From b0d35760346597b549f85b4c55406f5f0a06a3ba Mon Sep 17 00:00:00 2001 From: status-im-auto Date: Sat, 2 Nov 2024 18:54:09 +0000 Subject: [PATCH] Updates --- buddybook/.vite/manifest.json | 100 ++++++------ .../{ccip-D9LV_s6c.js => ccip-C1WRCCe-.js} | 2 +- ...{events-CHFTlyqt.js => events-_Z2_TJp5.js} | 2 +- buddybook/assets/hooks.module-BoePljmY.js | 1 + buddybook/assets/hooks.module-CBpTII2E.js | 1 - buddybook/assets/index-1C-dIFy4.js | 2 + .../{index-D4poE_Tm.js => index-B0w2h4-W.js} | 2 +- .../{index-C5SJQ4cM.js => index-BcaB-heU.js} | 2 +- .../{index-iQrFj71y.js => index-D6T2G_iY.js} | 34 ++-- .../{index-DaaUGS07.js => index-DSEy00EN.js} | 2 +- .../{index-BRDupqIG.js => index-Ds5ZBbkh.js} | 14 +- buddybook/assets/index-Vk_Kr0Nw.js | 2 - .../{index-CLqSQ1yP.js => index-mI-wCQlz.js} | 146 +++++++++--------- buddybook/assets/index.es-BvE4YOl7.js | 70 --------- buddybook/assets/index.es-pymM7oJc.js | 70 +++++++++ ...risln6.js => inherits_browser-DVmoQh9i.js} | 2 +- buddybook/favicon.svg | 4 + buddybook/index.html | 19 ++- flush-notes/404.html | 2 +- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 flush-notes/index.html | 2 +- flush-notes/index.txt | 2 +- flush-notes/view.html | 2 +- flush-notes/view.txt | 2 +- 25 files changed, 252 insertions(+), 233 deletions(-) rename buddybook/assets/{ccip-D9LV_s6c.js => ccip-C1WRCCe-.js} (97%) rename buddybook/assets/{events-CHFTlyqt.js => events-_Z2_TJp5.js} (98%) create mode 100644 buddybook/assets/hooks.module-BoePljmY.js delete mode 100644 buddybook/assets/hooks.module-CBpTII2E.js create mode 100644 buddybook/assets/index-1C-dIFy4.js rename buddybook/assets/{index-D4poE_Tm.js => index-B0w2h4-W.js} (99%) rename buddybook/assets/{index-C5SJQ4cM.js => index-BcaB-heU.js} (64%) rename buddybook/assets/{index-iQrFj71y.js => index-D6T2G_iY.js} (65%) rename buddybook/assets/{index-DaaUGS07.js => index-DSEy00EN.js} (98%) rename buddybook/assets/{index-BRDupqIG.js => index-Ds5ZBbkh.js} (85%) delete mode 100644 buddybook/assets/index-Vk_Kr0Nw.js rename buddybook/assets/{index-CLqSQ1yP.js => index-mI-wCQlz.js} (65%) delete mode 100644 buddybook/assets/index.es-BvE4YOl7.js create mode 100644 buddybook/assets/index.es-pymM7oJc.js rename buddybook/assets/{inherits_browser-Dprisln6.js => inherits_browser-DVmoQh9i.js} (85%) create mode 100644 buddybook/favicon.svg rename flush-notes/_next/static/{rp4Ih8fj9YecDRnymfEUx => YbqkI6PxL4I-BPyh4Nimw}/_buildManifest.js (100%) rename flush-notes/_next/static/{rp4Ih8fj9YecDRnymfEUx => YbqkI6PxL4I-BPyh4Nimw}/_ssgManifest.js (100%) diff --git a/buddybook/.vite/manifest.json b/buddybook/.vite/manifest.json index 6c4dbbd..a0715ab 100644 --- a/buddybook/.vite/manifest.json +++ b/buddybook/.vite/manifest.json @@ -1,50 +1,22 @@ { - "_events-CHFTlyqt.js": { - "file": "assets/events-CHFTlyqt.js", + "_events-_Z2_TJp5.js": { + "file": "assets/events-_Z2_TJp5.js", "name": "events", "imports": [ "index.html" ] }, - "_hooks.module-CBpTII2E.js": { - "file": "assets/hooks.module-CBpTII2E.js", + "_hooks.module-BoePljmY.js": { + "file": "assets/hooks.module-BoePljmY.js", "name": "hooks.module", "imports": [ "index.html", - "_events-CHFTlyqt.js", - "_inherits_browser-Dprisln6.js" + "_events-_Z2_TJp5.js", + "_inherits_browser-DVmoQh9i.js" ] }, - "_index-BRDupqIG.js": { - "file": "assets/index-BRDupqIG.js", - "name": "index", - "isDynamicEntry": true, - "imports": [ - "index.html", - "_inherits_browser-Dprisln6.js", - "_hooks.module-CBpTII2E.js", - "_events-CHFTlyqt.js" - ] - }, - "_index-C5SJQ4cM.js": { - "file": "assets/index-C5SJQ4cM.js", - "name": "index", - "isDynamicEntry": true, - "imports": [ - "index.html", - "_hooks.module-CBpTII2E.js" - ] - }, - "_index-DaaUGS07.js": { - "file": "assets/index-DaaUGS07.js", - "name": "index", - "isDynamicEntry": true, - "imports": [ - "_events-CHFTlyqt.js" - ] - }, - "_index-Vk_Kr0Nw.js": { - "file": "assets/index-Vk_Kr0Nw.js", + "_index-1C-dIFy4.js": { + "file": "assets/index-1C-dIFy4.js", "name": "index", "isDynamicEntry": true, "imports": [ @@ -54,24 +26,52 @@ "node_modules/@walletconnect/modal-ui/dist/index.js" ] }, - "_inherits_browser-Dprisln6.js": { - "file": "assets/inherits_browser-Dprisln6.js", + "_index-BcaB-heU.js": { + "file": "assets/index-BcaB-heU.js", + "name": "index", + "isDynamicEntry": true, + "imports": [ + "index.html", + "_hooks.module-BoePljmY.js" + ] + }, + "_index-DSEy00EN.js": { + "file": "assets/index-DSEy00EN.js", + "name": "index", + "isDynamicEntry": true, + "imports": [ + "_events-_Z2_TJp5.js" + ] + }, + "_index-Ds5ZBbkh.js": { + "file": "assets/index-Ds5ZBbkh.js", + "name": "index", + "isDynamicEntry": true, + "imports": [ + "index.html", + "_inherits_browser-DVmoQh9i.js", + "_hooks.module-BoePljmY.js", + "_events-_Z2_TJp5.js" + ] + }, + "_inherits_browser-DVmoQh9i.js": { + "file": "assets/inherits_browser-DVmoQh9i.js", "name": "inherits_browser", "imports": [ "index.html" ] }, "index.html": { - "file": "assets/index-CLqSQ1yP.js", + "file": "assets/index-mI-wCQlz.js", "name": "index", "src": "index.html", "isEntry": true, "dynamicImports": [ "node_modules/viem/_esm/utils/ccip.js", - "_index-C5SJQ4cM.js", - "_index-BRDupqIG.js", + "_index-BcaB-heU.js", + "_index-Ds5ZBbkh.js", "node_modules/@safe-global/safe-apps-sdk/dist/esm/index.js", - "_index-DaaUGS07.js", + "_index-DSEy00EN.js", "node_modules/@walletconnect/ethereum-provider/dist/index.es.js" ], "css": [ @@ -79,7 +79,7 @@ ] }, "node_modules/@safe-global/safe-apps-sdk/dist/esm/index.js": { - "file": "assets/index-D4poE_Tm.js", + "file": "assets/index-B0w2h4-W.js", "name": "index", "src": "node_modules/@safe-global/safe-apps-sdk/dist/esm/index.js", "isDynamicEntry": true, @@ -88,31 +88,31 @@ ] }, "node_modules/@walletconnect/ethereum-provider/dist/index.es.js": { - "file": "assets/index.es-BvE4YOl7.js", + "file": "assets/index.es-pymM7oJc.js", "name": "index.es", "src": "node_modules/@walletconnect/ethereum-provider/dist/index.es.js", "isDynamicEntry": true, "imports": [ "index.html", - "_events-CHFTlyqt.js", - "_inherits_browser-Dprisln6.js" + "_events-_Z2_TJp5.js", + "_inherits_browser-DVmoQh9i.js" ], "dynamicImports": [ - "_index-Vk_Kr0Nw.js" + "_index-1C-dIFy4.js" ] }, "node_modules/@walletconnect/modal-ui/dist/index.js": { - "file": "assets/index-iQrFj71y.js", + "file": "assets/index-D6T2G_iY.js", "name": "index", "src": "node_modules/@walletconnect/modal-ui/dist/index.js", "isDynamicEntry": true, "imports": [ - "_index-Vk_Kr0Nw.js", + "_index-1C-dIFy4.js", "index.html" ] }, "node_modules/viem/_esm/utils/ccip.js": { - "file": "assets/ccip-D9LV_s6c.js", + "file": "assets/ccip-C1WRCCe-.js", "name": "ccip", "src": "node_modules/viem/_esm/utils/ccip.js", "isDynamicEntry": true, diff --git a/buddybook/assets/ccip-D9LV_s6c.js b/buddybook/assets/ccip-C1WRCCe-.js similarity index 97% rename from buddybook/assets/ccip-D9LV_s6c.js rename to buddybook/assets/ccip-C1WRCCe-.js index d8c7ea8..2111488 100644 --- a/buddybook/assets/ccip-D9LV_s6c.js +++ b/buddybook/assets/ccip-C1WRCCe-.js @@ -1 +1 @@ -import{i as h,I as m,v as p,w,x as g,y as E,z as x,c as O,e as b,H as y,A as M}from"./index-CLqSQ1yP.js";function R(s,e){if(!h(s,{strict:!1}))throw new m({address:s});if(!h(e,{strict:!1}))throw new m({address:e});return s.toLowerCase()===e.toLowerCase()}class $ extends p{constructor({callbackSelector:e,cause:a,data:n,extraData:c,sender:d,urls:t}){var i;super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],(i=a.metaMessages)!=null&&i.length?"":[],"Offchain Gateway Call:",t&&[" Gateway URL(s):",...t.map(f=>` ${w(f)}`)],` Sender: ${d}`,` Data: ${n}`,` Callback selector: ${e}`,` Extra data: ${c}`].flat(),name:"OffchainLookupError"})}}class A extends p{constructor({result:e,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${w(a)}`,`Response: ${g(e)}`],name:"OffchainLookupResponseMalformedError"})}}class S extends p{constructor({sender:e,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${e}`],name:"OffchainLookupSenderMismatchError"})}}const T="0x556f1830",q={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function v(s,{blockNumber:e,blockTag:a,data:n,to:c}){const{args:d}=E({data:n,abi:[q]}),[t,i,f,r,o]=d,{ccipRead:u}=s,k=u&&typeof(u==null?void 0:u.request)=="function"?u.request:C;try{if(!R(c,t))throw new S({sender:t,to:c});const l=await k({data:f,sender:t,urls:i}),{data:L}=await x(s,{blockNumber:e,blockTag:a,data:O([r,b([{type:"bytes"},{type:"bytes"}],[l,o])]),to:c});return L}catch(l){throw new $({callbackSelector:r,cause:l,data:n,extraData:o,sender:t,urls:i})}}async function C({data:s,sender:e,urls:a}){var c;let n=new Error("An unknown error occurred.");for(let d=0;d` ${w(f)}`)],` Sender: ${d}`,` Data: ${n}`,` Callback selector: ${e}`,` Extra data: ${c}`].flat(),name:"OffchainLookupError"})}}class A extends p{constructor({result:e,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${w(a)}`,`Response: ${g(e)}`],name:"OffchainLookupResponseMalformedError"})}}class S extends p{constructor({sender:e,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${e}`],name:"OffchainLookupSenderMismatchError"})}}const T="0x556f1830",q={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function v(s,{blockNumber:e,blockTag:a,data:n,to:c}){const{args:d}=E({data:n,abi:[q]}),[t,i,f,r,o]=d,{ccipRead:u}=s,k=u&&typeof(u==null?void 0:u.request)=="function"?u.request:C;try{if(!R(c,t))throw new S({sender:t,to:c});const l=await k({data:f,sender:t,urls:i}),{data:L}=await x(s,{blockNumber:e,blockTag:a,data:O([r,b([{type:"bytes"},{type:"bytes"}],[l,o])]),to:c});return L}catch(l){throw new $({callbackSelector:r,cause:l,data:n,extraData:o,sender:t,urls:i})}}async function C({data:s,sender:e,urls:a}){var c;let n=new Error("An unknown error occurred.");for(let d=0;d0&&(s=n[0]),s instanceof Error)throw s;var u=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw u.context=s,u}var c=f[e];if(c===void 0)return!1;if(typeof c=="function")d(c,this,n);else for(var h=c.length,O=E(c,h),r=0;r0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,j(u)}return t}o.prototype.addListener=function(e,n){return g(this,e,n,!1)};o.prototype.on=o.prototype.addListener;o.prototype.prependListener=function(e,n){return g(this,e,n,!0)};function R(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=R.bind(r);return i.listener=n,r.wrapFn=i,i}o.prototype.once=function(e,n){return v(n),this.on(e,_(this,e,n)),this};o.prototype.prependOnceListener=function(e,n){return v(n),this.prependListener(e,_(this,e,n)),this};o.prototype.removeListener=function(e,n){var r,i,f,s,u;if(v(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(f=-1,s=r.length-1;s>=0;s--)if(r[s]===n||r[s].listener===n){u=r[s].listener,f=s;break}if(f<0)return this;f===0?r.shift():N(r,f),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||n)}return this};o.prototype.off=o.prototype.removeListener;o.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var f=Object.keys(r),s;for(i=0;i=0;i--)this.removeListener(e,n[i]);return this};function w(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?M(i):E(i,i.length)}o.prototype.listeners=function(e){return w(this,e,!0)};o.prototype.rawListeners=function(e){return w(this,e,!1)};o.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):b.call(t,e)};o.prototype.listenerCount=b;function b(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?l(this._events):[]};function E(t,e){for(var n=new Array(e),r=0;r0&&(s=n[0]),s instanceof Error)throw s;var u=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw u.context=s,u}var c=f[e];if(c===void 0)return!1;if(typeof c=="function")d(c,this,n);else for(var h=c.length,O=E(c,h),r=0;r0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,j(u)}return t}o.prototype.addListener=function(e,n){return g(this,e,n,!1)};o.prototype.on=o.prototype.addListener;o.prototype.prependListener=function(e,n){return g(this,e,n,!0)};function R(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=R.bind(r);return i.listener=n,r.wrapFn=i,i}o.prototype.once=function(e,n){return v(n),this.on(e,_(this,e,n)),this};o.prototype.prependOnceListener=function(e,n){return v(n),this.prependListener(e,_(this,e,n)),this};o.prototype.removeListener=function(e,n){var r,i,f,s,u;if(v(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(f=-1,s=r.length-1;s>=0;s--)if(r[s]===n||r[s].listener===n){u=r[s].listener,f=s;break}if(f<0)return this;f===0?r.shift():N(r,f),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||n)}return this};o.prototype.off=o.prototype.removeListener;o.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var f=Object.keys(r),s;for(i=0;i=0;i--)this.removeListener(e,n[i]);return this};function w(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?M(i):E(i,i.length)}o.prototype.listeners=function(e){return w(this,e,!0)};o.prototype.rawListeners=function(e){return w(this,e,!1)};o.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):b.call(t,e)};o.prototype.listenerCount=b;function b(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?l(this._events):[]};function E(t,e){for(var n=new Array(e),r=0;r0?this.tail.next=s:this.head=s,this.tail=s,++this.length}},{key:"unshift",value:function(E){var s={data:E,next:this.head};this.length===0&&(this.tail=s),this.head=s,++this.length}},{key:"shift",value:function(){if(this.length!==0){var E=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,E}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(E){if(this.length===0)return"";for(var s=this.head,p=""+s.data;s=s.next;)p+=E+s.data;return p}},{key:"concat",value:function(E){if(this.length===0)return h.alloc(0);for(var s=h.allocUnsafe(E>>>0),p=this.head,C=0;p;)v(p.data,s,C),C+=p.data.length,p=p.next;return s}},{key:"consume",value:function(E,s){var p;return ER.length?R.length:E;if(S===R.length?C+=R:C+=R.slice(0,E),E-=S,E===0){S===R.length?(++p,s.next?this.head=s.next:this.head=this.tail=null):(this.head=s,s.data=R.slice(S));break}++p}return this.length-=p,C}},{key:"_getBuffer",value:function(E){var s=h.allocUnsafe(E),p=this.head,C=1;for(p.data.copy(s),E-=p.data.length;p=p.next;){var R=p.data,S=E>R.length?R.length:E;if(R.copy(s,s.length-E,0,S),E-=S,E===0){S===R.length?(++C,p.next?this.head=p.next:this.head=this.tail=null):(this.head=p,p.data=R.slice(S));break}++C}return this.length-=C,s}},{key:w,value:function(E,s){return _(this,t(t({},s),{},{depth:0,customInspect:!1}))}}]),m}(),Yt}var pe={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0};function zi(e,t){var r=this,i=this._readableState&&this._readableState.destroyed,n=this._writableState&&this._writableState.destroyed;return i||n?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,pe.nextTick(or,this,e)):pe.nextTick(or,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(f){!t&&f?r._writableState?r._writableState.errorEmitted?pe.nextTick(ze,r):(r._writableState.errorEmitted=!0,pe.nextTick(mr,r,f)):pe.nextTick(mr,r,f):t?(pe.nextTick(ze,r),t(f)):pe.nextTick(ze,r)}),this)}function mr(e,t){or(e,t),ze(e)}function ze(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function Vi(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function or(e,t){e.emit("error",t)}function Gi(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}var ii={destroy:zi,undestroy:Vi,errorOrDestroy:Gi},ve={};function Ki(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var ni={};function J(e,t,r){r||(r=Error);function i(f,l,u){return typeof t=="string"?t:t(f,l,u)}var n=function(f){Ki(l,f);function l(u,b,h){return f.call(this,i(u,b,h))||this}return l}(r);n.prototype.name=r.name,n.prototype.code=e,ni[e]=n}function Sr(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(i){return String(i)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function Yi(e,t,r){return e.substr(0,t.length)===t}function Ji(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function Xi(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}J("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);J("ERR_INVALID_ARG_TYPE",function(e,t,r){var i;typeof t=="string"&&Yi(t,"not ")?(i="must not be",t=t.replace(/^not /,"")):i="must be";var n;if(Ji(e," argument"))n="The ".concat(e," ").concat(i," ").concat(Sr(t,"type"));else{var f=Xi(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(f," ").concat(i," ").concat(Sr(t,"type"))}return n+=". Received type ".concat(typeof r),n},TypeError);J("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");J("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});J("ERR_STREAM_PREMATURE_CLOSE","Premature close");J("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});J("ERR_MULTIPLE_CALLBACK","Callback called multiple times");J("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");J("ERR_STREAM_WRITE_AFTER_END","write after end");J("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);J("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);J("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");ve.codes=ni;var Qi=ve.codes.ERR_INVALID_OPT_VALUE;function Zi(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function en(e,t,r,i){var n=Zi(t,i,r);if(n!=null){if(!(isFinite(n)&&Math.floor(n)===n)||n<0){var f=i?r:"highWaterMark";throw new Qi(f,n)}return Math.floor(n)}return e.objectMode?16:16*1024}var ai={getHighWaterMark:en},tn=rn;function rn(e,t){if(Jt("noDeprecation"))return e;var r=!1;function i(){if(!r){if(Jt("throwDeprecation"))throw new Error(t);Jt("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return i}function Jt(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var Xt,Rr;function oi(){if(Rr)return Xt;Rr=1;var e={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0};Xt=D;function t(c){var d=this;this.next=null,this.entry=null,this.finish=function(){q(d,c)}}var r;D.WritableState=M;var i={deprecate:tn},n=ri,f=Oe.Buffer,l=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function u(c){return f.from(c)}function b(c){return f.isBuffer(c)||c instanceof l}var h=ii,g=ai,_=g.getHighWaterMark,w=ve.codes,v=w.ERR_INVALID_ARG_TYPE,m=w.ERR_METHOD_NOT_IMPLEMENTED,T=w.ERR_MULTIPLE_CALLBACK,E=w.ERR_STREAM_CANNOT_PIPE,s=w.ERR_STREAM_DESTROYED,p=w.ERR_STREAM_NULL_VALUES,C=w.ERR_STREAM_WRITE_AFTER_END,R=w.ERR_UNKNOWN_ENCODING,S=h.errorOrDestroy;Z(D,n);function N(){}function M(c,d,x){r=r||Se(),c=c||{},typeof x!="boolean"&&(x=d instanceof r),this.objectMode=!!c.objectMode,x&&(this.objectMode=this.objectMode||!!c.writableObjectMode),this.highWaterMark=_(this,c,"writableHighWaterMark",x),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var k=c.decodeStrings===!1;this.decodeStrings=!k,this.defaultEncoding=c.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(O){he(d,O)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=c.emitClose!==!1,this.autoDestroy=!!c.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}M.prototype.getBuffer=function(){for(var d=this.bufferedRequest,x=[];d;)x.push(d),d=d.next;return x},function(){try{Object.defineProperty(M.prototype,"buffer",{get:i.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var P;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(P=Function.prototype[Symbol.hasInstance],Object.defineProperty(D,Symbol.hasInstance,{value:function(d){return P.call(this,d)?!0:this!==D?!1:d&&d._writableState instanceof M}})):P=function(d){return d instanceof this};function D(c){r=r||Se();var d=this instanceof r;if(!d&&!P.call(D,this))return new D(c);this._writableState=new M(c,this,d),this.writable=!0,c&&(typeof c.write=="function"&&(this._write=c.write),typeof c.writev=="function"&&(this._writev=c.writev),typeof c.destroy=="function"&&(this._destroy=c.destroy),typeof c.final=="function"&&(this._final=c.final)),n.call(this)}D.prototype.pipe=function(){S(this,new E)};function B(c,d){var x=new C;S(c,x),e.nextTick(d,x)}function j(c,d,x,k){var O;return x===null?O=new p:typeof x!="string"&&!d.objectMode&&(O=new v("chunk",["string","Buffer"],x)),O?(S(c,O),e.nextTick(k,O),!1):!0}D.prototype.write=function(c,d,x){var k=this._writableState,O=!1,a=!k.objectMode&&b(c);return a&&!f.isBuffer(c)&&(c=u(c)),typeof d=="function"&&(x=d,d=null),a?d="buffer":d||(d=k.defaultEncoding),typeof x!="function"&&(x=N),k.ending?B(this,x):(a||j(this,k,c,x))&&(k.pendingcb++,O=W(this,k,a,c,d,x)),O},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var c=this._writableState;c.corked&&(c.corked--,!c.writing&&!c.corked&&!c.bufferProcessing&&c.bufferedRequest&&Q(this,c))},D.prototype.setDefaultEncoding=function(d){if(typeof d=="string"&&(d=d.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((d+"").toLowerCase())>-1))throw new R(d);return this._writableState.defaultEncoding=d,this},Object.defineProperty(D.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function X(c,d,x){return!c.objectMode&&c.decodeStrings!==!1&&typeof d=="string"&&(d=f.from(d,x)),d}Object.defineProperty(D.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function W(c,d,x,k,O,a){if(!x){var o=X(d,k,O);k!==o&&(x=!0,O="buffer",k=o)}var y=d.objectMode?1:k.length;d.length+=y;var A=d.length */var Cr;function nn(){return Cr||(Cr=1,function(e,t){var r=Oe,i=r.Buffer;function n(l,u){for(var b in l)u[b]=l[b]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(n(r,t),t.Buffer=f);function f(l,u,b){return i(l,u,b)}f.prototype=Object.create(i.prototype),n(i,f),f.from=function(l,u,b){if(typeof l=="number")throw new TypeError("Argument must not be a number");return i(l,u,b)},f.alloc=function(l,u,b){if(typeof l!="number")throw new TypeError("Argument must be a number");var h=i(l);return u!==void 0?typeof b=="string"?h.fill(u,b):h.fill(u):h.fill(0),h},f.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return i(l)},f.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(l)}}(je,je.exports)),je.exports}var Ar;function Br(){if(Ar)return Zt;Ar=1;var e=nn().Buffer,t=e.isEncoding||function(s){switch(s=""+s,s&&s.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(s){if(!s)return"utf8";for(var p;;)switch(s){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return s;default:if(p)return;s=(""+s).toLowerCase(),p=!0}}function i(s){var p=r(s);if(typeof p!="string"&&(e.isEncoding===t||!t(s)))throw new Error("Unknown encoding: "+s);return p||s}Zt.StringDecoder=n;function n(s){this.encoding=i(s);var p;switch(this.encoding){case"utf16le":this.text=_,this.end=w,p=4;break;case"utf8":this.fillLast=b,p=4;break;case"base64":this.text=v,this.end=m,p=3;break;default:this.write=T,this.end=E;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=e.allocUnsafe(p)}n.prototype.write=function(s){if(s.length===0)return"";var p,C;if(this.lastNeed){if(p=this.fillLast(s),p===void 0)return"";C=this.lastNeed,this.lastNeed=0}else C=0;return C>5===6?2:s>>4===14?3:s>>3===30?4:s>>6===2?-1:-2}function l(s,p,C){var R=p.length-1;if(R=0?(S>0&&(s.lastNeed=S-1),S):--R=0?(S>0&&(s.lastNeed=S-2),S):--R=0?(S>0&&(S===2?S=0:s.lastNeed=S-3),S):0))}function u(s,p,C){if((p[0]&192)!==128)return s.lastNeed=0,"�";if(s.lastNeed>1&&p.length>1){if((p[1]&192)!==128)return s.lastNeed=1,"�";if(s.lastNeed>2&&p.length>2&&(p[2]&192)!==128)return s.lastNeed=2,"�"}}function b(s){var p=this.lastTotal-this.lastNeed,C=u(this,s);if(C!==void 0)return C;if(this.lastNeed<=s.length)return s.copy(this.lastChar,p,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);s.copy(this.lastChar,p,0,s.length),this.lastNeed-=s.length}function h(s,p){var C=l(this,s,p);if(!this.lastNeed)return s.toString("utf8",p);this.lastTotal=C;var R=s.length-(C-this.lastNeed);return s.copy(this.lastChar,0,R),s.toString("utf8",p,R)}function g(s){var p=s&&s.length?this.write(s):"";return this.lastNeed?p+"�":p}function _(s,p){if((s.length-p)%2===0){var C=s.toString("utf16le",p);if(C){var R=C.charCodeAt(C.length-1);if(R>=55296&&R<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=s[s.length-2],this.lastChar[1]=s[s.length-1],C.slice(0,-1)}return C}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=s[s.length-1],s.toString("utf16le",p,s.length-1)}function w(s){var p=s&&s.length?this.write(s):"";if(this.lastNeed){var C=this.lastTotal-this.lastNeed;return p+this.lastChar.toString("utf16le",0,C)}return p}function v(s,p){var C=(s.length-p)%3;return C===0?s.toString("base64",p):(this.lastNeed=3-C,this.lastTotal=3,C===1?this.lastChar[0]=s[s.length-1]:(this.lastChar[0]=s[s.length-2],this.lastChar[1]=s[s.length-1]),s.toString("base64",p,s.length-C))}function m(s){var p=s&&s.length?this.write(s):"";return this.lastNeed?p+this.lastChar.toString("base64",0,3-this.lastNeed):p}function T(s){return s.toString(this.encoding)}function E(s){return s&&s.length?this.write(s):""}return Zt}var kr=ve.codes.ERR_STREAM_PREMATURE_CLOSE;function an(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),n=0;n0)if(typeof o!="string"&&!L.objectMode&&Object.getPrototypeOf(o)!==n.prototype&&(o=l(o)),A)L.endEmitted?N(a,new p):X(a,L,o,!0);else if(L.ended)N(a,new E);else{if(L.destroyed)return!1;L.reading=!1,L.decoder&&!y?(o=L.decoder.write(o),L.objectMode||o.length!==0?X(a,L,o,!1):Q(a,L)):X(a,L,o,!1)}else A||(L.reading=!1,Q(a,L))}return!L.ended&&(L.length=V?a=V:(a--,a|=a>>>1,a|=a>>>2,a|=a>>>4,a|=a>>>8,a|=a>>>16,a++),a}function ne(a,o){return a<=0||o.length===0&&o.ended?0:o.objectMode?1:a!==a?o.flowing&&o.length?o.buffer.head.data.length:o.length:(a>o.highWaterMark&&(o.highWaterMark=G(a)),a<=o.length?a:o.ended?o.length:(o.needReadable=!0,0))}B.prototype.read=function(a){h("read",a),a=parseInt(a,10);var o=this._readableState,y=a;if(a!==0&&(o.emittedReadable=!1),a===0&&o.needReadable&&((o.highWaterMark!==0?o.length>=o.highWaterMark:o.length>0)||o.ended))return h("read: emitReadable",o.length,o.ended),o.length===0&&o.ended?x(this):K(this),null;if(a=ne(a,o),a===0&&o.ended)return o.length===0&&x(this),null;var A=o.needReadable;h("need readable",A),(o.length===0||o.length-a0?U=d(a,o):U=null,U===null?(o.needReadable=o.length<=o.highWaterMark,a=0):(o.length-=a,o.awaitDrain=0),o.length===0&&(o.ended||(o.needReadable=!0),y!==a&&o.ended&&x(this)),U!==null&&this.emit("data",U),U};function he(a,o){if(h("onEofChunk"),!o.ended){if(o.decoder){var y=o.decoder.end();y&&y.length&&(o.buffer.push(y),o.length+=o.objectMode?1:y.length)}o.ended=!0,o.sync?K(a):(o.needReadable=!1,o.emittedReadable||(o.emittedReadable=!0,ee(a)))}}function K(a){var o=a._readableState;h("emitReadable",o.needReadable,o.emittedReadable),o.needReadable=!1,o.emittedReadable||(h("emitReadable",o.flowing),o.emittedReadable=!0,e.nextTick(ee,a))}function ee(a){var o=a._readableState;h("emitReadable_",o.destroyed,o.length,o.ended),!o.destroyed&&(o.length||o.ended)&&(a.emit("readable"),o.emittedReadable=!1),o.needReadable=!o.flowing&&!o.ended&&o.length<=o.highWaterMark,c(a)}function Q(a,o){o.readingMore||(o.readingMore=!0,e.nextTick(ae,a,o))}function ae(a,o){for(;!o.reading&&!o.ended&&(o.length1&&O(A.pipes,a)!==-1)&&!Be&&(h("false write response, pause",A.awaitDrain),A.awaitDrain++),y.pause())}function Ee(re){h("onerror",re),ce(),a.removeListener("error",Ee),r(a,"error")===0&&N(a,re)}P(a,"error",Ee);function xe(){a.removeListener("finish",me),ce()}a.once("close",xe);function me(){h("onfinish"),a.removeListener("close",xe),ce()}a.once("finish",me);function ce(){h("unpipe"),y.unpipe(a)}return a.emit("pipe",y),A.flowing||(h("pipe resume"),y.resume()),a};function _e(a){return function(){var y=a._readableState;h("pipeOnDrain",y.awaitDrain),y.awaitDrain&&y.awaitDrain--,y.awaitDrain===0&&r(a,"data")&&(y.flowing=!0,c(a))}}B.prototype.unpipe=function(a){var o=this._readableState,y={hasUnpiped:!1};if(o.pipesCount===0)return this;if(o.pipesCount===1)return a&&a!==o.pipes?this:(a||(a=o.pipes),o.pipes=null,o.pipesCount=0,o.flowing=!1,a&&a.emit("unpipe",this,y),this);if(!a){var A=o.pipes,U=o.pipesCount;o.pipes=null,o.pipesCount=0,o.flowing=!1;for(var L=0;L0,A.flowing!==!1&&this.resume()):a==="readable"&&!A.endEmitted&&!A.readableListening&&(A.readableListening=A.needReadable=!0,A.flowing=!1,A.emittedReadable=!1,h("on readable",A.length,A.reading),A.length?K(this):A.reading||e.nextTick(Y,this)),y},B.prototype.addListener=B.prototype.on,B.prototype.removeListener=function(a,o){var y=i.prototype.removeListener.call(this,a,o);return a==="readable"&&e.nextTick(te,this),y},B.prototype.removeAllListeners=function(a){var o=i.prototype.removeAllListeners.apply(this,arguments);return(a==="readable"||a===void 0)&&e.nextTick(te,this),o};function te(a){var o=a._readableState;o.readableListening=a.listenerCount("readable")>0,o.resumeScheduled&&!o.paused?o.flowing=!0:a.listenerCount("data")>0&&a.resume()}function Y(a){h("readable nexttick read 0"),a.read(0)}B.prototype.resume=function(){var a=this._readableState;return a.flowing||(h("resume"),a.flowing=!a.readableListening,oe(this,a)),a.paused=!1,this};function oe(a,o){o.resumeScheduled||(o.resumeScheduled=!0,e.nextTick(q,a,o))}function q(a,o){h("resume",o.reading),o.reading||a.read(0),o.resumeScheduled=!1,a.emit("resume"),c(a),o.flowing&&!o.reading&&a.read(0)}B.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function c(a){var o=a._readableState;for(h("flow",o.flowing);o.flowing&&a.read()!==null;);}B.prototype.wrap=function(a){var o=this,y=this._readableState,A=!1;a.on("end",function(){if(h("wrapped end"),y.decoder&&!y.ended){var I=y.decoder.end();I&&I.length&&o.push(I)}o.push(null)}),a.on("data",function(I){if(h("wrapped data"),y.decoder&&(I=y.decoder.write(I)),!(y.objectMode&&I==null)&&!(!y.objectMode&&(!I||!I.length))){var fe=o.push(I);fe||(A=!0,a.pause())}});for(var U in a)this[U]===void 0&&typeof a[U]=="function"&&(this[U]=function(fe){return function(){return a[fe].apply(a,arguments)}}(U));for(var L=0;L=o.length?(o.decoder?y=o.buffer.join(""):o.buffer.length===1?y=o.buffer.first():y=o.buffer.concat(o.length),o.buffer.clear()):y=o.buffer.consume(a,o.decoder),y}function x(a){var o=a._readableState;h("endReadable",o.endEmitted),o.endEmitted||(o.ended=!0,e.nextTick(k,o,a))}function k(a,o){if(h("endReadableNT",a.endEmitted,a.length),!a.endEmitted&&a.length===0&&(a.endEmitted=!0,o.readable=!1,o.emit("end"),a.autoDestroy)){var y=o._writableState;(!y||y.autoDestroy&&y.finished)&&o.destroy()}}typeof Symbol=="function"&&(B.from=function(a,o){return S===void 0&&(S=ln()),S(B,a,o)});function O(a,o){for(var y=0,A=a.length;y0;return En(l,b,h,function(g){n||(n=g),g&&f.forEach(Pr),!b&&(f.forEach(Pr),i(n))})});return t.reduce(xn)}var Rn=Sn;(function(e,t){t=e.exports=si(),t.Stream=t,t.Readable=t,t.Writable=oi(),t.Duplex=Se(),t.Transform=li,t.PassThrough=bn,t.finished=pr,t.pipeline=Rn})(ar,ar.exports);var _i=ar.exports;const{Transform:Tn}=_i;var Cn=e=>class ci extends Tn{constructor(r,i,n,f,l){super(l),this._rate=r,this._capacity=i,this._delimitedSuffix=n,this._hashBitLength=f,this._options=l,this._state=new e,this._state.initialize(r,i),this._finalized=!1}_transform(r,i,n){let f=null;try{this.update(r,i)}catch(l){f=l}n(f)}_flush(r){let i=null;try{this.push(this.digest())}catch(n){i=n}r(i)}update(r,i){if(!Buffer.isBuffer(r)&&typeof r!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer.isBuffer(r)||(r=Buffer.from(r,i)),this._state.absorb(r),this}digest(r){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let i=this._state.squeeze(this._hashBitLength/8);return r!==void 0&&(i=i.toString(r)),this._resetState(),i}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const r=new ci(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(r._state),r._finalized=this._finalized,r}};const{Transform:An}=_i;var Bn=e=>class di extends An{constructor(r,i,n,f){super(f),this._rate=r,this._capacity=i,this._delimitedSuffix=n,this._options=f,this._state=new e,this._state.initialize(r,i),this._finalized=!1}_transform(r,i,n){let f=null;try{this.update(r,i)}catch(l){f=l}n(f)}_flush(){}_read(r){this.push(this.squeeze(r))}update(r,i){if(!Buffer.isBuffer(r)&&typeof r!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer.isBuffer(r)||(r=Buffer.from(r,i)),this._state.absorb(r),this}squeeze(r,i){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let n=this._state.squeeze(r);return i!==void 0&&(n=n.toString(i)),n}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const r=new di(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(r._state),r._finalized=this._finalized,r}};const kn=Cn,Mn=Bn;var Nn=function(e){const t=kn(e),r=Mn(e);return function(i,n){switch(typeof i=="string"?i.toLowerCase():i){case"keccak224":return new t(1152,448,null,224,n);case"keccak256":return new t(1088,512,null,256,n);case"keccak384":return new t(832,768,null,384,n);case"keccak512":return new t(576,1024,null,512,n);case"sha3-224":return new t(1152,448,6,224,n);case"sha3-256":return new t(1088,512,6,256,n);case"sha3-384":return new t(832,768,6,384,n);case"sha3-512":return new t(576,1024,6,512,n);case"shake128":return new r(1344,256,31,n);case"shake256":return new r(1088,512,31,n);default:throw new Error("Invald algorithm: "+i)}}},pi={};const Ir=[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];pi.p1600=function(e){for(let t=0;t<24;++t){const r=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],n=e[2]^e[12]^e[22]^e[32]^e[42],f=e[3]^e[13]^e[23]^e[33]^e[43],l=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],b=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],g=e[8]^e[18]^e[28]^e[38]^e[48],_=e[9]^e[19]^e[29]^e[39]^e[49];let w=g^(n<<1|f>>>31),v=_^(f<<1|n>>>31);const m=e[0]^w,T=e[1]^v,E=e[10]^w,s=e[11]^v,p=e[20]^w,C=e[21]^v,R=e[30]^w,S=e[31]^v,N=e[40]^w,M=e[41]^v;w=r^(l<<1|u>>>31),v=i^(u<<1|l>>>31);const P=e[2]^w,D=e[3]^v,B=e[12]^w,j=e[13]^v,X=e[22]^w,W=e[23]^v,V=e[32]^w,G=e[33]^v,ne=e[42]^w,he=e[43]^v;w=n^(b<<1|h>>>31),v=f^(h<<1|b>>>31);const K=e[4]^w,ee=e[5]^v,Q=e[14]^w,ae=e[15]^v,_e=e[24]^w,te=e[25]^v,Y=e[34]^w,oe=e[35]^v,q=e[44]^w,c=e[45]^v;w=l^(g<<1|_>>>31),v=u^(_<<1|g>>>31);const d=e[6]^w,x=e[7]^v,k=e[16]^w,O=e[17]^v,a=e[26]^w,o=e[27]^v,y=e[36]^w,A=e[37]^v,U=e[46]^w,L=e[47]^v;w=b^(r<<1|i>>>31),v=h^(i<<1|r>>>31);const I=e[8]^w,fe=e[9]^v,de=e[18]^w,Be=e[19]^v,qe=e[28]^w,ke=e[29]^v,Ee=e[38]^w,xe=e[39]^v,me=e[48]^w,ce=e[49]^v,re=m,ie=T,tt=s<<4|E>>>28,rt=E<<4|s>>>28,it=p<<3|C>>>29,nt=C<<3|p>>>29,at=S<<9|R>>>23,ot=R<<9|S>>>23,ft=N<<18|M>>>14,st=M<<18|N>>>14,lt=P<<1|D>>>31,ut=D<<1|P>>>31,ht=j<<12|B>>>20,_t=B<<12|j>>>20,ct=X<<10|W>>>22,dt=W<<10|X>>>22,pt=G<<13|V>>>19,bt=V<<13|G>>>19,vt=ne<<2|he>>>30,gt=he<<2|ne>>>30,yt=ee<<30|K>>>2,wt=K<<30|ee>>>2,Et=Q<<6|ae>>>26,xt=ae<<6|Q>>>26,mt=te<<11|_e>>>21,St=_e<<11|te>>>21,Rt=Y<<15|oe>>>17,Tt=oe<<15|Y>>>17,Ct=c<<29|q>>>3,At=q<<29|c>>>3,Bt=d<<28|x>>>4,kt=x<<28|d>>>4,Mt=O<<23|k>>>9,Nt=k<<23|O>>>9,Dt=a<<25|o>>>7,Lt=o<<25|a>>>7,Ot=y<<21|A>>>11,Pt=A<<21|y>>>11,It=L<<24|U>>>8,$t=U<<24|L>>>8,Ft=I<<27|fe>>>5,Ut=fe<<27|I>>>5,Ht=de<<20|Be>>>12,qt=Be<<20|de>>>12,jt=ke<<7|qe>>>25,Wt=qe<<7|ke>>>25,zt=Ee<<8|xe>>>24,Vt=xe<<8|Ee>>>24,Gt=me<<14|ce>>>18,Kt=ce<<14|me>>>18;e[0]=re^~ht&mt,e[1]=ie^~_t&St,e[10]=Bt^~Ht&it,e[11]=kt^~qt&nt,e[20]=lt^~Et&Dt,e[21]=ut^~xt&Lt,e[30]=Ft^~tt&ct,e[31]=Ut^~rt&dt,e[40]=yt^~Mt&jt,e[41]=wt^~Nt&Wt,e[2]=ht^~mt&Ot,e[3]=_t^~St&Pt,e[12]=Ht^~it&pt,e[13]=qt^~nt&bt,e[22]=Et^~Dt&zt,e[23]=xt^~Lt&Vt,e[32]=tt^~ct&Rt,e[33]=rt^~dt&Tt,e[42]=Mt^~jt&at,e[43]=Nt^~Wt&ot,e[4]=mt^~Ot&Gt,e[5]=St^~Pt&Kt,e[14]=it^~pt&Ct,e[15]=nt^~bt&At,e[24]=Dt^~zt&ft,e[25]=Lt^~Vt&st,e[34]=ct^~Rt&It,e[35]=dt^~Tt&$t,e[44]=jt^~at&vt,e[45]=Wt^~ot>,e[6]=Ot^~Gt&re,e[7]=Pt^~Kt&ie,e[16]=pt^~Ct&Bt,e[17]=bt^~At&kt,e[26]=zt^~ft<,e[27]=Vt^~st&ut,e[36]=Rt^~It&Ft,e[37]=Tt^~$t&Ut,e[46]=at^~vt&yt,e[47]=ot^~gt&wt,e[8]=Gt^~re&ht,e[9]=Kt^~ie&_t,e[18]=Ct^~Bt&Ht,e[19]=At^~kt&qt,e[28]=ft^~lt&Et,e[29]=st^~ut&xt,e[38]=It^~Ft&tt,e[39]=$t^~Ut&rt,e[48]=vt^~yt&Mt,e[49]=gt^~wt&Nt,e[0]^=Ir[t*2],e[1]^=Ir[t*2+1]}};const Ge=pi;function Ce(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}Ce.prototype.initialize=function(e,t){for(let r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1};Ce.prototype.absorb=function(e){for(let t=0;t>>8*(this.count%4)&255,this.count+=1,this.count===this.blockSize&&(Ge.p1600(this.state),this.count=0);return t};Ce.prototype.copy=function(e){for(let t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing};var Dn=Ce,Ja=Nn(Dn),bi={exports:{}},fr={exports:{}};(function(e,t){var r=Oe,i=r.Buffer;function n(l,u){for(var b in l)u[b]=l[b]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(n(r,t),t.Buffer=f);function f(l,u,b){return i(l,u,b)}n(i,f),f.from=function(l,u,b){if(typeof l=="number")throw new TypeError("Argument must not be a number");return i(l,u,b)},f.alloc=function(l,u,b){if(typeof l!="number")throw new TypeError("Argument must be a number");var h=i(l);return u!==void 0?typeof b=="string"?h.fill(u,b):h.fill(u):h.fill(0),h},f.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return i(l)},f.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(l)}})(fr,fr.exports);var ge=fr.exports,vi=ge.Buffer;function Xe(e,t){this._block=vi.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Xe.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=vi.from(e,t));for(var r=this._block,i=this._blockSize,n=e.length,f=this._len,l=0;l=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(r&4294967295)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var f=this._hash();return e?f.toString(e):f};Xe.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Ae=Xe,Ln=Z,gi=Ae,On=ge.Buffer,Pn=[1518500249,1859775393,-1894007588,-899497514],In=new Array(80);function Pe(){this.init(),this._w=In,gi.call(this,64,56)}Ln(Pe,gi);Pe.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function $n(e){return e<<5|e>>>27}function Fn(e){return e<<30|e>>>2}function Un(e,t,r,i){return e===0?t&r|~t&i:e===2?t&r|t&i|r&i:t^r^i}Pe.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,n=this._c|0,f=this._d|0,l=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=t[u-3]^t[u-8]^t[u-14]^t[u-16];for(var b=0;b<80;++b){var h=~~(b/20),g=$n(r)+Un(h,i,n,f)+l+t[b]+Pn[h]|0;l=f,f=n,n=Fn(i),i=r,r=g}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=f+this._d|0,this._e=l+this._e|0};Pe.prototype._hash=function(){var e=On.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Hn=Pe,qn=Z,yi=Ae,jn=ge.Buffer,Wn=[1518500249,1859775393,-1894007588,-899497514],zn=new Array(80);function Ie(){this.init(),this._w=zn,yi.call(this,64,56)}qn(Ie,yi);Ie.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Vn(e){return e<<1|e>>>31}function Gn(e){return e<<5|e>>>27}function Kn(e){return e<<30|e>>>2}function Yn(e,t,r,i){return e===0?t&r|~t&i:e===2?t&r|t&i|r&i:t^r^i}Ie.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,n=this._c|0,f=this._d|0,l=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=Vn(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var b=0;b<80;++b){var h=~~(b/20),g=Gn(r)+Yn(h,i,n,f)+l+t[b]+Wn[h]|0;l=f,f=n,n=Kn(i),i=r,r=g}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=f+this._d|0,this._e=l+this._e|0};Ie.prototype._hash=function(){var e=jn.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Jn=Ie,Xn=Z,wi=Ae,Qn=ge.Buffer,Zn=[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],ea=new Array(64);function $e(){this.init(),this._w=ea,wi.call(this,64,56)}Xn($e,wi);$e.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function ta(e,t,r){return r^e&(t^r)}function ra(e,t,r){return e&t|r&(e|t)}function ia(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function na(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function aa(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function oa(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}$e.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,n=this._c|0,f=this._d|0,l=this._e|0,u=this._f|0,b=this._g|0,h=this._h|0,g=0;g<16;++g)t[g]=e.readInt32BE(g*4);for(;g<64;++g)t[g]=oa(t[g-2])+t[g-7]+aa(t[g-15])+t[g-16]|0;for(var _=0;_<64;++_){var w=h+na(l)+ta(l,u,b)+Zn[_]+t[_]|0,v=ia(r)+ra(r,i,n)|0;h=b,b=u,u=l,l=f+w|0,f=n,n=i,i=r,r=w+v|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=f+this._d|0,this._e=l+this._e|0,this._f=u+this._f|0,this._g=b+this._g|0,this._h=h+this._h|0};$e.prototype._hash=function(){var e=Qn.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var Ei=$e,fa=Z,sa=Ei,la=Ae,ua=ge.Buffer,ha=new Array(64);function Qe(){this.init(),this._w=ha,la.call(this,64,56)}fa(Qe,sa);Qe.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};Qe.prototype._hash=function(){var e=ua.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var _a=Qe,ca=Z,xi=Ae,da=ge.Buffer,$r=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],pa=new Array(160);function Fe(){this.init(),this._w=pa,xi.call(this,128,112)}ca(Fe,xi);Fe.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Fr(e,t,r){return r^e&(t^r)}function Ur(e,t,r){return e&t|r&(e|t)}function Hr(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function qr(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function ba(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function va(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function ga(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function ya(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function z(e,t){return e>>>0>>0?1:0}Fe.prototype._update=function(e){for(var t=this._w,r=this._ah|0,i=this._bh|0,n=this._ch|0,f=this._dh|0,l=this._eh|0,u=this._fh|0,b=this._gh|0,h=this._hh|0,g=this._al|0,_=this._bl|0,w=this._cl|0,v=this._dl|0,m=this._el|0,T=this._fl|0,E=this._gl|0,s=this._hl|0,p=0;p<32;p+=2)t[p]=e.readInt32BE(p*4),t[p+1]=e.readInt32BE(p*4+4);for(;p<160;p+=2){var C=t[p-30],R=t[p-15*2+1],S=ba(C,R),N=va(R,C);C=t[p-2*2],R=t[p-2*2+1];var M=ga(C,R),P=ya(R,C),D=t[p-7*2],B=t[p-7*2+1],j=t[p-16*2],X=t[p-16*2+1],W=N+B|0,V=S+D+z(W,N)|0;W=W+P|0,V=V+M+z(W,P)|0,W=W+X|0,V=V+j+z(W,X)|0,t[p]=V,t[p+1]=W}for(var G=0;G<160;G+=2){V=t[G],W=t[G+1];var ne=Ur(r,i,n),he=Ur(g,_,w),K=Hr(r,g),ee=Hr(g,r),Q=qr(l,m),ae=qr(m,l),_e=$r[G],te=$r[G+1],Y=Fr(l,u,b),oe=Fr(m,T,E),q=s+ae|0,c=h+Q+z(q,s)|0;q=q+oe|0,c=c+Y+z(q,oe)|0,q=q+te|0,c=c+_e+z(q,te)|0,q=q+W|0,c=c+V+z(q,W)|0;var d=ee+he|0,x=K+ne+z(d,ee)|0;h=b,s=E,b=u,E=T,u=l,T=m,m=v+q|0,l=f+c+z(m,v)|0,f=n,v=w,n=i,w=_,i=r,_=g,g=q+d|0,r=c+x+z(g,q)|0}this._al=this._al+g|0,this._bl=this._bl+_|0,this._cl=this._cl+w|0,this._dl=this._dl+v|0,this._el=this._el+m|0,this._fl=this._fl+T|0,this._gl=this._gl+E|0,this._hl=this._hl+s|0,this._ah=this._ah+r+z(this._al,g)|0,this._bh=this._bh+i+z(this._bl,_)|0,this._ch=this._ch+n+z(this._cl,w)|0,this._dh=this._dh+f+z(this._dl,v)|0,this._eh=this._eh+l+z(this._el,m)|0,this._fh=this._fh+u+z(this._fl,T)|0,this._gh=this._gh+b+z(this._gl,E)|0,this._hh=this._hh+h+z(this._hl,s)|0};Fe.prototype._hash=function(){var e=da.allocUnsafe(64);function t(r,i,n){e.writeInt32BE(r,n),e.writeInt32BE(i,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var mi=Fe,wa=Z,Ea=mi,xa=Ae,ma=ge.Buffer,Sa=new Array(160);function Ze(){this.init(),this._w=Sa,xa.call(this,128,112)}wa(Ze,Ea);Ze.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};Ze.prototype._hash=function(){var e=ma.allocUnsafe(48);function t(r,i,n){e.writeInt32BE(r,n),e.writeInt32BE(i,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var Ra=Ze,ye=bi.exports=function(t){t=t.toLowerCase();var r=ye[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};ye.sha=Hn;ye.sha1=Jn;ye.sha224=_a;ye.sha256=Ei;ye.sha384=Ra;ye.sha512=mi;var Xa=bi.exports,Ue,F,Si,Ri,be,jr,Ti,sr,br,lr,ur,Ci,Le={},Ai=[],Ta=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,et=Array.isArray;function se(e,t){for(var r in t)e[r]=t[r];return e}function Bi(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function hr(e,t,r){var i,n,f,l={};for(f in t)f=="key"?i=t[f]:f=="ref"?n=t[f]:l[f]=t[f];if(arguments.length>2&&(l.children=arguments.length>3?Ue.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(f in e.defaultProps)l[f]===void 0&&(l[f]=e.defaultProps[f]);return Me(e,l,i,n,null)}function Me(e,t,r,i,n){var f={type:e,props:t,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:n??++Si,__i:-1,__u:0};return n==null&&F.vnode!=null&&F.vnode(f),f}function Ca(){return{current:null}}function He(e){return e.children}function Ne(e,t){this.props=e,this.context=t}function Re(e,t){if(t==null)return e.__?Re(e.__,e.__i+1):null;for(var r;tt&&be.sort(sr));Ke.__r=0}function Mi(e,t,r,i,n,f,l,u,b,h,g){var _,w,v,m,T,E=i&&i.__k||Ai,s=t.length;for(r.__d=b,Aa(r,t,E),b=r.__d,_=0;_0?Me(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):n).__=e,n.__b=e.__b+1,f=null,(u=n.__i=Ba(n,r,l,g))!==-1&&(g--,(f=r[u])&&(f.__u|=131072)),f==null||f.__v===null?(u==-1&&_--,typeof n.type!="function"&&(n.__u|=65536)):u!==l&&(u==l-1?_--:u==l+1?_++:(u>l?_--:_++,n.__u|=65536))):n=e.__k[i]=null;if(g)for(i=0;i(b!=null&&!(131072&b.__u)?1:0))for(;l>=0||u=0){if((b=t[l])&&!(131072&b.__u)&&n==b.key&&f===b.type)return l;l--}if(u2&&(u.children=arguments.length>3?Ue.call(arguments,2):r),Me(e.type,u,i||e.key,n||e.ref,null)}function Da(e,t){var r={__c:t="__cC"+Ci++,__:e,Consumer:function(i,n){return i.children(n)},Provider:function(i){var n,f;return this.getChildContext||(n=new Set,(f={})[t]=this,this.getChildContext=function(){return f},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(l){this.props.value!==l.value&&n.forEach(function(u){u.__e=!0,_r(u)})},this.sub=function(l){n.add(l);var u=l.componentWillUnmount;l.componentWillUnmount=function(){n&&n.delete(l),u&&u.call(l)}}),i.children}};return r.Provider.__=r.Consumer.contextType=r}Ue=Ai.slice,F={__e:function(e,t,r,i){for(var n,f,l;t=t.__;)if((n=t.__c)&&!n.__)try{if((f=n.constructor)&&f.getDerivedStateFromError!=null&&(n.setState(f.getDerivedStateFromError(e)),l=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(e,i||{}),l=n.__d),l)return n.__E=n}catch(u){e=u}throw e}},Si=0,Ri=function(e){return e!=null&&e.constructor==null},Ne.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=se({},this.state),typeof e=="function"&&(e=e(se({},r),this.props)),e&&se(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),_r(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),_r(this))},Ne.prototype.render=He,be=[],Ti=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,sr=function(e,t){return e.__v.__b-t.__v.__b},Ke.__r=0,br=0,lr=zr(!1),ur=zr(!0),Ci=0;const La=Object.freeze(Object.defineProperty({__proto__:null,Component:Ne,Fragment:He,cloneElement:Na,createContext:Da,createElement:hr,createRef:Ca,h:hr,hydrate:Ii,get isValidElement(){return Ri},get options(){return F},render:Pi,toChildArray:Di},Symbol.toStringTag,{value:"Module"})),Qa=dr(La);var ue,$,nr,Vr,Te=0,$i=[],H=F,Gr=H.__b,Kr=H.__r,Yr=H.diffed,Jr=H.__c,Xr=H.unmount,Qr=H.__;function we(e,t){H.__h&&H.__h($,e,Te||t),Te=0;var r=$.__H||($.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function Fi(e){return Te=1,Ui(qi,e)}function Ui(e,t,r){var i=we(ue++,2);if(i.t=e,!i.__c&&(i.__=[r?r(t):qi(void 0,t),function(u){var b=i.__N?i.__N[0]:i.__[0],h=i.t(b,u);b!==h&&(i.__N=[h,i.__[1]],i.__c.setState({}))}],i.__c=$,!$.u)){var n=function(u,b,h){if(!i.__c.__H)return!0;var g=i.__c.__H.__.filter(function(w){return!!w.__c});if(g.every(function(w){return!w.__N}))return!f||f.call(this,u,b,h);var _=!1;return g.forEach(function(w){if(w.__N){var v=w.__[0];w.__=w.__N,w.__N=void 0,v!==w.__[0]&&(_=!0)}}),!(!_&&i.__c.props===u)&&(!f||f.call(this,u,b,h))};$.u=!0;var f=$.shouldComponentUpdate,l=$.componentWillUpdate;$.componentWillUpdate=function(u,b,h){if(this.__e){var g=f;f=void 0,n(u,b,h),f=g}l&&l.call(this,u,b,h)},$.shouldComponentUpdate=n}return i.__N||i.__}function Oa(e,t){var r=we(ue++,3);!H.__s&&wr(r.__H,t)&&(r.__=e,r.i=t,$.__H.__h.push(r))}function Hi(e,t){var r=we(ue++,4);!H.__s&&wr(r.__H,t)&&(r.__=e,r.i=t,$.__h.push(r))}function Pa(e){return Te=5,yr(function(){return{current:e}},[])}function Ia(e,t,r){Te=6,Hi(function(){return typeof e=="function"?(e(t()),function(){return e(null)}):e?(e.current=t(),function(){return e.current=null}):void 0},r==null?r:r.concat(e))}function yr(e,t){var r=we(ue++,7);return wr(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function $a(e,t){return Te=8,yr(function(){return e},t)}function Fa(e){var t=$.context[e.__c],r=we(ue++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub($)),t.props.value):e.__}function Ua(e,t){H.useDebugValue&&H.useDebugValue(t?t(e):e)}function Ha(e){var t=we(ue++,10),r=Fi();return t.__=e,$.componentDidCatch||($.componentDidCatch=function(i,n){t.__&&t.__(i,n),r[1](i)}),[r[0],function(){r[1](void 0)}]}function qa(){var e=we(ue++,11);if(!e.__){for(var t=$.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var r=t.__m||(t.__m=[0,0]);e.__="P"+r[0]+"-"+r[1]++}return e.__}function ja(){for(var e;e=$i.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Ve),e.__H.__h.forEach(cr),e.__H.__h=[]}catch(t){e.__H.__h=[],H.__e(t,e.__v)}}H.__b=function(e){$=null,Gr&&Gr(e)},H.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Qr&&Qr(e,t)},H.__r=function(e){Kr&&Kr(e),ue=0;var t=($=e.__c).__H;t&&(nr===$?(t.__h=[],$.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(t.__h.forEach(Ve),t.__h.forEach(cr),t.__h=[],ue=0)),nr=$},H.diffed=function(e){Yr&&Yr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&($i.push(t)!==1&&Vr===H.requestAnimationFrame||((Vr=H.requestAnimationFrame)||Wa)(ja)),t.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),nr=$=null},H.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Ve),r.__h=r.__h.filter(function(i){return!i.__||cr(i)})}catch(i){t.some(function(n){n.__h&&(n.__h=[])}),t=[],H.__e(i,r.__v)}}),Jr&&Jr(e,t)},H.unmount=function(e){Xr&&Xr(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(i){try{Ve(i)}catch(n){t=n}}),r.__H=void 0,t&&H.__e(t,r.__v))};var Zr=typeof requestAnimationFrame=="function";function Wa(e){var t,r=function(){clearTimeout(i),Zr&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(r,100);Zr&&(t=requestAnimationFrame(r))}function Ve(e){var t=$,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),$=t}function cr(e){var t=$;e.__c=e.__(),$=t}function wr(e,t){return!e||e.length!==t.length||t.some(function(r,i){return r!==e[i]})}function qi(e,t){return typeof t=="function"?t(e):t}const za=Object.freeze(Object.defineProperty({__proto__:null,useCallback:$a,useContext:Fa,useDebugValue:Ua,useEffect:Oa,useErrorBoundary:Ha,useId:qa,useImperativeHandle:Ia,useLayoutEffect:Hi,useMemo:yr,useReducer:Ui,useRef:Pa,useState:Fi},Symbol.toStringTag,{value:"Module"})),Za=dr(za);export{Za as a,Ya as b,Ja as j,Qa as r,Xa as s}; diff --git a/buddybook/assets/hooks.module-CBpTII2E.js b/buddybook/assets/hooks.module-CBpTII2E.js deleted file mode 100644 index 7819524..0000000 --- a/buddybook/assets/hooks.module-CBpTII2E.js +++ /dev/null @@ -1 +0,0 @@ -import{E as xr,g as dr,m as Le,d as Ee}from"./index-CLqSQ1yP.js";import{e as en}from"./events-CHFTlyqt.js";import{r as tn,i as J}from"./inherits_browser-Dprisln6.js";const Wn=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:xr,default:xr},Symbol.toStringTag,{value:"Module"})),Ya=dr(Wn);var ar={exports:{}},rn=en.EventEmitter,Yt,Er;function zn(){if(Er)return Yt;Er=1;function e(R,A){var w=Object.keys(R);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(R);A&&(s=s.filter(function(p){return Object.getOwnPropertyDescriptor(R,p).enumerable})),w.push.apply(w,s)}return w}function t(R){for(var A=1;A0?this.tail.next=s:this.head=s,this.tail=s,++this.length}},{key:"unshift",value:function(w){var s={data:w,next:this.head};this.length===0&&(this.tail=s),this.head=s,++this.length}},{key:"shift",value:function(){if(this.length!==0){var w=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,w}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(w){if(this.length===0)return"";for(var s=this.head,p=""+s.data;s=s.next;)p+=w+s.data;return p}},{key:"concat",value:function(w){if(this.length===0)return b.alloc(0);for(var s=b.allocUnsafe(w>>>0),p=this.head,y=0;p;)v(p.data,s,y),y+=p.data.length,p=p.next;return s}},{key:"consume",value:function(w,s){var p;return wS.length?S.length:w;if(T===S.length?y+=S:y+=S.slice(0,w),w-=T,w===0){T===S.length?(++p,s.next?this.head=s.next:this.head=this.tail=null):(this.head=s,s.data=S.slice(T));break}++p}return this.length-=p,y}},{key:"_getBuffer",value:function(w){var s=b.allocUnsafe(w),p=this.head,y=1;for(p.data.copy(s),w-=p.data.length;p=p.next;){var S=p.data,T=w>S.length?S.length:w;if(S.copy(s,s.length-w,0,T),w-=T,w===0){T===S.length?(++y,p.next?this.head=p.next:this.head=this.tail=null):(this.head=p,p.data=S.slice(T));break}++y}return this.length-=y,s}},{key:m,value:function(w,s){return u(this,t(t({},s),{},{depth:0,customInspect:!1}))}}]),R}(),Yt}function Gn(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(or,this,e)):process.nextTick(or,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(f){!t&&f?r._writableState?r._writableState.errorEmitted?process.nextTick(We,r):(r._writableState.errorEmitted=!0,process.nextTick(mr,r,f)):process.nextTick(mr,r,f):t?(process.nextTick(We,r),t(f)):process.nextTick(We,r)}),this)}function mr(e,t){or(e,t),We(e)}function We(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function Vn(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function or(e,t){e.emit("error",t)}function Kn(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}var nn={destroy:Gn,undestroy:Vn,errorOrDestroy:Kn},pe={};function Yn(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var an={};function X(e,t,r){r||(r=Error);function n(f,l,c){return typeof t=="string"?t:t(f,l,c)}var i=function(f){Yn(l,f);function l(c,d,b){return f.call(this,n(c,d,b))||this}return l}(r);i.prototype.name=r.name,i.prototype.code=e,an[e]=i}function Sr(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function Xn(e,t,r){return e.substr(0,t.length)===t}function Jn(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function Qn(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}X("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);X("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&Xn(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(Jn(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Sr(t,"type"));else{var f=Qn(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(f," ").concat(n," ").concat(Sr(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);X("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");X("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});X("ERR_STREAM_PREMATURE_CLOSE","Premature close");X("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});X("ERR_MULTIPLE_CALLBACK","Callback called multiple times");X("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");X("ERR_STREAM_WRITE_AFTER_END","write after end");X("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);X("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);X("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");pe.codes=an;var Zn=pe.codes.ERR_INVALID_OPT_VALUE;function ei(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function ti(e,t,r,n){var i=ei(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var f=n?r:"highWaterMark";throw new Zn(f,i)}return Math.floor(i)}return e.objectMode?16:16*1024}var on={getHighWaterMark:ti},ri=ni;function ni(e,t){if(Xt("noDeprecation"))return e;var r=!1;function n(){if(!r){if(Xt("throwDeprecation"))throw new Error(t);Xt("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function Xt(e){try{if(!Ee.localStorage)return!1}catch{return!1}var t=Ee.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var Jt,Rr;function fn(){if(Rr)return Jt;Rr=1,Jt=D;function e(_){var h=this;this.next=null,this.entry=null,this.finish=function(){ne(h,_)}}var t;D.WritableState=B;var r={deprecate:ri},n=rn,i=Le.Buffer,f=(typeof Ee<"u"?Ee:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function l(_){return i.from(_)}function c(_){return i.isBuffer(_)||_ instanceof f}var d=nn,b=on,E=b.getHighWaterMark,u=pe.codes,m=u.ERR_INVALID_ARG_TYPE,v=u.ERR_METHOD_NOT_IMPLEMENTED,R=u.ERR_MULTIPLE_CALLBACK,A=u.ERR_STREAM_CANNOT_PIPE,w=u.ERR_STREAM_DESTROYED,s=u.ERR_STREAM_NULL_VALUES,p=u.ERR_STREAM_WRITE_AFTER_END,y=u.ERR_UNKNOWN_ENCODING,S=d.errorOrDestroy;J(D,n);function T(){}function B(_,h,x){t=t||me(),_=_||{},typeof x!="boolean"&&(x=h instanceof t),this.objectMode=!!_.objectMode,x&&(this.objectMode=this.objectMode||!!_.writableObjectMode),this.highWaterMark=E(this,_,"writableHighWaterMark",x),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var k=_.decodeStrings===!1;this.decodeStrings=!k,this.defaultEncoding=_.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(L){le(h,L)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=_.emitClose!==!1,this.autoDestroy=!!_.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}B.prototype.getBuffer=function(){for(var h=this.bufferedRequest,x=[];h;)x.push(h),h=h.next;return x},function(){try{Object.defineProperty(B.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var O;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(O=Function.prototype[Symbol.hasInstance],Object.defineProperty(D,Symbol.hasInstance,{value:function(h){return O.call(this,h)?!0:this!==D?!1:h&&h._writableState instanceof B}})):O=function(h){return h instanceof this};function D(_){t=t||me();var h=this instanceof t;if(!h&&!O.call(D,this))return new D(_);this._writableState=new B(_,this,h),this.writable=!0,_&&(typeof _.write=="function"&&(this._write=_.write),typeof _.writev=="function"&&(this._writev=_.writev),typeof _.destroy=="function"&&(this._destroy=_.destroy),typeof _.final=="function"&&(this._final=_.final)),n.call(this)}D.prototype.pipe=function(){S(this,new A)};function M(_,h){var x=new p;S(_,x),process.nextTick(h,x)}function F(_,h,x,k){var L;return x===null?L=new s:typeof x!="string"&&!h.objectMode&&(L=new m("chunk",["string","Buffer"],x)),L?(S(_,L),process.nextTick(k,L),!1):!0}D.prototype.write=function(_,h,x){var k=this._writableState,L=!1,a=!k.objectMode&&c(_);return a&&!i.isBuffer(_)&&(_=l(_)),typeof h=="function"&&(x=h,h=null),a?h="buffer":h||(h=k.defaultEncoding),typeof x!="function"&&(x=T),k.ending?M(this,x):(a||F(this,k,_,x))&&(k.pendingcb++,L=Z(this,k,a,_,h,x)),L},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var _=this._writableState;_.corked&&(_.corked--,!_.writing&&!_.corked&&!_.bufferProcessing&&_.bufferedRequest&&Y(this,_))},D.prototype.setDefaultEncoding=function(h){if(typeof h=="string"&&(h=h.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((h+"").toLowerCase())>-1))throw new y(h);return this._writableState.defaultEncoding=h,this},Object.defineProperty(D.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function W(_,h,x){return!_.objectMode&&_.decodeStrings!==!1&&typeof h=="string"&&(h=i.from(h,x)),h}Object.defineProperty(D.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Z(_,h,x,k,L,a){if(!x){var o=W(h,k,L);k!==o&&(x=!0,L="buffer",k=o)}var g=h.objectMode?1:k.length;h.length+=g;var C=h.length */var Ar;function ii(){return Ar||(Ar=1,function(e,t){var r=Le,n=r.Buffer;function i(l,c){for(var d in l)c[d]=l[d]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=f);function f(l,c,d){return n(l,c,d)}f.prototype=Object.create(n.prototype),i(n,f),f.from=function(l,c,d){if(typeof l=="number")throw new TypeError("Argument must not be a number");return n(l,c,d)},f.alloc=function(l,c,d){if(typeof l!="number")throw new TypeError("Argument must be a number");var b=n(l);return c!==void 0?typeof d=="string"?b.fill(c,d):b.fill(c):b.fill(0),b},f.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return n(l)},f.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(l)}}(qe,qe.exports)),qe.exports}var Cr;function Br(){if(Cr)return Zt;Cr=1;var e=ii().Buffer,t=e.isEncoding||function(s){switch(s=""+s,s&&s.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(s){if(!s)return"utf8";for(var p;;)switch(s){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return s;default:if(p)return;s=(""+s).toLowerCase(),p=!0}}function n(s){var p=r(s);if(typeof p!="string"&&(e.isEncoding===t||!t(s)))throw new Error("Unknown encoding: "+s);return p||s}Zt.StringDecoder=i;function i(s){this.encoding=n(s);var p;switch(this.encoding){case"utf16le":this.text=u,this.end=m,p=4;break;case"utf8":this.fillLast=d,p=4;break;case"base64":this.text=v,this.end=R,p=3;break;default:this.write=A,this.end=w;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=e.allocUnsafe(p)}i.prototype.write=function(s){if(s.length===0)return"";var p,y;if(this.lastNeed){if(p=this.fillLast(s),p===void 0)return"";y=this.lastNeed,this.lastNeed=0}else y=0;return y>5===6?2:s>>4===14?3:s>>3===30?4:s>>6===2?-1:-2}function l(s,p,y){var S=p.length-1;if(S=0?(T>0&&(s.lastNeed=T-1),T):--S=0?(T>0&&(s.lastNeed=T-2),T):--S=0?(T>0&&(T===2?T=0:s.lastNeed=T-3),T):0))}function c(s,p,y){if((p[0]&192)!==128)return s.lastNeed=0,"�";if(s.lastNeed>1&&p.length>1){if((p[1]&192)!==128)return s.lastNeed=1,"�";if(s.lastNeed>2&&p.length>2&&(p[2]&192)!==128)return s.lastNeed=2,"�"}}function d(s){var p=this.lastTotal-this.lastNeed,y=c(this,s);if(y!==void 0)return y;if(this.lastNeed<=s.length)return s.copy(this.lastChar,p,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);s.copy(this.lastChar,p,0,s.length),this.lastNeed-=s.length}function b(s,p){var y=l(this,s,p);if(!this.lastNeed)return s.toString("utf8",p);this.lastTotal=y;var S=s.length-(y-this.lastNeed);return s.copy(this.lastChar,0,S),s.toString("utf8",p,S)}function E(s){var p=s&&s.length?this.write(s):"";return this.lastNeed?p+"�":p}function u(s,p){if((s.length-p)%2===0){var y=s.toString("utf16le",p);if(y){var S=y.charCodeAt(y.length-1);if(S>=55296&&S<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=s[s.length-2],this.lastChar[1]=s[s.length-1],y.slice(0,-1)}return y}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=s[s.length-1],s.toString("utf16le",p,s.length-1)}function m(s){var p=s&&s.length?this.write(s):"";if(this.lastNeed){var y=this.lastTotal-this.lastNeed;return p+this.lastChar.toString("utf16le",0,y)}return p}function v(s,p){var y=(s.length-p)%3;return y===0?s.toString("base64",p):(this.lastNeed=3-y,this.lastTotal=3,y===1?this.lastChar[0]=s[s.length-1]:(this.lastChar[0]=s[s.length-2],this.lastChar[1]=s[s.length-1]),s.toString("base64",p,s.length-y))}function R(s){var p=s&&s.length?this.write(s):"";return this.lastNeed?p+this.lastChar.toString("base64",0,3-this.lastNeed):p}function A(s){return s.toString(this.encoding)}function w(s){return s&&s.length?this.write(s):""}return Zt}var kr=pe.codes.ERR_STREAM_PREMATURE_CLOSE;function ai(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i0)if(typeof o!="string"&&!N.objectMode&&Object.getPrototypeOf(o)!==n.prototype&&(o=f(o)),C)N.endEmitted?T(a,new s):W(a,N,o,!0);else if(N.ended)T(a,new A);else{if(N.destroyed)return!1;N.reading=!1,N.decoder&&!g?(o=N.decoder.write(o),N.objectMode||o.length!==0?W(a,N,o,!1):Y(a,N)):W(a,N,o,!1)}else C||(N.reading=!1,Y(a,N))}return!N.ended&&(N.length=q?a=q:(a--,a|=a>>>1,a|=a>>>2,a|=a>>>4,a|=a>>>8,a|=a>>>16,a++),a}function G(a,o){return a<=0||o.length===0&&o.ended?0:o.objectMode?1:a!==a?o.flowing&&o.length?o.buffer.head.data.length:o.length:(a>o.highWaterMark&&(o.highWaterMark=z(a)),a<=o.length?a:o.ended?o.length:(o.needReadable=!0,0))}M.prototype.read=function(a){d("read",a),a=parseInt(a,10);var o=this._readableState,g=a;if(a!==0&&(o.emittedReadable=!1),a===0&&o.needReadable&&((o.highWaterMark!==0?o.length>=o.highWaterMark:o.length>0)||o.ended))return d("read: emitReadable",o.length,o.ended),o.length===0&&o.ended?x(this):K(this),null;if(a=G(a,o),a===0&&o.ended)return o.length===0&&x(this),null;var C=o.needReadable;d("need readable",C),(o.length===0||o.length-a0?U=h(a,o):U=null,U===null?(o.needReadable=o.length<=o.highWaterMark,a=0):(o.length-=a,o.awaitDrain=0),o.length===0&&(o.ended||(o.needReadable=!0),g!==a&&o.ended&&x(this)),U!==null&&this.emit("data",U),U};function le(a,o){if(d("onEofChunk"),!o.ended){if(o.decoder){var g=o.decoder.end();g&&g.length&&(o.buffer.push(g),o.length+=o.objectMode?1:g.length)}o.ended=!0,o.sync?K(a):(o.needReadable=!1,o.emittedReadable||(o.emittedReadable=!0,ee(a)))}}function K(a){var o=a._readableState;d("emitReadable",o.needReadable,o.emittedReadable),o.needReadable=!1,o.emittedReadable||(d("emitReadable",o.flowing),o.emittedReadable=!0,process.nextTick(ee,a))}function ee(a){var o=a._readableState;d("emitReadable_",o.destroyed,o.length,o.ended),!o.destroyed&&(o.length||o.ended)&&(a.emit("readable"),o.emittedReadable=!1),o.needReadable=!o.flowing&&!o.ended&&o.length<=o.highWaterMark,_(a)}function Y(a,o){o.readingMore||(o.readingMore=!0,process.nextTick(te,a,o))}function te(a,o){for(;!o.reading&&!o.ended&&(o.length1&&L(C.pipes,a)!==-1)&&!Ce&&(d("false write response, pause",C.awaitDrain),C.awaitDrain++),g.pause())}function ye(ae){d("onerror",ae),_e(),a.removeListener("error",ye),t(a,"error")===0&&T(a,ae)}O(a,"error",ye);function we(){a.removeListener("finish",xe),_e()}a.once("close",we);function xe(){d("onfinish"),a.removeListener("close",we),_e()}a.once("finish",xe);function _e(){d("unpipe"),g.unpipe(a)}return a.emit("pipe",g),C.flowing||(d("pipe resume"),g.resume()),a};function ue(a){return function(){var g=a._readableState;d("pipeOnDrain",g.awaitDrain),g.awaitDrain&&g.awaitDrain--,g.awaitDrain===0&&t(a,"data")&&(g.flowing=!0,_(a))}}M.prototype.unpipe=function(a){var o=this._readableState,g={hasUnpiped:!1};if(o.pipesCount===0)return this;if(o.pipesCount===1)return a&&a!==o.pipes?this:(a||(a=o.pipes),o.pipes=null,o.pipesCount=0,o.flowing=!1,a&&a.emit("unpipe",this,g),this);if(!a){var C=o.pipes,U=o.pipesCount;o.pipes=null,o.pipesCount=0,o.flowing=!1;for(var N=0;N0,C.flowing!==!1&&this.resume()):a==="readable"&&!C.endEmitted&&!C.readableListening&&(C.readableListening=C.needReadable=!0,C.flowing=!1,C.emittedReadable=!1,d("on readable",C.length,C.reading),C.length?K(this):C.reading||process.nextTick(V,this)),g},M.prototype.addListener=M.prototype.on,M.prototype.removeListener=function(a,o){var g=r.prototype.removeListener.call(this,a,o);return a==="readable"&&process.nextTick(re,this),g},M.prototype.removeAllListeners=function(a){var o=r.prototype.removeAllListeners.apply(this,arguments);return(a==="readable"||a===void 0)&&process.nextTick(re,this),o};function re(a){var o=a._readableState;o.readableListening=a.listenerCount("readable")>0,o.resumeScheduled&&!o.paused?o.flowing=!0:a.listenerCount("data")>0&&a.resume()}function V(a){d("readable nexttick read 0"),a.read(0)}M.prototype.resume=function(){var a=this._readableState;return a.flowing||(d("resume"),a.flowing=!a.readableListening,he(this,a)),a.paused=!1,this};function he(a,o){o.resumeScheduled||(o.resumeScheduled=!0,process.nextTick(ne,a,o))}function ne(a,o){d("resume",o.reading),o.reading||a.read(0),o.resumeScheduled=!1,a.emit("resume"),_(a),o.flowing&&!o.reading&&a.read(0)}M.prototype.pause=function(){return d("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(d("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function _(a){var o=a._readableState;for(d("flow",o.flowing);o.flowing&&a.read()!==null;);}M.prototype.wrap=function(a){var o=this,g=this._readableState,C=!1;a.on("end",function(){if(d("wrapped end"),g.decoder&&!g.ended){var P=g.decoder.end();P&&P.length&&o.push(P)}o.push(null)}),a.on("data",function(P){if(d("wrapped data"),g.decoder&&(P=g.decoder.write(P)),!(g.objectMode&&P==null)&&!(!g.objectMode&&(!P||!P.length))){var ie=o.push(P);ie||(C=!0,a.pause())}});for(var U in a)this[U]===void 0&&typeof a[U]=="function"&&(this[U]=function(ie){return function(){return a[ie].apply(a,arguments)}}(U));for(var N=0;N=o.length?(o.decoder?g=o.buffer.join(""):o.buffer.length===1?g=o.buffer.first():g=o.buffer.concat(o.length),o.buffer.clear()):g=o.buffer.consume(a,o.decoder),g}function x(a){var o=a._readableState;d("endReadable",o.endEmitted),o.endEmitted||(o.ended=!0,process.nextTick(k,o,a))}function k(a,o){if(d("endReadableNT",a.endEmitted,a.length),!a.endEmitted&&a.length===0&&(a.endEmitted=!0,o.readable=!1,o.emit("end"),a.autoDestroy)){var g=o._writableState;(!g||g.autoDestroy&&g.finished)&&o.destroy()}}typeof Symbol=="function"&&(M.from=function(a,o){return S===void 0&&(S=li()),S(M,a,o)});function L(a,o){for(var g=0,C=a.length;g0;return xi(l,d,b,function(E){i||(i=E),E&&f.forEach(Or),!d&&(f.forEach(Or),n(i))})});return t.reduce(Ei)}var Ri=Si;(function(e,t){t=e.exports=ln(),t.Stream=t,t.Readable=t,t.Writable=fn(),t.Duplex=me(),t.Transform=un,t.PassThrough=bi,t.finished=pr,t.pipeline=Ri})(ar,ar.exports);var cn=ar.exports;const{Transform:Ti}=cn;var Ai=e=>class dn extends Ti{constructor(r,n,i,f,l){super(l),this._rate=r,this._capacity=n,this._delimitedSuffix=i,this._hashBitLength=f,this._options=l,this._state=new e,this._state.initialize(r,n),this._finalized=!1}_transform(r,n,i){let f=null;try{this.update(r,n)}catch(l){f=l}i(f)}_flush(r){let n=null;try{this.push(this.digest())}catch(i){n=i}r(n)}update(r,n){if(!Buffer.isBuffer(r)&&typeof r!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer.isBuffer(r)||(r=Buffer.from(r,n)),this._state.absorb(r),this}digest(r){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let n=this._state.squeeze(this._hashBitLength/8);return r!==void 0&&(n=n.toString(r)),this._resetState(),n}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const r=new dn(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(r._state),r._finalized=this._finalized,r}};const{Transform:Ci}=cn;var Bi=e=>class pn extends Ci{constructor(r,n,i,f){super(f),this._rate=r,this._capacity=n,this._delimitedSuffix=i,this._options=f,this._state=new e,this._state.initialize(r,n),this._finalized=!1}_transform(r,n,i){let f=null;try{this.update(r,n)}catch(l){f=l}i(f)}_flush(){}_read(r){this.push(this.squeeze(r))}update(r,n){if(!Buffer.isBuffer(r)&&typeof r!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer.isBuffer(r)||(r=Buffer.from(r,n)),this._state.absorb(r),this}squeeze(r,n){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let i=this._state.squeeze(r);return n!==void 0&&(i=i.toString(n)),i}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const r=new pn(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(r._state),r._finalized=this._finalized,r}};const ki=Ai,Mi=Bi;var Di=function(e){const t=ki(e),r=Mi(e);return function(n,i){switch(typeof n=="string"?n.toLowerCase():n){case"keccak224":return new t(1152,448,null,224,i);case"keccak256":return new t(1088,512,null,256,i);case"keccak384":return new t(832,768,null,384,i);case"keccak512":return new t(576,1024,null,512,i);case"sha3-224":return new t(1152,448,6,224,i);case"sha3-256":return new t(1088,512,6,256,i);case"sha3-384":return new t(832,768,6,384,i);case"sha3-512":return new t(576,1024,6,512,i);case"shake128":return new r(1344,256,31,i);case"shake256":return new r(1088,512,31,i);default:throw new Error("Invald algorithm: "+n)}}},bn={};const Ir=[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];bn.p1600=function(e){for(let t=0;t<24;++t){const r=e[0]^e[10]^e[20]^e[30]^e[40],n=e[1]^e[11]^e[21]^e[31]^e[41],i=e[2]^e[12]^e[22]^e[32]^e[42],f=e[3]^e[13]^e[23]^e[33]^e[43],l=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],d=e[6]^e[16]^e[26]^e[36]^e[46],b=e[7]^e[17]^e[27]^e[37]^e[47],E=e[8]^e[18]^e[28]^e[38]^e[48],u=e[9]^e[19]^e[29]^e[39]^e[49];let m=E^(i<<1|f>>>31),v=u^(f<<1|i>>>31);const R=e[0]^m,A=e[1]^v,w=e[10]^m,s=e[11]^v,p=e[20]^m,y=e[21]^v,S=e[30]^m,T=e[31]^v,B=e[40]^m,O=e[41]^v;m=r^(l<<1|c>>>31),v=n^(c<<1|l>>>31);const D=e[2]^m,M=e[3]^v,F=e[12]^m,W=e[13]^v,Z=e[22]^m,q=e[23]^v,z=e[32]^m,G=e[33]^v,le=e[42]^m,K=e[43]^v;m=i^(d<<1|b>>>31),v=f^(b<<1|d>>>31);const ee=e[4]^m,Y=e[5]^v,te=e[14]^m,ue=e[15]^v,re=e[24]^m,V=e[25]^v,he=e[34]^m,ne=e[35]^v,_=e[44]^m,h=e[45]^v;m=l^(E<<1|u>>>31),v=c^(u<<1|E>>>31);const x=e[6]^m,k=e[7]^v,L=e[16]^m,a=e[17]^v,o=e[26]^m,g=e[27]^v,C=e[36]^m,U=e[37]^v,N=e[46]^m,P=e[47]^v;m=d^(r<<1|n>>>31),v=b^(n<<1|r>>>31);const ie=e[8]^m,ce=e[9]^v,Ce=e[18]^m,He=e[19]^v,Be=e[28]^m,ye=e[29]^v,we=e[38]^m,xe=e[39]^v,_e=e[48]^m,ae=e[49]^v,Q=R,et=A,tt=s<<4|w>>>28,rt=w<<4|s>>>28,nt=p<<3|y>>>29,it=y<<3|p>>>29,at=T<<9|S>>>23,ot=S<<9|T>>>23,ft=B<<18|O>>>14,st=O<<18|B>>>14,lt=D<<1|M>>>31,ut=M<<1|D>>>31,ht=W<<12|F>>>20,_t=F<<12|W>>>20,ct=Z<<10|q>>>22,dt=q<<10|Z>>>22,pt=G<<13|z>>>19,bt=z<<13|G>>>19,vt=le<<2|K>>>30,gt=K<<2|le>>>30,yt=Y<<30|ee>>>2,wt=ee<<30|Y>>>2,xt=te<<6|ue>>>26,Et=ue<<6|te>>>26,mt=V<<11|re>>>21,St=re<<11|V>>>21,Rt=he<<15|ne>>>17,Tt=ne<<15|he>>>17,At=h<<29|_>>>3,Ct=_<<29|h>>>3,Bt=x<<28|k>>>4,kt=k<<28|x>>>4,Mt=a<<23|L>>>9,Dt=L<<23|a>>>9,Nt=o<<25|g>>>7,Lt=g<<25|o>>>7,Pt=C<<21|U>>>11,Ot=U<<21|C>>>11,It=P<<24|N>>>8,$t=N<<24|P>>>8,Ft=ie<<27|ce>>>5,Ut=ce<<27|ie>>>5,Ht=Ce<<20|He>>>12,qt=He<<20|Ce>>>12,jt=ye<<7|Be>>>25,Wt=Be<<7|ye>>>25,zt=we<<8|xe>>>24,Gt=xe<<8|we>>>24,Vt=_e<<14|ae>>>18,Kt=ae<<14|_e>>>18;e[0]=Q^~ht&mt,e[1]=et^~_t&St,e[10]=Bt^~Ht&nt,e[11]=kt^~qt&it,e[20]=lt^~xt&Nt,e[21]=ut^~Et&Lt,e[30]=Ft^~tt&ct,e[31]=Ut^~rt&dt,e[40]=yt^~Mt&jt,e[41]=wt^~Dt&Wt,e[2]=ht^~mt&Pt,e[3]=_t^~St&Ot,e[12]=Ht^~nt&pt,e[13]=qt^~it&bt,e[22]=xt^~Nt&zt,e[23]=Et^~Lt&Gt,e[32]=tt^~ct&Rt,e[33]=rt^~dt&Tt,e[42]=Mt^~jt&at,e[43]=Dt^~Wt&ot,e[4]=mt^~Pt&Vt,e[5]=St^~Ot&Kt,e[14]=nt^~pt&At,e[15]=it^~bt&Ct,e[24]=Nt^~zt&ft,e[25]=Lt^~Gt&st,e[34]=ct^~Rt&It,e[35]=dt^~Tt&$t,e[44]=jt^~at&vt,e[45]=Wt^~ot>,e[6]=Pt^~Vt&Q,e[7]=Ot^~Kt&et,e[16]=pt^~At&Bt,e[17]=bt^~Ct&kt,e[26]=zt^~ft<,e[27]=Gt^~st&ut,e[36]=Rt^~It&Ft,e[37]=Tt^~$t&Ut,e[46]=at^~vt&yt,e[47]=ot^~gt&wt,e[8]=Vt^~Q&ht,e[9]=Kt^~et&_t,e[18]=At^~Bt&Ht,e[19]=Ct^~kt&qt,e[28]=ft^~lt&xt,e[29]=st^~ut&Et,e[38]=It^~Ft&tt,e[39]=$t^~Ut&rt,e[48]=vt^~yt&Mt,e[49]=gt^~wt&Dt,e[0]^=Ir[t*2],e[1]^=Ir[t*2+1]}};const Ge=bn;function Te(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}Te.prototype.initialize=function(e,t){for(let r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1};Te.prototype.absorb=function(e){for(let t=0;t>>8*(this.count%4)&255,this.count+=1,this.count===this.blockSize&&(Ge.p1600(this.state),this.count=0);return t};Te.prototype.copy=function(e){for(let t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing};var Ni=Te,Xa=Di(Ni),vn={exports:{}},fr={exports:{}};(function(e,t){var r=Le,n=r.Buffer;function i(l,c){for(var d in l)c[d]=l[d]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=f);function f(l,c,d){return n(l,c,d)}i(n,f),f.from=function(l,c,d){if(typeof l=="number")throw new TypeError("Argument must not be a number");return n(l,c,d)},f.alloc=function(l,c,d){if(typeof l!="number")throw new TypeError("Argument must be a number");var b=n(l);return c!==void 0?typeof d=="string"?b.fill(c,d):b.fill(c):b.fill(0),b},f.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return n(l)},f.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(l)}})(fr,fr.exports);var be=fr.exports,gn=be.Buffer;function Xe(e,t){this._block=gn.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Xe.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=gn.from(e,t));for(var r=this._block,n=this._blockSize,i=e.length,f=this._len,l=0;l=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var f=this._hash();return e?f.toString(e):f};Xe.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Ae=Xe,Li=J,yn=Ae,Pi=be.Buffer,Oi=[1518500249,1859775393,-1894007588,-899497514],Ii=new Array(80);function Pe(){this.init(),this._w=Ii,yn.call(this,64,56)}Li(Pe,yn);Pe.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function $i(e){return e<<5|e>>>27}function Fi(e){return e<<30|e>>>2}function Ui(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Pe.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,f=this._d|0,l=this._e|0,c=0;c<16;++c)t[c]=e.readInt32BE(c*4);for(;c<80;++c)t[c]=t[c-3]^t[c-8]^t[c-14]^t[c-16];for(var d=0;d<80;++d){var b=~~(d/20),E=$i(r)+Ui(b,n,i,f)+l+t[d]+Oi[b]|0;l=f,f=i,i=Fi(n),n=r,r=E}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=f+this._d|0,this._e=l+this._e|0};Pe.prototype._hash=function(){var e=Pi.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Hi=Pe,qi=J,wn=Ae,ji=be.Buffer,Wi=[1518500249,1859775393,-1894007588,-899497514],zi=new Array(80);function Oe(){this.init(),this._w=zi,wn.call(this,64,56)}qi(Oe,wn);Oe.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Gi(e){return e<<1|e>>>31}function Vi(e){return e<<5|e>>>27}function Ki(e){return e<<30|e>>>2}function Yi(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Oe.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,f=this._d|0,l=this._e|0,c=0;c<16;++c)t[c]=e.readInt32BE(c*4);for(;c<80;++c)t[c]=Gi(t[c-3]^t[c-8]^t[c-14]^t[c-16]);for(var d=0;d<80;++d){var b=~~(d/20),E=Vi(r)+Yi(b,n,i,f)+l+t[d]+Wi[b]|0;l=f,f=i,i=Ki(n),n=r,r=E}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=f+this._d|0,this._e=l+this._e|0};Oe.prototype._hash=function(){var e=ji.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Xi=Oe,Ji=J,xn=Ae,Qi=be.Buffer,Zi=[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],ea=new Array(64);function Ie(){this.init(),this._w=ea,xn.call(this,64,56)}Ji(Ie,xn);Ie.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function ta(e,t,r){return r^e&(t^r)}function ra(e,t,r){return e&t|r&(e|t)}function na(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function ia(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function aa(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function oa(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Ie.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,f=this._d|0,l=this._e|0,c=this._f|0,d=this._g|0,b=this._h|0,E=0;E<16;++E)t[E]=e.readInt32BE(E*4);for(;E<64;++E)t[E]=oa(t[E-2])+t[E-7]+aa(t[E-15])+t[E-16]|0;for(var u=0;u<64;++u){var m=b+ia(l)+ta(l,c,d)+Zi[u]+t[u]|0,v=na(r)+ra(r,n,i)|0;b=d,d=c,c=l,l=f+m|0,f=i,i=n,n=r,r=m+v|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=f+this._d|0,this._e=l+this._e|0,this._f=c+this._f|0,this._g=d+this._g|0,this._h=b+this._h|0};Ie.prototype._hash=function(){var e=Qi.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var En=Ie,fa=J,sa=En,la=Ae,ua=be.Buffer,ha=new Array(64);function Je(){this.init(),this._w=ha,la.call(this,64,56)}fa(Je,sa);Je.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};Je.prototype._hash=function(){var e=ua.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var _a=Je,ca=J,mn=Ae,da=be.Buffer,$r=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],pa=new Array(160);function $e(){this.init(),this._w=pa,mn.call(this,128,112)}ca($e,mn);$e.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Fr(e,t,r){return r^e&(t^r)}function Ur(e,t,r){return e&t|r&(e|t)}function Hr(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function qr(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function ba(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function va(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function ga(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function ya(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function j(e,t){return e>>>0>>0?1:0}$e.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,f=this._dh|0,l=this._eh|0,c=this._fh|0,d=this._gh|0,b=this._hh|0,E=this._al|0,u=this._bl|0,m=this._cl|0,v=this._dl|0,R=this._el|0,A=this._fl|0,w=this._gl|0,s=this._hl|0,p=0;p<32;p+=2)t[p]=e.readInt32BE(p*4),t[p+1]=e.readInt32BE(p*4+4);for(;p<160;p+=2){var y=t[p-30],S=t[p-15*2+1],T=ba(y,S),B=va(S,y);y=t[p-2*2],S=t[p-2*2+1];var O=ga(y,S),D=ya(S,y),M=t[p-7*2],F=t[p-7*2+1],W=t[p-16*2],Z=t[p-16*2+1],q=B+F|0,z=T+M+j(q,B)|0;q=q+D|0,z=z+O+j(q,D)|0,q=q+Z|0,z=z+W+j(q,Z)|0,t[p]=z,t[p+1]=q}for(var G=0;G<160;G+=2){z=t[G],q=t[G+1];var le=Ur(r,n,i),K=Ur(E,u,m),ee=Hr(r,E),Y=Hr(E,r),te=qr(l,R),ue=qr(R,l),re=$r[G],V=$r[G+1],he=Fr(l,c,d),ne=Fr(R,A,w),_=s+ue|0,h=b+te+j(_,s)|0;_=_+ne|0,h=h+he+j(_,ne)|0,_=_+V|0,h=h+re+j(_,V)|0,_=_+q|0,h=h+z+j(_,q)|0;var x=Y+K|0,k=ee+le+j(x,Y)|0;b=d,s=w,d=c,w=A,c=l,A=R,R=v+_|0,l=f+h+j(R,v)|0,f=i,v=m,i=n,m=u,n=r,u=E,E=_+x|0,r=h+k+j(E,_)|0}this._al=this._al+E|0,this._bl=this._bl+u|0,this._cl=this._cl+m|0,this._dl=this._dl+v|0,this._el=this._el+R|0,this._fl=this._fl+A|0,this._gl=this._gl+w|0,this._hl=this._hl+s|0,this._ah=this._ah+r+j(this._al,E)|0,this._bh=this._bh+n+j(this._bl,u)|0,this._ch=this._ch+i+j(this._cl,m)|0,this._dh=this._dh+f+j(this._dl,v)|0,this._eh=this._eh+l+j(this._el,R)|0,this._fh=this._fh+c+j(this._fl,A)|0,this._gh=this._gh+d+j(this._gl,w)|0,this._hh=this._hh+b+j(this._hl,s)|0};$e.prototype._hash=function(){var e=da.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var Sn=$e,wa=J,xa=Sn,Ea=Ae,ma=be.Buffer,Sa=new Array(160);function Qe(){this.init(),this._w=Sa,Ea.call(this,128,112)}wa(Qe,xa);Qe.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};Qe.prototype._hash=function(){var e=ma.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var Ra=Qe,ve=vn.exports=function(t){t=t.toLowerCase();var r=ve[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};ve.sha=Hi;ve.sha1=Xi;ve.sha224=_a;ve.sha256=En;ve.sha384=Ra;ve.sha512=Sn;var Ja=vn.exports,Fe,$,Rn,Tn,de,jr,An,sr,br,lr,ur,Cn,Ne={},Bn=[],Ta=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ze=Array.isArray;function oe(e,t){for(var r in t)e[r]=t[r];return e}function kn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function hr(e,t,r){var n,i,f,l={};for(f in t)f=="key"?n=t[f]:f=="ref"?i=t[f]:l[f]=t[f];if(arguments.length>2&&(l.children=arguments.length>3?Fe.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(f in e.defaultProps)l[f]===void 0&&(l[f]=e.defaultProps[f]);return ke(e,l,n,i,null)}function ke(e,t,r,n,i){var f={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:i??++Rn,__i:-1,__u:0};return i==null&&$.vnode!=null&&$.vnode(f),f}function Aa(){return{current:null}}function Ue(e){return e.children}function Me(e,t){this.props=e,this.context=t}function Se(e,t){if(t==null)return e.__?Se(e.__,e.__i+1):null;for(var r;tt&&de.sort(sr));Ve.__r=0}function Dn(e,t,r,n,i,f,l,c,d,b,E){var u,m,v,R,A,w=n&&n.__k||Bn,s=t.length;for(r.__d=d,Ca(r,t,w),d=r.__d,u=0;u0?ke(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,f=null,(c=i.__i=Ba(i,r,l,E))!==-1&&(E--,(f=r[c])&&(f.__u|=131072)),f==null||f.__v===null?(c==-1&&u--,typeof i.type!="function"&&(i.__u|=65536)):c!==l&&(c==l-1?u--:c==l+1?u++:(c>l?u--:u++,i.__u|=65536))):i=e.__k[n]=null;if(E)for(n=0;n(d!=null&&!(131072&d.__u)?1:0))for(;l>=0||c=0){if((d=t[l])&&!(131072&d.__u)&&i==d.key&&f===d.type)return l;l--}if(c2&&(c.children=arguments.length>3?Fe.call(arguments,2):r),ke(e.type,c,n||e.key,i||e.ref,null)}function Na(e,t){var r={__c:t="__cC"+Cn++,__:e,Consumer:function(n,i){return n.children(i)},Provider:function(n){var i,f;return this.getChildContext||(i=new Set,(f={})[t]=this,this.getChildContext=function(){return f},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(l){this.props.value!==l.value&&i.forEach(function(c){c.__e=!0,_r(c)})},this.sub=function(l){i.add(l);var c=l.componentWillUnmount;l.componentWillUnmount=function(){i&&i.delete(l),c&&c.call(l)}}),n.children}};return r.Provider.__=r.Consumer.contextType=r}Fe=Bn.slice,$={__e:function(e,t,r,n){for(var i,f,l;t=t.__;)if((i=t.__c)&&!i.__)try{if((f=i.constructor)&&f.getDerivedStateFromError!=null&&(i.setState(f.getDerivedStateFromError(e)),l=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,n||{}),l=i.__d),l)return i.__E=i}catch(c){e=c}throw e}},Rn=0,Tn=function(e){return e!=null&&e.constructor==null},Me.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=oe({},this.state),typeof e=="function"&&(e=e(oe({},r),this.props)),e&&oe(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),_r(this))},Me.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),_r(this))},Me.prototype.render=Ue,de=[],An=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,sr=function(e,t){return e.__v.__b-t.__v.__b},Ve.__r=0,br=0,lr=zr(!1),ur=zr(!0),Cn=0;const La=Object.freeze(Object.defineProperty({__proto__:null,Component:Me,Fragment:Ue,cloneElement:Da,createContext:Na,createElement:hr,createRef:Aa,h:hr,hydrate:$n,get isValidElement(){return Tn},get options(){return $},render:In,toChildArray:Ln},Symbol.toStringTag,{value:"Module"})),Qa=dr(La);var se,I,ir,Gr,Re=0,Fn=[],H=$,Vr=H.__b,Kr=H.__r,Yr=H.diffed,Xr=H.__c,Jr=H.unmount,Qr=H.__;function ge(e,t){H.__h&&H.__h(I,e,Re||t),Re=0;var r=I.__H||(I.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function Un(e){return Re=1,Hn(jn,e)}function Hn(e,t,r){var n=ge(se++,2);if(n.t=e,!n.__c&&(n.__=[r?r(t):jn(void 0,t),function(c){var d=n.__N?n.__N[0]:n.__[0],b=n.t(d,c);d!==b&&(n.__N=[b,n.__[1]],n.__c.setState({}))}],n.__c=I,!I.u)){var i=function(c,d,b){if(!n.__c.__H)return!0;var E=n.__c.__H.__.filter(function(m){return!!m.__c});if(E.every(function(m){return!m.__N}))return!f||f.call(this,c,d,b);var u=!1;return E.forEach(function(m){if(m.__N){var v=m.__[0];m.__=m.__N,m.__N=void 0,v!==m.__[0]&&(u=!0)}}),!(!u&&n.__c.props===c)&&(!f||f.call(this,c,d,b))};I.u=!0;var f=I.shouldComponentUpdate,l=I.componentWillUpdate;I.componentWillUpdate=function(c,d,b){if(this.__e){var E=f;f=void 0,i(c,d,b),f=E}l&&l.call(this,c,d,b)},I.shouldComponentUpdate=i}return n.__N||n.__}function Pa(e,t){var r=ge(se++,3);!H.__s&&wr(r.__H,t)&&(r.__=e,r.i=t,I.__H.__h.push(r))}function qn(e,t){var r=ge(se++,4);!H.__s&&wr(r.__H,t)&&(r.__=e,r.i=t,I.__h.push(r))}function Oa(e){return Re=5,yr(function(){return{current:e}},[])}function Ia(e,t,r){Re=6,qn(function(){return typeof e=="function"?(e(t()),function(){return e(null)}):e?(e.current=t(),function(){return e.current=null}):void 0},r==null?r:r.concat(e))}function yr(e,t){var r=ge(se++,7);return wr(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function $a(e,t){return Re=8,yr(function(){return e},t)}function Fa(e){var t=I.context[e.__c],r=ge(se++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(I)),t.props.value):e.__}function Ua(e,t){H.useDebugValue&&H.useDebugValue(t?t(e):e)}function Ha(e){var t=ge(se++,10),r=Un();return t.__=e,I.componentDidCatch||(I.componentDidCatch=function(n,i){t.__&&t.__(n,i),r[1](n)}),[r[0],function(){r[1](void 0)}]}function qa(){var e=ge(se++,11);if(!e.__){for(var t=I.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var r=t.__m||(t.__m=[0,0]);e.__="P"+r[0]+"-"+r[1]++}return e.__}function ja(){for(var e;e=Fn.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ze),e.__H.__h.forEach(cr),e.__H.__h=[]}catch(t){e.__H.__h=[],H.__e(t,e.__v)}}H.__b=function(e){I=null,Vr&&Vr(e)},H.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Qr&&Qr(e,t)},H.__r=function(e){Kr&&Kr(e),se=0;var t=(I=e.__c).__H;t&&(ir===I?(t.__h=[],I.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(t.__h.forEach(ze),t.__h.forEach(cr),t.__h=[],se=0)),ir=I},H.diffed=function(e){Yr&&Yr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Fn.push(t)!==1&&Gr===H.requestAnimationFrame||((Gr=H.requestAnimationFrame)||Wa)(ja)),t.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),ir=I=null},H.__c=function(e,t){t.some(function(r){try{r.__h.forEach(ze),r.__h=r.__h.filter(function(n){return!n.__||cr(n)})}catch(n){t.some(function(i){i.__h&&(i.__h=[])}),t=[],H.__e(n,r.__v)}}),Xr&&Xr(e,t)},H.unmount=function(e){Jr&&Jr(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{ze(n)}catch(i){t=i}}),r.__H=void 0,t&&H.__e(t,r.__v))};var Zr=typeof requestAnimationFrame=="function";function Wa(e){var t,r=function(){clearTimeout(n),Zr&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(r,100);Zr&&(t=requestAnimationFrame(r))}function ze(e){var t=I,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),I=t}function cr(e){var t=I;e.__c=e.__(),I=t}function wr(e,t){return!e||e.length!==t.length||t.some(function(r,n){return r!==e[n]})}function jn(e,t){return typeof t=="function"?t(e):t}const za=Object.freeze(Object.defineProperty({__proto__:null,useCallback:$a,useContext:Fa,useDebugValue:Ua,useEffect:Pa,useErrorBoundary:Ha,useId:qa,useImperativeHandle:Ia,useLayoutEffect:qn,useMemo:yr,useReducer:Hn,useRef:Oa,useState:Un},Symbol.toStringTag,{value:"Module"})),Za=dr(za);export{Za as a,Ya as b,Xa as j,Qa as r,Ja as s}; diff --git a/buddybook/assets/index-1C-dIFy4.js b/buddybook/assets/index-1C-dIFy4.js new file mode 100644 index 0000000..9a5dfb4 --- /dev/null +++ b/buddybook/assets/index-1C-dIFy4.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D6T2G_iY.js","assets/index-mI-wCQlz.js","assets/index-Dt_CGZqf.css"])))=>i.map(i=>d[i]); +import{_ as pe}from"./index-mI-wCQlz.js";const me=Symbol(),ee=Object.getPrototypeOf,Y=new WeakMap,he=e=>e&&(Y.has(e)?Y.get(e):ee(e)===Object.prototype||ee(e)===Array.prototype),ge=e=>he(e)&&e[me]||null,te=(e,t=!0)=>{Y.set(e,t)},z={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_WALLETCONNECT_PROJECT_ID:"1d93edc21291f98e3bed6ff7617ff539"},J=e=>typeof e=="object"&&e!==null,L=new WeakMap,x=new WeakSet,ye=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>J(o)&&!x.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),n=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,g,I=n)=>{const v=l.get(o);if((v==null?void 0:v[0])===g)return v[1];const b=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(b,!0),l.set(o,[g,b]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(b,j))return;const O=Reflect.get(o,j),A={value:O,enumerable:!0,configurable:!0};if(x.has(O))te(O,!1);else if(O instanceof Promise)delete A.value,A.get=()=>I(O);else if(L.has(O)){const[y,H]=L.get(O);A.value=c(y,H(),I)}Object.defineProperty(b,j,A)}),Object.preventExtensions(b)},d=new WeakMap,f=[1,1],W=o=>{if(!J(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,b=(i,a=++f[0])=>{I!==a&&(I=a,v.forEach(r=>r(i,a)))};let j=f[1];const O=(i=++f[1])=>(j!==i&&!v.size&&(j=i,y.forEach(([a])=>{const r=a[1](i);r>I&&(I=r)})),I),A=i=>(a,r)=>{const h=[...a];h[1]=[i,...h[1]],b(h,r)},y=new Map,H=(i,a)=>{if((z?"production":void 0)!=="production"&&y.has(i))throw new Error("prop listener already exists");if(v.size){const r=a[3](A(i));y.set(i,[a,r])}else y.set(i,[a])},Z=i=>{var a;const r=y.get(i);r&&(y.delete(i),(a=r[1])==null||a.call(r))},ue=i=>(v.add(i),v.size===1&&y.forEach(([r,h],U)=>{if((z?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const N=r[3](A(U));y.set(U,[r,N])}),()=>{v.delete(i),v.size===0&&y.forEach(([r,h],U)=>{h&&(h(),y.set(U,[r]))})}),q=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),R=t(q,{deleteProperty(i,a){const r=Reflect.get(i,a);Z(a);const h=Reflect.deleteProperty(i,a);return h&&b(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),N=Reflect.get(i,a,h);if(U&&(e(N,r)||d.has(r)&&e(N,d.get(r))))return!0;Z(a),J(r)&&(r=ge(r)||r);let V=r;if(r instanceof Promise)r.then(C=>{r.status="fulfilled",r.value=C,b(["resolve",[a],C])}).catch(C=>{r.status="rejected",r.reason=C,b(["reject",[a],C])});else{!L.has(r)&&s(r)&&(V=W(r));const C=!x.has(V)&&L.get(V);C&&H(a,C)}return Reflect.set(i,a,V,h),b(["set",[a],r,N]),!0}});d.set(o,R);const fe=[q,O,c,ue];return L.set(R,fe),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(R[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(q,i,a)}),R})=>[W,L,x,e,t,s,n,l,c,d,f],[ve]=ye();function P(e={}){return ve(e)}function D(e,t,s){const n=L.get(e);(z?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let l;const c=[],d=n[3];let f=!1;const o=d(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function be(e,t){const s=L.get(e);(z?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[n,l,c]=s;return c(n,l(),t)}const u=P({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),de={state:u,subscribe(e){return D(u,()=>e(u))},push(e,t){e!==u.view&&(u.view=e,t&&(u.data=t),u.history.push(e))},reset(e){u.view=e,u.history=[e]},replace(e){u.history.length>1&&(u.history[u.history.length-1]=e,u.view=e)},goBack(){if(u.history.length>1){u.history.pop();const[e]=u.history.slice(-1);u.view=e}},setData(e){u.data=e}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return m.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;if(n.startsWith("https://t.me")){const c=Buffer.from(t).toString("base64").replace(/[=]/g,"");n.endsWith("/")&&(n=n.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const d=new URL(n);return d.searchParams.set("startapp",c),d.toString()}n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){const s=this.isTelegram()?"_blank":t;window.open(e,s,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(m.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=de.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},we=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:we,userSessionId:"",events:[],connectedWalletId:void 0}),Ie={state:p,subscribe(e){return D(p.events,()=>e(be(p.events[p.events.length-1])))},initialize(){p.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(p.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){p.connectedWalletId=e},click(e){if(p.enabled){const t={type:"CLICK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},track(e){if(p.enabled){const t={type:"TRACK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},view(e){if(p.enabled){const t={type:"VIEW",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}}},_=P({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),w={state:_,subscribe(e){return D(_,()=>e(_))},setChains(e){_.chains=e},setWalletConnectUri(e){_.walletConnectUri=e},setIsCustomDesktop(e){_.isCustomDesktop=e},setIsCustomMobile(e){_.isCustomMobile=e},setIsDataLoaded(e){_.isDataLoaded=e},setIsUiLoaded(e){_.isUiLoaded=e},setIsAuth(e){_.isAuth=e}},B=P({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),$={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;Ie.initialize(),w.setChains(e.chains),w.setIsAuth(!!e.enableAuthMode),w.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),w.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),m.setModalVersionInStorage(),Object.assign(B,e)}};var _e=Object.defineProperty,se=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,We=(e,t)=>{for(var s in t||(t={}))Ee.call(t,s)&&ne(e,s,t[s]);if(se)for(var s of se(t))Oe.call(t,s)&&ne(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.7.0";async function K(e,t){const s=We({sdkType:Q,sdkVersion:X},t),n=new URL(e,G);return n.searchParams.append("projectId",$.state.projectId),Object.entries(s).forEach(([c,d])=>{d&&n.searchParams.append(c,String(d))}),(await fetch(n)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var Ce=Object.defineProperty,oe=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ae=(e,t)=>{for(var s in t||(t={}))Le.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))Pe.call(t,s)&&re(e,s,t[s]);return e};const ae=m.isMobile(),E=P({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),ke={state:E,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=$.state;if(e==="NONE"||t==="ALL"&&!e)return E.recomendedWallets;if(m.isArray(e)){const n={recommendedIds:e.join(",")},{listings:l}=await M.getAllListings(n),c=Object.values(l);c.sort((d,f)=>{const W=e.indexOf(d.id),o=e.indexOf(f.id);return W-o}),E.recomendedWallets=c}else{const{chains:s,isAuth:n}=w.state,l=s==null?void 0:s.join(","),c=m.isArray(t),d={page:1,sdks:n?"auth_v1":void 0,entries:m.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=ae?await M.getMobileListings(d):await M.getDesktopListings(d);E.recomendedWallets=Object.values(f)}return E.recomendedWallets},async getWallets(e){const t=Ae({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:n}=$.state,{recomendedWallets:l}=E;if(n==="ALL")return E.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):m.isArray(s)&&(t.excludedIds=s.join(",")),m.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),w.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:d}=e,{listings:f,total:W}=ae?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),g=d?"search":"wallets";return E[g]={listings:[...E[g].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){E.search={listings:[],total:0,page:1}}},T=P({open:!1}),F={state:T,subscribe(e){return D(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=w.state;if(m.removeWalletConnectDeepLink(),w.setWalletConnectUri(e==null?void 0:e.uri),w.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=w.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),T.open=!0,t())},200)}})},close(){T.open=!1}};var Me=Object.defineProperty,ie=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,je=(e,t)=>{for(var s in t||(t={}))Se.call(t,s)&&le(e,s,t[s]);if(ie)for(var s of ie(t))De.call(t,s)&&le(e,s,t[s]);return e};function Ue(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const k=P({themeMode:Ue()?"dark":"light"}),ce={state:k,subscribe(e){return D(k,()=>e(k))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(k.themeMode=t),s&&(k.themeVariables=je({},s))}},S=P({open:!1,message:"",variant:"success"}),Re={state:S,subscribe(e){return D(S,()=>e(S))},openToast(e,t){S.open=!0,S.message=e,S.variant=t},closeToast(){S.open=!1}};class Te{constructor(t){this.openModal=F.open,this.closeModal=F.close,this.subscribeModal=F.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),$.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-D6T2G_iY.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),w.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Te},Symbol.toStringTag,{value:"Module"}));export{m as C,ke as E,F as M,w as O,de as R,ce as T,Re as a,Ie as b,$ as c,Ve as i}; diff --git a/buddybook/assets/index-D4poE_Tm.js b/buddybook/assets/index-B0w2h4-W.js similarity index 99% rename from buddybook/assets/index-D4poE_Tm.js rename to buddybook/assets/index-B0w2h4-W.js index e1b26c7..c33061f 100644 --- a/buddybook/assets/index-D4poE_Tm.js +++ b/buddybook/assets/index-B0w2h4-W.js @@ -1,2 +1,2 @@ -import{k as m,c as q,e as k,t as F,n as Ye,i as Je,I as Ze,s as B,B as xe,a as G,b as en,d as N,f as V}from"./index-CLqSQ1yP.js";const nn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,tn=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function an(e){const{domain:n={},message:t,primaryType:i}=e,r={EIP712Domain:un({domain:n}),...e.types};on({domain:n,message:t,primaryType:i,types:r});const a=["0x1901"];return n&&a.push(sn({domain:n,types:r})),i!=="EIP712Domain"&&a.push($({data:t,primaryType:i,types:r})),m(q(a))}function sn({domain:e,types:n}){return $({data:e,primaryType:"EIP712Domain",types:n})}function $({data:e,primaryType:n,types:t}){const i=K({data:e,primaryType:n,types:t});return m(i)}function K({data:e,primaryType:n,types:t}){const i=[{type:"bytes32"}],r=[cn({primaryType:n,types:t})];for(const a of t[n]){const[u,l]=Q({types:t,name:a.name,type:a.type,value:e[a.name]});i.push(u),r.push(l)}return k(i,r)}function cn({primaryType:e,types:n}){const t=F(rn({primaryType:e,types:n}));return m(t)}function rn({primaryType:e,types:n}){let t="";const i=X({primaryType:e,types:n});i.delete(e);const r=[e,...Array.from(i).sort()];for(const a of r)t+=`${a}(${n[a].map(({name:u,type:l})=>`${l} ${u}`).join(",")})`;return t}function X({primaryType:e,types:n},t=new Set){const i=e.match(/^\w*/u),r=i==null?void 0:i[0];if(t.has(r)||n[r]===void 0)return t;t.add(r);for(const a of n[r])X({primaryType:a.type,types:n},t);return t}function Q({types:e,name:n,type:t,value:i}){if(e[t]!==void 0)return[{type:"bytes32"},m(K({data:i,primaryType:t,types:e}))];if(t==="bytes")return i=`0x${(i.length%2?"0":"")+i.slice(2)}`,[{type:"bytes32"},m(i)];if(t==="string")return[{type:"bytes32"},m(F(i))];if(t.lastIndexOf("]")===t.length-1){const r=t.slice(0,t.lastIndexOf("[")),a=i.map(u=>Q({name:n,type:r,types:e,value:u}));return[{type:"bytes32"},m(k(a.map(([u])=>u),a.map(([,u])=>u)))]}return[{type:t},i]}function on(e){const{domain:n,message:t,primaryType:i,types:r}=e,a=(u,l)=>{for(const f of u){const{name:v,type:g}=f,h=l[v],p=g.match(tn);if(p&&(typeof h=="number"||typeof h=="bigint")){const[M,S,L]=p;Ye(h,{signed:S==="int",size:Number.parseInt(L)/8})}if(g==="address"&&typeof h=="string"&&!Je(h))throw new Ze({address:h});const C=g.match(nn);if(C){const[M,S]=C;if(S&&B(h)!==Number.parseInt(S))throw new xe({expectedSize:Number.parseInt(S),givenSize:B(h)})}const D=r[g];D&&a(D,h)}};r.EIP712Domain&&n&&a(r.EIP712Domain,n),i!=="EIP712Domain"&&a(r[i],t)}function un({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},typeof(e==null?void 0:e.chainId)=="number"&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}const dn=`Ethereum Signed Message: +import{k as m,c as q,e as k,t as F,n as Ye,i as Je,I as Ze,s as B,B as xe,a as G,b as en,d as N,f as V}from"./index-mI-wCQlz.js";const nn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,tn=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function an(e){const{domain:n={},message:t,primaryType:i}=e,r={EIP712Domain:un({domain:n}),...e.types};on({domain:n,message:t,primaryType:i,types:r});const a=["0x1901"];return n&&a.push(sn({domain:n,types:r})),i!=="EIP712Domain"&&a.push($({data:t,primaryType:i,types:r})),m(q(a))}function sn({domain:e,types:n}){return $({data:e,primaryType:"EIP712Domain",types:n})}function $({data:e,primaryType:n,types:t}){const i=K({data:e,primaryType:n,types:t});return m(i)}function K({data:e,primaryType:n,types:t}){const i=[{type:"bytes32"}],r=[cn({primaryType:n,types:t})];for(const a of t[n]){const[u,l]=Q({types:t,name:a.name,type:a.type,value:e[a.name]});i.push(u),r.push(l)}return k(i,r)}function cn({primaryType:e,types:n}){const t=F(rn({primaryType:e,types:n}));return m(t)}function rn({primaryType:e,types:n}){let t="";const i=X({primaryType:e,types:n});i.delete(e);const r=[e,...Array.from(i).sort()];for(const a of r)t+=`${a}(${n[a].map(({name:u,type:l})=>`${l} ${u}`).join(",")})`;return t}function X({primaryType:e,types:n},t=new Set){const i=e.match(/^\w*/u),r=i==null?void 0:i[0];if(t.has(r)||n[r]===void 0)return t;t.add(r);for(const a of n[r])X({primaryType:a.type,types:n},t);return t}function Q({types:e,name:n,type:t,value:i}){if(e[t]!==void 0)return[{type:"bytes32"},m(K({data:i,primaryType:t,types:e}))];if(t==="bytes")return i=`0x${(i.length%2?"0":"")+i.slice(2)}`,[{type:"bytes32"},m(i)];if(t==="string")return[{type:"bytes32"},m(F(i))];if(t.lastIndexOf("]")===t.length-1){const r=t.slice(0,t.lastIndexOf("[")),a=i.map(u=>Q({name:n,type:r,types:e,value:u}));return[{type:"bytes32"},m(k(a.map(([u])=>u),a.map(([,u])=>u)))]}return[{type:t},i]}function on(e){const{domain:n,message:t,primaryType:i,types:r}=e,a=(u,l)=>{for(const f of u){const{name:v,type:g}=f,h=l[v],p=g.match(tn);if(p&&(typeof h=="number"||typeof h=="bigint")){const[M,S,L]=p;Ye(h,{signed:S==="int",size:Number.parseInt(L)/8})}if(g==="address"&&typeof h=="string"&&!Je(h))throw new Ze({address:h});const C=g.match(nn);if(C){const[M,S]=C;if(S&&B(h)!==Number.parseInt(S))throw new xe({expectedSize:Number.parseInt(S),givenSize:B(h)})}const D=r[g];D&&a(D,h)}};r.EIP712Domain&&n&&a(r.EIP712Domain,n),i!=="EIP712Domain"&&a(r[i],t)}function un({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},typeof(e==null?void 0:e.chainId)=="number"&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}const dn=`Ethereum Signed Message: `;function ln(e){const n=typeof e=="string"?G(e):typeof e.raw=="string"?e.raw:en(e.raw),t=G(`${dn}${B(n)}`);return q([t,n])}function fn(e,n){return m(ln(e),n)}const gn=()=>"9.1.0",hn=e=>e.toString(16).padStart(2,"0"),En=e=>{const n=new Uint8Array(e/2);return window.crypto.getRandomValues(n),Array.from(n,hn).join("")},_n=()=>typeof window<"u"?En(10):new Date().getTime().toString(36);class w{}w.makeRequest=(e,n)=>({id:_n(),method:e,params:n,env:{sdkVersion:gn()}});w.makeResponse=(e,n,t)=>({id:e,success:!0,version:t,data:n});w.makeErrorResponse=(e,n,t)=>({id:e,success:!1,error:n,version:t});var E;(function(e){e.sendTransactions="sendTransactions",e.rpcCall="rpcCall",e.getChainInfo="getChainInfo",e.getSafeInfo="getSafeInfo",e.getTxBySafeTxHash="getTxBySafeTxHash",e.getSafeBalances="getSafeBalances",e.signMessage="signMessage",e.signTypedMessage="signTypedMessage",e.getEnvironmentInfo="getEnvironmentInfo",e.getOffChainSignature="getOffChainSignature",e.requestAddressBook="requestAddressBook",e.wallet_getPermissions="wallet_getPermissions",e.wallet_requestPermissions="wallet_requestPermissions"})(E||(E={}));var H;(function(e){e.requestAddressBook="requestAddressBook"})(H||(H={}));class yn{constructor(n=null,t=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer=typeof window>"u",this.isValidMessage=({origin:i,data:r,source:a})=>{const u=!r,l=!this.isServer&&a===window.parent,f=typeof r.version<"u"&&parseInt(r.version.split(".")[0]),v=typeof f=="number"&&f>=1;let g=!0;return Array.isArray(this.allowedOrigins)&&(g=this.allowedOrigins.find(h=>h.test(i))!==void 0),!u&&l&&v&&g},this.logIncomingMessage=i=>{console.info(`Safe Apps SDK v1: A message was received from origin ${i.origin}. `,i.data)},this.onParentMessage=i=>{this.isValidMessage(i)&&(this.debugMode&&this.logIncomingMessage(i),this.handleIncomingMessage(i.data))},this.handleIncomingMessage=i=>{const{id:r}=i,a=this.callbacks.get(r);a&&(a(i),this.callbacks.delete(r))},this.send=(i,r)=>{const a=w.makeRequest(i,r);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(a,"*"),new Promise((u,l)=>{this.callbacks.set(a.id,f=>{if(!f.success){l(new Error(f.error));return}u(f)})})},this.allowedOrigins=n,this.debugMode=t,this.isServer||window.addEventListener("message",this.onParentMessage)}}const z=e=>typeof e=="object"&&e!=null&&"domain"in e&&"types"in e&&"message"in e;var Tn={},y={},T={},j=N&&N.__awaiter||function(e,n,t,i){function r(a){return a instanceof t?a:new t(function(u){u(a)})}return new(t||(t=Promise))(function(a,u){function l(g){try{v(i.next(g))}catch(h){u(h)}}function f(g){try{v(i.throw(g))}catch(h){u(h)}}function v(g){g.done?a(g.value):r(g.value).then(l,f)}v((i=i.apply(e,n||[])).next())})};Object.defineProperty(T,"__esModule",{value:!0});T.getData=T.fetchData=T.stringifyQuery=T.insertParams=void 0;const vn=e=>typeof e=="object"&&e!==null&&"code"in e&&"message"in e;function In(e,n,t){return e.replace(new RegExp(`\\{${n}\\}`,"g"),t)}function An(e,n){return n?Object.keys(n).reduce((t,i)=>In(t,i,String(n[i])),e):e}T.insertParams=An;function mn(e){if(!e)return"";const n=new URLSearchParams;Object.keys(e).forEach(i=>{e[i]!=null&&n.append(i,String(e[i]))});const t=n.toString();return t?`?${t}`:""}T.stringifyQuery=mn;function Y(e){return j(this,void 0,void 0,function*(){let n;try{n=yield e.json()}catch{n={}}if(!e.ok){const t=vn(n)?`CGW error - ${n.code}: ${n.message}`:`CGW error - status ${e.statusText}`;throw new Error(t)}return n})}function Sn(e,n,t,i,r){return j(this,void 0,void 0,function*(){const a=Object.assign({"Content-Type":"application/json"},i),u={method:n??"POST",headers:a};r&&(u.credentials=r),t!=null&&(u.body=typeof t=="string"?t:JSON.stringify(t));const l=yield fetch(e,u);return Y(l)})}T.fetchData=Sn;function On(e,n,t){return j(this,void 0,void 0,function*(){const i={method:"GET"};n&&(i.headers=Object.assign(Object.assign({},n),{"Content-Type":"application/json"})),t&&(i.credentials=t);const r=yield fetch(e,i);return Y(r)})}T.getData=On;Object.defineProperty(y,"__esModule",{value:!0});y.getEndpoint=y.deleteEndpoint=y.putEndpoint=y.postEndpoint=void 0;const O=T;function P(e,n,t,i){const r=(0,O.insertParams)(n,t),a=(0,O.stringifyQuery)(i);return`${e}${r}${a}`}function Nn(e,n,t){const i=P(e,n,t==null?void 0:t.path,t==null?void 0:t.query);return(0,O.fetchData)(i,"POST",t==null?void 0:t.body,t==null?void 0:t.headers,t==null?void 0:t.credentials)}y.postEndpoint=Nn;function bn(e,n,t){const i=P(e,n,t==null?void 0:t.path,t==null?void 0:t.query);return(0,O.fetchData)(i,"PUT",t==null?void 0:t.body,t==null?void 0:t.headers,t==null?void 0:t.credentials)}y.putEndpoint=bn;function pn(e,n,t){const i=P(e,n,t==null?void 0:t.path,t==null?void 0:t.query);return(0,O.fetchData)(i,"DELETE",t==null?void 0:t.body,t==null?void 0:t.headers,t==null?void 0:t.credentials)}y.deleteEndpoint=pn;function Cn(e,n,t,i){if(i)return(0,O.getData)(i,void 0,t==null?void 0:t.credentials);const r=P(e,n,t==null?void 0:t.path,t==null?void 0:t.query);return(0,O.getData)(r,t==null?void 0:t.headers,t==null?void 0:t.credentials)}y.getEndpoint=Cn;var R={};Object.defineProperty(R,"__esModule",{value:!0});R.DEFAULT_BASE_URL=void 0;R.DEFAULT_BASE_URL="https://safe-client.safe.global";var J={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ImplementationVersionState=void 0,function(n){n.UP_TO_DATE="UP_TO_DATE",n.OUTDATED="OUTDATED",n.UNKNOWN="UNKNOWN"}(e.ImplementationVersionState||(e.ImplementationVersionState={}))})(J);var Z={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppSocialPlatforms=e.SafeAppFeatures=e.SafeAppAccessPolicyTypes=void 0,function(n){n.NoRestrictions="NO_RESTRICTIONS",n.DomainAllowlist="DOMAIN_ALLOWLIST"}(e.SafeAppAccessPolicyTypes||(e.SafeAppAccessPolicyTypes={})),function(n){n.BATCHED_TRANSACTIONS="BATCHED_TRANSACTIONS"}(e.SafeAppFeatures||(e.SafeAppFeatures={})),function(n){n.TWITTER="TWITTER",n.GITHUB="GITHUB",n.DISCORD="DISCORD"}(e.SafeAppSocialPlatforms||(e.SafeAppSocialPlatforms={}))})(Z);var x={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LabelValue=e.StartTimeValue=e.DurationType=e.DetailedExecutionInfoType=e.TransactionListItemType=e.ConflictType=e.TransactionInfoType=e.SettingsInfoType=e.TransactionTokenType=e.TransferDirection=e.TransactionStatus=e.Operation=void 0,function(n){n[n.CALL=0]="CALL",n[n.DELEGATE=1]="DELEGATE"}(e.Operation||(e.Operation={})),function(n){n.AWAITING_CONFIRMATIONS="AWAITING_CONFIRMATIONS",n.AWAITING_EXECUTION="AWAITING_EXECUTION",n.CANCELLED="CANCELLED",n.FAILED="FAILED",n.SUCCESS="SUCCESS"}(e.TransactionStatus||(e.TransactionStatus={})),function(n){n.INCOMING="INCOMING",n.OUTGOING="OUTGOING",n.UNKNOWN="UNKNOWN"}(e.TransferDirection||(e.TransferDirection={})),function(n){n.ERC20="ERC20",n.ERC721="ERC721",n.NATIVE_COIN="NATIVE_COIN"}(e.TransactionTokenType||(e.TransactionTokenType={})),function(n){n.SET_FALLBACK_HANDLER="SET_FALLBACK_HANDLER",n.ADD_OWNER="ADD_OWNER",n.REMOVE_OWNER="REMOVE_OWNER",n.SWAP_OWNER="SWAP_OWNER",n.CHANGE_THRESHOLD="CHANGE_THRESHOLD",n.CHANGE_IMPLEMENTATION="CHANGE_IMPLEMENTATION",n.ENABLE_MODULE="ENABLE_MODULE",n.DISABLE_MODULE="DISABLE_MODULE",n.SET_GUARD="SET_GUARD",n.DELETE_GUARD="DELETE_GUARD"}(e.SettingsInfoType||(e.SettingsInfoType={})),function(n){n.TRANSFER="Transfer",n.SETTINGS_CHANGE="SettingsChange",n.CUSTOM="Custom",n.CREATION="Creation",n.SWAP_ORDER="SwapOrder",n.TWAP_ORDER="TwapOrder",n.SWAP_TRANSFER="SwapTransfer"}(e.TransactionInfoType||(e.TransactionInfoType={})),function(n){n.NONE="None",n.HAS_NEXT="HasNext",n.END="End"}(e.ConflictType||(e.ConflictType={})),function(n){n.TRANSACTION="TRANSACTION",n.LABEL="LABEL",n.CONFLICT_HEADER="CONFLICT_HEADER",n.DATE_LABEL="DATE_LABEL"}(e.TransactionListItemType||(e.TransactionListItemType={})),function(n){n.MULTISIG="MULTISIG",n.MODULE="MODULE"}(e.DetailedExecutionInfoType||(e.DetailedExecutionInfoType={})),function(n){n.AUTO="AUTO",n.LIMIT_DURATION="LIMIT_DURATION"}(e.DurationType||(e.DurationType={})),function(n){n.AT_MINING_TIME="AT_MINING_TIME",n.AT_EPOCH="AT_EPOCH"}(e.StartTimeValue||(e.StartTimeValue={})),function(n){n.Queued="Queued",n.Next="Next"}(e.LabelValue||(e.LabelValue={}))})(x);var ee={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.FEATURES=e.GAS_PRICE_TYPE=e.RPC_AUTHENTICATION=void 0,function(n){n.API_KEY_PATH="API_KEY_PATH",n.NO_AUTHENTICATION="NO_AUTHENTICATION",n.UNKNOWN="UNKNOWN"}(e.RPC_AUTHENTICATION||(e.RPC_AUTHENTICATION={})),function(n){n.ORACLE="ORACLE",n.FIXED="FIXED",n.FIXED_1559="FIXED1559",n.UNKNOWN="UNKNOWN"}(e.GAS_PRICE_TYPE||(e.GAS_PRICE_TYPE={})),function(n){n.ERC721="ERC721",n.SAFE_APPS="SAFE_APPS",n.CONTRACT_INTERACTION="CONTRACT_INTERACTION",n.DOMAIN_LOOKUP="DOMAIN_LOOKUP",n.SPENDING_LIMIT="SPENDING_LIMIT",n.EIP1559="EIP1559",n.SAFE_TX_GAS_OPTIONAL="SAFE_TX_GAS_OPTIONAL",n.TX_SIMULATION="TX_SIMULATION",n.EIP1271="EIP1271"}(e.FEATURES||(e.FEATURES={}))})(ee);var ne={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TokenType=void 0,function(n){n.ERC20="ERC20",n.ERC721="ERC721",n.NATIVE_TOKEN="NATIVE_TOKEN"}(e.TokenType||(e.TokenType={}))})(ne);var te={};Object.defineProperty(te,"__esModule",{value:!0});var ie={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ConfirmationViewTypes=void 0,function(n){n.COW_SWAP_ORDER="COW_SWAP_ORDER",n.COW_SWAP_TWAP_ORDER="COW_SWAP_TWAP_ORDER"}(e.ConfirmationViewTypes||(e.ConfirmationViewTypes={}))})(ie);var ae={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeMessageStatus=e.SafeMessageListItemType=void 0,function(n){n.DATE_LABEL="DATE_LABEL",n.MESSAGE="MESSAGE"}(e.SafeMessageListItemType||(e.SafeMessageListItemType={})),function(n){n.NEEDS_CONFIRMATION="NEEDS_CONFIRMATION",n.CONFIRMED="CONFIRMED"}(e.SafeMessageStatus||(e.SafeMessageStatus={}))})(ae);var se={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DeviceType=void 0,function(n){n.ANDROID="ANDROID",n.IOS="IOS",n.WEB="WEB"}(e.DeviceType||(e.DeviceType={}))})(se);var ce={};Object.defineProperty(ce,"__esModule",{value:!0});(function(e){var n=N&&N.__createBinding||(Object.create?function(s,c,o,d){d===void 0&&(d=o);var A=Object.getOwnPropertyDescriptor(c,o);(!A||("get"in A?!c.__esModule:A.writable||A.configurable))&&(A={enumerable:!0,get:function(){return c[o]}}),Object.defineProperty(s,d,A)}:function(s,c,o,d){d===void 0&&(d=o),s[d]=c[o]}),t=N&&N.__exportStar||function(s,c){for(var o in s)o!=="default"&&!Object.prototype.hasOwnProperty.call(c,o)&&n(c,s,o)};Object.defineProperty(e,"__esModule",{value:!0}),e.deleteAccount=e.getAccount=e.createAccount=e.verifyAuth=e.getAuthNonce=e.getContract=e.getSafeOverviews=e.unsubscribeAll=e.unsubscribeSingle=e.registerRecoveryModule=e.deleteRegisteredEmail=e.getRegisteredEmail=e.verifyEmail=e.resendEmailVerificationCode=e.changeEmail=e.registerEmail=e.unregisterDevice=e.unregisterSafe=e.registerDevice=e.getDelegates=e.confirmSafeMessage=e.proposeSafeMessage=e.getSafeMessage=e.getSafeMessages=e.getDecodedData=e.getMasterCopies=e.getSafeApps=e.getChainConfig=e.getChainsConfig=e.getConfirmationView=e.proposeTransaction=e.getNonces=e.postSafeGasEstimation=e.deleteTransaction=e.getTransactionDetails=e.getTransactionQueue=e.getTransactionHistory=e.getCollectiblesPage=e.getCollectibles=e.getAllOwnedSafes=e.getOwnedSafes=e.getFiatCurrencies=e.getBalances=e.getMultisigTransactions=e.getModuleTransactions=e.getIncomingTransfers=e.getSafeInfo=e.getRelayCount=e.relayTransaction=e.setBaseUrl=void 0,e.putAccountDataSettings=e.getAccountDataSettings=e.getAccountDataTypes=void 0;const i=y,r=R;t(J,e),t(Z,e),t(x,e),t(ee,e),t(ne,e),t(te,e),t(ie,e),t(ae,e),t(se,e),t(ce,e);let a=r.DEFAULT_BASE_URL;const u=s=>{a=s};e.setBaseUrl=u;function l(s,c){return(0,i.postEndpoint)(a,"/v1/chains/{chainId}/relay",{path:{chainId:s},body:c})}e.relayTransaction=l;function f(s,c){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/relay/{address}",{path:{chainId:s,address:c}})}e.getRelayCount=f;function v(s,c){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{address}",{path:{chainId:s,address:c}})}e.getSafeInfo=v;function g(s,c,o,d){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{address}/incoming-transfers/",{path:{chainId:s,address:c},query:o},d)}e.getIncomingTransfers=g;function h(s,c,o,d){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{address}/module-transactions/",{path:{chainId:s,address:c},query:o},d)}e.getModuleTransactions=h;function p(s,c,o,d){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{address}/multisig-transactions/",{path:{chainId:s,address:c},query:o},d)}e.getMultisigTransactions=p;function C(s,c,o="usd",d={}){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{address}/balances/{currency}",{path:{chainId:s,address:c,currency:o},query:d})}e.getBalances=C;function D(){return(0,i.getEndpoint)(a,"/v1/balances/supported-fiat-codes")}e.getFiatCurrencies=D;function M(s,c){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/owners/{address}/safes",{path:{chainId:s,address:c}})}e.getOwnedSafes=M;function S(s){return(0,i.getEndpoint)(a,"/v1/owners/{address}/safes",{path:{address:s}})}e.getAllOwnedSafes=S;function L(s,c,o={}){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:s,address:c},query:o})}e.getCollectibles=L;function ue(s,c,o={},d){return(0,i.getEndpoint)(a,"/v2/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:s,address:c},query:o},d)}e.getCollectiblesPage=ue;function de(s,c,o={},d){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/transactions/history",{path:{chainId:s,safe_address:c},query:o},d)}e.getTransactionHistory=de;function le(s,c,o={},d){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/transactions/queued",{path:{chainId:s,safe_address:c},query:o},d)}e.getTransactionQueue=le;function fe(s,c){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/transactions/{transactionId}",{path:{chainId:s,transactionId:c}})}e.getTransactionDetails=fe;function ge(s,c,o){return(0,i.deleteEndpoint)(a,"/v1/chains/{chainId}/transactions/{safeTxHash}",{path:{chainId:s,safeTxHash:c},body:{signature:o}})}e.deleteTransaction=ge;function he(s,c,o){return(0,i.postEndpoint)(a,"/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations",{path:{chainId:s,safe_address:c},body:o})}e.postSafeGasEstimation=he;function Ee(s,c){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/nonces",{path:{chainId:s,safe_address:c}})}e.getNonces=Ee;function _e(s,c,o){return(0,i.postEndpoint)(a,"/v1/chains/{chainId}/transactions/{safe_address}/propose",{path:{chainId:s,safe_address:c},body:o})}e.proposeTransaction=_e;function ye(s,c,o,d){return(0,i.postEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/views/transaction-confirmation",{path:{chainId:s,safe_address:c},body:{data:o,to:d}})}e.getConfirmationView=ye;function Te(s){return(0,i.getEndpoint)(a,"/v1/chains",{query:s})}e.getChainsConfig=Te;function ve(s){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}",{path:{chainId:s}})}e.getChainConfig=ve;function Ie(s,c={}){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safe-apps",{path:{chainId:s},query:c})}e.getSafeApps=Ie;function Ae(s){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/about/master-copies",{path:{chainId:s}})}e.getMasterCopies=Ae;function me(s,c,o){return(0,i.postEndpoint)(a,"/v1/chains/{chainId}/data-decoder",{path:{chainId:s},body:{data:c,to:o}})}e.getDecodedData=me;function Se(s,c,o){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:s,safe_address:c},query:{}},o)}e.getSafeMessages=Se;function Oe(s,c){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/messages/{message_hash}",{path:{chainId:s,message_hash:c}})}e.getSafeMessage=Oe;function Ne(s,c,o){return(0,i.postEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:s,safe_address:c},body:o})}e.proposeSafeMessage=Ne;function be(s,c,o){return(0,i.postEndpoint)(a,"/v1/chains/{chainId}/messages/{message_hash}/signatures",{path:{chainId:s,message_hash:c},body:o})}e.confirmSafeMessage=be;function pe(s,c={}){return(0,i.getEndpoint)(a,"/v2/chains/{chainId}/delegates",{path:{chainId:s},query:c})}e.getDelegates=pe;function Ce(s){return(0,i.postEndpoint)(a,"/v1/register/notifications",{body:s})}e.registerDevice=Ce;function De(s,c,o){return(0,i.deleteEndpoint)(a,"/v1/chains/{chainId}/notifications/devices/{uuid}/safes/{safe_address}",{path:{chainId:s,safe_address:c,uuid:o}})}e.unregisterSafe=De;function we(s,c){return(0,i.deleteEndpoint)(a,"/v1/chains/{chainId}/notifications/devices/{uuid}",{path:{chainId:s,uuid:c}})}e.unregisterDevice=we;function Pe(s,c,o,d){return(0,i.postEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/emails",{path:{chainId:s,safe_address:c},body:o,headers:d})}e.registerEmail=Pe;function Re(s,c,o,d,A){return(0,i.putEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}",{path:{chainId:s,safe_address:c,signer:o},body:d,headers:A})}e.changeEmail=Re;function Me(s,c,o){return(0,i.postEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}/verify-resend",{path:{chainId:s,safe_address:c,signer:o},body:""})}e.resendEmailVerificationCode=Me;function Le(s,c,o,d){return(0,i.putEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}/verify",{path:{chainId:s,safe_address:c,signer:o},body:d})}e.verifyEmail=Le;function Be(s,c,o,d){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}",{path:{chainId:s,safe_address:c,signer:o},headers:d})}e.getRegisteredEmail=Be;function He(s,c,o,d){return(0,i.deleteEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}",{path:{chainId:s,safe_address:c,signer:o},headers:d})}e.deleteRegisteredEmail=He;function Ue(s,c,o){return(0,i.postEndpoint)(a,"/v1/chains/{chainId}/safes/{safe_address}/recovery",{path:{chainId:s,safe_address:c},body:o})}e.registerRecoveryModule=Ue;function je(s){return(0,i.deleteEndpoint)(a,"/v1/subscriptions",{query:s})}e.unsubscribeSingle=je;function Ge(s){return(0,i.deleteEndpoint)(a,"/v1/subscriptions/all",{query:s})}e.unsubscribeAll=Ge;function Ve(s,c){return(0,i.getEndpoint)(a,"/v1/safes",{query:Object.assign(Object.assign({},c),{safes:s.join(",")})})}e.getSafeOverviews=Ve;function We(s,c){return(0,i.getEndpoint)(a,"/v1/chains/{chainId}/contracts/{contractAddress}",{path:{chainId:s,contractAddress:c}})}e.getContract=We;function qe(){return(0,i.getEndpoint)(a,"/v1/auth/nonce",{credentials:"include"})}e.getAuthNonce=qe;function ke(s){return(0,i.postEndpoint)(a,"/v1/auth/verify",{body:s,credentials:"include"})}e.verifyAuth=ke;function Fe(s){return(0,i.postEndpoint)(a,"/v1/accounts",{body:s,credentials:"include"})}e.createAccount=Fe;function $e(s){return(0,i.getEndpoint)(a,"/v1/accounts/{address}",{path:{address:s},credentials:"include"})}e.getAccount=$e;function Ke(s){return(0,i.deleteEndpoint)(a,"/v1/accounts/{address}",{path:{address:s},credentials:"include"})}e.deleteAccount=Ke;function Xe(){return(0,i.getEndpoint)(a,"/v1/accounts/data-types")}e.getAccountDataTypes=Xe;function Qe(s){return(0,i.getEndpoint)(a,"/v1/accounts/{address}/data-settings",{path:{address:s},credentials:"include"})}e.getAccountDataSettings=Qe;function ze(s,c){return(0,i.putEndpoint)(a,"/v1/accounts/{address}/data-settings",{path:{address:s},body:c,credentials:"include"})}e.putAccountDataSettings=ze})(Tn);class Dn{constructor(n){this.communicator=n}async getBySafeTxHash(n){if(!n)throw new Error("Invalid safeTxHash");return(await this.communicator.send(E.getTxBySafeTxHash,{safeTxHash:n})).data}async signMessage(n){const t={message:n};return(await this.communicator.send(E.signMessage,t)).data}async signTypedMessage(n){if(!z(n))throw new Error("Invalid typed data");return(await this.communicator.send(E.signTypedMessage,{typedData:n})).data}async send({txs:n,params:t}){if(!n||!n.length)throw new Error("No transactions were passed");const i={txs:n,params:t};return(await this.communicator.send(E.sendTransactions,i)).data}}const _={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},I={defaultBlockParam:(e="latest")=>e,returnFullTxObjectParam:(e=!1)=>e,blockNumberToHex:e=>Number.isInteger(e)?`0x${e.toString(16)}`:e};class wn{constructor(n){this.communicator=n,this.call=this.buildRequest({call:_.eth_call,formatters:[null,I.defaultBlockParam]}),this.getBalance=this.buildRequest({call:_.eth_getBalance,formatters:[null,I.defaultBlockParam]}),this.getCode=this.buildRequest({call:_.eth_getCode,formatters:[null,I.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:_.eth_getStorageAt,formatters:[null,I.blockNumberToHex,I.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:_.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:_.eth_getBlockByHash,formatters:[null,I.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:_.eth_getBlockByNumber,formatters:[I.blockNumberToHex,I.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:_.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:_.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:_.eth_getTransactionCount,formatters:[null,I.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:_.eth_gasPrice}),this.getEstimateGas=t=>this.buildRequest({call:_.eth_estimateGas})([t]),this.setSafeSettings=this.buildRequest({call:_.safe_setSettings})}buildRequest(n){const{call:t,formatters:i}=n;return async r=>{i&&Array.isArray(r)&&i.forEach((l,f)=>{l&&(r[f]=l(r[f]))});const a={call:t,params:r||[]};return(await this.communicator.send(E.rpcCall,a)).data}}}const Pn="0x1626ba7e",Rn="0x20c13b0b",U=4001;class b extends Error{constructor(n,t,i){super(n),this.code=t,this.data=i,Object.setPrototypeOf(this,b.prototype)}}class re{constructor(n){this.communicator=n}async getPermissions(){return(await this.communicator.send(E.wallet_getPermissions,void 0)).data}async requestPermissions(n){if(!this.isPermissionRequestValid(n))throw new b("Permissions request is invalid",U);try{return(await this.communicator.send(E.wallet_requestPermissions,n)).data}catch{throw new b("Permissions rejected",U)}}isPermissionRequestValid(n){return n.every(t=>typeof t=="object"?Object.keys(t).every(i=>!!Object.values(H).includes(i)):!1)}}const W=(e,n)=>n.some(t=>t.parentCapability===e),Mn=()=>(e,n,t)=>{const i=t.value;return t.value=async function(){const r=new re(this.communicator);let a=await r.getPermissions();if(W(n,a)||(a=await r.requestPermissions([{[n]:{}}])),!W(n,a))throw new b("Permissions rejected",U);return i.apply(this)},t};var Ln=function(e,n,t,i){var r=arguments.length,a=r<3?n:i===null?i=Object.getOwnPropertyDescriptor(n,t):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,n,t,i);else for(var l=e.length-1;l>=0;l--)(u=e[l])&&(a=(r<3?u(a):r>3?u(n,t,a):u(n,t))||a);return r>3&&a&&Object.defineProperty(n,t,a),a};class oe{constructor(n){this.communicator=n}async getChainInfo(){return(await this.communicator.send(E.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(E.getSafeInfo,void 0)).data}async experimental_getBalances({currency:n="usd"}={}){return(await this.communicator.send(E.getSafeBalances,{currency:n})).data}async check1271Signature(n,t="0x"){const i=await this.getInfo(),r=V({abi:[{constant:!1,inputs:[{name:"_dataHash",type:"bytes32"},{name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"",type:"bytes4"}],payable:!1,stateMutability:"nonpayable",type:"function"}],functionName:"isValidSignature",args:[n,t]}),a={call:_.eth_call,params:[{to:i.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(E.rpcCall,a)).data.slice(0,10).toLowerCase()===Pn}catch{return!1}}async check1271SignatureBytes(n,t="0x"){const i=await this.getInfo(),r=V({abi:[{constant:!1,inputs:[{name:"_data",type:"bytes"},{name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"",type:"bytes4"}],payable:!1,stateMutability:"nonpayable",type:"function"}],functionName:"isValidSignature",args:[n,t]}),a={call:_.eth_call,params:[{to:i.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(E.rpcCall,a)).data.slice(0,10).toLowerCase()===Rn}catch{return!1}}calculateMessageHash(n){return fn(n)}calculateTypedMessageHash(n){const t=typeof n.domain.chainId=="object"?n.domain.chainId.toNumber():Number(n.domain.chainId);let i=n.primaryType;if(!i){const r=Object.values(n.types),a=Object.keys(n.types).filter(u=>r.every(l=>l.every(({type:f})=>f.replace("[","").replace("]","")!==u)));if(a.length===0||a.length>1)throw new Error("Please specify primaryType");i=a[0]}return an({message:n.message,domain:{...n.domain,chainId:t,verifyingContract:n.domain.verifyingContract,salt:n.domain.salt},types:n.types,primaryType:i})}async getOffChainSignature(n){return(await this.communicator.send(E.getOffChainSignature,n)).data}async isMessageSigned(n,t="0x"){let i;if(typeof n=="string"&&(i=async()=>{const r=this.calculateMessageHash(n);return await this.isMessageHashSigned(r,t)}),z(n)&&(i=async()=>{const r=this.calculateTypedMessageHash(n);return await this.isMessageHashSigned(r,t)}),i)return await i();throw new Error("Invalid message type")}async isMessageHashSigned(n,t="0x"){const i=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const r of i)if(await r(n,t))return!0;return!1}async getEnvironmentInfo(){return(await this.communicator.send(E.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(E.requestAddressBook,void 0)).data}}Ln([Mn()],oe.prototype,"requestAddressBook",null);class Hn{constructor(n={}){const{allowedDomains:t=null,debug:i=!1}=n;this.communicator=new yn(t,i),this.eth=new wn(this.communicator),this.txs=new Dn(this.communicator),this.safe=new oe(this.communicator),this.wallet=new re(this.communicator)}}export{w as MessageFormatter,E as Methods,_ as RPC_CALLS,H as RestrictedMethods,Hn as default,gn as getSDKVersion,z as isObjectEIP712TypedData}; diff --git a/buddybook/assets/index-C5SJQ4cM.js b/buddybook/assets/index-BcaB-heU.js similarity index 64% rename from buddybook/assets/index-C5SJQ4cM.js rename to buddybook/assets/index-BcaB-heU.js index f640266..51f1d52 100644 --- a/buddybook/assets/index-C5SJQ4cM.js +++ b/buddybook/assets/index-BcaB-heU.js @@ -1 +1 @@ -import{d as M,g as sn,h as an}from"./index-CLqSQ1yP.js";import{j as on,s as cn,r as _t,a as dn,b as ln}from"./hooks.module-CBpTII2E.js";var Et={},te={},me={};Object.defineProperty(me,"__esModule",{value:!0});me.walletLogo=void 0;const un=(n,e)=>{let t;switch(n){case"standard":return t=e,`data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return t=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${t}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return t=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return t=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return t=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return t=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return t=e,`data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};me.walletLogo=un;var be={},j={},U={};Object.defineProperty(U,"__esModule",{value:!0});U.errorValues=U.standardErrorCodes=void 0;U.standardErrorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}};U.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}};var ye={},$e={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.serialize=n.getErrorCode=n.isValidCode=n.getMessageFromCode=n.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=U,t="Unspecified error message.";n.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function r(d,p=t){if(d&&Number.isInteger(d)){const m=d.toString();if(h(e.errorValues,m))return e.errorValues[m].message;if(c(d))return n.JSON_RPC_SERVER_ERROR_MESSAGE}return p}n.getMessageFromCode=r;function s(d){if(!Number.isInteger(d))return!1;const p=d.toString();return!!(e.errorValues[p]||c(d))}n.isValidCode=s;function i(d){var p;if(typeof d=="number")return d;if(a(d))return(p=d.code)!==null&&p!==void 0?p:d.errorCode}n.getErrorCode=i;function a(d){return typeof d=="object"&&d!==null&&(typeof d.code=="number"||typeof d.errorCode=="number")}function o(d,{shouldIncludeStack:p=!1}={}){const m={};if(d&&typeof d=="object"&&!Array.isArray(d)&&h(d,"code")&&s(d.code)){const B=d;m.code=B.code,B.message&&typeof B.message=="string"?(m.message=B.message,h(B,"data")&&(m.data=B.data)):(m.message=r(m.code),m.data={originalError:l(d)})}else m.code=e.standardErrorCodes.rpc.internal,m.message=f(d,"message")?d.message:t,m.data={originalError:l(d)};return p&&(m.stack=f(d,"stack")?d.stack:void 0),m}n.serialize=o;function c(d){return d>=-32099&&d<=-32e3}function l(d){return d&&typeof d=="object"&&!Array.isArray(d)?Object.assign({},d):d}function h(d,p){return Object.prototype.hasOwnProperty.call(d,p)}function f(d,p){return typeof d=="object"&&d!==null&&p in d&&typeof d[p]=="string"}})($e);Object.defineProperty(ye,"__esModule",{value:!0});ye.standardErrors=void 0;const v=U,St=$e;ye.standardErrors={rpc:{parse:n=>C(v.standardErrorCodes.rpc.parse,n),invalidRequest:n=>C(v.standardErrorCodes.rpc.invalidRequest,n),invalidParams:n=>C(v.standardErrorCodes.rpc.invalidParams,n),methodNotFound:n=>C(v.standardErrorCodes.rpc.methodNotFound,n),internal:n=>C(v.standardErrorCodes.rpc.internal,n),server:n=>{if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=n;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return C(e,n)},invalidInput:n=>C(v.standardErrorCodes.rpc.invalidInput,n),resourceNotFound:n=>C(v.standardErrorCodes.rpc.resourceNotFound,n),resourceUnavailable:n=>C(v.standardErrorCodes.rpc.resourceUnavailable,n),transactionRejected:n=>C(v.standardErrorCodes.rpc.transactionRejected,n),methodNotSupported:n=>C(v.standardErrorCodes.rpc.methodNotSupported,n),limitExceeded:n=>C(v.standardErrorCodes.rpc.limitExceeded,n)},provider:{userRejectedRequest:n=>$(v.standardErrorCodes.provider.userRejectedRequest,n),unauthorized:n=>$(v.standardErrorCodes.provider.unauthorized,n),unsupportedMethod:n=>$(v.standardErrorCodes.provider.unsupportedMethod,n),disconnected:n=>$(v.standardErrorCodes.provider.disconnected,n),chainDisconnected:n=>$(v.standardErrorCodes.provider.chainDisconnected,n),unsupportedChain:n=>$(v.standardErrorCodes.provider.unsupportedChain,n),custom:n=>{if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:t,data:r}=n;if(!t||typeof t!="string")throw new Error('"message" must be a nonempty string');return new It(e,t,r)}}};function C(n,e){const[t,r]=Ct(e);return new kt(n,t||(0,St.getMessageFromCode)(n),r)}function $(n,e){const[t,r]=Ct(e);return new It(n,t||(0,St.getMessageFromCode)(n),r)}function Ct(n){if(n){if(typeof n=="string")return[n];if(typeof n=="object"&&!Array.isArray(n)){const{message:e,data:t}=n;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,t]}}return[]}class kt extends Error{constructor(e,t,r){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||typeof t!="string")throw new Error('"message" must be a nonempty string.');super(t),this.code=e,r!==void 0&&(this.data=r)}}class It extends kt{constructor(e,t,r){if(!hn(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,r)}}function hn(n){return Number.isInteger(n)&&n>=1e3&&n<=4999}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.standardErrors=n.standardErrorCodes=void 0;var e=U;Object.defineProperty(n,"standardErrorCodes",{enumerable:!0,get:function(){return e.standardErrorCodes}});var t=ye;Object.defineProperty(n,"standardErrors",{enumerable:!0,get:function(){return t.standardErrors}})})(j);var we={},Q={};Object.defineProperty(Q,"__esModule",{value:!0});Q.isErrorResponse=void 0;function gn(n){return n.errorMessage!==void 0}Q.isErrorResponse=gn;var K={};Object.defineProperty(K,"__esModule",{value:!0});K.LIB_VERSION=void 0;K.LIB_VERSION="4.0.4";Object.defineProperty(we,"__esModule",{value:!0});we.serializeError=void 0;const pn=Q,fn=K,mn=U,bn=$e;function yn(n,e){const t=(0,bn.serialize)(wn(n),{shouldIncludeStack:!0}),r=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");r.searchParams.set("version",fn.LIB_VERSION),r.searchParams.set("code",t.code.toString());const s=vn(t.data,e);return s&&r.searchParams.set("method",s),r.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:r.href})}we.serializeError=yn;function wn(n){return typeof n=="string"?{message:n,code:mn.standardErrorCodes.rpc.internal}:(0,pn.isErrorResponse)(n)?Object.assign(Object.assign({},n),{message:n.errorMessage,code:n.errorCode,data:{method:n.method}}):n}function vn(n,e){const t=n==null?void 0:n.method;if(t)return t;if(e!==void 0){if(typeof e=="string")return e;if(Array.isArray(e)){if(e.length>0)return e[0].method}else return e.method}}var _={};Object.defineProperty(_,"__esModule",{value:!0});_.RegExpString=_.IntNumber=_.BigIntString=_.AddressString=_.HexString=_.OpaqueType=void 0;function ne(){return n=>n}_.OpaqueType=ne;_.HexString=ne();_.AddressString=ne();_.BigIntString=ne();function _n(n){return Math.floor(n)}_.IntNumber=_n;_.RegExpString=ne();var u={};Object.defineProperty(u,"__esModule",{value:!0});u.areAddressArraysEqual=u.getFavicon=u.range=u.isBigNumber=u.ensureParsedJSONObject=u.ensureBigInt=u.ensureRegExpString=u.ensureIntNumber=u.ensureBuffer=u.ensureAddressString=u.ensureEvenLengthHexString=u.ensureHexString=u.isHexString=u.prepend0x=u.strip0x=u.has0xPrefix=u.hexStringFromIntNumber=u.intNumberFromHexString=u.bigIntStringFromBigInt=u.hexStringFromBuffer=u.hexStringToUint8Array=u.uint8ArrayToHex=u.randomBytesHex=void 0;const q=j,I=_,Mt=/^[0-9]*$/,Lt=/^[a-f0-9]*$/;function En(n){return At(crypto.getRandomValues(new Uint8Array(n)))}u.randomBytesHex=En;function At(n){return[...n].map(e=>e.toString(16).padStart(2,"0")).join("")}u.uint8ArrayToHex=At;function Sn(n){return new Uint8Array(n.match(/.{1,2}/g).map(e=>parseInt(e,16)))}u.hexStringToUint8Array=Sn;function Cn(n,e=!1){const t=n.toString("hex");return(0,I.HexString)(e?`0x${t}`:t)}u.hexStringFromBuffer=Cn;function kn(n){return(0,I.BigIntString)(n.toString(10))}u.bigIntStringFromBigInt=kn;function In(n){return(0,I.IntNumber)(Number(BigInt(se(n,!0))))}u.intNumberFromHexString=In;function Mn(n){return(0,I.HexString)(`0x${BigInt(n).toString(16)}`)}u.hexStringFromIntNumber=Mn;function Fe(n){return n.startsWith("0x")||n.startsWith("0X")}u.has0xPrefix=Fe;function ve(n){return Fe(n)?n.slice(2):n}u.strip0x=ve;function Rt(n){return Fe(n)?`0x${n.slice(2)}`:`0x${n}`}u.prepend0x=Rt;function re(n){if(typeof n!="string")return!1;const e=ve(n).toLowerCase();return Lt.test(e)}u.isHexString=re;function xt(n,e=!1){if(typeof n=="string"){const t=ve(n).toLowerCase();if(Lt.test(t))return(0,I.HexString)(e?`0x${t}`:t)}throw q.standardErrors.rpc.invalidParams(`"${String(n)}" is not a hexadecimal string`)}u.ensureHexString=xt;function se(n,e=!1){let t=xt(n,!1);return t.length%2===1&&(t=(0,I.HexString)(`0${t}`)),e?(0,I.HexString)(`0x${t}`):t}u.ensureEvenLengthHexString=se;function Ln(n){if(typeof n=="string"){const e=ve(n).toLowerCase();if(re(e)&&e.length===40)return(0,I.AddressString)(Rt(e))}throw q.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(n)}`)}u.ensureAddressString=Ln;function An(n){if(Buffer.isBuffer(n))return n;if(typeof n=="string"){if(re(n)){const e=se(n,!1);return Buffer.from(e,"hex")}return Buffer.from(n,"utf8")}throw q.standardErrors.rpc.invalidParams(`Not binary data: ${String(n)}`)}u.ensureBuffer=An;function Pt(n){if(typeof n=="number"&&Number.isInteger(n))return(0,I.IntNumber)(n);if(typeof n=="string"){if(Mt.test(n))return(0,I.IntNumber)(Number(n));if(re(n))return(0,I.IntNumber)(Number(BigInt(se(n,!0))))}throw q.standardErrors.rpc.invalidParams(`Not an integer: ${String(n)}`)}u.ensureIntNumber=Pt;function Rn(n){if(n instanceof RegExp)return(0,I.RegExpString)(n.toString());throw q.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(n)}`)}u.ensureRegExpString=Rn;function xn(n){if(n!==null&&(typeof n=="bigint"||Nt(n)))return BigInt(n.toString(10));if(typeof n=="number")return BigInt(Pt(n));if(typeof n=="string"){if(Mt.test(n))return BigInt(n);if(re(n))return BigInt(se(n,!0))}throw q.standardErrors.rpc.invalidParams(`Not an integer: ${String(n)}`)}u.ensureBigInt=xn;function Pn(n){if(typeof n=="string")return JSON.parse(n);if(typeof n=="object")return n;throw q.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(n)}`)}u.ensureParsedJSONObject=Pn;function Nt(n){if(n==null||typeof n.constructor!="function")return!1;const{constructor:e}=n;return typeof e.config=="function"&&typeof e.EUCLID=="number"}u.isBigNumber=Nt;function Nn(n,e){return Array.from({length:e-n},(t,r)=>n+r)}u.range=Nn;function Tn(){const n=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:t}=document.location,r=n?n.getAttribute("href"):null;return!r||r.startsWith("javascript:")||r.startsWith("vbscript:")?null:r.startsWith("http://")||r.startsWith("https://")||r.startsWith("data:")?r:r.startsWith("//")?e+r:`${e}//${t}${r}`}u.getFavicon=Tn;function jn(n,e){return n.length===e.length&&n.every((t,r)=>t===e[r])}u.areAddressArraysEqual=jn;var P={},_e={},Ee={},y={};Object.defineProperty(y,"__esModule",{value:!0});y.decryptContent=y.encryptContent=y.importKeyFromHexString=y.exportKeyToHexString=y.decrypt=y.encrypt=y.deriveSharedSecret=y.generateKeyPair=void 0;const Tt=u;async function On(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}y.generateKeyPair=On;async function Dn(n,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},n,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}y.deriveSharedSecret=Dn;async function jt(n,e){const t=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},n,new TextEncoder().encode(e));return{iv:t,cipherText:r}}y.encrypt=jt;async function Ot(n,{iv:e,cipherText:t}){const r=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},n,t);return new TextDecoder().decode(r)}y.decrypt=Ot;function Dt(n){switch(n){case"public":return"spki";case"private":return"pkcs8"}}async function Wn(n,e){const t=Dt(n),r=await crypto.subtle.exportKey(t,e);return(0,Tt.uint8ArrayToHex)(new Uint8Array(r))}y.exportKeyToHexString=Wn;async function Un(n,e){const t=Dt(n),r=(0,Tt.hexStringToUint8Array)(e).buffer;return await crypto.subtle.importKey(t,r,{name:"ECDH",namedCurve:"P-256"},!0,n==="private"?["deriveKey"]:[])}y.importKeyFromHexString=Un;async function Bn(n,e){const t=JSON.stringify(n,(r,s)=>{if(!(s instanceof Error))return s;const i=s;return Object.assign(Object.assign({},i.code?{code:i.code}:{}),{message:i.message})});return jt(e,t)}y.encryptContent=Bn;async function Hn(n,e){return JSON.parse(await Ot(e,n))}y.decryptContent=Hn;var O={};Object.defineProperty(O,"__esModule",{value:!0});O.ScopedLocalStorage=void 0;class fe{constructor(e,t){this.scope=e,this.module=t}setItem(e,t){localStorage.setItem(this.scopedKey(e),t)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),t=[];for(let r=0;rlocalStorage.removeItem(r))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new fe("CBWSDK").clear(),new fe("walletlink").clear()}}O.ScopedLocalStorage=fe;Object.defineProperty(Ee,"__esModule",{value:!0});Ee.SCWKeyManager=void 0;const oe=y,Kn=O,De={storageKey:"ownPrivateKey",keyType:"private"},We={storageKey:"ownPublicKey",keyType:"public"},Ue={storageKey:"peerPublicKey",keyType:"public"};class qn{constructor(){this.storage=new Kn.ScopedLocalStorage("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(e){this.sharedSecret=null,this.peerPublicKey=e,await this.storeKey(Ue,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(We.storageKey),this.storage.removeItem(De.storageKey),this.storage.removeItem(Ue.storageKey)}async generateKeyPair(){const e=await(0,oe.generateKeyPair)();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(De,e.privateKey),await this.storeKey(We,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(De)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(We)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(Ue)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await(0,oe.deriveSharedSecret)(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const t=this.storage.getItem(e.storageKey);return t?(0,oe.importKeyFromHexString)(e.keyType,t):null}async storeKey(e,t){const r=await(0,oe.exportKeyToHexString)(e.keyType,t);this.storage.setItem(e.storageKey,r)}}Ee.SCWKeyManager=qn;var Se={};Object.defineProperty(Se,"__esModule",{value:!0});Se.SCWStateManager=void 0;const $n=O,Qe="accounts",Xe="activeChain",et="availableChains",tt="walletCapabilities";class Fn{get accounts(){return this._accounts}get activeChain(){return this._activeChain}get walletCapabilities(){return this._walletCapabilities}constructor(e){var t,r;this.storage=new $n.ScopedLocalStorage("CBWSDK","SCWStateManager"),this.updateListener=e.updateListener,this.availableChains=this.loadItemFromStorage(et),this._walletCapabilities=this.loadItemFromStorage(tt);const s=this.loadItemFromStorage(Qe),i=this.loadItemFromStorage(Xe);s&&this.updateListener.onAccountsUpdate({accounts:s,source:"storage"}),i&&this.updateListener.onChainUpdate({chain:i,source:"storage"}),this._accounts=s||[],this._activeChain=i||{id:(r=(t=e.appChainIds)===null||t===void 0?void 0:t[0])!==null&&r!==void 0?r:1}}updateAccounts(e){this._accounts=e,this.storeItemToStorage(Qe,e),this.updateListener.onAccountsUpdate({accounts:e,source:"wallet"})}switchChain(e){var t;const r=(t=this.availableChains)===null||t===void 0?void 0:t.find(s=>s.id===e);return r?(r===this._activeChain||(this._activeChain=r,this.storeItemToStorage(Xe,r),this.updateListener.onChainUpdate({chain:r,source:"wallet"})),!0):!1}updateAvailableChains(e){if(!e||Object.keys(e).length===0)return;const t=Object.entries(e).map(([r,s])=>({id:Number(r),rpcUrl:s}));this.availableChains=t,this.storeItemToStorage(et,t),this.switchChain(this._activeChain.id)}updateWalletCapabilities(e){this._walletCapabilities=e,this.storeItemToStorage(tt,e)}storeItemToStorage(e,t){this.storage.setItem(e,JSON.stringify(t))}loadItemFromStorage(e){const t=this.storage.getItem(e);return t?JSON.parse(t):void 0}clear(){this.storage.clear()}}Se.SCWStateManager=Fn;Object.defineProperty(_e,"__esModule",{value:!0});_e.SCWSigner=void 0;const zn=Ee,Vn=Se,ce=j,nt=u,de=y;class Zn{constructor(e){this.metadata=e.metadata,this.communicator=e.communicator,this.keyManager=new zn.SCWKeyManager,this.stateManager=new Vn.SCWStateManager({appChainIds:this.metadata.appChainIds,updateListener:e.updateListener}),this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(){const e=await this.createRequestMessage({handshake:{method:"eth_requestAccounts",params:this.metadata}}),t=await this.communicator.postRequestAndWaitForResponse(e);if("failure"in t.content)throw t.content.failure;const r=await(0,de.importKeyFromHexString)("public",t.sender);await this.keyManager.setPeerPublicKey(r);const s=await this.decryptResponseMessage(t);this.updateInternalState({method:"eth_requestAccounts"},s);const i=s.result;if("error"in i)throw i.error;return this.stateManager.accounts}async request(e){const t=this.tryLocalHandling(e);if(t!==void 0){if(t instanceof Error)throw t;return t}await this.communicator.waitForPopupLoaded();const r=await this.sendEncryptedRequest(e),s=await this.decryptResponseMessage(r);this.updateInternalState(e,s);const i=s.result;if("error"in i)throw i.error;return i.value}async disconnect(){this.stateManager.clear(),await this.keyManager.clear()}tryLocalHandling(e){var t;switch(e.method){case"wallet_switchEthereumChain":{const r=e.params;if(!r||!(!((t=r[0])===null||t===void 0)&&t.chainId))throw ce.standardErrors.rpc.invalidParams();const s=(0,nt.ensureIntNumber)(r[0].chainId);return this.stateManager.switchChain(s)?null:void 0}case"wallet_getCapabilities":{const r=this.stateManager.walletCapabilities;if(!r)throw ce.standardErrors.provider.unauthorized("No wallet capabilities found, please disconnect and reconnect");return r}default:return}}async sendEncryptedRequest(e){const t=await this.keyManager.getSharedSecret();if(!t)throw ce.standardErrors.provider.unauthorized("No valid session found, try requestAccounts before other methods");const r=await(0,de.encryptContent)({action:e,chainId:this.stateManager.activeChain.id},t),s=await this.createRequestMessage({encrypted:r});return this.communicator.postRequestAndWaitForResponse(s)}async createRequestMessage(e){const t=await(0,de.exportKeyToHexString)("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:t,content:e,timestamp:new Date}}async decryptResponseMessage(e){const t=e.content;if("failure"in t)throw t.failure;const r=await this.keyManager.getSharedSecret();if(!r)throw ce.standardErrors.provider.unauthorized("Invalid session");return(0,de.decryptContent)(t.encrypted,r)}updateInternalState(e,t){var r,s;const i=(r=t.data)===null||r===void 0?void 0:r.chains;i&&this.stateManager.updateAvailableChains(i);const a=(s=t.data)===null||s===void 0?void 0:s.capabilities;a&&this.stateManager.updateWalletCapabilities(a);const o=t.result;if(!("error"in o))switch(e.method){case"eth_requestAccounts":{const c=o.value;this.stateManager.updateAccounts(c);break}case"wallet_switchEthereumChain":{if(o.value!==null)return;const c=e.params,l=(0,nt.ensureIntNumber)(c[0].chainId);this.stateManager.switchChain(l);break}}}}_e.SCWSigner=Zn;var Ce={};const Gn=on;function Wt(n){return Buffer.allocUnsafe(n).fill(0)}function Yn(n){return n.toString(2).length}function Ut(n,e){let t=n.toString(16);t.length%2!==0&&(t="0"+t);const r=t.match(/.{1,2}/g).map(s=>parseInt(s,16));for(;r.length"u")throw new Error("Not an array?");if(t=Ft(n),t!=="dynamic"&&t!==0&&e.length>t)throw new Error("Elements exceed array size: "+t);s=[],n=n.slice(0,n.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(i in e)s.push(R(n,e[i]));if(t==="dynamic"){var a=R("uint256",e.length);s.unshift(a)}return Buffer.concat(s)}else{if(n==="bytes")return e=new Buffer(e),s=Buffer.concat([R("uint256",e.length),e]),e.length%32!==0&&(s=Buffer.concat([s,E.zeros(32-e.length%32)])),s;if(n.startsWith("bytes")){if(t=G(n),t<1||t>32)throw new Error("Invalid bytes width: "+t);return E.setLengthRight(e,32)}else if(n.startsWith("uint")){if(t=G(n),t%8||t<8||t>256)throw new Error("Invalid uint width: "+t);r=H(e);const o=E.bitLengthFromBigInt(r);if(o>t)throw new Error("Supplied uint exceeds width: "+t+" vs "+o);if(r<0)throw new Error("Supplied uint is negative");return E.bufferBEFromBigInt(r,32)}else if(n.startsWith("int")){if(t=G(n),t%8||t<8||t>256)throw new Error("Invalid int width: "+t);r=H(e);const o=E.bitLengthFromBigInt(r);if(o>t)throw new Error("Supplied int exceeds width: "+t+" vs "+o);const c=E.twosFromBigInt(r,256);return E.bufferBEFromBigInt(c,32)}else if(n.startsWith("ufixed")){if(t=rt(n),r=H(e),r<0)throw new Error("Supplied ufixed is negative");return R("uint256",r*BigInt(2)**BigInt(t[1]))}else if(n.startsWith("fixed"))return t=rt(n),R("int256",H(e)*BigInt(2)**BigInt(t[1]))}throw new Error("Unsupported or invalid type: "+n)}function nr(n){return n==="string"||n==="bytes"||Ft(n)==="dynamic"}function rr(n){return n.lastIndexOf("]")===n.length-1}function sr(n,e){var t=[],r=[],s=32*n.length;for(var i in n){var a=$t(n[i]),o=e[i],c=R(a,o);nr(a)?(t.push(R("uint256",s)),r.push(c),s+=c.length):t.push(c)}return Buffer.concat(t.concat(r))}function zt(n,e){if(n.length!==e.length)throw new Error("Number of types are not matching the values");for(var t,r,s=[],i=0;i32)throw new Error("Invalid bytes width: "+t);s.push(E.setLengthRight(o,t))}else if(a.startsWith("uint")){if(t=G(a),t%8||t<8||t>256)throw new Error("Invalid uint width: "+t);r=H(o);const c=E.bitLengthFromBigInt(r);if(c>t)throw new Error("Supplied uint exceeds width: "+t+" vs "+c);s.push(E.bufferBEFromBigInt(r,t/8))}else if(a.startsWith("int")){if(t=G(a),t%8||t<8||t>256)throw new Error("Invalid int width: "+t);r=H(o);const c=E.bitLengthFromBigInt(r);if(c>t)throw new Error("Supplied int exceeds width: "+t+" vs "+c);const l=E.twosFromBigInt(r,t);s.push(E.bufferBEFromBigInt(l,t/8))}else throw new Error("Unsupported or invalid type: "+a)}return Buffer.concat(s)}function ir(n,e){return E.keccak(zt(n,e))}var ar={rawEncode:sr,solidityPack:zt,soliditySHA3:ir};const A=qt,ee=ar,Vt={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},Be={encodeData(n,e,t,r=!0){const s=["bytes32"],i=[this.hashType(n,t)];if(r){const a=(o,c,l)=>{if(t[c]!==void 0)return["bytes32",l==null?"0x0000000000000000000000000000000000000000000000000000000000000000":A.keccak(this.encodeData(c,l,t,r))];if(l===void 0)throw new Error(`missing value for field ${o} of type ${c}`);if(c==="bytes")return["bytes32",A.keccak(l)];if(c==="string")return typeof l=="string"&&(l=Buffer.from(l,"utf8")),["bytes32",A.keccak(l)];if(c.lastIndexOf("]")===c.length-1){const h=c.slice(0,c.lastIndexOf("[")),f=l.map(d=>a(o,h,d));return["bytes32",A.keccak(ee.rawEncode(f.map(([d])=>d),f.map(([,d])=>d)))]}return[c,l]};for(const o of t[n]){const[c,l]=a(o.name,o.type,e[o.name]);s.push(c),i.push(l)}}else for(const a of t[n]){let o=e[a.name];if(o!==void 0)if(a.type==="bytes")s.push("bytes32"),o=A.keccak(o),i.push(o);else if(a.type==="string")s.push("bytes32"),typeof o=="string"&&(o=Buffer.from(o,"utf8")),o=A.keccak(o),i.push(o);else if(t[a.type]!==void 0)s.push("bytes32"),o=A.keccak(this.encodeData(a.type,o,t,r)),i.push(o);else{if(a.type.lastIndexOf("]")===a.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");s.push(a.type),i.push(o)}}return ee.rawEncode(s,i)},encodeType(n,e){let t="",r=this.findTypeDependencies(n,e).filter(s=>s!==n);r=[n].concat(r.sort());for(const s of r){if(!e[s])throw new Error("No type definition specified: "+s);t+=s+"("+e[s].map(({name:a,type:o})=>o+" "+a).join(",")+")"}return t},findTypeDependencies(n,e,t=[]){if(n=n.match(/^\w*/)[0],t.includes(n)||e[n]===void 0)return t;t.push(n);for(const r of e[n])for(const s of this.findTypeDependencies(r.type,e,t))!t.includes(s)&&t.push(s);return t},hashStruct(n,e,t,r=!0){return A.keccak(this.encodeData(n,e,t,r))},hashType(n,e){return A.keccak(this.encodeType(n,e))},sanitizeData(n){const e={};for(const t in Vt.properties)n[t]&&(e[t]=n[t]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(n,e=!0){const t=this.sanitizeData(n),r=[Buffer.from("1901","hex")];return r.push(this.hashStruct("EIP712Domain",t.domain,t.types,e)),t.primaryType!=="EIP712Domain"&&r.push(this.hashStruct(t.primaryType,t.message,t.types,e)),A.keccak(Buffer.concat(r))}};var or={TYPED_MESSAGE_SCHEMA:Vt,TypedDataUtils:Be,hashForSignTypedDataLegacy:function(n){return cr(n.data)},hashForSignTypedData_v3:function(n){return Be.hash(n.data,!1)},hashForSignTypedData_v4:function(n){return Be.hash(n.data)}};function cr(n){const e=new Error("Expect argument to be non-empty array");if(typeof n!="object"||!n.length)throw e;const t=n.map(function(i){return i.type==="bytes"?A.toBuffer(i.value):i.value}),r=n.map(function(i){return i.type}),s=n.map(function(i){if(!i.name)throw e;return i.type+" "+i.name});return ee.soliditySHA3(["bytes32","bytes32"],[ee.soliditySHA3(new Array(n.length).fill("string"),s),ee.soliditySHA3(r,t)])}var N={};Object.defineProperty(N,"__esModule",{value:!0});N.APP_VERSION_KEY=N.LOCAL_STORAGE_ADDRESSES_KEY=N.WALLET_USER_NAME_KEY=void 0;N.WALLET_USER_NAME_KEY="walletUsername";N.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";N.APP_VERSION_KEY="AppVersion";var ie={};Object.defineProperty(ie,"__esModule",{value:!0});ie.RelayEventManager=void 0;const dr=u;class lr{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,t=(0,dr.prepend0x)(e.toString(16));return this.callbacks.get(t)&&this.callbacks.delete(t),e}}ie.RelayEventManager=lr;var Ie={},Me={},Le={};Object.defineProperty(Le,"__esModule",{value:!0});Le.WalletLinkCipher=void 0;const le=u;class ur{constructor(e){this.secret=e}async encrypt(e){const t=this.secret;if(t.length!==64)throw Error("secret must be 256 bits");const r=crypto.getRandomValues(new Uint8Array(12)),s=await crypto.subtle.importKey("raw",(0,le.hexStringToUint8Array)(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),i=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},s,i.encode(e)),o=16,c=a.slice(a.byteLength-o),l=a.slice(0,a.byteLength-o),h=new Uint8Array(c),f=new Uint8Array(l),d=new Uint8Array([...r,...h,...f]);return(0,le.uint8ArrayToHex)(d)}async decrypt(e){const t=this.secret;if(t.length!==64)throw Error("secret must be 256 bits");return new Promise((r,s)=>{(async function(){const i=await crypto.subtle.importKey("raw",(0,le.hexStringToUint8Array)(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=(0,le.hexStringToUint8Array)(e),o=a.slice(0,12),c=a.slice(12,28),l=a.slice(28),h=new Uint8Array([...l,...c]),f={name:"AES-GCM",iv:new Uint8Array(o)};try{const d=await window.crypto.subtle.decrypt(f,i,h),p=new TextDecoder;r(p.decode(d))}catch(d){s(d)}})()})}}Le.WalletLinkCipher=ur;var Ae={};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.WalletLinkHTTP=void 0;class hr{constructor(e,t,r){this.linkAPIUrl=e,this.sessionId=t;const s=`${t}:${r}`;this.auth=`Basic ${btoa(s)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(t=>fetch(`${this.linkAPIUrl}/events/${t.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(t=>console.error("Unabled to mark event as failed:",t))}async fetchUnseenEvents(){var e;const t=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(t.ok){const{events:r,error:s}=await t.json();if(s)throw new Error(`Check unseen events failed: ${s}`);const i=(e=r==null?void 0:r.filter(a=>a.event==="Web3Response").map(a=>({type:"Event",sessionId:this.sessionId,eventId:a.id,event:a.event,data:a.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(i),i}throw new Error(`Check unseen events failed: ${t.status}`)}}Ae.WalletLinkHTTP=hr;var Y={};Object.defineProperty(Y,"__esModule",{value:!0});Y.WalletLinkWebSocket=Y.ConnectionState=void 0;var Z;(function(n){n[n.DISCONNECTED=0]="DISCONNECTED",n[n.CONNECTING=1]="CONNECTING",n[n.CONNECTED=2]="CONNECTED"})(Z||(Y.ConnectionState=Z={}));class gr{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,t=WebSocket){this.WebSocketClass=t,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,t)=>{var r;let s;try{this.webSocket=s=new this.WebSocketClass(this.url)}catch(i){t(i);return}(r=this.connectionStateListener)===null||r===void 0||r.call(this,Z.CONNECTING),s.onclose=i=>{var a;this.clearWebSocket(),t(new Error(`websocket error ${i.code}: ${i.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,Z.DISCONNECTED)},s.onopen=i=>{var a;e(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,Z.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(c=>this.sendData(c)),this.pendingData=[])},s.onmessage=i=>{var a,o;if(i.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(i.data);(o=this.incomingDataListener)===null||o===void 0||o.call(this,c)}catch{}}})}disconnect(){var e;const{webSocket:t}=this;if(t){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,Z.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{t.close()}catch{}}}sendData(e){const{webSocket:t}=this;if(!t){this.pendingData.push(e),this.connect();return}t.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}Y.WalletLinkWebSocket=gr;Object.defineProperty(Me,"__esModule",{value:!0});Me.WalletLinkConnection=void 0;const st=N,pr=Le,fr=Ae,ue=Y,F=_,it=1e4,mr=6e4;class br{constructor({session:e,linkAPIUrl:t,listener:r,WebSocketClass:s=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,F.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=a=>{if(!a)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",c=>a.JsonRpcUrl&&this.handleChainUpdated(c,a.JsonRpcUrl)]]).forEach((c,l)=>{const h=a[l];h!==void 0&&c(h)})},this.handleDestroyed=a=>{var o;a==="1"&&((o=this.listener)===null||o===void 0||o.resetAndReload())},this.handleAccountUpdated=async a=>{var o;{const c=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.accountUpdated(c)}},this.handleMetadataUpdated=async(a,o)=>{var c;{const l=await this.cipher.decrypt(o);(c=this.listener)===null||c===void 0||c.metadataUpdated(a,l)}},this.handleWalletUsernameUpdated=async a=>{this.handleMetadataUpdated(st.WALLET_USER_NAME_KEY,a)},this.handleAppVersionUpdated=async a=>{this.handleMetadataUpdated(st.APP_VERSION_KEY,a)},this.handleChainUpdated=async(a,o)=>{var c;{const l=await this.cipher.decrypt(a),h=await this.cipher.decrypt(o);(c=this.listener)===null||c===void 0||c.chainUpdated(l,h)}},this.session=e,this.cipher=new pr.WalletLinkCipher(e.secret),this.listener=r;const i=new ue.WalletLinkWebSocket(`${t}/rpc`,s);i.setConnectionStateListener(async a=>{let o=!1;switch(a){case ue.ConnectionState.DISCONNECTED:if(!this.destroyed){const c=async()=>{await new Promise(l=>setTimeout(l,5e3)),this.destroyed||i.connect().catch(()=>{c()})};c()}break;case ue.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),o=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},it),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case ue.ConnectionState.CONNECTING:break}this.connected!==o&&(this.connected=o)}),i.setIncomingDataListener(a=>{var o;switch(a.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const c=a.type==="IsLinkedOK"?a.linked:void 0;this.linked=c||a.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(a.metadata);break}case"Event":{this.handleIncomingEvent(a);break}}a.id!==void 0&&((o=this.requestResolutions.get(a.id))===null||o===void 0||o(a))}),this.ws=i,this.http=new fr.WalletLinkHTTP(t,e.id,e.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}destroy(){this.destroyed=!0,this.ws.disconnect(),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(e){var t;this._connected=e,e&&((t=this.onceConnected)===null||t===void 0||t.call(this))}setOnceConnected(e){return new Promise(t=>{this.connected?e().then(t):this.onceConnected=()=>{e().then(t),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(e){var t,r;this._linked=e,e&&((t=this.onceLinked)===null||t===void 0||t.call(this)),(r=this.listener)===null||r===void 0||r.linkedUpdated(e)}setOnceLinked(e){return new Promise(t=>{this.linked?e().then(t):this.onceLinked=()=>{e().then(t),this.onceLinked=void 0}})}async handleIncomingEvent(e){var t;if(!(e.type!=="Event"||e.event!=="Web3Response")){const r=await this.cipher.decrypt(e.data),s=JSON.parse(r);if(s.type!=="WEB3_RESPONSE")return;(t=this.listener)===null||t===void 0||t.handleWeb3ResponseMessage(s)}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(t=>this.handleIncomingEvent(t))}async setSessionMetadata(e,t){const r={type:"SetSessionConfig",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[e]:t}};return this.setOnceConnected(async()=>{const s=await this.makeRequest(r);if(s.type==="Fail")throw new Error(s.error||"failed to set session metadata")})}async publishEvent(e,t,r=!1){const s=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},t),{origin:location.origin,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),i={type:"PublishEvent",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:e,data:s,callWebhook:r};return this.setOnceLinked(async()=>{const a=await this.makeRequest(i);if(a.type==="Fail")throw new Error(a.error||"failed to publish event");return a.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>it*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,t=mr){const r=e.id;this.sendData(e);let s;return Promise.race([new Promise((i,a)=>{s=window.setTimeout(()=>{a(new Error(`request ${r} timed out`))},t)}),new Promise(i=>{this.requestResolutions.set(r,a=>{clearTimeout(s),i(a),this.requestResolutions.delete(r)})})])}async authenticate(){const e={type:"HostSession",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},t=await this.makeRequest(e);if(t.type==="Fail")throw new Error(t.error||"failed to authenticate")}sendIsLinked(){const e={type:"IsLinked",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}sendGetSessionConfig(){const e={type:"GetSessionConfig",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}}Me.WalletLinkConnection=br;var Re={};Object.defineProperty(Re,"__esModule",{value:!0});Re.WalletLinkSession=void 0;const yr=cn,at=u,ot="session:id",ct="session:secret",dt="session:linked";class ze{constructor(e,t,r,s){this._storage=e,this._id=t||(0,at.randomBytesHex)(16),this._secret=r||(0,at.randomBytesHex)(32),this._key=new yr.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!s}static load(e){const t=e.getItem(ot),r=e.getItem(dt),s=e.getItem(ct);return t&&s?new ze(e,t,s,r==="1"):null}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this._storage.setItem(ot,this._id),this._storage.setItem(ct,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(dt,this._linked?"1":"0")}}Re.WalletLinkSession=ze;var S={};Object.defineProperty(S,"__esModule",{value:!0});S.isDarkMode=S.isMobileWeb=S.getLocation=S.createQrUrl=void 0;function wr(n,e,t,r,s,i){const a=r?"parent-id":"id",o=new URLSearchParams({[a]:n,secret:e,server:t,v:s,chainId:i.toString()}).toString();return`${t}/#/link?${o}`}S.createQrUrl=wr;function vr(){try{return window.frameElement!==null}catch{return!1}}function _r(){try{return vr()&&window.top?window.top.location:window.location}catch{return window.location}}S.getLocation=_r;function Er(){var n;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((n=window==null?void 0:window.navigator)===null||n===void 0?void 0:n.userAgent)}S.isMobileWeb=Er;function Sr(){var n,e;return(e=(n=window==null?void 0:window.matchMedia)===null||n===void 0?void 0:n.call(window,"(prefers-color-scheme: dark)").matches)!==null&&e!==void 0?e:!1}S.isDarkMode=Sr;var xe={},ae={},Ve={};Object.defineProperty(Ve,"__esModule",{value:!0});Ve.default='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';var Cr=M&&M.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(ae,"__esModule",{value:!0});ae.injectCssReset=void 0;const kr=Cr(Ve);function Ir(){const n=document.createElement("style");n.type="text/css",n.appendChild(document.createTextNode(kr.default)),document.documentElement.appendChild(n)}ae.injectCssReset=Ir;var Ze={};function Zt(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n))for(e=0;e{this.items.delete(m),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,r.render)((0,r.h)("div",null,(0,r.h)(n.SnackbarContainer,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([p,m])=>(0,r.h)(n.SnackbarInstance,Object.assign({},m,{key:p}))))),this.root)}}n.Snackbar=l;const h=d=>(0,r.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-container")},(0,r.h)("style",null,a.default),(0,r.h)("div",{class:"-cbwsdk-snackbar"},d.children));n.SnackbarContainer=h;const f=({autoExpand:d,message:p,menuItems:m})=>{const[B,tn]=(0,s.useState)(!0),[Oe,Je]=(0,s.useState)(d??!1);(0,s.useEffect)(()=>{const L=[window.setTimeout(()=>{tn(!1)},1),window.setTimeout(()=>{Je(!0)},1e4)];return()=>{L.forEach(window.clearTimeout)}});const nn=()=>{Je(!Oe)};return(0,r.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-instance",B&&"-cbwsdk-snackbar-instance-hidden",Oe&&"-cbwsdk-snackbar-instance-expanded")},(0,r.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:nn},(0,r.h)("img",{src:o,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,r.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},p),(0,r.h)("div",{class:"-gear-container"},!Oe&&(0,r.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,r.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,r.h)("img",{src:c,class:"-gear-icon",title:"Expand"}))),m&&m.length>0&&(0,r.h)("div",{class:"-cbwsdk-snackbar-instance-menu"},m.map((L,rn)=>(0,r.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-instance-menu-item",L.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:L.onClick,key:rn},(0,r.h)("svg",{width:L.svgWidth,height:L.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,r.h)("path",{"fill-rule":L.defaultFillRule,"clip-rule":L.defaultClipRule,d:L.path,fill:"#AAAAAA"})),(0,r.h)("span",{class:(0,t.default)("-cbwsdk-snackbar-instance-menu-item-info",L.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},L.info)))))};n.SnackbarInstance=f})(Ze);Object.defineProperty(xe,"__esModule",{value:!0});xe.WalletLinkRelayUI=void 0;const Lr=ae,Ar=Ze;class Rr{constructor(){this.attached=!1,this.snackbar=new Ar.Snackbar}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,t=document.createElement("div");t.className="-cbwsdk-css-reset",e.appendChild(t),this.snackbar.attach(t),this.attached=!0,(0,Lr.injectCssReset)()}showConnecting(e){let t;return e.isUnlinkedErrorState?t={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:t={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(t)}}xe.WalletLinkRelayUI=Rr;var Pe={},Ne={},Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.default=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";var Yt=M&&M.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.RedirectDialog=void 0;const xr=Yt(Gt),x=_t,Pr=ae,Nr=Ze,Tr=S,jr=Yt(Ye);class Or{constructor(){this.root=null,this.darkMode=(0,Tr.isDarkMode)()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),(0,Pr.injectCssReset)()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&((0,x.render)(null,this.root),e&&(0,x.render)((0,x.h)(Dr,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}Ne.RedirectDialog=Or;const Dr=({title:n,buttonText:e,darkMode:t,onButtonClick:r,onDismiss:s})=>{const i=t?"dark":"light";return(0,x.h)(Nr.SnackbarContainer,{darkMode:t},(0,x.h)("div",{class:"-cbwsdk-redirect-dialog"},(0,x.h)("style",null,jr.default),(0,x.h)("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:s}),(0,x.h)("div",{class:(0,xr.default)("-cbwsdk-redirect-dialog-box",i)},(0,x.h)("p",null,n),(0,x.h)("button",{onClick:r},e))))};var T={};Object.defineProperty(T,"__esModule",{value:!0});T.CBW_MOBILE_DEEPLINK_URL=T.WALLETLINK_URL=T.CB_KEYS_URL=void 0;T.CB_KEYS_URL="https://keys.coinbase.com/connect";T.WALLETLINK_URL="https://www.walletlink.org";T.CBW_MOBILE_DEEPLINK_URL="https://go.cb-w.com/walletlink";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.WLMobileRelayUI=void 0;const Wr=Ne,Ur=S,Br=T;class Hr{constructor(){this.attached=!1,this.redirectDialog=new Wr.RedirectDialog}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(e){const t=new URL(Br.CBW_MOBILE_DEEPLINK_URL);t.searchParams.append("redirect_url",(0,Ur.getLocation)().href),e&&t.searchParams.append("wl_url",e);const r=document.createElement("a");r.target="cbw-opener",r.href=t.href,r.rel="noreferrer noopener",r.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}Pe.WLMobileRelayUI=Hr;Object.defineProperty(Ie,"__esModule",{value:!0});Ie.WalletLinkRelay=void 0;const Kr=Me,qr=N,$r=ie,He=Re,z=Q,Fr=S,zr=xe,ut=Pe,Vr=j,b=u,Zr=O;class W{constructor(e){this.accountsCallback=null,this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.chainCallback=null,this.dappDefaultChain=1,this.isMobileWeb=(0,Fr.isMobileWeb)(),this.appName="",this.appLogoUrl=null,this.linkedUpdated=i=>{this.isLinked=i;const a=this.storage.getItem(qr.LOCAL_STORAGE_ADDRESSES_KEY);if(i&&(this._session.linked=i),this.isUnlinkedErrorState=!1,a){const o=a.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!i&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(i,a)=>{this.storage.setItem(i,a)},this.chainUpdated=(i,a)=>{this.chainCallbackParams.chainId===i&&this.chainCallbackParams.jsonRpcUrl===a||(this.chainCallbackParams={chainId:i,jsonRpcUrl:a},this.chainCallback&&this.chainCallback(i,a))},this.accountUpdated=i=>{this.accountsCallback&&this.accountsCallback([i]),W.accountRequestCallbackIds.size>0&&(Array.from(W.accountRequestCallbackIds.values()).forEach(a=>{const o={type:"WEB3_RESPONSE",id:a,response:{method:"requestEthereumAccounts",result:[i]}};this.invokeCallback(Object.assign(Object.assign({},o),{id:a}))}),W.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage;const{session:t,ui:r,connection:s}=this.subscribe();this._session=t,this.connection=s,this.relayEventManager=new $r.RelayEventManager,this.ui=r}subscribe(){const e=He.WalletLinkSession.load(this.storage)||new He.WalletLinkSession(this.storage).save(),{linkAPIUrl:t}=this,r=new Kr.WalletLinkConnection({session:e,linkAPIUrl:t,listener:this}),s=this.isMobileWeb?new ut.WLMobileRelayUI:new zr.WalletLinkRelayUI;return r.connect(),{session:e,ui:s,connection:r}}attachUI(){this.ui.attach()}resetAndReload(){Promise.race([this.connection.setSessionMetadata("__destroyed","1"),new Promise(e=>setTimeout(()=>e(null),1e3))]).then(()=>{this.connection.destroy();const e=He.WalletLinkSession.load(this.storage);(e==null?void 0:e.id)===this._session.id&&Zr.ScopedLocalStorage.clearAll(),document.location.reload()}).catch(e=>{})}setAppInfo(e,t){this.appName=e,this.appLogoUrl=t}getStorageItem(e){return this.storage.getItem(e)}setStorageItem(e,t){this.storage.setItem(e,t)}signEthereumMessage(e,t,r,s){return this.sendRequest({method:"signEthereumMessage",params:{message:(0,b.hexStringFromBuffer)(e,!0),address:t,addPrefix:r,typedDataJson:s||null}})}ethereumAddressFromSignedMessage(e,t,r){return this.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:(0,b.hexStringFromBuffer)(e,!0),signature:(0,b.hexStringFromBuffer)(t,!0),addPrefix:r}})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,b.bigIntStringFromBigInt)(e.weiValue),data:(0,b.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,b.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?(0,b.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?(0,b.bigIntStringFromBigInt)(e.gasPriceInWei):null,gasLimit:e.gasLimit?(0,b.bigIntStringFromBigInt)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,b.bigIntStringFromBigInt)(e.weiValue),data:(0,b.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,b.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?(0,b.bigIntStringFromBigInt)(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?(0,b.bigIntStringFromBigInt)(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?(0,b.bigIntStringFromBigInt)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,t){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:(0,b.hexStringFromBuffer)(e,!0),chainId:t}})}scanQRCode(e){return this.sendRequest({method:"scanQRCode",params:{regExp:e}})}getWalletLinkSession(){return this._session}genericRequest(e,t){return this.sendRequest({method:"generic",params:{action:t,data:e}})}sendGenericMessage(e){return this.sendRequest(e)}sendRequest(e){let t=null;const r=(0,b.randomBytesHex)(8),s=i=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,e.method,i),t==null||t()};return new Promise((i,a)=>{t=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:s,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(r,o=>{if(t==null||t(),(0,z.isErrorResponse)(o))return a(new Error(o.errorMessage));i(o)}),this.publishWeb3RequestEvent(r,e)})}setAccountsCallback(e){this.accountsCallback=e}setChainCallback(e){this.chainCallback=e}setDappDefaultChainCallback(e){this.dappDefaultChain=e}publishWeb3RequestEvent(e,t){const r={type:"WEB3_REQUEST",id:e,request:t};this.publishEvent("Web3Request",r,!0).then(s=>{}).catch(s=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:r.id,response:{method:t.method,errorMessage:s.message}})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(t.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof ut.WLMobileRelayUI)switch(e){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(e){const t={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",t,!1).then()}publishEvent(e,t,r){return this.connection.publishEvent(e,t,r)}handleWeb3ResponseMessage(e){const{response:t}=e;if(t.method==="requestEthereumAccounts"){W.accountRequestCallbackIds.forEach(r=>this.invokeCallback(Object.assign(Object.assign({},e),{id:r}))),W.accountRequestCallbackIds.clear();return}this.invokeCallback(e)}handleErrorResponse(e,t,r){var s;const i=(s=r==null?void 0:r.message)!==null&&s!==void 0?s:"Unspecified error message.";this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:e,response:{method:t,errorMessage:i}})}invokeCallback(e){const t=this.relayEventManager.callbacks.get(e.id);t&&(t(e.response),this.relayEventManager.callbacks.delete(e.id))}requestEthereumAccounts(){const e={method:"requestEthereumAccounts",params:{appName:this.appName,appLogoUrl:this.appLogoUrl||null}},t=(0,b.randomBytesHex)(8);return new Promise((r,s)=>{this.relayEventManager.callbacks.set(t,i=>{if((0,z.isErrorResponse)(i))return s(new Error(i.errorMessage));r(i)}),W.accountRequestCallbackIds.add(t),this.publishWeb3RequestEvent(t,e)})}watchAsset(e,t,r,s,i,a){const o={method:"watchAsset",params:{type:e,options:{address:t,symbol:r,decimals:s,image:i},chainId:a}};let c=null;const l=(0,b.randomBytesHex)(8),h=f=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,o.method,f),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((f,d)=>{this.relayEventManager.callbacks.set(l,p=>{if(c==null||c(),(0,z.isErrorResponse)(p))return d(new Error(p.errorMessage));f(p)}),this.publishWeb3RequestEvent(l,o)})}addEthereumChain(e,t,r,s,i,a){const o={method:"addEthereumChain",params:{chainId:e,rpcUrls:t,blockExplorerUrls:s,chainName:i,iconUrls:r,nativeCurrency:a}};let c=null;const l=(0,b.randomBytesHex)(8),h=f=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,o.method,f),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((f,d)=>{this.relayEventManager.callbacks.set(l,p=>{if(c==null||c(),(0,z.isErrorResponse)(p))return d(new Error(p.errorMessage));f(p)}),this.publishWeb3RequestEvent(l,o)})}switchEthereumChain(e,t){const r={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:t})},s=(0,b.randomBytesHex)(8);return new Promise((i,a)=>{this.relayEventManager.callbacks.set(s,o=>{if((0,z.isErrorResponse)(o)&&o.errorCode)return a(Vr.standardErrors.provider.custom({code:o.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if((0,z.isErrorResponse)(o))return a(new Error(o.errorMessage));i(o)}),this.publishWeb3RequestEvent(s,r)})}}Ie.WalletLinkRelay=W;W.accountRequestCallbackIds=new Set;var Gr=M&&M.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Ce,"__esModule",{value:!0});Ce.WalletLinkSigner=void 0;const Ke=Gr(or),ht=N,Yr=ie,D=Q,Jr=Ie,gt=T,w=j,g=u,Qr=O,qe="DefaultChainId",pt="DefaultJsonRpcUrl";class Xr{constructor(e){var t,r;this._relay=null,this._addresses=[],this.hasMadeFirstChainChangedEmission=!1;const{appName:s,appLogoUrl:i}=e.metadata;this._appName=s,this._appLogoUrl=i,this._storage=new Qr.ScopedLocalStorage("walletlink",gt.WALLETLINK_URL),this.updateListener=e.updateListener,this._relayEventManager=new Yr.RelayEventManager,this._jsonRpcUrlFromOpts="";const a=this._storage.getItem(ht.LOCAL_STORAGE_ADDRESSES_KEY);if(a){const c=a.split(" ");c[0]!==""&&(this._addresses=c.map(l=>(0,g.ensureAddressString)(l)),(t=this.updateListener)===null||t===void 0||t.onAccountsUpdate({accounts:this._addresses,source:"storage"}))}this._storage.getItem(qe)&&((r=this.updateListener)===null||r===void 0||r.onChainUpdate({chain:{id:this.getChainId(),rpcUrl:this.jsonRpcUrl},source:"storage"}),this.hasMadeFirstChainChangedEmission=!0),this.initializeRelay()}getSession(){const e=this.initializeRelay(),{id:t,secret:r}=e.getWalletLinkSession();return{id:t,secret:r}}async handshake(){return await this.request({method:"eth_requestAccounts"})}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(pt))!==null&&e!==void 0?e:this._jsonRpcUrlFromOpts}set jsonRpcUrl(e){this._storage.setItem(pt,e)}updateProviderInfo(e,t){var r;this.jsonRpcUrl=e;const s=this.getChainId();this._storage.setItem(qe,t.toString(10)),((0,g.ensureIntNumber)(t)!==s||!this.hasMadeFirstChainChangedEmission)&&((r=this.updateListener)===null||r===void 0||r.onChainUpdate({chain:{id:t,rpcUrl:e},source:"wallet"}),this.hasMadeFirstChainChangedEmission=!0)}async watchAsset(e,t,r,s,i,a){const c=await this.initializeRelay().watchAsset(e,t,r,s,i,a==null?void 0:a.toString());return(0,D.isErrorResponse)(c)?!1:!!c.result}async addEthereumChain(e,t,r,s,i,a){var o,c;if((0,g.ensureIntNumber)(e)===this.getChainId())return!1;const l=this.initializeRelay();this._isAuthorized()||await l.requestEthereumAccounts();const h=await l.addEthereumChain(e.toString(),t,i,r,s,a);return(0,D.isErrorResponse)(h)?!1:(((o=h.result)===null||o===void 0?void 0:o.isApproved)===!0&&this.updateProviderInfo(t[0],e),((c=h.result)===null||c===void 0?void 0:c.isApproved)===!0)}async switchEthereumChain(e){const r=await this.initializeRelay().switchEthereumChain(e.toString(10),this.selectedAddress||void 0);if((0,D.isErrorResponse)(r)){if(!r.errorCode)return;throw r.errorCode===w.standardErrorCodes.provider.unsupportedChain?w.standardErrors.provider.unsupportedChain():w.standardErrors.provider.custom({message:r.errorMessage,code:r.errorCode})}const s=r.result;s.isApproved&&s.rpcUrl.length>0&&this.updateProviderInfo(s.rpcUrl,e)}async disconnect(){this._relay&&this._relay.resetAndReload(),this._storage.clear()}async request(e){try{return this._request(e).catch(t=>{throw t})}catch(t){return Promise.reject(t)}}async _request(e){if(!e||typeof e!="object"||Array.isArray(e))throw w.standardErrors.rpc.invalidRequest({message:"Expected a single, non-array, object argument.",data:e});const{method:t,params:r}=e;if(typeof t!="string"||t.length===0)throw w.standardErrors.rpc.invalidRequest({message:"'args.method' must be a non-empty string.",data:e});if(r!==void 0&&!Array.isArray(r)&&(typeof r!="object"||r===null))throw w.standardErrors.rpc.invalidRequest({message:"'args.params' must be an object or array if provided.",data:e});const s=r===void 0?[]:r,i=this._relayEventManager.makeRequestId();return(await this._sendRequestAsync({method:t,params:s,jsonrpc:"2.0",id:i})).result}_setAddresses(e,t){var r;if(!Array.isArray(e))throw new Error("addresses is not an array");const s=e.map(i=>(0,g.ensureAddressString)(i));JSON.stringify(s)!==JSON.stringify(this._addresses)&&(this._addresses=s,(r=this.updateListener)===null||r===void 0||r.onAccountsUpdate({accounts:s,source:"wallet"}),this._storage.setItem(ht.LOCAL_STORAGE_ADDRESSES_KEY,s.join(" ")))}_sendRequestAsync(e){return new Promise((t,r)=>{try{const s=this._handleSynchronousMethods(e);if(s!==void 0)return t({jsonrpc:"2.0",id:e.id,result:s})}catch(s){return r(s)}this._handleAsynchronousMethods(e).then(s=>s&&t(Object.assign(Object.assign({},s),{id:e.id}))).catch(s=>r(s))})}_handleSynchronousMethods(e){const{method:t}=e;switch(t){case"eth_accounts":return this._eth_accounts();case"eth_coinbase":return this._eth_coinbase();case"net_version":return this._net_version();case"eth_chainId":return this._eth_chainId();default:return}}async _handleAsynchronousMethods(e){const{method:t}=e,r=e.params||[];switch(t){case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_sign":return this._eth_sign(r);case"eth_ecRecover":return this._eth_ecRecover(r);case"personal_sign":return this._personal_sign(r);case"personal_ecRecover":return this._personal_ecRecover(r);case"eth_signTransaction":return this._eth_signTransaction(r);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(r);case"eth_sendTransaction":return this._eth_sendTransaction(r);case"eth_signTypedData_v1":return this._eth_signTypedData_v1(r);case"eth_signTypedData_v2":return this._throwUnsupportedMethodError();case"eth_signTypedData_v3":return this._eth_signTypedData_v3(r);case"eth_signTypedData_v4":case"eth_signTypedData":return this._eth_signTypedData_v4(r);case"wallet_addEthereumChain":return this._wallet_addEthereumChain(r);case"wallet_switchEthereumChain":return this._wallet_switchEthereumChain(r);case"wallet_watchAsset":return this._wallet_watchAsset(r);default:return this._throwUnsupportedMethodError()}}_isKnownAddress(e){try{const t=(0,g.ensureAddressString)(e);return this._addresses.map(s=>(0,g.ensureAddressString)(s)).includes(t)}catch{}return!1}_ensureKnownAddress(e){if(!this._isKnownAddress(e))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const t=e.from?(0,g.ensureAddressString)(e.from):this.selectedAddress;if(!t)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(t);const r=e.to?(0,g.ensureAddressString)(e.to):null,s=e.value!=null?(0,g.ensureBigInt)(e.value):BigInt(0),i=e.data?(0,g.ensureBuffer)(e.data):Buffer.alloc(0),a=e.nonce!=null?(0,g.ensureIntNumber)(e.nonce):null,o=e.gasPrice!=null?(0,g.ensureBigInt)(e.gasPrice):null,c=e.maxFeePerGas!=null?(0,g.ensureBigInt)(e.maxFeePerGas):null,l=e.maxPriorityFeePerGas!=null?(0,g.ensureBigInt)(e.maxPriorityFeePerGas):null,h=e.gas!=null?(0,g.ensureBigInt)(e.gas):null,f=e.chainId?(0,g.ensureIntNumber)(e.chainId):this.getChainId();return{fromAddress:t,toAddress:r,weiValue:s,data:i,nonce:a,gasPriceInWei:o,maxFeePerGas:c,maxPriorityFeePerGas:l,gasLimit:h,chainId:f}}_isAuthorized(){return this._addresses.length>0}_requireAuthorization(){if(!this._isAuthorized())throw w.standardErrors.provider.unauthorized({})}_throwUnsupportedMethodError(){throw w.standardErrors.provider.unsupportedMethod({})}async _signEthereumMessage(e,t,r,s){this._ensureKnownAddress(t);try{const a=await this.initializeRelay().signEthereumMessage(e,t,r,s);if((0,D.isErrorResponse)(a))throw new Error(a.errorMessage);return{jsonrpc:"2.0",id:0,result:a.result}}catch(i){throw typeof i.message=="string"&&i.message.match(/(denied|rejected)/i)?w.standardErrors.provider.userRejectedRequest("User denied message signature"):i}}async _ethereumAddressFromSignedMessage(e,t,r){const i=await this.initializeRelay().ethereumAddressFromSignedMessage(e,t,r);if((0,D.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}_eth_accounts(){return[...this._addresses]}_eth_coinbase(){return this.selectedAddress||null}_net_version(){return this.getChainId().toString(10)}_eth_chainId(){return(0,g.hexStringFromIntNumber)(this.getChainId())}getChainId(){const e=this._storage.getItem(qe);if(!e)return(0,g.ensureIntNumber)(1);const t=parseInt(e,10);return(0,g.ensureIntNumber)(t)}async _eth_requestAccounts(){if(this._isAuthorized())return Promise.resolve({jsonrpc:"2.0",id:0,result:this._addresses});let e;try{if(e=await this.initializeRelay().requestEthereumAccounts(),(0,D.isErrorResponse)(e))throw new Error(e.errorMessage)}catch(t){throw typeof t.message=="string"&&t.message.match(/(denied|rejected)/i)?w.standardErrors.provider.userRejectedRequest("User denied account authorization"):t}if(!e.result)throw new Error("accounts received is empty");return this._setAddresses(e.result),{jsonrpc:"2.0",id:0,result:this._addresses}}_eth_sign(e){this._requireAuthorization();const t=(0,g.ensureAddressString)(e[0]),r=(0,g.ensureBuffer)(e[1]);return this._signEthereumMessage(r,t,!1)}_eth_ecRecover(e){const t=(0,g.ensureBuffer)(e[0]),r=(0,g.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(t,r,!1)}_personal_sign(e){this._requireAuthorization();const t=(0,g.ensureBuffer)(e[0]),r=(0,g.ensureAddressString)(e[1]);return this._signEthereumMessage(t,r,!0)}_personal_ecRecover(e){const t=(0,g.ensureBuffer)(e[0]),r=(0,g.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(t,r,!0)}async _eth_signTransaction(e){this._requireAuthorization();const t=this._prepareTransactionParams(e[0]||{});try{const s=await this.initializeRelay().signEthereumTransaction(t);if((0,D.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}catch(r){throw typeof r.message=="string"&&r.message.match(/(denied|rejected)/i)?w.standardErrors.provider.userRejectedRequest("User denied transaction signature"):r}}async _eth_sendRawTransaction(e){const t=(0,g.ensureBuffer)(e[0]),s=await this.initializeRelay().submitEthereumTransaction(t,this.getChainId());if((0,D.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}async _eth_sendTransaction(e){this._requireAuthorization();const t=this._prepareTransactionParams(e[0]||{});try{const s=await this.initializeRelay().signAndSubmitEthereumTransaction(t);if((0,D.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}catch(r){throw typeof r.message=="string"&&r.message.match(/(denied|rejected)/i)?w.standardErrors.provider.userRejectedRequest("User denied transaction signature"):r}}async _eth_signTypedData_v1(e){this._requireAuthorization();const t=(0,g.ensureParsedJSONObject)(e[0]),r=(0,g.ensureAddressString)(e[1]);this._ensureKnownAddress(r);const s=Ke.default.hashForSignTypedDataLegacy({data:t}),i=JSON.stringify(t,null,2);return this._signEthereumMessage(s,r,!1,i)}async _eth_signTypedData_v3(e){this._requireAuthorization();const t=(0,g.ensureAddressString)(e[0]),r=(0,g.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(t);const s=Ke.default.hashForSignTypedData_v3({data:r}),i=JSON.stringify(r,null,2);return this._signEthereumMessage(s,t,!1,i)}async _eth_signTypedData_v4(e){this._requireAuthorization();const t=(0,g.ensureAddressString)(e[0]),r=(0,g.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(t);const s=Ke.default.hashForSignTypedData_v4({data:r}),i=JSON.stringify(r,null,2);return this._signEthereumMessage(s,t,!1,i)}async _wallet_addEthereumChain(e){var t,r,s,i;const a=e[0];if(((t=a.rpcUrls)===null||t===void 0?void 0:t.length)===0)return{jsonrpc:"2.0",id:0,error:{code:2,message:"please pass in at least 1 rpcUrl"}};if(!a.chainName||a.chainName.trim()==="")throw w.standardErrors.rpc.invalidParams("chainName is a required field");if(!a.nativeCurrency)throw w.standardErrors.rpc.invalidParams("nativeCurrency is a required field");const o=parseInt(a.chainId,16);return await this.addEthereumChain(o,(r=a.rpcUrls)!==null&&r!==void 0?r:[],(s=a.blockExplorerUrls)!==null&&s!==void 0?s:[],a.chainName,(i=a.iconUrls)!==null&&i!==void 0?i:[],a.nativeCurrency)?{jsonrpc:"2.0",id:0,result:null}:{jsonrpc:"2.0",id:0,error:{code:2,message:"unable to add ethereum chain"}}}async _wallet_switchEthereumChain(e){const t=e[0];return await this.switchEthereumChain(parseInt(t.chainId,16)),{jsonrpc:"2.0",id:0,result:null}}async _wallet_watchAsset(e){const t=Array.isArray(e)?e[0]:e;if(!t.type)throw w.standardErrors.rpc.invalidParams("Type is required");if((t==null?void 0:t.type)!=="ERC20")throw w.standardErrors.rpc.invalidParams(`Asset of type '${t.type}' is not supported`);if(!(t!=null&&t.options))throw w.standardErrors.rpc.invalidParams("Options are required");if(!(t!=null&&t.options.address))throw w.standardErrors.rpc.invalidParams("Address is required");const r=this.getChainId(),{address:s,symbol:i,image:a,decimals:o}=t.options;return{jsonrpc:"2.0",id:0,result:await this.watchAsset(t.type,s,i,o,a,r)}}initializeRelay(){if(!this._relay){const e=new Jr.WalletLinkRelay({linkAPIUrl:gt.WALLETLINK_URL,storage:this._storage});e.setAppInfo(this._appName,this._appLogoUrl),e.attachUI(),e.setAccountsCallback((t,r)=>this._setAddresses(t,r)),e.setChainCallback((t,r)=>{this.updateProviderInfo(r,parseInt(t,10))}),this._relay=e}return this._relay}}Ce.WalletLinkSigner=Xr;var k={};Object.defineProperty(k,"__esModule",{value:!0});k.checkErrorForInvalidRequestArgs=k.getCoinbaseInjectedProvider=k.getCoinbaseInjectedSigner=k.fetchRPCRequest=void 0;const es=K,pe=j;async function ts(n,e){if(!e.rpcUrl)throw pe.standardErrors.rpc.internal("No RPC URL set for chain");const t=Object.assign(Object.assign({},n),{jsonrpc:"2.0",id:crypto.randomUUID()});return(await(await window.fetch(e.rpcUrl,{method:"POST",body:JSON.stringify(t),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":es.LIB_VERSION}})).json()).result}k.fetchRPCRequest=ts;function Jt(){return globalThis.coinbaseWalletSigner}k.getCoinbaseInjectedSigner=Jt;function ns(){return globalThis.coinbaseWalletExtension}function rs(){var n,e;try{const t=globalThis;return(n=t.ethereum)!==null&&n!==void 0?n:(e=t.top)===null||e===void 0?void 0:e.ethereum}catch{return}}function ss({metadata:n,preference:e}){var t;if(e.options!=="smartWalletOnly"){if(Jt())return;const i=ns();if(i){const{appName:a,appLogoUrl:o,appChainIds:c}=n;return(t=i.setAppInfo)===null||t===void 0||t.call(i,a,o,c),i}}const r=rs();if(r!=null&&r.isCoinbaseBrowser)return r}k.getCoinbaseInjectedProvider=ss;function is(n){if(!n||typeof n!="object"||Array.isArray(n))return pe.standardErrors.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:n});const{method:e,params:t}=n;if(typeof e!="string"||e.length===0)return pe.standardErrors.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:n});if(t!==void 0&&!Array.isArray(t)&&(typeof t!="object"||t===null))return pe.standardErrors.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:n})}k.checkErrorForInvalidRequestArgs=is;Object.defineProperty(P,"__esModule",{value:!0});P.createSigner=P.fetchSignerType=P.storeSignerType=P.loadSignerType=void 0;const as=_e,Qt=Ce,os=j,cs=k,ds=O,Xt="SignerType",en=new ds.ScopedLocalStorage("CBWSDK","SignerConfigurator");function ls(){return en.getItem(Xt)}P.loadSignerType=ls;function us(n){en.setItem(Xt,n)}P.storeSignerType=us;async function hs(n){const{communicator:e,metadata:t}=n;ps(e,t).catch(()=>{});const r={id:crypto.randomUUID(),event:"selectSignerType",data:n.preference},{data:s}=await e.postRequestAndWaitForResponse(r);return s}P.fetchSignerType=hs;function gs(n){const{signerType:e,metadata:t,communicator:r,updateListener:s}=n;switch(e){case"scw":return new as.SCWSigner({metadata:t,updateListener:s,communicator:r});case"walletlink":return new Qt.WalletLinkSigner({metadata:t,updateListener:s});case"extension":{const i=(0,cs.getCoinbaseInjectedSigner)();if(!i)throw os.standardErrors.rpc.internal("injected signer not found");return i}}}P.createSigner=gs;async function ps(n,e){await n.onMessage(({event:r})=>r==="WalletLinkSessionRequest");const t=new Qt.WalletLinkSigner({metadata:e});n.postMessage({event:"WalletLinkUpdate",data:{session:t.getSession()}}),await t.handshake(),n.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var Te={},J={};Object.defineProperty(J,"__esModule",{value:!0});J.closePopup=J.openPopup=void 0;const fs=j,ft=420,mt=540;function ms(n){const e=(window.innerWidth-ft)/2+window.screenX,t=(window.innerHeight-mt)/2+window.screenY,r=window.open(n,"Smart Wallet",`width=${ft}, height=${mt}, left=${e}, top=${t}`);if(r==null||r.focus(),!r)throw fs.standardErrors.rpc.internal("Pop up window failed to open");return r}J.openPopup=ms;function bs(n){n&&!n.closed&&n.close()}J.closePopup=bs;Object.defineProperty(Te,"__esModule",{value:!0});Te.Communicator=void 0;const ys=K,bt=J,ws=T,yt=j;class vs{constructor(e=ws.CB_KEYS_URL){this.popup=null,this.listeners=new Map,this.postMessage=async t=>{(await this.waitForPopupLoaded()).postMessage(t,this.url.origin)},this.postRequestAndWaitForResponse=async t=>{const r=this.onMessage(({requestId:s})=>s===t.id);return this.postMessage(t),await r},this.onMessage=async t=>new Promise((r,s)=>{const i=a=>{if(a.origin!==this.url.origin)return;const o=a.data;t(o)&&(r(o),window.removeEventListener("message",i),this.listeners.delete(i))};window.addEventListener("message",i),this.listeners.set(i,{reject:s})}),this.disconnect=()=>{(0,bt.closePopup)(this.popup),this.popup=null,this.listeners.forEach(({reject:t},r)=>{t(yt.standardErrors.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",r)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=(0,bt.openPopup)(this.url),this.onMessage(({event:t})=>t==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:t})=>t==="PopupLoaded").then(t=>{this.postMessage({requestId:t.id,data:{version:ys.LIB_VERSION}})}).then(()=>{if(!this.popup)throw yt.standardErrors.rpc.internal();return this.popup})),this.url=new URL(e)}}Te.Communicator=vs;var je={};Object.defineProperty(je,"__esModule",{value:!0});je.determineMethodCategory=void 0;const wt={handshake:["eth_requestAccounts"],sign:["eth_ecRecover","personal_sign","personal_ecRecover","eth_signTransaction","eth_sendTransaction","eth_signTypedData_v1","eth_signTypedData_v3","eth_signTypedData_v4","eth_signTypedData","wallet_addEthereumChain","wallet_switchEthereumChain","wallet_watchAsset","wallet_getCapabilities","wallet_sendCalls","wallet_showCallsStatus"],state:["eth_chainId","eth_accounts","eth_coinbase","net_version"],deprecated:["eth_sign","eth_signTypedData_v2"],unsupported:["eth_subscribe","eth_unsubscribe"],fetch:[]};function _s(n){for(const e in wt){const t=e;if(wt[t].includes(n))return t}}je.determineMethodCategory=_s;var Es=M&&M.__rest||function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s{try{if(this.connected)return this.emit("connect",{chainId:(0,X.hexStringFromIntNumber)((0,he.IntNumber)(this.chain.id))}),this.accounts;const h=await this.requestSignerSelection(),f=this.initSigner(h),d=await f.handshake();return this.signer=f,(0,ge.storeSignerType)(h),this.emit("connect",{chainId:(0,X.hexStringFromIntNumber)((0,he.IntNumber)(this.chain.id))}),d}catch(h){throw this.handleUnauthorizedError(h),h}},sign:async l=>{if(!this.connected||!this.signer)throw V.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");try{return await this.signer.request(l)}catch(h){throw this.handleUnauthorizedError(h),h}},fetch:l=>(0,vt.fetchRPCRequest)(l,this.chain),state:l=>{const h=()=>{if(this.connected)return this.accounts;throw V.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")};switch(l.method){case"eth_chainId":return(0,X.hexStringFromIntNumber)((0,he.IntNumber)(this.chain.id));case"net_version":return this.chain.id;case"eth_accounts":return h();case"eth_coinbase":return h()[0];default:return this.handlers.unsupported(l)}},deprecated:({method:l})=>{throw V.standardErrors.rpc.methodNotSupported(`Method ${l} is deprecated.`)},unsupported:({method:l})=>{throw V.standardErrors.rpc.methodNotSupported(`Method ${l} is not supported.`)}},this.isCoinbaseWallet=!0,this.updateListener={onAccountsUpdate:({accounts:l,source:h})=>{(0,X.areAddressArraysEqual)(this.accounts,l)||(this.accounts=l,h!=="storage"&&this.emit("accountsChanged",this.accounts))},onChainUpdate:({chain:l,source:h})=>{l.id===this.chain.id&&l.rpcUrl===this.chain.rpcUrl||(this.chain=l,h!=="storage"&&this.emit("chainChanged",(0,X.hexStringFromIntNumber)((0,he.IntNumber)(l.id))))}},this.metadata=s,this.preference=o,this.communicator=new Is.Communicator(a),this.chain={id:(r=(t=s.appChainIds)===null||t===void 0?void 0:t[0])!==null&&r!==void 0?r:1};const c=(0,ge.loadSignerType)();this.signer=c?this.initSigner(c):null}get connected(){return this.accounts.length>0}async request(e){var t;try{const r=(0,vt.checkErrorForInvalidRequestArgs)(e);if(r)throw r;const s=(t=(0,Ms.determineMethodCategory)(e.method))!==null&&t!==void 0?t:"fetch";return this.handlers[s](e)}catch(r){return Promise.reject((0,ks.serializeError)(r,e.method))}}handleUnauthorizedError(e){e.code===V.standardErrorCodes.provider.unauthorized&&this.disconnect()}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),await this.request({method:"eth_requestAccounts"})}async disconnect(){this.accounts=[],this.chain={id:1},Ls.ScopedLocalStorage.clearAll(),this.emit("disconnect",V.standardErrors.provider.disconnected("User initiated disconnection"))}requestSignerSelection(){return(0,ge.fetchSignerType)({communicator:this.communicator,preference:this.preference,metadata:this.metadata})}initSigner(e){return(0,ge.createSigner)({signerType:e,metadata:this.metadata,communicator:this.communicator,updateListener:this.updateListener})}}be.CoinbaseWalletProvider=As;Object.defineProperty(te,"__esModule",{value:!0});te.CoinbaseWalletSDK=void 0;const Rs=me,xs=be,Ps=O,Ns=K,Ts=u,js=k;class Os{constructor(e){this.metadata={appName:e.appName||"Dapp",appLogoUrl:e.appLogoUrl||(0,Ts.getFavicon)(),appChainIds:e.appChainIds||[]},this.storeLatestVersion()}makeWeb3Provider(e={options:"all"}){var t;const r={metadata:this.metadata,preference:e};return(t=(0,js.getCoinbaseInjectedProvider)(r))!==null&&t!==void 0?t:new xs.CoinbaseWalletProvider(r)}getCoinbaseWalletLogo(e,t=240){return(0,Rs.walletLogo)(e,t)}storeLatestVersion(){new Ps.ScopedLocalStorage("CBWSDK").setItem("VERSION",Ns.LIB_VERSION)}}te.CoinbaseWalletSDK=Os;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.CoinbaseWalletSDK=void 0;const e=te;n.default=e.CoinbaseWalletSDK;var t=te;Object.defineProperty(n,"CoinbaseWalletSDK",{enumerable:!0,get:function(){return t.CoinbaseWalletSDK}})})(Et);const Ds=an(Et),Bs=Object.freeze(Object.defineProperty({__proto__:null,default:Ds},Symbol.toStringTag,{value:"Module"}));export{Bs as i}; +import{d as M,g as sr,h as ir}from"./index-mI-wCQlz.js";import{j as ar,s as or,r as _t,a as cr,b as dr}from"./hooks.module-BoePljmY.js";var Et={},te={},me={};Object.defineProperty(me,"__esModule",{value:!0});me.walletLogo=void 0;const lr=(r,e)=>{let t;switch(r){case"standard":return t=e,`data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return t=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${t}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return t=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return t=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return t=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return t=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return t=e,`data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};me.walletLogo=lr;var be={},j={},U={};Object.defineProperty(U,"__esModule",{value:!0});U.errorValues=U.standardErrorCodes=void 0;U.standardErrorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}};U.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}};var ye={},$e={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.serialize=r.getErrorCode=r.isValidCode=r.getMessageFromCode=r.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=U,t="Unspecified error message.";r.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function n(d,p=t){if(d&&Number.isInteger(d)){const m=d.toString();if(h(e.errorValues,m))return e.errorValues[m].message;if(c(d))return r.JSON_RPC_SERVER_ERROR_MESSAGE}return p}r.getMessageFromCode=n;function s(d){if(!Number.isInteger(d))return!1;const p=d.toString();return!!(e.errorValues[p]||c(d))}r.isValidCode=s;function i(d){var p;if(typeof d=="number")return d;if(a(d))return(p=d.code)!==null&&p!==void 0?p:d.errorCode}r.getErrorCode=i;function a(d){return typeof d=="object"&&d!==null&&(typeof d.code=="number"||typeof d.errorCode=="number")}function o(d,{shouldIncludeStack:p=!1}={}){const m={};if(d&&typeof d=="object"&&!Array.isArray(d)&&h(d,"code")&&s(d.code)){const B=d;m.code=B.code,B.message&&typeof B.message=="string"?(m.message=B.message,h(B,"data")&&(m.data=B.data)):(m.message=n(m.code),m.data={originalError:l(d)})}else m.code=e.standardErrorCodes.rpc.internal,m.message=f(d,"message")?d.message:t,m.data={originalError:l(d)};return p&&(m.stack=f(d,"stack")?d.stack:void 0),m}r.serialize=o;function c(d){return d>=-32099&&d<=-32e3}function l(d){return d&&typeof d=="object"&&!Array.isArray(d)?Object.assign({},d):d}function h(d,p){return Object.prototype.hasOwnProperty.call(d,p)}function f(d,p){return typeof d=="object"&&d!==null&&p in d&&typeof d[p]=="string"}})($e);Object.defineProperty(ye,"__esModule",{value:!0});ye.standardErrors=void 0;const v=U,St=$e;ye.standardErrors={rpc:{parse:r=>C(v.standardErrorCodes.rpc.parse,r),invalidRequest:r=>C(v.standardErrorCodes.rpc.invalidRequest,r),invalidParams:r=>C(v.standardErrorCodes.rpc.invalidParams,r),methodNotFound:r=>C(v.standardErrorCodes.rpc.methodNotFound,r),internal:r=>C(v.standardErrorCodes.rpc.internal,r),server:r=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=r;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return C(e,r)},invalidInput:r=>C(v.standardErrorCodes.rpc.invalidInput,r),resourceNotFound:r=>C(v.standardErrorCodes.rpc.resourceNotFound,r),resourceUnavailable:r=>C(v.standardErrorCodes.rpc.resourceUnavailable,r),transactionRejected:r=>C(v.standardErrorCodes.rpc.transactionRejected,r),methodNotSupported:r=>C(v.standardErrorCodes.rpc.methodNotSupported,r),limitExceeded:r=>C(v.standardErrorCodes.rpc.limitExceeded,r)},provider:{userRejectedRequest:r=>$(v.standardErrorCodes.provider.userRejectedRequest,r),unauthorized:r=>$(v.standardErrorCodes.provider.unauthorized,r),unsupportedMethod:r=>$(v.standardErrorCodes.provider.unsupportedMethod,r),disconnected:r=>$(v.standardErrorCodes.provider.disconnected,r),chainDisconnected:r=>$(v.standardErrorCodes.provider.chainDisconnected,r),unsupportedChain:r=>$(v.standardErrorCodes.provider.unsupportedChain,r),custom:r=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:t,data:n}=r;if(!t||typeof t!="string")throw new Error('"message" must be a nonempty string');return new It(e,t,n)}}};function C(r,e){const[t,n]=Ct(e);return new kt(r,t||(0,St.getMessageFromCode)(r),n)}function $(r,e){const[t,n]=Ct(e);return new It(r,t||(0,St.getMessageFromCode)(r),n)}function Ct(r){if(r){if(typeof r=="string")return[r];if(typeof r=="object"&&!Array.isArray(r)){const{message:e,data:t}=r;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,t]}}return[]}class kt extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||typeof t!="string")throw new Error('"message" must be a nonempty string.');super(t),this.code=e,n!==void 0&&(this.data=n)}}class It extends kt{constructor(e,t,n){if(!ur(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,n)}}function ur(r){return Number.isInteger(r)&&r>=1e3&&r<=4999}(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.standardErrors=r.standardErrorCodes=void 0;var e=U;Object.defineProperty(r,"standardErrorCodes",{enumerable:!0,get:function(){return e.standardErrorCodes}});var t=ye;Object.defineProperty(r,"standardErrors",{enumerable:!0,get:function(){return t.standardErrors}})})(j);var we={},Q={};Object.defineProperty(Q,"__esModule",{value:!0});Q.isErrorResponse=void 0;function hr(r){return r.errorMessage!==void 0}Q.isErrorResponse=hr;var K={};Object.defineProperty(K,"__esModule",{value:!0});K.LIB_VERSION=void 0;K.LIB_VERSION="4.0.4";Object.defineProperty(we,"__esModule",{value:!0});we.serializeError=void 0;const gr=Q,pr=K,fr=U,mr=$e;function br(r,e){const t=(0,mr.serialize)(yr(r),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");n.searchParams.set("version",pr.LIB_VERSION),n.searchParams.set("code",t.code.toString());const s=wr(t.data,e);return s&&n.searchParams.set("method",s),n.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:n.href})}we.serializeError=br;function yr(r){return typeof r=="string"?{message:r,code:fr.standardErrorCodes.rpc.internal}:(0,gr.isErrorResponse)(r)?Object.assign(Object.assign({},r),{message:r.errorMessage,code:r.errorCode,data:{method:r.method}}):r}function wr(r,e){const t=r==null?void 0:r.method;if(t)return t;if(e!==void 0){if(typeof e=="string")return e;if(Array.isArray(e)){if(e.length>0)return e[0].method}else return e.method}}var _={};Object.defineProperty(_,"__esModule",{value:!0});_.RegExpString=_.IntNumber=_.BigIntString=_.AddressString=_.HexString=_.OpaqueType=void 0;function re(){return r=>r}_.OpaqueType=re;_.HexString=re();_.AddressString=re();_.BigIntString=re();function vr(r){return Math.floor(r)}_.IntNumber=vr;_.RegExpString=re();var u={};Object.defineProperty(u,"__esModule",{value:!0});u.areAddressArraysEqual=u.getFavicon=u.range=u.isBigNumber=u.ensureParsedJSONObject=u.ensureBigInt=u.ensureRegExpString=u.ensureIntNumber=u.ensureBuffer=u.ensureAddressString=u.ensureEvenLengthHexString=u.ensureHexString=u.isHexString=u.prepend0x=u.strip0x=u.has0xPrefix=u.hexStringFromIntNumber=u.intNumberFromHexString=u.bigIntStringFromBigInt=u.hexStringFromBuffer=u.hexStringToUint8Array=u.uint8ArrayToHex=u.randomBytesHex=void 0;const q=j,I=_,Mt=/^[0-9]*$/,Lt=/^[a-f0-9]*$/;function _r(r){return At(crypto.getRandomValues(new Uint8Array(r)))}u.randomBytesHex=_r;function At(r){return[...r].map(e=>e.toString(16).padStart(2,"0")).join("")}u.uint8ArrayToHex=At;function Er(r){return new Uint8Array(r.match(/.{1,2}/g).map(e=>parseInt(e,16)))}u.hexStringToUint8Array=Er;function Sr(r,e=!1){const t=r.toString("hex");return(0,I.HexString)(e?`0x${t}`:t)}u.hexStringFromBuffer=Sr;function Cr(r){return(0,I.BigIntString)(r.toString(10))}u.bigIntStringFromBigInt=Cr;function kr(r){return(0,I.IntNumber)(Number(BigInt(se(r,!0))))}u.intNumberFromHexString=kr;function Ir(r){return(0,I.HexString)(`0x${BigInt(r).toString(16)}`)}u.hexStringFromIntNumber=Ir;function Fe(r){return r.startsWith("0x")||r.startsWith("0X")}u.has0xPrefix=Fe;function ve(r){return Fe(r)?r.slice(2):r}u.strip0x=ve;function Rt(r){return Fe(r)?`0x${r.slice(2)}`:`0x${r}`}u.prepend0x=Rt;function ne(r){if(typeof r!="string")return!1;const e=ve(r).toLowerCase();return Lt.test(e)}u.isHexString=ne;function xt(r,e=!1){if(typeof r=="string"){const t=ve(r).toLowerCase();if(Lt.test(t))return(0,I.HexString)(e?`0x${t}`:t)}throw q.standardErrors.rpc.invalidParams(`"${String(r)}" is not a hexadecimal string`)}u.ensureHexString=xt;function se(r,e=!1){let t=xt(r,!1);return t.length%2===1&&(t=(0,I.HexString)(`0${t}`)),e?(0,I.HexString)(`0x${t}`):t}u.ensureEvenLengthHexString=se;function Mr(r){if(typeof r=="string"){const e=ve(r).toLowerCase();if(ne(e)&&e.length===40)return(0,I.AddressString)(Rt(e))}throw q.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(r)}`)}u.ensureAddressString=Mr;function Lr(r){if(Buffer.isBuffer(r))return r;if(typeof r=="string"){if(ne(r)){const e=se(r,!1);return Buffer.from(e,"hex")}return Buffer.from(r,"utf8")}throw q.standardErrors.rpc.invalidParams(`Not binary data: ${String(r)}`)}u.ensureBuffer=Lr;function Pt(r){if(typeof r=="number"&&Number.isInteger(r))return(0,I.IntNumber)(r);if(typeof r=="string"){if(Mt.test(r))return(0,I.IntNumber)(Number(r));if(ne(r))return(0,I.IntNumber)(Number(BigInt(se(r,!0))))}throw q.standardErrors.rpc.invalidParams(`Not an integer: ${String(r)}`)}u.ensureIntNumber=Pt;function Ar(r){if(r instanceof RegExp)return(0,I.RegExpString)(r.toString());throw q.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(r)}`)}u.ensureRegExpString=Ar;function Rr(r){if(r!==null&&(typeof r=="bigint"||Nt(r)))return BigInt(r.toString(10));if(typeof r=="number")return BigInt(Pt(r));if(typeof r=="string"){if(Mt.test(r))return BigInt(r);if(ne(r))return BigInt(se(r,!0))}throw q.standardErrors.rpc.invalidParams(`Not an integer: ${String(r)}`)}u.ensureBigInt=Rr;function xr(r){if(typeof r=="string")return JSON.parse(r);if(typeof r=="object")return r;throw q.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(r)}`)}u.ensureParsedJSONObject=xr;function Nt(r){if(r==null||typeof r.constructor!="function")return!1;const{constructor:e}=r;return typeof e.config=="function"&&typeof e.EUCLID=="number"}u.isBigNumber=Nt;function Pr(r,e){return Array.from({length:e-r},(t,n)=>r+n)}u.range=Pr;function Nr(){const r=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:t}=document.location,n=r?r.getAttribute("href"):null;return!n||n.startsWith("javascript:")||n.startsWith("vbscript:")?null:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?e+n:`${e}//${t}${n}`}u.getFavicon=Nr;function Tr(r,e){return r.length===e.length&&r.every((t,n)=>t===e[n])}u.areAddressArraysEqual=Tr;var P={},_e={},Ee={},y={};Object.defineProperty(y,"__esModule",{value:!0});y.decryptContent=y.encryptContent=y.importKeyFromHexString=y.exportKeyToHexString=y.decrypt=y.encrypt=y.deriveSharedSecret=y.generateKeyPair=void 0;const Tt=u;async function jr(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}y.generateKeyPair=jr;async function Or(r,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},r,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}y.deriveSharedSecret=Or;async function jt(r,e){const t=crypto.getRandomValues(new Uint8Array(12)),n=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},r,new TextEncoder().encode(e));return{iv:t,cipherText:n}}y.encrypt=jt;async function Ot(r,{iv:e,cipherText:t}){const n=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},r,t);return new TextDecoder().decode(n)}y.decrypt=Ot;function Dt(r){switch(r){case"public":return"spki";case"private":return"pkcs8"}}async function Dr(r,e){const t=Dt(r),n=await crypto.subtle.exportKey(t,e);return(0,Tt.uint8ArrayToHex)(new Uint8Array(n))}y.exportKeyToHexString=Dr;async function Wr(r,e){const t=Dt(r),n=(0,Tt.hexStringToUint8Array)(e).buffer;return await crypto.subtle.importKey(t,n,{name:"ECDH",namedCurve:"P-256"},!0,r==="private"?["deriveKey"]:[])}y.importKeyFromHexString=Wr;async function Ur(r,e){const t=JSON.stringify(r,(n,s)=>{if(!(s instanceof Error))return s;const i=s;return Object.assign(Object.assign({},i.code?{code:i.code}:{}),{message:i.message})});return jt(e,t)}y.encryptContent=Ur;async function Br(r,e){return JSON.parse(await Ot(e,r))}y.decryptContent=Br;var O={};Object.defineProperty(O,"__esModule",{value:!0});O.ScopedLocalStorage=void 0;class fe{constructor(e,t){this.scope=e,this.module=t}setItem(e,t){localStorage.setItem(this.scopedKey(e),t)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),t=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new fe("CBWSDK").clear(),new fe("walletlink").clear()}}O.ScopedLocalStorage=fe;Object.defineProperty(Ee,"__esModule",{value:!0});Ee.SCWKeyManager=void 0;const oe=y,Hr=O,De={storageKey:"ownPrivateKey",keyType:"private"},We={storageKey:"ownPublicKey",keyType:"public"},Ue={storageKey:"peerPublicKey",keyType:"public"};class Kr{constructor(){this.storage=new Hr.ScopedLocalStorage("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(e){this.sharedSecret=null,this.peerPublicKey=e,await this.storeKey(Ue,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(We.storageKey),this.storage.removeItem(De.storageKey),this.storage.removeItem(Ue.storageKey)}async generateKeyPair(){const e=await(0,oe.generateKeyPair)();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(De,e.privateKey),await this.storeKey(We,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(De)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(We)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(Ue)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await(0,oe.deriveSharedSecret)(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const t=this.storage.getItem(e.storageKey);return t?(0,oe.importKeyFromHexString)(e.keyType,t):null}async storeKey(e,t){const n=await(0,oe.exportKeyToHexString)(e.keyType,t);this.storage.setItem(e.storageKey,n)}}Ee.SCWKeyManager=Kr;var Se={};Object.defineProperty(Se,"__esModule",{value:!0});Se.SCWStateManager=void 0;const qr=O,Qe="accounts",Xe="activeChain",et="availableChains",tt="walletCapabilities";class $r{get accounts(){return this._accounts}get activeChain(){return this._activeChain}get walletCapabilities(){return this._walletCapabilities}constructor(e){var t,n;this.storage=new qr.ScopedLocalStorage("CBWSDK","SCWStateManager"),this.updateListener=e.updateListener,this.availableChains=this.loadItemFromStorage(et),this._walletCapabilities=this.loadItemFromStorage(tt);const s=this.loadItemFromStorage(Qe),i=this.loadItemFromStorage(Xe);s&&this.updateListener.onAccountsUpdate({accounts:s,source:"storage"}),i&&this.updateListener.onChainUpdate({chain:i,source:"storage"}),this._accounts=s||[],this._activeChain=i||{id:(n=(t=e.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1}}updateAccounts(e){this._accounts=e,this.storeItemToStorage(Qe,e),this.updateListener.onAccountsUpdate({accounts:e,source:"wallet"})}switchChain(e){var t;const n=(t=this.availableChains)===null||t===void 0?void 0:t.find(s=>s.id===e);return n?(n===this._activeChain||(this._activeChain=n,this.storeItemToStorage(Xe,n),this.updateListener.onChainUpdate({chain:n,source:"wallet"})),!0):!1}updateAvailableChains(e){if(!e||Object.keys(e).length===0)return;const t=Object.entries(e).map(([n,s])=>({id:Number(n),rpcUrl:s}));this.availableChains=t,this.storeItemToStorage(et,t),this.switchChain(this._activeChain.id)}updateWalletCapabilities(e){this._walletCapabilities=e,this.storeItemToStorage(tt,e)}storeItemToStorage(e,t){this.storage.setItem(e,JSON.stringify(t))}loadItemFromStorage(e){const t=this.storage.getItem(e);return t?JSON.parse(t):void 0}clear(){this.storage.clear()}}Se.SCWStateManager=$r;Object.defineProperty(_e,"__esModule",{value:!0});_e.SCWSigner=void 0;const Fr=Ee,zr=Se,ce=j,rt=u,de=y;class Vr{constructor(e){this.metadata=e.metadata,this.communicator=e.communicator,this.keyManager=new Fr.SCWKeyManager,this.stateManager=new zr.SCWStateManager({appChainIds:this.metadata.appChainIds,updateListener:e.updateListener}),this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(){const e=await this.createRequestMessage({handshake:{method:"eth_requestAccounts",params:this.metadata}}),t=await this.communicator.postRequestAndWaitForResponse(e);if("failure"in t.content)throw t.content.failure;const n=await(0,de.importKeyFromHexString)("public",t.sender);await this.keyManager.setPeerPublicKey(n);const s=await this.decryptResponseMessage(t);this.updateInternalState({method:"eth_requestAccounts"},s);const i=s.result;if("error"in i)throw i.error;return this.stateManager.accounts}async request(e){const t=this.tryLocalHandling(e);if(t!==void 0){if(t instanceof Error)throw t;return t}await this.communicator.waitForPopupLoaded();const n=await this.sendEncryptedRequest(e),s=await this.decryptResponseMessage(n);this.updateInternalState(e,s);const i=s.result;if("error"in i)throw i.error;return i.value}async disconnect(){this.stateManager.clear(),await this.keyManager.clear()}tryLocalHandling(e){var t;switch(e.method){case"wallet_switchEthereumChain":{const n=e.params;if(!n||!(!((t=n[0])===null||t===void 0)&&t.chainId))throw ce.standardErrors.rpc.invalidParams();const s=(0,rt.ensureIntNumber)(n[0].chainId);return this.stateManager.switchChain(s)?null:void 0}case"wallet_getCapabilities":{const n=this.stateManager.walletCapabilities;if(!n)throw ce.standardErrors.provider.unauthorized("No wallet capabilities found, please disconnect and reconnect");return n}default:return}}async sendEncryptedRequest(e){const t=await this.keyManager.getSharedSecret();if(!t)throw ce.standardErrors.provider.unauthorized("No valid session found, try requestAccounts before other methods");const n=await(0,de.encryptContent)({action:e,chainId:this.stateManager.activeChain.id},t),s=await this.createRequestMessage({encrypted:n});return this.communicator.postRequestAndWaitForResponse(s)}async createRequestMessage(e){const t=await(0,de.exportKeyToHexString)("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:t,content:e,timestamp:new Date}}async decryptResponseMessage(e){const t=e.content;if("failure"in t)throw t.failure;const n=await this.keyManager.getSharedSecret();if(!n)throw ce.standardErrors.provider.unauthorized("Invalid session");return(0,de.decryptContent)(t.encrypted,n)}updateInternalState(e,t){var n,s;const i=(n=t.data)===null||n===void 0?void 0:n.chains;i&&this.stateManager.updateAvailableChains(i);const a=(s=t.data)===null||s===void 0?void 0:s.capabilities;a&&this.stateManager.updateWalletCapabilities(a);const o=t.result;if(!("error"in o))switch(e.method){case"eth_requestAccounts":{const c=o.value;this.stateManager.updateAccounts(c);break}case"wallet_switchEthereumChain":{if(o.value!==null)return;const c=e.params,l=(0,rt.ensureIntNumber)(c[0].chainId);this.stateManager.switchChain(l);break}}}}_e.SCWSigner=Vr;var Ce={};const Zr=ar;function Wt(r){return Buffer.allocUnsafe(r).fill(0)}function Gr(r){return r.toString(2).length}function Ut(r,e){let t=r.toString(16);t.length%2!==0&&(t="0"+t);const n=t.match(/.{1,2}/g).map(s=>parseInt(s,16));for(;n.length"u")throw new Error("Not an array?");if(t=Ft(r),t!=="dynamic"&&t!==0&&e.length>t)throw new Error("Elements exceed array size: "+t);s=[],r=r.slice(0,r.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(i in e)s.push(R(r,e[i]));if(t==="dynamic"){var a=R("uint256",e.length);s.unshift(a)}return Buffer.concat(s)}else{if(r==="bytes")return e=new Buffer(e),s=Buffer.concat([R("uint256",e.length),e]),e.length%32!==0&&(s=Buffer.concat([s,E.zeros(32-e.length%32)])),s;if(r.startsWith("bytes")){if(t=G(r),t<1||t>32)throw new Error("Invalid bytes width: "+t);return E.setLengthRight(e,32)}else if(r.startsWith("uint")){if(t=G(r),t%8||t<8||t>256)throw new Error("Invalid uint width: "+t);n=H(e);const o=E.bitLengthFromBigInt(n);if(o>t)throw new Error("Supplied uint exceeds width: "+t+" vs "+o);if(n<0)throw new Error("Supplied uint is negative");return E.bufferBEFromBigInt(n,32)}else if(r.startsWith("int")){if(t=G(r),t%8||t<8||t>256)throw new Error("Invalid int width: "+t);n=H(e);const o=E.bitLengthFromBigInt(n);if(o>t)throw new Error("Supplied int exceeds width: "+t+" vs "+o);const c=E.twosFromBigInt(n,256);return E.bufferBEFromBigInt(c,32)}else if(r.startsWith("ufixed")){if(t=nt(r),n=H(e),n<0)throw new Error("Supplied ufixed is negative");return R("uint256",n*BigInt(2)**BigInt(t[1]))}else if(r.startsWith("fixed"))return t=nt(r),R("int256",H(e)*BigInt(2)**BigInt(t[1]))}throw new Error("Unsupported or invalid type: "+r)}function tn(r){return r==="string"||r==="bytes"||Ft(r)==="dynamic"}function rn(r){return r.lastIndexOf("]")===r.length-1}function nn(r,e){var t=[],n=[],s=32*r.length;for(var i in r){var a=$t(r[i]),o=e[i],c=R(a,o);tn(a)?(t.push(R("uint256",s)),n.push(c),s+=c.length):t.push(c)}return Buffer.concat(t.concat(n))}function zt(r,e){if(r.length!==e.length)throw new Error("Number of types are not matching the values");for(var t,n,s=[],i=0;i32)throw new Error("Invalid bytes width: "+t);s.push(E.setLengthRight(o,t))}else if(a.startsWith("uint")){if(t=G(a),t%8||t<8||t>256)throw new Error("Invalid uint width: "+t);n=H(o);const c=E.bitLengthFromBigInt(n);if(c>t)throw new Error("Supplied uint exceeds width: "+t+" vs "+c);s.push(E.bufferBEFromBigInt(n,t/8))}else if(a.startsWith("int")){if(t=G(a),t%8||t<8||t>256)throw new Error("Invalid int width: "+t);n=H(o);const c=E.bitLengthFromBigInt(n);if(c>t)throw new Error("Supplied int exceeds width: "+t+" vs "+c);const l=E.twosFromBigInt(n,t);s.push(E.bufferBEFromBigInt(l,t/8))}else throw new Error("Unsupported or invalid type: "+a)}return Buffer.concat(s)}function sn(r,e){return E.keccak(zt(r,e))}var an={rawEncode:nn,solidityPack:zt,soliditySHA3:sn};const A=qt,ee=an,Vt={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},Be={encodeData(r,e,t,n=!0){const s=["bytes32"],i=[this.hashType(r,t)];if(n){const a=(o,c,l)=>{if(t[c]!==void 0)return["bytes32",l==null?"0x0000000000000000000000000000000000000000000000000000000000000000":A.keccak(this.encodeData(c,l,t,n))];if(l===void 0)throw new Error(`missing value for field ${o} of type ${c}`);if(c==="bytes")return["bytes32",A.keccak(l)];if(c==="string")return typeof l=="string"&&(l=Buffer.from(l,"utf8")),["bytes32",A.keccak(l)];if(c.lastIndexOf("]")===c.length-1){const h=c.slice(0,c.lastIndexOf("[")),f=l.map(d=>a(o,h,d));return["bytes32",A.keccak(ee.rawEncode(f.map(([d])=>d),f.map(([,d])=>d)))]}return[c,l]};for(const o of t[r]){const[c,l]=a(o.name,o.type,e[o.name]);s.push(c),i.push(l)}}else for(const a of t[r]){let o=e[a.name];if(o!==void 0)if(a.type==="bytes")s.push("bytes32"),o=A.keccak(o),i.push(o);else if(a.type==="string")s.push("bytes32"),typeof o=="string"&&(o=Buffer.from(o,"utf8")),o=A.keccak(o),i.push(o);else if(t[a.type]!==void 0)s.push("bytes32"),o=A.keccak(this.encodeData(a.type,o,t,n)),i.push(o);else{if(a.type.lastIndexOf("]")===a.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");s.push(a.type),i.push(o)}}return ee.rawEncode(s,i)},encodeType(r,e){let t="",n=this.findTypeDependencies(r,e).filter(s=>s!==r);n=[r].concat(n.sort());for(const s of n){if(!e[s])throw new Error("No type definition specified: "+s);t+=s+"("+e[s].map(({name:a,type:o})=>o+" "+a).join(",")+")"}return t},findTypeDependencies(r,e,t=[]){if(r=r.match(/^\w*/)[0],t.includes(r)||e[r]===void 0)return t;t.push(r);for(const n of e[r])for(const s of this.findTypeDependencies(n.type,e,t))!t.includes(s)&&t.push(s);return t},hashStruct(r,e,t,n=!0){return A.keccak(this.encodeData(r,e,t,n))},hashType(r,e){return A.keccak(this.encodeType(r,e))},sanitizeData(r){const e={};for(const t in Vt.properties)r[t]&&(e[t]=r[t]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(r,e=!0){const t=this.sanitizeData(r),n=[Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",t.domain,t.types,e)),t.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(t.primaryType,t.message,t.types,e)),A.keccak(Buffer.concat(n))}};var on={TYPED_MESSAGE_SCHEMA:Vt,TypedDataUtils:Be,hashForSignTypedDataLegacy:function(r){return cn(r.data)},hashForSignTypedData_v3:function(r){return Be.hash(r.data,!1)},hashForSignTypedData_v4:function(r){return Be.hash(r.data)}};function cn(r){const e=new Error("Expect argument to be non-empty array");if(typeof r!="object"||!r.length)throw e;const t=r.map(function(i){return i.type==="bytes"?A.toBuffer(i.value):i.value}),n=r.map(function(i){return i.type}),s=r.map(function(i){if(!i.name)throw e;return i.type+" "+i.name});return ee.soliditySHA3(["bytes32","bytes32"],[ee.soliditySHA3(new Array(r.length).fill("string"),s),ee.soliditySHA3(n,t)])}var N={};Object.defineProperty(N,"__esModule",{value:!0});N.APP_VERSION_KEY=N.LOCAL_STORAGE_ADDRESSES_KEY=N.WALLET_USER_NAME_KEY=void 0;N.WALLET_USER_NAME_KEY="walletUsername";N.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";N.APP_VERSION_KEY="AppVersion";var ie={};Object.defineProperty(ie,"__esModule",{value:!0});ie.RelayEventManager=void 0;const dn=u;class ln{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,t=(0,dn.prepend0x)(e.toString(16));return this.callbacks.get(t)&&this.callbacks.delete(t),e}}ie.RelayEventManager=ln;var Ie={},Me={},Le={};Object.defineProperty(Le,"__esModule",{value:!0});Le.WalletLinkCipher=void 0;const le=u;class un{constructor(e){this.secret=e}async encrypt(e){const t=this.secret;if(t.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),s=await crypto.subtle.importKey("raw",(0,le.hexStringToUint8Array)(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),i=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},s,i.encode(e)),o=16,c=a.slice(a.byteLength-o),l=a.slice(0,a.byteLength-o),h=new Uint8Array(c),f=new Uint8Array(l),d=new Uint8Array([...n,...h,...f]);return(0,le.uint8ArrayToHex)(d)}async decrypt(e){const t=this.secret;if(t.length!==64)throw Error("secret must be 256 bits");return new Promise((n,s)=>{(async function(){const i=await crypto.subtle.importKey("raw",(0,le.hexStringToUint8Array)(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=(0,le.hexStringToUint8Array)(e),o=a.slice(0,12),c=a.slice(12,28),l=a.slice(28),h=new Uint8Array([...l,...c]),f={name:"AES-GCM",iv:new Uint8Array(o)};try{const d=await window.crypto.subtle.decrypt(f,i,h),p=new TextDecoder;n(p.decode(d))}catch(d){s(d)}})()})}}Le.WalletLinkCipher=un;var Ae={};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.WalletLinkHTTP=void 0;class hn{constructor(e,t,n){this.linkAPIUrl=e,this.sessionId=t;const s=`${t}:${n}`;this.auth=`Basic ${btoa(s)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(t=>fetch(`${this.linkAPIUrl}/events/${t.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(t=>console.error("Unabled to mark event as failed:",t))}async fetchUnseenEvents(){var e;const t=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(t.ok){const{events:n,error:s}=await t.json();if(s)throw new Error(`Check unseen events failed: ${s}`);const i=(e=n==null?void 0:n.filter(a=>a.event==="Web3Response").map(a=>({type:"Event",sessionId:this.sessionId,eventId:a.id,event:a.event,data:a.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(i),i}throw new Error(`Check unseen events failed: ${t.status}`)}}Ae.WalletLinkHTTP=hn;var Y={};Object.defineProperty(Y,"__esModule",{value:!0});Y.WalletLinkWebSocket=Y.ConnectionState=void 0;var Z;(function(r){r[r.DISCONNECTED=0]="DISCONNECTED",r[r.CONNECTING=1]="CONNECTING",r[r.CONNECTED=2]="CONNECTED"})(Z||(Y.ConnectionState=Z={}));class gn{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,t=WebSocket){this.WebSocketClass=t,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,t)=>{var n;let s;try{this.webSocket=s=new this.WebSocketClass(this.url)}catch(i){t(i);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,Z.CONNECTING),s.onclose=i=>{var a;this.clearWebSocket(),t(new Error(`websocket error ${i.code}: ${i.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,Z.DISCONNECTED)},s.onopen=i=>{var a;e(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,Z.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(c=>this.sendData(c)),this.pendingData=[])},s.onmessage=i=>{var a,o;if(i.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(i.data);(o=this.incomingDataListener)===null||o===void 0||o.call(this,c)}catch{}}})}disconnect(){var e;const{webSocket:t}=this;if(t){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,Z.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{t.close()}catch{}}}sendData(e){const{webSocket:t}=this;if(!t){this.pendingData.push(e),this.connect();return}t.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}Y.WalletLinkWebSocket=gn;Object.defineProperty(Me,"__esModule",{value:!0});Me.WalletLinkConnection=void 0;const st=N,pn=Le,fn=Ae,ue=Y,F=_,it=1e4,mn=6e4;class bn{constructor({session:e,linkAPIUrl:t,listener:n,WebSocketClass:s=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,F.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=a=>{if(!a)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",c=>a.JsonRpcUrl&&this.handleChainUpdated(c,a.JsonRpcUrl)]]).forEach((c,l)=>{const h=a[l];h!==void 0&&c(h)})},this.handleDestroyed=a=>{var o;a==="1"&&((o=this.listener)===null||o===void 0||o.resetAndReload())},this.handleAccountUpdated=async a=>{var o;{const c=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.accountUpdated(c)}},this.handleMetadataUpdated=async(a,o)=>{var c;{const l=await this.cipher.decrypt(o);(c=this.listener)===null||c===void 0||c.metadataUpdated(a,l)}},this.handleWalletUsernameUpdated=async a=>{this.handleMetadataUpdated(st.WALLET_USER_NAME_KEY,a)},this.handleAppVersionUpdated=async a=>{this.handleMetadataUpdated(st.APP_VERSION_KEY,a)},this.handleChainUpdated=async(a,o)=>{var c;{const l=await this.cipher.decrypt(a),h=await this.cipher.decrypt(o);(c=this.listener)===null||c===void 0||c.chainUpdated(l,h)}},this.session=e,this.cipher=new pn.WalletLinkCipher(e.secret),this.listener=n;const i=new ue.WalletLinkWebSocket(`${t}/rpc`,s);i.setConnectionStateListener(async a=>{let o=!1;switch(a){case ue.ConnectionState.DISCONNECTED:if(!this.destroyed){const c=async()=>{await new Promise(l=>setTimeout(l,5e3)),this.destroyed||i.connect().catch(()=>{c()})};c()}break;case ue.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),o=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},it),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case ue.ConnectionState.CONNECTING:break}this.connected!==o&&(this.connected=o)}),i.setIncomingDataListener(a=>{var o;switch(a.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const c=a.type==="IsLinkedOK"?a.linked:void 0;this.linked=c||a.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(a.metadata);break}case"Event":{this.handleIncomingEvent(a);break}}a.id!==void 0&&((o=this.requestResolutions.get(a.id))===null||o===void 0||o(a))}),this.ws=i,this.http=new fn.WalletLinkHTTP(t,e.id,e.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}destroy(){this.destroyed=!0,this.ws.disconnect(),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(e){var t;this._connected=e,e&&((t=this.onceConnected)===null||t===void 0||t.call(this))}setOnceConnected(e){return new Promise(t=>{this.connected?e().then(t):this.onceConnected=()=>{e().then(t),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(e){var t,n;this._linked=e,e&&((t=this.onceLinked)===null||t===void 0||t.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(e)}setOnceLinked(e){return new Promise(t=>{this.linked?e().then(t):this.onceLinked=()=>{e().then(t),this.onceLinked=void 0}})}async handleIncomingEvent(e){var t;if(!(e.type!=="Event"||e.event!=="Web3Response")){const n=await this.cipher.decrypt(e.data),s=JSON.parse(n);if(s.type!=="WEB3_RESPONSE")return;(t=this.listener)===null||t===void 0||t.handleWeb3ResponseMessage(s)}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(t=>this.handleIncomingEvent(t))}async setSessionMetadata(e,t){const n={type:"SetSessionConfig",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[e]:t}};return this.setOnceConnected(async()=>{const s=await this.makeRequest(n);if(s.type==="Fail")throw new Error(s.error||"failed to set session metadata")})}async publishEvent(e,t,n=!1){const s=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},t),{origin:location.origin,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),i={type:"PublishEvent",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:e,data:s,callWebhook:n};return this.setOnceLinked(async()=>{const a=await this.makeRequest(i);if(a.type==="Fail")throw new Error(a.error||"failed to publish event");return a.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>it*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,t=mn){const n=e.id;this.sendData(e);let s;return Promise.race([new Promise((i,a)=>{s=window.setTimeout(()=>{a(new Error(`request ${n} timed out`))},t)}),new Promise(i=>{this.requestResolutions.set(n,a=>{clearTimeout(s),i(a),this.requestResolutions.delete(n)})})])}async authenticate(){const e={type:"HostSession",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},t=await this.makeRequest(e);if(t.type==="Fail")throw new Error(t.error||"failed to authenticate")}sendIsLinked(){const e={type:"IsLinked",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}sendGetSessionConfig(){const e={type:"GetSessionConfig",id:(0,F.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}}Me.WalletLinkConnection=bn;var Re={};Object.defineProperty(Re,"__esModule",{value:!0});Re.WalletLinkSession=void 0;const yn=or,at=u,ot="session:id",ct="session:secret",dt="session:linked";class ze{constructor(e,t,n,s){this._storage=e,this._id=t||(0,at.randomBytesHex)(16),this._secret=n||(0,at.randomBytesHex)(32),this._key=new yn.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!s}static load(e){const t=e.getItem(ot),n=e.getItem(dt),s=e.getItem(ct);return t&&s?new ze(e,t,s,n==="1"):null}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this._storage.setItem(ot,this._id),this._storage.setItem(ct,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(dt,this._linked?"1":"0")}}Re.WalletLinkSession=ze;var S={};Object.defineProperty(S,"__esModule",{value:!0});S.isDarkMode=S.isMobileWeb=S.getLocation=S.createQrUrl=void 0;function wn(r,e,t,n,s,i){const a=n?"parent-id":"id",o=new URLSearchParams({[a]:r,secret:e,server:t,v:s,chainId:i.toString()}).toString();return`${t}/#/link?${o}`}S.createQrUrl=wn;function vn(){try{return window.frameElement!==null}catch{return!1}}function _n(){try{return vn()&&window.top?window.top.location:window.location}catch{return window.location}}S.getLocation=_n;function En(){var r;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((r=window==null?void 0:window.navigator)===null||r===void 0?void 0:r.userAgent)}S.isMobileWeb=En;function Sn(){var r,e;return(e=(r=window==null?void 0:window.matchMedia)===null||r===void 0?void 0:r.call(window,"(prefers-color-scheme: dark)").matches)!==null&&e!==void 0?e:!1}S.isDarkMode=Sn;var xe={},ae={},Ve={};Object.defineProperty(Ve,"__esModule",{value:!0});Ve.default='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';var Cn=M&&M.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ae,"__esModule",{value:!0});ae.injectCssReset=void 0;const kn=Cn(Ve);function In(){const r=document.createElement("style");r.type="text/css",r.appendChild(document.createTextNode(kn.default)),document.documentElement.appendChild(r)}ae.injectCssReset=In;var Ze={};function Zt(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r))for(e=0;e{this.items.delete(m),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,n.render)((0,n.h)("div",null,(0,n.h)(r.SnackbarContainer,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([p,m])=>(0,n.h)(r.SnackbarInstance,Object.assign({},m,{key:p}))))),this.root)}}r.Snackbar=l;const h=d=>(0,n.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-container")},(0,n.h)("style",null,a.default),(0,n.h)("div",{class:"-cbwsdk-snackbar"},d.children));r.SnackbarContainer=h;const f=({autoExpand:d,message:p,menuItems:m})=>{const[B,tr]=(0,s.useState)(!0),[Oe,Je]=(0,s.useState)(d??!1);(0,s.useEffect)(()=>{const L=[window.setTimeout(()=>{tr(!1)},1),window.setTimeout(()=>{Je(!0)},1e4)];return()=>{L.forEach(window.clearTimeout)}});const rr=()=>{Je(!Oe)};return(0,n.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-instance",B&&"-cbwsdk-snackbar-instance-hidden",Oe&&"-cbwsdk-snackbar-instance-expanded")},(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:rr},(0,n.h)("img",{src:o,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},p),(0,n.h)("div",{class:"-gear-container"},!Oe&&(0,n.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,n.h)("img",{src:c,class:"-gear-icon",title:"Expand"}))),m&&m.length>0&&(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-menu"},m.map((L,nr)=>(0,n.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-instance-menu-item",L.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:L.onClick,key:nr},(0,n.h)("svg",{width:L.svgWidth,height:L.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("path",{"fill-rule":L.defaultFillRule,"clip-rule":L.defaultClipRule,d:L.path,fill:"#AAAAAA"})),(0,n.h)("span",{class:(0,t.default)("-cbwsdk-snackbar-instance-menu-item-info",L.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},L.info)))))};r.SnackbarInstance=f})(Ze);Object.defineProperty(xe,"__esModule",{value:!0});xe.WalletLinkRelayUI=void 0;const Ln=ae,An=Ze;class Rn{constructor(){this.attached=!1,this.snackbar=new An.Snackbar}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,t=document.createElement("div");t.className="-cbwsdk-css-reset",e.appendChild(t),this.snackbar.attach(t),this.attached=!0,(0,Ln.injectCssReset)()}showConnecting(e){let t;return e.isUnlinkedErrorState?t={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:t={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(t)}}xe.WalletLinkRelayUI=Rn;var Pe={},Ne={},Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.default=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";var Yt=M&&M.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.RedirectDialog=void 0;const xn=Yt(Gt),x=_t,Pn=ae,Nn=Ze,Tn=S,jn=Yt(Ye);class On{constructor(){this.root=null,this.darkMode=(0,Tn.isDarkMode)()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),(0,Pn.injectCssReset)()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&((0,x.render)(null,this.root),e&&(0,x.render)((0,x.h)(Dn,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}Ne.RedirectDialog=On;const Dn=({title:r,buttonText:e,darkMode:t,onButtonClick:n,onDismiss:s})=>{const i=t?"dark":"light";return(0,x.h)(Nn.SnackbarContainer,{darkMode:t},(0,x.h)("div",{class:"-cbwsdk-redirect-dialog"},(0,x.h)("style",null,jn.default),(0,x.h)("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:s}),(0,x.h)("div",{class:(0,xn.default)("-cbwsdk-redirect-dialog-box",i)},(0,x.h)("p",null,r),(0,x.h)("button",{onClick:n},e))))};var T={};Object.defineProperty(T,"__esModule",{value:!0});T.CBW_MOBILE_DEEPLINK_URL=T.WALLETLINK_URL=T.CB_KEYS_URL=void 0;T.CB_KEYS_URL="https://keys.coinbase.com/connect";T.WALLETLINK_URL="https://www.walletlink.org";T.CBW_MOBILE_DEEPLINK_URL="https://go.cb-w.com/walletlink";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.WLMobileRelayUI=void 0;const Wn=Ne,Un=S,Bn=T;class Hn{constructor(){this.attached=!1,this.redirectDialog=new Wn.RedirectDialog}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(e){const t=new URL(Bn.CBW_MOBILE_DEEPLINK_URL);t.searchParams.append("redirect_url",(0,Un.getLocation)().href),e&&t.searchParams.append("wl_url",e);const n=document.createElement("a");n.target="cbw-opener",n.href=t.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}Pe.WLMobileRelayUI=Hn;Object.defineProperty(Ie,"__esModule",{value:!0});Ie.WalletLinkRelay=void 0;const Kn=Me,qn=N,$n=ie,He=Re,z=Q,Fn=S,zn=xe,ut=Pe,Vn=j,b=u,Zn=O;class W{constructor(e){this.accountsCallback=null,this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.chainCallback=null,this.dappDefaultChain=1,this.isMobileWeb=(0,Fn.isMobileWeb)(),this.appName="",this.appLogoUrl=null,this.linkedUpdated=i=>{this.isLinked=i;const a=this.storage.getItem(qn.LOCAL_STORAGE_ADDRESSES_KEY);if(i&&(this._session.linked=i),this.isUnlinkedErrorState=!1,a){const o=a.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!i&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(i,a)=>{this.storage.setItem(i,a)},this.chainUpdated=(i,a)=>{this.chainCallbackParams.chainId===i&&this.chainCallbackParams.jsonRpcUrl===a||(this.chainCallbackParams={chainId:i,jsonRpcUrl:a},this.chainCallback&&this.chainCallback(i,a))},this.accountUpdated=i=>{this.accountsCallback&&this.accountsCallback([i]),W.accountRequestCallbackIds.size>0&&(Array.from(W.accountRequestCallbackIds.values()).forEach(a=>{const o={type:"WEB3_RESPONSE",id:a,response:{method:"requestEthereumAccounts",result:[i]}};this.invokeCallback(Object.assign(Object.assign({},o),{id:a}))}),W.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage;const{session:t,ui:n,connection:s}=this.subscribe();this._session=t,this.connection=s,this.relayEventManager=new $n.RelayEventManager,this.ui=n}subscribe(){const e=He.WalletLinkSession.load(this.storage)||new He.WalletLinkSession(this.storage).save(),{linkAPIUrl:t}=this,n=new Kn.WalletLinkConnection({session:e,linkAPIUrl:t,listener:this}),s=this.isMobileWeb?new ut.WLMobileRelayUI:new zn.WalletLinkRelayUI;return n.connect(),{session:e,ui:s,connection:n}}attachUI(){this.ui.attach()}resetAndReload(){Promise.race([this.connection.setSessionMetadata("__destroyed","1"),new Promise(e=>setTimeout(()=>e(null),1e3))]).then(()=>{this.connection.destroy();const e=He.WalletLinkSession.load(this.storage);(e==null?void 0:e.id)===this._session.id&&Zn.ScopedLocalStorage.clearAll(),document.location.reload()}).catch(e=>{})}setAppInfo(e,t){this.appName=e,this.appLogoUrl=t}getStorageItem(e){return this.storage.getItem(e)}setStorageItem(e,t){this.storage.setItem(e,t)}signEthereumMessage(e,t,n,s){return this.sendRequest({method:"signEthereumMessage",params:{message:(0,b.hexStringFromBuffer)(e,!0),address:t,addPrefix:n,typedDataJson:s||null}})}ethereumAddressFromSignedMessage(e,t,n){return this.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:(0,b.hexStringFromBuffer)(e,!0),signature:(0,b.hexStringFromBuffer)(t,!0),addPrefix:n}})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,b.bigIntStringFromBigInt)(e.weiValue),data:(0,b.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,b.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?(0,b.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?(0,b.bigIntStringFromBigInt)(e.gasPriceInWei):null,gasLimit:e.gasLimit?(0,b.bigIntStringFromBigInt)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,b.bigIntStringFromBigInt)(e.weiValue),data:(0,b.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,b.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?(0,b.bigIntStringFromBigInt)(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?(0,b.bigIntStringFromBigInt)(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?(0,b.bigIntStringFromBigInt)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,t){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:(0,b.hexStringFromBuffer)(e,!0),chainId:t}})}scanQRCode(e){return this.sendRequest({method:"scanQRCode",params:{regExp:e}})}getWalletLinkSession(){return this._session}genericRequest(e,t){return this.sendRequest({method:"generic",params:{action:t,data:e}})}sendGenericMessage(e){return this.sendRequest(e)}sendRequest(e){let t=null;const n=(0,b.randomBytesHex)(8),s=i=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,e.method,i),t==null||t()};return new Promise((i,a)=>{t=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:s,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(n,o=>{if(t==null||t(),(0,z.isErrorResponse)(o))return a(new Error(o.errorMessage));i(o)}),this.publishWeb3RequestEvent(n,e)})}setAccountsCallback(e){this.accountsCallback=e}setChainCallback(e){this.chainCallback=e}setDappDefaultChainCallback(e){this.dappDefaultChain=e}publishWeb3RequestEvent(e,t){const n={type:"WEB3_REQUEST",id:e,request:t};this.publishEvent("Web3Request",n,!0).then(s=>{}).catch(s=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:n.id,response:{method:t.method,errorMessage:s.message}})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(t.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof ut.WLMobileRelayUI)switch(e){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(e){const t={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",t,!1).then()}publishEvent(e,t,n){return this.connection.publishEvent(e,t,n)}handleWeb3ResponseMessage(e){const{response:t}=e;if(t.method==="requestEthereumAccounts"){W.accountRequestCallbackIds.forEach(n=>this.invokeCallback(Object.assign(Object.assign({},e),{id:n}))),W.accountRequestCallbackIds.clear();return}this.invokeCallback(e)}handleErrorResponse(e,t,n){var s;const i=(s=n==null?void 0:n.message)!==null&&s!==void 0?s:"Unspecified error message.";this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:e,response:{method:t,errorMessage:i}})}invokeCallback(e){const t=this.relayEventManager.callbacks.get(e.id);t&&(t(e.response),this.relayEventManager.callbacks.delete(e.id))}requestEthereumAccounts(){const e={method:"requestEthereumAccounts",params:{appName:this.appName,appLogoUrl:this.appLogoUrl||null}},t=(0,b.randomBytesHex)(8);return new Promise((n,s)=>{this.relayEventManager.callbacks.set(t,i=>{if((0,z.isErrorResponse)(i))return s(new Error(i.errorMessage));n(i)}),W.accountRequestCallbackIds.add(t),this.publishWeb3RequestEvent(t,e)})}watchAsset(e,t,n,s,i,a){const o={method:"watchAsset",params:{type:e,options:{address:t,symbol:n,decimals:s,image:i},chainId:a}};let c=null;const l=(0,b.randomBytesHex)(8),h=f=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,o.method,f),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((f,d)=>{this.relayEventManager.callbacks.set(l,p=>{if(c==null||c(),(0,z.isErrorResponse)(p))return d(new Error(p.errorMessage));f(p)}),this.publishWeb3RequestEvent(l,o)})}addEthereumChain(e,t,n,s,i,a){const o={method:"addEthereumChain",params:{chainId:e,rpcUrls:t,blockExplorerUrls:s,chainName:i,iconUrls:n,nativeCurrency:a}};let c=null;const l=(0,b.randomBytesHex)(8),h=f=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,o.method,f),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((f,d)=>{this.relayEventManager.callbacks.set(l,p=>{if(c==null||c(),(0,z.isErrorResponse)(p))return d(new Error(p.errorMessage));f(p)}),this.publishWeb3RequestEvent(l,o)})}switchEthereumChain(e,t){const n={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:t})},s=(0,b.randomBytesHex)(8);return new Promise((i,a)=>{this.relayEventManager.callbacks.set(s,o=>{if((0,z.isErrorResponse)(o)&&o.errorCode)return a(Vn.standardErrors.provider.custom({code:o.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if((0,z.isErrorResponse)(o))return a(new Error(o.errorMessage));i(o)}),this.publishWeb3RequestEvent(s,n)})}}Ie.WalletLinkRelay=W;W.accountRequestCallbackIds=new Set;var Gn=M&&M.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ce,"__esModule",{value:!0});Ce.WalletLinkSigner=void 0;const Ke=Gn(on),ht=N,Yn=ie,D=Q,Jn=Ie,gt=T,w=j,g=u,Qn=O,qe="DefaultChainId",pt="DefaultJsonRpcUrl";class Xn{constructor(e){var t,n;this._relay=null,this._addresses=[],this.hasMadeFirstChainChangedEmission=!1;const{appName:s,appLogoUrl:i}=e.metadata;this._appName=s,this._appLogoUrl=i,this._storage=new Qn.ScopedLocalStorage("walletlink",gt.WALLETLINK_URL),this.updateListener=e.updateListener,this._relayEventManager=new Yn.RelayEventManager,this._jsonRpcUrlFromOpts="";const a=this._storage.getItem(ht.LOCAL_STORAGE_ADDRESSES_KEY);if(a){const c=a.split(" ");c[0]!==""&&(this._addresses=c.map(l=>(0,g.ensureAddressString)(l)),(t=this.updateListener)===null||t===void 0||t.onAccountsUpdate({accounts:this._addresses,source:"storage"}))}this._storage.getItem(qe)&&((n=this.updateListener)===null||n===void 0||n.onChainUpdate({chain:{id:this.getChainId(),rpcUrl:this.jsonRpcUrl},source:"storage"}),this.hasMadeFirstChainChangedEmission=!0),this.initializeRelay()}getSession(){const e=this.initializeRelay(),{id:t,secret:n}=e.getWalletLinkSession();return{id:t,secret:n}}async handshake(){return await this.request({method:"eth_requestAccounts"})}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(pt))!==null&&e!==void 0?e:this._jsonRpcUrlFromOpts}set jsonRpcUrl(e){this._storage.setItem(pt,e)}updateProviderInfo(e,t){var n;this.jsonRpcUrl=e;const s=this.getChainId();this._storage.setItem(qe,t.toString(10)),((0,g.ensureIntNumber)(t)!==s||!this.hasMadeFirstChainChangedEmission)&&((n=this.updateListener)===null||n===void 0||n.onChainUpdate({chain:{id:t,rpcUrl:e},source:"wallet"}),this.hasMadeFirstChainChangedEmission=!0)}async watchAsset(e,t,n,s,i,a){const c=await this.initializeRelay().watchAsset(e,t,n,s,i,a==null?void 0:a.toString());return(0,D.isErrorResponse)(c)?!1:!!c.result}async addEthereumChain(e,t,n,s,i,a){var o,c;if((0,g.ensureIntNumber)(e)===this.getChainId())return!1;const l=this.initializeRelay();this._isAuthorized()||await l.requestEthereumAccounts();const h=await l.addEthereumChain(e.toString(),t,i,n,s,a);return(0,D.isErrorResponse)(h)?!1:(((o=h.result)===null||o===void 0?void 0:o.isApproved)===!0&&this.updateProviderInfo(t[0],e),((c=h.result)===null||c===void 0?void 0:c.isApproved)===!0)}async switchEthereumChain(e){const n=await this.initializeRelay().switchEthereumChain(e.toString(10),this.selectedAddress||void 0);if((0,D.isErrorResponse)(n)){if(!n.errorCode)return;throw n.errorCode===w.standardErrorCodes.provider.unsupportedChain?w.standardErrors.provider.unsupportedChain():w.standardErrors.provider.custom({message:n.errorMessage,code:n.errorCode})}const s=n.result;s.isApproved&&s.rpcUrl.length>0&&this.updateProviderInfo(s.rpcUrl,e)}async disconnect(){this._relay&&this._relay.resetAndReload(),this._storage.clear()}async request(e){try{return this._request(e).catch(t=>{throw t})}catch(t){return Promise.reject(t)}}async _request(e){if(!e||typeof e!="object"||Array.isArray(e))throw w.standardErrors.rpc.invalidRequest({message:"Expected a single, non-array, object argument.",data:e});const{method:t,params:n}=e;if(typeof t!="string"||t.length===0)throw w.standardErrors.rpc.invalidRequest({message:"'args.method' must be a non-empty string.",data:e});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw w.standardErrors.rpc.invalidRequest({message:"'args.params' must be an object or array if provided.",data:e});const s=n===void 0?[]:n,i=this._relayEventManager.makeRequestId();return(await this._sendRequestAsync({method:t,params:s,jsonrpc:"2.0",id:i})).result}_setAddresses(e,t){var n;if(!Array.isArray(e))throw new Error("addresses is not an array");const s=e.map(i=>(0,g.ensureAddressString)(i));JSON.stringify(s)!==JSON.stringify(this._addresses)&&(this._addresses=s,(n=this.updateListener)===null||n===void 0||n.onAccountsUpdate({accounts:s,source:"wallet"}),this._storage.setItem(ht.LOCAL_STORAGE_ADDRESSES_KEY,s.join(" ")))}_sendRequestAsync(e){return new Promise((t,n)=>{try{const s=this._handleSynchronousMethods(e);if(s!==void 0)return t({jsonrpc:"2.0",id:e.id,result:s})}catch(s){return n(s)}this._handleAsynchronousMethods(e).then(s=>s&&t(Object.assign(Object.assign({},s),{id:e.id}))).catch(s=>n(s))})}_handleSynchronousMethods(e){const{method:t}=e;switch(t){case"eth_accounts":return this._eth_accounts();case"eth_coinbase":return this._eth_coinbase();case"net_version":return this._net_version();case"eth_chainId":return this._eth_chainId();default:return}}async _handleAsynchronousMethods(e){const{method:t}=e,n=e.params||[];switch(t){case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_sign":return this._eth_sign(n);case"eth_ecRecover":return this._eth_ecRecover(n);case"personal_sign":return this._personal_sign(n);case"personal_ecRecover":return this._personal_ecRecover(n);case"eth_signTransaction":return this._eth_signTransaction(n);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(n);case"eth_sendTransaction":return this._eth_sendTransaction(n);case"eth_signTypedData_v1":return this._eth_signTypedData_v1(n);case"eth_signTypedData_v2":return this._throwUnsupportedMethodError();case"eth_signTypedData_v3":return this._eth_signTypedData_v3(n);case"eth_signTypedData_v4":case"eth_signTypedData":return this._eth_signTypedData_v4(n);case"wallet_addEthereumChain":return this._wallet_addEthereumChain(n);case"wallet_switchEthereumChain":return this._wallet_switchEthereumChain(n);case"wallet_watchAsset":return this._wallet_watchAsset(n);default:return this._throwUnsupportedMethodError()}}_isKnownAddress(e){try{const t=(0,g.ensureAddressString)(e);return this._addresses.map(s=>(0,g.ensureAddressString)(s)).includes(t)}catch{}return!1}_ensureKnownAddress(e){if(!this._isKnownAddress(e))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const t=e.from?(0,g.ensureAddressString)(e.from):this.selectedAddress;if(!t)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(t);const n=e.to?(0,g.ensureAddressString)(e.to):null,s=e.value!=null?(0,g.ensureBigInt)(e.value):BigInt(0),i=e.data?(0,g.ensureBuffer)(e.data):Buffer.alloc(0),a=e.nonce!=null?(0,g.ensureIntNumber)(e.nonce):null,o=e.gasPrice!=null?(0,g.ensureBigInt)(e.gasPrice):null,c=e.maxFeePerGas!=null?(0,g.ensureBigInt)(e.maxFeePerGas):null,l=e.maxPriorityFeePerGas!=null?(0,g.ensureBigInt)(e.maxPriorityFeePerGas):null,h=e.gas!=null?(0,g.ensureBigInt)(e.gas):null,f=e.chainId?(0,g.ensureIntNumber)(e.chainId):this.getChainId();return{fromAddress:t,toAddress:n,weiValue:s,data:i,nonce:a,gasPriceInWei:o,maxFeePerGas:c,maxPriorityFeePerGas:l,gasLimit:h,chainId:f}}_isAuthorized(){return this._addresses.length>0}_requireAuthorization(){if(!this._isAuthorized())throw w.standardErrors.provider.unauthorized({})}_throwUnsupportedMethodError(){throw w.standardErrors.provider.unsupportedMethod({})}async _signEthereumMessage(e,t,n,s){this._ensureKnownAddress(t);try{const a=await this.initializeRelay().signEthereumMessage(e,t,n,s);if((0,D.isErrorResponse)(a))throw new Error(a.errorMessage);return{jsonrpc:"2.0",id:0,result:a.result}}catch(i){throw typeof i.message=="string"&&i.message.match(/(denied|rejected)/i)?w.standardErrors.provider.userRejectedRequest("User denied message signature"):i}}async _ethereumAddressFromSignedMessage(e,t,n){const i=await this.initializeRelay().ethereumAddressFromSignedMessage(e,t,n);if((0,D.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}_eth_accounts(){return[...this._addresses]}_eth_coinbase(){return this.selectedAddress||null}_net_version(){return this.getChainId().toString(10)}_eth_chainId(){return(0,g.hexStringFromIntNumber)(this.getChainId())}getChainId(){const e=this._storage.getItem(qe);if(!e)return(0,g.ensureIntNumber)(1);const t=parseInt(e,10);return(0,g.ensureIntNumber)(t)}async _eth_requestAccounts(){if(this._isAuthorized())return Promise.resolve({jsonrpc:"2.0",id:0,result:this._addresses});let e;try{if(e=await this.initializeRelay().requestEthereumAccounts(),(0,D.isErrorResponse)(e))throw new Error(e.errorMessage)}catch(t){throw typeof t.message=="string"&&t.message.match(/(denied|rejected)/i)?w.standardErrors.provider.userRejectedRequest("User denied account authorization"):t}if(!e.result)throw new Error("accounts received is empty");return this._setAddresses(e.result),{jsonrpc:"2.0",id:0,result:this._addresses}}_eth_sign(e){this._requireAuthorization();const t=(0,g.ensureAddressString)(e[0]),n=(0,g.ensureBuffer)(e[1]);return this._signEthereumMessage(n,t,!1)}_eth_ecRecover(e){const t=(0,g.ensureBuffer)(e[0]),n=(0,g.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(t,n,!1)}_personal_sign(e){this._requireAuthorization();const t=(0,g.ensureBuffer)(e[0]),n=(0,g.ensureAddressString)(e[1]);return this._signEthereumMessage(t,n,!0)}_personal_ecRecover(e){const t=(0,g.ensureBuffer)(e[0]),n=(0,g.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(t,n,!0)}async _eth_signTransaction(e){this._requireAuthorization();const t=this._prepareTransactionParams(e[0]||{});try{const s=await this.initializeRelay().signEthereumTransaction(t);if((0,D.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?w.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_sendRawTransaction(e){const t=(0,g.ensureBuffer)(e[0]),s=await this.initializeRelay().submitEthereumTransaction(t,this.getChainId());if((0,D.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}async _eth_sendTransaction(e){this._requireAuthorization();const t=this._prepareTransactionParams(e[0]||{});try{const s=await this.initializeRelay().signAndSubmitEthereumTransaction(t);if((0,D.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?w.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_signTypedData_v1(e){this._requireAuthorization();const t=(0,g.ensureParsedJSONObject)(e[0]),n=(0,g.ensureAddressString)(e[1]);this._ensureKnownAddress(n);const s=Ke.default.hashForSignTypedDataLegacy({data:t}),i=JSON.stringify(t,null,2);return this._signEthereumMessage(s,n,!1,i)}async _eth_signTypedData_v3(e){this._requireAuthorization();const t=(0,g.ensureAddressString)(e[0]),n=(0,g.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(t);const s=Ke.default.hashForSignTypedData_v3({data:n}),i=JSON.stringify(n,null,2);return this._signEthereumMessage(s,t,!1,i)}async _eth_signTypedData_v4(e){this._requireAuthorization();const t=(0,g.ensureAddressString)(e[0]),n=(0,g.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(t);const s=Ke.default.hashForSignTypedData_v4({data:n}),i=JSON.stringify(n,null,2);return this._signEthereumMessage(s,t,!1,i)}async _wallet_addEthereumChain(e){var t,n,s,i;const a=e[0];if(((t=a.rpcUrls)===null||t===void 0?void 0:t.length)===0)return{jsonrpc:"2.0",id:0,error:{code:2,message:"please pass in at least 1 rpcUrl"}};if(!a.chainName||a.chainName.trim()==="")throw w.standardErrors.rpc.invalidParams("chainName is a required field");if(!a.nativeCurrency)throw w.standardErrors.rpc.invalidParams("nativeCurrency is a required field");const o=parseInt(a.chainId,16);return await this.addEthereumChain(o,(n=a.rpcUrls)!==null&&n!==void 0?n:[],(s=a.blockExplorerUrls)!==null&&s!==void 0?s:[],a.chainName,(i=a.iconUrls)!==null&&i!==void 0?i:[],a.nativeCurrency)?{jsonrpc:"2.0",id:0,result:null}:{jsonrpc:"2.0",id:0,error:{code:2,message:"unable to add ethereum chain"}}}async _wallet_switchEthereumChain(e){const t=e[0];return await this.switchEthereumChain(parseInt(t.chainId,16)),{jsonrpc:"2.0",id:0,result:null}}async _wallet_watchAsset(e){const t=Array.isArray(e)?e[0]:e;if(!t.type)throw w.standardErrors.rpc.invalidParams("Type is required");if((t==null?void 0:t.type)!=="ERC20")throw w.standardErrors.rpc.invalidParams(`Asset of type '${t.type}' is not supported`);if(!(t!=null&&t.options))throw w.standardErrors.rpc.invalidParams("Options are required");if(!(t!=null&&t.options.address))throw w.standardErrors.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:s,symbol:i,image:a,decimals:o}=t.options;return{jsonrpc:"2.0",id:0,result:await this.watchAsset(t.type,s,i,o,a,n)}}initializeRelay(){if(!this._relay){const e=new Jn.WalletLinkRelay({linkAPIUrl:gt.WALLETLINK_URL,storage:this._storage});e.setAppInfo(this._appName,this._appLogoUrl),e.attachUI(),e.setAccountsCallback((t,n)=>this._setAddresses(t,n)),e.setChainCallback((t,n)=>{this.updateProviderInfo(n,parseInt(t,10))}),this._relay=e}return this._relay}}Ce.WalletLinkSigner=Xn;var k={};Object.defineProperty(k,"__esModule",{value:!0});k.checkErrorForInvalidRequestArgs=k.getCoinbaseInjectedProvider=k.getCoinbaseInjectedSigner=k.fetchRPCRequest=void 0;const es=K,pe=j;async function ts(r,e){if(!e.rpcUrl)throw pe.standardErrors.rpc.internal("No RPC URL set for chain");const t=Object.assign(Object.assign({},r),{jsonrpc:"2.0",id:crypto.randomUUID()});return(await(await window.fetch(e.rpcUrl,{method:"POST",body:JSON.stringify(t),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":es.LIB_VERSION}})).json()).result}k.fetchRPCRequest=ts;function Jt(){return globalThis.coinbaseWalletSigner}k.getCoinbaseInjectedSigner=Jt;function rs(){return globalThis.coinbaseWalletExtension}function ns(){var r,e;try{const t=globalThis;return(r=t.ethereum)!==null&&r!==void 0?r:(e=t.top)===null||e===void 0?void 0:e.ethereum}catch{return}}function ss({metadata:r,preference:e}){var t;if(e.options!=="smartWalletOnly"){if(Jt())return;const i=rs();if(i){const{appName:a,appLogoUrl:o,appChainIds:c}=r;return(t=i.setAppInfo)===null||t===void 0||t.call(i,a,o,c),i}}const n=ns();if(n!=null&&n.isCoinbaseBrowser)return n}k.getCoinbaseInjectedProvider=ss;function is(r){if(!r||typeof r!="object"||Array.isArray(r))return pe.standardErrors.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:r});const{method:e,params:t}=r;if(typeof e!="string"||e.length===0)return pe.standardErrors.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:r});if(t!==void 0&&!Array.isArray(t)&&(typeof t!="object"||t===null))return pe.standardErrors.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:r})}k.checkErrorForInvalidRequestArgs=is;Object.defineProperty(P,"__esModule",{value:!0});P.createSigner=P.fetchSignerType=P.storeSignerType=P.loadSignerType=void 0;const as=_e,Qt=Ce,os=j,cs=k,ds=O,Xt="SignerType",er=new ds.ScopedLocalStorage("CBWSDK","SignerConfigurator");function ls(){return er.getItem(Xt)}P.loadSignerType=ls;function us(r){er.setItem(Xt,r)}P.storeSignerType=us;async function hs(r){const{communicator:e,metadata:t}=r;ps(e,t).catch(()=>{});const n={id:crypto.randomUUID(),event:"selectSignerType",data:r.preference},{data:s}=await e.postRequestAndWaitForResponse(n);return s}P.fetchSignerType=hs;function gs(r){const{signerType:e,metadata:t,communicator:n,updateListener:s}=r;switch(e){case"scw":return new as.SCWSigner({metadata:t,updateListener:s,communicator:n});case"walletlink":return new Qt.WalletLinkSigner({metadata:t,updateListener:s});case"extension":{const i=(0,cs.getCoinbaseInjectedSigner)();if(!i)throw os.standardErrors.rpc.internal("injected signer not found");return i}}}P.createSigner=gs;async function ps(r,e){await r.onMessage(({event:n})=>n==="WalletLinkSessionRequest");const t=new Qt.WalletLinkSigner({metadata:e});r.postMessage({event:"WalletLinkUpdate",data:{session:t.getSession()}}),await t.handshake(),r.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var Te={},J={};Object.defineProperty(J,"__esModule",{value:!0});J.closePopup=J.openPopup=void 0;const fs=j,ft=420,mt=540;function ms(r){const e=(window.innerWidth-ft)/2+window.screenX,t=(window.innerHeight-mt)/2+window.screenY,n=window.open(r,"Smart Wallet",`width=${ft}, height=${mt}, left=${e}, top=${t}`);if(n==null||n.focus(),!n)throw fs.standardErrors.rpc.internal("Pop up window failed to open");return n}J.openPopup=ms;function bs(r){r&&!r.closed&&r.close()}J.closePopup=bs;Object.defineProperty(Te,"__esModule",{value:!0});Te.Communicator=void 0;const ys=K,bt=J,ws=T,yt=j;class vs{constructor(e=ws.CB_KEYS_URL){this.popup=null,this.listeners=new Map,this.postMessage=async t=>{(await this.waitForPopupLoaded()).postMessage(t,this.url.origin)},this.postRequestAndWaitForResponse=async t=>{const n=this.onMessage(({requestId:s})=>s===t.id);return this.postMessage(t),await n},this.onMessage=async t=>new Promise((n,s)=>{const i=a=>{if(a.origin!==this.url.origin)return;const o=a.data;t(o)&&(n(o),window.removeEventListener("message",i),this.listeners.delete(i))};window.addEventListener("message",i),this.listeners.set(i,{reject:s})}),this.disconnect=()=>{(0,bt.closePopup)(this.popup),this.popup=null,this.listeners.forEach(({reject:t},n)=>{t(yt.standardErrors.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",n)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=(0,bt.openPopup)(this.url),this.onMessage(({event:t})=>t==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:t})=>t==="PopupLoaded").then(t=>{this.postMessage({requestId:t.id,data:{version:ys.LIB_VERSION}})}).then(()=>{if(!this.popup)throw yt.standardErrors.rpc.internal();return this.popup})),this.url=new URL(e)}}Te.Communicator=vs;var je={};Object.defineProperty(je,"__esModule",{value:!0});je.determineMethodCategory=void 0;const wt={handshake:["eth_requestAccounts"],sign:["eth_ecRecover","personal_sign","personal_ecRecover","eth_signTransaction","eth_sendTransaction","eth_signTypedData_v1","eth_signTypedData_v3","eth_signTypedData_v4","eth_signTypedData","wallet_addEthereumChain","wallet_switchEthereumChain","wallet_watchAsset","wallet_getCapabilities","wallet_sendCalls","wallet_showCallsStatus"],state:["eth_chainId","eth_accounts","eth_coinbase","net_version"],deprecated:["eth_sign","eth_signTypedData_v2"],unsupported:["eth_subscribe","eth_unsubscribe"],fetch:[]};function _s(r){for(const e in wt){const t=e;if(wt[t].includes(r))return t}}je.determineMethodCategory=_s;var Es=M&&M.__rest||function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s{try{if(this.connected)return this.emit("connect",{chainId:(0,X.hexStringFromIntNumber)((0,he.IntNumber)(this.chain.id))}),this.accounts;const h=await this.requestSignerSelection(),f=this.initSigner(h),d=await f.handshake();return this.signer=f,(0,ge.storeSignerType)(h),this.emit("connect",{chainId:(0,X.hexStringFromIntNumber)((0,he.IntNumber)(this.chain.id))}),d}catch(h){throw this.handleUnauthorizedError(h),h}},sign:async l=>{if(!this.connected||!this.signer)throw V.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");try{return await this.signer.request(l)}catch(h){throw this.handleUnauthorizedError(h),h}},fetch:l=>(0,vt.fetchRPCRequest)(l,this.chain),state:l=>{const h=()=>{if(this.connected)return this.accounts;throw V.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")};switch(l.method){case"eth_chainId":return(0,X.hexStringFromIntNumber)((0,he.IntNumber)(this.chain.id));case"net_version":return this.chain.id;case"eth_accounts":return h();case"eth_coinbase":return h()[0];default:return this.handlers.unsupported(l)}},deprecated:({method:l})=>{throw V.standardErrors.rpc.methodNotSupported(`Method ${l} is deprecated.`)},unsupported:({method:l})=>{throw V.standardErrors.rpc.methodNotSupported(`Method ${l} is not supported.`)}},this.isCoinbaseWallet=!0,this.updateListener={onAccountsUpdate:({accounts:l,source:h})=>{(0,X.areAddressArraysEqual)(this.accounts,l)||(this.accounts=l,h!=="storage"&&this.emit("accountsChanged",this.accounts))},onChainUpdate:({chain:l,source:h})=>{l.id===this.chain.id&&l.rpcUrl===this.chain.rpcUrl||(this.chain=l,h!=="storage"&&this.emit("chainChanged",(0,X.hexStringFromIntNumber)((0,he.IntNumber)(l.id))))}},this.metadata=s,this.preference=o,this.communicator=new Is.Communicator(a),this.chain={id:(n=(t=s.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1};const c=(0,ge.loadSignerType)();this.signer=c?this.initSigner(c):null}get connected(){return this.accounts.length>0}async request(e){var t;try{const n=(0,vt.checkErrorForInvalidRequestArgs)(e);if(n)throw n;const s=(t=(0,Ms.determineMethodCategory)(e.method))!==null&&t!==void 0?t:"fetch";return this.handlers[s](e)}catch(n){return Promise.reject((0,ks.serializeError)(n,e.method))}}handleUnauthorizedError(e){e.code===V.standardErrorCodes.provider.unauthorized&&this.disconnect()}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),await this.request({method:"eth_requestAccounts"})}async disconnect(){this.accounts=[],this.chain={id:1},Ls.ScopedLocalStorage.clearAll(),this.emit("disconnect",V.standardErrors.provider.disconnected("User initiated disconnection"))}requestSignerSelection(){return(0,ge.fetchSignerType)({communicator:this.communicator,preference:this.preference,metadata:this.metadata})}initSigner(e){return(0,ge.createSigner)({signerType:e,metadata:this.metadata,communicator:this.communicator,updateListener:this.updateListener})}}be.CoinbaseWalletProvider=As;Object.defineProperty(te,"__esModule",{value:!0});te.CoinbaseWalletSDK=void 0;const Rs=me,xs=be,Ps=O,Ns=K,Ts=u,js=k;class Os{constructor(e){this.metadata={appName:e.appName||"Dapp",appLogoUrl:e.appLogoUrl||(0,Ts.getFavicon)(),appChainIds:e.appChainIds||[]},this.storeLatestVersion()}makeWeb3Provider(e={options:"all"}){var t;const n={metadata:this.metadata,preference:e};return(t=(0,js.getCoinbaseInjectedProvider)(n))!==null&&t!==void 0?t:new xs.CoinbaseWalletProvider(n)}getCoinbaseWalletLogo(e,t=240){return(0,Rs.walletLogo)(e,t)}storeLatestVersion(){new Ps.ScopedLocalStorage("CBWSDK").setItem("VERSION",Ns.LIB_VERSION)}}te.CoinbaseWalletSDK=Os;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.CoinbaseWalletSDK=void 0;const e=te;r.default=e.CoinbaseWalletSDK;var t=te;Object.defineProperty(r,"CoinbaseWalletSDK",{enumerable:!0,get:function(){return t.CoinbaseWalletSDK}})})(Et);const Ds=ir(Et),Bs=Object.freeze(Object.defineProperty({__proto__:null,default:Ds},Symbol.toStringTag,{value:"Module"}));export{Bs as i}; diff --git a/buddybook/assets/index-iQrFj71y.js b/buddybook/assets/index-D6T2G_iY.js similarity index 65% rename from buddybook/assets/index-iQrFj71y.js rename to buddybook/assets/index-D6T2G_iY.js index d6f8de6..9eaaa89 100644 --- a/buddybook/assets/index-iQrFj71y.js +++ b/buddybook/assets/index-D6T2G_iY.js @@ -1,30 +1,30 @@ -import{T as $t,M as oe,R as N,E as k,C as $,a as X,b as Br,O as Z,c as ht}from"./index-Vk_Kr0Nw.js";import{C as Wr}from"./index-CLqSQ1yP.js";class Ur{setAnimation(t){this.animation=t,t==null||t.finished.then(()=>this.clearAnimation()).catch(()=>{})}clearAnimation(){this.animation=this.generator=void 0}}function jr(e,t){e.indexOf(t)===-1&&e.push(t)}const Jo=(e,t,o)=>Math.min(Math.max(o,e),t),V={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},ne=e=>typeof e=="number",bt=e=>Array.isArray(e)&&!ne(e[0]),kr=(e,t,o)=>{const n=t-e;return((o-e)%n+n)%n+e};function Hr(e,t){return bt(e)?e[kr(0,e.length,t)]:e}const Qo=(e,t,o)=>-o*e+o*t+e,Xo=()=>{},et=e=>e,mo=(e,t,o)=>t-e===0?1:(o-e)/(t-e);function tr(e,t){const o=e[e.length-1];for(let n=1;n<=t;n++){const r=mo(0,t,n);e.push(Qo(o,1,r))}}function zr(e){const t=[0];return tr(t,e-1),t}function Fr(e,t=zr(e.length),o=et){const n=e.length,r=n-t.length;return r>0&&tr(t,r),i=>{let s=0;for(;sArray.isArray(e)&&ne(e[0]),ke=e=>typeof e=="object"&&!!e.createAnimation,xt=e=>typeof e=="function",Vr=e=>typeof e=="string",Nt={ms:e=>e*1e3,s:e=>e/1e3},or=(e,t,o)=>(((1-3*o+3*t)*e+(3*o-6*t))*e+3*t)*e,Zr=1e-7,Kr=12;function qr(e,t,o,n,r){let i,s,l=0;do s=t+(o-t)/2,i=or(s,n,r)-e,i>0?o=s:t=s;while(Math.abs(i)>Zr&&++lqr(i,0,1,e,o);return i=>i===0||i===1?i:or(r(i),t,n)}const Yr=(e,t="end")=>o=>{o=t==="end"?Math.min(o,.999):Math.max(o,.001);const n=o*e,r=t==="end"?Math.floor(n):Math.ceil(n);return Jo(0,1,r/e)},Gr={ease:Lt(.25,.1,.25,1),"ease-in":Lt(.42,0,1,1),"ease-in-out":Lt(.42,0,.58,1),"ease-out":Lt(0,0,.58,1)},Jr=/\((.*?)\)/;function Ao(e){if(xt(e))return e;if(er(e))return Lt(...e);const t=Gr[e];if(t)return t;if(e.startsWith("steps")){const o=Jr.exec(e);if(o){const n=o[1].split(",");return Yr(parseFloat(n[0]),n[1].trim())}}return et}class rr{constructor(t,o=[0,1],{easing:n,duration:r=V.duration,delay:i=V.delay,endDelay:s=V.endDelay,repeat:l=V.repeat,offset:a,direction:c="normal",autoplay:d=!0}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=et,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise((h,p)=>{this.resolve=h,this.reject=p}),n=n||V.easing,ke(n)){const h=n.createAnimation(o);n=h.easing,o=h.keyframes||o,r=h.duration||r}this.repeat=l,this.easing=bt(n)?et:Ao(n),this.updateDuration(r);const y=Fr(o,a,bt(n)?n.map(Ao):et);this.tick=h=>{var p;i=i;let g=0;this.pauseTime!==void 0?g=this.pauseTime:g=(h-this.startTime)*this.rate,this.t=g,g/=1e3,g=Math.max(g-i,0),this.playState==="finished"&&this.pauseTime===void 0&&(g=this.totalDuration);const f=g/this.duration;let O=Math.floor(f),m=f%1;!m&&f>=1&&(m=1),m===1&&O--;const b=O%2;(c==="reverse"||c==="alternate"&&b||c==="alternate-reverse"&&!b)&&(m=1-m);const w=g>=this.totalDuration?1:Math.min(m,1),v=y(this.easing(w));t(v),this.pauseTime===void 0&&(this.playState==="finished"||g>=this.totalDuration+s)?(this.playState="finished",(p=this.resolve)===null||p===void 0||p.call(this,v)):this.playState!=="idle"&&(this.frameRequestId=requestAnimationFrame(this.tick))},d&&this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime!==void 0?this.startTime=t-this.pauseTime:this.startTime||(this.startTime=t),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",this.frameRequestId!==void 0&&cancelAnimationFrame(this.frameRequestId),(t=this.reject)===null||t===void 0||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(t){this.duration=t,this.totalDuration=t*(this.repeat+1)}get currentTime(){return this.t}set currentTime(t){this.pauseTime!==void 0||this.rate===0?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}/** +import{T as $t,M as re,R as N,E as k,C as $,a as X,b as Bo,O as Z,c as ht}from"./index-1C-dIFy4.js";import{C as Wo}from"./index-mI-wCQlz.js";class Uo{setAnimation(t){this.animation=t,t==null||t.finished.then(()=>this.clearAnimation()).catch(()=>{})}clearAnimation(){this.animation=this.generator=void 0}}function jo(e,t){e.indexOf(t)===-1&&e.push(t)}const Gr=(e,t,r)=>Math.min(Math.max(r,e),t),V={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},ne=e=>typeof e=="number",bt=e=>Array.isArray(e)&&!ne(e[0]),ko=(e,t,r)=>{const n=t-e;return((r-e)%n+n)%n+e};function Ho(e,t){return bt(e)?e[ko(0,e.length,t)]:e}const Jr=(e,t,r)=>-r*e+r*t+e,Qr=()=>{},et=e=>e,ur=(e,t,r)=>t-e===0?1:(r-e)/(t-e);function Xr(e,t){const r=e[e.length-1];for(let n=1;n<=t;n++){const o=ur(0,t,n);e.push(Jr(r,1,o))}}function zo(e){const t=[0];return Xr(t,e-1),t}function Fo(e,t=zo(e.length),r=et){const n=e.length,o=n-t.length;return o>0&&Xr(t,o),i=>{let s=0;for(;sArray.isArray(e)&&ne(e[0]),ke=e=>typeof e=="object"&&!!e.createAnimation,xt=e=>typeof e=="function",Vo=e=>typeof e=="string",Nt={ms:e=>e*1e3,s:e=>e/1e3},eo=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e,Zo=1e-7,Ko=12;function qo(e,t,r,n,o){let i,s,l=0;do s=t+(r-t)/2,i=eo(s,n,o)-e,i>0?r=s:t=s;while(Math.abs(i)>Zo&&++lqo(i,0,1,e,r);return i=>i===0||i===1?i:eo(o(i),t,n)}const Yo=(e,t="end")=>r=>{r=t==="end"?Math.min(r,.999):Math.max(r,.001);const n=r*e,o=t==="end"?Math.floor(n):Math.ceil(n);return Gr(0,1,o/e)},Go={ease:Lt(.25,.1,.25,1),"ease-in":Lt(.42,0,1,1),"ease-in-out":Lt(.42,0,.58,1),"ease-out":Lt(0,0,.58,1)},Jo=/\((.*?)\)/;function Er(e){if(xt(e))return e;if(to(e))return Lt(...e);const t=Go[e];if(t)return t;if(e.startsWith("steps")){const r=Jo.exec(e);if(r){const n=r[1].split(",");return Yo(parseFloat(n[0]),n[1].trim())}}return et}class ro{constructor(t,r=[0,1],{easing:n,duration:o=V.duration,delay:i=V.delay,endDelay:s=V.endDelay,repeat:l=V.repeat,offset:a,direction:c="normal",autoplay:d=!0}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=et,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise((h,p)=>{this.resolve=h,this.reject=p}),n=n||V.easing,ke(n)){const h=n.createAnimation(r);n=h.easing,r=h.keyframes||r,o=h.duration||o}this.repeat=l,this.easing=bt(n)?et:Er(n),this.updateDuration(o);const y=Fo(r,a,bt(n)?n.map(Er):et);this.tick=h=>{var p;i=i;let g=0;this.pauseTime!==void 0?g=this.pauseTime:g=(h-this.startTime)*this.rate,this.t=g,g/=1e3,g=Math.max(g-i,0),this.playState==="finished"&&this.pauseTime===void 0&&(g=this.totalDuration);const f=g/this.duration;let O=Math.floor(f),m=f%1;!m&&f>=1&&(m=1),m===1&&O--;const b=O%2;(c==="reverse"||c==="alternate"&&b||c==="alternate-reverse"&&!b)&&(m=1-m);const w=g>=this.totalDuration?1:Math.min(m,1),v=y(this.easing(w));t(v),this.pauseTime===void 0&&(this.playState==="finished"||g>=this.totalDuration+s)?(this.playState="finished",(p=this.resolve)===null||p===void 0||p.call(this,v)):this.playState!=="idle"&&(this.frameRequestId=requestAnimationFrame(this.tick))},d&&this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime!==void 0?this.startTime=t-this.pauseTime:this.startTime||(this.startTime=t),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",this.frameRequestId!==void 0&&cancelAnimationFrame(this.frameRequestId),(t=this.reject)===null||t===void 0||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(t){this.duration=t,this.totalDuration=t*(this.repeat+1)}get currentTime(){return this.t}set currentTime(t){this.pauseTime!==void 0||this.rate===0?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */const re=window,fo=re.ShadowRoot&&(re.ShadyCSS===void 0||re.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,po=Symbol(),Oo=new WeakMap;let nr=class{constructor(t,o,n){if(this._$cssResult$=!0,n!==po)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=o}get styleSheet(){let t=this.o;const o=this.t;if(fo&&t===void 0){const n=o!==void 0&&o.length===1;n&&(t=Oo.get(o)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&Oo.set(o,t))}return t}toString(){return this.cssText}};const Qr=e=>new nr(typeof e=="string"?e:e+"",void 0,po),I=(e,...t)=>{const o=e.length===1?e[0]:t.reduce((n,r,i)=>n+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+e[i+1],e[0]);return new nr(o,e,po)},Xr=(e,t)=>{fo?e.adoptedStyleSheets=t.map(o=>o instanceof CSSStyleSheet?o:o.styleSheet):t.forEach(o=>{const n=document.createElement("style"),r=re.litNonce;r!==void 0&&n.setAttribute("nonce",r),n.textContent=o.cssText,e.appendChild(n)})},Po=fo?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let o="";for(const n of t.cssRules)o+=n.cssText;return Qr(o)})(e):e;/** + */const oe=window,mr=oe.ShadowRoot&&(oe.ShadyCSS===void 0||oe.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,fr=Symbol(),Ar=new WeakMap;let oo=class{constructor(t,r,n){if(this._$cssResult$=!0,n!==fr)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=r}get styleSheet(){let t=this.o;const r=this.t;if(mr&&t===void 0){const n=r!==void 0&&r.length===1;n&&(t=Ar.get(r)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&Ar.set(r,t))}return t}toString(){return this.cssText}};const Qo=e=>new oo(typeof e=="string"?e:e+"",void 0,fr),I=(e,...t)=>{const r=e.length===1?e[0]:t.reduce((n,o,i)=>n+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+e[i+1],e[0]);return new oo(r,e,fr)},Xo=(e,t)=>{mr?e.adoptedStyleSheets=t.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet):t.forEach(r=>{const n=document.createElement("style"),o=oe.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=r.cssText,e.appendChild(n)})},Or=mr?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let r="";for(const n of t.cssRules)r+=n.cssText;return Qo(r)})(e):e;/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */var _e;const ie=window,Io=ie.trustedTypes,tn=Io?Io.emptyScript:"",To=ie.reactiveElementPolyfillSupport,He={toAttribute(e,t){switch(t){case Boolean:e=e?tn:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let o=e;switch(t){case Boolean:o=e!==null;break;case Number:o=e===null?null:Number(e);break;case Object:case Array:try{o=JSON.parse(e)}catch{o=null}}return o}},ir=(e,t)=>t!==e&&(t==t||e==e),Ce={attribute:!0,type:String,converter:He,reflect:!1,hasChanged:ir},ze="finalized";let wt=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var o;this.finalize(),((o=this.h)!==null&&o!==void 0?o:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach((o,n)=>{const r=this._$Ep(n,o);r!==void 0&&(this._$Ev.set(r,n),t.push(r))}),t}static createProperty(t,o=Ce){if(o.state&&(o.attribute=!1),this.finalize(),this.elementProperties.set(t,o),!o.noAccessor&&!this.prototype.hasOwnProperty(t)){const n=typeof t=="symbol"?Symbol():"__"+t,r=this.getPropertyDescriptor(t,n,o);r!==void 0&&Object.defineProperty(this.prototype,t,r)}}static getPropertyDescriptor(t,o,n){return{get(){return this[o]},set(r){const i=this[t];this[o]=r,this.requestUpdate(t,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Ce}static finalize(){if(this.hasOwnProperty(ze))return!1;this[ze]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const o=this.properties,n=[...Object.getOwnPropertyNames(o),...Object.getOwnPropertySymbols(o)];for(const r of n)this.createProperty(r,o[r])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const o=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const r of n)o.unshift(Po(r))}else t!==void 0&&o.push(Po(t));return o}static _$Ep(t,o){const n=o.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(o=>this.enableUpdating=o),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(o=>o(this))}addController(t){var o,n;((o=this._$ES)!==null&&o!==void 0?o:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)===null||n===void 0||n.call(t))}removeController(t){var o;(o=this._$ES)===null||o===void 0||o.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,o)=>{this.hasOwnProperty(o)&&(this._$Ei.set(o,this[o]),delete this[o])})}createRenderRoot(){var t;const o=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Xr(o,this.constructor.elementStyles),o}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(o=>{var n;return(n=o.hostConnected)===null||n===void 0?void 0:n.call(o)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(o=>{var n;return(n=o.hostDisconnected)===null||n===void 0?void 0:n.call(o)})}attributeChangedCallback(t,o,n){this._$AK(t,n)}_$EO(t,o,n=Ce){var r;const i=this.constructor._$Ep(t,n);if(i!==void 0&&n.reflect===!0){const s=(((r=n.converter)===null||r===void 0?void 0:r.toAttribute)!==void 0?n.converter:He).toAttribute(o,n.type);this._$El=t,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$El=null}}_$AK(t,o){var n;const r=this.constructor,i=r._$Ev.get(t);if(i!==void 0&&this._$El!==i){const s=r.getPropertyOptions(i),l=typeof s.converter=="function"?{fromAttribute:s.converter}:((n=s.converter)===null||n===void 0?void 0:n.fromAttribute)!==void 0?s.converter:He;this._$El=i,this[i]=l.fromAttribute(o,s.type),this._$El=null}}requestUpdate(t,o,n){let r=!0;t!==void 0&&(((n=n||this.constructor.getPropertyOptions(t)).hasChanged||ir)(this[t],o)?(this._$AL.has(t)||this._$AL.set(t,o),n.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,n))):r=!1),!this.isUpdatePending&&r&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(o){Promise.reject(o)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((r,i)=>this[i]=r),this._$Ei=void 0);let o=!1;const n=this._$AL;try{o=this.shouldUpdate(n),o?(this.willUpdate(n),(t=this._$ES)===null||t===void 0||t.forEach(r=>{var i;return(i=r.hostUpdate)===null||i===void 0?void 0:i.call(r)}),this.update(n)):this._$Ek()}catch(r){throw o=!1,this._$Ek(),r}o&&this._$AE(n)}willUpdate(t){}_$AE(t){var o;(o=this._$ES)===null||o===void 0||o.forEach(n=>{var r;return(r=n.hostUpdated)===null||r===void 0?void 0:r.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((o,n)=>this._$EO(n,this[n],o)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};wt[ze]=!0,wt.elementProperties=new Map,wt.elementStyles=[],wt.shadowRootOptions={mode:"open"},To==null||To({ReactiveElement:wt}),((_e=ie.reactiveElementVersions)!==null&&_e!==void 0?_e:ie.reactiveElementVersions=[]).push("1.6.3");/** + */var _e;const ie=window,Pr=ie.trustedTypes,tn=Pr?Pr.emptyScript:"",Ir=ie.reactiveElementPolyfillSupport,He={toAttribute(e,t){switch(t){case Boolean:e=e?tn:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=e!==null;break;case Number:r=e===null?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch{r=null}}return r}},no=(e,t)=>t!==e&&(t==t||e==e),Ce={attribute:!0,type:String,converter:He,reflect:!1,hasChanged:no},ze="finalized";let wt=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var r;this.finalize(),((r=this.h)!==null&&r!==void 0?r:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach((r,n)=>{const o=this._$Ep(n,r);o!==void 0&&(this._$Ev.set(o,n),t.push(o))}),t}static createProperty(t,r=Ce){if(r.state&&(r.attribute=!1),this.finalize(),this.elementProperties.set(t,r),!r.noAccessor&&!this.prototype.hasOwnProperty(t)){const n=typeof t=="symbol"?Symbol():"__"+t,o=this.getPropertyDescriptor(t,n,r);o!==void 0&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,r,n){return{get(){return this[r]},set(o){const i=this[t];this[r]=o,this.requestUpdate(t,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Ce}static finalize(){if(this.hasOwnProperty(ze))return!1;this[ze]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const r=this.properties,n=[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)];for(const o of n)this.createProperty(o,r[o])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const r=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const o of n)r.unshift(Or(o))}else t!==void 0&&r.push(Or(t));return r}static _$Ep(t,r){const n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(r=>r(this))}addController(t){var r,n;((r=this._$ES)!==null&&r!==void 0?r:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)===null||n===void 0||n.call(t))}removeController(t){var r;(r=this._$ES)===null||r===void 0||r.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,r)=>{this.hasOwnProperty(r)&&(this._$Ei.set(r,this[r]),delete this[r])})}createRenderRoot(){var t;const r=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Xo(r,this.constructor.elementStyles),r}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostConnected)===null||n===void 0?void 0:n.call(r)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostDisconnected)===null||n===void 0?void 0:n.call(r)})}attributeChangedCallback(t,r,n){this._$AK(t,n)}_$EO(t,r,n=Ce){var o;const i=this.constructor._$Ep(t,n);if(i!==void 0&&n.reflect===!0){const s=(((o=n.converter)===null||o===void 0?void 0:o.toAttribute)!==void 0?n.converter:He).toAttribute(r,n.type);this._$El=t,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$El=null}}_$AK(t,r){var n;const o=this.constructor,i=o._$Ev.get(t);if(i!==void 0&&this._$El!==i){const s=o.getPropertyOptions(i),l=typeof s.converter=="function"?{fromAttribute:s.converter}:((n=s.converter)===null||n===void 0?void 0:n.fromAttribute)!==void 0?s.converter:He;this._$El=i,this[i]=l.fromAttribute(r,s.type),this._$El=null}}requestUpdate(t,r,n){let o=!0;t!==void 0&&(((n=n||this.constructor.getPropertyOptions(t)).hasChanged||no)(this[t],r)?(this._$AL.has(t)||this._$AL.set(t,r),n.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,n))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(r){Promise.reject(r)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((o,i)=>this[i]=o),this._$Ei=void 0);let r=!1;const n=this._$AL;try{r=this.shouldUpdate(n),r?(this.willUpdate(n),(t=this._$ES)===null||t===void 0||t.forEach(o=>{var i;return(i=o.hostUpdate)===null||i===void 0?void 0:i.call(o)}),this.update(n)):this._$Ek()}catch(o){throw r=!1,this._$Ek(),o}r&&this._$AE(n)}willUpdate(t){}_$AE(t){var r;(r=this._$ES)===null||r===void 0||r.forEach(n=>{var o;return(o=n.hostUpdated)===null||o===void 0?void 0:o.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((r,n)=>this._$EO(n,this[n],r)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};wt[ze]=!0,wt.elementProperties=new Map,wt.elementStyles=[],wt.shadowRootOptions={mode:"open"},Ir==null||Ir({ReactiveElement:wt}),((_e=ie.reactiveElementVersions)!==null&&_e!==void 0?_e:ie.reactiveElementVersions=[]).push("1.6.3");/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */var Ee;const se=window,_t=se.trustedTypes,Mo=_t?_t.createPolicy("lit-html",{createHTML:e=>e}):void 0,Fe="$lit$",Q=`lit$${(Math.random()+"").slice(9)}$`,sr="?"+Q,en=`<${sr}>`,ut=document,Wt=()=>ut.createComment(""),Ut=e=>e===null||typeof e!="object"&&typeof e!="function",lr=Array.isArray,on=e=>lr(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ae=`[ -\f\r]`,Dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,So=/-->/g,Ro=/>/g,at=RegExp(`>|${Ae}(?:([^\\s"'>=/]+)(${Ae}*=${Ae}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),Do=/'/g,Lo=/"/g,ar=/^(?:script|style|textarea|title)$/i,cr=e=>(t,...o)=>({_$litType$:e,strings:t,values:o}),u=cr(1),L=cr(2),mt=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),No=new WeakMap,ct=ut.createTreeWalker(ut,129,null,!1);function dr(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Mo!==void 0?Mo.createHTML(t):t}const rn=(e,t)=>{const o=e.length-1,n=[];let r,i=t===2?"":"",s=Dt;for(let l=0;l"?(s=r??Dt,y=-1):d[1]===void 0?y=-2:(y=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?at:d[3]==='"'?Lo:Do):s===Lo||s===Do?s=at:s===So||s===Ro?s=Dt:(s=at,r=void 0);const p=s===at&&e[l+1].startsWith("/>")?" ":"";i+=s===Dt?a+en:y>=0?(n.push(c),a.slice(0,y)+Fe+a.slice(y)+Q+p):a+Q+(y===-2?(n.push(void 0),l):p)}return[dr(e,i+(e[o]||"")+(t===2?"":"")),n]};class jt{constructor({strings:t,_$litType$:o},n){let r;this.parts=[];let i=0,s=0;const l=t.length-1,a=this.parts,[c,d]=rn(t,o);if(this.el=jt.createElement(c,n),ct.currentNode=this.el.content,o===2){const y=this.el.content,h=y.firstChild;h.remove(),y.append(...h.childNodes)}for(;(r=ct.nextNode())!==null&&a.length0){r.textContent=_t?_t.emptyScript:"";for(let p=0;p2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=B}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,o=this,n,r){const i=this.strings;let s=!1;if(i===void 0)t=Ct(this,t,o,0),s=!Ut(t)||t!==this._$AH&&t!==mt,s&&(this._$AH=t);else{const l=t;let a,c;for(t=i[0],a=0;a{var n,r;const i=(n=o==null?void 0:o.renderBefore)!==null&&n!==void 0?n:t;let s=i._$litPart$;if(s===void 0){const l=(r=o==null?void 0:o.renderBefore)!==null&&r!==void 0?r:null;i._$litPart$=s=new Kt(t.insertBefore(Wt(),l),l,void 0,o??{})}return s._$AI(e),s};/** + */var Ee;const se=window,_t=se.trustedTypes,Tr=_t?_t.createPolicy("lit-html",{createHTML:e=>e}):void 0,Fe="$lit$",Q=`lit$${(Math.random()+"").slice(9)}$`,io="?"+Q,en=`<${io}>`,ut=document,Wt=()=>ut.createComment(""),Ut=e=>e===null||typeof e!="object"&&typeof e!="function",so=Array.isArray,rn=e=>so(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ae=`[ +\f\r]`,Dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Mr=/-->/g,Sr=/>/g,at=RegExp(`>|${Ae}(?:([^\\s"'>=/]+)(${Ae}*=${Ae}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),Rr=/'/g,Dr=/"/g,lo=/^(?:script|style|textarea|title)$/i,ao=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),u=ao(1),L=ao(2),mt=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),Lr=new WeakMap,ct=ut.createTreeWalker(ut,129,null,!1);function co(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Tr!==void 0?Tr.createHTML(t):t}const on=(e,t)=>{const r=e.length-1,n=[];let o,i=t===2?"":"",s=Dt;for(let l=0;l"?(s=o??Dt,y=-1):d[1]===void 0?y=-2:(y=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?at:d[3]==='"'?Dr:Rr):s===Dr||s===Rr?s=at:s===Mr||s===Sr?s=Dt:(s=at,o=void 0);const p=s===at&&e[l+1].startsWith("/>")?" ":"";i+=s===Dt?a+en:y>=0?(n.push(c),a.slice(0,y)+Fe+a.slice(y)+Q+p):a+Q+(y===-2?(n.push(void 0),l):p)}return[co(e,i+(e[r]||"")+(t===2?"":"")),n]};class jt{constructor({strings:t,_$litType$:r},n){let o;this.parts=[];let i=0,s=0;const l=t.length-1,a=this.parts,[c,d]=on(t,r);if(this.el=jt.createElement(c,n),ct.currentNode=this.el.content,r===2){const y=this.el.content,h=y.firstChild;h.remove(),y.append(...h.childNodes)}for(;(o=ct.nextNode())!==null&&a.length0){o.textContent=_t?_t.emptyScript:"";for(let p=0;p2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=B}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,r=this,n,o){const i=this.strings;let s=!1;if(i===void 0)t=Ct(this,t,r,0),s=!Ut(t)||t!==this._$AH&&t!==mt,s&&(this._$AH=t);else{const l=t;let a,c;for(t=i[0],a=0;a{var n,o;const i=(n=r==null?void 0:r.renderBefore)!==null&&n!==void 0?n:t;let s=i._$litPart$;if(s===void 0){const l=(o=r==null?void 0:r.renderBefore)!==null&&o!==void 0?o:null;i._$litPart$=s=new Kt(t.insertBefore(Wt(),l),l,void 0,r??{})}return s._$AI(e),s};/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */var Oe,Pe;class E extends wt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,o;const n=super.createRenderRoot();return(t=(o=this.renderOptions).renderBefore)!==null&&t!==void 0||(o.renderBefore=n.firstChild),n}update(t){const o=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=hn(o,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return mt}}E.finalized=!0,E._$litElement$=!0,(Oe=globalThis.litElementHydrateSupport)===null||Oe===void 0||Oe.call(globalThis,{LitElement:E});const Wo=globalThis.litElementPolyfillSupport;Wo==null||Wo({LitElement:E});((Pe=globalThis.litElementVersions)!==null&&Pe!==void 0?Pe:globalThis.litElementVersions=[]).push("3.3.3");/** + */var Oe,Pe;class E extends wt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,r;const n=super.createRenderRoot();return(t=(r=this.renderOptions).renderBefore)!==null&&t!==void 0||(r.renderBefore=n.firstChild),n}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=hn(r,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return mt}}E.finalized=!0,E._$litElement$=!0,(Oe=globalThis.litElementHydrateSupport)===null||Oe===void 0||Oe.call(globalThis,{LitElement:E});const Br=globalThis.litElementPolyfillSupport;Br==null||Br({LitElement:E});((Pe=globalThis.litElementVersions)!==null&&Pe!==void 0?Pe:globalThis.litElementVersions=[]).push("3.3.3");/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */const P=e=>t=>typeof t=="function"?((o,n)=>(customElements.define(o,n),n))(e,t):((o,n)=>{const{kind:r,elements:i}=n;return{kind:r,elements:i,finisher(s){customElements.define(o,s)}}})(e,t);/** + */const P=e=>t=>typeof t=="function"?((r,n)=>(customElements.define(r,n),n))(e,t):((r,n)=>{const{kind:o,elements:i}=n;return{kind:o,elements:i,finisher(s){customElements.define(r,s)}}})(e,t);/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */const un=(e,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(o){o.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(o){o.createProperty(t.key,e)}},mn=(e,t,o)=>{t.constructor.createProperty(o,e)};function _(e){return(t,o)=>o!==void 0?mn(e,t,o):un(e,t)}/** + */const un=(e,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(r){r.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(r){r.createProperty(t.key,e)}},mn=(e,t,r)=>{t.constructor.createProperty(r,e)};function _(e){return(t,r)=>r!==void 0?mn(e,t,r):un(e,t)}/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause @@ -36,19 +36,19 @@ import{T as $t,M as oe,R as N,E as k,C as $,a as X,b as Br,O as Z,c as ht}from". * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */const fn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},pn=e=>(...t)=>({_$litDirective$:e,values:t});class gn{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,o,n){this._$Ct=t,this._$AM=o,this._$Ci=n}_$AS(t,o){return this.update(t,o)}update(t,o){return this.render(...o)}}/** + */const fn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},pn=e=>(...t)=>({_$litDirective$:e,values:t});class gn{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,r,n){this._$Ct=t,this._$AM=r,this._$Ci=n}_$AS(t,r){return this.update(t,r)}update(t,r){return this.render(...r)}}/** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */const J=pn(class extends gn{constructor(e){var t;if(super(e),e.type!==fn.ATTRIBUTE||e.name!=="class"||((t=e.strings)===null||t===void 0?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){var o,n;if(this.it===void 0){this.it=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(i=>i!=="")));for(const i in t)t[i]&&!(!((o=this.nt)===null||o===void 0)&&o.has(i))&&this.it.add(i);return this.render(t)}const r=e.element.classList;this.it.forEach(i=>{i in t||(r.remove(i),this.it.delete(i))});for(const i in t){const s=!!t[i];s===this.it.has(i)||!((n=this.nt)===null||n===void 0)&&n.has(i)||(s?(r.add(i),this.it.add(i)):(r.remove(i),this.it.delete(i)))}return mt}}),Te=new WeakMap;function hr(e){return Te.has(e)||Te.set(e,{transforms:[],values:new Map}),Te.get(e)}function wn(e,t){return e.has(t)||e.set(t,new Ur),e.get(t)}const vn=["","X","Y","Z"],bn=["translate","scale","rotate","skew"],le={x:"translateX",y:"translateY",z:"translateZ"},Uo={syntax:"",initialValue:"0deg",toDefaultUnit:e=>e+"deg"},yn={translate:{syntax:"",initialValue:"0px",toDefaultUnit:e=>e+"px"},rotate:Uo,scale:{syntax:"",initialValue:1,toDefaultUnit:et},skew:Uo},kt=new Map,go=e=>`--motion-${e}`,ae=["x","y","z"];bn.forEach(e=>{vn.forEach(t=>{ae.push(e+t),kt.set(go(e+t),yn[e])})});const $n=(e,t)=>ae.indexOf(e)-ae.indexOf(t),xn=new Set(ae),ur=e=>xn.has(e),_n=(e,t)=>{le[t]&&(t=le[t]);const{transforms:o}=hr(e);jr(o,t),e.style.transform=Cn(o)},Cn=e=>e.sort($n).reduce(En,"").trim(),En=(e,t)=>`${e} ${t}(var(${go(t)}))`,Ve=e=>e.startsWith("--"),jo=new Set;function An(e){if(!jo.has(e)){jo.add(e);try{const{syntax:t,initialValue:o}=kt.has(e)?kt.get(e):{};CSS.registerProperty({name:e,inherits:!1,syntax:t,initialValue:o})}catch{}}}const Me=(e,t)=>document.createElement("div").animate(e,t),ko={cssRegisterProperty:()=>typeof CSS<"u"&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{Me({opacity:[1]})}catch{return!1}return!0},finished:()=>!!Me({opacity:[0,1]},{duration:.001}).finished,linearEasing:()=>{try{Me({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0}},Se={},vt={};for(const e in ko)vt[e]=()=>(Se[e]===void 0&&(Se[e]=ko[e]()),Se[e]);const On=.015,Pn=(e,t)=>{let o="";const n=Math.round(t/On);for(let r=0;rxt(e)?vt.linearEasing()?`linear(${Pn(e,t)})`:V.easing:er(e)?In(e):e,In=([e,t,o,n])=>`cubic-bezier(${e}, ${t}, ${o}, ${n})`;function Tn(e,t){for(let o=0;oArray.isArray(e)?e:[e];function Ze(e){return le[e]&&(e=le[e]),ur(e)?go(e):e}const Xt={get:(e,t)=>{t=Ze(t);let o=Ve(t)?e.style.getPropertyValue(t):getComputedStyle(e)[t];if(!o&&o!==0){const n=kt.get(t);n&&(o=n.initialValue)}return o},set:(e,t,o)=>{t=Ze(t),Ve(t)?e.style.setProperty(t,o):e.style[t]=o}};function mr(e,t=!0){if(!(!e||e.playState==="finished"))try{e.stop?e.stop():(t&&e.commitStyles(),e.cancel())}catch{}}function Sn(e,t){var o;let n=(t==null?void 0:t.toDefaultUnit)||et;const r=e[e.length-1];if(Vr(r)){const i=((o=r.match(/(-?[\d.]+)([a-z%]*)/))===null||o===void 0?void 0:o[2])||"";i&&(n=s=>s+i)}return n}function Rn(){return window.__MOTION_DEV_TOOLS_RECORD}function Dn(e,t,o,n={},r){const i=Rn(),s=n.record!==!1&&i;let l,{duration:a=V.duration,delay:c=V.delay,endDelay:d=V.endDelay,repeat:y=V.repeat,easing:h=V.easing,persist:p=!1,direction:g,offset:f,allowWebkitAcceleration:O=!1,autoplay:m=!0}=n;const b=hr(e),w=ur(t);let v=vt.waapi();w&&_n(e,t);const C=Ze(t),S=wn(b.values,C),R=kt.get(C);return mr(S.animation,!(ke(h)&&S.generator)&&n.record!==!1),()=>{const U=()=>{var D,Y;return(Y=(D=Xt.get(e,C))!==null&&D!==void 0?D:R==null?void 0:R.initialValue)!==null&&Y!==void 0?Y:0};let M=Tn(Mn(o),U);const z=Sn(M,R);if(ke(h)){const D=h.createAnimation(M,t!=="opacity",U,C,S);h=D.easing,M=D.keyframes||M,a=D.duration||a}if(Ve(C)&&(vt.cssRegisterProperty()?An(C):v=!1),w&&!vt.linearEasing()&&(xt(h)||bt(h)&&h.some(xt))&&(v=!1),v){R&&(M=M.map(W=>ne(W)?R.toDefaultUnit(W):W)),M.length===1&&(!vt.partialKeyframes()||s)&&M.unshift(U());const D={delay:Nt.ms(c),duration:Nt.ms(a),endDelay:Nt.ms(d),easing:bt(h)?void 0:Ho(h,a),direction:g,iterations:y+1,fill:"both"};l=e.animate({[C]:M,offset:f,easing:bt(h)?h.map(W=>Ho(W,a)):void 0},D),l.finished||(l.finished=new Promise((W,Nr)=>{l.onfinish=W,l.oncancel=Nr}));const Y=M[M.length-1];l.finished.then(()=>{p||(Xt.set(e,C,Y),l.cancel())}).catch(Xo),O||(l.playbackRate=1.000001)}else if(r&&w)M=M.map(D=>typeof D=="string"?parseFloat(D):D),M.length===1&&M.unshift(parseFloat(U())),l=new r(D=>{Xt.set(e,C,z?z(D):D)},M,Object.assign(Object.assign({},n),{duration:a,easing:h}));else{const D=M[M.length-1];Xt.set(e,C,R&&ne(D)?R.toDefaultUnit(D):D)}return s&&i(e,t,M,{duration:a,delay:c,easing:h,repeat:y,offset:f},"motion-one"),S.setAnimation(l),l&&!m&&l.pause(),l}}const Ln=(e,t)=>e[t]?Object.assign(Object.assign({},e),e[t]):Object.assign({},e);function Nn(e,t){return typeof e=="string"?e=document.querySelectorAll(e):e instanceof Element&&(e=[e]),Array.from(e||[])}const Bn=e=>e(),fr=(e,t,o=V.duration)=>new Proxy({animations:e.map(Bn).filter(Boolean),duration:o,options:t},Un),Wn=e=>e.animations[0],Un={get:(e,t)=>{const o=Wn(e);switch(t){case"duration":return e.duration;case"currentTime":return Nt.s((o==null?void 0:o[t])||0);case"playbackRate":case"playState":return o==null?void 0:o[t];case"finished":return e.finished||(e.finished=Promise.all(e.animations.map(jn)).catch(Xo)),e.finished;case"stop":return()=>{e.animations.forEach(n=>mr(n))};case"forEachNative":return n=>{e.animations.forEach(r=>n(r,e))};default:return typeof(o==null?void 0:o[t])>"u"?void 0:()=>e.animations.forEach(n=>n[t]())}},set:(e,t,o)=>{switch(t){case"currentTime":o=Nt.ms(o);case"playbackRate":for(let n=0;ne.finished;function kn(e,t,o){return xt(e)?e(t,o):e}function Hn(e){return function(o,n,r={}){o=Nn(o);const i=o.length,s=[];for(let l=0;l{const o=new rr(e,[0,1],t);return o.finished.catch(()=>{}),o}],t,t.duration)}function dt(e,t,o){return(xt(e)?Fn:zn)(e,t,o)}/** + */const J=pn(class extends gn{constructor(e){var t;if(super(e),e.type!==fn.ATTRIBUTE||e.name!=="class"||((t=e.strings)===null||t===void 0?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){var r,n;if(this.it===void 0){this.it=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(i=>i!=="")));for(const i in t)t[i]&&!(!((r=this.nt)===null||r===void 0)&&r.has(i))&&this.it.add(i);return this.render(t)}const o=e.element.classList;this.it.forEach(i=>{i in t||(o.remove(i),this.it.delete(i))});for(const i in t){const s=!!t[i];s===this.it.has(i)||!((n=this.nt)===null||n===void 0)&&n.has(i)||(s?(o.add(i),this.it.add(i)):(o.remove(i),this.it.delete(i)))}return mt}}),Te=new WeakMap;function ho(e){return Te.has(e)||Te.set(e,{transforms:[],values:new Map}),Te.get(e)}function wn(e,t){return e.has(t)||e.set(t,new Uo),e.get(t)}const vn=["","X","Y","Z"],bn=["translate","scale","rotate","skew"],le={x:"translateX",y:"translateY",z:"translateZ"},Wr={syntax:"",initialValue:"0deg",toDefaultUnit:e=>e+"deg"},yn={translate:{syntax:"",initialValue:"0px",toDefaultUnit:e=>e+"px"},rotate:Wr,scale:{syntax:"",initialValue:1,toDefaultUnit:et},skew:Wr},kt=new Map,pr=e=>`--motion-${e}`,ae=["x","y","z"];bn.forEach(e=>{vn.forEach(t=>{ae.push(e+t),kt.set(pr(e+t),yn[e])})});const $n=(e,t)=>ae.indexOf(e)-ae.indexOf(t),xn=new Set(ae),uo=e=>xn.has(e),_n=(e,t)=>{le[t]&&(t=le[t]);const{transforms:r}=ho(e);jo(r,t),e.style.transform=Cn(r)},Cn=e=>e.sort($n).reduce(En,"").trim(),En=(e,t)=>`${e} ${t}(var(${pr(t)}))`,Ve=e=>e.startsWith("--"),Ur=new Set;function An(e){if(!Ur.has(e)){Ur.add(e);try{const{syntax:t,initialValue:r}=kt.has(e)?kt.get(e):{};CSS.registerProperty({name:e,inherits:!1,syntax:t,initialValue:r})}catch{}}}const Me=(e,t)=>document.createElement("div").animate(e,t),jr={cssRegisterProperty:()=>typeof CSS<"u"&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{Me({opacity:[1]})}catch{return!1}return!0},finished:()=>!!Me({opacity:[0,1]},{duration:.001}).finished,linearEasing:()=>{try{Me({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0}},Se={},vt={};for(const e in jr)vt[e]=()=>(Se[e]===void 0&&(Se[e]=jr[e]()),Se[e]);const On=.015,Pn=(e,t)=>{let r="";const n=Math.round(t/On);for(let o=0;oxt(e)?vt.linearEasing()?`linear(${Pn(e,t)})`:V.easing:to(e)?In(e):e,In=([e,t,r,n])=>`cubic-bezier(${e}, ${t}, ${r}, ${n})`;function Tn(e,t){for(let r=0;rArray.isArray(e)?e:[e];function Ze(e){return le[e]&&(e=le[e]),uo(e)?pr(e):e}const Xt={get:(e,t)=>{t=Ze(t);let r=Ve(t)?e.style.getPropertyValue(t):getComputedStyle(e)[t];if(!r&&r!==0){const n=kt.get(t);n&&(r=n.initialValue)}return r},set:(e,t,r)=>{t=Ze(t),Ve(t)?e.style.setProperty(t,r):e.style[t]=r}};function mo(e,t=!0){if(!(!e||e.playState==="finished"))try{e.stop?e.stop():(t&&e.commitStyles(),e.cancel())}catch{}}function Sn(e,t){var r;let n=(t==null?void 0:t.toDefaultUnit)||et;const o=e[e.length-1];if(Vo(o)){const i=((r=o.match(/(-?[\d.]+)([a-z%]*)/))===null||r===void 0?void 0:r[2])||"";i&&(n=s=>s+i)}return n}function Rn(){return window.__MOTION_DEV_TOOLS_RECORD}function Dn(e,t,r,n={},o){const i=Rn(),s=n.record!==!1&&i;let l,{duration:a=V.duration,delay:c=V.delay,endDelay:d=V.endDelay,repeat:y=V.repeat,easing:h=V.easing,persist:p=!1,direction:g,offset:f,allowWebkitAcceleration:O=!1,autoplay:m=!0}=n;const b=ho(e),w=uo(t);let v=vt.waapi();w&&_n(e,t);const C=Ze(t),S=wn(b.values,C),R=kt.get(C);return mo(S.animation,!(ke(h)&&S.generator)&&n.record!==!1),()=>{const U=()=>{var D,Y;return(Y=(D=Xt.get(e,C))!==null&&D!==void 0?D:R==null?void 0:R.initialValue)!==null&&Y!==void 0?Y:0};let M=Tn(Mn(r),U);const z=Sn(M,R);if(ke(h)){const D=h.createAnimation(M,t!=="opacity",U,C,S);h=D.easing,M=D.keyframes||M,a=D.duration||a}if(Ve(C)&&(vt.cssRegisterProperty()?An(C):v=!1),w&&!vt.linearEasing()&&(xt(h)||bt(h)&&h.some(xt))&&(v=!1),v){R&&(M=M.map(W=>ne(W)?R.toDefaultUnit(W):W)),M.length===1&&(!vt.partialKeyframes()||s)&&M.unshift(U());const D={delay:Nt.ms(c),duration:Nt.ms(a),endDelay:Nt.ms(d),easing:bt(h)?void 0:kr(h,a),direction:g,iterations:y+1,fill:"both"};l=e.animate({[C]:M,offset:f,easing:bt(h)?h.map(W=>kr(W,a)):void 0},D),l.finished||(l.finished=new Promise((W,No)=>{l.onfinish=W,l.oncancel=No}));const Y=M[M.length-1];l.finished.then(()=>{p||(Xt.set(e,C,Y),l.cancel())}).catch(Qr),O||(l.playbackRate=1.000001)}else if(o&&w)M=M.map(D=>typeof D=="string"?parseFloat(D):D),M.length===1&&M.unshift(parseFloat(U())),l=new o(D=>{Xt.set(e,C,z?z(D):D)},M,Object.assign(Object.assign({},n),{duration:a,easing:h}));else{const D=M[M.length-1];Xt.set(e,C,R&&ne(D)?R.toDefaultUnit(D):D)}return s&&i(e,t,M,{duration:a,delay:c,easing:h,repeat:y,offset:f},"motion-one"),S.setAnimation(l),l&&!m&&l.pause(),l}}const Ln=(e,t)=>e[t]?Object.assign(Object.assign({},e),e[t]):Object.assign({},e);function Nn(e,t){return typeof e=="string"?e=document.querySelectorAll(e):e instanceof Element&&(e=[e]),Array.from(e||[])}const Bn=e=>e(),fo=(e,t,r=V.duration)=>new Proxy({animations:e.map(Bn).filter(Boolean),duration:r,options:t},Un),Wn=e=>e.animations[0],Un={get:(e,t)=>{const r=Wn(e);switch(t){case"duration":return e.duration;case"currentTime":return Nt.s((r==null?void 0:r[t])||0);case"playbackRate":case"playState":return r==null?void 0:r[t];case"finished":return e.finished||(e.finished=Promise.all(e.animations.map(jn)).catch(Qr)),e.finished;case"stop":return()=>{e.animations.forEach(n=>mo(n))};case"forEachNative":return n=>{e.animations.forEach(o=>n(o,e))};default:return typeof(r==null?void 0:r[t])>"u"?void 0:()=>e.animations.forEach(n=>n[t]())}},set:(e,t,r)=>{switch(t){case"currentTime":r=Nt.ms(r);case"playbackRate":for(let n=0;ne.finished;function kn(e,t,r){return xt(e)?e(t,r):e}function Hn(e){return function(r,n,o={}){r=Nn(r);const i=r.length,s=[];for(let l=0;l{const r=new ro(e,[0,1],t);return r.finished.catch(()=>{}),r}],t,t.duration)}function dt(e,t,r){return(xt(e)?Fn:zn)(e,t,r)}/** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */const j=e=>e??B;var qt={},Vn=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},pr={},F={};let wo;const Zn=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];F.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};F.getSymbolTotalCodewords=function(t){return Zn[t]};F.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};F.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');wo=t};F.isKanjiModeEnabled=function(){return typeof wo<"u"};F.toSJIS=function(t){return wo(t)};var we={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+o)}}e.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})(we);function gr(){this.buffer=[],this.length=0}gr.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let o=0;o>>t-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var Kn=gr;function Yt(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Yt.prototype.set=function(e,t,o,n){const r=e*this.size+t;this.data[r]=o,n&&(this.reservedBit[r]=!0)};Yt.prototype.get=function(e,t){return this.data[e*this.size+t]};Yt.prototype.xor=function(e,t,o){this.data[e*this.size+t]^=o};Yt.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var qn=Yt,wr={};(function(e){const t=F.getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const r=Math.floor(n/7)+2,i=t(n),s=i===145?26:Math.ceil((i-13)/(2*r-2))*2,l=[i-7];for(let a=1;a=0&&r<=7},e.from=function(r){return e.isValid(r)?parseInt(r,10):void 0},e.getPenaltyN1=function(r){const i=r.size;let s=0,l=0,a=0,c=null,d=null;for(let y=0;y=5&&(s+=t.N1+(l-5)),c=p,l=1),p=r.get(h,y),p===d?a++:(a>=5&&(s+=t.N1+(a-5)),d=p,a=1)}l>=5&&(s+=t.N1+(l-5)),a>=5&&(s+=t.N1+(a-5))}return s},e.getPenaltyN2=function(r){const i=r.size;let s=0;for(let l=0;l=10&&(l===1488||l===93)&&s++,a=a<<1&2047|r.get(d,c),d>=10&&(a===1488||a===93)&&s++}return s*t.N3},e.getPenaltyN4=function(r){let i=0;const s=r.data.length;for(let a=0;a=0;){const s=i[0];for(let a=0;a0){const i=new Uint8Array(this.degree);return i.set(n,r),i}return n};var Gn=vo,xr={},st={},bo={};bo.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var q={};const _r="[0-9]+",Jn="[A-Z $%*+\\-./:]+";let Ht="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Ht=Ht.replace(/u/g,"\\u");const Qn="(?:(?![A-Z0-9 $%*+\\-./:]|"+Ht+`)(?:.|[\r -]))+`;q.KANJI=new RegExp(Ht,"g");q.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");q.BYTE=new RegExp(Qn,"g");q.NUMERIC=new RegExp(_r,"g");q.ALPHANUMERIC=new RegExp(Jn,"g");const Xn=new RegExp("^"+Ht+"$"),ti=new RegExp("^"+_r+"$"),ei=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");q.testKanji=function(t){return Xn.test(t)};q.testNumeric=function(t){return ti.test(t)};q.testAlphanumeric=function(t){return ei.test(t)};(function(e){const t=bo,o=q;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(i,s){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!t.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?i.ccBits[0]:s<27?i.ccBits[1]:i.ccBits[2]},e.getBestModeForData=function(i){return o.testNumeric(i)?e.NUMERIC:o.testAlphanumeric(i)?e.ALPHANUMERIC:o.testKanji(i)?e.KANJI:e.BYTE},e.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},e.isValid=function(i){return i&&i.bit&&i.ccBits};function n(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+r)}}e.from=function(i,s){if(e.isValid(i))return i;try{return n(i)}catch{return s}}})(st);(function(e){const t=F,o=ve,n=we,r=st,i=bo,s=7973,l=t.getBCHDigit(s);function a(h,p,g){for(let f=1;f<=40;f++)if(p<=e.getCapacity(f,g,h))return f}function c(h,p){return r.getCharCountIndicator(h,p)+4}function d(h,p){let g=0;return h.forEach(function(f){const O=c(f.mode,p);g+=O+f.getBitsLength()}),g}function y(h,p){for(let g=1;g<=40;g++)if(d(h,g)<=e.getCapacity(g,p,r.MIXED))return g}e.from=function(p,g){return i.isValid(p)?parseInt(p,10):g},e.getCapacity=function(p,g,f){if(!i.isValid(p))throw new Error("Invalid QR Code version");typeof f>"u"&&(f=r.BYTE);const O=t.getSymbolTotalCodewords(p),m=o.getTotalCodewordsCount(p,g),b=(O-m)*8;if(f===r.MIXED)return b;const w=b-c(f,p);switch(f){case r.NUMERIC:return Math.floor(w/10*3);case r.ALPHANUMERIC:return Math.floor(w/11*2);case r.KANJI:return Math.floor(w/13);case r.BYTE:default:return Math.floor(w/8)}},e.getBestVersionForData=function(p,g){let f;const O=n.from(g,n.M);if(Array.isArray(p)){if(p.length>1)return y(p,O);if(p.length===0)return 1;f=p[0]}else f=p;return a(f.mode,f.getLength(),O)},e.getEncodedBits=function(p){if(!i.isValid(p)||p<7)throw new Error("Invalid QR Code version");let g=p<<12;for(;t.getBCHDigit(g)-l>=0;)g^=s<=0;)r^=Er<0&&(n=this.data.substr(o),r=parseInt(n,10),t.put(r,i*3+1))};var ni=Et;const ii=st,Re=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function At(e){this.mode=ii.ALPHANUMERIC,this.data=e}At.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};At.prototype.getLength=function(){return this.data.length};At.prototype.getBitsLength=function(){return At.getBitsLength(this.data.length)};At.prototype.write=function(t){let o;for(o=0;o+2<=this.data.length;o+=2){let n=Re.indexOf(this.data[o])*45;n+=Re.indexOf(this.data[o+1]),t.put(n,11)}this.data.length%2&&t.put(Re.indexOf(this.data[o]),6)};var si=At,li=function(t){for(var o=[],n=t.length,r=0;r=55296&&i<=56319&&n>r+1){var s=t.charCodeAt(r+1);s>=56320&&s<=57343&&(i=(i-55296)*1024+s-56320+65536,r+=1)}if(i<128){o.push(i);continue}if(i<2048){o.push(i>>6|192),o.push(i&63|128);continue}if(i<55296||i>=57344&&i<65536){o.push(i>>12|224),o.push(i>>6&63|128),o.push(i&63|128);continue}if(i>=65536&&i<=1114111){o.push(i>>18|240),o.push(i>>12&63|128),o.push(i>>6&63|128),o.push(i&63|128);continue}o.push(239,191,189)}return new Uint8Array(o).buffer};const ai=li,ci=st;function Ot(e){this.mode=ci.BYTE,typeof e=="string"&&(e=ai(e)),this.data=new Uint8Array(e)}Ot.getBitsLength=function(t){return t*8};Ot.prototype.getLength=function(){return this.data.length};Ot.prototype.getBitsLength=function(){return Ot.getBitsLength(this.data.length)};Ot.prototype.write=function(e){for(let t=0,o=this.data.length;t=33088&&o<=40956)o-=33088;else if(o>=57408&&o<=60351)o-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+` -Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),e.put(o,13)}};var mi=Pt;(function(e){const t=st,o=ni,n=si,r=di,i=mi,s=q,l=F,a=Wr;function c(m){return unescape(encodeURIComponent(m)).length}function d(m,b,w){const v=[];let C;for(;(C=m.exec(w))!==null;)v.push({data:C[0],index:C.index,mode:b,length:C[0].length});return v}function y(m){const b=d(s.NUMERIC,t.NUMERIC,m),w=d(s.ALPHANUMERIC,t.ALPHANUMERIC,m);let v,C;return l.isKanjiModeEnabled()?(v=d(s.BYTE,t.BYTE,m),C=d(s.KANJI,t.KANJI,m)):(v=d(s.BYTE_KANJI,t.BYTE,m),C=[]),b.concat(w,v,C).sort(function(R,U){return R.index-U.index}).map(function(R){return{data:R.data,mode:R.mode,length:R.length}})}function h(m,b){switch(b){case t.NUMERIC:return o.getBitsLength(m);case t.ALPHANUMERIC:return n.getBitsLength(m);case t.KANJI:return i.getBitsLength(m);case t.BYTE:return r.getBitsLength(m)}}function p(m){return m.reduce(function(b,w){const v=b.length-1>=0?b[b.length-1]:null;return v&&v.mode===w.mode?(b[b.length-1].data+=w.data,b):(b.push(w),b)},[])}function g(m){const b=[];for(let w=0;w=0&&l<=6&&(a===0||a===6)||a>=0&&a<=6&&(l===0||l===6)||l>=2&&l<=4&&a>=2&&a<=4?e.set(i+l,s+a,!0,!0):e.set(i+l,s+a,!1,!0))}}function xi(e){const t=e.size;for(let o=8;o>l&1)===1,e.set(r,i,s,!0),e.set(i,r,s,!0)}function Ne(e,t,o){const n=e.size,r=bi.getEncodedBits(t,o);let i,s;for(i=0;i<15;i++)s=(r>>i&1)===1,i<6?e.set(i,8,s,!0):i<8?e.set(i+1,8,s,!0):e.set(n-15+i,8,s,!0),i<8?e.set(8,n-i-1,s,!0):i<9?e.set(8,15-i-1+1,s,!0):e.set(8,15-i-1,s,!0);e.set(n-8,8,1,!0)}function Ei(e,t){const o=e.size;let n=-1,r=o-1,i=7,s=0;for(let l=o-1;l>0;l-=2)for(l===6&&l--;;){for(let a=0;a<2;a++)if(!e.isReserved(r,l-a)){let c=!1;s>>i&1)===1),e.set(r,l-a,c),i--,i===-1&&(s++,i=7)}if(r+=n,r<0||o<=r){r-=n,n=-n;break}}}function Ai(e,t,o){const n=new fi;o.forEach(function(a){n.put(a.mode.bit,4),n.put(a.getLength(),yi.getCharCountIndicator(a.mode,e)),a.write(n)});const r=ye.getSymbolTotalCodewords(e),i=Ye.getTotalCodewordsCount(e,t),s=(r-i)*8;for(n.getLengthInBits()+4<=s&&n.put(0,4);n.getLengthInBits()%8!==0;)n.putBit(0);const l=(s-n.getLengthInBits())/8;for(let a=0;ae??B;var qt={},Vn=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},po={},F={};let gr;const Zn=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];F.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};F.getSymbolTotalCodewords=function(t){return Zn[t]};F.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};F.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');gr=t};F.isKanjiModeEnabled=function(){return typeof gr<"u"};F.toSJIS=function(t){return gr(t)};var we={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+r)}}e.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},e.from=function(n,o){if(e.isValid(n))return n;try{return t(n)}catch{return o}}})(we);function go(){this.buffer=[],this.length=0}go.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let r=0;r>>t-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var Kn=go;function Yt(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Yt.prototype.set=function(e,t,r,n){const o=e*this.size+t;this.data[o]=r,n&&(this.reservedBit[o]=!0)};Yt.prototype.get=function(e,t){return this.data[e*this.size+t]};Yt.prototype.xor=function(e,t,r){this.data[e*this.size+t]^=r};Yt.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var qn=Yt,wo={};(function(e){const t=F.getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const o=Math.floor(n/7)+2,i=t(n),s=i===145?26:Math.ceil((i-13)/(2*o-2))*2,l=[i-7];for(let a=1;a=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const i=o.size;let s=0,l=0,a=0,c=null,d=null;for(let y=0;y=5&&(s+=t.N1+(l-5)),c=p,l=1),p=o.get(h,y),p===d?a++:(a>=5&&(s+=t.N1+(a-5)),d=p,a=1)}l>=5&&(s+=t.N1+(l-5)),a>=5&&(s+=t.N1+(a-5))}return s},e.getPenaltyN2=function(o){const i=o.size;let s=0;for(let l=0;l=10&&(l===1488||l===93)&&s++,a=a<<1&2047|o.get(d,c),d>=10&&(a===1488||a===93)&&s++}return s*t.N3},e.getPenaltyN4=function(o){let i=0;const s=o.data.length;for(let a=0;a=0;){const s=i[0];for(let a=0;a0){const i=new Uint8Array(this.degree);return i.set(n,o),i}return n};var Gn=wr,xo={},st={},vr={};vr.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var q={};const _o="[0-9]+",Jn="[A-Z $%*+\\-./:]+";let Ht="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Ht=Ht.replace(/u/g,"\\u");const Qn="(?:(?![A-Z0-9 $%*+\\-./:]|"+Ht+`)(?:.|[\r +]))+`;q.KANJI=new RegExp(Ht,"g");q.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");q.BYTE=new RegExp(Qn,"g");q.NUMERIC=new RegExp(_o,"g");q.ALPHANUMERIC=new RegExp(Jn,"g");const Xn=new RegExp("^"+Ht+"$"),ti=new RegExp("^"+_o+"$"),ei=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");q.testKanji=function(t){return Xn.test(t)};q.testNumeric=function(t){return ti.test(t)};q.testAlphanumeric=function(t){return ei.test(t)};(function(e){const t=vr,r=q;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(i,s){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!t.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?i.ccBits[0]:s<27?i.ccBits[1]:i.ccBits[2]},e.getBestModeForData=function(i){return r.testNumeric(i)?e.NUMERIC:r.testAlphanumeric(i)?e.ALPHANUMERIC:r.testKanji(i)?e.KANJI:e.BYTE},e.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},e.isValid=function(i){return i&&i.bit&&i.ccBits};function n(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(i,s){if(e.isValid(i))return i;try{return n(i)}catch{return s}}})(st);(function(e){const t=F,r=ve,n=we,o=st,i=vr,s=7973,l=t.getBCHDigit(s);function a(h,p,g){for(let f=1;f<=40;f++)if(p<=e.getCapacity(f,g,h))return f}function c(h,p){return o.getCharCountIndicator(h,p)+4}function d(h,p){let g=0;return h.forEach(function(f){const O=c(f.mode,p);g+=O+f.getBitsLength()}),g}function y(h,p){for(let g=1;g<=40;g++)if(d(h,g)<=e.getCapacity(g,p,o.MIXED))return g}e.from=function(p,g){return i.isValid(p)?parseInt(p,10):g},e.getCapacity=function(p,g,f){if(!i.isValid(p))throw new Error("Invalid QR Code version");typeof f>"u"&&(f=o.BYTE);const O=t.getSymbolTotalCodewords(p),m=r.getTotalCodewordsCount(p,g),b=(O-m)*8;if(f===o.MIXED)return b;const w=b-c(f,p);switch(f){case o.NUMERIC:return Math.floor(w/10*3);case o.ALPHANUMERIC:return Math.floor(w/11*2);case o.KANJI:return Math.floor(w/13);case o.BYTE:default:return Math.floor(w/8)}},e.getBestVersionForData=function(p,g){let f;const O=n.from(g,n.M);if(Array.isArray(p)){if(p.length>1)return y(p,O);if(p.length===0)return 1;f=p[0]}else f=p;return a(f.mode,f.getLength(),O)},e.getEncodedBits=function(p){if(!i.isValid(p)||p<7)throw new Error("Invalid QR Code version");let g=p<<12;for(;t.getBCHDigit(g)-l>=0;)g^=s<=0;)o^=Eo<0&&(n=this.data.substr(r),o=parseInt(n,10),t.put(o,i*3+1))};var ni=Et;const ii=st,Re=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function At(e){this.mode=ii.ALPHANUMERIC,this.data=e}At.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};At.prototype.getLength=function(){return this.data.length};At.prototype.getBitsLength=function(){return At.getBitsLength(this.data.length)};At.prototype.write=function(t){let r;for(r=0;r+2<=this.data.length;r+=2){let n=Re.indexOf(this.data[r])*45;n+=Re.indexOf(this.data[r+1]),t.put(n,11)}this.data.length%2&&t.put(Re.indexOf(this.data[r]),6)};var si=At,li=function(t){for(var r=[],n=t.length,o=0;o=55296&&i<=56319&&n>o+1){var s=t.charCodeAt(o+1);s>=56320&&s<=57343&&(i=(i-55296)*1024+s-56320+65536,o+=1)}if(i<128){r.push(i);continue}if(i<2048){r.push(i>>6|192),r.push(i&63|128);continue}if(i<55296||i>=57344&&i<65536){r.push(i>>12|224),r.push(i>>6&63|128),r.push(i&63|128);continue}if(i>=65536&&i<=1114111){r.push(i>>18|240),r.push(i>>12&63|128),r.push(i>>6&63|128),r.push(i&63|128);continue}r.push(239,191,189)}return new Uint8Array(r).buffer};const ai=li,ci=st;function Ot(e){this.mode=ci.BYTE,typeof e=="string"&&(e=ai(e)),this.data=new Uint8Array(e)}Ot.getBitsLength=function(t){return t*8};Ot.prototype.getLength=function(){return this.data.length};Ot.prototype.getBitsLength=function(){return Ot.getBitsLength(this.data.length)};Ot.prototype.write=function(e){for(let t=0,r=this.data.length;t=33088&&r<=40956)r-=33088;else if(r>=57408&&r<=60351)r-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+` +Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),e.put(r,13)}};var mi=Pt;(function(e){const t=st,r=ni,n=si,o=di,i=mi,s=q,l=F,a=Wo;function c(m){return unescape(encodeURIComponent(m)).length}function d(m,b,w){const v=[];let C;for(;(C=m.exec(w))!==null;)v.push({data:C[0],index:C.index,mode:b,length:C[0].length});return v}function y(m){const b=d(s.NUMERIC,t.NUMERIC,m),w=d(s.ALPHANUMERIC,t.ALPHANUMERIC,m);let v,C;return l.isKanjiModeEnabled()?(v=d(s.BYTE,t.BYTE,m),C=d(s.KANJI,t.KANJI,m)):(v=d(s.BYTE_KANJI,t.BYTE,m),C=[]),b.concat(w,v,C).sort(function(R,U){return R.index-U.index}).map(function(R){return{data:R.data,mode:R.mode,length:R.length}})}function h(m,b){switch(b){case t.NUMERIC:return r.getBitsLength(m);case t.ALPHANUMERIC:return n.getBitsLength(m);case t.KANJI:return i.getBitsLength(m);case t.BYTE:return o.getBitsLength(m)}}function p(m){return m.reduce(function(b,w){const v=b.length-1>=0?b[b.length-1]:null;return v&&v.mode===w.mode?(b[b.length-1].data+=w.data,b):(b.push(w),b)},[])}function g(m){const b=[];for(let w=0;w=0&&l<=6&&(a===0||a===6)||a>=0&&a<=6&&(l===0||l===6)||l>=2&&l<=4&&a>=2&&a<=4?e.set(i+l,s+a,!0,!0):e.set(i+l,s+a,!1,!0))}}function xi(e){const t=e.size;for(let r=8;r>l&1)===1,e.set(o,i,s,!0),e.set(i,o,s,!0)}function Ne(e,t,r){const n=e.size,o=bi.getEncodedBits(t,r);let i,s;for(i=0;i<15;i++)s=(o>>i&1)===1,i<6?e.set(i,8,s,!0):i<8?e.set(i+1,8,s,!0):e.set(n-15+i,8,s,!0),i<8?e.set(8,n-i-1,s,!0):i<9?e.set(8,15-i-1+1,s,!0):e.set(8,15-i-1,s,!0);e.set(n-8,8,1,!0)}function Ei(e,t){const r=e.size;let n=-1,o=r-1,i=7,s=0;for(let l=r-1;l>0;l-=2)for(l===6&&l--;;){for(let a=0;a<2;a++)if(!e.isReserved(o,l-a)){let c=!1;s>>i&1)===1),e.set(o,l-a,c),i--,i===-1&&(s++,i=7)}if(o+=n,o<0||r<=o){o-=n,n=-n;break}}}function Ai(e,t,r){const n=new fi;r.forEach(function(a){n.put(a.mode.bit,4),n.put(a.getLength(),yi.getCharCountIndicator(a.mode,e)),a.write(n)});const o=ye.getSymbolTotalCodewords(e),i=Ye.getTotalCodewordsCount(e,t),s=(o-i)*8;for(n.getLengthInBits()+4<=s&&n.put(0,4);n.getLengthInBits()%8!==0;)n.putBit(0);const l=(s-n.getLengthInBits())/8;for(let a=0;a=7&&Ci(a,t),Ei(a,s),isNaN(n)&&(n=qe.getBestMask(a,Ne.bind(null,a,o))),qe.applyMask(n,a),Ne(a,o,n),{modules:a,version:t,errorCorrectionLevel:o,maskPattern:n,segments:r}}pr.create=function(t,o){if(typeof t>"u"||t==="")throw new Error("No input text");let n=De.M,r,i;return typeof o<"u"&&(n=De.from(o.errorCorrectionLevel,De.M),r=de.from(o.version),i=qe.from(o.maskPattern),o.toSJISFunc&&ye.setToSJISFunction(o.toSJISFunc)),Pi(t,r,n,i)};var Or={},yo={};(function(e){function t(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let n=o.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+o);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(i){return[i,i]}))),n.length===6&&n.push("F","F");const r=parseInt(n.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+n.slice(0,6).join("")}}e.getOptions=function(n){n||(n={}),n.color||(n.color={});const r=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,i=n.width&&n.width>=21?n.width:void 0,s=n.scale||4;return{width:i,scale:i?4:s,margin:r,color:{dark:t(n.color.dark||"#000000ff"),light:t(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},e.getScale=function(n,r){return r.width&&r.width>=n+r.margin*2?r.width/(n+r.margin*2):r.scale},e.getImageWidth=function(n,r){const i=e.getScale(n,r);return Math.floor((n+r.margin*2)*i)},e.qrToImageData=function(n,r,i){const s=r.modules.size,l=r.modules.data,a=e.getScale(s,i),c=Math.floor((s+i.margin*2)*a),d=i.margin*a,y=[i.color.light,i.color.dark];for(let h=0;h=d&&p>=d&&h"u"&&(!s||!s.getContext)&&(a=s,s=void 0),s||(c=n()),a=t.getOptions(a);const d=t.getImageWidth(i.modules.size,a),y=c.getContext("2d"),h=y.createImageData(d,d);return t.qrToImageData(h.data,i,a),o(y,c,d),y.putImageData(h,0,0),c},e.renderToDataURL=function(i,s,l){let a=l;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),a||(a={});const c=e.render(i,s,a),d=a.type||"image/png",y=a.rendererOpts||{};return c.toDataURL(d,y.quality)}})(Or);var Pr={};const Ii=yo;function Vo(e,t){const o=e.a/255,n=t+'="'+e.hex+'"';return o<1?n+" "+t+'-opacity="'+o.toFixed(2).slice(1)+'"':n}function Be(e,t,o){let n=e+t;return typeof o<"u"&&(n+=" "+o),n}function Ti(e,t,o){let n="",r=0,i=!1,s=0;for(let l=0;l0&&a>0&&e[l-1]||(n+=i?Be("M",a+o,.5+c+o):Be("m",r,0),r=0,i=!1),a+1':"",c="',d='viewBox="0 0 '+l+" "+l+'"',h=''+a+c+` -`;return typeof n=="function"&&n(null,h),h};const Mi=Vn,Ge=pr,Ir=Or,Si=Pr;function $o(e,t,o,n,r){const i=[].slice.call(arguments,1),s=i.length,l=typeof i[s-1]=="function";if(!l&&!Mi())throw new Error("Callback required as last argument");if(l){if(s<2)throw new Error("Too few arguments provided");s===2?(r=o,o=t,t=n=void 0):s===3&&(t.getContext&&typeof r>"u"?(r=n,n=void 0):(r=n,n=o,o=t,t=void 0))}else{if(s<1)throw new Error("Too few arguments provided");return s===1?(o=t,t=n=void 0):s===2&&!t.getContext&&(n=o,o=t,t=void 0),new Promise(function(a,c){try{const d=Ge.create(o,n);a(e(d,t,n))}catch(d){c(d)}})}try{const a=Ge.create(o,n);r(null,e(a,t,n))}catch(a){r(a)}}qt.create=Ge.create;qt.toCanvas=$o.bind(null,Ir.render);qt.toDataURL=$o.bind(null,Ir.renderToDataURL);qt.toString=$o.bind(null,function(e,t,o){return Si.render(e,o)});var Ri=Object.defineProperty,Zo=Object.getOwnPropertySymbols,Di=Object.prototype.hasOwnProperty,Li=Object.prototype.propertyIsEnumerable,Ko=(e,t,o)=>t in e?Ri(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,We=(e,t)=>{for(var o in t||(t={}))Di.call(t,o)&&Ko(e,o,t[o]);if(Zo)for(var o of Zo(t))Li.call(t,o)&&Ko(e,o,t[o]);return e};function Ni(){var e;const t=(e=$t.state.themeMode)!=null?e:"dark",n={light:{foreground:{1:"rgb(20,20,20)",2:"rgb(121,134,134)",3:"rgb(158,169,169)"},background:{1:"rgb(255,255,255)",2:"rgb(241,243,243)",3:"rgb(228,231,231)"},overlay:"rgba(0,0,0,0.1)"},dark:{foreground:{1:"rgb(228,231,231)",2:"rgb(148,158,158)",3:"rgb(110,119,119)"},background:{1:"rgb(20,20,20)",2:"rgb(39,42,42)",3:"rgb(59,64,64)"},overlay:"rgba(255,255,255,0.1)"}}[t];return{"--wcm-color-fg-1":n.foreground[1],"--wcm-color-fg-2":n.foreground[2],"--wcm-color-fg-3":n.foreground[3],"--wcm-color-bg-1":n.background[1],"--wcm-color-bg-2":n.background[2],"--wcm-color-bg-3":n.background[3],"--wcm-color-overlay":n.overlay}}function qo(){return{"--wcm-accent-color":"#3396FF","--wcm-accent-fill-color":"#FFFFFF","--wcm-z-index":"89","--wcm-background-color":"#3396FF","--wcm-background-border-radius":"8px","--wcm-container-border-radius":"30px","--wcm-wallet-icon-border-radius":"15px","--wcm-wallet-icon-large-border-radius":"30px","--wcm-wallet-icon-small-border-radius":"7px","--wcm-input-border-radius":"28px","--wcm-button-border-radius":"10px","--wcm-notification-border-radius":"36px","--wcm-secondary-button-border-radius":"28px","--wcm-icon-button-border-radius":"50%","--wcm-button-hover-highlight-border-radius":"10px","--wcm-text-big-bold-size":"20px","--wcm-text-big-bold-weight":"600","--wcm-text-big-bold-line-height":"24px","--wcm-text-big-bold-letter-spacing":"-0.03em","--wcm-text-big-bold-text-transform":"none","--wcm-text-xsmall-bold-size":"10px","--wcm-text-xsmall-bold-weight":"700","--wcm-text-xsmall-bold-line-height":"12px","--wcm-text-xsmall-bold-letter-spacing":"0.02em","--wcm-text-xsmall-bold-text-transform":"uppercase","--wcm-text-xsmall-regular-size":"12px","--wcm-text-xsmall-regular-weight":"600","--wcm-text-xsmall-regular-line-height":"14px","--wcm-text-xsmall-regular-letter-spacing":"-0.03em","--wcm-text-xsmall-regular-text-transform":"none","--wcm-text-small-thin-size":"14px","--wcm-text-small-thin-weight":"500","--wcm-text-small-thin-line-height":"16px","--wcm-text-small-thin-letter-spacing":"-0.03em","--wcm-text-small-thin-text-transform":"none","--wcm-text-small-regular-size":"14px","--wcm-text-small-regular-weight":"600","--wcm-text-small-regular-line-height":"16px","--wcm-text-small-regular-letter-spacing":"-0.03em","--wcm-text-small-regular-text-transform":"none","--wcm-text-medium-regular-size":"16px","--wcm-text-medium-regular-weight":"600","--wcm-text-medium-regular-line-height":"20px","--wcm-text-medium-regular-letter-spacing":"-0.03em","--wcm-text-medium-regular-text-transform":"none","--wcm-font-family":"-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif","--wcm-font-feature-settings":"'tnum' on, 'lnum' on, 'case' on","--wcm-success-color":"rgb(38,181,98)","--wcm-error-color":"rgb(242, 90, 103)","--wcm-overlay-background-color":"rgba(0, 0, 0, 0.3)","--wcm-overlay-backdrop-filter":"none"}}const A={getPreset(e){return qo()[e]},setTheme(){const e=document.querySelector(":root"),{themeVariables:t}=$t.state;if(e){const o=We(We(We({},Ni()),qo()),t);Object.entries(o).forEach(([n,r])=>e.style.setProperty(n,r))}},globalCss:I`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}`},Bi=I`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`;var Wi=Object.defineProperty,Ui=Object.getOwnPropertyDescriptor,Mt=(e,t,o,n)=>{for(var r=n>1?void 0:n?Ui(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Wi(t,o,r),r};let rt=class extends E{constructor(){super(...arguments),this.disabled=!1,this.iconLeft=void 0,this.iconRight=void 0,this.onClick=()=>null,this.variant="default"}render(){const e={"wcm-icon-left":this.iconLeft!==void 0,"wcm-icon-right":this.iconRight!==void 0,"wcm-ghost":this.variant==="ghost","wcm-outline":this.variant==="outline"};let t="inverse";return this.variant==="ghost"&&(t="secondary"),this.variant==="outline"&&(t="accent"),u``}};rt.styles=[A.globalCss,Bi];Mt([_({type:Boolean})],rt.prototype,"disabled",2);Mt([_()],rt.prototype,"iconLeft",2);Mt([_()],rt.prototype,"iconRight",2);Mt([_()],rt.prototype,"onClick",2);Mt([_()],rt.prototype,"variant",2);rt=Mt([P("wcm-button")],rt);const ji=I`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`;var ki=Object.defineProperty,Hi=Object.getOwnPropertyDescriptor,xo=(e,t,o,n)=>{for(var r=n>1?void 0:n?Hi(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&ki(t,o,r),r};let zt=class extends E{constructor(){super(...arguments),this.disabled=!1,this.variant="primary"}render(){const e={"wcm-secondary":this.variant==="secondary"};return u``}};zt.styles=[A.globalCss,ji];xo([_({type:Boolean})],zt.prototype,"disabled",2);xo([_()],zt.prototype,"variant",2);zt=xo([P("wcm-button-big")],zt);const zi=I`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`;var Fi=Object.defineProperty,Vi=Object.getOwnPropertyDescriptor,Zi=(e,t,o,n)=>{for(var r=n>1?void 0:n?Vi(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Fi(t,o,r),r};let Je=class extends E{render(){return u`
`}};Je.styles=[A.globalCss,zi];Je=Zi([P("wcm-info-footer")],Je);const T={CROSS_ICON:L``,WALLET_CONNECT_LOGO:L``,WALLET_CONNECT_ICON:L``,WALLET_CONNECT_ICON_COLORED:L``,BACK_ICON:L``,COPY_ICON:L``,RETRY_ICON:L``,DESKTOP_ICON:L``,MOBILE_ICON:L``,ARROW_DOWN_ICON:L``,ARROW_UP_RIGHT_ICON:L``,ARROW_RIGHT_ICON:L``,QRCODE_ICON:L``,SCAN_ICON:L``,CHECKMARK_ICON:L``,SEARCH_ICON:L``,WALLET_PLACEHOLDER:L``,GLOBE_ICON:L``},Ki=I`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`;var qi=Object.defineProperty,Yi=Object.getOwnPropertyDescriptor,Gi=(e,t,o,n)=>{for(var r=n>1?void 0:n?Yi(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&qi(t,o,r),r};let Qe=class extends E{render(){return u`
${T.WALLET_CONNECT_LOGO}
`}};Qe.styles=[A.globalCss,Ki];Qe=Gi([P("wcm-modal-backcard")],Qe);const Ji=I`main{padding:20px;padding-top:0;width:100%}`;var Qi=Object.defineProperty,Xi=Object.getOwnPropertyDescriptor,ts=(e,t,o,n)=>{for(var r=n>1?void 0:n?Xi(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Qi(t,o,r),r};let Xe=class extends E{render(){return u`
`}};Xe.styles=[A.globalCss,Ji];Xe=ts([P("wcm-modal-content")],Xe);const es=I`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`;var os=Object.defineProperty,rs=Object.getOwnPropertyDescriptor,ns=(e,t,o,n)=>{for(var r=n>1?void 0:n?rs(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&os(t,o,r),r};let to=class extends E{render(){return u`
`}};to.styles=[A.globalCss,es];to=ns([P("wcm-modal-footer")],to);const is=I`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`;var ss=Object.defineProperty,ls=Object.getOwnPropertyDescriptor,Gt=(e,t,o,n)=>{for(var r=n>1?void 0:n?ls(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&ss(t,o,r),r};let ft=class extends E{constructor(){super(...arguments),this.title="",this.onAction=void 0,this.actionIcon=void 0,this.border=!1}backBtnTemplate(){return u``}actionBtnTemplate(){return u``}render(){const e={"wcm-border":this.border},t=N.state.history.length>1,o=this.title?u`${this.title}`:u``;return u`
${t?this.backBtnTemplate():null} ${o} ${this.onAction?this.actionBtnTemplate():null}
`}};ft.styles=[A.globalCss,is];Gt([_()],ft.prototype,"title",2);Gt([_()],ft.prototype,"onAction",2);Gt([_()],ft.prototype,"actionIcon",2);Gt([_({type:Boolean})],ft.prototype,"border",2);ft=Gt([P("wcm-modal-header")],ft);const x={MOBILE_BREAKPOINT:600,WCM_RECENT_WALLET_DATA:"WCM_RECENT_WALLET_DATA",EXPLORER_WALLET_URL:"https://explorer.walletconnect.com/?type=wallet",getShadowRootElement(e,t){const o=e.renderRoot.querySelector(t);if(!o)throw new Error(`${t} not found`);return o},getWalletIcon({id:e,image_id:t}){const{walletImages:o}=ht.state;return o!=null&&o[e]?o[e]:t?k.getWalletImageUrl(t):""},getWalletName(e,t=!1){return t&&e.length>8?`${e.substring(0,8)}..`:e},isMobileAnimation(){return window.innerWidth<=x.MOBILE_BREAKPOINT},async preloadImage(e){const t=new Promise((o,n)=>{const r=new Image;r.onload=o,r.onerror=n,r.crossOrigin="anonymous",r.src=e});return Promise.race([t,$.wait(3e3)])},getErrorMessage(e){return e instanceof Error?e.message:"Unknown Error"},debounce(e,t=500){let o;return(...n)=>{function r(){e(...n)}o&&clearTimeout(o),o=setTimeout(r,t)}},handleMobileLinking(e,t="_self"){const{walletConnectUri:o}=Z.state,{mobile:n,name:r}=e,i=n==null?void 0:n.native,s=n==null?void 0:n.universal;x.setRecentWallet(e);function l(a){if(i){const c=$.formatNativeUrl(i,a,r);$.openHref(c,t)}else if(s){const c=$.formatUniversalUrl(s,a,r);$.openHref(c,t)}}o&&l(o)},handleAndroidLinking(){const{walletConnectUri:e}=Z.state;e&&($.setWalletConnectAndroidDeepLink(e),$.openHref(e,$.isTelegram()?"_blank":"_self"))},async handleUriCopy(){const{walletConnectUri:e}=Z.state;if(e)try{await navigator.clipboard.writeText(e),X.openToast("Link copied","success")}catch{X.openToast("Failed to copy","error")}},getCustomImageUrls(){const{walletImages:e}=ht.state,t=Object.values(e??{});return Object.values(t)},truncate(e,t=8){return e.length<=t?e:`${e.substring(0,4)}...${e.substring(e.length-4)}`},setRecentWallet(e){try{localStorage.setItem(x.WCM_RECENT_WALLET_DATA,JSON.stringify(e))}catch{console.info("Unable to set recent wallet")}},getRecentWallet(){try{const e=localStorage.getItem(x.WCM_RECENT_WALLET_DATA);return e?JSON.parse(e):void 0}catch{console.info("Unable to get recent wallet")}},caseSafeIncludes(e,t){return e.toUpperCase().includes(t.toUpperCase())},openWalletExplorerUrl(){$.openHref(x.EXPLORER_WALLET_URL,"_blank")},getCachedRouterWalletPlatforms(){const{desktop:e,mobile:t}=$.getWalletRouterData(),o=!!(e!=null&&e.native),n=!!(e!=null&&e.universal),r=!!(t!=null&&t.native)||!!(t!=null&&t.universal);return{isDesktop:o,isMobile:r,isWeb:n}},goToConnectingView(e){N.setData({Wallet:e});const t=$.isMobile(),{isDesktop:o,isWeb:n,isMobile:r}=x.getCachedRouterWalletPlatforms();t?r?(N.push("MobileConnecting"),!$.isAndroid()&&$.isTelegram()&&this.handleMobileLinking(e,"_blank")):n?N.push("WebConnecting"):N.push("InstallWallet"):o?N.push("DesktopConnecting"):n?N.push("WebConnecting"):r?N.push("MobileQrcodeConnecting"):N.push("InstallWallet")}},as=I`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`;var cs=Object.defineProperty,ds=Object.getOwnPropertyDescriptor,_o=(e,t,o,n)=>{for(var r=n>1?void 0:n?ds(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&cs(t,o,r),r};let Ft=class extends E{constructor(){super(),this.view=N.state.view,this.prevView=N.state.view,this.unsubscribe=void 0,this.oldHeight="0px",this.resizeObserver=void 0,this.unsubscribe=N.subscribe(e=>{this.view!==e.view&&this.onChangeRoute()})}firstUpdated(){this.resizeObserver=new ResizeObserver(([e])=>{const t=`${e.contentRect.height}px`;this.oldHeight!=="0px"&&dt(this.routerEl,{height:[this.oldHeight,t]},{duration:.2}),this.oldHeight=t}),this.resizeObserver.observe(this.contentEl)}disconnectedCallback(){var e,t;(e=this.unsubscribe)==null||e.call(this),(t=this.resizeObserver)==null||t.disconnect()}get routerEl(){return x.getShadowRootElement(this,".wcm-router")}get contentEl(){return x.getShadowRootElement(this,".wcm-content")}viewTemplate(){switch(this.view){case"ConnectWallet":return u``;case"DesktopConnecting":return u``;case"MobileConnecting":return u``;case"WebConnecting":return u``;case"MobileQrcodeConnecting":return u``;case"WalletExplorer":return u``;case"Qrcode":return u``;case"InstallWallet":return u``;default:return u`
Not Found
`}}async onChangeRoute(){await dt(this.routerEl,{opacity:[1,0],scale:[1,1.02]},{duration:.15,delay:.1}).finished,this.view=N.state.view,dt(this.routerEl,{opacity:[0,1],scale:[.99,1]},{duration:.37,delay:.05})}render(){return u`
${this.viewTemplate()}
`}};Ft.styles=[A.globalCss,as];_o([H()],Ft.prototype,"view",2);_o([H()],Ft.prototype,"prevView",2);Ft=_o([P("wcm-modal-router")],Ft);const hs=I`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`;var us=Object.defineProperty,ms=Object.getOwnPropertyDescriptor,Tr=(e,t,o,n)=>{for(var r=n>1?void 0:n?ms(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&us(t,o,r),r};let he=class extends E{constructor(){super(),this.open=!1,this.unsubscribe=void 0,this.timeout=void 0,this.unsubscribe=X.subscribe(e=>{e.open?(this.open=!0,this.timeout=setTimeout(()=>X.closeToast(),2200)):(this.open=!1,clearTimeout(this.timeout))})}disconnectedCallback(){var e;(e=this.unsubscribe)==null||e.call(this),clearTimeout(this.timeout),X.closeToast()}render(){const{message:e,variant:t}=X.state,o={"wcm-success":t==="success","wcm-error":t==="error"};return this.open?u`
${t==="success"?T.CHECKMARK_ICON:null} ${t==="error"?T.CROSS_ICON:null}${e}
`:null}};he.styles=[A.globalCss,hs];Tr([H()],he.prototype,"open",2);he=Tr([P("wcm-modal-toast")],he);const fs=.1,Yo=2.5,G=7;function Ue(e,t,o){return e===t?!1:(e-t<0?t-e:e-t)<=o+fs}function ps(e,t){const o=Array.prototype.slice.call(qt.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(o.length);return o.reduce((r,i,s)=>(s%n===0?r.push([i]):r[r.length-1].push(i))&&r,[])}const gs={generate(e,t,o){const n="#141414",r="#ffffff",i=[],s=ps(e,"Q"),l=t/s.length,a=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];a.forEach(({x:g,y:f})=>{const O=(s.length-G)*l*g,m=(s.length-G)*l*f,b=.45;for(let w=0;w`)}});const c=Math.floor((o+25)/l),d=s.length/2-c/2,y=s.length/2+c/2-1,h=[];s.forEach((g,f)=>{g.forEach((O,m)=>{if(s[f][m]&&!(fs.length-(G+1)&&ms.length-(G+1))&&!(f>d&&fd&&m{p[g]?p[g].push(f):p[g]=[f]}),Object.entries(p).map(([g,f])=>{const O=f.filter(m=>f.every(b=>!Ue(m,b,l)));return[Number(g),O]}).forEach(([g,f])=>{f.forEach(O=>{i.push(L``)})}),Object.entries(p).filter(([g,f])=>f.length>1).map(([g,f])=>{const O=f.filter(m=>f.some(b=>Ue(m,b,l)));return[Number(g),O]}).map(([g,f])=>{f.sort((m,b)=>mw.some(v=>Ue(m,v,l)));b?b.push(m):O.push([m])}return[g,O.map(m=>[m[0],m[m.length-1]])]}).forEach(([g,f])=>{f.forEach(([O,m])=>{i.push(L``)})}),i}},ws=I`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`;var vs=Object.defineProperty,bs=Object.getOwnPropertyDescriptor,St=(e,t,o,n)=>{for(var r=n>1?void 0:n?bs(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&vs(t,o,r),r};let nt=class extends E{constructor(){super(...arguments),this.uri="",this.size=0,this.imageId=void 0,this.walletId=void 0,this.imageUrl=void 0}svgTemplate(){const t=$t.state.themeMode==="light"?this.size:this.size-18*2;return L`${gs.generate(this.uri,t,t/4)}`}render(){const e={"wcm-dark":$t.state.themeMode==="dark"};return u`
${this.walletId||this.imageUrl?u``:T.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`}};nt.styles=[A.globalCss,ws];St([_()],nt.prototype,"uri",2);St([_({type:Number})],nt.prototype,"size",2);St([_()],nt.prototype,"imageId",2);St([_()],nt.prototype,"walletId",2);St([_()],nt.prototype,"imageUrl",2);nt=St([P("wcm-qrcode")],nt);const ys=I`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`;var $s=Object.defineProperty,xs=Object.getOwnPropertyDescriptor,Mr=(e,t,o,n)=>{for(var r=n>1?void 0:n?xs(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&$s(t,o,r),r};let ue=class extends E{constructor(){super(...arguments),this.onChange=()=>null}render(){return u` ${T.SEARCH_ICON}`}};ue.styles=[A.globalCss,ys];Mr([_()],ue.prototype,"onChange",2);ue=Mr([P("wcm-search-input")],ue);const _s=I`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`;var Cs=Object.defineProperty,Es=Object.getOwnPropertyDescriptor,As=(e,t,o,n)=>{for(var r=n>1?void 0:n?Es(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Cs(t,o,r),r};let eo=class extends E{render(){return u``}};eo.styles=[A.globalCss,_s];eo=As([P("wcm-spinner")],eo);const Os=I`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`;var Ps=Object.defineProperty,Is=Object.getOwnPropertyDescriptor,Co=(e,t,o,n)=>{for(var r=n>1?void 0:n?Is(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Ps(t,o,r),r};let Vt=class extends E{constructor(){super(...arguments),this.variant="medium-regular",this.color="primary"}render(){const e={"wcm-big-bold":this.variant==="big-bold","wcm-medium-regular":this.variant==="medium-regular","wcm-small-regular":this.variant==="small-regular","wcm-small-thin":this.variant==="small-thin","wcm-xsmall-regular":this.variant==="xsmall-regular","wcm-xsmall-bold":this.variant==="xsmall-bold","wcm-color-primary":this.color==="primary","wcm-color-secondary":this.color==="secondary","wcm-color-tertiary":this.color==="tertiary","wcm-color-inverse":this.color==="inverse","wcm-color-accnt":this.color==="accent","wcm-color-error":this.color==="error"};return u``}};Vt.styles=[A.globalCss,Os];Co([_()],Vt.prototype,"variant",2);Co([_()],Vt.prototype,"color",2);Vt=Co([P("wcm-text")],Vt);const Ts=I`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`;var Ms=Object.defineProperty,Ss=Object.getOwnPropertyDescriptor,lt=(e,t,o,n)=>{for(var r=n>1?void 0:n?Ss(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Ms(t,o,r),r};let K=class extends E{constructor(){super(...arguments),this.onClick=()=>null,this.name="",this.walletId="",this.label=void 0,this.imageId=void 0,this.installed=!1,this.recent=!1}sublabelTemplate(){return this.recent?u`RECENT`:this.installed?u`INSTALLED`:null}handleClick(){Br.click({name:"WALLET_BUTTON",walletId:this.walletId}),this.onClick()}render(){var e;return u``}};K.styles=[A.globalCss,Ts];lt([_()],K.prototype,"onClick",2);lt([_()],K.prototype,"name",2);lt([_()],K.prototype,"walletId",2);lt([_()],K.prototype,"label",2);lt([_()],K.prototype,"imageId",2);lt([_({type:Boolean})],K.prototype,"installed",2);lt([_({type:Boolean})],K.prototype,"recent",2);K=lt([P("wcm-wallet-button")],K);const Rs=I`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var Ds=Object.defineProperty,Ls=Object.getOwnPropertyDescriptor,$e=(e,t,o,n)=>{for(var r=n>1?void 0:n?Ls(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Ds(t,o,r),r};let It=class extends E{constructor(){super(...arguments),this.walletId="",this.imageId=void 0,this.imageUrl=void 0}render(){var e;const t=(e=this.imageUrl)!=null&&e.length?this.imageUrl:x.getWalletIcon({id:this.walletId,image_id:this.imageId});return u`${t.length?u`
${this.id}
`:T.WALLET_PLACEHOLDER}`}};It.styles=[A.globalCss,Rs];$e([_()],It.prototype,"walletId",2);$e([_()],It.prototype,"imageId",2);$e([_()],It.prototype,"imageUrl",2);It=$e([P("wcm-wallet-image")],It);var Ns=Object.defineProperty,Bs=Object.getOwnPropertyDescriptor,Sr=(e,t,o,n)=>{for(var r=n>1?void 0:n?Bs(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Ns(t,o,r),r};let oo=class extends E{constructor(){super(),this.preload=!0,this.preloadData()}async loadImages(e){try{e!=null&&e.length&&await Promise.all(e.map(async t=>x.preloadImage(t)))}catch{console.info("Unsuccessful attempt at preloading some images",e)}}async preloadListings(){if(ht.state.enableExplorer){await k.getRecomendedWallets(),Z.setIsDataLoaded(!0);const{recomendedWallets:e}=k.state,t=e.map(o=>x.getWalletIcon(o));await this.loadImages(t)}else Z.setIsDataLoaded(!0)}async preloadCustomImages(){const e=x.getCustomImageUrls();await this.loadImages(e)}async preloadData(){try{this.preload&&(this.preload=!1,await Promise.all([this.preloadListings(),this.preloadCustomImages()]))}catch(e){console.error(e),X.openToast("Failed preloading","error")}}};Sr([H()],oo.prototype,"preload",2);oo=Sr([P("wcm-explorer-context")],oo);var Ws=Object.defineProperty,Us=Object.getOwnPropertyDescriptor,js=(e,t,o,n)=>{for(var r=n>1?void 0:n?Us(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Ws(t,o,r),r};let Go=class extends E{constructor(){super(),this.unsubscribeTheme=void 0,A.setTheme(),this.unsubscribeTheme=$t.subscribe(A.setTheme)}disconnectedCallback(){var e;(e=this.unsubscribeTheme)==null||e.call(this)}};Go=js([P("wcm-theme-context")],Go);const ks=I`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var Hs=Object.defineProperty,zs=Object.getOwnPropertyDescriptor,Fs=(e,t,o,n)=>{for(var r=n>1?void 0:n?zs(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Hs(t,o,r),r};let ro=class extends E{onGoToQrcode(){N.push("Qrcode")}render(){const{recomendedWallets:e}=k.state,t=[...e,...e],o=$.RECOMMENDED_WALLET_AMOUNT*2;return u`
${T.MOBILE_ICON}WalletConnect
${[...Array(o)].map((n,r)=>{const i=t[r%t.length];return i?u``:T.WALLET_PLACEHOLDER})}
Select Wallet
Choose WalletConnect to see supported apps on your device`}};ro.styles=[A.globalCss,ks];ro=Fs([P("wcm-android-wallet-selection")],ro);const Vs=I`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`;var Zs=Object.defineProperty,Ks=Object.getOwnPropertyDescriptor,Rt=(e,t,o,n)=>{for(var r=n>1?void 0:n?Ks(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Zs(t,o,r),r};let it=class extends E{constructor(){super(...arguments),this.walletId=void 0,this.imageId=void 0,this.isError=!1,this.isStale=!1,this.label=""}svgLoaderTemplate(){var e,t;const i=(t=(e=$t.state.themeVariables)==null?void 0:e["--wcm-wallet-icon-large-border-radius"])!=null?t:A.getPreset("--wcm-wallet-icon-large-border-radius");let s=0;i.includes("%")?s=88/100*parseInt(i,10):s=parseInt(i,10),s*=1.17;const l=317-s*1.57,a=425-s*1.8;return u``}render(){const e={"wcm-error":this.isError,"wcm-stale":this.isStale};return u`
${this.svgLoaderTemplate()}
${this.isError?"Connection declined":this.label}`}};it.styles=[A.globalCss,Vs];Rt([_()],it.prototype,"walletId",2);Rt([_()],it.prototype,"imageId",2);Rt([_({type:Boolean})],it.prototype,"isError",2);Rt([_({type:Boolean})],it.prototype,"isStale",2);Rt([_()],it.prototype,"label",2);it=Rt([P("wcm-connector-waiting")],it);const yt={manualWallets(){var e,t;const{mobileWallets:o,desktopWallets:n}=ht.state,r=(e=yt.recentWallet())==null?void 0:e.id,i=$.isMobile()?o:n,s=i==null?void 0:i.filter(l=>r!==l.id);return(t=$.isMobile()?s==null?void 0:s.map(({id:l,name:a,links:c})=>({id:l,name:a,mobile:c,links:c})):s==null?void 0:s.map(({id:l,name:a,links:c})=>({id:l,name:a,desktop:c,links:c})))!=null?t:[]},recentWallet(){return x.getRecentWallet()},recomendedWallets(e=!1){var t;const o=e||(t=yt.recentWallet())==null?void 0:t.id,{recomendedWallets:n}=k.state;return n.filter(i=>o!==i.id)}},ot={onConnecting(e){x.goToConnectingView(e)},manualWalletsTemplate(){return yt.manualWallets().map(t=>u``)},recomendedWalletsTemplate(e=!1){return yt.recomendedWallets(e).map(o=>u``)},recentWalletTemplate(){const e=yt.recentWallet();if(e)return u``}},qs=I`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`;var Ys=Object.defineProperty,Gs=Object.getOwnPropertyDescriptor,Js=(e,t,o,n)=>{for(var r=n>1?void 0:n?Gs(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Ys(t,o,r),r};let no=class extends E{render(){const{explorerExcludedWalletIds:e,enableExplorer:t}=ht.state,o=e!=="ALL"&&t,n=ot.manualWalletsTemplate(),r=ot.recomendedWalletsTemplate();let s=[ot.recentWalletTemplate(),...n,...r];s=s.filter(Boolean);const l=s.length>4||o;let a=[];l?a=s.slice(0,3):a=s;const c=!!a.length;return u`
${T.MOBILE_ICON}Mobile
${T.SCAN_ICON}Scan with your wallet
${c?u`
${T.DESKTOP_ICON}Desktop
${a} ${l?u``:null}
`:null}`}};no.styles=[A.globalCss,qs];no=Js([P("wcm-desktop-wallet-selection")],no);const Qs=I`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`;var Xs=Object.defineProperty,tl=Object.getOwnPropertyDescriptor,el=(e,t,o,n)=>{for(var r=n>1?void 0:n?tl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Xs(t,o,r),r};let io=class extends E{render(){const{termsOfServiceUrl:e,privacyPolicyUrl:t}=ht.state;return e??t?u`
By connecting your wallet to this app, you agree to the app's ${e?u`Terms of Service`:null} ${e&&t?"and":null} ${t?u`Privacy Policy`:null}
`:null}};io.styles=[A.globalCss,Qs];io=el([P("wcm-legal-notice")],io);const ol=I`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`;var rl=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,il=(e,t,o,n)=>{for(var r=n>1?void 0:n?nl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&rl(t,o,r),r};let so=class extends E{onQrcode(){N.push("Qrcode")}render(){const{explorerExcludedWalletIds:e,enableExplorer:t}=ht.state,o=e!=="ALL"&&t,n=ot.manualWalletsTemplate(),r=ot.recomendedWalletsTemplate();let s=[ot.recentWalletTemplate(),...n,...r];s=s.filter(Boolean);const l=s.length>8||o;let a=[];l?a=s.slice(0,7):a=s;const c=!!a.length;return u`${c?u`
${a} ${l?u``:null}
`:null}`}};so.styles=[A.globalCss,ol];so=il([P("wcm-mobile-wallet-selection")],so);const sl=I`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`;var ll=Object.defineProperty,al=Object.getOwnPropertyDescriptor,Eo=(e,t,o,n)=>{for(var r=n>1?void 0:n?al(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&ll(t,o,r),r};let Zt=class extends E{constructor(){super(),this.open=!1,this.active=!1,this.unsubscribeModal=void 0,this.abortController=void 0,this.unsubscribeModal=oe.subscribe(e=>{e.open?this.onOpenModalEvent():this.onCloseModalEvent()})}disconnectedCallback(){var e;(e=this.unsubscribeModal)==null||e.call(this)}get overlayEl(){return x.getShadowRootElement(this,".wcm-overlay")}get containerEl(){return x.getShadowRootElement(this,".wcm-container")}toggleBodyScroll(e){if(document.querySelector("body"))if(e){const o=document.getElementById("wcm-styles");o==null||o.remove()}else document.head.insertAdjacentHTML("beforeend",'')}onCloseModal(e){e.target===e.currentTarget&&oe.close()}onOpenModalEvent(){this.toggleBodyScroll(!1),this.addKeyboardEvents(),this.open=!0,setTimeout(async()=>{const e=x.isMobileAnimation()?{y:["50vh","0vh"]}:{scale:[.98,1]},t=.1,o=.2;await Promise.all([dt(this.overlayEl,{opacity:[0,1]},{delay:t,duration:o}).finished,dt(this.containerEl,e,{delay:t,duration:o}).finished]),this.active=!0},0)}async onCloseModalEvent(){this.toggleBodyScroll(!0),this.removeKeyboardEvents();const e=x.isMobileAnimation()?{y:["0vh","50vh"]}:{scale:[1,.98]},t=.2;await Promise.all([dt(this.overlayEl,{opacity:[1,0]},{duration:t}).finished,dt(this.containerEl,e,{duration:t}).finished]),this.containerEl.removeAttribute("style"),this.active=!1,this.open=!1}addKeyboardEvents(){this.abortController=new AbortController,window.addEventListener("keydown",e=>{var t;e.key==="Escape"?oe.close():e.key==="Tab"&&((t=e.target)!=null&&t.tagName.includes("wcm-")||this.containerEl.focus())},this.abortController),this.containerEl.focus()}removeKeyboardEvents(){var e;(e=this.abortController)==null||e.abort(),this.abortController=void 0}render(){const e={"wcm-overlay":!0,"wcm-active":this.active};return u`
${this.open?u`
`:null}
`}};Zt.styles=[A.globalCss,sl];Eo([H()],Zt.prototype,"open",2);Eo([H()],Zt.prototype,"active",2);Zt=Eo([P("wcm-modal")],Zt);const cl=I`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`;var dl=Object.defineProperty,hl=Object.getOwnPropertyDescriptor,Jt=(e,t,o,n)=>{for(var r=n>1?void 0:n?hl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&dl(t,o,r),r};let pt=class extends E{constructor(){super(...arguments),this.isMobile=!1,this.isDesktop=!1,this.isWeb=!1,this.isRetry=!1}onMobile(){$.isMobile()?N.replace("MobileConnecting"):N.replace("MobileQrcodeConnecting")}onDesktop(){N.replace("DesktopConnecting")}onWeb(){N.replace("WebConnecting")}render(){return u`
${this.isRetry?u``:null} ${this.isMobile?u`Mobile`:null} ${this.isDesktop?u`Desktop`:null} ${this.isWeb?u`Web`:null}
`}};pt.styles=[A.globalCss,cl];Jt([_({type:Boolean})],pt.prototype,"isMobile",2);Jt([_({type:Boolean})],pt.prototype,"isDesktop",2);Jt([_({type:Boolean})],pt.prototype,"isWeb",2);Jt([_({type:Boolean})],pt.prototype,"isRetry",2);pt=Jt([P("wcm-platform-selection")],pt);const ul=I`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var ml=Object.defineProperty,fl=Object.getOwnPropertyDescriptor,pl=(e,t,o,n)=>{for(var r=n>1?void 0:n?fl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&ml(t,o,r),r};let lo=class extends E{onClick(){N.push("WalletExplorer")}render(){const{recomendedWallets:e}=k.state,t=yt.manualWallets(),o=[...e,...t].reverse().slice(0,4);return u``}};lo.styles=[A.globalCss,ul];lo=pl([P("wcm-view-all-wallets-button")],lo);const gl=I`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`;var wl=Object.defineProperty,vl=Object.getOwnPropertyDescriptor,xe=(e,t,o,n)=>{for(var r=n>1?void 0:n?vl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&wl(t,o,r),r};let Tt=class extends E{constructor(){super(),this.walletId="",this.imageId="",this.uri="",setTimeout(()=>{const{walletConnectUri:e}=Z.state;this.uri=e},0)}get overlayEl(){return x.getShadowRootElement(this,".wcm-qr-container")}render(){return u`
${this.uri?u``:u``}
`}};Tt.styles=[A.globalCss,gl];xe([_()],Tt.prototype,"walletId",2);xe([_()],Tt.prototype,"imageId",2);xe([H()],Tt.prototype,"uri",2);Tt=xe([P("wcm-walletconnect-qr")],Tt);var bl=Object.defineProperty,yl=Object.getOwnPropertyDescriptor,$l=(e,t,o,n)=>{for(var r=n>1?void 0:n?yl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&bl(t,o,r),r};let ao=class extends E{viewTemplate(){return $.isAndroid()&&!$.isTelegram()?u``:$.isMobile()?u``:u``}render(){return u`${this.viewTemplate()}`}};ao.styles=[A.globalCss];ao=$l([P("wcm-connect-wallet-view")],ao);const xl=I`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var _l=Object.defineProperty,Cl=Object.getOwnPropertyDescriptor,Rr=(e,t,o,n)=>{for(var r=n>1?void 0:n?Cl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&_l(t,o,r),r};let me=class extends E{constructor(){super(),this.isError=!1,this.openDesktopApp()}onFormatAndRedirect(e){const{desktop:t,name:o}=$.getWalletRouterData(),n=t==null?void 0:t.native,r=t==null?void 0:t.universal;if(n){const i=$.formatNativeUrl(n,e,o);$.openHref(i,"_self")}else if(r){const i=$.formatUniversalUrl(r,e,o);$.openHref(i,"_blank")}}openDesktopApp(){const{walletConnectUri:e}=Z.state,t=$.getWalletRouterData();x.setRecentWallet(t),e&&this.onFormatAndRedirect(e)}render(){const{name:e,id:t,image_id:o}=$.getWalletRouterData(),{isMobile:n,isWeb:r}=x.getCachedRouterWalletPlatforms();return u`${`Connection can continue loading if ${e} is not installed on your device`}Retry`}};me.styles=[A.globalCss,xl];Rr([H()],me.prototype,"isError",2);me=Rr([P("wcm-desktop-connecting-view")],me);const El=I`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`;var Al=Object.defineProperty,Ol=Object.getOwnPropertyDescriptor,Pl=(e,t,o,n)=>{for(var r=n>1?void 0:n?Ol(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Al(t,o,r),r};let co=class extends E{onInstall(e){e&&$.openHref(e,"_blank")}render(){const{name:e,id:t,image_id:o,homepage:n}=$.getWalletRouterData();return u`${`Download ${e} to continue. If multiple browser extensions are installed, disable non ${e} ones and try again`}Download`}};co.styles=[A.globalCss,El];co=Pl([P("wcm-install-wallet-view")],co);const Il=I`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`;var Tl=Object.defineProperty,Ml=Object.getOwnPropertyDescriptor,Dr=(e,t,o,n)=>{for(var r=n>1?void 0:n?Ml(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Tl(t,o,r),r};let fe=class extends E{constructor(){super(),this.isError=!1,this.openMobileApp()}onFormatAndRedirect(e,t=!1){const{mobile:o,name:n}=$.getWalletRouterData(),r=o==null?void 0:o.native,i=o==null?void 0:o.universal,s=$.isTelegram()?"_blank":"_self";if(e=$.isTelegram()&&$.isAndroid()?encodeURIComponent(e):e,r&&!t){const l=$.formatNativeUrl(r,e,n);$.openHref(l,s)}else if(i){const l=$.formatUniversalUrl(i,e,n);$.openHref(l,s)}}openMobileApp(e=!1){const{walletConnectUri:t}=Z.state,o=$.getWalletRouterData();t&&this.onFormatAndRedirect(t,e),x.setRecentWallet(o)}onGoToAppStore(e){e&&$.openHref(e,"_blank")}render(){const{name:e,id:t,image_id:o,app:n,mobile:r}=$.getWalletRouterData(),{isWeb:i}=x.getCachedRouterWalletPlatforms(),s=n==null?void 0:n.ios,l=r==null?void 0:r.universal;return u`Retry${l?u`Still doesn't work? Try this alternate link`:null}
${`Get ${e}`}
App Store
`}};fe.styles=[A.globalCss,Il];Dr([H()],fe.prototype,"isError",2);fe=Dr([P("wcm-mobile-connecting-view")],fe);const Sl=I`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var Rl=Object.defineProperty,Dl=Object.getOwnPropertyDescriptor,Ll=(e,t,o,n)=>{for(var r=n>1?void 0:n?Dl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Rl(t,o,r),r};let ho=class extends E{render(){const{name:e,id:t,image_id:o}=$.getWalletRouterData(),{isDesktop:n,isWeb:r}=x.getCachedRouterWalletPlatforms();return u`${`Scan this QR Code with your phone's camera or inside ${e} app`}`}};ho.styles=[A.globalCss,Sl];ho=Ll([P("wcm-mobile-qr-connecting-view")],ho);var Nl=Object.defineProperty,Bl=Object.getOwnPropertyDescriptor,Wl=(e,t,o,n)=>{for(var r=n>1?void 0:n?Bl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&Nl(t,o,r),r};let uo=class extends E{render(){return u``}};uo.styles=[A.globalCss];uo=Wl([P("wcm-qrcode-view")],uo);const Ul=I`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`;var jl=Object.defineProperty,kl=Object.getOwnPropertyDescriptor,Qt=(e,t,o,n)=>{for(var r=n>1?void 0:n?kl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&jl(t,o,r),r};const je=40;let gt=class extends E{constructor(){super(...arguments),this.loading=!k.state.wallets.listings.length,this.firstFetch=!k.state.wallets.listings.length,this.search="",this.endReached=!1,this.intersectionObserver=void 0,this.searchDebounce=x.debounce(e=>{e.length>=1?(this.firstFetch=!0,this.endReached=!1,this.search=e,k.resetSearch(),this.fetchWallets()):this.search&&(this.search="",this.endReached=this.isLastPage(),k.resetSearch())})}firstUpdated(){this.createPaginationObserver()}disconnectedCallback(){var e;(e=this.intersectionObserver)==null||e.disconnect()}get placeholderEl(){return x.getShadowRootElement(this,".wcm-placeholder-block")}createPaginationObserver(){this.intersectionObserver=new IntersectionObserver(([e])=>{e.isIntersecting&&!(this.search&&this.firstFetch)&&this.fetchWallets()}),this.intersectionObserver.observe(this.placeholderEl)}isLastPage(){const{wallets:e,search:t}=k.state,{listings:o,total:n}=this.search?t:e;return n<=je||o.length>=n}async fetchWallets(){var e;const{wallets:t,search:o}=k.state,{listings:n,total:r,page:i}=this.search?o:t;if(!this.endReached&&(this.firstFetch||r>je&&n.lengthx.getWalletIcon(c));await Promise.all([...a.map(async c=>x.preloadImage(c)),$.wait(300)]),this.endReached=this.isLastPage()}catch(s){console.error(s),X.openToast(x.getErrorMessage(s),"error")}finally{this.loading=!1,this.firstFetch=!1}}onConnect(e){$.isAndroid()?x.handleMobileLinking(e):x.goToConnectingView(e)}onSearchChange(e){const{value:t}=e.target;this.searchDebounce(t)}render(){const{wallets:e,search:t}=k.state,{listings:o}=this.search?t:e,n=this.loading&&!o.length,r=this.search.length>=3;let i=ot.manualWalletsTemplate(),s=ot.recomendedWalletsTemplate(!0);r&&(i=i.filter(({values:c})=>x.caseSafeIncludes(c[0],this.search)),s=s.filter(({values:c})=>x.caseSafeIncludes(c[0],this.search)));const l=!this.loading&&!o.length&&!s.length,a={"wcm-loading":n,"wcm-end-reached":this.endReached||!this.loading,"wcm-empty":l};return u`
${n?null:i} ${n?null:s} ${n?null:o.map(c=>u`${c?u``:null}`)}
${l?u`No results found`:null} ${!l&&this.loading?u``:null}
`}};gt.styles=[A.globalCss,Ul];Qt([H()],gt.prototype,"loading",2);Qt([H()],gt.prototype,"firstFetch",2);Qt([H()],gt.prototype,"search",2);Qt([H()],gt.prototype,"endReached",2);gt=Qt([P("wcm-wallet-explorer-view")],gt);const Hl=I`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var zl=Object.defineProperty,Fl=Object.getOwnPropertyDescriptor,Lr=(e,t,o,n)=>{for(var r=n>1?void 0:n?Fl(t,o):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=(n?s(t,o,r):s(r))||r);return n&&r&&zl(t,o,r),r};let pe=class extends E{constructor(){super(),this.isError=!1,this.openWebWallet()}onFormatAndRedirect(e){const{desktop:t,name:o}=$.getWalletRouterData(),n=t==null?void 0:t.universal;if(n){const r=$.formatUniversalUrl(n,e,o);$.openHref(r,"_blank")}}openWebWallet(){const{walletConnectUri:e}=Z.state,t=$.getWalletRouterData();x.setRecentWallet(t),e&&this.onFormatAndRedirect(e)}render(){const{name:e,id:t,image_id:o}=$.getWalletRouterData(),{isMobile:n,isDesktop:r}=x.getCachedRouterWalletPlatforms(),i=$.isMobile();return u`${`${e} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`}};pe.styles=[A.globalCss,Hl];Lr([H()],pe.prototype,"isError",2);pe=Lr([P("wcm-web-connecting-view")],pe);export{Zt as WcmModal,nt as WcmQrCode}; +`);const s=Ai(t,r,o),l=ye.getSymbolSize(t),a=new pi(l);return $i(a,t),xi(a),_i(a,t),Ne(a,r,0),t>=7&&Ci(a,t),Ei(a,s),isNaN(n)&&(n=qe.getBestMask(a,Ne.bind(null,a,r))),qe.applyMask(n,a),Ne(a,r,n),{modules:a,version:t,errorCorrectionLevel:r,maskPattern:n,segments:o}}po.create=function(t,r){if(typeof t>"u"||t==="")throw new Error("No input text");let n=De.M,o,i;return typeof r<"u"&&(n=De.from(r.errorCorrectionLevel,De.M),o=de.from(r.version),i=qe.from(r.maskPattern),r.toSJISFunc&&ye.setToSJISFunction(r.toSJISFunc)),Pi(t,o,n,i)};var Oo={},br={};(function(e){function t(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let n=r.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+r);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(i){return[i,i]}))),n.length===6&&n.push("F","F");const o=parseInt(n.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+n.slice(0,6).join("")}}e.getOptions=function(n){n||(n={}),n.color||(n.color={});const o=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,i=n.width&&n.width>=21?n.width:void 0,s=n.scale||4;return{width:i,scale:i?4:s,margin:o,color:{dark:t(n.color.dark||"#000000ff"),light:t(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},e.getScale=function(n,o){return o.width&&o.width>=n+o.margin*2?o.width/(n+o.margin*2):o.scale},e.getImageWidth=function(n,o){const i=e.getScale(n,o);return Math.floor((n+o.margin*2)*i)},e.qrToImageData=function(n,o,i){const s=o.modules.size,l=o.modules.data,a=e.getScale(s,i),c=Math.floor((s+i.margin*2)*a),d=i.margin*a,y=[i.color.light,i.color.dark];for(let h=0;h=d&&p>=d&&h"u"&&(!s||!s.getContext)&&(a=s,s=void 0),s||(c=n()),a=t.getOptions(a);const d=t.getImageWidth(i.modules.size,a),y=c.getContext("2d"),h=y.createImageData(d,d);return t.qrToImageData(h.data,i,a),r(y,c,d),y.putImageData(h,0,0),c},e.renderToDataURL=function(i,s,l){let a=l;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),a||(a={});const c=e.render(i,s,a),d=a.type||"image/png",y=a.rendererOpts||{};return c.toDataURL(d,y.quality)}})(Oo);var Po={};const Ii=br;function Fr(e,t){const r=e.a/255,n=t+'="'+e.hex+'"';return r<1?n+" "+t+'-opacity="'+r.toFixed(2).slice(1)+'"':n}function Be(e,t,r){let n=e+t;return typeof r<"u"&&(n+=" "+r),n}function Ti(e,t,r){let n="",o=0,i=!1,s=0;for(let l=0;l0&&a>0&&e[l-1]||(n+=i?Be("M",a+r,.5+c+r):Be("m",o,0),o=0,i=!1),a+1':"",c="',d='viewBox="0 0 '+l+" "+l+'"',h=''+a+c+` +`;return typeof n=="function"&&n(null,h),h};const Mi=Vn,Ge=po,Io=Oo,Si=Po;function yr(e,t,r,n,o){const i=[].slice.call(arguments,1),s=i.length,l=typeof i[s-1]=="function";if(!l&&!Mi())throw new Error("Callback required as last argument");if(l){if(s<2)throw new Error("Too few arguments provided");s===2?(o=r,r=t,t=n=void 0):s===3&&(t.getContext&&typeof o>"u"?(o=n,n=void 0):(o=n,n=r,r=t,t=void 0))}else{if(s<1)throw new Error("Too few arguments provided");return s===1?(r=t,t=n=void 0):s===2&&!t.getContext&&(n=r,r=t,t=void 0),new Promise(function(a,c){try{const d=Ge.create(r,n);a(e(d,t,n))}catch(d){c(d)}})}try{const a=Ge.create(r,n);o(null,e(a,t,n))}catch(a){o(a)}}qt.create=Ge.create;qt.toCanvas=yr.bind(null,Io.render);qt.toDataURL=yr.bind(null,Io.renderToDataURL);qt.toString=yr.bind(null,function(e,t,r){return Si.render(e,r)});var Ri=Object.defineProperty,Vr=Object.getOwnPropertySymbols,Di=Object.prototype.hasOwnProperty,Li=Object.prototype.propertyIsEnumerable,Zr=(e,t,r)=>t in e?Ri(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,We=(e,t)=>{for(var r in t||(t={}))Di.call(t,r)&&Zr(e,r,t[r]);if(Vr)for(var r of Vr(t))Li.call(t,r)&&Zr(e,r,t[r]);return e};function Ni(){var e;const t=(e=$t.state.themeMode)!=null?e:"dark",n={light:{foreground:{1:"rgb(20,20,20)",2:"rgb(121,134,134)",3:"rgb(158,169,169)"},background:{1:"rgb(255,255,255)",2:"rgb(241,243,243)",3:"rgb(228,231,231)"},overlay:"rgba(0,0,0,0.1)"},dark:{foreground:{1:"rgb(228,231,231)",2:"rgb(148,158,158)",3:"rgb(110,119,119)"},background:{1:"rgb(20,20,20)",2:"rgb(39,42,42)",3:"rgb(59,64,64)"},overlay:"rgba(255,255,255,0.1)"}}[t];return{"--wcm-color-fg-1":n.foreground[1],"--wcm-color-fg-2":n.foreground[2],"--wcm-color-fg-3":n.foreground[3],"--wcm-color-bg-1":n.background[1],"--wcm-color-bg-2":n.background[2],"--wcm-color-bg-3":n.background[3],"--wcm-color-overlay":n.overlay}}function Kr(){return{"--wcm-accent-color":"#3396FF","--wcm-accent-fill-color":"#FFFFFF","--wcm-z-index":"89","--wcm-background-color":"#3396FF","--wcm-background-border-radius":"8px","--wcm-container-border-radius":"30px","--wcm-wallet-icon-border-radius":"15px","--wcm-wallet-icon-large-border-radius":"30px","--wcm-wallet-icon-small-border-radius":"7px","--wcm-input-border-radius":"28px","--wcm-button-border-radius":"10px","--wcm-notification-border-radius":"36px","--wcm-secondary-button-border-radius":"28px","--wcm-icon-button-border-radius":"50%","--wcm-button-hover-highlight-border-radius":"10px","--wcm-text-big-bold-size":"20px","--wcm-text-big-bold-weight":"600","--wcm-text-big-bold-line-height":"24px","--wcm-text-big-bold-letter-spacing":"-0.03em","--wcm-text-big-bold-text-transform":"none","--wcm-text-xsmall-bold-size":"10px","--wcm-text-xsmall-bold-weight":"700","--wcm-text-xsmall-bold-line-height":"12px","--wcm-text-xsmall-bold-letter-spacing":"0.02em","--wcm-text-xsmall-bold-text-transform":"uppercase","--wcm-text-xsmall-regular-size":"12px","--wcm-text-xsmall-regular-weight":"600","--wcm-text-xsmall-regular-line-height":"14px","--wcm-text-xsmall-regular-letter-spacing":"-0.03em","--wcm-text-xsmall-regular-text-transform":"none","--wcm-text-small-thin-size":"14px","--wcm-text-small-thin-weight":"500","--wcm-text-small-thin-line-height":"16px","--wcm-text-small-thin-letter-spacing":"-0.03em","--wcm-text-small-thin-text-transform":"none","--wcm-text-small-regular-size":"14px","--wcm-text-small-regular-weight":"600","--wcm-text-small-regular-line-height":"16px","--wcm-text-small-regular-letter-spacing":"-0.03em","--wcm-text-small-regular-text-transform":"none","--wcm-text-medium-regular-size":"16px","--wcm-text-medium-regular-weight":"600","--wcm-text-medium-regular-line-height":"20px","--wcm-text-medium-regular-letter-spacing":"-0.03em","--wcm-text-medium-regular-text-transform":"none","--wcm-font-family":"-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif","--wcm-font-feature-settings":"'tnum' on, 'lnum' on, 'case' on","--wcm-success-color":"rgb(38,181,98)","--wcm-error-color":"rgb(242, 90, 103)","--wcm-overlay-background-color":"rgba(0, 0, 0, 0.3)","--wcm-overlay-backdrop-filter":"none"}}const A={getPreset(e){return Kr()[e]},setTheme(){const e=document.querySelector(":root"),{themeVariables:t}=$t.state;if(e){const r=We(We(We({},Ni()),Kr()),t);Object.entries(r).forEach(([n,o])=>e.style.setProperty(n,o))}},globalCss:I`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}`},Bi=I`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`;var Wi=Object.defineProperty,Ui=Object.getOwnPropertyDescriptor,Mt=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ui(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Wi(t,r,o),o};let ot=class extends E{constructor(){super(...arguments),this.disabled=!1,this.iconLeft=void 0,this.iconRight=void 0,this.onClick=()=>null,this.variant="default"}render(){const e={"wcm-icon-left":this.iconLeft!==void 0,"wcm-icon-right":this.iconRight!==void 0,"wcm-ghost":this.variant==="ghost","wcm-outline":this.variant==="outline"};let t="inverse";return this.variant==="ghost"&&(t="secondary"),this.variant==="outline"&&(t="accent"),u``}};ot.styles=[A.globalCss,Bi];Mt([_({type:Boolean})],ot.prototype,"disabled",2);Mt([_()],ot.prototype,"iconLeft",2);Mt([_()],ot.prototype,"iconRight",2);Mt([_()],ot.prototype,"onClick",2);Mt([_()],ot.prototype,"variant",2);ot=Mt([P("wcm-button")],ot);const ji=I`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`;var ki=Object.defineProperty,Hi=Object.getOwnPropertyDescriptor,$r=(e,t,r,n)=>{for(var o=n>1?void 0:n?Hi(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ki(t,r,o),o};let zt=class extends E{constructor(){super(...arguments),this.disabled=!1,this.variant="primary"}render(){const e={"wcm-secondary":this.variant==="secondary"};return u``}};zt.styles=[A.globalCss,ji];$r([_({type:Boolean})],zt.prototype,"disabled",2);$r([_()],zt.prototype,"variant",2);zt=$r([P("wcm-button-big")],zt);const zi=I`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`;var Fi=Object.defineProperty,Vi=Object.getOwnPropertyDescriptor,Zi=(e,t,r,n)=>{for(var o=n>1?void 0:n?Vi(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Fi(t,r,o),o};let Je=class extends E{render(){return u`
`}};Je.styles=[A.globalCss,zi];Je=Zi([P("wcm-info-footer")],Je);const T={CROSS_ICON:L``,WALLET_CONNECT_LOGO:L``,WALLET_CONNECT_ICON:L``,WALLET_CONNECT_ICON_COLORED:L``,BACK_ICON:L``,COPY_ICON:L``,RETRY_ICON:L``,DESKTOP_ICON:L``,MOBILE_ICON:L``,ARROW_DOWN_ICON:L``,ARROW_UP_RIGHT_ICON:L``,ARROW_RIGHT_ICON:L``,QRCODE_ICON:L``,SCAN_ICON:L``,CHECKMARK_ICON:L``,SEARCH_ICON:L``,WALLET_PLACEHOLDER:L``,GLOBE_ICON:L``},Ki=I`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`;var qi=Object.defineProperty,Yi=Object.getOwnPropertyDescriptor,Gi=(e,t,r,n)=>{for(var o=n>1?void 0:n?Yi(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&qi(t,r,o),o};let Qe=class extends E{render(){return u`
${T.WALLET_CONNECT_LOGO}
`}};Qe.styles=[A.globalCss,Ki];Qe=Gi([P("wcm-modal-backcard")],Qe);const Ji=I`main{padding:20px;padding-top:0;width:100%}`;var Qi=Object.defineProperty,Xi=Object.getOwnPropertyDescriptor,ts=(e,t,r,n)=>{for(var o=n>1?void 0:n?Xi(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Qi(t,r,o),o};let Xe=class extends E{render(){return u`
`}};Xe.styles=[A.globalCss,Ji];Xe=ts([P("wcm-modal-content")],Xe);const es=I`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`;var rs=Object.defineProperty,os=Object.getOwnPropertyDescriptor,ns=(e,t,r,n)=>{for(var o=n>1?void 0:n?os(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&rs(t,r,o),o};let tr=class extends E{render(){return u`
`}};tr.styles=[A.globalCss,es];tr=ns([P("wcm-modal-footer")],tr);const is=I`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`;var ss=Object.defineProperty,ls=Object.getOwnPropertyDescriptor,Gt=(e,t,r,n)=>{for(var o=n>1?void 0:n?ls(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ss(t,r,o),o};let ft=class extends E{constructor(){super(...arguments),this.title="",this.onAction=void 0,this.actionIcon=void 0,this.border=!1}backBtnTemplate(){return u``}actionBtnTemplate(){return u``}render(){const e={"wcm-border":this.border},t=N.state.history.length>1,r=this.title?u`${this.title}`:u``;return u`
${t?this.backBtnTemplate():null} ${r} ${this.onAction?this.actionBtnTemplate():null}
`}};ft.styles=[A.globalCss,is];Gt([_()],ft.prototype,"title",2);Gt([_()],ft.prototype,"onAction",2);Gt([_()],ft.prototype,"actionIcon",2);Gt([_({type:Boolean})],ft.prototype,"border",2);ft=Gt([P("wcm-modal-header")],ft);const x={MOBILE_BREAKPOINT:600,WCM_RECENT_WALLET_DATA:"WCM_RECENT_WALLET_DATA",EXPLORER_WALLET_URL:"https://explorer.walletconnect.com/?type=wallet",getShadowRootElement(e,t){const r=e.renderRoot.querySelector(t);if(!r)throw new Error(`${t} not found`);return r},getWalletIcon({id:e,image_id:t}){const{walletImages:r}=ht.state;return r!=null&&r[e]?r[e]:t?k.getWalletImageUrl(t):""},getWalletName(e,t=!1){return t&&e.length>8?`${e.substring(0,8)}..`:e},isMobileAnimation(){return window.innerWidth<=x.MOBILE_BREAKPOINT},async preloadImage(e){const t=new Promise((r,n)=>{const o=new Image;o.onload=r,o.onerror=n,o.crossOrigin="anonymous",o.src=e});return Promise.race([t,$.wait(3e3)])},getErrorMessage(e){return e instanceof Error?e.message:"Unknown Error"},debounce(e,t=500){let r;return(...n)=>{function o(){e(...n)}r&&clearTimeout(r),r=setTimeout(o,t)}},handleMobileLinking(e,t="_self"){const{walletConnectUri:r}=Z.state,{mobile:n,name:o}=e,i=n==null?void 0:n.native,s=n==null?void 0:n.universal;x.setRecentWallet(e);function l(a){if(i){const c=$.formatNativeUrl(i,a,o);$.openHref(c,t)}else if(s){const c=$.formatUniversalUrl(s,a,o);$.openHref(c,t)}}r&&l(r)},handleAndroidLinking(){const{walletConnectUri:e}=Z.state;e&&($.setWalletConnectAndroidDeepLink(e),$.openHref(e,$.isTelegram()?"_blank":"_self"))},async handleUriCopy(){const{walletConnectUri:e}=Z.state;if(e)try{await navigator.clipboard.writeText(e),X.openToast("Link copied","success")}catch{X.openToast("Failed to copy","error")}},getCustomImageUrls(){const{walletImages:e}=ht.state,t=Object.values(e??{});return Object.values(t)},truncate(e,t=8){return e.length<=t?e:`${e.substring(0,4)}...${e.substring(e.length-4)}`},setRecentWallet(e){try{localStorage.setItem(x.WCM_RECENT_WALLET_DATA,JSON.stringify(e))}catch{console.info("Unable to set recent wallet")}},getRecentWallet(){try{const e=localStorage.getItem(x.WCM_RECENT_WALLET_DATA);return e?JSON.parse(e):void 0}catch{console.info("Unable to get recent wallet")}},caseSafeIncludes(e,t){return e.toUpperCase().includes(t.toUpperCase())},openWalletExplorerUrl(){$.openHref(x.EXPLORER_WALLET_URL,"_blank")},getCachedRouterWalletPlatforms(){const{desktop:e,mobile:t}=$.getWalletRouterData(),r=!!(e!=null&&e.native),n=!!(e!=null&&e.universal),o=!!(t!=null&&t.native)||!!(t!=null&&t.universal);return{isDesktop:r,isMobile:o,isWeb:n}},goToConnectingView(e){N.setData({Wallet:e});const t=$.isMobile(),{isDesktop:r,isWeb:n,isMobile:o}=x.getCachedRouterWalletPlatforms();t?o?(N.push("MobileConnecting"),!$.isAndroid()&&$.isTelegram()&&this.handleMobileLinking(e,"_blank")):n?N.push("WebConnecting"):N.push("InstallWallet"):r?N.push("DesktopConnecting"):n?N.push("WebConnecting"):o?N.push("MobileQrcodeConnecting"):N.push("InstallWallet")}},as=I`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`;var cs=Object.defineProperty,ds=Object.getOwnPropertyDescriptor,xr=(e,t,r,n)=>{for(var o=n>1?void 0:n?ds(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&cs(t,r,o),o};let Ft=class extends E{constructor(){super(),this.view=N.state.view,this.prevView=N.state.view,this.unsubscribe=void 0,this.oldHeight="0px",this.resizeObserver=void 0,this.unsubscribe=N.subscribe(e=>{this.view!==e.view&&this.onChangeRoute()})}firstUpdated(){this.resizeObserver=new ResizeObserver(([e])=>{const t=`${e.contentRect.height}px`;this.oldHeight!=="0px"&&dt(this.routerEl,{height:[this.oldHeight,t]},{duration:.2}),this.oldHeight=t}),this.resizeObserver.observe(this.contentEl)}disconnectedCallback(){var e,t;(e=this.unsubscribe)==null||e.call(this),(t=this.resizeObserver)==null||t.disconnect()}get routerEl(){return x.getShadowRootElement(this,".wcm-router")}get contentEl(){return x.getShadowRootElement(this,".wcm-content")}viewTemplate(){switch(this.view){case"ConnectWallet":return u``;case"DesktopConnecting":return u``;case"MobileConnecting":return u``;case"WebConnecting":return u``;case"MobileQrcodeConnecting":return u``;case"WalletExplorer":return u``;case"Qrcode":return u``;case"InstallWallet":return u``;default:return u`
Not Found
`}}async onChangeRoute(){await dt(this.routerEl,{opacity:[1,0],scale:[1,1.02]},{duration:.15,delay:.1}).finished,this.view=N.state.view,dt(this.routerEl,{opacity:[0,1],scale:[.99,1]},{duration:.37,delay:.05})}render(){return u`
${this.viewTemplate()}
`}};Ft.styles=[A.globalCss,as];xr([H()],Ft.prototype,"view",2);xr([H()],Ft.prototype,"prevView",2);Ft=xr([P("wcm-modal-router")],Ft);const hs=I`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`;var us=Object.defineProperty,ms=Object.getOwnPropertyDescriptor,To=(e,t,r,n)=>{for(var o=n>1?void 0:n?ms(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&us(t,r,o),o};let he=class extends E{constructor(){super(),this.open=!1,this.unsubscribe=void 0,this.timeout=void 0,this.unsubscribe=X.subscribe(e=>{e.open?(this.open=!0,this.timeout=setTimeout(()=>X.closeToast(),2200)):(this.open=!1,clearTimeout(this.timeout))})}disconnectedCallback(){var e;(e=this.unsubscribe)==null||e.call(this),clearTimeout(this.timeout),X.closeToast()}render(){const{message:e,variant:t}=X.state,r={"wcm-success":t==="success","wcm-error":t==="error"};return this.open?u`
${t==="success"?T.CHECKMARK_ICON:null} ${t==="error"?T.CROSS_ICON:null}${e}
`:null}};he.styles=[A.globalCss,hs];To([H()],he.prototype,"open",2);he=To([P("wcm-modal-toast")],he);const fs=.1,qr=2.5,G=7;function Ue(e,t,r){return e===t?!1:(e-t<0?t-e:e-t)<=r+fs}function ps(e,t){const r=Array.prototype.slice.call(qt.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(r.length);return r.reduce((o,i,s)=>(s%n===0?o.push([i]):o[o.length-1].push(i))&&o,[])}const gs={generate(e,t,r){const n="#141414",o="#ffffff",i=[],s=ps(e,"Q"),l=t/s.length,a=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];a.forEach(({x:g,y:f})=>{const O=(s.length-G)*l*g,m=(s.length-G)*l*f,b=.45;for(let w=0;w`)}});const c=Math.floor((r+25)/l),d=s.length/2-c/2,y=s.length/2+c/2-1,h=[];s.forEach((g,f)=>{g.forEach((O,m)=>{if(s[f][m]&&!(fs.length-(G+1)&&ms.length-(G+1))&&!(f>d&&fd&&m{p[g]?p[g].push(f):p[g]=[f]}),Object.entries(p).map(([g,f])=>{const O=f.filter(m=>f.every(b=>!Ue(m,b,l)));return[Number(g),O]}).forEach(([g,f])=>{f.forEach(O=>{i.push(L``)})}),Object.entries(p).filter(([g,f])=>f.length>1).map(([g,f])=>{const O=f.filter(m=>f.some(b=>Ue(m,b,l)));return[Number(g),O]}).map(([g,f])=>{f.sort((m,b)=>mw.some(v=>Ue(m,v,l)));b?b.push(m):O.push([m])}return[g,O.map(m=>[m[0],m[m.length-1]])]}).forEach(([g,f])=>{f.forEach(([O,m])=>{i.push(L``)})}),i}},ws=I`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`;var vs=Object.defineProperty,bs=Object.getOwnPropertyDescriptor,St=(e,t,r,n)=>{for(var o=n>1?void 0:n?bs(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&vs(t,r,o),o};let nt=class extends E{constructor(){super(...arguments),this.uri="",this.size=0,this.imageId=void 0,this.walletId=void 0,this.imageUrl=void 0}svgTemplate(){const t=$t.state.themeMode==="light"?this.size:this.size-18*2;return L`${gs.generate(this.uri,t,t/4)}`}render(){const e={"wcm-dark":$t.state.themeMode==="dark"};return u`
${this.walletId||this.imageUrl?u``:T.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`}};nt.styles=[A.globalCss,ws];St([_()],nt.prototype,"uri",2);St([_({type:Number})],nt.prototype,"size",2);St([_()],nt.prototype,"imageId",2);St([_()],nt.prototype,"walletId",2);St([_()],nt.prototype,"imageUrl",2);nt=St([P("wcm-qrcode")],nt);const ys=I`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`;var $s=Object.defineProperty,xs=Object.getOwnPropertyDescriptor,Mo=(e,t,r,n)=>{for(var o=n>1?void 0:n?xs(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&$s(t,r,o),o};let ue=class extends E{constructor(){super(...arguments),this.onChange=()=>null}render(){return u` ${T.SEARCH_ICON}`}};ue.styles=[A.globalCss,ys];Mo([_()],ue.prototype,"onChange",2);ue=Mo([P("wcm-search-input")],ue);const _s=I`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`;var Cs=Object.defineProperty,Es=Object.getOwnPropertyDescriptor,As=(e,t,r,n)=>{for(var o=n>1?void 0:n?Es(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Cs(t,r,o),o};let er=class extends E{render(){return u``}};er.styles=[A.globalCss,_s];er=As([P("wcm-spinner")],er);const Os=I`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`;var Ps=Object.defineProperty,Is=Object.getOwnPropertyDescriptor,_r=(e,t,r,n)=>{for(var o=n>1?void 0:n?Is(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Ps(t,r,o),o};let Vt=class extends E{constructor(){super(...arguments),this.variant="medium-regular",this.color="primary"}render(){const e={"wcm-big-bold":this.variant==="big-bold","wcm-medium-regular":this.variant==="medium-regular","wcm-small-regular":this.variant==="small-regular","wcm-small-thin":this.variant==="small-thin","wcm-xsmall-regular":this.variant==="xsmall-regular","wcm-xsmall-bold":this.variant==="xsmall-bold","wcm-color-primary":this.color==="primary","wcm-color-secondary":this.color==="secondary","wcm-color-tertiary":this.color==="tertiary","wcm-color-inverse":this.color==="inverse","wcm-color-accnt":this.color==="accent","wcm-color-error":this.color==="error"};return u``}};Vt.styles=[A.globalCss,Os];_r([_()],Vt.prototype,"variant",2);_r([_()],Vt.prototype,"color",2);Vt=_r([P("wcm-text")],Vt);const Ts=I`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`;var Ms=Object.defineProperty,Ss=Object.getOwnPropertyDescriptor,lt=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ss(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Ms(t,r,o),o};let K=class extends E{constructor(){super(...arguments),this.onClick=()=>null,this.name="",this.walletId="",this.label=void 0,this.imageId=void 0,this.installed=!1,this.recent=!1}sublabelTemplate(){return this.recent?u`RECENT`:this.installed?u`INSTALLED`:null}handleClick(){Bo.click({name:"WALLET_BUTTON",walletId:this.walletId}),this.onClick()}render(){var e;return u``}};K.styles=[A.globalCss,Ts];lt([_()],K.prototype,"onClick",2);lt([_()],K.prototype,"name",2);lt([_()],K.prototype,"walletId",2);lt([_()],K.prototype,"label",2);lt([_()],K.prototype,"imageId",2);lt([_({type:Boolean})],K.prototype,"installed",2);lt([_({type:Boolean})],K.prototype,"recent",2);K=lt([P("wcm-wallet-button")],K);const Rs=I`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var Ds=Object.defineProperty,Ls=Object.getOwnPropertyDescriptor,$e=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ls(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Ds(t,r,o),o};let It=class extends E{constructor(){super(...arguments),this.walletId="",this.imageId=void 0,this.imageUrl=void 0}render(){var e;const t=(e=this.imageUrl)!=null&&e.length?this.imageUrl:x.getWalletIcon({id:this.walletId,image_id:this.imageId});return u`${t.length?u`
${this.id}
`:T.WALLET_PLACEHOLDER}`}};It.styles=[A.globalCss,Rs];$e([_()],It.prototype,"walletId",2);$e([_()],It.prototype,"imageId",2);$e([_()],It.prototype,"imageUrl",2);It=$e([P("wcm-wallet-image")],It);var Ns=Object.defineProperty,Bs=Object.getOwnPropertyDescriptor,So=(e,t,r,n)=>{for(var o=n>1?void 0:n?Bs(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Ns(t,r,o),o};let rr=class extends E{constructor(){super(),this.preload=!0,this.preloadData()}async loadImages(e){try{e!=null&&e.length&&await Promise.all(e.map(async t=>x.preloadImage(t)))}catch{console.info("Unsuccessful attempt at preloading some images",e)}}async preloadListings(){if(ht.state.enableExplorer){await k.getRecomendedWallets(),Z.setIsDataLoaded(!0);const{recomendedWallets:e}=k.state,t=e.map(r=>x.getWalletIcon(r));await this.loadImages(t)}else Z.setIsDataLoaded(!0)}async preloadCustomImages(){const e=x.getCustomImageUrls();await this.loadImages(e)}async preloadData(){try{this.preload&&(this.preload=!1,await Promise.all([this.preloadListings(),this.preloadCustomImages()]))}catch(e){console.error(e),X.openToast("Failed preloading","error")}}};So([H()],rr.prototype,"preload",2);rr=So([P("wcm-explorer-context")],rr);var Ws=Object.defineProperty,Us=Object.getOwnPropertyDescriptor,js=(e,t,r,n)=>{for(var o=n>1?void 0:n?Us(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Ws(t,r,o),o};let Yr=class extends E{constructor(){super(),this.unsubscribeTheme=void 0,A.setTheme(),this.unsubscribeTheme=$t.subscribe(A.setTheme)}disconnectedCallback(){var e;(e=this.unsubscribeTheme)==null||e.call(this)}};Yr=js([P("wcm-theme-context")],Yr);const ks=I`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var Hs=Object.defineProperty,zs=Object.getOwnPropertyDescriptor,Fs=(e,t,r,n)=>{for(var o=n>1?void 0:n?zs(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Hs(t,r,o),o};let or=class extends E{onGoToQrcode(){N.push("Qrcode")}render(){const{recomendedWallets:e}=k.state,t=[...e,...e],r=$.RECOMMENDED_WALLET_AMOUNT*2;return u`
${T.MOBILE_ICON}WalletConnect
${[...Array(r)].map((n,o)=>{const i=t[o%t.length];return i?u``:T.WALLET_PLACEHOLDER})}
Select Wallet
Choose WalletConnect to see supported apps on your device`}};or.styles=[A.globalCss,ks];or=Fs([P("wcm-android-wallet-selection")],or);const Vs=I`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`;var Zs=Object.defineProperty,Ks=Object.getOwnPropertyDescriptor,Rt=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ks(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Zs(t,r,o),o};let it=class extends E{constructor(){super(...arguments),this.walletId=void 0,this.imageId=void 0,this.isError=!1,this.isStale=!1,this.label=""}svgLoaderTemplate(){var e,t;const i=(t=(e=$t.state.themeVariables)==null?void 0:e["--wcm-wallet-icon-large-border-radius"])!=null?t:A.getPreset("--wcm-wallet-icon-large-border-radius");let s=0;i.includes("%")?s=88/100*parseInt(i,10):s=parseInt(i,10),s*=1.17;const l=317-s*1.57,a=425-s*1.8;return u``}render(){const e={"wcm-error":this.isError,"wcm-stale":this.isStale};return u`
${this.svgLoaderTemplate()}
${this.isError?"Connection declined":this.label}`}};it.styles=[A.globalCss,Vs];Rt([_()],it.prototype,"walletId",2);Rt([_()],it.prototype,"imageId",2);Rt([_({type:Boolean})],it.prototype,"isError",2);Rt([_({type:Boolean})],it.prototype,"isStale",2);Rt([_()],it.prototype,"label",2);it=Rt([P("wcm-connector-waiting")],it);const yt={manualWallets(){var e,t;const{mobileWallets:r,desktopWallets:n}=ht.state,o=(e=yt.recentWallet())==null?void 0:e.id,i=$.isMobile()?r:n,s=i==null?void 0:i.filter(l=>o!==l.id);return(t=$.isMobile()?s==null?void 0:s.map(({id:l,name:a,links:c})=>({id:l,name:a,mobile:c,links:c})):s==null?void 0:s.map(({id:l,name:a,links:c})=>({id:l,name:a,desktop:c,links:c})))!=null?t:[]},recentWallet(){return x.getRecentWallet()},recomendedWallets(e=!1){var t;const r=e||(t=yt.recentWallet())==null?void 0:t.id,{recomendedWallets:n}=k.state;return n.filter(i=>r!==i.id)}},rt={onConnecting(e){x.goToConnectingView(e)},manualWalletsTemplate(){return yt.manualWallets().map(t=>u``)},recomendedWalletsTemplate(e=!1){return yt.recomendedWallets(e).map(r=>u``)},recentWalletTemplate(){const e=yt.recentWallet();if(e)return u``}},qs=I`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`;var Ys=Object.defineProperty,Gs=Object.getOwnPropertyDescriptor,Js=(e,t,r,n)=>{for(var o=n>1?void 0:n?Gs(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Ys(t,r,o),o};let nr=class extends E{render(){const{explorerExcludedWalletIds:e,enableExplorer:t}=ht.state,r=e!=="ALL"&&t,n=rt.manualWalletsTemplate(),o=rt.recomendedWalletsTemplate();let s=[rt.recentWalletTemplate(),...n,...o];s=s.filter(Boolean);const l=s.length>4||r;let a=[];l?a=s.slice(0,3):a=s;const c=!!a.length;return u`
${T.MOBILE_ICON}Mobile
${T.SCAN_ICON}Scan with your wallet
${c?u`
${T.DESKTOP_ICON}Desktop
${a} ${l?u``:null}
`:null}`}};nr.styles=[A.globalCss,qs];nr=Js([P("wcm-desktop-wallet-selection")],nr);const Qs=I`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`;var Xs=Object.defineProperty,tl=Object.getOwnPropertyDescriptor,el=(e,t,r,n)=>{for(var o=n>1?void 0:n?tl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Xs(t,r,o),o};let ir=class extends E{render(){const{termsOfServiceUrl:e,privacyPolicyUrl:t}=ht.state;return e??t?u`
By connecting your wallet to this app, you agree to the app's ${e?u`Terms of Service`:null} ${e&&t?"and":null} ${t?u`Privacy Policy`:null}
`:null}};ir.styles=[A.globalCss,Qs];ir=el([P("wcm-legal-notice")],ir);const rl=I`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`;var ol=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,il=(e,t,r,n)=>{for(var o=n>1?void 0:n?nl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ol(t,r,o),o};let sr=class extends E{onQrcode(){N.push("Qrcode")}render(){const{explorerExcludedWalletIds:e,enableExplorer:t}=ht.state,r=e!=="ALL"&&t,n=rt.manualWalletsTemplate(),o=rt.recomendedWalletsTemplate();let s=[rt.recentWalletTemplate(),...n,...o];s=s.filter(Boolean);const l=s.length>8||r;let a=[];l?a=s.slice(0,7):a=s;const c=!!a.length;return u`${c?u`
${a} ${l?u``:null}
`:null}`}};sr.styles=[A.globalCss,rl];sr=il([P("wcm-mobile-wallet-selection")],sr);const sl=I`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`;var ll=Object.defineProperty,al=Object.getOwnPropertyDescriptor,Cr=(e,t,r,n)=>{for(var o=n>1?void 0:n?al(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ll(t,r,o),o};let Zt=class extends E{constructor(){super(),this.open=!1,this.active=!1,this.unsubscribeModal=void 0,this.abortController=void 0,this.unsubscribeModal=re.subscribe(e=>{e.open?this.onOpenModalEvent():this.onCloseModalEvent()})}disconnectedCallback(){var e;(e=this.unsubscribeModal)==null||e.call(this)}get overlayEl(){return x.getShadowRootElement(this,".wcm-overlay")}get containerEl(){return x.getShadowRootElement(this,".wcm-container")}toggleBodyScroll(e){if(document.querySelector("body"))if(e){const r=document.getElementById("wcm-styles");r==null||r.remove()}else document.head.insertAdjacentHTML("beforeend",'')}onCloseModal(e){e.target===e.currentTarget&&re.close()}onOpenModalEvent(){this.toggleBodyScroll(!1),this.addKeyboardEvents(),this.open=!0,setTimeout(async()=>{const e=x.isMobileAnimation()?{y:["50vh","0vh"]}:{scale:[.98,1]},t=.1,r=.2;await Promise.all([dt(this.overlayEl,{opacity:[0,1]},{delay:t,duration:r}).finished,dt(this.containerEl,e,{delay:t,duration:r}).finished]),this.active=!0},0)}async onCloseModalEvent(){this.toggleBodyScroll(!0),this.removeKeyboardEvents();const e=x.isMobileAnimation()?{y:["0vh","50vh"]}:{scale:[1,.98]},t=.2;await Promise.all([dt(this.overlayEl,{opacity:[1,0]},{duration:t}).finished,dt(this.containerEl,e,{duration:t}).finished]),this.containerEl.removeAttribute("style"),this.active=!1,this.open=!1}addKeyboardEvents(){this.abortController=new AbortController,window.addEventListener("keydown",e=>{var t;e.key==="Escape"?re.close():e.key==="Tab"&&((t=e.target)!=null&&t.tagName.includes("wcm-")||this.containerEl.focus())},this.abortController),this.containerEl.focus()}removeKeyboardEvents(){var e;(e=this.abortController)==null||e.abort(),this.abortController=void 0}render(){const e={"wcm-overlay":!0,"wcm-active":this.active};return u`
${this.open?u`
`:null}
`}};Zt.styles=[A.globalCss,sl];Cr([H()],Zt.prototype,"open",2);Cr([H()],Zt.prototype,"active",2);Zt=Cr([P("wcm-modal")],Zt);const cl=I`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`;var dl=Object.defineProperty,hl=Object.getOwnPropertyDescriptor,Jt=(e,t,r,n)=>{for(var o=n>1?void 0:n?hl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&dl(t,r,o),o};let pt=class extends E{constructor(){super(...arguments),this.isMobile=!1,this.isDesktop=!1,this.isWeb=!1,this.isRetry=!1}onMobile(){$.isMobile()?N.replace("MobileConnecting"):N.replace("MobileQrcodeConnecting")}onDesktop(){N.replace("DesktopConnecting")}onWeb(){N.replace("WebConnecting")}render(){return u`
${this.isRetry?u``:null} ${this.isMobile?u`Mobile`:null} ${this.isDesktop?u`Desktop`:null} ${this.isWeb?u`Web`:null}
`}};pt.styles=[A.globalCss,cl];Jt([_({type:Boolean})],pt.prototype,"isMobile",2);Jt([_({type:Boolean})],pt.prototype,"isDesktop",2);Jt([_({type:Boolean})],pt.prototype,"isWeb",2);Jt([_({type:Boolean})],pt.prototype,"isRetry",2);pt=Jt([P("wcm-platform-selection")],pt);const ul=I`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var ml=Object.defineProperty,fl=Object.getOwnPropertyDescriptor,pl=(e,t,r,n)=>{for(var o=n>1?void 0:n?fl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ml(t,r,o),o};let lr=class extends E{onClick(){N.push("WalletExplorer")}render(){const{recomendedWallets:e}=k.state,t=yt.manualWallets(),r=[...e,...t].reverse().slice(0,4);return u``}};lr.styles=[A.globalCss,ul];lr=pl([P("wcm-view-all-wallets-button")],lr);const gl=I`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`;var wl=Object.defineProperty,vl=Object.getOwnPropertyDescriptor,xe=(e,t,r,n)=>{for(var o=n>1?void 0:n?vl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&wl(t,r,o),o};let Tt=class extends E{constructor(){super(),this.walletId="",this.imageId="",this.uri="",setTimeout(()=>{const{walletConnectUri:e}=Z.state;this.uri=e},0)}get overlayEl(){return x.getShadowRootElement(this,".wcm-qr-container")}render(){return u`
${this.uri?u``:u``}
`}};Tt.styles=[A.globalCss,gl];xe([_()],Tt.prototype,"walletId",2);xe([_()],Tt.prototype,"imageId",2);xe([H()],Tt.prototype,"uri",2);Tt=xe([P("wcm-walletconnect-qr")],Tt);var bl=Object.defineProperty,yl=Object.getOwnPropertyDescriptor,$l=(e,t,r,n)=>{for(var o=n>1?void 0:n?yl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&bl(t,r,o),o};let ar=class extends E{viewTemplate(){return $.isAndroid()&&!$.isTelegram()?u``:$.isMobile()?u``:u``}render(){return u`${this.viewTemplate()}`}};ar.styles=[A.globalCss];ar=$l([P("wcm-connect-wallet-view")],ar);const xl=I`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var _l=Object.defineProperty,Cl=Object.getOwnPropertyDescriptor,Ro=(e,t,r,n)=>{for(var o=n>1?void 0:n?Cl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&_l(t,r,o),o};let me=class extends E{constructor(){super(),this.isError=!1,this.openDesktopApp()}onFormatAndRedirect(e){const{desktop:t,name:r}=$.getWalletRouterData(),n=t==null?void 0:t.native,o=t==null?void 0:t.universal;if(n){const i=$.formatNativeUrl(n,e,r);$.openHref(i,"_self")}else if(o){const i=$.formatUniversalUrl(o,e,r);$.openHref(i,"_blank")}}openDesktopApp(){const{walletConnectUri:e}=Z.state,t=$.getWalletRouterData();x.setRecentWallet(t),e&&this.onFormatAndRedirect(e)}render(){const{name:e,id:t,image_id:r}=$.getWalletRouterData(),{isMobile:n,isWeb:o}=x.getCachedRouterWalletPlatforms();return u`${`Connection can continue loading if ${e} is not installed on your device`}Retry`}};me.styles=[A.globalCss,xl];Ro([H()],me.prototype,"isError",2);me=Ro([P("wcm-desktop-connecting-view")],me);const El=I`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`;var Al=Object.defineProperty,Ol=Object.getOwnPropertyDescriptor,Pl=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ol(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Al(t,r,o),o};let cr=class extends E{onInstall(e){e&&$.openHref(e,"_blank")}render(){const{name:e,id:t,image_id:r,homepage:n}=$.getWalletRouterData();return u`${`Download ${e} to continue. If multiple browser extensions are installed, disable non ${e} ones and try again`}Download`}};cr.styles=[A.globalCss,El];cr=Pl([P("wcm-install-wallet-view")],cr);const Il=I`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`;var Tl=Object.defineProperty,Ml=Object.getOwnPropertyDescriptor,Do=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ml(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Tl(t,r,o),o};let fe=class extends E{constructor(){super(),this.isError=!1,this.openMobileApp()}onFormatAndRedirect(e,t=!1){const{mobile:r,name:n}=$.getWalletRouterData(),o=r==null?void 0:r.native,i=r==null?void 0:r.universal,s=$.isTelegram()?"_blank":"_self";if(e=$.isTelegram()&&$.isAndroid()?encodeURIComponent(e):e,o&&!t){const l=$.formatNativeUrl(o,e,n);$.openHref(l,s)}else if(i){const l=$.formatUniversalUrl(i,e,n);$.openHref(l,s)}}openMobileApp(e=!1){const{walletConnectUri:t}=Z.state,r=$.getWalletRouterData();t&&this.onFormatAndRedirect(t,e),x.setRecentWallet(r)}onGoToAppStore(e){e&&$.openHref(e,"_blank")}render(){const{name:e,id:t,image_id:r,app:n,mobile:o}=$.getWalletRouterData(),{isWeb:i}=x.getCachedRouterWalletPlatforms(),s=n==null?void 0:n.ios,l=o==null?void 0:o.universal;return u`Retry${l?u`Still doesn't work? Try this alternate link`:null}
${`Get ${e}`}
App Store
`}};fe.styles=[A.globalCss,Il];Do([H()],fe.prototype,"isError",2);fe=Do([P("wcm-mobile-connecting-view")],fe);const Sl=I`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var Rl=Object.defineProperty,Dl=Object.getOwnPropertyDescriptor,Ll=(e,t,r,n)=>{for(var o=n>1?void 0:n?Dl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Rl(t,r,o),o};let dr=class extends E{render(){const{name:e,id:t,image_id:r}=$.getWalletRouterData(),{isDesktop:n,isWeb:o}=x.getCachedRouterWalletPlatforms();return u`${`Scan this QR Code with your phone's camera or inside ${e} app`}`}};dr.styles=[A.globalCss,Sl];dr=Ll([P("wcm-mobile-qr-connecting-view")],dr);var Nl=Object.defineProperty,Bl=Object.getOwnPropertyDescriptor,Wl=(e,t,r,n)=>{for(var o=n>1?void 0:n?Bl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Nl(t,r,o),o};let hr=class extends E{render(){return u``}};hr.styles=[A.globalCss];hr=Wl([P("wcm-qrcode-view")],hr);const Ul=I`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`;var jl=Object.defineProperty,kl=Object.getOwnPropertyDescriptor,Qt=(e,t,r,n)=>{for(var o=n>1?void 0:n?kl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&jl(t,r,o),o};const je=40;let gt=class extends E{constructor(){super(...arguments),this.loading=!k.state.wallets.listings.length,this.firstFetch=!k.state.wallets.listings.length,this.search="",this.endReached=!1,this.intersectionObserver=void 0,this.searchDebounce=x.debounce(e=>{e.length>=1?(this.firstFetch=!0,this.endReached=!1,this.search=e,k.resetSearch(),this.fetchWallets()):this.search&&(this.search="",this.endReached=this.isLastPage(),k.resetSearch())})}firstUpdated(){this.createPaginationObserver()}disconnectedCallback(){var e;(e=this.intersectionObserver)==null||e.disconnect()}get placeholderEl(){return x.getShadowRootElement(this,".wcm-placeholder-block")}createPaginationObserver(){this.intersectionObserver=new IntersectionObserver(([e])=>{e.isIntersecting&&!(this.search&&this.firstFetch)&&this.fetchWallets()}),this.intersectionObserver.observe(this.placeholderEl)}isLastPage(){const{wallets:e,search:t}=k.state,{listings:r,total:n}=this.search?t:e;return n<=je||r.length>=n}async fetchWallets(){var e;const{wallets:t,search:r}=k.state,{listings:n,total:o,page:i}=this.search?r:t;if(!this.endReached&&(this.firstFetch||o>je&&n.lengthx.getWalletIcon(c));await Promise.all([...a.map(async c=>x.preloadImage(c)),$.wait(300)]),this.endReached=this.isLastPage()}catch(s){console.error(s),X.openToast(x.getErrorMessage(s),"error")}finally{this.loading=!1,this.firstFetch=!1}}onConnect(e){$.isAndroid()?x.handleMobileLinking(e):x.goToConnectingView(e)}onSearchChange(e){const{value:t}=e.target;this.searchDebounce(t)}render(){const{wallets:e,search:t}=k.state,{listings:r}=this.search?t:e,n=this.loading&&!r.length,o=this.search.length>=3;let i=rt.manualWalletsTemplate(),s=rt.recomendedWalletsTemplate(!0);o&&(i=i.filter(({values:c})=>x.caseSafeIncludes(c[0],this.search)),s=s.filter(({values:c})=>x.caseSafeIncludes(c[0],this.search)));const l=!this.loading&&!r.length&&!s.length,a={"wcm-loading":n,"wcm-end-reached":this.endReached||!this.loading,"wcm-empty":l};return u`
${n?null:i} ${n?null:s} ${n?null:r.map(c=>u`${c?u``:null}`)}
${l?u`No results found`:null} ${!l&&this.loading?u``:null}
`}};gt.styles=[A.globalCss,Ul];Qt([H()],gt.prototype,"loading",2);Qt([H()],gt.prototype,"firstFetch",2);Qt([H()],gt.prototype,"search",2);Qt([H()],gt.prototype,"endReached",2);gt=Qt([P("wcm-wallet-explorer-view")],gt);const Hl=I`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var zl=Object.defineProperty,Fl=Object.getOwnPropertyDescriptor,Lo=(e,t,r,n)=>{for(var o=n>1?void 0:n?Fl(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&zl(t,r,o),o};let pe=class extends E{constructor(){super(),this.isError=!1,this.openWebWallet()}onFormatAndRedirect(e){const{desktop:t,name:r}=$.getWalletRouterData(),n=t==null?void 0:t.universal;if(n){const o=$.formatUniversalUrl(n,e,r);$.openHref(o,"_blank")}}openWebWallet(){const{walletConnectUri:e}=Z.state,t=$.getWalletRouterData();x.setRecentWallet(t),e&&this.onFormatAndRedirect(e)}render(){const{name:e,id:t,image_id:r}=$.getWalletRouterData(),{isMobile:n,isDesktop:o}=x.getCachedRouterWalletPlatforms(),i=$.isMobile();return u`${`${e} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`}};pe.styles=[A.globalCss,Hl];Lo([H()],pe.prototype,"isError",2);pe=Lo([P("wcm-web-connecting-view")],pe);export{Zt as WcmModal,nt as WcmQrCode}; diff --git a/buddybook/assets/index-DaaUGS07.js b/buddybook/assets/index-DSEy00EN.js similarity index 98% rename from buddybook/assets/index-DaaUGS07.js rename to buddybook/assets/index-DSEy00EN.js index b7f68b3..7199aa6 100644 --- a/buddybook/assets/index-DaaUGS07.js +++ b/buddybook/assets/index-DSEy00EN.js @@ -1 +1 @@ -import{e as p}from"./events-CHFTlyqt.js";function _(n,r){for(var i=0;ie[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var l={},g={},f={};Object.defineProperty(f,"__esModule",{value:!0});f.getLowerCase=void 0;function m(n){return n&&n.toLowerCase()}f.getLowerCase=m;Object.defineProperty(g,"__esModule",{value:!0});g.SafeAppProvider=void 0;const w=p,u=f;class k extends w.EventEmitter{constructor(r,i){super(),this.submittedTxs=new Map,this.safe=r,this.sdk=i}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(r){const{method:i,params:e=[]}=r;switch(i){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[t,a]=e;if(this.safe.safeAddress.toLowerCase()!==a.toLowerCase())throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(t);return("signature"in h?h.signature:void 0)||"0x"}case"eth_sign":{const[t,a]=e;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase()||!a.startsWith("0x"))throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(a);return("signature"in h?h.signature:void 0)||"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[t,a]=e,h=typeof a=="string"?JSON.parse(a):a;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address is invalid");const c=await this.sdk.txs.signTypedMessage(h);return("signature"in c?c.signature:void 0)||"0x"}case"eth_sendTransaction":const s={...e[0],value:e[0].value||"0",data:e[0].data||"0x"};typeof s.gas=="string"&&s.gas.startsWith("0x")&&(s.gas=parseInt(s.gas,16));const o=await this.sdk.txs.send({txs:[s],params:{safeTxGas:s.gas}});return this.submittedTxs.set(o.safeTxHash,{from:this.safe.safeAddress,hash:o.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:s.data,value:s.value,to:s.to,blockHash:null,blockNumber:null,transactionIndex:null}),o.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,u.getLowerCase)(e[0]),e[1],e[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([e[0],e[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([e[0],e[1]]);case"eth_getTransactionByHash":let d=e[0];try{d=(await this.sdk.txs.getBySafeTxHash(d)).txHash||d}catch{}return this.submittedTxs.has(d)?this.submittedTxs.get(d):this.sdk.eth.getTransactionByHash([d]).then(t=>(t&&(t.hash=e[0]),t));case"eth_getTransactionReceipt":{let t=e[0];try{t=(await this.sdk.txs.getBySafeTxHash(t)).txHash||t}catch{}return this.sdk.eth.getTransactionReceipt([t]).then(a=>(a&&(a.transactionHash=e[0]),a))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(e[0]);case"eth_call":return this.sdk.eth.call([e[0],e[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([e[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(e[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([e[0]]);default:throw Error(`"${r.method}" not implemented`)}}send(r,i){r||i("Undefined request"),this.request(r).then(e=>i(null,{jsonrpc:"2.0",id:r.id,result:e})).catch(e=>i(e,null))}}g.SafeAppProvider=k;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.SafeAppProvider=void 0;var r=g;Object.defineProperty(n,"SafeAppProvider",{enumerable:!0,get:function(){return r.SafeAppProvider}})})(l);const T=_({__proto__:null},[l]);export{T as i}; +import{e as p}from"./events-_Z2_TJp5.js";function _(n,r){for(var i=0;ie[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var l={},g={},f={};Object.defineProperty(f,"__esModule",{value:!0});f.getLowerCase=void 0;function m(n){return n&&n.toLowerCase()}f.getLowerCase=m;Object.defineProperty(g,"__esModule",{value:!0});g.SafeAppProvider=void 0;const w=p,u=f;class k extends w.EventEmitter{constructor(r,i){super(),this.submittedTxs=new Map,this.safe=r,this.sdk=i}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(r){const{method:i,params:e=[]}=r;switch(i){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[t,a]=e;if(this.safe.safeAddress.toLowerCase()!==a.toLowerCase())throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(t);return("signature"in h?h.signature:void 0)||"0x"}case"eth_sign":{const[t,a]=e;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase()||!a.startsWith("0x"))throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(a);return("signature"in h?h.signature:void 0)||"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[t,a]=e,h=typeof a=="string"?JSON.parse(a):a;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address is invalid");const c=await this.sdk.txs.signTypedMessage(h);return("signature"in c?c.signature:void 0)||"0x"}case"eth_sendTransaction":const s={...e[0],value:e[0].value||"0",data:e[0].data||"0x"};typeof s.gas=="string"&&s.gas.startsWith("0x")&&(s.gas=parseInt(s.gas,16));const o=await this.sdk.txs.send({txs:[s],params:{safeTxGas:s.gas}});return this.submittedTxs.set(o.safeTxHash,{from:this.safe.safeAddress,hash:o.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:s.data,value:s.value,to:s.to,blockHash:null,blockNumber:null,transactionIndex:null}),o.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,u.getLowerCase)(e[0]),e[1],e[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([e[0],e[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([e[0],e[1]]);case"eth_getTransactionByHash":let d=e[0];try{d=(await this.sdk.txs.getBySafeTxHash(d)).txHash||d}catch{}return this.submittedTxs.has(d)?this.submittedTxs.get(d):this.sdk.eth.getTransactionByHash([d]).then(t=>(t&&(t.hash=e[0]),t));case"eth_getTransactionReceipt":{let t=e[0];try{t=(await this.sdk.txs.getBySafeTxHash(t)).txHash||t}catch{}return this.sdk.eth.getTransactionReceipt([t]).then(a=>(a&&(a.transactionHash=e[0]),a))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(e[0]);case"eth_call":return this.sdk.eth.call([e[0],e[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([e[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(e[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([e[0]]);default:throw Error(`"${r.method}" not implemented`)}}send(r,i){r||i("Undefined request"),this.request(r).then(e=>i(null,{jsonrpc:"2.0",id:r.id,result:e})).catch(e=>i(e,null))}}g.SafeAppProvider=k;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.SafeAppProvider=void 0;var r=g;Object.defineProperty(n,"SafeAppProvider",{enumerable:!0,get:function(){return r.SafeAppProvider}})})(l);const T=_({__proto__:null},[l]);export{T as i}; diff --git a/buddybook/assets/index-BRDupqIG.js b/buddybook/assets/index-Ds5ZBbkh.js similarity index 85% rename from buddybook/assets/index-BRDupqIG.js rename to buddybook/assets/index-Ds5ZBbkh.js index e045626..89b77e7 100644 --- a/buddybook/assets/index-BRDupqIG.js +++ b/buddybook/assets/index-Ds5ZBbkh.js @@ -1,7 +1,7 @@ -import{d as x,g as Hs,j as xc,l as Tc,h as Pc}from"./index-CLqSQ1yP.js";import{r as $c}from"./inherits_browser-Dprisln6.js";import{s as Oc,r as Ke,a as an,j as Bc,b as Dc}from"./hooks.module-CBpTII2E.js";import{e as ta}from"./events-CHFTlyqt.js";var ra={},br={},cn={};Object.defineProperty(cn,"__esModule",{value:!0});cn.walletLogo=void 0;const jc=(t,e)=>{let r;switch(t){case"standard":return r=e,`data:image/svg+xml,%3Csvg width='${e}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return r=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${r}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return r=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return r=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return r=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return r=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return r=e,`data:image/svg+xml,%3Csvg width='${e}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};cn.walletLogo=jc;var ln={};Object.defineProperty(ln,"__esModule",{value:!0});ln.LINK_API_URL=void 0;ln.LINK_API_URL="https://www.walletlink.org";var A={},Us={exports:{}};Us.exports;(function(t){(function(e,r){function n(b,o){if(!b)throw new Error(o||"Assertion failed")}function i(b,o){b.super_=o;var l=function(){};l.prototype=o.prototype,b.prototype=new l,b.prototype.constructor=b}function s(b,o,l){if(s.isBN(b))return b;this.negative=0,this.words=null,this.length=0,this.red=null,b!==null&&((o==="le"||o==="be")&&(l=o,o=10),this._init(b||0,o||10,l||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var c;try{typeof window<"u"&&typeof window.Buffer<"u"?c=window.Buffer:c=$c.Buffer}catch{}s.isBN=function(o){return o instanceof s?!0:o!==null&&typeof o=="object"&&o.constructor.wordSize===s.wordSize&&Array.isArray(o.words)},s.max=function(o,l){return o.cmp(l)>0?o:l},s.min=function(o,l){return o.cmp(l)<0?o:l},s.prototype._init=function(o,l,f){if(typeof o=="number")return this._initNumber(o,l,f);if(typeof o=="object")return this._initArray(o,l,f);l==="hex"&&(l=16),n(l===(l|0)&&l>=2&&l<=36),o=o.toString().replace(/\s+/g,"");var g=0;o[0]==="-"&&(g++,this.negative=1),g=0;g-=3)w=o[g]|o[g-1]<<8|o[g-2]<<16,this.words[m]|=w<<_&67108863,this.words[m+1]=w>>>26-_&67108863,_+=24,_>=26&&(_-=26,m++);else if(f==="le")for(g=0,m=0;g>>26-_&67108863,_+=24,_>=26&&(_-=26,m++);return this._strip()};function u(b,o){var l=b.charCodeAt(o);if(l>=48&&l<=57)return l-48;if(l>=65&&l<=70)return l-55;if(l>=97&&l<=102)return l-87;n(!1,"Invalid character in "+b)}function d(b,o,l){var f=u(b,l);return l-1>=o&&(f|=u(b,l-1)<<4),f}s.prototype._parseHex=function(o,l,f){this.length=Math.ceil((o.length-l)/6),this.words=new Array(this.length);for(var g=0;g=l;g-=2)_=d(o,l,g)<=18?(m-=18,w+=1,this.words[w]|=_>>>26):m+=8;else{var p=o.length-l;for(g=p%2===0?l+1:l;g=18?(m-=18,w+=1,this.words[w]|=_>>>26):m+=8}this._strip()};function h(b,o,l,f){for(var g=0,m=0,w=Math.min(b.length,l),_=o;_=49?m=p-49+10:p>=17?m=p-17+10:m=p,n(p>=0&&m1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=S}catch{s.prototype.inspect=S}else s.prototype.inspect=S;function S(){return(this.red?""}var E=["","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"],M=[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],k=[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];s.prototype.toString=function(o,l){o=o||10,l=l|0||1;var f;if(o===16||o==="hex"){f="";for(var g=0,m=0,w=0;w>>24-g&16777215,g+=2,g>=26&&(g-=26,w--),m!==0||w!==this.length-1?f=E[6-p.length]+p+f:f=p+f}for(m!==0&&(f=m.toString(16)+f);f.length%l!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(o===(o|0)&&o>=2&&o<=36){var a=M[o],v=k[o];f="";var N=this.clone();for(N.negative=0;!N.isZero();){var I=N.modrn(v).toString(o);N=N.idivn(v),N.isZero()?f=I+f:f=E[a-I.length]+I+f}for(this.isZero()&&(f="0"+f);f.length%l!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var o=this.words[0];return this.length===2?o+=this.words[1]*67108864:this.length===3&&this.words[2]===1?o+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-o:o},s.prototype.toJSON=function(){return this.toString(16,2)},c&&(s.prototype.toBuffer=function(o,l){return this.toArrayLike(c,o,l)}),s.prototype.toArray=function(o,l){return this.toArrayLike(Array,o,l)};var T=function(o,l){return o.allocUnsafe?o.allocUnsafe(l):new o(l)};s.prototype.toArrayLike=function(o,l,f){this._strip();var g=this.byteLength(),m=f||Math.max(1,g);n(g<=m,"byte array longer than desired length"),n(m>0,"Requested array length <= 0");var w=T(o,m),_=l==="le"?"LE":"BE";return this["_toArrayLike"+_](w,g),w},s.prototype._toArrayLikeLE=function(o,l){for(var f=0,g=0,m=0,w=0;m>8&255),f>16&255),w===6?(f>24&255),g=0,w=0):(g=_>>>24,w+=2)}if(f=0&&(o[f--]=_>>8&255),f>=0&&(o[f--]=_>>16&255),w===6?(f>=0&&(o[f--]=_>>24&255),g=0,w=0):(g=_>>>24,w+=2)}if(f>=0)for(o[f--]=g;f>=0;)o[f--]=0},Math.clz32?s.prototype._countBits=function(o){return 32-Math.clz32(o)}:s.prototype._countBits=function(o){var l=o,f=0;return l>=4096&&(f+=13,l>>>=13),l>=64&&(f+=7,l>>>=7),l>=8&&(f+=4,l>>>=4),l>=2&&(f+=2,l>>>=2),f+l},s.prototype._zeroBits=function(o){if(o===0)return 26;var l=o,f=0;return l&8191||(f+=13,l>>>=13),l&127||(f+=7,l>>>=7),l&15||(f+=4,l>>>=4),l&3||(f+=2,l>>>=2),l&1||f++,f},s.prototype.bitLength=function(){var o=this.words[this.length-1],l=this._countBits(o);return(this.length-1)*26+l};function O(b){for(var o=new Array(b.bitLength()),l=0;l>>g&1}return o}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var o=0,l=0;lo.length?this.clone().ior(o):o.clone().ior(this)},s.prototype.uor=function(o){return this.length>o.length?this.clone().iuor(o):o.clone().iuor(this)},s.prototype.iuand=function(o){var l;this.length>o.length?l=o:l=this;for(var f=0;fo.length?this.clone().iand(o):o.clone().iand(this)},s.prototype.uand=function(o){return this.length>o.length?this.clone().iuand(o):o.clone().iuand(this)},s.prototype.iuxor=function(o){var l,f;this.length>o.length?(l=this,f=o):(l=o,f=this);for(var g=0;go.length?this.clone().ixor(o):o.clone().ixor(this)},s.prototype.uxor=function(o){return this.length>o.length?this.clone().iuxor(o):o.clone().iuxor(this)},s.prototype.inotn=function(o){n(typeof o=="number"&&o>=0);var l=Math.ceil(o/26)|0,f=o%26;this._expand(l),f>0&&l--;for(var g=0;g0&&(this.words[g]=~this.words[g]&67108863>>26-f),this._strip()},s.prototype.notn=function(o){return this.clone().inotn(o)},s.prototype.setn=function(o,l){n(typeof o=="number"&&o>=0);var f=o/26|0,g=o%26;return this._expand(f+1),l?this.words[f]=this.words[f]|1<o.length?(f=this,g=o):(f=o,g=this);for(var m=0,w=0;w>>26;for(;m!==0&&w>>26;if(this.length=f.length,m!==0)this.words[this.length]=m,this.length++;else if(f!==this)for(;wo.length?this.clone().iadd(o):o.clone().iadd(this)},s.prototype.isub=function(o){if(o.negative!==0){o.negative=0;var l=this.iadd(o);return o.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(o),this.negative=1,this._normSign();var f=this.cmp(o);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,m;f>0?(g=this,m=o):(g=o,m=this);for(var w=0,_=0;_>26,this.words[_]=l&67108863;for(;w!==0&&_>26,this.words[_]=l&67108863;if(w===0&&_>>26,N=p&67108863,I=Math.min(a,o.length-1),$=Math.max(0,a-b.length+1);$<=I;$++){var ze=a-$|0;g=b.words[ze]|0,m=o.words[$]|0,w=g*m+N,v+=w/67108864|0,N=w&67108863}l.words[a]=N|0,p=v|0}return p!==0?l.words[a]=p|0:l.length--,l._strip()}var L=function(o,l,f){var g=o.words,m=l.words,w=f.words,_=0,p,a,v,N=g[0]|0,I=N&8191,$=N>>>13,ze=g[1]|0,G=ze&8191,Z=ze>>>13,ki=g[2]|0,te=ki&8191,re=ki>>>13,Ri=g[3]|0,ne=Ri&8191,se=Ri>>>13,Ii=g[4]|0,ie=Ii&8191,oe=Ii>>>13,Ci=g[5]|0,ae=Ci&8191,ce=Ci>>>13,Ai=g[6]|0,le=Ai&8191,ue=Ai>>>13,Ni=g[7]|0,de=Ni&8191,he=Ni>>>13,Li=g[8]|0,fe=Li&8191,ge=Li>>>13,xi=g[9]|0,pe=xi&8191,me=xi>>>13,Ti=m[0]|0,ve=Ti&8191,we=Ti>>>13,Pi=m[1]|0,ye=Pi&8191,be=Pi>>>13,$i=m[2]|0,_e=$i&8191,Ee=$i>>>13,Oi=m[3]|0,Se=Oi&8191,Me=Oi>>>13,Bi=m[4]|0,ke=Bi&8191,Re=Bi>>>13,Di=m[5]|0,Ie=Di&8191,Ce=Di>>>13,ji=m[6]|0,Ae=ji&8191,Ne=ji>>>13,Fi=m[7]|0,Le=Fi&8191,xe=Fi>>>13,Hi=m[8]|0,Te=Hi&8191,Pe=Hi>>>13,Ui=m[9]|0,$e=Ui&8191,Oe=Ui>>>13;f.negative=o.negative^l.negative,f.length=19,p=Math.imul(I,ve),a=Math.imul(I,we),a=a+Math.imul($,ve)|0,v=Math.imul($,we);var Xn=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(Xn>>>26)|0,Xn&=67108863,p=Math.imul(G,ve),a=Math.imul(G,we),a=a+Math.imul(Z,ve)|0,v=Math.imul(Z,we),p=p+Math.imul(I,ye)|0,a=a+Math.imul(I,be)|0,a=a+Math.imul($,ye)|0,v=v+Math.imul($,be)|0;var Yn=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(Yn>>>26)|0,Yn&=67108863,p=Math.imul(te,ve),a=Math.imul(te,we),a=a+Math.imul(re,ve)|0,v=Math.imul(re,we),p=p+Math.imul(G,ye)|0,a=a+Math.imul(G,be)|0,a=a+Math.imul(Z,ye)|0,v=v+Math.imul(Z,be)|0,p=p+Math.imul(I,_e)|0,a=a+Math.imul(I,Ee)|0,a=a+Math.imul($,_e)|0,v=v+Math.imul($,Ee)|0;var es=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(es>>>26)|0,es&=67108863,p=Math.imul(ne,ve),a=Math.imul(ne,we),a=a+Math.imul(se,ve)|0,v=Math.imul(se,we),p=p+Math.imul(te,ye)|0,a=a+Math.imul(te,be)|0,a=a+Math.imul(re,ye)|0,v=v+Math.imul(re,be)|0,p=p+Math.imul(G,_e)|0,a=a+Math.imul(G,Ee)|0,a=a+Math.imul(Z,_e)|0,v=v+Math.imul(Z,Ee)|0,p=p+Math.imul(I,Se)|0,a=a+Math.imul(I,Me)|0,a=a+Math.imul($,Se)|0,v=v+Math.imul($,Me)|0;var ts=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ts>>>26)|0,ts&=67108863,p=Math.imul(ie,ve),a=Math.imul(ie,we),a=a+Math.imul(oe,ve)|0,v=Math.imul(oe,we),p=p+Math.imul(ne,ye)|0,a=a+Math.imul(ne,be)|0,a=a+Math.imul(se,ye)|0,v=v+Math.imul(se,be)|0,p=p+Math.imul(te,_e)|0,a=a+Math.imul(te,Ee)|0,a=a+Math.imul(re,_e)|0,v=v+Math.imul(re,Ee)|0,p=p+Math.imul(G,Se)|0,a=a+Math.imul(G,Me)|0,a=a+Math.imul(Z,Se)|0,v=v+Math.imul(Z,Me)|0,p=p+Math.imul(I,ke)|0,a=a+Math.imul(I,Re)|0,a=a+Math.imul($,ke)|0,v=v+Math.imul($,Re)|0;var rs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(rs>>>26)|0,rs&=67108863,p=Math.imul(ae,ve),a=Math.imul(ae,we),a=a+Math.imul(ce,ve)|0,v=Math.imul(ce,we),p=p+Math.imul(ie,ye)|0,a=a+Math.imul(ie,be)|0,a=a+Math.imul(oe,ye)|0,v=v+Math.imul(oe,be)|0,p=p+Math.imul(ne,_e)|0,a=a+Math.imul(ne,Ee)|0,a=a+Math.imul(se,_e)|0,v=v+Math.imul(se,Ee)|0,p=p+Math.imul(te,Se)|0,a=a+Math.imul(te,Me)|0,a=a+Math.imul(re,Se)|0,v=v+Math.imul(re,Me)|0,p=p+Math.imul(G,ke)|0,a=a+Math.imul(G,Re)|0,a=a+Math.imul(Z,ke)|0,v=v+Math.imul(Z,Re)|0,p=p+Math.imul(I,Ie)|0,a=a+Math.imul(I,Ce)|0,a=a+Math.imul($,Ie)|0,v=v+Math.imul($,Ce)|0;var ns=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ns>>>26)|0,ns&=67108863,p=Math.imul(le,ve),a=Math.imul(le,we),a=a+Math.imul(ue,ve)|0,v=Math.imul(ue,we),p=p+Math.imul(ae,ye)|0,a=a+Math.imul(ae,be)|0,a=a+Math.imul(ce,ye)|0,v=v+Math.imul(ce,be)|0,p=p+Math.imul(ie,_e)|0,a=a+Math.imul(ie,Ee)|0,a=a+Math.imul(oe,_e)|0,v=v+Math.imul(oe,Ee)|0,p=p+Math.imul(ne,Se)|0,a=a+Math.imul(ne,Me)|0,a=a+Math.imul(se,Se)|0,v=v+Math.imul(se,Me)|0,p=p+Math.imul(te,ke)|0,a=a+Math.imul(te,Re)|0,a=a+Math.imul(re,ke)|0,v=v+Math.imul(re,Re)|0,p=p+Math.imul(G,Ie)|0,a=a+Math.imul(G,Ce)|0,a=a+Math.imul(Z,Ie)|0,v=v+Math.imul(Z,Ce)|0,p=p+Math.imul(I,Ae)|0,a=a+Math.imul(I,Ne)|0,a=a+Math.imul($,Ae)|0,v=v+Math.imul($,Ne)|0;var ss=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ss>>>26)|0,ss&=67108863,p=Math.imul(de,ve),a=Math.imul(de,we),a=a+Math.imul(he,ve)|0,v=Math.imul(he,we),p=p+Math.imul(le,ye)|0,a=a+Math.imul(le,be)|0,a=a+Math.imul(ue,ye)|0,v=v+Math.imul(ue,be)|0,p=p+Math.imul(ae,_e)|0,a=a+Math.imul(ae,Ee)|0,a=a+Math.imul(ce,_e)|0,v=v+Math.imul(ce,Ee)|0,p=p+Math.imul(ie,Se)|0,a=a+Math.imul(ie,Me)|0,a=a+Math.imul(oe,Se)|0,v=v+Math.imul(oe,Me)|0,p=p+Math.imul(ne,ke)|0,a=a+Math.imul(ne,Re)|0,a=a+Math.imul(se,ke)|0,v=v+Math.imul(se,Re)|0,p=p+Math.imul(te,Ie)|0,a=a+Math.imul(te,Ce)|0,a=a+Math.imul(re,Ie)|0,v=v+Math.imul(re,Ce)|0,p=p+Math.imul(G,Ae)|0,a=a+Math.imul(G,Ne)|0,a=a+Math.imul(Z,Ae)|0,v=v+Math.imul(Z,Ne)|0,p=p+Math.imul(I,Le)|0,a=a+Math.imul(I,xe)|0,a=a+Math.imul($,Le)|0,v=v+Math.imul($,xe)|0;var is=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(is>>>26)|0,is&=67108863,p=Math.imul(fe,ve),a=Math.imul(fe,we),a=a+Math.imul(ge,ve)|0,v=Math.imul(ge,we),p=p+Math.imul(de,ye)|0,a=a+Math.imul(de,be)|0,a=a+Math.imul(he,ye)|0,v=v+Math.imul(he,be)|0,p=p+Math.imul(le,_e)|0,a=a+Math.imul(le,Ee)|0,a=a+Math.imul(ue,_e)|0,v=v+Math.imul(ue,Ee)|0,p=p+Math.imul(ae,Se)|0,a=a+Math.imul(ae,Me)|0,a=a+Math.imul(ce,Se)|0,v=v+Math.imul(ce,Me)|0,p=p+Math.imul(ie,ke)|0,a=a+Math.imul(ie,Re)|0,a=a+Math.imul(oe,ke)|0,v=v+Math.imul(oe,Re)|0,p=p+Math.imul(ne,Ie)|0,a=a+Math.imul(ne,Ce)|0,a=a+Math.imul(se,Ie)|0,v=v+Math.imul(se,Ce)|0,p=p+Math.imul(te,Ae)|0,a=a+Math.imul(te,Ne)|0,a=a+Math.imul(re,Ae)|0,v=v+Math.imul(re,Ne)|0,p=p+Math.imul(G,Le)|0,a=a+Math.imul(G,xe)|0,a=a+Math.imul(Z,Le)|0,v=v+Math.imul(Z,xe)|0,p=p+Math.imul(I,Te)|0,a=a+Math.imul(I,Pe)|0,a=a+Math.imul($,Te)|0,v=v+Math.imul($,Pe)|0;var os=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(os>>>26)|0,os&=67108863,p=Math.imul(pe,ve),a=Math.imul(pe,we),a=a+Math.imul(me,ve)|0,v=Math.imul(me,we),p=p+Math.imul(fe,ye)|0,a=a+Math.imul(fe,be)|0,a=a+Math.imul(ge,ye)|0,v=v+Math.imul(ge,be)|0,p=p+Math.imul(de,_e)|0,a=a+Math.imul(de,Ee)|0,a=a+Math.imul(he,_e)|0,v=v+Math.imul(he,Ee)|0,p=p+Math.imul(le,Se)|0,a=a+Math.imul(le,Me)|0,a=a+Math.imul(ue,Se)|0,v=v+Math.imul(ue,Me)|0,p=p+Math.imul(ae,ke)|0,a=a+Math.imul(ae,Re)|0,a=a+Math.imul(ce,ke)|0,v=v+Math.imul(ce,Re)|0,p=p+Math.imul(ie,Ie)|0,a=a+Math.imul(ie,Ce)|0,a=a+Math.imul(oe,Ie)|0,v=v+Math.imul(oe,Ce)|0,p=p+Math.imul(ne,Ae)|0,a=a+Math.imul(ne,Ne)|0,a=a+Math.imul(se,Ae)|0,v=v+Math.imul(se,Ne)|0,p=p+Math.imul(te,Le)|0,a=a+Math.imul(te,xe)|0,a=a+Math.imul(re,Le)|0,v=v+Math.imul(re,xe)|0,p=p+Math.imul(G,Te)|0,a=a+Math.imul(G,Pe)|0,a=a+Math.imul(Z,Te)|0,v=v+Math.imul(Z,Pe)|0,p=p+Math.imul(I,$e)|0,a=a+Math.imul(I,Oe)|0,a=a+Math.imul($,$e)|0,v=v+Math.imul($,Oe)|0;var as=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(as>>>26)|0,as&=67108863,p=Math.imul(pe,ye),a=Math.imul(pe,be),a=a+Math.imul(me,ye)|0,v=Math.imul(me,be),p=p+Math.imul(fe,_e)|0,a=a+Math.imul(fe,Ee)|0,a=a+Math.imul(ge,_e)|0,v=v+Math.imul(ge,Ee)|0,p=p+Math.imul(de,Se)|0,a=a+Math.imul(de,Me)|0,a=a+Math.imul(he,Se)|0,v=v+Math.imul(he,Me)|0,p=p+Math.imul(le,ke)|0,a=a+Math.imul(le,Re)|0,a=a+Math.imul(ue,ke)|0,v=v+Math.imul(ue,Re)|0,p=p+Math.imul(ae,Ie)|0,a=a+Math.imul(ae,Ce)|0,a=a+Math.imul(ce,Ie)|0,v=v+Math.imul(ce,Ce)|0,p=p+Math.imul(ie,Ae)|0,a=a+Math.imul(ie,Ne)|0,a=a+Math.imul(oe,Ae)|0,v=v+Math.imul(oe,Ne)|0,p=p+Math.imul(ne,Le)|0,a=a+Math.imul(ne,xe)|0,a=a+Math.imul(se,Le)|0,v=v+Math.imul(se,xe)|0,p=p+Math.imul(te,Te)|0,a=a+Math.imul(te,Pe)|0,a=a+Math.imul(re,Te)|0,v=v+Math.imul(re,Pe)|0,p=p+Math.imul(G,$e)|0,a=a+Math.imul(G,Oe)|0,a=a+Math.imul(Z,$e)|0,v=v+Math.imul(Z,Oe)|0;var cs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(cs>>>26)|0,cs&=67108863,p=Math.imul(pe,_e),a=Math.imul(pe,Ee),a=a+Math.imul(me,_e)|0,v=Math.imul(me,Ee),p=p+Math.imul(fe,Se)|0,a=a+Math.imul(fe,Me)|0,a=a+Math.imul(ge,Se)|0,v=v+Math.imul(ge,Me)|0,p=p+Math.imul(de,ke)|0,a=a+Math.imul(de,Re)|0,a=a+Math.imul(he,ke)|0,v=v+Math.imul(he,Re)|0,p=p+Math.imul(le,Ie)|0,a=a+Math.imul(le,Ce)|0,a=a+Math.imul(ue,Ie)|0,v=v+Math.imul(ue,Ce)|0,p=p+Math.imul(ae,Ae)|0,a=a+Math.imul(ae,Ne)|0,a=a+Math.imul(ce,Ae)|0,v=v+Math.imul(ce,Ne)|0,p=p+Math.imul(ie,Le)|0,a=a+Math.imul(ie,xe)|0,a=a+Math.imul(oe,Le)|0,v=v+Math.imul(oe,xe)|0,p=p+Math.imul(ne,Te)|0,a=a+Math.imul(ne,Pe)|0,a=a+Math.imul(se,Te)|0,v=v+Math.imul(se,Pe)|0,p=p+Math.imul(te,$e)|0,a=a+Math.imul(te,Oe)|0,a=a+Math.imul(re,$e)|0,v=v+Math.imul(re,Oe)|0;var ls=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ls>>>26)|0,ls&=67108863,p=Math.imul(pe,Se),a=Math.imul(pe,Me),a=a+Math.imul(me,Se)|0,v=Math.imul(me,Me),p=p+Math.imul(fe,ke)|0,a=a+Math.imul(fe,Re)|0,a=a+Math.imul(ge,ke)|0,v=v+Math.imul(ge,Re)|0,p=p+Math.imul(de,Ie)|0,a=a+Math.imul(de,Ce)|0,a=a+Math.imul(he,Ie)|0,v=v+Math.imul(he,Ce)|0,p=p+Math.imul(le,Ae)|0,a=a+Math.imul(le,Ne)|0,a=a+Math.imul(ue,Ae)|0,v=v+Math.imul(ue,Ne)|0,p=p+Math.imul(ae,Le)|0,a=a+Math.imul(ae,xe)|0,a=a+Math.imul(ce,Le)|0,v=v+Math.imul(ce,xe)|0,p=p+Math.imul(ie,Te)|0,a=a+Math.imul(ie,Pe)|0,a=a+Math.imul(oe,Te)|0,v=v+Math.imul(oe,Pe)|0,p=p+Math.imul(ne,$e)|0,a=a+Math.imul(ne,Oe)|0,a=a+Math.imul(se,$e)|0,v=v+Math.imul(se,Oe)|0;var us=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(us>>>26)|0,us&=67108863,p=Math.imul(pe,ke),a=Math.imul(pe,Re),a=a+Math.imul(me,ke)|0,v=Math.imul(me,Re),p=p+Math.imul(fe,Ie)|0,a=a+Math.imul(fe,Ce)|0,a=a+Math.imul(ge,Ie)|0,v=v+Math.imul(ge,Ce)|0,p=p+Math.imul(de,Ae)|0,a=a+Math.imul(de,Ne)|0,a=a+Math.imul(he,Ae)|0,v=v+Math.imul(he,Ne)|0,p=p+Math.imul(le,Le)|0,a=a+Math.imul(le,xe)|0,a=a+Math.imul(ue,Le)|0,v=v+Math.imul(ue,xe)|0,p=p+Math.imul(ae,Te)|0,a=a+Math.imul(ae,Pe)|0,a=a+Math.imul(ce,Te)|0,v=v+Math.imul(ce,Pe)|0,p=p+Math.imul(ie,$e)|0,a=a+Math.imul(ie,Oe)|0,a=a+Math.imul(oe,$e)|0,v=v+Math.imul(oe,Oe)|0;var ds=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ds>>>26)|0,ds&=67108863,p=Math.imul(pe,Ie),a=Math.imul(pe,Ce),a=a+Math.imul(me,Ie)|0,v=Math.imul(me,Ce),p=p+Math.imul(fe,Ae)|0,a=a+Math.imul(fe,Ne)|0,a=a+Math.imul(ge,Ae)|0,v=v+Math.imul(ge,Ne)|0,p=p+Math.imul(de,Le)|0,a=a+Math.imul(de,xe)|0,a=a+Math.imul(he,Le)|0,v=v+Math.imul(he,xe)|0,p=p+Math.imul(le,Te)|0,a=a+Math.imul(le,Pe)|0,a=a+Math.imul(ue,Te)|0,v=v+Math.imul(ue,Pe)|0,p=p+Math.imul(ae,$e)|0,a=a+Math.imul(ae,Oe)|0,a=a+Math.imul(ce,$e)|0,v=v+Math.imul(ce,Oe)|0;var hs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(hs>>>26)|0,hs&=67108863,p=Math.imul(pe,Ae),a=Math.imul(pe,Ne),a=a+Math.imul(me,Ae)|0,v=Math.imul(me,Ne),p=p+Math.imul(fe,Le)|0,a=a+Math.imul(fe,xe)|0,a=a+Math.imul(ge,Le)|0,v=v+Math.imul(ge,xe)|0,p=p+Math.imul(de,Te)|0,a=a+Math.imul(de,Pe)|0,a=a+Math.imul(he,Te)|0,v=v+Math.imul(he,Pe)|0,p=p+Math.imul(le,$e)|0,a=a+Math.imul(le,Oe)|0,a=a+Math.imul(ue,$e)|0,v=v+Math.imul(ue,Oe)|0;var fs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(fs>>>26)|0,fs&=67108863,p=Math.imul(pe,Le),a=Math.imul(pe,xe),a=a+Math.imul(me,Le)|0,v=Math.imul(me,xe),p=p+Math.imul(fe,Te)|0,a=a+Math.imul(fe,Pe)|0,a=a+Math.imul(ge,Te)|0,v=v+Math.imul(ge,Pe)|0,p=p+Math.imul(de,$e)|0,a=a+Math.imul(de,Oe)|0,a=a+Math.imul(he,$e)|0,v=v+Math.imul(he,Oe)|0;var gs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(gs>>>26)|0,gs&=67108863,p=Math.imul(pe,Te),a=Math.imul(pe,Pe),a=a+Math.imul(me,Te)|0,v=Math.imul(me,Pe),p=p+Math.imul(fe,$e)|0,a=a+Math.imul(fe,Oe)|0,a=a+Math.imul(ge,$e)|0,v=v+Math.imul(ge,Oe)|0;var ps=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ps>>>26)|0,ps&=67108863,p=Math.imul(pe,$e),a=Math.imul(pe,Oe),a=a+Math.imul(me,$e)|0,v=Math.imul(me,Oe);var ms=(_+p|0)+((a&8191)<<13)|0;return _=(v+(a>>>13)|0)+(ms>>>26)|0,ms&=67108863,w[0]=Xn,w[1]=Yn,w[2]=es,w[3]=ts,w[4]=rs,w[5]=ns,w[6]=ss,w[7]=is,w[8]=os,w[9]=as,w[10]=cs,w[11]=ls,w[12]=us,w[13]=ds,w[14]=hs,w[15]=fs,w[16]=gs,w[17]=ps,w[18]=ms,_!==0&&(w[19]=_,f.length++),f};Math.imul||(L=B);function R(b,o,l){l.negative=o.negative^b.negative,l.length=b.length+o.length;for(var f=0,g=0,m=0;m>>26)|0,g+=w>>>26,w&=67108863}l.words[m]=_,f=w,w=g}return f!==0?l.words[m]=f:l.length--,l._strip()}function z(b,o,l){return R(b,o,l)}s.prototype.mulTo=function(o,l){var f,g=this.length+o.length;return this.length===10&&o.length===10?f=L(this,o,l):g<63?f=B(this,o,l):g<1024?f=R(this,o,l):f=z(this,o,l),f},s.prototype.mul=function(o){var l=new s(null);return l.words=new Array(this.length+o.length),this.mulTo(o,l)},s.prototype.mulf=function(o){var l=new s(null);return l.words=new Array(this.length+o.length),z(this,o,l)},s.prototype.imul=function(o){return this.clone().mulTo(o,this)},s.prototype.imuln=function(o){var l=o<0;l&&(o=-o),n(typeof o=="number"),n(o<67108864);for(var f=0,g=0;g>=26,f+=m/67108864|0,f+=w>>>26,this.words[g]=w&67108863}return f!==0&&(this.words[g]=f,this.length++),l?this.ineg():this},s.prototype.muln=function(o){return this.clone().imuln(o)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(o){var l=O(o);if(l.length===0)return new s(1);for(var f=this,g=0;g=0);var l=o%26,f=(o-l)/26,g=67108863>>>26-l<<26-l,m;if(l!==0){var w=0;for(m=0;m>>26-l}w&&(this.words[m]=w,this.length++)}if(f!==0){for(m=this.length-1;m>=0;m--)this.words[m+f]=this.words[m];for(m=0;m=0);var g;l?g=(l-l%26)/26:g=0;var m=o%26,w=Math.min((o-m)/26,this.length),_=67108863^67108863>>>m<w)for(this.length-=w,a=0;a=0&&(v!==0||a>=g);a--){var N=this.words[a]|0;this.words[a]=v<<26-m|N>>>m,v=N&_}return p&&v!==0&&(p.words[p.length++]=v),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(o,l,f){return n(this.negative===0),this.iushrn(o,l,f)},s.prototype.shln=function(o){return this.clone().ishln(o)},s.prototype.ushln=function(o){return this.clone().iushln(o)},s.prototype.shrn=function(o){return this.clone().ishrn(o)},s.prototype.ushrn=function(o){return this.clone().iushrn(o)},s.prototype.testn=function(o){n(typeof o=="number"&&o>=0);var l=o%26,f=(o-l)/26,g=1<=0);var l=o%26,f=(o-l)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(l!==0&&f++,this.length=Math.min(f,this.length),l!==0){var g=67108863^67108863>>>l<=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},s.prototype.isubn=function(o){if(n(typeof o=="number"),n(o<67108864),o<0)return this.iaddn(-o);if(this.negative!==0)return this.negative=0,this.iaddn(o),this.negative=1,this;if(this.words[0]-=o,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var l=0;l>26)-(p/67108864|0),this.words[m+f]=w&67108863}for(;m>26,this.words[m+f]=w&67108863;if(_===0)return this._strip();for(n(_===-1),_=0,m=0;m>26,this.words[m]=w&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(o,l){var f=this.length-o.length,g=this.clone(),m=o,w=m.words[m.length-1]|0,_=this._countBits(w);f=26-_,f!==0&&(m=m.ushln(f),g.iushln(f),w=m.words[m.length-1]|0);var p=g.length-m.length,a;if(l!=="mod"){a=new s(null),a.length=p+1,a.words=new Array(a.length);for(var v=0;v=0;I--){var $=(g.words[m.length+I]|0)*67108864+(g.words[m.length+I-1]|0);for($=Math.min($/w|0,67108863),g._ishlnsubmul(m,$,I);g.negative!==0;)$--,g.negative=0,g._ishlnsubmul(m,1,I),g.isZero()||(g.negative^=1);a&&(a.words[I]=$)}return a&&a._strip(),g._strip(),l!=="div"&&f!==0&&g.iushrn(f),{div:a||null,mod:g}},s.prototype.divmod=function(o,l,f){if(n(!o.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var g,m,w;return this.negative!==0&&o.negative===0?(w=this.neg().divmod(o,l),l!=="mod"&&(g=w.div.neg()),l!=="div"&&(m=w.mod.neg(),f&&m.negative!==0&&m.iadd(o)),{div:g,mod:m}):this.negative===0&&o.negative!==0?(w=this.divmod(o.neg(),l),l!=="mod"&&(g=w.div.neg()),{div:g,mod:w.mod}):this.negative&o.negative?(w=this.neg().divmod(o.neg(),l),l!=="div"&&(m=w.mod.neg(),f&&m.negative!==0&&m.isub(o)),{div:w.div,mod:m}):o.length>this.length||this.cmp(o)<0?{div:new s(0),mod:this}:o.length===1?l==="div"?{div:this.divn(o.words[0]),mod:null}:l==="mod"?{div:null,mod:new s(this.modrn(o.words[0]))}:{div:this.divn(o.words[0]),mod:new s(this.modrn(o.words[0]))}:this._wordDiv(o,l)},s.prototype.div=function(o){return this.divmod(o,"div",!1).div},s.prototype.mod=function(o){return this.divmod(o,"mod",!1).mod},s.prototype.umod=function(o){return this.divmod(o,"mod",!0).mod},s.prototype.divRound=function(o){var l=this.divmod(o);if(l.mod.isZero())return l.div;var f=l.div.negative!==0?l.mod.isub(o):l.mod,g=o.ushrn(1),m=o.andln(1),w=f.cmp(g);return w<0||m===1&&w===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},s.prototype.modrn=function(o){var l=o<0;l&&(o=-o),n(o<=67108863);for(var f=(1<<26)%o,g=0,m=this.length-1;m>=0;m--)g=(f*g+(this.words[m]|0))%o;return l?-g:g},s.prototype.modn=function(o){return this.modrn(o)},s.prototype.idivn=function(o){var l=o<0;l&&(o=-o),n(o<=67108863);for(var f=0,g=this.length-1;g>=0;g--){var m=(this.words[g]|0)+f*67108864;this.words[g]=m/o|0,f=m%o}return this._strip(),l?this.ineg():this},s.prototype.divn=function(o){return this.clone().idivn(o)},s.prototype.egcd=function(o){n(o.negative===0),n(!o.isZero());var l=this,f=o.clone();l.negative!==0?l=l.umod(o):l=l.clone();for(var g=new s(1),m=new s(0),w=new s(0),_=new s(1),p=0;l.isEven()&&f.isEven();)l.iushrn(1),f.iushrn(1),++p;for(var a=f.clone(),v=l.clone();!l.isZero();){for(var N=0,I=1;!(l.words[0]&I)&&N<26;++N,I<<=1);if(N>0)for(l.iushrn(N);N-- >0;)(g.isOdd()||m.isOdd())&&(g.iadd(a),m.isub(v)),g.iushrn(1),m.iushrn(1);for(var $=0,ze=1;!(f.words[0]&ze)&&$<26;++$,ze<<=1);if($>0)for(f.iushrn($);$-- >0;)(w.isOdd()||_.isOdd())&&(w.iadd(a),_.isub(v)),w.iushrn(1),_.iushrn(1);l.cmp(f)>=0?(l.isub(f),g.isub(w),m.isub(_)):(f.isub(l),w.isub(g),_.isub(m))}return{a:w,b:_,gcd:f.iushln(p)}},s.prototype._invmp=function(o){n(o.negative===0),n(!o.isZero());var l=this,f=o.clone();l.negative!==0?l=l.umod(o):l=l.clone();for(var g=new s(1),m=new s(0),w=f.clone();l.cmpn(1)>0&&f.cmpn(1)>0;){for(var _=0,p=1;!(l.words[0]&p)&&_<26;++_,p<<=1);if(_>0)for(l.iushrn(_);_-- >0;)g.isOdd()&&g.iadd(w),g.iushrn(1);for(var a=0,v=1;!(f.words[0]&v)&&a<26;++a,v<<=1);if(a>0)for(f.iushrn(a);a-- >0;)m.isOdd()&&m.iadd(w),m.iushrn(1);l.cmp(f)>=0?(l.isub(f),g.isub(m)):(f.isub(l),m.isub(g))}var N;return l.cmpn(1)===0?N=g:N=m,N.cmpn(0)<0&&N.iadd(o),N},s.prototype.gcd=function(o){if(this.isZero())return o.abs();if(o.isZero())return this.abs();var l=this.clone(),f=o.clone();l.negative=0,f.negative=0;for(var g=0;l.isEven()&&f.isEven();g++)l.iushrn(1),f.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;f.isEven();)f.iushrn(1);var m=l.cmp(f);if(m<0){var w=l;l=f,f=w}else if(m===0||f.cmpn(1)===0)break;l.isub(f)}while(!0);return f.iushln(g)},s.prototype.invm=function(o){return this.egcd(o).a.umod(o)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(o){return this.words[0]&o},s.prototype.bincn=function(o){n(typeof o=="number");var l=o%26,f=(o-l)/26,g=1<>>26,_&=67108863,this.words[w]=_}return m!==0&&(this.words[w]=m,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(o){var l=o<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this._strip();var f;if(this.length>1)f=1;else{l&&(o=-o),n(o<=67108863,"Number is too big");var g=this.words[0]|0;f=g===o?0:go.length)return 1;if(this.length=0;f--){var g=this.words[f]|0,m=o.words[f]|0;if(g!==m){gm&&(l=1);break}}return l},s.prototype.gtn=function(o){return this.cmpn(o)===1},s.prototype.gt=function(o){return this.cmp(o)===1},s.prototype.gten=function(o){return this.cmpn(o)>=0},s.prototype.gte=function(o){return this.cmp(o)>=0},s.prototype.ltn=function(o){return this.cmpn(o)===-1},s.prototype.lt=function(o){return this.cmp(o)===-1},s.prototype.lten=function(o){return this.cmpn(o)<=0},s.prototype.lte=function(o){return this.cmp(o)<=0},s.prototype.eqn=function(o){return this.cmpn(o)===0},s.prototype.eq=function(o){return this.cmp(o)===0},s.red=function(o){return new H(o)},s.prototype.toRed=function(o){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),o.convertTo(this)._forceRed(o)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(o){return this.red=o,this},s.prototype.forceRed=function(o){return n(!this.red,"Already a number in reduction context"),this._forceRed(o)},s.prototype.redAdd=function(o){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,o)},s.prototype.redIAdd=function(o){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,o)},s.prototype.redSub=function(o){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,o)},s.prototype.redISub=function(o){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,o)},s.prototype.redShl=function(o){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,o)},s.prototype.redMul=function(o){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.mul(this,o)},s.prototype.redIMul=function(o){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.imul(this,o)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(o){return n(this.red&&!o.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,o)};var C={k256:null,p224:null,p192:null,p25519:null};function P(b,o){this.name=b,this.p=new s(o,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}P.prototype._tmp=function(){var o=new s(null);return o.words=new Array(Math.ceil(this.n/13)),o},P.prototype.ireduce=function(o){var l=o,f;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),f=l.bitLength();while(f>this.n);var g=f0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},P.prototype.split=function(o,l){o.iushrn(this.n,0,l)},P.prototype.imulK=function(o){return o.imul(this.k)};function J(){P.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(J,P),J.prototype.split=function(o,l){for(var f=4194303,g=Math.min(o.length,9),m=0;m>>22,w=_}w>>>=22,o.words[m-10]=w,w===0&&o.length>10?o.length-=10:o.length-=9},J.prototype.imulK=function(o){o.words[o.length]=0,o.words[o.length+1]=0,o.length+=2;for(var l=0,f=0;f>>=26,o.words[f]=m,l=g}return l!==0&&(o.words[o.length++]=l),o},s._prime=function(o){if(C[o])return C[o];var l;if(o==="k256")l=new J;else if(o==="p224")l=new We;else if(o==="p192")l=new Qe;else if(o==="p25519")l=new Y;else throw new Error("Unknown prime "+o);return C[o]=l,l};function H(b){if(typeof b=="string"){var o=s._prime(b);this.m=o.p,this.prime=o}else n(b.gtn(1),"modulus must be greater than 1"),this.m=b,this.prime=null}H.prototype._verify1=function(o){n(o.negative===0,"red works only with positives"),n(o.red,"red works only with red numbers")},H.prototype._verify2=function(o,l){n((o.negative|l.negative)===0,"red works only with positives"),n(o.red&&o.red===l.red,"red works only with red numbers")},H.prototype.imod=function(o){return this.prime?this.prime.ireduce(o)._forceRed(this):(y(o,o.umod(this.m)._forceRed(this)),o)},H.prototype.neg=function(o){return o.isZero()?o.clone():this.m.sub(o)._forceRed(this)},H.prototype.add=function(o,l){this._verify2(o,l);var f=o.add(l);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},H.prototype.iadd=function(o,l){this._verify2(o,l);var f=o.iadd(l);return f.cmp(this.m)>=0&&f.isub(this.m),f},H.prototype.sub=function(o,l){this._verify2(o,l);var f=o.sub(l);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},H.prototype.isub=function(o,l){this._verify2(o,l);var f=o.isub(l);return f.cmpn(0)<0&&f.iadd(this.m),f},H.prototype.shl=function(o,l){return this._verify1(o),this.imod(o.ushln(l))},H.prototype.imul=function(o,l){return this._verify2(o,l),this.imod(o.imul(l))},H.prototype.mul=function(o,l){return this._verify2(o,l),this.imod(o.mul(l))},H.prototype.isqr=function(o){return this.imul(o,o.clone())},H.prototype.sqr=function(o){return this.mul(o,o)},H.prototype.sqrt=function(o){if(o.isZero())return o.clone();var l=this.m.andln(3);if(n(l%2===1),l===3){var f=this.m.add(new s(1)).iushrn(2);return this.pow(o,f)}for(var g=this.m.subn(1),m=0;!g.isZero()&&g.andln(1)===0;)m++,g.iushrn(1);n(!g.isZero());var w=new s(1).toRed(this),_=w.redNeg(),p=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new s(2*a*a).toRed(this);this.pow(a,p).cmp(_)!==0;)a.redIAdd(_);for(var v=this.pow(a,g),N=this.pow(o,g.addn(1).iushrn(1)),I=this.pow(o,g),$=m;I.cmp(w)!==0;){for(var ze=I,G=0;ze.cmp(w)!==0;G++)ze=ze.redSqr();n(G<$);var Z=this.pow(v,new s(1).iushln($-G-1));N=N.redMul(Z),v=Z.redSqr(),I=I.redMul(v),$=G}return N},H.prototype.invm=function(o){var l=o._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},H.prototype.pow=function(o,l){if(l.isZero())return new s(1).toRed(this);if(l.cmpn(1)===0)return o.clone();var f=4,g=new Array(1<=0;m--){for(var v=l.words[m],N=a-1;N>=0;N--){var I=v>>N&1;if(w!==g[0]&&(w=this.sqr(w)),I===0&&_===0){p=0;continue}_<<=1,_|=I,p++,!(p!==f&&(m!==0||N!==0))&&(w=this.mul(w,g[_]),p=0,_=0)}a=26}return w},H.prototype.convertTo=function(o){var l=o.umod(this.m);return l===o?l.clone():l},H.prototype.convertFrom=function(o){var l=o.clone();return l.red=null,l},s.mont=function(o){return new q(o)};function q(b){H.call(this,b),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(q,H),q.prototype.convertTo=function(o){return this.imod(o.ushln(this.shift))},q.prototype.convertFrom=function(o){var l=this.imod(o.mul(this.rinv));return l.red=null,l},q.prototype.imul=function(o,l){if(o.isZero()||l.isZero())return o.words[0]=0,o.length=1,o;var f=o.imul(l),g=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=f.isub(g).iushrn(this.shift),w=m;return m.cmp(this.m)>=0?w=m.isub(this.m):m.cmpn(0)<0&&(w=m.iadd(this.m)),w._forceRed(this)},q.prototype.mul=function(o,l){if(o.isZero()||l.isZero())return new s(0)._forceRed(this);var f=o.mul(l),g=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=f.isub(g).iushrn(this.shift),w=m;return m.cmp(this.m)>=0?w=m.isub(this.m):m.cmpn(0)<0&&(w=m.iadd(this.m)),w._forceRed(this)},q.prototype.invm=function(o){var l=this.imod(o._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(t,x)})(Us);var un=Us.exports,Sr={},St={};Object.defineProperty(St,"__esModule",{value:!0});St.errorValues=St.standardErrorCodes=void 0;St.standardErrorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}};St.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}};var dn={},hn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serialize=t.getErrorCode=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=St,r="Unspecified error message.";t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function n(E,M=r){if(E&&Number.isInteger(E)){const k=E.toString();if(y(e.errorValues,k))return e.errorValues[k].message;if(d(E))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return M}t.getMessageFromCode=n;function i(E){if(!Number.isInteger(E))return!1;const M=E.toString();return!!(e.errorValues[M]||d(E))}t.isValidCode=i;function s(E){var M;if(typeof E=="number")return E;if(c(E))return(M=E.code)!==null&&M!==void 0?M:E.errorCode}t.getErrorCode=s;function c(E){return typeof E=="object"&&E!==null&&(typeof E.code=="number"||typeof E.errorCode=="number")}function u(E,{shouldIncludeStack:M=!1}={}){const k={};if(E&&typeof E=="object"&&!Array.isArray(E)&&y(E,"code")&&i(E.code)){const T=E;k.code=T.code,T.message&&typeof T.message=="string"?(k.message=T.message,y(T,"data")&&(k.data=T.data)):(k.message=n(k.code),k.data={originalError:h(E)})}else k.code=e.standardErrorCodes.rpc.internal,k.message=S(E,"message")?E.message:r,k.data={originalError:h(E)};return M&&(k.stack=S(E,"stack")?E.stack:void 0),k}t.serialize=u;function d(E){return E>=-32099&&E<=-32e3}function h(E){return E&&typeof E=="object"&&!Array.isArray(E)?Object.assign({},E):E}function y(E,M){return Object.prototype.hasOwnProperty.call(E,M)}function S(E,M){return typeof E=="object"&&E!==null&&M in E&&typeof E[M]=="string"}})(hn);Object.defineProperty(dn,"__esModule",{value:!0});dn.standardErrors=void 0;const He=St,na=hn;dn.standardErrors={rpc:{parse:t=>rt(He.standardErrorCodes.rpc.parse,t),invalidRequest:t=>rt(He.standardErrorCodes.rpc.invalidRequest,t),invalidParams:t=>rt(He.standardErrorCodes.rpc.invalidParams,t),methodNotFound:t=>rt(He.standardErrorCodes.rpc.methodNotFound,t),internal:t=>rt(He.standardErrorCodes.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return rt(e,t)},invalidInput:t=>rt(He.standardErrorCodes.rpc.invalidInput,t),resourceNotFound:t=>rt(He.standardErrorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>rt(He.standardErrorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>rt(He.standardErrorCodes.rpc.transactionRejected,t),methodNotSupported:t=>rt(He.standardErrorCodes.rpc.methodNotSupported,t),limitExceeded:t=>rt(He.standardErrorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>Wt(He.standardErrorCodes.provider.userRejectedRequest,t),unauthorized:t=>Wt(He.standardErrorCodes.provider.unauthorized,t),unsupportedMethod:t=>Wt(He.standardErrorCodes.provider.unsupportedMethod,t),disconnected:t=>Wt(He.standardErrorCodes.provider.disconnected,t),chainDisconnected:t=>Wt(He.standardErrorCodes.provider.chainDisconnected,t),unsupportedChain:t=>Wt(He.standardErrorCodes.provider.unsupportedChain,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:r,data:n}=t;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new oa(e,r,n)}}};function rt(t,e){const[r,n]=sa(e);return new ia(t,r||(0,na.getMessageFromCode)(t),n)}function Wt(t,e){const[r,n]=sa(e);return new oa(t,r||(0,na.getMessageFromCode)(t),n)}function sa(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,r]}}return[]}let ia=class extends Error{constructor(e,r,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string.');super(r),this.code=e,n!==void 0&&(this.data=n)}},oa=class extends ia{constructor(e,r,n){if(!Fc(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,r,n)}};function Fc(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}var fn={},cr={};Object.defineProperty(cr,"__esModule",{value:!0});cr.isErrorResponse=void 0;function Hc(t){return t.errorMessage!==void 0}cr.isErrorResponse=Hc;var lr={};Object.defineProperty(lr,"__esModule",{value:!0});lr.LIB_VERSION=void 0;lr.LIB_VERSION="3.9.3";Object.defineProperty(fn,"__esModule",{value:!0});fn.serializeError=void 0;const Uc=cr,Vc=lr,Wc=St,zc=hn;function qc(t,e){const r=(0,zc.serialize)(Jc(t),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");n.searchParams.set("version",Vc.LIB_VERSION),n.searchParams.set("code",r.code.toString());const i=Gc(r.data,e);return i&&n.searchParams.set("method",i),n.searchParams.set("message",r.message),Object.assign(Object.assign({},r),{docUrl:n.href})}fn.serializeError=qc;function Jc(t){return typeof t=="string"?{message:t,code:Wc.standardErrorCodes.rpc.internal}:(0,Uc.isErrorResponse)(t)?Object.assign(Object.assign({},t),{message:t.errorMessage,code:t.errorCode,data:{method:t.method}}):t}function Gc(t,e){const r=t==null?void 0:t.method;if(r)return r;if(e!==void 0){if(typeof e=="string")return e;if(Array.isArray(e)){if(e.length>0)return e[0].method}else return e.method}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.standardErrors=t.standardErrorCodes=t.serializeError=t.getMessageFromCode=t.getErrorCode=void 0;const e=St;Object.defineProperty(t,"standardErrorCodes",{enumerable:!0,get:function(){return e.standardErrorCodes}});const r=dn;Object.defineProperty(t,"standardErrors",{enumerable:!0,get:function(){return r.standardErrors}});const n=fn;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return n.serializeError}});const i=hn;Object.defineProperty(t,"getErrorCode",{enumerable:!0,get:function(){return i.getErrorCode}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return i.getMessageFromCode}})})(Sr);var De={};Object.defineProperty(De,"__esModule",{value:!0});De.ProviderType=De.RegExpString=De.IntNumber=De.BigIntString=De.AddressString=De.HexString=De.OpaqueType=void 0;function Mr(){return t=>t}De.OpaqueType=Mr;De.HexString=Mr();De.AddressString=Mr();De.BigIntString=Mr();function Zc(t){return Math.floor(t)}De.IntNumber=Zc;De.RegExpString=Mr();var Vi;(function(t){t.CoinbaseWallet="CoinbaseWallet",t.MetaMask="MetaMask",t.Unselected=""})(Vi||(De.ProviderType=Vi={}));var Qc=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(A,"__esModule",{value:!0});A.isMobileWeb=A.getLocation=A.isInIFrame=A.createQrUrl=A.getFavicon=A.range=A.isBigNumber=A.ensureParsedJSONObject=A.ensureBN=A.ensureRegExpString=A.ensureIntNumber=A.ensureBuffer=A.ensureAddressString=A.ensureEvenLengthHexString=A.ensureHexString=A.isHexString=A.prepend0x=A.strip0x=A.has0xPrefix=A.hexStringFromIntNumber=A.intNumberFromHexString=A.bigIntStringFromBN=A.hexStringFromBuffer=A.hexStringToUint8Array=A.uint8ArrayToHex=A.randomBytesHex=void 0;const Rt=Qc(un),Ht=Sr,ot=De,aa=/^[0-9]*$/,ca=/^[a-f0-9]*$/;function Kc(t){return la(crypto.getRandomValues(new Uint8Array(t)))}A.randomBytesHex=Kc;function la(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}A.uint8ArrayToHex=la;function Xc(t){return new Uint8Array(t.match(/.{1,2}/g).map(e=>parseInt(e,16)))}A.hexStringToUint8Array=Xc;function Yc(t,e=!1){const r=t.toString("hex");return(0,ot.HexString)(e?`0x${r}`:r)}A.hexStringFromBuffer=Yc;function el(t){return(0,ot.BigIntString)(t.toString(10))}A.bigIntStringFromBN=el;function tl(t){return(0,ot.IntNumber)(new Rt.default(Rr(t,!1),16).toNumber())}A.intNumberFromHexString=tl;function rl(t){return(0,ot.HexString)(`0x${new Rt.default(t).toString(16)}`)}A.hexStringFromIntNumber=rl;function Vs(t){return t.startsWith("0x")||t.startsWith("0X")}A.has0xPrefix=Vs;function gn(t){return Vs(t)?t.slice(2):t}A.strip0x=gn;function ua(t){return Vs(t)?`0x${t.slice(2)}`:`0x${t}`}A.prepend0x=ua;function kr(t){if(typeof t!="string")return!1;const e=gn(t).toLowerCase();return ca.test(e)}A.isHexString=kr;function da(t,e=!1){if(typeof t=="string"){const r=gn(t).toLowerCase();if(ca.test(r))return(0,ot.HexString)(e?`0x${r}`:r)}throw Ht.standardErrors.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}A.ensureHexString=da;function Rr(t,e=!1){let r=da(t,!1);return r.length%2===1&&(r=(0,ot.HexString)(`0${r}`)),e?(0,ot.HexString)(`0x${r}`):r}A.ensureEvenLengthHexString=Rr;function nl(t){if(typeof t=="string"){const e=gn(t).toLowerCase();if(kr(e)&&e.length===40)return(0,ot.AddressString)(ua(e))}throw Ht.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`)}A.ensureAddressString=nl;function sl(t){if(Buffer.isBuffer(t))return t;if(typeof t=="string"){if(kr(t)){const e=Rr(t,!1);return Buffer.from(e,"hex")}return Buffer.from(t,"utf8")}throw Ht.standardErrors.rpc.invalidParams(`Not binary data: ${String(t)}`)}A.ensureBuffer=sl;function ha(t){if(typeof t=="number"&&Number.isInteger(t))return(0,ot.IntNumber)(t);if(typeof t=="string"){if(aa.test(t))return(0,ot.IntNumber)(Number(t));if(kr(t))return(0,ot.IntNumber)(new Rt.default(Rr(t,!1),16).toNumber())}throw Ht.standardErrors.rpc.invalidParams(`Not an integer: ${String(t)}`)}A.ensureIntNumber=ha;function il(t){if(t instanceof RegExp)return(0,ot.RegExpString)(t.toString());throw Ht.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(t)}`)}A.ensureRegExpString=il;function ol(t){if(t!==null&&(Rt.default.isBN(t)||fa(t)))return new Rt.default(t.toString(10),10);if(typeof t=="number")return new Rt.default(ha(t));if(typeof t=="string"){if(aa.test(t))return new Rt.default(t,10);if(kr(t))return new Rt.default(Rr(t,!1),16)}throw Ht.standardErrors.rpc.invalidParams(`Not an integer: ${String(t)}`)}A.ensureBN=ol;function al(t){if(typeof t=="string")return JSON.parse(t);if(typeof t=="object")return t;throw Ht.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`)}A.ensureParsedJSONObject=al;function fa(t){if(t==null||typeof t.constructor!="function")return!1;const{constructor:e}=t;return typeof e.config=="function"&&typeof e.EUCLID=="number"}A.isBigNumber=fa;function cl(t,e){return Array.from({length:e-t},(r,n)=>t+n)}A.range=cl;function ll(){const t=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:r}=document.location,n=t?t.getAttribute("href"):null;return!n||n.startsWith("javascript:")||n.startsWith("vbscript:")?null:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?e+n:`${e}//${r}${n}`}A.getFavicon=ll;function ul(t,e,r,n,i,s){const c=n?"parent-id":"id",u=new URLSearchParams({[c]:t,secret:e,server:r,v:i,chainId:s.toString()}).toString();return`${r}/#/link?${u}`}A.createQrUrl=ul;function ga(){try{return window.frameElement!==null}catch{return!1}}A.isInIFrame=ga;function dl(){try{return ga()&&window.top?window.top.location:window.location}catch{return window.location}}A.getLocation=dl;function hl(){var t;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t=window==null?void 0:window.navigator)===null||t===void 0?void 0:t.userAgent)}A.isMobileWeb=hl;var pn={};Object.defineProperty(pn,"__esModule",{value:!0});pn.ScopedLocalStorage=void 0;class fl{constructor(e){this.scope=e}setItem(e,r){localStorage.setItem(this.scopedKey(e),r)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),r=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(e){return`${this.scope}:${e}`}}pn.ScopedLocalStorage=fl;var rr={},Ir={},Cr={},ur={};Object.defineProperty(ur,"__esModule",{value:!0});ur.EVENTS=void 0;ur.EVENTS={STARTED_CONNECTING:"walletlink_sdk.started.connecting",CONNECTED_STATE_CHANGE:"walletlink_sdk.connected",DISCONNECTED:"walletlink_sdk.disconnected",METADATA_DESTROYED:"walletlink_sdk_metadata_destroyed",LINKED:"walletlink_sdk.linked",FAILURE:"walletlink_sdk.generic_failure",SESSION_CONFIG_RECEIVED:"walletlink_sdk.session_config_event_received",ETH_ACCOUNTS_STATE:"walletlink_sdk.eth_accounts_state",SESSION_STATE_CHANGE:"walletlink_sdk.session_state_change",UNLINKED_ERROR_STATE:"walletlink_sdk.unlinked_error_state",SKIPPED_CLEARING_SESSION:"walletlink_sdk.skipped_clearing_session",GENERAL_ERROR:"walletlink_sdk.general_error",WEB3_REQUEST:"walletlink_sdk.web3.request",WEB3_REQUEST_PUBLISHED:"walletlink_sdk.web3.request_published",WEB3_RESPONSE:"walletlink_sdk.web3.response",METHOD_NOT_IMPLEMENTED:"walletlink_sdk.method_not_implemented",UNKNOWN_ADDRESS_ENCOUNTERED:"walletlink_sdk.unknown_address_encountered"};var it={};Object.defineProperty(it,"__esModule",{value:!0});it.RelayAbstract=it.APP_VERSION_KEY=it.LOCAL_STORAGE_ADDRESSES_KEY=it.WALLET_USER_NAME_KEY=void 0;const Wi=Sr;it.WALLET_USER_NAME_KEY="walletUsername";it.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";it.APP_VERSION_KEY="AppVersion";class gl{async makeEthereumJSONRPCRequest(e,r){if(!r)throw new Error("Error: No jsonRpcUrl provided");return window.fetch(r,{method:"POST",body:JSON.stringify(e),mode:"cors",headers:{"Content-Type":"application/json"}}).then(n=>n.json()).then(n=>{if(!n)throw Wi.standardErrors.rpc.parse({});const i=n,{error:s}=i;if(s)throw(0,Wi.serializeError)(s,e.method);return i})}}it.RelayAbstract=gl;var dr={};Object.defineProperty(dr,"__esModule",{value:!0});dr.Session=void 0;const zi=Oc,qi=A,Ji="session:id",Gi="session:secret",Zi="session:linked";class Ws{constructor(e,r,n,i){this._storage=e,this._id=r||(0,qi.randomBytesHex)(16),this._secret=n||(0,qi.randomBytesHex)(32),this._key=new zi.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!i}static load(e){const r=e.getItem(Ji),n=e.getItem(Zi),i=e.getItem(Gi);return r&&i?new Ws(e,r,i,n==="1"):null}static hash(e){return new zi.sha256().update(e).digest("hex")}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this._storage.setItem(Ji,this._id),this._storage.setItem(Gi,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(Zi,this._linked?"1":"0")}}dr.Session=Ws;var mn={},vn={};Object.defineProperty(vn,"__esModule",{value:!0});vn.Cipher=void 0;const Wr=A;class pl{constructor(e){this.secret=e}async encrypt(e){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",(0,Wr.hexStringToUint8Array)(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=new TextEncoder,c=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,s.encode(e)),u=16,d=c.slice(c.byteLength-u),h=c.slice(0,c.byteLength-u),y=new Uint8Array(d),S=new Uint8Array(h),E=new Uint8Array([...n,...y,...S]);return(0,Wr.uint8ArrayToHex)(E)}async decrypt(e){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");return new Promise((n,i)=>{(async function(){const s=await crypto.subtle.importKey("raw",(0,Wr.hexStringToUint8Array)(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),c=(0,Wr.hexStringToUint8Array)(e),u=c.slice(0,12),d=c.slice(12,28),h=c.slice(28),y=new Uint8Array([...h,...d]),S={name:"AES-GCM",iv:new Uint8Array(u)};try{const E=await window.crypto.subtle.decrypt(S,s,y),M=new TextDecoder;n(M.decode(E))}catch(E){i(E)}})()})}}vn.Cipher=pl;var wn={};Object.defineProperty(wn,"__esModule",{value:!0});wn.WalletLinkHTTP=void 0;class ml{constructor(e,r,n){this.linkAPIUrl=e,this.sessionId=r;const i=`${r}:${n}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(r=>fetch(`${this.linkAPIUrl}/events/${r.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(r=>console.error("Unabled to mark event as failed:",r))}async fetchUnseenEvents(){var e;const r=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(r.ok){const{events:n,error:i}=await r.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const s=(e=n==null?void 0:n.filter(c=>c.event==="Web3Response").map(c=>({type:"Event",sessionId:this.sessionId,eventId:c.id,event:c.event,data:c.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(s),s}throw new Error(`Check unseen events failed: ${r.status}`)}}wn.WalletLinkHTTP=ml;var nr={};Object.defineProperty(nr,"__esModule",{value:!0});nr.WalletLinkWebSocket=nr.ConnectionState=void 0;var Kt;(function(t){t[t.DISCONNECTED=0]="DISCONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED"})(Kt||(nr.ConnectionState=Kt={}));class vl{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,r=WebSocket){this.WebSocketClass=r,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,r)=>{var n;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(s){r(s);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,Kt.CONNECTING),i.onclose=s=>{var c;this.clearWebSocket(),r(new Error(`websocket error ${s.code}: ${s.reason}`)),(c=this.connectionStateListener)===null||c===void 0||c.call(this,Kt.DISCONNECTED)},i.onopen=s=>{var c;e(),(c=this.connectionStateListener)===null||c===void 0||c.call(this,Kt.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(d=>this.sendData(d)),this.pendingData=[])},i.onmessage=s=>{var c,u;if(s.data==="h")(c=this.incomingDataListener)===null||c===void 0||c.call(this,{type:"Heartbeat"});else try{const d=JSON.parse(s.data);(u=this.incomingDataListener)===null||u===void 0||u.call(this,d)}catch{}}})}disconnect(){var e;const{webSocket:r}=this;if(r){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,Kt.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{r.close()}catch{}}}sendData(e){const{webSocket:r}=this;if(!r){this.pendingData.push(e),this.connect();return}r.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}nr.WalletLinkWebSocket=vl;Object.defineProperty(mn,"__esModule",{value:!0});mn.WalletLinkConnection=void 0;const zt=De,wl=vn,ht=ur,Qi=it,qt=dr,yl=wn,zr=nr,Ki=1e4,bl=6e4;class _l{constructor({session:e,linkAPIUrl:r,listener:n,diagnostic:i,WebSocketClass:s=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,zt.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=u=>{if(!u)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",h=>u.JsonRpcUrl&&this.handleChainUpdated(h,u.JsonRpcUrl)]]).forEach((h,y)=>{const S=u[y];S!==void 0&&h(S)})},this.handleDestroyed=u=>{var d,h;u==="1"&&((d=this.listener)===null||d===void 0||d.resetAndReload(),(h=this.diagnostic)===null||h===void 0||h.log(ht.EVENTS.METADATA_DESTROYED,{alreadyDestroyed:this.isDestroyed,sessionIdHash:qt.Session.hash(this.session.id)}))},this.handleAccountUpdated=async u=>{var d,h;try{const y=await this.cipher.decrypt(u);(d=this.listener)===null||d===void 0||d.accountUpdated(y)}catch{(h=this.diagnostic)===null||h===void 0||h.log(ht.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"selectedAddress"})}},this.handleMetadataUpdated=async(u,d)=>{var h,y;try{const S=await this.cipher.decrypt(d);(h=this.listener)===null||h===void 0||h.metadataUpdated(u,S)}catch{(y=this.diagnostic)===null||y===void 0||y.log(ht.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:u})}},this.handleWalletUsernameUpdated=async u=>{this.handleMetadataUpdated(Qi.WALLET_USER_NAME_KEY,u)},this.handleAppVersionUpdated=async u=>{this.handleMetadataUpdated(Qi.APP_VERSION_KEY,u)},this.handleChainUpdated=async(u,d)=>{var h,y;try{const S=await this.cipher.decrypt(u),E=await this.cipher.decrypt(d);(h=this.listener)===null||h===void 0||h.chainUpdated(S,E)}catch{(y=this.diagnostic)===null||y===void 0||y.log(ht.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"chainId|jsonRpcUrl"})}},this.session=e,this.cipher=new wl.Cipher(e.secret),this.diagnostic=i,this.listener=n;const c=new zr.WalletLinkWebSocket(`${r}/rpc`,s);c.setConnectionStateListener(async u=>{var d;(d=this.diagnostic)===null||d===void 0||d.log(ht.EVENTS.CONNECTED_STATE_CHANGE,{state:u,sessionIdHash:qt.Session.hash(e.id)});let h=!1;switch(u){case zr.ConnectionState.DISCONNECTED:if(!this.destroyed){const y=async()=>{await new Promise(S=>setTimeout(S,5e3)),this.destroyed||c.connect().catch(()=>{y()})};y()}break;case zr.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),h=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},Ki),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case zr.ConnectionState.CONNECTING:break}this.connected!==h&&(this.connected=h)}),c.setIncomingDataListener(u=>{var d,h,y;switch(u.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const S=u.type==="IsLinkedOK"?u.linked:void 0;(d=this.diagnostic)===null||d===void 0||d.log(ht.EVENTS.LINKED,{sessionIdHash:qt.Session.hash(e.id),linked:S,type:u.type,onlineGuests:u.onlineGuests}),this.linked=S||u.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{(h=this.diagnostic)===null||h===void 0||h.log(ht.EVENTS.SESSION_CONFIG_RECEIVED,{sessionIdHash:qt.Session.hash(e.id),metadata_keys:u&&u.metadata?Object.keys(u.metadata):void 0}),this.handleSessionMetadataUpdated(u.metadata);break}case"Event":{this.handleIncomingEvent(u);break}}u.id!==void 0&&((y=this.requestResolutions.get(u.id))===null||y===void 0||y(u))}),this.ws=c,this.http=new yl.WalletLinkHTTP(r,e.id,e.key)}connect(){var e;if(this.destroyed)throw new Error("instance is destroyed");(e=this.diagnostic)===null||e===void 0||e.log(ht.EVENTS.STARTED_CONNECTING,{sessionIdHash:qt.Session.hash(this.session.id)}),this.ws.connect()}destroy(){var e;this.destroyed=!0,this.ws.disconnect(),(e=this.diagnostic)===null||e===void 0||e.log(ht.EVENTS.DISCONNECTED,{sessionIdHash:qt.Session.hash(this.session.id)}),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(e){var r,n;this._connected=e,e&&((r=this.onceConnected)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.connectedUpdated(e)}setOnceConnected(e){return new Promise(r=>{this.connected?e().then(r):this.onceConnected=()=>{e().then(r),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(e){var r,n;this._linked=e,e&&((r=this.onceLinked)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(e)}setOnceLinked(e){return new Promise(r=>{this.linked?e().then(r):this.onceLinked=()=>{e().then(r),this.onceLinked=void 0}})}async handleIncomingEvent(e){var r,n;if(!(e.type!=="Event"||e.event!=="Web3Response"))try{const i=await this.cipher.decrypt(e.data),s=JSON.parse(i);if(s.type!=="WEB3_RESPONSE")return;(r=this.listener)===null||r===void 0||r.handleWeb3ResponseMessage(s)}catch{(n=this.diagnostic)===null||n===void 0||n.log(ht.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"incomingEvent"})}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(r=>this.handleIncomingEvent(r))}async setSessionMetadata(e,r){const n={type:"SetSessionConfig",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[e]:r}};return this.setOnceConnected(async()=>{const i=await this.makeRequest(n);if(i.type==="Fail")throw new Error(i.error||"failed to set session metadata")})}async publishEvent(e,r,n=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},r),{origin:location.origin,relaySource:window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),s={type:"PublishEvent",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:e,data:i,callWebhook:n};return this.setOnceLinked(async()=>{const c=await this.makeRequest(s);if(c.type==="Fail")throw new Error(c.error||"failed to publish event");return c.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>Ki*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,r=bl){const n=e.id;this.sendData(e);let i;return Promise.race([new Promise((s,c)=>{i=window.setTimeout(()=>{c(new Error(`request ${n} timed out`))},r)}),new Promise(s=>{this.requestResolutions.set(n,c=>{clearTimeout(i),s(c),this.requestResolutions.delete(n)})})])}async authenticate(){const e={type:"HostSession",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},r=await this.makeRequest(e);if(r.type==="Fail")throw new Error(r.error||"failed to authentcate")}sendIsLinked(){const e={type:"IsLinked",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}sendGetSessionConfig(){const e={type:"GetSessionConfig",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}}mn.WalletLinkConnection=_l;var Ar={},Nr={},zs={};Object.defineProperty(zs,"__esModule",{value:!0});zs.default='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';var El=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Nr,"__esModule",{value:!0});Nr.injectCssReset=void 0;const Sl=El(zs);function Ml(){const t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode(Sl.default)),document.documentElement.appendChild(t)}Nr.injectCssReset=Ml;var yn={},bn={};function pa(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t))for(e=0;e65536?(n[0]=240|(i&1835008)>>>18,n[1]=128|(i&258048)>>>12,n[2]=128|(i&4032)>>>6,n[3]=128|i&63):i>2048?(n[0]=224|(i&61440)>>>12,n[1]=128|(i&4032)>>>6,n[2]=128|i&63):i>128?(n[0]=192|(i&1984)>>>6,n[1]=128|i&63):n[0]=i,this.parsedData.push(n)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}ma.prototype={getLength:function(t){return this.parsedData.length},write:function(t){for(var e=0,r=this.parsedData.length;e=7&&this.setupTypeNumber(t),this.dataCache==null&&(this.dataCache=wt.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(0<=r&&r<=6&&(n==0||n==6)||0<=n&&n<=6&&(r==0||r==6)||2<=r&&r<=4&&2<=n&&n<=4?this.modules[t+r][e+n]=!0:this.modules[t+r][e+n]=!1)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=K.getLostPoint(this);(r==0||t>n)&&(t=n,e=r)}return e},createMovieClip:function(t,e,r){var n=t.createEmptyMovieClip(e,r),i=1;this.make();for(var s=0;s>r&1)==1;this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(var r=0;r<18;r++){var n=!t&&(e>>r&1)==1;this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,n=K.getBCHTypeInfo(r),i=0;i<15;i++){var s=!t&&(n>>i&1)==1;i<6?this.modules[i][8]=s:i<8?this.modules[i+1][8]=s:this.modules[this.moduleCount-15+i][8]=s}for(var i=0;i<15;i++){var s=!t&&(n>>i&1)==1;i<8?this.modules[8][this.moduleCount-i-1]=s:i<9?this.modules[8][15-i-1+1]=s:this.modules[8][15-i-1]=s}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,n=this.moduleCount-1,i=7,s=0,c=this.moduleCount-1;c>0;c-=2)for(c==6&&c--;;){for(var u=0;u<2;u++)if(this.modules[n][c-u]==null){var d=!1;s>>i&1)==1);var h=K.getMask(e,n,c-u);h&&(d=!d),this.modules[n][c-u]=d,i--,i==-1&&(s++,i=7)}if(n+=r,n<0||this.moduleCount<=n){n-=r,r=-r;break}}}};wt.PAD0=236;wt.PAD1=17;wt.createData=function(t,e,r){for(var n=vt.getRSBlocks(t,e),i=new va,s=0;su*8)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+u*8+")");for(i.getLengthInBits()+4<=u*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=u*8||(i.put(wt.PAD0,8),i.getLengthInBits()>=u*8));)i.put(wt.PAD1,8);return wt.createBytes(i,n)};wt.createBytes=function(t,e){for(var r=0,n=0,i=0,s=new Array(e.length),c=new Array(e.length),u=0;u=0?M.get(k):0}}for(var T=0,y=0;y=0;)e^=K.G15<=0;)e^=K.G18<>>=1;return e},getPatternPosition:function(t){return K.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case Mt.PATTERN000:return(e+r)%2==0;case Mt.PATTERN001:return e%2==0;case Mt.PATTERN010:return r%3==0;case Mt.PATTERN011:return(e+r)%3==0;case Mt.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case Mt.PATTERN101:return e*r%2+e*r%3==0;case Mt.PATTERN110:return(e*r%2+e*r%3)%2==0;case Mt.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new Xt([1],0),r=0;r5&&(r+=3+s-5)}for(var n=0;n=256;)t-=255;return Fe.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(var Ue=0;Ue<8;Ue++)Fe.EXP_TABLE[Ue]=1<>>7-t%8&1)==1},put:function(t,e){for(var r=0;r>>e-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var vs=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function wa(t){if(this.options={padding:4,width:256,height:256,typeNumber:4,color:"#000000",background:"#ffffff",ecl:"M",image:{svg:"",width:0,height:0}},typeof t=="string"&&(t={content:t}),t)for(var e in t)this.options[e]=t[e];if(typeof this.options.content!="string")throw new Error("Expected 'content' as string!");if(this.options.content.length===0)throw new Error("Expected 'content' to be non-empty!");if(!(this.options.padding>=0))throw new Error("Expected 'padding' value to be non-negative!");if(!(this.options.width>0)||!(this.options.height>0))throw new Error("Expected 'width' or 'height' value to be higher than zero!");function r(d){switch(d){case"L":return It.L;case"M":return It.M;case"Q":return It.Q;case"H":return It.H;default:throw new Error("Unknwon error correction level: "+d)}}function n(d,h){for(var y=i(d),S=1,E=0,M=0,k=vs.length;M<=k;M++){var T=vs[M];if(!T)throw new Error("Content too long: expected "+E+" but got "+y);switch(h){case"L":E=T[0];break;case"M":E=T[1];break;case"Q":E=T[2];break;case"H":E=T[3];break;default:throw new Error("Unknwon error correction level: "+h)}if(y<=E)break;S++}if(S>vs.length)throw new Error("Content too long");return S}function i(d){var h=encodeURI(d).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return h.length+(h.length!=d?3:0)}var s=this.options.content,c=n(s,this.options.ecl),u=r(this.options.ecl);this.qrcode=new wt(c,u),this.qrcode.addData(s),this.qrcode.make()}wa.prototype.svg=function(t){var e=this.options||{},r=this.qrcode.modules;typeof t>"u"&&(t={container:e.container||"svg"});for(var n=typeof e.pretty<"u"?!!e.pretty:!0,i=n?" ":"",s=n?`\r -`:"",c=e.width,u=e.height,d=r.length,h=c/(d+2*e.padding),y=u/(d+2*e.padding),S=typeof e.join<"u"?!!e.join:!1,E=typeof e.swap<"u"?!!e.swap:!1,M=typeof e.xmlDeclaration<"u"?!!e.xmlDeclaration:!0,k=typeof e.predefined<"u"?!!e.predefined:!1,T=k?i+''+s:"",O=i+''+s,B="",L="",R=0;R'+s:B+=i+''+s}}S&&(B=i+'');let H="";if(this.options.image!==void 0&&this.options.image.svg){const b=c*this.options.image.width/100,o=u*this.options.image.height/100,l=c/2-b/2,f=u/2-o/2;H+=``,H+=this.options.image.svg+s,H+=""}var q="";switch(t.container){case"svg":M&&(q+=''+s),q+=''+s,q+=T+O+B,q+=H,q+="";break;case"svg-viewbox":M&&(q+=''+s),q+=''+s,q+=T+O+B,q+=H,q+="";break;case"g":q+=''+s,q+=T+O+B,q+=H,q+="";break;default:q+=(T+O+B+H).replace(/^\s+/,"");break}return q};var Al=wa,Nl=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.QRCode=void 0;const Ll=Ke,eo=an,xl=Nl(Al),Tl=t=>{const[e,r]=(0,eo.useState)("");return(0,eo.useEffect)(()=>{var n,i;const s=new xl.default({content:t.content,background:t.bgColor||"#ffffff",color:t.fgColor||"#000000",container:"svg",ecl:"M",width:(n=t.width)!==null&&n!==void 0?n:256,height:(i=t.height)!==null&&i!==void 0?i:256,padding:0,image:t.image}),c=Buffer.from(s.svg(),"utf8").toString("base64");r(`data:image/svg+xml;base64,${c}`)},[t.bgColor,t.content,t.fgColor,t.height,t.image,t.width]),e?(0,Ll.h)("img",{src:e,alt:"QR Code"}):null};Mn.QRCode=Tl;var kn={},qs={};Object.defineProperty(qs,"__esModule",{value:!0});qs.default=".-cbwsdk-css-reset .-cbwsdk-spinner{display:inline-block}.-cbwsdk-css-reset .-cbwsdk-spinner svg{display:inline-block;animation:2s linear infinite -cbwsdk-spinner-svg}.-cbwsdk-css-reset .-cbwsdk-spinner svg circle{animation:1.9s ease-in-out infinite both -cbwsdk-spinner-circle;display:block;fill:rgba(0,0,0,0);stroke-dasharray:283;stroke-dashoffset:280;stroke-linecap:round;stroke-width:10px;transform-origin:50% 50%}@keyframes -cbwsdk-spinner-svg{0%{transform:rotateZ(0deg)}100%{transform:rotateZ(360deg)}}@keyframes -cbwsdk-spinner-circle{0%,25%{stroke-dashoffset:280;transform:rotate(0)}50%,75%{stroke-dashoffset:75;transform:rotate(45deg)}100%{stroke-dashoffset:280;transform:rotate(360deg)}}";var Pl=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(kn,"__esModule",{value:!0});kn.Spinner=void 0;const Jr=Ke,$l=Pl(qs),Ol=t=>{var e;const r=(e=t.size)!==null&&e!==void 0?e:64,n=t.color||"#000";return(0,Jr.h)("div",{class:"-cbwsdk-spinner"},(0,Jr.h)("style",null,$l.default),(0,Jr.h)("svg",{viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",style:{width:r,height:r}},(0,Jr.h)("circle",{style:{cx:50,cy:50,r:45,stroke:n}})))};kn.Spinner=Ol;var Js={};Object.defineProperty(Js,"__esModule",{value:!0});Js.default=".-cbwsdk-css-reset .-cbwsdk-connect-content{height:430px;width:700px;border-radius:12px;padding:30px}.-cbwsdk-css-reset .-cbwsdk-connect-content.light{background:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content.dark{background:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-connect-content-header{display:flex;align-items:center;justify-content:space-between;margin:0 0 30px}.-cbwsdk-css-reset .-cbwsdk-connect-content-heading{font-style:normal;font-weight:500;font-size:28px;line-height:36px;margin:0}.-cbwsdk-css-reset .-cbwsdk-connect-content-heading.light{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-connect-content-heading.dark{color:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content-layout{display:flex;flex-direction:row}.-cbwsdk-css-reset .-cbwsdk-connect-content-column-left{margin-right:30px;display:flex;flex-direction:column;justify-content:space-between}.-cbwsdk-css-reset .-cbwsdk-connect-content-column-right{flex:25%;margin-right:34px}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-wrapper{width:220px;height:220px;border-radius:12px;display:flex;justify-content:center;align-items:center;background:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting{position:absolute;top:0;bottom:0;left:0;right:0;display:flex;flex-direction:column;align-items:center;justify-content:center}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.light{background-color:rgba(255,255,255,.95)}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.light>p{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.dark{background-color:rgba(10,11,13,.9)}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.dark>p{color:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting>p{font-size:12px;font-weight:bold;margin-top:16px}.-cbwsdk-css-reset .-cbwsdk-connect-content-update-app{border-radius:8px;font-size:14px;line-height:20px;padding:12px;width:339px}.-cbwsdk-css-reset .-cbwsdk-connect-content-update-app.light{background:#eef0f3;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-connect-content-update-app.dark{background:#1e2025;color:#8a919e}.-cbwsdk-css-reset .-cbwsdk-cancel-button{-webkit-appearance:none;border:none;background:none;cursor:pointer;padding:0;margin:0}.-cbwsdk-css-reset .-cbwsdk-cancel-button-x{position:relative;display:block;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-wallet-steps{padding:0 0 0 16px;margin:0;width:100%;list-style:decimal}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item{list-style-type:decimal;display:list-item;font-style:normal;font-weight:400;font-size:16px;line-height:24px;margin-top:20px}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item.light{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item.dark{color:#fff}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item-wrapper{display:flex;align-items:center}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-pad-left{margin-left:6px}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon{display:flex;border-radius:50%;height:24px;width:24px}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon svg{margin:auto;display:block}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon.light{background:#0052ff}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon.dark{background:#588af5}.-cbwsdk-css-reset .-cbwsdk-connect-item{align-items:center;display:flex;flex-direction:row;padding:16px 24px;gap:12px;cursor:pointer;border-radius:100px;font-weight:600}.-cbwsdk-css-reset .-cbwsdk-connect-item.light{background:#f5f8ff;color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-connect-item.dark{background:#001033;color:#588af5}.-cbwsdk-css-reset .-cbwsdk-connect-item-copy-wrapper{margin:0 4px 0 8px}.-cbwsdk-css-reset .-cbwsdk-connect-item-title{margin:0 0 0;font-size:16px;line-height:24px;font-weight:500}.-cbwsdk-css-reset .-cbwsdk-connect-item-description{font-weight:400;font-size:14px;line-height:20px;margin:0}";var ya=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(sr,"__esModule",{value:!0});sr.CoinbaseWalletSteps=sr.ConnectContent=void 0;const Dt=ya(Lr),V=Ke,Bl=A,Dl=lr,jl=_n,Fl=En,Hl=Sn,Ul=Mn,Vl=kn,Wl=ya(Js),ws={title:"Coinbase Wallet app",description:"Connect with your self-custody wallet",steps:ba},zl=t=>t==="light"?"#FFFFFF":"#0A0B0D";function ql(t){const{theme:e}=t,r=(0,Bl.createQrUrl)(t.sessionId,t.sessionSecret,t.linkAPIUrl,t.isParentConnection,t.version,t.chainId),n=ws.steps;return(0,V.h)("div",{"data-testid":"connect-content",className:(0,Dt.default)("-cbwsdk-connect-content",e)},(0,V.h)("style",null,Wl.default),(0,V.h)("div",{className:"-cbwsdk-connect-content-header"},(0,V.h)("h2",{className:(0,Dt.default)("-cbwsdk-connect-content-heading",e)},"Scan to connect with our mobile app"),t.onCancel&&(0,V.h)("button",{type:"button",className:"-cbwsdk-cancel-button",onClick:t.onCancel},(0,V.h)(jl.CloseIcon,{fill:e==="light"?"#0A0B0D":"#FFFFFF"}))),(0,V.h)("div",{className:"-cbwsdk-connect-content-layout"},(0,V.h)("div",{className:"-cbwsdk-connect-content-column-left"},(0,V.h)(Jl,{title:ws.title,description:ws.description,theme:e})),(0,V.h)("div",{className:"-cbwsdk-connect-content-column-right"},(0,V.h)("div",{className:"-cbwsdk-connect-content-qr-wrapper"},(0,V.h)(Ul.QRCode,{content:r,width:200,height:200,fgColor:"#000",bgColor:"transparent"}),(0,V.h)("input",{type:"hidden",name:"cbw-cbwsdk-version",value:Dl.LIB_VERSION}),(0,V.h)("input",{type:"hidden",value:r})),(0,V.h)(n,{theme:e}),!t.isConnected&&(0,V.h)("div",{"data-testid":"connecting-spinner",className:(0,Dt.default)("-cbwsdk-connect-content-qr-connecting",e)},(0,V.h)(Vl.Spinner,{size:36,color:e==="dark"?"#FFF":"#000"}),(0,V.h)("p",null,"Connecting...")))))}sr.ConnectContent=ql;function Jl({title:t,description:e,theme:r}){return(0,V.h)("div",{className:(0,Dt.default)("-cbwsdk-connect-item",r)},(0,V.h)("div",null,(0,V.h)(Fl.CoinbaseWalletRound,null)),(0,V.h)("div",{className:"-cbwsdk-connect-item-copy-wrapper"},(0,V.h)("h3",{className:"-cbwsdk-connect-item-title"},t),(0,V.h)("p",{className:"-cbwsdk-connect-item-description"},e)))}function ba({theme:t}){return(0,V.h)("ol",{className:"-cbwsdk-wallet-steps"},(0,V.h)("li",{className:(0,Dt.default)("-cbwsdk-wallet-steps-item",t)},(0,V.h)("div",{className:"-cbwsdk-wallet-steps-item-wrapper"},"Open Coinbase Wallet app")),(0,V.h)("li",{className:(0,Dt.default)("-cbwsdk-wallet-steps-item",t)},(0,V.h)("div",{className:"-cbwsdk-wallet-steps-item-wrapper"},(0,V.h)("span",null,"Tap ",(0,V.h)("strong",null,"Scan")," "),(0,V.h)("span",{className:(0,Dt.default)("-cbwsdk-wallet-steps-pad-left","-cbwsdk-wallet-steps-icon",t)},(0,V.h)(Hl.QRCodeIcon,{fill:zl(t)})))))}sr.CoinbaseWalletSteps=ba;var Rn={},In={};Object.defineProperty(In,"__esModule",{value:!0});In.ArrowLeftIcon=void 0;const to=Ke;function Gl(t){return(0,to.h)("svg",Object.assign({width:"16",height:"16",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},t),(0,to.h)("path",{d:"M8.60675 0.155884L7.37816 1.28209L12.7723 7.16662H0V8.83328H12.6548L6.82149 14.6666L8 15.8451L15.8201 8.02501L8.60675 0.155884Z"}))}In.ArrowLeftIcon=Gl;var Cn={};Object.defineProperty(Cn,"__esModule",{value:!0});Cn.LaptopIcon=void 0;const ys=Ke;function Zl(t){return(0,ys.h)("svg",Object.assign({width:"14",height:"14",viewBox:"0 0 14 14",xmlns:"http://www.w3.org/2000/svg"},t),(0,ys.h)("path",{d:"M1.8001 2.2002H12.2001V9.40019H1.8001V2.2002ZM3.4001 3.8002V7.80019H10.6001V3.8002H3.4001Z"}),(0,ys.h)("path",{d:"M13.4001 10.2002H0.600098C0.600098 11.0838 1.31644 11.8002 2.2001 11.8002H11.8001C12.6838 11.8002 13.4001 11.0838 13.4001 10.2002Z"}))}Cn.LaptopIcon=Zl;var An={};Object.defineProperty(An,"__esModule",{value:!0});An.SafeIcon=void 0;const ro=Ke;function Ql(t){return(0,ro.h)("svg",Object.assign({width:"14",height:"14",viewBox:"0 0 14 14",xmlns:"http://www.w3.org/2000/svg"},t),(0,ro.h)("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M0.600098 0.600098V11.8001H13.4001V0.600098H0.600098ZM7.0001 9.2001C5.3441 9.2001 4.0001 7.8561 4.0001 6.2001C4.0001 4.5441 5.3441 3.2001 7.0001 3.2001C8.6561 3.2001 10.0001 4.5441 10.0001 6.2001C10.0001 7.8561 8.6561 9.2001 7.0001 9.2001ZM0.600098 12.6001H3.8001V13.4001H0.600098V12.6001ZM10.2001 12.6001H13.4001V13.4001H10.2001V12.6001ZM8.8001 6.2001C8.8001 7.19421 7.99421 8.0001 7.0001 8.0001C6.00598 8.0001 5.2001 7.19421 5.2001 6.2001C5.2001 5.20598 6.00598 4.4001 7.0001 4.4001C7.99421 4.4001 8.8001 5.20598 8.8001 6.2001Z"}))}An.SafeIcon=Ql;var Gs={};Object.defineProperty(Gs,"__esModule",{value:!0});Gs.default=".-cbwsdk-css-reset .-cbwsdk-try-extension{display:flex;margin-top:12px;height:202px;width:700px;border-radius:12px;padding:30px}.-cbwsdk-css-reset .-cbwsdk-try-extension.light{background:#fff}.-cbwsdk-css-reset .-cbwsdk-try-extension.dark{background:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-try-extension-column-half{flex:50%}.-cbwsdk-css-reset .-cbwsdk-try-extension-heading{font-style:normal;font-weight:500;font-size:25px;line-height:32px;margin:0;max-width:204px}.-cbwsdk-css-reset .-cbwsdk-try-extension-heading.light{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-try-extension-heading.dark{color:#fff}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta{appearance:none;border:none;background:none;color:#0052ff;cursor:pointer;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta.light{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta.dark{color:#588af5}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta-wrapper{display:flex;align-items:center;margin-top:12px}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta-icon{display:block;margin-left:4px;height:14px}.-cbwsdk-css-reset .-cbwsdk-try-extension-list{display:flex;flex-direction:column;justify-content:center;align-items:center;margin:0;padding:0;list-style:none;height:100%}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item{display:flex;align-items:center;flex-flow:nowrap;margin-top:24px}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item:first-of-type{margin-top:0}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon-wrapper{display:block}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon{display:flex;height:32px;width:32px;border-radius:50%}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon svg{margin:auto;display:block}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon.light{background:#eef0f3}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon.dark{background:#1e2025}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-copy{display:block;font-weight:400;font-size:14px;line-height:20px;padding-left:12px}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-copy.light{color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-copy.dark{color:#8a919e}";var _a=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Rn,"__esModule",{value:!0});Rn.TryExtensionContent=void 0;const Nt=_a(Lr),Be=Ke,bs=an,Kl=In,Xl=Cn,Yl=An,eu=_a(Gs);function tu({theme:t}){const[e,r]=(0,bs.useState)(!1),n=(0,bs.useCallback)(()=>{window.open("https://api.wallet.coinbase.com/rpc/v2/desktop/chrome","_blank")},[]),i=(0,bs.useCallback)(()=>{e?window.location.reload():(n(),r(!0))},[n,e]);return(0,Be.h)("div",{class:(0,Nt.default)("-cbwsdk-try-extension",t)},(0,Be.h)("style",null,eu.default),(0,Be.h)("div",{class:"-cbwsdk-try-extension-column-half"},(0,Be.h)("h3",{class:(0,Nt.default)("-cbwsdk-try-extension-heading",t)},"Or try the Coinbase Wallet browser extension"),(0,Be.h)("div",{class:"-cbwsdk-try-extension-cta-wrapper"},(0,Be.h)("button",{class:(0,Nt.default)("-cbwsdk-try-extension-cta",t),onClick:i},e?"Refresh":"Install"),(0,Be.h)("div",null,!e&&(0,Be.h)(Kl.ArrowLeftIcon,{class:"-cbwsdk-try-extension-cta-icon",fill:t==="light"?"#0052FF":"#588AF5"})))),(0,Be.h)("div",{class:"-cbwsdk-try-extension-column-half"},(0,Be.h)("ul",{class:"-cbwsdk-try-extension-list"},(0,Be.h)("li",{class:"-cbwsdk-try-extension-list-item"},(0,Be.h)("div",{class:"-cbwsdk-try-extension-list-item-icon-wrapper"},(0,Be.h)("span",{class:(0,Nt.default)("-cbwsdk-try-extension-list-item-icon",t)},(0,Be.h)(Xl.LaptopIcon,{fill:t==="light"?"#0A0B0D":"#FFFFFF"}))),(0,Be.h)("div",{class:(0,Nt.default)("-cbwsdk-try-extension-list-item-copy",t)},"Connect with dapps with just one click on your desktop browser")),(0,Be.h)("li",{class:"-cbwsdk-try-extension-list-item"},(0,Be.h)("div",{class:"-cbwsdk-try-extension-list-item-icon-wrapper"},(0,Be.h)("span",{class:(0,Nt.default)("-cbwsdk-try-extension-list-item-icon",t)},(0,Be.h)(Yl.SafeIcon,{fill:t==="light"?"#0A0B0D":"#FFFFFF"}))),(0,Be.h)("div",{class:(0,Nt.default)("-cbwsdk-try-extension-list-item-copy",t)},"Add an additional layer of security by using a supported Ledger hardware wallet")))))}Rn.TryExtensionContent=tu;var Zs={};Object.defineProperty(Zs,"__esModule",{value:!0});Zs.default=".-cbwsdk-css-reset .-cbwsdk-connect-dialog{z-index:2147483647;position:fixed;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop{z-index:2147483647;position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop.light{background-color:rgba(0,0,0,.5)}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop.dark{background-color:rgba(50,53,61,.4)}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-box{display:flex;position:relative;flex-direction:column;transform:scale(1);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-box-hidden{opacity:0;transform:scale(0.85)}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-container{display:block}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-container-hidden{display:none}";var Ea=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bn,"__esModule",{value:!0});bn.ConnectDialog=void 0;const _s=Ea(Lr),Lt=Ke,Es=an,ru=sr,nu=Rn,su=Ea(Zs),iu=t=>{const{isOpen:e,darkMode:r}=t,[n,i]=(0,Es.useState)(!e),[s,c]=(0,Es.useState)(!e);(0,Es.useEffect)(()=>{const d=[window.setTimeout(()=>{c(!e)},10)];return e?i(!1):d.push(window.setTimeout(()=>{i(!0)},360)),()=>{d.forEach(window.clearTimeout)}},[e]);const u=r?"dark":"light";return(0,Lt.h)("div",{class:(0,_s.default)("-cbwsdk-connect-dialog-container",n&&"-cbwsdk-connect-dialog-container-hidden")},(0,Lt.h)("style",null,su.default),(0,Lt.h)("div",{class:(0,_s.default)("-cbwsdk-connect-dialog-backdrop",u,s&&"-cbwsdk-connect-dialog-backdrop-hidden")}),(0,Lt.h)("div",{class:"-cbwsdk-connect-dialog"},(0,Lt.h)("div",{class:(0,_s.default)("-cbwsdk-connect-dialog-box",s&&"-cbwsdk-connect-dialog-box-hidden")},t.connectDisabled?null:(0,Lt.h)(ru.ConnectContent,{theme:u,version:t.version,sessionId:t.sessionId,sessionSecret:t.sessionSecret,linkAPIUrl:t.linkAPIUrl,isConnected:t.isConnected,isParentConnection:t.isParentConnection,chainId:t.chainId,onCancel:t.onCancel}),(0,Lt.h)(nu.TryExtensionContent,{theme:u}))))};bn.ConnectDialog=iu;Object.defineProperty(yn,"__esModule",{value:!0});yn.LinkFlow=void 0;const Ss=Ke,ou=bn;class au{constructor(e){this.connected=!1,this.chainId=1,this.isOpen=!1,this.onCancel=null,this.root=null,this.connectDisabled=!1,this.darkMode=e.darkMode,this.version=e.version,this.sessionId=e.sessionId,this.sessionSecret=e.sessionSecret,this.linkAPIUrl=e.linkAPIUrl,this.isParentConnection=e.isParentConnection}attach(e){this.root=document.createElement("div"),this.root.className="-cbwsdk-link-flow-root",e.appendChild(this.root),this.render()}setConnected(e){this.connected!==e&&(this.connected=e,this.render())}setChainId(e){this.chainId!==e&&(this.chainId=e,this.render())}detach(){var e;this.root&&((0,Ss.render)(null,this.root),(e=this.root.parentElement)===null||e===void 0||e.removeChild(this.root))}setConnectDisabled(e){this.connectDisabled=e}open(e){this.isOpen=!0,this.onCancel=e.onCancel,this.render()}close(){this.isOpen=!1,this.onCancel=null,this.render()}render(){this.root&&(0,Ss.render)((0,Ss.h)(ou.ConnectDialog,{darkMode:this.darkMode,version:this.version,sessionId:this.sessionId,sessionSecret:this.sessionSecret,linkAPIUrl:this.linkAPIUrl,isOpen:this.isOpen,isConnected:this.connected,isParentConnection:this.isParentConnection,chainId:this.chainId,onCancel:this.onCancel,connectDisabled:this.connectDisabled}),this.root)}}yn.LinkFlow=au;var Qs={},Ks={};Object.defineProperty(Ks,"__esModule",{value:!0});Ks.default=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}";(function(t){var e=x&&x.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(t,"__esModule",{value:!0}),t.SnackbarInstance=t.SnackbarContainer=t.Snackbar=void 0;const r=e(Lr),n=Ke,i=an,s=e(Ks),c="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",u="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class d{constructor(E){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=E.darkMode}attach(E){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",E.appendChild(this.root),this.render()}presentItem(E){const M=this.nextItemKey++;return this.items.set(M,E),this.render(),()=>{this.items.delete(M),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,n.render)((0,n.h)("div",null,(0,n.h)(t.SnackbarContainer,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([E,M])=>(0,n.h)(t.SnackbarInstance,Object.assign({},M,{key:E}))))),this.root)}}t.Snackbar=d;const h=S=>(0,n.h)("div",{class:(0,r.default)("-cbwsdk-snackbar-container")},(0,n.h)("style",null,s.default),(0,n.h)("div",{class:"-cbwsdk-snackbar"},S.children));t.SnackbarContainer=h;const y=({autoExpand:S,message:E,menuItems:M})=>{const[k,T]=(0,i.useState)(!0),[O,B]=(0,i.useState)(S??!1);(0,i.useEffect)(()=>{const R=[window.setTimeout(()=>{T(!1)},1),window.setTimeout(()=>{B(!0)},1e4)];return()=>{R.forEach(window.clearTimeout)}});const L=()=>{B(!O)};return(0,n.h)("div",{class:(0,r.default)("-cbwsdk-snackbar-instance",k&&"-cbwsdk-snackbar-instance-hidden",O&&"-cbwsdk-snackbar-instance-expanded")},(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:L},(0,n.h)("img",{src:c,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},E),(0,n.h)("div",{class:"-gear-container"},!O&&(0,n.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,n.h)("img",{src:u,class:"-gear-icon",title:"Expand"}))),M&&M.length>0&&(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-menu"},M.map((R,z)=>(0,n.h)("div",{class:(0,r.default)("-cbwsdk-snackbar-instance-menu-item",R.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:R.onClick,key:z},(0,n.h)("svg",{width:R.svgWidth,height:R.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("path",{"fill-rule":R.defaultFillRule,"clip-rule":R.defaultClipRule,d:R.path,fill:"#AAAAAA"})),(0,n.h)("span",{class:(0,r.default)("-cbwsdk-snackbar-instance-menu-item-info",R.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},R.info)))))};t.SnackbarInstance=y})(Qs);Object.defineProperty(Ar,"__esModule",{value:!0});Ar.WalletLinkRelayUI=void 0;const cu=Nr,lu=yn,uu=Qs;class du{constructor(e){this.standalone=null,this.attached=!1,this.snackbar=new uu.Snackbar({darkMode:e.darkMode}),this.linkFlow=new lu.LinkFlow({darkMode:e.darkMode,version:e.version,sessionId:e.session.id,sessionSecret:e.session.secret,linkAPIUrl:e.linkAPIUrl,isParentConnection:!1})}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,r=document.createElement("div");r.className="-cbwsdk-css-reset",e.appendChild(r),this.linkFlow.attach(r),this.snackbar.attach(r),this.attached=!0,(0,cu.injectCssReset)()}setConnected(e){this.linkFlow.setConnected(e)}setChainId(e){this.linkFlow.setChainId(e)}setConnectDisabled(e){this.linkFlow.setConnectDisabled(e)}addEthereumChain(){}watchAsset(){}switchEthereumChain(){}requestEthereumAccounts(e){this.linkFlow.open({onCancel:e.onCancel})}hideRequestEthereumAccounts(){this.linkFlow.close()}signEthereumMessage(){}signEthereumTransaction(){}submitEthereumTransaction(){}ethereumAddressFromSignedMessage(){}showConnecting(e){let r;return e.isUnlinkedErrorState?r={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:r={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(r)}reloadUI(){document.location.reload()}inlineAccountsResponse(){return!1}inlineAddEthereumChain(){return!1}inlineWatchAsset(){return!1}inlineSwitchEthereumChain(){return!1}setStandalone(e){this.standalone=e}isStandalone(){var e;return(e=this.standalone)!==null&&e!==void 0?e:!1}}Ar.WalletLinkRelayUI=du;Object.defineProperty(Cr,"__esModule",{value:!0});Cr.WalletLinkRelay=void 0;const Jt=Sr,hu=De,Q=A,xt=ur,no=it,kt=dr,fu=mn,Tt=cr,gu=Ar;class Et extends no.RelayAbstract{constructor(e){var r;super(),this.accountsCallback=null,this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.chainCallback=null,this.dappDefaultChain=1,this.appName="",this.appLogoUrl=null,this.linkedUpdated=c=>{var u;this.isLinked=c;const d=this.storage.getItem(no.LOCAL_STORAGE_ADDRESSES_KEY);if(c&&(this.session.linked=c),this.isUnlinkedErrorState=!1,d){const h=d.split(" "),y=this.storage.getItem("IsStandaloneSigning")==="true";if(h[0]!==""&&!c&&this.session.linked&&!y){this.isUnlinkedErrorState=!0;const S=this.getSessionIdHash();(u=this.diagnostic)===null||u===void 0||u.log(xt.EVENTS.UNLINKED_ERROR_STATE,{sessionIdHash:S})}}},this.metadataUpdated=(c,u)=>{this.storage.setItem(c,u)},this.chainUpdated=(c,u)=>{this.chainCallbackParams.chainId===c&&this.chainCallbackParams.jsonRpcUrl===u||(this.chainCallbackParams={chainId:c,jsonRpcUrl:u},this.chainCallback&&this.chainCallback(c,u))},this.accountUpdated=c=>{this.accountsCallback&&this.accountsCallback([c]),Et.accountRequestCallbackIds.size>0&&(Array.from(Et.accountRequestCallbackIds.values()).forEach(u=>{const d={type:"WEB3_RESPONSE",id:u,response:{method:"requestEthereumAccounts",result:[c]}};this.invokeCallback(Object.assign(Object.assign({},d),{id:u}))}),Et.accountRequestCallbackIds.clear())},this.connectedUpdated=c=>{this.ui.setConnected(c)},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage,this.options=e;const{session:n,ui:i,connection:s}=this.subscribe();this._session=n,this.connection=s,this.relayEventManager=e.relayEventManager,this.diagnostic=e.diagnosticLogger,this._reloadOnDisconnect=(r=e.reloadOnDisconnect)!==null&&r!==void 0?r:!0,this.ui=i}subscribe(){const e=kt.Session.load(this.storage)||new kt.Session(this.storage).save(),{linkAPIUrl:r,diagnostic:n}=this,i=new fu.WalletLinkConnection({session:e,linkAPIUrl:r,diagnostic:n,listener:this}),{version:s,darkMode:c}=this.options,u=this.options.uiConstructor({linkAPIUrl:r,version:s,darkMode:c,session:e});return i.connect(),{session:e,ui:u,connection:i}}attachUI(){this.ui.attach()}resetAndReload(){Promise.race([this.connection.setSessionMetadata("__destroyed","1"),new Promise(e=>setTimeout(()=>e(null),1e3))]).then(()=>{var e,r;const n=this.ui.isStandalone();(e=this.diagnostic)===null||e===void 0||e.log(xt.EVENTS.SESSION_STATE_CHANGE,{method:"relay::resetAndReload",sessionMetadataChange:"__destroyed, 1",sessionIdHash:this.getSessionIdHash()}),this.connection.destroy();const i=kt.Session.load(this.storage);if((i==null?void 0:i.id)===this._session.id?this.storage.clear():i&&((r=this.diagnostic)===null||r===void 0||r.log(xt.EVENTS.SKIPPED_CLEARING_SESSION,{sessionIdHash:this.getSessionIdHash(),storedSessionIdHash:kt.Session.hash(i.id)})),this._reloadOnDisconnect){this.ui.reloadUI();return}this.accountsCallback&&this.accountsCallback([],!0);const{session:s,ui:c,connection:u}=this.subscribe();this._session=s,this.connection=u,this.ui=c,n&&this.ui.setStandalone&&this.ui.setStandalone(!0),this.options.headlessMode||this.attachUI()}).catch(e=>{var r;(r=this.diagnostic)===null||r===void 0||r.log(xt.EVENTS.FAILURE,{method:"relay::resetAndReload",message:`failed to reset and reload with ${e}`,sessionIdHash:this.getSessionIdHash()})})}setAppInfo(e,r){this.appName=e,this.appLogoUrl=r}getStorageItem(e){return this.storage.getItem(e)}get session(){return this._session}setStorageItem(e,r){this.storage.setItem(e,r)}signEthereumMessage(e,r,n,i){return this.sendRequest({method:"signEthereumMessage",params:{message:(0,Q.hexStringFromBuffer)(e,!0),address:r,addPrefix:n,typedDataJson:i||null}})}ethereumAddressFromSignedMessage(e,r,n){return this.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:(0,Q.hexStringFromBuffer)(e,!0),signature:(0,Q.hexStringFromBuffer)(r,!0),addPrefix:n}})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,Q.bigIntStringFromBN)(e.weiValue),data:(0,Q.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,Q.bigIntStringFromBN)(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?(0,Q.bigIntStringFromBN)(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?(0,Q.bigIntStringFromBN)(e.gasPriceInWei):null,gasLimit:e.gasLimit?(0,Q.bigIntStringFromBN)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,Q.bigIntStringFromBN)(e.weiValue),data:(0,Q.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,Q.bigIntStringFromBN)(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?(0,Q.bigIntStringFromBN)(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?(0,Q.bigIntStringFromBN)(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?(0,Q.bigIntStringFromBN)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,r){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:(0,Q.hexStringFromBuffer)(e,!0),chainId:r}})}scanQRCode(e){return this.sendRequest({method:"scanQRCode",params:{regExp:e}})}getQRCodeUrl(){return(0,Q.createQrUrl)(this._session.id,this._session.secret,this.linkAPIUrl,!1,this.options.version,this.dappDefaultChain)}genericRequest(e,r){return this.sendRequest({method:"generic",params:{action:r,data:e}})}sendGenericMessage(e){return this.sendRequest(e)}sendRequest(e){let r=null;const n=(0,Q.randomBytesHex)(8),i=c=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,e.method,c),r==null||r()};return{promise:new Promise((c,u)=>{this.ui.isStandalone()||(r=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload})),this.relayEventManager.callbacks.set(n,d=>{if(r==null||r(),(0,Tt.isErrorResponse)(d))return u(new Error(d.errorMessage));c(d)}),this.ui.isStandalone()?this.sendRequestStandalone(n,e):this.publishWeb3RequestEvent(n,e)}),cancel:i}}setConnectDisabled(e){this.ui.setConnectDisabled(e)}setAccountsCallback(e){this.accountsCallback=e}setChainCallback(e){this.chainCallback=e}setDappDefaultChainCallback(e){this.dappDefaultChain=e,this.ui instanceof gu.WalletLinkRelayUI&&this.ui.setChainId(e)}publishWeb3RequestEvent(e,r){var n;const i={type:"WEB3_REQUEST",id:e,request:r},s=kt.Session.load(this.storage);(n=this.diagnostic)===null||n===void 0||n.log(xt.EVENTS.WEB3_REQUEST,{eventId:i.id,method:`relay::${r.method}`,sessionIdHash:this.getSessionIdHash(),storedSessionIdHash:s?kt.Session.hash(s.id):"",isSessionMismatched:((s==null?void 0:s.id)!==this._session.id).toString()}),this.publishEvent("Web3Request",i,!0).then(c=>{var u;(u=this.diagnostic)===null||u===void 0||u.log(xt.EVENTS.WEB3_REQUEST_PUBLISHED,{eventId:i.id,method:`relay::${r.method}`,sessionIdHash:this.getSessionIdHash(),storedSessionIdHash:s?kt.Session.hash(s.id):"",isSessionMismatched:((s==null?void 0:s.id)!==this._session.id).toString()})}).catch(c=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:i.id,response:{method:r.method,errorMessage:c.message}})})}publishWeb3RequestCanceledEvent(e){const r={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",r,!1).then()}publishEvent(e,r,n){return this.connection.publishEvent(e,r,n)}handleWeb3ResponseMessage(e){var r;const{response:n}=e;if((r=this.diagnostic)===null||r===void 0||r.log(xt.EVENTS.WEB3_RESPONSE,{eventId:e.id,method:`relay::${n.method}`,sessionIdHash:this.getSessionIdHash()}),n.method==="requestEthereumAccounts"){Et.accountRequestCallbackIds.forEach(i=>this.invokeCallback(Object.assign(Object.assign({},e),{id:i}))),Et.accountRequestCallbackIds.clear();return}this.invokeCallback(e)}handleErrorResponse(e,r,n,i){var s;const c=(s=n==null?void 0:n.message)!==null&&s!==void 0?s:(0,Jt.getMessageFromCode)(i);this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:e,response:{method:r,errorMessage:c,errorCode:i}})}invokeCallback(e){const r=this.relayEventManager.callbacks.get(e.id);r&&(r(e.response),this.relayEventManager.callbacks.delete(e.id))}requestEthereumAccounts(){const e={method:"requestEthereumAccounts",params:{appName:this.appName,appLogoUrl:this.appLogoUrl||null}},r=(0,Q.randomBytesHex)(8),n=s=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,e.method,s)};return{promise:new Promise((s,c)=>{if(this.relayEventManager.callbacks.set(r,u=>{if(this.ui.hideRequestEthereumAccounts(),(0,Tt.isErrorResponse)(u))return c(new Error(u.errorMessage));s(u)}),this.ui.inlineAccountsResponse()){const u=d=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:r,response:{method:"requestEthereumAccounts",result:d}})};this.ui.requestEthereumAccounts({onCancel:n,onAccounts:u})}else{const u=Jt.standardErrors.provider.userRejectedRequest("User denied account authorization");this.ui.requestEthereumAccounts({onCancel:()=>n(u)})}Et.accountRequestCallbackIds.add(r),!this.ui.inlineAccountsResponse()&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(r,e)}),cancel:n}}selectProvider(e){const r={method:"selectProvider",params:{providerOptions:e}},n=(0,Q.randomBytesHex)(8),i=c=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,r.method,c)},s=new Promise((c,u)=>{this.relayEventManager.callbacks.set(n,y=>{if((0,Tt.isErrorResponse)(y))return u(new Error(y.errorMessage));c(y)});const d=y=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:n,response:{method:"selectProvider",result:hu.ProviderType.Unselected}})},h=y=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:n,response:{method:"selectProvider",result:y}})};this.ui.selectProvider&&this.ui.selectProvider({onApprove:h,onCancel:d,providerOptions:e})});return{cancel:i,promise:s}}watchAsset(e,r,n,i,s,c){const u={method:"watchAsset",params:{type:e,options:{address:r,symbol:n,decimals:i,image:s},chainId:c}};let d=null;const h=(0,Q.randomBytesHex)(8),y=E=>{this.publishWeb3RequestCanceledEvent(h),this.handleErrorResponse(h,u.method,E),d==null||d()};this.ui.inlineWatchAsset()||(d=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:y,onResetConnection:this.resetAndReload}));const S=new Promise((E,M)=>{this.relayEventManager.callbacks.set(h,O=>{if(d==null||d(),(0,Tt.isErrorResponse)(O))return M(new Error(O.errorMessage));E(O)});const k=O=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"watchAsset",result:!1}})},T=()=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"watchAsset",result:!0}})};this.ui.inlineWatchAsset()&&this.ui.watchAsset({onApprove:T,onCancel:k,type:e,address:r,symbol:n,decimals:i,image:s,chainId:c}),!this.ui.inlineWatchAsset()&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(h,u)});return{cancel:y,promise:S}}addEthereumChain(e,r,n,i,s,c){const u={method:"addEthereumChain",params:{chainId:e,rpcUrls:r,blockExplorerUrls:i,chainName:s,iconUrls:n,nativeCurrency:c}};let d=null;const h=(0,Q.randomBytesHex)(8),y=E=>{this.publishWeb3RequestCanceledEvent(h),this.handleErrorResponse(h,u.method,E),d==null||d()};return this.ui.inlineAddEthereumChain(e)||(d=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:y,onResetConnection:this.resetAndReload})),{promise:new Promise((E,M)=>{this.relayEventManager.callbacks.set(h,O=>{if(d==null||d(),(0,Tt.isErrorResponse)(O))return M(new Error(O.errorMessage));E(O)});const k=O=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"addEthereumChain",result:{isApproved:!1,rpcUrl:""}}})},T=O=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"addEthereumChain",result:{isApproved:!0,rpcUrl:O}}})};this.ui.inlineAddEthereumChain(e)&&this.ui.addEthereumChain({onCancel:k,onApprove:T,chainId:u.params.chainId,rpcUrls:u.params.rpcUrls,blockExplorerUrls:u.params.blockExplorerUrls,chainName:u.params.chainName,iconUrls:u.params.iconUrls,nativeCurrency:u.params.nativeCurrency}),!this.ui.inlineAddEthereumChain(e)&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(h,u)}),cancel:y}}switchEthereumChain(e,r){const n={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:r})},i=(0,Q.randomBytesHex)(8),s=u=>{this.publishWeb3RequestCanceledEvent(i),this.handleErrorResponse(i,n.method,u)};return{promise:new Promise((u,d)=>{this.relayEventManager.callbacks.set(i,S=>{if((0,Tt.isErrorResponse)(S)&&S.errorCode)return d(Jt.standardErrors.provider.custom({code:S.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if((0,Tt.isErrorResponse)(S))return d(new Error(S.errorMessage));u(S)});const h=S=>{var E;if(S){const M=(E=(0,Jt.getErrorCode)(S))!==null&&E!==void 0?E:Jt.standardErrorCodes.provider.unsupportedChain;this.handleErrorResponse(i,"switchEthereumChain",S instanceof Error?S:Jt.standardErrors.provider.unsupportedChain(e),M)}else this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:i,response:{method:"switchEthereumChain",result:{isApproved:!1,rpcUrl:""}}})},y=S=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:i,response:{method:"switchEthereumChain",result:{isApproved:!0,rpcUrl:S}}})};this.ui.switchEthereumChain({onCancel:h,onApprove:y,chainId:n.params.chainId,address:n.params.address}),!this.ui.inlineSwitchEthereumChain()&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(i,n)}),cancel:s}}inlineAddEthereumChain(e){return this.ui.inlineAddEthereumChain(e)}getSessionIdHash(){return kt.Session.hash(this._session.id)}sendRequestStandalone(e,r){const n=s=>{this.handleErrorResponse(e,r.method,s)},i=s=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:e,response:s})};switch(r.method){case"signEthereumMessage":this.ui.signEthereumMessage({request:r,onSuccess:i,onCancel:n});break;case"signEthereumTransaction":this.ui.signEthereumTransaction({request:r,onSuccess:i,onCancel:n});break;case"submitEthereumTransaction":this.ui.submitEthereumTransaction({request:r,onSuccess:i,onCancel:n});break;case"ethereumAddressFromSignedMessage":this.ui.ethereumAddressFromSignedMessage({request:r,onSuccess:i});break;default:n();break}}}Cr.WalletLinkRelay=Et;Et.accountRequestCallbackIds=new Set;var xr={},Nn={},Sa={};(function(t){var e=x&&x.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s);var u=Object.getOwnPropertyDescriptor(i,s);(!u||("get"in u?!i.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(n,c,u)}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=x&&x.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Qs,t)})(Sa);var Xs={};Object.defineProperty(Xs,"__esModule",{value:!0});Xs.default=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";var Ma=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Nn,"__esModule",{value:!0});Nn.RedirectDialog=void 0;const pu=Ma(Lr),mt=Ke,mu=Nr,vu=Sa,wu=Ma(Xs);class yu{constructor(){this.root=null}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),(0,mu.injectCssReset)()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&((0,mt.render)(null,this.root),e&&(0,mt.render)((0,mt.h)(bu,Object.assign({},e,{onDismiss:()=>{this.clear()}})),this.root))}}Nn.RedirectDialog=yu;const bu=({title:t,buttonText:e,darkMode:r,onButtonClick:n,onDismiss:i})=>{const s=r?"dark":"light";return(0,mt.h)(vu.SnackbarContainer,{darkMode:r},(0,mt.h)("div",{class:"-cbwsdk-redirect-dialog"},(0,mt.h)("style",null,wu.default),(0,mt.h)("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),(0,mt.h)("div",{class:(0,pu.default)("-cbwsdk-redirect-dialog-box",s)},(0,mt.h)("p",null,t),(0,mt.h)("button",{onClick:n},e))))};Object.defineProperty(xr,"__esModule",{value:!0});xr.MobileRelayUI=void 0;const _u=Nn;class Eu{constructor(e){this.attached=!1,this.darkMode=!1,this.redirectDialog=new _u.RedirectDialog,this.darkMode=e.darkMode}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}setConnected(e){}redirectToCoinbaseWallet(e){const r=new URL("https://go.cb-w.com/walletlink");r.searchParams.append("redirect_url",window.location.href),e&&r.searchParams.append("wl_url",e);const n=document.createElement("a");n.target="cbw-opener",n.href=r.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",darkMode:this.darkMode,onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}hideRequestEthereumAccounts(){this.redirectDialog.clear()}requestEthereumAccounts(){}addEthereumChain(){}watchAsset(){}selectProvider(){}switchEthereumChain(){}signEthereumMessage(){}signEthereumTransaction(){}submitEthereumTransaction(){}ethereumAddressFromSignedMessage(){}reloadUI(){}setStandalone(){}setConnectDisabled(){}inlineAccountsResponse(){return!1}inlineAddEthereumChain(){return!1}inlineWatchAsset(){return!1}inlineSwitchEthereumChain(){return!1}isStandalone(){return!1}}xr.MobileRelayUI=Eu;Object.defineProperty(Ir,"__esModule",{value:!0});Ir.MobileRelay=void 0;const Su=A,Mu=Cr,ku=xr;class Ru extends Mu.WalletLinkRelay{constructor(e){var r;super(e),this._enableMobileWalletLink=(r=e.enableMobileWalletLink)!==null&&r!==void 0?r:!1}requestEthereumAccounts(){return this._enableMobileWalletLink?super.requestEthereumAccounts():{promise:new Promise(()=>{const e=(0,Su.getLocation)();e.href=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(e.href)}`}),cancel:()=>{}}}publishWeb3RequestEvent(e,r){if(super.publishWeb3RequestEvent(e,r),!(this._enableMobileWalletLink&&this.ui instanceof ku.MobileRelayUI))return;let n=!1;switch(r.method){case"requestEthereumAccounts":case"connectAndSignIn":n=!0,this.ui.openCoinbaseWalletDeeplink(this.getQRCodeUrl());break;case"switchEthereumChain":return;default:n=!0,this.ui.openCoinbaseWalletDeeplink();break}n&&window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0})}handleWeb3ResponseMessage(e){super.handleWeb3ResponseMessage(e)}connectAndSignIn(e){if(!this._enableMobileWalletLink)throw new Error("connectAndSignIn is supported only when enableMobileWalletLink is on");return this.sendRequest({method:"connectAndSignIn",params:{appName:this.appName,appLogoUrl:this.appLogoUrl,domain:window.location.hostname,aud:window.location.href,version:"1",type:"eip4361",nonce:e.nonce,iat:new Date().toISOString(),chainId:`eip155:${this.dappDefaultChain}`,statement:e.statement,resources:e.resources}})}}Ir.MobileRelay=Ru;const Iu=Bc,Cu=un;function ka(t){return Buffer.allocUnsafe(t).fill(0)}function Ra(t,e,r){const n=ka(e);return t=Ln(t),r?t.length"u")throw new Error("Not an array?");if(r=La(t),r!=="dynamic"&&r!==0&&e.length>r)throw new Error("Elements exceed array size: "+r);i=[],t=t.slice(0,t.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(s in e)i.push(pt(t,e[s]));if(r==="dynamic"){var c=pt("uint256",e.length);i.unshift(c)}return Buffer.concat(i)}else{if(t==="bytes")return e=new Buffer(e),i=Buffer.concat([pt("uint256",e.length),e]),e.length%32!==0&&(i=Buffer.concat([i,jt.zeros(32-e.length%32)])),i;if(t.startsWith("bytes")){if(r=Yt(t),r<1||r>32)throw new Error("Invalid bytes width: "+r);return jt.setLengthRight(e,32)}else if(t.startsWith("uint")){if(r=Yt(t),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);if(n=Pt(e),n.bitLength()>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+n.bitLength());if(n<0)throw new Error("Supplied uint is negative");return n.toArrayLike(Buffer,"be",32)}else if(t.startsWith("int")){if(r=Yt(t),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);if(n=Pt(e),n.bitLength()>r)throw new Error("Supplied int exceeds width: "+r+" vs "+n.bitLength());return n.toTwos(256).toArrayLike(Buffer,"be",32)}else if(t.startsWith("ufixed")){if(r=so(t),n=Pt(e),n<0)throw new Error("Supplied ufixed is negative");return pt("uint256",n.mul(new Ot(2).pow(new Ot(r[1]))))}else if(t.startsWith("fixed"))return r=so(t),pt("int256",Pt(e).mul(new Ot(2).pow(new Ot(r[1]))))}throw new Error("Unsupported or invalid type: "+t)}function Tu(t){return t==="string"||t==="bytes"||La(t)==="dynamic"}function Pu(t){return t.lastIndexOf("]")===t.length-1}function $u(t,e){var r=[],n=[],i=32*t.length;for(var s in t){var c=Na(t[s]),u=e[s],d=pt(c,u);Tu(c)?(r.push(pt("uint256",i)),n.push(d),i+=d.length):r.push(d)}return Buffer.concat(r.concat(n))}function xa(t,e){if(t.length!==e.length)throw new Error("Number of types are not matching the values");for(var r,n,i=[],s=0;s32)throw new Error("Invalid bytes width: "+r);i.push(jt.setLengthRight(u,r))}else if(c.startsWith("uint")){if(r=Yt(c),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);if(n=Pt(u),n.bitLength()>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+n.bitLength());i.push(n.toArrayLike(Buffer,"be",r/8))}else if(c.startsWith("int")){if(r=Yt(c),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);if(n=Pt(u),n.bitLength()>r)throw new Error("Supplied int exceeds width: "+r+" vs "+n.bitLength());i.push(n.toTwos(r).toArrayLike(Buffer,"be",r/8))}else throw new Error("Unsupported or invalid type: "+c)}return Buffer.concat(i)}function Ou(t,e){return jt.keccak(xa(t,e))}var Bu={rawEncode:$u,solidityPack:xa,soliditySHA3:Ou};const lt=Aa,yr=Bu,Ta={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},Ms={encodeData(t,e,r,n=!0){const i=["bytes32"],s=[this.hashType(t,r)];if(n){const c=(u,d,h)=>{if(r[d]!==void 0)return["bytes32",h==null?"0x0000000000000000000000000000000000000000000000000000000000000000":lt.keccak(this.encodeData(d,h,r,n))];if(h===void 0)throw new Error(`missing value for field ${u} of type ${d}`);if(d==="bytes")return["bytes32",lt.keccak(h)];if(d==="string")return typeof h=="string"&&(h=Buffer.from(h,"utf8")),["bytes32",lt.keccak(h)];if(d.lastIndexOf("]")===d.length-1){const y=d.slice(0,d.lastIndexOf("[")),S=h.map(E=>c(u,y,E));return["bytes32",lt.keccak(yr.rawEncode(S.map(([E])=>E),S.map(([,E])=>E)))]}return[d,h]};for(const u of r[t]){const[d,h]=c(u.name,u.type,e[u.name]);i.push(d),s.push(h)}}else for(const c of r[t]){let u=e[c.name];if(u!==void 0)if(c.type==="bytes")i.push("bytes32"),u=lt.keccak(u),s.push(u);else if(c.type==="string")i.push("bytes32"),typeof u=="string"&&(u=Buffer.from(u,"utf8")),u=lt.keccak(u),s.push(u);else if(r[c.type]!==void 0)i.push("bytes32"),u=lt.keccak(this.encodeData(c.type,u,r,n)),s.push(u);else{if(c.type.lastIndexOf("]")===c.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(c.type),s.push(u)}}return yr.rawEncode(i,s)},encodeType(t,e){let r="",n=this.findTypeDependencies(t,e).filter(i=>i!==t);n=[t].concat(n.sort());for(const i of n){if(!e[i])throw new Error("No type definition specified: "+i);r+=i+"("+e[i].map(({name:c,type:u})=>u+" "+c).join(",")+")"}return r},findTypeDependencies(t,e,r=[]){if(t=t.match(/^\w*/)[0],r.includes(t)||e[t]===void 0)return r;r.push(t);for(const n of e[t])for(const i of this.findTypeDependencies(n.type,e,r))!r.includes(i)&&r.push(i);return r},hashStruct(t,e,r,n=!0){return lt.keccak(this.encodeData(t,e,r,n))},hashType(t,e){return lt.keccak(this.encodeType(t,e))},sanitizeData(t){const e={};for(const r in Ta.properties)t[r]&&(e[r]=t[r]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(t,e=!0){const r=this.sanitizeData(t),n=[Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",r.domain,r.types,e)),r.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(r.primaryType,r.message,r.types,e)),lt.keccak(Buffer.concat(n))}};var Du={TYPED_MESSAGE_SCHEMA:Ta,TypedDataUtils:Ms,hashForSignTypedDataLegacy:function(t){return ju(t.data)},hashForSignTypedData_v3:function(t){return Ms.hash(t.data,!1)},hashForSignTypedData_v4:function(t){return Ms.hash(t.data)}};function ju(t){const e=new Error("Expect argument to be non-empty array");if(typeof t!="object"||!t.length)throw e;const r=t.map(function(s){return s.type==="bytes"?lt.toBuffer(s.value):s.value}),n=t.map(function(s){return s.type}),i=t.map(function(s){if(!s.name)throw e;return s.type+" "+s.name});return yr.soliditySHA3(["bytes32","bytes32"],[yr.soliditySHA3(new Array(t.length).fill("string"),i),yr.soliditySHA3(n,r)])}var ir={};Object.defineProperty(ir,"__esModule",{value:!0});ir.filterFromParam=ir.FilterPolyfill=void 0;const Qt=De,Je=A,Fu=5*60*1e3,$t={jsonrpc:"2.0",id:0};class Hu{constructor(e){this.logFilters=new Map,this.blockFilters=new Set,this.pendingTransactionFilters=new Set,this.cursors=new Map,this.timeouts=new Map,this.nextFilterId=(0,Qt.IntNumber)(1),this.REQUEST_THROTTLE_INTERVAL=1e3,this.lastFetchTimestamp=new Date(0),this.resolvers=[],this.provider=e}async newFilter(e){const r=Pa(e),n=this.makeFilterId(),i=await this.setInitialCursorPosition(n,r.fromBlock);return console.info(`Installing new log filter(${n}):`,r,"initial cursor position:",i),this.logFilters.set(n,r),this.setFilterTimeout(n),(0,Je.hexStringFromIntNumber)(n)}async newBlockFilter(){const e=this.makeFilterId(),r=await this.setInitialCursorPosition(e,"latest");return console.info(`Installing new block filter (${e}) with initial cursor position:`,r),this.blockFilters.add(e),this.setFilterTimeout(e),(0,Je.hexStringFromIntNumber)(e)}async newPendingTransactionFilter(){const e=this.makeFilterId(),r=await this.setInitialCursorPosition(e,"latest");return console.info(`Installing new block filter (${e}) with initial cursor position:`,r),this.pendingTransactionFilters.add(e),this.setFilterTimeout(e),(0,Je.hexStringFromIntNumber)(e)}uninstallFilter(e){const r=(0,Je.intNumberFromHexString)(e);return console.info(`Uninstalling filter (${r})`),this.deleteFilter(r),!0}getFilterChanges(e){const r=(0,Je.intNumberFromHexString)(e);return this.timeouts.has(r)&&this.setFilterTimeout(r),this.logFilters.has(r)?this.getLogFilterChanges(r):this.blockFilters.has(r)?this.getBlockFilterChanges(r):this.pendingTransactionFilters.has(r)?this.getPendingTransactionFilterChanges(r):Promise.resolve(Gr())}async getFilterLogs(e){const r=(0,Je.intNumberFromHexString)(e),n=this.logFilters.get(r);return n?this.sendAsyncPromise(Object.assign(Object.assign({},$t),{method:"eth_getLogs",params:[io(n)]})):Gr()}makeFilterId(){return(0,Qt.IntNumber)(++this.nextFilterId)}sendAsyncPromise(e){return new Promise((r,n)=>{this.provider.sendAsync(e,(i,s)=>{if(i)return n(i);if(Array.isArray(s)||s==null)return n(new Error(`unexpected response received: ${JSON.stringify(s)}`));r(s)})})}deleteFilter(e){console.info(`Deleting filter (${e})`),this.logFilters.delete(e),this.blockFilters.delete(e),this.pendingTransactionFilters.delete(e),this.cursors.delete(e),this.timeouts.delete(e)}async getLogFilterChanges(e){const r=this.logFilters.get(e),n=this.cursors.get(e);if(!n||!r)return Gr();const i=await this.getCurrentBlockHeight(),s=r.toBlock==="latest"?i:r.toBlock;if(n>i||n>Number(r.toBlock))return Zr();console.info(`Fetching logs from ${n} to ${s} for filter ${e}`);const c=await this.sendAsyncPromise(Object.assign(Object.assign({},$t),{method:"eth_getLogs",params:[io(Object.assign(Object.assign({},r),{fromBlock:n,toBlock:s}))]}));if(Array.isArray(c.result)){const u=c.result.map(h=>(0,Je.intNumberFromHexString)(h.blockNumber||"0x0")),d=Math.max(...u);if(d&&d>n){const h=(0,Qt.IntNumber)(d+1);console.info(`Moving cursor position for filter (${e}) from ${n} to ${h}`),this.cursors.set(e,h)}}return c}async getBlockFilterChanges(e){const r=this.cursors.get(e);if(!r)return Gr();const n=await this.getCurrentBlockHeight();if(r>n)return Zr();console.info(`Fetching blocks from ${r} to ${n} for filter (${e})`);const i=(await Promise.all((0,Je.range)(r,n+1).map(c=>this.getBlockHashByNumber((0,Qt.IntNumber)(c))))).filter(c=>!!c),s=(0,Qt.IntNumber)(r+i.length);return console.info(`Moving cursor position for filter (${e}) from ${r} to ${s}`),this.cursors.set(e,s),Object.assign(Object.assign({},$t),{result:i})}async getPendingTransactionFilterChanges(e){return Promise.resolve(Zr())}async setInitialCursorPosition(e,r){const n=await this.getCurrentBlockHeight(),i=typeof r=="number"&&r>n?r:n;return this.cursors.set(e,i),i}setFilterTimeout(e){const r=this.timeouts.get(e);r&&window.clearTimeout(r);const n=window.setTimeout(()=>{console.info(`Filter (${e}) timed out`),this.deleteFilter(e)},Fu);this.timeouts.set(e,n)}async getCurrentBlockHeight(){const e=new Date;if(e.getTime()-this.lastFetchTimestamp.getTime()>this.REQUEST_THROTTLE_INTERVAL){this.lastFetchTimestamp=e;const r=await this._getCurrentBlockHeight();this.currentBlockHeight=r,this.resolvers.forEach(n=>n(r)),this.resolvers=[]}return this.currentBlockHeight?this.currentBlockHeight:new Promise(r=>this.resolvers.push(r))}async _getCurrentBlockHeight(){const{result:e}=await this.sendAsyncPromise(Object.assign(Object.assign({},$t),{method:"eth_blockNumber",params:[]}));return(0,Je.intNumberFromHexString)((0,Je.ensureHexString)(e))}async getBlockHashByNumber(e){const r=await this.sendAsyncPromise(Object.assign(Object.assign({},$t),{method:"eth_getBlockByNumber",params:[(0,Je.hexStringFromIntNumber)(e),!1]}));return r.result&&typeof r.result.hash=="string"?(0,Je.ensureHexString)(r.result.hash):null}}ir.FilterPolyfill=Hu;function Pa(t){return{fromBlock:oo(t.fromBlock),toBlock:oo(t.toBlock),addresses:t.address===void 0?null:Array.isArray(t.address)?t.address:[t.address],topics:t.topics||[]}}ir.filterFromParam=Pa;function io(t){const e={fromBlock:ao(t.fromBlock),toBlock:ao(t.toBlock),topics:t.topics};return t.addresses!==null&&(e.address=t.addresses),e}function oo(t){if(t===void 0||t==="latest"||t==="pending")return"latest";if(t==="earliest")return(0,Qt.IntNumber)(0);if((0,Je.isHexString)(t))return(0,Je.intNumberFromHexString)(t);throw new Error(`Invalid block option: ${String(t)}`)}function ao(t){return t==="latest"?t:(0,Je.hexStringFromIntNumber)(t)}function Gr(){return Object.assign(Object.assign({},$t),{error:{code:-32e3,message:"filter not found"}})}function Zr(){return Object.assign(Object.assign({},$t),{result:[]})}var xn={},$a={},Tn={},Ys=Uu;function Uu(t){t=t||{};var e=t.max||Number.MAX_SAFE_INTEGER,r=typeof t.start<"u"?t.start:Math.floor(Math.random()*e);return function(){return r=r%e,r++}}const co=(t,e)=>function(){const r=e.promiseModule,n=new Array(arguments.length);for(let i=0;i{e.errorFirst?n.push(function(c,u){if(e.multiArgs){const d=new Array(arguments.length-1);for(let h=1;h{e=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},e);const r=i=>{const s=c=>typeof c=="string"?i===c:c.test(i);return e.include?e.include.some(s):!e.exclude.some(s)};let n;typeof t=="function"?n=function(){return e.excludeMain?t.apply(this,arguments):co(t,e).apply(this,arguments)}:n=Object.create(Object.getPrototypeOf(t));for(const i in t){const s=t[i];n[i]=typeof s=="function"&&r(i)?co(s,e):s}return n},Tr={},Pr={};Object.defineProperty(Pr,"__esModule",{value:!0});const Wu=ta;function lo(t,e,r){try{Reflect.apply(t,e,r)}catch(n){setTimeout(()=>{throw n})}}function zu(t){const e=t.length,r=new Array(e);for(let n=0;n0&&([c]=r),c instanceof Error)throw c;const u=new Error(`Unhandled error.${c?` (${c.message})`:""}`);throw u.context=c,u}const s=i[e];if(s===void 0)return!1;if(typeof s=="function")lo(s,this,r);else{const c=s.length,u=zu(s);for(let d=0;dt+e,uo=["sync","latest"];class Ku extends Gu.default{constructor(e){super(),this._blockResetDuration=e.blockResetDuration||20*Zu,this._usePastBlocks=e.usePastBlocks||!1,this._currentBlock=null,this._isRunning=!1,this._onNewListener=this._onNewListener.bind(this),this._onRemoveListener=this._onRemoveListener.bind(this),this._resetCurrentBlock=this._resetCurrentBlock.bind(this),this._setupInternalEvents()}async destroy(){this._cancelBlockResetTimeout(),await this._maybeEnd(),super.removeAllListeners()}isRunning(){return this._isRunning}getCurrentBlock(){return this._currentBlock}async getLatestBlock(){return this._currentBlock?this._currentBlock:await new Promise(r=>this.once("latest",r))}removeAllListeners(e){return e?super.removeAllListeners(e):super.removeAllListeners(),this._setupInternalEvents(),this._onRemoveListener(),this}_setupInternalEvents(){this.removeListener("newListener",this._onNewListener),this.removeListener("removeListener",this._onRemoveListener),this.on("newListener",this._onNewListener),this.on("removeListener",this._onRemoveListener)}_onNewListener(e){uo.includes(e)&&this._maybeStart()}_onRemoveListener(){this._getBlockTrackerEventCount()>0||this._maybeEnd()}async _maybeStart(){this._isRunning||(this._isRunning=!0,this._cancelBlockResetTimeout(),await this._start(),this.emit("_started"))}async _maybeEnd(){this._isRunning&&(this._isRunning=!1,this._setupBlockResetTimeout(),await this._end(),this.emit("_ended"))}_getBlockTrackerEventCount(){return uo.map(e=>this.listenerCount(e)).reduce(Qu)}_shouldUseNewBlock(e){const r=this._currentBlock;if(!r)return!0;const n=ho(e),i=ho(r);return this._usePastBlocks&&ni}_newPotentialLatest(e){this._shouldUseNewBlock(e)&&this._setCurrentBlock(e)}_setCurrentBlock(e){const r=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{oldBlock:r,newBlock:e})}_setupBlockResetTimeout(){this._cancelBlockResetTimeout(),this._blockResetTimeout=setTimeout(this._resetCurrentBlock,this._blockResetDuration),this._blockResetTimeout.unref&&this._blockResetTimeout.unref()}_cancelBlockResetTimeout(){this._blockResetTimeout&&clearTimeout(this._blockResetTimeout)}_resetCurrentBlock(){this._currentBlock=null}}Tr.BaseBlockTracker=Ku;function ho(t){return Number.parseInt(t,16)}var Oa={},Ba={},Ve={};class Da extends TypeError{constructor(e,r){let n;const{message:i,explanation:s,...c}=e,{path:u}=e,d=u.length===0?i:`At path: ${u.join(".")} -- ${i}`;super(s??d),s!=null&&(this.cause=d),Object.assign(this,c),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Xu(t){return at(t)&&typeof t[Symbol.iterator]=="function"}function at(t){return typeof t=="object"&&t!=null}function fo(t){if(Object.prototype.toString.call(t)!=="[object Object]")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function je(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Yu(t){const{done:e,value:r}=t.next();return e?void 0:r}function ed(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:s}=e,{type:c}=r,{refinement:u,message:d=`Expected a value of type \`${c}\`${u?` with refinement \`${u}\``:""}, but received: \`${je(n)}\``}=t;return{value:n,type:c,refinement:u,key:i[i.length-1],path:i,branch:s,...t,message:d}}function*Os(t,e,r,n){Xu(t)||(t=[t]);for(const i of t){const s=ed(i,e,r,n);s&&(yield s)}}function*ei(t,e,r={}){const{path:n=[],branch:i=[t],coerce:s=!1,mask:c=!1}=r,u={path:n,branch:i};if(s&&(t=e.coercer(t,u),c&&e.type!=="type"&&at(e.schema)&&at(t)&&!Array.isArray(t)))for(const h in t)e.schema[h]===void 0&&delete t[h];let d="valid";for(const h of e.validator(t,u))h.explanation=r.message,d="not_valid",yield[h,void 0];for(let[h,y,S]of e.entries(t,u)){const E=ei(y,S,{path:h===void 0?n:[...n,h],branch:h===void 0?i:[...i,y],coerce:s,mask:c,message:r.message});for(const M of E)M[0]?(d=M[0].refinement!=null?"not_refined":"not_valid",yield[M[0],void 0]):s&&(y=M[1],h===void 0?t=y:t instanceof Map?t.set(h,y):t instanceof Set?t.add(y):at(t)&&(y!==void 0||h in t)&&(t[h]=y))}if(d!=="not_valid")for(const h of e.refiner(t,u))h.explanation=r.message,d="not_refined",yield[h,void 0];d==="valid"&&(yield[void 0,t])}class ee{constructor(e){const{type:r,schema:n,validator:i,refiner:s,coercer:c=d=>d,entries:u=function*(){}}=e;this.type=r,this.schema=n,this.entries=u,this.coercer=c,i?this.validator=(d,h)=>{const y=i(d,h);return Os(y,h,this,d)}:this.validator=()=>[],s?this.refiner=(d,h)=>{const y=s(d,h);return Os(y,h,this,d)}:this.refiner=()=>[]}assert(e,r){return ja(e,this,r)}create(e,r){return Fa(e,this,r)}is(e){return ti(e,this)}mask(e,r){return Ha(e,this,r)}validate(e,r={}){return hr(e,this,r)}}function ja(t,e,r){const n=hr(t,e,{message:r});if(n[0])throw n[0]}function Fa(t,e,r){const n=hr(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Ha(t,e,r){const n=hr(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function ti(t,e){return!hr(t,e)[0]}function hr(t,e,r={}){const n=ei(t,e,r),i=Yu(n);return i[0]?[new Da(i[0],function*(){for(const c of n)c[0]&&(yield c[0])}),void 0]:[void 0,i[1]]}function td(...t){const e=t[0].type==="type",r=t.map(i=>i.schema),n=Object.assign({},...r);return e?Or(n):$r(n)}function Xe(t,e){return new ee({type:t,schema:null,validator:e})}function rd(t,e){return new ee({...t,refiner:(r,n)=>r===void 0||t.refiner(r,n),validator(r,n){return r===void 0?!0:(e(r,n),t.validator(r,n))}})}function nd(t){return new ee({type:"dynamic",schema:null,*entries(e,r){yield*t(e,r).entries(e,r)},validator(e,r){return t(e,r).validator(e,r)},coercer(e,r){return t(e,r).coercer(e,r)},refiner(e,r){return t(e,r).refiner(e,r)}})}function sd(t){let e;return new ee({type:"lazy",schema:null,*entries(r,n){e??(e=t()),yield*e.entries(r,n)},validator(r,n){return e??(e=t()),e.validator(r,n)},coercer(r,n){return e??(e=t()),e.coercer(r,n)},refiner(r,n){return e??(e=t()),e.refiner(r,n)}})}function id(t,e){const{schema:r}=t,n={...r};for(const i of e)delete n[i];switch(t.type){case"type":return Or(n);default:return $r(n)}}function od(t){const e=t instanceof ee,r=e?{...t.schema}:{...t};for(const n in r)r[n]=Ua(r[n]);return e&&t.type==="type"?Or(r):$r(r)}function ad(t,e){const{schema:r}=t,n={};for(const i of e)n[i]=r[i];switch(t.type){case"type":return Or(n);default:return $r(n)}}function cd(t,e){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),Xe(t,e)}function ld(){return Xe("any",()=>!0)}function ud(t){return new ee({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${je(e)}`}})}function dd(){return Xe("bigint",t=>typeof t=="bigint")}function hd(){return Xe("boolean",t=>typeof t=="boolean")}function fd(){return Xe("date",t=>t instanceof Date&&!isNaN(t.getTime())||`Expected a valid \`Date\` object, but received: ${je(t)}`)}function gd(t){const e={},r=t.map(n=>je(n)).join();for(const n of t)e[n]=n;return new ee({type:"enums",schema:e,validator(n){return t.includes(n)||`Expected one of \`${r}\`, but received: ${je(n)}`}})}function pd(){return Xe("func",t=>typeof t=="function"||`Expected a function, but received: ${je(t)}`)}function md(t){return Xe("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${je(e)}`)}function vd(){return Xe("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${je(t)}`)}function wd(t){return new ee({type:"intersection",schema:null,*entries(e,r){for(const n of t)yield*n.entries(e,r)},*validator(e,r){for(const n of t)yield*n.validator(e,r)},*refiner(e,r){for(const n of t)yield*n.refiner(e,r)}})}function yd(t){const e=je(t),r=typeof t;return new ee({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${je(n)}`}})}function bd(t,e){return new ee({type:"map",schema:null,*entries(r){if(t&&e&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,t],yield[n,i,e]},coercer(r){return r instanceof Map?new Map(r):r},validator(r){return r instanceof Map||`Expected a \`Map\` object, but received: ${je(r)}`}})}function ri(){return Xe("never",()=>!1)}function _d(t){return new ee({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function Ed(){return Xe("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${je(t)}`)}function $r(t){const e=t?Object.keys(t):[],r=ri();return new ee({type:"object",schema:t||null,*entries(n){if(t&&at(n)){const i=new Set(Object.keys(n));for(const s of e)i.delete(s),yield[s,n[s],t[s]];for(const s of i)yield[s,n[s],r]}},validator(n){return at(n)||`Expected an object, but received: ${je(n)}`},coercer(n){return at(n)?{...n}:n}})}function Ua(t){return new ee({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Sd(t,e){return new ee({type:"record",schema:null,*entries(r){if(at(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator(r){return at(r)||`Expected an object, but received: ${je(r)}`}})}function Md(){return Xe("regexp",t=>t instanceof RegExp)}function kd(t){return new ee({type:"set",schema:null,*entries(e){if(t&&e instanceof Set)for(const r of e)yield[r,r,t]},coercer(e){return e instanceof Set?new Set(e):e},validator(e){return e instanceof Set||`Expected a \`Set\` object, but received: ${je(e)}`}})}function Va(){return Xe("string",t=>typeof t=="string"||`Expected a string, but received: ${je(t)}`)}function Rd(t){const e=ri();return new ee({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;ir.type).join(" | ");return new ee({type:"union",schema:null,coercer(r){for(const n of t){const[i,s]=n.validate(r,{coerce:!0});if(!i)return s}return r},validator(r,n){const i=[];for(const s of t){const[...c]=ei(r,s,n),[u]=c;if(u[0])for(const[d]of c)d&&i.push(d);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${je(r)}`,...i]}})}function Wa(){return Xe("unknown",()=>!0)}function ni(t,e,r){return new ee({...t,coercer:(n,i)=>ti(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}function Cd(t,e,r={}){return ni(t,Wa(),n=>{const i=typeof e=="function"?e():e;if(n===void 0)return i;if(!r.strict&&fo(n)&&fo(i)){const s={...n};let c=!1;for(const u in i)s[u]===void 0&&(s[u]=i[u],c=!0);if(c)return s}return n})}function Ad(t){return ni(t,Va(),e=>e.trim())}function Nd(t){return Ut(t,"empty",e=>{const r=za(e);return r===0||`Expected an empty ${t.type} but received one with a size of \`${r}\``})}function za(t){return t instanceof Map||t instanceof Set?t.size:t.length}function Ld(t,e,r={}){const{exclusive:n}=r;return Ut(t,"max",i=>n?in?i>e:i>=e||`Expected a ${t.type} greater than ${n?"":"or equal to "}${e} but received \`${i}\``)}function Td(t){return Ut(t,"nonempty",e=>za(e)>0||`Expected a nonempty ${t.type} but received an empty one`)}function Pd(t,e){return Ut(t,"pattern",r=>e.test(r)||`Expected a ${t.type} matching \`/${e.source}/\` but received "${r}"`)}function $d(t,e,r=e){const n=`Expected a ${t.type}`,i=e===r?`of \`${e}\``:`between \`${e}\` and \`${r}\``;return Ut(t,"size",s=>{if(typeof s=="number"||s instanceof Date)return e<=s&&s<=r||`${n} ${i} but received \`${s}\``;if(s instanceof Map||s instanceof Set){const{size:c}=s;return e<=c&&c<=r||`${n} with a size ${i} but received one with a size of \`${c}\``}else{const{length:c}=s;return e<=c&&c<=r||`${n} with a length ${i} but received one with a length of \`${c}\``}})}function Ut(t,e,r){return new ee({...t,*refiner(n,i){yield*t.refiner(n,i);const s=r(n,i),c=Os(s,i,t,n);for(const u of c)yield{...u,refinement:e}}})}const Od=Object.freeze(Object.defineProperty({__proto__:null,Struct:ee,StructError:Da,any:ld,array:ud,assert:ja,assign:td,bigint:dd,boolean:hd,coerce:ni,create:Fa,date:fd,defaulted:Cd,define:Xe,deprecated:rd,dynamic:nd,empty:Nd,enums:gd,func:pd,instance:md,integer:vd,intersection:wd,is:ti,lazy:sd,literal:yd,map:bd,mask:Ha,max:Ld,min:xd,never:ri,nonempty:Td,nullable:_d,number:Ed,object:$r,omit:id,optional:Ua,partial:od,pattern:Pd,pick:ad,record:Sd,refine:Ut,regexp:Md,set:kd,size:$d,string:Va,struct:cd,trimmed:Ad,tuple:Rd,type:Or,union:Id,unknown:Wa,validate:hr},Symbol.toStringTag,{value:"Module"})),Vt=Hs(Od);Object.defineProperty(Ve,"__esModule",{value:!0});Ve.assertExhaustive=Ve.assertStruct=Ve.assert=Ve.AssertionError=void 0;const Bd=Vt;function Dd(t){return typeof t=="object"&&t!==null&&"message"in t}function jd(t){var e,r;return typeof((r=(e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===null||r===void 0?void 0:r.name)=="string"}function Fd(t){const e=Dd(t)?t.message:String(t);return e.endsWith(".")?e.slice(0,-1):e}function qa(t,e){return jd(t)?new t({message:e}):t({message:e})}class si extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}}Ve.AssertionError=si;function Hd(t,e="Assertion failed.",r=si){if(!t)throw e instanceof Error?e:qa(r,e)}Ve.assert=Hd;function Ud(t,e,r="Assertion failed",n=si){try{(0,Bd.assert)(t,e)}catch(i){throw qa(n,`${r}: ${Fd(i)}.`)}}Ve.assertStruct=Ud;function Vd(t){throw new Error("Invalid branch reached. Should be detected during compilation.")}Ve.assertExhaustive=Vd;var Br={};Object.defineProperty(Br,"__esModule",{value:!0});Br.base64=void 0;const Wd=Vt,zd=Ve,qd=(t,e={})=>{var r,n;const i=(r=e.paddingRequired)!==null&&r!==void 0?r:!1,s=(n=e.characterSet)!==null&&n!==void 0?n:"base64";let c;s==="base64"?c=String.raw`[A-Za-z0-9+\/]`:((0,zd.assert)(s==="base64url"),c=String.raw`[-_A-Za-z0-9]`);let u;return i?u=new RegExp(`^(?:${c}{4})*(?:${c}{3}=|${c}{2}==)?$`,"u"):u=new RegExp(`^(?:${c}{4})*(?:${c}{2,3}|${c}{3}=|${c}{2}==)?$`,"u"),(0,Wd.pattern)(t,u)};Br.base64=qd;var W={},Dr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.remove0x=t.add0x=t.assertIsStrictHexString=t.assertIsHexString=t.isStrictHexString=t.isHexString=t.StrictHexStruct=t.HexStruct=void 0;const e=Vt,r=Ve;t.HexStruct=(0,e.pattern)((0,e.string)(),/^(?:0x)?[0-9a-f]+$/iu),t.StrictHexStruct=(0,e.pattern)((0,e.string)(),/^0x[0-9a-f]+$/iu);function n(h){return(0,e.is)(h,t.HexStruct)}t.isHexString=n;function i(h){return(0,e.is)(h,t.StrictHexStruct)}t.isStrictHexString=i;function s(h){(0,r.assert)(n(h),"Value must be a hexadecimal string.")}t.assertIsHexString=s;function c(h){(0,r.assert)(i(h),'Value must be a hexadecimal string, starting with "0x".')}t.assertIsStrictHexString=c;function u(h){return h.startsWith("0x")?h:h.startsWith("0X")?`0x${h.substring(2)}`:`0x${h}`}t.add0x=u;function d(h){return h.startsWith("0x")||h.startsWith("0X")?h.substring(2):h}t.remove0x=d})(Dr);Object.defineProperty(W,"__esModule",{value:!0});W.createDataView=W.concatBytes=W.valueToBytes=W.stringToBytes=W.numberToBytes=W.signedBigIntToBytes=W.bigIntToBytes=W.hexToBytes=W.bytesToString=W.bytesToNumber=W.bytesToSignedBigInt=W.bytesToBigInt=W.bytesToHex=W.assertIsBytes=W.isBytes=void 0;const tt=Ve,Bs=Dr,go=48,po=58,mo=87;function Jd(){const t=[];return()=>{if(t.length===0)for(let e=0;e<256;e++)t.push(e.toString(16).padStart(2,"0"));return t}}const Gd=Jd();function ii(t){return t instanceof Uint8Array}W.isBytes=ii;function fr(t){(0,tt.assert)(ii(t),"Value must be a Uint8Array.")}W.assertIsBytes=fr;function Ja(t){if(fr(t),t.length===0)return"0x";const e=Gd(),r=new Array(t.length);for(let n=0;n=BigInt(0),"Value must be a non-negative bigint.");const e=t.toString(16);return Pn(e)}W.bigIntToBytes=Za;function Xd(t,e){(0,tt.assert)(e>0);const r=t>>BigInt(31);return!((~t&r)+(t&~r)>>BigInt(e*8+-1))}function Yd(t,e){(0,tt.assert)(typeof t=="bigint","Value must be a bigint."),(0,tt.assert)(typeof e=="number","Byte length must be a number."),(0,tt.assert)(e>0,"Byte length must be greater than 0."),(0,tt.assert)(Xd(t,e),"Byte length is too small to represent the given value.");let r=t;const n=new Uint8Array(e);for(let i=0;i>=BigInt(8);return n.reverse()}W.signedBigIntToBytes=Yd;function Qa(t){(0,tt.assert)(typeof t=="number","Value must be a number."),(0,tt.assert)(t>=0,"Value must be a non-negative number."),(0,tt.assert)(Number.isSafeInteger(t),"Value is not a safe integer. Use `bigIntToBytes` instead.");const e=t.toString(16);return Pn(e)}W.numberToBytes=Qa;function Ka(t){return(0,tt.assert)(typeof t=="string","Value must be a string."),new TextEncoder().encode(t)}W.stringToBytes=Ka;function Xa(t){if(typeof t=="bigint")return Za(t);if(typeof t=="number")return Qa(t);if(typeof t=="string")return t.startsWith("0x")?Pn(t):Ka(t);if(ii(t))return t;throw new TypeError(`Unsupported value type: "${typeof t}".`)}W.valueToBytes=Xa;function eh(t){const e=new Array(t.length);let r=0;for(let i=0;ie.call(r,n,i,this))}get(e){return Ge(this,ct,"f").get(e)}has(e){return Ge(this,ct,"f").has(e)}keys(){return Ge(this,ct,"f").keys()}values(){return Ge(this,ct,"f").values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map(([e,r])=>`${String(e)} => ${String(r)}`).join(", ")} `:""}}`}}or.FrozenMap=oi;class ai{constructor(e){ft.set(this,void 0),tc(this,ft,new Set(e),"f"),Object.freeze(this)}get size(){return Ge(this,ft,"f").size}[(ft=new WeakMap,Symbol.iterator)](){return Ge(this,ft,"f")[Symbol.iterator]()}entries(){return Ge(this,ft,"f").entries()}forEach(e,r){return Ge(this,ft,"f").forEach((n,i,s)=>e.call(r,n,i,this))}has(e){return Ge(this,ft,"f").has(e)}keys(){return Ge(this,ft,"f").keys()}values(){return Ge(this,ft,"f").values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map(e=>String(e)).join(", ")} `:""}}`}}or.FrozenSet=ai;Object.freeze(oi);Object.freeze(oi.prototype);Object.freeze(ai);Object.freeze(ai.prototype);var rc={};Object.defineProperty(rc,"__esModule",{value:!0});var nc={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getJsonRpcIdValidator=t.assertIsJsonRpcError=t.isJsonRpcError=t.assertIsJsonRpcFailure=t.isJsonRpcFailure=t.assertIsJsonRpcSuccess=t.isJsonRpcSuccess=t.assertIsJsonRpcResponse=t.isJsonRpcResponse=t.assertIsPendingJsonRpcResponse=t.isPendingJsonRpcResponse=t.JsonRpcResponseStruct=t.JsonRpcFailureStruct=t.JsonRpcSuccessStruct=t.PendingJsonRpcResponseStruct=t.assertIsJsonRpcRequest=t.isJsonRpcRequest=t.assertIsJsonRpcNotification=t.isJsonRpcNotification=t.JsonRpcNotificationStruct=t.JsonRpcRequestStruct=t.JsonRpcParamsStruct=t.JsonRpcErrorStruct=t.JsonRpcIdStruct=t.JsonRpcVersionStruct=t.jsonrpc2=t.getJsonSize=t.isValidJson=t.JsonStruct=t.UnsafeJsonStruct=void 0;const e=Vt,r=Ve,n=()=>(0,e.define)("finite number",C=>(0,e.is)(C,(0,e.number)())&&Number.isFinite(C));t.UnsafeJsonStruct=(0,e.union)([(0,e.literal)(null),(0,e.boolean)(),n(),(0,e.string)(),(0,e.array)((0,e.lazy)(()=>t.UnsafeJsonStruct)),(0,e.record)((0,e.string)(),(0,e.lazy)(()=>t.UnsafeJsonStruct))]),t.JsonStruct=(0,e.define)("Json",(C,P)=>{function J(We,Qe){const H=[...Qe.validator(We,P)];return H.length>0?H:!0}try{const We=J(C,t.UnsafeJsonStruct);return We!==!0?We:J(JSON.parse(JSON.stringify(C)),t.UnsafeJsonStruct)}catch(We){return We instanceof RangeError?"Circular reference detected":!1}});function i(C){return(0,e.is)(C,t.JsonStruct)}t.isValidJson=i;function s(C){(0,r.assertStruct)(C,t.JsonStruct,"Invalid JSON value");const P=JSON.stringify(C);return new TextEncoder().encode(P).byteLength}t.getJsonSize=s,t.jsonrpc2="2.0",t.JsonRpcVersionStruct=(0,e.literal)(t.jsonrpc2),t.JsonRpcIdStruct=(0,e.nullable)((0,e.union)([(0,e.number)(),(0,e.string)()])),t.JsonRpcErrorStruct=(0,e.object)({code:(0,e.integer)(),message:(0,e.string)(),data:(0,e.optional)(t.JsonStruct),stack:(0,e.optional)((0,e.string)())}),t.JsonRpcParamsStruct=(0,e.optional)((0,e.union)([(0,e.record)((0,e.string)(),t.JsonStruct),(0,e.array)(t.JsonStruct)])),t.JsonRpcRequestStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,method:(0,e.string)(),params:t.JsonRpcParamsStruct}),t.JsonRpcNotificationStruct=(0,e.omit)(t.JsonRpcRequestStruct,["id"]);function c(C){return(0,e.is)(C,t.JsonRpcNotificationStruct)}t.isJsonRpcNotification=c;function u(C,P){(0,r.assertStruct)(C,t.JsonRpcNotificationStruct,"Invalid JSON-RPC notification",P)}t.assertIsJsonRpcNotification=u;function d(C){return(0,e.is)(C,t.JsonRpcRequestStruct)}t.isJsonRpcRequest=d;function h(C,P){(0,r.assertStruct)(C,t.JsonRpcRequestStruct,"Invalid JSON-RPC request",P)}t.assertIsJsonRpcRequest=h,t.PendingJsonRpcResponseStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,result:(0,e.optional)((0,e.unknown)()),error:(0,e.optional)(t.JsonRpcErrorStruct)}),t.JsonRpcSuccessStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,result:t.JsonStruct}),t.JsonRpcFailureStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,error:t.JsonRpcErrorStruct}),t.JsonRpcResponseStruct=(0,e.union)([t.JsonRpcSuccessStruct,t.JsonRpcFailureStruct]);function y(C){return(0,e.is)(C,t.PendingJsonRpcResponseStruct)}t.isPendingJsonRpcResponse=y;function S(C,P){(0,r.assertStruct)(C,t.PendingJsonRpcResponseStruct,"Invalid pending JSON-RPC response",P)}t.assertIsPendingJsonRpcResponse=S;function E(C){return(0,e.is)(C,t.JsonRpcResponseStruct)}t.isJsonRpcResponse=E;function M(C,P){(0,r.assertStruct)(C,t.JsonRpcResponseStruct,"Invalid JSON-RPC response",P)}t.assertIsJsonRpcResponse=M;function k(C){return(0,e.is)(C,t.JsonRpcSuccessStruct)}t.isJsonRpcSuccess=k;function T(C,P){(0,r.assertStruct)(C,t.JsonRpcSuccessStruct,"Invalid JSON-RPC success response",P)}t.assertIsJsonRpcSuccess=T;function O(C){return(0,e.is)(C,t.JsonRpcFailureStruct)}t.isJsonRpcFailure=O;function B(C,P){(0,r.assertStruct)(C,t.JsonRpcFailureStruct,"Invalid JSON-RPC failure response",P)}t.assertIsJsonRpcFailure=B;function L(C){return(0,e.is)(C,t.JsonRpcErrorStruct)}t.isJsonRpcError=L;function R(C,P){(0,r.assertStruct)(C,t.JsonRpcErrorStruct,"Invalid JSON-RPC error",P)}t.assertIsJsonRpcError=R;function z(C){const{permitEmptyString:P,permitFractions:J,permitNull:We}=Object.assign({permitEmptyString:!0,permitFractions:!1,permitNull:!0},C);return Y=>!!(typeof Y=="number"&&(J||Number.isInteger(Y))||typeof Y=="string"&&(P||Y.length>0)||We&&Y===null)}t.getJsonRpcIdValidator=z})(nc);var sc={};Object.defineProperty(sc,"__esModule",{value:!0});var ar={},hh=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ar,"__esModule",{value:!0});ar.createModuleLogger=ar.createProjectLogger=void 0;const fh=hh(xc),gh=(0,fh.default)("metamask");function ph(t){return gh.extend(t)}ar.createProjectLogger=ph;function mh(t,e){return t.extend(e)}ar.createModuleLogger=mh;var ic={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.calculateNumberSize=t.calculateStringSize=t.isASCII=t.isPlainObject=t.ESCAPE_CHARACTERS_REGEXP=t.JsonSize=t.hasProperty=t.isObject=t.isNullOrUndefined=t.isNonEmptyArray=void 0;function e(h){return Array.isArray(h)&&h.length>0}t.isNonEmptyArray=e;function r(h){return h==null}t.isNullOrUndefined=r;function n(h){return!!h&&typeof h=="object"&&!Array.isArray(h)}t.isObject=n;const i=(h,y)=>Object.hasOwnProperty.call(h,y);t.hasProperty=i,function(h){h[h.Null=4]="Null",h[h.Comma=1]="Comma",h[h.Wrapper=1]="Wrapper",h[h.True=4]="True",h[h.False=5]="False",h[h.Quote=1]="Quote",h[h.Colon=1]="Colon",h[h.Date=24]="Date"}(t.JsonSize||(t.JsonSize={})),t.ESCAPE_CHARACTERS_REGEXP=/"|\\|\n|\r|\t/gu;function s(h){if(typeof h!="object"||h===null)return!1;try{let y=h;for(;Object.getPrototypeOf(y)!==null;)y=Object.getPrototypeOf(y);return Object.getPrototypeOf(h)===y}catch{return!1}}t.isPlainObject=s;function c(h){return h.charCodeAt(0)<=127}t.isASCII=c;function u(h){var y;return h.split("").reduce((E,M)=>c(M)?E+1:E+2,0)+((y=h.match(t.ESCAPE_CHARACTERS_REGEXP))!==null&&y!==void 0?y:[]).length}t.calculateStringSize=u;function d(h){return h.toString().length}t.calculateNumberSize=d})(ic);var bt={};Object.defineProperty(bt,"__esModule",{value:!0});bt.hexToBigInt=bt.hexToNumber=bt.bigIntToHex=bt.numberToHex=void 0;const er=Ve,_r=Dr,vh=t=>((0,er.assert)(typeof t=="number","Value must be a number."),(0,er.assert)(t>=0,"Value must be a non-negative number."),(0,er.assert)(Number.isSafeInteger(t),"Value is not a safe integer. Use `bigIntToHex` instead."),(0,_r.add0x)(t.toString(16)));bt.numberToHex=vh;const wh=t=>((0,er.assert)(typeof t=="bigint","Value must be a bigint."),(0,er.assert)(t>=0,"Value must be a non-negative bigint."),(0,_r.add0x)(t.toString(16)));bt.bigIntToHex=wh;const yh=t=>{(0,_r.assertIsHexString)(t);const e=parseInt(t,16);return(0,er.assert)(Number.isSafeInteger(e),"Value is not a safe integer. Use `hexToBigInt` instead."),e};bt.hexToNumber=yh;const bh=t=>((0,_r.assertIsHexString)(t),BigInt((0,_r.add0x)(t)));bt.hexToBigInt=bh;var oc={};Object.defineProperty(oc,"__esModule",{value:!0});var ac={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.timeSince=t.inMilliseconds=t.Duration=void 0,function(s){s[s.Millisecond=1]="Millisecond",s[s.Second=1e3]="Second",s[s.Minute=6e4]="Minute",s[s.Hour=36e5]="Hour",s[s.Day=864e5]="Day",s[s.Week=6048e5]="Week",s[s.Year=31536e6]="Year"}(t.Duration||(t.Duration={}));const e=s=>Number.isInteger(s)&&s>=0,r=(s,c)=>{if(!e(s))throw new Error(`"${c}" must be a non-negative integer. Received: "${s}".`)};function n(s,c){return r(s,"count"),s*c}t.inMilliseconds=n;function i(s){return r(s,"timestamp"),Date.now()-s}t.timeSince=i})(ac);var cc={};Object.defineProperty(cc,"__esModule",{value:!0});var lc={},Ds={exports:{}};const _h="2.0.0",uc=256,Eh=Number.MAX_SAFE_INTEGER||9007199254740991,Sh=16,Mh=uc-6,kh=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var Bn={MAX_LENGTH:uc,MAX_SAFE_COMPONENT_LENGTH:Sh,MAX_SAFE_BUILD_LENGTH:Mh,MAX_SAFE_INTEGER:Eh,RELEASE_TYPES:kh,SEMVER_SPEC_VERSION:_h,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},ks={};const Rh=typeof process=="object"&&ks&&ks.NODE_DEBUG&&/\bsemver\b/i.test(ks.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};var Dn=Rh;(function(t,e){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=Bn,s=Dn;e=t.exports={};const c=e.re=[],u=e.safeRe=[],d=e.src=[],h=e.t={};let y=0;const S="[a-zA-Z0-9-]",E=[["\\s",1],["\\d",i],[S,n]],M=T=>{for(const[O,B]of E)T=T.split(`${O}*`).join(`${O}{0,${B}}`).split(`${O}+`).join(`${O}{1,${B}}`);return T},k=(T,O,B)=>{const L=M(O),R=y++;s(T,R,O),h[T]=R,d[R]=O,c[R]=new RegExp(O,B?"g":void 0),u[R]=new RegExp(L,B?"g":void 0)};k("NUMERICIDENTIFIER","0|[1-9]\\d*"),k("NUMERICIDENTIFIERLOOSE","\\d+"),k("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${S}*`),k("MAINVERSION",`(${d[h.NUMERICIDENTIFIER]})\\.(${d[h.NUMERICIDENTIFIER]})\\.(${d[h.NUMERICIDENTIFIER]})`),k("MAINVERSIONLOOSE",`(${d[h.NUMERICIDENTIFIERLOOSE]})\\.(${d[h.NUMERICIDENTIFIERLOOSE]})\\.(${d[h.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASEIDENTIFIER",`(?:${d[h.NUMERICIDENTIFIER]}|${d[h.NONNUMERICIDENTIFIER]})`),k("PRERELEASEIDENTIFIERLOOSE",`(?:${d[h.NUMERICIDENTIFIERLOOSE]}|${d[h.NONNUMERICIDENTIFIER]})`),k("PRERELEASE",`(?:-(${d[h.PRERELEASEIDENTIFIER]}(?:\\.${d[h.PRERELEASEIDENTIFIER]})*))`),k("PRERELEASELOOSE",`(?:-?(${d[h.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${d[h.PRERELEASEIDENTIFIERLOOSE]})*))`),k("BUILDIDENTIFIER",`${S}+`),k("BUILD",`(?:\\+(${d[h.BUILDIDENTIFIER]}(?:\\.${d[h.BUILDIDENTIFIER]})*))`),k("FULLPLAIN",`v?${d[h.MAINVERSION]}${d[h.PRERELEASE]}?${d[h.BUILD]}?`),k("FULL",`^${d[h.FULLPLAIN]}$`),k("LOOSEPLAIN",`[v=\\s]*${d[h.MAINVERSIONLOOSE]}${d[h.PRERELEASELOOSE]}?${d[h.BUILD]}?`),k("LOOSE",`^${d[h.LOOSEPLAIN]}$`),k("GTLT","((?:<|>)?=?)"),k("XRANGEIDENTIFIERLOOSE",`${d[h.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),k("XRANGEIDENTIFIER",`${d[h.NUMERICIDENTIFIER]}|x|X|\\*`),k("XRANGEPLAIN",`[v=\\s]*(${d[h.XRANGEIDENTIFIER]})(?:\\.(${d[h.XRANGEIDENTIFIER]})(?:\\.(${d[h.XRANGEIDENTIFIER]})(?:${d[h.PRERELEASE]})?${d[h.BUILD]}?)?)?`),k("XRANGEPLAINLOOSE",`[v=\\s]*(${d[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[h.XRANGEIDENTIFIERLOOSE]})(?:${d[h.PRERELEASELOOSE]})?${d[h.BUILD]}?)?)?`),k("XRANGE",`^${d[h.GTLT]}\\s*${d[h.XRANGEPLAIN]}$`),k("XRANGELOOSE",`^${d[h.GTLT]}\\s*${d[h.XRANGEPLAINLOOSE]}$`),k("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),k("COERCE",`${d[h.COERCEPLAIN]}(?:$|[^\\d])`),k("COERCEFULL",d[h.COERCEPLAIN]+`(?:${d[h.PRERELEASE]})?(?:${d[h.BUILD]})?(?:$|[^\\d])`),k("COERCERTL",d[h.COERCE],!0),k("COERCERTLFULL",d[h.COERCEFULL],!0),k("LONETILDE","(?:~>?)"),k("TILDETRIM",`(\\s*)${d[h.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",k("TILDE",`^${d[h.LONETILDE]}${d[h.XRANGEPLAIN]}$`),k("TILDELOOSE",`^${d[h.LONETILDE]}${d[h.XRANGEPLAINLOOSE]}$`),k("LONECARET","(?:\\^)"),k("CARETTRIM",`(\\s*)${d[h.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",k("CARET",`^${d[h.LONECARET]}${d[h.XRANGEPLAIN]}$`),k("CARETLOOSE",`^${d[h.LONECARET]}${d[h.XRANGEPLAINLOOSE]}$`),k("COMPARATORLOOSE",`^${d[h.GTLT]}\\s*(${d[h.LOOSEPLAIN]})$|^$`),k("COMPARATOR",`^${d[h.GTLT]}\\s*(${d[h.FULLPLAIN]})$|^$`),k("COMPARATORTRIM",`(\\s*)${d[h.GTLT]}\\s*(${d[h.LOOSEPLAIN]}|${d[h.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",k("HYPHENRANGE",`^\\s*(${d[h.XRANGEPLAIN]})\\s+-\\s+(${d[h.XRANGEPLAIN]})\\s*$`),k("HYPHENRANGELOOSE",`^\\s*(${d[h.XRANGEPLAINLOOSE]})\\s+-\\s+(${d[h.XRANGEPLAINLOOSE]})\\s*$`),k("STAR","(<|>)?=?\\s*\\*"),k("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),k("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Ds,Ds.exports);var jr=Ds.exports;const Ih=Object.freeze({loose:!0}),Ch=Object.freeze({}),Ah=t=>t?typeof t!="object"?Ih:t:Ch;var ci=Ah;const wo=/^[0-9]+$/,dc=(t,e)=>{const r=wo.test(t),n=wo.test(e);return r&&n&&(t=+t,e=+e),t===e?0:r&&!n?-1:n&&!r?1:tdc(e,t);var hc={compareIdentifiers:dc,rcompareIdentifiers:Nh};const Qr=Dn,{MAX_LENGTH:yo,MAX_SAFE_INTEGER:Kr}=Bn,{safeRe:bo,t:_o}=jr,Lh=ci,{compareIdentifiers:Gt}=hc;let xh=class gt{constructor(e,r){if(r=Lh(r),e instanceof gt){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>yo)throw new TypeError(`version is longer than ${yo} characters`);Qr("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;const n=e.trim().match(r.loose?bo[_o.LOOSE]:bo[_o.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>Kr||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Kr||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Kr||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){const s=+i;if(s>=0&&s=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);if(s===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(r){let s=[r,i];n===!1&&(s=[r]),Gt(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};var Ze=xh;const Eo=Ze,Th=(t,e,r=!1)=>{if(t instanceof Eo)return t;try{return new Eo(t,e)}catch(n){if(!r)return null;throw n}};var gr=Th;const Ph=gr,$h=(t,e)=>{const r=Ph(t,e);return r?r.version:null};var Oh=$h;const Bh=gr,Dh=(t,e)=>{const r=Bh(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null};var jh=Dh;const So=Ze,Fh=(t,e,r,n,i)=>{typeof r=="string"&&(i=n,n=r,r=void 0);try{return new So(t instanceof So?t.version:t,r).inc(e,n,i).version}catch{return null}};var Hh=Fh;const Mo=gr,Uh=(t,e)=>{const r=Mo(t,null,!0),n=Mo(e,null,!0),i=r.compare(n);if(i===0)return null;const s=i>0,c=s?r:n,u=s?n:r,d=!!c.prerelease.length;if(!!u.prerelease.length&&!d)return!u.patch&&!u.minor?"major":c.patch?"patch":c.minor?"minor":"major";const y=d?"pre":"";return r.major!==n.major?y+"major":r.minor!==n.minor?y+"minor":r.patch!==n.patch?y+"patch":"prerelease"};var Vh=Uh;const Wh=Ze,zh=(t,e)=>new Wh(t,e).major;var qh=zh;const Jh=Ze,Gh=(t,e)=>new Jh(t,e).minor;var Zh=Gh;const Qh=Ze,Kh=(t,e)=>new Qh(t,e).patch;var Xh=Kh;const Yh=gr,ef=(t,e)=>{const r=Yh(t,e);return r&&r.prerelease.length?r.prerelease:null};var tf=ef;const ko=Ze,rf=(t,e,r)=>new ko(t,r).compare(new ko(e,r));var ut=rf;const nf=ut,sf=(t,e,r)=>nf(e,t,r);var of=sf;const af=ut,cf=(t,e)=>af(t,e,!0);var lf=cf;const Ro=Ze,uf=(t,e,r)=>{const n=new Ro(t,r),i=new Ro(e,r);return n.compare(i)||n.compareBuild(i)};var li=uf;const df=li,hf=(t,e)=>t.sort((r,n)=>df(r,n,e));var ff=hf;const gf=li,pf=(t,e)=>t.sort((r,n)=>gf(n,r,e));var mf=pf;const vf=ut,wf=(t,e,r)=>vf(t,e,r)>0;var jn=wf;const yf=ut,bf=(t,e,r)=>yf(t,e,r)<0;var ui=bf;const _f=ut,Ef=(t,e,r)=>_f(t,e,r)===0;var fc=Ef;const Sf=ut,Mf=(t,e,r)=>Sf(t,e,r)!==0;var gc=Mf;const kf=ut,Rf=(t,e,r)=>kf(t,e,r)>=0;var di=Rf;const If=ut,Cf=(t,e,r)=>If(t,e,r)<=0;var hi=Cf;const Af=fc,Nf=gc,Lf=jn,xf=di,Tf=ui,Pf=hi,$f=(t,e,r,n)=>{switch(e){case"===":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t===r;case"!==":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t!==r;case"":case"=":case"==":return Af(t,r,n);case"!=":return Nf(t,r,n);case">":return Lf(t,r,n);case">=":return xf(t,r,n);case"<":return Tf(t,r,n);case"<=":return Pf(t,r,n);default:throw new TypeError(`Invalid operator: ${e}`)}};var pc=$f;const Of=Ze,Bf=gr,{safeRe:Xr,t:Yr}=jr,Df=(t,e)=>{if(t instanceof Of)return t;if(typeof t=="number"&&(t=String(t)),typeof t!="string")return null;e=e||{};let r=null;if(!e.rtl)r=t.match(e.includePrerelease?Xr[Yr.COERCEFULL]:Xr[Yr.COERCE]);else{const d=e.includePrerelease?Xr[Yr.COERCERTLFULL]:Xr[Yr.COERCERTL];let h;for(;(h=d.exec(t))&&(!r||r.index+r[0].length!==t.length);)(!r||h.index+h[0].length!==r.index+r[0].length)&&(r=h),d.lastIndex=h.index+h[1].length+h[2].length;d.lastIndex=-1}if(r===null)return null;const n=r[2],i=r[3]||"0",s=r[4]||"0",c=e.includePrerelease&&r[5]?`-${r[5]}`:"",u=e.includePrerelease&&r[6]?`+${r[6]}`:"";return Bf(`${n}.${i}.${s}${c}${u}`,e)};var jf=Df;class Ff{constructor(){this.max=1e3,this.map=new Map}get(e){const r=this.map.get(e);if(r!==void 0)return this.map.delete(e),this.map.set(e,r),r}delete(e){return this.map.delete(e)}set(e,r){if(!this.delete(e)&&r!==void 0){if(this.map.size>=this.max){const i=this.map.keys().next().value;this.delete(i)}this.map.set(e,r)}return this}}var Hf=Ff,Rs,Io;function dt(){if(Io)return Rs;Io=1;const t=/\s+/g;class e{constructor(l,f){if(f=i(f),l instanceof e)return l.loose===!!f.loose&&l.includePrerelease===!!f.includePrerelease?l:new e(l.raw,f);if(l instanceof s)return this.raw=l.value,this.set=[[l]],this.formatted=void 0,this;if(this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease,this.raw=l.trim().replace(t," "),this.set=this.raw.split("||").map(g=>this.parseRange(g.trim())).filter(g=>g.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const g=this.set[0];if(this.set=this.set.filter(m=>!T(m[0])),this.set.length===0)this.set=[g];else if(this.set.length>1){for(const m of this.set)if(m.length===1&&O(m[0])){this.set=[m];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let l=0;l0&&(this.formatted+="||");const f=this.set[l];for(let g=0;g0&&(this.formatted+=" "),this.formatted+=f[g].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(l){const g=((this.options.includePrerelease&&M)|(this.options.loose&&k))+":"+l,m=n.get(g);if(m)return m;const w=this.options.loose,_=w?d[h.HYPHENRANGELOOSE]:d[h.HYPHENRANGE];l=l.replace(_,q(this.options.includePrerelease)),c("hyphen replace",l),l=l.replace(d[h.COMPARATORTRIM],y),c("comparator trim",l),l=l.replace(d[h.TILDETRIM],S),c("tilde trim",l),l=l.replace(d[h.CARETTRIM],E),c("caret trim",l);let p=l.split(" ").map(I=>L(I,this.options)).join(" ").split(/\s+/).map(I=>H(I,this.options));w&&(p=p.filter(I=>(c("loose invalid filter",I,this.options),!!I.match(d[h.COMPARATORLOOSE])))),c("range list",p);const a=new Map,v=p.map(I=>new s(I,this.options));for(const I of v){if(T(I))return[I];a.set(I.value,I)}a.size>1&&a.has("")&&a.delete("");const N=[...a.values()];return n.set(g,N),N}intersects(l,f){if(!(l instanceof e))throw new TypeError("a Range is required");return this.set.some(g=>B(g,f)&&l.set.some(m=>B(m,f)&&g.every(w=>m.every(_=>w.intersects(_,f)))))}test(l){if(!l)return!1;if(typeof l=="string")try{l=new u(l,this.options)}catch{return!1}for(let f=0;fo.value==="<0.0.0-0",O=o=>o.value==="",B=(o,l)=>{let f=!0;const g=o.slice();let m=g.pop();for(;f&&g.length;)f=g.every(w=>m.intersects(w,l)),m=g.pop();return f},L=(o,l)=>(c("comp",o,l),o=P(o,l),c("caret",o),o=z(o,l),c("tildes",o),o=We(o,l),c("xrange",o),o=Y(o,l),c("stars",o),o),R=o=>!o||o.toLowerCase()==="x"||o==="*",z=(o,l)=>o.trim().split(/\s+/).map(f=>C(f,l)).join(" "),C=(o,l)=>{const f=l.loose?d[h.TILDELOOSE]:d[h.TILDE];return o.replace(f,(g,m,w,_,p)=>{c("tilde",o,g,m,w,_,p);let a;return R(m)?a="":R(w)?a=`>=${m}.0.0 <${+m+1}.0.0-0`:R(_)?a=`>=${m}.${w}.0 <${m}.${+w+1}.0-0`:p?(c("replaceTilde pr",p),a=`>=${m}.${w}.${_}-${p} <${m}.${+w+1}.0-0`):a=`>=${m}.${w}.${_} <${m}.${+w+1}.0-0`,c("tilde return",a),a})},P=(o,l)=>o.trim().split(/\s+/).map(f=>J(f,l)).join(" "),J=(o,l)=>{c("caret",o,l);const f=l.loose?d[h.CARETLOOSE]:d[h.CARET],g=l.includePrerelease?"-0":"";return o.replace(f,(m,w,_,p,a)=>{c("caret",o,m,w,_,p,a);let v;return R(w)?v="":R(_)?v=`>=${w}.0.0${g} <${+w+1}.0.0-0`:R(p)?w==="0"?v=`>=${w}.${_}.0${g} <${w}.${+_+1}.0-0`:v=`>=${w}.${_}.0${g} <${+w+1}.0.0-0`:a?(c("replaceCaret pr",a),w==="0"?_==="0"?v=`>=${w}.${_}.${p}-${a} <${w}.${_}.${+p+1}-0`:v=`>=${w}.${_}.${p}-${a} <${w}.${+_+1}.0-0`:v=`>=${w}.${_}.${p}-${a} <${+w+1}.0.0-0`):(c("no pr"),w==="0"?_==="0"?v=`>=${w}.${_}.${p}${g} <${w}.${_}.${+p+1}-0`:v=`>=${w}.${_}.${p}${g} <${w}.${+_+1}.0-0`:v=`>=${w}.${_}.${p} <${+w+1}.0.0-0`),c("caret return",v),v})},We=(o,l)=>(c("replaceXRanges",o,l),o.split(/\s+/).map(f=>Qe(f,l)).join(" ")),Qe=(o,l)=>{o=o.trim();const f=l.loose?d[h.XRANGELOOSE]:d[h.XRANGE];return o.replace(f,(g,m,w,_,p,a)=>{c("xRange",o,g,m,w,_,p,a);const v=R(w),N=v||R(_),I=N||R(p),$=I;return m==="="&&$&&(m=""),a=l.includePrerelease?"-0":"",v?m===">"||m==="<"?g="<0.0.0-0":g="*":m&&$?(N&&(_=0),p=0,m===">"?(m=">=",N?(w=+w+1,_=0,p=0):(_=+_+1,p=0)):m==="<="&&(m="<",N?w=+w+1:_=+_+1),m==="<"&&(a="-0"),g=`${m+w}.${_}.${p}${a}`):N?g=`>=${w}.0.0${a} <${+w+1}.0.0-0`:I&&(g=`>=${w}.${_}.0${a} <${w}.${+_+1}.0-0`),c("xRange return",g),g})},Y=(o,l)=>(c("replaceStars",o,l),o.trim().replace(d[h.STAR],"")),H=(o,l)=>(c("replaceGTE0",o,l),o.trim().replace(d[l.includePrerelease?h.GTE0PRE:h.GTE0],"")),q=o=>(l,f,g,m,w,_,p,a,v,N,I,$)=>(R(g)?f="":R(m)?f=`>=${g}.0.0${o?"-0":""}`:R(w)?f=`>=${g}.${m}.0${o?"-0":""}`:_?f=`>=${f}`:f=`>=${f}${o?"-0":""}`,R(v)?a="":R(N)?a=`<${+v+1}.0.0-0`:R(I)?a=`<${v}.${+N+1}.0-0`:$?a=`<=${v}.${N}.${I}-${$}`:o?a=`<${v}.${N}.${+I+1}-0`:a=`<=${a}`,`${f} ${a}`.trim()),b=(o,l,f)=>{for(let g=0;g0){const m=o[g].semver;if(m.major===l.major&&m.minor===l.minor&&m.patch===l.patch)return!0}return!1}return!0};return Rs}var Is,Co;function Fn(){if(Co)return Is;Co=1;const t=Symbol("SemVer ANY");class e{static get ANY(){return t}constructor(y,S){if(S=r(S),y instanceof e){if(y.loose===!!S.loose)return y;y=y.value}y=y.trim().split(/\s+/).join(" "),c("comparator",y,S),this.options=S,this.loose=!!S.loose,this.parse(y),this.semver===t?this.value="":this.value=this.operator+this.semver.version,c("comp",this)}parse(y){const S=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],E=y.match(S);if(!E)throw new TypeError(`Invalid comparator: ${y}`);this.operator=E[1]!==void 0?E[1]:"",this.operator==="="&&(this.operator=""),E[2]?this.semver=new u(E[2],this.options.loose):this.semver=t}toString(){return this.value}test(y){if(c("Comparator.test",y,this.options.loose),this.semver===t||y===t)return!0;if(typeof y=="string")try{y=new u(y,this.options)}catch{return!1}return s(y,this.operator,this.semver,this.options)}intersects(y,S){if(!(y instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new d(y.value,S).test(this.value):y.operator===""?y.value===""?!0:new d(this.value,S).test(y.semver):(S=r(S),S.includePrerelease&&(this.value==="<0.0.0-0"||y.value==="<0.0.0-0")||!S.includePrerelease&&(this.value.startsWith("<0.0.0")||y.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&y.operator.startsWith(">")||this.operator.startsWith("<")&&y.operator.startsWith("<")||this.semver.version===y.semver.version&&this.operator.includes("=")&&y.operator.includes("=")||s(this.semver,"<",y.semver,S)&&this.operator.startsWith(">")&&y.operator.startsWith("<")||s(this.semver,">",y.semver,S)&&this.operator.startsWith("<")&&y.operator.startsWith(">")))}}Is=e;const r=ci,{safeRe:n,t:i}=jr,s=pc,c=Dn,u=Ze,d=dt();return Is}const Uf=dt(),Vf=(t,e,r)=>{try{e=new Uf(e,r)}catch{return!1}return e.test(t)};var Hn=Vf;const Wf=dt(),zf=(t,e)=>new Wf(t,e).set.map(r=>r.map(n=>n.value).join(" ").trim().split(" "));var qf=zf;const Jf=Ze,Gf=dt(),Zf=(t,e,r)=>{let n=null,i=null,s=null;try{s=new Gf(e,r)}catch{return null}return t.forEach(c=>{s.test(c)&&(!n||i.compare(c)===-1)&&(n=c,i=new Jf(n,r))}),n};var Qf=Zf;const Kf=Ze,Xf=dt(),Yf=(t,e,r)=>{let n=null,i=null,s=null;try{s=new Xf(e,r)}catch{return null}return t.forEach(c=>{s.test(c)&&(!n||i.compare(c)===1)&&(n=c,i=new Kf(n,r))}),n};var e0=Yf;const Cs=Ze,t0=dt(),Ao=jn,r0=(t,e)=>{t=new t0(t,e);let r=new Cs("0.0.0");if(t.test(r)||(r=new Cs("0.0.0-0"),t.test(r)))return r;r=null;for(let n=0;n{const u=new Cs(c.semver.version);switch(c.operator){case">":u.prerelease.length===0?u.patch++:u.prerelease.push(0),u.raw=u.format();case"":case">=":(!s||Ao(u,s))&&(s=u);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${c.operator}`)}}),s&&(!r||Ao(r,s))&&(r=s)}return r&&t.test(r)?r:null};var n0=r0;const s0=dt(),i0=(t,e)=>{try{return new s0(t,e).range||"*"}catch{return null}};var o0=i0;const a0=Ze,mc=Fn(),{ANY:c0}=mc,l0=dt(),u0=Hn,No=jn,Lo=ui,d0=hi,h0=di,f0=(t,e,r,n)=>{t=new a0(t,n),e=new l0(e,n);let i,s,c,u,d;switch(r){case">":i=No,s=d0,c=Lo,u=">",d=">=";break;case"<":i=Lo,s=h0,c=No,u="<",d="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(u0(t,e,n))return!1;for(let h=0;h{M.semver===c0&&(M=new mc(">=0.0.0")),S=S||M,E=E||M,i(M.semver,S.semver,n)?S=M:c(M.semver,E.semver,n)&&(E=M)}),S.operator===u||S.operator===d||(!E.operator||E.operator===u)&&s(t,E.semver))return!1;if(E.operator===d&&c(t,E.semver))return!1}return!0};var fi=f0;const g0=fi,p0=(t,e,r)=>g0(t,e,">",r);var m0=p0;const v0=fi,w0=(t,e,r)=>v0(t,e,"<",r);var y0=w0;const xo=dt(),b0=(t,e,r)=>(t=new xo(t,r),e=new xo(e,r),t.intersects(e,r));var _0=b0;const E0=Hn,S0=ut;var M0=(t,e,r)=>{const n=[];let i=null,s=null;const c=t.sort((y,S)=>S0(y,S,r));for(const y of c)E0(y,e,r)?(s=y,i||(i=y)):(s&&n.push([i,s]),s=null,i=null);i&&n.push([i,null]);const u=[];for(const[y,S]of n)y===S?u.push(y):!S&&y===c[0]?u.push("*"):S?y===c[0]?u.push(`<=${S}`):u.push(`${y} - ${S}`):u.push(`>=${y}`);const d=u.join(" || "),h=typeof e.raw=="string"?e.raw:String(e);return d.length{if(t===e)return!0;t=new To(t,r),e=new To(e,r);let n=!1;e:for(const i of t.set){for(const s of e.set){const c=I0(i,s,r);if(n=n||c!==null,c)continue e}if(n)return!1}return!0},R0=[new gi(">=0.0.0-0")],Po=[new gi(">=0.0.0")],I0=(t,e,r)=>{if(t===e)return!0;if(t.length===1&&t[0].semver===As){if(e.length===1&&e[0].semver===As)return!0;r.includePrerelease?t=R0:t=Po}if(e.length===1&&e[0].semver===As){if(r.includePrerelease)return!0;e=Po}const n=new Set;let i,s;for(const M of t)M.operator===">"||M.operator===">="?i=$o(i,M,r):M.operator==="<"||M.operator==="<="?s=Oo(s,M,r):n.add(M.semver);if(n.size>1)return null;let c;if(i&&s){if(c=pi(i.semver,s.semver,r),c>0)return null;if(c===0&&(i.operator!==">="||s.operator!=="<="))return null}for(const M of n){if(i&&!mr(M,String(i),r)||s&&!mr(M,String(s),r))return null;for(const k of e)if(!mr(M,String(k),r))return!1;return!0}let u,d,h,y,S=s&&!r.includePrerelease&&s.semver.prerelease.length?s.semver:!1,E=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1;S&&S.prerelease.length===1&&s.operator==="<"&&S.prerelease[0]===0&&(S=!1);for(const M of e){if(y=y||M.operator===">"||M.operator===">=",h=h||M.operator==="<"||M.operator==="<=",i){if(E&&M.semver.prerelease&&M.semver.prerelease.length&&M.semver.major===E.major&&M.semver.minor===E.minor&&M.semver.patch===E.patch&&(E=!1),M.operator===">"||M.operator===">="){if(u=$o(i,M,r),u===M&&u!==i)return!1}else if(i.operator===">="&&!mr(i.semver,String(M),r))return!1}if(s){if(S&&M.semver.prerelease&&M.semver.prerelease.length&&M.semver.major===S.major&&M.semver.minor===S.minor&&M.semver.patch===S.patch&&(S=!1),M.operator==="<"||M.operator==="<="){if(d=Oo(s,M,r),d===M&&d!==s)return!1}else if(s.operator==="<="&&!mr(s.semver,String(M),r))return!1}if(!M.operator&&(s||i)&&c!==0)return!1}return!(i&&h&&!s&&c!==0||s&&y&&!i&&c!==0||E||S)},$o=(t,e,r)=>{if(!t)return e;const n=pi(t.semver,e.semver,r);return n>0?t:n<0||e.operator===">"&&t.operator===">="?e:t},Oo=(t,e,r)=>{if(!t)return e;const n=pi(t.semver,e.semver,r);return n<0?t:n>0||e.operator==="<"&&t.operator==="<="?e:t};var C0=k0;const Ns=jr,Bo=Bn,A0=Ze,Do=hc,N0=gr,L0=Oh,x0=jh,T0=Hh,P0=Vh,$0=qh,O0=Zh,B0=Xh,D0=tf,j0=ut,F0=of,H0=lf,U0=li,V0=ff,W0=mf,z0=jn,q0=ui,J0=fc,G0=gc,Z0=di,Q0=hi,K0=pc,X0=jf,Y0=Fn(),e1=dt(),t1=Hn,r1=qf,n1=Qf,s1=e0,i1=n0,o1=o0,a1=fi,c1=m0,l1=y0,u1=_0,d1=M0,h1=C0;var f1={parse:N0,valid:L0,clean:x0,inc:T0,diff:P0,major:$0,minor:O0,patch:B0,prerelease:D0,compare:j0,rcompare:F0,compareLoose:H0,compareBuild:U0,sort:V0,rsort:W0,gt:z0,lt:q0,eq:J0,neq:G0,gte:Z0,lte:Q0,cmp:K0,coerce:X0,Comparator:Y0,Range:e1,satisfies:t1,toComparators:r1,maxSatisfying:n1,minSatisfying:s1,minVersion:i1,validRange:o1,outside:a1,gtr:c1,ltr:l1,intersects:u1,simplifyRange:d1,subset:h1,SemVer:A0,re:Ns.re,src:Ns.src,tokens:Ns.t,SEMVER_SPEC_VERSION:Bo.SEMVER_SPEC_VERSION,RELEASE_TYPES:Bo.RELEASE_TYPES,compareIdentifiers:Do.compareIdentifiers,rcompareIdentifiers:Do.rcompareIdentifiers};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.satisfiesVersionRange=t.gtRange=t.gtVersion=t.assertIsSemVerRange=t.assertIsSemVerVersion=t.isValidSemVerRange=t.isValidSemVerVersion=t.VersionRangeStruct=t.VersionStruct=void 0;const e=f1,r=Vt,n=Ve;t.VersionStruct=(0,r.refine)((0,r.string)(),"Version",S=>(0,e.valid)(S)===null?`Expected SemVer version, got "${S}"`:!0),t.VersionRangeStruct=(0,r.refine)((0,r.string)(),"Version range",S=>(0,e.validRange)(S)===null?`Expected SemVer range, got "${S}"`:!0);function i(S){return(0,r.is)(S,t.VersionStruct)}t.isValidSemVerVersion=i;function s(S){return(0,r.is)(S,t.VersionRangeStruct)}t.isValidSemVerRange=s;function c(S){(0,n.assertStruct)(S,t.VersionStruct)}t.assertIsSemVerVersion=c;function u(S){(0,n.assertStruct)(S,t.VersionRangeStruct)}t.assertIsSemVerRange=u;function d(S,E){return(0,e.gt)(S,E)}t.gtVersion=d;function h(S,E){return(0,e.gtr)(S,E)}t.gtRange=h;function y(S,E){return(0,e.satisfies)(S,E,{includePrerelease:!0})}t.satisfiesVersionRange=y})(lc);(function(t){var e=x&&x.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s);var u=Object.getOwnPropertyDescriptor(i,s);(!u||("get"in u?!i.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(n,c,u)}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=x&&x.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Ve,t),r(Br,t),r(W,t),r($n,t),r(yt,t),r(or,t),r(rc,t),r(Dr,t),r(nc,t),r(sc,t),r(ar,t),r(ic,t),r(bt,t),r(oc,t),r(ac,t),r(cc,t),r(lc,t)})(Ba);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createModuleLogger=t.projectLogger=void 0;const e=Ba;Object.defineProperty(t,"createModuleLogger",{enumerable:!0,get:function(){return e.createModuleLogger}}),t.projectLogger=(0,e.createProjectLogger)("eth-block-tracker")})(Oa);var vc=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Tn,"__esModule",{value:!0});Tn.PollingBlockTracker=void 0;const g1=vc(Ys),p1=vc(Vu),m1=Tr,jo=Oa,Fo=(0,jo.createModuleLogger)(jo.projectLogger,"polling-block-tracker"),v1=(0,g1.default)(),w1=1e3;class y1 extends m1.BaseBlockTracker{constructor(e={}){var r;if(!e.provider)throw new Error("PollingBlockTracker - no provider specified.");super(Object.assign(Object.assign({},e),{blockResetDuration:(r=e.blockResetDuration)!==null&&r!==void 0?r:e.pollingInterval})),this._provider=e.provider,this._pollingInterval=e.pollingInterval||20*w1,this._retryTimeout=e.retryTimeout||this._pollingInterval/10,this._keepEventLoopActive=e.keepEventLoopActive===void 0?!0:e.keepEventLoopActive,this._setSkipCacheFlag=e.setSkipCacheFlag||!1}async checkForLatestBlock(){return await this._updateLatestBlock(),await this.getLatestBlock()}async _start(){this._synchronize()}async _end(){}async _synchronize(){for(var e;this._isRunning;)try{await this._updateLatestBlock();const r=Ho(this._pollingInterval,!this._keepEventLoopActive);this.emit("_waitingForNextIteration"),await r}catch(r){const n=new Error(`PollingBlockTracker - encountered an error while attempting to update latest block: -${(e=r.stack)!==null&&e!==void 0?e:r}`);try{this.emit("error",n)}catch{console.error(n)}const i=Ho(this._retryTimeout,!this._keepEventLoopActive);this.emit("_waitingForNextIteration"),await i}}async _updateLatestBlock(){const e=await this._fetchLatestBlock();this._newPotentialLatest(e)}async _fetchLatestBlock(){const e={jsonrpc:"2.0",id:v1(),method:"eth_blockNumber",params:[]};this._setSkipCacheFlag&&(e.skipCache=!0),Fo("Making request",e);const r=await(0,p1.default)(n=>this._provider.sendAsync(e,n))();if(Fo("Got response",r),r.error)throw new Error(`PollingBlockTracker - encountered error fetching block: -${r.error.message}`);return r.result}}Tn.PollingBlockTracker=y1;function Ho(t,e){return new Promise(r=>{const n=setTimeout(r,t);n.unref&&e&&n.unref()})}var Un={},b1=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Un,"__esModule",{value:!0});Un.SubscribeBlockTracker=void 0;const _1=b1(Ys),E1=Tr,S1=(0,_1.default)();class M1 extends E1.BaseBlockTracker{constructor(e={}){if(!e.provider)throw new Error("SubscribeBlockTracker - no provider specified.");super(e),this._provider=e.provider,this._subscriptionId=null}async checkForLatestBlock(){return await this.getLatestBlock()}async _start(){if(this._subscriptionId===void 0||this._subscriptionId===null)try{const e=await this._call("eth_blockNumber");this._subscriptionId=await this._call("eth_subscribe","newHeads"),this._provider.on("data",this._handleSubData.bind(this)),this._newPotentialLatest(e)}catch(e){this.emit("error",e)}}async _end(){if(this._subscriptionId!==null&&this._subscriptionId!==void 0)try{await this._call("eth_unsubscribe",this._subscriptionId),this._subscriptionId=null}catch(e){this.emit("error",e)}}_call(e,...r){return new Promise((n,i)=>{this._provider.sendAsync({id:S1(),method:e,params:r,jsonrpc:"2.0"},(s,c)=>{s?i(s):n(c.result)})})}_handleSubData(e,r){var n;r.method==="eth_subscription"&&((n=r.params)===null||n===void 0?void 0:n.subscription)===this._subscriptionId&&this._newPotentialLatest(r.params.result.number)}}Un.SubscribeBlockTracker=M1;(function(t){var e=x&&x.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=x&&x.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Tn,t),r(Un,t)})($a);var mi={},Vn={},Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});Fr.getUniqueId=void 0;const wc=4294967295;let Ls=Math.floor(Math.random()*wc);function k1(){return Ls=(Ls+1)%wc,Ls}Fr.getUniqueId=k1;Object.defineProperty(Vn,"__esModule",{value:!0});Vn.createIdRemapMiddleware=void 0;const R1=Fr;function I1(){return(t,e,r,n)=>{const i=t.id,s=R1.getUniqueId();t.id=s,e.id=s,r(c=>{t.id=i,e.id=i,c()})}}Vn.createIdRemapMiddleware=I1;var Wn={};Object.defineProperty(Wn,"__esModule",{value:!0});Wn.createAsyncMiddleware=void 0;function C1(t){return async(e,r,n,i)=>{let s;const c=new Promise(y=>{s=y});let u=null,d=!1;const h=async()=>{d=!0,n(y=>{u=y,s()}),await c};try{await t(e,r,h),d?(await c,u(null)):i(null)}catch(y){u?u(y):i(y)}}}Wn.createAsyncMiddleware=C1;var zn={};Object.defineProperty(zn,"__esModule",{value:!0});zn.createScaffoldMiddleware=void 0;function A1(t){return(e,r,n,i)=>{const s=t[e.method];return s===void 0?n():typeof s=="function"?s(e,r,n,i):(r.result=s,i())}}zn.createScaffoldMiddleware=A1;var Hr={},vi={};Object.defineProperty(vi,"__esModule",{value:!0});const N1=ta;function Uo(t,e,r){try{Reflect.apply(t,e,r)}catch(n){setTimeout(()=>{throw n})}}function L1(t){const e=t.length,r=new Array(e);for(let n=0;n0&&([c]=r),c instanceof Error)throw c;const u=new Error(`Unhandled error.${c?` (${c.message})`:""}`);throw u.context=c,u}const s=i[e];if(s===void 0)return!1;if(typeof s=="function")Uo(s,this,r);else{const c=s.length,u=L1(s);for(let d=0;d"u"&&(n=_c()),js(t,"",0,[],void 0,0,n);var i;try{Bt.length===0?i=JSON.stringify(t,e,r):i=JSON.stringify(t,Sc(e),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Ft.length!==0;){var s=Ft.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function tr(t,e,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:t}),Ft.push([n,r,e,i])):Bt.push([e,r,t]):(n[r]=t,Ft.push([n,r,e]))}function js(t,e,r,n,i,s,c){s+=1;var u;if(typeof t=="object"&&t!==null){for(u=0;uc.depthLimit){tr(sn,t,e,i);return}if(typeof c.edgesLimit<"u"&&r+1>c.edgesLimit){tr(sn,t,e,i);return}if(n.push(t),Array.isArray(t))for(u=0;ue?1:0}function Ec(t,e,r,n){typeof n>"u"&&(n=_c());var i=Fs(t,"",0,[],void 0,0,n)||t,s;try{Bt.length===0?s=JSON.stringify(i,e,r):s=JSON.stringify(i,Sc(e),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Ft.length!==0;){var c=Ft.pop();c.length===4?Object.defineProperty(c[0],c[1],c[3]):c[0][c[1]]=c[2]}}return s}function Fs(t,e,r,n,i,s,c){s+=1;var u;if(typeof t=="object"&&t!==null){for(u=0;uc.depthLimit){tr(sn,t,e,i);return}if(typeof c.edgesLimit<"u"&&r+1>c.edgesLimit){tr(sn,t,e,i);return}if(n.push(t),Array.isArray(t))for(u=0;u0)for(var n=0;n=1e3&&t<=4999}function D1(t,e){if(e!=="[Circular]")return e}var wi={},At={};Object.defineProperty(At,"__esModule",{value:!0});At.errorValues=At.errorCodes=void 0;At.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}};At.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeError=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=At,r=Ct,n=e.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",s={code:n,message:c(n)};t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function c(E,M=i){if(Number.isInteger(E)){const k=E.toString();if(S(e.errorValues,k))return e.errorValues[k].message;if(h(E))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return M}t.getMessageFromCode=c;function u(E){if(!Number.isInteger(E))return!1;const M=E.toString();return!!(e.errorValues[M]||h(E))}t.isValidCode=u;function d(E,{fallbackError:M=s,shouldIncludeStack:k=!1}={}){var T,O;if(!M||!Number.isInteger(M.code)||typeof M.message!="string")throw new Error("Must provide fallback error with integer number code and string message.");if(E instanceof r.EthereumRpcError)return E.serialize();const B={};if(E&&typeof E=="object"&&!Array.isArray(E)&&S(E,"code")&&u(E.code)){const R=E;B.code=R.code,R.message&&typeof R.message=="string"?(B.message=R.message,S(R,"data")&&(B.data=R.data)):(B.message=c(B.code),B.data={originalError:y(E)})}else{B.code=M.code;const R=(T=E)===null||T===void 0?void 0:T.message;B.message=R&&typeof R=="string"?R:M.message,B.data={originalError:y(E)}}const L=(O=E)===null||O===void 0?void 0:O.stack;return k&&E&&L&&typeof L=="string"&&(B.stack=L),B}t.serializeError=d;function h(E){return E>=-32099&&E<=-32e3}function y(E){return E&&typeof E=="object"&&!Array.isArray(E)?Object.assign({},E):E}function S(E,M){return Object.prototype.hasOwnProperty.call(E,M)}})(wi);var qn={};Object.defineProperty(qn,"__esModule",{value:!0});qn.ethErrors=void 0;const yi=Ct,kc=wi,qe=At;qn.ethErrors={rpc:{parse:t=>nt(qe.errorCodes.rpc.parse,t),invalidRequest:t=>nt(qe.errorCodes.rpc.invalidRequest,t),invalidParams:t=>nt(qe.errorCodes.rpc.invalidParams,t),methodNotFound:t=>nt(qe.errorCodes.rpc.methodNotFound,t),internal:t=>nt(qe.errorCodes.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return nt(e,t)},invalidInput:t=>nt(qe.errorCodes.rpc.invalidInput,t),resourceNotFound:t=>nt(qe.errorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>nt(qe.errorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>nt(qe.errorCodes.rpc.transactionRejected,t),methodNotSupported:t=>nt(qe.errorCodes.rpc.methodNotSupported,t),limitExceeded:t=>nt(qe.errorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>vr(qe.errorCodes.provider.userRejectedRequest,t),unauthorized:t=>vr(qe.errorCodes.provider.unauthorized,t),unsupportedMethod:t=>vr(qe.errorCodes.provider.unsupportedMethod,t),disconnected:t=>vr(qe.errorCodes.provider.disconnected,t),chainDisconnected:t=>vr(qe.errorCodes.provider.chainDisconnected,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:r,data:n}=t;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new yi.EthereumProviderError(e,r,n)}}};function nt(t,e){const[r,n]=Rc(e);return new yi.EthereumRpcError(t,r||kc.getMessageFromCode(t),n)}function vr(t,e){const[r,n]=Rc(e);return new yi.EthereumProviderError(t,r||kc.getMessageFromCode(t),n)}function Rc(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,r]}}return[]}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromCode=t.serializeError=t.EthereumProviderError=t.EthereumRpcError=t.ethErrors=t.errorCodes=void 0;const e=Ct;Object.defineProperty(t,"EthereumRpcError",{enumerable:!0,get:function(){return e.EthereumRpcError}}),Object.defineProperty(t,"EthereumProviderError",{enumerable:!0,get:function(){return e.EthereumProviderError}});const r=wi;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return r.getMessageFromCode}});const n=qn;Object.defineProperty(t,"ethErrors",{enumerable:!0,get:function(){return n.ethErrors}});const i=At;Object.defineProperty(t,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})})(yc);var j1=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Hr,"__esModule",{value:!0});Hr.JsonRpcEngine=void 0;const F1=j1(vi),st=yc;class _t extends F1.default{constructor(){super(),this._middleware=[]}push(e){this._middleware.push(e)}handle(e,r){if(r&&typeof r!="function")throw new Error('"callback" must be a function if provided.');return Array.isArray(e)?r?this._handleBatch(e,r):this._handleBatch(e):r?this._handle(e,r):this._promiseHandle(e)}asMiddleware(){return async(e,r,n,i)=>{try{const[s,c,u]=await _t._runAllMiddleware(e,r,this._middleware);return c?(await _t._runReturnHandlers(u),i(s)):n(async d=>{try{await _t._runReturnHandlers(u)}catch(h){return d(h)}return d()})}catch(s){return i(s)}}}async _handleBatch(e,r){try{const n=await Promise.all(e.map(this._promiseHandle.bind(this)));return r?r(null,n):n}catch(n){if(r)return r(n);throw n}}_promiseHandle(e){return new Promise(r=>{this._handle(e,(n,i)=>{r(i)})})}async _handle(e,r){if(!e||Array.isArray(e)||typeof e!="object"){const c=new st.EthereumRpcError(st.errorCodes.rpc.invalidRequest,`Requests must be plain objects. Received: ${typeof e}`,{request:e});return r(c,{id:void 0,jsonrpc:"2.0",error:c})}if(typeof e.method!="string"){const c=new st.EthereumRpcError(st.errorCodes.rpc.invalidRequest,`Must specify a string method. Received: ${typeof e.method}`,{request:e});return r(c,{id:e.id,jsonrpc:"2.0",error:c})}const n=Object.assign({},e),i={id:n.id,jsonrpc:n.jsonrpc};let s=null;try{await this._processRequest(n,i)}catch(c){s=c}return s&&(delete i.result,i.error||(i.error=st.serializeError(s))),r(s,i)}async _processRequest(e,r){const[n,i,s]=await _t._runAllMiddleware(e,r,this._middleware);if(_t._checkForCompletion(e,r,i),await _t._runReturnHandlers(s),n)throw n}static async _runAllMiddleware(e,r,n){const i=[];let s=null,c=!1;for(const u of n)if([s,c]=await _t._runMiddleware(e,r,u,i),c)break;return[s,c,i.reverse()]}static _runMiddleware(e,r,n,i){return new Promise(s=>{const c=d=>{const h=d||r.error;h&&(r.error=st.serializeError(h)),s([h,!0])},u=d=>{r.error?c(r.error):(d&&(typeof d!="function"&&c(new st.EthereumRpcError(st.errorCodes.rpc.internal,`JsonRpcEngine: "next" return handlers must be functions. Received "${typeof d}" for request: -${xs(e)}`,{request:e})),i.push(d)),s([null,!1]))};try{n(e,r,u,c)}catch(d){c(d)}})}static async _runReturnHandlers(e){for(const r of e)await new Promise((n,i)=>{r(s=>s?i(s):n())})}static _checkForCompletion(e,r,n){if(!("result"in r)&&!("error"in r))throw new st.EthereumRpcError(st.errorCodes.rpc.internal,`JsonRpcEngine: Response has no error or result for request: -${xs(e)}`,{request:e});if(!n)throw new st.EthereumRpcError(st.errorCodes.rpc.internal,`JsonRpcEngine: Nothing ended request: -${xs(e)}`,{request:e})}}Hr.JsonRpcEngine=_t;function xs(t){return JSON.stringify(t,null,2)}var Jn={};Object.defineProperty(Jn,"__esModule",{value:!0});Jn.mergeMiddleware=void 0;const H1=Hr;function U1(t){const e=new H1.JsonRpcEngine;return t.forEach(r=>e.push(r)),e.asMiddleware()}Jn.mergeMiddleware=U1;(function(t){var e=x&&x.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=x&&x.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Vn,t),r(Wn,t),r(zn,t),r(Fr,t),r(Hr,t),r(Jn,t)})(mi);var Ic={},bi={};const _i=Hs(Tc);var Gn={};Object.defineProperty(Gn,"__esModule",{value:!0});var Vo=_i,V1=function(){function t(e){if(this._maxConcurrency=e,this._queue=[],e<=0)throw new Error("semaphore must be initialized to a positive value");this._value=e}return t.prototype.acquire=function(){var e=this,r=this.isLocked(),n=new Promise(function(i){return e._queue.push(i)});return r||this._dispatch(),n},t.prototype.runExclusive=function(e){return Vo.__awaiter(this,void 0,void 0,function(){var r,n,i;return Vo.__generator(this,function(s){switch(s.label){case 0:return[4,this.acquire()];case 1:r=s.sent(),n=r[0],i=r[1],s.label=2;case 2:return s.trys.push([2,,4,5]),[4,e(n)];case 3:return[2,s.sent()];case 4:return i(),[7];case 5:return[2]}})})},t.prototype.isLocked=function(){return this._value<=0},t.prototype.release=function(){if(this._maxConcurrency>1)throw new Error("this method is unavailabel on semaphores with concurrency > 1; use the scoped release returned by acquire instead");if(this._currentReleaser){var e=this._currentReleaser;this._currentReleaser=void 0,e()}},t.prototype._dispatch=function(){var e=this,r=this._queue.shift();if(r){var n=!1;this._currentReleaser=function(){n||(n=!0,e._value++,e._dispatch())},r([this._value--,this._currentReleaser])}},t}();Gn.default=V1;Object.defineProperty(bi,"__esModule",{value:!0});var Wo=_i,W1=Gn,z1=function(){function t(){this._semaphore=new W1.default(1)}return t.prototype.acquire=function(){return Wo.__awaiter(this,void 0,void 0,function(){var e,r;return Wo.__generator(this,function(n){switch(n.label){case 0:return[4,this._semaphore.acquire()];case 1:return e=n.sent(),r=e[1],[2,r]}})})},t.prototype.runExclusive=function(e){return this._semaphore.runExclusive(function(){return e()})},t.prototype.isLocked=function(){return this._semaphore.isLocked()},t.prototype.release=function(){this._semaphore.release()},t}();bi.default=z1;var Zn={};Object.defineProperty(Zn,"__esModule",{value:!0});Zn.withTimeout=void 0;var en=_i;function q1(t,e,r){var n=this;return r===void 0&&(r=new Error("timeout")),{acquire:function(){return new Promise(function(i,s){return en.__awaiter(n,void 0,void 0,function(){var c,u,d;return en.__generator(this,function(h){switch(h.label){case 0:return c=!1,setTimeout(function(){c=!0,s(r)},e),[4,t.acquire()];case 1:return u=h.sent(),c?(d=Array.isArray(u)?u[1]:u,d()):i(u),[2]}})})})},runExclusive:function(i){return en.__awaiter(this,void 0,void 0,function(){var s,c;return en.__generator(this,function(u){switch(u.label){case 0:s=function(){},u.label=1;case 1:return u.trys.push([1,,7,8]),[4,this.acquire()];case 2:return c=u.sent(),Array.isArray(c)?(s=c[1],[4,i(c[0])]):[3,4];case 3:return[2,u.sent()];case 4:return s=c,[4,i()];case 5:return[2,u.sent()];case 6:return[3,8];case 7:return s(),[7];case 8:return[2]}})})},release:function(){t.release()},isLocked:function(){return t.isLocked()}}}Zn.withTimeout=q1;(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=t.Semaphore=t.Mutex=void 0;var e=bi;Object.defineProperty(t,"Mutex",{enumerable:!0,get:function(){return e.default}});var r=Gn;Object.defineProperty(t,"Semaphore",{enumerable:!0,get:function(){return r.default}});var n=Zn;Object.defineProperty(t,"withTimeout",{enumerable:!0,get:function(){return n.withTimeout}})})(Ic);var J1=Z1,G1=Object.prototype.hasOwnProperty;function Z1(){for(var t={},e=0;efunction(...i){const s=e.promiseModule;return new s((c,u)=>{e.multiArgs?i.push((...h)=>{e.errorFirst?h[0]?u(h):(h.shift(),c(h)):c(h)}):e.errorFirst?i.push((h,y)=>{h?u(h):c(y)}):i.push(c),Reflect.apply(t,this===r?n:this,i)})},qo=new WeakMap;var eg=(t,e)=>{e={exclude:[/.+(?:Sync|Stream)$/],errorFirst:!0,promiseModule:Promise,...e};const r=typeof t;if(!(t!==null&&(r==="object"||r==="function")))throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${t===null?"null":r}\``);const n=(c,u)=>{let d=qo.get(c);if(d||(d={},qo.set(c,d)),u in d)return d[u];const h=k=>typeof k=="string"||typeof u=="symbol"?u===k:k.test(u),y=Reflect.getOwnPropertyDescriptor(c,u),S=y===void 0||y.writable||y.configurable,M=(e.include?e.include.some(h):!e.exclude.some(h))&&S;return d[u]=M,M},i=new WeakMap,s=new Proxy(t,{apply(c,u,d){const h=i.get(c);if(h)return Reflect.apply(h,u,d);const y=e.excludeMain?c:zo(c,e,s,c);return i.set(c,y),Reflect.apply(y,u,d)},get(c,u){const d=c[u];if(!n(c,u)||d===Function.prototype[u])return d;const h=i.get(d);if(h)return h;if(typeof d=="function"){const y=zo(d,e,s,c);return i.set(d,y),y}return d}});return s};const tg=Pr.default;let rg=class extends tg{constructor(){super(),this.updates=[]}async initialize(){}async update(){throw new Error("BaseFilter - no update method specified")}addResults(e){this.updates=this.updates.concat(e),e.forEach(r=>this.emit("update",r))}addInitialResults(e){}getChangesAndClear(){const e=this.updates;return this.updates=[],e}};var Ei=rg;const ng=Ei;let sg=class extends ng{constructor(){super(),this.allResults=[]}async update(){throw new Error("BaseFilterWithHistory - no update method specified")}addResults(e){this.allResults=this.allResults.concat(e),super.addResults(e)}addInitialResults(e){this.allResults=this.allResults.concat(e),super.addInitialResults(e)}getAllResults(){return this.allResults}};var ig=sg,Vr={minBlockRef:og,maxBlockRef:ag,sortBlockRefs:Si,bnToHex:cg,blockRefIsNumber:lg,hexToInt:on,incrementHexInt:ug,intToHex:Cc,unsafeRandomBytes:dg};function og(...t){return Si(t)[0]}function ag(...t){const e=Si(t);return e[e.length-1]}function Si(t){return t.sort((e,r)=>e==="latest"||r==="earliest"?1:r==="latest"||e==="earliest"?-1:on(e)-on(r))}function cg(t){return"0x"+t.toString(16)}function lg(t){return t&&!["earliest","latest","pending"].includes(t)}function on(t){return t==null?t:Number.parseInt(t,16)}function ug(t){if(t==null)return t;const e=on(t);return Cc(e+1)}function Cc(t){if(t==null)return t;let e=t.toString(16);return e.length%2&&(e="0"+e),"0x"+e}function dg(t){let e="0x";for(let r=0;rn.toLowerCase()))}async initialize({currentBlock:e}){let r=this.params.fromBlock;["latest","pending"].includes(r)&&(r=e),r==="earliest"&&(r="0x0"),this.params.fromBlock=r;const n=mg(this.params.toBlock,e),i=Object.assign({},this.params,{toBlock:n}),s=await this._fetchLogs(i);this.addInitialResults(s)}async update({oldBlock:e,newBlock:r}){const n=r;let i;e?i=pg(e):i=r;const s=Object.assign({},this.params,{fromBlock:i,toBlock:n}),u=(await this._fetchLogs(s)).filter(d=>this.matchLog(d));this.addResults(u)}async _fetchLogs(e){return await fg(n=>this.ethQuery.getLogs(e,n))()}matchLog(e){if(tn(this.params.fromBlock)>=tn(e.blockNumber)||vg(this.params.toBlock)&&tn(this.params.toBlock)<=tn(e.blockNumber))return!1;const r=e.address&&e.address.toLowerCase();return this.params.address&&r&&!this.params.address.includes(r)?!1:this.params.topics.every((i,s)=>{let c=e.topics[s];if(!c)return!1;c=c.toLowerCase();let u=Array.isArray(i)?i:[i];return u.includes(null)?!0:(u=u.map(y=>y.toLowerCase()),u.includes(c))})}};var yg=wg,Mi=bg;async function bg({provider:t,fromBlock:e,toBlock:r}){e||(e=r);const n=Go(e),s=Go(r)-n+1,c=Array(s).fill().map((d,h)=>n+h).map(_g);let u=await Promise.all(c.map(d=>Sg(t,"eth_getBlockByNumber",[d,!1])));return u=u.filter(d=>d!==null),u}function Go(t){return t==null?t:Number.parseInt(t,16)}function _g(t){return t==null?t:"0x"+t.toString(16)}function Eg(t,e){return new Promise((r,n)=>{t.sendAsync(e,(i,s)=>{i?n(i):s.error?n(s.error):s.result?r(s.result):n(new Error("Result was empty"))})})}async function Sg(t,e,r){for(let n=0;n<3;n++)try{return await Eg(t,{id:1,jsonrpc:"2.0",method:e,params:r})}catch(i){console.error(`provider.sendAsync failed: ${i.stack||i.message||i}`)}return null}const Mg=Ei,kg=Mi,{incrementHexInt:Rg}=Vr;let Ig=class extends Mg{constructor({provider:e,params:r}){super(),this.type="block",this.provider=e}async update({oldBlock:e,newBlock:r}){const n=r,i=Rg(e),c=(await kg({provider:this.provider,fromBlock:i,toBlock:n})).map(u=>u.hash);this.addResults(c)}};var Cg=Ig;const Ag=Ei,Ng=Mi,{incrementHexInt:Lg}=Vr;let xg=class extends Ag{constructor({provider:e}){super(),this.type="tx",this.provider=e}async update({oldBlock:e}){const r=e,n=Lg(e),i=await Ng({provider:this.provider,fromBlock:n,toBlock:r}),s=[];for(const c of i)s.push(...c.transactions);this.addResults(s)}};var Tg=xg;const Pg=Ic.Mutex,{createAsyncMiddleware:$g,createScaffoldMiddleware:Og}=mi,Bg=yg,Dg=Cg,jg=Tg,{intToHex:Ac,hexToInt:Ts}=Vr;var Fg=Hg;function Hg({blockTracker:t,provider:e}){let r=0,n={};const i=new Pg,s=Ug({mutex:i}),c=Og({eth_newFilter:s(Ps(d)),eth_newBlockFilter:s(Ps(h)),eth_newPendingTransactionFilter:s(Ps(y)),eth_uninstallFilter:s(nn(M)),eth_getFilterChanges:s(nn(S)),eth_getFilterLogs:s(nn(E))}),u=async({oldBlock:L,newBlock:R})=>{if(n.length===0)return;const z=await i.acquire();try{await Promise.all(Zt(n).map(async C=>{try{await C.update({oldBlock:L,newBlock:R})}catch(P){console.error(P)}}))}catch(C){console.error(C)}z()};return c.newLogFilter=d,c.newBlockFilter=h,c.newPendingTransactionFilter=y,c.uninstallFilter=M,c.getFilterChanges=S,c.getFilterLogs=E,c.destroy=()=>{O()},c;async function d(L){const R=new Bg({provider:e,params:L});return await k(R),R}async function h(){const L=new Dg({provider:e});return await k(L),L}async function y(){const L=new jg({provider:e});return await k(L),L}async function S(L){const R=Ts(L),z=n[R];if(!z)throw new Error(`No filter for index "${R}"`);return z.getChangesAndClear()}async function E(L){const R=Ts(L),z=n[R];if(!z)throw new Error(`No filter for index "${R}"`);let C=[];return z.type==="log"&&(C=z.getAllResults()),C}async function M(L){const R=Ts(L),C=!!n[R];return C&&await T(R),C}async function k(L){const R=Zt(n).length,z=await t.getLatestBlock();await L.initialize({currentBlock:z}),r++,n[r]=L,L.id=r,L.idHex=Ac(r);const C=Zt(n).length;return B({prevFilterCount:R,newFilterCount:C}),r}async function T(L){const R=Zt(n).length;delete n[L];const z=Zt(n).length;B({prevFilterCount:R,newFilterCount:z})}async function O(){const L=Zt(n).length;n={},B({prevFilterCount:L,newFilterCount:0})}function B({prevFilterCount:L,newFilterCount:R}){if(L===0&&R>0){t.on("sync",u);return}if(L>0&&R===0){t.removeListener("sync",u);return}}}function Ps(t){return nn(async(...e)=>{const r=await t(...e);return Ac(r.id)})}function nn(t){return $g(async(e,r)=>{const n=await t.apply(null,e.params);r.result=n})}function Ug({mutex:t}){return e=>async(r,n,i,s)=>{(await t.acquire())(),e(r,n,i,s)}}function Zt(t,e){const r=[];for(let n in t)r.push(t[n]);return r}const Vg=Pr.default,{createAsyncMiddleware:Zo,createScaffoldMiddleware:Wg}=mi,zg=Fg,{unsafeRandomBytes:qg,incrementHexInt:Jg}=Vr,Gg=Mi;var Zg=Qg;function Qg({blockTracker:t,provider:e}){const r={},n=zg({blockTracker:t,provider:e});let i=!1;const s=new Vg,c=Wg({eth_subscribe:Zo(u),eth_unsubscribe:Zo(d)});return c.destroy=y,{events:s,middleware:c};async function u(S,E){if(i)throw new Error("SubscriptionManager - attempting to use after destroying");const M=S.params[0],k=qg(16);let T;switch(M){case"newHeads":T=O({subId:k});break;case"logs":const L=S.params[1],R=await n.newLogFilter(L);T=B({subId:k,filter:R});break;default:throw new Error(`SubscriptionManager - unsupported subscription type "${M}"`)}r[k]=T,E.result=k;return;function O({subId:L}){const R={type:M,destroy:async()=>{t.removeListener("sync",R.update)},update:async({oldBlock:z,newBlock:C})=>{const P=C,J=Jg(z);(await Gg({provider:e,fromBlock:J,toBlock:P})).map(Kg).filter(Y=>Y!==null).forEach(Y=>{h(L,Y)})}};return t.on("sync",R.update),R}function B({subId:L,filter:R}){return R.on("update",C=>h(L,C)),{type:M,destroy:async()=>await n.uninstallFilter(R.idHex)}}}async function d(S,E){if(i)throw new Error("SubscriptionManager - attempting to use after destroying");const M=S.params[0],k=r[M];if(!k){E.result=!1;return}delete r[M],await k.destroy(),E.result=!0}function h(S,E){s.emit("notification",{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:S,result:E}})}function y(){s.removeAllListeners();for(const S in r)r[S].destroy(),delete r[S];i=!0}}function Kg(t){return t==null?null:{hash:t.hash,parentHash:t.parentHash,sha3Uncles:t.sha3Uncles,miner:t.miner,stateRoot:t.stateRoot,transactionsRoot:t.transactionsRoot,receiptsRoot:t.receiptsRoot,logsBloom:t.logsBloom,difficulty:t.difficulty,number:t.number,gasLimit:t.gasLimit,gasUsed:t.gasUsed,nonce:t.nonce,mixHash:t.mixHash,timestamp:t.timestamp,extraData:t.extraData}}Object.defineProperty(xn,"__esModule",{value:!0});xn.SubscriptionManager=void 0;const Xg=$a,Yg=Zg,Qo=()=>{};class ep{constructor(e){const r=new Xg.PollingBlockTracker({provider:e,pollingInterval:15e3,setSkipCacheFlag:!0}),{events:n,middleware:i}=Yg({blockTracker:r,provider:e});this.events=n,this.subscriptionMiddleware=i}async handleRequest(e){const r={};return await this.subscriptionMiddleware(e,r,Qo,Qo),r}destroy(){this.subscriptionMiddleware.destroy()}}xn.SubscriptionManager=ep;var Nc=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(rr,"__esModule",{value:!0});rr.CoinbaseWalletProvider=void 0;const tp=Nc(un),rp=Dc,U=Sr,j=A,np=Ir,Ko=it,rn=dr,Ye=cr,$s=Nc(Du),wr=ur,sp=ir,ip=xn,Xo="DefaultChainId",Yo="DefaultJsonRpcUrl";class op extends rp.EventEmitter{constructor(e){var r,n;super(),this._filterPolyfill=new sp.FilterPolyfill(this),this._subscriptionManager=new ip.SubscriptionManager(this),this._relay=null,this._addresses=[],this.hasMadeFirstChainChangedEmission=!1,this.setProviderInfo=this.setProviderInfo.bind(this),this.updateProviderInfo=this.updateProviderInfo.bind(this),this.getChainId=this.getChainId.bind(this),this.setAppInfo=this.setAppInfo.bind(this),this.enable=this.enable.bind(this),this.close=this.close.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this),this.request=this.request.bind(this),this._setAddresses=this._setAddresses.bind(this),this.scanQRCode=this.scanQRCode.bind(this),this.genericRequest=this.genericRequest.bind(this),this._chainIdFromOpts=e.chainId,this._jsonRpcUrlFromOpts=e.jsonRpcUrl,this._overrideIsMetaMask=e.overrideIsMetaMask,this._relayProvider=e.relayProvider,this._storage=e.storage,this._relayEventManager=e.relayEventManager,this.diagnostic=e.diagnosticLogger,this.reloadOnDisconnect=!0,this.isCoinbaseWallet=(r=e.overrideIsCoinbaseWallet)!==null&&r!==void 0?r:!0,this.isCoinbaseBrowser=(n=e.overrideIsCoinbaseBrowser)!==null&&n!==void 0?n:!1,this.qrUrl=e.qrUrl;const i=this.getChainId(),s=(0,j.prepend0x)(i.toString(16));this.emit("connect",{chainIdStr:s});const c=this._storage.getItem(Ko.LOCAL_STORAGE_ADDRESSES_KEY);if(c){const u=c.split(" ");u[0]!==""&&(this._addresses=u.map(d=>(0,j.ensureAddressString)(d)),this.emit("accountsChanged",u))}this._subscriptionManager.events.on("notification",u=>{this.emit("message",{type:u.method,data:u.params})}),this._isAuthorized()&&this.initializeRelay(),window.addEventListener("message",u=>{var d;if(!(u.origin!==location.origin||u.source!==window)&&u.data.type==="walletLinkMessage"&&u.data.data.action==="dappChainSwitched"){const h=u.data.data.chainId,y=(d=u.data.data.jsonRpcUrl)!==null&&d!==void 0?d:this.jsonRpcUrl;this.updateProviderInfo(y,Number(h))}})}get selectedAddress(){return this._addresses[0]||void 0}get networkVersion(){return this.getChainId().toString(10)}get chainId(){return(0,j.prepend0x)(this.getChainId().toString(16))}get isWalletLink(){return!0}get isMetaMask(){return this._overrideIsMetaMask}get host(){return this.jsonRpcUrl}get connected(){return!0}isConnected(){return!0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(Yo))!==null&&e!==void 0?e:this._jsonRpcUrlFromOpts}set jsonRpcUrl(e){this._storage.setItem(Yo,e)}disableReloadOnDisconnect(){this.reloadOnDisconnect=!1}setProviderInfo(e,r){this.isCoinbaseBrowser||(this._chainIdFromOpts=r,this._jsonRpcUrlFromOpts=e),this.updateProviderInfo(this.jsonRpcUrl,this.getChainId())}updateProviderInfo(e,r){this.jsonRpcUrl=e;const n=this.getChainId();this._storage.setItem(Xo,r.toString(10)),((0,j.ensureIntNumber)(r)!==n||!this.hasMadeFirstChainChangedEmission)&&(this.emit("chainChanged",this.getChainId()),this.hasMadeFirstChainChangedEmission=!0)}async watchAsset(e,r,n,i,s,c){const d=await(await this.initializeRelay()).watchAsset(e,r,n,i,s,c==null?void 0:c.toString()).promise;return(0,Ye.isErrorResponse)(d)?!1:!!d.result}async addEthereumChain(e,r,n,i,s,c){var u,d;if((0,j.ensureIntNumber)(e)===this.getChainId())return!1;const h=await this.initializeRelay(),y=h.inlineAddEthereumChain(e.toString());!this._isAuthorized()&&!y&&await h.requestEthereumAccounts().promise;const S=await h.addEthereumChain(e.toString(),r,s,n,i,c).promise;return(0,Ye.isErrorResponse)(S)?!1:(((u=S.result)===null||u===void 0?void 0:u.isApproved)===!0&&this.updateProviderInfo(r[0],e),((d=S.result)===null||d===void 0?void 0:d.isApproved)===!0)}async switchEthereumChain(e){const n=await(await this.initializeRelay()).switchEthereumChain(e.toString(10),this.selectedAddress||void 0).promise;if((0,Ye.isErrorResponse)(n)){if(!n.errorCode)return;throw n.errorCode===U.standardErrorCodes.provider.unsupportedChain?U.standardErrors.provider.unsupportedChain():U.standardErrors.provider.custom({message:n.errorMessage,code:n.errorCode})}const i=n.result;i.isApproved&&i.rpcUrl.length>0&&this.updateProviderInfo(i.rpcUrl,e)}setAppInfo(e,r){this.initializeRelay().then(n=>n.setAppInfo(e,r))}async enable(){var e;return(e=this.diagnostic)===null||e===void 0||e.log(wr.EVENTS.ETH_ACCOUNTS_STATE,{method:"provider::enable",addresses_length:this._addresses.length,sessionIdHash:this._relay?rn.Session.hash(this._relay.session.id):void 0}),this._isAuthorized()?[...this._addresses]:await this.send("eth_requestAccounts")}async close(){(await this.initializeRelay()).resetAndReload()}send(e,r){try{const n=this._send(e,r);if(n instanceof Promise)return n.catch(i=>{throw(0,U.serializeError)(i,e)})}catch(n){throw(0,U.serializeError)(n,e)}}_send(e,r){if(typeof e=="string"){const i=e,s=Array.isArray(r)?r:r!==void 0?[r]:[],c={jsonrpc:"2.0",id:0,method:i,params:s};return this._sendRequestAsync(c).then(u=>u.result)}if(typeof r=="function"){const i=e,s=r;return this._sendAsync(i,s)}if(Array.isArray(e))return e.map(s=>this._sendRequest(s));const n=e;return this._sendRequest(n)}async sendAsync(e,r){try{return this._sendAsync(e,r).catch(n=>{throw(0,U.serializeError)(n,e)})}catch(n){return Promise.reject((0,U.serializeError)(n,e))}}async _sendAsync(e,r){if(typeof r!="function")throw new Error("callback is required");if(Array.isArray(e)){const i=r;this._sendMultipleRequestsAsync(e).then(s=>i(null,s)).catch(s=>i(s,null));return}const n=r;return this._sendRequestAsync(e).then(i=>n(null,i)).catch(i=>n(i,null))}async request(e){try{return this._request(e).catch(r=>{throw(0,U.serializeError)(r,e.method)})}catch(r){return Promise.reject((0,U.serializeError)(r,e.method))}}async _request(e){if(!e||typeof e!="object"||Array.isArray(e))throw U.standardErrors.rpc.invalidRequest({message:"Expected a single, non-array, object argument.",data:e});const{method:r,params:n}=e;if(typeof r!="string"||r.length===0)throw U.standardErrors.rpc.invalidRequest({message:"'args.method' must be a non-empty string.",data:e});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw U.standardErrors.rpc.invalidRequest({message:"'args.params' must be an object or array if provided.",data:e});const i=n===void 0?[]:n,s=this._relayEventManager.makeRequestId();return(await this._sendRequestAsync({method:r,params:i,jsonrpc:"2.0",id:s})).result}async scanQRCode(e){const n=await(await this.initializeRelay()).scanQRCode((0,j.ensureRegExpString)(e)).promise;if((0,Ye.isErrorResponse)(n))throw(0,U.serializeError)(n.errorMessage,"scanQRCode");if(typeof n.result!="string")throw(0,U.serializeError)("result was not a string","scanQRCode");return n.result}async genericRequest(e,r){const i=await(await this.initializeRelay()).genericRequest(e,r).promise;if((0,Ye.isErrorResponse)(i))throw(0,U.serializeError)(i.errorMessage,"generic");if(typeof i.result!="string")throw(0,U.serializeError)("result was not a string","generic");return i.result}async connectAndSignIn(e){var r;(r=this.diagnostic)===null||r===void 0||r.log(wr.EVENTS.ETH_ACCOUNTS_STATE,{method:"provider::connectAndSignIn",sessionIdHash:this._relay?rn.Session.hash(this._relay.session.id):void 0});let n;try{const s=await this.initializeRelay();if(!(s instanceof np.MobileRelay))throw new Error("connectAndSignIn is only supported on mobile");if(n=await s.connectAndSignIn(e).promise,(0,Ye.isErrorResponse)(n))throw new Error(n.errorMessage)}catch(s){throw typeof s.message=="string"&&s.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied account authorization"):s}if(!n.result)throw new Error("accounts received is empty");const{accounts:i}=n.result;return this._setAddresses(i),this.isCoinbaseBrowser||await this.switchEthereumChain(this.getChainId()),n.result}async selectProvider(e){const n=await(await this.initializeRelay()).selectProvider(e).promise;if((0,Ye.isErrorResponse)(n))throw(0,U.serializeError)(n.errorMessage,"selectProvider");if(typeof n.result!="string")throw(0,U.serializeError)("result was not a string","selectProvider");return n.result}supportsSubscriptions(){return!1}subscribe(){throw new Error("Subscriptions are not supported")}unsubscribe(){throw new Error("Subscriptions are not supported")}disconnect(){return!0}_sendRequest(e){const r={jsonrpc:"2.0",id:e.id},{method:n}=e;if(r.result=this._handleSynchronousMethods(e),r.result===void 0)throw new Error(`Coinbase Wallet does not support calling ${n} synchronously without a callback. Please provide a callback parameter to call ${n} asynchronously.`);return r}_setAddresses(e,r){if(!Array.isArray(e))throw new Error("addresses is not an array");const n=e.map(i=>(0,j.ensureAddressString)(i));JSON.stringify(n)!==JSON.stringify(this._addresses)&&(this._addresses=n,this.emit("accountsChanged",this._addresses),this._storage.setItem(Ko.LOCAL_STORAGE_ADDRESSES_KEY,n.join(" ")))}_sendRequestAsync(e){return new Promise((r,n)=>{try{const i=this._handleSynchronousMethods(e);if(i!==void 0)return r({jsonrpc:"2.0",id:e.id,result:i});const s=this._handleAsynchronousFilterMethods(e);if(s!==void 0){s.then(u=>r(Object.assign(Object.assign({},u),{id:e.id}))).catch(u=>n(u));return}const c=this._handleSubscriptionMethods(e);if(c!==void 0){c.then(u=>r({jsonrpc:"2.0",id:e.id,result:u.result})).catch(u=>n(u));return}}catch(i){return n(i)}this._handleAsynchronousMethods(e).then(i=>i&&r(Object.assign(Object.assign({},i),{id:e.id}))).catch(i=>n(i))})}_sendMultipleRequestsAsync(e){return Promise.all(e.map(r=>this._sendRequestAsync(r)))}_handleSynchronousMethods(e){const{method:r}=e,n=e.params||[];switch(r){case"eth_accounts":return this._eth_accounts();case"eth_coinbase":return this._eth_coinbase();case"eth_uninstallFilter":return this._eth_uninstallFilter(n);case"net_version":return this._net_version();case"eth_chainId":return this._eth_chainId();default:return}}async _handleAsynchronousMethods(e){const{method:r}=e,n=e.params||[];switch(r){case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_sign":return this._eth_sign(n);case"eth_ecRecover":return this._eth_ecRecover(n);case"personal_sign":return this._personal_sign(n);case"personal_ecRecover":return this._personal_ecRecover(n);case"eth_signTransaction":return this._eth_signTransaction(n);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(n);case"eth_sendTransaction":return this._eth_sendTransaction(n);case"eth_signTypedData_v1":return this._eth_signTypedData_v1(n);case"eth_signTypedData_v2":return this._throwUnsupportedMethodError();case"eth_signTypedData_v3":return this._eth_signTypedData_v3(n);case"eth_signTypedData_v4":case"eth_signTypedData":return this._eth_signTypedData_v4(n);case"cbWallet_arbitrary":return this._cbwallet_arbitrary(n);case"wallet_addEthereumChain":return this._wallet_addEthereumChain(n);case"wallet_switchEthereumChain":return this._wallet_switchEthereumChain(n);case"wallet_watchAsset":return this._wallet_watchAsset(n)}return(await this.initializeRelay()).makeEthereumJSONRPCRequest(e,this.jsonRpcUrl).catch(s=>{var c;throw(s.code===U.standardErrorCodes.rpc.methodNotFound||s.code===U.standardErrorCodes.rpc.methodNotSupported)&&((c=this.diagnostic)===null||c===void 0||c.log(wr.EVENTS.METHOD_NOT_IMPLEMENTED,{method:e.method,sessionIdHash:this._relay?rn.Session.hash(this._relay.session.id):void 0})),s})}_handleAsynchronousFilterMethods(e){const{method:r}=e,n=e.params||[];switch(r){case"eth_newFilter":return this._eth_newFilter(n);case"eth_newBlockFilter":return this._eth_newBlockFilter();case"eth_newPendingTransactionFilter":return this._eth_newPendingTransactionFilter();case"eth_getFilterChanges":return this._eth_getFilterChanges(n);case"eth_getFilterLogs":return this._eth_getFilterLogs(n)}}_handleSubscriptionMethods(e){switch(e.method){case"eth_subscribe":case"eth_unsubscribe":return this._subscriptionManager.handleRequest(e)}}_isKnownAddress(e){try{const r=(0,j.ensureAddressString)(e);return this._addresses.map(i=>(0,j.ensureAddressString)(i)).includes(r)}catch{}return!1}_ensureKnownAddress(e){var r;if(!this._isKnownAddress(e))throw(r=this.diagnostic)===null||r===void 0||r.log(wr.EVENTS.UNKNOWN_ADDRESS_ENCOUNTERED),new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const r=e.from?(0,j.ensureAddressString)(e.from):this.selectedAddress;if(!r)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(r);const n=e.to?(0,j.ensureAddressString)(e.to):null,i=e.value!=null?(0,j.ensureBN)(e.value):new tp.default(0),s=e.data?(0,j.ensureBuffer)(e.data):Buffer.alloc(0),c=e.nonce!=null?(0,j.ensureIntNumber)(e.nonce):null,u=e.gasPrice!=null?(0,j.ensureBN)(e.gasPrice):null,d=e.maxFeePerGas!=null?(0,j.ensureBN)(e.maxFeePerGas):null,h=e.maxPriorityFeePerGas!=null?(0,j.ensureBN)(e.maxPriorityFeePerGas):null,y=e.gas!=null?(0,j.ensureBN)(e.gas):null,S=e.chainId?(0,j.ensureIntNumber)(e.chainId):this.getChainId();return{fromAddress:r,toAddress:n,weiValue:i,data:s,nonce:c,gasPriceInWei:u,maxFeePerGas:d,maxPriorityFeePerGas:h,gasLimit:y,chainId:S}}_isAuthorized(){return this._addresses.length>0}_requireAuthorization(){if(!this._isAuthorized())throw U.standardErrors.provider.unauthorized({})}_throwUnsupportedMethodError(){throw U.standardErrors.provider.unsupportedMethod({})}async _signEthereumMessage(e,r,n,i){this._ensureKnownAddress(r);try{const c=await(await this.initializeRelay()).signEthereumMessage(e,r,n,i).promise;if((0,Ye.isErrorResponse)(c))throw new Error(c.errorMessage);return{jsonrpc:"2.0",id:0,result:c.result}}catch(s){throw typeof s.message=="string"&&s.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied message signature"):s}}async _ethereumAddressFromSignedMessage(e,r,n){const s=await(await this.initializeRelay()).ethereumAddressFromSignedMessage(e,r,n).promise;if((0,Ye.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}_eth_accounts(){return[...this._addresses]}_eth_coinbase(){return this.selectedAddress||null}_net_version(){return this.getChainId().toString(10)}_eth_chainId(){return(0,j.hexStringFromIntNumber)(this.getChainId())}getChainId(){const e=this._storage.getItem(Xo);if(!e)return(0,j.ensureIntNumber)(this._chainIdFromOpts);const r=parseInt(e,10);return(0,j.ensureIntNumber)(r)}async _eth_requestAccounts(){var e;if((e=this.diagnostic)===null||e===void 0||e.log(wr.EVENTS.ETH_ACCOUNTS_STATE,{method:"provider::_eth_requestAccounts",addresses_length:this._addresses.length,sessionIdHash:this._relay?rn.Session.hash(this._relay.session.id):void 0}),this._isAuthorized())return Promise.resolve({jsonrpc:"2.0",id:0,result:this._addresses});let r;try{if(r=await(await this.initializeRelay()).requestEthereumAccounts().promise,(0,Ye.isErrorResponse)(r))throw new Error(r.errorMessage)}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied account authorization"):n}if(!r.result)throw new Error("accounts received is empty");return this._setAddresses(r.result),this.isCoinbaseBrowser||await this.switchEthereumChain(this.getChainId()),{jsonrpc:"2.0",id:0,result:this._addresses}}_eth_sign(e){this._requireAuthorization();const r=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._signEthereumMessage(n,r,!1)}_eth_ecRecover(e){const r=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(r,n,!1)}_personal_sign(e){this._requireAuthorization();const r=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureAddressString)(e[1]);return this._signEthereumMessage(r,n,!0)}_personal_ecRecover(e){const r=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(r,n,!0)}async _eth_signTransaction(e){this._requireAuthorization();const r=this._prepareTransactionParams(e[0]||{});try{const i=await(await this.initializeRelay()).signEthereumTransaction(r).promise;if((0,Ye.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_sendRawTransaction(e){const r=(0,j.ensureBuffer)(e[0]),i=await(await this.initializeRelay()).submitEthereumTransaction(r,this.getChainId()).promise;if((0,Ye.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}async _eth_sendTransaction(e){this._requireAuthorization();const r=this._prepareTransactionParams(e[0]||{});try{const i=await(await this.initializeRelay()).signAndSubmitEthereumTransaction(r).promise;if((0,Ye.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_signTypedData_v1(e){this._requireAuthorization();const r=(0,j.ensureParsedJSONObject)(e[0]),n=(0,j.ensureAddressString)(e[1]);this._ensureKnownAddress(n);const i=$s.default.hashForSignTypedDataLegacy({data:r}),s=JSON.stringify(r,null,2);return this._signEthereumMessage(i,n,!1,s)}async _eth_signTypedData_v3(e){this._requireAuthorization();const r=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(r);const i=$s.default.hashForSignTypedData_v3({data:n}),s=JSON.stringify(n,null,2);return this._signEthereumMessage(i,r,!1,s)}async _eth_signTypedData_v4(e){this._requireAuthorization();const r=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(r);const i=$s.default.hashForSignTypedData_v4({data:n}),s=JSON.stringify(n,null,2);return this._signEthereumMessage(i,r,!1,s)}async _cbwallet_arbitrary(e){const r=e[0],n=e[1];if(typeof n!="string")throw new Error("parameter must be a string");if(typeof r!="object"||r===null)throw new Error("parameter must be an object");return{jsonrpc:"2.0",id:0,result:await this.genericRequest(r,n)}}async _wallet_addEthereumChain(e){var r,n,i,s;const c=e[0];if(((r=c.rpcUrls)===null||r===void 0?void 0:r.length)===0)return{jsonrpc:"2.0",id:0,error:{code:2,message:"please pass in at least 1 rpcUrl"}};if(!c.chainName||c.chainName.trim()==="")throw U.standardErrors.rpc.invalidParams("chainName is a required field");if(!c.nativeCurrency)throw U.standardErrors.rpc.invalidParams("nativeCurrency is a required field");const u=parseInt(c.chainId,16);return await this.addEthereumChain(u,(n=c.rpcUrls)!==null&&n!==void 0?n:[],(i=c.blockExplorerUrls)!==null&&i!==void 0?i:[],c.chainName,(s=c.iconUrls)!==null&&s!==void 0?s:[],c.nativeCurrency)?{jsonrpc:"2.0",id:0,result:null}:{jsonrpc:"2.0",id:0,error:{code:2,message:"unable to add ethereum chain"}}}async _wallet_switchEthereumChain(e){const r=e[0];return await this.switchEthereumChain(parseInt(r.chainId,16)),{jsonrpc:"2.0",id:0,result:null}}async _wallet_watchAsset(e){const r=Array.isArray(e)?e[0]:e;if(!r.type)throw U.standardErrors.rpc.invalidParams("Type is required");if((r==null?void 0:r.type)!=="ERC20")throw U.standardErrors.rpc.invalidParams(`Asset of type '${r.type}' is not supported`);if(!(r!=null&&r.options))throw U.standardErrors.rpc.invalidParams("Options are required");if(!(r!=null&&r.options.address))throw U.standardErrors.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:i,symbol:s,image:c,decimals:u}=r.options;return{jsonrpc:"2.0",id:0,result:await this.watchAsset(r.type,i,s,u,c,n)}}_eth_uninstallFilter(e){const r=(0,j.ensureHexString)(e[0]);return this._filterPolyfill.uninstallFilter(r)}async _eth_newFilter(e){const r=e[0];return{jsonrpc:"2.0",id:0,result:await this._filterPolyfill.newFilter(r)}}async _eth_newBlockFilter(){return{jsonrpc:"2.0",id:0,result:await this._filterPolyfill.newBlockFilter()}}async _eth_newPendingTransactionFilter(){return{jsonrpc:"2.0",id:0,result:await this._filterPolyfill.newPendingTransactionFilter()}}_eth_getFilterChanges(e){const r=(0,j.ensureHexString)(e[0]);return this._filterPolyfill.getFilterChanges(r)}_eth_getFilterLogs(e){const r=(0,j.ensureHexString)(e[0]);return this._filterPolyfill.getFilterLogs(r)}initializeRelay(){return this._relay?Promise.resolve(this._relay):this._relayProvider().then(e=>(e.setAccountsCallback((r,n)=>this._setAddresses(r,n)),e.setChainCallback((r,n)=>{this.updateProviderInfo(n,parseInt(r,10))}),e.setDappDefaultChainCallback(this._chainIdFromOpts),this._relay=e,e))}}rr.CoinbaseWalletProvider=op;var Qn={};Object.defineProperty(Qn,"__esModule",{value:!0});Qn.RelayEventManager=void 0;const ap=A;class cp{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,r=(0,ap.prepend0x)(e.toString(16));return this.callbacks.get(r)&&this.callbacks.delete(r),e}}Qn.RelayEventManager=cp;Object.defineProperty(br,"__esModule",{value:!0});br.CoinbaseWalletSDK=void 0;const lp=cn,up=ln,ea=A,dp=pn,hp=rr,fp=Ir,gp=xr,pp=Qn,mp=Ar,vp=Cr,Lc=lr;class Kn{constructor(e){var r,n,i;this._appName="",this._appLogoUrl=null,this._relay=null,this._relayEventManager=null;const s=e.linkAPIUrl||up.LINK_API_URL;typeof e.overrideIsMetaMask>"u"?this._overrideIsMetaMask=!1:this._overrideIsMetaMask=e.overrideIsMetaMask,this._overrideIsCoinbaseWallet=(r=e.overrideIsCoinbaseWallet)!==null&&r!==void 0?r:!0,this._overrideIsCoinbaseBrowser=(n=e.overrideIsCoinbaseBrowser)!==null&&n!==void 0?n:!1,this._diagnosticLogger=e.diagnosticLogger,this._reloadOnDisconnect=(i=e.reloadOnDisconnect)!==null&&i!==void 0?i:!0;const c=new URL(s),u=`${c.protocol}//${c.host}`;if(this._storage=new dp.ScopedLocalStorage(`-walletlink:${u}`),this._storage.setItem("version",Kn.VERSION),this.walletExtension||this.coinbaseBrowser)return;this._relayEventManager=new pp.RelayEventManager;const d=(0,ea.isMobileWeb)(),h=e.uiConstructor||(S=>d?new gp.MobileRelayUI(S):new mp.WalletLinkRelayUI(S)),y={linkAPIUrl:s,version:Lc.LIB_VERSION,darkMode:!!e.darkMode,headlessMode:!!e.headlessMode,uiConstructor:h,storage:this._storage,relayEventManager:this._relayEventManager,diagnosticLogger:this._diagnosticLogger,reloadOnDisconnect:this._reloadOnDisconnect,enableMobileWalletLink:e.enableMobileWalletLink};this._relay=d?new fp.MobileRelay(y):new vp.WalletLinkRelay(y),this.setAppInfo(e.appName,e.appLogoUrl),!e.headlessMode&&this._relay.attachUI()}makeWeb3Provider(e="",r=1){const n=this.walletExtension;if(n)return this.isCipherProvider(n)||n.setProviderInfo(e,r),this._reloadOnDisconnect===!1&&typeof n.disableReloadOnDisconnect=="function"&&n.disableReloadOnDisconnect(),n;const i=this.coinbaseBrowser;if(i)return i;const s=this._relay;if(!s||!this._relayEventManager||!this._storage)throw new Error("Relay not initialized, should never happen");return e||s.setConnectDisabled(!0),new hp.CoinbaseWalletProvider({relayProvider:()=>Promise.resolve(s),relayEventManager:this._relayEventManager,storage:this._storage,jsonRpcUrl:e,chainId:r,qrUrl:this.getQrUrl(),diagnosticLogger:this._diagnosticLogger,overrideIsMetaMask:this._overrideIsMetaMask,overrideIsCoinbaseWallet:this._overrideIsCoinbaseWallet,overrideIsCoinbaseBrowser:this._overrideIsCoinbaseBrowser})}setAppInfo(e,r){var n;this._appName=e||"DApp",this._appLogoUrl=r||(0,ea.getFavicon)();const i=this.walletExtension;i?this.isCipherProvider(i)||i.setAppInfo(this._appName,this._appLogoUrl):(n=this._relay)===null||n===void 0||n.setAppInfo(this._appName,this._appLogoUrl)}disconnect(){var e;const r=this===null||this===void 0?void 0:this.walletExtension;r?r.close():(e=this._relay)===null||e===void 0||e.resetAndReload()}getQrUrl(){var e,r;return(r=(e=this._relay)===null||e===void 0?void 0:e.getQRCodeUrl())!==null&&r!==void 0?r:null}getCoinbaseWalletLogo(e,r=240){return(0,lp.walletLogo)(e,r)}get walletExtension(){var e;return(e=window.coinbaseWalletExtension)!==null&&e!==void 0?e:window.walletLinkExtension}get coinbaseBrowser(){var e,r;try{const n=(e=window.ethereum)!==null&&e!==void 0?e:(r=window.top)===null||r===void 0?void 0:r.ethereum;return n&&"isCoinbaseBrowser"in n&&n.isCoinbaseBrowser?n:void 0}catch{return}}isCipherProvider(e){return typeof e.isCipher=="boolean"&&e.isCipher}}br.CoinbaseWalletSDK=Kn;Kn.VERSION=Lc.LIB_VERSION;(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.CoinbaseWalletProvider=t.CoinbaseWalletSDK=void 0;const e=br,r=rr;var n=br;Object.defineProperty(t,"CoinbaseWalletSDK",{enumerable:!0,get:function(){return n.CoinbaseWalletSDK}});var i=rr;Object.defineProperty(t,"CoinbaseWalletProvider",{enumerable:!0,get:function(){return i.CoinbaseWalletProvider}}),t.default=e.CoinbaseWalletSDK,typeof window<"u"&&(window.CoinbaseWalletSDK=e.CoinbaseWalletSDK,window.CoinbaseWalletProvider=r.CoinbaseWalletProvider,window.WalletLink=e.CoinbaseWalletSDK,window.WalletLinkProvider=r.CoinbaseWalletProvider)})(ra);const wp=Pc(ra),Tp=Object.freeze(Object.defineProperty({__proto__:null,default:wp},Symbol.toStringTag,{value:"Module"}));export{Tp as i}; +import{d as T,g as Hs,j as Tc,l as xc,h as Pc}from"./index-mI-wCQlz.js";import{r as $c}from"./inherits_browser-DVmoQh9i.js";import{s as Oc,r as Ke,a as an,j as Bc,b as Dc}from"./hooks.module-BoePljmY.js";import{e as ta}from"./events-_Z2_TJp5.js";var ra={},br={},cn={};Object.defineProperty(cn,"__esModule",{value:!0});cn.walletLogo=void 0;const jc=(t,e)=>{let r;switch(t){case"standard":return r=e,`data:image/svg+xml,%3Csvg width='${e}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return r=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${r}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return r=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return r=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return r=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return r=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return r=e,`data:image/svg+xml,%3Csvg width='${e}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};cn.walletLogo=jc;var ln={};Object.defineProperty(ln,"__esModule",{value:!0});ln.LINK_API_URL=void 0;ln.LINK_API_URL="https://www.walletlink.org";var A={},Us={exports:{}};Us.exports;(function(t){(function(e,r){function n(b,o){if(!b)throw new Error(o||"Assertion failed")}function i(b,o){b.super_=o;var l=function(){};l.prototype=o.prototype,b.prototype=new l,b.prototype.constructor=b}function s(b,o,l){if(s.isBN(b))return b;this.negative=0,this.words=null,this.length=0,this.red=null,b!==null&&((o==="le"||o==="be")&&(l=o,o=10),this._init(b||0,o||10,l||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var c;try{typeof window<"u"&&typeof window.Buffer<"u"?c=window.Buffer:c=$c.Buffer}catch{}s.isBN=function(o){return o instanceof s?!0:o!==null&&typeof o=="object"&&o.constructor.wordSize===s.wordSize&&Array.isArray(o.words)},s.max=function(o,l){return o.cmp(l)>0?o:l},s.min=function(o,l){return o.cmp(l)<0?o:l},s.prototype._init=function(o,l,f){if(typeof o=="number")return this._initNumber(o,l,f);if(typeof o=="object")return this._initArray(o,l,f);l==="hex"&&(l=16),n(l===(l|0)&&l>=2&&l<=36),o=o.toString().replace(/\s+/g,"");var g=0;o[0]==="-"&&(g++,this.negative=1),g=0;g-=3)w=o[g]|o[g-1]<<8|o[g-2]<<16,this.words[m]|=w<<_&67108863,this.words[m+1]=w>>>26-_&67108863,_+=24,_>=26&&(_-=26,m++);else if(f==="le")for(g=0,m=0;g>>26-_&67108863,_+=24,_>=26&&(_-=26,m++);return this._strip()};function u(b,o){var l=b.charCodeAt(o);if(l>=48&&l<=57)return l-48;if(l>=65&&l<=70)return l-55;if(l>=97&&l<=102)return l-87;n(!1,"Invalid character in "+b)}function d(b,o,l){var f=u(b,l);return l-1>=o&&(f|=u(b,l-1)<<4),f}s.prototype._parseHex=function(o,l,f){this.length=Math.ceil((o.length-l)/6),this.words=new Array(this.length);for(var g=0;g=l;g-=2)_=d(o,l,g)<=18?(m-=18,w+=1,this.words[w]|=_>>>26):m+=8;else{var p=o.length-l;for(g=p%2===0?l+1:l;g=18?(m-=18,w+=1,this.words[w]|=_>>>26):m+=8}this._strip()};function h(b,o,l,f){for(var g=0,m=0,w=Math.min(b.length,l),_=o;_=49?m=p-49+10:p>=17?m=p-17+10:m=p,n(p>=0&&m1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=S}catch{s.prototype.inspect=S}else s.prototype.inspect=S;function S(){return(this.red?""}var E=["","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"],M=[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],k=[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];s.prototype.toString=function(o,l){o=o||10,l=l|0||1;var f;if(o===16||o==="hex"){f="";for(var g=0,m=0,w=0;w>>24-g&16777215,g+=2,g>=26&&(g-=26,w--),m!==0||w!==this.length-1?f=E[6-p.length]+p+f:f=p+f}for(m!==0&&(f=m.toString(16)+f);f.length%l!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(o===(o|0)&&o>=2&&o<=36){var a=M[o],v=k[o];f="";var N=this.clone();for(N.negative=0;!N.isZero();){var I=N.modrn(v).toString(o);N=N.idivn(v),N.isZero()?f=I+f:f=E[a-I.length]+I+f}for(this.isZero()&&(f="0"+f);f.length%l!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var o=this.words[0];return this.length===2?o+=this.words[1]*67108864:this.length===3&&this.words[2]===1?o+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-o:o},s.prototype.toJSON=function(){return this.toString(16,2)},c&&(s.prototype.toBuffer=function(o,l){return this.toArrayLike(c,o,l)}),s.prototype.toArray=function(o,l){return this.toArrayLike(Array,o,l)};var x=function(o,l){return o.allocUnsafe?o.allocUnsafe(l):new o(l)};s.prototype.toArrayLike=function(o,l,f){this._strip();var g=this.byteLength(),m=f||Math.max(1,g);n(g<=m,"byte array longer than desired length"),n(m>0,"Requested array length <= 0");var w=x(o,m),_=l==="le"?"LE":"BE";return this["_toArrayLike"+_](w,g),w},s.prototype._toArrayLikeLE=function(o,l){for(var f=0,g=0,m=0,w=0;m>8&255),f>16&255),w===6?(f>24&255),g=0,w=0):(g=_>>>24,w+=2)}if(f=0&&(o[f--]=_>>8&255),f>=0&&(o[f--]=_>>16&255),w===6?(f>=0&&(o[f--]=_>>24&255),g=0,w=0):(g=_>>>24,w+=2)}if(f>=0)for(o[f--]=g;f>=0;)o[f--]=0},Math.clz32?s.prototype._countBits=function(o){return 32-Math.clz32(o)}:s.prototype._countBits=function(o){var l=o,f=0;return l>=4096&&(f+=13,l>>>=13),l>=64&&(f+=7,l>>>=7),l>=8&&(f+=4,l>>>=4),l>=2&&(f+=2,l>>>=2),f+l},s.prototype._zeroBits=function(o){if(o===0)return 26;var l=o,f=0;return l&8191||(f+=13,l>>>=13),l&127||(f+=7,l>>>=7),l&15||(f+=4,l>>>=4),l&3||(f+=2,l>>>=2),l&1||f++,f},s.prototype.bitLength=function(){var o=this.words[this.length-1],l=this._countBits(o);return(this.length-1)*26+l};function O(b){for(var o=new Array(b.bitLength()),l=0;l>>g&1}return o}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var o=0,l=0;lo.length?this.clone().ior(o):o.clone().ior(this)},s.prototype.uor=function(o){return this.length>o.length?this.clone().iuor(o):o.clone().iuor(this)},s.prototype.iuand=function(o){var l;this.length>o.length?l=o:l=this;for(var f=0;fo.length?this.clone().iand(o):o.clone().iand(this)},s.prototype.uand=function(o){return this.length>o.length?this.clone().iuand(o):o.clone().iuand(this)},s.prototype.iuxor=function(o){var l,f;this.length>o.length?(l=this,f=o):(l=o,f=this);for(var g=0;go.length?this.clone().ixor(o):o.clone().ixor(this)},s.prototype.uxor=function(o){return this.length>o.length?this.clone().iuxor(o):o.clone().iuxor(this)},s.prototype.inotn=function(o){n(typeof o=="number"&&o>=0);var l=Math.ceil(o/26)|0,f=o%26;this._expand(l),f>0&&l--;for(var g=0;g0&&(this.words[g]=~this.words[g]&67108863>>26-f),this._strip()},s.prototype.notn=function(o){return this.clone().inotn(o)},s.prototype.setn=function(o,l){n(typeof o=="number"&&o>=0);var f=o/26|0,g=o%26;return this._expand(f+1),l?this.words[f]=this.words[f]|1<o.length?(f=this,g=o):(f=o,g=this);for(var m=0,w=0;w>>26;for(;m!==0&&w>>26;if(this.length=f.length,m!==0)this.words[this.length]=m,this.length++;else if(f!==this)for(;wo.length?this.clone().iadd(o):o.clone().iadd(this)},s.prototype.isub=function(o){if(o.negative!==0){o.negative=0;var l=this.iadd(o);return o.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(o),this.negative=1,this._normSign();var f=this.cmp(o);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,m;f>0?(g=this,m=o):(g=o,m=this);for(var w=0,_=0;_>26,this.words[_]=l&67108863;for(;w!==0&&_>26,this.words[_]=l&67108863;if(w===0&&_>>26,N=p&67108863,I=Math.min(a,o.length-1),$=Math.max(0,a-b.length+1);$<=I;$++){var ze=a-$|0;g=b.words[ze]|0,m=o.words[$]|0,w=g*m+N,v+=w/67108864|0,N=w&67108863}l.words[a]=N|0,p=v|0}return p!==0?l.words[a]=p|0:l.length--,l._strip()}var L=function(o,l,f){var g=o.words,m=l.words,w=f.words,_=0,p,a,v,N=g[0]|0,I=N&8191,$=N>>>13,ze=g[1]|0,G=ze&8191,Z=ze>>>13,ki=g[2]|0,te=ki&8191,re=ki>>>13,Ri=g[3]|0,ne=Ri&8191,se=Ri>>>13,Ii=g[4]|0,ie=Ii&8191,oe=Ii>>>13,Ci=g[5]|0,ae=Ci&8191,ce=Ci>>>13,Ai=g[6]|0,le=Ai&8191,ue=Ai>>>13,Ni=g[7]|0,de=Ni&8191,he=Ni>>>13,Li=g[8]|0,fe=Li&8191,ge=Li>>>13,Ti=g[9]|0,pe=Ti&8191,me=Ti>>>13,xi=m[0]|0,ve=xi&8191,we=xi>>>13,Pi=m[1]|0,ye=Pi&8191,be=Pi>>>13,$i=m[2]|0,_e=$i&8191,Ee=$i>>>13,Oi=m[3]|0,Se=Oi&8191,Me=Oi>>>13,Bi=m[4]|0,ke=Bi&8191,Re=Bi>>>13,Di=m[5]|0,Ie=Di&8191,Ce=Di>>>13,ji=m[6]|0,Ae=ji&8191,Ne=ji>>>13,Fi=m[7]|0,Le=Fi&8191,Te=Fi>>>13,Hi=m[8]|0,xe=Hi&8191,Pe=Hi>>>13,Ui=m[9]|0,$e=Ui&8191,Oe=Ui>>>13;f.negative=o.negative^l.negative,f.length=19,p=Math.imul(I,ve),a=Math.imul(I,we),a=a+Math.imul($,ve)|0,v=Math.imul($,we);var Xn=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(Xn>>>26)|0,Xn&=67108863,p=Math.imul(G,ve),a=Math.imul(G,we),a=a+Math.imul(Z,ve)|0,v=Math.imul(Z,we),p=p+Math.imul(I,ye)|0,a=a+Math.imul(I,be)|0,a=a+Math.imul($,ye)|0,v=v+Math.imul($,be)|0;var Yn=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(Yn>>>26)|0,Yn&=67108863,p=Math.imul(te,ve),a=Math.imul(te,we),a=a+Math.imul(re,ve)|0,v=Math.imul(re,we),p=p+Math.imul(G,ye)|0,a=a+Math.imul(G,be)|0,a=a+Math.imul(Z,ye)|0,v=v+Math.imul(Z,be)|0,p=p+Math.imul(I,_e)|0,a=a+Math.imul(I,Ee)|0,a=a+Math.imul($,_e)|0,v=v+Math.imul($,Ee)|0;var es=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(es>>>26)|0,es&=67108863,p=Math.imul(ne,ve),a=Math.imul(ne,we),a=a+Math.imul(se,ve)|0,v=Math.imul(se,we),p=p+Math.imul(te,ye)|0,a=a+Math.imul(te,be)|0,a=a+Math.imul(re,ye)|0,v=v+Math.imul(re,be)|0,p=p+Math.imul(G,_e)|0,a=a+Math.imul(G,Ee)|0,a=a+Math.imul(Z,_e)|0,v=v+Math.imul(Z,Ee)|0,p=p+Math.imul(I,Se)|0,a=a+Math.imul(I,Me)|0,a=a+Math.imul($,Se)|0,v=v+Math.imul($,Me)|0;var ts=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ts>>>26)|0,ts&=67108863,p=Math.imul(ie,ve),a=Math.imul(ie,we),a=a+Math.imul(oe,ve)|0,v=Math.imul(oe,we),p=p+Math.imul(ne,ye)|0,a=a+Math.imul(ne,be)|0,a=a+Math.imul(se,ye)|0,v=v+Math.imul(se,be)|0,p=p+Math.imul(te,_e)|0,a=a+Math.imul(te,Ee)|0,a=a+Math.imul(re,_e)|0,v=v+Math.imul(re,Ee)|0,p=p+Math.imul(G,Se)|0,a=a+Math.imul(G,Me)|0,a=a+Math.imul(Z,Se)|0,v=v+Math.imul(Z,Me)|0,p=p+Math.imul(I,ke)|0,a=a+Math.imul(I,Re)|0,a=a+Math.imul($,ke)|0,v=v+Math.imul($,Re)|0;var rs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(rs>>>26)|0,rs&=67108863,p=Math.imul(ae,ve),a=Math.imul(ae,we),a=a+Math.imul(ce,ve)|0,v=Math.imul(ce,we),p=p+Math.imul(ie,ye)|0,a=a+Math.imul(ie,be)|0,a=a+Math.imul(oe,ye)|0,v=v+Math.imul(oe,be)|0,p=p+Math.imul(ne,_e)|0,a=a+Math.imul(ne,Ee)|0,a=a+Math.imul(se,_e)|0,v=v+Math.imul(se,Ee)|0,p=p+Math.imul(te,Se)|0,a=a+Math.imul(te,Me)|0,a=a+Math.imul(re,Se)|0,v=v+Math.imul(re,Me)|0,p=p+Math.imul(G,ke)|0,a=a+Math.imul(G,Re)|0,a=a+Math.imul(Z,ke)|0,v=v+Math.imul(Z,Re)|0,p=p+Math.imul(I,Ie)|0,a=a+Math.imul(I,Ce)|0,a=a+Math.imul($,Ie)|0,v=v+Math.imul($,Ce)|0;var ns=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ns>>>26)|0,ns&=67108863,p=Math.imul(le,ve),a=Math.imul(le,we),a=a+Math.imul(ue,ve)|0,v=Math.imul(ue,we),p=p+Math.imul(ae,ye)|0,a=a+Math.imul(ae,be)|0,a=a+Math.imul(ce,ye)|0,v=v+Math.imul(ce,be)|0,p=p+Math.imul(ie,_e)|0,a=a+Math.imul(ie,Ee)|0,a=a+Math.imul(oe,_e)|0,v=v+Math.imul(oe,Ee)|0,p=p+Math.imul(ne,Se)|0,a=a+Math.imul(ne,Me)|0,a=a+Math.imul(se,Se)|0,v=v+Math.imul(se,Me)|0,p=p+Math.imul(te,ke)|0,a=a+Math.imul(te,Re)|0,a=a+Math.imul(re,ke)|0,v=v+Math.imul(re,Re)|0,p=p+Math.imul(G,Ie)|0,a=a+Math.imul(G,Ce)|0,a=a+Math.imul(Z,Ie)|0,v=v+Math.imul(Z,Ce)|0,p=p+Math.imul(I,Ae)|0,a=a+Math.imul(I,Ne)|0,a=a+Math.imul($,Ae)|0,v=v+Math.imul($,Ne)|0;var ss=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ss>>>26)|0,ss&=67108863,p=Math.imul(de,ve),a=Math.imul(de,we),a=a+Math.imul(he,ve)|0,v=Math.imul(he,we),p=p+Math.imul(le,ye)|0,a=a+Math.imul(le,be)|0,a=a+Math.imul(ue,ye)|0,v=v+Math.imul(ue,be)|0,p=p+Math.imul(ae,_e)|0,a=a+Math.imul(ae,Ee)|0,a=a+Math.imul(ce,_e)|0,v=v+Math.imul(ce,Ee)|0,p=p+Math.imul(ie,Se)|0,a=a+Math.imul(ie,Me)|0,a=a+Math.imul(oe,Se)|0,v=v+Math.imul(oe,Me)|0,p=p+Math.imul(ne,ke)|0,a=a+Math.imul(ne,Re)|0,a=a+Math.imul(se,ke)|0,v=v+Math.imul(se,Re)|0,p=p+Math.imul(te,Ie)|0,a=a+Math.imul(te,Ce)|0,a=a+Math.imul(re,Ie)|0,v=v+Math.imul(re,Ce)|0,p=p+Math.imul(G,Ae)|0,a=a+Math.imul(G,Ne)|0,a=a+Math.imul(Z,Ae)|0,v=v+Math.imul(Z,Ne)|0,p=p+Math.imul(I,Le)|0,a=a+Math.imul(I,Te)|0,a=a+Math.imul($,Le)|0,v=v+Math.imul($,Te)|0;var is=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(is>>>26)|0,is&=67108863,p=Math.imul(fe,ve),a=Math.imul(fe,we),a=a+Math.imul(ge,ve)|0,v=Math.imul(ge,we),p=p+Math.imul(de,ye)|0,a=a+Math.imul(de,be)|0,a=a+Math.imul(he,ye)|0,v=v+Math.imul(he,be)|0,p=p+Math.imul(le,_e)|0,a=a+Math.imul(le,Ee)|0,a=a+Math.imul(ue,_e)|0,v=v+Math.imul(ue,Ee)|0,p=p+Math.imul(ae,Se)|0,a=a+Math.imul(ae,Me)|0,a=a+Math.imul(ce,Se)|0,v=v+Math.imul(ce,Me)|0,p=p+Math.imul(ie,ke)|0,a=a+Math.imul(ie,Re)|0,a=a+Math.imul(oe,ke)|0,v=v+Math.imul(oe,Re)|0,p=p+Math.imul(ne,Ie)|0,a=a+Math.imul(ne,Ce)|0,a=a+Math.imul(se,Ie)|0,v=v+Math.imul(se,Ce)|0,p=p+Math.imul(te,Ae)|0,a=a+Math.imul(te,Ne)|0,a=a+Math.imul(re,Ae)|0,v=v+Math.imul(re,Ne)|0,p=p+Math.imul(G,Le)|0,a=a+Math.imul(G,Te)|0,a=a+Math.imul(Z,Le)|0,v=v+Math.imul(Z,Te)|0,p=p+Math.imul(I,xe)|0,a=a+Math.imul(I,Pe)|0,a=a+Math.imul($,xe)|0,v=v+Math.imul($,Pe)|0;var os=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(os>>>26)|0,os&=67108863,p=Math.imul(pe,ve),a=Math.imul(pe,we),a=a+Math.imul(me,ve)|0,v=Math.imul(me,we),p=p+Math.imul(fe,ye)|0,a=a+Math.imul(fe,be)|0,a=a+Math.imul(ge,ye)|0,v=v+Math.imul(ge,be)|0,p=p+Math.imul(de,_e)|0,a=a+Math.imul(de,Ee)|0,a=a+Math.imul(he,_e)|0,v=v+Math.imul(he,Ee)|0,p=p+Math.imul(le,Se)|0,a=a+Math.imul(le,Me)|0,a=a+Math.imul(ue,Se)|0,v=v+Math.imul(ue,Me)|0,p=p+Math.imul(ae,ke)|0,a=a+Math.imul(ae,Re)|0,a=a+Math.imul(ce,ke)|0,v=v+Math.imul(ce,Re)|0,p=p+Math.imul(ie,Ie)|0,a=a+Math.imul(ie,Ce)|0,a=a+Math.imul(oe,Ie)|0,v=v+Math.imul(oe,Ce)|0,p=p+Math.imul(ne,Ae)|0,a=a+Math.imul(ne,Ne)|0,a=a+Math.imul(se,Ae)|0,v=v+Math.imul(se,Ne)|0,p=p+Math.imul(te,Le)|0,a=a+Math.imul(te,Te)|0,a=a+Math.imul(re,Le)|0,v=v+Math.imul(re,Te)|0,p=p+Math.imul(G,xe)|0,a=a+Math.imul(G,Pe)|0,a=a+Math.imul(Z,xe)|0,v=v+Math.imul(Z,Pe)|0,p=p+Math.imul(I,$e)|0,a=a+Math.imul(I,Oe)|0,a=a+Math.imul($,$e)|0,v=v+Math.imul($,Oe)|0;var as=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(as>>>26)|0,as&=67108863,p=Math.imul(pe,ye),a=Math.imul(pe,be),a=a+Math.imul(me,ye)|0,v=Math.imul(me,be),p=p+Math.imul(fe,_e)|0,a=a+Math.imul(fe,Ee)|0,a=a+Math.imul(ge,_e)|0,v=v+Math.imul(ge,Ee)|0,p=p+Math.imul(de,Se)|0,a=a+Math.imul(de,Me)|0,a=a+Math.imul(he,Se)|0,v=v+Math.imul(he,Me)|0,p=p+Math.imul(le,ke)|0,a=a+Math.imul(le,Re)|0,a=a+Math.imul(ue,ke)|0,v=v+Math.imul(ue,Re)|0,p=p+Math.imul(ae,Ie)|0,a=a+Math.imul(ae,Ce)|0,a=a+Math.imul(ce,Ie)|0,v=v+Math.imul(ce,Ce)|0,p=p+Math.imul(ie,Ae)|0,a=a+Math.imul(ie,Ne)|0,a=a+Math.imul(oe,Ae)|0,v=v+Math.imul(oe,Ne)|0,p=p+Math.imul(ne,Le)|0,a=a+Math.imul(ne,Te)|0,a=a+Math.imul(se,Le)|0,v=v+Math.imul(se,Te)|0,p=p+Math.imul(te,xe)|0,a=a+Math.imul(te,Pe)|0,a=a+Math.imul(re,xe)|0,v=v+Math.imul(re,Pe)|0,p=p+Math.imul(G,$e)|0,a=a+Math.imul(G,Oe)|0,a=a+Math.imul(Z,$e)|0,v=v+Math.imul(Z,Oe)|0;var cs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(cs>>>26)|0,cs&=67108863,p=Math.imul(pe,_e),a=Math.imul(pe,Ee),a=a+Math.imul(me,_e)|0,v=Math.imul(me,Ee),p=p+Math.imul(fe,Se)|0,a=a+Math.imul(fe,Me)|0,a=a+Math.imul(ge,Se)|0,v=v+Math.imul(ge,Me)|0,p=p+Math.imul(de,ke)|0,a=a+Math.imul(de,Re)|0,a=a+Math.imul(he,ke)|0,v=v+Math.imul(he,Re)|0,p=p+Math.imul(le,Ie)|0,a=a+Math.imul(le,Ce)|0,a=a+Math.imul(ue,Ie)|0,v=v+Math.imul(ue,Ce)|0,p=p+Math.imul(ae,Ae)|0,a=a+Math.imul(ae,Ne)|0,a=a+Math.imul(ce,Ae)|0,v=v+Math.imul(ce,Ne)|0,p=p+Math.imul(ie,Le)|0,a=a+Math.imul(ie,Te)|0,a=a+Math.imul(oe,Le)|0,v=v+Math.imul(oe,Te)|0,p=p+Math.imul(ne,xe)|0,a=a+Math.imul(ne,Pe)|0,a=a+Math.imul(se,xe)|0,v=v+Math.imul(se,Pe)|0,p=p+Math.imul(te,$e)|0,a=a+Math.imul(te,Oe)|0,a=a+Math.imul(re,$e)|0,v=v+Math.imul(re,Oe)|0;var ls=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ls>>>26)|0,ls&=67108863,p=Math.imul(pe,Se),a=Math.imul(pe,Me),a=a+Math.imul(me,Se)|0,v=Math.imul(me,Me),p=p+Math.imul(fe,ke)|0,a=a+Math.imul(fe,Re)|0,a=a+Math.imul(ge,ke)|0,v=v+Math.imul(ge,Re)|0,p=p+Math.imul(de,Ie)|0,a=a+Math.imul(de,Ce)|0,a=a+Math.imul(he,Ie)|0,v=v+Math.imul(he,Ce)|0,p=p+Math.imul(le,Ae)|0,a=a+Math.imul(le,Ne)|0,a=a+Math.imul(ue,Ae)|0,v=v+Math.imul(ue,Ne)|0,p=p+Math.imul(ae,Le)|0,a=a+Math.imul(ae,Te)|0,a=a+Math.imul(ce,Le)|0,v=v+Math.imul(ce,Te)|0,p=p+Math.imul(ie,xe)|0,a=a+Math.imul(ie,Pe)|0,a=a+Math.imul(oe,xe)|0,v=v+Math.imul(oe,Pe)|0,p=p+Math.imul(ne,$e)|0,a=a+Math.imul(ne,Oe)|0,a=a+Math.imul(se,$e)|0,v=v+Math.imul(se,Oe)|0;var us=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(us>>>26)|0,us&=67108863,p=Math.imul(pe,ke),a=Math.imul(pe,Re),a=a+Math.imul(me,ke)|0,v=Math.imul(me,Re),p=p+Math.imul(fe,Ie)|0,a=a+Math.imul(fe,Ce)|0,a=a+Math.imul(ge,Ie)|0,v=v+Math.imul(ge,Ce)|0,p=p+Math.imul(de,Ae)|0,a=a+Math.imul(de,Ne)|0,a=a+Math.imul(he,Ae)|0,v=v+Math.imul(he,Ne)|0,p=p+Math.imul(le,Le)|0,a=a+Math.imul(le,Te)|0,a=a+Math.imul(ue,Le)|0,v=v+Math.imul(ue,Te)|0,p=p+Math.imul(ae,xe)|0,a=a+Math.imul(ae,Pe)|0,a=a+Math.imul(ce,xe)|0,v=v+Math.imul(ce,Pe)|0,p=p+Math.imul(ie,$e)|0,a=a+Math.imul(ie,Oe)|0,a=a+Math.imul(oe,$e)|0,v=v+Math.imul(oe,Oe)|0;var ds=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ds>>>26)|0,ds&=67108863,p=Math.imul(pe,Ie),a=Math.imul(pe,Ce),a=a+Math.imul(me,Ie)|0,v=Math.imul(me,Ce),p=p+Math.imul(fe,Ae)|0,a=a+Math.imul(fe,Ne)|0,a=a+Math.imul(ge,Ae)|0,v=v+Math.imul(ge,Ne)|0,p=p+Math.imul(de,Le)|0,a=a+Math.imul(de,Te)|0,a=a+Math.imul(he,Le)|0,v=v+Math.imul(he,Te)|0,p=p+Math.imul(le,xe)|0,a=a+Math.imul(le,Pe)|0,a=a+Math.imul(ue,xe)|0,v=v+Math.imul(ue,Pe)|0,p=p+Math.imul(ae,$e)|0,a=a+Math.imul(ae,Oe)|0,a=a+Math.imul(ce,$e)|0,v=v+Math.imul(ce,Oe)|0;var hs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(hs>>>26)|0,hs&=67108863,p=Math.imul(pe,Ae),a=Math.imul(pe,Ne),a=a+Math.imul(me,Ae)|0,v=Math.imul(me,Ne),p=p+Math.imul(fe,Le)|0,a=a+Math.imul(fe,Te)|0,a=a+Math.imul(ge,Le)|0,v=v+Math.imul(ge,Te)|0,p=p+Math.imul(de,xe)|0,a=a+Math.imul(de,Pe)|0,a=a+Math.imul(he,xe)|0,v=v+Math.imul(he,Pe)|0,p=p+Math.imul(le,$e)|0,a=a+Math.imul(le,Oe)|0,a=a+Math.imul(ue,$e)|0,v=v+Math.imul(ue,Oe)|0;var fs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(fs>>>26)|0,fs&=67108863,p=Math.imul(pe,Le),a=Math.imul(pe,Te),a=a+Math.imul(me,Le)|0,v=Math.imul(me,Te),p=p+Math.imul(fe,xe)|0,a=a+Math.imul(fe,Pe)|0,a=a+Math.imul(ge,xe)|0,v=v+Math.imul(ge,Pe)|0,p=p+Math.imul(de,$e)|0,a=a+Math.imul(de,Oe)|0,a=a+Math.imul(he,$e)|0,v=v+Math.imul(he,Oe)|0;var gs=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(gs>>>26)|0,gs&=67108863,p=Math.imul(pe,xe),a=Math.imul(pe,Pe),a=a+Math.imul(me,xe)|0,v=Math.imul(me,Pe),p=p+Math.imul(fe,$e)|0,a=a+Math.imul(fe,Oe)|0,a=a+Math.imul(ge,$e)|0,v=v+Math.imul(ge,Oe)|0;var ps=(_+p|0)+((a&8191)<<13)|0;_=(v+(a>>>13)|0)+(ps>>>26)|0,ps&=67108863,p=Math.imul(pe,$e),a=Math.imul(pe,Oe),a=a+Math.imul(me,$e)|0,v=Math.imul(me,Oe);var ms=(_+p|0)+((a&8191)<<13)|0;return _=(v+(a>>>13)|0)+(ms>>>26)|0,ms&=67108863,w[0]=Xn,w[1]=Yn,w[2]=es,w[3]=ts,w[4]=rs,w[5]=ns,w[6]=ss,w[7]=is,w[8]=os,w[9]=as,w[10]=cs,w[11]=ls,w[12]=us,w[13]=ds,w[14]=hs,w[15]=fs,w[16]=gs,w[17]=ps,w[18]=ms,_!==0&&(w[19]=_,f.length++),f};Math.imul||(L=B);function R(b,o,l){l.negative=o.negative^b.negative,l.length=b.length+o.length;for(var f=0,g=0,m=0;m>>26)|0,g+=w>>>26,w&=67108863}l.words[m]=_,f=w,w=g}return f!==0?l.words[m]=f:l.length--,l._strip()}function z(b,o,l){return R(b,o,l)}s.prototype.mulTo=function(o,l){var f,g=this.length+o.length;return this.length===10&&o.length===10?f=L(this,o,l):g<63?f=B(this,o,l):g<1024?f=R(this,o,l):f=z(this,o,l),f},s.prototype.mul=function(o){var l=new s(null);return l.words=new Array(this.length+o.length),this.mulTo(o,l)},s.prototype.mulf=function(o){var l=new s(null);return l.words=new Array(this.length+o.length),z(this,o,l)},s.prototype.imul=function(o){return this.clone().mulTo(o,this)},s.prototype.imuln=function(o){var l=o<0;l&&(o=-o),n(typeof o=="number"),n(o<67108864);for(var f=0,g=0;g>=26,f+=m/67108864|0,f+=w>>>26,this.words[g]=w&67108863}return f!==0&&(this.words[g]=f,this.length++),l?this.ineg():this},s.prototype.muln=function(o){return this.clone().imuln(o)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(o){var l=O(o);if(l.length===0)return new s(1);for(var f=this,g=0;g=0);var l=o%26,f=(o-l)/26,g=67108863>>>26-l<<26-l,m;if(l!==0){var w=0;for(m=0;m>>26-l}w&&(this.words[m]=w,this.length++)}if(f!==0){for(m=this.length-1;m>=0;m--)this.words[m+f]=this.words[m];for(m=0;m=0);var g;l?g=(l-l%26)/26:g=0;var m=o%26,w=Math.min((o-m)/26,this.length),_=67108863^67108863>>>m<w)for(this.length-=w,a=0;a=0&&(v!==0||a>=g);a--){var N=this.words[a]|0;this.words[a]=v<<26-m|N>>>m,v=N&_}return p&&v!==0&&(p.words[p.length++]=v),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(o,l,f){return n(this.negative===0),this.iushrn(o,l,f)},s.prototype.shln=function(o){return this.clone().ishln(o)},s.prototype.ushln=function(o){return this.clone().iushln(o)},s.prototype.shrn=function(o){return this.clone().ishrn(o)},s.prototype.ushrn=function(o){return this.clone().iushrn(o)},s.prototype.testn=function(o){n(typeof o=="number"&&o>=0);var l=o%26,f=(o-l)/26,g=1<=0);var l=o%26,f=(o-l)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(l!==0&&f++,this.length=Math.min(f,this.length),l!==0){var g=67108863^67108863>>>l<=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},s.prototype.isubn=function(o){if(n(typeof o=="number"),n(o<67108864),o<0)return this.iaddn(-o);if(this.negative!==0)return this.negative=0,this.iaddn(o),this.negative=1,this;if(this.words[0]-=o,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var l=0;l>26)-(p/67108864|0),this.words[m+f]=w&67108863}for(;m>26,this.words[m+f]=w&67108863;if(_===0)return this._strip();for(n(_===-1),_=0,m=0;m>26,this.words[m]=w&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(o,l){var f=this.length-o.length,g=this.clone(),m=o,w=m.words[m.length-1]|0,_=this._countBits(w);f=26-_,f!==0&&(m=m.ushln(f),g.iushln(f),w=m.words[m.length-1]|0);var p=g.length-m.length,a;if(l!=="mod"){a=new s(null),a.length=p+1,a.words=new Array(a.length);for(var v=0;v=0;I--){var $=(g.words[m.length+I]|0)*67108864+(g.words[m.length+I-1]|0);for($=Math.min($/w|0,67108863),g._ishlnsubmul(m,$,I);g.negative!==0;)$--,g.negative=0,g._ishlnsubmul(m,1,I),g.isZero()||(g.negative^=1);a&&(a.words[I]=$)}return a&&a._strip(),g._strip(),l!=="div"&&f!==0&&g.iushrn(f),{div:a||null,mod:g}},s.prototype.divmod=function(o,l,f){if(n(!o.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var g,m,w;return this.negative!==0&&o.negative===0?(w=this.neg().divmod(o,l),l!=="mod"&&(g=w.div.neg()),l!=="div"&&(m=w.mod.neg(),f&&m.negative!==0&&m.iadd(o)),{div:g,mod:m}):this.negative===0&&o.negative!==0?(w=this.divmod(o.neg(),l),l!=="mod"&&(g=w.div.neg()),{div:g,mod:w.mod}):this.negative&o.negative?(w=this.neg().divmod(o.neg(),l),l!=="div"&&(m=w.mod.neg(),f&&m.negative!==0&&m.isub(o)),{div:w.div,mod:m}):o.length>this.length||this.cmp(o)<0?{div:new s(0),mod:this}:o.length===1?l==="div"?{div:this.divn(o.words[0]),mod:null}:l==="mod"?{div:null,mod:new s(this.modrn(o.words[0]))}:{div:this.divn(o.words[0]),mod:new s(this.modrn(o.words[0]))}:this._wordDiv(o,l)},s.prototype.div=function(o){return this.divmod(o,"div",!1).div},s.prototype.mod=function(o){return this.divmod(o,"mod",!1).mod},s.prototype.umod=function(o){return this.divmod(o,"mod",!0).mod},s.prototype.divRound=function(o){var l=this.divmod(o);if(l.mod.isZero())return l.div;var f=l.div.negative!==0?l.mod.isub(o):l.mod,g=o.ushrn(1),m=o.andln(1),w=f.cmp(g);return w<0||m===1&&w===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},s.prototype.modrn=function(o){var l=o<0;l&&(o=-o),n(o<=67108863);for(var f=(1<<26)%o,g=0,m=this.length-1;m>=0;m--)g=(f*g+(this.words[m]|0))%o;return l?-g:g},s.prototype.modn=function(o){return this.modrn(o)},s.prototype.idivn=function(o){var l=o<0;l&&(o=-o),n(o<=67108863);for(var f=0,g=this.length-1;g>=0;g--){var m=(this.words[g]|0)+f*67108864;this.words[g]=m/o|0,f=m%o}return this._strip(),l?this.ineg():this},s.prototype.divn=function(o){return this.clone().idivn(o)},s.prototype.egcd=function(o){n(o.negative===0),n(!o.isZero());var l=this,f=o.clone();l.negative!==0?l=l.umod(o):l=l.clone();for(var g=new s(1),m=new s(0),w=new s(0),_=new s(1),p=0;l.isEven()&&f.isEven();)l.iushrn(1),f.iushrn(1),++p;for(var a=f.clone(),v=l.clone();!l.isZero();){for(var N=0,I=1;!(l.words[0]&I)&&N<26;++N,I<<=1);if(N>0)for(l.iushrn(N);N-- >0;)(g.isOdd()||m.isOdd())&&(g.iadd(a),m.isub(v)),g.iushrn(1),m.iushrn(1);for(var $=0,ze=1;!(f.words[0]&ze)&&$<26;++$,ze<<=1);if($>0)for(f.iushrn($);$-- >0;)(w.isOdd()||_.isOdd())&&(w.iadd(a),_.isub(v)),w.iushrn(1),_.iushrn(1);l.cmp(f)>=0?(l.isub(f),g.isub(w),m.isub(_)):(f.isub(l),w.isub(g),_.isub(m))}return{a:w,b:_,gcd:f.iushln(p)}},s.prototype._invmp=function(o){n(o.negative===0),n(!o.isZero());var l=this,f=o.clone();l.negative!==0?l=l.umod(o):l=l.clone();for(var g=new s(1),m=new s(0),w=f.clone();l.cmpn(1)>0&&f.cmpn(1)>0;){for(var _=0,p=1;!(l.words[0]&p)&&_<26;++_,p<<=1);if(_>0)for(l.iushrn(_);_-- >0;)g.isOdd()&&g.iadd(w),g.iushrn(1);for(var a=0,v=1;!(f.words[0]&v)&&a<26;++a,v<<=1);if(a>0)for(f.iushrn(a);a-- >0;)m.isOdd()&&m.iadd(w),m.iushrn(1);l.cmp(f)>=0?(l.isub(f),g.isub(m)):(f.isub(l),m.isub(g))}var N;return l.cmpn(1)===0?N=g:N=m,N.cmpn(0)<0&&N.iadd(o),N},s.prototype.gcd=function(o){if(this.isZero())return o.abs();if(o.isZero())return this.abs();var l=this.clone(),f=o.clone();l.negative=0,f.negative=0;for(var g=0;l.isEven()&&f.isEven();g++)l.iushrn(1),f.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;f.isEven();)f.iushrn(1);var m=l.cmp(f);if(m<0){var w=l;l=f,f=w}else if(m===0||f.cmpn(1)===0)break;l.isub(f)}while(!0);return f.iushln(g)},s.prototype.invm=function(o){return this.egcd(o).a.umod(o)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(o){return this.words[0]&o},s.prototype.bincn=function(o){n(typeof o=="number");var l=o%26,f=(o-l)/26,g=1<>>26,_&=67108863,this.words[w]=_}return m!==0&&(this.words[w]=m,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(o){var l=o<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this._strip();var f;if(this.length>1)f=1;else{l&&(o=-o),n(o<=67108863,"Number is too big");var g=this.words[0]|0;f=g===o?0:go.length)return 1;if(this.length=0;f--){var g=this.words[f]|0,m=o.words[f]|0;if(g!==m){gm&&(l=1);break}}return l},s.prototype.gtn=function(o){return this.cmpn(o)===1},s.prototype.gt=function(o){return this.cmp(o)===1},s.prototype.gten=function(o){return this.cmpn(o)>=0},s.prototype.gte=function(o){return this.cmp(o)>=0},s.prototype.ltn=function(o){return this.cmpn(o)===-1},s.prototype.lt=function(o){return this.cmp(o)===-1},s.prototype.lten=function(o){return this.cmpn(o)<=0},s.prototype.lte=function(o){return this.cmp(o)<=0},s.prototype.eqn=function(o){return this.cmpn(o)===0},s.prototype.eq=function(o){return this.cmp(o)===0},s.red=function(o){return new H(o)},s.prototype.toRed=function(o){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),o.convertTo(this)._forceRed(o)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(o){return this.red=o,this},s.prototype.forceRed=function(o){return n(!this.red,"Already a number in reduction context"),this._forceRed(o)},s.prototype.redAdd=function(o){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,o)},s.prototype.redIAdd=function(o){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,o)},s.prototype.redSub=function(o){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,o)},s.prototype.redISub=function(o){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,o)},s.prototype.redShl=function(o){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,o)},s.prototype.redMul=function(o){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.mul(this,o)},s.prototype.redIMul=function(o){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.imul(this,o)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(o){return n(this.red&&!o.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,o)};var C={k256:null,p224:null,p192:null,p25519:null};function P(b,o){this.name=b,this.p=new s(o,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}P.prototype._tmp=function(){var o=new s(null);return o.words=new Array(Math.ceil(this.n/13)),o},P.prototype.ireduce=function(o){var l=o,f;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),f=l.bitLength();while(f>this.n);var g=f0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},P.prototype.split=function(o,l){o.iushrn(this.n,0,l)},P.prototype.imulK=function(o){return o.imul(this.k)};function J(){P.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(J,P),J.prototype.split=function(o,l){for(var f=4194303,g=Math.min(o.length,9),m=0;m>>22,w=_}w>>>=22,o.words[m-10]=w,w===0&&o.length>10?o.length-=10:o.length-=9},J.prototype.imulK=function(o){o.words[o.length]=0,o.words[o.length+1]=0,o.length+=2;for(var l=0,f=0;f>>=26,o.words[f]=m,l=g}return l!==0&&(o.words[o.length++]=l),o},s._prime=function(o){if(C[o])return C[o];var l;if(o==="k256")l=new J;else if(o==="p224")l=new We;else if(o==="p192")l=new Qe;else if(o==="p25519")l=new Y;else throw new Error("Unknown prime "+o);return C[o]=l,l};function H(b){if(typeof b=="string"){var o=s._prime(b);this.m=o.p,this.prime=o}else n(b.gtn(1),"modulus must be greater than 1"),this.m=b,this.prime=null}H.prototype._verify1=function(o){n(o.negative===0,"red works only with positives"),n(o.red,"red works only with red numbers")},H.prototype._verify2=function(o,l){n((o.negative|l.negative)===0,"red works only with positives"),n(o.red&&o.red===l.red,"red works only with red numbers")},H.prototype.imod=function(o){return this.prime?this.prime.ireduce(o)._forceRed(this):(y(o,o.umod(this.m)._forceRed(this)),o)},H.prototype.neg=function(o){return o.isZero()?o.clone():this.m.sub(o)._forceRed(this)},H.prototype.add=function(o,l){this._verify2(o,l);var f=o.add(l);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},H.prototype.iadd=function(o,l){this._verify2(o,l);var f=o.iadd(l);return f.cmp(this.m)>=0&&f.isub(this.m),f},H.prototype.sub=function(o,l){this._verify2(o,l);var f=o.sub(l);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},H.prototype.isub=function(o,l){this._verify2(o,l);var f=o.isub(l);return f.cmpn(0)<0&&f.iadd(this.m),f},H.prototype.shl=function(o,l){return this._verify1(o),this.imod(o.ushln(l))},H.prototype.imul=function(o,l){return this._verify2(o,l),this.imod(o.imul(l))},H.prototype.mul=function(o,l){return this._verify2(o,l),this.imod(o.mul(l))},H.prototype.isqr=function(o){return this.imul(o,o.clone())},H.prototype.sqr=function(o){return this.mul(o,o)},H.prototype.sqrt=function(o){if(o.isZero())return o.clone();var l=this.m.andln(3);if(n(l%2===1),l===3){var f=this.m.add(new s(1)).iushrn(2);return this.pow(o,f)}for(var g=this.m.subn(1),m=0;!g.isZero()&&g.andln(1)===0;)m++,g.iushrn(1);n(!g.isZero());var w=new s(1).toRed(this),_=w.redNeg(),p=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new s(2*a*a).toRed(this);this.pow(a,p).cmp(_)!==0;)a.redIAdd(_);for(var v=this.pow(a,g),N=this.pow(o,g.addn(1).iushrn(1)),I=this.pow(o,g),$=m;I.cmp(w)!==0;){for(var ze=I,G=0;ze.cmp(w)!==0;G++)ze=ze.redSqr();n(G<$);var Z=this.pow(v,new s(1).iushln($-G-1));N=N.redMul(Z),v=Z.redSqr(),I=I.redMul(v),$=G}return N},H.prototype.invm=function(o){var l=o._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},H.prototype.pow=function(o,l){if(l.isZero())return new s(1).toRed(this);if(l.cmpn(1)===0)return o.clone();var f=4,g=new Array(1<=0;m--){for(var v=l.words[m],N=a-1;N>=0;N--){var I=v>>N&1;if(w!==g[0]&&(w=this.sqr(w)),I===0&&_===0){p=0;continue}_<<=1,_|=I,p++,!(p!==f&&(m!==0||N!==0))&&(w=this.mul(w,g[_]),p=0,_=0)}a=26}return w},H.prototype.convertTo=function(o){var l=o.umod(this.m);return l===o?l.clone():l},H.prototype.convertFrom=function(o){var l=o.clone();return l.red=null,l},s.mont=function(o){return new q(o)};function q(b){H.call(this,b),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(q,H),q.prototype.convertTo=function(o){return this.imod(o.ushln(this.shift))},q.prototype.convertFrom=function(o){var l=this.imod(o.mul(this.rinv));return l.red=null,l},q.prototype.imul=function(o,l){if(o.isZero()||l.isZero())return o.words[0]=0,o.length=1,o;var f=o.imul(l),g=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=f.isub(g).iushrn(this.shift),w=m;return m.cmp(this.m)>=0?w=m.isub(this.m):m.cmpn(0)<0&&(w=m.iadd(this.m)),w._forceRed(this)},q.prototype.mul=function(o,l){if(o.isZero()||l.isZero())return new s(0)._forceRed(this);var f=o.mul(l),g=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=f.isub(g).iushrn(this.shift),w=m;return m.cmp(this.m)>=0?w=m.isub(this.m):m.cmpn(0)<0&&(w=m.iadd(this.m)),w._forceRed(this)},q.prototype.invm=function(o){var l=this.imod(o._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(t,T)})(Us);var un=Us.exports,Sr={},St={};Object.defineProperty(St,"__esModule",{value:!0});St.errorValues=St.standardErrorCodes=void 0;St.standardErrorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}};St.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}};var dn={},hn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serialize=t.getErrorCode=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=St,r="Unspecified error message.";t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function n(E,M=r){if(E&&Number.isInteger(E)){const k=E.toString();if(y(e.errorValues,k))return e.errorValues[k].message;if(d(E))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return M}t.getMessageFromCode=n;function i(E){if(!Number.isInteger(E))return!1;const M=E.toString();return!!(e.errorValues[M]||d(E))}t.isValidCode=i;function s(E){var M;if(typeof E=="number")return E;if(c(E))return(M=E.code)!==null&&M!==void 0?M:E.errorCode}t.getErrorCode=s;function c(E){return typeof E=="object"&&E!==null&&(typeof E.code=="number"||typeof E.errorCode=="number")}function u(E,{shouldIncludeStack:M=!1}={}){const k={};if(E&&typeof E=="object"&&!Array.isArray(E)&&y(E,"code")&&i(E.code)){const x=E;k.code=x.code,x.message&&typeof x.message=="string"?(k.message=x.message,y(x,"data")&&(k.data=x.data)):(k.message=n(k.code),k.data={originalError:h(E)})}else k.code=e.standardErrorCodes.rpc.internal,k.message=S(E,"message")?E.message:r,k.data={originalError:h(E)};return M&&(k.stack=S(E,"stack")?E.stack:void 0),k}t.serialize=u;function d(E){return E>=-32099&&E<=-32e3}function h(E){return E&&typeof E=="object"&&!Array.isArray(E)?Object.assign({},E):E}function y(E,M){return Object.prototype.hasOwnProperty.call(E,M)}function S(E,M){return typeof E=="object"&&E!==null&&M in E&&typeof E[M]=="string"}})(hn);Object.defineProperty(dn,"__esModule",{value:!0});dn.standardErrors=void 0;const He=St,na=hn;dn.standardErrors={rpc:{parse:t=>rt(He.standardErrorCodes.rpc.parse,t),invalidRequest:t=>rt(He.standardErrorCodes.rpc.invalidRequest,t),invalidParams:t=>rt(He.standardErrorCodes.rpc.invalidParams,t),methodNotFound:t=>rt(He.standardErrorCodes.rpc.methodNotFound,t),internal:t=>rt(He.standardErrorCodes.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return rt(e,t)},invalidInput:t=>rt(He.standardErrorCodes.rpc.invalidInput,t),resourceNotFound:t=>rt(He.standardErrorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>rt(He.standardErrorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>rt(He.standardErrorCodes.rpc.transactionRejected,t),methodNotSupported:t=>rt(He.standardErrorCodes.rpc.methodNotSupported,t),limitExceeded:t=>rt(He.standardErrorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>Wt(He.standardErrorCodes.provider.userRejectedRequest,t),unauthorized:t=>Wt(He.standardErrorCodes.provider.unauthorized,t),unsupportedMethod:t=>Wt(He.standardErrorCodes.provider.unsupportedMethod,t),disconnected:t=>Wt(He.standardErrorCodes.provider.disconnected,t),chainDisconnected:t=>Wt(He.standardErrorCodes.provider.chainDisconnected,t),unsupportedChain:t=>Wt(He.standardErrorCodes.provider.unsupportedChain,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:r,data:n}=t;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new oa(e,r,n)}}};function rt(t,e){const[r,n]=sa(e);return new ia(t,r||(0,na.getMessageFromCode)(t),n)}function Wt(t,e){const[r,n]=sa(e);return new oa(t,r||(0,na.getMessageFromCode)(t),n)}function sa(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,r]}}return[]}let ia=class extends Error{constructor(e,r,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string.');super(r),this.code=e,n!==void 0&&(this.data=n)}},oa=class extends ia{constructor(e,r,n){if(!Fc(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,r,n)}};function Fc(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}var fn={},cr={};Object.defineProperty(cr,"__esModule",{value:!0});cr.isErrorResponse=void 0;function Hc(t){return t.errorMessage!==void 0}cr.isErrorResponse=Hc;var lr={};Object.defineProperty(lr,"__esModule",{value:!0});lr.LIB_VERSION=void 0;lr.LIB_VERSION="3.9.3";Object.defineProperty(fn,"__esModule",{value:!0});fn.serializeError=void 0;const Uc=cr,Vc=lr,Wc=St,zc=hn;function qc(t,e){const r=(0,zc.serialize)(Jc(t),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");n.searchParams.set("version",Vc.LIB_VERSION),n.searchParams.set("code",r.code.toString());const i=Gc(r.data,e);return i&&n.searchParams.set("method",i),n.searchParams.set("message",r.message),Object.assign(Object.assign({},r),{docUrl:n.href})}fn.serializeError=qc;function Jc(t){return typeof t=="string"?{message:t,code:Wc.standardErrorCodes.rpc.internal}:(0,Uc.isErrorResponse)(t)?Object.assign(Object.assign({},t),{message:t.errorMessage,code:t.errorCode,data:{method:t.method}}):t}function Gc(t,e){const r=t==null?void 0:t.method;if(r)return r;if(e!==void 0){if(typeof e=="string")return e;if(Array.isArray(e)){if(e.length>0)return e[0].method}else return e.method}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.standardErrors=t.standardErrorCodes=t.serializeError=t.getMessageFromCode=t.getErrorCode=void 0;const e=St;Object.defineProperty(t,"standardErrorCodes",{enumerable:!0,get:function(){return e.standardErrorCodes}});const r=dn;Object.defineProperty(t,"standardErrors",{enumerable:!0,get:function(){return r.standardErrors}});const n=fn;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return n.serializeError}});const i=hn;Object.defineProperty(t,"getErrorCode",{enumerable:!0,get:function(){return i.getErrorCode}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return i.getMessageFromCode}})})(Sr);var De={};Object.defineProperty(De,"__esModule",{value:!0});De.ProviderType=De.RegExpString=De.IntNumber=De.BigIntString=De.AddressString=De.HexString=De.OpaqueType=void 0;function Mr(){return t=>t}De.OpaqueType=Mr;De.HexString=Mr();De.AddressString=Mr();De.BigIntString=Mr();function Zc(t){return Math.floor(t)}De.IntNumber=Zc;De.RegExpString=Mr();var Vi;(function(t){t.CoinbaseWallet="CoinbaseWallet",t.MetaMask="MetaMask",t.Unselected=""})(Vi||(De.ProviderType=Vi={}));var Qc=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(A,"__esModule",{value:!0});A.isMobileWeb=A.getLocation=A.isInIFrame=A.createQrUrl=A.getFavicon=A.range=A.isBigNumber=A.ensureParsedJSONObject=A.ensureBN=A.ensureRegExpString=A.ensureIntNumber=A.ensureBuffer=A.ensureAddressString=A.ensureEvenLengthHexString=A.ensureHexString=A.isHexString=A.prepend0x=A.strip0x=A.has0xPrefix=A.hexStringFromIntNumber=A.intNumberFromHexString=A.bigIntStringFromBN=A.hexStringFromBuffer=A.hexStringToUint8Array=A.uint8ArrayToHex=A.randomBytesHex=void 0;const Rt=Qc(un),Ht=Sr,ot=De,aa=/^[0-9]*$/,ca=/^[a-f0-9]*$/;function Kc(t){return la(crypto.getRandomValues(new Uint8Array(t)))}A.randomBytesHex=Kc;function la(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}A.uint8ArrayToHex=la;function Xc(t){return new Uint8Array(t.match(/.{1,2}/g).map(e=>parseInt(e,16)))}A.hexStringToUint8Array=Xc;function Yc(t,e=!1){const r=t.toString("hex");return(0,ot.HexString)(e?`0x${r}`:r)}A.hexStringFromBuffer=Yc;function el(t){return(0,ot.BigIntString)(t.toString(10))}A.bigIntStringFromBN=el;function tl(t){return(0,ot.IntNumber)(new Rt.default(Rr(t,!1),16).toNumber())}A.intNumberFromHexString=tl;function rl(t){return(0,ot.HexString)(`0x${new Rt.default(t).toString(16)}`)}A.hexStringFromIntNumber=rl;function Vs(t){return t.startsWith("0x")||t.startsWith("0X")}A.has0xPrefix=Vs;function gn(t){return Vs(t)?t.slice(2):t}A.strip0x=gn;function ua(t){return Vs(t)?`0x${t.slice(2)}`:`0x${t}`}A.prepend0x=ua;function kr(t){if(typeof t!="string")return!1;const e=gn(t).toLowerCase();return ca.test(e)}A.isHexString=kr;function da(t,e=!1){if(typeof t=="string"){const r=gn(t).toLowerCase();if(ca.test(r))return(0,ot.HexString)(e?`0x${r}`:r)}throw Ht.standardErrors.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}A.ensureHexString=da;function Rr(t,e=!1){let r=da(t,!1);return r.length%2===1&&(r=(0,ot.HexString)(`0${r}`)),e?(0,ot.HexString)(`0x${r}`):r}A.ensureEvenLengthHexString=Rr;function nl(t){if(typeof t=="string"){const e=gn(t).toLowerCase();if(kr(e)&&e.length===40)return(0,ot.AddressString)(ua(e))}throw Ht.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`)}A.ensureAddressString=nl;function sl(t){if(Buffer.isBuffer(t))return t;if(typeof t=="string"){if(kr(t)){const e=Rr(t,!1);return Buffer.from(e,"hex")}return Buffer.from(t,"utf8")}throw Ht.standardErrors.rpc.invalidParams(`Not binary data: ${String(t)}`)}A.ensureBuffer=sl;function ha(t){if(typeof t=="number"&&Number.isInteger(t))return(0,ot.IntNumber)(t);if(typeof t=="string"){if(aa.test(t))return(0,ot.IntNumber)(Number(t));if(kr(t))return(0,ot.IntNumber)(new Rt.default(Rr(t,!1),16).toNumber())}throw Ht.standardErrors.rpc.invalidParams(`Not an integer: ${String(t)}`)}A.ensureIntNumber=ha;function il(t){if(t instanceof RegExp)return(0,ot.RegExpString)(t.toString());throw Ht.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(t)}`)}A.ensureRegExpString=il;function ol(t){if(t!==null&&(Rt.default.isBN(t)||fa(t)))return new Rt.default(t.toString(10),10);if(typeof t=="number")return new Rt.default(ha(t));if(typeof t=="string"){if(aa.test(t))return new Rt.default(t,10);if(kr(t))return new Rt.default(Rr(t,!1),16)}throw Ht.standardErrors.rpc.invalidParams(`Not an integer: ${String(t)}`)}A.ensureBN=ol;function al(t){if(typeof t=="string")return JSON.parse(t);if(typeof t=="object")return t;throw Ht.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`)}A.ensureParsedJSONObject=al;function fa(t){if(t==null||typeof t.constructor!="function")return!1;const{constructor:e}=t;return typeof e.config=="function"&&typeof e.EUCLID=="number"}A.isBigNumber=fa;function cl(t,e){return Array.from({length:e-t},(r,n)=>t+n)}A.range=cl;function ll(){const t=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:r}=document.location,n=t?t.getAttribute("href"):null;return!n||n.startsWith("javascript:")||n.startsWith("vbscript:")?null:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?e+n:`${e}//${r}${n}`}A.getFavicon=ll;function ul(t,e,r,n,i,s){const c=n?"parent-id":"id",u=new URLSearchParams({[c]:t,secret:e,server:r,v:i,chainId:s.toString()}).toString();return`${r}/#/link?${u}`}A.createQrUrl=ul;function ga(){try{return window.frameElement!==null}catch{return!1}}A.isInIFrame=ga;function dl(){try{return ga()&&window.top?window.top.location:window.location}catch{return window.location}}A.getLocation=dl;function hl(){var t;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t=window==null?void 0:window.navigator)===null||t===void 0?void 0:t.userAgent)}A.isMobileWeb=hl;var pn={};Object.defineProperty(pn,"__esModule",{value:!0});pn.ScopedLocalStorage=void 0;class fl{constructor(e){this.scope=e}setItem(e,r){localStorage.setItem(this.scopedKey(e),r)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),r=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(e){return`${this.scope}:${e}`}}pn.ScopedLocalStorage=fl;var rr={},Ir={},Cr={},ur={};Object.defineProperty(ur,"__esModule",{value:!0});ur.EVENTS=void 0;ur.EVENTS={STARTED_CONNECTING:"walletlink_sdk.started.connecting",CONNECTED_STATE_CHANGE:"walletlink_sdk.connected",DISCONNECTED:"walletlink_sdk.disconnected",METADATA_DESTROYED:"walletlink_sdk_metadata_destroyed",LINKED:"walletlink_sdk.linked",FAILURE:"walletlink_sdk.generic_failure",SESSION_CONFIG_RECEIVED:"walletlink_sdk.session_config_event_received",ETH_ACCOUNTS_STATE:"walletlink_sdk.eth_accounts_state",SESSION_STATE_CHANGE:"walletlink_sdk.session_state_change",UNLINKED_ERROR_STATE:"walletlink_sdk.unlinked_error_state",SKIPPED_CLEARING_SESSION:"walletlink_sdk.skipped_clearing_session",GENERAL_ERROR:"walletlink_sdk.general_error",WEB3_REQUEST:"walletlink_sdk.web3.request",WEB3_REQUEST_PUBLISHED:"walletlink_sdk.web3.request_published",WEB3_RESPONSE:"walletlink_sdk.web3.response",METHOD_NOT_IMPLEMENTED:"walletlink_sdk.method_not_implemented",UNKNOWN_ADDRESS_ENCOUNTERED:"walletlink_sdk.unknown_address_encountered"};var it={};Object.defineProperty(it,"__esModule",{value:!0});it.RelayAbstract=it.APP_VERSION_KEY=it.LOCAL_STORAGE_ADDRESSES_KEY=it.WALLET_USER_NAME_KEY=void 0;const Wi=Sr;it.WALLET_USER_NAME_KEY="walletUsername";it.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";it.APP_VERSION_KEY="AppVersion";class gl{async makeEthereumJSONRPCRequest(e,r){if(!r)throw new Error("Error: No jsonRpcUrl provided");return window.fetch(r,{method:"POST",body:JSON.stringify(e),mode:"cors",headers:{"Content-Type":"application/json"}}).then(n=>n.json()).then(n=>{if(!n)throw Wi.standardErrors.rpc.parse({});const i=n,{error:s}=i;if(s)throw(0,Wi.serializeError)(s,e.method);return i})}}it.RelayAbstract=gl;var dr={};Object.defineProperty(dr,"__esModule",{value:!0});dr.Session=void 0;const zi=Oc,qi=A,Ji="session:id",Gi="session:secret",Zi="session:linked";class Ws{constructor(e,r,n,i){this._storage=e,this._id=r||(0,qi.randomBytesHex)(16),this._secret=n||(0,qi.randomBytesHex)(32),this._key=new zi.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!i}static load(e){const r=e.getItem(Ji),n=e.getItem(Zi),i=e.getItem(Gi);return r&&i?new Ws(e,r,i,n==="1"):null}static hash(e){return new zi.sha256().update(e).digest("hex")}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this._storage.setItem(Ji,this._id),this._storage.setItem(Gi,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(Zi,this._linked?"1":"0")}}dr.Session=Ws;var mn={},vn={};Object.defineProperty(vn,"__esModule",{value:!0});vn.Cipher=void 0;const Wr=A;class pl{constructor(e){this.secret=e}async encrypt(e){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",(0,Wr.hexStringToUint8Array)(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=new TextEncoder,c=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,s.encode(e)),u=16,d=c.slice(c.byteLength-u),h=c.slice(0,c.byteLength-u),y=new Uint8Array(d),S=new Uint8Array(h),E=new Uint8Array([...n,...y,...S]);return(0,Wr.uint8ArrayToHex)(E)}async decrypt(e){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");return new Promise((n,i)=>{(async function(){const s=await crypto.subtle.importKey("raw",(0,Wr.hexStringToUint8Array)(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),c=(0,Wr.hexStringToUint8Array)(e),u=c.slice(0,12),d=c.slice(12,28),h=c.slice(28),y=new Uint8Array([...h,...d]),S={name:"AES-GCM",iv:new Uint8Array(u)};try{const E=await window.crypto.subtle.decrypt(S,s,y),M=new TextDecoder;n(M.decode(E))}catch(E){i(E)}})()})}}vn.Cipher=pl;var wn={};Object.defineProperty(wn,"__esModule",{value:!0});wn.WalletLinkHTTP=void 0;class ml{constructor(e,r,n){this.linkAPIUrl=e,this.sessionId=r;const i=`${r}:${n}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(r=>fetch(`${this.linkAPIUrl}/events/${r.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(r=>console.error("Unabled to mark event as failed:",r))}async fetchUnseenEvents(){var e;const r=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(r.ok){const{events:n,error:i}=await r.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const s=(e=n==null?void 0:n.filter(c=>c.event==="Web3Response").map(c=>({type:"Event",sessionId:this.sessionId,eventId:c.id,event:c.event,data:c.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(s),s}throw new Error(`Check unseen events failed: ${r.status}`)}}wn.WalletLinkHTTP=ml;var nr={};Object.defineProperty(nr,"__esModule",{value:!0});nr.WalletLinkWebSocket=nr.ConnectionState=void 0;var Kt;(function(t){t[t.DISCONNECTED=0]="DISCONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED"})(Kt||(nr.ConnectionState=Kt={}));class vl{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,r=WebSocket){this.WebSocketClass=r,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,r)=>{var n;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(s){r(s);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,Kt.CONNECTING),i.onclose=s=>{var c;this.clearWebSocket(),r(new Error(`websocket error ${s.code}: ${s.reason}`)),(c=this.connectionStateListener)===null||c===void 0||c.call(this,Kt.DISCONNECTED)},i.onopen=s=>{var c;e(),(c=this.connectionStateListener)===null||c===void 0||c.call(this,Kt.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(d=>this.sendData(d)),this.pendingData=[])},i.onmessage=s=>{var c,u;if(s.data==="h")(c=this.incomingDataListener)===null||c===void 0||c.call(this,{type:"Heartbeat"});else try{const d=JSON.parse(s.data);(u=this.incomingDataListener)===null||u===void 0||u.call(this,d)}catch{}}})}disconnect(){var e;const{webSocket:r}=this;if(r){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,Kt.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{r.close()}catch{}}}sendData(e){const{webSocket:r}=this;if(!r){this.pendingData.push(e),this.connect();return}r.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}nr.WalletLinkWebSocket=vl;Object.defineProperty(mn,"__esModule",{value:!0});mn.WalletLinkConnection=void 0;const zt=De,wl=vn,ht=ur,Qi=it,qt=dr,yl=wn,zr=nr,Ki=1e4,bl=6e4;class _l{constructor({session:e,linkAPIUrl:r,listener:n,diagnostic:i,WebSocketClass:s=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,zt.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=u=>{if(!u)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",h=>u.JsonRpcUrl&&this.handleChainUpdated(h,u.JsonRpcUrl)]]).forEach((h,y)=>{const S=u[y];S!==void 0&&h(S)})},this.handleDestroyed=u=>{var d,h;u==="1"&&((d=this.listener)===null||d===void 0||d.resetAndReload(),(h=this.diagnostic)===null||h===void 0||h.log(ht.EVENTS.METADATA_DESTROYED,{alreadyDestroyed:this.isDestroyed,sessionIdHash:qt.Session.hash(this.session.id)}))},this.handleAccountUpdated=async u=>{var d,h;try{const y=await this.cipher.decrypt(u);(d=this.listener)===null||d===void 0||d.accountUpdated(y)}catch{(h=this.diagnostic)===null||h===void 0||h.log(ht.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"selectedAddress"})}},this.handleMetadataUpdated=async(u,d)=>{var h,y;try{const S=await this.cipher.decrypt(d);(h=this.listener)===null||h===void 0||h.metadataUpdated(u,S)}catch{(y=this.diagnostic)===null||y===void 0||y.log(ht.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:u})}},this.handleWalletUsernameUpdated=async u=>{this.handleMetadataUpdated(Qi.WALLET_USER_NAME_KEY,u)},this.handleAppVersionUpdated=async u=>{this.handleMetadataUpdated(Qi.APP_VERSION_KEY,u)},this.handleChainUpdated=async(u,d)=>{var h,y;try{const S=await this.cipher.decrypt(u),E=await this.cipher.decrypt(d);(h=this.listener)===null||h===void 0||h.chainUpdated(S,E)}catch{(y=this.diagnostic)===null||y===void 0||y.log(ht.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"chainId|jsonRpcUrl"})}},this.session=e,this.cipher=new wl.Cipher(e.secret),this.diagnostic=i,this.listener=n;const c=new zr.WalletLinkWebSocket(`${r}/rpc`,s);c.setConnectionStateListener(async u=>{var d;(d=this.diagnostic)===null||d===void 0||d.log(ht.EVENTS.CONNECTED_STATE_CHANGE,{state:u,sessionIdHash:qt.Session.hash(e.id)});let h=!1;switch(u){case zr.ConnectionState.DISCONNECTED:if(!this.destroyed){const y=async()=>{await new Promise(S=>setTimeout(S,5e3)),this.destroyed||c.connect().catch(()=>{y()})};y()}break;case zr.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),h=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},Ki),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case zr.ConnectionState.CONNECTING:break}this.connected!==h&&(this.connected=h)}),c.setIncomingDataListener(u=>{var d,h,y;switch(u.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const S=u.type==="IsLinkedOK"?u.linked:void 0;(d=this.diagnostic)===null||d===void 0||d.log(ht.EVENTS.LINKED,{sessionIdHash:qt.Session.hash(e.id),linked:S,type:u.type,onlineGuests:u.onlineGuests}),this.linked=S||u.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{(h=this.diagnostic)===null||h===void 0||h.log(ht.EVENTS.SESSION_CONFIG_RECEIVED,{sessionIdHash:qt.Session.hash(e.id),metadata_keys:u&&u.metadata?Object.keys(u.metadata):void 0}),this.handleSessionMetadataUpdated(u.metadata);break}case"Event":{this.handleIncomingEvent(u);break}}u.id!==void 0&&((y=this.requestResolutions.get(u.id))===null||y===void 0||y(u))}),this.ws=c,this.http=new yl.WalletLinkHTTP(r,e.id,e.key)}connect(){var e;if(this.destroyed)throw new Error("instance is destroyed");(e=this.diagnostic)===null||e===void 0||e.log(ht.EVENTS.STARTED_CONNECTING,{sessionIdHash:qt.Session.hash(this.session.id)}),this.ws.connect()}destroy(){var e;this.destroyed=!0,this.ws.disconnect(),(e=this.diagnostic)===null||e===void 0||e.log(ht.EVENTS.DISCONNECTED,{sessionIdHash:qt.Session.hash(this.session.id)}),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(e){var r,n;this._connected=e,e&&((r=this.onceConnected)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.connectedUpdated(e)}setOnceConnected(e){return new Promise(r=>{this.connected?e().then(r):this.onceConnected=()=>{e().then(r),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(e){var r,n;this._linked=e,e&&((r=this.onceLinked)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(e)}setOnceLinked(e){return new Promise(r=>{this.linked?e().then(r):this.onceLinked=()=>{e().then(r),this.onceLinked=void 0}})}async handleIncomingEvent(e){var r,n;if(!(e.type!=="Event"||e.event!=="Web3Response"))try{const i=await this.cipher.decrypt(e.data),s=JSON.parse(i);if(s.type!=="WEB3_RESPONSE")return;(r=this.listener)===null||r===void 0||r.handleWeb3ResponseMessage(s)}catch{(n=this.diagnostic)===null||n===void 0||n.log(ht.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"incomingEvent"})}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(r=>this.handleIncomingEvent(r))}async setSessionMetadata(e,r){const n={type:"SetSessionConfig",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[e]:r}};return this.setOnceConnected(async()=>{const i=await this.makeRequest(n);if(i.type==="Fail")throw new Error(i.error||"failed to set session metadata")})}async publishEvent(e,r,n=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},r),{origin:location.origin,relaySource:window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),s={type:"PublishEvent",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:e,data:i,callWebhook:n};return this.setOnceLinked(async()=>{const c=await this.makeRequest(s);if(c.type==="Fail")throw new Error(c.error||"failed to publish event");return c.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>Ki*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,r=bl){const n=e.id;this.sendData(e);let i;return Promise.race([new Promise((s,c)=>{i=window.setTimeout(()=>{c(new Error(`request ${n} timed out`))},r)}),new Promise(s=>{this.requestResolutions.set(n,c=>{clearTimeout(i),s(c),this.requestResolutions.delete(n)})})])}async authenticate(){const e={type:"HostSession",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},r=await this.makeRequest(e);if(r.type==="Fail")throw new Error(r.error||"failed to authentcate")}sendIsLinked(){const e={type:"IsLinked",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}sendGetSessionConfig(){const e={type:"GetSessionConfig",id:(0,zt.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}}mn.WalletLinkConnection=_l;var Ar={},Nr={},zs={};Object.defineProperty(zs,"__esModule",{value:!0});zs.default='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';var El=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Nr,"__esModule",{value:!0});Nr.injectCssReset=void 0;const Sl=El(zs);function Ml(){const t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode(Sl.default)),document.documentElement.appendChild(t)}Nr.injectCssReset=Ml;var yn={},bn={};function pa(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t))for(e=0;e65536?(n[0]=240|(i&1835008)>>>18,n[1]=128|(i&258048)>>>12,n[2]=128|(i&4032)>>>6,n[3]=128|i&63):i>2048?(n[0]=224|(i&61440)>>>12,n[1]=128|(i&4032)>>>6,n[2]=128|i&63):i>128?(n[0]=192|(i&1984)>>>6,n[1]=128|i&63):n[0]=i,this.parsedData.push(n)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}ma.prototype={getLength:function(t){return this.parsedData.length},write:function(t){for(var e=0,r=this.parsedData.length;e=7&&this.setupTypeNumber(t),this.dataCache==null&&(this.dataCache=wt.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(0<=r&&r<=6&&(n==0||n==6)||0<=n&&n<=6&&(r==0||r==6)||2<=r&&r<=4&&2<=n&&n<=4?this.modules[t+r][e+n]=!0:this.modules[t+r][e+n]=!1)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=K.getLostPoint(this);(r==0||t>n)&&(t=n,e=r)}return e},createMovieClip:function(t,e,r){var n=t.createEmptyMovieClip(e,r),i=1;this.make();for(var s=0;s>r&1)==1;this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(var r=0;r<18;r++){var n=!t&&(e>>r&1)==1;this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,n=K.getBCHTypeInfo(r),i=0;i<15;i++){var s=!t&&(n>>i&1)==1;i<6?this.modules[i][8]=s:i<8?this.modules[i+1][8]=s:this.modules[this.moduleCount-15+i][8]=s}for(var i=0;i<15;i++){var s=!t&&(n>>i&1)==1;i<8?this.modules[8][this.moduleCount-i-1]=s:i<9?this.modules[8][15-i-1+1]=s:this.modules[8][15-i-1]=s}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,n=this.moduleCount-1,i=7,s=0,c=this.moduleCount-1;c>0;c-=2)for(c==6&&c--;;){for(var u=0;u<2;u++)if(this.modules[n][c-u]==null){var d=!1;s>>i&1)==1);var h=K.getMask(e,n,c-u);h&&(d=!d),this.modules[n][c-u]=d,i--,i==-1&&(s++,i=7)}if(n+=r,n<0||this.moduleCount<=n){n-=r,r=-r;break}}}};wt.PAD0=236;wt.PAD1=17;wt.createData=function(t,e,r){for(var n=vt.getRSBlocks(t,e),i=new va,s=0;su*8)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+u*8+")");for(i.getLengthInBits()+4<=u*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=u*8||(i.put(wt.PAD0,8),i.getLengthInBits()>=u*8));)i.put(wt.PAD1,8);return wt.createBytes(i,n)};wt.createBytes=function(t,e){for(var r=0,n=0,i=0,s=new Array(e.length),c=new Array(e.length),u=0;u=0?M.get(k):0}}for(var x=0,y=0;y=0;)e^=K.G15<=0;)e^=K.G18<>>=1;return e},getPatternPosition:function(t){return K.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case Mt.PATTERN000:return(e+r)%2==0;case Mt.PATTERN001:return e%2==0;case Mt.PATTERN010:return r%3==0;case Mt.PATTERN011:return(e+r)%3==0;case Mt.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case Mt.PATTERN101:return e*r%2+e*r%3==0;case Mt.PATTERN110:return(e*r%2+e*r%3)%2==0;case Mt.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new Xt([1],0),r=0;r5&&(r+=3+s-5)}for(var n=0;n=256;)t-=255;return Fe.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(var Ue=0;Ue<8;Ue++)Fe.EXP_TABLE[Ue]=1<>>7-t%8&1)==1},put:function(t,e){for(var r=0;r>>e-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var vs=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function wa(t){if(this.options={padding:4,width:256,height:256,typeNumber:4,color:"#000000",background:"#ffffff",ecl:"M",image:{svg:"",width:0,height:0}},typeof t=="string"&&(t={content:t}),t)for(var e in t)this.options[e]=t[e];if(typeof this.options.content!="string")throw new Error("Expected 'content' as string!");if(this.options.content.length===0)throw new Error("Expected 'content' to be non-empty!");if(!(this.options.padding>=0))throw new Error("Expected 'padding' value to be non-negative!");if(!(this.options.width>0)||!(this.options.height>0))throw new Error("Expected 'width' or 'height' value to be higher than zero!");function r(d){switch(d){case"L":return It.L;case"M":return It.M;case"Q":return It.Q;case"H":return It.H;default:throw new Error("Unknwon error correction level: "+d)}}function n(d,h){for(var y=i(d),S=1,E=0,M=0,k=vs.length;M<=k;M++){var x=vs[M];if(!x)throw new Error("Content too long: expected "+E+" but got "+y);switch(h){case"L":E=x[0];break;case"M":E=x[1];break;case"Q":E=x[2];break;case"H":E=x[3];break;default:throw new Error("Unknwon error correction level: "+h)}if(y<=E)break;S++}if(S>vs.length)throw new Error("Content too long");return S}function i(d){var h=encodeURI(d).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return h.length+(h.length!=d?3:0)}var s=this.options.content,c=n(s,this.options.ecl),u=r(this.options.ecl);this.qrcode=new wt(c,u),this.qrcode.addData(s),this.qrcode.make()}wa.prototype.svg=function(t){var e=this.options||{},r=this.qrcode.modules;typeof t>"u"&&(t={container:e.container||"svg"});for(var n=typeof e.pretty<"u"?!!e.pretty:!0,i=n?" ":"",s=n?`\r +`:"",c=e.width,u=e.height,d=r.length,h=c/(d+2*e.padding),y=u/(d+2*e.padding),S=typeof e.join<"u"?!!e.join:!1,E=typeof e.swap<"u"?!!e.swap:!1,M=typeof e.xmlDeclaration<"u"?!!e.xmlDeclaration:!0,k=typeof e.predefined<"u"?!!e.predefined:!1,x=k?i+''+s:"",O=i+''+s,B="",L="",R=0;R'+s:B+=i+''+s}}S&&(B=i+'');let H="";if(this.options.image!==void 0&&this.options.image.svg){const b=c*this.options.image.width/100,o=u*this.options.image.height/100,l=c/2-b/2,f=u/2-o/2;H+=``,H+=this.options.image.svg+s,H+=""}var q="";switch(t.container){case"svg":M&&(q+=''+s),q+=''+s,q+=x+O+B,q+=H,q+="";break;case"svg-viewbox":M&&(q+=''+s),q+=''+s,q+=x+O+B,q+=H,q+="";break;case"g":q+=''+s,q+=x+O+B,q+=H,q+="";break;default:q+=(x+O+B+H).replace(/^\s+/,"");break}return q};var Al=wa,Nl=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.QRCode=void 0;const Ll=Ke,eo=an,Tl=Nl(Al),xl=t=>{const[e,r]=(0,eo.useState)("");return(0,eo.useEffect)(()=>{var n,i;const s=new Tl.default({content:t.content,background:t.bgColor||"#ffffff",color:t.fgColor||"#000000",container:"svg",ecl:"M",width:(n=t.width)!==null&&n!==void 0?n:256,height:(i=t.height)!==null&&i!==void 0?i:256,padding:0,image:t.image}),c=Buffer.from(s.svg(),"utf8").toString("base64");r(`data:image/svg+xml;base64,${c}`)},[t.bgColor,t.content,t.fgColor,t.height,t.image,t.width]),e?(0,Ll.h)("img",{src:e,alt:"QR Code"}):null};Mn.QRCode=xl;var kn={},qs={};Object.defineProperty(qs,"__esModule",{value:!0});qs.default=".-cbwsdk-css-reset .-cbwsdk-spinner{display:inline-block}.-cbwsdk-css-reset .-cbwsdk-spinner svg{display:inline-block;animation:2s linear infinite -cbwsdk-spinner-svg}.-cbwsdk-css-reset .-cbwsdk-spinner svg circle{animation:1.9s ease-in-out infinite both -cbwsdk-spinner-circle;display:block;fill:rgba(0,0,0,0);stroke-dasharray:283;stroke-dashoffset:280;stroke-linecap:round;stroke-width:10px;transform-origin:50% 50%}@keyframes -cbwsdk-spinner-svg{0%{transform:rotateZ(0deg)}100%{transform:rotateZ(360deg)}}@keyframes -cbwsdk-spinner-circle{0%,25%{stroke-dashoffset:280;transform:rotate(0)}50%,75%{stroke-dashoffset:75;transform:rotate(45deg)}100%{stroke-dashoffset:280;transform:rotate(360deg)}}";var Pl=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(kn,"__esModule",{value:!0});kn.Spinner=void 0;const Jr=Ke,$l=Pl(qs),Ol=t=>{var e;const r=(e=t.size)!==null&&e!==void 0?e:64,n=t.color||"#000";return(0,Jr.h)("div",{class:"-cbwsdk-spinner"},(0,Jr.h)("style",null,$l.default),(0,Jr.h)("svg",{viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",style:{width:r,height:r}},(0,Jr.h)("circle",{style:{cx:50,cy:50,r:45,stroke:n}})))};kn.Spinner=Ol;var Js={};Object.defineProperty(Js,"__esModule",{value:!0});Js.default=".-cbwsdk-css-reset .-cbwsdk-connect-content{height:430px;width:700px;border-radius:12px;padding:30px}.-cbwsdk-css-reset .-cbwsdk-connect-content.light{background:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content.dark{background:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-connect-content-header{display:flex;align-items:center;justify-content:space-between;margin:0 0 30px}.-cbwsdk-css-reset .-cbwsdk-connect-content-heading{font-style:normal;font-weight:500;font-size:28px;line-height:36px;margin:0}.-cbwsdk-css-reset .-cbwsdk-connect-content-heading.light{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-connect-content-heading.dark{color:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content-layout{display:flex;flex-direction:row}.-cbwsdk-css-reset .-cbwsdk-connect-content-column-left{margin-right:30px;display:flex;flex-direction:column;justify-content:space-between}.-cbwsdk-css-reset .-cbwsdk-connect-content-column-right{flex:25%;margin-right:34px}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-wrapper{width:220px;height:220px;border-radius:12px;display:flex;justify-content:center;align-items:center;background:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting{position:absolute;top:0;bottom:0;left:0;right:0;display:flex;flex-direction:column;align-items:center;justify-content:center}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.light{background-color:rgba(255,255,255,.95)}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.light>p{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.dark{background-color:rgba(10,11,13,.9)}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.dark>p{color:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting>p{font-size:12px;font-weight:bold;margin-top:16px}.-cbwsdk-css-reset .-cbwsdk-connect-content-update-app{border-radius:8px;font-size:14px;line-height:20px;padding:12px;width:339px}.-cbwsdk-css-reset .-cbwsdk-connect-content-update-app.light{background:#eef0f3;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-connect-content-update-app.dark{background:#1e2025;color:#8a919e}.-cbwsdk-css-reset .-cbwsdk-cancel-button{-webkit-appearance:none;border:none;background:none;cursor:pointer;padding:0;margin:0}.-cbwsdk-css-reset .-cbwsdk-cancel-button-x{position:relative;display:block;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-wallet-steps{padding:0 0 0 16px;margin:0;width:100%;list-style:decimal}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item{list-style-type:decimal;display:list-item;font-style:normal;font-weight:400;font-size:16px;line-height:24px;margin-top:20px}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item.light{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item.dark{color:#fff}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item-wrapper{display:flex;align-items:center}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-pad-left{margin-left:6px}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon{display:flex;border-radius:50%;height:24px;width:24px}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon svg{margin:auto;display:block}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon.light{background:#0052ff}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon.dark{background:#588af5}.-cbwsdk-css-reset .-cbwsdk-connect-item{align-items:center;display:flex;flex-direction:row;padding:16px 24px;gap:12px;cursor:pointer;border-radius:100px;font-weight:600}.-cbwsdk-css-reset .-cbwsdk-connect-item.light{background:#f5f8ff;color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-connect-item.dark{background:#001033;color:#588af5}.-cbwsdk-css-reset .-cbwsdk-connect-item-copy-wrapper{margin:0 4px 0 8px}.-cbwsdk-css-reset .-cbwsdk-connect-item-title{margin:0 0 0;font-size:16px;line-height:24px;font-weight:500}.-cbwsdk-css-reset .-cbwsdk-connect-item-description{font-weight:400;font-size:14px;line-height:20px;margin:0}";var ya=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(sr,"__esModule",{value:!0});sr.CoinbaseWalletSteps=sr.ConnectContent=void 0;const Dt=ya(Lr),V=Ke,Bl=A,Dl=lr,jl=_n,Fl=En,Hl=Sn,Ul=Mn,Vl=kn,Wl=ya(Js),ws={title:"Coinbase Wallet app",description:"Connect with your self-custody wallet",steps:ba},zl=t=>t==="light"?"#FFFFFF":"#0A0B0D";function ql(t){const{theme:e}=t,r=(0,Bl.createQrUrl)(t.sessionId,t.sessionSecret,t.linkAPIUrl,t.isParentConnection,t.version,t.chainId),n=ws.steps;return(0,V.h)("div",{"data-testid":"connect-content",className:(0,Dt.default)("-cbwsdk-connect-content",e)},(0,V.h)("style",null,Wl.default),(0,V.h)("div",{className:"-cbwsdk-connect-content-header"},(0,V.h)("h2",{className:(0,Dt.default)("-cbwsdk-connect-content-heading",e)},"Scan to connect with our mobile app"),t.onCancel&&(0,V.h)("button",{type:"button",className:"-cbwsdk-cancel-button",onClick:t.onCancel},(0,V.h)(jl.CloseIcon,{fill:e==="light"?"#0A0B0D":"#FFFFFF"}))),(0,V.h)("div",{className:"-cbwsdk-connect-content-layout"},(0,V.h)("div",{className:"-cbwsdk-connect-content-column-left"},(0,V.h)(Jl,{title:ws.title,description:ws.description,theme:e})),(0,V.h)("div",{className:"-cbwsdk-connect-content-column-right"},(0,V.h)("div",{className:"-cbwsdk-connect-content-qr-wrapper"},(0,V.h)(Ul.QRCode,{content:r,width:200,height:200,fgColor:"#000",bgColor:"transparent"}),(0,V.h)("input",{type:"hidden",name:"cbw-cbwsdk-version",value:Dl.LIB_VERSION}),(0,V.h)("input",{type:"hidden",value:r})),(0,V.h)(n,{theme:e}),!t.isConnected&&(0,V.h)("div",{"data-testid":"connecting-spinner",className:(0,Dt.default)("-cbwsdk-connect-content-qr-connecting",e)},(0,V.h)(Vl.Spinner,{size:36,color:e==="dark"?"#FFF":"#000"}),(0,V.h)("p",null,"Connecting...")))))}sr.ConnectContent=ql;function Jl({title:t,description:e,theme:r}){return(0,V.h)("div",{className:(0,Dt.default)("-cbwsdk-connect-item",r)},(0,V.h)("div",null,(0,V.h)(Fl.CoinbaseWalletRound,null)),(0,V.h)("div",{className:"-cbwsdk-connect-item-copy-wrapper"},(0,V.h)("h3",{className:"-cbwsdk-connect-item-title"},t),(0,V.h)("p",{className:"-cbwsdk-connect-item-description"},e)))}function ba({theme:t}){return(0,V.h)("ol",{className:"-cbwsdk-wallet-steps"},(0,V.h)("li",{className:(0,Dt.default)("-cbwsdk-wallet-steps-item",t)},(0,V.h)("div",{className:"-cbwsdk-wallet-steps-item-wrapper"},"Open Coinbase Wallet app")),(0,V.h)("li",{className:(0,Dt.default)("-cbwsdk-wallet-steps-item",t)},(0,V.h)("div",{className:"-cbwsdk-wallet-steps-item-wrapper"},(0,V.h)("span",null,"Tap ",(0,V.h)("strong",null,"Scan")," "),(0,V.h)("span",{className:(0,Dt.default)("-cbwsdk-wallet-steps-pad-left","-cbwsdk-wallet-steps-icon",t)},(0,V.h)(Hl.QRCodeIcon,{fill:zl(t)})))))}sr.CoinbaseWalletSteps=ba;var Rn={},In={};Object.defineProperty(In,"__esModule",{value:!0});In.ArrowLeftIcon=void 0;const to=Ke;function Gl(t){return(0,to.h)("svg",Object.assign({width:"16",height:"16",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},t),(0,to.h)("path",{d:"M8.60675 0.155884L7.37816 1.28209L12.7723 7.16662H0V8.83328H12.6548L6.82149 14.6666L8 15.8451L15.8201 8.02501L8.60675 0.155884Z"}))}In.ArrowLeftIcon=Gl;var Cn={};Object.defineProperty(Cn,"__esModule",{value:!0});Cn.LaptopIcon=void 0;const ys=Ke;function Zl(t){return(0,ys.h)("svg",Object.assign({width:"14",height:"14",viewBox:"0 0 14 14",xmlns:"http://www.w3.org/2000/svg"},t),(0,ys.h)("path",{d:"M1.8001 2.2002H12.2001V9.40019H1.8001V2.2002ZM3.4001 3.8002V7.80019H10.6001V3.8002H3.4001Z"}),(0,ys.h)("path",{d:"M13.4001 10.2002H0.600098C0.600098 11.0838 1.31644 11.8002 2.2001 11.8002H11.8001C12.6838 11.8002 13.4001 11.0838 13.4001 10.2002Z"}))}Cn.LaptopIcon=Zl;var An={};Object.defineProperty(An,"__esModule",{value:!0});An.SafeIcon=void 0;const ro=Ke;function Ql(t){return(0,ro.h)("svg",Object.assign({width:"14",height:"14",viewBox:"0 0 14 14",xmlns:"http://www.w3.org/2000/svg"},t),(0,ro.h)("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M0.600098 0.600098V11.8001H13.4001V0.600098H0.600098ZM7.0001 9.2001C5.3441 9.2001 4.0001 7.8561 4.0001 6.2001C4.0001 4.5441 5.3441 3.2001 7.0001 3.2001C8.6561 3.2001 10.0001 4.5441 10.0001 6.2001C10.0001 7.8561 8.6561 9.2001 7.0001 9.2001ZM0.600098 12.6001H3.8001V13.4001H0.600098V12.6001ZM10.2001 12.6001H13.4001V13.4001H10.2001V12.6001ZM8.8001 6.2001C8.8001 7.19421 7.99421 8.0001 7.0001 8.0001C6.00598 8.0001 5.2001 7.19421 5.2001 6.2001C5.2001 5.20598 6.00598 4.4001 7.0001 4.4001C7.99421 4.4001 8.8001 5.20598 8.8001 6.2001Z"}))}An.SafeIcon=Ql;var Gs={};Object.defineProperty(Gs,"__esModule",{value:!0});Gs.default=".-cbwsdk-css-reset .-cbwsdk-try-extension{display:flex;margin-top:12px;height:202px;width:700px;border-radius:12px;padding:30px}.-cbwsdk-css-reset .-cbwsdk-try-extension.light{background:#fff}.-cbwsdk-css-reset .-cbwsdk-try-extension.dark{background:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-try-extension-column-half{flex:50%}.-cbwsdk-css-reset .-cbwsdk-try-extension-heading{font-style:normal;font-weight:500;font-size:25px;line-height:32px;margin:0;max-width:204px}.-cbwsdk-css-reset .-cbwsdk-try-extension-heading.light{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-try-extension-heading.dark{color:#fff}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta{appearance:none;border:none;background:none;color:#0052ff;cursor:pointer;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta.light{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta.dark{color:#588af5}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta-wrapper{display:flex;align-items:center;margin-top:12px}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta-icon{display:block;margin-left:4px;height:14px}.-cbwsdk-css-reset .-cbwsdk-try-extension-list{display:flex;flex-direction:column;justify-content:center;align-items:center;margin:0;padding:0;list-style:none;height:100%}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item{display:flex;align-items:center;flex-flow:nowrap;margin-top:24px}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item:first-of-type{margin-top:0}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon-wrapper{display:block}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon{display:flex;height:32px;width:32px;border-radius:50%}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon svg{margin:auto;display:block}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon.light{background:#eef0f3}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon.dark{background:#1e2025}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-copy{display:block;font-weight:400;font-size:14px;line-height:20px;padding-left:12px}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-copy.light{color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-copy.dark{color:#8a919e}";var _a=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Rn,"__esModule",{value:!0});Rn.TryExtensionContent=void 0;const Nt=_a(Lr),Be=Ke,bs=an,Kl=In,Xl=Cn,Yl=An,eu=_a(Gs);function tu({theme:t}){const[e,r]=(0,bs.useState)(!1),n=(0,bs.useCallback)(()=>{window.open("https://api.wallet.coinbase.com/rpc/v2/desktop/chrome","_blank")},[]),i=(0,bs.useCallback)(()=>{e?window.location.reload():(n(),r(!0))},[n,e]);return(0,Be.h)("div",{class:(0,Nt.default)("-cbwsdk-try-extension",t)},(0,Be.h)("style",null,eu.default),(0,Be.h)("div",{class:"-cbwsdk-try-extension-column-half"},(0,Be.h)("h3",{class:(0,Nt.default)("-cbwsdk-try-extension-heading",t)},"Or try the Coinbase Wallet browser extension"),(0,Be.h)("div",{class:"-cbwsdk-try-extension-cta-wrapper"},(0,Be.h)("button",{class:(0,Nt.default)("-cbwsdk-try-extension-cta",t),onClick:i},e?"Refresh":"Install"),(0,Be.h)("div",null,!e&&(0,Be.h)(Kl.ArrowLeftIcon,{class:"-cbwsdk-try-extension-cta-icon",fill:t==="light"?"#0052FF":"#588AF5"})))),(0,Be.h)("div",{class:"-cbwsdk-try-extension-column-half"},(0,Be.h)("ul",{class:"-cbwsdk-try-extension-list"},(0,Be.h)("li",{class:"-cbwsdk-try-extension-list-item"},(0,Be.h)("div",{class:"-cbwsdk-try-extension-list-item-icon-wrapper"},(0,Be.h)("span",{class:(0,Nt.default)("-cbwsdk-try-extension-list-item-icon",t)},(0,Be.h)(Xl.LaptopIcon,{fill:t==="light"?"#0A0B0D":"#FFFFFF"}))),(0,Be.h)("div",{class:(0,Nt.default)("-cbwsdk-try-extension-list-item-copy",t)},"Connect with dapps with just one click on your desktop browser")),(0,Be.h)("li",{class:"-cbwsdk-try-extension-list-item"},(0,Be.h)("div",{class:"-cbwsdk-try-extension-list-item-icon-wrapper"},(0,Be.h)("span",{class:(0,Nt.default)("-cbwsdk-try-extension-list-item-icon",t)},(0,Be.h)(Yl.SafeIcon,{fill:t==="light"?"#0A0B0D":"#FFFFFF"}))),(0,Be.h)("div",{class:(0,Nt.default)("-cbwsdk-try-extension-list-item-copy",t)},"Add an additional layer of security by using a supported Ledger hardware wallet")))))}Rn.TryExtensionContent=tu;var Zs={};Object.defineProperty(Zs,"__esModule",{value:!0});Zs.default=".-cbwsdk-css-reset .-cbwsdk-connect-dialog{z-index:2147483647;position:fixed;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop{z-index:2147483647;position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop.light{background-color:rgba(0,0,0,.5)}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop.dark{background-color:rgba(50,53,61,.4)}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-box{display:flex;position:relative;flex-direction:column;transform:scale(1);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-box-hidden{opacity:0;transform:scale(0.85)}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-container{display:block}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-container-hidden{display:none}";var Ea=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bn,"__esModule",{value:!0});bn.ConnectDialog=void 0;const _s=Ea(Lr),Lt=Ke,Es=an,ru=sr,nu=Rn,su=Ea(Zs),iu=t=>{const{isOpen:e,darkMode:r}=t,[n,i]=(0,Es.useState)(!e),[s,c]=(0,Es.useState)(!e);(0,Es.useEffect)(()=>{const d=[window.setTimeout(()=>{c(!e)},10)];return e?i(!1):d.push(window.setTimeout(()=>{i(!0)},360)),()=>{d.forEach(window.clearTimeout)}},[e]);const u=r?"dark":"light";return(0,Lt.h)("div",{class:(0,_s.default)("-cbwsdk-connect-dialog-container",n&&"-cbwsdk-connect-dialog-container-hidden")},(0,Lt.h)("style",null,su.default),(0,Lt.h)("div",{class:(0,_s.default)("-cbwsdk-connect-dialog-backdrop",u,s&&"-cbwsdk-connect-dialog-backdrop-hidden")}),(0,Lt.h)("div",{class:"-cbwsdk-connect-dialog"},(0,Lt.h)("div",{class:(0,_s.default)("-cbwsdk-connect-dialog-box",s&&"-cbwsdk-connect-dialog-box-hidden")},t.connectDisabled?null:(0,Lt.h)(ru.ConnectContent,{theme:u,version:t.version,sessionId:t.sessionId,sessionSecret:t.sessionSecret,linkAPIUrl:t.linkAPIUrl,isConnected:t.isConnected,isParentConnection:t.isParentConnection,chainId:t.chainId,onCancel:t.onCancel}),(0,Lt.h)(nu.TryExtensionContent,{theme:u}))))};bn.ConnectDialog=iu;Object.defineProperty(yn,"__esModule",{value:!0});yn.LinkFlow=void 0;const Ss=Ke,ou=bn;class au{constructor(e){this.connected=!1,this.chainId=1,this.isOpen=!1,this.onCancel=null,this.root=null,this.connectDisabled=!1,this.darkMode=e.darkMode,this.version=e.version,this.sessionId=e.sessionId,this.sessionSecret=e.sessionSecret,this.linkAPIUrl=e.linkAPIUrl,this.isParentConnection=e.isParentConnection}attach(e){this.root=document.createElement("div"),this.root.className="-cbwsdk-link-flow-root",e.appendChild(this.root),this.render()}setConnected(e){this.connected!==e&&(this.connected=e,this.render())}setChainId(e){this.chainId!==e&&(this.chainId=e,this.render())}detach(){var e;this.root&&((0,Ss.render)(null,this.root),(e=this.root.parentElement)===null||e===void 0||e.removeChild(this.root))}setConnectDisabled(e){this.connectDisabled=e}open(e){this.isOpen=!0,this.onCancel=e.onCancel,this.render()}close(){this.isOpen=!1,this.onCancel=null,this.render()}render(){this.root&&(0,Ss.render)((0,Ss.h)(ou.ConnectDialog,{darkMode:this.darkMode,version:this.version,sessionId:this.sessionId,sessionSecret:this.sessionSecret,linkAPIUrl:this.linkAPIUrl,isOpen:this.isOpen,isConnected:this.connected,isParentConnection:this.isParentConnection,chainId:this.chainId,onCancel:this.onCancel,connectDisabled:this.connectDisabled}),this.root)}}yn.LinkFlow=au;var Qs={},Ks={};Object.defineProperty(Ks,"__esModule",{value:!0});Ks.default=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}";(function(t){var e=T&&T.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(t,"__esModule",{value:!0}),t.SnackbarInstance=t.SnackbarContainer=t.Snackbar=void 0;const r=e(Lr),n=Ke,i=an,s=e(Ks),c="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",u="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class d{constructor(E){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=E.darkMode}attach(E){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",E.appendChild(this.root),this.render()}presentItem(E){const M=this.nextItemKey++;return this.items.set(M,E),this.render(),()=>{this.items.delete(M),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,n.render)((0,n.h)("div",null,(0,n.h)(t.SnackbarContainer,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([E,M])=>(0,n.h)(t.SnackbarInstance,Object.assign({},M,{key:E}))))),this.root)}}t.Snackbar=d;const h=S=>(0,n.h)("div",{class:(0,r.default)("-cbwsdk-snackbar-container")},(0,n.h)("style",null,s.default),(0,n.h)("div",{class:"-cbwsdk-snackbar"},S.children));t.SnackbarContainer=h;const y=({autoExpand:S,message:E,menuItems:M})=>{const[k,x]=(0,i.useState)(!0),[O,B]=(0,i.useState)(S??!1);(0,i.useEffect)(()=>{const R=[window.setTimeout(()=>{x(!1)},1),window.setTimeout(()=>{B(!0)},1e4)];return()=>{R.forEach(window.clearTimeout)}});const L=()=>{B(!O)};return(0,n.h)("div",{class:(0,r.default)("-cbwsdk-snackbar-instance",k&&"-cbwsdk-snackbar-instance-hidden",O&&"-cbwsdk-snackbar-instance-expanded")},(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:L},(0,n.h)("img",{src:c,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},E),(0,n.h)("div",{class:"-gear-container"},!O&&(0,n.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,n.h)("img",{src:u,class:"-gear-icon",title:"Expand"}))),M&&M.length>0&&(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-menu"},M.map((R,z)=>(0,n.h)("div",{class:(0,r.default)("-cbwsdk-snackbar-instance-menu-item",R.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:R.onClick,key:z},(0,n.h)("svg",{width:R.svgWidth,height:R.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("path",{"fill-rule":R.defaultFillRule,"clip-rule":R.defaultClipRule,d:R.path,fill:"#AAAAAA"})),(0,n.h)("span",{class:(0,r.default)("-cbwsdk-snackbar-instance-menu-item-info",R.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},R.info)))))};t.SnackbarInstance=y})(Qs);Object.defineProperty(Ar,"__esModule",{value:!0});Ar.WalletLinkRelayUI=void 0;const cu=Nr,lu=yn,uu=Qs;class du{constructor(e){this.standalone=null,this.attached=!1,this.snackbar=new uu.Snackbar({darkMode:e.darkMode}),this.linkFlow=new lu.LinkFlow({darkMode:e.darkMode,version:e.version,sessionId:e.session.id,sessionSecret:e.session.secret,linkAPIUrl:e.linkAPIUrl,isParentConnection:!1})}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,r=document.createElement("div");r.className="-cbwsdk-css-reset",e.appendChild(r),this.linkFlow.attach(r),this.snackbar.attach(r),this.attached=!0,(0,cu.injectCssReset)()}setConnected(e){this.linkFlow.setConnected(e)}setChainId(e){this.linkFlow.setChainId(e)}setConnectDisabled(e){this.linkFlow.setConnectDisabled(e)}addEthereumChain(){}watchAsset(){}switchEthereumChain(){}requestEthereumAccounts(e){this.linkFlow.open({onCancel:e.onCancel})}hideRequestEthereumAccounts(){this.linkFlow.close()}signEthereumMessage(){}signEthereumTransaction(){}submitEthereumTransaction(){}ethereumAddressFromSignedMessage(){}showConnecting(e){let r;return e.isUnlinkedErrorState?r={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:r={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(r)}reloadUI(){document.location.reload()}inlineAccountsResponse(){return!1}inlineAddEthereumChain(){return!1}inlineWatchAsset(){return!1}inlineSwitchEthereumChain(){return!1}setStandalone(e){this.standalone=e}isStandalone(){var e;return(e=this.standalone)!==null&&e!==void 0?e:!1}}Ar.WalletLinkRelayUI=du;Object.defineProperty(Cr,"__esModule",{value:!0});Cr.WalletLinkRelay=void 0;const Jt=Sr,hu=De,Q=A,Tt=ur,no=it,kt=dr,fu=mn,xt=cr,gu=Ar;class Et extends no.RelayAbstract{constructor(e){var r;super(),this.accountsCallback=null,this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.chainCallback=null,this.dappDefaultChain=1,this.appName="",this.appLogoUrl=null,this.linkedUpdated=c=>{var u;this.isLinked=c;const d=this.storage.getItem(no.LOCAL_STORAGE_ADDRESSES_KEY);if(c&&(this.session.linked=c),this.isUnlinkedErrorState=!1,d){const h=d.split(" "),y=this.storage.getItem("IsStandaloneSigning")==="true";if(h[0]!==""&&!c&&this.session.linked&&!y){this.isUnlinkedErrorState=!0;const S=this.getSessionIdHash();(u=this.diagnostic)===null||u===void 0||u.log(Tt.EVENTS.UNLINKED_ERROR_STATE,{sessionIdHash:S})}}},this.metadataUpdated=(c,u)=>{this.storage.setItem(c,u)},this.chainUpdated=(c,u)=>{this.chainCallbackParams.chainId===c&&this.chainCallbackParams.jsonRpcUrl===u||(this.chainCallbackParams={chainId:c,jsonRpcUrl:u},this.chainCallback&&this.chainCallback(c,u))},this.accountUpdated=c=>{this.accountsCallback&&this.accountsCallback([c]),Et.accountRequestCallbackIds.size>0&&(Array.from(Et.accountRequestCallbackIds.values()).forEach(u=>{const d={type:"WEB3_RESPONSE",id:u,response:{method:"requestEthereumAccounts",result:[c]}};this.invokeCallback(Object.assign(Object.assign({},d),{id:u}))}),Et.accountRequestCallbackIds.clear())},this.connectedUpdated=c=>{this.ui.setConnected(c)},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage,this.options=e;const{session:n,ui:i,connection:s}=this.subscribe();this._session=n,this.connection=s,this.relayEventManager=e.relayEventManager,this.diagnostic=e.diagnosticLogger,this._reloadOnDisconnect=(r=e.reloadOnDisconnect)!==null&&r!==void 0?r:!0,this.ui=i}subscribe(){const e=kt.Session.load(this.storage)||new kt.Session(this.storage).save(),{linkAPIUrl:r,diagnostic:n}=this,i=new fu.WalletLinkConnection({session:e,linkAPIUrl:r,diagnostic:n,listener:this}),{version:s,darkMode:c}=this.options,u=this.options.uiConstructor({linkAPIUrl:r,version:s,darkMode:c,session:e});return i.connect(),{session:e,ui:u,connection:i}}attachUI(){this.ui.attach()}resetAndReload(){Promise.race([this.connection.setSessionMetadata("__destroyed","1"),new Promise(e=>setTimeout(()=>e(null),1e3))]).then(()=>{var e,r;const n=this.ui.isStandalone();(e=this.diagnostic)===null||e===void 0||e.log(Tt.EVENTS.SESSION_STATE_CHANGE,{method:"relay::resetAndReload",sessionMetadataChange:"__destroyed, 1",sessionIdHash:this.getSessionIdHash()}),this.connection.destroy();const i=kt.Session.load(this.storage);if((i==null?void 0:i.id)===this._session.id?this.storage.clear():i&&((r=this.diagnostic)===null||r===void 0||r.log(Tt.EVENTS.SKIPPED_CLEARING_SESSION,{sessionIdHash:this.getSessionIdHash(),storedSessionIdHash:kt.Session.hash(i.id)})),this._reloadOnDisconnect){this.ui.reloadUI();return}this.accountsCallback&&this.accountsCallback([],!0);const{session:s,ui:c,connection:u}=this.subscribe();this._session=s,this.connection=u,this.ui=c,n&&this.ui.setStandalone&&this.ui.setStandalone(!0),this.options.headlessMode||this.attachUI()}).catch(e=>{var r;(r=this.diagnostic)===null||r===void 0||r.log(Tt.EVENTS.FAILURE,{method:"relay::resetAndReload",message:`failed to reset and reload with ${e}`,sessionIdHash:this.getSessionIdHash()})})}setAppInfo(e,r){this.appName=e,this.appLogoUrl=r}getStorageItem(e){return this.storage.getItem(e)}get session(){return this._session}setStorageItem(e,r){this.storage.setItem(e,r)}signEthereumMessage(e,r,n,i){return this.sendRequest({method:"signEthereumMessage",params:{message:(0,Q.hexStringFromBuffer)(e,!0),address:r,addPrefix:n,typedDataJson:i||null}})}ethereumAddressFromSignedMessage(e,r,n){return this.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:(0,Q.hexStringFromBuffer)(e,!0),signature:(0,Q.hexStringFromBuffer)(r,!0),addPrefix:n}})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,Q.bigIntStringFromBN)(e.weiValue),data:(0,Q.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,Q.bigIntStringFromBN)(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?(0,Q.bigIntStringFromBN)(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?(0,Q.bigIntStringFromBN)(e.gasPriceInWei):null,gasLimit:e.gasLimit?(0,Q.bigIntStringFromBN)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,Q.bigIntStringFromBN)(e.weiValue),data:(0,Q.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,Q.bigIntStringFromBN)(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?(0,Q.bigIntStringFromBN)(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?(0,Q.bigIntStringFromBN)(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?(0,Q.bigIntStringFromBN)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,r){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:(0,Q.hexStringFromBuffer)(e,!0),chainId:r}})}scanQRCode(e){return this.sendRequest({method:"scanQRCode",params:{regExp:e}})}getQRCodeUrl(){return(0,Q.createQrUrl)(this._session.id,this._session.secret,this.linkAPIUrl,!1,this.options.version,this.dappDefaultChain)}genericRequest(e,r){return this.sendRequest({method:"generic",params:{action:r,data:e}})}sendGenericMessage(e){return this.sendRequest(e)}sendRequest(e){let r=null;const n=(0,Q.randomBytesHex)(8),i=c=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,e.method,c),r==null||r()};return{promise:new Promise((c,u)=>{this.ui.isStandalone()||(r=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload})),this.relayEventManager.callbacks.set(n,d=>{if(r==null||r(),(0,xt.isErrorResponse)(d))return u(new Error(d.errorMessage));c(d)}),this.ui.isStandalone()?this.sendRequestStandalone(n,e):this.publishWeb3RequestEvent(n,e)}),cancel:i}}setConnectDisabled(e){this.ui.setConnectDisabled(e)}setAccountsCallback(e){this.accountsCallback=e}setChainCallback(e){this.chainCallback=e}setDappDefaultChainCallback(e){this.dappDefaultChain=e,this.ui instanceof gu.WalletLinkRelayUI&&this.ui.setChainId(e)}publishWeb3RequestEvent(e,r){var n;const i={type:"WEB3_REQUEST",id:e,request:r},s=kt.Session.load(this.storage);(n=this.diagnostic)===null||n===void 0||n.log(Tt.EVENTS.WEB3_REQUEST,{eventId:i.id,method:`relay::${r.method}`,sessionIdHash:this.getSessionIdHash(),storedSessionIdHash:s?kt.Session.hash(s.id):"",isSessionMismatched:((s==null?void 0:s.id)!==this._session.id).toString()}),this.publishEvent("Web3Request",i,!0).then(c=>{var u;(u=this.diagnostic)===null||u===void 0||u.log(Tt.EVENTS.WEB3_REQUEST_PUBLISHED,{eventId:i.id,method:`relay::${r.method}`,sessionIdHash:this.getSessionIdHash(),storedSessionIdHash:s?kt.Session.hash(s.id):"",isSessionMismatched:((s==null?void 0:s.id)!==this._session.id).toString()})}).catch(c=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:i.id,response:{method:r.method,errorMessage:c.message}})})}publishWeb3RequestCanceledEvent(e){const r={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",r,!1).then()}publishEvent(e,r,n){return this.connection.publishEvent(e,r,n)}handleWeb3ResponseMessage(e){var r;const{response:n}=e;if((r=this.diagnostic)===null||r===void 0||r.log(Tt.EVENTS.WEB3_RESPONSE,{eventId:e.id,method:`relay::${n.method}`,sessionIdHash:this.getSessionIdHash()}),n.method==="requestEthereumAccounts"){Et.accountRequestCallbackIds.forEach(i=>this.invokeCallback(Object.assign(Object.assign({},e),{id:i}))),Et.accountRequestCallbackIds.clear();return}this.invokeCallback(e)}handleErrorResponse(e,r,n,i){var s;const c=(s=n==null?void 0:n.message)!==null&&s!==void 0?s:(0,Jt.getMessageFromCode)(i);this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:e,response:{method:r,errorMessage:c,errorCode:i}})}invokeCallback(e){const r=this.relayEventManager.callbacks.get(e.id);r&&(r(e.response),this.relayEventManager.callbacks.delete(e.id))}requestEthereumAccounts(){const e={method:"requestEthereumAccounts",params:{appName:this.appName,appLogoUrl:this.appLogoUrl||null}},r=(0,Q.randomBytesHex)(8),n=s=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,e.method,s)};return{promise:new Promise((s,c)=>{if(this.relayEventManager.callbacks.set(r,u=>{if(this.ui.hideRequestEthereumAccounts(),(0,xt.isErrorResponse)(u))return c(new Error(u.errorMessage));s(u)}),this.ui.inlineAccountsResponse()){const u=d=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:r,response:{method:"requestEthereumAccounts",result:d}})};this.ui.requestEthereumAccounts({onCancel:n,onAccounts:u})}else{const u=Jt.standardErrors.provider.userRejectedRequest("User denied account authorization");this.ui.requestEthereumAccounts({onCancel:()=>n(u)})}Et.accountRequestCallbackIds.add(r),!this.ui.inlineAccountsResponse()&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(r,e)}),cancel:n}}selectProvider(e){const r={method:"selectProvider",params:{providerOptions:e}},n=(0,Q.randomBytesHex)(8),i=c=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,r.method,c)},s=new Promise((c,u)=>{this.relayEventManager.callbacks.set(n,y=>{if((0,xt.isErrorResponse)(y))return u(new Error(y.errorMessage));c(y)});const d=y=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:n,response:{method:"selectProvider",result:hu.ProviderType.Unselected}})},h=y=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:n,response:{method:"selectProvider",result:y}})};this.ui.selectProvider&&this.ui.selectProvider({onApprove:h,onCancel:d,providerOptions:e})});return{cancel:i,promise:s}}watchAsset(e,r,n,i,s,c){const u={method:"watchAsset",params:{type:e,options:{address:r,symbol:n,decimals:i,image:s},chainId:c}};let d=null;const h=(0,Q.randomBytesHex)(8),y=E=>{this.publishWeb3RequestCanceledEvent(h),this.handleErrorResponse(h,u.method,E),d==null||d()};this.ui.inlineWatchAsset()||(d=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:y,onResetConnection:this.resetAndReload}));const S=new Promise((E,M)=>{this.relayEventManager.callbacks.set(h,O=>{if(d==null||d(),(0,xt.isErrorResponse)(O))return M(new Error(O.errorMessage));E(O)});const k=O=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"watchAsset",result:!1}})},x=()=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"watchAsset",result:!0}})};this.ui.inlineWatchAsset()&&this.ui.watchAsset({onApprove:x,onCancel:k,type:e,address:r,symbol:n,decimals:i,image:s,chainId:c}),!this.ui.inlineWatchAsset()&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(h,u)});return{cancel:y,promise:S}}addEthereumChain(e,r,n,i,s,c){const u={method:"addEthereumChain",params:{chainId:e,rpcUrls:r,blockExplorerUrls:i,chainName:s,iconUrls:n,nativeCurrency:c}};let d=null;const h=(0,Q.randomBytesHex)(8),y=E=>{this.publishWeb3RequestCanceledEvent(h),this.handleErrorResponse(h,u.method,E),d==null||d()};return this.ui.inlineAddEthereumChain(e)||(d=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:y,onResetConnection:this.resetAndReload})),{promise:new Promise((E,M)=>{this.relayEventManager.callbacks.set(h,O=>{if(d==null||d(),(0,xt.isErrorResponse)(O))return M(new Error(O.errorMessage));E(O)});const k=O=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"addEthereumChain",result:{isApproved:!1,rpcUrl:""}}})},x=O=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"addEthereumChain",result:{isApproved:!0,rpcUrl:O}}})};this.ui.inlineAddEthereumChain(e)&&this.ui.addEthereumChain({onCancel:k,onApprove:x,chainId:u.params.chainId,rpcUrls:u.params.rpcUrls,blockExplorerUrls:u.params.blockExplorerUrls,chainName:u.params.chainName,iconUrls:u.params.iconUrls,nativeCurrency:u.params.nativeCurrency}),!this.ui.inlineAddEthereumChain(e)&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(h,u)}),cancel:y}}switchEthereumChain(e,r){const n={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:r})},i=(0,Q.randomBytesHex)(8),s=u=>{this.publishWeb3RequestCanceledEvent(i),this.handleErrorResponse(i,n.method,u)};return{promise:new Promise((u,d)=>{this.relayEventManager.callbacks.set(i,S=>{if((0,xt.isErrorResponse)(S)&&S.errorCode)return d(Jt.standardErrors.provider.custom({code:S.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if((0,xt.isErrorResponse)(S))return d(new Error(S.errorMessage));u(S)});const h=S=>{var E;if(S){const M=(E=(0,Jt.getErrorCode)(S))!==null&&E!==void 0?E:Jt.standardErrorCodes.provider.unsupportedChain;this.handleErrorResponse(i,"switchEthereumChain",S instanceof Error?S:Jt.standardErrors.provider.unsupportedChain(e),M)}else this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:i,response:{method:"switchEthereumChain",result:{isApproved:!1,rpcUrl:""}}})},y=S=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:i,response:{method:"switchEthereumChain",result:{isApproved:!0,rpcUrl:S}}})};this.ui.switchEthereumChain({onCancel:h,onApprove:y,chainId:n.params.chainId,address:n.params.address}),!this.ui.inlineSwitchEthereumChain()&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(i,n)}),cancel:s}}inlineAddEthereumChain(e){return this.ui.inlineAddEthereumChain(e)}getSessionIdHash(){return kt.Session.hash(this._session.id)}sendRequestStandalone(e,r){const n=s=>{this.handleErrorResponse(e,r.method,s)},i=s=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:e,response:s})};switch(r.method){case"signEthereumMessage":this.ui.signEthereumMessage({request:r,onSuccess:i,onCancel:n});break;case"signEthereumTransaction":this.ui.signEthereumTransaction({request:r,onSuccess:i,onCancel:n});break;case"submitEthereumTransaction":this.ui.submitEthereumTransaction({request:r,onSuccess:i,onCancel:n});break;case"ethereumAddressFromSignedMessage":this.ui.ethereumAddressFromSignedMessage({request:r,onSuccess:i});break;default:n();break}}}Cr.WalletLinkRelay=Et;Et.accountRequestCallbackIds=new Set;var Tr={},Nn={},Sa={};(function(t){var e=T&&T.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s);var u=Object.getOwnPropertyDescriptor(i,s);(!u||("get"in u?!i.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(n,c,u)}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=T&&T.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Qs,t)})(Sa);var Xs={};Object.defineProperty(Xs,"__esModule",{value:!0});Xs.default=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";var Ma=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Nn,"__esModule",{value:!0});Nn.RedirectDialog=void 0;const pu=Ma(Lr),mt=Ke,mu=Nr,vu=Sa,wu=Ma(Xs);class yu{constructor(){this.root=null}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),(0,mu.injectCssReset)()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&((0,mt.render)(null,this.root),e&&(0,mt.render)((0,mt.h)(bu,Object.assign({},e,{onDismiss:()=>{this.clear()}})),this.root))}}Nn.RedirectDialog=yu;const bu=({title:t,buttonText:e,darkMode:r,onButtonClick:n,onDismiss:i})=>{const s=r?"dark":"light";return(0,mt.h)(vu.SnackbarContainer,{darkMode:r},(0,mt.h)("div",{class:"-cbwsdk-redirect-dialog"},(0,mt.h)("style",null,wu.default),(0,mt.h)("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),(0,mt.h)("div",{class:(0,pu.default)("-cbwsdk-redirect-dialog-box",s)},(0,mt.h)("p",null,t),(0,mt.h)("button",{onClick:n},e))))};Object.defineProperty(Tr,"__esModule",{value:!0});Tr.MobileRelayUI=void 0;const _u=Nn;class Eu{constructor(e){this.attached=!1,this.darkMode=!1,this.redirectDialog=new _u.RedirectDialog,this.darkMode=e.darkMode}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}setConnected(e){}redirectToCoinbaseWallet(e){const r=new URL("https://go.cb-w.com/walletlink");r.searchParams.append("redirect_url",window.location.href),e&&r.searchParams.append("wl_url",e);const n=document.createElement("a");n.target="cbw-opener",n.href=r.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",darkMode:this.darkMode,onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}hideRequestEthereumAccounts(){this.redirectDialog.clear()}requestEthereumAccounts(){}addEthereumChain(){}watchAsset(){}selectProvider(){}switchEthereumChain(){}signEthereumMessage(){}signEthereumTransaction(){}submitEthereumTransaction(){}ethereumAddressFromSignedMessage(){}reloadUI(){}setStandalone(){}setConnectDisabled(){}inlineAccountsResponse(){return!1}inlineAddEthereumChain(){return!1}inlineWatchAsset(){return!1}inlineSwitchEthereumChain(){return!1}isStandalone(){return!1}}Tr.MobileRelayUI=Eu;Object.defineProperty(Ir,"__esModule",{value:!0});Ir.MobileRelay=void 0;const Su=A,Mu=Cr,ku=Tr;class Ru extends Mu.WalletLinkRelay{constructor(e){var r;super(e),this._enableMobileWalletLink=(r=e.enableMobileWalletLink)!==null&&r!==void 0?r:!1}requestEthereumAccounts(){return this._enableMobileWalletLink?super.requestEthereumAccounts():{promise:new Promise(()=>{const e=(0,Su.getLocation)();e.href=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(e.href)}`}),cancel:()=>{}}}publishWeb3RequestEvent(e,r){if(super.publishWeb3RequestEvent(e,r),!(this._enableMobileWalletLink&&this.ui instanceof ku.MobileRelayUI))return;let n=!1;switch(r.method){case"requestEthereumAccounts":case"connectAndSignIn":n=!0,this.ui.openCoinbaseWalletDeeplink(this.getQRCodeUrl());break;case"switchEthereumChain":return;default:n=!0,this.ui.openCoinbaseWalletDeeplink();break}n&&window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0})}handleWeb3ResponseMessage(e){super.handleWeb3ResponseMessage(e)}connectAndSignIn(e){if(!this._enableMobileWalletLink)throw new Error("connectAndSignIn is supported only when enableMobileWalletLink is on");return this.sendRequest({method:"connectAndSignIn",params:{appName:this.appName,appLogoUrl:this.appLogoUrl,domain:window.location.hostname,aud:window.location.href,version:"1",type:"eip4361",nonce:e.nonce,iat:new Date().toISOString(),chainId:`eip155:${this.dappDefaultChain}`,statement:e.statement,resources:e.resources}})}}Ir.MobileRelay=Ru;const Iu=Bc,Cu=un;function ka(t){return Buffer.allocUnsafe(t).fill(0)}function Ra(t,e,r){const n=ka(e);return t=Ln(t),r?t.length"u")throw new Error("Not an array?");if(r=La(t),r!=="dynamic"&&r!==0&&e.length>r)throw new Error("Elements exceed array size: "+r);i=[],t=t.slice(0,t.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(s in e)i.push(pt(t,e[s]));if(r==="dynamic"){var c=pt("uint256",e.length);i.unshift(c)}return Buffer.concat(i)}else{if(t==="bytes")return e=new Buffer(e),i=Buffer.concat([pt("uint256",e.length),e]),e.length%32!==0&&(i=Buffer.concat([i,jt.zeros(32-e.length%32)])),i;if(t.startsWith("bytes")){if(r=Yt(t),r<1||r>32)throw new Error("Invalid bytes width: "+r);return jt.setLengthRight(e,32)}else if(t.startsWith("uint")){if(r=Yt(t),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);if(n=Pt(e),n.bitLength()>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+n.bitLength());if(n<0)throw new Error("Supplied uint is negative");return n.toArrayLike(Buffer,"be",32)}else if(t.startsWith("int")){if(r=Yt(t),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);if(n=Pt(e),n.bitLength()>r)throw new Error("Supplied int exceeds width: "+r+" vs "+n.bitLength());return n.toTwos(256).toArrayLike(Buffer,"be",32)}else if(t.startsWith("ufixed")){if(r=so(t),n=Pt(e),n<0)throw new Error("Supplied ufixed is negative");return pt("uint256",n.mul(new Ot(2).pow(new Ot(r[1]))))}else if(t.startsWith("fixed"))return r=so(t),pt("int256",Pt(e).mul(new Ot(2).pow(new Ot(r[1]))))}throw new Error("Unsupported or invalid type: "+t)}function xu(t){return t==="string"||t==="bytes"||La(t)==="dynamic"}function Pu(t){return t.lastIndexOf("]")===t.length-1}function $u(t,e){var r=[],n=[],i=32*t.length;for(var s in t){var c=Na(t[s]),u=e[s],d=pt(c,u);xu(c)?(r.push(pt("uint256",i)),n.push(d),i+=d.length):r.push(d)}return Buffer.concat(r.concat(n))}function Ta(t,e){if(t.length!==e.length)throw new Error("Number of types are not matching the values");for(var r,n,i=[],s=0;s32)throw new Error("Invalid bytes width: "+r);i.push(jt.setLengthRight(u,r))}else if(c.startsWith("uint")){if(r=Yt(c),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);if(n=Pt(u),n.bitLength()>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+n.bitLength());i.push(n.toArrayLike(Buffer,"be",r/8))}else if(c.startsWith("int")){if(r=Yt(c),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);if(n=Pt(u),n.bitLength()>r)throw new Error("Supplied int exceeds width: "+r+" vs "+n.bitLength());i.push(n.toTwos(r).toArrayLike(Buffer,"be",r/8))}else throw new Error("Unsupported or invalid type: "+c)}return Buffer.concat(i)}function Ou(t,e){return jt.keccak(Ta(t,e))}var Bu={rawEncode:$u,solidityPack:Ta,soliditySHA3:Ou};const lt=Aa,yr=Bu,xa={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},Ms={encodeData(t,e,r,n=!0){const i=["bytes32"],s=[this.hashType(t,r)];if(n){const c=(u,d,h)=>{if(r[d]!==void 0)return["bytes32",h==null?"0x0000000000000000000000000000000000000000000000000000000000000000":lt.keccak(this.encodeData(d,h,r,n))];if(h===void 0)throw new Error(`missing value for field ${u} of type ${d}`);if(d==="bytes")return["bytes32",lt.keccak(h)];if(d==="string")return typeof h=="string"&&(h=Buffer.from(h,"utf8")),["bytes32",lt.keccak(h)];if(d.lastIndexOf("]")===d.length-1){const y=d.slice(0,d.lastIndexOf("[")),S=h.map(E=>c(u,y,E));return["bytes32",lt.keccak(yr.rawEncode(S.map(([E])=>E),S.map(([,E])=>E)))]}return[d,h]};for(const u of r[t]){const[d,h]=c(u.name,u.type,e[u.name]);i.push(d),s.push(h)}}else for(const c of r[t]){let u=e[c.name];if(u!==void 0)if(c.type==="bytes")i.push("bytes32"),u=lt.keccak(u),s.push(u);else if(c.type==="string")i.push("bytes32"),typeof u=="string"&&(u=Buffer.from(u,"utf8")),u=lt.keccak(u),s.push(u);else if(r[c.type]!==void 0)i.push("bytes32"),u=lt.keccak(this.encodeData(c.type,u,r,n)),s.push(u);else{if(c.type.lastIndexOf("]")===c.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(c.type),s.push(u)}}return yr.rawEncode(i,s)},encodeType(t,e){let r="",n=this.findTypeDependencies(t,e).filter(i=>i!==t);n=[t].concat(n.sort());for(const i of n){if(!e[i])throw new Error("No type definition specified: "+i);r+=i+"("+e[i].map(({name:c,type:u})=>u+" "+c).join(",")+")"}return r},findTypeDependencies(t,e,r=[]){if(t=t.match(/^\w*/)[0],r.includes(t)||e[t]===void 0)return r;r.push(t);for(const n of e[t])for(const i of this.findTypeDependencies(n.type,e,r))!r.includes(i)&&r.push(i);return r},hashStruct(t,e,r,n=!0){return lt.keccak(this.encodeData(t,e,r,n))},hashType(t,e){return lt.keccak(this.encodeType(t,e))},sanitizeData(t){const e={};for(const r in xa.properties)t[r]&&(e[r]=t[r]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(t,e=!0){const r=this.sanitizeData(t),n=[Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",r.domain,r.types,e)),r.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(r.primaryType,r.message,r.types,e)),lt.keccak(Buffer.concat(n))}};var Du={TYPED_MESSAGE_SCHEMA:xa,TypedDataUtils:Ms,hashForSignTypedDataLegacy:function(t){return ju(t.data)},hashForSignTypedData_v3:function(t){return Ms.hash(t.data,!1)},hashForSignTypedData_v4:function(t){return Ms.hash(t.data)}};function ju(t){const e=new Error("Expect argument to be non-empty array");if(typeof t!="object"||!t.length)throw e;const r=t.map(function(s){return s.type==="bytes"?lt.toBuffer(s.value):s.value}),n=t.map(function(s){return s.type}),i=t.map(function(s){if(!s.name)throw e;return s.type+" "+s.name});return yr.soliditySHA3(["bytes32","bytes32"],[yr.soliditySHA3(new Array(t.length).fill("string"),i),yr.soliditySHA3(n,r)])}var ir={};Object.defineProperty(ir,"__esModule",{value:!0});ir.filterFromParam=ir.FilterPolyfill=void 0;const Qt=De,Je=A,Fu=5*60*1e3,$t={jsonrpc:"2.0",id:0};class Hu{constructor(e){this.logFilters=new Map,this.blockFilters=new Set,this.pendingTransactionFilters=new Set,this.cursors=new Map,this.timeouts=new Map,this.nextFilterId=(0,Qt.IntNumber)(1),this.REQUEST_THROTTLE_INTERVAL=1e3,this.lastFetchTimestamp=new Date(0),this.resolvers=[],this.provider=e}async newFilter(e){const r=Pa(e),n=this.makeFilterId(),i=await this.setInitialCursorPosition(n,r.fromBlock);return console.info(`Installing new log filter(${n}):`,r,"initial cursor position:",i),this.logFilters.set(n,r),this.setFilterTimeout(n),(0,Je.hexStringFromIntNumber)(n)}async newBlockFilter(){const e=this.makeFilterId(),r=await this.setInitialCursorPosition(e,"latest");return console.info(`Installing new block filter (${e}) with initial cursor position:`,r),this.blockFilters.add(e),this.setFilterTimeout(e),(0,Je.hexStringFromIntNumber)(e)}async newPendingTransactionFilter(){const e=this.makeFilterId(),r=await this.setInitialCursorPosition(e,"latest");return console.info(`Installing new block filter (${e}) with initial cursor position:`,r),this.pendingTransactionFilters.add(e),this.setFilterTimeout(e),(0,Je.hexStringFromIntNumber)(e)}uninstallFilter(e){const r=(0,Je.intNumberFromHexString)(e);return console.info(`Uninstalling filter (${r})`),this.deleteFilter(r),!0}getFilterChanges(e){const r=(0,Je.intNumberFromHexString)(e);return this.timeouts.has(r)&&this.setFilterTimeout(r),this.logFilters.has(r)?this.getLogFilterChanges(r):this.blockFilters.has(r)?this.getBlockFilterChanges(r):this.pendingTransactionFilters.has(r)?this.getPendingTransactionFilterChanges(r):Promise.resolve(Gr())}async getFilterLogs(e){const r=(0,Je.intNumberFromHexString)(e),n=this.logFilters.get(r);return n?this.sendAsyncPromise(Object.assign(Object.assign({},$t),{method:"eth_getLogs",params:[io(n)]})):Gr()}makeFilterId(){return(0,Qt.IntNumber)(++this.nextFilterId)}sendAsyncPromise(e){return new Promise((r,n)=>{this.provider.sendAsync(e,(i,s)=>{if(i)return n(i);if(Array.isArray(s)||s==null)return n(new Error(`unexpected response received: ${JSON.stringify(s)}`));r(s)})})}deleteFilter(e){console.info(`Deleting filter (${e})`),this.logFilters.delete(e),this.blockFilters.delete(e),this.pendingTransactionFilters.delete(e),this.cursors.delete(e),this.timeouts.delete(e)}async getLogFilterChanges(e){const r=this.logFilters.get(e),n=this.cursors.get(e);if(!n||!r)return Gr();const i=await this.getCurrentBlockHeight(),s=r.toBlock==="latest"?i:r.toBlock;if(n>i||n>Number(r.toBlock))return Zr();console.info(`Fetching logs from ${n} to ${s} for filter ${e}`);const c=await this.sendAsyncPromise(Object.assign(Object.assign({},$t),{method:"eth_getLogs",params:[io(Object.assign(Object.assign({},r),{fromBlock:n,toBlock:s}))]}));if(Array.isArray(c.result)){const u=c.result.map(h=>(0,Je.intNumberFromHexString)(h.blockNumber||"0x0")),d=Math.max(...u);if(d&&d>n){const h=(0,Qt.IntNumber)(d+1);console.info(`Moving cursor position for filter (${e}) from ${n} to ${h}`),this.cursors.set(e,h)}}return c}async getBlockFilterChanges(e){const r=this.cursors.get(e);if(!r)return Gr();const n=await this.getCurrentBlockHeight();if(r>n)return Zr();console.info(`Fetching blocks from ${r} to ${n} for filter (${e})`);const i=(await Promise.all((0,Je.range)(r,n+1).map(c=>this.getBlockHashByNumber((0,Qt.IntNumber)(c))))).filter(c=>!!c),s=(0,Qt.IntNumber)(r+i.length);return console.info(`Moving cursor position for filter (${e}) from ${r} to ${s}`),this.cursors.set(e,s),Object.assign(Object.assign({},$t),{result:i})}async getPendingTransactionFilterChanges(e){return Promise.resolve(Zr())}async setInitialCursorPosition(e,r){const n=await this.getCurrentBlockHeight(),i=typeof r=="number"&&r>n?r:n;return this.cursors.set(e,i),i}setFilterTimeout(e){const r=this.timeouts.get(e);r&&window.clearTimeout(r);const n=window.setTimeout(()=>{console.info(`Filter (${e}) timed out`),this.deleteFilter(e)},Fu);this.timeouts.set(e,n)}async getCurrentBlockHeight(){const e=new Date;if(e.getTime()-this.lastFetchTimestamp.getTime()>this.REQUEST_THROTTLE_INTERVAL){this.lastFetchTimestamp=e;const r=await this._getCurrentBlockHeight();this.currentBlockHeight=r,this.resolvers.forEach(n=>n(r)),this.resolvers=[]}return this.currentBlockHeight?this.currentBlockHeight:new Promise(r=>this.resolvers.push(r))}async _getCurrentBlockHeight(){const{result:e}=await this.sendAsyncPromise(Object.assign(Object.assign({},$t),{method:"eth_blockNumber",params:[]}));return(0,Je.intNumberFromHexString)((0,Je.ensureHexString)(e))}async getBlockHashByNumber(e){const r=await this.sendAsyncPromise(Object.assign(Object.assign({},$t),{method:"eth_getBlockByNumber",params:[(0,Je.hexStringFromIntNumber)(e),!1]}));return r.result&&typeof r.result.hash=="string"?(0,Je.ensureHexString)(r.result.hash):null}}ir.FilterPolyfill=Hu;function Pa(t){return{fromBlock:oo(t.fromBlock),toBlock:oo(t.toBlock),addresses:t.address===void 0?null:Array.isArray(t.address)?t.address:[t.address],topics:t.topics||[]}}ir.filterFromParam=Pa;function io(t){const e={fromBlock:ao(t.fromBlock),toBlock:ao(t.toBlock),topics:t.topics};return t.addresses!==null&&(e.address=t.addresses),e}function oo(t){if(t===void 0||t==="latest"||t==="pending")return"latest";if(t==="earliest")return(0,Qt.IntNumber)(0);if((0,Je.isHexString)(t))return(0,Je.intNumberFromHexString)(t);throw new Error(`Invalid block option: ${String(t)}`)}function ao(t){return t==="latest"?t:(0,Je.hexStringFromIntNumber)(t)}function Gr(){return Object.assign(Object.assign({},$t),{error:{code:-32e3,message:"filter not found"}})}function Zr(){return Object.assign(Object.assign({},$t),{result:[]})}var Tn={},$a={},xn={},Ys=Uu;function Uu(t){t=t||{};var e=t.max||Number.MAX_SAFE_INTEGER,r=typeof t.start<"u"?t.start:Math.floor(Math.random()*e);return function(){return r=r%e,r++}}const co=(t,e)=>function(){const r=e.promiseModule,n=new Array(arguments.length);for(let i=0;i{e.errorFirst?n.push(function(c,u){if(e.multiArgs){const d=new Array(arguments.length-1);for(let h=1;h{e=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},e);const r=i=>{const s=c=>typeof c=="string"?i===c:c.test(i);return e.include?e.include.some(s):!e.exclude.some(s)};let n;typeof t=="function"?n=function(){return e.excludeMain?t.apply(this,arguments):co(t,e).apply(this,arguments)}:n=Object.create(Object.getPrototypeOf(t));for(const i in t){const s=t[i];n[i]=typeof s=="function"&&r(i)?co(s,e):s}return n},xr={},Pr={};Object.defineProperty(Pr,"__esModule",{value:!0});const Wu=ta;function lo(t,e,r){try{Reflect.apply(t,e,r)}catch(n){setTimeout(()=>{throw n})}}function zu(t){const e=t.length,r=new Array(e);for(let n=0;n0&&([c]=r),c instanceof Error)throw c;const u=new Error(`Unhandled error.${c?` (${c.message})`:""}`);throw u.context=c,u}const s=i[e];if(s===void 0)return!1;if(typeof s=="function")lo(s,this,r);else{const c=s.length,u=zu(s);for(let d=0;dt+e,uo=["sync","latest"];class Ku extends Gu.default{constructor(e){super(),this._blockResetDuration=e.blockResetDuration||20*Zu,this._usePastBlocks=e.usePastBlocks||!1,this._currentBlock=null,this._isRunning=!1,this._onNewListener=this._onNewListener.bind(this),this._onRemoveListener=this._onRemoveListener.bind(this),this._resetCurrentBlock=this._resetCurrentBlock.bind(this),this._setupInternalEvents()}async destroy(){this._cancelBlockResetTimeout(),await this._maybeEnd(),super.removeAllListeners()}isRunning(){return this._isRunning}getCurrentBlock(){return this._currentBlock}async getLatestBlock(){return this._currentBlock?this._currentBlock:await new Promise(r=>this.once("latest",r))}removeAllListeners(e){return e?super.removeAllListeners(e):super.removeAllListeners(),this._setupInternalEvents(),this._onRemoveListener(),this}_setupInternalEvents(){this.removeListener("newListener",this._onNewListener),this.removeListener("removeListener",this._onRemoveListener),this.on("newListener",this._onNewListener),this.on("removeListener",this._onRemoveListener)}_onNewListener(e){uo.includes(e)&&this._maybeStart()}_onRemoveListener(){this._getBlockTrackerEventCount()>0||this._maybeEnd()}async _maybeStart(){this._isRunning||(this._isRunning=!0,this._cancelBlockResetTimeout(),await this._start(),this.emit("_started"))}async _maybeEnd(){this._isRunning&&(this._isRunning=!1,this._setupBlockResetTimeout(),await this._end(),this.emit("_ended"))}_getBlockTrackerEventCount(){return uo.map(e=>this.listenerCount(e)).reduce(Qu)}_shouldUseNewBlock(e){const r=this._currentBlock;if(!r)return!0;const n=ho(e),i=ho(r);return this._usePastBlocks&&ni}_newPotentialLatest(e){this._shouldUseNewBlock(e)&&this._setCurrentBlock(e)}_setCurrentBlock(e){const r=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{oldBlock:r,newBlock:e})}_setupBlockResetTimeout(){this._cancelBlockResetTimeout(),this._blockResetTimeout=setTimeout(this._resetCurrentBlock,this._blockResetDuration),this._blockResetTimeout.unref&&this._blockResetTimeout.unref()}_cancelBlockResetTimeout(){this._blockResetTimeout&&clearTimeout(this._blockResetTimeout)}_resetCurrentBlock(){this._currentBlock=null}}xr.BaseBlockTracker=Ku;function ho(t){return Number.parseInt(t,16)}var Oa={},Ba={},Ve={};class Da extends TypeError{constructor(e,r){let n;const{message:i,explanation:s,...c}=e,{path:u}=e,d=u.length===0?i:`At path: ${u.join(".")} -- ${i}`;super(s??d),s!=null&&(this.cause=d),Object.assign(this,c),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Xu(t){return at(t)&&typeof t[Symbol.iterator]=="function"}function at(t){return typeof t=="object"&&t!=null}function fo(t){if(Object.prototype.toString.call(t)!=="[object Object]")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function je(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Yu(t){const{done:e,value:r}=t.next();return e?void 0:r}function ed(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:s}=e,{type:c}=r,{refinement:u,message:d=`Expected a value of type \`${c}\`${u?` with refinement \`${u}\``:""}, but received: \`${je(n)}\``}=t;return{value:n,type:c,refinement:u,key:i[i.length-1],path:i,branch:s,...t,message:d}}function*Os(t,e,r,n){Xu(t)||(t=[t]);for(const i of t){const s=ed(i,e,r,n);s&&(yield s)}}function*ei(t,e,r={}){const{path:n=[],branch:i=[t],coerce:s=!1,mask:c=!1}=r,u={path:n,branch:i};if(s&&(t=e.coercer(t,u),c&&e.type!=="type"&&at(e.schema)&&at(t)&&!Array.isArray(t)))for(const h in t)e.schema[h]===void 0&&delete t[h];let d="valid";for(const h of e.validator(t,u))h.explanation=r.message,d="not_valid",yield[h,void 0];for(let[h,y,S]of e.entries(t,u)){const E=ei(y,S,{path:h===void 0?n:[...n,h],branch:h===void 0?i:[...i,y],coerce:s,mask:c,message:r.message});for(const M of E)M[0]?(d=M[0].refinement!=null?"not_refined":"not_valid",yield[M[0],void 0]):s&&(y=M[1],h===void 0?t=y:t instanceof Map?t.set(h,y):t instanceof Set?t.add(y):at(t)&&(y!==void 0||h in t)&&(t[h]=y))}if(d!=="not_valid")for(const h of e.refiner(t,u))h.explanation=r.message,d="not_refined",yield[h,void 0];d==="valid"&&(yield[void 0,t])}class ee{constructor(e){const{type:r,schema:n,validator:i,refiner:s,coercer:c=d=>d,entries:u=function*(){}}=e;this.type=r,this.schema=n,this.entries=u,this.coercer=c,i?this.validator=(d,h)=>{const y=i(d,h);return Os(y,h,this,d)}:this.validator=()=>[],s?this.refiner=(d,h)=>{const y=s(d,h);return Os(y,h,this,d)}:this.refiner=()=>[]}assert(e,r){return ja(e,this,r)}create(e,r){return Fa(e,this,r)}is(e){return ti(e,this)}mask(e,r){return Ha(e,this,r)}validate(e,r={}){return hr(e,this,r)}}function ja(t,e,r){const n=hr(t,e,{message:r});if(n[0])throw n[0]}function Fa(t,e,r){const n=hr(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Ha(t,e,r){const n=hr(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function ti(t,e){return!hr(t,e)[0]}function hr(t,e,r={}){const n=ei(t,e,r),i=Yu(n);return i[0]?[new Da(i[0],function*(){for(const c of n)c[0]&&(yield c[0])}),void 0]:[void 0,i[1]]}function td(...t){const e=t[0].type==="type",r=t.map(i=>i.schema),n=Object.assign({},...r);return e?Or(n):$r(n)}function Xe(t,e){return new ee({type:t,schema:null,validator:e})}function rd(t,e){return new ee({...t,refiner:(r,n)=>r===void 0||t.refiner(r,n),validator(r,n){return r===void 0?!0:(e(r,n),t.validator(r,n))}})}function nd(t){return new ee({type:"dynamic",schema:null,*entries(e,r){yield*t(e,r).entries(e,r)},validator(e,r){return t(e,r).validator(e,r)},coercer(e,r){return t(e,r).coercer(e,r)},refiner(e,r){return t(e,r).refiner(e,r)}})}function sd(t){let e;return new ee({type:"lazy",schema:null,*entries(r,n){e??(e=t()),yield*e.entries(r,n)},validator(r,n){return e??(e=t()),e.validator(r,n)},coercer(r,n){return e??(e=t()),e.coercer(r,n)},refiner(r,n){return e??(e=t()),e.refiner(r,n)}})}function id(t,e){const{schema:r}=t,n={...r};for(const i of e)delete n[i];switch(t.type){case"type":return Or(n);default:return $r(n)}}function od(t){const e=t instanceof ee,r=e?{...t.schema}:{...t};for(const n in r)r[n]=Ua(r[n]);return e&&t.type==="type"?Or(r):$r(r)}function ad(t,e){const{schema:r}=t,n={};for(const i of e)n[i]=r[i];switch(t.type){case"type":return Or(n);default:return $r(n)}}function cd(t,e){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),Xe(t,e)}function ld(){return Xe("any",()=>!0)}function ud(t){return new ee({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${je(e)}`}})}function dd(){return Xe("bigint",t=>typeof t=="bigint")}function hd(){return Xe("boolean",t=>typeof t=="boolean")}function fd(){return Xe("date",t=>t instanceof Date&&!isNaN(t.getTime())||`Expected a valid \`Date\` object, but received: ${je(t)}`)}function gd(t){const e={},r=t.map(n=>je(n)).join();for(const n of t)e[n]=n;return new ee({type:"enums",schema:e,validator(n){return t.includes(n)||`Expected one of \`${r}\`, but received: ${je(n)}`}})}function pd(){return Xe("func",t=>typeof t=="function"||`Expected a function, but received: ${je(t)}`)}function md(t){return Xe("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${je(e)}`)}function vd(){return Xe("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${je(t)}`)}function wd(t){return new ee({type:"intersection",schema:null,*entries(e,r){for(const n of t)yield*n.entries(e,r)},*validator(e,r){for(const n of t)yield*n.validator(e,r)},*refiner(e,r){for(const n of t)yield*n.refiner(e,r)}})}function yd(t){const e=je(t),r=typeof t;return new ee({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${je(n)}`}})}function bd(t,e){return new ee({type:"map",schema:null,*entries(r){if(t&&e&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,t],yield[n,i,e]},coercer(r){return r instanceof Map?new Map(r):r},validator(r){return r instanceof Map||`Expected a \`Map\` object, but received: ${je(r)}`}})}function ri(){return Xe("never",()=>!1)}function _d(t){return new ee({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function Ed(){return Xe("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${je(t)}`)}function $r(t){const e=t?Object.keys(t):[],r=ri();return new ee({type:"object",schema:t||null,*entries(n){if(t&&at(n)){const i=new Set(Object.keys(n));for(const s of e)i.delete(s),yield[s,n[s],t[s]];for(const s of i)yield[s,n[s],r]}},validator(n){return at(n)||`Expected an object, but received: ${je(n)}`},coercer(n){return at(n)?{...n}:n}})}function Ua(t){return new ee({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Sd(t,e){return new ee({type:"record",schema:null,*entries(r){if(at(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator(r){return at(r)||`Expected an object, but received: ${je(r)}`}})}function Md(){return Xe("regexp",t=>t instanceof RegExp)}function kd(t){return new ee({type:"set",schema:null,*entries(e){if(t&&e instanceof Set)for(const r of e)yield[r,r,t]},coercer(e){return e instanceof Set?new Set(e):e},validator(e){return e instanceof Set||`Expected a \`Set\` object, but received: ${je(e)}`}})}function Va(){return Xe("string",t=>typeof t=="string"||`Expected a string, but received: ${je(t)}`)}function Rd(t){const e=ri();return new ee({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;ir.type).join(" | ");return new ee({type:"union",schema:null,coercer(r){for(const n of t){const[i,s]=n.validate(r,{coerce:!0});if(!i)return s}return r},validator(r,n){const i=[];for(const s of t){const[...c]=ei(r,s,n),[u]=c;if(u[0])for(const[d]of c)d&&i.push(d);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${je(r)}`,...i]}})}function Wa(){return Xe("unknown",()=>!0)}function ni(t,e,r){return new ee({...t,coercer:(n,i)=>ti(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}function Cd(t,e,r={}){return ni(t,Wa(),n=>{const i=typeof e=="function"?e():e;if(n===void 0)return i;if(!r.strict&&fo(n)&&fo(i)){const s={...n};let c=!1;for(const u in i)s[u]===void 0&&(s[u]=i[u],c=!0);if(c)return s}return n})}function Ad(t){return ni(t,Va(),e=>e.trim())}function Nd(t){return Ut(t,"empty",e=>{const r=za(e);return r===0||`Expected an empty ${t.type} but received one with a size of \`${r}\``})}function za(t){return t instanceof Map||t instanceof Set?t.size:t.length}function Ld(t,e,r={}){const{exclusive:n}=r;return Ut(t,"max",i=>n?in?i>e:i>=e||`Expected a ${t.type} greater than ${n?"":"or equal to "}${e} but received \`${i}\``)}function xd(t){return Ut(t,"nonempty",e=>za(e)>0||`Expected a nonempty ${t.type} but received an empty one`)}function Pd(t,e){return Ut(t,"pattern",r=>e.test(r)||`Expected a ${t.type} matching \`/${e.source}/\` but received "${r}"`)}function $d(t,e,r=e){const n=`Expected a ${t.type}`,i=e===r?`of \`${e}\``:`between \`${e}\` and \`${r}\``;return Ut(t,"size",s=>{if(typeof s=="number"||s instanceof Date)return e<=s&&s<=r||`${n} ${i} but received \`${s}\``;if(s instanceof Map||s instanceof Set){const{size:c}=s;return e<=c&&c<=r||`${n} with a size ${i} but received one with a size of \`${c}\``}else{const{length:c}=s;return e<=c&&c<=r||`${n} with a length ${i} but received one with a length of \`${c}\``}})}function Ut(t,e,r){return new ee({...t,*refiner(n,i){yield*t.refiner(n,i);const s=r(n,i),c=Os(s,i,t,n);for(const u of c)yield{...u,refinement:e}}})}const Od=Object.freeze(Object.defineProperty({__proto__:null,Struct:ee,StructError:Da,any:ld,array:ud,assert:ja,assign:td,bigint:dd,boolean:hd,coerce:ni,create:Fa,date:fd,defaulted:Cd,define:Xe,deprecated:rd,dynamic:nd,empty:Nd,enums:gd,func:pd,instance:md,integer:vd,intersection:wd,is:ti,lazy:sd,literal:yd,map:bd,mask:Ha,max:Ld,min:Td,never:ri,nonempty:xd,nullable:_d,number:Ed,object:$r,omit:id,optional:Ua,partial:od,pattern:Pd,pick:ad,record:Sd,refine:Ut,regexp:Md,set:kd,size:$d,string:Va,struct:cd,trimmed:Ad,tuple:Rd,type:Or,union:Id,unknown:Wa,validate:hr},Symbol.toStringTag,{value:"Module"})),Vt=Hs(Od);Object.defineProperty(Ve,"__esModule",{value:!0});Ve.assertExhaustive=Ve.assertStruct=Ve.assert=Ve.AssertionError=void 0;const Bd=Vt;function Dd(t){return typeof t=="object"&&t!==null&&"message"in t}function jd(t){var e,r;return typeof((r=(e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===null||r===void 0?void 0:r.name)=="string"}function Fd(t){const e=Dd(t)?t.message:String(t);return e.endsWith(".")?e.slice(0,-1):e}function qa(t,e){return jd(t)?new t({message:e}):t({message:e})}class si extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}}Ve.AssertionError=si;function Hd(t,e="Assertion failed.",r=si){if(!t)throw e instanceof Error?e:qa(r,e)}Ve.assert=Hd;function Ud(t,e,r="Assertion failed",n=si){try{(0,Bd.assert)(t,e)}catch(i){throw qa(n,`${r}: ${Fd(i)}.`)}}Ve.assertStruct=Ud;function Vd(t){throw new Error("Invalid branch reached. Should be detected during compilation.")}Ve.assertExhaustive=Vd;var Br={};Object.defineProperty(Br,"__esModule",{value:!0});Br.base64=void 0;const Wd=Vt,zd=Ve,qd=(t,e={})=>{var r,n;const i=(r=e.paddingRequired)!==null&&r!==void 0?r:!1,s=(n=e.characterSet)!==null&&n!==void 0?n:"base64";let c;s==="base64"?c=String.raw`[A-Za-z0-9+\/]`:((0,zd.assert)(s==="base64url"),c=String.raw`[-_A-Za-z0-9]`);let u;return i?u=new RegExp(`^(?:${c}{4})*(?:${c}{3}=|${c}{2}==)?$`,"u"):u=new RegExp(`^(?:${c}{4})*(?:${c}{2,3}|${c}{3}=|${c}{2}==)?$`,"u"),(0,Wd.pattern)(t,u)};Br.base64=qd;var W={},Dr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.remove0x=t.add0x=t.assertIsStrictHexString=t.assertIsHexString=t.isStrictHexString=t.isHexString=t.StrictHexStruct=t.HexStruct=void 0;const e=Vt,r=Ve;t.HexStruct=(0,e.pattern)((0,e.string)(),/^(?:0x)?[0-9a-f]+$/iu),t.StrictHexStruct=(0,e.pattern)((0,e.string)(),/^0x[0-9a-f]+$/iu);function n(h){return(0,e.is)(h,t.HexStruct)}t.isHexString=n;function i(h){return(0,e.is)(h,t.StrictHexStruct)}t.isStrictHexString=i;function s(h){(0,r.assert)(n(h),"Value must be a hexadecimal string.")}t.assertIsHexString=s;function c(h){(0,r.assert)(i(h),'Value must be a hexadecimal string, starting with "0x".')}t.assertIsStrictHexString=c;function u(h){return h.startsWith("0x")?h:h.startsWith("0X")?`0x${h.substring(2)}`:`0x${h}`}t.add0x=u;function d(h){return h.startsWith("0x")||h.startsWith("0X")?h.substring(2):h}t.remove0x=d})(Dr);Object.defineProperty(W,"__esModule",{value:!0});W.createDataView=W.concatBytes=W.valueToBytes=W.stringToBytes=W.numberToBytes=W.signedBigIntToBytes=W.bigIntToBytes=W.hexToBytes=W.bytesToString=W.bytesToNumber=W.bytesToSignedBigInt=W.bytesToBigInt=W.bytesToHex=W.assertIsBytes=W.isBytes=void 0;const tt=Ve,Bs=Dr,go=48,po=58,mo=87;function Jd(){const t=[];return()=>{if(t.length===0)for(let e=0;e<256;e++)t.push(e.toString(16).padStart(2,"0"));return t}}const Gd=Jd();function ii(t){return t instanceof Uint8Array}W.isBytes=ii;function fr(t){(0,tt.assert)(ii(t),"Value must be a Uint8Array.")}W.assertIsBytes=fr;function Ja(t){if(fr(t),t.length===0)return"0x";const e=Gd(),r=new Array(t.length);for(let n=0;n=BigInt(0),"Value must be a non-negative bigint.");const e=t.toString(16);return Pn(e)}W.bigIntToBytes=Za;function Xd(t,e){(0,tt.assert)(e>0);const r=t>>BigInt(31);return!((~t&r)+(t&~r)>>BigInt(e*8+-1))}function Yd(t,e){(0,tt.assert)(typeof t=="bigint","Value must be a bigint."),(0,tt.assert)(typeof e=="number","Byte length must be a number."),(0,tt.assert)(e>0,"Byte length must be greater than 0."),(0,tt.assert)(Xd(t,e),"Byte length is too small to represent the given value.");let r=t;const n=new Uint8Array(e);for(let i=0;i>=BigInt(8);return n.reverse()}W.signedBigIntToBytes=Yd;function Qa(t){(0,tt.assert)(typeof t=="number","Value must be a number."),(0,tt.assert)(t>=0,"Value must be a non-negative number."),(0,tt.assert)(Number.isSafeInteger(t),"Value is not a safe integer. Use `bigIntToBytes` instead.");const e=t.toString(16);return Pn(e)}W.numberToBytes=Qa;function Ka(t){return(0,tt.assert)(typeof t=="string","Value must be a string."),new TextEncoder().encode(t)}W.stringToBytes=Ka;function Xa(t){if(typeof t=="bigint")return Za(t);if(typeof t=="number")return Qa(t);if(typeof t=="string")return t.startsWith("0x")?Pn(t):Ka(t);if(ii(t))return t;throw new TypeError(`Unsupported value type: "${typeof t}".`)}W.valueToBytes=Xa;function eh(t){const e=new Array(t.length);let r=0;for(let i=0;ie.call(r,n,i,this))}get(e){return Ge(this,ct,"f").get(e)}has(e){return Ge(this,ct,"f").has(e)}keys(){return Ge(this,ct,"f").keys()}values(){return Ge(this,ct,"f").values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map(([e,r])=>`${String(e)} => ${String(r)}`).join(", ")} `:""}}`}}or.FrozenMap=oi;class ai{constructor(e){ft.set(this,void 0),tc(this,ft,new Set(e),"f"),Object.freeze(this)}get size(){return Ge(this,ft,"f").size}[(ft=new WeakMap,Symbol.iterator)](){return Ge(this,ft,"f")[Symbol.iterator]()}entries(){return Ge(this,ft,"f").entries()}forEach(e,r){return Ge(this,ft,"f").forEach((n,i,s)=>e.call(r,n,i,this))}has(e){return Ge(this,ft,"f").has(e)}keys(){return Ge(this,ft,"f").keys()}values(){return Ge(this,ft,"f").values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map(e=>String(e)).join(", ")} `:""}}`}}or.FrozenSet=ai;Object.freeze(oi);Object.freeze(oi.prototype);Object.freeze(ai);Object.freeze(ai.prototype);var rc={};Object.defineProperty(rc,"__esModule",{value:!0});var nc={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getJsonRpcIdValidator=t.assertIsJsonRpcError=t.isJsonRpcError=t.assertIsJsonRpcFailure=t.isJsonRpcFailure=t.assertIsJsonRpcSuccess=t.isJsonRpcSuccess=t.assertIsJsonRpcResponse=t.isJsonRpcResponse=t.assertIsPendingJsonRpcResponse=t.isPendingJsonRpcResponse=t.JsonRpcResponseStruct=t.JsonRpcFailureStruct=t.JsonRpcSuccessStruct=t.PendingJsonRpcResponseStruct=t.assertIsJsonRpcRequest=t.isJsonRpcRequest=t.assertIsJsonRpcNotification=t.isJsonRpcNotification=t.JsonRpcNotificationStruct=t.JsonRpcRequestStruct=t.JsonRpcParamsStruct=t.JsonRpcErrorStruct=t.JsonRpcIdStruct=t.JsonRpcVersionStruct=t.jsonrpc2=t.getJsonSize=t.isValidJson=t.JsonStruct=t.UnsafeJsonStruct=void 0;const e=Vt,r=Ve,n=()=>(0,e.define)("finite number",C=>(0,e.is)(C,(0,e.number)())&&Number.isFinite(C));t.UnsafeJsonStruct=(0,e.union)([(0,e.literal)(null),(0,e.boolean)(),n(),(0,e.string)(),(0,e.array)((0,e.lazy)(()=>t.UnsafeJsonStruct)),(0,e.record)((0,e.string)(),(0,e.lazy)(()=>t.UnsafeJsonStruct))]),t.JsonStruct=(0,e.define)("Json",(C,P)=>{function J(We,Qe){const H=[...Qe.validator(We,P)];return H.length>0?H:!0}try{const We=J(C,t.UnsafeJsonStruct);return We!==!0?We:J(JSON.parse(JSON.stringify(C)),t.UnsafeJsonStruct)}catch(We){return We instanceof RangeError?"Circular reference detected":!1}});function i(C){return(0,e.is)(C,t.JsonStruct)}t.isValidJson=i;function s(C){(0,r.assertStruct)(C,t.JsonStruct,"Invalid JSON value");const P=JSON.stringify(C);return new TextEncoder().encode(P).byteLength}t.getJsonSize=s,t.jsonrpc2="2.0",t.JsonRpcVersionStruct=(0,e.literal)(t.jsonrpc2),t.JsonRpcIdStruct=(0,e.nullable)((0,e.union)([(0,e.number)(),(0,e.string)()])),t.JsonRpcErrorStruct=(0,e.object)({code:(0,e.integer)(),message:(0,e.string)(),data:(0,e.optional)(t.JsonStruct),stack:(0,e.optional)((0,e.string)())}),t.JsonRpcParamsStruct=(0,e.optional)((0,e.union)([(0,e.record)((0,e.string)(),t.JsonStruct),(0,e.array)(t.JsonStruct)])),t.JsonRpcRequestStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,method:(0,e.string)(),params:t.JsonRpcParamsStruct}),t.JsonRpcNotificationStruct=(0,e.omit)(t.JsonRpcRequestStruct,["id"]);function c(C){return(0,e.is)(C,t.JsonRpcNotificationStruct)}t.isJsonRpcNotification=c;function u(C,P){(0,r.assertStruct)(C,t.JsonRpcNotificationStruct,"Invalid JSON-RPC notification",P)}t.assertIsJsonRpcNotification=u;function d(C){return(0,e.is)(C,t.JsonRpcRequestStruct)}t.isJsonRpcRequest=d;function h(C,P){(0,r.assertStruct)(C,t.JsonRpcRequestStruct,"Invalid JSON-RPC request",P)}t.assertIsJsonRpcRequest=h,t.PendingJsonRpcResponseStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,result:(0,e.optional)((0,e.unknown)()),error:(0,e.optional)(t.JsonRpcErrorStruct)}),t.JsonRpcSuccessStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,result:t.JsonStruct}),t.JsonRpcFailureStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,error:t.JsonRpcErrorStruct}),t.JsonRpcResponseStruct=(0,e.union)([t.JsonRpcSuccessStruct,t.JsonRpcFailureStruct]);function y(C){return(0,e.is)(C,t.PendingJsonRpcResponseStruct)}t.isPendingJsonRpcResponse=y;function S(C,P){(0,r.assertStruct)(C,t.PendingJsonRpcResponseStruct,"Invalid pending JSON-RPC response",P)}t.assertIsPendingJsonRpcResponse=S;function E(C){return(0,e.is)(C,t.JsonRpcResponseStruct)}t.isJsonRpcResponse=E;function M(C,P){(0,r.assertStruct)(C,t.JsonRpcResponseStruct,"Invalid JSON-RPC response",P)}t.assertIsJsonRpcResponse=M;function k(C){return(0,e.is)(C,t.JsonRpcSuccessStruct)}t.isJsonRpcSuccess=k;function x(C,P){(0,r.assertStruct)(C,t.JsonRpcSuccessStruct,"Invalid JSON-RPC success response",P)}t.assertIsJsonRpcSuccess=x;function O(C){return(0,e.is)(C,t.JsonRpcFailureStruct)}t.isJsonRpcFailure=O;function B(C,P){(0,r.assertStruct)(C,t.JsonRpcFailureStruct,"Invalid JSON-RPC failure response",P)}t.assertIsJsonRpcFailure=B;function L(C){return(0,e.is)(C,t.JsonRpcErrorStruct)}t.isJsonRpcError=L;function R(C,P){(0,r.assertStruct)(C,t.JsonRpcErrorStruct,"Invalid JSON-RPC error",P)}t.assertIsJsonRpcError=R;function z(C){const{permitEmptyString:P,permitFractions:J,permitNull:We}=Object.assign({permitEmptyString:!0,permitFractions:!1,permitNull:!0},C);return Y=>!!(typeof Y=="number"&&(J||Number.isInteger(Y))||typeof Y=="string"&&(P||Y.length>0)||We&&Y===null)}t.getJsonRpcIdValidator=z})(nc);var sc={};Object.defineProperty(sc,"__esModule",{value:!0});var ar={},hh=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ar,"__esModule",{value:!0});ar.createModuleLogger=ar.createProjectLogger=void 0;const fh=hh(Tc),gh=(0,fh.default)("metamask");function ph(t){return gh.extend(t)}ar.createProjectLogger=ph;function mh(t,e){return t.extend(e)}ar.createModuleLogger=mh;var ic={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.calculateNumberSize=t.calculateStringSize=t.isASCII=t.isPlainObject=t.ESCAPE_CHARACTERS_REGEXP=t.JsonSize=t.hasProperty=t.isObject=t.isNullOrUndefined=t.isNonEmptyArray=void 0;function e(h){return Array.isArray(h)&&h.length>0}t.isNonEmptyArray=e;function r(h){return h==null}t.isNullOrUndefined=r;function n(h){return!!h&&typeof h=="object"&&!Array.isArray(h)}t.isObject=n;const i=(h,y)=>Object.hasOwnProperty.call(h,y);t.hasProperty=i,function(h){h[h.Null=4]="Null",h[h.Comma=1]="Comma",h[h.Wrapper=1]="Wrapper",h[h.True=4]="True",h[h.False=5]="False",h[h.Quote=1]="Quote",h[h.Colon=1]="Colon",h[h.Date=24]="Date"}(t.JsonSize||(t.JsonSize={})),t.ESCAPE_CHARACTERS_REGEXP=/"|\\|\n|\r|\t/gu;function s(h){if(typeof h!="object"||h===null)return!1;try{let y=h;for(;Object.getPrototypeOf(y)!==null;)y=Object.getPrototypeOf(y);return Object.getPrototypeOf(h)===y}catch{return!1}}t.isPlainObject=s;function c(h){return h.charCodeAt(0)<=127}t.isASCII=c;function u(h){var y;return h.split("").reduce((E,M)=>c(M)?E+1:E+2,0)+((y=h.match(t.ESCAPE_CHARACTERS_REGEXP))!==null&&y!==void 0?y:[]).length}t.calculateStringSize=u;function d(h){return h.toString().length}t.calculateNumberSize=d})(ic);var bt={};Object.defineProperty(bt,"__esModule",{value:!0});bt.hexToBigInt=bt.hexToNumber=bt.bigIntToHex=bt.numberToHex=void 0;const er=Ve,_r=Dr,vh=t=>((0,er.assert)(typeof t=="number","Value must be a number."),(0,er.assert)(t>=0,"Value must be a non-negative number."),(0,er.assert)(Number.isSafeInteger(t),"Value is not a safe integer. Use `bigIntToHex` instead."),(0,_r.add0x)(t.toString(16)));bt.numberToHex=vh;const wh=t=>((0,er.assert)(typeof t=="bigint","Value must be a bigint."),(0,er.assert)(t>=0,"Value must be a non-negative bigint."),(0,_r.add0x)(t.toString(16)));bt.bigIntToHex=wh;const yh=t=>{(0,_r.assertIsHexString)(t);const e=parseInt(t,16);return(0,er.assert)(Number.isSafeInteger(e),"Value is not a safe integer. Use `hexToBigInt` instead."),e};bt.hexToNumber=yh;const bh=t=>((0,_r.assertIsHexString)(t),BigInt((0,_r.add0x)(t)));bt.hexToBigInt=bh;var oc={};Object.defineProperty(oc,"__esModule",{value:!0});var ac={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.timeSince=t.inMilliseconds=t.Duration=void 0,function(s){s[s.Millisecond=1]="Millisecond",s[s.Second=1e3]="Second",s[s.Minute=6e4]="Minute",s[s.Hour=36e5]="Hour",s[s.Day=864e5]="Day",s[s.Week=6048e5]="Week",s[s.Year=31536e6]="Year"}(t.Duration||(t.Duration={}));const e=s=>Number.isInteger(s)&&s>=0,r=(s,c)=>{if(!e(s))throw new Error(`"${c}" must be a non-negative integer. Received: "${s}".`)};function n(s,c){return r(s,"count"),s*c}t.inMilliseconds=n;function i(s){return r(s,"timestamp"),Date.now()-s}t.timeSince=i})(ac);var cc={};Object.defineProperty(cc,"__esModule",{value:!0});var lc={},Ds={exports:{}};const _h="2.0.0",uc=256,Eh=Number.MAX_SAFE_INTEGER||9007199254740991,Sh=16,Mh=uc-6,kh=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var Bn={MAX_LENGTH:uc,MAX_SAFE_COMPONENT_LENGTH:Sh,MAX_SAFE_BUILD_LENGTH:Mh,MAX_SAFE_INTEGER:Eh,RELEASE_TYPES:kh,SEMVER_SPEC_VERSION:_h,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},Rh={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0},ks={};const Ih=typeof Rh=="object"&&ks&&ks.NODE_DEBUG&&/\bsemver\b/i.test(ks.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};var Dn=Ih;(function(t,e){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=Bn,s=Dn;e=t.exports={};const c=e.re=[],u=e.safeRe=[],d=e.src=[],h=e.t={};let y=0;const S="[a-zA-Z0-9-]",E=[["\\s",1],["\\d",i],[S,n]],M=x=>{for(const[O,B]of E)x=x.split(`${O}*`).join(`${O}{0,${B}}`).split(`${O}+`).join(`${O}{1,${B}}`);return x},k=(x,O,B)=>{const L=M(O),R=y++;s(x,R,O),h[x]=R,d[R]=O,c[R]=new RegExp(O,B?"g":void 0),u[R]=new RegExp(L,B?"g":void 0)};k("NUMERICIDENTIFIER","0|[1-9]\\d*"),k("NUMERICIDENTIFIERLOOSE","\\d+"),k("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${S}*`),k("MAINVERSION",`(${d[h.NUMERICIDENTIFIER]})\\.(${d[h.NUMERICIDENTIFIER]})\\.(${d[h.NUMERICIDENTIFIER]})`),k("MAINVERSIONLOOSE",`(${d[h.NUMERICIDENTIFIERLOOSE]})\\.(${d[h.NUMERICIDENTIFIERLOOSE]})\\.(${d[h.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASEIDENTIFIER",`(?:${d[h.NUMERICIDENTIFIER]}|${d[h.NONNUMERICIDENTIFIER]})`),k("PRERELEASEIDENTIFIERLOOSE",`(?:${d[h.NUMERICIDENTIFIERLOOSE]}|${d[h.NONNUMERICIDENTIFIER]})`),k("PRERELEASE",`(?:-(${d[h.PRERELEASEIDENTIFIER]}(?:\\.${d[h.PRERELEASEIDENTIFIER]})*))`),k("PRERELEASELOOSE",`(?:-?(${d[h.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${d[h.PRERELEASEIDENTIFIERLOOSE]})*))`),k("BUILDIDENTIFIER",`${S}+`),k("BUILD",`(?:\\+(${d[h.BUILDIDENTIFIER]}(?:\\.${d[h.BUILDIDENTIFIER]})*))`),k("FULLPLAIN",`v?${d[h.MAINVERSION]}${d[h.PRERELEASE]}?${d[h.BUILD]}?`),k("FULL",`^${d[h.FULLPLAIN]}$`),k("LOOSEPLAIN",`[v=\\s]*${d[h.MAINVERSIONLOOSE]}${d[h.PRERELEASELOOSE]}?${d[h.BUILD]}?`),k("LOOSE",`^${d[h.LOOSEPLAIN]}$`),k("GTLT","((?:<|>)?=?)"),k("XRANGEIDENTIFIERLOOSE",`${d[h.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),k("XRANGEIDENTIFIER",`${d[h.NUMERICIDENTIFIER]}|x|X|\\*`),k("XRANGEPLAIN",`[v=\\s]*(${d[h.XRANGEIDENTIFIER]})(?:\\.(${d[h.XRANGEIDENTIFIER]})(?:\\.(${d[h.XRANGEIDENTIFIER]})(?:${d[h.PRERELEASE]})?${d[h.BUILD]}?)?)?`),k("XRANGEPLAINLOOSE",`[v=\\s]*(${d[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[h.XRANGEIDENTIFIERLOOSE]})(?:${d[h.PRERELEASELOOSE]})?${d[h.BUILD]}?)?)?`),k("XRANGE",`^${d[h.GTLT]}\\s*${d[h.XRANGEPLAIN]}$`),k("XRANGELOOSE",`^${d[h.GTLT]}\\s*${d[h.XRANGEPLAINLOOSE]}$`),k("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),k("COERCE",`${d[h.COERCEPLAIN]}(?:$|[^\\d])`),k("COERCEFULL",d[h.COERCEPLAIN]+`(?:${d[h.PRERELEASE]})?(?:${d[h.BUILD]})?(?:$|[^\\d])`),k("COERCERTL",d[h.COERCE],!0),k("COERCERTLFULL",d[h.COERCEFULL],!0),k("LONETILDE","(?:~>?)"),k("TILDETRIM",`(\\s*)${d[h.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",k("TILDE",`^${d[h.LONETILDE]}${d[h.XRANGEPLAIN]}$`),k("TILDELOOSE",`^${d[h.LONETILDE]}${d[h.XRANGEPLAINLOOSE]}$`),k("LONECARET","(?:\\^)"),k("CARETTRIM",`(\\s*)${d[h.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",k("CARET",`^${d[h.LONECARET]}${d[h.XRANGEPLAIN]}$`),k("CARETLOOSE",`^${d[h.LONECARET]}${d[h.XRANGEPLAINLOOSE]}$`),k("COMPARATORLOOSE",`^${d[h.GTLT]}\\s*(${d[h.LOOSEPLAIN]})$|^$`),k("COMPARATOR",`^${d[h.GTLT]}\\s*(${d[h.FULLPLAIN]})$|^$`),k("COMPARATORTRIM",`(\\s*)${d[h.GTLT]}\\s*(${d[h.LOOSEPLAIN]}|${d[h.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",k("HYPHENRANGE",`^\\s*(${d[h.XRANGEPLAIN]})\\s+-\\s+(${d[h.XRANGEPLAIN]})\\s*$`),k("HYPHENRANGELOOSE",`^\\s*(${d[h.XRANGEPLAINLOOSE]})\\s+-\\s+(${d[h.XRANGEPLAINLOOSE]})\\s*$`),k("STAR","(<|>)?=?\\s*\\*"),k("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),k("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Ds,Ds.exports);var jr=Ds.exports;const Ch=Object.freeze({loose:!0}),Ah=Object.freeze({}),Nh=t=>t?typeof t!="object"?Ch:t:Ah;var ci=Nh;const wo=/^[0-9]+$/,dc=(t,e)=>{const r=wo.test(t),n=wo.test(e);return r&&n&&(t=+t,e=+e),t===e?0:r&&!n?-1:n&&!r?1:tdc(e,t);var hc={compareIdentifiers:dc,rcompareIdentifiers:Lh};const Qr=Dn,{MAX_LENGTH:yo,MAX_SAFE_INTEGER:Kr}=Bn,{safeRe:bo,t:_o}=jr,Th=ci,{compareIdentifiers:Gt}=hc;let xh=class gt{constructor(e,r){if(r=Th(r),e instanceof gt){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>yo)throw new TypeError(`version is longer than ${yo} characters`);Qr("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;const n=e.trim().match(r.loose?bo[_o.LOOSE]:bo[_o.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>Kr||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Kr||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Kr||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){const s=+i;if(s>=0&&s=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);if(s===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(r){let s=[r,i];n===!1&&(s=[r]),Gt(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};var Ze=xh;const Eo=Ze,Ph=(t,e,r=!1)=>{if(t instanceof Eo)return t;try{return new Eo(t,e)}catch(n){if(!r)return null;throw n}};var gr=Ph;const $h=gr,Oh=(t,e)=>{const r=$h(t,e);return r?r.version:null};var Bh=Oh;const Dh=gr,jh=(t,e)=>{const r=Dh(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null};var Fh=jh;const So=Ze,Hh=(t,e,r,n,i)=>{typeof r=="string"&&(i=n,n=r,r=void 0);try{return new So(t instanceof So?t.version:t,r).inc(e,n,i).version}catch{return null}};var Uh=Hh;const Mo=gr,Vh=(t,e)=>{const r=Mo(t,null,!0),n=Mo(e,null,!0),i=r.compare(n);if(i===0)return null;const s=i>0,c=s?r:n,u=s?n:r,d=!!c.prerelease.length;if(!!u.prerelease.length&&!d)return!u.patch&&!u.minor?"major":c.patch?"patch":c.minor?"minor":"major";const y=d?"pre":"";return r.major!==n.major?y+"major":r.minor!==n.minor?y+"minor":r.patch!==n.patch?y+"patch":"prerelease"};var Wh=Vh;const zh=Ze,qh=(t,e)=>new zh(t,e).major;var Jh=qh;const Gh=Ze,Zh=(t,e)=>new Gh(t,e).minor;var Qh=Zh;const Kh=Ze,Xh=(t,e)=>new Kh(t,e).patch;var Yh=Xh;const ef=gr,tf=(t,e)=>{const r=ef(t,e);return r&&r.prerelease.length?r.prerelease:null};var rf=tf;const ko=Ze,nf=(t,e,r)=>new ko(t,r).compare(new ko(e,r));var ut=nf;const sf=ut,of=(t,e,r)=>sf(e,t,r);var af=of;const cf=ut,lf=(t,e)=>cf(t,e,!0);var uf=lf;const Ro=Ze,df=(t,e,r)=>{const n=new Ro(t,r),i=new Ro(e,r);return n.compare(i)||n.compareBuild(i)};var li=df;const hf=li,ff=(t,e)=>t.sort((r,n)=>hf(r,n,e));var gf=ff;const pf=li,mf=(t,e)=>t.sort((r,n)=>pf(n,r,e));var vf=mf;const wf=ut,yf=(t,e,r)=>wf(t,e,r)>0;var jn=yf;const bf=ut,_f=(t,e,r)=>bf(t,e,r)<0;var ui=_f;const Ef=ut,Sf=(t,e,r)=>Ef(t,e,r)===0;var fc=Sf;const Mf=ut,kf=(t,e,r)=>Mf(t,e,r)!==0;var gc=kf;const Rf=ut,If=(t,e,r)=>Rf(t,e,r)>=0;var di=If;const Cf=ut,Af=(t,e,r)=>Cf(t,e,r)<=0;var hi=Af;const Nf=fc,Lf=gc,Tf=jn,xf=di,Pf=ui,$f=hi,Of=(t,e,r,n)=>{switch(e){case"===":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t===r;case"!==":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t!==r;case"":case"=":case"==":return Nf(t,r,n);case"!=":return Lf(t,r,n);case">":return Tf(t,r,n);case">=":return xf(t,r,n);case"<":return Pf(t,r,n);case"<=":return $f(t,r,n);default:throw new TypeError(`Invalid operator: ${e}`)}};var pc=Of;const Bf=Ze,Df=gr,{safeRe:Xr,t:Yr}=jr,jf=(t,e)=>{if(t instanceof Bf)return t;if(typeof t=="number"&&(t=String(t)),typeof t!="string")return null;e=e||{};let r=null;if(!e.rtl)r=t.match(e.includePrerelease?Xr[Yr.COERCEFULL]:Xr[Yr.COERCE]);else{const d=e.includePrerelease?Xr[Yr.COERCERTLFULL]:Xr[Yr.COERCERTL];let h;for(;(h=d.exec(t))&&(!r||r.index+r[0].length!==t.length);)(!r||h.index+h[0].length!==r.index+r[0].length)&&(r=h),d.lastIndex=h.index+h[1].length+h[2].length;d.lastIndex=-1}if(r===null)return null;const n=r[2],i=r[3]||"0",s=r[4]||"0",c=e.includePrerelease&&r[5]?`-${r[5]}`:"",u=e.includePrerelease&&r[6]?`+${r[6]}`:"";return Df(`${n}.${i}.${s}${c}${u}`,e)};var Ff=jf;class Hf{constructor(){this.max=1e3,this.map=new Map}get(e){const r=this.map.get(e);if(r!==void 0)return this.map.delete(e),this.map.set(e,r),r}delete(e){return this.map.delete(e)}set(e,r){if(!this.delete(e)&&r!==void 0){if(this.map.size>=this.max){const i=this.map.keys().next().value;this.delete(i)}this.map.set(e,r)}return this}}var Uf=Hf,Rs,Io;function dt(){if(Io)return Rs;Io=1;const t=/\s+/g;class e{constructor(l,f){if(f=i(f),l instanceof e)return l.loose===!!f.loose&&l.includePrerelease===!!f.includePrerelease?l:new e(l.raw,f);if(l instanceof s)return this.raw=l.value,this.set=[[l]],this.formatted=void 0,this;if(this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease,this.raw=l.trim().replace(t," "),this.set=this.raw.split("||").map(g=>this.parseRange(g.trim())).filter(g=>g.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const g=this.set[0];if(this.set=this.set.filter(m=>!x(m[0])),this.set.length===0)this.set=[g];else if(this.set.length>1){for(const m of this.set)if(m.length===1&&O(m[0])){this.set=[m];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let l=0;l0&&(this.formatted+="||");const f=this.set[l];for(let g=0;g0&&(this.formatted+=" "),this.formatted+=f[g].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(l){const g=((this.options.includePrerelease&&M)|(this.options.loose&&k))+":"+l,m=n.get(g);if(m)return m;const w=this.options.loose,_=w?d[h.HYPHENRANGELOOSE]:d[h.HYPHENRANGE];l=l.replace(_,q(this.options.includePrerelease)),c("hyphen replace",l),l=l.replace(d[h.COMPARATORTRIM],y),c("comparator trim",l),l=l.replace(d[h.TILDETRIM],S),c("tilde trim",l),l=l.replace(d[h.CARETTRIM],E),c("caret trim",l);let p=l.split(" ").map(I=>L(I,this.options)).join(" ").split(/\s+/).map(I=>H(I,this.options));w&&(p=p.filter(I=>(c("loose invalid filter",I,this.options),!!I.match(d[h.COMPARATORLOOSE])))),c("range list",p);const a=new Map,v=p.map(I=>new s(I,this.options));for(const I of v){if(x(I))return[I];a.set(I.value,I)}a.size>1&&a.has("")&&a.delete("");const N=[...a.values()];return n.set(g,N),N}intersects(l,f){if(!(l instanceof e))throw new TypeError("a Range is required");return this.set.some(g=>B(g,f)&&l.set.some(m=>B(m,f)&&g.every(w=>m.every(_=>w.intersects(_,f)))))}test(l){if(!l)return!1;if(typeof l=="string")try{l=new u(l,this.options)}catch{return!1}for(let f=0;fo.value==="<0.0.0-0",O=o=>o.value==="",B=(o,l)=>{let f=!0;const g=o.slice();let m=g.pop();for(;f&&g.length;)f=g.every(w=>m.intersects(w,l)),m=g.pop();return f},L=(o,l)=>(c("comp",o,l),o=P(o,l),c("caret",o),o=z(o,l),c("tildes",o),o=We(o,l),c("xrange",o),o=Y(o,l),c("stars",o),o),R=o=>!o||o.toLowerCase()==="x"||o==="*",z=(o,l)=>o.trim().split(/\s+/).map(f=>C(f,l)).join(" "),C=(o,l)=>{const f=l.loose?d[h.TILDELOOSE]:d[h.TILDE];return o.replace(f,(g,m,w,_,p)=>{c("tilde",o,g,m,w,_,p);let a;return R(m)?a="":R(w)?a=`>=${m}.0.0 <${+m+1}.0.0-0`:R(_)?a=`>=${m}.${w}.0 <${m}.${+w+1}.0-0`:p?(c("replaceTilde pr",p),a=`>=${m}.${w}.${_}-${p} <${m}.${+w+1}.0-0`):a=`>=${m}.${w}.${_} <${m}.${+w+1}.0-0`,c("tilde return",a),a})},P=(o,l)=>o.trim().split(/\s+/).map(f=>J(f,l)).join(" "),J=(o,l)=>{c("caret",o,l);const f=l.loose?d[h.CARETLOOSE]:d[h.CARET],g=l.includePrerelease?"-0":"";return o.replace(f,(m,w,_,p,a)=>{c("caret",o,m,w,_,p,a);let v;return R(w)?v="":R(_)?v=`>=${w}.0.0${g} <${+w+1}.0.0-0`:R(p)?w==="0"?v=`>=${w}.${_}.0${g} <${w}.${+_+1}.0-0`:v=`>=${w}.${_}.0${g} <${+w+1}.0.0-0`:a?(c("replaceCaret pr",a),w==="0"?_==="0"?v=`>=${w}.${_}.${p}-${a} <${w}.${_}.${+p+1}-0`:v=`>=${w}.${_}.${p}-${a} <${w}.${+_+1}.0-0`:v=`>=${w}.${_}.${p}-${a} <${+w+1}.0.0-0`):(c("no pr"),w==="0"?_==="0"?v=`>=${w}.${_}.${p}${g} <${w}.${_}.${+p+1}-0`:v=`>=${w}.${_}.${p}${g} <${w}.${+_+1}.0-0`:v=`>=${w}.${_}.${p} <${+w+1}.0.0-0`),c("caret return",v),v})},We=(o,l)=>(c("replaceXRanges",o,l),o.split(/\s+/).map(f=>Qe(f,l)).join(" ")),Qe=(o,l)=>{o=o.trim();const f=l.loose?d[h.XRANGELOOSE]:d[h.XRANGE];return o.replace(f,(g,m,w,_,p,a)=>{c("xRange",o,g,m,w,_,p,a);const v=R(w),N=v||R(_),I=N||R(p),$=I;return m==="="&&$&&(m=""),a=l.includePrerelease?"-0":"",v?m===">"||m==="<"?g="<0.0.0-0":g="*":m&&$?(N&&(_=0),p=0,m===">"?(m=">=",N?(w=+w+1,_=0,p=0):(_=+_+1,p=0)):m==="<="&&(m="<",N?w=+w+1:_=+_+1),m==="<"&&(a="-0"),g=`${m+w}.${_}.${p}${a}`):N?g=`>=${w}.0.0${a} <${+w+1}.0.0-0`:I&&(g=`>=${w}.${_}.0${a} <${w}.${+_+1}.0-0`),c("xRange return",g),g})},Y=(o,l)=>(c("replaceStars",o,l),o.trim().replace(d[h.STAR],"")),H=(o,l)=>(c("replaceGTE0",o,l),o.trim().replace(d[l.includePrerelease?h.GTE0PRE:h.GTE0],"")),q=o=>(l,f,g,m,w,_,p,a,v,N,I,$)=>(R(g)?f="":R(m)?f=`>=${g}.0.0${o?"-0":""}`:R(w)?f=`>=${g}.${m}.0${o?"-0":""}`:_?f=`>=${f}`:f=`>=${f}${o?"-0":""}`,R(v)?a="":R(N)?a=`<${+v+1}.0.0-0`:R(I)?a=`<${v}.${+N+1}.0-0`:$?a=`<=${v}.${N}.${I}-${$}`:o?a=`<${v}.${N}.${+I+1}-0`:a=`<=${a}`,`${f} ${a}`.trim()),b=(o,l,f)=>{for(let g=0;g0){const m=o[g].semver;if(m.major===l.major&&m.minor===l.minor&&m.patch===l.patch)return!0}return!1}return!0};return Rs}var Is,Co;function Fn(){if(Co)return Is;Co=1;const t=Symbol("SemVer ANY");class e{static get ANY(){return t}constructor(y,S){if(S=r(S),y instanceof e){if(y.loose===!!S.loose)return y;y=y.value}y=y.trim().split(/\s+/).join(" "),c("comparator",y,S),this.options=S,this.loose=!!S.loose,this.parse(y),this.semver===t?this.value="":this.value=this.operator+this.semver.version,c("comp",this)}parse(y){const S=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],E=y.match(S);if(!E)throw new TypeError(`Invalid comparator: ${y}`);this.operator=E[1]!==void 0?E[1]:"",this.operator==="="&&(this.operator=""),E[2]?this.semver=new u(E[2],this.options.loose):this.semver=t}toString(){return this.value}test(y){if(c("Comparator.test",y,this.options.loose),this.semver===t||y===t)return!0;if(typeof y=="string")try{y=new u(y,this.options)}catch{return!1}return s(y,this.operator,this.semver,this.options)}intersects(y,S){if(!(y instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new d(y.value,S).test(this.value):y.operator===""?y.value===""?!0:new d(this.value,S).test(y.semver):(S=r(S),S.includePrerelease&&(this.value==="<0.0.0-0"||y.value==="<0.0.0-0")||!S.includePrerelease&&(this.value.startsWith("<0.0.0")||y.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&y.operator.startsWith(">")||this.operator.startsWith("<")&&y.operator.startsWith("<")||this.semver.version===y.semver.version&&this.operator.includes("=")&&y.operator.includes("=")||s(this.semver,"<",y.semver,S)&&this.operator.startsWith(">")&&y.operator.startsWith("<")||s(this.semver,">",y.semver,S)&&this.operator.startsWith("<")&&y.operator.startsWith(">")))}}Is=e;const r=ci,{safeRe:n,t:i}=jr,s=pc,c=Dn,u=Ze,d=dt();return Is}const Vf=dt(),Wf=(t,e,r)=>{try{e=new Vf(e,r)}catch{return!1}return e.test(t)};var Hn=Wf;const zf=dt(),qf=(t,e)=>new zf(t,e).set.map(r=>r.map(n=>n.value).join(" ").trim().split(" "));var Jf=qf;const Gf=Ze,Zf=dt(),Qf=(t,e,r)=>{let n=null,i=null,s=null;try{s=new Zf(e,r)}catch{return null}return t.forEach(c=>{s.test(c)&&(!n||i.compare(c)===-1)&&(n=c,i=new Gf(n,r))}),n};var Kf=Qf;const Xf=Ze,Yf=dt(),e0=(t,e,r)=>{let n=null,i=null,s=null;try{s=new Yf(e,r)}catch{return null}return t.forEach(c=>{s.test(c)&&(!n||i.compare(c)===1)&&(n=c,i=new Xf(n,r))}),n};var t0=e0;const Cs=Ze,r0=dt(),Ao=jn,n0=(t,e)=>{t=new r0(t,e);let r=new Cs("0.0.0");if(t.test(r)||(r=new Cs("0.0.0-0"),t.test(r)))return r;r=null;for(let n=0;n{const u=new Cs(c.semver.version);switch(c.operator){case">":u.prerelease.length===0?u.patch++:u.prerelease.push(0),u.raw=u.format();case"":case">=":(!s||Ao(u,s))&&(s=u);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${c.operator}`)}}),s&&(!r||Ao(r,s))&&(r=s)}return r&&t.test(r)?r:null};var s0=n0;const i0=dt(),o0=(t,e)=>{try{return new i0(t,e).range||"*"}catch{return null}};var a0=o0;const c0=Ze,mc=Fn(),{ANY:l0}=mc,u0=dt(),d0=Hn,No=jn,Lo=ui,h0=hi,f0=di,g0=(t,e,r,n)=>{t=new c0(t,n),e=new u0(e,n);let i,s,c,u,d;switch(r){case">":i=No,s=h0,c=Lo,u=">",d=">=";break;case"<":i=Lo,s=f0,c=No,u="<",d="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(d0(t,e,n))return!1;for(let h=0;h{M.semver===l0&&(M=new mc(">=0.0.0")),S=S||M,E=E||M,i(M.semver,S.semver,n)?S=M:c(M.semver,E.semver,n)&&(E=M)}),S.operator===u||S.operator===d||(!E.operator||E.operator===u)&&s(t,E.semver))return!1;if(E.operator===d&&c(t,E.semver))return!1}return!0};var fi=g0;const p0=fi,m0=(t,e,r)=>p0(t,e,">",r);var v0=m0;const w0=fi,y0=(t,e,r)=>w0(t,e,"<",r);var b0=y0;const To=dt(),_0=(t,e,r)=>(t=new To(t,r),e=new To(e,r),t.intersects(e,r));var E0=_0;const S0=Hn,M0=ut;var k0=(t,e,r)=>{const n=[];let i=null,s=null;const c=t.sort((y,S)=>M0(y,S,r));for(const y of c)S0(y,e,r)?(s=y,i||(i=y)):(s&&n.push([i,s]),s=null,i=null);i&&n.push([i,null]);const u=[];for(const[y,S]of n)y===S?u.push(y):!S&&y===c[0]?u.push("*"):S?y===c[0]?u.push(`<=${S}`):u.push(`${y} - ${S}`):u.push(`>=${y}`);const d=u.join(" || "),h=typeof e.raw=="string"?e.raw:String(e);return d.length{if(t===e)return!0;t=new xo(t,r),e=new xo(e,r);let n=!1;e:for(const i of t.set){for(const s of e.set){const c=C0(i,s,r);if(n=n||c!==null,c)continue e}if(n)return!1}return!0},I0=[new gi(">=0.0.0-0")],Po=[new gi(">=0.0.0")],C0=(t,e,r)=>{if(t===e)return!0;if(t.length===1&&t[0].semver===As){if(e.length===1&&e[0].semver===As)return!0;r.includePrerelease?t=I0:t=Po}if(e.length===1&&e[0].semver===As){if(r.includePrerelease)return!0;e=Po}const n=new Set;let i,s;for(const M of t)M.operator===">"||M.operator===">="?i=$o(i,M,r):M.operator==="<"||M.operator==="<="?s=Oo(s,M,r):n.add(M.semver);if(n.size>1)return null;let c;if(i&&s){if(c=pi(i.semver,s.semver,r),c>0)return null;if(c===0&&(i.operator!==">="||s.operator!=="<="))return null}for(const M of n){if(i&&!mr(M,String(i),r)||s&&!mr(M,String(s),r))return null;for(const k of e)if(!mr(M,String(k),r))return!1;return!0}let u,d,h,y,S=s&&!r.includePrerelease&&s.semver.prerelease.length?s.semver:!1,E=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1;S&&S.prerelease.length===1&&s.operator==="<"&&S.prerelease[0]===0&&(S=!1);for(const M of e){if(y=y||M.operator===">"||M.operator===">=",h=h||M.operator==="<"||M.operator==="<=",i){if(E&&M.semver.prerelease&&M.semver.prerelease.length&&M.semver.major===E.major&&M.semver.minor===E.minor&&M.semver.patch===E.patch&&(E=!1),M.operator===">"||M.operator===">="){if(u=$o(i,M,r),u===M&&u!==i)return!1}else if(i.operator===">="&&!mr(i.semver,String(M),r))return!1}if(s){if(S&&M.semver.prerelease&&M.semver.prerelease.length&&M.semver.major===S.major&&M.semver.minor===S.minor&&M.semver.patch===S.patch&&(S=!1),M.operator==="<"||M.operator==="<="){if(d=Oo(s,M,r),d===M&&d!==s)return!1}else if(s.operator==="<="&&!mr(s.semver,String(M),r))return!1}if(!M.operator&&(s||i)&&c!==0)return!1}return!(i&&h&&!s&&c!==0||s&&y&&!i&&c!==0||E||S)},$o=(t,e,r)=>{if(!t)return e;const n=pi(t.semver,e.semver,r);return n>0?t:n<0||e.operator===">"&&t.operator===">="?e:t},Oo=(t,e,r)=>{if(!t)return e;const n=pi(t.semver,e.semver,r);return n<0?t:n>0||e.operator==="<"&&t.operator==="<="?e:t};var A0=R0;const Ns=jr,Bo=Bn,N0=Ze,Do=hc,L0=gr,T0=Bh,x0=Fh,P0=Uh,$0=Wh,O0=Jh,B0=Qh,D0=Yh,j0=rf,F0=ut,H0=af,U0=uf,V0=li,W0=gf,z0=vf,q0=jn,J0=ui,G0=fc,Z0=gc,Q0=di,K0=hi,X0=pc,Y0=Ff,e1=Fn(),t1=dt(),r1=Hn,n1=Jf,s1=Kf,i1=t0,o1=s0,a1=a0,c1=fi,l1=v0,u1=b0,d1=E0,h1=k0,f1=A0;var g1={parse:L0,valid:T0,clean:x0,inc:P0,diff:$0,major:O0,minor:B0,patch:D0,prerelease:j0,compare:F0,rcompare:H0,compareLoose:U0,compareBuild:V0,sort:W0,rsort:z0,gt:q0,lt:J0,eq:G0,neq:Z0,gte:Q0,lte:K0,cmp:X0,coerce:Y0,Comparator:e1,Range:t1,satisfies:r1,toComparators:n1,maxSatisfying:s1,minSatisfying:i1,minVersion:o1,validRange:a1,outside:c1,gtr:l1,ltr:u1,intersects:d1,simplifyRange:h1,subset:f1,SemVer:N0,re:Ns.re,src:Ns.src,tokens:Ns.t,SEMVER_SPEC_VERSION:Bo.SEMVER_SPEC_VERSION,RELEASE_TYPES:Bo.RELEASE_TYPES,compareIdentifiers:Do.compareIdentifiers,rcompareIdentifiers:Do.rcompareIdentifiers};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.satisfiesVersionRange=t.gtRange=t.gtVersion=t.assertIsSemVerRange=t.assertIsSemVerVersion=t.isValidSemVerRange=t.isValidSemVerVersion=t.VersionRangeStruct=t.VersionStruct=void 0;const e=g1,r=Vt,n=Ve;t.VersionStruct=(0,r.refine)((0,r.string)(),"Version",S=>(0,e.valid)(S)===null?`Expected SemVer version, got "${S}"`:!0),t.VersionRangeStruct=(0,r.refine)((0,r.string)(),"Version range",S=>(0,e.validRange)(S)===null?`Expected SemVer range, got "${S}"`:!0);function i(S){return(0,r.is)(S,t.VersionStruct)}t.isValidSemVerVersion=i;function s(S){return(0,r.is)(S,t.VersionRangeStruct)}t.isValidSemVerRange=s;function c(S){(0,n.assertStruct)(S,t.VersionStruct)}t.assertIsSemVerVersion=c;function u(S){(0,n.assertStruct)(S,t.VersionRangeStruct)}t.assertIsSemVerRange=u;function d(S,E){return(0,e.gt)(S,E)}t.gtVersion=d;function h(S,E){return(0,e.gtr)(S,E)}t.gtRange=h;function y(S,E){return(0,e.satisfies)(S,E,{includePrerelease:!0})}t.satisfiesVersionRange=y})(lc);(function(t){var e=T&&T.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s);var u=Object.getOwnPropertyDescriptor(i,s);(!u||("get"in u?!i.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(n,c,u)}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=T&&T.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Ve,t),r(Br,t),r(W,t),r($n,t),r(yt,t),r(or,t),r(rc,t),r(Dr,t),r(nc,t),r(sc,t),r(ar,t),r(ic,t),r(bt,t),r(oc,t),r(ac,t),r(cc,t),r(lc,t)})(Ba);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createModuleLogger=t.projectLogger=void 0;const e=Ba;Object.defineProperty(t,"createModuleLogger",{enumerable:!0,get:function(){return e.createModuleLogger}}),t.projectLogger=(0,e.createProjectLogger)("eth-block-tracker")})(Oa);var vc=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(xn,"__esModule",{value:!0});xn.PollingBlockTracker=void 0;const p1=vc(Ys),m1=vc(Vu),v1=xr,jo=Oa,Fo=(0,jo.createModuleLogger)(jo.projectLogger,"polling-block-tracker"),w1=(0,p1.default)(),y1=1e3;class b1 extends v1.BaseBlockTracker{constructor(e={}){var r;if(!e.provider)throw new Error("PollingBlockTracker - no provider specified.");super(Object.assign(Object.assign({},e),{blockResetDuration:(r=e.blockResetDuration)!==null&&r!==void 0?r:e.pollingInterval})),this._provider=e.provider,this._pollingInterval=e.pollingInterval||20*y1,this._retryTimeout=e.retryTimeout||this._pollingInterval/10,this._keepEventLoopActive=e.keepEventLoopActive===void 0?!0:e.keepEventLoopActive,this._setSkipCacheFlag=e.setSkipCacheFlag||!1}async checkForLatestBlock(){return await this._updateLatestBlock(),await this.getLatestBlock()}async _start(){this._synchronize()}async _end(){}async _synchronize(){for(var e;this._isRunning;)try{await this._updateLatestBlock();const r=Ho(this._pollingInterval,!this._keepEventLoopActive);this.emit("_waitingForNextIteration"),await r}catch(r){const n=new Error(`PollingBlockTracker - encountered an error while attempting to update latest block: +${(e=r.stack)!==null&&e!==void 0?e:r}`);try{this.emit("error",n)}catch{console.error(n)}const i=Ho(this._retryTimeout,!this._keepEventLoopActive);this.emit("_waitingForNextIteration"),await i}}async _updateLatestBlock(){const e=await this._fetchLatestBlock();this._newPotentialLatest(e)}async _fetchLatestBlock(){const e={jsonrpc:"2.0",id:w1(),method:"eth_blockNumber",params:[]};this._setSkipCacheFlag&&(e.skipCache=!0),Fo("Making request",e);const r=await(0,m1.default)(n=>this._provider.sendAsync(e,n))();if(Fo("Got response",r),r.error)throw new Error(`PollingBlockTracker - encountered error fetching block: +${r.error.message}`);return r.result}}xn.PollingBlockTracker=b1;function Ho(t,e){return new Promise(r=>{const n=setTimeout(r,t);n.unref&&e&&n.unref()})}var Un={},_1=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Un,"__esModule",{value:!0});Un.SubscribeBlockTracker=void 0;const E1=_1(Ys),S1=xr,M1=(0,E1.default)();class k1 extends S1.BaseBlockTracker{constructor(e={}){if(!e.provider)throw new Error("SubscribeBlockTracker - no provider specified.");super(e),this._provider=e.provider,this._subscriptionId=null}async checkForLatestBlock(){return await this.getLatestBlock()}async _start(){if(this._subscriptionId===void 0||this._subscriptionId===null)try{const e=await this._call("eth_blockNumber");this._subscriptionId=await this._call("eth_subscribe","newHeads"),this._provider.on("data",this._handleSubData.bind(this)),this._newPotentialLatest(e)}catch(e){this.emit("error",e)}}async _end(){if(this._subscriptionId!==null&&this._subscriptionId!==void 0)try{await this._call("eth_unsubscribe",this._subscriptionId),this._subscriptionId=null}catch(e){this.emit("error",e)}}_call(e,...r){return new Promise((n,i)=>{this._provider.sendAsync({id:M1(),method:e,params:r,jsonrpc:"2.0"},(s,c)=>{s?i(s):n(c.result)})})}_handleSubData(e,r){var n;r.method==="eth_subscription"&&((n=r.params)===null||n===void 0?void 0:n.subscription)===this._subscriptionId&&this._newPotentialLatest(r.params.result.number)}}Un.SubscribeBlockTracker=k1;(function(t){var e=T&&T.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=T&&T.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(xn,t),r(Un,t)})($a);var mi={},Vn={},Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});Fr.getUniqueId=void 0;const wc=4294967295;let Ls=Math.floor(Math.random()*wc);function R1(){return Ls=(Ls+1)%wc,Ls}Fr.getUniqueId=R1;Object.defineProperty(Vn,"__esModule",{value:!0});Vn.createIdRemapMiddleware=void 0;const I1=Fr;function C1(){return(t,e,r,n)=>{const i=t.id,s=I1.getUniqueId();t.id=s,e.id=s,r(c=>{t.id=i,e.id=i,c()})}}Vn.createIdRemapMiddleware=C1;var Wn={};Object.defineProperty(Wn,"__esModule",{value:!0});Wn.createAsyncMiddleware=void 0;function A1(t){return async(e,r,n,i)=>{let s;const c=new Promise(y=>{s=y});let u=null,d=!1;const h=async()=>{d=!0,n(y=>{u=y,s()}),await c};try{await t(e,r,h),d?(await c,u(null)):i(null)}catch(y){u?u(y):i(y)}}}Wn.createAsyncMiddleware=A1;var zn={};Object.defineProperty(zn,"__esModule",{value:!0});zn.createScaffoldMiddleware=void 0;function N1(t){return(e,r,n,i)=>{const s=t[e.method];return s===void 0?n():typeof s=="function"?s(e,r,n,i):(r.result=s,i())}}zn.createScaffoldMiddleware=N1;var Hr={},vi={};Object.defineProperty(vi,"__esModule",{value:!0});const L1=ta;function Uo(t,e,r){try{Reflect.apply(t,e,r)}catch(n){setTimeout(()=>{throw n})}}function T1(t){const e=t.length,r=new Array(e);for(let n=0;n0&&([c]=r),c instanceof Error)throw c;const u=new Error(`Unhandled error.${c?` (${c.message})`:""}`);throw u.context=c,u}const s=i[e];if(s===void 0)return!1;if(typeof s=="function")Uo(s,this,r);else{const c=s.length,u=T1(s);for(let d=0;d"u"&&(n=_c()),js(t,"",0,[],void 0,0,n);var i;try{Bt.length===0?i=JSON.stringify(t,e,r):i=JSON.stringify(t,Sc(e),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Ft.length!==0;){var s=Ft.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function tr(t,e,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:t}),Ft.push([n,r,e,i])):Bt.push([e,r,t]):(n[r]=t,Ft.push([n,r,e]))}function js(t,e,r,n,i,s,c){s+=1;var u;if(typeof t=="object"&&t!==null){for(u=0;uc.depthLimit){tr(sn,t,e,i);return}if(typeof c.edgesLimit<"u"&&r+1>c.edgesLimit){tr(sn,t,e,i);return}if(n.push(t),Array.isArray(t))for(u=0;ue?1:0}function Ec(t,e,r,n){typeof n>"u"&&(n=_c());var i=Fs(t,"",0,[],void 0,0,n)||t,s;try{Bt.length===0?s=JSON.stringify(i,e,r):s=JSON.stringify(i,Sc(e),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Ft.length!==0;){var c=Ft.pop();c.length===4?Object.defineProperty(c[0],c[1],c[3]):c[0][c[1]]=c[2]}}return s}function Fs(t,e,r,n,i,s,c){s+=1;var u;if(typeof t=="object"&&t!==null){for(u=0;uc.depthLimit){tr(sn,t,e,i);return}if(typeof c.edgesLimit<"u"&&r+1>c.edgesLimit){tr(sn,t,e,i);return}if(n.push(t),Array.isArray(t))for(u=0;u0)for(var n=0;n=1e3&&t<=4999}function j1(t,e){if(e!=="[Circular]")return e}var wi={},At={};Object.defineProperty(At,"__esModule",{value:!0});At.errorValues=At.errorCodes=void 0;At.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}};At.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeError=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=At,r=Ct,n=e.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",s={code:n,message:c(n)};t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function c(E,M=i){if(Number.isInteger(E)){const k=E.toString();if(S(e.errorValues,k))return e.errorValues[k].message;if(h(E))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return M}t.getMessageFromCode=c;function u(E){if(!Number.isInteger(E))return!1;const M=E.toString();return!!(e.errorValues[M]||h(E))}t.isValidCode=u;function d(E,{fallbackError:M=s,shouldIncludeStack:k=!1}={}){var x,O;if(!M||!Number.isInteger(M.code)||typeof M.message!="string")throw new Error("Must provide fallback error with integer number code and string message.");if(E instanceof r.EthereumRpcError)return E.serialize();const B={};if(E&&typeof E=="object"&&!Array.isArray(E)&&S(E,"code")&&u(E.code)){const R=E;B.code=R.code,R.message&&typeof R.message=="string"?(B.message=R.message,S(R,"data")&&(B.data=R.data)):(B.message=c(B.code),B.data={originalError:y(E)})}else{B.code=M.code;const R=(x=E)===null||x===void 0?void 0:x.message;B.message=R&&typeof R=="string"?R:M.message,B.data={originalError:y(E)}}const L=(O=E)===null||O===void 0?void 0:O.stack;return k&&E&&L&&typeof L=="string"&&(B.stack=L),B}t.serializeError=d;function h(E){return E>=-32099&&E<=-32e3}function y(E){return E&&typeof E=="object"&&!Array.isArray(E)?Object.assign({},E):E}function S(E,M){return Object.prototype.hasOwnProperty.call(E,M)}})(wi);var qn={};Object.defineProperty(qn,"__esModule",{value:!0});qn.ethErrors=void 0;const yi=Ct,kc=wi,qe=At;qn.ethErrors={rpc:{parse:t=>nt(qe.errorCodes.rpc.parse,t),invalidRequest:t=>nt(qe.errorCodes.rpc.invalidRequest,t),invalidParams:t=>nt(qe.errorCodes.rpc.invalidParams,t),methodNotFound:t=>nt(qe.errorCodes.rpc.methodNotFound,t),internal:t=>nt(qe.errorCodes.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return nt(e,t)},invalidInput:t=>nt(qe.errorCodes.rpc.invalidInput,t),resourceNotFound:t=>nt(qe.errorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>nt(qe.errorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>nt(qe.errorCodes.rpc.transactionRejected,t),methodNotSupported:t=>nt(qe.errorCodes.rpc.methodNotSupported,t),limitExceeded:t=>nt(qe.errorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>vr(qe.errorCodes.provider.userRejectedRequest,t),unauthorized:t=>vr(qe.errorCodes.provider.unauthorized,t),unsupportedMethod:t=>vr(qe.errorCodes.provider.unsupportedMethod,t),disconnected:t=>vr(qe.errorCodes.provider.disconnected,t),chainDisconnected:t=>vr(qe.errorCodes.provider.chainDisconnected,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:r,data:n}=t;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new yi.EthereumProviderError(e,r,n)}}};function nt(t,e){const[r,n]=Rc(e);return new yi.EthereumRpcError(t,r||kc.getMessageFromCode(t),n)}function vr(t,e){const[r,n]=Rc(e);return new yi.EthereumProviderError(t,r||kc.getMessageFromCode(t),n)}function Rc(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,r]}}return[]}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromCode=t.serializeError=t.EthereumProviderError=t.EthereumRpcError=t.ethErrors=t.errorCodes=void 0;const e=Ct;Object.defineProperty(t,"EthereumRpcError",{enumerable:!0,get:function(){return e.EthereumRpcError}}),Object.defineProperty(t,"EthereumProviderError",{enumerable:!0,get:function(){return e.EthereumProviderError}});const r=wi;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return r.getMessageFromCode}});const n=qn;Object.defineProperty(t,"ethErrors",{enumerable:!0,get:function(){return n.ethErrors}});const i=At;Object.defineProperty(t,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})})(yc);var F1=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Hr,"__esModule",{value:!0});Hr.JsonRpcEngine=void 0;const H1=F1(vi),st=yc;class _t extends H1.default{constructor(){super(),this._middleware=[]}push(e){this._middleware.push(e)}handle(e,r){if(r&&typeof r!="function")throw new Error('"callback" must be a function if provided.');return Array.isArray(e)?r?this._handleBatch(e,r):this._handleBatch(e):r?this._handle(e,r):this._promiseHandle(e)}asMiddleware(){return async(e,r,n,i)=>{try{const[s,c,u]=await _t._runAllMiddleware(e,r,this._middleware);return c?(await _t._runReturnHandlers(u),i(s)):n(async d=>{try{await _t._runReturnHandlers(u)}catch(h){return d(h)}return d()})}catch(s){return i(s)}}}async _handleBatch(e,r){try{const n=await Promise.all(e.map(this._promiseHandle.bind(this)));return r?r(null,n):n}catch(n){if(r)return r(n);throw n}}_promiseHandle(e){return new Promise(r=>{this._handle(e,(n,i)=>{r(i)})})}async _handle(e,r){if(!e||Array.isArray(e)||typeof e!="object"){const c=new st.EthereumRpcError(st.errorCodes.rpc.invalidRequest,`Requests must be plain objects. Received: ${typeof e}`,{request:e});return r(c,{id:void 0,jsonrpc:"2.0",error:c})}if(typeof e.method!="string"){const c=new st.EthereumRpcError(st.errorCodes.rpc.invalidRequest,`Must specify a string method. Received: ${typeof e.method}`,{request:e});return r(c,{id:e.id,jsonrpc:"2.0",error:c})}const n=Object.assign({},e),i={id:n.id,jsonrpc:n.jsonrpc};let s=null;try{await this._processRequest(n,i)}catch(c){s=c}return s&&(delete i.result,i.error||(i.error=st.serializeError(s))),r(s,i)}async _processRequest(e,r){const[n,i,s]=await _t._runAllMiddleware(e,r,this._middleware);if(_t._checkForCompletion(e,r,i),await _t._runReturnHandlers(s),n)throw n}static async _runAllMiddleware(e,r,n){const i=[];let s=null,c=!1;for(const u of n)if([s,c]=await _t._runMiddleware(e,r,u,i),c)break;return[s,c,i.reverse()]}static _runMiddleware(e,r,n,i){return new Promise(s=>{const c=d=>{const h=d||r.error;h&&(r.error=st.serializeError(h)),s([h,!0])},u=d=>{r.error?c(r.error):(d&&(typeof d!="function"&&c(new st.EthereumRpcError(st.errorCodes.rpc.internal,`JsonRpcEngine: "next" return handlers must be functions. Received "${typeof d}" for request: +${Ts(e)}`,{request:e})),i.push(d)),s([null,!1]))};try{n(e,r,u,c)}catch(d){c(d)}})}static async _runReturnHandlers(e){for(const r of e)await new Promise((n,i)=>{r(s=>s?i(s):n())})}static _checkForCompletion(e,r,n){if(!("result"in r)&&!("error"in r))throw new st.EthereumRpcError(st.errorCodes.rpc.internal,`JsonRpcEngine: Response has no error or result for request: +${Ts(e)}`,{request:e});if(!n)throw new st.EthereumRpcError(st.errorCodes.rpc.internal,`JsonRpcEngine: Nothing ended request: +${Ts(e)}`,{request:e})}}Hr.JsonRpcEngine=_t;function Ts(t){return JSON.stringify(t,null,2)}var Jn={};Object.defineProperty(Jn,"__esModule",{value:!0});Jn.mergeMiddleware=void 0;const U1=Hr;function V1(t){const e=new U1.JsonRpcEngine;return t.forEach(r=>e.push(r)),e.asMiddleware()}Jn.mergeMiddleware=V1;(function(t){var e=T&&T.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=T&&T.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Vn,t),r(Wn,t),r(zn,t),r(Fr,t),r(Hr,t),r(Jn,t)})(mi);var Ic={},bi={};const _i=Hs(xc);var Gn={};Object.defineProperty(Gn,"__esModule",{value:!0});var Vo=_i,W1=function(){function t(e){if(this._maxConcurrency=e,this._queue=[],e<=0)throw new Error("semaphore must be initialized to a positive value");this._value=e}return t.prototype.acquire=function(){var e=this,r=this.isLocked(),n=new Promise(function(i){return e._queue.push(i)});return r||this._dispatch(),n},t.prototype.runExclusive=function(e){return Vo.__awaiter(this,void 0,void 0,function(){var r,n,i;return Vo.__generator(this,function(s){switch(s.label){case 0:return[4,this.acquire()];case 1:r=s.sent(),n=r[0],i=r[1],s.label=2;case 2:return s.trys.push([2,,4,5]),[4,e(n)];case 3:return[2,s.sent()];case 4:return i(),[7];case 5:return[2]}})})},t.prototype.isLocked=function(){return this._value<=0},t.prototype.release=function(){if(this._maxConcurrency>1)throw new Error("this method is unavailabel on semaphores with concurrency > 1; use the scoped release returned by acquire instead");if(this._currentReleaser){var e=this._currentReleaser;this._currentReleaser=void 0,e()}},t.prototype._dispatch=function(){var e=this,r=this._queue.shift();if(r){var n=!1;this._currentReleaser=function(){n||(n=!0,e._value++,e._dispatch())},r([this._value--,this._currentReleaser])}},t}();Gn.default=W1;Object.defineProperty(bi,"__esModule",{value:!0});var Wo=_i,z1=Gn,q1=function(){function t(){this._semaphore=new z1.default(1)}return t.prototype.acquire=function(){return Wo.__awaiter(this,void 0,void 0,function(){var e,r;return Wo.__generator(this,function(n){switch(n.label){case 0:return[4,this._semaphore.acquire()];case 1:return e=n.sent(),r=e[1],[2,r]}})})},t.prototype.runExclusive=function(e){return this._semaphore.runExclusive(function(){return e()})},t.prototype.isLocked=function(){return this._semaphore.isLocked()},t.prototype.release=function(){this._semaphore.release()},t}();bi.default=q1;var Zn={};Object.defineProperty(Zn,"__esModule",{value:!0});Zn.withTimeout=void 0;var en=_i;function J1(t,e,r){var n=this;return r===void 0&&(r=new Error("timeout")),{acquire:function(){return new Promise(function(i,s){return en.__awaiter(n,void 0,void 0,function(){var c,u,d;return en.__generator(this,function(h){switch(h.label){case 0:return c=!1,setTimeout(function(){c=!0,s(r)},e),[4,t.acquire()];case 1:return u=h.sent(),c?(d=Array.isArray(u)?u[1]:u,d()):i(u),[2]}})})})},runExclusive:function(i){return en.__awaiter(this,void 0,void 0,function(){var s,c;return en.__generator(this,function(u){switch(u.label){case 0:s=function(){},u.label=1;case 1:return u.trys.push([1,,7,8]),[4,this.acquire()];case 2:return c=u.sent(),Array.isArray(c)?(s=c[1],[4,i(c[0])]):[3,4];case 3:return[2,u.sent()];case 4:return s=c,[4,i()];case 5:return[2,u.sent()];case 6:return[3,8];case 7:return s(),[7];case 8:return[2]}})})},release:function(){t.release()},isLocked:function(){return t.isLocked()}}}Zn.withTimeout=J1;(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=t.Semaphore=t.Mutex=void 0;var e=bi;Object.defineProperty(t,"Mutex",{enumerable:!0,get:function(){return e.default}});var r=Gn;Object.defineProperty(t,"Semaphore",{enumerable:!0,get:function(){return r.default}});var n=Zn;Object.defineProperty(t,"withTimeout",{enumerable:!0,get:function(){return n.withTimeout}})})(Ic);var G1=Q1,Z1=Object.prototype.hasOwnProperty;function Q1(){for(var t={},e=0;efunction(...i){const s=e.promiseModule;return new s((c,u)=>{e.multiArgs?i.push((...h)=>{e.errorFirst?h[0]?u(h):(h.shift(),c(h)):c(h)}):e.errorFirst?i.push((h,y)=>{h?u(h):c(y)}):i.push(c),Reflect.apply(t,this===r?n:this,i)})},qo=new WeakMap;var tg=(t,e)=>{e={exclude:[/.+(?:Sync|Stream)$/],errorFirst:!0,promiseModule:Promise,...e};const r=typeof t;if(!(t!==null&&(r==="object"||r==="function")))throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${t===null?"null":r}\``);const n=(c,u)=>{let d=qo.get(c);if(d||(d={},qo.set(c,d)),u in d)return d[u];const h=k=>typeof k=="string"||typeof u=="symbol"?u===k:k.test(u),y=Reflect.getOwnPropertyDescriptor(c,u),S=y===void 0||y.writable||y.configurable,M=(e.include?e.include.some(h):!e.exclude.some(h))&&S;return d[u]=M,M},i=new WeakMap,s=new Proxy(t,{apply(c,u,d){const h=i.get(c);if(h)return Reflect.apply(h,u,d);const y=e.excludeMain?c:zo(c,e,s,c);return i.set(c,y),Reflect.apply(y,u,d)},get(c,u){const d=c[u];if(!n(c,u)||d===Function.prototype[u])return d;const h=i.get(d);if(h)return h;if(typeof d=="function"){const y=zo(d,e,s,c);return i.set(d,y),y}return d}});return s};const rg=Pr.default;let ng=class extends rg{constructor(){super(),this.updates=[]}async initialize(){}async update(){throw new Error("BaseFilter - no update method specified")}addResults(e){this.updates=this.updates.concat(e),e.forEach(r=>this.emit("update",r))}addInitialResults(e){}getChangesAndClear(){const e=this.updates;return this.updates=[],e}};var Ei=ng;const sg=Ei;let ig=class extends sg{constructor(){super(),this.allResults=[]}async update(){throw new Error("BaseFilterWithHistory - no update method specified")}addResults(e){this.allResults=this.allResults.concat(e),super.addResults(e)}addInitialResults(e){this.allResults=this.allResults.concat(e),super.addInitialResults(e)}getAllResults(){return this.allResults}};var og=ig,Vr={minBlockRef:ag,maxBlockRef:cg,sortBlockRefs:Si,bnToHex:lg,blockRefIsNumber:ug,hexToInt:on,incrementHexInt:dg,intToHex:Cc,unsafeRandomBytes:hg};function ag(...t){return Si(t)[0]}function cg(...t){const e=Si(t);return e[e.length-1]}function Si(t){return t.sort((e,r)=>e==="latest"||r==="earliest"?1:r==="latest"||e==="earliest"?-1:on(e)-on(r))}function lg(t){return"0x"+t.toString(16)}function ug(t){return t&&!["earliest","latest","pending"].includes(t)}function on(t){return t==null?t:Number.parseInt(t,16)}function dg(t){if(t==null)return t;const e=on(t);return Cc(e+1)}function Cc(t){if(t==null)return t;let e=t.toString(16);return e.length%2&&(e="0"+e),"0x"+e}function hg(t){let e="0x";for(let r=0;rn.toLowerCase()))}async initialize({currentBlock:e}){let r=this.params.fromBlock;["latest","pending"].includes(r)&&(r=e),r==="earliest"&&(r="0x0"),this.params.fromBlock=r;const n=vg(this.params.toBlock,e),i=Object.assign({},this.params,{toBlock:n}),s=await this._fetchLogs(i);this.addInitialResults(s)}async update({oldBlock:e,newBlock:r}){const n=r;let i;e?i=mg(e):i=r;const s=Object.assign({},this.params,{fromBlock:i,toBlock:n}),u=(await this._fetchLogs(s)).filter(d=>this.matchLog(d));this.addResults(u)}async _fetchLogs(e){return await gg(n=>this.ethQuery.getLogs(e,n))()}matchLog(e){if(tn(this.params.fromBlock)>=tn(e.blockNumber)||wg(this.params.toBlock)&&tn(this.params.toBlock)<=tn(e.blockNumber))return!1;const r=e.address&&e.address.toLowerCase();return this.params.address&&r&&!this.params.address.includes(r)?!1:this.params.topics.every((i,s)=>{let c=e.topics[s];if(!c)return!1;c=c.toLowerCase();let u=Array.isArray(i)?i:[i];return u.includes(null)?!0:(u=u.map(y=>y.toLowerCase()),u.includes(c))})}};var bg=yg,Mi=_g;async function _g({provider:t,fromBlock:e,toBlock:r}){e||(e=r);const n=Go(e),s=Go(r)-n+1,c=Array(s).fill().map((d,h)=>n+h).map(Eg);let u=await Promise.all(c.map(d=>Mg(t,"eth_getBlockByNumber",[d,!1])));return u=u.filter(d=>d!==null),u}function Go(t){return t==null?t:Number.parseInt(t,16)}function Eg(t){return t==null?t:"0x"+t.toString(16)}function Sg(t,e){return new Promise((r,n)=>{t.sendAsync(e,(i,s)=>{i?n(i):s.error?n(s.error):s.result?r(s.result):n(new Error("Result was empty"))})})}async function Mg(t,e,r){for(let n=0;n<3;n++)try{return await Sg(t,{id:1,jsonrpc:"2.0",method:e,params:r})}catch(i){console.error(`provider.sendAsync failed: ${i.stack||i.message||i}`)}return null}const kg=Ei,Rg=Mi,{incrementHexInt:Ig}=Vr;let Cg=class extends kg{constructor({provider:e,params:r}){super(),this.type="block",this.provider=e}async update({oldBlock:e,newBlock:r}){const n=r,i=Ig(e),c=(await Rg({provider:this.provider,fromBlock:i,toBlock:n})).map(u=>u.hash);this.addResults(c)}};var Ag=Cg;const Ng=Ei,Lg=Mi,{incrementHexInt:Tg}=Vr;let xg=class extends Ng{constructor({provider:e}){super(),this.type="tx",this.provider=e}async update({oldBlock:e}){const r=e,n=Tg(e),i=await Lg({provider:this.provider,fromBlock:n,toBlock:r}),s=[];for(const c of i)s.push(...c.transactions);this.addResults(s)}};var Pg=xg;const $g=Ic.Mutex,{createAsyncMiddleware:Og,createScaffoldMiddleware:Bg}=mi,Dg=bg,jg=Ag,Fg=Pg,{intToHex:Ac,hexToInt:xs}=Vr;var Hg=Ug;function Ug({blockTracker:t,provider:e}){let r=0,n={};const i=new $g,s=Vg({mutex:i}),c=Bg({eth_newFilter:s(Ps(d)),eth_newBlockFilter:s(Ps(h)),eth_newPendingTransactionFilter:s(Ps(y)),eth_uninstallFilter:s(nn(M)),eth_getFilterChanges:s(nn(S)),eth_getFilterLogs:s(nn(E))}),u=async({oldBlock:L,newBlock:R})=>{if(n.length===0)return;const z=await i.acquire();try{await Promise.all(Zt(n).map(async C=>{try{await C.update({oldBlock:L,newBlock:R})}catch(P){console.error(P)}}))}catch(C){console.error(C)}z()};return c.newLogFilter=d,c.newBlockFilter=h,c.newPendingTransactionFilter=y,c.uninstallFilter=M,c.getFilterChanges=S,c.getFilterLogs=E,c.destroy=()=>{O()},c;async function d(L){const R=new Dg({provider:e,params:L});return await k(R),R}async function h(){const L=new jg({provider:e});return await k(L),L}async function y(){const L=new Fg({provider:e});return await k(L),L}async function S(L){const R=xs(L),z=n[R];if(!z)throw new Error(`No filter for index "${R}"`);return z.getChangesAndClear()}async function E(L){const R=xs(L),z=n[R];if(!z)throw new Error(`No filter for index "${R}"`);let C=[];return z.type==="log"&&(C=z.getAllResults()),C}async function M(L){const R=xs(L),C=!!n[R];return C&&await x(R),C}async function k(L){const R=Zt(n).length,z=await t.getLatestBlock();await L.initialize({currentBlock:z}),r++,n[r]=L,L.id=r,L.idHex=Ac(r);const C=Zt(n).length;return B({prevFilterCount:R,newFilterCount:C}),r}async function x(L){const R=Zt(n).length;delete n[L];const z=Zt(n).length;B({prevFilterCount:R,newFilterCount:z})}async function O(){const L=Zt(n).length;n={},B({prevFilterCount:L,newFilterCount:0})}function B({prevFilterCount:L,newFilterCount:R}){if(L===0&&R>0){t.on("sync",u);return}if(L>0&&R===0){t.removeListener("sync",u);return}}}function Ps(t){return nn(async(...e)=>{const r=await t(...e);return Ac(r.id)})}function nn(t){return Og(async(e,r)=>{const n=await t.apply(null,e.params);r.result=n})}function Vg({mutex:t}){return e=>async(r,n,i,s)=>{(await t.acquire())(),e(r,n,i,s)}}function Zt(t,e){const r=[];for(let n in t)r.push(t[n]);return r}const Wg=Pr.default,{createAsyncMiddleware:Zo,createScaffoldMiddleware:zg}=mi,qg=Hg,{unsafeRandomBytes:Jg,incrementHexInt:Gg}=Vr,Zg=Mi;var Qg=Kg;function Kg({blockTracker:t,provider:e}){const r={},n=qg({blockTracker:t,provider:e});let i=!1;const s=new Wg,c=zg({eth_subscribe:Zo(u),eth_unsubscribe:Zo(d)});return c.destroy=y,{events:s,middleware:c};async function u(S,E){if(i)throw new Error("SubscriptionManager - attempting to use after destroying");const M=S.params[0],k=Jg(16);let x;switch(M){case"newHeads":x=O({subId:k});break;case"logs":const L=S.params[1],R=await n.newLogFilter(L);x=B({subId:k,filter:R});break;default:throw new Error(`SubscriptionManager - unsupported subscription type "${M}"`)}r[k]=x,E.result=k;return;function O({subId:L}){const R={type:M,destroy:async()=>{t.removeListener("sync",R.update)},update:async({oldBlock:z,newBlock:C})=>{const P=C,J=Gg(z);(await Zg({provider:e,fromBlock:J,toBlock:P})).map(Xg).filter(Y=>Y!==null).forEach(Y=>{h(L,Y)})}};return t.on("sync",R.update),R}function B({subId:L,filter:R}){return R.on("update",C=>h(L,C)),{type:M,destroy:async()=>await n.uninstallFilter(R.idHex)}}}async function d(S,E){if(i)throw new Error("SubscriptionManager - attempting to use after destroying");const M=S.params[0],k=r[M];if(!k){E.result=!1;return}delete r[M],await k.destroy(),E.result=!0}function h(S,E){s.emit("notification",{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:S,result:E}})}function y(){s.removeAllListeners();for(const S in r)r[S].destroy(),delete r[S];i=!0}}function Xg(t){return t==null?null:{hash:t.hash,parentHash:t.parentHash,sha3Uncles:t.sha3Uncles,miner:t.miner,stateRoot:t.stateRoot,transactionsRoot:t.transactionsRoot,receiptsRoot:t.receiptsRoot,logsBloom:t.logsBloom,difficulty:t.difficulty,number:t.number,gasLimit:t.gasLimit,gasUsed:t.gasUsed,nonce:t.nonce,mixHash:t.mixHash,timestamp:t.timestamp,extraData:t.extraData}}Object.defineProperty(Tn,"__esModule",{value:!0});Tn.SubscriptionManager=void 0;const Yg=$a,ep=Qg,Qo=()=>{};class tp{constructor(e){const r=new Yg.PollingBlockTracker({provider:e,pollingInterval:15e3,setSkipCacheFlag:!0}),{events:n,middleware:i}=ep({blockTracker:r,provider:e});this.events=n,this.subscriptionMiddleware=i}async handleRequest(e){const r={};return await this.subscriptionMiddleware(e,r,Qo,Qo),r}destroy(){this.subscriptionMiddleware.destroy()}}Tn.SubscriptionManager=tp;var Nc=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(rr,"__esModule",{value:!0});rr.CoinbaseWalletProvider=void 0;const rp=Nc(un),np=Dc,U=Sr,j=A,sp=Ir,Ko=it,rn=dr,Ye=cr,$s=Nc(Du),wr=ur,ip=ir,op=Tn,Xo="DefaultChainId",Yo="DefaultJsonRpcUrl";class ap extends np.EventEmitter{constructor(e){var r,n;super(),this._filterPolyfill=new ip.FilterPolyfill(this),this._subscriptionManager=new op.SubscriptionManager(this),this._relay=null,this._addresses=[],this.hasMadeFirstChainChangedEmission=!1,this.setProviderInfo=this.setProviderInfo.bind(this),this.updateProviderInfo=this.updateProviderInfo.bind(this),this.getChainId=this.getChainId.bind(this),this.setAppInfo=this.setAppInfo.bind(this),this.enable=this.enable.bind(this),this.close=this.close.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this),this.request=this.request.bind(this),this._setAddresses=this._setAddresses.bind(this),this.scanQRCode=this.scanQRCode.bind(this),this.genericRequest=this.genericRequest.bind(this),this._chainIdFromOpts=e.chainId,this._jsonRpcUrlFromOpts=e.jsonRpcUrl,this._overrideIsMetaMask=e.overrideIsMetaMask,this._relayProvider=e.relayProvider,this._storage=e.storage,this._relayEventManager=e.relayEventManager,this.diagnostic=e.diagnosticLogger,this.reloadOnDisconnect=!0,this.isCoinbaseWallet=(r=e.overrideIsCoinbaseWallet)!==null&&r!==void 0?r:!0,this.isCoinbaseBrowser=(n=e.overrideIsCoinbaseBrowser)!==null&&n!==void 0?n:!1,this.qrUrl=e.qrUrl;const i=this.getChainId(),s=(0,j.prepend0x)(i.toString(16));this.emit("connect",{chainIdStr:s});const c=this._storage.getItem(Ko.LOCAL_STORAGE_ADDRESSES_KEY);if(c){const u=c.split(" ");u[0]!==""&&(this._addresses=u.map(d=>(0,j.ensureAddressString)(d)),this.emit("accountsChanged",u))}this._subscriptionManager.events.on("notification",u=>{this.emit("message",{type:u.method,data:u.params})}),this._isAuthorized()&&this.initializeRelay(),window.addEventListener("message",u=>{var d;if(!(u.origin!==location.origin||u.source!==window)&&u.data.type==="walletLinkMessage"&&u.data.data.action==="dappChainSwitched"){const h=u.data.data.chainId,y=(d=u.data.data.jsonRpcUrl)!==null&&d!==void 0?d:this.jsonRpcUrl;this.updateProviderInfo(y,Number(h))}})}get selectedAddress(){return this._addresses[0]||void 0}get networkVersion(){return this.getChainId().toString(10)}get chainId(){return(0,j.prepend0x)(this.getChainId().toString(16))}get isWalletLink(){return!0}get isMetaMask(){return this._overrideIsMetaMask}get host(){return this.jsonRpcUrl}get connected(){return!0}isConnected(){return!0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(Yo))!==null&&e!==void 0?e:this._jsonRpcUrlFromOpts}set jsonRpcUrl(e){this._storage.setItem(Yo,e)}disableReloadOnDisconnect(){this.reloadOnDisconnect=!1}setProviderInfo(e,r){this.isCoinbaseBrowser||(this._chainIdFromOpts=r,this._jsonRpcUrlFromOpts=e),this.updateProviderInfo(this.jsonRpcUrl,this.getChainId())}updateProviderInfo(e,r){this.jsonRpcUrl=e;const n=this.getChainId();this._storage.setItem(Xo,r.toString(10)),((0,j.ensureIntNumber)(r)!==n||!this.hasMadeFirstChainChangedEmission)&&(this.emit("chainChanged",this.getChainId()),this.hasMadeFirstChainChangedEmission=!0)}async watchAsset(e,r,n,i,s,c){const d=await(await this.initializeRelay()).watchAsset(e,r,n,i,s,c==null?void 0:c.toString()).promise;return(0,Ye.isErrorResponse)(d)?!1:!!d.result}async addEthereumChain(e,r,n,i,s,c){var u,d;if((0,j.ensureIntNumber)(e)===this.getChainId())return!1;const h=await this.initializeRelay(),y=h.inlineAddEthereumChain(e.toString());!this._isAuthorized()&&!y&&await h.requestEthereumAccounts().promise;const S=await h.addEthereumChain(e.toString(),r,s,n,i,c).promise;return(0,Ye.isErrorResponse)(S)?!1:(((u=S.result)===null||u===void 0?void 0:u.isApproved)===!0&&this.updateProviderInfo(r[0],e),((d=S.result)===null||d===void 0?void 0:d.isApproved)===!0)}async switchEthereumChain(e){const n=await(await this.initializeRelay()).switchEthereumChain(e.toString(10),this.selectedAddress||void 0).promise;if((0,Ye.isErrorResponse)(n)){if(!n.errorCode)return;throw n.errorCode===U.standardErrorCodes.provider.unsupportedChain?U.standardErrors.provider.unsupportedChain():U.standardErrors.provider.custom({message:n.errorMessage,code:n.errorCode})}const i=n.result;i.isApproved&&i.rpcUrl.length>0&&this.updateProviderInfo(i.rpcUrl,e)}setAppInfo(e,r){this.initializeRelay().then(n=>n.setAppInfo(e,r))}async enable(){var e;return(e=this.diagnostic)===null||e===void 0||e.log(wr.EVENTS.ETH_ACCOUNTS_STATE,{method:"provider::enable",addresses_length:this._addresses.length,sessionIdHash:this._relay?rn.Session.hash(this._relay.session.id):void 0}),this._isAuthorized()?[...this._addresses]:await this.send("eth_requestAccounts")}async close(){(await this.initializeRelay()).resetAndReload()}send(e,r){try{const n=this._send(e,r);if(n instanceof Promise)return n.catch(i=>{throw(0,U.serializeError)(i,e)})}catch(n){throw(0,U.serializeError)(n,e)}}_send(e,r){if(typeof e=="string"){const i=e,s=Array.isArray(r)?r:r!==void 0?[r]:[],c={jsonrpc:"2.0",id:0,method:i,params:s};return this._sendRequestAsync(c).then(u=>u.result)}if(typeof r=="function"){const i=e,s=r;return this._sendAsync(i,s)}if(Array.isArray(e))return e.map(s=>this._sendRequest(s));const n=e;return this._sendRequest(n)}async sendAsync(e,r){try{return this._sendAsync(e,r).catch(n=>{throw(0,U.serializeError)(n,e)})}catch(n){return Promise.reject((0,U.serializeError)(n,e))}}async _sendAsync(e,r){if(typeof r!="function")throw new Error("callback is required");if(Array.isArray(e)){const i=r;this._sendMultipleRequestsAsync(e).then(s=>i(null,s)).catch(s=>i(s,null));return}const n=r;return this._sendRequestAsync(e).then(i=>n(null,i)).catch(i=>n(i,null))}async request(e){try{return this._request(e).catch(r=>{throw(0,U.serializeError)(r,e.method)})}catch(r){return Promise.reject((0,U.serializeError)(r,e.method))}}async _request(e){if(!e||typeof e!="object"||Array.isArray(e))throw U.standardErrors.rpc.invalidRequest({message:"Expected a single, non-array, object argument.",data:e});const{method:r,params:n}=e;if(typeof r!="string"||r.length===0)throw U.standardErrors.rpc.invalidRequest({message:"'args.method' must be a non-empty string.",data:e});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw U.standardErrors.rpc.invalidRequest({message:"'args.params' must be an object or array if provided.",data:e});const i=n===void 0?[]:n,s=this._relayEventManager.makeRequestId();return(await this._sendRequestAsync({method:r,params:i,jsonrpc:"2.0",id:s})).result}async scanQRCode(e){const n=await(await this.initializeRelay()).scanQRCode((0,j.ensureRegExpString)(e)).promise;if((0,Ye.isErrorResponse)(n))throw(0,U.serializeError)(n.errorMessage,"scanQRCode");if(typeof n.result!="string")throw(0,U.serializeError)("result was not a string","scanQRCode");return n.result}async genericRequest(e,r){const i=await(await this.initializeRelay()).genericRequest(e,r).promise;if((0,Ye.isErrorResponse)(i))throw(0,U.serializeError)(i.errorMessage,"generic");if(typeof i.result!="string")throw(0,U.serializeError)("result was not a string","generic");return i.result}async connectAndSignIn(e){var r;(r=this.diagnostic)===null||r===void 0||r.log(wr.EVENTS.ETH_ACCOUNTS_STATE,{method:"provider::connectAndSignIn",sessionIdHash:this._relay?rn.Session.hash(this._relay.session.id):void 0});let n;try{const s=await this.initializeRelay();if(!(s instanceof sp.MobileRelay))throw new Error("connectAndSignIn is only supported on mobile");if(n=await s.connectAndSignIn(e).promise,(0,Ye.isErrorResponse)(n))throw new Error(n.errorMessage)}catch(s){throw typeof s.message=="string"&&s.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied account authorization"):s}if(!n.result)throw new Error("accounts received is empty");const{accounts:i}=n.result;return this._setAddresses(i),this.isCoinbaseBrowser||await this.switchEthereumChain(this.getChainId()),n.result}async selectProvider(e){const n=await(await this.initializeRelay()).selectProvider(e).promise;if((0,Ye.isErrorResponse)(n))throw(0,U.serializeError)(n.errorMessage,"selectProvider");if(typeof n.result!="string")throw(0,U.serializeError)("result was not a string","selectProvider");return n.result}supportsSubscriptions(){return!1}subscribe(){throw new Error("Subscriptions are not supported")}unsubscribe(){throw new Error("Subscriptions are not supported")}disconnect(){return!0}_sendRequest(e){const r={jsonrpc:"2.0",id:e.id},{method:n}=e;if(r.result=this._handleSynchronousMethods(e),r.result===void 0)throw new Error(`Coinbase Wallet does not support calling ${n} synchronously without a callback. Please provide a callback parameter to call ${n} asynchronously.`);return r}_setAddresses(e,r){if(!Array.isArray(e))throw new Error("addresses is not an array");const n=e.map(i=>(0,j.ensureAddressString)(i));JSON.stringify(n)!==JSON.stringify(this._addresses)&&(this._addresses=n,this.emit("accountsChanged",this._addresses),this._storage.setItem(Ko.LOCAL_STORAGE_ADDRESSES_KEY,n.join(" ")))}_sendRequestAsync(e){return new Promise((r,n)=>{try{const i=this._handleSynchronousMethods(e);if(i!==void 0)return r({jsonrpc:"2.0",id:e.id,result:i});const s=this._handleAsynchronousFilterMethods(e);if(s!==void 0){s.then(u=>r(Object.assign(Object.assign({},u),{id:e.id}))).catch(u=>n(u));return}const c=this._handleSubscriptionMethods(e);if(c!==void 0){c.then(u=>r({jsonrpc:"2.0",id:e.id,result:u.result})).catch(u=>n(u));return}}catch(i){return n(i)}this._handleAsynchronousMethods(e).then(i=>i&&r(Object.assign(Object.assign({},i),{id:e.id}))).catch(i=>n(i))})}_sendMultipleRequestsAsync(e){return Promise.all(e.map(r=>this._sendRequestAsync(r)))}_handleSynchronousMethods(e){const{method:r}=e,n=e.params||[];switch(r){case"eth_accounts":return this._eth_accounts();case"eth_coinbase":return this._eth_coinbase();case"eth_uninstallFilter":return this._eth_uninstallFilter(n);case"net_version":return this._net_version();case"eth_chainId":return this._eth_chainId();default:return}}async _handleAsynchronousMethods(e){const{method:r}=e,n=e.params||[];switch(r){case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_sign":return this._eth_sign(n);case"eth_ecRecover":return this._eth_ecRecover(n);case"personal_sign":return this._personal_sign(n);case"personal_ecRecover":return this._personal_ecRecover(n);case"eth_signTransaction":return this._eth_signTransaction(n);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(n);case"eth_sendTransaction":return this._eth_sendTransaction(n);case"eth_signTypedData_v1":return this._eth_signTypedData_v1(n);case"eth_signTypedData_v2":return this._throwUnsupportedMethodError();case"eth_signTypedData_v3":return this._eth_signTypedData_v3(n);case"eth_signTypedData_v4":case"eth_signTypedData":return this._eth_signTypedData_v4(n);case"cbWallet_arbitrary":return this._cbwallet_arbitrary(n);case"wallet_addEthereumChain":return this._wallet_addEthereumChain(n);case"wallet_switchEthereumChain":return this._wallet_switchEthereumChain(n);case"wallet_watchAsset":return this._wallet_watchAsset(n)}return(await this.initializeRelay()).makeEthereumJSONRPCRequest(e,this.jsonRpcUrl).catch(s=>{var c;throw(s.code===U.standardErrorCodes.rpc.methodNotFound||s.code===U.standardErrorCodes.rpc.methodNotSupported)&&((c=this.diagnostic)===null||c===void 0||c.log(wr.EVENTS.METHOD_NOT_IMPLEMENTED,{method:e.method,sessionIdHash:this._relay?rn.Session.hash(this._relay.session.id):void 0})),s})}_handleAsynchronousFilterMethods(e){const{method:r}=e,n=e.params||[];switch(r){case"eth_newFilter":return this._eth_newFilter(n);case"eth_newBlockFilter":return this._eth_newBlockFilter();case"eth_newPendingTransactionFilter":return this._eth_newPendingTransactionFilter();case"eth_getFilterChanges":return this._eth_getFilterChanges(n);case"eth_getFilterLogs":return this._eth_getFilterLogs(n)}}_handleSubscriptionMethods(e){switch(e.method){case"eth_subscribe":case"eth_unsubscribe":return this._subscriptionManager.handleRequest(e)}}_isKnownAddress(e){try{const r=(0,j.ensureAddressString)(e);return this._addresses.map(i=>(0,j.ensureAddressString)(i)).includes(r)}catch{}return!1}_ensureKnownAddress(e){var r;if(!this._isKnownAddress(e))throw(r=this.diagnostic)===null||r===void 0||r.log(wr.EVENTS.UNKNOWN_ADDRESS_ENCOUNTERED),new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const r=e.from?(0,j.ensureAddressString)(e.from):this.selectedAddress;if(!r)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(r);const n=e.to?(0,j.ensureAddressString)(e.to):null,i=e.value!=null?(0,j.ensureBN)(e.value):new rp.default(0),s=e.data?(0,j.ensureBuffer)(e.data):Buffer.alloc(0),c=e.nonce!=null?(0,j.ensureIntNumber)(e.nonce):null,u=e.gasPrice!=null?(0,j.ensureBN)(e.gasPrice):null,d=e.maxFeePerGas!=null?(0,j.ensureBN)(e.maxFeePerGas):null,h=e.maxPriorityFeePerGas!=null?(0,j.ensureBN)(e.maxPriorityFeePerGas):null,y=e.gas!=null?(0,j.ensureBN)(e.gas):null,S=e.chainId?(0,j.ensureIntNumber)(e.chainId):this.getChainId();return{fromAddress:r,toAddress:n,weiValue:i,data:s,nonce:c,gasPriceInWei:u,maxFeePerGas:d,maxPriorityFeePerGas:h,gasLimit:y,chainId:S}}_isAuthorized(){return this._addresses.length>0}_requireAuthorization(){if(!this._isAuthorized())throw U.standardErrors.provider.unauthorized({})}_throwUnsupportedMethodError(){throw U.standardErrors.provider.unsupportedMethod({})}async _signEthereumMessage(e,r,n,i){this._ensureKnownAddress(r);try{const c=await(await this.initializeRelay()).signEthereumMessage(e,r,n,i).promise;if((0,Ye.isErrorResponse)(c))throw new Error(c.errorMessage);return{jsonrpc:"2.0",id:0,result:c.result}}catch(s){throw typeof s.message=="string"&&s.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied message signature"):s}}async _ethereumAddressFromSignedMessage(e,r,n){const s=await(await this.initializeRelay()).ethereumAddressFromSignedMessage(e,r,n).promise;if((0,Ye.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}_eth_accounts(){return[...this._addresses]}_eth_coinbase(){return this.selectedAddress||null}_net_version(){return this.getChainId().toString(10)}_eth_chainId(){return(0,j.hexStringFromIntNumber)(this.getChainId())}getChainId(){const e=this._storage.getItem(Xo);if(!e)return(0,j.ensureIntNumber)(this._chainIdFromOpts);const r=parseInt(e,10);return(0,j.ensureIntNumber)(r)}async _eth_requestAccounts(){var e;if((e=this.diagnostic)===null||e===void 0||e.log(wr.EVENTS.ETH_ACCOUNTS_STATE,{method:"provider::_eth_requestAccounts",addresses_length:this._addresses.length,sessionIdHash:this._relay?rn.Session.hash(this._relay.session.id):void 0}),this._isAuthorized())return Promise.resolve({jsonrpc:"2.0",id:0,result:this._addresses});let r;try{if(r=await(await this.initializeRelay()).requestEthereumAccounts().promise,(0,Ye.isErrorResponse)(r))throw new Error(r.errorMessage)}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied account authorization"):n}if(!r.result)throw new Error("accounts received is empty");return this._setAddresses(r.result),this.isCoinbaseBrowser||await this.switchEthereumChain(this.getChainId()),{jsonrpc:"2.0",id:0,result:this._addresses}}_eth_sign(e){this._requireAuthorization();const r=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._signEthereumMessage(n,r,!1)}_eth_ecRecover(e){const r=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(r,n,!1)}_personal_sign(e){this._requireAuthorization();const r=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureAddressString)(e[1]);return this._signEthereumMessage(r,n,!0)}_personal_ecRecover(e){const r=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(r,n,!0)}async _eth_signTransaction(e){this._requireAuthorization();const r=this._prepareTransactionParams(e[0]||{});try{const i=await(await this.initializeRelay()).signEthereumTransaction(r).promise;if((0,Ye.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_sendRawTransaction(e){const r=(0,j.ensureBuffer)(e[0]),i=await(await this.initializeRelay()).submitEthereumTransaction(r,this.getChainId()).promise;if((0,Ye.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}async _eth_sendTransaction(e){this._requireAuthorization();const r=this._prepareTransactionParams(e[0]||{});try{const i=await(await this.initializeRelay()).signAndSubmitEthereumTransaction(r).promise;if((0,Ye.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?U.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_signTypedData_v1(e){this._requireAuthorization();const r=(0,j.ensureParsedJSONObject)(e[0]),n=(0,j.ensureAddressString)(e[1]);this._ensureKnownAddress(n);const i=$s.default.hashForSignTypedDataLegacy({data:r}),s=JSON.stringify(r,null,2);return this._signEthereumMessage(i,n,!1,s)}async _eth_signTypedData_v3(e){this._requireAuthorization();const r=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(r);const i=$s.default.hashForSignTypedData_v3({data:n}),s=JSON.stringify(n,null,2);return this._signEthereumMessage(i,r,!1,s)}async _eth_signTypedData_v4(e){this._requireAuthorization();const r=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(r);const i=$s.default.hashForSignTypedData_v4({data:n}),s=JSON.stringify(n,null,2);return this._signEthereumMessage(i,r,!1,s)}async _cbwallet_arbitrary(e){const r=e[0],n=e[1];if(typeof n!="string")throw new Error("parameter must be a string");if(typeof r!="object"||r===null)throw new Error("parameter must be an object");return{jsonrpc:"2.0",id:0,result:await this.genericRequest(r,n)}}async _wallet_addEthereumChain(e){var r,n,i,s;const c=e[0];if(((r=c.rpcUrls)===null||r===void 0?void 0:r.length)===0)return{jsonrpc:"2.0",id:0,error:{code:2,message:"please pass in at least 1 rpcUrl"}};if(!c.chainName||c.chainName.trim()==="")throw U.standardErrors.rpc.invalidParams("chainName is a required field");if(!c.nativeCurrency)throw U.standardErrors.rpc.invalidParams("nativeCurrency is a required field");const u=parseInt(c.chainId,16);return await this.addEthereumChain(u,(n=c.rpcUrls)!==null&&n!==void 0?n:[],(i=c.blockExplorerUrls)!==null&&i!==void 0?i:[],c.chainName,(s=c.iconUrls)!==null&&s!==void 0?s:[],c.nativeCurrency)?{jsonrpc:"2.0",id:0,result:null}:{jsonrpc:"2.0",id:0,error:{code:2,message:"unable to add ethereum chain"}}}async _wallet_switchEthereumChain(e){const r=e[0];return await this.switchEthereumChain(parseInt(r.chainId,16)),{jsonrpc:"2.0",id:0,result:null}}async _wallet_watchAsset(e){const r=Array.isArray(e)?e[0]:e;if(!r.type)throw U.standardErrors.rpc.invalidParams("Type is required");if((r==null?void 0:r.type)!=="ERC20")throw U.standardErrors.rpc.invalidParams(`Asset of type '${r.type}' is not supported`);if(!(r!=null&&r.options))throw U.standardErrors.rpc.invalidParams("Options are required");if(!(r!=null&&r.options.address))throw U.standardErrors.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:i,symbol:s,image:c,decimals:u}=r.options;return{jsonrpc:"2.0",id:0,result:await this.watchAsset(r.type,i,s,u,c,n)}}_eth_uninstallFilter(e){const r=(0,j.ensureHexString)(e[0]);return this._filterPolyfill.uninstallFilter(r)}async _eth_newFilter(e){const r=e[0];return{jsonrpc:"2.0",id:0,result:await this._filterPolyfill.newFilter(r)}}async _eth_newBlockFilter(){return{jsonrpc:"2.0",id:0,result:await this._filterPolyfill.newBlockFilter()}}async _eth_newPendingTransactionFilter(){return{jsonrpc:"2.0",id:0,result:await this._filterPolyfill.newPendingTransactionFilter()}}_eth_getFilterChanges(e){const r=(0,j.ensureHexString)(e[0]);return this._filterPolyfill.getFilterChanges(r)}_eth_getFilterLogs(e){const r=(0,j.ensureHexString)(e[0]);return this._filterPolyfill.getFilterLogs(r)}initializeRelay(){return this._relay?Promise.resolve(this._relay):this._relayProvider().then(e=>(e.setAccountsCallback((r,n)=>this._setAddresses(r,n)),e.setChainCallback((r,n)=>{this.updateProviderInfo(n,parseInt(r,10))}),e.setDappDefaultChainCallback(this._chainIdFromOpts),this._relay=e,e))}}rr.CoinbaseWalletProvider=ap;var Qn={};Object.defineProperty(Qn,"__esModule",{value:!0});Qn.RelayEventManager=void 0;const cp=A;class lp{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,r=(0,cp.prepend0x)(e.toString(16));return this.callbacks.get(r)&&this.callbacks.delete(r),e}}Qn.RelayEventManager=lp;Object.defineProperty(br,"__esModule",{value:!0});br.CoinbaseWalletSDK=void 0;const up=cn,dp=ln,ea=A,hp=pn,fp=rr,gp=Ir,pp=Tr,mp=Qn,vp=Ar,wp=Cr,Lc=lr;class Kn{constructor(e){var r,n,i;this._appName="",this._appLogoUrl=null,this._relay=null,this._relayEventManager=null;const s=e.linkAPIUrl||dp.LINK_API_URL;typeof e.overrideIsMetaMask>"u"?this._overrideIsMetaMask=!1:this._overrideIsMetaMask=e.overrideIsMetaMask,this._overrideIsCoinbaseWallet=(r=e.overrideIsCoinbaseWallet)!==null&&r!==void 0?r:!0,this._overrideIsCoinbaseBrowser=(n=e.overrideIsCoinbaseBrowser)!==null&&n!==void 0?n:!1,this._diagnosticLogger=e.diagnosticLogger,this._reloadOnDisconnect=(i=e.reloadOnDisconnect)!==null&&i!==void 0?i:!0;const c=new URL(s),u=`${c.protocol}//${c.host}`;if(this._storage=new hp.ScopedLocalStorage(`-walletlink:${u}`),this._storage.setItem("version",Kn.VERSION),this.walletExtension||this.coinbaseBrowser)return;this._relayEventManager=new mp.RelayEventManager;const d=(0,ea.isMobileWeb)(),h=e.uiConstructor||(S=>d?new pp.MobileRelayUI(S):new vp.WalletLinkRelayUI(S)),y={linkAPIUrl:s,version:Lc.LIB_VERSION,darkMode:!!e.darkMode,headlessMode:!!e.headlessMode,uiConstructor:h,storage:this._storage,relayEventManager:this._relayEventManager,diagnosticLogger:this._diagnosticLogger,reloadOnDisconnect:this._reloadOnDisconnect,enableMobileWalletLink:e.enableMobileWalletLink};this._relay=d?new gp.MobileRelay(y):new wp.WalletLinkRelay(y),this.setAppInfo(e.appName,e.appLogoUrl),!e.headlessMode&&this._relay.attachUI()}makeWeb3Provider(e="",r=1){const n=this.walletExtension;if(n)return this.isCipherProvider(n)||n.setProviderInfo(e,r),this._reloadOnDisconnect===!1&&typeof n.disableReloadOnDisconnect=="function"&&n.disableReloadOnDisconnect(),n;const i=this.coinbaseBrowser;if(i)return i;const s=this._relay;if(!s||!this._relayEventManager||!this._storage)throw new Error("Relay not initialized, should never happen");return e||s.setConnectDisabled(!0),new fp.CoinbaseWalletProvider({relayProvider:()=>Promise.resolve(s),relayEventManager:this._relayEventManager,storage:this._storage,jsonRpcUrl:e,chainId:r,qrUrl:this.getQrUrl(),diagnosticLogger:this._diagnosticLogger,overrideIsMetaMask:this._overrideIsMetaMask,overrideIsCoinbaseWallet:this._overrideIsCoinbaseWallet,overrideIsCoinbaseBrowser:this._overrideIsCoinbaseBrowser})}setAppInfo(e,r){var n;this._appName=e||"DApp",this._appLogoUrl=r||(0,ea.getFavicon)();const i=this.walletExtension;i?this.isCipherProvider(i)||i.setAppInfo(this._appName,this._appLogoUrl):(n=this._relay)===null||n===void 0||n.setAppInfo(this._appName,this._appLogoUrl)}disconnect(){var e;const r=this===null||this===void 0?void 0:this.walletExtension;r?r.close():(e=this._relay)===null||e===void 0||e.resetAndReload()}getQrUrl(){var e,r;return(r=(e=this._relay)===null||e===void 0?void 0:e.getQRCodeUrl())!==null&&r!==void 0?r:null}getCoinbaseWalletLogo(e,r=240){return(0,up.walletLogo)(e,r)}get walletExtension(){var e;return(e=window.coinbaseWalletExtension)!==null&&e!==void 0?e:window.walletLinkExtension}get coinbaseBrowser(){var e,r;try{const n=(e=window.ethereum)!==null&&e!==void 0?e:(r=window.top)===null||r===void 0?void 0:r.ethereum;return n&&"isCoinbaseBrowser"in n&&n.isCoinbaseBrowser?n:void 0}catch{return}}isCipherProvider(e){return typeof e.isCipher=="boolean"&&e.isCipher}}br.CoinbaseWalletSDK=Kn;Kn.VERSION=Lc.LIB_VERSION;(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.CoinbaseWalletProvider=t.CoinbaseWalletSDK=void 0;const e=br,r=rr;var n=br;Object.defineProperty(t,"CoinbaseWalletSDK",{enumerable:!0,get:function(){return n.CoinbaseWalletSDK}});var i=rr;Object.defineProperty(t,"CoinbaseWalletProvider",{enumerable:!0,get:function(){return i.CoinbaseWalletProvider}}),t.default=e.CoinbaseWalletSDK,typeof window<"u"&&(window.CoinbaseWalletSDK=e.CoinbaseWalletSDK,window.CoinbaseWalletProvider=r.CoinbaseWalletProvider,window.WalletLink=e.CoinbaseWalletSDK,window.WalletLinkProvider=r.CoinbaseWalletProvider)})(ra);const yp=Pc(ra),Pp=Object.freeze(Object.defineProperty({__proto__:null,default:yp},Symbol.toStringTag,{value:"Module"}));export{Pp as i}; diff --git a/buddybook/assets/index-Vk_Kr0Nw.js b/buddybook/assets/index-Vk_Kr0Nw.js deleted file mode 100644 index bace430..0000000 --- a/buddybook/assets/index-Vk_Kr0Nw.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-iQrFj71y.js","assets/index-CLqSQ1yP.js","assets/index-Dt_CGZqf.css"])))=>i.map(i=>d[i]); -import{_ as pe}from"./index-CLqSQ1yP.js";const me=Symbol(),ee=Object.getPrototypeOf,Y=new WeakMap,he=e=>e&&(Y.has(e)?Y.get(e):ee(e)===Object.prototype||ee(e)===Array.prototype),ge=e=>he(e)&&e[me]||null,te=(e,t=!0)=>{Y.set(e,t)},z={BASE_URL:"/buddybook/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_WALLETCONNECT_PROJECT_ID:"1d93edc21291f98e3bed6ff7617ff539"},J=e=>typeof e=="object"&&e!==null,L=new WeakMap,x=new WeakSet,ye=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>J(o)&&!x.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),n=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,g,I=n)=>{const v=l.get(o);if((v==null?void 0:v[0])===g)return v[1];const b=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(b,!0),l.set(o,[g,b]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(b,j))return;const O=Reflect.get(o,j),A={value:O,enumerable:!0,configurable:!0};if(x.has(O))te(O,!1);else if(O instanceof Promise)delete A.value,A.get=()=>I(O);else if(L.has(O)){const[y,H]=L.get(O);A.value=c(y,H(),I)}Object.defineProperty(b,j,A)}),Object.preventExtensions(b)},d=new WeakMap,f=[1,1],W=o=>{if(!J(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,b=(i,a=++f[0])=>{I!==a&&(I=a,v.forEach(r=>r(i,a)))};let j=f[1];const O=(i=++f[1])=>(j!==i&&!v.size&&(j=i,y.forEach(([a])=>{const r=a[1](i);r>I&&(I=r)})),I),A=i=>(a,r)=>{const h=[...a];h[1]=[i,...h[1]],b(h,r)},y=new Map,H=(i,a)=>{if((z?"production":void 0)!=="production"&&y.has(i))throw new Error("prop listener already exists");if(v.size){const r=a[3](A(i));y.set(i,[a,r])}else y.set(i,[a])},Z=i=>{var a;const r=y.get(i);r&&(y.delete(i),(a=r[1])==null||a.call(r))},ue=i=>(v.add(i),v.size===1&&y.forEach(([r,h],U)=>{if((z?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const N=r[3](A(U));y.set(U,[r,N])}),()=>{v.delete(i),v.size===0&&y.forEach(([r,h],U)=>{h&&(h(),y.set(U,[r]))})}),q=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),R=t(q,{deleteProperty(i,a){const r=Reflect.get(i,a);Z(a);const h=Reflect.deleteProperty(i,a);return h&&b(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),N=Reflect.get(i,a,h);if(U&&(e(N,r)||d.has(r)&&e(N,d.get(r))))return!0;Z(a),J(r)&&(r=ge(r)||r);let V=r;if(r instanceof Promise)r.then(C=>{r.status="fulfilled",r.value=C,b(["resolve",[a],C])}).catch(C=>{r.status="rejected",r.reason=C,b(["reject",[a],C])});else{!L.has(r)&&s(r)&&(V=W(r));const C=!x.has(V)&&L.get(V);C&&H(a,C)}return Reflect.set(i,a,V,h),b(["set",[a],r,N]),!0}});d.set(o,R);const fe=[q,O,c,ue];return L.set(R,fe),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(R[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(q,i,a)}),R})=>[W,L,x,e,t,s,n,l,c,d,f],[ve]=ye();function P(e={}){return ve(e)}function D(e,t,s){const n=L.get(e);(z?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let l;const c=[],d=n[3];let f=!1;const o=d(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function be(e,t){const s=L.get(e);(z?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[n,l,c]=s;return c(n,l(),t)}const u=P({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),de={state:u,subscribe(e){return D(u,()=>e(u))},push(e,t){e!==u.view&&(u.view=e,t&&(u.data=t),u.history.push(e))},reset(e){u.view=e,u.history=[e]},replace(e){u.history.length>1&&(u.history[u.history.length-1]=e,u.view=e)},goBack(){if(u.history.length>1){u.history.pop();const[e]=u.history.slice(-1);u.view=e}},setData(e){u.data=e}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return m.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;if(n.startsWith("https://t.me")){const c=Buffer.from(t).toString("base64").replace(/[=]/g,"");n.endsWith("/")&&(n=n.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const d=new URL(n);return d.searchParams.set("startapp",c),d.toString()}n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){const s=this.isTelegram()?"_blank":t;window.open(e,s,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(m.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=de.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},we=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:we,userSessionId:"",events:[],connectedWalletId:void 0}),Ie={state:p,subscribe(e){return D(p.events,()=>e(be(p.events[p.events.length-1])))},initialize(){p.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(p.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){p.connectedWalletId=e},click(e){if(p.enabled){const t={type:"CLICK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},track(e){if(p.enabled){const t={type:"TRACK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},view(e){if(p.enabled){const t={type:"VIEW",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}}},_=P({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),w={state:_,subscribe(e){return D(_,()=>e(_))},setChains(e){_.chains=e},setWalletConnectUri(e){_.walletConnectUri=e},setIsCustomDesktop(e){_.isCustomDesktop=e},setIsCustomMobile(e){_.isCustomMobile=e},setIsDataLoaded(e){_.isDataLoaded=e},setIsUiLoaded(e){_.isUiLoaded=e},setIsAuth(e){_.isAuth=e}},B=P({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),$={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;Ie.initialize(),w.setChains(e.chains),w.setIsAuth(!!e.enableAuthMode),w.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),w.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),m.setModalVersionInStorage(),Object.assign(B,e)}};var _e=Object.defineProperty,se=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,We=(e,t)=>{for(var s in t||(t={}))Ee.call(t,s)&&ne(e,s,t[s]);if(se)for(var s of se(t))Oe.call(t,s)&&ne(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.7.0";async function K(e,t){const s=We({sdkType:Q,sdkVersion:X},t),n=new URL(e,G);return n.searchParams.append("projectId",$.state.projectId),Object.entries(s).forEach(([c,d])=>{d&&n.searchParams.append(c,String(d))}),(await fetch(n)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var Ce=Object.defineProperty,oe=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ae=(e,t)=>{for(var s in t||(t={}))Le.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))Pe.call(t,s)&&re(e,s,t[s]);return e};const ae=m.isMobile(),E=P({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),ke={state:E,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=$.state;if(e==="NONE"||t==="ALL"&&!e)return E.recomendedWallets;if(m.isArray(e)){const n={recommendedIds:e.join(",")},{listings:l}=await M.getAllListings(n),c=Object.values(l);c.sort((d,f)=>{const W=e.indexOf(d.id),o=e.indexOf(f.id);return W-o}),E.recomendedWallets=c}else{const{chains:s,isAuth:n}=w.state,l=s==null?void 0:s.join(","),c=m.isArray(t),d={page:1,sdks:n?"auth_v1":void 0,entries:m.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=ae?await M.getMobileListings(d):await M.getDesktopListings(d);E.recomendedWallets=Object.values(f)}return E.recomendedWallets},async getWallets(e){const t=Ae({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:n}=$.state,{recomendedWallets:l}=E;if(n==="ALL")return E.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):m.isArray(s)&&(t.excludedIds=s.join(",")),m.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),w.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:d}=e,{listings:f,total:W}=ae?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),g=d?"search":"wallets";return E[g]={listings:[...E[g].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){E.search={listings:[],total:0,page:1}}},T=P({open:!1}),F={state:T,subscribe(e){return D(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=w.state;if(m.removeWalletConnectDeepLink(),w.setWalletConnectUri(e==null?void 0:e.uri),w.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=w.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),T.open=!0,t())},200)}})},close(){T.open=!1}};var Me=Object.defineProperty,ie=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,je=(e,t)=>{for(var s in t||(t={}))Se.call(t,s)&&le(e,s,t[s]);if(ie)for(var s of ie(t))De.call(t,s)&&le(e,s,t[s]);return e};function Ue(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const k=P({themeMode:Ue()?"dark":"light"}),ce={state:k,subscribe(e){return D(k,()=>e(k))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(k.themeMode=t),s&&(k.themeVariables=je({},s))}},S=P({open:!1,message:"",variant:"success"}),Re={state:S,subscribe(e){return D(S,()=>e(S))},openToast(e,t){S.open=!0,S.message=e,S.variant=t},closeToast(){S.open=!1}};class Te{constructor(t){this.openModal=F.open,this.closeModal=F.close,this.subscribeModal=F.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),$.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-iQrFj71y.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),w.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Te},Symbol.toStringTag,{value:"Module"}));export{m as C,ke as E,F as M,w as O,de as R,ce as T,Re as a,Ie as b,$ as c,Ve as i}; diff --git a/buddybook/assets/index-CLqSQ1yP.js b/buddybook/assets/index-mI-wCQlz.js similarity index 65% rename from buddybook/assets/index-CLqSQ1yP.js rename to buddybook/assets/index-mI-wCQlz.js index 9e1c33c..16f0134 100644 --- a/buddybook/assets/index-CLqSQ1yP.js +++ b/buddybook/assets/index-mI-wCQlz.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C5SJQ4cM.js","assets/hooks.module-CBpTII2E.js","assets/events-CHFTlyqt.js","assets/inherits_browser-Dprisln6.js","assets/index-BRDupqIG.js","assets/index-DaaUGS07.js","assets/index.es-BvE4YOl7.js"])))=>i.map(i=>d[i]); -var lu=Object.defineProperty;var Fs=et=>{throw TypeError(et)};var uu=(et,o,tt)=>o in et?lu(et,o,{enumerable:!0,configurable:!0,writable:!0,value:tt}):et[o]=tt;var wt=(et,o,tt)=>uu(et,typeof o!="symbol"?o+"":o,tt),as=(et,o,tt)=>o.has(et)||Fs("Cannot "+tt);var Lt=(et,o,tt)=>(as(et,o,"read from private field"),tt?tt.call(et):o.get(et)),hr=(et,o,tt)=>o.has(et)?Fs("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(et):o.set(et,tt),ur=(et,o,tt,rt)=>(as(et,o,"write to private field"),rt?rt.call(et,tt):o.set(et,tt),tt),fr=(et,o,tt)=>(as(et,o,"access private method"),tt);var Cn=(et,o,tt,rt)=>({set _(nt){ur(et,o,nt,tt)},get _(){return Lt(et,o,rt)}});function _mergeNamespaces(et,o){for(var tt=0;ttrt[nt]})}}}return Object.freeze(Object.defineProperty(et,Symbol.toStringTag,{value:"Module"}))}(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const nt of document.querySelectorAll('link[rel="modulepreload"]'))rt(nt);new MutationObserver(nt=>{for(const ot of nt)if(ot.type==="childList")for(const it of ot.addedNodes)it.tagName==="LINK"&&it.rel==="modulepreload"&&rt(it)}).observe(document,{childList:!0,subtree:!0});function tt(nt){const ot={};return nt.integrity&&(ot.integrity=nt.integrity),nt.referrerPolicy&&(ot.referrerPolicy=nt.referrerPolicy),nt.crossOrigin==="use-credentials"?ot.credentials="include":nt.crossOrigin==="anonymous"?ot.credentials="omit":ot.credentials="same-origin",ot}function rt(nt){if(nt.ep)return;nt.ep=!0;const ot=tt(nt);fetch(nt.href,ot)}})();var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(et){return et&&et.__esModule&&Object.prototype.hasOwnProperty.call(et,"default")?et.default:et}function getAugmentedNamespace(et){if(et.__esModule)return et;var o=et.default;if(typeof o=="function"){var tt=function rt(){return this instanceof rt?Reflect.construct(o,arguments,this.constructor):o.apply(this,arguments)};tt.prototype=o.prototype}else tt={};return Object.defineProperty(tt,"__esModule",{value:!0}),Object.keys(et).forEach(function(rt){var nt=Object.getOwnPropertyDescriptor(et,rt);Object.defineProperty(tt,rt,nt.get?nt:{enumerable:!0,get:function(){return et[rt]}})}),tt}var jsxRuntime={exports:{}},reactJsxRuntime_production_min={},react={exports:{}},react_production_min={};/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BcaB-heU.js","assets/hooks.module-BoePljmY.js","assets/events-_Z2_TJp5.js","assets/inherits_browser-DVmoQh9i.js","assets/index-Ds5ZBbkh.js","assets/index-DSEy00EN.js","assets/index.es-pymM7oJc.js"])))=>i.map(i=>d[i]); +var cu=Object.defineProperty;var Us=et=>{throw TypeError(et)};var lu=(et,o,tt)=>o in et?cu(et,o,{enumerable:!0,configurable:!0,writable:!0,value:tt}):et[o]=tt;var wt=(et,o,tt)=>lu(et,typeof o!="symbol"?o+"":o,tt),cs=(et,o,tt)=>o.has(et)||Us("Cannot "+tt);var Ot=(et,o,tt)=>(cs(et,o,"read from private field"),tt?tt.call(et):o.get(et)),fr=(et,o,tt)=>o.has(et)?Us("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(et):o.set(et,tt),lr=(et,o,tt,rt)=>(cs(et,o,"write to private field"),rt?rt.call(et,tt):o.set(et,tt),tt),mr=(et,o,tt)=>(cs(et,o,"access private method"),tt);var Cn=(et,o,tt,rt)=>({set _(nt){lr(et,o,nt,tt)},get _(){return Ot(et,o,rt)}});function _mergeNamespaces(et,o){for(var tt=0;ttrt[nt]})}}}return Object.freeze(Object.defineProperty(et,Symbol.toStringTag,{value:"Module"}))}(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const nt of document.querySelectorAll('link[rel="modulepreload"]'))rt(nt);new MutationObserver(nt=>{for(const ot of nt)if(ot.type==="childList")for(const it of ot.addedNodes)it.tagName==="LINK"&&it.rel==="modulepreload"&&rt(it)}).observe(document,{childList:!0,subtree:!0});function tt(nt){const ot={};return nt.integrity&&(ot.integrity=nt.integrity),nt.referrerPolicy&&(ot.referrerPolicy=nt.referrerPolicy),nt.crossOrigin==="use-credentials"?ot.credentials="include":nt.crossOrigin==="anonymous"?ot.credentials="omit":ot.credentials="same-origin",ot}function rt(nt){if(nt.ep)return;nt.ep=!0;const ot=tt(nt);fetch(nt.href,ot)}})();var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function getDefaultExportFromCjs(et){return et&&et.__esModule&&Object.prototype.hasOwnProperty.call(et,"default")?et.default:et}function getAugmentedNamespace(et){if(et.__esModule)return et;var o=et.default;if(typeof o=="function"){var tt=function rt(){return this instanceof rt?Reflect.construct(o,arguments,this.constructor):o.apply(this,arguments)};tt.prototype=o.prototype}else tt={};return Object.defineProperty(tt,"__esModule",{value:!0}),Object.keys(et).forEach(function(rt){var nt=Object.getOwnPropertyDescriptor(et,rt);Object.defineProperty(tt,rt,nt.get?nt:{enumerable:!0,get:function(){return et[rt]}})}),tt}var jsxRuntime={exports:{}},reactJsxRuntime_production_min={},react={exports:{}},react_production_min={};/** * @license React * react.production.min.js * @@ -7,7 +7,7 @@ var lu=Object.defineProperty;var Fs=et=>{throw TypeError(et)};var uu=(et,o,tt)=> * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var l$4=Symbol.for("react.element"),n$5=Symbol.for("react.portal"),p$6=Symbol.for("react.fragment"),q$6=Symbol.for("react.strict_mode"),r$5=Symbol.for("react.profiler"),t$4=Symbol.for("react.provider"),u$3=Symbol.for("react.context"),v$5=Symbol.for("react.forward_ref"),w$4=Symbol.for("react.suspense"),x$2=Symbol.for("react.memo"),y$3=Symbol.for("react.lazy"),z$4=Symbol.iterator;function A$2(et){return et===null||typeof et!="object"?null:(et=z$4&&et[z$4]||et["@@iterator"],typeof et=="function"?et:null)}var B$2={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C$2=Object.assign,D$2={};function E$2(et,o,tt){this.props=et,this.context=o,this.refs=D$2,this.updater=tt||B$2}E$2.prototype.isReactComponent={};E$2.prototype.setState=function(et,o){if(typeof et!="object"&&typeof et!="function"&&et!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,et,o,"setState")};E$2.prototype.forceUpdate=function(et){this.updater.enqueueForceUpdate(this,et,"forceUpdate")};function F$1(){}F$1.prototype=E$2.prototype;function G$2(et,o,tt){this.props=et,this.context=o,this.refs=D$2,this.updater=tt||B$2}var H$2=G$2.prototype=new F$1;H$2.constructor=G$2;C$2(H$2,E$2.prototype);H$2.isPureReactComponent=!0;var I$2=Array.isArray,J$1=Object.prototype.hasOwnProperty,K$2={current:null},L$2={key:!0,ref:!0,__self:!0,__source:!0};function M$2(et,o,tt){var rt,nt={},ot=null,it=null;if(o!=null)for(rt in o.ref!==void 0&&(it=o.ref),o.key!==void 0&&(ot=""+o.key),o)J$1.call(o,rt)&&!L$2.hasOwnProperty(rt)&&(nt[rt]=o[rt]);var st=arguments.length-2;if(st===1)nt.children=tt;else if(1{throw TypeError(et)};var uu=(et,o,tt)=> * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var f$2=reactExports,k$4=Symbol.for("react.element"),l$3=Symbol.for("react.fragment"),m$6=Object.prototype.hasOwnProperty,n$4=f$2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p$5={key:!0,ref:!0,__self:!0,__source:!0};function q$5(et,o,tt){var rt,nt={},ot=null,it=null;tt!==void 0&&(ot=""+tt),o.key!==void 0&&(ot=""+o.key),o.ref!==void 0&&(it=o.ref);for(rt in o)m$6.call(o,rt)&&!p$5.hasOwnProperty(rt)&&(nt[rt]=o[rt]);if(et&&et.defaultProps)for(rt in o=et.defaultProps,o)nt[rt]===void 0&&(nt[rt]=o[rt]);return{$$typeof:k$4,type:et,key:ot,ref:it,props:nt,_owner:n$4.current}}reactJsxRuntime_production_min.Fragment=l$3;reactJsxRuntime_production_min.jsx=q$5;reactJsxRuntime_production_min.jsxs=q$5;jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports,reactDom={exports:{}},reactDom_production_min={},scheduler={exports:{}},scheduler_production_min={};/** + */var f$2=reactExports,k$4=Symbol.for("react.element"),l$3=Symbol.for("react.fragment"),m$6=Object.prototype.hasOwnProperty,n$4=f$2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p$5={key:!0,ref:!0,__self:!0,__source:!0};function q$5(et,o,tt){var rt,nt={},ot=null,it=null;tt!==void 0&&(ot=""+tt),o.key!==void 0&&(ot=""+o.key),o.ref!==void 0&&(it=o.ref);for(rt in o)m$6.call(o,rt)&&!p$5.hasOwnProperty(rt)&&(nt[rt]=o[rt]);if(et&&et.defaultProps)for(rt in o=et.defaultProps,o)nt[rt]===void 0&&(nt[rt]=o[rt]);return{$$typeof:k$4,type:et,key:ot,ref:it,props:nt,_owner:n$4.current}}reactJsxRuntime_production_min.Fragment=l$3;reactJsxRuntime_production_min.jsx=q$5;reactJsxRuntime_production_min.jsxs=q$5;jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports,buffer$2={},base64Js={};base64Js.byteLength=byteLength;base64Js.toByteArray=toByteArray;base64Js.fromByteArray=fromByteArray;var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code$3="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i$1=0,len=code$3.length;i$10)throw new Error("Invalid string. Length must be a multiple of 4");var tt=et.indexOf("=");tt===-1&&(tt=o);var rt=tt===o?0:4-tt%4;return[tt,rt]}function byteLength(et){var o=getLens(et),tt=o[0],rt=o[1];return(tt+rt)*3/4-rt}function _byteLength(et,o,tt){return(o+tt)*3/4-tt}function toByteArray(et){var o,tt=getLens(et),rt=tt[0],nt=tt[1],ot=new Arr(_byteLength(et,rt,nt)),it=0,st=nt>0?rt-4:rt,at;for(at=0;at>16&255,ot[it++]=o>>8&255,ot[it++]=o&255;return nt===2&&(o=revLookup[et.charCodeAt(at)]<<2|revLookup[et.charCodeAt(at+1)]>>4,ot[it++]=o&255),nt===1&&(o=revLookup[et.charCodeAt(at)]<<10|revLookup[et.charCodeAt(at+1)]<<4|revLookup[et.charCodeAt(at+2)]>>2,ot[it++]=o>>8&255,ot[it++]=o&255),ot}function tripletToBase64(et){return lookup[et>>18&63]+lookup[et>>12&63]+lookup[et>>6&63]+lookup[et&63]}function encodeChunk(et,o,tt){for(var rt,nt=[],ot=o;otst?st:it+ot));return rt===1?(o=et[tt-1],nt.push(lookup[o>>2]+lookup[o<<4&63]+"==")):rt===2&&(o=(et[tt-2]<<8)+et[tt-1],nt.push(lookup[o>>10]+lookup[o>>4&63]+lookup[o<<2&63]+"=")),nt.join("")}var ieee754={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ieee754.read=function(et,o,tt,rt,nt){var ot,it,st=nt*8-rt-1,at=(1<>1,lt=-7,dt=tt?nt-1:0,ht=tt?-1:1,mt=et[o+dt];for(dt+=ht,ot=mt&(1<<-lt)-1,mt>>=-lt,lt+=st;lt>0;ot=ot*256+et[o+dt],dt+=ht,lt-=8);for(it=ot&(1<<-lt)-1,ot>>=-lt,lt+=rt;lt>0;it=it*256+et[o+dt],dt+=ht,lt-=8);if(ot===0)ot=1-ct;else{if(ot===at)return it?NaN:(mt?-1:1)*(1/0);it=it+Math.pow(2,rt),ot=ot-ct}return(mt?-1:1)*it*Math.pow(2,ot-rt)};ieee754.write=function(et,o,tt,rt,nt,ot){var it,st,at,ct=ot*8-nt-1,lt=(1<>1,ht=nt===23?Math.pow(2,-24)-Math.pow(2,-77):0,mt=rt?0:ot-1,ft=rt?1:-1,pt=o<0||o===0&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(st=isNaN(o)?1:0,it=lt):(it=Math.floor(Math.log(o)/Math.LN2),o*(at=Math.pow(2,-it))<1&&(it--,at*=2),it+dt>=1?o+=ht/at:o+=ht*Math.pow(2,1-dt),o*at>=2&&(it++,at/=2),it+dt>=lt?(st=0,it=lt):it+dt>=1?(st=(o*at-1)*Math.pow(2,nt),it=it+dt):(st=o*Math.pow(2,dt-1)*Math.pow(2,nt),it=0));nt>=8;et[tt+mt]=st&255,mt+=ft,st/=256,nt-=8);for(it=it<0;et[tt+mt]=it&255,mt+=ft,it/=256,ct-=8);et[tt+mt-ft]|=pt*128};/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */(function(et){const o=base64Js,tt=ieee754,rt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;et.Buffer=st,et.SlowBuffer=bt,et.INSPECT_MAX_BYTES=50;const nt=2147483647;et.kMaxLength=nt,st.TYPED_ARRAY_SUPPORT=ot(),!st.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ot(){try{const Tt=new Uint8Array(1),$t={foo:function(){return 42}};return Object.setPrototypeOf($t,Uint8Array.prototype),Object.setPrototypeOf(Tt,$t),Tt.foo()===42}catch{return!1}}Object.defineProperty(st.prototype,"parent",{enumerable:!0,get:function(){if(st.isBuffer(this))return this.buffer}}),Object.defineProperty(st.prototype,"offset",{enumerable:!0,get:function(){if(st.isBuffer(this))return this.byteOffset}});function it(Tt){if(Tt>nt)throw new RangeError('The value "'+Tt+'" is invalid for option "size"');const $t=new Uint8Array(Tt);return Object.setPrototypeOf($t,st.prototype),$t}function st(Tt,$t,Rt){if(typeof Tt=="number"){if(typeof $t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return dt(Tt)}return at(Tt,$t,Rt)}st.poolSize=8192;function at(Tt,$t,Rt){if(typeof Tt=="string")return ht(Tt,$t);if(ArrayBuffer.isView(Tt))return ft(Tt);if(Tt==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Tt);if(_r(Tt,ArrayBuffer)||Tt&&_r(Tt.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(_r(Tt,SharedArrayBuffer)||Tt&&_r(Tt.buffer,SharedArrayBuffer)))return pt(Tt,$t,Rt);if(typeof Tt=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Dt=Tt.valueOf&&Tt.valueOf();if(Dt!=null&&Dt!==Tt)return st.from(Dt,$t,Rt);const Kt=yt(Tt);if(Kt)return Kt;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof Tt[Symbol.toPrimitive]=="function")return st.from(Tt[Symbol.toPrimitive]("string"),$t,Rt);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Tt)}st.from=function(Tt,$t,Rt){return at(Tt,$t,Rt)},Object.setPrototypeOf(st.prototype,Uint8Array.prototype),Object.setPrototypeOf(st,Uint8Array);function ct(Tt){if(typeof Tt!="number")throw new TypeError('"size" argument must be of type number');if(Tt<0)throw new RangeError('The value "'+Tt+'" is invalid for option "size"')}function lt(Tt,$t,Rt){return ct(Tt),Tt<=0?it(Tt):$t!==void 0?typeof Rt=="string"?it(Tt).fill($t,Rt):it(Tt).fill($t):it(Tt)}st.alloc=function(Tt,$t,Rt){return lt(Tt,$t,Rt)};function dt(Tt){return ct(Tt),it(Tt<0?0:gt(Tt)|0)}st.allocUnsafe=function(Tt){return dt(Tt)},st.allocUnsafeSlow=function(Tt){return dt(Tt)};function ht(Tt,$t){if((typeof $t!="string"||$t==="")&&($t="utf8"),!st.isEncoding($t))throw new TypeError("Unknown encoding: "+$t);const Rt=xt(Tt,$t)|0;let Dt=it(Rt);const Kt=Dt.write(Tt,$t);return Kt!==Rt&&(Dt=Dt.slice(0,Kt)),Dt}function mt(Tt){const $t=Tt.length<0?0:gt(Tt.length)|0,Rt=it($t);for(let Dt=0;Dt<$t;Dt+=1)Rt[Dt]=Tt[Dt]&255;return Rt}function ft(Tt){if(_r(Tt,Uint8Array)){const $t=new Uint8Array(Tt);return pt($t.buffer,$t.byteOffset,$t.byteLength)}return mt(Tt)}function pt(Tt,$t,Rt){if($t<0||Tt.byteLength<$t)throw new RangeError('"offset" is outside of buffer bounds');if(Tt.byteLength<$t+(Rt||0))throw new RangeError('"length" is outside of buffer bounds');let Dt;return $t===void 0&&Rt===void 0?Dt=new Uint8Array(Tt):Rt===void 0?Dt=new Uint8Array(Tt,$t):Dt=new Uint8Array(Tt,$t,Rt),Object.setPrototypeOf(Dt,st.prototype),Dt}function yt(Tt){if(st.isBuffer(Tt)){const $t=gt(Tt.length)|0,Rt=it($t);return Rt.length===0||Tt.copy(Rt,0,0,$t),Rt}if(Tt.length!==void 0)return typeof Tt.length!="number"||Tr(Tt.length)?it(0):mt(Tt);if(Tt.type==="Buffer"&&Array.isArray(Tt.data))return mt(Tt.data)}function gt(Tt){if(Tt>=nt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt.toString(16)+" bytes");return Tt|0}function bt(Tt){return+Tt!=Tt&&(Tt=0),st.alloc(+Tt)}st.isBuffer=function($t){return $t!=null&&$t._isBuffer===!0&&$t!==st.prototype},st.compare=function($t,Rt){if(_r($t,Uint8Array)&&($t=st.from($t,$t.offset,$t.byteLength)),_r(Rt,Uint8Array)&&(Rt=st.from(Rt,Rt.offset,Rt.byteLength)),!st.isBuffer($t)||!st.isBuffer(Rt))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if($t===Rt)return 0;let Dt=$t.length,Kt=Rt.length;for(let nr=0,sr=Math.min(Dt,Kt);nrKt.length?(st.isBuffer(sr)||(sr=st.from(sr)),sr.copy(Kt,nr)):Uint8Array.prototype.set.call(Kt,sr,nr);else if(st.isBuffer(sr))sr.copy(Kt,nr);else throw new TypeError('"list" argument must be an Array of Buffers');nr+=sr.length}return Kt};function xt(Tt,$t){if(st.isBuffer(Tt))return Tt.length;if(ArrayBuffer.isView(Tt)||_r(Tt,ArrayBuffer))return Tt.byteLength;if(typeof Tt!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof Tt);const Rt=Tt.length,Dt=arguments.length>2&&arguments[2]===!0;if(!Dt&&Rt===0)return 0;let Kt=!1;for(;;)switch($t){case"ascii":case"latin1":case"binary":return Rt;case"utf8":case"utf-8":return cr(Tt).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt*2;case"hex":return Rt>>>1;case"base64":return pr(Tt).length;default:if(Kt)return Dt?-1:cr(Tt).length;$t=(""+$t).toLowerCase(),Kt=!0}}st.byteLength=xt;function vt(Tt,$t,Rt){let Dt=!1;if(($t===void 0||$t<0)&&($t=0),$t>this.length||((Rt===void 0||Rt>this.length)&&(Rt=this.length),Rt<=0)||(Rt>>>=0,$t>>>=0,Rt<=$t))return"";for(Tt||(Tt="utf8");;)switch(Tt){case"hex":return qt(this,$t,Rt);case"utf8":case"utf-8":return zt(this,$t,Rt);case"ascii":return Wt(this,$t,Rt);case"latin1":case"binary":return Ft(this,$t,Rt);case"base64":return Mt(this,$t,Rt);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pt(this,$t,Rt);default:if(Dt)throw new TypeError("Unknown encoding: "+Tt);Tt=(Tt+"").toLowerCase(),Dt=!0}}st.prototype._isBuffer=!0;function Et(Tt,$t,Rt){const Dt=Tt[$t];Tt[$t]=Tt[Rt],Tt[Rt]=Dt}st.prototype.swap16=function(){const $t=this.length;if($t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let Rt=0;Rt<$t;Rt+=2)Et(this,Rt,Rt+1);return this},st.prototype.swap32=function(){const $t=this.length;if($t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let Rt=0;Rt<$t;Rt+=4)Et(this,Rt,Rt+3),Et(this,Rt+1,Rt+2);return this},st.prototype.swap64=function(){const $t=this.length;if($t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let Rt=0;Rt<$t;Rt+=8)Et(this,Rt,Rt+7),Et(this,Rt+1,Rt+6),Et(this,Rt+2,Rt+5),Et(this,Rt+3,Rt+4);return this},st.prototype.toString=function(){const $t=this.length;return $t===0?"":arguments.length===0?zt(this,0,$t):vt.apply(this,arguments)},st.prototype.toLocaleString=st.prototype.toString,st.prototype.equals=function($t){if(!st.isBuffer($t))throw new TypeError("Argument must be a Buffer");return this===$t?!0:st.compare(this,$t)===0},st.prototype.inspect=function(){let $t="";const Rt=et.INSPECT_MAX_BYTES;return $t=this.toString("hex",0,Rt).replace(/(.{2})/g,"$1 ").trim(),this.length>Rt&&($t+=" ... "),""},rt&&(st.prototype[rt]=st.prototype.inspect),st.prototype.compare=function($t,Rt,Dt,Kt,nr){if(_r($t,Uint8Array)&&($t=st.from($t,$t.offset,$t.byteLength)),!st.isBuffer($t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof $t);if(Rt===void 0&&(Rt=0),Dt===void 0&&(Dt=$t?$t.length:0),Kt===void 0&&(Kt=0),nr===void 0&&(nr=this.length),Rt<0||Dt>$t.length||Kt<0||nr>this.length)throw new RangeError("out of range index");if(Kt>=nr&&Rt>=Dt)return 0;if(Kt>=nr)return-1;if(Rt>=Dt)return 1;if(Rt>>>=0,Dt>>>=0,Kt>>>=0,nr>>>=0,this===$t)return 0;let sr=nr-Kt,br=Dt-Rt;const $r=Math.min(sr,br),yr=this.slice(Kt,nr),Ar=$t.slice(Rt,Dt);for(let xr=0;xr<$r;++xr)if(yr[xr]!==Ar[xr]){sr=yr[xr],br=Ar[xr];break}return sr2147483647?Rt=2147483647:Rt<-2147483648&&(Rt=-2147483648),Rt=+Rt,Tr(Rt)&&(Rt=Kt?0:Tt.length-1),Rt<0&&(Rt=Tt.length+Rt),Rt>=Tt.length){if(Kt)return-1;Rt=Tt.length-1}else if(Rt<0)if(Kt)Rt=0;else return-1;if(typeof $t=="string"&&($t=st.from($t,Dt)),st.isBuffer($t))return $t.length===0?-1:St(Tt,$t,Rt,Dt,Kt);if(typeof $t=="number")return $t=$t&255,typeof Uint8Array.prototype.indexOf=="function"?Kt?Uint8Array.prototype.indexOf.call(Tt,$t,Rt):Uint8Array.prototype.lastIndexOf.call(Tt,$t,Rt):St(Tt,[$t],Rt,Dt,Kt);throw new TypeError("val must be string, number or Buffer")}function St(Tt,$t,Rt,Dt,Kt){let nr=1,sr=Tt.length,br=$t.length;if(Dt!==void 0&&(Dt=String(Dt).toLowerCase(),Dt==="ucs2"||Dt==="ucs-2"||Dt==="utf16le"||Dt==="utf-16le")){if(Tt.length<2||$t.length<2)return-1;nr=2,sr/=2,br/=2,Rt/=2}function $r(Ar,xr){return nr===1?Ar[xr]:Ar.readUInt16BE(xr*nr)}let yr;if(Kt){let Ar=-1;for(yr=Rt;yrsr&&(Rt=sr-br),yr=Rt;yr>=0;yr--){let Ar=!0;for(let xr=0;xrKt&&(Dt=Kt)):Dt=Kt;const nr=$t.length;Dt>nr/2&&(Dt=nr/2);let sr;for(sr=0;sr>>0,isFinite(Dt)?(Dt=Dt>>>0,Kt===void 0&&(Kt="utf8")):(Kt=Dt,Dt=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const nr=this.length-Rt;if((Dt===void 0||Dt>nr)&&(Dt=nr),$t.length>0&&(Dt<0||Rt<0)||Rt>this.length)throw new RangeError("Attempt to write outside buffer bounds");Kt||(Kt="utf8");let sr=!1;for(;;)switch(Kt){case"hex":return At(this,$t,Rt,Dt);case"utf8":case"utf-8":return kt(this,$t,Rt,Dt);case"ascii":case"latin1":case"binary":return It(this,$t,Rt,Dt);case"base64":return Nt(this,$t,Rt,Dt);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Lt(this,$t,Rt,Dt);default:if(sr)throw new TypeError("Unknown encoding: "+Kt);Kt=(""+Kt).toLowerCase(),sr=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Mt(Tt,$t,Rt){return $t===0&&Rt===Tt.length?o.fromByteArray(Tt):o.fromByteArray(Tt.slice($t,Rt))}function zt(Tt,$t,Rt){Rt=Math.min(Tt.length,Rt);const Dt=[];let Kt=$t;for(;Kt239?4:nr>223?3:nr>191?2:1;if(Kt+br<=Rt){let $r,yr,Ar,xr;switch(br){case 1:nr<128&&(sr=nr);break;case 2:$r=Tt[Kt+1],($r&192)===128&&(xr=(nr&31)<<6|$r&63,xr>127&&(sr=xr));break;case 3:$r=Tt[Kt+1],yr=Tt[Kt+2],($r&192)===128&&(yr&192)===128&&(xr=(nr&15)<<12|($r&63)<<6|yr&63,xr>2047&&(xr<55296||xr>57343)&&(sr=xr));break;case 4:$r=Tt[Kt+1],yr=Tt[Kt+2],Ar=Tt[Kt+3],($r&192)===128&&(yr&192)===128&&(Ar&192)===128&&(xr=(nr&15)<<18|($r&63)<<12|(yr&63)<<6|Ar&63,xr>65535&&xr<1114112&&(sr=xr))}}sr===null?(sr=65533,br=1):sr>65535&&(sr-=65536,Dt.push(sr>>>10&1023|55296),sr=56320|sr&1023),Dt.push(sr),Kt+=br}return Xt(Dt)}const Ut=4096;function Xt(Tt){const $t=Tt.length;if($t<=Ut)return String.fromCharCode.apply(String,Tt);let Rt="",Dt=0;for(;Dt<$t;)Rt+=String.fromCharCode.apply(String,Tt.slice(Dt,Dt+=Ut));return Rt}function Wt(Tt,$t,Rt){let Dt="";Rt=Math.min(Tt.length,Rt);for(let Kt=$t;KtDt)&&(Rt=Dt);let Kt="";for(let nr=$t;nrDt&&($t=Dt),Rt<0?(Rt+=Dt,Rt<0&&(Rt=0)):Rt>Dt&&(Rt=Dt),Rt<$t&&(Rt=$t);const Kt=this.subarray($t,Rt);return Object.setPrototypeOf(Kt,st.prototype),Kt};function Yt(Tt,$t,Rt){if(Tt%1!==0||Tt<0)throw new RangeError("offset is not uint");if(Tt+$t>Rt)throw new RangeError("Trying to access beyond buffer length")}st.prototype.readUintLE=st.prototype.readUIntLE=function($t,Rt,Dt){$t=$t>>>0,Rt=Rt>>>0,Dt||Yt($t,Rt,this.length);let Kt=this[$t],nr=1,sr=0;for(;++sr>>0,Rt=Rt>>>0,Dt||Yt($t,Rt,this.length);let Kt=this[$t+--Rt],nr=1;for(;Rt>0&&(nr*=256);)Kt+=this[$t+--Rt]*nr;return Kt},st.prototype.readUint8=st.prototype.readUInt8=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,1,this.length),this[$t]},st.prototype.readUint16LE=st.prototype.readUInt16LE=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,2,this.length),this[$t]|this[$t+1]<<8},st.prototype.readUint16BE=st.prototype.readUInt16BE=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,2,this.length),this[$t]<<8|this[$t+1]},st.prototype.readUint32LE=st.prototype.readUInt32LE=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,4,this.length),(this[$t]|this[$t+1]<<8|this[$t+2]<<16)+this[$t+3]*16777216},st.prototype.readUint32BE=st.prototype.readUInt32BE=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,4,this.length),this[$t]*16777216+(this[$t+1]<<16|this[$t+2]<<8|this[$t+3])},st.prototype.readBigUInt64LE=vr(function($t){$t=$t>>>0,Vt($t,"offset");const Rt=this[$t],Dt=this[$t+7];(Rt===void 0||Dt===void 0)&&er($t,this.length-8);const Kt=Rt+this[++$t]*2**8+this[++$t]*2**16+this[++$t]*2**24,nr=this[++$t]+this[++$t]*2**8+this[++$t]*2**16+Dt*2**24;return BigInt(Kt)+(BigInt(nr)<>>0,Vt($t,"offset");const Rt=this[$t],Dt=this[$t+7];(Rt===void 0||Dt===void 0)&&er($t,this.length-8);const Kt=Rt*2**24+this[++$t]*2**16+this[++$t]*2**8+this[++$t],nr=this[++$t]*2**24+this[++$t]*2**16+this[++$t]*2**8+Dt;return(BigInt(Kt)<>>0,Rt=Rt>>>0,Dt||Yt($t,Rt,this.length);let Kt=this[$t],nr=1,sr=0;for(;++sr=nr&&(Kt-=Math.pow(2,8*Rt)),Kt},st.prototype.readIntBE=function($t,Rt,Dt){$t=$t>>>0,Rt=Rt>>>0,Dt||Yt($t,Rt,this.length);let Kt=Rt,nr=1,sr=this[$t+--Kt];for(;Kt>0&&(nr*=256);)sr+=this[$t+--Kt]*nr;return nr*=128,sr>=nr&&(sr-=Math.pow(2,8*Rt)),sr},st.prototype.readInt8=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,1,this.length),this[$t]&128?(255-this[$t]+1)*-1:this[$t]},st.prototype.readInt16LE=function($t,Rt){$t=$t>>>0,Rt||Yt($t,2,this.length);const Dt=this[$t]|this[$t+1]<<8;return Dt&32768?Dt|4294901760:Dt},st.prototype.readInt16BE=function($t,Rt){$t=$t>>>0,Rt||Yt($t,2,this.length);const Dt=this[$t+1]|this[$t]<<8;return Dt&32768?Dt|4294901760:Dt},st.prototype.readInt32LE=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,4,this.length),this[$t]|this[$t+1]<<8|this[$t+2]<<16|this[$t+3]<<24},st.prototype.readInt32BE=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,4,this.length),this[$t]<<24|this[$t+1]<<16|this[$t+2]<<8|this[$t+3]},st.prototype.readBigInt64LE=vr(function($t){$t=$t>>>0,Vt($t,"offset");const Rt=this[$t],Dt=this[$t+7];(Rt===void 0||Dt===void 0)&&er($t,this.length-8);const Kt=this[$t+4]+this[$t+5]*2**8+this[$t+6]*2**16+(Dt<<24);return(BigInt(Kt)<>>0,Vt($t,"offset");const Rt=this[$t],Dt=this[$t+7];(Rt===void 0||Dt===void 0)&&er($t,this.length-8);const Kt=(Rt<<24)+this[++$t]*2**16+this[++$t]*2**8+this[++$t];return(BigInt(Kt)<>>0,Rt||Yt($t,4,this.length),tt.read(this,$t,!0,23,4)},st.prototype.readFloatBE=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,4,this.length),tt.read(this,$t,!1,23,4)},st.prototype.readDoubleLE=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,8,this.length),tt.read(this,$t,!0,52,8)},st.prototype.readDoubleBE=function($t,Rt){return $t=$t>>>0,Rt||Yt($t,8,this.length),tt.read(this,$t,!1,52,8)};function Qt(Tt,$t,Rt,Dt,Kt,nr){if(!st.isBuffer(Tt))throw new TypeError('"buffer" argument must be a Buffer instance');if($t>Kt||$tTt.length)throw new RangeError("Index out of range")}st.prototype.writeUintLE=st.prototype.writeUIntLE=function($t,Rt,Dt,Kt){if($t=+$t,Rt=Rt>>>0,Dt=Dt>>>0,!Kt){const br=Math.pow(2,8*Dt)-1;Qt(this,$t,Rt,Dt,br,0)}let nr=1,sr=0;for(this[Rt]=$t&255;++sr>>0,Dt=Dt>>>0,!Kt){const br=Math.pow(2,8*Dt)-1;Qt(this,$t,Rt,Dt,br,0)}let nr=Dt-1,sr=1;for(this[Rt+nr]=$t&255;--nr>=0&&(sr*=256);)this[Rt+nr]=$t/sr&255;return Rt+Dt},st.prototype.writeUint8=st.prototype.writeUInt8=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,1,255,0),this[Rt]=$t&255,Rt+1},st.prototype.writeUint16LE=st.prototype.writeUInt16LE=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,2,65535,0),this[Rt]=$t&255,this[Rt+1]=$t>>>8,Rt+2},st.prototype.writeUint16BE=st.prototype.writeUInt16BE=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,2,65535,0),this[Rt]=$t>>>8,this[Rt+1]=$t&255,Rt+2},st.prototype.writeUint32LE=st.prototype.writeUInt32LE=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,4,4294967295,0),this[Rt+3]=$t>>>24,this[Rt+2]=$t>>>16,this[Rt+1]=$t>>>8,this[Rt]=$t&255,Rt+4},st.prototype.writeUint32BE=st.prototype.writeUInt32BE=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,4,4294967295,0),this[Rt]=$t>>>24,this[Rt+1]=$t>>>16,this[Rt+2]=$t>>>8,this[Rt+3]=$t&255,Rt+4};function jt(Tt,$t,Rt,Dt,Kt){Bt($t,Dt,Kt,Tt,Rt,7);let nr=Number($t&BigInt(4294967295));Tt[Rt++]=nr,nr=nr>>8,Tt[Rt++]=nr,nr=nr>>8,Tt[Rt++]=nr,nr=nr>>8,Tt[Rt++]=nr;let sr=Number($t>>BigInt(32)&BigInt(4294967295));return Tt[Rt++]=sr,sr=sr>>8,Tt[Rt++]=sr,sr=sr>>8,Tt[Rt++]=sr,sr=sr>>8,Tt[Rt++]=sr,Rt}function Gt(Tt,$t,Rt,Dt,Kt){Bt($t,Dt,Kt,Tt,Rt,7);let nr=Number($t&BigInt(4294967295));Tt[Rt+7]=nr,nr=nr>>8,Tt[Rt+6]=nr,nr=nr>>8,Tt[Rt+5]=nr,nr=nr>>8,Tt[Rt+4]=nr;let sr=Number($t>>BigInt(32)&BigInt(4294967295));return Tt[Rt+3]=sr,sr=sr>>8,Tt[Rt+2]=sr,sr=sr>>8,Tt[Rt+1]=sr,sr=sr>>8,Tt[Rt]=sr,Rt+8}st.prototype.writeBigUInt64LE=vr(function($t,Rt=0){return jt(this,$t,Rt,BigInt(0),BigInt("0xffffffffffffffff"))}),st.prototype.writeBigUInt64BE=vr(function($t,Rt=0){return Gt(this,$t,Rt,BigInt(0),BigInt("0xffffffffffffffff"))}),st.prototype.writeIntLE=function($t,Rt,Dt,Kt){if($t=+$t,Rt=Rt>>>0,!Kt){const $r=Math.pow(2,8*Dt-1);Qt(this,$t,Rt,Dt,$r-1,-$r)}let nr=0,sr=1,br=0;for(this[Rt]=$t&255;++nr>0)-br&255;return Rt+Dt},st.prototype.writeIntBE=function($t,Rt,Dt,Kt){if($t=+$t,Rt=Rt>>>0,!Kt){const $r=Math.pow(2,8*Dt-1);Qt(this,$t,Rt,Dt,$r-1,-$r)}let nr=Dt-1,sr=1,br=0;for(this[Rt+nr]=$t&255;--nr>=0&&(sr*=256);)$t<0&&br===0&&this[Rt+nr+1]!==0&&(br=1),this[Rt+nr]=($t/sr>>0)-br&255;return Rt+Dt},st.prototype.writeInt8=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,1,127,-128),$t<0&&($t=255+$t+1),this[Rt]=$t&255,Rt+1},st.prototype.writeInt16LE=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,2,32767,-32768),this[Rt]=$t&255,this[Rt+1]=$t>>>8,Rt+2},st.prototype.writeInt16BE=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,2,32767,-32768),this[Rt]=$t>>>8,this[Rt+1]=$t&255,Rt+2},st.prototype.writeInt32LE=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,4,2147483647,-2147483648),this[Rt]=$t&255,this[Rt+1]=$t>>>8,this[Rt+2]=$t>>>16,this[Rt+3]=$t>>>24,Rt+4},st.prototype.writeInt32BE=function($t,Rt,Dt){return $t=+$t,Rt=Rt>>>0,Dt||Qt(this,$t,Rt,4,2147483647,-2147483648),$t<0&&($t=4294967295+$t+1),this[Rt]=$t>>>24,this[Rt+1]=$t>>>16,this[Rt+2]=$t>>>8,this[Rt+3]=$t&255,Rt+4},st.prototype.writeBigInt64LE=vr(function($t,Rt=0){return jt(this,$t,Rt,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),st.prototype.writeBigInt64BE=vr(function($t,Rt=0){return Gt(this,$t,Rt,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function rr(Tt,$t,Rt,Dt,Kt,nr){if(Rt+Dt>Tt.length)throw new RangeError("Index out of range");if(Rt<0)throw new RangeError("Index out of range")}function Ht(Tt,$t,Rt,Dt,Kt){return $t=+$t,Rt=Rt>>>0,Kt||rr(Tt,$t,Rt,4),tt.write(Tt,$t,Rt,Dt,23,4),Rt+4}st.prototype.writeFloatLE=function($t,Rt,Dt){return Ht(this,$t,Rt,!0,Dt)},st.prototype.writeFloatBE=function($t,Rt,Dt){return Ht(this,$t,Rt,!1,Dt)};function dr(Tt,$t,Rt,Dt,Kt){return $t=+$t,Rt=Rt>>>0,Kt||rr(Tt,$t,Rt,8),tt.write(Tt,$t,Rt,Dt,52,8),Rt+8}st.prototype.writeDoubleLE=function($t,Rt,Dt){return dr(this,$t,Rt,!0,Dt)},st.prototype.writeDoubleBE=function($t,Rt,Dt){return dr(this,$t,Rt,!1,Dt)},st.prototype.copy=function($t,Rt,Dt,Kt){if(!st.isBuffer($t))throw new TypeError("argument should be a Buffer");if(Dt||(Dt=0),!Kt&&Kt!==0&&(Kt=this.length),Rt>=$t.length&&(Rt=$t.length),Rt||(Rt=0),Kt>0&&Kt=this.length)throw new RangeError("Index out of range");if(Kt<0)throw new RangeError("sourceEnd out of bounds");Kt>this.length&&(Kt=this.length),$t.length-Rt>>0,Dt=Dt===void 0?this.length:Dt>>>0,$t||($t=0);let nr;if(typeof $t=="number")for(nr=Rt;nr2**32?Kt=tr(String(Rt)):typeof Rt=="bigint"&&(Kt=String(Rt),(Rt>BigInt(2)**BigInt(32)||Rt<-(BigInt(2)**BigInt(32)))&&(Kt=tr(Kt)),Kt+="n"),Dt+=` It must be ${$t}. Received ${Kt}`,Dt},RangeError);function tr(Tt){let $t="",Rt=Tt.length;const Dt=Tt[0]==="-"?1:0;for(;Rt>=Dt+4;Rt-=3)$t=`_${Tt.slice(Rt-3,Rt)}${$t}`;return`${Tt.slice(0,Rt)}${$t}`}function _t(Tt,$t,Rt){Vt($t,"offset"),(Tt[$t]===void 0||Tt[$t+Rt]===void 0)&&er($t,Tt.length-(Rt+1))}function Bt(Tt,$t,Rt,Dt,Kt,nr){if(Tt>Rt||Tt<$t){const sr=typeof $t=="bigint"?"n":"";let br;throw $t===0||$t===BigInt(0)?br=`>= 0${sr} and < 2${sr} ** ${(nr+1)*8}${sr}`:br=`>= -(2${sr} ** ${(nr+1)*8-1}${sr}) and < 2 ** ${(nr+1)*8-1}${sr}`,new Zt.ERR_OUT_OF_RANGE("value",br,Tt)}_t(Dt,Kt,nr)}function Vt(Tt,$t){if(typeof Tt!="number")throw new Zt.ERR_INVALID_ARG_TYPE($t,"number",Tt)}function er(Tt,$t,Rt){throw Math.floor(Tt)!==Tt?(Vt(Tt,Rt),new Zt.ERR_OUT_OF_RANGE("offset","an integer",Tt)):$t<0?new Zt.ERR_BUFFER_OUT_OF_BOUNDS:new Zt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${$t}`,Tt)}const ar=/[^+/0-9A-Za-z-_]/g;function ur(Tt){if(Tt=Tt.split("=")[0],Tt=Tt.trim().replace(ar,""),Tt.length<2)return"";for(;Tt.length%4!==0;)Tt=Tt+"=";return Tt}function cr(Tt,$t){$t=$t||1/0;let Rt;const Dt=Tt.length;let Kt=null;const nr=[];for(let sr=0;sr55295&&Rt<57344){if(!Kt){if(Rt>56319){($t-=3)>-1&&nr.push(239,191,189);continue}else if(sr+1===Dt){($t-=3)>-1&&nr.push(239,191,189);continue}Kt=Rt;continue}if(Rt<56320){($t-=3)>-1&&nr.push(239,191,189),Kt=Rt;continue}Rt=(Kt-55296<<10|Rt-56320)+65536}else Kt&&($t-=3)>-1&&nr.push(239,191,189);if(Kt=null,Rt<128){if(($t-=1)<0)break;nr.push(Rt)}else if(Rt<2048){if(($t-=2)<0)break;nr.push(Rt>>6|192,Rt&63|128)}else if(Rt<65536){if(($t-=3)<0)break;nr.push(Rt>>12|224,Rt>>6&63|128,Rt&63|128)}else if(Rt<1114112){if(($t-=4)<0)break;nr.push(Rt>>18|240,Rt>>12&63|128,Rt>>6&63|128,Rt&63|128)}else throw new Error("Invalid code point")}return nr}function hr(Tt){const $t=[];for(let Rt=0;Rt>8,Kt=Rt%256,nr.push(Kt),nr.push(Dt);return nr}function pr(Tt){return o.toByteArray(ur(Tt))}function wr(Tt,$t,Rt,Dt){let Kt;for(Kt=0;Kt=$t.length||Kt>=Tt.length);++Kt)$t[Kt+Rt]=Tt[Kt];return Kt}function _r(Tt,$t){return Tt instanceof $t||Tt!=null&&Tt.constructor!=null&&Tt.constructor.name!=null&&Tt.constructor.name===$t.name}function Tr(Tt){return Tt!==Tt}const gr=function(){const Tt="0123456789abcdef",$t=new Array(256);for(let Rt=0;Rt<16;++Rt){const Dt=Rt*16;for(let Kt=0;Kt<16;++Kt)$t[Dt+Kt]=Tt[Rt]+Tt[Kt]}return $t}();function vr(Tt){return typeof BigInt>"u"?ir:Tt}function ir(){throw new Error("BigInt not supported")}})(buffer$2);var reactDom={exports:{}},reactDom_production_min={},scheduler={exports:{}},scheduler_production_min={};/** * @license React * scheduler.production.min.js * @@ -23,7 +28,7 @@ var lu=Object.defineProperty;var Fs=et=>{throw TypeError(et)};var uu=(et,o,tt)=> * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(et){function o(Bt,Wt){var jt=Bt.length;Bt.push(Wt);e:for(;0>>1,Kt=Bt[Xt];if(0>>1;Xtnt(tr,jt))ztnt(lr,tr)?(Bt[Xt]=lr,Bt[zt]=jt,Xt=zt):(Bt[Xt]=tr,Bt[Gt]=jt,Xt=Gt);else if(ztnt(lr,jt))Bt[Xt]=lr,Bt[zt]=jt,Xt=zt;else break e}}return Wt}function nt(Bt,Wt){var jt=Bt.sortIndex-Wt.sortIndex;return jt!==0?jt:Bt.id-Wt.id}if(typeof performance=="object"&&typeof performance.now=="function"){var ot=performance;et.unstable_now=function(){return ot.now()}}else{var it=Date,st=it.now();et.unstable_now=function(){return it.now()-st}}var at=[],ct=[],lt=1,dt=null,ht=3,mt=!1,ft=!1,pt=!1,gt=typeof setTimeout=="function"?setTimeout:null,yt=typeof clearTimeout=="function"?clearTimeout:null,bt=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function xt(Bt){for(var Wt=tt(ct);Wt!==null;){if(Wt.callback===null)rt(ct);else if(Wt.startTime<=Bt)rt(ct),Wt.sortIndex=Wt.expirationTime,o(at,Wt);else break;Wt=tt(ct)}}function vt(Bt){if(pt=!1,xt(Bt),!ft)if(tt(at)!==null)ft=!0,Qt(Et);else{var Wt=tt(ct);Wt!==null&&Vt(vt,Wt.startTime-Bt)}}function Et(Bt,Wt){ft=!1,pt&&(pt=!1,yt(At),At=-1),mt=!0;var jt=ht;try{for(xt(Wt),dt=tt(at);dt!==null&&(!(dt.expirationTime>Wt)||Bt&&!Ot());){var Xt=dt.callback;if(typeof Xt=="function"){dt.callback=null,ht=dt.priorityLevel;var Kt=Xt(dt.expirationTime<=Wt);Wt=et.unstable_now(),typeof Kt=="function"?dt.callback=Kt:dt===tt(at)&&rt(at),xt(Wt)}else rt(at);dt=tt(at)}if(dt!==null)var Pt=!0;else{var Gt=tt(ct);Gt!==null&&Vt(vt,Gt.startTime-Wt),Pt=!1}return Pt}finally{dt=null,ht=jt,mt=!1}}var Ct=!1,St=null,At=-1,kt=5,It=-1;function Ot(){return!(et.unstable_now()-ItBt||125Xt?(Bt.sortIndex=jt,o(ct,Bt),tt(at)===null&&Bt===tt(ct)&&(pt?(yt(At),At=-1):pt=!0,Vt(vt,jt-Xt))):(Bt.sortIndex=Kt,o(at,Bt),ft||mt||(ft=!0,Qt(Et))),Bt},et.unstable_shouldYield=Ot,et.unstable_wrapCallback=function(Bt){var Wt=ht;return function(){var jt=ht;ht=Wt;try{return Bt.apply(this,arguments)}finally{ht=jt}}}})(scheduler_production_min);scheduler.exports=scheduler_production_min;var schedulerExports=scheduler.exports;/** + */(function(et){function o(Ft,qt){var Pt=Ft.length;Ft.push(qt);e:for(;0>>1,Qt=Ft[Yt];if(0>>1;Ytnt(rr,Pt))Htnt(dr,rr)?(Ft[Yt]=dr,Ft[Ht]=Pt,Yt=Ht):(Ft[Yt]=rr,Ft[Gt]=Pt,Yt=Gt);else if(Htnt(dr,Pt))Ft[Yt]=dr,Ft[Ht]=Pt,Yt=Ht;else break e}}return qt}function nt(Ft,qt){var Pt=Ft.sortIndex-qt.sortIndex;return Pt!==0?Pt:Ft.id-qt.id}if(typeof performance=="object"&&typeof performance.now=="function"){var ot=performance;et.unstable_now=function(){return ot.now()}}else{var it=Date,st=it.now();et.unstable_now=function(){return it.now()-st}}var at=[],ct=[],lt=1,dt=null,ht=3,mt=!1,ft=!1,pt=!1,yt=typeof setTimeout=="function"?setTimeout:null,gt=typeof clearTimeout=="function"?clearTimeout:null,bt=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function xt(Ft){for(var qt=tt(ct);qt!==null;){if(qt.callback===null)rt(ct);else if(qt.startTime<=Ft)rt(ct),qt.sortIndex=qt.expirationTime,o(at,qt);else break;qt=tt(ct)}}function vt(Ft){if(pt=!1,xt(Ft),!ft)if(tt(at)!==null)ft=!0,Xt(Et);else{var qt=tt(ct);qt!==null&&Wt(vt,qt.startTime-Ft)}}function Et(Ft,qt){ft=!1,pt&&(pt=!1,gt(At),At=-1),mt=!0;var Pt=ht;try{for(xt(qt),dt=tt(at);dt!==null&&(!(dt.expirationTime>qt)||Ft&&!Nt());){var Yt=dt.callback;if(typeof Yt=="function"){dt.callback=null,ht=dt.priorityLevel;var Qt=Yt(dt.expirationTime<=qt);qt=et.unstable_now(),typeof Qt=="function"?dt.callback=Qt:dt===tt(at)&&rt(at),xt(qt)}else rt(at);dt=tt(at)}if(dt!==null)var jt=!0;else{var Gt=tt(ct);Gt!==null&&Wt(vt,Gt.startTime-qt),jt=!1}return jt}finally{dt=null,ht=Pt,mt=!1}}var Ct=!1,St=null,At=-1,kt=5,It=-1;function Nt(){return!(et.unstable_now()-ItFt||125Yt?(Ft.sortIndex=Pt,o(ct,Ft),tt(at)===null&&Ft===tt(ct)&&(pt?(gt(At),At=-1):pt=!0,Wt(vt,Pt-Yt))):(Ft.sortIndex=Qt,o(at,Ft),ft||mt||(ft=!0,Xt(Et))),Ft},et.unstable_shouldYield=Nt,et.unstable_wrapCallback=function(Ft){var qt=ht;return function(){var Pt=ht;ht=qt;try{return Ft.apply(this,arguments)}finally{ht=Pt}}}})(scheduler_production_min);scheduler.exports=scheduler_production_min;var schedulerExports=scheduler.exports;/** * @license React * react-dom.production.min.js * @@ -31,14 +36,14 @@ var lu=Object.defineProperty;var Fs=et=>{throw TypeError(et)};var uu=(et,o,tt)=> * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var aa=reactExports,ca$1=schedulerExports;function p$4(et){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+et,tt=1;tt"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ja=Object.prototype.hasOwnProperty,ka=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,la={},ma={};function oa(et){return ja.call(ma,et)?!0:ja.call(la,et)?!1:ka.test(et)?ma[et]=!0:(la[et]=!0,!1)}function pa(et,o,tt,rt){if(tt!==null&&tt.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return rt?!1:tt!==null?!tt.acceptsBooleans:(et=et.toLowerCase().slice(0,5),et!=="data-"&&et!=="aria-");default:return!1}}function qa(et,o,tt,rt){if(o===null||typeof o>"u"||pa(et,o,tt,rt))return!0;if(rt)return!1;if(tt!==null)switch(tt.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function v$4(et,o,tt,rt,nt,ot,it){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=rt,this.attributeNamespace=nt,this.mustUseProperty=tt,this.propertyName=et,this.type=o,this.sanitizeURL=ot,this.removeEmptyString=it}var z$3={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(et){z$3[et]=new v$4(et,0,!1,et,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(et){var o=et[0];z$3[o]=new v$4(o,1,!1,et[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(et){z$3[et]=new v$4(et,2,!1,et.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(et){z$3[et]=new v$4(et,2,!1,et,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(et){z$3[et]=new v$4(et,3,!1,et.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(et){z$3[et]=new v$4(et,3,!0,et,null,!1,!1)});["capture","download"].forEach(function(et){z$3[et]=new v$4(et,4,!1,et,null,!1,!1)});["cols","rows","size","span"].forEach(function(et){z$3[et]=new v$4(et,6,!1,et,null,!1,!1)});["rowSpan","start"].forEach(function(et){z$3[et]=new v$4(et,5,!1,et.toLowerCase(),null,!1,!1)});var ra$1=/[\-:]([a-z])/g;function sa(et){return et[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(et){var o=et.replace(ra$1,sa);z$3[o]=new v$4(o,1,!1,et,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(et){var o=et.replace(ra$1,sa);z$3[o]=new v$4(o,1,!1,et,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(et){var o=et.replace(ra$1,sa);z$3[o]=new v$4(o,1,!1,et,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(et){z$3[et]=new v$4(et,1,!1,et.toLowerCase(),null,!1,!1)});z$3.xlinkHref=new v$4("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(et){z$3[et]=new v$4(et,1,!1,et.toLowerCase(),null,!0,!0)});function ta(et,o,tt,rt){var nt=z$3.hasOwnProperty(o)?z$3[o]:null;(nt!==null?nt.type!==0:rt||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ja=Object.prototype.hasOwnProperty,ka=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,la={},ma={};function oa(et){return ja.call(ma,et)?!0:ja.call(la,et)?!1:ka.test(et)?ma[et]=!0:(la[et]=!0,!1)}function pa(et,o,tt,rt){if(tt!==null&&tt.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return rt?!1:tt!==null?!tt.acceptsBooleans:(et=et.toLowerCase().slice(0,5),et!=="data-"&&et!=="aria-");default:return!1}}function qa(et,o,tt,rt){if(o===null||typeof o>"u"||pa(et,o,tt,rt))return!0;if(rt)return!1;if(tt!==null)switch(tt.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function v$4(et,o,tt,rt,nt,ot,it){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=rt,this.attributeNamespace=nt,this.mustUseProperty=tt,this.propertyName=et,this.type=o,this.sanitizeURL=ot,this.removeEmptyString=it}var z$2={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(et){z$2[et]=new v$4(et,0,!1,et,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(et){var o=et[0];z$2[o]=new v$4(o,1,!1,et[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(et){z$2[et]=new v$4(et,2,!1,et.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(et){z$2[et]=new v$4(et,2,!1,et,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(et){z$2[et]=new v$4(et,3,!1,et.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(et){z$2[et]=new v$4(et,3,!0,et,null,!1,!1)});["capture","download"].forEach(function(et){z$2[et]=new v$4(et,4,!1,et,null,!1,!1)});["cols","rows","size","span"].forEach(function(et){z$2[et]=new v$4(et,6,!1,et,null,!1,!1)});["rowSpan","start"].forEach(function(et){z$2[et]=new v$4(et,5,!1,et.toLowerCase(),null,!1,!1)});var ra$1=/[\-:]([a-z])/g;function sa(et){return et[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(et){var o=et.replace(ra$1,sa);z$2[o]=new v$4(o,1,!1,et,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(et){var o=et.replace(ra$1,sa);z$2[o]=new v$4(o,1,!1,et,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(et){var o=et.replace(ra$1,sa);z$2[o]=new v$4(o,1,!1,et,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(et){z$2[et]=new v$4(et,1,!1,et.toLowerCase(),null,!1,!1)});z$2.xlinkHref=new v$4("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(et){z$2[et]=new v$4(et,1,!1,et.toLowerCase(),null,!0,!0)});function ta(et,o,tt,rt){var nt=z$2.hasOwnProperty(o)?z$2[o]:null;(nt!==null?nt.type!==0:rt||!(2st||nt[it]!==ot[st]){var at=` -`+nt[it].replace(" at new "," at ");return et.displayName&&at.includes("")&&(at=at.replace("",et.displayName)),at}while(1<=it&&0<=st);break}}}finally{Na=!1,Error.prepareStackTrace=tt}return(et=et?et.displayName||et.name:"")?Ma(et):""}function Pa(et){switch(et.tag){case 5:return Ma(et.type);case 16:return Ma("Lazy");case 13:return Ma("Suspense");case 19:return Ma("SuspenseList");case 0:case 2:case 15:return et=Oa(et.type,!1),et;case 11:return et=Oa(et.type.render,!1),et;case 1:return et=Oa(et.type,!0),et;default:return""}}function Qa(et){if(et==null)return null;if(typeof et=="function")return et.displayName||et.name||null;if(typeof et=="string")return et;switch(et){case ya:return"Fragment";case wa:return"Portal";case Aa:return"Profiler";case za:return"StrictMode";case Ea:return"Suspense";case Fa:return"SuspenseList"}if(typeof et=="object")switch(et.$$typeof){case Ca:return(et.displayName||"Context")+".Consumer";case Ba:return(et._context.displayName||"Context")+".Provider";case Da:var o=et.render;return et=et.displayName,et||(et=o.displayName||o.name||"",et=et!==""?"ForwardRef("+et+")":"ForwardRef"),et;case Ga:return o=et.displayName||null,o!==null?o:Qa(et.type)||"Memo";case Ha:o=et._payload,et=et._init;try{return Qa(et(o))}catch{}}return null}function Ra(et){var o=et.type;switch(et.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return et=o.render,et=et.displayName||et.name||"",o.displayName||(et!==""?"ForwardRef("+et+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qa(o);case 8:return o===za?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function Sa(et){switch(typeof et){case"boolean":case"number":case"string":case"undefined":return et;case"object":return et;default:return""}}function Ta(et){var o=et.type;return(et=et.nodeName)&&et.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function Ua(et){var o=Ta(et)?"checked":"value",tt=Object.getOwnPropertyDescriptor(et.constructor.prototype,o),rt=""+et[o];if(!et.hasOwnProperty(o)&&typeof tt<"u"&&typeof tt.get=="function"&&typeof tt.set=="function"){var nt=tt.get,ot=tt.set;return Object.defineProperty(et,o,{configurable:!0,get:function(){return nt.call(this)},set:function(it){rt=""+it,ot.call(this,it)}}),Object.defineProperty(et,o,{enumerable:tt.enumerable}),{getValue:function(){return rt},setValue:function(it){rt=""+it},stopTracking:function(){et._valueTracker=null,delete et[o]}}}}function Va(et){et._valueTracker||(et._valueTracker=Ua(et))}function Wa(et){if(!et)return!1;var o=et._valueTracker;if(!o)return!0;var tt=o.getValue(),rt="";return et&&(rt=Ta(et)?et.checked?"true":"false":et.value),et=rt,et!==tt?(o.setValue(et),!0):!1}function Xa(et){if(et=et||(typeof document<"u"?document:void 0),typeof et>"u")return null;try{return et.activeElement||et.body}catch{return et.body}}function Ya(et,o){var tt=o.checked;return A$1({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:tt??et._wrapperState.initialChecked})}function Za(et,o){var tt=o.defaultValue==null?"":o.defaultValue,rt=o.checked!=null?o.checked:o.defaultChecked;tt=Sa(o.value!=null?o.value:tt),et._wrapperState={initialChecked:rt,initialValue:tt,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function ab(et,o){o=o.checked,o!=null&&ta(et,"checked",o,!1)}function bb(et,o){ab(et,o);var tt=Sa(o.value),rt=o.type;if(tt!=null)rt==="number"?(tt===0&&et.value===""||et.value!=tt)&&(et.value=""+tt):et.value!==""+tt&&(et.value=""+tt);else if(rt==="submit"||rt==="reset"){et.removeAttribute("value");return}o.hasOwnProperty("value")?cb$1(et,o.type,tt):o.hasOwnProperty("defaultValue")&&cb$1(et,o.type,Sa(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(et.defaultChecked=!!o.defaultChecked)}function db(et,o,tt){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var rt=o.type;if(!(rt!=="submit"&&rt!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+et._wrapperState.initialValue,tt||o===et.value||(et.value=o),et.defaultValue=o}tt=et.name,tt!==""&&(et.name=""),et.defaultChecked=!!et._wrapperState.initialChecked,tt!==""&&(et.name=tt)}function cb$1(et,o,tt){(o!=="number"||Xa(et.ownerDocument)!==et)&&(tt==null?et.defaultValue=""+et._wrapperState.initialValue:et.defaultValue!==""+tt&&(et.defaultValue=""+tt))}var eb=Array.isArray;function fb(et,o,tt,rt){if(et=et.options,o){o={};for(var nt=0;nt"+o.valueOf().toString()+"",o=mb.firstChild;et.firstChild;)et.removeChild(et.firstChild);for(;o.firstChild;)et.appendChild(o.firstChild)}});function ob(et,o){if(o){var tt=et.firstChild;if(tt&&tt===et.lastChild&&tt.nodeType===3){tt.nodeValue=o;return}}et.textContent=o}var pb={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qb=["Webkit","ms","Moz","O"];Object.keys(pb).forEach(function(et){qb.forEach(function(o){o=o+et.charAt(0).toUpperCase()+et.substring(1),pb[o]=pb[et]})});function rb(et,o,tt){return o==null||typeof o=="boolean"||o===""?"":tt||typeof o!="number"||o===0||pb.hasOwnProperty(et)&&pb[et]?(""+o).trim():o+"px"}function sb(et,o){et=et.style;for(var tt in o)if(o.hasOwnProperty(tt)){var rt=tt.indexOf("--")===0,nt=rb(tt,o[tt],rt);tt==="float"&&(tt="cssFloat"),rt?et.setProperty(tt,nt):et[tt]=nt}}var tb=A$1({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ub(et,o){if(o){if(tb[et]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(p$4(137,et));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(p$4(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(p$4(61))}if(o.style!=null&&typeof o.style!="object")throw Error(p$4(62))}}function vb(et,o){if(et.indexOf("-")===-1)return typeof o.is=="string";switch(et){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 wb=null;function xb(et){return et=et.target||et.srcElement||window,et.correspondingUseElement&&(et=et.correspondingUseElement),et.nodeType===3?et.parentNode:et}var yb=null,zb=null,Ab=null;function Bb(et){if(et=Cb(et)){if(typeof yb!="function")throw Error(p$4(280));var o=et.stateNode;o&&(o=Db(o),yb(et.stateNode,et.type,o))}}function Eb(et){zb?Ab?Ab.push(et):Ab=[et]:zb=et}function Fb(){if(zb){var et=zb,o=Ab;if(Ab=zb=null,Bb(et),o)for(et=0;et>>=0,et===0?32:31-(pc(et)/qc|0)|0}var rc=64,sc=4194304;function tc(et){switch(et&-et){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: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:return et&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return et&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return et}}function uc(et,o){var tt=et.pendingLanes;if(tt===0)return 0;var rt=0,nt=et.suspendedLanes,ot=et.pingedLanes,it=tt&268435455;if(it!==0){var st=it&~nt;st!==0?rt=tc(st):(ot&=it,ot!==0&&(rt=tc(ot)))}else it=tt&~nt,it!==0?rt=tc(it):ot!==0&&(rt=tc(ot));if(rt===0)return 0;if(o!==0&&o!==rt&&!(o&nt)&&(nt=rt&-rt,ot=o&-o,nt>=ot||nt===16&&(ot&4194240)!==0))return o;if(rt&4&&(rt|=tt&16),o=et.entangledLanes,o!==0)for(et=et.entanglements,o&=rt;0tt;tt++)o.push(et);return o}function Ac(et,o,tt){et.pendingLanes|=o,o!==536870912&&(et.suspendedLanes=0,et.pingedLanes=0),et=et.eventTimes,o=31-oc(o),et[o]=tt}function Bc(et,o){var tt=et.pendingLanes&~o;et.pendingLanes=o,et.suspendedLanes=0,et.pingedLanes=0,et.expiredLanes&=o,et.mutableReadLanes&=o,et.entangledLanes&=o,o=et.entanglements;var rt=et.eventTimes;for(et=et.expirationTimes;0=be$1),ee$1=" ",fe$1=!1;function ge$1(et,o){switch(et){case"keyup":return $d.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function he$1(et){return et=et.detail,typeof et=="object"&&"data"in et?et.data:null}var ie$1=!1;function je$1(et,o){switch(et){case"compositionend":return he$1(o);case"keypress":return o.which!==32?null:(fe$1=!0,ee$1);case"textInput":return et=o.data,et===ee$1&&fe$1?null:et;default:return null}}function ke$1(et,o){if(ie$1)return et==="compositionend"||!ae$1&&ge$1(et,o)?(et=nd(),md=ld=kd=null,ie$1=!1,et):null;switch(et){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1=o)return{node:tt,offset:o-et};et=rt}e:{for(;tt;){if(tt.nextSibling){tt=tt.nextSibling;break e}tt=tt.parentNode}tt=void 0}tt=Je(tt)}}function Le$1(et,o){return et&&o?et===o?!0:et&&et.nodeType===3?!1:o&&o.nodeType===3?Le$1(et,o.parentNode):"contains"in et?et.contains(o):et.compareDocumentPosition?!!(et.compareDocumentPosition(o)&16):!1:!1}function Me$1(){for(var et=window,o=Xa();o instanceof et.HTMLIFrameElement;){try{var tt=typeof o.contentWindow.location.href=="string"}catch{tt=!1}if(tt)et=o.contentWindow;else break;o=Xa(et.document)}return o}function Ne$1(et){var o=et&&et.nodeName&&et.nodeName.toLowerCase();return o&&(o==="input"&&(et.type==="text"||et.type==="search"||et.type==="tel"||et.type==="url"||et.type==="password")||o==="textarea"||et.contentEditable==="true")}function Oe$1(et){var o=Me$1(),tt=et.focusedElem,rt=et.selectionRange;if(o!==tt&&tt&&tt.ownerDocument&&Le$1(tt.ownerDocument.documentElement,tt)){if(rt!==null&&Ne$1(tt)){if(o=rt.start,et=rt.end,et===void 0&&(et=o),"selectionStart"in tt)tt.selectionStart=o,tt.selectionEnd=Math.min(et,tt.value.length);else if(et=(o=tt.ownerDocument||document)&&o.defaultView||window,et.getSelection){et=et.getSelection();var nt=tt.textContent.length,ot=Math.min(rt.start,nt);rt=rt.end===void 0?ot:Math.min(rt.end,nt),!et.extend&&ot>rt&&(nt=rt,rt=ot,ot=nt),nt=Ke(tt,ot);var it=Ke(tt,rt);nt&&it&&(et.rangeCount!==1||et.anchorNode!==nt.node||et.anchorOffset!==nt.offset||et.focusNode!==it.node||et.focusOffset!==it.offset)&&(o=o.createRange(),o.setStart(nt.node,nt.offset),et.removeAllRanges(),ot>rt?(et.addRange(o),et.extend(it.node,it.offset)):(o.setEnd(it.node,it.offset),et.addRange(o)))}}for(o=[],et=tt;et=et.parentNode;)et.nodeType===1&&o.push({element:et,left:et.scrollLeft,top:et.scrollTop});for(typeof tt.focus=="function"&&tt.focus(),tt=0;tt=document.documentMode,Qe=null,Re$1=null,Se$1=null,Te$1=!1;function Ue(et,o,tt){var rt=tt.window===tt?tt.document:tt.nodeType===9?tt:tt.ownerDocument;Te$1||Qe==null||Qe!==Xa(rt)||(rt=Qe,"selectionStart"in rt&&Ne$1(rt)?rt={start:rt.selectionStart,end:rt.selectionEnd}:(rt=(rt.ownerDocument&&rt.ownerDocument.defaultView||window).getSelection(),rt={anchorNode:rt.anchorNode,anchorOffset:rt.anchorOffset,focusNode:rt.focusNode,focusOffset:rt.focusOffset}),Se$1&&Ie(Se$1,rt)||(Se$1=rt,rt=oe$1(Re$1,"onSelect"),0Tf||(et.current=Sf[Tf],Sf[Tf]=null,Tf--)}function G$1(et,o){Tf++,Sf[Tf]=et.current,et.current=o}var Vf={},H$1=Uf(Vf),Wf=Uf(!1),Xf=Vf;function Yf(et,o){var tt=et.type.contextTypes;if(!tt)return Vf;var rt=et.stateNode;if(rt&&rt.__reactInternalMemoizedUnmaskedChildContext===o)return rt.__reactInternalMemoizedMaskedChildContext;var nt={},ot;for(ot in tt)nt[ot]=o[ot];return rt&&(et=et.stateNode,et.__reactInternalMemoizedUnmaskedChildContext=o,et.__reactInternalMemoizedMaskedChildContext=nt),nt}function Zf(et){return et=et.childContextTypes,et!=null}function $f(){E$1(Wf),E$1(H$1)}function ag(et,o,tt){if(H$1.current!==Vf)throw Error(p$4(168));G$1(H$1,o),G$1(Wf,tt)}function bg(et,o,tt){var rt=et.stateNode;if(o=o.childContextTypes,typeof rt.getChildContext!="function")return tt;rt=rt.getChildContext();for(var nt in rt)if(!(nt in o))throw Error(p$4(108,Ra(et)||"Unknown",nt));return A$1({},tt,rt)}function cg(et){return et=(et=et.stateNode)&&et.__reactInternalMemoizedMergedChildContext||Vf,Xf=H$1.current,G$1(H$1,et),G$1(Wf,Wf.current),!0}function dg(et,o,tt){var rt=et.stateNode;if(!rt)throw Error(p$4(169));tt?(et=bg(et,o,Xf),rt.__reactInternalMemoizedMergedChildContext=et,E$1(Wf),E$1(H$1),G$1(H$1,et)):E$1(Wf),G$1(Wf,tt)}var eg=null,fg=!1,gg=!1;function hg(et){eg===null?eg=[et]:eg.push(et)}function ig(et){fg=!0,hg(et)}function jg(){if(!gg&&eg!==null){gg=!0;var et=0,o=C$1;try{var tt=eg;for(C$1=1;et>=it,nt-=it,rg=1<<32-oc(o)+nt|tt<At?(kt=St,St=null):kt=St.sibling;var It=ht(yt,St,xt[At],vt);if(It===null){St===null&&(St=kt);break}et&&St&&It.alternate===null&&o(yt,St),bt=ot(It,bt,At),Ct===null?Et=It:Ct.sibling=It,Ct=It,St=kt}if(At===xt.length)return tt(yt,St),I$1&&tg(yt,At),Et;if(St===null){for(;AtAt?(kt=St,St=null):kt=St.sibling;var Ot=ht(yt,St,It.value,vt);if(Ot===null){St===null&&(St=kt);break}et&&St&&Ot.alternate===null&&o(yt,St),bt=ot(Ot,bt,At),Ct===null?Et=Ot:Ct.sibling=Ot,Ct=Ot,St=kt}if(It.done)return tt(yt,St),I$1&&tg(yt,At),Et;if(St===null){for(;!It.done;At++,It=xt.next())It=dt(yt,It.value,vt),It!==null&&(bt=ot(It,bt,At),Ct===null?Et=It:Ct.sibling=It,Ct=It);return I$1&&tg(yt,At),Et}for(St=rt(yt,St);!It.done;At++,It=xt.next())It=mt(St,yt,At,It.value,vt),It!==null&&(et&&It.alternate!==null&&St.delete(It.key===null?At:It.key),bt=ot(It,bt,At),Ct===null?Et=It:Ct.sibling=It,Ct=It);return et&&St.forEach(function(Nt){return o(yt,Nt)}),I$1&&tg(yt,At),Et}function gt(yt,bt,xt,vt){if(typeof xt=="object"&&xt!==null&&xt.type===ya&&xt.key===null&&(xt=xt.props.children),typeof xt=="object"&&xt!==null){switch(xt.$$typeof){case va:e:{for(var Et=xt.key,Ct=bt;Ct!==null;){if(Ct.key===Et){if(Et=xt.type,Et===ya){if(Ct.tag===7){tt(yt,Ct.sibling),bt=nt(Ct,xt.props.children),bt.return=yt,yt=bt;break e}}else if(Ct.elementType===Et||typeof Et=="object"&&Et!==null&&Et.$$typeof===Ha&&Ng(Et)===Ct.type){tt(yt,Ct.sibling),bt=nt(Ct,xt.props),bt.ref=Lg(yt,Ct,xt),bt.return=yt,yt=bt;break e}tt(yt,Ct);break}else o(yt,Ct);Ct=Ct.sibling}xt.type===ya?(bt=Tg(xt.props.children,yt.mode,vt,xt.key),bt.return=yt,yt=bt):(vt=Rg(xt.type,xt.key,xt.props,null,yt.mode,vt),vt.ref=Lg(yt,bt,xt),vt.return=yt,yt=vt)}return it(yt);case wa:e:{for(Ct=xt.key;bt!==null;){if(bt.key===Ct)if(bt.tag===4&&bt.stateNode.containerInfo===xt.containerInfo&&bt.stateNode.implementation===xt.implementation){tt(yt,bt.sibling),bt=nt(bt,xt.children||[]),bt.return=yt,yt=bt;break e}else{tt(yt,bt);break}else o(yt,bt);bt=bt.sibling}bt=Sg(xt,yt.mode,vt),bt.return=yt,yt=bt}return it(yt);case Ha:return Ct=xt._init,gt(yt,bt,Ct(xt._payload),vt)}if(eb(xt))return ft(yt,bt,xt,vt);if(Ka(xt))return pt(yt,bt,xt,vt);Mg(yt,xt)}return typeof xt=="string"&&xt!==""||typeof xt=="number"?(xt=""+xt,bt!==null&&bt.tag===6?(tt(yt,bt.sibling),bt=nt(bt,xt),bt.return=yt,yt=bt):(tt(yt,bt),bt=Qg(xt,yt.mode,vt),bt.return=yt,yt=bt),it(yt)):tt(yt,bt)}return gt}var Ug=Og(!0),Vg=Og(!1),Wg=Uf(null),Xg=null,Yg=null,Zg=null;function $g(){Zg=Yg=Xg=null}function ah(et){var o=Wg.current;E$1(Wg),et._currentValue=o}function bh(et,o,tt){for(;et!==null;){var rt=et.alternate;if((et.childLanes&o)!==o?(et.childLanes|=o,rt!==null&&(rt.childLanes|=o)):rt!==null&&(rt.childLanes&o)!==o&&(rt.childLanes|=o),et===tt)break;et=et.return}}function ch(et,o){Xg=et,Zg=Yg=null,et=et.dependencies,et!==null&&et.firstContext!==null&&(et.lanes&o&&(dh=!0),et.firstContext=null)}function eh(et){var o=et._currentValue;if(Zg!==et)if(et={context:et,memoizedValue:o,next:null},Yg===null){if(Xg===null)throw Error(p$4(308));Yg=et,Xg.dependencies={lanes:0,firstContext:et}}else Yg=Yg.next=et;return o}var fh=null;function gh(et){fh===null?fh=[et]:fh.push(et)}function hh(et,o,tt,rt){var nt=o.interleaved;return nt===null?(tt.next=tt,gh(o)):(tt.next=nt.next,nt.next=tt),o.interleaved=tt,ih(et,rt)}function ih(et,o){et.lanes|=o;var tt=et.alternate;for(tt!==null&&(tt.lanes|=o),tt=et,et=et.return;et!==null;)et.childLanes|=o,tt=et.alternate,tt!==null&&(tt.childLanes|=o),tt=et,et=et.return;return tt.tag===3?tt.stateNode:null}var jh=!1;function kh(et){et.updateQueue={baseState:et.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function lh(et,o){et=et.updateQueue,o.updateQueue===et&&(o.updateQueue={baseState:et.baseState,firstBaseUpdate:et.firstBaseUpdate,lastBaseUpdate:et.lastBaseUpdate,shared:et.shared,effects:et.effects})}function mh(et,o){return{eventTime:et,lane:o,tag:0,payload:null,callback:null,next:null}}function nh(et,o,tt){var rt=et.updateQueue;if(rt===null)return null;if(rt=rt.shared,K$1&2){var nt=rt.pending;return nt===null?o.next=o:(o.next=nt.next,nt.next=o),rt.pending=o,ih(et,tt)}return nt=rt.interleaved,nt===null?(o.next=o,gh(rt)):(o.next=nt.next,nt.next=o),rt.interleaved=o,ih(et,tt)}function oh(et,o,tt){if(o=o.updateQueue,o!==null&&(o=o.shared,(tt&4194240)!==0)){var rt=o.lanes;rt&=et.pendingLanes,tt|=rt,o.lanes=tt,Cc(et,tt)}}function ph(et,o){var tt=et.updateQueue,rt=et.alternate;if(rt!==null&&(rt=rt.updateQueue,tt===rt)){var nt=null,ot=null;if(tt=tt.firstBaseUpdate,tt!==null){do{var it={eventTime:tt.eventTime,lane:tt.lane,tag:tt.tag,payload:tt.payload,callback:tt.callback,next:null};ot===null?nt=ot=it:ot=ot.next=it,tt=tt.next}while(tt!==null);ot===null?nt=ot=o:ot=ot.next=o}else nt=ot=o;tt={baseState:rt.baseState,firstBaseUpdate:nt,lastBaseUpdate:ot,shared:rt.shared,effects:rt.effects},et.updateQueue=tt;return}et=tt.lastBaseUpdate,et===null?tt.firstBaseUpdate=o:et.next=o,tt.lastBaseUpdate=o}function qh(et,o,tt,rt){var nt=et.updateQueue;jh=!1;var ot=nt.firstBaseUpdate,it=nt.lastBaseUpdate,st=nt.shared.pending;if(st!==null){nt.shared.pending=null;var at=st,ct=at.next;at.next=null,it===null?ot=ct:it.next=ct,it=at;var lt=et.alternate;lt!==null&&(lt=lt.updateQueue,st=lt.lastBaseUpdate,st!==it&&(st===null?lt.firstBaseUpdate=ct:st.next=ct,lt.lastBaseUpdate=at))}if(ot!==null){var dt=nt.baseState;it=0,lt=ct=at=null,st=ot;do{var ht=st.lane,mt=st.eventTime;if((rt&ht)===ht){lt!==null&&(lt=lt.next={eventTime:mt,lane:0,tag:st.tag,payload:st.payload,callback:st.callback,next:null});e:{var ft=et,pt=st;switch(ht=o,mt=tt,pt.tag){case 1:if(ft=pt.payload,typeof ft=="function"){dt=ft.call(mt,dt,ht);break e}dt=ft;break e;case 3:ft.flags=ft.flags&-65537|128;case 0:if(ft=pt.payload,ht=typeof ft=="function"?ft.call(mt,dt,ht):ft,ht==null)break e;dt=A$1({},dt,ht);break e;case 2:jh=!0}}st.callback!==null&&st.lane!==0&&(et.flags|=64,ht=nt.effects,ht===null?nt.effects=[st]:ht.push(st))}else mt={eventTime:mt,lane:ht,tag:st.tag,payload:st.payload,callback:st.callback,next:null},lt===null?(ct=lt=mt,at=dt):lt=lt.next=mt,it|=ht;if(st=st.next,st===null){if(st=nt.shared.pending,st===null)break;ht=st,st=ht.next,ht.next=null,nt.lastBaseUpdate=ht,nt.shared.pending=null}}while(!0);if(lt===null&&(at=dt),nt.baseState=at,nt.firstBaseUpdate=ct,nt.lastBaseUpdate=lt,o=nt.shared.interleaved,o!==null){nt=o;do it|=nt.lane,nt=nt.next;while(nt!==o)}else ot===null&&(nt.shared.lanes=0);rh|=it,et.lanes=it,et.memoizedState=dt}}function sh(et,o,tt){if(et=o.effects,o.effects=null,et!==null)for(o=0;ott?tt:4,et(!0);var rt=Gh.transition;Gh.transition={};try{et(!1),o()}finally{C$1=tt,Gh.transition=rt}}function wi(){return Uh().memoizedState}function xi(et,o,tt){var rt=yi(et);if(tt={lane:rt,action:tt,hasEagerState:!1,eagerState:null,next:null},zi(et))Ai(o,tt);else if(tt=hh(et,o,tt,rt),tt!==null){var nt=R();gi(tt,et,rt,nt),Bi(tt,o,rt)}}function ii(et,o,tt){var rt=yi(et),nt={lane:rt,action:tt,hasEagerState:!1,eagerState:null,next:null};if(zi(et))Ai(o,nt);else{var ot=et.alternate;if(et.lanes===0&&(ot===null||ot.lanes===0)&&(ot=o.lastRenderedReducer,ot!==null))try{var it=o.lastRenderedState,st=ot(it,tt);if(nt.hasEagerState=!0,nt.eagerState=st,He(st,it)){var at=o.interleaved;at===null?(nt.next=nt,gh(o)):(nt.next=at.next,at.next=nt),o.interleaved=nt;return}}catch{}finally{}tt=hh(et,o,nt,rt),tt!==null&&(nt=R(),gi(tt,et,rt,nt),Bi(tt,o,rt))}}function zi(et){var o=et.alternate;return et===M$1||o!==null&&o===M$1}function Ai(et,o){Jh=Ih=!0;var tt=et.pending;tt===null?o.next=o:(o.next=tt.next,tt.next=o),et.pending=o}function Bi(et,o,tt){if(tt&4194240){var rt=o.lanes;rt&=et.pendingLanes,tt|=rt,o.lanes=tt,Cc(et,tt)}}var Rh={readContext:eh,useCallback:P,useContext:P,useEffect:P,useImperativeHandle:P,useInsertionEffect:P,useLayoutEffect:P,useMemo:P,useReducer:P,useRef:P,useState:P,useDebugValue:P,useDeferredValue:P,useTransition:P,useMutableSource:P,useSyncExternalStore:P,useId:P,unstable_isNewReconciler:!1},Oh={readContext:eh,useCallback:function(et,o){return Th().memoizedState=[et,o===void 0?null:o],et},useContext:eh,useEffect:mi,useImperativeHandle:function(et,o,tt){return tt=tt!=null?tt.concat([et]):null,ki(4194308,4,pi.bind(null,o,et),tt)},useLayoutEffect:function(et,o){return ki(4194308,4,et,o)},useInsertionEffect:function(et,o){return ki(4,2,et,o)},useMemo:function(et,o){var tt=Th();return o=o===void 0?null:o,et=et(),tt.memoizedState=[et,o],et},useReducer:function(et,o,tt){var rt=Th();return o=tt!==void 0?tt(o):o,rt.memoizedState=rt.baseState=o,et={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:et,lastRenderedState:o},rt.queue=et,et=et.dispatch=xi.bind(null,M$1,et),[rt.memoizedState,et]},useRef:function(et){var o=Th();return et={current:et},o.memoizedState=et},useState:hi,useDebugValue:ri,useDeferredValue:function(et){return Th().memoizedState=et},useTransition:function(){var et=hi(!1),o=et[0];return et=vi.bind(null,et[1]),Th().memoizedState=et,[o,et]},useMutableSource:function(){},useSyncExternalStore:function(et,o,tt){var rt=M$1,nt=Th();if(I$1){if(tt===void 0)throw Error(p$4(407));tt=tt()}else{if(tt=o(),Q$1===null)throw Error(p$4(349));Hh&30||di(rt,o,tt)}nt.memoizedState=tt;var ot={value:tt,getSnapshot:o};return nt.queue=ot,mi(ai.bind(null,rt,ot,et),[et]),rt.flags|=2048,bi(9,ci.bind(null,rt,ot,tt,o),void 0,null),tt},useId:function(){var et=Th(),o=Q$1.identifierPrefix;if(I$1){var tt=sg,rt=rg;tt=(rt&~(1<<32-oc(rt)-1)).toString(32)+tt,o=":"+o+"R"+tt,tt=Kh++,0")&&(at=at.replace("",et.displayName)),at}while(1<=it&&0<=st);break}}}finally{Na=!1,Error.prepareStackTrace=tt}return(et=et?et.displayName||et.name:"")?Ma(et):""}function Pa(et){switch(et.tag){case 5:return Ma(et.type);case 16:return Ma("Lazy");case 13:return Ma("Suspense");case 19:return Ma("SuspenseList");case 0:case 2:case 15:return et=Oa(et.type,!1),et;case 11:return et=Oa(et.type.render,!1),et;case 1:return et=Oa(et.type,!0),et;default:return""}}function Qa(et){if(et==null)return null;if(typeof et=="function")return et.displayName||et.name||null;if(typeof et=="string")return et;switch(et){case ya:return"Fragment";case wa:return"Portal";case Aa:return"Profiler";case za:return"StrictMode";case Ea:return"Suspense";case Fa:return"SuspenseList"}if(typeof et=="object")switch(et.$$typeof){case Ca:return(et.displayName||"Context")+".Consumer";case Ba:return(et._context.displayName||"Context")+".Provider";case Da:var o=et.render;return et=et.displayName,et||(et=o.displayName||o.name||"",et=et!==""?"ForwardRef("+et+")":"ForwardRef"),et;case Ga:return o=et.displayName||null,o!==null?o:Qa(et.type)||"Memo";case Ha:o=et._payload,et=et._init;try{return Qa(et(o))}catch{}}return null}function Ra(et){var o=et.type;switch(et.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return et=o.render,et=et.displayName||et.name||"",o.displayName||(et!==""?"ForwardRef("+et+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qa(o);case 8:return o===za?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function Sa(et){switch(typeof et){case"boolean":case"number":case"string":case"undefined":return et;case"object":return et;default:return""}}function Ta(et){var o=et.type;return(et=et.nodeName)&&et.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function Ua(et){var o=Ta(et)?"checked":"value",tt=Object.getOwnPropertyDescriptor(et.constructor.prototype,o),rt=""+et[o];if(!et.hasOwnProperty(o)&&typeof tt<"u"&&typeof tt.get=="function"&&typeof tt.set=="function"){var nt=tt.get,ot=tt.set;return Object.defineProperty(et,o,{configurable:!0,get:function(){return nt.call(this)},set:function(it){rt=""+it,ot.call(this,it)}}),Object.defineProperty(et,o,{enumerable:tt.enumerable}),{getValue:function(){return rt},setValue:function(it){rt=""+it},stopTracking:function(){et._valueTracker=null,delete et[o]}}}}function Va(et){et._valueTracker||(et._valueTracker=Ua(et))}function Wa(et){if(!et)return!1;var o=et._valueTracker;if(!o)return!0;var tt=o.getValue(),rt="";return et&&(rt=Ta(et)?et.checked?"true":"false":et.value),et=rt,et!==tt?(o.setValue(et),!0):!1}function Xa(et){if(et=et||(typeof document<"u"?document:void 0),typeof et>"u")return null;try{return et.activeElement||et.body}catch{return et.body}}function Ya(et,o){var tt=o.checked;return A$1({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:tt??et._wrapperState.initialChecked})}function Za(et,o){var tt=o.defaultValue==null?"":o.defaultValue,rt=o.checked!=null?o.checked:o.defaultChecked;tt=Sa(o.value!=null?o.value:tt),et._wrapperState={initialChecked:rt,initialValue:tt,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function ab(et,o){o=o.checked,o!=null&&ta(et,"checked",o,!1)}function bb(et,o){ab(et,o);var tt=Sa(o.value),rt=o.type;if(tt!=null)rt==="number"?(tt===0&&et.value===""||et.value!=tt)&&(et.value=""+tt):et.value!==""+tt&&(et.value=""+tt);else if(rt==="submit"||rt==="reset"){et.removeAttribute("value");return}o.hasOwnProperty("value")?cb$1(et,o.type,tt):o.hasOwnProperty("defaultValue")&&cb$1(et,o.type,Sa(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(et.defaultChecked=!!o.defaultChecked)}function db(et,o,tt){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var rt=o.type;if(!(rt!=="submit"&&rt!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+et._wrapperState.initialValue,tt||o===et.value||(et.value=o),et.defaultValue=o}tt=et.name,tt!==""&&(et.name=""),et.defaultChecked=!!et._wrapperState.initialChecked,tt!==""&&(et.name=tt)}function cb$1(et,o,tt){(o!=="number"||Xa(et.ownerDocument)!==et)&&(tt==null?et.defaultValue=""+et._wrapperState.initialValue:et.defaultValue!==""+tt&&(et.defaultValue=""+tt))}var eb=Array.isArray;function fb(et,o,tt,rt){if(et=et.options,o){o={};for(var nt=0;nt"+o.valueOf().toString()+"",o=mb.firstChild;et.firstChild;)et.removeChild(et.firstChild);for(;o.firstChild;)et.appendChild(o.firstChild)}});function ob(et,o){if(o){var tt=et.firstChild;if(tt&&tt===et.lastChild&&tt.nodeType===3){tt.nodeValue=o;return}}et.textContent=o}var pb={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qb=["Webkit","ms","Moz","O"];Object.keys(pb).forEach(function(et){qb.forEach(function(o){o=o+et.charAt(0).toUpperCase()+et.substring(1),pb[o]=pb[et]})});function rb(et,o,tt){return o==null||typeof o=="boolean"||o===""?"":tt||typeof o!="number"||o===0||pb.hasOwnProperty(et)&&pb[et]?(""+o).trim():o+"px"}function sb(et,o){et=et.style;for(var tt in o)if(o.hasOwnProperty(tt)){var rt=tt.indexOf("--")===0,nt=rb(tt,o[tt],rt);tt==="float"&&(tt="cssFloat"),rt?et.setProperty(tt,nt):et[tt]=nt}}var tb=A$1({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ub(et,o){if(o){if(tb[et]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(p$4(137,et));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(p$4(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(p$4(61))}if(o.style!=null&&typeof o.style!="object")throw Error(p$4(62))}}function vb(et,o){if(et.indexOf("-")===-1)return typeof o.is=="string";switch(et){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 wb=null;function xb(et){return et=et.target||et.srcElement||window,et.correspondingUseElement&&(et=et.correspondingUseElement),et.nodeType===3?et.parentNode:et}var yb=null,zb=null,Ab=null;function Bb(et){if(et=Cb(et)){if(typeof yb!="function")throw Error(p$4(280));var o=et.stateNode;o&&(o=Db(o),yb(et.stateNode,et.type,o))}}function Eb(et){zb?Ab?Ab.push(et):Ab=[et]:zb=et}function Fb(){if(zb){var et=zb,o=Ab;if(Ab=zb=null,Bb(et),o)for(et=0;et>>=0,et===0?32:31-(pc(et)/qc|0)|0}var rc=64,sc=4194304;function tc(et){switch(et&-et){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: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:return et&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return et&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return et}}function uc(et,o){var tt=et.pendingLanes;if(tt===0)return 0;var rt=0,nt=et.suspendedLanes,ot=et.pingedLanes,it=tt&268435455;if(it!==0){var st=it&~nt;st!==0?rt=tc(st):(ot&=it,ot!==0&&(rt=tc(ot)))}else it=tt&~nt,it!==0?rt=tc(it):ot!==0&&(rt=tc(ot));if(rt===0)return 0;if(o!==0&&o!==rt&&!(o&nt)&&(nt=rt&-rt,ot=o&-o,nt>=ot||nt===16&&(ot&4194240)!==0))return o;if(rt&4&&(rt|=tt&16),o=et.entangledLanes,o!==0)for(et=et.entanglements,o&=rt;0tt;tt++)o.push(et);return o}function Ac(et,o,tt){et.pendingLanes|=o,o!==536870912&&(et.suspendedLanes=0,et.pingedLanes=0),et=et.eventTimes,o=31-oc(o),et[o]=tt}function Bc(et,o){var tt=et.pendingLanes&~o;et.pendingLanes=o,et.suspendedLanes=0,et.pingedLanes=0,et.expiredLanes&=o,et.mutableReadLanes&=o,et.entangledLanes&=o,o=et.entanglements;var rt=et.eventTimes;for(et=et.expirationTimes;0=be$1),ee$1=" ",fe$1=!1;function ge$1(et,o){switch(et){case"keyup":return $d.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function he$1(et){return et=et.detail,typeof et=="object"&&"data"in et?et.data:null}var ie$1=!1;function je$1(et,o){switch(et){case"compositionend":return he$1(o);case"keypress":return o.which!==32?null:(fe$1=!0,ee$1);case"textInput":return et=o.data,et===ee$1&&fe$1?null:et;default:return null}}function ke$1(et,o){if(ie$1)return et==="compositionend"||!ae$1&&ge$1(et,o)?(et=nd(),md=ld=kd=null,ie$1=!1,et):null;switch(et){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1=o)return{node:tt,offset:o-et};et=rt}e:{for(;tt;){if(tt.nextSibling){tt=tt.nextSibling;break e}tt=tt.parentNode}tt=void 0}tt=Je(tt)}}function Le$1(et,o){return et&&o?et===o?!0:et&&et.nodeType===3?!1:o&&o.nodeType===3?Le$1(et,o.parentNode):"contains"in et?et.contains(o):et.compareDocumentPosition?!!(et.compareDocumentPosition(o)&16):!1:!1}function Me$1(){for(var et=window,o=Xa();o instanceof et.HTMLIFrameElement;){try{var tt=typeof o.contentWindow.location.href=="string"}catch{tt=!1}if(tt)et=o.contentWindow;else break;o=Xa(et.document)}return o}function Ne$1(et){var o=et&&et.nodeName&&et.nodeName.toLowerCase();return o&&(o==="input"&&(et.type==="text"||et.type==="search"||et.type==="tel"||et.type==="url"||et.type==="password")||o==="textarea"||et.contentEditable==="true")}function Oe$1(et){var o=Me$1(),tt=et.focusedElem,rt=et.selectionRange;if(o!==tt&&tt&&tt.ownerDocument&&Le$1(tt.ownerDocument.documentElement,tt)){if(rt!==null&&Ne$1(tt)){if(o=rt.start,et=rt.end,et===void 0&&(et=o),"selectionStart"in tt)tt.selectionStart=o,tt.selectionEnd=Math.min(et,tt.value.length);else if(et=(o=tt.ownerDocument||document)&&o.defaultView||window,et.getSelection){et=et.getSelection();var nt=tt.textContent.length,ot=Math.min(rt.start,nt);rt=rt.end===void 0?ot:Math.min(rt.end,nt),!et.extend&&ot>rt&&(nt=rt,rt=ot,ot=nt),nt=Ke(tt,ot);var it=Ke(tt,rt);nt&&it&&(et.rangeCount!==1||et.anchorNode!==nt.node||et.anchorOffset!==nt.offset||et.focusNode!==it.node||et.focusOffset!==it.offset)&&(o=o.createRange(),o.setStart(nt.node,nt.offset),et.removeAllRanges(),ot>rt?(et.addRange(o),et.extend(it.node,it.offset)):(o.setEnd(it.node,it.offset),et.addRange(o)))}}for(o=[],et=tt;et=et.parentNode;)et.nodeType===1&&o.push({element:et,left:et.scrollLeft,top:et.scrollTop});for(typeof tt.focus=="function"&&tt.focus(),tt=0;tt=document.documentMode,Qe=null,Re$1=null,Se$1=null,Te$1=!1;function Ue(et,o,tt){var rt=tt.window===tt?tt.document:tt.nodeType===9?tt:tt.ownerDocument;Te$1||Qe==null||Qe!==Xa(rt)||(rt=Qe,"selectionStart"in rt&&Ne$1(rt)?rt={start:rt.selectionStart,end:rt.selectionEnd}:(rt=(rt.ownerDocument&&rt.ownerDocument.defaultView||window).getSelection(),rt={anchorNode:rt.anchorNode,anchorOffset:rt.anchorOffset,focusNode:rt.focusNode,focusOffset:rt.focusOffset}),Se$1&&Ie(Se$1,rt)||(Se$1=rt,rt=oe$1(Re$1,"onSelect"),0Tf||(et.current=Sf[Tf],Sf[Tf]=null,Tf--)}function G$1(et,o){Tf++,Sf[Tf]=et.current,et.current=o}var Vf={},H$1=Uf(Vf),Wf=Uf(!1),Xf=Vf;function Yf(et,o){var tt=et.type.contextTypes;if(!tt)return Vf;var rt=et.stateNode;if(rt&&rt.__reactInternalMemoizedUnmaskedChildContext===o)return rt.__reactInternalMemoizedMaskedChildContext;var nt={},ot;for(ot in tt)nt[ot]=o[ot];return rt&&(et=et.stateNode,et.__reactInternalMemoizedUnmaskedChildContext=o,et.__reactInternalMemoizedMaskedChildContext=nt),nt}function Zf(et){return et=et.childContextTypes,et!=null}function $f(){E$1(Wf),E$1(H$1)}function ag(et,o,tt){if(H$1.current!==Vf)throw Error(p$4(168));G$1(H$1,o),G$1(Wf,tt)}function bg(et,o,tt){var rt=et.stateNode;if(o=o.childContextTypes,typeof rt.getChildContext!="function")return tt;rt=rt.getChildContext();for(var nt in rt)if(!(nt in o))throw Error(p$4(108,Ra(et)||"Unknown",nt));return A$1({},tt,rt)}function cg(et){return et=(et=et.stateNode)&&et.__reactInternalMemoizedMergedChildContext||Vf,Xf=H$1.current,G$1(H$1,et),G$1(Wf,Wf.current),!0}function dg(et,o,tt){var rt=et.stateNode;if(!rt)throw Error(p$4(169));tt?(et=bg(et,o,Xf),rt.__reactInternalMemoizedMergedChildContext=et,E$1(Wf),E$1(H$1),G$1(H$1,et)):E$1(Wf),G$1(Wf,tt)}var eg=null,fg=!1,gg=!1;function hg(et){eg===null?eg=[et]:eg.push(et)}function ig(et){fg=!0,hg(et)}function jg(){if(!gg&&eg!==null){gg=!0;var et=0,o=C$1;try{var tt=eg;for(C$1=1;et>=it,nt-=it,rg=1<<32-oc(o)+nt|tt<At?(kt=St,St=null):kt=St.sibling;var It=ht(gt,St,xt[At],vt);if(It===null){St===null&&(St=kt);break}et&&St&&It.alternate===null&&o(gt,St),bt=ot(It,bt,At),Ct===null?Et=It:Ct.sibling=It,Ct=It,St=kt}if(At===xt.length)return tt(gt,St),I$1&&tg(gt,At),Et;if(St===null){for(;AtAt?(kt=St,St=null):kt=St.sibling;var Nt=ht(gt,St,It.value,vt);if(Nt===null){St===null&&(St=kt);break}et&&St&&Nt.alternate===null&&o(gt,St),bt=ot(Nt,bt,At),Ct===null?Et=Nt:Ct.sibling=Nt,Ct=Nt,St=kt}if(It.done)return tt(gt,St),I$1&&tg(gt,At),Et;if(St===null){for(;!It.done;At++,It=xt.next())It=dt(gt,It.value,vt),It!==null&&(bt=ot(It,bt,At),Ct===null?Et=It:Ct.sibling=It,Ct=It);return I$1&&tg(gt,At),Et}for(St=rt(gt,St);!It.done;At++,It=xt.next())It=mt(St,gt,At,It.value,vt),It!==null&&(et&&It.alternate!==null&&St.delete(It.key===null?At:It.key),bt=ot(It,bt,At),Ct===null?Et=It:Ct.sibling=It,Ct=It);return et&&St.forEach(function(Lt){return o(gt,Lt)}),I$1&&tg(gt,At),Et}function yt(gt,bt,xt,vt){if(typeof xt=="object"&&xt!==null&&xt.type===ya&&xt.key===null&&(xt=xt.props.children),typeof xt=="object"&&xt!==null){switch(xt.$$typeof){case va:e:{for(var Et=xt.key,Ct=bt;Ct!==null;){if(Ct.key===Et){if(Et=xt.type,Et===ya){if(Ct.tag===7){tt(gt,Ct.sibling),bt=nt(Ct,xt.props.children),bt.return=gt,gt=bt;break e}}else if(Ct.elementType===Et||typeof Et=="object"&&Et!==null&&Et.$$typeof===Ha&&Ng(Et)===Ct.type){tt(gt,Ct.sibling),bt=nt(Ct,xt.props),bt.ref=Lg(gt,Ct,xt),bt.return=gt,gt=bt;break e}tt(gt,Ct);break}else o(gt,Ct);Ct=Ct.sibling}xt.type===ya?(bt=Tg(xt.props.children,gt.mode,vt,xt.key),bt.return=gt,gt=bt):(vt=Rg(xt.type,xt.key,xt.props,null,gt.mode,vt),vt.ref=Lg(gt,bt,xt),vt.return=gt,gt=vt)}return it(gt);case wa:e:{for(Ct=xt.key;bt!==null;){if(bt.key===Ct)if(bt.tag===4&&bt.stateNode.containerInfo===xt.containerInfo&&bt.stateNode.implementation===xt.implementation){tt(gt,bt.sibling),bt=nt(bt,xt.children||[]),bt.return=gt,gt=bt;break e}else{tt(gt,bt);break}else o(gt,bt);bt=bt.sibling}bt=Sg(xt,gt.mode,vt),bt.return=gt,gt=bt}return it(gt);case Ha:return Ct=xt._init,yt(gt,bt,Ct(xt._payload),vt)}if(eb(xt))return ft(gt,bt,xt,vt);if(Ka(xt))return pt(gt,bt,xt,vt);Mg(gt,xt)}return typeof xt=="string"&&xt!==""||typeof xt=="number"?(xt=""+xt,bt!==null&&bt.tag===6?(tt(gt,bt.sibling),bt=nt(bt,xt),bt.return=gt,gt=bt):(tt(gt,bt),bt=Qg(xt,gt.mode,vt),bt.return=gt,gt=bt),it(gt)):tt(gt,bt)}return yt}var Ug=Og(!0),Vg=Og(!1),Wg=Uf(null),Xg=null,Yg=null,Zg=null;function $g(){Zg=Yg=Xg=null}function ah(et){var o=Wg.current;E$1(Wg),et._currentValue=o}function bh(et,o,tt){for(;et!==null;){var rt=et.alternate;if((et.childLanes&o)!==o?(et.childLanes|=o,rt!==null&&(rt.childLanes|=o)):rt!==null&&(rt.childLanes&o)!==o&&(rt.childLanes|=o),et===tt)break;et=et.return}}function ch(et,o){Xg=et,Zg=Yg=null,et=et.dependencies,et!==null&&et.firstContext!==null&&(et.lanes&o&&(dh=!0),et.firstContext=null)}function eh(et){var o=et._currentValue;if(Zg!==et)if(et={context:et,memoizedValue:o,next:null},Yg===null){if(Xg===null)throw Error(p$4(308));Yg=et,Xg.dependencies={lanes:0,firstContext:et}}else Yg=Yg.next=et;return o}var fh=null;function gh(et){fh===null?fh=[et]:fh.push(et)}function hh(et,o,tt,rt){var nt=o.interleaved;return nt===null?(tt.next=tt,gh(o)):(tt.next=nt.next,nt.next=tt),o.interleaved=tt,ih(et,rt)}function ih(et,o){et.lanes|=o;var tt=et.alternate;for(tt!==null&&(tt.lanes|=o),tt=et,et=et.return;et!==null;)et.childLanes|=o,tt=et.alternate,tt!==null&&(tt.childLanes|=o),tt=et,et=et.return;return tt.tag===3?tt.stateNode:null}var jh=!1;function kh(et){et.updateQueue={baseState:et.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function lh(et,o){et=et.updateQueue,o.updateQueue===et&&(o.updateQueue={baseState:et.baseState,firstBaseUpdate:et.firstBaseUpdate,lastBaseUpdate:et.lastBaseUpdate,shared:et.shared,effects:et.effects})}function mh(et,o){return{eventTime:et,lane:o,tag:0,payload:null,callback:null,next:null}}function nh(et,o,tt){var rt=et.updateQueue;if(rt===null)return null;if(rt=rt.shared,K$1&2){var nt=rt.pending;return nt===null?o.next=o:(o.next=nt.next,nt.next=o),rt.pending=o,ih(et,tt)}return nt=rt.interleaved,nt===null?(o.next=o,gh(rt)):(o.next=nt.next,nt.next=o),rt.interleaved=o,ih(et,tt)}function oh(et,o,tt){if(o=o.updateQueue,o!==null&&(o=o.shared,(tt&4194240)!==0)){var rt=o.lanes;rt&=et.pendingLanes,tt|=rt,o.lanes=tt,Cc(et,tt)}}function ph(et,o){var tt=et.updateQueue,rt=et.alternate;if(rt!==null&&(rt=rt.updateQueue,tt===rt)){var nt=null,ot=null;if(tt=tt.firstBaseUpdate,tt!==null){do{var it={eventTime:tt.eventTime,lane:tt.lane,tag:tt.tag,payload:tt.payload,callback:tt.callback,next:null};ot===null?nt=ot=it:ot=ot.next=it,tt=tt.next}while(tt!==null);ot===null?nt=ot=o:ot=ot.next=o}else nt=ot=o;tt={baseState:rt.baseState,firstBaseUpdate:nt,lastBaseUpdate:ot,shared:rt.shared,effects:rt.effects},et.updateQueue=tt;return}et=tt.lastBaseUpdate,et===null?tt.firstBaseUpdate=o:et.next=o,tt.lastBaseUpdate=o}function qh(et,o,tt,rt){var nt=et.updateQueue;jh=!1;var ot=nt.firstBaseUpdate,it=nt.lastBaseUpdate,st=nt.shared.pending;if(st!==null){nt.shared.pending=null;var at=st,ct=at.next;at.next=null,it===null?ot=ct:it.next=ct,it=at;var lt=et.alternate;lt!==null&&(lt=lt.updateQueue,st=lt.lastBaseUpdate,st!==it&&(st===null?lt.firstBaseUpdate=ct:st.next=ct,lt.lastBaseUpdate=at))}if(ot!==null){var dt=nt.baseState;it=0,lt=ct=at=null,st=ot;do{var ht=st.lane,mt=st.eventTime;if((rt&ht)===ht){lt!==null&&(lt=lt.next={eventTime:mt,lane:0,tag:st.tag,payload:st.payload,callback:st.callback,next:null});e:{var ft=et,pt=st;switch(ht=o,mt=tt,pt.tag){case 1:if(ft=pt.payload,typeof ft=="function"){dt=ft.call(mt,dt,ht);break e}dt=ft;break e;case 3:ft.flags=ft.flags&-65537|128;case 0:if(ft=pt.payload,ht=typeof ft=="function"?ft.call(mt,dt,ht):ft,ht==null)break e;dt=A$1({},dt,ht);break e;case 2:jh=!0}}st.callback!==null&&st.lane!==0&&(et.flags|=64,ht=nt.effects,ht===null?nt.effects=[st]:ht.push(st))}else mt={eventTime:mt,lane:ht,tag:st.tag,payload:st.payload,callback:st.callback,next:null},lt===null?(ct=lt=mt,at=dt):lt=lt.next=mt,it|=ht;if(st=st.next,st===null){if(st=nt.shared.pending,st===null)break;ht=st,st=ht.next,ht.next=null,nt.lastBaseUpdate=ht,nt.shared.pending=null}}while(!0);if(lt===null&&(at=dt),nt.baseState=at,nt.firstBaseUpdate=ct,nt.lastBaseUpdate=lt,o=nt.shared.interleaved,o!==null){nt=o;do it|=nt.lane,nt=nt.next;while(nt!==o)}else ot===null&&(nt.shared.lanes=0);rh|=it,et.lanes=it,et.memoizedState=dt}}function sh(et,o,tt){if(et=o.effects,o.effects=null,et!==null)for(o=0;ott?tt:4,et(!0);var rt=Gh.transition;Gh.transition={};try{et(!1),o()}finally{C$1=tt,Gh.transition=rt}}function wi(){return Uh().memoizedState}function xi(et,o,tt){var rt=yi(et);if(tt={lane:rt,action:tt,hasEagerState:!1,eagerState:null,next:null},zi(et))Ai(o,tt);else if(tt=hh(et,o,tt,rt),tt!==null){var nt=R();gi(tt,et,rt,nt),Bi(tt,o,rt)}}function ii(et,o,tt){var rt=yi(et),nt={lane:rt,action:tt,hasEagerState:!1,eagerState:null,next:null};if(zi(et))Ai(o,nt);else{var ot=et.alternate;if(et.lanes===0&&(ot===null||ot.lanes===0)&&(ot=o.lastRenderedReducer,ot!==null))try{var it=o.lastRenderedState,st=ot(it,tt);if(nt.hasEagerState=!0,nt.eagerState=st,He(st,it)){var at=o.interleaved;at===null?(nt.next=nt,gh(o)):(nt.next=at.next,at.next=nt),o.interleaved=nt;return}}catch{}finally{}tt=hh(et,o,nt,rt),tt!==null&&(nt=R(),gi(tt,et,rt,nt),Bi(tt,o,rt))}}function zi(et){var o=et.alternate;return et===M$1||o!==null&&o===M$1}function Ai(et,o){Jh=Ih=!0;var tt=et.pending;tt===null?o.next=o:(o.next=tt.next,tt.next=o),et.pending=o}function Bi(et,o,tt){if(tt&4194240){var rt=o.lanes;rt&=et.pendingLanes,tt|=rt,o.lanes=tt,Cc(et,tt)}}var Rh={readContext:eh,useCallback:P,useContext:P,useEffect:P,useImperativeHandle:P,useInsertionEffect:P,useLayoutEffect:P,useMemo:P,useReducer:P,useRef:P,useState:P,useDebugValue:P,useDeferredValue:P,useTransition:P,useMutableSource:P,useSyncExternalStore:P,useId:P,unstable_isNewReconciler:!1},Oh={readContext:eh,useCallback:function(et,o){return Th().memoizedState=[et,o===void 0?null:o],et},useContext:eh,useEffect:mi,useImperativeHandle:function(et,o,tt){return tt=tt!=null?tt.concat([et]):null,ki(4194308,4,pi.bind(null,o,et),tt)},useLayoutEffect:function(et,o){return ki(4194308,4,et,o)},useInsertionEffect:function(et,o){return ki(4,2,et,o)},useMemo:function(et,o){var tt=Th();return o=o===void 0?null:o,et=et(),tt.memoizedState=[et,o],et},useReducer:function(et,o,tt){var rt=Th();return o=tt!==void 0?tt(o):o,rt.memoizedState=rt.baseState=o,et={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:et,lastRenderedState:o},rt.queue=et,et=et.dispatch=xi.bind(null,M$1,et),[rt.memoizedState,et]},useRef:function(et){var o=Th();return et={current:et},o.memoizedState=et},useState:hi,useDebugValue:ri,useDeferredValue:function(et){return Th().memoizedState=et},useTransition:function(){var et=hi(!1),o=et[0];return et=vi.bind(null,et[1]),Th().memoizedState=et,[o,et]},useMutableSource:function(){},useSyncExternalStore:function(et,o,tt){var rt=M$1,nt=Th();if(I$1){if(tt===void 0)throw Error(p$4(407));tt=tt()}else{if(tt=o(),Q$1===null)throw Error(p$4(349));Hh&30||di(rt,o,tt)}nt.memoizedState=tt;var ot={value:tt,getSnapshot:o};return nt.queue=ot,mi(ai.bind(null,rt,ot,et),[et]),rt.flags|=2048,bi(9,ci.bind(null,rt,ot,tt,o),void 0,null),tt},useId:function(){var et=Th(),o=Q$1.identifierPrefix;if(I$1){var tt=sg,rt=rg;tt=(rt&~(1<<32-oc(rt)-1)).toString(32)+tt,o=":"+o+"R"+tt,tt=Kh++,0<\/script>",et=et.removeChild(et.firstChild)):typeof rt.is=="string"?et=it.createElement(tt,{is:rt.is}):(et=it.createElement(tt),tt==="select"&&(it=et,rt.multiple?it.multiple=!0:rt.size&&(it.size=rt.size))):et=it.createElementNS(et,tt),et[Of]=o,et[Pf]=rt,zj(et,o,!1,!1),o.stateNode=et;e:{switch(it=vb(tt,rt),tt){case"dialog":D$1("cancel",et),D$1("close",et),nt=rt;break;case"iframe":case"object":case"embed":D$1("load",et),nt=rt;break;case"video":case"audio":for(nt=0;ntGj&&(o.flags|=128,rt=!0,Dj(ot,!1),o.lanes=4194304)}else{if(!rt)if(et=Ch(it),et!==null){if(o.flags|=128,rt=!0,tt=et.updateQueue,tt!==null&&(o.updateQueue=tt,o.flags|=4),Dj(ot,!0),ot.tail===null&&ot.tailMode==="hidden"&&!it.alternate&&!I$1)return S$1(o),null}else 2*B$1()-ot.renderingStartTime>Gj&&tt!==1073741824&&(o.flags|=128,rt=!0,Dj(ot,!1),o.lanes=4194304);ot.isBackwards?(it.sibling=o.child,o.child=it):(tt=ot.last,tt!==null?tt.sibling=it:o.child=it,ot.last=it)}return ot.tail!==null?(o=ot.tail,ot.rendering=o,ot.tail=o.sibling,ot.renderingStartTime=B$1(),o.sibling=null,tt=L$1.current,G$1(L$1,rt?tt&1|2:tt&1),o):(S$1(o),null);case 22:case 23:return Hj(),rt=o.memoizedState!==null,et!==null&&et.memoizedState!==null!==rt&&(o.flags|=8192),rt&&o.mode&1?fj&1073741824&&(S$1(o),o.subtreeFlags&6&&(o.flags|=8192)):S$1(o),null;case 24:return null;case 25:return null}throw Error(p$4(156,o.tag))}function Ij(et,o){switch(wg(o),o.tag){case 1:return Zf(o.type)&&$f(),et=o.flags,et&65536?(o.flags=et&-65537|128,o):null;case 3:return zh(),E$1(Wf),E$1(H$1),Eh(),et=o.flags,et&65536&&!(et&128)?(o.flags=et&-65537|128,o):null;case 5:return Bh(o),null;case 13:if(E$1(L$1),et=o.memoizedState,et!==null&&et.dehydrated!==null){if(o.alternate===null)throw Error(p$4(340));Ig()}return et=o.flags,et&65536?(o.flags=et&-65537|128,o):null;case 19:return E$1(L$1),null;case 4:return zh(),null;case 10:return ah(o.type._context),null;case 22:case 23:return Hj(),null;case 24:return null;default:return null}}var Jj=!1,U$1=!1,Kj=typeof WeakSet=="function"?WeakSet:Set,V$2=null;function Lj(et,o){var tt=et.ref;if(tt!==null)if(typeof tt=="function")try{tt(null)}catch(rt){W$1(et,o,rt)}else tt.current=null}function Mj(et,o,tt){try{tt()}catch(rt){W$1(et,o,rt)}}var Nj=!1;function Oj(et,o){if(Cf=dd,et=Me$1(),Ne$1(et)){if("selectionStart"in et)var tt={start:et.selectionStart,end:et.selectionEnd};else e:{tt=(tt=et.ownerDocument)&&tt.defaultView||window;var rt=tt.getSelection&&tt.getSelection();if(rt&&rt.rangeCount!==0){tt=rt.anchorNode;var nt=rt.anchorOffset,ot=rt.focusNode;rt=rt.focusOffset;try{tt.nodeType,ot.nodeType}catch{tt=null;break e}var it=0,st=-1,at=-1,ct=0,lt=0,dt=et,ht=null;t:for(;;){for(var mt;dt!==tt||nt!==0&&dt.nodeType!==3||(st=it+nt),dt!==ot||rt!==0&&dt.nodeType!==3||(at=it+rt),dt.nodeType===3&&(it+=dt.nodeValue.length),(mt=dt.firstChild)!==null;)ht=dt,dt=mt;for(;;){if(dt===et)break t;if(ht===tt&&++ct===nt&&(st=it),ht===ot&&++lt===rt&&(at=it),(mt=dt.nextSibling)!==null)break;dt=ht,ht=dt.parentNode}dt=mt}tt=st===-1||at===-1?null:{start:st,end:at}}else tt=null}tt=tt||{start:0,end:0}}else tt=null;for(Df={focusedElem:et,selectionRange:tt},dd=!1,V$2=o;V$2!==null;)if(o=V$2,et=o.child,(o.subtreeFlags&1028)!==0&&et!==null)et.return=o,V$2=et;else for(;V$2!==null;){o=V$2;try{var ft=o.alternate;if(o.flags&1024)switch(o.tag){case 0:case 11:case 15:break;case 1:if(ft!==null){var pt=ft.memoizedProps,gt=ft.memoizedState,yt=o.stateNode,bt=yt.getSnapshotBeforeUpdate(o.elementType===o.type?pt:Ci(o.type,pt),gt);yt.__reactInternalSnapshotBeforeUpdate=bt}break;case 3:var xt=o.stateNode.containerInfo;xt.nodeType===1?xt.textContent="":xt.nodeType===9&&xt.documentElement&&xt.removeChild(xt.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(p$4(163))}}catch(vt){W$1(o,o.return,vt)}if(et=o.sibling,et!==null){et.return=o.return,V$2=et;break}V$2=o.return}return ft=Nj,Nj=!1,ft}function Pj(et,o,tt){var rt=o.updateQueue;if(rt=rt!==null?rt.lastEffect:null,rt!==null){var nt=rt=rt.next;do{if((nt.tag&et)===et){var ot=nt.destroy;nt.destroy=void 0,ot!==void 0&&Mj(o,tt,ot)}nt=nt.next}while(nt!==rt)}}function Qj(et,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var tt=o=o.next;do{if((tt.tag&et)===et){var rt=tt.create;tt.destroy=rt()}tt=tt.next}while(tt!==o)}}function Rj(et){var o=et.ref;if(o!==null){var tt=et.stateNode;switch(et.tag){case 5:et=tt;break;default:et=tt}typeof o=="function"?o(et):o.current=et}}function Sj(et){var o=et.alternate;o!==null&&(et.alternate=null,Sj(o)),et.child=null,et.deletions=null,et.sibling=null,et.tag===5&&(o=et.stateNode,o!==null&&(delete o[Of],delete o[Pf],delete o[of],delete o[Qf],delete o[Rf])),et.stateNode=null,et.return=null,et.dependencies=null,et.memoizedProps=null,et.memoizedState=null,et.pendingProps=null,et.stateNode=null,et.updateQueue=null}function Tj(et){return et.tag===5||et.tag===3||et.tag===4}function Uj(et){e:for(;;){for(;et.sibling===null;){if(et.return===null||Tj(et.return))return null;et=et.return}for(et.sibling.return=et.return,et=et.sibling;et.tag!==5&&et.tag!==6&&et.tag!==18;){if(et.flags&2||et.child===null||et.tag===4)continue e;et.child.return=et,et=et.child}if(!(et.flags&2))return et.stateNode}}function Vj(et,o,tt){var rt=et.tag;if(rt===5||rt===6)et=et.stateNode,o?tt.nodeType===8?tt.parentNode.insertBefore(et,o):tt.insertBefore(et,o):(tt.nodeType===8?(o=tt.parentNode,o.insertBefore(et,tt)):(o=tt,o.appendChild(et)),tt=tt._reactRootContainer,tt!=null||o.onclick!==null||(o.onclick=Bf));else if(rt!==4&&(et=et.child,et!==null))for(Vj(et,o,tt),et=et.sibling;et!==null;)Vj(et,o,tt),et=et.sibling}function Wj(et,o,tt){var rt=et.tag;if(rt===5||rt===6)et=et.stateNode,o?tt.insertBefore(et,o):tt.appendChild(et);else if(rt!==4&&(et=et.child,et!==null))for(Wj(et,o,tt),et=et.sibling;et!==null;)Wj(et,o,tt),et=et.sibling}var X$1=null,Xj=!1;function Yj(et,o,tt){for(tt=tt.child;tt!==null;)Zj(et,o,tt),tt=tt.sibling}function Zj(et,o,tt){if(lc&&typeof lc.onCommitFiberUnmount=="function")try{lc.onCommitFiberUnmount(kc,tt)}catch{}switch(tt.tag){case 5:U$1||Lj(tt,o);case 6:var rt=X$1,nt=Xj;X$1=null,Yj(et,o,tt),X$1=rt,Xj=nt,X$1!==null&&(Xj?(et=X$1,tt=tt.stateNode,et.nodeType===8?et.parentNode.removeChild(tt):et.removeChild(tt)):X$1.removeChild(tt.stateNode));break;case 18:X$1!==null&&(Xj?(et=X$1,tt=tt.stateNode,et.nodeType===8?Kf(et.parentNode,tt):et.nodeType===1&&Kf(et,tt),bd(et)):Kf(X$1,tt.stateNode));break;case 4:rt=X$1,nt=Xj,X$1=tt.stateNode.containerInfo,Xj=!0,Yj(et,o,tt),X$1=rt,Xj=nt;break;case 0:case 11:case 14:case 15:if(!U$1&&(rt=tt.updateQueue,rt!==null&&(rt=rt.lastEffect,rt!==null))){nt=rt=rt.next;do{var ot=nt,it=ot.destroy;ot=ot.tag,it!==void 0&&(ot&2||ot&4)&&Mj(tt,o,it),nt=nt.next}while(nt!==rt)}Yj(et,o,tt);break;case 1:if(!U$1&&(Lj(tt,o),rt=tt.stateNode,typeof rt.componentWillUnmount=="function"))try{rt.props=tt.memoizedProps,rt.state=tt.memoizedState,rt.componentWillUnmount()}catch(st){W$1(tt,o,st)}Yj(et,o,tt);break;case 21:Yj(et,o,tt);break;case 22:tt.mode&1?(U$1=(rt=U$1)||tt.memoizedState!==null,Yj(et,o,tt),U$1=rt):Yj(et,o,tt);break;default:Yj(et,o,tt)}}function ak(et){var o=et.updateQueue;if(o!==null){et.updateQueue=null;var tt=et.stateNode;tt===null&&(tt=et.stateNode=new Kj),o.forEach(function(rt){var nt=bk.bind(null,et,rt);tt.has(rt)||(tt.add(rt),rt.then(nt,nt))})}}function ck(et,o){var tt=o.deletions;if(tt!==null)for(var rt=0;rtnt&&(nt=it),rt&=~ot}if(rt=nt,rt=B$1()-rt,rt=(120>rt?120:480>rt?480:1080>rt?1080:1920>rt?1920:3e3>rt?3e3:4320>rt?4320:1960*lk(rt/1960))-rt,10et?16:et,wk===null)var rt=!1;else{if(et=wk,wk=null,xk=0,K$1&6)throw Error(p$4(331));var nt=K$1;for(K$1|=4,V$2=et.current;V$2!==null;){var ot=V$2,it=ot.child;if(V$2.flags&16){var st=ot.deletions;if(st!==null){for(var at=0;atB$1()-fk?Kk(et,0):rk|=tt),Dk(et,o)}function Yk(et,o){o===0&&(et.mode&1?(o=sc,sc<<=1,!(sc&130023424)&&(sc=4194304)):o=1);var tt=R();et=ih(et,o),et!==null&&(Ac(et,o,tt),Dk(et,tt))}function uj(et){var o=et.memoizedState,tt=0;o!==null&&(tt=o.retryLane),Yk(et,tt)}function bk(et,o){var tt=0;switch(et.tag){case 13:var rt=et.stateNode,nt=et.memoizedState;nt!==null&&(tt=nt.retryLane);break;case 19:rt=et.stateNode;break;default:throw Error(p$4(314))}rt!==null&&rt.delete(o),Yk(et,tt)}var Vk;Vk=function(et,o,tt){if(et!==null)if(et.memoizedProps!==o.pendingProps||Wf.current)dh=!0;else{if(!(et.lanes&tt)&&!(o.flags&128))return dh=!1,yj(et,o,tt);dh=!!(et.flags&131072)}else dh=!1,I$1&&o.flags&1048576&&ug(o,ng,o.index);switch(o.lanes=0,o.tag){case 2:var rt=o.type;ij(et,o),et=o.pendingProps;var nt=Yf(o,H$1.current);ch(o,tt),nt=Nh(null,o,rt,et,nt,tt);var ot=Sh();return o.flags|=1,typeof nt=="object"&&nt!==null&&typeof nt.render=="function"&&nt.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,Zf(rt)?(ot=!0,cg(o)):ot=!1,o.memoizedState=nt.state!==null&&nt.state!==void 0?nt.state:null,kh(o),nt.updater=Ei,o.stateNode=nt,nt._reactInternals=o,Ii(o,rt,et,tt),o=jj(null,o,rt,!0,ot,tt)):(o.tag=0,I$1&&ot&&vg(o),Xi(null,o,nt,tt),o=o.child),o;case 16:rt=o.elementType;e:{switch(ij(et,o),et=o.pendingProps,nt=rt._init,rt=nt(rt._payload),o.type=rt,nt=o.tag=Zk(rt),et=Ci(rt,et),nt){case 0:o=cj(null,o,rt,et,tt);break e;case 1:o=hj(null,o,rt,et,tt);break e;case 11:o=Yi(null,o,rt,et,tt);break e;case 14:o=$i(null,o,rt,Ci(rt.type,et),tt);break e}throw Error(p$4(306,rt,""))}return o;case 0:return rt=o.type,nt=o.pendingProps,nt=o.elementType===rt?nt:Ci(rt,nt),cj(et,o,rt,nt,tt);case 1:return rt=o.type,nt=o.pendingProps,nt=o.elementType===rt?nt:Ci(rt,nt),hj(et,o,rt,nt,tt);case 3:e:{if(kj(o),et===null)throw Error(p$4(387));rt=o.pendingProps,ot=o.memoizedState,nt=ot.element,lh(et,o),qh(o,rt,null,tt);var it=o.memoizedState;if(rt=it.element,ot.isDehydrated)if(ot={element:rt,isDehydrated:!1,cache:it.cache,pendingSuspenseBoundaries:it.pendingSuspenseBoundaries,transitions:it.transitions},o.updateQueue.baseState=ot,o.memoizedState=ot,o.flags&256){nt=Ji(Error(p$4(423)),o),o=lj(et,o,rt,tt,nt);break e}else if(rt!==nt){nt=Ji(Error(p$4(424)),o),o=lj(et,o,rt,tt,nt);break e}else for(yg=Lf(o.stateNode.containerInfo.firstChild),xg=o,I$1=!0,zg=null,tt=Vg(o,null,rt,tt),o.child=tt;tt;)tt.flags=tt.flags&-3|4096,tt=tt.sibling;else{if(Ig(),rt===nt){o=Zi(et,o,tt);break e}Xi(et,o,rt,tt)}o=o.child}return o;case 5:return Ah(o),et===null&&Eg(o),rt=o.type,nt=o.pendingProps,ot=et!==null?et.memoizedProps:null,it=nt.children,Ef(rt,nt)?it=null:ot!==null&&Ef(rt,ot)&&(o.flags|=32),gj(et,o),Xi(et,o,it,tt),o.child;case 6:return et===null&&Eg(o),null;case 13:return oj(et,o,tt);case 4:return yh(o,o.stateNode.containerInfo),rt=o.pendingProps,et===null?o.child=Ug(o,null,rt,tt):Xi(et,o,rt,tt),o.child;case 11:return rt=o.type,nt=o.pendingProps,nt=o.elementType===rt?nt:Ci(rt,nt),Yi(et,o,rt,nt,tt);case 7:return Xi(et,o,o.pendingProps,tt),o.child;case 8:return Xi(et,o,o.pendingProps.children,tt),o.child;case 12:return Xi(et,o,o.pendingProps.children,tt),o.child;case 10:e:{if(rt=o.type._context,nt=o.pendingProps,ot=o.memoizedProps,it=nt.value,G$1(Wg,rt._currentValue),rt._currentValue=it,ot!==null)if(He(ot.value,it)){if(ot.children===nt.children&&!Wf.current){o=Zi(et,o,tt);break e}}else for(ot=o.child,ot!==null&&(ot.return=o);ot!==null;){var st=ot.dependencies;if(st!==null){it=ot.child;for(var at=st.firstContext;at!==null;){if(at.context===rt){if(ot.tag===1){at=mh(-1,tt&-tt),at.tag=2;var ct=ot.updateQueue;if(ct!==null){ct=ct.shared;var lt=ct.pending;lt===null?at.next=at:(at.next=lt.next,lt.next=at),ct.pending=at}}ot.lanes|=tt,at=ot.alternate,at!==null&&(at.lanes|=tt),bh(ot.return,tt,o),st.lanes|=tt;break}at=at.next}}else if(ot.tag===10)it=ot.type===o.type?null:ot.child;else if(ot.tag===18){if(it=ot.return,it===null)throw Error(p$4(341));it.lanes|=tt,st=it.alternate,st!==null&&(st.lanes|=tt),bh(it,tt,o),it=ot.sibling}else it=ot.child;if(it!==null)it.return=ot;else for(it=ot;it!==null;){if(it===o){it=null;break}if(ot=it.sibling,ot!==null){ot.return=it.return,it=ot;break}it=it.return}ot=it}Xi(et,o,nt.children,tt),o=o.child}return o;case 9:return nt=o.type,rt=o.pendingProps.children,ch(o,tt),nt=eh(nt),rt=rt(nt),o.flags|=1,Xi(et,o,rt,tt),o.child;case 14:return rt=o.type,nt=Ci(rt,o.pendingProps),nt=Ci(rt.type,nt),$i(et,o,rt,nt,tt);case 15:return bj(et,o,o.type,o.pendingProps,tt);case 17:return rt=o.type,nt=o.pendingProps,nt=o.elementType===rt?nt:Ci(rt,nt),ij(et,o),o.tag=1,Zf(rt)?(et=!0,cg(o)):et=!1,ch(o,tt),Gi(o,rt,nt),Ii(o,rt,nt,tt),jj(null,o,rt,!0,et,tt);case 19:return xj(et,o,tt);case 22:return dj(et,o,tt)}throw Error(p$4(156,o.tag))};function Fk(et,o){return ac(et,o)}function $k(et,o,tt,rt){this.tag=et,this.key=tt,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=rt,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bg(et,o,tt,rt){return new $k(et,o,tt,rt)}function aj(et){return et=et.prototype,!(!et||!et.isReactComponent)}function Zk(et){if(typeof et=="function")return aj(et)?1:0;if(et!=null){if(et=et.$$typeof,et===Da)return 11;if(et===Ga)return 14}return 2}function Pg(et,o){var tt=et.alternate;return tt===null?(tt=Bg(et.tag,o,et.key,et.mode),tt.elementType=et.elementType,tt.type=et.type,tt.stateNode=et.stateNode,tt.alternate=et,et.alternate=tt):(tt.pendingProps=o,tt.type=et.type,tt.flags=0,tt.subtreeFlags=0,tt.deletions=null),tt.flags=et.flags&14680064,tt.childLanes=et.childLanes,tt.lanes=et.lanes,tt.child=et.child,tt.memoizedProps=et.memoizedProps,tt.memoizedState=et.memoizedState,tt.updateQueue=et.updateQueue,o=et.dependencies,tt.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},tt.sibling=et.sibling,tt.index=et.index,tt.ref=et.ref,tt}function Rg(et,o,tt,rt,nt,ot){var it=2;if(rt=et,typeof et=="function")aj(et)&&(it=1);else if(typeof et=="string")it=5;else e:switch(et){case ya:return Tg(tt.children,nt,ot,o);case za:it=8,nt|=8;break;case Aa:return et=Bg(12,tt,o,nt|2),et.elementType=Aa,et.lanes=ot,et;case Ea:return et=Bg(13,tt,o,nt),et.elementType=Ea,et.lanes=ot,et;case Fa:return et=Bg(19,tt,o,nt),et.elementType=Fa,et.lanes=ot,et;case Ia:return pj(tt,nt,ot,o);default:if(typeof et=="object"&&et!==null)switch(et.$$typeof){case Ba:it=10;break e;case Ca:it=9;break e;case Da:it=11;break e;case Ga:it=14;break e;case Ha:it=16,rt=null;break e}throw Error(p$4(130,et==null?et:typeof et,""))}return o=Bg(it,tt,o,nt),o.elementType=et,o.type=rt,o.lanes=ot,o}function Tg(et,o,tt,rt){return et=Bg(7,et,rt,o),et.lanes=tt,et}function pj(et,o,tt,rt){return et=Bg(22,et,rt,o),et.elementType=Ia,et.lanes=tt,et.stateNode={isHidden:!1},et}function Qg(et,o,tt){return et=Bg(6,et,null,o),et.lanes=tt,et}function Sg(et,o,tt){return o=Bg(4,et.children!==null?et.children:[],et.key,o),o.lanes=tt,o.stateNode={containerInfo:et.containerInfo,pendingChildren:null,implementation:et.implementation},o}function al(et,o,tt,rt,nt){this.tag=o,this.containerInfo=et,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zc(0),this.expirationTimes=zc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zc(0),this.identifierPrefix=rt,this.onRecoverableError=nt,this.mutableSourceEagerHydrationData=null}function bl(et,o,tt,rt,nt,ot,it,st,at){return et=new al(et,o,tt,st,at),o===1?(o=1,ot===!0&&(o|=8)):o=0,ot=Bg(3,null,null,o),et.current=ot,ot.stateNode=et,ot.memoizedState={element:rt,isDehydrated:tt,cache:null,transitions:null,pendingSuspenseBoundaries:null},kh(ot),et}function cl(et,o,tt){var rt=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE)}catch(et){console.error(et)}}checkDCE(),reactDom.exports=reactDom_production_min;var reactDomExports=reactDom.exports;const ReactDOM=getDefaultExportFromCjs(reactDomExports);var createRoot,m$5=reactDomExports;createRoot=m$5.createRoot,m$5.hydrateRoot;const version$8="2.21.28";let errorConfig={getDocsUrl:({docsBaseUrl:et,docsPath:o="",docsSlug:tt})=>o?`${et??"https://viem.sh"}${o}${tt?`#${tt}`:""}`:void 0,version:version$8},BaseError$3=class $s extends Error{constructor(o,tt={}){var st;const rt=(()=>{var at;return tt.cause instanceof $s?tt.cause.details:(at=tt.cause)!=null&&at.message?tt.cause.message:tt.details})(),nt=tt.cause instanceof $s&&tt.cause.docsPath||tt.docsPath,ot=(st=errorConfig.getDocsUrl)==null?void 0:st.call(errorConfig,{...tt,docsPath:nt}),it=[o||"An error occurred.","",...tt.metaMessages?[...tt.metaMessages,""]:[],...ot?[`Docs: ${ot}`]:[],...rt?[`Details: ${rt}`]:[],`Version: ${errorConfig.version}`].join(` +`+ot.stack}return{value:et,source:o,stack:nt,digest:null}}function Ki(et,o,tt){return{value:et,source:null,stack:tt??null,digest:o??null}}function Li(et,o){try{console.error(o.value)}catch(tt){setTimeout(function(){throw tt})}}var Mi=typeof WeakMap=="function"?WeakMap:Map;function Ni(et,o,tt){tt=mh(-1,tt),tt.tag=3,tt.payload={element:null};var rt=o.value;return tt.callback=function(){Oi||(Oi=!0,Pi=rt),Li(et,o)},tt}function Qi(et,o,tt){tt=mh(-1,tt),tt.tag=3;var rt=et.type.getDerivedStateFromError;if(typeof rt=="function"){var nt=o.value;tt.payload=function(){return rt(nt)},tt.callback=function(){Li(et,o)}}var ot=et.stateNode;return ot!==null&&typeof ot.componentDidCatch=="function"&&(tt.callback=function(){Li(et,o),typeof rt!="function"&&(Ri===null?Ri=new Set([this]):Ri.add(this));var it=o.stack;this.componentDidCatch(o.value,{componentStack:it!==null?it:""})}),tt}function Si(et,o,tt){var rt=et.pingCache;if(rt===null){rt=et.pingCache=new Mi;var nt=new Set;rt.set(o,nt)}else nt=rt.get(o),nt===void 0&&(nt=new Set,rt.set(o,nt));nt.has(tt)||(nt.add(tt),et=Ti.bind(null,et,o,tt),o.then(et,et))}function Ui(et){do{var o;if((o=et.tag===13)&&(o=et.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return et;et=et.return}while(et!==null);return null}function Vi(et,o,tt,rt,nt){return et.mode&1?(et.flags|=65536,et.lanes=nt,et):(et===o?et.flags|=65536:(et.flags|=128,tt.flags|=131072,tt.flags&=-52805,tt.tag===1&&(tt.alternate===null?tt.tag=17:(o=mh(-1,1),o.tag=2,nh(tt,o,1))),tt.lanes|=1),et)}var Wi=ua.ReactCurrentOwner,dh=!1;function Xi(et,o,tt,rt){o.child=et===null?Vg(o,null,tt,rt):Ug(o,et.child,tt,rt)}function Yi(et,o,tt,rt,nt){tt=tt.render;var ot=o.ref;return ch(o,nt),rt=Nh(et,o,tt,rt,ot,nt),tt=Sh(),et!==null&&!dh?(o.updateQueue=et.updateQueue,o.flags&=-2053,et.lanes&=~nt,Zi(et,o,nt)):(I$1&&tt&&vg(o),o.flags|=1,Xi(et,o,rt,nt),o.child)}function $i(et,o,tt,rt,nt){if(et===null){var ot=tt.type;return typeof ot=="function"&&!aj(ot)&&ot.defaultProps===void 0&&tt.compare===null&&tt.defaultProps===void 0?(o.tag=15,o.type=ot,bj(et,o,ot,rt,nt)):(et=Rg(tt.type,null,rt,o,o.mode,nt),et.ref=o.ref,et.return=o,o.child=et)}if(ot=et.child,!(et.lanes&nt)){var it=ot.memoizedProps;if(tt=tt.compare,tt=tt!==null?tt:Ie,tt(it,rt)&&et.ref===o.ref)return Zi(et,o,nt)}return o.flags|=1,et=Pg(ot,rt),et.ref=o.ref,et.return=o,o.child=et}function bj(et,o,tt,rt,nt){if(et!==null){var ot=et.memoizedProps;if(Ie(ot,rt)&&et.ref===o.ref)if(dh=!1,o.pendingProps=rt=ot,(et.lanes&nt)!==0)et.flags&131072&&(dh=!0);else return o.lanes=et.lanes,Zi(et,o,nt)}return cj(et,o,tt,rt,nt)}function dj(et,o,tt){var rt=o.pendingProps,nt=rt.children,ot=et!==null?et.memoizedState:null;if(rt.mode==="hidden")if(!(o.mode&1))o.memoizedState={baseLanes:0,cachePool:null,transitions:null},G$1(ej,fj),fj|=tt;else{if(!(tt&1073741824))return et=ot!==null?ot.baseLanes|tt:tt,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:et,cachePool:null,transitions:null},o.updateQueue=null,G$1(ej,fj),fj|=et,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},rt=ot!==null?ot.baseLanes:tt,G$1(ej,fj),fj|=rt}else ot!==null?(rt=ot.baseLanes|tt,o.memoizedState=null):rt=tt,G$1(ej,fj),fj|=rt;return Xi(et,o,nt,tt),o.child}function gj(et,o){var tt=o.ref;(et===null&&tt!==null||et!==null&&et.ref!==tt)&&(o.flags|=512,o.flags|=2097152)}function cj(et,o,tt,rt,nt){var ot=Zf(tt)?Xf:H$1.current;return ot=Yf(o,ot),ch(o,nt),tt=Nh(et,o,tt,rt,ot,nt),rt=Sh(),et!==null&&!dh?(o.updateQueue=et.updateQueue,o.flags&=-2053,et.lanes&=~nt,Zi(et,o,nt)):(I$1&&rt&&vg(o),o.flags|=1,Xi(et,o,tt,nt),o.child)}function hj(et,o,tt,rt,nt){if(Zf(tt)){var ot=!0;cg(o)}else ot=!1;if(ch(o,nt),o.stateNode===null)ij(et,o),Gi(o,tt,rt),Ii(o,tt,rt,nt),rt=!0;else if(et===null){var it=o.stateNode,st=o.memoizedProps;it.props=st;var at=it.context,ct=tt.contextType;typeof ct=="object"&&ct!==null?ct=eh(ct):(ct=Zf(tt)?Xf:H$1.current,ct=Yf(o,ct));var lt=tt.getDerivedStateFromProps,dt=typeof lt=="function"||typeof it.getSnapshotBeforeUpdate=="function";dt||typeof it.UNSAFE_componentWillReceiveProps!="function"&&typeof it.componentWillReceiveProps!="function"||(st!==rt||at!==ct)&&Hi(o,it,rt,ct),jh=!1;var ht=o.memoizedState;it.state=ht,qh(o,rt,it,nt),at=o.memoizedState,st!==rt||ht!==at||Wf.current||jh?(typeof lt=="function"&&(Di(o,tt,lt,rt),at=o.memoizedState),(st=jh||Fi(o,tt,st,rt,ht,at,ct))?(dt||typeof it.UNSAFE_componentWillMount!="function"&&typeof it.componentWillMount!="function"||(typeof it.componentWillMount=="function"&&it.componentWillMount(),typeof it.UNSAFE_componentWillMount=="function"&&it.UNSAFE_componentWillMount()),typeof it.componentDidMount=="function"&&(o.flags|=4194308)):(typeof it.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=rt,o.memoizedState=at),it.props=rt,it.state=at,it.context=ct,rt=st):(typeof it.componentDidMount=="function"&&(o.flags|=4194308),rt=!1)}else{it=o.stateNode,lh(et,o),st=o.memoizedProps,ct=o.type===o.elementType?st:Ci(o.type,st),it.props=ct,dt=o.pendingProps,ht=it.context,at=tt.contextType,typeof at=="object"&&at!==null?at=eh(at):(at=Zf(tt)?Xf:H$1.current,at=Yf(o,at));var mt=tt.getDerivedStateFromProps;(lt=typeof mt=="function"||typeof it.getSnapshotBeforeUpdate=="function")||typeof it.UNSAFE_componentWillReceiveProps!="function"&&typeof it.componentWillReceiveProps!="function"||(st!==dt||ht!==at)&&Hi(o,it,rt,at),jh=!1,ht=o.memoizedState,it.state=ht,qh(o,rt,it,nt);var ft=o.memoizedState;st!==dt||ht!==ft||Wf.current||jh?(typeof mt=="function"&&(Di(o,tt,mt,rt),ft=o.memoizedState),(ct=jh||Fi(o,tt,ct,rt,ht,ft,at)||!1)?(lt||typeof it.UNSAFE_componentWillUpdate!="function"&&typeof it.componentWillUpdate!="function"||(typeof it.componentWillUpdate=="function"&&it.componentWillUpdate(rt,ft,at),typeof it.UNSAFE_componentWillUpdate=="function"&&it.UNSAFE_componentWillUpdate(rt,ft,at)),typeof it.componentDidUpdate=="function"&&(o.flags|=4),typeof it.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof it.componentDidUpdate!="function"||st===et.memoizedProps&&ht===et.memoizedState||(o.flags|=4),typeof it.getSnapshotBeforeUpdate!="function"||st===et.memoizedProps&&ht===et.memoizedState||(o.flags|=1024),o.memoizedProps=rt,o.memoizedState=ft),it.props=rt,it.state=ft,it.context=at,rt=ct):(typeof it.componentDidUpdate!="function"||st===et.memoizedProps&&ht===et.memoizedState||(o.flags|=4),typeof it.getSnapshotBeforeUpdate!="function"||st===et.memoizedProps&&ht===et.memoizedState||(o.flags|=1024),rt=!1)}return jj(et,o,tt,rt,ot,nt)}function jj(et,o,tt,rt,nt,ot){gj(et,o);var it=(o.flags&128)!==0;if(!rt&&!it)return nt&&dg(o,tt,!1),Zi(et,o,ot);rt=o.stateNode,Wi.current=o;var st=it&&typeof tt.getDerivedStateFromError!="function"?null:rt.render();return o.flags|=1,et!==null&&it?(o.child=Ug(o,et.child,null,ot),o.child=Ug(o,null,st,ot)):Xi(et,o,st,ot),o.memoizedState=rt.state,nt&&dg(o,tt,!0),o.child}function kj(et){var o=et.stateNode;o.pendingContext?ag(et,o.pendingContext,o.pendingContext!==o.context):o.context&&ag(et,o.context,!1),yh(et,o.containerInfo)}function lj(et,o,tt,rt,nt){return Ig(),Jg(nt),o.flags|=256,Xi(et,o,tt,rt),o.child}var mj={dehydrated:null,treeContext:null,retryLane:0};function nj(et){return{baseLanes:et,cachePool:null,transitions:null}}function oj(et,o,tt){var rt=o.pendingProps,nt=L$1.current,ot=!1,it=(o.flags&128)!==0,st;if((st=it)||(st=et!==null&&et.memoizedState===null?!1:(nt&2)!==0),st?(ot=!0,o.flags&=-129):(et===null||et.memoizedState!==null)&&(nt|=1),G$1(L$1,nt&1),et===null)return Eg(o),et=o.memoizedState,et!==null&&(et=et.dehydrated,et!==null)?(o.mode&1?et.data==="$!"?o.lanes=8:o.lanes=1073741824:o.lanes=1,null):(it=rt.children,et=rt.fallback,ot?(rt=o.mode,ot=o.child,it={mode:"hidden",children:it},!(rt&1)&&ot!==null?(ot.childLanes=0,ot.pendingProps=it):ot=pj(it,rt,0,null),et=Tg(et,rt,tt,null),ot.return=o,et.return=o,ot.sibling=et,o.child=ot,o.child.memoizedState=nj(tt),o.memoizedState=mj,et):qj(o,it));if(nt=et.memoizedState,nt!==null&&(st=nt.dehydrated,st!==null))return rj(et,o,it,rt,st,nt,tt);if(ot){ot=rt.fallback,it=o.mode,nt=et.child,st=nt.sibling;var at={mode:"hidden",children:rt.children};return!(it&1)&&o.child!==nt?(rt=o.child,rt.childLanes=0,rt.pendingProps=at,o.deletions=null):(rt=Pg(nt,at),rt.subtreeFlags=nt.subtreeFlags&14680064),st!==null?ot=Pg(st,ot):(ot=Tg(ot,it,tt,null),ot.flags|=2),ot.return=o,rt.return=o,rt.sibling=ot,o.child=rt,rt=ot,ot=o.child,it=et.child.memoizedState,it=it===null?nj(tt):{baseLanes:it.baseLanes|tt,cachePool:null,transitions:it.transitions},ot.memoizedState=it,ot.childLanes=et.childLanes&~tt,o.memoizedState=mj,rt}return ot=et.child,et=ot.sibling,rt=Pg(ot,{mode:"visible",children:rt.children}),!(o.mode&1)&&(rt.lanes=tt),rt.return=o,rt.sibling=null,et!==null&&(tt=o.deletions,tt===null?(o.deletions=[et],o.flags|=16):tt.push(et)),o.child=rt,o.memoizedState=null,rt}function qj(et,o){return o=pj({mode:"visible",children:o},et.mode,0,null),o.return=et,et.child=o}function sj(et,o,tt,rt){return rt!==null&&Jg(rt),Ug(o,et.child,null,tt),et=qj(o,o.pendingProps.children),et.flags|=2,o.memoizedState=null,et}function rj(et,o,tt,rt,nt,ot,it){if(tt)return o.flags&256?(o.flags&=-257,rt=Ki(Error(p$4(422))),sj(et,o,it,rt)):o.memoizedState!==null?(o.child=et.child,o.flags|=128,null):(ot=rt.fallback,nt=o.mode,rt=pj({mode:"visible",children:rt.children},nt,0,null),ot=Tg(ot,nt,it,null),ot.flags|=2,rt.return=o,ot.return=o,rt.sibling=ot,o.child=rt,o.mode&1&&Ug(o,et.child,null,it),o.child.memoizedState=nj(it),o.memoizedState=mj,ot);if(!(o.mode&1))return sj(et,o,it,null);if(nt.data==="$!"){if(rt=nt.nextSibling&&nt.nextSibling.dataset,rt)var st=rt.dgst;return rt=st,ot=Error(p$4(419)),rt=Ki(ot,rt,void 0),sj(et,o,it,rt)}if(st=(it&et.childLanes)!==0,dh||st){if(rt=Q$1,rt!==null){switch(it&-it){case 4:nt=2;break;case 16:nt=8;break;case 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:case 8388608:case 16777216:case 33554432:case 67108864:nt=32;break;case 536870912:nt=268435456;break;default:nt=0}nt=nt&(rt.suspendedLanes|it)?0:nt,nt!==0&&nt!==ot.retryLane&&(ot.retryLane=nt,ih(et,nt),gi(rt,et,nt,-1))}return tj(),rt=Ki(Error(p$4(421))),sj(et,o,it,rt)}return nt.data==="$?"?(o.flags|=128,o.child=et.child,o=uj.bind(null,et),nt._reactRetry=o,null):(et=ot.treeContext,yg=Lf(nt.nextSibling),xg=o,I$1=!0,zg=null,et!==null&&(og[pg++]=rg,og[pg++]=sg,og[pg++]=qg,rg=et.id,sg=et.overflow,qg=o),o=qj(o,rt.children),o.flags|=4096,o)}function vj(et,o,tt){et.lanes|=o;var rt=et.alternate;rt!==null&&(rt.lanes|=o),bh(et.return,o,tt)}function wj(et,o,tt,rt,nt){var ot=et.memoizedState;ot===null?et.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:rt,tail:tt,tailMode:nt}:(ot.isBackwards=o,ot.rendering=null,ot.renderingStartTime=0,ot.last=rt,ot.tail=tt,ot.tailMode=nt)}function xj(et,o,tt){var rt=o.pendingProps,nt=rt.revealOrder,ot=rt.tail;if(Xi(et,o,rt.children,tt),rt=L$1.current,rt&2)rt=rt&1|2,o.flags|=128;else{if(et!==null&&et.flags&128)e:for(et=o.child;et!==null;){if(et.tag===13)et.memoizedState!==null&&vj(et,tt,o);else if(et.tag===19)vj(et,tt,o);else if(et.child!==null){et.child.return=et,et=et.child;continue}if(et===o)break e;for(;et.sibling===null;){if(et.return===null||et.return===o)break e;et=et.return}et.sibling.return=et.return,et=et.sibling}rt&=1}if(G$1(L$1,rt),!(o.mode&1))o.memoizedState=null;else switch(nt){case"forwards":for(tt=o.child,nt=null;tt!==null;)et=tt.alternate,et!==null&&Ch(et)===null&&(nt=tt),tt=tt.sibling;tt=nt,tt===null?(nt=o.child,o.child=null):(nt=tt.sibling,tt.sibling=null),wj(o,!1,nt,tt,ot);break;case"backwards":for(tt=null,nt=o.child,o.child=null;nt!==null;){if(et=nt.alternate,et!==null&&Ch(et)===null){o.child=nt;break}et=nt.sibling,nt.sibling=tt,tt=nt,nt=et}wj(o,!0,tt,null,ot);break;case"together":wj(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function ij(et,o){!(o.mode&1)&&et!==null&&(et.alternate=null,o.alternate=null,o.flags|=2)}function Zi(et,o,tt){if(et!==null&&(o.dependencies=et.dependencies),rh|=o.lanes,!(tt&o.childLanes))return null;if(et!==null&&o.child!==et.child)throw Error(p$4(153));if(o.child!==null){for(et=o.child,tt=Pg(et,et.pendingProps),o.child=tt,tt.return=o;et.sibling!==null;)et=et.sibling,tt=tt.sibling=Pg(et,et.pendingProps),tt.return=o;tt.sibling=null}return o.child}function yj(et,o,tt){switch(o.tag){case 3:kj(o),Ig();break;case 5:Ah(o);break;case 1:Zf(o.type)&&cg(o);break;case 4:yh(o,o.stateNode.containerInfo);break;case 10:var rt=o.type._context,nt=o.memoizedProps.value;G$1(Wg,rt._currentValue),rt._currentValue=nt;break;case 13:if(rt=o.memoizedState,rt!==null)return rt.dehydrated!==null?(G$1(L$1,L$1.current&1),o.flags|=128,null):tt&o.child.childLanes?oj(et,o,tt):(G$1(L$1,L$1.current&1),et=Zi(et,o,tt),et!==null?et.sibling:null);G$1(L$1,L$1.current&1);break;case 19:if(rt=(tt&o.childLanes)!==0,et.flags&128){if(rt)return xj(et,o,tt);o.flags|=128}if(nt=o.memoizedState,nt!==null&&(nt.rendering=null,nt.tail=null,nt.lastEffect=null),G$1(L$1,L$1.current),rt)break;return null;case 22:case 23:return o.lanes=0,dj(et,o,tt)}return Zi(et,o,tt)}var zj,Aj,Bj,Cj;zj=function(et,o){for(var tt=o.child;tt!==null;){if(tt.tag===5||tt.tag===6)et.appendChild(tt.stateNode);else if(tt.tag!==4&&tt.child!==null){tt.child.return=tt,tt=tt.child;continue}if(tt===o)break;for(;tt.sibling===null;){if(tt.return===null||tt.return===o)return;tt=tt.return}tt.sibling.return=tt.return,tt=tt.sibling}};Aj=function(){};Bj=function(et,o,tt,rt){var nt=et.memoizedProps;if(nt!==rt){et=o.stateNode,xh(uh.current);var ot=null;switch(tt){case"input":nt=Ya(et,nt),rt=Ya(et,rt),ot=[];break;case"select":nt=A$1({},nt,{value:void 0}),rt=A$1({},rt,{value:void 0}),ot=[];break;case"textarea":nt=gb(et,nt),rt=gb(et,rt),ot=[];break;default:typeof nt.onClick!="function"&&typeof rt.onClick=="function"&&(et.onclick=Bf)}ub(tt,rt);var it;tt=null;for(ct in nt)if(!rt.hasOwnProperty(ct)&&nt.hasOwnProperty(ct)&&nt[ct]!=null)if(ct==="style"){var st=nt[ct];for(it in st)st.hasOwnProperty(it)&&(tt||(tt={}),tt[it]="")}else ct!=="dangerouslySetInnerHTML"&&ct!=="children"&&ct!=="suppressContentEditableWarning"&&ct!=="suppressHydrationWarning"&&ct!=="autoFocus"&&(ea.hasOwnProperty(ct)?ot||(ot=[]):(ot=ot||[]).push(ct,null));for(ct in rt){var at=rt[ct];if(st=nt!=null?nt[ct]:void 0,rt.hasOwnProperty(ct)&&at!==st&&(at!=null||st!=null))if(ct==="style")if(st){for(it in st)!st.hasOwnProperty(it)||at&&at.hasOwnProperty(it)||(tt||(tt={}),tt[it]="");for(it in at)at.hasOwnProperty(it)&&st[it]!==at[it]&&(tt||(tt={}),tt[it]=at[it])}else tt||(ot||(ot=[]),ot.push(ct,tt)),tt=at;else ct==="dangerouslySetInnerHTML"?(at=at?at.__html:void 0,st=st?st.__html:void 0,at!=null&&st!==at&&(ot=ot||[]).push(ct,at)):ct==="children"?typeof at!="string"&&typeof at!="number"||(ot=ot||[]).push(ct,""+at):ct!=="suppressContentEditableWarning"&&ct!=="suppressHydrationWarning"&&(ea.hasOwnProperty(ct)?(at!=null&&ct==="onScroll"&&D$1("scroll",et),ot||st===at||(ot=[])):(ot=ot||[]).push(ct,at))}tt&&(ot=ot||[]).push("style",tt);var ct=ot;(o.updateQueue=ct)&&(o.flags|=4)}};Cj=function(et,o,tt,rt){tt!==rt&&(o.flags|=4)};function Dj(et,o){if(!I$1)switch(et.tailMode){case"hidden":o=et.tail;for(var tt=null;o!==null;)o.alternate!==null&&(tt=o),o=o.sibling;tt===null?et.tail=null:tt.sibling=null;break;case"collapsed":tt=et.tail;for(var rt=null;tt!==null;)tt.alternate!==null&&(rt=tt),tt=tt.sibling;rt===null?o||et.tail===null?et.tail=null:et.tail.sibling=null:rt.sibling=null}}function S$1(et){var o=et.alternate!==null&&et.alternate.child===et.child,tt=0,rt=0;if(o)for(var nt=et.child;nt!==null;)tt|=nt.lanes|nt.childLanes,rt|=nt.subtreeFlags&14680064,rt|=nt.flags&14680064,nt.return=et,nt=nt.sibling;else for(nt=et.child;nt!==null;)tt|=nt.lanes|nt.childLanes,rt|=nt.subtreeFlags,rt|=nt.flags,nt.return=et,nt=nt.sibling;return et.subtreeFlags|=rt,et.childLanes=tt,o}function Ej(et,o,tt){var rt=o.pendingProps;switch(wg(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return S$1(o),null;case 1:return Zf(o.type)&&$f(),S$1(o),null;case 3:return rt=o.stateNode,zh(),E$1(Wf),E$1(H$1),Eh(),rt.pendingContext&&(rt.context=rt.pendingContext,rt.pendingContext=null),(et===null||et.child===null)&&(Gg(o)?o.flags|=4:et===null||et.memoizedState.isDehydrated&&!(o.flags&256)||(o.flags|=1024,zg!==null&&(Fj(zg),zg=null))),Aj(et,o),S$1(o),null;case 5:Bh(o);var nt=xh(wh.current);if(tt=o.type,et!==null&&o.stateNode!=null)Bj(et,o,tt,rt,nt),et.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!rt){if(o.stateNode===null)throw Error(p$4(166));return S$1(o),null}if(et=xh(uh.current),Gg(o)){rt=o.stateNode,tt=o.type;var ot=o.memoizedProps;switch(rt[Of]=o,rt[Pf]=ot,et=(o.mode&1)!==0,tt){case"dialog":D$1("cancel",rt),D$1("close",rt);break;case"iframe":case"object":case"embed":D$1("load",rt);break;case"video":case"audio":for(nt=0;nt<\/script>",et=et.removeChild(et.firstChild)):typeof rt.is=="string"?et=it.createElement(tt,{is:rt.is}):(et=it.createElement(tt),tt==="select"&&(it=et,rt.multiple?it.multiple=!0:rt.size&&(it.size=rt.size))):et=it.createElementNS(et,tt),et[Of]=o,et[Pf]=rt,zj(et,o,!1,!1),o.stateNode=et;e:{switch(it=vb(tt,rt),tt){case"dialog":D$1("cancel",et),D$1("close",et),nt=rt;break;case"iframe":case"object":case"embed":D$1("load",et),nt=rt;break;case"video":case"audio":for(nt=0;ntGj&&(o.flags|=128,rt=!0,Dj(ot,!1),o.lanes=4194304)}else{if(!rt)if(et=Ch(it),et!==null){if(o.flags|=128,rt=!0,tt=et.updateQueue,tt!==null&&(o.updateQueue=tt,o.flags|=4),Dj(ot,!0),ot.tail===null&&ot.tailMode==="hidden"&&!it.alternate&&!I$1)return S$1(o),null}else 2*B$1()-ot.renderingStartTime>Gj&&tt!==1073741824&&(o.flags|=128,rt=!0,Dj(ot,!1),o.lanes=4194304);ot.isBackwards?(it.sibling=o.child,o.child=it):(tt=ot.last,tt!==null?tt.sibling=it:o.child=it,ot.last=it)}return ot.tail!==null?(o=ot.tail,ot.rendering=o,ot.tail=o.sibling,ot.renderingStartTime=B$1(),o.sibling=null,tt=L$1.current,G$1(L$1,rt?tt&1|2:tt&1),o):(S$1(o),null);case 22:case 23:return Hj(),rt=o.memoizedState!==null,et!==null&&et.memoizedState!==null!==rt&&(o.flags|=8192),rt&&o.mode&1?fj&1073741824&&(S$1(o),o.subtreeFlags&6&&(o.flags|=8192)):S$1(o),null;case 24:return null;case 25:return null}throw Error(p$4(156,o.tag))}function Ij(et,o){switch(wg(o),o.tag){case 1:return Zf(o.type)&&$f(),et=o.flags,et&65536?(o.flags=et&-65537|128,o):null;case 3:return zh(),E$1(Wf),E$1(H$1),Eh(),et=o.flags,et&65536&&!(et&128)?(o.flags=et&-65537|128,o):null;case 5:return Bh(o),null;case 13:if(E$1(L$1),et=o.memoizedState,et!==null&&et.dehydrated!==null){if(o.alternate===null)throw Error(p$4(340));Ig()}return et=o.flags,et&65536?(o.flags=et&-65537|128,o):null;case 19:return E$1(L$1),null;case 4:return zh(),null;case 10:return ah(o.type._context),null;case 22:case 23:return Hj(),null;case 24:return null;default:return null}}var Jj=!1,U$1=!1,Kj=typeof WeakSet=="function"?WeakSet:Set,V$2=null;function Lj(et,o){var tt=et.ref;if(tt!==null)if(typeof tt=="function")try{tt(null)}catch(rt){W$1(et,o,rt)}else tt.current=null}function Mj(et,o,tt){try{tt()}catch(rt){W$1(et,o,rt)}}var Nj=!1;function Oj(et,o){if(Cf=dd,et=Me$1(),Ne$1(et)){if("selectionStart"in et)var tt={start:et.selectionStart,end:et.selectionEnd};else e:{tt=(tt=et.ownerDocument)&&tt.defaultView||window;var rt=tt.getSelection&&tt.getSelection();if(rt&&rt.rangeCount!==0){tt=rt.anchorNode;var nt=rt.anchorOffset,ot=rt.focusNode;rt=rt.focusOffset;try{tt.nodeType,ot.nodeType}catch{tt=null;break e}var it=0,st=-1,at=-1,ct=0,lt=0,dt=et,ht=null;t:for(;;){for(var mt;dt!==tt||nt!==0&&dt.nodeType!==3||(st=it+nt),dt!==ot||rt!==0&&dt.nodeType!==3||(at=it+rt),dt.nodeType===3&&(it+=dt.nodeValue.length),(mt=dt.firstChild)!==null;)ht=dt,dt=mt;for(;;){if(dt===et)break t;if(ht===tt&&++ct===nt&&(st=it),ht===ot&&++lt===rt&&(at=it),(mt=dt.nextSibling)!==null)break;dt=ht,ht=dt.parentNode}dt=mt}tt=st===-1||at===-1?null:{start:st,end:at}}else tt=null}tt=tt||{start:0,end:0}}else tt=null;for(Df={focusedElem:et,selectionRange:tt},dd=!1,V$2=o;V$2!==null;)if(o=V$2,et=o.child,(o.subtreeFlags&1028)!==0&&et!==null)et.return=o,V$2=et;else for(;V$2!==null;){o=V$2;try{var ft=o.alternate;if(o.flags&1024)switch(o.tag){case 0:case 11:case 15:break;case 1:if(ft!==null){var pt=ft.memoizedProps,yt=ft.memoizedState,gt=o.stateNode,bt=gt.getSnapshotBeforeUpdate(o.elementType===o.type?pt:Ci(o.type,pt),yt);gt.__reactInternalSnapshotBeforeUpdate=bt}break;case 3:var xt=o.stateNode.containerInfo;xt.nodeType===1?xt.textContent="":xt.nodeType===9&&xt.documentElement&&xt.removeChild(xt.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(p$4(163))}}catch(vt){W$1(o,o.return,vt)}if(et=o.sibling,et!==null){et.return=o.return,V$2=et;break}V$2=o.return}return ft=Nj,Nj=!1,ft}function Pj(et,o,tt){var rt=o.updateQueue;if(rt=rt!==null?rt.lastEffect:null,rt!==null){var nt=rt=rt.next;do{if((nt.tag&et)===et){var ot=nt.destroy;nt.destroy=void 0,ot!==void 0&&Mj(o,tt,ot)}nt=nt.next}while(nt!==rt)}}function Qj(et,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var tt=o=o.next;do{if((tt.tag&et)===et){var rt=tt.create;tt.destroy=rt()}tt=tt.next}while(tt!==o)}}function Rj(et){var o=et.ref;if(o!==null){var tt=et.stateNode;switch(et.tag){case 5:et=tt;break;default:et=tt}typeof o=="function"?o(et):o.current=et}}function Sj(et){var o=et.alternate;o!==null&&(et.alternate=null,Sj(o)),et.child=null,et.deletions=null,et.sibling=null,et.tag===5&&(o=et.stateNode,o!==null&&(delete o[Of],delete o[Pf],delete o[of],delete o[Qf],delete o[Rf])),et.stateNode=null,et.return=null,et.dependencies=null,et.memoizedProps=null,et.memoizedState=null,et.pendingProps=null,et.stateNode=null,et.updateQueue=null}function Tj(et){return et.tag===5||et.tag===3||et.tag===4}function Uj(et){e:for(;;){for(;et.sibling===null;){if(et.return===null||Tj(et.return))return null;et=et.return}for(et.sibling.return=et.return,et=et.sibling;et.tag!==5&&et.tag!==6&&et.tag!==18;){if(et.flags&2||et.child===null||et.tag===4)continue e;et.child.return=et,et=et.child}if(!(et.flags&2))return et.stateNode}}function Vj(et,o,tt){var rt=et.tag;if(rt===5||rt===6)et=et.stateNode,o?tt.nodeType===8?tt.parentNode.insertBefore(et,o):tt.insertBefore(et,o):(tt.nodeType===8?(o=tt.parentNode,o.insertBefore(et,tt)):(o=tt,o.appendChild(et)),tt=tt._reactRootContainer,tt!=null||o.onclick!==null||(o.onclick=Bf));else if(rt!==4&&(et=et.child,et!==null))for(Vj(et,o,tt),et=et.sibling;et!==null;)Vj(et,o,tt),et=et.sibling}function Wj(et,o,tt){var rt=et.tag;if(rt===5||rt===6)et=et.stateNode,o?tt.insertBefore(et,o):tt.appendChild(et);else if(rt!==4&&(et=et.child,et!==null))for(Wj(et,o,tt),et=et.sibling;et!==null;)Wj(et,o,tt),et=et.sibling}var X$1=null,Xj=!1;function Yj(et,o,tt){for(tt=tt.child;tt!==null;)Zj(et,o,tt),tt=tt.sibling}function Zj(et,o,tt){if(lc&&typeof lc.onCommitFiberUnmount=="function")try{lc.onCommitFiberUnmount(kc,tt)}catch{}switch(tt.tag){case 5:U$1||Lj(tt,o);case 6:var rt=X$1,nt=Xj;X$1=null,Yj(et,o,tt),X$1=rt,Xj=nt,X$1!==null&&(Xj?(et=X$1,tt=tt.stateNode,et.nodeType===8?et.parentNode.removeChild(tt):et.removeChild(tt)):X$1.removeChild(tt.stateNode));break;case 18:X$1!==null&&(Xj?(et=X$1,tt=tt.stateNode,et.nodeType===8?Kf(et.parentNode,tt):et.nodeType===1&&Kf(et,tt),bd(et)):Kf(X$1,tt.stateNode));break;case 4:rt=X$1,nt=Xj,X$1=tt.stateNode.containerInfo,Xj=!0,Yj(et,o,tt),X$1=rt,Xj=nt;break;case 0:case 11:case 14:case 15:if(!U$1&&(rt=tt.updateQueue,rt!==null&&(rt=rt.lastEffect,rt!==null))){nt=rt=rt.next;do{var ot=nt,it=ot.destroy;ot=ot.tag,it!==void 0&&(ot&2||ot&4)&&Mj(tt,o,it),nt=nt.next}while(nt!==rt)}Yj(et,o,tt);break;case 1:if(!U$1&&(Lj(tt,o),rt=tt.stateNode,typeof rt.componentWillUnmount=="function"))try{rt.props=tt.memoizedProps,rt.state=tt.memoizedState,rt.componentWillUnmount()}catch(st){W$1(tt,o,st)}Yj(et,o,tt);break;case 21:Yj(et,o,tt);break;case 22:tt.mode&1?(U$1=(rt=U$1)||tt.memoizedState!==null,Yj(et,o,tt),U$1=rt):Yj(et,o,tt);break;default:Yj(et,o,tt)}}function ak(et){var o=et.updateQueue;if(o!==null){et.updateQueue=null;var tt=et.stateNode;tt===null&&(tt=et.stateNode=new Kj),o.forEach(function(rt){var nt=bk.bind(null,et,rt);tt.has(rt)||(tt.add(rt),rt.then(nt,nt))})}}function ck(et,o){var tt=o.deletions;if(tt!==null)for(var rt=0;rtnt&&(nt=it),rt&=~ot}if(rt=nt,rt=B$1()-rt,rt=(120>rt?120:480>rt?480:1080>rt?1080:1920>rt?1920:3e3>rt?3e3:4320>rt?4320:1960*lk(rt/1960))-rt,10et?16:et,wk===null)var rt=!1;else{if(et=wk,wk=null,xk=0,K$1&6)throw Error(p$4(331));var nt=K$1;for(K$1|=4,V$2=et.current;V$2!==null;){var ot=V$2,it=ot.child;if(V$2.flags&16){var st=ot.deletions;if(st!==null){for(var at=0;atB$1()-fk?Kk(et,0):rk|=tt),Dk(et,o)}function Yk(et,o){o===0&&(et.mode&1?(o=sc,sc<<=1,!(sc&130023424)&&(sc=4194304)):o=1);var tt=R();et=ih(et,o),et!==null&&(Ac(et,o,tt),Dk(et,tt))}function uj(et){var o=et.memoizedState,tt=0;o!==null&&(tt=o.retryLane),Yk(et,tt)}function bk(et,o){var tt=0;switch(et.tag){case 13:var rt=et.stateNode,nt=et.memoizedState;nt!==null&&(tt=nt.retryLane);break;case 19:rt=et.stateNode;break;default:throw Error(p$4(314))}rt!==null&&rt.delete(o),Yk(et,tt)}var Vk;Vk=function(et,o,tt){if(et!==null)if(et.memoizedProps!==o.pendingProps||Wf.current)dh=!0;else{if(!(et.lanes&tt)&&!(o.flags&128))return dh=!1,yj(et,o,tt);dh=!!(et.flags&131072)}else dh=!1,I$1&&o.flags&1048576&&ug(o,ng,o.index);switch(o.lanes=0,o.tag){case 2:var rt=o.type;ij(et,o),et=o.pendingProps;var nt=Yf(o,H$1.current);ch(o,tt),nt=Nh(null,o,rt,et,nt,tt);var ot=Sh();return o.flags|=1,typeof nt=="object"&&nt!==null&&typeof nt.render=="function"&&nt.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,Zf(rt)?(ot=!0,cg(o)):ot=!1,o.memoizedState=nt.state!==null&&nt.state!==void 0?nt.state:null,kh(o),nt.updater=Ei,o.stateNode=nt,nt._reactInternals=o,Ii(o,rt,et,tt),o=jj(null,o,rt,!0,ot,tt)):(o.tag=0,I$1&&ot&&vg(o),Xi(null,o,nt,tt),o=o.child),o;case 16:rt=o.elementType;e:{switch(ij(et,o),et=o.pendingProps,nt=rt._init,rt=nt(rt._payload),o.type=rt,nt=o.tag=Zk(rt),et=Ci(rt,et),nt){case 0:o=cj(null,o,rt,et,tt);break e;case 1:o=hj(null,o,rt,et,tt);break e;case 11:o=Yi(null,o,rt,et,tt);break e;case 14:o=$i(null,o,rt,Ci(rt.type,et),tt);break e}throw Error(p$4(306,rt,""))}return o;case 0:return rt=o.type,nt=o.pendingProps,nt=o.elementType===rt?nt:Ci(rt,nt),cj(et,o,rt,nt,tt);case 1:return rt=o.type,nt=o.pendingProps,nt=o.elementType===rt?nt:Ci(rt,nt),hj(et,o,rt,nt,tt);case 3:e:{if(kj(o),et===null)throw Error(p$4(387));rt=o.pendingProps,ot=o.memoizedState,nt=ot.element,lh(et,o),qh(o,rt,null,tt);var it=o.memoizedState;if(rt=it.element,ot.isDehydrated)if(ot={element:rt,isDehydrated:!1,cache:it.cache,pendingSuspenseBoundaries:it.pendingSuspenseBoundaries,transitions:it.transitions},o.updateQueue.baseState=ot,o.memoizedState=ot,o.flags&256){nt=Ji(Error(p$4(423)),o),o=lj(et,o,rt,tt,nt);break e}else if(rt!==nt){nt=Ji(Error(p$4(424)),o),o=lj(et,o,rt,tt,nt);break e}else for(yg=Lf(o.stateNode.containerInfo.firstChild),xg=o,I$1=!0,zg=null,tt=Vg(o,null,rt,tt),o.child=tt;tt;)tt.flags=tt.flags&-3|4096,tt=tt.sibling;else{if(Ig(),rt===nt){o=Zi(et,o,tt);break e}Xi(et,o,rt,tt)}o=o.child}return o;case 5:return Ah(o),et===null&&Eg(o),rt=o.type,nt=o.pendingProps,ot=et!==null?et.memoizedProps:null,it=nt.children,Ef(rt,nt)?it=null:ot!==null&&Ef(rt,ot)&&(o.flags|=32),gj(et,o),Xi(et,o,it,tt),o.child;case 6:return et===null&&Eg(o),null;case 13:return oj(et,o,tt);case 4:return yh(o,o.stateNode.containerInfo),rt=o.pendingProps,et===null?o.child=Ug(o,null,rt,tt):Xi(et,o,rt,tt),o.child;case 11:return rt=o.type,nt=o.pendingProps,nt=o.elementType===rt?nt:Ci(rt,nt),Yi(et,o,rt,nt,tt);case 7:return Xi(et,o,o.pendingProps,tt),o.child;case 8:return Xi(et,o,o.pendingProps.children,tt),o.child;case 12:return Xi(et,o,o.pendingProps.children,tt),o.child;case 10:e:{if(rt=o.type._context,nt=o.pendingProps,ot=o.memoizedProps,it=nt.value,G$1(Wg,rt._currentValue),rt._currentValue=it,ot!==null)if(He(ot.value,it)){if(ot.children===nt.children&&!Wf.current){o=Zi(et,o,tt);break e}}else for(ot=o.child,ot!==null&&(ot.return=o);ot!==null;){var st=ot.dependencies;if(st!==null){it=ot.child;for(var at=st.firstContext;at!==null;){if(at.context===rt){if(ot.tag===1){at=mh(-1,tt&-tt),at.tag=2;var ct=ot.updateQueue;if(ct!==null){ct=ct.shared;var lt=ct.pending;lt===null?at.next=at:(at.next=lt.next,lt.next=at),ct.pending=at}}ot.lanes|=tt,at=ot.alternate,at!==null&&(at.lanes|=tt),bh(ot.return,tt,o),st.lanes|=tt;break}at=at.next}}else if(ot.tag===10)it=ot.type===o.type?null:ot.child;else if(ot.tag===18){if(it=ot.return,it===null)throw Error(p$4(341));it.lanes|=tt,st=it.alternate,st!==null&&(st.lanes|=tt),bh(it,tt,o),it=ot.sibling}else it=ot.child;if(it!==null)it.return=ot;else for(it=ot;it!==null;){if(it===o){it=null;break}if(ot=it.sibling,ot!==null){ot.return=it.return,it=ot;break}it=it.return}ot=it}Xi(et,o,nt.children,tt),o=o.child}return o;case 9:return nt=o.type,rt=o.pendingProps.children,ch(o,tt),nt=eh(nt),rt=rt(nt),o.flags|=1,Xi(et,o,rt,tt),o.child;case 14:return rt=o.type,nt=Ci(rt,o.pendingProps),nt=Ci(rt.type,nt),$i(et,o,rt,nt,tt);case 15:return bj(et,o,o.type,o.pendingProps,tt);case 17:return rt=o.type,nt=o.pendingProps,nt=o.elementType===rt?nt:Ci(rt,nt),ij(et,o),o.tag=1,Zf(rt)?(et=!0,cg(o)):et=!1,ch(o,tt),Gi(o,rt,nt),Ii(o,rt,nt,tt),jj(null,o,rt,!0,et,tt);case 19:return xj(et,o,tt);case 22:return dj(et,o,tt)}throw Error(p$4(156,o.tag))};function Fk(et,o){return ac(et,o)}function $k(et,o,tt,rt){this.tag=et,this.key=tt,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=rt,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bg(et,o,tt,rt){return new $k(et,o,tt,rt)}function aj(et){return et=et.prototype,!(!et||!et.isReactComponent)}function Zk(et){if(typeof et=="function")return aj(et)?1:0;if(et!=null){if(et=et.$$typeof,et===Da)return 11;if(et===Ga)return 14}return 2}function Pg(et,o){var tt=et.alternate;return tt===null?(tt=Bg(et.tag,o,et.key,et.mode),tt.elementType=et.elementType,tt.type=et.type,tt.stateNode=et.stateNode,tt.alternate=et,et.alternate=tt):(tt.pendingProps=o,tt.type=et.type,tt.flags=0,tt.subtreeFlags=0,tt.deletions=null),tt.flags=et.flags&14680064,tt.childLanes=et.childLanes,tt.lanes=et.lanes,tt.child=et.child,tt.memoizedProps=et.memoizedProps,tt.memoizedState=et.memoizedState,tt.updateQueue=et.updateQueue,o=et.dependencies,tt.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},tt.sibling=et.sibling,tt.index=et.index,tt.ref=et.ref,tt}function Rg(et,o,tt,rt,nt,ot){var it=2;if(rt=et,typeof et=="function")aj(et)&&(it=1);else if(typeof et=="string")it=5;else e:switch(et){case ya:return Tg(tt.children,nt,ot,o);case za:it=8,nt|=8;break;case Aa:return et=Bg(12,tt,o,nt|2),et.elementType=Aa,et.lanes=ot,et;case Ea:return et=Bg(13,tt,o,nt),et.elementType=Ea,et.lanes=ot,et;case Fa:return et=Bg(19,tt,o,nt),et.elementType=Fa,et.lanes=ot,et;case Ia:return pj(tt,nt,ot,o);default:if(typeof et=="object"&&et!==null)switch(et.$$typeof){case Ba:it=10;break e;case Ca:it=9;break e;case Da:it=11;break e;case Ga:it=14;break e;case Ha:it=16,rt=null;break e}throw Error(p$4(130,et==null?et:typeof et,""))}return o=Bg(it,tt,o,nt),o.elementType=et,o.type=rt,o.lanes=ot,o}function Tg(et,o,tt,rt){return et=Bg(7,et,rt,o),et.lanes=tt,et}function pj(et,o,tt,rt){return et=Bg(22,et,rt,o),et.elementType=Ia,et.lanes=tt,et.stateNode={isHidden:!1},et}function Qg(et,o,tt){return et=Bg(6,et,null,o),et.lanes=tt,et}function Sg(et,o,tt){return o=Bg(4,et.children!==null?et.children:[],et.key,o),o.lanes=tt,o.stateNode={containerInfo:et.containerInfo,pendingChildren:null,implementation:et.implementation},o}function al(et,o,tt,rt,nt){this.tag=o,this.containerInfo=et,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zc(0),this.expirationTimes=zc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zc(0),this.identifierPrefix=rt,this.onRecoverableError=nt,this.mutableSourceEagerHydrationData=null}function bl(et,o,tt,rt,nt,ot,it,st,at){return et=new al(et,o,tt,st,at),o===1?(o=1,ot===!0&&(o|=8)):o=0,ot=Bg(3,null,null,o),et.current=ot,ot.stateNode=et,ot.memoizedState={element:rt,isDehydrated:tt,cache:null,transitions:null,pendingSuspenseBoundaries:null},kh(ot),et}function cl(et,o,tt){var rt=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE)}catch(et){console.error(et)}}checkDCE(),reactDom.exports=reactDom_production_min;var reactDomExports=reactDom.exports;const ReactDOM=getDefaultExportFromCjs(reactDomExports);var createRoot,m$5=reactDomExports;createRoot=m$5.createRoot,m$5.hydrateRoot;const version$8="2.21.28";let errorConfig={getDocsUrl:({docsBaseUrl:et,docsPath:o="",docsSlug:tt})=>o?`${et??"https://viem.sh"}${o}${tt?`#${tt}`:""}`:void 0,version:version$8},BaseError$3=class ks extends Error{constructor(o,tt={}){var st;const rt=(()=>{var at;return tt.cause instanceof ks?tt.cause.details:(at=tt.cause)!=null&&at.message?tt.cause.message:tt.details})(),nt=tt.cause instanceof ks&&tt.cause.docsPath||tt.docsPath,ot=(st=errorConfig.getDocsUrl)==null?void 0:st.call(errorConfig,{...tt,docsPath:nt}),it=[o||"An error occurred.","",...tt.metaMessages?[...tt.metaMessages,""]:[],...ot?[`Docs: ${ot}`]:[],...rt?[`Details: ${rt}`]:[],`Version: ${errorConfig.version}`].join(` `);super(it,tt.cause?{cause:tt.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=rt,this.docsPath=nt,this.metaMessages=tt.metaMessages,this.name=tt.name??this.name,this.shortMessage=o,this.version=version$8}walk(o){return walk(this,o)}};function walk(et,o){return o!=null&&o(et)?et:et&&typeof et=="object"&&"cause"in et?walk(et.cause,o):o?null:et}class IntegerOutOfRangeError extends BaseError$3{constructor({max:o,min:tt,signed:rt,size:nt,value:ot}){super(`Number "${ot}" is not in safe ${nt?`${nt*8}-bit ${rt?"signed":"unsigned"} `:""}integer range ${o?`(${tt} to ${o})`:`(above ${tt})`}`,{name:"IntegerOutOfRangeError"})}}class InvalidBytesBooleanError extends BaseError$3{constructor(o){super(`Bytes value "${o}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class SizeOverflowError extends BaseError$3{constructor({givenSize:o,maxSize:tt}){super(`Size cannot exceed ${tt} bytes. Given size: ${o} bytes.`,{name:"SizeOverflowError"})}}class SliceOffsetOutOfBoundsError extends BaseError$3{constructor({offset:o,position:tt,size:rt}){super(`Slice ${tt==="start"?"starting":"ending"} at offset "${o}" is out-of-bounds (size: ${rt}).`,{name:"SliceOffsetOutOfBoundsError"})}}class SizeExceedsPaddingSizeError extends BaseError$3{constructor({size:o,targetSize:tt,type:rt}){super(`${rt.charAt(0).toUpperCase()}${rt.slice(1).toLowerCase()} size (${o}) exceeds padding size (${tt}).`,{name:"SizeExceedsPaddingSizeError"})}}class InvalidBytesLengthError extends BaseError$3{constructor({size:o,targetSize:tt,type:rt}){super(`${rt.charAt(0).toUpperCase()}${rt.slice(1).toLowerCase()} is expected to be ${tt} ${rt} long, but is ${o} ${rt} long.`,{name:"InvalidBytesLengthError"})}}function pad(et,{dir:o,size:tt=32}={}){return typeof et=="string"?padHex(et,{dir:o,size:tt}):padBytes(et,{dir:o,size:tt})}function padHex(et,{dir:o,size:tt=32}={}){if(tt===null)return et;const rt=et.replace("0x","");if(rt.length>tt*2)throw new SizeExceedsPaddingSizeError({size:Math.ceil(rt.length/2),targetSize:tt,type:"hex"});return`0x${rt[o==="right"?"padEnd":"padStart"](tt*2,"0")}`}function padBytes(et,{dir:o,size:tt=32}={}){if(tt===null)return et;if(et.length>tt)throw new SizeExceedsPaddingSizeError({size:et.length,targetSize:tt,type:"bytes"});const rt=new Uint8Array(tt);for(let nt=0;nt=charCodeMap.zero&&et<=charCodeMap.nine)return et-charCodeMap.zero;if(et>=charCodeMap.A&&et<=charCodeMap.F)return et-(charCodeMap.A-10);if(et>=charCodeMap.a&&et<=charCodeMap.f)return et-(charCodeMap.a-10)}function hexToBytes$3(et,o={}){let tt=et;o.size&&(assertSize(tt,{size:o.size}),tt=pad(tt,{dir:"right",size:o.size}));let rt=tt.slice(2);rt.length%2&&(rt=`0${rt}`);const nt=rt.length/2,ot=new Uint8Array(nt);for(let it=0,st=0;ito)throw new SizeOverflowError({givenSize:size$2(et),maxSize:o})}function hexToBigInt(et,o={}){const{signed:tt}=o;o.size&&assertSize(et,{size:o.size});const rt=BigInt(et);if(!tt)return rt;const nt=(et.length-2)/2,ot=(1n<o.toString(16).padStart(2,"0"));function toHex(et,o={}){return typeof et=="number"||typeof et=="bigint"?numberToHex(et,o):typeof et=="string"?stringToHex(et,o):typeof et=="boolean"?boolToHex(et,o):bytesToHex$3(et,o)}function boolToHex(et,o={}){const tt=`0x${Number(et)}`;return typeof o.size=="number"?(assertSize(tt,{size:o.size}),pad(tt,{size:o.size})):tt}function bytesToHex$3(et,o={}){let tt="";for(let nt=0;ntot||ntformatAbiParam(tt,{includeName:o})).join(o?", ":","):""}function formatAbiParam(et,{includeName:o}){return et.type.startsWith("tuple")?`(${formatAbiParams(et.components,{includeName:o})})${et.type.slice(5)}`:et.type+(o&&et.name?` ${et.name}`:"")}class AbiConstructorNotFoundError extends BaseError$3{constructor({docsPath:o}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join(` `),{docsPath:o,name:"AbiConstructorNotFoundError"})}}class AbiConstructorParamsNotFoundError extends BaseError$3{constructor({docsPath:o}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join(` `),{docsPath:o,name:"AbiConstructorParamsNotFoundError"})}}class AbiDecodingDataSizeTooSmallError extends BaseError$3{constructor({data:o,params:tt,size:rt}){super([`Data size of ${rt} bytes is too small for given parameters.`].join(` @@ -52,7 +57,7 @@ Error generating stack: `+ot.message+` `),{docsPath:tt,name:"InvalidAbiDecodingType"})}}class InvalidArrayError extends BaseError$3{constructor(o){super([`Value "${o}" is not a valid array.`].join(` `),{name:"InvalidArrayError"})}}class InvalidDefinitionTypeError extends BaseError$3{constructor(o){super([`"${o}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(` `),{name:"InvalidDefinitionTypeError"})}}function concat$6(et){return typeof et[0]=="string"?concatHex(et):concatBytes$3(et)}function concatBytes$3(et){let o=0;for(const nt of et)o+=nt.length;const tt=new Uint8Array(o);let rt=0;for(const nt of et)tt.set(nt,rt),rt+=nt.length;return tt}function concatHex(et){return`0x${et.reduce((o,tt)=>o+tt.replace("0x",""),"")}`}class InvalidAddressError extends BaseError$3{constructor({address:o}){super(`Address "${o}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class LruMap extends Map{constructor(o){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=o}get(o){const tt=super.get(o);return super.has(o)&&tt!==void 0&&(this.delete(o),super.set(o,tt)),tt}set(o,tt){if(super.set(o,tt),this.maxSize&&this.size>this.maxSize){const rt=this.keys().next().value;rt&&this.delete(rt)}return this}}function number$4(et){if(!Number.isSafeInteger(et)||et<0)throw new Error(`positive integer expected, not ${et}`)}function isBytes$3(et){return et instanceof Uint8Array||et!=null&&typeof et=="object"&&et.constructor.name==="Uint8Array"}function bytes$1(et,...o){if(!isBytes$3(et))throw new Error("Uint8Array expected");if(o.length>0&&!o.includes(et.length))throw new Error(`Uint8Array expected of length ${o}, not of length=${et.length}`)}function hash$1(et){if(typeof et!="function"||typeof et.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");number$4(et.outputLen),number$4(et.blockLen)}function exists$1(et,o=!0){if(et.destroyed)throw new Error("Hash instance has been destroyed");if(o&&et.finished)throw new Error("Hash#digest() has already been called")}function output$1(et,o){bytes$1(et);const tt=o.outputLen;if(et.length>_32n&U32_MASK64)}:{h:Number(et>>_32n&U32_MASK64)|0,l:Number(et&U32_MASK64)|0}}function split$1(et,o=!1){let tt=new Uint32Array(et.length),rt=new Uint32Array(et.length);for(let nt=0;ntBigInt(et>>>0)<<_32n|BigInt(o>>>0),shrSH=(et,o,tt)=>et>>>tt,shrSL=(et,o,tt)=>et<<32-tt|o>>>tt,rotrSH=(et,o,tt)=>et>>>tt|o<<32-tt,rotrSL=(et,o,tt)=>et<<32-tt|o>>>tt,rotrBH=(et,o,tt)=>et<<64-tt|o>>>tt-32,rotrBL=(et,o,tt)=>et>>>tt-32|o<<64-tt,rotr32H=(et,o)=>o,rotr32L=(et,o)=>et,rotlSH=(et,o,tt)=>et<>>32-tt,rotlSL=(et,o,tt)=>o<>>32-tt,rotlBH=(et,o,tt)=>o<>>64-tt,rotlBL=(et,o,tt)=>et<>>64-tt;function add(et,o,tt,rt){const nt=(o>>>0)+(rt>>>0);return{h:et+tt+(nt/2**32|0)|0,l:nt|0}}const add3L=(et,o,tt)=>(et>>>0)+(o>>>0)+(tt>>>0),add3H=(et,o,tt,rt)=>o+tt+rt+(et/2**32|0)|0,add4L=(et,o,tt,rt)=>(et>>>0)+(o>>>0)+(tt>>>0)+(rt>>>0),add4H=(et,o,tt,rt,nt)=>o+tt+rt+nt+(et/2**32|0)|0,add5L=(et,o,tt,rt,nt)=>(et>>>0)+(o>>>0)+(tt>>>0)+(rt>>>0)+(nt>>>0),add5H=(et,o,tt,rt,nt,ot)=>o+tt+rt+nt+ot+(et/2**32|0)|0,u64={fromBig,split:split$1,toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L},crypto$2=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const u32$1=et=>new Uint32Array(et.buffer,et.byteOffset,Math.floor(et.byteLength/4)),createView$1=et=>new DataView(et.buffer,et.byteOffset,et.byteLength),rotr=(et,o)=>et<<32-o|et>>>o,isLE$1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,byteSwap=et=>et<<24&4278190080|et<<8&16711680|et>>>8&65280|et>>>24&255;function byteSwap32(et){for(let o=0;oet().update(toBytes$2(rt)).digest(),tt=et();return o.outputLen=tt.outputLen,o.blockLen=tt.blockLen,o.create=()=>et(),o}function randomBytes$1(et=32){if(crypto$2&&typeof crypto$2.getRandomValues=="function")return crypto$2.getRandomValues(new Uint8Array(et));if(crypto$2&&typeof crypto$2.randomBytes=="function")return crypto$2.randomBytes(et);throw new Error("crypto.getRandomValues must be defined")}const SHA3_PI=[],SHA3_ROTL=[],_SHA3_IOTA=[],_0n$7=BigInt(0),_1n$9=BigInt(1),_2n$6=BigInt(2),_7n=BigInt(7),_256n=BigInt(256),_0x71n=BigInt(113);for(let et=0,o=_1n$9,tt=1,rt=0;et<24;et++){[tt,rt]=[rt,(2*tt+3*rt)%5],SHA3_PI.push(2*(5*rt+tt)),SHA3_ROTL.push((et+1)*(et+2)/2%64);let nt=_0n$7;for(let ot=0;ot<7;ot++)o=(o<<_1n$9^(o>>_7n)*_0x71n)%_256n,o&_2n$6&&(nt^=_1n$9<<(_1n$9<tt>32?rotlBH(et,o,tt):rotlSH(et,o,tt),rotlL=(et,o,tt)=>tt>32?rotlBL(et,o,tt):rotlSL(et,o,tt);function keccakP(et,o=24){const tt=new Uint32Array(10);for(let rt=24-o;rt<24;rt++){for(let it=0;it<10;it++)tt[it]=et[it]^et[it+10]^et[it+20]^et[it+30]^et[it+40];for(let it=0;it<10;it+=2){const st=(it+8)%10,at=(it+2)%10,ct=tt[at],lt=tt[at+1],dt=rotlH(ct,lt,1)^tt[st],ht=rotlL(ct,lt,1)^tt[st+1];for(let mt=0;mt<50;mt+=10)et[it+mt]^=dt,et[it+mt+1]^=ht}let nt=et[2],ot=et[3];for(let it=0;it<24;it++){const st=SHA3_ROTL[it],at=rotlH(nt,ot,st),ct=rotlL(nt,ot,st),lt=SHA3_PI[it];nt=et[lt],ot=et[lt+1],et[lt]=at,et[lt+1]=ct}for(let it=0;it<50;it+=10){for(let st=0;st<10;st++)tt[st]=et[it+st];for(let st=0;st<10;st++)et[it+st]^=~tt[(st+2)%10]&tt[(st+4)%10]}et[0]^=SHA3_IOTA_H[rt],et[1]^=SHA3_IOTA_L[rt]}tt.fill(0)}class Keccak extends Hash{constructor(o,tt,rt,nt=!1,ot=24){if(super(),this.blockLen=o,this.suffix=tt,this.outputLen=rt,this.enableXOF=nt,this.rounds=ot,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,number$4(rt),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=u32$1(this.state)}keccak(){isLE$1||byteSwap32(this.state32),keccakP(this.state32,this.rounds),isLE$1||byteSwap32(this.state32),this.posOut=0,this.pos=0}update(o){exists$1(this);const{blockLen:tt,state:rt}=this;o=toBytes$2(o);const nt=o.length;for(let ot=0;ot=rt&&this.keccak();const it=Math.min(rt-this.posOut,ot-nt);o.set(tt.subarray(this.posOut,this.posOut+it),nt),this.posOut+=it,nt+=it}return o}xofInto(o){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(o)}xof(o){return number$4(o),this.xofInto(new Uint8Array(o))}digestInto(o){if(output$1(o,this),this.finished)throw new 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){const{blockLen:tt,suffix:rt,outputLen:nt,rounds:ot,enableXOF:it}=this;return o||(o=new Keccak(tt,rt,nt,it,ot)),o.state32.set(this.state32),o.pos=this.pos,o.posOut=this.posOut,o.finished=this.finished,o.rounds=ot,o.suffix=rt,o.outputLen=nt,o.enableXOF=it,o.destroyed=this.destroyed,o}}const gen=(et,o,tt)=>wrapConstructor(()=>new Keccak(o,et,tt)),keccak_256=gen(1,136,256/8);function keccak256$1(et,o){const tt=o||"hex",rt=keccak_256(isHex(et,{strict:!1})?toBytes$3(et):et);return tt==="bytes"?rt:toHex(rt)}const checksumAddressCache=new LruMap(8192);function checksumAddress(et,o){if(checksumAddressCache.has(`${et}.${o}`))return checksumAddressCache.get(`${et}.${o}`);const tt=o?`${o}${et.toLowerCase()}`:et.substring(2).toLowerCase(),rt=keccak256$1(stringToBytes(tt),"bytes"),nt=(o?tt.substring(`${o}0x`.length):tt).split("");for(let it=0;it<40;it+=2)rt[it>>1]>>4>=8&&nt[it]&&(nt[it]=nt[it].toUpperCase()),(rt[it>>1]&15)>=8&&nt[it+1]&&(nt[it+1]=nt[it+1].toUpperCase());const ot=`0x${nt.join("")}`;return checksumAddressCache.set(`${et}.${o}`,ot),ot}function getAddress(et,o){if(!isAddress(et,{strict:!1}))throw new InvalidAddressError({address:et});return checksumAddress(et,o)}const addressRegex=/^0x[a-fA-F0-9]{40}$/,isAddressCache=new LruMap(8192);function isAddress(et,o){const{strict:tt=!0}=o??{},rt=`${et}.${tt}`;if(isAddressCache.has(rt))return isAddressCache.get(rt);const nt=addressRegex.test(et)?et.toLowerCase()===et?!0:tt?checksumAddress(et)===et:!0:!1;return isAddressCache.set(rt,nt),nt}function slice(et,o,tt,{strict:rt}={}){return isHex(et,{strict:!1})?sliceHex(et,o,tt,{strict:rt}):sliceBytes(et,o,tt,{strict:rt})}function assertStartOffset(et,o){if(typeof o=="number"&&o>0&&o>size$2(et)-1)throw new SliceOffsetOutOfBoundsError({offset:o,position:"start",size:size$2(et)})}function assertEndOffset(et,o,tt){if(typeof o=="number"&&typeof tt=="number"&&size$2(et)!==tt-o)throw new SliceOffsetOutOfBoundsError({offset:tt,position:"end",size:size$2(et)})}function sliceBytes(et,o,tt,{strict:rt}={}){assertStartOffset(et,o);const nt=et.slice(o,tt);return rt&&assertEndOffset(nt,o,tt),nt}function sliceHex(et,o,tt,{strict:rt}={}){assertStartOffset(et,o);const nt=`0x${et.replace("0x","").slice((o??0)*2,(tt??et.length)*2)}`;return rt&&assertEndOffset(nt,o,tt),nt}function encodeAbiParameters(et,o){if(et.length!==o.length)throw new AbiEncodingLengthMismatchError({expectedLength:et.length,givenLength:o.length});const tt=prepareParams({params:et,values:o}),rt=encodeParams(tt);return rt.length===0?"0x":rt}function prepareParams({params:et,values:o}){const tt=[];for(let rt=0;rt0?concat$6([st,it]):st}}if(nt)return{dynamic:!0,encoded:it}}return{dynamic:!1,encoded:concat$6(ot.map(({encoded:it})=>it))}}function encodeBytes(et,{param:o}){const[,tt]=o.type.split("bytes"),rt=size$2(et);if(!tt){let nt=et;return rt%32!==0&&(nt=padHex(nt,{dir:"right",size:Math.ceil((et.length-2)/2/32)*32})),{dynamic:!0,encoded:concat$6([padHex(numberToHex(rt,{size:32})),nt])}}if(rt!==Number.parseInt(tt))throw new AbiEncodingBytesSizeMismatchError({expectedSize:Number.parseInt(tt),value:et});return{dynamic:!1,encoded:padHex(et,{dir:"right"})}}function encodeBool(et){if(typeof et!="boolean")throw new BaseError$3(`Invalid boolean value: "${et}" (type: ${typeof et}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:padHex(boolToHex(et))}}function encodeNumber(et,{signed:o}){return{dynamic:!1,encoded:numberToHex(et,{size:32,signed:o})}}function encodeString(et){const o=stringToHex(et),tt=Math.ceil(size$2(o)/32),rt=[];for(let nt=0;ntnt))}}function getArrayComponents(et){const o=et.match(/^(.*)\[(\d+)?\]$/);return o?[o[2]?Number(o[2]):null,o[1]]:void 0}const docsPath$2="/docs/contract/encodeDeployData";function encodeDeployData(et){const{abi:o,args:tt,bytecode:rt}=et;if(!tt||tt.length===0)return rt;const nt=o.find(it=>"type"in it&&it.type==="constructor");if(!nt)throw new AbiConstructorNotFoundError({docsPath:docsPath$2});if(!("inputs"in nt))throw new AbiConstructorParamsNotFoundError({docsPath:docsPath$2});if(!nt.inputs||nt.inputs.length===0)throw new AbiConstructorParamsNotFoundError({docsPath:docsPath$2});const ot=encodeAbiParameters(nt.inputs,tt);return concatHex([rt,ot])}function parseAccount(et){return typeof et=="string"?{address:et,type:"json-rpc"}:et}class AccountNotFoundError extends BaseError$3{constructor({docsPath:o}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(` -`),{docsPath:o,docsSlug:"account",name:"AccountNotFoundError"})}}const scriptRel="modulepreload",assetsURL=function(et){return"/buddybook/"+et},seen={},__vitePreload=function(o,tt,rt){let nt=Promise.resolve();if(tt&&tt.length>0){document.getElementsByTagName("link");const it=document.querySelector("meta[property=csp-nonce]"),st=(it==null?void 0:it.nonce)||(it==null?void 0:it.getAttribute("nonce"));nt=Promise.allSettled(tt.map(at=>{if(at=assetsURL(at),at in seen)return;seen[at]=!0;const ct=at.endsWith(".css"),lt=ct?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${at}"]${lt}`))return;const dt=document.createElement("link");if(dt.rel=ct?"stylesheet":scriptRel,ct||(dt.as="script"),dt.crossOrigin="",dt.href=at,st&&dt.setAttribute("nonce",st),document.head.appendChild(dt),ct)return new Promise((ht,mt)=>{dt.addEventListener("load",ht),dt.addEventListener("error",()=>mt(new Error(`Unable to preload CSS for ${at}`)))})}))}function ot(it){const st=new Event("vite:preloadError",{cancelable:!0});if(st.payload=it,window.dispatchEvent(st),!st.defaultPrevented)throw it}return nt.then(it=>{for(const st of it||[])st.status==="rejected"&&ot(st.reason);return o().catch(ot)})};class NegativeOffsetError extends BaseError$3{constructor({offset:o}){super(`Offset \`${o}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class PositionOutOfBoundsError extends BaseError$3{constructor({length:o,position:tt}){super(`Position \`${tt}\` is out of bounds (\`0 < position < ${o}\`).`,{name:"PositionOutOfBoundsError"})}}class RecursiveReadLimitExceededError extends BaseError$3{constructor({count:o,limit:tt}){super(`Recursive read limit of \`${tt}\` exceeded (recursive read count: \`${o}\`).`,{name:"RecursiveReadLimitExceededError"})}}const staticCursor={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new RecursiveReadLimitExceededError({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(et){if(et<0||et>this.bytes.length-1)throw new PositionOutOfBoundsError({length:this.bytes.length,position:et})},decrementPosition(et){if(et<0)throw new NegativeOffsetError({offset:et});const o=this.position-et;this.assertPosition(o),this.position=o},getReadCount(et){return this.positionReadCount.get(et||this.position)||0},incrementPosition(et){if(et<0)throw new NegativeOffsetError({offset:et});const o=this.position+et;this.assertPosition(o),this.position=o},inspectByte(et){const o=et??this.position;return this.assertPosition(o),this.bytes[o]},inspectBytes(et,o){const tt=o??this.position;return this.assertPosition(tt+et-1),this.bytes.subarray(tt,tt+et)},inspectUint8(et){const o=et??this.position;return this.assertPosition(o),this.bytes[o]},inspectUint16(et){const o=et??this.position;return this.assertPosition(o+1),this.dataView.getUint16(o)},inspectUint24(et){const o=et??this.position;return this.assertPosition(o+2),(this.dataView.getUint16(o)<<8)+this.dataView.getUint8(o+2)},inspectUint32(et){const o=et??this.position;return this.assertPosition(o+3),this.dataView.getUint32(o)},pushByte(et){this.assertPosition(this.position),this.bytes[this.position]=et,this.position++},pushBytes(et){this.assertPosition(this.position+et.length-1),this.bytes.set(et,this.position),this.position+=et.length},pushUint8(et){this.assertPosition(this.position),this.bytes[this.position]=et,this.position++},pushUint16(et){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,et),this.position+=2},pushUint24(et){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,et>>8),this.dataView.setUint8(this.position+2,et&255),this.position+=3},pushUint32(et){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,et),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const et=this.inspectByte();return this.position++,et},readBytes(et,o){this.assertReadLimit(),this._touch();const tt=this.inspectBytes(et);return this.position+=o??et,tt},readUint8(){this.assertReadLimit(),this._touch();const et=this.inspectUint8();return this.position+=1,et},readUint16(){this.assertReadLimit(),this._touch();const et=this.inspectUint16();return this.position+=2,et},readUint24(){this.assertReadLimit(),this._touch();const et=this.inspectUint24();return this.position+=3,et},readUint32(){this.assertReadLimit(),this._touch();const et=this.inspectUint32();return this.position+=4,et},get remaining(){return this.bytes.length-this.position},setPosition(et){const o=this.position;return this.assertPosition(et),this.position=et,()=>this.position=o},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const et=this.getReadCount();this.positionReadCount.set(this.position,et+1),et>0&&this.recursiveReadCount++}};function createCursor(et,{recursiveReadLimit:o=8192}={}){const tt=Object.create(staticCursor);return tt.bytes=et,tt.dataView=new DataView(et.buffer,et.byteOffset,et.byteLength),tt.positionReadCount=new Map,tt.recursiveReadLimit=o,tt}function toRlp(et,o="hex"){const tt=getEncodable(et),rt=createCursor(new Uint8Array(tt.length));return tt.encode(rt),o==="hex"?bytesToHex$3(rt.bytes):rt.bytes}function getEncodable(et){return Array.isArray(et)?getEncodableList(et.map(o=>getEncodable(o))):getEncodableBytes(et)}function getEncodableList(et){const o=et.reduce((nt,ot)=>nt+ot.length,0),tt=getSizeOfLength(o);return{length:o<=55?1+o:1+tt+o,encode(nt){o<=55?nt.pushByte(192+o):(nt.pushByte(247+tt),tt===1?nt.pushUint8(o):tt===2?nt.pushUint16(o):tt===3?nt.pushUint24(o):nt.pushUint32(o));for(const{encode:ot}of et)ot(nt)}}}function getEncodableBytes(et){const o=typeof et=="string"?hexToBytes$3(et):et,tt=getSizeOfLength(o.length);return{length:o.length===1&&o[0]<128?1:o.length<=55?1+o.length:1+tt+o.length,encode(nt){o.length===1&&o[0]<128?nt.pushBytes(o):o.length<=55?(nt.pushByte(128+o.length),nt.pushBytes(o)):(nt.pushByte(183+tt),tt===1?nt.pushUint8(o.length):tt===2?nt.pushUint16(o.length):tt===3?nt.pushUint24(o.length):nt.pushUint32(o.length),nt.pushBytes(o))}}}function getSizeOfLength(et){if(et<2**8)return 1;if(et<2**16)return 2;if(et<2**24)return 3;if(et<2**32)return 4;throw new BaseError$3("Length is too large.")}class ChainDoesNotSupportContract extends BaseError$3{constructor({blockNumber:o,chain:tt,contract:rt}){super(`Chain "${tt.name}" does not support contract "${rt.name}".`,{metaMessages:["This could be due to any of the following:",...o&&rt.blockCreated&&rt.blockCreated>o?[`- The contract "${rt.name}" was not deployed until block ${rt.blockCreated} (current block ${o}).`]:[`- The chain does not have the contract "${rt.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class ClientChainNotConfiguredError extends BaseError$3{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class InvalidChainIdError extends BaseError$3{constructor({chainId:o}){super(typeof o=="number"?`Chain ID "${o}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const etherUnits={gwei:9,wei:18},gweiUnits={ether:-9,wei:9},weiUnits={ether:-18,gwei:-9};function formatUnits(et,o){let tt=et.toString();const rt=tt.startsWith("-");rt&&(tt=tt.slice(1)),tt=tt.padStart(o,"0");let[nt,ot]=[tt.slice(0,tt.length-o),tt.slice(tt.length-o)];return ot=ot.replace(/(0+)$/,""),`${rt?"-":""}${nt||"0"}${ot?`.${ot}`:""}`}function formatGwei(et,o="wei"){return formatUnits(et,gweiUnits[o])}class ExecutionRevertedError extends BaseError$3{constructor({cause:o,message:tt}={}){var nt;const rt=(nt=tt==null?void 0:tt.replace("execution reverted: ",""))==null?void 0:nt.replace("execution reverted","");super(`Execution reverted ${rt?`with reason: ${rt}`:"for an unknown reason"}.`,{cause:o,name:"ExecutionRevertedError"})}}Object.defineProperty(ExecutionRevertedError,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(ExecutionRevertedError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class FeeCapTooHighError extends BaseError$3{constructor({cause:o,maxFeePerGas:tt}={}){super(`The fee cap (\`maxFeePerGas\`${tt?` = ${formatGwei(tt)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:o,name:"FeeCapTooHighError"})}}Object.defineProperty(FeeCapTooHighError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class FeeCapTooLowError extends BaseError$3{constructor({cause:o,maxFeePerGas:tt}={}){super(`The fee cap (\`maxFeePerGas\`${tt?` = ${formatGwei(tt)}`:""} gwei) cannot be lower than the block base fee.`,{cause:o,name:"FeeCapTooLowError"})}}Object.defineProperty(FeeCapTooLowError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class NonceTooHighError extends BaseError$3{constructor({cause:o,nonce:tt}={}){super(`Nonce provided for the transaction ${tt?`(${tt}) `:""}is higher than the next one expected.`,{cause:o,name:"NonceTooHighError"})}}Object.defineProperty(NonceTooHighError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class NonceTooLowError extends BaseError$3{constructor({cause:o,nonce:tt}={}){super([`Nonce provided for the transaction ${tt?`(${tt}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(` +`),{docsPath:o,docsSlug:"account",name:"AccountNotFoundError"})}}const scriptRel="modulepreload",assetsURL=function(et){return"/"+et},seen={},__vitePreload=function(o,tt,rt){let nt=Promise.resolve();if(tt&&tt.length>0){document.getElementsByTagName("link");const it=document.querySelector("meta[property=csp-nonce]"),st=(it==null?void 0:it.nonce)||(it==null?void 0:it.getAttribute("nonce"));nt=Promise.allSettled(tt.map(at=>{if(at=assetsURL(at),at in seen)return;seen[at]=!0;const ct=at.endsWith(".css"),lt=ct?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${at}"]${lt}`))return;const dt=document.createElement("link");if(dt.rel=ct?"stylesheet":scriptRel,ct||(dt.as="script"),dt.crossOrigin="",dt.href=at,st&&dt.setAttribute("nonce",st),document.head.appendChild(dt),ct)return new Promise((ht,mt)=>{dt.addEventListener("load",ht),dt.addEventListener("error",()=>mt(new Error(`Unable to preload CSS for ${at}`)))})}))}function ot(it){const st=new Event("vite:preloadError",{cancelable:!0});if(st.payload=it,window.dispatchEvent(st),!st.defaultPrevented)throw it}return nt.then(it=>{for(const st of it||[])st.status==="rejected"&&ot(st.reason);return o().catch(ot)})};class NegativeOffsetError extends BaseError$3{constructor({offset:o}){super(`Offset \`${o}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class PositionOutOfBoundsError extends BaseError$3{constructor({length:o,position:tt}){super(`Position \`${tt}\` is out of bounds (\`0 < position < ${o}\`).`,{name:"PositionOutOfBoundsError"})}}class RecursiveReadLimitExceededError extends BaseError$3{constructor({count:o,limit:tt}){super(`Recursive read limit of \`${tt}\` exceeded (recursive read count: \`${o}\`).`,{name:"RecursiveReadLimitExceededError"})}}const staticCursor={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new RecursiveReadLimitExceededError({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(et){if(et<0||et>this.bytes.length-1)throw new PositionOutOfBoundsError({length:this.bytes.length,position:et})},decrementPosition(et){if(et<0)throw new NegativeOffsetError({offset:et});const o=this.position-et;this.assertPosition(o),this.position=o},getReadCount(et){return this.positionReadCount.get(et||this.position)||0},incrementPosition(et){if(et<0)throw new NegativeOffsetError({offset:et});const o=this.position+et;this.assertPosition(o),this.position=o},inspectByte(et){const o=et??this.position;return this.assertPosition(o),this.bytes[o]},inspectBytes(et,o){const tt=o??this.position;return this.assertPosition(tt+et-1),this.bytes.subarray(tt,tt+et)},inspectUint8(et){const o=et??this.position;return this.assertPosition(o),this.bytes[o]},inspectUint16(et){const o=et??this.position;return this.assertPosition(o+1),this.dataView.getUint16(o)},inspectUint24(et){const o=et??this.position;return this.assertPosition(o+2),(this.dataView.getUint16(o)<<8)+this.dataView.getUint8(o+2)},inspectUint32(et){const o=et??this.position;return this.assertPosition(o+3),this.dataView.getUint32(o)},pushByte(et){this.assertPosition(this.position),this.bytes[this.position]=et,this.position++},pushBytes(et){this.assertPosition(this.position+et.length-1),this.bytes.set(et,this.position),this.position+=et.length},pushUint8(et){this.assertPosition(this.position),this.bytes[this.position]=et,this.position++},pushUint16(et){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,et),this.position+=2},pushUint24(et){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,et>>8),this.dataView.setUint8(this.position+2,et&255),this.position+=3},pushUint32(et){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,et),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const et=this.inspectByte();return this.position++,et},readBytes(et,o){this.assertReadLimit(),this._touch();const tt=this.inspectBytes(et);return this.position+=o??et,tt},readUint8(){this.assertReadLimit(),this._touch();const et=this.inspectUint8();return this.position+=1,et},readUint16(){this.assertReadLimit(),this._touch();const et=this.inspectUint16();return this.position+=2,et},readUint24(){this.assertReadLimit(),this._touch();const et=this.inspectUint24();return this.position+=3,et},readUint32(){this.assertReadLimit(),this._touch();const et=this.inspectUint32();return this.position+=4,et},get remaining(){return this.bytes.length-this.position},setPosition(et){const o=this.position;return this.assertPosition(et),this.position=et,()=>this.position=o},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const et=this.getReadCount();this.positionReadCount.set(this.position,et+1),et>0&&this.recursiveReadCount++}};function createCursor(et,{recursiveReadLimit:o=8192}={}){const tt=Object.create(staticCursor);return tt.bytes=et,tt.dataView=new DataView(et.buffer,et.byteOffset,et.byteLength),tt.positionReadCount=new Map,tt.recursiveReadLimit=o,tt}function toRlp(et,o="hex"){const tt=getEncodable(et),rt=createCursor(new Uint8Array(tt.length));return tt.encode(rt),o==="hex"?bytesToHex$3(rt.bytes):rt.bytes}function getEncodable(et){return Array.isArray(et)?getEncodableList(et.map(o=>getEncodable(o))):getEncodableBytes(et)}function getEncodableList(et){const o=et.reduce((nt,ot)=>nt+ot.length,0),tt=getSizeOfLength(o);return{length:o<=55?1+o:1+tt+o,encode(nt){o<=55?nt.pushByte(192+o):(nt.pushByte(247+tt),tt===1?nt.pushUint8(o):tt===2?nt.pushUint16(o):tt===3?nt.pushUint24(o):nt.pushUint32(o));for(const{encode:ot}of et)ot(nt)}}}function getEncodableBytes(et){const o=typeof et=="string"?hexToBytes$3(et):et,tt=getSizeOfLength(o.length);return{length:o.length===1&&o[0]<128?1:o.length<=55?1+o.length:1+tt+o.length,encode(nt){o.length===1&&o[0]<128?nt.pushBytes(o):o.length<=55?(nt.pushByte(128+o.length),nt.pushBytes(o)):(nt.pushByte(183+tt),tt===1?nt.pushUint8(o.length):tt===2?nt.pushUint16(o.length):tt===3?nt.pushUint24(o.length):nt.pushUint32(o.length),nt.pushBytes(o))}}}function getSizeOfLength(et){if(et<2**8)return 1;if(et<2**16)return 2;if(et<2**24)return 3;if(et<2**32)return 4;throw new BaseError$3("Length is too large.")}class ChainDoesNotSupportContract extends BaseError$3{constructor({blockNumber:o,chain:tt,contract:rt}){super(`Chain "${tt.name}" does not support contract "${rt.name}".`,{metaMessages:["This could be due to any of the following:",...o&&rt.blockCreated&&rt.blockCreated>o?[`- The contract "${rt.name}" was not deployed until block ${rt.blockCreated} (current block ${o}).`]:[`- The chain does not have the contract "${rt.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class ClientChainNotConfiguredError extends BaseError$3{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class InvalidChainIdError extends BaseError$3{constructor({chainId:o}){super(typeof o=="number"?`Chain ID "${o}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const etherUnits={gwei:9,wei:18},gweiUnits={ether:-9,wei:9},weiUnits={ether:-18,gwei:-9};function formatUnits(et,o){let tt=et.toString();const rt=tt.startsWith("-");rt&&(tt=tt.slice(1)),tt=tt.padStart(o,"0");let[nt,ot]=[tt.slice(0,tt.length-o),tt.slice(tt.length-o)];return ot=ot.replace(/(0+)$/,""),`${rt?"-":""}${nt||"0"}${ot?`.${ot}`:""}`}function formatGwei(et,o="wei"){return formatUnits(et,gweiUnits[o])}class ExecutionRevertedError extends BaseError$3{constructor({cause:o,message:tt}={}){var nt;const rt=(nt=tt==null?void 0:tt.replace("execution reverted: ",""))==null?void 0:nt.replace("execution reverted","");super(`Execution reverted ${rt?`with reason: ${rt}`:"for an unknown reason"}.`,{cause:o,name:"ExecutionRevertedError"})}}Object.defineProperty(ExecutionRevertedError,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(ExecutionRevertedError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class FeeCapTooHighError extends BaseError$3{constructor({cause:o,maxFeePerGas:tt}={}){super(`The fee cap (\`maxFeePerGas\`${tt?` = ${formatGwei(tt)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:o,name:"FeeCapTooHighError"})}}Object.defineProperty(FeeCapTooHighError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class FeeCapTooLowError extends BaseError$3{constructor({cause:o,maxFeePerGas:tt}={}){super(`The fee cap (\`maxFeePerGas\`${tt?` = ${formatGwei(tt)}`:""} gwei) cannot be lower than the block base fee.`,{cause:o,name:"FeeCapTooLowError"})}}Object.defineProperty(FeeCapTooLowError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class NonceTooHighError extends BaseError$3{constructor({cause:o,nonce:tt}={}){super(`Nonce provided for the transaction ${tt?`(${tt}) `:""}is higher than the next one expected.`,{cause:o,name:"NonceTooHighError"})}}Object.defineProperty(NonceTooHighError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class NonceTooLowError extends BaseError$3{constructor({cause:o,nonce:tt}={}){super([`Nonce provided for the transaction ${tt?`(${tt}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(` `),{cause:o,name:"NonceTooLowError"})}}Object.defineProperty(NonceTooLowError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class NonceMaxValueError extends BaseError$3{constructor({cause:o,nonce:tt}={}){super(`Nonce provided for the transaction ${tt?`(${tt}) `:""}exceeds the maximum allowed nonce.`,{cause:o,name:"NonceMaxValueError"})}}Object.defineProperty(NonceMaxValueError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class InsufficientFundsError extends BaseError$3{constructor({cause:o}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(` `),{cause:o,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(InsufficientFundsError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class IntrinsicGasTooHighError extends BaseError$3{constructor({cause:o,gas:tt}={}){super(`The amount of gas ${tt?`(${tt}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:o,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(IntrinsicGasTooHighError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class IntrinsicGasTooLowError extends BaseError$3{constructor({cause:o,gas:tt}={}){super(`The amount of gas ${tt?`(${tt}) `:""}provided for the transaction is too low.`,{cause:o,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(IntrinsicGasTooLowError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class TransactionTypeNotSupportedError extends BaseError$3{constructor({cause:o}){super("The transaction type is not supported for this chain.",{cause:o,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(TransactionTypeNotSupportedError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class TipAboveFeeCapError extends BaseError$3{constructor({cause:o,maxPriorityFeePerGas:tt,maxFeePerGas:rt}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${tt?` = ${formatGwei(tt)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${rt?` = ${formatGwei(rt)} gwei`:""}).`].join(` `),{cause:o,name:"TipAboveFeeCapError"})}}Object.defineProperty(TipAboveFeeCapError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class UnknownNodeError extends BaseError$3{constructor({cause:o}){super(`An error occurred while executing: ${o==null?void 0:o.shortMessage}`,{cause:o,name:"UnknownNodeError"})}}function formatEther(et,o="wei"){return formatUnits(et,etherUnits[o])}function prettyPrint(et){const o=Object.entries(et).map(([rt,nt])=>nt===void 0||nt===!1?null:[rt,nt]).filter(Boolean),tt=o.reduce((rt,[nt])=>Math.max(rt,nt.length),0);return o.map(([rt,nt])=>` ${`${rt}:`.padEnd(tt+1)} ${nt}`).join(` @@ -67,11 +72,11 @@ Error generating stack: `+ot.message+` `),rt.state&&(nt+=` state: `,nt+=prettyStateMapping(rt.state)),rt.stateDiff&&(nt+=` stateDiff: `,nt+=prettyStateMapping(rt.stateDiff)),nt},` State Override: -`).slice(0,-1)}function serializeStateMapping(et){if(!(!et||et.length===0))return et.reduce((o,{slot:tt,value:rt})=>{if(tt.length!==66)throw new InvalidBytesLengthError({size:tt.length,targetSize:66,type:"hex"});if(rt.length!==66)throw new InvalidBytesLengthError({size:rt.length,targetSize:66,type:"hex"});return o[tt]=rt,o},{})}function serializeAccountStateOverride(et){const{balance:o,nonce:tt,state:rt,stateDiff:nt,code:ot}=et,it={};if(ot!==void 0&&(it.code=ot),o!==void 0&&(it.balance=numberToHex(o)),tt!==void 0&&(it.nonce=numberToHex(tt)),rt!==void 0&&(it.state=serializeStateMapping(rt)),nt!==void 0){if(it.state)throw new StateAssignmentConflictError;it.stateDiff=serializeStateMapping(nt)}return it}function serializeStateOverride(et){if(!et)return;const o={};for(const{address:tt,...rt}of et){if(!isAddress(tt,{strict:!1}))throw new InvalidAddressError({address:tt});if(o[tt])throw new AccountStateConflictError({address:tt});o[tt]=serializeAccountStateOverride(rt)}return o}async function getBalance$1(et,{address:o,blockNumber:tt,blockTag:rt="latest"}){const nt=tt?numberToHex(tt):void 0,ot=await et.request({method:"eth_getBalance",params:[o,nt||rt]});return BigInt(ot)}function blobsToCommitments(et){const{kzg:o}=et,tt=et.to??(typeof et.blobs[0]=="string"?"hex":"bytes"),rt=typeof et.blobs[0]=="string"?et.blobs.map(ot=>hexToBytes$3(ot)):et.blobs,nt=[];for(const ot of rt)nt.push(Uint8Array.from(o.blobToKzgCommitment(ot)));return tt==="bytes"?nt:nt.map(ot=>bytesToHex$3(ot))}function blobsToProofs(et){const{kzg:o}=et,tt=et.to??(typeof et.blobs[0]=="string"?"hex":"bytes"),rt=typeof et.blobs[0]=="string"?et.blobs.map(it=>hexToBytes$3(it)):et.blobs,nt=typeof et.commitments[0]=="string"?et.commitments.map(it=>hexToBytes$3(it)):et.commitments,ot=[];for(let it=0;itbytesToHex$3(it))}function setBigUint64$1(et,o,tt,rt){if(typeof et.setBigUint64=="function")return et.setBigUint64(o,tt,rt);const nt=BigInt(32),ot=BigInt(4294967295),it=Number(tt>>nt&ot),st=Number(tt&ot),at=rt?4:0,ct=rt?0:4;et.setUint32(o+at,it,rt),et.setUint32(o+ct,st,rt)}const Chi=(et,o,tt)=>et&o^~et&tt,Maj=(et,o,tt)=>et&o^et&tt^o&tt;class HashMD extends Hash{constructor(o,tt,rt,nt){super(),this.blockLen=o,this.outputLen=tt,this.padOffset=rt,this.isLE=nt,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(o),this.view=createView$1(this.buffer)}update(o){exists$1(this);const{view:tt,buffer:rt,blockLen:nt}=this;o=toBytes$2(o);const ot=o.length;for(let it=0;itnt-it&&(this.process(rt,0),it=0);for(let dt=it;dtlt.length)throw new Error("_sha2: outputLen bigger than state");for(let dt=0;dt>>3,pt=rotr(mt,17)^rotr(mt,19)^mt>>>10;SHA256_W[dt]=pt+SHA256_W[dt-7]+ft+SHA256_W[dt-16]|0}let{A:rt,B:nt,C:ot,D:it,E:st,F:at,G:ct,H:lt}=this;for(let dt=0;dt<64;dt++){const ht=rotr(st,6)^rotr(st,11)^rotr(st,25),mt=lt+ht+Chi(st,at,ct)+SHA256_K[dt]+SHA256_W[dt]|0,pt=(rotr(rt,2)^rotr(rt,13)^rotr(rt,22))+Maj(rt,nt,ot)|0;lt=ct,ct=at,at=st,st=it+mt|0,it=ot,ot=nt,nt=rt,rt=mt+pt|0}rt=rt+this.A|0,nt=nt+this.B|0,ot=ot+this.C|0,it=it+this.D|0,st=st+this.E|0,at=at+this.F|0,ct=ct+this.G|0,lt=lt+this.H|0,this.set(rt,nt,ot,it,st,at,ct,lt)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const sha256$3=wrapConstructor(()=>new SHA256);function sha256$2(et,o){return sha256$3(isHex(et,{strict:!1})?toBytes$3(et):et)}function commitmentToVersionedHash(et){const{commitment:o,version:tt=1}=et,rt=et.to??(typeof o=="string"?"hex":"bytes"),nt=sha256$2(o);return nt.set([tt],0),rt==="bytes"?nt:bytesToHex$3(nt)}function commitmentsToVersionedHashes(et){const{commitments:o,version:tt}=et,rt=et.to??(typeof o[0]=="string"?"hex":"bytes"),nt=[];for(const ot of o)nt.push(commitmentToVersionedHash({commitment:ot,to:rt,version:tt}));return nt}const blobsPerTransaction=6,bytesPerFieldElement=32,fieldElementsPerBlob=4096,bytesPerBlob=bytesPerFieldElement*fieldElementsPerBlob,maxBytesPerTransaction=bytesPerBlob*blobsPerTransaction-1-1*fieldElementsPerBlob*blobsPerTransaction,versionedHashVersionKzg=1;class BlobSizeTooLargeError extends BaseError$3{constructor({maxSize:o,size:tt}){super("Blob size is too large.",{metaMessages:[`Max: ${o} bytes`,`Given: ${tt} bytes`],name:"BlobSizeTooLargeError"})}}class EmptyBlobError extends BaseError$3{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class InvalidVersionedHashSizeError extends BaseError$3{constructor({hash:o,size:tt}){super(`Versioned hash "${o}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${tt}`],name:"InvalidVersionedHashSizeError"})}}class InvalidVersionedHashVersionError extends BaseError$3{constructor({hash:o,version:tt}){super(`Versioned hash "${o}" version is invalid.`,{metaMessages:[`Expected: ${versionedHashVersionKzg}`,`Received: ${tt}`],name:"InvalidVersionedHashVersionError"})}}function toBlobs(et){const o=et.to??(typeof et.data=="string"?"hex":"bytes"),tt=typeof et.data=="string"?hexToBytes$3(et.data):et.data,rt=size$2(tt);if(!rt)throw new EmptyBlobError;if(rt>maxBytesPerTransaction)throw new BlobSizeTooLargeError({maxSize:maxBytesPerTransaction,size:rt});const nt=[];let ot=!0,it=0;for(;ot;){const st=createCursor(new Uint8Array(bytesPerBlob));let at=0;for(;atst.bytes):nt.map(st=>bytesToHex$3(st.bytes))}function toBlobSidecars(et){const{data:o,kzg:tt,to:rt}=et,nt=et.blobs??toBlobs({data:o,to:rt}),ot=et.commitments??blobsToCommitments({blobs:nt,kzg:tt,to:rt}),it=et.proofs??blobsToProofs({blobs:nt,commitments:ot,kzg:tt,to:rt}),st=[];for(let at=0;at1||tt[0]>1)throw new InvalidBytesBooleanError(tt);return!!tt[0]}function bytesToNumber$1(et,o={}){typeof o.size<"u"&&assertSize(et,{size:o.size});const tt=bytesToHex$3(et,o);return hexToNumber$2(tt,o)}function bytesToString(et,o={}){let tt=et;return typeof o.size<"u"&&(assertSize(tt,{size:o.size}),tt=trim$1(tt,{dir:"right"})),new TextDecoder().decode(tt)}function decodeAbiParameters(et,o){const tt=typeof o=="string"?hexToBytes$3(o):o,rt=createCursor(tt);if(size$2(tt)===0&&et.length>0)throw new AbiDecodingZeroDataError;if(size$2(o)&&size$2(o)<32)throw new AbiDecodingDataSizeTooSmallError({data:typeof o=="string"?o:bytesToHex$3(o),params:et,size:size$2(o)});let nt=0;const ot=[];for(let it=0;it48?bytesToBigInt(nt,{signed:tt}):bytesToNumber$1(nt,{signed:tt}),32]}function decodeTuple(et,o,{staticPosition:tt}){const rt=o.components.length===0||o.components.some(({name:it})=>!it),nt=rt?[]:{};let ot=0;if(hasDynamicChild(o)){const it=bytesToNumber$1(et.readBytes(sizeOfOffset)),st=tt+it;for(let at=0;atkeccak256$1(toBytes$3(et));function hashSignature(et){return hash(et)}const version$7="1.0.6";let BaseError$2=class ks extends Error{constructor(o,tt={}){var it;const rt=tt.cause instanceof ks?tt.cause.details:(it=tt.cause)!=null&&it.message?tt.cause.message:tt.details,nt=tt.cause instanceof ks&&tt.cause.docsPath||tt.docsPath,ot=[o||"An error occurred.","",...tt.metaMessages?[...tt.metaMessages,""]:[],...nt?[`Docs: https://abitype.dev${nt}`]:[],...rt?[`Details: ${rt}`]:[],`Version: abitype@${version$7}`].join(` -`);super(ot),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),tt.cause&&(this.cause=tt.cause),this.details=rt,this.docsPath=nt,this.metaMessages=tt.metaMessages,this.shortMessage=o}};function execTyped(et,o){const tt=et.exec(o);return tt==null?void 0:tt.groups}const bytesRegex=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,integerRegex=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,isTupleRegex=/^\(.+?\).*?$/,tupleRegex=/^tuple(?(\[(\d*)\])*)$/;function formatAbiParameter(et){let o=et.type;if(tupleRegex.test(et.type)&&"components"in et){o="(";const tt=et.components.length;for(let nt=0;nt[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)$/;function isErrorSignature(et){return errorSignatureRegex.test(et)}function execErrorSignature(et){return execTyped(errorSignatureRegex,et)}const eventSignatureRegex=/^event (?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)$/;function isEventSignature(et){return eventSignatureRegex.test(et)}function execEventSignature(et){return execTyped(eventSignatureRegex,et)}const functionSignatureRegex=/^function (?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)(?: (?external|public{1}))?(?: (?pure|view|nonpayable|payable{1}))?(?: returns\s?\((?.*?)\))?$/;function isFunctionSignature(et){return functionSignatureRegex.test(et)}function execFunctionSignature(et){return execTyped(functionSignatureRegex,et)}const structSignatureRegex=/^struct (?[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?.*?)\}$/;function isStructSignature(et){return structSignatureRegex.test(et)}function execStructSignature(et){return execTyped(structSignatureRegex,et)}const constructorSignatureRegex=/^constructor\((?.*?)\)(?:\s(?payable{1}))?$/;function isConstructorSignature(et){return constructorSignatureRegex.test(et)}function execConstructorSignature(et){return execTyped(constructorSignatureRegex,et)}const fallbackSignatureRegex=/^fallback\(\) external(?:\s(?payable{1}))?$/;function isFallbackSignature(et){return fallbackSignatureRegex.test(et)}const receiveSignatureRegex=/^receive\(\) external payable$/;function isReceiveSignature(et){return receiveSignatureRegex.test(et)}const eventModifiers=new Set(["indexed"]),functionModifiers=new Set(["calldata","memory","storage"]);class UnknownTypeError extends BaseError$2{constructor({type:o}){super("Unknown type.",{metaMessages:[`Type "${o}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class UnknownSolidityTypeError extends BaseError$2{constructor({type:o}){super("Unknown type.",{metaMessages:[`Type "${o}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class InvalidParameterError extends BaseError$2{constructor({param:o}){super("Invalid ABI parameter.",{details:o}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class SolidityProtectedKeywordError extends BaseError$2{constructor({param:o,name:tt}){super("Invalid ABI parameter.",{details:o,metaMessages:[`"${tt}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class InvalidModifierError extends BaseError$2{constructor({param:o,type:tt,modifier:rt}){super("Invalid ABI parameter.",{details:o,metaMessages:[`Modifier "${rt}" not allowed${tt?` in "${tt}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class InvalidFunctionModifierError extends BaseError$2{constructor({param:o,type:tt,modifier:rt}){super("Invalid ABI parameter.",{details:o,metaMessages:[`Modifier "${rt}" not allowed${tt?` in "${tt}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${rt}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class InvalidAbiTypeParameterError extends BaseError$2{constructor({abiParameter:o}){super("Invalid ABI parameter.",{details:JSON.stringify(o,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}let InvalidSignatureError$1=class extends BaseError$2{constructor({signature:o,type:tt}){super(`Invalid ${tt} signature.`,{details:o}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}};class UnknownSignatureError extends BaseError$2{constructor({signature:o}){super("Unknown signature.",{details:o}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class InvalidStructSignatureError extends BaseError$2{constructor({signature:o}){super("Invalid struct signature.",{details:o,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class CircularReferenceError extends BaseError$2{constructor({type:o}){super("Circular reference detected.",{metaMessages:[`Struct "${o}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class InvalidParenthesisError extends BaseError$2{constructor({current:o,depth:tt}){super("Unbalanced parentheses.",{metaMessages:[`"${o.trim()}" has too many ${tt>0?"opening":"closing"} parentheses.`],details:`Depth "${tt}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function getParameterCacheKey(et,o){return o?`${o}:${et}`:et}const parameterCache=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function parseSignature(et,o={}){if(isFunctionSignature(et)){const tt=execFunctionSignature(et);if(!tt)throw new InvalidSignatureError$1({signature:et,type:"function"});const rt=splitParameters(tt.parameters),nt=[],ot=rt.length;for(let st=0;st[a-zA-Z$_][a-zA-Z0-9$_]*)(?(?:\[\d*?\])+?)?(?:\s(?calldata|indexed|memory|storage{1}))?(?:\s(?[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,abiParameterWithTupleRegex=/^\((?.+?)\)(?(?:\[\d*?\])+?)?(?:\s(?calldata|indexed|memory|storage{1}))?(?:\s(?[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,dynamicIntegerRegex=/^u?int$/;function parseAbiParameter(et,o){var dt,ht;const tt=getParameterCacheKey(et,o==null?void 0:o.type);if(parameterCache.has(tt))return parameterCache.get(tt);const rt=isTupleRegex.test(et),nt=execTyped(rt?abiParameterWithTupleRegex:abiParameterWithoutTupleRegex,et);if(!nt)throw new InvalidParameterError({param:et});if(nt.name&&isSolidityKeyword(nt.name))throw new SolidityProtectedKeywordError({param:et,name:nt.name});const ot=nt.name?{name:nt.name}:{},it=nt.modifier==="indexed"?{indexed:!0}:{},st=(o==null?void 0:o.structs)??{};let at,ct={};if(rt){at="tuple";const mt=splitParameters(nt.type),ft=[],pt=mt.length;for(let gt=0;gt[a-zA-Z$_][a-zA-Z0-9$_]*)(?(?:\[\d*?\])+?)?$/;function resolveStructs(et,o,tt=new Set){const rt=[],nt=et.length;for(let ot=0;ot{const o=typeof et=="string"?et:formatAbiItem(et);return normalizeSignature$1(o)};function toSignatureHash(et){return hashSignature(toSignature(et))}const toEventSelector=toSignatureHash,toFunctionSelector=et=>slice(toSignatureHash(et),0,4);function getAbiItem(et){const{abi:o,args:tt=[],name:rt}=et,nt=isHex(rt,{strict:!1}),ot=o.filter(st=>nt?st.type==="function"?toFunctionSelector(st)===rt:st.type==="event"?toEventSelector(st)===rt:!1:"name"in st&&st.name===rt);if(ot.length===0)return;if(ot.length===1)return ot[0];let it;for(const st of ot){if(!("inputs"in st))continue;if(!tt||tt.length===0){if(!st.inputs||st.inputs.length===0)return st;continue}if(!st.inputs||st.inputs.length===0||st.inputs.length!==tt.length)continue;if(tt.every((ct,lt)=>{const dt="inputs"in st&&st.inputs[lt];return dt?isArgOfType(ct,dt):!1})){if(it&&"inputs"in it&&it.inputs){const ct=getAmbiguousTypes(st.inputs,it.inputs,tt);if(ct)throw new AbiItemAmbiguityError({abiItem:st,type:ct[0]},{abiItem:it,type:ct[1]})}it=st}}return it||ot[0]}function isArgOfType(et,o){const tt=typeof et,rt=o.type;switch(rt){case"address":return isAddress(et,{strict:!1});case"bool":return tt==="boolean";case"function":return tt==="string";case"string":return tt==="string";default:return rt==="tuple"&&"components"in o?Object.values(o.components).every((nt,ot)=>isArgOfType(Object.values(et)[ot],nt)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(rt)?tt==="number"||tt==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(rt)?tt==="string"||et instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(rt)?Array.isArray(et)&&et.every(nt=>isArgOfType(nt,{...o,type:rt.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function getAmbiguousTypes(et,o,tt){for(const rt in et){const nt=et[rt],ot=o[rt];if(nt.type==="tuple"&&ot.type==="tuple"&&"components"in nt&&"components"in ot)return getAmbiguousTypes(nt.components,ot.components,tt[rt]);const it=[nt.type,ot.type];if(it.includes("address")&&it.includes("bytes20")?!0:it.includes("address")&&it.includes("string")?isAddress(tt[rt],{strict:!1}):it.includes("address")&&it.includes("bytes")?isAddress(tt[rt],{strict:!1}):!1)return it}}const docsPath$1="/docs/contract/decodeFunctionResult";function decodeFunctionResult(et){const{abi:o,args:tt,functionName:rt,data:nt}=et;let ot=o[0];if(rt){const st=getAbiItem({abi:o,args:tt,name:rt});if(!st)throw new AbiFunctionNotFoundError(rt,{docsPath:docsPath$1});ot=st}if(ot.type!=="function")throw new AbiFunctionNotFoundError(void 0,{docsPath:docsPath$1});if(!ot.outputs)throw new AbiFunctionOutputsNotFoundError(ot.name,{docsPath:docsPath$1});const it=decodeAbiParameters(ot.outputs,nt);if(it&&it.length>1)return it;if(it&&it.length===1)return it[0]}const docsPath="/docs/contract/encodeFunctionData";function prepareEncodeFunctionData(et){const{abi:o,args:tt,functionName:rt}=et;let nt=o[0];if(rt){const ot=getAbiItem({abi:o,args:tt,name:rt});if(!ot)throw new AbiFunctionNotFoundError(rt,{docsPath});nt=ot}if(nt.type!=="function")throw new AbiFunctionNotFoundError(void 0,{docsPath});return{abi:[nt],functionName:toFunctionSelector(formatAbiItem$1(nt))}}function encodeFunctionData(et){const{args:o}=et,{abi:tt,functionName:rt}=(()=>{var st;return et.abi.length===1&&((st=et.functionName)!=null&&st.startsWith("0x"))?et:prepareEncodeFunctionData(et)})(),nt=tt[0],ot=rt,it="inputs"in nt&&nt.inputs?encodeAbiParameters(nt.inputs,o??[]):void 0;return concatHex([ot,it??"0x"])}function getChainContractAddress({blockNumber:et,chain:o,contract:tt}){var nt;const rt=(nt=o==null?void 0:o.contracts)==null?void 0:nt[tt];if(!rt)throw new ChainDoesNotSupportContract({chain:o,contract:{name:tt}});if(et&&rt.blockCreated&&rt.blockCreated>et)throw new ChainDoesNotSupportContract({blockNumber:et,chain:o,contract:{name:tt,blockCreated:rt.blockCreated}});return rt.address}const panicReasons={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},solidityError={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},solidityPanic={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function decodeErrorResult(et){const{abi:o,data:tt}=et,rt=slice(tt,0,4);if(rt==="0x")throw new AbiDecodingZeroDataError;const ot=[...o||[],solidityError,solidityPanic].find(it=>it.type==="error"&&rt===toFunctionSelector(formatAbiItem$1(it)));if(!ot)throw new AbiErrorSignatureNotFoundError(rt,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:ot,args:"inputs"in ot&&ot.inputs&&ot.inputs.length>0?decodeAbiParameters(ot.inputs,slice(tt,4)):void 0,errorName:ot.name}}function formatAbiItemWithArgs({abiItem:et,args:o,includeFunctionName:tt=!0,includeName:rt=!1}){if("name"in et&&"inputs"in et&&et.inputs)return`${tt?et.name:""}(${et.inputs.map((nt,ot)=>`${rt&&nt.name?`${nt.name}: `:""}${typeof o[ot]=="object"?stringify$2(o[ot]):o[ot]}`).join(", ")})`}class CallExecutionError extends BaseError$3{constructor(o,{account:tt,docsPath:rt,chain:nt,data:ot,gas:it,gasPrice:st,maxFeePerGas:at,maxPriorityFeePerGas:ct,nonce:lt,to:dt,value:ht,stateOverride:mt}){var gt;const ft=tt?parseAccount(tt):void 0;let pt=prettyPrint({from:ft==null?void 0:ft.address,to:dt,value:typeof ht<"u"&&`${formatEther(ht)} ${((gt=nt==null?void 0:nt.nativeCurrency)==null?void 0:gt.symbol)||"ETH"}`,data:ot,gas:it,gasPrice:typeof st<"u"&&`${formatGwei(st)} gwei`,maxFeePerGas:typeof at<"u"&&`${formatGwei(at)} gwei`,maxPriorityFeePerGas:typeof ct<"u"&&`${formatGwei(ct)} gwei`,nonce:lt});mt&&(pt+=` +`).slice(0,-1)}function serializeStateMapping(et){if(!(!et||et.length===0))return et.reduce((o,{slot:tt,value:rt})=>{if(tt.length!==66)throw new InvalidBytesLengthError({size:tt.length,targetSize:66,type:"hex"});if(rt.length!==66)throw new InvalidBytesLengthError({size:rt.length,targetSize:66,type:"hex"});return o[tt]=rt,o},{})}function serializeAccountStateOverride(et){const{balance:o,nonce:tt,state:rt,stateDiff:nt,code:ot}=et,it={};if(ot!==void 0&&(it.code=ot),o!==void 0&&(it.balance=numberToHex(o)),tt!==void 0&&(it.nonce=numberToHex(tt)),rt!==void 0&&(it.state=serializeStateMapping(rt)),nt!==void 0){if(it.state)throw new StateAssignmentConflictError;it.stateDiff=serializeStateMapping(nt)}return it}function serializeStateOverride(et){if(!et)return;const o={};for(const{address:tt,...rt}of et){if(!isAddress(tt,{strict:!1}))throw new InvalidAddressError({address:tt});if(o[tt])throw new AccountStateConflictError({address:tt});o[tt]=serializeAccountStateOverride(rt)}return o}async function getBalance$1(et,{address:o,blockNumber:tt,blockTag:rt="latest"}){const nt=tt?numberToHex(tt):void 0,ot=await et.request({method:"eth_getBalance",params:[o,nt||rt]});return BigInt(ot)}function blobsToCommitments(et){const{kzg:o}=et,tt=et.to??(typeof et.blobs[0]=="string"?"hex":"bytes"),rt=typeof et.blobs[0]=="string"?et.blobs.map(ot=>hexToBytes$3(ot)):et.blobs,nt=[];for(const ot of rt)nt.push(Uint8Array.from(o.blobToKzgCommitment(ot)));return tt==="bytes"?nt:nt.map(ot=>bytesToHex$3(ot))}function blobsToProofs(et){const{kzg:o}=et,tt=et.to??(typeof et.blobs[0]=="string"?"hex":"bytes"),rt=typeof et.blobs[0]=="string"?et.blobs.map(it=>hexToBytes$3(it)):et.blobs,nt=typeof et.commitments[0]=="string"?et.commitments.map(it=>hexToBytes$3(it)):et.commitments,ot=[];for(let it=0;itbytesToHex$3(it))}function setBigUint64$1(et,o,tt,rt){if(typeof et.setBigUint64=="function")return et.setBigUint64(o,tt,rt);const nt=BigInt(32),ot=BigInt(4294967295),it=Number(tt>>nt&ot),st=Number(tt&ot),at=rt?4:0,ct=rt?0:4;et.setUint32(o+at,it,rt),et.setUint32(o+ct,st,rt)}const Chi=(et,o,tt)=>et&o^~et&tt,Maj=(et,o,tt)=>et&o^et&tt^o&tt;class HashMD extends Hash{constructor(o,tt,rt,nt){super(),this.blockLen=o,this.outputLen=tt,this.padOffset=rt,this.isLE=nt,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(o),this.view=createView$1(this.buffer)}update(o){exists$1(this);const{view:tt,buffer:rt,blockLen:nt}=this;o=toBytes$2(o);const ot=o.length;for(let it=0;itnt-it&&(this.process(rt,0),it=0);for(let dt=it;dtlt.length)throw new Error("_sha2: outputLen bigger than state");for(let dt=0;dt>>3,pt=rotr(mt,17)^rotr(mt,19)^mt>>>10;SHA256_W[dt]=pt+SHA256_W[dt-7]+ft+SHA256_W[dt-16]|0}let{A:rt,B:nt,C:ot,D:it,E:st,F:at,G:ct,H:lt}=this;for(let dt=0;dt<64;dt++){const ht=rotr(st,6)^rotr(st,11)^rotr(st,25),mt=lt+ht+Chi(st,at,ct)+SHA256_K[dt]+SHA256_W[dt]|0,pt=(rotr(rt,2)^rotr(rt,13)^rotr(rt,22))+Maj(rt,nt,ot)|0;lt=ct,ct=at,at=st,st=it+mt|0,it=ot,ot=nt,nt=rt,rt=mt+pt|0}rt=rt+this.A|0,nt=nt+this.B|0,ot=ot+this.C|0,it=it+this.D|0,st=st+this.E|0,at=at+this.F|0,ct=ct+this.G|0,lt=lt+this.H|0,this.set(rt,nt,ot,it,st,at,ct,lt)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const sha256$3=wrapConstructor(()=>new SHA256);function sha256$2(et,o){return sha256$3(isHex(et,{strict:!1})?toBytes$3(et):et)}function commitmentToVersionedHash(et){const{commitment:o,version:tt=1}=et,rt=et.to??(typeof o=="string"?"hex":"bytes"),nt=sha256$2(o);return nt.set([tt],0),rt==="bytes"?nt:bytesToHex$3(nt)}function commitmentsToVersionedHashes(et){const{commitments:o,version:tt}=et,rt=et.to??(typeof o[0]=="string"?"hex":"bytes"),nt=[];for(const ot of o)nt.push(commitmentToVersionedHash({commitment:ot,to:rt,version:tt}));return nt}const blobsPerTransaction=6,bytesPerFieldElement=32,fieldElementsPerBlob=4096,bytesPerBlob=bytesPerFieldElement*fieldElementsPerBlob,maxBytesPerTransaction=bytesPerBlob*blobsPerTransaction-1-1*fieldElementsPerBlob*blobsPerTransaction,versionedHashVersionKzg=1;class BlobSizeTooLargeError extends BaseError$3{constructor({maxSize:o,size:tt}){super("Blob size is too large.",{metaMessages:[`Max: ${o} bytes`,`Given: ${tt} bytes`],name:"BlobSizeTooLargeError"})}}class EmptyBlobError extends BaseError$3{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class InvalidVersionedHashSizeError extends BaseError$3{constructor({hash:o,size:tt}){super(`Versioned hash "${o}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${tt}`],name:"InvalidVersionedHashSizeError"})}}class InvalidVersionedHashVersionError extends BaseError$3{constructor({hash:o,version:tt}){super(`Versioned hash "${o}" version is invalid.`,{metaMessages:[`Expected: ${versionedHashVersionKzg}`,`Received: ${tt}`],name:"InvalidVersionedHashVersionError"})}}function toBlobs(et){const o=et.to??(typeof et.data=="string"?"hex":"bytes"),tt=typeof et.data=="string"?hexToBytes$3(et.data):et.data,rt=size$2(tt);if(!rt)throw new EmptyBlobError;if(rt>maxBytesPerTransaction)throw new BlobSizeTooLargeError({maxSize:maxBytesPerTransaction,size:rt});const nt=[];let ot=!0,it=0;for(;ot;){const st=createCursor(new Uint8Array(bytesPerBlob));let at=0;for(;atst.bytes):nt.map(st=>bytesToHex$3(st.bytes))}function toBlobSidecars(et){const{data:o,kzg:tt,to:rt}=et,nt=et.blobs??toBlobs({data:o,to:rt}),ot=et.commitments??blobsToCommitments({blobs:nt,kzg:tt,to:rt}),it=et.proofs??blobsToProofs({blobs:nt,commitments:ot,kzg:tt,to:rt}),st=[];for(let at=0;at1||tt[0]>1)throw new InvalidBytesBooleanError(tt);return!!tt[0]}function bytesToNumber$1(et,o={}){typeof o.size<"u"&&assertSize(et,{size:o.size});const tt=bytesToHex$3(et,o);return hexToNumber$2(tt,o)}function bytesToString(et,o={}){let tt=et;return typeof o.size<"u"&&(assertSize(tt,{size:o.size}),tt=trim$1(tt,{dir:"right"})),new TextDecoder().decode(tt)}function decodeAbiParameters(et,o){const tt=typeof o=="string"?hexToBytes$3(o):o,rt=createCursor(tt);if(size$2(tt)===0&&et.length>0)throw new AbiDecodingZeroDataError;if(size$2(o)&&size$2(o)<32)throw new AbiDecodingDataSizeTooSmallError({data:typeof o=="string"?o:bytesToHex$3(o),params:et,size:size$2(o)});let nt=0;const ot=[];for(let it=0;it48?bytesToBigInt(nt,{signed:tt}):bytesToNumber$1(nt,{signed:tt}),32]}function decodeTuple(et,o,{staticPosition:tt}){const rt=o.components.length===0||o.components.some(({name:it})=>!it),nt=rt?[]:{};let ot=0;if(hasDynamicChild(o)){const it=bytesToNumber$1(et.readBytes(sizeOfOffset)),st=tt+it;for(let at=0;atkeccak256$1(toBytes$3(et));function hashSignature(et){return hash(et)}const version$7="1.0.6";let BaseError$2=class Rs extends Error{constructor(o,tt={}){var it;const rt=tt.cause instanceof Rs?tt.cause.details:(it=tt.cause)!=null&&it.message?tt.cause.message:tt.details,nt=tt.cause instanceof Rs&&tt.cause.docsPath||tt.docsPath,ot=[o||"An error occurred.","",...tt.metaMessages?[...tt.metaMessages,""]:[],...nt?[`Docs: https://abitype.dev${nt}`]:[],...rt?[`Details: ${rt}`]:[],`Version: abitype@${version$7}`].join(` +`);super(ot),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),tt.cause&&(this.cause=tt.cause),this.details=rt,this.docsPath=nt,this.metaMessages=tt.metaMessages,this.shortMessage=o}};function execTyped(et,o){const tt=et.exec(o);return tt==null?void 0:tt.groups}const bytesRegex=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,integerRegex=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,isTupleRegex=/^\(.+?\).*?$/,tupleRegex=/^tuple(?(\[(\d*)\])*)$/;function formatAbiParameter(et){let o=et.type;if(tupleRegex.test(et.type)&&"components"in et){o="(";const tt=et.components.length;for(let nt=0;nt[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)$/;function isErrorSignature(et){return errorSignatureRegex.test(et)}function execErrorSignature(et){return execTyped(errorSignatureRegex,et)}const eventSignatureRegex=/^event (?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)$/;function isEventSignature(et){return eventSignatureRegex.test(et)}function execEventSignature(et){return execTyped(eventSignatureRegex,et)}const functionSignatureRegex=/^function (?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)(?: (?external|public{1}))?(?: (?pure|view|nonpayable|payable{1}))?(?: returns\s?\((?.*?)\))?$/;function isFunctionSignature(et){return functionSignatureRegex.test(et)}function execFunctionSignature(et){return execTyped(functionSignatureRegex,et)}const structSignatureRegex=/^struct (?[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?.*?)\}$/;function isStructSignature(et){return structSignatureRegex.test(et)}function execStructSignature(et){return execTyped(structSignatureRegex,et)}const constructorSignatureRegex=/^constructor\((?.*?)\)(?:\s(?payable{1}))?$/;function isConstructorSignature(et){return constructorSignatureRegex.test(et)}function execConstructorSignature(et){return execTyped(constructorSignatureRegex,et)}const fallbackSignatureRegex=/^fallback\(\) external(?:\s(?payable{1}))?$/;function isFallbackSignature(et){return fallbackSignatureRegex.test(et)}const receiveSignatureRegex=/^receive\(\) external payable$/;function isReceiveSignature(et){return receiveSignatureRegex.test(et)}const eventModifiers=new Set(["indexed"]),functionModifiers=new Set(["calldata","memory","storage"]);class UnknownTypeError extends BaseError$2{constructor({type:o}){super("Unknown type.",{metaMessages:[`Type "${o}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class UnknownSolidityTypeError extends BaseError$2{constructor({type:o}){super("Unknown type.",{metaMessages:[`Type "${o}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class InvalidParameterError extends BaseError$2{constructor({param:o}){super("Invalid ABI parameter.",{details:o}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class SolidityProtectedKeywordError extends BaseError$2{constructor({param:o,name:tt}){super("Invalid ABI parameter.",{details:o,metaMessages:[`"${tt}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class InvalidModifierError extends BaseError$2{constructor({param:o,type:tt,modifier:rt}){super("Invalid ABI parameter.",{details:o,metaMessages:[`Modifier "${rt}" not allowed${tt?` in "${tt}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class InvalidFunctionModifierError extends BaseError$2{constructor({param:o,type:tt,modifier:rt}){super("Invalid ABI parameter.",{details:o,metaMessages:[`Modifier "${rt}" not allowed${tt?` in "${tt}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${rt}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class InvalidAbiTypeParameterError extends BaseError$2{constructor({abiParameter:o}){super("Invalid ABI parameter.",{details:JSON.stringify(o,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}let InvalidSignatureError$1=class extends BaseError$2{constructor({signature:o,type:tt}){super(`Invalid ${tt} signature.`,{details:o}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}};class UnknownSignatureError extends BaseError$2{constructor({signature:o}){super("Unknown signature.",{details:o}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class InvalidStructSignatureError extends BaseError$2{constructor({signature:o}){super("Invalid struct signature.",{details:o,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class CircularReferenceError extends BaseError$2{constructor({type:o}){super("Circular reference detected.",{metaMessages:[`Struct "${o}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class InvalidParenthesisError extends BaseError$2{constructor({current:o,depth:tt}){super("Unbalanced parentheses.",{metaMessages:[`"${o.trim()}" has too many ${tt>0?"opening":"closing"} parentheses.`],details:`Depth "${tt}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function getParameterCacheKey(et,o){return o?`${o}:${et}`:et}const parameterCache=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function parseSignature(et,o={}){if(isFunctionSignature(et)){const tt=execFunctionSignature(et);if(!tt)throw new InvalidSignatureError$1({signature:et,type:"function"});const rt=splitParameters(tt.parameters),nt=[],ot=rt.length;for(let st=0;st[a-zA-Z$_][a-zA-Z0-9$_]*)(?(?:\[\d*?\])+?)?(?:\s(?calldata|indexed|memory|storage{1}))?(?:\s(?[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,abiParameterWithTupleRegex=/^\((?.+?)\)(?(?:\[\d*?\])+?)?(?:\s(?calldata|indexed|memory|storage{1}))?(?:\s(?[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,dynamicIntegerRegex=/^u?int$/;function parseAbiParameter(et,o){var dt,ht;const tt=getParameterCacheKey(et,o==null?void 0:o.type);if(parameterCache.has(tt))return parameterCache.get(tt);const rt=isTupleRegex.test(et),nt=execTyped(rt?abiParameterWithTupleRegex:abiParameterWithoutTupleRegex,et);if(!nt)throw new InvalidParameterError({param:et});if(nt.name&&isSolidityKeyword(nt.name))throw new SolidityProtectedKeywordError({param:et,name:nt.name});const ot=nt.name?{name:nt.name}:{},it=nt.modifier==="indexed"?{indexed:!0}:{},st=(o==null?void 0:o.structs)??{};let at,ct={};if(rt){at="tuple";const mt=splitParameters(nt.type),ft=[],pt=mt.length;for(let yt=0;yt[a-zA-Z$_][a-zA-Z0-9$_]*)(?(?:\[\d*?\])+?)?$/;function resolveStructs(et,o,tt=new Set){const rt=[],nt=et.length;for(let ot=0;ot{const o=typeof et=="string"?et:formatAbiItem(et);return normalizeSignature$1(o)};function toSignatureHash(et){return hashSignature(toSignature(et))}const toEventSelector=toSignatureHash,toFunctionSelector=et=>slice(toSignatureHash(et),0,4);function getAbiItem(et){const{abi:o,args:tt=[],name:rt}=et,nt=isHex(rt,{strict:!1}),ot=o.filter(st=>nt?st.type==="function"?toFunctionSelector(st)===rt:st.type==="event"?toEventSelector(st)===rt:!1:"name"in st&&st.name===rt);if(ot.length===0)return;if(ot.length===1)return ot[0];let it;for(const st of ot){if(!("inputs"in st))continue;if(!tt||tt.length===0){if(!st.inputs||st.inputs.length===0)return st;continue}if(!st.inputs||st.inputs.length===0||st.inputs.length!==tt.length)continue;if(tt.every((ct,lt)=>{const dt="inputs"in st&&st.inputs[lt];return dt?isArgOfType(ct,dt):!1})){if(it&&"inputs"in it&&it.inputs){const ct=getAmbiguousTypes(st.inputs,it.inputs,tt);if(ct)throw new AbiItemAmbiguityError({abiItem:st,type:ct[0]},{abiItem:it,type:ct[1]})}it=st}}return it||ot[0]}function isArgOfType(et,o){const tt=typeof et,rt=o.type;switch(rt){case"address":return isAddress(et,{strict:!1});case"bool":return tt==="boolean";case"function":return tt==="string";case"string":return tt==="string";default:return rt==="tuple"&&"components"in o?Object.values(o.components).every((nt,ot)=>isArgOfType(Object.values(et)[ot],nt)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(rt)?tt==="number"||tt==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(rt)?tt==="string"||et instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(rt)?Array.isArray(et)&&et.every(nt=>isArgOfType(nt,{...o,type:rt.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function getAmbiguousTypes(et,o,tt){for(const rt in et){const nt=et[rt],ot=o[rt];if(nt.type==="tuple"&&ot.type==="tuple"&&"components"in nt&&"components"in ot)return getAmbiguousTypes(nt.components,ot.components,tt[rt]);const it=[nt.type,ot.type];if(it.includes("address")&&it.includes("bytes20")?!0:it.includes("address")&&it.includes("string")?isAddress(tt[rt],{strict:!1}):it.includes("address")&&it.includes("bytes")?isAddress(tt[rt],{strict:!1}):!1)return it}}const docsPath$1="/docs/contract/decodeFunctionResult";function decodeFunctionResult(et){const{abi:o,args:tt,functionName:rt,data:nt}=et;let ot=o[0];if(rt){const st=getAbiItem({abi:o,args:tt,name:rt});if(!st)throw new AbiFunctionNotFoundError(rt,{docsPath:docsPath$1});ot=st}if(ot.type!=="function")throw new AbiFunctionNotFoundError(void 0,{docsPath:docsPath$1});if(!ot.outputs)throw new AbiFunctionOutputsNotFoundError(ot.name,{docsPath:docsPath$1});const it=decodeAbiParameters(ot.outputs,nt);if(it&&it.length>1)return it;if(it&&it.length===1)return it[0]}const docsPath="/docs/contract/encodeFunctionData";function prepareEncodeFunctionData(et){const{abi:o,args:tt,functionName:rt}=et;let nt=o[0];if(rt){const ot=getAbiItem({abi:o,args:tt,name:rt});if(!ot)throw new AbiFunctionNotFoundError(rt,{docsPath});nt=ot}if(nt.type!=="function")throw new AbiFunctionNotFoundError(void 0,{docsPath});return{abi:[nt],functionName:toFunctionSelector(formatAbiItem$1(nt))}}function encodeFunctionData(et){const{args:o}=et,{abi:tt,functionName:rt}=(()=>{var st;return et.abi.length===1&&((st=et.functionName)!=null&&st.startsWith("0x"))?et:prepareEncodeFunctionData(et)})(),nt=tt[0],ot=rt,it="inputs"in nt&&nt.inputs?encodeAbiParameters(nt.inputs,o??[]):void 0;return concatHex([ot,it??"0x"])}function getChainContractAddress({blockNumber:et,chain:o,contract:tt}){var nt;const rt=(nt=o==null?void 0:o.contracts)==null?void 0:nt[tt];if(!rt)throw new ChainDoesNotSupportContract({chain:o,contract:{name:tt}});if(et&&rt.blockCreated&&rt.blockCreated>et)throw new ChainDoesNotSupportContract({blockNumber:et,chain:o,contract:{name:tt,blockCreated:rt.blockCreated}});return rt.address}const panicReasons={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},solidityError={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},solidityPanic={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function decodeErrorResult(et){const{abi:o,data:tt}=et,rt=slice(tt,0,4);if(rt==="0x")throw new AbiDecodingZeroDataError;const ot=[...o||[],solidityError,solidityPanic].find(it=>it.type==="error"&&rt===toFunctionSelector(formatAbiItem$1(it)));if(!ot)throw new AbiErrorSignatureNotFoundError(rt,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:ot,args:"inputs"in ot&&ot.inputs&&ot.inputs.length>0?decodeAbiParameters(ot.inputs,slice(tt,4)):void 0,errorName:ot.name}}function formatAbiItemWithArgs({abiItem:et,args:o,includeFunctionName:tt=!0,includeName:rt=!1}){if("name"in et&&"inputs"in et&&et.inputs)return`${tt?et.name:""}(${et.inputs.map((nt,ot)=>`${rt&&nt.name?`${nt.name}: `:""}${typeof o[ot]=="object"?stringify$2(o[ot]):o[ot]}`).join(", ")})`}class CallExecutionError extends BaseError$3{constructor(o,{account:tt,docsPath:rt,chain:nt,data:ot,gas:it,gasPrice:st,maxFeePerGas:at,maxPriorityFeePerGas:ct,nonce:lt,to:dt,value:ht,stateOverride:mt}){var yt;const ft=tt?parseAccount(tt):void 0;let pt=prettyPrint({from:ft==null?void 0:ft.address,to:dt,value:typeof ht<"u"&&`${formatEther(ht)} ${((yt=nt==null?void 0:nt.nativeCurrency)==null?void 0:yt.symbol)||"ETH"}`,data:ot,gas:it,gasPrice:typeof st<"u"&&`${formatGwei(st)} gwei`,maxFeePerGas:typeof at<"u"&&`${formatGwei(at)} gwei`,maxPriorityFeePerGas:typeof ct<"u"&&`${formatGwei(ct)} gwei`,nonce:lt});mt&&(pt+=` ${prettyStateOverride(mt)}`),super(o.shortMessage,{cause:o,docsPath:rt,metaMessages:[...o.metaMessages?[...o.metaMessages," "]:[],"Raw Call Arguments:",pt].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=o}}class ContractFunctionExecutionError extends BaseError$3{constructor(o,{abi:tt,args:rt,contractAddress:nt,docsPath:ot,functionName:it,sender:st}){const at=getAbiItem({abi:tt,args:rt,name:it}),ct=at?formatAbiItemWithArgs({abiItem:at,args:rt,includeFunctionName:!1,includeName:!1}):void 0,lt=at?formatAbiItem$1(at,{includeName:!0}):void 0,dt=prettyPrint({address:nt&&getContractAddress(nt),function:lt,args:ct&&ct!=="()"&&`${[...Array((it==null?void 0:it.length)??0).keys()].map(()=>" ").join("")}${ct}`,sender:st});super(o.shortMessage||`An unknown error occurred while executing the contract function "${it}".`,{cause:o,docsPath:ot,metaMessages:[...o.metaMessages?[...o.metaMessages," "]:[],dt&&"Contract Call:",dt].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=tt,this.args=rt,this.cause=o,this.contractAddress=nt,this.functionName=it,this.sender=st}}class ContractFunctionRevertedError extends BaseError$3{constructor({abi:o,data:tt,functionName:rt,message:nt}){let ot,it,st,at;if(tt&&tt!=="0x")try{it=decodeErrorResult({abi:o,data:tt});const{abiItem:lt,errorName:dt,args:ht}=it;if(dt==="Error")at=ht[0];else if(dt==="Panic"){const[mt]=ht;at=panicReasons[mt]}else{const mt=lt?formatAbiItem$1(lt,{includeName:!0}):void 0,ft=lt&&ht?formatAbiItemWithArgs({abiItem:lt,args:ht,includeFunctionName:!1,includeName:!1}):void 0;st=[mt?`Error: ${mt}`:"",ft&&ft!=="()"?` ${[...Array((dt==null?void 0:dt.length)??0).keys()].map(()=>" ").join("")}${ft}`:""]}}catch(lt){ot=lt}else nt&&(at=nt);let ct;ot instanceof AbiErrorSignatureNotFoundError&&(ct=ot.signature,st=[`Unable to decode signature "${ct}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${ct}.`]),super(at&&at!=="execution reverted"||ct?[`The contract function "${rt}" reverted with the following ${ct?"signature":"reason"}:`,at||ct].join(` -`):`The contract function "${rt}" reverted.`,{cause:ot,metaMessages:st,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=it,this.reason=at,this.signature=ct}}class ContractFunctionZeroDataError extends BaseError$3{constructor({functionName:o}){super(`The contract function "${o}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${o}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class CounterfactualDeploymentFailedError extends BaseError$3{constructor({factory:o}){super(`Deployment for counterfactual contract call failed${o?` for factory "${o}".`:""}`,{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class RawContractError extends BaseError$3{constructor({data:o,message:tt}){super(tt||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o}}function isNullUniversalResolverError(et,o){var rt,nt,ot,it,st,at;if(!(et instanceof BaseError$3))return!1;const tt=et.walk(ct=>ct instanceof ContractFunctionRevertedError);return tt instanceof ContractFunctionRevertedError?!!(((rt=tt.data)==null?void 0:rt.errorName)==="ResolverNotFound"||((nt=tt.data)==null?void 0:nt.errorName)==="ResolverWildcardNotSupported"||((ot=tt.data)==null?void 0:ot.errorName)==="ResolverNotContract"||((it=tt.data)==null?void 0:it.errorName)==="ResolverError"||((st=tt.data)==null?void 0:st.errorName)==="HttpError"||(at=tt.reason)!=null&&at.includes("Wildcard on non-extended resolvers is not supported")||o==="reverse"&&tt.reason===panicReasons[50]):!1}function encodedLabelToLabelhash(et){if(et.length!==66||et.indexOf("[")!==0||et.indexOf("]")!==65)return null;const o=`0x${et.slice(1,65)}`;return isHex(o)?o:null}function namehash(et){let o=new Uint8Array(32).fill(0);if(!et)return bytesToHex$3(o);const tt=et.split(".");for(let rt=tt.length-1;rt>=0;rt-=1){const nt=encodedLabelToLabelhash(tt[rt]),ot=nt?toBytes$3(nt):keccak256$1(stringToBytes(tt[rt]),"bytes");o=keccak256$1(concat$6([o,ot]),"bytes")}return bytesToHex$3(o)}function encodeLabelhash(et){return`[${et.slice(2)}]`}function labelhash(et){const o=new Uint8Array(32).fill(0);return et?encodedLabelToLabelhash(et)||keccak256$1(stringToBytes(et)):bytesToHex$3(o)}function packetToBytes(et){const o=et.replace(/^\.|\.$/gm,"");if(o.length===0)return new Uint8Array(1);const tt=new Uint8Array(stringToBytes(o).byteLength+2);let rt=0;const nt=o.split(".");for(let ot=0;ot255&&(it=stringToBytes(encodeLabelhash(labelhash(nt[ot])))),tt[rt]=it.length,tt.set(it,rt+1),rt+=it.length+1}return tt.byteLength!==rt+1?tt.slice(0,rt+1):tt}const EXECUTION_REVERTED_ERROR_CODE=3;function getContractError(et,{abi:o,address:tt,args:rt,docsPath:nt,functionName:ot,sender:it}){const{code:st,data:at,message:ct,shortMessage:lt}=et instanceof RawContractError?et:et instanceof BaseError$3?et.walk(ht=>"data"in ht)||et.walk():{},dt=et instanceof AbiDecodingZeroDataError?new ContractFunctionZeroDataError({functionName:ot}):[EXECUTION_REVERTED_ERROR_CODE,InternalRpcError.code].includes(st)&&(at||ct||lt)?new ContractFunctionRevertedError({abi:o,data:typeof at=="object"?at.data:at,functionName:ot,message:lt??ct}):et;return new ContractFunctionExecutionError(dt,{abi:o,args:rt,contractAddress:tt,docsPath:nt,functionName:ot,sender:it})}const aggregate3Signature="0x82ad56cb",deploylessCallViaBytecodeBytecode="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",deploylessCallViaFactoryBytecode="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe";function getCallError(et,{docsPath:o,...tt}){const rt=(()=>{const nt=getNodeError(et,tt);return nt instanceof UnknownNodeError?et:nt})();return new CallExecutionError(rt,{docsPath:o,...tt})}const schedulerCache=new Map;function createBatchScheduler({fn:et,id:o,shouldSplitBatch:tt,wait:rt=0,sort:nt}){const ot=async()=>{const lt=at();it();const dt=lt.map(({args:ht})=>ht);dt.length!==0&&et(dt).then(ht=>{var mt;nt&&Array.isArray(ht)&&ht.sort(nt);for(let ft=0;ft{var mt;for(let ft=0;ftschedulerCache.delete(o),st=()=>at().map(({args:lt})=>lt),at=()=>schedulerCache.get(o)||[],ct=lt=>schedulerCache.set(o,[...at(),lt]);return{flush:it,async schedule(lt){const dt={},ht=new Promise((pt,gt)=>{dt.resolve=pt,dt.reject=gt});return(tt==null?void 0:tt([...st(),lt]))&&ot(),at().length>0?(ct({args:lt,pendingPromise:dt}),ht):(ct({args:lt,pendingPromise:dt}),setTimeout(ot,rt),ht)}}}async function call(et,o){var Ot,Nt,Yt,Ft;const{account:tt=et.account,batch:rt=!!((Ot=et.batch)!=null&&Ot.multicall),blockNumber:nt,blockTag:ot="latest",accessList:it,blobs:st,code:at,data:ct,factory:lt,factoryData:dt,gas:ht,gasPrice:mt,maxFeePerBlobGas:ft,maxFeePerGas:pt,maxPriorityFeePerGas:gt,nonce:yt,to:bt,value:xt,stateOverride:vt,...Et}=o,Ct=tt?parseAccount(tt):void 0;if(at&&(lt||dt))throw new BaseError$3("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(at&&bt)throw new BaseError$3("Cannot provide both `code` & `to` as parameters.");const St=at&&ct,At=lt&&dt&&bt&&ct,kt=St||At,It=St?toDeploylessCallViaBytecodeData({code:at,data:ct}):At?toDeploylessCallViaFactoryData({data:ct,factory:lt,factoryData:dt,to:bt}):ct;try{assertRequest(o);const Qt=(nt?numberToHex(nt):void 0)||ot,Vt=serializeStateOverride(vt),Bt=(Ft=(Yt=(Nt=et.chain)==null?void 0:Nt.formatters)==null?void 0:Yt.transactionRequest)==null?void 0:Ft.format,jt=(Bt||formatTransactionRequest)({...extract$1(Et,{format:Bt}),from:Ct==null?void 0:Ct.address,accessList:it,blobs:st,data:It,gas:ht,gasPrice:mt,maxFeePerBlobGas:ft,maxFeePerGas:pt,maxPriorityFeePerGas:gt,nonce:yt,to:kt?void 0:bt,value:xt});if(rt&&shouldPerformMulticall({request:jt})&&!Vt)try{return await scheduleMulticall(et,{...jt,blockNumber:nt,blockTag:ot})}catch(Kt){if(!(Kt instanceof ClientChainNotConfiguredError)&&!(Kt instanceof ChainDoesNotSupportContract))throw Kt}const Xt=await et.request({method:"eth_call",params:Vt?[jt,Qt,Vt]:[jt,Qt]});return Xt==="0x"?{data:void 0}:{data:Xt}}catch(Ht){const Qt=getRevertErrorData(Ht),{offchainLookup:Vt,offchainLookupSignature:Bt}=await __vitePreload(async()=>{const{offchainLookup:Wt,offchainLookupSignature:jt}=await import("./ccip-D9LV_s6c.js");return{offchainLookup:Wt,offchainLookupSignature:jt}},[]);if(et.ccipRead!==!1&&(Qt==null?void 0:Qt.slice(0,10))===Bt&&bt)return{data:await Vt(et,{data:Qt,to:bt})};throw kt&&(Qt==null?void 0:Qt.slice(0,10))==="0x101bb98d"?new CounterfactualDeploymentFailedError({factory:lt}):getCallError(Ht,{...o,account:Ct,chain:et.chain})}}function shouldPerformMulticall({request:et}){const{data:o,to:tt,...rt}=et;return!(!o||o.startsWith(aggregate3Signature)||!tt||Object.values(rt).filter(nt=>typeof nt<"u").length>0)}async function scheduleMulticall(et,o){var pt;const{batchSize:tt=1024,wait:rt=0}=typeof((pt=et.batch)==null?void 0:pt.multicall)=="object"?et.batch.multicall:{},{blockNumber:nt,blockTag:ot="latest",data:it,multicallAddress:st,to:at}=o;let ct=st;if(!ct){if(!et.chain)throw new ClientChainNotConfiguredError;ct=getChainContractAddress({blockNumber:nt,chain:et.chain,contract:"multicall3"})}const dt=(nt?numberToHex(nt):void 0)||ot,{schedule:ht}=createBatchScheduler({id:`${et.uid}.${dt}`,wait:rt,shouldSplitBatch(gt){return gt.reduce((bt,{data:xt})=>bt+(xt.length-2),0)>tt*2},fn:async gt=>{const yt=gt.map(vt=>({allowFailure:!0,callData:vt.data,target:vt.to})),bt=encodeFunctionData({abi:multicall3Abi,args:[yt],functionName:"aggregate3"}),xt=await et.request({method:"eth_call",params:[{data:bt,to:ct},dt]});return decodeFunctionResult({abi:multicall3Abi,args:[yt],functionName:"aggregate3",data:xt||"0x"})}}),[{returnData:mt,success:ft}]=await ht({data:it,to:at});if(!ft)throw new RawContractError({data:mt});return mt==="0x"?{data:void 0}:{data:mt}}function toDeploylessCallViaBytecodeData(et){const{code:o,data:tt}=et;return encodeDeployData({abi:parseAbi(["constructor(bytes, bytes)"]),bytecode:deploylessCallViaBytecodeBytecode,args:[o,tt]})}function toDeploylessCallViaFactoryData(et){const{data:o,factory:tt,factoryData:rt,to:nt}=et;return encodeDeployData({abi:parseAbi(["constructor(address, bytes, address, bytes)"]),bytecode:deploylessCallViaFactoryBytecode,args:[nt,o,tt,rt]})}function getRevertErrorData(et){var tt;if(!(et instanceof BaseError$3))return;const o=et.walk();return typeof(o==null?void 0:o.data)=="object"?(tt=o.data)==null?void 0:tt.data:o.data}async function readContract$1(et,o){const{abi:tt,address:rt,args:nt,functionName:ot,...it}=o,st=encodeFunctionData({abi:tt,args:nt,functionName:ot});try{const{data:at}=await getAction$1(et,call,"call")({...it,data:st,to:rt});return decodeFunctionResult({abi:tt,args:nt,functionName:ot,data:at||"0x"})}catch(at){throw getContractError(at,{abi:tt,address:rt,args:nt,docsPath:"/docs/contract/readContract",functionName:ot})}}async function getEnsAddress$1(et,{blockNumber:o,blockTag:tt,coinType:rt,name:nt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){let at=st;if(!at){if(!et.chain)throw new Error("client chain not configured. universalResolverAddress is required.");at=getChainContractAddress({blockNumber:o,chain:et.chain,contract:"ensUniversalResolver"})}try{const ct=encodeFunctionData({abi:addressResolverAbi,functionName:"addr",...rt!=null?{args:[namehash(nt),BigInt(rt)]}:{args:[namehash(nt)]}}),lt={address:at,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(nt)),ct],blockNumber:o,blockTag:tt},dt=getAction$1(et,readContract$1,"readContract"),ht=ot?await dt({...lt,args:[...lt.args,ot]}):await dt(lt);if(ht[0]==="0x")return null;const mt=decodeFunctionResult({abi:addressResolverAbi,args:rt!=null?[namehash(nt),BigInt(rt)]:void 0,functionName:"addr",data:ht[0]});return mt==="0x"||trim$1(mt)==="0x00"?null:mt}catch(ct){if(it)throw ct;if(isNullUniversalResolverError(ct,"resolve"))return null;throw ct}}class EnsAvatarInvalidMetadataError extends BaseError$3{constructor({data:o}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(o)}`],name:"EnsAvatarInvalidMetadataError"})}}class EnsAvatarInvalidNftUriError extends BaseError$3{constructor({reason:o}){super(`ENS NFT avatar URI is invalid. ${o}`,{name:"EnsAvatarInvalidNftUriError"})}}class EnsAvatarUriResolutionError extends BaseError$3{constructor({uri:o}){super(`Unable to resolve ENS avatar URI "${o}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class EnsAvatarUnsupportedNamespaceError extends BaseError$3{constructor({namespace:o}){super(`ENS NFT avatar namespace "${o}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const networkRegex=/(?https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?\/)?(?ipfs\/|ipns\/)?(?[\w\-.]+)(?\/.*)?/,ipfsHashRegex=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?[\w\-.]+))?(?\/.*)?$/,base64Regex$1=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,dataURIRegex=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function isImageUri(et){try{const o=await fetch(et,{method:"HEAD"});if(o.status===200){const tt=o.headers.get("content-type");return tt==null?void 0:tt.startsWith("image/")}return!1}catch(o){return typeof o=="object"&&typeof o.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(tt=>{const rt=new Image;rt.onload=()=>{tt(!0)},rt.onerror=()=>{tt(!1)},rt.src=et})}}function getGateway(et,o){return et?et.endsWith("/")?et.slice(0,-1):et:o}function resolveAvatarUri({uri:et,gatewayUrls:o}){const tt=base64Regex$1.test(et);if(tt)return{uri:et,isOnChain:!0,isEncoded:tt};const rt=getGateway(o==null?void 0:o.ipfs,"https://ipfs.io"),nt=getGateway(o==null?void 0:o.arweave,"https://arweave.net"),ot=et.match(networkRegex),{protocol:it,subpath:st,target:at,subtarget:ct=""}=(ot==null?void 0:ot.groups)||{},lt=it==="ipns:/"||st==="ipns/",dt=it==="ipfs:/"||st==="ipfs/"||ipfsHashRegex.test(et);if(et.startsWith("http")&&!lt&&!dt){let mt=et;return o!=null&&o.arweave&&(mt=et.replace(/https:\/\/arweave.net/g,o==null?void 0:o.arweave)),{uri:mt,isOnChain:!1,isEncoded:!1}}if((lt||dt)&&at)return{uri:`${rt}/${lt?"ipns":"ipfs"}/${at}${ct}`,isOnChain:!1,isEncoded:!1};if(it==="ar:/"&&at)return{uri:`${nt}/${at}${ct||""}`,isOnChain:!1,isEncoded:!1};let ht=et.replace(dataURIRegex,"");if(ht.startsWith("nt.json());return await parseAvatarUri({gatewayUrls:et,uri:getJsonImage(tt)})}catch{throw new EnsAvatarUriResolutionError({uri:o})}}async function parseAvatarUri({gatewayUrls:et,uri:o}){const{uri:tt,isOnChain:rt}=resolveAvatarUri({uri:o,gatewayUrls:et});if(rt||await isImageUri(tt))return tt;throw new EnsAvatarUriResolutionError({uri:o})}function parseNftUri(et){let o=et;o.startsWith("did:nft:")&&(o=o.replace("did:nft:","").replace(/_/g,"/"));const[tt,rt,nt]=o.split("/"),[ot,it]=tt.split(":"),[st,at]=rt.split(":");if(!ot||ot.toLowerCase()!=="eip155")throw new EnsAvatarInvalidNftUriError({reason:"Only EIP-155 supported"});if(!it)throw new EnsAvatarInvalidNftUriError({reason:"Chain ID not found"});if(!at)throw new EnsAvatarInvalidNftUriError({reason:"Contract address not found"});if(!nt)throw new EnsAvatarInvalidNftUriError({reason:"Token ID not found"});if(!st)throw new EnsAvatarInvalidNftUriError({reason:"ERC namespace not found"});return{chainID:Number.parseInt(it),namespace:st.toLowerCase(),contractAddress:at,tokenID:nt}}async function getNftTokenUri(et,{nft:o}){if(o.namespace==="erc721")return readContract$1(et,{address:o.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(o.tokenID)]});if(o.namespace==="erc1155")return readContract$1(et,{address:o.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(o.tokenID)]});throw new EnsAvatarUnsupportedNamespaceError({namespace:o.namespace})}async function parseAvatarRecord(et,{gatewayUrls:o,record:tt}){return/eip155:/i.test(tt)?parseNftAvatarUri(et,{gatewayUrls:o,record:tt}):parseAvatarUri({uri:tt,gatewayUrls:o})}async function parseNftAvatarUri(et,{gatewayUrls:o,record:tt}){const rt=parseNftUri(tt),nt=await getNftTokenUri(et,{nft:rt}),{uri:ot,isOnChain:it,isEncoded:st}=resolveAvatarUri({uri:nt,gatewayUrls:o});if(it&&(ot.includes("data:application/json;base64,")||ot.startsWith("{"))){const ct=st?atob(ot.replace("data:application/json;base64,","")):ot,lt=JSON.parse(ct);return parseAvatarUri({uri:getJsonImage(lt),gatewayUrls:o})}let at=rt.tokenID;return rt.namespace==="erc1155"&&(at=at.replace("0x","").padStart(64,"0")),getMetadataAvatarUri({gatewayUrls:o,uri:ot.replace(/(?:0x)?{id}/,at)})}async function getEnsText(et,{blockNumber:o,blockTag:tt,name:rt,key:nt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){let at=st;if(!at){if(!et.chain)throw new Error("client chain not configured. universalResolverAddress is required.");at=getChainContractAddress({blockNumber:o,chain:et.chain,contract:"ensUniversalResolver"})}try{const ct={address:at,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(rt)),encodeFunctionData({abi:textResolverAbi,functionName:"text",args:[namehash(rt),nt]})],blockNumber:o,blockTag:tt},lt=getAction$1(et,readContract$1,"readContract"),dt=ot?await lt({...ct,args:[...ct.args,ot]}):await lt(ct);if(dt[0]==="0x")return null;const ht=decodeFunctionResult({abi:textResolverAbi,functionName:"text",data:dt[0]});return ht===""?null:ht}catch(ct){if(it)throw ct;if(isNullUniversalResolverError(ct,"resolve"))return null;throw ct}}async function getEnsAvatar$1(et,{blockNumber:o,blockTag:tt,assetGatewayUrls:rt,name:nt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){const at=await getAction$1(et,getEnsText,"getEnsText")({blockNumber:o,blockTag:tt,key:"avatar",name:nt,universalResolverAddress:st,gatewayUrls:ot,strict:it});if(!at)return null;try{return await parseAvatarRecord(et,{record:at,gatewayUrls:rt})}catch{return null}}async function getEnsName$1(et,{address:o,blockNumber:tt,blockTag:rt,gatewayUrls:nt,strict:ot,universalResolverAddress:it}){let st=it;if(!st){if(!et.chain)throw new Error("client chain not configured. universalResolverAddress is required.");st=getChainContractAddress({blockNumber:tt,chain:et.chain,contract:"ensUniversalResolver"})}const at=`${o.toLowerCase().substring(2)}.addr.reverse`;try{const ct={address:st,abi:universalResolverReverseAbi,functionName:"reverse",args:[toHex(packetToBytes(at))],blockNumber:tt,blockTag:rt},lt=getAction$1(et,readContract$1,"readContract"),[dt,ht]=nt?await lt({...ct,args:[...ct.args,nt]}):await lt(ct);return o.toLowerCase()!==ht.toLowerCase()?null:dt}catch(ct){if(ot)throw ct;if(isNullUniversalResolverError(ct,"reverse"))return null;throw ct}}const promiseCache$1=new Map,responseCache=new Map;function getCache(et){const o=(nt,ot)=>({clear:()=>ot.delete(nt),get:()=>ot.get(nt),set:it=>ot.set(nt,it)}),tt=o(et,promiseCache$1),rt=o(et,responseCache);return{clear:()=>{tt.clear(),rt.clear()},promise:tt,response:rt}}async function withCache(et,{cacheKey:o,cacheTime:tt=Number.POSITIVE_INFINITY}){const rt=getCache(o),nt=rt.response.get();if(nt&&tt>0&&new Date().getTime()-nt.created.getTime()`blockNumber.${et}`;async function getBlockNumber$1(et,{cacheTime:o=et.cacheTime}={}){const tt=await withCache(()=>et.request({method:"eth_blockNumber"}),{cacheKey:cacheKey(et.uid),cacheTime:o});return BigInt(tt)}function formatLog(et,{args:o,eventName:tt}={}){return{...et,blockHash:et.blockHash?et.blockHash:null,blockNumber:et.blockNumber?BigInt(et.blockNumber):null,logIndex:et.logIndex?Number(et.logIndex):null,transactionHash:et.transactionHash?et.transactionHash:null,transactionIndex:et.transactionIndex?Number(et.transactionIndex):null,...tt?{args:o,eventName:tt}:{}}}const receiptStatuses={"0x0":"reverted","0x1":"success"};function formatTransactionReceipt(et){const o={...et,blockNumber:et.blockNumber?BigInt(et.blockNumber):null,contractAddress:et.contractAddress?et.contractAddress:null,cumulativeGasUsed:et.cumulativeGasUsed?BigInt(et.cumulativeGasUsed):null,effectiveGasPrice:et.effectiveGasPrice?BigInt(et.effectiveGasPrice):null,gasUsed:et.gasUsed?BigInt(et.gasUsed):null,logs:et.logs?et.logs.map(tt=>formatLog(tt)):null,to:et.to?et.to:null,transactionIndex:et.transactionIndex?hexToNumber$2(et.transactionIndex):null,status:et.status?receiptStatuses[et.status]:null,type:et.type?transactionType[et.type]||et.type:null};return et.blobGasPrice&&(o.blobGasPrice=BigInt(et.blobGasPrice)),et.blobGasUsed&&(o.blobGasUsed=BigInt(et.blobGasUsed)),o}const defineTransactionReceipt=defineFormatter("transactionReceipt",formatTransactionReceipt);async function multicall$1(et,o){var gt;const{allowFailure:tt=!0,batchSize:rt,blockNumber:nt,blockTag:ot,multicallAddress:it,stateOverride:st}=o,at=o.contracts,ct=rt??(typeof((gt=et.batch)==null?void 0:gt.multicall)=="object"&&et.batch.multicall.batchSize||1024);let lt=it;if(!lt){if(!et.chain)throw new Error("client chain not configured. multicallAddress is required.");lt=getChainContractAddress({blockNumber:nt,chain:et.chain,contract:"multicall3"})}const dt=[[]];let ht=0,mt=0;for(let yt=0;yt0&&mt>ct&&dt[ht].length>0&&(ht++,mt=(Ct.length-2)/2,dt[ht]=[]),dt[ht]=[...dt[ht],{allowFailure:!0,callData:Ct,target:xt}]}catch(Ct){const St=getContractError(Ct,{abi:bt,address:xt,args:vt,docsPath:"/docs/contract/multicall",functionName:Et});if(!tt)throw St;dt[ht]=[...dt[ht],{allowFailure:!0,callData:"0x",target:xt}]}}const ft=await Promise.allSettled(dt.map(yt=>getAction$1(et,readContract$1,"readContract")({abi:multicall3Abi,address:lt,args:[yt],blockNumber:nt,blockTag:ot,functionName:"aggregate3",stateOverride:st}))),pt=[];for(let yt=0;ytlistenersCache.get(et)||[],ot=()=>{const lt=nt();listenersCache.set(et,lt.filter(dt=>dt.id!==rt))},it=()=>{const lt=cleanupCache.get(et);nt().length===1&<&<(),ot()},st=nt();if(listenersCache.set(et,[...st,{id:rt,fns:o}]),st&&st.length>0)return it;const at={};for(const lt in o)at[lt]=(...dt)=>{var mt,ft;const ht=nt();if(ht.length!==0)for(const pt of ht)(ft=(mt=pt.fns)[lt])==null||ft.call(mt,...dt)};const ct=tt(at);return typeof ct=="function"&&cleanupCache.set(et,ct),it}async function wait$1(et){return new Promise(o=>setTimeout(o,et))}function poll(et,{emitOnBegin:o,initialWaitTime:tt,interval:rt}){let nt=!0;const ot=()=>nt=!1;return(async()=>{let st;o&&(st=await et({unpoll:ot}));const at=await(tt==null?void 0:tt(st))??rt;await wait$1(at);const ct=async()=>{nt&&(await et({unpoll:ot}),await wait$1(rt),ct())};ct()})(),ot}function watchBlockNumber$1(et,{emitOnBegin:o=!1,emitMissed:tt=!1,onBlockNumber:rt,onError:nt,poll:ot,pollingInterval:it=et.pollingInterval}){const st=typeof ot<"u"?ot:!(et.transport.type==="webSocket"||et.transport.type==="fallback"&&et.transport.transports[0].config.type==="webSocket");let at;return st?(()=>{const dt=stringify$2(["watchBlockNumber",et.uid,o,tt,it]);return observe(dt,{onBlockNumber:rt,onError:nt},ht=>poll(async()=>{var mt;try{const ft=await getAction$1(et,getBlockNumber$1,"getBlockNumber")({cacheTime:0});if(at){if(ft===at)return;if(ft-at>1&&tt)for(let pt=at+1n;ptat)&&(ht.onBlockNumber(ft,at),at=ft)}catch(ft){(mt=ht.onError)==null||mt.call(ht,ft)}},{emitOnBegin:o,interval:it}))})():(()=>{const dt=stringify$2(["watchBlockNumber",et.uid,o,tt]);return observe(dt,{onBlockNumber:rt,onError:nt},ht=>{let mt=!0,ft=()=>mt=!1;return(async()=>{try{const pt=(()=>{if(et.transport.type==="fallback"){const yt=et.transport.transports.find(bt=>bt.config.type==="webSocket");return yt?yt.value:et.transport}return et.transport})(),{unsubscribe:gt}=await pt.subscribe({params:["newHeads"],onData(yt){var xt;if(!mt)return;const bt=hexToBigInt((xt=yt.result)==null?void 0:xt.number);ht.onBlockNumber(bt,at),at=bt},onError(yt){var bt;(bt=ht.onError)==null||bt.call(ht,yt)}});ft=gt,mt||ft()}catch(pt){nt==null||nt(pt)}})(),()=>ft()})})()}const promiseCache=new LruMap(8192);function withDedupe(et,{enabled:o=!0,id:tt}){if(!o||!tt)return et();if(promiseCache.get(tt))return promiseCache.get(tt);const rt=et().finally(()=>promiseCache.delete(tt));return promiseCache.set(tt,rt),rt}function withRetry(et,{delay:o=100,retryCount:tt=2,shouldRetry:rt=()=>!0}={}){return new Promise((nt,ot)=>{const it=async({count:st=0}={})=>{const at=async({error:ct})=>{const lt=typeof o=="function"?o({count:st,error:ct}):o;lt&&await wait$1(lt),it({count:st+1})};try{const ct=await et();nt(ct)}catch(ct){if(st{const{dedupe:nt=!1,retryDelay:ot=150,retryCount:it=3,uid:st}={...o,...rt},at=nt?keccak256$1(stringToHex(`${st}.${stringify$2(tt)}`)):void 0;return withDedupe(()=>withRetry(async()=>{try{return await et(tt)}catch(ct){const lt=ct;switch(lt.code){case ParseRpcError.code:throw new ParseRpcError(lt);case InvalidRequestRpcError.code:throw new InvalidRequestRpcError(lt);case MethodNotFoundRpcError.code:throw new MethodNotFoundRpcError(lt,{method:tt.method});case InvalidParamsRpcError.code:throw new InvalidParamsRpcError(lt);case InternalRpcError.code:throw new InternalRpcError(lt);case InvalidInputRpcError.code:throw new InvalidInputRpcError(lt);case ResourceNotFoundRpcError.code:throw new ResourceNotFoundRpcError(lt);case ResourceUnavailableRpcError.code:throw new ResourceUnavailableRpcError(lt);case TransactionRejectedRpcError.code:throw new TransactionRejectedRpcError(lt);case MethodNotSupportedRpcError.code:throw new MethodNotSupportedRpcError(lt,{method:tt.method});case LimitExceededRpcError.code:throw new LimitExceededRpcError(lt);case JsonRpcVersionUnsupportedError.code:throw new JsonRpcVersionUnsupportedError(lt);case UserRejectedRequestError.code:throw new UserRejectedRequestError(lt);case UnauthorizedProviderError.code:throw new UnauthorizedProviderError(lt);case UnsupportedProviderMethodError.code:throw new UnsupportedProviderMethodError(lt);case ProviderDisconnectedError.code:throw new ProviderDisconnectedError(lt);case ChainDisconnectedError.code:throw new ChainDisconnectedError(lt);case SwitchChainError.code:throw new SwitchChainError(lt);case 5e3:throw new UserRejectedRequestError(lt);default:throw ct instanceof BaseError$3?ct:new UnknownRpcError(lt)}}},{delay:({count:ct,error:lt})=>{var dt;if(lt&< instanceof HttpRequestError){const ht=(dt=lt==null?void 0:lt.headers)==null?void 0:dt.get("Retry-After");if(ht!=null&&ht.match(/\d/))return Number.parseInt(ht)*1e3}return~~(1<shouldRetry(ct)}),{enabled:nt,id:at})}}function shouldRetry(et){return"code"in et&&typeof et.code=="number"?et.code===-1||et.code===LimitExceededRpcError.code||et.code===InternalRpcError.code:et instanceof HttpRequestError&&et.status?et.status===403||et.status===408||et.status===413||et.status===429||et.status===500||et.status===502||et.status===503||et.status===504:!0}function defineChain(et){return{formatters:void 0,fees:void 0,serializers:void 0,...et}}function withTimeout(et,{errorInstance:o=new Error("timed out"),timeout:tt,signal:rt}){return new Promise((nt,ot)=>{(async()=>{let it;try{const st=new AbortController;tt>0&&(it=setTimeout(()=>{rt?st.abort():ot(o)},tt)),nt(await et({signal:(st==null?void 0:st.signal)||null}))}catch(st){(st==null?void 0:st.name)==="AbortError"&&ot(o),ot(st)}finally{clearTimeout(it)}})()})}function createIdStore(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const idCache=createIdStore();function getHttpRpcClient(et,o={}){return{async request(tt){var dt;const{body:rt,onRequest:nt=o.onRequest,onResponse:ot=o.onResponse,timeout:it=o.timeout??1e4}=tt,st={...o.fetchOptions??{},...tt.fetchOptions??{}},{headers:at,method:ct,signal:lt}=st;try{const ht=await withTimeout(async({signal:ft})=>{const pt={...st,body:Array.isArray(rt)?stringify$2(rt.map(xt=>({jsonrpc:"2.0",id:xt.id??idCache.take(),...xt}))):stringify$2({jsonrpc:"2.0",id:rt.id??idCache.take(),...rt}),headers:{"Content-Type":"application/json",...at},method:ct||"POST",signal:lt||(it>0?ft:null)},gt=new Request(et,pt),yt=await(nt==null?void 0:nt(gt,pt))??{...pt,url:et};return await fetch(yt.url??et,yt)},{errorInstance:new TimeoutError$4({body:rt,url:et}),timeout:it,signal:!0});ot&&await ot(ht);let mt;if((dt=ht.headers.get("Content-Type"))!=null&&dt.startsWith("application/json"))mt=await ht.json();else{mt=await ht.text();try{mt=JSON.parse(mt||"{}")}catch(ft){if(ht.ok)throw ft;mt={error:mt}}}if(!ht.ok)throw new HttpRequestError({body:rt,details:stringify$2(mt.error)||ht.statusText,headers:ht.headers,status:ht.status,url:et});return mt}catch(ht){throw ht instanceof HttpRequestError||ht instanceof TimeoutError$4?ht:new HttpRequestError({body:rt,cause:ht,url:et})}}}}function assertTransactionEIP7702(et){const{authorizationList:o}=et;if(o)for(const tt of o){const{contractAddress:rt,chainId:nt}=tt;if(!isAddress(rt))throw new InvalidAddressError({address:rt});if(nt<=0)throw new InvalidChainIdError({chainId:nt})}assertTransactionEIP1559(et)}function assertTransactionEIP4844(et){const{blobVersionedHashes:o}=et;if(o){if(o.length===0)throw new EmptyBlobError;for(const tt of o){const rt=size$2(tt),nt=hexToNumber$2(slice(tt,0,1));if(rt!==32)throw new InvalidVersionedHashSizeError({hash:tt,size:rt});if(nt!==versionedHashVersionKzg)throw new InvalidVersionedHashVersionError({hash:tt,version:nt})}}assertTransactionEIP1559(et)}function assertTransactionEIP1559(et){const{chainId:o,maxPriorityFeePerGas:tt,maxFeePerGas:rt,to:nt}=et;if(o<=0)throw new InvalidChainIdError({chainId:o});if(nt&&!isAddress(nt))throw new InvalidAddressError({address:nt});if(rt&&rt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:rt});if(tt&&rt&&tt>rt)throw new TipAboveFeeCapError({maxFeePerGas:rt,maxPriorityFeePerGas:tt})}function assertTransactionEIP2930(et){const{chainId:o,maxPriorityFeePerGas:tt,gasPrice:rt,maxFeePerGas:nt,to:ot}=et;if(o<=0)throw new InvalidChainIdError({chainId:o});if(ot&&!isAddress(ot))throw new InvalidAddressError({address:ot});if(tt||nt)throw new BaseError$3("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(rt&&rt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:rt})}function assertTransactionLegacy(et){const{chainId:o,maxPriorityFeePerGas:tt,gasPrice:rt,maxFeePerGas:nt,to:ot}=et;if(ot&&!isAddress(ot))throw new InvalidAddressError({address:ot});if(typeof o<"u"&&o<=0)throw new InvalidChainIdError({chainId:o});if(tt||nt)throw new BaseError$3("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(rt&&rt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:rt})}function serializeAuthorizationList(et){if(!et||et.length===0)return[];const o=[];for(const tt of et){const{contractAddress:rt,chainId:nt,nonce:ot,...it}=tt;o.push([toHex(nt),rt,ot?toHex(ot):"0x",...toYParitySignatureArray({},it)])}return o}function serializeAccessList(et){if(!et||et.length===0)return[];const o=[];for(let tt=0;tt"u"||typeof mt>"u")){const xt=typeof et.blobs[0]=="string"?et.blobs:et.blobs.map(Ct=>bytesToHex$3(Ct)),vt=et.kzg,Et=blobsToCommitments({blobs:xt,kzg:vt});if(typeof ht>"u"&&(ht=commitmentsToVersionedHashes({commitments:Et})),typeof mt>"u"){const Ct=blobsToProofs({blobs:xt,commitments:Et,kzg:vt});mt=toBlobSidecars({blobs:xt,commitments:Et,proofs:Ct})}}const ft=serializeAccessList(lt),pt=[toHex(tt),nt?toHex(nt):"0x",ct?toHex(ct):"0x",at?toHex(at):"0x",rt?toHex(rt):"0x",ot??"0x",it?toHex(it):"0x",dt??"0x",ft,st?toHex(st):"0x",ht??[],...toYParitySignatureArray(et,o)],gt=[],yt=[],bt=[];if(mt)for(let xt=0;xt{if(o.v>=35n)return(o.v-35n)/2n>0?o.v:27n+(o.v===35n?0n:1n);if(tt>0)return BigInt(tt*2)+BigInt(35n+o.v-27n);const mt=27n+(o.v===27n?0n:1n);if(o.v!==mt)throw new InvalidLegacyVError({v:o.v});return mt})(),dt=trim$1(o.r),ht=trim$1(o.s);ct=[...ct,toHex(lt),dt==="0x00"?"0x":dt,ht==="0x00"?"0x":ht]}else tt>0&&(ct=[...ct,toHex(tt),"0x","0x"]);return toRlp(ct)}function toYParitySignatureArray(et,o){const tt=o??et,{v:rt,yParity:nt}=tt;if(typeof tt.r>"u")return[];if(typeof tt.s>"u")return[];if(typeof rt>"u"&&typeof nt>"u")return[];const ot=trim$1(tt.r),it=trim$1(tt.s);return[typeof nt=="number"?nt?toHex(1):"0x":rt===0n?"0x":rt===1n?toHex(1):rt===27n?"0x":toHex(1),ot==="0x00"?"0x":ot,it==="0x00"?"0x":it]}async function signMessage$1(et,{account:o=et.account,message:tt}){if(!o)throw new AccountNotFoundError({docsPath:"/docs/actions/wallet/signMessage"});const rt=parseAccount(o);if(rt.signMessage)return rt.signMessage({message:tt});const nt=typeof tt=="string"?stringToHex(tt):tt.raw instanceof Uint8Array?toHex(tt.raw):tt.raw;return et.request({method:"personal_sign",params:[nt,rt.address]},{retryCount:0})}class HMAC extends Hash{constructor(o,tt){super(),this.finished=!1,this.destroyed=!1,hash$1(o);const rt=toBytes$2(tt);if(this.iHash=o.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const nt=this.blockLen,ot=new Uint8Array(nt);ot.set(rt.length>nt?o.create().update(rt).digest():rt);for(let it=0;itnew HMAC(et,o).update(tt).digest();hmac.create=(et,o)=>new HMAC(et,o);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$6=BigInt(0),_1n$8=BigInt(1),_2n$5=BigInt(2);function isBytes$2(et){return et instanceof Uint8Array||et!=null&&typeof et=="object"&&et.constructor.name==="Uint8Array"}function abytes(et){if(!isBytes$2(et))throw new Error("Uint8Array expected")}function abool(et,o){if(typeof o!="boolean")throw new Error(`${et} must be valid boolean, got "${o}".`)}const hexes$1=Array.from({length:256},(et,o)=>o.toString(16).padStart(2,"0"));function bytesToHex$2(et){abytes(et);let o="";for(let tt=0;tt=asciis._0&&et<=asciis._9)return et-asciis._0;if(et>=asciis._A&&et<=asciis._F)return et-(asciis._A-10);if(et>=asciis._a&&et<=asciis._f)return et-(asciis._a-10)}function hexToBytes$2(et){if(typeof et!="string")throw new Error("hex string expected, got "+typeof et);const o=et.length,tt=o/2;if(o%2)throw new Error("padded hex string expected, got unpadded hex of length "+o);const rt=new Uint8Array(tt);for(let nt=0,ot=0;nttypeof et=="bigint"&&_0n$6<=et;function inRange(et,o,tt){return isPosBig(et)&&isPosBig(o)&&isPosBig(tt)&&o<=et&&et_0n$6;et>>=_1n$8,o+=1);return o}function bitGet(et,o){return et>>BigInt(o)&_1n$8}function bitSet(et,o,tt){return et|(tt?_1n$8:_0n$6)<(_2n$5<new Uint8Array(et),u8fr=et=>Uint8Array.from(et);function createHmacDrbg(et,o,tt){if(typeof et!="number"||et<2)throw new Error("hashLen must be a number");if(typeof o!="number"||o<2)throw new Error("qByteLen must be a number");if(typeof tt!="function")throw new Error("hmacFn must be a function");let rt=u8n(et),nt=u8n(et),ot=0;const it=()=>{rt.fill(1),nt.fill(0),ot=0},st=(...dt)=>tt(nt,rt,...dt),at=(dt=u8n())=>{nt=st(u8fr([0]),dt),rt=st(),dt.length!==0&&(nt=st(u8fr([1]),dt),rt=st())},ct=()=>{if(ot++>=1e3)throw new Error("drbg: tried 1000 values");let dt=0;const ht=[];for(;dt{it(),at(dt);let mt;for(;!(mt=ht(ct()));)at();return it(),mt}}const validatorFns={bigint:et=>typeof et=="bigint",function:et=>typeof et=="function",boolean:et=>typeof et=="boolean",string:et=>typeof et=="string",stringOrUint8Array:et=>typeof et=="string"||isBytes$2(et),isSafeInteger:et=>Number.isSafeInteger(et),array:et=>Array.isArray(et),field:(et,o)=>o.Fp.isValid(et),hash:et=>typeof et=="function"&&Number.isSafeInteger(et.outputLen)};function validateObject(et,o,tt={}){const rt=(nt,ot,it)=>{const st=validatorFns[ot];if(typeof st!="function")throw new Error(`Invalid validator "${ot}", expected function`);const at=et[nt];if(!(it&&at===void 0)&&!st(at,et))throw new Error(`Invalid param ${String(nt)}=${at} (${typeof at}), expected ${ot}`)};for(const[nt,ot]of Object.entries(o))rt(nt,ot,!1);for(const[nt,ot]of Object.entries(tt))rt(nt,ot,!0);return et}const notImplemented=()=>{throw new Error("not implemented")};function memoized(et){const o=new WeakMap;return(tt,...rt)=>{const nt=o.get(tt);if(nt!==void 0)return nt;const ot=et(tt,...rt);return o.set(tt,ot),ot}}const ut=Object.freeze(Object.defineProperty({__proto__:null,aInRange,abool,abytes,bitGet,bitLen,bitMask,bitSet,bytesToHex:bytesToHex$2,bytesToNumberBE,bytesToNumberLE,concatBytes:concatBytes$1,createHmacDrbg,ensureBytes:ensureBytes$1,equalBytes:equalBytes$1,hexToBytes:hexToBytes$2,hexToNumber:hexToNumber$1,inRange,isBytes:isBytes$2,memoized,notImplemented,numberToBytesBE,numberToBytesLE,numberToHexUnpadded:numberToHexUnpadded$1,numberToVarBytesBE,utf8ToBytes:utf8ToBytes$2,validateObject},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$5=BigInt(0),_1n$7=BigInt(1),_2n$4=BigInt(2),_3n$3=BigInt(3),_4n=BigInt(4),_5n$1=BigInt(5),_8n$3=BigInt(8);BigInt(9);BigInt(16);function mod$1(et,o){const tt=et%o;return tt>=_0n$5?tt:o+tt}function pow(et,o,tt){if(tt<=_0n$5||o<_0n$5)throw new Error("Expected power/modulo > 0");if(tt===_1n$7)return _0n$5;let rt=_1n$7;for(;o>_0n$5;)o&_1n$7&&(rt=rt*et%tt),et=et*et%tt,o>>=_1n$7;return rt}function pow2$1(et,o,tt){let rt=et;for(;o-- >_0n$5;)rt*=rt,rt%=tt;return rt}function invert$1(et,o){if(et===_0n$5||o<=_0n$5)throw new Error(`invert: expected positive integers, got n=${et} mod=${o}`);let tt=mod$1(et,o),rt=o,nt=_0n$5,ot=_1n$7;for(;tt!==_0n$5;){const st=rt/tt,at=rt%tt,ct=nt-ot*st;rt=tt,tt=at,nt=ot,ot=ct}if(rt!==_1n$7)throw new Error("invert: does not exist");return mod$1(nt,o)}function tonelliShanks(et){const o=(et-_1n$7)/_2n$4;let tt,rt,nt;for(tt=et-_1n$7,rt=0;tt%_2n$4===_0n$5;tt/=_2n$4,rt++);for(nt=_2n$4;nt(mod$1(et,o)&_1n$7)===_1n$7,FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(et){const o={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},tt=FIELD_FIELDS.reduce((rt,nt)=>(rt[nt]="function",rt),o);return validateObject(et,tt)}function FpPow(et,o,tt){if(tt<_0n$5)throw new Error("Expected power > 0");if(tt===_0n$5)return et.ONE;if(tt===_1n$7)return o;let rt=et.ONE,nt=o;for(;tt>_0n$5;)tt&_1n$7&&(rt=et.mul(rt,nt)),nt=et.sqr(nt),tt>>=_1n$7;return rt}function FpInvertBatch(et,o){const tt=new Array(o.length),rt=o.reduce((ot,it,st)=>et.is0(it)?ot:(tt[st]=ot,et.mul(ot,it)),et.ONE),nt=et.inv(rt);return o.reduceRight((ot,it,st)=>et.is0(it)?ot:(tt[st]=et.mul(ot,tt[st]),et.mul(ot,it)),nt),tt}function nLength(et,o){const tt=o!==void 0?o:et.toString(2).length,rt=Math.ceil(tt/8);return{nBitLength:tt,nByteLength:rt}}function Field$1(et,o,tt=!1,rt={}){if(et<=_0n$5)throw new Error(`Expected Field ORDER > 0, got ${et}`);const{nBitLength:nt,nByteLength:ot}=nLength(et,o);if(ot>2048)throw new Error("Field lengths over 2048 bytes are not supported");const it=FpSqrt(et),st=Object.freeze({ORDER:et,BITS:nt,BYTES:ot,MASK:bitMask(nt),ZERO:_0n$5,ONE:_1n$7,create:at=>mod$1(at,et),isValid:at=>{if(typeof at!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof at}`);return _0n$5<=at&&atat===_0n$5,isOdd:at=>(at&_1n$7)===_1n$7,neg:at=>mod$1(-at,et),eql:(at,ct)=>at===ct,sqr:at=>mod$1(at*at,et),add:(at,ct)=>mod$1(at+ct,et),sub:(at,ct)=>mod$1(at-ct,et),mul:(at,ct)=>mod$1(at*ct,et),pow:(at,ct)=>FpPow(st,at,ct),div:(at,ct)=>mod$1(at*invert$1(ct,et),et),sqrN:at=>at*at,addN:(at,ct)=>at+ct,subN:(at,ct)=>at-ct,mulN:(at,ct)=>at*ct,inv:at=>invert$1(at,et),sqrt:rt.sqrt||(at=>it(st,at)),invertBatch:at=>FpInvertBatch(st,at),cmov:(at,ct,lt)=>lt?ct:at,toBytes:at=>tt?numberToBytesLE(at,ot):numberToBytesBE(at,ot),fromBytes:at=>{if(at.length!==ot)throw new Error(`Fp.fromBytes: expected ${ot}, got ${at.length}`);return tt?bytesToNumberLE(at):bytesToNumberBE(at)}});return Object.freeze(st)}function getFieldBytesLength(et){if(typeof et!="bigint")throw new Error("field order must be bigint");const o=et.toString(2).length;return Math.ceil(o/8)}function getMinHashLength(et){const o=getFieldBytesLength(et);return o+Math.ceil(o/2)}function mapHashToField(et,o,tt=!1){const rt=et.length,nt=getFieldBytesLength(o),ot=getMinHashLength(o);if(rt<16||rt1024)throw new Error(`expected ${ot}-1024 bytes of input, got ${rt}`);const it=tt?bytesToNumberBE(et):bytesToNumberLE(et),st=mod$1(it,o-_1n$7)+_1n$7;return tt?numberToBytesLE(st,nt):numberToBytesBE(st,nt)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$4=BigInt(0),_1n$6=BigInt(1),pointPrecomputes$1=new WeakMap,pointWindowSizes=new WeakMap;function wNAF(et,o){const tt=(ot,it)=>{const st=it.negate();return ot?st:it},rt=ot=>{if(!Number.isSafeInteger(ot)||ot<=0||ot>o)throw new Error(`Wrong window size=${ot}, should be [1..${o}]`)},nt=ot=>{rt(ot);const it=Math.ceil(o/ot)+1,st=2**(ot-1);return{windows:it,windowSize:st}};return{constTimeNegate:tt,unsafeLadder(ot,it){let st=et.ZERO,at=ot;for(;it>_0n$4;)it&_1n$6&&(st=st.add(at)),at=at.double(),it>>=_1n$6;return st},precomputeWindow(ot,it){const{windows:st,windowSize:at}=nt(it),ct=[];let lt=ot,dt=lt;for(let ht=0;ht>=ft,yt>ct&&(yt-=mt,st+=_1n$6);const bt=gt,xt=gt+Math.abs(yt)-1,vt=pt%2!==0,Et=yt<0;yt===0?dt=dt.add(tt(vt,it[bt])):lt=lt.add(tt(Et,it[xt]))}return{p:lt,f:dt}},wNAFCached(ot,it,st){const at=pointWindowSizes.get(ot)||1;let ct=pointPrecomputes$1.get(ot);return ct||(ct=this.precomputeWindow(ot,at),at!==1&&pointPrecomputes$1.set(ot,st(ct))),this.wNAF(at,ct,it)},setWindowSize(ot,it){rt(it),pointWindowSizes.set(ot,it),pointPrecomputes$1.delete(ot)}}}function pippenger(et,o,tt,rt){if(!Array.isArray(tt)||!Array.isArray(rt)||rt.length!==tt.length)throw new Error("arrays of points and scalars must have equal length");rt.forEach((lt,dt)=>{if(!o.isValid(lt))throw new Error(`wrong scalar at index ${dt}`)}),tt.forEach((lt,dt)=>{if(!(lt instanceof et))throw new Error(`wrong point at index ${dt}`)});const nt=bitLen(BigInt(tt.length)),ot=nt>12?nt-3:nt>4?nt-2:nt?2:1,it=(1<=0;lt-=ot){st.fill(et.ZERO);for(let ht=0;ht>BigInt(lt)&BigInt(it));st[ft]=st[ft].add(tt[ht])}let dt=et.ZERO;for(let ht=st.length-1,mt=et.ZERO;ht>0;ht--)mt=mt.add(st[ht]),dt=dt.add(mt);if(ct=ct.add(dt),lt!==0)for(let ht=0;ht{const{Err:tt}=DER;if(et<0||et>256)throw new tt("tlv.encode: wrong tag");if(o.length&1)throw new tt("tlv.encode: unpadded data");const rt=o.length/2,nt=numberToHexUnpadded$1(rt);if(nt.length/2&128)throw new tt("tlv.encode: long form length too big");const ot=rt>127?numberToHexUnpadded$1(nt.length/2|128):"";return`${numberToHexUnpadded$1(et)}${ot}${nt}${o}`},decode(et,o){const{Err:tt}=DER;let rt=0;if(et<0||et>256)throw new tt("tlv.encode: wrong tag");if(o.length<2||o[rt++]!==et)throw new tt("tlv.decode: wrong tlv");const nt=o[rt++],ot=!!(nt&128);let it=0;if(!ot)it=nt;else{const at=nt&127;if(!at)throw new tt("tlv.decode(long): indefinite length not supported");if(at>4)throw new tt("tlv.decode(long): byte length is too big");const ct=o.subarray(rt,rt+at);if(ct.length!==at)throw new tt("tlv.decode: length bytes not complete");if(ct[0]===0)throw new tt("tlv.decode(long): zero leftmost byte");for(const lt of ct)it=it<<8|lt;if(rt+=at,it<128)throw new tt("tlv.decode(long): not minimal encoding")}const st=o.subarray(rt,rt+it);if(st.length!==it)throw new tt("tlv.decode: wrong value length");return{v:st,l:o.subarray(rt+it)}}},_int:{encode(et){const{Err:o}=DER;if(et<_0n$3)throw new o("integer: negative integers are not allowed");let tt=numberToHexUnpadded$1(et);if(Number.parseInt(tt[0],16)&8&&(tt="00"+tt),tt.length&1)throw new o("unexpected assertion");return tt},decode(et){const{Err:o}=DER;if(et[0]&128)throw new o("Invalid signature integer: negative");if(et[0]===0&&!(et[1]&128))throw new o("Invalid signature integer: unnecessary leading zero");return b2n(et)}},toSig(et){const{Err:o,_int:tt,_tlv:rt}=DER,nt=typeof et=="string"?h2b(et):et;abytes(nt);const{v:ot,l:it}=rt.decode(48,nt);if(it.length)throw new o("Invalid signature: left bytes after parsing");const{v:st,l:at}=rt.decode(2,ot),{v:ct,l:lt}=rt.decode(2,at);if(lt.length)throw new o("Invalid signature: left bytes after parsing");return{r:tt.decode(st),s:tt.decode(ct)}},hexFromSig(et){const{_tlv:o,_int:tt}=DER,rt=`${o.encode(2,tt.encode(et.r))}${o.encode(2,tt.encode(et.s))}`;return o.encode(48,rt)}},_0n$3=BigInt(0),_1n$5=BigInt(1);BigInt(2);const _3n$2=BigInt(3);BigInt(4);function weierstrassPoints(et){const o=validatePointOpts(et),{Fp:tt}=o,rt=Field$1(o.n,o.nBitLength),nt=o.toBytes||((pt,gt,yt)=>{const bt=gt.toAffine();return concatBytes$1(Uint8Array.from([4]),tt.toBytes(bt.x),tt.toBytes(bt.y))}),ot=o.fromBytes||(pt=>{const gt=pt.subarray(1),yt=tt.fromBytes(gt.subarray(0,tt.BYTES)),bt=tt.fromBytes(gt.subarray(tt.BYTES,2*tt.BYTES));return{x:yt,y:bt}});function it(pt){const{a:gt,b:yt}=o,bt=tt.sqr(pt),xt=tt.mul(bt,pt);return tt.add(tt.add(xt,tt.mul(pt,gt)),yt)}if(!tt.eql(tt.sqr(o.Gy),it(o.Gx)))throw new Error("bad generator point: equation left != right");function st(pt){return inRange(pt,_1n$5,o.n)}function at(pt){const{allowedPrivateKeyLengths:gt,nByteLength:yt,wrapPrivateKey:bt,n:xt}=o;if(gt&&typeof pt!="bigint"){if(isBytes$2(pt)&&(pt=bytesToHex$2(pt)),typeof pt!="string"||!gt.includes(pt.length))throw new Error("Invalid key");pt=pt.padStart(yt*2,"0")}let vt;try{vt=typeof pt=="bigint"?pt:bytesToNumberBE(ensureBytes$1("private key",pt,yt))}catch{throw new Error(`private key must be ${yt} bytes, hex or bigint, not ${typeof pt}`)}return bt&&(vt=mod$1(vt,xt)),aInRange("private key",vt,_1n$5,xt),vt}function ct(pt){if(!(pt instanceof ht))throw new Error("ProjectivePoint expected")}const lt=memoized((pt,gt)=>{const{px:yt,py:bt,pz:xt}=pt;if(tt.eql(xt,tt.ONE))return{x:yt,y:bt};const vt=pt.is0();gt==null&&(gt=vt?tt.ONE:tt.inv(xt));const Et=tt.mul(yt,gt),Ct=tt.mul(bt,gt),St=tt.mul(xt,gt);if(vt)return{x:tt.ZERO,y:tt.ZERO};if(!tt.eql(St,tt.ONE))throw new Error("invZ was invalid");return{x:Et,y:Ct}}),dt=memoized(pt=>{if(pt.is0()){if(o.allowInfinityPoint&&!tt.is0(pt.py))return;throw new Error("bad point: ZERO")}const{x:gt,y:yt}=pt.toAffine();if(!tt.isValid(gt)||!tt.isValid(yt))throw new Error("bad point: x or y not FE");const bt=tt.sqr(yt),xt=it(gt);if(!tt.eql(bt,xt))throw new Error("bad point: equation left != right");if(!pt.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class ht{constructor(gt,yt,bt){if(this.px=gt,this.py=yt,this.pz=bt,gt==null||!tt.isValid(gt))throw new Error("x required");if(yt==null||!tt.isValid(yt))throw new Error("y required");if(bt==null||!tt.isValid(bt))throw new Error("z required");Object.freeze(this)}static fromAffine(gt){const{x:yt,y:bt}=gt||{};if(!gt||!tt.isValid(yt)||!tt.isValid(bt))throw new Error("invalid affine point");if(gt instanceof ht)throw new Error("projective point not allowed");const xt=vt=>tt.eql(vt,tt.ZERO);return xt(yt)&&xt(bt)?ht.ZERO:new ht(yt,bt,tt.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(gt){const yt=tt.invertBatch(gt.map(bt=>bt.pz));return gt.map((bt,xt)=>bt.toAffine(yt[xt])).map(ht.fromAffine)}static fromHex(gt){const yt=ht.fromAffine(ot(ensureBytes$1("pointHex",gt)));return yt.assertValidity(),yt}static fromPrivateKey(gt){return ht.BASE.multiply(at(gt))}static msm(gt,yt){return pippenger(ht,rt,gt,yt)}_setWindowSize(gt){ft.setWindowSize(this,gt)}assertValidity(){dt(this)}hasEvenY(){const{y:gt}=this.toAffine();if(tt.isOdd)return!tt.isOdd(gt);throw new Error("Field doesn't support isOdd")}equals(gt){ct(gt);const{px:yt,py:bt,pz:xt}=this,{px:vt,py:Et,pz:Ct}=gt,St=tt.eql(tt.mul(yt,Ct),tt.mul(vt,xt)),At=tt.eql(tt.mul(bt,Ct),tt.mul(Et,xt));return St&&At}negate(){return new ht(this.px,tt.neg(this.py),this.pz)}double(){const{a:gt,b:yt}=o,bt=tt.mul(yt,_3n$2),{px:xt,py:vt,pz:Et}=this;let Ct=tt.ZERO,St=tt.ZERO,At=tt.ZERO,kt=tt.mul(xt,xt),It=tt.mul(vt,vt),Ot=tt.mul(Et,Et),Nt=tt.mul(xt,vt);return Nt=tt.add(Nt,Nt),At=tt.mul(xt,Et),At=tt.add(At,At),Ct=tt.mul(gt,At),St=tt.mul(bt,Ot),St=tt.add(Ct,St),Ct=tt.sub(It,St),St=tt.add(It,St),St=tt.mul(Ct,St),Ct=tt.mul(Nt,Ct),At=tt.mul(bt,At),Ot=tt.mul(gt,Ot),Nt=tt.sub(kt,Ot),Nt=tt.mul(gt,Nt),Nt=tt.add(Nt,At),At=tt.add(kt,kt),kt=tt.add(At,kt),kt=tt.add(kt,Ot),kt=tt.mul(kt,Nt),St=tt.add(St,kt),Ot=tt.mul(vt,Et),Ot=tt.add(Ot,Ot),kt=tt.mul(Ot,Nt),Ct=tt.sub(Ct,kt),At=tt.mul(Ot,It),At=tt.add(At,At),At=tt.add(At,At),new ht(Ct,St,At)}add(gt){ct(gt);const{px:yt,py:bt,pz:xt}=this,{px:vt,py:Et,pz:Ct}=gt;let St=tt.ZERO,At=tt.ZERO,kt=tt.ZERO;const It=o.a,Ot=tt.mul(o.b,_3n$2);let Nt=tt.mul(yt,vt),Yt=tt.mul(bt,Et),Ft=tt.mul(xt,Ct),Ht=tt.add(yt,bt),Qt=tt.add(vt,Et);Ht=tt.mul(Ht,Qt),Qt=tt.add(Nt,Yt),Ht=tt.sub(Ht,Qt),Qt=tt.add(yt,xt);let Vt=tt.add(vt,Ct);return Qt=tt.mul(Qt,Vt),Vt=tt.add(Nt,Ft),Qt=tt.sub(Qt,Vt),Vt=tt.add(bt,xt),St=tt.add(Et,Ct),Vt=tt.mul(Vt,St),St=tt.add(Yt,Ft),Vt=tt.sub(Vt,St),kt=tt.mul(It,Qt),St=tt.mul(Ot,Ft),kt=tt.add(St,kt),St=tt.sub(Yt,kt),kt=tt.add(Yt,kt),At=tt.mul(St,kt),Yt=tt.add(Nt,Nt),Yt=tt.add(Yt,Nt),Ft=tt.mul(It,Ft),Qt=tt.mul(Ot,Qt),Yt=tt.add(Yt,Ft),Ft=tt.sub(Nt,Ft),Ft=tt.mul(It,Ft),Qt=tt.add(Qt,Ft),Nt=tt.mul(Yt,Qt),At=tt.add(At,Nt),Nt=tt.mul(Vt,Qt),St=tt.mul(Ht,St),St=tt.sub(St,Nt),Nt=tt.mul(Ht,Yt),kt=tt.mul(Vt,kt),kt=tt.add(kt,Nt),new ht(St,At,kt)}subtract(gt){return this.add(gt.negate())}is0(){return this.equals(ht.ZERO)}wNAF(gt){return ft.wNAFCached(this,gt,ht.normalizeZ)}multiplyUnsafe(gt){aInRange("scalar",gt,_0n$3,o.n);const yt=ht.ZERO;if(gt===_0n$3)return yt;if(gt===_1n$5)return this;const{endo:bt}=o;if(!bt)return ft.unsafeLadder(this,gt);let{k1neg:xt,k1:vt,k2neg:Et,k2:Ct}=bt.splitScalar(gt),St=yt,At=yt,kt=this;for(;vt>_0n$3||Ct>_0n$3;)vt&_1n$5&&(St=St.add(kt)),Ct&_1n$5&&(At=At.add(kt)),kt=kt.double(),vt>>=_1n$5,Ct>>=_1n$5;return xt&&(St=St.negate()),Et&&(At=At.negate()),At=new ht(tt.mul(At.px,bt.beta),At.py,At.pz),St.add(At)}multiply(gt){const{endo:yt,n:bt}=o;aInRange("scalar",gt,_1n$5,bt);let xt,vt;if(yt){const{k1neg:Et,k1:Ct,k2neg:St,k2:At}=yt.splitScalar(gt);let{p:kt,f:It}=this.wNAF(Ct),{p:Ot,f:Nt}=this.wNAF(At);kt=ft.constTimeNegate(Et,kt),Ot=ft.constTimeNegate(St,Ot),Ot=new ht(tt.mul(Ot.px,yt.beta),Ot.py,Ot.pz),xt=kt.add(Ot),vt=It.add(Nt)}else{const{p:Et,f:Ct}=this.wNAF(gt);xt=Et,vt=Ct}return ht.normalizeZ([xt,vt])[0]}multiplyAndAddUnsafe(gt,yt,bt){const xt=ht.BASE,vt=(Ct,St)=>St===_0n$3||St===_1n$5||!Ct.equals(xt)?Ct.multiplyUnsafe(St):Ct.multiply(St),Et=vt(this,yt).add(vt(gt,bt));return Et.is0()?void 0:Et}toAffine(gt){return lt(this,gt)}isTorsionFree(){const{h:gt,isTorsionFree:yt}=o;if(gt===_1n$5)return!0;if(yt)return yt(ht,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:gt,clearCofactor:yt}=o;return gt===_1n$5?this:yt?yt(ht,this):this.multiplyUnsafe(o.h)}toRawBytes(gt=!0){return abool("isCompressed",gt),this.assertValidity(),nt(ht,this,gt)}toHex(gt=!0){return abool("isCompressed",gt),bytesToHex$2(this.toRawBytes(gt))}}ht.BASE=new ht(o.Gx,o.Gy,tt.ONE),ht.ZERO=new ht(tt.ZERO,tt.ONE,tt.ZERO);const mt=o.nBitLength,ft=wNAF(ht,o.endo?Math.ceil(mt/2):mt);return{CURVE:o,ProjectivePoint:ht,normPrivateKeyToScalar:at,weierstrassEquation:it,isWithinCurveOrder:st}}function validateOpts$2(et){const o=validateBasic(et);return validateObject(o,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...o})}function weierstrass$1(et){const o=validateOpts$2(et),{Fp:tt,n:rt}=o,nt=tt.BYTES+1,ot=2*tt.BYTES+1;function it(Ft){return mod$1(Ft,rt)}function st(Ft){return invert$1(Ft,rt)}const{ProjectivePoint:at,normPrivateKeyToScalar:ct,weierstrassEquation:lt,isWithinCurveOrder:dt}=weierstrassPoints({...o,toBytes(Ft,Ht,Qt){const Vt=Ht.toAffine(),Bt=tt.toBytes(Vt.x),Wt=concatBytes$1;return abool("isCompressed",Qt),Qt?Wt(Uint8Array.from([Ht.hasEvenY()?2:3]),Bt):Wt(Uint8Array.from([4]),Bt,tt.toBytes(Vt.y))},fromBytes(Ft){const Ht=Ft.length,Qt=Ft[0],Vt=Ft.subarray(1);if(Ht===nt&&(Qt===2||Qt===3)){const Bt=bytesToNumberBE(Vt);if(!inRange(Bt,_1n$5,tt.ORDER))throw new Error("Point is not on curve");const Wt=lt(Bt);let jt;try{jt=tt.sqrt(Wt)}catch(Pt){const Gt=Pt instanceof Error?": "+Pt.message:"";throw new Error("Point is not on curve"+Gt)}const Xt=(jt&_1n$5)===_1n$5;return(Qt&1)===1!==Xt&&(jt=tt.neg(jt)),{x:Bt,y:jt}}else if(Ht===ot&&Qt===4){const Bt=tt.fromBytes(Vt.subarray(0,tt.BYTES)),Wt=tt.fromBytes(Vt.subarray(tt.BYTES,2*tt.BYTES));return{x:Bt,y:Wt}}else throw new Error(`Point of length ${Ht} was invalid. Expected ${nt} compressed bytes or ${ot} uncompressed bytes`)}}),ht=Ft=>bytesToHex$2(numberToBytesBE(Ft,o.nByteLength));function mt(Ft){const Ht=rt>>_1n$5;return Ft>Ht}function ft(Ft){return mt(Ft)?it(-Ft):Ft}const pt=(Ft,Ht,Qt)=>bytesToNumberBE(Ft.slice(Ht,Qt));class gt{constructor(Ht,Qt,Vt){this.r=Ht,this.s=Qt,this.recovery=Vt,this.assertValidity()}static fromCompact(Ht){const Qt=o.nByteLength;return Ht=ensureBytes$1("compactSignature",Ht,Qt*2),new gt(pt(Ht,0,Qt),pt(Ht,Qt,2*Qt))}static fromDER(Ht){const{r:Qt,s:Vt}=DER.toSig(ensureBytes$1("DER",Ht));return new gt(Qt,Vt)}assertValidity(){aInRange("r",this.r,_1n$5,rt),aInRange("s",this.s,_1n$5,rt)}addRecoveryBit(Ht){return new gt(this.r,this.s,Ht)}recoverPublicKey(Ht){const{r:Qt,s:Vt,recovery:Bt}=this,Wt=Ct(ensureBytes$1("msgHash",Ht));if(Bt==null||![0,1,2,3].includes(Bt))throw new Error("recovery id invalid");const jt=Bt===2||Bt===3?Qt+o.n:Qt;if(jt>=tt.ORDER)throw new Error("recovery id 2 or 3 invalid");const Xt=Bt&1?"03":"02",Kt=at.fromHex(Xt+ht(jt)),Pt=st(jt),Gt=it(-Wt*Pt),tr=it(Vt*Pt),zt=at.BASE.multiplyAndAddUnsafe(Kt,Gt,tr);if(!zt)throw new Error("point at infinify");return zt.assertValidity(),zt}hasHighS(){return mt(this.s)}normalizeS(){return this.hasHighS()?new gt(this.r,it(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$2(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$2(this.toCompactHex())}toCompactHex(){return ht(this.r)+ht(this.s)}}const yt={isValidPrivateKey(Ft){try{return ct(Ft),!0}catch{return!1}},normPrivateKeyToScalar:ct,randomPrivateKey:()=>{const Ft=getMinHashLength(o.n);return mapHashToField(o.randomBytes(Ft),o.n)},precompute(Ft=8,Ht=at.BASE){return Ht._setWindowSize(Ft),Ht.multiply(BigInt(3)),Ht}};function bt(Ft,Ht=!0){return at.fromPrivateKey(Ft).toRawBytes(Ht)}function xt(Ft){const Ht=isBytes$2(Ft),Qt=typeof Ft=="string",Vt=(Ht||Qt)&&Ft.length;return Ht?Vt===nt||Vt===ot:Qt?Vt===2*nt||Vt===2*ot:Ft instanceof at}function vt(Ft,Ht,Qt=!0){if(xt(Ft))throw new Error("first arg must be private key");if(!xt(Ht))throw new Error("second arg must be public key");return at.fromHex(Ht).multiply(ct(Ft)).toRawBytes(Qt)}const Et=o.bits2int||function(Ft){const Ht=bytesToNumberBE(Ft),Qt=Ft.length*8-o.nBitLength;return Qt>0?Ht>>BigInt(Qt):Ht},Ct=o.bits2int_modN||function(Ft){return it(Et(Ft))},St=bitMask(o.nBitLength);function At(Ft){return aInRange(`num < 2^${o.nBitLength}`,Ft,_0n$3,St),numberToBytesBE(Ft,o.nByteLength)}function kt(Ft,Ht,Qt=It){if(["recovered","canonical"].some(rr=>rr in Qt))throw new Error("sign() legacy options not supported");const{hash:Vt,randomBytes:Bt}=o;let{lowS:Wt,prehash:jt,extraEntropy:Xt}=Qt;Wt==null&&(Wt=!0),Ft=ensureBytes$1("msgHash",Ft),validateSigVerOpts(Qt),jt&&(Ft=ensureBytes$1("prehashed msgHash",Vt(Ft)));const Kt=Ct(Ft),Pt=ct(Ht),Gt=[At(Pt),At(Kt)];if(Xt!=null&&Xt!==!1){const rr=Xt===!0?Bt(tt.BYTES):Xt;Gt.push(ensureBytes$1("extraEntropy",rr))}const tr=concatBytes$1(...Gt),zt=Kt;function lr(rr){const Jt=Et(rr);if(!dt(Jt))return;const Rt=st(Jt),Mt=at.BASE.multiply(Jt).toAffine(),Ut=it(Mt.x);if(Ut===_0n$3)return;const Zt=it(Rt*it(zt+Ut*Pt));if(Zt===_0n$3)return;let nr=(Mt.x===Ut?0:2)|Number(Mt.y&_1n$5),ar=Zt;return Wt&&mt(Zt)&&(ar=ft(Zt),nr^=1),new gt(Ut,ar,nr)}return{seed:tr,k2sig:lr}}const It={lowS:o.lowS,prehash:!1},Ot={lowS:o.lowS,prehash:!1};function Nt(Ft,Ht,Qt=It){const{seed:Vt,k2sig:Bt}=kt(Ft,Ht,Qt),Wt=o;return createHmacDrbg(Wt.hash.outputLen,Wt.nByteLength,Wt.hmac)(Vt,Bt)}at.BASE._setWindowSize(8);function Yt(Ft,Ht,Qt,Vt=Ot){var Mt;const Bt=Ft;if(Ht=ensureBytes$1("msgHash",Ht),Qt=ensureBytes$1("publicKey",Qt),"strict"in Vt)throw new Error("options.strict was renamed to lowS");validateSigVerOpts(Vt);const{lowS:Wt,prehash:jt}=Vt;let Xt,Kt;try{if(typeof Bt=="string"||isBytes$2(Bt))try{Xt=gt.fromDER(Bt)}catch(Ut){if(!(Ut instanceof DER.Err))throw Ut;Xt=gt.fromCompact(Bt)}else if(typeof Bt=="object"&&typeof Bt.r=="bigint"&&typeof Bt.s=="bigint"){const{r:Ut,s:Zt}=Bt;Xt=new gt(Ut,Zt)}else throw new Error("PARSE");Kt=at.fromHex(Qt)}catch(Ut){if(Ut.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Wt&&Xt.hasHighS())return!1;jt&&(Ht=o.hash(Ht));const{r:Pt,s:Gt}=Xt,tr=Ct(Ht),zt=st(Gt),lr=it(tr*zt),rr=it(Pt*zt),Jt=(Mt=at.BASE.multiplyAndAddUnsafe(Kt,lr,rr))==null?void 0:Mt.toAffine();return Jt?it(Jt.x)===Pt:!1}return{CURVE:o,getPublicKey:bt,getSharedSecret:vt,sign:Nt,verify:Yt,ProjectivePoint:at,Signature:gt,utils:yt}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(et){return{hash:et,hmac:(o,...tt)=>hmac(et,o,concatBytes$2(...tt)),randomBytes:randomBytes$1}}function createCurve(et,o){const tt=rt=>weierstrass$1({...et,...getHash(rt)});return Object.freeze({...tt(o),create:tt})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$4=BigInt(1),_2n$3=BigInt(2),divNearest$1=(et,o)=>(et+o/_2n$3)/o;function sqrtMod$1(et){const o=secp256k1P,tt=BigInt(3),rt=BigInt(6),nt=BigInt(11),ot=BigInt(22),it=BigInt(23),st=BigInt(44),at=BigInt(88),ct=et*et*et%o,lt=ct*ct*et%o,dt=pow2$1(lt,tt,o)*lt%o,ht=pow2$1(dt,tt,o)*lt%o,mt=pow2$1(ht,_2n$3,o)*ct%o,ft=pow2$1(mt,nt,o)*mt%o,pt=pow2$1(ft,ot,o)*ft%o,gt=pow2$1(pt,st,o)*pt%o,yt=pow2$1(gt,at,o)*gt%o,bt=pow2$1(yt,st,o)*pt%o,xt=pow2$1(bt,tt,o)*lt%o,vt=pow2$1(xt,it,o)*ft%o,Et=pow2$1(vt,rt,o)*ct%o,Ct=pow2$1(Et,_2n$3,o);if(!Fp$1.eql(Fp$1.sqr(Ct),et))throw new Error("Cannot find square root");return Ct}const Fp$1=Field$1(secp256k1P,void 0,void 0,{sqrt:sqrtMod$1}),secp256k1=createCurve({a:BigInt(0),b:BigInt(7),Fp:Fp$1,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:et=>{const o=secp256k1N,tt=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),rt=-_1n$4*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),nt=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),ot=tt,it=BigInt("0x100000000000000000000000000000000"),st=divNearest$1(ot*et,o),at=divNearest$1(-rt*et,o);let ct=mod$1(et-st*tt-at*nt,o),lt=mod$1(-st*rt-at*ot,o);const dt=ct>it,ht=lt>it;if(dt&&(ct=o-ct),ht&&(lt=o-lt),ct>it||lt>it)throw new Error("splitScalar: Endomorphism failed, k="+et);return{k1neg:dt,k1:ct,k2neg:ht,k2:lt}}}},sha256$3);BigInt(0);secp256k1.ProjectivePoint;function getAction(et,o,tt){const rt=et[o.name];if(typeof rt=="function")return rt;const nt=et[tt];return typeof nt=="function"?nt:ot=>o(et,ot)}const version$6="2.13.8",getVersion$1=()=>`@wagmi/core@${version$6}`;var __classPrivateFieldGet$2=function(et,o,tt,rt){if(tt==="a"&&!rt)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?et!==o||!rt:!o.has(et))throw new TypeError("Cannot read private member from an object whose class did not declare it");return tt==="m"?rt:tt==="a"?rt.call(et):rt?rt.value:o.get(et)},_BaseError_instances,_BaseError_walk;let BaseError$1=class _s extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return getVersion$1()}constructor(o,tt={}){var ot;super(),_BaseError_instances.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const rt=tt.cause instanceof _s?tt.cause.details:(ot=tt.cause)!=null&&ot.message?tt.cause.message:tt.details,nt=tt.cause instanceof _s&&tt.cause.docsPath||tt.docsPath;this.message=[o||"An error occurred.","",...tt.metaMessages?[...tt.metaMessages,""]:[],...nt?[`Docs: ${this.docsBaseUrl}${nt}.html${tt.docsSlug?`#${tt.docsSlug}`:""}`]:[],...rt?[`Details: ${rt}`]:[],`Version: ${this.version}`].join(` -`),tt.cause&&(this.cause=tt.cause),this.details=rt,this.docsPath=nt,this.metaMessages=tt.metaMessages,this.shortMessage=o}walk(o){return __classPrivateFieldGet$2(this,_BaseError_instances,"m",_BaseError_walk).call(this,this,o)}};_BaseError_instances=new WeakSet,_BaseError_walk=function et(o,tt){return tt!=null&&tt(o)?o:o.cause?__classPrivateFieldGet$2(this,_BaseError_instances,"m",et).call(this,o.cause,tt):o};class ChainNotConfiguredError extends BaseError$1{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class ConnectorAlreadyConnectedError extends BaseError$1{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class ConnectorNotConnectedError extends BaseError$1{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class ConnectorAccountNotFoundError extends BaseError$1{constructor({address:o,connector:tt}){super(`Account "${o}" not found for connector "${tt.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class ConnectorChainMismatchError extends BaseError$1{constructor({connectionChainId:o,connectorChainId:tt}){super(`The current chain of the connector (id: ${tt}) does not match the connection's chain (id: ${o}).`,{metaMessages:[`Current Chain ID: ${tt}`,`Expected Chain ID: ${o}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class ConnectorUnavailableReconnectingError extends BaseError$1{constructor({connector:o}){super(`Connector "${o.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uuid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function connect$1(et,o){var rt;let tt;if(typeof o.connector=="function"?tt=et._internal.connectors.setup(o.connector):tt=o.connector,tt.uid===et.state.current)throw new ConnectorAlreadyConnectedError;try{et.setState(it=>({...it,status:"connecting"})),tt.emitter.emit("message",{type:"connecting"});const nt=await tt.connect({chainId:o.chainId}),ot=nt.accounts;return tt.emitter.off("connect",et._internal.events.connect),tt.emitter.on("change",et._internal.events.change),tt.emitter.on("disconnect",et._internal.events.disconnect),await((rt=et.storage)==null?void 0:rt.setItem("recentConnectorId",tt.id)),et.setState(it=>({...it,connections:new Map(it.connections).set(tt.uid,{accounts:ot,chainId:nt.chainId,connector:tt}),current:tt.uid,status:"connected"})),{accounts:ot,chainId:nt.chainId}}catch(nt){throw et.setState(ot=>({...ot,status:ot.current?"connected":"disconnected"})),nt}}const size$1=256;let index$3=size$1,buffer$2;function uid$1(et=11){if(!buffer$2||index$3+et>size$1*2){buffer$2="",index$3=0;for(let o=0;o{const bt=yt(gt);for(const vt in ft)delete bt[vt];const xt={...gt,...bt};return Object.assign(xt,{extend:pt(xt)})}}return Object.assign(ft,{extend:pt(ft)})}function createTransport({key:et,name:o,request:tt,retryCount:rt=3,retryDelay:nt=150,timeout:ot,type:it},st){const at=uid$1();return{config:{key:et,name:o,request:tt,retryCount:rt,retryDelay:nt,timeout:ot,type:it},request:buildRequest(tt,{retryCount:rt,retryDelay:nt,uid:at}),value:st}}function custom$1(et,o={}){const{key:tt="custom",name:rt="Custom Provider",retryDelay:nt}=o;return({retryCount:ot})=>createTransport({key:tt,name:rt,request:et.request.bind(et),retryCount:o.retryCount??ot,retryDelay:nt,type:"custom"})}class UrlRequiredError extends BaseError$3{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function http(et,o={}){const{batch:tt,fetchOptions:rt,key:nt="http",name:ot="HTTP JSON-RPC",onFetchRequest:it,onFetchResponse:st,retryDelay:at}=o;return({chain:ct,retryCount:lt,timeout:dt})=>{const{batchSize:ht=1e3,wait:mt=0}=typeof tt=="object"?tt:{},ft=o.retryCount??lt,pt=dt??o.timeout??1e4,gt=ct==null?void 0:ct.rpcUrls.default.http[0];if(!gt)throw new UrlRequiredError;const yt=getHttpRpcClient(gt,{fetchOptions:rt,onRequest:it,onResponse:st,timeout:pt});return createTransport({key:nt,name:ot,async request({method:bt,params:xt}){const vt={method:bt,params:xt},{schedule:Et}=createBatchScheduler({id:gt,wait:mt,shouldSplitBatch(kt){return kt.length>ht},fn:kt=>yt.request({body:kt}),sort:(kt,It)=>kt.id-It.id}),Ct=async kt=>tt?Et(kt):[await yt.request({body:kt})],[{error:St,result:At}]=await Ct(vt);if(St)throw new RpcRequestError({body:vt,error:St,url:gt});return At},retryCount:ft,retryDelay:at,timeout:pt,type:"http"},{fetchOptions:rt,url:gt})}}async function getConnectorClient(et,o={}){let tt;if(o.connector){const{connector:ct}=o;if(et.state.status==="reconnecting"&&!ct.getAccounts&&!ct.getChainId)throw new ConnectorUnavailableReconnectingError({connector:ct});const[lt,dt]=await Promise.all([ct.getAccounts(),ct.getChainId()]);tt={accounts:lt,chainId:dt,connector:ct}}else tt=et.state.connections.get(et.state.current);if(!tt)throw new ConnectorNotConnectedError;const rt=o.chainId??tt.chainId,nt=await tt.connector.getChainId();if(nt!==tt.chainId)throw new ConnectorChainMismatchError({connectionChainId:tt.chainId,connectorChainId:nt});const ot=tt.connector;if(ot.getClient)return ot.getClient({chainId:rt});const it=parseAccount(o.account??tt.accounts[0]);if(it.address=getAddress(it.address),o.account&&!tt.accounts.some(ct=>ct.toLowerCase()===it.address.toLowerCase()))throw new ConnectorAccountNotFoundError({address:it.address,connector:ot});const st=et.chains.find(ct=>ct.id===rt),at=await tt.connector.getProvider({chainId:rt});return createClient({account:it,chain:st,name:"Connector Client",transport:ct=>custom$1(at)({...ct,retryCount:0})})}async function disconnect(et,o={}){var nt,ot;let tt;if(o.connector)tt=o.connector;else{const{connections:it,current:st}=et.state,at=it.get(st);tt=at==null?void 0:at.connector}const rt=et.state.connections;tt&&(await tt.disconnect(),tt.emitter.off("change",et._internal.events.change),tt.emitter.off("disconnect",et._internal.events.disconnect),tt.emitter.on("connect",et._internal.events.connect),rt.delete(tt.uid)),et.setState(it=>{if(rt.size===0)return{...it,connections:new Map,current:null,status:"disconnected"};const st=rt.values().next().value;return{...it,connections:new Map(rt),current:st.connector.uid}});{const it=et.state.current;if(!it)return;const st=(nt=et.state.connections.get(it))==null?void 0:nt.connector;if(!st)return;await((ot=et.storage)==null?void 0:ot.setItem("recentConnectorId",st.id))}}function getUnit(et){return typeof et=="number"?et:et==="wei"?0:Math.abs(weiUnits[et])}function getAccount(et){const o=et.state.current,tt=et.state.connections.get(o),rt=tt==null?void 0:tt.accounts,nt=rt==null?void 0:rt[0],ot=et.chains.find(st=>st.id===(tt==null?void 0:tt.chainId)),it=et.state.status;switch(it){case"connected":return{address:nt,addresses:rt,chain:ot,chainId:tt==null?void 0:tt.chainId,connector:tt==null?void 0:tt.connector,isConnected:!0,isConnecting:!1,isDisconnected:!1,isReconnecting:!1,status:it};case"reconnecting":return{address:nt,addresses:rt,chain:ot,chainId:tt==null?void 0:tt.chainId,connector:tt==null?void 0:tt.connector,isConnected:!!nt,isConnecting:!1,isDisconnected:!1,isReconnecting:!0,status:it};case"connecting":return{address:nt,addresses:rt,chain:ot,chainId:tt==null?void 0:tt.chainId,connector:tt==null?void 0:tt.connector,isConnected:!1,isConnecting:!0,isDisconnected:!1,isReconnecting:!1,status:it};case"disconnected":return{address:void 0,addresses:void 0,chain:void 0,chainId:void 0,connector:void 0,isConnected:!1,isConnecting:!1,isDisconnected:!0,isReconnecting:!1,status:it}}}async function multicall(et,o){const{allowFailure:tt=!0,chainId:rt,contracts:nt,...ot}=o,it=et.getClient({chainId:rt});return getAction(it,multicall$1,"multicall")({allowFailure:tt,contracts:nt,...ot})}function readContract(et,o){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,readContract$1,"readContract")(rt)}async function readContracts(et,o){var st;const{allowFailure:tt=!0,blockNumber:rt,blockTag:nt,...ot}=o,it=o.contracts;try{const at={};for(const[ht,mt]of it.entries()){const ft=mt.chainId??et.state.chainId;at[ft]||(at[ft]=[]),(st=at[ft])==null||st.push({contract:mt,index:ht})}const ct=()=>Object.entries(at).map(([ht,mt])=>multicall(et,{...ot,allowFailure:tt,blockNumber:rt,blockTag:nt,chainId:Number.parseInt(ht),contracts:mt.map(({contract:ft})=>ft)})),lt=(await Promise.all(ct())).flat(),dt=Object.values(at).flatMap(ht=>ht.map(({index:mt})=>mt));return lt.reduce((ht,mt,ft)=>(ht&&(ht[dt[ft]]=mt),ht),[])}catch(at){if(at instanceof ContractFunctionExecutionError)throw at;const ct=()=>it.map(lt=>readContract(et,{...lt,blockNumber:rt,blockTag:nt}));return tt?(await Promise.allSettled(ct())).map(lt=>lt.status==="fulfilled"?{result:lt.value,status:"success"}:{error:lt.reason,result:void 0,status:"failure"}):await Promise.all(ct())}}async function getBalance(et,o){const{address:tt,blockNumber:rt,blockTag:nt,chainId:ot,token:it,unit:st="ether"}=o;if(it)try{return getTokenBalance(et,{balanceAddress:tt,chainId:ot,symbolType:"string",tokenAddress:it})}catch(ht){if(ht instanceof ContractFunctionExecutionError){const mt=await getTokenBalance(et,{balanceAddress:tt,chainId:ot,symbolType:"bytes32",tokenAddress:it}),ft=hexToString(trim$1(mt.symbol,{dir:"right"}));return{...mt,symbol:ft}}throw ht}const at=et.getClient({chainId:ot}),lt=await getAction(at,getBalance$1,"getBalance")(rt?{address:tt,blockNumber:rt}:{address:tt,blockTag:nt}),dt=et.chains.find(ht=>ht.id===ot)??at.chain;return{decimals:dt.nativeCurrency.decimals,formatted:formatUnits(lt,getUnit(st)),symbol:dt.nativeCurrency.symbol,value:lt}}async function getTokenBalance(et,o){const{balanceAddress:tt,chainId:rt,symbolType:nt,tokenAddress:ot,unit:it}=o,st={abi:[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:nt}]}],address:ot},[at,ct,lt]=await readContracts(et,{allowFailure:!1,contracts:[{...st,functionName:"balanceOf",args:[tt],chainId:rt},{...st,functionName:"decimals",chainId:rt},{...st,functionName:"symbol",chainId:rt}]}),dt=formatUnits(at??"0",getUnit(it??ct));return{decimals:ct,formatted:dt,symbol:lt,value:at}}function getBlockNumber(et,o={}){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,getBlockNumber$1,"getBlockNumber")(rt)}function getChainId(et){return et.state.chainId}function deepEqual(et,o){if(et===o)return!0;if(et&&o&&typeof et=="object"&&typeof o=="object"){if(et.constructor!==o.constructor)return!1;let tt,rt;if(Array.isArray(et)&&Array.isArray(o)){if(tt=et.length,tt!==o.length)return!1;for(rt=tt;rt--!==0;)if(!deepEqual(et[rt],o[rt]))return!1;return!0}if(et.valueOf!==Object.prototype.valueOf)return et.valueOf()===o.valueOf();if(et.toString!==Object.prototype.toString)return et.toString()===o.toString();const nt=Object.keys(et);if(tt=nt.length,tt!==Object.keys(o).length)return!1;for(rt=tt;rt--!==0;)if(!Object.prototype.hasOwnProperty.call(o,nt[rt]))return!1;for(rt=tt;rt--!==0;){const ot=nt[rt];if(ot&&!deepEqual(et[ot],o[ot]))return!1}return!0}return et!==et&&o!==o}let previousChains=[];function getChains(et){const o=et.chains;return deepEqual(previousChains,o)?previousChains:(previousChains=o,o)}let previousConnections=[];function getConnections(et){const o=[...et.state.connections.values()];return et.state.status==="reconnecting"||deepEqual(previousConnections,o)?previousConnections:(previousConnections=o,o)}let previousConnectors=[];function getConnectors(et){const o=et.connectors;return deepEqual(previousConnectors,o)?previousConnectors:(previousConnectors=o,o)}function getEnsAddress(et,o){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,getEnsAddress$1,"getEnsAddress")(rt)}function getEnsAvatar(et,o){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,getEnsAvatar$1,"getEnsAvatar")(rt)}function getEnsName(et,o){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,getEnsName$1,"getEnsName")(rt)}let isReconnecting=!1;async function reconnect(et,o={}){var ct,lt;if(isReconnecting)return[];isReconnecting=!0,et.setState(dt=>({...dt,status:dt.current?"reconnecting":"connecting"}));const tt=[];if((ct=o.connectors)!=null&&ct.length)for(const dt of o.connectors){let ht;typeof dt=="function"?ht=et._internal.connectors.setup(dt):ht=dt,tt.push(ht)}else tt.push(...et.connectors);let rt;try{rt=await((lt=et.storage)==null?void 0:lt.getItem("recentConnectorId"))}catch{}const nt={};for(const[,dt]of et.state.connections)nt[dt.connector.id]=1;rt&&(nt[rt]=0);const ot=Object.keys(nt).length>0?[...tt].sort((dt,ht)=>(nt[dt.id]??10)-(nt[ht.id]??10)):tt;let it=!1;const st=[],at=[];for(const dt of ot){const ht=await dt.getProvider().catch(()=>{});if(!ht||at.some(pt=>pt===ht)||!await dt.isAuthorized())continue;const ft=await dt.connect({isReconnecting:!0}).catch(()=>null);ft&&(dt.emitter.off("connect",et._internal.events.connect),dt.emitter.on("change",et._internal.events.change),dt.emitter.on("disconnect",et._internal.events.disconnect),et.setState(pt=>{const gt=new Map(it?pt.connections:new Map).set(dt.uid,{accounts:ft.accounts,chainId:ft.chainId,connector:dt});return{...pt,current:it?pt.current:dt.uid,connections:gt}}),st.push({accounts:ft.accounts,chainId:ft.chainId,connector:dt}),at.push(ht),it=!0)}return(et.state.status==="reconnecting"||et.state.status==="connecting")&&(it?et.setState(dt=>({...dt,status:"connected"})):et.setState(dt=>({...dt,connections:new Map,current:null,status:"disconnected"}))),isReconnecting=!1,st}async function signMessage(et,o){const{account:tt,connector:rt,...nt}=o;let ot;return typeof tt=="object"&&tt.type==="local"?ot=et.getClient():ot=await getConnectorClient(et,{account:tt,connector:rt}),getAction(ot,signMessage$1,"signMessage")({...nt,...tt?{account:tt}:{}})}class ProviderNotFoundError extends BaseError$1{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}class SwitchChainNotSupportedError extends BaseError$1{constructor({connector:o}){super(`"${o.name}" does not support programmatic chain switching.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SwitchChainNotSupportedError"})}}async function switchChain(et,o){var it;const{addEthereumChainParameter:tt,chainId:rt}=o,nt=et.state.connections.get(((it=o.connector)==null?void 0:it.uid)??et.state.current);if(nt){const st=nt.connector;if(!st.switchChain)throw new SwitchChainNotSupportedError({connector:st});return await st.switchChain({addEthereumChainParameter:tt,chainId:rt})}const ot=et.chains.find(st=>st.id===rt);if(!ot)throw new ChainNotConfiguredError;return et.setState(st=>({...st,chainId:rt})),ot}function watchAccount(et,o){const{onChange:tt}=o;return et.subscribe(()=>getAccount(et),tt,{equalityFn(rt,nt){const{connector:ot,...it}=rt,{connector:st,...at}=nt;return deepEqual(it,at)&&(ot==null?void 0:ot.id)===(st==null?void 0:st.id)&&(ot==null?void 0:ot.uid)===(st==null?void 0:st.uid)}})}function watchBlockNumber(et,o){const{syncConnectedChain:tt=et._internal.syncConnectedChain,...rt}=o;let nt;const ot=at=>{nt&&nt();const ct=et.getClient({chainId:at});return nt=getAction(ct,watchBlockNumber$1,"watchBlockNumber")(rt),nt},it=ot(o.chainId);let st;return tt&&!o.chainId&&(st=et.subscribe(({chainId:at})=>at,async at=>ot(at))),()=>{it==null||it(),st==null||st()}}function watchChainId(et,o){const{onChange:tt}=o;return et.subscribe(rt=>rt.chainId,tt)}function watchConnections(et,o){const{onChange:tt}=o;return et.subscribe(()=>getConnections(et),tt,{equalityFn:deepEqual})}function watchConnectors(et,o){const{onChange:tt}=o;return et._internal.connectors.subscribe((rt,nt)=>{tt(Object.values(rt),nt)})}function createConnector(et){return et}const supportsSimulationIdRegex=/(rabby|trustwallet)/,targetMap={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(et){return et!=null&&et.coinbaseWalletExtension?et.coinbaseWalletExtension:findProvider(et,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(et){return findProvider(et,o=>{if(!o.isMetaMask||o.isBraveWallet&&!o._events&&!o._state)return!1;const tt=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPortal","isRabby","isTokenPocket","isTokenary","isZerion"];for(const rt of tt)if(o[rt])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(et){var o,tt;return(o=et==null?void 0:et.phantom)!=null&&o.ethereum?(tt=et.phantom)==null?void 0:tt.ethereum:findProvider(et,"isPhantom")}}};injected.type="injected";function injected(et={}){const{shimDisconnect:o=!0,unstable_shimAsyncInject:tt}=et;function rt(){const at=et.target;if(typeof at=="function"){const ct=at();if(ct)return ct}return typeof at=="object"?at:typeof at=="string"?{...targetMap[at]??{id:at,name:`${at[0].toUpperCase()}${at.slice(1)}`,provider:`is${at[0].toUpperCase()}${at.slice(1)}`}}:{id:"injected",name:"Injected",provider(ct){return ct==null?void 0:ct.ethereum}}}let nt,ot,it,st;return at=>({get icon(){return rt().icon},get id(){return rt().id},get name(){return rt().name},get supportsSimulation(){return supportsSimulationIdRegex.test(this.id.toLowerCase())},type:injected.type,async setup(){const ct=await this.getProvider();ct!=null&&ct.on&&et.target&&(it||(it=this.onConnect.bind(this),ct.on("connect",it)),nt||(nt=this.onAccountsChanged.bind(this),ct.on("accountsChanged",nt)))},async connect({chainId:ct,isReconnecting:lt}={}){var mt,ft,pt,gt,yt,bt;const dt=await this.getProvider();if(!dt)throw new ProviderNotFoundError;let ht=[];if(lt)ht=await this.getAccounts().catch(()=>[]);else if(o)try{ht=(gt=(pt=(ft=(mt=(await dt.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])==null?void 0:mt.caveats)==null?void 0:ft[0])==null?void 0:pt.value)==null?void 0:gt.map(vt=>getAddress(vt)),ht.length>0&&(ht=await this.getAccounts())}catch(xt){const vt=xt;if(vt.code===UserRejectedRequestError.code)throw new UserRejectedRequestError(vt);if(vt.code===ResourceUnavailableRpcError.code)throw vt}try{!(ht!=null&&ht.length)&&!lt&&(ht=(await dt.request({method:"eth_requestAccounts"})).map(Et=>getAddress(Et))),it&&(dt.removeListener("connect",it),it=void 0),nt||(nt=this.onAccountsChanged.bind(this),dt.on("accountsChanged",nt)),ot||(ot=this.onChainChanged.bind(this),dt.on("chainChanged",ot)),st||(st=this.onDisconnect.bind(this),dt.on("disconnect",st));let xt=await this.getChainId();if(ct&&xt!==ct){const vt=await this.switchChain({chainId:ct}).catch(Et=>{if(Et.code===UserRejectedRequestError.code)throw Et;return{id:xt}});xt=(vt==null?void 0:vt.id)??xt}return o&&await((yt=at.storage)==null?void 0:yt.removeItem(`${this.id}.disconnected`)),et.target||await((bt=at.storage)==null?void 0:bt.setItem("injected.connected",!0)),{accounts:ht,chainId:xt}}catch(xt){const vt=xt;throw vt.code===UserRejectedRequestError.code?new UserRejectedRequestError(vt):vt.code===ResourceUnavailableRpcError.code?new ResourceUnavailableRpcError(vt):vt}},async disconnect(){var lt,dt;const ct=await this.getProvider();if(!ct)throw new ProviderNotFoundError;ot&&(ct.removeListener("chainChanged",ot),ot=void 0),st&&(ct.removeListener("disconnect",st),st=void 0),it||(it=this.onConnect.bind(this),ct.on("connect",it));try{await withTimeout(()=>ct.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}o&&await((lt=at.storage)==null?void 0:lt.setItem(`${this.id}.disconnected`,!0)),et.target||await((dt=at.storage)==null?void 0:dt.removeItem("injected.connected"))},async getAccounts(){const ct=await this.getProvider();if(!ct)throw new ProviderNotFoundError;return(await ct.request({method:"eth_accounts"})).map(dt=>getAddress(dt))},async getChainId(){const ct=await this.getProvider();if(!ct)throw new ProviderNotFoundError;const lt=await ct.request({method:"eth_chainId"});return Number(lt)},async getProvider(){if(typeof window>"u")return;let ct;const lt=rt();return typeof lt.provider=="function"?ct=lt.provider(window):typeof lt.provider=="string"?ct=findProvider(window,lt.provider):ct=lt.provider,ct&&!ct.removeListener&&("off"in ct&&typeof ct.off=="function"?ct.removeListener=ct.off:ct.removeListener=()=>{}),ct},async isAuthorized(){var ct,lt;try{if(o&&await((ct=at.storage)==null?void 0:ct.getItem(`${this.id}.disconnected`))||!et.target&&!await((lt=at.storage)==null?void 0:lt.getItem("injected.connected")))return!1;if(!await this.getProvider()){if(tt!==void 0&&tt!==!1){const ft=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",ft),!!await this.getProvider()),pt=typeof tt=="number"?tt:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(yt=>window.addEventListener("ethereum#initialized",()=>yt(ft()),{once:!0}))]:[],new Promise(yt=>setTimeout(()=>yt(ft()),pt))]))return!0}throw new ProviderNotFoundError}return!!(await withRetry(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:ct,chainId:lt}){var mt,ft,pt,gt;const dt=await this.getProvider();if(!dt)throw new ProviderNotFoundError;const ht=at.chains.find(yt=>yt.id===lt);if(!ht)throw new SwitchChainError(new ChainNotConfiguredError);try{return await Promise.all([dt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(lt)}]}).then(async()=>{await this.getChainId()===lt&&at.emitter.emit("change",{chainId:lt})}),new Promise(yt=>{const bt=xt=>{"chainId"in xt&&xt.chainId===lt&&(at.emitter.off("change",bt),yt())};at.emitter.on("change",bt)})]),ht}catch(yt){const bt=yt;if(bt.code===4902||((ft=(mt=bt==null?void 0:bt.data)==null?void 0:mt.originalError)==null?void 0:ft.code)===4902)try{const{default:xt,...vt}=ht.blockExplorers??{};let Et;ct!=null&&ct.blockExplorerUrls?Et=ct.blockExplorerUrls:xt&&(Et=[xt.url,...Object.values(vt).map(kt=>kt.url)]);let Ct;(pt=ct==null?void 0:ct.rpcUrls)!=null&&pt.length?Ct=ct.rpcUrls:Ct=[((gt=ht.rpcUrls.default)==null?void 0:gt.http[0])??""];const St={blockExplorerUrls:Et,chainId:numberToHex(lt),chainName:(ct==null?void 0:ct.chainName)??ht.name,iconUrls:ct==null?void 0:ct.iconUrls,nativeCurrency:(ct==null?void 0:ct.nativeCurrency)??ht.nativeCurrency,rpcUrls:Ct};if(await dt.request({method:"wallet_addEthereumChain",params:[St]}),await this.getChainId()!==lt)throw new UserRejectedRequestError(new Error("User rejected switch after adding network."));return ht}catch(xt){throw new UserRejectedRequestError(xt)}throw bt.code===UserRejectedRequestError.code?new UserRejectedRequestError(bt):new SwitchChainError(bt)}},async onAccountsChanged(ct){var lt;if(ct.length===0)this.onDisconnect();else if(at.emitter.listenerCount("connect")){const dt=(await this.getChainId()).toString();this.onConnect({chainId:dt}),o&&await((lt=at.storage)==null?void 0:lt.removeItem(`${this.id}.disconnected`))}else at.emitter.emit("change",{accounts:ct.map(dt=>getAddress(dt))})},onChainChanged(ct){const lt=Number(ct);at.emitter.emit("change",{chainId:lt})},async onConnect(ct){const lt=await this.getAccounts();if(lt.length===0)return;const dt=Number(ct.chainId);at.emitter.emit("connect",{accounts:lt,chainId:dt});const ht=await this.getProvider();ht&&(it&&(ht.removeListener("connect",it),it=void 0),nt||(nt=this.onAccountsChanged.bind(this),ht.on("accountsChanged",nt)),ot||(ot=this.onChainChanged.bind(this),ht.on("chainChanged",ot)),st||(st=this.onDisconnect.bind(this),ht.on("disconnect",st)))},async onDisconnect(ct){const lt=await this.getProvider();ct&&ct.code===1013&<&&(await this.getAccounts()).length||(at.emitter.emit("disconnect"),lt&&(ot&&(lt.removeListener("chainChanged",ot),ot=void 0),st&&(lt.removeListener("disconnect",st),st=void 0),it||(it=this.onConnect.bind(this),lt.on("connect",it))))}})}function findProvider(et,o){function tt(nt){return typeof o=="function"?o(nt):typeof o=="string"?nt[o]:!0}const rt=et.ethereum;if(rt!=null&&rt.providers)return rt.providers.find(nt=>tt(nt));if(rt&&tt(rt))return rt}function requestProviders(et){if(typeof window>"u")return;const o=tt=>et(tt.detail);return window.addEventListener("eip6963:announceProvider",o),window.dispatchEvent(new CustomEvent("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",o)}function createStore$1(){const et=new Set;let o=[];const tt=()=>requestProviders(nt=>{o.some(({info:ot})=>ot.uuid===nt.info.uuid)||(o=[...o,nt],et.forEach(ot=>ot(o,{added:[nt]})))});let rt=tt();return{_listeners(){return et},clear(){et.forEach(nt=>nt([],{removed:[...o]})),o=[]},destroy(){this.clear(),et.clear(),rt==null||rt()},findProvider({rdns:nt}){return o.find(ot=>ot.info.rdns===nt)},getProviders(){return o},reset(){this.clear(),rt==null||rt(),rt=tt()},subscribe(nt,{emitImmediately:ot}={}){return et.add(nt),ot&&nt(o,{added:o}),()=>et.delete(nt)}}}const __vite_import_meta_env__$2={BASE_URL:"/buddybook/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_WALLETCONNECT_PROJECT_ID:"1d93edc21291f98e3bed6ff7617ff539"},subscribeWithSelectorImpl=et=>(o,tt,rt)=>{const nt=rt.subscribe;return rt.subscribe=(it,st,at)=>{let ct=it;if(st){const lt=(at==null?void 0:at.equalityFn)||Object.is;let dt=it(rt.getState());ct=ht=>{const mt=it(ht);if(!lt(dt,mt)){const ft=dt;st(dt=mt,ft)}},at!=null&&at.fireImmediately&&st(dt,dt)}return nt(ct)},et(o,tt,rt)},subscribeWithSelector=subscribeWithSelectorImpl;function createJSONStorage(et,o){let tt;try{tt=et()}catch{return}return{getItem:nt=>{var ot;const it=at=>at===null?null:JSON.parse(at,void 0),st=(ot=tt.getItem(nt))!=null?ot:null;return st instanceof Promise?st.then(it):it(st)},setItem:(nt,ot)=>tt.setItem(nt,JSON.stringify(ot,void 0)),removeItem:nt=>tt.removeItem(nt)}}const toThenable=et=>o=>{try{const tt=et(o);return tt instanceof Promise?tt:{then(rt){return toThenable(rt)(tt)},catch(rt){return this}}}catch(tt){return{then(rt){return this},catch(rt){return toThenable(rt)(tt)}}}},oldImpl=(et,o)=>(tt,rt,nt)=>{let ot={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:gt=>gt,version:0,merge:(gt,yt)=>({...yt,...gt}),...o},it=!1;const st=new Set,at=new Set;let ct;try{ct=ot.getStorage()}catch{}if(!ct)return et((...gt)=>{console.warn(`[zustand persist middleware] Unable to update item '${ot.name}', the given storage is currently unavailable.`),tt(...gt)},rt,nt);const lt=toThenable(ot.serialize),dt=()=>{const gt=ot.partialize({...rt()});let yt;const bt=lt({state:gt,version:ot.version}).then(xt=>ct.setItem(ot.name,xt)).catch(xt=>{yt=xt});if(yt)throw yt;return bt},ht=nt.setState;nt.setState=(gt,yt)=>{ht(gt,yt),dt()};const mt=et((...gt)=>{tt(...gt),dt()},rt,nt);let ft;const pt=()=>{var gt;if(!ct)return;it=!1,st.forEach(bt=>bt(rt()));const yt=((gt=ot.onRehydrateStorage)==null?void 0:gt.call(ot,rt()))||void 0;return toThenable(ct.getItem.bind(ct))(ot.name).then(bt=>{if(bt)return ot.deserialize(bt)}).then(bt=>{if(bt)if(typeof bt.version=="number"&&bt.version!==ot.version){if(ot.migrate)return ot.migrate(bt.state,bt.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return bt.state}).then(bt=>{var xt;return ft=ot.merge(bt,(xt=rt())!=null?xt:mt),tt(ft,!0),dt()}).then(()=>{yt==null||yt(ft,void 0),it=!0,at.forEach(bt=>bt(ft))}).catch(bt=>{yt==null||yt(void 0,bt)})};return nt.persist={setOptions:gt=>{ot={...ot,...gt},gt.getStorage&&(ct=gt.getStorage())},clearStorage:()=>{ct==null||ct.removeItem(ot.name)},getOptions:()=>ot,rehydrate:()=>pt(),hasHydrated:()=>it,onHydrate:gt=>(st.add(gt),()=>{st.delete(gt)}),onFinishHydration:gt=>(at.add(gt),()=>{at.delete(gt)})},pt(),ft||mt},newImpl=(et,o)=>(tt,rt,nt)=>{let ot={storage:createJSONStorage(()=>localStorage),partialize:pt=>pt,version:0,merge:(pt,gt)=>({...gt,...pt}),...o},it=!1;const st=new Set,at=new Set;let ct=ot.storage;if(!ct)return et((...pt)=>{console.warn(`[zustand persist middleware] Unable to update item '${ot.name}', the given storage is currently unavailable.`),tt(...pt)},rt,nt);const lt=()=>{const pt=ot.partialize({...rt()});return ct.setItem(ot.name,{state:pt,version:ot.version})},dt=nt.setState;nt.setState=(pt,gt)=>{dt(pt,gt),lt()};const ht=et((...pt)=>{tt(...pt),lt()},rt,nt);let mt;const ft=()=>{var pt,gt;if(!ct)return;it=!1,st.forEach(bt=>{var xt;return bt((xt=rt())!=null?xt:ht)});const yt=((gt=ot.onRehydrateStorage)==null?void 0:gt.call(ot,(pt=rt())!=null?pt:ht))||void 0;return toThenable(ct.getItem.bind(ct))(ot.name).then(bt=>{if(bt)if(typeof bt.version=="number"&&bt.version!==ot.version){if(ot.migrate)return ot.migrate(bt.state,bt.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return bt.state}).then(bt=>{var xt;return mt=ot.merge(bt,(xt=rt())!=null?xt:ht),tt(mt,!0),lt()}).then(()=>{yt==null||yt(mt,void 0),mt=rt(),it=!0,at.forEach(bt=>bt(mt))}).catch(bt=>{yt==null||yt(void 0,bt)})};return nt.persist={setOptions:pt=>{ot={...ot,...pt},pt.storage&&(ct=pt.storage)},clearStorage:()=>{ct==null||ct.removeItem(ot.name)},getOptions:()=>ot,rehydrate:()=>ft(),hasHydrated:()=>it,onHydrate:pt=>(st.add(pt),()=>{st.delete(pt)}),onFinishHydration:pt=>(at.add(pt),()=>{at.delete(pt)})},ot.skipHydration||ft(),mt||ht},persistImpl=(et,o)=>"getStorage"in o||"serialize"in o||"deserialize"in o?((__vite_import_meta_env__$2?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),oldImpl(et,o)):newImpl(et,o),persist=persistImpl,__vite_import_meta_env__$1={BASE_URL:"/buddybook/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_WALLETCONNECT_PROJECT_ID:"1d93edc21291f98e3bed6ff7617ff539"},createStoreImpl=et=>{let o;const tt=new Set,rt=(at,ct)=>{const lt=typeof at=="function"?at(o):at;if(!Object.is(lt,o)){const dt=o;o=ct??typeof lt!="object"?lt:Object.assign({},o,lt),tt.forEach(ht=>ht(o,dt))}},nt=()=>o,st={setState:rt,getState:nt,subscribe:at=>(tt.add(at),()=>tt.delete(at)),destroy:()=>{(__vite_import_meta_env__$1?"production":void 0)!=="production"&&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."),tt.clear()}};return o=et(rt,nt,st),st},createStore=et=>et?createStoreImpl(et):createStoreImpl;var eventemitter3={exports:{}};(function(et){var o=Object.prototype.hasOwnProperty,tt="~";function rt(){}Object.create&&(rt.prototype=Object.create(null),new rt().__proto__||(tt=!1));function nt(at,ct,lt){this.fn=at,this.context=ct,this.once=lt||!1}function ot(at,ct,lt,dt,ht){if(typeof lt!="function")throw new TypeError("The listener must be a function");var mt=new nt(lt,dt||at,ht),ft=tt?tt+ct:ct;return at._events[ft]?at._events[ft].fn?at._events[ft]=[at._events[ft],mt]:at._events[ft].push(mt):(at._events[ft]=mt,at._eventsCount++),at}function it(at,ct){--at._eventsCount===0?at._events=new rt:delete at._events[ct]}function st(){this._events=new rt,this._eventsCount=0}st.prototype.eventNames=function(){var ct=[],lt,dt;if(this._eventsCount===0)return ct;for(dt in lt=this._events)o.call(lt,dt)&&ct.push(tt?dt.slice(1):dt);return Object.getOwnPropertySymbols?ct.concat(Object.getOwnPropertySymbols(lt)):ct},st.prototype.listeners=function(ct){var lt=tt?tt+ct:ct,dt=this._events[lt];if(!dt)return[];if(dt.fn)return[dt.fn];for(var ht=0,mt=dt.length,ft=new Array(mt);ht{let nt=rt;return(nt==null?void 0:nt.__type)==="bigint"&&(nt=BigInt(nt.value)),(nt==null?void 0:nt.__type)==="Map"&&(nt=new Map(nt.value)),(o==null?void 0:o(tt,nt))??nt})}function getReferenceKey(et,o){return et.slice(0,o).join(".")||"."}function getCutoff(et,o){const{length:tt}=et;for(let rt=0;rt{let it=ot;return typeof it=="bigint"&&(it={__type:"bigint",value:ot.toString()}),it instanceof Map&&(it={__type:"Map",value:Array.from(ot.entries())}),(o==null?void 0:o(nt,it))??it},rt),tt??void 0)}function createStorage(et){const{deserialize:o=deserialize$1,key:tt="wagmi",serialize:rt=serialize$1,storage:nt=noopStorage}=et;function ot(it){return it instanceof Promise?it.then(st=>st).catch(()=>null):it}return{...nt,key:tt,async getItem(it,st){const at=nt.getItem(`${tt}.${it}`),ct=await ot(at);return ct?o(ct)??null:st??null},async setItem(it,st){const at=`${tt}.${it}`;st===null?await ot(nt.removeItem(at)):await ot(nt.setItem(at,rt(st)))},async removeItem(it){await ot(nt.removeItem(`${tt}.${it}`))}}}const noopStorage={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},size=256;let index$2=size,buffer$1;function uid(et=11){if(!buffer$1||index$2+et>size*2){buffer$1="",index$2=0;for(let o=0;oot.chains),at=createStore(()=>[...ot.connectors??[],...nt?[]:(it==null?void 0:it.getProviders().map(lt))??[]].map(ct));function ct(Et){var At;const Ct=createEmitter(uid()),St={...Et({emitter:Ct,chains:st.getState(),storage:tt,transports:ot.transports}),emitter:Ct,uid:Ct.uid};return Ct.on("connect",xt),(At=St.setup)==null||At.call(St),St}function lt(Et){const{info:Ct}=Et,St=Et.provider;return injected({target:{...Ct,id:Ct.rdns,provider:St}})}const dt=new Map;function ht(Et={}){const Ct=Et.chainId??gt.getState().chainId,St=st.getState().find(kt=>kt.id===Ct);if(Et.chainId&&!St)throw new ChainNotConfiguredError;{const kt=dt.get(gt.getState().chainId);if(kt&&!St)return kt;if(!St)throw new ChainNotConfiguredError}{const kt=dt.get(Ct);if(kt)return kt}let At;if(ot.client)At=ot.client({chain:St});else{const kt=St.id,It=st.getState().map(Yt=>Yt.id),Ot={},Nt=Object.entries(ot);for(const[Yt,Ft]of Nt)if(!(Yt==="chains"||Yt==="client"||Yt==="connectors"||Yt==="transports"))if(typeof Ft=="object")if(kt in Ft)Ot[Yt]=Ft[kt];else{if(It.some(Qt=>Qt in Ft))continue;Ot[Yt]=Ft}else Ot[Yt]=Ft;At=createClient({...Ot,chain:St,batch:Ot.batch??{multicall:!0},transport:Yt=>ot.transports[kt]({...Yt,connectors:at})})}return dt.set(Ct,At),At}function mt(){return{chainId:st.getState()[0].id,connections:new Map,current:null,status:"disconnected"}}let ft;const pt="0.0.0-canary-";version$6.startsWith(pt)?ft=Number.parseInt(version$6.replace(pt,"")):ft=Number.parseInt(version$6.split(".")[0]??"0");const gt=createStore(subscribeWithSelector(tt?persist(mt,{migrate(Et,Ct){if(Ct===ft)return Et;const St=mt(),At=yt(Et,St.chainId);return{...St,chainId:At}},name:"store",partialize(Et){return{connections:{__type:"Map",value:Array.from(Et.connections.entries()).map(([Ct,St])=>{const{id:At,name:kt,type:It,uid:Ot}=St.connector;return[Ct,{...St,connector:{id:At,name:kt,type:It,uid:Ot}}]})},chainId:Et.chainId,current:Et.current}},merge(Et,Ct){typeof Et=="object"&&Et&&"status"in Et&&delete Et.status;const St=yt(Et,Ct.chainId);return{...Ct,...Et,chainId:St}},skipHydration:nt,storage:tt,version:ft}):mt));function yt(Et,Ct){return Et&&typeof Et=="object"&&"chainId"in Et&&typeof Et.chainId=="number"&&st.getState().some(St=>St.id===Et.chainId)?Et.chainId:Ct}rt&>.subscribe(({connections:Et,current:Ct})=>{var St;return Ct?(St=Et.get(Ct))==null?void 0:St.chainId:void 0},Et=>{if(st.getState().some(St=>St.id===Et))return gt.setState(St=>({...St,chainId:Et??St.chainId}))}),it==null||it.subscribe(Et=>{const Ct=new Map;for(const At of at.getState())Ct.set(At.id,!0);const St=[];for(const At of Et){const kt=ct(lt(At));Ct.has(kt.id)||St.push(kt)}tt&&!gt.persist.hasHydrated()||at.setState(At=>[...At,...St],!0)});function bt(Et){gt.setState(Ct=>{const St=Ct.connections.get(Et.uid);return St?{...Ct,connections:new Map(Ct.connections).set(Et.uid,{accounts:Et.accounts??St.accounts,chainId:Et.chainId??St.chainId,connector:St.connector})}:Ct})}function xt(Et){gt.getState().status==="connecting"||gt.getState().status==="reconnecting"||gt.setState(Ct=>{const St=at.getState().find(At=>At.uid===Et.uid);return St?(St.emitter.listenerCount("connect")&&St.emitter.off("connect",bt),St.emitter.listenerCount("change")||St.emitter.on("change",bt),St.emitter.listenerCount("disconnect")||St.emitter.on("disconnect",vt),{...Ct,connections:new Map(Ct.connections).set(Et.uid,{accounts:Et.accounts,chainId:Et.chainId,connector:St}),current:Et.uid,status:"connected"}):Ct})}function vt(Et){gt.setState(Ct=>{const St=Ct.connections.get(Et.uid);if(St){const kt=St.connector;kt.emitter.listenerCount("change")&&St.connector.emitter.off("change",bt),kt.emitter.listenerCount("disconnect")&&St.connector.emitter.off("disconnect",vt),kt.emitter.listenerCount("connect")||St.connector.emitter.on("connect",xt)}if(Ct.connections.delete(Et.uid),Ct.connections.size===0)return{...Ct,connections:new Map,current:null,status:"disconnected"};const At=Ct.connections.values().next().value;return{...Ct,connections:new Map(Ct.connections),current:At.connector.uid}})}return{get chains(){return st.getState()},get connectors(){return at.getState()},storage:tt,getClient:ht,get state(){return gt.getState()},setState(Et){let Ct;typeof Et=="function"?Ct=Et(gt.getState()):Ct=Et;const St=mt();typeof Ct!="object"&&(Ct=St),Object.keys(St).some(kt=>!(kt in Ct))&&(Ct=St),gt.setState(Ct,!0)},subscribe(Et,Ct,St){return gt.subscribe(Et,Ct,St?{...St,fireImmediately:St.emitImmediately}:void 0)},_internal:{mipd:it,store:gt,ssr:!!nt,syncConnectedChain:rt,transports:ot.transports,chains:{setState(Et){const Ct=typeof Et=="function"?Et(st.getState()):Et;if(Ct.length!==0)return st.setState(Ct,!0)},subscribe(Et){return st.subscribe(Et)}},connectors:{providerDetailToConnector:lt,setup:ct,setState(Et){return at.setState(typeof Et=="function"?Et(at.getState()):Et,!0)},subscribe(Et){return at.subscribe(Et)}},events:{change:bt,connect:xt,disconnect:vt}}}}function hydrate(et,o){const{initialState:tt,reconnectOnMount:rt}=o;return tt&&!et._internal.store.persist.hasHydrated()&&et.setState({...tt,chainId:et.chains.some(nt=>nt.id===tt.chainId)?tt.chainId:et.chains[0].id,connections:rt?tt.connections:new Map,status:rt?"reconnecting":"disconnected"}),{async onMount(){var nt;if(et._internal.ssr){await et._internal.store.persist.rehydrate();const ot=(nt=et._internal.mipd)==null?void 0:nt.getProviders().map(et._internal.connectors.providerDetailToConnector).map(et._internal.connectors.setup);et._internal.connectors.setState(it=>[...it,...ot??[]])}rt?reconnect(et):et.storage&&et.setState(ot=>({...ot,connections:new Map}))}}}function extractRpcUrls(et){var ot,it,st;const{chain:o}=et,tt=o.rpcUrls.default.http[0];if(!et.transports)return[tt];const rt=(it=(ot=et.transports)==null?void 0:ot[o.id])==null?void 0:it.call(ot,{chain:o});return(((st=rt==null?void 0:rt.value)==null?void 0:st.transports)||[rt]).map(({value:at})=>(at==null?void 0:at.url)||tt)}function Hydrate(et){const{children:o,config:tt,initialState:rt,reconnectOnMount:nt=!0}=et,{onMount:ot}=hydrate(tt,{initialState:rt,reconnectOnMount:nt});tt._internal.ssr||ot();const it=reactExports.useRef(!0);return reactExports.useEffect(()=>{if(it.current&&tt._internal.ssr)return ot(),()=>{it.current=!1}},[]),o}const WagmiContext=reactExports.createContext(void 0);function WagmiProvider(et){const{children:o,config:tt}=et,rt={value:tt};return reactExports.createElement(Hydrate,et,reactExports.createElement(WagmiContext.Provider,rt,o))}const version$5="2.12.19",getVersion=()=>`wagmi@${version$5}`;class BaseError extends BaseError$1{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiError"})}get docsBaseUrl(){return"https://wagmi.sh/react"}get version(){return getVersion()}}class WagmiProviderNotFoundError extends BaseError{constructor(){super("`useConfig` must be used within `WagmiProvider`.",{docsPath:"/api/WagmiProvider"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiProviderNotFoundError"})}}function useConfig(et={}){const o=et.config??reactExports.useContext(WagmiContext);if(!o)throw new WagmiProviderNotFoundError;return o}function watchChains(et,o){const{onChange:tt}=o;return et._internal.chains.subscribe((rt,nt)=>{tt(rt,nt)})}var withSelector={exports:{}},withSelector_production_min={},shim={exports:{}},useSyncExternalStoreShim_production_min={};/** +`):`The contract function "${rt}" reverted.`,{cause:ot,metaMessages:st,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=it,this.reason=at,this.signature=ct}}class ContractFunctionZeroDataError extends BaseError$3{constructor({functionName:o}){super(`The contract function "${o}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${o}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class CounterfactualDeploymentFailedError extends BaseError$3{constructor({factory:o}){super(`Deployment for counterfactual contract call failed${o?` for factory "${o}".`:""}`,{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class RawContractError extends BaseError$3{constructor({data:o,message:tt}){super(tt||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o}}function isNullUniversalResolverError(et,o){var rt,nt,ot,it,st,at;if(!(et instanceof BaseError$3))return!1;const tt=et.walk(ct=>ct instanceof ContractFunctionRevertedError);return tt instanceof ContractFunctionRevertedError?!!(((rt=tt.data)==null?void 0:rt.errorName)==="ResolverNotFound"||((nt=tt.data)==null?void 0:nt.errorName)==="ResolverWildcardNotSupported"||((ot=tt.data)==null?void 0:ot.errorName)==="ResolverNotContract"||((it=tt.data)==null?void 0:it.errorName)==="ResolverError"||((st=tt.data)==null?void 0:st.errorName)==="HttpError"||(at=tt.reason)!=null&&at.includes("Wildcard on non-extended resolvers is not supported")||o==="reverse"&&tt.reason===panicReasons[50]):!1}function encodedLabelToLabelhash(et){if(et.length!==66||et.indexOf("[")!==0||et.indexOf("]")!==65)return null;const o=`0x${et.slice(1,65)}`;return isHex(o)?o:null}function namehash(et){let o=new Uint8Array(32).fill(0);if(!et)return bytesToHex$3(o);const tt=et.split(".");for(let rt=tt.length-1;rt>=0;rt-=1){const nt=encodedLabelToLabelhash(tt[rt]),ot=nt?toBytes$3(nt):keccak256$1(stringToBytes(tt[rt]),"bytes");o=keccak256$1(concat$6([o,ot]),"bytes")}return bytesToHex$3(o)}function encodeLabelhash(et){return`[${et.slice(2)}]`}function labelhash(et){const o=new Uint8Array(32).fill(0);return et?encodedLabelToLabelhash(et)||keccak256$1(stringToBytes(et)):bytesToHex$3(o)}function packetToBytes(et){const o=et.replace(/^\.|\.$/gm,"");if(o.length===0)return new Uint8Array(1);const tt=new Uint8Array(stringToBytes(o).byteLength+2);let rt=0;const nt=o.split(".");for(let ot=0;ot255&&(it=stringToBytes(encodeLabelhash(labelhash(nt[ot])))),tt[rt]=it.length,tt.set(it,rt+1),rt+=it.length+1}return tt.byteLength!==rt+1?tt.slice(0,rt+1):tt}const EXECUTION_REVERTED_ERROR_CODE=3;function getContractError(et,{abi:o,address:tt,args:rt,docsPath:nt,functionName:ot,sender:it}){const{code:st,data:at,message:ct,shortMessage:lt}=et instanceof RawContractError?et:et instanceof BaseError$3?et.walk(ht=>"data"in ht)||et.walk():{},dt=et instanceof AbiDecodingZeroDataError?new ContractFunctionZeroDataError({functionName:ot}):[EXECUTION_REVERTED_ERROR_CODE,InternalRpcError.code].includes(st)&&(at||ct||lt)?new ContractFunctionRevertedError({abi:o,data:typeof at=="object"?at.data:at,functionName:ot,message:lt??ct}):et;return new ContractFunctionExecutionError(dt,{abi:o,args:rt,contractAddress:tt,docsPath:nt,functionName:ot,sender:it})}const aggregate3Signature="0x82ad56cb",deploylessCallViaBytecodeBytecode="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",deploylessCallViaFactoryBytecode="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe";function getCallError(et,{docsPath:o,...tt}){const rt=(()=>{const nt=getNodeError(et,tt);return nt instanceof UnknownNodeError?et:nt})();return new CallExecutionError(rt,{docsPath:o,...tt})}const schedulerCache=new Map;function createBatchScheduler({fn:et,id:o,shouldSplitBatch:tt,wait:rt=0,sort:nt}){const ot=async()=>{const lt=at();it();const dt=lt.map(({args:ht})=>ht);dt.length!==0&&et(dt).then(ht=>{var mt;nt&&Array.isArray(ht)&&ht.sort(nt);for(let ft=0;ft{var mt;for(let ft=0;ftschedulerCache.delete(o),st=()=>at().map(({args:lt})=>lt),at=()=>schedulerCache.get(o)||[],ct=lt=>schedulerCache.set(o,[...at(),lt]);return{flush:it,async schedule(lt){const dt={},ht=new Promise((pt,yt)=>{dt.resolve=pt,dt.reject=yt});return(tt==null?void 0:tt([...st(),lt]))&&ot(),at().length>0?(ct({args:lt,pendingPromise:dt}),ht):(ct({args:lt,pendingPromise:dt}),setTimeout(ot,rt),ht)}}}async function call(et,o){var Nt,Lt,Mt,zt;const{account:tt=et.account,batch:rt=!!((Nt=et.batch)!=null&&Nt.multicall),blockNumber:nt,blockTag:ot="latest",accessList:it,blobs:st,code:at,data:ct,factory:lt,factoryData:dt,gas:ht,gasPrice:mt,maxFeePerBlobGas:ft,maxFeePerGas:pt,maxPriorityFeePerGas:yt,nonce:gt,to:bt,value:xt,stateOverride:vt,...Et}=o,Ct=tt?parseAccount(tt):void 0;if(at&&(lt||dt))throw new BaseError$3("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(at&&bt)throw new BaseError$3("Cannot provide both `code` & `to` as parameters.");const St=at&&ct,At=lt&&dt&&bt&&ct,kt=St||At,It=St?toDeploylessCallViaBytecodeData({code:at,data:ct}):At?toDeploylessCallViaFactoryData({data:ct,factory:lt,factoryData:dt,to:bt}):ct;try{assertRequest(o);const Xt=(nt?numberToHex(nt):void 0)||ot,Wt=serializeStateOverride(vt),Ft=(zt=(Mt=(Lt=et.chain)==null?void 0:Lt.formatters)==null?void 0:Mt.transactionRequest)==null?void 0:zt.format,Pt=(Ft||formatTransactionRequest)({...extract$1(Et,{format:Ft}),from:Ct==null?void 0:Ct.address,accessList:it,blobs:st,data:It,gas:ht,gasPrice:mt,maxFeePerBlobGas:ft,maxFeePerGas:pt,maxPriorityFeePerGas:yt,nonce:gt,to:kt?void 0:bt,value:xt});if(rt&&shouldPerformMulticall({request:Pt})&&!Wt)try{return await scheduleMulticall(et,{...Pt,blockNumber:nt,blockTag:ot})}catch(Qt){if(!(Qt instanceof ClientChainNotConfiguredError)&&!(Qt instanceof ChainDoesNotSupportContract))throw Qt}const Yt=await et.request({method:"eth_call",params:Wt?[Pt,Xt,Wt]:[Pt,Xt]});return Yt==="0x"?{data:void 0}:{data:Yt}}catch(Ut){const Xt=getRevertErrorData(Ut),{offchainLookup:Wt,offchainLookupSignature:Ft}=await __vitePreload(async()=>{const{offchainLookup:qt,offchainLookupSignature:Pt}=await import("./ccip-C1WRCCe-.js");return{offchainLookup:qt,offchainLookupSignature:Pt}},[]);if(et.ccipRead!==!1&&(Xt==null?void 0:Xt.slice(0,10))===Ft&&bt)return{data:await Wt(et,{data:Xt,to:bt})};throw kt&&(Xt==null?void 0:Xt.slice(0,10))==="0x101bb98d"?new CounterfactualDeploymentFailedError({factory:lt}):getCallError(Ut,{...o,account:Ct,chain:et.chain})}}function shouldPerformMulticall({request:et}){const{data:o,to:tt,...rt}=et;return!(!o||o.startsWith(aggregate3Signature)||!tt||Object.values(rt).filter(nt=>typeof nt<"u").length>0)}async function scheduleMulticall(et,o){var pt;const{batchSize:tt=1024,wait:rt=0}=typeof((pt=et.batch)==null?void 0:pt.multicall)=="object"?et.batch.multicall:{},{blockNumber:nt,blockTag:ot="latest",data:it,multicallAddress:st,to:at}=o;let ct=st;if(!ct){if(!et.chain)throw new ClientChainNotConfiguredError;ct=getChainContractAddress({blockNumber:nt,chain:et.chain,contract:"multicall3"})}const dt=(nt?numberToHex(nt):void 0)||ot,{schedule:ht}=createBatchScheduler({id:`${et.uid}.${dt}`,wait:rt,shouldSplitBatch(yt){return yt.reduce((bt,{data:xt})=>bt+(xt.length-2),0)>tt*2},fn:async yt=>{const gt=yt.map(vt=>({allowFailure:!0,callData:vt.data,target:vt.to})),bt=encodeFunctionData({abi:multicall3Abi,args:[gt],functionName:"aggregate3"}),xt=await et.request({method:"eth_call",params:[{data:bt,to:ct},dt]});return decodeFunctionResult({abi:multicall3Abi,args:[gt],functionName:"aggregate3",data:xt||"0x"})}}),[{returnData:mt,success:ft}]=await ht({data:it,to:at});if(!ft)throw new RawContractError({data:mt});return mt==="0x"?{data:void 0}:{data:mt}}function toDeploylessCallViaBytecodeData(et){const{code:o,data:tt}=et;return encodeDeployData({abi:parseAbi(["constructor(bytes, bytes)"]),bytecode:deploylessCallViaBytecodeBytecode,args:[o,tt]})}function toDeploylessCallViaFactoryData(et){const{data:o,factory:tt,factoryData:rt,to:nt}=et;return encodeDeployData({abi:parseAbi(["constructor(address, bytes, address, bytes)"]),bytecode:deploylessCallViaFactoryBytecode,args:[nt,o,tt,rt]})}function getRevertErrorData(et){var tt;if(!(et instanceof BaseError$3))return;const o=et.walk();return typeof(o==null?void 0:o.data)=="object"?(tt=o.data)==null?void 0:tt.data:o.data}async function readContract$1(et,o){const{abi:tt,address:rt,args:nt,functionName:ot,...it}=o,st=encodeFunctionData({abi:tt,args:nt,functionName:ot});try{const{data:at}=await getAction$1(et,call,"call")({...it,data:st,to:rt});return decodeFunctionResult({abi:tt,args:nt,functionName:ot,data:at||"0x"})}catch(at){throw getContractError(at,{abi:tt,address:rt,args:nt,docsPath:"/docs/contract/readContract",functionName:ot})}}async function getEnsAddress$1(et,{blockNumber:o,blockTag:tt,coinType:rt,name:nt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){let at=st;if(!at){if(!et.chain)throw new Error("client chain not configured. universalResolverAddress is required.");at=getChainContractAddress({blockNumber:o,chain:et.chain,contract:"ensUniversalResolver"})}try{const ct=encodeFunctionData({abi:addressResolverAbi,functionName:"addr",...rt!=null?{args:[namehash(nt),BigInt(rt)]}:{args:[namehash(nt)]}}),lt={address:at,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(nt)),ct],blockNumber:o,blockTag:tt},dt=getAction$1(et,readContract$1,"readContract"),ht=ot?await dt({...lt,args:[...lt.args,ot]}):await dt(lt);if(ht[0]==="0x")return null;const mt=decodeFunctionResult({abi:addressResolverAbi,args:rt!=null?[namehash(nt),BigInt(rt)]:void 0,functionName:"addr",data:ht[0]});return mt==="0x"||trim$1(mt)==="0x00"?null:mt}catch(ct){if(it)throw ct;if(isNullUniversalResolverError(ct,"resolve"))return null;throw ct}}class EnsAvatarInvalidMetadataError extends BaseError$3{constructor({data:o}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(o)}`],name:"EnsAvatarInvalidMetadataError"})}}class EnsAvatarInvalidNftUriError extends BaseError$3{constructor({reason:o}){super(`ENS NFT avatar URI is invalid. ${o}`,{name:"EnsAvatarInvalidNftUriError"})}}class EnsAvatarUriResolutionError extends BaseError$3{constructor({uri:o}){super(`Unable to resolve ENS avatar URI "${o}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class EnsAvatarUnsupportedNamespaceError extends BaseError$3{constructor({namespace:o}){super(`ENS NFT avatar namespace "${o}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const networkRegex=/(?https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?\/)?(?ipfs\/|ipns\/)?(?[\w\-.]+)(?\/.*)?/,ipfsHashRegex=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?[\w\-.]+))?(?\/.*)?$/,base64Regex=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,dataURIRegex=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function isImageUri(et){try{const o=await fetch(et,{method:"HEAD"});if(o.status===200){const tt=o.headers.get("content-type");return tt==null?void 0:tt.startsWith("image/")}return!1}catch(o){return typeof o=="object"&&typeof o.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(tt=>{const rt=new Image;rt.onload=()=>{tt(!0)},rt.onerror=()=>{tt(!1)},rt.src=et})}}function getGateway(et,o){return et?et.endsWith("/")?et.slice(0,-1):et:o}function resolveAvatarUri({uri:et,gatewayUrls:o}){const tt=base64Regex.test(et);if(tt)return{uri:et,isOnChain:!0,isEncoded:tt};const rt=getGateway(o==null?void 0:o.ipfs,"https://ipfs.io"),nt=getGateway(o==null?void 0:o.arweave,"https://arweave.net"),ot=et.match(networkRegex),{protocol:it,subpath:st,target:at,subtarget:ct=""}=(ot==null?void 0:ot.groups)||{},lt=it==="ipns:/"||st==="ipns/",dt=it==="ipfs:/"||st==="ipfs/"||ipfsHashRegex.test(et);if(et.startsWith("http")&&!lt&&!dt){let mt=et;return o!=null&&o.arweave&&(mt=et.replace(/https:\/\/arweave.net/g,o==null?void 0:o.arweave)),{uri:mt,isOnChain:!1,isEncoded:!1}}if((lt||dt)&&at)return{uri:`${rt}/${lt?"ipns":"ipfs"}/${at}${ct}`,isOnChain:!1,isEncoded:!1};if(it==="ar:/"&&at)return{uri:`${nt}/${at}${ct||""}`,isOnChain:!1,isEncoded:!1};let ht=et.replace(dataURIRegex,"");if(ht.startsWith("nt.json());return await parseAvatarUri({gatewayUrls:et,uri:getJsonImage(tt)})}catch{throw new EnsAvatarUriResolutionError({uri:o})}}async function parseAvatarUri({gatewayUrls:et,uri:o}){const{uri:tt,isOnChain:rt}=resolveAvatarUri({uri:o,gatewayUrls:et});if(rt||await isImageUri(tt))return tt;throw new EnsAvatarUriResolutionError({uri:o})}function parseNftUri(et){let o=et;o.startsWith("did:nft:")&&(o=o.replace("did:nft:","").replace(/_/g,"/"));const[tt,rt,nt]=o.split("/"),[ot,it]=tt.split(":"),[st,at]=rt.split(":");if(!ot||ot.toLowerCase()!=="eip155")throw new EnsAvatarInvalidNftUriError({reason:"Only EIP-155 supported"});if(!it)throw new EnsAvatarInvalidNftUriError({reason:"Chain ID not found"});if(!at)throw new EnsAvatarInvalidNftUriError({reason:"Contract address not found"});if(!nt)throw new EnsAvatarInvalidNftUriError({reason:"Token ID not found"});if(!st)throw new EnsAvatarInvalidNftUriError({reason:"ERC namespace not found"});return{chainID:Number.parseInt(it),namespace:st.toLowerCase(),contractAddress:at,tokenID:nt}}async function getNftTokenUri(et,{nft:o}){if(o.namespace==="erc721")return readContract$1(et,{address:o.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(o.tokenID)]});if(o.namespace==="erc1155")return readContract$1(et,{address:o.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(o.tokenID)]});throw new EnsAvatarUnsupportedNamespaceError({namespace:o.namespace})}async function parseAvatarRecord(et,{gatewayUrls:o,record:tt}){return/eip155:/i.test(tt)?parseNftAvatarUri(et,{gatewayUrls:o,record:tt}):parseAvatarUri({uri:tt,gatewayUrls:o})}async function parseNftAvatarUri(et,{gatewayUrls:o,record:tt}){const rt=parseNftUri(tt),nt=await getNftTokenUri(et,{nft:rt}),{uri:ot,isOnChain:it,isEncoded:st}=resolveAvatarUri({uri:nt,gatewayUrls:o});if(it&&(ot.includes("data:application/json;base64,")||ot.startsWith("{"))){const ct=st?atob(ot.replace("data:application/json;base64,","")):ot,lt=JSON.parse(ct);return parseAvatarUri({uri:getJsonImage(lt),gatewayUrls:o})}let at=rt.tokenID;return rt.namespace==="erc1155"&&(at=at.replace("0x","").padStart(64,"0")),getMetadataAvatarUri({gatewayUrls:o,uri:ot.replace(/(?:0x)?{id}/,at)})}async function getEnsText(et,{blockNumber:o,blockTag:tt,name:rt,key:nt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){let at=st;if(!at){if(!et.chain)throw new Error("client chain not configured. universalResolverAddress is required.");at=getChainContractAddress({blockNumber:o,chain:et.chain,contract:"ensUniversalResolver"})}try{const ct={address:at,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(rt)),encodeFunctionData({abi:textResolverAbi,functionName:"text",args:[namehash(rt),nt]})],blockNumber:o,blockTag:tt},lt=getAction$1(et,readContract$1,"readContract"),dt=ot?await lt({...ct,args:[...ct.args,ot]}):await lt(ct);if(dt[0]==="0x")return null;const ht=decodeFunctionResult({abi:textResolverAbi,functionName:"text",data:dt[0]});return ht===""?null:ht}catch(ct){if(it)throw ct;if(isNullUniversalResolverError(ct,"resolve"))return null;throw ct}}async function getEnsAvatar$1(et,{blockNumber:o,blockTag:tt,assetGatewayUrls:rt,name:nt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){const at=await getAction$1(et,getEnsText,"getEnsText")({blockNumber:o,blockTag:tt,key:"avatar",name:nt,universalResolverAddress:st,gatewayUrls:ot,strict:it});if(!at)return null;try{return await parseAvatarRecord(et,{record:at,gatewayUrls:rt})}catch{return null}}async function getEnsName$1(et,{address:o,blockNumber:tt,blockTag:rt,gatewayUrls:nt,strict:ot,universalResolverAddress:it}){let st=it;if(!st){if(!et.chain)throw new Error("client chain not configured. universalResolverAddress is required.");st=getChainContractAddress({blockNumber:tt,chain:et.chain,contract:"ensUniversalResolver"})}const at=`${o.toLowerCase().substring(2)}.addr.reverse`;try{const ct={address:st,abi:universalResolverReverseAbi,functionName:"reverse",args:[toHex(packetToBytes(at))],blockNumber:tt,blockTag:rt},lt=getAction$1(et,readContract$1,"readContract"),[dt,ht]=nt?await lt({...ct,args:[...ct.args,nt]}):await lt(ct);return o.toLowerCase()!==ht.toLowerCase()?null:dt}catch(ct){if(ot)throw ct;if(isNullUniversalResolverError(ct,"reverse"))return null;throw ct}}const promiseCache$1=new Map,responseCache=new Map;function getCache(et){const o=(nt,ot)=>({clear:()=>ot.delete(nt),get:()=>ot.get(nt),set:it=>ot.set(nt,it)}),tt=o(et,promiseCache$1),rt=o(et,responseCache);return{clear:()=>{tt.clear(),rt.clear()},promise:tt,response:rt}}async function withCache(et,{cacheKey:o,cacheTime:tt=Number.POSITIVE_INFINITY}){const rt=getCache(o),nt=rt.response.get();if(nt&&tt>0&&new Date().getTime()-nt.created.getTime()`blockNumber.${et}`;async function getBlockNumber$1(et,{cacheTime:o=et.cacheTime}={}){const tt=await withCache(()=>et.request({method:"eth_blockNumber"}),{cacheKey:cacheKey(et.uid),cacheTime:o});return BigInt(tt)}function formatLog(et,{args:o,eventName:tt}={}){return{...et,blockHash:et.blockHash?et.blockHash:null,blockNumber:et.blockNumber?BigInt(et.blockNumber):null,logIndex:et.logIndex?Number(et.logIndex):null,transactionHash:et.transactionHash?et.transactionHash:null,transactionIndex:et.transactionIndex?Number(et.transactionIndex):null,...tt?{args:o,eventName:tt}:{}}}const receiptStatuses={"0x0":"reverted","0x1":"success"};function formatTransactionReceipt(et){const o={...et,blockNumber:et.blockNumber?BigInt(et.blockNumber):null,contractAddress:et.contractAddress?et.contractAddress:null,cumulativeGasUsed:et.cumulativeGasUsed?BigInt(et.cumulativeGasUsed):null,effectiveGasPrice:et.effectiveGasPrice?BigInt(et.effectiveGasPrice):null,gasUsed:et.gasUsed?BigInt(et.gasUsed):null,logs:et.logs?et.logs.map(tt=>formatLog(tt)):null,to:et.to?et.to:null,transactionIndex:et.transactionIndex?hexToNumber$2(et.transactionIndex):null,status:et.status?receiptStatuses[et.status]:null,type:et.type?transactionType[et.type]||et.type:null};return et.blobGasPrice&&(o.blobGasPrice=BigInt(et.blobGasPrice)),et.blobGasUsed&&(o.blobGasUsed=BigInt(et.blobGasUsed)),o}const defineTransactionReceipt=defineFormatter("transactionReceipt",formatTransactionReceipt);async function multicall$1(et,o){var yt;const{allowFailure:tt=!0,batchSize:rt,blockNumber:nt,blockTag:ot,multicallAddress:it,stateOverride:st}=o,at=o.contracts,ct=rt??(typeof((yt=et.batch)==null?void 0:yt.multicall)=="object"&&et.batch.multicall.batchSize||1024);let lt=it;if(!lt){if(!et.chain)throw new Error("client chain not configured. multicallAddress is required.");lt=getChainContractAddress({blockNumber:nt,chain:et.chain,contract:"multicall3"})}const dt=[[]];let ht=0,mt=0;for(let gt=0;gt0&&mt>ct&&dt[ht].length>0&&(ht++,mt=(Ct.length-2)/2,dt[ht]=[]),dt[ht]=[...dt[ht],{allowFailure:!0,callData:Ct,target:xt}]}catch(Ct){const St=getContractError(Ct,{abi:bt,address:xt,args:vt,docsPath:"/docs/contract/multicall",functionName:Et});if(!tt)throw St;dt[ht]=[...dt[ht],{allowFailure:!0,callData:"0x",target:xt}]}}const ft=await Promise.allSettled(dt.map(gt=>getAction$1(et,readContract$1,"readContract")({abi:multicall3Abi,address:lt,args:[gt],blockNumber:nt,blockTag:ot,functionName:"aggregate3",stateOverride:st}))),pt=[];for(let gt=0;gtlistenersCache.get(et)||[],ot=()=>{const lt=nt();listenersCache.set(et,lt.filter(dt=>dt.id!==rt))},it=()=>{const lt=cleanupCache.get(et);nt().length===1&<&<(),ot()},st=nt();if(listenersCache.set(et,[...st,{id:rt,fns:o}]),st&&st.length>0)return it;const at={};for(const lt in o)at[lt]=(...dt)=>{var mt,ft;const ht=nt();if(ht.length!==0)for(const pt of ht)(ft=(mt=pt.fns)[lt])==null||ft.call(mt,...dt)};const ct=tt(at);return typeof ct=="function"&&cleanupCache.set(et,ct),it}async function wait$1(et){return new Promise(o=>setTimeout(o,et))}function poll(et,{emitOnBegin:o,initialWaitTime:tt,interval:rt}){let nt=!0;const ot=()=>nt=!1;return(async()=>{let st;o&&(st=await et({unpoll:ot}));const at=await(tt==null?void 0:tt(st))??rt;await wait$1(at);const ct=async()=>{nt&&(await et({unpoll:ot}),await wait$1(rt),ct())};ct()})(),ot}function watchBlockNumber$1(et,{emitOnBegin:o=!1,emitMissed:tt=!1,onBlockNumber:rt,onError:nt,poll:ot,pollingInterval:it=et.pollingInterval}){const st=typeof ot<"u"?ot:!(et.transport.type==="webSocket"||et.transport.type==="fallback"&&et.transport.transports[0].config.type==="webSocket");let at;return st?(()=>{const dt=stringify$2(["watchBlockNumber",et.uid,o,tt,it]);return observe(dt,{onBlockNumber:rt,onError:nt},ht=>poll(async()=>{var mt;try{const ft=await getAction$1(et,getBlockNumber$1,"getBlockNumber")({cacheTime:0});if(at){if(ft===at)return;if(ft-at>1&&tt)for(let pt=at+1n;ptat)&&(ht.onBlockNumber(ft,at),at=ft)}catch(ft){(mt=ht.onError)==null||mt.call(ht,ft)}},{emitOnBegin:o,interval:it}))})():(()=>{const dt=stringify$2(["watchBlockNumber",et.uid,o,tt]);return observe(dt,{onBlockNumber:rt,onError:nt},ht=>{let mt=!0,ft=()=>mt=!1;return(async()=>{try{const pt=(()=>{if(et.transport.type==="fallback"){const gt=et.transport.transports.find(bt=>bt.config.type==="webSocket");return gt?gt.value:et.transport}return et.transport})(),{unsubscribe:yt}=await pt.subscribe({params:["newHeads"],onData(gt){var xt;if(!mt)return;const bt=hexToBigInt((xt=gt.result)==null?void 0:xt.number);ht.onBlockNumber(bt,at),at=bt},onError(gt){var bt;(bt=ht.onError)==null||bt.call(ht,gt)}});ft=yt,mt||ft()}catch(pt){nt==null||nt(pt)}})(),()=>ft()})})()}const promiseCache=new LruMap(8192);function withDedupe(et,{enabled:o=!0,id:tt}){if(!o||!tt)return et();if(promiseCache.get(tt))return promiseCache.get(tt);const rt=et().finally(()=>promiseCache.delete(tt));return promiseCache.set(tt,rt),rt}function withRetry(et,{delay:o=100,retryCount:tt=2,shouldRetry:rt=()=>!0}={}){return new Promise((nt,ot)=>{const it=async({count:st=0}={})=>{const at=async({error:ct})=>{const lt=typeof o=="function"?o({count:st,error:ct}):o;lt&&await wait$1(lt),it({count:st+1})};try{const ct=await et();nt(ct)}catch(ct){if(st{const{dedupe:nt=!1,retryDelay:ot=150,retryCount:it=3,uid:st}={...o,...rt},at=nt?keccak256$1(stringToHex(`${st}.${stringify$2(tt)}`)):void 0;return withDedupe(()=>withRetry(async()=>{try{return await et(tt)}catch(ct){const lt=ct;switch(lt.code){case ParseRpcError.code:throw new ParseRpcError(lt);case InvalidRequestRpcError.code:throw new InvalidRequestRpcError(lt);case MethodNotFoundRpcError.code:throw new MethodNotFoundRpcError(lt,{method:tt.method});case InvalidParamsRpcError.code:throw new InvalidParamsRpcError(lt);case InternalRpcError.code:throw new InternalRpcError(lt);case InvalidInputRpcError.code:throw new InvalidInputRpcError(lt);case ResourceNotFoundRpcError.code:throw new ResourceNotFoundRpcError(lt);case ResourceUnavailableRpcError.code:throw new ResourceUnavailableRpcError(lt);case TransactionRejectedRpcError.code:throw new TransactionRejectedRpcError(lt);case MethodNotSupportedRpcError.code:throw new MethodNotSupportedRpcError(lt,{method:tt.method});case LimitExceededRpcError.code:throw new LimitExceededRpcError(lt);case JsonRpcVersionUnsupportedError.code:throw new JsonRpcVersionUnsupportedError(lt);case UserRejectedRequestError.code:throw new UserRejectedRequestError(lt);case UnauthorizedProviderError.code:throw new UnauthorizedProviderError(lt);case UnsupportedProviderMethodError.code:throw new UnsupportedProviderMethodError(lt);case ProviderDisconnectedError.code:throw new ProviderDisconnectedError(lt);case ChainDisconnectedError.code:throw new ChainDisconnectedError(lt);case SwitchChainError.code:throw new SwitchChainError(lt);case 5e3:throw new UserRejectedRequestError(lt);default:throw ct instanceof BaseError$3?ct:new UnknownRpcError(lt)}}},{delay:({count:ct,error:lt})=>{var dt;if(lt&< instanceof HttpRequestError){const ht=(dt=lt==null?void 0:lt.headers)==null?void 0:dt.get("Retry-After");if(ht!=null&&ht.match(/\d/))return Number.parseInt(ht)*1e3}return~~(1<shouldRetry(ct)}),{enabled:nt,id:at})}}function shouldRetry(et){return"code"in et&&typeof et.code=="number"?et.code===-1||et.code===LimitExceededRpcError.code||et.code===InternalRpcError.code:et instanceof HttpRequestError&&et.status?et.status===403||et.status===408||et.status===413||et.status===429||et.status===500||et.status===502||et.status===503||et.status===504:!0}function defineChain(et){return{formatters:void 0,fees:void 0,serializers:void 0,...et}}function withTimeout(et,{errorInstance:o=new Error("timed out"),timeout:tt,signal:rt}){return new Promise((nt,ot)=>{(async()=>{let it;try{const st=new AbortController;tt>0&&(it=setTimeout(()=>{rt?st.abort():ot(o)},tt)),nt(await et({signal:(st==null?void 0:st.signal)||null}))}catch(st){(st==null?void 0:st.name)==="AbortError"&&ot(o),ot(st)}finally{clearTimeout(it)}})()})}function createIdStore(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const idCache=createIdStore();function getHttpRpcClient(et,o={}){return{async request(tt){var dt;const{body:rt,onRequest:nt=o.onRequest,onResponse:ot=o.onResponse,timeout:it=o.timeout??1e4}=tt,st={...o.fetchOptions??{},...tt.fetchOptions??{}},{headers:at,method:ct,signal:lt}=st;try{const ht=await withTimeout(async({signal:ft})=>{const pt={...st,body:Array.isArray(rt)?stringify$2(rt.map(xt=>({jsonrpc:"2.0",id:xt.id??idCache.take(),...xt}))):stringify$2({jsonrpc:"2.0",id:rt.id??idCache.take(),...rt}),headers:{"Content-Type":"application/json",...at},method:ct||"POST",signal:lt||(it>0?ft:null)},yt=new Request(et,pt),gt=await(nt==null?void 0:nt(yt,pt))??{...pt,url:et};return await fetch(gt.url??et,gt)},{errorInstance:new TimeoutError$4({body:rt,url:et}),timeout:it,signal:!0});ot&&await ot(ht);let mt;if((dt=ht.headers.get("Content-Type"))!=null&&dt.startsWith("application/json"))mt=await ht.json();else{mt=await ht.text();try{mt=JSON.parse(mt||"{}")}catch(ft){if(ht.ok)throw ft;mt={error:mt}}}if(!ht.ok)throw new HttpRequestError({body:rt,details:stringify$2(mt.error)||ht.statusText,headers:ht.headers,status:ht.status,url:et});return mt}catch(ht){throw ht instanceof HttpRequestError||ht instanceof TimeoutError$4?ht:new HttpRequestError({body:rt,cause:ht,url:et})}}}}function assertTransactionEIP7702(et){const{authorizationList:o}=et;if(o)for(const tt of o){const{contractAddress:rt,chainId:nt}=tt;if(!isAddress(rt))throw new InvalidAddressError({address:rt});if(nt<=0)throw new InvalidChainIdError({chainId:nt})}assertTransactionEIP1559(et)}function assertTransactionEIP4844(et){const{blobVersionedHashes:o}=et;if(o){if(o.length===0)throw new EmptyBlobError;for(const tt of o){const rt=size$2(tt),nt=hexToNumber$2(slice(tt,0,1));if(rt!==32)throw new InvalidVersionedHashSizeError({hash:tt,size:rt});if(nt!==versionedHashVersionKzg)throw new InvalidVersionedHashVersionError({hash:tt,version:nt})}}assertTransactionEIP1559(et)}function assertTransactionEIP1559(et){const{chainId:o,maxPriorityFeePerGas:tt,maxFeePerGas:rt,to:nt}=et;if(o<=0)throw new InvalidChainIdError({chainId:o});if(nt&&!isAddress(nt))throw new InvalidAddressError({address:nt});if(rt&&rt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:rt});if(tt&&rt&&tt>rt)throw new TipAboveFeeCapError({maxFeePerGas:rt,maxPriorityFeePerGas:tt})}function assertTransactionEIP2930(et){const{chainId:o,maxPriorityFeePerGas:tt,gasPrice:rt,maxFeePerGas:nt,to:ot}=et;if(o<=0)throw new InvalidChainIdError({chainId:o});if(ot&&!isAddress(ot))throw new InvalidAddressError({address:ot});if(tt||nt)throw new BaseError$3("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(rt&&rt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:rt})}function assertTransactionLegacy(et){const{chainId:o,maxPriorityFeePerGas:tt,gasPrice:rt,maxFeePerGas:nt,to:ot}=et;if(ot&&!isAddress(ot))throw new InvalidAddressError({address:ot});if(typeof o<"u"&&o<=0)throw new InvalidChainIdError({chainId:o});if(tt||nt)throw new BaseError$3("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(rt&&rt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:rt})}function serializeAuthorizationList(et){if(!et||et.length===0)return[];const o=[];for(const tt of et){const{contractAddress:rt,chainId:nt,nonce:ot,...it}=tt;o.push([toHex(nt),rt,ot?toHex(ot):"0x",...toYParitySignatureArray({},it)])}return o}function serializeAccessList(et){if(!et||et.length===0)return[];const o=[];for(let tt=0;tt"u"||typeof mt>"u")){const xt=typeof et.blobs[0]=="string"?et.blobs:et.blobs.map(Ct=>bytesToHex$3(Ct)),vt=et.kzg,Et=blobsToCommitments({blobs:xt,kzg:vt});if(typeof ht>"u"&&(ht=commitmentsToVersionedHashes({commitments:Et})),typeof mt>"u"){const Ct=blobsToProofs({blobs:xt,commitments:Et,kzg:vt});mt=toBlobSidecars({blobs:xt,commitments:Et,proofs:Ct})}}const ft=serializeAccessList(lt),pt=[toHex(tt),nt?toHex(nt):"0x",ct?toHex(ct):"0x",at?toHex(at):"0x",rt?toHex(rt):"0x",ot??"0x",it?toHex(it):"0x",dt??"0x",ft,st?toHex(st):"0x",ht??[],...toYParitySignatureArray(et,o)],yt=[],gt=[],bt=[];if(mt)for(let xt=0;xt{if(o.v>=35n)return(o.v-35n)/2n>0?o.v:27n+(o.v===35n?0n:1n);if(tt>0)return BigInt(tt*2)+BigInt(35n+o.v-27n);const mt=27n+(o.v===27n?0n:1n);if(o.v!==mt)throw new InvalidLegacyVError({v:o.v});return mt})(),dt=trim$1(o.r),ht=trim$1(o.s);ct=[...ct,toHex(lt),dt==="0x00"?"0x":dt,ht==="0x00"?"0x":ht]}else tt>0&&(ct=[...ct,toHex(tt),"0x","0x"]);return toRlp(ct)}function toYParitySignatureArray(et,o){const tt=o??et,{v:rt,yParity:nt}=tt;if(typeof tt.r>"u")return[];if(typeof tt.s>"u")return[];if(typeof rt>"u"&&typeof nt>"u")return[];const ot=trim$1(tt.r),it=trim$1(tt.s);return[typeof nt=="number"?nt?toHex(1):"0x":rt===0n?"0x":rt===1n?toHex(1):rt===27n?"0x":toHex(1),ot==="0x00"?"0x":ot,it==="0x00"?"0x":it]}async function signMessage$1(et,{account:o=et.account,message:tt}){if(!o)throw new AccountNotFoundError({docsPath:"/docs/actions/wallet/signMessage"});const rt=parseAccount(o);if(rt.signMessage)return rt.signMessage({message:tt});const nt=typeof tt=="string"?stringToHex(tt):tt.raw instanceof Uint8Array?toHex(tt.raw):tt.raw;return et.request({method:"personal_sign",params:[nt,rt.address]},{retryCount:0})}class HMAC extends Hash{constructor(o,tt){super(),this.finished=!1,this.destroyed=!1,hash$1(o);const rt=toBytes$2(tt);if(this.iHash=o.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const nt=this.blockLen,ot=new Uint8Array(nt);ot.set(rt.length>nt?o.create().update(rt).digest():rt);for(let it=0;itnew HMAC(et,o).update(tt).digest();hmac.create=(et,o)=>new HMAC(et,o);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$6=BigInt(0),_1n$8=BigInt(1),_2n$5=BigInt(2);function isBytes$2(et){return et instanceof Uint8Array||et!=null&&typeof et=="object"&&et.constructor.name==="Uint8Array"}function abytes(et){if(!isBytes$2(et))throw new Error("Uint8Array expected")}function abool(et,o){if(typeof o!="boolean")throw new Error(`${et} must be valid boolean, got "${o}".`)}const hexes$1=Array.from({length:256},(et,o)=>o.toString(16).padStart(2,"0"));function bytesToHex$2(et){abytes(et);let o="";for(let tt=0;tt=asciis._0&&et<=asciis._9)return et-asciis._0;if(et>=asciis._A&&et<=asciis._F)return et-(asciis._A-10);if(et>=asciis._a&&et<=asciis._f)return et-(asciis._a-10)}function hexToBytes$2(et){if(typeof et!="string")throw new Error("hex string expected, got "+typeof et);const o=et.length,tt=o/2;if(o%2)throw new Error("padded hex string expected, got unpadded hex of length "+o);const rt=new Uint8Array(tt);for(let nt=0,ot=0;nttypeof et=="bigint"&&_0n$6<=et;function inRange(et,o,tt){return isPosBig(et)&&isPosBig(o)&&isPosBig(tt)&&o<=et&&et_0n$6;et>>=_1n$8,o+=1);return o}function bitGet(et,o){return et>>BigInt(o)&_1n$8}function bitSet(et,o,tt){return et|(tt?_1n$8:_0n$6)<(_2n$5<new Uint8Array(et),u8fr=et=>Uint8Array.from(et);function createHmacDrbg(et,o,tt){if(typeof et!="number"||et<2)throw new Error("hashLen must be a number");if(typeof o!="number"||o<2)throw new Error("qByteLen must be a number");if(typeof tt!="function")throw new Error("hmacFn must be a function");let rt=u8n(et),nt=u8n(et),ot=0;const it=()=>{rt.fill(1),nt.fill(0),ot=0},st=(...dt)=>tt(nt,rt,...dt),at=(dt=u8n())=>{nt=st(u8fr([0]),dt),rt=st(),dt.length!==0&&(nt=st(u8fr([1]),dt),rt=st())},ct=()=>{if(ot++>=1e3)throw new Error("drbg: tried 1000 values");let dt=0;const ht=[];for(;dt{it(),at(dt);let mt;for(;!(mt=ht(ct()));)at();return it(),mt}}const validatorFns={bigint:et=>typeof et=="bigint",function:et=>typeof et=="function",boolean:et=>typeof et=="boolean",string:et=>typeof et=="string",stringOrUint8Array:et=>typeof et=="string"||isBytes$2(et),isSafeInteger:et=>Number.isSafeInteger(et),array:et=>Array.isArray(et),field:(et,o)=>o.Fp.isValid(et),hash:et=>typeof et=="function"&&Number.isSafeInteger(et.outputLen)};function validateObject(et,o,tt={}){const rt=(nt,ot,it)=>{const st=validatorFns[ot];if(typeof st!="function")throw new Error(`Invalid validator "${ot}", expected function`);const at=et[nt];if(!(it&&at===void 0)&&!st(at,et))throw new Error(`Invalid param ${String(nt)}=${at} (${typeof at}), expected ${ot}`)};for(const[nt,ot]of Object.entries(o))rt(nt,ot,!1);for(const[nt,ot]of Object.entries(tt))rt(nt,ot,!0);return et}const notImplemented=()=>{throw new Error("not implemented")};function memoized(et){const o=new WeakMap;return(tt,...rt)=>{const nt=o.get(tt);if(nt!==void 0)return nt;const ot=et(tt,...rt);return o.set(tt,ot),ot}}const ut=Object.freeze(Object.defineProperty({__proto__:null,aInRange,abool,abytes,bitGet,bitLen,bitMask,bitSet,bytesToHex:bytesToHex$2,bytesToNumberBE,bytesToNumberLE,concatBytes:concatBytes$1,createHmacDrbg,ensureBytes:ensureBytes$1,equalBytes:equalBytes$1,hexToBytes:hexToBytes$2,hexToNumber:hexToNumber$1,inRange,isBytes:isBytes$2,memoized,notImplemented,numberToBytesBE,numberToBytesLE,numberToHexUnpadded:numberToHexUnpadded$1,numberToVarBytesBE,utf8ToBytes:utf8ToBytes$2,validateObject},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$5=BigInt(0),_1n$7=BigInt(1),_2n$4=BigInt(2),_3n$3=BigInt(3),_4n=BigInt(4),_5n$1=BigInt(5),_8n$3=BigInt(8);BigInt(9);BigInt(16);function mod$1(et,o){const tt=et%o;return tt>=_0n$5?tt:o+tt}function pow(et,o,tt){if(tt<=_0n$5||o<_0n$5)throw new Error("Expected power/modulo > 0");if(tt===_1n$7)return _0n$5;let rt=_1n$7;for(;o>_0n$5;)o&_1n$7&&(rt=rt*et%tt),et=et*et%tt,o>>=_1n$7;return rt}function pow2$1(et,o,tt){let rt=et;for(;o-- >_0n$5;)rt*=rt,rt%=tt;return rt}function invert$1(et,o){if(et===_0n$5||o<=_0n$5)throw new Error(`invert: expected positive integers, got n=${et} mod=${o}`);let tt=mod$1(et,o),rt=o,nt=_0n$5,ot=_1n$7;for(;tt!==_0n$5;){const st=rt/tt,at=rt%tt,ct=nt-ot*st;rt=tt,tt=at,nt=ot,ot=ct}if(rt!==_1n$7)throw new Error("invert: does not exist");return mod$1(nt,o)}function tonelliShanks(et){const o=(et-_1n$7)/_2n$4;let tt,rt,nt;for(tt=et-_1n$7,rt=0;tt%_2n$4===_0n$5;tt/=_2n$4,rt++);for(nt=_2n$4;nt(mod$1(et,o)&_1n$7)===_1n$7,FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(et){const o={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},tt=FIELD_FIELDS.reduce((rt,nt)=>(rt[nt]="function",rt),o);return validateObject(et,tt)}function FpPow(et,o,tt){if(tt<_0n$5)throw new Error("Expected power > 0");if(tt===_0n$5)return et.ONE;if(tt===_1n$7)return o;let rt=et.ONE,nt=o;for(;tt>_0n$5;)tt&_1n$7&&(rt=et.mul(rt,nt)),nt=et.sqr(nt),tt>>=_1n$7;return rt}function FpInvertBatch(et,o){const tt=new Array(o.length),rt=o.reduce((ot,it,st)=>et.is0(it)?ot:(tt[st]=ot,et.mul(ot,it)),et.ONE),nt=et.inv(rt);return o.reduceRight((ot,it,st)=>et.is0(it)?ot:(tt[st]=et.mul(ot,tt[st]),et.mul(ot,it)),nt),tt}function nLength(et,o){const tt=o!==void 0?o:et.toString(2).length,rt=Math.ceil(tt/8);return{nBitLength:tt,nByteLength:rt}}function Field$1(et,o,tt=!1,rt={}){if(et<=_0n$5)throw new Error(`Expected Field ORDER > 0, got ${et}`);const{nBitLength:nt,nByteLength:ot}=nLength(et,o);if(ot>2048)throw new Error("Field lengths over 2048 bytes are not supported");const it=FpSqrt(et),st=Object.freeze({ORDER:et,BITS:nt,BYTES:ot,MASK:bitMask(nt),ZERO:_0n$5,ONE:_1n$7,create:at=>mod$1(at,et),isValid:at=>{if(typeof at!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof at}`);return _0n$5<=at&&atat===_0n$5,isOdd:at=>(at&_1n$7)===_1n$7,neg:at=>mod$1(-at,et),eql:(at,ct)=>at===ct,sqr:at=>mod$1(at*at,et),add:(at,ct)=>mod$1(at+ct,et),sub:(at,ct)=>mod$1(at-ct,et),mul:(at,ct)=>mod$1(at*ct,et),pow:(at,ct)=>FpPow(st,at,ct),div:(at,ct)=>mod$1(at*invert$1(ct,et),et),sqrN:at=>at*at,addN:(at,ct)=>at+ct,subN:(at,ct)=>at-ct,mulN:(at,ct)=>at*ct,inv:at=>invert$1(at,et),sqrt:rt.sqrt||(at=>it(st,at)),invertBatch:at=>FpInvertBatch(st,at),cmov:(at,ct,lt)=>lt?ct:at,toBytes:at=>tt?numberToBytesLE(at,ot):numberToBytesBE(at,ot),fromBytes:at=>{if(at.length!==ot)throw new Error(`Fp.fromBytes: expected ${ot}, got ${at.length}`);return tt?bytesToNumberLE(at):bytesToNumberBE(at)}});return Object.freeze(st)}function getFieldBytesLength(et){if(typeof et!="bigint")throw new Error("field order must be bigint");const o=et.toString(2).length;return Math.ceil(o/8)}function getMinHashLength(et){const o=getFieldBytesLength(et);return o+Math.ceil(o/2)}function mapHashToField(et,o,tt=!1){const rt=et.length,nt=getFieldBytesLength(o),ot=getMinHashLength(o);if(rt<16||rt1024)throw new Error(`expected ${ot}-1024 bytes of input, got ${rt}`);const it=tt?bytesToNumberBE(et):bytesToNumberLE(et),st=mod$1(it,o-_1n$7)+_1n$7;return tt?numberToBytesLE(st,nt):numberToBytesBE(st,nt)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$4=BigInt(0),_1n$6=BigInt(1),pointPrecomputes$1=new WeakMap,pointWindowSizes=new WeakMap;function wNAF(et,o){const tt=(ot,it)=>{const st=it.negate();return ot?st:it},rt=ot=>{if(!Number.isSafeInteger(ot)||ot<=0||ot>o)throw new Error(`Wrong window size=${ot}, should be [1..${o}]`)},nt=ot=>{rt(ot);const it=Math.ceil(o/ot)+1,st=2**(ot-1);return{windows:it,windowSize:st}};return{constTimeNegate:tt,unsafeLadder(ot,it){let st=et.ZERO,at=ot;for(;it>_0n$4;)it&_1n$6&&(st=st.add(at)),at=at.double(),it>>=_1n$6;return st},precomputeWindow(ot,it){const{windows:st,windowSize:at}=nt(it),ct=[];let lt=ot,dt=lt;for(let ht=0;ht>=ft,gt>ct&&(gt-=mt,st+=_1n$6);const bt=yt,xt=yt+Math.abs(gt)-1,vt=pt%2!==0,Et=gt<0;gt===0?dt=dt.add(tt(vt,it[bt])):lt=lt.add(tt(Et,it[xt]))}return{p:lt,f:dt}},wNAFCached(ot,it,st){const at=pointWindowSizes.get(ot)||1;let ct=pointPrecomputes$1.get(ot);return ct||(ct=this.precomputeWindow(ot,at),at!==1&&pointPrecomputes$1.set(ot,st(ct))),this.wNAF(at,ct,it)},setWindowSize(ot,it){rt(it),pointWindowSizes.set(ot,it),pointPrecomputes$1.delete(ot)}}}function pippenger(et,o,tt,rt){if(!Array.isArray(tt)||!Array.isArray(rt)||rt.length!==tt.length)throw new Error("arrays of points and scalars must have equal length");rt.forEach((lt,dt)=>{if(!o.isValid(lt))throw new Error(`wrong scalar at index ${dt}`)}),tt.forEach((lt,dt)=>{if(!(lt instanceof et))throw new Error(`wrong point at index ${dt}`)});const nt=bitLen(BigInt(tt.length)),ot=nt>12?nt-3:nt>4?nt-2:nt?2:1,it=(1<=0;lt-=ot){st.fill(et.ZERO);for(let ht=0;ht>BigInt(lt)&BigInt(it));st[ft]=st[ft].add(tt[ht])}let dt=et.ZERO;for(let ht=st.length-1,mt=et.ZERO;ht>0;ht--)mt=mt.add(st[ht]),dt=dt.add(mt);if(ct=ct.add(dt),lt!==0)for(let ht=0;ht{const{Err:tt}=DER;if(et<0||et>256)throw new tt("tlv.encode: wrong tag");if(o.length&1)throw new tt("tlv.encode: unpadded data");const rt=o.length/2,nt=numberToHexUnpadded$1(rt);if(nt.length/2&128)throw new tt("tlv.encode: long form length too big");const ot=rt>127?numberToHexUnpadded$1(nt.length/2|128):"";return`${numberToHexUnpadded$1(et)}${ot}${nt}${o}`},decode(et,o){const{Err:tt}=DER;let rt=0;if(et<0||et>256)throw new tt("tlv.encode: wrong tag");if(o.length<2||o[rt++]!==et)throw new tt("tlv.decode: wrong tlv");const nt=o[rt++],ot=!!(nt&128);let it=0;if(!ot)it=nt;else{const at=nt&127;if(!at)throw new tt("tlv.decode(long): indefinite length not supported");if(at>4)throw new tt("tlv.decode(long): byte length is too big");const ct=o.subarray(rt,rt+at);if(ct.length!==at)throw new tt("tlv.decode: length bytes not complete");if(ct[0]===0)throw new tt("tlv.decode(long): zero leftmost byte");for(const lt of ct)it=it<<8|lt;if(rt+=at,it<128)throw new tt("tlv.decode(long): not minimal encoding")}const st=o.subarray(rt,rt+it);if(st.length!==it)throw new tt("tlv.decode: wrong value length");return{v:st,l:o.subarray(rt+it)}}},_int:{encode(et){const{Err:o}=DER;if(et<_0n$3)throw new o("integer: negative integers are not allowed");let tt=numberToHexUnpadded$1(et);if(Number.parseInt(tt[0],16)&8&&(tt="00"+tt),tt.length&1)throw new o("unexpected assertion");return tt},decode(et){const{Err:o}=DER;if(et[0]&128)throw new o("Invalid signature integer: negative");if(et[0]===0&&!(et[1]&128))throw new o("Invalid signature integer: unnecessary leading zero");return b2n(et)}},toSig(et){const{Err:o,_int:tt,_tlv:rt}=DER,nt=typeof et=="string"?h2b(et):et;abytes(nt);const{v:ot,l:it}=rt.decode(48,nt);if(it.length)throw new o("Invalid signature: left bytes after parsing");const{v:st,l:at}=rt.decode(2,ot),{v:ct,l:lt}=rt.decode(2,at);if(lt.length)throw new o("Invalid signature: left bytes after parsing");return{r:tt.decode(st),s:tt.decode(ct)}},hexFromSig(et){const{_tlv:o,_int:tt}=DER,rt=`${o.encode(2,tt.encode(et.r))}${o.encode(2,tt.encode(et.s))}`;return o.encode(48,rt)}},_0n$3=BigInt(0),_1n$5=BigInt(1);BigInt(2);const _3n$2=BigInt(3);BigInt(4);function weierstrassPoints(et){const o=validatePointOpts(et),{Fp:tt}=o,rt=Field$1(o.n,o.nBitLength),nt=o.toBytes||((pt,yt,gt)=>{const bt=yt.toAffine();return concatBytes$1(Uint8Array.from([4]),tt.toBytes(bt.x),tt.toBytes(bt.y))}),ot=o.fromBytes||(pt=>{const yt=pt.subarray(1),gt=tt.fromBytes(yt.subarray(0,tt.BYTES)),bt=tt.fromBytes(yt.subarray(tt.BYTES,2*tt.BYTES));return{x:gt,y:bt}});function it(pt){const{a:yt,b:gt}=o,bt=tt.sqr(pt),xt=tt.mul(bt,pt);return tt.add(tt.add(xt,tt.mul(pt,yt)),gt)}if(!tt.eql(tt.sqr(o.Gy),it(o.Gx)))throw new Error("bad generator point: equation left != right");function st(pt){return inRange(pt,_1n$5,o.n)}function at(pt){const{allowedPrivateKeyLengths:yt,nByteLength:gt,wrapPrivateKey:bt,n:xt}=o;if(yt&&typeof pt!="bigint"){if(isBytes$2(pt)&&(pt=bytesToHex$2(pt)),typeof pt!="string"||!yt.includes(pt.length))throw new Error("Invalid key");pt=pt.padStart(gt*2,"0")}let vt;try{vt=typeof pt=="bigint"?pt:bytesToNumberBE(ensureBytes$1("private key",pt,gt))}catch{throw new Error(`private key must be ${gt} bytes, hex or bigint, not ${typeof pt}`)}return bt&&(vt=mod$1(vt,xt)),aInRange("private key",vt,_1n$5,xt),vt}function ct(pt){if(!(pt instanceof ht))throw new Error("ProjectivePoint expected")}const lt=memoized((pt,yt)=>{const{px:gt,py:bt,pz:xt}=pt;if(tt.eql(xt,tt.ONE))return{x:gt,y:bt};const vt=pt.is0();yt==null&&(yt=vt?tt.ONE:tt.inv(xt));const Et=tt.mul(gt,yt),Ct=tt.mul(bt,yt),St=tt.mul(xt,yt);if(vt)return{x:tt.ZERO,y:tt.ZERO};if(!tt.eql(St,tt.ONE))throw new Error("invZ was invalid");return{x:Et,y:Ct}}),dt=memoized(pt=>{if(pt.is0()){if(o.allowInfinityPoint&&!tt.is0(pt.py))return;throw new Error("bad point: ZERO")}const{x:yt,y:gt}=pt.toAffine();if(!tt.isValid(yt)||!tt.isValid(gt))throw new Error("bad point: x or y not FE");const bt=tt.sqr(gt),xt=it(yt);if(!tt.eql(bt,xt))throw new Error("bad point: equation left != right");if(!pt.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class ht{constructor(yt,gt,bt){if(this.px=yt,this.py=gt,this.pz=bt,yt==null||!tt.isValid(yt))throw new Error("x required");if(gt==null||!tt.isValid(gt))throw new Error("y required");if(bt==null||!tt.isValid(bt))throw new Error("z required");Object.freeze(this)}static fromAffine(yt){const{x:gt,y:bt}=yt||{};if(!yt||!tt.isValid(gt)||!tt.isValid(bt))throw new Error("invalid affine point");if(yt instanceof ht)throw new Error("projective point not allowed");const xt=vt=>tt.eql(vt,tt.ZERO);return xt(gt)&&xt(bt)?ht.ZERO:new ht(gt,bt,tt.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(yt){const gt=tt.invertBatch(yt.map(bt=>bt.pz));return yt.map((bt,xt)=>bt.toAffine(gt[xt])).map(ht.fromAffine)}static fromHex(yt){const gt=ht.fromAffine(ot(ensureBytes$1("pointHex",yt)));return gt.assertValidity(),gt}static fromPrivateKey(yt){return ht.BASE.multiply(at(yt))}static msm(yt,gt){return pippenger(ht,rt,yt,gt)}_setWindowSize(yt){ft.setWindowSize(this,yt)}assertValidity(){dt(this)}hasEvenY(){const{y:yt}=this.toAffine();if(tt.isOdd)return!tt.isOdd(yt);throw new Error("Field doesn't support isOdd")}equals(yt){ct(yt);const{px:gt,py:bt,pz:xt}=this,{px:vt,py:Et,pz:Ct}=yt,St=tt.eql(tt.mul(gt,Ct),tt.mul(vt,xt)),At=tt.eql(tt.mul(bt,Ct),tt.mul(Et,xt));return St&&At}negate(){return new ht(this.px,tt.neg(this.py),this.pz)}double(){const{a:yt,b:gt}=o,bt=tt.mul(gt,_3n$2),{px:xt,py:vt,pz:Et}=this;let Ct=tt.ZERO,St=tt.ZERO,At=tt.ZERO,kt=tt.mul(xt,xt),It=tt.mul(vt,vt),Nt=tt.mul(Et,Et),Lt=tt.mul(xt,vt);return Lt=tt.add(Lt,Lt),At=tt.mul(xt,Et),At=tt.add(At,At),Ct=tt.mul(yt,At),St=tt.mul(bt,Nt),St=tt.add(Ct,St),Ct=tt.sub(It,St),St=tt.add(It,St),St=tt.mul(Ct,St),Ct=tt.mul(Lt,Ct),At=tt.mul(bt,At),Nt=tt.mul(yt,Nt),Lt=tt.sub(kt,Nt),Lt=tt.mul(yt,Lt),Lt=tt.add(Lt,At),At=tt.add(kt,kt),kt=tt.add(At,kt),kt=tt.add(kt,Nt),kt=tt.mul(kt,Lt),St=tt.add(St,kt),Nt=tt.mul(vt,Et),Nt=tt.add(Nt,Nt),kt=tt.mul(Nt,Lt),Ct=tt.sub(Ct,kt),At=tt.mul(Nt,It),At=tt.add(At,At),At=tt.add(At,At),new ht(Ct,St,At)}add(yt){ct(yt);const{px:gt,py:bt,pz:xt}=this,{px:vt,py:Et,pz:Ct}=yt;let St=tt.ZERO,At=tt.ZERO,kt=tt.ZERO;const It=o.a,Nt=tt.mul(o.b,_3n$2);let Lt=tt.mul(gt,vt),Mt=tt.mul(bt,Et),zt=tt.mul(xt,Ct),Ut=tt.add(gt,bt),Xt=tt.add(vt,Et);Ut=tt.mul(Ut,Xt),Xt=tt.add(Lt,Mt),Ut=tt.sub(Ut,Xt),Xt=tt.add(gt,xt);let Wt=tt.add(vt,Ct);return Xt=tt.mul(Xt,Wt),Wt=tt.add(Lt,zt),Xt=tt.sub(Xt,Wt),Wt=tt.add(bt,xt),St=tt.add(Et,Ct),Wt=tt.mul(Wt,St),St=tt.add(Mt,zt),Wt=tt.sub(Wt,St),kt=tt.mul(It,Xt),St=tt.mul(Nt,zt),kt=tt.add(St,kt),St=tt.sub(Mt,kt),kt=tt.add(Mt,kt),At=tt.mul(St,kt),Mt=tt.add(Lt,Lt),Mt=tt.add(Mt,Lt),zt=tt.mul(It,zt),Xt=tt.mul(Nt,Xt),Mt=tt.add(Mt,zt),zt=tt.sub(Lt,zt),zt=tt.mul(It,zt),Xt=tt.add(Xt,zt),Lt=tt.mul(Mt,Xt),At=tt.add(At,Lt),Lt=tt.mul(Wt,Xt),St=tt.mul(Ut,St),St=tt.sub(St,Lt),Lt=tt.mul(Ut,Mt),kt=tt.mul(Wt,kt),kt=tt.add(kt,Lt),new ht(St,At,kt)}subtract(yt){return this.add(yt.negate())}is0(){return this.equals(ht.ZERO)}wNAF(yt){return ft.wNAFCached(this,yt,ht.normalizeZ)}multiplyUnsafe(yt){aInRange("scalar",yt,_0n$3,o.n);const gt=ht.ZERO;if(yt===_0n$3)return gt;if(yt===_1n$5)return this;const{endo:bt}=o;if(!bt)return ft.unsafeLadder(this,yt);let{k1neg:xt,k1:vt,k2neg:Et,k2:Ct}=bt.splitScalar(yt),St=gt,At=gt,kt=this;for(;vt>_0n$3||Ct>_0n$3;)vt&_1n$5&&(St=St.add(kt)),Ct&_1n$5&&(At=At.add(kt)),kt=kt.double(),vt>>=_1n$5,Ct>>=_1n$5;return xt&&(St=St.negate()),Et&&(At=At.negate()),At=new ht(tt.mul(At.px,bt.beta),At.py,At.pz),St.add(At)}multiply(yt){const{endo:gt,n:bt}=o;aInRange("scalar",yt,_1n$5,bt);let xt,vt;if(gt){const{k1neg:Et,k1:Ct,k2neg:St,k2:At}=gt.splitScalar(yt);let{p:kt,f:It}=this.wNAF(Ct),{p:Nt,f:Lt}=this.wNAF(At);kt=ft.constTimeNegate(Et,kt),Nt=ft.constTimeNegate(St,Nt),Nt=new ht(tt.mul(Nt.px,gt.beta),Nt.py,Nt.pz),xt=kt.add(Nt),vt=It.add(Lt)}else{const{p:Et,f:Ct}=this.wNAF(yt);xt=Et,vt=Ct}return ht.normalizeZ([xt,vt])[0]}multiplyAndAddUnsafe(yt,gt,bt){const xt=ht.BASE,vt=(Ct,St)=>St===_0n$3||St===_1n$5||!Ct.equals(xt)?Ct.multiplyUnsafe(St):Ct.multiply(St),Et=vt(this,gt).add(vt(yt,bt));return Et.is0()?void 0:Et}toAffine(yt){return lt(this,yt)}isTorsionFree(){const{h:yt,isTorsionFree:gt}=o;if(yt===_1n$5)return!0;if(gt)return gt(ht,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:yt,clearCofactor:gt}=o;return yt===_1n$5?this:gt?gt(ht,this):this.multiplyUnsafe(o.h)}toRawBytes(yt=!0){return abool("isCompressed",yt),this.assertValidity(),nt(ht,this,yt)}toHex(yt=!0){return abool("isCompressed",yt),bytesToHex$2(this.toRawBytes(yt))}}ht.BASE=new ht(o.Gx,o.Gy,tt.ONE),ht.ZERO=new ht(tt.ZERO,tt.ONE,tt.ZERO);const mt=o.nBitLength,ft=wNAF(ht,o.endo?Math.ceil(mt/2):mt);return{CURVE:o,ProjectivePoint:ht,normPrivateKeyToScalar:at,weierstrassEquation:it,isWithinCurveOrder:st}}function validateOpts$2(et){const o=validateBasic(et);return validateObject(o,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...o})}function weierstrass$1(et){const o=validateOpts$2(et),{Fp:tt,n:rt}=o,nt=tt.BYTES+1,ot=2*tt.BYTES+1;function it(zt){return mod$1(zt,rt)}function st(zt){return invert$1(zt,rt)}const{ProjectivePoint:at,normPrivateKeyToScalar:ct,weierstrassEquation:lt,isWithinCurveOrder:dt}=weierstrassPoints({...o,toBytes(zt,Ut,Xt){const Wt=Ut.toAffine(),Ft=tt.toBytes(Wt.x),qt=concatBytes$1;return abool("isCompressed",Xt),Xt?qt(Uint8Array.from([Ut.hasEvenY()?2:3]),Ft):qt(Uint8Array.from([4]),Ft,tt.toBytes(Wt.y))},fromBytes(zt){const Ut=zt.length,Xt=zt[0],Wt=zt.subarray(1);if(Ut===nt&&(Xt===2||Xt===3)){const Ft=bytesToNumberBE(Wt);if(!inRange(Ft,_1n$5,tt.ORDER))throw new Error("Point is not on curve");const qt=lt(Ft);let Pt;try{Pt=tt.sqrt(qt)}catch(jt){const Gt=jt instanceof Error?": "+jt.message:"";throw new Error("Point is not on curve"+Gt)}const Yt=(Pt&_1n$5)===_1n$5;return(Xt&1)===1!==Yt&&(Pt=tt.neg(Pt)),{x:Ft,y:Pt}}else if(Ut===ot&&Xt===4){const Ft=tt.fromBytes(Wt.subarray(0,tt.BYTES)),qt=tt.fromBytes(Wt.subarray(tt.BYTES,2*tt.BYTES));return{x:Ft,y:qt}}else throw new Error(`Point of length ${Ut} was invalid. Expected ${nt} compressed bytes or ${ot} uncompressed bytes`)}}),ht=zt=>bytesToHex$2(numberToBytesBE(zt,o.nByteLength));function mt(zt){const Ut=rt>>_1n$5;return zt>Ut}function ft(zt){return mt(zt)?it(-zt):zt}const pt=(zt,Ut,Xt)=>bytesToNumberBE(zt.slice(Ut,Xt));class yt{constructor(Ut,Xt,Wt){this.r=Ut,this.s=Xt,this.recovery=Wt,this.assertValidity()}static fromCompact(Ut){const Xt=o.nByteLength;return Ut=ensureBytes$1("compactSignature",Ut,Xt*2),new yt(pt(Ut,0,Xt),pt(Ut,Xt,2*Xt))}static fromDER(Ut){const{r:Xt,s:Wt}=DER.toSig(ensureBytes$1("DER",Ut));return new yt(Xt,Wt)}assertValidity(){aInRange("r",this.r,_1n$5,rt),aInRange("s",this.s,_1n$5,rt)}addRecoveryBit(Ut){return new yt(this.r,this.s,Ut)}recoverPublicKey(Ut){const{r:Xt,s:Wt,recovery:Ft}=this,qt=Ct(ensureBytes$1("msgHash",Ut));if(Ft==null||![0,1,2,3].includes(Ft))throw new Error("recovery id invalid");const Pt=Ft===2||Ft===3?Xt+o.n:Xt;if(Pt>=tt.ORDER)throw new Error("recovery id 2 or 3 invalid");const Yt=Ft&1?"03":"02",Qt=at.fromHex(Yt+ht(Pt)),jt=st(Pt),Gt=it(-qt*jt),rr=it(Wt*jt),Ht=at.BASE.multiplyAndAddUnsafe(Qt,Gt,rr);if(!Ht)throw new Error("point at infinify");return Ht.assertValidity(),Ht}hasHighS(){return mt(this.s)}normalizeS(){return this.hasHighS()?new yt(this.r,it(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$2(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$2(this.toCompactHex())}toCompactHex(){return ht(this.r)+ht(this.s)}}const gt={isValidPrivateKey(zt){try{return ct(zt),!0}catch{return!1}},normPrivateKeyToScalar:ct,randomPrivateKey:()=>{const zt=getMinHashLength(o.n);return mapHashToField(o.randomBytes(zt),o.n)},precompute(zt=8,Ut=at.BASE){return Ut._setWindowSize(zt),Ut.multiply(BigInt(3)),Ut}};function bt(zt,Ut=!0){return at.fromPrivateKey(zt).toRawBytes(Ut)}function xt(zt){const Ut=isBytes$2(zt),Xt=typeof zt=="string",Wt=(Ut||Xt)&&zt.length;return Ut?Wt===nt||Wt===ot:Xt?Wt===2*nt||Wt===2*ot:zt instanceof at}function vt(zt,Ut,Xt=!0){if(xt(zt))throw new Error("first arg must be private key");if(!xt(Ut))throw new Error("second arg must be public key");return at.fromHex(Ut).multiply(ct(zt)).toRawBytes(Xt)}const Et=o.bits2int||function(zt){const Ut=bytesToNumberBE(zt),Xt=zt.length*8-o.nBitLength;return Xt>0?Ut>>BigInt(Xt):Ut},Ct=o.bits2int_modN||function(zt){return it(Et(zt))},St=bitMask(o.nBitLength);function At(zt){return aInRange(`num < 2^${o.nBitLength}`,zt,_0n$3,St),numberToBytesBE(zt,o.nByteLength)}function kt(zt,Ut,Xt=It){if(["recovered","canonical"].some(Zt=>Zt in Xt))throw new Error("sign() legacy options not supported");const{hash:Wt,randomBytes:Ft}=o;let{lowS:qt,prehash:Pt,extraEntropy:Yt}=Xt;qt==null&&(qt=!0),zt=ensureBytes$1("msgHash",zt),validateSigVerOpts(Xt),Pt&&(zt=ensureBytes$1("prehashed msgHash",Wt(zt)));const Qt=Ct(zt),jt=ct(Ut),Gt=[At(jt),At(Qt)];if(Yt!=null&&Yt!==!1){const Zt=Yt===!0?Ft(tt.BYTES):Yt;Gt.push(ensureBytes$1("extraEntropy",Zt))}const rr=concatBytes$1(...Gt),Ht=Qt;function dr(Zt){const Jt=Et(Zt);if(!dt(Jt))return;const tr=st(Jt),_t=at.BASE.multiply(Jt).toAffine(),Bt=it(_t.x);if(Bt===_0n$3)return;const Vt=it(tr*it(Ht+Bt*jt));if(Vt===_0n$3)return;let er=(_t.x===Bt?0:2)|Number(_t.y&_1n$5),ar=Vt;return qt&&mt(Vt)&&(ar=ft(Vt),er^=1),new yt(Bt,ar,er)}return{seed:rr,k2sig:dr}}const It={lowS:o.lowS,prehash:!1},Nt={lowS:o.lowS,prehash:!1};function Lt(zt,Ut,Xt=It){const{seed:Wt,k2sig:Ft}=kt(zt,Ut,Xt),qt=o;return createHmacDrbg(qt.hash.outputLen,qt.nByteLength,qt.hmac)(Wt,Ft)}at.BASE._setWindowSize(8);function Mt(zt,Ut,Xt,Wt=Nt){var _t;const Ft=zt;if(Ut=ensureBytes$1("msgHash",Ut),Xt=ensureBytes$1("publicKey",Xt),"strict"in Wt)throw new Error("options.strict was renamed to lowS");validateSigVerOpts(Wt);const{lowS:qt,prehash:Pt}=Wt;let Yt,Qt;try{if(typeof Ft=="string"||isBytes$2(Ft))try{Yt=yt.fromDER(Ft)}catch(Bt){if(!(Bt instanceof DER.Err))throw Bt;Yt=yt.fromCompact(Ft)}else if(typeof Ft=="object"&&typeof Ft.r=="bigint"&&typeof Ft.s=="bigint"){const{r:Bt,s:Vt}=Ft;Yt=new yt(Bt,Vt)}else throw new Error("PARSE");Qt=at.fromHex(Xt)}catch(Bt){if(Bt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(qt&&Yt.hasHighS())return!1;Pt&&(Ut=o.hash(Ut));const{r:jt,s:Gt}=Yt,rr=Ct(Ut),Ht=st(Gt),dr=it(rr*Ht),Zt=it(jt*Ht),Jt=(_t=at.BASE.multiplyAndAddUnsafe(Qt,dr,Zt))==null?void 0:_t.toAffine();return Jt?it(Jt.x)===jt:!1}return{CURVE:o,getPublicKey:bt,getSharedSecret:vt,sign:Lt,verify:Mt,ProjectivePoint:at,Signature:yt,utils:gt}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(et){return{hash:et,hmac:(o,...tt)=>hmac(et,o,concatBytes$2(...tt)),randomBytes:randomBytes$1}}function createCurve(et,o){const tt=rt=>weierstrass$1({...et,...getHash(rt)});return Object.freeze({...tt(o),create:tt})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$4=BigInt(1),_2n$3=BigInt(2),divNearest$1=(et,o)=>(et+o/_2n$3)/o;function sqrtMod$1(et){const o=secp256k1P,tt=BigInt(3),rt=BigInt(6),nt=BigInt(11),ot=BigInt(22),it=BigInt(23),st=BigInt(44),at=BigInt(88),ct=et*et*et%o,lt=ct*ct*et%o,dt=pow2$1(lt,tt,o)*lt%o,ht=pow2$1(dt,tt,o)*lt%o,mt=pow2$1(ht,_2n$3,o)*ct%o,ft=pow2$1(mt,nt,o)*mt%o,pt=pow2$1(ft,ot,o)*ft%o,yt=pow2$1(pt,st,o)*pt%o,gt=pow2$1(yt,at,o)*yt%o,bt=pow2$1(gt,st,o)*pt%o,xt=pow2$1(bt,tt,o)*lt%o,vt=pow2$1(xt,it,o)*ft%o,Et=pow2$1(vt,rt,o)*ct%o,Ct=pow2$1(Et,_2n$3,o);if(!Fp$1.eql(Fp$1.sqr(Ct),et))throw new Error("Cannot find square root");return Ct}const Fp$1=Field$1(secp256k1P,void 0,void 0,{sqrt:sqrtMod$1}),secp256k1=createCurve({a:BigInt(0),b:BigInt(7),Fp:Fp$1,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:et=>{const o=secp256k1N,tt=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),rt=-_1n$4*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),nt=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),ot=tt,it=BigInt("0x100000000000000000000000000000000"),st=divNearest$1(ot*et,o),at=divNearest$1(-rt*et,o);let ct=mod$1(et-st*tt-at*nt,o),lt=mod$1(-st*rt-at*ot,o);const dt=ct>it,ht=lt>it;if(dt&&(ct=o-ct),ht&&(lt=o-lt),ct>it||lt>it)throw new Error("splitScalar: Endomorphism failed, k="+et);return{k1neg:dt,k1:ct,k2neg:ht,k2:lt}}}},sha256$3);BigInt(0);secp256k1.ProjectivePoint;function getAction(et,o,tt){const rt=et[o.name];if(typeof rt=="function")return rt;const nt=et[tt];return typeof nt=="function"?nt:ot=>o(et,ot)}const version$6="2.13.8",getVersion$1=()=>`@wagmi/core@${version$6}`;var __classPrivateFieldGet$1=function(et,o,tt,rt){if(tt==="a"&&!rt)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?et!==o||!rt:!o.has(et))throw new TypeError("Cannot read private member from an object whose class did not declare it");return tt==="m"?rt:tt==="a"?rt.call(et):rt?rt.value:o.get(et)},_BaseError_instances,_BaseError_walk;let BaseError$1=class _s extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return getVersion$1()}constructor(o,tt={}){var ot;super(),_BaseError_instances.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const rt=tt.cause instanceof _s?tt.cause.details:(ot=tt.cause)!=null&&ot.message?tt.cause.message:tt.details,nt=tt.cause instanceof _s&&tt.cause.docsPath||tt.docsPath;this.message=[o||"An error occurred.","",...tt.metaMessages?[...tt.metaMessages,""]:[],...nt?[`Docs: ${this.docsBaseUrl}${nt}.html${tt.docsSlug?`#${tt.docsSlug}`:""}`]:[],...rt?[`Details: ${rt}`]:[],`Version: ${this.version}`].join(` +`),tt.cause&&(this.cause=tt.cause),this.details=rt,this.docsPath=nt,this.metaMessages=tt.metaMessages,this.shortMessage=o}walk(o){return __classPrivateFieldGet$1(this,_BaseError_instances,"m",_BaseError_walk).call(this,this,o)}};_BaseError_instances=new WeakSet,_BaseError_walk=function et(o,tt){return tt!=null&&tt(o)?o:o.cause?__classPrivateFieldGet$1(this,_BaseError_instances,"m",et).call(this,o.cause,tt):o};class ChainNotConfiguredError extends BaseError$1{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class ConnectorAlreadyConnectedError extends BaseError$1{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class ConnectorNotConnectedError extends BaseError$1{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class ConnectorAccountNotFoundError extends BaseError$1{constructor({address:o,connector:tt}){super(`Account "${o}" not found for connector "${tt.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class ConnectorChainMismatchError extends BaseError$1{constructor({connectionChainId:o,connectorChainId:tt}){super(`The current chain of the connector (id: ${tt}) does not match the connection's chain (id: ${o}).`,{metaMessages:[`Current Chain ID: ${tt}`,`Expected Chain ID: ${o}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class ConnectorUnavailableReconnectingError extends BaseError$1{constructor({connector:o}){super(`Connector "${o.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uuid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function connect$1(et,o){var rt;let tt;if(typeof o.connector=="function"?tt=et._internal.connectors.setup(o.connector):tt=o.connector,tt.uid===et.state.current)throw new ConnectorAlreadyConnectedError;try{et.setState(it=>({...it,status:"connecting"})),tt.emitter.emit("message",{type:"connecting"});const nt=await tt.connect({chainId:o.chainId}),ot=nt.accounts;return tt.emitter.off("connect",et._internal.events.connect),tt.emitter.on("change",et._internal.events.change),tt.emitter.on("disconnect",et._internal.events.disconnect),await((rt=et.storage)==null?void 0:rt.setItem("recentConnectorId",tt.id)),et.setState(it=>({...it,connections:new Map(it.connections).set(tt.uid,{accounts:ot,chainId:nt.chainId,connector:tt}),current:tt.uid,status:"connected"})),{accounts:ot,chainId:nt.chainId}}catch(nt){throw et.setState(ot=>({...ot,status:ot.current?"connected":"disconnected"})),nt}}const size$1=256;let index$3=size$1,buffer$1;function uid$1(et=11){if(!buffer$1||index$3+et>size$1*2){buffer$1="",index$3=0;for(let o=0;o{const bt=gt(yt);for(const vt in ft)delete bt[vt];const xt={...yt,...bt};return Object.assign(xt,{extend:pt(xt)})}}return Object.assign(ft,{extend:pt(ft)})}function createTransport({key:et,name:o,request:tt,retryCount:rt=3,retryDelay:nt=150,timeout:ot,type:it},st){const at=uid$1();return{config:{key:et,name:o,request:tt,retryCount:rt,retryDelay:nt,timeout:ot,type:it},request:buildRequest(tt,{retryCount:rt,retryDelay:nt,uid:at}),value:st}}function custom(et,o={}){const{key:tt="custom",name:rt="Custom Provider",retryDelay:nt}=o;return({retryCount:ot})=>createTransport({key:tt,name:rt,request:et.request.bind(et),retryCount:o.retryCount??ot,retryDelay:nt,type:"custom"})}class UrlRequiredError extends BaseError$3{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function http(et,o={}){const{batch:tt,fetchOptions:rt,key:nt="http",name:ot="HTTP JSON-RPC",onFetchRequest:it,onFetchResponse:st,retryDelay:at}=o;return({chain:ct,retryCount:lt,timeout:dt})=>{const{batchSize:ht=1e3,wait:mt=0}=typeof tt=="object"?tt:{},ft=o.retryCount??lt,pt=dt??o.timeout??1e4,yt=ct==null?void 0:ct.rpcUrls.default.http[0];if(!yt)throw new UrlRequiredError;const gt=getHttpRpcClient(yt,{fetchOptions:rt,onRequest:it,onResponse:st,timeout:pt});return createTransport({key:nt,name:ot,async request({method:bt,params:xt}){const vt={method:bt,params:xt},{schedule:Et}=createBatchScheduler({id:yt,wait:mt,shouldSplitBatch(kt){return kt.length>ht},fn:kt=>gt.request({body:kt}),sort:(kt,It)=>kt.id-It.id}),Ct=async kt=>tt?Et(kt):[await gt.request({body:kt})],[{error:St,result:At}]=await Ct(vt);if(St)throw new RpcRequestError({body:vt,error:St,url:yt});return At},retryCount:ft,retryDelay:at,timeout:pt,type:"http"},{fetchOptions:rt,url:yt})}}async function getConnectorClient(et,o={}){let tt;if(o.connector){const{connector:ct}=o;if(et.state.status==="reconnecting"&&!ct.getAccounts&&!ct.getChainId)throw new ConnectorUnavailableReconnectingError({connector:ct});const[lt,dt]=await Promise.all([ct.getAccounts(),ct.getChainId()]);tt={accounts:lt,chainId:dt,connector:ct}}else tt=et.state.connections.get(et.state.current);if(!tt)throw new ConnectorNotConnectedError;const rt=o.chainId??tt.chainId,nt=await tt.connector.getChainId();if(nt!==tt.chainId)throw new ConnectorChainMismatchError({connectionChainId:tt.chainId,connectorChainId:nt});const ot=tt.connector;if(ot.getClient)return ot.getClient({chainId:rt});const it=parseAccount(o.account??tt.accounts[0]);if(it.address=getAddress(it.address),o.account&&!tt.accounts.some(ct=>ct.toLowerCase()===it.address.toLowerCase()))throw new ConnectorAccountNotFoundError({address:it.address,connector:ot});const st=et.chains.find(ct=>ct.id===rt),at=await tt.connector.getProvider({chainId:rt});return createClient({account:it,chain:st,name:"Connector Client",transport:ct=>custom(at)({...ct,retryCount:0})})}async function disconnect(et,o={}){var nt,ot;let tt;if(o.connector)tt=o.connector;else{const{connections:it,current:st}=et.state,at=it.get(st);tt=at==null?void 0:at.connector}const rt=et.state.connections;tt&&(await tt.disconnect(),tt.emitter.off("change",et._internal.events.change),tt.emitter.off("disconnect",et._internal.events.disconnect),tt.emitter.on("connect",et._internal.events.connect),rt.delete(tt.uid)),et.setState(it=>{if(rt.size===0)return{...it,connections:new Map,current:null,status:"disconnected"};const st=rt.values().next().value;return{...it,connections:new Map(rt),current:st.connector.uid}});{const it=et.state.current;if(!it)return;const st=(nt=et.state.connections.get(it))==null?void 0:nt.connector;if(!st)return;await((ot=et.storage)==null?void 0:ot.setItem("recentConnectorId",st.id))}}function getUnit(et){return typeof et=="number"?et:et==="wei"?0:Math.abs(weiUnits[et])}function getAccount(et){const o=et.state.current,tt=et.state.connections.get(o),rt=tt==null?void 0:tt.accounts,nt=rt==null?void 0:rt[0],ot=et.chains.find(st=>st.id===(tt==null?void 0:tt.chainId)),it=et.state.status;switch(it){case"connected":return{address:nt,addresses:rt,chain:ot,chainId:tt==null?void 0:tt.chainId,connector:tt==null?void 0:tt.connector,isConnected:!0,isConnecting:!1,isDisconnected:!1,isReconnecting:!1,status:it};case"reconnecting":return{address:nt,addresses:rt,chain:ot,chainId:tt==null?void 0:tt.chainId,connector:tt==null?void 0:tt.connector,isConnected:!!nt,isConnecting:!1,isDisconnected:!1,isReconnecting:!0,status:it};case"connecting":return{address:nt,addresses:rt,chain:ot,chainId:tt==null?void 0:tt.chainId,connector:tt==null?void 0:tt.connector,isConnected:!1,isConnecting:!0,isDisconnected:!1,isReconnecting:!1,status:it};case"disconnected":return{address:void 0,addresses:void 0,chain:void 0,chainId:void 0,connector:void 0,isConnected:!1,isConnecting:!1,isDisconnected:!0,isReconnecting:!1,status:it}}}async function multicall(et,o){const{allowFailure:tt=!0,chainId:rt,contracts:nt,...ot}=o,it=et.getClient({chainId:rt});return getAction(it,multicall$1,"multicall")({allowFailure:tt,contracts:nt,...ot})}function readContract(et,o){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,readContract$1,"readContract")(rt)}async function readContracts(et,o){var st;const{allowFailure:tt=!0,blockNumber:rt,blockTag:nt,...ot}=o,it=o.contracts;try{const at={};for(const[ht,mt]of it.entries()){const ft=mt.chainId??et.state.chainId;at[ft]||(at[ft]=[]),(st=at[ft])==null||st.push({contract:mt,index:ht})}const ct=()=>Object.entries(at).map(([ht,mt])=>multicall(et,{...ot,allowFailure:tt,blockNumber:rt,blockTag:nt,chainId:Number.parseInt(ht),contracts:mt.map(({contract:ft})=>ft)})),lt=(await Promise.all(ct())).flat(),dt=Object.values(at).flatMap(ht=>ht.map(({index:mt})=>mt));return lt.reduce((ht,mt,ft)=>(ht&&(ht[dt[ft]]=mt),ht),[])}catch(at){if(at instanceof ContractFunctionExecutionError)throw at;const ct=()=>it.map(lt=>readContract(et,{...lt,blockNumber:rt,blockTag:nt}));return tt?(await Promise.allSettled(ct())).map(lt=>lt.status==="fulfilled"?{result:lt.value,status:"success"}:{error:lt.reason,result:void 0,status:"failure"}):await Promise.all(ct())}}async function getBalance(et,o){const{address:tt,blockNumber:rt,blockTag:nt,chainId:ot,token:it,unit:st="ether"}=o;if(it)try{return getTokenBalance(et,{balanceAddress:tt,chainId:ot,symbolType:"string",tokenAddress:it})}catch(ht){if(ht instanceof ContractFunctionExecutionError){const mt=await getTokenBalance(et,{balanceAddress:tt,chainId:ot,symbolType:"bytes32",tokenAddress:it}),ft=hexToString(trim$1(mt.symbol,{dir:"right"}));return{...mt,symbol:ft}}throw ht}const at=et.getClient({chainId:ot}),lt=await getAction(at,getBalance$1,"getBalance")(rt?{address:tt,blockNumber:rt}:{address:tt,blockTag:nt}),dt=et.chains.find(ht=>ht.id===ot)??at.chain;return{decimals:dt.nativeCurrency.decimals,formatted:formatUnits(lt,getUnit(st)),symbol:dt.nativeCurrency.symbol,value:lt}}async function getTokenBalance(et,o){const{balanceAddress:tt,chainId:rt,symbolType:nt,tokenAddress:ot,unit:it}=o,st={abi:[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:nt}]}],address:ot},[at,ct,lt]=await readContracts(et,{allowFailure:!1,contracts:[{...st,functionName:"balanceOf",args:[tt],chainId:rt},{...st,functionName:"decimals",chainId:rt},{...st,functionName:"symbol",chainId:rt}]}),dt=formatUnits(at??"0",getUnit(it??ct));return{decimals:ct,formatted:dt,symbol:lt,value:at}}function getBlockNumber(et,o={}){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,getBlockNumber$1,"getBlockNumber")(rt)}function getChainId(et){return et.state.chainId}function deepEqual(et,o){if(et===o)return!0;if(et&&o&&typeof et=="object"&&typeof o=="object"){if(et.constructor!==o.constructor)return!1;let tt,rt;if(Array.isArray(et)&&Array.isArray(o)){if(tt=et.length,tt!==o.length)return!1;for(rt=tt;rt--!==0;)if(!deepEqual(et[rt],o[rt]))return!1;return!0}if(et.valueOf!==Object.prototype.valueOf)return et.valueOf()===o.valueOf();if(et.toString!==Object.prototype.toString)return et.toString()===o.toString();const nt=Object.keys(et);if(tt=nt.length,tt!==Object.keys(o).length)return!1;for(rt=tt;rt--!==0;)if(!Object.prototype.hasOwnProperty.call(o,nt[rt]))return!1;for(rt=tt;rt--!==0;){const ot=nt[rt];if(ot&&!deepEqual(et[ot],o[ot]))return!1}return!0}return et!==et&&o!==o}let previousChains=[];function getChains(et){const o=et.chains;return deepEqual(previousChains,o)?previousChains:(previousChains=o,o)}let previousConnections=[];function getConnections(et){const o=[...et.state.connections.values()];return et.state.status==="reconnecting"||deepEqual(previousConnections,o)?previousConnections:(previousConnections=o,o)}let previousConnectors=[];function getConnectors(et){const o=et.connectors;return deepEqual(previousConnectors,o)?previousConnectors:(previousConnectors=o,o)}function getEnsAddress(et,o){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,getEnsAddress$1,"getEnsAddress")(rt)}function getEnsAvatar(et,o){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,getEnsAvatar$1,"getEnsAvatar")(rt)}function getEnsName(et,o){const{chainId:tt,...rt}=o,nt=et.getClient({chainId:tt});return getAction(nt,getEnsName$1,"getEnsName")(rt)}let isReconnecting=!1;async function reconnect(et,o={}){var ct,lt;if(isReconnecting)return[];isReconnecting=!0,et.setState(dt=>({...dt,status:dt.current?"reconnecting":"connecting"}));const tt=[];if((ct=o.connectors)!=null&&ct.length)for(const dt of o.connectors){let ht;typeof dt=="function"?ht=et._internal.connectors.setup(dt):ht=dt,tt.push(ht)}else tt.push(...et.connectors);let rt;try{rt=await((lt=et.storage)==null?void 0:lt.getItem("recentConnectorId"))}catch{}const nt={};for(const[,dt]of et.state.connections)nt[dt.connector.id]=1;rt&&(nt[rt]=0);const ot=Object.keys(nt).length>0?[...tt].sort((dt,ht)=>(nt[dt.id]??10)-(nt[ht.id]??10)):tt;let it=!1;const st=[],at=[];for(const dt of ot){const ht=await dt.getProvider().catch(()=>{});if(!ht||at.some(pt=>pt===ht)||!await dt.isAuthorized())continue;const ft=await dt.connect({isReconnecting:!0}).catch(()=>null);ft&&(dt.emitter.off("connect",et._internal.events.connect),dt.emitter.on("change",et._internal.events.change),dt.emitter.on("disconnect",et._internal.events.disconnect),et.setState(pt=>{const yt=new Map(it?pt.connections:new Map).set(dt.uid,{accounts:ft.accounts,chainId:ft.chainId,connector:dt});return{...pt,current:it?pt.current:dt.uid,connections:yt}}),st.push({accounts:ft.accounts,chainId:ft.chainId,connector:dt}),at.push(ht),it=!0)}return(et.state.status==="reconnecting"||et.state.status==="connecting")&&(it?et.setState(dt=>({...dt,status:"connected"})):et.setState(dt=>({...dt,connections:new Map,current:null,status:"disconnected"}))),isReconnecting=!1,st}async function signMessage(et,o){const{account:tt,connector:rt,...nt}=o;let ot;return typeof tt=="object"&&tt.type==="local"?ot=et.getClient():ot=await getConnectorClient(et,{account:tt,connector:rt}),getAction(ot,signMessage$1,"signMessage")({...nt,...tt?{account:tt}:{}})}class ProviderNotFoundError extends BaseError$1{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}class SwitchChainNotSupportedError extends BaseError$1{constructor({connector:o}){super(`"${o.name}" does not support programmatic chain switching.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SwitchChainNotSupportedError"})}}async function switchChain(et,o){var it;const{addEthereumChainParameter:tt,chainId:rt}=o,nt=et.state.connections.get(((it=o.connector)==null?void 0:it.uid)??et.state.current);if(nt){const st=nt.connector;if(!st.switchChain)throw new SwitchChainNotSupportedError({connector:st});return await st.switchChain({addEthereumChainParameter:tt,chainId:rt})}const ot=et.chains.find(st=>st.id===rt);if(!ot)throw new ChainNotConfiguredError;return et.setState(st=>({...st,chainId:rt})),ot}function watchAccount(et,o){const{onChange:tt}=o;return et.subscribe(()=>getAccount(et),tt,{equalityFn(rt,nt){const{connector:ot,...it}=rt,{connector:st,...at}=nt;return deepEqual(it,at)&&(ot==null?void 0:ot.id)===(st==null?void 0:st.id)&&(ot==null?void 0:ot.uid)===(st==null?void 0:st.uid)}})}function watchBlockNumber(et,o){const{syncConnectedChain:tt=et._internal.syncConnectedChain,...rt}=o;let nt;const ot=at=>{nt&&nt();const ct=et.getClient({chainId:at});return nt=getAction(ct,watchBlockNumber$1,"watchBlockNumber")(rt),nt},it=ot(o.chainId);let st;return tt&&!o.chainId&&(st=et.subscribe(({chainId:at})=>at,async at=>ot(at))),()=>{it==null||it(),st==null||st()}}function watchChainId(et,o){const{onChange:tt}=o;return et.subscribe(rt=>rt.chainId,tt)}function watchConnections(et,o){const{onChange:tt}=o;return et.subscribe(()=>getConnections(et),tt,{equalityFn:deepEqual})}function watchConnectors(et,o){const{onChange:tt}=o;return et._internal.connectors.subscribe((rt,nt)=>{tt(Object.values(rt),nt)})}function createConnector(et){return et}const supportsSimulationIdRegex=/(rabby|trustwallet)/,targetMap={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(et){return et!=null&&et.coinbaseWalletExtension?et.coinbaseWalletExtension:findProvider(et,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(et){return findProvider(et,o=>{if(!o.isMetaMask||o.isBraveWallet&&!o._events&&!o._state)return!1;const tt=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPortal","isRabby","isTokenPocket","isTokenary","isZerion"];for(const rt of tt)if(o[rt])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(et){var o,tt;return(o=et==null?void 0:et.phantom)!=null&&o.ethereum?(tt=et.phantom)==null?void 0:tt.ethereum:findProvider(et,"isPhantom")}}};injected.type="injected";function injected(et={}){const{shimDisconnect:o=!0,unstable_shimAsyncInject:tt}=et;function rt(){const at=et.target;if(typeof at=="function"){const ct=at();if(ct)return ct}return typeof at=="object"?at:typeof at=="string"?{...targetMap[at]??{id:at,name:`${at[0].toUpperCase()}${at.slice(1)}`,provider:`is${at[0].toUpperCase()}${at.slice(1)}`}}:{id:"injected",name:"Injected",provider(ct){return ct==null?void 0:ct.ethereum}}}let nt,ot,it,st;return at=>({get icon(){return rt().icon},get id(){return rt().id},get name(){return rt().name},get supportsSimulation(){return supportsSimulationIdRegex.test(this.id.toLowerCase())},type:injected.type,async setup(){const ct=await this.getProvider();ct!=null&&ct.on&&et.target&&(it||(it=this.onConnect.bind(this),ct.on("connect",it)),nt||(nt=this.onAccountsChanged.bind(this),ct.on("accountsChanged",nt)))},async connect({chainId:ct,isReconnecting:lt}={}){var mt,ft,pt,yt,gt,bt;const dt=await this.getProvider();if(!dt)throw new ProviderNotFoundError;let ht=[];if(lt)ht=await this.getAccounts().catch(()=>[]);else if(o)try{ht=(yt=(pt=(ft=(mt=(await dt.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])==null?void 0:mt.caveats)==null?void 0:ft[0])==null?void 0:pt.value)==null?void 0:yt.map(vt=>getAddress(vt)),ht.length>0&&(ht=await this.getAccounts())}catch(xt){const vt=xt;if(vt.code===UserRejectedRequestError.code)throw new UserRejectedRequestError(vt);if(vt.code===ResourceUnavailableRpcError.code)throw vt}try{!(ht!=null&&ht.length)&&!lt&&(ht=(await dt.request({method:"eth_requestAccounts"})).map(Et=>getAddress(Et))),it&&(dt.removeListener("connect",it),it=void 0),nt||(nt=this.onAccountsChanged.bind(this),dt.on("accountsChanged",nt)),ot||(ot=this.onChainChanged.bind(this),dt.on("chainChanged",ot)),st||(st=this.onDisconnect.bind(this),dt.on("disconnect",st));let xt=await this.getChainId();if(ct&&xt!==ct){const vt=await this.switchChain({chainId:ct}).catch(Et=>{if(Et.code===UserRejectedRequestError.code)throw Et;return{id:xt}});xt=(vt==null?void 0:vt.id)??xt}return o&&await((gt=at.storage)==null?void 0:gt.removeItem(`${this.id}.disconnected`)),et.target||await((bt=at.storage)==null?void 0:bt.setItem("injected.connected",!0)),{accounts:ht,chainId:xt}}catch(xt){const vt=xt;throw vt.code===UserRejectedRequestError.code?new UserRejectedRequestError(vt):vt.code===ResourceUnavailableRpcError.code?new ResourceUnavailableRpcError(vt):vt}},async disconnect(){var lt,dt;const ct=await this.getProvider();if(!ct)throw new ProviderNotFoundError;ot&&(ct.removeListener("chainChanged",ot),ot=void 0),st&&(ct.removeListener("disconnect",st),st=void 0),it||(it=this.onConnect.bind(this),ct.on("connect",it));try{await withTimeout(()=>ct.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}o&&await((lt=at.storage)==null?void 0:lt.setItem(`${this.id}.disconnected`,!0)),et.target||await((dt=at.storage)==null?void 0:dt.removeItem("injected.connected"))},async getAccounts(){const ct=await this.getProvider();if(!ct)throw new ProviderNotFoundError;return(await ct.request({method:"eth_accounts"})).map(dt=>getAddress(dt))},async getChainId(){const ct=await this.getProvider();if(!ct)throw new ProviderNotFoundError;const lt=await ct.request({method:"eth_chainId"});return Number(lt)},async getProvider(){if(typeof window>"u")return;let ct;const lt=rt();return typeof lt.provider=="function"?ct=lt.provider(window):typeof lt.provider=="string"?ct=findProvider(window,lt.provider):ct=lt.provider,ct&&!ct.removeListener&&("off"in ct&&typeof ct.off=="function"?ct.removeListener=ct.off:ct.removeListener=()=>{}),ct},async isAuthorized(){var ct,lt;try{if(o&&await((ct=at.storage)==null?void 0:ct.getItem(`${this.id}.disconnected`))||!et.target&&!await((lt=at.storage)==null?void 0:lt.getItem("injected.connected")))return!1;if(!await this.getProvider()){if(tt!==void 0&&tt!==!1){const ft=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",ft),!!await this.getProvider()),pt=typeof tt=="number"?tt:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(gt=>window.addEventListener("ethereum#initialized",()=>gt(ft()),{once:!0}))]:[],new Promise(gt=>setTimeout(()=>gt(ft()),pt))]))return!0}throw new ProviderNotFoundError}return!!(await withRetry(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:ct,chainId:lt}){var mt,ft,pt,yt;const dt=await this.getProvider();if(!dt)throw new ProviderNotFoundError;const ht=at.chains.find(gt=>gt.id===lt);if(!ht)throw new SwitchChainError(new ChainNotConfiguredError);try{return await Promise.all([dt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(lt)}]}).then(async()=>{await this.getChainId()===lt&&at.emitter.emit("change",{chainId:lt})}),new Promise(gt=>{const bt=xt=>{"chainId"in xt&&xt.chainId===lt&&(at.emitter.off("change",bt),gt())};at.emitter.on("change",bt)})]),ht}catch(gt){const bt=gt;if(bt.code===4902||((ft=(mt=bt==null?void 0:bt.data)==null?void 0:mt.originalError)==null?void 0:ft.code)===4902)try{const{default:xt,...vt}=ht.blockExplorers??{};let Et;ct!=null&&ct.blockExplorerUrls?Et=ct.blockExplorerUrls:xt&&(Et=[xt.url,...Object.values(vt).map(kt=>kt.url)]);let Ct;(pt=ct==null?void 0:ct.rpcUrls)!=null&&pt.length?Ct=ct.rpcUrls:Ct=[((yt=ht.rpcUrls.default)==null?void 0:yt.http[0])??""];const St={blockExplorerUrls:Et,chainId:numberToHex(lt),chainName:(ct==null?void 0:ct.chainName)??ht.name,iconUrls:ct==null?void 0:ct.iconUrls,nativeCurrency:(ct==null?void 0:ct.nativeCurrency)??ht.nativeCurrency,rpcUrls:Ct};if(await dt.request({method:"wallet_addEthereumChain",params:[St]}),await this.getChainId()!==lt)throw new UserRejectedRequestError(new Error("User rejected switch after adding network."));return ht}catch(xt){throw new UserRejectedRequestError(xt)}throw bt.code===UserRejectedRequestError.code?new UserRejectedRequestError(bt):new SwitchChainError(bt)}},async onAccountsChanged(ct){var lt;if(ct.length===0)this.onDisconnect();else if(at.emitter.listenerCount("connect")){const dt=(await this.getChainId()).toString();this.onConnect({chainId:dt}),o&&await((lt=at.storage)==null?void 0:lt.removeItem(`${this.id}.disconnected`))}else at.emitter.emit("change",{accounts:ct.map(dt=>getAddress(dt))})},onChainChanged(ct){const lt=Number(ct);at.emitter.emit("change",{chainId:lt})},async onConnect(ct){const lt=await this.getAccounts();if(lt.length===0)return;const dt=Number(ct.chainId);at.emitter.emit("connect",{accounts:lt,chainId:dt});const ht=await this.getProvider();ht&&(it&&(ht.removeListener("connect",it),it=void 0),nt||(nt=this.onAccountsChanged.bind(this),ht.on("accountsChanged",nt)),ot||(ot=this.onChainChanged.bind(this),ht.on("chainChanged",ot)),st||(st=this.onDisconnect.bind(this),ht.on("disconnect",st)))},async onDisconnect(ct){const lt=await this.getProvider();ct&&ct.code===1013&<&&(await this.getAccounts()).length||(at.emitter.emit("disconnect"),lt&&(ot&&(lt.removeListener("chainChanged",ot),ot=void 0),st&&(lt.removeListener("disconnect",st),st=void 0),it||(it=this.onConnect.bind(this),lt.on("connect",it))))}})}function findProvider(et,o){function tt(nt){return typeof o=="function"?o(nt):typeof o=="string"?nt[o]:!0}const rt=et.ethereum;if(rt!=null&&rt.providers)return rt.providers.find(nt=>tt(nt));if(rt&&tt(rt))return rt}function requestProviders(et){if(typeof window>"u")return;const o=tt=>et(tt.detail);return window.addEventListener("eip6963:announceProvider",o),window.dispatchEvent(new CustomEvent("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",o)}function createStore$1(){const et=new Set;let o=[];const tt=()=>requestProviders(nt=>{o.some(({info:ot})=>ot.uuid===nt.info.uuid)||(o=[...o,nt],et.forEach(ot=>ot(o,{added:[nt]})))});let rt=tt();return{_listeners(){return et},clear(){et.forEach(nt=>nt([],{removed:[...o]})),o=[]},destroy(){this.clear(),et.clear(),rt==null||rt()},findProvider({rdns:nt}){return o.find(ot=>ot.info.rdns===nt)},getProviders(){return o},reset(){this.clear(),rt==null||rt(),rt=tt()},subscribe(nt,{emitImmediately:ot}={}){return et.add(nt),ot&&nt(o,{added:o}),()=>et.delete(nt)}}}const __vite_import_meta_env__$1={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_WALLETCONNECT_PROJECT_ID:"1d93edc21291f98e3bed6ff7617ff539"},subscribeWithSelectorImpl=et=>(o,tt,rt)=>{const nt=rt.subscribe;return rt.subscribe=(it,st,at)=>{let ct=it;if(st){const lt=(at==null?void 0:at.equalityFn)||Object.is;let dt=it(rt.getState());ct=ht=>{const mt=it(ht);if(!lt(dt,mt)){const ft=dt;st(dt=mt,ft)}},at!=null&&at.fireImmediately&&st(dt,dt)}return nt(ct)},et(o,tt,rt)},subscribeWithSelector=subscribeWithSelectorImpl;function createJSONStorage(et,o){let tt;try{tt=et()}catch{return}return{getItem:nt=>{var ot;const it=at=>at===null?null:JSON.parse(at,void 0),st=(ot=tt.getItem(nt))!=null?ot:null;return st instanceof Promise?st.then(it):it(st)},setItem:(nt,ot)=>tt.setItem(nt,JSON.stringify(ot,void 0)),removeItem:nt=>tt.removeItem(nt)}}const toThenable=et=>o=>{try{const tt=et(o);return tt instanceof Promise?tt:{then(rt){return toThenable(rt)(tt)},catch(rt){return this}}}catch(tt){return{then(rt){return this},catch(rt){return toThenable(rt)(tt)}}}},oldImpl=(et,o)=>(tt,rt,nt)=>{let ot={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:yt=>yt,version:0,merge:(yt,gt)=>({...gt,...yt}),...o},it=!1;const st=new Set,at=new Set;let ct;try{ct=ot.getStorage()}catch{}if(!ct)return et((...yt)=>{console.warn(`[zustand persist middleware] Unable to update item '${ot.name}', the given storage is currently unavailable.`),tt(...yt)},rt,nt);const lt=toThenable(ot.serialize),dt=()=>{const yt=ot.partialize({...rt()});let gt;const bt=lt({state:yt,version:ot.version}).then(xt=>ct.setItem(ot.name,xt)).catch(xt=>{gt=xt});if(gt)throw gt;return bt},ht=nt.setState;nt.setState=(yt,gt)=>{ht(yt,gt),dt()};const mt=et((...yt)=>{tt(...yt),dt()},rt,nt);let ft;const pt=()=>{var yt;if(!ct)return;it=!1,st.forEach(bt=>bt(rt()));const gt=((yt=ot.onRehydrateStorage)==null?void 0:yt.call(ot,rt()))||void 0;return toThenable(ct.getItem.bind(ct))(ot.name).then(bt=>{if(bt)return ot.deserialize(bt)}).then(bt=>{if(bt)if(typeof bt.version=="number"&&bt.version!==ot.version){if(ot.migrate)return ot.migrate(bt.state,bt.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return bt.state}).then(bt=>{var xt;return ft=ot.merge(bt,(xt=rt())!=null?xt:mt),tt(ft,!0),dt()}).then(()=>{gt==null||gt(ft,void 0),it=!0,at.forEach(bt=>bt(ft))}).catch(bt=>{gt==null||gt(void 0,bt)})};return nt.persist={setOptions:yt=>{ot={...ot,...yt},yt.getStorage&&(ct=yt.getStorage())},clearStorage:()=>{ct==null||ct.removeItem(ot.name)},getOptions:()=>ot,rehydrate:()=>pt(),hasHydrated:()=>it,onHydrate:yt=>(st.add(yt),()=>{st.delete(yt)}),onFinishHydration:yt=>(at.add(yt),()=>{at.delete(yt)})},pt(),ft||mt},newImpl=(et,o)=>(tt,rt,nt)=>{let ot={storage:createJSONStorage(()=>localStorage),partialize:pt=>pt,version:0,merge:(pt,yt)=>({...yt,...pt}),...o},it=!1;const st=new Set,at=new Set;let ct=ot.storage;if(!ct)return et((...pt)=>{console.warn(`[zustand persist middleware] Unable to update item '${ot.name}', the given storage is currently unavailable.`),tt(...pt)},rt,nt);const lt=()=>{const pt=ot.partialize({...rt()});return ct.setItem(ot.name,{state:pt,version:ot.version})},dt=nt.setState;nt.setState=(pt,yt)=>{dt(pt,yt),lt()};const ht=et((...pt)=>{tt(...pt),lt()},rt,nt);let mt;const ft=()=>{var pt,yt;if(!ct)return;it=!1,st.forEach(bt=>{var xt;return bt((xt=rt())!=null?xt:ht)});const gt=((yt=ot.onRehydrateStorage)==null?void 0:yt.call(ot,(pt=rt())!=null?pt:ht))||void 0;return toThenable(ct.getItem.bind(ct))(ot.name).then(bt=>{if(bt)if(typeof bt.version=="number"&&bt.version!==ot.version){if(ot.migrate)return ot.migrate(bt.state,bt.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return bt.state}).then(bt=>{var xt;return mt=ot.merge(bt,(xt=rt())!=null?xt:ht),tt(mt,!0),lt()}).then(()=>{gt==null||gt(mt,void 0),mt=rt(),it=!0,at.forEach(bt=>bt(mt))}).catch(bt=>{gt==null||gt(void 0,bt)})};return nt.persist={setOptions:pt=>{ot={...ot,...pt},pt.storage&&(ct=pt.storage)},clearStorage:()=>{ct==null||ct.removeItem(ot.name)},getOptions:()=>ot,rehydrate:()=>ft(),hasHydrated:()=>it,onHydrate:pt=>(st.add(pt),()=>{st.delete(pt)}),onFinishHydration:pt=>(at.add(pt),()=>{at.delete(pt)})},ot.skipHydration||ft(),mt||ht},persistImpl=(et,o)=>"getStorage"in o||"serialize"in o||"deserialize"in o?((__vite_import_meta_env__$1?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),oldImpl(et,o)):newImpl(et,o),persist=persistImpl,__vite_import_meta_env__={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_WALLETCONNECT_PROJECT_ID:"1d93edc21291f98e3bed6ff7617ff539"},createStoreImpl=et=>{let o;const tt=new Set,rt=(at,ct)=>{const lt=typeof at=="function"?at(o):at;if(!Object.is(lt,o)){const dt=o;o=ct??typeof lt!="object"?lt:Object.assign({},o,lt),tt.forEach(ht=>ht(o,dt))}},nt=()=>o,st={setState:rt,getState:nt,subscribe:at=>(tt.add(at),()=>tt.delete(at)),destroy:()=>{(__vite_import_meta_env__?"production":void 0)!=="production"&&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."),tt.clear()}};return o=et(rt,nt,st),st},createStore=et=>et?createStoreImpl(et):createStoreImpl;var eventemitter3={exports:{}};(function(et){var o=Object.prototype.hasOwnProperty,tt="~";function rt(){}Object.create&&(rt.prototype=Object.create(null),new rt().__proto__||(tt=!1));function nt(at,ct,lt){this.fn=at,this.context=ct,this.once=lt||!1}function ot(at,ct,lt,dt,ht){if(typeof lt!="function")throw new TypeError("The listener must be a function");var mt=new nt(lt,dt||at,ht),ft=tt?tt+ct:ct;return at._events[ft]?at._events[ft].fn?at._events[ft]=[at._events[ft],mt]:at._events[ft].push(mt):(at._events[ft]=mt,at._eventsCount++),at}function it(at,ct){--at._eventsCount===0?at._events=new rt:delete at._events[ct]}function st(){this._events=new rt,this._eventsCount=0}st.prototype.eventNames=function(){var ct=[],lt,dt;if(this._eventsCount===0)return ct;for(dt in lt=this._events)o.call(lt,dt)&&ct.push(tt?dt.slice(1):dt);return Object.getOwnPropertySymbols?ct.concat(Object.getOwnPropertySymbols(lt)):ct},st.prototype.listeners=function(ct){var lt=tt?tt+ct:ct,dt=this._events[lt];if(!dt)return[];if(dt.fn)return[dt.fn];for(var ht=0,mt=dt.length,ft=new Array(mt);ht{let nt=rt;return(nt==null?void 0:nt.__type)==="bigint"&&(nt=BigInt(nt.value)),(nt==null?void 0:nt.__type)==="Map"&&(nt=new Map(nt.value)),(o==null?void 0:o(tt,nt))??nt})}function getReferenceKey(et,o){return et.slice(0,o).join(".")||"."}function getCutoff(et,o){const{length:tt}=et;for(let rt=0;rt{let it=ot;return typeof it=="bigint"&&(it={__type:"bigint",value:ot.toString()}),it instanceof Map&&(it={__type:"Map",value:Array.from(ot.entries())}),(o==null?void 0:o(nt,it))??it},rt),tt??void 0)}function createStorage(et){const{deserialize:o=deserialize$1,key:tt="wagmi",serialize:rt=serialize$1,storage:nt=noopStorage}=et;function ot(it){return it instanceof Promise?it.then(st=>st).catch(()=>null):it}return{...nt,key:tt,async getItem(it,st){const at=nt.getItem(`${tt}.${it}`),ct=await ot(at);return ct?o(ct)??null:st??null},async setItem(it,st){const at=`${tt}.${it}`;st===null?await ot(nt.removeItem(at)):await ot(nt.setItem(at,rt(st)))},async removeItem(it){await ot(nt.removeItem(`${tt}.${it}`))}}}const noopStorage={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},size=256;let index$2=size,buffer;function uid(et=11){if(!buffer||index$2+et>size*2){buffer="",index$2=0;for(let o=0;oot.chains),at=createStore(()=>[...ot.connectors??[],...nt?[]:(it==null?void 0:it.getProviders().map(lt))??[]].map(ct));function ct(Et){var At;const Ct=createEmitter(uid()),St={...Et({emitter:Ct,chains:st.getState(),storage:tt,transports:ot.transports}),emitter:Ct,uid:Ct.uid};return Ct.on("connect",xt),(At=St.setup)==null||At.call(St),St}function lt(Et){const{info:Ct}=Et,St=Et.provider;return injected({target:{...Ct,id:Ct.rdns,provider:St}})}const dt=new Map;function ht(Et={}){const Ct=Et.chainId??yt.getState().chainId,St=st.getState().find(kt=>kt.id===Ct);if(Et.chainId&&!St)throw new ChainNotConfiguredError;{const kt=dt.get(yt.getState().chainId);if(kt&&!St)return kt;if(!St)throw new ChainNotConfiguredError}{const kt=dt.get(Ct);if(kt)return kt}let At;if(ot.client)At=ot.client({chain:St});else{const kt=St.id,It=st.getState().map(Mt=>Mt.id),Nt={},Lt=Object.entries(ot);for(const[Mt,zt]of Lt)if(!(Mt==="chains"||Mt==="client"||Mt==="connectors"||Mt==="transports"))if(typeof zt=="object")if(kt in zt)Nt[Mt]=zt[kt];else{if(It.some(Xt=>Xt in zt))continue;Nt[Mt]=zt}else Nt[Mt]=zt;At=createClient({...Nt,chain:St,batch:Nt.batch??{multicall:!0},transport:Mt=>ot.transports[kt]({...Mt,connectors:at})})}return dt.set(Ct,At),At}function mt(){return{chainId:st.getState()[0].id,connections:new Map,current:null,status:"disconnected"}}let ft;const pt="0.0.0-canary-";version$6.startsWith(pt)?ft=Number.parseInt(version$6.replace(pt,"")):ft=Number.parseInt(version$6.split(".")[0]??"0");const yt=createStore(subscribeWithSelector(tt?persist(mt,{migrate(Et,Ct){if(Ct===ft)return Et;const St=mt(),At=gt(Et,St.chainId);return{...St,chainId:At}},name:"store",partialize(Et){return{connections:{__type:"Map",value:Array.from(Et.connections.entries()).map(([Ct,St])=>{const{id:At,name:kt,type:It,uid:Nt}=St.connector;return[Ct,{...St,connector:{id:At,name:kt,type:It,uid:Nt}}]})},chainId:Et.chainId,current:Et.current}},merge(Et,Ct){typeof Et=="object"&&Et&&"status"in Et&&delete Et.status;const St=gt(Et,Ct.chainId);return{...Ct,...Et,chainId:St}},skipHydration:nt,storage:tt,version:ft}):mt));function gt(Et,Ct){return Et&&typeof Et=="object"&&"chainId"in Et&&typeof Et.chainId=="number"&&st.getState().some(St=>St.id===Et.chainId)?Et.chainId:Ct}rt&&yt.subscribe(({connections:Et,current:Ct})=>{var St;return Ct?(St=Et.get(Ct))==null?void 0:St.chainId:void 0},Et=>{if(st.getState().some(St=>St.id===Et))return yt.setState(St=>({...St,chainId:Et??St.chainId}))}),it==null||it.subscribe(Et=>{const Ct=new Map;for(const At of at.getState())Ct.set(At.id,!0);const St=[];for(const At of Et){const kt=ct(lt(At));Ct.has(kt.id)||St.push(kt)}tt&&!yt.persist.hasHydrated()||at.setState(At=>[...At,...St],!0)});function bt(Et){yt.setState(Ct=>{const St=Ct.connections.get(Et.uid);return St?{...Ct,connections:new Map(Ct.connections).set(Et.uid,{accounts:Et.accounts??St.accounts,chainId:Et.chainId??St.chainId,connector:St.connector})}:Ct})}function xt(Et){yt.getState().status==="connecting"||yt.getState().status==="reconnecting"||yt.setState(Ct=>{const St=at.getState().find(At=>At.uid===Et.uid);return St?(St.emitter.listenerCount("connect")&&St.emitter.off("connect",bt),St.emitter.listenerCount("change")||St.emitter.on("change",bt),St.emitter.listenerCount("disconnect")||St.emitter.on("disconnect",vt),{...Ct,connections:new Map(Ct.connections).set(Et.uid,{accounts:Et.accounts,chainId:Et.chainId,connector:St}),current:Et.uid,status:"connected"}):Ct})}function vt(Et){yt.setState(Ct=>{const St=Ct.connections.get(Et.uid);if(St){const kt=St.connector;kt.emitter.listenerCount("change")&&St.connector.emitter.off("change",bt),kt.emitter.listenerCount("disconnect")&&St.connector.emitter.off("disconnect",vt),kt.emitter.listenerCount("connect")||St.connector.emitter.on("connect",xt)}if(Ct.connections.delete(Et.uid),Ct.connections.size===0)return{...Ct,connections:new Map,current:null,status:"disconnected"};const At=Ct.connections.values().next().value;return{...Ct,connections:new Map(Ct.connections),current:At.connector.uid}})}return{get chains(){return st.getState()},get connectors(){return at.getState()},storage:tt,getClient:ht,get state(){return yt.getState()},setState(Et){let Ct;typeof Et=="function"?Ct=Et(yt.getState()):Ct=Et;const St=mt();typeof Ct!="object"&&(Ct=St),Object.keys(St).some(kt=>!(kt in Ct))&&(Ct=St),yt.setState(Ct,!0)},subscribe(Et,Ct,St){return yt.subscribe(Et,Ct,St?{...St,fireImmediately:St.emitImmediately}:void 0)},_internal:{mipd:it,store:yt,ssr:!!nt,syncConnectedChain:rt,transports:ot.transports,chains:{setState(Et){const Ct=typeof Et=="function"?Et(st.getState()):Et;if(Ct.length!==0)return st.setState(Ct,!0)},subscribe(Et){return st.subscribe(Et)}},connectors:{providerDetailToConnector:lt,setup:ct,setState(Et){return at.setState(typeof Et=="function"?Et(at.getState()):Et,!0)},subscribe(Et){return at.subscribe(Et)}},events:{change:bt,connect:xt,disconnect:vt}}}}function hydrate(et,o){const{initialState:tt,reconnectOnMount:rt}=o;return tt&&!et._internal.store.persist.hasHydrated()&&et.setState({...tt,chainId:et.chains.some(nt=>nt.id===tt.chainId)?tt.chainId:et.chains[0].id,connections:rt?tt.connections:new Map,status:rt?"reconnecting":"disconnected"}),{async onMount(){var nt;if(et._internal.ssr){await et._internal.store.persist.rehydrate();const ot=(nt=et._internal.mipd)==null?void 0:nt.getProviders().map(et._internal.connectors.providerDetailToConnector).map(et._internal.connectors.setup);et._internal.connectors.setState(it=>[...it,...ot??[]])}rt?reconnect(et):et.storage&&et.setState(ot=>({...ot,connections:new Map}))}}}function extractRpcUrls(et){var ot,it,st;const{chain:o}=et,tt=o.rpcUrls.default.http[0];if(!et.transports)return[tt];const rt=(it=(ot=et.transports)==null?void 0:ot[o.id])==null?void 0:it.call(ot,{chain:o});return(((st=rt==null?void 0:rt.value)==null?void 0:st.transports)||[rt]).map(({value:at})=>(at==null?void 0:at.url)||tt)}function Hydrate(et){const{children:o,config:tt,initialState:rt,reconnectOnMount:nt=!0}=et,{onMount:ot}=hydrate(tt,{initialState:rt,reconnectOnMount:nt});tt._internal.ssr||ot();const it=reactExports.useRef(!0);return reactExports.useEffect(()=>{if(it.current&&tt._internal.ssr)return ot(),()=>{it.current=!1}},[]),o}const WagmiContext=reactExports.createContext(void 0);function WagmiProvider(et){const{children:o,config:tt}=et,rt={value:tt};return reactExports.createElement(Hydrate,et,reactExports.createElement(WagmiContext.Provider,rt,o))}const version$5="2.12.19",getVersion=()=>`wagmi@${version$5}`;class BaseError extends BaseError$1{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiError"})}get docsBaseUrl(){return"https://wagmi.sh/react"}get version(){return getVersion()}}class WagmiProviderNotFoundError extends BaseError{constructor(){super("`useConfig` must be used within `WagmiProvider`.",{docsPath:"/api/WagmiProvider"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiProviderNotFoundError"})}}function useConfig(et={}){const o=et.config??reactExports.useContext(WagmiContext);if(!o)throw new WagmiProviderNotFoundError;return o}function watchChains(et,o){const{onChange:tt}=o;return et._internal.chains.subscribe((rt,nt)=>{tt(rt,nt)})}var withSelector={exports:{}},withSelector_production_min={},shim={exports:{}},useSyncExternalStoreShim_production_min={};/** * @license React * use-sync-external-store-shim.production.min.js * @@ -87,12 +92,7 @@ ${prettyStateOverride(mt)}`),super(o.shortMessage,{cause:o,docsPath:rt,metaMessa * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var h$3=reactExports,n$2=shimExports;function p$2(et,o){return et===o&&(et!==0||1/et===1/o)||et!==et&&o!==o}var q$3=typeof Object.is=="function"?Object.is:p$2,r$3=n$2.useSyncExternalStore,t$2=h$3.useRef,u$1=h$3.useEffect,v$3=h$3.useMemo,w$3=h$3.useDebugValue;withSelector_production_min.useSyncExternalStoreWithSelector=function(et,o,tt,rt,nt){var ot=t$2(null);if(ot.current===null){var it={hasValue:!1,value:null};ot.current=it}else it=ot.current;ot=v$3(function(){function at(mt){if(!ct){if(ct=!0,lt=mt,mt=rt(mt),nt!==void 0&&it.hasValue){var ft=it.value;if(nt(ft,mt))return dt=ft}return dt=mt}if(ft=dt,q$3(lt,mt))return ft;var pt=rt(mt);return nt!==void 0&&nt(ft,pt)?ft:(lt=mt,dt=pt)}var ct=!1,lt,dt,ht=tt===void 0?null:tt;return[function(){return at(o())},ht===null?void 0:function(){return at(ht())}]},[o,tt,rt,nt]);var st=r$3(et,ot[0],ot[1]);return u$1(function(){it.hasValue=!0,it.value=st},[st]),w$3(st),st};withSelector.exports=withSelector_production_min;var withSelectorExports=withSelector.exports;const isPlainObject$4=et=>typeof et=="object"&&!Array.isArray(et);function useSyncExternalStoreWithTracked(et,o,tt=o,rt=deepEqual){const nt=reactExports.useRef([]),ot=withSelectorExports.useSyncExternalStoreWithSelector(et,o,tt,it=>it,(it,st)=>{if(isPlainObject$4(it)&&isPlainObject$4(st)&&nt.current.length){for(const at of nt.current)if(!rt(it[at],st[at]))return!1;return!0}return rt(it,st)});return reactExports.useMemo(()=>{if(isPlainObject$4(ot)){const it={...ot};let st={};for(const[at,ct]of Object.entries(it))st={...st,[at]:{configurable:!1,enumerable:!0,get:()=>(nt.current.includes(at)||nt.current.push(at),ct)}};return Object.defineProperties(it,st),it}return ot},[ot])}function useAccount(et={}){const o=useConfig(et);return useSyncExternalStoreWithTracked(tt=>watchAccount(o,{onChange:tt}),()=>getAccount(o))}function useAccountEffect(et={}){const{onConnect:o,onDisconnect:tt}=et,rt=useConfig(et);reactExports.useEffect(()=>watchAccount(rt,{onChange(nt,ot){if((ot.status==="reconnecting"||ot.status==="connecting"&&ot.address===void 0)&&nt.status==="connected"){const{address:it,addresses:st,chain:at,chainId:ct,connector:lt}=nt,dt=ot.status==="reconnecting"||ot.status===void 0;o==null||o({address:it,addresses:st,chain:at,chainId:ct,connector:lt,isReconnected:dt})}else ot.status==="connected"&&nt.status==="disconnected"&&(tt==null||tt())}}),[rt,o,tt])}var Subscribable=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(et){return this.listeners.add(et),this.onSubscribe(),()=>{this.listeners.delete(et),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},isServer=typeof window>"u"||"Deno"in globalThis;function noop$4(){}function functionalUpdate(et,o){return typeof et=="function"?et(o):et}function isValidTimeout(et){return typeof et=="number"&&et>=0&&et!==1/0}function timeUntilStale(et,o){return Math.max(et+(o||0)-Date.now(),0)}function resolveStaleTime(et,o){return typeof et=="function"?et(o):et}function resolveEnabled(et,o){return typeof et=="function"?et(o):et}function matchQuery(et,o){const{type:tt="all",exact:rt,fetchStatus:nt,predicate:ot,queryKey:it,stale:st}=et;if(it){if(rt){if(o.queryHash!==hashQueryKeyByOptions(it,o.options))return!1}else if(!partialMatchKey(o.queryKey,it))return!1}if(tt!=="all"){const at=o.isActive();if(tt==="active"&&!at||tt==="inactive"&&at)return!1}return!(typeof st=="boolean"&&o.isStale()!==st||nt&&nt!==o.state.fetchStatus||ot&&!ot(o))}function matchMutation(et,o){const{exact:tt,status:rt,predicate:nt,mutationKey:ot}=et;if(ot){if(!o.options.mutationKey)return!1;if(tt){if(hashKey(o.options.mutationKey)!==hashKey(ot))return!1}else if(!partialMatchKey(o.options.mutationKey,ot))return!1}return!(rt&&o.state.status!==rt||nt&&!nt(o))}function hashQueryKeyByOptions(et,o){return((o==null?void 0:o.queryKeyHashFn)||hashKey)(et)}function hashKey(et){return JSON.stringify(et,(o,tt)=>isPlainObject$3(tt)?Object.keys(tt).sort().reduce((rt,nt)=>(rt[nt]=tt[nt],rt),{}):tt)}function partialMatchKey(et,o){return et===o?!0:typeof et!=typeof o?!1:et&&o&&typeof et=="object"&&typeof o=="object"?!Object.keys(o).some(tt=>!partialMatchKey(et[tt],o[tt])):!1}function replaceEqualDeep(et,o){if(et===o)return et;const tt=isPlainArray(et)&&isPlainArray(o);if(tt||isPlainObject$3(et)&&isPlainObject$3(o)){const rt=tt?et:Object.keys(et),nt=rt.length,ot=tt?o:Object.keys(o),it=ot.length,st=tt?[]:{};let at=0;for(let ct=0;ct{setTimeout(o,et)})}function replaceData(et,o,tt){return typeof tt.structuralSharing=="function"?tt.structuralSharing(et,o):tt.structuralSharing!==!1?replaceEqualDeep(et,o):o}function addToEnd(et,o,tt=0){const rt=[...et,o];return tt&&rt.length>tt?rt.slice(1):rt}function addToStart(et,o,tt=0){const rt=[o,...et];return tt&&rt.length>tt?rt.slice(0,-1):rt}var skipToken=Symbol();function ensureQueryFn(et,o){return!et.queryFn&&(o!=null&&o.initialPromise)?()=>o.initialPromise:!et.queryFn||et.queryFn===skipToken?()=>Promise.reject(new Error(`Missing queryFn: '${et.queryHash}'`)):et.queryFn}var kn,hn,Mn,Us,FocusManager=(Us=class extends Subscribable{constructor(){super();hr(this,kn);hr(this,hn);hr(this,Mn);ur(this,Mn,o=>{if(!isServer&&window.addEventListener){const tt=()=>o();return window.addEventListener("visibilitychange",tt,!1),()=>{window.removeEventListener("visibilitychange",tt)}}})}onSubscribe(){Lt(this,hn)||this.setEventListener(Lt(this,Mn))}onUnsubscribe(){var o;this.hasListeners()||((o=Lt(this,hn))==null||o.call(this),ur(this,hn,void 0))}setEventListener(o){var tt;ur(this,Mn,o),(tt=Lt(this,hn))==null||tt.call(this),ur(this,hn,o(rt=>{typeof rt=="boolean"?this.setFocused(rt):this.onFocus()}))}setFocused(o){Lt(this,kn)!==o&&(ur(this,kn,o),this.onFocus())}onFocus(){const o=this.isFocused();this.listeners.forEach(tt=>{tt(o)})}isFocused(){var o;return typeof Lt(this,kn)=="boolean"?Lt(this,kn):((o=globalThis.document)==null?void 0:o.visibilityState)!=="hidden"}},kn=new WeakMap,hn=new WeakMap,Mn=new WeakMap,Us),focusManager=new FocusManager,Bn,fn,Fn,zs,OnlineManager=(zs=class extends Subscribable{constructor(){super();hr(this,Bn,!0);hr(this,fn);hr(this,Fn);ur(this,Fn,o=>{if(!isServer&&window.addEventListener){const tt=()=>o(!0),rt=()=>o(!1);return window.addEventListener("online",tt,!1),window.addEventListener("offline",rt,!1),()=>{window.removeEventListener("online",tt),window.removeEventListener("offline",rt)}}})}onSubscribe(){Lt(this,fn)||this.setEventListener(Lt(this,Fn))}onUnsubscribe(){var o;this.hasListeners()||((o=Lt(this,fn))==null||o.call(this),ur(this,fn,void 0))}setEventListener(o){var tt;ur(this,Fn,o),(tt=Lt(this,fn))==null||tt.call(this),ur(this,fn,o(this.setOnline.bind(this)))}setOnline(o){Lt(this,Bn)!==o&&(ur(this,Bn,o),this.listeners.forEach(rt=>{rt(o)}))}isOnline(){return Lt(this,Bn)}},Bn=new WeakMap,fn=new WeakMap,Fn=new WeakMap,zs),onlineManager=new OnlineManager;function pendingThenable(){let et,o;const tt=new Promise((nt,ot)=>{et=nt,o=ot});tt.status="pending",tt.catch(()=>{});function rt(nt){Object.assign(tt,nt),delete tt.resolve,delete tt.reject}return tt.resolve=nt=>{rt({status:"fulfilled",value:nt}),et(nt)},tt.reject=nt=>{rt({status:"rejected",reason:nt}),o(nt)},tt}function defaultRetryDelay(et){return Math.min(1e3*2**et,3e4)}function canFetch(et){return(et??"online")==="online"?onlineManager.isOnline():!0}var CancelledError=class extends Error{constructor(et){super("CancelledError"),this.revert=et==null?void 0:et.revert,this.silent=et==null?void 0:et.silent}};function isCancelledError(et){return et instanceof CancelledError}function createRetryer(et){let o=!1,tt=0,rt=!1,nt;const ot=pendingThenable(),it=pt=>{var gt;rt||(ht(new CancelledError(pt)),(gt=et.abort)==null||gt.call(et))},st=()=>{o=!0},at=()=>{o=!1},ct=()=>focusManager.isFocused()&&(et.networkMode==="always"||onlineManager.isOnline())&&et.canRun(),lt=()=>canFetch(et.networkMode)&&et.canRun(),dt=pt=>{var gt;rt||(rt=!0,(gt=et.onSuccess)==null||gt.call(et,pt),nt==null||nt(),ot.resolve(pt))},ht=pt=>{var gt;rt||(rt=!0,(gt=et.onError)==null||gt.call(et,pt),nt==null||nt(),ot.reject(pt))},mt=()=>new Promise(pt=>{var gt;nt=yt=>{(rt||ct())&&pt(yt)},(gt=et.onPause)==null||gt.call(et)}).then(()=>{var pt;nt=void 0,rt||(pt=et.onContinue)==null||pt.call(et)}),ft=()=>{if(rt)return;let pt;const gt=tt===0?et.initialPromise:void 0;try{pt=gt??et.fn()}catch(yt){pt=Promise.reject(yt)}Promise.resolve(pt).then(dt).catch(yt=>{var Ct;if(rt)return;const bt=et.retry??(isServer?0:3),xt=et.retryDelay??defaultRetryDelay,vt=typeof xt=="function"?xt(tt,yt):xt,Et=bt===!0||typeof bt=="number"&&ttct()?void 0:mt()).then(()=>{o?ht(yt):ft()})})};return{promise:ot,cancel:it,continue:()=>(nt==null||nt(),ot),cancelRetry:st,continueRetry:at,canStart:lt,start:()=>(lt()?ft():mt().then(ft),ot)}}function createNotifyManager(){let et=[],o=0,tt=st=>{st()},rt=st=>{st()},nt=st=>setTimeout(st,0);const ot=st=>{o?et.push(st):nt(()=>{tt(st)})},it=()=>{const st=et;et=[],st.length&&nt(()=>{rt(()=>{st.forEach(at=>{tt(at)})})})};return{batch:st=>{let at;o++;try{at=st()}finally{o--,o||it()}return at},batchCalls:st=>(...at)=>{ot(()=>{st(...at)})},schedule:ot,setNotifyFunction:st=>{tt=st},setBatchNotifyFunction:st=>{rt=st},setScheduler:st=>{nt=st}}}var notifyManager=createNotifyManager(),_n,Vs,Removable=(Vs=class{constructor(){hr(this,_n)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),isValidTimeout(this.gcTime)&&ur(this,_n,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(et){this.gcTime=Math.max(this.gcTime||0,et??(isServer?1/0:5*60*1e3))}clearGcTimeout(){Lt(this,_n)&&(clearTimeout(Lt(this,_n)),ur(this,_n,void 0))}},_n=new WeakMap,Vs),Un,zn,Vr,Or,io,Rn,Gr,nn,Hs,Query=(Hs=class extends Removable{constructor(o){super();hr(this,Gr);hr(this,Un);hr(this,zn);hr(this,Vr);hr(this,Or);hr(this,io);hr(this,Rn);ur(this,Rn,!1),ur(this,io,o.defaultOptions),this.setOptions(o.options),this.observers=[],ur(this,Vr,o.cache),this.queryKey=o.queryKey,this.queryHash=o.queryHash,ur(this,Un,getDefaultState$1(this.options)),this.state=o.state??Lt(this,Un),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var o;return(o=Lt(this,Or))==null?void 0:o.promise}setOptions(o){this.options={...Lt(this,io),...o},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&Lt(this,Vr).remove(this)}setData(o,tt){const rt=replaceData(this.state.data,o,this.options);return fr(this,Gr,nn).call(this,{data:rt,type:"success",dataUpdatedAt:tt==null?void 0:tt.updatedAt,manual:tt==null?void 0:tt.manual}),rt}setState(o,tt){fr(this,Gr,nn).call(this,{type:"setState",state:o,setStateOptions:tt})}cancel(o){var rt,nt;const tt=(rt=Lt(this,Or))==null?void 0:rt.promise;return(nt=Lt(this,Or))==null||nt.cancel(o),tt?tt.then(noop$4).catch(noop$4):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Lt(this,Un))}isActive(){return this.observers.some(o=>resolveEnabled(o.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===skipToken||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(o=>o.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(o=0){return this.state.isInvalidated||this.state.data===void 0||!timeUntilStale(this.state.dataUpdatedAt,o)}onFocus(){var tt;const o=this.observers.find(rt=>rt.shouldFetchOnWindowFocus());o==null||o.refetch({cancelRefetch:!1}),(tt=Lt(this,Or))==null||tt.continue()}onOnline(){var tt;const o=this.observers.find(rt=>rt.shouldFetchOnReconnect());o==null||o.refetch({cancelRefetch:!1}),(tt=Lt(this,Or))==null||tt.continue()}addObserver(o){this.observers.includes(o)||(this.observers.push(o),this.clearGcTimeout(),Lt(this,Vr).notify({type:"observerAdded",query:this,observer:o}))}removeObserver(o){this.observers.includes(o)&&(this.observers=this.observers.filter(tt=>tt!==o),this.observers.length||(Lt(this,Or)&&(Lt(this,Rn)?Lt(this,Or).cancel({revert:!0}):Lt(this,Or).cancelRetry()),this.scheduleGc()),Lt(this,Vr).notify({type:"observerRemoved",query:this,observer:o}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||fr(this,Gr,nn).call(this,{type:"invalidate"})}fetch(o,tt){var at,ct,lt;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(tt!=null&&tt.cancelRefetch))this.cancel({silent:!0});else if(Lt(this,Or))return Lt(this,Or).continueRetry(),Lt(this,Or).promise}if(o&&this.setOptions(o),!this.options.queryFn){const dt=this.observers.find(ht=>ht.options.queryFn);dt&&this.setOptions(dt.options)}const rt=new AbortController,nt=dt=>{Object.defineProperty(dt,"signal",{enumerable:!0,get:()=>(ur(this,Rn,!0),rt.signal)})},ot=()=>{const dt=ensureQueryFn(this.options,tt),ht={queryKey:this.queryKey,meta:this.meta};return nt(ht),ur(this,Rn,!1),this.options.persister?this.options.persister(dt,ht,this):dt(ht)},it={fetchOptions:tt,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:ot};nt(it),(at=this.options.behavior)==null||at.onFetch(it,this),ur(this,zn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((ct=it.fetchOptions)==null?void 0:ct.meta))&&fr(this,Gr,nn).call(this,{type:"fetch",meta:(lt=it.fetchOptions)==null?void 0:lt.meta});const st=dt=>{var ht,mt,ft,pt;isCancelledError(dt)&&dt.silent||fr(this,Gr,nn).call(this,{type:"error",error:dt}),isCancelledError(dt)||((mt=(ht=Lt(this,Vr).config).onError)==null||mt.call(ht,dt,this),(pt=(ft=Lt(this,Vr).config).onSettled)==null||pt.call(ft,this.state.data,dt,this)),this.scheduleGc()};return ur(this,Or,createRetryer({initialPromise:tt==null?void 0:tt.initialPromise,fn:it.fetchFn,abort:rt.abort.bind(rt),onSuccess:dt=>{var ht,mt,ft,pt;if(dt===void 0){st(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(dt)}catch(gt){st(gt);return}(mt=(ht=Lt(this,Vr).config).onSuccess)==null||mt.call(ht,dt,this),(pt=(ft=Lt(this,Vr).config).onSettled)==null||pt.call(ft,dt,this.state.error,this),this.scheduleGc()},onError:st,onFail:(dt,ht)=>{fr(this,Gr,nn).call(this,{type:"failed",failureCount:dt,error:ht})},onPause:()=>{fr(this,Gr,nn).call(this,{type:"pause"})},onContinue:()=>{fr(this,Gr,nn).call(this,{type:"continue"})},retry:it.options.retry,retryDelay:it.options.retryDelay,networkMode:it.options.networkMode,canRun:()=>!0})),Lt(this,Or).start()}},Un=new WeakMap,zn=new WeakMap,Vr=new WeakMap,Or=new WeakMap,io=new WeakMap,Rn=new WeakMap,Gr=new WeakSet,nn=function(o){const tt=rt=>{switch(o.type){case"failed":return{...rt,fetchFailureCount:o.failureCount,fetchFailureReason:o.error};case"pause":return{...rt,fetchStatus:"paused"};case"continue":return{...rt,fetchStatus:"fetching"};case"fetch":return{...rt,...fetchState(rt.data,this.options),fetchMeta:o.meta??null};case"success":return{...rt,data:o.data,dataUpdateCount:rt.dataUpdateCount+1,dataUpdatedAt:o.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!o.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const nt=o.error;return isCancelledError(nt)&&nt.revert&&Lt(this,zn)?{...Lt(this,zn),fetchStatus:"idle"}:{...rt,error:nt,errorUpdateCount:rt.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:rt.fetchFailureCount+1,fetchFailureReason:nt,fetchStatus:"idle",status:"error"};case"invalidate":return{...rt,isInvalidated:!0};case"setState":return{...rt,...o.state}}};this.state=tt(this.state),notifyManager.batch(()=>{this.observers.forEach(rt=>{rt.onQueryUpdate()}),Lt(this,Vr).notify({query:this,type:"updated",action:o})})},Hs);function fetchState(et,o){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:canFetch(o.networkMode)?"fetching":"paused",...et===void 0&&{error:null,status:"pending"}}}function getDefaultState$1(et){const o=typeof et.initialData=="function"?et.initialData():et.initialData,tt=o!==void 0,rt=tt?typeof et.initialDataUpdatedAt=="function"?et.initialDataUpdatedAt():et.initialDataUpdatedAt:0;return{data:o,dataUpdateCount:0,dataUpdatedAt:tt?rt??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:tt?"success":"pending",fetchStatus:"idle"}}var Zr,Ws,QueryCache=(Ws=class extends Subscribable{constructor(o={}){super();hr(this,Zr);this.config=o,ur(this,Zr,new Map)}build(o,tt,rt){const nt=tt.queryKey,ot=tt.queryHash??hashQueryKeyByOptions(nt,tt);let it=this.get(ot);return it||(it=new Query({cache:this,queryKey:nt,queryHash:ot,options:o.defaultQueryOptions(tt),state:rt,defaultOptions:o.getQueryDefaults(nt)}),this.add(it)),it}add(o){Lt(this,Zr).has(o.queryHash)||(Lt(this,Zr).set(o.queryHash,o),this.notify({type:"added",query:o}))}remove(o){const tt=Lt(this,Zr).get(o.queryHash);tt&&(o.destroy(),tt===o&&Lt(this,Zr).delete(o.queryHash),this.notify({type:"removed",query:o}))}clear(){notifyManager.batch(()=>{this.getAll().forEach(o=>{this.remove(o)})})}get(o){return Lt(this,Zr).get(o)}getAll(){return[...Lt(this,Zr).values()]}find(o){const tt={exact:!0,...o};return this.getAll().find(rt=>matchQuery(tt,rt))}findAll(o={}){const tt=this.getAll();return Object.keys(o).length>0?tt.filter(rt=>matchQuery(o,rt)):tt}notify(o){notifyManager.batch(()=>{this.listeners.forEach(tt=>{tt(o)})})}onFocus(){notifyManager.batch(()=>{this.getAll().forEach(o=>{o.onFocus()})})}onOnline(){notifyManager.batch(()=>{this.getAll().forEach(o=>{o.onOnline()})})}},Zr=new WeakMap,Ws),qr,Lr,Tn,Kr,un,Gs,Mutation=(Gs=class extends Removable{constructor(o){super();hr(this,Kr);hr(this,qr);hr(this,Lr);hr(this,Tn);this.mutationId=o.mutationId,ur(this,Lr,o.mutationCache),ur(this,qr,[]),this.state=o.state||getDefaultState(),this.setOptions(o.options),this.scheduleGc()}setOptions(o){this.options=o,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(o){Lt(this,qr).includes(o)||(Lt(this,qr).push(o),this.clearGcTimeout(),Lt(this,Lr).notify({type:"observerAdded",mutation:this,observer:o}))}removeObserver(o){ur(this,qr,Lt(this,qr).filter(tt=>tt!==o)),this.scheduleGc(),Lt(this,Lr).notify({type:"observerRemoved",mutation:this,observer:o})}optionalRemove(){Lt(this,qr).length||(this.state.status==="pending"?this.scheduleGc():Lt(this,Lr).remove(this))}continue(){var o;return((o=Lt(this,Tn))==null?void 0:o.continue())??this.execute(this.state.variables)}async execute(o){var nt,ot,it,st,at,ct,lt,dt,ht,mt,ft,pt,gt,yt,bt,xt,vt,Et,Ct,St;ur(this,Tn,createRetryer({fn:()=>this.options.mutationFn?this.options.mutationFn(o):Promise.reject(new Error("No mutationFn found")),onFail:(At,kt)=>{fr(this,Kr,un).call(this,{type:"failed",failureCount:At,error:kt})},onPause:()=>{fr(this,Kr,un).call(this,{type:"pause"})},onContinue:()=>{fr(this,Kr,un).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Lt(this,Lr).canRun(this)}));const tt=this.state.status==="pending",rt=!Lt(this,Tn).canStart();try{if(!tt){fr(this,Kr,un).call(this,{type:"pending",variables:o,isPaused:rt}),await((ot=(nt=Lt(this,Lr).config).onMutate)==null?void 0:ot.call(nt,o,this));const kt=await((st=(it=this.options).onMutate)==null?void 0:st.call(it,o));kt!==this.state.context&&fr(this,Kr,un).call(this,{type:"pending",context:kt,variables:o,isPaused:rt})}const At=await Lt(this,Tn).start();return await((ct=(at=Lt(this,Lr).config).onSuccess)==null?void 0:ct.call(at,At,o,this.state.context,this)),await((dt=(lt=this.options).onSuccess)==null?void 0:dt.call(lt,At,o,this.state.context)),await((mt=(ht=Lt(this,Lr).config).onSettled)==null?void 0:mt.call(ht,At,null,this.state.variables,this.state.context,this)),await((pt=(ft=this.options).onSettled)==null?void 0:pt.call(ft,At,null,o,this.state.context)),fr(this,Kr,un).call(this,{type:"success",data:At}),At}catch(At){try{throw await((yt=(gt=Lt(this,Lr).config).onError)==null?void 0:yt.call(gt,At,o,this.state.context,this)),await((xt=(bt=this.options).onError)==null?void 0:xt.call(bt,At,o,this.state.context)),await((Et=(vt=Lt(this,Lr).config).onSettled)==null?void 0:Et.call(vt,void 0,At,this.state.variables,this.state.context,this)),await((St=(Ct=this.options).onSettled)==null?void 0:St.call(Ct,void 0,At,o,this.state.context)),At}finally{fr(this,Kr,un).call(this,{type:"error",error:At})}}finally{Lt(this,Lr).runNext(this)}}},qr=new WeakMap,Lr=new WeakMap,Tn=new WeakMap,Kr=new WeakSet,un=function(o){const tt=rt=>{switch(o.type){case"failed":return{...rt,failureCount:o.failureCount,failureReason:o.error};case"pause":return{...rt,isPaused:!0};case"continue":return{...rt,isPaused:!1};case"pending":return{...rt,context:o.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:o.isPaused,status:"pending",variables:o.variables,submittedAt:Date.now()};case"success":return{...rt,data:o.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...rt,data:void 0,error:o.error,failureCount:rt.failureCount+1,failureReason:o.error,isPaused:!1,status:"error"}}};this.state=tt(this.state),notifyManager.batch(()=>{Lt(this,qr).forEach(rt=>{rt.onMutationUpdate(o)}),Lt(this,Lr).notify({mutation:this,type:"updated",action:o})})},Gs);function getDefaultState(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zr,so,Zs,MutationCache=(Zs=class extends Subscribable{constructor(o={}){super();hr(this,zr);hr(this,so);this.config=o,ur(this,zr,new Map),ur(this,so,Date.now())}build(o,tt,rt){const nt=new Mutation({mutationCache:this,mutationId:++Cn(this,so)._,options:o.defaultMutationOptions(tt),state:rt});return this.add(nt),nt}add(o){const tt=scopeFor(o),rt=Lt(this,zr).get(tt)??[];rt.push(o),Lt(this,zr).set(tt,rt),this.notify({type:"added",mutation:o})}remove(o){var rt;const tt=scopeFor(o);if(Lt(this,zr).has(tt)){const nt=(rt=Lt(this,zr).get(tt))==null?void 0:rt.filter(ot=>ot!==o);nt&&(nt.length===0?Lt(this,zr).delete(tt):Lt(this,zr).set(tt,nt))}this.notify({type:"removed",mutation:o})}canRun(o){var rt;const tt=(rt=Lt(this,zr).get(scopeFor(o)))==null?void 0:rt.find(nt=>nt.state.status==="pending");return!tt||tt===o}runNext(o){var rt;const tt=(rt=Lt(this,zr).get(scopeFor(o)))==null?void 0:rt.find(nt=>nt!==o&&nt.state.isPaused);return(tt==null?void 0:tt.continue())??Promise.resolve()}clear(){notifyManager.batch(()=>{this.getAll().forEach(o=>{this.remove(o)})})}getAll(){return[...Lt(this,zr).values()].flat()}find(o){const tt={exact:!0,...o};return this.getAll().find(rt=>matchMutation(tt,rt))}findAll(o={}){return this.getAll().filter(tt=>matchMutation(o,tt))}notify(o){notifyManager.batch(()=>{this.listeners.forEach(tt=>{tt(o)})})}resumePausedMutations(){const o=this.getAll().filter(tt=>tt.state.isPaused);return notifyManager.batch(()=>Promise.all(o.map(tt=>tt.continue().catch(noop$4))))}},zr=new WeakMap,so=new WeakMap,Zs);function scopeFor(et){var o;return((o=et.options.scope)==null?void 0:o.id)??String(et.mutationId)}function infiniteQueryBehavior(et){return{onFetch:(o,tt)=>{var lt,dt,ht,mt,ft;const rt=o.options,nt=(ht=(dt=(lt=o.fetchOptions)==null?void 0:lt.meta)==null?void 0:dt.fetchMore)==null?void 0:ht.direction,ot=((mt=o.state.data)==null?void 0:mt.pages)||[],it=((ft=o.state.data)==null?void 0:ft.pageParams)||[];let st={pages:[],pageParams:[]},at=0;const ct=async()=>{let pt=!1;const gt=xt=>{Object.defineProperty(xt,"signal",{enumerable:!0,get:()=>(o.signal.aborted?pt=!0:o.signal.addEventListener("abort",()=>{pt=!0}),o.signal)})},yt=ensureQueryFn(o.options,o.fetchOptions),bt=async(xt,vt,Et)=>{if(pt)return Promise.reject();if(vt==null&&xt.pages.length)return Promise.resolve(xt);const Ct={queryKey:o.queryKey,pageParam:vt,direction:Et?"backward":"forward",meta:o.options.meta};gt(Ct);const St=await yt(Ct),{maxPages:At}=o.options,kt=Et?addToStart:addToEnd;return{pages:kt(xt.pages,St,At),pageParams:kt(xt.pageParams,vt,At)}};if(nt&&ot.length){const xt=nt==="backward",vt=xt?getPreviousPageParam:getNextPageParam,Et={pages:ot,pageParams:it},Ct=vt(rt,Et);st=await bt(Et,Ct,xt)}else{const xt=et??ot.length;do{const vt=at===0?it[0]??rt.initialPageParam:getNextPageParam(rt,st);if(at>0&&vt==null)break;st=await bt(st,vt),at++}while(at{var pt,gt;return(gt=(pt=o.options).persister)==null?void 0:gt.call(pt,ct,{queryKey:o.queryKey,meta:o.options.meta,signal:o.signal},tt)}:o.fetchFn=ct}}}function getNextPageParam(et,{pages:o,pageParams:tt}){const rt=o.length-1;return o.length>0?et.getNextPageParam(o[rt],o,tt[rt],tt):void 0}function getPreviousPageParam(et,{pages:o,pageParams:tt}){var rt;return o.length>0?(rt=et.getPreviousPageParam)==null?void 0:rt.call(et,o[0],o,tt[0],tt):void 0}var Ir,pn,mn,Vn,Hn,gn,Wn,Gn,qs,QueryClient=(qs=class{constructor(et={}){hr(this,Ir);hr(this,pn);hr(this,mn);hr(this,Vn);hr(this,Hn);hr(this,gn);hr(this,Wn);hr(this,Gn);ur(this,Ir,et.queryCache||new QueryCache),ur(this,pn,et.mutationCache||new MutationCache),ur(this,mn,et.defaultOptions||{}),ur(this,Vn,new Map),ur(this,Hn,new Map),ur(this,gn,0)}mount(){Cn(this,gn)._++,Lt(this,gn)===1&&(ur(this,Wn,focusManager.subscribe(async et=>{et&&(await this.resumePausedMutations(),Lt(this,Ir).onFocus())})),ur(this,Gn,onlineManager.subscribe(async et=>{et&&(await this.resumePausedMutations(),Lt(this,Ir).onOnline())})))}unmount(){var et,o;Cn(this,gn)._--,Lt(this,gn)===0&&((et=Lt(this,Wn))==null||et.call(this),ur(this,Wn,void 0),(o=Lt(this,Gn))==null||o.call(this),ur(this,Gn,void 0))}isFetching(et){return Lt(this,Ir).findAll({...et,fetchStatus:"fetching"}).length}isMutating(et){return Lt(this,pn).findAll({...et,status:"pending"}).length}getQueryData(et){var tt;const o=this.defaultQueryOptions({queryKey:et});return(tt=Lt(this,Ir).get(o.queryHash))==null?void 0:tt.state.data}ensureQueryData(et){const o=this.getQueryData(et.queryKey);if(o===void 0)return this.fetchQuery(et);{const tt=this.defaultQueryOptions(et),rt=Lt(this,Ir).build(this,tt);return et.revalidateIfStale&&rt.isStaleByTime(resolveStaleTime(tt.staleTime,rt))&&this.prefetchQuery(tt),Promise.resolve(o)}}getQueriesData(et){return Lt(this,Ir).findAll(et).map(({queryKey:o,state:tt})=>{const rt=tt.data;return[o,rt]})}setQueryData(et,o,tt){const rt=this.defaultQueryOptions({queryKey:et}),nt=Lt(this,Ir).get(rt.queryHash),ot=nt==null?void 0:nt.state.data,it=functionalUpdate(o,ot);if(it!==void 0)return Lt(this,Ir).build(this,rt).setData(it,{...tt,manual:!0})}setQueriesData(et,o,tt){return notifyManager.batch(()=>Lt(this,Ir).findAll(et).map(({queryKey:rt})=>[rt,this.setQueryData(rt,o,tt)]))}getQueryState(et){var tt;const o=this.defaultQueryOptions({queryKey:et});return(tt=Lt(this,Ir).get(o.queryHash))==null?void 0:tt.state}removeQueries(et){const o=Lt(this,Ir);notifyManager.batch(()=>{o.findAll(et).forEach(tt=>{o.remove(tt)})})}resetQueries(et,o){const tt=Lt(this,Ir),rt={type:"active",...et};return notifyManager.batch(()=>(tt.findAll(et).forEach(nt=>{nt.reset()}),this.refetchQueries(rt,o)))}cancelQueries(et={},o={}){const tt={revert:!0,...o},rt=notifyManager.batch(()=>Lt(this,Ir).findAll(et).map(nt=>nt.cancel(tt)));return Promise.all(rt).then(noop$4).catch(noop$4)}invalidateQueries(et={},o={}){return notifyManager.batch(()=>{if(Lt(this,Ir).findAll(et).forEach(rt=>{rt.invalidate()}),et.refetchType==="none")return Promise.resolve();const tt={...et,type:et.refetchType??et.type??"active"};return this.refetchQueries(tt,o)})}refetchQueries(et={},o){const tt={...o,cancelRefetch:(o==null?void 0:o.cancelRefetch)??!0},rt=notifyManager.batch(()=>Lt(this,Ir).findAll(et).filter(nt=>!nt.isDisabled()).map(nt=>{let ot=nt.fetch(void 0,tt);return tt.throwOnError||(ot=ot.catch(noop$4)),nt.state.fetchStatus==="paused"?Promise.resolve():ot}));return Promise.all(rt).then(noop$4)}fetchQuery(et){const o=this.defaultQueryOptions(et);o.retry===void 0&&(o.retry=!1);const tt=Lt(this,Ir).build(this,o);return tt.isStaleByTime(resolveStaleTime(o.staleTime,tt))?tt.fetch(o):Promise.resolve(tt.state.data)}prefetchQuery(et){return this.fetchQuery(et).then(noop$4).catch(noop$4)}fetchInfiniteQuery(et){return et.behavior=infiniteQueryBehavior(et.pages),this.fetchQuery(et)}prefetchInfiniteQuery(et){return this.fetchInfiniteQuery(et).then(noop$4).catch(noop$4)}ensureInfiniteQueryData(et){return et.behavior=infiniteQueryBehavior(et.pages),this.ensureQueryData(et)}resumePausedMutations(){return onlineManager.isOnline()?Lt(this,pn).resumePausedMutations():Promise.resolve()}getQueryCache(){return Lt(this,Ir)}getMutationCache(){return Lt(this,pn)}getDefaultOptions(){return Lt(this,mn)}setDefaultOptions(et){ur(this,mn,et)}setQueryDefaults(et,o){Lt(this,Vn).set(hashKey(et),{queryKey:et,defaultOptions:o})}getQueryDefaults(et){const o=[...Lt(this,Vn).values()];let tt={};return o.forEach(rt=>{partialMatchKey(et,rt.queryKey)&&(tt={...tt,...rt.defaultOptions})}),tt}setMutationDefaults(et,o){Lt(this,Hn).set(hashKey(et),{mutationKey:et,defaultOptions:o})}getMutationDefaults(et){const o=[...Lt(this,Hn).values()];let tt={};return o.forEach(rt=>{partialMatchKey(et,rt.mutationKey)&&(tt={...tt,...rt.defaultOptions})}),tt}defaultQueryOptions(et){if(et._defaulted)return et;const o={...Lt(this,mn).queries,...this.getQueryDefaults(et.queryKey),...et,_defaulted:!0};return o.queryHash||(o.queryHash=hashQueryKeyByOptions(o.queryKey,o)),o.refetchOnReconnect===void 0&&(o.refetchOnReconnect=o.networkMode!=="always"),o.throwOnError===void 0&&(o.throwOnError=!!o.suspense),!o.networkMode&&o.persister&&(o.networkMode="offlineFirst"),o.enabled!==!0&&o.queryFn===skipToken&&(o.enabled=!1),o}defaultMutationOptions(et){return et!=null&&et._defaulted?et:{...Lt(this,mn).mutations,...(et==null?void 0:et.mutationKey)&&this.getMutationDefaults(et.mutationKey),...et,_defaulted:!0}}clear(){Lt(this,Ir).clear(),Lt(this,pn).clear()}},Ir=new WeakMap,pn=new WeakMap,mn=new WeakMap,Vn=new WeakMap,Hn=new WeakMap,gn=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,qs),Br,Cr,ao,Mr,In,Zn,yn,Qr,co,qn,Kn,Pn,jn,bn,Qn,kr,oo,Rs,Ts,Is,Ps,js,Ns,Ds,ru,Ks,QueryObserver=(Ks=class extends Subscribable{constructor(o,tt){super();hr(this,kr);hr(this,Br);hr(this,Cr);hr(this,ao);hr(this,Mr);hr(this,In);hr(this,Zn);hr(this,yn);hr(this,Qr);hr(this,co);hr(this,qn);hr(this,Kn);hr(this,Pn);hr(this,jn);hr(this,bn);hr(this,Qn,new Set);this.options=tt,ur(this,Br,o),ur(this,Qr,null),ur(this,yn,pendingThenable()),this.options.experimental_prefetchInRender||Lt(this,yn).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(tt)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(Lt(this,Cr).addObserver(this),shouldFetchOnMount(Lt(this,Cr),this.options)?fr(this,kr,oo).call(this):this.updateResult(),fr(this,kr,Ps).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return shouldFetchOn(Lt(this,Cr),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return shouldFetchOn(Lt(this,Cr),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,fr(this,kr,js).call(this),fr(this,kr,Ns).call(this),Lt(this,Cr).removeObserver(this)}setOptions(o,tt){const rt=this.options,nt=Lt(this,Cr);if(this.options=Lt(this,Br).defaultQueryOptions(o),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof resolveEnabled(this.options.enabled,Lt(this,Cr))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");fr(this,kr,Ds).call(this),Lt(this,Cr).setOptions(this.options),rt._defaulted&&!shallowEqualObjects(this.options,rt)&&Lt(this,Br).getQueryCache().notify({type:"observerOptionsUpdated",query:Lt(this,Cr),observer:this});const ot=this.hasListeners();ot&&shouldFetchOptionally(Lt(this,Cr),nt,this.options,rt)&&fr(this,kr,oo).call(this),this.updateResult(tt),ot&&(Lt(this,Cr)!==nt||resolveEnabled(this.options.enabled,Lt(this,Cr))!==resolveEnabled(rt.enabled,Lt(this,Cr))||resolveStaleTime(this.options.staleTime,Lt(this,Cr))!==resolveStaleTime(rt.staleTime,Lt(this,Cr)))&&fr(this,kr,Rs).call(this);const it=fr(this,kr,Ts).call(this);ot&&(Lt(this,Cr)!==nt||resolveEnabled(this.options.enabled,Lt(this,Cr))!==resolveEnabled(rt.enabled,Lt(this,Cr))||it!==Lt(this,bn))&&fr(this,kr,Is).call(this,it)}getOptimisticResult(o){const tt=Lt(this,Br).getQueryCache().build(Lt(this,Br),o),rt=this.createResult(tt,o);return shouldAssignObserverCurrentProperties(this,rt)&&(ur(this,Mr,rt),ur(this,Zn,this.options),ur(this,In,Lt(this,Cr).state)),rt}getCurrentResult(){return Lt(this,Mr)}trackResult(o,tt){const rt={};return Object.keys(o).forEach(nt=>{Object.defineProperty(rt,nt,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(nt),tt==null||tt(nt),o[nt])})}),rt}trackProp(o){Lt(this,Qn).add(o)}getCurrentQuery(){return Lt(this,Cr)}refetch({...o}={}){return this.fetch({...o})}fetchOptimistic(o){const tt=Lt(this,Br).defaultQueryOptions(o),rt=Lt(this,Br).getQueryCache().build(Lt(this,Br),tt);return rt.fetch().then(()=>this.createResult(rt,tt))}fetch(o){return fr(this,kr,oo).call(this,{...o,cancelRefetch:o.cancelRefetch??!0}).then(()=>(this.updateResult(),Lt(this,Mr)))}createResult(o,tt){var At;const rt=Lt(this,Cr),nt=this.options,ot=Lt(this,Mr),it=Lt(this,In),st=Lt(this,Zn),ct=o!==rt?o.state:Lt(this,ao),{state:lt}=o;let dt={...lt},ht=!1,mt;if(tt._optimisticResults){const kt=this.hasListeners(),It=!kt&&shouldFetchOnMount(o,tt),Ot=kt&&shouldFetchOptionally(o,rt,tt,nt);(It||Ot)&&(dt={...dt,...fetchState(lt.data,o.options)}),tt._optimisticResults==="isRestoring"&&(dt.fetchStatus="idle")}let{error:ft,errorUpdatedAt:pt,status:gt}=dt;if(tt.select&&dt.data!==void 0)if(ot&&dt.data===(it==null?void 0:it.data)&&tt.select===Lt(this,co))mt=Lt(this,qn);else try{ur(this,co,tt.select),mt=tt.select(dt.data),mt=replaceData(ot==null?void 0:ot.data,mt,tt),ur(this,qn,mt),ur(this,Qr,null)}catch(kt){ur(this,Qr,kt)}else mt=dt.data;if(tt.placeholderData!==void 0&&mt===void 0&>==="pending"){let kt;if(ot!=null&&ot.isPlaceholderData&&tt.placeholderData===(st==null?void 0:st.placeholderData))kt=ot.data;else if(kt=typeof tt.placeholderData=="function"?tt.placeholderData((At=Lt(this,Kn))==null?void 0:At.state.data,Lt(this,Kn)):tt.placeholderData,tt.select&&kt!==void 0)try{kt=tt.select(kt),ur(this,Qr,null)}catch(It){ur(this,Qr,It)}kt!==void 0&&(gt="success",mt=replaceData(ot==null?void 0:ot.data,kt,tt),ht=!0)}Lt(this,Qr)&&(ft=Lt(this,Qr),mt=Lt(this,qn),pt=Date.now(),gt="error");const yt=dt.fetchStatus==="fetching",bt=gt==="pending",xt=gt==="error",vt=bt&&yt,Et=mt!==void 0,St={status:gt,fetchStatus:dt.fetchStatus,isPending:bt,isSuccess:gt==="success",isError:xt,isInitialLoading:vt,isLoading:vt,data:mt,dataUpdatedAt:dt.dataUpdatedAt,error:ft,errorUpdatedAt:pt,failureCount:dt.fetchFailureCount,failureReason:dt.fetchFailureReason,errorUpdateCount:dt.errorUpdateCount,isFetched:dt.dataUpdateCount>0||dt.errorUpdateCount>0,isFetchedAfterMount:dt.dataUpdateCount>ct.dataUpdateCount||dt.errorUpdateCount>ct.errorUpdateCount,isFetching:yt,isRefetching:yt&&!bt,isLoadingError:xt&&!Et,isPaused:dt.fetchStatus==="paused",isPlaceholderData:ht,isRefetchError:xt&&Et,isStale:isStale(o,tt),refetch:this.refetch,promise:Lt(this,yn)};if(this.options.experimental_prefetchInRender){const kt=Nt=>{St.status==="error"?Nt.reject(St.error):St.data!==void 0&&Nt.resolve(St.data)},It=()=>{const Nt=ur(this,yn,St.promise=pendingThenable());kt(Nt)},Ot=Lt(this,yn);switch(Ot.status){case"pending":o.queryHash===rt.queryHash&&kt(Ot);break;case"fulfilled":(St.status==="error"||St.data!==Ot.value)&&It();break;case"rejected":(St.status!=="error"||St.error!==Ot.reason)&&It();break}}return St}updateResult(o){const tt=Lt(this,Mr),rt=this.createResult(Lt(this,Cr),this.options);if(ur(this,In,Lt(this,Cr).state),ur(this,Zn,this.options),Lt(this,In).data!==void 0&&ur(this,Kn,Lt(this,Cr)),shallowEqualObjects(rt,tt))return;ur(this,Mr,rt);const nt={},ot=()=>{if(!tt)return!0;const{notifyOnChangeProps:it}=this.options,st=typeof it=="function"?it():it;if(st==="all"||!st&&!Lt(this,Qn).size)return!0;const at=new Set(st??Lt(this,Qn));return this.options.throwOnError&&at.add("error"),Object.keys(Lt(this,Mr)).some(ct=>{const lt=ct;return Lt(this,Mr)[lt]!==tt[lt]&&at.has(lt)})};(o==null?void 0:o.listeners)!==!1&&ot()&&(nt.listeners=!0),fr(this,kr,ru).call(this,{...nt,...o})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&fr(this,kr,Ps).call(this)}},Br=new WeakMap,Cr=new WeakMap,ao=new WeakMap,Mr=new WeakMap,In=new WeakMap,Zn=new WeakMap,yn=new WeakMap,Qr=new WeakMap,co=new WeakMap,qn=new WeakMap,Kn=new WeakMap,Pn=new WeakMap,jn=new WeakMap,bn=new WeakMap,Qn=new WeakMap,kr=new WeakSet,oo=function(o){fr(this,kr,Ds).call(this);let tt=Lt(this,Cr).fetch(this.options,o);return o!=null&&o.throwOnError||(tt=tt.catch(noop$4)),tt},Rs=function(){fr(this,kr,js).call(this);const o=resolveStaleTime(this.options.staleTime,Lt(this,Cr));if(isServer||Lt(this,Mr).isStale||!isValidTimeout(o))return;const rt=timeUntilStale(Lt(this,Mr).dataUpdatedAt,o)+1;ur(this,Pn,setTimeout(()=>{Lt(this,Mr).isStale||this.updateResult()},rt))},Ts=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(Lt(this,Cr)):this.options.refetchInterval)??!1},Is=function(o){fr(this,kr,Ns).call(this),ur(this,bn,o),!(isServer||resolveEnabled(this.options.enabled,Lt(this,Cr))===!1||!isValidTimeout(Lt(this,bn))||Lt(this,bn)===0)&&ur(this,jn,setInterval(()=>{(this.options.refetchIntervalInBackground||focusManager.isFocused())&&fr(this,kr,oo).call(this)},Lt(this,bn)))},Ps=function(){fr(this,kr,Rs).call(this),fr(this,kr,Is).call(this,fr(this,kr,Ts).call(this))},js=function(){Lt(this,Pn)&&(clearTimeout(Lt(this,Pn)),ur(this,Pn,void 0))},Ns=function(){Lt(this,jn)&&(clearInterval(Lt(this,jn)),ur(this,jn,void 0))},Ds=function(){const o=Lt(this,Br).getQueryCache().build(Lt(this,Br),this.options);if(o===Lt(this,Cr))return;const tt=Lt(this,Cr);ur(this,Cr,o),ur(this,ao,o.state),this.hasListeners()&&(tt==null||tt.removeObserver(this),o.addObserver(this))},ru=function(o){notifyManager.batch(()=>{o.listeners&&this.listeners.forEach(tt=>{tt(Lt(this,Mr))}),Lt(this,Br).getQueryCache().notify({query:Lt(this,Cr),type:"observerResultsUpdated"})})},Ks);function shouldLoadOnMount(et,o){return resolveEnabled(o.enabled,et)!==!1&&et.state.data===void 0&&!(et.state.status==="error"&&o.retryOnMount===!1)}function shouldFetchOnMount(et,o){return shouldLoadOnMount(et,o)||et.state.data!==void 0&&shouldFetchOn(et,o,o.refetchOnMount)}function shouldFetchOn(et,o,tt){if(resolveEnabled(o.enabled,et)!==!1){const rt=typeof tt=="function"?tt(et):tt;return rt==="always"||rt!==!1&&isStale(et,o)}return!1}function shouldFetchOptionally(et,o,tt,rt){return(et!==o||resolveEnabled(rt.enabled,et)===!1)&&(!tt.suspense||et.state.status!=="error")&&isStale(et,tt)}function isStale(et,o){return resolveEnabled(o.enabled,et)!==!1&&et.isStaleByTime(resolveStaleTime(o.staleTime,et))}function shouldAssignObserverCurrentProperties(et,o){return!shallowEqualObjects(et.getCurrentResult(),o)}var xn,vn,Fr,sn,ln,Xo,Os,Qs,MutationObserver$1=(Qs=class extends Subscribable{constructor(tt,rt){super();hr(this,ln);hr(this,xn);hr(this,vn);hr(this,Fr);hr(this,sn);ur(this,xn,tt),this.setOptions(rt),this.bindMethods(),fr(this,ln,Xo).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(tt){var nt;const rt=this.options;this.options=Lt(this,xn).defaultMutationOptions(tt),shallowEqualObjects(this.options,rt)||Lt(this,xn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Lt(this,Fr),observer:this}),rt!=null&&rt.mutationKey&&this.options.mutationKey&&hashKey(rt.mutationKey)!==hashKey(this.options.mutationKey)?this.reset():((nt=Lt(this,Fr))==null?void 0:nt.state.status)==="pending"&&Lt(this,Fr).setOptions(this.options)}onUnsubscribe(){var tt;this.hasListeners()||(tt=Lt(this,Fr))==null||tt.removeObserver(this)}onMutationUpdate(tt){fr(this,ln,Xo).call(this),fr(this,ln,Os).call(this,tt)}getCurrentResult(){return Lt(this,vn)}reset(){var tt;(tt=Lt(this,Fr))==null||tt.removeObserver(this),ur(this,Fr,void 0),fr(this,ln,Xo).call(this),fr(this,ln,Os).call(this)}mutate(tt,rt){var nt;return ur(this,sn,rt),(nt=Lt(this,Fr))==null||nt.removeObserver(this),ur(this,Fr,Lt(this,xn).getMutationCache().build(Lt(this,xn),this.options)),Lt(this,Fr).addObserver(this),Lt(this,Fr).execute(tt)}},xn=new WeakMap,vn=new WeakMap,Fr=new WeakMap,sn=new WeakMap,ln=new WeakSet,Xo=function(){var rt;const tt=((rt=Lt(this,Fr))==null?void 0:rt.state)??getDefaultState();ur(this,vn,{...tt,isPending:tt.status==="pending",isSuccess:tt.status==="success",isError:tt.status==="error",isIdle:tt.status==="idle",mutate:this.mutate,reset:this.reset})},Os=function(tt){notifyManager.batch(()=>{var rt,nt,ot,it,st,at,ct,lt;if(Lt(this,sn)&&this.hasListeners()){const dt=Lt(this,vn).variables,ht=Lt(this,vn).context;(tt==null?void 0:tt.type)==="success"?((nt=(rt=Lt(this,sn)).onSuccess)==null||nt.call(rt,tt.data,dt,ht),(it=(ot=Lt(this,sn)).onSettled)==null||it.call(ot,tt.data,null,dt,ht)):(tt==null?void 0:tt.type)==="error"&&((at=(st=Lt(this,sn)).onError)==null||at.call(st,tt.error,dt,ht),(lt=(ct=Lt(this,sn)).onSettled)==null||lt.call(ct,void 0,tt.error,dt,ht))}this.listeners.forEach(dt=>{dt(Lt(this,vn))})})},Qs);function hashFn(et){return JSON.stringify(et,(o,tt)=>isPlainObject$2(tt)?Object.keys(tt).sort().reduce((rt,nt)=>(rt[nt]=tt[nt],rt),{}):typeof tt=="bigint"?tt.toString():tt)}function isPlainObject$2(et){if(!hasObjectPrototype(et))return!1;const o=et.constructor;if(typeof o>"u")return!0;const tt=o.prototype;return!(!hasObjectPrototype(tt)||!tt.hasOwnProperty("isPrototypeOf"))}function hasObjectPrototype(et){return Object.prototype.toString.call(et)==="[object Object]"}function filterQueryOptions(et){const{_defaulted:o,behavior:tt,gcTime:rt,initialData:nt,initialDataUpdatedAt:ot,maxPages:it,meta:st,networkMode:at,queryFn:ct,queryHash:lt,queryKey:dt,queryKeyHashFn:ht,retry:mt,retryDelay:ft,structuralSharing:pt,getPreviousPageParam:gt,getNextPageParam:yt,initialPageParam:bt,_optimisticResults:xt,enabled:vt,notifyOnChangeProps:Et,placeholderData:Ct,refetchInterval:St,refetchIntervalInBackground:At,refetchOnMount:kt,refetchOnReconnect:It,refetchOnWindowFocus:Ot,retryOnMount:Nt,select:Yt,staleTime:Ft,suspense:Ht,throwOnError:Qt,config:Vt,connector:Bt,query:Wt,...jt}=et;return jt}function connectMutationOptions(et){return{mutationFn(o){return connect$1(et,o)},mutationKey:["connect"]}}function disconnectMutationOptions(et){return{mutationFn(o){return disconnect(et,o)},mutationKey:["disconnect"]}}function getBalanceQueryOptions(et,o={}){return{async queryFn({queryKey:tt}){const{address:rt,scopeKey:nt,...ot}=tt[1];if(!rt)throw new Error("address is required");return await getBalance(et,{...ot,address:rt})??null},queryKey:getBalanceQueryKey(o)}}function getBalanceQueryKey(et={}){return["balance",filterQueryOptions(et)]}function getBlockNumberQueryOptions(et,o={}){return{gcTime:0,async queryFn({queryKey:tt}){const{scopeKey:rt,...nt}=tt[1];return await getBlockNumber(et,nt)??null},queryKey:getBlockNumberQueryKey(o)}}function getBlockNumberQueryKey(et={}){return["blockNumber",filterQueryOptions(et)]}function getEnsAddressQueryOptions(et,o={}){return{async queryFn({queryKey:tt}){const{name:rt,scopeKey:nt,...ot}=tt[1];if(!rt)throw new Error("name is required");return getEnsAddress(et,{...ot,name:rt})},queryKey:getEnsAddressQueryKey(o)}}function getEnsAddressQueryKey(et={}){return["ensAddress",filterQueryOptions(et)]}function getEnsAvatarQueryOptions(et,o={}){return{async queryFn({queryKey:tt}){const{name:rt,scopeKey:nt,...ot}=tt[1];if(!rt)throw new Error("name is required");return getEnsAvatar(et,{...ot,name:rt})},queryKey:getEnsAvatarQueryKey(o)}}function getEnsAvatarQueryKey(et={}){return["ensAvatar",filterQueryOptions(et)]}function getEnsNameQueryOptions(et,o={}){return{async queryFn({queryKey:tt}){const{address:rt,scopeKey:nt,...ot}=tt[1];if(!rt)throw new Error("address is required");return getEnsName(et,{...ot,address:rt})},queryKey:getEnsNameQueryKey(o)}}function getEnsNameQueryKey(et={}){return["ensName",filterQueryOptions(et)]}function signMessageMutationOptions(et){return{mutationFn(o){return signMessage(et,o)},mutationKey:["signMessage"]}}function switchChainMutationOptions(et){return{mutationFn(o){return switchChain(et,o)},mutationKey:["switchChain"]}}var QueryClientContext=reactExports.createContext(void 0),useQueryClient=et=>{const o=reactExports.useContext(QueryClientContext);if(!o)throw new Error("No QueryClient set, use QueryClientProvider to set one");return o},QueryClientProvider=({client:et,children:o})=>(reactExports.useEffect(()=>(et.mount(),()=>{et.unmount()}),[et]),jsxRuntimeExports.jsx(QueryClientContext.Provider,{value:et,children:o})),IsRestoringContext=reactExports.createContext(!1),useIsRestoring=()=>reactExports.useContext(IsRestoringContext);IsRestoringContext.Provider;function createValue(){let et=!1;return{clearReset:()=>{et=!1},reset:()=>{et=!0},isReset:()=>et}}var QueryErrorResetBoundaryContext=reactExports.createContext(createValue()),useQueryErrorResetBoundary=()=>reactExports.useContext(QueryErrorResetBoundaryContext);function shouldThrowError(et,o){return typeof et=="function"?et(...o):!!et}function noop$3(){}var ensurePreventErrorBoundaryRetry=(et,o)=>{(et.suspense||et.throwOnError)&&(o.isReset()||(et.retryOnMount=!1))},useClearResetErrorBoundary=et=>{reactExports.useEffect(()=>{et.clearReset()},[et])},getHasError=({result:et,errorResetBoundary:o,throwOnError:tt,query:rt})=>et.isError&&!o.isReset()&&!et.isFetching&&rt&&shouldThrowError(tt,[et.error,rt]),ensureSuspenseTimers=et=>{et.suspense&&(et.staleTime===void 0&&(et.staleTime=1e3),typeof et.gcTime=="number"&&(et.gcTime=Math.max(et.gcTime,1e3)))},willFetch=(et,o)=>et.isLoading&&et.isFetching&&!o,shouldSuspend=(et,o)=>(et==null?void 0:et.suspense)&&o.isPending,fetchOptimistic=(et,o,tt)=>o.fetchOptimistic(et).catch(()=>{tt.clearReset()});function useBaseQuery(et,o,tt){var lt,dt,ht,mt,ft;const rt=useQueryClient(),nt=useIsRestoring(),ot=useQueryErrorResetBoundary(),it=rt.defaultQueryOptions(et);(dt=(lt=rt.getDefaultOptions().queries)==null?void 0:lt._experimental_beforeQuery)==null||dt.call(lt,it),it._optimisticResults=nt?"isRestoring":"optimistic",ensureSuspenseTimers(it),ensurePreventErrorBoundaryRetry(it,ot),useClearResetErrorBoundary(ot);const st=!rt.getQueryCache().get(it.queryHash),[at]=reactExports.useState(()=>new o(rt,it)),ct=at.getOptimisticResult(it);if(reactExports.useSyncExternalStore(reactExports.useCallback(pt=>{const gt=nt?()=>{}:at.subscribe(notifyManager.batchCalls(pt));return at.updateResult(),gt},[at,nt]),()=>at.getCurrentResult(),()=>at.getCurrentResult()),reactExports.useEffect(()=>{at.setOptions(it,{listeners:!1})},[it,at]),shouldSuspend(it,ct))throw fetchOptimistic(it,at,ot);if(getHasError({result:ct,errorResetBoundary:ot,throwOnError:it.throwOnError,query:rt.getQueryCache().get(it.queryHash)}))throw ct.error;if((mt=(ht=rt.getDefaultOptions().queries)==null?void 0:ht._experimental_afterQuery)==null||mt.call(ht,it,ct),it.experimental_prefetchInRender&&!isServer&&willFetch(ct,nt)){const pt=st?fetchOptimistic(it,at,ot):(ft=rt.getQueryCache().get(it.queryHash))==null?void 0:ft.promise;pt==null||pt.catch(noop$3).finally(()=>{at.hasListeners()||at.updateResult()})}return it.notifyOnChangeProps?ct:at.trackResult(ct)}function useQuery$1(et,o){return useBaseQuery(et,QueryObserver)}function useMutation(et,o){const tt=useQueryClient(),[rt]=reactExports.useState(()=>new MutationObserver$1(tt,et));reactExports.useEffect(()=>{rt.setOptions(et)},[rt,et]);const nt=reactExports.useSyncExternalStore(reactExports.useCallback(it=>rt.subscribe(notifyManager.batchCalls(it)),[rt]),()=>rt.getCurrentResult(),()=>rt.getCurrentResult()),ot=reactExports.useCallback((it,st)=>{rt.mutate(it,st).catch(noop$3)},[rt]);if(nt.error&&shouldThrowError(rt.options.throwOnError,[nt.error]))throw nt.error;return{...nt,mutate:ot,mutateAsync:nt.mutate}}function useQuery(et){const o=useQuery$1({...et,queryKeyHashFn:hashFn});return o.queryKey=et.queryKey,o}function useChainId(et={}){const o=useConfig(et);return reactExports.useSyncExternalStore(tt=>watchChainId(o,{onChange:tt}),()=>getChainId(o),()=>getChainId(o))}function useBalance(et={}){const{address:o,query:tt={}}=et,rt=useConfig(et),nt=useChainId({config:rt}),ot=getBalanceQueryOptions(rt,{...et,chainId:et.chainId??nt}),it=!!(o&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useWatchBlockNumber(et={}){const{enabled:o=!0,onBlockNumber:tt,config:rt,...nt}=et,ot=useConfig(et),it=useChainId({config:ot}),st=et.chainId??it;reactExports.useEffect(()=>{if(o&&tt)return watchBlockNumber(ot,{...nt,chainId:st,onBlockNumber:tt})},[st,ot,o,tt,nt.onError,nt.emitMissed,nt.emitOnBegin,nt.poll,nt.pollingInterval,nt.syncConnectedChain])}function useBlockNumber(et={}){const{query:o={},watch:tt}=et,rt=useConfig(et),nt=useQueryClient(),ot=useChainId({config:rt}),it=et.chainId??ot,st=getBlockNumberQueryOptions(rt,{...et,chainId:it});return useWatchBlockNumber({config:et.config,chainId:et.chainId,...typeof tt=="object"?tt:{},enabled:!!((o.enabled??!0)&&(typeof tt=="object"?tt.enabled:tt)),onBlockNumber(at){nt.setQueryData(st.queryKey,at)}}),useQuery({...o,...st})}function useChains$1(et={}){const o=useConfig(et);return reactExports.useSyncExternalStore(tt=>watchChains(o,{onChange:tt}),()=>getChains(o),()=>getChains(o))}function useConnectors$1(et={}){const o=useConfig(et);return reactExports.useSyncExternalStore(tt=>watchConnectors(o,{onChange:tt}),()=>getConnectors(o),()=>getConnectors(o))}function useConnect$1(et={}){const{mutation:o}=et,tt=useConfig(et),rt=connectMutationOptions(tt),{mutate:nt,mutateAsync:ot,...it}=useMutation({...o,...rt});return reactExports.useEffect(()=>tt.subscribe(({status:st})=>st,(st,at)=>{at==="connected"&&st==="disconnected"&&it.reset()}),[tt,it.reset]),{...it,connect:nt,connectAsync:ot,connectors:useConnectors$1({config:tt})}}function useConnections(et={}){const o=useConfig(et);return reactExports.useSyncExternalStore(tt=>watchConnections(o,{onChange:tt}),()=>getConnections(o),()=>getConnections(o))}function useDisconnect(et={}){const{mutation:o}=et,tt=useConfig(et),rt=disconnectMutationOptions(tt),{mutate:nt,mutateAsync:ot,...it}=useMutation({...o,...rt});return{...it,connectors:useConnections({config:tt}).map(st=>st.connector),disconnect:nt,disconnectAsync:ot}}function useEnsAddress(et={}){const{name:o,query:tt={}}=et,rt=useConfig(et),nt=useChainId({config:rt}),ot=getEnsAddressQueryOptions(rt,{...et,chainId:et.chainId??nt}),it=!!(o&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useEnsAvatar(et={}){const{name:o,query:tt={}}=et,rt=useConfig(et),nt=useChainId({config:rt}),ot=getEnsAvatarQueryOptions(rt,{...et,chainId:et.chainId??nt}),it=!!(o&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useEnsName(et={}){const{address:o,query:tt={}}=et,rt=useConfig(et),nt=useChainId({config:rt}),ot=getEnsNameQueryOptions(rt,{...et,chainId:et.chainId??nt}),it=!!(o&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useSignMessage(et={}){const{mutation:o}=et,tt=useConfig(et),rt=signMessageMutationOptions(tt),{mutate:nt,mutateAsync:ot,...it}=useMutation({...o,...rt});return{...it,signMessage:nt,signMessageAsync:ot}}function useSwitchChain(et={}){const{mutation:o}=et,tt=useConfig(et),rt=switchChainMutationOptions(tt),{mutate:nt,mutateAsync:ot,...it}=useMutation({...o,...rt});return{...it,chains:useChains$1({config:tt}),switchChain:nt,switchChainAsync:ot}}const contracts={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},formatters={block:defineBlock({format(et){var tt;return{transactions:(tt=et.transactions)==null?void 0:tt.map(rt=>{if(typeof rt=="string")return rt;const nt=formatTransaction(rt);return nt.typeHex==="0x7e"&&(nt.isSystemTx=rt.isSystemTx,nt.mint=rt.mint?hexToBigInt(rt.mint):void 0,nt.sourceHash=rt.sourceHash,nt.type="deposit"),nt}),stateRoot:et.stateRoot}}}),transaction:defineTransaction({format(et){const o={};return et.type==="0x7e"&&(o.isSystemTx=et.isSystemTx,o.mint=et.mint?hexToBigInt(et.mint):void 0,o.sourceHash=et.sourceHash,o.type="deposit"),o}}),transactionReceipt:defineTransactionReceipt({format(et){return{l1GasPrice:et.l1GasPrice?hexToBigInt(et.l1GasPrice):null,l1GasUsed:et.l1GasUsed?hexToBigInt(et.l1GasUsed):null,l1Fee:et.l1Fee?hexToBigInt(et.l1Fee):null,l1FeeScalar:et.l1FeeScalar?Number(et.l1FeeScalar):null}}})};function serializeTransaction(et,o){return isDeposit(et)?serializeTransactionDeposit(et):serializeTransaction$1(et,o)}const serializers={transaction:serializeTransaction};function serializeTransactionDeposit(et){assertTransactionDeposit(et);const{sourceHash:o,data:tt,from:rt,gas:nt,isSystemTx:ot,mint:it,to:st,value:at}=et,ct=[o,rt,st??"0x",it?toHex(it):"0x",at?toHex(at):"0x",nt?toHex(nt):"0x",ot?"0x1":"0x",tt??"0x"];return concatHex(["0x7e",toRlp(ct)])}function isDeposit(et){return et.type==="deposit"||typeof et.sourceHash<"u"}function assertTransactionDeposit(et){const{from:o,to:tt}=et;if(o&&!isAddress(o))throw new InvalidAddressError({address:o});if(tt&&!isAddress(tt))throw new InvalidAddressError({address:tt})}const chainConfig={contracts,formatters,serializers},arbitrum=defineChain({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),mainnet=defineChain({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),sourceId=1,optimism=defineChain({...chainConfig,id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimism Explorer",url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io/api"}},contracts:{...chainConfig.contracts,disputeGameFactory:{[sourceId]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[sourceId]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[sourceId]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[sourceId]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId}),polygon=defineChain({id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}});coinbaseWallet.type="coinbaseWallet";function coinbaseWallet(et={}){return et.version==="3"||et.headlessMode?version3(et):version4(et)}function version4(et){let o,tt,rt,nt,ot;return it=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",supportsSimulation:!0,type:coinbaseWallet.type,async connect({chainId:st}={}){try{const at=await this.getProvider(),ct=(await at.request({method:"eth_requestAccounts"})).map(dt=>getAddress(dt));rt||(rt=this.onAccountsChanged.bind(this),at.on("accountsChanged",rt)),nt||(nt=this.onChainChanged.bind(this),at.on("chainChanged",nt)),ot||(ot=this.onDisconnect.bind(this),at.on("disconnect",ot));let lt=await this.getChainId();if(st&<!==st){const dt=await this.switchChain({chainId:st}).catch(ht=>{if(ht.code===UserRejectedRequestError.code)throw ht;return{id:lt}});lt=(dt==null?void 0:dt.id)??lt}return{accounts:ct,chainId:lt}}catch(at){throw/(user closed modal|accounts received is empty|user denied account|request rejected)/i.test(at.message)?new UserRejectedRequestError(at):at}},async disconnect(){var at;const st=await this.getProvider();rt&&(st.removeListener("accountsChanged",rt),rt=void 0),nt&&(st.removeListener("chainChanged",nt),nt=void 0),ot&&(st.removeListener("disconnect",ot),ot=void 0),st.disconnect(),(at=st.close)==null||at.call(st)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(at=>getAddress(at))},async getChainId(){const at=await(await this.getProvider()).request({method:"eth_chainId"});return Number(at)},async getProvider(){if(!tt){const st=await(async()=>{const{default:at}=await __vitePreload(async()=>{const{default:ct}=await import("./index-C5SJQ4cM.js").then(lt=>lt.i);return{default:ct}},__vite__mapDeps([0,1,2,3]));return typeof at!="function"&&typeof at.default=="function"?at.default:at})();o=new st({...et,appChainIds:it.chains.map(at=>at.id)}),tt=o.makeWeb3Provider({...et,options:et.preference??"all"})}return tt},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:st,chainId:at}){var dt,ht,mt,ft;const ct=it.chains.find(pt=>pt.id===at);if(!ct)throw new SwitchChainError(new ChainNotConfiguredError);const lt=await this.getProvider();try{return await lt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(ct.id)}]}),ct}catch(pt){if(pt.code===4902)try{let gt;st!=null&&st.blockExplorerUrls?gt=st.blockExplorerUrls:gt=(dt=ct.blockExplorers)!=null&&dt.default.url?[(ht=ct.blockExplorers)==null?void 0:ht.default.url]:[];let yt;(mt=st==null?void 0:st.rpcUrls)!=null&&mt.length?yt=st.rpcUrls:yt=[((ft=ct.rpcUrls.default)==null?void 0:ft.http[0])??""];const bt={blockExplorerUrls:gt,chainId:numberToHex(at),chainName:(st==null?void 0:st.chainName)??ct.name,iconUrls:st==null?void 0:st.iconUrls,nativeCurrency:(st==null?void 0:st.nativeCurrency)??ct.nativeCurrency,rpcUrls:yt};return await lt.request({method:"wallet_addEthereumChain",params:[bt]}),ct}catch(gt){throw new UserRejectedRequestError(gt)}throw new SwitchChainError(pt)}},onAccountsChanged(st){st.length===0?this.onDisconnect():it.emitter.emit("change",{accounts:st.map(at=>getAddress(at))})},onChainChanged(st){const at=Number(st);it.emitter.emit("change",{chainId:at})},async onDisconnect(st){it.emitter.emit("disconnect");const at=await this.getProvider();rt&&(at.removeListener("accountsChanged",rt),rt=void 0),nt&&(at.removeListener("chainChanged",nt),nt=void 0),ot&&(at.removeListener("disconnect",ot),ot=void 0)}})}function version3(et){let tt,rt,nt,ot,it;return st=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",supportsSimulation:!0,type:coinbaseWallet.type,async connect({chainId:at}={}){try{const ct=await this.getProvider(),lt=(await ct.request({method:"eth_requestAccounts"})).map(ht=>getAddress(ht));nt||(nt=this.onAccountsChanged.bind(this),ct.on("accountsChanged",nt)),ot||(ot=this.onChainChanged.bind(this),ct.on("chainChanged",ot)),it||(it=this.onDisconnect.bind(this),ct.on("disconnect",it));let dt=await this.getChainId();if(at&&dt!==at){const ht=await this.switchChain({chainId:at}).catch(mt=>{if(mt.code===UserRejectedRequestError.code)throw mt;return{id:dt}});dt=(ht==null?void 0:ht.id)??dt}return{accounts:lt,chainId:dt}}catch(ct){throw/(user closed modal|accounts received is empty|user denied account)/i.test(ct.message)?new UserRejectedRequestError(ct):ct}},async disconnect(){const at=await this.getProvider();nt&&(at.removeListener("accountsChanged",nt),nt=void 0),ot&&(at.removeListener("chainChanged",ot),ot=void 0),it&&(at.removeListener("disconnect",it),it=void 0),at.disconnect(),at.close()},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(ct=>getAddress(ct))},async getChainId(){const ct=await(await this.getProvider()).request({method:"eth_chainId"});return Number(ct)},async getProvider(){var at;if(!rt){const ct=await(async()=>{const{default:ft}=await __vitePreload(async()=>{const{default:pt}=await import("./index-BRDupqIG.js").then(gt=>gt.i);return{default:pt}},__vite__mapDeps([4,3,1,2]));return typeof ft!="function"&&typeof ft.default=="function"?ft.default:ft})();tt=new ct({...et,reloadOnDisconnect:!1});const lt=(at=tt.walletExtension)==null?void 0:at.getChainId(),dt=st.chains.find(ft=>et.chainId?ft.id===et.chainId:ft.id===lt)||st.chains[0],ht=et.chainId||(dt==null?void 0:dt.id),mt=et.jsonRpcUrl||(dt==null?void 0:dt.rpcUrls.default.http[0]);rt=tt.makeWeb3Provider(mt,ht)}return rt},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:at,chainId:ct}){var ht,mt,ft,pt;const lt=st.chains.find(gt=>gt.id===ct);if(!lt)throw new SwitchChainError(new ChainNotConfiguredError);const dt=await this.getProvider();try{return await dt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(lt.id)}]}),lt}catch(gt){if(gt.code===4902)try{let yt;at!=null&&at.blockExplorerUrls?yt=at.blockExplorerUrls:yt=(ht=lt.blockExplorers)!=null&&ht.default.url?[(mt=lt.blockExplorers)==null?void 0:mt.default.url]:[];let bt;(ft=at==null?void 0:at.rpcUrls)!=null&&ft.length?bt=at.rpcUrls:bt=[((pt=lt.rpcUrls.default)==null?void 0:pt.http[0])??""];const xt={blockExplorerUrls:yt,chainId:numberToHex(ct),chainName:(at==null?void 0:at.chainName)??lt.name,iconUrls:at==null?void 0:at.iconUrls,nativeCurrency:(at==null?void 0:at.nativeCurrency)??lt.nativeCurrency,rpcUrls:bt};return await dt.request({method:"wallet_addEthereumChain",params:[xt]}),lt}catch(yt){throw new UserRejectedRequestError(yt)}throw new SwitchChainError(gt)}},onAccountsChanged(at){at.length===0?this.onDisconnect():st.emitter.emit("change",{accounts:at.map(ct=>getAddress(ct))})},onChainChanged(at){const ct=Number(at);st.emitter.emit("change",{chainId:ct})},async onDisconnect(at){st.emitter.emit("disconnect");const ct=await this.getProvider();nt&&(ct.removeListener("accountsChanged",nt),nt=void 0),ot&&(ct.removeListener("chainChanged",ot),ot=void 0),it&&(ct.removeListener("disconnect",it),it=void 0)}})}safe.type="safe";function safe(et={}){const{shimDisconnect:o=!1}=et;let tt,rt;return nt=>({id:"safe",name:"Safe",type:safe.type,async connect(){var at;const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;const it=await this.getAccounts(),st=await this.getChainId();return rt||(rt=this.onDisconnect.bind(this),ot.on("disconnect",rt)),o&&await((at=nt.storage)==null?void 0:at.removeItem("safe.disconnected")),{accounts:it,chainId:st}},async disconnect(){var it;const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;rt&&(ot.removeListener("disconnect",rt),rt=void 0),o&&await((it=nt.storage)==null?void 0:it.setItem("safe.disconnected",!0))},async getAccounts(){const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;return(await ot.request({method:"eth_accounts"})).map(getAddress)},async getProvider(){if(typeof window<"u"&&(window==null?void 0:window.parent)!==window){if(!tt){const{default:it}=await __vitePreload(async()=>{const{default:lt}=await import("./index-D4poE_Tm.js");return{default:lt}},[]),st=new it(et),at=await withTimeout(()=>st.safe.getInfo(),{timeout:et.unstable_getInfoTimeout??10});if(!at)throw new Error("Could not load Safe information");const{SafeAppProvider:ct}=await __vitePreload(async()=>{const{SafeAppProvider:lt}=await import("./index-DaaUGS07.js").then(dt=>dt.i);return{SafeAppProvider:lt}},__vite__mapDeps([5,2]));tt=new ct(at,st)}return tt}},async getChainId(){const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;return Number(ot.chainId)},async isAuthorized(){var ot;try{return o&&await((ot=nt.storage)==null?void 0:ot.getItem("safe.disconnected"))?!1:!!(await this.getAccounts()).length}catch{return!1}},onAccountsChanged(){},onChainChanged(){},onDisconnect(){nt.emitter.emit("disconnect")}})}walletConnect.type="walletConnect";function walletConnect(et){const o=et.isNewChainsStale??!0;let tt,rt;const nt="eip155";let ot,it,st,at,ct,lt;return dt=>({id:"walletConnect",name:"WalletConnect",type:walletConnect.type,async setup(){const ht=await this.getProvider().catch(()=>null);ht&&(st||(st=this.onConnect.bind(this),ht.on("connect",st)),ct||(ct=this.onSessionDelete.bind(this),ht.on("session_delete",ct)))},async connect({chainId:ht,...mt}={}){var ft,pt;try{const gt=await this.getProvider();if(!gt)throw new ProviderNotFoundError;at||(at=this.onDisplayUri,gt.on("display_uri",at));let yt=ht;if(!yt){const Et=await((ft=dt.storage)==null?void 0:ft.getItem("state"))??{};dt.chains.some(St=>St.id===Et.chainId)?yt=Et.chainId:yt=(pt=dt.chains[0])==null?void 0:pt.id}if(!yt)throw new Error("No chains found on connector.");const bt=await this.isChainsStale();if(gt.session&&bt&&await gt.disconnect(),!gt.session||bt){const Et=dt.chains.filter(Ct=>Ct.id!==yt).map(Ct=>Ct.id);await gt.connect({optionalChains:[yt,...Et],..."pairingTopic"in mt?{pairingTopic:mt.pairingTopic}:{}}),this.setRequestedChainsIds(dt.chains.map(Ct=>Ct.id))}const xt=(await gt.enable()).map(Et=>getAddress(Et)),vt=await this.getChainId();return at&&(gt.removeListener("display_uri",at),at=void 0),st&&(gt.removeListener("connect",st),st=void 0),ot||(ot=this.onAccountsChanged.bind(this),gt.on("accountsChanged",ot)),it||(it=this.onChainChanged.bind(this),gt.on("chainChanged",it)),lt||(lt=this.onDisconnect.bind(this),gt.on("disconnect",lt)),ct||(ct=this.onSessionDelete.bind(this),gt.on("session_delete",ct)),{accounts:xt,chainId:vt}}catch(gt){throw/(user rejected|connection request reset)/i.test(gt==null?void 0:gt.message)?new UserRejectedRequestError(gt):gt}},async disconnect(){const ht=await this.getProvider();try{await(ht==null?void 0:ht.disconnect())}catch(mt){if(!/No matching key/i.test(mt.message))throw mt}finally{it&&(ht==null||ht.removeListener("chainChanged",it),it=void 0),lt&&(ht==null||ht.removeListener("disconnect",lt),lt=void 0),st||(st=this.onConnect.bind(this),ht==null||ht.on("connect",st)),ot&&(ht==null||ht.removeListener("accountsChanged",ot),ot=void 0),ct&&(ht==null||ht.removeListener("session_delete",ct),ct=void 0),this.setRequestedChainsIds([])}},async getAccounts(){return(await this.getProvider()).accounts.map(mt=>getAddress(mt))},async getProvider({chainId:ht}={}){var ft;async function mt(){const pt=dt.chains.map(yt=>yt.id);if(!pt.length)return;const{EthereumProvider:gt}=await __vitePreload(async()=>{const{EthereumProvider:yt}=await import("./index.es-BvE4YOl7.js");return{EthereumProvider:yt}},__vite__mapDeps([6,2,3]));return await gt.init({...et,disableProviderPing:!0,optionalChains:pt,projectId:et.projectId,rpcMap:Object.fromEntries(dt.chains.map(yt=>{const[bt]=extractRpcUrls({chain:yt,transports:dt.transports});return[yt.id,bt]})),showQrModal:et.showQrModal??!0})}return tt||(rt||(rt=mt()),tt=await rt,tt==null||tt.events.setMaxListeners(Number.POSITIVE_INFINITY)),ht&&await((ft=this.switchChain)==null?void 0:ft.call(this,{chainId:ht})),tt},async getChainId(){return(await this.getProvider()).chainId},async isAuthorized(){try{const[ht,mt]=await Promise.all([this.getAccounts(),this.getProvider()]);return ht.length?await this.isChainsStale()&&mt.session?(await mt.disconnect().catch(()=>{}),!1):!0:!1}catch{return!1}},async switchChain({addEthereumChainParameter:ht,chainId:mt}){var gt,yt,bt;const ft=await this.getProvider();if(!ft)throw new ProviderNotFoundError;const pt=dt.chains.find(xt=>xt.id===mt);if(!pt)throw new SwitchChainError(new ChainNotConfiguredError);try{await Promise.all([new Promise(vt=>{const Et=({chainId:Ct})=>{Ct===mt&&(dt.emitter.off("change",Et),vt())};dt.emitter.on("change",Et)}),ft.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(mt)}]})]);const xt=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...xt,mt]),pt}catch(xt){const vt=xt;if(/(user rejected)/i.test(vt.message))throw new UserRejectedRequestError(vt);try{let Et;ht!=null&&ht.blockExplorerUrls?Et=ht.blockExplorerUrls:Et=(gt=pt.blockExplorers)!=null&>.default.url?[(yt=pt.blockExplorers)==null?void 0:yt.default.url]:[];let Ct;(bt=ht==null?void 0:ht.rpcUrls)!=null&&bt.length?Ct=ht.rpcUrls:Ct=[...pt.rpcUrls.default.http];const St={blockExplorerUrls:Et,chainId:numberToHex(mt),chainName:(ht==null?void 0:ht.chainName)??pt.name,iconUrls:ht==null?void 0:ht.iconUrls,nativeCurrency:(ht==null?void 0:ht.nativeCurrency)??pt.nativeCurrency,rpcUrls:Ct};await ft.request({method:"wallet_addEthereumChain",params:[St]});const At=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...At,mt]),pt}catch(Et){throw new UserRejectedRequestError(Et)}}},onAccountsChanged(ht){ht.length===0?this.onDisconnect():dt.emitter.emit("change",{accounts:ht.map(mt=>getAddress(mt))})},onChainChanged(ht){const mt=Number(ht);dt.emitter.emit("change",{chainId:mt})},async onConnect(ht){const mt=Number(ht.chainId),ft=await this.getAccounts();dt.emitter.emit("connect",{accounts:ft,chainId:mt})},async onDisconnect(ht){this.setRequestedChainsIds([]),dt.emitter.emit("disconnect");const mt=await this.getProvider();ot&&(mt.removeListener("accountsChanged",ot),ot=void 0),it&&(mt.removeListener("chainChanged",it),it=void 0),lt&&(mt.removeListener("disconnect",lt),lt=void 0),ct&&(mt.removeListener("session_delete",ct),ct=void 0),st||(st=this.onConnect.bind(this),mt.on("connect",st))},onDisplayUri(ht){dt.emitter.emit("message",{type:"display_uri",data:ht})},onSessionDelete(){this.onDisconnect()},getNamespaceChainsIds(){var mt,ft,pt;return tt?((pt=(ft=(mt=tt.session)==null?void 0:mt.namespaces[nt])==null?void 0:ft.accounts)==null?void 0:pt.map(gt=>Number.parseInt(gt.split(":")[1]||"")))??[]:[]},async getRequestedChainsIds(){var ht;return await((ht=dt.storage)==null?void 0:ht.getItem(this.requestedChainsStorageKey))??[]},async isChainsStale(){if(!o)return!1;const ht=dt.chains.map(pt=>pt.id),mt=this.getNamespaceChainsIds();if(mt.length&&!mt.some(pt=>ht.includes(pt)))return!1;const ft=await this.getRequestedChainsIds();return!ht.every(pt=>ft.includes(pt))},async setRequestedChainsIds(ht){var mt;await((mt=dt.storage)==null?void 0:mt.setItem(this.requestedChainsStorageKey,ht))},get requestedChainsStorageKey(){return`${this.id}.requestedChains`}})}var __spreadArray$1=function(et,o,tt){if(tt||arguments.length===2)for(var rt=0,nt=o.length,ot;rt"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(et){return et!==""&&userAgentRules.reduce(function(o,tt){var rt=tt[0],nt=tt[1];if(o)return o;var ot=nt.exec(et);return!!ot&&[rt,ot]},!1)}function parseUserAgent(et){var o=matchUserAgent(et);if(!o)return null;var tt=o[0],rt=o[1];if(tt==="searchbot")return new BotInfo;var nt=rt[1]&&rt[1].split(".").join("_").split("_").slice(0,3);nt?nt.length0)throw new Error("Invalid string. Length must be a multiple of 4");var tt=et.indexOf("=");tt===-1&&(tt=o);var rt=tt===o?0:4-tt%4;return[tt,rt]}function byteLength(et){var o=getLens(et),tt=o[0],rt=o[1];return(tt+rt)*3/4-rt}function _byteLength(et,o,tt){return(o+tt)*3/4-tt}function toByteArray(et){var o,tt=getLens(et),rt=tt[0],nt=tt[1],ot=new Arr(_byteLength(et,rt,nt)),it=0,st=nt>0?rt-4:rt,at;for(at=0;at>16&255,ot[it++]=o>>8&255,ot[it++]=o&255;return nt===2&&(o=revLookup[et.charCodeAt(at)]<<2|revLookup[et.charCodeAt(at+1)]>>4,ot[it++]=o&255),nt===1&&(o=revLookup[et.charCodeAt(at)]<<10|revLookup[et.charCodeAt(at+1)]<<4|revLookup[et.charCodeAt(at+2)]>>2,ot[it++]=o>>8&255,ot[it++]=o&255),ot}function tripletToBase64(et){return lookup[et>>18&63]+lookup[et>>12&63]+lookup[et>>6&63]+lookup[et&63]}function encodeChunk(et,o,tt){for(var rt,nt=[],ot=o;otst?st:it+ot));return rt===1?(o=et[tt-1],nt.push(lookup[o>>2]+lookup[o<<4&63]+"==")):rt===2&&(o=(et[tt-2]<<8)+et[tt-1],nt.push(lookup[o>>10]+lookup[o>>4&63]+lookup[o<<2&63]+"=")),nt.join("")}var ieee754={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ieee754.read=function(et,o,tt,rt,nt){var ot,it,st=nt*8-rt-1,at=(1<>1,lt=-7,dt=tt?nt-1:0,ht=tt?-1:1,mt=et[o+dt];for(dt+=ht,ot=mt&(1<<-lt)-1,mt>>=-lt,lt+=st;lt>0;ot=ot*256+et[o+dt],dt+=ht,lt-=8);for(it=ot&(1<<-lt)-1,ot>>=-lt,lt+=rt;lt>0;it=it*256+et[o+dt],dt+=ht,lt-=8);if(ot===0)ot=1-ct;else{if(ot===at)return it?NaN:(mt?-1:1)*(1/0);it=it+Math.pow(2,rt),ot=ot-ct}return(mt?-1:1)*it*Math.pow(2,ot-rt)};ieee754.write=function(et,o,tt,rt,nt,ot){var it,st,at,ct=ot*8-nt-1,lt=(1<>1,ht=nt===23?Math.pow(2,-24)-Math.pow(2,-77):0,mt=rt?0:ot-1,ft=rt?1:-1,pt=o<0||o===0&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(st=isNaN(o)?1:0,it=lt):(it=Math.floor(Math.log(o)/Math.LN2),o*(at=Math.pow(2,-it))<1&&(it--,at*=2),it+dt>=1?o+=ht/at:o+=ht*Math.pow(2,1-dt),o*at>=2&&(it++,at/=2),it+dt>=lt?(st=0,it=lt):it+dt>=1?(st=(o*at-1)*Math.pow(2,nt),it=it+dt):(st=o*Math.pow(2,dt-1)*Math.pow(2,nt),it=0));nt>=8;et[tt+mt]=st&255,mt+=ft,st/=256,nt-=8);for(it=it<0;et[tt+mt]=it&255,mt+=ft,it/=256,ct-=8);et[tt+mt-ft]|=pt*128};/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */(function(et){const o=base64Js,tt=ieee754,rt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;et.Buffer=st,et.SlowBuffer=bt,et.INSPECT_MAX_BYTES=50;const nt=2147483647;et.kMaxLength=nt,st.TYPED_ARRAY_SUPPORT=ot(),!st.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ot(){try{const Tt=new Uint8Array(1),$t={foo:function(){return 42}};return Object.setPrototypeOf($t,Uint8Array.prototype),Object.setPrototypeOf(Tt,$t),Tt.foo()===42}catch{return!1}}Object.defineProperty(st.prototype,"parent",{enumerable:!0,get:function(){if(st.isBuffer(this))return this.buffer}}),Object.defineProperty(st.prototype,"offset",{enumerable:!0,get:function(){if(st.isBuffer(this))return this.byteOffset}});function it(Tt){if(Tt>nt)throw new RangeError('The value "'+Tt+'" is invalid for option "size"');const $t=new Uint8Array(Tt);return Object.setPrototypeOf($t,st.prototype),$t}function st(Tt,$t,_t){if(typeof Tt=="number"){if(typeof $t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return dt(Tt)}return at(Tt,$t,_t)}st.poolSize=8192;function at(Tt,$t,_t){if(typeof Tt=="string")return ht(Tt,$t);if(ArrayBuffer.isView(Tt))return ft(Tt);if(Tt==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Tt);if(_r(Tt,ArrayBuffer)||Tt&&_r(Tt.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(_r(Tt,SharedArrayBuffer)||Tt&&_r(Tt.buffer,SharedArrayBuffer)))return pt(Tt,$t,_t);if(typeof Tt=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Dt=Tt.valueOf&&Tt.valueOf();if(Dt!=null&&Dt!==Tt)return st.from(Dt,$t,_t);const qt=gt(Tt);if(qt)return qt;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof Tt[Symbol.toPrimitive]=="function")return st.from(Tt[Symbol.toPrimitive]("string"),$t,_t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Tt)}st.from=function(Tt,$t,_t){return at(Tt,$t,_t)},Object.setPrototypeOf(st.prototype,Uint8Array.prototype),Object.setPrototypeOf(st,Uint8Array);function ct(Tt){if(typeof Tt!="number")throw new TypeError('"size" argument must be of type number');if(Tt<0)throw new RangeError('The value "'+Tt+'" is invalid for option "size"')}function lt(Tt,$t,_t){return ct(Tt),Tt<=0?it(Tt):$t!==void 0?typeof _t=="string"?it(Tt).fill($t,_t):it(Tt).fill($t):it(Tt)}st.alloc=function(Tt,$t,_t){return lt(Tt,$t,_t)};function dt(Tt){return ct(Tt),it(Tt<0?0:yt(Tt)|0)}st.allocUnsafe=function(Tt){return dt(Tt)},st.allocUnsafeSlow=function(Tt){return dt(Tt)};function ht(Tt,$t){if((typeof $t!="string"||$t==="")&&($t="utf8"),!st.isEncoding($t))throw new TypeError("Unknown encoding: "+$t);const _t=xt(Tt,$t)|0;let Dt=it(_t);const qt=Dt.write(Tt,$t);return qt!==_t&&(Dt=Dt.slice(0,qt)),Dt}function mt(Tt){const $t=Tt.length<0?0:yt(Tt.length)|0,_t=it($t);for(let Dt=0;Dt<$t;Dt+=1)_t[Dt]=Tt[Dt]&255;return _t}function ft(Tt){if(_r(Tt,Uint8Array)){const $t=new Uint8Array(Tt);return pt($t.buffer,$t.byteOffset,$t.byteLength)}return mt(Tt)}function pt(Tt,$t,_t){if($t<0||Tt.byteLength<$t)throw new RangeError('"offset" is outside of buffer bounds');if(Tt.byteLength<$t+(_t||0))throw new RangeError('"length" is outside of buffer bounds');let Dt;return $t===void 0&&_t===void 0?Dt=new Uint8Array(Tt):_t===void 0?Dt=new Uint8Array(Tt,$t):Dt=new Uint8Array(Tt,$t,_t),Object.setPrototypeOf(Dt,st.prototype),Dt}function gt(Tt){if(st.isBuffer(Tt)){const $t=yt(Tt.length)|0,_t=it($t);return _t.length===0||Tt.copy(_t,0,0,$t),_t}if(Tt.length!==void 0)return typeof Tt.length!="number"||Rr(Tt.length)?it(0):mt(Tt);if(Tt.type==="Buffer"&&Array.isArray(Tt.data))return mt(Tt.data)}function yt(Tt){if(Tt>=nt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt.toString(16)+" bytes");return Tt|0}function bt(Tt){return+Tt!=Tt&&(Tt=0),st.alloc(+Tt)}st.isBuffer=function($t){return $t!=null&&$t._isBuffer===!0&&$t!==st.prototype},st.compare=function($t,_t){if(_r($t,Uint8Array)&&($t=st.from($t,$t.offset,$t.byteLength)),_r(_t,Uint8Array)&&(_t=st.from(_t,_t.offset,_t.byteLength)),!st.isBuffer($t)||!st.isBuffer(_t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if($t===_t)return 0;let Dt=$t.length,qt=_t.length;for(let er=0,sr=Math.min(Dt,qt);erqt.length?(st.isBuffer(sr)||(sr=st.from(sr)),sr.copy(qt,er)):Uint8Array.prototype.set.call(qt,sr,er);else if(st.isBuffer(sr))sr.copy(qt,er);else throw new TypeError('"list" argument must be an Array of Buffers');er+=sr.length}return qt};function xt(Tt,$t){if(st.isBuffer(Tt))return Tt.length;if(ArrayBuffer.isView(Tt)||_r(Tt,ArrayBuffer))return Tt.byteLength;if(typeof Tt!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof Tt);const _t=Tt.length,Dt=arguments.length>2&&arguments[2]===!0;if(!Dt&&_t===0)return 0;let qt=!1;for(;;)switch($t){case"ascii":case"latin1":case"binary":return _t;case"utf8":case"utf-8":return cr(Tt).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _t*2;case"hex":return _t>>>1;case"base64":return gr(Tt).length;default:if(qt)return Dt?-1:cr(Tt).length;$t=(""+$t).toLowerCase(),qt=!0}}st.byteLength=xt;function vt(Tt,$t,_t){let Dt=!1;if(($t===void 0||$t<0)&&($t=0),$t>this.length||((_t===void 0||_t>this.length)&&(_t=this.length),_t<=0)||(_t>>>=0,$t>>>=0,_t<=$t))return"";for(Tt||(Tt="utf8");;)switch(Tt){case"hex":return Wt(this,$t,_t);case"utf8":case"utf-8":return Ft(this,$t,_t);case"ascii":return Vt(this,$t,_t);case"latin1":case"binary":return Bt(this,$t,_t);case"base64":return Yt(this,$t,_t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return jt(this,$t,_t);default:if(Dt)throw new TypeError("Unknown encoding: "+Tt);Tt=(Tt+"").toLowerCase(),Dt=!0}}st.prototype._isBuffer=!0;function Et(Tt,$t,_t){const Dt=Tt[$t];Tt[$t]=Tt[_t],Tt[_t]=Dt}st.prototype.swap16=function(){const $t=this.length;if($t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let _t=0;_t<$t;_t+=2)Et(this,_t,_t+1);return this},st.prototype.swap32=function(){const $t=this.length;if($t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let _t=0;_t<$t;_t+=4)Et(this,_t,_t+3),Et(this,_t+1,_t+2);return this},st.prototype.swap64=function(){const $t=this.length;if($t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let _t=0;_t<$t;_t+=8)Et(this,_t,_t+7),Et(this,_t+1,_t+6),Et(this,_t+2,_t+5),Et(this,_t+3,_t+4);return this},st.prototype.toString=function(){const $t=this.length;return $t===0?"":arguments.length===0?Ft(this,0,$t):vt.apply(this,arguments)},st.prototype.toLocaleString=st.prototype.toString,st.prototype.equals=function($t){if(!st.isBuffer($t))throw new TypeError("Argument must be a Buffer");return this===$t?!0:st.compare(this,$t)===0},st.prototype.inspect=function(){let $t="";const _t=et.INSPECT_MAX_BYTES;return $t=this.toString("hex",0,_t).replace(/(.{2})/g,"$1 ").trim(),this.length>_t&&($t+=" ... "),""},rt&&(st.prototype[rt]=st.prototype.inspect),st.prototype.compare=function($t,_t,Dt,qt,er){if(_r($t,Uint8Array)&&($t=st.from($t,$t.offset,$t.byteLength)),!st.isBuffer($t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof $t);if(_t===void 0&&(_t=0),Dt===void 0&&(Dt=$t?$t.length:0),qt===void 0&&(qt=0),er===void 0&&(er=this.length),_t<0||Dt>$t.length||qt<0||er>this.length)throw new RangeError("out of range index");if(qt>=er&&_t>=Dt)return 0;if(qt>=er)return-1;if(_t>=Dt)return 1;if(_t>>>=0,Dt>>>=0,qt>>>=0,er>>>=0,this===$t)return 0;let sr=er-qt,br=Dt-_t;const Ar=Math.min(sr,br),xr=this.slice(qt,er),Sr=$t.slice(_t,Dt);for(let vr=0;vr2147483647?_t=2147483647:_t<-2147483648&&(_t=-2147483648),_t=+_t,Rr(_t)&&(_t=qt?0:Tt.length-1),_t<0&&(_t=Tt.length+_t),_t>=Tt.length){if(qt)return-1;_t=Tt.length-1}else if(_t<0)if(qt)_t=0;else return-1;if(typeof $t=="string"&&($t=st.from($t,Dt)),st.isBuffer($t))return $t.length===0?-1:St(Tt,$t,_t,Dt,qt);if(typeof $t=="number")return $t=$t&255,typeof Uint8Array.prototype.indexOf=="function"?qt?Uint8Array.prototype.indexOf.call(Tt,$t,_t):Uint8Array.prototype.lastIndexOf.call(Tt,$t,_t):St(Tt,[$t],_t,Dt,qt);throw new TypeError("val must be string, number or Buffer")}function St(Tt,$t,_t,Dt,qt){let er=1,sr=Tt.length,br=$t.length;if(Dt!==void 0&&(Dt=String(Dt).toLowerCase(),Dt==="ucs2"||Dt==="ucs-2"||Dt==="utf16le"||Dt==="utf-16le")){if(Tt.length<2||$t.length<2)return-1;er=2,sr/=2,br/=2,_t/=2}function Ar(Sr,vr){return er===1?Sr[vr]:Sr.readUInt16BE(vr*er)}let xr;if(qt){let Sr=-1;for(xr=_t;xrsr&&(_t=sr-br),xr=_t;xr>=0;xr--){let Sr=!0;for(let vr=0;vrqt&&(Dt=qt)):Dt=qt;const er=$t.length;Dt>er/2&&(Dt=er/2);let sr;for(sr=0;sr>>0,isFinite(Dt)?(Dt=Dt>>>0,qt===void 0&&(qt="utf8")):(qt=Dt,Dt=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const er=this.length-_t;if((Dt===void 0||Dt>er)&&(Dt=er),$t.length>0&&(Dt<0||_t<0)||_t>this.length)throw new RangeError("Attempt to write outside buffer bounds");qt||(qt="utf8");let sr=!1;for(;;)switch(qt){case"hex":return At(this,$t,_t,Dt);case"utf8":case"utf-8":return kt(this,$t,_t,Dt);case"ascii":case"latin1":case"binary":return It(this,$t,_t,Dt);case"base64":return Ot(this,$t,_t,Dt);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Nt(this,$t,_t,Dt);default:if(sr)throw new TypeError("Unknown encoding: "+qt);qt=(""+qt).toLowerCase(),sr=!0}},st.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Yt(Tt,$t,_t){return $t===0&&_t===Tt.length?o.fromByteArray(Tt):o.fromByteArray(Tt.slice($t,_t))}function Ft(Tt,$t,_t){_t=Math.min(Tt.length,_t);const Dt=[];let qt=$t;for(;qt<_t;){const er=Tt[qt];let sr=null,br=er>239?4:er>223?3:er>191?2:1;if(qt+br<=_t){let Ar,xr,Sr,vr;switch(br){case 1:er<128&&(sr=er);break;case 2:Ar=Tt[qt+1],(Ar&192)===128&&(vr=(er&31)<<6|Ar&63,vr>127&&(sr=vr));break;case 3:Ar=Tt[qt+1],xr=Tt[qt+2],(Ar&192)===128&&(xr&192)===128&&(vr=(er&15)<<12|(Ar&63)<<6|xr&63,vr>2047&&(vr<55296||vr>57343)&&(sr=vr));break;case 4:Ar=Tt[qt+1],xr=Tt[qt+2],Sr=Tt[qt+3],(Ar&192)===128&&(xr&192)===128&&(Sr&192)===128&&(vr=(er&15)<<18|(Ar&63)<<12|(xr&63)<<6|Sr&63,vr>65535&&vr<1114112&&(sr=vr))}}sr===null?(sr=65533,br=1):sr>65535&&(sr-=65536,Dt.push(sr>>>10&1023|55296),sr=56320|sr&1023),Dt.push(sr),qt+=br}return Qt(Dt)}const Ht=4096;function Qt(Tt){const $t=Tt.length;if($t<=Ht)return String.fromCharCode.apply(String,Tt);let _t="",Dt=0;for(;Dt<$t;)_t+=String.fromCharCode.apply(String,Tt.slice(Dt,Dt+=Ht));return _t}function Vt(Tt,$t,_t){let Dt="";_t=Math.min(Tt.length,_t);for(let qt=$t;qt<_t;++qt)Dt+=String.fromCharCode(Tt[qt]&127);return Dt}function Bt(Tt,$t,_t){let Dt="";_t=Math.min(Tt.length,_t);for(let qt=$t;qt<_t;++qt)Dt+=String.fromCharCode(Tt[qt]);return Dt}function Wt(Tt,$t,_t){const Dt=Tt.length;(!$t||$t<0)&&($t=0),(!_t||_t<0||_t>Dt)&&(_t=Dt);let qt="";for(let er=$t;er<_t;++er)qt+=mr[Tt[er]];return qt}function jt(Tt,$t,_t){const Dt=Tt.slice($t,_t);let qt="";for(let er=0;erDt&&($t=Dt),_t<0?(_t+=Dt,_t<0&&(_t=0)):_t>Dt&&(_t=Dt),_t<$t&&(_t=$t);const qt=this.subarray($t,_t);return Object.setPrototypeOf(qt,st.prototype),qt};function Xt(Tt,$t,_t){if(Tt%1!==0||Tt<0)throw new RangeError("offset is not uint");if(Tt+$t>_t)throw new RangeError("Trying to access beyond buffer length")}st.prototype.readUintLE=st.prototype.readUIntLE=function($t,_t,Dt){$t=$t>>>0,_t=_t>>>0,Dt||Xt($t,_t,this.length);let qt=this[$t],er=1,sr=0;for(;++sr<_t&&(er*=256);)qt+=this[$t+sr]*er;return qt},st.prototype.readUintBE=st.prototype.readUIntBE=function($t,_t,Dt){$t=$t>>>0,_t=_t>>>0,Dt||Xt($t,_t,this.length);let qt=this[$t+--_t],er=1;for(;_t>0&&(er*=256);)qt+=this[$t+--_t]*er;return qt},st.prototype.readUint8=st.prototype.readUInt8=function($t,_t){return $t=$t>>>0,_t||Xt($t,1,this.length),this[$t]},st.prototype.readUint16LE=st.prototype.readUInt16LE=function($t,_t){return $t=$t>>>0,_t||Xt($t,2,this.length),this[$t]|this[$t+1]<<8},st.prototype.readUint16BE=st.prototype.readUInt16BE=function($t,_t){return $t=$t>>>0,_t||Xt($t,2,this.length),this[$t]<<8|this[$t+1]},st.prototype.readUint32LE=st.prototype.readUInt32LE=function($t,_t){return $t=$t>>>0,_t||Xt($t,4,this.length),(this[$t]|this[$t+1]<<8|this[$t+2]<<16)+this[$t+3]*16777216},st.prototype.readUint32BE=st.prototype.readUInt32BE=function($t,_t){return $t=$t>>>0,_t||Xt($t,4,this.length),this[$t]*16777216+(this[$t+1]<<16|this[$t+2]<<8|this[$t+3])},st.prototype.readBigUInt64LE=wr(function($t){$t=$t>>>0,Zt($t,"offset");const _t=this[$t],Dt=this[$t+7];(_t===void 0||Dt===void 0)&&nr($t,this.length-8);const qt=_t+this[++$t]*2**8+this[++$t]*2**16+this[++$t]*2**24,er=this[++$t]+this[++$t]*2**8+this[++$t]*2**16+Dt*2**24;return BigInt(qt)+(BigInt(er)<>>0,Zt($t,"offset");const _t=this[$t],Dt=this[$t+7];(_t===void 0||Dt===void 0)&&nr($t,this.length-8);const qt=_t*2**24+this[++$t]*2**16+this[++$t]*2**8+this[++$t],er=this[++$t]*2**24+this[++$t]*2**16+this[++$t]*2**8+Dt;return(BigInt(qt)<>>0,_t=_t>>>0,Dt||Xt($t,_t,this.length);let qt=this[$t],er=1,sr=0;for(;++sr<_t&&(er*=256);)qt+=this[$t+sr]*er;return er*=128,qt>=er&&(qt-=Math.pow(2,8*_t)),qt},st.prototype.readIntBE=function($t,_t,Dt){$t=$t>>>0,_t=_t>>>0,Dt||Xt($t,_t,this.length);let qt=_t,er=1,sr=this[$t+--qt];for(;qt>0&&(er*=256);)sr+=this[$t+--qt]*er;return er*=128,sr>=er&&(sr-=Math.pow(2,8*_t)),sr},st.prototype.readInt8=function($t,_t){return $t=$t>>>0,_t||Xt($t,1,this.length),this[$t]&128?(255-this[$t]+1)*-1:this[$t]},st.prototype.readInt16LE=function($t,_t){$t=$t>>>0,_t||Xt($t,2,this.length);const Dt=this[$t]|this[$t+1]<<8;return Dt&32768?Dt|4294901760:Dt},st.prototype.readInt16BE=function($t,_t){$t=$t>>>0,_t||Xt($t,2,this.length);const Dt=this[$t+1]|this[$t]<<8;return Dt&32768?Dt|4294901760:Dt},st.prototype.readInt32LE=function($t,_t){return $t=$t>>>0,_t||Xt($t,4,this.length),this[$t]|this[$t+1]<<8|this[$t+2]<<16|this[$t+3]<<24},st.prototype.readInt32BE=function($t,_t){return $t=$t>>>0,_t||Xt($t,4,this.length),this[$t]<<24|this[$t+1]<<16|this[$t+2]<<8|this[$t+3]},st.prototype.readBigInt64LE=wr(function($t){$t=$t>>>0,Zt($t,"offset");const _t=this[$t],Dt=this[$t+7];(_t===void 0||Dt===void 0)&&nr($t,this.length-8);const qt=this[$t+4]+this[$t+5]*2**8+this[$t+6]*2**16+(Dt<<24);return(BigInt(qt)<>>0,Zt($t,"offset");const _t=this[$t],Dt=this[$t+7];(_t===void 0||Dt===void 0)&&nr($t,this.length-8);const qt=(_t<<24)+this[++$t]*2**16+this[++$t]*2**8+this[++$t];return(BigInt(qt)<>>0,_t||Xt($t,4,this.length),tt.read(this,$t,!0,23,4)},st.prototype.readFloatBE=function($t,_t){return $t=$t>>>0,_t||Xt($t,4,this.length),tt.read(this,$t,!1,23,4)},st.prototype.readDoubleLE=function($t,_t){return $t=$t>>>0,_t||Xt($t,8,this.length),tt.read(this,$t,!0,52,8)},st.prototype.readDoubleBE=function($t,_t){return $t=$t>>>0,_t||Xt($t,8,this.length),tt.read(this,$t,!1,52,8)};function Kt(Tt,$t,_t,Dt,qt,er){if(!st.isBuffer(Tt))throw new TypeError('"buffer" argument must be a Buffer instance');if($t>qt||$tTt.length)throw new RangeError("Index out of range")}st.prototype.writeUintLE=st.prototype.writeUIntLE=function($t,_t,Dt,qt){if($t=+$t,_t=_t>>>0,Dt=Dt>>>0,!qt){const br=Math.pow(2,8*Dt)-1;Kt(this,$t,_t,Dt,br,0)}let er=1,sr=0;for(this[_t]=$t&255;++sr>>0,Dt=Dt>>>0,!qt){const br=Math.pow(2,8*Dt)-1;Kt(this,$t,_t,Dt,br,0)}let er=Dt-1,sr=1;for(this[_t+er]=$t&255;--er>=0&&(sr*=256);)this[_t+er]=$t/sr&255;return _t+Dt},st.prototype.writeUint8=st.prototype.writeUInt8=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,1,255,0),this[_t]=$t&255,_t+1},st.prototype.writeUint16LE=st.prototype.writeUInt16LE=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,2,65535,0),this[_t]=$t&255,this[_t+1]=$t>>>8,_t+2},st.prototype.writeUint16BE=st.prototype.writeUInt16BE=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,2,65535,0),this[_t]=$t>>>8,this[_t+1]=$t&255,_t+2},st.prototype.writeUint32LE=st.prototype.writeUInt32LE=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,4,4294967295,0),this[_t+3]=$t>>>24,this[_t+2]=$t>>>16,this[_t+1]=$t>>>8,this[_t]=$t&255,_t+4},st.prototype.writeUint32BE=st.prototype.writeUInt32BE=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,4,4294967295,0),this[_t]=$t>>>24,this[_t+1]=$t>>>16,this[_t+2]=$t>>>8,this[_t+3]=$t&255,_t+4};function Pt(Tt,$t,_t,Dt,qt){Ut($t,Dt,qt,Tt,_t,7);let er=Number($t&BigInt(4294967295));Tt[_t++]=er,er=er>>8,Tt[_t++]=er,er=er>>8,Tt[_t++]=er,er=er>>8,Tt[_t++]=er;let sr=Number($t>>BigInt(32)&BigInt(4294967295));return Tt[_t++]=sr,sr=sr>>8,Tt[_t++]=sr,sr=sr>>8,Tt[_t++]=sr,sr=sr>>8,Tt[_t++]=sr,_t}function Gt(Tt,$t,_t,Dt,qt){Ut($t,Dt,qt,Tt,_t,7);let er=Number($t&BigInt(4294967295));Tt[_t+7]=er,er=er>>8,Tt[_t+6]=er,er=er>>8,Tt[_t+5]=er,er=er>>8,Tt[_t+4]=er;let sr=Number($t>>BigInt(32)&BigInt(4294967295));return Tt[_t+3]=sr,sr=sr>>8,Tt[_t+2]=sr,sr=sr>>8,Tt[_t+1]=sr,sr=sr>>8,Tt[_t]=sr,_t+8}st.prototype.writeBigUInt64LE=wr(function($t,_t=0){return Pt(this,$t,_t,BigInt(0),BigInt("0xffffffffffffffff"))}),st.prototype.writeBigUInt64BE=wr(function($t,_t=0){return Gt(this,$t,_t,BigInt(0),BigInt("0xffffffffffffffff"))}),st.prototype.writeIntLE=function($t,_t,Dt,qt){if($t=+$t,_t=_t>>>0,!qt){const Ar=Math.pow(2,8*Dt-1);Kt(this,$t,_t,Dt,Ar-1,-Ar)}let er=0,sr=1,br=0;for(this[_t]=$t&255;++er>0)-br&255;return _t+Dt},st.prototype.writeIntBE=function($t,_t,Dt,qt){if($t=+$t,_t=_t>>>0,!qt){const Ar=Math.pow(2,8*Dt-1);Kt(this,$t,_t,Dt,Ar-1,-Ar)}let er=Dt-1,sr=1,br=0;for(this[_t+er]=$t&255;--er>=0&&(sr*=256);)$t<0&&br===0&&this[_t+er+1]!==0&&(br=1),this[_t+er]=($t/sr>>0)-br&255;return _t+Dt},st.prototype.writeInt8=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,1,127,-128),$t<0&&($t=255+$t+1),this[_t]=$t&255,_t+1},st.prototype.writeInt16LE=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,2,32767,-32768),this[_t]=$t&255,this[_t+1]=$t>>>8,_t+2},st.prototype.writeInt16BE=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,2,32767,-32768),this[_t]=$t>>>8,this[_t+1]=$t&255,_t+2},st.prototype.writeInt32LE=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,4,2147483647,-2147483648),this[_t]=$t&255,this[_t+1]=$t>>>8,this[_t+2]=$t>>>16,this[_t+3]=$t>>>24,_t+4},st.prototype.writeInt32BE=function($t,_t,Dt){return $t=+$t,_t=_t>>>0,Dt||Kt(this,$t,_t,4,2147483647,-2147483648),$t<0&&($t=4294967295+$t+1),this[_t]=$t>>>24,this[_t+1]=$t>>>16,this[_t+2]=$t>>>8,this[_t+3]=$t&255,_t+4},st.prototype.writeBigInt64LE=wr(function($t,_t=0){return Pt(this,$t,_t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),st.prototype.writeBigInt64BE=wr(function($t,_t=0){return Gt(this,$t,_t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function tr(Tt,$t,_t,Dt,qt,er){if(_t+Dt>Tt.length)throw new RangeError("Index out of range");if(_t<0)throw new RangeError("Index out of range")}function zt(Tt,$t,_t,Dt,qt){return $t=+$t,_t=_t>>>0,qt||tr(Tt,$t,_t,4),tt.write(Tt,$t,_t,Dt,23,4),_t+4}st.prototype.writeFloatLE=function($t,_t,Dt){return zt(this,$t,_t,!0,Dt)},st.prototype.writeFloatBE=function($t,_t,Dt){return zt(this,$t,_t,!1,Dt)};function lr(Tt,$t,_t,Dt,qt){return $t=+$t,_t=_t>>>0,qt||tr(Tt,$t,_t,8),tt.write(Tt,$t,_t,Dt,52,8),_t+8}st.prototype.writeDoubleLE=function($t,_t,Dt){return lr(this,$t,_t,!0,Dt)},st.prototype.writeDoubleBE=function($t,_t,Dt){return lr(this,$t,_t,!1,Dt)},st.prototype.copy=function($t,_t,Dt,qt){if(!st.isBuffer($t))throw new TypeError("argument should be a Buffer");if(Dt||(Dt=0),!qt&&qt!==0&&(qt=this.length),_t>=$t.length&&(_t=$t.length),_t||(_t=0),qt>0&&qt=this.length)throw new RangeError("Index out of range");if(qt<0)throw new RangeError("sourceEnd out of bounds");qt>this.length&&(qt=this.length),$t.length-_t>>0,Dt=Dt===void 0?this.length:Dt>>>0,$t||($t=0);let er;if(typeof $t=="number")for(er=_t;er2**32?qt=Rt(String(_t)):typeof _t=="bigint"&&(qt=String(_t),(_t>BigInt(2)**BigInt(32)||_t<-(BigInt(2)**BigInt(32)))&&(qt=Rt(qt)),qt+="n"),Dt+=` It must be ${$t}. Received ${qt}`,Dt},RangeError);function Rt(Tt){let $t="",_t=Tt.length;const Dt=Tt[0]==="-"?1:0;for(;_t>=Dt+4;_t-=3)$t=`_${Tt.slice(_t-3,_t)}${$t}`;return`${Tt.slice(0,_t)}${$t}`}function Mt(Tt,$t,_t){Zt($t,"offset"),(Tt[$t]===void 0||Tt[$t+_t]===void 0)&&nr($t,Tt.length-(_t+1))}function Ut(Tt,$t,_t,Dt,qt,er){if(Tt>_t||Tt<$t){const sr=typeof $t=="bigint"?"n":"";let br;throw $t===0||$t===BigInt(0)?br=`>= 0${sr} and < 2${sr} ** ${(er+1)*8}${sr}`:br=`>= -(2${sr} ** ${(er+1)*8-1}${sr}) and < 2 ** ${(er+1)*8-1}${sr}`,new rr.ERR_OUT_OF_RANGE("value",br,Tt)}Mt(Dt,qt,er)}function Zt(Tt,$t){if(typeof Tt!="number")throw new rr.ERR_INVALID_ARG_TYPE($t,"number",Tt)}function nr(Tt,$t,_t){throw Math.floor(Tt)!==Tt?(Zt(Tt,_t),new rr.ERR_OUT_OF_RANGE("offset","an integer",Tt)):$t<0?new rr.ERR_BUFFER_OUT_OF_BOUNDS:new rr.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${$t}`,Tt)}const ar=/[^+/0-9A-Za-z-_]/g;function dr(Tt){if(Tt=Tt.split("=")[0],Tt=Tt.trim().replace(ar,""),Tt.length<2)return"";for(;Tt.length%4!==0;)Tt=Tt+"=";return Tt}function cr(Tt,$t){$t=$t||1/0;let _t;const Dt=Tt.length;let qt=null;const er=[];for(let sr=0;sr55295&&_t<57344){if(!qt){if(_t>56319){($t-=3)>-1&&er.push(239,191,189);continue}else if(sr+1===Dt){($t-=3)>-1&&er.push(239,191,189);continue}qt=_t;continue}if(_t<56320){($t-=3)>-1&&er.push(239,191,189),qt=_t;continue}_t=(qt-55296<<10|_t-56320)+65536}else qt&&($t-=3)>-1&&er.push(239,191,189);if(qt=null,_t<128){if(($t-=1)<0)break;er.push(_t)}else if(_t<2048){if(($t-=2)<0)break;er.push(_t>>6|192,_t&63|128)}else if(_t<65536){if(($t-=3)<0)break;er.push(_t>>12|224,_t>>6&63|128,_t&63|128)}else if(_t<1114112){if(($t-=4)<0)break;er.push(_t>>18|240,_t>>12&63|128,_t>>6&63|128,_t&63|128)}else throw new Error("Invalid code point")}return er}function yr(Tt){const $t=[];for(let _t=0;_t>8,qt=_t%256,er.push(qt),er.push(Dt);return er}function gr(Tt){return o.toByteArray(dr(Tt))}function Pr(Tt,$t,_t,Dt){let qt;for(qt=0;qt=$t.length||qt>=Tt.length);++qt)$t[qt+_t]=Tt[qt];return qt}function _r(Tt,$t){return Tt instanceof $t||Tt!=null&&Tt.constructor!=null&&Tt.constructor.name!=null&&Tt.constructor.name===$t.name}function Rr(Tt){return Tt!==Tt}const mr=function(){const Tt="0123456789abcdef",$t=new Array(256);for(let _t=0;_t<16;++_t){const Dt=_t*16;for(let qt=0;qt<16;++qt)$t[Dt+qt]=Tt[_t]+Tt[qt]}return $t}();function wr(Tt){return typeof BigInt>"u"?ir:Tt}function ir(){throw new Error("BigInt not supported")}})(buffer);var extendStatics=function(et,o){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(tt,rt){tt.__proto__=rt}||function(tt,rt){for(var nt in rt)Object.prototype.hasOwnProperty.call(rt,nt)&&(tt[nt]=rt[nt])},extendStatics(et,o)};function __extends(et,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");extendStatics(et,o);function tt(){this.constructor=et}et.prototype=o===null?Object.create(o):(tt.prototype=o.prototype,new tt)}var __assign=function(){return __assign=Object.assign||function(o){for(var tt,rt=1,nt=arguments.length;rt=0;st--)(it=et[st])&&(ot=(nt<3?it(ot):nt>3?it(o,tt,ot):it(o,tt))||ot);return nt>3&&ot&&Object.defineProperty(o,tt,ot),ot}function __param(et,o){return function(tt,rt){o(tt,rt,et)}}function __esDecorate(et,o,tt,rt,nt,ot){function it(yt){if(yt!==void 0&&typeof yt!="function")throw new TypeError("Function expected");return yt}for(var st=rt.kind,at=st==="getter"?"get":st==="setter"?"set":"value",ct=!o&&et?rt.static?et:et.prototype:null,lt=o||(ct?Object.getOwnPropertyDescriptor(ct,rt.name):{}),dt,ht=!1,mt=tt.length-1;mt>=0;mt--){var ft={};for(var pt in rt)ft[pt]=pt==="access"?{}:rt[pt];for(var pt in rt.access)ft.access[pt]=rt.access[pt];ft.addInitializer=function(yt){if(ht)throw new TypeError("Cannot add initializers after decoration has completed");ot.push(it(yt||null))};var gt=(0,tt[mt])(st==="accessor"?{get:lt.get,set:lt.set}:lt[at],ft);if(st==="accessor"){if(gt===void 0)continue;if(gt===null||typeof gt!="object")throw new TypeError("Object expected");(dt=it(gt.get))&&(lt.get=dt),(dt=it(gt.set))&&(lt.set=dt),(dt=it(gt.init))&&nt.unshift(dt)}else(dt=it(gt))&&(st==="field"?nt.unshift(dt):lt[at]=dt)}ct&&Object.defineProperty(ct,rt.name,lt),ht=!0}function __runInitializers(et,o,tt){for(var rt=arguments.length>2,nt=0;nt0&&ot[ot.length-1])&&(ct[0]===6||ct[0]===2)){tt=0;continue}if(ct[0]===3&&(!ot||ct[1]>ot[0]&&ct[1]=et.length&&(et=void 0),{value:et&&et[rt++],done:!et}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(et,o){var tt=typeof Symbol=="function"&&et[Symbol.iterator];if(!tt)return et;var rt=tt.call(et),nt,ot=[],it;try{for(;(o===void 0||o-- >0)&&!(nt=rt.next()).done;)ot.push(nt.value)}catch(st){it={error:st}}finally{try{nt&&!nt.done&&(tt=rt.return)&&tt.call(rt)}finally{if(it)throw it.error}}return ot}function __spread(){for(var et=[],o=0;o1||at(mt,pt)})},ft&&(nt[mt]=ft(nt[mt])))}function at(mt,ft){try{ct(rt[mt](ft))}catch(pt){ht(ot[0][3],pt)}}function ct(mt){mt.value instanceof __await?Promise.resolve(mt.value.v).then(lt,dt):ht(ot[0][2],mt)}function lt(mt){at("next",mt)}function dt(mt){at("throw",mt)}function ht(mt,ft){mt(ft),ot.shift(),ot.length&&at(ot[0][0],ot[0][1])}}function __asyncDelegator(et){var o,tt;return o={},rt("next"),rt("throw",function(nt){throw nt}),rt("return"),o[Symbol.iterator]=function(){return this},o;function rt(nt,ot){o[nt]=et[nt]?function(it){return(tt=!tt)?{value:__await(et[nt](it)),done:!1}:ot?ot(it):it}:ot}}function __asyncValues(et){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=et[Symbol.asyncIterator],tt;return o?o.call(et):(et=typeof __values=="function"?__values(et):et[Symbol.iterator](),tt={},rt("next"),rt("throw"),rt("return"),tt[Symbol.asyncIterator]=function(){return this},tt);function rt(ot){tt[ot]=et[ot]&&function(it){return new Promise(function(st,at){it=et[ot](it),nt(st,at,it.done,it.value)})}}function nt(ot,it,st,at){Promise.resolve(at).then(function(ct){ot({value:ct,done:st})},it)}}function __makeTemplateObject(et,o){return Object.defineProperty?Object.defineProperty(et,"raw",{value:o}):et.raw=o,et}var __setModuleDefault=Object.create?function(et,o){Object.defineProperty(et,"default",{enumerable:!0,value:o})}:function(et,o){et.default=o};function __importStar(et){if(et&&et.__esModule)return et;var o={};if(et!=null)for(var tt in et)tt!=="default"&&Object.prototype.hasOwnProperty.call(et,tt)&&__createBinding(o,et,tt);return __setModuleDefault(o,et),o}function __importDefault$1(et){return et&&et.__esModule?et:{default:et}}function __classPrivateFieldGet$1(et,o,tt,rt){if(tt==="a"&&!rt)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?et!==o||!rt:!o.has(et))throw new TypeError("Cannot read private member from an object whose class did not declare it");return tt==="m"?rt:tt==="a"?rt.call(et):rt?rt.value:o.get(et)}function __classPrivateFieldSet$1(et,o,tt,rt,nt){if(rt==="m")throw new TypeError("Private method is not writable");if(rt==="a"&&!nt)throw new TypeError("Private accessor was defined without a setter");if(typeof o=="function"?et!==o||!nt:!o.has(et))throw new TypeError("Cannot write private member to an object whose class did not declare it");return rt==="a"?nt.call(et,tt):nt?nt.value=tt:o.set(et,tt),tt}function __classPrivateFieldIn(et,o){if(o===null||typeof o!="object"&&typeof o!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof et=="function"?o===et:et.has(o)}function __addDisposableResource(et,o,tt){if(o!=null){if(typeof o!="object"&&typeof o!="function")throw new TypeError("Object expected.");var rt,nt;if(tt){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");rt=o[Symbol.asyncDispose]}if(rt===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");rt=o[Symbol.dispose],tt&&(nt=rt)}if(typeof rt!="function")throw new TypeError("Object not disposable.");nt&&(rt=function(){try{nt.call(this)}catch(ot){return Promise.reject(ot)}}),et.stack.push({value:o,dispose:rt,async:tt})}else tt&&et.stack.push({async:!0});return o}var _SuppressedError=typeof SuppressedError=="function"?SuppressedError:function(et,o,tt){var rt=new Error(tt);return rt.name="SuppressedError",rt.error=et,rt.suppressed=o,rt};function __disposeResources(et){function o(ot){et.error=et.hasError?new _SuppressedError(ot,et.error,"An error was suppressed during disposal."):ot,et.hasError=!0}var tt,rt=0;function nt(){for(;tt=et.stack.pop();)try{if(!tt.async&&rt===1)return rt=0,et.stack.push(tt),Promise.resolve().then(nt);if(tt.dispose){var ot=tt.dispose.call(tt.value);if(tt.async)return rt|=2,Promise.resolve(ot).then(nt,function(it){return o(it),nt()})}else rt|=1}catch(it){o(it)}if(rt===1)return et.hasError?Promise.reject(et.error):Promise.resolve();if(et.hasError)throw et.error}return nt()}function __rewriteRelativeImportExtension(et,o){return typeof et=="string"&&/^\.\.?\//.test(et)?et.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(tt,rt,nt,ot,it){return rt?o?".jsx":".js":nt&&(!ot||!it)?tt:nt+ot+"."+it.toLowerCase()+"js"}):et}const tslib_es6={__extends,__assign,__rest,__decorate,__param,__esDecorate,__runInitializers,__propKey,__setFunctionName,__metadata,__awaiter,__generator,__createBinding,__exportStar,__values,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar,__importDefault:__importDefault$1,__classPrivateFieldGet:__classPrivateFieldGet$1,__classPrivateFieldSet:__classPrivateFieldSet$1,__classPrivateFieldIn,__addDisposableResource,__disposeResources,__rewriteRelativeImportExtension},tslib_es6$1=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource,get __assign(){return __assign},__asyncDelegator,__asyncGenerator,__asyncValues,__await,__awaiter,__classPrivateFieldGet:__classPrivateFieldGet$1,__classPrivateFieldIn,__classPrivateFieldSet:__classPrivateFieldSet$1,__createBinding,__decorate,__disposeResources,__esDecorate,__exportStar,__extends,__generator,__importDefault:__importDefault$1,__importStar,__makeTemplateObject,__metadata,__param,__propKey,__read,__rest,__rewriteRelativeImportExtension,__runInitializers,__setFunctionName,__spread,__spreadArray,__spreadArrays,__values,default:tslib_es6},Symbol.toStringTag,{value:"Module"}));var define_process_env_default$2={},defaultEnvironment="production",env$2=typeof process>"u"||define_process_env_default$2===void 0?defaultEnvironment:"production",createDefinition=function(et){return{isEnabled:function(o){return et.some(function(tt){return!!o[tt]})}}},featureDefinitions={measureLayout:createDefinition(["layout","layoutId","drag"]),animation:createDefinition(["animate","exit","variants","whileHover","whileTap","whileFocus","whileDrag","whileInView"]),exit:createDefinition(["exit"]),drag:createDefinition(["drag","dragControls"]),focus:createDefinition(["whileFocus"]),hover:createDefinition(["whileHover","onHoverStart","onHoverEnd"]),tap:createDefinition(["whileTap","onTap","onTapStart","onTapCancel"]),pan:createDefinition(["onPan","onPanStart","onPanSessionStart","onPanEnd"]),inView:createDefinition(["whileInView","onViewportEnter","onViewportLeave"])};function loadFeatures(et){for(var o in et)et[o]!==null&&(o==="projectionNodeConstructor"?featureDefinitions.projectionNodeConstructor=et[o]:featureDefinitions[o].Component=et[o])}var invariant$1=function(){},LazyContext=reactExports.createContext({strict:!1}),featureNames=Object.keys(featureDefinitions),numFeatures=featureNames.length;function useFeatures(et,o,tt){var rt=[],nt=reactExports.useContext(LazyContext);if(!o)return null;env$2!=="production"&&tt&&nt.strict;for(var ot=0;ot"u")return o;var tt=new Map;return new Proxy(o,{get:function(rt,nt){return tt.has(nt)||tt.set(nt,o(nt)),tt.get(nt)}})}var lowercaseSVGElements=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","svg","switch","symbol","text","tspan","use","view"];function isSVGComponent(et){return typeof et!="string"||et.includes("-")?!1:!!(lowercaseSVGElements.indexOf(et)>-1||/[A-Z]/.test(et))}var scaleCorrectors={};function addScaleCorrector(et){Object.assign(scaleCorrectors,et)}var transformAxes=["","X","Y","Z"],order$1=["translate","scale","rotate","skew"],transformProps=["transformPerspective","x","y","z"];order$1.forEach(function(et){return transformAxes.forEach(function(o){return transformProps.push(et+o)})});function sortTransformProps(et,o){return transformProps.indexOf(et)-transformProps.indexOf(o)}var transformPropSet=new Set(transformProps);function isTransformProp(et){return transformPropSet.has(et)}var transformOriginProps=new Set(["originX","originY","originZ"]);function isTransformOriginProp(et){return transformOriginProps.has(et)}function isForcedMotionValue(et,o){var tt=o.layout,rt=o.layoutId;return isTransformProp(et)||isTransformOriginProp(et)||(tt||rt!==void 0)&&(!!scaleCorrectors[et]||et==="opacity")}var isMotionValue=function(et){return!!(et!==null&&typeof et=="object"&&et.getVelocity)},translateAlias={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"};function buildTransform(et,o,tt,rt){var nt=et.transform,ot=et.transformKeys,it=o.enableHardwareAcceleration,st=it===void 0?!0:it,at=o.allowTransformNone,ct=at===void 0?!0:at,lt="";ot.sort(sortTransformProps);for(var dt=!1,ht=ot.length,mt=0;mttt=>Math.max(Math.min(tt,o),et),sanitize=et=>et%1?Number(et.toFixed(5)):et,floatRegex=/(-)?([\d]*\.?[\d])+/g,colorRegex=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,singleColorRegex=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function isString(et){return typeof et=="string"}const number$3={test:et=>typeof et=="number",parse:parseFloat,transform:et=>et},alpha=Object.assign(Object.assign({},number$3),{transform:clamp$2(0,1)}),scale=Object.assign(Object.assign({},number$3),{default:1}),createUnitType=et=>({test:o=>isString(o)&&o.endsWith(et)&&o.split(" ").length===1,parse:parseFloat,transform:o=>`${o}${et}`}),degrees=createUnitType("deg"),percent=createUnitType("%"),px=createUnitType("px"),vh=createUnitType("vh"),vw=createUnitType("vw"),progressPercentage=Object.assign(Object.assign({},percent),{parse:et=>percent.parse(et)/100,transform:et=>percent.transform(et*100)}),isColorString=(et,o)=>tt=>!!(isString(tt)&&singleColorRegex.test(tt)&&tt.startsWith(et)||o&&Object.prototype.hasOwnProperty.call(tt,o)),splitColor=(et,o,tt)=>rt=>{if(!isString(rt))return rt;const[nt,ot,it,st]=rt.match(floatRegex);return{[et]:parseFloat(nt),[o]:parseFloat(ot),[tt]:parseFloat(it),alpha:st!==void 0?parseFloat(st):1}},hsla={test:isColorString("hsl","hue"),parse:splitColor("hue","saturation","lightness"),transform:({hue:et,saturation:o,lightness:tt,alpha:rt=1})=>"hsla("+Math.round(et)+", "+percent.transform(sanitize(o))+", "+percent.transform(sanitize(tt))+", "+sanitize(alpha.transform(rt))+")"},clampRgbUnit=clamp$2(0,255),rgbUnit=Object.assign(Object.assign({},number$3),{transform:et=>Math.round(clampRgbUnit(et))}),rgba={test:isColorString("rgb","red"),parse:splitColor("red","green","blue"),transform:({red:et,green:o,blue:tt,alpha:rt=1})=>"rgba("+rgbUnit.transform(et)+", "+rgbUnit.transform(o)+", "+rgbUnit.transform(tt)+", "+sanitize(alpha.transform(rt))+")"};function parseHex(et){let o="",tt="",rt="",nt="";return et.length>5?(o=et.substr(1,2),tt=et.substr(3,2),rt=et.substr(5,2),nt=et.substr(7,2)):(o=et.substr(1,1),tt=et.substr(2,1),rt=et.substr(3,1),nt=et.substr(4,1),o+=o,tt+=tt,rt+=rt,nt+=nt),{red:parseInt(o,16),green:parseInt(tt,16),blue:parseInt(rt,16),alpha:nt?parseInt(nt,16)/255:1}}const hex={test:isColorString("#"),parse:parseHex,transform:rgba.transform},color$1={test:et=>rgba.test(et)||hex.test(et)||hsla.test(et),parse:et=>rgba.test(et)?rgba.parse(et):hsla.test(et)?hsla.parse(et):hex.parse(et),transform:et=>isString(et)?et:et.hasOwnProperty("red")?rgba.transform(et):hsla.transform(et)},colorToken="${c}",numberToken="${n}";function test(et){var o,tt,rt,nt;return isNaN(et)&&isString(et)&&((tt=(o=et.match(floatRegex))===null||o===void 0?void 0:o.length)!==null&&tt!==void 0?tt:0)+((nt=(rt=et.match(colorRegex))===null||rt===void 0?void 0:rt.length)!==null&&nt!==void 0?nt:0)>0}function analyse$1(et){typeof et=="number"&&(et=`${et}`);const o=[];let tt=0;const rt=et.match(colorRegex);rt&&(tt=rt.length,et=et.replace(colorRegex,colorToken),o.push(...rt.map(color$1.parse)));const nt=et.match(floatRegex);return nt&&(et=et.replace(floatRegex,numberToken),o.push(...nt.map(number$3.parse))),{values:o,numColors:tt,tokenised:et}}function parse$4(et){return analyse$1(et).values}function createTransformer(et){const{values:o,numColors:tt,tokenised:rt}=analyse$1(et),nt=o.length;return ot=>{let it=rt;for(let st=0;sttypeof et=="number"?0:et;function getAnimatableNone$1(et){const o=parse$4(et);return createTransformer(et)(o.map(convertNumbersToZero))}const complex={test,parse:parse$4,createTransformer,getAnimatableNone:getAnimatableNone$1},maxDefaults=new Set(["brightness","contrast","saturate","opacity"]);function applyDefaultFilter(et){let[o,tt]=et.slice(0,-1).split("(");if(o==="drop-shadow")return et;const[rt]=tt.match(floatRegex)||[];if(!rt)return et;const nt=tt.replace(rt,"");let ot=maxDefaults.has(o)?1:0;return rt!==tt&&(ot*=100),o+"("+ot+nt+")"}const functionRegex=/([a-z-]*)\(.*?\)/g,filter$1=Object.assign(Object.assign({},complex),{getAnimatableNone:et=>{const o=et.match(functionRegex);return o?o.map(applyDefaultFilter).join(" "):et}});var int=__assign(__assign({},number$3),{transform:Math.round}),numberValueTypes={borderWidth:px,borderTopWidth:px,borderRightWidth:px,borderBottomWidth:px,borderLeftWidth:px,borderRadius:px,radius:px,borderTopLeftRadius:px,borderTopRightRadius:px,borderBottomRightRadius:px,borderBottomLeftRadius:px,width:px,maxWidth:px,height:px,maxHeight:px,size:px,top:px,right:px,bottom:px,left:px,padding:px,paddingTop:px,paddingRight:px,paddingBottom:px,paddingLeft:px,margin:px,marginTop:px,marginRight:px,marginBottom:px,marginLeft:px,rotate:degrees,rotateX:degrees,rotateY:degrees,rotateZ:degrees,scale,scaleX:scale,scaleY:scale,scaleZ:scale,skew:degrees,skewX:degrees,skewY:degrees,distance:px,translateX:px,translateY:px,translateZ:px,x:px,y:px,z:px,perspective:px,transformPerspective:px,opacity:alpha,originX:progressPercentage,originY:progressPercentage,originZ:px,zIndex:int,fillOpacity:alpha,strokeOpacity:alpha,numOctaves:int};function buildHTMLStyles(et,o,tt,rt){var nt,ot=et.style,it=et.vars,st=et.transform,at=et.transformKeys,ct=et.transformOrigin;at.length=0;var lt=!1,dt=!1,ht=!0;for(var mt in o){var ft=o[mt];if(isCSSVariable$1(mt)){it[mt]=ft;continue}var pt=numberValueTypes[mt],gt=getValueAsType(ft,pt);if(isTransformProp(mt)){if(lt=!0,st[mt]=gt,at.push(mt),!ht)continue;ft!==((nt=pt.default)!==null&&nt!==void 0?nt:0)&&(ht=!1)}else isTransformOriginProp(mt)?(ct[mt]=gt,dt=!0):ot[mt]=gt}lt?ot.transform=buildTransform(et,tt,ht,rt):rt?ot.transform=rt({},""):!o.transform&&ot.transform&&(ot.transform="none"),dt&&(ot.transformOrigin=buildTransformOrigin(ct))}var createHtmlRenderState=function(){return{style:{},transform:{},transformKeys:[],transformOrigin:{},vars:{}}};function copyRawValuesOnly(et,o,tt){for(var rt in o)!isMotionValue(o[rt])&&!isForcedMotionValue(rt,tt)&&(et[rt]=o[rt])}function useInitialMotionValues(et,o,tt){var rt=et.transformTemplate;return reactExports.useMemo(function(){var nt=createHtmlRenderState();buildHTMLStyles(nt,o,{enableHardwareAcceleration:!tt},rt);var ot=nt.vars,it=nt.style;return __assign(__assign({},ot),it)},[o])}function useStyle(et,o,tt){var rt=et.style||{},nt={};return copyRawValuesOnly(nt,rt,et),Object.assign(nt,useInitialMotionValues(et,o,tt)),et.transformValues&&(nt=et.transformValues(nt)),nt}function useHTMLProps(et,o,tt){var rt={},nt=useStyle(et,o,tt);return et.drag&&et.dragListener!==!1&&(rt.draggable=!1,nt.userSelect=nt.WebkitUserSelect=nt.WebkitTouchCallout="none",nt.touchAction=et.drag===!0?"none":"pan-".concat(et.drag==="x"?"y":"x")),rt.style=nt,rt}var validMotionProps=new Set(["initial","animate","exit","style","variants","transition","transformTemplate","transformValues","custom","inherit","layout","layoutId","layoutDependency","onLayoutAnimationStart","onLayoutAnimationComplete","onLayoutMeasure","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","drag","dragControls","dragListener","dragConstraints","dragDirectionLock","dragSnapToOrigin","_dragX","_dragY","dragElastic","dragMomentum","dragPropagation","dragTransition","whileDrag","onPan","onPanStart","onPanEnd","onPanSessionStart","onTap","onTapStart","onTapCancel","onHoverStart","onHoverEnd","whileFocus","whileTap","whileHover","whileInView","onViewportEnter","onViewportLeave","viewport","layoutScroll"]);function isValidMotionProp(et){return validMotionProps.has(et)}var shouldForward=function(et){return!isValidMotionProp(et)};function loadExternalIsValidProp(et){et&&(shouldForward=function(o){return o.startsWith("on")?!isValidMotionProp(o):et(o)})}try{loadExternalIsValidProp(require("@emotion/is-prop-valid").default)}catch{}function filterProps(et,o,tt){var rt={};for(var nt in et)(shouldForward(nt)||tt===!0&&isValidMotionProp(nt)||!o&&!isValidMotionProp(nt)||et.draggable&&nt.startsWith("onDrag"))&&(rt[nt]=et[nt]);return rt}function calcOrigin$1(et,o,tt){return typeof et=="string"?et:px.transform(o+tt*et)}function calcSVGTransformOrigin(et,o,tt){var rt=calcOrigin$1(o,et.x,et.width),nt=calcOrigin$1(tt,et.y,et.height);return"".concat(rt," ").concat(nt)}var camelKeys={offset:"strokeDashoffset",array:"strokeDasharray"};function buildSVGPath(et,o,tt,rt,nt){tt===void 0&&(tt=1),rt===void 0&&(rt=0),et.pathLength=1;var ot=camelKeys;et[ot.offset]=px.transform(-rt);var it=px.transform(o),st=px.transform(tt);et[ot.array]="".concat(it," ").concat(st)}function buildSVGAttrs(et,o,tt,rt){var nt=o.attrX,ot=o.attrY,it=o.originX,st=o.originY,at=o.pathLength,ct=o.pathSpacing,lt=ct===void 0?1:ct,dt=o.pathOffset,ht=dt===void 0?0:dt,mt=__rest(o,["attrX","attrY","originX","originY","pathLength","pathSpacing","pathOffset"]);buildHTMLStyles(et,mt,tt,rt),et.attrs=et.style,et.style={};var ft=et.attrs,pt=et.style,gt=et.dimensions;ft.transform&&(gt&&(pt.transform=ft.transform),delete ft.transform),gt&&(it!==void 0||st!==void 0||pt.transform)&&(pt.transformOrigin=calcSVGTransformOrigin(gt,it!==void 0?it:.5,st!==void 0?st:.5)),nt!==void 0&&(ft.x=nt),ot!==void 0&&(ft.y=ot),at!==void 0&&buildSVGPath(ft,at,lt,ht)}var createSvgRenderState=function(){return __assign(__assign({},createHtmlRenderState()),{attrs:{}})};function useSVGProps(et,o){var tt=reactExports.useMemo(function(){var nt=createSvgRenderState();return buildSVGAttrs(nt,o,{enableHardwareAcceleration:!1},et.transformTemplate),__assign(__assign({},nt.attrs),{style:__assign({},nt.style)})},[o]);if(et.style){var rt={};copyRawValuesOnly(rt,et.style,et),tt.style=__assign(__assign({},rt),tt.style)}return tt}function createUseRender(et){et===void 0&&(et=!1);var o=function(tt,rt,nt,ot,it,st){var at=it.latestValues,ct=isSVGComponent(tt)?useSVGProps:useHTMLProps,lt=ct(rt,at,st),dt=filterProps(rt,typeof tt=="string",et),ht=__assign(__assign(__assign({},dt),lt),{ref:ot});return nt&&(ht["data-projection-id"]=nt),reactExports.createElement(tt,ht)};return o}var CAMEL_CASE_PATTERN=/([a-z])([A-Z])/g,REPLACE_TEMPLATE="$1-$2",camelToDash=function(et){return et.replace(CAMEL_CASE_PATTERN,REPLACE_TEMPLATE).toLowerCase()};function renderHTML(et,o,tt,rt){var nt=o.style,ot=o.vars;Object.assign(et.style,nt,rt&&rt.getProjectionStyles(tt));for(var it in ot)et.style.setProperty(it,ot[it])}var camelCaseAttributes=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength"]);function renderSVG(et,o,tt,rt){renderHTML(et,o,void 0,rt);for(var nt in o.attrs)et.setAttribute(camelCaseAttributes.has(nt)?nt:camelToDash(nt),o.attrs[nt])}function scrapeMotionValuesFromProps$1(et){var o=et.style,tt={};for(var rt in o)(isMotionValue(o[rt])||isForcedMotionValue(rt,et))&&(tt[rt]=o[rt]);return tt}function scrapeMotionValuesFromProps(et){var o=scrapeMotionValuesFromProps$1(et);for(var tt in et)if(isMotionValue(et[tt])){var rt=tt==="x"||tt==="y"?"attr"+tt.toUpperCase():tt;o[rt]=et[tt]}return o}function isAnimationControls(et){return typeof et=="object"&&typeof et.start=="function"}var isKeyframesTarget=function(et){return Array.isArray(et)},isCustomValue=function(et){return!!(et&&typeof et=="object"&&et.mix&&et.toValue)},resolveFinalValueInKeyframes=function(et){return isKeyframesTarget(et)?et[et.length-1]||0:et};function resolveMotionValue(et){var o=isMotionValue(et)?et.get():et;return isCustomValue(o)?o.toValue():o}function makeState(et,o,tt,rt){var nt=et.scrapeMotionValuesFromProps,ot=et.createRenderState,it=et.onMount,st={latestValues:makeLatestValues(o,tt,rt,nt),renderState:ot()};return it&&(st.mount=function(at){return it(o,at,st)}),st}var makeUseVisualState=function(et){return function(o,tt){var rt=reactExports.useContext(MotionContext),nt=reactExports.useContext(PresenceContext);return tt?makeState(et,o,rt,nt):useConstant(function(){return makeState(et,o,rt,nt)})}};function makeLatestValues(et,o,tt,rt){var nt={},ot=(tt==null?void 0:tt.initial)===!1,it=rt(et);for(var st in it)nt[st]=resolveMotionValue(it[st]);var at=et.initial,ct=et.animate,lt=checkIfControllingVariants(et),dt=checkIfVariantNode(et);o&&dt&&!lt&&et.inherit!==!1&&(at??(at=o.initial),ct??(ct=o.animate));var ht=ot||at===!1,mt=ht?ct:at;if(mt&&typeof mt!="boolean"&&!isAnimationControls(mt)){var ft=Array.isArray(mt)?mt:[mt];ft.forEach(function(pt){var gt=resolveVariantFromProps(et,pt);if(gt){var yt=gt.transitionEnd;gt.transition;var bt=__rest(gt,["transitionEnd","transition"]);for(var xt in bt){var vt=bt[xt];if(Array.isArray(vt)){var Et=ht?vt.length-1:0;vt=vt[Et]}vt!==null&&(nt[xt]=vt)}for(var xt in yt)nt[xt]=yt[xt]}})}return nt}var svgMotionConfig={useVisualState:makeUseVisualState({scrapeMotionValuesFromProps,createRenderState:createSvgRenderState,onMount:function(et,o,tt){var rt=tt.renderState,nt=tt.latestValues;try{rt.dimensions=typeof o.getBBox=="function"?o.getBBox():o.getBoundingClientRect()}catch{rt.dimensions={x:0,y:0,width:0,height:0}}buildSVGAttrs(rt,nt,{enableHardwareAcceleration:!1},et.transformTemplate),renderSVG(o,rt)}})},htmlMotionConfig={useVisualState:makeUseVisualState({scrapeMotionValuesFromProps:scrapeMotionValuesFromProps$1,createRenderState:createHtmlRenderState})};function createDomMotionConfig(et,o,tt,rt,nt){var ot=o.forwardMotionProps,it=ot===void 0?!1:ot,st=isSVGComponent(et)?svgMotionConfig:htmlMotionConfig;return __assign(__assign({},st),{preloadedFeatures:tt,useRender:createUseRender(it),createVisualElement:rt,projectionNodeConstructor:nt,Component:et})}var AnimationType;(function(et){et.Animate="animate",et.Hover="whileHover",et.Tap="whileTap",et.Drag="whileDrag",et.Focus="whileFocus",et.InView="whileInView",et.Exit="exit"})(AnimationType||(AnimationType={}));function addDomEvent(et,o,tt,rt){return rt===void 0&&(rt={passive:!0}),et.addEventListener(o,tt,rt),function(){return et.removeEventListener(o,tt)}}function useDomEvent(et,o,tt,rt){reactExports.useEffect(function(){var nt=et.current;if(tt&&nt)return addDomEvent(nt,o,tt,rt)},[et,o,tt,rt])}function useFocusGesture(et){var o=et.whileFocus,tt=et.visualElement,rt=function(){var ot;(ot=tt.animationState)===null||ot===void 0||ot.setActive(AnimationType.Focus,!0)},nt=function(){var ot;(ot=tt.animationState)===null||ot===void 0||ot.setActive(AnimationType.Focus,!1)};useDomEvent(tt,"focus",o?rt:void 0),useDomEvent(tt,"blur",o?nt:void 0)}function isMouseEvent(et){return typeof PointerEvent<"u"&&et instanceof PointerEvent?et.pointerType==="mouse":et instanceof MouseEvent}function isTouchEvent(et){var o=!!et.touches;return o}function filterPrimaryPointer(et){return function(o){var tt=o instanceof MouseEvent,rt=!tt||tt&&o.button===0;rt&&et(o)}}var defaultPagePoint={pageX:0,pageY:0};function pointFromTouch(et,o){o===void 0&&(o="page");var tt=et.touches[0]||et.changedTouches[0],rt=tt||defaultPagePoint;return{x:rt[o+"X"],y:rt[o+"Y"]}}function pointFromMouse(et,o){return o===void 0&&(o="page"),{x:et[o+"X"],y:et[o+"Y"]}}function extractEventInfo(et,o){return o===void 0&&(o="page"),{point:isTouchEvent(et)?pointFromTouch(et,o):pointFromMouse(et,o)}}var wrapHandler=function(et,o){o===void 0&&(o=!1);var tt=function(rt){return et(rt,extractEventInfo(rt))};return o?filterPrimaryPointer(tt):tt},supportsPointerEvents=function(){return isBrowser$3&&window.onpointerdown===null},supportsTouchEvents=function(){return isBrowser$3&&window.ontouchstart===null},supportsMouseEvents=function(){return isBrowser$3&&window.onmousedown===null},mouseEventNames={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},touchEventNames={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function getPointerEventName(et){return supportsPointerEvents()?et:supportsTouchEvents()?touchEventNames[et]:supportsMouseEvents()?mouseEventNames[et]:et}function addPointerEvent(et,o,tt,rt){return addDomEvent(et,getPointerEventName(o),wrapHandler(tt,o==="pointerdown"),rt)}function usePointerEvent(et,o,tt,rt){return useDomEvent(et,getPointerEventName(o),tt&&wrapHandler(tt,o==="pointerdown"),rt)}function createLock(et){var o=null;return function(){var tt=function(){o=null};return o===null?(o=et,tt):!1}}var globalHorizontalLock=createLock("dragHorizontal"),globalVerticalLock=createLock("dragVertical");function getGlobalLock(et){var o=!1;if(et==="y")o=globalVerticalLock();else if(et==="x")o=globalHorizontalLock();else{var tt=globalHorizontalLock(),rt=globalVerticalLock();tt&&rt?o=function(){tt(),rt()}:(tt&&tt(),rt&&rt())}return o}function isDragActive(){var et=getGlobalLock(!0);return et?(et(),!1):!0}function createHoverEvent(et,o,tt){return function(rt,nt){var ot;!isMouseEvent(rt)||isDragActive()||((ot=et.animationState)===null||ot===void 0||ot.setActive(AnimationType.Hover,o),tt==null||tt(rt,nt))}}function useHoverGesture(et){var o=et.onHoverStart,tt=et.onHoverEnd,rt=et.whileHover,nt=et.visualElement;usePointerEvent(nt,"pointerenter",o||rt?createHoverEvent(nt,!0,o):void 0,{passive:!o}),usePointerEvent(nt,"pointerleave",tt||rt?createHoverEvent(nt,!1,tt):void 0,{passive:!tt})}var isNodeOrChild=function(et,o){return o?et===o?!0:isNodeOrChild(et,o.parentElement):!1};function useUnmountEffect(et){return reactExports.useEffect(function(){return function(){return et()}},[])}const clamp$1=(et,o,tt)=>Math.min(Math.max(tt,et),o),safeMin=.001,minDuration=.01,maxDuration=10,minDamping=.05,maxDamping=1;function findSpring({duration:et=800,bounce:o=.25,velocity:tt=0,mass:rt=1}){let nt,ot,it=1-o;it=clamp$1(minDamping,maxDamping,it),et=clamp$1(minDuration,maxDuration,et/1e3),it<1?(nt=ct=>{const lt=ct*it,dt=lt*et,ht=lt-tt,mt=calcAngularFreq(ct,it),ft=Math.exp(-dt);return safeMin-ht/mt*ft},ot=ct=>{const dt=ct*it*et,ht=dt*tt+tt,mt=Math.pow(it,2)*Math.pow(ct,2)*et,ft=Math.exp(-dt),pt=calcAngularFreq(Math.pow(ct,2),it);return(-nt(ct)+safeMin>0?-1:1)*((ht-mt)*ft)/pt}):(nt=ct=>{const lt=Math.exp(-ct*et),dt=(ct-tt)*et+1;return-safeMin+lt*dt},ot=ct=>{const lt=Math.exp(-ct*et),dt=(tt-ct)*(et*et);return lt*dt});const st=5/et,at=approximateRoot(nt,ot,st);if(et=et*1e3,isNaN(at))return{stiffness:100,damping:10,duration:et};{const ct=Math.pow(at,2)*rt;return{stiffness:ct,damping:it*2*Math.sqrt(rt*ct),duration:et}}}const rootIterations=12;function approximateRoot(et,o,tt){let rt=tt;for(let nt=1;ntet[tt]!==void 0)}function getSpringOptions(et){let o=Object.assign({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},et);if(!isSpringType(et,physicsKeys)&&isSpringType(et,durationKeys)){const tt=findSpring(et);o=Object.assign(Object.assign(Object.assign({},o),tt),{velocity:0,mass:1}),o.isResolvedFromDuration=!0}return o}function spring(et){var{from:o=0,to:tt=1,restSpeed:rt=2,restDelta:nt}=et,ot=__rest(et,["from","to","restSpeed","restDelta"]);const it={done:!1,value:o};let{stiffness:st,damping:at,mass:ct,velocity:lt,duration:dt,isResolvedFromDuration:ht}=getSpringOptions(ot),mt=zero$1,ft=zero$1;function pt(){const gt=lt?-(lt/1e3):0,yt=tt-o,bt=at/(2*Math.sqrt(st*ct)),xt=Math.sqrt(st/ct)/1e3;if(nt===void 0&&(nt=Math.min(Math.abs(tt-o)/100,.4)),bt<1){const vt=calcAngularFreq(xt,bt);mt=Et=>{const Ct=Math.exp(-bt*xt*Et);return tt-Ct*((gt+bt*xt*yt)/vt*Math.sin(vt*Et)+yt*Math.cos(vt*Et))},ft=Et=>{const Ct=Math.exp(-bt*xt*Et);return bt*xt*Ct*(Math.sin(vt*Et)*(gt+bt*xt*yt)/vt+yt*Math.cos(vt*Et))-Ct*(Math.cos(vt*Et)*(gt+bt*xt*yt)-vt*yt*Math.sin(vt*Et))}}else if(bt===1)mt=vt=>tt-Math.exp(-xt*vt)*(yt+(gt+xt*yt)*vt);else{const vt=xt*Math.sqrt(bt*bt-1);mt=Et=>{const Ct=Math.exp(-bt*xt*Et),St=Math.min(vt*Et,300);return tt-Ct*((gt+bt*xt*yt)*Math.sinh(St)+vt*yt*Math.cosh(St))/vt}}}return pt(),{next:gt=>{const yt=mt(gt);if(ht)it.done=gt>=dt;else{const bt=ft(gt)*1e3,xt=Math.abs(bt)<=rt,vt=Math.abs(tt-yt)<=nt;it.done=xt&&vt}return it.value=it.done?tt:yt,it},flipTarget:()=>{lt=-lt,[o,tt]=[tt,o],pt()}}}spring.needsInterpolation=(et,o)=>typeof et=="string"||typeof o=="string";const zero$1=et=>0,progress=(et,o,tt)=>{const rt=o-et;return rt===0?1:(tt-et)/rt},mix=(et,o,tt)=>-tt*et+tt*o+et;function hueToRgb(et,o,tt){return tt<0&&(tt+=1),tt>1&&(tt-=1),tt<1/6?et+(o-et)*6*tt:tt<1/2?o:tt<2/3?et+(o-et)*(2/3-tt)*6:et}function hslaToRgba({hue:et,saturation:o,lightness:tt,alpha:rt}){et/=360,o/=100,tt/=100;let nt=0,ot=0,it=0;if(!o)nt=ot=it=tt;else{const st=tt<.5?tt*(1+o):tt+o-tt*o,at=2*tt-st;nt=hueToRgb(at,st,et+1/3),ot=hueToRgb(at,st,et),it=hueToRgb(at,st,et-1/3)}return{red:Math.round(nt*255),green:Math.round(ot*255),blue:Math.round(it*255),alpha:rt}}const mixLinearColor=(et,o,tt)=>{const rt=et*et,nt=o*o;return Math.sqrt(Math.max(0,tt*(nt-rt)+rt))},colorTypes=[hex,rgba,hsla],getColorType=et=>colorTypes.find(o=>o.test(et)),mixColor=(et,o)=>{let tt=getColorType(et),rt=getColorType(o),nt=tt.parse(et),ot=rt.parse(o);tt===hsla&&(nt=hslaToRgba(nt),tt=rgba),rt===hsla&&(ot=hslaToRgba(ot),rt=rgba);const it=Object.assign({},nt);return st=>{for(const at in it)at!=="alpha"&&(it[at]=mixLinearColor(nt[at],ot[at],st));return it.alpha=mix(nt.alpha,ot.alpha,st),tt.transform(it)}},isNum=et=>typeof et=="number",combineFunctions=(et,o)=>tt=>o(et(tt)),pipe$1=(...et)=>et.reduce(combineFunctions);function getMixer(et,o){return isNum(et)?tt=>mix(et,o,tt):color$1.test(et)?mixColor(et,o):mixComplex(et,o)}const mixArray=(et,o)=>{const tt=[...et],rt=tt.length,nt=et.map((ot,it)=>getMixer(ot,o[it]));return ot=>{for(let it=0;it{const tt=Object.assign(Object.assign({},et),o),rt={};for(const nt in tt)et[nt]!==void 0&&o[nt]!==void 0&&(rt[nt]=getMixer(et[nt],o[nt]));return nt=>{for(const ot in rt)tt[ot]=rt[ot](nt);return tt}};function analyse(et){const o=complex.parse(et),tt=o.length;let rt=0,nt=0,ot=0;for(let it=0;it{const tt=complex.createTransformer(o),rt=analyse(et),nt=analyse(o);return rt.numHSL===nt.numHSL&&rt.numRGB===nt.numRGB&&rt.numNumbers>=nt.numNumbers?pipe$1(mixArray(rt.parsed,nt.parsed),tt):it=>`${it>0?o:et}`},mixNumber=(et,o)=>tt=>mix(et,o,tt);function detectMixerFactory(et){if(typeof et=="number")return mixNumber;if(typeof et=="string")return color$1.test(et)?mixColor:mixComplex;if(Array.isArray(et))return mixArray;if(typeof et=="object")return mixObject}function createMixers(et,o,tt){const rt=[],nt=tt||detectMixerFactory(et[0]),ot=et.length-1;for(let it=0;ittt(progress(et,o,rt))}function slowInterpolate(et,o){const tt=et.length,rt=tt-1;return nt=>{let ot=0,it=!1;if(nt<=et[0]?it=!0:nt>=et[rt]&&(ot=rt-1,it=!0),!it){let at=1;for(;atnt||at===rt);at++);ot=at-1}const st=progress(et[ot],et[ot+1],nt);return o[ot](st)}}function interpolate(et,o,{clamp:tt=!0,ease:rt,mixer:nt}={}){const ot=et.length;invariant$1(ot===o.length),invariant$1(!rt||!Array.isArray(rt)||rt.length===ot-1),et[0]>et[ot-1]&&(et=[].concat(et),o=[].concat(o),et.reverse(),o.reverse());const it=createMixers(o,rt,nt),st=ot===2?fastInterpolate(et,it):slowInterpolate(et,it);return tt?at=>st(clamp$1(et[0],et[ot-1],at)):st}const reverseEasing=et=>o=>1-et(1-o),mirrorEasing=et=>o=>o<=.5?et(2*o)/2:(2-et(2*(1-o)))/2,createExpoIn=et=>o=>Math.pow(o,et),createBackIn=et=>o=>o*o*((et+1)*o-et),createAnticipate=et=>{const o=createBackIn(et);return tt=>(tt*=2)<1?.5*o(tt):.5*(2-Math.pow(2,-10*(tt-1)))},DEFAULT_OVERSHOOT_STRENGTH=1.525,BOUNCE_FIRST_THRESHOLD=4/11,BOUNCE_SECOND_THRESHOLD=8/11,BOUNCE_THIRD_THRESHOLD=9/10,linear=et=>et,easeIn=createExpoIn(2),easeOut=reverseEasing(easeIn),easeInOut=mirrorEasing(easeIn),circIn=et=>1-Math.sin(Math.acos(et)),circOut=reverseEasing(circIn),circInOut=mirrorEasing(circOut),backIn=createBackIn(DEFAULT_OVERSHOOT_STRENGTH),backOut=reverseEasing(backIn),backInOut=mirrorEasing(backIn),anticipate=createAnticipate(DEFAULT_OVERSHOOT_STRENGTH),ca=4356/361,cb=35442/1805,cc=16061/1805,bounceOut=et=>{if(et===1||et===0)return et;const o=et*et;return etet<.5?.5*(1-bounceOut(1-et*2)):.5*bounceOut(et*2-1)+.5;function defaultEasing(et,o){return et.map(()=>o||easeInOut).splice(0,et.length-1)}function defaultOffset(et){const o=et.length;return et.map((tt,rt)=>rt!==0?rt/(o-1):0)}function convertOffsetToTimes(et,o){return et.map(tt=>tt*o)}function keyframes$1({from:et=0,to:o=1,ease:tt,offset:rt,duration:nt=300}){const ot={done:!1,value:et},it=Array.isArray(o)?o:[et,o],st=convertOffsetToTimes(rt&&rt.length===it.length?rt:defaultOffset(it),nt);function at(){return interpolate(st,it,{ease:Array.isArray(tt)?tt:defaultEasing(it,tt)})}let ct=at();return{next:lt=>(ot.value=ct(lt),ot.done=lt>=nt,ot),flipTarget:()=>{it.reverse(),ct=at()}}}function decay({velocity:et=0,from:o=0,power:tt=.8,timeConstant:rt=350,restDelta:nt=.5,modifyTarget:ot}){const it={done:!1,value:o};let st=tt*et;const at=o+st,ct=ot===void 0?at:ot(at);return ct!==at&&(st=ct-o),{next:lt=>{const dt=-st*Math.exp(-lt/rt);return it.done=!(dt>nt||dt<-nt),it.value=it.done?ct:ct+dt,it},flipTarget:()=>{}}}const types$3={keyframes:keyframes$1,spring,decay};function detectAnimationFromOptions(et){if(Array.isArray(et.to))return keyframes$1;if(types$3[et.type])return types$3[et.type];const o=new Set(Object.keys(et));return o.has("ease")||o.has("duration")&&!o.has("dampingRatio")?keyframes$1:o.has("dampingRatio")||o.has("stiffness")||o.has("mass")||o.has("damping")||o.has("restSpeed")||o.has("restDelta")?spring:keyframes$1}const defaultTimestep=1/60*1e3,getCurrentTime=typeof performance<"u"?()=>performance.now():()=>Date.now(),onNextFrame=typeof window<"u"?et=>window.requestAnimationFrame(et):et=>setTimeout(()=>et(getCurrentTime()),defaultTimestep);function createRenderStep(et){let o=[],tt=[],rt=0,nt=!1,ot=!1;const it=new WeakSet,st={schedule:(at,ct=!1,lt=!1)=>{const dt=lt&&nt,ht=dt?o:tt;return ct&&it.add(at),ht.indexOf(at)===-1&&(ht.push(at),dt&&nt&&(rt=o.length)),at},cancel:at=>{const ct=tt.indexOf(at);ct!==-1&&tt.splice(ct,1),it.delete(at)},process:at=>{if(nt){ot=!0;return}if(nt=!0,[o,tt]=[tt,o],tt.length=0,rt=o.length,rt)for(let ct=0;ct(et[o]=createRenderStep(()=>runNextFrame=!0),et),{}),sync=stepsOrder.reduce((et,o)=>{const tt=steps[o];return et[o]=(rt,nt=!1,ot=!1)=>(runNextFrame||startLoop(),tt.schedule(rt,nt,ot)),et},{}),cancelSync=stepsOrder.reduce((et,o)=>(et[o]=steps[o].cancel,et),{}),flushSync=stepsOrder.reduce((et,o)=>(et[o]=()=>steps[o].process(frame),et),{}),processStep=et=>steps[et].process(frame),processFrame=et=>{runNextFrame=!1,frame.delta=useDefaultElapsed?defaultTimestep:Math.max(Math.min(et-frame.timestamp,maxElapsed),1),frame.timestamp=et,isProcessing=!0,stepsOrder.forEach(processStep),isProcessing=!1,runNextFrame&&(useDefaultElapsed=!1,onNextFrame(processFrame))},startLoop=()=>{runNextFrame=!0,useDefaultElapsed=!0,isProcessing||onNextFrame(processFrame)},getFrameData=()=>frame;function loopElapsed(et,o,tt=0){return et-o-tt}function reverseElapsed(et,o,tt=0,rt=!0){return rt?loopElapsed(o+-et,o,tt):o-(et-o)+tt}function hasRepeatDelayElapsed(et,o,tt,rt){return rt?et>=o+tt:et<=-tt}const framesync=et=>{const o=({delta:tt})=>et(tt);return{start:()=>sync.update(o,!0),stop:()=>cancelSync.update(o)}};function animate$1(et){var o,tt,{from:rt,autoplay:nt=!0,driver:ot=framesync,elapsed:it=0,repeat:st=0,repeatType:at="loop",repeatDelay:ct=0,onPlay:lt,onStop:dt,onComplete:ht,onRepeat:mt,onUpdate:ft}=et,pt=__rest(et,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]);let{to:gt}=pt,yt,bt=0,xt=pt.duration,vt,Et=!1,Ct=!0,St;const At=detectAnimationFromOptions(pt);!((tt=(o=At).needsInterpolation)===null||tt===void 0)&&tt.call(o,rt,gt)&&(St=interpolate([0,100],[rt,gt],{clamp:!1}),rt=0,gt=100);const kt=At(Object.assign(Object.assign({},pt),{from:rt,to:gt}));function It(){bt++,at==="reverse"?(Ct=bt%2===0,it=reverseElapsed(it,xt,ct,Ct)):(it=loopElapsed(it,xt,ct),at==="mirror"&&kt.flipTarget()),Et=!1,mt&&mt()}function Ot(){yt.stop(),ht&&ht()}function Nt(Ft){if(Ct||(Ft=-Ft),it+=Ft,!Et){const Ht=kt.next(Math.max(0,it));vt=Ht.value,St&&(vt=St(vt)),Et=Ct?Ht.done:it<=0}ft==null||ft(vt),Et&&(bt===0&&(xt??(xt=it)),bt{dt==null||dt(),yt.stop()}}}function velocityPerSecond(et,o){return o?et*(1e3/o):0}function inertia({from:et=0,velocity:o=0,min:tt,max:rt,power:nt=.8,timeConstant:ot=750,bounceStiffness:it=500,bounceDamping:st=10,restDelta:at=1,modifyTarget:ct,driver:lt,onUpdate:dt,onComplete:ht,onStop:mt}){let ft;function pt(xt){return tt!==void 0&&xtrt}function gt(xt){return tt===void 0?rt:rt===void 0||Math.abs(tt-xt){var Et;dt==null||dt(vt),(Et=xt.onUpdate)===null||Et===void 0||Et.call(xt,vt)},onComplete:ht,onStop:mt}))}function bt(xt){yt(Object.assign({type:"spring",stiffness:it,damping:st,restDelta:at},xt))}if(pt(et))bt({from:et,velocity:o,to:gt(et)});else{let xt=nt*o+et;typeof ct<"u"&&(xt=ct(xt));const vt=gt(xt),Et=vt===tt?-1:1;let Ct,St;const At=kt=>{Ct=St,St=kt,o=velocityPerSecond(kt-Ct,getFrameData().delta),(Et===1&&kt>vt||Et===-1&&ktft==null?void 0:ft.stop()}}const isPoint=et=>et.hasOwnProperty("x")&&et.hasOwnProperty("y"),isPoint3D=et=>isPoint(et)&&et.hasOwnProperty("z"),distance1D=(et,o)=>Math.abs(et-o);function distance(et,o){if(isNum(et)&&isNum(o))return distance1D(et,o);if(isPoint(et)&&isPoint(o)){const tt=distance1D(et.x,o.x),rt=distance1D(et.y,o.y),nt=isPoint3D(et)&&isPoint3D(o)?distance1D(et.z,o.z):0;return Math.sqrt(Math.pow(tt,2)+Math.pow(rt,2)+Math.pow(nt,2))}}const a=(et,o)=>1-3*o+3*et,b$3=(et,o)=>3*o-6*et,c$2=et=>3*et,calcBezier=(et,o,tt)=>((a(o,tt)*et+b$3(o,tt))*et+c$2(o))*et,getSlope=(et,o,tt)=>3*a(o,tt)*et*et+2*b$3(o,tt)*et+c$2(o),subdivisionPrecision=1e-7,subdivisionMaxIterations=10;function binarySubdivide(et,o,tt,rt,nt){let ot,it,st=0;do it=o+(tt-o)/2,ot=calcBezier(it,rt,nt)-et,ot>0?tt=it:o=it;while(Math.abs(ot)>subdivisionPrecision&&++st=newtonMinSlope?newtonRaphsonIterate(it,dt,et,tt):ht===0?dt:binarySubdivide(it,st,st+kSampleStepSize,et,tt)}return it=>it===0||it===1?it:calcBezier(ot(it),o,rt)}function useTapGesture(et){var o=et.onTap,tt=et.onTapStart,rt=et.onTapCancel,nt=et.whileTap,ot=et.visualElement,it=o||tt||rt||nt,st=reactExports.useRef(!1),at=reactExports.useRef(null),ct={passive:!(tt||o||rt||ft)};function lt(){var pt;(pt=at.current)===null||pt===void 0||pt.call(at),at.current=null}function dt(){var pt;return lt(),st.current=!1,(pt=ot.animationState)===null||pt===void 0||pt.setActive(AnimationType.Tap,!1),!isDragActive()}function ht(pt,gt){dt()&&(isNodeOrChild(ot.getInstance(),pt.target)?o==null||o(pt,gt):rt==null||rt(pt,gt))}function mt(pt,gt){dt()&&(rt==null||rt(pt,gt))}function ft(pt,gt){var yt;lt(),!st.current&&(st.current=!0,at.current=pipe$1(addPointerEvent(window,"pointerup",ht,ct),addPointerEvent(window,"pointercancel",mt,ct)),(yt=ot.animationState)===null||yt===void 0||yt.setActive(AnimationType.Tap,!0),tt==null||tt(pt,gt))}usePointerEvent(ot,"pointerdown",it?ft:void 0,ct),useUnmountEffect(lt)}var warned=new Set;function warnOnce(et,o,tt){warned.has(o)||(console.warn(o),warned.add(o))}var observerCallbacks=new WeakMap,observers$1=new WeakMap,fireObserverCallback=function(et){var o;(o=observerCallbacks.get(et.target))===null||o===void 0||o(et)},fireAllObserverCallbacks=function(et){et.forEach(fireObserverCallback)};function initIntersectionObserver(et){var o=et.root,tt=__rest(et,["root"]),rt=o||document;observers$1.has(rt)||observers$1.set(rt,{});var nt=observers$1.get(rt),ot=JSON.stringify(tt);return nt[ot]||(nt[ot]=new IntersectionObserver(fireAllObserverCallbacks,__assign({root:o},tt))),nt[ot]}function observeIntersection(et,o,tt){var rt=initIntersectionObserver(o);return observerCallbacks.set(et,tt),rt.observe(et),function(){observerCallbacks.delete(et),rt.unobserve(et)}}function useViewport(et){var o=et.visualElement,tt=et.whileInView,rt=et.onViewportEnter,nt=et.onViewportLeave,ot=et.viewport,it=ot===void 0?{}:ot,st=reactExports.useRef({hasEnteredView:!1,isInView:!1}),at=!!(tt||rt||nt);it.once&&st.current.hasEnteredView&&(at=!1);var ct=typeof IntersectionObserver>"u"?useMissingIntersectionObserver:useIntersectionObserver;ct(at,st.current,o,it)}var thresholdNames={some:0,all:1};function useIntersectionObserver(et,o,tt,rt){var nt=rt.root,ot=rt.margin,it=rt.amount,st=it===void 0?"some":it,at=rt.once;reactExports.useEffect(function(){if(et){var ct={root:nt==null?void 0:nt.current,rootMargin:ot,threshold:typeof st=="number"?st:thresholdNames[st]},lt=function(dt){var ht,mt=dt.isIntersecting;if(o.isInView!==mt&&(o.isInView=mt,!(at&&!mt&&o.hasEnteredView))){mt&&(o.hasEnteredView=!0),(ht=tt.animationState)===null||ht===void 0||ht.setActive(AnimationType.InView,mt);var ft=tt.getProps(),pt=mt?ft.onViewportEnter:ft.onViewportLeave;pt==null||pt(dt)}};return observeIntersection(tt.getInstance(),ct,lt)}},[et,nt,ot,st])}function useMissingIntersectionObserver(et,o,tt,rt){var nt=rt.fallback,ot=nt===void 0?!0:nt;reactExports.useEffect(function(){!et||!ot||(env$2!=="production"&&warnOnce(!1,"IntersectionObserver not available on this device. whileInView animations will trigger on mount."),requestAnimationFrame(function(){var it;o.hasEnteredView=!0;var st=tt.getProps().onViewportEnter;st==null||st(null),(it=tt.animationState)===null||it===void 0||it.setActive(AnimationType.InView,!0)}))},[et])}var makeRenderlessComponent=function(et){return function(o){return et(o),null}},gestureAnimations={inView:makeRenderlessComponent(useViewport),tap:makeRenderlessComponent(useTapGesture),focus:makeRenderlessComponent(useFocusGesture),hover:makeRenderlessComponent(useHoverGesture)},counter=0,incrementId=function(){return counter++},useId$1=function(){return useConstant(incrementId)};function usePresence$1(){var et=reactExports.useContext(PresenceContext);if(et===null)return[!0,null];var o=et.isPresent,tt=et.onExitComplete,rt=et.register,nt=useId$1();reactExports.useEffect(function(){return rt(nt)},[]);var ot=function(){return tt==null?void 0:tt(nt)};return!o&&tt?[!1,ot]:[!0]}function shallowCompare(et,o){if(!Array.isArray(o))return!1;var tt=o.length;if(tt!==et.length)return!1;for(var rt=0;rt-1&&et.splice(tt,1)}var SubscriptionManager$1=function(){function et(){this.subscriptions=[]}return et.prototype.add=function(o){var tt=this;return addUniqueItem(this.subscriptions,o),function(){return removeItem(tt.subscriptions,o)}},et.prototype.notify=function(o,tt,rt){var nt=this.subscriptions.length;if(nt)if(nt===1)this.subscriptions[0](o,tt,rt);else for(var ot=0;otbt&&Ot,Qt=Array.isArray(It)?It:[It],Vt=Qt.reduce(ot,{});Nt===!1&&(Vt={});var Bt=kt.prevResolvedValues,Wt=Bt===void 0?{}:Bt,jt=__assign(__assign({},Wt),Vt),Xt=function(tr){Ht=!0,gt.delete(tr),kt.needsAnimating[tr]=!0};for(var Kt in jt){var Pt=Vt[Kt],Gt=Wt[Kt];yt.hasOwnProperty(Kt)||(Pt!==Gt?isKeyframesTarget(Pt)&&isKeyframesTarget(Gt)?!shallowCompare(Pt,Gt)||Ft?Xt(Kt):kt.protectedKeys[Kt]=!0:Pt!==void 0?Xt(Kt):gt.add(Kt):Pt!==void 0&>.has(Kt)?Xt(Kt):kt.protectedKeys[Kt]=!0)}kt.prevProp=It,kt.prevResolvedValues=Vt,kt.isActive&&(yt=__assign(__assign({},yt),Vt)),nt&&et.blockInitialAnimation&&(Ht=!1),Ht&&!Yt&&pt.push.apply(pt,__spreadArray([],__read(Qt.map(function(tr){return{animation:tr,options:__assign({type:At},lt)}})),!1))},vt=0;vt=3;if(!(!mt&&!ft)){var pt=ht.point,gt=getFrameData().timestamp;nt.history.push(__assign(__assign({},pt),{timestamp:gt}));var yt=nt.handlers,bt=yt.onStart,xt=yt.onMove;mt||(bt&&bt(nt.lastMoveEvent,ht),nt.startEvent=nt.lastMoveEvent),xt&&xt(nt.lastMoveEvent,ht)}}},this.handlePointerMove=function(ht,mt){if(nt.lastMoveEvent=ht,nt.lastMoveEventInfo=transformPoint(mt,nt.transformPagePoint),isMouseEvent(ht)&&ht.buttons===0){nt.handlePointerUp(ht,mt);return}sync.update(nt.updatePoint,!0)},this.handlePointerUp=function(ht,mt){nt.end();var ft=nt.handlers,pt=ft.onEnd,gt=ft.onSessionEnd,yt=getPanInfo(transformPoint(mt,nt.transformPagePoint),nt.history);nt.startEvent&&pt&&pt(ht,yt),gt&>(ht,yt)},!(isTouchEvent(o)&&o.touches.length>1)){this.handlers=tt,this.transformPagePoint=it;var st=extractEventInfo(o),at=transformPoint(st,this.transformPagePoint),ct=at.point,lt=getFrameData().timestamp;this.history=[__assign(__assign({},ct),{timestamp:lt})];var dt=tt.onSessionStart;dt&&dt(o,getPanInfo(at,this.history)),this.removeListeners=pipe$1(addPointerEvent(window,"pointermove",this.handlePointerMove),addPointerEvent(window,"pointerup",this.handlePointerUp),addPointerEvent(window,"pointercancel",this.handlePointerUp))}}return et.prototype.updateHandlers=function(o){this.handlers=o},et.prototype.end=function(){this.removeListeners&&this.removeListeners(),cancelSync.update(this.updatePoint)},et}();function transformPoint(et,o){return o?{point:o(et.point)}:et}function subtractPoint(et,o){return{x:et.x-o.x,y:et.y-o.y}}function getPanInfo(et,o){var tt=et.point;return{point:tt,delta:subtractPoint(tt,lastDevicePoint(o)),offset:subtractPoint(tt,startDevicePoint(o)),velocity:getVelocity(o,.1)}}function startDevicePoint(et){return et[0]}function lastDevicePoint(et){return et[et.length-1]}function getVelocity(et,o){if(et.length<2)return{x:0,y:0};for(var tt=et.length-1,rt=null,nt=lastDevicePoint(et);tt>=0&&(rt=et[tt],!(nt.timestamp-rt.timestamp>secondsToMilliseconds(o)));)tt--;if(!rt)return{x:0,y:0};var ot=(nt.timestamp-rt.timestamp)/1e3;if(ot===0)return{x:0,y:0};var it={x:(nt.x-rt.x)/ot,y:(nt.y-rt.y)/ot};return it.x===1/0&&(it.x=0),it.y===1/0&&(it.y=0),it}function calcLength(et){return et.max-et.min}function isNear(et,o,tt){return o===void 0&&(o=0),tt===void 0&&(tt=.01),distance(et,o)nt&&(et=tt?mix(nt,et,tt.max):Math.min(et,nt)),et}function calcRelativeAxisConstraints(et,o,tt){return{min:o!==void 0?et.min+o:void 0,max:tt!==void 0?et.max+tt-(et.max-et.min):void 0}}function calcRelativeConstraints(et,o){var tt=o.top,rt=o.left,nt=o.bottom,ot=o.right;return{x:calcRelativeAxisConstraints(et.x,rt,ot),y:calcRelativeAxisConstraints(et.y,tt,nt)}}function calcViewportAxisConstraints(et,o){var tt,rt=o.min-et.min,nt=o.max-et.max;return o.max-o.minrt?tt=progress(o.min,o.max-rt,et.min):rt>nt&&(tt=progress(et.min,et.max-nt,o.min)),clamp$1(0,1,tt)}function rebaseAxisConstraints(et,o){var tt={};return o.min!==void 0&&(tt.min=o.min-et.min),o.max!==void 0&&(tt.max=o.max-et.min),tt}var defaultElastic=.35;function resolveDragElastic(et){return et===void 0&&(et=defaultElastic),et===!1?et=0:et===!0&&(et=defaultElastic),{x:resolveAxisElastic(et,"left","right"),y:resolveAxisElastic(et,"top","bottom")}}function resolveAxisElastic(et,o,tt){return{min:resolvePointElastic(et,o),max:resolvePointElastic(et,tt)}}function resolvePointElastic(et,o){var tt;return typeof et=="number"?et:(tt=et[o])!==null&&tt!==void 0?tt:0}var createAxisDelta=function(){return{translate:0,scale:1,origin:0,originPoint:0}},createDelta=function(){return{x:createAxisDelta(),y:createAxisDelta()}},createAxis=function(){return{min:0,max:0}},createBox=function(){return{x:createAxis(),y:createAxis()}};function eachAxis(et){return[et("x"),et("y")]}function convertBoundingBoxToBox(et){var o=et.top,tt=et.left,rt=et.right,nt=et.bottom;return{x:{min:tt,max:rt},y:{min:o,max:nt}}}function convertBoxToBoundingBox(et){var o=et.x,tt=et.y;return{top:tt.min,right:o.max,bottom:tt.max,left:o.min}}function transformBoxPoints(et,o){if(!o)return et;var tt=o({x:et.left,y:et.top}),rt=o({x:et.right,y:et.bottom});return{top:tt.y,left:tt.x,bottom:rt.y,right:rt.x}}function isIdentityScale(et){return et===void 0||et===1}function hasScale(et){var o=et.scale,tt=et.scaleX,rt=et.scaleY;return!isIdentityScale(o)||!isIdentityScale(tt)||!isIdentityScale(rt)}function hasTransform(et){return hasScale(et)||hasTranslate(et.x)||hasTranslate(et.y)||et.z||et.rotate||et.rotateX||et.rotateY}function hasTranslate(et){return et&&et!=="0%"}function scalePoint(et,o,tt){var rt=et-tt,nt=o*rt;return tt+nt}function applyPointDelta(et,o,tt,rt,nt){return nt!==void 0&&(et=scalePoint(et,nt,rt)),scalePoint(et,tt,rt)+o}function applyAxisDelta(et,o,tt,rt,nt){o===void 0&&(o=0),tt===void 0&&(tt=1),et.min=applyPointDelta(et.min,o,tt,rt,nt),et.max=applyPointDelta(et.max,o,tt,rt,nt)}function applyBoxDelta(et,o){var tt=o.x,rt=o.y;applyAxisDelta(et.x,tt.translate,tt.scale,tt.originPoint),applyAxisDelta(et.y,rt.translate,rt.scale,rt.originPoint)}function applyTreeDeltas(et,o,tt,rt){var nt,ot;rt===void 0&&(rt=!1);var it=tt.length;if(it){o.x=o.y=1;for(var st,at,ct=0;cto?tt="y":Math.abs(et.x)>o&&(tt="x"),tt}function useDrag(et){var o=et.dragControls,tt=et.visualElement,rt=useConstant(function(){return new VisualElementDragControls(tt)});reactExports.useEffect(function(){return o&&o.subscribe(rt)},[rt,o]),reactExports.useEffect(function(){return rt.addListeners()},[rt])}function usePanGesture(et){var o=et.onPan,tt=et.onPanStart,rt=et.onPanEnd,nt=et.onPanSessionStart,ot=et.visualElement,it=o||tt||rt||nt,st=reactExports.useRef(null),at=reactExports.useContext(MotionConfigContext).transformPagePoint,ct={onSessionStart:nt,onStart:tt,onMove:o,onEnd:function(dt,ht){st.current=null,rt&&rt(dt,ht)}};reactExports.useEffect(function(){st.current!==null&&st.current.updateHandlers(ct)});function lt(dt){st.current=new PanSession(dt,ct,{transformPagePoint:at})}usePointerEvent(ot,"pointerdown",it&<),useUnmountEffect(function(){return st.current&&st.current.end()})}var drag={pan:makeRenderlessComponent(usePanGesture),drag:makeRenderlessComponent(useDrag)},names$1=["LayoutMeasure","BeforeLayoutMeasure","LayoutUpdate","ViewportBoxUpdate","Update","Render","AnimationComplete","LayoutAnimationComplete","AnimationStart","LayoutAnimationStart","SetAxisTarget","Unmount"];function createLifecycles(){var et=names$1.map(function(){return new SubscriptionManager$1}),o={},tt={clearAllListeners:function(){return et.forEach(function(rt){return rt.clear()})},updatePropListeners:function(rt){names$1.forEach(function(nt){var ot,it="on"+nt,st=rt[it];(ot=o[nt])===null||ot===void 0||ot.call(o),st&&(o[nt]=tt[it](st))})}};return et.forEach(function(rt,nt){tt["on"+names$1[nt]]=function(ot){return rt.add(ot)},tt["notify"+names$1[nt]]=function(){for(var ot=[],it=0;it=0?window.pageYOffset:null,ct=convertChangedValueTypes(o,et,st);return ot.length&&ot.forEach(function(lt){var dt=__read(lt,2),ht=dt[0],mt=dt[1];et.getValue(ht).set(mt)}),et.syncRender(),at!==null&&window.scrollTo({top:at}),{target:ct,transitionEnd:rt}}else return{target:o,transitionEnd:rt}};function unitConversion(et,o,tt,rt){return hasPositionalKey(o)?checkAndConvertChangedValueTypes(et,o,tt,rt):{target:o,transitionEnd:rt}}var parseDomVariant=function(et,o,tt,rt){var nt=resolveCSSVariables(et,o,rt);return o=nt.target,rt=nt.transitionEnd,unitConversion(et,o,tt,rt)};function getComputedStyle$1(et){return window.getComputedStyle(et)}var htmlConfig={treeType:"dom",readValueFromInstance:function(et,o){if(isTransformProp(o)){var tt=getDefaultValueType(o);return tt&&tt.default||0}else{var rt=getComputedStyle$1(et);return(isCSSVariable$1(o)?rt.getPropertyValue(o):rt[o])||0}},sortNodePosition:function(et,o){return et.compareDocumentPosition(o)&2?1:-1},getBaseTarget:function(et,o){var tt;return(tt=et.style)===null||tt===void 0?void 0:tt[o]},measureViewportBox:function(et,o){var tt=o.transformPagePoint;return measureViewportBox(et,tt)},resetTransform:function(et,o,tt){var rt=tt.transformTemplate;o.style.transform=rt?rt({},""):"none",et.scheduleRender()},restoreTransform:function(et,o){et.style.transform=o.style.transform},removeValueFromRenderState:function(et,o){var tt=o.vars,rt=o.style;delete tt[et],delete rt[et]},makeTargetAnimatable:function(et,o,tt,rt){var nt=tt.transformValues;rt===void 0&&(rt=!0);var ot=o.transition,it=o.transitionEnd,st=__rest(o,["transition","transitionEnd"]),at=getOrigin(st,ot||{},et);if(nt&&(it&&(it=nt(it)),st&&(st=nt(st)),at&&(at=nt(at))),rt){checkTargetForNewValues(et,st,at);var ct=parseDomVariant(et,st,at,it);it=ct.transitionEnd,st=ct.target}return __assign({transition:ot,transitionEnd:it},st)},scrapeMotionValuesFromProps:scrapeMotionValuesFromProps$1,build:function(et,o,tt,rt,nt){et.isVisible!==void 0&&(o.style.visibility=et.isVisible?"visible":"hidden"),buildHTMLStyles(o,tt,rt,nt.transformTemplate)},render:renderHTML},htmlVisualElement=visualElement(htmlConfig),svgVisualElement=visualElement(__assign(__assign({},htmlConfig),{getBaseTarget:function(et,o){return et[o]},readValueFromInstance:function(et,o){var tt;return isTransformProp(o)?((tt=getDefaultValueType(o))===null||tt===void 0?void 0:tt.default)||0:(o=camelCaseAttributes.has(o)?o:camelToDash(o),et.getAttribute(o))},scrapeMotionValuesFromProps,build:function(et,o,tt,rt,nt){buildSVGAttrs(o,tt,rt,nt.transformTemplate)},render:renderSVG})),createDomVisualElement=function(et,o){return isSVGComponent(et)?svgVisualElement(o,{enableHardwareAcceleration:!1}):htmlVisualElement(o,{enableHardwareAcceleration:!0})};function pixelsToPercent(et,o){return o.max===o.min?0:et/(o.max-o.min)*100}var correctBorderRadius={correct:function(et,o){if(!o.target)return et;if(typeof et=="string")if(px.test(et))et=parseFloat(et);else return et;var tt=pixelsToPercent(et,o.target.x),rt=pixelsToPercent(et,o.target.y);return"".concat(tt,"% ").concat(rt,"%")}},varToken="_$css",correctBoxShadow={correct:function(et,o){var tt=o.treeScale,rt=o.projectionDelta,nt=et,ot=et.includes("var("),it=[];ot&&(et=et.replace(cssVariableRegex,function(pt){return it.push(pt),varToken}));var st=complex.parse(et);if(st.length>5)return nt;var at=complex.createTransformer(et),ct=typeof st[0]!="number"?1:0,lt=rt.x.scale*tt.x,dt=rt.y.scale*tt.y;st[0+ct]/=lt,st[1+ct]/=dt;var ht=mix(lt,dt,.5);typeof st[2+ct]=="number"&&(st[2+ct]/=ht),typeof st[3+ct]=="number"&&(st[3+ct]/=ht);var mt=at(st);if(ot){var ft=0;mt=mt.replace(varToken,function(){var pt=it[ft];return ft++,pt})}return mt}},MeasureLayoutWithContext=function(et){__extends(o,et);function o(){return et!==null&&et.apply(this,arguments)||this}return o.prototype.componentDidMount=function(){var tt=this,rt=this.props,nt=rt.visualElement,ot=rt.layoutGroup,it=rt.switchLayoutGroup,st=rt.layoutId,at=nt.projection;addScaleCorrector(defaultScaleCorrectors),at&&(ot!=null&&ot.group&&ot.group.add(at),it!=null&&it.register&&st&&it.register(at),at.root.didUpdate(),at.addEventListener("animationComplete",function(){tt.safeToRemove()}),at.setOptions(__assign(__assign({},at.options),{onExitComplete:function(){return tt.safeToRemove()}}))),globalProjectionState.hasEverUpdated=!0},o.prototype.getSnapshotBeforeUpdate=function(tt){var rt=this,nt=this.props,ot=nt.layoutDependency,it=nt.visualElement,st=nt.drag,at=nt.isPresent,ct=it.projection;return ct&&(ct.isPresent=at,st||tt.layoutDependency!==ot||ot===void 0?ct.willUpdate():this.safeToRemove(),tt.isPresent!==at&&(at?ct.promote():ct.relegate()||sync.postRender(function(){var lt;!((lt=ct.getStack())===null||lt===void 0)&<.members.length||rt.safeToRemove()}))),null},o.prototype.componentDidUpdate=function(){var tt=this.props.visualElement.projection;tt&&(tt.root.didUpdate(),!tt.currentAnimation&&tt.isLead()&&this.safeToRemove())},o.prototype.componentWillUnmount=function(){var tt=this.props,rt=tt.visualElement,nt=tt.layoutGroup,ot=tt.switchLayoutGroup,it=rt.projection;it&&(it.scheduleCheckAfterUnmount(),nt!=null&&nt.group&&nt.group.remove(it),ot!=null&&ot.deregister&&ot.deregister(it))},o.prototype.safeToRemove=function(){var tt=this.props.safeToRemove;tt==null||tt()},o.prototype.render=function(){return null},o}(React.Component);function MeasureLayout(et){var o=__read(usePresence$1(),2),tt=o[0],rt=o[1],nt=reactExports.useContext(LayoutGroupContext);return React.createElement(MeasureLayoutWithContext,__assign({},et,{layoutGroup:nt,switchLayoutGroup:reactExports.useContext(SwitchLayoutGroupContext),isPresent:tt,safeToRemove:rt}))}var defaultScaleCorrectors={borderRadius:__assign(__assign({},correctBorderRadius),{applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]}),borderTopLeftRadius:correctBorderRadius,borderTopRightRadius:correctBorderRadius,borderBottomLeftRadius:correctBorderRadius,borderBottomRightRadius:correctBorderRadius,boxShadow:correctBoxShadow},layoutFeatures={measureLayout:MeasureLayout};function animate(et,o,tt){tt===void 0&&(tt={});var rt=isMotionValue(et)?et:motionValue(et);return startAnimation("",rt,o,tt),{stop:function(){return rt.stop()},isAnimating:function(){return rt.isAnimating()}}}var borders=["TopLeft","TopRight","BottomLeft","BottomRight"],numBorders=borders.length,asNumber=function(et){return typeof et=="string"?parseFloat(et):et},isPx=function(et){return typeof et=="number"||px.test(et)};function mixValues(et,o,tt,rt,nt,ot){var it,st,at,ct;nt?(et.opacity=mix(0,(it=tt.opacity)!==null&&it!==void 0?it:1,easeCrossfadeIn(rt)),et.opacityExit=mix((st=o.opacity)!==null&&st!==void 0?st:1,0,easeCrossfadeOut(rt))):ot&&(et.opacity=mix((at=o.opacity)!==null&&at!==void 0?at:1,(ct=tt.opacity)!==null&&ct!==void 0?ct:1,rt));for(var lt=0;lto?1:tt(progress(et,o,rt))}}function copyAxisInto(et,o){et.min=o.min,et.max=o.max}function copyBoxInto(et,o){copyAxisInto(et.x,o.x),copyAxisInto(et.y,o.y)}function removePointDelta(et,o,tt,rt,nt){return et-=o,et=scalePoint(et,1/tt,rt),nt!==void 0&&(et=scalePoint(et,1/nt,rt)),et}function removeAxisDelta(et,o,tt,rt,nt,ot,it){if(o===void 0&&(o=0),tt===void 0&&(tt=1),rt===void 0&&(rt=.5),ot===void 0&&(ot=et),it===void 0&&(it=et),percent.test(o)){o=parseFloat(o);var st=mix(it.min,it.max,o/100);o=st-it.min}if(typeof o=="number"){var at=mix(ot.min,ot.max,rt);et===ot&&(at-=o),et.min=removePointDelta(et.min,o,tt,at,nt),et.max=removePointDelta(et.max,o,tt,at,nt)}}function removeAxisTransforms(et,o,tt,rt,nt){var ot=__read(tt,3),it=ot[0],st=ot[1],at=ot[2];removeAxisDelta(et,o[it],o[st],o[at],o.scale,rt,nt)}var xKeys=["x","scaleX","originX"],yKeys=["y","scaleY","originY"];function removeBoxTransforms(et,o,tt,rt){removeAxisTransforms(et.x,o,xKeys,tt==null?void 0:tt.x,rt==null?void 0:rt.x),removeAxisTransforms(et.y,o,yKeys,tt==null?void 0:tt.y,rt==null?void 0:rt.y)}function isAxisDeltaZero(et){return et.translate===0&&et.scale===1}function isDeltaZero(et){return isAxisDeltaZero(et.x)&&isAxisDeltaZero(et.y)}function boxEquals(et,o){return et.x.min===o.x.min&&et.x.max===o.x.max&&et.y.min===o.y.min&&et.y.max===o.y.max}var NodeStack=function(){function et(){this.members=[]}return et.prototype.add=function(o){addUniqueItem(this.members,o),o.scheduleRender()},et.prototype.remove=function(o){if(removeItem(this.members,o),o===this.prevLead&&(this.prevLead=void 0),o===this.lead){var tt=this.members[this.members.length-1];tt&&this.promote(tt)}},et.prototype.relegate=function(o){var tt=this.members.findIndex(function(it){return o===it});if(tt===0)return!1;for(var rt,nt=tt;nt>=0;nt--){var ot=this.members[nt];if(ot.isPresent!==!1){rt=ot;break}}return rt?(this.promote(rt),!0):!1},et.prototype.promote=function(o,tt){var rt,nt=this.lead;if(o!==nt&&(this.prevLead=nt,this.lead=o,o.show(),nt)){nt.instance&&nt.scheduleRender(),o.scheduleRender(),o.resumeFrom=nt,tt&&(o.resumeFrom.preserveOpacity=!0),nt.snapshot&&(o.snapshot=nt.snapshot,o.snapshot.latestValues=nt.animationValues||nt.latestValues,o.snapshot.isShared=!0),!((rt=o.root)===null||rt===void 0)&&rt.isUpdating&&(o.isLayoutDirty=!0);var ot=o.options.crossfade;ot===!1&&nt.hide()}},et.prototype.exitAnimationComplete=function(){this.members.forEach(function(o){var tt,rt,nt,ot,it;(rt=(tt=o.options).onExitComplete)===null||rt===void 0||rt.call(tt),(it=(nt=o.resumingFrom)===null||nt===void 0?void 0:(ot=nt.options).onExitComplete)===null||it===void 0||it.call(ot)})},et.prototype.scheduleRender=function(){this.members.forEach(function(o){o.instance&&o.scheduleRender(!1)})},et.prototype.removeLeadSnapshot=function(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)},et}(),identityProjection="translate3d(0px, 0px, 0) scale(1, 1) scale(1, 1)";function buildProjectionTransform(et,o,tt){var rt=et.x.translate/o.x,nt=et.y.translate/o.y,ot="translate3d(".concat(rt,"px, ").concat(nt,"px, 0) ");if(ot+="scale(".concat(1/o.x,", ").concat(1/o.y,") "),tt){var it=tt.rotate,st=tt.rotateX,at=tt.rotateY;it&&(ot+="rotate(".concat(it,"deg) ")),st&&(ot+="rotateX(".concat(st,"deg) ")),at&&(ot+="rotateY(".concat(at,"deg) "))}var ct=et.x.scale*o.x,lt=et.y.scale*o.y;return ot+="scale(".concat(ct,", ").concat(lt,")"),ot===identityProjection?"none":ot}var compareByDepth=function(et,o){return et.depth-o.depth},FlatTree=function(){function et(){this.children=[],this.isDirty=!1}return et.prototype.add=function(o){addUniqueItem(this.children,o),this.isDirty=!0},et.prototype.remove=function(o){removeItem(this.children,o),this.isDirty=!0},et.prototype.forEach=function(o){this.isDirty&&this.children.sort(compareByDepth),this.isDirty=!1,this.children.forEach(o)},et}(),animationTarget=1e3;function createProjectionNode(et){var o=et.attachResizeListener,tt=et.defaultParent,rt=et.measureScroll,nt=et.checkIsScrollRoot,ot=et.resetTransform;return function(){function it(st,at,ct){var lt=this;at===void 0&&(at={}),ct===void 0&&(ct=tt==null?void 0:tt()),this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.potentialNodes=new Map,this.checkUpdateFailed=function(){lt.isUpdating&&(lt.isUpdating=!1,lt.clearAllSnapshots())},this.updateProjection=function(){lt.nodes.forEach(resolveTargetDelta),lt.nodes.forEach(calcProjection)},this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.id=st,this.latestValues=at,this.root=ct?ct.root||ct:this,this.path=ct?__spreadArray(__spreadArray([],__read(ct.path),!1),[ct],!1):[],this.parent=ct,this.depth=ct?ct.depth+1:0,st&&this.root.registerPotentialNode(st,this);for(var dt=0;dt=0;rt--)if(et.path[rt].instance){tt=et.path[rt];break}var nt=tt&&tt!==et.root?tt.instance:document,ot=nt.querySelector('[data-projection-id="'.concat(o,'"]'));ot&&et.mount(ot,!0)}function roundAxis(et){et.min=Math.round(et.min),et.max=Math.round(et.max)}function roundBox(et){roundAxis(et.x),roundAxis(et.y)}var DocumentProjectionNode=createProjectionNode({attachResizeListener:function(et,o){return addDomEvent(et,"resize",o)},measureScroll:function(){return{x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}},checkIsScrollRoot:function(){return!0}}),rootProjectionNode={current:void 0},HTMLProjectionNode=createProjectionNode({measureScroll:function(et){return{x:et.scrollLeft,y:et.scrollTop}},defaultParent:function(){if(!rootProjectionNode.current){var et=new DocumentProjectionNode(0,{});et.mount(window),et.setOptions({layoutScroll:!0}),rootProjectionNode.current=et}return rootProjectionNode.current},resetTransform:function(et,o){et.style.transform=o??"none"},checkIsScrollRoot:function(et){return window.getComputedStyle(et).position==="fixed"}}),featureBundle=__assign(__assign(__assign(__assign({},animations),gestureAnimations),drag),layoutFeatures),motion=createMotionProxy(function(et,o){return createDomMotionConfig(et,o,featureBundle,createDomVisualElement,HTMLProjectionNode)});function useIsMounted$1(){var et=reactExports.useRef(!1);return useIsomorphicLayoutEffect$3(function(){return et.current=!0,function(){et.current=!1}},[]),et}function useForceUpdate(){var et=useIsMounted$1(),o=__read(reactExports.useState(0),2),tt=o[0],rt=o[1],nt=reactExports.useCallback(function(){et.current&&rt(tt+1)},[tt]),ot=reactExports.useCallback(function(){return sync.postRender(nt)},[nt]);return[ot,tt]}var PresenceChild=function(et){var o=et.children,tt=et.initial,rt=et.isPresent,nt=et.onExitComplete,ot=et.custom,it=et.presenceAffectsLayout,st=useConstant(newChildrenMap),at=useId$1(),ct=reactExports.useMemo(function(){return{id:at,initial:tt,isPresent:rt,custom:ot,onExitComplete:function(lt){var dt,ht;st.set(lt,!0);try{for(var mt=__values(st.values()),ft=mt.next();!ft.done;ft=mt.next()){var pt=ft.value;if(!pt)return}}catch(gt){dt={error:gt}}finally{try{ft&&!ft.done&&(ht=mt.return)&&ht.call(mt)}finally{if(dt)throw dt.error}}nt==null||nt()},register:function(lt){return st.set(lt,!1),function(){return st.delete(lt)}}}},it?void 0:[rt]);return reactExports.useMemo(function(){st.forEach(function(lt,dt){return st.set(dt,!1)})},[rt]),reactExports.useEffect(function(){!rt&&!st.size&&(nt==null||nt())},[rt]),reactExports.createElement(PresenceContext.Provider,{value:ct},o)};function newChildrenMap(){return new Map}var getChildKey=function(et){return et.key||""};function updateChildLookup(et,o){et.forEach(function(tt){var rt=getChildKey(tt);o.set(rt,tt)})}function onlyElements(et){var o=[];return reactExports.Children.forEach(et,function(tt){reactExports.isValidElement(tt)&&o.push(tt)}),o}var AnimatePresence=function(et){var o=et.children,tt=et.custom,rt=et.initial,nt=rt===void 0?!0:rt,ot=et.onExitComplete,it=et.exitBeforeEnter,st=et.presenceAffectsLayout,at=st===void 0?!0:st,ct=__read(useForceUpdate(),1),lt=ct[0],dt=reactExports.useContext(LayoutGroupContext).forceRender;dt&&(lt=dt);var ht=useIsMounted$1(),mt=onlyElements(o),ft=mt,pt=new Set,gt=reactExports.useRef(ft),yt=reactExports.useRef(new Map).current,bt=reactExports.useRef(!0);if(useIsomorphicLayoutEffect$3(function(){bt.current=!1,updateChildLookup(mt,yt),gt.current=ft}),useUnmountEffect(function(){bt.current=!0,yt.clear(),pt.clear()}),bt.current)return reactExports.createElement(reactExports.Fragment,null,ft.map(function(At){return reactExports.createElement(PresenceChild,{key:getChildKey(At),isPresent:!0,initial:nt?void 0:!1,presenceAffectsLayout:at},At)}));ft=__spreadArray([],__read(ft),!1);for(var xt=gt.current.map(getChildKey),vt=mt.map(getChildKey),Et=xt.length,Ct=0;Ct1&&console.warn("You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour."),reactExports.createElement(reactExports.Fragment,null,pt.size?ft:ft.map(function(At){return reactExports.cloneElement(At)}))};function MotionConfig(et){var o=et.children,tt=et.isValidProp,rt=__rest(et,["children","isValidProp"]);tt&&loadExternalIsValidProp(tt),rt=__assign(__assign({},reactExports.useContext(MotionConfigContext)),rt),rt.isStatic=useConstant(function(){return rt.isStatic});var nt=reactExports.useMemo(function(){return rt},[JSON.stringify(rt.transition),rt.transformPagePoint,rt.reducedMotion]);return reactExports.createElement(MotionConfigContext.Provider,{value:nt},o)}var reactIs$2={exports:{}},reactIs_production_min$1={};/** + */var h$3=reactExports,n$2=shimExports;function p$2(et,o){return et===o&&(et!==0||1/et===1/o)||et!==et&&o!==o}var q$3=typeof Object.is=="function"?Object.is:p$2,r$3=n$2.useSyncExternalStore,t$2=h$3.useRef,u$1=h$3.useEffect,v$3=h$3.useMemo,w$3=h$3.useDebugValue;withSelector_production_min.useSyncExternalStoreWithSelector=function(et,o,tt,rt,nt){var ot=t$2(null);if(ot.current===null){var it={hasValue:!1,value:null};ot.current=it}else it=ot.current;ot=v$3(function(){function at(mt){if(!ct){if(ct=!0,lt=mt,mt=rt(mt),nt!==void 0&&it.hasValue){var ft=it.value;if(nt(ft,mt))return dt=ft}return dt=mt}if(ft=dt,q$3(lt,mt))return ft;var pt=rt(mt);return nt!==void 0&&nt(ft,pt)?ft:(lt=mt,dt=pt)}var ct=!1,lt,dt,ht=tt===void 0?null:tt;return[function(){return at(o())},ht===null?void 0:function(){return at(ht())}]},[o,tt,rt,nt]);var st=r$3(et,ot[0],ot[1]);return u$1(function(){it.hasValue=!0,it.value=st},[st]),w$3(st),st};withSelector.exports=withSelector_production_min;var withSelectorExports=withSelector.exports;const isPlainObject$4=et=>typeof et=="object"&&!Array.isArray(et);function useSyncExternalStoreWithTracked(et,o,tt=o,rt=deepEqual){const nt=reactExports.useRef([]),ot=withSelectorExports.useSyncExternalStoreWithSelector(et,o,tt,it=>it,(it,st)=>{if(isPlainObject$4(it)&&isPlainObject$4(st)&&nt.current.length){for(const at of nt.current)if(!rt(it[at],st[at]))return!1;return!0}return rt(it,st)});return reactExports.useMemo(()=>{if(isPlainObject$4(ot)){const it={...ot};let st={};for(const[at,ct]of Object.entries(it))st={...st,[at]:{configurable:!1,enumerable:!0,get:()=>(nt.current.includes(at)||nt.current.push(at),ct)}};return Object.defineProperties(it,st),it}return ot},[ot])}function useAccount(et={}){const o=useConfig(et);return useSyncExternalStoreWithTracked(tt=>watchAccount(o,{onChange:tt}),()=>getAccount(o))}function useAccountEffect(et={}){const{onConnect:o,onDisconnect:tt}=et,rt=useConfig(et);reactExports.useEffect(()=>watchAccount(rt,{onChange(nt,ot){if((ot.status==="reconnecting"||ot.status==="connecting"&&ot.address===void 0)&&nt.status==="connected"){const{address:it,addresses:st,chain:at,chainId:ct,connector:lt}=nt,dt=ot.status==="reconnecting"||ot.status===void 0;o==null||o({address:it,addresses:st,chain:at,chainId:ct,connector:lt,isReconnected:dt})}else ot.status==="connected"&&nt.status==="disconnected"&&(tt==null||tt())}}),[rt,o,tt])}var Subscribable=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(et){return this.listeners.add(et),this.onSubscribe(),()=>{this.listeners.delete(et),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},isServer=typeof window>"u"||"Deno"in globalThis;function noop$4(){}function functionalUpdate(et,o){return typeof et=="function"?et(o):et}function isValidTimeout(et){return typeof et=="number"&&et>=0&&et!==1/0}function timeUntilStale(et,o){return Math.max(et+(o||0)-Date.now(),0)}function resolveStaleTime(et,o){return typeof et=="function"?et(o):et}function resolveEnabled(et,o){return typeof et=="function"?et(o):et}function matchQuery(et,o){const{type:tt="all",exact:rt,fetchStatus:nt,predicate:ot,queryKey:it,stale:st}=et;if(it){if(rt){if(o.queryHash!==hashQueryKeyByOptions(it,o.options))return!1}else if(!partialMatchKey(o.queryKey,it))return!1}if(tt!=="all"){const at=o.isActive();if(tt==="active"&&!at||tt==="inactive"&&at)return!1}return!(typeof st=="boolean"&&o.isStale()!==st||nt&&nt!==o.state.fetchStatus||ot&&!ot(o))}function matchMutation(et,o){const{exact:tt,status:rt,predicate:nt,mutationKey:ot}=et;if(ot){if(!o.options.mutationKey)return!1;if(tt){if(hashKey(o.options.mutationKey)!==hashKey(ot))return!1}else if(!partialMatchKey(o.options.mutationKey,ot))return!1}return!(rt&&o.state.status!==rt||nt&&!nt(o))}function hashQueryKeyByOptions(et,o){return((o==null?void 0:o.queryKeyHashFn)||hashKey)(et)}function hashKey(et){return JSON.stringify(et,(o,tt)=>isPlainObject$3(tt)?Object.keys(tt).sort().reduce((rt,nt)=>(rt[nt]=tt[nt],rt),{}):tt)}function partialMatchKey(et,o){return et===o?!0:typeof et!=typeof o?!1:et&&o&&typeof et=="object"&&typeof o=="object"?!Object.keys(o).some(tt=>!partialMatchKey(et[tt],o[tt])):!1}function replaceEqualDeep(et,o){if(et===o)return et;const tt=isPlainArray(et)&&isPlainArray(o);if(tt||isPlainObject$3(et)&&isPlainObject$3(o)){const rt=tt?et:Object.keys(et),nt=rt.length,ot=tt?o:Object.keys(o),it=ot.length,st=tt?[]:{};let at=0;for(let ct=0;ct{setTimeout(o,et)})}function replaceData(et,o,tt){return typeof tt.structuralSharing=="function"?tt.structuralSharing(et,o):tt.structuralSharing!==!1?replaceEqualDeep(et,o):o}function addToEnd(et,o,tt=0){const rt=[...et,o];return tt&&rt.length>tt?rt.slice(1):rt}function addToStart(et,o,tt=0){const rt=[o,...et];return tt&&rt.length>tt?rt.slice(0,-1):rt}var skipToken=Symbol();function ensureQueryFn(et,o){return!et.queryFn&&(o!=null&&o.initialPromise)?()=>o.initialPromise:!et.queryFn||et.queryFn===skipToken?()=>Promise.reject(new Error(`Missing queryFn: '${et.queryHash}'`)):et.queryFn}var kn,hn,Mn,zs,FocusManager=(zs=class extends Subscribable{constructor(){super();fr(this,kn);fr(this,hn);fr(this,Mn);lr(this,Mn,o=>{if(!isServer&&window.addEventListener){const tt=()=>o();return window.addEventListener("visibilitychange",tt,!1),()=>{window.removeEventListener("visibilitychange",tt)}}})}onSubscribe(){Ot(this,hn)||this.setEventListener(Ot(this,Mn))}onUnsubscribe(){var o;this.hasListeners()||((o=Ot(this,hn))==null||o.call(this),lr(this,hn,void 0))}setEventListener(o){var tt;lr(this,Mn,o),(tt=Ot(this,hn))==null||tt.call(this),lr(this,hn,o(rt=>{typeof rt=="boolean"?this.setFocused(rt):this.onFocus()}))}setFocused(o){Ot(this,kn)!==o&&(lr(this,kn,o),this.onFocus())}onFocus(){const o=this.isFocused();this.listeners.forEach(tt=>{tt(o)})}isFocused(){var o;return typeof Ot(this,kn)=="boolean"?Ot(this,kn):((o=globalThis.document)==null?void 0:o.visibilityState)!=="hidden"}},kn=new WeakMap,hn=new WeakMap,Mn=new WeakMap,zs),focusManager=new FocusManager,Bn,fn,Fn,Vs,OnlineManager=(Vs=class extends Subscribable{constructor(){super();fr(this,Bn,!0);fr(this,fn);fr(this,Fn);lr(this,Fn,o=>{if(!isServer&&window.addEventListener){const tt=()=>o(!0),rt=()=>o(!1);return window.addEventListener("online",tt,!1),window.addEventListener("offline",rt,!1),()=>{window.removeEventListener("online",tt),window.removeEventListener("offline",rt)}}})}onSubscribe(){Ot(this,fn)||this.setEventListener(Ot(this,Fn))}onUnsubscribe(){var o;this.hasListeners()||((o=Ot(this,fn))==null||o.call(this),lr(this,fn,void 0))}setEventListener(o){var tt;lr(this,Fn,o),(tt=Ot(this,fn))==null||tt.call(this),lr(this,fn,o(this.setOnline.bind(this)))}setOnline(o){Ot(this,Bn)!==o&&(lr(this,Bn,o),this.listeners.forEach(rt=>{rt(o)}))}isOnline(){return Ot(this,Bn)}},Bn=new WeakMap,fn=new WeakMap,Fn=new WeakMap,Vs),onlineManager=new OnlineManager;function pendingThenable(){let et,o;const tt=new Promise((nt,ot)=>{et=nt,o=ot});tt.status="pending",tt.catch(()=>{});function rt(nt){Object.assign(tt,nt),delete tt.resolve,delete tt.reject}return tt.resolve=nt=>{rt({status:"fulfilled",value:nt}),et(nt)},tt.reject=nt=>{rt({status:"rejected",reason:nt}),o(nt)},tt}function defaultRetryDelay(et){return Math.min(1e3*2**et,3e4)}function canFetch(et){return(et??"online")==="online"?onlineManager.isOnline():!0}var CancelledError=class extends Error{constructor(et){super("CancelledError"),this.revert=et==null?void 0:et.revert,this.silent=et==null?void 0:et.silent}};function isCancelledError(et){return et instanceof CancelledError}function createRetryer(et){let o=!1,tt=0,rt=!1,nt;const ot=pendingThenable(),it=pt=>{var yt;rt||(ht(new CancelledError(pt)),(yt=et.abort)==null||yt.call(et))},st=()=>{o=!0},at=()=>{o=!1},ct=()=>focusManager.isFocused()&&(et.networkMode==="always"||onlineManager.isOnline())&&et.canRun(),lt=()=>canFetch(et.networkMode)&&et.canRun(),dt=pt=>{var yt;rt||(rt=!0,(yt=et.onSuccess)==null||yt.call(et,pt),nt==null||nt(),ot.resolve(pt))},ht=pt=>{var yt;rt||(rt=!0,(yt=et.onError)==null||yt.call(et,pt),nt==null||nt(),ot.reject(pt))},mt=()=>new Promise(pt=>{var yt;nt=gt=>{(rt||ct())&&pt(gt)},(yt=et.onPause)==null||yt.call(et)}).then(()=>{var pt;nt=void 0,rt||(pt=et.onContinue)==null||pt.call(et)}),ft=()=>{if(rt)return;let pt;const yt=tt===0?et.initialPromise:void 0;try{pt=yt??et.fn()}catch(gt){pt=Promise.reject(gt)}Promise.resolve(pt).then(dt).catch(gt=>{var Ct;if(rt)return;const bt=et.retry??(isServer?0:3),xt=et.retryDelay??defaultRetryDelay,vt=typeof xt=="function"?xt(tt,gt):xt,Et=bt===!0||typeof bt=="number"&&ttct()?void 0:mt()).then(()=>{o?ht(gt):ft()})})};return{promise:ot,cancel:it,continue:()=>(nt==null||nt(),ot),cancelRetry:st,continueRetry:at,canStart:lt,start:()=>(lt()?ft():mt().then(ft),ot)}}function createNotifyManager(){let et=[],o=0,tt=st=>{st()},rt=st=>{st()},nt=st=>setTimeout(st,0);const ot=st=>{o?et.push(st):nt(()=>{tt(st)})},it=()=>{const st=et;et=[],st.length&&nt(()=>{rt(()=>{st.forEach(at=>{tt(at)})})})};return{batch:st=>{let at;o++;try{at=st()}finally{o--,o||it()}return at},batchCalls:st=>(...at)=>{ot(()=>{st(...at)})},schedule:ot,setNotifyFunction:st=>{tt=st},setBatchNotifyFunction:st=>{rt=st},setScheduler:st=>{nt=st}}}var notifyManager=createNotifyManager(),Rn,Hs,Removable=(Hs=class{constructor(){fr(this,Rn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),isValidTimeout(this.gcTime)&&lr(this,Rn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(et){this.gcTime=Math.max(this.gcTime||0,et??(isServer?1/0:5*60*1e3))}clearGcTimeout(){Ot(this,Rn)&&(clearTimeout(Ot(this,Rn)),lr(this,Rn,void 0))}},Rn=new WeakMap,Hs),Un,zn,Vr,Lr,io,_n,Gr,nn,Ws,Query=(Ws=class extends Removable{constructor(o){super();fr(this,Gr);fr(this,Un);fr(this,zn);fr(this,Vr);fr(this,Lr);fr(this,io);fr(this,_n);lr(this,_n,!1),lr(this,io,o.defaultOptions),this.setOptions(o.options),this.observers=[],lr(this,Vr,o.cache),this.queryKey=o.queryKey,this.queryHash=o.queryHash,lr(this,Un,getDefaultState$1(this.options)),this.state=o.state??Ot(this,Un),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var o;return(o=Ot(this,Lr))==null?void 0:o.promise}setOptions(o){this.options={...Ot(this,io),...o},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&Ot(this,Vr).remove(this)}setData(o,tt){const rt=replaceData(this.state.data,o,this.options);return mr(this,Gr,nn).call(this,{data:rt,type:"success",dataUpdatedAt:tt==null?void 0:tt.updatedAt,manual:tt==null?void 0:tt.manual}),rt}setState(o,tt){mr(this,Gr,nn).call(this,{type:"setState",state:o,setStateOptions:tt})}cancel(o){var rt,nt;const tt=(rt=Ot(this,Lr))==null?void 0:rt.promise;return(nt=Ot(this,Lr))==null||nt.cancel(o),tt?tt.then(noop$4).catch(noop$4):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Ot(this,Un))}isActive(){return this.observers.some(o=>resolveEnabled(o.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===skipToken||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(o=>o.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(o=0){return this.state.isInvalidated||this.state.data===void 0||!timeUntilStale(this.state.dataUpdatedAt,o)}onFocus(){var tt;const o=this.observers.find(rt=>rt.shouldFetchOnWindowFocus());o==null||o.refetch({cancelRefetch:!1}),(tt=Ot(this,Lr))==null||tt.continue()}onOnline(){var tt;const o=this.observers.find(rt=>rt.shouldFetchOnReconnect());o==null||o.refetch({cancelRefetch:!1}),(tt=Ot(this,Lr))==null||tt.continue()}addObserver(o){this.observers.includes(o)||(this.observers.push(o),this.clearGcTimeout(),Ot(this,Vr).notify({type:"observerAdded",query:this,observer:o}))}removeObserver(o){this.observers.includes(o)&&(this.observers=this.observers.filter(tt=>tt!==o),this.observers.length||(Ot(this,Lr)&&(Ot(this,_n)?Ot(this,Lr).cancel({revert:!0}):Ot(this,Lr).cancelRetry()),this.scheduleGc()),Ot(this,Vr).notify({type:"observerRemoved",query:this,observer:o}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||mr(this,Gr,nn).call(this,{type:"invalidate"})}fetch(o,tt){var at,ct,lt;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(tt!=null&&tt.cancelRefetch))this.cancel({silent:!0});else if(Ot(this,Lr))return Ot(this,Lr).continueRetry(),Ot(this,Lr).promise}if(o&&this.setOptions(o),!this.options.queryFn){const dt=this.observers.find(ht=>ht.options.queryFn);dt&&this.setOptions(dt.options)}const rt=new AbortController,nt=dt=>{Object.defineProperty(dt,"signal",{enumerable:!0,get:()=>(lr(this,_n,!0),rt.signal)})},ot=()=>{const dt=ensureQueryFn(this.options,tt),ht={queryKey:this.queryKey,meta:this.meta};return nt(ht),lr(this,_n,!1),this.options.persister?this.options.persister(dt,ht,this):dt(ht)},it={fetchOptions:tt,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:ot};nt(it),(at=this.options.behavior)==null||at.onFetch(it,this),lr(this,zn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((ct=it.fetchOptions)==null?void 0:ct.meta))&&mr(this,Gr,nn).call(this,{type:"fetch",meta:(lt=it.fetchOptions)==null?void 0:lt.meta});const st=dt=>{var ht,mt,ft,pt;isCancelledError(dt)&&dt.silent||mr(this,Gr,nn).call(this,{type:"error",error:dt}),isCancelledError(dt)||((mt=(ht=Ot(this,Vr).config).onError)==null||mt.call(ht,dt,this),(pt=(ft=Ot(this,Vr).config).onSettled)==null||pt.call(ft,this.state.data,dt,this)),this.scheduleGc()};return lr(this,Lr,createRetryer({initialPromise:tt==null?void 0:tt.initialPromise,fn:it.fetchFn,abort:rt.abort.bind(rt),onSuccess:dt=>{var ht,mt,ft,pt;if(dt===void 0){st(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(dt)}catch(yt){st(yt);return}(mt=(ht=Ot(this,Vr).config).onSuccess)==null||mt.call(ht,dt,this),(pt=(ft=Ot(this,Vr).config).onSettled)==null||pt.call(ft,dt,this.state.error,this),this.scheduleGc()},onError:st,onFail:(dt,ht)=>{mr(this,Gr,nn).call(this,{type:"failed",failureCount:dt,error:ht})},onPause:()=>{mr(this,Gr,nn).call(this,{type:"pause"})},onContinue:()=>{mr(this,Gr,nn).call(this,{type:"continue"})},retry:it.options.retry,retryDelay:it.options.retryDelay,networkMode:it.options.networkMode,canRun:()=>!0})),Ot(this,Lr).start()}},Un=new WeakMap,zn=new WeakMap,Vr=new WeakMap,Lr=new WeakMap,io=new WeakMap,_n=new WeakMap,Gr=new WeakSet,nn=function(o){const tt=rt=>{switch(o.type){case"failed":return{...rt,fetchFailureCount:o.failureCount,fetchFailureReason:o.error};case"pause":return{...rt,fetchStatus:"paused"};case"continue":return{...rt,fetchStatus:"fetching"};case"fetch":return{...rt,...fetchState(rt.data,this.options),fetchMeta:o.meta??null};case"success":return{...rt,data:o.data,dataUpdateCount:rt.dataUpdateCount+1,dataUpdatedAt:o.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!o.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const nt=o.error;return isCancelledError(nt)&&nt.revert&&Ot(this,zn)?{...Ot(this,zn),fetchStatus:"idle"}:{...rt,error:nt,errorUpdateCount:rt.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:rt.fetchFailureCount+1,fetchFailureReason:nt,fetchStatus:"idle",status:"error"};case"invalidate":return{...rt,isInvalidated:!0};case"setState":return{...rt,...o.state}}};this.state=tt(this.state),notifyManager.batch(()=>{this.observers.forEach(rt=>{rt.onQueryUpdate()}),Ot(this,Vr).notify({query:this,type:"updated",action:o})})},Ws);function fetchState(et,o){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:canFetch(o.networkMode)?"fetching":"paused",...et===void 0&&{error:null,status:"pending"}}}function getDefaultState$1(et){const o=typeof et.initialData=="function"?et.initialData():et.initialData,tt=o!==void 0,rt=tt?typeof et.initialDataUpdatedAt=="function"?et.initialDataUpdatedAt():et.initialDataUpdatedAt:0;return{data:o,dataUpdateCount:0,dataUpdatedAt:tt?rt??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:tt?"success":"pending",fetchStatus:"idle"}}var qr,Gs,QueryCache=(Gs=class extends Subscribable{constructor(o={}){super();fr(this,qr);this.config=o,lr(this,qr,new Map)}build(o,tt,rt){const nt=tt.queryKey,ot=tt.queryHash??hashQueryKeyByOptions(nt,tt);let it=this.get(ot);return it||(it=new Query({cache:this,queryKey:nt,queryHash:ot,options:o.defaultQueryOptions(tt),state:rt,defaultOptions:o.getQueryDefaults(nt)}),this.add(it)),it}add(o){Ot(this,qr).has(o.queryHash)||(Ot(this,qr).set(o.queryHash,o),this.notify({type:"added",query:o}))}remove(o){const tt=Ot(this,qr).get(o.queryHash);tt&&(o.destroy(),tt===o&&Ot(this,qr).delete(o.queryHash),this.notify({type:"removed",query:o}))}clear(){notifyManager.batch(()=>{this.getAll().forEach(o=>{this.remove(o)})})}get(o){return Ot(this,qr).get(o)}getAll(){return[...Ot(this,qr).values()]}find(o){const tt={exact:!0,...o};return this.getAll().find(rt=>matchQuery(tt,rt))}findAll(o={}){const tt=this.getAll();return Object.keys(o).length>0?tt.filter(rt=>matchQuery(o,rt)):tt}notify(o){notifyManager.batch(()=>{this.listeners.forEach(tt=>{tt(o)})})}onFocus(){notifyManager.batch(()=>{this.getAll().forEach(o=>{o.onFocus()})})}onOnline(){notifyManager.batch(()=>{this.getAll().forEach(o=>{o.onOnline()})})}},qr=new WeakMap,Gs),Kr,Or,Tn,Qr,un,qs,Mutation=(qs=class extends Removable{constructor(o){super();fr(this,Qr);fr(this,Kr);fr(this,Or);fr(this,Tn);this.mutationId=o.mutationId,lr(this,Or,o.mutationCache),lr(this,Kr,[]),this.state=o.state||getDefaultState(),this.setOptions(o.options),this.scheduleGc()}setOptions(o){this.options=o,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(o){Ot(this,Kr).includes(o)||(Ot(this,Kr).push(o),this.clearGcTimeout(),Ot(this,Or).notify({type:"observerAdded",mutation:this,observer:o}))}removeObserver(o){lr(this,Kr,Ot(this,Kr).filter(tt=>tt!==o)),this.scheduleGc(),Ot(this,Or).notify({type:"observerRemoved",mutation:this,observer:o})}optionalRemove(){Ot(this,Kr).length||(this.state.status==="pending"?this.scheduleGc():Ot(this,Or).remove(this))}continue(){var o;return((o=Ot(this,Tn))==null?void 0:o.continue())??this.execute(this.state.variables)}async execute(o){var nt,ot,it,st,at,ct,lt,dt,ht,mt,ft,pt,yt,gt,bt,xt,vt,Et,Ct,St;lr(this,Tn,createRetryer({fn:()=>this.options.mutationFn?this.options.mutationFn(o):Promise.reject(new Error("No mutationFn found")),onFail:(At,kt)=>{mr(this,Qr,un).call(this,{type:"failed",failureCount:At,error:kt})},onPause:()=>{mr(this,Qr,un).call(this,{type:"pause"})},onContinue:()=>{mr(this,Qr,un).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Ot(this,Or).canRun(this)}));const tt=this.state.status==="pending",rt=!Ot(this,Tn).canStart();try{if(!tt){mr(this,Qr,un).call(this,{type:"pending",variables:o,isPaused:rt}),await((ot=(nt=Ot(this,Or).config).onMutate)==null?void 0:ot.call(nt,o,this));const kt=await((st=(it=this.options).onMutate)==null?void 0:st.call(it,o));kt!==this.state.context&&mr(this,Qr,un).call(this,{type:"pending",context:kt,variables:o,isPaused:rt})}const At=await Ot(this,Tn).start();return await((ct=(at=Ot(this,Or).config).onSuccess)==null?void 0:ct.call(at,At,o,this.state.context,this)),await((dt=(lt=this.options).onSuccess)==null?void 0:dt.call(lt,At,o,this.state.context)),await((mt=(ht=Ot(this,Or).config).onSettled)==null?void 0:mt.call(ht,At,null,this.state.variables,this.state.context,this)),await((pt=(ft=this.options).onSettled)==null?void 0:pt.call(ft,At,null,o,this.state.context)),mr(this,Qr,un).call(this,{type:"success",data:At}),At}catch(At){try{throw await((gt=(yt=Ot(this,Or).config).onError)==null?void 0:gt.call(yt,At,o,this.state.context,this)),await((xt=(bt=this.options).onError)==null?void 0:xt.call(bt,At,o,this.state.context)),await((Et=(vt=Ot(this,Or).config).onSettled)==null?void 0:Et.call(vt,void 0,At,this.state.variables,this.state.context,this)),await((St=(Ct=this.options).onSettled)==null?void 0:St.call(Ct,void 0,At,o,this.state.context)),At}finally{mr(this,Qr,un).call(this,{type:"error",error:At})}}finally{Ot(this,Or).runNext(this)}}},Kr=new WeakMap,Or=new WeakMap,Tn=new WeakMap,Qr=new WeakSet,un=function(o){const tt=rt=>{switch(o.type){case"failed":return{...rt,failureCount:o.failureCount,failureReason:o.error};case"pause":return{...rt,isPaused:!0};case"continue":return{...rt,isPaused:!1};case"pending":return{...rt,context:o.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:o.isPaused,status:"pending",variables:o.variables,submittedAt:Date.now()};case"success":return{...rt,data:o.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...rt,data:void 0,error:o.error,failureCount:rt.failureCount+1,failureReason:o.error,isPaused:!1,status:"error"}}};this.state=tt(this.state),notifyManager.batch(()=>{Ot(this,Kr).forEach(rt=>{rt.onMutationUpdate(o)}),Ot(this,Or).notify({mutation:this,type:"updated",action:o})})},qs);function getDefaultState(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zr,so,Ks,MutationCache=(Ks=class extends Subscribable{constructor(o={}){super();fr(this,zr);fr(this,so);this.config=o,lr(this,zr,new Map),lr(this,so,Date.now())}build(o,tt,rt){const nt=new Mutation({mutationCache:this,mutationId:++Cn(this,so)._,options:o.defaultMutationOptions(tt),state:rt});return this.add(nt),nt}add(o){const tt=scopeFor(o),rt=Ot(this,zr).get(tt)??[];rt.push(o),Ot(this,zr).set(tt,rt),this.notify({type:"added",mutation:o})}remove(o){var rt;const tt=scopeFor(o);if(Ot(this,zr).has(tt)){const nt=(rt=Ot(this,zr).get(tt))==null?void 0:rt.filter(ot=>ot!==o);nt&&(nt.length===0?Ot(this,zr).delete(tt):Ot(this,zr).set(tt,nt))}this.notify({type:"removed",mutation:o})}canRun(o){var rt;const tt=(rt=Ot(this,zr).get(scopeFor(o)))==null?void 0:rt.find(nt=>nt.state.status==="pending");return!tt||tt===o}runNext(o){var rt;const tt=(rt=Ot(this,zr).get(scopeFor(o)))==null?void 0:rt.find(nt=>nt!==o&&nt.state.isPaused);return(tt==null?void 0:tt.continue())??Promise.resolve()}clear(){notifyManager.batch(()=>{this.getAll().forEach(o=>{this.remove(o)})})}getAll(){return[...Ot(this,zr).values()].flat()}find(o){const tt={exact:!0,...o};return this.getAll().find(rt=>matchMutation(tt,rt))}findAll(o={}){return this.getAll().filter(tt=>matchMutation(o,tt))}notify(o){notifyManager.batch(()=>{this.listeners.forEach(tt=>{tt(o)})})}resumePausedMutations(){const o=this.getAll().filter(tt=>tt.state.isPaused);return notifyManager.batch(()=>Promise.all(o.map(tt=>tt.continue().catch(noop$4))))}},zr=new WeakMap,so=new WeakMap,Ks);function scopeFor(et){var o;return((o=et.options.scope)==null?void 0:o.id)??String(et.mutationId)}function infiniteQueryBehavior(et){return{onFetch:(o,tt)=>{var lt,dt,ht,mt,ft;const rt=o.options,nt=(ht=(dt=(lt=o.fetchOptions)==null?void 0:lt.meta)==null?void 0:dt.fetchMore)==null?void 0:ht.direction,ot=((mt=o.state.data)==null?void 0:mt.pages)||[],it=((ft=o.state.data)==null?void 0:ft.pageParams)||[];let st={pages:[],pageParams:[]},at=0;const ct=async()=>{let pt=!1;const yt=xt=>{Object.defineProperty(xt,"signal",{enumerable:!0,get:()=>(o.signal.aborted?pt=!0:o.signal.addEventListener("abort",()=>{pt=!0}),o.signal)})},gt=ensureQueryFn(o.options,o.fetchOptions),bt=async(xt,vt,Et)=>{if(pt)return Promise.reject();if(vt==null&&xt.pages.length)return Promise.resolve(xt);const Ct={queryKey:o.queryKey,pageParam:vt,direction:Et?"backward":"forward",meta:o.options.meta};yt(Ct);const St=await gt(Ct),{maxPages:At}=o.options,kt=Et?addToStart:addToEnd;return{pages:kt(xt.pages,St,At),pageParams:kt(xt.pageParams,vt,At)}};if(nt&&ot.length){const xt=nt==="backward",vt=xt?getPreviousPageParam:getNextPageParam,Et={pages:ot,pageParams:it},Ct=vt(rt,Et);st=await bt(Et,Ct,xt)}else{const xt=et??ot.length;do{const vt=at===0?it[0]??rt.initialPageParam:getNextPageParam(rt,st);if(at>0&&vt==null)break;st=await bt(st,vt),at++}while(at{var pt,yt;return(yt=(pt=o.options).persister)==null?void 0:yt.call(pt,ct,{queryKey:o.queryKey,meta:o.options.meta,signal:o.signal},tt)}:o.fetchFn=ct}}}function getNextPageParam(et,{pages:o,pageParams:tt}){const rt=o.length-1;return o.length>0?et.getNextPageParam(o[rt],o,tt[rt],tt):void 0}function getPreviousPageParam(et,{pages:o,pageParams:tt}){var rt;return o.length>0?(rt=et.getPreviousPageParam)==null?void 0:rt.call(et,o[0],o,tt[0],tt):void 0}var Pr,pn,mn,Vn,Hn,gn,Wn,Gn,Qs,QueryClient=(Qs=class{constructor(et={}){fr(this,Pr);fr(this,pn);fr(this,mn);fr(this,Vn);fr(this,Hn);fr(this,gn);fr(this,Wn);fr(this,Gn);lr(this,Pr,et.queryCache||new QueryCache),lr(this,pn,et.mutationCache||new MutationCache),lr(this,mn,et.defaultOptions||{}),lr(this,Vn,new Map),lr(this,Hn,new Map),lr(this,gn,0)}mount(){Cn(this,gn)._++,Ot(this,gn)===1&&(lr(this,Wn,focusManager.subscribe(async et=>{et&&(await this.resumePausedMutations(),Ot(this,Pr).onFocus())})),lr(this,Gn,onlineManager.subscribe(async et=>{et&&(await this.resumePausedMutations(),Ot(this,Pr).onOnline())})))}unmount(){var et,o;Cn(this,gn)._--,Ot(this,gn)===0&&((et=Ot(this,Wn))==null||et.call(this),lr(this,Wn,void 0),(o=Ot(this,Gn))==null||o.call(this),lr(this,Gn,void 0))}isFetching(et){return Ot(this,Pr).findAll({...et,fetchStatus:"fetching"}).length}isMutating(et){return Ot(this,pn).findAll({...et,status:"pending"}).length}getQueryData(et){var tt;const o=this.defaultQueryOptions({queryKey:et});return(tt=Ot(this,Pr).get(o.queryHash))==null?void 0:tt.state.data}ensureQueryData(et){const o=this.getQueryData(et.queryKey);if(o===void 0)return this.fetchQuery(et);{const tt=this.defaultQueryOptions(et),rt=Ot(this,Pr).build(this,tt);return et.revalidateIfStale&&rt.isStaleByTime(resolveStaleTime(tt.staleTime,rt))&&this.prefetchQuery(tt),Promise.resolve(o)}}getQueriesData(et){return Ot(this,Pr).findAll(et).map(({queryKey:o,state:tt})=>{const rt=tt.data;return[o,rt]})}setQueryData(et,o,tt){const rt=this.defaultQueryOptions({queryKey:et}),nt=Ot(this,Pr).get(rt.queryHash),ot=nt==null?void 0:nt.state.data,it=functionalUpdate(o,ot);if(it!==void 0)return Ot(this,Pr).build(this,rt).setData(it,{...tt,manual:!0})}setQueriesData(et,o,tt){return notifyManager.batch(()=>Ot(this,Pr).findAll(et).map(({queryKey:rt})=>[rt,this.setQueryData(rt,o,tt)]))}getQueryState(et){var tt;const o=this.defaultQueryOptions({queryKey:et});return(tt=Ot(this,Pr).get(o.queryHash))==null?void 0:tt.state}removeQueries(et){const o=Ot(this,Pr);notifyManager.batch(()=>{o.findAll(et).forEach(tt=>{o.remove(tt)})})}resetQueries(et,o){const tt=Ot(this,Pr),rt={type:"active",...et};return notifyManager.batch(()=>(tt.findAll(et).forEach(nt=>{nt.reset()}),this.refetchQueries(rt,o)))}cancelQueries(et={},o={}){const tt={revert:!0,...o},rt=notifyManager.batch(()=>Ot(this,Pr).findAll(et).map(nt=>nt.cancel(tt)));return Promise.all(rt).then(noop$4).catch(noop$4)}invalidateQueries(et={},o={}){return notifyManager.batch(()=>{if(Ot(this,Pr).findAll(et).forEach(rt=>{rt.invalidate()}),et.refetchType==="none")return Promise.resolve();const tt={...et,type:et.refetchType??et.type??"active"};return this.refetchQueries(tt,o)})}refetchQueries(et={},o){const tt={...o,cancelRefetch:(o==null?void 0:o.cancelRefetch)??!0},rt=notifyManager.batch(()=>Ot(this,Pr).findAll(et).filter(nt=>!nt.isDisabled()).map(nt=>{let ot=nt.fetch(void 0,tt);return tt.throwOnError||(ot=ot.catch(noop$4)),nt.state.fetchStatus==="paused"?Promise.resolve():ot}));return Promise.all(rt).then(noop$4)}fetchQuery(et){const o=this.defaultQueryOptions(et);o.retry===void 0&&(o.retry=!1);const tt=Ot(this,Pr).build(this,o);return tt.isStaleByTime(resolveStaleTime(o.staleTime,tt))?tt.fetch(o):Promise.resolve(tt.state.data)}prefetchQuery(et){return this.fetchQuery(et).then(noop$4).catch(noop$4)}fetchInfiniteQuery(et){return et.behavior=infiniteQueryBehavior(et.pages),this.fetchQuery(et)}prefetchInfiniteQuery(et){return this.fetchInfiniteQuery(et).then(noop$4).catch(noop$4)}ensureInfiniteQueryData(et){return et.behavior=infiniteQueryBehavior(et.pages),this.ensureQueryData(et)}resumePausedMutations(){return onlineManager.isOnline()?Ot(this,pn).resumePausedMutations():Promise.resolve()}getQueryCache(){return Ot(this,Pr)}getMutationCache(){return Ot(this,pn)}getDefaultOptions(){return Ot(this,mn)}setDefaultOptions(et){lr(this,mn,et)}setQueryDefaults(et,o){Ot(this,Vn).set(hashKey(et),{queryKey:et,defaultOptions:o})}getQueryDefaults(et){const o=[...Ot(this,Vn).values()];let tt={};return o.forEach(rt=>{partialMatchKey(et,rt.queryKey)&&(tt={...tt,...rt.defaultOptions})}),tt}setMutationDefaults(et,o){Ot(this,Hn).set(hashKey(et),{mutationKey:et,defaultOptions:o})}getMutationDefaults(et){const o=[...Ot(this,Hn).values()];let tt={};return o.forEach(rt=>{partialMatchKey(et,rt.mutationKey)&&(tt={...tt,...rt.defaultOptions})}),tt}defaultQueryOptions(et){if(et._defaulted)return et;const o={...Ot(this,mn).queries,...this.getQueryDefaults(et.queryKey),...et,_defaulted:!0};return o.queryHash||(o.queryHash=hashQueryKeyByOptions(o.queryKey,o)),o.refetchOnReconnect===void 0&&(o.refetchOnReconnect=o.networkMode!=="always"),o.throwOnError===void 0&&(o.throwOnError=!!o.suspense),!o.networkMode&&o.persister&&(o.networkMode="offlineFirst"),o.enabled!==!0&&o.queryFn===skipToken&&(o.enabled=!1),o}defaultMutationOptions(et){return et!=null&&et._defaulted?et:{...Ot(this,mn).mutations,...(et==null?void 0:et.mutationKey)&&this.getMutationDefaults(et.mutationKey),...et,_defaulted:!0}}clear(){Ot(this,Pr).clear(),Ot(this,pn).clear()}},Pr=new WeakMap,pn=new WeakMap,mn=new WeakMap,Vn=new WeakMap,Hn=new WeakMap,gn=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,Qs),Br,Cr,ao,Mr,In,qn,bn,Xr,co,Kn,Qn,Pn,jn,yn,Xn,Rr,oo,Ts,Is,Ps,js,Ns,Ds,Ls,tu,Xs,QueryObserver=(Xs=class extends Subscribable{constructor(o,tt){super();fr(this,Rr);fr(this,Br);fr(this,Cr);fr(this,ao);fr(this,Mr);fr(this,In);fr(this,qn);fr(this,bn);fr(this,Xr);fr(this,co);fr(this,Kn);fr(this,Qn);fr(this,Pn);fr(this,jn);fr(this,yn);fr(this,Xn,new Set);this.options=tt,lr(this,Br,o),lr(this,Xr,null),lr(this,bn,pendingThenable()),this.options.experimental_prefetchInRender||Ot(this,bn).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(tt)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(Ot(this,Cr).addObserver(this),shouldFetchOnMount(Ot(this,Cr),this.options)?mr(this,Rr,oo).call(this):this.updateResult(),mr(this,Rr,js).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return shouldFetchOn(Ot(this,Cr),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return shouldFetchOn(Ot(this,Cr),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,mr(this,Rr,Ns).call(this),mr(this,Rr,Ds).call(this),Ot(this,Cr).removeObserver(this)}setOptions(o,tt){const rt=this.options,nt=Ot(this,Cr);if(this.options=Ot(this,Br).defaultQueryOptions(o),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof resolveEnabled(this.options.enabled,Ot(this,Cr))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");mr(this,Rr,Ls).call(this),Ot(this,Cr).setOptions(this.options),rt._defaulted&&!shallowEqualObjects(this.options,rt)&&Ot(this,Br).getQueryCache().notify({type:"observerOptionsUpdated",query:Ot(this,Cr),observer:this});const ot=this.hasListeners();ot&&shouldFetchOptionally(Ot(this,Cr),nt,this.options,rt)&&mr(this,Rr,oo).call(this),this.updateResult(tt),ot&&(Ot(this,Cr)!==nt||resolveEnabled(this.options.enabled,Ot(this,Cr))!==resolveEnabled(rt.enabled,Ot(this,Cr))||resolveStaleTime(this.options.staleTime,Ot(this,Cr))!==resolveStaleTime(rt.staleTime,Ot(this,Cr)))&&mr(this,Rr,Ts).call(this);const it=mr(this,Rr,Is).call(this);ot&&(Ot(this,Cr)!==nt||resolveEnabled(this.options.enabled,Ot(this,Cr))!==resolveEnabled(rt.enabled,Ot(this,Cr))||it!==Ot(this,yn))&&mr(this,Rr,Ps).call(this,it)}getOptimisticResult(o){const tt=Ot(this,Br).getQueryCache().build(Ot(this,Br),o),rt=this.createResult(tt,o);return shouldAssignObserverCurrentProperties(this,rt)&&(lr(this,Mr,rt),lr(this,qn,this.options),lr(this,In,Ot(this,Cr).state)),rt}getCurrentResult(){return Ot(this,Mr)}trackResult(o,tt){const rt={};return Object.keys(o).forEach(nt=>{Object.defineProperty(rt,nt,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(nt),tt==null||tt(nt),o[nt])})}),rt}trackProp(o){Ot(this,Xn).add(o)}getCurrentQuery(){return Ot(this,Cr)}refetch({...o}={}){return this.fetch({...o})}fetchOptimistic(o){const tt=Ot(this,Br).defaultQueryOptions(o),rt=Ot(this,Br).getQueryCache().build(Ot(this,Br),tt);return rt.fetch().then(()=>this.createResult(rt,tt))}fetch(o){return mr(this,Rr,oo).call(this,{...o,cancelRefetch:o.cancelRefetch??!0}).then(()=>(this.updateResult(),Ot(this,Mr)))}createResult(o,tt){var At;const rt=Ot(this,Cr),nt=this.options,ot=Ot(this,Mr),it=Ot(this,In),st=Ot(this,qn),ct=o!==rt?o.state:Ot(this,ao),{state:lt}=o;let dt={...lt},ht=!1,mt;if(tt._optimisticResults){const kt=this.hasListeners(),It=!kt&&shouldFetchOnMount(o,tt),Nt=kt&&shouldFetchOptionally(o,rt,tt,nt);(It||Nt)&&(dt={...dt,...fetchState(lt.data,o.options)}),tt._optimisticResults==="isRestoring"&&(dt.fetchStatus="idle")}let{error:ft,errorUpdatedAt:pt,status:yt}=dt;if(tt.select&&dt.data!==void 0)if(ot&&dt.data===(it==null?void 0:it.data)&&tt.select===Ot(this,co))mt=Ot(this,Kn);else try{lr(this,co,tt.select),mt=tt.select(dt.data),mt=replaceData(ot==null?void 0:ot.data,mt,tt),lr(this,Kn,mt),lr(this,Xr,null)}catch(kt){lr(this,Xr,kt)}else mt=dt.data;if(tt.placeholderData!==void 0&&mt===void 0&&yt==="pending"){let kt;if(ot!=null&&ot.isPlaceholderData&&tt.placeholderData===(st==null?void 0:st.placeholderData))kt=ot.data;else if(kt=typeof tt.placeholderData=="function"?tt.placeholderData((At=Ot(this,Qn))==null?void 0:At.state.data,Ot(this,Qn)):tt.placeholderData,tt.select&&kt!==void 0)try{kt=tt.select(kt),lr(this,Xr,null)}catch(It){lr(this,Xr,It)}kt!==void 0&&(yt="success",mt=replaceData(ot==null?void 0:ot.data,kt,tt),ht=!0)}Ot(this,Xr)&&(ft=Ot(this,Xr),mt=Ot(this,Kn),pt=Date.now(),yt="error");const gt=dt.fetchStatus==="fetching",bt=yt==="pending",xt=yt==="error",vt=bt&>,Et=mt!==void 0,St={status:yt,fetchStatus:dt.fetchStatus,isPending:bt,isSuccess:yt==="success",isError:xt,isInitialLoading:vt,isLoading:vt,data:mt,dataUpdatedAt:dt.dataUpdatedAt,error:ft,errorUpdatedAt:pt,failureCount:dt.fetchFailureCount,failureReason:dt.fetchFailureReason,errorUpdateCount:dt.errorUpdateCount,isFetched:dt.dataUpdateCount>0||dt.errorUpdateCount>0,isFetchedAfterMount:dt.dataUpdateCount>ct.dataUpdateCount||dt.errorUpdateCount>ct.errorUpdateCount,isFetching:gt,isRefetching:gt&&!bt,isLoadingError:xt&&!Et,isPaused:dt.fetchStatus==="paused",isPlaceholderData:ht,isRefetchError:xt&&Et,isStale:isStale(o,tt),refetch:this.refetch,promise:Ot(this,bn)};if(this.options.experimental_prefetchInRender){const kt=Lt=>{St.status==="error"?Lt.reject(St.error):St.data!==void 0&&Lt.resolve(St.data)},It=()=>{const Lt=lr(this,bn,St.promise=pendingThenable());kt(Lt)},Nt=Ot(this,bn);switch(Nt.status){case"pending":o.queryHash===rt.queryHash&&kt(Nt);break;case"fulfilled":(St.status==="error"||St.data!==Nt.value)&&It();break;case"rejected":(St.status!=="error"||St.error!==Nt.reason)&&It();break}}return St}updateResult(o){const tt=Ot(this,Mr),rt=this.createResult(Ot(this,Cr),this.options);if(lr(this,In,Ot(this,Cr).state),lr(this,qn,this.options),Ot(this,In).data!==void 0&&lr(this,Qn,Ot(this,Cr)),shallowEqualObjects(rt,tt))return;lr(this,Mr,rt);const nt={},ot=()=>{if(!tt)return!0;const{notifyOnChangeProps:it}=this.options,st=typeof it=="function"?it():it;if(st==="all"||!st&&!Ot(this,Xn).size)return!0;const at=new Set(st??Ot(this,Xn));return this.options.throwOnError&&at.add("error"),Object.keys(Ot(this,Mr)).some(ct=>{const lt=ct;return Ot(this,Mr)[lt]!==tt[lt]&&at.has(lt)})};(o==null?void 0:o.listeners)!==!1&&ot()&&(nt.listeners=!0),mr(this,Rr,tu).call(this,{...nt,...o})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&mr(this,Rr,js).call(this)}},Br=new WeakMap,Cr=new WeakMap,ao=new WeakMap,Mr=new WeakMap,In=new WeakMap,qn=new WeakMap,bn=new WeakMap,Xr=new WeakMap,co=new WeakMap,Kn=new WeakMap,Qn=new WeakMap,Pn=new WeakMap,jn=new WeakMap,yn=new WeakMap,Xn=new WeakMap,Rr=new WeakSet,oo=function(o){mr(this,Rr,Ls).call(this);let tt=Ot(this,Cr).fetch(this.options,o);return o!=null&&o.throwOnError||(tt=tt.catch(noop$4)),tt},Ts=function(){mr(this,Rr,Ns).call(this);const o=resolveStaleTime(this.options.staleTime,Ot(this,Cr));if(isServer||Ot(this,Mr).isStale||!isValidTimeout(o))return;const rt=timeUntilStale(Ot(this,Mr).dataUpdatedAt,o)+1;lr(this,Pn,setTimeout(()=>{Ot(this,Mr).isStale||this.updateResult()},rt))},Is=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(Ot(this,Cr)):this.options.refetchInterval)??!1},Ps=function(o){mr(this,Rr,Ds).call(this),lr(this,yn,o),!(isServer||resolveEnabled(this.options.enabled,Ot(this,Cr))===!1||!isValidTimeout(Ot(this,yn))||Ot(this,yn)===0)&&lr(this,jn,setInterval(()=>{(this.options.refetchIntervalInBackground||focusManager.isFocused())&&mr(this,Rr,oo).call(this)},Ot(this,yn)))},js=function(){mr(this,Rr,Ts).call(this),mr(this,Rr,Ps).call(this,mr(this,Rr,Is).call(this))},Ns=function(){Ot(this,Pn)&&(clearTimeout(Ot(this,Pn)),lr(this,Pn,void 0))},Ds=function(){Ot(this,jn)&&(clearInterval(Ot(this,jn)),lr(this,jn,void 0))},Ls=function(){const o=Ot(this,Br).getQueryCache().build(Ot(this,Br),this.options);if(o===Ot(this,Cr))return;const tt=Ot(this,Cr);lr(this,Cr,o),lr(this,ao,o.state),this.hasListeners()&&(tt==null||tt.removeObserver(this),o.addObserver(this))},tu=function(o){notifyManager.batch(()=>{o.listeners&&this.listeners.forEach(tt=>{tt(Ot(this,Mr))}),Ot(this,Br).getQueryCache().notify({query:Ot(this,Cr),type:"observerResultsUpdated"})})},Xs);function shouldLoadOnMount(et,o){return resolveEnabled(o.enabled,et)!==!1&&et.state.data===void 0&&!(et.state.status==="error"&&o.retryOnMount===!1)}function shouldFetchOnMount(et,o){return shouldLoadOnMount(et,o)||et.state.data!==void 0&&shouldFetchOn(et,o,o.refetchOnMount)}function shouldFetchOn(et,o,tt){if(resolveEnabled(o.enabled,et)!==!1){const rt=typeof tt=="function"?tt(et):tt;return rt==="always"||rt!==!1&&isStale(et,o)}return!1}function shouldFetchOptionally(et,o,tt,rt){return(et!==o||resolveEnabled(rt.enabled,et)===!1)&&(!tt.suspense||et.state.status!=="error")&&isStale(et,tt)}function isStale(et,o){return resolveEnabled(o.enabled,et)!==!1&&et.isStaleByTime(resolveStaleTime(o.staleTime,et))}function shouldAssignObserverCurrentProperties(et,o){return!shallowEqualObjects(et.getCurrentResult(),o)}var xn,vn,Fr,sn,ln,Jo,Os,Ys,MutationObserver$1=(Ys=class extends Subscribable{constructor(tt,rt){super();fr(this,ln);fr(this,xn);fr(this,vn);fr(this,Fr);fr(this,sn);lr(this,xn,tt),this.setOptions(rt),this.bindMethods(),mr(this,ln,Jo).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(tt){var nt;const rt=this.options;this.options=Ot(this,xn).defaultMutationOptions(tt),shallowEqualObjects(this.options,rt)||Ot(this,xn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Ot(this,Fr),observer:this}),rt!=null&&rt.mutationKey&&this.options.mutationKey&&hashKey(rt.mutationKey)!==hashKey(this.options.mutationKey)?this.reset():((nt=Ot(this,Fr))==null?void 0:nt.state.status)==="pending"&&Ot(this,Fr).setOptions(this.options)}onUnsubscribe(){var tt;this.hasListeners()||(tt=Ot(this,Fr))==null||tt.removeObserver(this)}onMutationUpdate(tt){mr(this,ln,Jo).call(this),mr(this,ln,Os).call(this,tt)}getCurrentResult(){return Ot(this,vn)}reset(){var tt;(tt=Ot(this,Fr))==null||tt.removeObserver(this),lr(this,Fr,void 0),mr(this,ln,Jo).call(this),mr(this,ln,Os).call(this)}mutate(tt,rt){var nt;return lr(this,sn,rt),(nt=Ot(this,Fr))==null||nt.removeObserver(this),lr(this,Fr,Ot(this,xn).getMutationCache().build(Ot(this,xn),this.options)),Ot(this,Fr).addObserver(this),Ot(this,Fr).execute(tt)}},xn=new WeakMap,vn=new WeakMap,Fr=new WeakMap,sn=new WeakMap,ln=new WeakSet,Jo=function(){var rt;const tt=((rt=Ot(this,Fr))==null?void 0:rt.state)??getDefaultState();lr(this,vn,{...tt,isPending:tt.status==="pending",isSuccess:tt.status==="success",isError:tt.status==="error",isIdle:tt.status==="idle",mutate:this.mutate,reset:this.reset})},Os=function(tt){notifyManager.batch(()=>{var rt,nt,ot,it,st,at,ct,lt;if(Ot(this,sn)&&this.hasListeners()){const dt=Ot(this,vn).variables,ht=Ot(this,vn).context;(tt==null?void 0:tt.type)==="success"?((nt=(rt=Ot(this,sn)).onSuccess)==null||nt.call(rt,tt.data,dt,ht),(it=(ot=Ot(this,sn)).onSettled)==null||it.call(ot,tt.data,null,dt,ht)):(tt==null?void 0:tt.type)==="error"&&((at=(st=Ot(this,sn)).onError)==null||at.call(st,tt.error,dt,ht),(lt=(ct=Ot(this,sn)).onSettled)==null||lt.call(ct,void 0,tt.error,dt,ht))}this.listeners.forEach(dt=>{dt(Ot(this,vn))})})},Ys);function hashFn(et){return JSON.stringify(et,(o,tt)=>isPlainObject$2(tt)?Object.keys(tt).sort().reduce((rt,nt)=>(rt[nt]=tt[nt],rt),{}):typeof tt=="bigint"?tt.toString():tt)}function isPlainObject$2(et){if(!hasObjectPrototype(et))return!1;const o=et.constructor;if(typeof o>"u")return!0;const tt=o.prototype;return!(!hasObjectPrototype(tt)||!tt.hasOwnProperty("isPrototypeOf"))}function hasObjectPrototype(et){return Object.prototype.toString.call(et)==="[object Object]"}function filterQueryOptions(et){const{_defaulted:o,behavior:tt,gcTime:rt,initialData:nt,initialDataUpdatedAt:ot,maxPages:it,meta:st,networkMode:at,queryFn:ct,queryHash:lt,queryKey:dt,queryKeyHashFn:ht,retry:mt,retryDelay:ft,structuralSharing:pt,getPreviousPageParam:yt,getNextPageParam:gt,initialPageParam:bt,_optimisticResults:xt,enabled:vt,notifyOnChangeProps:Et,placeholderData:Ct,refetchInterval:St,refetchIntervalInBackground:At,refetchOnMount:kt,refetchOnReconnect:It,refetchOnWindowFocus:Nt,retryOnMount:Lt,select:Mt,staleTime:zt,suspense:Ut,throwOnError:Xt,config:Wt,connector:Ft,query:qt,...Pt}=et;return Pt}function connectMutationOptions(et){return{mutationFn(o){return connect$1(et,o)},mutationKey:["connect"]}}function disconnectMutationOptions(et){return{mutationFn(o){return disconnect(et,o)},mutationKey:["disconnect"]}}function getBalanceQueryOptions(et,o={}){return{async queryFn({queryKey:tt}){const{address:rt,scopeKey:nt,...ot}=tt[1];if(!rt)throw new Error("address is required");return await getBalance(et,{...ot,address:rt})??null},queryKey:getBalanceQueryKey(o)}}function getBalanceQueryKey(et={}){return["balance",filterQueryOptions(et)]}function getBlockNumberQueryOptions(et,o={}){return{gcTime:0,async queryFn({queryKey:tt}){const{scopeKey:rt,...nt}=tt[1];return await getBlockNumber(et,nt)??null},queryKey:getBlockNumberQueryKey(o)}}function getBlockNumberQueryKey(et={}){return["blockNumber",filterQueryOptions(et)]}function getEnsAddressQueryOptions(et,o={}){return{async queryFn({queryKey:tt}){const{name:rt,scopeKey:nt,...ot}=tt[1];if(!rt)throw new Error("name is required");return getEnsAddress(et,{...ot,name:rt})},queryKey:getEnsAddressQueryKey(o)}}function getEnsAddressQueryKey(et={}){return["ensAddress",filterQueryOptions(et)]}function getEnsAvatarQueryOptions(et,o={}){return{async queryFn({queryKey:tt}){const{name:rt,scopeKey:nt,...ot}=tt[1];if(!rt)throw new Error("name is required");return getEnsAvatar(et,{...ot,name:rt})},queryKey:getEnsAvatarQueryKey(o)}}function getEnsAvatarQueryKey(et={}){return["ensAvatar",filterQueryOptions(et)]}function getEnsNameQueryOptions(et,o={}){return{async queryFn({queryKey:tt}){const{address:rt,scopeKey:nt,...ot}=tt[1];if(!rt)throw new Error("address is required");return getEnsName(et,{...ot,address:rt})},queryKey:getEnsNameQueryKey(o)}}function getEnsNameQueryKey(et={}){return["ensName",filterQueryOptions(et)]}function signMessageMutationOptions(et){return{mutationFn(o){return signMessage(et,o)},mutationKey:["signMessage"]}}function switchChainMutationOptions(et){return{mutationFn(o){return switchChain(et,o)},mutationKey:["switchChain"]}}var QueryClientContext=reactExports.createContext(void 0),useQueryClient=et=>{const o=reactExports.useContext(QueryClientContext);if(!o)throw new Error("No QueryClient set, use QueryClientProvider to set one");return o},QueryClientProvider=({client:et,children:o})=>(reactExports.useEffect(()=>(et.mount(),()=>{et.unmount()}),[et]),jsxRuntimeExports.jsx(QueryClientContext.Provider,{value:et,children:o})),IsRestoringContext=reactExports.createContext(!1),useIsRestoring=()=>reactExports.useContext(IsRestoringContext);IsRestoringContext.Provider;function createValue(){let et=!1;return{clearReset:()=>{et=!1},reset:()=>{et=!0},isReset:()=>et}}var QueryErrorResetBoundaryContext=reactExports.createContext(createValue()),useQueryErrorResetBoundary=()=>reactExports.useContext(QueryErrorResetBoundaryContext);function shouldThrowError(et,o){return typeof et=="function"?et(...o):!!et}function noop$3(){}var ensurePreventErrorBoundaryRetry=(et,o)=>{(et.suspense||et.throwOnError)&&(o.isReset()||(et.retryOnMount=!1))},useClearResetErrorBoundary=et=>{reactExports.useEffect(()=>{et.clearReset()},[et])},getHasError=({result:et,errorResetBoundary:o,throwOnError:tt,query:rt})=>et.isError&&!o.isReset()&&!et.isFetching&&rt&&shouldThrowError(tt,[et.error,rt]),ensureSuspenseTimers=et=>{et.suspense&&(et.staleTime===void 0&&(et.staleTime=1e3),typeof et.gcTime=="number"&&(et.gcTime=Math.max(et.gcTime,1e3)))},willFetch=(et,o)=>et.isLoading&&et.isFetching&&!o,shouldSuspend=(et,o)=>(et==null?void 0:et.suspense)&&o.isPending,fetchOptimistic=(et,o,tt)=>o.fetchOptimistic(et).catch(()=>{tt.clearReset()});function useBaseQuery(et,o,tt){var lt,dt,ht,mt,ft;const rt=useQueryClient(),nt=useIsRestoring(),ot=useQueryErrorResetBoundary(),it=rt.defaultQueryOptions(et);(dt=(lt=rt.getDefaultOptions().queries)==null?void 0:lt._experimental_beforeQuery)==null||dt.call(lt,it),it._optimisticResults=nt?"isRestoring":"optimistic",ensureSuspenseTimers(it),ensurePreventErrorBoundaryRetry(it,ot),useClearResetErrorBoundary(ot);const st=!rt.getQueryCache().get(it.queryHash),[at]=reactExports.useState(()=>new o(rt,it)),ct=at.getOptimisticResult(it);if(reactExports.useSyncExternalStore(reactExports.useCallback(pt=>{const yt=nt?()=>{}:at.subscribe(notifyManager.batchCalls(pt));return at.updateResult(),yt},[at,nt]),()=>at.getCurrentResult(),()=>at.getCurrentResult()),reactExports.useEffect(()=>{at.setOptions(it,{listeners:!1})},[it,at]),shouldSuspend(it,ct))throw fetchOptimistic(it,at,ot);if(getHasError({result:ct,errorResetBoundary:ot,throwOnError:it.throwOnError,query:rt.getQueryCache().get(it.queryHash)}))throw ct.error;if((mt=(ht=rt.getDefaultOptions().queries)==null?void 0:ht._experimental_afterQuery)==null||mt.call(ht,it,ct),it.experimental_prefetchInRender&&!isServer&&willFetch(ct,nt)){const pt=st?fetchOptimistic(it,at,ot):(ft=rt.getQueryCache().get(it.queryHash))==null?void 0:ft.promise;pt==null||pt.catch(noop$3).finally(()=>{at.hasListeners()||at.updateResult()})}return it.notifyOnChangeProps?ct:at.trackResult(ct)}function useQuery$1(et,o){return useBaseQuery(et,QueryObserver)}function useMutation(et,o){const tt=useQueryClient(),[rt]=reactExports.useState(()=>new MutationObserver$1(tt,et));reactExports.useEffect(()=>{rt.setOptions(et)},[rt,et]);const nt=reactExports.useSyncExternalStore(reactExports.useCallback(it=>rt.subscribe(notifyManager.batchCalls(it)),[rt]),()=>rt.getCurrentResult(),()=>rt.getCurrentResult()),ot=reactExports.useCallback((it,st)=>{rt.mutate(it,st).catch(noop$3)},[rt]);if(nt.error&&shouldThrowError(rt.options.throwOnError,[nt.error]))throw nt.error;return{...nt,mutate:ot,mutateAsync:nt.mutate}}function useQuery(et){const o=useQuery$1({...et,queryKeyHashFn:hashFn});return o.queryKey=et.queryKey,o}function useChainId(et={}){const o=useConfig(et);return reactExports.useSyncExternalStore(tt=>watchChainId(o,{onChange:tt}),()=>getChainId(o),()=>getChainId(o))}function useBalance(et={}){const{address:o,query:tt={}}=et,rt=useConfig(et),nt=useChainId({config:rt}),ot=getBalanceQueryOptions(rt,{...et,chainId:et.chainId??nt}),it=!!(o&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useWatchBlockNumber(et={}){const{enabled:o=!0,onBlockNumber:tt,config:rt,...nt}=et,ot=useConfig(et),it=useChainId({config:ot}),st=et.chainId??it;reactExports.useEffect(()=>{if(o&&tt)return watchBlockNumber(ot,{...nt,chainId:st,onBlockNumber:tt})},[st,ot,o,tt,nt.onError,nt.emitMissed,nt.emitOnBegin,nt.poll,nt.pollingInterval,nt.syncConnectedChain])}function useBlockNumber(et={}){const{query:o={},watch:tt}=et,rt=useConfig(et),nt=useQueryClient(),ot=useChainId({config:rt}),it=et.chainId??ot,st=getBlockNumberQueryOptions(rt,{...et,chainId:it});return useWatchBlockNumber({config:et.config,chainId:et.chainId,...typeof tt=="object"?tt:{},enabled:!!((o.enabled??!0)&&(typeof tt=="object"?tt.enabled:tt)),onBlockNumber(at){nt.setQueryData(st.queryKey,at)}}),useQuery({...o,...st})}function useChains$1(et={}){const o=useConfig(et);return reactExports.useSyncExternalStore(tt=>watchChains(o,{onChange:tt}),()=>getChains(o),()=>getChains(o))}function useConnectors$1(et={}){const o=useConfig(et);return reactExports.useSyncExternalStore(tt=>watchConnectors(o,{onChange:tt}),()=>getConnectors(o),()=>getConnectors(o))}function useConnect$1(et={}){const{mutation:o}=et,tt=useConfig(et),rt=connectMutationOptions(tt),{mutate:nt,mutateAsync:ot,...it}=useMutation({...o,...rt});return reactExports.useEffect(()=>tt.subscribe(({status:st})=>st,(st,at)=>{at==="connected"&&st==="disconnected"&&it.reset()}),[tt,it.reset]),{...it,connect:nt,connectAsync:ot,connectors:useConnectors$1({config:tt})}}function useConnections(et={}){const o=useConfig(et);return reactExports.useSyncExternalStore(tt=>watchConnections(o,{onChange:tt}),()=>getConnections(o),()=>getConnections(o))}function useDisconnect(et={}){const{mutation:o}=et,tt=useConfig(et),rt=disconnectMutationOptions(tt),{mutate:nt,mutateAsync:ot,...it}=useMutation({...o,...rt});return{...it,connectors:useConnections({config:tt}).map(st=>st.connector),disconnect:nt,disconnectAsync:ot}}function useEnsAddress(et={}){const{name:o,query:tt={}}=et,rt=useConfig(et),nt=useChainId({config:rt}),ot=getEnsAddressQueryOptions(rt,{...et,chainId:et.chainId??nt}),it=!!(o&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useEnsAvatar(et={}){const{name:o,query:tt={}}=et,rt=useConfig(et),nt=useChainId({config:rt}),ot=getEnsAvatarQueryOptions(rt,{...et,chainId:et.chainId??nt}),it=!!(o&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useEnsName(et={}){const{address:o,query:tt={}}=et,rt=useConfig(et),nt=useChainId({config:rt}),ot=getEnsNameQueryOptions(rt,{...et,chainId:et.chainId??nt}),it=!!(o&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useSignMessage(et={}){const{mutation:o}=et,tt=useConfig(et),rt=signMessageMutationOptions(tt),{mutate:nt,mutateAsync:ot,...it}=useMutation({...o,...rt});return{...it,signMessage:nt,signMessageAsync:ot}}function useSwitchChain(et={}){const{mutation:o}=et,tt=useConfig(et),rt=switchChainMutationOptions(tt),{mutate:nt,mutateAsync:ot,...it}=useMutation({...o,...rt});return{...it,chains:useChains$1({config:tt}),switchChain:nt,switchChainAsync:ot}}const contracts={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},formatters={block:defineBlock({format(et){var tt;return{transactions:(tt=et.transactions)==null?void 0:tt.map(rt=>{if(typeof rt=="string")return rt;const nt=formatTransaction(rt);return nt.typeHex==="0x7e"&&(nt.isSystemTx=rt.isSystemTx,nt.mint=rt.mint?hexToBigInt(rt.mint):void 0,nt.sourceHash=rt.sourceHash,nt.type="deposit"),nt}),stateRoot:et.stateRoot}}}),transaction:defineTransaction({format(et){const o={};return et.type==="0x7e"&&(o.isSystemTx=et.isSystemTx,o.mint=et.mint?hexToBigInt(et.mint):void 0,o.sourceHash=et.sourceHash,o.type="deposit"),o}}),transactionReceipt:defineTransactionReceipt({format(et){return{l1GasPrice:et.l1GasPrice?hexToBigInt(et.l1GasPrice):null,l1GasUsed:et.l1GasUsed?hexToBigInt(et.l1GasUsed):null,l1Fee:et.l1Fee?hexToBigInt(et.l1Fee):null,l1FeeScalar:et.l1FeeScalar?Number(et.l1FeeScalar):null}}})};function serializeTransaction(et,o){return isDeposit(et)?serializeTransactionDeposit(et):serializeTransaction$1(et,o)}const serializers={transaction:serializeTransaction};function serializeTransactionDeposit(et){assertTransactionDeposit(et);const{sourceHash:o,data:tt,from:rt,gas:nt,isSystemTx:ot,mint:it,to:st,value:at}=et,ct=[o,rt,st??"0x",it?toHex(it):"0x",at?toHex(at):"0x",nt?toHex(nt):"0x",ot?"0x1":"0x",tt??"0x"];return concatHex(["0x7e",toRlp(ct)])}function isDeposit(et){return et.type==="deposit"||typeof et.sourceHash<"u"}function assertTransactionDeposit(et){const{from:o,to:tt}=et;if(o&&!isAddress(o))throw new InvalidAddressError({address:o});if(tt&&!isAddress(tt))throw new InvalidAddressError({address:tt})}const chainConfig={contracts,formatters,serializers},arbitrum=defineChain({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),mainnet=defineChain({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),sourceId=1,optimism=defineChain({...chainConfig,id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimism Explorer",url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io/api"}},contracts:{...chainConfig.contracts,disputeGameFactory:{[sourceId]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[sourceId]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[sourceId]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[sourceId]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId}),polygon=defineChain({id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}});coinbaseWallet.type="coinbaseWallet";function coinbaseWallet(et={}){return et.version==="3"||et.headlessMode?version3(et):version4(et)}function version4(et){let o,tt,rt,nt,ot;return it=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",supportsSimulation:!0,type:coinbaseWallet.type,async connect({chainId:st}={}){try{const at=await this.getProvider(),ct=(await at.request({method:"eth_requestAccounts"})).map(dt=>getAddress(dt));rt||(rt=this.onAccountsChanged.bind(this),at.on("accountsChanged",rt)),nt||(nt=this.onChainChanged.bind(this),at.on("chainChanged",nt)),ot||(ot=this.onDisconnect.bind(this),at.on("disconnect",ot));let lt=await this.getChainId();if(st&<!==st){const dt=await this.switchChain({chainId:st}).catch(ht=>{if(ht.code===UserRejectedRequestError.code)throw ht;return{id:lt}});lt=(dt==null?void 0:dt.id)??lt}return{accounts:ct,chainId:lt}}catch(at){throw/(user closed modal|accounts received is empty|user denied account|request rejected)/i.test(at.message)?new UserRejectedRequestError(at):at}},async disconnect(){var at;const st=await this.getProvider();rt&&(st.removeListener("accountsChanged",rt),rt=void 0),nt&&(st.removeListener("chainChanged",nt),nt=void 0),ot&&(st.removeListener("disconnect",ot),ot=void 0),st.disconnect(),(at=st.close)==null||at.call(st)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(at=>getAddress(at))},async getChainId(){const at=await(await this.getProvider()).request({method:"eth_chainId"});return Number(at)},async getProvider(){if(!tt){const st=await(async()=>{const{default:at}=await __vitePreload(async()=>{const{default:ct}=await import("./index-BcaB-heU.js").then(lt=>lt.i);return{default:ct}},__vite__mapDeps([0,1,2,3]));return typeof at!="function"&&typeof at.default=="function"?at.default:at})();o=new st({...et,appChainIds:it.chains.map(at=>at.id)}),tt=o.makeWeb3Provider({...et,options:et.preference??"all"})}return tt},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:st,chainId:at}){var dt,ht,mt,ft;const ct=it.chains.find(pt=>pt.id===at);if(!ct)throw new SwitchChainError(new ChainNotConfiguredError);const lt=await this.getProvider();try{return await lt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(ct.id)}]}),ct}catch(pt){if(pt.code===4902)try{let yt;st!=null&&st.blockExplorerUrls?yt=st.blockExplorerUrls:yt=(dt=ct.blockExplorers)!=null&&dt.default.url?[(ht=ct.blockExplorers)==null?void 0:ht.default.url]:[];let gt;(mt=st==null?void 0:st.rpcUrls)!=null&&mt.length?gt=st.rpcUrls:gt=[((ft=ct.rpcUrls.default)==null?void 0:ft.http[0])??""];const bt={blockExplorerUrls:yt,chainId:numberToHex(at),chainName:(st==null?void 0:st.chainName)??ct.name,iconUrls:st==null?void 0:st.iconUrls,nativeCurrency:(st==null?void 0:st.nativeCurrency)??ct.nativeCurrency,rpcUrls:gt};return await lt.request({method:"wallet_addEthereumChain",params:[bt]}),ct}catch(yt){throw new UserRejectedRequestError(yt)}throw new SwitchChainError(pt)}},onAccountsChanged(st){st.length===0?this.onDisconnect():it.emitter.emit("change",{accounts:st.map(at=>getAddress(at))})},onChainChanged(st){const at=Number(st);it.emitter.emit("change",{chainId:at})},async onDisconnect(st){it.emitter.emit("disconnect");const at=await this.getProvider();rt&&(at.removeListener("accountsChanged",rt),rt=void 0),nt&&(at.removeListener("chainChanged",nt),nt=void 0),ot&&(at.removeListener("disconnect",ot),ot=void 0)}})}function version3(et){let tt,rt,nt,ot,it;return st=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",supportsSimulation:!0,type:coinbaseWallet.type,async connect({chainId:at}={}){try{const ct=await this.getProvider(),lt=(await ct.request({method:"eth_requestAccounts"})).map(ht=>getAddress(ht));nt||(nt=this.onAccountsChanged.bind(this),ct.on("accountsChanged",nt)),ot||(ot=this.onChainChanged.bind(this),ct.on("chainChanged",ot)),it||(it=this.onDisconnect.bind(this),ct.on("disconnect",it));let dt=await this.getChainId();if(at&&dt!==at){const ht=await this.switchChain({chainId:at}).catch(mt=>{if(mt.code===UserRejectedRequestError.code)throw mt;return{id:dt}});dt=(ht==null?void 0:ht.id)??dt}return{accounts:lt,chainId:dt}}catch(ct){throw/(user closed modal|accounts received is empty|user denied account)/i.test(ct.message)?new UserRejectedRequestError(ct):ct}},async disconnect(){const at=await this.getProvider();nt&&(at.removeListener("accountsChanged",nt),nt=void 0),ot&&(at.removeListener("chainChanged",ot),ot=void 0),it&&(at.removeListener("disconnect",it),it=void 0),at.disconnect(),at.close()},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(ct=>getAddress(ct))},async getChainId(){const ct=await(await this.getProvider()).request({method:"eth_chainId"});return Number(ct)},async getProvider(){var at;if(!rt){const ct=await(async()=>{const{default:ft}=await __vitePreload(async()=>{const{default:pt}=await import("./index-Ds5ZBbkh.js").then(yt=>yt.i);return{default:pt}},__vite__mapDeps([4,3,1,2]));return typeof ft!="function"&&typeof ft.default=="function"?ft.default:ft})();tt=new ct({...et,reloadOnDisconnect:!1});const lt=(at=tt.walletExtension)==null?void 0:at.getChainId(),dt=st.chains.find(ft=>et.chainId?ft.id===et.chainId:ft.id===lt)||st.chains[0],ht=et.chainId||(dt==null?void 0:dt.id),mt=et.jsonRpcUrl||(dt==null?void 0:dt.rpcUrls.default.http[0]);rt=tt.makeWeb3Provider(mt,ht)}return rt},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:at,chainId:ct}){var ht,mt,ft,pt;const lt=st.chains.find(yt=>yt.id===ct);if(!lt)throw new SwitchChainError(new ChainNotConfiguredError);const dt=await this.getProvider();try{return await dt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(lt.id)}]}),lt}catch(yt){if(yt.code===4902)try{let gt;at!=null&&at.blockExplorerUrls?gt=at.blockExplorerUrls:gt=(ht=lt.blockExplorers)!=null&&ht.default.url?[(mt=lt.blockExplorers)==null?void 0:mt.default.url]:[];let bt;(ft=at==null?void 0:at.rpcUrls)!=null&&ft.length?bt=at.rpcUrls:bt=[((pt=lt.rpcUrls.default)==null?void 0:pt.http[0])??""];const xt={blockExplorerUrls:gt,chainId:numberToHex(ct),chainName:(at==null?void 0:at.chainName)??lt.name,iconUrls:at==null?void 0:at.iconUrls,nativeCurrency:(at==null?void 0:at.nativeCurrency)??lt.nativeCurrency,rpcUrls:bt};return await dt.request({method:"wallet_addEthereumChain",params:[xt]}),lt}catch(gt){throw new UserRejectedRequestError(gt)}throw new SwitchChainError(yt)}},onAccountsChanged(at){at.length===0?this.onDisconnect():st.emitter.emit("change",{accounts:at.map(ct=>getAddress(ct))})},onChainChanged(at){const ct=Number(at);st.emitter.emit("change",{chainId:ct})},async onDisconnect(at){st.emitter.emit("disconnect");const ct=await this.getProvider();nt&&(ct.removeListener("accountsChanged",nt),nt=void 0),ot&&(ct.removeListener("chainChanged",ot),ot=void 0),it&&(ct.removeListener("disconnect",it),it=void 0)}})}safe.type="safe";function safe(et={}){const{shimDisconnect:o=!1}=et;let tt,rt;return nt=>({id:"safe",name:"Safe",type:safe.type,async connect(){var at;const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;const it=await this.getAccounts(),st=await this.getChainId();return rt||(rt=this.onDisconnect.bind(this),ot.on("disconnect",rt)),o&&await((at=nt.storage)==null?void 0:at.removeItem("safe.disconnected")),{accounts:it,chainId:st}},async disconnect(){var it;const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;rt&&(ot.removeListener("disconnect",rt),rt=void 0),o&&await((it=nt.storage)==null?void 0:it.setItem("safe.disconnected",!0))},async getAccounts(){const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;return(await ot.request({method:"eth_accounts"})).map(getAddress)},async getProvider(){if(typeof window<"u"&&(window==null?void 0:window.parent)!==window){if(!tt){const{default:it}=await __vitePreload(async()=>{const{default:lt}=await import("./index-B0w2h4-W.js");return{default:lt}},[]),st=new it(et),at=await withTimeout(()=>st.safe.getInfo(),{timeout:et.unstable_getInfoTimeout??10});if(!at)throw new Error("Could not load Safe information");const{SafeAppProvider:ct}=await __vitePreload(async()=>{const{SafeAppProvider:lt}=await import("./index-DSEy00EN.js").then(dt=>dt.i);return{SafeAppProvider:lt}},__vite__mapDeps([5,2]));tt=new ct(at,st)}return tt}},async getChainId(){const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;return Number(ot.chainId)},async isAuthorized(){var ot;try{return o&&await((ot=nt.storage)==null?void 0:ot.getItem("safe.disconnected"))?!1:!!(await this.getAccounts()).length}catch{return!1}},onAccountsChanged(){},onChainChanged(){},onDisconnect(){nt.emitter.emit("disconnect")}})}walletConnect.type="walletConnect";function walletConnect(et){const o=et.isNewChainsStale??!0;let tt,rt;const nt="eip155";let ot,it,st,at,ct,lt;return dt=>({id:"walletConnect",name:"WalletConnect",type:walletConnect.type,async setup(){const ht=await this.getProvider().catch(()=>null);ht&&(st||(st=this.onConnect.bind(this),ht.on("connect",st)),ct||(ct=this.onSessionDelete.bind(this),ht.on("session_delete",ct)))},async connect({chainId:ht,...mt}={}){var ft,pt;try{const yt=await this.getProvider();if(!yt)throw new ProviderNotFoundError;at||(at=this.onDisplayUri,yt.on("display_uri",at));let gt=ht;if(!gt){const Et=await((ft=dt.storage)==null?void 0:ft.getItem("state"))??{};dt.chains.some(St=>St.id===Et.chainId)?gt=Et.chainId:gt=(pt=dt.chains[0])==null?void 0:pt.id}if(!gt)throw new Error("No chains found on connector.");const bt=await this.isChainsStale();if(yt.session&&bt&&await yt.disconnect(),!yt.session||bt){const Et=dt.chains.filter(Ct=>Ct.id!==gt).map(Ct=>Ct.id);await yt.connect({optionalChains:[gt,...Et],..."pairingTopic"in mt?{pairingTopic:mt.pairingTopic}:{}}),this.setRequestedChainsIds(dt.chains.map(Ct=>Ct.id))}const xt=(await yt.enable()).map(Et=>getAddress(Et)),vt=await this.getChainId();return at&&(yt.removeListener("display_uri",at),at=void 0),st&&(yt.removeListener("connect",st),st=void 0),ot||(ot=this.onAccountsChanged.bind(this),yt.on("accountsChanged",ot)),it||(it=this.onChainChanged.bind(this),yt.on("chainChanged",it)),lt||(lt=this.onDisconnect.bind(this),yt.on("disconnect",lt)),ct||(ct=this.onSessionDelete.bind(this),yt.on("session_delete",ct)),{accounts:xt,chainId:vt}}catch(yt){throw/(user rejected|connection request reset)/i.test(yt==null?void 0:yt.message)?new UserRejectedRequestError(yt):yt}},async disconnect(){const ht=await this.getProvider();try{await(ht==null?void 0:ht.disconnect())}catch(mt){if(!/No matching key/i.test(mt.message))throw mt}finally{it&&(ht==null||ht.removeListener("chainChanged",it),it=void 0),lt&&(ht==null||ht.removeListener("disconnect",lt),lt=void 0),st||(st=this.onConnect.bind(this),ht==null||ht.on("connect",st)),ot&&(ht==null||ht.removeListener("accountsChanged",ot),ot=void 0),ct&&(ht==null||ht.removeListener("session_delete",ct),ct=void 0),this.setRequestedChainsIds([])}},async getAccounts(){return(await this.getProvider()).accounts.map(mt=>getAddress(mt))},async getProvider({chainId:ht}={}){var ft;async function mt(){const pt=dt.chains.map(gt=>gt.id);if(!pt.length)return;const{EthereumProvider:yt}=await __vitePreload(async()=>{const{EthereumProvider:gt}=await import("./index.es-pymM7oJc.js");return{EthereumProvider:gt}},__vite__mapDeps([6,2,3]));return await yt.init({...et,disableProviderPing:!0,optionalChains:pt,projectId:et.projectId,rpcMap:Object.fromEntries(dt.chains.map(gt=>{const[bt]=extractRpcUrls({chain:gt,transports:dt.transports});return[gt.id,bt]})),showQrModal:et.showQrModal??!0})}return tt||(rt||(rt=mt()),tt=await rt,tt==null||tt.events.setMaxListeners(Number.POSITIVE_INFINITY)),ht&&await((ft=this.switchChain)==null?void 0:ft.call(this,{chainId:ht})),tt},async getChainId(){return(await this.getProvider()).chainId},async isAuthorized(){try{const[ht,mt]=await Promise.all([this.getAccounts(),this.getProvider()]);return ht.length?await this.isChainsStale()&&mt.session?(await mt.disconnect().catch(()=>{}),!1):!0:!1}catch{return!1}},async switchChain({addEthereumChainParameter:ht,chainId:mt}){var yt,gt,bt;const ft=await this.getProvider();if(!ft)throw new ProviderNotFoundError;const pt=dt.chains.find(xt=>xt.id===mt);if(!pt)throw new SwitchChainError(new ChainNotConfiguredError);try{await Promise.all([new Promise(vt=>{const Et=({chainId:Ct})=>{Ct===mt&&(dt.emitter.off("change",Et),vt())};dt.emitter.on("change",Et)}),ft.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(mt)}]})]);const xt=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...xt,mt]),pt}catch(xt){const vt=xt;if(/(user rejected)/i.test(vt.message))throw new UserRejectedRequestError(vt);try{let Et;ht!=null&&ht.blockExplorerUrls?Et=ht.blockExplorerUrls:Et=(yt=pt.blockExplorers)!=null&&yt.default.url?[(gt=pt.blockExplorers)==null?void 0:gt.default.url]:[];let Ct;(bt=ht==null?void 0:ht.rpcUrls)!=null&&bt.length?Ct=ht.rpcUrls:Ct=[...pt.rpcUrls.default.http];const St={blockExplorerUrls:Et,chainId:numberToHex(mt),chainName:(ht==null?void 0:ht.chainName)??pt.name,iconUrls:ht==null?void 0:ht.iconUrls,nativeCurrency:(ht==null?void 0:ht.nativeCurrency)??pt.nativeCurrency,rpcUrls:Ct};await ft.request({method:"wallet_addEthereumChain",params:[St]});const At=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...At,mt]),pt}catch(Et){throw new UserRejectedRequestError(Et)}}},onAccountsChanged(ht){ht.length===0?this.onDisconnect():dt.emitter.emit("change",{accounts:ht.map(mt=>getAddress(mt))})},onChainChanged(ht){const mt=Number(ht);dt.emitter.emit("change",{chainId:mt})},async onConnect(ht){const mt=Number(ht.chainId),ft=await this.getAccounts();dt.emitter.emit("connect",{accounts:ft,chainId:mt})},async onDisconnect(ht){this.setRequestedChainsIds([]),dt.emitter.emit("disconnect");const mt=await this.getProvider();ot&&(mt.removeListener("accountsChanged",ot),ot=void 0),it&&(mt.removeListener("chainChanged",it),it=void 0),lt&&(mt.removeListener("disconnect",lt),lt=void 0),ct&&(mt.removeListener("session_delete",ct),ct=void 0),st||(st=this.onConnect.bind(this),mt.on("connect",st))},onDisplayUri(ht){dt.emitter.emit("message",{type:"display_uri",data:ht})},onSessionDelete(){this.onDisconnect()},getNamespaceChainsIds(){var mt,ft,pt;return tt?((pt=(ft=(mt=tt.session)==null?void 0:mt.namespaces[nt])==null?void 0:ft.accounts)==null?void 0:pt.map(yt=>Number.parseInt(yt.split(":")[1]||"")))??[]:[]},async getRequestedChainsIds(){var ht;return await((ht=dt.storage)==null?void 0:ht.getItem(this.requestedChainsStorageKey))??[]},async isChainsStale(){if(!o)return!1;const ht=dt.chains.map(pt=>pt.id),mt=this.getNamespaceChainsIds();if(mt.length&&!mt.some(pt=>ht.includes(pt)))return!1;const ft=await this.getRequestedChainsIds();return!ht.every(pt=>ft.includes(pt))},async setRequestedChainsIds(ht){var mt;await((mt=dt.storage)==null?void 0:mt.setItem(this.requestedChainsStorageKey,ht))},get requestedChainsStorageKey(){return`${this.id}.requestedChains`}})}var define_process_default$3={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0},__spreadArray$1=function(et,o,tt){for(var rt=0,nt=o.length,ot;rt"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(et){return et!==""&&userAgentRules.reduce(function(o,tt){var rt=tt[0],nt=tt[1];if(o)return o;var ot=nt.exec(et);return!!ot&&[rt,ot]},!1)}function parseUserAgent(et){var o=matchUserAgent(et);if(!o)return null;var tt=o[0],rt=o[1];if(tt==="searchbot")return new BotInfo;var nt=rt[1]&&rt[1].split(".").join("_").split("_").slice(0,3);nt?nt.length=0;st--)(it=et[st])&&(ot=(nt<3?it(ot):nt>3?it(o,tt,ot):it(o,tt))||ot);return nt>3&&ot&&Object.defineProperty(o,tt,ot),ot}function __param(et,o){return function(tt,rt){o(tt,rt,et)}}function __esDecorate(et,o,tt,rt,nt,ot){function it(gt){if(gt!==void 0&&typeof gt!="function")throw new TypeError("Function expected");return gt}for(var st=rt.kind,at=st==="getter"?"get":st==="setter"?"set":"value",ct=!o&&et?rt.static?et:et.prototype:null,lt=o||(ct?Object.getOwnPropertyDescriptor(ct,rt.name):{}),dt,ht=!1,mt=tt.length-1;mt>=0;mt--){var ft={};for(var pt in rt)ft[pt]=pt==="access"?{}:rt[pt];for(var pt in rt.access)ft.access[pt]=rt.access[pt];ft.addInitializer=function(gt){if(ht)throw new TypeError("Cannot add initializers after decoration has completed");ot.push(it(gt||null))};var yt=(0,tt[mt])(st==="accessor"?{get:lt.get,set:lt.set}:lt[at],ft);if(st==="accessor"){if(yt===void 0)continue;if(yt===null||typeof yt!="object")throw new TypeError("Object expected");(dt=it(yt.get))&&(lt.get=dt),(dt=it(yt.set))&&(lt.set=dt),(dt=it(yt.init))&&nt.unshift(dt)}else(dt=it(yt))&&(st==="field"?nt.unshift(dt):lt[at]=dt)}ct&&Object.defineProperty(ct,rt.name,lt),ht=!0}function __runInitializers(et,o,tt){for(var rt=arguments.length>2,nt=0;nt0&&ot[ot.length-1])&&(ct[0]===6||ct[0]===2)){tt=0;continue}if(ct[0]===3&&(!ot||ct[1]>ot[0]&&ct[1]=et.length&&(et=void 0),{value:et&&et[rt++],done:!et}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(et,o){var tt=typeof Symbol=="function"&&et[Symbol.iterator];if(!tt)return et;var rt=tt.call(et),nt,ot=[],it;try{for(;(o===void 0||o-- >0)&&!(nt=rt.next()).done;)ot.push(nt.value)}catch(st){it={error:st}}finally{try{nt&&!nt.done&&(tt=rt.return)&&tt.call(rt)}finally{if(it)throw it.error}}return ot}function __spread(){for(var et=[],o=0;o1||at(mt,pt)})},ft&&(nt[mt]=ft(nt[mt])))}function at(mt,ft){try{ct(rt[mt](ft))}catch(pt){ht(ot[0][3],pt)}}function ct(mt){mt.value instanceof __await?Promise.resolve(mt.value.v).then(lt,dt):ht(ot[0][2],mt)}function lt(mt){at("next",mt)}function dt(mt){at("throw",mt)}function ht(mt,ft){mt(ft),ot.shift(),ot.length&&at(ot[0][0],ot[0][1])}}function __asyncDelegator(et){var o,tt;return o={},rt("next"),rt("throw",function(nt){throw nt}),rt("return"),o[Symbol.iterator]=function(){return this},o;function rt(nt,ot){o[nt]=et[nt]?function(it){return(tt=!tt)?{value:__await(et[nt](it)),done:!1}:ot?ot(it):it}:ot}}function __asyncValues(et){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=et[Symbol.asyncIterator],tt;return o?o.call(et):(et=typeof __values=="function"?__values(et):et[Symbol.iterator](),tt={},rt("next"),rt("throw"),rt("return"),tt[Symbol.asyncIterator]=function(){return this},tt);function rt(ot){tt[ot]=et[ot]&&function(it){return new Promise(function(st,at){it=et[ot](it),nt(st,at,it.done,it.value)})}}function nt(ot,it,st,at){Promise.resolve(at).then(function(ct){ot({value:ct,done:st})},it)}}function __makeTemplateObject(et,o){return Object.defineProperty?Object.defineProperty(et,"raw",{value:o}):et.raw=o,et}var __setModuleDefault=Object.create?function(et,o){Object.defineProperty(et,"default",{enumerable:!0,value:o})}:function(et,o){et.default=o};function __importStar(et){if(et&&et.__esModule)return et;var o={};if(et!=null)for(var tt in et)tt!=="default"&&Object.prototype.hasOwnProperty.call(et,tt)&&__createBinding(o,et,tt);return __setModuleDefault(o,et),o}function __importDefault$1(et){return et&&et.__esModule?et:{default:et}}function __classPrivateFieldGet(et,o,tt,rt){if(tt==="a"&&!rt)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?et!==o||!rt:!o.has(et))throw new TypeError("Cannot read private member from an object whose class did not declare it");return tt==="m"?rt:tt==="a"?rt.call(et):rt?rt.value:o.get(et)}function __classPrivateFieldSet(et,o,tt,rt,nt){if(rt==="m")throw new TypeError("Private method is not writable");if(rt==="a"&&!nt)throw new TypeError("Private accessor was defined without a setter");if(typeof o=="function"?et!==o||!nt:!o.has(et))throw new TypeError("Cannot write private member to an object whose class did not declare it");return rt==="a"?nt.call(et,tt):nt?nt.value=tt:o.set(et,tt),tt}function __classPrivateFieldIn(et,o){if(o===null||typeof o!="object"&&typeof o!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof et=="function"?o===et:et.has(o)}function __addDisposableResource(et,o,tt){if(o!=null){if(typeof o!="object"&&typeof o!="function")throw new TypeError("Object expected.");var rt,nt;if(tt){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");rt=o[Symbol.asyncDispose]}if(rt===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");rt=o[Symbol.dispose],tt&&(nt=rt)}if(typeof rt!="function")throw new TypeError("Object not disposable.");nt&&(rt=function(){try{nt.call(this)}catch(ot){return Promise.reject(ot)}}),et.stack.push({value:o,dispose:rt,async:tt})}else tt&&et.stack.push({async:!0});return o}var _SuppressedError=typeof SuppressedError=="function"?SuppressedError:function(et,o,tt){var rt=new Error(tt);return rt.name="SuppressedError",rt.error=et,rt.suppressed=o,rt};function __disposeResources(et){function o(ot){et.error=et.hasError?new _SuppressedError(ot,et.error,"An error was suppressed during disposal."):ot,et.hasError=!0}var tt,rt=0;function nt(){for(;tt=et.stack.pop();)try{if(!tt.async&&rt===1)return rt=0,et.stack.push(tt),Promise.resolve().then(nt);if(tt.dispose){var ot=tt.dispose.call(tt.value);if(tt.async)return rt|=2,Promise.resolve(ot).then(nt,function(it){return o(it),nt()})}else rt|=1}catch(it){o(it)}if(rt===1)return et.hasError?Promise.reject(et.error):Promise.resolve();if(et.hasError)throw et.error}return nt()}function __rewriteRelativeImportExtension(et,o){return typeof et=="string"&&/^\.\.?\//.test(et)?et.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(tt,rt,nt,ot,it){return rt?o?".jsx":".js":nt&&(!ot||!it)?tt:nt+ot+"."+it.toLowerCase()+"js"}):et}const tslib_es6={__extends,__assign,__rest,__decorate,__param,__esDecorate,__runInitializers,__propKey,__setFunctionName,__metadata,__awaiter,__generator,__createBinding,__exportStar,__values,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar,__importDefault:__importDefault$1,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,__addDisposableResource,__disposeResources,__rewriteRelativeImportExtension},tslib_es6$1=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource,get __assign(){return __assign},__asyncDelegator,__asyncGenerator,__asyncValues,__await,__awaiter,__classPrivateFieldGet,__classPrivateFieldIn,__classPrivateFieldSet,__createBinding,__decorate,__disposeResources,__esDecorate,__exportStar,__extends,__generator,__importDefault:__importDefault$1,__importStar,__makeTemplateObject,__metadata,__param,__propKey,__read,__rest,__rewriteRelativeImportExtension,__runInitializers,__setFunctionName,__spread,__spreadArray,__spreadArrays,__values,default:tslib_es6},Symbol.toStringTag,{value:"Module"}));var define_process_default$2={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0},define_process_env_default$1={},defaultEnvironment="production",env$1=typeof define_process_default$2>"u"||define_process_env_default$1===void 0?defaultEnvironment:"production",createDefinition=function(et){return{isEnabled:function(o){return et.some(function(tt){return!!o[tt]})}}},featureDefinitions={measureLayout:createDefinition(["layout","layoutId","drag"]),animation:createDefinition(["animate","exit","variants","whileHover","whileTap","whileFocus","whileDrag","whileInView"]),exit:createDefinition(["exit"]),drag:createDefinition(["drag","dragControls"]),focus:createDefinition(["whileFocus"]),hover:createDefinition(["whileHover","onHoverStart","onHoverEnd"]),tap:createDefinition(["whileTap","onTap","onTapStart","onTapCancel"]),pan:createDefinition(["onPan","onPanStart","onPanSessionStart","onPanEnd"]),inView:createDefinition(["whileInView","onViewportEnter","onViewportLeave"])};function loadFeatures(et){for(var o in et)et[o]!==null&&(o==="projectionNodeConstructor"?featureDefinitions.projectionNodeConstructor=et[o]:featureDefinitions[o].Component=et[o])}var invariant$1=function(){},LazyContext=reactExports.createContext({strict:!1}),featureNames=Object.keys(featureDefinitions),numFeatures=featureNames.length;function useFeatures(et,o,tt){var rt=[],nt=reactExports.useContext(LazyContext);if(!o)return null;env$1!=="production"&&tt&&nt.strict;for(var ot=0;ot"u")return o;var tt=new Map;return new Proxy(o,{get:function(rt,nt){return tt.has(nt)||tt.set(nt,o(nt)),tt.get(nt)}})}var lowercaseSVGElements=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","svg","switch","symbol","text","tspan","use","view"];function isSVGComponent(et){return typeof et!="string"||et.includes("-")?!1:!!(lowercaseSVGElements.indexOf(et)>-1||/[A-Z]/.test(et))}var scaleCorrectors={};function addScaleCorrector(et){Object.assign(scaleCorrectors,et)}var transformAxes=["","X","Y","Z"],order$1=["translate","scale","rotate","skew"],transformProps=["transformPerspective","x","y","z"];order$1.forEach(function(et){return transformAxes.forEach(function(o){return transformProps.push(et+o)})});function sortTransformProps(et,o){return transformProps.indexOf(et)-transformProps.indexOf(o)}var transformPropSet=new Set(transformProps);function isTransformProp(et){return transformPropSet.has(et)}var transformOriginProps=new Set(["originX","originY","originZ"]);function isTransformOriginProp(et){return transformOriginProps.has(et)}function isForcedMotionValue(et,o){var tt=o.layout,rt=o.layoutId;return isTransformProp(et)||isTransformOriginProp(et)||(tt||rt!==void 0)&&(!!scaleCorrectors[et]||et==="opacity")}var isMotionValue=function(et){return!!(et!==null&&typeof et=="object"&&et.getVelocity)},translateAlias={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"};function buildTransform(et,o,tt,rt){var nt=et.transform,ot=et.transformKeys,it=o.enableHardwareAcceleration,st=it===void 0?!0:it,at=o.allowTransformNone,ct=at===void 0?!0:at,lt="";ot.sort(sortTransformProps);for(var dt=!1,ht=ot.length,mt=0;mttt=>Math.max(Math.min(tt,o),et),sanitize=et=>et%1?Number(et.toFixed(5)):et,floatRegex=/(-)?([\d]*\.?[\d])+/g,colorRegex=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,singleColorRegex=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function isString(et){return typeof et=="string"}const number$3={test:et=>typeof et=="number",parse:parseFloat,transform:et=>et},alpha=Object.assign(Object.assign({},number$3),{transform:clamp$2(0,1)}),scale=Object.assign(Object.assign({},number$3),{default:1}),createUnitType=et=>({test:o=>isString(o)&&o.endsWith(et)&&o.split(" ").length===1,parse:parseFloat,transform:o=>`${o}${et}`}),degrees=createUnitType("deg"),percent=createUnitType("%"),px=createUnitType("px"),vh=createUnitType("vh"),vw=createUnitType("vw"),progressPercentage=Object.assign(Object.assign({},percent),{parse:et=>percent.parse(et)/100,transform:et=>percent.transform(et*100)}),isColorString=(et,o)=>tt=>!!(isString(tt)&&singleColorRegex.test(tt)&&tt.startsWith(et)||o&&Object.prototype.hasOwnProperty.call(tt,o)),splitColor=(et,o,tt)=>rt=>{if(!isString(rt))return rt;const[nt,ot,it,st]=rt.match(floatRegex);return{[et]:parseFloat(nt),[o]:parseFloat(ot),[tt]:parseFloat(it),alpha:st!==void 0?parseFloat(st):1}},hsla={test:isColorString("hsl","hue"),parse:splitColor("hue","saturation","lightness"),transform:({hue:et,saturation:o,lightness:tt,alpha:rt=1})=>"hsla("+Math.round(et)+", "+percent.transform(sanitize(o))+", "+percent.transform(sanitize(tt))+", "+sanitize(alpha.transform(rt))+")"},clampRgbUnit=clamp$2(0,255),rgbUnit=Object.assign(Object.assign({},number$3),{transform:et=>Math.round(clampRgbUnit(et))}),rgba={test:isColorString("rgb","red"),parse:splitColor("red","green","blue"),transform:({red:et,green:o,blue:tt,alpha:rt=1})=>"rgba("+rgbUnit.transform(et)+", "+rgbUnit.transform(o)+", "+rgbUnit.transform(tt)+", "+sanitize(alpha.transform(rt))+")"};function parseHex(et){let o="",tt="",rt="",nt="";return et.length>5?(o=et.substr(1,2),tt=et.substr(3,2),rt=et.substr(5,2),nt=et.substr(7,2)):(o=et.substr(1,1),tt=et.substr(2,1),rt=et.substr(3,1),nt=et.substr(4,1),o+=o,tt+=tt,rt+=rt,nt+=nt),{red:parseInt(o,16),green:parseInt(tt,16),blue:parseInt(rt,16),alpha:nt?parseInt(nt,16)/255:1}}const hex={test:isColorString("#"),parse:parseHex,transform:rgba.transform},color$1={test:et=>rgba.test(et)||hex.test(et)||hsla.test(et),parse:et=>rgba.test(et)?rgba.parse(et):hsla.test(et)?hsla.parse(et):hex.parse(et),transform:et=>isString(et)?et:et.hasOwnProperty("red")?rgba.transform(et):hsla.transform(et)},colorToken="${c}",numberToken="${n}";function test(et){var o,tt,rt,nt;return isNaN(et)&&isString(et)&&((tt=(o=et.match(floatRegex))===null||o===void 0?void 0:o.length)!==null&&tt!==void 0?tt:0)+((nt=(rt=et.match(colorRegex))===null||rt===void 0?void 0:rt.length)!==null&&nt!==void 0?nt:0)>0}function analyse$1(et){typeof et=="number"&&(et=`${et}`);const o=[];let tt=0;const rt=et.match(colorRegex);rt&&(tt=rt.length,et=et.replace(colorRegex,colorToken),o.push(...rt.map(color$1.parse)));const nt=et.match(floatRegex);return nt&&(et=et.replace(floatRegex,numberToken),o.push(...nt.map(number$3.parse))),{values:o,numColors:tt,tokenised:et}}function parse$4(et){return analyse$1(et).values}function createTransformer(et){const{values:o,numColors:tt,tokenised:rt}=analyse$1(et),nt=o.length;return ot=>{let it=rt;for(let st=0;sttypeof et=="number"?0:et;function getAnimatableNone$1(et){const o=parse$4(et);return createTransformer(et)(o.map(convertNumbersToZero))}const complex={test,parse:parse$4,createTransformer,getAnimatableNone:getAnimatableNone$1},maxDefaults=new Set(["brightness","contrast","saturate","opacity"]);function applyDefaultFilter(et){let[o,tt]=et.slice(0,-1).split("(");if(o==="drop-shadow")return et;const[rt]=tt.match(floatRegex)||[];if(!rt)return et;const nt=tt.replace(rt,"");let ot=maxDefaults.has(o)?1:0;return rt!==tt&&(ot*=100),o+"("+ot+nt+")"}const functionRegex=/([a-z-]*)\(.*?\)/g,filter$1=Object.assign(Object.assign({},complex),{getAnimatableNone:et=>{const o=et.match(functionRegex);return o?o.map(applyDefaultFilter).join(" "):et}});var int=__assign(__assign({},number$3),{transform:Math.round}),numberValueTypes={borderWidth:px,borderTopWidth:px,borderRightWidth:px,borderBottomWidth:px,borderLeftWidth:px,borderRadius:px,radius:px,borderTopLeftRadius:px,borderTopRightRadius:px,borderBottomRightRadius:px,borderBottomLeftRadius:px,width:px,maxWidth:px,height:px,maxHeight:px,size:px,top:px,right:px,bottom:px,left:px,padding:px,paddingTop:px,paddingRight:px,paddingBottom:px,paddingLeft:px,margin:px,marginTop:px,marginRight:px,marginBottom:px,marginLeft:px,rotate:degrees,rotateX:degrees,rotateY:degrees,rotateZ:degrees,scale,scaleX:scale,scaleY:scale,scaleZ:scale,skew:degrees,skewX:degrees,skewY:degrees,distance:px,translateX:px,translateY:px,translateZ:px,x:px,y:px,z:px,perspective:px,transformPerspective:px,opacity:alpha,originX:progressPercentage,originY:progressPercentage,originZ:px,zIndex:int,fillOpacity:alpha,strokeOpacity:alpha,numOctaves:int};function buildHTMLStyles(et,o,tt,rt){var nt,ot=et.style,it=et.vars,st=et.transform,at=et.transformKeys,ct=et.transformOrigin;at.length=0;var lt=!1,dt=!1,ht=!0;for(var mt in o){var ft=o[mt];if(isCSSVariable$1(mt)){it[mt]=ft;continue}var pt=numberValueTypes[mt],yt=getValueAsType(ft,pt);if(isTransformProp(mt)){if(lt=!0,st[mt]=yt,at.push(mt),!ht)continue;ft!==((nt=pt.default)!==null&&nt!==void 0?nt:0)&&(ht=!1)}else isTransformOriginProp(mt)?(ct[mt]=yt,dt=!0):ot[mt]=yt}lt?ot.transform=buildTransform(et,tt,ht,rt):rt?ot.transform=rt({},""):!o.transform&&ot.transform&&(ot.transform="none"),dt&&(ot.transformOrigin=buildTransformOrigin(ct))}var createHtmlRenderState=function(){return{style:{},transform:{},transformKeys:[],transformOrigin:{},vars:{}}};function copyRawValuesOnly(et,o,tt){for(var rt in o)!isMotionValue(o[rt])&&!isForcedMotionValue(rt,tt)&&(et[rt]=o[rt])}function useInitialMotionValues(et,o,tt){var rt=et.transformTemplate;return reactExports.useMemo(function(){var nt=createHtmlRenderState();buildHTMLStyles(nt,o,{enableHardwareAcceleration:!tt},rt);var ot=nt.vars,it=nt.style;return __assign(__assign({},ot),it)},[o])}function useStyle(et,o,tt){var rt=et.style||{},nt={};return copyRawValuesOnly(nt,rt,et),Object.assign(nt,useInitialMotionValues(et,o,tt)),et.transformValues&&(nt=et.transformValues(nt)),nt}function useHTMLProps(et,o,tt){var rt={},nt=useStyle(et,o,tt);return et.drag&&et.dragListener!==!1&&(rt.draggable=!1,nt.userSelect=nt.WebkitUserSelect=nt.WebkitTouchCallout="none",nt.touchAction=et.drag===!0?"none":"pan-".concat(et.drag==="x"?"y":"x")),rt.style=nt,rt}var validMotionProps=new Set(["initial","animate","exit","style","variants","transition","transformTemplate","transformValues","custom","inherit","layout","layoutId","layoutDependency","onLayoutAnimationStart","onLayoutAnimationComplete","onLayoutMeasure","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","drag","dragControls","dragListener","dragConstraints","dragDirectionLock","dragSnapToOrigin","_dragX","_dragY","dragElastic","dragMomentum","dragPropagation","dragTransition","whileDrag","onPan","onPanStart","onPanEnd","onPanSessionStart","onTap","onTapStart","onTapCancel","onHoverStart","onHoverEnd","whileFocus","whileTap","whileHover","whileInView","onViewportEnter","onViewportLeave","viewport","layoutScroll"]);function isValidMotionProp(et){return validMotionProps.has(et)}var shouldForward=function(et){return!isValidMotionProp(et)};function loadExternalIsValidProp(et){et&&(shouldForward=function(o){return o.startsWith("on")?!isValidMotionProp(o):et(o)})}try{loadExternalIsValidProp(require("@emotion/is-prop-valid").default)}catch{}function filterProps(et,o,tt){var rt={};for(var nt in et)(shouldForward(nt)||tt===!0&&isValidMotionProp(nt)||!o&&!isValidMotionProp(nt)||et.draggable&&nt.startsWith("onDrag"))&&(rt[nt]=et[nt]);return rt}function calcOrigin$1(et,o,tt){return typeof et=="string"?et:px.transform(o+tt*et)}function calcSVGTransformOrigin(et,o,tt){var rt=calcOrigin$1(o,et.x,et.width),nt=calcOrigin$1(tt,et.y,et.height);return"".concat(rt," ").concat(nt)}var camelKeys={offset:"strokeDashoffset",array:"strokeDasharray"};function buildSVGPath(et,o,tt,rt,nt){tt===void 0&&(tt=1),rt===void 0&&(rt=0),et.pathLength=1;var ot=camelKeys;et[ot.offset]=px.transform(-rt);var it=px.transform(o),st=px.transform(tt);et[ot.array]="".concat(it," ").concat(st)}function buildSVGAttrs(et,o,tt,rt){var nt=o.attrX,ot=o.attrY,it=o.originX,st=o.originY,at=o.pathLength,ct=o.pathSpacing,lt=ct===void 0?1:ct,dt=o.pathOffset,ht=dt===void 0?0:dt,mt=__rest(o,["attrX","attrY","originX","originY","pathLength","pathSpacing","pathOffset"]);buildHTMLStyles(et,mt,tt,rt),et.attrs=et.style,et.style={};var ft=et.attrs,pt=et.style,yt=et.dimensions;ft.transform&&(yt&&(pt.transform=ft.transform),delete ft.transform),yt&&(it!==void 0||st!==void 0||pt.transform)&&(pt.transformOrigin=calcSVGTransformOrigin(yt,it!==void 0?it:.5,st!==void 0?st:.5)),nt!==void 0&&(ft.x=nt),ot!==void 0&&(ft.y=ot),at!==void 0&&buildSVGPath(ft,at,lt,ht)}var createSvgRenderState=function(){return __assign(__assign({},createHtmlRenderState()),{attrs:{}})};function useSVGProps(et,o){var tt=reactExports.useMemo(function(){var nt=createSvgRenderState();return buildSVGAttrs(nt,o,{enableHardwareAcceleration:!1},et.transformTemplate),__assign(__assign({},nt.attrs),{style:__assign({},nt.style)})},[o]);if(et.style){var rt={};copyRawValuesOnly(rt,et.style,et),tt.style=__assign(__assign({},rt),tt.style)}return tt}function createUseRender(et){et===void 0&&(et=!1);var o=function(tt,rt,nt,ot,it,st){var at=it.latestValues,ct=isSVGComponent(tt)?useSVGProps:useHTMLProps,lt=ct(rt,at,st),dt=filterProps(rt,typeof tt=="string",et),ht=__assign(__assign(__assign({},dt),lt),{ref:ot});return nt&&(ht["data-projection-id"]=nt),reactExports.createElement(tt,ht)};return o}var CAMEL_CASE_PATTERN=/([a-z])([A-Z])/g,REPLACE_TEMPLATE="$1-$2",camelToDash=function(et){return et.replace(CAMEL_CASE_PATTERN,REPLACE_TEMPLATE).toLowerCase()};function renderHTML(et,o,tt,rt){var nt=o.style,ot=o.vars;Object.assign(et.style,nt,rt&&rt.getProjectionStyles(tt));for(var it in ot)et.style.setProperty(it,ot[it])}var camelCaseAttributes=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength"]);function renderSVG(et,o,tt,rt){renderHTML(et,o,void 0,rt);for(var nt in o.attrs)et.setAttribute(camelCaseAttributes.has(nt)?nt:camelToDash(nt),o.attrs[nt])}function scrapeMotionValuesFromProps$1(et){var o=et.style,tt={};for(var rt in o)(isMotionValue(o[rt])||isForcedMotionValue(rt,et))&&(tt[rt]=o[rt]);return tt}function scrapeMotionValuesFromProps(et){var o=scrapeMotionValuesFromProps$1(et);for(var tt in et)if(isMotionValue(et[tt])){var rt=tt==="x"||tt==="y"?"attr"+tt.toUpperCase():tt;o[rt]=et[tt]}return o}function isAnimationControls(et){return typeof et=="object"&&typeof et.start=="function"}var isKeyframesTarget=function(et){return Array.isArray(et)},isCustomValue=function(et){return!!(et&&typeof et=="object"&&et.mix&&et.toValue)},resolveFinalValueInKeyframes=function(et){return isKeyframesTarget(et)?et[et.length-1]||0:et};function resolveMotionValue(et){var o=isMotionValue(et)?et.get():et;return isCustomValue(o)?o.toValue():o}function makeState(et,o,tt,rt){var nt=et.scrapeMotionValuesFromProps,ot=et.createRenderState,it=et.onMount,st={latestValues:makeLatestValues(o,tt,rt,nt),renderState:ot()};return it&&(st.mount=function(at){return it(o,at,st)}),st}var makeUseVisualState=function(et){return function(o,tt){var rt=reactExports.useContext(MotionContext),nt=reactExports.useContext(PresenceContext);return tt?makeState(et,o,rt,nt):useConstant(function(){return makeState(et,o,rt,nt)})}};function makeLatestValues(et,o,tt,rt){var nt={},ot=(tt==null?void 0:tt.initial)===!1,it=rt(et);for(var st in it)nt[st]=resolveMotionValue(it[st]);var at=et.initial,ct=et.animate,lt=checkIfControllingVariants(et),dt=checkIfVariantNode(et);o&&dt&&!lt&&et.inherit!==!1&&(at??(at=o.initial),ct??(ct=o.animate));var ht=ot||at===!1,mt=ht?ct:at;if(mt&&typeof mt!="boolean"&&!isAnimationControls(mt)){var ft=Array.isArray(mt)?mt:[mt];ft.forEach(function(pt){var yt=resolveVariantFromProps(et,pt);if(yt){var gt=yt.transitionEnd;yt.transition;var bt=__rest(yt,["transitionEnd","transition"]);for(var xt in bt){var vt=bt[xt];if(Array.isArray(vt)){var Et=ht?vt.length-1:0;vt=vt[Et]}vt!==null&&(nt[xt]=vt)}for(var xt in gt)nt[xt]=gt[xt]}})}return nt}var svgMotionConfig={useVisualState:makeUseVisualState({scrapeMotionValuesFromProps,createRenderState:createSvgRenderState,onMount:function(et,o,tt){var rt=tt.renderState,nt=tt.latestValues;try{rt.dimensions=typeof o.getBBox=="function"?o.getBBox():o.getBoundingClientRect()}catch{rt.dimensions={x:0,y:0,width:0,height:0}}buildSVGAttrs(rt,nt,{enableHardwareAcceleration:!1},et.transformTemplate),renderSVG(o,rt)}})},htmlMotionConfig={useVisualState:makeUseVisualState({scrapeMotionValuesFromProps:scrapeMotionValuesFromProps$1,createRenderState:createHtmlRenderState})};function createDomMotionConfig(et,o,tt,rt,nt){var ot=o.forwardMotionProps,it=ot===void 0?!1:ot,st=isSVGComponent(et)?svgMotionConfig:htmlMotionConfig;return __assign(__assign({},st),{preloadedFeatures:tt,useRender:createUseRender(it),createVisualElement:rt,projectionNodeConstructor:nt,Component:et})}var AnimationType;(function(et){et.Animate="animate",et.Hover="whileHover",et.Tap="whileTap",et.Drag="whileDrag",et.Focus="whileFocus",et.InView="whileInView",et.Exit="exit"})(AnimationType||(AnimationType={}));function addDomEvent(et,o,tt,rt){return rt===void 0&&(rt={passive:!0}),et.addEventListener(o,tt,rt),function(){return et.removeEventListener(o,tt)}}function useDomEvent(et,o,tt,rt){reactExports.useEffect(function(){var nt=et.current;if(tt&&nt)return addDomEvent(nt,o,tt,rt)},[et,o,tt,rt])}function useFocusGesture(et){var o=et.whileFocus,tt=et.visualElement,rt=function(){var ot;(ot=tt.animationState)===null||ot===void 0||ot.setActive(AnimationType.Focus,!0)},nt=function(){var ot;(ot=tt.animationState)===null||ot===void 0||ot.setActive(AnimationType.Focus,!1)};useDomEvent(tt,"focus",o?rt:void 0),useDomEvent(tt,"blur",o?nt:void 0)}function isMouseEvent(et){return typeof PointerEvent<"u"&&et instanceof PointerEvent?et.pointerType==="mouse":et instanceof MouseEvent}function isTouchEvent(et){var o=!!et.touches;return o}function filterPrimaryPointer(et){return function(o){var tt=o instanceof MouseEvent,rt=!tt||tt&&o.button===0;rt&&et(o)}}var defaultPagePoint={pageX:0,pageY:0};function pointFromTouch(et,o){o===void 0&&(o="page");var tt=et.touches[0]||et.changedTouches[0],rt=tt||defaultPagePoint;return{x:rt[o+"X"],y:rt[o+"Y"]}}function pointFromMouse(et,o){return o===void 0&&(o="page"),{x:et[o+"X"],y:et[o+"Y"]}}function extractEventInfo(et,o){return o===void 0&&(o="page"),{point:isTouchEvent(et)?pointFromTouch(et,o):pointFromMouse(et,o)}}var wrapHandler=function(et,o){o===void 0&&(o=!1);var tt=function(rt){return et(rt,extractEventInfo(rt))};return o?filterPrimaryPointer(tt):tt},supportsPointerEvents=function(){return isBrowser$3&&window.onpointerdown===null},supportsTouchEvents=function(){return isBrowser$3&&window.ontouchstart===null},supportsMouseEvents=function(){return isBrowser$3&&window.onmousedown===null},mouseEventNames={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},touchEventNames={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function getPointerEventName(et){return supportsPointerEvents()?et:supportsTouchEvents()?touchEventNames[et]:supportsMouseEvents()?mouseEventNames[et]:et}function addPointerEvent(et,o,tt,rt){return addDomEvent(et,getPointerEventName(o),wrapHandler(tt,o==="pointerdown"),rt)}function usePointerEvent(et,o,tt,rt){return useDomEvent(et,getPointerEventName(o),tt&&wrapHandler(tt,o==="pointerdown"),rt)}function createLock(et){var o=null;return function(){var tt=function(){o=null};return o===null?(o=et,tt):!1}}var globalHorizontalLock=createLock("dragHorizontal"),globalVerticalLock=createLock("dragVertical");function getGlobalLock(et){var o=!1;if(et==="y")o=globalVerticalLock();else if(et==="x")o=globalHorizontalLock();else{var tt=globalHorizontalLock(),rt=globalVerticalLock();tt&&rt?o=function(){tt(),rt()}:(tt&&tt(),rt&&rt())}return o}function isDragActive(){var et=getGlobalLock(!0);return et?(et(),!1):!0}function createHoverEvent(et,o,tt){return function(rt,nt){var ot;!isMouseEvent(rt)||isDragActive()||((ot=et.animationState)===null||ot===void 0||ot.setActive(AnimationType.Hover,o),tt==null||tt(rt,nt))}}function useHoverGesture(et){var o=et.onHoverStart,tt=et.onHoverEnd,rt=et.whileHover,nt=et.visualElement;usePointerEvent(nt,"pointerenter",o||rt?createHoverEvent(nt,!0,o):void 0,{passive:!o}),usePointerEvent(nt,"pointerleave",tt||rt?createHoverEvent(nt,!1,tt):void 0,{passive:!tt})}var isNodeOrChild=function(et,o){return o?et===o?!0:isNodeOrChild(et,o.parentElement):!1};function useUnmountEffect(et){return reactExports.useEffect(function(){return function(){return et()}},[])}const clamp$1=(et,o,tt)=>Math.min(Math.max(tt,et),o),safeMin=.001,minDuration=.01,maxDuration=10,minDamping=.05,maxDamping=1;function findSpring({duration:et=800,bounce:o=.25,velocity:tt=0,mass:rt=1}){let nt,ot,it=1-o;it=clamp$1(minDamping,maxDamping,it),et=clamp$1(minDuration,maxDuration,et/1e3),it<1?(nt=ct=>{const lt=ct*it,dt=lt*et,ht=lt-tt,mt=calcAngularFreq(ct,it),ft=Math.exp(-dt);return safeMin-ht/mt*ft},ot=ct=>{const dt=ct*it*et,ht=dt*tt+tt,mt=Math.pow(it,2)*Math.pow(ct,2)*et,ft=Math.exp(-dt),pt=calcAngularFreq(Math.pow(ct,2),it);return(-nt(ct)+safeMin>0?-1:1)*((ht-mt)*ft)/pt}):(nt=ct=>{const lt=Math.exp(-ct*et),dt=(ct-tt)*et+1;return-safeMin+lt*dt},ot=ct=>{const lt=Math.exp(-ct*et),dt=(tt-ct)*(et*et);return lt*dt});const st=5/et,at=approximateRoot(nt,ot,st);if(et=et*1e3,isNaN(at))return{stiffness:100,damping:10,duration:et};{const ct=Math.pow(at,2)*rt;return{stiffness:ct,damping:it*2*Math.sqrt(rt*ct),duration:et}}}const rootIterations=12;function approximateRoot(et,o,tt){let rt=tt;for(let nt=1;ntet[tt]!==void 0)}function getSpringOptions(et){let o=Object.assign({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},et);if(!isSpringType(et,physicsKeys)&&isSpringType(et,durationKeys)){const tt=findSpring(et);o=Object.assign(Object.assign(Object.assign({},o),tt),{velocity:0,mass:1}),o.isResolvedFromDuration=!0}return o}function spring(et){var{from:o=0,to:tt=1,restSpeed:rt=2,restDelta:nt}=et,ot=__rest(et,["from","to","restSpeed","restDelta"]);const it={done:!1,value:o};let{stiffness:st,damping:at,mass:ct,velocity:lt,duration:dt,isResolvedFromDuration:ht}=getSpringOptions(ot),mt=zero$1,ft=zero$1;function pt(){const yt=lt?-(lt/1e3):0,gt=tt-o,bt=at/(2*Math.sqrt(st*ct)),xt=Math.sqrt(st/ct)/1e3;if(nt===void 0&&(nt=Math.min(Math.abs(tt-o)/100,.4)),bt<1){const vt=calcAngularFreq(xt,bt);mt=Et=>{const Ct=Math.exp(-bt*xt*Et);return tt-Ct*((yt+bt*xt*gt)/vt*Math.sin(vt*Et)+gt*Math.cos(vt*Et))},ft=Et=>{const Ct=Math.exp(-bt*xt*Et);return bt*xt*Ct*(Math.sin(vt*Et)*(yt+bt*xt*gt)/vt+gt*Math.cos(vt*Et))-Ct*(Math.cos(vt*Et)*(yt+bt*xt*gt)-vt*gt*Math.sin(vt*Et))}}else if(bt===1)mt=vt=>tt-Math.exp(-xt*vt)*(gt+(yt+xt*gt)*vt);else{const vt=xt*Math.sqrt(bt*bt-1);mt=Et=>{const Ct=Math.exp(-bt*xt*Et),St=Math.min(vt*Et,300);return tt-Ct*((yt+bt*xt*gt)*Math.sinh(St)+vt*gt*Math.cosh(St))/vt}}}return pt(),{next:yt=>{const gt=mt(yt);if(ht)it.done=yt>=dt;else{const bt=ft(yt)*1e3,xt=Math.abs(bt)<=rt,vt=Math.abs(tt-gt)<=nt;it.done=xt&&vt}return it.value=it.done?tt:gt,it},flipTarget:()=>{lt=-lt,[o,tt]=[tt,o],pt()}}}spring.needsInterpolation=(et,o)=>typeof et=="string"||typeof o=="string";const zero$1=et=>0,progress=(et,o,tt)=>{const rt=o-et;return rt===0?1:(tt-et)/rt},mix=(et,o,tt)=>-tt*et+tt*o+et;function hueToRgb(et,o,tt){return tt<0&&(tt+=1),tt>1&&(tt-=1),tt<1/6?et+(o-et)*6*tt:tt<1/2?o:tt<2/3?et+(o-et)*(2/3-tt)*6:et}function hslaToRgba({hue:et,saturation:o,lightness:tt,alpha:rt}){et/=360,o/=100,tt/=100;let nt=0,ot=0,it=0;if(!o)nt=ot=it=tt;else{const st=tt<.5?tt*(1+o):tt+o-tt*o,at=2*tt-st;nt=hueToRgb(at,st,et+1/3),ot=hueToRgb(at,st,et),it=hueToRgb(at,st,et-1/3)}return{red:Math.round(nt*255),green:Math.round(ot*255),blue:Math.round(it*255),alpha:rt}}const mixLinearColor=(et,o,tt)=>{const rt=et*et,nt=o*o;return Math.sqrt(Math.max(0,tt*(nt-rt)+rt))},colorTypes=[hex,rgba,hsla],getColorType=et=>colorTypes.find(o=>o.test(et)),mixColor=(et,o)=>{let tt=getColorType(et),rt=getColorType(o),nt=tt.parse(et),ot=rt.parse(o);tt===hsla&&(nt=hslaToRgba(nt),tt=rgba),rt===hsla&&(ot=hslaToRgba(ot),rt=rgba);const it=Object.assign({},nt);return st=>{for(const at in it)at!=="alpha"&&(it[at]=mixLinearColor(nt[at],ot[at],st));return it.alpha=mix(nt.alpha,ot.alpha,st),tt.transform(it)}},isNum=et=>typeof et=="number",combineFunctions=(et,o)=>tt=>o(et(tt)),pipe$1=(...et)=>et.reduce(combineFunctions);function getMixer(et,o){return isNum(et)?tt=>mix(et,o,tt):color$1.test(et)?mixColor(et,o):mixComplex(et,o)}const mixArray=(et,o)=>{const tt=[...et],rt=tt.length,nt=et.map((ot,it)=>getMixer(ot,o[it]));return ot=>{for(let it=0;it{const tt=Object.assign(Object.assign({},et),o),rt={};for(const nt in tt)et[nt]!==void 0&&o[nt]!==void 0&&(rt[nt]=getMixer(et[nt],o[nt]));return nt=>{for(const ot in rt)tt[ot]=rt[ot](nt);return tt}};function analyse(et){const o=complex.parse(et),tt=o.length;let rt=0,nt=0,ot=0;for(let it=0;it{const tt=complex.createTransformer(o),rt=analyse(et),nt=analyse(o);return rt.numHSL===nt.numHSL&&rt.numRGB===nt.numRGB&&rt.numNumbers>=nt.numNumbers?pipe$1(mixArray(rt.parsed,nt.parsed),tt):it=>`${it>0?o:et}`},mixNumber=(et,o)=>tt=>mix(et,o,tt);function detectMixerFactory(et){if(typeof et=="number")return mixNumber;if(typeof et=="string")return color$1.test(et)?mixColor:mixComplex;if(Array.isArray(et))return mixArray;if(typeof et=="object")return mixObject}function createMixers(et,o,tt){const rt=[],nt=tt||detectMixerFactory(et[0]),ot=et.length-1;for(let it=0;ittt(progress(et,o,rt))}function slowInterpolate(et,o){const tt=et.length,rt=tt-1;return nt=>{let ot=0,it=!1;if(nt<=et[0]?it=!0:nt>=et[rt]&&(ot=rt-1,it=!0),!it){let at=1;for(;atnt||at===rt);at++);ot=at-1}const st=progress(et[ot],et[ot+1],nt);return o[ot](st)}}function interpolate(et,o,{clamp:tt=!0,ease:rt,mixer:nt}={}){const ot=et.length;invariant$1(ot===o.length),invariant$1(!rt||!Array.isArray(rt)||rt.length===ot-1),et[0]>et[ot-1]&&(et=[].concat(et),o=[].concat(o),et.reverse(),o.reverse());const it=createMixers(o,rt,nt),st=ot===2?fastInterpolate(et,it):slowInterpolate(et,it);return tt?at=>st(clamp$1(et[0],et[ot-1],at)):st}const reverseEasing=et=>o=>1-et(1-o),mirrorEasing=et=>o=>o<=.5?et(2*o)/2:(2-et(2*(1-o)))/2,createExpoIn=et=>o=>Math.pow(o,et),createBackIn=et=>o=>o*o*((et+1)*o-et),createAnticipate=et=>{const o=createBackIn(et);return tt=>(tt*=2)<1?.5*o(tt):.5*(2-Math.pow(2,-10*(tt-1)))},DEFAULT_OVERSHOOT_STRENGTH=1.525,BOUNCE_FIRST_THRESHOLD=4/11,BOUNCE_SECOND_THRESHOLD=8/11,BOUNCE_THIRD_THRESHOLD=9/10,linear=et=>et,easeIn=createExpoIn(2),easeOut=reverseEasing(easeIn),easeInOut=mirrorEasing(easeIn),circIn=et=>1-Math.sin(Math.acos(et)),circOut=reverseEasing(circIn),circInOut=mirrorEasing(circOut),backIn=createBackIn(DEFAULT_OVERSHOOT_STRENGTH),backOut=reverseEasing(backIn),backInOut=mirrorEasing(backIn),anticipate=createAnticipate(DEFAULT_OVERSHOOT_STRENGTH),ca=4356/361,cb=35442/1805,cc=16061/1805,bounceOut=et=>{if(et===1||et===0)return et;const o=et*et;return etet<.5?.5*(1-bounceOut(1-et*2)):.5*bounceOut(et*2-1)+.5;function defaultEasing(et,o){return et.map(()=>o||easeInOut).splice(0,et.length-1)}function defaultOffset(et){const o=et.length;return et.map((tt,rt)=>rt!==0?rt/(o-1):0)}function convertOffsetToTimes(et,o){return et.map(tt=>tt*o)}function keyframes$1({from:et=0,to:o=1,ease:tt,offset:rt,duration:nt=300}){const ot={done:!1,value:et},it=Array.isArray(o)?o:[et,o],st=convertOffsetToTimes(rt&&rt.length===it.length?rt:defaultOffset(it),nt);function at(){return interpolate(st,it,{ease:Array.isArray(tt)?tt:defaultEasing(it,tt)})}let ct=at();return{next:lt=>(ot.value=ct(lt),ot.done=lt>=nt,ot),flipTarget:()=>{it.reverse(),ct=at()}}}function decay({velocity:et=0,from:o=0,power:tt=.8,timeConstant:rt=350,restDelta:nt=.5,modifyTarget:ot}){const it={done:!1,value:o};let st=tt*et;const at=o+st,ct=ot===void 0?at:ot(at);return ct!==at&&(st=ct-o),{next:lt=>{const dt=-st*Math.exp(-lt/rt);return it.done=!(dt>nt||dt<-nt),it.value=it.done?ct:ct+dt,it},flipTarget:()=>{}}}const types$3={keyframes:keyframes$1,spring,decay};function detectAnimationFromOptions(et){if(Array.isArray(et.to))return keyframes$1;if(types$3[et.type])return types$3[et.type];const o=new Set(Object.keys(et));return o.has("ease")||o.has("duration")&&!o.has("dampingRatio")?keyframes$1:o.has("dampingRatio")||o.has("stiffness")||o.has("mass")||o.has("damping")||o.has("restSpeed")||o.has("restDelta")?spring:keyframes$1}const defaultTimestep=1/60*1e3,getCurrentTime=typeof performance<"u"?()=>performance.now():()=>Date.now(),onNextFrame=typeof window<"u"?et=>window.requestAnimationFrame(et):et=>setTimeout(()=>et(getCurrentTime()),defaultTimestep);function createRenderStep(et){let o=[],tt=[],rt=0,nt=!1,ot=!1;const it=new WeakSet,st={schedule:(at,ct=!1,lt=!1)=>{const dt=lt&&nt,ht=dt?o:tt;return ct&&it.add(at),ht.indexOf(at)===-1&&(ht.push(at),dt&&nt&&(rt=o.length)),at},cancel:at=>{const ct=tt.indexOf(at);ct!==-1&&tt.splice(ct,1),it.delete(at)},process:at=>{if(nt){ot=!0;return}if(nt=!0,[o,tt]=[tt,o],tt.length=0,rt=o.length,rt)for(let ct=0;ct(et[o]=createRenderStep(()=>runNextFrame=!0),et),{}),sync=stepsOrder.reduce((et,o)=>{const tt=steps[o];return et[o]=(rt,nt=!1,ot=!1)=>(runNextFrame||startLoop(),tt.schedule(rt,nt,ot)),et},{}),cancelSync=stepsOrder.reduce((et,o)=>(et[o]=steps[o].cancel,et),{}),flushSync=stepsOrder.reduce((et,o)=>(et[o]=()=>steps[o].process(frame),et),{}),processStep=et=>steps[et].process(frame),processFrame=et=>{runNextFrame=!1,frame.delta=useDefaultElapsed?defaultTimestep:Math.max(Math.min(et-frame.timestamp,maxElapsed),1),frame.timestamp=et,isProcessing=!0,stepsOrder.forEach(processStep),isProcessing=!1,runNextFrame&&(useDefaultElapsed=!1,onNextFrame(processFrame))},startLoop=()=>{runNextFrame=!0,useDefaultElapsed=!0,isProcessing||onNextFrame(processFrame)},getFrameData=()=>frame;function loopElapsed(et,o,tt=0){return et-o-tt}function reverseElapsed(et,o,tt=0,rt=!0){return rt?loopElapsed(o+-et,o,tt):o-(et-o)+tt}function hasRepeatDelayElapsed(et,o,tt,rt){return rt?et>=o+tt:et<=-tt}const framesync=et=>{const o=({delta:tt})=>et(tt);return{start:()=>sync.update(o,!0),stop:()=>cancelSync.update(o)}};function animate$1(et){var o,tt,{from:rt,autoplay:nt=!0,driver:ot=framesync,elapsed:it=0,repeat:st=0,repeatType:at="loop",repeatDelay:ct=0,onPlay:lt,onStop:dt,onComplete:ht,onRepeat:mt,onUpdate:ft}=et,pt=__rest(et,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]);let{to:yt}=pt,gt,bt=0,xt=pt.duration,vt,Et=!1,Ct=!0,St;const At=detectAnimationFromOptions(pt);!((tt=(o=At).needsInterpolation)===null||tt===void 0)&&tt.call(o,rt,yt)&&(St=interpolate([0,100],[rt,yt],{clamp:!1}),rt=0,yt=100);const kt=At(Object.assign(Object.assign({},pt),{from:rt,to:yt}));function It(){bt++,at==="reverse"?(Ct=bt%2===0,it=reverseElapsed(it,xt,ct,Ct)):(it=loopElapsed(it,xt,ct),at==="mirror"&&kt.flipTarget()),Et=!1,mt&&mt()}function Nt(){gt.stop(),ht&&ht()}function Lt(zt){if(Ct||(zt=-zt),it+=zt,!Et){const Ut=kt.next(Math.max(0,it));vt=Ut.value,St&&(vt=St(vt)),Et=Ct?Ut.done:it<=0}ft==null||ft(vt),Et&&(bt===0&&(xt??(xt=it)),bt{dt==null||dt(),gt.stop()}}}function velocityPerSecond(et,o){return o?et*(1e3/o):0}function inertia({from:et=0,velocity:o=0,min:tt,max:rt,power:nt=.8,timeConstant:ot=750,bounceStiffness:it=500,bounceDamping:st=10,restDelta:at=1,modifyTarget:ct,driver:lt,onUpdate:dt,onComplete:ht,onStop:mt}){let ft;function pt(xt){return tt!==void 0&&xtrt}function yt(xt){return tt===void 0?rt:rt===void 0||Math.abs(tt-xt){var Et;dt==null||dt(vt),(Et=xt.onUpdate)===null||Et===void 0||Et.call(xt,vt)},onComplete:ht,onStop:mt}))}function bt(xt){gt(Object.assign({type:"spring",stiffness:it,damping:st,restDelta:at},xt))}if(pt(et))bt({from:et,velocity:o,to:yt(et)});else{let xt=nt*o+et;typeof ct<"u"&&(xt=ct(xt));const vt=yt(xt),Et=vt===tt?-1:1;let Ct,St;const At=kt=>{Ct=St,St=kt,o=velocityPerSecond(kt-Ct,getFrameData().delta),(Et===1&&kt>vt||Et===-1&&ktft==null?void 0:ft.stop()}}const isPoint=et=>et.hasOwnProperty("x")&&et.hasOwnProperty("y"),isPoint3D=et=>isPoint(et)&&et.hasOwnProperty("z"),distance1D=(et,o)=>Math.abs(et-o);function distance(et,o){if(isNum(et)&&isNum(o))return distance1D(et,o);if(isPoint(et)&&isPoint(o)){const tt=distance1D(et.x,o.x),rt=distance1D(et.y,o.y),nt=isPoint3D(et)&&isPoint3D(o)?distance1D(et.z,o.z):0;return Math.sqrt(Math.pow(tt,2)+Math.pow(rt,2)+Math.pow(nt,2))}}const a=(et,o)=>1-3*o+3*et,b$3=(et,o)=>3*o-6*et,c$2=et=>3*et,calcBezier=(et,o,tt)=>((a(o,tt)*et+b$3(o,tt))*et+c$2(o))*et,getSlope=(et,o,tt)=>3*a(o,tt)*et*et+2*b$3(o,tt)*et+c$2(o),subdivisionPrecision=1e-7,subdivisionMaxIterations=10;function binarySubdivide(et,o,tt,rt,nt){let ot,it,st=0;do it=o+(tt-o)/2,ot=calcBezier(it,rt,nt)-et,ot>0?tt=it:o=it;while(Math.abs(ot)>subdivisionPrecision&&++st=newtonMinSlope?newtonRaphsonIterate(it,dt,et,tt):ht===0?dt:binarySubdivide(it,st,st+kSampleStepSize,et,tt)}return it=>it===0||it===1?it:calcBezier(ot(it),o,rt)}function useTapGesture(et){var o=et.onTap,tt=et.onTapStart,rt=et.onTapCancel,nt=et.whileTap,ot=et.visualElement,it=o||tt||rt||nt,st=reactExports.useRef(!1),at=reactExports.useRef(null),ct={passive:!(tt||o||rt||ft)};function lt(){var pt;(pt=at.current)===null||pt===void 0||pt.call(at),at.current=null}function dt(){var pt;return lt(),st.current=!1,(pt=ot.animationState)===null||pt===void 0||pt.setActive(AnimationType.Tap,!1),!isDragActive()}function ht(pt,yt){dt()&&(isNodeOrChild(ot.getInstance(),pt.target)?o==null||o(pt,yt):rt==null||rt(pt,yt))}function mt(pt,yt){dt()&&(rt==null||rt(pt,yt))}function ft(pt,yt){var gt;lt(),!st.current&&(st.current=!0,at.current=pipe$1(addPointerEvent(window,"pointerup",ht,ct),addPointerEvent(window,"pointercancel",mt,ct)),(gt=ot.animationState)===null||gt===void 0||gt.setActive(AnimationType.Tap,!0),tt==null||tt(pt,yt))}usePointerEvent(ot,"pointerdown",it?ft:void 0,ct),useUnmountEffect(lt)}var warned=new Set;function warnOnce(et,o,tt){warned.has(o)||(console.warn(o),warned.add(o))}var observerCallbacks=new WeakMap,observers$1=new WeakMap,fireObserverCallback=function(et){var o;(o=observerCallbacks.get(et.target))===null||o===void 0||o(et)},fireAllObserverCallbacks=function(et){et.forEach(fireObserverCallback)};function initIntersectionObserver(et){var o=et.root,tt=__rest(et,["root"]),rt=o||document;observers$1.has(rt)||observers$1.set(rt,{});var nt=observers$1.get(rt),ot=JSON.stringify(tt);return nt[ot]||(nt[ot]=new IntersectionObserver(fireAllObserverCallbacks,__assign({root:o},tt))),nt[ot]}function observeIntersection(et,o,tt){var rt=initIntersectionObserver(o);return observerCallbacks.set(et,tt),rt.observe(et),function(){observerCallbacks.delete(et),rt.unobserve(et)}}function useViewport(et){var o=et.visualElement,tt=et.whileInView,rt=et.onViewportEnter,nt=et.onViewportLeave,ot=et.viewport,it=ot===void 0?{}:ot,st=reactExports.useRef({hasEnteredView:!1,isInView:!1}),at=!!(tt||rt||nt);it.once&&st.current.hasEnteredView&&(at=!1);var ct=typeof IntersectionObserver>"u"?useMissingIntersectionObserver:useIntersectionObserver;ct(at,st.current,o,it)}var thresholdNames={some:0,all:1};function useIntersectionObserver(et,o,tt,rt){var nt=rt.root,ot=rt.margin,it=rt.amount,st=it===void 0?"some":it,at=rt.once;reactExports.useEffect(function(){if(et){var ct={root:nt==null?void 0:nt.current,rootMargin:ot,threshold:typeof st=="number"?st:thresholdNames[st]},lt=function(dt){var ht,mt=dt.isIntersecting;if(o.isInView!==mt&&(o.isInView=mt,!(at&&!mt&&o.hasEnteredView))){mt&&(o.hasEnteredView=!0),(ht=tt.animationState)===null||ht===void 0||ht.setActive(AnimationType.InView,mt);var ft=tt.getProps(),pt=mt?ft.onViewportEnter:ft.onViewportLeave;pt==null||pt(dt)}};return observeIntersection(tt.getInstance(),ct,lt)}},[et,nt,ot,st])}function useMissingIntersectionObserver(et,o,tt,rt){var nt=rt.fallback,ot=nt===void 0?!0:nt;reactExports.useEffect(function(){!et||!ot||(env$1!=="production"&&warnOnce(!1,"IntersectionObserver not available on this device. whileInView animations will trigger on mount."),requestAnimationFrame(function(){var it;o.hasEnteredView=!0;var st=tt.getProps().onViewportEnter;st==null||st(null),(it=tt.animationState)===null||it===void 0||it.setActive(AnimationType.InView,!0)}))},[et])}var makeRenderlessComponent=function(et){return function(o){return et(o),null}},gestureAnimations={inView:makeRenderlessComponent(useViewport),tap:makeRenderlessComponent(useTapGesture),focus:makeRenderlessComponent(useFocusGesture),hover:makeRenderlessComponent(useHoverGesture)},counter=0,incrementId=function(){return counter++},useId$1=function(){return useConstant(incrementId)};function usePresence$1(){var et=reactExports.useContext(PresenceContext);if(et===null)return[!0,null];var o=et.isPresent,tt=et.onExitComplete,rt=et.register,nt=useId$1();reactExports.useEffect(function(){return rt(nt)},[]);var ot=function(){return tt==null?void 0:tt(nt)};return!o&&tt?[!1,ot]:[!0]}function shallowCompare(et,o){if(!Array.isArray(o))return!1;var tt=o.length;if(tt!==et.length)return!1;for(var rt=0;rt-1&&et.splice(tt,1)}var SubscriptionManager$1=function(){function et(){this.subscriptions=[]}return et.prototype.add=function(o){var tt=this;return addUniqueItem(this.subscriptions,o),function(){return removeItem(tt.subscriptions,o)}},et.prototype.notify=function(o,tt,rt){var nt=this.subscriptions.length;if(nt)if(nt===1)this.subscriptions[0](o,tt,rt);else for(var ot=0;otbt&&Nt,Xt=Array.isArray(It)?It:[It],Wt=Xt.reduce(ot,{});Lt===!1&&(Wt={});var Ft=kt.prevResolvedValues,qt=Ft===void 0?{}:Ft,Pt=__assign(__assign({},qt),Wt),Yt=function(rr){Ut=!0,yt.delete(rr),kt.needsAnimating[rr]=!0};for(var Qt in Pt){var jt=Wt[Qt],Gt=qt[Qt];gt.hasOwnProperty(Qt)||(jt!==Gt?isKeyframesTarget(jt)&&isKeyframesTarget(Gt)?!shallowCompare(jt,Gt)||zt?Yt(Qt):kt.protectedKeys[Qt]=!0:jt!==void 0?Yt(Qt):yt.add(Qt):jt!==void 0&&yt.has(Qt)?Yt(Qt):kt.protectedKeys[Qt]=!0)}kt.prevProp=It,kt.prevResolvedValues=Wt,kt.isActive&&(gt=__assign(__assign({},gt),Wt)),nt&&et.blockInitialAnimation&&(Ut=!1),Ut&&!Mt&&pt.push.apply(pt,__spreadArray([],__read(Xt.map(function(rr){return{animation:rr,options:__assign({type:At},lt)}})),!1))},vt=0;vt=3;if(!(!mt&&!ft)){var pt=ht.point,yt=getFrameData().timestamp;nt.history.push(__assign(__assign({},pt),{timestamp:yt}));var gt=nt.handlers,bt=gt.onStart,xt=gt.onMove;mt||(bt&&bt(nt.lastMoveEvent,ht),nt.startEvent=nt.lastMoveEvent),xt&&xt(nt.lastMoveEvent,ht)}}},this.handlePointerMove=function(ht,mt){if(nt.lastMoveEvent=ht,nt.lastMoveEventInfo=transformPoint(mt,nt.transformPagePoint),isMouseEvent(ht)&&ht.buttons===0){nt.handlePointerUp(ht,mt);return}sync.update(nt.updatePoint,!0)},this.handlePointerUp=function(ht,mt){nt.end();var ft=nt.handlers,pt=ft.onEnd,yt=ft.onSessionEnd,gt=getPanInfo(transformPoint(mt,nt.transformPagePoint),nt.history);nt.startEvent&&pt&&pt(ht,gt),yt&&yt(ht,gt)},!(isTouchEvent(o)&&o.touches.length>1)){this.handlers=tt,this.transformPagePoint=it;var st=extractEventInfo(o),at=transformPoint(st,this.transformPagePoint),ct=at.point,lt=getFrameData().timestamp;this.history=[__assign(__assign({},ct),{timestamp:lt})];var dt=tt.onSessionStart;dt&&dt(o,getPanInfo(at,this.history)),this.removeListeners=pipe$1(addPointerEvent(window,"pointermove",this.handlePointerMove),addPointerEvent(window,"pointerup",this.handlePointerUp),addPointerEvent(window,"pointercancel",this.handlePointerUp))}}return et.prototype.updateHandlers=function(o){this.handlers=o},et.prototype.end=function(){this.removeListeners&&this.removeListeners(),cancelSync.update(this.updatePoint)},et}();function transformPoint(et,o){return o?{point:o(et.point)}:et}function subtractPoint(et,o){return{x:et.x-o.x,y:et.y-o.y}}function getPanInfo(et,o){var tt=et.point;return{point:tt,delta:subtractPoint(tt,lastDevicePoint(o)),offset:subtractPoint(tt,startDevicePoint(o)),velocity:getVelocity(o,.1)}}function startDevicePoint(et){return et[0]}function lastDevicePoint(et){return et[et.length-1]}function getVelocity(et,o){if(et.length<2)return{x:0,y:0};for(var tt=et.length-1,rt=null,nt=lastDevicePoint(et);tt>=0&&(rt=et[tt],!(nt.timestamp-rt.timestamp>secondsToMilliseconds(o)));)tt--;if(!rt)return{x:0,y:0};var ot=(nt.timestamp-rt.timestamp)/1e3;if(ot===0)return{x:0,y:0};var it={x:(nt.x-rt.x)/ot,y:(nt.y-rt.y)/ot};return it.x===1/0&&(it.x=0),it.y===1/0&&(it.y=0),it}function calcLength(et){return et.max-et.min}function isNear(et,o,tt){return o===void 0&&(o=0),tt===void 0&&(tt=.01),distance(et,o)nt&&(et=tt?mix(nt,et,tt.max):Math.min(et,nt)),et}function calcRelativeAxisConstraints(et,o,tt){return{min:o!==void 0?et.min+o:void 0,max:tt!==void 0?et.max+tt-(et.max-et.min):void 0}}function calcRelativeConstraints(et,o){var tt=o.top,rt=o.left,nt=o.bottom,ot=o.right;return{x:calcRelativeAxisConstraints(et.x,rt,ot),y:calcRelativeAxisConstraints(et.y,tt,nt)}}function calcViewportAxisConstraints(et,o){var tt,rt=o.min-et.min,nt=o.max-et.max;return o.max-o.minrt?tt=progress(o.min,o.max-rt,et.min):rt>nt&&(tt=progress(et.min,et.max-nt,o.min)),clamp$1(0,1,tt)}function rebaseAxisConstraints(et,o){var tt={};return o.min!==void 0&&(tt.min=o.min-et.min),o.max!==void 0&&(tt.max=o.max-et.min),tt}var defaultElastic=.35;function resolveDragElastic(et){return et===void 0&&(et=defaultElastic),et===!1?et=0:et===!0&&(et=defaultElastic),{x:resolveAxisElastic(et,"left","right"),y:resolveAxisElastic(et,"top","bottom")}}function resolveAxisElastic(et,o,tt){return{min:resolvePointElastic(et,o),max:resolvePointElastic(et,tt)}}function resolvePointElastic(et,o){var tt;return typeof et=="number"?et:(tt=et[o])!==null&&tt!==void 0?tt:0}var createAxisDelta=function(){return{translate:0,scale:1,origin:0,originPoint:0}},createDelta=function(){return{x:createAxisDelta(),y:createAxisDelta()}},createAxis=function(){return{min:0,max:0}},createBox=function(){return{x:createAxis(),y:createAxis()}};function eachAxis(et){return[et("x"),et("y")]}function convertBoundingBoxToBox(et){var o=et.top,tt=et.left,rt=et.right,nt=et.bottom;return{x:{min:tt,max:rt},y:{min:o,max:nt}}}function convertBoxToBoundingBox(et){var o=et.x,tt=et.y;return{top:tt.min,right:o.max,bottom:tt.max,left:o.min}}function transformBoxPoints(et,o){if(!o)return et;var tt=o({x:et.left,y:et.top}),rt=o({x:et.right,y:et.bottom});return{top:tt.y,left:tt.x,bottom:rt.y,right:rt.x}}function isIdentityScale(et){return et===void 0||et===1}function hasScale(et){var o=et.scale,tt=et.scaleX,rt=et.scaleY;return!isIdentityScale(o)||!isIdentityScale(tt)||!isIdentityScale(rt)}function hasTransform(et){return hasScale(et)||hasTranslate(et.x)||hasTranslate(et.y)||et.z||et.rotate||et.rotateX||et.rotateY}function hasTranslate(et){return et&&et!=="0%"}function scalePoint(et,o,tt){var rt=et-tt,nt=o*rt;return tt+nt}function applyPointDelta(et,o,tt,rt,nt){return nt!==void 0&&(et=scalePoint(et,nt,rt)),scalePoint(et,tt,rt)+o}function applyAxisDelta(et,o,tt,rt,nt){o===void 0&&(o=0),tt===void 0&&(tt=1),et.min=applyPointDelta(et.min,o,tt,rt,nt),et.max=applyPointDelta(et.max,o,tt,rt,nt)}function applyBoxDelta(et,o){var tt=o.x,rt=o.y;applyAxisDelta(et.x,tt.translate,tt.scale,tt.originPoint),applyAxisDelta(et.y,rt.translate,rt.scale,rt.originPoint)}function applyTreeDeltas(et,o,tt,rt){var nt,ot;rt===void 0&&(rt=!1);var it=tt.length;if(it){o.x=o.y=1;for(var st,at,ct=0;cto?tt="y":Math.abs(et.x)>o&&(tt="x"),tt}function useDrag(et){var o=et.dragControls,tt=et.visualElement,rt=useConstant(function(){return new VisualElementDragControls(tt)});reactExports.useEffect(function(){return o&&o.subscribe(rt)},[rt,o]),reactExports.useEffect(function(){return rt.addListeners()},[rt])}function usePanGesture(et){var o=et.onPan,tt=et.onPanStart,rt=et.onPanEnd,nt=et.onPanSessionStart,ot=et.visualElement,it=o||tt||rt||nt,st=reactExports.useRef(null),at=reactExports.useContext(MotionConfigContext).transformPagePoint,ct={onSessionStart:nt,onStart:tt,onMove:o,onEnd:function(dt,ht){st.current=null,rt&&rt(dt,ht)}};reactExports.useEffect(function(){st.current!==null&&st.current.updateHandlers(ct)});function lt(dt){st.current=new PanSession(dt,ct,{transformPagePoint:at})}usePointerEvent(ot,"pointerdown",it&<),useUnmountEffect(function(){return st.current&&st.current.end()})}var drag={pan:makeRenderlessComponent(usePanGesture),drag:makeRenderlessComponent(useDrag)},names$1=["LayoutMeasure","BeforeLayoutMeasure","LayoutUpdate","ViewportBoxUpdate","Update","Render","AnimationComplete","LayoutAnimationComplete","AnimationStart","LayoutAnimationStart","SetAxisTarget","Unmount"];function createLifecycles(){var et=names$1.map(function(){return new SubscriptionManager$1}),o={},tt={clearAllListeners:function(){return et.forEach(function(rt){return rt.clear()})},updatePropListeners:function(rt){names$1.forEach(function(nt){var ot,it="on"+nt,st=rt[it];(ot=o[nt])===null||ot===void 0||ot.call(o),st&&(o[nt]=tt[it](st))})}};return et.forEach(function(rt,nt){tt["on"+names$1[nt]]=function(ot){return rt.add(ot)},tt["notify"+names$1[nt]]=function(){for(var ot=[],it=0;it=0?window.pageYOffset:null,ct=convertChangedValueTypes(o,et,st);return ot.length&&ot.forEach(function(lt){var dt=__read(lt,2),ht=dt[0],mt=dt[1];et.getValue(ht).set(mt)}),et.syncRender(),at!==null&&window.scrollTo({top:at}),{target:ct,transitionEnd:rt}}else return{target:o,transitionEnd:rt}};function unitConversion(et,o,tt,rt){return hasPositionalKey(o)?checkAndConvertChangedValueTypes(et,o,tt,rt):{target:o,transitionEnd:rt}}var parseDomVariant=function(et,o,tt,rt){var nt=resolveCSSVariables(et,o,rt);return o=nt.target,rt=nt.transitionEnd,unitConversion(et,o,tt,rt)};function getComputedStyle$1(et){return window.getComputedStyle(et)}var htmlConfig={treeType:"dom",readValueFromInstance:function(et,o){if(isTransformProp(o)){var tt=getDefaultValueType(o);return tt&&tt.default||0}else{var rt=getComputedStyle$1(et);return(isCSSVariable$1(o)?rt.getPropertyValue(o):rt[o])||0}},sortNodePosition:function(et,o){return et.compareDocumentPosition(o)&2?1:-1},getBaseTarget:function(et,o){var tt;return(tt=et.style)===null||tt===void 0?void 0:tt[o]},measureViewportBox:function(et,o){var tt=o.transformPagePoint;return measureViewportBox(et,tt)},resetTransform:function(et,o,tt){var rt=tt.transformTemplate;o.style.transform=rt?rt({},""):"none",et.scheduleRender()},restoreTransform:function(et,o){et.style.transform=o.style.transform},removeValueFromRenderState:function(et,o){var tt=o.vars,rt=o.style;delete tt[et],delete rt[et]},makeTargetAnimatable:function(et,o,tt,rt){var nt=tt.transformValues;rt===void 0&&(rt=!0);var ot=o.transition,it=o.transitionEnd,st=__rest(o,["transition","transitionEnd"]),at=getOrigin(st,ot||{},et);if(nt&&(it&&(it=nt(it)),st&&(st=nt(st)),at&&(at=nt(at))),rt){checkTargetForNewValues(et,st,at);var ct=parseDomVariant(et,st,at,it);it=ct.transitionEnd,st=ct.target}return __assign({transition:ot,transitionEnd:it},st)},scrapeMotionValuesFromProps:scrapeMotionValuesFromProps$1,build:function(et,o,tt,rt,nt){et.isVisible!==void 0&&(o.style.visibility=et.isVisible?"visible":"hidden"),buildHTMLStyles(o,tt,rt,nt.transformTemplate)},render:renderHTML},htmlVisualElement=visualElement(htmlConfig),svgVisualElement=visualElement(__assign(__assign({},htmlConfig),{getBaseTarget:function(et,o){return et[o]},readValueFromInstance:function(et,o){var tt;return isTransformProp(o)?((tt=getDefaultValueType(o))===null||tt===void 0?void 0:tt.default)||0:(o=camelCaseAttributes.has(o)?o:camelToDash(o),et.getAttribute(o))},scrapeMotionValuesFromProps,build:function(et,o,tt,rt,nt){buildSVGAttrs(o,tt,rt,nt.transformTemplate)},render:renderSVG})),createDomVisualElement=function(et,o){return isSVGComponent(et)?svgVisualElement(o,{enableHardwareAcceleration:!1}):htmlVisualElement(o,{enableHardwareAcceleration:!0})};function pixelsToPercent(et,o){return o.max===o.min?0:et/(o.max-o.min)*100}var correctBorderRadius={correct:function(et,o){if(!o.target)return et;if(typeof et=="string")if(px.test(et))et=parseFloat(et);else return et;var tt=pixelsToPercent(et,o.target.x),rt=pixelsToPercent(et,o.target.y);return"".concat(tt,"% ").concat(rt,"%")}},varToken="_$css",correctBoxShadow={correct:function(et,o){var tt=o.treeScale,rt=o.projectionDelta,nt=et,ot=et.includes("var("),it=[];ot&&(et=et.replace(cssVariableRegex,function(pt){return it.push(pt),varToken}));var st=complex.parse(et);if(st.length>5)return nt;var at=complex.createTransformer(et),ct=typeof st[0]!="number"?1:0,lt=rt.x.scale*tt.x,dt=rt.y.scale*tt.y;st[0+ct]/=lt,st[1+ct]/=dt;var ht=mix(lt,dt,.5);typeof st[2+ct]=="number"&&(st[2+ct]/=ht),typeof st[3+ct]=="number"&&(st[3+ct]/=ht);var mt=at(st);if(ot){var ft=0;mt=mt.replace(varToken,function(){var pt=it[ft];return ft++,pt})}return mt}},MeasureLayoutWithContext=function(et){__extends(o,et);function o(){return et!==null&&et.apply(this,arguments)||this}return o.prototype.componentDidMount=function(){var tt=this,rt=this.props,nt=rt.visualElement,ot=rt.layoutGroup,it=rt.switchLayoutGroup,st=rt.layoutId,at=nt.projection;addScaleCorrector(defaultScaleCorrectors),at&&(ot!=null&&ot.group&&ot.group.add(at),it!=null&&it.register&&st&&it.register(at),at.root.didUpdate(),at.addEventListener("animationComplete",function(){tt.safeToRemove()}),at.setOptions(__assign(__assign({},at.options),{onExitComplete:function(){return tt.safeToRemove()}}))),globalProjectionState.hasEverUpdated=!0},o.prototype.getSnapshotBeforeUpdate=function(tt){var rt=this,nt=this.props,ot=nt.layoutDependency,it=nt.visualElement,st=nt.drag,at=nt.isPresent,ct=it.projection;return ct&&(ct.isPresent=at,st||tt.layoutDependency!==ot||ot===void 0?ct.willUpdate():this.safeToRemove(),tt.isPresent!==at&&(at?ct.promote():ct.relegate()||sync.postRender(function(){var lt;!((lt=ct.getStack())===null||lt===void 0)&<.members.length||rt.safeToRemove()}))),null},o.prototype.componentDidUpdate=function(){var tt=this.props.visualElement.projection;tt&&(tt.root.didUpdate(),!tt.currentAnimation&&tt.isLead()&&this.safeToRemove())},o.prototype.componentWillUnmount=function(){var tt=this.props,rt=tt.visualElement,nt=tt.layoutGroup,ot=tt.switchLayoutGroup,it=rt.projection;it&&(it.scheduleCheckAfterUnmount(),nt!=null&&nt.group&&nt.group.remove(it),ot!=null&&ot.deregister&&ot.deregister(it))},o.prototype.safeToRemove=function(){var tt=this.props.safeToRemove;tt==null||tt()},o.prototype.render=function(){return null},o}(React.Component);function MeasureLayout(et){var o=__read(usePresence$1(),2),tt=o[0],rt=o[1],nt=reactExports.useContext(LayoutGroupContext);return React.createElement(MeasureLayoutWithContext,__assign({},et,{layoutGroup:nt,switchLayoutGroup:reactExports.useContext(SwitchLayoutGroupContext),isPresent:tt,safeToRemove:rt}))}var defaultScaleCorrectors={borderRadius:__assign(__assign({},correctBorderRadius),{applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]}),borderTopLeftRadius:correctBorderRadius,borderTopRightRadius:correctBorderRadius,borderBottomLeftRadius:correctBorderRadius,borderBottomRightRadius:correctBorderRadius,boxShadow:correctBoxShadow},layoutFeatures={measureLayout:MeasureLayout};function animate(et,o,tt){tt===void 0&&(tt={});var rt=isMotionValue(et)?et:motionValue(et);return startAnimation("",rt,o,tt),{stop:function(){return rt.stop()},isAnimating:function(){return rt.isAnimating()}}}var borders=["TopLeft","TopRight","BottomLeft","BottomRight"],numBorders=borders.length,asNumber=function(et){return typeof et=="string"?parseFloat(et):et},isPx=function(et){return typeof et=="number"||px.test(et)};function mixValues(et,o,tt,rt,nt,ot){var it,st,at,ct;nt?(et.opacity=mix(0,(it=tt.opacity)!==null&&it!==void 0?it:1,easeCrossfadeIn(rt)),et.opacityExit=mix((st=o.opacity)!==null&&st!==void 0?st:1,0,easeCrossfadeOut(rt))):ot&&(et.opacity=mix((at=o.opacity)!==null&&at!==void 0?at:1,(ct=tt.opacity)!==null&&ct!==void 0?ct:1,rt));for(var lt=0;lto?1:tt(progress(et,o,rt))}}function copyAxisInto(et,o){et.min=o.min,et.max=o.max}function copyBoxInto(et,o){copyAxisInto(et.x,o.x),copyAxisInto(et.y,o.y)}function removePointDelta(et,o,tt,rt,nt){return et-=o,et=scalePoint(et,1/tt,rt),nt!==void 0&&(et=scalePoint(et,1/nt,rt)),et}function removeAxisDelta(et,o,tt,rt,nt,ot,it){if(o===void 0&&(o=0),tt===void 0&&(tt=1),rt===void 0&&(rt=.5),ot===void 0&&(ot=et),it===void 0&&(it=et),percent.test(o)){o=parseFloat(o);var st=mix(it.min,it.max,o/100);o=st-it.min}if(typeof o=="number"){var at=mix(ot.min,ot.max,rt);et===ot&&(at-=o),et.min=removePointDelta(et.min,o,tt,at,nt),et.max=removePointDelta(et.max,o,tt,at,nt)}}function removeAxisTransforms(et,o,tt,rt,nt){var ot=__read(tt,3),it=ot[0],st=ot[1],at=ot[2];removeAxisDelta(et,o[it],o[st],o[at],o.scale,rt,nt)}var xKeys=["x","scaleX","originX"],yKeys=["y","scaleY","originY"];function removeBoxTransforms(et,o,tt,rt){removeAxisTransforms(et.x,o,xKeys,tt==null?void 0:tt.x,rt==null?void 0:rt.x),removeAxisTransforms(et.y,o,yKeys,tt==null?void 0:tt.y,rt==null?void 0:rt.y)}function isAxisDeltaZero(et){return et.translate===0&&et.scale===1}function isDeltaZero(et){return isAxisDeltaZero(et.x)&&isAxisDeltaZero(et.y)}function boxEquals(et,o){return et.x.min===o.x.min&&et.x.max===o.x.max&&et.y.min===o.y.min&&et.y.max===o.y.max}var NodeStack=function(){function et(){this.members=[]}return et.prototype.add=function(o){addUniqueItem(this.members,o),o.scheduleRender()},et.prototype.remove=function(o){if(removeItem(this.members,o),o===this.prevLead&&(this.prevLead=void 0),o===this.lead){var tt=this.members[this.members.length-1];tt&&this.promote(tt)}},et.prototype.relegate=function(o){var tt=this.members.findIndex(function(it){return o===it});if(tt===0)return!1;for(var rt,nt=tt;nt>=0;nt--){var ot=this.members[nt];if(ot.isPresent!==!1){rt=ot;break}}return rt?(this.promote(rt),!0):!1},et.prototype.promote=function(o,tt){var rt,nt=this.lead;if(o!==nt&&(this.prevLead=nt,this.lead=o,o.show(),nt)){nt.instance&&nt.scheduleRender(),o.scheduleRender(),o.resumeFrom=nt,tt&&(o.resumeFrom.preserveOpacity=!0),nt.snapshot&&(o.snapshot=nt.snapshot,o.snapshot.latestValues=nt.animationValues||nt.latestValues,o.snapshot.isShared=!0),!((rt=o.root)===null||rt===void 0)&&rt.isUpdating&&(o.isLayoutDirty=!0);var ot=o.options.crossfade;ot===!1&&nt.hide()}},et.prototype.exitAnimationComplete=function(){this.members.forEach(function(o){var tt,rt,nt,ot,it;(rt=(tt=o.options).onExitComplete)===null||rt===void 0||rt.call(tt),(it=(nt=o.resumingFrom)===null||nt===void 0?void 0:(ot=nt.options).onExitComplete)===null||it===void 0||it.call(ot)})},et.prototype.scheduleRender=function(){this.members.forEach(function(o){o.instance&&o.scheduleRender(!1)})},et.prototype.removeLeadSnapshot=function(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)},et}(),identityProjection="translate3d(0px, 0px, 0) scale(1, 1) scale(1, 1)";function buildProjectionTransform(et,o,tt){var rt=et.x.translate/o.x,nt=et.y.translate/o.y,ot="translate3d(".concat(rt,"px, ").concat(nt,"px, 0) ");if(ot+="scale(".concat(1/o.x,", ").concat(1/o.y,") "),tt){var it=tt.rotate,st=tt.rotateX,at=tt.rotateY;it&&(ot+="rotate(".concat(it,"deg) ")),st&&(ot+="rotateX(".concat(st,"deg) ")),at&&(ot+="rotateY(".concat(at,"deg) "))}var ct=et.x.scale*o.x,lt=et.y.scale*o.y;return ot+="scale(".concat(ct,", ").concat(lt,")"),ot===identityProjection?"none":ot}var compareByDepth=function(et,o){return et.depth-o.depth},FlatTree=function(){function et(){this.children=[],this.isDirty=!1}return et.prototype.add=function(o){addUniqueItem(this.children,o),this.isDirty=!0},et.prototype.remove=function(o){removeItem(this.children,o),this.isDirty=!0},et.prototype.forEach=function(o){this.isDirty&&this.children.sort(compareByDepth),this.isDirty=!1,this.children.forEach(o)},et}(),animationTarget=1e3;function createProjectionNode(et){var o=et.attachResizeListener,tt=et.defaultParent,rt=et.measureScroll,nt=et.checkIsScrollRoot,ot=et.resetTransform;return function(){function it(st,at,ct){var lt=this;at===void 0&&(at={}),ct===void 0&&(ct=tt==null?void 0:tt()),this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.potentialNodes=new Map,this.checkUpdateFailed=function(){lt.isUpdating&&(lt.isUpdating=!1,lt.clearAllSnapshots())},this.updateProjection=function(){lt.nodes.forEach(resolveTargetDelta),lt.nodes.forEach(calcProjection)},this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.id=st,this.latestValues=at,this.root=ct?ct.root||ct:this,this.path=ct?__spreadArray(__spreadArray([],__read(ct.path),!1),[ct],!1):[],this.parent=ct,this.depth=ct?ct.depth+1:0,st&&this.root.registerPotentialNode(st,this);for(var dt=0;dt=0;rt--)if(et.path[rt].instance){tt=et.path[rt];break}var nt=tt&&tt!==et.root?tt.instance:document,ot=nt.querySelector('[data-projection-id="'.concat(o,'"]'));ot&&et.mount(ot,!0)}function roundAxis(et){et.min=Math.round(et.min),et.max=Math.round(et.max)}function roundBox(et){roundAxis(et.x),roundAxis(et.y)}var DocumentProjectionNode=createProjectionNode({attachResizeListener:function(et,o){return addDomEvent(et,"resize",o)},measureScroll:function(){return{x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}},checkIsScrollRoot:function(){return!0}}),rootProjectionNode={current:void 0},HTMLProjectionNode=createProjectionNode({measureScroll:function(et){return{x:et.scrollLeft,y:et.scrollTop}},defaultParent:function(){if(!rootProjectionNode.current){var et=new DocumentProjectionNode(0,{});et.mount(window),et.setOptions({layoutScroll:!0}),rootProjectionNode.current=et}return rootProjectionNode.current},resetTransform:function(et,o){et.style.transform=o??"none"},checkIsScrollRoot:function(et){return window.getComputedStyle(et).position==="fixed"}}),featureBundle=__assign(__assign(__assign(__assign({},animations),gestureAnimations),drag),layoutFeatures),motion=createMotionProxy(function(et,o){return createDomMotionConfig(et,o,featureBundle,createDomVisualElement,HTMLProjectionNode)});function useIsMounted$1(){var et=reactExports.useRef(!1);return useIsomorphicLayoutEffect$3(function(){return et.current=!0,function(){et.current=!1}},[]),et}function useForceUpdate(){var et=useIsMounted$1(),o=__read(reactExports.useState(0),2),tt=o[0],rt=o[1],nt=reactExports.useCallback(function(){et.current&&rt(tt+1)},[tt]),ot=reactExports.useCallback(function(){return sync.postRender(nt)},[nt]);return[ot,tt]}var PresenceChild=function(et){var o=et.children,tt=et.initial,rt=et.isPresent,nt=et.onExitComplete,ot=et.custom,it=et.presenceAffectsLayout,st=useConstant(newChildrenMap),at=useId$1(),ct=reactExports.useMemo(function(){return{id:at,initial:tt,isPresent:rt,custom:ot,onExitComplete:function(lt){var dt,ht;st.set(lt,!0);try{for(var mt=__values(st.values()),ft=mt.next();!ft.done;ft=mt.next()){var pt=ft.value;if(!pt)return}}catch(yt){dt={error:yt}}finally{try{ft&&!ft.done&&(ht=mt.return)&&ht.call(mt)}finally{if(dt)throw dt.error}}nt==null||nt()},register:function(lt){return st.set(lt,!1),function(){return st.delete(lt)}}}},it?void 0:[rt]);return reactExports.useMemo(function(){st.forEach(function(lt,dt){return st.set(dt,!1)})},[rt]),reactExports.useEffect(function(){!rt&&!st.size&&(nt==null||nt())},[rt]),reactExports.createElement(PresenceContext.Provider,{value:ct},o)};function newChildrenMap(){return new Map}var getChildKey=function(et){return et.key||""};function updateChildLookup(et,o){et.forEach(function(tt){var rt=getChildKey(tt);o.set(rt,tt)})}function onlyElements(et){var o=[];return reactExports.Children.forEach(et,function(tt){reactExports.isValidElement(tt)&&o.push(tt)}),o}var AnimatePresence=function(et){var o=et.children,tt=et.custom,rt=et.initial,nt=rt===void 0?!0:rt,ot=et.onExitComplete,it=et.exitBeforeEnter,st=et.presenceAffectsLayout,at=st===void 0?!0:st,ct=__read(useForceUpdate(),1),lt=ct[0],dt=reactExports.useContext(LayoutGroupContext).forceRender;dt&&(lt=dt);var ht=useIsMounted$1(),mt=onlyElements(o),ft=mt,pt=new Set,yt=reactExports.useRef(ft),gt=reactExports.useRef(new Map).current,bt=reactExports.useRef(!0);if(useIsomorphicLayoutEffect$3(function(){bt.current=!1,updateChildLookup(mt,gt),yt.current=ft}),useUnmountEffect(function(){bt.current=!0,gt.clear(),pt.clear()}),bt.current)return reactExports.createElement(reactExports.Fragment,null,ft.map(function(At){return reactExports.createElement(PresenceChild,{key:getChildKey(At),isPresent:!0,initial:nt?void 0:!1,presenceAffectsLayout:at},At)}));ft=__spreadArray([],__read(ft),!1);for(var xt=yt.current.map(getChildKey),vt=mt.map(getChildKey),Et=xt.length,Ct=0;Ct1&&console.warn("You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour."),reactExports.createElement(reactExports.Fragment,null,pt.size?ft:ft.map(function(At){return reactExports.cloneElement(At)}))};function MotionConfig(et){var o=et.children,tt=et.isValidProp,rt=__rest(et,["children","isValidProp"]);tt&&loadExternalIsValidProp(tt),rt=__assign(__assign({},reactExports.useContext(MotionConfigContext)),rt),rt.isStatic=useConstant(function(){return rt.isStatic});var nt=reactExports.useMemo(function(){return rt},[JSON.stringify(rt.transition),rt.transformPagePoint,rt.reducedMotion]);return reactExports.createElement(MotionConfigContext.Provider,{value:nt},o)}var reactIs$2={exports:{}},reactIs_production_min$1={};/** * @license React * react-is.production.min.js * @@ -100,24 +100,24 @@ ${prettyStateOverride(mt)}`),super(o.shortMessage,{cause:o,docsPath:rt,metaMessa * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var b$2=Symbol.for("react.element"),c$1=Symbol.for("react.portal"),d$2=Symbol.for("react.fragment"),e$1=Symbol.for("react.strict_mode"),f$1=Symbol.for("react.profiler"),g$2=Symbol.for("react.provider"),h$2=Symbol.for("react.context"),k$2=Symbol.for("react.server_context"),l$1=Symbol.for("react.forward_ref"),m$3=Symbol.for("react.suspense"),n$1=Symbol.for("react.suspense_list"),p$1=Symbol.for("react.memo"),q$2=Symbol.for("react.lazy"),t$1=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference");function v$2(et){if(typeof et=="object"&&et!==null){var o=et.$$typeof;switch(o){case b$2:switch(et=et.type,et){case d$2:case f$1:case e$1:case m$3:case n$1:return et;default:switch(et=et&&et.$$typeof,et){case k$2:case h$2:case l$1:case q$2:case p$1:case g$2:return et;default:return o}}case c$1:return o}}}reactIs_production_min$1.ContextConsumer=h$2;reactIs_production_min$1.ContextProvider=g$2;reactIs_production_min$1.Element=b$2;reactIs_production_min$1.ForwardRef=l$1;reactIs_production_min$1.Fragment=d$2;reactIs_production_min$1.Lazy=q$2;reactIs_production_min$1.Memo=p$1;reactIs_production_min$1.Portal=c$1;reactIs_production_min$1.Profiler=f$1;reactIs_production_min$1.StrictMode=e$1;reactIs_production_min$1.Suspense=m$3;reactIs_production_min$1.SuspenseList=n$1;reactIs_production_min$1.isAsyncMode=function(){return!1};reactIs_production_min$1.isConcurrentMode=function(){return!1};reactIs_production_min$1.isContextConsumer=function(et){return v$2(et)===h$2};reactIs_production_min$1.isContextProvider=function(et){return v$2(et)===g$2};reactIs_production_min$1.isElement=function(et){return typeof et=="object"&&et!==null&&et.$$typeof===b$2};reactIs_production_min$1.isForwardRef=function(et){return v$2(et)===l$1};reactIs_production_min$1.isFragment=function(et){return v$2(et)===d$2};reactIs_production_min$1.isLazy=function(et){return v$2(et)===q$2};reactIs_production_min$1.isMemo=function(et){return v$2(et)===p$1};reactIs_production_min$1.isPortal=function(et){return v$2(et)===c$1};reactIs_production_min$1.isProfiler=function(et){return v$2(et)===f$1};reactIs_production_min$1.isStrictMode=function(et){return v$2(et)===e$1};reactIs_production_min$1.isSuspense=function(et){return v$2(et)===m$3};reactIs_production_min$1.isSuspenseList=function(et){return v$2(et)===n$1};reactIs_production_min$1.isValidElementType=function(et){return typeof et=="string"||typeof et=="function"||et===d$2||et===f$1||et===e$1||et===m$3||et===n$1||et===t$1||typeof et=="object"&&et!==null&&(et.$$typeof===q$2||et.$$typeof===p$1||et.$$typeof===g$2||et.$$typeof===h$2||et.$$typeof===l$1||et.$$typeof===u||et.getModuleId!==void 0)};reactIs_production_min$1.typeOf=v$2;reactIs$2.exports=reactIs_production_min$1;var reactIsExports$1=reactIs$2.exports;function stylis_min(et){function o(Kt,Pt,Gt,tr,zt){for(var lr=0,rr=0,Jt=0,Rt=0,Mt,Ut,Zt=0,nr=0,ar,dr=ar=Mt=0,cr=0,yr=0,pr=0,gr=0,Pr=Gt.length,_r=Pr-1,Rr,mr="",wr="",ir="",Tt="",$t;crMt)&&(gr=(mr=mr.replace(" ",":")).length),0tr&&(tr=(Pt=Pt.trim()).charCodeAt(0)),tr){case 38:return Pt.replace(yt,"$1"+Kt.trim());case 58:return Kt.trim()+Pt.replace(yt,"$1"+Kt.trim());default:if(0<1*Gt&&0rr.charCodeAt(8))break;case 115:zt=zt.replace(rr,"-webkit-"+rr)+";"+zt;break;case 207:case 102:zt=zt.replace(rr,"-webkit-"+(102Gt.charCodeAt(0)&&(Gt=Gt.trim()),Xt=Gt,Gt=[Xt],0_t)&&(pr=(gr=gr.replace(" ",":")).length),0rr&&(rr=(jt=jt.trim()).charCodeAt(0)),rr){case 38:return jt.replace(gt,"$1"+Qt.trim());case 58:return Qt.trim()+jt.replace(gt,"$1"+Qt.trim());default:if(0<1*Gt&&0Zt.charCodeAt(8))break;case 115:Ht=Ht.replace(Zt,"-webkit-"+Zt)+";"+Ht;break;case 207:case 102:Ht=Ht.replace(Zt,"-webkit-"+(102Gt.charCodeAt(0)&&(Gt=Gt.trim()),Yt=Gt,Gt=[Yt],01?o-1:0),rt=1;rt0?" Args: "+tt.join(", "):""))}var j=function(){function et(tt){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=tt}var o=et.prototype;return o.indexOfGroup=function(tt){for(var rt=0,nt=0;nt=this.groupSizes.length){for(var nt=this.groupSizes,ot=nt.length,it=ot;tt>=it;)(it<<=1)<0&&D(16,""+tt);this.groupSizes=new Uint32Array(it),this.groupSizes.set(nt),this.length=it;for(var st=ot;st=this.length||this.groupSizes[tt]===0)return rt;for(var nt=this.groupSizes[tt],ot=this.indexOfGroup(tt),it=ot+nt,st=ot;st=k&&(k=o+1),T.set(et,o),x.set(o,et)},M="style["+N+'][data-styled-version="5.3.11"]',G=new RegExp("^"+N+'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)'),L=function(et,o,tt){for(var rt,nt=tt.split(","),ot=0,it=nt.length;ot=0;ct--){var lt=at[ct];if(lt&<.nodeType===1&<.hasAttribute(N))return lt}}(tt),ot=nt!==void 0?nt.nextSibling:null;rt.setAttribute(N,"active"),rt.setAttribute("data-styled-version","5.3.11");var it=Y();return it&&rt.setAttribute("nonce",it),tt.insertBefore(rt,ot),rt},H=function(){function et(tt){var rt=this.element=q(tt);rt.appendChild(document.createTextNode("")),this.sheet=function(nt){if(nt.sheet)return nt.sheet;for(var ot=document.styleSheets,it=0,st=ot.length;it=0){var nt=document.createTextNode(rt),ot=this.nodes[tt];return this.element.insertBefore(nt,ot||null),this.length++,!0}return!1},o.deleteRule=function(tt){this.element.removeChild(this.nodes[tt]),this.length--},o.getRule=function(tt){return tt0&&(dt+=ht+",")}),ot+=""+ct+lt+'{content:"'+dt+`"}/*!sc*/ -`}}}return ot}(this)},et}(),Z=/(a)(d)/gi,K=function(et){return String.fromCharCode(et+(et>25?39:97))};function Q(et){var o,tt="";for(o=Math.abs(et);o>52;o=o/52|0)tt=K(o%52)+tt;return(K(o%52)+tt).replace(Z,"$1-$2")}var ee=function(et,o){for(var tt=o.length;tt;)et=33*et^o.charCodeAt(--tt);return et},te=function(et){return ee(5381,et)};function ne(et){for(var o=0;o>>0);if(!tt.hasNameForId(nt,st)){var at=rt(it,"."+st,void 0,nt);tt.insertRules(nt,st,at)}ot.push(st),this.staticRulesId=st}else{for(var ct=this.rules.length,lt=ee(this.baseHash,rt.hash),dt="",ht=0;ht>>0);if(!tt.hasNameForId(nt,gt)){var yt=rt(dt,"."+gt,void 0,nt);tt.insertRules(nt,gt,yt)}ot.push(gt)}}return ot.join(" ")},et}(),se=/^\s*\/\/.*$/gm,ie=[":","[",".","#"];function ae(et){var o,tt,rt,nt,ot=w$1,it=ot.options,st=it===void 0?w$1:it,at=ot.plugins,ct=at===void 0?S:at,lt=new stylis_min(st),dt=[],ht=function(pt){function gt(yt){if(yt)try{pt(yt+"}")}catch{}}return function(yt,bt,xt,vt,Et,Ct,St,At,kt,It){switch(yt){case 1:if(kt===0&&bt.charCodeAt(0)===64)return pt(bt+";"),"";break;case 2:if(At===0)return bt+"/*|*/";break;case 3:switch(At){case 102:case 112:return pt(xt[0]+bt),"";default:return bt+(It===0?"/*|*/":"")}case-2:bt.split("/*|*/}").forEach(gt)}}}(function(pt){dt.push(pt)}),mt=function(pt,gt,yt){return gt===0&&ie.indexOf(yt[tt.length])!==-1||yt.match(nt)?pt:"."+o};function ft(pt,gt,yt,bt){bt===void 0&&(bt="&");var xt=pt.replace(se,""),vt=gt&&yt?yt+" "+gt+" { "+xt+" }":xt;return o=bt,tt=gt,rt=new RegExp("\\"+tt+"\\b","g"),nt=new RegExp("(\\"+tt+"\\b){2,}"),lt(yt||!gt?"":gt,vt)}return lt.use([].concat(ct,[function(pt,gt,yt){pt===2&&yt.length&&yt[0].lastIndexOf(tt)>0&&(yt[0]=yt[0].replace(rt,mt))},ht,function(pt){if(pt===-2){var gt=dt;return dt=[],gt}}])),ft.hash=ct.length?ct.reduce(function(pt,gt){return gt.name||D(15),ee(pt,gt.name)},5381).toString():"",ft}var ce=React.createContext();ce.Consumer;var le=React.createContext(),de=(le.Consumer,new X),he=ae();function pe(){return reactExports.useContext(ce)||de}function fe(){return reactExports.useContext(le)||he}var ye=function(){function et(o,tt){var rt=this;this.inject=function(nt,ot){ot===void 0&&(ot=he);var it=rt.name+ot.hash;nt.hasNameForId(rt.id,it)||nt.insertRules(rt.id,it,ot(rt.rules,it,"@keyframes"))},this.toString=function(){return D(12,String(rt.name))},this.name=o,this.id="sc-keyframes-"+o,this.rules=tt}return et.prototype.getName=function(o){return o===void 0&&(o=he),this.name+o.hash},et}(),ve=/([A-Z])/,ge=/([A-Z])/g,Se=/^ms-/,we=function(et){return"-"+et.toLowerCase()};function Ee(et){return ve.test(et)?et.replace(ge,we).replace(Se,"-ms-"):et}var be=function(et){return et==null||et===!1||et===""};function _e(et,o,tt,rt){if(Array.isArray(et)){for(var nt,ot=[],it=0,st=et.length;it1?o-1:0),rt=1;rt?@[\\\]^`{|}~-]+/g,De=/(^-|-$)/g;function je(et){return et.replace(Re,"-").replace(De,"")}var Te=function(et){return Q(te(et)>>>0)};function xe(et){return typeof et=="string"&&!0}var ke=function(et){return typeof et=="function"||typeof et=="object"&&et!==null&&!Array.isArray(et)},Ve=function(et){return et!=="__proto__"&&et!=="constructor"&&et!=="prototype"};function Be(et,o,tt){var rt=et[tt];ke(o)&&ke(rt)?ze(rt,o):et[tt]=o}function ze(et){for(var o=arguments.length,tt=new Array(o>1?o-1:0),rt=1;rt=0||(It[At]=Ct[At]);return It}(o,["componentId"]),Et=xt&&xt+"-"+(xe(bt)?bt:je(b(bt)));return Ye(bt,y$1({},vt,{attrs:ht,componentId:Et}),tt)},Object.defineProperty(ft,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(bt){this._foldedDefaultProps=rt?ze({},et.defaultProps,bt):bt}}),Object.defineProperty(ft,"toString",{value:function(){return"."+ft.styledComponentId}}),nt&&m$1(ft,et,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0,withComponent:!0}),ft}var qe=function(et){return function o(tt,rt,nt){if(nt===void 0&&(nt=w$1),!reactIsExports$1.isValidElementType(rt))return D(1,String(rt));var ot=function(){return tt(rt,nt,Ae.apply(void 0,arguments))};return ot.withConfig=function(it){return o(tt,rt,y$1({},nt,{},it))},ot.attrs=function(it){return o(tt,rt,y$1({},nt,{attrs:Array.prototype.concat(nt.attrs,it).filter(Boolean)}))},ot}(Ye,et)};["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","textPath","tspan"].forEach(function(et){qe[et]=qe(et)});function We(et){for(var o=arguments.length,tt=new Array(o>1?o-1:0),rt=1;rt>--at&1}const dt=31,ht=2**dt,mt=ht>>>1,ft=mt>>1,pt=ht-1;let gt=0;for(let Et=0;Et1;){let It=Ct+St>>>1;Et>>1|lt(),At=At<<1^mt,kt=(kt^mt)<<1|mt|1;bt=At,xt=1+kt-At}let vt=rt-4;return yt.map(Et=>{switch(Et-vt){case 3:return vt+65792+(et[st++]<<16|et[st++]<<8|et[st++]);case 2:return vt+256+(et[st++]<<8|et[st++]);case 1:return vt+et[st++];default:return Et-1}})}function read_payload(et){let o=0;return()=>et[o++]}function read_compressed_payload(et){return read_payload(decode_arithmetic(unsafe_atob(et)))}function unsafe_atob(et){let o=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((nt,ot)=>o[nt.charCodeAt(0)]=ot);let tt=et.length,rt=new Uint8Array(6*tt>>3);for(let nt=0,ot=0,it=0,st=0;nt=8&&(rt[ot++]=st>>(it-=8));return rt}function signed(et){return et&1?~et>>1:et>>1}function read_deltas(et,o){let tt=Array(et);for(let rt=0,nt=0;rt{let o=read_sorted(et);if(o.length)return o})}function read_mapped(et){let o=[];for(;;){let tt=et();if(tt==0)break;o.push(read_linear_table(tt,et))}for(;;){let tt=et()-1;if(tt<0)break;o.push(read_replacement_table(tt,et))}return o.flat()}function read_array_while(et){let o=[];for(;;){let tt=et(o.length);if(!tt)break;o.push(tt)}return o}function read_transposed(et,o,tt){let rt=Array(et).fill().map(()=>[]);for(let nt=0;ntrt[it].push(ot));return rt}function read_linear_table(et,o){let tt=1+o(),rt=o(),nt=read_array_while(o);return read_transposed(nt.length,1+et,o).flatMap((it,st)=>{let[at,...ct]=it;return Array(nt[st]).fill().map((lt,dt)=>{let ht=dt*rt;return[at+dt*tt,ct.map(mt=>mt+ht)]})})}function read_replacement_table(et,o){let tt=1+o();return read_transposed(tt,1+et,o).map(nt=>[nt[0],nt.slice(1)])}function read_trie(et){let o=[],tt=read_sorted(et);return nt(rt([]),[]),o;function rt(ot){let it=et(),st=read_array_while(()=>{let at=read_sorted(et).map(ct=>tt[ct]);if(at.length)return rt(at)});return{S:it,B:st,Q:ot}}function nt({S:ot,B:it},st,at){if(!(ot&4&&at===st[st.length-1])){ot&2&&(at=st[st.length-1]),ot&1&&o.push(st);for(let ct of it)for(let lt of ct.Q)nt(ct,[...st,lt],at)}}}function hex_cp(et){return et.toString(16).toUpperCase().padStart(2,"0")}function quote_cp(et){return`{${hex_cp(et)}}`}function explode_cp(et){let o=[];for(let tt=0,rt=et.length;tt>24&255}function unpack_cp(et){return et&16777215}let SHIFTED_RANK,EXCLUSIONS,DECOMP,RECOMP;function init$1(){let et=read_compressed_payload(COMPRESSED);SHIFTED_RANK=new Map(read_sorted_arrays(et).flatMap((o,tt)=>o.map(rt=>[rt,tt+1<<24]))),EXCLUSIONS=new Set(read_sorted(et)),DECOMP=new Map,RECOMP=new Map;for(let[o,tt]of read_mapped(et)){if(!EXCLUSIONS.has(o)&&tt.length==2){let[rt,nt]=tt,ot=RECOMP.get(rt);ot||(ot=new Map,RECOMP.set(rt,ot)),ot.set(nt,o)}DECOMP.set(o,tt.reverse())}}function is_hangul(et){return et>=S0&&et=L0&&et=V0&&oT0&&o0&&nt(T0+ct)}else{let it=DECOMP.get(ot);it?tt.push(...it):nt(ot)}if(!tt.length)break;ot=tt.pop()}if(rt&&o.length>1){let ot=unpack_cc(o[0]);for(let it=1;it0&&nt>=it)it==0?(o.push(rt,...tt),tt.length=0,rt=st):tt.push(st),nt=it;else{let at=compose_pair(rt,st);at>=0?rt=at:nt==0&&it==0?(o.push(rt),rt=st):(tt.push(st),nt=it)}}return rt>=0&&o.push(rt,...tt),o}function nfd(et){return decomposed(et).map(unpack_cp)}function nfc(et){return composed_from_decomposed(decomposed(et))}const HYPHEN=45,STOP_CH=".",FE0F=65039,UNIQUE_PH=1,Array_from=et=>Array.from(et);function group_has_cp(et,o){return et.P.has(o)||et.Q.has(o)}class Emoji extends Array{get is_emoji(){return!0}}let MAPPED,IGNORED,CM,NSM,ESCAPE,GROUPS,WHOLE_VALID,WHOLE_MAP,VALID,EMOJI_LIST,EMOJI_ROOT;function init(){if(MAPPED)return;let et=read_compressed_payload(COMPRESSED$1);const o=()=>read_sorted(et),tt=()=>new Set(o()),rt=(lt,dt)=>dt.forEach(ht=>lt.add(ht));MAPPED=new Map(read_mapped(et)),IGNORED=tt(),CM=o(),NSM=new Set(o().map(lt=>CM[lt])),CM=new Set(CM),ESCAPE=tt(),tt();let nt=read_sorted_arrays(et),ot=et();const it=()=>{let lt=new Set;return o().forEach(dt=>rt(lt,nt[dt])),rt(lt,o()),lt};GROUPS=read_array_while(lt=>{let dt=read_array_while(et).map(ht=>ht+96);if(dt.length){let ht=lt>=ot;dt[0]-=32,dt=str_from_cps(dt),ht&&(dt=`Restricted[${dt}]`);let mt=it(),ft=it(),pt=!et();return{N:dt,P:mt,Q:ft,M:pt,R:ht}}}),WHOLE_VALID=tt(),WHOLE_MAP=new Map;let st=o().concat(Array_from(WHOLE_VALID)).sort((lt,dt)=>lt-dt);st.forEach((lt,dt)=>{let ht=et(),mt=st[dt]=ht?st[dt-ht]:{V:[],M:new Map};mt.V.push(lt),WHOLE_VALID.has(lt)||WHOLE_MAP.set(lt,mt)});for(let{V:lt,M:dt}of new Set(WHOLE_MAP.values())){let ht=[];for(let ft of lt){let pt=GROUPS.filter(yt=>group_has_cp(yt,ft)),gt=ht.find(({G:yt})=>pt.some(bt=>yt.has(bt)));gt||(gt={G:new Set,V:[]},ht.push(gt)),gt.V.push(ft),rt(gt.G,pt)}let mt=ht.flatMap(ft=>Array_from(ft.G));for(let{G:ft,V:pt}of ht){let gt=new Set(mt.filter(yt=>!ft.has(yt)));for(let yt of pt)dt.set(yt,gt)}}VALID=new Set;let at=new Set;const ct=lt=>VALID.has(lt)?at.add(lt):VALID.add(lt);for(let lt of GROUPS){for(let dt of lt.P)ct(dt);for(let dt of lt.Q)ct(dt)}for(let lt of VALID)!WHOLE_MAP.has(lt)&&!at.has(lt)&&WHOLE_MAP.set(lt,UNIQUE_PH);rt(VALID,nfd(VALID)),EMOJI_LIST=read_trie(et).map(lt=>Emoji.from(lt)).sort(compare_arrays),EMOJI_ROOT=new Map;for(let lt of EMOJI_LIST){let dt=[EMOJI_ROOT];for(let ht of lt){let mt=dt.map(ft=>{let pt=ft.get(ht);return pt||(pt=new Map,ft.set(ht,pt)),pt});ht===FE0F?dt.push(...mt):dt=mt}for(let ht of dt)ht.V=lt}}function quoted_cp(et){return(should_escape(et)?"":`${bidi_qq(safe_str_from_cps([et]))} `)+quote_cp(et)}function bidi_qq(et){return`"${et}"‎`}function check_label_extension(et){if(et.length>=4&&et[2]==HYPHEN&&et[3]==HYPHEN)throw new Error(`invalid label extension: "${str_from_cps(et.slice(0,4))}"`)}function check_leading_underscore(et){for(let tt=et.lastIndexOf(95);tt>0;)if(et[--tt]!==95)throw new Error("underscore allowed only at start")}function check_fenced(et){let o=et[0],tt=FENCED.get(o);if(tt)throw error_placement(`leading ${tt}`);let rt=et.length,nt=-1;for(let ot=1;oto&&(o>>=1,et=[...et.slice(0,o),8230,...et.slice(-o)]);let nt=0,ot=et.length;for(let it=0;it{let ot=explode_cp(nt),it={input:ot,offset:rt};rt+=ot.length+1;try{let st=it.tokens=tokens_from_str(ot,o,tt),at=st.length,ct;if(!at)throw new Error("empty label");let lt=it.output=st.flat();if(check_leading_underscore(lt),!(it.emoji=at>1||st[0].is_emoji)&<.every(ht=>ht<128))check_label_extension(lt),ct="ASCII";else{let ht=st.flatMap(mt=>mt.is_emoji?[]:mt);if(!ht.length)ct="Emoji";else{if(CM.has(lt[0]))throw error_placement("leading combining mark");for(let pt=1;ptit.has(st)):Array_from(it),!tt.length)return}else rt.push(nt)}if(tt){for(let nt of tt)if(rt.every(ot=>group_has_cp(nt,ot)))throw new Error(`whole-script confusable: ${et.N}/${nt.N}`)}}function determine_group(et){let o=GROUPS;for(let tt of et){let rt=o.filter(nt=>group_has_cp(nt,tt));if(!rt.length)throw GROUPS.some(nt=>group_has_cp(nt,tt))?error_group_member(o[0],tt):error_disallowed(tt);if(o=rt,rt.length==1)break}return o}function flatten$1(et){return et.map(({input:o,error:tt,output:rt})=>{if(tt){let nt=tt.message;throw new Error(et.length==1?nt:`Invalid label ${bidi_qq(safe_str_from_cps(o,63))}: ${nt}`)}return str_from_cps(rt)}).join(STOP_CH)}function error_disallowed(et){return new Error(`disallowed character: ${quoted_cp(et)}`)}function error_group_member(et,o){let tt=quoted_cp(o),rt=GROUPS.find(nt=>nt.P.has(o));return rt&&(tt=`${rt.N} ${tt}`),new Error(`illegal mixture: ${et.N} + ${tt}`)}function error_placement(et){return new Error(`illegal placement: ${et}`)}function check_group(et,o){for(let tt of o)if(!group_has_cp(et,tt))throw error_group_member(et,tt);if(et.M){let tt=nfd(o);for(let rt=1,nt=tt.length;rtNSM_MAX)throw new Error(`excessive non-spacing marks: ${bidi_qq(safe_str_from_cps(tt.slice(rt-1,ot)))} (${ot-rt}/${NSM_MAX})`);rt=ot}}}function tokens_from_str(et,o,tt){let rt=[],nt=[];for(et=et.slice().reverse();et.length;){let ot=consume_emoji_reversed(et);if(ot)nt.length&&(rt.push(o(nt)),nt=[]),rt.push(tt(ot));else{let it=et.pop();if(VALID.has(it))nt.push(it);else{let st=MAPPED.get(it);if(st)nt.push(...st);else if(!IGNORED.has(it))throw error_disallowed(it)}}}return nt.length&&rt.push(o(nt)),rt}function filter_fe0f(et){return et.filter(o=>o!=FE0F)}function consume_emoji_reversed(et,o){let tt=EMOJI_ROOT,rt,nt=et.length;for(;nt&&(tt=tt.get(et[--nt]),!!tt);){let{V:ot}=tt;ot&&(rt=ot,et.length=nt)}return rt}function normalize$2(et){return ens_normalize(et)}function debounce$1(et,o,tt){var rt,nt,ot,it,st;o==null&&(o=100);function at(){var lt=Date.now()-it;lt=0?rt=setTimeout(at,o-lt):(rt=null,tt||(st=et.apply(ot,nt),ot=nt=null))}var ct=function(){ot=this,nt=arguments,it=Date.now();var lt=tt&&!rt;return rt||(rt=setTimeout(at,o)),lt&&(st=et.apply(ot,nt),ot=nt=null),st};return ct.clear=function(){rt&&(clearTimeout(rt),rt=null)},ct.flush=function(){rt&&(st=et.apply(ot,nt),ot=nt=null,clearTimeout(rt),rt=null)},ct}debounce$1.debounce=debounce$1;var debounce_1=debounce$1;const createDebounce=getDefaultExportFromCjs(debounce_1);function useMeasure(et){let{debounce:o,scroll:tt,polyfill:rt,offsetSize:nt}=et===void 0?{debounce:0,scroll:!1,offsetSize:!1}:et;const ot=rt||(typeof window>"u"?class{}:window.ResizeObserver);if(!ot)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[it,st]=reactExports.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),at=reactExports.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:it}),ct=o?typeof o=="number"?o:o.scroll:null,lt=o?typeof o=="number"?o:o.resize:null,dt=reactExports.useRef(!1);reactExports.useEffect(()=>(dt.current=!0,()=>void(dt.current=!1)));const[ht,mt,ft]=reactExports.useMemo(()=>{const bt=()=>{if(!at.current.element)return;const{left:xt,top:vt,width:Et,height:Ct,bottom:St,right:At,x:kt,y:It}=at.current.element.getBoundingClientRect(),Ot={left:xt,top:vt,width:Et,height:Ct,bottom:St,right:At,x:kt,y:It};at.current.element instanceof HTMLElement&&nt&&(Ot.height=at.current.element.offsetHeight,Ot.width=at.current.element.offsetWidth),Object.freeze(Ot),dt.current&&!areBoundsEqual(at.current.lastBounds,Ot)&&st(at.current.lastBounds=Ot)};return[bt,lt?createDebounce(bt,lt):bt,ct?createDebounce(bt,ct):bt]},[st,nt,ct,lt]);function pt(){at.current.scrollContainers&&(at.current.scrollContainers.forEach(bt=>bt.removeEventListener("scroll",ft,!0)),at.current.scrollContainers=null),at.current.resizeObserver&&(at.current.resizeObserver.disconnect(),at.current.resizeObserver=null)}function gt(){at.current.element&&(at.current.resizeObserver=new ot(ft),at.current.resizeObserver.observe(at.current.element),tt&&at.current.scrollContainers&&at.current.scrollContainers.forEach(bt=>bt.addEventListener("scroll",ft,{capture:!0,passive:!0})))}const yt=bt=>{!bt||bt===at.current.element||(pt(),at.current.element=bt,at.current.scrollContainers=findScrollContainers(bt),gt())};return useOnWindowScroll(ft,!!tt),useOnWindowResize(mt),reactExports.useEffect(()=>{pt(),gt()},[tt,ft,mt]),reactExports.useEffect(()=>pt,[]),[yt,it,ht]}function useOnWindowResize(et){reactExports.useEffect(()=>{const o=et;return window.addEventListener("resize",o),()=>void window.removeEventListener("resize",o)},[et])}function useOnWindowScroll(et,o){reactExports.useEffect(()=>{if(o){const tt=et;return window.addEventListener("scroll",tt,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",tt,!0)}},[et,o])}function findScrollContainers(et){const o=[];if(!et||et===document.body)return o;const{overflow:tt,overflowX:rt,overflowY:nt}=window.getComputedStyle(et);return[tt,rt,nt].some(ot=>ot==="auto"||ot==="scroll")&&o.push(et),[...o,...findScrollContainers(et.parentElement)]}const keys$1=["x","y","top","bottom","left","right","width","height"],areBoundsEqual=(et,o)=>keys$1.every(tt=>et[tt]===o[tt]);var MapShim=function(){if(typeof Map<"u")return Map;function et(o,tt){var rt=-1;return o.some(function(nt,ot){return nt[0]===tt?(rt=ot,!0):!1}),rt}return function(){function o(){this.__entries__=[]}return Object.defineProperty(o.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),o.prototype.get=function(tt){var rt=et(this.__entries__,tt),nt=this.__entries__[rt];return nt&&nt[1]},o.prototype.set=function(tt,rt){var nt=et(this.__entries__,tt);~nt?this.__entries__[nt][1]=rt:this.__entries__.push([tt,rt])},o.prototype.delete=function(tt){var rt=this.__entries__,nt=et(rt,tt);~nt&&rt.splice(nt,1)},o.prototype.has=function(tt){return!!~et(this.__entries__,tt)},o.prototype.clear=function(){this.__entries__.splice(0)},o.prototype.forEach=function(tt,rt){rt===void 0&&(rt=null);for(var nt=0,ot=this.__entries__;nt0},et.prototype.connect_=function(){!isBrowser$2||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),mutationObserverSupported?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},et.prototype.disconnect_=function(){!isBrowser$2||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},et.prototype.onTransitionEnd_=function(o){var tt=o.propertyName,rt=tt===void 0?"":tt,nt=transitionKeys.some(function(ot){return!!~rt.indexOf(ot)});nt&&this.refresh()},et.getInstance=function(){return this.instance_||(this.instance_=new et),this.instance_},et.instance_=null,et}(),defineConfigurable=function(et,o){for(var tt=0,rt=Object.keys(o);tt"u"||!(Element instanceof Object))){if(!(o instanceof getWindowOf(o).Element))throw new TypeError('parameter 1 is not of type "Element".');var tt=this.observations_;tt.has(o)||(tt.set(o,new ResizeObservation(o)),this.controller_.addObserver(this),this.controller_.refresh())}},et.prototype.unobserve=function(o){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(o instanceof getWindowOf(o).Element))throw new TypeError('parameter 1 is not of type "Element".');var tt=this.observations_;tt.has(o)&&(tt.delete(o),tt.size||this.controller_.removeObserver(this))}},et.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},et.prototype.gatherActive=function(){var o=this;this.clearActive(),this.observations_.forEach(function(tt){tt.isActive()&&o.activeObservations_.push(tt)})},et.prototype.broadcastActive=function(){if(this.hasActive()){var o=this.callbackCtx_,tt=this.activeObservations_.map(function(rt){return new ResizeObserverEntry(rt.target,rt.broadcastRect())});this.callback_.call(o,tt,o),this.clearActive()}},et.prototype.clearActive=function(){this.activeObservations_.splice(0)},et.prototype.hasActive=function(){return this.activeObservations_.length>0},et}(),observers=typeof WeakMap<"u"?new WeakMap:new MapShim,ResizeObserver$1=function(){function et(o){if(!(this instanceof et))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var tt=ResizeObserverController.getInstance(),rt=new ResizeObserverSPI(o,tt,this);observers.set(this,rt)}return et}();["observe","unobserve","disconnect"].forEach(function(et){ResizeObserver$1.prototype[et]=function(){var o;return(o=observers.get(this))[et].apply(o,arguments)}});var index$1=function(){return typeof global$1.ResizeObserver<"u"?global$1.ResizeObserver:ResizeObserver$1}(),browser$1={},canPromise$1=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},qrcode={},utils$2={};let toSJISFunction;const CODEWORDS_COUNT=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];utils$2.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17};utils$2.getSymbolTotalCodewords=function(o){return CODEWORDS_COUNT[o]};utils$2.getBCHDigit=function(et){let o=0;for(;et!==0;)o++,et>>>=1;return o};utils$2.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction=o};utils$2.isKanjiModeEnabled=function(){return typeof toSJISFunction<"u"};utils$2.toSJIS=function(o){return toSJISFunction(o)};var errorCorrectionLevel={};(function(et){et.L={bit:1},et.M={bit:0},et.Q={bit:3},et.H={bit:2};function o(tt){if(typeof tt!="string")throw new Error("Param is not a string");switch(tt.toLowerCase()){case"l":case"low":return et.L;case"m":case"medium":return et.M;case"q":case"quartile":return et.Q;case"h":case"high":return et.H;default:throw new Error("Unknown EC Level: "+tt)}}et.isValid=function(rt){return rt&&typeof rt.bit<"u"&&rt.bit>=0&&rt.bit<4},et.from=function(rt,nt){if(et.isValid(rt))return rt;try{return o(rt)}catch{return nt}}})(errorCorrectionLevel);function BitBuffer$1(){this.buffer=[],this.length=0}BitBuffer$1.prototype={get:function(et){const o=Math.floor(et/8);return(this.buffer[o]>>>7-et%8&1)===1},put:function(et,o){for(let tt=0;tt>>o-tt-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(et){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),et&&(this.buffer[o]|=128>>>this.length%8),this.length++}};var bitBuffer=BitBuffer$1;function BitMatrix$1(et){if(!et||et<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=et,this.data=new Uint8Array(et*et),this.reservedBit=new Uint8Array(et*et)}BitMatrix$1.prototype.set=function(et,o,tt,rt){const nt=et*this.size+o;this.data[nt]=tt,rt&&(this.reservedBit[nt]=!0)};BitMatrix$1.prototype.get=function(et,o){return this.data[et*this.size+o]};BitMatrix$1.prototype.xor=function(et,o,tt){this.data[et*this.size+o]^=tt};BitMatrix$1.prototype.isReserved=function(et,o){return this.reservedBit[et*this.size+o]};var bitMatrix=BitMatrix$1,alignmentPattern={};(function(et){const o=utils$2.getSymbolSize;et.getRowColCoords=function(rt){if(rt===1)return[];const nt=Math.floor(rt/7)+2,ot=o(rt),it=ot===145?26:Math.ceil((ot-13)/(2*nt-2))*2,st=[ot-7];for(let at=1;at=0&&nt<=7},et.from=function(nt){return et.isValid(nt)?parseInt(nt,10):void 0},et.getPenaltyN1=function(nt){const ot=nt.size;let it=0,st=0,at=0,ct=null,lt=null;for(let dt=0;dt=5&&(it+=o.N1+(st-5)),ct=mt,st=1),mt=nt.get(ht,dt),mt===lt?at++:(at>=5&&(it+=o.N1+(at-5)),lt=mt,at=1)}st>=5&&(it+=o.N1+(st-5)),at>=5&&(it+=o.N1+(at-5))}return it},et.getPenaltyN2=function(nt){const ot=nt.size;let it=0;for(let st=0;st=10&&(st===1488||st===93)&&it++,at=at<<1&2047|nt.get(lt,ct),lt>=10&&(at===1488||at===93)&&it++}return it*o.N3},et.getPenaltyN4=function(nt){let ot=0;const it=nt.data.length;for(let at=0;at=0;){const it=ot[0];for(let at=0;at0){const ot=new Uint8Array(this.degree);return ot.set(rt,nt),ot}return rt};var reedSolomonEncoder=ReedSolomonEncoder$1,version$4={},mode$1={},versionCheck={};versionCheck.isValid=function(o){return!isNaN(o)&&o>=1&&o<=40};var regex={};const numeric="[0-9]+",alphanumeric="[A-Z $%*+\\-./:]+";let kanji="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";kanji=kanji.replace(/u/g,"\\u");const byte="(?:(?![A-Z0-9 $%*+\\-./:]|"+kanji+`)(?:.|[\r -]))+`;regex.KANJI=new RegExp(kanji,"g");regex.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");regex.BYTE=new RegExp(byte,"g");regex.NUMERIC=new RegExp(numeric,"g");regex.ALPHANUMERIC=new RegExp(alphanumeric,"g");const TEST_KANJI=new RegExp("^"+kanji+"$"),TEST_NUMERIC=new RegExp("^"+numeric+"$"),TEST_ALPHANUMERIC=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");regex.testKanji=function(o){return TEST_KANJI.test(o)};regex.testNumeric=function(o){return TEST_NUMERIC.test(o)};regex.testAlphanumeric=function(o){return TEST_ALPHANUMERIC.test(o)};(function(et){const o=versionCheck,tt=regex;et.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},et.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},et.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},et.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},et.MIXED={bit:-1},et.getCharCountIndicator=function(ot,it){if(!ot.ccBits)throw new Error("Invalid mode: "+ot);if(!o.isValid(it))throw new Error("Invalid version: "+it);return it>=1&&it<10?ot.ccBits[0]:it<27?ot.ccBits[1]:ot.ccBits[2]},et.getBestModeForData=function(ot){return tt.testNumeric(ot)?et.NUMERIC:tt.testAlphanumeric(ot)?et.ALPHANUMERIC:tt.testKanji(ot)?et.KANJI:et.BYTE},et.toString=function(ot){if(ot&&ot.id)return ot.id;throw new Error("Invalid mode")},et.isValid=function(ot){return ot&&ot.bit&&ot.ccBits};function rt(nt){if(typeof nt!="string")throw new Error("Param is not a string");switch(nt.toLowerCase()){case"numeric":return et.NUMERIC;case"alphanumeric":return et.ALPHANUMERIC;case"kanji":return et.KANJI;case"byte":return et.BYTE;default:throw new Error("Unknown mode: "+nt)}}et.from=function(ot,it){if(et.isValid(ot))return ot;try{return rt(ot)}catch{return it}}})(mode$1);(function(et){const o=utils$2,tt=errorCorrectionCode,rt=errorCorrectionLevel,nt=mode$1,ot=versionCheck,it=7973,st=o.getBCHDigit(it);function at(ht,mt,ft){for(let pt=1;pt<=40;pt++)if(mt<=et.getCapacity(pt,ft,ht))return pt}function ct(ht,mt){return nt.getCharCountIndicator(ht,mt)+4}function lt(ht,mt){let ft=0;return ht.forEach(function(pt){const gt=ct(pt.mode,mt);ft+=gt+pt.getBitsLength()}),ft}function dt(ht,mt){for(let ft=1;ft<=40;ft++)if(lt(ht,ft)<=et.getCapacity(ft,mt,nt.MIXED))return ft}et.from=function(mt,ft){return ot.isValid(mt)?parseInt(mt,10):ft},et.getCapacity=function(mt,ft,pt){if(!ot.isValid(mt))throw new Error("Invalid QR Code version");typeof pt>"u"&&(pt=nt.BYTE);const gt=o.getSymbolTotalCodewords(mt),yt=tt.getTotalCodewordsCount(mt,ft),bt=(gt-yt)*8;if(pt===nt.MIXED)return bt;const xt=bt-ct(pt,mt);switch(pt){case nt.NUMERIC:return Math.floor(xt/10*3);case nt.ALPHANUMERIC:return Math.floor(xt/11*2);case nt.KANJI:return Math.floor(xt/13);case nt.BYTE:default:return Math.floor(xt/8)}},et.getBestVersionForData=function(mt,ft){let pt;const gt=rt.from(ft,rt.M);if(Array.isArray(mt)){if(mt.length>1)return dt(mt,gt);if(mt.length===0)return 1;pt=mt[0]}else pt=mt;return at(pt.mode,pt.getLength(),gt)},et.getEncodedBits=function(mt){if(!ot.isValid(mt)||mt<7)throw new Error("Invalid QR Code version");let ft=mt<<12;for(;o.getBCHDigit(ft)-st>=0;)ft^=it<=0;)nt^=G15<0&&(rt=this.data.substr(tt),nt=parseInt(rt,10),o.put(nt,ot*3+1))};var numericData=NumericData;const Mode$3=mode$1,ALPHA_NUM_CHARS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function AlphanumericData(et){this.mode=Mode$3.ALPHANUMERIC,this.data=et}AlphanumericData.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)};AlphanumericData.prototype.getLength=function(){return this.data.length};AlphanumericData.prototype.getBitsLength=function(){return AlphanumericData.getBitsLength(this.data.length)};AlphanumericData.prototype.write=function(o){let tt;for(tt=0;tt+2<=this.data.length;tt+=2){let rt=ALPHA_NUM_CHARS.indexOf(this.data[tt])*45;rt+=ALPHA_NUM_CHARS.indexOf(this.data[tt+1]),o.put(rt,11)}this.data.length%2&&o.put(ALPHA_NUM_CHARS.indexOf(this.data[tt]),6)};var alphanumericData=AlphanumericData;const Mode$2=mode$1;function ByteData(et){this.mode=Mode$2.BYTE,typeof et=="string"?this.data=new TextEncoder().encode(et):this.data=new Uint8Array(et)}ByteData.getBitsLength=function(o){return o*8};ByteData.prototype.getLength=function(){return this.data.length};ByteData.prototype.getBitsLength=function(){return ByteData.getBitsLength(this.data.length)};ByteData.prototype.write=function(et){for(let o=0,tt=this.data.length;o=33088&&tt<=40956)tt-=33088;else if(tt>=57408&&tt<=60351)tt-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+` -Make sure your charset is UTF-8`);tt=(tt>>>8&255)*192+(tt&255),et.put(tt,13)}};var kanjiData=KanjiData,dijkstra={exports:{}};(function(et){var o={single_source_shortest_paths:function(tt,rt,nt){var ot={},it={};it[rt]=0;var st=o.PriorityQueue.make();st.push(rt,0);for(var at,ct,lt,dt,ht,mt,ft,pt,gt;!st.empty();){at=st.pop(),ct=at.value,dt=at.cost,ht=tt[ct]||{};for(lt in ht)ht.hasOwnProperty(lt)&&(mt=ht[lt],ft=dt+mt,pt=it[lt],gt=typeof it[lt]>"u",(gt||pt>ft)&&(it[lt]=ft,st.push(lt,ft),ot[lt]=ct))}if(typeof nt<"u"&&typeof it[nt]>"u"){var yt=["Could not find a path from ",rt," to ",nt,"."].join("");throw new Error(yt)}return ot},extract_shortest_path_from_predecessor_list:function(tt,rt){for(var nt=[],ot=rt;ot;)nt.push(ot),tt[ot],ot=tt[ot];return nt.reverse(),nt},find_path:function(tt,rt,nt){var ot=o.single_source_shortest_paths(tt,rt,nt);return o.extract_shortest_path_from_predecessor_list(ot,nt)},PriorityQueue:{make:function(tt){var rt=o.PriorityQueue,nt={},ot;tt=tt||{};for(ot in rt)rt.hasOwnProperty(ot)&&(nt[ot]=rt[ot]);return nt.queue=[],nt.sorter=tt.sorter||rt.default_sorter,nt},default_sorter:function(tt,rt){return tt.cost-rt.cost},push:function(tt,rt){var nt={value:tt,cost:rt};this.queue.push(nt),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};et.exports=o})(dijkstra);var dijkstraExports=dijkstra.exports;(function(et){const o=mode$1,tt=numericData,rt=alphanumericData,nt=byteData,ot=kanjiData,it=regex,st=utils$2,at=dijkstraExports;function ct(yt){return unescape(encodeURIComponent(yt)).length}function lt(yt,bt,xt){const vt=[];let Et;for(;(Et=yt.exec(xt))!==null;)vt.push({data:Et[0],index:Et.index,mode:bt,length:Et[0].length});return vt}function dt(yt){const bt=lt(it.NUMERIC,o.NUMERIC,yt),xt=lt(it.ALPHANUMERIC,o.ALPHANUMERIC,yt);let vt,Et;return st.isKanjiModeEnabled()?(vt=lt(it.BYTE,o.BYTE,yt),Et=lt(it.KANJI,o.KANJI,yt)):(vt=lt(it.BYTE_KANJI,o.BYTE,yt),Et=[]),bt.concat(xt,vt,Et).sort(function(St,At){return St.index-At.index}).map(function(St){return{data:St.data,mode:St.mode,length:St.length}})}function ht(yt,bt){switch(bt){case o.NUMERIC:return tt.getBitsLength(yt);case o.ALPHANUMERIC:return rt.getBitsLength(yt);case o.KANJI:return ot.getBitsLength(yt);case o.BYTE:return nt.getBitsLength(yt)}}function mt(yt){return yt.reduce(function(bt,xt){const vt=bt.length-1>=0?bt[bt.length-1]:null;return vt&&vt.mode===xt.mode?(bt[bt.length-1].data+=xt.data,bt):(bt.push(xt),bt)},[])}function ft(yt){const bt=[];for(let xt=0;xt=0&&st<=6&&(at===0||at===6)||at>=0&&at<=6&&(st===0||st===6)||st>=2&&st<=4&&at>=2&&at<=4?et.set(ot+st,it+at,!0,!0):et.set(ot+st,it+at,!1,!0))}}function setupTimingPattern(et){const o=et.size;for(let tt=8;tt>st&1)===1,et.set(nt,ot,it,!0),et.set(ot,nt,it,!0)}function setupFormatInfo(et,o,tt){const rt=et.size,nt=FormatInfo.getEncodedBits(o,tt);let ot,it;for(ot=0;ot<15;ot++)it=(nt>>ot&1)===1,ot<6?et.set(ot,8,it,!0):ot<8?et.set(ot+1,8,it,!0):et.set(rt-15+ot,8,it,!0),ot<8?et.set(8,rt-ot-1,it,!0):ot<9?et.set(8,15-ot-1+1,it,!0):et.set(8,15-ot-1,it,!0);et.set(rt-8,8,1,!0)}function setupData(et,o){const tt=et.size;let rt=-1,nt=tt-1,ot=7,it=0;for(let st=tt-1;st>0;st-=2)for(st===6&&st--;;){for(let at=0;at<2;at++)if(!et.isReserved(nt,st-at)){let ct=!1;it>>ot&1)===1),et.set(nt,st-at,ct),ot--,ot===-1&&(it++,ot=7)}if(nt+=rt,nt<0||tt<=nt){nt-=rt,rt=-rt;break}}}function createData(et,o,tt){const rt=new BitBuffer;tt.forEach(function(at){rt.put(at.mode.bit,4),rt.put(at.getLength(),Mode.getCharCountIndicator(at.mode,et)),at.write(rt)});const nt=Utils$1.getSymbolTotalCodewords(et),ot=ECCode.getTotalCodewordsCount(et,o),it=(nt-ot)*8;for(rt.getLengthInBits()+4<=it&&rt.put(0,4);rt.getLengthInBits()%8!==0;)rt.putBit(0);const st=(it-rt.getLengthInBits())/8;for(let at=0;at1?o-1:0),rt=1;rt0?" Args: "+tt.join(", "):""))}var j=function(){function et(tt){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=tt}var o=et.prototype;return o.indexOfGroup=function(tt){for(var rt=0,nt=0;nt=this.groupSizes.length){for(var nt=this.groupSizes,ot=nt.length,it=ot;tt>=it;)(it<<=1)<0&&D(16,""+tt);this.groupSizes=new Uint32Array(it),this.groupSizes.set(nt),this.length=it;for(var st=ot;st=this.length||this.groupSizes[tt]===0)return rt;for(var nt=this.groupSizes[tt],ot=this.indexOfGroup(tt),it=ot+nt,st=ot;st=k&&(k=o+1),T.set(et,o),x.set(o,et)},M="style["+N+'][data-styled-version="5.3.11"]',G=new RegExp("^"+N+'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)'),L=function(et,o,tt){for(var rt,nt=tt.split(","),ot=0,it=nt.length;ot=0;ct--){var lt=at[ct];if(lt&<.nodeType===1&<.hasAttribute(N))return lt}}(tt),ot=nt!==void 0?nt.nextSibling:null;rt.setAttribute(N,"active"),rt.setAttribute("data-styled-version","5.3.11");var it=Y();return it&&rt.setAttribute("nonce",it),tt.insertBefore(rt,ot),rt},H=function(){function et(tt){var rt=this.element=q(tt);rt.appendChild(document.createTextNode("")),this.sheet=function(nt){if(nt.sheet)return nt.sheet;for(var ot=document.styleSheets,it=0,st=ot.length;it=0){var nt=document.createTextNode(rt),ot=this.nodes[tt];return this.element.insertBefore(nt,ot||null),this.length++,!0}return!1},o.deleteRule=function(tt){this.element.removeChild(this.nodes[tt]),this.length--},o.getRule=function(tt){return tt0&&(dt+=ht+",")}),ot+=""+ct+lt+'{content:"'+dt+`"}/*!sc*/ +`}}}return ot}(this)},et}(),Z=/(a)(d)/gi,K=function(et){return String.fromCharCode(et+(et>25?39:97))};function Q(et){var o,tt="";for(o=Math.abs(et);o>52;o=o/52|0)tt=K(o%52)+tt;return(K(o%52)+tt).replace(Z,"$1-$2")}var ee=function(et,o){for(var tt=o.length;tt;)et=33*et^o.charCodeAt(--tt);return et},te=function(et){return ee(5381,et)};function ne(et){for(var o=0;o>>0);if(!tt.hasNameForId(nt,st)){var at=rt(it,"."+st,void 0,nt);tt.insertRules(nt,st,at)}ot.push(st),this.staticRulesId=st}else{for(var ct=this.rules.length,lt=ee(this.baseHash,rt.hash),dt="",ht=0;ht>>0);if(!tt.hasNameForId(nt,yt)){var gt=rt(dt,"."+yt,void 0,nt);tt.insertRules(nt,yt,gt)}ot.push(yt)}}return ot.join(" ")},et}(),se=/^\s*\/\/.*$/gm,ie=[":","[",".","#"];function ae(et){var o,tt,rt,nt,ot=w$1,it=ot.options,st=it===void 0?w$1:it,at=ot.plugins,ct=at===void 0?S:at,lt=new stylis_min(st),dt=[],ht=function(pt){function yt(gt){if(gt)try{pt(gt+"}")}catch{}}return function(gt,bt,xt,vt,Et,Ct,St,At,kt,It){switch(gt){case 1:if(kt===0&&bt.charCodeAt(0)===64)return pt(bt+";"),"";break;case 2:if(At===0)return bt+"/*|*/";break;case 3:switch(At){case 102:case 112:return pt(xt[0]+bt),"";default:return bt+(It===0?"/*|*/":"")}case-2:bt.split("/*|*/}").forEach(yt)}}}(function(pt){dt.push(pt)}),mt=function(pt,yt,gt){return yt===0&&ie.indexOf(gt[tt.length])!==-1||gt.match(nt)?pt:"."+o};function ft(pt,yt,gt,bt){bt===void 0&&(bt="&");var xt=pt.replace(se,""),vt=yt&>?gt+" "+yt+" { "+xt+" }":xt;return o=bt,tt=yt,rt=new RegExp("\\"+tt+"\\b","g"),nt=new RegExp("(\\"+tt+"\\b){2,}"),lt(gt||!yt?"":yt,vt)}return lt.use([].concat(ct,[function(pt,yt,gt){pt===2&>.length&>[0].lastIndexOf(tt)>0&&(gt[0]=gt[0].replace(rt,mt))},ht,function(pt){if(pt===-2){var yt=dt;return dt=[],yt}}])),ft.hash=ct.length?ct.reduce(function(pt,yt){return yt.name||D(15),ee(pt,yt.name)},5381).toString():"",ft}var ce=React.createContext();ce.Consumer;var le=React.createContext(),de=(le.Consumer,new X),he=ae();function pe(){return reactExports.useContext(ce)||de}function fe(){return reactExports.useContext(le)||he}var ye=function(){function et(o,tt){var rt=this;this.inject=function(nt,ot){ot===void 0&&(ot=he);var it=rt.name+ot.hash;nt.hasNameForId(rt.id,it)||nt.insertRules(rt.id,it,ot(rt.rules,it,"@keyframes"))},this.toString=function(){return D(12,String(rt.name))},this.name=o,this.id="sc-keyframes-"+o,this.rules=tt}return et.prototype.getName=function(o){return o===void 0&&(o=he),this.name+o.hash},et}(),ve=/([A-Z])/,ge=/([A-Z])/g,Se=/^ms-/,we=function(et){return"-"+et.toLowerCase()};function Ee(et){return ve.test(et)?et.replace(ge,we).replace(Se,"-ms-"):et}var be=function(et){return et==null||et===!1||et===""};function _e(et,o,tt,rt){if(Array.isArray(et)){for(var nt,ot=[],it=0,st=et.length;it1?o-1:0),rt=1;rt?@[\\\]^`{|}~-]+/g,De=/(^-|-$)/g;function je(et){return et.replace(Re,"-").replace(De,"")}var Te=function(et){return Q(te(et)>>>0)};function xe(et){return typeof et=="string"&&!0}var ke=function(et){return typeof et=="function"||typeof et=="object"&&et!==null&&!Array.isArray(et)},Ve=function(et){return et!=="__proto__"&&et!=="constructor"&&et!=="prototype"};function Be(et,o,tt){var rt=et[tt];ke(o)&&ke(rt)?ze(rt,o):et[tt]=o}function ze(et){for(var o=arguments.length,tt=new Array(o>1?o-1:0),rt=1;rt=0||(It[At]=Ct[At]);return It}(o,["componentId"]),Et=xt&&xt+"-"+(xe(bt)?bt:je(b(bt)));return Ye(bt,y$1({},vt,{attrs:ht,componentId:Et}),tt)},Object.defineProperty(ft,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(bt){this._foldedDefaultProps=rt?ze({},et.defaultProps,bt):bt}}),Object.defineProperty(ft,"toString",{value:function(){return"."+ft.styledComponentId}}),nt&&m$1(ft,et,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0,withComponent:!0}),ft}var qe=function(et){return function o(tt,rt,nt){if(nt===void 0&&(nt=w$1),!reactIsExports$1.isValidElementType(rt))return D(1,String(rt));var ot=function(){return tt(rt,nt,Ae.apply(void 0,arguments))};return ot.withConfig=function(it){return o(tt,rt,y$1({},nt,{},it))},ot.attrs=function(it){return o(tt,rt,y$1({},nt,{attrs:Array.prototype.concat(nt.attrs,it).filter(Boolean)}))},ot}(Ye,et)};["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","textPath","tspan"].forEach(function(et){qe[et]=qe(et)});function We(et){for(var o=arguments.length,tt=new Array(o>1?o-1:0),rt=1;rt>--at&1}const dt=31,ht=2**dt,mt=ht>>>1,ft=mt>>1,pt=ht-1;let yt=0;for(let Et=0;Et1;){let It=Ct+St>>>1;Et>>1|lt(),At=At<<1^mt,kt=(kt^mt)<<1|mt|1;bt=At,xt=1+kt-At}let vt=rt-4;return gt.map(Et=>{switch(Et-vt){case 3:return vt+65792+(et[st++]<<16|et[st++]<<8|et[st++]);case 2:return vt+256+(et[st++]<<8|et[st++]);case 1:return vt+et[st++];default:return Et-1}})}function read_payload(et){let o=0;return()=>et[o++]}function read_compressed_payload(et){return read_payload(decode_arithmetic(unsafe_atob(et)))}function unsafe_atob(et){let o=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((nt,ot)=>o[nt.charCodeAt(0)]=ot);let tt=et.length,rt=new Uint8Array(6*tt>>3);for(let nt=0,ot=0,it=0,st=0;nt=8&&(rt[ot++]=st>>(it-=8));return rt}function signed(et){return et&1?~et>>1:et>>1}function read_deltas(et,o){let tt=Array(et);for(let rt=0,nt=0;rt{let o=read_sorted(et);if(o.length)return o})}function read_mapped(et){let o=[];for(;;){let tt=et();if(tt==0)break;o.push(read_linear_table(tt,et))}for(;;){let tt=et()-1;if(tt<0)break;o.push(read_replacement_table(tt,et))}return o.flat()}function read_array_while(et){let o=[];for(;;){let tt=et(o.length);if(!tt)break;o.push(tt)}return o}function read_transposed(et,o,tt){let rt=Array(et).fill().map(()=>[]);for(let nt=0;ntrt[it].push(ot));return rt}function read_linear_table(et,o){let tt=1+o(),rt=o(),nt=read_array_while(o);return read_transposed(nt.length,1+et,o).flatMap((it,st)=>{let[at,...ct]=it;return Array(nt[st]).fill().map((lt,dt)=>{let ht=dt*rt;return[at+dt*tt,ct.map(mt=>mt+ht)]})})}function read_replacement_table(et,o){let tt=1+o();return read_transposed(tt,1+et,o).map(nt=>[nt[0],nt.slice(1)])}function read_trie(et){let o=[],tt=read_sorted(et);return nt(rt([]),[]),o;function rt(ot){let it=et(),st=read_array_while(()=>{let at=read_sorted(et).map(ct=>tt[ct]);if(at.length)return rt(at)});return{S:it,B:st,Q:ot}}function nt({S:ot,B:it},st,at){if(!(ot&4&&at===st[st.length-1])){ot&2&&(at=st[st.length-1]),ot&1&&o.push(st);for(let ct of it)for(let lt of ct.Q)nt(ct,[...st,lt],at)}}}function hex_cp(et){return et.toString(16).toUpperCase().padStart(2,"0")}function quote_cp(et){return`{${hex_cp(et)}}`}function explode_cp(et){let o=[];for(let tt=0,rt=et.length;tt>24&255}function unpack_cp(et){return et&16777215}let SHIFTED_RANK,EXCLUSIONS,DECOMP,RECOMP;function init$1(){let et=read_compressed_payload(COMPRESSED);SHIFTED_RANK=new Map(read_sorted_arrays(et).flatMap((o,tt)=>o.map(rt=>[rt,tt+1<<24]))),EXCLUSIONS=new Set(read_sorted(et)),DECOMP=new Map,RECOMP=new Map;for(let[o,tt]of read_mapped(et)){if(!EXCLUSIONS.has(o)&&tt.length==2){let[rt,nt]=tt,ot=RECOMP.get(rt);ot||(ot=new Map,RECOMP.set(rt,ot)),ot.set(nt,o)}DECOMP.set(o,tt.reverse())}}function is_hangul(et){return et>=S0&&et=L0&&et=V0&&oT0&&o0&&nt(T0+ct)}else{let it=DECOMP.get(ot);it?tt.push(...it):nt(ot)}if(!tt.length)break;ot=tt.pop()}if(rt&&o.length>1){let ot=unpack_cc(o[0]);for(let it=1;it0&&nt>=it)it==0?(o.push(rt,...tt),tt.length=0,rt=st):tt.push(st),nt=it;else{let at=compose_pair(rt,st);at>=0?rt=at:nt==0&&it==0?(o.push(rt),rt=st):(tt.push(st),nt=it)}}return rt>=0&&o.push(rt,...tt),o}function nfd(et){return decomposed(et).map(unpack_cp)}function nfc(et){return composed_from_decomposed(decomposed(et))}const HYPHEN=45,STOP_CH=".",FE0F=65039,UNIQUE_PH=1,Array_from=et=>Array.from(et);function group_has_cp(et,o){return et.P.has(o)||et.Q.has(o)}class Emoji extends Array{get is_emoji(){return!0}}let MAPPED,IGNORED,CM,NSM,ESCAPE,GROUPS,WHOLE_VALID,WHOLE_MAP,VALID,EMOJI_LIST,EMOJI_ROOT;function init(){if(MAPPED)return;let et=read_compressed_payload(COMPRESSED$1);const o=()=>read_sorted(et),tt=()=>new Set(o()),rt=(lt,dt)=>dt.forEach(ht=>lt.add(ht));MAPPED=new Map(read_mapped(et)),IGNORED=tt(),CM=o(),NSM=new Set(o().map(lt=>CM[lt])),CM=new Set(CM),ESCAPE=tt(),tt();let nt=read_sorted_arrays(et),ot=et();const it=()=>{let lt=new Set;return o().forEach(dt=>rt(lt,nt[dt])),rt(lt,o()),lt};GROUPS=read_array_while(lt=>{let dt=read_array_while(et).map(ht=>ht+96);if(dt.length){let ht=lt>=ot;dt[0]-=32,dt=str_from_cps(dt),ht&&(dt=`Restricted[${dt}]`);let mt=it(),ft=it(),pt=!et();return{N:dt,P:mt,Q:ft,M:pt,R:ht}}}),WHOLE_VALID=tt(),WHOLE_MAP=new Map;let st=o().concat(Array_from(WHOLE_VALID)).sort((lt,dt)=>lt-dt);st.forEach((lt,dt)=>{let ht=et(),mt=st[dt]=ht?st[dt-ht]:{V:[],M:new Map};mt.V.push(lt),WHOLE_VALID.has(lt)||WHOLE_MAP.set(lt,mt)});for(let{V:lt,M:dt}of new Set(WHOLE_MAP.values())){let ht=[];for(let ft of lt){let pt=GROUPS.filter(gt=>group_has_cp(gt,ft)),yt=ht.find(({G:gt})=>pt.some(bt=>gt.has(bt)));yt||(yt={G:new Set,V:[]},ht.push(yt)),yt.V.push(ft),rt(yt.G,pt)}let mt=ht.flatMap(ft=>Array_from(ft.G));for(let{G:ft,V:pt}of ht){let yt=new Set(mt.filter(gt=>!ft.has(gt)));for(let gt of pt)dt.set(gt,yt)}}VALID=new Set;let at=new Set;const ct=lt=>VALID.has(lt)?at.add(lt):VALID.add(lt);for(let lt of GROUPS){for(let dt of lt.P)ct(dt);for(let dt of lt.Q)ct(dt)}for(let lt of VALID)!WHOLE_MAP.has(lt)&&!at.has(lt)&&WHOLE_MAP.set(lt,UNIQUE_PH);rt(VALID,nfd(VALID)),EMOJI_LIST=read_trie(et).map(lt=>Emoji.from(lt)).sort(compare_arrays),EMOJI_ROOT=new Map;for(let lt of EMOJI_LIST){let dt=[EMOJI_ROOT];for(let ht of lt){let mt=dt.map(ft=>{let pt=ft.get(ht);return pt||(pt=new Map,ft.set(ht,pt)),pt});ht===FE0F?dt.push(...mt):dt=mt}for(let ht of dt)ht.V=lt}}function quoted_cp(et){return(should_escape(et)?"":`${bidi_qq(safe_str_from_cps([et]))} `)+quote_cp(et)}function bidi_qq(et){return`"${et}"‎`}function check_label_extension(et){if(et.length>=4&&et[2]==HYPHEN&&et[3]==HYPHEN)throw new Error(`invalid label extension: "${str_from_cps(et.slice(0,4))}"`)}function check_leading_underscore(et){for(let tt=et.lastIndexOf(95);tt>0;)if(et[--tt]!==95)throw new Error("underscore allowed only at start")}function check_fenced(et){let o=et[0],tt=FENCED.get(o);if(tt)throw error_placement(`leading ${tt}`);let rt=et.length,nt=-1;for(let ot=1;oto&&(o>>=1,et=[...et.slice(0,o),8230,...et.slice(-o)]);let nt=0,ot=et.length;for(let it=0;it{let ot=explode_cp(nt),it={input:ot,offset:rt};rt+=ot.length+1;try{let st=it.tokens=tokens_from_str(ot,o,tt),at=st.length,ct;if(!at)throw new Error("empty label");let lt=it.output=st.flat();if(check_leading_underscore(lt),!(it.emoji=at>1||st[0].is_emoji)&<.every(ht=>ht<128))check_label_extension(lt),ct="ASCII";else{let ht=st.flatMap(mt=>mt.is_emoji?[]:mt);if(!ht.length)ct="Emoji";else{if(CM.has(lt[0]))throw error_placement("leading combining mark");for(let pt=1;ptit.has(st)):Array_from(it),!tt.length)return}else rt.push(nt)}if(tt){for(let nt of tt)if(rt.every(ot=>group_has_cp(nt,ot)))throw new Error(`whole-script confusable: ${et.N}/${nt.N}`)}}function determine_group(et){let o=GROUPS;for(let tt of et){let rt=o.filter(nt=>group_has_cp(nt,tt));if(!rt.length)throw GROUPS.some(nt=>group_has_cp(nt,tt))?error_group_member(o[0],tt):error_disallowed(tt);if(o=rt,rt.length==1)break}return o}function flatten$1(et){return et.map(({input:o,error:tt,output:rt})=>{if(tt){let nt=tt.message;throw new Error(et.length==1?nt:`Invalid label ${bidi_qq(safe_str_from_cps(o,63))}: ${nt}`)}return str_from_cps(rt)}).join(STOP_CH)}function error_disallowed(et){return new Error(`disallowed character: ${quoted_cp(et)}`)}function error_group_member(et,o){let tt=quoted_cp(o),rt=GROUPS.find(nt=>nt.P.has(o));return rt&&(tt=`${rt.N} ${tt}`),new Error(`illegal mixture: ${et.N} + ${tt}`)}function error_placement(et){return new Error(`illegal placement: ${et}`)}function check_group(et,o){for(let tt of o)if(!group_has_cp(et,tt))throw error_group_member(et,tt);if(et.M){let tt=nfd(o);for(let rt=1,nt=tt.length;rtNSM_MAX)throw new Error(`excessive non-spacing marks: ${bidi_qq(safe_str_from_cps(tt.slice(rt-1,ot)))} (${ot-rt}/${NSM_MAX})`);rt=ot}}}function tokens_from_str(et,o,tt){let rt=[],nt=[];for(et=et.slice().reverse();et.length;){let ot=consume_emoji_reversed(et);if(ot)nt.length&&(rt.push(o(nt)),nt=[]),rt.push(tt(ot));else{let it=et.pop();if(VALID.has(it))nt.push(it);else{let st=MAPPED.get(it);if(st)nt.push(...st);else if(!IGNORED.has(it))throw error_disallowed(it)}}}return nt.length&&rt.push(o(nt)),rt}function filter_fe0f(et){return et.filter(o=>o!=FE0F)}function consume_emoji_reversed(et,o){let tt=EMOJI_ROOT,rt,nt=et.length;for(;nt&&(tt=tt.get(et[--nt]),!!tt);){let{V:ot}=tt;ot&&(rt=ot,et.length=nt)}return rt}function normalize$2(et){return ens_normalize(et)}function debounce$1(et,o,tt){var rt,nt,ot,it,st;o==null&&(o=100);function at(){var lt=Date.now()-it;lt=0?rt=setTimeout(at,o-lt):(rt=null,tt||(st=et.apply(ot,nt),ot=nt=null))}var ct=function(){ot=this,nt=arguments,it=Date.now();var lt=tt&&!rt;return rt||(rt=setTimeout(at,o)),lt&&(st=et.apply(ot,nt),ot=nt=null),st};return ct.clear=function(){rt&&(clearTimeout(rt),rt=null)},ct.flush=function(){rt&&(st=et.apply(ot,nt),ot=nt=null,clearTimeout(rt),rt=null)},ct}debounce$1.debounce=debounce$1;var debounce_1=debounce$1;const createDebounce=getDefaultExportFromCjs(debounce_1);function useMeasure(et){let{debounce:o,scroll:tt,polyfill:rt,offsetSize:nt}=et===void 0?{debounce:0,scroll:!1,offsetSize:!1}:et;const ot=rt||(typeof window>"u"?class{}:window.ResizeObserver);if(!ot)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[it,st]=reactExports.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),at=reactExports.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:it}),ct=o?typeof o=="number"?o:o.scroll:null,lt=o?typeof o=="number"?o:o.resize:null,dt=reactExports.useRef(!1);reactExports.useEffect(()=>(dt.current=!0,()=>void(dt.current=!1)));const[ht,mt,ft]=reactExports.useMemo(()=>{const bt=()=>{if(!at.current.element)return;const{left:xt,top:vt,width:Et,height:Ct,bottom:St,right:At,x:kt,y:It}=at.current.element.getBoundingClientRect(),Nt={left:xt,top:vt,width:Et,height:Ct,bottom:St,right:At,x:kt,y:It};at.current.element instanceof HTMLElement&&nt&&(Nt.height=at.current.element.offsetHeight,Nt.width=at.current.element.offsetWidth),Object.freeze(Nt),dt.current&&!areBoundsEqual(at.current.lastBounds,Nt)&&st(at.current.lastBounds=Nt)};return[bt,lt?createDebounce(bt,lt):bt,ct?createDebounce(bt,ct):bt]},[st,nt,ct,lt]);function pt(){at.current.scrollContainers&&(at.current.scrollContainers.forEach(bt=>bt.removeEventListener("scroll",ft,!0)),at.current.scrollContainers=null),at.current.resizeObserver&&(at.current.resizeObserver.disconnect(),at.current.resizeObserver=null)}function yt(){at.current.element&&(at.current.resizeObserver=new ot(ft),at.current.resizeObserver.observe(at.current.element),tt&&at.current.scrollContainers&&at.current.scrollContainers.forEach(bt=>bt.addEventListener("scroll",ft,{capture:!0,passive:!0})))}const gt=bt=>{!bt||bt===at.current.element||(pt(),at.current.element=bt,at.current.scrollContainers=findScrollContainers(bt),yt())};return useOnWindowScroll(ft,!!tt),useOnWindowResize(mt),reactExports.useEffect(()=>{pt(),yt()},[tt,ft,mt]),reactExports.useEffect(()=>pt,[]),[gt,it,ht]}function useOnWindowResize(et){reactExports.useEffect(()=>{const o=et;return window.addEventListener("resize",o),()=>void window.removeEventListener("resize",o)},[et])}function useOnWindowScroll(et,o){reactExports.useEffect(()=>{if(o){const tt=et;return window.addEventListener("scroll",tt,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",tt,!0)}},[et,o])}function findScrollContainers(et){const o=[];if(!et||et===document.body)return o;const{overflow:tt,overflowX:rt,overflowY:nt}=window.getComputedStyle(et);return[tt,rt,nt].some(ot=>ot==="auto"||ot==="scroll")&&o.push(et),[...o,...findScrollContainers(et.parentElement)]}const keys$1=["x","y","top","bottom","left","right","width","height"],areBoundsEqual=(et,o)=>keys$1.every(tt=>et[tt]===o[tt]);var MapShim=function(){if(typeof Map<"u")return Map;function et(o,tt){var rt=-1;return o.some(function(nt,ot){return nt[0]===tt?(rt=ot,!0):!1}),rt}return function(){function o(){this.__entries__=[]}return Object.defineProperty(o.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),o.prototype.get=function(tt){var rt=et(this.__entries__,tt),nt=this.__entries__[rt];return nt&&nt[1]},o.prototype.set=function(tt,rt){var nt=et(this.__entries__,tt);~nt?this.__entries__[nt][1]=rt:this.__entries__.push([tt,rt])},o.prototype.delete=function(tt){var rt=this.__entries__,nt=et(rt,tt);~nt&&rt.splice(nt,1)},o.prototype.has=function(tt){return!!~et(this.__entries__,tt)},o.prototype.clear=function(){this.__entries__.splice(0)},o.prototype.forEach=function(tt,rt){rt===void 0&&(rt=null);for(var nt=0,ot=this.__entries__;nt0},et.prototype.connect_=function(){!isBrowser$2||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),mutationObserverSupported?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},et.prototype.disconnect_=function(){!isBrowser$2||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},et.prototype.onTransitionEnd_=function(o){var tt=o.propertyName,rt=tt===void 0?"":tt,nt=transitionKeys.some(function(ot){return!!~rt.indexOf(ot)});nt&&this.refresh()},et.getInstance=function(){return this.instance_||(this.instance_=new et),this.instance_},et.instance_=null,et}(),defineConfigurable=function(et,o){for(var tt=0,rt=Object.keys(o);tt"u"||!(Element instanceof Object))){if(!(o instanceof getWindowOf(o).Element))throw new TypeError('parameter 1 is not of type "Element".');var tt=this.observations_;tt.has(o)||(tt.set(o,new ResizeObservation(o)),this.controller_.addObserver(this),this.controller_.refresh())}},et.prototype.unobserve=function(o){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(o instanceof getWindowOf(o).Element))throw new TypeError('parameter 1 is not of type "Element".');var tt=this.observations_;tt.has(o)&&(tt.delete(o),tt.size||this.controller_.removeObserver(this))}},et.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},et.prototype.gatherActive=function(){var o=this;this.clearActive(),this.observations_.forEach(function(tt){tt.isActive()&&o.activeObservations_.push(tt)})},et.prototype.broadcastActive=function(){if(this.hasActive()){var o=this.callbackCtx_,tt=this.activeObservations_.map(function(rt){return new ResizeObserverEntry(rt.target,rt.broadcastRect())});this.callback_.call(o,tt,o),this.clearActive()}},et.prototype.clearActive=function(){this.activeObservations_.splice(0)},et.prototype.hasActive=function(){return this.activeObservations_.length>0},et}(),observers=typeof WeakMap<"u"?new WeakMap:new MapShim,ResizeObserver$1=function(){function et(o){if(!(this instanceof et))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var tt=ResizeObserverController.getInstance(),rt=new ResizeObserverSPI(o,tt,this);observers.set(this,rt)}return et}();["observe","unobserve","disconnect"].forEach(function(et){ResizeObserver$1.prototype[et]=function(){var o;return(o=observers.get(this))[et].apply(o,arguments)}});var index$1=function(){return typeof global$1.ResizeObserver<"u"?global$1.ResizeObserver:ResizeObserver$1}(),browser$1={},canPromise$1=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},qrcode={},utils$2={};let toSJISFunction;const CODEWORDS_COUNT=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];utils$2.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17};utils$2.getSymbolTotalCodewords=function(o){return CODEWORDS_COUNT[o]};utils$2.getBCHDigit=function(et){let o=0;for(;et!==0;)o++,et>>>=1;return o};utils$2.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction=o};utils$2.isKanjiModeEnabled=function(){return typeof toSJISFunction<"u"};utils$2.toSJIS=function(o){return toSJISFunction(o)};var errorCorrectionLevel={};(function(et){et.L={bit:1},et.M={bit:0},et.Q={bit:3},et.H={bit:2};function o(tt){if(typeof tt!="string")throw new Error("Param is not a string");switch(tt.toLowerCase()){case"l":case"low":return et.L;case"m":case"medium":return et.M;case"q":case"quartile":return et.Q;case"h":case"high":return et.H;default:throw new Error("Unknown EC Level: "+tt)}}et.isValid=function(rt){return rt&&typeof rt.bit<"u"&&rt.bit>=0&&rt.bit<4},et.from=function(rt,nt){if(et.isValid(rt))return rt;try{return o(rt)}catch{return nt}}})(errorCorrectionLevel);function BitBuffer$1(){this.buffer=[],this.length=0}BitBuffer$1.prototype={get:function(et){const o=Math.floor(et/8);return(this.buffer[o]>>>7-et%8&1)===1},put:function(et,o){for(let tt=0;tt>>o-tt-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(et){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),et&&(this.buffer[o]|=128>>>this.length%8),this.length++}};var bitBuffer=BitBuffer$1;function BitMatrix$1(et){if(!et||et<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=et,this.data=new Uint8Array(et*et),this.reservedBit=new Uint8Array(et*et)}BitMatrix$1.prototype.set=function(et,o,tt,rt){const nt=et*this.size+o;this.data[nt]=tt,rt&&(this.reservedBit[nt]=!0)};BitMatrix$1.prototype.get=function(et,o){return this.data[et*this.size+o]};BitMatrix$1.prototype.xor=function(et,o,tt){this.data[et*this.size+o]^=tt};BitMatrix$1.prototype.isReserved=function(et,o){return this.reservedBit[et*this.size+o]};var bitMatrix=BitMatrix$1,alignmentPattern={};(function(et){const o=utils$2.getSymbolSize;et.getRowColCoords=function(rt){if(rt===1)return[];const nt=Math.floor(rt/7)+2,ot=o(rt),it=ot===145?26:Math.ceil((ot-13)/(2*nt-2))*2,st=[ot-7];for(let at=1;at=0&&nt<=7},et.from=function(nt){return et.isValid(nt)?parseInt(nt,10):void 0},et.getPenaltyN1=function(nt){const ot=nt.size;let it=0,st=0,at=0,ct=null,lt=null;for(let dt=0;dt=5&&(it+=o.N1+(st-5)),ct=mt,st=1),mt=nt.get(ht,dt),mt===lt?at++:(at>=5&&(it+=o.N1+(at-5)),lt=mt,at=1)}st>=5&&(it+=o.N1+(st-5)),at>=5&&(it+=o.N1+(at-5))}return it},et.getPenaltyN2=function(nt){const ot=nt.size;let it=0;for(let st=0;st=10&&(st===1488||st===93)&&it++,at=at<<1&2047|nt.get(lt,ct),lt>=10&&(at===1488||at===93)&&it++}return it*o.N3},et.getPenaltyN4=function(nt){let ot=0;const it=nt.data.length;for(let at=0;at=0;){const it=ot[0];for(let at=0;at0){const ot=new Uint8Array(this.degree);return ot.set(rt,nt),ot}return rt};var reedSolomonEncoder=ReedSolomonEncoder$1,version$4={},mode$1={},versionCheck={};versionCheck.isValid=function(o){return!isNaN(o)&&o>=1&&o<=40};var regex={};const numeric="[0-9]+",alphanumeric="[A-Z $%*+\\-./:]+";let kanji="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";kanji=kanji.replace(/u/g,"\\u");const byte="(?:(?![A-Z0-9 $%*+\\-./:]|"+kanji+`)(?:.|[\r +]))+`;regex.KANJI=new RegExp(kanji,"g");regex.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");regex.BYTE=new RegExp(byte,"g");regex.NUMERIC=new RegExp(numeric,"g");regex.ALPHANUMERIC=new RegExp(alphanumeric,"g");const TEST_KANJI=new RegExp("^"+kanji+"$"),TEST_NUMERIC=new RegExp("^"+numeric+"$"),TEST_ALPHANUMERIC=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");regex.testKanji=function(o){return TEST_KANJI.test(o)};regex.testNumeric=function(o){return TEST_NUMERIC.test(o)};regex.testAlphanumeric=function(o){return TEST_ALPHANUMERIC.test(o)};(function(et){const o=versionCheck,tt=regex;et.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},et.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},et.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},et.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},et.MIXED={bit:-1},et.getCharCountIndicator=function(ot,it){if(!ot.ccBits)throw new Error("Invalid mode: "+ot);if(!o.isValid(it))throw new Error("Invalid version: "+it);return it>=1&&it<10?ot.ccBits[0]:it<27?ot.ccBits[1]:ot.ccBits[2]},et.getBestModeForData=function(ot){return tt.testNumeric(ot)?et.NUMERIC:tt.testAlphanumeric(ot)?et.ALPHANUMERIC:tt.testKanji(ot)?et.KANJI:et.BYTE},et.toString=function(ot){if(ot&&ot.id)return ot.id;throw new Error("Invalid mode")},et.isValid=function(ot){return ot&&ot.bit&&ot.ccBits};function rt(nt){if(typeof nt!="string")throw new Error("Param is not a string");switch(nt.toLowerCase()){case"numeric":return et.NUMERIC;case"alphanumeric":return et.ALPHANUMERIC;case"kanji":return et.KANJI;case"byte":return et.BYTE;default:throw new Error("Unknown mode: "+nt)}}et.from=function(ot,it){if(et.isValid(ot))return ot;try{return rt(ot)}catch{return it}}})(mode$1);(function(et){const o=utils$2,tt=errorCorrectionCode,rt=errorCorrectionLevel,nt=mode$1,ot=versionCheck,it=7973,st=o.getBCHDigit(it);function at(ht,mt,ft){for(let pt=1;pt<=40;pt++)if(mt<=et.getCapacity(pt,ft,ht))return pt}function ct(ht,mt){return nt.getCharCountIndicator(ht,mt)+4}function lt(ht,mt){let ft=0;return ht.forEach(function(pt){const yt=ct(pt.mode,mt);ft+=yt+pt.getBitsLength()}),ft}function dt(ht,mt){for(let ft=1;ft<=40;ft++)if(lt(ht,ft)<=et.getCapacity(ft,mt,nt.MIXED))return ft}et.from=function(mt,ft){return ot.isValid(mt)?parseInt(mt,10):ft},et.getCapacity=function(mt,ft,pt){if(!ot.isValid(mt))throw new Error("Invalid QR Code version");typeof pt>"u"&&(pt=nt.BYTE);const yt=o.getSymbolTotalCodewords(mt),gt=tt.getTotalCodewordsCount(mt,ft),bt=(yt-gt)*8;if(pt===nt.MIXED)return bt;const xt=bt-ct(pt,mt);switch(pt){case nt.NUMERIC:return Math.floor(xt/10*3);case nt.ALPHANUMERIC:return Math.floor(xt/11*2);case nt.KANJI:return Math.floor(xt/13);case nt.BYTE:default:return Math.floor(xt/8)}},et.getBestVersionForData=function(mt,ft){let pt;const yt=rt.from(ft,rt.M);if(Array.isArray(mt)){if(mt.length>1)return dt(mt,yt);if(mt.length===0)return 1;pt=mt[0]}else pt=mt;return at(pt.mode,pt.getLength(),yt)},et.getEncodedBits=function(mt){if(!ot.isValid(mt)||mt<7)throw new Error("Invalid QR Code version");let ft=mt<<12;for(;o.getBCHDigit(ft)-st>=0;)ft^=it<=0;)nt^=G15<0&&(rt=this.data.substr(tt),nt=parseInt(rt,10),o.put(nt,ot*3+1))};var numericData=NumericData;const Mode$3=mode$1,ALPHA_NUM_CHARS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function AlphanumericData(et){this.mode=Mode$3.ALPHANUMERIC,this.data=et}AlphanumericData.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)};AlphanumericData.prototype.getLength=function(){return this.data.length};AlphanumericData.prototype.getBitsLength=function(){return AlphanumericData.getBitsLength(this.data.length)};AlphanumericData.prototype.write=function(o){let tt;for(tt=0;tt+2<=this.data.length;tt+=2){let rt=ALPHA_NUM_CHARS.indexOf(this.data[tt])*45;rt+=ALPHA_NUM_CHARS.indexOf(this.data[tt+1]),o.put(rt,11)}this.data.length%2&&o.put(ALPHA_NUM_CHARS.indexOf(this.data[tt]),6)};var alphanumericData=AlphanumericData;const Mode$2=mode$1;function ByteData(et){this.mode=Mode$2.BYTE,typeof et=="string"?this.data=new TextEncoder().encode(et):this.data=new Uint8Array(et)}ByteData.getBitsLength=function(o){return o*8};ByteData.prototype.getLength=function(){return this.data.length};ByteData.prototype.getBitsLength=function(){return ByteData.getBitsLength(this.data.length)};ByteData.prototype.write=function(et){for(let o=0,tt=this.data.length;o=33088&&tt<=40956)tt-=33088;else if(tt>=57408&&tt<=60351)tt-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+` +Make sure your charset is UTF-8`);tt=(tt>>>8&255)*192+(tt&255),et.put(tt,13)}};var kanjiData=KanjiData,dijkstra={exports:{}};(function(et){var o={single_source_shortest_paths:function(tt,rt,nt){var ot={},it={};it[rt]=0;var st=o.PriorityQueue.make();st.push(rt,0);for(var at,ct,lt,dt,ht,mt,ft,pt,yt;!st.empty();){at=st.pop(),ct=at.value,dt=at.cost,ht=tt[ct]||{};for(lt in ht)ht.hasOwnProperty(lt)&&(mt=ht[lt],ft=dt+mt,pt=it[lt],yt=typeof it[lt]>"u",(yt||pt>ft)&&(it[lt]=ft,st.push(lt,ft),ot[lt]=ct))}if(typeof nt<"u"&&typeof it[nt]>"u"){var gt=["Could not find a path from ",rt," to ",nt,"."].join("");throw new Error(gt)}return ot},extract_shortest_path_from_predecessor_list:function(tt,rt){for(var nt=[],ot=rt;ot;)nt.push(ot),tt[ot],ot=tt[ot];return nt.reverse(),nt},find_path:function(tt,rt,nt){var ot=o.single_source_shortest_paths(tt,rt,nt);return o.extract_shortest_path_from_predecessor_list(ot,nt)},PriorityQueue:{make:function(tt){var rt=o.PriorityQueue,nt={},ot;tt=tt||{};for(ot in rt)rt.hasOwnProperty(ot)&&(nt[ot]=rt[ot]);return nt.queue=[],nt.sorter=tt.sorter||rt.default_sorter,nt},default_sorter:function(tt,rt){return tt.cost-rt.cost},push:function(tt,rt){var nt={value:tt,cost:rt};this.queue.push(nt),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};et.exports=o})(dijkstra);var dijkstraExports=dijkstra.exports;(function(et){const o=mode$1,tt=numericData,rt=alphanumericData,nt=byteData,ot=kanjiData,it=regex,st=utils$2,at=dijkstraExports;function ct(gt){return unescape(encodeURIComponent(gt)).length}function lt(gt,bt,xt){const vt=[];let Et;for(;(Et=gt.exec(xt))!==null;)vt.push({data:Et[0],index:Et.index,mode:bt,length:Et[0].length});return vt}function dt(gt){const bt=lt(it.NUMERIC,o.NUMERIC,gt),xt=lt(it.ALPHANUMERIC,o.ALPHANUMERIC,gt);let vt,Et;return st.isKanjiModeEnabled()?(vt=lt(it.BYTE,o.BYTE,gt),Et=lt(it.KANJI,o.KANJI,gt)):(vt=lt(it.BYTE_KANJI,o.BYTE,gt),Et=[]),bt.concat(xt,vt,Et).sort(function(St,At){return St.index-At.index}).map(function(St){return{data:St.data,mode:St.mode,length:St.length}})}function ht(gt,bt){switch(bt){case o.NUMERIC:return tt.getBitsLength(gt);case o.ALPHANUMERIC:return rt.getBitsLength(gt);case o.KANJI:return ot.getBitsLength(gt);case o.BYTE:return nt.getBitsLength(gt)}}function mt(gt){return gt.reduce(function(bt,xt){const vt=bt.length-1>=0?bt[bt.length-1]:null;return vt&&vt.mode===xt.mode?(bt[bt.length-1].data+=xt.data,bt):(bt.push(xt),bt)},[])}function ft(gt){const bt=[];for(let xt=0;xt=0&&st<=6&&(at===0||at===6)||at>=0&&at<=6&&(st===0||st===6)||st>=2&&st<=4&&at>=2&&at<=4?et.set(ot+st,it+at,!0,!0):et.set(ot+st,it+at,!1,!0))}}function setupTimingPattern(et){const o=et.size;for(let tt=8;tt>st&1)===1,et.set(nt,ot,it,!0),et.set(ot,nt,it,!0)}function setupFormatInfo(et,o,tt){const rt=et.size,nt=FormatInfo.getEncodedBits(o,tt);let ot,it;for(ot=0;ot<15;ot++)it=(nt>>ot&1)===1,ot<6?et.set(ot,8,it,!0):ot<8?et.set(ot+1,8,it,!0):et.set(rt-15+ot,8,it,!0),ot<8?et.set(8,rt-ot-1,it,!0):ot<9?et.set(8,15-ot-1+1,it,!0):et.set(8,15-ot-1,it,!0);et.set(rt-8,8,1,!0)}function setupData(et,o){const tt=et.size;let rt=-1,nt=tt-1,ot=7,it=0;for(let st=tt-1;st>0;st-=2)for(st===6&&st--;;){for(let at=0;at<2;at++)if(!et.isReserved(nt,st-at)){let ct=!1;it>>ot&1)===1),et.set(nt,st-at,ct),ot--,ot===-1&&(it++,ot=7)}if(nt+=rt,nt<0||tt<=nt){nt-=rt,rt=-rt;break}}}function createData(et,o,tt){const rt=new BitBuffer;tt.forEach(function(at){rt.put(at.mode.bit,4),rt.put(at.getLength(),Mode.getCharCountIndicator(at.mode,et)),at.write(rt)});const nt=Utils$1.getSymbolTotalCodewords(et),ot=ECCode.getTotalCodewordsCount(et,o),it=(nt-ot)*8;for(rt.getLengthInBits()+4<=it&&rt.put(0,4);rt.getLengthInBits()%8!==0;)rt.putBit(0);const st=(it-rt.getLengthInBits())/8;for(let at=0;at=7&&setupVersionInfo(at,o),setupData(at,it),isNaN(rt)&&(rt=MaskPattern.getBestMask(at,setupFormatInfo.bind(null,at,tt))),MaskPattern.applyMask(rt,at),setupFormatInfo(at,tt,rt),{modules:at,version:o,errorCorrectionLevel:tt,maskPattern:rt,segments:nt}}qrcode.create=function(o,tt){if(typeof o>"u"||o==="")throw new Error("No input text");let rt=ECLevel.M,nt,ot;return typeof tt<"u"&&(rt=ECLevel.from(tt.errorCorrectionLevel,ECLevel.M),nt=Version$1.from(tt.version),ot=MaskPattern.from(tt.maskPattern),tt.toSJISFunc&&Utils$1.setToSJISFunction(tt.toSJISFunc)),createSymbol(o,nt,rt,ot)};var canvas={},utils$1={};(function(et){function o(tt){if(typeof tt=="number"&&(tt=tt.toString()),typeof tt!="string")throw new Error("Color should be defined as hex string");let rt=tt.slice().replace("#","").split("");if(rt.length<3||rt.length===5||rt.length>8)throw new Error("Invalid hex color: "+tt);(rt.length===3||rt.length===4)&&(rt=Array.prototype.concat.apply([],rt.map(function(ot){return[ot,ot]}))),rt.length===6&&rt.push("F","F");const nt=parseInt(rt.join(""),16);return{r:nt>>24&255,g:nt>>16&255,b:nt>>8&255,a:nt&255,hex:"#"+rt.slice(0,6).join("")}}et.getOptions=function(rt){rt||(rt={}),rt.color||(rt.color={});const nt=typeof rt.margin>"u"||rt.margin===null||rt.margin<0?4:rt.margin,ot=rt.width&&rt.width>=21?rt.width:void 0,it=rt.scale||4;return{width:ot,scale:ot?4:it,margin:nt,color:{dark:o(rt.color.dark||"#000000ff"),light:o(rt.color.light||"#ffffffff")},type:rt.type,rendererOpts:rt.rendererOpts||{}}},et.getScale=function(rt,nt){return nt.width&&nt.width>=rt+nt.margin*2?nt.width/(rt+nt.margin*2):nt.scale},et.getImageWidth=function(rt,nt){const ot=et.getScale(rt,nt);return Math.floor((rt+nt.margin*2)*ot)},et.qrToImageData=function(rt,nt,ot){const it=nt.modules.size,st=nt.modules.data,at=et.getScale(it,ot),ct=Math.floor((it+ot.margin*2)*at),lt=ot.margin*at,dt=[ot.color.light,ot.color.dark];for(let ht=0;ht=lt&&mt>=lt&&ht"u"&&(!it||!it.getContext)&&(at=it,it=void 0),it||(ct=rt()),at=o.getOptions(at);const lt=o.getImageWidth(ot.modules.size,at),dt=ct.getContext("2d"),ht=dt.createImageData(lt,lt);return o.qrToImageData(ht.data,ot,at),tt(dt,ct,lt),dt.putImageData(ht,0,0),ct},et.renderToDataURL=function(ot,it,st){let at=st;typeof at>"u"&&(!it||!it.getContext)&&(at=it,it=void 0),at||(at={});const ct=et.render(ot,it,at),lt=at.type||"image/png",dt=at.rendererOpts||{};return ct.toDataURL(lt,dt.quality)}})(canvas);var svgTag={};const Utils=utils$1;function getColorAttrib(et,o){const tt=et.a/255,rt=o+'="'+et.hex+'"';return tt<1?rt+" "+o+'-opacity="'+tt.toFixed(2).slice(1)+'"':rt}function svgCmd(et,o,tt){let rt=et+o;return typeof tt<"u"&&(rt+=" "+tt),rt}function qrToPath(et,o,tt){let rt="",nt=0,ot=!1,it=0;for(let st=0;st0&&at>0&&et[st-1]||(rt+=ot?svgCmd("M",at+tt,.5+ct+tt):svgCmd("m",nt,0),nt=0,ot=!1),at+1':"",ct="',lt='viewBox="0 0 '+st+" "+st+'"',ht=''+at+ct+` -`;return typeof rt=="function"&&rt(null,ht),ht};const canPromise=canPromise$1,QRCode$2=qrcode,CanvasRenderer=canvas,SvgRenderer=svgTag;function renderCanvas(et,o,tt,rt,nt){const ot=[].slice.call(arguments,1),it=ot.length,st=typeof ot[it-1]=="function";if(!st&&!canPromise())throw new Error("Callback required as last argument");if(st){if(it<2)throw new Error("Too few arguments provided");it===2?(nt=tt,tt=o,o=rt=void 0):it===3&&(o.getContext&&typeof nt>"u"?(nt=rt,rt=void 0):(nt=rt,rt=tt,tt=o,o=void 0))}else{if(it<1)throw new Error("Too few arguments provided");return it===1?(tt=o,o=rt=void 0):it===2&&!o.getContext&&(rt=tt,tt=o,o=void 0),new Promise(function(at,ct){try{const lt=QRCode$2.create(tt,rt);at(et(lt,o,rt))}catch(lt){ct(lt)}})}try{const at=QRCode$2.create(tt,rt);nt(null,et(at,o,rt))}catch(at){nt(at)}}browser$1.create=QRCode$2.create;browser$1.toCanvas=renderCanvas.bind(null,CanvasRenderer.render);browser$1.toDataURL=renderCanvas.bind(null,CanvasRenderer.renderToDataURL);browser$1.toString=renderCanvas.bind(null,function(et,o,tt){return SvgRenderer.render(et,tt)});var PRE_ENTER=0,ENTERING=1,ENTERED=2,PRE_EXIT=3,EXITING=4,EXITED=5,UNMOUNTED=6,STATES=["preEnter","entering","entered","preExit","exiting","exited","unmounted"],startOrEnd=function(o){return o?UNMOUNTED:EXITED},updateState=function(o,tt,rt,nt,ot){clearTimeout(nt.current),tt(o),rt.current=o,ot&&ot({state:STATES[o]})},useTransition=function(o){var tt=o===void 0?{}:o,rt=tt.enter,nt=rt===void 0?!0:rt,ot=tt.exit,it=ot===void 0?!0:ot,st=tt.preEnter,at=tt.preExit,ct=tt.timeout,lt=tt.initialEntered,dt=tt.mountOnEnter,ht=tt.unmountOnExit,mt=tt.onChange,ft=reactExports.useState(lt?ENTERED:startOrEnd(dt)),pt=ft[0],gt=ft[1],yt=reactExports.useRef(pt),bt=reactExports.useRef(),xt,vt;typeof ct=="object"?(xt=ct.enter,vt=ct.exit):xt=vt=ct;var Et=reactExports.useCallback(function(){var St;switch(yt.current){case ENTERING:case PRE_ENTER:St=ENTERED;break;case EXITING:case PRE_EXIT:St=startOrEnd(ht);break}St!==void 0&&updateState(St,gt,yt,bt,mt)},[mt,ht]),Ct=reactExports.useCallback(function(St){var At=function It(Ot){switch(updateState(Ot,gt,yt,bt,mt),Ot){case ENTERING:xt>=0&&(bt.current=setTimeout(Et,xt));break;case EXITING:vt>=0&&(bt.current=setTimeout(Et,vt));break;case PRE_ENTER:case PRE_EXIT:bt.current=setTimeout(function(){return It(Ot+1)},0);break}},kt=yt.current<=ENTERED;typeof St!="boolean"&&(St=!kt),St?kt||At(nt?st?PRE_ENTER:ENTERING:ENTERED):kt&&At(it?at?PRE_EXIT:EXITING:startOrEnd(ht))},[Et,mt,nt,it,st,at,xt,vt,ht]);return reactExports.useEffect(function(){return function(){return clearTimeout(bt.current)}},[]),[STATES[pt],Ct,Et]};const defaultConnectors=({app:et,walletConnectProjectId:o,coinbaseWalletPreference:tt})=>{const rt=et.name&&et.icon&&et.description&&et.url,nt=!(typeof window>"u")&&(window==null?void 0:window.parent)!==window,ot=[];return nt&&ot.push(safe({allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/]})),ot.push(injected({target:"metaMask"}),coinbaseWallet({appName:et.name,appLogoUrl:et.icon,overrideIsMetaMask:!1,preference:tt})),o&&ot.push(walletConnect({showQrModal:!1,projectId:o,metadata:rt?{name:et.name,description:et.description,url:et.url,icons:[et.icon]}:void 0})),ot};let globalAppName,globalAppIcon;const getAppName=()=>globalAppName,getAppIcon=()=>globalAppIcon,defaultConfig=({appName:et="ConnectKit",appIcon:o,appDescription:tt,appUrl:rt,walletConnectProjectId:nt,coinbaseWalletPreference:ot,chains:it=[mainnet,polygon,optimism,arbitrum],client:st,...at})=>{var ct,lt;globalAppName=et,o&&(globalAppIcon=o);const dt=(ct=at==null?void 0:at.transports)!==null&&ct!==void 0?ct:Object.fromEntries(it.map(ft=>[ft.id,http()])),ht=(lt=at==null?void 0:at.connectors)!==null&<!==void 0?lt:defaultConnectors({app:{name:et,icon:o,description:tt,url:rt},walletConnectProjectId:nt,coinbaseWalletPreference:ot});return{...at,chains:it,connectors:ht,transports:dt}},isWalletInstalled=et=>{if(typeof window>"u")return!1;const{ethereum:o}=window;return!!(o!=null&&o[`is${et}`]||o!=null&&o.providers&&(o!=null&&o.providers.find(tt=>tt==null?void 0:tt[`is${et}`])))},isFamily=()=>isWalletInstalled("Family"),isRainbow=()=>isWalletInstalled("Rainbow"),isZerion=()=>isWalletInstalled("Zerion"),Mock=({...et})=>jsxRuntimeExports.jsxs("svg",{...et,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)"},children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.5611 8.12948C21.0082 7.90729 21.5007 7.79167 22 7.79167C22.4993 7.79167 22.9919 7.90729 23.439 8.12948L23.4408 8.1304L33.0387 12.9293C33.577 13.197 34.031 13.61 34.3478 14.121C34.6649 14.6323 34.833 15.2218 34.8333 15.8234V27.2595C34.833 27.8611 34.6649 28.4511 34.3478 28.9624C34.031 29.4733 33.578 29.8858 33.0398 30.1535L23.4411 34.9528C22.9919 35.1775 22.4963 35.2947 21.994 35.2947C21.4918 35.2947 20.9964 35.1777 20.5472 34.9529L10.9475 30.1531L10.9452 30.1519C10.4071 29.8808 9.95535 29.4646 9.6411 28.9504C9.32739 28.437 9.16312 27.8464 9.16673 27.2448L9.16675 27.2417L10.0004 27.2475H9.16673V27.2448V15.8239C9.16705 15.2223 9.33518 14.6322 9.65222 14.121C9.96906 13.61 10.4221 13.1976 10.9604 12.9298L20.5592 8.1304L20.5611 8.12948ZM21.3031 9.62267L11.8706 14.3389L22 19.4036L32.1294 14.3389L22.697 9.62267C22.4806 9.51531 22.2416 9.45905 22 9.45905C21.7585 9.45905 21.5194 9.51534 21.3031 9.62267ZM10.8341 15.8241C10.8341 15.7785 10.8362 15.733 10.8401 15.6878L21.1663 20.8509V33.3983L11.6955 28.6629C11.4352 28.5315 11.2159 28.3297 11.0638 28.0809C10.9116 27.8318 10.8321 27.5452 10.8341 27.2533L10.8341 27.2475V15.8241ZM22.8337 33.3923L32.2967 28.6608C32.5576 28.5312 32.7772 28.3313 32.9308 28.0836C33.0844 27.836 33.1658 27.5504 33.166 27.259V15.8243C33.1659 15.7786 33.1639 15.7331 33.1599 15.6878L22.8337 20.8509V33.3923Z",fill:"url(#paint0_linear_3546_7073)"}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.8341 15.8241C10.8341 15.7785 10.8362 15.733 10.8401 15.6878L21.1663 20.8509V33.3983L11.6955 28.6629C11.4352 28.5315 11.2159 28.3297 11.0638 28.0809C10.9116 27.8318 10.8321 27.5452 10.8341 27.2533L10.8341 27.2475V15.8241Z",fill:"url(#paint1_linear_3546_7073)",fillOpacity:"0.3"}),jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_3546_7073",x1:"22",y1:"7.79167",x2:"22",y2:"35.2947",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.7"})]}),jsxRuntimeExports.jsxs("linearGradient",{id:"paint1_linear_3546_7073",x1:"22",y1:"7.79167",x2:"22",y2:"35.2947",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.7"})]})]})]}),Injected=({...et})=>jsxRuntimeExports.jsx("svg",{...et,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.6505 3.64041C15.6501 3.64062 15.6497 3.64083 15.6493 3.64103L6.05165 8.43985L16.2501 13.5391L26.4484 8.43987L16.8508 3.64103C16.8504 3.64083 16.85 3.64063 16.8496 3.64043C16.6632 3.54806 16.458 3.5 16.25 3.5C16.042 3.5 15.8369 3.54806 15.6505 3.64041ZM28 10.4592L17.5001 15.7091L17.5 28.5205L27.248 23.6465L27.2508 23.6452C27.4757 23.5334 27.665 23.3611 27.7973 23.1477C27.9297 22.9342 27.9999 22.6881 28 22.4369V10.4592ZM15 28.527L15.0001 15.7091L4.50006 10.4591V22.4333C4.49831 22.6849 4.56687 22.9319 4.69807 23.1466C4.82896 23.3608 5.01696 23.5342 5.24095 23.6475C5.24148 23.6477 5.242 23.648 5.24253 23.6483L15 28.527ZM14.5207 31.0824L4.12104 25.8826L4.11759 25.8809C3.47681 25.558 2.93902 25.0625 2.56486 24.4502C2.19154 23.8394 1.99597 23.1365 2.00006 22.4207V10.0486C2.00044 9.33234 2.20062 8.62972 2.5781 8.021C2.95529 7.41274 3.49457 6.92167 4.13537 6.60291C4.13585 6.60267 4.13633 6.60243 4.13681 6.60219L14.534 1.40359L14.5368 1.40221C15.0692 1.13767 15.6556 1 16.25 1C16.8445 1 17.4309 1.13767 17.9633 1.40221L17.966 1.40358L28.3633 6.60219C28.3638 6.60245 28.3643 6.6027 28.3648 6.60295C29.0055 6.92171 29.5448 7.41276 29.922 8.021C30.2994 8.62973 30.4996 9.33168 30.5 10.0479V22.4376C30.4996 23.1538 30.2994 23.8565 29.922 24.4652C29.5448 25.0734 29.0056 25.5644 28.365 25.8831C28.3644 25.8834 28.3638 25.8837 28.3633 25.884L17.9664 31.0824C17.9663 31.0825 17.9665 31.0824 17.9664 31.0824C17.4316 31.3499 16.8415 31.4894 16.2435 31.4894C15.6455 31.4894 15.0554 31.3499 14.5207 31.0824C14.5205 31.0824 14.5208 31.0825 14.5207 31.0824Z",fill:"#CCCCCC"})}),WalletConnect=({background:et=!1,...o})=>jsxRuntimeExports.jsx("svg",{...o,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:et?{background:"var(--ck-brand-walletConnect)"}:void 0,children:jsxRuntimeExports.jsx("path",{d:"M9.58818 11.8556C13.1293 8.31442 18.8706 8.31442 22.4117 11.8556L22.8379 12.2818C23.015 12.4588 23.015 12.7459 22.8379 12.9229L21.3801 14.3808C21.2915 14.4693 21.148 14.4693 21.0595 14.3808L20.473 13.7943C18.0026 11.3239 13.9973 11.3239 11.5269 13.7943L10.8989 14.4223C10.8104 14.5109 10.6668 14.5109 10.5783 14.4223L9.12041 12.9645C8.94336 12.7875 8.94336 12.5004 9.12041 12.3234L9.58818 11.8556ZM25.4268 14.8706L26.7243 16.1682C26.9013 16.3452 26.9013 16.6323 26.7243 16.8093L20.8737 22.6599C20.6966 22.8371 20.4096 22.8371 20.2325 22.6599L16.0802 18.5076C16.0359 18.4634 15.9641 18.4634 15.9199 18.5076L11.7675 22.6599C11.5905 22.8371 11.3034 22.8371 11.1264 22.66C11.1264 22.66 11.1264 22.6599 11.1264 22.6599L5.27561 16.8092C5.09856 16.6322 5.09856 16.3451 5.27561 16.168L6.57313 14.8706C6.75019 14.6934 7.03726 14.6934 7.21431 14.8706L11.3668 19.023C11.411 19.0672 11.4828 19.0672 11.5271 19.023L15.6793 14.8706C15.8563 14.6934 16.1434 14.6934 16.3205 14.8706L20.473 19.023C20.5172 19.0672 20.589 19.0672 20.6332 19.023L24.7856 14.8706C24.9627 14.6935 25.2498 14.6935 25.4268 14.8706Z",fill:et?"white":"var(--ck-brand-walletConnect)"})}),MetaMask=({background:et=!1,...o})=>jsxRuntimeExports.jsxs("svg",{...o,style:et?{background:"linear-gradient(0deg, var(--ck-brand-metamask-12), var(--ck-brand-metamask-11))",borderRadius:"27.5%"}:void 0,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("path",{d:"M27.2684 4.03027L17.5018 11.2841L19.3079 7.00442L27.2684 4.03027Z",fill:"var(--ck-brand-metamask-02)",stroke:"var(--ck-brand-metamask-02)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M4.7218 4.03027L14.4099 11.3528L12.6921 7.00442L4.7218 4.03027Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M23.7544 20.8438L21.1532 24.8289L26.7187 26.3602L28.3187 20.9321L23.7544 20.8438Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M3.69104 20.9321L5.28117 26.3602L10.8467 24.8289L8.24551 20.8438L3.69104 20.9321Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.5327 14.1108L8.98181 16.4568L14.5081 16.7022L14.3117 10.7637L10.5327 14.1108Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M21.4576 14.1111L17.6295 10.6953L17.5018 16.7025L23.0182 16.4571L21.4576 14.1111Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.8469 24.8292L14.1647 23.2096L11.2984 20.9717L10.8469 24.8292Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M17.8257 23.2096L21.1531 24.8292L20.6918 20.9717L17.8257 23.2096Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M21.1531 24.8296L17.8257 23.21L18.0906 25.3793L18.0612 26.2921L21.1531 24.8296Z",fill:"var(--ck-brand-metamask-06)",stroke:"var(--ck-brand-metamask-06)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.8469 24.8296L13.9388 26.2921L13.9192 25.3793L14.1647 23.21L10.8469 24.8296Z",fill:"var(--ck-brand-metamask-06)",stroke:"var(--ck-brand-metamask-06)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M13.9877 19.5389L11.2196 18.7242L13.1729 17.8311L13.9877 19.5389Z",fill:"var(--ck-brand-metamask-09)",stroke:"var(--ck-brand-metamask-09)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M18.0023 19.5389L18.8171 17.8311L20.7802 18.7242L18.0023 19.5389Z",fill:"var(--ck-brand-metamask-09)",stroke:"var(--ck-brand-metamask-09)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.8468 24.8289L11.3179 20.8438L8.24561 20.9321L10.8468 24.8289Z",fill:"var(--ck-brand-metamask-03)",stroke:"var(--ck-brand-metamask-03)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M20.6821 20.8438L21.1532 24.8289L23.7544 20.9321L20.6821 20.8438Z",fill:"var(--ck-brand-metamask-03)",stroke:"var(--ck-brand-metamask-03)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M23.0182 16.4565L17.5018 16.7019L18.0122 19.5387L18.827 17.8308L20.7902 18.7239L23.0182 16.4565Z",fill:"var(--ck-brand-metamask-03)",stroke:"var(--ck-brand-metamask-03)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M11.2198 18.7239L13.1829 17.8308L13.9878 19.5387L14.5081 16.7019L8.98181 16.4565L11.2198 18.7239Z",fill:"var(--ck-brand-metamask-03)",stroke:"var(--ck-brand-metamask-03)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M8.98181 16.4565L11.2983 20.9718L11.2198 18.7239L8.98181 16.4565Z",fill:"var(--ck-brand-metamask-10)",stroke:"var(--ck-brand-metamask-10)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M20.7901 18.7239L20.6919 20.9718L23.0181 16.4565L20.7901 18.7239Z",fill:"var(--ck-brand-metamask-10)",stroke:"var(--ck-brand-metamask-10)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M14.508 16.7021L13.9878 19.5389L14.6356 22.886L14.7828 18.4788L14.508 16.7021Z",fill:"var(--ck-brand-metamask-10)",stroke:"var(--ck-brand-metamask-10)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M17.5017 16.7021L17.2367 18.4689L17.3545 22.886L18.0121 19.5389L17.5017 16.7021Z",fill:"var(--ck-brand-metamask-10)",stroke:"var(--ck-brand-metamask-10)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M18.0121 19.5388L17.3545 22.886L17.8257 23.2099L20.6918 20.972L20.79 18.7241L18.0121 19.5388Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M11.2196 18.7241L11.2981 20.972L14.1644 23.2099L14.6355 22.886L13.9877 19.5388L11.2196 18.7241Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M18.0615 26.2917L18.0908 25.3788L17.8455 25.1628H14.145L13.9192 25.3788L13.9388 26.2917L10.8469 24.8291L11.9267 25.7126L14.1155 27.234H17.875L20.0736 25.7126L21.1533 24.8291L18.0615 26.2917Z",fill:"var(--ck-brand-metamask-07)",stroke:"var(--ck-brand-metamask-07)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M17.8258 23.2096L17.3546 22.8857H14.6357L14.1646 23.2096L13.9191 25.379L14.1449 25.163H17.8454L18.0907 25.379L17.8258 23.2096Z",fill:"var(--ck-brand-metamask-04)",stroke:"var(--ck-brand-metamask-04)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M27.6806 11.7552L28.5149 7.75041L27.2683 4.03027L17.8257 11.0387L21.4575 14.1109L26.591 15.6128L27.7296 14.2876L27.2389 13.9342L28.0241 13.2178L27.4156 12.7465L28.2007 12.1478L27.6806 11.7552Z",fill:"var(--ck-brand-metamask-05)",stroke:"var(--ck-brand-metamask-05)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M3.48486 7.75041L4.3192 11.7552L3.78916 12.1478L4.57441 12.7465L3.97566 13.2178L4.7609 13.9342L4.27012 14.2876L5.39892 15.6128L10.5325 14.1109L14.1644 11.0387L4.72164 4.03027L3.48486 7.75041Z",fill:"var(--ck-brand-metamask-05)",stroke:"var(--ck-brand-metamask-05)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M26.591 15.6122L21.4575 14.1104L23.0181 16.4564L20.6919 20.9716L23.7544 20.9323H28.3186L26.591 15.6122Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.5326 14.1104L5.39897 15.6122L3.69104 20.9323H8.24551L11.2982 20.9716L8.98168 16.4564L10.5326 14.1104Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M17.5018 16.7018L17.8258 11.0381L19.3177 7.00391H12.6921L14.1645 11.0381L14.5081 16.7018L14.6258 18.4883L14.6356 22.8856H17.3546L17.3742 18.4883L17.5018 16.7018Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"})]}),Coinbase=({background:et=!1,...o})=>jsxRuntimeExports.jsxs("svg",{...o,width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("circle",{cx:"10",cy:"10",r:"10",fill:"var(--ck-brand-coinbaseWallet)"}),et&&jsxRuntimeExports.jsx("rect",{rx:"27%",width:"20",height:"20",fill:"var(--ck-brand-coinbaseWallet)"}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.0001 17C13.8661 17 17.0001 13.866 17.0001 10C17.0001 6.13401 13.8661 3 10.0001 3C6.13413 3 3.00012 6.13401 3.00012 10C3.00012 13.866 6.13413 17 10.0001 17ZM8.25012 7.71429C7.95427 7.71429 7.71441 7.95414 7.71441 8.25V11.75C7.71441 12.0459 7.95427 12.2857 8.25012 12.2857H11.7501C12.046 12.2857 12.2858 12.0459 12.2858 11.75V8.25C12.2858 7.95414 12.046 7.71429 11.7501 7.71429H8.25012Z",fill:"white"})]}),Family=({...et})=>jsxRuntimeExports.jsx("svg",{...et,width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{backgroundSize:"100% 100%",backgroundImage:'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAABQGlDQ1BzUDNDAAB4nGNgYHyQk5xbzKLAwJCbV1IU5O6kEBEZpcD+iIGZQYSBk4GPQTYxubjAN9gthAEIihPLi5NLinIYUMC3awyMIPqybkZiXopc+xz3pvOzD4rlWyascy2VY8APuFJSi5OB9B8gVkkuKCphYGAEuoZBqbykAMR2AbJFkjMSU4DsCCBbpwjoQCC7BSSeDmHPALGTIOw1IHZRSJAzkH0AyFZIR2InIbFzc0qToW4AuZ4nNS80GEhzALEMQzFDAIMxgzMONWxgNc5AaMCgCAov9HAoTjM2gujicWJgYL33//9nVQYG9skMDH8n/P//e+H////8GBiYZzEwHBBB6G++z8Bgux/EQoh5AfkbzYHBtBUhpmHBwCDIxcBwoqIgsSgRLMQMxExpmQwMn5YzMPBGMjAIXwDqiQYAOQZcLsEClb4AAGmfSURBVHgB1b0J1G3HVR6497n3/98o6Q0anubBludJeAiTbYwd2gGC6UACBFZY7gVNB3CaJEB3VhbQhNW9OtDQkAYSIOkEGhJCGJrEBGzJkrEsT7Jky5JszXrSexqf3qw3/v891TXsvWvvferce/8nyabrvfPfc+rUqdq166u9d+06pwrP+/CHA3AI8RQRmqFxbyRliVdpcSQ9jj27IASwdAVHVxi7l65hcZAn6NlFdOOce4vCgB5Fc5iXdiN1abSFP1/2PrRoUtiYR/Oy9C9Tr7EwNVc4pwojTDFxC0CMI2nH8hwlhX4D5ZOvWwzy9cHlS8FlzhfwZNlyDN2pPlSXwT0VAtd7yTL8+SDuHOvCzzKdyOButIeuj6HfpTXtu8Ew3WD6NpjnALnFuI1IPB9GK0n5ZiCM9H4GyTJhLqAX1GHZMoJK70Etp0tK4nlhLqBfQF08CFnAgPrN8SHMz0N1YmjluYGwNKDnSeV5DEOnttHnpZ7fKBDyuWJWUHnKqWLUsgyaJ4WbjT2nDv56TCWL6gaw0vklrAv/vpD2mNcWrTpAI00+H9G0G5XWU/1gs8fBSCM1gMq/Y/d9BzD3WiqUpS4zQakyBkDQ6k7HQ5uZi4CgQepphJE66DiuC9PM57lcpsU1auA6Ul1Q1S399o6mF1qXFDq5NbyHqi7QoBmZ5wp8wdn+3G6o6qifRV0vQ3QtbxGwPUbT+RSXeEj/NiUyqQwP5BaIOw8Gl94HAwTKS0viXkk1fejeru02k2+jrNb1gE7d4GA7YwtEYYEtHyhN0HWh6/Q7AQV4bmidPwzDaF00rbpdGnHQqI+vh26LoPjNdQCi3XeAlL7zcaA6g5PYCDBqMup70xahvpK2DkMACmjVvc4904EFApL08dJgAAxVUX3OTEIlFcYYigooPi9fZ0nPtCj6fKPr+2MSD+fUARzNDBCJ0yBR9ZT6qjKC8jRImcxfvuf4b84pLXBdsG1bG94pLSL00i0taHpdP4rv6XnoOiut1aDSaCyYI3AV7aM29KAyc1QwNqSyZ5gHdEcM7kbyaAXfmOYg5vaF2MrQxCzFGFZ3Oj9dH98xPc263t0YQKAdPCA0CHxn1CDo+Z4ysSQvrovTPjkksHCdoLYDtOpCaY3AAZgvYBjABFShWdGfjs7VKcepugSiS3dK/6vt80HHUnVfalA4b2CHDROCG1uDmM87dd4Cgy5HiG1I2OB6uwEC9VhOhxosytZrSSAg2nU9dZ2wRT+MaB+mXwdtd7pD6qJA3ENtQCOxAYZ2d6M+Y3w2dQEL9rntQXXSAGOaO2f+zcACGZVwMRJZ5QtULxE+/OvKHAvTFhMs7bZx5XyOVNZg7kAxT0nkTkmNVNFunoRz6rZXKi4xxvR2YhoDm5ntJRxxroJhBMQtIHe+vj6e8muBTMwKJgFqg/eUV0/8aNWnWRfn/QBV/gDUrh2w0Un9PZMv063axEtfXxehn/JhgdNzHRoDQM2fWiU12Hb3OMyV0K3KeDAbadUA8AQsIDqVRqS1VndOOoCuWCBmIavgdE0MI/D2JCl61eAi7RSYWVWO1Rddp9QN7evQAnk5tJyRUgemknQ6rgMfyozyoNHqfTDo1PWAtkQWuhttxveB6lDqpWtQz7XG0HTqw8fNFF3mOWU+5eKcRNYSG6AN6qk2wNHZKWJPkgqQHstSFZxUpvOJZhTlNaHryQig828AwBFzoFQ0MQ8ziDOYMTGhJ6akhq+gnjGoYWjD8YBEQK0GFbrjAYyD2AAhd6KSFQNZQBCcOMDaTj1wfahjgjU5pB7U2B1UbcPqfCDJuC6qzYxWTPGR3xPTBqm9dD1R6gLAHdO2SSDaU6MJX/u+CA3XMWdES0edk6UzUr14nNDxs/QrfnPlANBSnmkKCsNTQ6gGk+r1A3uR47ykggrmibrWcRbQLOGGErEVqkRT6jjm2qtG5/MJAXwGwajApunhB0QODFrTtECd03VWwmk+1QqEobnBEjrTXkDOkjkBYUIgSHGmkyIaST/wCuCQnk4ETW2TBOSBSei1UkMDcJlFkBBPu0mhnwA6I3BO0nlMs574SrydoRt7Qe0A2VRRYDbjKIVRI6kpvpgcaJWjrkCnC8Wh50I3rkhhdT1RQJ5AZaIBNjZUdqOHDtSub2xEB+5YTpSQM2ApUk0PaA0wEF3Du/qBBcBE1Vnbn1wXAKtxuNzg6qCBrTtlp0FO5Zl0YMHMdeBfDUoteSe+ftxhVVov3TWPQNOv24bbIZ33SaOU81mU4h1pmBkdPEBE6rg6yLgIQAb1fvAbPF0UN5hY0b3GxI+AWYOXwTzRYCYglHN7TzPQgDoUM0QTUCUrSzEl4bCaGTOodhoDPEvr9Gwo5kp+tsOB71ZLpPpb6DYN7+qLyBpJaRwYDqiCrouugx8HxLqzNJ5BBbnutMYT4iUoCYNkBhWTCJrmoBU0heaJ/Or2BlUbMjWAgdww9aCAWOoQUnukMgjY8VgHEBM3g5qvCcAz6vxsZg0EkBIOmsfW5OCEKpGW2PMkM/fwdD51gJ4OAA71GfRmS2oAa9MOJxpIMkOpeJZiufGKqVFUNWSmiS2HKObKhJiuxw8AUMtnerDS5U2nOh6gdMD1YL5hFZYChfpbxwDa/scMBLYnRf1C6aCdgF55CAhMpmWx2vBm4Ad2LMNAnrTa1LW/RkVQvz0SqEmbzLDSOyOAI4E4CyqlTGYAYusz9tiG7uhX28/efQsNoFsJ7aTVIjNDwAkV2CsUxyCepgEIn9MzU8VII6mBTZxu0Mm4LxZgFk9HH9hOLoydEUNnGeCJjpAlQxo4zrB6C/TslkhodLYmWM1R60qgRjAdskq5CuiuYkB0pAZzoQVIqiHVAXPdZoE7axBg8AAraFDTL41ATVsyLRMPaAJz4k+HOJDURZr7+tiKsJZhM7AnwTIjzZN+14nvqdz19BsHjetprBH6iq0krWO8ES5OUouzAut7MQxs78qbagaAIV7hSR2+FwuDSBJPiTHTzsalgqY0us73FSgK07vCQG0OKsIDeQuyT0M1fC82clFjEwZ1aphQ8u9j3myKGFCr+gFJBRiRVtV0AiPhJtToDPTKJwvu5KGRupBUyx0T2EYO1VSCamumDjkDZUqxlA7VG1AHuEPtqr0YRiKHInSqhq0dtQ7WM+VO42DtlCylCdgzoT+QidFl4dLFmGw/0zQ3BvqNQM64i/HrDNqgXsrCOkcR9GA4uPc7FKiH73JQZtq3DNBQXQrMGsgGxJHQBOQVD/RScJVwWCUgWEEjhBYGBlHB1b5ij0Yqm+w1sTeBwIDk4bAN4AdTnZNqbFMycLWZNAUwEk1AQLDNT5PNL1PtSH+oSPbozUgDyYAqJliPfzU41sksYcnNklGm+509WQFNNjSoekDxykwRlLSm9KFAll18bIYBtbuRNsjjGDVucQIl//ZdHiCugRWWeZzUB4lc122OzMnqj0elVVEBHxRd1YbGxswSWneOPrRknjgJzQBeSQXEXlriC4jzgWAGi2xf8UBjU6zohaurcPnmzXDhpk2wfTrN6VJYiww4urYGz545HY8z8FQ8nl9fJ3VTGmad6ElgTnlP2FOAIICBUAEFaAFQzQ0w9r4e3IrXgyVYKEp4c6J902a4YssW2BXrcIGifT0mObJ2Fg6ePQvPpuP0aTg163MjBCqnF7o7GkwFMg0YLKTaMZCEZ5+8FUwMYgxBBniTGDPpap0Sz/PAkbr6aqR9T+T3ZYnvkfYdK6uwQoPztShNj6yvwcHI70OR/wfi71oocnKSNVDRmKklspuuLzRnV12H1L4I1P0K3mKesZoQLRAxwQCgvl0Itl49COKNIBLhBM5tJ+2Lbb+z9zUXScUgJRBHBqxgjVtByEcBeKxsVwBfGFmBsDsy7y07dsDrLjgfrti61fiijXoBG1Lc/pOn4LaDB+ELR4/CExHoE6h2bx6ksInCg8v0r3MAgDqZoDutsZs7HhBSJ8y9IsDO1RV4285d8MZI+1WRdmjQPhYeO3kSPnv4MNx97Dg8d/ZMAW/uOB3Z0oX2DBJkSVht7p5MFxYG0oaBtARWLcJ1wcD+4BA73Ap89a6d8NadO+G6bduk8y0KqaxHnj8Bdx45DPcePw6HI8iZ71nDTAqPOnLfFewEKLosZDv6LCIBtmfXjwCbQd0pHgplJJmDaT9Kt+MjHwk8KzaQ0NAYAPJvNicSgK1kLkeXpfCKiqu2NKu3ItleFpn4zgsvhOu3b4ctkwm8kHB6NovgOJLB/cCJE1k6BG50UDNxoQ5okMSz7rzae6HtzokAuaS7LoL37ZH2V5+3HbZON/w1mwlnorS668hR+EwE94PPP0/mRPWArIdgBl3F2xGMXz6HUA2PjqU0qAF3KGB/VaT5a3ftjkDeAdsi7QHOPSS+fz7Sfnuk/eHIdx6j5MkUoj0da3Tocx233vO9XsxGGUuE6n/n+vo3FLOpvDMCWrtl6mDASWMA671g4HYKzPE+S+gVksgrnQI0VKYmc+JvXroHXhGBPO06eDFDqmgCx588+SQ8dupUUUuIakDGDAABM1uKqEAsPmg2LWg0tCNKte+96kp4RQRFt6REWzakBrvv+PPwB/v3Z9Ok0A7i1eBJojqrCKJ1St1BNA2bUEDSOMTEF0VT4u9ccTm8MWrDTS8y35O34gtHj8EHn34q0r5WXHohmYAgIE6/ZxuA1qBOgF4nQK+HOljWM6UMaDZD+Bp33Xxz0CaHnhmc52NOYNbSeVWBd8VdywCQ7Ll3XXQRvOfii7JkaIWNSosxSCVb+2PPHYQ/fvIJksQo7wME9aAfQ0xATUJAsTETs1L811+4G755z55RbfJi0v6JSPtHDhwgW5VnRosZUj02QTSOJyKra3LzrcZn3x35/k2XXAI7VlfgpaT9yNnE9+ci7c/KmCWZSwLoBFqwYD4bO0MaNM76XtLMwIGaB8TpnREqS795mTvurltuCaJuQzBvvlW7y87wMWjT+aoyMzKQs6nRxQFGBfOUpNv2CIIkHb4q2msvBkOXZfDnjhyB33p0b2Za1j7Kfg5gvTnFi6EnWbJ+jwDu4G9dfjm8ddcu+HLSfmek/T/t2x8HjzOlaQqoxdMR9Dsiyk/bFzAngfM9V14B74yA/nLRnvL89KFD8B8j7Wtk+qUB4zowgIskzucB5HyNJHO6z+aKMT+CMrNC48MHA2iwgz8D6K4TG9hIZgEzCLg3sX0NNOqMBe6Oqu6HrrsWLo+j/40GPSgcY+BY4LTPxFH5P7/vfng+AmNKkpols6TDAuKJPFsAcX40MX7k5S+Di6IHwOcbXkKaOSTT41cfeih6SNbFF6xfudQ0VDdnAcN5UYj841dcD5cpvnvazoXmscGuj9sXTb5/8eBDcCJ1yA5zR0yS+GwC9qzPQD4DUCV1qCA+21vTQ3zxLVDT0XkwyygZ3bsWQC4eBOuLJjuT/bJTSsv2cpIS26YT+B8jIOaBOcw5ACzzwxLpfdqLIxj/yateCTsjLezDLrOWoUz6xCN1wNUcTxM+8cGdEcwfePnLDZiXpWEjNM9Lm9x/P3jttdF2n+aIRHv2HvFv5j/Vg/hfbP0p/Nj1L4dLI99btL0QmmHJuOS+/PFXviK6AKcZC0lIVCFZvDlm4goAzNt/+gDCKGITsymY2Vk5x6HbLoOYZv8Q0cyUsSuLz6eB3paKPWwaH/yxCIjdDhAA4yB8oWEsz+TT/tFIy7YotbJ/FoqfXA9icx1K14etUdP8wHXXRdpXR8v5ctCdQgLlD0RQbyVbMQsNHnhD0pQdTV4V03FTbKvUEa9wbkRd1osdxvJMwuSHIh+3RH5mUCczKJDQwzp/IJNYIRiBarCovEwcPE6rVG4k4BlCfmlHu4D8Sy/sh8xqi1Tf9111VXTUb5HWCvqAL++RQmrg74r2JKT3B/o+D/hEYkDxj2fAxOM7or1/6ZbN0lhfrqMfof2yrVvgu6++Kr8TAQQMkWpQ/L1pliIB5TuvuCLWdcuXnfYW3SlcRXzPcQqU5lVWsO/PdAp7nZPMgxluCnV4pG1JgIGETrf1K5R62rcQRUzNPE1+xB7ee8nF0c+5SzLVFQwNTmuwvxghjFy/OQ7s3hcHeOkLizRb1ZG0Tu8cYF80y7suvhjeSIPXVj4vEomjYYz2115wAXxDpC3RWKamifaYgGl/T/RkfG30j4/l81LS7vPX52+LfH9XpCthIwuTAFkay3Q8VN8/v5ZbDmhaDC1wdwMgq0FhzdD2EHnHFqDOygHbL2UgtXtlJYOCy9Ijz6B+5RysGmkBeyMNEUae4eu3RffbxXGKOvFWXm/MXoEeLki077lk8Py5gOFcaB4rj8+/Mfrvz4/2cT8rHbC8OlDAvCvOuL7z4osG+W2E9hdCcyten39LpP3S1U3lDUEynXhsVj+WAPNujFgIjEXKK3umDCaR3zdBaAE7hQ6UkR7Um1dQ3+LStk5ShcmX+LejykvA4AoxOMNYhdGCXqQ6Abtn6Q3LHbAgPvnA33fl5TCLo+9AhfDvt0Xa03sNPh9Ysuxl6Fg2bav8RNu3RA2TrvI3lUR3mtj45ssugy1q5u/FouNc+Qzu/LyIif82mnKJ1uyfCEraOiBrSZzGb4IxJZH1dQG2KlQjXq7pqvYO/Uph8QTwb5J2aaYnzf69Kc5E+RoGOg/+gJGggM00eft7meAZy9evjur7+jjb10dQJ2CvR4l37bbtMf78QVqfz5crjJX/hl074cpol84izcl0Sr9Xb9sGN+zeJWm/krTPK+/1ke/plYdEM7/fzC9KCZC1V0OeVBIZrEbnIINCbTvbN++GtrQBNhFUZqSi37CfwTuiAz+5YzJTcQnGkgTmY9DjvfSmZzY6uHRF5uPN0aY7G8GcfaKR9q+O6ppnE33ar/QB7vyrI5+TPbq2Pst1+Np43QLyV5pWH59ej/jr0aRLUrr40QO9C88vMhG20L71yVhMQeNUBzOZrxN7/Egvol+2oXMhGVTllcH0rsCbd9XB1DKAA1eWGRx6JKrE6MySdm+hNCPlJkm3ParB9HLQjmjbXRslNkC7cb5SoQWQFF5NLxYl2tNk1us03+ErS/uA38Eerzv/fNgZ+Z60S5bSYSg8BWuUZwuT4OI6j3C9iqjpHfyk8QNW8Zu+8k3S+YZoamzuJpaZDqCtwd4ouAFGvR+BEjMjFqVtSY80A/raHTvh9NpaNjW2OvtT/4LLw9/zYUEfW5i2Va4+ki39mgt2RNrX4U27d2fJt0g6Amyc5jAvrQYqzOlMzgmQbOmviTRnKd0HSay/jClvWllvhuDVu+1kzDdyQ//1lCGpB21upJ6WiHt7GmEzfaqiwgBo91h9T38q5cOoaYJDcoNKp6vg6bkhejwSU18f7U//OuY8UMwDzyIwLpMWRtLo+K+6KJlM6/CGSPsi8J4rzfk6WN7XT9nASqAlAueb3HjrNAaQdesIECZbusWYRBwvrJgcPBhEhwh1qW1oLUoLcPpsbqR3Oa7Zus2+orlMMOIYqKcOogwdfHPgs2ZzREVpid2i6Yrt2+DKaGpcFgcqPixdh69QuChO/FwaeZ7q4MMLpd0IHGXmedNg9Hn368PLIs83T8qSDcnlmIM1ksupLgRdMu2hQ2wsY8CJWnlnFcCfvDCxxXZOg5Mr4/RsNufnSEU5H6slMasPrmyowPb0ttKaHsGnrYehfLz7/a98BWyaTJqS8K9K8OSn8+Si++HXvUZo1/LmnGhXHb8lCJfOM7QvjQ0cC0gfdtx19BgNxIORXg0cm3P5rhBqvQfvcmAjgzCH2rKEVcgumEs2bR6kNwM2fQ5O/XFd+grQfA9hYBer7IRWbUMbApwo8WYIh0u3DT+d+qsEZg7ebEjh4q1bBvc3Srsx/RAA8RyedXlou9nPMbBQ27N5c563KFI6qDqotwiDbetyUgnUpE45A6uiw8iKlvy5ePksP3+wG4BeVezzSygepIqmltC00tql5xNDiQNry+LQeQ7UFXeKAYeGQUu8ZVTruaSFBenH6FgE2IV0NDr9WN4BRm4w/9Hauj5/LZUlPQmqHXFwuN6XGc8cJ5KvpA668jqP0OZANTmCRwC6HqJBXpbVKgPR4ktMZsfO6LIbY0aABpBhhOkuk7JiZTud1BXbWTSqpeq0iJBmXxsN55J2o+mXSQtz0hqgIcylKbQyGbFpwlhGMJBBtU2gzNjmla7y6wdxcIjsqXEfwQawcxojKqR+A4X606QqDyxYaPlXypzX880zVfHgT96NdG5wtRJllmVogkrw5/Ix74gEIddKEyXWQqg2dtBV9OmXCBtI+pKl3UhoDZxxUVqvQkbas4X3VnwrTQrJbzyjl9nSnbqVSC2B1zSEUZpraVO9ZpgRYnrWAvVqOQRqqMtQycIuDTUwhmvd+42QNBfjjGlpHNTPeomsymxJa/ldwgTxfWHs2WUat5UNwNDEOJfgeYwNXrQGS0IDQ2OJCmi54mmw5myNSD/5S3bCDkthvY43Y80WhgYAemZX1uXwRJjtD/ggiSrrytFUJS9Ntdb3g3zsicqfajSo7AgnWjakUV9OOiMo6Y3OjgtOKyiEaknuA7rGsDcd6apcHwZAddoE5jy7LMq9jdx8BNtpuYFawqiBfwFmq6eH8WLzvfTuD+Mnf4zc1wWBAjWG4C/Ubwh9EEB7kMivNkEALLAlU6xfIMfrQ2fOwrygwWKkMcVBsCCE0KDNSxmVN5Fd74V2A+j7Uvw825oBho1ygorXtGObJtN/VL76PuCweB1QlTsgtQHkwQCYCup7MJqMXzBbpKX0SQAYdGauc3BpMAyzPr6+Jt9FzqROdUGg1rs9GZshGHwyn6ZjBGu+lAWoSwHF7KjL2aaIQIXuP3lCAGEc8uAq54HrCmaws1aQ4FoX1X2fDUtIkZbqIS2dg6s8qvOA7lmwwJdrBa65aVs0jKQfpNW9YSRt0M+4zqo7aRPgUPntaWNBpNtM918tBExnVcW0tG+i8eDpM/myeMxC9p7NNNbQdSLXiX2Y2loHVwt+URTM7J9soQCgtkwL8PCxYzZ3lrrQICLYiqP8aUgc5rCTKMF3UXAA1M/qcnF4v2VqoEqLwdanNXtViXb5jkk8Fy9pcTytpFEAb3ouNPhCOy8BH47w3AHID/SDa191a3BtOmX9gX0nnidMlQ8VeACY41AJR6jxY9u7pTynLL7NGryZWDRiP73SVwqoawLnRbiB4xAeTUtYETe0lOW6hFYtVY8HJ0m1JNeSkxvJ8XyYt6LBgEpJHANULdl0owebdlAejv9ii8hGPSUtzEkHVnJL3Rp5SRZhPEsxl9x90xah/SxHDPgPDUHUCEWDB7jr0GGpOO/XUsZpYCS0frfHrO+dC6x77ph3OXSFmkcI5uWU+hJRaeWT6zP40tGjlWBVcZM5MyOoHti6Vs9YOmqcgF3HaSkL4xJSD/JETTcaEjXQwdWlBdRBy4/ELUqLjfLcuQGzT9voOIYVaNvItEGjOAN0V2xwYNHtxGj05Dx8/Hgcd52Bmiw4XLmX0EKbxRrYHYQxTquKgj3MwuEApJbLikS3PP1UW2L6YlABERxjW+USsz1t6PI22l9JNX101H99fOvFG7nm3wD23V2+9s/jgrRjecNIOWP0wkjeisd8H4iPqPjX7Bz+NrWFFgAtkOnnTMBKiw4f3L+/rBFNpq3BWAB5+V+RaPvpYGYo1Hc5Br0xhCaIZcX5YFe+LEtsdfCnjz1e1mv2EgOlzLoCaF/j+De4Hu4ldx+cNACwkhpUgxIgOK2Ol3vQAAo4oIzdw0baMPIcNs7DAqAvQ4dLq4OPF0VsUNEGS4ARgOs2ChbUrUOeDWDGYQkjH3v6aUCqgDYtZgrIjDcWnB6bPgxXS5TBoAO3KhChuurqCv8F1M+cOg23PPkUfOtVV7KWg3pSOaMlMmgm4zDeMFeBeHRgFm8eiAPUX/uvN8Itd98Ljzz9bHmJnAYdQHUCfW5Y0GKVC75OX4GAjgGI6pdGl3yetNLVl1wE3/yWr4L3//V3wJ6dO5qg5mphcKBs1FU/Y9pUxfPGR3oskU4/8sST0YlwHLZu2SQTI7LhKNTtLVodRM65/VT81NOq24l3nLITLOU9Dl54G4mxefPytIfKpIM/2/84vPuyS2HTpLG6KDa4xyBtiASHU0D9S8/pdk2ndzyyF3783/4ePPzMgbL1wuoq1YfBqlbsDB7AwXSa5cKLhWzceCqsMSztUF3n866k2H/4KPzGh2+Gm+66B37m7/4teMdrXmUpZyk6B+iDENrxnkYvqz74+OMZK2kfFiD8yC6yAAN7uXo6lM0DNk0Kxm3H6omEtAUwsi8aRUqXtdgrqvKn5t0EbjvwLHzi2WfhGy+9rPoudal8GhYzh/2ixdNimSRpCPgp7dNHjsBP/s5/gMfi6HnTls3QTTrgr9eFKUEDur3Y4cbDQMYtkR4b58uHgmVU1ygS0KwBR+Ixz8LF2ZS9Bw/Bz/z7P4Y/+MkPwIXnn2coCiOdOYTlu62ZA9BgJto+9tRTcMfBg9CtTq0NjTwwrGt56y9jqmljcaf5YTYNkiZBNhXQVLIAuSxAy4tts0rJ2wuThJ5EUP/SPXfDDbt25w9PTd6qsAANldaQ0uLvbIlrVaf08zt/eVtssCOwGsE8XZlGQE/iDVkCR9nwQWyxcnPcLvurGgyUFS9kKwoAMMsApO/30nINa2uwL0rrf/Whm+Gn/vb7hnVWPAdoyqMBDUGZE14ia1v+udOn4dfv/SL0Xfr6e5K1esDi/O1J89e9cJwLD6qQLQJMVZqk8HSebPAyJEAFcJbUNKuTpTP9TiKAJtMJPB5nDX/v4YfgR1/zWjOy1p0GWtKAJQHdN+mGnXLA2Q994V6YblqBlc2bIh0rmR7eT4VHzWIfkqQmWQ3a1Pr/Q/DbaeQ4GvnJFhRpu7wcn+od22wWB+y5k5+FW+970OQnPGAB4u61QmgkYsmsaWP6/t9H98IXo2t38+bV3DbscgoaxIRP3oexVtjZlp4W0CaH2BlhUEGZfqSK9iSlda8pNkiXiVxJ77hGSfDvHnwQrty2Hb7tqqsNogNn7mgzQlqBGHUicNJApU/k7z9yDFY2rWa7eZpWbsoSgF5L5IKdk1zAremDNsMcKXNDeInSChFOl5PlXPmFtF5cR1I7DeLTNlhpQ6J4/vjhozUrJYb1Ng/6RGNA32e6/edP3u34l3Eg+Cv33AMrqyswjeOrpM2hKwLH+J8DezawmhoIRuhUPljMmlFbq8FEMoeqzvI0JZQtEpAkXsZzUh1RVCdCp2m9iPUz8M/uvANu2L0brti2XTJHpdKQKiGMUi1rOr+Xzq4XiPaJHapLpkZaS3lazA1WU9zri7M+iATQqkyX5XnDHaf1vgNAm4e1OkPI6mLQp9WFjKBd6hwqoHl5NqzGdH5c9u7uijadRFCtr88smMGaFyw4vAbVNDNtehZVDgXmJ54/AT/56U+RwEuAnkRaJlmjyN7lAOKA6D0tMAR0K24KDZ7lc2r0uksnmvqwlObBGm+VkBmWiY5Xqz2cOXMWvufmm+DfvvNdcP35F9AmkZYo6fTEiWDfQm2/3O2AzDSD9Ppim+XdmEKdgSrbKBd7LZUle3SEYkblvLyNpKSSLns0YCsNbjytL9NlgQElNQOnjHOwbBQPdQHxkjDfibwJNOZB40vWRQlQwljZNVp2/3XWAS/X9cSJk/C9N90EZ2K61diRVnhsk9sIaG9G/R50FTS8G5h8Fui0g6Y5hc7c1IMk0lu5PtTVOHPvpzbraEQik6E/nRbTI1XgWLTb/v7Hb4UHjx6pPVcfjpONCaAB4b5Ckm9Z4zcDOm+yQwxjpuV9s9PCuVi2HS4b8WBNg/W8z3sFduZ+jW/FdYP82mnxHNI6OmIdNK25LnIfch3T/bQ7a+nENW1S8XkgNumsKefaQeJY7atGD475DH7pXJTggcOH4e/d9JG8WedqBHI6knTuJp3gSBcZNB3KzNCf/8EgroYpqFGwF0b1RR0U/SNTkYhkhvB+00XChdz5yzYDsBIonwDPnj0N33fLzfBPb/gq+JtXX2PVujNDRFqHBoCVamtpZt2oxT/Oe/uhbFzJEkBLAlMO+g7TkK7YkKI6rWHkBtKCq5BPjzpLvbBmbT9eLVb+kOTgvbtzW3WlA4ArqmVe6JccXbOZKqA7v3HfPvi5z34Wjsfx1OYo2FbjuCZJ5zJQ74rggerVYJdw0fb1qyiRcoxB3wkVhqfMS6cxABrXtQdVYHPv7aUiJbfiwpvStG5B5um1s/Czd3wWnj55Er7r5dfDedGW0iZIAMs548NWNKBOr86RmUEHsIQOxcyozvsuL2ySpTiZF1rFNqXPWMAN3NtI2kacviQuS4fmMb0AHRU/gDs6zR1QR2cV7sHMJsigo3s6sJobYi/H4+jZM/DnceLkf7/jzuzx2kxATho7gVkPTGWvcuqsUi7jF2AgtT1PNG3NhWYM0whY+VyjP5SlDMoItPai6oHA7P7tphORGskaOLO2Dr9y793wx48+Aj/+hhvgXXmd48qcAahYuIVKQ3A0GymtGhDZrMh7pPO0Kt3vOqG9NCC9P0CACE1mgJK6MB40gWGDaeflrdIiEYNQec03i2sVqRN38tyMUicu9L6OVDc2LTy4USdDa1boLD7zzDPwC5+7Ex46djSCeKVI5vg7mRavBsrYpjzBZoN0Iqz1GJC3iJfQeJdDp8fGRVCMqB8nltlEFv/lHY+ySHXeeWVSV2fn7eGeOnUK/sFtH4M3X3gRfHeU1u+4LC0yPjHdrSWB5VqBWDc0qywg27MyivbHBm1ysJkSiO7CgaDz9CDrGvdAXaOLgzlpfZqxMJJ3BXX1bBThwa634oPONjPUmThklU6SmkVgUHQEHQfz+1paV+NjTz4Bf/rww3BrnAVcjUJsS5TKCcjpSJIZp8WrUex3EiAde6CoDEQZ2LIlUDRkQ8DAkK0pND/B4i/BRb2PqMNSKGWJaGbeOJ8M7OzIR7OBZ1p+ay322LsOH4Q7Pvks7Nq0Cb7lqmuixL4Krt+xE7bweyCKaiEFhxI7aNpp8ANYJDX7oYsqq1+r16lV8lMj2spR+lbdze+8+EVpF8VBlYrlHBWJhSPsnWHPQpXQJR3PFmY3a+Jbj9U+cNXrnYT2gQVJAvEjcYLkxsf2ws37H4f90S2XgLs1zgGsxl82MVaS63SiwUzg7IY7+labWZXnGTF2j8LiHde70rih2TDV7uGepCdoGHCFoR1lR5t2pj3Bk786VnatW4Nj62vwOw98CX73/i/Ba3buhn90w1vgDbsvqiNrxUwPbFR08UieX/EKaNcRoW+L6QWroDoGCkAss+iLHlAdRvcwGArPSh89q0yKuWkBqixqgUp5BWyfIdrJHu0oF9GgCNVTRav29B2aF314QoNp4l8Wavprnk8+9QT89r33wL0HD8GZfj0DN5sWUwZx8WQkTxeqyZMwUDGoOiWohgzDSoYhL8zkBJ2bdzncyGIYjLejlCIOfCWpAar3gPPN7xbQQjRp0iNJ6TWoWy3vXtkEb9+zB959xVVw+bbzYOvU7ketgc2VNUKVkYEgHpcisrC6nGQQRINazZScB6qBUjD15iv28zINoOJ1lNYYAezNABbYtmrtvJstQhJX92jdgUHbp2xeUHygjh+g0q5DaERw3F+79DJ444UXw31Ru378ySfh9gPPwoEzp2ETSeTslovnub3JfVqkcjUltMYx5xCknaB5rhpd45TOp55BzaCYY0ZlWlwEqC48oJdlggKNPE47amUvCMCrdu2CvxHt57dGBq120/rJTbDMNLadizNMR6RBBw9AFHjp+WK/seYJkl0gaVwYr9A3KKZVeDv5RtLOS18lGLi6IzC1JZq0ZrruCuDZwigdPNW9LLnVXGc5VPzojqabPGmArdE2fsvFe+Ctl+yBY2tn4IuHDsGH9u+HLx47UvaLx/IFk3QiZRoZ/57vwFxRb+uKhaBxOORgc1CIMGSp//5uUJBIarAtpVpCppbjvws3b4YfuO56+Gu7L8r3+c0q8I/6iwaILT1l4oBGSQPnuwGG0Kt8mxnwCAohoKU1UqfR/dkIEh8C2nuhLRPqPTRpAXU60g3iuAikPVhSS2yFeadJwWreZN50ltRgAayBDfqaeMUvqp2/ugm+bs+l8DUR3HceOgD/5oEH4bkIcp223XnRMQGbKVuxHmqcxvih7RMoX4KjtAC9DxCKqYE4LE5G3iqa7dfEsbQo33dffS18xxVX5+18jUTW57XWVkUH27HBVaA0ElKjkfM+qA7lXtDGvN1mLSuHLpjy0XGnIdeqUBkJvt04Lc5J65WgScPI5tC18iquVQSe8QVaSCYR0NkJCmJN0/8cwChvXo+QvSkyEI0Rb4ua9g07d8EfRz/0H+57nFZUqsANHQg2mnWngpDOMVRXKig8tviSzo0fuiWZwT3APbxcl0LQi3+XSa5U/HNe9Fz85KtfBW+Jg76UfBbA+D39wSG430ERWrqWjRXJBYRgjewuI0kkMNh69I1M2xgdioA5WG4+Pf+uLdvWm7UcKhMABCXycr1ko1qVToPSXgbAI4JEYYmAVuLLuiwwCJtjO3/ftdfB1du3wa8/9CAcm/W84WWdETb2L/+xqo5BDXpQDvP5JyYHKoNbZ8T3cCQbrBlAVYzCk/IhQBxa74l+yZ97zevg2q3bq2sogJHQ5hdqJtzJW0HUpLRbJ35osaeNnletzVIJQEkr1zkVHca8Gr0HTg8uEN1G1CxoLq4o6t+guF7Kqnv1odDGg+L8YlJP2qthjgXNE1ASWl3Ly0hhKGR6dfH2iy6BK7Zug5+OHpEDZ8/mWWQ2c7Rg5NP0spVwQN8DaJsc4kWisQ+03HZa2rLNxSYGQEOKq/cJlE0UmNXx2Uuib/J/ffUb4OqtWwXM/QiY5V3cMGS0x1MLQ0H21sU8wma3ox4to3JXFcb1ogvZzRbAlaFB6wE8L8zrjc30uDBv3dSIxUmHZD4hMUrkS1fbMGutbC90xQ5HrPxXgsT4oYPjf2WjlMPP8cJDoO6njUx//g1vhH941+fhUHTN5o29lamErYqhh7Adh4jJYdxc5bmpj5BfY0JY6YagdpNlVQcsjOoL88npeX5k3v/5ujfl7SqCA7Ps5qWYKcwYntbrUM+Hn2WhSCdWbahsONMiHM8vOoogx0Wy8q9EQP4rAGBxE2rHEMFdUvNsXK5zN7/niI8elHRW9yQdHR1Ld/plMi7dvAV+IYL6A5//HDyfHOFsCmqLAEBwlalDmnFW5UubaPeyEr4pzH2XgxM2l8BqPUeABQJzGgD+WJzW3hPB3Dsga6kMYNWbzm8ecaH1y7NRWkJDxbKWLEkqB6xAyA6+vkqA+XyBNuJH9eNI/EbyCPayaht1M3tVwlDFSGU64g00KyhtElyxaCV15k8Q2ZGD2NRKg/KA8cotW+GHr3sZ/MJDD2QTlN/HblW9OFpxXvVH443JYfdVrg/o32GoAxEkRCbpnDYRev+VV8G74qh3RvyVjx6DVW0M5EWgboGMn5FBEBKQlaRm+rVG4YmXOmaszn+v4kYDLhGvicZzzMPFockbQcxBJYmLAGqMfZBMDuyabjvdETS4fZPoTkpkiCFhNn2C2jbfFN16Xzp+DP746afyhBroBQO5h5hCQMZvdWIsGHb4ybHpUjzGsXviECKi6POmWRkEfssll8rdwYaNAYy7bOA6WzJ47PCAkO3o8oEsyzOa9JFrkPNiawcY2GV/BUMFNO+HbU3A6glRTwhgqKPzx6lKW0q2MJwTGITgzBBqQ7HulPmhxeh/d821cMtzB+Bw3xfes7YIunbBncHgeuzeYFs3YRS0TArbOwYVTPZzP4vM6OEfvex62B0d7t7UGAAbykyWH1mbQzEPYHhuAzUUSSFtS/M1H2VNiI4kujs6d+jnx9K37p1zWlycdkA/A6Q8i4Zm7uz10zTWUF4ocOgd7+e1j1l2IKhz/RuP7ZMV+J+vfxX0eQfZWRlrkVoWM4qaUVNWh3fYanH5nXrjXJ4USVWnseug0Kk9ILdJktDRvnjz+RfAW3fstBUMbXNDshgisxmkh/ruyT/80g37rrCtU8oFWXjKLBHN5gtONh+oPj3kay2LPAtBO283nFY3Zn15B3X7gDSRekYzQ8kxPRWKlS8esADtpgijF8N0rOwkwvHzzXHi5TXbt8M9J54v73uI6w0sr5qmQgAzsYI4tKFReTcqb9BkI7OFRtgr1RbKyjzrsxm8N/ofJzQL6D9Pp6SGgWBya7d/UCUX26kt1QXELK2okYMbrVRgFy8I22KoO3cj4AbMkRczLbbSq9E+irnU0W8gs4C4xun5fWQ2O8AKFD43g/URAHuQ61WuUnHyNT/3XSjaOEpR+PZLL4e77v9iERSqg5VHEDS6ZfYwODMDcWCC1IkVIcy95Ic1XoM5AMggsDCgz+bGZdF2/oY4EBQprA5tZoxJZ31vDNj6XkuSAgNUg5pEmbz8wxKM/LPS4AttaNUxXtKgy7Fl6rZiQAfVGUVrsqKiNmKbuZoxEzCZqnWcA6g5AU0WtinlW/4LfcEB1inzBOqv3r0bLlxZhYNRAOYPQeT9GX7jztY7SAGqrEZbdbBsUGq5UkvgTqYGSee377oQtqaPIIP+LB2Mm24emD0zlr2WjpDaU+xFqIMOusZO2dHs1tMLRstX41jvdapzmOdHDnTn89Jj49rRhnw+llbFo7qHavwQlLEs0hnB2MEBqubTkhX8NcC4hg1Drcn5azxcsLIC3xy9HrM05upDNbnE1aILC0uLkMUv+EOVxmikcwDRDInYtHliNPT/mz17bCXCEMQtZkAjDnWcEqymyugliGtoMTPUr5zSm2qctndpPTGtc4ChzD7XtO5ap0V3L5/yC0n0joShHVUm5rrUtX7eVJONfZQMYSg8WjS2Qu8S6OWY33HRRfBvHtsLOOlLpx18V1d/gzIFw5zy7KZBriba3PDACvKbattnQG+NRL32vAvs5Ik2ORxj5klnVRTRB1Vz+oQaBB3NGKRGS+9Dd0oJyeCKPkmCMnUcnA0HG7B9XfHzQ9hY1rggr/rKXnnpCrlRsIKgY3OEHhETjNfm8HlqQamiF5LiyAoj0lyPn14dsXJB1ObHI3Y6Ze4FJbwG5bNpOBKmJoE/x0Ym6CrN3o1I1FVxNihIPAzUmSbOMyHYrEcFjA4BGpJf1KlSxYoZuQzj1cAqybsRCb1IDPm0sGR6nXaZMlxDy/MdGmbkAS91Ho378kxXPUHs6XBFDMqcd3+cTPMrOLCkwuuiR+y2o4dpJ1l6E3IseHzqXwplYqUlnRq1rMCriM5xaZnWKH6v2LRlkFayCENmhJFffW56Png6hs9l6sh2lKqoypeGxkGvL14P+hpPNXTpAG06TJpavPyMpZVztGXk5yhikNbRUYuiiSKPA9brA8mgvt6RASSozgADb9QYqNHdGhM62toRgUeRaUq8P3woC0R24dVdrtCqaHFV4qBcvh68D+0TDRpGIbMuHl4k9OVbNksluIB+RDpr4C8bWkJs8LwaELHZUdIRc9jNhUoasBpOL3KEKqnH+AKN61Zj4pxrXPD8vLRyHqrJkZtYOX+T1yC9KoryDVa5F7ind50BO7fJAMwAoxLcn7faJwV245mBJ52nwWGfPWRBFv0Z9GgYCscxwSFbUjCDEGqeY8xmKc1M6DMxPVyc3qijAoNmDljmhEa+LWAjjEvqUQZifTFJv/OLyn6uJgY/UtaHkI/vEIcEtK49sQDj4mtR5TaSFlx6+hAY5X4BhJga7JqmRkWZfOqaoIQl4lokzrsXGkcK50+nWRim9+YnQZfB4MGBK9CU5ezp5tt23r2XgRPql9wazGn5liyho4djhQcZyPdcviPXY20ZYAhkfz54hiUzYm04ig+6p2p9T/H5o1pwlQdoistip4Zx0Zry7lRaiVwi30Vp+TrU2V3UqMlx/N5KAQfS8g252syjFhe57VqdGRptRTxsC5eaxC+DwaRO0xp7PUvoOEwPk6pNQGEPsfqdEcwYQYfhV9+ukUKw0XI7aNWhP3+d36vDkBeD66YEp5tjQK51ACijfiA7ml1UoZohQNKqq2BnCnLDIwgUhm6JWgM0XgJHNbq0tefAIh1l0/K9IR0y1ymDXPvqKPtyzFOsobImAwGjBnGohGgrpkFpO4L6mrkGbW6ox4omD7Q8c5AbgiHU7WMLEY0bKgF2j5VQGhCDpdB/5lIWlOmFKHaMn+2HKzxocI+B2l+3znXP9irMlJdmvzITOkA9oWDcc7TgjEiNrvCFyK+DDt0qWHsVYKPkF5LW10yn82AucXnhHiGYOhaPAVDlxy8pM3o6GnSxJ4iYyLf1uzatxWf8uadUSg42Xg8INajX88tsALw9CHIOiA47wfGMsBhq2hRGJlawimNNpDpnYiszAhw4c8YkEGKCajMVWsxyVLTvIaiJhMqknBetDT1w2ynJVDJQkhTppKP3GNEDiIjttN5EW1EESxB1pJKKJXkD2NyKUmZXy0NVvhaX4r7p1HVQC3CoorraYbIZxhMrPDBcFEYb4dyCl7VHzq4De8sEzgFk3ZQCZWw8PcRoCnZQOC8IKIPKS1aLzoBK65uNVUKDG7AthwZFamwFlxiH9Jm2V9PdbC+iXo6KXXUpiQyqUibO5FDpLSEAyki2BIrbTzcTQlMkqLSoOWI6VWjGiVyiupTlFwIYkwP7KsgJ1IHfhR5r9OB+/fmisKDNdLGHzpxWu1yR10xWuwrVtSht28hEheZOsnriodanfjdYrtU9Sv+lo0dMVnodZzHtGrgQ6a3vIQw6pCETxqQ3DwRbElmBAt15Dp27bnFtDAXYiBnrdSNpTc92PdSnTzT2TmLnx6r6KnzH+h2UpMX6bjQzUh1sGnAeVZiBUVgGqBqwpDElmvujA3U69j7/PN1U5QGBG5mkOsAFw6Kg+Ffip/OaDsTBbXnt6CfN2MGjJ07YfCihMRPVvSwV6X6v2xOHNAVdOLTpzUlY+nTki+bGk7fu6Gl97Xs9joEWYOAC8gTMedTcHEsrrYbDDu4DWwyo0BBoYRleST4zF0zd9Bp3TSqDJUeK16BDm2asKuZAe53CHYcO5gUdDVhHtLjGoKePabSbBhGAsfGQDhrg+suHE7N1uOfIEXj1BTtECxtCAYxTnEEN/p76Ne6eMKTDS+rgpHIYvHlGQ/tOZcrJ6btCSUu3tAsLtaoOtaEZ52bGT2hScWj7hC5Hp9Vli6Zr8AD1M4VAZegkBvblDbwAMksK4qeHJhINPz24AgxNFVS0oQK/l3ooJObzew4fhsNnz8KmrZuBNWt5rBpgGi8BxgMX01x9NP/wZwdYkwfu/RDcrCpmoKRnbnrqCXgNAZrHKkiNItovDCnBFsGacfNqY55RElmtcWdEBADZ01Dqgwi23+iPZw0LJI3vqeKCd5qESGqmnZt3GD47SKsBBLXs/NupXsCjcn43lDulAnrvf0EJiwDW5Ajgx2IVzKF2QvMsBzXs+C/7HiNw86KanJXqlNJulqGhD4M4lX2lqV7YIU2NDiY9q3mkrZH/095H4ejaWT0e81ga/Dqa7L0W4+YF5eEQWxoa3+Pxd/z6+73WN4PdyDH2zaD/1m/ed4MbyXtuWqx1oLoGXy64Dx8kfn4QLUhAbbE/KNCKpFYdUoSbki0n19fhpiefzPtKopiHXusODYzABSr6NHC6eRXRBXCGrDL11g98JFto/+mTcOszT1WhCCPA5huuUF7rwRhG0Eg7Qi9wBVlKo3rfOfub6yc/SGDgOJQ0uLGjewFxG8nTHVy3vGKS1EXFq06Kgii0nX6kzduMBSudhwJSNLKAVwnS3K2IhA8/sR/2nnietmmuryWIpA6s+RXQCUDBla1De0sKHYEAowYl1M+XMO9PWDYj/92HH4L3XnZlZig6LonPODgGhhEilJrT9yWJZm4AA+QUiV1tSLZ/6/d7WnzoOo/3ngF/5oSXKq0OIhz0tWJa8YagVHXoARqRumCBGwKMaktUJWozE8DKFv54KE1x/+lje8uGUoQdmfhqcMJYCsr90vrca6nN6wcdklWPTCWhmB2JyNsPHoBPH3g2rxfM9rNIaEUTzFFVnhCDaWyrQjZ/RGNojsoBYNUE1MkHwTlaOhSfscUwn5ZPfdpRhqq0rV+X1uSlz/vWbWI+zRnJjc4C2vCzYqZkyd8aNuqi95fMbFM0yJyWO2575hm47dmnodu8iSQ0vaNNhRQPFZg6t+RaK4jJYfg1gvD6fmopzXx7lmzo1OOmUwiTKfzE7Z+EE2trw3EZDPHVbDgP7jGafLwTCbwCaVZVtF5FGIC8cZAnwHzLR6bAeNpuGN+65vRj9xalbeVtxGCNs68AKPOLhJBrYBh0QNUuGGyctB3/hNq+HbTJOnDqJPzs7Z/JGOmmK1kAajpaUleEk2nnNiQkK1NhegI9UMBKSRRgM4PSlrfRcbIyhSdOn4JfufcusZs6B2JU+TAjhIeoDo4Plr/eQtGVr7OBZD8SEbxoIxoQdEbtobI/669dtEXHDY+WPe7Tdy9aWvYu1WsHXKyTKKCAzfaoB4n8jhyadYM4Hr9ilQUTdaTrP3r0Edh76gR0ar9v+QwuI0pnVvFl5R2aejJm01/jtsMBeOuLSkGii+7S343l4vKHmph73GQ2hX5lFX4v2tJvu/ASeM/lVxq1xhNXKBnTj1J180JL60s+Ipn1OtGd6kUMZLAMFB2KhgeguFPobaQdBGKw7f0ATZni00JFy2ASpzZcHXgQHUGLTRDzA5VNwO7VIDbrkNdGcKibTQsoVHKR6sCSmf1I+vjQY4/Br3/x3gjm1bKpUPZwdCJsRKhKmSisq6apIxrrgBLAezkaDVSXX2UGQ2OmiRidXXeTDOrUA0/F6J/49Cfg8RPHW9pwKLFR52aZGRo3jJRGVQctIsTe6ZR/uhPpXJct6KoYaal4oz+7kYq8GGlV2XPpoLQTdHXRYpK0ledHp+IavOSIlsWH/ly1H4N5oorg86dPPg8/dfunIyYCdKvTMiCcVI9T0BkCmEkfng6pn9LBaOhcHUYuGDRob6OKZ/EfiUxmx2Ql2kfxOBxm8Hdu/At4MlZIqx7+1W0EXB+0jJMylQQPY3Tq4XSngQE0cKV7WHdq4nhxebmGx5EDGgduIP2yaXFeeqRBlJEWYNLXDtM4Wk3ueBoabOZ26kCKGxxT+n306BH4rg9/CA716xkXk2Q7J9OUJbRkCCQwa+sHVRY06Bs0v7s2NrLEMZPSuZ9w6RQSsdiiidBJlNCT1Uh8VC9PnTkD33PTX8ADRw4bKe3bwHTAxZ1R6OXReaGHpVpn3/vN0SVeJJh0xG5wjs5nbQ1F1YFR27rdaFpYKm3XTAsL6bA0DydcbBsBS22aWGHzQgRGsKaHP/ghxpluvwmBin8fPHwI3v+RG+GJU6cyFiarqxkbWUJrDcT0UaMHwhpAo0NhbXsfOhgBSTNoCY1Qu49Bo5bSkfhNqzDdvAqPxQr93QjqG/ftNSqJe3h+NNjyvStJ3Ejuvr7WYBYA53g1KGJpTGqbvR9GbWu1bI5W3Fj6jabFJdP6vMlkEoaWZwIOTZb6+ijV3fFRL//FfGfvRnDto9stS2k6WBN//Mn98L0f/gvYf+Y0TDYXLGTNnSSz0Aa1XRAHps4A7GBp8KEbfbCRUQUMqQP5pY8tOyWBaDfRrGJSr9y0CZ6brcP/8LFb4Ne+8Hk4G8/FAwJOUsOQeSKFg13ERjO6dLBOJFzQnc1LbLpn1sDDZQ5YMl1JixtIu3y+7WPgmlMdeCipARaqPxeUAJUsuO20kEpt+y9jG//AzTfCkX4WBdommCYMrK5kTGAyNzplP3tBKQV6c8QR3cCo9XIggneBYagP1BdPyug7u8LVtkeBE2WTFYtbhhFHjF6P5sc/v+sO+I8P3g8/+7avha+77AroqGdWVUOg1nWDOZpDh86ty6HB5cAMUD69yq3gRs7NkSnfaxHCBBpCUf1dIm2rks20dN2P01FeUIK6vFlHz6e6zpQrb0HAxq/xXiggJwR8dN9j8HOf+VR+BWKyGoG8aSUem/J4aiKejfoWpOSM5aW4YsLWOQ5U9ytGHJCVN8h89R0aFZFzLDM5qKa+q1slqNnxOmLNg5KQPB6g7K0C7Mejn/oHPvpheMeey+F7rn813HDRHtgeGSBVRD26tcQNANJqhdzhnBRj0KBqZE5jnsd2nq3zVhos3JlLqUeKxDeeW3qTG2jYA1TvvHmMykd3Wq0Ng9WGuh8PqkTnZ9bX4RNPPA6/f/+X4PY4A7geTc4E4mxukmROE27JA8ZChds56GxVG/G7JxnHlD40qleJK2G6kEdoMxGzQ14thboXAYRqKrD663jbsSlotdrHnjo7uwY3P/0k3BR79cvPuwDefeXV8O6rXgYv27ELNiW1BNbkgAXnOSgpHJRak0EQn2dSOjvBYEAwYMNyGkLS15dsFvVAk3fAdiO00vYqQlqcwMvCINU12WhZCyW7OQBPJmVtZmy6eqp/TTXo5MTZs7Dv2BH4yGOPwI3xeOLkiTj7F8dOEbwrEcRddgqsFqkcvRri0UD13jNrfmTgwiivREjC/GA3DZITBPvmfbkZ2Mxwb3MHrqn+4lg5+vOCgdk/XRo6/eu7AvY+MmEWzx+Obr2H4szib3/xbrjhwovh+197A3zd5VfDhgMDtkPTgXiWMDhJXc0SVVVss83HLsIqAixuAZ1WnczLW+LJYrB9oHzRXn4Lv+sH4gG8vc0dQX+VrUNo0Hd3lML/4vbb4AsHnoX1DsskSQTylFy1xWU7zWDOQJ6wZGZzIYCxjzletw2otmkxZKSNllpOV2cU5BoHta9fW2C1a/QX0HmwqOhR7qjLz9sE33jJ5fDeK6+BV+68EFYi+oMzM4x6GqW1SmLjV9amBzOqQ/uc/CyHQhyLDHMeWFLM40bSpj9iR6ajr5n02ZAmEzTxJdS6Iw68HABK0IfBcCCH1128B371ve+D+w8diJ6MffDnUcMenK1VIOf3NJyfGSwPeE2QodStLbwRjcjB7LEy/AwBbLycC3KJokBblWC9nVxCZdM/Mt0C8FfX2CO9btrD11xyKXzbZVfCe/ZcASsR7bNQN5rx1VwUcppOgVkDubMvJaEGt3CW69nBUDb5EUZonNM1wsj91j0Yzwtxflpt6HLaPCDsgPe8yRvk9sSLvD8gVp88DYbFdlb28wDkQVEY/yST8IaLL4W3xPb7wJveDB9/5in4w8cfgTuPxrmGSXm/pJPBH4A2NcoMZeE5GlSXOkg6biO91MPgdQAbP1w5qRVK9zbnvKwWybXKb/TdOkjanjiVlOE1286Dn3j5q+DtaR/DvgBY9jNUDB0DdvAHdyQjkbvqjyXah+48MqMKp3NupYrooIgiO4LUDdTdSldJg4oDnq817xeWlmhGereG+V2NDRnz8DYPdrJo6OUII7+ozBJjosRjJZqT74neqvdefgV8/MAz8MsP3RfnHU4W5QCVd0QARTZ+0X16pXgglPjnJEm5njZvclwYkYvcTSEM5IecZYEXKpMTE/JK6D384wjkb4/ejQumq4PdZf1Os5l/oTYoV00kCJEpzB645kDZyQTgfG1n30QikEEq/VMGEIqXUtdQCcAKtIIdFzfCRsKZZtsG0iJotMueNyqS6ShNljpzqLzocCAg+BwaUhpIe7KXk/dM4SPt9Z02rH/Lrt3wh08+Dr+59xE4lRJNwCjCIZi5HIc3w3AcxjfCYLHGEQib3o6NpQ3Mjp6uQxWA9rAj2lX/5JWvgW+95LKs/WYklc0Os6HSMSotGnGmsomU5kQJVIYydjWDU2C7us6lU77BcUP9emnirwchuLS+Zv63kRYdkynfMGhN3TtJCqIaFFKy4A+wgqRXxfAneEyxFNMVUG+N5sj7r7oO9mzaAv9blNbHs9dlonSLpxABYBykLBs8R1ph2krQAngrs0DgZmmuP60qpwhld6weLp6swK+//k3w6u3nZxNDwByUuaHALYAOlo4x2iSQe66+OwwCYuOX5tyQGQq2dTqcwxVY4t5G0uPwXFwX6l4mrZEWgpIlLKor+upileX5Ym3UOrbmZ3QI6sSbHTOlHWbBPvM3on39qvPPgx+9+/PwRHTzsWjX4GTpjKrTDYVUW6gN6IM6tWAOL4sQYKBua9paQ/SFJWamrSo2bYbfueGtAzDro2+B2REcWoeW6MGWbSkFhxtqhczNAGbRlnlYNJxZNpxD2mX6COLwRnNixj9cz/0rBgOtDwp8dF/zno8kmVvteu2W7fCrr78BLkoLmye1TFPLlhrukFWGLzo8jXw05z4HvJxjsyDX0quSUNb73Rzjf/N1b4IrN2+pYO7L0fcwvmWyVn3QALWTBmJzEyDlKwZsdEiSyhKvegO6f8OY8TsvVdp5sRr/ui9WBw4qa0vlxgNk02YDPMt173ivN1RddyBed8e1W7fBb0dPyBagtaB94wEqqylsrP+DqjDwywz+0IlEPyB4VW2lYFCMKVtUhNkMfj7azFdu3poBvM5gdpI5gxvqN7cayPPUod9mOf121FA4QLEmHWGABu6aGMwnYKDOFx0vVdrR9GDrxSc8bezrzQffTrzywqS5lTUdJr6haVP7roXazuuUJv1etmkr/PT1r8wCToN6gF0vPNER3sKnGmS2306ZI5HtbIdlWrlVtkhOYP5AHBi8e/fFUjEBtTv0xucMYgE4wGAHWi+5tdS4dss2KHYYGrFleRHUOJElFplMga6VoMCRAxZc4waePae8pV+GKoFd29kxMXVaSp037HG8Np2l0YFyeyAd6lltcmTJDOVYU3HfEv3W358+x5uVcVXGClHklbwZ3Noq1Yo1wuLXrRoZFdwSBUEbBMVESlskvyqqme+Mg4Je+ZhbPV8kQG+vPWKD+pUSdT5E0jt27C43mvyocAiidSiepjnrErX+2QYrFlzDBp49p7xFyhH9pUe6p+jJUCU9R31TFDYiSPQBVUiYNoDKd/DtF6yEZxD3wQqx74mAvnrTpgzoIJMMWDMUTJ1baAPaZ4g1PkiN1G8oPSrQILCLhP5InMK+cLqpAlnZzTPFjL53IFUMazKTy1MdQXeOH7z0Srgu2ut17epGPQjwQYMXB4leYNhoo5xLIypa1Xsdhluo40udE2+u2bwZvvviy9rjGA9saJsecg8aZkivzA5lelwQvV3/8NqXw2w2K4PEXm0wDgCGD9KrYNgsI6BfOChEWCClGOBU2z5K59dt2w7v2nWRVJQrpE0LPb3N6o7pbOBZ953BoRti12QVfvaKl0cpsBlkyznJQzMrEB898AMMnbLncsBLnD6AbnypR4BBXYJOE5l01epm+PHLrxWBMwsLvEtt7EBotQmDnto15w9qvBSPr9mxC752x84ipUN1OdbC69ziMkFjdKojszkRQrNSOgbliTrNyv7mZDt/Z5w4SSKhNdhoTW97Bo2FIKWWIPtGh+oDTRL7TVvPh//76lfBfzj8LNx04hjsWz9b3u7Ls2MBZEbFuQXqYBEWE8IsWCaElzAtAAE5WAQy4Gn/m0k8rooA/przt8P7d10KO+Lkx3oYd5kOMDZGQgDxG3DQryuke6mMVKX8Bkc8X8UJfOtFe+AThw/n5eOwo0y4QxIOB+MBqPc8G6QZr/zc54Khbiwl9yRmlJIU6R2NZOj3a+tw9XQFfv+Nb4Wt3VTUTFY7oLwZWiipopbqlGgHRfqrCfP5fGfvySCqYRsvwo+wgXnOeVTz1CUcVsV3xrFyWhdhIWGNfILVYPyrJSW3j0jSoDxNUCXuouB5qj+p4+8Lk+Rc6cpMXvo906/D++74FDwXZuo7w5RJZ8c22mMl5gcOC6fQ3tZtNDiZGhTz8vbIM3jHzj2wXfX+BGRjZsBiMGsKsEWCAk2vHkg/HVeqr9O1MgseKrCNlFV5oqNBbrtxCzSJs7QMgmOvATnXqdETmnkpAseEQQvQRlsqU3AWbHuMgVnzReKUlEZVJn9bkLUoS+oE8FCmx7/9kj3wm0/ui2OuXjZ6KjPPAIOGyVEIi4Te+PvQwVLcYnQVA8U266O58b7o2WBm8K+RyP1iMAdXDEtkRY6pL4M6v/mbpA5JZ1ZzvDa2dHpfgKOhiXdsly8NqYGH86VqcHUz5PT1HsC8hGCcA2G8OBEi+lcG51B/Nfh9xwOY3y6jpgfWNpAxFYH6XdHL8hv79kKYTgkYtOmm+WKBrkE34niY/4I/jkVaSBbDvoft0R56RRwQ9r2VBMbPOXi6hnmN0orLL3sqUAeSCtnzgUpCsHRmvsASQQM2OECrziQrbbFBD3Pq1ei4SBfVC1HycvJETK1BXvPAHCyvjaTW5wADIeTzHGsDqQO0EwTVBjKvEEr7vHr7edGWn8Dx7MIjW7qR2+CrtDmFjgO6qU6D+Q2kQ9ldl97ZSB/RejDLyDfUAYNm9Fw1PacOjCEtLVhjZQYqUwOUyTFWPak6g1gBTfZHYWIoE2PChXHpls/RpjP14/yDep46CpepAb3MABpcegYT09gSMqZdXB4Lg2okLXD0hlB6MmYSmfem83bAx44fIQnd1Rfecl4NaQIwt/GW+wSLM/FiRzhTAH11nOI2zApgZv9aDGMA9rA4GFCH2nNR1T+Fju7rdanB9fJWXKtAb37kaIMspWoV6JlWkbzBdQamP9g00ik4bbD1NnnoOLD5mijX0Xr1nO+AXGed91weUcCRa22embKo8Ku3xDmDo4cgKCeDBTAuTwRoQOveYIxUzlSLEBCq2NzI/s0tWw2TmPktuwwABlJkmdACtcRRRjMGOsWZX9daZsDM0b5RqQDhSHDEBKspWCoNaO+H4OOj19KbeaeaQOc94JeOYI0UhvwN7tx3njAn26WDaiCNIoMLrFJ618pqeVUiqK2RWw1l7A4vnapEGF1ON5DI45f5pXrefqSMEqgvXl09J6ZslHEe1PnHixWwDNUiTpsdxmsBMBRPrV/uREoG1AxV52U54B7XhLEnRkwxnT6UTmBkSytoHjQawJM/qFIYz/6cQO2e58O/sZeO5BHLApEJocDv2QudWN8S1PSa5or3pjhCxXyzxc7uBPJyrKrF/7Q0mFvbcwweh9yJmdZBIwZlZzfuWZ0+LKw18NZb1Q1wpKTUoDyv6MCaXKIRejVJ0UKj7jDObhupxvBeWKqvzA1Olw9IDa5T9aqtpjxRQgdrU+ZvS4OKFmpgdLENHdwTvSabDupd2HhUKhLmM/lcwqCXslSkc98pQ+MZnJPvWJwHRl+LFm1g0rPkZomu81BSHdTzHNcaW7SUSIvoMHLOEWO832ibeDDjgnTmmhHu7o7lsSi0AY3zSQmtk/j/bD9rpB420jyh84IDc3TOWKIFiEWNEFS+Bgyq4wiY6ab3agwGfT5/cB1jhLCxDjdicQyfUXTASF6Lgi5Paz7vixYJje2815K5YXo4M9S3nrseabDFEpoNdG1jtDgXw4H03Rice+861zAA7ghKrb1VG0LuKZu49y0W6jNmyarQaDDNrgatetCk+ajBF8bqBjC0+VWn4nGBLr8fo2MD8YvShpEbWpjla1eZo2trdqKLnsqbHcHGQ3sZA+/t0Ht1NVqLXxx//OTz0AxBnhyZcXzhodnwPl4B0WNiEHDeTRATysgSVRizbzApADAwL4LuFOpmcOmXeXndegpgYOJwXPNZeHFDZrcXKmhZe/DMaStZ+I5vUNSN5+6rVza6QYlS1EhmY8THNPcdP9rOQUmkpY6wgbTqWDRRwA0pC3QjyAtLT508XgYbxPBOV1uZMNLowXaUfM+lL8sKQ/2MyjEGNV0ufw8uDVIGCh97jx2SF7DkRSx+bn6zgarOSxsUb5nuFPaePAGAOK6FdMVb9+W6ZLrxL1YG+aLs9bH35EkzA6zbFlzcgkzPOXhADDp+UGCAAoDT62vwU7feCCfXzgy3yZhTzkCdAhg/awZyB+Ir77GCmz9h8p2Ega3rwLQbIEPpdGcj7b92+62wlhaQx9oRDajn0B/ghYPZ8ELFGbrdM3x95+GDwMtL4AtoeH6y8xH+nK+1NMJB4gLq07MZ3HX4kH3DDU2yHIQBYdigoxKW1TLMl8IAI+q1IcH4uP/wAbj38LPw2LGjAzBji3bXQoYOBOvShBYT7XOeZgQHCFQNRuf8WuYjRw7C3QefhYcjMMxWH1jrr/mnJ7n80W/wCHMOUOVKBR1f7z16GI6tr6sNmywP2sbDfNB3vicbZvq8JK1ycgt6u7wA40effdqCYQTUfC70BYB5HVR7DFoEekmsJzs8OBnY6Z3pvBfIU/vyB50373vEbJFhwI2OfvrtB4UrglogpjgvffVvUHXQr7wybXonsdueeAzOhBnc/PhDeaOeCdo3DXGMPGyTvGzABfn5cvnddW0q/dmTT+S94dHZIsVERpMPjuXr7rU/wZL80c6CNbzcslsTrff8n5/cF3vd2YpzsKAGaDBzpCcNJK0CA0uZQXq0z0rHAQUKtRfPegTDBx9/OK9r/JEnH8/7gzDQtQoXm9rTzWVjI16VG3D00VJ1tI0tDYm1ofSmPGlG7EQ0kW6NnTEtKP6XTz2e66K3zht83ADDjq95tdEwT8Nwh2Sa0V2fipL5o88+WRbEz4viE44oB6HTjyLVKTZoqoPCUVGO4FBd+w6DGQuY01cHaW+NTx08INKtpeI1R7TP1khhPtVpggWtJtnYs3T4vqhpYgmdAHHo7Jm8nvEzZ07BbU/vL4DohuobdB1QsUafa3taHbpqZnbP5cv30cWL1ugK3QnQ9xx6FvadeD7TfuDMGfjoE3ulM2pQG23uCYPaDmGePeeO0MjDXxvtAlbz3fLMk/BYHBAWCd3ROtKVIShMrlxo2tjGBOBBoQY16tZxD+pfUzhmwhKg03Zuv/3og1Fa9Haf584x2BXjpzmFIegOxSgNfKQ8AG0dfZnc0FNq+D945AHaT3ElRk7gDx59ANIaHQO6u6G0KwXU8oNli6mLodPfV52iU3XWHUoDuWweG+BPEu0rtNNYPP7r44/k+1NVP94vUH8W5VsQG829TPDmpD40r/QncumYRWz80eN7C16mE6h7lcMAoCBqDsCqe0c0nXeLKWZydbzKHMBK6UjgZw8fhk8ceNbaoyo76bnpYTWAMJILQQZY5gA7AOMgj9JJLrdTQAb1fRv9fjRK589GKVf2AynA+Pyh5+DmaHrkNJ0FtedfRx0MGuuj67FBa5UjbwJ4a85rEk37Sjw+9fST8JkDz5TOmGmfwO3x+rZYp6kCvv7WUuMBHQIzL5VdE9y9sCCNViWylU2ngKzOb33mqYiRg2WV/7RVCdvRhhEOc9Bo7EYYWTlp/AEDcAXsBOZJ2rh+WnYJ/cUv3Q1HkirvhpIGPXMBmpLLd0gtfX16VCdMYl6DEWGw/Vhi7snZGvzS3Z+j7cZou960oGC8+fN33Zk/4vS2aBMcmpOuIoM06K7pOW0nC5hBgRpq2Qmsa5G2n7/r9kxrJ7SXHVp/8Qt3wrGzpwX8GtiirbpGh/L8bPEch+0DFgbVvFC8zr9Q6DgUafs/vvSFrA0TXspq/938Rm0V7KJ0M7haUHBq0qJQIqXGbAfljesjqO8/cQx+66H7TQ9t2XVjzNJBC785nXNIIsLAK8DH7z98P+w9cTyrvdQJ80HnT0Vb+l/fd4+R5gLmDoZmEMAArEYC6mvFtk5dexOpc+VqcP72/V+CJ6LPP29sSkJkQttR74t26Z/sfUjS+kN3Ri/0/CBca00+b74Oy3UAMB4Wz7e0PevvP/IQ7Dt1qmw0lPZi6SZ1E07B05BAnNfoKtTldEe7HxLDVeaoDHSyfdjLUTeuX4V/F23pv4heD89QM2iBBjhgSAo6svw9n0fnmUkdKn1C/2f7HoV/dd+9tO902egmdcQJb0UWj9+4/4vRJNkvdqsxQbBhRvE5qVyhFRtp6DrofEKVnppfbGLw70eeeBx+6767YbJphWznKe3YOy3aJpog/9e9d8EHH3ukLBvAtndXXXrieXD0MG+D8x0HjXZ0fAcwGiXzvquSeaqOD0Us/OsoSDK/eb/vSfFwaKnG66Ogxp2AvB2Ylo6XVA30LqrYwwDGrgl8nW3CCnIGNw8MJxMyPSLBSSX+7BfugPuPHxEpzcAYmCKKud0yAFdpWGoaNY1qMIWlQdPx8LEj8M8+91k4neIJEJM8mJ3IICXFpy+R/6fPfBIeOHJ4KOXAaprW3uVeeosUVucizdSzvizmVwLzQ0ePwM/dcXve4zGbSStTorsjTVNAjvH3FyLfvxTt1Ck9K/ynQ0tQGTAC2MEjtoFrTCN18GCUtcNKVzvjo8ePwk9/7jMZE4nG6YRox44GhYwnICHJjKo49HjTeGWCO/CR0kVrJtJrOK3qRbr1qvuu7vF9pO/h73/qY/DUqeeNlOPKD4DtQO1tuGYcOHBpqaSkUwLzf3/bR+F4nA6ZrGySBU462ksvg2JSpF3aATVtpfBDH/8oPBif0w017WwjzgOzsSvBSmNtVmg7mQ8GQzqePPk8/Eik/XC0n7u8sWWL9kmW0NN4HItt+IGYfv/zxwywWl4Q7QnhJs3XwQK8C/Y+P5eWJBC6QbUvnT8daX//rTfDmSTwWCtOaTBoGlrkp+BPRFhLOjfi8Jq777ZmqTeSsMTJJzLKuDIfNvI6ZbQc2PraOqyfPQuzeKydOg07I/H/z9e/G1523gV1ERq1ao9fxXKMFEt9Za6W7hpszOj90V7+7ls+BIfixEnatndKG0VOaC89pDLSAoJ9JGx97Wykfy3vTb5ndTP8+298D1y6bbssnCOL6GClmd/h0DSHEdqZnZn+INURAE2hStEnjh+Dv3fLTXAg0lRoX420k4RTtCfez/pZoZtov2LTFvj1r3sXXHXe+WZpW1lkJkBzNasgRDqWV9w1B9zaPEudKAmDf/DJKNDiZFvexD7SzzvNdnkTe16irQ5OMsidLc2Se8BMB+rJjh/+4f8F5gXUDzHruDx1DaxeiSiAahvFcDLODP3Row/BVdu2wSsuuADqrBAMTQgYSl4ttb1fU2zkzrrlsrqNx3+JNvMPfvwWeD7Fpf2naQ/qTjZT76qGEW3TSWHHYqf8k0cehiu2b4NX7txR6Waed65DUaWEXufZYfWuTZiJphlrPT6yfx/8yMf/Eg5HbZGBvKlIuMmAdiKEAA4EiuRp+qM4lnlZBPT1519glKqx7xVfEYbnk86acVrbshZc0b8x/qZo7//EZ2+DgyxEEqBXqqmU7WfXuIXvAjBiXrUUKtBUI8wF9NiDgzgEh2eTRNs6DP61KEFujJWcxd/E3G3J3tNMhSG4NXM7BQ593emBlDIzjsXG/K0Hvgi/GAdJZ7ATIBdATCoglC9LQN0RE2mvw1NR69y0b1/+oPOa886D80Zo9+aQNkUMQBqAnlJ8+j0ZJdov3fU5+OV774aTKT7SvbKpRXsnTKu0E7CJiLUofv/8sUdz21x7/vmwPdEOli5PoxEg6toM7qE9eH0+8v1f3veFyPfPw6mYMG9kT6ZQcZFW2mUDUGIceheYs6PngTlHDUyOFEbeAA+ik/oq+vvyxXf169BC1oEWcEzmx/paND3Ws/nBZsjVm7fAT7z+q+Cdey6PDOkG664xGU1KcAh+bYOeiRLhtmefjgOjO2FvtN+K5yKZGKt5AiK7ubqJME73fl7ZMn9aH9X3bD3RT+bTWqrHGlweaf+ZN78Fvv7Sy/KAzK8IZNQ22DpgY9aQ9yzqch49fPqZZ+CffvqTcSr+tKO9uOk6nioeoT0RMiPaZ5n2tczzRPsroqT+4de8Hr7h0itz6WZrEGi76wy9CmsT/qXzNAP4mQNPwy/f8zl44Pnj0RNDAmS1emTy/t9KIxpTg8EdQIHcSWeDg3mA1jf79rIvZhlT/rDR2NIAvKQBr4Bd1rxbz4ydra1npiZw9BEcIca9bfdF8J3XvBzefdmVsGU6ta84wpCxqOpiJEk8PxE7zs3RNfSf47Tqrc8+lScdpnkWjcAgdudEADEaAtAq831enDuDOY0Loh3bn020z+CrL74Y3nfttfBNV12Vpd5gSVq0tOuLTL+yoY9Ge/fWOPv3+w8+CHcefC6q47Qh/JRUdOmIxW/bKdpHVKTQXkGd6M/AjnXoYn1eu2MnfMe1L4f3XH41bIt80qtc8a8Onu9a2xyPPLk9Avl3H7ov0n6gDFizRF6VafmJTHNP8kNDMAOYUT8BGnXB8r1hI9B9vPaeeyrt/EAIlVXaCB8MDivajJSmDhFohfZAA60C7JlIugRqZvY1ccD1jXuugG+/5jp4ZWR2KrQlJTSDS90C3HP4UDZl/mTvI/DM6VNlKpt8s8zQjtR0deRzvii4EJ4BrUUSaBFKBsdaAkcBxSw2YqpLH+m/aus2eOell8L7XnYdvCl2UNmPRPjW6JBQAH3Xc8/Bjfsehz999FF4+vQpmiyZin9cBq5Tol1UNEiDq2ar3CJQ8+ZNBdhr0jHT0sepPa7del7eb/19174MXnXBTuClxlvaUWMuCbG7Dz0Ht0Zf/QejAHni9IncCQvPiwDp2MRIbsWueGOA5ityfmn/9XTSVds5l58L6gSnAuKgpAEUya35mqHKgJYIboMgzW1upLWg7ar9UJpfJHZGcr6OrAQkSd0rEySBOAFhRkdibmJ4ktipEc6PDfrmCy+Ga7afBxdG9X5+sh+JgLWYz/FoXx6MnpO9cTbyzgiIw2tnyjsBNEvJEw1ZKrB7iyRbp2xOgkRFXf6rUVjq03OnTEeiN0vsdalHn4AdwZHqd0Es780XXQTXRFt195bNcEGincpKtuzRqJ0OnY60R8/F5yPtB8+cNTOs2Q+eNEukP7vjplUqi5mhGzV3HKwLs7DJpMxD9twk/s4GtJf6JNp3Rtpft+vC7InavXlzHCes5vXnUogp8uD4udjpHovmxF1RixyJnRrFB86TJVM5Ty5QZD851lFlBm1nB4DJdg7GxKjnDDcWQlxngKGSzYCGVhizo/meA3WGtTJDyAdW05NbLzO2nxWJvb4uUruAYpalSU8bsvRkk4vIMHqvU7OTXQX0ZCqDJlZx7O+UKVbdc1HLzGDrzp0V2Kb2wE6dcVb2CyHaWRsF3gXJ85JUbWrUTDcN7jKQJ9OqSQztRL+g2dPebjutZRI9zPvAZghpzcT7zHfZnaov30XrsZIMygotQhdpDn6Hp+NOyG0y6Spw2dRA6/bRAG4OBFth5N507gMNR7CVZ6yuS/dJdMoH4lyBQFvzpsqnDYUmHc009qUh+8QIZuiMVCRtbxF6JWmG6gZI4qK8utoViUHqLcejArLoTPVrEUKVq4BG6qBZgmA5WFp2swn00zhJQ2BIC75nLUQ7pga/vpfy+Ajtk05evUUBwRzaofFrQgC2eVghs/RLwOr7JB2TCRP5nrXKtPB9VjsrjPGdaJeX8h3txa9M8ZjukX0iLjkE4xoCBWapTwPMWgCN1ruEja0+ajLkxkKoi9xpUEvXjrf7AuJU2QQOJID0XWZiVqWRKazaZTMZ9qAAGCM0k9LV/bxRqWQUkNMLUwbAlXFo6qUrF4oECUGtA106dx7ERTDk1wQS7dRJQ+pM3AFZktPoVvY/UdKg0K20hjmQ7HwE80qlp320UQvRTdonpNozj0t5YdIX2jXfaYJM+J6Obg7tJIUHmlAdAzCjm53WUrpVJTkfB3MK87ek8NcmKS/oSAAQBhCoZRVwECAH0AwuwM62VPo0ui9xxUwJ4vrLwHKjKv0yS/W9FjUIZI8NmCXPcSbYZpjaQAXVaMvQnssk2vtUZho4VrNKz6AuTTv7wVu0E78r7Ypo075YtaVI6hbtSUqHzHfueL3srxdqHTiPIu6HtJP/3ggWJzw8sOvzmnjbHrgAtPPCdID4RZlpTwjSICr34I7AX6RRYQOafJH91KoiWVqTfZx/J50CBVTGUnrJ34AUrY2pQbsIzD54aZCL6/NC7kHVveTYZ6lXBiwh84D3Aay0g6IfLO2IDiScxA1ccQHtWvAgOl5pkms65HwTnV2QjhkE1OD4DoYW4bumXUtZHSevH+pnoKaFeo4D3jfqOicsb3IMCiJQA3diRQ1J7jwY6INdEQgnWU2D8BZFMiCbLZSH2WAueJsDrOo1IKZ8jIRGWwd5RpUpZCqpyvqWO1w2RZj4yQjtQeUFA1ygq8eARlyedqx2jOOXTT+gXQ1YBdx0rbvfwFyaR7t0QAAZ+Ml9UJ1X5aE6wQsFcwpTjbVmUBWVtHwyCupQJFpKlE0KxewQSJqTVOPGR8pUhFooDGBJgR1UicP54RDQAIBO5QV9XzO2PmJPVQ+sp1ReNjPSNfnaNY8g1A1FSL1L5waiGX2h2KAdXN0U0M11bYpyqfilaWfNwlqS8hCNw3wXcwWE/wGHgsTSrujmarBEVmlqvQCqr/nFBXMKZuNNqxhrvj5/c88wiWznTHxhEtLgShqXMFyaVzFZSYKgGbsMHU6CMYil8QXElZm2fjpXMqW4oQgkgW1+BmgyL6h+tSOivDq3iOZKru2QfM31CqoDapkRTI4cF1Q+NTGbbTJ2z0IGlKSu6ZaiGSzfmc+8KLmhnUAr5ikDGXGw4ZW0G8LAyGydt/hsTI5Bp9C/oma5cCApCwLKoOINgVoqAJJkhjpBg1WKo86EH2MbW2qAhglYiTRSgJlHlqq6Jyn0IxIbGBcQNANMvVnDBKKd0RKU1gJdd8VHLY1atNdzpElBHKWdfwLUzgdEOypeMFSlGZE1iGpXqhwaLWlpr+RZMGvaUfO9EV/4AnYFWBU/aBPEAZDBXfPvtJVoNKAd+fsGQGJCYG5nSwHNLKKuYHBbSxUQ8iruOOyGo3S5E7TMMw/XnmB/VTkCwlDjURAkibI2MqzO/3WdYJB3m3aFTAI5eoDDCO0WiyBodPtTiMQOoaLJPSwQDUMyxWxxJGnazMcgDhtSjsqjVNcxhdvNlbcURmN66+XwROtrf48yKPdUkRrY8uYUWN3AmBB7SW9xQYl0e4wCQV0oqSESQz/fArDPSC/sAa7uwRPD0ockMxfm9iscFINQeRkqregb3nQAtHVo0WzOcQjaUhFgyVnpINoNwGEIalO+ohNgfudjfqqOizAHS63rFib9L92bbjhTbLSWAU8thIWCrHOlgco2HD2jwQ1BD+Ra4qIWjIY2dUuBxdI9TKvlgDEQdJ1QgxqgaigCJPuv2YaeR7uyK5envUkwKAMGzFggKBAx7SLRg8qXaCeAByZg0Mw4LLFFO0e0OiBWSBth2IBUE2emTBymyxL6XAMDV65BEVh7jICaEykholV6uV0NKA2yprRoE1V/Rhg693F/Txfd6pRMuxoUV6nlM2gV0Cj9y017TqsEi87pXPhO+bQ6oBE+nP9GwLxEOHdAc8HB1boBbNR+WZYaGvgi/eYxcsT+QEePv4HtpMsyzXhwwNPuAMIheDJeGO3nQrce0M2lXZMHG6AdWvSPgNikASvUBnmeO5hTeGGA1gRsANg5WtMtEgSy0h/uOei7MsK4SoTlgTAmIXS80zZMrpSQcNGhnVkz9L8ItGs6WjT6eJ++QTt7c2paR7sZM+j7uDHacUFHWJTWPRZgfpiWdzKU/5Ey1e9D13rj0FdJUjo4aT2UDjZvW+nyE9QFC4eQB5RolEGllU3DlqhRNOtn1L3RJW7RyyVUQABomloZpx1REXj8pX0HjmbK19RaiAaemBnQ7Mod3ENFM+eNdWyQ2cltizUH7o+opLmlGW2nMGmpDYxbF4c0W9IVzTgfdy6PeWmnzDh9Ax0T6qyXTQtgO4GvVKD0qK8BqQJg03K5YGuueA4amrVMUPR48FJa3Umw0iVxaqTcphkkt1J2nbVUpKoGwDbNFG/GMTDkfYnoVL1KJ9kQzahyD5UHmndgylQ059lcrM/pduBidVr0g/OC9ADu+RbNiJYOVQ+NBXR8ZozKfcp78HJSMxNNqAuDwrWKtuLINYh6CtXzXnqbwlpVtfc4b1XVQXLfKXW95tLMZ452uRPCKF0wXqsB7fYe/yyg2WQ3ntaoJcUaQ3urvceq0alpbj3YxAU0y8ts87NvhWYayvuF29Cjpere2mroxjPB3RiIrbFnwOqnpbiyGGBNurmMFg2A42lg7Bl4cWmXPM+R9nk81+rPP78M7Yjzr1+E8P8B0szv+tLrxRwAAAAASUVORK5CYII=")'}}),Trust=({theme:et="light",...o})=>jsxRuntimeExports.jsxs("svg",{...o,width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("rect",{width:"44",height:"44",fill:et==="light"?"var(--ck-brand-trust-02)":"var(--ck-brand-trust-02b)"}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M33.0246 11.8662C33.4096 11.8662 33.774 12.0243 34.0421 12.2925C34.3102 12.5675 34.4615 12.9387 34.4546 13.3168C34.3859 17.4143 34.2277 20.5493 33.9321 23.0312C33.6433 25.5131 33.2102 27.3556 32.5571 28.8475C32.1171 29.8443 31.574 30.6693 30.9346 31.3706C30.0752 32.2987 29.0921 32.9725 28.0196 33.6119C27.561 33.8861 27.0843 34.1568 26.5842 34.4408C25.5172 35.0468 24.3441 35.713 23.0146 36.6025C22.5333 36.9256 21.9077 36.9256 21.4265 36.6025C20.0766 35.7026 18.8879 35.0281 17.8112 34.4173C17.5718 34.2815 17.3379 34.1488 17.109 34.0175C15.8509 33.2887 14.7165 32.5943 13.7265 31.5906C13.0665 30.9306 12.4959 30.1262 12.0421 29.1706C11.4234 27.8918 11.004 26.345 10.6946 24.3443C10.2821 21.67 10.0759 18.1706 10.0002 13.3168C9.99336 12.9387 10.1377 12.5675 10.4059 12.2925C10.674 12.0243 11.0452 11.8662 11.4302 11.8662H12.0215C13.8433 11.8731 17.8652 11.6943 21.344 8.98559C21.8596 8.58683 22.5815 8.58683 23.0971 8.98559C26.5759 11.6943 30.5977 11.8731 32.4265 11.8662H33.0246ZM29.8277 27.9331C30.2746 27.0118 30.6459 25.74 30.9277 23.9112C31.2646 21.725 31.4709 18.755 31.5671 14.7125C29.4221 14.6506 25.7371 14.2381 22.224 11.8731C18.7109 14.2312 15.0259 14.6437 12.8877 14.7125C12.9633 18.0537 13.1146 20.6525 13.3552 22.6943C13.6302 25.0181 14.0221 26.5925 14.5102 27.6993C14.8333 28.435 15.1909 28.9643 15.6171 29.4318C16.1877 30.0575 16.9096 30.5731 17.8927 31.1643C18.3005 31.409 18.7502 31.6635 19.2396 31.9406C20.1116 32.4341 21.1099 32.9991 22.224 33.7081C23.3175 33.0107 24.3014 32.4515 25.1633 31.9616C25.4231 31.8139 25.6717 31.6725 25.909 31.5356C27.119 30.8412 28.0127 30.2637 28.6796 29.59C29.1265 29.1293 29.4909 28.6275 29.8277 27.9331Z",fill:et==="light"?"var(--ck-brand-trust-01)":"var(--ck-brand-trust-01b)"})]}),Argent=({...et})=>jsxRuntimeExports.jsxs("svg",{...et,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("rect",{width:"32",height:"32",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M18.3242 7.63647H13.6516C13.4955 7.63647 13.3704 7.76611 13.367 7.92726C13.2726 12.4568 10.9768 16.7559 7.02532 19.8009C6.89986 19.8976 6.87128 20.0792 6.963 20.21L9.69685 24.112C9.78986 24.2448 9.97107 24.2747 10.0986 24.1772C12.5694 22.2856 14.5567 20.0038 15.9879 17.4746C17.4191 20.0038 19.4065 22.2856 21.8773 24.1772C22.0047 24.2747 22.186 24.2448 22.2791 24.112L25.013 20.21C25.1045 20.0792 25.0759 19.8976 24.9506 19.8009C20.999 16.7559 18.7033 12.4568 18.609 7.92726C18.6056 7.76611 18.4803 7.63647 18.3242 7.63647Z",fill:"var(--ck-brand-argent)"})]}),ImToken=({...et})=>jsxRuntimeExports.jsx("svg",{...et,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:`linear-gradient( +`);const it=createData(o,tt,nt),st=Utils$1.getSymbolSize(o),at=new BitMatrix(st);return setupFinderPattern(at,o),setupTimingPattern(at),setupAlignmentPattern(at,o),setupFormatInfo(at,tt,0),o>=7&&setupVersionInfo(at,o),setupData(at,it),isNaN(rt)&&(rt=MaskPattern.getBestMask(at,setupFormatInfo.bind(null,at,tt))),MaskPattern.applyMask(rt,at),setupFormatInfo(at,tt,rt),{modules:at,version:o,errorCorrectionLevel:tt,maskPattern:rt,segments:nt}}qrcode.create=function(o,tt){if(typeof o>"u"||o==="")throw new Error("No input text");let rt=ECLevel.M,nt,ot;return typeof tt<"u"&&(rt=ECLevel.from(tt.errorCorrectionLevel,ECLevel.M),nt=Version$1.from(tt.version),ot=MaskPattern.from(tt.maskPattern),tt.toSJISFunc&&Utils$1.setToSJISFunction(tt.toSJISFunc)),createSymbol(o,nt,rt,ot)};var canvas={},utils$1={};(function(et){function o(tt){if(typeof tt=="number"&&(tt=tt.toString()),typeof tt!="string")throw new Error("Color should be defined as hex string");let rt=tt.slice().replace("#","").split("");if(rt.length<3||rt.length===5||rt.length>8)throw new Error("Invalid hex color: "+tt);(rt.length===3||rt.length===4)&&(rt=Array.prototype.concat.apply([],rt.map(function(ot){return[ot,ot]}))),rt.length===6&&rt.push("F","F");const nt=parseInt(rt.join(""),16);return{r:nt>>24&255,g:nt>>16&255,b:nt>>8&255,a:nt&255,hex:"#"+rt.slice(0,6).join("")}}et.getOptions=function(rt){rt||(rt={}),rt.color||(rt.color={});const nt=typeof rt.margin>"u"||rt.margin===null||rt.margin<0?4:rt.margin,ot=rt.width&&rt.width>=21?rt.width:void 0,it=rt.scale||4;return{width:ot,scale:ot?4:it,margin:nt,color:{dark:o(rt.color.dark||"#000000ff"),light:o(rt.color.light||"#ffffffff")},type:rt.type,rendererOpts:rt.rendererOpts||{}}},et.getScale=function(rt,nt){return nt.width&&nt.width>=rt+nt.margin*2?nt.width/(rt+nt.margin*2):nt.scale},et.getImageWidth=function(rt,nt){const ot=et.getScale(rt,nt);return Math.floor((rt+nt.margin*2)*ot)},et.qrToImageData=function(rt,nt,ot){const it=nt.modules.size,st=nt.modules.data,at=et.getScale(it,ot),ct=Math.floor((it+ot.margin*2)*at),lt=ot.margin*at,dt=[ot.color.light,ot.color.dark];for(let ht=0;ht=lt&&mt>=lt&&ht"u"&&(!it||!it.getContext)&&(at=it,it=void 0),it||(ct=rt()),at=o.getOptions(at);const lt=o.getImageWidth(ot.modules.size,at),dt=ct.getContext("2d"),ht=dt.createImageData(lt,lt);return o.qrToImageData(ht.data,ot,at),tt(dt,ct,lt),dt.putImageData(ht,0,0),ct},et.renderToDataURL=function(ot,it,st){let at=st;typeof at>"u"&&(!it||!it.getContext)&&(at=it,it=void 0),at||(at={});const ct=et.render(ot,it,at),lt=at.type||"image/png",dt=at.rendererOpts||{};return ct.toDataURL(lt,dt.quality)}})(canvas);var svgTag={};const Utils=utils$1;function getColorAttrib(et,o){const tt=et.a/255,rt=o+'="'+et.hex+'"';return tt<1?rt+" "+o+'-opacity="'+tt.toFixed(2).slice(1)+'"':rt}function svgCmd(et,o,tt){let rt=et+o;return typeof tt<"u"&&(rt+=" "+tt),rt}function qrToPath(et,o,tt){let rt="",nt=0,ot=!1,it=0;for(let st=0;st0&&at>0&&et[st-1]||(rt+=ot?svgCmd("M",at+tt,.5+ct+tt):svgCmd("m",nt,0),nt=0,ot=!1),at+1':"",ct="',lt='viewBox="0 0 '+st+" "+st+'"',ht=''+at+ct+` +`;return typeof rt=="function"&&rt(null,ht),ht};const canPromise=canPromise$1,QRCode$2=qrcode,CanvasRenderer=canvas,SvgRenderer=svgTag;function renderCanvas(et,o,tt,rt,nt){const ot=[].slice.call(arguments,1),it=ot.length,st=typeof ot[it-1]=="function";if(!st&&!canPromise())throw new Error("Callback required as last argument");if(st){if(it<2)throw new Error("Too few arguments provided");it===2?(nt=tt,tt=o,o=rt=void 0):it===3&&(o.getContext&&typeof nt>"u"?(nt=rt,rt=void 0):(nt=rt,rt=tt,tt=o,o=void 0))}else{if(it<1)throw new Error("Too few arguments provided");return it===1?(tt=o,o=rt=void 0):it===2&&!o.getContext&&(rt=tt,tt=o,o=void 0),new Promise(function(at,ct){try{const lt=QRCode$2.create(tt,rt);at(et(lt,o,rt))}catch(lt){ct(lt)}})}try{const at=QRCode$2.create(tt,rt);nt(null,et(at,o,rt))}catch(at){nt(at)}}browser$1.create=QRCode$2.create;browser$1.toCanvas=renderCanvas.bind(null,CanvasRenderer.render);browser$1.toDataURL=renderCanvas.bind(null,CanvasRenderer.renderToDataURL);browser$1.toString=renderCanvas.bind(null,function(et,o,tt){return SvgRenderer.render(et,tt)});var PRE_ENTER=0,ENTERING=1,ENTERED=2,PRE_EXIT=3,EXITING=4,EXITED=5,UNMOUNTED=6,STATES=["preEnter","entering","entered","preExit","exiting","exited","unmounted"],startOrEnd=function(o){return o?UNMOUNTED:EXITED},updateState=function(o,tt,rt,nt,ot){clearTimeout(nt.current),tt(o),rt.current=o,ot&&ot({state:STATES[o]})},useTransition=function(o){var tt=o===void 0?{}:o,rt=tt.enter,nt=rt===void 0?!0:rt,ot=tt.exit,it=ot===void 0?!0:ot,st=tt.preEnter,at=tt.preExit,ct=tt.timeout,lt=tt.initialEntered,dt=tt.mountOnEnter,ht=tt.unmountOnExit,mt=tt.onChange,ft=reactExports.useState(lt?ENTERED:startOrEnd(dt)),pt=ft[0],yt=ft[1],gt=reactExports.useRef(pt),bt=reactExports.useRef(),xt,vt;typeof ct=="object"?(xt=ct.enter,vt=ct.exit):xt=vt=ct;var Et=reactExports.useCallback(function(){var St;switch(gt.current){case ENTERING:case PRE_ENTER:St=ENTERED;break;case EXITING:case PRE_EXIT:St=startOrEnd(ht);break}St!==void 0&&updateState(St,yt,gt,bt,mt)},[mt,ht]),Ct=reactExports.useCallback(function(St){var At=function It(Nt){switch(updateState(Nt,yt,gt,bt,mt),Nt){case ENTERING:xt>=0&&(bt.current=setTimeout(Et,xt));break;case EXITING:vt>=0&&(bt.current=setTimeout(Et,vt));break;case PRE_ENTER:case PRE_EXIT:bt.current=setTimeout(function(){return It(Nt+1)},0);break}},kt=gt.current<=ENTERED;typeof St!="boolean"&&(St=!kt),St?kt||At(nt?st?PRE_ENTER:ENTERING:ENTERED):kt&&At(it?at?PRE_EXIT:EXITING:startOrEnd(ht))},[Et,mt,nt,it,st,at,xt,vt,ht]);return reactExports.useEffect(function(){return function(){return clearTimeout(bt.current)}},[]),[STATES[pt],Ct,Et]};const defaultConnectors=({app:et,walletConnectProjectId:o,coinbaseWalletPreference:tt})=>{const rt=et.name&&et.icon&&et.description&&et.url,nt=!(typeof window>"u")&&(window==null?void 0:window.parent)!==window,ot=[];return nt&&ot.push(safe({allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/]})),ot.push(injected({target:"metaMask"}),coinbaseWallet({appName:et.name,appLogoUrl:et.icon,overrideIsMetaMask:!1,preference:tt})),o&&ot.push(walletConnect({showQrModal:!1,projectId:o,metadata:rt?{name:et.name,description:et.description,url:et.url,icons:[et.icon]}:void 0})),ot};let globalAppName,globalAppIcon;const getAppName=()=>globalAppName,getAppIcon=()=>globalAppIcon,defaultConfig=({appName:et="ConnectKit",appIcon:o,appDescription:tt,appUrl:rt,walletConnectProjectId:nt,coinbaseWalletPreference:ot,chains:it=[mainnet,polygon,optimism,arbitrum],client:st,...at})=>{var ct,lt;globalAppName=et,o&&(globalAppIcon=o);const dt=(ct=at==null?void 0:at.transports)!==null&&ct!==void 0?ct:Object.fromEntries(it.map(ft=>[ft.id,http()])),ht=(lt=at==null?void 0:at.connectors)!==null&<!==void 0?lt:defaultConnectors({app:{name:et,icon:o,description:tt,url:rt},walletConnectProjectId:nt,coinbaseWalletPreference:ot});return{...at,chains:it,connectors:ht,transports:dt}},isWalletInstalled=et=>{if(typeof window>"u")return!1;const{ethereum:o}=window;return!!(o!=null&&o[`is${et}`]||o!=null&&o.providers&&(o!=null&&o.providers.find(tt=>tt==null?void 0:tt[`is${et}`])))},isFamily=()=>isWalletInstalled("Family"),isRainbow=()=>isWalletInstalled("Rainbow"),isZerion=()=>isWalletInstalled("Zerion"),Mock=({...et})=>jsxRuntimeExports.jsxs("svg",{...et,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)"},children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.5611 8.12948C21.0082 7.90729 21.5007 7.79167 22 7.79167C22.4993 7.79167 22.9919 7.90729 23.439 8.12948L23.4408 8.1304L33.0387 12.9293C33.577 13.197 34.031 13.61 34.3478 14.121C34.6649 14.6323 34.833 15.2218 34.8333 15.8234V27.2595C34.833 27.8611 34.6649 28.4511 34.3478 28.9624C34.031 29.4733 33.578 29.8858 33.0398 30.1535L23.4411 34.9528C22.9919 35.1775 22.4963 35.2947 21.994 35.2947C21.4918 35.2947 20.9964 35.1777 20.5472 34.9529L10.9475 30.1531L10.9452 30.1519C10.4071 29.8808 9.95535 29.4646 9.6411 28.9504C9.32739 28.437 9.16312 27.8464 9.16673 27.2448L9.16675 27.2417L10.0004 27.2475H9.16673V27.2448V15.8239C9.16705 15.2223 9.33518 14.6322 9.65222 14.121C9.96906 13.61 10.4221 13.1976 10.9604 12.9298L20.5592 8.1304L20.5611 8.12948ZM21.3031 9.62267L11.8706 14.3389L22 19.4036L32.1294 14.3389L22.697 9.62267C22.4806 9.51531 22.2416 9.45905 22 9.45905C21.7585 9.45905 21.5194 9.51534 21.3031 9.62267ZM10.8341 15.8241C10.8341 15.7785 10.8362 15.733 10.8401 15.6878L21.1663 20.8509V33.3983L11.6955 28.6629C11.4352 28.5315 11.2159 28.3297 11.0638 28.0809C10.9116 27.8318 10.8321 27.5452 10.8341 27.2533L10.8341 27.2475V15.8241ZM22.8337 33.3923L32.2967 28.6608C32.5576 28.5312 32.7772 28.3313 32.9308 28.0836C33.0844 27.836 33.1658 27.5504 33.166 27.259V15.8243C33.1659 15.7786 33.1639 15.7331 33.1599 15.6878L22.8337 20.8509V33.3923Z",fill:"url(#paint0_linear_3546_7073)"}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.8341 15.8241C10.8341 15.7785 10.8362 15.733 10.8401 15.6878L21.1663 20.8509V33.3983L11.6955 28.6629C11.4352 28.5315 11.2159 28.3297 11.0638 28.0809C10.9116 27.8318 10.8321 27.5452 10.8341 27.2533L10.8341 27.2475V15.8241Z",fill:"url(#paint1_linear_3546_7073)",fillOpacity:"0.3"}),jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_3546_7073",x1:"22",y1:"7.79167",x2:"22",y2:"35.2947",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.7"})]}),jsxRuntimeExports.jsxs("linearGradient",{id:"paint1_linear_3546_7073",x1:"22",y1:"7.79167",x2:"22",y2:"35.2947",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.7"})]})]})]}),Injected=({...et})=>jsxRuntimeExports.jsx("svg",{...et,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.6505 3.64041C15.6501 3.64062 15.6497 3.64083 15.6493 3.64103L6.05165 8.43985L16.2501 13.5391L26.4484 8.43987L16.8508 3.64103C16.8504 3.64083 16.85 3.64063 16.8496 3.64043C16.6632 3.54806 16.458 3.5 16.25 3.5C16.042 3.5 15.8369 3.54806 15.6505 3.64041ZM28 10.4592L17.5001 15.7091L17.5 28.5205L27.248 23.6465L27.2508 23.6452C27.4757 23.5334 27.665 23.3611 27.7973 23.1477C27.9297 22.9342 27.9999 22.6881 28 22.4369V10.4592ZM15 28.527L15.0001 15.7091L4.50006 10.4591V22.4333C4.49831 22.6849 4.56687 22.9319 4.69807 23.1466C4.82896 23.3608 5.01696 23.5342 5.24095 23.6475C5.24148 23.6477 5.242 23.648 5.24253 23.6483L15 28.527ZM14.5207 31.0824L4.12104 25.8826L4.11759 25.8809C3.47681 25.558 2.93902 25.0625 2.56486 24.4502C2.19154 23.8394 1.99597 23.1365 2.00006 22.4207V10.0486C2.00044 9.33234 2.20062 8.62972 2.5781 8.021C2.95529 7.41274 3.49457 6.92167 4.13537 6.60291C4.13585 6.60267 4.13633 6.60243 4.13681 6.60219L14.534 1.40359L14.5368 1.40221C15.0692 1.13767 15.6556 1 16.25 1C16.8445 1 17.4309 1.13767 17.9633 1.40221L17.966 1.40358L28.3633 6.60219C28.3638 6.60245 28.3643 6.6027 28.3648 6.60295C29.0055 6.92171 29.5448 7.41276 29.922 8.021C30.2994 8.62973 30.4996 9.33168 30.5 10.0479V22.4376C30.4996 23.1538 30.2994 23.8565 29.922 24.4652C29.5448 25.0734 29.0056 25.5644 28.365 25.8831C28.3644 25.8834 28.3638 25.8837 28.3633 25.884L17.9664 31.0824C17.9663 31.0825 17.9665 31.0824 17.9664 31.0824C17.4316 31.3499 16.8415 31.4894 16.2435 31.4894C15.6455 31.4894 15.0554 31.3499 14.5207 31.0824C14.5205 31.0824 14.5208 31.0825 14.5207 31.0824Z",fill:"#CCCCCC"})}),WalletConnect=({background:et=!1,...o})=>jsxRuntimeExports.jsx("svg",{...o,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:et?{background:"var(--ck-brand-walletConnect)"}:void 0,children:jsxRuntimeExports.jsx("path",{d:"M9.58818 11.8556C13.1293 8.31442 18.8706 8.31442 22.4117 11.8556L22.8379 12.2818C23.015 12.4588 23.015 12.7459 22.8379 12.9229L21.3801 14.3808C21.2915 14.4693 21.148 14.4693 21.0595 14.3808L20.473 13.7943C18.0026 11.3239 13.9973 11.3239 11.5269 13.7943L10.8989 14.4223C10.8104 14.5109 10.6668 14.5109 10.5783 14.4223L9.12041 12.9645C8.94336 12.7875 8.94336 12.5004 9.12041 12.3234L9.58818 11.8556ZM25.4268 14.8706L26.7243 16.1682C26.9013 16.3452 26.9013 16.6323 26.7243 16.8093L20.8737 22.6599C20.6966 22.8371 20.4096 22.8371 20.2325 22.6599L16.0802 18.5076C16.0359 18.4634 15.9641 18.4634 15.9199 18.5076L11.7675 22.6599C11.5905 22.8371 11.3034 22.8371 11.1264 22.66C11.1264 22.66 11.1264 22.6599 11.1264 22.6599L5.27561 16.8092C5.09856 16.6322 5.09856 16.3451 5.27561 16.168L6.57313 14.8706C6.75019 14.6934 7.03726 14.6934 7.21431 14.8706L11.3668 19.023C11.411 19.0672 11.4828 19.0672 11.5271 19.023L15.6793 14.8706C15.8563 14.6934 16.1434 14.6934 16.3205 14.8706L20.473 19.023C20.5172 19.0672 20.589 19.0672 20.6332 19.023L24.7856 14.8706C24.9627 14.6935 25.2498 14.6935 25.4268 14.8706Z",fill:et?"white":"var(--ck-brand-walletConnect)"})}),MetaMask=({background:et=!1,...o})=>jsxRuntimeExports.jsxs("svg",{...o,style:et?{background:"linear-gradient(0deg, var(--ck-brand-metamask-12), var(--ck-brand-metamask-11))",borderRadius:"27.5%"}:void 0,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("path",{d:"M27.2684 4.03027L17.5018 11.2841L19.3079 7.00442L27.2684 4.03027Z",fill:"var(--ck-brand-metamask-02)",stroke:"var(--ck-brand-metamask-02)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M4.7218 4.03027L14.4099 11.3528L12.6921 7.00442L4.7218 4.03027Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M23.7544 20.8438L21.1532 24.8289L26.7187 26.3602L28.3187 20.9321L23.7544 20.8438Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M3.69104 20.9321L5.28117 26.3602L10.8467 24.8289L8.24551 20.8438L3.69104 20.9321Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.5327 14.1108L8.98181 16.4568L14.5081 16.7022L14.3117 10.7637L10.5327 14.1108Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M21.4576 14.1111L17.6295 10.6953L17.5018 16.7025L23.0182 16.4571L21.4576 14.1111Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.8469 24.8292L14.1647 23.2096L11.2984 20.9717L10.8469 24.8292Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M17.8257 23.2096L21.1531 24.8292L20.6918 20.9717L17.8257 23.2096Z",fill:"var(--ck-brand-metamask-08)",stroke:"var(--ck-brand-metamask-08)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M21.1531 24.8296L17.8257 23.21L18.0906 25.3793L18.0612 26.2921L21.1531 24.8296Z",fill:"var(--ck-brand-metamask-06)",stroke:"var(--ck-brand-metamask-06)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.8469 24.8296L13.9388 26.2921L13.9192 25.3793L14.1647 23.21L10.8469 24.8296Z",fill:"var(--ck-brand-metamask-06)",stroke:"var(--ck-brand-metamask-06)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M13.9877 19.5389L11.2196 18.7242L13.1729 17.8311L13.9877 19.5389Z",fill:"var(--ck-brand-metamask-09)",stroke:"var(--ck-brand-metamask-09)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M18.0023 19.5389L18.8171 17.8311L20.7802 18.7242L18.0023 19.5389Z",fill:"var(--ck-brand-metamask-09)",stroke:"var(--ck-brand-metamask-09)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.8468 24.8289L11.3179 20.8438L8.24561 20.9321L10.8468 24.8289Z",fill:"var(--ck-brand-metamask-03)",stroke:"var(--ck-brand-metamask-03)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M20.6821 20.8438L21.1532 24.8289L23.7544 20.9321L20.6821 20.8438Z",fill:"var(--ck-brand-metamask-03)",stroke:"var(--ck-brand-metamask-03)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M23.0182 16.4565L17.5018 16.7019L18.0122 19.5387L18.827 17.8308L20.7902 18.7239L23.0182 16.4565Z",fill:"var(--ck-brand-metamask-03)",stroke:"var(--ck-brand-metamask-03)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M11.2198 18.7239L13.1829 17.8308L13.9878 19.5387L14.5081 16.7019L8.98181 16.4565L11.2198 18.7239Z",fill:"var(--ck-brand-metamask-03)",stroke:"var(--ck-brand-metamask-03)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M8.98181 16.4565L11.2983 20.9718L11.2198 18.7239L8.98181 16.4565Z",fill:"var(--ck-brand-metamask-10)",stroke:"var(--ck-brand-metamask-10)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M20.7901 18.7239L20.6919 20.9718L23.0181 16.4565L20.7901 18.7239Z",fill:"var(--ck-brand-metamask-10)",stroke:"var(--ck-brand-metamask-10)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M14.508 16.7021L13.9878 19.5389L14.6356 22.886L14.7828 18.4788L14.508 16.7021Z",fill:"var(--ck-brand-metamask-10)",stroke:"var(--ck-brand-metamask-10)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M17.5017 16.7021L17.2367 18.4689L17.3545 22.886L18.0121 19.5389L17.5017 16.7021Z",fill:"var(--ck-brand-metamask-10)",stroke:"var(--ck-brand-metamask-10)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M18.0121 19.5388L17.3545 22.886L17.8257 23.2099L20.6918 20.972L20.79 18.7241L18.0121 19.5388Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M11.2196 18.7241L11.2981 20.972L14.1644 23.2099L14.6355 22.886L13.9877 19.5388L11.2196 18.7241Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M18.0615 26.2917L18.0908 25.3788L17.8455 25.1628H14.145L13.9192 25.3788L13.9388 26.2917L10.8469 24.8291L11.9267 25.7126L14.1155 27.234H17.875L20.0736 25.7126L21.1533 24.8291L18.0615 26.2917Z",fill:"var(--ck-brand-metamask-07)",stroke:"var(--ck-brand-metamask-07)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M17.8258 23.2096L17.3546 22.8857H14.6357L14.1646 23.2096L13.9191 25.379L14.1449 25.163H17.8454L18.0907 25.379L17.8258 23.2096Z",fill:"var(--ck-brand-metamask-04)",stroke:"var(--ck-brand-metamask-04)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M27.6806 11.7552L28.5149 7.75041L27.2683 4.03027L17.8257 11.0387L21.4575 14.1109L26.591 15.6128L27.7296 14.2876L27.2389 13.9342L28.0241 13.2178L27.4156 12.7465L28.2007 12.1478L27.6806 11.7552Z",fill:"var(--ck-brand-metamask-05)",stroke:"var(--ck-brand-metamask-05)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M3.48486 7.75041L4.3192 11.7552L3.78916 12.1478L4.57441 12.7465L3.97566 13.2178L4.7609 13.9342L4.27012 14.2876L5.39892 15.6128L10.5325 14.1109L14.1644 11.0387L4.72164 4.03027L3.48486 7.75041Z",fill:"var(--ck-brand-metamask-05)",stroke:"var(--ck-brand-metamask-05)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M26.591 15.6122L21.4575 14.1104L23.0181 16.4564L20.6919 20.9716L23.7544 20.9323H28.3186L26.591 15.6122Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M10.5326 14.1104L5.39897 15.6122L3.69104 20.9323H8.24551L11.2982 20.9716L8.98168 16.4564L10.5326 14.1104Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M17.5018 16.7018L17.8258 11.0381L19.3177 7.00391H12.6921L14.1645 11.0381L14.5081 16.7018L14.6258 18.4883L14.6356 22.8856H17.3546L17.3742 18.4883L17.5018 16.7018Z",fill:"var(--ck-brand-metamask-01)",stroke:"var(--ck-brand-metamask-01)",strokeWidth:"0.269931",strokeLinecap:"round",strokeLinejoin:"round"})]}),Coinbase=({background:et=!1,...o})=>jsxRuntimeExports.jsxs("svg",{...o,width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("circle",{cx:"10",cy:"10",r:"10",fill:"var(--ck-brand-coinbaseWallet)"}),et&&jsxRuntimeExports.jsx("rect",{rx:"27%",width:"20",height:"20",fill:"var(--ck-brand-coinbaseWallet)"}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.0001 17C13.8661 17 17.0001 13.866 17.0001 10C17.0001 6.13401 13.8661 3 10.0001 3C6.13413 3 3.00012 6.13401 3.00012 10C3.00012 13.866 6.13413 17 10.0001 17ZM8.25012 7.71429C7.95427 7.71429 7.71441 7.95414 7.71441 8.25V11.75C7.71441 12.0459 7.95427 12.2857 8.25012 12.2857H11.7501C12.046 12.2857 12.2858 12.0459 12.2858 11.75V8.25C12.2858 7.95414 12.046 7.71429 11.7501 7.71429H8.25012Z",fill:"white"})]}),Family=({...et})=>jsxRuntimeExports.jsx("svg",{...et,width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{backgroundSize:"100% 100%",backgroundImage:'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAABQGlDQ1BzUDNDAAB4nGNgYHyQk5xbzKLAwJCbV1IU5O6kEBEZpcD+iIGZQYSBk4GPQTYxubjAN9gthAEIihPLi5NLinIYUMC3awyMIPqybkZiXopc+xz3pvOzD4rlWyascy2VY8APuFJSi5OB9B8gVkkuKCphYGAEuoZBqbykAMR2AbJFkjMSU4DsCCBbpwjoQCC7BSSeDmHPALGTIOw1IHZRSJAzkH0AyFZIR2InIbFzc0qToW4AuZ4nNS80GEhzALEMQzFDAIMxgzMONWxgNc5AaMCgCAov9HAoTjM2gujicWJgYL33//9nVQYG9skMDH8n/P//e+H////8GBiYZzEwHBBB6G++z8Bgux/EQoh5AfkbzYHBtBUhpmHBwCDIxcBwoqIgsSgRLMQMxExpmQwMn5YzMPBGMjAIXwDqiQYAOQZcLsEClb4AAGmfSURBVHgB1b0J1G3HVR6497n3/98o6Q0anubBludJeAiTbYwd2gGC6UACBFZY7gVNB3CaJEB3VhbQhNW9OtDQkAYSIOkEGhJCGJrEBGzJkrEsT7Jky5JszXrSexqf3qw3/v891TXsvWvvferce/8nyabrvfPfc+rUqdq166u9d+06pwrP+/CHA3AI8RQRmqFxbyRliVdpcSQ9jj27IASwdAVHVxi7l65hcZAn6NlFdOOce4vCgB5Fc5iXdiN1abSFP1/2PrRoUtiYR/Oy9C9Tr7EwNVc4pwojTDFxC0CMI2nH8hwlhX4D5ZOvWwzy9cHlS8FlzhfwZNlyDN2pPlSXwT0VAtd7yTL8+SDuHOvCzzKdyOButIeuj6HfpTXtu8Ew3WD6NpjnALnFuI1IPB9GK0n5ZiCM9H4GyTJhLqAX1GHZMoJK70Etp0tK4nlhLqBfQF08CFnAgPrN8SHMz0N1YmjluYGwNKDnSeV5DEOnttHnpZ7fKBDyuWJWUHnKqWLUsgyaJ4WbjT2nDv56TCWL6gaw0vklrAv/vpD2mNcWrTpAI00+H9G0G5XWU/1gs8fBSCM1gMq/Y/d9BzD3WiqUpS4zQakyBkDQ6k7HQ5uZi4CgQepphJE66DiuC9PM57lcpsU1auA6Ul1Q1S399o6mF1qXFDq5NbyHqi7QoBmZ5wp8wdn+3G6o6qifRV0vQ3QtbxGwPUbT+RSXeEj/NiUyqQwP5BaIOw8Gl94HAwTKS0viXkk1fejeru02k2+jrNb1gE7d4GA7YwtEYYEtHyhN0HWh6/Q7AQV4bmidPwzDaF00rbpdGnHQqI+vh26LoPjNdQCi3XeAlL7zcaA6g5PYCDBqMup70xahvpK2DkMACmjVvc4904EFApL08dJgAAxVUX3OTEIlFcYYigooPi9fZ0nPtCj6fKPr+2MSD+fUARzNDBCJ0yBR9ZT6qjKC8jRImcxfvuf4b84pLXBdsG1bG94pLSL00i0taHpdP4rv6XnoOiut1aDSaCyYI3AV7aM29KAyc1QwNqSyZ5gHdEcM7kbyaAXfmOYg5vaF2MrQxCzFGFZ3Oj9dH98xPc263t0YQKAdPCA0CHxn1CDo+Z4ysSQvrovTPjkksHCdoLYDtOpCaY3AAZgvYBjABFShWdGfjs7VKcepugSiS3dK/6vt80HHUnVfalA4b2CHDROCG1uDmM87dd4Cgy5HiG1I2OB6uwEC9VhOhxosytZrSSAg2nU9dZ2wRT+MaB+mXwdtd7pD6qJA3ENtQCOxAYZ2d6M+Y3w2dQEL9rntQXXSAGOaO2f+zcACGZVwMRJZ5QtULxE+/OvKHAvTFhMs7bZx5XyOVNZg7kAxT0nkTkmNVNFunoRz6rZXKi4xxvR2YhoDm5ntJRxxroJhBMQtIHe+vj6e8muBTMwKJgFqg/eUV0/8aNWnWRfn/QBV/gDUrh2w0Un9PZMv063axEtfXxehn/JhgdNzHRoDQM2fWiU12Hb3OMyV0K3KeDAbadUA8AQsIDqVRqS1VndOOoCuWCBmIavgdE0MI/D2JCl61eAi7RSYWVWO1Rddp9QN7evQAnk5tJyRUgemknQ6rgMfyozyoNHqfTDo1PWAtkQWuhttxveB6lDqpWtQz7XG0HTqw8fNFF3mOWU+5eKcRNYSG6AN6qk2wNHZKWJPkgqQHstSFZxUpvOJZhTlNaHryQig828AwBFzoFQ0MQ8ziDOYMTGhJ6akhq+gnjGoYWjD8YBEQK0GFbrjAYyD2AAhd6KSFQNZQBCcOMDaTj1wfahjgjU5pB7U2B1UbcPqfCDJuC6qzYxWTPGR3xPTBqm9dD1R6gLAHdO2SSDaU6MJX/u+CA3XMWdES0edk6UzUr14nNDxs/QrfnPlANBSnmkKCsNTQ6gGk+r1A3uR47ykggrmibrWcRbQLOGGErEVqkRT6jjm2qtG5/MJAXwGwajApunhB0QODFrTtECd03VWwmk+1QqEobnBEjrTXkDOkjkBYUIgSHGmkyIaST/wCuCQnk4ETW2TBOSBSei1UkMDcJlFkBBPu0mhnwA6I3BO0nlMs574SrydoRt7Qe0A2VRRYDbjKIVRI6kpvpgcaJWjrkCnC8Wh50I3rkhhdT1RQJ5AZaIBNjZUdqOHDtSub2xEB+5YTpSQM2ApUk0PaA0wEF3Du/qBBcBE1Vnbn1wXAKtxuNzg6qCBrTtlp0FO5Zl0YMHMdeBfDUoteSe+ftxhVVov3TWPQNOv24bbIZ33SaOU81mU4h1pmBkdPEBE6rg6yLgIQAb1fvAbPF0UN5hY0b3GxI+AWYOXwTzRYCYglHN7TzPQgDoUM0QTUCUrSzEl4bCaGTOodhoDPEvr9Gwo5kp+tsOB71ZLpPpb6DYN7+qLyBpJaRwYDqiCrouugx8HxLqzNJ5BBbnutMYT4iUoCYNkBhWTCJrmoBU0heaJ/Or2BlUbMjWAgdww9aCAWOoQUnukMgjY8VgHEBM3g5qvCcAz6vxsZg0EkBIOmsfW5OCEKpGW2PMkM/fwdD51gJ4OAA71GfRmS2oAa9MOJxpIMkOpeJZiufGKqVFUNWSmiS2HKObKhJiuxw8AUMtnerDS5U2nOh6gdMD1YL5hFZYChfpbxwDa/scMBLYnRf1C6aCdgF55CAhMpmWx2vBm4Ad2LMNAnrTa1LW/RkVQvz0SqEmbzLDSOyOAI4E4CyqlTGYAYusz9tiG7uhX28/efQsNoFsJ7aTVIjNDwAkV2CsUxyCepgEIn9MzU8VII6mBTZxu0Mm4LxZgFk9HH9hOLoydEUNnGeCJjpAlQxo4zrB6C/TslkhodLYmWM1R60qgRjAdskq5CuiuYkB0pAZzoQVIqiHVAXPdZoE7axBg8AAraFDTL41ATVsyLRMPaAJz4k+HOJDURZr7+tiKsJZhM7AnwTIjzZN+14nvqdz19BsHjetprBH6iq0krWO8ES5OUouzAut7MQxs78qbagaAIV7hSR2+FwuDSBJPiTHTzsalgqY0us73FSgK07vCQG0OKsIDeQuyT0M1fC82clFjEwZ1aphQ8u9j3myKGFCr+gFJBRiRVtV0AiPhJtToDPTKJwvu5KGRupBUyx0T2EYO1VSCamumDjkDZUqxlA7VG1AHuEPtqr0YRiKHInSqhq0dtQ7WM+VO42DtlCylCdgzoT+QidFl4dLFmGw/0zQ3BvqNQM64i/HrDNqgXsrCOkcR9GA4uPc7FKiH73JQZtq3DNBQXQrMGsgGxJHQBOQVD/RScJVwWCUgWEEjhBYGBlHB1b5ij0Yqm+w1sTeBwIDk4bAN4AdTnZNqbFMycLWZNAUwEk1AQLDNT5PNL1PtSH+oSPbozUgDyYAqJliPfzU41sksYcnNklGm+509WQFNNjSoekDxykwRlLSm9KFAll18bIYBtbuRNsjjGDVucQIl//ZdHiCugRWWeZzUB4lc122OzMnqj0elVVEBHxRd1YbGxswSWneOPrRknjgJzQBeSQXEXlriC4jzgWAGi2xf8UBjU6zohaurcPnmzXDhpk2wfTrN6VJYiww4urYGz545HY8z8FQ8nl9fJ3VTGmad6ElgTnlP2FOAIICBUAEFaAFQzQ0w9r4e3IrXgyVYKEp4c6J902a4YssW2BXrcIGifT0mObJ2Fg6ePQvPpuP0aTg163MjBCqnF7o7GkwFMg0YLKTaMZCEZ5+8FUwMYgxBBniTGDPpap0Sz/PAkbr6aqR9T+T3ZYnvkfYdK6uwQoPztShNj6yvwcHI70OR/wfi71oocnKSNVDRmKklspuuLzRnV12H1L4I1P0K3mKesZoQLRAxwQCgvl0Itl49COKNIBLhBM5tJ+2Lbb+z9zUXScUgJRBHBqxgjVtByEcBeKxsVwBfGFmBsDsy7y07dsDrLjgfrti61fiijXoBG1Lc/pOn4LaDB+ELR4/CExHoE6h2bx6ksInCg8v0r3MAgDqZoDutsZs7HhBSJ8y9IsDO1RV4285d8MZI+1WRdmjQPhYeO3kSPnv4MNx97Dg8d/ZMAW/uOB3Z0oX2DBJkSVht7p5MFxYG0oaBtARWLcJ1wcD+4BA73Ap89a6d8NadO+G6bduk8y0KqaxHnj8Bdx45DPcePw6HI8iZ71nDTAqPOnLfFewEKLosZDv6LCIBtmfXjwCbQd0pHgplJJmDaT9Kt+MjHwk8KzaQ0NAYAPJvNicSgK1kLkeXpfCKiqu2NKu3ItleFpn4zgsvhOu3b4ctkwm8kHB6NovgOJLB/cCJE1k6BG50UDNxoQ5okMSz7rzae6HtzokAuaS7LoL37ZH2V5+3HbZON/w1mwlnorS668hR+EwE94PPP0/mRPWArIdgBl3F2xGMXz6HUA2PjqU0qAF3KGB/VaT5a3ftjkDeAdsi7QHOPSS+fz7Sfnuk/eHIdx6j5MkUoj0da3Tocx233vO9XsxGGUuE6n/n+vo3FLOpvDMCWrtl6mDASWMA671g4HYKzPE+S+gVksgrnQI0VKYmc+JvXroHXhGBPO06eDFDqmgCx588+SQ8dupUUUuIakDGDAABM1uKqEAsPmg2LWg0tCNKte+96kp4RQRFt6REWzakBrvv+PPwB/v3Z9Ok0A7i1eBJojqrCKJ1St1BNA2bUEDSOMTEF0VT4u9ccTm8MWrDTS8y35O34gtHj8EHn34q0r5WXHohmYAgIE6/ZxuA1qBOgF4nQK+HOljWM6UMaDZD+Bp33Xxz0CaHnhmc52NOYNbSeVWBd8VdywCQ7Ll3XXQRvOfii7JkaIWNSosxSCVb+2PPHYQ/fvIJksQo7wME9aAfQ0xATUJAsTETs1L811+4G755z55RbfJi0v6JSPtHDhwgW5VnRosZUj02QTSOJyKra3LzrcZn3x35/k2XXAI7VlfgpaT9yNnE9+ci7c/KmCWZSwLoBFqwYD4bO0MaNM76XtLMwIGaB8TpnREqS795mTvurltuCaJuQzBvvlW7y87wMWjT+aoyMzKQs6nRxQFGBfOUpNv2CIIkHb4q2msvBkOXZfDnjhyB33p0b2Za1j7Kfg5gvTnFi6EnWbJ+jwDu4G9dfjm8ddcu+HLSfmek/T/t2x8HjzOlaQqoxdMR9Dsiyk/bFzAngfM9V14B74yA/nLRnvL89KFD8B8j7Wtk+qUB4zowgIskzucB5HyNJHO6z+aKMT+CMrNC48MHA2iwgz8D6K4TG9hIZgEzCLg3sX0NNOqMBe6Oqu6HrrsWLo+j/40GPSgcY+BY4LTPxFH5P7/vfng+AmNKkpols6TDAuKJPFsAcX40MX7k5S+Di6IHwOcbXkKaOSTT41cfeih6SNbFF6xfudQ0VDdnAcN5UYj841dcD5cpvnvazoXmscGuj9sXTb5/8eBDcCJ1yA5zR0yS+GwC9qzPQD4DUCV1qCA+21vTQ3zxLVDT0XkwyygZ3bsWQC4eBOuLJjuT/bJTSsv2cpIS26YT+B8jIOaBOcw5ACzzwxLpfdqLIxj/yateCTsjLezDLrOWoUz6xCN1wNUcTxM+8cGdEcwfePnLDZiXpWEjNM9Lm9x/P3jttdF2n+aIRHv2HvFv5j/Vg/hfbP0p/Nj1L4dLI99btL0QmmHJuOS+/PFXviK6AKcZC0lIVCFZvDlm4goAzNt/+gDCKGITsymY2Vk5x6HbLoOYZv8Q0cyUsSuLz6eB3paKPWwaH/yxCIjdDhAA4yB8oWEsz+TT/tFIy7YotbJ/FoqfXA9icx1K14etUdP8wHXXRdpXR8v5ctCdQgLlD0RQbyVbMQsNHnhD0pQdTV4V03FTbKvUEa9wbkRd1osdxvJMwuSHIh+3RH5mUCczKJDQwzp/IJNYIRiBarCovEwcPE6rVG4k4BlCfmlHu4D8Sy/sh8xqi1Tf9111VXTUb5HWCvqAL++RQmrg74r2JKT3B/o+D/hEYkDxj2fAxOM7or1/6ZbN0lhfrqMfof2yrVvgu6++Kr8TAQQMkWpQ/L1pliIB5TuvuCLWdcuXnfYW3SlcRXzPcQqU5lVWsO/PdAp7nZPMgxluCnV4pG1JgIGETrf1K5R62rcQRUzNPE1+xB7ee8nF0c+5SzLVFQwNTmuwvxghjFy/OQ7s3hcHeOkLizRb1ZG0Tu8cYF80y7suvhjeSIPXVj4vEomjYYz2115wAXxDpC3RWKamifaYgGl/T/RkfG30j4/l81LS7vPX52+LfH9XpCthIwuTAFkay3Q8VN8/v5ZbDmhaDC1wdwMgq0FhzdD2EHnHFqDOygHbL2UgtXtlJYOCy9Ijz6B+5RysGmkBeyMNEUae4eu3RffbxXGKOvFWXm/MXoEeLki077lk8Py5gOFcaB4rj8+/Mfrvz4/2cT8rHbC8OlDAvCvOuL7z4osG+W2E9hdCcyten39LpP3S1U3lDUEynXhsVj+WAPNujFgIjEXKK3umDCaR3zdBaAE7hQ6UkR7Um1dQ3+LStk5ShcmX+LejykvA4AoxOMNYhdGCXqQ6Abtn6Q3LHbAgPvnA33fl5TCLo+9AhfDvt0Xa03sNPh9Ysuxl6Fg2bav8RNu3RA2TrvI3lUR3mtj45ssugy1q5u/FouNc+Qzu/LyIif82mnKJ1uyfCEraOiBrSZzGb4IxJZH1dQG2KlQjXq7pqvYO/Uph8QTwb5J2aaYnzf69Kc5E+RoGOg/+gJGggM00eft7meAZy9evjur7+jjb10dQJ2CvR4l37bbtMf78QVqfz5crjJX/hl074cpol84izcl0Sr9Xb9sGN+zeJWm/krTPK+/1ke/plYdEM7/fzC9KCZC1V0OeVBIZrEbnIINCbTvbN++GtrQBNhFUZqSi37CfwTuiAz+5YzJTcQnGkgTmY9DjvfSmZzY6uHRF5uPN0aY7G8GcfaKR9q+O6ppnE33ar/QB7vyrI5+TPbq2Pst1+Np43QLyV5pWH59ej/jr0aRLUrr40QO9C88vMhG20L71yVhMQeNUBzOZrxN7/Egvol+2oXMhGVTllcH0rsCbd9XB1DKAA1eWGRx6JKrE6MySdm+hNCPlJkm3ParB9HLQjmjbXRslNkC7cb5SoQWQFF5NLxYl2tNk1us03+ErS/uA38Eerzv/fNgZ+Z60S5bSYSg8BWuUZwuT4OI6j3C9iqjpHfyk8QNW8Zu+8k3S+YZoamzuJpaZDqCtwd4ouAFGvR+BEjMjFqVtSY80A/raHTvh9NpaNjW2OvtT/4LLw9/zYUEfW5i2Va4+ki39mgt2RNrX4U27d2fJt0g6Amyc5jAvrQYqzOlMzgmQbOmviTRnKd0HSay/jClvWllvhuDVu+1kzDdyQ//1lCGpB21upJ6WiHt7GmEzfaqiwgBo91h9T38q5cOoaYJDcoNKp6vg6bkhejwSU18f7U//OuY8UMwDzyIwLpMWRtLo+K+6KJlM6/CGSPsi8J4rzfk6WN7XT9nASqAlAueb3HjrNAaQdesIECZbusWYRBwvrJgcPBhEhwh1qW1oLUoLcPpsbqR3Oa7Zus2+orlMMOIYqKcOogwdfHPgs2ZzREVpid2i6Yrt2+DKaGpcFgcqPixdh69QuChO/FwaeZ7q4MMLpd0IHGXmedNg9Hn368PLIs83T8qSDcnlmIM1ksupLgRdMu2hQ2wsY8CJWnlnFcCfvDCxxXZOg5Mr4/RsNufnSEU5H6slMasPrmyowPb0ttKaHsGnrYehfLz7/a98BWyaTJqS8K9K8OSn8+Si++HXvUZo1/LmnGhXHb8lCJfOM7QvjQ0cC0gfdtx19BgNxIORXg0cm3P5rhBqvQfvcmAjgzCH2rKEVcgumEs2bR6kNwM2fQ5O/XFd+grQfA9hYBer7IRWbUMbApwo8WYIh0u3DT+d+qsEZg7ebEjh4q1bBvc3Srsx/RAA8RyedXlou9nPMbBQ27N5c563KFI6qDqotwiDbetyUgnUpE45A6uiw8iKlvy5ePksP3+wG4BeVezzSygepIqmltC00tql5xNDiQNry+LQeQ7UFXeKAYeGQUu8ZVTruaSFBenH6FgE2IV0NDr9WN4BRm4w/9Hauj5/LZUlPQmqHXFwuN6XGc8cJ5KvpA668jqP0OZANTmCRwC6HqJBXpbVKgPR4ktMZsfO6LIbY0aABpBhhOkuk7JiZTud1BXbWTSqpeq0iJBmXxsN55J2o+mXSQtz0hqgIcylKbQyGbFpwlhGMJBBtU2gzNjmla7y6wdxcIjsqXEfwQawcxojKqR+A4X606QqDyxYaPlXypzX880zVfHgT96NdG5wtRJllmVogkrw5/Ix74gEIddKEyXWQqg2dtBV9OmXCBtI+pKl3UhoDZxxUVqvQkbas4X3VnwrTQrJbzyjl9nSnbqVSC2B1zSEUZpraVO9ZpgRYnrWAvVqOQRqqMtQycIuDTUwhmvd+42QNBfjjGlpHNTPeomsymxJa/ldwgTxfWHs2WUat5UNwNDEOJfgeYwNXrQGS0IDQ2OJCmi54mmw5myNSD/5S3bCDkthvY43Y80WhgYAemZX1uXwRJjtD/ggiSrrytFUJS9Ntdb3g3zsicqfajSo7AgnWjakUV9OOiMo6Y3OjgtOKyiEaknuA7rGsDcd6apcHwZAddoE5jy7LMq9jdx8BNtpuYFawqiBfwFmq6eH8WLzvfTuD+Mnf4zc1wWBAjWG4C/Ubwh9EEB7kMivNkEALLAlU6xfIMfrQ2fOwrygwWKkMcVBsCCE0KDNSxmVN5Fd74V2A+j7Uvw825oBho1ygorXtGObJtN/VL76PuCweB1QlTsgtQHkwQCYCup7MJqMXzBbpKX0SQAYdGauc3BpMAyzPr6+Jt9FzqROdUGg1rs9GZshGHwyn6ZjBGu+lAWoSwHF7KjL2aaIQIXuP3lCAGEc8uAq54HrCmaws1aQ4FoX1X2fDUtIkZbqIS2dg6s8qvOA7lmwwJdrBa65aVs0jKQfpNW9YSRt0M+4zqo7aRPgUPntaWNBpNtM918tBExnVcW0tG+i8eDpM/myeMxC9p7NNNbQdSLXiX2Y2loHVwt+URTM7J9soQCgtkwL8PCxYzZ3lrrQICLYiqP8aUgc5rCTKMF3UXAA1M/qcnF4v2VqoEqLwdanNXtViXb5jkk8Fy9pcTytpFEAb3ouNPhCOy8BH47w3AHID/SDa191a3BtOmX9gX0nnidMlQ8VeACY41AJR6jxY9u7pTynLL7NGryZWDRiP73SVwqoawLnRbiB4xAeTUtYETe0lOW6hFYtVY8HJ0m1JNeSkxvJ8XyYt6LBgEpJHANULdl0owebdlAejv9ii8hGPSUtzEkHVnJL3Rp5SRZhPEsxl9x90xah/SxHDPgPDUHUCEWDB7jr0GGpOO/XUsZpYCS0frfHrO+dC6x77ph3OXSFmkcI5uWU+hJRaeWT6zP40tGjlWBVcZM5MyOoHti6Vs9YOmqcgF3HaSkL4xJSD/JETTcaEjXQwdWlBdRBy4/ELUqLjfLcuQGzT9voOIYVaNvItEGjOAN0V2xwYNHtxGj05Dx8/Hgcd52Bmiw4XLmX0EKbxRrYHYQxTquKgj3MwuEApJbLikS3PP1UW2L6YlABERxjW+USsz1t6PI22l9JNX101H99fOvFG7nm3wD23V2+9s/jgrRjecNIOWP0wkjeisd8H4iPqPjX7Bz+NrWFFgAtkOnnTMBKiw4f3L+/rBFNpq3BWAB5+V+RaPvpYGYo1Hc5Br0xhCaIZcX5YFe+LEtsdfCnjz1e1mv2EgOlzLoCaF/j+De4Hu4ldx+cNACwkhpUgxIgOK2Ol3vQAAo4oIzdw0baMPIcNs7DAqAvQ4dLq4OPF0VsUNEGS4ARgOs2ChbUrUOeDWDGYQkjH3v6aUCqgDYtZgrIjDcWnB6bPgxXS5TBoAO3KhChuurqCv8F1M+cOg23PPkUfOtVV7KWg3pSOaMlMmgm4zDeMFeBeHRgFm8eiAPUX/uvN8Itd98Ljzz9bHmJnAYdQHUCfW5Y0GKVC75OX4GAjgGI6pdGl3yetNLVl1wE3/yWr4L3//V3wJ6dO5qg5mphcKBs1FU/Y9pUxfPGR3oskU4/8sST0YlwHLZu2SQTI7LhKNTtLVodRM65/VT81NOq24l3nLITLOU9Dl54G4mxefPytIfKpIM/2/84vPuyS2HTpLG6KDa4xyBtiASHU0D9S8/pdk2ndzyyF3783/4ePPzMgbL1wuoq1YfBqlbsDB7AwXSa5cKLhWzceCqsMSztUF3n866k2H/4KPzGh2+Gm+66B37m7/4teMdrXmUpZyk6B+iDENrxnkYvqz74+OMZK2kfFiD8yC6yAAN7uXo6lM0DNk0Kxm3H6omEtAUwsi8aRUqXtdgrqvKn5t0EbjvwLHzi2WfhGy+9rPoudal8GhYzh/2ixdNimSRpCPgp7dNHjsBP/s5/gMfi6HnTls3QTTrgr9eFKUEDur3Y4cbDQMYtkR4b58uHgmVU1ygS0KwBR+Ixz8LF2ZS9Bw/Bz/z7P4Y/+MkPwIXnn2coCiOdOYTlu62ZA9BgJto+9tRTcMfBg9CtTq0NjTwwrGt56y9jqmljcaf5YTYNkiZBNhXQVLIAuSxAy4tts0rJ2wuThJ5EUP/SPXfDDbt25w9PTd6qsAANldaQ0uLvbIlrVaf08zt/eVtssCOwGsE8XZlGQE/iDVkCR9nwQWyxcnPcLvurGgyUFS9kKwoAMMsApO/30nINa2uwL0rrf/Whm+Gn/vb7hnVWPAdoyqMBDUGZE14ia1v+udOn4dfv/SL0Xfr6e5K1esDi/O1J89e9cJwLD6qQLQJMVZqk8HSebPAyJEAFcJbUNKuTpTP9TiKAJtMJPB5nDX/v4YfgR1/zWjOy1p0GWtKAJQHdN+mGnXLA2Q994V6YblqBlc2bIh0rmR7eT4VHzWIfkqQmWQ3a1Pr/Q/DbaeQ4GvnJFhRpu7wcn+od22wWB+y5k5+FW+970OQnPGAB4u61QmgkYsmsaWP6/t9H98IXo2t38+bV3DbscgoaxIRP3oexVtjZlp4W0CaH2BlhUEGZfqSK9iSlda8pNkiXiVxJ77hGSfDvHnwQrty2Hb7tqqsNogNn7mgzQlqBGHUicNJApU/k7z9yDFY2rWa7eZpWbsoSgF5L5IKdk1zAremDNsMcKXNDeInSChFOl5PlXPmFtF5cR1I7DeLTNlhpQ6J4/vjhozUrJYb1Ng/6RGNA32e6/edP3u34l3Eg+Cv33AMrqyswjeOrpM2hKwLH+J8DezawmhoIRuhUPljMmlFbq8FEMoeqzvI0JZQtEpAkXsZzUh1RVCdCp2m9iPUz8M/uvANu2L0brti2XTJHpdKQKiGMUi1rOr+Xzq4XiPaJHapLpkZaS3lazA1WU9zri7M+iATQqkyX5XnDHaf1vgNAm4e1OkPI6mLQp9WFjKBd6hwqoHl5NqzGdH5c9u7uijadRFCtr88smMGaFyw4vAbVNDNtehZVDgXmJ54/AT/56U+RwEuAnkRaJlmjyN7lAOKA6D0tMAR0K24KDZ7lc2r0uksnmvqwlObBGm+VkBmWiY5Xqz2cOXMWvufmm+DfvvNdcP35F9AmkZYo6fTEiWDfQm2/3O2AzDSD9Ppim+XdmEKdgSrbKBd7LZUle3SEYkblvLyNpKSSLns0YCsNbjytL9NlgQElNQOnjHOwbBQPdQHxkjDfibwJNOZB40vWRQlQwljZNVp2/3XWAS/X9cSJk/C9N90EZ2K61diRVnhsk9sIaG9G/R50FTS8G5h8Fui0g6Y5hc7c1IMk0lu5PtTVOHPvpzbraEQik6E/nRbTI1XgWLTb/v7Hb4UHjx6pPVcfjpONCaAB4b5Ckm9Z4zcDOm+yQwxjpuV9s9PCuVi2HS4b8WBNg/W8z3sFduZ+jW/FdYP82mnxHNI6OmIdNK25LnIfch3T/bQ7a+nENW1S8XkgNumsKefaQeJY7atGD475DH7pXJTggcOH4e/d9JG8WedqBHI6knTuJp3gSBcZNB3KzNCf/8EgroYpqFGwF0b1RR0U/SNTkYhkhvB+00XChdz5yzYDsBIonwDPnj0N33fLzfBPb/gq+JtXX2PVujNDRFqHBoCVamtpZt2oxT/Oe/uhbFzJEkBLAlMO+g7TkK7YkKI6rWHkBtKCq5BPjzpLvbBmbT9eLVb+kOTgvbtzW3WlA4ArqmVe6JccXbOZKqA7v3HfPvi5z34Wjsfx1OYo2FbjuCZJ5zJQ74rggerVYJdw0fb1qyiRcoxB3wkVhqfMS6cxABrXtQdVYHPv7aUiJbfiwpvStG5B5um1s/Czd3wWnj55Er7r5dfDedGW0iZIAMs548NWNKBOr86RmUEHsIQOxcyozvsuL2ySpTiZF1rFNqXPWMAN3NtI2kacviQuS4fmMb0AHRU/gDs6zR1QR2cV7sHMJsigo3s6sJobYi/H4+jZM/DnceLkf7/jzuzx2kxATho7gVkPTGWvcuqsUi7jF2AgtT1PNG3NhWYM0whY+VyjP5SlDMoItPai6oHA7P7tphORGskaOLO2Dr9y793wx48+Aj/+hhvgXXmd48qcAahYuIVKQ3A0GymtGhDZrMh7pPO0Kt3vOqG9NCC9P0CACE1mgJK6MB40gWGDaeflrdIiEYNQec03i2sVqRN38tyMUicu9L6OVDc2LTy4USdDa1boLD7zzDPwC5+7Ex46djSCeKVI5vg7mRavBsrYpjzBZoN0Iqz1GJC3iJfQeJdDp8fGRVCMqB8nltlEFv/lHY+ySHXeeWVSV2fn7eGeOnUK/sFtH4M3X3gRfHeU1u+4LC0yPjHdrSWB5VqBWDc0qywg27MyivbHBm1ysJkSiO7CgaDz9CDrGvdAXaOLgzlpfZqxMJJ3BXX1bBThwa634oPONjPUmThklU6SmkVgUHQEHQfz+1paV+NjTz4Bf/rww3BrnAVcjUJsS5TKCcjpSJIZp8WrUex3EiAde6CoDEQZ2LIlUDRkQ8DAkK0pND/B4i/BRb2PqMNSKGWJaGbeOJ8M7OzIR7OBZ1p+ay322LsOH4Q7Pvks7Nq0Cb7lqmuixL4Krt+xE7bweyCKaiEFhxI7aNpp8ANYJDX7oYsqq1+r16lV8lMj2spR+lbdze+8+EVpF8VBlYrlHBWJhSPsnWHPQpXQJR3PFmY3a+Jbj9U+cNXrnYT2gQVJAvEjcYLkxsf2ws37H4f90S2XgLs1zgGsxl82MVaS63SiwUzg7IY7+labWZXnGTF2j8LiHde70rih2TDV7uGepCdoGHCFoR1lR5t2pj3Bk786VnatW4Nj62vwOw98CX73/i/Ba3buhn90w1vgDbsvqiNrxUwPbFR08UieX/EKaNcRoW+L6QWroDoGCkAss+iLHlAdRvcwGArPSh89q0yKuWkBqixqgUp5BWyfIdrJHu0oF9GgCNVTRav29B2aF314QoNp4l8Wavprnk8+9QT89r33wL0HD8GZfj0DN5sWUwZx8WQkTxeqyZMwUDGoOiWohgzDSoYhL8zkBJ2bdzncyGIYjLejlCIOfCWpAar3gPPN7xbQQjRp0iNJ6TWoWy3vXtkEb9+zB959xVVw+bbzYOvU7ketgc2VNUKVkYEgHpcisrC6nGQQRINazZScB6qBUjD15iv28zINoOJ1lNYYAezNABbYtmrtvJstQhJX92jdgUHbp2xeUHygjh+g0q5DaERw3F+79DJ444UXw31Ru378ySfh9gPPwoEzp2ETSeTslovnub3JfVqkcjUltMYx5xCknaB5rhpd45TOp55BzaCYY0ZlWlwEqC48oJdlggKNPE47amUvCMCrdu2CvxHt57dGBq120/rJTbDMNLadizNMR6RBBw9AFHjp+WK/seYJkl0gaVwYr9A3KKZVeDv5RtLOS18lGLi6IzC1JZq0ZrruCuDZwigdPNW9LLnVXGc5VPzojqabPGmArdE2fsvFe+Ctl+yBY2tn4IuHDsGH9u+HLx47UvaLx/IFk3QiZRoZ/57vwFxRb+uKhaBxOORgc1CIMGSp//5uUJBIarAtpVpCppbjvws3b4YfuO56+Gu7L8r3+c0q8I/6iwaILT1l4oBGSQPnuwGG0Kt8mxnwCAohoKU1UqfR/dkIEh8C2nuhLRPqPTRpAXU60g3iuAikPVhSS2yFeadJwWreZN50ltRgAayBDfqaeMUvqp2/ugm+bs+l8DUR3HceOgD/5oEH4bkIcp223XnRMQGbKVuxHmqcxvih7RMoX4KjtAC9DxCKqYE4LE5G3iqa7dfEsbQo33dffS18xxVX5+18jUTW57XWVkUH27HBVaA0ElKjkfM+qA7lXtDGvN1mLSuHLpjy0XGnIdeqUBkJvt04Lc5J65WgScPI5tC18iquVQSe8QVaSCYR0NkJCmJN0/8cwChvXo+QvSkyEI0Rb4ua9g07d8EfRz/0H+57nFZUqsANHQg2mnWngpDOMVRXKig8tviSzo0fuiWZwT3APbxcl0LQi3+XSa5U/HNe9Fz85KtfBW+Jg76UfBbA+D39wSG430ERWrqWjRXJBYRgjewuI0kkMNh69I1M2xgdioA5WG4+Pf+uLdvWm7UcKhMABCXycr1ko1qVToPSXgbAI4JEYYmAVuLLuiwwCJtjO3/ftdfB1du3wa8/9CAcm/W84WWdETb2L/+xqo5BDXpQDvP5JyYHKoNbZ8T3cCQbrBlAVYzCk/IhQBxa74l+yZ97zevg2q3bq2sogJHQ5hdqJtzJW0HUpLRbJ35osaeNnletzVIJQEkr1zkVHca8Gr0HTg8uEN1G1CxoLq4o6t+guF7Kqnv1odDGg+L8YlJP2qthjgXNE1ASWl3Ly0hhKGR6dfH2iy6BK7Zug5+OHpEDZ8/mWWQ2c7Rg5NP0spVwQN8DaJsc4kWisQ+03HZa2rLNxSYGQEOKq/cJlE0UmNXx2Uuib/J/ffUb4OqtWwXM/QiY5V3cMGS0x1MLQ0H21sU8wma3ox4to3JXFcb1ogvZzRbAlaFB6wE8L8zrjc30uDBv3dSIxUmHZD4hMUrkS1fbMGutbC90xQ5HrPxXgsT4oYPjf2WjlMPP8cJDoO6njUx//g1vhH941+fhUHTN5o29lamErYqhh7Adh4jJYdxc5bmpj5BfY0JY6YagdpNlVQcsjOoL88npeX5k3v/5ujfl7SqCA7Ps5qWYKcwYntbrUM+Hn2WhSCdWbahsONMiHM8vOoogx0Wy8q9EQP4rAGBxE2rHEMFdUvNsXK5zN7/niI8elHRW9yQdHR1Ld/plMi7dvAV+IYL6A5//HDyfHOFsCmqLAEBwlalDmnFW5UubaPeyEr4pzH2XgxM2l8BqPUeABQJzGgD+WJzW3hPB3Dsga6kMYNWbzm8ecaH1y7NRWkJDxbKWLEkqB6xAyA6+vkqA+XyBNuJH9eNI/EbyCPayaht1M3tVwlDFSGU64g00KyhtElyxaCV15k8Q2ZGD2NRKg/KA8cotW+GHr3sZ/MJDD2QTlN/HblW9OFpxXvVH443JYfdVrg/o32GoAxEkRCbpnDYRev+VV8G74qh3RvyVjx6DVW0M5EWgboGMn5FBEBKQlaRm+rVG4YmXOmaszn+v4kYDLhGvicZzzMPFockbQcxBJYmLAGqMfZBMDuyabjvdETS4fZPoTkpkiCFhNn2C2jbfFN16Xzp+DP746afyhBroBQO5h5hCQMZvdWIsGHb4ybHpUjzGsXviECKi6POmWRkEfssll8rdwYaNAYy7bOA6WzJ47PCAkO3o8oEsyzOa9JFrkPNiawcY2GV/BUMFNO+HbU3A6glRTwhgqKPzx6lKW0q2MJwTGITgzBBqQ7HulPmhxeh/d821cMtzB+Bw3xfes7YIunbBncHgeuzeYFs3YRS0TArbOwYVTPZzP4vM6OEfvex62B0d7t7UGAAbykyWH1mbQzEPYHhuAzUUSSFtS/M1H2VNiI4kujs6d+jnx9K37p1zWlycdkA/A6Q8i4Zm7uz10zTWUF4ocOgd7+e1j1l2IKhz/RuP7ZMV+J+vfxX0eQfZWRlrkVoWM4qaUVNWh3fYanH5nXrjXJ4USVWnseug0Kk9ILdJktDRvnjz+RfAW3fstBUMbXNDshgisxmkh/ruyT/80g37rrCtU8oFWXjKLBHN5gtONh+oPj3kay2LPAtBO283nFY3Zn15B3X7gDSRekYzQ8kxPRWKlS8esADtpgijF8N0rOwkwvHzzXHi5TXbt8M9J54v73uI6w0sr5qmQgAzsYI4tKFReTcqb9BkI7OFRtgr1RbKyjzrsxm8N/ofJzQL6D9Pp6SGgWBya7d/UCUX26kt1QXELK2okYMbrVRgFy8I22KoO3cj4AbMkRczLbbSq9E+irnU0W8gs4C4xun5fWQ2O8AKFD43g/URAHuQ61WuUnHyNT/3XSjaOEpR+PZLL4e77v9iERSqg5VHEDS6ZfYwODMDcWCC1IkVIcy95Ic1XoM5AMggsDCgz+bGZdF2/oY4EBQprA5tZoxJZ31vDNj6XkuSAgNUg5pEmbz8wxKM/LPS4AttaNUxXtKgy7Fl6rZiQAfVGUVrsqKiNmKbuZoxEzCZqnWcA6g5AU0WtinlW/4LfcEB1inzBOqv3r0bLlxZhYNRAOYPQeT9GX7jztY7SAGqrEZbdbBsUGq5UkvgTqYGSee377oQtqaPIIP+LB2Mm24emD0zlr2WjpDaU+xFqIMOusZO2dHs1tMLRstX41jvdapzmOdHDnTn89Jj49rRhnw+llbFo7qHavwQlLEs0hnB2MEBqubTkhX8NcC4hg1Drcn5azxcsLIC3xy9HrM05upDNbnE1aILC0uLkMUv+EOVxmikcwDRDInYtHliNPT/mz17bCXCEMQtZkAjDnWcEqymyugliGtoMTPUr5zSm2qctndpPTGtc4ChzD7XtO5ap0V3L5/yC0n0joShHVUm5rrUtX7eVJONfZQMYSg8WjS2Qu8S6OWY33HRRfBvHtsLOOlLpx18V1d/gzIFw5zy7KZBriba3PDACvKbattnQG+NRL32vAvs5Ik2ORxj5klnVRTRB1Vz+oQaBB3NGKRGS+9Dd0oJyeCKPkmCMnUcnA0HG7B9XfHzQ9hY1rggr/rKXnnpCrlRsIKgY3OEHhETjNfm8HlqQamiF5LiyAoj0lyPn14dsXJB1ObHI3Y6Ze4FJbwG5bNpOBKmJoE/x0Ym6CrN3o1I1FVxNihIPAzUmSbOMyHYrEcFjA4BGpJf1KlSxYoZuQzj1cAqybsRCb1IDPm0sGR6nXaZMlxDy/MdGmbkAS91Ho378kxXPUHs6XBFDMqcd3+cTPMrOLCkwuuiR+y2o4dpJ1l6E3IseHzqXwplYqUlnRq1rMCriM5xaZnWKH6v2LRlkFayCENmhJFffW56Png6hs9l6sh2lKqoypeGxkGvL14P+hpPNXTpAG06TJpavPyMpZVztGXk5yhikNbRUYuiiSKPA9brA8mgvt6RASSozgADb9QYqNHdGhM62toRgUeRaUq8P3woC0R24dVdrtCqaHFV4qBcvh68D+0TDRpGIbMuHl4k9OVbNksluIB+RDpr4C8bWkJs8LwaELHZUdIRc9jNhUoasBpOL3KEKqnH+AKN61Zj4pxrXPD8vLRyHqrJkZtYOX+T1yC9KoryDVa5F7ind50BO7fJAMwAoxLcn7faJwV245mBJ52nwWGfPWRBFv0Z9GgYCscxwSFbUjCDEGqeY8xmKc1M6DMxPVyc3qijAoNmDljmhEa+LWAjjEvqUQZifTFJv/OLyn6uJgY/UtaHkI/vEIcEtK49sQDj4mtR5TaSFlx6+hAY5X4BhJga7JqmRkWZfOqaoIQl4lokzrsXGkcK50+nWRim9+YnQZfB4MGBK9CU5ezp5tt23r2XgRPql9wazGn5liyho4djhQcZyPdcviPXY20ZYAhkfz54hiUzYm04ig+6p2p9T/H5o1pwlQdoistip4Zx0Zry7lRaiVwi30Vp+TrU2V3UqMlx/N5KAQfS8g252syjFhe57VqdGRptRTxsC5eaxC+DwaRO0xp7PUvoOEwPk6pNQGEPsfqdEcwYQYfhV9+ukUKw0XI7aNWhP3+d36vDkBeD66YEp5tjQK51ACijfiA7ml1UoZohQNKqq2BnCnLDIwgUhm6JWgM0XgJHNbq0tefAIh1l0/K9IR0y1ymDXPvqKPtyzFOsobImAwGjBnGohGgrpkFpO4L6mrkGbW6ox4omD7Q8c5AbgiHU7WMLEY0bKgF2j5VQGhCDpdB/5lIWlOmFKHaMn+2HKzxocI+B2l+3znXP9irMlJdmvzITOkA9oWDcc7TgjEiNrvCFyK+DDt0qWHsVYKPkF5LW10yn82AucXnhHiGYOhaPAVDlxy8pM3o6GnSxJ4iYyLf1uzatxWf8uadUSg42Xg8INajX88tsALw9CHIOiA47wfGMsBhq2hRGJlawimNNpDpnYiszAhw4c8YkEGKCajMVWsxyVLTvIaiJhMqknBetDT1w2ynJVDJQkhTppKP3GNEDiIjttN5EW1EESxB1pJKKJXkD2NyKUmZXy0NVvhaX4r7p1HVQC3CoorraYbIZxhMrPDBcFEYb4dyCl7VHzq4De8sEzgFk3ZQCZWw8PcRoCnZQOC8IKIPKS1aLzoBK65uNVUKDG7AthwZFamwFlxiH9Jm2V9PdbC+iXo6KXXUpiQyqUibO5FDpLSEAyki2BIrbTzcTQlMkqLSoOWI6VWjGiVyiupTlFwIYkwP7KsgJ1IHfhR5r9OB+/fmisKDNdLGHzpxWu1yR10xWuwrVtSht28hEheZOsnriodanfjdYrtU9Sv+lo0dMVnodZzHtGrgQ6a3vIQw6pCETxqQ3DwRbElmBAt15Dp27bnFtDAXYiBnrdSNpTc92PdSnTzT2TmLnx6r6KnzH+h2UpMX6bjQzUh1sGnAeVZiBUVgGqBqwpDElmvujA3U69j7/PN1U5QGBG5mkOsAFw6Kg+Ffip/OaDsTBbXnt6CfN2MGjJ07YfCihMRPVvSwV6X6v2xOHNAVdOLTpzUlY+nTki+bGk7fu6Gl97Xs9joEWYOAC8gTMedTcHEsrrYbDDu4DWwyo0BBoYRleST4zF0zd9Bp3TSqDJUeK16BDm2asKuZAe53CHYcO5gUdDVhHtLjGoKePabSbBhGAsfGQDhrg+suHE7N1uOfIEXj1BTtECxtCAYxTnEEN/p76Ne6eMKTDS+rgpHIYvHlGQ/tOZcrJ6btCSUu3tAsLtaoOtaEZ52bGT2hScWj7hC5Hp9Vli6Zr8AD1M4VAZegkBvblDbwAMksK4qeHJhINPz24AgxNFVS0oQK/l3ooJObzew4fhsNnz8KmrZuBNWt5rBpgGi8BxgMX01x9NP/wZwdYkwfu/RDcrCpmoKRnbnrqCXgNAZrHKkiNItovDCnBFsGacfNqY55RElmtcWdEBADZ01Dqgwi23+iPZw0LJI3vqeKCd5qESGqmnZt3GD47SKsBBLXs/NupXsCjcn43lDulAnrvf0EJiwDW5Ajgx2IVzKF2QvMsBzXs+C/7HiNw86KanJXqlNJulqGhD4M4lX2lqV7YIU2NDiY9q3mkrZH/095H4ejaWT0e81ga/Dqa7L0W4+YF5eEQWxoa3+Pxd/z6+73WN4PdyDH2zaD/1m/ed4MbyXtuWqx1oLoGXy64Dx8kfn4QLUhAbbE/KNCKpFYdUoSbki0n19fhpiefzPtKopiHXusODYzABSr6NHC6eRXRBXCGrDL11g98JFto/+mTcOszT1WhCCPA5huuUF7rwRhG0Eg7Qi9wBVlKo3rfOfub6yc/SGDgOJQ0uLGjewFxG8nTHVy3vGKS1EXFq06Kgii0nX6kzduMBSudhwJSNLKAVwnS3K2IhA8/sR/2nnietmmuryWIpA6s+RXQCUDBla1De0sKHYEAowYl1M+XMO9PWDYj/92HH4L3XnZlZig6LonPODgGhhEilJrT9yWJZm4AA+QUiV1tSLZ/6/d7WnzoOo/3ngF/5oSXKq0OIhz0tWJa8YagVHXoARqRumCBGwKMaktUJWozE8DKFv54KE1x/+lje8uGUoQdmfhqcMJYCsr90vrca6nN6wcdklWPTCWhmB2JyNsPHoBPH3g2rxfM9rNIaEUTzFFVnhCDaWyrQjZ/RGNojsoBYNUE1MkHwTlaOhSfscUwn5ZPfdpRhqq0rV+X1uSlz/vWbWI+zRnJjc4C2vCzYqZkyd8aNuqi95fMbFM0yJyWO2575hm47dmnodu8iSQ0vaNNhRQPFZg6t+RaK4jJYfg1gvD6fmopzXx7lmzo1OOmUwiTKfzE7Z+EE2trw3EZDPHVbDgP7jGafLwTCbwCaVZVtF5FGIC8cZAnwHzLR6bAeNpuGN+65vRj9xalbeVtxGCNs68AKPOLhJBrYBh0QNUuGGyctB3/hNq+HbTJOnDqJPzs7Z/JGOmmK1kAajpaUleEk2nnNiQkK1NhegI9UMBKSRRgM4PSlrfRcbIyhSdOn4JfufcusZs6B2JU+TAjhIeoDo4Plr/eQtGVr7OBZD8SEbxoIxoQdEbtobI/669dtEXHDY+WPe7Tdy9aWvYu1WsHXKyTKKCAzfaoB4n8jhyadYM4Hr9ilQUTdaTrP3r0Edh76gR0ar9v+QwuI0pnVvFl5R2aejJm01/jtsMBeOuLSkGii+7S343l4vKHmph73GQ2hX5lFX4v2tJvu/ASeM/lVxq1xhNXKBnTj1J180JL60s+Ipn1OtGd6kUMZLAMFB2KhgeguFPobaQdBGKw7f0ATZni00JFy2ASpzZcHXgQHUGLTRDzA5VNwO7VIDbrkNdGcKibTQsoVHKR6sCSmf1I+vjQY4/Br3/x3gjm1bKpUPZwdCJsRKhKmSisq6apIxrrgBLAezkaDVSXX2UGQ2OmiRidXXeTDOrUA0/F6J/49Cfg8RPHW9pwKLFR52aZGRo3jJRGVQctIsTe6ZR/uhPpXJct6KoYaal4oz+7kYq8GGlV2XPpoLQTdHXRYpK0ledHp+IavOSIlsWH/ly1H4N5oorg86dPPg8/dfunIyYCdKvTMiCcVI9T0BkCmEkfng6pn9LBaOhcHUYuGDRob6OKZ/EfiUxmx2Ql2kfxOBxm8Hdu/At4MlZIqx7+1W0EXB+0jJMylQQPY3Tq4XSngQE0cKV7WHdq4nhxebmGx5EDGgduIP2yaXFeeqRBlJEWYNLXDtM4Wk3ueBoabOZ26kCKGxxT+n306BH4rg9/CA716xkXk2Q7J9OUJbRkCCQwa+sHVRY06Bs0v7s2NrLEMZPSuZ9w6RQSsdiiidBJlNCT1Uh8VC9PnTkD33PTX8ADRw4bKe3bwHTAxZ1R6OXReaGHpVpn3/vN0SVeJJh0xG5wjs5nbQ1F1YFR27rdaFpYKm3XTAsL6bA0DydcbBsBS22aWGHzQgRGsKaHP/ghxpluvwmBin8fPHwI3v+RG+GJU6cyFiarqxkbWUJrDcT0UaMHwhpAo0NhbXsfOhgBSTNoCY1Qu49Bo5bSkfhNqzDdvAqPxQr93QjqG/ftNSqJe3h+NNjyvStJ3Ejuvr7WYBYA53g1KGJpTGqbvR9GbWu1bI5W3Fj6jabFJdP6vMlkEoaWZwIOTZb6+ijV3fFRL//FfGfvRnDto9stS2k6WBN//Mn98L0f/gvYf+Y0TDYXLGTNnSSz0Aa1XRAHps4A7GBp8KEbfbCRUQUMqQP5pY8tOyWBaDfRrGJSr9y0CZ6brcP/8LFb4Ne+8Hk4G8/FAwJOUsOQeSKFg13ERjO6dLBOJFzQnc1LbLpn1sDDZQ5YMl1JixtIu3y+7WPgmlMdeCipARaqPxeUAJUsuO20kEpt+y9jG//AzTfCkX4WBdommCYMrK5kTGAyNzplP3tBKQV6c8QR3cCo9XIggneBYagP1BdPyug7u8LVtkeBE2WTFYtbhhFHjF6P5sc/v+sO+I8P3g8/+7avha+77AroqGdWVUOg1nWDOZpDh86ty6HB5cAMUD69yq3gRs7NkSnfaxHCBBpCUf1dIm2rks20dN2P01FeUIK6vFlHz6e6zpQrb0HAxq/xXiggJwR8dN9j8HOf+VR+BWKyGoG8aSUem/J4aiKejfoWpOSM5aW4YsLWOQ5U9ytGHJCVN8h89R0aFZFzLDM5qKa+q1slqNnxOmLNg5KQPB6g7K0C7Mejn/oHPvpheMeey+F7rn813HDRHtgeGSBVRD26tcQNANJqhdzhnBRj0KBqZE5jnsd2nq3zVhos3JlLqUeKxDeeW3qTG2jYA1TvvHmMykd3Wq0Ng9WGuh8PqkTnZ9bX4RNPPA6/f/+X4PY4A7geTc4E4mxukmROE27JA8ZChds56GxVG/G7JxnHlD40qleJK2G6kEdoMxGzQ14thboXAYRqKrD663jbsSlotdrHnjo7uwY3P/0k3BR79cvPuwDefeXV8O6rXgYv27ELNiW1BNbkgAXnOSgpHJRak0EQn2dSOjvBYEAwYMNyGkLS15dsFvVAk3fAdiO00vYqQlqcwMvCINU12WhZCyW7OQBPJmVtZmy6eqp/TTXo5MTZs7Dv2BH4yGOPwI3xeOLkiTj7F8dOEbwrEcRddgqsFqkcvRri0UD13jNrfmTgwiivREjC/GA3DZITBPvmfbkZ2Mxwb3MHrqn+4lg5+vOCgdk/XRo6/eu7AvY+MmEWzx+Obr2H4szib3/xbrjhwovh+197A3zd5VfDhgMDtkPTgXiWMDhJXc0SVVVss83HLsIqAixuAZ1WnczLW+LJYrB9oHzRXn4Lv+sH4gG8vc0dQX+VrUNo0Hd3lML/4vbb4AsHnoX1DsskSQTylFy1xWU7zWDOQJ6wZGZzIYCxjzletw2otmkxZKSNllpOV2cU5BoHta9fW2C1a/QX0HmwqOhR7qjLz9sE33jJ5fDeK6+BV+68EFYi+oMzM4x6GqW1SmLjV9amBzOqQ/uc/CyHQhyLDHMeWFLM40bSpj9iR6ajr5n02ZAmEzTxJdS6Iw68HABK0IfBcCCH1128B371ve+D+w8diJ6MffDnUcMenK1VIOf3NJyfGSwPeE2QodStLbwRjcjB7LEy/AwBbLycC3KJokBblWC9nVxCZdM/Mt0C8FfX2CO9btrD11xyKXzbZVfCe/ZcASsR7bNQN5rx1VwUcppOgVkDubMvJaEGt3CW69nBUDb5EUZonNM1wsj91j0Yzwtxflpt6HLaPCDsgPe8yRvk9sSLvD8gVp88DYbFdlb28wDkQVEY/yST8IaLL4W3xPb7wJveDB9/5in4w8cfgTuPxrmGSXm/pJPBH4A2NcoMZeE5GlSXOkg6biO91MPgdQAbP1w5qRVK9zbnvKwWybXKb/TdOkjanjiVlOE1286Dn3j5q+DtaR/DvgBY9jNUDB0DdvAHdyQjkbvqjyXah+48MqMKp3NupYrooIgiO4LUDdTdSldJg4oDnq817xeWlmhGereG+V2NDRnz8DYPdrJo6OUII7+ozBJjosRjJZqT74neqvdefgV8/MAz8MsP3RfnHU4W5QCVd0QARTZ+0X16pXgglPjnJEm5njZvclwYkYvcTSEM5IecZYEXKpMTE/JK6D384wjkb4/ejQumq4PdZf1Os5l/oTYoV00kCJEpzB645kDZyQTgfG1n30QikEEq/VMGEIqXUtdQCcAKtIIdFzfCRsKZZtsG0iJotMueNyqS6ShNljpzqLzocCAg+BwaUhpIe7KXk/dM4SPt9Z02rH/Lrt3wh08+Dr+59xE4lRJNwCjCIZi5HIc3w3AcxjfCYLHGEQib3o6NpQ3Mjp6uQxWA9rAj2lX/5JWvgW+95LKs/WYklc0Os6HSMSotGnGmsomU5kQJVIYydjWDU2C7us6lU77BcUP9emnirwchuLS+Zv63kRYdkynfMGhN3TtJCqIaFFKy4A+wgqRXxfAneEyxFNMVUG+N5sj7r7oO9mzaAv9blNbHs9dlonSLpxABYBykLBs8R1ph2krQAngrs0DgZmmuP60qpwhld6weLp6swK+//k3w6u3nZxNDwByUuaHALYAOlo4x2iSQe66+OwwCYuOX5tyQGQq2dTqcwxVY4t5G0uPwXFwX6l4mrZEWgpIlLKor+upileX5Ym3UOrbmZ3QI6sSbHTOlHWbBPvM3on39qvPPgx+9+/PwRHTzsWjX4GTpjKrTDYVUW6gN6IM6tWAOL4sQYKBua9paQ/SFJWamrSo2bYbfueGtAzDro2+B2REcWoeW6MGWbSkFhxtqhczNAGbRlnlYNJxZNpxD2mX6COLwRnNixj9cz/0rBgOtDwp8dF/zno8kmVvteu2W7fCrr78BLkoLmye1TFPLlhrukFWGLzo8jXw05z4HvJxjsyDX0quSUNb73Rzjf/N1b4IrN2+pYO7L0fcwvmWyVn3QALWTBmJzEyDlKwZsdEiSyhKvegO6f8OY8TsvVdp5sRr/ui9WBw4qa0vlxgNk02YDPMt173ivN1RddyBed8e1W7fBb0dPyBagtaB94wEqqylsrP+DqjDwywz+0IlEPyB4VW2lYFCMKVtUhNkMfj7azFdu3poBvM5gdpI5gxvqN7cayPPUod9mOf121FA4QLEmHWGABu6aGMwnYKDOFx0vVdrR9GDrxSc8bezrzQffTrzywqS5lTUdJr6haVP7roXazuuUJv1etmkr/PT1r8wCToN6gF0vPNER3sKnGmS2306ZI5HtbIdlWrlVtkhOYP5AHBi8e/fFUjEBtTv0xucMYgE4wGAHWi+5tdS4dss2KHYYGrFleRHUOJElFplMga6VoMCRAxZc4waePae8pV+GKoFd29kxMXVaSp037HG8Np2l0YFyeyAd6lltcmTJDOVYU3HfEv3W358+x5uVcVXGClHklbwZ3Noq1Yo1wuLXrRoZFdwSBUEbBMVESlskvyqqme+Mg4Je+ZhbPV8kQG+vPWKD+pUSdT5E0jt27C43mvyocAiidSiepjnrErX+2QYrFlzDBp49p7xFyhH9pUe6p+jJUCU9R31TFDYiSPQBVUiYNoDKd/DtF6yEZxD3wQqx74mAvnrTpgzoIJMMWDMUTJ1baAPaZ4g1PkiN1G8oPSrQILCLhP5InMK+cLqpAlnZzTPFjL53IFUMazKTy1MdQXeOH7z0Srgu2ut17epGPQjwQYMXB4leYNhoo5xLIypa1Xsdhluo40udE2+u2bwZvvviy9rjGA9saJsecg8aZkivzA5lelwQvV3/8NqXw2w2K4PEXm0wDgCGD9KrYNgsI6BfOChEWCClGOBU2z5K59dt2w7v2nWRVJQrpE0LPb3N6o7pbOBZ953BoRti12QVfvaKl0cpsBlkyznJQzMrEB898AMMnbLncsBLnD6AbnypR4BBXYJOE5l01epm+PHLrxWBMwsLvEtt7EBotQmDnto15w9qvBSPr9mxC752x84ipUN1OdbC69ziMkFjdKojszkRQrNSOgbliTrNyv7mZDt/Z5w4SSKhNdhoTW97Bo2FIKWWIPtGh+oDTRL7TVvPh//76lfBfzj8LNx04hjsWz9b3u7Ls2MBZEbFuQXqYBEWE8IsWCaElzAtAAE5WAQy4Gn/m0k8rooA/przt8P7d10KO+Lkx3oYd5kOMDZGQgDxG3DQryuke6mMVKX8Bkc8X8UJfOtFe+AThw/n5eOwo0y4QxIOB+MBqPc8G6QZr/zc54Khbiwl9yRmlJIU6R2NZOj3a+tw9XQFfv+Nb4Wt3VTUTFY7oLwZWiipopbqlGgHRfqrCfP5fGfvySCqYRsvwo+wgXnOeVTz1CUcVsV3xrFyWhdhIWGNfILVYPyrJSW3j0jSoDxNUCXuouB5qj+p4+8Lk+Rc6cpMXvo906/D++74FDwXZuo7w5RJZ8c22mMl5gcOC6fQ3tZtNDiZGhTz8vbIM3jHzj2wXfX+BGRjZsBiMGsKsEWCAk2vHkg/HVeqr9O1MgseKrCNlFV5oqNBbrtxCzSJs7QMgmOvATnXqdETmnkpAseEQQvQRlsqU3AWbHuMgVnzReKUlEZVJn9bkLUoS+oE8FCmx7/9kj3wm0/ui2OuXjZ6KjPPAIOGyVEIi4Te+PvQwVLcYnQVA8U266O58b7o2WBm8K+RyP1iMAdXDEtkRY6pL4M6v/mbpA5JZ1ZzvDa2dHpfgKOhiXdsly8NqYGH86VqcHUz5PT1HsC8hGCcA2G8OBEi+lcG51B/Nfh9xwOY3y6jpgfWNpAxFYH6XdHL8hv79kKYTgkYtOmm+WKBrkE34niY/4I/jkVaSBbDvoft0R56RRwQ9r2VBMbPOXi6hnmN0orLL3sqUAeSCtnzgUpCsHRmvsASQQM2OECrziQrbbFBD3Pq1ei4SBfVC1HycvJETK1BXvPAHCyvjaTW5wADIeTzHGsDqQO0EwTVBjKvEEr7vHr7edGWn8Dx7MIjW7qR2+CrtDmFjgO6qU6D+Q2kQ9ldl97ZSB/RejDLyDfUAYNm9Fw1PacOjCEtLVhjZQYqUwOUyTFWPak6g1gBTfZHYWIoE2PChXHpls/RpjP14/yDep46CpepAb3MABpcegYT09gSMqZdXB4Lg2okLXD0hlB6MmYSmfem83bAx44fIQnd1Rfecl4NaQIwt/GW+wSLM/FiRzhTAH11nOI2zApgZv9aDGMA9rA4GFCH2nNR1T+Fju7rdanB9fJWXKtAb37kaIMspWoV6JlWkbzBdQamP9g00ik4bbD1NnnoOLD5mijX0Xr1nO+AXGed91weUcCRa22embKo8Ku3xDmDo4cgKCeDBTAuTwRoQOveYIxUzlSLEBCq2NzI/s0tWw2TmPktuwwABlJkmdACtcRRRjMGOsWZX9daZsDM0b5RqQDhSHDEBKspWCoNaO+H4OOj19KbeaeaQOc94JeOYI0UhvwN7tx3njAn26WDaiCNIoMLrFJ618pqeVUiqK2RWw1l7A4vnapEGF1ON5DI45f5pXrefqSMEqgvXl09J6ZslHEe1PnHixWwDNUiTpsdxmsBMBRPrV/uREoG1AxV52U54B7XhLEnRkwxnT6UTmBkSytoHjQawJM/qFIYz/6cQO2e58O/sZeO5BHLApEJocDv2QudWN8S1PSa5or3pjhCxXyzxc7uBPJyrKrF/7Q0mFvbcwweh9yJmdZBIwZlZzfuWZ0+LKw18NZb1Q1wpKTUoDyv6MCaXKIRejVJ0UKj7jDObhupxvBeWKqvzA1Olw9IDa5T9aqtpjxRQgdrU+ZvS4OKFmpgdLENHdwTvSabDupd2HhUKhLmM/lcwqCXslSkc98pQ+MZnJPvWJwHRl+LFm1g0rPkZomu81BSHdTzHNcaW7SUSIvoMHLOEWO832ibeDDjgnTmmhHu7o7lsSi0AY3zSQmtk/j/bD9rpB420jyh84IDc3TOWKIFiEWNEFS+Bgyq4wiY6ab3agwGfT5/cB1jhLCxDjdicQyfUXTASF6Lgi5Paz7vixYJje2815K5YXo4M9S3nrseabDFEpoNdG1jtDgXw4H03Rice+861zAA7ghKrb1VG0LuKZu49y0W6jNmyarQaDDNrgatetCk+ajBF8bqBjC0+VWn4nGBLr8fo2MD8YvShpEbWpjla1eZo2trdqKLnsqbHcHGQ3sZA+/t0Ht1NVqLXxx//OTz0AxBnhyZcXzhodnwPl4B0WNiEHDeTRATysgSVRizbzApADAwL4LuFOpmcOmXeXndegpgYOJwXPNZeHFDZrcXKmhZe/DMaStZ+I5vUNSN5+6rVza6QYlS1EhmY8THNPcdP9rOQUmkpY6wgbTqWDRRwA0pC3QjyAtLT508XgYbxPBOV1uZMNLowXaUfM+lL8sKQ/2MyjEGNV0ufw8uDVIGCh97jx2SF7DkRSx+bn6zgarOSxsUb5nuFPaePAGAOK6FdMVb9+W6ZLrxL1YG+aLs9bH35EkzA6zbFlzcgkzPOXhADDp+UGCAAoDT62vwU7feCCfXzgy3yZhTzkCdAhg/awZyB+Ir77GCmz9h8p2Ega3rwLQbIEPpdGcj7b92+62wlhaQx9oRDajn0B/ghYPZ8ELFGbrdM3x95+GDwMtL4AtoeH6y8xH+nK+1NMJB4gLq07MZ3HX4kH3DDU2yHIQBYdigoxKW1TLMl8IAI+q1IcH4uP/wAbj38LPw2LGjAzBji3bXQoYOBOvShBYT7XOeZgQHCFQNRuf8WuYjRw7C3QefhYcjMMxWH1jrr/mnJ7n80W/wCHMOUOVKBR1f7z16GI6tr6sNmywP2sbDfNB3vicbZvq8JK1ycgt6u7wA40effdqCYQTUfC70BYB5HVR7DFoEekmsJzs8OBnY6Z3pvBfIU/vyB50373vEbJFhwI2OfvrtB4UrglogpjgvffVvUHXQr7wybXonsdueeAzOhBnc/PhDeaOeCdo3DXGMPGyTvGzABfn5cvnddW0q/dmTT+S94dHZIsVERpMPjuXr7rU/wZL80c6CNbzcslsTrff8n5/cF3vd2YpzsKAGaDBzpCcNJK0CA0uZQXq0z0rHAQUKtRfPegTDBx9/OK9r/JEnH8/7gzDQtQoXm9rTzWVjI16VG3D00VJ1tI0tDYm1ofSmPGlG7EQ0kW6NnTEtKP6XTz2e66K3zht83ADDjq95tdEwT8Nwh2Sa0V2fipL5o88+WRbEz4viE44oB6HTjyLVKTZoqoPCUVGO4FBd+w6DGQuY01cHaW+NTx08INKtpeI1R7TP1khhPtVpggWtJtnYs3T4vqhpYgmdAHHo7Jm8nvEzZ07BbU/vL4DohuobdB1QsUafa3taHbpqZnbP5cv30cWL1ugK3QnQ9xx6FvadeD7TfuDMGfjoE3ulM2pQG23uCYPaDmGePeeO0MjDXxvtAlbz3fLMk/BYHBAWCd3ROtKVIShMrlxo2tjGBOBBoQY16tZxD+pfUzhmwhKg03Zuv/3og1Fa9Haf584x2BXjpzmFIegOxSgNfKQ8AG0dfZnc0FNq+D945AHaT3ElRk7gDx59ANIaHQO6u6G0KwXU8oNli6mLodPfV52iU3XWHUoDuWweG+BPEu0rtNNYPP7r44/k+1NVP94vUH8W5VsQG829TPDmpD40r/QncumYRWz80eN7C16mE6h7lcMAoCBqDsCqe0c0nXeLKWZydbzKHMBK6UjgZw8fhk8ceNbaoyo76bnpYTWAMJILQQZY5gA7AOMgj9JJLrdTQAb1fRv9fjRK589GKVf2AynA+Pyh5+DmaHrkNJ0FtedfRx0MGuuj67FBa5UjbwJ4a85rEk37Sjw+9fST8JkDz5TOmGmfwO3x+rZYp6kCvv7WUuMBHQIzL5VdE9y9sCCNViWylU2ngKzOb33mqYiRg2WV/7RVCdvRhhEOc9Bo7EYYWTlp/AEDcAXsBOZJ2rh+WnYJ/cUv3Q1HkirvhpIGPXMBmpLLd0gtfX16VCdMYl6DEWGw/Vhi7snZGvzS3Z+j7cZou960oGC8+fN33Zk/4vS2aBMcmpOuIoM06K7pOW0nC5hBgRpq2Qmsa5G2n7/r9kxrJ7SXHVp/8Qt3wrGzpwX8GtiirbpGh/L8bPEch+0DFgbVvFC8zr9Q6DgUafs/vvSFrA0TXspq/938Rm0V7KJ0M7haUHBq0qJQIqXGbAfljesjqO8/cQx+66H7TQ9t2XVjzNJBC785nXNIIsLAK8DH7z98P+w9cTyrvdQJ80HnT0Vb+l/fd4+R5gLmDoZmEMAArEYC6mvFtk5dexOpc+VqcP72/V+CJ6LPP29sSkJkQttR74t26Z/sfUjS+kN3Ri/0/CBca00+b74Oy3UAMB4Wz7e0PevvP/IQ7Dt1qmw0lPZi6SZ1E07B05BAnNfoKtTldEe7HxLDVeaoDHSyfdjLUTeuX4V/F23pv4heD89QM2iBBjhgSAo6svw9n0fnmUkdKn1C/2f7HoV/dd+9tO902egmdcQJb0UWj9+4/4vRJNkvdqsxQbBhRvE5qVyhFRtp6DrofEKVnppfbGLw70eeeBx+6767YbJphWznKe3YOy3aJpog/9e9d8EHH3ukLBvAtndXXXrieXD0MG+D8x0HjXZ0fAcwGiXzvquSeaqOD0Us/OsoSDK/eb/vSfFwaKnG66Ogxp2AvB2Ylo6XVA30LqrYwwDGrgl8nW3CCnIGNw8MJxMyPSLBSSX+7BfugPuPHxEpzcAYmCKKud0yAFdpWGoaNY1qMIWlQdPx8LEj8M8+91k4neIJEJM8mJ3IICXFpy+R/6fPfBIeOHJ4KOXAaprW3uVeeosUVucizdSzvizmVwLzQ0ePwM/dcXve4zGbSStTorsjTVNAjvH3FyLfvxTt1Ck9K/ynQ0tQGTAC2MEjtoFrTCN18GCUtcNKVzvjo8ePwk9/7jMZE4nG6YRox44GhYwnICHJjKo49HjTeGWCO/CR0kVrJtJrOK3qRbr1qvuu7vF9pO/h73/qY/DUqeeNlOPKD4DtQO1tuGYcOHBpqaSkUwLzf3/bR+F4nA6ZrGySBU462ksvg2JSpF3aATVtpfBDH/8oPBif0w017WwjzgOzsSvBSmNtVmg7mQ8GQzqePPk8/Eik/XC0n7u8sWWL9kmW0NN4HItt+IGYfv/zxwywWl4Q7QnhJs3XwQK8C/Y+P5eWJBC6QbUvnT8daX//rTfDmSTwWCtOaTBoGlrkp+BPRFhLOjfi8Jq777ZmqTeSsMTJJzLKuDIfNvI6ZbQc2PraOqyfPQuzeKydOg07I/H/z9e/G1523gV1ERq1ao9fxXKMFEt9Za6W7hpszOj90V7+7ls+BIfixEnatndKG0VOaC89pDLSAoJ9JGx97Wykfy3vTb5ndTP8+298D1y6bbssnCOL6GClmd/h0DSHEdqZnZn+INURAE2hStEnjh+Dv3fLTXAg0lRoX420k4RTtCfez/pZoZtov2LTFvj1r3sXXHXe+WZpW1lkJkBzNasgRDqWV9w1B9zaPEudKAmDf/DJKNDiZFvexD7SzzvNdnkTe16irQ5OMsidLc2Se8BMB+rJjh/+4f8F5gXUDzHruDx1DaxeiSiAahvFcDLODP3Row/BVdu2wSsuuADqrBAMTQgYSl4ttb1fU2zkzrrlsrqNx3+JNvMPfvwWeD7Fpf2naQ/qTjZT76qGEW3TSWHHYqf8k0cehiu2b4NX7txR6Waed65DUaWEXufZYfWuTZiJphlrPT6yfx/8yMf/Eg5HbZGBvKlIuMmAdiKEAA4EiuRp+qM4lnlZBPT1519glKqx7xVfEYbnk86acVrbshZc0b8x/qZo7//EZ2+DgyxEEqBXqqmU7WfXuIXvAjBiXrUUKtBUI8wF9NiDgzgEh2eTRNs6DP61KEFujJWcxd/E3G3J3tNMhSG4NXM7BQ593emBlDIzjsXG/K0Hvgi/GAdJZ7ATIBdATCoglC9LQN0RE2mvw1NR69y0b1/+oPOa886D80Zo9+aQNkUMQBqAnlJ8+j0ZJdov3fU5+OV774aTKT7SvbKpRXsnTKu0E7CJiLUofv/8sUdz21x7/vmwPdEOli5PoxEg6toM7qE9eH0+8v1f3veFyPfPw6mYMG9kT6ZQcZFW2mUDUGIceheYs6PngTlHDUyOFEbeAA+ik/oq+vvyxXf169BC1oEWcEzmx/paND3Ws/nBZsjVm7fAT7z+q+Cdey6PDOkG664xGU1KcAh+bYOeiRLhtmefjgOjO2FvtN+K5yKZGKt5AiK7ubqJME73fl7ZMn9aH9X3bD3RT+bTWqrHGlweaf+ZN78Fvv7Sy/KAzK8IZNQ22DpgY9aQ9yzqch49fPqZZ+CffvqTcSr+tKO9uOk6nioeoT0RMiPaZ5n2tczzRPsroqT+4de8Hr7h0itz6WZrEGi76wy9CmsT/qXzNAP4mQNPwy/f8zl44Pnj0RNDAmS1emTy/t9KIxpTg8EdQIHcSWeDg3mA1jf79rIvZhlT/rDR2NIAvKQBr4Bd1rxbz4ydra1npiZw9BEcIca9bfdF8J3XvBzefdmVsGU6ta84wpCxqOpiJEk8PxE7zs3RNfSf47Tqrc8+lScdpnkWjcAgdudEADEaAtAq831enDuDOY0Loh3bn020z+CrL74Y3nfttfBNV12Vpd5gSVq0tOuLTL+yoY9Ge/fWOPv3+w8+CHcefC6q47Qh/JRUdOmIxW/bKdpHVKTQXkGd6M/AjnXoYn1eu2MnfMe1L4f3XH41bIt80qtc8a8Onu9a2xyPPLk9Avl3H7ov0n6gDFizRF6VafmJTHNP8kNDMAOYUT8BGnXB8r1hI9B9vPaeeyrt/EAIlVXaCB8MDivajJSmDhFohfZAA60C7JlIugRqZvY1ccD1jXuugG+/5jp4ZWR2KrQlJTSDS90C3HP4UDZl/mTvI/DM6VNlKpt8s8zQjtR0deRzvii4EJ4BrUUSaBFKBsdaAkcBxSw2YqpLH+m/aus2eOell8L7XnYdvCl2UNmPRPjW6JBQAH3Xc8/Bjfsehz999FF4+vQpmiyZin9cBq5Tol1UNEiDq2ar3CJQ8+ZNBdhr0jHT0sepPa7del7eb/19174MXnXBTuClxlvaUWMuCbG7Dz0Ht0Zf/QejAHni9IncCQvPiwDp2MRIbsWueGOA5ityfmn/9XTSVds5l58L6gSnAuKgpAEUya35mqHKgJYIboMgzW1upLWg7ar9UJpfJHZGcr6OrAQkSd0rEySBOAFhRkdibmJ4ktipEc6PDfrmCy+Ga7afBxdG9X5+sh+JgLWYz/FoXx6MnpO9cTbyzgiIw2tnyjsBNEvJEw1ZKrB7iyRbp2xOgkRFXf6rUVjq03OnTEeiN0vsdalHn4AdwZHqd0Es780XXQTXRFt195bNcEGincpKtuzRqJ0OnY60R8/F5yPtB8+cNTOs2Q+eNEukP7vjplUqi5mhGzV3HKwLs7DJpMxD9twk/s4GtJf6JNp3Rtpft+vC7InavXlzHCes5vXnUogp8uD4udjpHovmxF1RixyJnRrFB86TJVM5Ty5QZD851lFlBm1nB4DJdg7GxKjnDDcWQlxngKGSzYCGVhizo/meA3WGtTJDyAdW05NbLzO2nxWJvb4uUruAYpalSU8bsvRkk4vIMHqvU7OTXQX0ZCqDJlZx7O+UKVbdc1HLzGDrzp0V2Kb2wE6dcVb2CyHaWRsF3gXJ85JUbWrUTDcN7jKQJ9OqSQztRL+g2dPebjutZRI9zPvAZghpzcT7zHfZnaov30XrsZIMygotQhdpDn6Hp+NOyG0y6Spw2dRA6/bRAG4OBFth5N507gMNR7CVZ6yuS/dJdMoH4lyBQFvzpsqnDYUmHc009qUh+8QIZuiMVCRtbxF6JWmG6gZI4qK8utoViUHqLcejArLoTPVrEUKVq4BG6qBZgmA5WFp2swn00zhJQ2BIC75nLUQ7pga/vpfy+Ajtk05evUUBwRzaofFrQgC2eVghs/RLwOr7JB2TCRP5nrXKtPB9VjsrjPGdaJeX8h3txa9M8ZjukX0iLjkE4xoCBWapTwPMWgCN1ruEja0+ajLkxkKoi9xpUEvXjrf7AuJU2QQOJID0XWZiVqWRKazaZTMZ9qAAGCM0k9LV/bxRqWQUkNMLUwbAlXFo6qUrF4oECUGtA106dx7ERTDk1wQS7dRJQ+pM3AFZktPoVvY/UdKg0K20hjmQ7HwE80qlp320UQvRTdonpNozj0t5YdIX2jXfaYJM+J6Obg7tJIUHmlAdAzCjm53WUrpVJTkfB3MK87ek8NcmKS/oSAAQBhCoZRVwECAH0AwuwM62VPo0ui9xxUwJ4vrLwHKjKv0yS/W9FjUIZI8NmCXPcSbYZpjaQAXVaMvQnssk2vtUZho4VrNKz6AuTTv7wVu0E78r7Ypo075YtaVI6hbtSUqHzHfueL3srxdqHTiPIu6HtJP/3ggWJzw8sOvzmnjbHrgAtPPCdID4RZlpTwjSICr34I7AX6RRYQOafJH91KoiWVqTfZx/J50CBVTGUnrJ34AUrY2pQbsIzD54aZCL6/NC7kHVveTYZ6lXBiwh84D3Aay0g6IfLO2IDiScxA1ccQHtWvAgOl5pkms65HwTnV2QjhkE1OD4DoYW4bumXUtZHSevH+pnoKaFeo4D3jfqOicsb3IMCiJQA3diRQ1J7jwY6INdEQgnWU2D8BZFMiCbLZSH2WAueJsDrOo1IKZ8jIRGWwd5RpUpZCqpyvqWO1w2RZj4yQjtQeUFA1ygq8eARlyedqx2jOOXTT+gXQ1YBdx0rbvfwFyaR7t0QAAZ+Ml9UJ1X5aE6wQsFcwpTjbVmUBWVtHwyCupQJFpKlE0KxewQSJqTVOPGR8pUhFooDGBJgR1UicP54RDQAIBO5QV9XzO2PmJPVQ+sp1ReNjPSNfnaNY8g1A1FSL1L5waiGX2h2KAdXN0U0M11bYpyqfilaWfNwlqS8hCNw3wXcwWE/wGHgsTSrujmarBEVmlqvQCqr/nFBXMKZuNNqxhrvj5/c88wiWznTHxhEtLgShqXMFyaVzFZSYKgGbsMHU6CMYil8QXElZm2fjpXMqW4oQgkgW1+BmgyL6h+tSOivDq3iOZKru2QfM31CqoDapkRTI4cF1Q+NTGbbTJ2z0IGlKSu6ZaiGSzfmc+8KLmhnUAr5ikDGXGw4ZW0G8LAyGydt/hsTI5Bp9C/oma5cCApCwLKoOINgVoqAJJkhjpBg1WKo86EH2MbW2qAhglYiTRSgJlHlqq6Jyn0IxIbGBcQNANMvVnDBKKd0RKU1gJdd8VHLY1atNdzpElBHKWdfwLUzgdEOypeMFSlGZE1iGpXqhwaLWlpr+RZMGvaUfO9EV/4AnYFWBU/aBPEAZDBXfPvtJVoNKAd+fsGQGJCYG5nSwHNLKKuYHBbSxUQ8iruOOyGo3S5E7TMMw/XnmB/VTkCwlDjURAkibI2MqzO/3WdYJB3m3aFTAI5eoDDCO0WiyBodPtTiMQOoaLJPSwQDUMyxWxxJGnazMcgDhtSjsqjVNcxhdvNlbcURmN66+XwROtrf48yKPdUkRrY8uYUWN3AmBB7SW9xQYl0e4wCQV0oqSESQz/fArDPSC/sAa7uwRPD0ockMxfm9iscFINQeRkqregb3nQAtHVo0WzOcQjaUhFgyVnpINoNwGEIalO+ohNgfudjfqqOizAHS63rFib9L92bbjhTbLSWAU8thIWCrHOlgco2HD2jwQ1BD+Ra4qIWjIY2dUuBxdI9TKvlgDEQdJ1QgxqgaigCJPuv2YaeR7uyK5envUkwKAMGzFggKBAx7SLRg8qXaCeAByZg0Mw4LLFFO0e0OiBWSBth2IBUE2emTBymyxL6XAMDV65BEVh7jICaEykholV6uV0NKA2yprRoE1V/Rhg693F/Txfd6pRMuxoUV6nlM2gV0Cj9y017TqsEi87pXPhO+bQ6oBE+nP9GwLxEOHdAc8HB1boBbNR+WZYaGvgi/eYxcsT+QEePv4HtpMsyzXhwwNPuAMIheDJeGO3nQrce0M2lXZMHG6AdWvSPgNikASvUBnmeO5hTeGGA1gRsANg5WtMtEgSy0h/uOei7MsK4SoTlgTAmIXS80zZMrpSQcNGhnVkz9L8ItGs6WjT6eJ++QTt7c2paR7sZM+j7uDHacUFHWJTWPRZgfpiWdzKU/5Ey1e9D13rj0FdJUjo4aT2UDjZvW+nyE9QFC4eQB5RolEGllU3DlqhRNOtn1L3RJW7RyyVUQABomloZpx1REXj8pX0HjmbK19RaiAaemBnQ7Mod3ENFM+eNdWyQ2cltizUH7o+opLmlGW2nMGmpDYxbF4c0W9IVzTgfdy6PeWmnzDh9Ax0T6qyXTQtgO4GvVKD0qK8BqQJg03K5YGuueA4amrVMUPR48FJa3Umw0iVxaqTcphkkt1J2nbVUpKoGwDbNFG/GMTDkfYnoVL1KJ9kQzahyD5UHmndgylQ059lcrM/pduBidVr0g/OC9ADu+RbNiJYOVQ+NBXR8ZozKfcp78HJSMxNNqAuDwrWKtuLINYh6CtXzXnqbwlpVtfc4b1XVQXLfKXW95tLMZ452uRPCKF0wXqsB7fYe/yyg2WQ3ntaoJcUaQ3urvceq0alpbj3YxAU0y8ts87NvhWYayvuF29Cjpere2mroxjPB3RiIrbFnwOqnpbiyGGBNurmMFg2A42lg7Bl4cWmXPM+R9nk81+rPP78M7Yjzr1+E8P8B0szv+tLrxRwAAAAASUVORK5CYII=")'}}),Trust=({theme:et="light",...o})=>jsxRuntimeExports.jsxs("svg",{...o,width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("rect",{width:"44",height:"44",fill:et==="light"?"var(--ck-brand-trust-02)":"var(--ck-brand-trust-02b)"}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M33.0246 11.8662C33.4096 11.8662 33.774 12.0243 34.0421 12.2925C34.3102 12.5675 34.4615 12.9387 34.4546 13.3168C34.3859 17.4143 34.2277 20.5493 33.9321 23.0312C33.6433 25.5131 33.2102 27.3556 32.5571 28.8475C32.1171 29.8443 31.574 30.6693 30.9346 31.3706C30.0752 32.2987 29.0921 32.9725 28.0196 33.6119C27.561 33.8861 27.0843 34.1568 26.5842 34.4408C25.5172 35.0468 24.3441 35.713 23.0146 36.6025C22.5333 36.9256 21.9077 36.9256 21.4265 36.6025C20.0766 35.7026 18.8879 35.0281 17.8112 34.4173C17.5718 34.2815 17.3379 34.1488 17.109 34.0175C15.8509 33.2887 14.7165 32.5943 13.7265 31.5906C13.0665 30.9306 12.4959 30.1262 12.0421 29.1706C11.4234 27.8918 11.004 26.345 10.6946 24.3443C10.2821 21.67 10.0759 18.1706 10.0002 13.3168C9.99336 12.9387 10.1377 12.5675 10.4059 12.2925C10.674 12.0243 11.0452 11.8662 11.4302 11.8662H12.0215C13.8433 11.8731 17.8652 11.6943 21.344 8.98559C21.8596 8.58683 22.5815 8.58683 23.0971 8.98559C26.5759 11.6943 30.5977 11.8731 32.4265 11.8662H33.0246ZM29.8277 27.9331C30.2746 27.0118 30.6459 25.74 30.9277 23.9112C31.2646 21.725 31.4709 18.755 31.5671 14.7125C29.4221 14.6506 25.7371 14.2381 22.224 11.8731C18.7109 14.2312 15.0259 14.6437 12.8877 14.7125C12.9633 18.0537 13.1146 20.6525 13.3552 22.6943C13.6302 25.0181 14.0221 26.5925 14.5102 27.6993C14.8333 28.435 15.1909 28.9643 15.6171 29.4318C16.1877 30.0575 16.9096 30.5731 17.8927 31.1643C18.3005 31.409 18.7502 31.6635 19.2396 31.9406C20.1116 32.4341 21.1099 32.9991 22.224 33.7081C23.3175 33.0107 24.3014 32.4515 25.1633 31.9616C25.4231 31.8139 25.6717 31.6725 25.909 31.5356C27.119 30.8412 28.0127 30.2637 28.6796 29.59C29.1265 29.1293 29.4909 28.6275 29.8277 27.9331Z",fill:et==="light"?"var(--ck-brand-trust-01)":"var(--ck-brand-trust-01b)"})]}),Argent=({...et})=>jsxRuntimeExports.jsxs("svg",{...et,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("rect",{width:"32",height:"32",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M18.3242 7.63647H13.6516C13.4955 7.63647 13.3704 7.76611 13.367 7.92726C13.2726 12.4568 10.9768 16.7559 7.02532 19.8009C6.89986 19.8976 6.87128 20.0792 6.963 20.21L9.69685 24.112C9.78986 24.2448 9.97107 24.2747 10.0986 24.1772C12.5694 22.2856 14.5567 20.0038 15.9879 17.4746C17.4191 20.0038 19.4065 22.2856 21.8773 24.1772C22.0047 24.2747 22.186 24.2448 22.2791 24.112L25.013 20.21C25.1045 20.0792 25.0759 19.8976 24.9506 19.8009C20.999 16.7559 18.7033 12.4568 18.609 7.92726C18.6056 7.76611 18.4803 7.63647 18.3242 7.63647Z",fill:"var(--ck-brand-argent)"})]}),ImToken=({...et})=>jsxRuntimeExports.jsx("svg",{...et,width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:`linear-gradient( 180deg, var(--ck-brand-imtoken-01) 0%, var(--ck-brand-imtoken-02) 100% @@ -854,7 +854,7 @@ from { opacity: 1; transform: scale(1); } input[type="radio"]:not(:disabled), input[type="checkbox"]:not(:disabled), select:not(:disabled) - `),nt=rt[0],ot=rt[rt.length-1],it=tt.key==="Tab"||tt.keyCode===KEYCODE_TAB;it&&(tt.shiftKey?document.activeElement===nt&&(ot.focus(),tt.preventDefault()):document.activeElement===ot&&(nt.focus(),tt.preventDefault()))}}return reactExports.useEffect(()=>(et.current&&(et.current.addEventListener("keydown",o),et.current.focus({preventScroll:!0})),()=>{et.current&&et.current.removeEventListener("keydown",o)}),[]),et}function FocusTrap(et){const o=useFocusTrap();return reactExports.useEffect(()=>{o.current&&o.current.focus({preventScroll:!0})},[]),jsxRuntimeExports.jsx("div",{ref:o,tabIndex:0,children:et.children})}function usePrevious(et,o){const tt=reactExports.useRef({target:et,previous:o});return tt.current.target!==et&&(tt.current.previous=tt.current.target,tt.current.target=et),tt.current.previous}const Context$1=reactExports.createContext(null),ConnectKitThemeProvider=({children:et,theme:o="auto",mode:tt="auto",customTheme:rt})=>{const nt={theme:o,mode:tt,customTheme:rt};return reactExports.createElement(Context$1.Provider,{value:nt},jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:et}))},useThemeContext=()=>{const et=React.useContext(Context$1);if(!et)throw Error("ConnectKitThemeProvider must be inside a Provider.");return et},ExternalLinkIcon=({...et})=>jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{left:0,top:0},...et,children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 4C2.89543 4 2 4.89543 2 6V12C2 13.1046 2.89543 14 4 14H10C11.1046 14 12 13.1046 12 12V9.66667C12 9.11438 12.4477 8.66667 13 8.66667C13.5523 8.66667 14 9.11438 14 9.66667V12C14 14.2091 12.2091 16 10 16H4C1.79086 16 0 14.2091 0 12V6C0 3.79086 1.79086 2 4 2H6.33333C6.88562 2 7.33333 2.44772 7.33333 3C7.33333 3.55228 6.88562 4 6.33333 4H4Z",fill:"currentColor",fillOpacity:.3}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.5 1C9.5 0.447715 9.94772 0 10.5 0H15C15.5523 0 16 0.447715 16 1V5.5C16 6.05228 15.5523 6.5 15 6.5C14.4477 6.5 14 6.05228 14 5.5V3.41421L8.70711 8.70711C8.31658 9.09763 7.68342 9.09763 7.29289 8.70711C6.90237 8.31658 6.90237 7.68342 7.29289 7.29289L12.5858 2H10.5C9.94772 2 9.5 1.55228 9.5 1Z",fill:"currentColor",fillOpacity:.3})]}),AlertIcon=({...et})=>jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"19",height:"18",viewBox:"0 0 19 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.81753 1.60122C7.39283 0.530035 8.46953 0 9.50409 0C10.5507 0 11.6022 0.539558 12.1805 1.59767L18.6047 13.3334C18.882 13.8283 19 14.3568 19 14.8622C19 16.5296 17.7949 18 15.9149 18H3.08514C1.20508 18 0 16.5296 0 14.8622C0 14.3454 0.131445 13.8172 0.405555 13.3379L6.81753 1.60122ZM9.50409 2C9.13355 2 8.77256 2.18675 8.57866 2.54907L8.57458 2.5567L2.14992 14.3166L2.144 14.3268C2.04638 14.4959 2 14.6817 2 14.8622C2 15.5497 2.43032 16 3.08514 16H15.9149C16.5697 16 17 15.5497 17 14.8622C17 14.6681 16.9554 14.4805 16.8588 14.309L16.8529 14.2986L10.4259 2.55741C10.2191 2.1792 9.86395 2 9.50409 2Z",fill:"currentColor"}),jsxRuntimeExports.jsx("path",{d:"M9.5 11.2297C9.01639 11.2297 8.7459 10.9419 8.72951 10.4186L8.60656 6.4157C8.59016 5.88372 8.95902 5.5 9.4918 5.5C10.0164 5.5 10.4016 5.89244 10.3852 6.42442L10.2623 10.4099C10.2377 10.9419 9.96721 11.2297 9.5 11.2297ZM9.5 14.5C8.95082 14.5 8.5 14.0901 8.5 13.5058C8.5 12.9215 8.95082 12.5116 9.5 12.5116C10.0492 12.5116 10.5 12.9128 10.5 13.5058C10.5 14.0988 10.041 14.5 9.5 14.5Z",fill:"currentColor"})]}),DisconnectIcon=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"15",height:"14",viewBox:"0 0 15 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{left:0,top:0},...et,children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 0C1.79086 0 0 1.79086 0 4V10C0 12.2091 1.79086 14 4 14H6C6.55228 14 7 13.5523 7 13C7 12.4477 6.55228 12 6 12H4C2.89543 12 2 11.1046 2 10V4C2 2.89543 2.89543 2 4 2H6C6.55228 2 7 1.55228 7 1C7 0.447715 6.55228 0 6 0H4ZM11.7071 3.29289C11.3166 2.90237 10.6834 2.90237 10.2929 3.29289C9.90237 3.68342 9.90237 4.31658 10.2929 4.70711L11.5858 6H9.5H6C5.44772 6 5 6.44772 5 7C5 7.55228 5.44772 8 6 8H9.5H11.5858L10.2929 9.29289C9.90237 9.68342 9.90237 10.3166 10.2929 10.7071C10.6834 11.0976 11.3166 11.0976 11.7071 10.7071L14.7071 7.70711C15.0976 7.31658 15.0976 6.68342 14.7071 6.29289L11.7071 3.29289Z",fill:"currentColor",fillOpacity:"0.4"})}),TickIcon=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C13.9706 18 18 13.9706 18 9C18 4.02944 13.9706 0 9 0C4.02944 0 0 4.02944 0 9C0 13.9706 4.02944 18 9 18ZM13.274 7.13324C13.6237 6.70579 13.5607 6.07577 13.1332 5.72604C12.7058 5.37632 12.0758 5.43932 11.726 5.86676L7.92576 10.5115L6.20711 8.79289C5.81658 8.40237 5.18342 8.40237 4.79289 8.79289C4.40237 9.18342 4.40237 9.81658 4.79289 10.2071L7.29289 12.7071C7.49267 12.9069 7.76764 13.0128 8.04981 12.9988C8.33199 12.9847 8.59505 12.8519 8.77396 12.6332L13.274 7.13324Z",fill:"currentColor"})}),RetryIconCircle=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M32 16C32 24.8366 24.8366 32 16 32C7.16344 32 0 24.8366 0 16C0 7.16344 7.16344 0 16 0C24.8366 0 32 7.16344 32 16ZM24.5001 8.74263C25.0834 8.74263 25.5563 9.21551 25.5563 9.79883V14.5997C25.5563 15.183 25.0834 15.6559 24.5001 15.6559H19.6992C19.1159 15.6559 18.643 15.183 18.643 14.5997C18.643 14.0164 19.1159 13.5435 19.6992 13.5435H21.8378L20.071 11.8798C20.0632 11.8724 20.0555 11.865 20.048 11.8574C19.1061 10.915 17.8835 10.3042 16.5643 10.1171C15.2452 9.92999 13.9009 10.1767 12.7341 10.82C11.5674 11.4634 10.6413 12.4685 10.0955 13.684C9.54968 14.8994 9.41368 16.2593 9.70801 17.5588C10.0023 18.8583 10.711 20.0269 11.7273 20.8885C12.7436 21.7502 14.0124 22.2582 15.3425 22.336C16.6726 22.4138 17.9919 22.0572 19.1017 21.3199C19.5088 21.0495 19.8795 20.7333 20.2078 20.3793C20.6043 19.9515 21.2726 19.9262 21.7004 20.3228C22.1282 20.7194 22.1534 21.3876 21.7569 21.8154C21.3158 22.2912 20.8176 22.7161 20.2706 23.0795C18.7793 24.0702 17.0064 24.5493 15.2191 24.4448C13.4318 24.3402 11.7268 23.6576 10.3612 22.4998C8.9956 21.3419 8.0433 19.7716 7.6478 18.0254C7.2523 16.2793 7.43504 14.4519 8.16848 12.8186C8.90192 11.1854 10.1463 9.83471 11.7142 8.97021C13.282 8.10572 15.0884 7.77421 16.861 8.02565C18.6282 8.27631 20.2664 9.09278 21.5304 10.3525L23.4439 12.1544V9.79883C23.4439 9.21551 23.9168 8.74263 24.5001 8.74263Z",fill:"currentColor"})}),RetryIcon=({...et})=>jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:[jsxRuntimeExports.jsx("path",{d:"M14.5 2V6H10.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M14 5.66537L10.9899 2.75871C10.0931 1.83853 8.92897 1.24216 7.6729 1.05947C6.41683 0.876774 5.13688 1.11765 4.02592 1.7458C2.91497 2.37395 2.0332 3.35534 1.5135 4.54208C0.993792 5.72883 0.864305 7.05663 1.14455 8.3254C1.42479 9.59418 2.09958 10.7352 3.06724 11.5765C4.03489 12.4178 5.24298 12.9138 6.50946 12.9898C7.77594 13.0657 9.03219 12.7176 10.0889 11.9977C10.4765 11.7337 10.8295 11.4249 11.142 11.0792",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),CopyToClipboardIcon$1=({...et})=>jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:[jsxRuntimeExports.jsx("path",{d:"M14 9.5V7C14 5.89543 13.1046 5 12 5H7C5.89543 5 5 5.89543 5 7V12C5 13.1046 5.89543 14 7 14H9.5",stroke:"var(--ck-body-color-muted)",strokeWidth:"2"}),jsxRuntimeExports.jsx("rect",{x:"10",y:"10",width:"9",height:"9",rx:"2",stroke:"var(--ck-body-color-muted)",strokeWidth:"2"}),jsxRuntimeExports.jsx("path",{d:"M1 3L3 5L7 1",stroke:"var(--ck-body-color)",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})]}),AuthIcon=({...et})=>jsxRuntimeExports.jsx("div",{...et,style:{zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",bottom:0,right:0,background:"#34C759",borderRadius:10,boxShadow:"0 0 0 1.5px var(--background)",width:10,height:10,...et==null?void 0:et.style},children:jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"6",height:"6",viewBox:"0 0 6 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx("path",{d:"M0.75 3L2.25 4.5L5.25 1.5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})});var StatusState;(function(et){et.READY="ready",et.LOADING="loading",et.SUCCESS="success",et.REJECTED="rejected",et.ERROR="error"})(StatusState||(StatusState={}));const SIWEContext=reactExports.createContext(null),useSIWE=({onSignIn:et,onSignOut:o}={})=>{const tt=reactExports.useContext(SIWEContext);if(!tt)return{isSignedIn:!1,data:void 0,status:StatusState.ERROR,error:new Error("useSIWE hook must be inside a SIWEProvider."),isRejected:!1,isError:!0,isLoading:!1,isSuccess:!1,isReady:!1,reset:()=>{},signIn:()=>Promise.reject(),signOut:()=>Promise.reject()};const{session:rt,nonce:nt,status:ot,signOut:it,signIn:st,resetStatus:at}=tt,{address:ct,chainId:lt}=rt.data||{},dt=ct?StatusState.SUCCESS:rt.isLoading||nt.isLoading?StatusState.LOADING:ot,ht=dt===StatusState.LOADING,mt=dt===StatusState.SUCCESS,ft=dt===StatusState.REJECTED,pt=dt===StatusState.ERROR,gt=!ct||nt.isFetching||ht||mt,yt=()=>at(),bt=!!ct;return{isSignedIn:bt,data:bt?{address:ct,chainId:lt}:void 0,status:dt,error:rt.error||nt.error,isRejected:ft,isError:pt,isLoading:ht,isSuccess:mt,isReady:gt,signIn:async()=>{if(!bt){const xt=await st();xt&&(et==null||et(xt))}},signOut:async()=>{bt&&(await it(),o==null||o())},reset:yt}},arAE={connectWallet:"الاتصال بالمحفظة",disconnect:"قطع الاتصال",connected:"متصل",wrongNetwork:"شبكة خاطئة",switchNetworks:"تغيير الشبكات",chainNetwork:"شبكة {{ CHAIN }}",copyToClipboard:"نسخ إلى الحافظة",copyCode:"نسخ الكود",moreInformation:"مزيد من المعلومات",back:"عودة",close:"إغلاق",or:"أو",more:"المزيد",tryAgain:"حاول مجددًا",tryAgainQuestion:"هل نحاول مرة أخرى؟",dontHaveTheApp:"ليس لديك التطبيق؟",scanTheQRCode:"مسح رمز الاستجابة السريعة",useWalletConnectModal:"استخدم نموذج ولِيت‌كنيكت",useModal:"استخدم النموذج",installTheExtension:"تثبيت الإضافة",getWalletName:"الحصول على {{ CONNECTORNAME }}",otherWallets:"محافظ أخرى",learnMore:"تعرف على المزيد",getWallet:"الحصول على محفظة",approveInWallet:"الموافقة في المحفظة",confirmInWallet:"تأكيد في المحفظة",awaitingConfirmation:"بانتظار التأكيد",signIn:"تسجيل الدخول",signOut:"تسجيل الخروج",signedIn:"تم تسجيل الدخول",signedOut:"تم تسجيل الخروج",walletNotConnected:"المحفظة غير متصلة",warnings_walletSwitchingUnsupported:"عذرًا، لا تدعم محفظتك تغيير الشبكات من هذا التطبيق.",warnings_walletSwitchingUnsupportedResolve:"حاول تغيير الشبكات من داخل محفظتك بدلاً من ذلك.",warnings_chainUnsupported:"هذا التطبيق غير متوافق مع الشبكة المتصلة حاليًا.",warnings_chainUnsupportedResolve:"للمتابعة، قم بتغيير الشبكة أو قطع الاتصال.",onboardingScreen_heading:"الحصول على محفظة",onboardingScreen_h1:"ابدأ استكشاف الويب3",onboardingScreen_p:"تعتبر محفظتك بوابتك إلى عوالم إيثريوم، التكنولوجيا السحرية التي تمكن استكشاف الويب3.",onboardingScreen_ctaText:"اختر محفظتك الأولى",onboardingScreen_ctaUrl:"https://ethereum.org/ar/wallets/find-wallet/",aboutScreen_heading:"حول المحافظ",aboutScreen_a_h1:"حافظ على أصولك الرقمية",aboutScreen_a_p:"تمكنك المحافظ من إرسال واستقبال وتخزين والتفاعل مع الأصول الرقمية مثل NFTs ورموز إيثريوم الأخرى.",aboutScreen_b_h1:"وسيلة أفضل لتسجيل الدخول",aboutScreen_b_p:"في تطبيقات العصر الحديث، يمكن استخدام محفظتك كوسيلة سهلة لتسجيل الدخول بدلاً من الحاجة إلى تذكر كلمة مرور.",aboutScreen_c_h1:"استكشاف عالم الويب3",aboutScreen_c_p:"تعتبر محفظتك أداة أساسية تمكنك من استكشاف والمشاركة في عالم الويب3 الذي يتطور بسرعة.",aboutScreen_ctaText:"استزيد من المعرفة",aboutScreen_ctaUrl:"https://ethereum.org/ar/wallets/",connectorsScreen_heading:"الاتصال بالمحفظة",connectorsScreen_newcomer:"ليس لدي محفظة",connectorsScreen_h1:"ما هي المحافظ؟",connectorsScreen_p:"تُستخدم المحافظ لإرسال واستقبال وتخزين الأصول الرقمية. يمكنك الاتصال بمحفظة للتفاعل مع التطبيقات.",mobileConnectorsScreen_heading:"اختر محفظة",scanScreen_heading:"مسح باستخدام الهاتف",scanScreen_heading_withConnector:"مسح باستخدام {{ CONNECTORNAME }}",scanScreen_tooltip_walletConnect:`افتح محفظة تدعم ولِيت‌كنيكت + `),nt=rt[0],ot=rt[rt.length-1],it=tt.key==="Tab"||tt.keyCode===KEYCODE_TAB;it&&(tt.shiftKey?document.activeElement===nt&&(ot.focus(),tt.preventDefault()):document.activeElement===ot&&(nt.focus(),tt.preventDefault()))}}return reactExports.useEffect(()=>(et.current&&(et.current.addEventListener("keydown",o),et.current.focus({preventScroll:!0})),()=>{et.current&&et.current.removeEventListener("keydown",o)}),[]),et}function FocusTrap(et){const o=useFocusTrap();return reactExports.useEffect(()=>{o.current&&o.current.focus({preventScroll:!0})},[]),jsxRuntimeExports.jsx("div",{ref:o,tabIndex:0,children:et.children})}function usePrevious(et,o){const tt=reactExports.useRef({target:et,previous:o});return tt.current.target!==et&&(tt.current.previous=tt.current.target,tt.current.target=et),tt.current.previous}const Context$1=reactExports.createContext(null),ConnectKitThemeProvider=({children:et,theme:o="auto",mode:tt="auto",customTheme:rt})=>{const nt={theme:o,mode:tt,customTheme:rt};return reactExports.createElement(Context$1.Provider,{value:nt},jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:et}))},useThemeContext=()=>{const et=React.useContext(Context$1);if(!et)throw Error("ConnectKitThemeProvider must be inside a Provider.");return et},ExternalLinkIcon=({...et})=>jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{left:0,top:0},...et,children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 4C2.89543 4 2 4.89543 2 6V12C2 13.1046 2.89543 14 4 14H10C11.1046 14 12 13.1046 12 12V9.66667C12 9.11438 12.4477 8.66667 13 8.66667C13.5523 8.66667 14 9.11438 14 9.66667V12C14 14.2091 12.2091 16 10 16H4C1.79086 16 0 14.2091 0 12V6C0 3.79086 1.79086 2 4 2H6.33333C6.88562 2 7.33333 2.44772 7.33333 3C7.33333 3.55228 6.88562 4 6.33333 4H4Z",fill:"currentColor",fillOpacity:.3}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.5 1C9.5 0.447715 9.94772 0 10.5 0H15C15.5523 0 16 0.447715 16 1V5.5C16 6.05228 15.5523 6.5 15 6.5C14.4477 6.5 14 6.05228 14 5.5V3.41421L8.70711 8.70711C8.31658 9.09763 7.68342 9.09763 7.29289 8.70711C6.90237 8.31658 6.90237 7.68342 7.29289 7.29289L12.5858 2H10.5C9.94772 2 9.5 1.55228 9.5 1Z",fill:"currentColor",fillOpacity:.3})]}),AlertIcon=({...et})=>jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"19",height:"18",viewBox:"0 0 19 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.81753 1.60122C7.39283 0.530035 8.46953 0 9.50409 0C10.5507 0 11.6022 0.539558 12.1805 1.59767L18.6047 13.3334C18.882 13.8283 19 14.3568 19 14.8622C19 16.5296 17.7949 18 15.9149 18H3.08514C1.20508 18 0 16.5296 0 14.8622C0 14.3454 0.131445 13.8172 0.405555 13.3379L6.81753 1.60122ZM9.50409 2C9.13355 2 8.77256 2.18675 8.57866 2.54907L8.57458 2.5567L2.14992 14.3166L2.144 14.3268C2.04638 14.4959 2 14.6817 2 14.8622C2 15.5497 2.43032 16 3.08514 16H15.9149C16.5697 16 17 15.5497 17 14.8622C17 14.6681 16.9554 14.4805 16.8588 14.309L16.8529 14.2986L10.4259 2.55741C10.2191 2.1792 9.86395 2 9.50409 2Z",fill:"currentColor"}),jsxRuntimeExports.jsx("path",{d:"M9.5 11.2297C9.01639 11.2297 8.7459 10.9419 8.72951 10.4186L8.60656 6.4157C8.59016 5.88372 8.95902 5.5 9.4918 5.5C10.0164 5.5 10.4016 5.89244 10.3852 6.42442L10.2623 10.4099C10.2377 10.9419 9.96721 11.2297 9.5 11.2297ZM9.5 14.5C8.95082 14.5 8.5 14.0901 8.5 13.5058C8.5 12.9215 8.95082 12.5116 9.5 12.5116C10.0492 12.5116 10.5 12.9128 10.5 13.5058C10.5 14.0988 10.041 14.5 9.5 14.5Z",fill:"currentColor"})]}),DisconnectIcon=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"15",height:"14",viewBox:"0 0 15 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{left:0,top:0},...et,children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 0C1.79086 0 0 1.79086 0 4V10C0 12.2091 1.79086 14 4 14H6C6.55228 14 7 13.5523 7 13C7 12.4477 6.55228 12 6 12H4C2.89543 12 2 11.1046 2 10V4C2 2.89543 2.89543 2 4 2H6C6.55228 2 7 1.55228 7 1C7 0.447715 6.55228 0 6 0H4ZM11.7071 3.29289C11.3166 2.90237 10.6834 2.90237 10.2929 3.29289C9.90237 3.68342 9.90237 4.31658 10.2929 4.70711L11.5858 6H9.5H6C5.44772 6 5 6.44772 5 7C5 7.55228 5.44772 8 6 8H9.5H11.5858L10.2929 9.29289C9.90237 9.68342 9.90237 10.3166 10.2929 10.7071C10.6834 11.0976 11.3166 11.0976 11.7071 10.7071L14.7071 7.70711C15.0976 7.31658 15.0976 6.68342 14.7071 6.29289L11.7071 3.29289Z",fill:"currentColor",fillOpacity:"0.4"})}),TickIcon=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C13.9706 18 18 13.9706 18 9C18 4.02944 13.9706 0 9 0C4.02944 0 0 4.02944 0 9C0 13.9706 4.02944 18 9 18ZM13.274 7.13324C13.6237 6.70579 13.5607 6.07577 13.1332 5.72604C12.7058 5.37632 12.0758 5.43932 11.726 5.86676L7.92576 10.5115L6.20711 8.79289C5.81658 8.40237 5.18342 8.40237 4.79289 8.79289C4.40237 9.18342 4.40237 9.81658 4.79289 10.2071L7.29289 12.7071C7.49267 12.9069 7.76764 13.0128 8.04981 12.9988C8.33199 12.9847 8.59505 12.8519 8.77396 12.6332L13.274 7.13324Z",fill:"currentColor"})}),RetryIconCircle=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M32 16C32 24.8366 24.8366 32 16 32C7.16344 32 0 24.8366 0 16C0 7.16344 7.16344 0 16 0C24.8366 0 32 7.16344 32 16ZM24.5001 8.74263C25.0834 8.74263 25.5563 9.21551 25.5563 9.79883V14.5997C25.5563 15.183 25.0834 15.6559 24.5001 15.6559H19.6992C19.1159 15.6559 18.643 15.183 18.643 14.5997C18.643 14.0164 19.1159 13.5435 19.6992 13.5435H21.8378L20.071 11.8798C20.0632 11.8724 20.0555 11.865 20.048 11.8574C19.1061 10.915 17.8835 10.3042 16.5643 10.1171C15.2452 9.92999 13.9009 10.1767 12.7341 10.82C11.5674 11.4634 10.6413 12.4685 10.0955 13.684C9.54968 14.8994 9.41368 16.2593 9.70801 17.5588C10.0023 18.8583 10.711 20.0269 11.7273 20.8885C12.7436 21.7502 14.0124 22.2582 15.3425 22.336C16.6726 22.4138 17.9919 22.0572 19.1017 21.3199C19.5088 21.0495 19.8795 20.7333 20.2078 20.3793C20.6043 19.9515 21.2726 19.9262 21.7004 20.3228C22.1282 20.7194 22.1534 21.3876 21.7569 21.8154C21.3158 22.2912 20.8176 22.7161 20.2706 23.0795C18.7793 24.0702 17.0064 24.5493 15.2191 24.4448C13.4318 24.3402 11.7268 23.6576 10.3612 22.4998C8.9956 21.3419 8.0433 19.7716 7.6478 18.0254C7.2523 16.2793 7.43504 14.4519 8.16848 12.8186C8.90192 11.1854 10.1463 9.83471 11.7142 8.97021C13.282 8.10572 15.0884 7.77421 16.861 8.02565C18.6282 8.27631 20.2664 9.09278 21.5304 10.3525L23.4439 12.1544V9.79883C23.4439 9.21551 23.9168 8.74263 24.5001 8.74263Z",fill:"currentColor"})}),RetryIcon=({...et})=>jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:[jsxRuntimeExports.jsx("path",{d:"M14.5 2V6H10.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M14 5.66537L10.9899 2.75871C10.0931 1.83853 8.92897 1.24216 7.6729 1.05947C6.41683 0.876774 5.13688 1.11765 4.02592 1.7458C2.91497 2.37395 2.0332 3.35534 1.5135 4.54208C0.993792 5.72883 0.864305 7.05663 1.14455 8.3254C1.42479 9.59418 2.09958 10.7352 3.06724 11.5765C4.03489 12.4178 5.24298 12.9138 6.50946 12.9898C7.77594 13.0657 9.03219 12.7176 10.0889 11.9977C10.4765 11.7337 10.8295 11.4249 11.142 11.0792",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),CopyToClipboardIcon$1=({...et})=>jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:[jsxRuntimeExports.jsx("path",{d:"M14 9.5V7C14 5.89543 13.1046 5 12 5H7C5.89543 5 5 5.89543 5 7V12C5 13.1046 5.89543 14 7 14H9.5",stroke:"var(--ck-body-color-muted)",strokeWidth:"2"}),jsxRuntimeExports.jsx("rect",{x:"10",y:"10",width:"9",height:"9",rx:"2",stroke:"var(--ck-body-color-muted)",strokeWidth:"2"}),jsxRuntimeExports.jsx("path",{d:"M1 3L3 5L7 1",stroke:"var(--ck-body-color)",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})]}),AuthIcon=({...et})=>jsxRuntimeExports.jsx("div",{...et,style:{zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",bottom:0,right:0,background:"#34C759",borderRadius:10,boxShadow:"0 0 0 1.5px var(--background)",width:10,height:10,...et==null?void 0:et.style},children:jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"6",height:"6",viewBox:"0 0 6 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx("path",{d:"M0.75 3L2.25 4.5L5.25 1.5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})});var StatusState;(function(et){et.READY="ready",et.LOADING="loading",et.SUCCESS="success",et.REJECTED="rejected",et.ERROR="error"})(StatusState||(StatusState={}));const SIWEContext=reactExports.createContext(null),useSIWE=({onSignIn:et,onSignOut:o}={})=>{const tt=reactExports.useContext(SIWEContext);if(!tt)return{isSignedIn:!1,data:void 0,status:StatusState.ERROR,error:new Error("useSIWE hook must be inside a SIWEProvider."),isRejected:!1,isError:!0,isLoading:!1,isSuccess:!1,isReady:!1,reset:()=>{},signIn:()=>Promise.reject(),signOut:()=>Promise.reject()};const{session:rt,nonce:nt,status:ot,signOut:it,signIn:st,resetStatus:at}=tt,{address:ct,chainId:lt}=rt.data||{},dt=ct?StatusState.SUCCESS:rt.isLoading||nt.isLoading?StatusState.LOADING:ot,ht=dt===StatusState.LOADING,mt=dt===StatusState.SUCCESS,ft=dt===StatusState.REJECTED,pt=dt===StatusState.ERROR,yt=!ct||nt.isFetching||ht||mt,gt=()=>at(),bt=!!ct;return{isSignedIn:bt,data:bt?{address:ct,chainId:lt}:void 0,status:dt,error:rt.error||nt.error,isRejected:ft,isError:pt,isLoading:ht,isSuccess:mt,isReady:yt,signIn:async()=>{if(!bt){const xt=await st();xt&&(et==null||et(xt))}},signOut:async()=>{bt&&(await it(),o==null||o())},reset:gt}},arAE={connectWallet:"الاتصال بالمحفظة",disconnect:"قطع الاتصال",connected:"متصل",wrongNetwork:"شبكة خاطئة",switchNetworks:"تغيير الشبكات",chainNetwork:"شبكة {{ CHAIN }}",copyToClipboard:"نسخ إلى الحافظة",copyCode:"نسخ الكود",moreInformation:"مزيد من المعلومات",back:"عودة",close:"إغلاق",or:"أو",more:"المزيد",tryAgain:"حاول مجددًا",tryAgainQuestion:"هل نحاول مرة أخرى؟",dontHaveTheApp:"ليس لديك التطبيق؟",scanTheQRCode:"مسح رمز الاستجابة السريعة",useWalletConnectModal:"استخدم نموذج ولِيت‌كنيكت",useModal:"استخدم النموذج",installTheExtension:"تثبيت الإضافة",getWalletName:"الحصول على {{ CONNECTORNAME }}",otherWallets:"محافظ أخرى",learnMore:"تعرف على المزيد",getWallet:"الحصول على محفظة",approveInWallet:"الموافقة في المحفظة",confirmInWallet:"تأكيد في المحفظة",awaitingConfirmation:"بانتظار التأكيد",signIn:"تسجيل الدخول",signOut:"تسجيل الخروج",signedIn:"تم تسجيل الدخول",signedOut:"تم تسجيل الخروج",walletNotConnected:"المحفظة غير متصلة",warnings_walletSwitchingUnsupported:"عذرًا، لا تدعم محفظتك تغيير الشبكات من هذا التطبيق.",warnings_walletSwitchingUnsupportedResolve:"حاول تغيير الشبكات من داخل محفظتك بدلاً من ذلك.",warnings_chainUnsupported:"هذا التطبيق غير متوافق مع الشبكة المتصلة حاليًا.",warnings_chainUnsupportedResolve:"للمتابعة، قم بتغيير الشبكة أو قطع الاتصال.",onboardingScreen_heading:"الحصول على محفظة",onboardingScreen_h1:"ابدأ استكشاف الويب3",onboardingScreen_p:"تعتبر محفظتك بوابتك إلى عوالم إيثريوم، التكنولوجيا السحرية التي تمكن استكشاف الويب3.",onboardingScreen_ctaText:"اختر محفظتك الأولى",onboardingScreen_ctaUrl:"https://ethereum.org/ar/wallets/find-wallet/",aboutScreen_heading:"حول المحافظ",aboutScreen_a_h1:"حافظ على أصولك الرقمية",aboutScreen_a_p:"تمكنك المحافظ من إرسال واستقبال وتخزين والتفاعل مع الأصول الرقمية مثل NFTs ورموز إيثريوم الأخرى.",aboutScreen_b_h1:"وسيلة أفضل لتسجيل الدخول",aboutScreen_b_p:"في تطبيقات العصر الحديث، يمكن استخدام محفظتك كوسيلة سهلة لتسجيل الدخول بدلاً من الحاجة إلى تذكر كلمة مرور.",aboutScreen_c_h1:"استكشاف عالم الويب3",aboutScreen_c_p:"تعتبر محفظتك أداة أساسية تمكنك من استكشاف والمشاركة في عالم الويب3 الذي يتطور بسرعة.",aboutScreen_ctaText:"استزيد من المعرفة",aboutScreen_ctaUrl:"https://ethereum.org/ar/wallets/",connectorsScreen_heading:"الاتصال بالمحفظة",connectorsScreen_newcomer:"ليس لدي محفظة",connectorsScreen_h1:"ما هي المحافظ؟",connectorsScreen_p:"تُستخدم المحافظ لإرسال واستقبال وتخزين الأصول الرقمية. يمكنك الاتصال بمحفظة للتفاعل مع التطبيقات.",mobileConnectorsScreen_heading:"اختر محفظة",scanScreen_heading:"مسح باستخدام الهاتف",scanScreen_heading_withConnector:"مسح باستخدام {{ CONNECTORNAME }}",scanScreen_tooltip_walletConnect:`افتح محفظة تدعم ولِيت‌كنيكت لبدء المسح.`,scanScreen_tooltip_default:"افتح {{ CONNECTORNAME }} على هاتفك للمسح",downloadAppScreen_heading:"الحصول على {{ CONNECTORNAME }}",downloadAppScreen_iosAndroid:`استخدم كاميرا هاتفك للمسح وتنزيله على نظامي iOS أو Android .`,downloadAppScreen_ios:"استخدم كاميرا هاتفك للمسح وتنزيله على نظام iOS.",downloadAppScreen_android:"استخدم كاميرا هاتفك للمسح وتنزيله على نظام Android.",injectionScreen_unavailable_h1:"المتصفح غير مدعوم",injectionScreen_unavailable_p:"لتوصيل محفظتك {{ CONNECTORSHORTNAME }}، قم بتثبيت الإضافة على متصفح {{ SUGGESTEDEXTENSIONBROWSER }}.",injectionScreen_install_h1:"تثبيت {{ CONNECTORNAME }}",injectionScreen_install_p:"لتوصيل محفظتك {{ CONNECTORSHORTNAME }}، قم بتثبيت الإضافة على المتصفح.",injectionScreen_connecting_h1:"طلب الاتصال",injectionScreen_connecting_p:"افتح إضافة المتصفح {{ CONNECTORSHORTNAME }} لتوصيل محفظتك.",injectionScreen_connecting_injected_h1:"طلب الاتصال",injectionScreen_connecting_injected_p:"قبل الطلب من خلال محفظتك للاتصال بتطبيقنا.",injectionScreen_connected_h1:"الاتصال بالفعل",injectionScreen_connected_p:"من الآمن الآن إغلاق هذه النافذة المنبثقة.",injectionScreen_rejected_h1:"تم رفض الطلب",injectionScreen_rejected_p:"لقد قمت برفض الطلب. انقر أعلى للمحاولة مرة أخرى.",injectionScreen_failed_h1:"فشل الاتصال",injectionScreen_failed_p:"عذرًا، حدث خطأ ما. يُرجى المحاولة مرة أخرى للاتصال.",injectionScreen_notconnected_h1:"تسجيل الدخول إلى {{ CONNECTORNAME }}",injectionScreen_notconnected_p:"للمتابعة، يُرجى تسجيل الدخول إلى إضافة {{ CONNECTORNAME }}.",profileScreen_heading:"متصل",switchNetworkScreen_heading:"تبديل الشبكات",signInWithEthereumScreen_tooltip:`أنت غير مسجل الدخول حاليًا إلى هذا التطبيق. @@ -933,7 +933,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C là chủ sở hữu của ví.`,signInWithEthereumScreen_signedOut_p:`Vui lòng ký tin nhắn yêu cầu trên ví của bạn để tiếp tục.`,signInWithEthereumScreen_signedOut_button:"Đăng nhập",signInWithEthereumScreen_signedIn_heading:"Đăng nhập qua Ethereum",signInWithEthereumScreen_signedIn_h1:"Bạn đã xác nhận thành công.",signInWithEthereumScreen_signedIn_p:`Sau khi Đăng xuất bạn sẽ cần xác nhận lại trong làn tiếp theo.`,signInWithEthereumScreen_signedIn_button:"Đăng xuất"},getLocale=et=>{switch(et){case"ee-EE":return eeEE;case"ar-AE":return arAE;case"es-ES":return esES;case"fa-IR":return faIR;case"fr-FR":return frFR;case"ja-JP":return jaJP;case"pt-BR":return ptBR;case"ru-RU":return ruRU;case"zh-CN":return zhCN;case"ca-AD":return caAD;case"tr-TR":return trTR;case"vi-VN":return viVN;default:return enUS}};function useLocales(et){var o,tt;const nt=(tt=(o=useContext().options)===null||o===void 0?void 0:o.language)!==null&&tt!==void 0?tt:"en-US",ot=reactExports.useMemo(()=>getLocale(nt),[nt]);if(!ot)return console.error(`Missing translations for: ${nt}`),`Missing translations for: ${nt}`;const it={};return Object.keys(ot).map(st=>{const at=ot[st];return it[st]=localize(at,et)}),it}const localize=(et,o)=>{let tt=et;return o&&Object.keys(o).forEach(rt=>{tt=tt.replace(new RegExp(`({{ ${rt} }})`,"g"),o[rt])}),replaceMarkdown(tt)},replaceMarkdown=et=>{let o=et;return o=o.split(` -`),o=o.map((tt,rt)=>jsxRuntimeExports.jsxs(React.Fragment,{children:[wrapTags(tt),rtet.split(/(\*\*[^\*]*\*\*)/g).map((rt,nt)=>/(\*\*.*\*\*)/g.test(rt)?jsxRuntimeExports.jsx("strong",{children:rt.replace(/\*\*/g,"")},nt):`${rt}`).map(rt=>typeof rt=="string"?rt.split(/(\[WALLETCONNECTLOGO\])/g).map(nt=>nt==="[WALLETCONNECTLOGO]"?jsxRuntimeExports.jsx("span",{className:"ck-tt-logo",children:jsxRuntimeExports.jsx(Logos.WalletConnect,{})},nt):nt):rt),LOG_LEVEL={debug:10,info:20,warn:30,error:40,none:100},useIsoLayoutEffect=typeof window<"u"&&window.document&&window.document.createElement!==void 0?reactExports.useLayoutEffect:reactExports.useEffect,useFitText=({logLevel:et="info",maxFontSize:o=100,minFontSize:tt=20,onFinish:rt,onStart:nt,resolution:ot=5}={})=>{const it=LOG_LEVEL[et],st=reactExports.useCallback(()=>({calcKey:0,fontSize:o,fontSizePrev:tt,fontSizeMax:o,fontSizeMin:tt}),[o,tt]),at=reactExports.useRef(null),ct=reactExports.useRef(),lt=reactExports.useRef(!1),[dt,ht]=reactExports.useState(st),{calcKey:mt,fontSize:ft,fontSizeMax:pt,fontSizeMin:gt,fontSizePrev:yt}=dt;let bt=null;const[xt]=reactExports.useState(()=>new index$1(()=>{bt=window.requestAnimationFrame(()=>{lt.current||(nt&&nt(),lt.current=!0,ht({...st(),calcKey:mt+1}))})}));reactExports.useEffect(()=>(at.current&&xt.observe(at.current),()=>{bt&&window.cancelAnimationFrame(bt),xt.disconnect()}),[bt,xt]);const vt=at.current&&at.current.innerHTML;return reactExports.useEffect(()=>{mt===0||lt.current||(vt!==ct.current&&(nt&&nt(),ht({...st(),calcKey:mt+1})),ct.current=vt)},[mt,st,vt,nt]),useIsoLayoutEffect(()=>{if(mt===0)return;const Et=Math.abs(ft-yt)<=ot,Ct=!!at.current&&(at.current.scrollHeight>at.current.offsetHeight||at.current.scrollWidth>at.current.offsetWidth),St=Ct&&ft===yt,At=ft>yt;if(Et){St?(lt.current=!1,it<=LOG_LEVEL.info&&console.info(`[use-fit-text] reached \`minFontSize = ${tt}\` without fitting text`)):Ct?ht({fontSize:At?yt:gt,fontSizeMax:pt,fontSizeMin:gt,fontSizePrev:yt,calcKey:mt}):(lt.current=!1,rt&&rt(ft));return}let kt,It=pt,Ot=gt;Ct?(kt=At?yt-ft:gt-ft,It=Math.min(pt,ft)):(kt=At?pt-ft:yt-ft,Ot=Math.max(gt,ft)),ht({calcKey:mt,fontSize:ft+kt/2,fontSizeMax:It,fontSizeMin:Ot,fontSizePrev:ft})},[mt,ft,pt,gt,yt,rt,at,ot]),{fontSize:ft,ref:at}},FitText=({children:et})=>{const[o,tt]=React.useState(!1),{fontSize:rt,ref:nt}=useFitText({logLevel:"none",maxFontSize:100,minFontSize:70,onStart:()=>tt(!0),onFinish:()=>tt(!0)});return jsxRuntimeExports.jsx("div",{ref:nt,style:{visibility:o?"visible":"hidden",fontSize:`${rt}%`,maxHeight:"100%",maxWidth:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:et})};FitText.displayName="FitText";function useConnectors(){const et=useConnectors$1();return et??[]}function useConnector(et,o){const tt=useConnectors();return et==="injected"&&o?tt.find(rt=>rt.id===et&&rt.name===o):et==="injected"?tt.find(rt=>rt.id===et&&rt.name.includes("Injected")):tt.find(rt=>rt.id===et)}function useWalletConnectConnector(){return useConnector("walletConnect")}const useWallet=et=>{const tt=useWallets().find(rt=>rt.id===et);return tt||null},useWallets=()=>{const et=useConnectors(),o=useContext();return et.map(rt=>{var nt,ot;const it=Object.keys(walletConfigs).find(at=>at.split(",").map(ct=>ct.trim()).indexOf(rt.id)!==-1),st={id:rt.id,name:(ot=(nt=rt.name)!==null&&nt!==void 0?nt:rt.id)!==null&&ot!==void 0?ot:rt.type,icon:jsxRuntimeExports.jsx("img",{src:rt.icon,alt:rt.name,width:"100%",height:"100%"}),connector:rt,iconShape:"squircle",isInstalled:rt.type==="mock"||rt.type==="injected"&&rt.id!=="metaMask"||isCoinbaseWalletConnector(rt.id)};if(it){const at=walletConfigs[it];return{...st,iconConnector:rt.icon?jsxRuntimeExports.jsx("img",{src:rt.icon,alt:rt.name,width:"100%",height:"100%"}):void 0,...at}}return st}).filter((rt,nt,ot)=>ot.findIndex(it=>it.id===rt.id)===nt).map(rt=>{var nt,ot;return rt.id==="walletConnect"?{...rt,name:((nt=o.options)===null||nt===void 0?void 0:nt.walletConnectName)||rt.name,shortName:((ot=o.options)===null||ot===void 0?void 0:ot.walletConnectName)||rt.shortName}:rt}).filter((rt,nt,ot)=>!(rt.id==="coinbaseWalletSDK"&&ot.find(it=>it.id==="com.coinbase.wallet"))).filter((rt,nt,ot)=>!((rt.id==="metaMaskSDK"||rt.id==="metaMask")&&ot.find(it=>it.id==="io.metamask"||it.id==="io.metamask.mobile"))).sort((rt,nt)=>{const ot=rt.isInstalled&&isInjectedConnector(rt.connector.type),it=nt.isInstalled&&isInjectedConnector(nt.connector.type);return ot&&!it?-1:!ot&&it?1:0}).sort((rt,nt)=>rt.id==="walletConnect"?1:nt.id==="walletConnect"?-1:0)},ProfileIcon=({isSignedIn:et})=>jsxRuntimeExports.jsxs("div",{style:{position:"relative"},children:[et?jsxRuntimeExports.jsx(AuthIcon,{style:{bottom:-1,right:-1}}):jsxRuntimeExports.jsx("div",{style:{zIndex:2,position:"absolute",top:-2,right:-2,background:"#1A88F8",borderRadius:8,boxShadow:"0 0 0 2px var(--ck-body-background)",width:8,height:8}}),jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{overflow:"visible"},children:[jsxRuntimeExports.jsx("circle",{cx:"10",cy:"10",r:"9",stroke:"currentColor",strokeWidth:"2"}),jsxRuntimeExports.jsx("path",{d:"M16.5 16.775C14.8618 15.0649 12.5552 14 10 14C7.44477 14 5.13825 15.0649 3.5 16.775",stroke:"currentColor",strokeWidth:"2"}),jsxRuntimeExports.jsx("circle",{cx:"10",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"2"})]})]}),InfoIcon=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 11C20 15.9706 15.9706 20 11 20C6.02944 20 2 15.9706 2 11C2 6.02944 6.02944 2 11 2C15.9706 2 20 6.02944 20 11ZM22 11C22 17.0751 17.0751 22 11 22C4.92487 22 0 17.0751 0 11C0 4.92487 4.92487 0 11 0C17.0751 0 22 4.92487 22 11ZM11.6445 12.7051C11.6445 13.1348 11.3223 13.4678 10.7744 13.4678C10.2266 13.4678 9.92578 13.1885 9.92578 12.6191V12.4795C9.92578 11.4268 10.4951 10.8574 11.2686 10.3203C12.2031 9.67578 12.665 9.32129 12.665 8.59082C12.665 7.76367 12.0205 7.21582 11.043 7.21582C10.3232 7.21582 9.80762 7.57031 9.45312 8.16113C9.38282 8.24242 9.32286 8.32101 9.2667 8.39461C9.04826 8.68087 8.88747 8.8916 8.40039 8.8916C8.0459 8.8916 7.66992 8.62305 7.66992 8.15039C7.66992 7.96777 7.70215 7.7959 7.75586 7.61328C8.05664 6.625 9.27051 5.75488 11.1182 5.75488C12.9336 5.75488 14.5234 6.71094 14.5234 8.50488C14.5234 9.7832 13.7822 10.417 12.7402 11.1045C11.999 11.5986 11.6445 11.9746 11.6445 12.5762V12.7051ZM11.9131 15.5625C11.9131 16.1855 11.376 16.6797 10.7529 16.6797C10.1299 16.6797 9.59277 16.1748 9.59277 15.5625C9.59277 14.9395 10.1191 14.4453 10.7529 14.4453C11.3867 14.4453 11.9131 14.9287 11.9131 15.5625Z",fill:"currentColor"})}),CloseIcon=({...et})=>jsxRuntimeExports.jsx(motion.svg,{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{d:"M1 13L13 1M1 1L13 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),BackIcon=({...et})=>jsxRuntimeExports.jsx(motion.svg,{width:9,height:16,viewBox:"0 0 9 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{d:"M8 1L1 8L8 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),contentTransitionDuration=.22,contentVariants$2={initial:{zIndex:2,opacity:0},animate:{opacity:1,scale:1,transition:{duration:contentTransitionDuration*.75,delay:contentTransitionDuration*.25,ease:[.26,.08,.25,1]}},exit:{zIndex:1,opacity:0,pointerEvents:"none",position:"absolute",left:["50%","50%"],x:["-50%","-50%"],transition:{duration:contentTransitionDuration,ease:[.26,.08,.25,1]}}},Modal=({open:et,pages:o,pageId:tt,positionInside:rt,inline:nt,demo:ot,onClose:it,onBack:st,onInfo:at})=>{var ct,lt,dt,ht,mt,ft,pt,gt,yt,bt,xt,vt;const Et=useContext(),Ct=useThemeContext(),St=isMobile(),{isSignedIn:At,reset:kt}=useSIWE(),It=useWallet((ct=Et.connector)===null||ct===void 0?void 0:ct.id),Ot={name:It==null?void 0:It.name,shortName:(lt=It==null?void 0:It.shortName)!==null&<!==void 0?lt:It==null?void 0:It.name,icon:(dt=It==null?void 0:It.iconConnector)!==null&&dt!==void 0?dt:It==null?void 0:It.icon,iconShape:(ht=It==null?void 0:It.iconShape)!==null&&ht!==void 0?ht:"circle",iconShouldShrink:It==null?void 0:It.iconShouldShrink},Nt=useLocales({CONNECTORNAME:Ot==null?void 0:Ot.name}),[Yt,Ft]=useTransition({timeout:160,preEnter:!0,mountOnEnter:!0,unmountOnExit:!0}),Ht=!(Yt==="exited"||Yt==="unmounted"),Qt=Yt==="preEnter"||Yt!=="exiting",Vt=Et.route===routes.CONNECTORS?0:Et.route===routes.DOWNLOAD?2:1,Bt=usePrevious(Vt,Vt);rt||useLockBodyScroll(Ht),usePrevious(tt,tt),reactExports.useEffect(()=>{Ft(et),et&&Kt(void 0)},[et]);const[Wt,jt]=reactExports.useState({width:void 0,height:void 0}),[Xt,Kt]=reactExports.useState(void 0),Pt=Zt=>{const nr={width:Zt==null?void 0:Zt.offsetWidth,height:Zt==null?void 0:Zt.offsetHeight};jt({width:`${nr==null?void 0:nr.width}px`,height:`${nr==null?void 0:nr.height}px`})};let Gt;const tr=reactExports.useCallback(Zt=>{Zt&&(rr.current=Zt,Kt(Xt!==void 0),clearTimeout(Gt),Gt=setTimeout(()=>Kt(!1),360),Pt(Zt))},[et,Xt]),{chain:zt}=useAccount(),{switchChain:lr}=useSwitchChain(),rr=reactExports.useRef(null);reactExports.useEffect(()=>{rr.current&&Pt(rr.current)},[zt,lr,St,At,Et.options,Et.resize]),reactExports.useEffect(()=>{if(!Ht){jt({width:void 0,height:void 0});return}const Zt=nr=>{nr.key==="Escape"&&it&&it()};return document.addEventListener("keydown",Zt),()=>{document.removeEventListener("keydown",Zt)}},[Ht,it]);const Jt={"--height":Wt.height,"--width":Wt.width};function Rt(){return It?!(!It.getWalletConnectDeeplink||It.isInstalled):!1}function Mt(){var Zt;switch(Et.route){case routes.ABOUT:return Nt.aboutScreen_heading;case routes.CONNECT:return Rt()?isWalletConnectConnector((Zt=It==null?void 0:It.connector)===null||Zt===void 0?void 0:Zt.id)?Nt.scanScreen_heading:Nt.scanScreen_heading_withConnector:Ot==null?void 0:Ot.name;case routes.CONNECTORS:return Nt.connectorsScreen_heading;case routes.MOBILECONNECTORS:return Nt.mobileConnectorsScreen_heading;case routes.DOWNLOAD:return Nt.downloadAppScreen_heading;case routes.ONBOARDING:return Nt.onboardingScreen_heading;case routes.PROFILE:return Nt.profileScreen_heading;case routes.SWITCHNETWORKS:return Nt.switchNetworkScreen_heading;case routes.SIGNINWITHETHEREUM:return At?Nt.signInWithEthereumScreen_signedIn_heading:Nt.signInWithEthereumScreen_signedOut_heading;default:return""}}const Ut=jsxRuntimeExports.jsx(ResetContainer,{$useTheme:(mt=ot==null?void 0:ot.theme)!==null&&mt!==void 0?mt:Ct.theme,$useMode:(ft=ot==null?void 0:ot.mode)!==null&&ft!==void 0?ft:Ct.mode,$customTheme:(pt=ot==null?void 0:ot.customTheme)!==null&&pt!==void 0?pt:Ct.customTheme,children:jsxRuntimeExports.jsxs(ModalContainer,{role:"dialog",style:{pointerEvents:Qt?"auto":"none",position:rt?"absolute":void 0},children:[!nt&&jsxRuntimeExports.jsx(BackgroundOverlay,{$active:Qt,onClick:it,$blur:(gt=Et.options)===null||gt===void 0?void 0:gt.overlayBlur}),jsxRuntimeExports.jsxs(Container$7,{style:Jt,initial:!1,children:[jsxRuntimeExports.jsx("div",{style:{pointerEvents:Xt?"all":"none",position:"absolute",top:0,bottom:0,left:"50%",transform:"translateX(-50%)",width:"var(--width)",zIndex:9,transition:"width 200ms ease"}}),jsxRuntimeExports.jsxs(BoxContainer,{className:`${Qt&&"active"}`,children:[jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:((yt=Et.options)===null||yt===void 0?void 0:yt.disclaimer)&&Et.route===routes.CONNECTORS&&jsxRuntimeExports.jsx(DisclaimerBackground,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:0,duration:.2,ease:[.25,.1,.25,1]},children:jsxRuntimeExports.jsx(Disclaimer,{children:jsxRuntimeExports.jsx("div",{children:(bt=Et.options)===null||bt===void 0?void 0:bt.disclaimer})})})}),jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:Et.errorMessage&&jsxRuntimeExports.jsxs(ErrorMessage,{initial:{y:"10%",x:"-50%"},animate:{y:"-100%"},exit:{y:"100%"},transition:{duration:.2,ease:"easeInOut"},children:[jsxRuntimeExports.jsx("span",{children:Et.errorMessage}),jsxRuntimeExports.jsx("div",{onClick:()=>Et.displayError(null),style:{position:"absolute",right:24,top:24,cursor:"pointer"},children:jsxRuntimeExports.jsx(CloseIcon,{})})]})}),jsxRuntimeExports.jsxs(ControllerContainer,{children:[it&&jsxRuntimeExports.jsx(CloseButton,{"aria-label":flattenChildren(Nt.close).toString(),onClick:it,children:jsxRuntimeExports.jsx(CloseIcon,{})}),jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:23,left:20,width:32,height:32},children:jsxRuntimeExports.jsx(AnimatePresence,{children:st?jsxRuntimeExports.jsx(BackButton,{disabled:Xt,"aria-label":flattenChildren(Nt.back).toString(),onClick:st,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:St?0:.1,delay:St?.01:0},children:jsxRuntimeExports.jsx(BackIcon,{})},"backButton"):Et.route===routes.PROFILE&&Et.signInWithEthereum?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!At&&!(!((xt=Et.options)===null||xt===void 0)&&xt.hideTooltips)&&jsxRuntimeExports.jsx(motion.div,{style:{position:"absolute",inset:0,pointerEvents:"none"},initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1,transition:{delay:.5,duration:.2}},exit:{opacity:0,scale:.6,transition:{delay:0,duration:St?0:.1}},children:jsxRuntimeExports.jsx(SignInTooltip,{children:Nt.signInWithEthereumScreen_tooltip})}),jsxRuntimeExports.jsx(SiweButton,{disabled:Xt,"aria-label":Nt.signInWithEthereumScreen_signedOut_heading,onClick:()=>{kt(),Et.setRoute(routes.SIGNINWITHETHEREUM)},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:St?0:.1,delay:St?.01:0},children:jsxRuntimeExports.jsx(ProfileIcon,{isSignedIn:At})},"siweButton")]}):at&&!(!((vt=Et.options)===null||vt===void 0)&&vt.hideQuestionMarkCTA)&&jsxRuntimeExports.jsx(InfoButton,{disabled:Xt,"aria-label":flattenChildren(Nt.moreInformation).toString(),onClick:at,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:St?0:.1,delay:St?.01:0},children:jsxRuntimeExports.jsx(InfoIcon,{})},"infoButton")})})]}),jsxRuntimeExports.jsx(ModalHeading,{children:jsxRuntimeExports.jsx(AnimatePresence,{children:jsxRuntimeExports.jsx(motion.div,{style:{position:"absolute",top:0,bottom:0,left:52,right:52,display:"flex",justifyContent:"center"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:St?0:.17,delay:St?.01:0},children:jsxRuntimeExports.jsx(FitText,{children:Mt()})},`${Et.route}-${At?"signedIn":""}`)})}),jsxRuntimeExports.jsx(InnerContainer$1,{children:Object.keys(o).map(Zt=>{const nr=o[Zt];return jsxRuntimeExports.jsx(Page,{open:Zt===tt,initial:!rt&&Yt!=="entered",enterAnim:Zt===tt?Vt>Bt?"active-scale-up":"active":"",exitAnim:Zt!==tt?Vt{const[st,at]=useTransition({timeout:400,preEnter:!0,initialEntered:o,mountOnEnter:!0,unmountOnExit:!0}),ct=!(st==="exited"||st==="unmounted"),lt=st==="preEnter"||st!=="exiting";return reactExports.useEffect(()=>{at(o)},[o]),ct?jsxRuntimeExports.jsx(PageContainer,{className:`${lt?ot:it}`,style:{animationDuration:tt?"0ms":void 0,animationDelay:tt?"0ms":void 0},children:et}):null},OrDivider=({children:et})=>{const o=useLocales();return jsxRuntimeExports.jsx(TextWithHr,{children:jsxRuntimeExports.jsx("span",{children:et??o.or})})},Graphic=styled(motion.div)` +`),o=o.map((tt,rt)=>jsxRuntimeExports.jsxs(React.Fragment,{children:[wrapTags(tt),rtet.split(/(\*\*[^\*]*\*\*)/g).map((rt,nt)=>/(\*\*.*\*\*)/g.test(rt)?jsxRuntimeExports.jsx("strong",{children:rt.replace(/\*\*/g,"")},nt):`${rt}`).map(rt=>typeof rt=="string"?rt.split(/(\[WALLETCONNECTLOGO\])/g).map(nt=>nt==="[WALLETCONNECTLOGO]"?jsxRuntimeExports.jsx("span",{className:"ck-tt-logo",children:jsxRuntimeExports.jsx(Logos.WalletConnect,{})},nt):nt):rt),LOG_LEVEL={debug:10,info:20,warn:30,error:40,none:100},useIsoLayoutEffect=typeof window<"u"&&window.document&&window.document.createElement!==void 0?reactExports.useLayoutEffect:reactExports.useEffect,useFitText=({logLevel:et="info",maxFontSize:o=100,minFontSize:tt=20,onFinish:rt,onStart:nt,resolution:ot=5}={})=>{const it=LOG_LEVEL[et],st=reactExports.useCallback(()=>({calcKey:0,fontSize:o,fontSizePrev:tt,fontSizeMax:o,fontSizeMin:tt}),[o,tt]),at=reactExports.useRef(null),ct=reactExports.useRef(),lt=reactExports.useRef(!1),[dt,ht]=reactExports.useState(st),{calcKey:mt,fontSize:ft,fontSizeMax:pt,fontSizeMin:yt,fontSizePrev:gt}=dt;let bt=null;const[xt]=reactExports.useState(()=>new index$1(()=>{bt=window.requestAnimationFrame(()=>{lt.current||(nt&&nt(),lt.current=!0,ht({...st(),calcKey:mt+1}))})}));reactExports.useEffect(()=>(at.current&&xt.observe(at.current),()=>{bt&&window.cancelAnimationFrame(bt),xt.disconnect()}),[bt,xt]);const vt=at.current&&at.current.innerHTML;return reactExports.useEffect(()=>{mt===0||lt.current||(vt!==ct.current&&(nt&&nt(),ht({...st(),calcKey:mt+1})),ct.current=vt)},[mt,st,vt,nt]),useIsoLayoutEffect(()=>{if(mt===0)return;const Et=Math.abs(ft-gt)<=ot,Ct=!!at.current&&(at.current.scrollHeight>at.current.offsetHeight||at.current.scrollWidth>at.current.offsetWidth),St=Ct&&ft===gt,At=ft>gt;if(Et){St?(lt.current=!1,it<=LOG_LEVEL.info&&console.info(`[use-fit-text] reached \`minFontSize = ${tt}\` without fitting text`)):Ct?ht({fontSize:At?gt:yt,fontSizeMax:pt,fontSizeMin:yt,fontSizePrev:gt,calcKey:mt}):(lt.current=!1,rt&&rt(ft));return}let kt,It=pt,Nt=yt;Ct?(kt=At?gt-ft:yt-ft,It=Math.min(pt,ft)):(kt=At?pt-ft:gt-ft,Nt=Math.max(yt,ft)),ht({calcKey:mt,fontSize:ft+kt/2,fontSizeMax:It,fontSizeMin:Nt,fontSizePrev:ft})},[mt,ft,pt,yt,gt,rt,at,ot]),{fontSize:ft,ref:at}},FitText=({children:et})=>{const[o,tt]=React.useState(!1),{fontSize:rt,ref:nt}=useFitText({logLevel:"none",maxFontSize:100,minFontSize:70,onStart:()=>tt(!0),onFinish:()=>tt(!0)});return jsxRuntimeExports.jsx("div",{ref:nt,style:{visibility:o?"visible":"hidden",fontSize:`${rt}%`,maxHeight:"100%",maxWidth:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:et})};FitText.displayName="FitText";function useConnectors(){const et=useConnectors$1();return et??[]}function useConnector(et,o){const tt=useConnectors();return et==="injected"&&o?tt.find(rt=>rt.id===et&&rt.name===o):et==="injected"?tt.find(rt=>rt.id===et&&rt.name.includes("Injected")):tt.find(rt=>rt.id===et)}function useWalletConnectConnector(){return useConnector("walletConnect")}const useWallet=et=>{const tt=useWallets().find(rt=>rt.id===et);return tt||null},useWallets=()=>{const et=useConnectors(),o=useContext();return et.map(rt=>{var nt,ot;const it=Object.keys(walletConfigs).find(at=>at.split(",").map(ct=>ct.trim()).indexOf(rt.id)!==-1),st={id:rt.id,name:(ot=(nt=rt.name)!==null&&nt!==void 0?nt:rt.id)!==null&&ot!==void 0?ot:rt.type,icon:jsxRuntimeExports.jsx("img",{src:rt.icon,alt:rt.name,width:"100%",height:"100%"}),connector:rt,iconShape:"squircle",isInstalled:rt.type==="mock"||rt.type==="injected"&&rt.id!=="metaMask"||isCoinbaseWalletConnector(rt.id)};if(it){const at=walletConfigs[it];return{...st,iconConnector:rt.icon?jsxRuntimeExports.jsx("img",{src:rt.icon,alt:rt.name,width:"100%",height:"100%"}):void 0,...at}}return st}).filter((rt,nt,ot)=>ot.findIndex(it=>it.id===rt.id)===nt).map(rt=>{var nt,ot;return rt.id==="walletConnect"?{...rt,name:((nt=o.options)===null||nt===void 0?void 0:nt.walletConnectName)||rt.name,shortName:((ot=o.options)===null||ot===void 0?void 0:ot.walletConnectName)||rt.shortName}:rt}).filter((rt,nt,ot)=>!(rt.id==="coinbaseWalletSDK"&&ot.find(it=>it.id==="com.coinbase.wallet"))).filter((rt,nt,ot)=>!((rt.id==="metaMaskSDK"||rt.id==="metaMask")&&ot.find(it=>it.id==="io.metamask"||it.id==="io.metamask.mobile"))).sort((rt,nt)=>{const ot=rt.isInstalled&&isInjectedConnector(rt.connector.type),it=nt.isInstalled&&isInjectedConnector(nt.connector.type);return ot&&!it?-1:!ot&&it?1:0}).sort((rt,nt)=>rt.id==="walletConnect"?1:nt.id==="walletConnect"?-1:0)},ProfileIcon=({isSignedIn:et})=>jsxRuntimeExports.jsxs("div",{style:{position:"relative"},children:[et?jsxRuntimeExports.jsx(AuthIcon,{style:{bottom:-1,right:-1}}):jsxRuntimeExports.jsx("div",{style:{zIndex:2,position:"absolute",top:-2,right:-2,background:"#1A88F8",borderRadius:8,boxShadow:"0 0 0 2px var(--ck-body-background)",width:8,height:8}}),jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{overflow:"visible"},children:[jsxRuntimeExports.jsx("circle",{cx:"10",cy:"10",r:"9",stroke:"currentColor",strokeWidth:"2"}),jsxRuntimeExports.jsx("path",{d:"M16.5 16.775C14.8618 15.0649 12.5552 14 10 14C7.44477 14 5.13825 15.0649 3.5 16.775",stroke:"currentColor",strokeWidth:"2"}),jsxRuntimeExports.jsx("circle",{cx:"10",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"2"})]})]}),InfoIcon=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 11C20 15.9706 15.9706 20 11 20C6.02944 20 2 15.9706 2 11C2 6.02944 6.02944 2 11 2C15.9706 2 20 6.02944 20 11ZM22 11C22 17.0751 17.0751 22 11 22C4.92487 22 0 17.0751 0 11C0 4.92487 4.92487 0 11 0C17.0751 0 22 4.92487 22 11ZM11.6445 12.7051C11.6445 13.1348 11.3223 13.4678 10.7744 13.4678C10.2266 13.4678 9.92578 13.1885 9.92578 12.6191V12.4795C9.92578 11.4268 10.4951 10.8574 11.2686 10.3203C12.2031 9.67578 12.665 9.32129 12.665 8.59082C12.665 7.76367 12.0205 7.21582 11.043 7.21582C10.3232 7.21582 9.80762 7.57031 9.45312 8.16113C9.38282 8.24242 9.32286 8.32101 9.2667 8.39461C9.04826 8.68087 8.88747 8.8916 8.40039 8.8916C8.0459 8.8916 7.66992 8.62305 7.66992 8.15039C7.66992 7.96777 7.70215 7.7959 7.75586 7.61328C8.05664 6.625 9.27051 5.75488 11.1182 5.75488C12.9336 5.75488 14.5234 6.71094 14.5234 8.50488C14.5234 9.7832 13.7822 10.417 12.7402 11.1045C11.999 11.5986 11.6445 11.9746 11.6445 12.5762V12.7051ZM11.9131 15.5625C11.9131 16.1855 11.376 16.6797 10.7529 16.6797C10.1299 16.6797 9.59277 16.1748 9.59277 15.5625C9.59277 14.9395 10.1191 14.4453 10.7529 14.4453C11.3867 14.4453 11.9131 14.9287 11.9131 15.5625Z",fill:"currentColor"})}),CloseIcon=({...et})=>jsxRuntimeExports.jsx(motion.svg,{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{d:"M1 13L13 1M1 1L13 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),BackIcon=({...et})=>jsxRuntimeExports.jsx(motion.svg,{width:9,height:16,viewBox:"0 0 9 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{d:"M8 1L1 8L8 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),contentTransitionDuration=.22,contentVariants$2={initial:{zIndex:2,opacity:0},animate:{opacity:1,scale:1,transition:{duration:contentTransitionDuration*.75,delay:contentTransitionDuration*.25,ease:[.26,.08,.25,1]}},exit:{zIndex:1,opacity:0,pointerEvents:"none",position:"absolute",left:["50%","50%"],x:["-50%","-50%"],transition:{duration:contentTransitionDuration,ease:[.26,.08,.25,1]}}},Modal=({open:et,pages:o,pageId:tt,positionInside:rt,inline:nt,demo:ot,onClose:it,onBack:st,onInfo:at})=>{var ct,lt,dt,ht,mt,ft,pt,yt,gt,bt,xt,vt;const Et=useContext(),Ct=useThemeContext(),St=isMobile(),{isSignedIn:At,reset:kt}=useSIWE(),It=useWallet((ct=Et.connector)===null||ct===void 0?void 0:ct.id),Nt={name:It==null?void 0:It.name,shortName:(lt=It==null?void 0:It.shortName)!==null&<!==void 0?lt:It==null?void 0:It.name,icon:(dt=It==null?void 0:It.iconConnector)!==null&&dt!==void 0?dt:It==null?void 0:It.icon,iconShape:(ht=It==null?void 0:It.iconShape)!==null&&ht!==void 0?ht:"circle",iconShouldShrink:It==null?void 0:It.iconShouldShrink},Lt=useLocales({CONNECTORNAME:Nt==null?void 0:Nt.name}),[Mt,zt]=useTransition({timeout:160,preEnter:!0,mountOnEnter:!0,unmountOnExit:!0}),Ut=!(Mt==="exited"||Mt==="unmounted"),Xt=Mt==="preEnter"||Mt!=="exiting",Wt=Et.route===routes.CONNECTORS?0:Et.route===routes.DOWNLOAD?2:1,Ft=usePrevious(Wt,Wt);rt||useLockBodyScroll(Ut),usePrevious(tt,tt),reactExports.useEffect(()=>{zt(et),et&&Qt(void 0)},[et]);const[qt,Pt]=reactExports.useState({width:void 0,height:void 0}),[Yt,Qt]=reactExports.useState(void 0),jt=Vt=>{const er={width:Vt==null?void 0:Vt.offsetWidth,height:Vt==null?void 0:Vt.offsetHeight};Pt({width:`${er==null?void 0:er.width}px`,height:`${er==null?void 0:er.height}px`})};let Gt;const rr=reactExports.useCallback(Vt=>{Vt&&(Zt.current=Vt,Qt(Yt!==void 0),clearTimeout(Gt),Gt=setTimeout(()=>Qt(!1),360),jt(Vt))},[et,Yt]),{chain:Ht}=useAccount(),{switchChain:dr}=useSwitchChain(),Zt=reactExports.useRef(null);reactExports.useEffect(()=>{Zt.current&&jt(Zt.current)},[Ht,dr,St,At,Et.options,Et.resize]),reactExports.useEffect(()=>{if(!Ut){Pt({width:void 0,height:void 0});return}const Vt=er=>{er.key==="Escape"&&it&&it()};return document.addEventListener("keydown",Vt),()=>{document.removeEventListener("keydown",Vt)}},[Ut,it]);const Jt={"--height":qt.height,"--width":qt.width};function tr(){return It?!(!It.getWalletConnectDeeplink||It.isInstalled):!1}function _t(){var Vt;switch(Et.route){case routes.ABOUT:return Lt.aboutScreen_heading;case routes.CONNECT:return tr()?isWalletConnectConnector((Vt=It==null?void 0:It.connector)===null||Vt===void 0?void 0:Vt.id)?Lt.scanScreen_heading:Lt.scanScreen_heading_withConnector:Nt==null?void 0:Nt.name;case routes.CONNECTORS:return Lt.connectorsScreen_heading;case routes.MOBILECONNECTORS:return Lt.mobileConnectorsScreen_heading;case routes.DOWNLOAD:return Lt.downloadAppScreen_heading;case routes.ONBOARDING:return Lt.onboardingScreen_heading;case routes.PROFILE:return Lt.profileScreen_heading;case routes.SWITCHNETWORKS:return Lt.switchNetworkScreen_heading;case routes.SIGNINWITHETHEREUM:return At?Lt.signInWithEthereumScreen_signedIn_heading:Lt.signInWithEthereumScreen_signedOut_heading;default:return""}}const Bt=jsxRuntimeExports.jsx(ResetContainer,{$useTheme:(mt=ot==null?void 0:ot.theme)!==null&&mt!==void 0?mt:Ct.theme,$useMode:(ft=ot==null?void 0:ot.mode)!==null&&ft!==void 0?ft:Ct.mode,$customTheme:(pt=ot==null?void 0:ot.customTheme)!==null&&pt!==void 0?pt:Ct.customTheme,children:jsxRuntimeExports.jsxs(ModalContainer,{role:"dialog",style:{pointerEvents:Xt?"auto":"none",position:rt?"absolute":void 0},children:[!nt&&jsxRuntimeExports.jsx(BackgroundOverlay,{$active:Xt,onClick:it,$blur:(yt=Et.options)===null||yt===void 0?void 0:yt.overlayBlur}),jsxRuntimeExports.jsxs(Container$7,{style:Jt,initial:!1,children:[jsxRuntimeExports.jsx("div",{style:{pointerEvents:Yt?"all":"none",position:"absolute",top:0,bottom:0,left:"50%",transform:"translateX(-50%)",width:"var(--width)",zIndex:9,transition:"width 200ms ease"}}),jsxRuntimeExports.jsxs(BoxContainer,{className:`${Xt&&"active"}`,children:[jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:((gt=Et.options)===null||gt===void 0?void 0:gt.disclaimer)&&Et.route===routes.CONNECTORS&&jsxRuntimeExports.jsx(DisclaimerBackground,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:0,duration:.2,ease:[.25,.1,.25,1]},children:jsxRuntimeExports.jsx(Disclaimer,{children:jsxRuntimeExports.jsx("div",{children:(bt=Et.options)===null||bt===void 0?void 0:bt.disclaimer})})})}),jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:Et.errorMessage&&jsxRuntimeExports.jsxs(ErrorMessage,{initial:{y:"10%",x:"-50%"},animate:{y:"-100%"},exit:{y:"100%"},transition:{duration:.2,ease:"easeInOut"},children:[jsxRuntimeExports.jsx("span",{children:Et.errorMessage}),jsxRuntimeExports.jsx("div",{onClick:()=>Et.displayError(null),style:{position:"absolute",right:24,top:24,cursor:"pointer"},children:jsxRuntimeExports.jsx(CloseIcon,{})})]})}),jsxRuntimeExports.jsxs(ControllerContainer,{children:[it&&jsxRuntimeExports.jsx(CloseButton,{"aria-label":flattenChildren(Lt.close).toString(),onClick:it,children:jsxRuntimeExports.jsx(CloseIcon,{})}),jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:23,left:20,width:32,height:32},children:jsxRuntimeExports.jsx(AnimatePresence,{children:st?jsxRuntimeExports.jsx(BackButton,{disabled:Yt,"aria-label":flattenChildren(Lt.back).toString(),onClick:st,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:St?0:.1,delay:St?.01:0},children:jsxRuntimeExports.jsx(BackIcon,{})},"backButton"):Et.route===routes.PROFILE&&Et.signInWithEthereum?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!At&&!(!((xt=Et.options)===null||xt===void 0)&&xt.hideTooltips)&&jsxRuntimeExports.jsx(motion.div,{style:{position:"absolute",inset:0,pointerEvents:"none"},initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1,transition:{delay:.5,duration:.2}},exit:{opacity:0,scale:.6,transition:{delay:0,duration:St?0:.1}},children:jsxRuntimeExports.jsx(SignInTooltip,{children:Lt.signInWithEthereumScreen_tooltip})}),jsxRuntimeExports.jsx(SiweButton,{disabled:Yt,"aria-label":Lt.signInWithEthereumScreen_signedOut_heading,onClick:()=>{kt(),Et.setRoute(routes.SIGNINWITHETHEREUM)},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:St?0:.1,delay:St?.01:0},children:jsxRuntimeExports.jsx(ProfileIcon,{isSignedIn:At})},"siweButton")]}):at&&!(!((vt=Et.options)===null||vt===void 0)&&vt.hideQuestionMarkCTA)&&jsxRuntimeExports.jsx(InfoButton,{disabled:Yt,"aria-label":flattenChildren(Lt.moreInformation).toString(),onClick:at,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:St?0:.1,delay:St?.01:0},children:jsxRuntimeExports.jsx(InfoIcon,{})},"infoButton")})})]}),jsxRuntimeExports.jsx(ModalHeading,{children:jsxRuntimeExports.jsx(AnimatePresence,{children:jsxRuntimeExports.jsx(motion.div,{style:{position:"absolute",top:0,bottom:0,left:52,right:52,display:"flex",justifyContent:"center"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:St?0:.17,delay:St?.01:0},children:jsxRuntimeExports.jsx(FitText,{children:_t()})},`${Et.route}-${At?"signedIn":""}`)})}),jsxRuntimeExports.jsx(InnerContainer$1,{children:Object.keys(o).map(Vt=>{const er=o[Vt];return jsxRuntimeExports.jsx(Page,{open:Vt===tt,initial:!rt&&Mt!=="entered",enterAnim:Vt===tt?Wt>Ft?"active-scale-up":"active":"",exitAnim:Vt!==tt?Wt{const[st,at]=useTransition({timeout:400,preEnter:!0,initialEntered:o,mountOnEnter:!0,unmountOnExit:!0}),ct=!(st==="exited"||st==="unmounted"),lt=st==="preEnter"||st!=="exiting";return reactExports.useEffect(()=>{at(o)},[o]),ct?jsxRuntimeExports.jsx(PageContainer,{className:`${lt?ot:it}`,style:{animationDuration:tt?"0ms":void 0,animationDelay:tt?"0ms":void 0},children:et}):null},OrDivider=({children:et})=>{const o=useLocales();return jsxRuntimeExports.jsx(TextWithHr,{children:jsxRuntimeExports.jsx("span",{children:et??o.or})})},Graphic=styled(motion.div)` position: relative; margin: 16px auto 20px; height: 190px; @@ -1516,7 +1516,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C rgba(255, 255, 255, 0.2) 0%, rgba(0, 0, 0, 0) 100% ), - linear-gradient(180deg, #3897FB 0%, #5004F1 100%))`,boxShadow:"var(--ck-graphic-globe-box-shadow, 0px -6px 20px rgba(56, 151, 251, 0.23))"},children:jsxRuntimeExports.jsx(SpinContainer,{style:et?void 0:{animationPlayState:"paused"},children:jsxRuntimeExports.jsxs("svg",{width:"128",height:"128",viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("circle",{cx:"30",cy:"141",r:"64",stroke:`url(#networkRadialA-${o})`,strokeWidth:"3"}),jsxRuntimeExports.jsx("circle",{cx:"78.8515",cy:"131.123",r:"54.1005",transform:"rotate(-37.4016 78.8515 131.123)",stroke:`url(#networkRadialB-${o})`,strokeWidth:"3"}),jsxRuntimeExports.jsx("circle",{cx:"63.6053",cy:"2.12794",r:"50.8338",transform:"rotate(134.702 63.6053 2.12794)",stroke:`url(#networkRadialC-${o})`,strokeWidth:"3"}),jsxRuntimeExports.jsx("circle",{cx:"126.658",cy:"56.6577",r:"50.3433",transform:"rotate(-105 126.658 56.6577)",stroke:`url(#networkRadialD-${o})`,strokeWidth:"3"}),jsxRuntimeExports.jsx("circle",{cx:"13.6619",cy:"18.9603",r:"46.0247",transform:"rotate(107.362 13.6619 18.9603)",stroke:`url(#networkRadialE-${o})`,strokeWidth:"3"})]}),jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialA-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(60.5 84) rotate(104.668) scale(77.0097)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]}),jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialB-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(96.1805 81.6717) rotate(97.125) scale(64.7443)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]}),jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialC-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(96.3816 -36.4455) rotate(114.614) scale(57.7177)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]}),jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialD-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(137.86 7.73234) rotate(92.3288) scale(62.743)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]}),jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialE-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(35.3203 -21.566) rotate(104.513) scale(54.8617)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]})]})]})})},"SlideThreeInner"),jsxRuntimeExports.jsxs(motion.div,{exit:{opacity:0},children:[jsxRuntimeExports.jsx(motion.div,{initial:et?void 0:{scale:1.1},animate:et?pulseAnim:void 0,transition:{...pulseTransition},style:{position:"absolute",inset:0,borderRadius:"50%",boxShadow:"0 0 0 2px var(--ck-graphic-globe-lines, rgba(126, 112, 243, 1))"}},"pulseA"),jsxRuntimeExports.jsx(motion.div,{initial:et?void 0:{scale:1.2,opacity:.25},animate:et?pulseAnim:void 0,transition:{...pulseTransition,delay:.5},style:{position:"absolute",inset:0,borderRadius:"50%",boxShadow:"0 0 0 2px var(--ck-graphic-globe-lines, rgba(126, 112, 243, 1))"}},"pulseB")]})]},et),jsxRuntimeExports.jsxs(motion.div,{initial:{rotate:-20,scale:.1,y:-10,x:-10},animate:{rotate:0,scale:1,y:0,x:0},exit:{zIndex:3,scale:.2,y:-25,x:15},style:{zIndex:12,borderRadius:"50%",position:"absolute",bottom:-4,right:-4,width:54,height:54,display:"flex",alignItems:"center",justifyContent:"center",padding:13,background:"var(--ck-graphic-compass-background, var(--ck-body-background))",boxShadow:"var(--ck-graphic-compass-box-shadow, 0px 2px 9px rgba(0, 0, 0, 0.15))"},children:[jsxRuntimeExports.jsx(BgLighten,{}),jsxRuntimeExports.jsx(motion.div,{style:{zIndex:2,position:"absolute"},initial:{rotate:-170},animate:{rotate:0},exit:{rotate:-180,transition:{duration:0}},transition:{type:"spring",stiffness:6,damping:.9,mass:.2},children:Compass})]})]},"SlideThree")})},About=()=>{var et,o;const tt=useLocales({}),rt=useContext(),nt=(o=(et=rt.options)===null||et===void 0?void 0:et.ethereumOnboardingUrl)!==null&&o!==void 0?o:tt.aboutScreen_ctaUrl,[ot,it]=reactExports.useState(!0),[st,at]=reactExports.useState(0),ct=reactExports.useRef(!1),lt=reactExports.useRef(0),dt=[.16,1,.3,1],ht=600;let mt;reactExports.useEffect(()=>()=>clearInterval(mt),[]);const ft=()=>{if(Et.current){const{overflow:It}=getComputedStyle(Et.current);return It!=="visible"}return!1},pt=It=>{it(!1),ft()?gt(It):at(It)},gt=It=>{if(Et.current){const{offsetWidth:Ot}=Et.current;Et.current.scrollLeft=Ot*It,setTimeout(()=>at(It),100)}},yt=()=>{if(!Et.current)return;const{offsetWidth:It,scrollLeft:Ot}=Et.current,Nt=lt.current;lt.current=Ot;const Yt=4;if(Nt-Ot>-Yt&&Nt-Ot{vt()},xt=()=>{const{offsetWidth:It,scrollLeft:Ot}=Et.current,Nt=Math.round(Ot/It);at(Nt)},vt=()=>{ct.current=!0,clearTimeout(mt)},Et=reactExports.useRef(null);reactExports.useEffect(()=>{if(Et.current)return Et.current.addEventListener("scroll",yt),Et.current.addEventListener("touchmove",bt),Et.current.addEventListener("touchend",xt),()=>{Et.current&&(Et.current.removeEventListener("scroll",yt),Et.current.removeEventListener("touchmove",bt),Et.current.removeEventListener("touchend",xt))}},[Et]);const Ct=[jsxRuntimeExports.jsx(SlideOne,{layoutId:"graphicCircle",duration:ht,ease:dt}),jsxRuntimeExports.jsx(SlideTwo,{layoutId:"graphicCircle",duration:ht,ease:dt}),jsxRuntimeExports.jsx(SlideThree,{layoutId:"graphicCircle",duration:ht,ease:dt})],St=[jsxRuntimeExports.jsx(SlideOne,{duration:ht,ease:dt}),jsxRuntimeExports.jsx(SlideTwo,{duration:ht,ease:dt}),jsxRuntimeExports.jsx(SlideThree,{duration:ht,ease:dt})],At=(()=>{var It;switch((It=rt.options)===null||It===void 0?void 0:It.language){case"en-US":case"zh-CN":return 64;default:return 84}})(),kt=[jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ModalH1,{style:{height:24},$small:!0,children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_a_h1})}),jsxRuntimeExports.jsx(ModalBody,{style:{height:At},children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_a_p})})]}),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ModalH1,{style:{height:24},$small:!0,children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_b_h1})}),jsxRuntimeExports.jsx(ModalBody,{style:{height:At},children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_b_p})})]}),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ModalH1,{style:{height:24},$small:!0,children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_c_h1})}),jsxRuntimeExports.jsx(ModalBody,{style:{height:At},children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_c_p})})]})];return jsxRuntimeExports.jsxs(PageContent,{children:[jsxRuntimeExports.jsxs(Slider,{children:[jsxRuntimeExports.jsx(ImageContainer$1,{children:jsxRuntimeExports.jsx(MotionConfig,{transition:{duration:ht/1e3,ease:dt},children:jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,onExitComplete:()=>it(!0),children:Ct.map((It,Ot)=>st===Ot&&jsxRuntimeExports.jsx(ImageContainerInner,{style:{position:"absolute"},children:It},Ot))})})}),jsxRuntimeExports.jsx(Slides,{ref:Et,children:jsxRuntimeExports.jsx(AnimatePresence,{children:kt.map((It,Ot)=>jsxRuntimeExports.jsxs(Slide,{$active:st===Ot,children:[jsxRuntimeExports.jsx(MobileImageContainer,{children:jsxRuntimeExports.jsx(MotionConfig,{transition:{duration:0},children:jsxRuntimeExports.jsx(ImageContainerInner,{children:St[Ot]})})}),jsxRuntimeExports.jsx(ModalContent,{style:{gap:8,paddingBottom:0},children:It})]},Ot))})})]}),jsxRuntimeExports.jsx(OrDivider,{children:jsxRuntimeExports.jsx(Dots,{children:kt.map((It,Ot)=>jsxRuntimeExports.jsx(Dot,{$active:st===Ot,onClick:()=>{vt(),pt(Ot)}},Ot))})}),jsxRuntimeExports.jsx(Button$1,{href:nt,arrow:!0,children:tt.aboutScreen_ctaText})]})},Shimmer$1=We` + linear-gradient(180deg, #3897FB 0%, #5004F1 100%))`,boxShadow:"var(--ck-graphic-globe-box-shadow, 0px -6px 20px rgba(56, 151, 251, 0.23))"},children:jsxRuntimeExports.jsx(SpinContainer,{style:et?void 0:{animationPlayState:"paused"},children:jsxRuntimeExports.jsxs("svg",{width:"128",height:"128",viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("circle",{cx:"30",cy:"141",r:"64",stroke:`url(#networkRadialA-${o})`,strokeWidth:"3"}),jsxRuntimeExports.jsx("circle",{cx:"78.8515",cy:"131.123",r:"54.1005",transform:"rotate(-37.4016 78.8515 131.123)",stroke:`url(#networkRadialB-${o})`,strokeWidth:"3"}),jsxRuntimeExports.jsx("circle",{cx:"63.6053",cy:"2.12794",r:"50.8338",transform:"rotate(134.702 63.6053 2.12794)",stroke:`url(#networkRadialC-${o})`,strokeWidth:"3"}),jsxRuntimeExports.jsx("circle",{cx:"126.658",cy:"56.6577",r:"50.3433",transform:"rotate(-105 126.658 56.6577)",stroke:`url(#networkRadialD-${o})`,strokeWidth:"3"}),jsxRuntimeExports.jsx("circle",{cx:"13.6619",cy:"18.9603",r:"46.0247",transform:"rotate(107.362 13.6619 18.9603)",stroke:`url(#networkRadialE-${o})`,strokeWidth:"3"})]}),jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialA-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(60.5 84) rotate(104.668) scale(77.0097)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]}),jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialB-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(96.1805 81.6717) rotate(97.125) scale(64.7443)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]}),jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialC-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(96.3816 -36.4455) rotate(114.614) scale(57.7177)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]}),jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialD-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(137.86 7.73234) rotate(92.3288) scale(62.743)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]}),jsxRuntimeExports.jsxs("radialGradient",{id:`networkRadialE-${o}`,cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(35.3203 -21.566) rotate(104.513) scale(54.8617)",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-globe-lines, white)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-globe-lines, white)",stopOpacity:"0"})]})]})]})})},"SlideThreeInner"),jsxRuntimeExports.jsxs(motion.div,{exit:{opacity:0},children:[jsxRuntimeExports.jsx(motion.div,{initial:et?void 0:{scale:1.1},animate:et?pulseAnim:void 0,transition:{...pulseTransition},style:{position:"absolute",inset:0,borderRadius:"50%",boxShadow:"0 0 0 2px var(--ck-graphic-globe-lines, rgba(126, 112, 243, 1))"}},"pulseA"),jsxRuntimeExports.jsx(motion.div,{initial:et?void 0:{scale:1.2,opacity:.25},animate:et?pulseAnim:void 0,transition:{...pulseTransition,delay:.5},style:{position:"absolute",inset:0,borderRadius:"50%",boxShadow:"0 0 0 2px var(--ck-graphic-globe-lines, rgba(126, 112, 243, 1))"}},"pulseB")]})]},et),jsxRuntimeExports.jsxs(motion.div,{initial:{rotate:-20,scale:.1,y:-10,x:-10},animate:{rotate:0,scale:1,y:0,x:0},exit:{zIndex:3,scale:.2,y:-25,x:15},style:{zIndex:12,borderRadius:"50%",position:"absolute",bottom:-4,right:-4,width:54,height:54,display:"flex",alignItems:"center",justifyContent:"center",padding:13,background:"var(--ck-graphic-compass-background, var(--ck-body-background))",boxShadow:"var(--ck-graphic-compass-box-shadow, 0px 2px 9px rgba(0, 0, 0, 0.15))"},children:[jsxRuntimeExports.jsx(BgLighten,{}),jsxRuntimeExports.jsx(motion.div,{style:{zIndex:2,position:"absolute"},initial:{rotate:-170},animate:{rotate:0},exit:{rotate:-180,transition:{duration:0}},transition:{type:"spring",stiffness:6,damping:.9,mass:.2},children:Compass})]})]},"SlideThree")})},About=()=>{var et,o;const tt=useLocales({}),rt=useContext(),nt=(o=(et=rt.options)===null||et===void 0?void 0:et.ethereumOnboardingUrl)!==null&&o!==void 0?o:tt.aboutScreen_ctaUrl,[ot,it]=reactExports.useState(!0),[st,at]=reactExports.useState(0),ct=reactExports.useRef(!1),lt=reactExports.useRef(0),dt=[.16,1,.3,1],ht=600;let mt;reactExports.useEffect(()=>()=>clearInterval(mt),[]);const ft=()=>{if(Et.current){const{overflow:It}=getComputedStyle(Et.current);return It!=="visible"}return!1},pt=It=>{it(!1),ft()?yt(It):at(It)},yt=It=>{if(Et.current){const{offsetWidth:Nt}=Et.current;Et.current.scrollLeft=Nt*It,setTimeout(()=>at(It),100)}},gt=()=>{if(!Et.current)return;const{offsetWidth:It,scrollLeft:Nt}=Et.current,Lt=lt.current;lt.current=Nt;const Mt=4;if(Lt-Nt>-Mt&&Lt-Nt{vt()},xt=()=>{const{offsetWidth:It,scrollLeft:Nt}=Et.current,Lt=Math.round(Nt/It);at(Lt)},vt=()=>{ct.current=!0,clearTimeout(mt)},Et=reactExports.useRef(null);reactExports.useEffect(()=>{if(Et.current)return Et.current.addEventListener("scroll",gt),Et.current.addEventListener("touchmove",bt),Et.current.addEventListener("touchend",xt),()=>{Et.current&&(Et.current.removeEventListener("scroll",gt),Et.current.removeEventListener("touchmove",bt),Et.current.removeEventListener("touchend",xt))}},[Et]);const Ct=[jsxRuntimeExports.jsx(SlideOne,{layoutId:"graphicCircle",duration:ht,ease:dt}),jsxRuntimeExports.jsx(SlideTwo,{layoutId:"graphicCircle",duration:ht,ease:dt}),jsxRuntimeExports.jsx(SlideThree,{layoutId:"graphicCircle",duration:ht,ease:dt})],St=[jsxRuntimeExports.jsx(SlideOne,{duration:ht,ease:dt}),jsxRuntimeExports.jsx(SlideTwo,{duration:ht,ease:dt}),jsxRuntimeExports.jsx(SlideThree,{duration:ht,ease:dt})],At=(()=>{var It;switch((It=rt.options)===null||It===void 0?void 0:It.language){case"en-US":case"zh-CN":return 64;default:return 84}})(),kt=[jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ModalH1,{style:{height:24},$small:!0,children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_a_h1})}),jsxRuntimeExports.jsx(ModalBody,{style:{height:At},children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_a_p})})]}),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ModalH1,{style:{height:24},$small:!0,children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_b_h1})}),jsxRuntimeExports.jsx(ModalBody,{style:{height:At},children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_b_p})})]}),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ModalH1,{style:{height:24},$small:!0,children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_c_h1})}),jsxRuntimeExports.jsx(ModalBody,{style:{height:At},children:jsxRuntimeExports.jsx(FitText,{children:tt.aboutScreen_c_p})})]})];return jsxRuntimeExports.jsxs(PageContent,{children:[jsxRuntimeExports.jsxs(Slider,{children:[jsxRuntimeExports.jsx(ImageContainer$1,{children:jsxRuntimeExports.jsx(MotionConfig,{transition:{duration:ht/1e3,ease:dt},children:jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,onExitComplete:()=>it(!0),children:Ct.map((It,Nt)=>st===Nt&&jsxRuntimeExports.jsx(ImageContainerInner,{style:{position:"absolute"},children:It},Nt))})})}),jsxRuntimeExports.jsx(Slides,{ref:Et,children:jsxRuntimeExports.jsx(AnimatePresence,{children:kt.map((It,Nt)=>jsxRuntimeExports.jsxs(Slide,{$active:st===Nt,children:[jsxRuntimeExports.jsx(MobileImageContainer,{children:jsxRuntimeExports.jsx(MotionConfig,{transition:{duration:0},children:jsxRuntimeExports.jsx(ImageContainerInner,{children:St[Nt]})})}),jsxRuntimeExports.jsx(ModalContent,{style:{gap:8,paddingBottom:0},children:It})]},Nt))})})]}),jsxRuntimeExports.jsx(OrDivider,{children:jsxRuntimeExports.jsx(Dots,{children:kt.map((It,Nt)=>jsxRuntimeExports.jsx(Dot,{$active:st===Nt,onClick:()=>{vt(),pt(Nt)}},Nt))})}),jsxRuntimeExports.jsx(Button$1,{href:nt,arrow:!0,children:tt.aboutScreen_ctaText})]})},Shimmer$1=We` 0%{ transform: translate(-100%) rotate(-45deg); } 100%{ transform: translate(100%) rotate(-80deg); } `,InfoBox=styled.div` @@ -2382,7 +2382,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C margin: 0; margin-left: 4px; } -`,CopyToClipboard=({string:et,children:o,variant:tt})=>{const[rt,nt]=reactExports.useState(!1);let ot;const it=()=>{if(!et)return;const st=et.trim();navigator.clipboard&&navigator.clipboard.writeText(st),nt(!0),clearTimeout(ot),ot=setTimeout(()=>nt(!1),1e3)};return tt==="button"?jsxRuntimeExports.jsx(Button$1,{disabled:!et,onClick:it,icon:jsxRuntimeExports.jsx(CopyToClipboardIcon,{copied:rt}),children:o}):jsxRuntimeExports.jsx(Container$5,{onClick:it,$disabled:!et,children:jsxRuntimeExports.jsxs(OffsetContainer,{children:[o,jsxRuntimeExports.jsx(CopyToClipboardIcon,{copied:rt,small:!0})]})})},MoreIcon=jsxRuntimeExports.jsx("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx("path",{d:"M30 42V19M19 30.5H42",stroke:"var(--ck-body-color-muted)",strokeWidth:"3",strokeLinecap:"round"})}),MobileConnectors=()=>{var et,o;const tt=useContext(),rt=useLocales(),{connect:{getUri:nt}}=useWeb3(),ot=nt(),{open:it,isOpen:st}=useWalletConnectModal(),at=useWallets(),ct=(et=Object.keys(walletConfigs).filter(dt=>{const ht=walletConfigs[dt];return!(at.find(mt=>mt.connector.id===dt)||!ht.getWalletConnectDeeplink)}))!==null&&et!==void 0?et:[],lt=dt=>{var ht;const mt=(ht=dt.getWalletConnectDeeplink)===null||ht===void 0?void 0:ht.call(dt,ot);mt&&(window.location.href=mt)};return jsxRuntimeExports.jsx(PageContent,{style:{width:312},children:jsxRuntimeExports.jsxs(Container$6,{children:[jsxRuntimeExports.jsx(ModalContent,{style:{paddingBottom:0},children:jsxRuntimeExports.jsx(ScrollArea$2,{height:340,children:jsxRuntimeExports.jsxs(WalletList,{$disabled:!ot,children:[ct.sort((dt,ht)=>{var mt,ft,pt,gt;const yt=walletConfigs[dt],bt=walletConfigs[ht],xt=(ft=(mt=yt.name)!==null&&mt!==void 0?mt:yt.shortName)!==null&&ft!==void 0?ft:dt,vt=(gt=(pt=bt.name)!==null&&pt!==void 0?pt:bt.shortName)!==null&>!==void 0?gt:ht;return xt.localeCompare(vt)}).filter(dt=>!(dt==="coinbaseWallet"||dt==="com.coinbase.wallet")).map((dt,ht)=>{const mt=walletConfigs[dt],{name:ft,shortName:pt,iconConnector:gt,icon:yt}=mt;return jsxRuntimeExports.jsxs(WalletItem,{onClick:()=>lt(mt),style:{animationDelay:`${ht*50}ms`},children:[jsxRuntimeExports.jsx(WalletIcon,{$outline:!0,children:gt??yt}),jsxRuntimeExports.jsx(WalletLabel,{children:pt??ft})]},ht)}),jsxRuntimeExports.jsxs(WalletItem,{onClick:it,$waiting:st,children:[jsxRuntimeExports.jsx(WalletIcon,{style:{background:"var(--ck-body-background-secondary)"},children:st?jsxRuntimeExports.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntimeExports.jsx("div",{style:{width:"50%"},children:jsxRuntimeExports.jsx(Spinner$4,{})})}):MoreIcon}),jsxRuntimeExports.jsx(WalletLabel,{children:rt.more})]})]})})}),((o=tt.options)===null||o===void 0?void 0:o.walletConnectCTA)!=="modal"&&jsxRuntimeExports.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:14,paddingTop:8},children:jsxRuntimeExports.jsx(CopyToClipboard,{variant:"button",string:ot,children:rt.copyToClipboard})})]})})},Content$1=styled(motion.div)` +`,CopyToClipboard=({string:et,children:o,variant:tt})=>{const[rt,nt]=reactExports.useState(!1);let ot;const it=()=>{if(!et)return;const st=et.trim();navigator.clipboard&&navigator.clipboard.writeText(st),nt(!0),clearTimeout(ot),ot=setTimeout(()=>nt(!1),1e3)};return tt==="button"?jsxRuntimeExports.jsx(Button$1,{disabled:!et,onClick:it,icon:jsxRuntimeExports.jsx(CopyToClipboardIcon,{copied:rt}),children:o}):jsxRuntimeExports.jsx(Container$5,{onClick:it,$disabled:!et,children:jsxRuntimeExports.jsxs(OffsetContainer,{children:[o,jsxRuntimeExports.jsx(CopyToClipboardIcon,{copied:rt,small:!0})]})})},MoreIcon=jsxRuntimeExports.jsx("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx("path",{d:"M30 42V19M19 30.5H42",stroke:"var(--ck-body-color-muted)",strokeWidth:"3",strokeLinecap:"round"})}),MobileConnectors=()=>{var et,o;const tt=useContext(),rt=useLocales(),{connect:{getUri:nt}}=useWeb3(),ot=nt(),{open:it,isOpen:st}=useWalletConnectModal(),at=useWallets(),ct=(et=Object.keys(walletConfigs).filter(dt=>{const ht=walletConfigs[dt];return!(at.find(mt=>mt.connector.id===dt)||!ht.getWalletConnectDeeplink)}))!==null&&et!==void 0?et:[],lt=dt=>{var ht;const mt=(ht=dt.getWalletConnectDeeplink)===null||ht===void 0?void 0:ht.call(dt,ot);mt&&(window.location.href=mt)};return jsxRuntimeExports.jsx(PageContent,{style:{width:312},children:jsxRuntimeExports.jsxs(Container$6,{children:[jsxRuntimeExports.jsx(ModalContent,{style:{paddingBottom:0},children:jsxRuntimeExports.jsx(ScrollArea$2,{height:340,children:jsxRuntimeExports.jsxs(WalletList,{$disabled:!ot,children:[ct.sort((dt,ht)=>{var mt,ft,pt,yt;const gt=walletConfigs[dt],bt=walletConfigs[ht],xt=(ft=(mt=gt.name)!==null&&mt!==void 0?mt:gt.shortName)!==null&&ft!==void 0?ft:dt,vt=(yt=(pt=bt.name)!==null&&pt!==void 0?pt:bt.shortName)!==null&&yt!==void 0?yt:ht;return xt.localeCompare(vt)}).filter(dt=>!(dt==="coinbaseWallet"||dt==="com.coinbase.wallet")).map((dt,ht)=>{const mt=walletConfigs[dt],{name:ft,shortName:pt,iconConnector:yt,icon:gt}=mt;return jsxRuntimeExports.jsxs(WalletItem,{onClick:()=>lt(mt),style:{animationDelay:`${ht*50}ms`},children:[jsxRuntimeExports.jsx(WalletIcon,{$outline:!0,children:yt??gt}),jsxRuntimeExports.jsx(WalletLabel,{children:pt??ft})]},ht)}),jsxRuntimeExports.jsxs(WalletItem,{onClick:it,$waiting:st,children:[jsxRuntimeExports.jsx(WalletIcon,{style:{background:"var(--ck-body-background-secondary)"},children:st?jsxRuntimeExports.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntimeExports.jsx("div",{style:{width:"50%"},children:jsxRuntimeExports.jsx(Spinner$4,{})})}):MoreIcon}),jsxRuntimeExports.jsx(WalletLabel,{children:rt.more})]})]})})}),((o=tt.options)===null||o===void 0?void 0:o.walletConnectCTA)!=="modal"&&jsxRuntimeExports.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:14,paddingTop:8},children:jsxRuntimeExports.jsx(CopyToClipboard,{variant:"button",string:ot,children:rt.copyToClipboard})})]})})},Content$1=styled(motion.div)` display: flex; flex-direction: column; gap: 6px; @@ -2568,7 +2568,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C background: var(--ck-tooltip-background); border-radius: ${et=>et.$size==="small"?2:3}px 0 0 0; } -`,Tooltip=({children:et,message:o,open:tt,xOffset:rt=0,yOffset:nt=0,delay:ot})=>{var it;const st=useContext(),at=useThemeContext();if(!((it=st.options)===null||it===void 0)&&it.hideTooltips)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:et});const[ct,lt]=reactExports.useState(!1),[dt,ht]=reactExports.useState(!1),[mt,ft]=reactExports.useState("small"),[pt,gt]=reactExports.useState(!1),[yt]=reactExports.useState(st.route),bt=reactExports.useRef(null),[xt,vt]=useMeasure({debounce:pt?0:220,offsetSize:!0,scroll:!0}),Et=()=>{let At=!1;const kt=rt+vt.left+vt.width,It=nt+vt.top+vt.height*.5;return(kt>window.innerWidth||kt<0||It>window.innerHeight||It<0)&&(At=!0),At};return(typeof window<"u"?reactExports.useLayoutEffect:reactExports.useEffect)(()=>{if(!bt.current||vt.top+vt.bottom+vt.left+vt.right+vt.height+vt.width===0)return;const At=rt+vt.left+vt.width,kt=nt+vt.top+vt.height*.5;!pt&&At!==0&&kt!==0&>(!0),bt.current.style.left=`${At}px`,bt.current.style.top=`${kt}px`,ft(bt.current.offsetHeight<=40?"small":"large"),ht(Et())},[vt,tt,ct]),reactExports.useEffect(()=>{st.open||lt(!1)},[st.open]),reactExports.useEffect(()=>{lt(!!tt)},[tt]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(motion.div,{ref:xt,style:tt===void 0?{cursor:"help"}:{},onHoverStart:()=>lt(!0),onHoverEnd:()=>lt(!1),onClick:()=>lt(!1),children:et}),jsxRuntimeExports.jsx(Portal$2,{children:jsxRuntimeExports.jsx(AnimatePresence,{children:yt===st.route&&!dt&&ct&&jsxRuntimeExports.jsx(ResetContainer,{$useTheme:at.theme,$useMode:at.mode,$customTheme:at.customTheme,children:jsxRuntimeExports.jsx(TooltipWindow,{children:jsxRuntimeExports.jsxs(TooltipContainer,{role:"tooltip",$size:mt,ref:bt,initial:"collapsed",animate:pt?"open":{},exit:"collapsed",variants:{collapsed:{transformOrigin:"20px 50%",opacity:0,scale:.9,z:.01,y:"-50%",x:20,transition:{duration:.1}},open:{willChange:"opacity,transform",opacity:1,scale:1,z:.01,y:"-50%",x:20,transition:{ease:[.76,0,.24,1],duration:.15,delay:ot||.5}}},children:[o,jsxRuntimeExports.jsx(TooltipTail,{$size:mt})]})})})})})]})},LogoContainer$4=styled(motion.div)` +`,Tooltip=({children:et,message:o,open:tt,xOffset:rt=0,yOffset:nt=0,delay:ot})=>{var it;const st=useContext(),at=useThemeContext();if(!((it=st.options)===null||it===void 0)&&it.hideTooltips)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:et});const[ct,lt]=reactExports.useState(!1),[dt,ht]=reactExports.useState(!1),[mt,ft]=reactExports.useState("small"),[pt,yt]=reactExports.useState(!1),[gt]=reactExports.useState(st.route),bt=reactExports.useRef(null),[xt,vt]=useMeasure({debounce:pt?0:220,offsetSize:!0,scroll:!0}),Et=()=>{let At=!1;const kt=rt+vt.left+vt.width,It=nt+vt.top+vt.height*.5;return(kt>window.innerWidth||kt<0||It>window.innerHeight||It<0)&&(At=!0),At};return(typeof window<"u"?reactExports.useLayoutEffect:reactExports.useEffect)(()=>{if(!bt.current||vt.top+vt.bottom+vt.left+vt.right+vt.height+vt.width===0)return;const At=rt+vt.left+vt.width,kt=nt+vt.top+vt.height*.5;!pt&&At!==0&&kt!==0&&yt(!0),bt.current.style.left=`${At}px`,bt.current.style.top=`${kt}px`,ft(bt.current.offsetHeight<=40?"small":"large"),ht(Et())},[vt,tt,ct]),reactExports.useEffect(()=>{st.open||lt(!1)},[st.open]),reactExports.useEffect(()=>{lt(!!tt)},[tt]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(motion.div,{ref:xt,style:tt===void 0?{cursor:"help"}:{},onHoverStart:()=>lt(!0),onHoverEnd:()=>lt(!1),onClick:()=>lt(!1),children:et}),jsxRuntimeExports.jsx(Portal$2,{children:jsxRuntimeExports.jsx(AnimatePresence,{children:gt===st.route&&!dt&&ct&&jsxRuntimeExports.jsx(ResetContainer,{$useTheme:at.theme,$useMode:at.mode,$customTheme:at.customTheme,children:jsxRuntimeExports.jsx(TooltipWindow,{children:jsxRuntimeExports.jsxs(TooltipContainer,{role:"tooltip",$size:mt,ref:bt,initial:"collapsed",animate:pt?"open":{},exit:"collapsed",variants:{collapsed:{transformOrigin:"20px 50%",opacity:0,scale:.9,z:.01,y:"-50%",x:20,transition:{duration:.1}},open:{willChange:"opacity,transform",opacity:1,scale:1,z:.01,y:"-50%",x:20,transition:{ease:[.76,0,.24,1],duration:.15,delay:ot||.5}}},children:[o,jsxRuntimeExports.jsx(TooltipTail,{$size:mt})]})})})})})]})},LogoContainer$4=styled(motion.div)` z-index: 4; position: relative; overflow: hidden; @@ -2742,7 +2742,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C transform: rotate(360deg); } } -`,CircleSpinner=({logo:et,smallLogo:o,connecting:tt=!0,unavailable:rt=!1,countdown:nt=!1})=>jsxRuntimeExports.jsxs(LogoContainer$3,{transition:{duration:.5,ease:[.175,.885,.32,.98]},children:[jsxRuntimeExports.jsx(Logo,{$small:!rt&&o,style:rt?{borderRadius:0}:void 0,children:et}),jsxRuntimeExports.jsx(SpinnerContainer,{children:jsxRuntimeExports.jsxs(AnimatePresence,{children:[tt&&jsxRuntimeExports.jsx(Spinner$2,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:nt?1:0}},children:jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"102",height:"102",viewBox:"0 0 102 102",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("path",{d:"M52 100C24.3858 100 2 77.6142 2 50",stroke:"url(#paint0_linear_1943_4139)",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("defs",{children:jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_1943_4139",x1:"2",y1:"48.5",x2:"53",y2:"100",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-spinner-color)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-spinner-color)",stopOpacity:"0"})]})})]})},"Spinner"),nt&&jsxRuntimeExports.jsxs(ExpiringSpinner,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:[jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsx("div",{})]},"ExpiringSpinner")]})})]}),states$1={CONNECTED:"connected",CONNECTING:"connecting",EXPIRING:"expiring",FAILED:"failed",REJECTED:"rejected",NOTCONNECTED:"notconnected",UNAVAILABLE:"unavailable"},contentVariants$1={initial:{willChange:"transform,opacity",position:"relative",opacity:0,scale:.95},animate:{position:"relative",opacity:1,scale:1,transition:{ease:[.16,1,.3,1],duration:.4,delay:.05,position:{delay:0}}},exit:{position:"absolute",opacity:0,scale:.95,transition:{ease:[.16,1,.3,1],duration:.3}}},ConnectWithInjector=({switchConnectMethod:et,forceState:o})=>{var tt,rt,nt,ot,it,st,at,ct;const{connect:lt}=useConnect({mutation:{onMutate:Ot=>{Ot.connector?St(states$1.CONNECTING):St(states$1.UNAVAILABLE)},onError(Ot){console.error(Ot)},onSettled(Ot,Nt){if(Nt){if(yt(!0),setTimeout(()=>yt(!1),3500),Nt.code)switch(Nt.code){case-32002:St(states$1.NOTCONNECTED);break;case 4001:St(states$1.REJECTED);break;default:St(states$1.FAILED);break}else if(Nt.message)switch(Nt.message){case"User rejected request":St(states$1.REJECTED);break;default:St(states$1.FAILED);break}}setTimeout(dt,100)}}}),{triggerResize:dt,connector:ht}=useContext(),mt=ht.id,ft=useWallet(mt),pt={name:ft==null?void 0:ft.name,shortName:(tt=ft==null?void 0:ft.shortName)!==null&&tt!==void 0?tt:ft==null?void 0:ft.name,icon:(rt=ft==null?void 0:ft.iconConnector)!==null&&rt!==void 0?rt:ft==null?void 0:ft.icon,iconShape:(nt=ft==null?void 0:ft.iconShape)!==null&&nt!==void 0?nt:"circle",iconShouldShrink:ft==null?void 0:ft.iconShouldShrink},[gt,yt]=reactExports.useState(!1);reactExports.useState(9);const xt=detectBrowser(),vt=(ot=ft==null?void 0:ft.downloadUrls)===null||ot===void 0?void 0:ot[xt],Et=ft!=null&&ft.downloadUrls?{name:Object.keys(ft==null?void 0:ft.downloadUrls)[0],label:((it=Object.keys(ft==null?void 0:ft.downloadUrls)[0])===null||it===void 0?void 0:it.charAt(0).toUpperCase())+((st=Object.keys(ft==null?void 0:ft.downloadUrls)[0])===null||st===void 0?void 0:st.slice(1)),url:ft==null?void 0:ft.downloadUrls[Object.keys(ft==null?void 0:ft.downloadUrls)[0]]}:void 0,[Ct,St]=reactExports.useState(o||(ft!=null&&ft.isInstalled?states$1.CONNECTING:states$1.UNAVAILABLE)),At=useLocales({CONNECTORNAME:pt.name,CONNECTORSHORTNAME:(at=pt.shortName)!==null&&at!==void 0?at:pt.name,SUGGESTEDEXTENSIONBROWSER:(ct=Et==null?void 0:Et.label)!==null&&ct!==void 0?ct:"your browser"}),kt=async()=>{ft!=null&&ft.isInstalled&&(ft!=null&&ft.connector)?lt({connector:ft==null?void 0:ft.connector}):St(states$1.UNAVAILABLE)};let It;return reactExports.useEffect(()=>{if(Ct!==states$1.UNAVAILABLE)return It=setTimeout(kt,600),()=>{clearTimeout(It)}},[]),ft?isWalletConnectConnector(ft==null?void 0:ft.connector.id)?jsxRuntimeExports.jsx(PageContent,{children:jsxRuntimeExports.jsxs(Container$4,{children:[jsxRuntimeExports.jsx(ModalHeading,{children:"Invalid State"}),jsxRuntimeExports.jsx(ModalContent,{children:jsxRuntimeExports.jsx(Alert,{children:"WalletConnect does not have an injection flow. This state should never happen."})})]})}):jsxRuntimeExports.jsx(PageContent,{children:jsxRuntimeExports.jsxs(Container$4,{children:[jsxRuntimeExports.jsx(ConnectingContainer,{children:jsxRuntimeExports.jsxs(ConnectingAnimation,{$shake:Ct===states$1.FAILED||Ct===states$1.REJECTED,$circle:pt.iconShape==="circle",children:[jsxRuntimeExports.jsx(AnimatePresence,{children:(Ct===states$1.FAILED||Ct===states$1.REJECTED)&&jsxRuntimeExports.jsx(RetryButton,{"aria-label":"Retry",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},whileTap:{scale:.9},transition:{duration:.1},onClick:kt,children:jsxRuntimeExports.jsx(RetryIconContainer,{children:jsxRuntimeExports.jsx(Tooltip,{open:gt&&(Ct===states$1.FAILED||Ct===states$1.REJECTED),message:At.tryAgainQuestion,xOffset:-6,children:jsxRuntimeExports.jsx(RetryIconCircle,{})})})})}),pt.iconShape==="circle"?jsxRuntimeExports.jsx(CircleSpinner,{logo:Ct===states$1.UNAVAILABLE?jsxRuntimeExports.jsx("div",{style:{transform:"scale(1.14)",position:"relative",width:"100%"},children:pt.icon}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:pt.icon}),smallLogo:pt.iconShouldShrink,connecting:Ct===states$1.CONNECTING,unavailable:Ct===states$1.UNAVAILABLE}):jsxRuntimeExports.jsx(SquircleSpinner,{logo:Ct===states$1.UNAVAILABLE?jsxRuntimeExports.jsx("div",{style:{transform:"scale(1.14)",position:"relative",width:"100%"},children:pt.icon}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:pt.icon}),connecting:Ct===states$1.CONNECTING})]})}),jsxRuntimeExports.jsx(ModalContentContainer,{children:jsxRuntimeExports.jsxs(AnimatePresence,{initial:!1,children:[Ct===states$1.FAILED&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{children:[jsxRuntimeExports.jsxs(ModalH1,{$error:!0,children:[jsxRuntimeExports.jsx(AlertIcon,{}),At.injectionScreen_failed_h1]}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_failed_p})]})},states$1.FAILED),Ct===states$1.REJECTED&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:28},children:[jsxRuntimeExports.jsx(ModalH1,{children:At.injectionScreen_rejected_h1}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_rejected_p})]})},states$1.REJECTED),(Ct===states$1.CONNECTING||Ct===states$1.EXPIRING)&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:28},children:[jsxRuntimeExports.jsx(ModalH1,{children:ft.connector.id==="injected"?At.injectionScreen_connecting_injected_h1:At.injectionScreen_connecting_h1}),jsxRuntimeExports.jsx(ModalBody,{children:ft.connector.id==="injected"?At.injectionScreen_connecting_injected_p:At.injectionScreen_connecting_p})]})},states$1.CONNECTING),Ct===states$1.CONNECTED&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{children:[jsxRuntimeExports.jsxs(ModalH1,{$valid:!0,children:[jsxRuntimeExports.jsx(TickIcon,{})," ",At.injectionScreen_connected_h1]}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_connected_p})]})},states$1.CONNECTED),Ct===states$1.NOTCONNECTED&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{children:[jsxRuntimeExports.jsx(ModalH1,{children:At.injectionScreen_notconnected_h1}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_notconnected_p})]})},states$1.NOTCONNECTED),Ct===states$1.UNAVAILABLE&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:vt?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:18},children:[jsxRuntimeExports.jsx(ModalH1,{children:At.injectionScreen_install_h1}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_install_p})]}),!ft.isInstalled&&vt&&jsxRuntimeExports.jsx(Button$1,{href:vt,icon:jsxRuntimeExports.jsx(BrowserIcon,{}),children:At.installTheExtension})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:12},children:[jsxRuntimeExports.jsx(ModalH1,{children:At.injectionScreen_unavailable_h1}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_unavailable_p})]}),!ft.isInstalled&&Et&&jsxRuntimeExports.jsxs(Button$1,{href:Et==null?void 0:Et.url,icon:jsxRuntimeExports.jsx(BrowserIcon,{browser:Et==null?void 0:Et.name}),children:["Install on ",Et==null?void 0:Et.label]})]})},states$1.UNAVAILABLE)]})})]})}):jsxRuntimeExports.jsx(PageContent,{children:jsxRuntimeExports.jsxs(Container$4,{children:[jsxRuntimeExports.jsx(ModalHeading,{children:"Invalid State"}),jsxRuntimeExports.jsx(ModalContent,{children:jsxRuntimeExports.jsx(Alert,{children:"No connectors match the id given. This state should never happen."})})]})})},QRCodeContainer=styled(motion.div)` +`,CircleSpinner=({logo:et,smallLogo:o,connecting:tt=!0,unavailable:rt=!1,countdown:nt=!1})=>jsxRuntimeExports.jsxs(LogoContainer$3,{transition:{duration:.5,ease:[.175,.885,.32,.98]},children:[jsxRuntimeExports.jsx(Logo,{$small:!rt&&o,style:rt?{borderRadius:0}:void 0,children:et}),jsxRuntimeExports.jsx(SpinnerContainer,{children:jsxRuntimeExports.jsxs(AnimatePresence,{children:[tt&&jsxRuntimeExports.jsx(Spinner$2,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:nt?1:0}},children:jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"102",height:"102",viewBox:"0 0 102 102",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("path",{d:"M52 100C24.3858 100 2 77.6142 2 50",stroke:"url(#paint0_linear_1943_4139)",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("defs",{children:jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_1943_4139",x1:"2",y1:"48.5",x2:"53",y2:"100",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-spinner-color)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-spinner-color)",stopOpacity:"0"})]})})]})},"Spinner"),nt&&jsxRuntimeExports.jsxs(ExpiringSpinner,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:[jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsx("div",{})]},"ExpiringSpinner")]})})]}),states$1={CONNECTED:"connected",CONNECTING:"connecting",EXPIRING:"expiring",FAILED:"failed",REJECTED:"rejected",NOTCONNECTED:"notconnected",UNAVAILABLE:"unavailable"},contentVariants$1={initial:{willChange:"transform,opacity",position:"relative",opacity:0,scale:.95},animate:{position:"relative",opacity:1,scale:1,transition:{ease:[.16,1,.3,1],duration:.4,delay:.05,position:{delay:0}}},exit:{position:"absolute",opacity:0,scale:.95,transition:{ease:[.16,1,.3,1],duration:.3}}},ConnectWithInjector=({switchConnectMethod:et,forceState:o})=>{var tt,rt,nt,ot,it,st,at,ct;const{connect:lt}=useConnect({mutation:{onMutate:Nt=>{Nt.connector?St(states$1.CONNECTING):St(states$1.UNAVAILABLE)},onError(Nt){console.error(Nt)},onSettled(Nt,Lt){if(Lt){if(gt(!0),setTimeout(()=>gt(!1),3500),Lt.code)switch(Lt.code){case-32002:St(states$1.NOTCONNECTED);break;case 4001:St(states$1.REJECTED);break;default:St(states$1.FAILED);break}else if(Lt.message)switch(Lt.message){case"User rejected request":St(states$1.REJECTED);break;default:St(states$1.FAILED);break}}setTimeout(dt,100)}}}),{triggerResize:dt,connector:ht}=useContext(),mt=ht.id,ft=useWallet(mt),pt={name:ft==null?void 0:ft.name,shortName:(tt=ft==null?void 0:ft.shortName)!==null&&tt!==void 0?tt:ft==null?void 0:ft.name,icon:(rt=ft==null?void 0:ft.iconConnector)!==null&&rt!==void 0?rt:ft==null?void 0:ft.icon,iconShape:(nt=ft==null?void 0:ft.iconShape)!==null&&nt!==void 0?nt:"circle",iconShouldShrink:ft==null?void 0:ft.iconShouldShrink},[yt,gt]=reactExports.useState(!1);reactExports.useState(9);const xt=detectBrowser(),vt=(ot=ft==null?void 0:ft.downloadUrls)===null||ot===void 0?void 0:ot[xt],Et=ft!=null&&ft.downloadUrls?{name:Object.keys(ft==null?void 0:ft.downloadUrls)[0],label:((it=Object.keys(ft==null?void 0:ft.downloadUrls)[0])===null||it===void 0?void 0:it.charAt(0).toUpperCase())+((st=Object.keys(ft==null?void 0:ft.downloadUrls)[0])===null||st===void 0?void 0:st.slice(1)),url:ft==null?void 0:ft.downloadUrls[Object.keys(ft==null?void 0:ft.downloadUrls)[0]]}:void 0,[Ct,St]=reactExports.useState(o||(ft!=null&&ft.isInstalled?states$1.CONNECTING:states$1.UNAVAILABLE)),At=useLocales({CONNECTORNAME:pt.name,CONNECTORSHORTNAME:(at=pt.shortName)!==null&&at!==void 0?at:pt.name,SUGGESTEDEXTENSIONBROWSER:(ct=Et==null?void 0:Et.label)!==null&&ct!==void 0?ct:"your browser"}),kt=async()=>{ft!=null&&ft.isInstalled&&(ft!=null&&ft.connector)?lt({connector:ft==null?void 0:ft.connector}):St(states$1.UNAVAILABLE)};let It;return reactExports.useEffect(()=>{if(Ct!==states$1.UNAVAILABLE)return It=setTimeout(kt,600),()=>{clearTimeout(It)}},[]),ft?isWalletConnectConnector(ft==null?void 0:ft.connector.id)?jsxRuntimeExports.jsx(PageContent,{children:jsxRuntimeExports.jsxs(Container$4,{children:[jsxRuntimeExports.jsx(ModalHeading,{children:"Invalid State"}),jsxRuntimeExports.jsx(ModalContent,{children:jsxRuntimeExports.jsx(Alert,{children:"WalletConnect does not have an injection flow. This state should never happen."})})]})}):jsxRuntimeExports.jsx(PageContent,{children:jsxRuntimeExports.jsxs(Container$4,{children:[jsxRuntimeExports.jsx(ConnectingContainer,{children:jsxRuntimeExports.jsxs(ConnectingAnimation,{$shake:Ct===states$1.FAILED||Ct===states$1.REJECTED,$circle:pt.iconShape==="circle",children:[jsxRuntimeExports.jsx(AnimatePresence,{children:(Ct===states$1.FAILED||Ct===states$1.REJECTED)&&jsxRuntimeExports.jsx(RetryButton,{"aria-label":"Retry",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},whileTap:{scale:.9},transition:{duration:.1},onClick:kt,children:jsxRuntimeExports.jsx(RetryIconContainer,{children:jsxRuntimeExports.jsx(Tooltip,{open:yt&&(Ct===states$1.FAILED||Ct===states$1.REJECTED),message:At.tryAgainQuestion,xOffset:-6,children:jsxRuntimeExports.jsx(RetryIconCircle,{})})})})}),pt.iconShape==="circle"?jsxRuntimeExports.jsx(CircleSpinner,{logo:Ct===states$1.UNAVAILABLE?jsxRuntimeExports.jsx("div",{style:{transform:"scale(1.14)",position:"relative",width:"100%"},children:pt.icon}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:pt.icon}),smallLogo:pt.iconShouldShrink,connecting:Ct===states$1.CONNECTING,unavailable:Ct===states$1.UNAVAILABLE}):jsxRuntimeExports.jsx(SquircleSpinner,{logo:Ct===states$1.UNAVAILABLE?jsxRuntimeExports.jsx("div",{style:{transform:"scale(1.14)",position:"relative",width:"100%"},children:pt.icon}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:pt.icon}),connecting:Ct===states$1.CONNECTING})]})}),jsxRuntimeExports.jsx(ModalContentContainer,{children:jsxRuntimeExports.jsxs(AnimatePresence,{initial:!1,children:[Ct===states$1.FAILED&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{children:[jsxRuntimeExports.jsxs(ModalH1,{$error:!0,children:[jsxRuntimeExports.jsx(AlertIcon,{}),At.injectionScreen_failed_h1]}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_failed_p})]})},states$1.FAILED),Ct===states$1.REJECTED&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:28},children:[jsxRuntimeExports.jsx(ModalH1,{children:At.injectionScreen_rejected_h1}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_rejected_p})]})},states$1.REJECTED),(Ct===states$1.CONNECTING||Ct===states$1.EXPIRING)&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:28},children:[jsxRuntimeExports.jsx(ModalH1,{children:ft.connector.id==="injected"?At.injectionScreen_connecting_injected_h1:At.injectionScreen_connecting_h1}),jsxRuntimeExports.jsx(ModalBody,{children:ft.connector.id==="injected"?At.injectionScreen_connecting_injected_p:At.injectionScreen_connecting_p})]})},states$1.CONNECTING),Ct===states$1.CONNECTED&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{children:[jsxRuntimeExports.jsxs(ModalH1,{$valid:!0,children:[jsxRuntimeExports.jsx(TickIcon,{})," ",At.injectionScreen_connected_h1]}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_connected_p})]})},states$1.CONNECTED),Ct===states$1.NOTCONNECTED&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:jsxRuntimeExports.jsxs(ModalContent,{children:[jsxRuntimeExports.jsx(ModalH1,{children:At.injectionScreen_notconnected_h1}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_notconnected_p})]})},states$1.NOTCONNECTED),Ct===states$1.UNAVAILABLE&&jsxRuntimeExports.jsx(Content$1,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$1,children:vt?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:18},children:[jsxRuntimeExports.jsx(ModalH1,{children:At.injectionScreen_install_h1}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_install_p})]}),!ft.isInstalled&&vt&&jsxRuntimeExports.jsx(Button$1,{href:vt,icon:jsxRuntimeExports.jsx(BrowserIcon,{}),children:At.installTheExtension})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:12},children:[jsxRuntimeExports.jsx(ModalH1,{children:At.injectionScreen_unavailable_h1}),jsxRuntimeExports.jsx(ModalBody,{children:At.injectionScreen_unavailable_p})]}),!ft.isInstalled&&Et&&jsxRuntimeExports.jsxs(Button$1,{href:Et==null?void 0:Et.url,icon:jsxRuntimeExports.jsx(BrowserIcon,{browser:Et==null?void 0:Et.name}),children:["Install on ",Et==null?void 0:Et.label]})]})},states$1.UNAVAILABLE)]})})]})}):jsxRuntimeExports.jsx(PageContent,{children:jsxRuntimeExports.jsxs(Container$4,{children:[jsxRuntimeExports.jsx(ModalHeading,{children:"Invalid State"}),jsxRuntimeExports.jsx(ModalContent,{children:jsxRuntimeExports.jsx(Alert,{children:"No connectors match the id given. This state should never happen."})})]})})},QRCodeContainer=styled(motion.div)` z-index: 3; position: relative; overflow: hidden; @@ -2882,7 +2882,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.02); } `} -`,generateMatrix=(et,o)=>{const tt=Array.prototype.slice.call(browser$1.create(et,{errorCorrectionLevel:o}).modules.data,0),rt=Math.sqrt(tt.length);return tt.reduce((nt,ot,it)=>(it%rt===0?nt.push([ot]):nt[nt.length-1].push(ot))&&nt,[])};function QRCode$1({ecl:et="M",size:o=200,uri:tt,clearArea:rt=!1,image:nt,imageBackground:ot="transparent"}){const it=rt?76:0,st=o-10*2,at=reactExports.useMemo(()=>{const ct=[],lt=generateMatrix(tt,et),dt=st/lt.length;if([{x:0,y:0},{x:1,y:0},{x:0,y:1}].forEach(({x:gt,y:yt})=>{const bt=(lt.length-7)*dt*gt,xt=(lt.length-7)*dt*yt;for(let vt=0;vt<3;vt++)ct.push(jsxRuntimeExports.jsx("rect",{fill:vt%2!==0?"var(--ck-qr-background, var(--ck-body-background))":"var(--ck-qr-dot-color)",rx:(vt-2)*-5+(vt===0?2:3),ry:(vt-2)*-5+(vt===0?2:3),width:dt*(7-vt*2),height:dt*(7-vt*2),x:bt+dt*vt,y:xt+dt*vt},`${vt}-${gt}-${yt}`))}),nt){const gt=(lt.length-7)*dt*1,yt=(lt.length-7)*dt*1;ct.push(jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("rect",{fill:ot,rx:-2*-5+2,ry:-2*-5+2,width:dt*(7-0*2),height:dt*(7-0*2),x:gt+dt*0,y:yt+dt*0}),jsxRuntimeExports.jsx("foreignObject",{width:dt*(7-0*2),height:dt*(7-0*2),x:gt+dt*0,y:yt+dt*0,children:jsxRuntimeExports.jsx("div",{style:{borderRadius:-2*-5+2,overflow:"hidden"},children:nt})})]}))}const mt=Math.floor((it+25)/dt),ft=lt.length/2-mt/2,pt=lt.length/2+mt/2-1;return lt.forEach((gt,yt)=>{gt.forEach((bt,xt)=>{lt[yt][xt]&&(yt<7&&xt<7||yt>lt.length-8&&xt<7||yt<7&&xt>lt.length-8||(nt||!(yt>ft&&ytft&&xt{function tt(){o({width:window.innerWidth,height:window.innerHeight})}return window.addEventListener("resize",tt),tt(),()=>window.removeEventListener("resize",tt)},[]),et}function CustomQRCode({value:et,image:o,imageBackground:tt,imagePosition:rt="center",tooltipMessage:nt}){const it=useWindowSize().width>920&&nt?jsxRuntimeExports.jsx(Tooltip,{xOffset:139,yOffset:5,delay:.1,message:nt,children:o}):o;return jsxRuntimeExports.jsx(QRCodeContainer,{children:jsxRuntimeExports.jsxs(QRCodeContent,{children:[o&&jsxRuntimeExports.jsx(LogoContainer$2,{children:jsxRuntimeExports.jsx(LogoIcon,{$wcLogo:rt!=="center",style:{background:rt==="center"?tt:void 0},children:it})}),jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:et?jsxRuntimeExports.jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,position:"absolute",inset:[0,0]},transition:{duration:.2},children:jsxRuntimeExports.jsx(QRCode$1,{uri:et,size:288,ecl:"M",clearArea:!!(rt==="center"&&o)})},et):jsxRuntimeExports.jsxs(QRPlaceholder,{initial:{opacity:.1},animate:{opacity:.1},exit:{opacity:0,position:"absolute",inset:[0,0]},transition:{duration:.2},children:[jsxRuntimeExports.jsx("span",{}),jsxRuntimeExports.jsx("span",{}),jsxRuntimeExports.jsx("span",{}),jsxRuntimeExports.jsx("div",{})]})})]})})}CustomQRCode.displayName="CustomQRCode";const IconContainer$1=styled(motion.div)` +`,generateMatrix=(et,o)=>{const tt=Array.prototype.slice.call(browser$1.create(et,{errorCorrectionLevel:o}).modules.data,0),rt=Math.sqrt(tt.length);return tt.reduce((nt,ot,it)=>(it%rt===0?nt.push([ot]):nt[nt.length-1].push(ot))&&nt,[])};function QRCode$1({ecl:et="M",size:o=200,uri:tt,clearArea:rt=!1,image:nt,imageBackground:ot="transparent"}){const it=rt?76:0,st=o-10*2,at=reactExports.useMemo(()=>{const ct=[],lt=generateMatrix(tt,et),dt=st/lt.length;if([{x:0,y:0},{x:1,y:0},{x:0,y:1}].forEach(({x:yt,y:gt})=>{const bt=(lt.length-7)*dt*yt,xt=(lt.length-7)*dt*gt;for(let vt=0;vt<3;vt++)ct.push(jsxRuntimeExports.jsx("rect",{fill:vt%2!==0?"var(--ck-qr-background, var(--ck-body-background))":"var(--ck-qr-dot-color)",rx:(vt-2)*-5+(vt===0?2:3),ry:(vt-2)*-5+(vt===0?2:3),width:dt*(7-vt*2),height:dt*(7-vt*2),x:bt+dt*vt,y:xt+dt*vt},`${vt}-${yt}-${gt}`))}),nt){const yt=(lt.length-7)*dt*1,gt=(lt.length-7)*dt*1;ct.push(jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("rect",{fill:ot,rx:-2*-5+2,ry:-2*-5+2,width:dt*(7-0*2),height:dt*(7-0*2),x:yt+dt*0,y:gt+dt*0}),jsxRuntimeExports.jsx("foreignObject",{width:dt*(7-0*2),height:dt*(7-0*2),x:yt+dt*0,y:gt+dt*0,children:jsxRuntimeExports.jsx("div",{style:{borderRadius:-2*-5+2,overflow:"hidden"},children:nt})})]}))}const mt=Math.floor((it+25)/dt),ft=lt.length/2-mt/2,pt=lt.length/2+mt/2-1;return lt.forEach((yt,gt)=>{yt.forEach((bt,xt)=>{lt[gt][xt]&&(gt<7&&xt<7||gt>lt.length-8&&xt<7||gt<7&&xt>lt.length-8||(nt||!(gt>ft&>ft&&xt{function tt(){o({width:window.innerWidth,height:window.innerHeight})}return window.addEventListener("resize",tt),tt(),()=>window.removeEventListener("resize",tt)},[]),et}function CustomQRCode({value:et,image:o,imageBackground:tt,imagePosition:rt="center",tooltipMessage:nt}){const it=useWindowSize().width>920&&nt?jsxRuntimeExports.jsx(Tooltip,{xOffset:139,yOffset:5,delay:.1,message:nt,children:o}):o;return jsxRuntimeExports.jsx(QRCodeContainer,{children:jsxRuntimeExports.jsxs(QRCodeContent,{children:[o&&jsxRuntimeExports.jsx(LogoContainer$2,{children:jsxRuntimeExports.jsx(LogoIcon,{$wcLogo:rt!=="center",style:{background:rt==="center"?tt:void 0},children:it})}),jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:et?jsxRuntimeExports.jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,position:"absolute",inset:[0,0]},transition:{duration:.2},children:jsxRuntimeExports.jsx(QRCode$1,{uri:et,size:288,ecl:"M",clearArea:!!(rt==="center"&&o)})},et):jsxRuntimeExports.jsxs(QRPlaceholder,{initial:{opacity:.1},animate:{opacity:.1},exit:{opacity:0,position:"absolute",inset:[0,0]},transition:{duration:.2},children:[jsxRuntimeExports.jsx("span",{}),jsxRuntimeExports.jsx("span",{}),jsxRuntimeExports.jsx("span",{}),jsxRuntimeExports.jsx("div",{})]})})]})})}CustomQRCode.displayName="CustomQRCode";const IconContainer$1=styled(motion.div)` position: relative; display: flex; align-items: center; @@ -2896,7 +2896,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C max-width: 100%; height: auto; } -`,ScanIconWithLogos=({logo:et})=>{const o=[jsxRuntimeExports.jsx(Logos.MetaMask,{background:!0}),jsxRuntimeExports.jsx(Logos.Coinbase,{background:!0}),jsxRuntimeExports.jsx(Logos.Crypto,{}),jsxRuntimeExports.jsx(Logos.ImToken,{}),jsxRuntimeExports.jsx(Logos.Argent,{}),jsxRuntimeExports.jsx(Logos.Trust,{})];return jsxRuntimeExports.jsx(IconContainer$1,{children:jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"47",height:"52",viewBox:"0 0 47 52",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsxs("g",{mask:"url(#gradient-mask)",children:[jsxRuntimeExports.jsx("path",{d:"M7 14.5C7 11.4624 9.46243 9 12.5 9H31.5C34.5376 9 37 11.4624 37 14.5V47H7V14.5Z",fill:"var(--ck-graphic-scaniconwithlogos-04)"}),et?jsxRuntimeExports.jsx("foreignObject",{x:"13",y:"21",width:"18",height:"18",rx:"5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:5},children:et})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("foreignObject",{x:"12",y:"15",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[0]})}),jsxRuntimeExports.jsx("foreignObject",{x:"23",y:"15",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[1]})}),jsxRuntimeExports.jsx("foreignObject",{x:"12",y:"26",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[2]})})}),jsxRuntimeExports.jsx("foreignObject",{x:"23",y:"26",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[3]})}),jsxRuntimeExports.jsx("foreignObject",{x:"12",y:"37",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[4]})}),jsxRuntimeExports.jsx("foreignObject",{x:"23",y:"37",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[5]})})]}),jsxRuntimeExports.jsx("path",{d:"M36 47V13.7143C36 11.1107 33.8893 9 31.2857 9H12.7143C10.1107 9 8 11.1107 8 13.7143V47",stroke:"url(#paint0_linear_924_12568)",strokeWidth:"2"}),jsxRuntimeExports.jsx("path",{d:"M15 10H29C29 11.1046 28.1046 12 27 12H17C15.8954 12 15 11.1046 15 10Z",fill:"var(--ck-graphic-scaniconwithlogos-01)"}),jsxRuntimeExports.jsx("rect",{x:"1",y:"47",width:"43",height:"5",fill:"var(--ck-tooltip-background)"}),jsxRuntimeExports.jsx("rect",{x:"22",y:"1",width:"24",height:"24",rx:"12",fill:"var(--ck-graphic-scaniconwithlogos-03)",stroke:"var(--ck-tooltip-background)",strokeWidth:"2"}),jsxRuntimeExports.jsx("rect",{x:"34.5",y:"10",width:"2.5",height:"2.5",rx:"0.75",fill:"#373737"}),jsxRuntimeExports.jsx("rect",{x:"31",y:"10",width:"2.5",height:"2.5",rx:"0.75",fill:"#373737"}),jsxRuntimeExports.jsx("rect",{x:"31",y:"13.5",width:"2.5",height:"2.5",rx:"0.75",fill:"#373737"}),jsxRuntimeExports.jsx("rect",{x:"34.5",y:"13.5",width:"2.5",height:"2.5",rx:"0.75",fill:"#373737"}),jsxRuntimeExports.jsx("path",{d:"M28.5 10.5V9C28.5 8.17157 29.1716 7.5 30 7.5H31.5",stroke:"#373737",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M36.5 7.5L38 7.5C38.8284 7.5 39.5 8.17157 39.5 9L39.5 10.5",stroke:"#373737",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M39.5 15.5L39.5 17C39.5 17.8284 38.8284 18.5 38 18.5L36.5 18.5",stroke:"#373737",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M31.5 18.5L30 18.5C29.1716 18.5 28.5 17.8284 28.5 17L28.5 15.5",stroke:"#373737",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_924_12568",x1:"22",y1:"8.2549",x2:"22",y2:"47",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-scaniconwithlogos-01)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-scaniconwithlogos-02)"})]}),jsxRuntimeExports.jsxs("linearGradient",{id:"linear-gradient-mask",x1:"47",y1:"42",x2:"47",y2:"47",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"black",stopOpacity:"0"})]}),jsxRuntimeExports.jsx("mask",{id:"gradient-mask",children:jsxRuntimeExports.jsx("rect",{x:"0",y:"0",width:"47",height:"52",fill:"url(#linear-gradient-mask)"})})]})]})})},ConnectWithQRCode=({switchConnectMethod:et})=>{var o,tt,rt,nt,ot,it,st,at;const ct=useContext(),lt=ct.connector.id,dt=useWallet(ct.connector.id),{open:ht,isOpen:mt}=useWalletConnectModal(),{connect:{getUri:ft}}=useWeb3(),pt=ft(lt),gt=pt?(tt=(o=dt==null?void 0:dt.getWalletConnectDeeplink)===null||o===void 0?void 0:o.call(dt,pt))!==null&&tt!==void 0?tt:pt:void 0,yt=useLocales({CONNECTORNAME:dt==null?void 0:dt.name});if(!dt)return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:["Wallet not found ",ct.connector.id]});const bt=dt==null?void 0:dt.downloadUrls,xt={chrome:bt==null?void 0:bt.chrome,firefox:bt==null?void 0:bt.firefox,brave:bt==null?void 0:bt.brave,edge:bt==null?void 0:bt.edge,safari:bt==null?void 0:bt.safari};detectBrowser();const vt=bt&&Object.keys(bt).length!==0;xt&&(Object.keys(xt)[0],((rt=Object.keys(xt)[0])===null||rt===void 0?void 0:rt.charAt(0).toUpperCase())+((nt=Object.keys(xt)[0])===null||nt===void 0?void 0:nt.slice(1)),xt[Object.keys(xt)[0]]);const Et=isWalletConnectConnector(lt);return jsxRuntimeExports.jsxs(PageContent,{children:[jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:8,gap:14},children:[jsxRuntimeExports.jsx(CustomQRCode,{value:gt,image:dt==null?void 0:dt.icon,tooltipMessage:isWalletConnectConnector(lt)?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ScanIconWithLogos,{}),jsxRuntimeExports.jsx("span",{children:yt.scanScreen_tooltip_walletConnect})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ScanIconWithLogos,{logo:dt==null?void 0:dt.icon}),jsxRuntimeExports.jsx("span",{children:yt.scanScreen_tooltip_default})]})}),Et?jsxRuntimeExports.jsx(OrDivider,{}):vt&&jsxRuntimeExports.jsx(OrDivider,{children:yt.dontHaveTheApp})]}),Et&&jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:14},children:[((ot=ct.options)===null||ot===void 0?void 0:ot.walletConnectCTA)!=="modal"&&jsxRuntimeExports.jsx(CopyToClipboard,{variant:"button",string:gt,children:((it=ct.options)===null||it===void 0?void 0:it.walletConnectCTA)==="link"?yt.copyToClipboard:yt.copyCode}),((st=ct.options)===null||st===void 0?void 0:st.walletConnectCTA)!=="link"&&jsxRuntimeExports.jsx(Button$1,{icon:jsxRuntimeExports.jsx(ExternalLinkIcon,{}),onClick:ht,disabled:mt,waiting:mt,children:((at=ct.options)===null||at===void 0?void 0:at.walletConnectCTA)==="modal"?yt.useWalletConnectModal:yt.useModal})]}),vt&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Button$1,{onClick:()=>{ct.setRoute(routes.DOWNLOAD)},download:!0,children:yt.getWalletName})})]})},states={QRCODE:"qrcode",INJECTOR:"injector"},ConnectUsing=()=>{const et=useContext(),o=useWallet(et.connector.id),tt=!(o!=null&&o.isInstalled)&&(o==null?void 0:o.getWalletConnectDeeplink),[rt,nt]=reactExports.useState(tt?states.QRCODE:states.INJECTOR);return reactExports.useEffect(()=>{const ot=async()=>{await(o==null?void 0:o.connector.getProvider())||(nt(states.QRCODE),setTimeout(et.triggerResize,10))};rt===states.INJECTOR&&ot()},[]),o?jsxRuntimeExports.jsxs(AnimatePresence,{children:[rt===states.QRCODE&&jsxRuntimeExports.jsx(motion.div,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$2,children:jsxRuntimeExports.jsx(ConnectWithQRCode,{switchConnectMethod:ot=>{nt(states.INJECTOR)}})},states.QRCODE),rt===states.INJECTOR&&jsxRuntimeExports.jsx(motion.div,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$2,children:jsxRuntimeExports.jsx(ConnectWithInjector,{switchConnectMethod:ot=>{nt(states.QRCODE)}})},states.INJECTOR)]}):jsxRuntimeExports.jsxs(Alert,{children:["Connector not found ",et.connector.id]})},DownloadApp=()=>{var et,o,tt;const rt=useContext(),nt=useWallet(rt.connector.id),ot=useLocales({CONNECTORNAME:nt==null?void 0:nt.name});if(!nt)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:"Wallet not found"});const it={ios:(et=nt.downloadUrls)===null||et===void 0?void 0:et.ios,android:(o=nt.downloadUrls)===null||o===void 0?void 0:o.android,redirect:(tt=nt.downloadUrls)===null||tt===void 0?void 0:tt.download},st=it.ios&&it.android?ot.downloadAppScreen_iosAndroid:it.ios?ot.downloadAppScreen_ios:ot.downloadAppScreen_android;return jsxRuntimeExports.jsx(PageContent,{children:jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:4,gap:14},children:[it.redirect&&jsxRuntimeExports.jsx(CustomQRCode,{value:it.redirect}),!it.redirect&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:"No download link available"}),jsxRuntimeExports.jsx(ModalBody,{style:{fontSize:15,lineHeight:"20px",padding:"0 12px"},children:st})]})})},AvatarContainer=styled(motion.div)` +`,ScanIconWithLogos=({logo:et})=>{const o=[jsxRuntimeExports.jsx(Logos.MetaMask,{background:!0}),jsxRuntimeExports.jsx(Logos.Coinbase,{background:!0}),jsxRuntimeExports.jsx(Logos.Crypto,{}),jsxRuntimeExports.jsx(Logos.ImToken,{}),jsxRuntimeExports.jsx(Logos.Argent,{}),jsxRuntimeExports.jsx(Logos.Trust,{})];return jsxRuntimeExports.jsx(IconContainer$1,{children:jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"47",height:"52",viewBox:"0 0 47 52",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsxs("g",{mask:"url(#gradient-mask)",children:[jsxRuntimeExports.jsx("path",{d:"M7 14.5C7 11.4624 9.46243 9 12.5 9H31.5C34.5376 9 37 11.4624 37 14.5V47H7V14.5Z",fill:"var(--ck-graphic-scaniconwithlogos-04)"}),et?jsxRuntimeExports.jsx("foreignObject",{x:"13",y:"21",width:"18",height:"18",rx:"5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:5},children:et})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("foreignObject",{x:"12",y:"15",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[0]})}),jsxRuntimeExports.jsx("foreignObject",{x:"23",y:"15",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[1]})}),jsxRuntimeExports.jsx("foreignObject",{x:"12",y:"26",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[2]})})}),jsxRuntimeExports.jsx("foreignObject",{x:"23",y:"26",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[3]})}),jsxRuntimeExports.jsx("foreignObject",{x:"12",y:"37",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[4]})}),jsxRuntimeExports.jsx("foreignObject",{x:"23",y:"37",width:"9",height:"9",rx:"2.5",children:jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",borderRadius:2.5},children:o[5]})})]}),jsxRuntimeExports.jsx("path",{d:"M36 47V13.7143C36 11.1107 33.8893 9 31.2857 9H12.7143C10.1107 9 8 11.1107 8 13.7143V47",stroke:"url(#paint0_linear_924_12568)",strokeWidth:"2"}),jsxRuntimeExports.jsx("path",{d:"M15 10H29C29 11.1046 28.1046 12 27 12H17C15.8954 12 15 11.1046 15 10Z",fill:"var(--ck-graphic-scaniconwithlogos-01)"}),jsxRuntimeExports.jsx("rect",{x:"1",y:"47",width:"43",height:"5",fill:"var(--ck-tooltip-background)"}),jsxRuntimeExports.jsx("rect",{x:"22",y:"1",width:"24",height:"24",rx:"12",fill:"var(--ck-graphic-scaniconwithlogos-03)",stroke:"var(--ck-tooltip-background)",strokeWidth:"2"}),jsxRuntimeExports.jsx("rect",{x:"34.5",y:"10",width:"2.5",height:"2.5",rx:"0.75",fill:"#373737"}),jsxRuntimeExports.jsx("rect",{x:"31",y:"10",width:"2.5",height:"2.5",rx:"0.75",fill:"#373737"}),jsxRuntimeExports.jsx("rect",{x:"31",y:"13.5",width:"2.5",height:"2.5",rx:"0.75",fill:"#373737"}),jsxRuntimeExports.jsx("rect",{x:"34.5",y:"13.5",width:"2.5",height:"2.5",rx:"0.75",fill:"#373737"}),jsxRuntimeExports.jsx("path",{d:"M28.5 10.5V9C28.5 8.17157 29.1716 7.5 30 7.5H31.5",stroke:"#373737",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M36.5 7.5L38 7.5C38.8284 7.5 39.5 8.17157 39.5 9L39.5 10.5",stroke:"#373737",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M39.5 15.5L39.5 17C39.5 17.8284 38.8284 18.5 38 18.5L36.5 18.5",stroke:"#373737",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M31.5 18.5L30 18.5C29.1716 18.5 28.5 17.8284 28.5 17L28.5 15.5",stroke:"#373737",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_924_12568",x1:"22",y1:"8.2549",x2:"22",y2:"47",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-graphic-scaniconwithlogos-01)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-graphic-scaniconwithlogos-02)"})]}),jsxRuntimeExports.jsxs("linearGradient",{id:"linear-gradient-mask",x1:"47",y1:"42",x2:"47",y2:"47",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"black",stopOpacity:"0"})]}),jsxRuntimeExports.jsx("mask",{id:"gradient-mask",children:jsxRuntimeExports.jsx("rect",{x:"0",y:"0",width:"47",height:"52",fill:"url(#linear-gradient-mask)"})})]})]})})},ConnectWithQRCode=({switchConnectMethod:et})=>{var o,tt,rt,nt,ot,it,st,at;const ct=useContext(),lt=ct.connector.id,dt=useWallet(ct.connector.id),{open:ht,isOpen:mt}=useWalletConnectModal(),{connect:{getUri:ft}}=useWeb3(),pt=ft(lt),yt=pt?(tt=(o=dt==null?void 0:dt.getWalletConnectDeeplink)===null||o===void 0?void 0:o.call(dt,pt))!==null&&tt!==void 0?tt:pt:void 0,gt=useLocales({CONNECTORNAME:dt==null?void 0:dt.name});if(!dt)return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:["Wallet not found ",ct.connector.id]});const bt=dt==null?void 0:dt.downloadUrls,xt={chrome:bt==null?void 0:bt.chrome,firefox:bt==null?void 0:bt.firefox,brave:bt==null?void 0:bt.brave,edge:bt==null?void 0:bt.edge,safari:bt==null?void 0:bt.safari};detectBrowser();const vt=bt&&Object.keys(bt).length!==0;xt&&(Object.keys(xt)[0],((rt=Object.keys(xt)[0])===null||rt===void 0?void 0:rt.charAt(0).toUpperCase())+((nt=Object.keys(xt)[0])===null||nt===void 0?void 0:nt.slice(1)),xt[Object.keys(xt)[0]]);const Et=isWalletConnectConnector(lt);return jsxRuntimeExports.jsxs(PageContent,{children:[jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:8,gap:14},children:[jsxRuntimeExports.jsx(CustomQRCode,{value:yt,image:dt==null?void 0:dt.icon,tooltipMessage:isWalletConnectConnector(lt)?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ScanIconWithLogos,{}),jsxRuntimeExports.jsx("span",{children:gt.scanScreen_tooltip_walletConnect})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ScanIconWithLogos,{logo:dt==null?void 0:dt.icon}),jsxRuntimeExports.jsx("span",{children:gt.scanScreen_tooltip_default})]})}),Et?jsxRuntimeExports.jsx(OrDivider,{}):vt&&jsxRuntimeExports.jsx(OrDivider,{children:gt.dontHaveTheApp})]}),Et&&jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:14},children:[((ot=ct.options)===null||ot===void 0?void 0:ot.walletConnectCTA)!=="modal"&&jsxRuntimeExports.jsx(CopyToClipboard,{variant:"button",string:yt,children:((it=ct.options)===null||it===void 0?void 0:it.walletConnectCTA)==="link"?gt.copyToClipboard:gt.copyCode}),((st=ct.options)===null||st===void 0?void 0:st.walletConnectCTA)!=="link"&&jsxRuntimeExports.jsx(Button$1,{icon:jsxRuntimeExports.jsx(ExternalLinkIcon,{}),onClick:ht,disabled:mt,waiting:mt,children:((at=ct.options)===null||at===void 0?void 0:at.walletConnectCTA)==="modal"?gt.useWalletConnectModal:gt.useModal})]}),vt&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Button$1,{onClick:()=>{ct.setRoute(routes.DOWNLOAD)},download:!0,children:gt.getWalletName})})]})},states={QRCODE:"qrcode",INJECTOR:"injector"},ConnectUsing=()=>{const et=useContext(),o=useWallet(et.connector.id),tt=!(o!=null&&o.isInstalled)&&(o==null?void 0:o.getWalletConnectDeeplink),[rt,nt]=reactExports.useState(tt?states.QRCODE:states.INJECTOR);return reactExports.useEffect(()=>{const ot=async()=>{await(o==null?void 0:o.connector.getProvider())||(nt(states.QRCODE),setTimeout(et.triggerResize,10))};rt===states.INJECTOR&&ot()},[]),o?jsxRuntimeExports.jsxs(AnimatePresence,{children:[rt===states.QRCODE&&jsxRuntimeExports.jsx(motion.div,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$2,children:jsxRuntimeExports.jsx(ConnectWithQRCode,{switchConnectMethod:ot=>{nt(states.INJECTOR)}})},states.QRCODE),rt===states.INJECTOR&&jsxRuntimeExports.jsx(motion.div,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants$2,children:jsxRuntimeExports.jsx(ConnectWithInjector,{switchConnectMethod:ot=>{nt(states.QRCODE)}})},states.INJECTOR)]}):jsxRuntimeExports.jsxs(Alert,{children:["Connector not found ",et.connector.id]})},DownloadApp=()=>{var et,o,tt;const rt=useContext(),nt=useWallet(rt.connector.id),ot=useLocales({CONNECTORNAME:nt==null?void 0:nt.name});if(!nt)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:"Wallet not found"});const it={ios:(et=nt.downloadUrls)===null||et===void 0?void 0:et.ios,android:(o=nt.downloadUrls)===null||o===void 0?void 0:o.android,redirect:(tt=nt.downloadUrls)===null||tt===void 0?void 0:tt.download},st=it.ios&&it.android?ot.downloadAppScreen_iosAndroid:it.ios?ot.downloadAppScreen_ios:ot.downloadAppScreen_android;return jsxRuntimeExports.jsx(PageContent,{children:jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:4,gap:14},children:[it.redirect&&jsxRuntimeExports.jsx(CustomQRCode,{value:it.redirect}),!it.redirect&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:"No download link available"}),jsxRuntimeExports.jsx(ModalBody,{style:{fontSize:15,lineHeight:"20px",padding:"0 12px"},children:st})]})})},AvatarContainer=styled(motion.div)` padding: 18px 0 20px; @media only screen and (max-width: ${defaultTheme.mobileWidth}px) { padding: 16px 0 20px; @@ -2975,7 +2975,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C will-change: opacity; // Needed for Safari transition: opacity 500ms ease; transform: scale(1.01); // fixes background color bleeding -`;function useIsMounted(){const[et,o]=reactExports.useState(!1);return reactExports.useEffect(()=>o(!0),[]),et}const ensFallbackConfig=createConfig({chains:[mainnet],transports:{[mainnet.id]:http()}});function useEnsFallbackConfig(){return useChainIsSupported(1)?void 0:ensFallbackConfig}const Avatar=({address:et,name:o,size:tt=96,radius:rt=96})=>{var nt,ot,it;const st=useIsMounted(),at=useContext(),ct=reactExports.useRef(null),[lt,dt]=reactExports.useState(!0),ht=useEnsFallbackConfig(),{data:mt}=useEnsAddress({chainId:1,name:o,config:ht}),{data:ft}=useEnsName({chainId:1,address:(nt=et??mt)!==null&&nt!==void 0?nt:void 0,config:ht}),{data:pt}=useEnsAvatar({chainId:1,name:normalize$2(ft??""),config:ht}),gt={address:mt??et,name:ft??o,avatar:pt??void 0};return reactExports.useEffect(()=>{ct.current&&ct.current.complete&&ct.current.naturalHeight!==0||dt(!1)},[pt]),st?!((ot=at.options)===null||ot===void 0)&&ot.customAvatar?jsxRuntimeExports.jsx("div",{style:{width:tt,height:tt,borderRadius:rt,overflow:"hidden"},children:(it=at.options)===null||it===void 0?void 0:it.customAvatar({address:et??(gt==null?void 0:gt.address),ensName:o??(gt==null?void 0:gt.name),ensImage:gt==null?void 0:gt.avatar,size:tt,radius:rt})}):!gt.name||!gt.avatar?jsxRuntimeExports.jsx(ResetContainer,{style:{pointerEvents:"none"},children:jsxRuntimeExports.jsx(EnsAvatar,{$size:tt,$seed:gt.address,$radius:rt})}):jsxRuntimeExports.jsx(ResetContainer,{style:{pointerEvents:"none"},children:jsxRuntimeExports.jsx(EnsAvatar,{$size:tt,$seed:gt.address,$radius:rt,children:jsxRuntimeExports.jsx(ImageContainer,{ref:ct,src:gt.avatar,alt:gt.name,onLoad:()=>dt(!0),$loaded:lt})})}):jsxRuntimeExports.jsx("div",{style:{width:tt,height:tt,borderRadius:rt}})},KnownChain=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"black"},children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.5611 8.12948C21.0082 7.90729 21.5007 7.79167 22 7.79167C22.4993 7.79167 22.9919 7.90729 23.439 8.12948L23.4408 8.1304L33.0387 12.9293C33.577 13.197 34.031 13.61 34.3478 14.121C34.6649 14.6323 34.833 15.2218 34.8333 15.8234V27.2595C34.833 27.8611 34.6649 28.4511 34.3478 28.9624C34.031 29.4733 33.578 29.8858 33.0398 30.1535L23.4411 34.9528C22.9919 35.1775 22.4963 35.2947 21.994 35.2947C21.4918 35.2947 20.9964 35.1777 20.5472 34.9529L10.9475 30.1531L10.9452 30.1519C10.4071 29.8808 9.95535 29.4646 9.6411 28.9504C9.32739 28.437 9.16312 27.8464 9.16673 27.2448L9.16675 27.2417L10.0004 27.2475H9.16673V27.2448V15.8239C9.16705 15.2223 9.33518 14.6322 9.65222 14.121C9.96906 13.61 10.4221 13.1976 10.9604 12.9298L20.5592 8.1304L20.5611 8.12948ZM21.3031 9.62267L11.8706 14.3389L22 19.4036L32.1294 14.3389L22.697 9.62267C22.4806 9.51531 22.2416 9.45905 22 9.45905C21.7585 9.45905 21.5194 9.51534 21.3031 9.62267ZM10.8341 15.8241C10.8341 15.7785 10.8362 15.733 10.8401 15.6878L21.1663 20.8509V33.3983L11.6955 28.6629C11.4352 28.5315 11.2159 28.3297 11.0638 28.0809C10.9116 27.8318 10.8321 27.5452 10.8341 27.2533L10.8341 27.2475V15.8241ZM22.8337 33.3923L32.2967 28.6608C32.5576 28.5312 32.7772 28.3313 32.9308 28.0836C33.0844 27.836 33.1658 27.5504 33.166 27.259V15.8243C33.1659 15.7786 33.1639 15.7331 33.1599 15.6878L22.8337 20.8509V33.3923Z",fill:"url(#paint0_linear_3546_7073)"}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.8341 15.8241C10.8341 15.7785 10.8362 15.733 10.8401 15.6878L21.1663 20.8509V33.3983L11.6955 28.6629C11.4352 28.5315 11.2159 28.3297 11.0638 28.0809C10.9116 27.8318 10.8321 27.5452 10.8341 27.2533L10.8341 27.2475V15.8241Z",fill:"url(#paint1_linear_3546_7073)",fillOpacity:"0.3"}),jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_3546_7073",x1:"22",y1:"7.79167",x2:"22",y2:"35.2947",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.7"})]}),jsxRuntimeExports.jsxs("linearGradient",{id:"paint1_linear_3546_7073",x1:"22",y1:"7.79167",x2:"22",y2:"35.2947",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.7"})]})]})]}),UnknownChain=({testnet:et,...o})=>jsxRuntimeExports.jsx(KnownChain,{testnet:!0,...o}),Ethereum=({testnet:et,...o})=>{let tt="var(--ck-chain-ethereum-01, #25292E)",rt="var(--ck-chain-ethereum-02, #ffffff)";return et&&(tt="linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)",rt="#fff"),jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:tt},children:[jsxRuntimeExports.jsx("path",{d:"M21.9967 6.99621L21.7955 7.67987V27.5163L21.9967 27.7171L31.2044 22.2744L21.9967 6.99621Z",fill:rt}),jsxRuntimeExports.jsx("path",{d:"M21.9957 6.99621L12.7878 22.2744L21.9957 27.7171V18.0891V6.99621Z",fill:rt}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.9959 36.9996L21.9959 36.9997V36.9995L31.2091 24.0243L21.9959 29.4642L12.788 24.0243L21.9957 36.9993L21.9958 36.9997L21.9959 36.9996Z",fill:rt}),jsxRuntimeExports.jsx("path",{d:"M21.996 27.7181L31.2037 22.2753L21.996 18.09V27.7181Z",fill:rt}),jsxRuntimeExports.jsx("path",{d:"M12.7878 22.2753L21.9957 27.7181V18.09L12.7878 22.2753Z",fill:rt})]})},Polygon=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#6F41D8"},children:jsxRuntimeExports.jsx("path",{d:"M29.0015 17.4529C28.4941 17.1572 27.8355 17.1572 27.2773 17.4529L23.3186 19.7271L20.6305 21.2094L16.6719 23.4822C16.1645 23.7792 15.5059 23.7792 14.9476 23.4822L11.8016 21.703C11.2943 21.4074 10.9395 20.8642 10.9395 20.2702V16.7612C10.9395 16.1686 11.2434 15.6255 11.8016 15.3285L14.8954 13.5988C15.4041 13.3018 16.0641 13.3018 16.6224 13.5988L19.7161 15.3285C20.2249 15.6255 20.5796 16.1686 20.5796 16.7612V19.0355L23.2678 17.5024V15.2295C23.2707 14.9343 23.1917 14.6441 23.0395 14.3911C22.8873 14.1381 22.6679 13.9324 22.4056 13.7968L16.6719 10.5353C16.1645 10.2382 15.5059 10.2382 14.9476 10.5353L9.11214 13.7968C8.84992 13.9324 8.63049 14.1381 8.47828 14.3911C8.32607 14.6441 8.24705 14.9343 8.25002 15.2295V21.802C8.25002 22.396 8.55389 22.9391 9.11214 23.2361L14.9476 26.4976C15.455 26.7932 16.115 26.7932 16.6719 26.4976L20.6305 24.2729L23.3186 22.7411L27.2773 20.5177C27.7846 20.2207 28.4433 20.2207 29.0015 20.5177L32.0966 22.2475C32.6054 22.5431 32.9588 23.0863 32.9588 23.6803V27.1893C32.9588 27.7819 32.6563 28.325 32.0966 28.622L29.0029 30.4013C28.4941 30.6983 27.8341 30.6983 27.2773 30.4013L24.1821 28.6715C23.6734 28.3745 23.3186 27.8314 23.3186 27.2387V24.9645L20.6305 26.4976V28.7705C20.6305 29.3631 20.9344 29.9076 21.4926 30.2032L27.3281 33.4647C27.8355 33.7617 28.4941 33.7617 29.0524 33.4647L34.8879 30.2032C35.3953 29.9076 35.75 29.3645 35.75 28.7705V22.198C35.753 21.9028 35.674 21.6126 35.5218 21.3596C35.3695 21.1066 35.1501 20.9009 34.8879 20.7653L29.0029 17.4529H29.0015Z",fill:"white"})}),Optimism=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#FF0420"},children:[jsxRuntimeExports.jsx("path",{d:"M15.5877 27.8473C14.2777 27.8473 13.2045 27.539 12.3679 26.9226C11.5422 26.2952 11.1294 25.4035 11.1294 24.2477C11.1294 24.0055 11.157 23.7082 11.212 23.356C11.3552 22.5634 11.5588 21.6112 11.823 20.4994C12.5715 17.4722 14.5034 15.9586 17.6187 15.9586C18.4664 15.9586 19.2259 16.1017 19.8974 16.3879C20.5689 16.663 21.0973 17.0814 21.4826 17.6428C21.8678 18.1932 22.0605 18.8537 22.0605 19.6242C22.0605 19.8554 22.033 20.1471 21.9779 20.4994C21.8128 21.4791 21.6146 22.4313 21.3835 23.356C20.9982 24.8641 20.3322 25.9924 19.3855 26.741C18.4388 27.4785 17.1729 27.8473 15.5877 27.8473ZM15.8189 25.4695C16.4354 25.4695 16.9582 25.2879 17.3876 24.9247C17.8279 24.5614 18.1416 24.0055 18.3287 23.257C18.5819 22.2222 18.7746 21.3195 18.9067 20.5489C18.9507 20.3178 18.9727 20.0811 18.9727 19.8389C18.9727 18.8372 18.4498 18.3363 17.4041 18.3363C16.7876 18.3363 16.2592 18.5179 15.8189 18.8812C15.3896 19.2445 15.0813 19.8004 14.8943 20.5489C14.6961 21.2865 14.4979 22.1892 14.2998 23.257C14.2557 23.477 14.2337 23.7082 14.2337 23.9504C14.2337 24.9632 14.7622 25.4695 15.8189 25.4695Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M22.8188 27.6815C22.6977 27.6815 22.6041 27.6429 22.5381 27.5659C22.483 27.4778 22.4665 27.3788 22.4885 27.2687L24.7672 16.5358C24.7892 16.4147 24.8498 16.3156 24.9489 16.2385C25.0479 16.1615 25.1525 16.1229 25.2626 16.1229H29.6548C30.8767 16.1229 31.8564 16.3761 32.5939 16.8825C33.3426 17.3889 33.7168 18.1209 33.7168 19.0786C33.7168 19.3538 33.6838 19.64 33.6177 19.9372C33.3426 21.2032 32.7867 22.1389 31.95 22.7443C31.1244 23.3498 29.9905 23.6525 28.5485 23.6525H26.3194L25.5598 27.2687C25.5377 27.3898 25.4772 27.4888 25.3782 27.5659C25.2791 27.6429 25.1745 27.6815 25.0645 27.6815H22.8188ZM28.6641 21.3738C29.1264 21.3738 29.5282 21.2472 29.8695 20.994C30.2217 20.7408 30.4529 20.3776 30.563 19.9042C30.596 19.717 30.6125 19.552 30.6125 19.4089C30.6125 19.0896 30.519 18.8474 30.3318 18.6823C30.1446 18.5062 29.8255 18.4182 29.3741 18.4182H27.3926L26.7652 21.3738H28.6641Z",fill:"white"})]}),Arbitrum=({testnet:et,...o})=>{const tt=et?"#ffffff":"#28A0F0",rt=et?"#ffffff":"#96BEDC";return jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#2C364F"},children:[!et&&jsxRuntimeExports.jsx("path",{d:"M25.7948 20.5826L28.2683 16.3854L34.9355 26.7696L34.9386 28.7625L34.9168 15.0491C34.9011 14.7137 34.7231 14.407 34.4391 14.2261L22.4357 7.32182C22.1551 7.1838 21.7989 7.18546 21.5187 7.32618C21.4807 7.34524 21.4453 7.36576 21.4113 7.38835L21.3694 7.41467L9.71816 14.1664L9.67298 14.1871C9.61474 14.2137 9.55609 14.2479 9.50076 14.2872C9.27983 14.4456 9.1331 14.68 9.08564 14.9425C9.07859 14.9823 9.0732 15.023 9.07092 15.064L9.08916 26.239L15.2994 16.6138C16.0811 15.3376 17.7847 14.9262 19.3662 14.9488L21.2221 14.9977L10.2862 32.5356L11.5753 33.2778L22.6422 15.0155L27.5338 14.9977L16.4956 33.7209L21.0955 36.3668L21.6451 36.6827C21.8776 36.7772 22.1516 36.7819 22.386 36.6972L34.5581 29.6433L32.2309 30.9918L25.7948 20.5826ZM26.7384 34.175L22.0925 26.8829L24.9287 22.0702L31.0303 31.6876L26.7384 34.175Z",fill:"#2D374B"}),jsxRuntimeExports.jsx("path",{d:"M22.0924 26.8832L26.7385 34.1751L31.0302 31.6879L24.9286 22.0705L22.0924 26.8832Z",fill:tt}),jsxRuntimeExports.jsx("path",{d:"M34.9387 28.7627L34.9356 26.7698L28.2684 16.3856L25.7949 20.5828L32.2312 30.992L34.5584 29.6435C34.7866 29.4582 34.9248 29.1861 34.9393 28.8926L34.9387 28.7627Z",fill:tt}),jsxRuntimeExports.jsx("path",{d:"M7 30.642L10.2863 32.5356L21.2222 14.9976L19.3663 14.9487C17.785 14.9263 16.0814 15.3375 15.2995 16.6137L9.08927 26.239L7 29.449V30.642V30.642Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M27.534 14.9977L22.6423 15.0155L11.5754 33.2778L15.4437 35.5049L16.4955 33.7209L27.534 14.9977Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M37 14.9723C36.9592 13.9493 36.4052 13.013 35.5377 12.4677L23.377 5.47434C22.5187 5.04223 21.4466 5.04161 20.5868 5.47414C20.4852 5.52533 8.76078 12.3251 8.76078 12.3251C8.5985 12.4029 8.44224 12.4955 8.2953 12.6008C7.52081 13.156 7.0487 14.0186 7 14.9661V29.4492L9.08927 26.2392L9.07103 15.0639C9.07352 15.0231 9.0787 14.9827 9.08575 14.9431C9.133 14.6801 9.27994 14.4457 9.50086 14.2872C9.5562 14.2478 21.4806 7.34517 21.5186 7.32611C21.799 7.18538 22.155 7.18373 22.4356 7.32175L34.439 14.226C34.723 14.4069 34.901 14.7137 34.9167 15.049V28.8921C34.9022 29.1856 34.7862 29.4577 34.558 29.643L32.2308 30.9916L31.03 31.6875L26.7383 34.1747L22.3859 36.6969C22.1515 36.7817 21.8773 36.7769 21.645 36.6824L16.4955 33.7206L15.4435 35.5046L20.0713 38.169C20.2243 38.256 20.3607 38.3331 20.4726 38.3961C20.6458 38.4933 20.764 38.5582 20.8056 38.5785C21.1345 38.7383 21.6077 38.8311 22.0342 38.8311C22.4251 38.8311 22.8064 38.7594 23.1672 38.6181L35.8092 31.2971C36.5347 30.7348 36.9617 29.8869 37 28.9686V14.9723Z",fill:rt})]})},Telos=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#571AFF"},children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M26.1834 8.14754C25.6606 8.23504 25.3644 8.50235 24.9216 9.28591C24.5651 9.91722 24.4762 10.0244 24.2024 10.1592L23.9832 10.2668L19.2967 10.286L14.6097 10.3057L14.3875 10.3902C13.7059 10.6492 13.6192 10.7135 11.6291 12.4407C9.72243 14.0953 9.64893 14.1723 9.59249 14.5836C9.54437 14.9362 9.78981 15.6327 10.5191 17.2143C11.2847 18.8737 11.2839 18.8641 10.7444 19.5256C10.2645 20.1136 10.2269 20.2588 10.2041 21.5915C10.1717 23.502 10.2487 27.6023 10.3222 27.8591C10.3572 27.9816 10.7908 29.204 11.2861 30.5755C11.7813 31.9471 12.4192 33.715 12.704 34.5038C13.4281 36.5107 13.4814 36.5986 14.0392 36.7237C14.3066 36.7837 14.3206 36.781 18.9677 35.7258C24.4395 34.4837 23.7264 34.709 25.0739 33.7968C29.8732 30.5475 29.7337 30.66 29.8969 29.9083C30.0583 29.1642 30.1082 29.1379 31.8267 28.8999C34.6122 28.5145 34.6328 28.5083 34.8831 28.0109C35.0182 27.7423 35.7786 23.3406 35.8136 22.6209C35.8504 21.8828 36.042 22.221 33.3816 18.3395C30.022 13.4382 30.2381 13.7777 30.2399 13.4041C30.2407 13.1735 30.3366 12.9736 31.3236 11.1418C31.8236 10.2134 32.2742 9.35241 32.3254 9.22904C32.5236 8.74691 32.4204 8.3921 32.0301 8.21622L31.8267 8.12391L29.1102 8.11822C27.6048 8.11516 26.2997 8.12829 26.1834 8.14754ZM30.0474 9.4876C30.5623 9.72297 30.5382 9.82447 29.5119 11.7398C28.4317 13.7558 28.3157 13.2711 30.7154 16.7707C31.639 18.1173 32.8076 19.8218 33.3124 20.5581C34.6844 22.5592 34.6048 22.1799 34.1831 24.6903C33.7858 27.0602 33.7792 27.0817 33.3759 27.282C33.1506 27.394 33.2276 27.3813 30.8493 27.7117C28.9147 27.9803 28.8543 28.017 28.6719 29.0338C28.5778 29.557 28.4606 29.8169 28.2243 30.0247C28.0808 30.1512 24.8682 32.368 23.9451 32.9778C23.2587 33.4311 23.6861 33.3152 17.7471 34.6574C17.1997 34.7812 16.4079 34.9632 15.987 35.0617C14.4588 35.4195 14.4299 35.4033 13.8804 33.8948C12.9188 31.2528 11.6811 27.7957 11.6194 27.5787C11.5534 27.3463 11.549 27.1202 11.549 24.059V20.7878L11.6501 20.5966C11.7056 20.4912 11.8671 20.2759 12.0088 20.118C12.8418 19.19 12.8383 19.1183 11.8601 16.9907C10.7663 14.612 10.6797 14.9992 12.697 13.2501C14.2418 11.91 14.3048 11.8593 14.5905 11.7237L14.8394 11.6055L19.6983 11.5854C23.5417 11.5692 24.5891 11.5543 24.7103 11.515C25.1465 11.3728 25.4086 11.1094 25.7975 10.4203C26.3851 9.38041 26.3111 9.40797 28.4597 9.41891C29.6996 9.42547 29.9332 9.43554 30.0474 9.4876Z",fill:"#F7F5FC"})}),Aurora=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#6CD544"},children:jsxRuntimeExports.jsx("path",{d:"M22.0006 7.292C22.6198 7.29004 23.2271 7.46144 23.754 7.7868C24.2808 8.11216 24.706 8.57848 24.9816 9.133L34.3566 27.883C34.611 28.3912 34.7312 28.956 34.7058 29.5238C34.6805 30.0915 34.5103 30.6433 34.2116 31.1268C33.9129 31.6103 33.4956 32.0094 32.9992 32.2861C32.5028 32.5629 31.9439 32.7081 31.3756 32.708H12.6256C12.0573 32.7079 11.4985 32.5626 11.0023 32.2858C10.506 32.009 10.0888 31.6099 9.79022 31.1264C9.49163 30.6429 9.3216 30.0912 9.29628 29.5235C9.27096 28.9558 9.39119 28.3911 9.64556 27.883L19.0196 9.133C19.2951 8.57848 19.7203 8.11216 20.2472 7.7868C20.774 7.46144 21.3814 7.29004 22.0006 7.292ZM22.0006 5C20.9561 4.9999 19.9322 5.29059 19.0437 5.83952C18.1551 6.38846 17.4369 7.17394 16.9696 8.108L7.59456 26.858C7.16544 27.7156 6.96271 28.6687 7.00564 29.6268C7.04856 30.5848 7.33572 31.516 7.83982 32.3318C8.34392 33.1476 9.04823 33.821 9.88584 34.288C10.7235 34.755 11.6666 35.0001 12.6256 35H31.3756C32.3345 34.9999 33.2775 34.7547 34.1149 34.2876C34.9524 33.8206 35.6566 33.1472 36.1606 32.3314C36.6645 31.5156 36.9516 30.5845 36.9945 29.6265C37.0374 28.6686 36.8346 27.7156 36.4056 26.858L27.0316 8.108C26.5642 7.17394 25.846 6.38846 24.9574 5.83952C24.0689 5.29059 23.045 4.9999 22.0006 5Z",fill:"white"})}),Avalanche=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#E84142"},children:[jsxRuntimeExports.jsx("path",{d:"M11.0188 32.1528H15.4825C16.5334 32.1528 17.0589 32.1528 17.5278 32.023C18.042 31.8701 18.511 31.5991 18.9009 31.2261C19.2589 30.885 19.5173 30.4328 20.0269 29.5409L20.0272 29.5404L20.0422 29.5142L25.8314 19.2804C26.3456 18.3821 26.5999 17.93 26.7129 17.4554C26.8372 16.9412 26.8372 16.3988 26.7129 15.8847C26.6007 15.4136 26.3439 14.9648 25.8373 14.0798L25.8258 14.0597L23.56 10.1045C23.0911 9.27958 22.8538 8.86711 22.5543 8.71456C22.2323 8.55071 21.848 8.55071 21.526 8.71456C21.2265 8.86711 20.9892 9.27958 20.5202 10.1045L9.49892 29.5311C9.03561 30.3447 8.80392 30.7517 8.82089 31.0849C8.84349 31.4466 9.02994 31.7743 9.33507 31.9721C9.61756 32.1528 10.0809 32.1528 11.0188 32.1528Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M33.1506 32.1528H26.7547C25.8111 32.1528 25.3365 32.1528 25.0596 31.9721C24.7545 31.7743 24.5681 31.4411 24.5455 31.0794C24.5286 30.7486 24.7621 30.3456 25.2294 29.539L25.2295 29.5388L25.2404 29.5199L28.4328 24.0392C28.9018 23.2313 29.1391 22.8301 29.4329 22.6776C29.7548 22.5137 30.1336 22.5137 30.4555 22.6776C30.7472 22.8261 30.9744 23.2102 31.4241 23.9708L31.4248 23.9719L31.4613 24.0336L34.665 29.5143C34.6806 29.5413 34.696 29.5678 34.7113 29.5939L34.7113 29.594C35.1554 30.3603 35.382 30.7514 35.3657 31.0739C35.3486 31.4353 35.1566 31.7688 34.8515 31.9666C34.5689 32.1528 34.0942 32.1528 33.1506 32.1528Z",fill:"white"})]}),Celo=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#FCFE72"},children:jsxRuntimeExports.jsx("path",{d:"M9 9H34.5183V18.112H30.3564C28.896 14.7687 25.6102 12.4171 21.777 12.4171C16.593 12.4171 12.3948 16.6422 12.3948 21.823C12.3948 27.0039 16.593 31.2654 21.777 31.2654C25.5373 31.2654 28.8231 28.9876 30.2829 25.7172H34.5178V34.682H9V9Z",fill:et?"#ffffff":"black"})}),Gnosis=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#009CB4"},children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.3439 11.8664C17.9374 6.53462 26.7953 6.74397 32.1271 12.3374C32.4738 12.7038 32.8075 13.0832 33.1084 13.4823L22 24.5972L10.8916 13.4823C11.1991 13.0832 11.5262 12.7038 11.8729 12.3374C12.0234 12.1804 12.1804 12.0234 12.3439 11.8664ZM30.6094 13.3972C28.3196 11.0944 25.271 9.83182 22 9.83182C18.729 9.83182 15.6804 11.0944 13.3907 13.3972L22 22.0066L30.6094 13.3972ZM33.9785 14.7446L31.7215 17.0016C33.5402 19.1801 33.2523 22.425 31.0738 24.2437C29.1636 25.84 26.3897 25.84 24.4794 24.2437L22 26.7231L19.5271 24.2502C17.3486 26.0689 14.1037 25.7811 12.285 23.6026C10.6888 21.6923 10.6888 18.9185 12.285 17.0082L11.1271 15.8502L10.028 14.7446C8.7 16.9297 8 19.4418 8 21.9998C8 29.7325 14.2673 35.9998 22 35.9998C29.7327 35.9998 36 29.7325 36 21.9998C36.0065 19.4418 35.3 16.9297 33.9785 14.7446ZM30.6486 18.0747C31.1392 18.7093 31.4075 19.4943 31.4075 20.299C31.4075 21.1037 31.1392 21.8887 30.6486 22.5233C29.4187 24.113 27.1355 24.4074 25.5458 23.1775L30.6486 18.0747ZM18.4542 23.1839C17.8196 23.6745 17.0346 23.9427 16.2299 23.9427C15.4252 23.9427 14.6467 23.6745 14.0056 23.1904C12.4159 21.9605 12.1215 19.6708 13.3514 18.0811L18.4542 23.1839Z",fill:"white"})}),Evmos=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#2D2A25"},children:jsxRuntimeExports.jsx("path",{d:"M18.4916 12.6668C12.9416 14.806 12.4332 20.2846 10.8418 22.8432C9.23155 25.4322 5.54251 26.8607 6.04698 28.1801C6.55143 29.4994 10.2449 28.0824 13.1669 28.9242C16.0543 29.7561 20.0831 33.4862 25.633 31.3469C28.4603 30.2573 30.5076 28.0143 31.449 25.3574C31.5502 25.0723 31.361 24.7673 31.0606 24.7391C30.874 24.7215 30.6948 24.8196 30.6106 24.9877C29.759 26.6908 28.2981 28.0934 26.3864 28.8301C23.2303 30.0465 19.777 29.0915 17.6562 26.6961C17.1746 26.1522 16.7626 25.533 16.4374 24.8487C16.348 24.6603 16.2629 24.4689 16.1875 24.2708C16.1117 24.0728 16.0473 23.8735 15.9881 23.6732C17.6562 22.8925 19.5812 22.0656 21.7635 21.2246C23.903 20.3999 25.8505 19.731 27.5841 19.1958C28.7571 18.8341 29.8322 18.5331 30.8029 18.2871C30.8732 18.2695 30.9423 18.2519 31.0112 18.2347C31.158 18.1982 31.3088 18.2769 31.363 18.4186L31.364 18.4213C31.396 18.5053 31.4236 18.5898 31.4535 18.6743C31.6453 19.2196 31.7892 19.7706 31.8841 20.3229C31.9258 20.5645 32.1888 20.6961 32.4044 20.5799C33.2014 20.1504 33.9302 19.7314 34.5814 19.3283C37.0083 17.8276 38.3538 16.5549 38.0776 15.8336C37.802 15.1119 35.9541 15.0705 33.1503 15.5854C32.2593 15.7491 31.2716 15.9691 30.207 16.2416C30.0229 16.2886 29.8365 16.3375 29.6481 16.3877C28.7522 16.6262 27.8073 16.8995 26.8234 17.2053C24.9936 17.7744 23.0305 18.4561 21.0038 19.2372C19.1078 19.9682 17.3109 20.726 15.6629 21.4812C15.6428 18.2761 17.5725 15.2461 20.7286 14.0297C22.6399 13.293 24.6605 13.3533 26.4285 14.0473C26.6029 14.116 26.8015 14.0684 26.9291 13.9298C27.1331 13.7076 27.0706 13.3537 26.8053 13.2094C24.3353 11.8685 21.319 11.5771 18.4916 12.6668Z",fill:"#FAF1E4"})}),BinanceSmartChain=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#16181A"},children:[jsxRuntimeExports.jsx("path",{d:"M16.0445 19.6063L21.8705 13.7805L27.6996 19.6093L31.0896 16.2193L21.8705 7L12.6545 16.2163L16.0445 19.6063Z",fill:et?"#fff":"#F3BA2F"}),jsxRuntimeExports.jsx("path",{d:"M13.6505 21.9995L10.2606 18.6096L6.87046 21.9997L10.2604 25.3896L13.6505 21.9995Z",fill:et?"#fff":"#F3BA2F"}),jsxRuntimeExports.jsx("path",{d:"M16.0445 24.3937L21.8705 30.2195L27.6994 24.3909L31.0913 27.779L31.0896 27.7809L21.8705 37L12.6542 27.7839L12.6495 27.7792L16.0445 24.3937Z",fill:et?"#fff":"#F3BA2F"}),jsxRuntimeExports.jsx("path",{d:"M33.4808 25.3911L36.8709 22.001L33.481 18.6111L30.0909 22.0012L33.4808 25.3911Z",fill:et?"#fff":"#F3BA2F"}),jsxRuntimeExports.jsx("path",{d:"M25.3091 21.9982H25.3105L21.8705 18.5582L19.3283 21.1004H19.3281L19.0362 21.3926L18.4336 21.9951L18.4289 21.9999L18.4336 22.0048L21.8705 25.4418L25.3105 22.0018L25.3122 21.9999L25.3091 21.9982Z",fill:et?"#fff":"#F3BA2F"})]}),Canto=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"white"},children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M35 8V36H9L13.875 35.9998V31.0586H9V12.9412H13.875V8H35ZM17.9373 12.9414H30.1247V17.8826H17.9373V12.9414ZM30.1247 26.9414H17.9373V17.8826L13.0623 17.8828V26.9416L17.9373 26.9414V31.8826H30.1247V26.9414Z",fill:"#06FC99"})}),Fantom=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#0911EF"},children:jsxRuntimeExports.jsx("path",{d:"M20.92 9.25864C21.5933 8.91379 22.6178 8.91379 23.2911 9.25864L30.1616 12.7775C30.5671 12.9852 30.7898 13.2947 30.8297 13.6142H30.8363V31.302C30.8274 31.6504 30.6025 31.9966 30.1616 32.2225L23.2911 35.7413C22.6178 36.0862 21.5933 36.0862 20.92 35.7413L14.0495 32.2225C13.6104 31.9976 13.3997 31.6489 13.3893 31.302C13.3883 31.2678 13.3881 31.2393 13.3891 31.2157L13.3891 13.7278C13.3884 13.7086 13.3883 13.6895 13.3889 13.6705L13.3893 13.6142L13.3924 13.6142C13.4229 13.2912 13.6355 12.9896 14.0495 12.7775L20.92 9.25864ZM29.7547 23.4821L23.2911 26.7926C22.6178 27.1374 21.5933 27.1374 20.92 26.7926L14.4706 23.4895V31.2669L20.92 34.5527C21.2842 34.7415 21.6622 34.9254 22.0318 34.9488L22.1056 34.9512C22.4907 34.9524 22.8646 34.7628 23.2438 34.5833L29.7547 31.2387V23.4821ZM11.3214 31.8437C11.3214 32.5212 11.4026 32.9667 11.5639 33.2806C11.6976 33.5407 11.8981 33.7394 12.2643 33.9813L12.2852 33.9951C12.3656 34.0476 12.4541 34.1026 12.5619 34.1672L12.689 34.2427L13.0792 34.4711L12.5195 35.3685L12.0827 35.1126L12.0093 35.0689C11.883 34.9932 11.7783 34.9284 11.6807 34.8645C10.637 34.1822 10.2478 33.4384 10.2401 31.8907L10.24 31.8437H11.3214ZM21.5647 18.7412C21.5147 18.7579 21.4678 18.7772 21.4251 18.7991L14.5546 22.318C14.5474 22.3216 14.5405 22.3253 14.534 22.3289L14.5281 22.3322L14.5389 22.3382L14.5546 22.3464L21.4251 25.8653C21.4678 25.8872 21.5147 25.9065 21.5647 25.9231V18.7412ZM22.6465 18.7412V25.9231C22.6965 25.9065 22.7433 25.8872 22.7861 25.8653L29.6566 22.3464C29.6638 22.3427 29.6707 22.3391 29.6772 22.3355L29.683 22.3322L29.6722 22.3262L29.6566 22.318L22.7861 18.7991C22.7433 18.7772 22.6965 18.7579 22.6465 18.7412ZM29.7547 14.8689L23.5915 18.0256L29.7547 21.1822V14.8689ZM14.4706 14.8763V21.1749L20.6195 18.0256L14.4706 14.8763ZM22.7861 10.1859C22.4288 10.0029 21.7824 10.0029 21.4251 10.1859L14.5546 13.7048C14.5474 13.7085 14.5405 13.7122 14.534 13.7158L14.5281 13.719L14.5389 13.725L14.5546 13.7333L21.4251 17.2522C21.7824 17.4352 22.4288 17.4352 22.7861 17.2522L29.6566 13.7333C29.6638 13.7296 29.6707 13.7259 29.6772 13.7223L29.683 13.719L29.6722 13.7131L29.6566 13.7048L22.7861 10.1859ZM31.7205 9.64552L32.1573 9.90132L32.2307 9.94503C32.357 10.0206 32.4616 10.0856 32.5593 10.1494C33.603 10.8317 33.9922 11.5756 33.9998 13.1231L34 13.1703H32.9186C32.9186 12.4926 32.8373 12.0472 32.6761 11.7334C32.5424 11.4733 32.3419 11.2745 31.9757 11.0327L31.9547 11.0189C31.8744 10.9664 31.7858 10.9113 31.6781 10.8466L31.551 10.7712L31.1608 10.5428L31.7205 9.64552Z",fill:"white"})}),Filecoin=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#0090FF"},children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M23.75 19.3069L23.15 22.5069L28.85 23.3069L28.45 24.8069L22.85 24.0069C22.45 25.3069 22.25 26.7069 21.75 27.9069C21.25 29.3069 20.75 30.7069 20.15 32.0069C19.35 33.7069 17.95 34.9069 16.05 35.2069C14.95 35.4069 13.75 35.3069 12.85 34.6069C12.55 34.4069 12.25 34.0069 12.25 33.7069C12.25 33.3069 12.45 32.8069 12.75 32.6069C12.95 32.5069 13.45 32.6069 13.75 32.7069C14.05 33.0069 14.35 33.4069 14.55 33.8069C15.15 34.6069 15.95 34.7069 16.75 34.1069C17.65 33.3069 18.15 32.2069 18.45 31.1069C19.05 28.7069 19.65 26.4069 20.15 24.0069V23.6069L14.85 22.8069L15.05 21.3069L20.55 22.1069L21.25 19.0069L15.55 18.1069L15.75 16.5069L21.65 17.3069C21.85 16.7069 21.95 16.2069 22.15 15.7069C22.65 13.9069 23.15 12.1069 24.35 10.5069C25.55 8.90687 26.95 7.90687 29.05 8.00687C29.95 8.00687 30.85 8.30687 31.45 9.00687C31.55 9.10687 31.75 9.30687 31.75 9.50687C31.75 9.90687 31.75 10.4069 31.45 10.7069C31.05 11.0069 30.55 10.9069 30.15 10.5069C29.85 10.2069 29.65 9.90687 29.35 9.60687C28.75 8.80687 27.85 8.70687 27.15 9.40687C26.65 9.90687 26.15 10.6069 25.85 11.3069C25.15 13.4069 24.65 15.6069 23.95 17.8069L29.45 18.6069L29.05 20.1069L23.75 19.3069Z",fill:"white"})}),IoTeX=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#00D4D5"},children:[jsxRuntimeExports.jsx("path",{d:"M23.7136 6.875V14.3784L30.2284 10.6315L23.7136 6.875Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.9",d:"M30.2284 10.6316V18.135L36.7418 14.3785L30.2284 10.6316Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.8",d:"M23.7136 14.3784V21.8818L30.2284 18.1349L23.7136 14.3784ZM30.2284 18.1349V25.6383L36.7417 21.8818L30.2284 18.1349Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.8",d:"M23.7136 21.8817V29.385L30.2284 25.6382L23.7136 21.8817Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M30.2284 25.6382V33.1416L36.7418 29.3851L30.2284 25.6382Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.4",d:"M6.87537 14.1253V21.6287L13.3901 17.8722L6.87537 14.1253Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.2",d:"M15.0938 16.9153V24.4186L21.5975 20.6718L15.0938 16.9153Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.3",d:"M10.2648 21.6604V29.1638L16.7781 25.4073L10.2648 21.6604Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.9",d:"M14.5575 27.3226V34.826L21.0612 31.0695L14.5575 27.3226Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.7",d:"M23.66 30.5525V38.0572L30.1637 34.2993L23.66 30.5525Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.9",d:"M16.1786 13.2097V20.7145L22.6824 16.9676L16.1786 13.2097Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.8",d:"M23.7136 6.875V14.3784L17.1989 10.6315L23.7136 6.875Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.6",d:"M16.1786 10.0649V17.5669L9.66248 13.8104L16.1786 10.0649Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.6",d:"M22.6934 13.7775V21.2823L16.1786 17.5244L22.6934 13.7775Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.95",d:"M15.0635 16.9153V24.4186L8.54877 20.6718L15.0635 16.9153Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.6",d:"M23.7136 21.8817V29.385L17.2099 25.6382L23.7136 21.8817Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.55",d:"M10.2648 23.6295V31.1328L3.75 27.375L10.2648 23.6295Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M36.7418 14.3784V21.8818L30.2284 18.1349L36.7418 14.3784Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.95",d:"M30.2284 18.1362V25.6382L23.7136 21.8817L30.2284 18.1362Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.9",d:"M36.7418 21.8817V29.385L30.2284 25.6382L36.7418 21.8817Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.7",d:"M30.2284 25.6382V33.1416L23.7136 29.3851L30.2284 25.6382Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.4",d:"M22.2712 28.7651V36.2684L15.7579 32.5216L22.2712 28.7651Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M30.2284 10.6316V18.135L23.7136 14.3785L30.2284 10.6316Z",fill:"white"})]}),Metis=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#2F3140"},children:jsxRuntimeExports.jsx("path",{d:"M37.5175 22.0531C37.4579 19.2923 36.6563 16.5985 35.1968 14.2542C33.7374 11.91 31.674 10.0017 29.223 8.72965C26.772 7.45759 24.0238 6.86863 21.2668 7.02455C18.5098 7.18047 15.8456 8.07553 13.5537 9.61582C11.2617 11.1561 9.42659 13.2849 8.24079 15.7787C7.05498 18.2725 6.56222 21.0396 6.81419 23.7895C7.06617 26.5394 8.05359 29.1708 9.67288 31.4076C11.2922 33.6444 13.4836 35.4042 16.0173 36.5023C16.7657 35.3775 17.3385 34.1453 17.716 32.848C18.0245 32.0632 18.3595 31.2913 18.7067 30.5446C19.5444 30.7955 20.4345 30.8143 21.282 30.5989C22.1295 30.3835 22.9026 29.942 23.5188 29.3215L23.5704 29.2699C22.8136 28.9884 21.9979 28.9032 21.1993 29.022C20.4006 29.1408 19.6451 29.4598 19.0029 29.9494C19.4276 29.0613 19.891 28.1997 20.3667 27.3632C21.189 27.6541 22.075 27.7156 22.9296 27.541C23.7842 27.3665 24.5751 26.9626 25.2175 26.3726L25.2692 26.3209C24.538 26.0116 23.7416 25.8885 22.9513 25.9626C22.1609 26.0368 21.4013 26.3058 20.7404 26.7456C21.216 25.9608 21.7053 25.1889 22.2203 24.468C23.0713 24.6915 23.9672 24.6777 24.811 24.4282C25.6547 24.1787 26.414 23.703 27.0066 23.0526L27.0453 23.001C26.3425 22.7718 25.5958 22.7106 24.8651 22.8224C24.1344 22.9341 23.4401 23.2157 22.838 23.6444C22.8767 23.5928 22.9283 23.5289 22.9664 23.4773C23.2749 23.0784 23.5969 22.6796 23.9177 22.2936C24.8969 21.9731 25.7703 21.3916 26.4436 20.6117C27.117 19.8318 27.5649 18.883 27.7391 17.8674L27.752 17.79H27.7391C26.7194 18.0552 25.7944 18.6007 25.0689 19.3648C24.3434 20.1288 23.8464 21.0808 23.6343 22.1129C23.3258 22.4859 23.0167 22.8603 22.7211 23.2449C22.9706 22.5925 23.0724 21.893 23.0191 21.1966C22.9657 20.5002 22.7586 19.8243 22.4126 19.2176L22.3739 19.2692C21.8489 19.9862 21.5326 20.8345 21.4599 21.7201C21.3873 22.6058 21.5611 23.4942 21.9621 24.2872C21.4729 24.9823 20.9972 25.6897 20.5467 26.4357C20.6918 25.6858 20.6542 24.9118 20.4369 24.1795C20.2196 23.4471 19.8291 22.7779 19.2985 22.2284L19.2727 22.2929C18.9445 23.1107 18.8477 24.0031 18.9929 24.8723C19.1382 25.7415 19.5199 26.5539 20.0962 27.2205C19.6457 28.0054 19.2211 28.816 18.8093 29.6524C18.9344 28.8712 18.8712 28.0715 18.6251 27.3196C18.3789 26.5677 17.9568 25.8855 17.3939 25.3295L17.3681 25.3941C17.0745 26.2514 17.0201 27.1724 17.2105 28.0583C17.401 28.9442 17.8292 29.7614 18.4492 30.4223C18.1774 31.0012 17.9219 31.5774 17.6773 32.1849C17.61 32.1231 17.5313 32.0751 17.4456 32.0435C17.0066 31.916 16.5867 31.7299 16.1974 31.4904C15.8754 31.2994 15.5337 31.144 15.1781 31.027C13.7886 30.5765 13.9945 29.9079 13.2756 28.5564C13.0416 28.2781 12.7931 28.0125 12.5309 27.7607C12.2876 27.603 12.0884 27.386 11.9519 27.1302C11.7934 26.8107 11.6931 26.4656 11.6557 26.1109C11.6514 25.9148 11.5858 25.7249 11.4681 25.5679C11.3504 25.4109 11.1864 25.2948 10.9993 25.2358C8.95338 24.5284 9.86728 21.8778 9.94406 21.5299C9.91262 21.08 9.81271 20.6375 9.64781 20.2178C9.63057 20.1632 9.61763 20.1073 9.60908 20.0506C9.55449 19.776 9.56444 19.4924 9.63813 19.2223C9.71183 18.9521 9.84726 18.7028 10.0338 18.4939C10.2784 18.2493 11.1277 17.8505 11.3078 17.6188C11.4879 17.387 11.6163 17.1295 11.797 16.9114C12.3687 16.3412 13.0291 15.8675 13.7526 15.509C14.3444 15.1876 14.4477 14.364 14.6787 14.1065C15.0647 13.6689 15.6565 13.6689 16.0941 13.283C16.3129 13.09 16.6377 12.9867 16.8415 12.7815C17.8692 11.8403 19.1644 11.2423 20.5474 11.0706C21.5064 10.9924 22.4717 11.0795 23.4012 11.3281C23.5358 11.3507 23.669 11.3809 23.8001 11.4185C25.9228 11.4959 28.4709 11.9328 29.397 12.8338C29.8555 13.2744 30.1961 13.8229 30.3877 14.4293C30.5382 14.8988 30.7456 15.3481 31.0054 15.7672L31.5714 16.6933C31.932 17.2773 32.0475 17.9801 31.8928 18.6489C31.7885 18.974 31.7795 19.3223 31.8669 19.6525C32.1655 20.1031 32.5152 20.5177 32.9093 20.8878C33.0658 21.0427 33.2382 21.1807 33.4236 21.2995C33.8592 21.5594 34.2802 21.8429 34.6848 22.1489C34.698 22.2729 34.6775 22.3982 34.6254 22.5115C34.5732 22.6247 34.4914 22.7218 34.3885 22.7924C34.0284 23.1137 33.3333 23.6159 33.3333 23.6159C33.3584 23.758 33.4016 23.8964 33.4617 24.0276C33.5643 24.2077 33.796 24.4911 33.7192 24.735C33.6424 24.9789 33.1403 25.1855 33.2816 25.4552C33.423 25.7386 33.7831 25.8154 33.6805 26.0729C33.5779 26.3175 33.0757 26.7524 33.1274 26.9352C33.179 27.1179 33.5908 28.8377 32.6382 29.1353C31.4592 29.3685 30.2627 29.5019 29.0614 29.5342C28.8675 29.5454 28.6797 29.6055 28.5155 29.709C28.3513 29.8125 28.216 29.956 28.1223 30.126C27.9399 30.4661 27.8222 30.837 27.7751 31.22C27.4275 32.5896 26.9671 33.928 26.3985 35.2215C26.3985 35.2215 26.3597 35.2989 26.3081 35.4144C26.1833 35.6687 26.1048 35.9432 26.0764 36.2251C26.1573 36.4321 26.2799 36.6204 26.4365 36.7782C26.519 36.8726 26.6271 36.9411 26.7477 36.9753C26.8683 37.0096 26.9962 37.0081 27.116 36.9711C30.1997 35.8965 32.8655 33.8757 34.7332 31.197C36.601 28.5182 37.5754 25.3182 37.5175 22.0531Z",fill:et?"#ffffff":"#00DACC"})});var Chains={UnknownChain,Ethereum,Polygon,Optimism,Arbitrum,Aurora,Avalanche,Celo,Telos,Gnosis,Evmos,BinanceSmartChain,Foundry:KnownChain,Sepolia:KnownChain,Taraxa:KnownChain,zkSync:KnownChain,Flare:KnownChain,Canto,Fantom,Filecoin,Metis,IoTeX};const chainConfigs=[{id:1,name:"Ethereum",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{}),rpcUrls:{alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]}}},{id:3,name:"Rinkeby",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0}),rpcUrls:{}},{id:4,name:"Ropsten",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:5,name:"Görli",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:42,name:"Kovan",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:10,name:"Optimism",logo:jsxRuntimeExports.jsx(Chains.Optimism,{})},{id:69,name:"Optimism Kovan",logo:jsxRuntimeExports.jsx(Chains.Optimism,{testnet:!0})},{id:420,name:"Optimism Goerli",logo:jsxRuntimeExports.jsx(Chains.Optimism,{testnet:!0})},{id:137,name:"Polygon",logo:jsxRuntimeExports.jsx(Chains.Polygon,{})},{id:80001,name:"Polygon Mumbai",logo:jsxRuntimeExports.jsx(Chains.Polygon,{testnet:!0})},{id:31337,name:"Hardhat",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:1337,name:"Localhost",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:42161,name:"Arbitrum",logo:jsxRuntimeExports.jsx(Chains.Arbitrum,{}),rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]}}},{id:421611,name:"Arbitrum Rinkeby",logo:jsxRuntimeExports.jsx(Chains.Arbitrum,{testnet:!0})},{id:421613,name:"Arbitrum Goerli",logo:jsxRuntimeExports.jsx(Chains.Arbitrum,{testnet:!0}),rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]}}},{id:40,name:"Telos",logo:jsxRuntimeExports.jsx(Chains.Telos,{})},{id:41,name:"Telos Testnet",logo:jsxRuntimeExports.jsx(Chains.Telos,{testnet:!0})},{id:1313161554,name:"Aurora",logo:jsxRuntimeExports.jsx(Chains.Aurora,{})},{id:1313161555,name:"Aurora Testnet",logo:jsxRuntimeExports.jsx(Chains.Aurora,{testnet:!0})},{id:43114,name:"Avalanche",logo:jsxRuntimeExports.jsx(Chains.Avalanche,{})},{id:43113,name:"Avalanche Fuji",logo:jsxRuntimeExports.jsx(Chains.Avalanche,{testnet:!0})},{id:31337,name:"Foundry",logo:jsxRuntimeExports.jsx(Chains.Foundry,{testnet:!0})},{id:100,name:"Gnosis",logo:jsxRuntimeExports.jsx(Chains.Gnosis,{})},{id:9001,name:"Evmos",logo:jsxRuntimeExports.jsx(Chains.Evmos,{})},{id:9e3,name:"Evmos Testnet",logo:jsxRuntimeExports.jsx(Chains.Evmos,{testnet:!0})},{id:56,name:"BNB Smart Chain",logo:jsxRuntimeExports.jsx(Chains.BinanceSmartChain,{})},{id:97,name:"Binance Smart Chain Testnet",logo:jsxRuntimeExports.jsx(Chains.BinanceSmartChain,{testnet:!0})},{id:11155111,name:"Sepolia",logo:jsxRuntimeExports.jsx(Chains.Sepolia,{})},{id:841,name:"Taraxa",logo:jsxRuntimeExports.jsx(Chains.Taraxa,{})},{id:842,name:"Taraxa Testnet",logo:jsxRuntimeExports.jsx(Chains.Taraxa,{testnet:!0})},{id:324,name:"zkSync",logo:jsxRuntimeExports.jsx(Chains.zkSync,{})},{id:280,name:"zkSync Testnet",logo:jsxRuntimeExports.jsx(Chains.zkSync,{testnet:!0})},{id:42220,name:"Celo",logo:jsxRuntimeExports.jsx(Chains.Celo,{})},{id:44787,name:"Celo Alfajores",logo:jsxRuntimeExports.jsx(Chains.Celo,{testnet:!0})},{id:7700,name:"Canto",logo:jsxRuntimeExports.jsx(Chains.Canto,{})},{id:250,name:"Fantom",logo:jsxRuntimeExports.jsx(Chains.Fantom,{})},{id:4002,name:"Fantom Testnet",logo:jsxRuntimeExports.jsx(Chains.Fantom,{testnet:!0})},{id:14,name:"Flare",logo:jsxRuntimeExports.jsx(Chains.Flare,{})},{id:114,name:"Coston2",logo:jsxRuntimeExports.jsx(Chains.Flare,{})},{id:314,name:"Filecoin",logo:jsxRuntimeExports.jsx(Chains.Filecoin,{})},{id:3141,name:"Filecoin Hyperspace",logo:jsxRuntimeExports.jsx(Chains.Filecoin,{testnet:!0})},{id:314159,name:"Filecoin Calibration",logo:jsxRuntimeExports.jsx(Chains.Filecoin,{testnet:!0})},{id:1088,name:"Metis",logo:jsxRuntimeExports.jsx(Chains.Metis,{})},{id:599,name:"Metis Goerli",logo:jsxRuntimeExports.jsx(Chains.Metis,{testnet:!0})},{id:4689,name:"IoTeX",logo:jsxRuntimeExports.jsx(Chains.IoTeX,{})},{id:4690,name:"IoTeX Testnet",logo:jsxRuntimeExports.jsx(Chains.IoTeX,{testnet:!0})}],SwitchNetworksContainer=styled.div` +`;function useIsMounted(){const[et,o]=reactExports.useState(!1);return reactExports.useEffect(()=>o(!0),[]),et}const ensFallbackConfig=createConfig({chains:[mainnet],transports:{[mainnet.id]:http()}});function useEnsFallbackConfig(){return useChainIsSupported(1)?void 0:ensFallbackConfig}const Avatar=({address:et,name:o,size:tt=96,radius:rt=96})=>{var nt,ot,it;const st=useIsMounted(),at=useContext(),ct=reactExports.useRef(null),[lt,dt]=reactExports.useState(!0),ht=useEnsFallbackConfig(),{data:mt}=useEnsAddress({chainId:1,name:o,config:ht}),{data:ft}=useEnsName({chainId:1,address:(nt=et??mt)!==null&&nt!==void 0?nt:void 0,config:ht}),{data:pt}=useEnsAvatar({chainId:1,name:normalize$2(ft??""),config:ht}),yt={address:mt??et,name:ft??o,avatar:pt??void 0};return reactExports.useEffect(()=>{ct.current&&ct.current.complete&&ct.current.naturalHeight!==0||dt(!1)},[pt]),st?!((ot=at.options)===null||ot===void 0)&&ot.customAvatar?jsxRuntimeExports.jsx("div",{style:{width:tt,height:tt,borderRadius:rt,overflow:"hidden"},children:(it=at.options)===null||it===void 0?void 0:it.customAvatar({address:et??(yt==null?void 0:yt.address),ensName:o??(yt==null?void 0:yt.name),ensImage:yt==null?void 0:yt.avatar,size:tt,radius:rt})}):!yt.name||!yt.avatar?jsxRuntimeExports.jsx(ResetContainer,{style:{pointerEvents:"none"},children:jsxRuntimeExports.jsx(EnsAvatar,{$size:tt,$seed:yt.address,$radius:rt})}):jsxRuntimeExports.jsx(ResetContainer,{style:{pointerEvents:"none"},children:jsxRuntimeExports.jsx(EnsAvatar,{$size:tt,$seed:yt.address,$radius:rt,children:jsxRuntimeExports.jsx(ImageContainer,{ref:ct,src:yt.avatar,alt:yt.name,onLoad:()=>dt(!0),$loaded:lt})})}):jsxRuntimeExports.jsx("div",{style:{width:tt,height:tt,borderRadius:rt}})},KnownChain=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"black"},children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.5611 8.12948C21.0082 7.90729 21.5007 7.79167 22 7.79167C22.4993 7.79167 22.9919 7.90729 23.439 8.12948L23.4408 8.1304L33.0387 12.9293C33.577 13.197 34.031 13.61 34.3478 14.121C34.6649 14.6323 34.833 15.2218 34.8333 15.8234V27.2595C34.833 27.8611 34.6649 28.4511 34.3478 28.9624C34.031 29.4733 33.578 29.8858 33.0398 30.1535L23.4411 34.9528C22.9919 35.1775 22.4963 35.2947 21.994 35.2947C21.4918 35.2947 20.9964 35.1777 20.5472 34.9529L10.9475 30.1531L10.9452 30.1519C10.4071 29.8808 9.95535 29.4646 9.6411 28.9504C9.32739 28.437 9.16312 27.8464 9.16673 27.2448L9.16675 27.2417L10.0004 27.2475H9.16673V27.2448V15.8239C9.16705 15.2223 9.33518 14.6322 9.65222 14.121C9.96906 13.61 10.4221 13.1976 10.9604 12.9298L20.5592 8.1304L20.5611 8.12948ZM21.3031 9.62267L11.8706 14.3389L22 19.4036L32.1294 14.3389L22.697 9.62267C22.4806 9.51531 22.2416 9.45905 22 9.45905C21.7585 9.45905 21.5194 9.51534 21.3031 9.62267ZM10.8341 15.8241C10.8341 15.7785 10.8362 15.733 10.8401 15.6878L21.1663 20.8509V33.3983L11.6955 28.6629C11.4352 28.5315 11.2159 28.3297 11.0638 28.0809C10.9116 27.8318 10.8321 27.5452 10.8341 27.2533L10.8341 27.2475V15.8241ZM22.8337 33.3923L32.2967 28.6608C32.5576 28.5312 32.7772 28.3313 32.9308 28.0836C33.0844 27.836 33.1658 27.5504 33.166 27.259V15.8243C33.1659 15.7786 33.1639 15.7331 33.1599 15.6878L22.8337 20.8509V33.3923Z",fill:"url(#paint0_linear_3546_7073)"}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.8341 15.8241C10.8341 15.7785 10.8362 15.733 10.8401 15.6878L21.1663 20.8509V33.3983L11.6955 28.6629C11.4352 28.5315 11.2159 28.3297 11.0638 28.0809C10.9116 27.8318 10.8321 27.5452 10.8341 27.2533L10.8341 27.2475V15.8241Z",fill:"url(#paint1_linear_3546_7073)",fillOpacity:"0.3"}),jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_3546_7073",x1:"22",y1:"7.79167",x2:"22",y2:"35.2947",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.7"})]}),jsxRuntimeExports.jsxs("linearGradient",{id:"paint1_linear_3546_7073",x1:"22",y1:"7.79167",x2:"22",y2:"35.2947",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"white"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.7"})]})]})]}),UnknownChain=({testnet:et,...o})=>jsxRuntimeExports.jsx(KnownChain,{testnet:!0,...o}),Ethereum=({testnet:et,...o})=>{let tt="var(--ck-chain-ethereum-01, #25292E)",rt="var(--ck-chain-ethereum-02, #ffffff)";return et&&(tt="linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)",rt="#fff"),jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:tt},children:[jsxRuntimeExports.jsx("path",{d:"M21.9967 6.99621L21.7955 7.67987V27.5163L21.9967 27.7171L31.2044 22.2744L21.9967 6.99621Z",fill:rt}),jsxRuntimeExports.jsx("path",{d:"M21.9957 6.99621L12.7878 22.2744L21.9957 27.7171V18.0891V6.99621Z",fill:rt}),jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.9959 36.9996L21.9959 36.9997V36.9995L31.2091 24.0243L21.9959 29.4642L12.788 24.0243L21.9957 36.9993L21.9958 36.9997L21.9959 36.9996Z",fill:rt}),jsxRuntimeExports.jsx("path",{d:"M21.996 27.7181L31.2037 22.2753L21.996 18.09V27.7181Z",fill:rt}),jsxRuntimeExports.jsx("path",{d:"M12.7878 22.2753L21.9957 27.7181V18.09L12.7878 22.2753Z",fill:rt})]})},Polygon=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#6F41D8"},children:jsxRuntimeExports.jsx("path",{d:"M29.0015 17.4529C28.4941 17.1572 27.8355 17.1572 27.2773 17.4529L23.3186 19.7271L20.6305 21.2094L16.6719 23.4822C16.1645 23.7792 15.5059 23.7792 14.9476 23.4822L11.8016 21.703C11.2943 21.4074 10.9395 20.8642 10.9395 20.2702V16.7612C10.9395 16.1686 11.2434 15.6255 11.8016 15.3285L14.8954 13.5988C15.4041 13.3018 16.0641 13.3018 16.6224 13.5988L19.7161 15.3285C20.2249 15.6255 20.5796 16.1686 20.5796 16.7612V19.0355L23.2678 17.5024V15.2295C23.2707 14.9343 23.1917 14.6441 23.0395 14.3911C22.8873 14.1381 22.6679 13.9324 22.4056 13.7968L16.6719 10.5353C16.1645 10.2382 15.5059 10.2382 14.9476 10.5353L9.11214 13.7968C8.84992 13.9324 8.63049 14.1381 8.47828 14.3911C8.32607 14.6441 8.24705 14.9343 8.25002 15.2295V21.802C8.25002 22.396 8.55389 22.9391 9.11214 23.2361L14.9476 26.4976C15.455 26.7932 16.115 26.7932 16.6719 26.4976L20.6305 24.2729L23.3186 22.7411L27.2773 20.5177C27.7846 20.2207 28.4433 20.2207 29.0015 20.5177L32.0966 22.2475C32.6054 22.5431 32.9588 23.0863 32.9588 23.6803V27.1893C32.9588 27.7819 32.6563 28.325 32.0966 28.622L29.0029 30.4013C28.4941 30.6983 27.8341 30.6983 27.2773 30.4013L24.1821 28.6715C23.6734 28.3745 23.3186 27.8314 23.3186 27.2387V24.9645L20.6305 26.4976V28.7705C20.6305 29.3631 20.9344 29.9076 21.4926 30.2032L27.3281 33.4647C27.8355 33.7617 28.4941 33.7617 29.0524 33.4647L34.8879 30.2032C35.3953 29.9076 35.75 29.3645 35.75 28.7705V22.198C35.753 21.9028 35.674 21.6126 35.5218 21.3596C35.3695 21.1066 35.1501 20.9009 34.8879 20.7653L29.0029 17.4529H29.0015Z",fill:"white"})}),Optimism=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#FF0420"},children:[jsxRuntimeExports.jsx("path",{d:"M15.5877 27.8473C14.2777 27.8473 13.2045 27.539 12.3679 26.9226C11.5422 26.2952 11.1294 25.4035 11.1294 24.2477C11.1294 24.0055 11.157 23.7082 11.212 23.356C11.3552 22.5634 11.5588 21.6112 11.823 20.4994C12.5715 17.4722 14.5034 15.9586 17.6187 15.9586C18.4664 15.9586 19.2259 16.1017 19.8974 16.3879C20.5689 16.663 21.0973 17.0814 21.4826 17.6428C21.8678 18.1932 22.0605 18.8537 22.0605 19.6242C22.0605 19.8554 22.033 20.1471 21.9779 20.4994C21.8128 21.4791 21.6146 22.4313 21.3835 23.356C20.9982 24.8641 20.3322 25.9924 19.3855 26.741C18.4388 27.4785 17.1729 27.8473 15.5877 27.8473ZM15.8189 25.4695C16.4354 25.4695 16.9582 25.2879 17.3876 24.9247C17.8279 24.5614 18.1416 24.0055 18.3287 23.257C18.5819 22.2222 18.7746 21.3195 18.9067 20.5489C18.9507 20.3178 18.9727 20.0811 18.9727 19.8389C18.9727 18.8372 18.4498 18.3363 17.4041 18.3363C16.7876 18.3363 16.2592 18.5179 15.8189 18.8812C15.3896 19.2445 15.0813 19.8004 14.8943 20.5489C14.6961 21.2865 14.4979 22.1892 14.2998 23.257C14.2557 23.477 14.2337 23.7082 14.2337 23.9504C14.2337 24.9632 14.7622 25.4695 15.8189 25.4695Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M22.8188 27.6815C22.6977 27.6815 22.6041 27.6429 22.5381 27.5659C22.483 27.4778 22.4665 27.3788 22.4885 27.2687L24.7672 16.5358C24.7892 16.4147 24.8498 16.3156 24.9489 16.2385C25.0479 16.1615 25.1525 16.1229 25.2626 16.1229H29.6548C30.8767 16.1229 31.8564 16.3761 32.5939 16.8825C33.3426 17.3889 33.7168 18.1209 33.7168 19.0786C33.7168 19.3538 33.6838 19.64 33.6177 19.9372C33.3426 21.2032 32.7867 22.1389 31.95 22.7443C31.1244 23.3498 29.9905 23.6525 28.5485 23.6525H26.3194L25.5598 27.2687C25.5377 27.3898 25.4772 27.4888 25.3782 27.5659C25.2791 27.6429 25.1745 27.6815 25.0645 27.6815H22.8188ZM28.6641 21.3738C29.1264 21.3738 29.5282 21.2472 29.8695 20.994C30.2217 20.7408 30.4529 20.3776 30.563 19.9042C30.596 19.717 30.6125 19.552 30.6125 19.4089C30.6125 19.0896 30.519 18.8474 30.3318 18.6823C30.1446 18.5062 29.8255 18.4182 29.3741 18.4182H27.3926L26.7652 21.3738H28.6641Z",fill:"white"})]}),Arbitrum=({testnet:et,...o})=>{const tt=et?"#ffffff":"#28A0F0",rt=et?"#ffffff":"#96BEDC";return jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#2C364F"},children:[!et&&jsxRuntimeExports.jsx("path",{d:"M25.7948 20.5826L28.2683 16.3854L34.9355 26.7696L34.9386 28.7625L34.9168 15.0491C34.9011 14.7137 34.7231 14.407 34.4391 14.2261L22.4357 7.32182C22.1551 7.1838 21.7989 7.18546 21.5187 7.32618C21.4807 7.34524 21.4453 7.36576 21.4113 7.38835L21.3694 7.41467L9.71816 14.1664L9.67298 14.1871C9.61474 14.2137 9.55609 14.2479 9.50076 14.2872C9.27983 14.4456 9.1331 14.68 9.08564 14.9425C9.07859 14.9823 9.0732 15.023 9.07092 15.064L9.08916 26.239L15.2994 16.6138C16.0811 15.3376 17.7847 14.9262 19.3662 14.9488L21.2221 14.9977L10.2862 32.5356L11.5753 33.2778L22.6422 15.0155L27.5338 14.9977L16.4956 33.7209L21.0955 36.3668L21.6451 36.6827C21.8776 36.7772 22.1516 36.7819 22.386 36.6972L34.5581 29.6433L32.2309 30.9918L25.7948 20.5826ZM26.7384 34.175L22.0925 26.8829L24.9287 22.0702L31.0303 31.6876L26.7384 34.175Z",fill:"#2D374B"}),jsxRuntimeExports.jsx("path",{d:"M22.0924 26.8832L26.7385 34.1751L31.0302 31.6879L24.9286 22.0705L22.0924 26.8832Z",fill:tt}),jsxRuntimeExports.jsx("path",{d:"M34.9387 28.7627L34.9356 26.7698L28.2684 16.3856L25.7949 20.5828L32.2312 30.992L34.5584 29.6435C34.7866 29.4582 34.9248 29.1861 34.9393 28.8926L34.9387 28.7627Z",fill:tt}),jsxRuntimeExports.jsx("path",{d:"M7 30.642L10.2863 32.5356L21.2222 14.9976L19.3663 14.9487C17.785 14.9263 16.0814 15.3375 15.2995 16.6137L9.08927 26.239L7 29.449V30.642V30.642Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M27.534 14.9977L22.6423 15.0155L11.5754 33.2778L15.4437 35.5049L16.4955 33.7209L27.534 14.9977Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M37 14.9723C36.9592 13.9493 36.4052 13.013 35.5377 12.4677L23.377 5.47434C22.5187 5.04223 21.4466 5.04161 20.5868 5.47414C20.4852 5.52533 8.76078 12.3251 8.76078 12.3251C8.5985 12.4029 8.44224 12.4955 8.2953 12.6008C7.52081 13.156 7.0487 14.0186 7 14.9661V29.4492L9.08927 26.2392L9.07103 15.0639C9.07352 15.0231 9.0787 14.9827 9.08575 14.9431C9.133 14.6801 9.27994 14.4457 9.50086 14.2872C9.5562 14.2478 21.4806 7.34517 21.5186 7.32611C21.799 7.18538 22.155 7.18373 22.4356 7.32175L34.439 14.226C34.723 14.4069 34.901 14.7137 34.9167 15.049V28.8921C34.9022 29.1856 34.7862 29.4577 34.558 29.643L32.2308 30.9916L31.03 31.6875L26.7383 34.1747L22.3859 36.6969C22.1515 36.7817 21.8773 36.7769 21.645 36.6824L16.4955 33.7206L15.4435 35.5046L20.0713 38.169C20.2243 38.256 20.3607 38.3331 20.4726 38.3961C20.6458 38.4933 20.764 38.5582 20.8056 38.5785C21.1345 38.7383 21.6077 38.8311 22.0342 38.8311C22.4251 38.8311 22.8064 38.7594 23.1672 38.6181L35.8092 31.2971C36.5347 30.7348 36.9617 29.8869 37 28.9686V14.9723Z",fill:rt})]})},Telos=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#571AFF"},children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M26.1834 8.14754C25.6606 8.23504 25.3644 8.50235 24.9216 9.28591C24.5651 9.91722 24.4762 10.0244 24.2024 10.1592L23.9832 10.2668L19.2967 10.286L14.6097 10.3057L14.3875 10.3902C13.7059 10.6492 13.6192 10.7135 11.6291 12.4407C9.72243 14.0953 9.64893 14.1723 9.59249 14.5836C9.54437 14.9362 9.78981 15.6327 10.5191 17.2143C11.2847 18.8737 11.2839 18.8641 10.7444 19.5256C10.2645 20.1136 10.2269 20.2588 10.2041 21.5915C10.1717 23.502 10.2487 27.6023 10.3222 27.8591C10.3572 27.9816 10.7908 29.204 11.2861 30.5755C11.7813 31.9471 12.4192 33.715 12.704 34.5038C13.4281 36.5107 13.4814 36.5986 14.0392 36.7237C14.3066 36.7837 14.3206 36.781 18.9677 35.7258C24.4395 34.4837 23.7264 34.709 25.0739 33.7968C29.8732 30.5475 29.7337 30.66 29.8969 29.9083C30.0583 29.1642 30.1082 29.1379 31.8267 28.8999C34.6122 28.5145 34.6328 28.5083 34.8831 28.0109C35.0182 27.7423 35.7786 23.3406 35.8136 22.6209C35.8504 21.8828 36.042 22.221 33.3816 18.3395C30.022 13.4382 30.2381 13.7777 30.2399 13.4041C30.2407 13.1735 30.3366 12.9736 31.3236 11.1418C31.8236 10.2134 32.2742 9.35241 32.3254 9.22904C32.5236 8.74691 32.4204 8.3921 32.0301 8.21622L31.8267 8.12391L29.1102 8.11822C27.6048 8.11516 26.2997 8.12829 26.1834 8.14754ZM30.0474 9.4876C30.5623 9.72297 30.5382 9.82447 29.5119 11.7398C28.4317 13.7558 28.3157 13.2711 30.7154 16.7707C31.639 18.1173 32.8076 19.8218 33.3124 20.5581C34.6844 22.5592 34.6048 22.1799 34.1831 24.6903C33.7858 27.0602 33.7792 27.0817 33.3759 27.282C33.1506 27.394 33.2276 27.3813 30.8493 27.7117C28.9147 27.9803 28.8543 28.017 28.6719 29.0338C28.5778 29.557 28.4606 29.8169 28.2243 30.0247C28.0808 30.1512 24.8682 32.368 23.9451 32.9778C23.2587 33.4311 23.6861 33.3152 17.7471 34.6574C17.1997 34.7812 16.4079 34.9632 15.987 35.0617C14.4588 35.4195 14.4299 35.4033 13.8804 33.8948C12.9188 31.2528 11.6811 27.7957 11.6194 27.5787C11.5534 27.3463 11.549 27.1202 11.549 24.059V20.7878L11.6501 20.5966C11.7056 20.4912 11.8671 20.2759 12.0088 20.118C12.8418 19.19 12.8383 19.1183 11.8601 16.9907C10.7663 14.612 10.6797 14.9992 12.697 13.2501C14.2418 11.91 14.3048 11.8593 14.5905 11.7237L14.8394 11.6055L19.6983 11.5854C23.5417 11.5692 24.5891 11.5543 24.7103 11.515C25.1465 11.3728 25.4086 11.1094 25.7975 10.4203C26.3851 9.38041 26.3111 9.40797 28.4597 9.41891C29.6996 9.42547 29.9332 9.43554 30.0474 9.4876Z",fill:"#F7F5FC"})}),Aurora=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#6CD544"},children:jsxRuntimeExports.jsx("path",{d:"M22.0006 7.292C22.6198 7.29004 23.2271 7.46144 23.754 7.7868C24.2808 8.11216 24.706 8.57848 24.9816 9.133L34.3566 27.883C34.611 28.3912 34.7312 28.956 34.7058 29.5238C34.6805 30.0915 34.5103 30.6433 34.2116 31.1268C33.9129 31.6103 33.4956 32.0094 32.9992 32.2861C32.5028 32.5629 31.9439 32.7081 31.3756 32.708H12.6256C12.0573 32.7079 11.4985 32.5626 11.0023 32.2858C10.506 32.009 10.0888 31.6099 9.79022 31.1264C9.49163 30.6429 9.3216 30.0912 9.29628 29.5235C9.27096 28.9558 9.39119 28.3911 9.64556 27.883L19.0196 9.133C19.2951 8.57848 19.7203 8.11216 20.2472 7.7868C20.774 7.46144 21.3814 7.29004 22.0006 7.292ZM22.0006 5C20.9561 4.9999 19.9322 5.29059 19.0437 5.83952C18.1551 6.38846 17.4369 7.17394 16.9696 8.108L7.59456 26.858C7.16544 27.7156 6.96271 28.6687 7.00564 29.6268C7.04856 30.5848 7.33572 31.516 7.83982 32.3318C8.34392 33.1476 9.04823 33.821 9.88584 34.288C10.7235 34.755 11.6666 35.0001 12.6256 35H31.3756C32.3345 34.9999 33.2775 34.7547 34.1149 34.2876C34.9524 33.8206 35.6566 33.1472 36.1606 32.3314C36.6645 31.5156 36.9516 30.5845 36.9945 29.6265C37.0374 28.6686 36.8346 27.7156 36.4056 26.858L27.0316 8.108C26.5642 7.17394 25.846 6.38846 24.9574 5.83952C24.0689 5.29059 23.045 4.9999 22.0006 5Z",fill:"white"})}),Avalanche=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#E84142"},children:[jsxRuntimeExports.jsx("path",{d:"M11.0188 32.1528H15.4825C16.5334 32.1528 17.0589 32.1528 17.5278 32.023C18.042 31.8701 18.511 31.5991 18.9009 31.2261C19.2589 30.885 19.5173 30.4328 20.0269 29.5409L20.0272 29.5404L20.0422 29.5142L25.8314 19.2804C26.3456 18.3821 26.5999 17.93 26.7129 17.4554C26.8372 16.9412 26.8372 16.3988 26.7129 15.8847C26.6007 15.4136 26.3439 14.9648 25.8373 14.0798L25.8258 14.0597L23.56 10.1045C23.0911 9.27958 22.8538 8.86711 22.5543 8.71456C22.2323 8.55071 21.848 8.55071 21.526 8.71456C21.2265 8.86711 20.9892 9.27958 20.5202 10.1045L9.49892 29.5311C9.03561 30.3447 8.80392 30.7517 8.82089 31.0849C8.84349 31.4466 9.02994 31.7743 9.33507 31.9721C9.61756 32.1528 10.0809 32.1528 11.0188 32.1528Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M33.1506 32.1528H26.7547C25.8111 32.1528 25.3365 32.1528 25.0596 31.9721C24.7545 31.7743 24.5681 31.4411 24.5455 31.0794C24.5286 30.7486 24.7621 30.3456 25.2294 29.539L25.2295 29.5388L25.2404 29.5199L28.4328 24.0392C28.9018 23.2313 29.1391 22.8301 29.4329 22.6776C29.7548 22.5137 30.1336 22.5137 30.4555 22.6776C30.7472 22.8261 30.9744 23.2102 31.4241 23.9708L31.4248 23.9719L31.4613 24.0336L34.665 29.5143C34.6806 29.5413 34.696 29.5678 34.7113 29.5939L34.7113 29.594C35.1554 30.3603 35.382 30.7514 35.3657 31.0739C35.3486 31.4353 35.1566 31.7688 34.8515 31.9666C34.5689 32.1528 34.0942 32.1528 33.1506 32.1528Z",fill:"white"})]}),Celo=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#FCFE72"},children:jsxRuntimeExports.jsx("path",{d:"M9 9H34.5183V18.112H30.3564C28.896 14.7687 25.6102 12.4171 21.777 12.4171C16.593 12.4171 12.3948 16.6422 12.3948 21.823C12.3948 27.0039 16.593 31.2654 21.777 31.2654C25.5373 31.2654 28.8231 28.9876 30.2829 25.7172H34.5178V34.682H9V9Z",fill:et?"#ffffff":"black"})}),Gnosis=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#009CB4"},children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.3439 11.8664C17.9374 6.53462 26.7953 6.74397 32.1271 12.3374C32.4738 12.7038 32.8075 13.0832 33.1084 13.4823L22 24.5972L10.8916 13.4823C11.1991 13.0832 11.5262 12.7038 11.8729 12.3374C12.0234 12.1804 12.1804 12.0234 12.3439 11.8664ZM30.6094 13.3972C28.3196 11.0944 25.271 9.83182 22 9.83182C18.729 9.83182 15.6804 11.0944 13.3907 13.3972L22 22.0066L30.6094 13.3972ZM33.9785 14.7446L31.7215 17.0016C33.5402 19.1801 33.2523 22.425 31.0738 24.2437C29.1636 25.84 26.3897 25.84 24.4794 24.2437L22 26.7231L19.5271 24.2502C17.3486 26.0689 14.1037 25.7811 12.285 23.6026C10.6888 21.6923 10.6888 18.9185 12.285 17.0082L11.1271 15.8502L10.028 14.7446C8.7 16.9297 8 19.4418 8 21.9998C8 29.7325 14.2673 35.9998 22 35.9998C29.7327 35.9998 36 29.7325 36 21.9998C36.0065 19.4418 35.3 16.9297 33.9785 14.7446ZM30.6486 18.0747C31.1392 18.7093 31.4075 19.4943 31.4075 20.299C31.4075 21.1037 31.1392 21.8887 30.6486 22.5233C29.4187 24.113 27.1355 24.4074 25.5458 23.1775L30.6486 18.0747ZM18.4542 23.1839C17.8196 23.6745 17.0346 23.9427 16.2299 23.9427C15.4252 23.9427 14.6467 23.6745 14.0056 23.1904C12.4159 21.9605 12.1215 19.6708 13.3514 18.0811L18.4542 23.1839Z",fill:"white"})}),Evmos=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#2D2A25"},children:jsxRuntimeExports.jsx("path",{d:"M18.4916 12.6668C12.9416 14.806 12.4332 20.2846 10.8418 22.8432C9.23155 25.4322 5.54251 26.8607 6.04698 28.1801C6.55143 29.4994 10.2449 28.0824 13.1669 28.9242C16.0543 29.7561 20.0831 33.4862 25.633 31.3469C28.4603 30.2573 30.5076 28.0143 31.449 25.3574C31.5502 25.0723 31.361 24.7673 31.0606 24.7391C30.874 24.7215 30.6948 24.8196 30.6106 24.9877C29.759 26.6908 28.2981 28.0934 26.3864 28.8301C23.2303 30.0465 19.777 29.0915 17.6562 26.6961C17.1746 26.1522 16.7626 25.533 16.4374 24.8487C16.348 24.6603 16.2629 24.4689 16.1875 24.2708C16.1117 24.0728 16.0473 23.8735 15.9881 23.6732C17.6562 22.8925 19.5812 22.0656 21.7635 21.2246C23.903 20.3999 25.8505 19.731 27.5841 19.1958C28.7571 18.8341 29.8322 18.5331 30.8029 18.2871C30.8732 18.2695 30.9423 18.2519 31.0112 18.2347C31.158 18.1982 31.3088 18.2769 31.363 18.4186L31.364 18.4213C31.396 18.5053 31.4236 18.5898 31.4535 18.6743C31.6453 19.2196 31.7892 19.7706 31.8841 20.3229C31.9258 20.5645 32.1888 20.6961 32.4044 20.5799C33.2014 20.1504 33.9302 19.7314 34.5814 19.3283C37.0083 17.8276 38.3538 16.5549 38.0776 15.8336C37.802 15.1119 35.9541 15.0705 33.1503 15.5854C32.2593 15.7491 31.2716 15.9691 30.207 16.2416C30.0229 16.2886 29.8365 16.3375 29.6481 16.3877C28.7522 16.6262 27.8073 16.8995 26.8234 17.2053C24.9936 17.7744 23.0305 18.4561 21.0038 19.2372C19.1078 19.9682 17.3109 20.726 15.6629 21.4812C15.6428 18.2761 17.5725 15.2461 20.7286 14.0297C22.6399 13.293 24.6605 13.3533 26.4285 14.0473C26.6029 14.116 26.8015 14.0684 26.9291 13.9298C27.1331 13.7076 27.0706 13.3537 26.8053 13.2094C24.3353 11.8685 21.319 11.5771 18.4916 12.6668Z",fill:"#FAF1E4"})}),BinanceSmartChain=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#16181A"},children:[jsxRuntimeExports.jsx("path",{d:"M16.0445 19.6063L21.8705 13.7805L27.6996 19.6093L31.0896 16.2193L21.8705 7L12.6545 16.2163L16.0445 19.6063Z",fill:et?"#fff":"#F3BA2F"}),jsxRuntimeExports.jsx("path",{d:"M13.6505 21.9995L10.2606 18.6096L6.87046 21.9997L10.2604 25.3896L13.6505 21.9995Z",fill:et?"#fff":"#F3BA2F"}),jsxRuntimeExports.jsx("path",{d:"M16.0445 24.3937L21.8705 30.2195L27.6994 24.3909L31.0913 27.779L31.0896 27.7809L21.8705 37L12.6542 27.7839L12.6495 27.7792L16.0445 24.3937Z",fill:et?"#fff":"#F3BA2F"}),jsxRuntimeExports.jsx("path",{d:"M33.4808 25.3911L36.8709 22.001L33.481 18.6111L30.0909 22.0012L33.4808 25.3911Z",fill:et?"#fff":"#F3BA2F"}),jsxRuntimeExports.jsx("path",{d:"M25.3091 21.9982H25.3105L21.8705 18.5582L19.3283 21.1004H19.3281L19.0362 21.3926L18.4336 21.9951L18.4289 21.9999L18.4336 22.0048L21.8705 25.4418L25.3105 22.0018L25.3122 21.9999L25.3091 21.9982Z",fill:et?"#fff":"#F3BA2F"})]}),Canto=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"white"},children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M35 8V36H9L13.875 35.9998V31.0586H9V12.9412H13.875V8H35ZM17.9373 12.9414H30.1247V17.8826H17.9373V12.9414ZM30.1247 26.9414H17.9373V17.8826L13.0623 17.8828V26.9416L17.9373 26.9414V31.8826H30.1247V26.9414Z",fill:"#06FC99"})}),Fantom=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#0911EF"},children:jsxRuntimeExports.jsx("path",{d:"M20.92 9.25864C21.5933 8.91379 22.6178 8.91379 23.2911 9.25864L30.1616 12.7775C30.5671 12.9852 30.7898 13.2947 30.8297 13.6142H30.8363V31.302C30.8274 31.6504 30.6025 31.9966 30.1616 32.2225L23.2911 35.7413C22.6178 36.0862 21.5933 36.0862 20.92 35.7413L14.0495 32.2225C13.6104 31.9976 13.3997 31.6489 13.3893 31.302C13.3883 31.2678 13.3881 31.2393 13.3891 31.2157L13.3891 13.7278C13.3884 13.7086 13.3883 13.6895 13.3889 13.6705L13.3893 13.6142L13.3924 13.6142C13.4229 13.2912 13.6355 12.9896 14.0495 12.7775L20.92 9.25864ZM29.7547 23.4821L23.2911 26.7926C22.6178 27.1374 21.5933 27.1374 20.92 26.7926L14.4706 23.4895V31.2669L20.92 34.5527C21.2842 34.7415 21.6622 34.9254 22.0318 34.9488L22.1056 34.9512C22.4907 34.9524 22.8646 34.7628 23.2438 34.5833L29.7547 31.2387V23.4821ZM11.3214 31.8437C11.3214 32.5212 11.4026 32.9667 11.5639 33.2806C11.6976 33.5407 11.8981 33.7394 12.2643 33.9813L12.2852 33.9951C12.3656 34.0476 12.4541 34.1026 12.5619 34.1672L12.689 34.2427L13.0792 34.4711L12.5195 35.3685L12.0827 35.1126L12.0093 35.0689C11.883 34.9932 11.7783 34.9284 11.6807 34.8645C10.637 34.1822 10.2478 33.4384 10.2401 31.8907L10.24 31.8437H11.3214ZM21.5647 18.7412C21.5147 18.7579 21.4678 18.7772 21.4251 18.7991L14.5546 22.318C14.5474 22.3216 14.5405 22.3253 14.534 22.3289L14.5281 22.3322L14.5389 22.3382L14.5546 22.3464L21.4251 25.8653C21.4678 25.8872 21.5147 25.9065 21.5647 25.9231V18.7412ZM22.6465 18.7412V25.9231C22.6965 25.9065 22.7433 25.8872 22.7861 25.8653L29.6566 22.3464C29.6638 22.3427 29.6707 22.3391 29.6772 22.3355L29.683 22.3322L29.6722 22.3262L29.6566 22.318L22.7861 18.7991C22.7433 18.7772 22.6965 18.7579 22.6465 18.7412ZM29.7547 14.8689L23.5915 18.0256L29.7547 21.1822V14.8689ZM14.4706 14.8763V21.1749L20.6195 18.0256L14.4706 14.8763ZM22.7861 10.1859C22.4288 10.0029 21.7824 10.0029 21.4251 10.1859L14.5546 13.7048C14.5474 13.7085 14.5405 13.7122 14.534 13.7158L14.5281 13.719L14.5389 13.725L14.5546 13.7333L21.4251 17.2522C21.7824 17.4352 22.4288 17.4352 22.7861 17.2522L29.6566 13.7333C29.6638 13.7296 29.6707 13.7259 29.6772 13.7223L29.683 13.719L29.6722 13.7131L29.6566 13.7048L22.7861 10.1859ZM31.7205 9.64552L32.1573 9.90132L32.2307 9.94503C32.357 10.0206 32.4616 10.0856 32.5593 10.1494C33.603 10.8317 33.9922 11.5756 33.9998 13.1231L34 13.1703H32.9186C32.9186 12.4926 32.8373 12.0472 32.6761 11.7334C32.5424 11.4733 32.3419 11.2745 31.9757 11.0327L31.9547 11.0189C31.8744 10.9664 31.7858 10.9113 31.6781 10.8466L31.551 10.7712L31.1608 10.5428L31.7205 9.64552Z",fill:"white"})}),Filecoin=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#0090FF"},children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M23.75 19.3069L23.15 22.5069L28.85 23.3069L28.45 24.8069L22.85 24.0069C22.45 25.3069 22.25 26.7069 21.75 27.9069C21.25 29.3069 20.75 30.7069 20.15 32.0069C19.35 33.7069 17.95 34.9069 16.05 35.2069C14.95 35.4069 13.75 35.3069 12.85 34.6069C12.55 34.4069 12.25 34.0069 12.25 33.7069C12.25 33.3069 12.45 32.8069 12.75 32.6069C12.95 32.5069 13.45 32.6069 13.75 32.7069C14.05 33.0069 14.35 33.4069 14.55 33.8069C15.15 34.6069 15.95 34.7069 16.75 34.1069C17.65 33.3069 18.15 32.2069 18.45 31.1069C19.05 28.7069 19.65 26.4069 20.15 24.0069V23.6069L14.85 22.8069L15.05 21.3069L20.55 22.1069L21.25 19.0069L15.55 18.1069L15.75 16.5069L21.65 17.3069C21.85 16.7069 21.95 16.2069 22.15 15.7069C22.65 13.9069 23.15 12.1069 24.35 10.5069C25.55 8.90687 26.95 7.90687 29.05 8.00687C29.95 8.00687 30.85 8.30687 31.45 9.00687C31.55 9.10687 31.75 9.30687 31.75 9.50687C31.75 9.90687 31.75 10.4069 31.45 10.7069C31.05 11.0069 30.55 10.9069 30.15 10.5069C29.85 10.2069 29.65 9.90687 29.35 9.60687C28.75 8.80687 27.85 8.70687 27.15 9.40687C26.65 9.90687 26.15 10.6069 25.85 11.3069C25.15 13.4069 24.65 15.6069 23.95 17.8069L29.45 18.6069L29.05 20.1069L23.75 19.3069Z",fill:"white"})}),IoTeX=({testnet:et,...o})=>jsxRuntimeExports.jsxs("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#00D4D5"},children:[jsxRuntimeExports.jsx("path",{d:"M23.7136 6.875V14.3784L30.2284 10.6315L23.7136 6.875Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.9",d:"M30.2284 10.6316V18.135L36.7418 14.3785L30.2284 10.6316Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.8",d:"M23.7136 14.3784V21.8818L30.2284 18.1349L23.7136 14.3784ZM30.2284 18.1349V25.6383L36.7417 21.8818L30.2284 18.1349Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.8",d:"M23.7136 21.8817V29.385L30.2284 25.6382L23.7136 21.8817Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M30.2284 25.6382V33.1416L36.7418 29.3851L30.2284 25.6382Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.4",d:"M6.87537 14.1253V21.6287L13.3901 17.8722L6.87537 14.1253Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.2",d:"M15.0938 16.9153V24.4186L21.5975 20.6718L15.0938 16.9153Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.3",d:"M10.2648 21.6604V29.1638L16.7781 25.4073L10.2648 21.6604Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.9",d:"M14.5575 27.3226V34.826L21.0612 31.0695L14.5575 27.3226Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.7",d:"M23.66 30.5525V38.0572L30.1637 34.2993L23.66 30.5525Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.9",d:"M16.1786 13.2097V20.7145L22.6824 16.9676L16.1786 13.2097Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.8",d:"M23.7136 6.875V14.3784L17.1989 10.6315L23.7136 6.875Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.6",d:"M16.1786 10.0649V17.5669L9.66248 13.8104L16.1786 10.0649Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.6",d:"M22.6934 13.7775V21.2823L16.1786 17.5244L22.6934 13.7775Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.95",d:"M15.0635 16.9153V24.4186L8.54877 20.6718L15.0635 16.9153Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.6",d:"M23.7136 21.8817V29.385L17.2099 25.6382L23.7136 21.8817Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.55",d:"M10.2648 23.6295V31.1328L3.75 27.375L10.2648 23.6295Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M36.7418 14.3784V21.8818L30.2284 18.1349L36.7418 14.3784Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.95",d:"M30.2284 18.1362V25.6382L23.7136 21.8817L30.2284 18.1362Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.9",d:"M36.7418 21.8817V29.385L30.2284 25.6382L36.7418 21.8817Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.7",d:"M30.2284 25.6382V33.1416L23.7136 29.3851L30.2284 25.6382Z",fill:"white"}),jsxRuntimeExports.jsx("path",{opacity:"0.4",d:"M22.2712 28.7651V36.2684L15.7579 32.5216L22.2712 28.7651Z",fill:"white"}),jsxRuntimeExports.jsx("path",{d:"M30.2284 10.6316V18.135L23.7136 14.3785L30.2284 10.6316Z",fill:"white"})]}),Metis=({testnet:et,...o})=>jsxRuntimeExports.jsx("svg",{...o,"aria-hidden":"true",width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{background:et?"linear-gradient(180deg, #8995A9 0%, #424D5F 99.48%)":"#2F3140"},children:jsxRuntimeExports.jsx("path",{d:"M37.5175 22.0531C37.4579 19.2923 36.6563 16.5985 35.1968 14.2542C33.7374 11.91 31.674 10.0017 29.223 8.72965C26.772 7.45759 24.0238 6.86863 21.2668 7.02455C18.5098 7.18047 15.8456 8.07553 13.5537 9.61582C11.2617 11.1561 9.42659 13.2849 8.24079 15.7787C7.05498 18.2725 6.56222 21.0396 6.81419 23.7895C7.06617 26.5394 8.05359 29.1708 9.67288 31.4076C11.2922 33.6444 13.4836 35.4042 16.0173 36.5023C16.7657 35.3775 17.3385 34.1453 17.716 32.848C18.0245 32.0632 18.3595 31.2913 18.7067 30.5446C19.5444 30.7955 20.4345 30.8143 21.282 30.5989C22.1295 30.3835 22.9026 29.942 23.5188 29.3215L23.5704 29.2699C22.8136 28.9884 21.9979 28.9032 21.1993 29.022C20.4006 29.1408 19.6451 29.4598 19.0029 29.9494C19.4276 29.0613 19.891 28.1997 20.3667 27.3632C21.189 27.6541 22.075 27.7156 22.9296 27.541C23.7842 27.3665 24.5751 26.9626 25.2175 26.3726L25.2692 26.3209C24.538 26.0116 23.7416 25.8885 22.9513 25.9626C22.1609 26.0368 21.4013 26.3058 20.7404 26.7456C21.216 25.9608 21.7053 25.1889 22.2203 24.468C23.0713 24.6915 23.9672 24.6777 24.811 24.4282C25.6547 24.1787 26.414 23.703 27.0066 23.0526L27.0453 23.001C26.3425 22.7718 25.5958 22.7106 24.8651 22.8224C24.1344 22.9341 23.4401 23.2157 22.838 23.6444C22.8767 23.5928 22.9283 23.5289 22.9664 23.4773C23.2749 23.0784 23.5969 22.6796 23.9177 22.2936C24.8969 21.9731 25.7703 21.3916 26.4436 20.6117C27.117 19.8318 27.5649 18.883 27.7391 17.8674L27.752 17.79H27.7391C26.7194 18.0552 25.7944 18.6007 25.0689 19.3648C24.3434 20.1288 23.8464 21.0808 23.6343 22.1129C23.3258 22.4859 23.0167 22.8603 22.7211 23.2449C22.9706 22.5925 23.0724 21.893 23.0191 21.1966C22.9657 20.5002 22.7586 19.8243 22.4126 19.2176L22.3739 19.2692C21.8489 19.9862 21.5326 20.8345 21.4599 21.7201C21.3873 22.6058 21.5611 23.4942 21.9621 24.2872C21.4729 24.9823 20.9972 25.6897 20.5467 26.4357C20.6918 25.6858 20.6542 24.9118 20.4369 24.1795C20.2196 23.4471 19.8291 22.7779 19.2985 22.2284L19.2727 22.2929C18.9445 23.1107 18.8477 24.0031 18.9929 24.8723C19.1382 25.7415 19.5199 26.5539 20.0962 27.2205C19.6457 28.0054 19.2211 28.816 18.8093 29.6524C18.9344 28.8712 18.8712 28.0715 18.6251 27.3196C18.3789 26.5677 17.9568 25.8855 17.3939 25.3295L17.3681 25.3941C17.0745 26.2514 17.0201 27.1724 17.2105 28.0583C17.401 28.9442 17.8292 29.7614 18.4492 30.4223C18.1774 31.0012 17.9219 31.5774 17.6773 32.1849C17.61 32.1231 17.5313 32.0751 17.4456 32.0435C17.0066 31.916 16.5867 31.7299 16.1974 31.4904C15.8754 31.2994 15.5337 31.144 15.1781 31.027C13.7886 30.5765 13.9945 29.9079 13.2756 28.5564C13.0416 28.2781 12.7931 28.0125 12.5309 27.7607C12.2876 27.603 12.0884 27.386 11.9519 27.1302C11.7934 26.8107 11.6931 26.4656 11.6557 26.1109C11.6514 25.9148 11.5858 25.7249 11.4681 25.5679C11.3504 25.4109 11.1864 25.2948 10.9993 25.2358C8.95338 24.5284 9.86728 21.8778 9.94406 21.5299C9.91262 21.08 9.81271 20.6375 9.64781 20.2178C9.63057 20.1632 9.61763 20.1073 9.60908 20.0506C9.55449 19.776 9.56444 19.4924 9.63813 19.2223C9.71183 18.9521 9.84726 18.7028 10.0338 18.4939C10.2784 18.2493 11.1277 17.8505 11.3078 17.6188C11.4879 17.387 11.6163 17.1295 11.797 16.9114C12.3687 16.3412 13.0291 15.8675 13.7526 15.509C14.3444 15.1876 14.4477 14.364 14.6787 14.1065C15.0647 13.6689 15.6565 13.6689 16.0941 13.283C16.3129 13.09 16.6377 12.9867 16.8415 12.7815C17.8692 11.8403 19.1644 11.2423 20.5474 11.0706C21.5064 10.9924 22.4717 11.0795 23.4012 11.3281C23.5358 11.3507 23.669 11.3809 23.8001 11.4185C25.9228 11.4959 28.4709 11.9328 29.397 12.8338C29.8555 13.2744 30.1961 13.8229 30.3877 14.4293C30.5382 14.8988 30.7456 15.3481 31.0054 15.7672L31.5714 16.6933C31.932 17.2773 32.0475 17.9801 31.8928 18.6489C31.7885 18.974 31.7795 19.3223 31.8669 19.6525C32.1655 20.1031 32.5152 20.5177 32.9093 20.8878C33.0658 21.0427 33.2382 21.1807 33.4236 21.2995C33.8592 21.5594 34.2802 21.8429 34.6848 22.1489C34.698 22.2729 34.6775 22.3982 34.6254 22.5115C34.5732 22.6247 34.4914 22.7218 34.3885 22.7924C34.0284 23.1137 33.3333 23.6159 33.3333 23.6159C33.3584 23.758 33.4016 23.8964 33.4617 24.0276C33.5643 24.2077 33.796 24.4911 33.7192 24.735C33.6424 24.9789 33.1403 25.1855 33.2816 25.4552C33.423 25.7386 33.7831 25.8154 33.6805 26.0729C33.5779 26.3175 33.0757 26.7524 33.1274 26.9352C33.179 27.1179 33.5908 28.8377 32.6382 29.1353C31.4592 29.3685 30.2627 29.5019 29.0614 29.5342C28.8675 29.5454 28.6797 29.6055 28.5155 29.709C28.3513 29.8125 28.216 29.956 28.1223 30.126C27.9399 30.4661 27.8222 30.837 27.7751 31.22C27.4275 32.5896 26.9671 33.928 26.3985 35.2215C26.3985 35.2215 26.3597 35.2989 26.3081 35.4144C26.1833 35.6687 26.1048 35.9432 26.0764 36.2251C26.1573 36.4321 26.2799 36.6204 26.4365 36.7782C26.519 36.8726 26.6271 36.9411 26.7477 36.9753C26.8683 37.0096 26.9962 37.0081 27.116 36.9711C30.1997 35.8965 32.8655 33.8757 34.7332 31.197C36.601 28.5182 37.5754 25.3182 37.5175 22.0531Z",fill:et?"#ffffff":"#00DACC"})});var Chains={UnknownChain,Ethereum,Polygon,Optimism,Arbitrum,Aurora,Avalanche,Celo,Telos,Gnosis,Evmos,BinanceSmartChain,Foundry:KnownChain,Sepolia:KnownChain,Taraxa:KnownChain,zkSync:KnownChain,Flare:KnownChain,Canto,Fantom,Filecoin,Metis,IoTeX};const chainConfigs=[{id:1,name:"Ethereum",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{}),rpcUrls:{alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]}}},{id:3,name:"Rinkeby",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0}),rpcUrls:{}},{id:4,name:"Ropsten",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:5,name:"Görli",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:42,name:"Kovan",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:10,name:"Optimism",logo:jsxRuntimeExports.jsx(Chains.Optimism,{})},{id:69,name:"Optimism Kovan",logo:jsxRuntimeExports.jsx(Chains.Optimism,{testnet:!0})},{id:420,name:"Optimism Goerli",logo:jsxRuntimeExports.jsx(Chains.Optimism,{testnet:!0})},{id:137,name:"Polygon",logo:jsxRuntimeExports.jsx(Chains.Polygon,{})},{id:80001,name:"Polygon Mumbai",logo:jsxRuntimeExports.jsx(Chains.Polygon,{testnet:!0})},{id:31337,name:"Hardhat",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:1337,name:"Localhost",logo:jsxRuntimeExports.jsx(Chains.Ethereum,{testnet:!0})},{id:42161,name:"Arbitrum",logo:jsxRuntimeExports.jsx(Chains.Arbitrum,{}),rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]}}},{id:421611,name:"Arbitrum Rinkeby",logo:jsxRuntimeExports.jsx(Chains.Arbitrum,{testnet:!0})},{id:421613,name:"Arbitrum Goerli",logo:jsxRuntimeExports.jsx(Chains.Arbitrum,{testnet:!0}),rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]}}},{id:40,name:"Telos",logo:jsxRuntimeExports.jsx(Chains.Telos,{})},{id:41,name:"Telos Testnet",logo:jsxRuntimeExports.jsx(Chains.Telos,{testnet:!0})},{id:1313161554,name:"Aurora",logo:jsxRuntimeExports.jsx(Chains.Aurora,{})},{id:1313161555,name:"Aurora Testnet",logo:jsxRuntimeExports.jsx(Chains.Aurora,{testnet:!0})},{id:43114,name:"Avalanche",logo:jsxRuntimeExports.jsx(Chains.Avalanche,{})},{id:43113,name:"Avalanche Fuji",logo:jsxRuntimeExports.jsx(Chains.Avalanche,{testnet:!0})},{id:31337,name:"Foundry",logo:jsxRuntimeExports.jsx(Chains.Foundry,{testnet:!0})},{id:100,name:"Gnosis",logo:jsxRuntimeExports.jsx(Chains.Gnosis,{})},{id:9001,name:"Evmos",logo:jsxRuntimeExports.jsx(Chains.Evmos,{})},{id:9e3,name:"Evmos Testnet",logo:jsxRuntimeExports.jsx(Chains.Evmos,{testnet:!0})},{id:56,name:"BNB Smart Chain",logo:jsxRuntimeExports.jsx(Chains.BinanceSmartChain,{})},{id:97,name:"Binance Smart Chain Testnet",logo:jsxRuntimeExports.jsx(Chains.BinanceSmartChain,{testnet:!0})},{id:11155111,name:"Sepolia",logo:jsxRuntimeExports.jsx(Chains.Sepolia,{})},{id:841,name:"Taraxa",logo:jsxRuntimeExports.jsx(Chains.Taraxa,{})},{id:842,name:"Taraxa Testnet",logo:jsxRuntimeExports.jsx(Chains.Taraxa,{testnet:!0})},{id:324,name:"zkSync",logo:jsxRuntimeExports.jsx(Chains.zkSync,{})},{id:280,name:"zkSync Testnet",logo:jsxRuntimeExports.jsx(Chains.zkSync,{testnet:!0})},{id:42220,name:"Celo",logo:jsxRuntimeExports.jsx(Chains.Celo,{})},{id:44787,name:"Celo Alfajores",logo:jsxRuntimeExports.jsx(Chains.Celo,{testnet:!0})},{id:7700,name:"Canto",logo:jsxRuntimeExports.jsx(Chains.Canto,{})},{id:250,name:"Fantom",logo:jsxRuntimeExports.jsx(Chains.Fantom,{})},{id:4002,name:"Fantom Testnet",logo:jsxRuntimeExports.jsx(Chains.Fantom,{testnet:!0})},{id:14,name:"Flare",logo:jsxRuntimeExports.jsx(Chains.Flare,{})},{id:114,name:"Coston2",logo:jsxRuntimeExports.jsx(Chains.Flare,{})},{id:314,name:"Filecoin",logo:jsxRuntimeExports.jsx(Chains.Filecoin,{})},{id:3141,name:"Filecoin Hyperspace",logo:jsxRuntimeExports.jsx(Chains.Filecoin,{testnet:!0})},{id:314159,name:"Filecoin Calibration",logo:jsxRuntimeExports.jsx(Chains.Filecoin,{testnet:!0})},{id:1088,name:"Metis",logo:jsxRuntimeExports.jsx(Chains.Metis,{})},{id:599,name:"Metis Goerli",logo:jsxRuntimeExports.jsx(Chains.Metis,{testnet:!0})},{id:4689,name:"IoTeX",logo:jsxRuntimeExports.jsx(Chains.IoTeX,{})},{id:4690,name:"IoTeX Testnet",logo:jsxRuntimeExports.jsx(Chains.IoTeX,{testnet:!0})}],SwitchNetworksContainer=styled.div` display: flex; flex-direction: column; @@ -3181,7 +3181,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C @media only screen and (max-width: ${defaultTheme.mobileWidth}px) { inset: 0 var(--ck-dropdown-active-inset, -8px); } -`,Spinner$1=jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 16.75C2.69036 16.75 3.25 17.3096 3.25 18V19C3.25 26.5939 9.40609 32.75 17 32.75V35.25C8.02537 35.25 0.75 27.9746 0.75 19V18C0.75 17.3096 1.30964 16.75 2 16.75Z",fill:"url(#paint0_linear_1288_18701)"}),jsxRuntimeExports.jsx("defs",{children:jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_1288_18701",x1:"2",y1:"19.4884",x2:"16.8752",y2:"33.7485",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-spinner-color)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-spinner-color)",stopOpacity:"0"})]})})]}),ChainSelectList=({variant:et})=>{const{connector:o,chain:tt}=useAccount(),{chains:rt,isPending:nt,switchChain:ot,error:it}=useSwitchChain(),[st,at]=reactExports.useState(void 0),ct=useLocales({}),lt=isMobile(),dt=(it==null?void 0:it.code)===4902,ht=dt||!ot,mt=pt=>{ot&&(at(pt),ot({chainId:pt}))},{triggerResize:ft}=useContext();return jsxRuntimeExports.jsxs(SwitchNetworksContainer,{style:{marginBottom:ot!==void 0?-8:0},children:[jsxRuntimeExports.jsx(ChainButtonContainer,{children:jsxRuntimeExports.jsx(ChainButtons,{children:rt.map(pt=>{var gt;const bt={...chainConfigs.find(xt=>xt.id===pt.id),...pt};return jsxRuntimeExports.jsxs(ChainButton,{$variant:et,disabled:ht||bt.id===(tt==null?void 0:tt.id)||nt&&st===bt.id,onClick:()=>mt==null?void 0:mt(bt.id),style:{opacity:ht&&bt.id!==(tt==null?void 0:tt.id)?.4:void 0},children:[jsxRuntimeExports.jsxs("span",{style:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:12,color:bt.id===(tt==null?void 0:tt.id)?"var(--ck-dropdown-active-color, inherit)":"inherit"},children:[jsxRuntimeExports.jsxs(ChainLogoContainer,{children:[jsxRuntimeExports.jsx(ChainLogoSpinner,{initial:{opacity:0},animate:{opacity:nt&&st===bt.id?1:0},transition:{ease:[.76,0,.24,1],duration:.15,delay:.1},children:jsxRuntimeExports.jsx(motion.div,{animate:lt&&isCoinbaseWalletConnector(o==null?void 0:o.id)&&nt&&st===bt.id?{opacity:[1,0],transition:{delay:4,duration:3}}:{opacity:1},children:Spinner$1},`${bt==null?void 0:bt.id}-${bt==null?void 0:bt.name}`)}),jsxRuntimeExports.jsx(ChainIcon,{children:(gt=bt.logo)!==null&>!==void 0?gt:jsxRuntimeExports.jsx(Chains.UnknownChain,{})})]}),bt.name]}),et!=="secondary"&&jsxRuntimeExports.jsx(ChainButtonStatus,{children:jsxRuntimeExports.jsxs(AnimatePresence,{initial:!1,exitBeforeEnter:!0,children:[bt.id===(tt==null?void 0:tt.id)&&jsxRuntimeExports.jsx(motion.span,{style:{color:"var(--ck-dropdown-active-color, var(--ck-focus-color))",display:"block",position:"relative"},initial:{opacity:0,x:-4},animate:{opacity:1,x:0},exit:{opacity:0,x:4,transition:{duration:.1,delay:0}},transition:{ease:[.76,0,.24,1],duration:.3,delay:.2},children:ct.connected},"connectedText"),nt&&st===bt.id&&jsxRuntimeExports.jsx(motion.span,{style:{color:"var(--ck-dropdown-pending-color, inherit)",display:"block",position:"relative"},initial:{opacity:0,x:-4},animate:{opacity:1,x:0},exit:{opacity:0,x:4},transition:{ease:[.76,0,.24,1],duration:.3,delay:.1},children:jsxRuntimeExports.jsx(motion.span,{animate:lt&&isCoinbaseWalletConnector(o==null?void 0:o.id)&&{opacity:[1,0],transition:{delay:4,duration:4}},children:ct.approveInWallet})},"approveText")]})}),et==="secondary"?jsxRuntimeExports.jsx(ChainButtonBg,{initial:!1,animate:{opacity:bt.id===(tt==null?void 0:tt.id)?1:0},transition:{duration:.3,ease:"easeOut"}}):bt.id===(tt==null?void 0:tt.id)&&jsxRuntimeExports.jsx(ChainButtonBg,{layoutId:"activeChain",layout:"position",transition:{duration:.3,ease:"easeOut"}})]},`${bt==null?void 0:bt.id}-${bt==null?void 0:bt.name}`)})})}),jsxRuntimeExports.jsx(AnimatePresence,{children:dt&&jsxRuntimeExports.jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{ease:[.76,0,.24,1],duration:.3},onAnimationStart:ft,onAnimationComplete:ft,children:jsxRuntimeExports.jsx("div",{style:{paddingTop:10,paddingBottom:8},children:jsxRuntimeExports.jsxs(Alert,{children:[ct.warnings_walletSwitchingUnsupported," ",ct.warnings_walletSwitchingUnsupportedResolve]})})})})]})},DropdownWindow=styled(motion.div)` +`,Spinner$1=jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 16.75C2.69036 16.75 3.25 17.3096 3.25 18V19C3.25 26.5939 9.40609 32.75 17 32.75V35.25C8.02537 35.25 0.75 27.9746 0.75 19V18C0.75 17.3096 1.30964 16.75 2 16.75Z",fill:"url(#paint0_linear_1288_18701)"}),jsxRuntimeExports.jsx("defs",{children:jsxRuntimeExports.jsxs("linearGradient",{id:"paint0_linear_1288_18701",x1:"2",y1:"19.4884",x2:"16.8752",y2:"33.7485",gradientUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("stop",{stopColor:"var(--ck-spinner-color)"}),jsxRuntimeExports.jsx("stop",{offset:"1",stopColor:"var(--ck-spinner-color)",stopOpacity:"0"})]})})]}),ChainSelectList=({variant:et})=>{const{connector:o,chain:tt}=useAccount(),{chains:rt,isPending:nt,switchChain:ot,error:it}=useSwitchChain(),[st,at]=reactExports.useState(void 0),ct=useLocales({}),lt=isMobile(),dt=(it==null?void 0:it.code)===4902,ht=dt||!ot,mt=pt=>{ot&&(at(pt),ot({chainId:pt}))},{triggerResize:ft}=useContext();return jsxRuntimeExports.jsxs(SwitchNetworksContainer,{style:{marginBottom:ot!==void 0?-8:0},children:[jsxRuntimeExports.jsx(ChainButtonContainer,{children:jsxRuntimeExports.jsx(ChainButtons,{children:rt.map(pt=>{var yt;const bt={...chainConfigs.find(xt=>xt.id===pt.id),...pt};return jsxRuntimeExports.jsxs(ChainButton,{$variant:et,disabled:ht||bt.id===(tt==null?void 0:tt.id)||nt&&st===bt.id,onClick:()=>mt==null?void 0:mt(bt.id),style:{opacity:ht&&bt.id!==(tt==null?void 0:tt.id)?.4:void 0},children:[jsxRuntimeExports.jsxs("span",{style:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:12,color:bt.id===(tt==null?void 0:tt.id)?"var(--ck-dropdown-active-color, inherit)":"inherit"},children:[jsxRuntimeExports.jsxs(ChainLogoContainer,{children:[jsxRuntimeExports.jsx(ChainLogoSpinner,{initial:{opacity:0},animate:{opacity:nt&&st===bt.id?1:0},transition:{ease:[.76,0,.24,1],duration:.15,delay:.1},children:jsxRuntimeExports.jsx(motion.div,{animate:lt&&isCoinbaseWalletConnector(o==null?void 0:o.id)&&nt&&st===bt.id?{opacity:[1,0],transition:{delay:4,duration:3}}:{opacity:1},children:Spinner$1},`${bt==null?void 0:bt.id}-${bt==null?void 0:bt.name}`)}),jsxRuntimeExports.jsx(ChainIcon,{children:(yt=bt.logo)!==null&&yt!==void 0?yt:jsxRuntimeExports.jsx(Chains.UnknownChain,{})})]}),bt.name]}),et!=="secondary"&&jsxRuntimeExports.jsx(ChainButtonStatus,{children:jsxRuntimeExports.jsxs(AnimatePresence,{initial:!1,exitBeforeEnter:!0,children:[bt.id===(tt==null?void 0:tt.id)&&jsxRuntimeExports.jsx(motion.span,{style:{color:"var(--ck-dropdown-active-color, var(--ck-focus-color))",display:"block",position:"relative"},initial:{opacity:0,x:-4},animate:{opacity:1,x:0},exit:{opacity:0,x:4,transition:{duration:.1,delay:0}},transition:{ease:[.76,0,.24,1],duration:.3,delay:.2},children:ct.connected},"connectedText"),nt&&st===bt.id&&jsxRuntimeExports.jsx(motion.span,{style:{color:"var(--ck-dropdown-pending-color, inherit)",display:"block",position:"relative"},initial:{opacity:0,x:-4},animate:{opacity:1,x:0},exit:{opacity:0,x:4},transition:{ease:[.76,0,.24,1],duration:.3,delay:.1},children:jsxRuntimeExports.jsx(motion.span,{animate:lt&&isCoinbaseWalletConnector(o==null?void 0:o.id)&&{opacity:[1,0],transition:{delay:4,duration:4}},children:ct.approveInWallet})},"approveText")]})}),et==="secondary"?jsxRuntimeExports.jsx(ChainButtonBg,{initial:!1,animate:{opacity:bt.id===(tt==null?void 0:tt.id)?1:0},transition:{duration:.3,ease:"easeOut"}}):bt.id===(tt==null?void 0:tt.id)&&jsxRuntimeExports.jsx(ChainButtonBg,{layoutId:"activeChain",layout:"position",transition:{duration:.3,ease:"easeOut"}})]},`${bt==null?void 0:bt.id}-${bt==null?void 0:bt.name}`)})})}),jsxRuntimeExports.jsx(AnimatePresence,{children:dt&&jsxRuntimeExports.jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{ease:[.76,0,.24,1],duration:.3},onAnimationStart:ft,onAnimationComplete:ft,children:jsxRuntimeExports.jsx("div",{style:{paddingTop:10,paddingBottom:8},children:jsxRuntimeExports.jsxs(Alert,{children:[ct.warnings_walletSwitchingUnsupported," ",ct.warnings_walletSwitchingUnsupportedResolve]})})})})]})},DropdownWindow=styled(motion.div)` z-index: 2147483647; position: fixed; inset: 0; @@ -3218,7 +3218,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C font-weight: 400; user-select: none; color: var(--ck-dropdown-color, var(--ck-tooltip-color)); -`,ChainSelectDropdown=({children:et,open:o,onClose:tt,offsetX:rt=0,offsetY:nt=8})=>{var ot,it,st;const at=useContext(),ct=useThemeContext(),lt=useLocales(),[dt,ht]=reactExports.useState({x:0,y:0});useLockBodyScroll(o);const mt=reactExports.useRef(null);reactExports.useEffect(()=>{const Ct=St=>{var At,kt,It;if(o&&(St.key==="Escape"&&tt(),St.key==="ArrowDown"||St.key==="ArrowUp")){if(!mt.current)return;St.preventDefault();const Ot=(At=mt.current)===null||At===void 0?void 0:At.querySelectorAll(` +`,ChainSelectDropdown=({children:et,open:o,onClose:tt,offsetX:rt=0,offsetY:nt=8})=>{var ot,it,st;const at=useContext(),ct=useThemeContext(),lt=useLocales(),[dt,ht]=reactExports.useState({x:0,y:0});useLockBodyScroll(o);const mt=reactExports.useRef(null);reactExports.useEffect(()=>{const Ct=St=>{var At,kt,It;if(o&&(St.key==="Escape"&&tt(),St.key==="ArrowDown"||St.key==="ArrowUp")){if(!mt.current)return;St.preventDefault();const Nt=(At=mt.current)===null||At===void 0?void 0:At.querySelectorAll(` a[href]:not(:disabled), button:not(:disabled), textarea:not(:disabled), @@ -3226,7 +3226,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C input[type="radio"]:not(:disabled), input[type="checkbox"]:not(:disabled), select:not(:disabled) - `),Nt=Ot[0],Yt=Ot[Ot.length-1];if(St.key==="ArrowUp")if(document.activeElement===Nt)Yt.focus();else{let Ft=(kt=document==null?void 0:document.activeElement)===null||kt===void 0?void 0:kt.previousSibling;for(Ft||(Ft=Yt);Ft.disabled;)Ft=Ft.previousSibling;Ft.focus()}else if(document.activeElement===Yt)Nt.focus();else{let Ft=(It=document==null?void 0:document.activeElement)===null||It===void 0?void 0:It.nextSibling;for(Ft||(Ft=Nt);Ft.disabled;)Ft=Ft.nextSibling;Ft.focus()}}};return document.addEventListener("keydown",Ct),()=>{document.removeEventListener("keydown",Ct)}},[o]);const ft=reactExports.useRef(null),pt=reactExports.useCallback(Ct=>{Ct&&(ft.current=Ct,bt())},[o]),[gt,yt]=useMeasure({debounce:120,offsetSize:!0,scroll:!0}),bt=()=>{if(!ft.current||yt.top+yt.bottom+yt.left+yt.right+yt.height+yt.width===0)return;let Ct=yt.left+rt,St=yt.top+yt.height+nt;ft.current.style.left=`${Ct}px`,ft.current.style.top=`${St}px`};(typeof window<"u"?reactExports.useLayoutEffect:reactExports.useEffect)(bt,[ft.current,yt,o]),reactExports.useEffect(bt,[o,ft.current]);const vt=tt,Et=tt;return reactExports.useEffect(()=>(bt(),window.addEventListener("scroll",vt),window.addEventListener("resize",Et),()=>{window.removeEventListener("scroll",vt),window.removeEventListener("resize",Et)}),[]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{ref:gt,children:et}),jsxRuntimeExports.jsx(AnimatePresence,{children:o&&jsxRuntimeExports.jsx(Portal$2,{children:jsxRuntimeExports.jsx(ResetContainer,{$useTheme:(ot=ct.theme)!==null&&ot!==void 0?ot:at.theme,$useMode:(it=ct.mode)!==null&&it!==void 0?it:at.mode,$customTheme:(st=ct.customTheme)!==null&&st!==void 0?st:at.customTheme,children:jsxRuntimeExports.jsx(FocusTrap,{children:jsxRuntimeExports.jsxs(DropdownWindow,{ref:mt,children:[jsxRuntimeExports.jsx(DropdownOverlay,{onClick:tt}),jsxRuntimeExports.jsxs(DropdownContainer,{ref:pt,style:{left:dt.x,top:dt.y},initial:"collapsed",animate:"open",exit:"collapsed",variants:{collapsed:{transformOrigin:"0 0",opacity:0,scale:.96,z:.01,y:-4,x:0,transition:{duration:.1}},open:{transformOrigin:"0 0",willChange:"opacity,transform",opacity:1,scale:1,z:.01,y:0,x:0,transition:{ease:[.76,0,.24,1],duration:.15}}},children:[jsxRuntimeExports.jsx(DropdownHeading,{children:lt.switchNetworks}),jsxRuntimeExports.jsx(ChainSelectList,{})]})]})})})})})]})},ChainContainer=styled.div` + `),Lt=Nt[0],Mt=Nt[Nt.length-1];if(St.key==="ArrowUp")if(document.activeElement===Lt)Mt.focus();else{let zt=(kt=document==null?void 0:document.activeElement)===null||kt===void 0?void 0:kt.previousSibling;for(zt||(zt=Mt);zt.disabled;)zt=zt.previousSibling;zt.focus()}else if(document.activeElement===Mt)Lt.focus();else{let zt=(It=document==null?void 0:document.activeElement)===null||It===void 0?void 0:It.nextSibling;for(zt||(zt=Lt);zt.disabled;)zt=zt.nextSibling;zt.focus()}}};return document.addEventListener("keydown",Ct),()=>{document.removeEventListener("keydown",Ct)}},[o]);const ft=reactExports.useRef(null),pt=reactExports.useCallback(Ct=>{Ct&&(ft.current=Ct,bt())},[o]),[yt,gt]=useMeasure({debounce:120,offsetSize:!0,scroll:!0}),bt=()=>{if(!ft.current||gt.top+gt.bottom+gt.left+gt.right+gt.height+gt.width===0)return;let Ct=gt.left+rt,St=gt.top+gt.height+nt;ft.current.style.left=`${Ct}px`,ft.current.style.top=`${St}px`};(typeof window<"u"?reactExports.useLayoutEffect:reactExports.useEffect)(bt,[ft.current,gt,o]),reactExports.useEffect(bt,[o,ft.current]);const vt=tt,Et=tt;return reactExports.useEffect(()=>(bt(),window.addEventListener("scroll",vt),window.addEventListener("resize",Et),()=>{window.removeEventListener("scroll",vt),window.removeEventListener("resize",Et)}),[]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{ref:yt,children:et}),jsxRuntimeExports.jsx(AnimatePresence,{children:o&&jsxRuntimeExports.jsx(Portal$2,{children:jsxRuntimeExports.jsx(ResetContainer,{$useTheme:(ot=ct.theme)!==null&&ot!==void 0?ot:at.theme,$useMode:(it=ct.mode)!==null&&it!==void 0?it:at.mode,$customTheme:(st=ct.customTheme)!==null&&st!==void 0?st:at.customTheme,children:jsxRuntimeExports.jsx(FocusTrap,{children:jsxRuntimeExports.jsxs(DropdownWindow,{ref:mt,children:[jsxRuntimeExports.jsx(DropdownOverlay,{onClick:tt}),jsxRuntimeExports.jsxs(DropdownContainer,{ref:pt,style:{left:dt.x,top:dt.y},initial:"collapsed",animate:"open",exit:"collapsed",variants:{collapsed:{transformOrigin:"0 0",opacity:0,scale:.96,z:.01,y:-4,x:0,transition:{duration:.1}},open:{transformOrigin:"0 0",willChange:"opacity,transform",opacity:1,scale:1,z:.01,y:0,x:0,transition:{ease:[.76,0,.24,1],duration:.15}}},children:[jsxRuntimeExports.jsx(DropdownHeading,{children:lt.switchNetworks}),jsxRuntimeExports.jsx(ChainSelectList,{})]})]})})})})})]})},ChainContainer=styled.div` --bg: transparent; --color: #333; ${et=>typeof et.size=="string"?Ae` @@ -3393,7 +3393,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C } } `} -`,ChevronDown=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"11",height:"6",viewBox:"0 0 11 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{d:"M1.5 1L5.5 5L9.5 1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),ChainSelector=()=>{const et=useContext(),[o,tt]=reactExports.useState(!1),{chain:rt}=useAccount(),{chains:nt}=useSwitchChain(),ot=useLocales({CHAIN:rt==null?void 0:rt.name}),it=isMobile()||(window==null?void 0:window.innerWidth){et.open||tt(!1)},[et.open]);const st=nt.length<=1;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Container$3,{children:jsxRuntimeExports.jsx(ChainSelectDropdown,{offsetX:-12,open:!it&&o,onClose:()=>tt(!1),children:jsxRuntimeExports.jsxs(SwitchChainButton,{"aria-label":flattenChildren(ot.switchNetworks).toString(),disabled:st,onClick:()=>{it?et.setRoute(routes.SWITCHNETWORKS):tt(!o)},children:[st?jsxRuntimeExports.jsx(Tooltip,{message:ot.chainNetwork,xOffset:-6,delay:.01,children:jsxRuntimeExports.jsx(Chain,{id:rt==null?void 0:rt.id})}):jsxRuntimeExports.jsx(Chain,{id:rt==null?void 0:rt.id}),!st&&jsxRuntimeExports.jsx(ChevronDown,{style:{top:1,left:-3}})]})})})})},Profile=({closeModal:et})=>{var o,tt,rt;const nt=useContext(),ot=useThemeContext(),it=useLocales(),{reset:st}=useConnect$1(),{disconnect:at}=useDisconnect(),{address:ct,isConnected:lt,connector:dt,chain:ht}=useAccount(),mt=useEnsFallbackConfig(),{data:ft}=useEnsName({chainId:1,address:ct,config:mt}),{data:pt}=useBalance({address:ct}),[gt,yt]=reactExports.useState(!1);reactExports.useEffect(()=>{lt||nt.setOpen(!1)},[lt]),reactExports.useEffect(()=>{if(gt)return et?et():nt.setOpen(!1),()=>{at(),st()}},[gt,at,st]);const bt=["web95","rounded","minimal"].includes((tt=(o=ot.theme)!==null&&o!==void 0?o:nt.theme)!==null&&tt!==void 0?tt:"")?"....":void 0;return jsxRuntimeExports.jsxs(PageContent,{children:[jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:22,gap:6},children:[jsxRuntimeExports.jsx(AvatarContainer,{children:jsxRuntimeExports.jsxs(AvatarInner,{children:[jsxRuntimeExports.jsx(ChainSelectorContainer,{children:jsxRuntimeExports.jsx(ChainSelector,{})}),jsxRuntimeExports.jsx(Avatar,{address:ct})]})}),jsxRuntimeExports.jsx(ModalH1,{children:jsxRuntimeExports.jsx(CopyToClipboard,{string:ct,children:ft??truncateEthAddress(ct,bt)})}),!((rt=nt==null?void 0:nt.options)===null||rt===void 0)&&rt.hideBalance?null:jsxRuntimeExports.jsx(ModalBody,{children:jsxRuntimeExports.jsx(BalanceContainer,{children:jsxRuntimeExports.jsxs(AnimatePresence,{exitBeforeEnter:!0,initial:!1,children:[pt&&jsxRuntimeExports.jsxs(Balance$1,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[nFormatter(Number(pt==null?void 0:pt.formatted))," ",pt==null?void 0:pt.symbol]},`chain-${ht==null?void 0:ht.id}`),!pt&&jsxRuntimeExports.jsx(LoadingBalance,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:" "})]})})})]}),!isSafeConnector(dt==null?void 0:dt.id)&&jsxRuntimeExports.jsx(Button$1,{onClick:()=>yt(!0),icon:jsxRuntimeExports.jsx(DisconnectIcon,{}),children:it.disconnect})]})},SwitchNetworks=()=>{const{reset:et}=useConnect$1(),{disconnect:o}=useDisconnect(),{connector:tt,chain:rt}=useAccount(),nt=useChainIsSupported(rt==null?void 0:rt.id),ot=useLocales({}),it=()=>{o(),et()};return jsxRuntimeExports.jsx(PageContent,{style:{width:278},children:jsxRuntimeExports.jsxs(ModalContent,{style:{padding:0,marginTop:-10},children:[!nt&&jsxRuntimeExports.jsxs(ModalBody,{children:[ot.warnings_chainUnsupported," ",ot.warnings_chainUnsupportedResolve]}),jsxRuntimeExports.jsx("div",{style:{padding:"6px 8px"},children:jsxRuntimeExports.jsx(ChainSelectList,{variant:"secondary"})}),!nt&&!isSafeConnector(tt==null?void 0:tt.id)&&jsxRuntimeExports.jsxs("div",{style:{paddingTop:12},children:[jsxRuntimeExports.jsx(OrDivider,{}),jsxRuntimeExports.jsx(Button$1,{icon:jsxRuntimeExports.jsx(DisconnectIcon,{}),variant:"secondary",onClick:it,children:ot.disconnect})]})]})})},spinKeyframes=We` +`,ChevronDown=({...et})=>jsxRuntimeExports.jsx("svg",{"aria-hidden":"true",width:"11",height:"6",viewBox:"0 0 11 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",...et,children:jsxRuntimeExports.jsx("path",{d:"M1.5 1L5.5 5L9.5 1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),ChainSelector=()=>{const et=useContext(),[o,tt]=reactExports.useState(!1),{chain:rt}=useAccount(),{chains:nt}=useSwitchChain(),ot=useLocales({CHAIN:rt==null?void 0:rt.name}),it=isMobile()||(window==null?void 0:window.innerWidth){et.open||tt(!1)},[et.open]);const st=nt.length<=1;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Container$3,{children:jsxRuntimeExports.jsx(ChainSelectDropdown,{offsetX:-12,open:!it&&o,onClose:()=>tt(!1),children:jsxRuntimeExports.jsxs(SwitchChainButton,{"aria-label":flattenChildren(ot.switchNetworks).toString(),disabled:st,onClick:()=>{it?et.setRoute(routes.SWITCHNETWORKS):tt(!o)},children:[st?jsxRuntimeExports.jsx(Tooltip,{message:ot.chainNetwork,xOffset:-6,delay:.01,children:jsxRuntimeExports.jsx(Chain,{id:rt==null?void 0:rt.id})}):jsxRuntimeExports.jsx(Chain,{id:rt==null?void 0:rt.id}),!st&&jsxRuntimeExports.jsx(ChevronDown,{style:{top:1,left:-3}})]})})})})},Profile=({closeModal:et})=>{var o,tt,rt;const nt=useContext(),ot=useThemeContext(),it=useLocales(),{reset:st}=useConnect$1(),{disconnect:at}=useDisconnect(),{address:ct,isConnected:lt,connector:dt,chain:ht}=useAccount(),mt=useEnsFallbackConfig(),{data:ft}=useEnsName({chainId:1,address:ct,config:mt}),{data:pt}=useBalance({address:ct}),[yt,gt]=reactExports.useState(!1);reactExports.useEffect(()=>{lt||nt.setOpen(!1)},[lt]),reactExports.useEffect(()=>{if(yt)return et?et():nt.setOpen(!1),()=>{at(),st()}},[yt,at,st]);const bt=["web95","rounded","minimal"].includes((tt=(o=ot.theme)!==null&&o!==void 0?o:nt.theme)!==null&&tt!==void 0?tt:"")?"....":void 0;return jsxRuntimeExports.jsxs(PageContent,{children:[jsxRuntimeExports.jsxs(ModalContent,{style:{paddingBottom:22,gap:6},children:[jsxRuntimeExports.jsx(AvatarContainer,{children:jsxRuntimeExports.jsxs(AvatarInner,{children:[jsxRuntimeExports.jsx(ChainSelectorContainer,{children:jsxRuntimeExports.jsx(ChainSelector,{})}),jsxRuntimeExports.jsx(Avatar,{address:ct})]})}),jsxRuntimeExports.jsx(ModalH1,{children:jsxRuntimeExports.jsx(CopyToClipboard,{string:ct,children:ft??truncateEthAddress(ct,bt)})}),!((rt=nt==null?void 0:nt.options)===null||rt===void 0)&&rt.hideBalance?null:jsxRuntimeExports.jsx(ModalBody,{children:jsxRuntimeExports.jsx(BalanceContainer,{children:jsxRuntimeExports.jsxs(AnimatePresence,{exitBeforeEnter:!0,initial:!1,children:[pt&&jsxRuntimeExports.jsxs(Balance$1,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[nFormatter(Number(pt==null?void 0:pt.formatted))," ",pt==null?void 0:pt.symbol]},`chain-${ht==null?void 0:ht.id}`),!pt&&jsxRuntimeExports.jsx(LoadingBalance,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:" "})]})})})]}),!isSafeConnector(dt==null?void 0:dt.id)&&jsxRuntimeExports.jsx(Button$1,{onClick:()=>gt(!0),icon:jsxRuntimeExports.jsx(DisconnectIcon,{}),children:it.disconnect})]})},SwitchNetworks=()=>{const{reset:et}=useConnect$1(),{disconnect:o}=useDisconnect(),{connector:tt,chain:rt}=useAccount(),nt=useChainIsSupported(rt==null?void 0:rt.id),ot=useLocales({}),it=()=>{o(),et()};return jsxRuntimeExports.jsx(PageContent,{style:{width:278},children:jsxRuntimeExports.jsxs(ModalContent,{style:{padding:0,marginTop:-10},children:[!nt&&jsxRuntimeExports.jsxs(ModalBody,{children:[ot.warnings_chainUnsupported," ",ot.warnings_chainUnsupportedResolve]}),jsxRuntimeExports.jsx("div",{style:{padding:"6px 8px"},children:jsxRuntimeExports.jsx(ChainSelectList,{variant:"secondary"})}),!nt&&!isSafeConnector(tt==null?void 0:tt.id)&&jsxRuntimeExports.jsxs("div",{style:{paddingTop:12},children:[jsxRuntimeExports.jsx(OrDivider,{}),jsxRuntimeExports.jsx(Button$1,{icon:jsxRuntimeExports.jsx(DisconnectIcon,{}),variant:"secondary",onClick:it,children:ot.disconnect})]})]})})},spinKeyframes=We` from{ transform: rotate(0deg); } to{ transform: rotate(360deg); } `,lineKeyframes=We` @@ -3591,7 +3591,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C } } `}; -`,SIWEButton=({showSignOutButton:et,onSignIn:o,onSignOut:tt})=>{const rt=useIsMounted(),nt=useLocales(),{setOpen:ot}=useModal(),{isSignedIn:it,isReady:st,isLoading:at,isRejected:ct,isSuccess:lt,isError:dt,signIn:ht,signOut:mt,error:ft}=useSIWE({onSignIn:yt=>o==null?void 0:o(yt),onSignOut:()=>tt==null?void 0:tt()}),{address:pt}=useAccount();function gt(){return lt?nt.signedIn:ct?nt.tryAgain:at?nt.awaitingConfirmation:dt?ft??"Unknown Error":nt.signIn}return rt?et&&it?jsxRuntimeExports.jsx(Button$1,{style:{margin:0},onClick:mt,icon:jsxRuntimeExports.jsx(DisconnectIcon,{}),children:nt.signOut},"button"):pt?jsxRuntimeExports.jsx(Button$1,{style:{margin:0},arrow:it?!1:!at&&!ct,onClick:!at&&!lt?ht:void 0,disabled:at,waiting:at,icon:ct&&jsxRuntimeExports.jsx(motion.div,{initial:{rotate:-270},animate:{rotate:0},transition:{duration:1,ease:[.175,.885,.32,.98]},children:jsxRuntimeExports.jsx(RetryIcon,{style:{opacity:.4}})}),children:gt()},"button"):jsxRuntimeExports.jsx(Button$1,{style:{margin:0},onClick:()=>ot(!0),arrow:!0,children:nt.walletNotConnected},"button"):jsxRuntimeExports.jsx(Button$1,{style:{margin:0},disabled:!0},"loading")},LazyImage=({src:et,alt:o,width:tt,height:rt})=>{const nt=reactExports.useRef(null),[ot,it]=reactExports.useState(!0);return reactExports.useEffect(()=>{nt.current&&nt.current.complete&&nt.current.naturalHeight!==0||it(!1)},[et]),jsxRuntimeExports.jsx("div",{style:{width:tt,height:rt,background:"rgba(0,0,0,0.02)",boxShadow:"inset 0 0 0 1px rgba(0,0,0,0.02)"},children:jsxRuntimeExports.jsx("img",{ref:nt,src:et,alt:o,width:tt,height:rt,onLoad:()=>it(!0),style:{transition:"opacity 0.2s ease",opacity:ot?1:0}})})},transition={duration:.2,ease:[.26,.08,.25,1]},copyTransition={duration:.16,ease:[.26,.08,.25,1]},SignInWithEthereum=()=>{var et,o;const tt=useContext(),{isSignedIn:rt,reset:nt}=useSIWE(),ot=isMobile(),[it,st]=reactExports.useState(rt?"signedIn":"signedOut"),at=useLocales({}),ct=it==="signedIn"?{heading:at.signInWithEthereumScreen_signedIn_heading,h1:at.signInWithEthereumScreen_signedIn_h1,p:at.signInWithEthereumScreen_signedIn_p,button:at.signInWithEthereumScreen_signedIn_button}:{heading:at.signInWithEthereumScreen_signedOut_heading,h1:at.signInWithEthereumScreen_signedOut_h1,p:at.signInWithEthereumScreen_signedOut_p,button:at.signInWithEthereumScreen_signedOut_button};reactExports.useEffect(()=>{rt&&st("signedIn")},[]),reactExports.useEffect(()=>{rt||st("signedOut")},[rt]);const{address:lt}=useAccount(),ht=(()=>{const ft={svg:null,default:null},pt=document.getElementsByTagName("link");return Array.from(pt).forEach(gt=>{(gt.getAttribute("rel")==="icon"||gt.getAttribute("rel")==="shortcut icon")&>.getAttribute("href")&&(gt.getAttribute("type")==="image/svg+xml"?ft.svg=gt.getAttribute("href"):ft.default=gt.getAttribute("href"))}),ft})(),mt=(o=(et=getAppIcon())!==null&&et!==void 0?et:ht.svg)!==null&&o!==void 0?o:ht.default;return jsxRuntimeExports.jsx(PageContent,{style:{width:278},children:jsxRuntimeExports.jsxs(ModalContent,{style:{padding:0,marginTop:-10},children:[jsxRuntimeExports.jsx(ContentContainer,{children:jsxRuntimeExports.jsx(AnimatePresence,{exitBeforeEnter:!0,children:jsxRuntimeExports.jsx(motion.div,{initial:ot?!1:{opacity:0,scale:.94},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.94},transition:copyTransition,children:jsxRuntimeExports.jsx(ModalBody,{style:{height:42},children:jsxRuntimeExports.jsx(FitText,{children:ct.h1})})},flattenChildren(ct.h1).toString())})}),jsxRuntimeExports.jsxs(StatusGraphic,{$connected:rt,children:[jsxRuntimeExports.jsx("div",{style:{position:"absolute",inset:0},children:jsxRuntimeExports.jsx(StatusGraphicBgSvg,{width:"262",height:"134",viewBox:"0 0 262 134",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx(motion.rect,{x:"0",y:"0",rx:"12",width:"262",height:"134",strokeDasharray:"3 3",animate:{strokeDashoffset:[0,-6]},transition:{duration:.4,ease:"linear",repeat:1/0}})})}),jsxRuntimeExports.jsx(motion.div,{initial:ot?!1:{opacity:0,x:50,scale:.8},animate:{opacity:1,x:0,scale:1},transition,children:jsxRuntimeExports.jsx(LogoContainer,{children:jsxRuntimeExports.jsx(Avatar,{address:lt,size:64})})},"avatarImage"),jsxRuntimeExports.jsx(motion.div,{initial:ot?!1:{scale:.6},animate:{scale:1},transition:{...transition},children:jsxRuntimeExports.jsx(StatusIcon,{children:jsxRuntimeExports.jsx(TickIcon,{})})},"tickIcon"),jsxRuntimeExports.jsx(motion.div,{initial:ot?!1:{opacity:0,x:-40,scale:.8},animate:{opacity:1,x:0,scale:1},transition:{...transition},children:jsxRuntimeExports.jsx(LogoContainer,{children:mt?jsxRuntimeExports.jsx(LazyImage,{src:mt,alt:"app"}):jsxRuntimeExports.jsx(Chains.UnknownChain,{})})},"appLogo")]},"status"),jsxRuntimeExports.jsx(AnimatePresence,{exitBeforeEnter:!0,children:jsxRuntimeExports.jsx(motion.div,{style:{paddingBottom:ot?24:12},initial:ot?!1:{opacity:0,scale:.94},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.94},transition:copyTransition,children:jsxRuntimeExports.jsx(ModalBody,{style:{height:42,marginTop:-1,marginBottom:-3},children:jsxRuntimeExports.jsx(FitText,{children:ct.p})})},flattenChildren(ct.p).toString())}),jsxRuntimeExports.jsx(SIWEButton,{showSignOutButton:it==="signedIn",onSignIn:()=>{setTimeout(()=>{tt.setOpen(!1)},1e3)}})]})})},customThemeDefault$1={},ConnectModal$1=({mode:et="auto",theme:o="auto",customTheme:tt=customThemeDefault$1,lang:rt="en-US"})=>{var nt;const ot=useContext(),{isConnected:it,chain:st}=useAccount(),at=useChainIsSupported(st==null?void 0:st.id),ct=!(!((nt=ot.options)===null||nt===void 0)&&nt.enforceSupportedChains&&it&&!at),lt=ct&&ot.route!==routes.CONNECTORS&&ot.route!==routes.PROFILE,dt=ct&&ot.route!==routes.PROFILE,ht=()=>{ot.route===routes.SIGNINWITHETHEREUM||ot.route===routes.SWITCHNETWORKS?ot.setRoute(routes.PROFILE):ot.route===routes.DOWNLOAD?ot.setRoute(routes.CONNECT):ot.setRoute(routes.CONNECTORS)},mt={onboarding:jsxRuntimeExports.jsx(Introduction,{}),about:jsxRuntimeExports.jsx(About,{}),download:jsxRuntimeExports.jsx(DownloadApp,{}),connectors:jsxRuntimeExports.jsx(Wallets,{}),mobileConnectors:jsxRuntimeExports.jsx(MobileConnectors,{}),connect:jsxRuntimeExports.jsx(ConnectUsing,{}),profile:jsxRuntimeExports.jsx(Profile,{}),switchNetworks:jsxRuntimeExports.jsx(SwitchNetworks,{}),signInWithEthereum:jsxRuntimeExports.jsx(SignInWithEthereum,{})};function ft(){ot.setOpen(!1)}return reactExports.useEffect(()=>{var pt;it?(ot.route!==routes.PROFILE||ot.route!==routes.SIGNINWITHETHEREUM)&&(ot.signInWithEthereum&&!(!((pt=ot.options)===null||pt===void 0)&&pt.disableSiweRedirect)?ot.setRoute(routes.SIGNINWITHETHEREUM):ft()):ft()},[it]),reactExports.useEffect(()=>ot.setMode(et),[et]),reactExports.useEffect(()=>ot.setTheme(o),[o]),reactExports.useEffect(()=>ot.setCustomTheme(tt),[tt]),reactExports.useEffect(()=>ot.setLang(rt),[rt]),reactExports.useEffect(()=>{const pt=getAppName();if(!pt||!ot.open)return;const gt=document.createElement("meta");return gt.setAttribute("property","og:title"),gt.setAttribute("content",pt),document.head.prepend(gt),()=>{document.head.removeChild(gt)}},[ot.open]),jsxRuntimeExports.jsx(ConnectKitThemeProvider,{theme:o,customTheme:tt,mode:et,children:jsxRuntimeExports.jsx(Modal,{open:ot.open,pages:mt,pageId:ot.route,onClose:ct?ft:void 0,onInfo:dt?()=>ot.setRoute(routes.ABOUT):void 0,onBack:lt?ht:void 0})})};function useGoogleFont(et){reactExports.useEffect(()=>{if(!et)return;et=et.replace(/ /g,"+");const o=document.createElement("link");o.href="https://fonts.googleapis.com",o.rel="preconnect";const tt=document.createElement("link");tt.href="https://fonts.gstatic.com",tt.rel="preconnect",tt.crossOrigin="true";const rt=document.createElement("link");return rt.href=`https://fonts.googleapis.com/css2?family=${et}:wght@400;500;600&display=swap`,rt.rel="stylesheet",document.head.appendChild(o),document.head.appendChild(tt),document.head.appendChild(rt),()=>{document.head.removeChild(o),document.head.removeChild(tt),document.head.removeChild(rt)}},[et])}function useThemeFont(et){var o;const rt=(o={web95:"Lato",retro:"Nunito",midnight:"Inter",minimal:"Inter",rounded:"Nunito"}[et])!==null&&o!==void 0?o:null;useGoogleFont(rt??"")}const useConnectCallback=({onConnect:et,onDisconnect:o})=>{useAccountEffect({onConnect:({address:tt,connector:rt,isReconnected:nt})=>{nt||et==null||et({address:tt,connectorId:rt==null?void 0:rt.id})},onDisconnect:()=>o==null?void 0:o()})},routes={ONBOARDING:"onboarding",ABOUT:"about",CONNECTORS:"connectors",MOBILECONNECTORS:"mobileConnectors",CONNECT:"connect",DOWNLOAD:"download",PROFILE:"profile",SWITCHNETWORKS:"switchNetworks",SIGNINWITHETHEREUM:"signInWithEthereum"},Context=reactExports.createContext(null),ConnectKitProvider=({children:et,theme:o="auto",mode:tt="auto",customTheme:rt,options:nt,onConnect:ot,onDisconnect:it,debugMode:st=!1})=>{var at,ct,lt,dt;if(!React.useContext(WagmiContext))throw Error("ConnectKitProvider must be within a WagmiProvider");if(React.useContext(Context))throw new Error("Multiple, nested usages of ConnectKitProvider detected. Please use only one.");useConnectCallback({onConnect:ot,onDisconnect:it});const ht=useChains(),mt=useConnector("injected"),ft={language:"en-US",hideBalance:!1,hideTooltips:!1,hideQuestionMarkCTA:!1,hideNoWalletCTA:!1,walletConnectCTA:"link",hideRecentBadge:!1,avoidLayoutShift:!0,embedGoogleFonts:!1,truncateLongENSAddress:!0,walletConnectName:void 0,reducedMotion:!1,disclaimer:null,bufferPolyfill:!0,customAvatar:void 0,initialChainId:(at=ht==null?void 0:ht[0])===null||at===void 0?void 0:at.id,enforceSupportedChains:!1,ethereumOnboardingUrl:void 0,walletOnboardingUrl:void 0,disableSiweRedirect:!1},pt=Object.assign({},ft,nt);typeof window<"u"&&pt.bufferPolyfill&&(window.Buffer=(ct=window.Buffer)!==null&&ct!==void 0?ct:buffer.Buffer);const[gt,yt]=reactExports.useState(o),[bt,xt]=reactExports.useState(tt),[vt,Et]=reactExports.useState(rt??{}),[Ct,St]=reactExports.useState("en-US"),[At,kt]=reactExports.useState(!1),[It,Ot]=reactExports.useState({id:""}),[Nt,Yt]=reactExports.useState(routes.CONNECTORS),[Ft,Ht]=reactExports.useState(""),[Qt,Vt]=reactExports.useState(0);pt.embedGoogleFonts&&useThemeFont(o),reactExports.useEffect(()=>yt(o),[o]),reactExports.useEffect(()=>St(pt.language||"en-US"),[pt.language]),reactExports.useEffect(()=>Ht(null),[Nt,At]);const{chain:Bt,isConnected:Wt}=useAccount(),jt=useChainIsSupported(Bt==null?void 0:Bt.id);reactExports.useEffect(()=>{Wt&&pt.enforceSupportedChains&&!jt&&(kt(!0),Yt(routes.SWITCHNETWORKS))},[Wt,jt,Bt,Nt,At]),reactExports.useEffect(()=>{isFamily()&&(mt==null||mt.connect())},[mt]);const Xt=st?console.log:()=>{},Kt={theme:gt,setTheme:yt,mode:bt,setMode:xt,customTheme:rt,setCustomTheme:Et,lang:Ct,setLang:St,open:At,setOpen:kt,route:Nt,setRoute:Yt,connector:It,setConnector:Ot,signInWithEthereum:(dt=(lt=React.useContext(SIWEContext))===null||lt===void 0?void 0:lt.enabled)!==null&&dt!==void 0?dt:!1,onConnect:ot,options:pt,errorMessage:Ft,debugMode:st,log:Xt,displayError:(Pt,Gt)=>{Ht(Pt),console.log("---------CONNECTKIT DEBUG---------"),console.log(Pt),Gt&&console.table(Gt),console.log("---------/CONNECTKIT DEBUG---------")},resize:Qt,triggerResize:()=>Vt(Pt=>Pt+1)};return reactExports.createElement(Context.Provider,{value:Kt},jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Web3ContextProvider,{enabled:At,children:jsxRuntimeExports.jsxs(Le,{theme:defaultTheme$1,children:[et,jsxRuntimeExports.jsx(ConnectModal$1,{lang:Ct,theme:gt,mode:tt,customTheme:vt})]})})}))},useContext=()=>{const et=React.useContext(Context);if(!et)throw Error("ConnectKit Hook must be inside a Provider.");return et},safeRoutes={disconnected:[routes.CONNECTORS,routes.ABOUT,routes.ONBOARDING,routes.MOBILECONNECTORS,routes.ONBOARDING],connected:[routes.PROFILE,routes.SWITCHNETWORKS,routes.SIGNINWITHETHEREUM]},allRoutes=[...safeRoutes.connected,...safeRoutes.disconnected],useModal=({onConnect:et,onDisconnect:o}={})=>{const tt=useContext();useConnectCallback({onConnect:et,onDisconnect:o});const{isConnected:rt}=useAccount(),{signIn:nt}=useSIWE(),ot=()=>{tt.setOpen(!1)},it=()=>{tt.setOpen(!0)},st=at=>{let ct=at;allRoutes.includes(at)?rt?safeRoutes.connected.includes(at)||(ct=routes.PROFILE,tt.log(`Route ${at} is not a valid route when connected, navigating to ${ct} instead.`)):safeRoutes.disconnected.includes(at)||(ct=routes.CONNECTORS,tt.log(`Route ${at} is not a valid route when disconnected, navigating to ${ct} instead.`)):(ct=rt?routes.PROFILE:routes.CONNECTORS,tt.log(`Route ${at} is not a valid route, navigating to ${ct} instead.`)),tt.setRoute(ct),it()};return{open:tt.open,setOpen:at=>{at?st(rt?routes.PROFILE:routes.CONNECTORS):ot()},openAbout:()=>st(routes.ABOUT),openOnboarding:()=>st(routes.ONBOARDING),openProfile:()=>st(routes.PROFILE),openSwitchNetworks:()=>st(routes.SWITCHNETWORKS),openSIWE:at=>{st(routes.SIGNINWITHETHEREUM),at&&nt()}}},TextContainer=styled(motion.div)` +`,SIWEButton=({showSignOutButton:et,onSignIn:o,onSignOut:tt})=>{const rt=useIsMounted(),nt=useLocales(),{setOpen:ot}=useModal(),{isSignedIn:it,isReady:st,isLoading:at,isRejected:ct,isSuccess:lt,isError:dt,signIn:ht,signOut:mt,error:ft}=useSIWE({onSignIn:gt=>o==null?void 0:o(gt),onSignOut:()=>tt==null?void 0:tt()}),{address:pt}=useAccount();function yt(){return lt?nt.signedIn:ct?nt.tryAgain:at?nt.awaitingConfirmation:dt?ft??"Unknown Error":nt.signIn}return rt?et&&it?jsxRuntimeExports.jsx(Button$1,{style:{margin:0},onClick:mt,icon:jsxRuntimeExports.jsx(DisconnectIcon,{}),children:nt.signOut},"button"):pt?jsxRuntimeExports.jsx(Button$1,{style:{margin:0},arrow:it?!1:!at&&!ct,onClick:!at&&!lt?ht:void 0,disabled:at,waiting:at,icon:ct&&jsxRuntimeExports.jsx(motion.div,{initial:{rotate:-270},animate:{rotate:0},transition:{duration:1,ease:[.175,.885,.32,.98]},children:jsxRuntimeExports.jsx(RetryIcon,{style:{opacity:.4}})}),children:yt()},"button"):jsxRuntimeExports.jsx(Button$1,{style:{margin:0},onClick:()=>ot(!0),arrow:!0,children:nt.walletNotConnected},"button"):jsxRuntimeExports.jsx(Button$1,{style:{margin:0},disabled:!0},"loading")},LazyImage=({src:et,alt:o,width:tt,height:rt})=>{const nt=reactExports.useRef(null),[ot,it]=reactExports.useState(!0);return reactExports.useEffect(()=>{nt.current&&nt.current.complete&&nt.current.naturalHeight!==0||it(!1)},[et]),jsxRuntimeExports.jsx("div",{style:{width:tt,height:rt,background:"rgba(0,0,0,0.02)",boxShadow:"inset 0 0 0 1px rgba(0,0,0,0.02)"},children:jsxRuntimeExports.jsx("img",{ref:nt,src:et,alt:o,width:tt,height:rt,onLoad:()=>it(!0),style:{transition:"opacity 0.2s ease",opacity:ot?1:0}})})},transition={duration:.2,ease:[.26,.08,.25,1]},copyTransition={duration:.16,ease:[.26,.08,.25,1]},SignInWithEthereum=()=>{var et,o;const tt=useContext(),{isSignedIn:rt,reset:nt}=useSIWE(),ot=isMobile(),[it,st]=reactExports.useState(rt?"signedIn":"signedOut"),at=useLocales({}),ct=it==="signedIn"?{heading:at.signInWithEthereumScreen_signedIn_heading,h1:at.signInWithEthereumScreen_signedIn_h1,p:at.signInWithEthereumScreen_signedIn_p,button:at.signInWithEthereumScreen_signedIn_button}:{heading:at.signInWithEthereumScreen_signedOut_heading,h1:at.signInWithEthereumScreen_signedOut_h1,p:at.signInWithEthereumScreen_signedOut_p,button:at.signInWithEthereumScreen_signedOut_button};reactExports.useEffect(()=>{rt&&st("signedIn")},[]),reactExports.useEffect(()=>{rt||st("signedOut")},[rt]);const{address:lt}=useAccount(),ht=(()=>{const ft={svg:null,default:null},pt=document.getElementsByTagName("link");return Array.from(pt).forEach(yt=>{(yt.getAttribute("rel")==="icon"||yt.getAttribute("rel")==="shortcut icon")&&yt.getAttribute("href")&&(yt.getAttribute("type")==="image/svg+xml"?ft.svg=yt.getAttribute("href"):ft.default=yt.getAttribute("href"))}),ft})(),mt=(o=(et=getAppIcon())!==null&&et!==void 0?et:ht.svg)!==null&&o!==void 0?o:ht.default;return jsxRuntimeExports.jsx(PageContent,{style:{width:278},children:jsxRuntimeExports.jsxs(ModalContent,{style:{padding:0,marginTop:-10},children:[jsxRuntimeExports.jsx(ContentContainer,{children:jsxRuntimeExports.jsx(AnimatePresence,{exitBeforeEnter:!0,children:jsxRuntimeExports.jsx(motion.div,{initial:ot?!1:{opacity:0,scale:.94},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.94},transition:copyTransition,children:jsxRuntimeExports.jsx(ModalBody,{style:{height:42},children:jsxRuntimeExports.jsx(FitText,{children:ct.h1})})},flattenChildren(ct.h1).toString())})}),jsxRuntimeExports.jsxs(StatusGraphic,{$connected:rt,children:[jsxRuntimeExports.jsx("div",{style:{position:"absolute",inset:0},children:jsxRuntimeExports.jsx(StatusGraphicBgSvg,{width:"262",height:"134",viewBox:"0 0 262 134",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx(motion.rect,{x:"0",y:"0",rx:"12",width:"262",height:"134",strokeDasharray:"3 3",animate:{strokeDashoffset:[0,-6]},transition:{duration:.4,ease:"linear",repeat:1/0}})})}),jsxRuntimeExports.jsx(motion.div,{initial:ot?!1:{opacity:0,x:50,scale:.8},animate:{opacity:1,x:0,scale:1},transition,children:jsxRuntimeExports.jsx(LogoContainer,{children:jsxRuntimeExports.jsx(Avatar,{address:lt,size:64})})},"avatarImage"),jsxRuntimeExports.jsx(motion.div,{initial:ot?!1:{scale:.6},animate:{scale:1},transition:{...transition},children:jsxRuntimeExports.jsx(StatusIcon,{children:jsxRuntimeExports.jsx(TickIcon,{})})},"tickIcon"),jsxRuntimeExports.jsx(motion.div,{initial:ot?!1:{opacity:0,x:-40,scale:.8},animate:{opacity:1,x:0,scale:1},transition:{...transition},children:jsxRuntimeExports.jsx(LogoContainer,{children:mt?jsxRuntimeExports.jsx(LazyImage,{src:mt,alt:"app"}):jsxRuntimeExports.jsx(Chains.UnknownChain,{})})},"appLogo")]},"status"),jsxRuntimeExports.jsx(AnimatePresence,{exitBeforeEnter:!0,children:jsxRuntimeExports.jsx(motion.div,{style:{paddingBottom:ot?24:12},initial:ot?!1:{opacity:0,scale:.94},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.94},transition:copyTransition,children:jsxRuntimeExports.jsx(ModalBody,{style:{height:42,marginTop:-1,marginBottom:-3},children:jsxRuntimeExports.jsx(FitText,{children:ct.p})})},flattenChildren(ct.p).toString())}),jsxRuntimeExports.jsx(SIWEButton,{showSignOutButton:it==="signedIn",onSignIn:()=>{setTimeout(()=>{tt.setOpen(!1)},1e3)}})]})})},customThemeDefault$1={},ConnectModal$1=({mode:et="auto",theme:o="auto",customTheme:tt=customThemeDefault$1,lang:rt="en-US"})=>{var nt;const ot=useContext(),{isConnected:it,chain:st}=useAccount(),at=useChainIsSupported(st==null?void 0:st.id),ct=!(!((nt=ot.options)===null||nt===void 0)&&nt.enforceSupportedChains&&it&&!at),lt=ct&&ot.route!==routes.CONNECTORS&&ot.route!==routes.PROFILE,dt=ct&&ot.route!==routes.PROFILE,ht=()=>{ot.route===routes.SIGNINWITHETHEREUM||ot.route===routes.SWITCHNETWORKS?ot.setRoute(routes.PROFILE):ot.route===routes.DOWNLOAD?ot.setRoute(routes.CONNECT):ot.setRoute(routes.CONNECTORS)},mt={onboarding:jsxRuntimeExports.jsx(Introduction,{}),about:jsxRuntimeExports.jsx(About,{}),download:jsxRuntimeExports.jsx(DownloadApp,{}),connectors:jsxRuntimeExports.jsx(Wallets,{}),mobileConnectors:jsxRuntimeExports.jsx(MobileConnectors,{}),connect:jsxRuntimeExports.jsx(ConnectUsing,{}),profile:jsxRuntimeExports.jsx(Profile,{}),switchNetworks:jsxRuntimeExports.jsx(SwitchNetworks,{}),signInWithEthereum:jsxRuntimeExports.jsx(SignInWithEthereum,{})};function ft(){ot.setOpen(!1)}return reactExports.useEffect(()=>{var pt;it?(ot.route!==routes.PROFILE||ot.route!==routes.SIGNINWITHETHEREUM)&&(ot.signInWithEthereum&&!(!((pt=ot.options)===null||pt===void 0)&&pt.disableSiweRedirect)?ot.setRoute(routes.SIGNINWITHETHEREUM):ft()):ft()},[it]),reactExports.useEffect(()=>ot.setMode(et),[et]),reactExports.useEffect(()=>ot.setTheme(o),[o]),reactExports.useEffect(()=>ot.setCustomTheme(tt),[tt]),reactExports.useEffect(()=>ot.setLang(rt),[rt]),reactExports.useEffect(()=>{const pt=getAppName();if(!pt||!ot.open)return;const yt=document.createElement("meta");return yt.setAttribute("property","og:title"),yt.setAttribute("content",pt),document.head.prepend(yt),()=>{document.head.removeChild(yt)}},[ot.open]),jsxRuntimeExports.jsx(ConnectKitThemeProvider,{theme:o,customTheme:tt,mode:et,children:jsxRuntimeExports.jsx(Modal,{open:ot.open,pages:mt,pageId:ot.route,onClose:ct?ft:void 0,onInfo:dt?()=>ot.setRoute(routes.ABOUT):void 0,onBack:lt?ht:void 0})})};function useGoogleFont(et){reactExports.useEffect(()=>{if(!et)return;et=et.replace(/ /g,"+");const o=document.createElement("link");o.href="https://fonts.googleapis.com",o.rel="preconnect";const tt=document.createElement("link");tt.href="https://fonts.gstatic.com",tt.rel="preconnect",tt.crossOrigin="true";const rt=document.createElement("link");return rt.href=`https://fonts.googleapis.com/css2?family=${et}:wght@400;500;600&display=swap`,rt.rel="stylesheet",document.head.appendChild(o),document.head.appendChild(tt),document.head.appendChild(rt),()=>{document.head.removeChild(o),document.head.removeChild(tt),document.head.removeChild(rt)}},[et])}function useThemeFont(et){var o;const rt=(o={web95:"Lato",retro:"Nunito",midnight:"Inter",minimal:"Inter",rounded:"Nunito"}[et])!==null&&o!==void 0?o:null;useGoogleFont(rt??"")}const useConnectCallback=({onConnect:et,onDisconnect:o})=>{useAccountEffect({onConnect:({address:tt,connector:rt,isReconnected:nt})=>{nt||et==null||et({address:tt,connectorId:rt==null?void 0:rt.id})},onDisconnect:()=>o==null?void 0:o()})},routes={ONBOARDING:"onboarding",ABOUT:"about",CONNECTORS:"connectors",MOBILECONNECTORS:"mobileConnectors",CONNECT:"connect",DOWNLOAD:"download",PROFILE:"profile",SWITCHNETWORKS:"switchNetworks",SIGNINWITHETHEREUM:"signInWithEthereum"},Context=reactExports.createContext(null),ConnectKitProvider=({children:et,theme:o="auto",mode:tt="auto",customTheme:rt,options:nt,onConnect:ot,onDisconnect:it,debugMode:st=!1})=>{var at,ct,lt,dt;if(!React.useContext(WagmiContext))throw Error("ConnectKitProvider must be within a WagmiProvider");if(React.useContext(Context))throw new Error("Multiple, nested usages of ConnectKitProvider detected. Please use only one.");useConnectCallback({onConnect:ot,onDisconnect:it});const ht=useChains(),mt=useConnector("injected"),ft={language:"en-US",hideBalance:!1,hideTooltips:!1,hideQuestionMarkCTA:!1,hideNoWalletCTA:!1,walletConnectCTA:"link",hideRecentBadge:!1,avoidLayoutShift:!0,embedGoogleFonts:!1,truncateLongENSAddress:!0,walletConnectName:void 0,reducedMotion:!1,disclaimer:null,bufferPolyfill:!0,customAvatar:void 0,initialChainId:(at=ht==null?void 0:ht[0])===null||at===void 0?void 0:at.id,enforceSupportedChains:!1,ethereumOnboardingUrl:void 0,walletOnboardingUrl:void 0,disableSiweRedirect:!1},pt=Object.assign({},ft,nt);typeof window<"u"&&pt.bufferPolyfill&&(window.Buffer=(ct=window.Buffer)!==null&&ct!==void 0?ct:buffer$2.Buffer);const[yt,gt]=reactExports.useState(o),[bt,xt]=reactExports.useState(tt),[vt,Et]=reactExports.useState(rt??{}),[Ct,St]=reactExports.useState("en-US"),[At,kt]=reactExports.useState(!1),[It,Nt]=reactExports.useState({id:""}),[Lt,Mt]=reactExports.useState(routes.CONNECTORS),[zt,Ut]=reactExports.useState(""),[Xt,Wt]=reactExports.useState(0);pt.embedGoogleFonts&&useThemeFont(o),reactExports.useEffect(()=>gt(o),[o]),reactExports.useEffect(()=>St(pt.language||"en-US"),[pt.language]),reactExports.useEffect(()=>Ut(null),[Lt,At]);const{chain:Ft,isConnected:qt}=useAccount(),Pt=useChainIsSupported(Ft==null?void 0:Ft.id);reactExports.useEffect(()=>{qt&&pt.enforceSupportedChains&&!Pt&&(kt(!0),Mt(routes.SWITCHNETWORKS))},[qt,Pt,Ft,Lt,At]),reactExports.useEffect(()=>{isFamily()&&(mt==null||mt.connect())},[mt]);const Yt=st?console.log:()=>{},Qt={theme:yt,setTheme:gt,mode:bt,setMode:xt,customTheme:rt,setCustomTheme:Et,lang:Ct,setLang:St,open:At,setOpen:kt,route:Lt,setRoute:Mt,connector:It,setConnector:Nt,signInWithEthereum:(dt=(lt=React.useContext(SIWEContext))===null||lt===void 0?void 0:lt.enabled)!==null&&dt!==void 0?dt:!1,onConnect:ot,options:pt,errorMessage:zt,debugMode:st,log:Yt,displayError:(jt,Gt)=>{Ut(jt),console.log("---------CONNECTKIT DEBUG---------"),console.log(jt),Gt&&console.table(Gt),console.log("---------/CONNECTKIT DEBUG---------")},resize:Xt,triggerResize:()=>Wt(jt=>jt+1)};return reactExports.createElement(Context.Provider,{value:Qt},jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Web3ContextProvider,{enabled:At,children:jsxRuntimeExports.jsxs(Le,{theme:defaultTheme$1,children:[et,jsxRuntimeExports.jsx(ConnectModal$1,{lang:Ct,theme:yt,mode:tt,customTheme:vt})]})})}))},useContext=()=>{const et=React.useContext(Context);if(!et)throw Error("ConnectKit Hook must be inside a Provider.");return et},safeRoutes={disconnected:[routes.CONNECTORS,routes.ABOUT,routes.ONBOARDING,routes.MOBILECONNECTORS,routes.ONBOARDING],connected:[routes.PROFILE,routes.SWITCHNETWORKS,routes.SIGNINWITHETHEREUM]},allRoutes=[...safeRoutes.connected,...safeRoutes.disconnected],useModal=({onConnect:et,onDisconnect:o}={})=>{const tt=useContext();useConnectCallback({onConnect:et,onDisconnect:o});const{isConnected:rt}=useAccount(),{signIn:nt}=useSIWE(),ot=()=>{tt.setOpen(!1)},it=()=>{tt.setOpen(!0)},st=at=>{let ct=at;allRoutes.includes(at)?rt?safeRoutes.connected.includes(at)||(ct=routes.PROFILE,tt.log(`Route ${at} is not a valid route when connected, navigating to ${ct} instead.`)):safeRoutes.disconnected.includes(at)||(ct=routes.CONNECTORS,tt.log(`Route ${at} is not a valid route when disconnected, navigating to ${ct} instead.`)):(ct=rt?routes.PROFILE:routes.CONNECTORS,tt.log(`Route ${at} is not a valid route, navigating to ${ct} instead.`)),tt.setRoute(ct),it()};return{open:tt.open,setOpen:at=>{at?st(rt?routes.PROFILE:routes.CONNECTORS):ot()},openAbout:()=>st(routes.ABOUT),openOnboarding:()=>st(routes.ONBOARDING),openProfile:()=>st(routes.PROFILE),openSwitchNetworks:()=>st(routes.SWITCHNETWORKS),openSIWE:at=>{st(routes.SIGNINWITHETHEREUM),at&&nt()}}},TextContainer=styled(motion.div)` top: 0; bottom: 0; left: 0; @@ -3797,7 +3797,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C background: currentColor; animation: ${PlaceholderKeyframes} 1000ms ease infinite both; } -`,Balance=({hideIcon:et,hideSymbol:o})=>{const tt=useIsMounted(),[rt,nt]=reactExports.useState(!0),{address:ot,chain:it}=useAccount();useChains();const st=useChainIsSupported(it==null?void 0:it.id),at=useQueryClient(),{data:ct}=useBlockNumber({watch:!0}),{data:lt,queryKey:dt}=useBalance({address:ot,chainId:it==null?void 0:it.id});reactExports.useEffect(()=>{(ct??0%5===0)&&at.invalidateQueries({queryKey:dt})},[ct,dt]);const ht=chainConfigs.find(ft=>ft.id===(it==null?void 0:it.id)),mt=`${!tt||(lt==null?void 0:lt.formatted)===void 0?"balance-loading":`balance-${ht==null?void 0:ht.id}-${lt==null?void 0:lt.formatted}`}`;return reactExports.useEffect(()=>{nt(!1)},[]),jsxRuntimeExports.jsx("div",{style:{position:"relative"},children:jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:jsxRuntimeExports.jsx(motion.div,{initial:(lt==null?void 0:lt.formatted)!==void 0&&rt?{opacity:1}:{opacity:0,position:"absolute",top:0,left:0,bottom:0},animate:{opacity:1,position:"relative"},exit:{opacity:0,position:"absolute",top:0,left:0,bottom:0},transition:{duration:.4,ease:[.25,1,.5,1],delay:.4},children:!ot||!tt||(lt==null?void 0:lt.formatted)===void 0?jsxRuntimeExports.jsxs(Container$1,{children:[!et&&jsxRuntimeExports.jsx(Chain,{id:it==null?void 0:it.id}),jsxRuntimeExports.jsx("span",{style:{minWidth:32},children:jsxRuntimeExports.jsxs(PulseContainer,{children:[jsxRuntimeExports.jsx("span",{style:{animationDelay:"0ms"}}),jsxRuntimeExports.jsx("span",{style:{animationDelay:"50ms"}}),jsxRuntimeExports.jsx("span",{style:{animationDelay:"100ms"}})]})})]}):st?jsxRuntimeExports.jsxs(Container$1,{children:[!et&&jsxRuntimeExports.jsx(Chain,{id:it==null?void 0:it.id}),jsxRuntimeExports.jsx("span",{style:{minWidth:32},children:nFormatter(Number(lt==null?void 0:lt.formatted))}),!o&&` ${lt==null?void 0:lt.symbol}`]}):jsxRuntimeExports.jsxs(Container$1,{children:[!et&&jsxRuntimeExports.jsx(Chain,{id:it==null?void 0:it.id}),jsxRuntimeExports.jsx("span",{style:{minWidth:32},children:"???"})]})},mt)})})},contentVariants={initial:{zIndex:2,opacity:0,x:"-100%"},animate:{opacity:1,x:.1,transition:{duration:.4,ease:[.25,1,.5,1]}},exit:{zIndex:1,opacity:0,x:"-100%",pointerEvents:"none",position:"absolute",transition:{duration:.4,ease:[.25,1,.5,1]}}},addressVariants={initial:{zIndex:2,opacity:0,x:"100%"},animate:{x:.2,opacity:1,transition:{duration:.4,ease:[.25,1,.5,1]}},exit:{zIndex:1,x:"100%",opacity:0,pointerEvents:"none",position:"absolute",transition:{duration:.4,ease:[.25,1,.5,1]}}},textVariants={initial:{opacity:0},animate:{opacity:1,transition:{duration:.3,ease:[.25,1,.5,1]}},exit:{position:"absolute",opacity:0,transition:{duration:.3,ease:[.25,1,.5,1]}}},ConnectButtonRenderer=({children:et})=>{const o=useIsMounted(),tt=useContext(),{open:rt,setOpen:nt}=useModal(),{address:ot,isConnected:it,chain:st}=useAccount(),at=useChainIsSupported(st==null?void 0:st.id),ct=useEnsFallbackConfig(),{data:lt}=useEnsName({chainId:1,address:ot,config:ct});function dt(){nt(!1)}function ht(){nt(!0),tt.setRoute(it?routes.PROFILE:routes.CONNECTORS)}return!et||!o?null:jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:et({show:ht,hide:dt,chain:st,unsupported:!at,isConnected:!!ot,isConnecting:rt,address:ot,truncatedAddress:ot?truncateEthAddress(ot):void 0,ensName:lt==null?void 0:lt.toString()})})};ConnectButtonRenderer.displayName="ConnectKitButton.Custom";function ConnectKitButtonInner({label:et,showAvatar:o,separator:tt}){var rt;const nt=useLocales({}),ot=useContext(),{isSignedIn:it}=useSIWE(),{address:st,chain:at}=useAccount(),ct=useChainIsSupported(at==null?void 0:at.id),lt=useEnsFallbackConfig(),{data:dt}=useEnsName({chainId:1,address:st,config:lt}),ht=nt.connectWallet;return jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:st?jsxRuntimeExports.jsxs(TextContainer,{initial:"initial",animate:"animate",exit:"exit",variants:addressVariants,style:{height:40},children:[o&&jsxRuntimeExports.jsxs(IconContainer,{children:[jsxRuntimeExports.jsxs(AnimatePresence,{initial:!1,children:[it&&jsxRuntimeExports.jsx(motion.div,{style:{zIndex:2,position:"absolute",bottom:0,right:0},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsxRuntimeExports.jsx(AuthIcon,{})}),!ct&&jsxRuntimeExports.jsx(UnsupportedNetworkContainer,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsxRuntimeExports.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx("path",{d:"M1.68831 13.5H12.0764C13.1026 13.5 13.7647 12.7197 13.7647 11.763C13.7647 11.4781 13.6985 11.1863 13.5462 10.9149L8.34225 1.37526C8.02445 0.791754 7.45505 0.5 6.88566 0.5C6.31627 0.5 5.73364 0.791754 5.42246 1.37526L0.225108 10.9217C0.0728291 11.1863 0 11.4781 0 11.763C0 12.7197 0.662083 13.5 1.68831 13.5ZM6.88566 8.8048C6.49503 8.8048 6.27655 8.5809 6.26331 8.1738L6.16399 5.0595C6.15075 4.64562 6.44869 4.34708 6.87904 4.34708C7.30278 4.34708 7.61396 4.6524 7.60071 5.06628L7.5014 8.16701C7.48154 8.5809 7.26305 8.8048 6.88566 8.8048ZM6.88566 11.3492C6.44207 11.3492 6.07792 11.0303 6.07792 10.5757C6.07792 10.1211 6.44207 9.80219 6.88566 9.80219C7.32926 9.80219 7.69341 10.1143 7.69341 10.5757C7.69341 11.0371 7.32264 11.3492 6.88566 11.3492Z",fill:"currentColor"})})})]}),jsxRuntimeExports.jsx(Avatar,{size:24,address:st})]}),jsxRuntimeExports.jsx("div",{style:{position:"relative",paddingRight:o?1:0},children:jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:dt?jsxRuntimeExports.jsx(TextContainer,{initial:"initial",animate:"animate",exit:"exit",variants:textVariants,style:{position:dt?"relative":"absolute"},children:!((rt=ot.options)===null||rt===void 0)&&rt.truncateLongENSAddress?truncateENSAddress(dt,20):dt},"ckEnsName"):jsxRuntimeExports.jsxs(TextContainer,{initial:"initial",animate:"animate",exit:"exit",variants:textVariants,style:{position:dt?"absolute":"relative"},children:[truncateEthAddress(st,tt)," "]},"ckTruncatedAddress")})})]},"connectedText"):jsxRuntimeExports.jsx(TextContainer,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants,style:{height:40},children:et||ht},"connectWalletText")})}function ConnectKitButton({label:et,showBalance:o=!1,showAvatar:tt=!0,theme:rt,mode:nt,customTheme:ot,onClick:it}){var st;const at=useIsMounted(),ct=useContext(),{isConnected:lt,address:dt,chain:ht}=useAccount(),mt=useChainIsSupported(ht==null?void 0:ht.id);function ft(){ct.setOpen(!0),ct.setRoute(lt?routes.PROFILE:routes.CONNECTORS)}const pt=["web95","rounded","minimal"].includes((st=rt??ct.theme)!==null&&st!==void 0?st:"")?"....":void 0;if(!at)return null;const gt=o&&mt,yt=dt&>return jsxRuntimeExports.jsx(ResetContainer,{$useTheme:rt??ct.theme,$useMode:nt??ct.mode,$customTheme:ot??ct.customTheme,children:jsxRuntimeExports.jsxs(ThemeContainer,{onClick:()=>{it?it(ft):ft()},children:[gt&&jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:yt&&jsxRuntimeExports.jsx(motion.div,{initial:{opacity:0,x:"100%",width:0,marginRight:0},animate:{opacity:1,x:0,width:"auto",marginRight:-24,transition:{duration:.4,ease:[.25,1,.5,1]}},exit:{opacity:0,x:"100%",width:0,marginRight:0,transition:{duration:.4,ease:[.25,1,.5,1]}},children:jsxRuntimeExports.jsx(ThemedButton,{variant:"secondary",theme:rt??ct.theme,mode:nt??ct.mode,customTheme:ot??ct.customTheme,style:{overflow:"hidden"},children:jsxRuntimeExports.jsx(motion.div,{style:{paddingRight:24},children:jsxRuntimeExports.jsx(Balance,{hideSymbol:!0})})})},"balance")}),jsxRuntimeExports.jsx(ThemedButton,{theme:rt??ct.theme,mode:nt??ct.mode,customTheme:ot??ct.customTheme,style:gt&&o&&dt&&(rt==="retro"||ct.theme==="retro")?{boxShadow:"var(--ck-connectbutton-balance-connectbutton-box-shadow)",borderRadius:"var(--ck-connectbutton-balance-connectbutton-border-radius)",overflow:"hidden"}:{overflow:"hidden"},children:jsxRuntimeExports.jsx(ConnectKitButtonInner,{separator:pt,showAvatar:tt,label:et})})]})})}ConnectKitButton.Custom=ConnectButtonRenderer;const dist=8,shake=We` +`,Balance=({hideIcon:et,hideSymbol:o})=>{const tt=useIsMounted(),[rt,nt]=reactExports.useState(!0),{address:ot,chain:it}=useAccount();useChains();const st=useChainIsSupported(it==null?void 0:it.id),at=useQueryClient(),{data:ct}=useBlockNumber({watch:!0}),{data:lt,queryKey:dt}=useBalance({address:ot,chainId:it==null?void 0:it.id});reactExports.useEffect(()=>{(ct??0%5===0)&&at.invalidateQueries({queryKey:dt})},[ct,dt]);const ht=chainConfigs.find(ft=>ft.id===(it==null?void 0:it.id)),mt=`${!tt||(lt==null?void 0:lt.formatted)===void 0?"balance-loading":`balance-${ht==null?void 0:ht.id}-${lt==null?void 0:lt.formatted}`}`;return reactExports.useEffect(()=>{nt(!1)},[]),jsxRuntimeExports.jsx("div",{style:{position:"relative"},children:jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:jsxRuntimeExports.jsx(motion.div,{initial:(lt==null?void 0:lt.formatted)!==void 0&&rt?{opacity:1}:{opacity:0,position:"absolute",top:0,left:0,bottom:0},animate:{opacity:1,position:"relative"},exit:{opacity:0,position:"absolute",top:0,left:0,bottom:0},transition:{duration:.4,ease:[.25,1,.5,1],delay:.4},children:!ot||!tt||(lt==null?void 0:lt.formatted)===void 0?jsxRuntimeExports.jsxs(Container$1,{children:[!et&&jsxRuntimeExports.jsx(Chain,{id:it==null?void 0:it.id}),jsxRuntimeExports.jsx("span",{style:{minWidth:32},children:jsxRuntimeExports.jsxs(PulseContainer,{children:[jsxRuntimeExports.jsx("span",{style:{animationDelay:"0ms"}}),jsxRuntimeExports.jsx("span",{style:{animationDelay:"50ms"}}),jsxRuntimeExports.jsx("span",{style:{animationDelay:"100ms"}})]})})]}):st?jsxRuntimeExports.jsxs(Container$1,{children:[!et&&jsxRuntimeExports.jsx(Chain,{id:it==null?void 0:it.id}),jsxRuntimeExports.jsx("span",{style:{minWidth:32},children:nFormatter(Number(lt==null?void 0:lt.formatted))}),!o&&` ${lt==null?void 0:lt.symbol}`]}):jsxRuntimeExports.jsxs(Container$1,{children:[!et&&jsxRuntimeExports.jsx(Chain,{id:it==null?void 0:it.id}),jsxRuntimeExports.jsx("span",{style:{minWidth:32},children:"???"})]})},mt)})})},contentVariants={initial:{zIndex:2,opacity:0,x:"-100%"},animate:{opacity:1,x:.1,transition:{duration:.4,ease:[.25,1,.5,1]}},exit:{zIndex:1,opacity:0,x:"-100%",pointerEvents:"none",position:"absolute",transition:{duration:.4,ease:[.25,1,.5,1]}}},addressVariants={initial:{zIndex:2,opacity:0,x:"100%"},animate:{x:.2,opacity:1,transition:{duration:.4,ease:[.25,1,.5,1]}},exit:{zIndex:1,x:"100%",opacity:0,pointerEvents:"none",position:"absolute",transition:{duration:.4,ease:[.25,1,.5,1]}}},textVariants={initial:{opacity:0},animate:{opacity:1,transition:{duration:.3,ease:[.25,1,.5,1]}},exit:{position:"absolute",opacity:0,transition:{duration:.3,ease:[.25,1,.5,1]}}},ConnectButtonRenderer=({children:et})=>{const o=useIsMounted(),tt=useContext(),{open:rt,setOpen:nt}=useModal(),{address:ot,isConnected:it,chain:st}=useAccount(),at=useChainIsSupported(st==null?void 0:st.id),ct=useEnsFallbackConfig(),{data:lt}=useEnsName({chainId:1,address:ot,config:ct});function dt(){nt(!1)}function ht(){nt(!0),tt.setRoute(it?routes.PROFILE:routes.CONNECTORS)}return!et||!o?null:jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:et({show:ht,hide:dt,chain:st,unsupported:!at,isConnected:!!ot,isConnecting:rt,address:ot,truncatedAddress:ot?truncateEthAddress(ot):void 0,ensName:lt==null?void 0:lt.toString()})})};ConnectButtonRenderer.displayName="ConnectKitButton.Custom";function ConnectKitButtonInner({label:et,showAvatar:o,separator:tt}){var rt;const nt=useLocales({}),ot=useContext(),{isSignedIn:it}=useSIWE(),{address:st,chain:at}=useAccount(),ct=useChainIsSupported(at==null?void 0:at.id),lt=useEnsFallbackConfig(),{data:dt}=useEnsName({chainId:1,address:st,config:lt}),ht=nt.connectWallet;return jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:st?jsxRuntimeExports.jsxs(TextContainer,{initial:"initial",animate:"animate",exit:"exit",variants:addressVariants,style:{height:40},children:[o&&jsxRuntimeExports.jsxs(IconContainer,{children:[jsxRuntimeExports.jsxs(AnimatePresence,{initial:!1,children:[it&&jsxRuntimeExports.jsx(motion.div,{style:{zIndex:2,position:"absolute",bottom:0,right:0},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsxRuntimeExports.jsx(AuthIcon,{})}),!ct&&jsxRuntimeExports.jsx(UnsupportedNetworkContainer,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:jsxRuntimeExports.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsx("path",{d:"M1.68831 13.5H12.0764C13.1026 13.5 13.7647 12.7197 13.7647 11.763C13.7647 11.4781 13.6985 11.1863 13.5462 10.9149L8.34225 1.37526C8.02445 0.791754 7.45505 0.5 6.88566 0.5C6.31627 0.5 5.73364 0.791754 5.42246 1.37526L0.225108 10.9217C0.0728291 11.1863 0 11.4781 0 11.763C0 12.7197 0.662083 13.5 1.68831 13.5ZM6.88566 8.8048C6.49503 8.8048 6.27655 8.5809 6.26331 8.1738L6.16399 5.0595C6.15075 4.64562 6.44869 4.34708 6.87904 4.34708C7.30278 4.34708 7.61396 4.6524 7.60071 5.06628L7.5014 8.16701C7.48154 8.5809 7.26305 8.8048 6.88566 8.8048ZM6.88566 11.3492C6.44207 11.3492 6.07792 11.0303 6.07792 10.5757C6.07792 10.1211 6.44207 9.80219 6.88566 9.80219C7.32926 9.80219 7.69341 10.1143 7.69341 10.5757C7.69341 11.0371 7.32264 11.3492 6.88566 11.3492Z",fill:"currentColor"})})})]}),jsxRuntimeExports.jsx(Avatar,{size:24,address:st})]}),jsxRuntimeExports.jsx("div",{style:{position:"relative",paddingRight:o?1:0},children:jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:dt?jsxRuntimeExports.jsx(TextContainer,{initial:"initial",animate:"animate",exit:"exit",variants:textVariants,style:{position:dt?"relative":"absolute"},children:!((rt=ot.options)===null||rt===void 0)&&rt.truncateLongENSAddress?truncateENSAddress(dt,20):dt},"ckEnsName"):jsxRuntimeExports.jsxs(TextContainer,{initial:"initial",animate:"animate",exit:"exit",variants:textVariants,style:{position:dt?"absolute":"relative"},children:[truncateEthAddress(st,tt)," "]},"ckTruncatedAddress")})})]},"connectedText"):jsxRuntimeExports.jsx(TextContainer,{initial:"initial",animate:"animate",exit:"exit",variants:contentVariants,style:{height:40},children:et||ht},"connectWalletText")})}function ConnectKitButton({label:et,showBalance:o=!1,showAvatar:tt=!0,theme:rt,mode:nt,customTheme:ot,onClick:it}){var st;const at=useIsMounted(),ct=useContext(),{isConnected:lt,address:dt,chain:ht}=useAccount(),mt=useChainIsSupported(ht==null?void 0:ht.id);function ft(){ct.setOpen(!0),ct.setRoute(lt?routes.PROFILE:routes.CONNECTORS)}const pt=["web95","rounded","minimal"].includes((st=rt??ct.theme)!==null&&st!==void 0?st:"")?"....":void 0;if(!at)return null;const yt=o&&mt,gt=dt&&yt;return jsxRuntimeExports.jsx(ResetContainer,{$useTheme:rt??ct.theme,$useMode:nt??ct.mode,$customTheme:ot??ct.customTheme,children:jsxRuntimeExports.jsxs(ThemeContainer,{onClick:()=>{it?it(ft):ft()},children:[yt&&jsxRuntimeExports.jsx(AnimatePresence,{initial:!1,children:gt&&jsxRuntimeExports.jsx(motion.div,{initial:{opacity:0,x:"100%",width:0,marginRight:0},animate:{opacity:1,x:0,width:"auto",marginRight:-24,transition:{duration:.4,ease:[.25,1,.5,1]}},exit:{opacity:0,x:"100%",width:0,marginRight:0,transition:{duration:.4,ease:[.25,1,.5,1]}},children:jsxRuntimeExports.jsx(ThemedButton,{variant:"secondary",theme:rt??ct.theme,mode:nt??ct.mode,customTheme:ot??ct.customTheme,style:{overflow:"hidden"},children:jsxRuntimeExports.jsx(motion.div,{style:{paddingRight:24},children:jsxRuntimeExports.jsx(Balance,{hideSymbol:!0})})})},"balance")}),jsxRuntimeExports.jsx(ThemedButton,{theme:rt??ct.theme,mode:nt??ct.mode,customTheme:ot??ct.customTheme,style:yt&&o&&dt&&(rt==="retro"||ct.theme==="retro")?{boxShadow:"var(--ck-connectbutton-balance-connectbutton-box-shadow)",borderRadius:"var(--ck-connectbutton-balance-connectbutton-border-radius)",overflow:"hidden"}:{overflow:"hidden"},children:jsxRuntimeExports.jsx(ConnectKitButtonInner,{separator:pt,showAvatar:tt,label:et})})]})})}ConnectKitButton.Custom=ConnectButtonRenderer;const dist=8,shake=We` 0%{ transform:none; } 25%{ transform:translateX(${dist}px); } 50%{ transform:translateX(-${dist}px); } @@ -3852,7 +3852,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function _extends$2(){return _extends$2=Object.assign?Object.assign.bind():function(et){for(var o=1;o"u")throw new Error(o)}function warning(et,o){if(!et){typeof console<"u"&&console.warn(o);try{throw new Error(o)}catch{}}}function createKey(){return Math.random().toString(36).substr(2,8)}function getHistoryState(et,o){return{usr:et.state,key:et.key,idx:o}}function createLocation(et,o,tt,rt){return tt===void 0&&(tt=null),_extends$2({pathname:typeof et=="string"?et:et.pathname,search:"",hash:""},typeof o=="string"?parsePath(o):o,{state:tt,key:o&&o.key||rt||createKey()})}function createPath(et){let{pathname:o="/",search:tt="",hash:rt=""}=et;return tt&&tt!=="?"&&(o+=tt.charAt(0)==="?"?tt:"?"+tt),rt&&rt!=="#"&&(o+=rt.charAt(0)==="#"?rt:"#"+rt),o}function parsePath(et){let o={};if(et){let tt=et.indexOf("#");tt>=0&&(o.hash=et.substr(tt),et=et.substr(0,tt));let rt=et.indexOf("?");rt>=0&&(o.search=et.substr(rt),et=et.substr(0,rt)),et&&(o.pathname=et)}return o}function getUrlBasedHistory(et,o,tt,rt){rt===void 0&&(rt={});let{window:nt=document.defaultView,v5Compat:ot=!1}=rt,it=nt.history,st=Action.Pop,at=null,ct=lt();ct==null&&(ct=0,it.replaceState(_extends$2({},it.state,{idx:ct}),""));function lt(){return(it.state||{idx:null}).idx}function dt(){st=Action.Pop;let gt=lt(),yt=gt==null?null:gt-ct;ct=gt,at&&at({action:st,location:pt.location,delta:yt})}function ht(gt,yt){st=Action.Push;let bt=createLocation(pt.location,gt,yt);ct=lt()+1;let xt=getHistoryState(bt,ct),vt=pt.createHref(bt);try{it.pushState(xt,"",vt)}catch(Et){if(Et instanceof DOMException&&Et.name==="DataCloneError")throw Et;nt.location.assign(vt)}ot&&at&&at({action:st,location:pt.location,delta:1})}function mt(gt,yt){st=Action.Replace;let bt=createLocation(pt.location,gt,yt);ct=lt();let xt=getHistoryState(bt,ct),vt=pt.createHref(bt);it.replaceState(xt,"",vt),ot&&at&&at({action:st,location:pt.location,delta:0})}function ft(gt){let yt=nt.location.origin!=="null"?nt.location.origin:nt.location.href,bt=typeof gt=="string"?gt:createPath(gt);return bt=bt.replace(/ $/,"%20"),invariant(yt,"No window.location.(origin|href) available to create URL for href: "+bt),new URL(bt,yt)}let pt={get action(){return st},get location(){return et(nt,it)},listen(gt){if(at)throw new Error("A history only accepts one active listener");return nt.addEventListener(PopStateEventType,dt),at=gt,()=>{nt.removeEventListener(PopStateEventType,dt),at=null}},createHref(gt){return o(nt,gt)},createURL:ft,encodeLocation(gt){let yt=ft(gt);return{pathname:yt.pathname,search:yt.search,hash:yt.hash}},push:ht,replace:mt,go(gt){return it.go(gt)}};return pt}var ResultType;(function(et){et.data="data",et.deferred="deferred",et.redirect="redirect",et.error="error"})(ResultType||(ResultType={}));function matchRoutes(et,o,tt){return tt===void 0&&(tt="/"),matchRoutesImpl(et,o,tt,!1)}function matchRoutesImpl(et,o,tt,rt){let nt=typeof o=="string"?parsePath(o):o,ot=stripBasename(nt.pathname||"/",tt);if(ot==null)return null;let it=flattenRoutes(et);rankRouteBranches(it);let st=null;for(let at=0;st==null&&at{let at={relativePath:st===void 0?ot.path||"":st,caseSensitive:ot.caseSensitive===!0,childrenIndex:it,route:ot};at.relativePath.startsWith("/")&&(invariant(at.relativePath.startsWith(rt),'Absolute route path "'+at.relativePath+'" nested under path '+('"'+rt+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),at.relativePath=at.relativePath.slice(rt.length));let ct=joinPaths([rt,at.relativePath]),lt=tt.concat(at);ot.children&&ot.children.length>0&&(invariant(ot.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+ct+'".')),flattenRoutes(ot.children,o,lt,ct)),!(ot.path==null&&!ot.index)&&o.push({path:ct,score:computeScore(ct,ot.index),routesMeta:lt})};return et.forEach((ot,it)=>{var st;if(ot.path===""||!((st=ot.path)!=null&&st.includes("?")))nt(ot,it);else for(let at of explodeOptionalSegments(ot.path))nt(ot,it,at)}),o}function explodeOptionalSegments(et){let o=et.split("/");if(o.length===0)return[];let[tt,...rt]=o,nt=tt.endsWith("?"),ot=tt.replace(/\?$/,"");if(rt.length===0)return nt?[ot,""]:[ot];let it=explodeOptionalSegments(rt.join("/")),st=[];return st.push(...it.map(at=>at===""?ot:[ot,at].join("/"))),nt&&st.push(...it),st.map(at=>et.startsWith("/")&&at===""?"/":at)}function rankRouteBranches(et){et.sort((o,tt)=>o.score!==tt.score?tt.score-o.score:compareIndexes(o.routesMeta.map(rt=>rt.childrenIndex),tt.routesMeta.map(rt=>rt.childrenIndex)))}const paramRe=/^:[\w-]+$/,dynamicSegmentValue=3,indexRouteValue=2,emptySegmentValue=1,staticSegmentValue=10,splatPenalty=-2,isSplat=et=>et==="*";function computeScore(et,o){let tt=et.split("/"),rt=tt.length;return tt.some(isSplat)&&(rt+=splatPenalty),o&&(rt+=indexRouteValue),tt.filter(nt=>!isSplat(nt)).reduce((nt,ot)=>nt+(paramRe.test(ot)?dynamicSegmentValue:ot===""?emptySegmentValue:staticSegmentValue),rt)}function compareIndexes(et,o){return et.length===o.length&&et.slice(0,-1).every((rt,nt)=>rt===o[nt])?et[et.length-1]-o[o.length-1]:0}function matchRouteBranch(et,o,tt){let{routesMeta:rt}=et,nt={},ot="/",it=[];for(let st=0;st{let{paramName:ht,isOptional:mt}=lt;if(ht==="*"){let pt=st[dt]||"";it=ot.slice(0,ot.length-pt.length).replace(/(.)\/+$/,"$1")}const ft=st[dt];return mt&&!ft?ct[ht]=void 0:ct[ht]=(ft||"").replace(/%2F/g,"/"),ct},{}),pathname:ot,pathnameBase:it,pattern:et}}function compilePath(et,o,tt){o===void 0&&(o=!1),tt===void 0&&(tt=!0),warning(et==="*"||!et.endsWith("*")||et.endsWith("/*"),'Route path "'+et+'" will be treated as if it were '+('"'+et.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+et.replace(/\*$/,"/*")+'".'));let rt=[],nt="^"+et.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(it,st,at)=>(rt.push({paramName:st,isOptional:at!=null}),at?"/?([^\\/]+)?":"/([^\\/]+)"));return et.endsWith("*")?(rt.push({paramName:"*"}),nt+=et==="*"||et==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):tt?nt+="\\/*$":et!==""&&et!=="/"&&(nt+="(?:(?=\\/|$))"),[new RegExp(nt,o?void 0:"i"),rt]}function decodePath(et){try{return et.split("/").map(o=>decodeURIComponent(o).replace(/\//g,"%2F")).join("/")}catch(o){return warning(!1,'The URL path "'+et+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+o+").")),et}}function stripBasename(et,o){if(o==="/")return et;if(!et.toLowerCase().startsWith(o.toLowerCase()))return null;let tt=o.endsWith("/")?o.length-1:o.length,rt=et.charAt(tt);return rt&&rt!=="/"?null:et.slice(tt)||"/"}function resolvePath(et,o){o===void 0&&(o="/");let{pathname:tt,search:rt="",hash:nt=""}=typeof et=="string"?parsePath(et):et;return{pathname:tt?tt.startsWith("/")?tt:resolvePathname(tt,o):o,search:normalizeSearch(rt),hash:normalizeHash(nt)}}function resolvePathname(et,o){let tt=o.replace(/\/+$/,"").split("/");return et.split("/").forEach(nt=>{nt===".."?tt.length>1&&tt.pop():nt!=="."&&tt.push(nt)}),tt.length>1?tt.join("/"):"/"}function getInvalidPathError(et,o,tt,rt){return"Cannot include a '"+et+"' character in a manually specified "+("`to."+o+"` field ["+JSON.stringify(rt)+"]. Please separate it out to the ")+("`to."+tt+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function getPathContributingMatches(et){return et.filter((o,tt)=>tt===0||o.route.path&&o.route.path.length>0)}function getResolveToMatches(et,o){let tt=getPathContributingMatches(et);return o?tt.map((rt,nt)=>nt===tt.length-1?rt.pathname:rt.pathnameBase):tt.map(rt=>rt.pathnameBase)}function resolveTo(et,o,tt,rt){rt===void 0&&(rt=!1);let nt;typeof et=="string"?nt=parsePath(et):(nt=_extends$2({},et),invariant(!nt.pathname||!nt.pathname.includes("?"),getInvalidPathError("?","pathname","search",nt)),invariant(!nt.pathname||!nt.pathname.includes("#"),getInvalidPathError("#","pathname","hash",nt)),invariant(!nt.search||!nt.search.includes("#"),getInvalidPathError("#","search","hash",nt)));let ot=et===""||nt.pathname==="",it=ot?"/":nt.pathname,st;if(it==null)st=tt;else{let dt=o.length-1;if(!rt&&it.startsWith("..")){let ht=it.split("/");for(;ht[0]==="..";)ht.shift(),dt-=1;nt.pathname=ht.join("/")}st=dt>=0?o[dt]:"/"}let at=resolvePath(nt,st),ct=it&&it!=="/"&&it.endsWith("/"),lt=(ot||it===".")&&tt.endsWith("/");return!at.pathname.endsWith("/")&&(ct||lt)&&(at.pathname+="/"),at}const joinPaths=et=>et.join("/").replace(/\/\/+/g,"/"),normalizePathname=et=>et.replace(/\/+$/,"").replace(/^\/*/,"/"),normalizeSearch=et=>!et||et==="?"?"":et.startsWith("?")?et:"?"+et,normalizeHash=et=>!et||et==="#"?"":et.startsWith("#")?et:"#"+et;function isRouteErrorResponse(et){return et!=null&&typeof et.status=="number"&&typeof et.statusText=="string"&&typeof et.internal=="boolean"&&"data"in et}const validMutationMethodsArr=["post","put","patch","delete"];new Set(validMutationMethodsArr);const validRequestMethodsArr=["get",...validMutationMethodsArr];new Set(validRequestMethodsArr);/** + */function _extends$2(){return _extends$2=Object.assign?Object.assign.bind():function(et){for(var o=1;o"u")throw new Error(o)}function warning(et,o){if(!et){typeof console<"u"&&console.warn(o);try{throw new Error(o)}catch{}}}function createKey(){return Math.random().toString(36).substr(2,8)}function getHistoryState(et,o){return{usr:et.state,key:et.key,idx:o}}function createLocation(et,o,tt,rt){return tt===void 0&&(tt=null),_extends$2({pathname:typeof et=="string"?et:et.pathname,search:"",hash:""},typeof o=="string"?parsePath(o):o,{state:tt,key:o&&o.key||rt||createKey()})}function createPath(et){let{pathname:o="/",search:tt="",hash:rt=""}=et;return tt&&tt!=="?"&&(o+=tt.charAt(0)==="?"?tt:"?"+tt),rt&&rt!=="#"&&(o+=rt.charAt(0)==="#"?rt:"#"+rt),o}function parsePath(et){let o={};if(et){let tt=et.indexOf("#");tt>=0&&(o.hash=et.substr(tt),et=et.substr(0,tt));let rt=et.indexOf("?");rt>=0&&(o.search=et.substr(rt),et=et.substr(0,rt)),et&&(o.pathname=et)}return o}function getUrlBasedHistory(et,o,tt,rt){rt===void 0&&(rt={});let{window:nt=document.defaultView,v5Compat:ot=!1}=rt,it=nt.history,st=Action.Pop,at=null,ct=lt();ct==null&&(ct=0,it.replaceState(_extends$2({},it.state,{idx:ct}),""));function lt(){return(it.state||{idx:null}).idx}function dt(){st=Action.Pop;let yt=lt(),gt=yt==null?null:yt-ct;ct=yt,at&&at({action:st,location:pt.location,delta:gt})}function ht(yt,gt){st=Action.Push;let bt=createLocation(pt.location,yt,gt);ct=lt()+1;let xt=getHistoryState(bt,ct),vt=pt.createHref(bt);try{it.pushState(xt,"",vt)}catch(Et){if(Et instanceof DOMException&&Et.name==="DataCloneError")throw Et;nt.location.assign(vt)}ot&&at&&at({action:st,location:pt.location,delta:1})}function mt(yt,gt){st=Action.Replace;let bt=createLocation(pt.location,yt,gt);ct=lt();let xt=getHistoryState(bt,ct),vt=pt.createHref(bt);it.replaceState(xt,"",vt),ot&&at&&at({action:st,location:pt.location,delta:0})}function ft(yt){let gt=nt.location.origin!=="null"?nt.location.origin:nt.location.href,bt=typeof yt=="string"?yt:createPath(yt);return bt=bt.replace(/ $/,"%20"),invariant(gt,"No window.location.(origin|href) available to create URL for href: "+bt),new URL(bt,gt)}let pt={get action(){return st},get location(){return et(nt,it)},listen(yt){if(at)throw new Error("A history only accepts one active listener");return nt.addEventListener(PopStateEventType,dt),at=yt,()=>{nt.removeEventListener(PopStateEventType,dt),at=null}},createHref(yt){return o(nt,yt)},createURL:ft,encodeLocation(yt){let gt=ft(yt);return{pathname:gt.pathname,search:gt.search,hash:gt.hash}},push:ht,replace:mt,go(yt){return it.go(yt)}};return pt}var ResultType;(function(et){et.data="data",et.deferred="deferred",et.redirect="redirect",et.error="error"})(ResultType||(ResultType={}));function matchRoutes(et,o,tt){return tt===void 0&&(tt="/"),matchRoutesImpl(et,o,tt,!1)}function matchRoutesImpl(et,o,tt,rt){let nt=typeof o=="string"?parsePath(o):o,ot=stripBasename(nt.pathname||"/",tt);if(ot==null)return null;let it=flattenRoutes(et);rankRouteBranches(it);let st=null;for(let at=0;st==null&&at{let at={relativePath:st===void 0?ot.path||"":st,caseSensitive:ot.caseSensitive===!0,childrenIndex:it,route:ot};at.relativePath.startsWith("/")&&(invariant(at.relativePath.startsWith(rt),'Absolute route path "'+at.relativePath+'" nested under path '+('"'+rt+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),at.relativePath=at.relativePath.slice(rt.length));let ct=joinPaths([rt,at.relativePath]),lt=tt.concat(at);ot.children&&ot.children.length>0&&(invariant(ot.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+ct+'".')),flattenRoutes(ot.children,o,lt,ct)),!(ot.path==null&&!ot.index)&&o.push({path:ct,score:computeScore(ct,ot.index),routesMeta:lt})};return et.forEach((ot,it)=>{var st;if(ot.path===""||!((st=ot.path)!=null&&st.includes("?")))nt(ot,it);else for(let at of explodeOptionalSegments(ot.path))nt(ot,it,at)}),o}function explodeOptionalSegments(et){let o=et.split("/");if(o.length===0)return[];let[tt,...rt]=o,nt=tt.endsWith("?"),ot=tt.replace(/\?$/,"");if(rt.length===0)return nt?[ot,""]:[ot];let it=explodeOptionalSegments(rt.join("/")),st=[];return st.push(...it.map(at=>at===""?ot:[ot,at].join("/"))),nt&&st.push(...it),st.map(at=>et.startsWith("/")&&at===""?"/":at)}function rankRouteBranches(et){et.sort((o,tt)=>o.score!==tt.score?tt.score-o.score:compareIndexes(o.routesMeta.map(rt=>rt.childrenIndex),tt.routesMeta.map(rt=>rt.childrenIndex)))}const paramRe=/^:[\w-]+$/,dynamicSegmentValue=3,indexRouteValue=2,emptySegmentValue=1,staticSegmentValue=10,splatPenalty=-2,isSplat=et=>et==="*";function computeScore(et,o){let tt=et.split("/"),rt=tt.length;return tt.some(isSplat)&&(rt+=splatPenalty),o&&(rt+=indexRouteValue),tt.filter(nt=>!isSplat(nt)).reduce((nt,ot)=>nt+(paramRe.test(ot)?dynamicSegmentValue:ot===""?emptySegmentValue:staticSegmentValue),rt)}function compareIndexes(et,o){return et.length===o.length&&et.slice(0,-1).every((rt,nt)=>rt===o[nt])?et[et.length-1]-o[o.length-1]:0}function matchRouteBranch(et,o,tt){let{routesMeta:rt}=et,nt={},ot="/",it=[];for(let st=0;st{let{paramName:ht,isOptional:mt}=lt;if(ht==="*"){let pt=st[dt]||"";it=ot.slice(0,ot.length-pt.length).replace(/(.)\/+$/,"$1")}const ft=st[dt];return mt&&!ft?ct[ht]=void 0:ct[ht]=(ft||"").replace(/%2F/g,"/"),ct},{}),pathname:ot,pathnameBase:it,pattern:et}}function compilePath(et,o,tt){o===void 0&&(o=!1),tt===void 0&&(tt=!0),warning(et==="*"||!et.endsWith("*")||et.endsWith("/*"),'Route path "'+et+'" will be treated as if it were '+('"'+et.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+et.replace(/\*$/,"/*")+'".'));let rt=[],nt="^"+et.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(it,st,at)=>(rt.push({paramName:st,isOptional:at!=null}),at?"/?([^\\/]+)?":"/([^\\/]+)"));return et.endsWith("*")?(rt.push({paramName:"*"}),nt+=et==="*"||et==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):tt?nt+="\\/*$":et!==""&&et!=="/"&&(nt+="(?:(?=\\/|$))"),[new RegExp(nt,o?void 0:"i"),rt]}function decodePath(et){try{return et.split("/").map(o=>decodeURIComponent(o).replace(/\//g,"%2F")).join("/")}catch(o){return warning(!1,'The URL path "'+et+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+o+").")),et}}function stripBasename(et,o){if(o==="/")return et;if(!et.toLowerCase().startsWith(o.toLowerCase()))return null;let tt=o.endsWith("/")?o.length-1:o.length,rt=et.charAt(tt);return rt&&rt!=="/"?null:et.slice(tt)||"/"}function resolvePath(et,o){o===void 0&&(o="/");let{pathname:tt,search:rt="",hash:nt=""}=typeof et=="string"?parsePath(et):et;return{pathname:tt?tt.startsWith("/")?tt:resolvePathname(tt,o):o,search:normalizeSearch(rt),hash:normalizeHash(nt)}}function resolvePathname(et,o){let tt=o.replace(/\/+$/,"").split("/");return et.split("/").forEach(nt=>{nt===".."?tt.length>1&&tt.pop():nt!=="."&&tt.push(nt)}),tt.length>1?tt.join("/"):"/"}function getInvalidPathError(et,o,tt,rt){return"Cannot include a '"+et+"' character in a manually specified "+("`to."+o+"` field ["+JSON.stringify(rt)+"]. Please separate it out to the ")+("`to."+tt+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function getPathContributingMatches(et){return et.filter((o,tt)=>tt===0||o.route.path&&o.route.path.length>0)}function getResolveToMatches(et,o){let tt=getPathContributingMatches(et);return o?tt.map((rt,nt)=>nt===tt.length-1?rt.pathname:rt.pathnameBase):tt.map(rt=>rt.pathnameBase)}function resolveTo(et,o,tt,rt){rt===void 0&&(rt=!1);let nt;typeof et=="string"?nt=parsePath(et):(nt=_extends$2({},et),invariant(!nt.pathname||!nt.pathname.includes("?"),getInvalidPathError("?","pathname","search",nt)),invariant(!nt.pathname||!nt.pathname.includes("#"),getInvalidPathError("#","pathname","hash",nt)),invariant(!nt.search||!nt.search.includes("#"),getInvalidPathError("#","search","hash",nt)));let ot=et===""||nt.pathname==="",it=ot?"/":nt.pathname,st;if(it==null)st=tt;else{let dt=o.length-1;if(!rt&&it.startsWith("..")){let ht=it.split("/");for(;ht[0]==="..";)ht.shift(),dt-=1;nt.pathname=ht.join("/")}st=dt>=0?o[dt]:"/"}let at=resolvePath(nt,st),ct=it&&it!=="/"&&it.endsWith("/"),lt=(ot||it===".")&&tt.endsWith("/");return!at.pathname.endsWith("/")&&(ct||lt)&&(at.pathname+="/"),at}const joinPaths=et=>et.join("/").replace(/\/\/+/g,"/"),normalizePathname=et=>et.replace(/\/+$/,"").replace(/^\/*/,"/"),normalizeSearch=et=>!et||et==="?"?"":et.startsWith("?")?et:"?"+et,normalizeHash=et=>!et||et==="#"?"":et.startsWith("#")?et:"#"+et;function isRouteErrorResponse(et){return et!=null&&typeof et.status=="number"&&typeof et.statusText=="string"&&typeof et.internal=="boolean"&&"data"in et}const validMutationMethodsArr=["post","put","patch","delete"];new Set(validMutationMethodsArr);const validRequestMethodsArr=["get",...validMutationMethodsArr];new Set(validRequestMethodsArr);/** * React Router v6.27.0 * * Copyright (c) Remix Software Inc. @@ -3861,7 +3861,7 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function _extends$1(){return _extends$1=Object.assign?Object.assign.bind():function(et){for(var o=1;o{st.current=!0}),reactExports.useCallback(function(ct,lt){if(lt===void 0&&(lt={}),!st.current)return;if(typeof ct=="number"){rt.go(ct);return}let dt=resolveTo(ct,JSON.parse(it),ot,lt.relative==="path");et==null&&o!=="/"&&(dt.pathname=dt.pathname==="/"?o:joinPaths([o,dt.pathname])),(lt.replace?rt.replace:rt.push)(dt,lt.state,lt)},[o,rt,it,ot,et])}function useParams(){let{matches:et}=reactExports.useContext(RouteContext),o=et[et.length-1];return o?o.params:{}}function useResolvedPath(et,o){let{relative:tt}=o===void 0?{}:o,{future:rt}=reactExports.useContext(NavigationContext),{matches:nt}=reactExports.useContext(RouteContext),{pathname:ot}=useLocation(),it=JSON.stringify(getResolveToMatches(nt,rt.v7_relativeSplatPath));return reactExports.useMemo(()=>resolveTo(et,JSON.parse(it),ot,tt==="path"),[et,it,ot,tt])}function useRoutes(et,o){return useRoutesImpl(et,o)}function useRoutesImpl(et,o,tt,rt){useInRouterContext()||invariant(!1);let{navigator:nt}=reactExports.useContext(NavigationContext),{matches:ot}=reactExports.useContext(RouteContext),it=ot[ot.length-1],st=it?it.params:{};it&&it.pathname;let at=it?it.pathnameBase:"/";it&&it.route;let ct=useLocation(),lt;if(o){var dt;let gt=typeof o=="string"?parsePath(o):o;at==="/"||(dt=gt.pathname)!=null&&dt.startsWith(at)||invariant(!1),lt=gt}else lt=ct;let ht=lt.pathname||"/",mt=ht;if(at!=="/"){let gt=at.replace(/^\//,"").split("/");mt="/"+ht.replace(/^\//,"").split("/").slice(gt.length).join("/")}let ft=matchRoutes(et,{pathname:mt}),pt=_renderMatches(ft&&ft.map(gt=>Object.assign({},gt,{params:Object.assign({},st,gt.params),pathname:joinPaths([at,nt.encodeLocation?nt.encodeLocation(gt.pathname).pathname:gt.pathname]),pathnameBase:gt.pathnameBase==="/"?at:joinPaths([at,nt.encodeLocation?nt.encodeLocation(gt.pathnameBase).pathname:gt.pathnameBase])})),ot,tt,rt);return o&&pt?reactExports.createElement(LocationContext.Provider,{value:{location:_extends$1({pathname:"/",search:"",hash:"",state:null,key:"default"},lt),navigationType:Action.Pop}},pt):pt}function DefaultErrorComponent(){let et=useRouteError(),o=isRouteErrorResponse(et)?et.status+" "+et.statusText:et instanceof Error?et.message:JSON.stringify(et),tt=et instanceof Error?et.stack:null,nt={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return reactExports.createElement(reactExports.Fragment,null,reactExports.createElement("h2",null,"Unexpected Application Error!"),reactExports.createElement("h3",{style:{fontStyle:"italic"}},o),tt?reactExports.createElement("pre",{style:nt},tt):null,null)}const defaultErrorElement=reactExports.createElement(DefaultErrorComponent,null);class RenderErrorBoundary extends reactExports.Component{constructor(o){super(o),this.state={location:o.location,revalidation:o.revalidation,error:o.error}}static getDerivedStateFromError(o){return{error:o}}static getDerivedStateFromProps(o,tt){return tt.location!==o.location||tt.revalidation!=="idle"&&o.revalidation==="idle"?{error:o.error,location:o.location,revalidation:o.revalidation}:{error:o.error!==void 0?o.error:tt.error,location:tt.location,revalidation:o.revalidation||tt.revalidation}}componentDidCatch(o,tt){console.error("React Router caught the following error during render",o,tt)}render(){return this.state.error!==void 0?reactExports.createElement(RouteContext.Provider,{value:this.props.routeContext},reactExports.createElement(RouteErrorContext.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function RenderedRoute(et){let{routeContext:o,match:tt,children:rt}=et,nt=reactExports.useContext(DataRouterContext);return nt&&nt.static&&nt.staticContext&&(tt.route.errorElement||tt.route.ErrorBoundary)&&(nt.staticContext._deepestRenderedBoundaryId=tt.route.id),reactExports.createElement(RouteContext.Provider,{value:o},rt)}function _renderMatches(et,o,tt,rt){var nt;if(o===void 0&&(o=[]),tt===void 0&&(tt=null),rt===void 0&&(rt=null),et==null){var ot;if(!tt)return null;if(tt.errors)et=tt.matches;else if((ot=rt)!=null&&ot.v7_partialHydration&&o.length===0&&!tt.initialized&&tt.matches.length>0)et=tt.matches;else return null}let it=et,st=(nt=tt)==null?void 0:nt.errors;if(st!=null){let lt=it.findIndex(dt=>dt.route.id&&(st==null?void 0:st[dt.route.id])!==void 0);lt>=0||invariant(!1),it=it.slice(0,Math.min(it.length,lt+1))}let at=!1,ct=-1;if(tt&&rt&&rt.v7_partialHydration)for(let lt=0;lt=0?it=it.slice(0,ct+1):it=[it[0]];break}}}return it.reduceRight((lt,dt,ht)=>{let mt,ft=!1,pt=null,gt=null;tt&&(mt=st&&dt.route.id?st[dt.route.id]:void 0,pt=dt.route.errorElement||defaultErrorElement,at&&(ct<0&&ht===0?(ft=!0,gt=null):ct===ht&&(ft=!0,gt=dt.route.hydrateFallbackElement||null)));let yt=o.concat(it.slice(0,ht+1)),bt=()=>{let xt;return mt?xt=pt:ft?xt=gt:dt.route.Component?xt=reactExports.createElement(dt.route.Component,null):dt.route.element?xt=dt.route.element:xt=lt,reactExports.createElement(RenderedRoute,{match:dt,routeContext:{outlet:lt,matches:yt,isDataRoute:tt!=null},children:xt})};return tt&&(dt.route.ErrorBoundary||dt.route.errorElement||ht===0)?reactExports.createElement(RenderErrorBoundary,{location:tt.location,revalidation:tt.revalidation,component:pt,error:mt,children:bt(),routeContext:{outlet:null,matches:yt,isDataRoute:!0}}):bt()},null)}var DataRouterHook$1=function(et){return et.UseBlocker="useBlocker",et.UseRevalidator="useRevalidator",et.UseNavigateStable="useNavigate",et}(DataRouterHook$1||{}),DataRouterStateHook$1=function(et){return et.UseBlocker="useBlocker",et.UseLoaderData="useLoaderData",et.UseActionData="useActionData",et.UseRouteError="useRouteError",et.UseNavigation="useNavigation",et.UseRouteLoaderData="useRouteLoaderData",et.UseMatches="useMatches",et.UseRevalidator="useRevalidator",et.UseNavigateStable="useNavigate",et.UseRouteId="useRouteId",et}(DataRouterStateHook$1||{});function useDataRouterContext(et){let o=reactExports.useContext(DataRouterContext);return o||invariant(!1),o}function useDataRouterState(et){let o=reactExports.useContext(DataRouterStateContext);return o||invariant(!1),o}function useRouteContext(et){let o=reactExports.useContext(RouteContext);return o||invariant(!1),o}function useCurrentRouteId(et){let o=useRouteContext(),tt=o.matches[o.matches.length-1];return tt.route.id||invariant(!1),tt.route.id}function useRouteError(){var et;let o=reactExports.useContext(RouteErrorContext),tt=useDataRouterState(DataRouterStateHook$1.UseRouteError),rt=useCurrentRouteId(DataRouterStateHook$1.UseRouteError);return o!==void 0?o:(et=tt.errors)==null?void 0:et[rt]}function useNavigateStable(){let{router:et}=useDataRouterContext(DataRouterHook$1.UseNavigateStable),o=useCurrentRouteId(DataRouterStateHook$1.UseNavigateStable),tt=reactExports.useRef(!1);return useIsomorphicLayoutEffect$1(()=>{tt.current=!0}),reactExports.useCallback(function(nt,ot){ot===void 0&&(ot={}),tt.current&&(typeof nt=="number"?et.navigate(nt):et.navigate(nt,_extends$1({fromRouteId:o},ot)))},[et,o])}function Navigate(et){let{to:o,replace:tt,state:rt,relative:nt}=et;useInRouterContext()||invariant(!1);let{future:ot,static:it}=reactExports.useContext(NavigationContext),{matches:st}=reactExports.useContext(RouteContext),{pathname:at}=useLocation(),ct=useNavigate(),lt=resolveTo(o,getResolveToMatches(st,ot.v7_relativeSplatPath),at,nt==="path"),dt=JSON.stringify(lt);return reactExports.useEffect(()=>ct(JSON.parse(dt),{replace:tt,state:rt,relative:nt}),[ct,dt,nt,tt,rt]),null}function Route(et){invariant(!1)}function Router(et){let{basename:o="/",children:tt=null,location:rt,navigationType:nt=Action.Pop,navigator:ot,static:it=!1,future:st}=et;useInRouterContext()&&invariant(!1);let at=o.replace(/^\/*/,"/"),ct=reactExports.useMemo(()=>({basename:at,navigator:ot,static:it,future:_extends$1({v7_relativeSplatPath:!1},st)}),[at,st,ot,it]);typeof rt=="string"&&(rt=parsePath(rt));let{pathname:lt="/",search:dt="",hash:ht="",state:mt=null,key:ft="default"}=rt,pt=reactExports.useMemo(()=>{let gt=stripBasename(lt,at);return gt==null?null:{location:{pathname:gt,search:dt,hash:ht,state:mt,key:ft},navigationType:nt}},[at,lt,dt,ht,mt,ft,nt]);return pt==null?null:reactExports.createElement(NavigationContext.Provider,{value:ct},reactExports.createElement(LocationContext.Provider,{children:tt,value:pt}))}function Routes(et){let{children:o,location:tt}=et;return useRoutes(createRoutesFromChildren(o),tt)}new Promise(()=>{});function createRoutesFromChildren(et,o){o===void 0&&(o=[]);let tt=[];return reactExports.Children.forEach(et,(rt,nt)=>{if(!reactExports.isValidElement(rt))return;let ot=[...o,nt];if(rt.type===reactExports.Fragment){tt.push.apply(tt,createRoutesFromChildren(rt.props.children,ot));return}rt.type!==Route&&invariant(!1),!rt.props.index||!rt.props.children||invariant(!1);let it={id:rt.props.id||ot.join("-"),caseSensitive:rt.props.caseSensitive,element:rt.props.element,Component:rt.props.Component,index:rt.props.index,path:rt.props.path,loader:rt.props.loader,action:rt.props.action,errorElement:rt.props.errorElement,ErrorBoundary:rt.props.ErrorBoundary,hasErrorBoundary:rt.props.ErrorBoundary!=null||rt.props.errorElement!=null,shouldRevalidate:rt.props.shouldRevalidate,handle:rt.props.handle,lazy:rt.props.lazy};rt.props.children&&(it.children=createRoutesFromChildren(rt.props.children,ot)),tt.push(it)}),tt}/** + */function _extends$1(){return _extends$1=Object.assign?Object.assign.bind():function(et){for(var o=1;o{st.current=!0}),reactExports.useCallback(function(ct,lt){if(lt===void 0&&(lt={}),!st.current)return;if(typeof ct=="number"){rt.go(ct);return}let dt=resolveTo(ct,JSON.parse(it),ot,lt.relative==="path");et==null&&o!=="/"&&(dt.pathname=dt.pathname==="/"?o:joinPaths([o,dt.pathname])),(lt.replace?rt.replace:rt.push)(dt,lt.state,lt)},[o,rt,it,ot,et])}function useParams(){let{matches:et}=reactExports.useContext(RouteContext),o=et[et.length-1];return o?o.params:{}}function useResolvedPath(et,o){let{relative:tt}=o===void 0?{}:o,{future:rt}=reactExports.useContext(NavigationContext),{matches:nt}=reactExports.useContext(RouteContext),{pathname:ot}=useLocation(),it=JSON.stringify(getResolveToMatches(nt,rt.v7_relativeSplatPath));return reactExports.useMemo(()=>resolveTo(et,JSON.parse(it),ot,tt==="path"),[et,it,ot,tt])}function useRoutes(et,o){return useRoutesImpl(et,o)}function useRoutesImpl(et,o,tt,rt){useInRouterContext()||invariant(!1);let{navigator:nt}=reactExports.useContext(NavigationContext),{matches:ot}=reactExports.useContext(RouteContext),it=ot[ot.length-1],st=it?it.params:{};it&&it.pathname;let at=it?it.pathnameBase:"/";it&&it.route;let ct=useLocation(),lt;if(o){var dt;let yt=typeof o=="string"?parsePath(o):o;at==="/"||(dt=yt.pathname)!=null&&dt.startsWith(at)||invariant(!1),lt=yt}else lt=ct;let ht=lt.pathname||"/",mt=ht;if(at!=="/"){let yt=at.replace(/^\//,"").split("/");mt="/"+ht.replace(/^\//,"").split("/").slice(yt.length).join("/")}let ft=matchRoutes(et,{pathname:mt}),pt=_renderMatches(ft&&ft.map(yt=>Object.assign({},yt,{params:Object.assign({},st,yt.params),pathname:joinPaths([at,nt.encodeLocation?nt.encodeLocation(yt.pathname).pathname:yt.pathname]),pathnameBase:yt.pathnameBase==="/"?at:joinPaths([at,nt.encodeLocation?nt.encodeLocation(yt.pathnameBase).pathname:yt.pathnameBase])})),ot,tt,rt);return o&&pt?reactExports.createElement(LocationContext.Provider,{value:{location:_extends$1({pathname:"/",search:"",hash:"",state:null,key:"default"},lt),navigationType:Action.Pop}},pt):pt}function DefaultErrorComponent(){let et=useRouteError(),o=isRouteErrorResponse(et)?et.status+" "+et.statusText:et instanceof Error?et.message:JSON.stringify(et),tt=et instanceof Error?et.stack:null,nt={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return reactExports.createElement(reactExports.Fragment,null,reactExports.createElement("h2",null,"Unexpected Application Error!"),reactExports.createElement("h3",{style:{fontStyle:"italic"}},o),tt?reactExports.createElement("pre",{style:nt},tt):null,null)}const defaultErrorElement=reactExports.createElement(DefaultErrorComponent,null);class RenderErrorBoundary extends reactExports.Component{constructor(o){super(o),this.state={location:o.location,revalidation:o.revalidation,error:o.error}}static getDerivedStateFromError(o){return{error:o}}static getDerivedStateFromProps(o,tt){return tt.location!==o.location||tt.revalidation!=="idle"&&o.revalidation==="idle"?{error:o.error,location:o.location,revalidation:o.revalidation}:{error:o.error!==void 0?o.error:tt.error,location:tt.location,revalidation:o.revalidation||tt.revalidation}}componentDidCatch(o,tt){console.error("React Router caught the following error during render",o,tt)}render(){return this.state.error!==void 0?reactExports.createElement(RouteContext.Provider,{value:this.props.routeContext},reactExports.createElement(RouteErrorContext.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function RenderedRoute(et){let{routeContext:o,match:tt,children:rt}=et,nt=reactExports.useContext(DataRouterContext);return nt&&nt.static&&nt.staticContext&&(tt.route.errorElement||tt.route.ErrorBoundary)&&(nt.staticContext._deepestRenderedBoundaryId=tt.route.id),reactExports.createElement(RouteContext.Provider,{value:o},rt)}function _renderMatches(et,o,tt,rt){var nt;if(o===void 0&&(o=[]),tt===void 0&&(tt=null),rt===void 0&&(rt=null),et==null){var ot;if(!tt)return null;if(tt.errors)et=tt.matches;else if((ot=rt)!=null&&ot.v7_partialHydration&&o.length===0&&!tt.initialized&&tt.matches.length>0)et=tt.matches;else return null}let it=et,st=(nt=tt)==null?void 0:nt.errors;if(st!=null){let lt=it.findIndex(dt=>dt.route.id&&(st==null?void 0:st[dt.route.id])!==void 0);lt>=0||invariant(!1),it=it.slice(0,Math.min(it.length,lt+1))}let at=!1,ct=-1;if(tt&&rt&&rt.v7_partialHydration)for(let lt=0;lt=0?it=it.slice(0,ct+1):it=[it[0]];break}}}return it.reduceRight((lt,dt,ht)=>{let mt,ft=!1,pt=null,yt=null;tt&&(mt=st&&dt.route.id?st[dt.route.id]:void 0,pt=dt.route.errorElement||defaultErrorElement,at&&(ct<0&&ht===0?(ft=!0,yt=null):ct===ht&&(ft=!0,yt=dt.route.hydrateFallbackElement||null)));let gt=o.concat(it.slice(0,ht+1)),bt=()=>{let xt;return mt?xt=pt:ft?xt=yt:dt.route.Component?xt=reactExports.createElement(dt.route.Component,null):dt.route.element?xt=dt.route.element:xt=lt,reactExports.createElement(RenderedRoute,{match:dt,routeContext:{outlet:lt,matches:gt,isDataRoute:tt!=null},children:xt})};return tt&&(dt.route.ErrorBoundary||dt.route.errorElement||ht===0)?reactExports.createElement(RenderErrorBoundary,{location:tt.location,revalidation:tt.revalidation,component:pt,error:mt,children:bt(),routeContext:{outlet:null,matches:gt,isDataRoute:!0}}):bt()},null)}var DataRouterHook$1=function(et){return et.UseBlocker="useBlocker",et.UseRevalidator="useRevalidator",et.UseNavigateStable="useNavigate",et}(DataRouterHook$1||{}),DataRouterStateHook$1=function(et){return et.UseBlocker="useBlocker",et.UseLoaderData="useLoaderData",et.UseActionData="useActionData",et.UseRouteError="useRouteError",et.UseNavigation="useNavigation",et.UseRouteLoaderData="useRouteLoaderData",et.UseMatches="useMatches",et.UseRevalidator="useRevalidator",et.UseNavigateStable="useNavigate",et.UseRouteId="useRouteId",et}(DataRouterStateHook$1||{});function useDataRouterContext(et){let o=reactExports.useContext(DataRouterContext);return o||invariant(!1),o}function useDataRouterState(et){let o=reactExports.useContext(DataRouterStateContext);return o||invariant(!1),o}function useRouteContext(et){let o=reactExports.useContext(RouteContext);return o||invariant(!1),o}function useCurrentRouteId(et){let o=useRouteContext(),tt=o.matches[o.matches.length-1];return tt.route.id||invariant(!1),tt.route.id}function useRouteError(){var et;let o=reactExports.useContext(RouteErrorContext),tt=useDataRouterState(DataRouterStateHook$1.UseRouteError),rt=useCurrentRouteId(DataRouterStateHook$1.UseRouteError);return o!==void 0?o:(et=tt.errors)==null?void 0:et[rt]}function useNavigateStable(){let{router:et}=useDataRouterContext(DataRouterHook$1.UseNavigateStable),o=useCurrentRouteId(DataRouterStateHook$1.UseNavigateStable),tt=reactExports.useRef(!1);return useIsomorphicLayoutEffect$1(()=>{tt.current=!0}),reactExports.useCallback(function(nt,ot){ot===void 0&&(ot={}),tt.current&&(typeof nt=="number"?et.navigate(nt):et.navigate(nt,_extends$1({fromRouteId:o},ot)))},[et,o])}function Navigate(et){let{to:o,replace:tt,state:rt,relative:nt}=et;useInRouterContext()||invariant(!1);let{future:ot,static:it}=reactExports.useContext(NavigationContext),{matches:st}=reactExports.useContext(RouteContext),{pathname:at}=useLocation(),ct=useNavigate(),lt=resolveTo(o,getResolveToMatches(st,ot.v7_relativeSplatPath),at,nt==="path"),dt=JSON.stringify(lt);return reactExports.useEffect(()=>ct(JSON.parse(dt),{replace:tt,state:rt,relative:nt}),[ct,dt,nt,tt,rt]),null}function Route(et){invariant(!1)}function Router(et){let{basename:o="/",children:tt=null,location:rt,navigationType:nt=Action.Pop,navigator:ot,static:it=!1,future:st}=et;useInRouterContext()&&invariant(!1);let at=o.replace(/^\/*/,"/"),ct=reactExports.useMemo(()=>({basename:at,navigator:ot,static:it,future:_extends$1({v7_relativeSplatPath:!1},st)}),[at,st,ot,it]);typeof rt=="string"&&(rt=parsePath(rt));let{pathname:lt="/",search:dt="",hash:ht="",state:mt=null,key:ft="default"}=rt,pt=reactExports.useMemo(()=>{let yt=stripBasename(lt,at);return yt==null?null:{location:{pathname:yt,search:dt,hash:ht,state:mt,key:ft},navigationType:nt}},[at,lt,dt,ht,mt,ft,nt]);return pt==null?null:reactExports.createElement(NavigationContext.Provider,{value:ct},reactExports.createElement(LocationContext.Provider,{children:tt,value:pt}))}function Routes(et){let{children:o,location:tt}=et;return useRoutes(createRoutesFromChildren(o),tt)}new Promise(()=>{});function createRoutesFromChildren(et,o){o===void 0&&(o=[]);let tt=[];return reactExports.Children.forEach(et,(rt,nt)=>{if(!reactExports.isValidElement(rt))return;let ot=[...o,nt];if(rt.type===reactExports.Fragment){tt.push.apply(tt,createRoutesFromChildren(rt.props.children,ot));return}rt.type!==Route&&invariant(!1),!rt.props.index||!rt.props.children||invariant(!1);let it={id:rt.props.id||ot.join("-"),caseSensitive:rt.props.caseSensitive,element:rt.props.element,Component:rt.props.Component,index:rt.props.index,path:rt.props.path,loader:rt.props.loader,action:rt.props.action,errorElement:rt.props.errorElement,ErrorBoundary:rt.props.ErrorBoundary,hasErrorBoundary:rt.props.ErrorBoundary!=null||rt.props.errorElement!=null,shouldRevalidate:rt.props.shouldRevalidate,handle:rt.props.handle,lazy:rt.props.lazy};rt.props.children&&(it.children=createRoutesFromChildren(rt.props.children,ot)),tt.push(it)}),tt}/** * React Router DOM v6.27.0 * * Copyright (c) Remix Software Inc. @@ -3870,10 +3870,10 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function _extends(){return _extends=Object.assign?Object.assign.bind():function(et){for(var o=1;o=0)&&(tt[nt]=et[nt]);return tt}function isModifiedEvent(et){return!!(et.metaKey||et.altKey||et.ctrlKey||et.shiftKey)}function shouldProcessLinkClick(et,o){return et.button===0&&(!o||o==="_self")&&!isModifiedEvent(et)}const _excluded=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],REACT_ROUTER_VERSION="6";try{window.__reactRouterVersion=REACT_ROUTER_VERSION}catch{}const START_TRANSITION="startTransition",startTransitionImpl=React$1[START_TRANSITION];function BrowserRouter(et){let{basename:o,children:tt,future:rt,window:nt}=et,ot=reactExports.useRef();ot.current==null&&(ot.current=createBrowserHistory({window:nt,v5Compat:!0}));let it=ot.current,[st,at]=reactExports.useState({action:it.action,location:it.location}),{v7_startTransition:ct}=rt||{},lt=reactExports.useCallback(dt=>{ct&&startTransitionImpl?startTransitionImpl(()=>at(dt)):at(dt)},[at,ct]);return reactExports.useLayoutEffect(()=>it.listen(lt),[it,lt]),reactExports.createElement(Router,{basename:o,children:tt,location:st.location,navigationType:st.action,navigator:it,future:rt})}const isBrowser$1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ABSOLUTE_URL_REGEX=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Link=reactExports.forwardRef(function(o,tt){let{onClick:rt,relative:nt,reloadDocument:ot,replace:it,state:st,target:at,to:ct,preventScrollReset:lt,viewTransition:dt}=o,ht=_objectWithoutPropertiesLoose$1(o,_excluded),{basename:mt}=reactExports.useContext(NavigationContext),ft,pt=!1;if(typeof ct=="string"&&ABSOLUTE_URL_REGEX.test(ct)&&(ft=ct,isBrowser$1))try{let xt=new URL(window.location.href),vt=ct.startsWith("//")?new URL(xt.protocol+ct):new URL(ct),Et=stripBasename(vt.pathname,mt);vt.origin===xt.origin&&Et!=null?ct=Et+vt.search+vt.hash:pt=!0}catch{}let gt=useHref(ct,{relative:nt}),yt=useLinkClickHandler(ct,{replace:it,state:st,target:at,preventScrollReset:lt,relative:nt,viewTransition:dt});function bt(xt){rt&&rt(xt),xt.defaultPrevented||yt(xt)}return reactExports.createElement("a",_extends({},ht,{href:ft||gt,onClick:pt||ot?rt:bt,ref:tt,target:at}))});var DataRouterHook;(function(et){et.UseScrollRestoration="useScrollRestoration",et.UseSubmit="useSubmit",et.UseSubmitFetcher="useSubmitFetcher",et.UseFetcher="useFetcher",et.useViewTransitionState="useViewTransitionState"})(DataRouterHook||(DataRouterHook={}));var DataRouterStateHook;(function(et){et.UseFetcher="useFetcher",et.UseFetchers="useFetchers",et.UseScrollRestoration="useScrollRestoration"})(DataRouterStateHook||(DataRouterStateHook={}));function useLinkClickHandler(et,o){let{target:tt,replace:rt,state:nt,preventScrollReset:ot,relative:it,viewTransition:st}=o===void 0?{}:o,at=useNavigate(),ct=useLocation(),lt=useResolvedPath(et,{relative:it});return reactExports.useCallback(dt=>{if(shouldProcessLinkClick(dt,tt)){dt.preventDefault();let ht=rt!==void 0?rt:createPath(ct)===createPath(lt);at(et,{replace:ht,state:nt,preventScrollReset:ot,relative:it,viewTransition:st})}},[ct,at,lt,rt,nt,tt,et,ot,it,st])}function setRef(et,o){typeof et=="function"?et(o):et!=null&&(et.current=o)}function composeRefs(...et){return o=>et.forEach(tt=>setRef(tt,o))}function useComposedRefs(...et){return reactExports.useCallback(composeRefs(...et),et)}var Slot=reactExports.forwardRef((et,o)=>{const{children:tt,...rt}=et,nt=reactExports.Children.toArray(tt),ot=nt.find(isSlottable);if(ot){const it=ot.props.children,st=nt.map(at=>at===ot?reactExports.Children.count(it)>1?reactExports.Children.only(null):reactExports.isValidElement(it)?it.props.children:null:at);return jsxRuntimeExports.jsx(SlotClone,{...rt,ref:o,children:reactExports.isValidElement(it)?reactExports.cloneElement(it,void 0,st):null})}return jsxRuntimeExports.jsx(SlotClone,{...rt,ref:o,children:tt})});Slot.displayName="Slot";var SlotClone=reactExports.forwardRef((et,o)=>{const{children:tt,...rt}=et;if(reactExports.isValidElement(tt)){const nt=getElementRef$1(tt);return reactExports.cloneElement(tt,{...mergeProps(rt,tt.props),ref:o?composeRefs(o,nt):nt})}return reactExports.Children.count(tt)>1?reactExports.Children.only(null):null});SlotClone.displayName="SlotClone";var Slottable=({children:et})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:et});function isSlottable(et){return reactExports.isValidElement(et)&&et.type===Slottable}function mergeProps(et,o){const tt={...o};for(const rt in o){const nt=et[rt],ot=o[rt];/^on[A-Z]/.test(rt)?nt&&ot?tt[rt]=(...st)=>{ot(...st),nt(...st)}:nt&&(tt[rt]=nt):rt==="style"?tt[rt]={...nt,...ot}:rt==="className"&&(tt[rt]=[nt,ot].filter(Boolean).join(" "))}return{...et,...tt}}function getElementRef$1(et){var rt,nt;let o=(rt=Object.getOwnPropertyDescriptor(et.props,"ref"))==null?void 0:rt.get,tt=o&&"isReactWarning"in o&&o.isReactWarning;return tt?et.ref:(o=(nt=Object.getOwnPropertyDescriptor(et,"ref"))==null?void 0:nt.get,tt=o&&"isReactWarning"in o&&o.isReactWarning,tt?et.props.ref:et.props.ref||et.ref)}function r$1(et){var o,tt,rt="";if(typeof et=="string"||typeof et=="number")rt+=et;else if(typeof et=="object")if(Array.isArray(et))for(o=0;otypeof et=="boolean"?"".concat(et):et===0?"0":et,cx=clsx$1,cva=(et,o)=>tt=>{var rt;if((o==null?void 0:o.variants)==null)return cx(et,tt==null?void 0:tt.class,tt==null?void 0:tt.className);const{variants:nt,defaultVariants:ot}=o,it=Object.keys(nt).map(ct=>{const lt=tt==null?void 0:tt[ct],dt=ot==null?void 0:ot[ct];if(lt===null)return null;const ht=falsyToString(lt)||falsyToString(dt);return nt[ct][ht]}),st=tt&&Object.entries(tt).reduce((ct,lt)=>{let[dt,ht]=lt;return ht===void 0||(ct[dt]=ht),ct},{}),at=o==null||(rt=o.compoundVariants)===null||rt===void 0?void 0:rt.reduce((ct,lt)=>{let{class:dt,className:ht,...mt}=lt;return Object.entries(mt).every(ft=>{let[pt,gt]=ft;return Array.isArray(gt)?gt.includes({...ot,...st}[pt]):{...ot,...st}[pt]===gt})?[...ct,dt,ht]:ct},[]);return cx(et,it,at,tt==null?void 0:tt.class,tt==null?void 0:tt.className)};function r(et){var o,tt,rt="";if(typeof et=="string"||typeof et=="number")rt+=et;else if(typeof et=="object")if(Array.isArray(et)){var nt=et.length;for(o=0;o{const o=createClassMap(et),{conflictingClassGroups:tt,conflictingClassGroupModifiers:rt}=et;return{getClassGroupId:it=>{const st=it.split(CLASS_PART_SEPARATOR);return st[0]===""&&st.length!==1&&st.shift(),getGroupRecursive(st,o)||getGroupIdForArbitraryProperty(it)},getConflictingClassGroupIds:(it,st)=>{const at=tt[it]||[];return st&&rt[it]?[...at,...rt[it]]:at}}},getGroupRecursive=(et,o)=>{var it;if(et.length===0)return o.classGroupId;const tt=et[0],rt=o.nextPart.get(tt),nt=rt?getGroupRecursive(et.slice(1),rt):void 0;if(nt)return nt;if(o.validators.length===0)return;const ot=et.join(CLASS_PART_SEPARATOR);return(it=o.validators.find(({validator:st})=>st(ot)))==null?void 0:it.classGroupId},arbitraryPropertyRegex=/^\[(.+)\]$/,getGroupIdForArbitraryProperty=et=>{if(arbitraryPropertyRegex.test(et)){const o=arbitraryPropertyRegex.exec(et)[1],tt=o==null?void 0:o.substring(0,o.indexOf(":"));if(tt)return"arbitrary.."+tt}},createClassMap=et=>{const{theme:o,prefix:tt}=et,rt={nextPart:new Map,validators:[]};return getPrefixedClassGroupEntries(Object.entries(et.classGroups),tt).forEach(([ot,it])=>{processClassesRecursively(it,rt,ot,o)}),rt},processClassesRecursively=(et,o,tt,rt)=>{et.forEach(nt=>{if(typeof nt=="string"){const ot=nt===""?o:getPart(o,nt);ot.classGroupId=tt;return}if(typeof nt=="function"){if(isThemeGetter(nt)){processClassesRecursively(nt(rt),o,tt,rt);return}o.validators.push({validator:nt,classGroupId:tt});return}Object.entries(nt).forEach(([ot,it])=>{processClassesRecursively(it,getPart(o,ot),tt,rt)})})},getPart=(et,o)=>{let tt=et;return o.split(CLASS_PART_SEPARATOR).forEach(rt=>{tt.nextPart.has(rt)||tt.nextPart.set(rt,{nextPart:new Map,validators:[]}),tt=tt.nextPart.get(rt)}),tt},isThemeGetter=et=>et.isThemeGetter,getPrefixedClassGroupEntries=(et,o)=>o?et.map(([tt,rt])=>{const nt=rt.map(ot=>typeof ot=="string"?o+ot:typeof ot=="object"?Object.fromEntries(Object.entries(ot).map(([it,st])=>[o+it,st])):ot);return[tt,nt]}):et,createLruCache=et=>{if(et<1)return{get:()=>{},set:()=>{}};let o=0,tt=new Map,rt=new Map;const nt=(ot,it)=>{tt.set(ot,it),o++,o>et&&(o=0,rt=tt,tt=new Map)};return{get(ot){let it=tt.get(ot);if(it!==void 0)return it;if((it=rt.get(ot))!==void 0)return nt(ot,it),it},set(ot,it){tt.has(ot)?tt.set(ot,it):nt(ot,it)}}},IMPORTANT_MODIFIER="!",createParseClassName=et=>{const{separator:o,experimentalParseClassName:tt}=et,rt=o.length===1,nt=o[0],ot=o.length,it=st=>{const at=[];let ct=0,lt=0,dt;for(let gt=0;gtlt?dt-lt:void 0;return{modifiers:at,hasImportantModifier:mt,baseClassName:ft,maybePostfixModifierPosition:pt}};return tt?st=>tt({className:st,parseClassName:it}):it},sortModifiers=et=>{if(et.length<=1)return et;const o=[];let tt=[];return et.forEach(rt=>{rt[0]==="["?(o.push(...tt.sort(),rt),tt=[]):tt.push(rt)}),o.push(...tt.sort()),o},createConfigUtils=et=>({cache:createLruCache(et.cacheSize),parseClassName:createParseClassName(et),...createClassGroupUtils(et)}),SPLIT_CLASSES_REGEX=/\s+/,mergeClassList=(et,o)=>{const{parseClassName:tt,getClassGroupId:rt,getConflictingClassGroupIds:nt}=o,ot=[],it=et.trim().split(SPLIT_CLASSES_REGEX);let st="";for(let at=it.length-1;at>=0;at-=1){const ct=it[at],{modifiers:lt,hasImportantModifier:dt,baseClassName:ht,maybePostfixModifierPosition:mt}=tt(ct);let ft=!!mt,pt=rt(ft?ht.substring(0,mt):ht);if(!pt){if(!ft){st=ct+(st.length>0?" "+st:st);continue}if(pt=rt(ht),!pt){st=ct+(st.length>0?" "+st:st);continue}ft=!1}const gt=sortModifiers(lt).join(":"),yt=dt?gt+IMPORTANT_MODIFIER:gt,bt=yt+pt;if(ot.includes(bt))continue;ot.push(bt);const xt=nt(pt,ft);for(let vt=0;vt0?" "+st:st)}return st};function twJoin(){let et=0,o,tt,rt="";for(;et{if(typeof et=="string")return et;let o,tt="";for(let rt=0;rtdt(lt),et());return tt=createConfigUtils(ct),rt=tt.cache.get,nt=tt.cache.set,ot=st,st(at)}function st(at){const ct=rt(at);if(ct)return ct;const lt=mergeClassList(at,tt);return nt(at,lt),lt}return function(){return ot(twJoin.apply(null,arguments))}}const fromTheme=et=>{const o=tt=>tt[et]||[];return o.isThemeGetter=!0,o},arbitraryValueRegex=/^\[(?:([a-z-]+):)?(.+)\]$/i,fractionRegex=/^\d+\/\d+$/,stringLengths=new Set(["px","full","screen"]),tshirtUnitRegex=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lengthUnitRegex=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,colorFunctionRegex=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,shadowRegex=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,imageRegex=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,isLength=et=>isNumber(et)||stringLengths.has(et)||fractionRegex.test(et),isArbitraryLength=et=>getIsArbitraryValue(et,"length",isLengthOnly),isNumber=et=>!!et&&!Number.isNaN(Number(et)),isArbitraryNumber=et=>getIsArbitraryValue(et,"number",isNumber),isInteger$1=et=>!!et&&Number.isInteger(Number(et)),isPercent=et=>et.endsWith("%")&&isNumber(et.slice(0,-1)),isArbitraryValue=et=>arbitraryValueRegex.test(et),isTshirtSize=et=>tshirtUnitRegex.test(et),sizeLabels=new Set(["length","size","percentage"]),isArbitrarySize=et=>getIsArbitraryValue(et,sizeLabels,isNever),isArbitraryPosition=et=>getIsArbitraryValue(et,"position",isNever),imageLabels=new Set(["image","url"]),isArbitraryImage=et=>getIsArbitraryValue(et,imageLabels,isImage),isArbitraryShadow=et=>getIsArbitraryValue(et,"",isShadow),isAny=()=>!0,getIsArbitraryValue=(et,o,tt)=>{const rt=arbitraryValueRegex.exec(et);return rt?rt[1]?typeof o=="string"?rt[1]===o:o.has(rt[1]):tt(rt[2]):!1},isLengthOnly=et=>lengthUnitRegex.test(et)&&!colorFunctionRegex.test(et),isNever=()=>!1,isShadow=et=>shadowRegex.test(et),isImage=et=>imageRegex.test(et),getDefaultConfig=()=>{const et=fromTheme("colors"),o=fromTheme("spacing"),tt=fromTheme("blur"),rt=fromTheme("brightness"),nt=fromTheme("borderColor"),ot=fromTheme("borderRadius"),it=fromTheme("borderSpacing"),st=fromTheme("borderWidth"),at=fromTheme("contrast"),ct=fromTheme("grayscale"),lt=fromTheme("hueRotate"),dt=fromTheme("invert"),ht=fromTheme("gap"),mt=fromTheme("gradientColorStops"),ft=fromTheme("gradientColorStopPositions"),pt=fromTheme("inset"),gt=fromTheme("margin"),yt=fromTheme("opacity"),bt=fromTheme("padding"),xt=fromTheme("saturate"),vt=fromTheme("scale"),Et=fromTheme("sepia"),Ct=fromTheme("skew"),St=fromTheme("space"),At=fromTheme("translate"),kt=()=>["auto","contain","none"],It=()=>["auto","hidden","clip","visible","scroll"],Ot=()=>["auto",isArbitraryValue,o],Nt=()=>[isArbitraryValue,o],Yt=()=>["",isLength,isArbitraryLength],Ft=()=>["auto",isNumber,isArbitraryValue],Ht=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Qt=()=>["solid","dashed","dotted","double","none"],Vt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Bt=()=>["start","end","center","between","around","evenly","stretch"],Wt=()=>["","0",isArbitraryValue],jt=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Xt=()=>[isNumber,isArbitraryValue];return{cacheSize:500,separator:":",theme:{colors:[isAny],spacing:[isLength,isArbitraryLength],blur:["none","",isTshirtSize,isArbitraryValue],brightness:Xt(),borderColor:[et],borderRadius:["none","","full",isTshirtSize,isArbitraryValue],borderSpacing:Nt(),borderWidth:Yt(),contrast:Xt(),grayscale:Wt(),hueRotate:Xt(),invert:Wt(),gap:Nt(),gradientColorStops:[et],gradientColorStopPositions:[isPercent,isArbitraryLength],inset:Ot(),margin:Ot(),opacity:Xt(),padding:Nt(),saturate:Xt(),scale:Xt(),sepia:Wt(),skew:Xt(),space:Nt(),translate:Nt()},classGroups:{aspect:[{aspect:["auto","square","video",isArbitraryValue]}],container:["container"],columns:[{columns:[isTshirtSize]}],"break-after":[{"break-after":jt()}],"break-before":[{"break-before":jt()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Ht(),isArbitraryValue]}],overflow:[{overflow:It()}],"overflow-x":[{"overflow-x":It()}],"overflow-y":[{"overflow-y":It()}],overscroll:[{overscroll:kt()}],"overscroll-x":[{"overscroll-x":kt()}],"overscroll-y":[{"overscroll-y":kt()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[pt]}],"inset-x":[{"inset-x":[pt]}],"inset-y":[{"inset-y":[pt]}],start:[{start:[pt]}],end:[{end:[pt]}],top:[{top:[pt]}],right:[{right:[pt]}],bottom:[{bottom:[pt]}],left:[{left:[pt]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",isInteger$1,isArbitraryValue]}],basis:[{basis:Ot()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",isArbitraryValue]}],grow:[{grow:Wt()}],shrink:[{shrink:Wt()}],order:[{order:["first","last","none",isInteger$1,isArbitraryValue]}],"grid-cols":[{"grid-cols":[isAny]}],"col-start-end":[{col:["auto",{span:["full",isInteger$1,isArbitraryValue]},isArbitraryValue]}],"col-start":[{"col-start":Ft()}],"col-end":[{"col-end":Ft()}],"grid-rows":[{"grid-rows":[isAny]}],"row-start-end":[{row:["auto",{span:[isInteger$1,isArbitraryValue]},isArbitraryValue]}],"row-start":[{"row-start":Ft()}],"row-end":[{"row-end":Ft()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",isArbitraryValue]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",isArbitraryValue]}],gap:[{gap:[ht]}],"gap-x":[{"gap-x":[ht]}],"gap-y":[{"gap-y":[ht]}],"justify-content":[{justify:["normal",...Bt()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Bt(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Bt(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[bt]}],px:[{px:[bt]}],py:[{py:[bt]}],ps:[{ps:[bt]}],pe:[{pe:[bt]}],pt:[{pt:[bt]}],pr:[{pr:[bt]}],pb:[{pb:[bt]}],pl:[{pl:[bt]}],m:[{m:[gt]}],mx:[{mx:[gt]}],my:[{my:[gt]}],ms:[{ms:[gt]}],me:[{me:[gt]}],mt:[{mt:[gt]}],mr:[{mr:[gt]}],mb:[{mb:[gt]}],ml:[{ml:[gt]}],"space-x":[{"space-x":[St]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[St]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",isArbitraryValue,o]}],"min-w":[{"min-w":[isArbitraryValue,o,"min","max","fit"]}],"max-w":[{"max-w":[isArbitraryValue,o,"none","full","min","max","fit","prose",{screen:[isTshirtSize]},isTshirtSize]}],h:[{h:[isArbitraryValue,o,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[isArbitraryValue,o,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[isArbitraryValue,o,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[isArbitraryValue,o,"auto","min","max","fit"]}],"font-size":[{text:["base",isTshirtSize,isArbitraryLength]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",isArbitraryNumber]}],"font-family":[{font:[isAny]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",isArbitraryValue]}],"line-clamp":[{"line-clamp":["none",isNumber,isArbitraryNumber]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",isLength,isArbitraryValue]}],"list-image":[{"list-image":["none",isArbitraryValue]}],"list-style-type":[{list:["none","disc","decimal",isArbitraryValue]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[et]}],"placeholder-opacity":[{"placeholder-opacity":[yt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[et]}],"text-opacity":[{"text-opacity":[yt]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Qt(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",isLength,isArbitraryLength]}],"underline-offset":[{"underline-offset":["auto",isLength,isArbitraryValue]}],"text-decoration-color":[{decoration:[et]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Nt()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",isArbitraryValue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",isArbitraryValue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[yt]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Ht(),isArbitraryPosition]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",isArbitrarySize]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},isArbitraryImage]}],"bg-color":[{bg:[et]}],"gradient-from-pos":[{from:[ft]}],"gradient-via-pos":[{via:[ft]}],"gradient-to-pos":[{to:[ft]}],"gradient-from":[{from:[mt]}],"gradient-via":[{via:[mt]}],"gradient-to":[{to:[mt]}],rounded:[{rounded:[ot]}],"rounded-s":[{"rounded-s":[ot]}],"rounded-e":[{"rounded-e":[ot]}],"rounded-t":[{"rounded-t":[ot]}],"rounded-r":[{"rounded-r":[ot]}],"rounded-b":[{"rounded-b":[ot]}],"rounded-l":[{"rounded-l":[ot]}],"rounded-ss":[{"rounded-ss":[ot]}],"rounded-se":[{"rounded-se":[ot]}],"rounded-ee":[{"rounded-ee":[ot]}],"rounded-es":[{"rounded-es":[ot]}],"rounded-tl":[{"rounded-tl":[ot]}],"rounded-tr":[{"rounded-tr":[ot]}],"rounded-br":[{"rounded-br":[ot]}],"rounded-bl":[{"rounded-bl":[ot]}],"border-w":[{border:[st]}],"border-w-x":[{"border-x":[st]}],"border-w-y":[{"border-y":[st]}],"border-w-s":[{"border-s":[st]}],"border-w-e":[{"border-e":[st]}],"border-w-t":[{"border-t":[st]}],"border-w-r":[{"border-r":[st]}],"border-w-b":[{"border-b":[st]}],"border-w-l":[{"border-l":[st]}],"border-opacity":[{"border-opacity":[yt]}],"border-style":[{border:[...Qt(),"hidden"]}],"divide-x":[{"divide-x":[st]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[st]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[yt]}],"divide-style":[{divide:Qt()}],"border-color":[{border:[nt]}],"border-color-x":[{"border-x":[nt]}],"border-color-y":[{"border-y":[nt]}],"border-color-s":[{"border-s":[nt]}],"border-color-e":[{"border-e":[nt]}],"border-color-t":[{"border-t":[nt]}],"border-color-r":[{"border-r":[nt]}],"border-color-b":[{"border-b":[nt]}],"border-color-l":[{"border-l":[nt]}],"divide-color":[{divide:[nt]}],"outline-style":[{outline:["",...Qt()]}],"outline-offset":[{"outline-offset":[isLength,isArbitraryValue]}],"outline-w":[{outline:[isLength,isArbitraryLength]}],"outline-color":[{outline:[et]}],"ring-w":[{ring:Yt()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[et]}],"ring-opacity":[{"ring-opacity":[yt]}],"ring-offset-w":[{"ring-offset":[isLength,isArbitraryLength]}],"ring-offset-color":[{"ring-offset":[et]}],shadow:[{shadow:["","inner","none",isTshirtSize,isArbitraryShadow]}],"shadow-color":[{shadow:[isAny]}],opacity:[{opacity:[yt]}],"mix-blend":[{"mix-blend":[...Vt(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Vt()}],filter:[{filter:["","none"]}],blur:[{blur:[tt]}],brightness:[{brightness:[rt]}],contrast:[{contrast:[at]}],"drop-shadow":[{"drop-shadow":["","none",isTshirtSize,isArbitraryValue]}],grayscale:[{grayscale:[ct]}],"hue-rotate":[{"hue-rotate":[lt]}],invert:[{invert:[dt]}],saturate:[{saturate:[xt]}],sepia:[{sepia:[Et]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[tt]}],"backdrop-brightness":[{"backdrop-brightness":[rt]}],"backdrop-contrast":[{"backdrop-contrast":[at]}],"backdrop-grayscale":[{"backdrop-grayscale":[ct]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[lt]}],"backdrop-invert":[{"backdrop-invert":[dt]}],"backdrop-opacity":[{"backdrop-opacity":[yt]}],"backdrop-saturate":[{"backdrop-saturate":[xt]}],"backdrop-sepia":[{"backdrop-sepia":[Et]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[it]}],"border-spacing-x":[{"border-spacing-x":[it]}],"border-spacing-y":[{"border-spacing-y":[it]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",isArbitraryValue]}],duration:[{duration:Xt()}],ease:[{ease:["linear","in","out","in-out",isArbitraryValue]}],delay:[{delay:Xt()}],animate:[{animate:["none","spin","ping","pulse","bounce",isArbitraryValue]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[vt]}],"scale-x":[{"scale-x":[vt]}],"scale-y":[{"scale-y":[vt]}],rotate:[{rotate:[isInteger$1,isArbitraryValue]}],"translate-x":[{"translate-x":[At]}],"translate-y":[{"translate-y":[At]}],"skew-x":[{"skew-x":[Ct]}],"skew-y":[{"skew-y":[Ct]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",isArbitraryValue]}],accent:[{accent:["auto",et]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",isArbitraryValue]}],"caret-color":[{caret:[et]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Nt()}],"scroll-mx":[{"scroll-mx":Nt()}],"scroll-my":[{"scroll-my":Nt()}],"scroll-ms":[{"scroll-ms":Nt()}],"scroll-me":[{"scroll-me":Nt()}],"scroll-mt":[{"scroll-mt":Nt()}],"scroll-mr":[{"scroll-mr":Nt()}],"scroll-mb":[{"scroll-mb":Nt()}],"scroll-ml":[{"scroll-ml":Nt()}],"scroll-p":[{"scroll-p":Nt()}],"scroll-px":[{"scroll-px":Nt()}],"scroll-py":[{"scroll-py":Nt()}],"scroll-ps":[{"scroll-ps":Nt()}],"scroll-pe":[{"scroll-pe":Nt()}],"scroll-pt":[{"scroll-pt":Nt()}],"scroll-pr":[{"scroll-pr":Nt()}],"scroll-pb":[{"scroll-pb":Nt()}],"scroll-pl":[{"scroll-pl":Nt()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",isArbitraryValue]}],fill:[{fill:[et,"none"]}],"stroke-w":[{stroke:[isLength,isArbitraryLength,isArbitraryNumber]}],stroke:[{stroke:[et,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},twMerge=createTailwindMerge(getDefaultConfig);function cn(...et){return twMerge(clsx(et))}const buttonVariants=cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Button=reactExports.forwardRef(({className:et,variant:o,size:tt,asChild:rt=!1,...nt},ot)=>{const it=rt?Slot:"button";return jsxRuntimeExports.jsx(it,{className:cn(buttonVariants({variant:o,size:tt,className:et})),ref:ot,...nt})});Button.displayName="Button";function allocUnsafe$j(et=0){return new Uint8Array(et)}const N1$6=Math.pow(2,7),N2$6=Math.pow(2,14),N3$6=Math.pow(2,21),N4$6=Math.pow(2,28),N5$6=Math.pow(2,35),N6$6=Math.pow(2,42),N7$6=Math.pow(2,49),MSB$8=128,REST$8=127;function encodingLength$6(et){if(etNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function encodeUint8Array(et,o,tt=0){switch(encodingLength$6(et)){case 8:o[tt++]=et&255|MSB$8,et/=128;case 7:o[tt++]=et&255|MSB$8,et/=128;case 6:o[tt++]=et&255|MSB$8,et/=128;case 5:o[tt++]=et&255|MSB$8,et/=128;case 4:o[tt++]=et&255|MSB$8,et>>>=7;case 3:o[tt++]=et&255|MSB$8,et>>>=7;case 2:o[tt++]=et&255|MSB$8,et>>>=7;case 1:{o[tt++]=et&255,et>>>=7;break}default:throw new Error("unreachable")}return o}function encodeUint8ArrayList(et,o,tt=0){switch(encodingLength$6(et)){case 8:o.set(tt++,et&255|MSB$8),et/=128;case 7:o.set(tt++,et&255|MSB$8),et/=128;case 6:o.set(tt++,et&255|MSB$8),et/=128;case 5:o.set(tt++,et&255|MSB$8),et/=128;case 4:o.set(tt++,et&255|MSB$8),et>>>=7;case 3:o.set(tt++,et&255|MSB$8),et>>>=7;case 2:o.set(tt++,et&255|MSB$8),et>>>=7;case 1:{o.set(tt++,et&255),et>>>=7;break}default:throw new Error("unreachable")}return o}function decodeUint8Array(et,o){let tt=et[o],rt=0;if(rt+=tt&REST$8,tt>>31>0){const tt=~this.lo+1>>>0;let rt=~this.hi>>>0;return tt===0&&(rt=rt+1>>>0),-(tt+rt*4294967296)}return this.lo+this.hi*4294967296}toBigInt(o=!1){if(o)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){const tt=~this.lo+1>>>0;let rt=~this.hi>>>0;return tt===0&&(rt=rt+1>>>0),-(BigInt(tt)+(BigInt(rt)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(o=!1){return this.toBigInt(o).toString()}zzEncode(){const o=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^o)>>>0,this.lo=(this.lo<<1^o)>>>0,this}zzDecode(){const o=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^o)>>>0,this.hi=(this.hi>>>1^o)>>>0,this}length(){const o=this.lo,tt=(this.lo>>>28|this.hi<<4)>>>0,rt=this.hi>>>24;return rt===0?tt===0?o<16384?o<128?1:2:o<2097152?3:4:tt<16384?tt<128?5:6:tt<2097152?7:8:rt<128?9:10}static fromBigInt(o){if(o===0n)return zero;if(oMIN_SAFE_NUMBER_INTEGER)return this.fromNumber(Number(o));const tt=o<0n;tt&&(o=-o);let rt=o>>32n,nt=o-(rt<<32n);return tt&&(rt=~rt|0n,nt=~nt|0n,++nt>TWO_32&&(nt=0n,++rt>TWO_32&&(rt=0n))),new Sn(Number(nt),Number(rt))}static fromNumber(o){if(o===0)return zero;const tt=o<0;tt&&(o=-o);let rt=o>>>0,nt=(o-rt)/4294967296>>>0;return tt&&(nt=~nt>>>0,rt=~rt>>>0,++rt>4294967295&&(rt=0,++nt>4294967295&&(nt=0))),new Sn(rt,nt)}static from(o){return typeof o=="number"?Sn.fromNumber(o):typeof o=="bigint"?Sn.fromBigInt(o):typeof o=="string"?Sn.fromBigInt(BigInt(o)):o.low!=null||o.high!=null?new Sn(o.low>>>0,o.high>>>0):zero}};const zero=new LongBits$2(0,0);zero.toBigInt=function(){return 0n};zero.zzEncode=zero.zzDecode=function(){return this};zero.length=function(){return 1};const TWO_32=4294967296n;function length$6(et){let o=0,tt=0;for(let rt=0;rt191&&st<224?ot[it++]=(st&31)<<6|et[o++]&63:st>239&&st<365?(st=((st&7)<<18|(et[o++]&63)<<12|(et[o++]&63)<<6|et[o++]&63)-65536,ot[it++]=55296+(st>>10),ot[it++]=56320+(st&1023)):ot[it++]=(st&15)<<12|(et[o++]&63)<<6|et[o++]&63,it>8191&&((nt??(nt=[])).push(String.fromCharCode.apply(String,ot)),it=0);return nt!=null?(it>0&&nt.push(String.fromCharCode.apply(String,ot.slice(0,it))),nt.join("")):String.fromCharCode.apply(String,ot.slice(0,it))}function write$2(et,o,tt){const rt=tt;let nt,ot;for(let it=0;it>6|192,o[tt++]=nt&63|128):(nt&64512)===55296&&((ot=et.charCodeAt(it+1))&64512)===56320?(nt=65536+((nt&1023)<<10)+(ot&1023),++it,o[tt++]=nt>>18|240,o[tt++]=nt>>12&63|128,o[tt++]=nt>>6&63|128,o[tt++]=nt&63|128):(o[tt++]=nt>>12|224,o[tt++]=nt>>6&63|128,o[tt++]=nt&63|128);return tt-rt}function indexOutOfRange$1(et,o){return RangeError(`index out of range: ${et.pos} + ${o??1} > ${et.len}`)}function readFixed32End(et,o){return(et[o-4]|et[o-3]<<8|et[o-2]<<16|et[o-1]<<24)>>>0}class Uint8ArrayReader{constructor(o){wt(this,"buf");wt(this,"pos");wt(this,"len");wt(this,"_slice",Uint8Array.prototype.subarray);this.buf=o,this.pos=0,this.len=o.length}uint32(){let o=4294967295;if(o=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(o=(o|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return o;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange$1(this,10);return o}int32(){return this.uint32()|0}sint32(){const o=this.uint32();return o>>>1^-(o&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);return readFixed32End(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);return readFixed32End(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);const o=readFloatLE(this.buf,this.pos);return this.pos+=4,o}double(){if(this.pos+8>this.len)throw indexOutOfRange$1(this,4);const o=readDoubleLE(this.buf,this.pos);return this.pos+=8,o}bytes(){const o=this.uint32(),tt=this.pos,rt=this.pos+o;if(rt>this.len)throw indexOutOfRange$1(this,o);return this.pos+=o,tt===rt?new Uint8Array(0):this.buf.subarray(tt,rt)}string(){const o=this.bytes();return read$7(o,0,o.length)}skip(o){if(typeof o=="number"){if(this.pos+o>this.len)throw indexOutOfRange$1(this,o);this.pos+=o}else do if(this.pos>=this.len)throw indexOutOfRange$1(this);while(this.buf[this.pos++]&128);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(;(o=this.uint32()&7)!==4;)this.skipType(o);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${o} at offset ${this.pos}`)}return this}readLongVarint(){const o=new LongBits$2(0,0);let tt=0;if(this.len-this.pos>4){for(;tt<4;++tt)if(o.lo=(o.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return o;if(o.lo=(o.lo|(this.buf[this.pos]&127)<<28)>>>0,o.hi=(o.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return o;tt=0}else{for(;tt<3;++tt){if(this.pos>=this.len)throw indexOutOfRange$1(this);if(o.lo=(o.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return o}return o.lo=(o.lo|(this.buf[this.pos++]&127)<>>0,o}if(this.len-this.pos>4){for(;tt<5;++tt)if(o.hi=(o.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return o}else for(;tt<5;++tt){if(this.pos>=this.len)throw indexOutOfRange$1(this);if(o.hi=(o.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return o}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange$1(this,8);const o=readFixed32End(this.buf,this.pos+=4),tt=readFixed32End(this.buf,this.pos+=4);return new LongBits$2(o,tt)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const o=decodeUint8Array(this.buf,this.pos);return this.pos+=encodingLength$6(o),o}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(et){return new Uint8ArrayReader(et instanceof Uint8Array?et:et.subarray())}function decodeMessage(et,o,tt){const rt=createReader(et);return o.decode(rt,void 0,tt)}function allocUnsafe$i(et=0){return new Uint8Array(et)}function coerce$l(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$w(et){return new TextEncoder().encode(et)}function toString$x(et){return new TextDecoder().decode(et)}function base$l(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$l=base$l,_brrp__multiformats_scope_baseX$k=src$l;let Encoder$m=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$m=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$m(this,o)}},ComposedDecoder$k=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$m(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$m(et,o){return new ComposedDecoder$k({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$k=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$m(o,tt,rt),this.decoder=new Decoder$m(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$n({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$k(et,o,tt,rt)}function baseX$k({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$k(tt,et);return from$n({prefix:o,name:et,encode:rt,decode:ot=>coerce$l(nt(ot))})}function decode$Y(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$O(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$g=alphabet$g.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$N(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$g[tt],o),"")}function decode$X(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$g[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$w=from$n({prefix:"🚀",name:"base256emoji",encode:encode$N,decode:decode$X}),base256emoji$x=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$w},Symbol.toStringTag,{value:"Module"})),base32$A=rfc4648$j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$g=rfc4648$j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$g=rfc4648$j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$g=rfc4648$j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$g=rfc4648$j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$g=rfc4648$j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$g=rfc4648$j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$g=rfc4648$j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$g=rfc4648$j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$B=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$A,base32hex:base32hex$g,base32hexpad:base32hexpad$g,base32hexpadupper:base32hexpadupper$g,base32hexupper:base32hexupper$g,base32pad:base32pad$g,base32padupper:base32padupper$g,base32upper:base32upper$g,base32z:base32z$g},Symbol.toStringTag,{value:"Module"})),base36$x=baseX$k({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$g=baseX$k({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$y=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$x,base36upper:base36upper$g},Symbol.toStringTag,{value:"Module"})),base58btc$k=baseX$k({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$g=baseX$k({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$g=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$k,base58flickr:base58flickr$g},Symbol.toStringTag,{value:"Module"})),base64$z=rfc4648$j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$g=rfc4648$j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$h=rfc4648$j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$g=rfc4648$j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$A=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$z,base64pad:base64pad$g,base64url:base64url$h,base64urlpad:base64urlpad$g},Symbol.toStringTag,{value:"Module"})),base8$w=rfc4648$j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$x=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$w},Symbol.toStringTag,{value:"Module"})),identity$i=from$n({prefix:"\0",name:"identity",encode:et=>toString$x(et),decode:et=>fromString$w(et)}),identityBase$g=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$i},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$g={...identityBase$g,...base2$x,...base8$x,...base10$x,...base16$x,...base32$B,...base36$y,...base58$g,...base64$A,...base256emoji$x};function createCodec$h(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$k=createCodec$h("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$g=createCodec$h("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$i(et.length);for(let tt=0;tt4096)return allocUnsafe$i(it);nt+it>8192&&(rt=allocUnsafe$i(8192),nt=0);const st=rt.subarray(nt,nt+=it);return nt&7&&(nt=(nt|7)+1),st}}let Op$1=class{constructor(o,tt,rt){wt(this,"fn");wt(this,"len");wt(this,"next");wt(this,"val");this.fn=o,this.len=tt,this.next=void 0,this.val=rt}};function noop$2(){}let State$1=class{constructor(o){wt(this,"head");wt(this,"tail");wt(this,"len");wt(this,"next");this.head=o.head,this.tail=o.tail,this.len=o.len,this.next=o.states}};const bufferPool=pool$1();function alloc$7(et){return globalThis.Buffer!=null?allocUnsafe$i(et):bufferPool(et)}class Uint8ArrayWriter{constructor(){wt(this,"len");wt(this,"head");wt(this,"tail");wt(this,"states");this.len=0,this.head=new Op$1(noop$2,0,0),this.tail=this.head,this.states=null}_push(o,tt,rt){return this.tail=this.tail.next=new Op$1(o,tt,rt),this.len+=tt,this}uint32(o){return this.len+=(this.tail=this.tail.next=new VarintOp$1((o=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$1,10,LongBits$2.fromNumber(o)):this.uint32(o)}sint32(o){return this.uint32((o<<1^o>>31)>>>0)}uint64(o){const tt=LongBits$2.fromBigInt(o);return this._push(writeVarint64$1,tt.length(),tt)}uint64Number(o){return this._push(encodeUint8Array,encodingLength$6(o),o)}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){const tt=LongBits$2.fromBigInt(o).zzEncode();return this._push(writeVarint64$1,tt.length(),tt)}sint64Number(o){const tt=LongBits$2.fromNumber(o).zzEncode();return this._push(writeVarint64$1,tt.length(),tt)}sint64String(o){return this.sint64(BigInt(o))}bool(o){return this._push(writeByte$1,1,o?1:0)}fixed32(o){return this._push(writeFixed32$1,4,o>>>0)}sfixed32(o){return this.fixed32(o)}fixed64(o){const tt=LongBits$2.fromBigInt(o);return this._push(writeFixed32$1,4,tt.lo)._push(writeFixed32$1,4,tt.hi)}fixed64Number(o){const tt=LongBits$2.fromNumber(o);return this._push(writeFixed32$1,4,tt.lo)._push(writeFixed32$1,4,tt.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){const tt=o.length>>>0;return tt===0?this._push(writeByte$1,1,0):this.uint32(tt)._push(writeBytes$1,tt,o)}string(o){const tt=length$6(o);return tt!==0?this.uint32(tt)._push(write$2,tt,o):this._push(writeByte$1,1,0)}fork(){return this.states=new State$1(this),this.head=this.tail=new Op$1(noop$2,0,0),this.len=0,this}reset(){return this.states!=null?(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$1(noop$2,0,0),this.len=0),this}ldelim(){const o=this.head,tt=this.tail,rt=this.len;return this.reset().uint32(rt),rt!==0&&(this.tail.next=o.next,this.tail=tt,this.len+=rt),this}finish(){let o=this.head.next;const tt=alloc$7(this.len);let rt=0;for(;o!=null;)o.fn(o.val,tt,rt),rt+=o.len,o=o.next;return tt}}function writeByte$1(et,o,tt){o[tt]=et&255}function writeVarint32$1(et,o,tt){for(;et>127;)o[tt++]=et&127|128,et>>>=7;o[tt]=et}let VarintOp$1=class extends Op$1{constructor(tt,rt){super(writeVarint32$1,tt,rt);wt(this,"next");this.next=void 0}};function writeVarint64$1(et,o,tt){for(;et.hi!==0;)o[tt++]=et.lo&127|128,et.lo=(et.lo>>>7|et.hi<<25)>>>0,et.hi>>>=7;for(;et.lo>127;)o[tt++]=et.lo&127|128,et.lo=et.lo>>>7;o[tt++]=et.lo}function writeFixed32$1(et,o,tt){o[tt]=et&255,o[tt+1]=et>>>8&255,o[tt+2]=et>>>16&255,o[tt+3]=et>>>24}function writeBytes$1(et,o,tt){o.set(et,tt)}globalThis.Buffer!=null&&(Uint8ArrayWriter.prototype.bytes=function(et){const o=et.length>>>0;return this.uint32(o),o>0&&this._push(writeBytesBuffer,o,et),this},Uint8ArrayWriter.prototype.string=function(et){const o=globalThis.Buffer.byteLength(et);return this.uint32(o),o>0&&this._push(writeStringBuffer$1,o,et),this});function writeBytesBuffer(et,o,tt){o.set(et,tt)}function writeStringBuffer$1(et,o,tt){et.length<40?write$2(et,o,tt):o.utf8Write!=null?o.utf8Write(et,tt):o.set(fromString$v(et),tt)}function createWriter(){return new Uint8ArrayWriter}function encodeMessage(et,o){const tt=createWriter();return o.encode(et,tt,{lengthDelimited:!1}),tt.finish()}var CODEC_TYPES;(function(et){et[et.VARINT=0]="VARINT",et[et.BIT64=1]="BIT64",et[et.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",et[et.START_GROUP=3]="START_GROUP",et[et.END_GROUP=4]="END_GROUP",et[et.BIT32=5]="BIT32"})(CODEC_TYPES||(CODEC_TYPES={}));function createCodec$g(et,o,tt,rt){return{name:et,type:o,encode:tt,decode:rt}}function enumeration(et){function o(nt){if(et[nt.toString()]==null)throw new Error("Invalid enum value");return et[nt]}const tt=function(ot,it){const st=o(ot);it.int32(st)},rt=function(ot){const it=ot.int32();return o(it)};return createCodec$g("enum",CODEC_TYPES.VARINT,tt,rt)}function message$1(et,o){return createCodec$g("message",CODEC_TYPES.LENGTH_DELIMITED,et,o)}class MaxLengthError extends Error{constructor(){super(...arguments);wt(this,"code","ERR_MAX_LENGTH");wt(this,"name","MaxLengthError")}}class MaxSizeError extends Error{constructor(){super(...arguments);wt(this,"code","ERR_MAX_SIZE");wt(this,"name","MaxSizeError")}}function alloc$6(et=0){return globalThis.Buffer!=null&&globalThis.Buffer.alloc!=null?globalThis.Buffer.alloc(et):new Uint8Array(et)}function allocUnsafe$h(et=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(et):new Uint8Array(et)}var RateLimitProof$4;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof$4||(RateLimitProof$4={}));var WakuMessage$4;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof$4.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$4.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage$4||(WakuMessage$4={}));var FilterRequest;(function(et){(function(tt){let rt;tt.codec=()=>(rt==null&&(rt=message$1((nt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),nt.contentTopic!=null&&nt.contentTopic!==""&&(ot.uint32(10),ot.string(nt.contentTopic)),it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{const st={contentTopic:""},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.contentTopic=nt.string();break}default:{nt.skipType(ct&7);break}}}return st})),rt),tt.encode=nt=>encodeMessage(nt,tt.codec()),tt.decode=(nt,ot)=>decodeMessage(nt,tt.codec(),ot)})(et.ContentFilter||(et.ContentFilter={}));let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.subscribe!=null&&tt.subscribe!==!1&&(rt.uint32(8),rt.bool(tt.subscribe)),tt.topic!=null&&tt.topic!==""&&(rt.uint32(18),rt.string(tt.topic)),tt.contentFilters!=null)for(const ot of tt.contentFilters)rt.uint32(26),et.ContentFilter.codec().encode(ot,rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={subscribe:!1,topic:"",contentFilters:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.subscribe=tt.bool();break}case 2:{ot.topic=tt.string();break}case 3:{if(((st=nt.limits)==null?void 0:st.contentFilters)!=null&&ot.contentFilters.length===nt.limits.contentFilters)throw new MaxLengthError('Decode error - map field "contentFilters" had too many elements');ot.contentFilters.push(et.ContentFilter.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.contentFilters$}));break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(FilterRequest||(FilterRequest={}));var MessagePush$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.messages!=null)for(const ot of tt.messages)rt.uint32(10),WakuMessage$3.codec().encode(ot,rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={messages:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{if(((st=nt.limits)==null?void 0:st.messages)!=null&&ot.messages.length===nt.limits.messages)throw new MaxLengthError('Decode error - map field "messages" had too many elements');ot.messages.push(WakuMessage$3.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.messages$}));break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(MessagePush$1||(MessagePush$1={}));var FilterRpc;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.request!=null&&(rt.uint32(18),FilterRequest.codec().encode(tt.request,rt)),tt.push!=null&&(rt.uint32(26),MessagePush$1.codec().encode(tt.push,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={requestId:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.request=FilterRequest.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.request});break}case 3:{ot.push=MessagePush$1.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.push});break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(FilterRpc||(FilterRpc={}));var RateLimitProof$3;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof$3||(RateLimitProof$3={}));var WakuMessage$3;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof$3.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$3.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage$3||(WakuMessage$3={}));var TopicOnlyMessage;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 2:{ot.contentTopic=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(TopicOnlyMessage||(TopicOnlyMessage={}));var FilterSubscribeRequest;(function(et){let o;(function(nt){nt.SUBSCRIBER_PING="SUBSCRIBER_PING",nt.SUBSCRIBE="SUBSCRIBE",nt.UNSUBSCRIBE="UNSUBSCRIBE",nt.UNSUBSCRIBE_ALL="UNSUBSCRIBE_ALL"})(o=et.FilterSubscribeType||(et.FilterSubscribeType={}));let tt;(function(nt){nt[nt.SUBSCRIBER_PING=0]="SUBSCRIBER_PING",nt[nt.SUBSCRIBE=1]="SUBSCRIBE",nt[nt.UNSUBSCRIBE=2]="UNSUBSCRIBE",nt[nt.UNSUBSCRIBE_ALL=3]="UNSUBSCRIBE_ALL"})(tt||(tt={})),function(nt){nt.codec=()=>enumeration(tt)}(o=et.FilterSubscribeType||(et.FilterSubscribeType={}));let rt;et.codec=()=>(rt==null&&(rt=message$1((nt,ot,it={})=>{if(it.lengthDelimited!==!1&&ot.fork(),nt.requestId!=null&&nt.requestId!==""&&(ot.uint32(10),ot.string(nt.requestId)),nt.filterSubscribeType!=null&&tt[nt.filterSubscribeType]!==0&&(ot.uint32(16),et.FilterSubscribeType.codec().encode(nt.filterSubscribeType,ot)),nt.pubsubTopic!=null&&(ot.uint32(82),ot.string(nt.pubsubTopic)),nt.contentTopics!=null)for(const st of nt.contentTopics)ot.uint32(90),ot.string(st);it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{var ct;const st={requestId:"",filterSubscribeType:o.SUBSCRIBER_PING,contentTopics:[]},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.requestId=nt.string();break}case 2:{st.filterSubscribeType=et.FilterSubscribeType.codec().decode(nt);break}case 10:{st.pubsubTopic=nt.string();break}case 11:{if(((ct=it.limits)==null?void 0:ct.contentTopics)!=null&&st.contentTopics.length===it.limits.contentTopics)throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');st.contentTopics.push(nt.string());break}default:{nt.skipType(lt&7);break}}}return st})),rt),et.encode=nt=>encodeMessage(nt,et.codec()),et.decode=(nt,ot)=>decodeMessage(nt,et.codec(),ot)})(FilterSubscribeRequest||(FilterSubscribeRequest={}));var FilterSubscribeResponse$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.statusCode!=null&&tt.statusCode!==0&&(rt.uint32(80),rt.uint32(tt.statusCode)),tt.statusDesc!=null&&(rt.uint32(90),rt.string(tt.statusDesc)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={requestId:"",statusCode:0},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 10:{ot.statusCode=tt.uint32();break}case 11:{ot.statusDesc=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(FilterSubscribeResponse$1||(FilterSubscribeResponse$1={}));var MessagePush;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.wakuMessage!=null&&(rt.uint32(10),WakuMessage$2.codec().encode(tt.wakuMessage,rt)),tt.pubsubTopic!=null&&(rt.uint32(18),rt.string(tt.pubsubTopic)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.wakuMessage=WakuMessage$2.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.wakuMessage});break}case 2:{ot.pubsubTopic=tt.string();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(MessagePush||(MessagePush={}));var RateLimitProof$2;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof$2||(RateLimitProof$2={}));var WakuMessage$2;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof$2.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$2.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage$2||(WakuMessage$2={}));var PushRequest;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.pubsubTopic!=null&&tt.pubsubTopic!==""&&(rt.uint32(10),rt.string(tt.pubsubTopic)),tt.message!=null&&(rt.uint32(18),WakuMessage$1.codec().encode(tt.message,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={pubsubTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.pubsubTopic=tt.string();break}case 2:{ot.message=WakuMessage$1.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.message});break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PushRequest||(PushRequest={}));var PushResponse;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.isSuccess!=null&&tt.isSuccess!==!1&&(rt.uint32(8),rt.bool(tt.isSuccess)),tt.info!=null&&(rt.uint32(18),rt.string(tt.info)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={isSuccess:!1},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.isSuccess=tt.bool();break}case 2:{ot.info=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PushResponse||(PushResponse={}));var PushRpc$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.request!=null&&(rt.uint32(18),PushRequest.codec().encode(tt.request,rt)),tt.response!=null&&(rt.uint32(26),PushResponse.codec().encode(tt.response,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={requestId:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.request=PushRequest.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.request});break}case 3:{ot.response=PushResponse.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.response});break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PushRpc$1||(PushRpc$1={}));var RateLimitProof$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof$1||(RateLimitProof$1={}));var WakuMessage$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof$1.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$1.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage$1||(WakuMessage$1={}));var WakuMessageKeyValue;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.messageHash!=null&&(rt.uint32(10),rt.bytes(tt.messageHash)),tt.message!=null&&(rt.uint32(18),WakuMessage.codec().encode(tt.message,rt)),tt.pubsubTopic!=null&&(rt.uint32(26),rt.string(tt.pubsubTopic)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.messageHash=tt.bytes();break}case 2:{ot.message=WakuMessage.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.message});break}case 3:{ot.pubsubTopic=tt.string();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessageKeyValue||(WakuMessageKeyValue={}));var StoreQueryRequest$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.includeData!=null&&tt.includeData!==!1&&(rt.uint32(16),rt.bool(tt.includeData)),tt.pubsubTopic!=null&&(rt.uint32(82),rt.string(tt.pubsubTopic)),tt.contentTopics!=null)for(const ot of tt.contentTopics)rt.uint32(90),rt.string(ot);if(tt.timeStart!=null&&(rt.uint32(96),rt.sint64(tt.timeStart)),tt.timeEnd!=null&&(rt.uint32(104),rt.sint64(tt.timeEnd)),tt.messageHashes!=null)for(const ot of tt.messageHashes)rt.uint32(162),rt.bytes(ot);tt.paginationCursor!=null&&(rt.uint32(410),rt.bytes(tt.paginationCursor)),tt.paginationForward!=null&&tt.paginationForward!==!1&&(rt.uint32(416),rt.bool(tt.paginationForward)),tt.paginationLimit!=null&&(rt.uint32(424),rt.uint64(tt.paginationLimit)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={requestId:"",includeData:!1,contentTopics:[],messageHashes:[],paginationForward:!1},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.includeData=tt.bool();break}case 10:{ot.pubsubTopic=tt.string();break}case 11:{if(((st=nt.limits)==null?void 0:st.contentTopics)!=null&&ot.contentTopics.length===nt.limits.contentTopics)throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');ot.contentTopics.push(tt.string());break}case 12:{ot.timeStart=tt.sint64();break}case 13:{ot.timeEnd=tt.sint64();break}case 20:{if(((at=nt.limits)==null?void 0:at.messageHashes)!=null&&ot.messageHashes.length===nt.limits.messageHashes)throw new MaxLengthError('Decode error - map field "messageHashes" had too many elements');ot.messageHashes.push(tt.bytes());break}case 51:{ot.paginationCursor=tt.bytes();break}case 52:{ot.paginationForward=tt.bool();break}case 53:{ot.paginationLimit=tt.uint64();break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(StoreQueryRequest$1||(StoreQueryRequest$1={}));var StoreQueryResponse$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.statusCode!=null&&(rt.uint32(80),rt.uint32(tt.statusCode)),tt.statusDesc!=null&&(rt.uint32(90),rt.string(tt.statusDesc)),tt.messages!=null)for(const ot of tt.messages)rt.uint32(162),WakuMessageKeyValue.codec().encode(ot,rt);tt.paginationCursor!=null&&(rt.uint32(410),rt.bytes(tt.paginationCursor)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={requestId:"",messages:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 10:{ot.statusCode=tt.uint32();break}case 11:{ot.statusDesc=tt.string();break}case 20:{if(((st=nt.limits)==null?void 0:st.messages)!=null&&ot.messages.length===nt.limits.messages)throw new MaxLengthError('Decode error - map field "messages" had too many elements');ot.messages.push(WakuMessageKeyValue.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.messages$}));break}case 51:{ot.paginationCursor=tt.bytes();break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(StoreQueryResponse$1||(StoreQueryResponse$1={}));var RateLimitProof;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof||(RateLimitProof={}));var WakuMessage;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage||(WakuMessage={}));var PeerInfo;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.enr!=null&&(rt.uint32(10),rt.bytes(tt.enr)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.enr=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerInfo||(PeerInfo={}));var PeerExchangeQuery;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.numPeers!=null&&(rt.uint32(8),rt.uint64(tt.numPeers)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.numPeers=tt.uint64();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerExchangeQuery||(PeerExchangeQuery={}));var PeerExchangeResponse;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.peerInfos!=null)for(const ot of tt.peerInfos)rt.uint32(10),PeerInfo.codec().encode(ot,rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={peerInfos:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{if(((st=nt.limits)==null?void 0:st.peerInfos)!=null&&ot.peerInfos.length===nt.limits.peerInfos)throw new MaxLengthError('Decode error - map field "peerInfos" had too many elements');ot.peerInfos.push(PeerInfo.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.peerInfos$}));break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerExchangeResponse||(PeerExchangeResponse={}));var PeerExchangeRPC$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.query!=null&&(rt.uint32(10),PeerExchangeQuery.codec().encode(tt.query,rt)),tt.response!=null&&(rt.uint32(18),PeerExchangeResponse.codec().encode(tt.response,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.query=PeerExchangeQuery.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.query});break}case 2:{ot.response=PeerExchangeResponse.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.response});break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerExchangeRPC$1||(PeerExchangeRPC$1={}));var WakuMetadataRequest;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.clusterId!=null&&(rt.uint32(8),rt.uint32(tt.clusterId)),tt.shards!=null)for(const ot of tt.shards)rt.uint32(16),rt.uint32(ot);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={shards:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.clusterId=tt.uint32();break}case 2:{if(((st=nt.limits)==null?void 0:st.shards)!=null&&ot.shards.length===nt.limits.shards)throw new MaxLengthError('Decode error - map field "shards" had too many elements');ot.shards.push(tt.uint32());break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMetadataRequest||(WakuMetadataRequest={}));var WakuMetadataResponse;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.clusterId!=null&&(rt.uint32(8),rt.uint32(tt.clusterId)),tt.shards!=null)for(const ot of tt.shards)rt.uint32(16),rt.uint32(ot);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={shards:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.clusterId=tt.uint32();break}case 2:{if(((st=nt.limits)==null?void 0:st.shards)!=null&&ot.shards.length===nt.limits.shards)throw new MaxLengthError('Decode error - map field "shards" had too many elements');ot.shards.push(tt.uint32());break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMetadataResponse||(WakuMetadataResponse={}));function isDefined(et){return!!et}function groupByContentTopic(et){const o=new Map;return et.forEach(tt=>{let rt=o.get(tt.contentTopic);rt||(o.set(tt.contentTopic,[]),rt=o.get(tt.contentTopic)),rt.push(tt)}),o}const FRAME_RATE=60;async function toAsyncIterator(et,o,tt){const rt=FRAME_RATE,nt=[];let ot;ot=await et.subscribeWithUnsubscribe(o,lt=>{nt.push(lt)});const it=Number.isInteger(tt==null?void 0:tt.timeoutMs),st=0,at=Date.now();async function*ct(){for(;;){if(it&&Date.now()-at>=st)return;await wait(rt);const lt=nt.shift();if(!ot&&nt.length===0)return lt;!lt&&ot||(yield lt)}}return{iterator:ct(),async stop(){ot&&(await ot(),ot=void 0)}}}function wait(et){return new Promise(o=>{setTimeout(o,et)})}const MB=1024**2,SIZE_CAP_IN_MB=1;async function isMessageSizeUnderCap(et,o){const tt=await et.toWire(o);return tt?isWireSizeUnderCap(tt):!1}const isWireSizeUnderCap=et=>et.length/MB<=SIZE_CAP_IN_MB;var Protocols;(function(et){et.Relay="relay",et.Store="store",et.LightPush="lightpush",et.Filter="filter"})(Protocols||(Protocols={}));var ProtocolError$1;(function(et){et.GENERIC_FAIL="Generic error",et.ENCODE_FAILED="Failed to encode",et.DECODE_FAILED="Failed to decode",et.EMPTY_PAYLOAD="Payload is empty",et.SIZE_TOO_BIG="Size is too big",et.TOPIC_NOT_CONFIGURED="Topic not configured",et.TOPIC_DECODER_MISMATCH="Topic decoder mismatch",et.INVALID_DECODER_TOPICS="Invalid decoder topics",et.NO_PEER_AVAILABLE="No peer available",et.NO_STREAM_AVAILABLE="No stream available",et.NO_RESPONSE="No response received",et.REMOTE_PEER_REJECTED="Remote peer rejected",et.REQUEST_TIMEOUT="Request timeout",et.RLN_IDENTITY_MISSING="Identity credentials are not set",et.RLN_MEMBERSHIP_INDEX="Membership index is not set",et.RLN_LIMIT_MISSING="User message limit is not set",et.RLN_PROOF_GENERATION="Proof generation failed"})(ProtocolError$1||(ProtocolError$1={}));var Tags;(function(et){et.BOOTSTRAP="bootstrap",et.PEER_EXCHANGE="peer-exchange",et.LOCAL="local-peer-cache"})(Tags||(Tags={}));var EPeersByDiscoveryEvents;(function(et){et.PEER_DISCOVERY_BOOTSTRAP="peer:discovery:bootstrap",et.PEER_DISCOVERY_PEER_EXCHANGE="peer:discovery:peer-exchange",et.PEER_CONNECT_BOOTSTRAP="peer:connected:bootstrap",et.PEER_CONNECT_PEER_EXCHANGE="peer:connected:peer-exchange"})(EPeersByDiscoveryEvents||(EPeersByDiscoveryEvents={}));var EConnectionStateEvents;(function(et){et.CONNECTION_STATUS="waku:connection"})(EConnectionStateEvents||(EConnectionStateEvents={}));const DNS_DISCOVERY_TAG="@waku/bootstrap",DEFAULT_CLUSTER_ID=1,DefaultShardInfo={clusterId:DEFAULT_CLUSTER_ID,shards:[0,1,2,3,4,5,6,7,8]},DefaultNetworkConfig=DefaultShardInfo;var HealthStatus;(function(et){et.Unhealthy="Unhealthy",et.MinimallyHealthy="MinimallyHealthy",et.SufficientlyHealthy="SufficientlyHealthy"})(HealthStatus||(HealthStatus={}));function coerce$k(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$u(et){return new TextEncoder().encode(et)}function toString$w(et){return new TextDecoder().decode(et)}function base$k(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$k=base$k,_brrp__multiformats_scope_baseX$j=src$k;let Encoder$l=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$l=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$l(this,o)}},ComposedDecoder$j=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$l(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$l(et,o){return new ComposedDecoder$j({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$j=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$l(o,tt,rt),this.decoder=new Decoder$l(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$m({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$j(et,o,tt,rt)}function baseX$j({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$j(tt,et);return from$m({prefix:o,name:et,encode:rt,decode:ot=>coerce$k(nt(ot))})}function decode$W(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$M(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$f=alphabet$f.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$L(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$f[tt],o),"")}function decode$V(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$f[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$u=from$m({prefix:"🚀",name:"base256emoji",encode:encode$L,decode:decode$V}),base256emoji$v=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$u},Symbol.toStringTag,{value:"Module"})),base32$y=rfc4648$i({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$f=rfc4648$i({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$f=rfc4648$i({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$f=rfc4648$i({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$f=rfc4648$i({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$f=rfc4648$i({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$f=rfc4648$i({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$f=rfc4648$i({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$f=rfc4648$i({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$z=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$y,base32hex:base32hex$f,base32hexpad:base32hexpad$f,base32hexpadupper:base32hexpadupper$f,base32hexupper:base32hexupper$f,base32pad:base32pad$f,base32padupper:base32padupper$f,base32upper:base32upper$f,base32z:base32z$f},Symbol.toStringTag,{value:"Module"})),base36$v=baseX$j({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$f=baseX$j({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$w=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$v,base36upper:base36upper$f},Symbol.toStringTag,{value:"Module"})),base58btc$j=baseX$j({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$f=baseX$j({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$f=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$j,base58flickr:base58flickr$f},Symbol.toStringTag,{value:"Module"})),base64$x=rfc4648$i({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$f=rfc4648$i({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$g=rfc4648$i({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$f=rfc4648$i({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$y=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$x,base64pad:base64pad$f,base64url:base64url$g,base64urlpad:base64urlpad$f},Symbol.toStringTag,{value:"Module"})),base8$u=rfc4648$i({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$v=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$u},Symbol.toStringTag,{value:"Module"})),identity$h=from$m({prefix:"\0",name:"identity",encode:et=>toString$w(et),decode:et=>fromString$u(et)}),identityBase$f=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$h},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$f={...identityBase$f,...base2$v,...base8$v,...base10$v,...base16$v,...base32$z,...base36$w,...base58$f,...base64$y,...base256emoji$v};function allocUnsafe$g(et=0){return new Uint8Array(et)}function createCodec$f(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$j=createCodec$f("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$f=createCodec$f("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$g(et.length);for(let tt=0;tttoString$v(et,"base16"),bytesToUtf8=et=>toString$v(et,"utf8"),utf8ToBytes$1=et=>fromString$t(et,"utf8");function concat$5(et,o){const tt=et.reduce((ot,it)=>ot+it.length,0),rt=new Uint8Array(tt);let nt=0;for(const ot of et)rt.set(ot,nt),nt+=ot.length;return rt}function isStaticSharding(et){return"clusterId"in et&&"shards"in et&&!("contentTopics"in et)}function isAutoSharding(et){return"contentTopics"in et}function derivePubsubTopicsFromNetworkConfig(et){if(isStaticSharding(et)){if(et.shards.length===0)throw new Error("Invalid shards configuration: please provide at least one shard");return shardInfoToPubsubTopics(et)}else if(isAutoSharding(et)){if(et.contentTopics.length===0)throw new Error("Invalid content topics configuration: please provide at least one content topic");return et.contentTopics.map(o=>contentTopicToPubsubTopic(o,et.clusterId))}else throw new Error("Unknown shard config. Please use ShardInfo or ContentTopicInfo")}const singleShardInfoToPubsubTopic=et=>{if(et.shard===void 0)throw new Error("Invalid shard");return`/waku/2/rs/${et.clusterId??DEFAULT_CLUSTER_ID}/${et.shard}`},shardInfoToPubsubTopics=et=>{if("contentTopics"in et&&et.contentTopics)return Array.from(new Set(et.contentTopics.map(o=>contentTopicToPubsubTopic(o,et.clusterId))));if("shards"in et){if(et.shards===void 0)throw new Error("Invalid shard");return Array.from(new Set(et.shards.map(o=>`/waku/2/rs/${et.clusterId??DEFAULT_CLUSTER_ID}/${o}`)))}else{if("application"in et&&"version"in et)return[contentTopicToPubsubTopic(`/${et.application}/${et.version}/default/default`,et.clusterId)];throw new Error("Missing required configuration in shard parameters")}},pubsubTopicToSingleShardInfo=et=>{const o=et.split("/");if(o.length!=6||o[1]!=="waku"||o[2]!=="2"||o[3]!=="rs")throw new Error("Invalid pubsub topic");const tt=parseInt(o[4]),rt=parseInt(o[5]);if(isNaN(tt)||isNaN(rt))throw new Error("Invalid clusterId or shard");return{clusterId:tt,shard:rt}},pubsubTopicsToShardInfo=et=>{const o=new Set,tt=new Set;for(const ot of et){const{clusterId:it,shard:st}=pubsubTopicToSingleShardInfo(ot);o.add(`${it}:${st}`),tt.add(it)}if(o.size===0)throw new Error("No valid pubsub topics provided");if(tt.size>1)throw new Error("Pubsub topics from multiple cluster IDs are not supported");const rt=tt.values().next().value,nt=Array.from(o).map(ot=>parseInt(ot.split(":")[1]));return{clusterId:rt,shards:nt}};function ensurePubsubTopicIsConfigured(et,o){if(!o.includes(et))throw new Error(`Pubsub topic ${et} has not been configured on this instance. Configured topics are: ${o}. Please update your configuration by passing in the topic during Waku node instantiation.`)}function ensureValidContentTopic(et){const o=et.split("/");if(o.length<5||o.length>6)throw Error("Content topic format is invalid");let tt=0;if(o.length==6){if(tt=parseInt(o[1]),isNaN(tt))throw new Error("Invalid generation field in content topic");if(tt>0)throw new Error("Generation greater than 0 is not supported")}const rt=o.splice(-4);if(rt[0].length==0)throw new Error("Application field cannot be empty");if(rt[1].length==0)throw new Error("Version field cannot be empty");if(rt[2].length==0)throw new Error("Topic name field cannot be empty");if(rt[3].length==0)throw new Error("Encoding field cannot be empty");return{generation:tt,application:rt[0],version:rt[1],topicName:rt[2],encoding:rt[3]}}function contentTopicToShardIndex(et,o=8){const{application:tt,version:rt}=ensureValidContentTopic(et),nt=sha256$3(concat$5([utf8ToBytes$1(tt),utf8ToBytes$1(rt)])),ot=new DataView(nt.buffer.slice(-8));return Number(ot.getBigUint64(0,!1)%BigInt(o))}function contentTopicToPubsubTopic(et,o=DEFAULT_CLUSTER_ID,tt=8){if(!et)throw Error("Content topic must be specified");const rt=contentTopicToShardIndex(et,tt);return`/waku/2/rs/${o}/${rt}`}function determinePubsubTopic(et,o){return typeof o=="string"?o:(o==null?void 0:o.shard)!==void 0?singleShardInfoToPubsubTopic(o):contentTopicToPubsubTopic(et,(o==null?void 0:o.clusterId)??DEFAULT_CLUSTER_ID)}const decodeRelayShard=et=>{if(et=new Uint8Array(et),et.length<3)throw new Error("Insufficient data");const o=new DataView(et.buffer),tt=o.getUint16(0),rt=[];if(et.length===130)for(let nt=0;nt<1024;nt++){const ot=Math.floor(nt/8)+2,it=7-nt%8;o.getUint8(ot)&1<=et.length)throw new Error("Unexpected end of data");rt.push(o.getUint16(it))}}return{clusterId:tt,shards:rt}},encodeRelayShard=et=>{const{clusterId:o,shards:tt}=et,rt=tt.length>=64?130:3+2*tt.length,nt=new ArrayBuffer(rt),ot=new DataView(nt);if(ot.setUint16(0,o),tt.length>=64)for(const it of tt){const st=Math.floor(it/8)+2,at=7-it%8;ot.setUint8(st,ot.getUint8(st)|1<tt.toString().includes("ws")||tt.toString().includes("wss"));if(!o)throw new Error("No ws multiaddr found in the given addresses");return o}var browser={exports:{}},ms$1,hasRequiredMs;function requireMs(){if(hasRequiredMs)return ms$1;hasRequiredMs=1;var et=1e3,o=et*60,tt=o*60,rt=tt*24,nt=rt*7,ot=rt*365.25;ms$1=function(lt,dt){dt=dt||{};var ht=typeof lt;if(ht==="string"&<.length>0)return it(lt);if(ht==="number"&&isFinite(lt))return dt.long?at(lt):st(lt);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(lt))};function it(lt){if(lt=String(lt),!(lt.length>100)){var dt=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(lt);if(dt){var ht=parseFloat(dt[1]),mt=(dt[2]||"ms").toLowerCase();switch(mt){case"years":case"year":case"yrs":case"yr":case"y":return ht*ot;case"weeks":case"week":case"w":return ht*nt;case"days":case"day":case"d":return ht*rt;case"hours":case"hour":case"hrs":case"hr":case"h":return ht*tt;case"minutes":case"minute":case"mins":case"min":case"m":return ht*o;case"seconds":case"second":case"secs":case"sec":case"s":return ht*et;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return ht;default:return}}}}function st(lt){var dt=Math.abs(lt);return dt>=rt?Math.round(lt/rt)+"d":dt>=tt?Math.round(lt/tt)+"h":dt>=o?Math.round(lt/o)+"m":dt>=et?Math.round(lt/et)+"s":lt+"ms"}function at(lt){var dt=Math.abs(lt);return dt>=rt?ct(lt,dt,rt,"day"):dt>=tt?ct(lt,dt,tt,"hour"):dt>=o?ct(lt,dt,o,"minute"):dt>=et?ct(lt,dt,et,"second"):lt+" ms"}function ct(lt,dt,ht,mt){var ft=dt>=ht*1.5;return Math.round(lt/ht)+" "+mt+(ft?"s":"")}return ms$1}function setup$1(et){tt.debug=tt,tt.default=tt,tt.coerce=at,tt.disable=ot,tt.enable=nt,tt.enabled=it,tt.humanize=requireMs(),tt.destroy=ct,Object.keys(et).forEach(lt=>{tt[lt]=et[lt]}),tt.names=[],tt.skips=[],tt.formatters={};function o(lt){let dt=0;for(let ht=0;ht{if(Ct==="%%")return"%";vt++;const At=tt.formatters[St];if(typeof At=="function"){const kt=gt[vt];Ct=At.call(yt,kt),gt.splice(vt,1),vt--}return Ct}),tt.formatArgs.call(yt,gt),(yt.log||tt.log).apply(yt,gt)}return pt.namespace=lt,pt.useColors=tt.useColors(),pt.color=tt.selectColor(lt),pt.extend=rt,pt.destroy=tt.destroy,Object.defineProperty(pt,"enabled",{enumerable:!0,configurable:!1,get:()=>ht!==null?ht:(mt!==tt.namespaces&&(mt=tt.namespaces,ft=tt.enabled(lt)),ft),set:gt=>{ht=gt}}),typeof tt.init=="function"&&tt.init(pt),pt}function rt(lt,dt){const ht=tt(this.namespace+(typeof dt>"u"?":":dt)+lt);return ht.log=this.log,ht}function nt(lt){tt.save(lt),tt.namespaces=lt,tt.names=[],tt.skips=[];let dt;const ht=(typeof lt=="string"?lt:"").split(/[\s,]+/),mt=ht.length;for(dt=0;dt"-"+dt)].join(",");return tt.enable(""),lt}function it(lt){if(lt[lt.length-1]==="*")return!0;let dt,ht;for(dt=0,ht=tt.skips.length;dt{let ct=!1;return()=>{ct||(ct=!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`."))}})(),o.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"];function rt(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let ct;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(ct=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(ct[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function nt(ct){if(ct[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+ct[0]+(this.useColors?"%c ":" ")+"+"+et.exports.humanize(this.diff),!this.useColors)return;const lt="color: "+this.color;ct.splice(1,0,lt,"color: inherit");let dt=0,ht=0;ct[0].replace(/%[a-zA-Z%]/g,mt=>{mt!=="%%"&&(dt++,mt==="%c"&&(ht=dt))}),ct.splice(ht,0,lt)}o.log=console.debug||console.log||(()=>{});function ot(ct){try{ct?o.storage.setItem("debug",ct):o.storage.removeItem("debug")}catch{}}function it(){let ct;try{ct=o.storage.getItem("debug")}catch{}return!ct&&typeof process<"u"&&"env"in process&&(ct=tt.DEBUG),ct}function st(){try{return localStorage}catch{}}et.exports=common$1(o);const{formatters:at}=et.exports;at.j=function(ct){try{return JSON.stringify(ct)}catch(lt){return"[UnexpectedJSONParseError]: "+lt.message}}})(browser,browser.exports);var browserExports=browser.exports;const debug=getDefaultExportFromCjs(browserExports),APP_NAME="waku";let Logger$1=class Jo{constructor(o){wt(this,"_info");wt(this,"_warn");wt(this,"_error");this._info=debug(Jo.createDebugNamespace("info",o)),this._warn=debug(Jo.createDebugNamespace("warn",o)),this._error=debug(Jo.createDebugNamespace("error",o))}static createDebugNamespace(o,tt){return tt?`${APP_NAME}:${o}:${tt}`:`${APP_NAME}:${o}`}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}log(o,...tt){const rt=this[o];rt(...tt)}};const log$o=new Logger$1("message:version-0"),OneMillion=BigInt(1e6),Version=0;class DecodedMessage{constructor(o,tt){wt(this,"pubsubTopic");wt(this,"proto");this.pubsubTopic=o,this.proto=tt}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){const o=this.proto.timestamp/OneMillion;return new Date(Number(o))}return}catch{return}}get meta(){return this.proto.meta}get version(){return this.proto.version??0}get rateLimitProof(){return this.proto.rateLimitProof}}let Encoder$k=class{constructor(o,tt=!1,rt,nt){wt(this,"contentTopic");wt(this,"ephemeral");wt(this,"pubsubTopic");wt(this,"metaSetter");if(this.contentTopic=o,this.ephemeral=tt,this.pubsubTopic=rt,this.metaSetter=nt,!o||o==="")throw new Error("Content topic must be specified")}async toWire(o){return WakuMessage$4.encode(await this.toProtoObj(o))}async toProtoObj(o){const tt=o.timestamp??new Date,rt={payload:o.payload,version:Version,contentTopic:this.contentTopic,timestamp:BigInt(tt.valueOf())*OneMillion,meta:void 0,rateLimitProof:o.rateLimitProof,ephemeral:this.ephemeral};if(this.metaSetter){const nt=this.metaSetter(rt);return{...rt,meta:nt}}return rt}};function createEncoder({pubsubTopic:et,pubsubTopicShardInfo:o,contentTopic:tt,ephemeral:rt,metaSetter:nt}){return new Encoder$k(tt,rt,determinePubsubTopic(tt,et??o),nt)}let Decoder$k=class{constructor(o,tt){wt(this,"pubsubTopic");wt(this,"contentTopic");if(this.pubsubTopic=o,this.contentTopic=tt,!tt||tt==="")throw new Error("Content topic must be specified")}fromWireToProtoObj(o){const tt=WakuMessage$4.decode(o);return Promise.resolve({payload:tt.payload,contentTopic:tt.contentTopic,version:tt.version??void 0,timestamp:tt.timestamp??void 0,meta:tt.meta??void 0,rateLimitProof:tt.rateLimitProof??void 0,ephemeral:tt.ephemeral??!1})}async fromProtoObj(o,tt){return tt.version??Version!==0?(log$o.error("Failed to decode due to incorrect version, expected:",Version,", actual:",tt.version),Promise.resolve(void 0)):new DecodedMessage(o,tt)}};function createDecoder(et,o){return new Decoder$k(determinePubsubTopic(et,o),et)}function isAsyncIterable$8(et){return et[Symbol.asyncIterator]!=null}function all$2(et){if(isAsyncIterable$8(et))return(async()=>{const tt=[];for await(const rt of et)tt.push(rt);return tt})();const o=[];for(const tt of et)o.push(tt);return o}function alloc$5(et=0){return new Uint8Array(et)}function allocUnsafe$f(et=0){return new Uint8Array(et)}function asUint8Array$3(et){return et}function concat$4(et,o){o==null&&(o=et.reduce((nt,ot)=>nt+ot.length,0));const tt=allocUnsafe$f(o);let rt=0;for(const nt of et)tt.set(nt,rt),rt+=nt.length;return tt}function equals$f(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt0&&this.appendAll(o)}*[(Ys=symbol$1,Symbol.iterator)](){yield*this.bufs}get byteLength(){return this.length}append(...o){this.appendAll(o)}appendAll(o){let tt=0;for(const rt of o)if(rt instanceof Uint8Array)tt+=rt.byteLength,this.bufs.push(rt);else if(isUint8ArrayList(rt))tt+=rt.byteLength,this.bufs.push(...rt.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=tt}prepend(...o){this.prependAll(o)}prependAll(o){let tt=0;for(const rt of o.reverse())if(rt instanceof Uint8Array)tt+=rt.byteLength,this.bufs.unshift(rt);else if(isUint8ArrayList(rt))tt+=rt.byteLength,this.bufs.unshift(...rt.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=tt}get(o){const tt=findBufAndOffset(this.bufs,o);return tt.buf[tt.index]}set(o,tt){const rt=findBufAndOffset(this.bufs,o);rt.buf[rt.index]=tt}write(o,tt=0){if(o instanceof Uint8Array)for(let rt=0;rt0;)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,tt){const{bufs:rt,length:nt}=this._subList(o,tt);return concat$4(rt,nt)}subarray(o,tt){const{bufs:rt,length:nt}=this._subList(o,tt);return rt.length===1?rt[0]:concat$4(rt,nt)}sublist(o,tt){const{bufs:rt,length:nt}=this._subList(o,tt),ot=new Uint8ArrayList;return ot.length=nt,ot.bufs=[...rt],ot}_subList(o,tt){if(o=o??0,tt=tt??this.length,o<0&&(o=this.length+o),tt<0&&(tt=this.length+tt),o<0||tt>this.length)throw new RangeError("index is out of bounds");if(o===tt)return{bufs:[],length:0};if(o===0&&tt===this.length)return{bufs:this.bufs,length:this.length};const rt=[];let nt=0;for(let ot=0;ot=at)continue;const ct=o>=st&&ost&&tt<=at;if(ct&<){if(o===st&&tt===at){rt.push(it);break}const dt=o-st;rt.push(it.subarray(dt,dt+(tt-o)));break}if(ct){if(o===0){rt.push(it);continue}rt.push(it.subarray(o-st));continue}if(lt){if(tt===at){rt.push(it);break}rt.push(it.subarray(0,tt-st));break}rt.push(it)}return{bufs:rt,length:tt-o}}indexOf(o,tt=0){if(!isUint8ArrayList(o)&&!(o instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');const rt=o instanceof Uint8Array?o:o.subarray();if(tt=Number(tt??0),isNaN(tt)&&(tt=0),tt<0&&(tt=this.length+tt),tt<0&&(tt=0),o.length===0)return tt>this.length?this.length:tt;const nt=rt.byteLength;if(nt===0)throw new TypeError("search must be at least 1 byte long");const ot=256,it=new Int32Array(ot);for(let dt=0;dt=0;ht--){const mt=this.get(dt+ht);if(rt[ht]!==mt){lt=Math.max(1,ht-st[mt]);break}}if(lt===0)return dt}return-1}getInt8(o){const tt=this.subarray(o,o+1);return new DataView(tt.buffer,tt.byteOffset,tt.byteLength).getInt8(0)}setInt8(o,tt){const rt=allocUnsafe$f(1);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setInt8(0,tt),this.write(rt,o)}getInt16(o,tt){const rt=this.subarray(o,o+2);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getInt16(0,tt)}setInt16(o,tt,rt){const nt=alloc$5(2);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setInt16(0,tt,rt),this.write(nt,o)}getInt32(o,tt){const rt=this.subarray(o,o+4);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getInt32(0,tt)}setInt32(o,tt,rt){const nt=alloc$5(4);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setInt32(0,tt,rt),this.write(nt,o)}getBigInt64(o,tt){const rt=this.subarray(o,o+8);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getBigInt64(0,tt)}setBigInt64(o,tt,rt){const nt=alloc$5(8);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setBigInt64(0,tt,rt),this.write(nt,o)}getUint8(o){const tt=this.subarray(o,o+1);return new DataView(tt.buffer,tt.byteOffset,tt.byteLength).getUint8(0)}setUint8(o,tt){const rt=allocUnsafe$f(1);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setUint8(0,tt),this.write(rt,o)}getUint16(o,tt){const rt=this.subarray(o,o+2);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getUint16(0,tt)}setUint16(o,tt,rt){const nt=alloc$5(2);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setUint16(0,tt,rt),this.write(nt,o)}getUint32(o,tt){const rt=this.subarray(o,o+4);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getUint32(0,tt)}setUint32(o,tt,rt){const nt=alloc$5(4);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setUint32(0,tt,rt),this.write(nt,o)}getBigUint64(o,tt){const rt=this.subarray(o,o+8);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getBigUint64(0,tt)}setBigUint64(o,tt,rt){const nt=alloc$5(8);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setBigUint64(0,tt,rt),this.write(nt,o)}getFloat32(o,tt){const rt=this.subarray(o,o+4);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getFloat32(0,tt)}setFloat32(o,tt,rt){const nt=alloc$5(4);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setFloat32(0,tt,rt),this.write(nt,o)}getFloat64(o,tt){const rt=this.subarray(o,o+8);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getFloat64(0,tt)}setFloat64(o,tt,rt){const nt=alloc$5(8);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setFloat64(0,tt,rt),this.write(nt,o)}equals(o){if(o==null||!(o instanceof Uint8ArrayList)||o.bufs.length!==this.bufs.length)return!1;for(let tt=0;ttnt+ot.byteLength,0)),rt.length=tt,rt}}function allocUnsafe$e(et=0){return new Uint8Array(et)}function isAsyncIterable$7(et){return et[Symbol.asyncIterator]!=null}const defaultEncoder=et=>{const o=encodingLength$6(et),tt=allocUnsafe$e(o);return encode$P(et,tt),defaultEncoder.bytes=o,tt};defaultEncoder.bytes=0;function encode$K(et,o){o=o??{};const tt=o.lengthEncoder??defaultEncoder;function*rt(nt){const ot=tt(nt.byteLength);ot instanceof Uint8Array?yield ot:yield*ot,nt instanceof Uint8Array?yield nt:yield*nt}return isAsyncIterable$7(et)?async function*(){for await(const nt of et)yield*rt(nt)}():function*(){for(const nt of et)yield*rt(nt)}()}encode$K.single=(et,o)=>{o=o??{};const tt=o.lengthEncoder??defaultEncoder;return new Uint8ArrayList(tt(et.byteLength),et)};let InvalidMessageLengthError$1=class extends Error{constructor(){super(...arguments);wt(this,"name","InvalidMessageLengthError");wt(this,"code","ERR_INVALID_MSG_LENGTH")}},InvalidDataLengthError$1=class extends Error{constructor(){super(...arguments);wt(this,"name","InvalidDataLengthError");wt(this,"code","ERR_MSG_DATA_TOO_LONG")}},InvalidDataLengthLengthError$1=class extends Error{constructor(){super(...arguments);wt(this,"name","InvalidDataLengthLengthError");wt(this,"code","ERR_MSG_LENGTH_TOO_LONG")}},UnexpectedEOFError$1=class extends Error{constructor(){super(...arguments);wt(this,"name","UnexpectedEOFError");wt(this,"code","ERR_UNEXPECTED_EOF")}};const MAX_LENGTH_LENGTH=8,MAX_DATA_LENGTH=1024*1024*4;var ReadMode;(function(et){et[et.LENGTH=0]="LENGTH",et[et.DATA=1]="DATA"})(ReadMode||(ReadMode={}));const defaultDecoder=et=>{const o=decode$Z(et);return defaultDecoder.bytes=encodingLength$6(o),o};defaultDecoder.bytes=0;function decode$U(et,o){const tt=new Uint8ArrayList;let rt=ReadMode.LENGTH,nt=-1;const ot=(o==null?void 0:o.lengthDecoder)??defaultDecoder,it=(o==null?void 0:o.maxLengthLength)??MAX_LENGTH_LENGTH,st=(o==null?void 0:o.maxDataLength)??MAX_DATA_LENGTH;function*at(){for(;tt.byteLength>0;){if(rt===ReadMode.LENGTH)try{if(nt=ot(tt),nt<0)throw new InvalidMessageLengthError$1("Invalid message length");if(nt>st)throw new InvalidDataLengthError$1("Message length too long");const ct=ot.bytes;tt.consume(ct),(o==null?void 0:o.onLength)!=null&&o.onLength(nt),rt=ReadMode.DATA}catch(ct){if(ct instanceof RangeError){if(tt.byteLength>it)throw new InvalidDataLengthLengthError$1("Message length length too long");break}throw ct}if(rt===ReadMode.DATA){if(tt.byteLength0)throw new UnexpectedEOFError$1("Unexpected end of input")}():function*(){for(const ct of et)tt.append(ct),yield*at();if(tt.byteLength>0)throw new UnexpectedEOFError$1("Unexpected end of input")}()}decode$U.fromReader=(et,o)=>{let tt=1;const rt=async function*(){for(;;)try{const{done:ot,value:it}=await et.next(tt);if(ot===!0)return;it!=null&&(yield it)}catch(ot){if(ot.code==="ERR_UNDER_READ")return{done:!0,value:null};throw ot}finally{tt=1}}();return decode$U(rt,{...o??{},onLength:ot=>{tt=ot}})};function pDefer(){const et={};return et.promise=new Promise((o,tt)=>{et.resolve=o,et.reject=tt}),et}class FixedFIFO{constructor(o){wt(this,"buffer");wt(this,"mask");wt(this,"top");wt(this,"btm");wt(this,"next");if(!(o>0)||o-1&o)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(o),this.mask=o-1,this.top=0,this.btm=0,this.next=null}push(o){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=o,this.top=this.top+1&this.mask,!0)}shift(){const o=this.buffer[this.btm];if(o!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,o}isEmpty(){return this.buffer[this.btm]===void 0}}class FIFO{constructor(o={}){wt(this,"size");wt(this,"hwm");wt(this,"head");wt(this,"tail");this.hwm=o.splitLimit??16,this.head=new FixedFIFO(this.hwm),this.tail=this.head,this.size=0}calculateSize(o){return(o==null?void 0:o.byteLength)!=null?o.byteLength:1}push(o){if((o==null?void 0:o.value)!=null&&(this.size+=this.calculateSize(o.value)),!this.head.push(o)){const tt=this.head;this.head=tt.next=new FixedFIFO(2*this.head.buffer.length),this.head.push(o)}}shift(){let o=this.tail.shift();if(o===void 0&&this.tail.next!=null){const tt=this.tail.next;this.tail.next=null,this.tail=tt,o=this.tail.shift()}return(o==null?void 0:o.value)!=null&&(this.size-=this.calculateSize(o.value)),o}isEmpty(){return this.head.isEmpty()}}let AbortError$a=class extends Error{constructor(tt,rt){super(tt??"The operation was aborted");wt(this,"type");wt(this,"code");this.type="aborted",this.code=rt??"ABORT_ERR"}};function pushable(et={}){return _pushable(tt=>{const rt=tt.shift();if(rt==null)return{done:!0};if(rt.error!=null)throw rt.error;return{done:rt.done===!0,value:rt.value}},et)}function _pushable(et,o){o=o??{};let tt=o.onEnd,rt=new FIFO,nt,ot,it,st=pDefer();const at=async()=>{try{return rt.isEmpty()?it?{done:!0}:await new Promise((gt,yt)=>{ot=bt=>{ot=null,rt.push(bt);try{gt(et(rt))}catch(xt){yt(xt)}return nt}}):et(rt)}finally{rt.isEmpty()&&queueMicrotask(()=>{st.resolve(),st=pDefer()})}},ct=gt=>ot!=null?ot(gt):(rt.push(gt),nt),lt=gt=>(rt=new FIFO,ot!=null?ot({error:gt}):(rt.push({error:gt}),nt)),dt=gt=>{if(it)return nt;if((o==null?void 0:o.objectMode)!==!0&&(gt==null?void 0:gt.byteLength)==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return ct({done:!1,value:gt})},ht=gt=>it?nt:(it=!0,gt!=null?lt(gt):ct({done:!0})),mt=()=>(rt=new FIFO,ht(),{done:!0}),ft=gt=>(ht(gt),{done:!0});if(nt={[Symbol.asyncIterator](){return this},next:at,return:mt,throw:ft,push:dt,end:ht,get readableLength(){return rt.size},onEmpty:async gt=>{const yt=gt==null?void 0:gt.signal;if(yt==null||yt.throwIfAborted(),rt.isEmpty())return;let bt,xt;yt!=null&&(bt=new Promise((vt,Et)=>{xt=()=>{Et(new AbortError$a)},yt.addEventListener("abort",xt)}));try{await Promise.race([st.promise,bt])}finally{xt!=null&&yt!=null&&(yt==null||yt.removeEventListener("abort",xt))}}},tt==null)return nt;const pt=nt;return nt={[Symbol.asyncIterator](){return this},next(){return pt.next()},throw(gt){return pt.throw(gt),tt!=null&&(tt(gt),tt=void 0),{done:!0}},return(){return pt.return(),tt!=null&&(tt(),tt=void 0),{done:!0}},push:dt,end(gt){return pt.end(gt),tt!=null&&(tt(gt),tt=void 0),nt},get readableLength(){return pt.readableLength},onEmpty:gt=>pt.onEmpty(gt)},nt}function isAsyncIterable$6(et){return et[Symbol.asyncIterator]!=null}function merge$2(...et){const o=[];for(const tt of et)isAsyncIterable$6(tt)||o.push(tt);return o.length===et.length?function*(){for(const tt of o)yield*tt}():async function*(){const tt=pushable({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(et.map(async rt=>{for await(const nt of rt)tt.push(nt)})),tt.end()}catch(rt){tt.end(rt)}}),yield*tt}()}function pipe(et,...o){if(et==null)throw new Error("Empty pipeline");if(isDuplex(et)){const rt=et;et=()=>rt.source}else if(isIterable(et)||isAsyncIterable$5(et)){const rt=et;et=()=>rt}const tt=[et,...o];if(tt.length>1&&isDuplex(tt[tt.length-1])&&(tt[tt.length-1]=tt[tt.length-1].sink),tt.length>2)for(let rt=1;rt{let o;for(;et.length>0;)o=et.shift()(o);return o},isAsyncIterable$5=et=>(et==null?void 0:et[Symbol.asyncIterator])!=null,isIterable=et=>(et==null?void 0:et[Symbol.iterator])!=null,isDuplex=et=>et==null?!1:et.sink!=null&&et.source!=null,duplexPipelineFn=et=>o=>{const tt=et.sink(o);if((tt==null?void 0:tt.then)!=null){const rt=pushable({objectMode:!0});tt.then(()=>{rt.end()},it=>{rt.end(it)});let nt;const ot=et.source;if(isAsyncIterable$5(ot))nt=async function*(){yield*ot,rt.end()};else if(isIterable(ot))nt=function*(){yield*ot,rt.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return merge$2(rt,nt())}return et.source};async function sortPeersByLatency(et,o){return o.length===0?[]:(await Promise.all(o.map(async nt=>{try{const ot=(await et.get(nt.id)).metadata.get("ping");if(!ot)return{peer:nt,ping:1/0};const it=Number(bytesToUtf8(ot));return{peer:nt,ping:it}}catch{return{peer:nt,ping:1/0}}}))).filter(nt=>nt!==null).sort((nt,ot)=>nt.ping-ot.ping).map(nt=>nt.peer)}async function getPeersForProtocol(et,o){const tt=[];return await et.forEach(rt=>{for(let nt=0;ntit.tags.has(Tags.BOOTSTRAP)).slice(0,tt);o>0&&o!it.tags.has(Tags.BOOTSTRAP));if(o===0)return[...rt,...nt];const ot=[...rt];for(;ot.length0;){const it=Math.floor(Math.random()*nt.length),st=nt.splice(it,1)[0];ot.push(st)}return ot}function selectOpenConnection(et){return et.filter(o=>o.status==="open").sort((o,tt)=>tt.timeline.open-o.timeline.open).at(0)}const STREAM_LOCK_KEY="consumed";class StreamManager{constructor(o,tt,rt){wt(this,"multicodec");wt(this,"getConnections");wt(this,"addEventListener");wt(this,"log");wt(this,"ongoingCreation",new Set);wt(this,"streamPool",new Map);wt(this,"handlePeerUpdateStreamPool",o=>{const{peer:tt}=o.detail;!tt.protocols.includes(this.multicodec)||this.getOpenStreamForCodec(tt.id)||this.scheduleNewStream(tt)});this.multicodec=o,this.getConnections=tt,this.addEventListener=rt,this.log=new Logger$1(`stream-manager:${o}`),this.addEventListener("peer:update",this.handlePeerUpdateStreamPool)}async getStream(o){const tt=o.id.toString(),rt=this.streamPool.get(tt);rt&&(this.streamPool.delete(tt),await rt);let nt=this.getOpenStreamForCodec(o.id);return nt?(this.log.info(`Found existing stream peerId=${o.id.toString()} multicodec=${this.multicodec}`),this.lockStream(o.id.toString(),nt),nt):(nt=await this.createStream(o),this.lockStream(o.id.toString(),nt),nt)}async createStream(o,tt=0){const rt=this.getConnections(o.id),nt=selectOpenConnection(rt);if(!nt)throw new Error(`Failed to get a connection to the peer peerId=${o.id.toString()} multicodec=${this.multicodec}`);let ot,it;for(let st=0;stit.protocol===this.multicodec);if(!(!nt||["done","closed","closing"].includes(nt.writeStatus||"")||this.isStreamLocked(nt)))return nt}lockStream(o,tt){this.log.info(`Locking stream for peerId:${o} streamId:${tt.id}`),tt.metadata[STREAM_LOCK_KEY]=!0}isStreamLocked(o){return!!o.metadata[STREAM_LOCK_KEY]}}class BaseProtocol{constructor(o,tt,rt,nt){wt(this,"multicodec");wt(this,"components");wt(this,"log");wt(this,"pubsubTopics");wt(this,"addLibp2pEventListener");wt(this,"removeLibp2pEventListener");wt(this,"streamManager");this.multicodec=o,this.components=tt,this.log=rt,this.pubsubTopics=nt,this.addLibp2pEventListener=tt.events.addEventListener.bind(tt.events),this.removeLibp2pEventListener=tt.events.removeEventListener.bind(tt.events),this.streamManager=new StreamManager(o,tt.connectionManager.getConnections.bind(tt.connectionManager),this.addLibp2pEventListener)}async getStream(o){return this.streamManager.getStream(o)}async allPeers(){return getPeersForProtocol(this.components.peerStore,[this.multicodec])}async connectedPeers(){return(await this.allPeers()).filter(tt=>this.components.connectionManager.getConnections(tt.id).length>0)}async getPeers({numPeers:o,maxBootstrapPeers:tt,peerIdStr:rt}={maxBootstrapPeers:0,numPeers:0}){if(rt){const st=(await this.connectedPeers()).find(at=>at.id.toString()===rt);return st?[st]:(this.log.warn(`Passed node to use for ${this.multicodec} not found: ${rt}. Attempting to use random peers.`),this.getPeers({numPeers:o,maxBootstrapPeers:tt}))}const nt=await this.connectedPeers(),ot=filterPeersByDiscovery(nt,o,tt),it=await sortPeersByLatency(this.components.peerStore,ot);return it.length===0&&this.log.warn("No peers found. Ensure you have a connection to the network."),it.length{log$n.error("Failed to register ",FilterCodecs.PUSH,ot)})}async subscribe(tt,rt,nt){const ot=await this.getStream(rt),it=FilterSubscribeRpc.createSubscribeRequest(tt,nt);let st;try{st=await pipe([it.encode()],encode$K,ot,decode$U,async dt=>await all$2(dt))}catch(dt){return log$n.error("Failed to send subscribe request",dt),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:rt.id}}}const{statusCode:at,requestId:ct,statusDesc:lt}=FilterSubscribeResponse.decode(st[0].slice());return at<200||at>=300?(log$n.error(`Filter subscribe request ${ct} failed with status code ${at}: ${lt}`),{failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:rt.id},success:null}):{failure:null,success:rt.id}}async unsubscribe(tt,rt,nt){let ot;try{ot=await this.getStream(rt)}catch(st){return log$n.error(`Failed to get a stream for remote peer${rt.id.toString()}`,st),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:rt.id}}}const it=FilterSubscribeRpc.createUnsubscribeRequest(tt,nt);try{await pipe([it.encode()],encode$K,ot.sink)}catch(st){return log$n.error("Failed to send unsubscribe request",st),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:rt.id}}}return{success:rt.id,failure:null}}async unsubscribeAll(tt,rt){const nt=await this.getStream(rt),ot=FilterSubscribeRpc.createUnsubscribeAllRequest(tt),it=await pipe([ot.encode()],encode$K,nt,decode$U,async lt=>await all$2(lt));if(!it||!it.length)return{failure:{error:ProtocolError$1.NO_RESPONSE,peerId:rt.id},success:null};const{statusCode:st,requestId:at,statusDesc:ct}=FilterSubscribeResponse.decode(it[0].slice());return st<200||st>=300?(log$n.error(`Filter unsubscribe all request ${at} failed with status code ${st}: ${ct}`),{failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:rt.id},success:null}):{failure:null,success:rt.id}}async ping(tt){let rt;try{rt=await this.getStream(tt)}catch(ct){return log$n.error(`Failed to get a stream for remote peer${tt.id.toString()}`,ct),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:tt.id}}}const nt=FilterSubscribeRpc.createSubscriberPingRequest();let ot;try{ot=await pipe([nt.encode()],encode$K,rt,decode$U,async ct=>await all$2(ct))}catch(ct){return log$n.error("Failed to send ping request",ct),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:tt.id}}}if(!ot||!ot.length)return{success:null,failure:{error:ProtocolError$1.NO_RESPONSE,peerId:tt.id}};const{statusCode:it,requestId:st,statusDesc:at}=FilterSubscribeResponse.decode(ot[0].slice());return it<200||it>=300?(log$n.error(`Filter ping request ${st} failed with status code ${it}: ${at}`),{success:null,failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:tt.id}}):{success:tt.id,failure:null}}onRequest(tt){const{connection:rt,stream:nt}=tt,{remotePeer:ot}=rt;log$n.info(`Received message from ${ot.toString()}`);try{pipe(nt,decode$U,async it=>{for await(const st of it){const at=FilterPushRpc.decode(st.slice()),{pubsubTopic:ct,wakuMessage:lt}=at;if(!lt){log$n.error("Received empty message");return}if(!ct){log$n.error("Pubsub topic missing from push message");return}await this.handleIncomingMessage(ct,lt,rt.remotePeer.toString())}}).then(()=>{log$n.info("Receiving pipe closed.")},async it=>{log$n.error(`Error with receiving pipe on peer:${rt.remotePeer.toString()} -- stream:${nt.id} -- protocol:${nt.protocol}: `,it)})}catch(it){log$n.error("Error decoding message",it)}}}class PushRpc{constructor(o){wt(this,"proto");this.proto=o}static createRequest(o,tt){return new PushRpc({requestId:v4$2(),request:{message:o,pubsubTopic:tt},response:void 0})}static decode(o){const tt=PushRpc$1.decode(o);return new PushRpc(tt)}encode(){return PushRpc$1.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const RLN_GENERATION_PREFIX_ERROR="could not generate rln-v2 proof",isRLNResponseError=et=>et?et.includes(RLN_GENERATION_PREFIX_ERROR):!1,matchRLNErrorMessage=et=>{const o={[ProtocolError$1.RLN_IDENTITY_MISSING]:ProtocolError$1.RLN_IDENTITY_MISSING,[ProtocolError$1.RLN_MEMBERSHIP_INDEX]:ProtocolError$1.RLN_MEMBERSHIP_INDEX,[ProtocolError$1.RLN_LIMIT_MISSING]:ProtocolError$1.RLN_LIMIT_MISSING},tt=et.toLowerCase();for(const rt in o)if(tt.includes(rt.toLowerCase()))return o[rt];return ProtocolError$1.RLN_PROOF_GENERATION},log$m=new Logger$1("light-push"),LightPushCodec="/vac/waku/lightpush/2.0.0-beta1";class LightPushCore extends BaseProtocol{constructor(tt,rt){super(LightPushCodec,rt.components,log$m,tt);wt(this,"pubsubTopics");this.pubsubTopics=tt}async preparePushMessage(tt,rt){try{if(!rt.payload||rt.payload.length===0)return log$m.error("Failed to send waku light push: payload is empty"),{query:null,error:ProtocolError$1.EMPTY_PAYLOAD};if(!await isMessageSizeUnderCap(tt,rt))return log$m.error("Failed to send waku light push: message is bigger than 1MB"),{query:null,error:ProtocolError$1.SIZE_TOO_BIG};const nt=await tt.toProtoObj(rt);return nt?{query:PushRpc.createRequest(nt,tt.pubsubTopic),error:null}:(log$m.error("Failed to encode to protoMessage, aborting push"),{query:null,error:ProtocolError$1.ENCODE_FAILED})}catch(nt){return log$m.error("Failed to prepare push message",nt),{query:null,error:ProtocolError$1.GENERIC_FAIL}}}async send(tt,rt,nt){const{query:ot,error:it}=await this.preparePushMessage(tt,rt);if(it||!ot)return{success:null,failure:{error:it,peerId:nt.id}};let st;try{st=await this.getStream(nt)}catch(dt){return log$m.error("Failed to get stream",dt),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:nt.id}}}let at;try{at=await pipe([ot.encode()],encode$K,st,decode$U,async dt=>await all$2(dt))}catch(dt){return log$m.error("Failed to send waku light push request",dt),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:nt.id}}}const ct=new Uint8ArrayList;at.forEach(dt=>{ct.append(dt)});let lt;try{lt=PushRpc.decode(ct).response}catch(dt){return log$m.error("Failed to decode push reply",dt),{success:null,failure:{error:ProtocolError$1.DECODE_FAILED,peerId:nt.id}}}if(!lt)return log$m.error("Remote peer fault: No response in PushRPC"),{success:null,failure:{error:ProtocolError$1.NO_RESPONSE,peerId:nt.id}};if(isRLNResponseError(lt.info)){const dt=matchRLNErrorMessage(lt.info);return log$m.error("Remote peer rejected the message: ",dt),{success:null,failure:{error:dt,peerId:nt.id}}}return lt.isSuccess?{success:nt.id,failure:null}:(log$m.error("Remote peer rejected the message: ",lt.info),{success:null,failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:nt.id}})}}const EmptyMessage={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};function toProtoMessage(et){return{...EmptyMessage,...et}}const DEFAULT_PAGE_SIZE=20,MAX_PAGE_SIZE=100,ONE_MILLION=1e6;class StoreQueryRequest{constructor(o){wt(this,"proto");this.proto=o}static create(o){const tt=new StoreQueryRequest({...o,requestId:v4$2(),timeStart:o.timeStart?BigInt(o.timeStart.getTime()*ONE_MILLION):void 0,timeEnd:o.timeEnd?BigInt(o.timeEnd.getTime()*ONE_MILLION):void 0,messageHashes:o.messageHashes||[],paginationLimit:o.paginationLimit?BigInt(o.paginationLimit):void 0});if(o.pubsubTopic&&!o.contentTopics||!o.pubsubTopic&&o.contentTopics)throw new Error("Both pubsubTopic and contentTopics must be set or unset");if(o.messageHashes&&(o.pubsubTopic||o.contentTopics||o.timeStart||o.timeEnd))throw new Error("Message hash lookup queries cannot include content filter criteria");return tt}static decode(o){const tt=StoreQueryRequest$1.decode(o);return new StoreQueryRequest(tt)}encode(){return StoreQueryRequest$1.encode(this.proto)}}class StoreQueryResponse{constructor(o){wt(this,"proto");this.proto=o}static decode(o){const tt=StoreQueryResponse$1.decode(o);return new StoreQueryResponse(tt)}encode(){return StoreQueryResponse$1.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get messages(){return this.proto.messages}get paginationCursor(){return this.proto.paginationCursor}}const log$l=new Logger$1("store"),StoreCodec="/vac/waku/store-query/3.0.0";class StoreCore extends BaseProtocol{constructor(tt,rt){super(StoreCodec,rt.components,log$l,tt);wt(this,"pubsubTopics");this.pubsubTopics=tt}async*queryPerPage(tt,rt,nt){if(tt.contentTopics.toString()!==Array.from(rt.keys()).toString())throw new Error("Internal error, the decoders should match the query's content topics");let ot=tt.paginationCursor;for(;;){const it=StoreQueryRequest.create({...tt,paginationCursor:ot});let st;try{st=await this.getStream(nt)}catch(ht){log$l.error("Failed to get stream",ht);break}const at=await pipe([it.encode()],encode$K,st,decode$U,async ht=>await all$2(ht)),ct=new Uint8ArrayList;at.forEach(ht=>{ct.append(ht)});const lt=StoreQueryResponse.decode(ct);if(!lt.statusCode||lt.statusCode>=300){const ht=`Store query failed with status code: ${lt.statusCode}, description: ${lt.statusDesc}`;throw log$l.error(ht),new Error(ht)}if(!lt.messages||!lt.messages.length){log$l.warn("Stopping pagination due to empty messages in response");break}if(log$l.info(`${lt.messages.length} messages retrieved from store`),yield lt.messages.map(ht=>{if(!ht.message)return Promise.resolve(void 0);const mt=ht.message.contentTopic;if(mt){const ft=rt.get(mt);if(ft)return ft.fromProtoObj(ht.pubsubTopic||"",toProtoMessage(ht.message))}return Promise.resolve(void 0)}),tt.paginationForward?ot=lt.messages[lt.messages.length-1].messageHash:ot=lt.messages[0].messageHash,lt.messages.length>MAX_PAGE_SIZE&<.messages.length<(tt.paginationLimit||DEFAULT_PAGE_SIZE))break}}}const peerDiscoverySymbol$2=Symbol.for("@libp2p/peer-discovery"),peerIdSymbol$3=Symbol.for("@libp2p/peer-id");function isPeerId$2(et){return!!(et!=null&&et[peerIdSymbol$3])}var cs;let AbortError$9=(cs=class extends Error{constructor(o="The operation was aborted"){super(o),this.name="AbortError"}},wt(cs,"name","AbortError"),cs);class UnexpectedPeerError extends Error{constructor(o="Unexpected Peer"){super(o),this.name="UnexpectedPeerError"}}wt(UnexpectedPeerError,"name","UnexpectedPeerError");var ls;let InvalidMessageError$3=(ls=class extends Error{constructor(o="Invalid message"){super(o),this.name="InvalidMessageError"}},wt(ls,"name","InvalidMessageError"),ls);class ProtocolError extends Error{constructor(o="Protocol error"){super(o),this.name="ProtocolError"}}wt(ProtocolError,"name","ProtocolError");var us;let TimeoutError$3=(us=class extends Error{constructor(o="Timed out"){super(o),this.name="TimeoutError"}},wt(us,"name","TimeoutError"),us);function setMaxListeners$9(){}const setMaxListeners$8=(et,...o)=>{try{[...o]}catch{}};var Yr,Xs;let TypedEventEmitter$3=(Xs=class extends EventTarget{constructor(){super();hr(this,Yr,new Map);setMaxListeners$8(1/0,this)}listenerCount(tt){const rt=Lt(this,Yr).get(tt);return rt==null?0:rt.length}addEventListener(tt,rt,nt){super.addEventListener(tt,rt,nt);let ot=Lt(this,Yr).get(tt);ot==null&&(ot=[],Lt(this,Yr).set(tt,ot)),ot.push({callback:rt,once:(nt!==!0&&nt!==!1&&(nt==null?void 0:nt.once))??!1})}removeEventListener(tt,rt,nt){super.removeEventListener(tt.toString(),rt??null,nt);let ot=Lt(this,Yr).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==rt),Lt(this,Yr).set(tt,ot))}dispatchEvent(tt){const rt=super.dispatchEvent(tt);let nt=Lt(this,Yr).get(tt.type);return nt==null||(nt=nt.filter(({once:ot})=>!ot),Lt(this,Yr).set(tt.type,nt)),rt}safeDispatchEvent(tt,rt={}){return this.dispatchEvent(new CustomEvent(tt,rt))}},Yr=new WeakMap,Xs);const serviceCapabilities$5=Symbol.for("@libp2p/service-capabilities"),RelayPingContentTopic="/relay-ping/1/ping/null",log$k=new Logger$1("keep-alive");class KeepAliveManager{constructor({options:o,relay:tt,libp2p:rt}){wt(this,"relay");wt(this,"libp2p");wt(this,"options");wt(this,"pingKeepAliveTimers",new Map);wt(this,"relayKeepAliveTimers",new Map);this.options=o,this.relay=tt,this.libp2p=rt}start(o){this.stop(o);const{pingKeepAlive:tt,relayKeepAlive:rt}=this.options,nt=o.toString();if(tt!==0){const it=setInterval(()=>{(async()=>{let st;try{try{st=await this.libp2p.services.ping.ping(o),log$k.info(`Ping succeeded (${nt})`,st)}catch{log$k.error(`Ping failed for peer (${nt}). + */function _extends(){return _extends=Object.assign?Object.assign.bind():function(et){for(var o=1;o=0)&&(tt[nt]=et[nt]);return tt}function isModifiedEvent(et){return!!(et.metaKey||et.altKey||et.ctrlKey||et.shiftKey)}function shouldProcessLinkClick(et,o){return et.button===0&&(!o||o==="_self")&&!isModifiedEvent(et)}const _excluded=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],REACT_ROUTER_VERSION="6";try{window.__reactRouterVersion=REACT_ROUTER_VERSION}catch{}const START_TRANSITION="startTransition",startTransitionImpl=React$1[START_TRANSITION];function BrowserRouter(et){let{basename:o,children:tt,future:rt,window:nt}=et,ot=reactExports.useRef();ot.current==null&&(ot.current=createBrowserHistory({window:nt,v5Compat:!0}));let it=ot.current,[st,at]=reactExports.useState({action:it.action,location:it.location}),{v7_startTransition:ct}=rt||{},lt=reactExports.useCallback(dt=>{ct&&startTransitionImpl?startTransitionImpl(()=>at(dt)):at(dt)},[at,ct]);return reactExports.useLayoutEffect(()=>it.listen(lt),[it,lt]),reactExports.createElement(Router,{basename:o,children:tt,location:st.location,navigationType:st.action,navigator:it,future:rt})}const isBrowser$1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ABSOLUTE_URL_REGEX=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Link=reactExports.forwardRef(function(o,tt){let{onClick:rt,relative:nt,reloadDocument:ot,replace:it,state:st,target:at,to:ct,preventScrollReset:lt,viewTransition:dt}=o,ht=_objectWithoutPropertiesLoose$1(o,_excluded),{basename:mt}=reactExports.useContext(NavigationContext),ft,pt=!1;if(typeof ct=="string"&&ABSOLUTE_URL_REGEX.test(ct)&&(ft=ct,isBrowser$1))try{let xt=new URL(window.location.href),vt=ct.startsWith("//")?new URL(xt.protocol+ct):new URL(ct),Et=stripBasename(vt.pathname,mt);vt.origin===xt.origin&&Et!=null?ct=Et+vt.search+vt.hash:pt=!0}catch{}let yt=useHref(ct,{relative:nt}),gt=useLinkClickHandler(ct,{replace:it,state:st,target:at,preventScrollReset:lt,relative:nt,viewTransition:dt});function bt(xt){rt&&rt(xt),xt.defaultPrevented||gt(xt)}return reactExports.createElement("a",_extends({},ht,{href:ft||yt,onClick:pt||ot?rt:bt,ref:tt,target:at}))});var DataRouterHook;(function(et){et.UseScrollRestoration="useScrollRestoration",et.UseSubmit="useSubmit",et.UseSubmitFetcher="useSubmitFetcher",et.UseFetcher="useFetcher",et.useViewTransitionState="useViewTransitionState"})(DataRouterHook||(DataRouterHook={}));var DataRouterStateHook;(function(et){et.UseFetcher="useFetcher",et.UseFetchers="useFetchers",et.UseScrollRestoration="useScrollRestoration"})(DataRouterStateHook||(DataRouterStateHook={}));function useLinkClickHandler(et,o){let{target:tt,replace:rt,state:nt,preventScrollReset:ot,relative:it,viewTransition:st}=o===void 0?{}:o,at=useNavigate(),ct=useLocation(),lt=useResolvedPath(et,{relative:it});return reactExports.useCallback(dt=>{if(shouldProcessLinkClick(dt,tt)){dt.preventDefault();let ht=rt!==void 0?rt:createPath(ct)===createPath(lt);at(et,{replace:ht,state:nt,preventScrollReset:ot,relative:it,viewTransition:st})}},[ct,at,lt,rt,nt,tt,et,ot,it,st])}function setRef(et,o){typeof et=="function"?et(o):et!=null&&(et.current=o)}function composeRefs(...et){return o=>et.forEach(tt=>setRef(tt,o))}function useComposedRefs(...et){return reactExports.useCallback(composeRefs(...et),et)}var Slot=reactExports.forwardRef((et,o)=>{const{children:tt,...rt}=et,nt=reactExports.Children.toArray(tt),ot=nt.find(isSlottable);if(ot){const it=ot.props.children,st=nt.map(at=>at===ot?reactExports.Children.count(it)>1?reactExports.Children.only(null):reactExports.isValidElement(it)?it.props.children:null:at);return jsxRuntimeExports.jsx(SlotClone,{...rt,ref:o,children:reactExports.isValidElement(it)?reactExports.cloneElement(it,void 0,st):null})}return jsxRuntimeExports.jsx(SlotClone,{...rt,ref:o,children:tt})});Slot.displayName="Slot";var SlotClone=reactExports.forwardRef((et,o)=>{const{children:tt,...rt}=et;if(reactExports.isValidElement(tt)){const nt=getElementRef$1(tt);return reactExports.cloneElement(tt,{...mergeProps(rt,tt.props),ref:o?composeRefs(o,nt):nt})}return reactExports.Children.count(tt)>1?reactExports.Children.only(null):null});SlotClone.displayName="SlotClone";var Slottable=({children:et})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:et});function isSlottable(et){return reactExports.isValidElement(et)&&et.type===Slottable}function mergeProps(et,o){const tt={...o};for(const rt in o){const nt=et[rt],ot=o[rt];/^on[A-Z]/.test(rt)?nt&&ot?tt[rt]=(...st)=>{ot(...st),nt(...st)}:nt&&(tt[rt]=nt):rt==="style"?tt[rt]={...nt,...ot}:rt==="className"&&(tt[rt]=[nt,ot].filter(Boolean).join(" "))}return{...et,...tt}}function getElementRef$1(et){var rt,nt;let o=(rt=Object.getOwnPropertyDescriptor(et.props,"ref"))==null?void 0:rt.get,tt=o&&"isReactWarning"in o&&o.isReactWarning;return tt?et.ref:(o=(nt=Object.getOwnPropertyDescriptor(et,"ref"))==null?void 0:nt.get,tt=o&&"isReactWarning"in o&&o.isReactWarning,tt?et.props.ref:et.props.ref||et.ref)}function r$1(et){var o,tt,rt="";if(typeof et=="string"||typeof et=="number")rt+=et;else if(typeof et=="object")if(Array.isArray(et))for(o=0;otypeof et=="boolean"?"".concat(et):et===0?"0":et,cx=clsx$1,cva=(et,o)=>tt=>{var rt;if((o==null?void 0:o.variants)==null)return cx(et,tt==null?void 0:tt.class,tt==null?void 0:tt.className);const{variants:nt,defaultVariants:ot}=o,it=Object.keys(nt).map(ct=>{const lt=tt==null?void 0:tt[ct],dt=ot==null?void 0:ot[ct];if(lt===null)return null;const ht=falsyToString(lt)||falsyToString(dt);return nt[ct][ht]}),st=tt&&Object.entries(tt).reduce((ct,lt)=>{let[dt,ht]=lt;return ht===void 0||(ct[dt]=ht),ct},{}),at=o==null||(rt=o.compoundVariants)===null||rt===void 0?void 0:rt.reduce((ct,lt)=>{let{class:dt,className:ht,...mt}=lt;return Object.entries(mt).every(ft=>{let[pt,yt]=ft;return Array.isArray(yt)?yt.includes({...ot,...st}[pt]):{...ot,...st}[pt]===yt})?[...ct,dt,ht]:ct},[]);return cx(et,it,at,tt==null?void 0:tt.class,tt==null?void 0:tt.className)};function r(et){var o,tt,rt="";if(typeof et=="string"||typeof et=="number")rt+=et;else if(typeof et=="object")if(Array.isArray(et)){var nt=et.length;for(o=0;o{const o=createClassMap(et),{conflictingClassGroups:tt,conflictingClassGroupModifiers:rt}=et;return{getClassGroupId:it=>{const st=it.split(CLASS_PART_SEPARATOR);return st[0]===""&&st.length!==1&&st.shift(),getGroupRecursive(st,o)||getGroupIdForArbitraryProperty(it)},getConflictingClassGroupIds:(it,st)=>{const at=tt[it]||[];return st&&rt[it]?[...at,...rt[it]]:at}}},getGroupRecursive=(et,o)=>{var it;if(et.length===0)return o.classGroupId;const tt=et[0],rt=o.nextPart.get(tt),nt=rt?getGroupRecursive(et.slice(1),rt):void 0;if(nt)return nt;if(o.validators.length===0)return;const ot=et.join(CLASS_PART_SEPARATOR);return(it=o.validators.find(({validator:st})=>st(ot)))==null?void 0:it.classGroupId},arbitraryPropertyRegex=/^\[(.+)\]$/,getGroupIdForArbitraryProperty=et=>{if(arbitraryPropertyRegex.test(et)){const o=arbitraryPropertyRegex.exec(et)[1],tt=o==null?void 0:o.substring(0,o.indexOf(":"));if(tt)return"arbitrary.."+tt}},createClassMap=et=>{const{theme:o,prefix:tt}=et,rt={nextPart:new Map,validators:[]};return getPrefixedClassGroupEntries(Object.entries(et.classGroups),tt).forEach(([ot,it])=>{processClassesRecursively(it,rt,ot,o)}),rt},processClassesRecursively=(et,o,tt,rt)=>{et.forEach(nt=>{if(typeof nt=="string"){const ot=nt===""?o:getPart(o,nt);ot.classGroupId=tt;return}if(typeof nt=="function"){if(isThemeGetter(nt)){processClassesRecursively(nt(rt),o,tt,rt);return}o.validators.push({validator:nt,classGroupId:tt});return}Object.entries(nt).forEach(([ot,it])=>{processClassesRecursively(it,getPart(o,ot),tt,rt)})})},getPart=(et,o)=>{let tt=et;return o.split(CLASS_PART_SEPARATOR).forEach(rt=>{tt.nextPart.has(rt)||tt.nextPart.set(rt,{nextPart:new Map,validators:[]}),tt=tt.nextPart.get(rt)}),tt},isThemeGetter=et=>et.isThemeGetter,getPrefixedClassGroupEntries=(et,o)=>o?et.map(([tt,rt])=>{const nt=rt.map(ot=>typeof ot=="string"?o+ot:typeof ot=="object"?Object.fromEntries(Object.entries(ot).map(([it,st])=>[o+it,st])):ot);return[tt,nt]}):et,createLruCache=et=>{if(et<1)return{get:()=>{},set:()=>{}};let o=0,tt=new Map,rt=new Map;const nt=(ot,it)=>{tt.set(ot,it),o++,o>et&&(o=0,rt=tt,tt=new Map)};return{get(ot){let it=tt.get(ot);if(it!==void 0)return it;if((it=rt.get(ot))!==void 0)return nt(ot,it),it},set(ot,it){tt.has(ot)?tt.set(ot,it):nt(ot,it)}}},IMPORTANT_MODIFIER="!",createParseClassName=et=>{const{separator:o,experimentalParseClassName:tt}=et,rt=o.length===1,nt=o[0],ot=o.length,it=st=>{const at=[];let ct=0,lt=0,dt;for(let yt=0;ytlt?dt-lt:void 0;return{modifiers:at,hasImportantModifier:mt,baseClassName:ft,maybePostfixModifierPosition:pt}};return tt?st=>tt({className:st,parseClassName:it}):it},sortModifiers=et=>{if(et.length<=1)return et;const o=[];let tt=[];return et.forEach(rt=>{rt[0]==="["?(o.push(...tt.sort(),rt),tt=[]):tt.push(rt)}),o.push(...tt.sort()),o},createConfigUtils=et=>({cache:createLruCache(et.cacheSize),parseClassName:createParseClassName(et),...createClassGroupUtils(et)}),SPLIT_CLASSES_REGEX=/\s+/,mergeClassList=(et,o)=>{const{parseClassName:tt,getClassGroupId:rt,getConflictingClassGroupIds:nt}=o,ot=[],it=et.trim().split(SPLIT_CLASSES_REGEX);let st="";for(let at=it.length-1;at>=0;at-=1){const ct=it[at],{modifiers:lt,hasImportantModifier:dt,baseClassName:ht,maybePostfixModifierPosition:mt}=tt(ct);let ft=!!mt,pt=rt(ft?ht.substring(0,mt):ht);if(!pt){if(!ft){st=ct+(st.length>0?" "+st:st);continue}if(pt=rt(ht),!pt){st=ct+(st.length>0?" "+st:st);continue}ft=!1}const yt=sortModifiers(lt).join(":"),gt=dt?yt+IMPORTANT_MODIFIER:yt,bt=gt+pt;if(ot.includes(bt))continue;ot.push(bt);const xt=nt(pt,ft);for(let vt=0;vt0?" "+st:st)}return st};function twJoin(){let et=0,o,tt,rt="";for(;et{if(typeof et=="string")return et;let o,tt="";for(let rt=0;rtdt(lt),et());return tt=createConfigUtils(ct),rt=tt.cache.get,nt=tt.cache.set,ot=st,st(at)}function st(at){const ct=rt(at);if(ct)return ct;const lt=mergeClassList(at,tt);return nt(at,lt),lt}return function(){return ot(twJoin.apply(null,arguments))}}const fromTheme=et=>{const o=tt=>tt[et]||[];return o.isThemeGetter=!0,o},arbitraryValueRegex=/^\[(?:([a-z-]+):)?(.+)\]$/i,fractionRegex=/^\d+\/\d+$/,stringLengths=new Set(["px","full","screen"]),tshirtUnitRegex=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lengthUnitRegex=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,colorFunctionRegex=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,shadowRegex=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,imageRegex=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,isLength=et=>isNumber(et)||stringLengths.has(et)||fractionRegex.test(et),isArbitraryLength=et=>getIsArbitraryValue(et,"length",isLengthOnly),isNumber=et=>!!et&&!Number.isNaN(Number(et)),isArbitraryNumber=et=>getIsArbitraryValue(et,"number",isNumber),isInteger$1=et=>!!et&&Number.isInteger(Number(et)),isPercent=et=>et.endsWith("%")&&isNumber(et.slice(0,-1)),isArbitraryValue=et=>arbitraryValueRegex.test(et),isTshirtSize=et=>tshirtUnitRegex.test(et),sizeLabels=new Set(["length","size","percentage"]),isArbitrarySize=et=>getIsArbitraryValue(et,sizeLabels,isNever),isArbitraryPosition=et=>getIsArbitraryValue(et,"position",isNever),imageLabels=new Set(["image","url"]),isArbitraryImage=et=>getIsArbitraryValue(et,imageLabels,isImage),isArbitraryShadow=et=>getIsArbitraryValue(et,"",isShadow),isAny=()=>!0,getIsArbitraryValue=(et,o,tt)=>{const rt=arbitraryValueRegex.exec(et);return rt?rt[1]?typeof o=="string"?rt[1]===o:o.has(rt[1]):tt(rt[2]):!1},isLengthOnly=et=>lengthUnitRegex.test(et)&&!colorFunctionRegex.test(et),isNever=()=>!1,isShadow=et=>shadowRegex.test(et),isImage=et=>imageRegex.test(et),getDefaultConfig=()=>{const et=fromTheme("colors"),o=fromTheme("spacing"),tt=fromTheme("blur"),rt=fromTheme("brightness"),nt=fromTheme("borderColor"),ot=fromTheme("borderRadius"),it=fromTheme("borderSpacing"),st=fromTheme("borderWidth"),at=fromTheme("contrast"),ct=fromTheme("grayscale"),lt=fromTheme("hueRotate"),dt=fromTheme("invert"),ht=fromTheme("gap"),mt=fromTheme("gradientColorStops"),ft=fromTheme("gradientColorStopPositions"),pt=fromTheme("inset"),yt=fromTheme("margin"),gt=fromTheme("opacity"),bt=fromTheme("padding"),xt=fromTheme("saturate"),vt=fromTheme("scale"),Et=fromTheme("sepia"),Ct=fromTheme("skew"),St=fromTheme("space"),At=fromTheme("translate"),kt=()=>["auto","contain","none"],It=()=>["auto","hidden","clip","visible","scroll"],Nt=()=>["auto",isArbitraryValue,o],Lt=()=>[isArbitraryValue,o],Mt=()=>["",isLength,isArbitraryLength],zt=()=>["auto",isNumber,isArbitraryValue],Ut=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Xt=()=>["solid","dashed","dotted","double","none"],Wt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ft=()=>["start","end","center","between","around","evenly","stretch"],qt=()=>["","0",isArbitraryValue],Pt=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Yt=()=>[isNumber,isArbitraryValue];return{cacheSize:500,separator:":",theme:{colors:[isAny],spacing:[isLength,isArbitraryLength],blur:["none","",isTshirtSize,isArbitraryValue],brightness:Yt(),borderColor:[et],borderRadius:["none","","full",isTshirtSize,isArbitraryValue],borderSpacing:Lt(),borderWidth:Mt(),contrast:Yt(),grayscale:qt(),hueRotate:Yt(),invert:qt(),gap:Lt(),gradientColorStops:[et],gradientColorStopPositions:[isPercent,isArbitraryLength],inset:Nt(),margin:Nt(),opacity:Yt(),padding:Lt(),saturate:Yt(),scale:Yt(),sepia:qt(),skew:Yt(),space:Lt(),translate:Lt()},classGroups:{aspect:[{aspect:["auto","square","video",isArbitraryValue]}],container:["container"],columns:[{columns:[isTshirtSize]}],"break-after":[{"break-after":Pt()}],"break-before":[{"break-before":Pt()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Ut(),isArbitraryValue]}],overflow:[{overflow:It()}],"overflow-x":[{"overflow-x":It()}],"overflow-y":[{"overflow-y":It()}],overscroll:[{overscroll:kt()}],"overscroll-x":[{"overscroll-x":kt()}],"overscroll-y":[{"overscroll-y":kt()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[pt]}],"inset-x":[{"inset-x":[pt]}],"inset-y":[{"inset-y":[pt]}],start:[{start:[pt]}],end:[{end:[pt]}],top:[{top:[pt]}],right:[{right:[pt]}],bottom:[{bottom:[pt]}],left:[{left:[pt]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",isInteger$1,isArbitraryValue]}],basis:[{basis:Nt()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",isArbitraryValue]}],grow:[{grow:qt()}],shrink:[{shrink:qt()}],order:[{order:["first","last","none",isInteger$1,isArbitraryValue]}],"grid-cols":[{"grid-cols":[isAny]}],"col-start-end":[{col:["auto",{span:["full",isInteger$1,isArbitraryValue]},isArbitraryValue]}],"col-start":[{"col-start":zt()}],"col-end":[{"col-end":zt()}],"grid-rows":[{"grid-rows":[isAny]}],"row-start-end":[{row:["auto",{span:[isInteger$1,isArbitraryValue]},isArbitraryValue]}],"row-start":[{"row-start":zt()}],"row-end":[{"row-end":zt()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",isArbitraryValue]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",isArbitraryValue]}],gap:[{gap:[ht]}],"gap-x":[{"gap-x":[ht]}],"gap-y":[{"gap-y":[ht]}],"justify-content":[{justify:["normal",...Ft()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Ft(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Ft(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[bt]}],px:[{px:[bt]}],py:[{py:[bt]}],ps:[{ps:[bt]}],pe:[{pe:[bt]}],pt:[{pt:[bt]}],pr:[{pr:[bt]}],pb:[{pb:[bt]}],pl:[{pl:[bt]}],m:[{m:[yt]}],mx:[{mx:[yt]}],my:[{my:[yt]}],ms:[{ms:[yt]}],me:[{me:[yt]}],mt:[{mt:[yt]}],mr:[{mr:[yt]}],mb:[{mb:[yt]}],ml:[{ml:[yt]}],"space-x":[{"space-x":[St]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[St]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",isArbitraryValue,o]}],"min-w":[{"min-w":[isArbitraryValue,o,"min","max","fit"]}],"max-w":[{"max-w":[isArbitraryValue,o,"none","full","min","max","fit","prose",{screen:[isTshirtSize]},isTshirtSize]}],h:[{h:[isArbitraryValue,o,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[isArbitraryValue,o,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[isArbitraryValue,o,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[isArbitraryValue,o,"auto","min","max","fit"]}],"font-size":[{text:["base",isTshirtSize,isArbitraryLength]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",isArbitraryNumber]}],"font-family":[{font:[isAny]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",isArbitraryValue]}],"line-clamp":[{"line-clamp":["none",isNumber,isArbitraryNumber]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",isLength,isArbitraryValue]}],"list-image":[{"list-image":["none",isArbitraryValue]}],"list-style-type":[{list:["none","disc","decimal",isArbitraryValue]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[et]}],"placeholder-opacity":[{"placeholder-opacity":[gt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[et]}],"text-opacity":[{"text-opacity":[gt]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Xt(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",isLength,isArbitraryLength]}],"underline-offset":[{"underline-offset":["auto",isLength,isArbitraryValue]}],"text-decoration-color":[{decoration:[et]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Lt()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",isArbitraryValue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",isArbitraryValue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[gt]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Ut(),isArbitraryPosition]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",isArbitrarySize]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},isArbitraryImage]}],"bg-color":[{bg:[et]}],"gradient-from-pos":[{from:[ft]}],"gradient-via-pos":[{via:[ft]}],"gradient-to-pos":[{to:[ft]}],"gradient-from":[{from:[mt]}],"gradient-via":[{via:[mt]}],"gradient-to":[{to:[mt]}],rounded:[{rounded:[ot]}],"rounded-s":[{"rounded-s":[ot]}],"rounded-e":[{"rounded-e":[ot]}],"rounded-t":[{"rounded-t":[ot]}],"rounded-r":[{"rounded-r":[ot]}],"rounded-b":[{"rounded-b":[ot]}],"rounded-l":[{"rounded-l":[ot]}],"rounded-ss":[{"rounded-ss":[ot]}],"rounded-se":[{"rounded-se":[ot]}],"rounded-ee":[{"rounded-ee":[ot]}],"rounded-es":[{"rounded-es":[ot]}],"rounded-tl":[{"rounded-tl":[ot]}],"rounded-tr":[{"rounded-tr":[ot]}],"rounded-br":[{"rounded-br":[ot]}],"rounded-bl":[{"rounded-bl":[ot]}],"border-w":[{border:[st]}],"border-w-x":[{"border-x":[st]}],"border-w-y":[{"border-y":[st]}],"border-w-s":[{"border-s":[st]}],"border-w-e":[{"border-e":[st]}],"border-w-t":[{"border-t":[st]}],"border-w-r":[{"border-r":[st]}],"border-w-b":[{"border-b":[st]}],"border-w-l":[{"border-l":[st]}],"border-opacity":[{"border-opacity":[gt]}],"border-style":[{border:[...Xt(),"hidden"]}],"divide-x":[{"divide-x":[st]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[st]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[gt]}],"divide-style":[{divide:Xt()}],"border-color":[{border:[nt]}],"border-color-x":[{"border-x":[nt]}],"border-color-y":[{"border-y":[nt]}],"border-color-s":[{"border-s":[nt]}],"border-color-e":[{"border-e":[nt]}],"border-color-t":[{"border-t":[nt]}],"border-color-r":[{"border-r":[nt]}],"border-color-b":[{"border-b":[nt]}],"border-color-l":[{"border-l":[nt]}],"divide-color":[{divide:[nt]}],"outline-style":[{outline:["",...Xt()]}],"outline-offset":[{"outline-offset":[isLength,isArbitraryValue]}],"outline-w":[{outline:[isLength,isArbitraryLength]}],"outline-color":[{outline:[et]}],"ring-w":[{ring:Mt()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[et]}],"ring-opacity":[{"ring-opacity":[gt]}],"ring-offset-w":[{"ring-offset":[isLength,isArbitraryLength]}],"ring-offset-color":[{"ring-offset":[et]}],shadow:[{shadow:["","inner","none",isTshirtSize,isArbitraryShadow]}],"shadow-color":[{shadow:[isAny]}],opacity:[{opacity:[gt]}],"mix-blend":[{"mix-blend":[...Wt(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Wt()}],filter:[{filter:["","none"]}],blur:[{blur:[tt]}],brightness:[{brightness:[rt]}],contrast:[{contrast:[at]}],"drop-shadow":[{"drop-shadow":["","none",isTshirtSize,isArbitraryValue]}],grayscale:[{grayscale:[ct]}],"hue-rotate":[{"hue-rotate":[lt]}],invert:[{invert:[dt]}],saturate:[{saturate:[xt]}],sepia:[{sepia:[Et]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[tt]}],"backdrop-brightness":[{"backdrop-brightness":[rt]}],"backdrop-contrast":[{"backdrop-contrast":[at]}],"backdrop-grayscale":[{"backdrop-grayscale":[ct]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[lt]}],"backdrop-invert":[{"backdrop-invert":[dt]}],"backdrop-opacity":[{"backdrop-opacity":[gt]}],"backdrop-saturate":[{"backdrop-saturate":[xt]}],"backdrop-sepia":[{"backdrop-sepia":[Et]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[it]}],"border-spacing-x":[{"border-spacing-x":[it]}],"border-spacing-y":[{"border-spacing-y":[it]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",isArbitraryValue]}],duration:[{duration:Yt()}],ease:[{ease:["linear","in","out","in-out",isArbitraryValue]}],delay:[{delay:Yt()}],animate:[{animate:["none","spin","ping","pulse","bounce",isArbitraryValue]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[vt]}],"scale-x":[{"scale-x":[vt]}],"scale-y":[{"scale-y":[vt]}],rotate:[{rotate:[isInteger$1,isArbitraryValue]}],"translate-x":[{"translate-x":[At]}],"translate-y":[{"translate-y":[At]}],"skew-x":[{"skew-x":[Ct]}],"skew-y":[{"skew-y":[Ct]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",isArbitraryValue]}],accent:[{accent:["auto",et]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",isArbitraryValue]}],"caret-color":[{caret:[et]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Lt()}],"scroll-mx":[{"scroll-mx":Lt()}],"scroll-my":[{"scroll-my":Lt()}],"scroll-ms":[{"scroll-ms":Lt()}],"scroll-me":[{"scroll-me":Lt()}],"scroll-mt":[{"scroll-mt":Lt()}],"scroll-mr":[{"scroll-mr":Lt()}],"scroll-mb":[{"scroll-mb":Lt()}],"scroll-ml":[{"scroll-ml":Lt()}],"scroll-p":[{"scroll-p":Lt()}],"scroll-px":[{"scroll-px":Lt()}],"scroll-py":[{"scroll-py":Lt()}],"scroll-ps":[{"scroll-ps":Lt()}],"scroll-pe":[{"scroll-pe":Lt()}],"scroll-pt":[{"scroll-pt":Lt()}],"scroll-pr":[{"scroll-pr":Lt()}],"scroll-pb":[{"scroll-pb":Lt()}],"scroll-pl":[{"scroll-pl":Lt()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",isArbitraryValue]}],fill:[{fill:[et,"none"]}],"stroke-w":[{stroke:[isLength,isArbitraryLength,isArbitraryNumber]}],stroke:[{stroke:[et,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},twMerge=createTailwindMerge(getDefaultConfig);function cn(...et){return twMerge(clsx(et))}const buttonVariants=cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Button=reactExports.forwardRef(({className:et,variant:o,size:tt,asChild:rt=!1,...nt},ot)=>{const it=rt?Slot:"button";return jsxRuntimeExports.jsx(it,{className:cn(buttonVariants({variant:o,size:tt,className:et})),ref:ot,...nt})});Button.displayName="Button";function allocUnsafe$j(et=0){return new Uint8Array(et)}const N1$6=Math.pow(2,7),N2$6=Math.pow(2,14),N3$6=Math.pow(2,21),N4$6=Math.pow(2,28),N5$6=Math.pow(2,35),N6$6=Math.pow(2,42),N7$6=Math.pow(2,49),MSB$8=128,REST$8=127;function encodingLength$6(et){if(etNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function encodeUint8Array(et,o,tt=0){switch(encodingLength$6(et)){case 8:o[tt++]=et&255|MSB$8,et/=128;case 7:o[tt++]=et&255|MSB$8,et/=128;case 6:o[tt++]=et&255|MSB$8,et/=128;case 5:o[tt++]=et&255|MSB$8,et/=128;case 4:o[tt++]=et&255|MSB$8,et>>>=7;case 3:o[tt++]=et&255|MSB$8,et>>>=7;case 2:o[tt++]=et&255|MSB$8,et>>>=7;case 1:{o[tt++]=et&255,et>>>=7;break}default:throw new Error("unreachable")}return o}function encodeUint8ArrayList(et,o,tt=0){switch(encodingLength$6(et)){case 8:o.set(tt++,et&255|MSB$8),et/=128;case 7:o.set(tt++,et&255|MSB$8),et/=128;case 6:o.set(tt++,et&255|MSB$8),et/=128;case 5:o.set(tt++,et&255|MSB$8),et/=128;case 4:o.set(tt++,et&255|MSB$8),et>>>=7;case 3:o.set(tt++,et&255|MSB$8),et>>>=7;case 2:o.set(tt++,et&255|MSB$8),et>>>=7;case 1:{o.set(tt++,et&255),et>>>=7;break}default:throw new Error("unreachable")}return o}function decodeUint8Array(et,o){let tt=et[o],rt=0;if(rt+=tt&REST$8,tt>>31>0){const tt=~this.lo+1>>>0;let rt=~this.hi>>>0;return tt===0&&(rt=rt+1>>>0),-(tt+rt*4294967296)}return this.lo+this.hi*4294967296}toBigInt(o=!1){if(o)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){const tt=~this.lo+1>>>0;let rt=~this.hi>>>0;return tt===0&&(rt=rt+1>>>0),-(BigInt(tt)+(BigInt(rt)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(o=!1){return this.toBigInt(o).toString()}zzEncode(){const o=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^o)>>>0,this.lo=(this.lo<<1^o)>>>0,this}zzDecode(){const o=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^o)>>>0,this.hi=(this.hi>>>1^o)>>>0,this}length(){const o=this.lo,tt=(this.lo>>>28|this.hi<<4)>>>0,rt=this.hi>>>24;return rt===0?tt===0?o<16384?o<128?1:2:o<2097152?3:4:tt<16384?tt<128?5:6:tt<2097152?7:8:rt<128?9:10}static fromBigInt(o){if(o===0n)return zero;if(oMIN_SAFE_NUMBER_INTEGER)return this.fromNumber(Number(o));const tt=o<0n;tt&&(o=-o);let rt=o>>32n,nt=o-(rt<<32n);return tt&&(rt=~rt|0n,nt=~nt|0n,++nt>TWO_32&&(nt=0n,++rt>TWO_32&&(rt=0n))),new Sn(Number(nt),Number(rt))}static fromNumber(o){if(o===0)return zero;const tt=o<0;tt&&(o=-o);let rt=o>>>0,nt=(o-rt)/4294967296>>>0;return tt&&(nt=~nt>>>0,rt=~rt>>>0,++rt>4294967295&&(rt=0,++nt>4294967295&&(nt=0))),new Sn(rt,nt)}static from(o){return typeof o=="number"?Sn.fromNumber(o):typeof o=="bigint"?Sn.fromBigInt(o):typeof o=="string"?Sn.fromBigInt(BigInt(o)):o.low!=null||o.high!=null?new Sn(o.low>>>0,o.high>>>0):zero}};const zero=new LongBits$2(0,0);zero.toBigInt=function(){return 0n};zero.zzEncode=zero.zzDecode=function(){return this};zero.length=function(){return 1};const TWO_32=4294967296n;function length$6(et){let o=0,tt=0;for(let rt=0;rt191&&st<224?ot[it++]=(st&31)<<6|et[o++]&63:st>239&&st<365?(st=((st&7)<<18|(et[o++]&63)<<12|(et[o++]&63)<<6|et[o++]&63)-65536,ot[it++]=55296+(st>>10),ot[it++]=56320+(st&1023)):ot[it++]=(st&15)<<12|(et[o++]&63)<<6|et[o++]&63,it>8191&&((nt??(nt=[])).push(String.fromCharCode.apply(String,ot)),it=0);return nt!=null?(it>0&&nt.push(String.fromCharCode.apply(String,ot.slice(0,it))),nt.join("")):String.fromCharCode.apply(String,ot.slice(0,it))}function write$2(et,o,tt){const rt=tt;let nt,ot;for(let it=0;it>6|192,o[tt++]=nt&63|128):(nt&64512)===55296&&((ot=et.charCodeAt(it+1))&64512)===56320?(nt=65536+((nt&1023)<<10)+(ot&1023),++it,o[tt++]=nt>>18|240,o[tt++]=nt>>12&63|128,o[tt++]=nt>>6&63|128,o[tt++]=nt&63|128):(o[tt++]=nt>>12|224,o[tt++]=nt>>6&63|128,o[tt++]=nt&63|128);return tt-rt}function indexOutOfRange$1(et,o){return RangeError(`index out of range: ${et.pos} + ${o??1} > ${et.len}`)}function readFixed32End(et,o){return(et[o-4]|et[o-3]<<8|et[o-2]<<16|et[o-1]<<24)>>>0}class Uint8ArrayReader{constructor(o){wt(this,"buf");wt(this,"pos");wt(this,"len");wt(this,"_slice",Uint8Array.prototype.subarray);this.buf=o,this.pos=0,this.len=o.length}uint32(){let o=4294967295;if(o=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(o=(o|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return o;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange$1(this,10);return o}int32(){return this.uint32()|0}sint32(){const o=this.uint32();return o>>>1^-(o&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);return readFixed32End(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);return readFixed32End(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);const o=readFloatLE(this.buf,this.pos);return this.pos+=4,o}double(){if(this.pos+8>this.len)throw indexOutOfRange$1(this,4);const o=readDoubleLE(this.buf,this.pos);return this.pos+=8,o}bytes(){const o=this.uint32(),tt=this.pos,rt=this.pos+o;if(rt>this.len)throw indexOutOfRange$1(this,o);return this.pos+=o,tt===rt?new Uint8Array(0):this.buf.subarray(tt,rt)}string(){const o=this.bytes();return read$7(o,0,o.length)}skip(o){if(typeof o=="number"){if(this.pos+o>this.len)throw indexOutOfRange$1(this,o);this.pos+=o}else do if(this.pos>=this.len)throw indexOutOfRange$1(this);while(this.buf[this.pos++]&128);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(;(o=this.uint32()&7)!==4;)this.skipType(o);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${o} at offset ${this.pos}`)}return this}readLongVarint(){const o=new LongBits$2(0,0);let tt=0;if(this.len-this.pos>4){for(;tt<4;++tt)if(o.lo=(o.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return o;if(o.lo=(o.lo|(this.buf[this.pos]&127)<<28)>>>0,o.hi=(o.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return o;tt=0}else{for(;tt<3;++tt){if(this.pos>=this.len)throw indexOutOfRange$1(this);if(o.lo=(o.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return o}return o.lo=(o.lo|(this.buf[this.pos++]&127)<>>0,o}if(this.len-this.pos>4){for(;tt<5;++tt)if(o.hi=(o.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return o}else for(;tt<5;++tt){if(this.pos>=this.len)throw indexOutOfRange$1(this);if(o.hi=(o.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return o}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange$1(this,8);const o=readFixed32End(this.buf,this.pos+=4),tt=readFixed32End(this.buf,this.pos+=4);return new LongBits$2(o,tt)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const o=decodeUint8Array(this.buf,this.pos);return this.pos+=encodingLength$6(o),o}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(et){return new Uint8ArrayReader(et instanceof Uint8Array?et:et.subarray())}function decodeMessage(et,o,tt){const rt=createReader(et);return o.decode(rt,void 0,tt)}function allocUnsafe$i(et=0){return new Uint8Array(et)}function coerce$k(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$w(et){return new TextEncoder().encode(et)}function toString$x(et){return new TextDecoder().decode(et)}function base$l(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$l=base$l,_brrp__multiformats_scope_baseX$k=src$l;let Encoder$m=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$m=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$m(this,o)}},ComposedDecoder$k=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$m(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$m(et,o){return new ComposedDecoder$k({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$k=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$m(o,tt,rt),this.decoder=new Decoder$m(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$n({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$k(et,o,tt,rt)}function baseX$k({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$k(tt,et);return from$n({prefix:o,name:et,encode:rt,decode:ot=>coerce$k(nt(ot))})}function decode$Y(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$O(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$g=alphabet$g.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$N(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$g[tt],o),"")}function decode$X(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$g[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$w=from$n({prefix:"🚀",name:"base256emoji",encode:encode$N,decode:decode$X}),base256emoji$x=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$w},Symbol.toStringTag,{value:"Module"})),base32$A=rfc4648$j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$g=rfc4648$j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$g=rfc4648$j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$g=rfc4648$j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$g=rfc4648$j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$g=rfc4648$j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$g=rfc4648$j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$g=rfc4648$j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$g=rfc4648$j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$B=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$A,base32hex:base32hex$g,base32hexpad:base32hexpad$g,base32hexpadupper:base32hexpadupper$g,base32hexupper:base32hexupper$g,base32pad:base32pad$g,base32padupper:base32padupper$g,base32upper:base32upper$g,base32z:base32z$g},Symbol.toStringTag,{value:"Module"})),base36$x=baseX$k({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$g=baseX$k({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$y=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$x,base36upper:base36upper$g},Symbol.toStringTag,{value:"Module"})),base58btc$k=baseX$k({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$g=baseX$k({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$g=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$k,base58flickr:base58flickr$g},Symbol.toStringTag,{value:"Module"})),base64$z=rfc4648$j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$g=rfc4648$j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$h=rfc4648$j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$g=rfc4648$j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$A=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$z,base64pad:base64pad$g,base64url:base64url$h,base64urlpad:base64urlpad$g},Symbol.toStringTag,{value:"Module"})),base8$w=rfc4648$j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$x=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$w},Symbol.toStringTag,{value:"Module"})),identity$i=from$n({prefix:"\0",name:"identity",encode:et=>toString$x(et),decode:et=>fromString$w(et)}),identityBase$g=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$i},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$g={...identityBase$g,...base2$x,...base8$x,...base10$x,...base16$x,...base32$B,...base36$y,...base58$g,...base64$A,...base256emoji$x};function createCodec$h(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$k=createCodec$h("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$g=createCodec$h("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$i(et.length);for(let tt=0;tt4096)return allocUnsafe$i(it);nt+it>8192&&(rt=allocUnsafe$i(8192),nt=0);const st=rt.subarray(nt,nt+=it);return nt&7&&(nt=(nt|7)+1),st}}let Op$1=class{constructor(o,tt,rt){wt(this,"fn");wt(this,"len");wt(this,"next");wt(this,"val");this.fn=o,this.len=tt,this.next=void 0,this.val=rt}};function noop$2(){}let State$1=class{constructor(o){wt(this,"head");wt(this,"tail");wt(this,"len");wt(this,"next");this.head=o.head,this.tail=o.tail,this.len=o.len,this.next=o.states}};const bufferPool=pool$1();function alloc$7(et){return globalThis.Buffer!=null?allocUnsafe$i(et):bufferPool(et)}class Uint8ArrayWriter{constructor(){wt(this,"len");wt(this,"head");wt(this,"tail");wt(this,"states");this.len=0,this.head=new Op$1(noop$2,0,0),this.tail=this.head,this.states=null}_push(o,tt,rt){return this.tail=this.tail.next=new Op$1(o,tt,rt),this.len+=tt,this}uint32(o){return this.len+=(this.tail=this.tail.next=new VarintOp$1((o=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$1,10,LongBits$2.fromNumber(o)):this.uint32(o)}sint32(o){return this.uint32((o<<1^o>>31)>>>0)}uint64(o){const tt=LongBits$2.fromBigInt(o);return this._push(writeVarint64$1,tt.length(),tt)}uint64Number(o){return this._push(encodeUint8Array,encodingLength$6(o),o)}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){const tt=LongBits$2.fromBigInt(o).zzEncode();return this._push(writeVarint64$1,tt.length(),tt)}sint64Number(o){const tt=LongBits$2.fromNumber(o).zzEncode();return this._push(writeVarint64$1,tt.length(),tt)}sint64String(o){return this.sint64(BigInt(o))}bool(o){return this._push(writeByte$1,1,o?1:0)}fixed32(o){return this._push(writeFixed32$1,4,o>>>0)}sfixed32(o){return this.fixed32(o)}fixed64(o){const tt=LongBits$2.fromBigInt(o);return this._push(writeFixed32$1,4,tt.lo)._push(writeFixed32$1,4,tt.hi)}fixed64Number(o){const tt=LongBits$2.fromNumber(o);return this._push(writeFixed32$1,4,tt.lo)._push(writeFixed32$1,4,tt.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){const tt=o.length>>>0;return tt===0?this._push(writeByte$1,1,0):this.uint32(tt)._push(writeBytes$1,tt,o)}string(o){const tt=length$6(o);return tt!==0?this.uint32(tt)._push(write$2,tt,o):this._push(writeByte$1,1,0)}fork(){return this.states=new State$1(this),this.head=this.tail=new Op$1(noop$2,0,0),this.len=0,this}reset(){return this.states!=null?(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$1(noop$2,0,0),this.len=0),this}ldelim(){const o=this.head,tt=this.tail,rt=this.len;return this.reset().uint32(rt),rt!==0&&(this.tail.next=o.next,this.tail=tt,this.len+=rt),this}finish(){let o=this.head.next;const tt=alloc$7(this.len);let rt=0;for(;o!=null;)o.fn(o.val,tt,rt),rt+=o.len,o=o.next;return tt}}function writeByte$1(et,o,tt){o[tt]=et&255}function writeVarint32$1(et,o,tt){for(;et>127;)o[tt++]=et&127|128,et>>>=7;o[tt]=et}let VarintOp$1=class extends Op$1{constructor(tt,rt){super(writeVarint32$1,tt,rt);wt(this,"next");this.next=void 0}};function writeVarint64$1(et,o,tt){for(;et.hi!==0;)o[tt++]=et.lo&127|128,et.lo=(et.lo>>>7|et.hi<<25)>>>0,et.hi>>>=7;for(;et.lo>127;)o[tt++]=et.lo&127|128,et.lo=et.lo>>>7;o[tt++]=et.lo}function writeFixed32$1(et,o,tt){o[tt]=et&255,o[tt+1]=et>>>8&255,o[tt+2]=et>>>16&255,o[tt+3]=et>>>24}function writeBytes$1(et,o,tt){o.set(et,tt)}globalThis.Buffer!=null&&(Uint8ArrayWriter.prototype.bytes=function(et){const o=et.length>>>0;return this.uint32(o),o>0&&this._push(writeBytesBuffer,o,et),this},Uint8ArrayWriter.prototype.string=function(et){const o=globalThis.Buffer.byteLength(et);return this.uint32(o),o>0&&this._push(writeStringBuffer$1,o,et),this});function writeBytesBuffer(et,o,tt){o.set(et,tt)}function writeStringBuffer$1(et,o,tt){et.length<40?write$2(et,o,tt):o.utf8Write!=null?o.utf8Write(et,tt):o.set(fromString$v(et),tt)}function createWriter(){return new Uint8ArrayWriter}function encodeMessage(et,o){const tt=createWriter();return o.encode(et,tt,{lengthDelimited:!1}),tt.finish()}var CODEC_TYPES;(function(et){et[et.VARINT=0]="VARINT",et[et.BIT64=1]="BIT64",et[et.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",et[et.START_GROUP=3]="START_GROUP",et[et.END_GROUP=4]="END_GROUP",et[et.BIT32=5]="BIT32"})(CODEC_TYPES||(CODEC_TYPES={}));function createCodec$g(et,o,tt,rt){return{name:et,type:o,encode:tt,decode:rt}}function enumeration(et){function o(nt){if(et[nt.toString()]==null)throw new Error("Invalid enum value");return et[nt]}const tt=function(ot,it){const st=o(ot);it.int32(st)},rt=function(ot){const it=ot.int32();return o(it)};return createCodec$g("enum",CODEC_TYPES.VARINT,tt,rt)}function message$1(et,o){return createCodec$g("message",CODEC_TYPES.LENGTH_DELIMITED,et,o)}class MaxLengthError extends Error{constructor(){super(...arguments);wt(this,"code","ERR_MAX_LENGTH");wt(this,"name","MaxLengthError")}}class MaxSizeError extends Error{constructor(){super(...arguments);wt(this,"code","ERR_MAX_SIZE");wt(this,"name","MaxSizeError")}}function alloc$6(et=0){return globalThis.Buffer!=null&&globalThis.Buffer.alloc!=null?globalThis.Buffer.alloc(et):new Uint8Array(et)}function allocUnsafe$h(et=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(et):new Uint8Array(et)}var RateLimitProof$4;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof$4||(RateLimitProof$4={}));var WakuMessage$4;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof$4.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$4.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage$4||(WakuMessage$4={}));var FilterRequest;(function(et){(function(tt){let rt;tt.codec=()=>(rt==null&&(rt=message$1((nt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),nt.contentTopic!=null&&nt.contentTopic!==""&&(ot.uint32(10),ot.string(nt.contentTopic)),it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{const st={contentTopic:""},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.contentTopic=nt.string();break}default:{nt.skipType(ct&7);break}}}return st})),rt),tt.encode=nt=>encodeMessage(nt,tt.codec()),tt.decode=(nt,ot)=>decodeMessage(nt,tt.codec(),ot)})(et.ContentFilter||(et.ContentFilter={}));let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.subscribe!=null&&tt.subscribe!==!1&&(rt.uint32(8),rt.bool(tt.subscribe)),tt.topic!=null&&tt.topic!==""&&(rt.uint32(18),rt.string(tt.topic)),tt.contentFilters!=null)for(const ot of tt.contentFilters)rt.uint32(26),et.ContentFilter.codec().encode(ot,rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={subscribe:!1,topic:"",contentFilters:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.subscribe=tt.bool();break}case 2:{ot.topic=tt.string();break}case 3:{if(((st=nt.limits)==null?void 0:st.contentFilters)!=null&&ot.contentFilters.length===nt.limits.contentFilters)throw new MaxLengthError('Decode error - map field "contentFilters" had too many elements');ot.contentFilters.push(et.ContentFilter.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.contentFilters$}));break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(FilterRequest||(FilterRequest={}));var MessagePush$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.messages!=null)for(const ot of tt.messages)rt.uint32(10),WakuMessage$3.codec().encode(ot,rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={messages:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{if(((st=nt.limits)==null?void 0:st.messages)!=null&&ot.messages.length===nt.limits.messages)throw new MaxLengthError('Decode error - map field "messages" had too many elements');ot.messages.push(WakuMessage$3.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.messages$}));break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(MessagePush$1||(MessagePush$1={}));var FilterRpc;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.request!=null&&(rt.uint32(18),FilterRequest.codec().encode(tt.request,rt)),tt.push!=null&&(rt.uint32(26),MessagePush$1.codec().encode(tt.push,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={requestId:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.request=FilterRequest.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.request});break}case 3:{ot.push=MessagePush$1.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.push});break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(FilterRpc||(FilterRpc={}));var RateLimitProof$3;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof$3||(RateLimitProof$3={}));var WakuMessage$3;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof$3.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$3.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage$3||(WakuMessage$3={}));var TopicOnlyMessage;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 2:{ot.contentTopic=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(TopicOnlyMessage||(TopicOnlyMessage={}));var FilterSubscribeRequest;(function(et){let o;(function(nt){nt.SUBSCRIBER_PING="SUBSCRIBER_PING",nt.SUBSCRIBE="SUBSCRIBE",nt.UNSUBSCRIBE="UNSUBSCRIBE",nt.UNSUBSCRIBE_ALL="UNSUBSCRIBE_ALL"})(o=et.FilterSubscribeType||(et.FilterSubscribeType={}));let tt;(function(nt){nt[nt.SUBSCRIBER_PING=0]="SUBSCRIBER_PING",nt[nt.SUBSCRIBE=1]="SUBSCRIBE",nt[nt.UNSUBSCRIBE=2]="UNSUBSCRIBE",nt[nt.UNSUBSCRIBE_ALL=3]="UNSUBSCRIBE_ALL"})(tt||(tt={})),function(nt){nt.codec=()=>enumeration(tt)}(o=et.FilterSubscribeType||(et.FilterSubscribeType={}));let rt;et.codec=()=>(rt==null&&(rt=message$1((nt,ot,it={})=>{if(it.lengthDelimited!==!1&&ot.fork(),nt.requestId!=null&&nt.requestId!==""&&(ot.uint32(10),ot.string(nt.requestId)),nt.filterSubscribeType!=null&&tt[nt.filterSubscribeType]!==0&&(ot.uint32(16),et.FilterSubscribeType.codec().encode(nt.filterSubscribeType,ot)),nt.pubsubTopic!=null&&(ot.uint32(82),ot.string(nt.pubsubTopic)),nt.contentTopics!=null)for(const st of nt.contentTopics)ot.uint32(90),ot.string(st);it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{var ct;const st={requestId:"",filterSubscribeType:o.SUBSCRIBER_PING,contentTopics:[]},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.requestId=nt.string();break}case 2:{st.filterSubscribeType=et.FilterSubscribeType.codec().decode(nt);break}case 10:{st.pubsubTopic=nt.string();break}case 11:{if(((ct=it.limits)==null?void 0:ct.contentTopics)!=null&&st.contentTopics.length===it.limits.contentTopics)throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');st.contentTopics.push(nt.string());break}default:{nt.skipType(lt&7);break}}}return st})),rt),et.encode=nt=>encodeMessage(nt,et.codec()),et.decode=(nt,ot)=>decodeMessage(nt,et.codec(),ot)})(FilterSubscribeRequest||(FilterSubscribeRequest={}));var FilterSubscribeResponse$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.statusCode!=null&&tt.statusCode!==0&&(rt.uint32(80),rt.uint32(tt.statusCode)),tt.statusDesc!=null&&(rt.uint32(90),rt.string(tt.statusDesc)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={requestId:"",statusCode:0},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 10:{ot.statusCode=tt.uint32();break}case 11:{ot.statusDesc=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(FilterSubscribeResponse$1||(FilterSubscribeResponse$1={}));var MessagePush;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.wakuMessage!=null&&(rt.uint32(10),WakuMessage$2.codec().encode(tt.wakuMessage,rt)),tt.pubsubTopic!=null&&(rt.uint32(18),rt.string(tt.pubsubTopic)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.wakuMessage=WakuMessage$2.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.wakuMessage});break}case 2:{ot.pubsubTopic=tt.string();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(MessagePush||(MessagePush={}));var RateLimitProof$2;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof$2||(RateLimitProof$2={}));var WakuMessage$2;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof$2.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$2.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage$2||(WakuMessage$2={}));var PushRequest;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.pubsubTopic!=null&&tt.pubsubTopic!==""&&(rt.uint32(10),rt.string(tt.pubsubTopic)),tt.message!=null&&(rt.uint32(18),WakuMessage$1.codec().encode(tt.message,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={pubsubTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.pubsubTopic=tt.string();break}case 2:{ot.message=WakuMessage$1.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.message});break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PushRequest||(PushRequest={}));var PushResponse;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.isSuccess!=null&&tt.isSuccess!==!1&&(rt.uint32(8),rt.bool(tt.isSuccess)),tt.info!=null&&(rt.uint32(18),rt.string(tt.info)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={isSuccess:!1},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.isSuccess=tt.bool();break}case 2:{ot.info=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PushResponse||(PushResponse={}));var PushRpc$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.request!=null&&(rt.uint32(18),PushRequest.codec().encode(tt.request,rt)),tt.response!=null&&(rt.uint32(26),PushResponse.codec().encode(tt.response,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={requestId:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.request=PushRequest.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.request});break}case 3:{ot.response=PushResponse.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.response});break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PushRpc$1||(PushRpc$1={}));var RateLimitProof$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof$1||(RateLimitProof$1={}));var WakuMessage$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof$1.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$1.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage$1||(WakuMessage$1={}));var WakuMessageKeyValue;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.messageHash!=null&&(rt.uint32(10),rt.bytes(tt.messageHash)),tt.message!=null&&(rt.uint32(18),WakuMessage.codec().encode(tt.message,rt)),tt.pubsubTopic!=null&&(rt.uint32(26),rt.string(tt.pubsubTopic)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.messageHash=tt.bytes();break}case 2:{ot.message=WakuMessage.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.message});break}case 3:{ot.pubsubTopic=tt.string();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessageKeyValue||(WakuMessageKeyValue={}));var StoreQueryRequest$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.includeData!=null&&tt.includeData!==!1&&(rt.uint32(16),rt.bool(tt.includeData)),tt.pubsubTopic!=null&&(rt.uint32(82),rt.string(tt.pubsubTopic)),tt.contentTopics!=null)for(const ot of tt.contentTopics)rt.uint32(90),rt.string(ot);if(tt.timeStart!=null&&(rt.uint32(96),rt.sint64(tt.timeStart)),tt.timeEnd!=null&&(rt.uint32(104),rt.sint64(tt.timeEnd)),tt.messageHashes!=null)for(const ot of tt.messageHashes)rt.uint32(162),rt.bytes(ot);tt.paginationCursor!=null&&(rt.uint32(410),rt.bytes(tt.paginationCursor)),tt.paginationForward!=null&&tt.paginationForward!==!1&&(rt.uint32(416),rt.bool(tt.paginationForward)),tt.paginationLimit!=null&&(rt.uint32(424),rt.uint64(tt.paginationLimit)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={requestId:"",includeData:!1,contentTopics:[],messageHashes:[],paginationForward:!1},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.includeData=tt.bool();break}case 10:{ot.pubsubTopic=tt.string();break}case 11:{if(((st=nt.limits)==null?void 0:st.contentTopics)!=null&&ot.contentTopics.length===nt.limits.contentTopics)throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');ot.contentTopics.push(tt.string());break}case 12:{ot.timeStart=tt.sint64();break}case 13:{ot.timeEnd=tt.sint64();break}case 20:{if(((at=nt.limits)==null?void 0:at.messageHashes)!=null&&ot.messageHashes.length===nt.limits.messageHashes)throw new MaxLengthError('Decode error - map field "messageHashes" had too many elements');ot.messageHashes.push(tt.bytes());break}case 51:{ot.paginationCursor=tt.bytes();break}case 52:{ot.paginationForward=tt.bool();break}case 53:{ot.paginationLimit=tt.uint64();break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(StoreQueryRequest$1||(StoreQueryRequest$1={}));var StoreQueryResponse$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.requestId!=null&&tt.requestId!==""&&(rt.uint32(10),rt.string(tt.requestId)),tt.statusCode!=null&&(rt.uint32(80),rt.uint32(tt.statusCode)),tt.statusDesc!=null&&(rt.uint32(90),rt.string(tt.statusDesc)),tt.messages!=null)for(const ot of tt.messages)rt.uint32(162),WakuMessageKeyValue.codec().encode(ot,rt);tt.paginationCursor!=null&&(rt.uint32(410),rt.bytes(tt.paginationCursor)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={requestId:"",messages:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 10:{ot.statusCode=tt.uint32();break}case 11:{ot.statusDesc=tt.string();break}case 20:{if(((st=nt.limits)==null?void 0:st.messages)!=null&&ot.messages.length===nt.limits.messages)throw new MaxLengthError('Decode error - map field "messages" had too many elements');ot.messages.push(WakuMessageKeyValue.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.messages$}));break}case 51:{ot.paginationCursor=tt.bytes();break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(StoreQueryResponse$1||(StoreQueryResponse$1={}));var RateLimitProof;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(rt.uint32(10),rt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(rt.uint32(18),rt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(rt.uint32(26),rt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(rt.uint32(34),rt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(rt.uint32(42),rt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(rt.uint32(50),rt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(rt.uint32(58),rt.bytes(tt.rlnIdentifier)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={proof:alloc$6(0),merkleRoot:alloc$6(0),epoch:alloc$6(0),shareX:alloc$6(0),shareY:alloc$6(0),nullifier:alloc$6(0),rlnIdentifier:alloc$6(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(RateLimitProof||(RateLimitProof={}));var WakuMessage;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(10),rt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(rt.uint32(18),rt.string(tt.contentTopic)),tt.version!=null&&(rt.uint32(24),rt.uint32(tt.version)),tt.timestamp!=null&&(rt.uint32(80),rt.sint64(tt.timestamp)),tt.meta!=null&&(rt.uint32(90),rt.bytes(tt.meta)),tt.rateLimitProof!=null&&(rt.uint32(170),RateLimitProof.codec().encode(tt.rateLimitProof,rt)),tt.ephemeral!=null&&(rt.uint32(248),rt.bool(tt.ephemeral)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={payload:alloc$6(0),contentTopic:""},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMessage||(WakuMessage={}));var PeerInfo;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.enr!=null&&(rt.uint32(10),rt.bytes(tt.enr)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.enr=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerInfo||(PeerInfo={}));var PeerExchangeQuery;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.numPeers!=null&&(rt.uint32(8),rt.uint64(tt.numPeers)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.numPeers=tt.uint64();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerExchangeQuery||(PeerExchangeQuery={}));var PeerExchangeResponse;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.peerInfos!=null)for(const ot of tt.peerInfos)rt.uint32(10),PeerInfo.codec().encode(ot,rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={peerInfos:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{if(((st=nt.limits)==null?void 0:st.peerInfos)!=null&&ot.peerInfos.length===nt.limits.peerInfos)throw new MaxLengthError('Decode error - map field "peerInfos" had too many elements');ot.peerInfos.push(PeerInfo.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.peerInfos$}));break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerExchangeResponse||(PeerExchangeResponse={}));var PeerExchangeRPC$1;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.query!=null&&(rt.uint32(10),PeerExchangeQuery.codec().encode(tt.query,rt)),tt.response!=null&&(rt.uint32(18),PeerExchangeResponse.codec().encode(tt.response,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.query=PeerExchangeQuery.codec().decode(tt,tt.uint32(),{limits:(st=nt.limits)==null?void 0:st.query});break}case 2:{ot.response=PeerExchangeResponse.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.response});break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerExchangeRPC$1||(PeerExchangeRPC$1={}));var WakuMetadataRequest;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.clusterId!=null&&(rt.uint32(8),rt.uint32(tt.clusterId)),tt.shards!=null)for(const ot of tt.shards)rt.uint32(16),rt.uint32(ot);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={shards:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.clusterId=tt.uint32();break}case 2:{if(((st=nt.limits)==null?void 0:st.shards)!=null&&ot.shards.length===nt.limits.shards)throw new MaxLengthError('Decode error - map field "shards" had too many elements');ot.shards.push(tt.uint32());break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMetadataRequest||(WakuMetadataRequest={}));var WakuMetadataResponse;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.clusterId!=null&&(rt.uint32(8),rt.uint32(tt.clusterId)),tt.shards!=null)for(const ot of tt.shards)rt.uint32(16),rt.uint32(ot);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st;const ot={shards:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.clusterId=tt.uint32();break}case 2:{if(((st=nt.limits)==null?void 0:st.shards)!=null&&ot.shards.length===nt.limits.shards)throw new MaxLengthError('Decode error - map field "shards" had too many elements');ot.shards.push(tt.uint32());break}default:{tt.skipType(at&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(WakuMetadataResponse||(WakuMetadataResponse={}));function isDefined(et){return!!et}function groupByContentTopic(et){const o=new Map;return et.forEach(tt=>{let rt=o.get(tt.contentTopic);rt||(o.set(tt.contentTopic,[]),rt=o.get(tt.contentTopic)),rt.push(tt)}),o}const FRAME_RATE=60;async function toAsyncIterator(et,o,tt){const rt=FRAME_RATE,nt=[];let ot;ot=await et.subscribeWithUnsubscribe(o,lt=>{nt.push(lt)});const it=Number.isInteger(tt==null?void 0:tt.timeoutMs),st=0,at=Date.now();async function*ct(){for(;;){if(it&&Date.now()-at>=st)return;await wait(rt);const lt=nt.shift();if(!ot&&nt.length===0)return lt;!lt&&ot||(yield lt)}}return{iterator:ct(),async stop(){ot&&(await ot(),ot=void 0)}}}function wait(et){return new Promise(o=>{setTimeout(o,et)})}const MB=1024**2,SIZE_CAP_IN_MB=1;async function isMessageSizeUnderCap(et,o){const tt=await et.toWire(o);return tt?isWireSizeUnderCap(tt):!1}const isWireSizeUnderCap=et=>et.length/MB<=SIZE_CAP_IN_MB;var Protocols;(function(et){et.Relay="relay",et.Store="store",et.LightPush="lightpush",et.Filter="filter"})(Protocols||(Protocols={}));var ProtocolError$1;(function(et){et.GENERIC_FAIL="Generic error",et.ENCODE_FAILED="Failed to encode",et.DECODE_FAILED="Failed to decode",et.EMPTY_PAYLOAD="Payload is empty",et.SIZE_TOO_BIG="Size is too big",et.TOPIC_NOT_CONFIGURED="Topic not configured",et.TOPIC_DECODER_MISMATCH="Topic decoder mismatch",et.INVALID_DECODER_TOPICS="Invalid decoder topics",et.NO_PEER_AVAILABLE="No peer available",et.NO_STREAM_AVAILABLE="No stream available",et.NO_RESPONSE="No response received",et.REMOTE_PEER_REJECTED="Remote peer rejected",et.REQUEST_TIMEOUT="Request timeout",et.RLN_IDENTITY_MISSING="Identity credentials are not set",et.RLN_MEMBERSHIP_INDEX="Membership index is not set",et.RLN_LIMIT_MISSING="User message limit is not set",et.RLN_PROOF_GENERATION="Proof generation failed"})(ProtocolError$1||(ProtocolError$1={}));var Tags;(function(et){et.BOOTSTRAP="bootstrap",et.PEER_EXCHANGE="peer-exchange",et.LOCAL="local-peer-cache"})(Tags||(Tags={}));var EPeersByDiscoveryEvents;(function(et){et.PEER_DISCOVERY_BOOTSTRAP="peer:discovery:bootstrap",et.PEER_DISCOVERY_PEER_EXCHANGE="peer:discovery:peer-exchange",et.PEER_CONNECT_BOOTSTRAP="peer:connected:bootstrap",et.PEER_CONNECT_PEER_EXCHANGE="peer:connected:peer-exchange"})(EPeersByDiscoveryEvents||(EPeersByDiscoveryEvents={}));var EConnectionStateEvents;(function(et){et.CONNECTION_STATUS="waku:connection"})(EConnectionStateEvents||(EConnectionStateEvents={}));const DNS_DISCOVERY_TAG="@waku/bootstrap",DEFAULT_CLUSTER_ID=1,DefaultShardInfo={clusterId:DEFAULT_CLUSTER_ID,shards:[0,1,2,3,4,5,6,7,8]},DefaultNetworkConfig=DefaultShardInfo;var HealthStatus;(function(et){et.Unhealthy="Unhealthy",et.MinimallyHealthy="MinimallyHealthy",et.SufficientlyHealthy="SufficientlyHealthy"})(HealthStatus||(HealthStatus={}));function coerce$j(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$u(et){return new TextEncoder().encode(et)}function toString$w(et){return new TextDecoder().decode(et)}function base$k(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$k=base$k,_brrp__multiformats_scope_baseX$j=src$k;let Encoder$l=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$l=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$l(this,o)}},ComposedDecoder$j=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$l(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$l(et,o){return new ComposedDecoder$j({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$j=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$l(o,tt,rt),this.decoder=new Decoder$l(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$m({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$j(et,o,tt,rt)}function baseX$j({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$j(tt,et);return from$m({prefix:o,name:et,encode:rt,decode:ot=>coerce$j(nt(ot))})}function decode$W(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$M(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$f=alphabet$f.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$L(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$f[tt],o),"")}function decode$V(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$f[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$u=from$m({prefix:"🚀",name:"base256emoji",encode:encode$L,decode:decode$V}),base256emoji$v=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$u},Symbol.toStringTag,{value:"Module"})),base32$y=rfc4648$i({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$f=rfc4648$i({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$f=rfc4648$i({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$f=rfc4648$i({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$f=rfc4648$i({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$f=rfc4648$i({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$f=rfc4648$i({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$f=rfc4648$i({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$f=rfc4648$i({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$z=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$y,base32hex:base32hex$f,base32hexpad:base32hexpad$f,base32hexpadupper:base32hexpadupper$f,base32hexupper:base32hexupper$f,base32pad:base32pad$f,base32padupper:base32padupper$f,base32upper:base32upper$f,base32z:base32z$f},Symbol.toStringTag,{value:"Module"})),base36$v=baseX$j({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$f=baseX$j({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$w=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$v,base36upper:base36upper$f},Symbol.toStringTag,{value:"Module"})),base58btc$j=baseX$j({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$f=baseX$j({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$f=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$j,base58flickr:base58flickr$f},Symbol.toStringTag,{value:"Module"})),base64$x=rfc4648$i({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$f=rfc4648$i({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$g=rfc4648$i({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$f=rfc4648$i({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$y=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$x,base64pad:base64pad$f,base64url:base64url$g,base64urlpad:base64urlpad$f},Symbol.toStringTag,{value:"Module"})),base8$u=rfc4648$i({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$v=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$u},Symbol.toStringTag,{value:"Module"})),identity$h=from$m({prefix:"\0",name:"identity",encode:et=>toString$w(et),decode:et=>fromString$u(et)}),identityBase$f=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$h},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$f={...identityBase$f,...base2$v,...base8$v,...base10$v,...base16$v,...base32$z,...base36$w,...base58$f,...base64$y,...base256emoji$v};function allocUnsafe$g(et=0){return new Uint8Array(et)}function createCodec$f(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$j=createCodec$f("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$f=createCodec$f("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$g(et.length);for(let tt=0;tttoString$v(et,"base16"),bytesToUtf8=et=>toString$v(et,"utf8"),utf8ToBytes$1=et=>fromString$t(et,"utf8");function concat$5(et,o){const tt=et.reduce((ot,it)=>ot+it.length,0),rt=new Uint8Array(tt);let nt=0;for(const ot of et)rt.set(ot,nt),nt+=ot.length;return rt}function isStaticSharding(et){return"clusterId"in et&&"shards"in et&&!("contentTopics"in et)}function isAutoSharding(et){return"contentTopics"in et}function derivePubsubTopicsFromNetworkConfig(et){if(isStaticSharding(et)){if(et.shards.length===0)throw new Error("Invalid shards configuration: please provide at least one shard");return shardInfoToPubsubTopics(et)}else if(isAutoSharding(et)){if(et.contentTopics.length===0)throw new Error("Invalid content topics configuration: please provide at least one content topic");return et.contentTopics.map(o=>contentTopicToPubsubTopic(o,et.clusterId))}else throw new Error("Unknown shard config. Please use ShardInfo or ContentTopicInfo")}const singleShardInfoToPubsubTopic=et=>{if(et.shard===void 0)throw new Error("Invalid shard");return`/waku/2/rs/${et.clusterId??DEFAULT_CLUSTER_ID}/${et.shard}`},shardInfoToPubsubTopics=et=>{if("contentTopics"in et&&et.contentTopics)return Array.from(new Set(et.contentTopics.map(o=>contentTopicToPubsubTopic(o,et.clusterId))));if("shards"in et){if(et.shards===void 0)throw new Error("Invalid shard");return Array.from(new Set(et.shards.map(o=>`/waku/2/rs/${et.clusterId??DEFAULT_CLUSTER_ID}/${o}`)))}else{if("application"in et&&"version"in et)return[contentTopicToPubsubTopic(`/${et.application}/${et.version}/default/default`,et.clusterId)];throw new Error("Missing required configuration in shard parameters")}},pubsubTopicToSingleShardInfo=et=>{const o=et.split("/");if(o.length!=6||o[1]!=="waku"||o[2]!=="2"||o[3]!=="rs")throw new Error("Invalid pubsub topic");const tt=parseInt(o[4]),rt=parseInt(o[5]);if(isNaN(tt)||isNaN(rt))throw new Error("Invalid clusterId or shard");return{clusterId:tt,shard:rt}},pubsubTopicsToShardInfo=et=>{const o=new Set,tt=new Set;for(const ot of et){const{clusterId:it,shard:st}=pubsubTopicToSingleShardInfo(ot);o.add(`${it}:${st}`),tt.add(it)}if(o.size===0)throw new Error("No valid pubsub topics provided");if(tt.size>1)throw new Error("Pubsub topics from multiple cluster IDs are not supported");const rt=tt.values().next().value,nt=Array.from(o).map(ot=>parseInt(ot.split(":")[1]));return{clusterId:rt,shards:nt}};function ensurePubsubTopicIsConfigured(et,o){if(!o.includes(et))throw new Error(`Pubsub topic ${et} has not been configured on this instance. Configured topics are: ${o}. Please update your configuration by passing in the topic during Waku node instantiation.`)}function ensureValidContentTopic(et){const o=et.split("/");if(o.length<5||o.length>6)throw Error("Content topic format is invalid");let tt=0;if(o.length==6){if(tt=parseInt(o[1]),isNaN(tt))throw new Error("Invalid generation field in content topic");if(tt>0)throw new Error("Generation greater than 0 is not supported")}const rt=o.splice(-4);if(rt[0].length==0)throw new Error("Application field cannot be empty");if(rt[1].length==0)throw new Error("Version field cannot be empty");if(rt[2].length==0)throw new Error("Topic name field cannot be empty");if(rt[3].length==0)throw new Error("Encoding field cannot be empty");return{generation:tt,application:rt[0],version:rt[1],topicName:rt[2],encoding:rt[3]}}function contentTopicToShardIndex(et,o=8){const{application:tt,version:rt}=ensureValidContentTopic(et),nt=sha256$3(concat$5([utf8ToBytes$1(tt),utf8ToBytes$1(rt)])),ot=new DataView(nt.buffer.slice(-8));return Number(ot.getBigUint64(0,!1)%BigInt(o))}function contentTopicToPubsubTopic(et,o=DEFAULT_CLUSTER_ID,tt=8){if(!et)throw Error("Content topic must be specified");const rt=contentTopicToShardIndex(et,tt);return`/waku/2/rs/${o}/${rt}`}function determinePubsubTopic(et,o){return typeof o=="string"?o:(o==null?void 0:o.shard)!==void 0?singleShardInfoToPubsubTopic(o):contentTopicToPubsubTopic(et,(o==null?void 0:o.clusterId)??DEFAULT_CLUSTER_ID)}const decodeRelayShard=et=>{if(et=new Uint8Array(et),et.length<3)throw new Error("Insufficient data");const o=new DataView(et.buffer),tt=o.getUint16(0),rt=[];if(et.length===130)for(let nt=0;nt<1024;nt++){const ot=Math.floor(nt/8)+2,it=7-nt%8;o.getUint8(ot)&1<=et.length)throw new Error("Unexpected end of data");rt.push(o.getUint16(it))}}return{clusterId:tt,shards:rt}},encodeRelayShard=et=>{const{clusterId:o,shards:tt}=et,rt=tt.length>=64?130:3+2*tt.length,nt=new ArrayBuffer(rt),ot=new DataView(nt);if(ot.setUint16(0,o),tt.length>=64)for(const it of tt){const st=Math.floor(it/8)+2,at=7-it%8;ot.setUint8(st,ot.getUint8(st)|1<tt.toString().includes("ws")||tt.toString().includes("wss"));if(!o)throw new Error("No ws multiaddr found in the given addresses");return o}var browser={exports:{}},ms$1,hasRequiredMs;function requireMs(){if(hasRequiredMs)return ms$1;hasRequiredMs=1;var et=1e3,o=et*60,tt=o*60,rt=tt*24,nt=rt*7,ot=rt*365.25;ms$1=function(lt,dt){dt=dt||{};var ht=typeof lt;if(ht==="string"&<.length>0)return it(lt);if(ht==="number"&&isFinite(lt))return dt.long?at(lt):st(lt);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(lt))};function it(lt){if(lt=String(lt),!(lt.length>100)){var dt=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(lt);if(dt){var ht=parseFloat(dt[1]),mt=(dt[2]||"ms").toLowerCase();switch(mt){case"years":case"year":case"yrs":case"yr":case"y":return ht*ot;case"weeks":case"week":case"w":return ht*nt;case"days":case"day":case"d":return ht*rt;case"hours":case"hour":case"hrs":case"hr":case"h":return ht*tt;case"minutes":case"minute":case"mins":case"min":case"m":return ht*o;case"seconds":case"second":case"secs":case"sec":case"s":return ht*et;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return ht;default:return}}}}function st(lt){var dt=Math.abs(lt);return dt>=rt?Math.round(lt/rt)+"d":dt>=tt?Math.round(lt/tt)+"h":dt>=o?Math.round(lt/o)+"m":dt>=et?Math.round(lt/et)+"s":lt+"ms"}function at(lt){var dt=Math.abs(lt);return dt>=rt?ct(lt,dt,rt,"day"):dt>=tt?ct(lt,dt,tt,"hour"):dt>=o?ct(lt,dt,o,"minute"):dt>=et?ct(lt,dt,et,"second"):lt+" ms"}function ct(lt,dt,ht,mt){var ft=dt>=ht*1.5;return Math.round(lt/ht)+" "+mt+(ft?"s":"")}return ms$1}function setup$1(et){tt.debug=tt,tt.default=tt,tt.coerce=at,tt.disable=ot,tt.enable=nt,tt.enabled=it,tt.humanize=requireMs(),tt.destroy=ct,Object.keys(et).forEach(lt=>{tt[lt]=et[lt]}),tt.names=[],tt.skips=[],tt.formatters={};function o(lt){let dt=0;for(let ht=0;ht{if(Ct==="%%")return"%";vt++;const At=tt.formatters[St];if(typeof At=="function"){const kt=yt[vt];Ct=At.call(gt,kt),yt.splice(vt,1),vt--}return Ct}),tt.formatArgs.call(gt,yt),(gt.log||tt.log).apply(gt,yt)}return pt.namespace=lt,pt.useColors=tt.useColors(),pt.color=tt.selectColor(lt),pt.extend=rt,pt.destroy=tt.destroy,Object.defineProperty(pt,"enabled",{enumerable:!0,configurable:!1,get:()=>ht!==null?ht:(mt!==tt.namespaces&&(mt=tt.namespaces,ft=tt.enabled(lt)),ft),set:yt=>{ht=yt}}),typeof tt.init=="function"&&tt.init(pt),pt}function rt(lt,dt){const ht=tt(this.namespace+(typeof dt>"u"?":":dt)+lt);return ht.log=this.log,ht}function nt(lt){tt.save(lt),tt.namespaces=lt,tt.names=[],tt.skips=[];let dt;const ht=(typeof lt=="string"?lt:"").split(/[\s,]+/),mt=ht.length;for(dt=0;dt"-"+dt)].join(",");return tt.enable(""),lt}function it(lt){if(lt[lt.length-1]==="*")return!0;let dt,ht;for(dt=0,ht=tt.skips.length;dt{let lt=!1;return()=>{lt||(lt=!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`."))}})(),o.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"];function nt(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let lt;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(lt=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(lt[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function ot(lt){if(lt[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+lt[0]+(this.useColors?"%c ":" ")+"+"+et.exports.humanize(this.diff),!this.useColors)return;const dt="color: "+this.color;lt.splice(1,0,dt,"color: inherit");let ht=0,mt=0;lt[0].replace(/%[a-zA-Z%]/g,ft=>{ft!=="%%"&&(ht++,ft==="%c"&&(mt=ht))}),lt.splice(mt,0,dt)}o.log=console.debug||console.log||(()=>{});function it(lt){try{lt?o.storage.setItem("debug",lt):o.storage.removeItem("debug")}catch{}}function st(){let lt;try{lt=o.storage.getItem("debug")}catch{}return!lt&&typeof tt<"u"&&"env"in tt&&(lt=rt.DEBUG),lt}function at(){try{return localStorage}catch{}}et.exports=common$1(o);const{formatters:ct}=et.exports;ct.j=function(lt){try{return JSON.stringify(lt)}catch(dt){return"[UnexpectedJSONParseError]: "+dt.message}}})(browser,browser.exports);var browserExports=browser.exports;const debug=getDefaultExportFromCjs(browserExports),APP_NAME="waku";let Logger$1=class _i{constructor(o){wt(this,"_info");wt(this,"_warn");wt(this,"_error");this._info=debug(_i.createDebugNamespace("info",o)),this._warn=debug(_i.createDebugNamespace("warn",o)),this._error=debug(_i.createDebugNamespace("error",o))}static createDebugNamespace(o,tt){return tt?`${APP_NAME}:${o}:${tt}`:`${APP_NAME}:${o}`}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}log(o,...tt){const rt=this[o];rt(...tt)}};const log$o=new Logger$1("message:version-0"),OneMillion=BigInt(1e6),Version=0;class DecodedMessage{constructor(o,tt){wt(this,"pubsubTopic");wt(this,"proto");this.pubsubTopic=o,this.proto=tt}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){const o=this.proto.timestamp/OneMillion;return new Date(Number(o))}return}catch{return}}get meta(){return this.proto.meta}get version(){return this.proto.version??0}get rateLimitProof(){return this.proto.rateLimitProof}}let Encoder$k=class{constructor(o,tt=!1,rt,nt){wt(this,"contentTopic");wt(this,"ephemeral");wt(this,"pubsubTopic");wt(this,"metaSetter");if(this.contentTopic=o,this.ephemeral=tt,this.pubsubTopic=rt,this.metaSetter=nt,!o||o==="")throw new Error("Content topic must be specified")}async toWire(o){return WakuMessage$4.encode(await this.toProtoObj(o))}async toProtoObj(o){const tt=o.timestamp??new Date,rt={payload:o.payload,version:Version,contentTopic:this.contentTopic,timestamp:BigInt(tt.valueOf())*OneMillion,meta:void 0,rateLimitProof:o.rateLimitProof,ephemeral:this.ephemeral};if(this.metaSetter){const nt=this.metaSetter(rt);return{...rt,meta:nt}}return rt}};function createEncoder({pubsubTopic:et,pubsubTopicShardInfo:o,contentTopic:tt,ephemeral:rt,metaSetter:nt}){return new Encoder$k(tt,rt,determinePubsubTopic(tt,et??o),nt)}let Decoder$k=class{constructor(o,tt){wt(this,"pubsubTopic");wt(this,"contentTopic");if(this.pubsubTopic=o,this.contentTopic=tt,!tt||tt==="")throw new Error("Content topic must be specified")}fromWireToProtoObj(o){const tt=WakuMessage$4.decode(o);return Promise.resolve({payload:tt.payload,contentTopic:tt.contentTopic,version:tt.version??void 0,timestamp:tt.timestamp??void 0,meta:tt.meta??void 0,rateLimitProof:tt.rateLimitProof??void 0,ephemeral:tt.ephemeral??!1})}async fromProtoObj(o,tt){return tt.version??Version!==0?(log$o.error("Failed to decode due to incorrect version, expected:",Version,", actual:",tt.version),Promise.resolve(void 0)):new DecodedMessage(o,tt)}};function createDecoder(et,o){return new Decoder$k(determinePubsubTopic(et,o),et)}function isAsyncIterable$8(et){return et[Symbol.asyncIterator]!=null}function all$2(et){if(isAsyncIterable$8(et))return(async()=>{const tt=[];for await(const rt of et)tt.push(rt);return tt})();const o=[];for(const tt of et)o.push(tt);return o}function alloc$5(et=0){return new Uint8Array(et)}function allocUnsafe$f(et=0){return new Uint8Array(et)}function asUint8Array$3(et){return et}function concat$4(et,o){o==null&&(o=et.reduce((nt,ot)=>nt+ot.length,0));const tt=allocUnsafe$f(o);let rt=0;for(const nt of et)tt.set(nt,rt),rt+=nt.length;return tt}function equals$f(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt0&&this.appendAll(o)}*[(Zs=symbol$1,Symbol.iterator)](){yield*this.bufs}get byteLength(){return this.length}append(...o){this.appendAll(o)}appendAll(o){let tt=0;for(const rt of o)if(rt instanceof Uint8Array)tt+=rt.byteLength,this.bufs.push(rt);else if(isUint8ArrayList(rt))tt+=rt.byteLength,this.bufs.push(...rt.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=tt}prepend(...o){this.prependAll(o)}prependAll(o){let tt=0;for(const rt of o.reverse())if(rt instanceof Uint8Array)tt+=rt.byteLength,this.bufs.unshift(rt);else if(isUint8ArrayList(rt))tt+=rt.byteLength,this.bufs.unshift(...rt.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=tt}get(o){const tt=findBufAndOffset(this.bufs,o);return tt.buf[tt.index]}set(o,tt){const rt=findBufAndOffset(this.bufs,o);rt.buf[rt.index]=tt}write(o,tt=0){if(o instanceof Uint8Array)for(let rt=0;rt0;)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,tt){const{bufs:rt,length:nt}=this._subList(o,tt);return concat$4(rt,nt)}subarray(o,tt){const{bufs:rt,length:nt}=this._subList(o,tt);return rt.length===1?rt[0]:concat$4(rt,nt)}sublist(o,tt){const{bufs:rt,length:nt}=this._subList(o,tt),ot=new Uint8ArrayList;return ot.length=nt,ot.bufs=[...rt],ot}_subList(o,tt){if(o=o??0,tt=tt??this.length,o<0&&(o=this.length+o),tt<0&&(tt=this.length+tt),o<0||tt>this.length)throw new RangeError("index is out of bounds");if(o===tt)return{bufs:[],length:0};if(o===0&&tt===this.length)return{bufs:this.bufs,length:this.length};const rt=[];let nt=0;for(let ot=0;ot=at)continue;const ct=o>=st&&ost&&tt<=at;if(ct&<){if(o===st&&tt===at){rt.push(it);break}const dt=o-st;rt.push(it.subarray(dt,dt+(tt-o)));break}if(ct){if(o===0){rt.push(it);continue}rt.push(it.subarray(o-st));continue}if(lt){if(tt===at){rt.push(it);break}rt.push(it.subarray(0,tt-st));break}rt.push(it)}return{bufs:rt,length:tt-o}}indexOf(o,tt=0){if(!isUint8ArrayList(o)&&!(o instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');const rt=o instanceof Uint8Array?o:o.subarray();if(tt=Number(tt??0),isNaN(tt)&&(tt=0),tt<0&&(tt=this.length+tt),tt<0&&(tt=0),o.length===0)return tt>this.length?this.length:tt;const nt=rt.byteLength;if(nt===0)throw new TypeError("search must be at least 1 byte long");const ot=256,it=new Int32Array(ot);for(let dt=0;dt=0;ht--){const mt=this.get(dt+ht);if(rt[ht]!==mt){lt=Math.max(1,ht-st[mt]);break}}if(lt===0)return dt}return-1}getInt8(o){const tt=this.subarray(o,o+1);return new DataView(tt.buffer,tt.byteOffset,tt.byteLength).getInt8(0)}setInt8(o,tt){const rt=allocUnsafe$f(1);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setInt8(0,tt),this.write(rt,o)}getInt16(o,tt){const rt=this.subarray(o,o+2);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getInt16(0,tt)}setInt16(o,tt,rt){const nt=alloc$5(2);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setInt16(0,tt,rt),this.write(nt,o)}getInt32(o,tt){const rt=this.subarray(o,o+4);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getInt32(0,tt)}setInt32(o,tt,rt){const nt=alloc$5(4);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setInt32(0,tt,rt),this.write(nt,o)}getBigInt64(o,tt){const rt=this.subarray(o,o+8);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getBigInt64(0,tt)}setBigInt64(o,tt,rt){const nt=alloc$5(8);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setBigInt64(0,tt,rt),this.write(nt,o)}getUint8(o){const tt=this.subarray(o,o+1);return new DataView(tt.buffer,tt.byteOffset,tt.byteLength).getUint8(0)}setUint8(o,tt){const rt=allocUnsafe$f(1);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setUint8(0,tt),this.write(rt,o)}getUint16(o,tt){const rt=this.subarray(o,o+2);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getUint16(0,tt)}setUint16(o,tt,rt){const nt=alloc$5(2);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setUint16(0,tt,rt),this.write(nt,o)}getUint32(o,tt){const rt=this.subarray(o,o+4);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getUint32(0,tt)}setUint32(o,tt,rt){const nt=alloc$5(4);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setUint32(0,tt,rt),this.write(nt,o)}getBigUint64(o,tt){const rt=this.subarray(o,o+8);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getBigUint64(0,tt)}setBigUint64(o,tt,rt){const nt=alloc$5(8);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setBigUint64(0,tt,rt),this.write(nt,o)}getFloat32(o,tt){const rt=this.subarray(o,o+4);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getFloat32(0,tt)}setFloat32(o,tt,rt){const nt=alloc$5(4);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setFloat32(0,tt,rt),this.write(nt,o)}getFloat64(o,tt){const rt=this.subarray(o,o+8);return new DataView(rt.buffer,rt.byteOffset,rt.byteLength).getFloat64(0,tt)}setFloat64(o,tt,rt){const nt=alloc$5(8);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setFloat64(0,tt,rt),this.write(nt,o)}equals(o){if(o==null||!(o instanceof Uint8ArrayList)||o.bufs.length!==this.bufs.length)return!1;for(let tt=0;ttnt+ot.byteLength,0)),rt.length=tt,rt}}function allocUnsafe$e(et=0){return new Uint8Array(et)}function isAsyncIterable$7(et){return et[Symbol.asyncIterator]!=null}const defaultEncoder=et=>{const o=encodingLength$6(et),tt=allocUnsafe$e(o);return encode$P(et,tt),defaultEncoder.bytes=o,tt};defaultEncoder.bytes=0;function encode$K(et,o){o=o??{};const tt=o.lengthEncoder??defaultEncoder;function*rt(nt){const ot=tt(nt.byteLength);ot instanceof Uint8Array?yield ot:yield*ot,nt instanceof Uint8Array?yield nt:yield*nt}return isAsyncIterable$7(et)?async function*(){for await(const nt of et)yield*rt(nt)}():function*(){for(const nt of et)yield*rt(nt)}()}encode$K.single=(et,o)=>{o=o??{};const tt=o.lengthEncoder??defaultEncoder;return new Uint8ArrayList(tt(et.byteLength),et)};let InvalidMessageLengthError$1=class extends Error{constructor(){super(...arguments);wt(this,"name","InvalidMessageLengthError");wt(this,"code","ERR_INVALID_MSG_LENGTH")}},InvalidDataLengthError$1=class extends Error{constructor(){super(...arguments);wt(this,"name","InvalidDataLengthError");wt(this,"code","ERR_MSG_DATA_TOO_LONG")}},InvalidDataLengthLengthError$1=class extends Error{constructor(){super(...arguments);wt(this,"name","InvalidDataLengthLengthError");wt(this,"code","ERR_MSG_LENGTH_TOO_LONG")}},UnexpectedEOFError$1=class extends Error{constructor(){super(...arguments);wt(this,"name","UnexpectedEOFError");wt(this,"code","ERR_UNEXPECTED_EOF")}};const MAX_LENGTH_LENGTH=8,MAX_DATA_LENGTH=1024*1024*4;var ReadMode;(function(et){et[et.LENGTH=0]="LENGTH",et[et.DATA=1]="DATA"})(ReadMode||(ReadMode={}));const defaultDecoder=et=>{const o=decode$Z(et);return defaultDecoder.bytes=encodingLength$6(o),o};defaultDecoder.bytes=0;function decode$U(et,o){const tt=new Uint8ArrayList;let rt=ReadMode.LENGTH,nt=-1;const ot=(o==null?void 0:o.lengthDecoder)??defaultDecoder,it=(o==null?void 0:o.maxLengthLength)??MAX_LENGTH_LENGTH,st=(o==null?void 0:o.maxDataLength)??MAX_DATA_LENGTH;function*at(){for(;tt.byteLength>0;){if(rt===ReadMode.LENGTH)try{if(nt=ot(tt),nt<0)throw new InvalidMessageLengthError$1("Invalid message length");if(nt>st)throw new InvalidDataLengthError$1("Message length too long");const ct=ot.bytes;tt.consume(ct),(o==null?void 0:o.onLength)!=null&&o.onLength(nt),rt=ReadMode.DATA}catch(ct){if(ct instanceof RangeError){if(tt.byteLength>it)throw new InvalidDataLengthLengthError$1("Message length length too long");break}throw ct}if(rt===ReadMode.DATA){if(tt.byteLength0)throw new UnexpectedEOFError$1("Unexpected end of input")}():function*(){for(const ct of et)tt.append(ct),yield*at();if(tt.byteLength>0)throw new UnexpectedEOFError$1("Unexpected end of input")}()}decode$U.fromReader=(et,o)=>{let tt=1;const rt=async function*(){for(;;)try{const{done:ot,value:it}=await et.next(tt);if(ot===!0)return;it!=null&&(yield it)}catch(ot){if(ot.code==="ERR_UNDER_READ")return{done:!0,value:null};throw ot}finally{tt=1}}();return decode$U(rt,{...o??{},onLength:ot=>{tt=ot}})};function pDefer(){const et={};return et.promise=new Promise((o,tt)=>{et.resolve=o,et.reject=tt}),et}class FixedFIFO{constructor(o){wt(this,"buffer");wt(this,"mask");wt(this,"top");wt(this,"btm");wt(this,"next");if(!(o>0)||o-1&o)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(o),this.mask=o-1,this.top=0,this.btm=0,this.next=null}push(o){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=o,this.top=this.top+1&this.mask,!0)}shift(){const o=this.buffer[this.btm];if(o!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,o}isEmpty(){return this.buffer[this.btm]===void 0}}class FIFO{constructor(o={}){wt(this,"size");wt(this,"hwm");wt(this,"head");wt(this,"tail");this.hwm=o.splitLimit??16,this.head=new FixedFIFO(this.hwm),this.tail=this.head,this.size=0}calculateSize(o){return(o==null?void 0:o.byteLength)!=null?o.byteLength:1}push(o){if((o==null?void 0:o.value)!=null&&(this.size+=this.calculateSize(o.value)),!this.head.push(o)){const tt=this.head;this.head=tt.next=new FixedFIFO(2*this.head.buffer.length),this.head.push(o)}}shift(){let o=this.tail.shift();if(o===void 0&&this.tail.next!=null){const tt=this.tail.next;this.tail.next=null,this.tail=tt,o=this.tail.shift()}return(o==null?void 0:o.value)!=null&&(this.size-=this.calculateSize(o.value)),o}isEmpty(){return this.head.isEmpty()}}let AbortError$a=class extends Error{constructor(tt,rt){super(tt??"The operation was aborted");wt(this,"type");wt(this,"code");this.type="aborted",this.code=rt??"ABORT_ERR"}};function pushable(et={}){return _pushable(tt=>{const rt=tt.shift();if(rt==null)return{done:!0};if(rt.error!=null)throw rt.error;return{done:rt.done===!0,value:rt.value}},et)}function _pushable(et,o){o=o??{};let tt=o.onEnd,rt=new FIFO,nt,ot,it,st=pDefer();const at=async()=>{try{return rt.isEmpty()?it?{done:!0}:await new Promise((yt,gt)=>{ot=bt=>{ot=null,rt.push(bt);try{yt(et(rt))}catch(xt){gt(xt)}return nt}}):et(rt)}finally{rt.isEmpty()&&queueMicrotask(()=>{st.resolve(),st=pDefer()})}},ct=yt=>ot!=null?ot(yt):(rt.push(yt),nt),lt=yt=>(rt=new FIFO,ot!=null?ot({error:yt}):(rt.push({error:yt}),nt)),dt=yt=>{if(it)return nt;if((o==null?void 0:o.objectMode)!==!0&&(yt==null?void 0:yt.byteLength)==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return ct({done:!1,value:yt})},ht=yt=>it?nt:(it=!0,yt!=null?lt(yt):ct({done:!0})),mt=()=>(rt=new FIFO,ht(),{done:!0}),ft=yt=>(ht(yt),{done:!0});if(nt={[Symbol.asyncIterator](){return this},next:at,return:mt,throw:ft,push:dt,end:ht,get readableLength(){return rt.size},onEmpty:async yt=>{const gt=yt==null?void 0:yt.signal;if(gt==null||gt.throwIfAborted(),rt.isEmpty())return;let bt,xt;gt!=null&&(bt=new Promise((vt,Et)=>{xt=()=>{Et(new AbortError$a)},gt.addEventListener("abort",xt)}));try{await Promise.race([st.promise,bt])}finally{xt!=null&>!=null&&(gt==null||gt.removeEventListener("abort",xt))}}},tt==null)return nt;const pt=nt;return nt={[Symbol.asyncIterator](){return this},next(){return pt.next()},throw(yt){return pt.throw(yt),tt!=null&&(tt(yt),tt=void 0),{done:!0}},return(){return pt.return(),tt!=null&&(tt(),tt=void 0),{done:!0}},push:dt,end(yt){return pt.end(yt),tt!=null&&(tt(yt),tt=void 0),nt},get readableLength(){return pt.readableLength},onEmpty:yt=>pt.onEmpty(yt)},nt}function isAsyncIterable$6(et){return et[Symbol.asyncIterator]!=null}function merge$2(...et){const o=[];for(const tt of et)isAsyncIterable$6(tt)||o.push(tt);return o.length===et.length?function*(){for(const tt of o)yield*tt}():async function*(){const tt=pushable({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(et.map(async rt=>{for await(const nt of rt)tt.push(nt)})),tt.end()}catch(rt){tt.end(rt)}}),yield*tt}()}function pipe(et,...o){if(et==null)throw new Error("Empty pipeline");if(isDuplex(et)){const rt=et;et=()=>rt.source}else if(isIterable(et)||isAsyncIterable$5(et)){const rt=et;et=()=>rt}const tt=[et,...o];if(tt.length>1&&isDuplex(tt[tt.length-1])&&(tt[tt.length-1]=tt[tt.length-1].sink),tt.length>2)for(let rt=1;rt{let o;for(;et.length>0;)o=et.shift()(o);return o},isAsyncIterable$5=et=>(et==null?void 0:et[Symbol.asyncIterator])!=null,isIterable=et=>(et==null?void 0:et[Symbol.iterator])!=null,isDuplex=et=>et==null?!1:et.sink!=null&&et.source!=null,duplexPipelineFn=et=>o=>{const tt=et.sink(o);if((tt==null?void 0:tt.then)!=null){const rt=pushable({objectMode:!0});tt.then(()=>{rt.end()},it=>{rt.end(it)});let nt;const ot=et.source;if(isAsyncIterable$5(ot))nt=async function*(){yield*ot,rt.end()};else if(isIterable(ot))nt=function*(){yield*ot,rt.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return merge$2(rt,nt())}return et.source};async function sortPeersByLatency(et,o){return o.length===0?[]:(await Promise.all(o.map(async nt=>{try{const ot=(await et.get(nt.id)).metadata.get("ping");if(!ot)return{peer:nt,ping:1/0};const it=Number(bytesToUtf8(ot));return{peer:nt,ping:it}}catch{return{peer:nt,ping:1/0}}}))).filter(nt=>nt!==null).sort((nt,ot)=>nt.ping-ot.ping).map(nt=>nt.peer)}async function getPeersForProtocol(et,o){const tt=[];return await et.forEach(rt=>{for(let nt=0;ntit.tags.has(Tags.BOOTSTRAP)).slice(0,tt);o>0&&o!it.tags.has(Tags.BOOTSTRAP));if(o===0)return[...rt,...nt];const ot=[...rt];for(;ot.length0;){const it=Math.floor(Math.random()*nt.length),st=nt.splice(it,1)[0];ot.push(st)}return ot}function selectOpenConnection(et){return et.filter(o=>o.status==="open").sort((o,tt)=>tt.timeline.open-o.timeline.open).at(0)}const STREAM_LOCK_KEY="consumed";class StreamManager{constructor(o,tt,rt){wt(this,"multicodec");wt(this,"getConnections");wt(this,"addEventListener");wt(this,"log");wt(this,"ongoingCreation",new Set);wt(this,"streamPool",new Map);wt(this,"handlePeerUpdateStreamPool",o=>{const{peer:tt}=o.detail;!tt.protocols.includes(this.multicodec)||this.getOpenStreamForCodec(tt.id)||this.scheduleNewStream(tt)});this.multicodec=o,this.getConnections=tt,this.addEventListener=rt,this.log=new Logger$1(`stream-manager:${o}`),this.addEventListener("peer:update",this.handlePeerUpdateStreamPool)}async getStream(o){const tt=o.id.toString(),rt=this.streamPool.get(tt);rt&&(this.streamPool.delete(tt),await rt);let nt=this.getOpenStreamForCodec(o.id);return nt?(this.log.info(`Found existing stream peerId=${o.id.toString()} multicodec=${this.multicodec}`),this.lockStream(o.id.toString(),nt),nt):(nt=await this.createStream(o),this.lockStream(o.id.toString(),nt),nt)}async createStream(o,tt=0){const rt=this.getConnections(o.id),nt=selectOpenConnection(rt);if(!nt)throw new Error(`Failed to get a connection to the peer peerId=${o.id.toString()} multicodec=${this.multicodec}`);let ot,it;for(let st=0;stit.protocol===this.multicodec);if(!(!nt||["done","closed","closing"].includes(nt.writeStatus||"")||this.isStreamLocked(nt)))return nt}lockStream(o,tt){this.log.info(`Locking stream for peerId:${o} streamId:${tt.id}`),tt.metadata[STREAM_LOCK_KEY]=!0}isStreamLocked(o){return!!o.metadata[STREAM_LOCK_KEY]}}class BaseProtocol{constructor(o,tt,rt,nt){wt(this,"multicodec");wt(this,"components");wt(this,"log");wt(this,"pubsubTopics");wt(this,"addLibp2pEventListener");wt(this,"removeLibp2pEventListener");wt(this,"streamManager");this.multicodec=o,this.components=tt,this.log=rt,this.pubsubTopics=nt,this.addLibp2pEventListener=tt.events.addEventListener.bind(tt.events),this.removeLibp2pEventListener=tt.events.removeEventListener.bind(tt.events),this.streamManager=new StreamManager(o,tt.connectionManager.getConnections.bind(tt.connectionManager),this.addLibp2pEventListener)}async getStream(o){return this.streamManager.getStream(o)}async allPeers(){return getPeersForProtocol(this.components.peerStore,[this.multicodec])}async connectedPeers(){return(await this.allPeers()).filter(tt=>this.components.connectionManager.getConnections(tt.id).length>0)}async getPeers({numPeers:o,maxBootstrapPeers:tt,peerIdStr:rt}={maxBootstrapPeers:0,numPeers:0}){if(rt){const st=(await this.connectedPeers()).find(at=>at.id.toString()===rt);return st?[st]:(this.log.warn(`Passed node to use for ${this.multicodec} not found: ${rt}. Attempting to use random peers.`),this.getPeers({numPeers:o,maxBootstrapPeers:tt}))}const nt=await this.connectedPeers(),ot=filterPeersByDiscovery(nt,o,tt),it=await sortPeersByLatency(this.components.peerStore,ot);return it.length===0&&this.log.warn("No peers found. Ensure you have a connection to the network."),it.length{log$n.error("Failed to register ",FilterCodecs.PUSH,ot)})}async subscribe(tt,rt,nt){const ot=await this.getStream(rt),it=FilterSubscribeRpc.createSubscribeRequest(tt,nt);let st;try{st=await pipe([it.encode()],encode$K,ot,decode$U,async dt=>await all$2(dt))}catch(dt){return log$n.error("Failed to send subscribe request",dt),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:rt.id}}}const{statusCode:at,requestId:ct,statusDesc:lt}=FilterSubscribeResponse.decode(st[0].slice());return at<200||at>=300?(log$n.error(`Filter subscribe request ${ct} failed with status code ${at}: ${lt}`),{failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:rt.id},success:null}):{failure:null,success:rt.id}}async unsubscribe(tt,rt,nt){let ot;try{ot=await this.getStream(rt)}catch(st){return log$n.error(`Failed to get a stream for remote peer${rt.id.toString()}`,st),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:rt.id}}}const it=FilterSubscribeRpc.createUnsubscribeRequest(tt,nt);try{await pipe([it.encode()],encode$K,ot.sink)}catch(st){return log$n.error("Failed to send unsubscribe request",st),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:rt.id}}}return{success:rt.id,failure:null}}async unsubscribeAll(tt,rt){const nt=await this.getStream(rt),ot=FilterSubscribeRpc.createUnsubscribeAllRequest(tt),it=await pipe([ot.encode()],encode$K,nt,decode$U,async lt=>await all$2(lt));if(!it||!it.length)return{failure:{error:ProtocolError$1.NO_RESPONSE,peerId:rt.id},success:null};const{statusCode:st,requestId:at,statusDesc:ct}=FilterSubscribeResponse.decode(it[0].slice());return st<200||st>=300?(log$n.error(`Filter unsubscribe all request ${at} failed with status code ${st}: ${ct}`),{failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:rt.id},success:null}):{failure:null,success:rt.id}}async ping(tt){let rt;try{rt=await this.getStream(tt)}catch(ct){return log$n.error(`Failed to get a stream for remote peer${tt.id.toString()}`,ct),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:tt.id}}}const nt=FilterSubscribeRpc.createSubscriberPingRequest();let ot;try{ot=await pipe([nt.encode()],encode$K,rt,decode$U,async ct=>await all$2(ct))}catch(ct){return log$n.error("Failed to send ping request",ct),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:tt.id}}}if(!ot||!ot.length)return{success:null,failure:{error:ProtocolError$1.NO_RESPONSE,peerId:tt.id}};const{statusCode:it,requestId:st,statusDesc:at}=FilterSubscribeResponse.decode(ot[0].slice());return it<200||it>=300?(log$n.error(`Filter ping request ${st} failed with status code ${it}: ${at}`),{success:null,failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:tt.id}}):{success:tt.id,failure:null}}onRequest(tt){const{connection:rt,stream:nt}=tt,{remotePeer:ot}=rt;log$n.info(`Received message from ${ot.toString()}`);try{pipe(nt,decode$U,async it=>{for await(const st of it){const at=FilterPushRpc.decode(st.slice()),{pubsubTopic:ct,wakuMessage:lt}=at;if(!lt){log$n.error("Received empty message");return}if(!ct){log$n.error("Pubsub topic missing from push message");return}await this.handleIncomingMessage(ct,lt,rt.remotePeer.toString())}}).then(()=>{log$n.info("Receiving pipe closed.")},async it=>{log$n.error(`Error with receiving pipe on peer:${rt.remotePeer.toString()} -- stream:${nt.id} -- protocol:${nt.protocol}: `,it)})}catch(it){log$n.error("Error decoding message",it)}}}class PushRpc{constructor(o){wt(this,"proto");this.proto=o}static createRequest(o,tt){return new PushRpc({requestId:v4$2(),request:{message:o,pubsubTopic:tt},response:void 0})}static decode(o){const tt=PushRpc$1.decode(o);return new PushRpc(tt)}encode(){return PushRpc$1.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const RLN_GENERATION_PREFIX_ERROR="could not generate rln-v2 proof",isRLNResponseError=et=>et?et.includes(RLN_GENERATION_PREFIX_ERROR):!1,matchRLNErrorMessage=et=>{const o={[ProtocolError$1.RLN_IDENTITY_MISSING]:ProtocolError$1.RLN_IDENTITY_MISSING,[ProtocolError$1.RLN_MEMBERSHIP_INDEX]:ProtocolError$1.RLN_MEMBERSHIP_INDEX,[ProtocolError$1.RLN_LIMIT_MISSING]:ProtocolError$1.RLN_LIMIT_MISSING},tt=et.toLowerCase();for(const rt in o)if(tt.includes(rt.toLowerCase()))return o[rt];return ProtocolError$1.RLN_PROOF_GENERATION},log$m=new Logger$1("light-push"),LightPushCodec="/vac/waku/lightpush/2.0.0-beta1";class LightPushCore extends BaseProtocol{constructor(tt,rt){super(LightPushCodec,rt.components,log$m,tt);wt(this,"pubsubTopics");this.pubsubTopics=tt}async preparePushMessage(tt,rt){try{if(!rt.payload||rt.payload.length===0)return log$m.error("Failed to send waku light push: payload is empty"),{query:null,error:ProtocolError$1.EMPTY_PAYLOAD};if(!await isMessageSizeUnderCap(tt,rt))return log$m.error("Failed to send waku light push: message is bigger than 1MB"),{query:null,error:ProtocolError$1.SIZE_TOO_BIG};const nt=await tt.toProtoObj(rt);return nt?{query:PushRpc.createRequest(nt,tt.pubsubTopic),error:null}:(log$m.error("Failed to encode to protoMessage, aborting push"),{query:null,error:ProtocolError$1.ENCODE_FAILED})}catch(nt){return log$m.error("Failed to prepare push message",nt),{query:null,error:ProtocolError$1.GENERIC_FAIL}}}async send(tt,rt,nt){const{query:ot,error:it}=await this.preparePushMessage(tt,rt);if(it||!ot)return{success:null,failure:{error:it,peerId:nt.id}};let st;try{st=await this.getStream(nt)}catch(dt){return log$m.error("Failed to get stream",dt),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:nt.id}}}let at;try{at=await pipe([ot.encode()],encode$K,st,decode$U,async dt=>await all$2(dt))}catch(dt){return log$m.error("Failed to send waku light push request",dt),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:nt.id}}}const ct=new Uint8ArrayList;at.forEach(dt=>{ct.append(dt)});let lt;try{lt=PushRpc.decode(ct).response}catch(dt){return log$m.error("Failed to decode push reply",dt),{success:null,failure:{error:ProtocolError$1.DECODE_FAILED,peerId:nt.id}}}if(!lt)return log$m.error("Remote peer fault: No response in PushRPC"),{success:null,failure:{error:ProtocolError$1.NO_RESPONSE,peerId:nt.id}};if(isRLNResponseError(lt.info)){const dt=matchRLNErrorMessage(lt.info);return log$m.error("Remote peer rejected the message: ",dt),{success:null,failure:{error:dt,peerId:nt.id}}}return lt.isSuccess?{success:nt.id,failure:null}:(log$m.error("Remote peer rejected the message: ",lt.info),{success:null,failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:nt.id}})}}const EmptyMessage={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};function toProtoMessage(et){return{...EmptyMessage,...et}}const DEFAULT_PAGE_SIZE=20,MAX_PAGE_SIZE=100,ONE_MILLION=1e6;class StoreQueryRequest{constructor(o){wt(this,"proto");this.proto=o}static create(o){const tt=new StoreQueryRequest({...o,requestId:v4$2(),timeStart:o.timeStart?BigInt(o.timeStart.getTime()*ONE_MILLION):void 0,timeEnd:o.timeEnd?BigInt(o.timeEnd.getTime()*ONE_MILLION):void 0,messageHashes:o.messageHashes||[],paginationLimit:o.paginationLimit?BigInt(o.paginationLimit):void 0});if(o.pubsubTopic&&!o.contentTopics||!o.pubsubTopic&&o.contentTopics)throw new Error("Both pubsubTopic and contentTopics must be set or unset");if(o.messageHashes&&(o.pubsubTopic||o.contentTopics||o.timeStart||o.timeEnd))throw new Error("Message hash lookup queries cannot include content filter criteria");return tt}static decode(o){const tt=StoreQueryRequest$1.decode(o);return new StoreQueryRequest(tt)}encode(){return StoreQueryRequest$1.encode(this.proto)}}class StoreQueryResponse{constructor(o){wt(this,"proto");this.proto=o}static decode(o){const tt=StoreQueryResponse$1.decode(o);return new StoreQueryResponse(tt)}encode(){return StoreQueryResponse$1.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get messages(){return this.proto.messages}get paginationCursor(){return this.proto.paginationCursor}}const log$l=new Logger$1("store"),StoreCodec="/vac/waku/store-query/3.0.0";class StoreCore extends BaseProtocol{constructor(tt,rt){super(StoreCodec,rt.components,log$l,tt);wt(this,"pubsubTopics");this.pubsubTopics=tt}async*queryPerPage(tt,rt,nt){if(tt.contentTopics.toString()!==Array.from(rt.keys()).toString())throw new Error("Internal error, the decoders should match the query's content topics");let ot=tt.paginationCursor;for(;;){const it=StoreQueryRequest.create({...tt,paginationCursor:ot});let st;try{st=await this.getStream(nt)}catch(ht){log$l.error("Failed to get stream",ht);break}const at=await pipe([it.encode()],encode$K,st,decode$U,async ht=>await all$2(ht)),ct=new Uint8ArrayList;at.forEach(ht=>{ct.append(ht)});const lt=StoreQueryResponse.decode(ct);if(!lt.statusCode||lt.statusCode>=300){const ht=`Store query failed with status code: ${lt.statusCode}, description: ${lt.statusDesc}`;throw log$l.error(ht),new Error(ht)}if(!lt.messages||!lt.messages.length){log$l.warn("Stopping pagination due to empty messages in response");break}if(log$l.info(`${lt.messages.length} messages retrieved from store`),yield lt.messages.map(ht=>{if(!ht.message)return Promise.resolve(void 0);const mt=ht.message.contentTopic;if(mt){const ft=rt.get(mt);if(ft)return ft.fromProtoObj(ht.pubsubTopic||"",toProtoMessage(ht.message))}return Promise.resolve(void 0)}),tt.paginationForward?ot=lt.messages[lt.messages.length-1].messageHash:ot=lt.messages[0].messageHash,lt.messages.length>MAX_PAGE_SIZE&<.messages.length<(tt.paginationLimit||DEFAULT_PAGE_SIZE))break}}}const peerDiscoverySymbol$2=Symbol.for("@libp2p/peer-discovery"),peerIdSymbol$3=Symbol.for("@libp2p/peer-id");function isPeerId$2(et){return!!(et!=null&&et[peerIdSymbol$3])}var ls;let AbortError$9=(ls=class extends Error{constructor(o="The operation was aborted"){super(o),this.name="AbortError"}},wt(ls,"name","AbortError"),ls);class UnexpectedPeerError extends Error{constructor(o="Unexpected Peer"){super(o),this.name="UnexpectedPeerError"}}wt(UnexpectedPeerError,"name","UnexpectedPeerError");var us;let InvalidMessageError$3=(us=class extends Error{constructor(o="Invalid message"){super(o),this.name="InvalidMessageError"}},wt(us,"name","InvalidMessageError"),us);class ProtocolError extends Error{constructor(o="Protocol error"){super(o),this.name="ProtocolError"}}wt(ProtocolError,"name","ProtocolError");var ds;let TimeoutError$3=(ds=class extends Error{constructor(o="Timed out"){super(o),this.name="TimeoutError"}},wt(ds,"name","TimeoutError"),ds);function setMaxListeners$9(){}const setMaxListeners$8=(et,...o)=>{try{[...o]}catch{}};var Yr,Js;let TypedEventEmitter$3=(Js=class extends EventTarget{constructor(){super();fr(this,Yr,new Map);setMaxListeners$8(1/0,this)}listenerCount(tt){const rt=Ot(this,Yr).get(tt);return rt==null?0:rt.length}addEventListener(tt,rt,nt){super.addEventListener(tt,rt,nt);let ot=Ot(this,Yr).get(tt);ot==null&&(ot=[],Ot(this,Yr).set(tt,ot)),ot.push({callback:rt,once:(nt!==!0&&nt!==!1&&(nt==null?void 0:nt.once))??!1})}removeEventListener(tt,rt,nt){super.removeEventListener(tt.toString(),rt??null,nt);let ot=Ot(this,Yr).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==rt),Ot(this,Yr).set(tt,ot))}dispatchEvent(tt){const rt=super.dispatchEvent(tt);let nt=Ot(this,Yr).get(tt.type);return nt==null||(nt=nt.filter(({once:ot})=>!ot),Ot(this,Yr).set(tt.type,nt)),rt}safeDispatchEvent(tt,rt={}){return this.dispatchEvent(new CustomEvent(tt,rt))}},Yr=new WeakMap,Js);const serviceCapabilities$5=Symbol.for("@libp2p/service-capabilities"),RelayPingContentTopic="/relay-ping/1/ping/null",log$k=new Logger$1("keep-alive");class KeepAliveManager{constructor({options:o,relay:tt,libp2p:rt}){wt(this,"relay");wt(this,"libp2p");wt(this,"options");wt(this,"pingKeepAliveTimers",new Map);wt(this,"relayKeepAliveTimers",new Map);this.options=o,this.relay=tt,this.libp2p=rt}start(o){this.stop(o);const{pingKeepAlive:tt,relayKeepAlive:rt}=this.options,nt=o.toString();if(tt!==0){const it=setInterval(()=>{(async()=>{let st;try{try{st=await this.libp2p.services.ping.ping(o),log$k.info(`Ping succeeded (${nt})`,st)}catch{log$k.error(`Ping failed for peer (${nt}). Next ping will be attempted in ${tt} seconds. `);return}try{await this.libp2p.peerStore.merge(o,{metadata:{ping:utf8ToBytes$1(st.toString())}})}catch(at){log$k.error("Failed to update ping",at)}}catch(at){log$k.error(`Ping failed (${nt})`,at)}})()},tt*1e3);this.pingKeepAliveTimers.set(nt,it)}const ot=this.relay;if(ot&&rt!==0){const it=this.scheduleRelayPings(ot,rt,o.toString());this.relayKeepAliveTimers.set(o,it)}}stop(o){var rt;const tt=o.toString();this.pingKeepAliveTimers.has(tt)&&(clearInterval(this.pingKeepAliveTimers.get(tt)),this.pingKeepAliveTimers.delete(tt)),this.relayKeepAliveTimers.has(o)&&((rt=this.relayKeepAliveTimers.get(o))==null||rt.map(clearInterval),this.relayKeepAliveTimers.delete(o))}stopAll(){for(const o of[...Object.values(this.pingKeepAliveTimers),...Object.values(this.relayKeepAliveTimers)])clearInterval(o);this.pingKeepAliveTimers.clear(),this.relayKeepAliveTimers.clear()}connectionsExist(){return this.pingKeepAliveTimers.size>0||this.relayKeepAliveTimers.size>0}scheduleRelayPings(o,tt,rt){const nt=[];for(const ot of o.pubsubTopics){if(!o.getMeshPeers(ot).includes(rt))continue;const st=createEncoder({pubsubTopicShardInfo:pubsubTopicToSingleShardInfo(ot),contentTopic:RelayPingContentTopic,ephemeral:!0}),at=setInterval(()=>{log$k.info("Sending Waku Relay ping message"),o.send(st,{payload:new Uint8Array([1])}).catch(ct=>log$k.error("Failed to send relay ping",ct))},tt*1e3);nt.push(at)}return nt}}const log$j=new Logger$1("connection-manager"),DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED=1,DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER=3,DEFAULT_MAX_PARALLEL_DIALS=3,Nn=class Nn extends TypedEventEmitter$3{constructor(tt,rt,nt,ot,it){super();wt(this,"configuredPubsubTopics");wt(this,"keepAliveManager");wt(this,"options");wt(this,"libp2p");wt(this,"dialAttemptsForPeer",new Map);wt(this,"dialErrorsForPeer",new Map);wt(this,"currentActiveParallelDialCount",0);wt(this,"pendingPeerDialQueue",[]);wt(this,"isP2PNetworkConnected",!1);wt(this,"onEventHandlers",{"peer:discovery":tt=>{(async()=>{const{id:rt}=tt.detail;await this.dispatchDiscoveryEvent(rt);try{await this.attemptDial(rt)}catch(nt){log$j.error(`Error dialing peer ${rt.toString()} : ${nt}`)}})()},"peer:connect":tt=>{(async()=>{log$j.info(`Connected to peer ${tt.detail.toString()}`);const rt=tt.detail;this.keepAliveManager.start(rt),(await this.getTagNamesForPeer(rt)).includes(Tags.BOOTSTRAP)?this.libp2p.getConnections().filter(it=>it.tags.includes(Tags.BOOTSTRAP)).length>this.options.maxBootstrapPeersAllowed?await this.dropConnection(rt):this.dispatchEvent(new CustomEvent(EPeersByDiscoveryEvents.PEER_CONNECT_BOOTSTRAP,{detail:rt})):this.dispatchEvent(new CustomEvent(EPeersByDiscoveryEvents.PEER_CONNECT_PEER_EXCHANGE,{detail:rt})),this.setP2PNetworkConnected()})()},"peer:disconnect":tt=>{(async()=>(this.keepAliveManager.stop(tt.detail),this.setP2PNetworkDisconnected()))()},"browser:network":()=>{this.dispatchWakuConnectionEvent()}});this.configuredPubsubTopics=nt,this.libp2p=tt,this.configuredPubsubTopics=nt,this.options={maxDialAttemptsForPeer:DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,maxBootstrapPeersAllowed:DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,maxParallelDials:DEFAULT_MAX_PARALLEL_DIALS,...it},this.keepAliveManager=new KeepAliveManager({relay:ot,libp2p:tt,options:rt}),this.startEventListeners().then(()=>log$j.info("Connection Manager is now running")).catch(st=>log$j.error("Unexpected error while running service",st)),this.dialPeerStorePeers().catch(st=>log$j.error("Unexpected error while dialing peer store peers",st))}isConnected(){var tt;return globalThis!=null&&globalThis.navigator&&!((tt=globalThis==null?void 0:globalThis.navigator)!=null&&tt.onLine)?!1:this.isP2PNetworkConnected}static create(tt,rt,nt,ot,it,st){let at=Nn.instances.get(tt);return at||(at=new Nn(rt,nt,ot,it,st),Nn.instances.set(tt,at)),at}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"]),this.stopNetworkStatusListener()}async dropConnection(tt){try{this.keepAliveManager.stop(tt),await this.libp2p.hangUp(tt),log$j.info(`Dropped connection with peer ${tt.toString()}`)}catch(rt){log$j.error(`Error dropping connection with peer ${tt.toString()} - ${rt}`)}}async getPeersByDiscovery(){const tt=await this.libp2p.peerStore.all(),rt=this.libp2p.getConnections().map(lt=>lt.remotePeer),nt=[],ot=[],it=[],st=[],at=[],ct=[];for(const lt of tt){const dt=await this.getTagNamesForPeer(lt.id);dt.includes(Tags.BOOTSTRAP)?nt.push(lt):dt.includes(Tags.PEER_EXCHANGE)?ot.push(lt):dt.includes(Tags.LOCAL)&&it.push(lt)}for(const lt of rt){const dt=await this.libp2p.peerStore.get(lt),ht=await this.getTagNamesForPeer(lt);ht.includes(Tags.BOOTSTRAP)?st.push(dt):ht.includes(Tags.PEER_EXCHANGE)?at.push(dt):ht.includes(Tags.LOCAL)&&ct.push(dt)}return{DISCOVERED:{[Tags.BOOTSTRAP]:nt,[Tags.PEER_EXCHANGE]:ot,[Tags.LOCAL]:it},CONNECTED:{[Tags.BOOTSTRAP]:st,[Tags.PEER_EXCHANGE]:at,[Tags.LOCAL]:ct}}}async dialPeerStorePeers(){const tt=await this.libp2p.peerStore.all(),rt=[];for(const nt of tt)this.libp2p.getConnections().find(ot=>ot.remotePeer===nt.id)||rt.push(this.attemptDial(nt.id));try{await Promise.all(rt)}catch(nt){log$j.error("Unexpected error while dialing peer store peers",nt)}}async startEventListeners(){this.startPeerDiscoveryListener(),this.startPeerConnectionListener(),this.startPeerDisconnectionListener(),this.startNetworkStatusListener()}async dialPeer(tt){this.currentActiveParallelDialCount+=1;let rt=0;for(;rt{ot.tags=Array.from(new Set([...ot.tags,...nt]))}),this.dialAttemptsForPeer.set(tt.toString(),-1),this.keepAliveManager.start(tt);break}catch(nt){nt instanceof AggregateError?log$j.error(`Error dialing peer ${tt.toString()} - ${nt.errors}`):log$j.error(`Error dialing peer ${tt.toString()} - ${nt.message}`),this.dialErrorsForPeer.set(tt.toString(),nt),rt++,this.dialAttemptsForPeer.set(tt.toString(),rt)}if(this.currentActiveParallelDialCount--,this.processDialQueue(),rt===this.options.maxDialAttemptsForPeer)try{const nt=this.dialErrorsForPeer.get(tt.toString());if(nt){let ot;nt instanceof AggregateError?nt.errors?nt.errors.length===0?log$j.warn("Errors array is empty for AggregateError"):ot=JSON.stringify(nt.errors[0]):log$j.warn("No errors array found for AggregateError"):ot=nt.message,log$j.info(`Deleting undialable peer ${tt.toString()} from peer store. Reason: ${ot}`)}this.dialErrorsForPeer.delete(tt.toString()),await this.libp2p.peerStore.delete(tt),await this.attemptDnsDiscovery()}catch(nt){throw new Error(`Error deleting undialable peer ${tt.toString()} from peer store - ${nt}`)}}async attemptDnsDiscovery(){if(this.libp2p.getConnections().length>0||(await this.libp2p.peerStore.all()).length>0)return;log$j.info("Attempting to trigger DNS discovery.");const tt=Object.values(this.libp2p.components.components).find(rt=>rt&&rt.toString?rt.toString().includes(DNS_DISCOVERY_TAG):!1);tt&&await tt.findPeers()}processDialQueue(){if(this.pendingPeerDialQueue.length>0&&this.currentActiveParallelDialCount{log$j.error(rt)})}}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(tt){if(await this.shouldDialPeer(tt)){if(this.currentActiveParallelDialCount>=this.options.maxParallelDials){this.pendingPeerDialQueue.push(tt);return}await this.dialPeer(tt)}}async shouldDialPeer(tt){if(this.libp2p.getConnections(tt).length>0)return log$j.warn(`Already connected to peer ${tt.toString()}. Not dialing.`),!1;if(!await this.isPeerTopicConfigured(tt)){const st=await this.getPeerShardInfo(tt,this.libp2p.peerStore);return log$j.warn(`Discovered peer ${tt.toString()} with ShardInfo ${st} is not part of any of the configured pubsub topics (${this.configuredPubsubTopics}). - Not dialing.`),!1}return await this.isPeerDialableBasedOnBootstrapStatus(tt)?this.dialAttemptsForPeer.has(tt.toString())?(log$j.warn(`Peer ${tt.toString()} has already been attempted dial before, or already has a dial attempt in progress, skipping dial`),!1):!0:(log$j.warn(`Peer ${tt.toString()} is not dialable based on bootstrap status. Not dialing.`),!1)}async isPeerDialableBasedOnBootstrapStatus(tt){return(await this.getTagNamesForPeer(tt)).some(it=>it===Tags.BOOTSTRAP)?this.libp2p.getConnections().filter(it=>it.tags.find(st=>st===Tags.BOOTSTRAP)).lengththis.configuredPubsubTopics.includes(it)):!0}async getPeerShardInfo(tt,rt){const ot=(await rt.get(tt)).metadata.get("shardInfo");if(ot)return decodeRelayShard(ot)}startNetworkStatusListener(){try{globalThis.addEventListener("online",this.onEventHandlers["browser:network"]),globalThis.addEventListener("offline",this.onEventHandlers["browser:network"])}catch(tt){log$j.error(`Failed to start network listener: ${tt}`)}}stopNetworkStatusListener(){try{globalThis.removeEventListener("online",this.onEventHandlers["browser:network"]),globalThis.removeEventListener("offline",this.onEventHandlers["browser:network"])}catch(tt){log$j.error(`Failed to stop network listener: ${tt}`)}}setP2PNetworkConnected(){this.isP2PNetworkConnected||(this.isP2PNetworkConnected=!0,this.dispatchWakuConnectionEvent())}setP2PNetworkDisconnected(){this.isP2PNetworkConnected&&this.libp2p.getConnections().length===0&&(this.isP2PNetworkConnected=!1,this.dispatchWakuConnectionEvent())}dispatchWakuConnectionEvent(){this.dispatchEvent(new CustomEvent(EConnectionStateEvents.CONNECTION_STATUS,{detail:this.isConnected()}))}};wt(Nn,"instances",new Map);let ConnectionManager=Nn;const An=class An{constructor(){wt(this,"health");this.health={overallStatus:HealthStatus.Unhealthy,protocolStatuses:new Map}}static getInstance(){return An.instance||(An.instance=new An),An.instance}getHealthStatus(){return this.health.overallStatus}getProtocolStatus(o){return this.health.protocolStatuses.get(o)}updateProtocolHealth(o,tt){const rt=this.getNameFromMulticodec(o);let nt=HealthStatus.Unhealthy;tt==1?nt=HealthStatus.MinimallyHealthy:tt>=2&&(nt=HealthStatus.SufficientlyHealthy),this.health.protocolStatuses.set(rt,{name:rt,status:nt,lastUpdate:new Date}),this.updateOverallHealth()}getNameFromMulticodec(o){let tt;if(o.includes("filter"))tt=Protocols.Filter;else if(o.includes("lightpush"))tt=Protocols.LightPush;else if(o.includes("store"))tt=Protocols.Store;else throw new Error(`Unknown protocol: ${o}`);return tt}updateOverallHealth(){const tt=[Protocols.LightPush,Protocols.Filter].map(rt=>{var nt;return(nt=this.getProtocolStatus(rt))==null?void 0:nt.status});tt.some(rt=>rt===HealthStatus.Unhealthy)?this.health.overallStatus=HealthStatus.Unhealthy:tt.some(rt=>rt===HealthStatus.MinimallyHealthy)?this.health.overallStatus=HealthStatus.MinimallyHealthy:this.health.overallStatus=HealthStatus.SufficientlyHealthy}};wt(An,"instance");let HealthManager=An;const getHealthManager=()=>HealthManager.getInstance(),log$i=new Logger$1("metadata"),MetadataCodec="/vac/waku/metadata/1.0.0";class Metadata extends BaseProtocol{constructor(tt,rt){super(MetadataCodec,rt.components,log$i,tt);wt(this,"pubsubTopics");wt(this,"libp2pComponents");wt(this,"handshakesConfirmed",new Map);this.pubsubTopics=tt,this.libp2pComponents=rt,rt.registrar.handle(MetadataCodec,nt=>{this.onRequest(nt)})}async query(tt){const rt=WakuMetadataRequest.encode(pubsubTopicsToShardInfo(this.pubsubTopics)),nt=await this.libp2pComponents.peerStore.get(tt);if(!nt)return{shardInfo:null,error:ProtocolError$1.NO_PEER_AVAILABLE};let ot;try{ot=await this.getStream(nt)}catch(ct){return log$i.error("Failed to get stream",ct),{shardInfo:null,error:ProtocolError$1.NO_STREAM_AVAILABLE}}const it=await pipe([rt],encode$K,ot,decode$U,async ct=>await all$2(ct)),{error:st,shardInfo:at}=this.decodeMetadataResponse(it);return st?{shardInfo:null,error:st}:(await this.savePeerShardInfo(tt,at),{shardInfo:at,error:null})}async confirmOrAttemptHandshake(tt){const rt=this.handshakesConfirmed.get(tt.toString());return rt?{shardInfo:rt,error:null}:await this.query(tt)}async onRequest(tt){try{const{stream:rt,connection:nt}=tt,ot=WakuMetadataResponse.encode(pubsubTopicsToShardInfo(this.pubsubTopics)),it=await pipe([ot],encode$K,rt,decode$U,async ct=>await all$2(ct)),{error:st,shardInfo:at}=this.decodeMetadataResponse(it);if(st)return;await this.savePeerShardInfo(nt.remotePeer,at)}catch(rt){log$i.error("Error handling metadata request",rt)}}decodeMetadataResponse(tt){const rt=new Uint8ArrayList;tt.forEach(ot=>{rt.append(ot)});const nt=WakuMetadataResponse.decode(rt);return nt?{shardInfo:nt,error:null}:(log$i.error("Error decoding metadata response"),{shardInfo:null,error:ProtocolError$1.DECODE_FAILED})}async savePeerShardInfo(tt,rt){await this.libp2pComponents.peerStore.merge(tt,{metadata:{shardInfo:encodeRelayShard(rt)}}),this.handshakesConfirmed.set(tt.toString(),rt)}}function wakuMetadata(et){return o=>new Metadata(et,o)}function equals$e(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$j=base$j,_brrp__multiformats_scope_baseX$i=src$j;let Encoder$j=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$j=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$k(this,o)}},ComposedDecoder$i=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$k(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$k(et,o){return new ComposedDecoder$i({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$i=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$j(o,tt,rt),this.decoder=new Decoder$j(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$l({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$i(et,o,tt,rt)}function baseX$i({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$i(tt,et);return from$l({prefix:o,name:et,encode:rt,decode:ot=>coerce$j(nt(ot))})}function decode$T(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$J(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<=INT$5;)o[tt++]=et&255|MSB$7,et/=128;for(;et&MSBALL$5;)o[tt++]=et&255|MSB$7,et>>>=7;return o[tt]=et|0,encode$I.bytes=tt-rt+1,o}var decode$S=read$6,MSB$1$5=128,REST$1$5=127;function read$6(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$6.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$5)<=MSB$1$5);return read$6.bytes=ot-rt,tt}var N1$5=Math.pow(2,7),N2$5=Math.pow(2,14),N3$5=Math.pow(2,21),N4$5=Math.pow(2,28),N5$5=Math.pow(2,35),N6$5=Math.pow(2,42),N7$5=Math.pow(2,49),N8$5=Math.pow(2,56),N9$5=Math.pow(2,63),length$5=function(et){return et{const[dt,ht]=decode$R(o.subarray(tt));return tt+=ht,dt};let nt=rt(),ot=DAG_PB_CODE$3;if(nt===18?(nt=0,tt=0):ot=rt(),nt!==0&&nt!==1)throw new RangeError(`Invalid CID version ${nt}`);const it=tt,st=rt(),at=rt(),ct=tt+at,lt=ct-it;return{version:nt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(o,tt){const[rt,nt]=parseCIDtoBytes$3(o,tt),ot=jr.decode(nt);if(ot.version===0&&o[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache$3(ot).set(rt,o),ot}};function parseCIDtoBytes$3(et,o){switch(et[0]){case"Q":{const tt=o??base58btc$i;return[base58btc$i.prefix,tt.decode(`${base58btc$i.prefix}${et}`)]}case base58btc$i.prefix:{const tt=o??base58btc$i;return[base58btc$i.prefix,tt.decode(et)]}case base32$w.prefix:{const tt=o??base32$w;return[base32$w.prefix,tt.decode(et)]}case base36$t.prefix:{const tt=o??base36$t;return[base36$t.prefix,tt.decode(et)]}default:{if(o==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[et[0],o.decode(et)]}}}function toStringV0$3(et,o,tt){const{prefix:rt}=tt;if(rt!==base58btc$i.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const nt=o.get(rt);if(nt==null){const ot=tt.encode(et).slice(1);return o.set(rt,ot),ot}else return nt}function toStringV1$3(et,o,tt){const{prefix:rt}=tt,nt=o.get(rt);if(nt==null){const ot=tt.encode(et);return o.set(rt,ot),ot}else return nt}const DAG_PB_CODE$3=112,SHA_256_CODE$3=18;function encodeCID$3(et,o,tt){const rt=encodingLength$5(et),nt=rt+encodingLength$5(o),ot=new Uint8Array(nt+tt.byteLength);return encodeTo$3(et,ot,0),encodeTo$3(o,ot,rt),ot.set(tt,nt),ot}const cidSymbol$3=Symbol.for("@ipld/js-cid/CID");function equals$c(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt(et[tt]=o,et),[]),alphabetCharsToBytes$e=alphabet$e.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$H(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$e[tt],o),"")}function decode$P(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$e[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$s=from$l({prefix:"🚀",name:"base256emoji",encode:encode$H,decode:decode$P}),base256emoji$t=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$s},Symbol.toStringTag,{value:"Module"})),base64$v=rfc4648$h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$e=rfc4648$h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$f=rfc4648$h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$e=rfc4648$h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$w=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$v,base64pad:base64pad$e,base64url:base64url$f,base64urlpad:base64urlpad$e},Symbol.toStringTag,{value:"Module"})),base8$s=rfc4648$h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$t=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$s},Symbol.toStringTag,{value:"Module"})),identity$g=from$l({prefix:"\0",name:"identity",encode:et=>toString$u(et),decode:et=>fromString$s(et)}),identityBase$e=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$g},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$e={...identityBase$e,...base2$t,...base8$t,...base10$t,...base16$t,...base32$x,...base36$u,...base58$e,...base64$w,...base256emoji$t};function allocUnsafe$d(et=0){return new Uint8Array(et)}function createCodec$e(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$i=createCodec$e("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$e=createCodec$e("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$d(et.length);for(let tt=0;ttnt+ot.length,0));const tt=allocUnsafe$d(o);let rt=0;for(const nt of et)tt.set(nt,rt),rt+=nt.length;return tt}class Parser{constructor(){wt(this,"index",0);wt(this,"input","")}new(o){return this.index=0,this.input=o,this}readAtomically(o){const tt=this.index,rt=o();return rt===void 0&&(this.index=tt),rt}parseWith(o){const tt=o();if(this.index===this.input.length)return tt}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(()=>{const tt=this.readChar();if(tt===o)return tt})}readSeparator(o,tt,rt){return this.readAtomically(()=>{if(!(tt>0&&this.readGivenChar(o)===void 0))return rt()})}readNumber(o,tt,rt,nt){return this.readAtomically(()=>{let ot=0,it=0;const st=this.peekChar();if(st===void 0)return;const at=st==="0",ct=2**(8*nt)-1;for(;;){const lt=this.readAtomically(()=>{const dt=this.readChar();if(dt===void 0)return;const ht=Number.parseInt(dt,o);if(!Number.isNaN(ht))return ht});if(lt===void 0)break;if(ot*=o,ot+=lt,ot>ct||(it+=1,tt!==void 0&&it>tt))return}if(it!==0)return!rt&&at&&it>1?void 0:ot})}readIPv4Addr(){return this.readAtomically(()=>{const o=new Uint8Array(4);for(let tt=0;ttthis.readNumber(10,3,!1,1));if(rt===void 0)return;o[tt]=rt}return o})}readIPv6Addr(){const o=tt=>{for(let rt=0;rtthis.readIPv4Addr());if(it!==void 0)return tt[nt]=it[0],tt[nt+1]=it[1],tt[nt+2]=it[2],tt[nt+3]=it[3],[nt+4,!0]}const ot=this.readSeparator(":",rt,()=>this.readNumber(16,4,!0,2));if(ot===void 0)return[nt,!1];tt[nt]=ot>>8,tt[nt+1]=ot&255}return[tt.length,!1]};return this.readAtomically(()=>{const tt=new Uint8Array(16),[rt,nt]=o(tt);if(rt===16)return tt;if(nt||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;const ot=new Uint8Array(14),it=16-(rt+2),[st]=o(ot.subarray(0,it));return tt.set(ot.subarray(0,st),16-st),tt})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}}const MAX_IPV6_LENGTH=45,MAX_IPV4_LENGTH=15,parser=new Parser;function parseIPv4(et){if(!(et.length>MAX_IPV4_LENGTH))return parser.new(et).parseWith(()=>parser.readIPv4Addr())}function parseIPv6(et){if(et.includes("%")&&(et=et.split("%")[0]),!(et.length>MAX_IPV6_LENGTH))return parser.new(et).parseWith(()=>parser.readIPv6Addr())}function parseIP(et){if(et.includes("%")&&(et=et.split("%")[0]),!(et.length>MAX_IPV6_LENGTH))return parser.new(et).parseWith(()=>parser.readIPAddr())}function fromString$r(et,o="utf8"){const tt=BASES$e[o];if(tt==null)throw new Error(`Unsupported encoding "${o}"`);return tt.decoder.decode(`${tt.prefix}${et}`)}function isIPv4(et){return!!parseIPv4(et)}function isIPv6(et){return!!parseIPv6(et)}function isIP(et){return!!parseIP(et)}const isV4=isIPv4,isV6=isIPv6,toBytes$1=function(et){let o=0;if(et=et.toString().trim(),isV4(et)){const tt=new Uint8Array(o+4);return et.split(/\./g).forEach(rt=>{tt[o++]=parseInt(rt,10)&255}),tt}if(isV6(et)){const tt=et.split(":",8);let rt;for(rt=0;rt0;rt--)ot.push("0");tt.splice.apply(tt,ot)}const nt=new Uint8Array(o+16);for(rt=0;rt>8&255,nt[o++]=ot&255}return nt}throw new Error("invalid ip address")},toString$s=function(et,o=0,tt){o=~~o,tt=tt??et.length-o;const rt=new DataView(et.buffer);if(tt===4){const nt=[];for(let ot=0;ot{const o=createProtocol(...et);codes[o.code]=o,names[o.name]=o});function createProtocol(et,o,tt,rt,nt){return{code:et,size:o,name:tt,resolvable:!!rt,path:!!nt}}function getProtocol(et){if(typeof et=="number"){if(codes[et]!=null)return codes[et];throw new Error(`no protocol with code: ${et}`)}else if(typeof et=="string"){if(names[et]!=null)return names[et];throw new Error(`no protocol with name: ${et}`)}throw new Error(`invalid protocol id type: ${typeof et}`)}getProtocol("ip4");getProtocol("ip6");getProtocol("ipcidr");function convertToString(et,o){switch(getProtocol(et).code){case 4:case 41:return bytes2ip(o);case 42:return bytes2str(o);case 6:case 273:case 33:case 132:return bytes2port(o).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bytes2str(o);case 421:return bytes2mh(o);case 444:return bytes2onion(o);case 445:return bytes2onion(o);case 466:return bytes2mb(o);case 481:return globalThis.encodeURIComponent(bytes2str(o));default:return toString$t(o,"base16")}}function convertToBytes(et,o){switch(getProtocol(et).code){case 4:return ip2bytes(o);case 41:return ip2bytes(o);case 42:return str2bytes(o);case 6:case 273:case 33:case 132:return port2bytes(parseInt(o,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return str2bytes(o);case 421:return mh2bytes(o);case 444:return onion2bytes(o);case 445:return onion32bytes(o);case 466:return mb2bytes(o);case 481:return str2bytes(globalThis.decodeURIComponent(o));default:return fromString$r(o,"base16")}}const decoders=Object.values(bases$e).map(et=>et.decoder),anybaseDecoder=function(){let et=decoders[0].or(decoders[1]);return decoders.slice(2).forEach(o=>et=et.or(o)),et}();function ip2bytes(et){if(!isIP(et))throw new Error("invalid ip address");return toBytes$1(et)}function bytes2ip(et){const o=toString$s(et,0,et.length);if(o==null)throw new Error("ipBuff is required");if(!isIP(o))throw new Error("invalid ip address");return o}function port2bytes(et){const o=new ArrayBuffer(2);return new DataView(o).setUint16(0,et),new Uint8Array(o)}function bytes2port(et){return new DataView(et.buffer).getUint16(et.byteOffset)}function str2bytes(et){const o=fromString$r(et),tt=Uint8Array.from(encode$P(o.length));return concat$3([tt,o],tt.length+o.length)}function bytes2str(et){const o=decode$Z(et);if(et=et.slice(encodingLength$6(o)),et.length!==o)throw new Error("inconsistent lengths");return toString$t(et)}function mh2bytes(et){let o;et[0]==="Q"||et[0]==="1"?o=decode$Q(base58btc$i.decode(`z${et}`)).bytes:o=CID$3.parse(et).multihash.bytes;const tt=Uint8Array.from(encode$P(o.length));return concat$3([tt,o],tt.length+o.length)}function mb2bytes(et){const o=anybaseDecoder.decode(et),tt=Uint8Array.from(encode$P(o.length));return concat$3([tt,o],tt.length+o.length)}function bytes2mb(et){const o=decode$Z(et),tt=et.slice(encodingLength$6(o));if(tt.length!==o)throw new Error("inconsistent lengths");return"u"+toString$t(tt,"base64url")}function bytes2mh(et){const o=decode$Z(et),tt=et.slice(encodingLength$6(o));if(tt.length!==o)throw new Error("inconsistent lengths");return toString$t(tt,"base58btc")}function onion2bytes(et){const o=et.split(":");if(o.length!==2)throw new Error(`failed to parse onion addr: ["'${o.join('", "')}'"]' does not contain a port number`);if(o[0].length!==16)throw new Error(`failed to parse onion addr: ${o[0]} not a Tor onion address.`);const tt=base32$w.decode("b"+o[0]),rt=parseInt(o[1],10);if(rt<1||rt>65536)throw new Error("Port number is not in range(1, 65536)");const nt=port2bytes(rt);return concat$3([tt,nt],tt.length+nt.length)}function onion32bytes(et){const o=et.split(":");if(o.length!==2)throw new Error(`failed to parse onion addr: ["'${o.join('", "')}'"]' does not contain a port number`);if(o[0].length!==56)throw new Error(`failed to parse onion addr: ${o[0]} not a Tor onion3 address.`);const tt=base32$w.decode(`b${o[0]}`),rt=parseInt(o[1],10);if(rt<1||rt>65536)throw new Error("Port number is not in range(1, 65536)");const nt=port2bytes(rt);return concat$3([tt,nt],tt.length+nt.length)}function bytes2onion(et){const o=et.slice(0,et.length-2),tt=et.slice(et.length-2),rt=toString$t(o,"base32"),nt=bytes2port(tt);return`${rt}:${nt}`}function stringToMultiaddrParts(et){et=cleanPath(et);const o=[],tt=[];let rt=null;const nt=et.split("/").slice(1);if(nt.length===1&&nt[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let ot=0;ot=nt.length)throw ParseError("invalid address: "+et);if(st.path===!0){rt=cleanPath(nt.slice(ot).join("/")),o.push([st.code,convertToBytes(st.code,rt)]),tt.push([st.code,rt]);break}const at=convertToBytes(st.code,nt[ot]);o.push([st.code,at]),tt.push([st.code,convertToString(st.code,at)])}return{string:stringTuplesToString(tt),bytes:tuplesToBytes(o),tuples:o,stringTuples:tt,path:rt}}function bytesToMultiaddrParts(et){const o=[],tt=[];let rt=null,nt=0;for(;ntet.length)throw ParseError("Invalid address Uint8Array: "+toString$t(et,"base16"));o.push([ot,ct]);const lt=convertToString(ot,ct);if(tt.push([ot,lt]),st.path===!0){rt=lt;break}}return{bytes:Uint8Array.from(et),string:stringTuplesToString(tt),tuples:o,stringTuples:tt,path:rt}}function stringTuplesToString(et){const o=[];return et.map(tt=>{const rt=getProtocol(tt[0]);return o.push(rt.name),tt.length>1&&tt[1]!=null&&o.push(tt[1]),null}),cleanPath(o.join("/"))}function tuplesToBytes(et){return concat$3(et.map(o=>{const tt=getProtocol(o[0]);let rt=Uint8Array.from(encode$P(tt.code));return o.length>1&&o[1]!=null&&(rt=concat$3([rt,o[1]])),rt}))}function sizeForAddr(et,o){if(et.size>0)return et.size/8;if(et.size===0)return 0;{const tt=decode$Z(o instanceof Uint8Array?o:Uint8Array.from(o));return tt+encodingLength$6(tt)}}function cleanPath(et){return"/"+et.trim().split("/").filter(o=>o).join("/")}function ParseError(et){return new Error("Error parsing address: "+et)}const inspect$1=Symbol.for("nodejs.util.inspect.custom"),symbol=Symbol.for("@multiformats/js-multiaddr/multiaddr"),DNS_CODES=[getProtocol("dns").code,getProtocol("dns4").code,getProtocol("dns6").code,getProtocol("dnsaddr").code];class NoAvailableResolverError extends Error{constructor(o="No available resolver"){super(o),this.name="NoAvailableResolverError"}}var na,Yn,wn,lo,uo;const Dn=class Dn{constructor(o){wt(this,"bytes");hr(this,Yn);hr(this,wn);hr(this,lo);hr(this,uo);wt(this,na,!0);o==null&&(o="");let tt;if(o instanceof Uint8Array)tt=bytesToMultiaddrParts(o);else if(typeof o=="string"){if(o.length>0&&o.charAt(0)!=="/")throw new Error(`multiaddr "${o}" must start with a "/"`);tt=stringToMultiaddrParts(o)}else if(isMultiaddr(o))tt=bytesToMultiaddrParts(o.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=tt.bytes,ur(this,Yn,tt.string),ur(this,wn,tt.tuples),ur(this,lo,tt.stringTuples),ur(this,uo,tt.path)}toString(){return Lt(this,Yn)}toJSON(){return this.toString()}toOptions(){let o,tt,rt,nt,ot="";const it=getProtocol("tcp"),st=getProtocol("udp"),at=getProtocol("ip4"),ct=getProtocol("ip6"),lt=getProtocol("dns6"),dt=getProtocol("ip6zone");for(const[mt,ft]of this.stringTuples())mt===dt.code&&(ot=`%${ft??""}`),DNS_CODES.includes(mt)&&(tt=it.name,nt=443,rt=`${ft??""}${ot}`,o=mt===lt.code?6:4),(mt===it.code||mt===st.code)&&(tt=getProtocol(mt).name,nt=parseInt(ft??"")),(mt===at.code||mt===ct.code)&&(tt=getProtocol(mt).name,rt=`${ft??""}${ot}`,o=mt===ct.code?6:4);if(o==null||tt==null||rt==null||nt==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:o,host:rt,transport:tt,port:nt}}protos(){return Lt(this,wn).map(([o])=>Object.assign({},getProtocol(o)))}protoCodes(){return Lt(this,wn).map(([o])=>o)}protoNames(){return Lt(this,wn).map(([o])=>getProtocol(o).name)}tuples(){return Lt(this,wn)}stringTuples(){return Lt(this,lo)}encapsulate(o){return o=new Dn(o),new Dn(this.toString()+o.toString())}decapsulate(o){const tt=o.toString(),rt=this.toString(),nt=rt.lastIndexOf(tt);if(nt<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${o.toString()}`);return new Dn(rt.slice(0,nt))}decapsulateCode(o){const tt=this.tuples();for(let rt=tt.length-1;rt>=0;rt--)if(tt[rt][0]===o)return new Dn(tuplesToBytes(tt.slice(0,rt)));return this}getPeerId(){try{let o=[];this.stringTuples().forEach(([rt,nt])=>{rt===names.p2p.code&&o.push([rt,nt]),rt===names["p2p-circuit"].code&&(o=[])});const tt=o.pop();if((tt==null?void 0:tt[1])!=null){const rt=tt[1];return rt[0]==="Q"||rt[0]==="1"?toString$t(base58btc$i.decode(`z${rt}`),"base58btc"):toString$t(CID$3.parse(rt).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return Lt(this,uo)}equals(o){return equals$c(this.bytes,o.bytes)}async resolve(o){const tt=this.protos().find(ot=>ot.resolvable);if(tt==null)return[this];const rt=resolvers$1.get(tt.name);if(rt==null)throw new NoAvailableResolverError(`no available resolver for ${tt.name}`);return(await rt(this,o)).map(ot=>multiaddr(ot))}nodeAddress(){const o=this.toOptions();if(o.transport!=="tcp"&&o.transport!=="udp")throw new 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){const tt=(o??this).protos();return!(tt.length!==2||tt[0].code!==4&&tt[0].code!==41||tt[1].code!==6&&tt[1].code!==273)}[(na=symbol,inspect$1)](){return`Multiaddr(${Lt(this,Yn)})`}};Yn=new WeakMap,wn=new WeakMap,lo=new WeakMap,uo=new WeakMap;let Multiaddr=Dn;const resolvers$1=new Map;function isMultiaddr(et){return!!(et!=null&&et[symbol])}function multiaddr(et){return new Multiaddr(et)}const E_CANCELED=new Error("request for lock canceled");var __awaiter$2=function(et,o,tt,rt){function nt(ot){return ot instanceof tt?ot:new tt(function(it){it(ot)})}return new(tt||(tt=Promise))(function(ot,it){function st(lt){try{ct(rt.next(lt))}catch(dt){it(dt)}}function at(lt){try{ct(rt.throw(lt))}catch(dt){it(dt)}}function ct(lt){lt.done?ot(lt.value):nt(lt.value).then(st,at)}ct((rt=rt.apply(et,o||[])).next())})};class Semaphore{constructor(o,tt=E_CANCELED){this._value=o,this._cancelError=tt,this._queue=[],this._weightedWaiters=[]}acquire(o=1,tt=0){if(o<=0)throw new Error(`invalid weight ${o}: must be positive`);return new Promise((rt,nt)=>{const ot={resolve:rt,reject:nt,weight:o,priority:tt},it=findIndexFromEnd(this._queue,st=>tt<=st.priority);it===-1&&o<=this._value?this._dispatchItem(ot):this._queue.splice(it+1,0,ot)})}runExclusive(o){return __awaiter$2(this,arguments,void 0,function*(tt,rt=1,nt=0){const[ot,it]=yield this.acquire(rt,nt);try{return yield tt(ot)}finally{it()}})}waitForUnlock(o=1,tt=0){if(o<=0)throw new Error(`invalid weight ${o}: must be positive`);return this._couldLockImmediately(o,tt)?Promise.resolve():new Promise(rt=>{this._weightedWaiters[o-1]||(this._weightedWaiters[o-1]=[]),insertSorted(this._weightedWaiters[o-1],{resolve:rt,priority:tt})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(o){this._value=o,this._dispatchQueue()}release(o=1){if(o<=0)throw new Error(`invalid weight ${o}: must be positive`);this._value+=o,this._dispatchQueue()}cancel(){this._queue.forEach(o=>o.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(o){const tt=this._value;this._value-=o.weight,o.resolve([tt,this._newReleaser(o.weight)])}_newReleaser(o){let tt=!1;return()=>{tt||(tt=!0,this.release(o))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let o=this._value;o>0;o--){const tt=this._weightedWaiters[o-1];tt&&(tt.forEach(rt=>rt.resolve()),this._weightedWaiters[o-1]=[])}else{const o=this._queue[0].priority;for(let tt=this._value;tt>0;tt--){const rt=this._weightedWaiters[tt-1];if(!rt)continue;const nt=rt.findIndex(ot=>ot.priority<=o);(nt===-1?rt:rt.splice(0,nt)).forEach(ot=>ot.resolve())}}}_couldLockImmediately(o,tt){return(this._queue.length===0||this._queue[0].priorityo.priority<=rt.priority);et.splice(tt+1,0,o)}function findIndexFromEnd(et,o){for(let tt=et.length-1;tt>=0;tt--)if(o(et[tt]))return tt;return-1}var __awaiter$1=function(et,o,tt,rt){function nt(ot){return ot instanceof tt?ot:new tt(function(it){it(ot)})}return new(tt||(tt=Promise))(function(ot,it){function st(lt){try{ct(rt.next(lt))}catch(dt){it(dt)}}function at(lt){try{ct(rt.throw(lt))}catch(dt){it(dt)}}function ct(lt){lt.done?ot(lt.value):nt(lt.value).then(st,at)}ct((rt=rt.apply(et,o||[])).next())})};class Mutex{constructor(o){this._semaphore=new Semaphore(1,o)}acquire(){return __awaiter$1(this,arguments,void 0,function*(o=0){const[,tt]=yield this._semaphore.acquire(1,o);return tt})}runExclusive(o,tt=0){return this._semaphore.runExclusive(()=>o(),1,tt)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(o=0){return this._semaphore.waitForUnlock(1,o)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class PeerManager{constructor(o,tt,rt){wt(this,"connectionManager");wt(this,"core");wt(this,"log");wt(this,"peers",new Map);wt(this,"healthManager");wt(this,"readMutex",new Mutex);wt(this,"writeMutex",new Mutex);wt(this,"writeLockHolder",null);this.connectionManager=o,this.core=tt,this.log=rt,this.healthManager=getHealthManager(),this.healthManager.updateProtocolHealth(this.core.multicodec,0)}getWriteLockHolder(){return this.writeLockHolder}getPeers(){return Array.from(this.peers.values())}async addPeer(o){return this.writeMutex.runExclusive(async()=>{this.writeLockHolder=`addPeer: ${o.id.toString()}`,await this.connectionManager.attemptDial(o.id),this.peers.set(o.id.toString(),o),this.log.info(`Added and dialed peer: ${o.id.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null})}async removePeer(o){return this.writeMutex.runExclusive(()=>{this.writeLockHolder=`removePeer: ${o.toString()}`,this.peers.delete(o.toString()),this.log.info(`Removed peer: ${o.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null})}async getPeerCount(){return this.readMutex.runExclusive(()=>this.peers.size)}async hasPeers(){return this.readMutex.runExclusive(()=>this.peers.size>0)}async removeExcessPeers(o){this.log.info(`Removing ${o} excess peer(s)`);const tt=Array.from(this.peers.values()).slice(0,o);for(const rt of tt)await this.removePeer(rt.id)}async findAndAddPeers(o){const tt=await this.findPeers(o);return tt.length===0?(this.log.warn("No additional peers found"),[]):this.addMultiplePeers(tt)}async findPeers(o){const tt=await this.core.getPeers();return this.readMutex.runExclusive(async()=>tt.filter(nt=>!this.peers.has(nt.id.toString())).slice(0,o))}async addMultiplePeers(o){const tt=[];for(const rt of o)await this.addPeer(rt),tt.push(rt);return tt}}const DEFAULT_NUM_PEERS_TO_USE=2,DEFAULT_MAINTAIN_PEERS_INTERVAL=3e4;class BaseProtocolSDK{constructor(o,tt,rt){wt(this,"core");wt(this,"connectionManager");wt(this,"peerManager");wt(this,"numPeersToUse");wt(this,"maintainPeersIntervalId",null);wt(this,"log");this.core=o,this.connectionManager=tt,this.log=new Logger$1(`sdk:${o.multicodec}`),this.numPeersToUse=(rt==null?void 0:rt.numPeersToUse)??DEFAULT_NUM_PEERS_TO_USE;const nt=(rt==null?void 0:rt.maintainPeersInterval)??DEFAULT_MAINTAIN_PEERS_INTERVAL;this.peerManager=new PeerManager(tt,o,this.log),this.log.info(`Initializing BaseProtocolSDK with numPeersToUse: ${this.numPeersToUse}, maintainPeersInterval: ${nt}ms`),this.startMaintainPeersInterval(nt)}get connectedPeers(){return this.peerManager.getPeers().slice(0,this.numPeersToUse)}async renewPeer(o){this.log.info(`Attempting to renew peer ${o}`);const tt=await this.peerManager.findPeers(1);if(tt.length===0){this.log.error("Failed to find a new peer to replace the disconnected one");return}return await this.peerManager.removePeer(o),await this.peerManager.addPeer(tt[0]),this.log.info(`Successfully renewed peer. New peer: ${tt[0].id}`),tt[0]}stopMaintainPeersInterval(){this.maintainPeersIntervalId?(clearInterval(this.maintainPeersIntervalId),this.maintainPeersIntervalId=null,this.log.info("Maintain peers interval stopped")):this.log.info("Maintain peers interval was not running")}async hasPeers(o={}){const{forceUseAllPeers:tt=!1,maxAttempts:rt=3}=o;this.log.info(`Checking for peers. forceUseAllPeers: ${tt}, maxAttempts: ${rt}`);for(let nt=0;nt0)return this.log.info(`At least one peer connected (${this.connectedPeers.length}), not forcing use of all peers`),!0;if(this.connectedPeers.length>=this.numPeersToUse)return this.log.info(`Required number of peers (${this.numPeersToUse}) reached`),!0;this.log.warn(`Found only ${this.connectedPeers.length}/${this.numPeersToUse} required peers. Retrying...`)}return this.log.error(`Failed to find required number of peers (${this.numPeersToUse}) after ${rt} attempts`),!1}async startMaintainPeersInterval(o){this.log.info(`Starting maintain peers interval with ${o}ms interval`);try{this.maintainPeersIntervalId=setInterval(()=>{this.log.info("Running scheduled peer maintenance"),this.maintainPeers().catch(tt=>{this.log.error("Error during scheduled peer maintenance:",tt)})},o),this.log.info("Maintain peers interval started successfully")}catch(tt){throw this.log.error("Error starting maintain peers interval:",tt),tt}}async maintainPeers(){try{const o=await this.peerManager.getPeerCount(),tt=this.numPeersToUse-o;if(this.log.info(`Current peer count: ${o}, target: ${this.numPeersToUse}`),tt===0){this.log.info("Peer count is at target, no maintenance required");return}tt>0?(this.log.info(`Attempting to add ${tt} peer(s)`),await this.peerManager.findAndAddPeers(tt)):(this.log.info(`Attempting to remove ${Math.abs(tt)} excess peer(s)`),await this.peerManager.removeExcessPeers(Math.abs(tt)));const rt=await this.peerManager.getPeerCount();this.log.info(`Peer maintenance completed. Initial count: ${o}, Final count: ${rt}`)}catch(o){this.log.error("Error during peer maintenance",{error:o})}}}const DEFAULT_KEEP_ALIVE=6e4,DEFAULT_LIGHT_PUSH_FILTER_CHECK=!1,DEFAULT_LIGHT_PUSH_FILTER_CHECK_INTERVAL=1e4,DEFAULT_SUBSCRIBE_OPTIONS={keepAlive:DEFAULT_KEEP_ALIVE,enableLightPushFilterCheck:DEFAULT_LIGHT_PUSH_FILTER_CHECK};function messageHash(et,o){const tt=utf8ToBytes$1(et),rt=utf8ToBytes$1(o.contentTopic),nt=tryConvertTimestampToBytes(o.timestamp),ot=concat$5([tt,o.payload,rt,o.meta,nt].filter(isDefined));return sha256$3(ot)}function tryConvertTimestampToBytes(et){if(!et)return;let o;return typeof et=="bigint"?o=et:o=BigInt(et.valueOf())*1000000n,numberToBytes(o)}function messageHashStr(et,o){const tt=messageHash(et,o);return bytesToHex$1(tt)}const log$h=new Logger$1("sdk:receiver:reliability_monitor"),DEFAULT_MAX_PINGS=3,MESSAGE_VERIFICATION_DELAY=5e3;class ReceiverReliabilityMonitor{constructor(o,tt,rt,nt,ot,it,st){wt(this,"pubsubTopic");wt(this,"getPeers");wt(this,"renewPeer");wt(this,"getContentTopics");wt(this,"protocolSubscribe");wt(this,"addLibp2pEventListener");wt(this,"sendLightPushMessage");wt(this,"receivedMessagesFormPeer",new Set);wt(this,"receivedMessages",new Set);wt(this,"scheduledVerification",new Map);wt(this,"verifiedPeers",new Set);wt(this,"peerFailures",new Map);wt(this,"maxPingFailures",DEFAULT_MAX_PINGS);wt(this,"peerRenewalLocks",new Set);this.pubsubTopic=o,this.getPeers=tt,this.renewPeer=rt,this.getContentTopics=nt,this.protocolSubscribe=ot,this.addLibp2pEventListener=it,this.sendLightPushMessage=st,this.addLibp2pEventListener("peer:disconnect",at=>{const ct=at.detail;this.getPeers().some(lt=>lt.id.equals(ct))&&this.renewAndSubscribePeer(ct)})}setMaxPingFailures(o){o!==void 0&&(this.maxPingFailures=o)}async handlePingResult(o,tt){if(tt!=null&&tt.success){this.peerFailures.delete(o.toString());return}const rt=(this.peerFailures.get(o.toString())||0)+1;if(this.peerFailures.set(o.toString(),rt),rt>=this.maxPingFailures)try{log$h.info(`Attempting to renew ${o.toString()} due to ping failures.`),await this.renewAndSubscribePeer(o),this.peerFailures.delete(o.toString())}catch(nt){log$h.error(`Failed to renew peer ${o.toString()}: ${nt}.`)}}notifyMessageReceived(o,tt){const rt=this.buildMessageHash(tt);return this.verifiedPeers.add(o),this.receivedMessagesFormPeer.add(`${o}-${rt}`),log$h.info(`notifyMessage received debug: ephemeral:${tt.ephemeral} ${bytesToUtf8(tt.payload)}`),log$h.info(`notifyMessage received: peer:${o} message:${rt}`),this.receivedMessages.has(rt)?!0:(this.receivedMessages.add(rt),!1)}notifyMessageSent(o,tt){const rt=o.toString(),nt=this.buildMessageHash(tt);if(log$h.info(`notifyMessage sent debug: ${bytesToUtf8(tt.payload)}`),this.scheduledVerification.has(rt)){log$h.warn(`notifyMessage sent: attempting to schedule verification for pending peer:${rt} message:${nt}`);return}const ot=window.setTimeout(async()=>{const it=this.verifiedPeers.has(rt),st=this.receivedMessagesFormPeer.has(`${rt}-${nt}`);if(it||st){log$h.info(`notifyMessage sent setTimeout: verified that peer pushes filter messages, peer:${rt} message:${nt}`);return}log$h.warn(`notifyMessage sent setTimeout: peer didn't return probe message, attempting renewAndSubscribe, peer:${rt} message:${nt}`),this.scheduledVerification.delete(rt),await this.renewAndSubscribePeer(o)},MESSAGE_VERIFICATION_DELAY);this.scheduledVerification.set(rt,ot)}shouldVerifyPeer(o){const tt=o.toString(),rt=this.verifiedPeers.has(tt),nt=this.scheduledVerification.has(tt);return!(rt||nt)}buildMessageHash(o){return messageHashStr(this.pubsubTopic,o)}async renewAndSubscribePeer(o){const tt=o.toString();try{if(this.peerRenewalLocks.has(tt)){log$h.info(`Peer ${tt} is already being renewed.`);return}this.peerRenewalLocks.add(tt);const rt=await this.renewPeer(o);if(!rt){log$h.warn(`Failed to renew peer ${tt}: No new peer found.`);return}return await this.protocolSubscribe(this.pubsubTopic,rt,this.getContentTopics()),await this.sendLightPushMessage(rt),this.peerFailures.delete(tt),rt}catch(rt){log$h.error(`Failed to renew peer ${tt}: ${rt}.`);return}finally{this.peerRenewalLocks.delete(tt)}}}const On=class On{static createReceiverMonitor(o,tt,rt,nt,ot,it,st){if(On.receiverMonitors.has(o))return On.receiverMonitors.get(o);const at=new ReceiverReliabilityMonitor(o,tt,rt,nt,ot,it,st);return On.receiverMonitors.set(o,at),at}constructor(){}static stop(o){this.receiverMonitors.delete(o)}static stopAll(){for(const[o,tt]of this.receiverMonitors)tt.setMaxPingFailures(void 0),this.receiverMonitors.delete(o)}};wt(On,"receiverMonitors",new Map);let ReliabilityMonitorManager=On;const log$g=new Logger$1("sdk:filter:subscription_manager");class SubscriptionManager{constructor(o,tt,rt,nt,ot,it,st){wt(this,"pubsubTopic");wt(this,"protocol");wt(this,"connectionManager");wt(this,"getPeers");wt(this,"renewPeer");wt(this,"libp2p");wt(this,"lightPush");wt(this,"reliabilityMonitor");wt(this,"keepAliveTimeout",DEFAULT_KEEP_ALIVE);wt(this,"keepAliveInterval",null);wt(this,"enableLightPushFilterCheck",DEFAULT_LIGHT_PUSH_FILTER_CHECK);wt(this,"subscriptionCallbacks");this.pubsubTopic=o,this.protocol=tt,this.connectionManager=rt,this.getPeers=nt,this.renewPeer=ot,this.libp2p=it,this.lightPush=st,this.pubsubTopic=o,this.subscriptionCallbacks=new Map,this.reliabilityMonitor=ReliabilityMonitorManager.createReceiverMonitor(this.pubsubTopic,this.getPeers.bind(this),this.renewPeer.bind(this),()=>Array.from(this.subscriptionCallbacks.keys()),this.protocol.subscribe.bind(this.protocol),this.protocol.addLibp2pEventListener.bind(this.protocol),this.sendLightPushCheckMessage.bind(this))}async subscribe(o,tt,rt=DEFAULT_SUBSCRIBE_OPTIONS){this.reliabilityMonitor.setMaxPingFailures(rt.pingsBeforePeerRenewed),this.keepAliveTimeout=rt.keepAlive||DEFAULT_KEEP_ALIVE,this.enableLightPushFilterCheck=(rt==null?void 0:rt.enableLightPushFilterCheck)||DEFAULT_LIGHT_PUSH_FILTER_CHECK;const nt=Array.isArray(o)?o:[o];for(const lt of nt)if(lt.pubsubTopic!==this.pubsubTopic)return{failures:[{error:ProtocolError$1.TOPIC_DECODER_MISMATCH}],successes:[]};this.enableLightPushFilterCheck&&nt.push(createDecoder(this.buildLightPushContentTopic(),this.pubsubTopic));const ot=groupByContentTopic(nt),it=Array.from(ot.keys()),st=this.getPeers().map(async lt=>this.subscribeWithPeerVerification(lt,it)),at=await Promise.allSettled(st),ct=this.handleResult(at,"subscribe");return ot.forEach((lt,dt)=>{const ht={decoders:lt,callback:tt};dt!==this.buildLightPushContentTopic()&&this.subscriptionCallbacks.set(dt,ht)}),this.startSubscriptionsMaintenance(this.keepAliveTimeout),ct}async unsubscribe(o){const tt=this.getPeers().map(async ot=>{const it=await this.protocol.unsubscribe(this.pubsubTopic,ot,o);return o.forEach(st=>{this.subscriptionCallbacks.delete(st)}),it}),rt=await Promise.allSettled(tt),nt=this.handleResult(rt,"unsubscribe");return this.subscriptionCallbacks.size===0&&this.stopSubscriptionsMaintenance(),nt}async ping(o){log$g.info("Sending keep-alive ping");const rt=(o?[o]:this.getPeers().map(ot=>ot.id)).map(ot=>this.pingSpecificPeer(ot)),nt=await Promise.allSettled(rt);return this.handleResult(nt,"ping")}async unsubscribeAll(){const o=this.getPeers().map(async nt=>this.protocol.unsubscribeAll(this.pubsubTopic,nt)),tt=await Promise.allSettled(o);this.subscriptionCallbacks.clear();const rt=this.handleResult(tt,"unsubscribeAll");return this.stopSubscriptionsMaintenance(),rt}async processIncomingMessage(o,tt){if(this.reliabilityMonitor.notifyMessageReceived(tt,o)){log$g.info("Message already received, skipping");return}const{contentTopic:nt}=o,ot=this.subscriptionCallbacks.get(nt);if(!ot){log$g.error("No subscription callback available for ",nt);return}log$g.info("Processing message with content topic ",nt," on pubsub topic ",this.pubsubTopic),await pushMessage(ot,this.pubsubTopic,o)}async subscribeWithPeerVerification(o,tt){const rt=await this.protocol.subscribe(this.pubsubTopic,o,tt);return await this.sendLightPushCheckMessage(o),rt}handleResult(o,tt){const rt={failures:[],successes:[]};for(const nt of o)if(nt.status==="rejected")log$g.error(`Failed to resolve ${tt} promise successfully: `,nt.reason),rt.failures.push({error:ProtocolError$1.GENERIC_FAIL});else{const ot=nt.value;ot.failure?rt.failures.push(ot.failure):rt.successes.push(ot.success)}return rt}async pingSpecificPeer(o){var nt,ot;const tt=this.getPeers().find(it=>it.id.equals(o));if(!tt)return{success:null,failure:{peerId:o,error:ProtocolError$1.NO_PEER_AVAILABLE}};let rt;try{rt=await this.protocol.ping(tt)}catch{rt={success:null,failure:{peerId:o,error:ProtocolError$1.GENERIC_FAIL}}}return log$g.info(`Received result from filter ping peerId:${o.toString()} success:${(nt=rt.success)==null?void 0:nt.toString()} failure:${(ot=rt.failure)==null?void 0:ot.error}`),await this.reliabilityMonitor.handlePingResult(o,rt),rt}startSubscriptionsMaintenance(o){log$g.info("Starting subscriptions maintenance"),this.startKeepAlivePings(o),this.startConnectionListener()}stopSubscriptionsMaintenance(){log$g.info("Stopping subscriptions maintenance"),this.stopKeepAlivePings(),this.stopConnectionListener()}startConnectionListener(){this.connectionManager.addEventListener(EConnectionStateEvents.CONNECTION_STATUS,this.connectionListener.bind(this))}stopConnectionListener(){this.connectionManager.removeEventListener(EConnectionStateEvents.CONNECTION_STATUS,this.connectionListener.bind(this))}async connectionListener({detail:o}){if(!o){this.stopKeepAlivePings();return}try{await this.ping()}catch(tt){log$g.error(`networkStateListener failed to recover: ${tt}`)}this.startKeepAlivePings(this.keepAliveTimeout)}startKeepAlivePings(o){if(this.keepAliveInterval){log$g.info("Recurring pings already set up.");return}this.keepAliveInterval=setInterval(()=>{this.ping()},o)}stopKeepAlivePings(){if(!this.keepAliveInterval){log$g.info("Already stopped recurring pings.");return}log$g.info("Stopping recurring pings."),clearInterval(this.keepAliveInterval),this.keepAliveInterval=null}async sendLightPushCheckMessage(o){if(this.lightPush&&this.libp2p&&this.reliabilityMonitor.shouldVerifyPeer(o.id)){const tt=createEncoder({contentTopic:this.buildLightPushContentTopic(),pubsubTopic:this.pubsubTopic,ephemeral:!0}),rt={payload:new Uint8Array(1)},nt=await tt.toProtoObj(rt);setTimeout(async()=>{const ot=await this.lightPush.protocol.send(tt,rt,o);if(this.reliabilityMonitor.notifyMessageSent(o.id,nt),ot.failure){log$g.error(`failed to send lightPush ping message to peer:${o.id.toString()} ${ot.failure.error}`);return}},DEFAULT_LIGHT_PUSH_FILTER_CHECK_INTERVAL)}}buildLightPushContentTopic(){return`/js-waku-subscription-ping/1/${this.libp2p.peerId.toString()}/utf8`}}async function pushMessage(et,o,tt){const{decoders:rt,callback:nt}=et,{contentTopic:ot}=tt;if(!ot){log$g.warn("Message has no content topic, skipping");return}try{const it=rt.map(at=>at.fromProtoObj(o,tt).then(ct=>ct||Promise.reject("Decoding failed"))),st=await Promise.any(it);await nt(st)}catch(it){log$g.error("Error decoding message",it)}}const log$f=new Logger$1("sdk:filter");class Filter extends BaseProtocolSDK{constructor(tt,rt,nt,ot){super(new FilterCore(async(it,st,at)=>{const ct=this.getActiveSubscription(it);if(!ct){log$f.error(`No subscription locally registered for topic ${it}`);return}await ct.processIncomingMessage(st,at)},tt.configuredPubsubTopics,rt),tt,{numPeersToUse:ot==null?void 0:ot.numPeersToUse});wt(this,"libp2p");wt(this,"lightPush");wt(this,"protocol");wt(this,"activeSubscriptions",new Map);this.libp2p=rt,this.lightPush=nt,this.protocol=this.core,this.activeSubscriptions=new Map}async subscribe(tt,rt,nt,ot=DEFAULT_SUBSCRIBE_OPTIONS){const it=this.getUniquePubsubTopics(tt);if(it.length!==1)return{subscription:null,error:ProtocolError$1.INVALID_DECODER_TOPICS,results:null};const st=it[0],{subscription:at,error:ct}=await this.createSubscription(st,nt);if(ct)return{subscription:null,error:ct,results:null};const{failures:lt,successes:dt}=await at.subscribe(tt,rt,ot);return{subscription:at,error:null,results:{failures:lt,successes:dt}}}async createSubscription(tt,rt){var st;rt={autoRetry:!0,...rt};const nt=typeof tt=="string"?tt:(st=shardInfoToPubsubTopics(tt))==null?void 0:st[0];return ensurePubsubTopicIsConfigured(nt,this.protocol.pubsubTopics),await this.hasPeers(rt)?(log$f.info(`Creating filter subscription with ${this.connectedPeers.length} peers: `,this.connectedPeers.map(at=>at.id.toString())),{error:null,subscription:this.getActiveSubscription(nt)??this.setActiveSubscription(nt,new SubscriptionManager(nt,this.protocol,this.connectionManager,()=>this.connectedPeers,this.renewPeer.bind(this),this.libp2p,this.lightPush))}):{error:ProtocolError$1.NO_PEER_AVAILABLE,subscription:null}}async subscribeWithUnsubscribe(tt,rt,nt=DEFAULT_SUBSCRIBE_OPTIONS){const ot=this.getUniquePubsubTopics(tt);if(ot.length===0)throw Error("Failed to subscribe: no pubsubTopic found on decoders provided.");if(ot.length>1)throw Error("Failed to subscribe: all decoders should have the same pubsub topic. Use createSubscription to be more agile.");const{subscription:it,error:st}=await this.createSubscription(ot[0]);if(st)throw Error(`Failed to create subscription: ${st}`);await it.subscribe(tt,rt,nt);const at=Array.from(groupByContentTopic(Array.isArray(tt)?tt:[tt]).keys());return async()=>{await it.unsubscribe(at)}}toSubscriptionIterator(tt){return toAsyncIterator(this,tt)}getActiveSubscription(tt){return this.activeSubscriptions.get(tt)}setActiveSubscription(tt,rt){return this.activeSubscriptions.set(tt,rt),rt}getUniquePubsubTopics(tt){return Array.isArray(tt)?tt.length===0?[]:[...new Set(tt.map(nt=>nt.pubsubTopic))]:[tt.pubsubTopic]}}function wakuFilter(et,o,tt){return rt=>new Filter(et,rt,o,tt)}const log$e=new Logger$1("sdk:light-push"),DEFAULT_MAX_ATTEMPTS=3,DEFAULT_SEND_OPTIONS={autoRetry:!1,maxAttempts:DEFAULT_MAX_ATTEMPTS};class LightPush{constructor(o,tt,rt){wt(this,"libp2p");wt(this,"numPeersToUse",DEFAULT_NUM_PEERS_TO_USE);wt(this,"protocol");this.libp2p=tt,this.numPeersToUse=(rt==null?void 0:rt.numPeersToUse)??DEFAULT_NUM_PEERS_TO_USE,this.protocol=new LightPushCore(o.configuredPubsubTopics,tt)}async send(o,tt,rt=DEFAULT_SEND_OPTIONS){const nt=[],ot=[],{pubsubTopic:it}=o;try{ensurePubsubTopicIsConfigured(it,this.protocol.pubsubTopics)}catch{return log$e.error("Failed to send waku light push: pubsub topic not configured"),{successes:nt,failures:[{error:ProtocolError$1.TOPIC_NOT_CONFIGURED}]}}const st=await this.getConnectedPeers();if(st.length===0)return{successes:nt,failures:[{error:ProtocolError$1.NO_PEER_AVAILABLE}]};const at=await Promise.allSettled(st.map(ct=>this.protocol.send(o,tt,ct)));for(const ct of at){if(ct.status!=="fulfilled"){log$e.error("Failed unexpectedly while sending:",ct.reason),ot.push({error:ProtocolError$1.GENERIC_FAIL});continue}const{failure:lt,success:dt}=ct.value;if(dt){nt.push(dt);continue}lt&&(ot.push(lt),rt!=null&&rt.autoRetry&&this.attemptRetries(ht=>this.protocol.send(o,tt,ht),rt.maxAttempts))}return getHealthManager().updateProtocolHealth(this.protocol.multicodec,nt.length),{successes:nt,failures:ot}}async attemptRetries(o,tt){var nt;tt=tt||DEFAULT_MAX_ATTEMPTS;const rt=await this.getConnectedPeers();if(rt.length===0){log$e.warn("Cannot retry with no connected peers.");return}for(let ot=0;ot{try{return await this.libp2p.peerStore.get(rt)}catch{return null}}))).filter(rt=>!!rt).filter(rt=>rt.protocols.includes(LightPushCodec)).slice(0,this.numPeersToUse)}}function wakuLightPush(et,o={}){return tt=>new LightPush(et,tt,o)}const DEFAULT_NUM_PEERS=1,log$d=new Logger$1("waku:store:sdk");class Store extends BaseProtocolSDK{constructor(tt,rt,nt){super(new StoreCore(tt.configuredPubsubTopics,rt),tt,{numPeersToUse:DEFAULT_NUM_PEERS});wt(this,"peerIdStrToUse");wt(this,"protocol");this.peerIdStrToUse=nt,this.protocol=this.core}async*queryGenerator(tt,rt){const{pubsubTopic:nt,contentTopics:ot,decodersAsMap:it}=this.validateDecodersAndPubsubTopic(tt),st={pubsubTopic:nt,contentTopics:ot,includeData:!0,paginationForward:!0,...rt},at=(await this.protocol.getPeers({numPeers:this.numPeersToUse,maxBootstrapPeers:1,peerIdStr:this.peerIdStrToUse}))[0];if(!at)throw log$d.error("No peers available to query"),new Error("No peers available to query");log$d.info(`Querying store with options: ${JSON.stringify(rt)}`);const ct=this.protocol.queryPerPage(st,it,at);for await(const lt of ct)yield lt}async queryWithOrderedCallback(tt,rt,nt){log$d.info("Querying store with ordered callback");for await(const ot of this.queryGenerator(tt,nt))if(await this.processMessages(ot,rt))break}async queryWithPromiseCallback(tt,rt,nt){log$d.info("Querying store with promise callback");let ot=!1;for await(const it of this.queryGenerator(tt,nt)){const st=it.map(async at=>{ot||(ot=!!await rt(at))});if(await Promise.all(st),ot)break}}async processMessages(tt,rt){let nt=!1;const it=(await Promise.all(tt)).filter(isDefined);return await Promise.all(it.map(async st=>{st&&!nt&&(nt=!!await rt(st))})),nt}createCursor(tt){return messageHash(tt.pubsubTopic,tt)}validateDecodersAndPubsubTopic(tt){if(tt.length===0)throw log$d.error("No decoders provided"),new Error("No decoders provided");const rt=Array.from(new Set(tt.map(st=>st.pubsubTopic)));if(rt.length>1)throw log$d.error("API does not support querying multiple pubsub topics at once"),new Error("API does not support querying multiple pubsub topics at once");const nt=rt[0];ensurePubsubTopicIsConfigured(nt,this.protocol.pubsubTopics);const ot=new Map;tt.forEach(st=>{if(ot.has(st.contentTopic))throw log$d.error("API does not support different decoder per content topic"),new Error("API does not support different decoder per content topic");ot.set(st.contentTopic,st)});const it=tt.filter(st=>st.pubsubTopic===nt).map(st=>st.contentTopic);if(it.length===0)throw log$d.error(`No decoders found for topic ${nt}`),new Error("No decoders found for topic "+nt);return{pubsubTopic:nt,contentTopics:it,decodersAsMap:ot}}}function wakuStore(et,o){return tt=>new Store(et,tt,o)}const log$c=new Logger$1("wait-for-remote-peer");async function waitForRemotePeer(et,o,tt){o=o!=null&&o.length?o:getEnabledProtocols(et);const rt=et.libp2p.getConnections();if(!et.isStarted())throw Error("Waku node is not started");if(rt.length>0&&!o.includes(Protocols.Relay)&&await waitForMetadata(et,o))return;const nt=[];if(o.includes(Protocols.Relay)){if(!et.relay)throw Error("Cannot wait for Relay peer: protocol not mounted");nt.push(et.relay.waitForPeers())}if(o.includes(Protocols.Store)){if(!et.store)throw Error("Cannot wait for Store peer: protocol not mounted");nt.push(waitForConnectedPeer(StoreCodec,et.libp2p))}if(o.includes(Protocols.LightPush)){if(!et.lightPush)throw Error("Cannot wait for LightPush peer: protocol not mounted");nt.push(waitForConnectedPeer(LightPushCodec,et.libp2p))}if(o.includes(Protocols.Filter)){if(!et.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");nt.push(waitForConnectedPeer(FilterCodecs.SUBSCRIBE,et.libp2p))}tt?await rejectOnTimeout(Promise.all(nt),tt,"Timed out waiting for a remote peer."):await Promise.all(nt)}async function waitForConnectedPeer(et,o){log$c.info(`Waiting for ${et} peer.`),await new Promise(tt=>{const rt=async nt=>{var ot,it;if((it=(ot=nt.detail)==null?void 0:ot.protocols)!=null&&it.includes(et)){const st=o.services.metadata;if(!st){o.removeEventListener("peer:identify",rt),tt();return}try{await st.confirmOrAttemptHandshake(nt.detail.peerId),o.removeEventListener("peer:identify",rt),tt()}catch(at){at.code==="ERR_CONNECTION_BEING_CLOSED"&&log$c.error("Connection closed. Some peers can be on different shard."),log$c.error(`Error waiting for metadata: ${at}`)}}};o.addEventListener("peer:identify",rt)})}async function waitForMetadata(et,o){const tt=et.libp2p.getPeers(),rt=et.libp2p.services.metadata,nt=mapProtocolsToCodecs(o);if(!tt.length||!rt)return log$c.info(`Skipping waitForMetadata due to missing connections:${tt.length} or metadataService:${!!rt}`),!1;for(const ot of tt)try{const it=await et.libp2p.peerStore.get(ot);if(it.protocols.some(at=>nt.has(at))&&!(await rt.confirmOrAttemptHandshake(ot)).error&&(it.protocols.forEach(lt=>{nt.has(lt)&&nt.set(lt,!0)}),Array.from(nt.values()).every(lt=>lt)))return!0}catch(it){it.code==="ERR_CONNECTION_BEING_CLOSED"&&log$c.error("Connection closed. Some peers can be on different shard."),log$c.error(`Error while iterating through peers: ${it}`);continue}return!1}const awaitTimeout=(et,o)=>new Promise((tt,rt)=>setTimeout(()=>rt(Error(o)),et));async function rejectOnTimeout(et,o,tt){await Promise.race([et,awaitTimeout(o,tt)])}function getEnabledProtocols(et){const o=[];return et.relay&&o.push(Protocols.Relay),et.filter&&o.push(Protocols.Filter),et.store&&o.push(Protocols.Store),et.lightPush&&o.push(Protocols.LightPush),o}function mapProtocolsToCodecs(et){const o=new Map,tt={[Protocols.Filter]:FilterCodecs.SUBSCRIBE,[Protocols.LightPush]:LightPushCodec,[Protocols.Store]:StoreCodec};for(const rt of et)tt[rt]&&o.set(tt[rt],!1);return o}const DefaultPingKeepAliveValueSecs=5*60,DefaultRelayKeepAliveValueSecs=5*60,DefaultUserAgent="js-waku",DefaultPingMaxInboundStreams=10,log$b=new Logger$1("waku");class WakuNode{constructor(o,tt,rt,nt,ot){wt(this,"pubsubTopics");wt(this,"libp2p");wt(this,"relay");wt(this,"store");wt(this,"filter");wt(this,"lightPush");wt(this,"connectionManager");wt(this,"health");var ct;this.pubsubTopics=o,this.relay=ot,this.libp2p=rt,nt={filter:!1,lightpush:!1,store:!1,...nt};const it=tt.pingKeepAlive||DefaultPingKeepAliveValueSecs,st=this.relay?tt.relayKeepAlive||DefaultRelayKeepAliveValueSecs:0,at=this.libp2p.peerId.toString();if(this.connectionManager=ConnectionManager.create(at,rt,{pingKeepAlive:it,relayKeepAlive:st},this.pubsubTopics,this.relay),this.health=getHealthManager(),nt.store){let lt;(ct=tt.nodeToUse)!=null&&ct.store&&this.dialMultiaddr(tt.nodeToUse.store,StoreCodec).catch(ht=>{log$b.error("Failed to dial store peer",ht)});const dt=wakuStore(this.connectionManager,lt);this.store=dt(rt)}if(nt.lightpush){const lt=wakuLightPush(this.connectionManager,tt);this.lightPush=lt(rt)}if(nt.filter){const lt=wakuFilter(this.connectionManager,this.lightPush,tt);this.filter=lt(rt)}log$b.info("Waku node created",at,`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`)}get peerId(){return this.libp2p.peerId}get protocols(){return this.libp2p.getProtocols()}async dial(o,tt){const rt=tt??[],nt=this.mapToPeerIdOrMultiaddr(o);typeof tt>"u"&&(this.relay&&rt.push(Protocols.Relay),this.store&&rt.push(Protocols.Store),this.filter&&rt.push(Protocols.Filter),this.lightPush&&rt.push(Protocols.LightPush));const ot=[];return rt.includes(Protocols.Relay)&&(this.relay?this.relay.gossipSub.multicodecs.forEach(it=>ot.push(it)):log$b.error("Relay codec not included in dial codec: protocol not mounted locally")),rt.includes(Protocols.Store)&&(this.store?ot.push(this.store.protocol.multicodec):log$b.error("Store codec not included in dial codec: protocol not mounted locally")),rt.includes(Protocols.LightPush)&&(this.lightPush?ot.push(this.lightPush.protocol.multicodec):log$b.error("Light Push codec not included in dial codec: protocol not mounted locally")),rt.includes(Protocols.Filter)&&(this.filter?ot.push(this.filter.protocol.multicodec):log$b.error("Filter codec not included in dial codec: protocol not mounted locally")),log$b.info(`Dialing to ${nt.toString()} with protocols ${rt}`),this.libp2p.dialProtocol(nt,ot)}async start(){await this.libp2p.start()}async stop(){ReliabilityMonitorManager.stopAll(),this.connectionManager.stop(),await this.libp2p.stop()}async waitForPeers(o,tt){return waitForRemotePeer(this,o,tt)}isStarted(){return this.libp2p.status=="started"}isConnected(){return this.connectionManager.isConnected()}async dialMultiaddr(o,tt){const rt=multiaddr(o);if(!rt.getPeerId())throw new Error("Failed to dial multiaddr: missing peer ID");return await this.libp2p.dialProtocol(rt,[tt]),rt.getPeerId()}mapToPeerIdOrMultiaddr(o){return isPeerId$2(o)?o:multiaddr(o)}}var ds;let InvalidParametersError$3=(ds=class extends Error{constructor(o="Invalid parameters"){super(o),this.name="InvalidParametersError"}},wt(ds,"name","InvalidParametersError"),ds);class InvalidPublicKeyError extends Error{constructor(o="Invalid public key"){super(o),this.name="InvalidPublicKeyError"}}wt(InvalidPublicKeyError,"name","InvalidPublicKeyError");var hs;let UnsupportedKeyTypeError$1=(hs=class extends Error{constructor(o="Unsupported key type"){super(o),this.name="UnsupportedKeyTypeError"}},wt(hs,"name","UnsupportedKeyTypeError"),hs);function equals$b(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$i=base$i,_brrp__multiformats_scope_baseX$h=src$i;let Encoder$i=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$i=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$j(this,o)}},ComposedDecoder$h=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$j(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$j(et,o){return new ComposedDecoder$h({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$h=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$i(o,tt,rt),this.decoder=new Decoder$i(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$k({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$h(et,o,tt,rt)}function baseX$h({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$h(tt,et);return from$k({prefix:o,name:et,encode:rt,decode:ot=>coerce$i(nt(ot))})}function decode$O(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$G(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<=INT$4;)o[tt++]=et&255|MSB$6,et/=128;for(;et&MSBALL$4;)o[tt++]=et&255|MSB$6,et>>>=7;return o[tt]=et|0,encode$F.bytes=tt-rt+1,o}var decode$N=read$5,MSB$1$4=128,REST$1$4=127;function read$5(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$5.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$4)<=MSB$1$4);return read$5.bytes=ot-rt,tt}var N1$4=Math.pow(2,7),N2$4=Math.pow(2,14),N3$4=Math.pow(2,21),N4$4=Math.pow(2,28),N5$4=Math.pow(2,35),N6$4=Math.pow(2,42),N7$4=Math.pow(2,49),N8$4=Math.pow(2,56),N9$4=Math.pow(2,63),length$4=function(et){return et{const[dt,ht]=decode$M(o.subarray(tt));return tt+=ht,dt};let nt=rt(),ot=DAG_PB_CODE$2;if(nt===18?(nt=0,tt=0):ot=rt(),nt!==0&&nt!==1)throw new RangeError(`Invalid CID version ${nt}`);const it=tt,st=rt(),at=rt(),ct=tt+at,lt=ct-it;return{version:nt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(o,tt){const[rt,nt]=parseCIDtoBytes$2(o,tt),ot=Nr.decode(nt);if(ot.version===0&&o[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache$2(ot).set(rt,o),ot}};function parseCIDtoBytes$2(et,o){switch(et[0]){case"Q":{const tt=o??base58btc$h;return[base58btc$h.prefix,tt.decode(`${base58btc$h.prefix}${et}`)]}case base58btc$h.prefix:{const tt=o??base58btc$h;return[base58btc$h.prefix,tt.decode(et)]}case base32$u.prefix:{const tt=o??base32$u;return[base32$u.prefix,tt.decode(et)]}case base36$r.prefix:{const tt=o??base36$r;return[base36$r.prefix,tt.decode(et)]}default:{if(o==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[et[0],o.decode(et)]}}}function toStringV0$2(et,o,tt){const{prefix:rt}=tt;if(rt!==base58btc$h.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const nt=o.get(rt);if(nt==null){const ot=tt.encode(et).slice(1);return o.set(rt,ot),ot}else return nt}function toStringV1$2(et,o,tt){const{prefix:rt}=tt,nt=o.get(rt);if(nt==null){const ot=tt.encode(et);return o.set(rt,ot),ot}else return nt}const DAG_PB_CODE$2=112,SHA_256_CODE$2=18;function encodeCID$2(et,o,tt){const rt=encodingLength$4(et),nt=rt+encodingLength$4(o),ot=new Uint8Array(nt+tt.byteLength);return encodeTo$2(et,ot,0),encodeTo$2(o,ot,rt),ot.set(tt,nt),ot}const cidSymbol$2=Symbol.for("@ipld/js-cid/CID"),code$2=0,name$4="identity",encode$E=coerce$i;function digest$1(et){return create$5(code$2,encode$E(et))}const identity$f={code:code$2,name:name$4,encode:encode$E,digest:digest$1};function equals$9(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;ttBigInt(et))),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends HashMD{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(){const{Ah:o,Al:tt,Bh:rt,Bl:nt,Ch:ot,Cl:it,Dh:st,Dl:at,Eh:ct,El:lt,Fh:dt,Fl:ht,Gh:mt,Gl:ft,Hh:pt,Hl:gt}=this;return[o,tt,rt,nt,ot,it,st,at,ct,lt,dt,ht,mt,ft,pt,gt]}set(o,tt,rt,nt,ot,it,st,at,ct,lt,dt,ht,mt,ft,pt,gt){this.Ah=o|0,this.Al=tt|0,this.Bh=rt|0,this.Bl=nt|0,this.Ch=ot|0,this.Cl=it|0,this.Dh=st|0,this.Dl=at|0,this.Eh=ct|0,this.El=lt|0,this.Fh=dt|0,this.Fl=ht|0,this.Gh=mt|0,this.Gl=ft|0,this.Hh=pt|0,this.Hl=gt|0}process(o,tt){for(let xt=0;xt<16;xt++,tt+=4)SHA512_W_H[xt]=o.getUint32(tt),SHA512_W_L[xt]=o.getUint32(tt+=4);for(let xt=16;xt<80;xt++){const vt=SHA512_W_H[xt-15]|0,Et=SHA512_W_L[xt-15]|0,Ct=u64.rotrSH(vt,Et,1)^u64.rotrSH(vt,Et,8)^u64.shrSH(vt,Et,7),St=u64.rotrSL(vt,Et,1)^u64.rotrSL(vt,Et,8)^u64.shrSL(vt,Et,7),At=SHA512_W_H[xt-2]|0,kt=SHA512_W_L[xt-2]|0,It=u64.rotrSH(At,kt,19)^u64.rotrBH(At,kt,61)^u64.shrSH(At,kt,6),Ot=u64.rotrSL(At,kt,19)^u64.rotrBL(At,kt,61)^u64.shrSL(At,kt,6),Nt=u64.add4L(St,Ot,SHA512_W_L[xt-7],SHA512_W_L[xt-16]),Yt=u64.add4H(Nt,Ct,It,SHA512_W_H[xt-7],SHA512_W_H[xt-16]);SHA512_W_H[xt]=Yt|0,SHA512_W_L[xt]=Nt|0}let{Ah:rt,Al:nt,Bh:ot,Bl:it,Ch:st,Cl:at,Dh:ct,Dl:lt,Eh:dt,El:ht,Fh:mt,Fl:ft,Gh:pt,Gl:gt,Hh:yt,Hl:bt}=this;for(let xt=0;xt<80;xt++){const vt=u64.rotrSH(dt,ht,14)^u64.rotrSH(dt,ht,18)^u64.rotrBH(dt,ht,41),Et=u64.rotrSL(dt,ht,14)^u64.rotrSL(dt,ht,18)^u64.rotrBL(dt,ht,41),Ct=dt&mt^~dt&pt,St=ht&ft^~ht>,At=u64.add5L(bt,Et,St,SHA512_Kl[xt],SHA512_W_L[xt]),kt=u64.add5H(At,yt,vt,Ct,SHA512_Kh[xt],SHA512_W_H[xt]),It=At|0,Ot=u64.rotrSH(rt,nt,28)^u64.rotrBH(rt,nt,34)^u64.rotrBH(rt,nt,39),Nt=u64.rotrSL(rt,nt,28)^u64.rotrBL(rt,nt,34)^u64.rotrBL(rt,nt,39),Yt=rt&ot^rt&st^ot&st,Ft=nt&it^nt&at^it&at;yt=pt|0,bt=gt|0,pt=mt|0,gt=ft|0,mt=dt|0,ft=ht|0,{h:dt,l:ht}=u64.add(ct|0,lt|0,kt|0,It|0),ct=st|0,lt=at|0,st=ot|0,at=it|0,ot=rt|0,it=nt|0;const Ht=u64.add3L(It,Nt,Ft);rt=u64.add3H(Ht,kt,Ot,Yt),nt=Ht|0}({h:rt,l:nt}=u64.add(this.Ah|0,this.Al|0,rt|0,nt|0)),{h:ot,l:it}=u64.add(this.Bh|0,this.Bl|0,ot|0,it|0),{h:st,l:at}=u64.add(this.Ch|0,this.Cl|0,st|0,at|0),{h:ct,l:lt}=u64.add(this.Dh|0,this.Dl|0,ct|0,lt|0),{h:dt,l:ht}=u64.add(this.Eh|0,this.El|0,dt|0,ht|0),{h:mt,l:ft}=u64.add(this.Fh|0,this.Fl|0,mt|0,ft|0),{h:pt,l:gt}=u64.add(this.Gh|0,this.Gl|0,pt|0,gt|0),{h:yt,l:bt}=u64.add(this.Hh|0,this.Hl|0,yt|0,bt|0),this.set(rt,nt,ot,it,st,at,ct,lt,dt,ht,mt,ft,pt,gt,yt,bt)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.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)}}const sha512=wrapConstructor(()=>new SHA512);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$3=BigInt(1),_2n$2=BigInt(2),_8n$2=BigInt(8),VERIFY_DEFAULT={zip215:!0};function validateOpts$1(et){const o=validateBasic(et);return validateObject(et,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...o})}function twistedEdwards(et){const o=validateOpts$1(et),{Fp:tt,n:rt,prehash:nt,hash:ot,randomBytes:it,nByteLength:st,h:at}=o,ct=_2n$2<{try{return{isValid:!0,value:tt.sqrt(Qt*tt.inv(Vt))}}catch{return{isValid:!1,value:_0n$2}}}),mt=o.adjustScalarBytes||(Qt=>Qt),ft=o.domain||((Qt,Vt,Bt)=>{if(abool("phflag",Bt),Vt.length||Bt)throw new Error("Contexts/pre-hash are not supported");return Qt});function pt(Qt,Vt){aInRange("coordinate "+Qt,Vt,_0n$2,ct)}function gt(Qt){if(!(Qt instanceof xt))throw new Error("ExtendedPoint expected")}const yt=memoized((Qt,Vt)=>{const{ex:Bt,ey:Wt,ez:jt}=Qt,Xt=Qt.is0();Vt==null&&(Vt=Xt?_8n$2:tt.inv(jt));const Kt=lt(Bt*Vt),Pt=lt(Wt*Vt),Gt=lt(jt*Vt);if(Xt)return{x:_0n$2,y:_1n$3};if(Gt!==_1n$3)throw new Error("invZ was invalid");return{x:Kt,y:Pt}}),bt=memoized(Qt=>{const{a:Vt,d:Bt}=o;if(Qt.is0())throw new Error("bad point: ZERO");const{ex:Wt,ey:jt,ez:Xt,et:Kt}=Qt,Pt=lt(Wt*Wt),Gt=lt(jt*jt),tr=lt(Xt*Xt),zt=lt(tr*tr),lr=lt(Pt*Vt),rr=lt(tr*lt(lr+Gt)),Jt=lt(zt+lt(Bt*lt(Pt*Gt)));if(rr!==Jt)throw new Error("bad point: equation left != right (1)");const Rt=lt(Wt*jt),Mt=lt(Xt*Kt);if(Rt!==Mt)throw new Error("bad point: equation left != right (2)");return!0});class xt{constructor(Vt,Bt,Wt,jt){this.ex=Vt,this.ey=Bt,this.ez=Wt,this.et=jt,pt("x",Vt),pt("y",Bt),pt("z",Wt),pt("t",jt),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(Vt){if(Vt instanceof xt)throw new Error("extended point not allowed");const{x:Bt,y:Wt}=Vt||{};return pt("x",Bt),pt("y",Wt),new xt(Bt,Wt,_1n$3,lt(Bt*Wt))}static normalizeZ(Vt){const Bt=tt.invertBatch(Vt.map(Wt=>Wt.ez));return Vt.map((Wt,jt)=>Wt.toAffine(Bt[jt])).map(xt.fromAffine)}static msm(Vt,Bt){return pippenger(xt,dt,Vt,Bt)}_setWindowSize(Vt){Ct.setWindowSize(this,Vt)}assertValidity(){bt(this)}equals(Vt){gt(Vt);const{ex:Bt,ey:Wt,ez:jt}=this,{ex:Xt,ey:Kt,ez:Pt}=Vt,Gt=lt(Bt*Pt),tr=lt(Xt*jt),zt=lt(Wt*Pt),lr=lt(Kt*jt);return Gt===tr&&zt===lr}is0(){return this.equals(xt.ZERO)}negate(){return new xt(lt(-this.ex),this.ey,this.ez,lt(-this.et))}double(){const{a:Vt}=o,{ex:Bt,ey:Wt,ez:jt}=this,Xt=lt(Bt*Bt),Kt=lt(Wt*Wt),Pt=lt(_2n$2*lt(jt*jt)),Gt=lt(Vt*Xt),tr=Bt+Wt,zt=lt(lt(tr*tr)-Xt-Kt),lr=Gt+Kt,rr=lr-Pt,Jt=Gt-Kt,Rt=lt(zt*rr),Mt=lt(lr*Jt),Ut=lt(zt*Jt),Zt=lt(rr*lr);return new xt(Rt,Mt,Zt,Ut)}add(Vt){gt(Vt);const{a:Bt,d:Wt}=o,{ex:jt,ey:Xt,ez:Kt,et:Pt}=this,{ex:Gt,ey:tr,ez:zt,et:lr}=Vt;if(Bt===BigInt(-1)){const gr=lt((Xt-jt)*(tr+Gt)),Pr=lt((Xt+jt)*(tr-Gt)),_r=lt(Pr-gr);if(_r===_0n$2)return this.double();const Rr=lt(Kt*_2n$2*lr),mr=lt(Pt*_2n$2*zt),wr=mr+Rr,ir=Pr+gr,Tt=mr-Rr,$t=lt(wr*_r),_t=lt(ir*Tt),Dt=lt(wr*Tt),qt=lt(_r*ir);return new xt($t,_t,qt,Dt)}const rr=lt(jt*Gt),Jt=lt(Xt*tr),Rt=lt(Pt*Wt*lr),Mt=lt(Kt*zt),Ut=lt((jt+Xt)*(Gt+tr)-rr-Jt),Zt=Mt-Rt,nr=Mt+Rt,ar=lt(Jt-Bt*rr),dr=lt(Ut*Zt),cr=lt(nr*ar),yr=lt(Ut*ar),pr=lt(Zt*nr);return new xt(dr,cr,pr,yr)}subtract(Vt){return this.add(Vt.negate())}wNAF(Vt){return Ct.wNAFCached(this,Vt,xt.normalizeZ)}multiply(Vt){const Bt=Vt;aInRange("scalar",Bt,_1n$3,rt);const{p:Wt,f:jt}=this.wNAF(Bt);return xt.normalizeZ([Wt,jt])[0]}multiplyUnsafe(Vt){const Bt=Vt;return aInRange("scalar",Bt,_0n$2,rt),Bt===_0n$2?Et:this.equals(Et)||Bt===_1n$3?this:this.equals(vt)?this.wNAF(Bt).p:Ct.unsafeLadder(this,Bt)}isSmallOrder(){return this.multiplyUnsafe(at).is0()}isTorsionFree(){return Ct.unsafeLadder(this,rt).is0()}toAffine(Vt){return yt(this,Vt)}clearCofactor(){const{h:Vt}=o;return Vt===_1n$3?this:this.multiplyUnsafe(Vt)}static fromHex(Vt,Bt=!1){const{d:Wt,a:jt}=o,Xt=tt.BYTES;Vt=ensureBytes$1("pointHex",Vt,Xt),abool("zip215",Bt);const Kt=Vt.slice(),Pt=Vt[Xt-1];Kt[Xt-1]=Pt&-129;const Gt=bytesToNumberLE(Kt),tr=Bt?ct:tt.ORDER;aInRange("pointHex.y",Gt,_0n$2,tr);const zt=lt(Gt*Gt),lr=lt(zt-_1n$3),rr=lt(Wt*zt-jt);let{isValid:Jt,value:Rt}=ht(lr,rr);if(!Jt)throw new Error("Point.fromHex: invalid y coordinate");const Mt=(Rt&_1n$3)===_1n$3,Ut=(Pt&128)!==0;if(!Bt&&Rt===_0n$2&&Ut)throw new Error("Point.fromHex: x=0 and x_0=1");return Ut!==Mt&&(Rt=lt(-Rt)),xt.fromAffine({x:Rt,y:Gt})}static fromPrivateKey(Vt){return kt(Vt).point}toRawBytes(){const{x:Vt,y:Bt}=this.toAffine(),Wt=numberToBytesLE(Bt,tt.BYTES);return Wt[Wt.length-1]|=Vt&_1n$3?128:0,Wt}toHex(){return bytesToHex$2(this.toRawBytes())}}xt.BASE=new xt(o.Gx,o.Gy,_1n$3,lt(o.Gx*o.Gy)),xt.ZERO=new xt(_0n$2,_1n$3,_1n$3,_0n$2);const{BASE:vt,ZERO:Et}=xt,Ct=wNAF(xt,st*8);function St(Qt){return mod$1(Qt,rt)}function At(Qt){return St(bytesToNumberLE(Qt))}function kt(Qt){const Vt=st;Qt=ensureBytes$1("private key",Qt,Vt);const Bt=ensureBytes$1("hashed private key",ot(Qt),2*Vt),Wt=mt(Bt.slice(0,Vt)),jt=Bt.slice(Vt,2*Vt),Xt=At(Wt),Kt=vt.multiply(Xt),Pt=Kt.toRawBytes();return{head:Wt,prefix:jt,scalar:Xt,point:Kt,pointBytes:Pt}}function It(Qt){return kt(Qt).pointBytes}function Ot(Qt=new Uint8Array,...Vt){const Bt=concatBytes$1(...Vt);return At(ot(ft(Bt,ensureBytes$1("context",Qt),!!nt)))}function Nt(Qt,Vt,Bt={}){Qt=ensureBytes$1("message",Qt),nt&&(Qt=nt(Qt));const{prefix:Wt,scalar:jt,pointBytes:Xt}=kt(Vt),Kt=Ot(Bt.context,Wt,Qt),Pt=vt.multiply(Kt).toRawBytes(),Gt=Ot(Bt.context,Pt,Xt,Qt),tr=St(Kt+Gt*jt);aInRange("signature.s",tr,_0n$2,rt);const zt=concatBytes$1(Pt,numberToBytesLE(tr,tt.BYTES));return ensureBytes$1("result",zt,st*2)}const Yt=VERIFY_DEFAULT;function Ft(Qt,Vt,Bt,Wt=Yt){const{context:jt,zip215:Xt}=Wt,Kt=tt.BYTES;Qt=ensureBytes$1("signature",Qt,2*Kt),Vt=ensureBytes$1("message",Vt),Xt!==void 0&&abool("zip215",Xt),nt&&(Vt=nt(Vt));const Pt=bytesToNumberLE(Qt.slice(Kt,2*Kt));let Gt,tr,zt;try{Gt=xt.fromHex(Bt,Xt),tr=xt.fromHex(Qt.slice(0,Kt),Xt),zt=vt.multiplyUnsafe(Pt)}catch{return!1}if(!Xt&&Gt.isSmallOrder())return!1;const lr=Ot(jt,tr.toRawBytes(),Gt.toRawBytes(),Vt);return tr.add(Gt.multiplyUnsafe(lr)).subtract(zt).clearCofactor().equals(xt.ZERO)}return vt._setWindowSize(8),{CURVE:o,getPublicKey:It,sign:Nt,verify:Ft,ExtendedPoint:xt,utils:{getExtendedPublicKey:kt,randomPrivateKey:()=>it(tt.BYTES),precompute(Qt=8,Vt=xt.BASE){return Vt._setWindowSize(Qt),Vt.multiply(BigInt(3)),Vt}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$2=BigInt(1);function validateOpts(et){return validateObject(et,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...et})}function montgomery(et){const o=validateOpts(et),{P:tt}=o,rt=bt=>mod$1(bt,tt),nt=o.montgomeryBits,ot=Math.ceil(nt/8),it=o.nByteLength,st=o.adjustScalarBytes||(bt=>bt),at=o.powPminus2||(bt=>pow(bt,tt-BigInt(2),tt));function ct(bt,xt,vt){const Et=rt(bt*(xt-vt));return xt=rt(xt-Et),vt=rt(vt+Et),[xt,vt]}const lt=(o.a-BigInt(2))/BigInt(4);function dt(bt,xt){aInRange("u",bt,_0n$1,tt),aInRange("scalar",xt,_0n$1,tt);const vt=xt,Et=bt;let Ct=_1n$2,St=_0n$1,At=bt,kt=_1n$2,It=_0n$1,Ot;for(let Yt=BigInt(nt-1);Yt>=_0n$1;Yt--){const Ft=vt>>Yt&_1n$2;It^=Ft,Ot=ct(It,Ct,At),Ct=Ot[0],At=Ot[1],Ot=ct(It,St,kt),St=Ot[0],kt=Ot[1],It=Ft;const Ht=Ct+St,Qt=rt(Ht*Ht),Vt=Ct-St,Bt=rt(Vt*Vt),Wt=Qt-Bt,jt=At+kt,Xt=At-kt,Kt=rt(Xt*Ht),Pt=rt(jt*Vt),Gt=Kt+Pt,tr=Kt-Pt;At=rt(Gt*Gt),kt=rt(Et*rt(tr*tr)),Ct=rt(Qt*Bt),St=rt(Wt*(Qt+rt(lt*Wt)))}Ot=ct(It,Ct,At),Ct=Ot[0],At=Ot[1],Ot=ct(It,St,kt),St=Ot[0],kt=Ot[1];const Nt=at(St);return rt(Ct*Nt)}function ht(bt){return numberToBytesLE(rt(bt),ot)}function mt(bt){const xt=ensureBytes$1("u coordinate",bt,ot);return it===32&&(xt[31]&=127),bytesToNumberLE(xt)}function ft(bt){const xt=ensureBytes$1("scalar",bt),vt=xt.length;if(vt!==ot&&vt!==it)throw new Error(`Expected ${ot} or ${it} bytes, got ${vt}`);return bytesToNumberLE(st(xt))}function pt(bt,xt){const vt=mt(xt),Et=ft(bt),Ct=dt(vt,Et);if(Ct===_0n$1)throw new Error("Invalid private or public key received");return ht(Ct)}const gt=ht(o.Gu);function yt(bt){return pt(bt,gt)}return{scalarMult:pt,scalarMultBase:yt,getSharedSecret:(bt,xt)=>pt(bt,xt),getPublicKey:bt=>yt(bt),utils:{randomPrivateKey:()=>o.randomBytes(o.nByteLength)},GuBytes:gt}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ED25519_P=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _1n$1=BigInt(1),_2n$1=BigInt(2),_3n$1=BigInt(3),_5n=BigInt(5),_8n$1=BigInt(8);function ed25519_pow_2_252_3(et){const o=BigInt(10),tt=BigInt(20),rt=BigInt(40),nt=BigInt(80),ot=ED25519_P,st=et*et%ot*et%ot,at=pow2$1(st,_2n$1,ot)*st%ot,ct=pow2$1(at,_1n$1,ot)*et%ot,lt=pow2$1(ct,_5n,ot)*ct%ot,dt=pow2$1(lt,o,ot)*lt%ot,ht=pow2$1(dt,tt,ot)*dt%ot,mt=pow2$1(ht,rt,ot)*ht%ot,ft=pow2$1(mt,nt,ot)*mt%ot,pt=pow2$1(ft,nt,ot)*mt%ot,gt=pow2$1(pt,o,ot)*lt%ot;return{pow_p_5_8:pow2$1(gt,_2n$1,ot)*et%ot,b2:st}}function adjustScalarBytes(et){return et[0]&=248,et[31]&=127,et[31]|=64,et}function uvRatio(et,o){const tt=ED25519_P,rt=mod$1(o*o*o,tt),nt=mod$1(rt*rt*o,tt),ot=ed25519_pow_2_252_3(et*nt).pow_p_5_8;let it=mod$1(et*rt*ot,tt);const st=mod$1(o*it*it,tt),at=it,ct=mod$1(it*ED25519_SQRT_M1,tt),lt=st===et,dt=st===mod$1(-et,tt),ht=st===mod$1(-et*ED25519_SQRT_M1,tt);return lt&&(it=at),(dt||ht)&&(it=ct),isNegativeLE(it,tt)&&(it=mod$1(-it,tt)),{isValid:lt||dt,value:it}}const Fp=Field$1(ED25519_P,void 0,!0),ed25519Defaults={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_8n$1,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sha512,randomBytes:randomBytes$1,adjustScalarBytes,uvRatio},ed25519=twistedEdwards(ed25519Defaults),x25519=montgomery({P:ED25519_P,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:et=>{const o=ED25519_P,{pow_p_5_8:tt,b2:rt}=ed25519_pow_2_252_3(et);return mod$1(pow2$1(tt,_3n$1,o)*rt,o)},adjustScalarBytes,randomBytes:randomBytes$1}),PUBLIC_KEY_BYTE_LENGTH=32,PRIVATE_KEY_BYTE_LENGTH=64,KEYS_BYTE_LENGTH=32;function generateKey(){const et=ed25519.utils.randomPrivateKey(),o=ed25519.getPublicKey(et);return{privateKey:concatKeys(et,o),publicKey:o}}function hashAndSign(et,o){const tt=et.subarray(0,KEYS_BYTE_LENGTH);return ed25519.sign(o instanceof Uint8Array?o:o.subarray(),tt)}function hashAndVerify$2(et,o,tt){return ed25519.verify(o,tt instanceof Uint8Array?tt:tt.subarray(),et)}function concatKeys(et,o){const tt=new Uint8Array(PRIVATE_KEY_BYTE_LENGTH);for(let rt=0;rtenumeration(__KeyTypeValues)})(KeyType||(KeyType={}));var PublicKey;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.Type!=null&&(rt.uint32(8),KeyType.codec().encode(tt.Type,rt)),tt.Data!=null&&(rt.uint32(18),rt.bytes(tt.Data)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.Type=KeyType.codec().decode(tt);break}case 2:{ot.Data=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PublicKey||(PublicKey={}));var PrivateKey;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.Type!=null&&(rt.uint32(8),KeyType.codec().encode(tt.Type,rt)),tt.Data!=null&&(rt.uint32(18),rt.bytes(tt.Data)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.Type=KeyType.codec().decode(tt);break}case 2:{ot.Data=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PrivateKey||(PrivateKey={}));/*! + Not dialing.`),!1}return await this.isPeerDialableBasedOnBootstrapStatus(tt)?this.dialAttemptsForPeer.has(tt.toString())?(log$j.warn(`Peer ${tt.toString()} has already been attempted dial before, or already has a dial attempt in progress, skipping dial`),!1):!0:(log$j.warn(`Peer ${tt.toString()} is not dialable based on bootstrap status. Not dialing.`),!1)}async isPeerDialableBasedOnBootstrapStatus(tt){return(await this.getTagNamesForPeer(tt)).some(it=>it===Tags.BOOTSTRAP)?this.libp2p.getConnections().filter(it=>it.tags.find(st=>st===Tags.BOOTSTRAP)).lengththis.configuredPubsubTopics.includes(it)):!0}async getPeerShardInfo(tt,rt){const ot=(await rt.get(tt)).metadata.get("shardInfo");if(ot)return decodeRelayShard(ot)}startNetworkStatusListener(){try{globalThis.addEventListener("online",this.onEventHandlers["browser:network"]),globalThis.addEventListener("offline",this.onEventHandlers["browser:network"])}catch(tt){log$j.error(`Failed to start network listener: ${tt}`)}}stopNetworkStatusListener(){try{globalThis.removeEventListener("online",this.onEventHandlers["browser:network"]),globalThis.removeEventListener("offline",this.onEventHandlers["browser:network"])}catch(tt){log$j.error(`Failed to stop network listener: ${tt}`)}}setP2PNetworkConnected(){this.isP2PNetworkConnected||(this.isP2PNetworkConnected=!0,this.dispatchWakuConnectionEvent())}setP2PNetworkDisconnected(){this.isP2PNetworkConnected&&this.libp2p.getConnections().length===0&&(this.isP2PNetworkConnected=!1,this.dispatchWakuConnectionEvent())}dispatchWakuConnectionEvent(){this.dispatchEvent(new CustomEvent(EConnectionStateEvents.CONNECTION_STATUS,{detail:this.isConnected()}))}};wt(Nn,"instances",new Map);let ConnectionManager=Nn;const An=class An{constructor(){wt(this,"health");this.health={overallStatus:HealthStatus.Unhealthy,protocolStatuses:new Map}}static getInstance(){return An.instance||(An.instance=new An),An.instance}getHealthStatus(){return this.health.overallStatus}getProtocolStatus(o){return this.health.protocolStatuses.get(o)}updateProtocolHealth(o,tt){const rt=this.getNameFromMulticodec(o);let nt=HealthStatus.Unhealthy;tt==1?nt=HealthStatus.MinimallyHealthy:tt>=2&&(nt=HealthStatus.SufficientlyHealthy),this.health.protocolStatuses.set(rt,{name:rt,status:nt,lastUpdate:new Date}),this.updateOverallHealth()}getNameFromMulticodec(o){let tt;if(o.includes("filter"))tt=Protocols.Filter;else if(o.includes("lightpush"))tt=Protocols.LightPush;else if(o.includes("store"))tt=Protocols.Store;else throw new Error(`Unknown protocol: ${o}`);return tt}updateOverallHealth(){const tt=[Protocols.LightPush,Protocols.Filter].map(rt=>{var nt;return(nt=this.getProtocolStatus(rt))==null?void 0:nt.status});tt.some(rt=>rt===HealthStatus.Unhealthy)?this.health.overallStatus=HealthStatus.Unhealthy:tt.some(rt=>rt===HealthStatus.MinimallyHealthy)?this.health.overallStatus=HealthStatus.MinimallyHealthy:this.health.overallStatus=HealthStatus.SufficientlyHealthy}};wt(An,"instance");let HealthManager=An;const getHealthManager=()=>HealthManager.getInstance(),log$i=new Logger$1("metadata"),MetadataCodec="/vac/waku/metadata/1.0.0";class Metadata extends BaseProtocol{constructor(tt,rt){super(MetadataCodec,rt.components,log$i,tt);wt(this,"pubsubTopics");wt(this,"libp2pComponents");wt(this,"handshakesConfirmed",new Map);this.pubsubTopics=tt,this.libp2pComponents=rt,rt.registrar.handle(MetadataCodec,nt=>{this.onRequest(nt)})}async query(tt){const rt=WakuMetadataRequest.encode(pubsubTopicsToShardInfo(this.pubsubTopics)),nt=await this.libp2pComponents.peerStore.get(tt);if(!nt)return{shardInfo:null,error:ProtocolError$1.NO_PEER_AVAILABLE};let ot;try{ot=await this.getStream(nt)}catch(ct){return log$i.error("Failed to get stream",ct),{shardInfo:null,error:ProtocolError$1.NO_STREAM_AVAILABLE}}const it=await pipe([rt],encode$K,ot,decode$U,async ct=>await all$2(ct)),{error:st,shardInfo:at}=this.decodeMetadataResponse(it);return st?{shardInfo:null,error:st}:(await this.savePeerShardInfo(tt,at),{shardInfo:at,error:null})}async confirmOrAttemptHandshake(tt){const rt=this.handshakesConfirmed.get(tt.toString());return rt?{shardInfo:rt,error:null}:await this.query(tt)}async onRequest(tt){try{const{stream:rt,connection:nt}=tt,ot=WakuMetadataResponse.encode(pubsubTopicsToShardInfo(this.pubsubTopics)),it=await pipe([ot],encode$K,rt,decode$U,async ct=>await all$2(ct)),{error:st,shardInfo:at}=this.decodeMetadataResponse(it);if(st)return;await this.savePeerShardInfo(nt.remotePeer,at)}catch(rt){log$i.error("Error handling metadata request",rt)}}decodeMetadataResponse(tt){const rt=new Uint8ArrayList;tt.forEach(ot=>{rt.append(ot)});const nt=WakuMetadataResponse.decode(rt);return nt?{shardInfo:nt,error:null}:(log$i.error("Error decoding metadata response"),{shardInfo:null,error:ProtocolError$1.DECODE_FAILED})}async savePeerShardInfo(tt,rt){await this.libp2pComponents.peerStore.merge(tt,{metadata:{shardInfo:encodeRelayShard(rt)}}),this.handshakesConfirmed.set(tt.toString(),rt)}}function wakuMetadata(et){return o=>new Metadata(et,o)}function equals$e(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$j=base$j,_brrp__multiformats_scope_baseX$i=src$j;let Encoder$j=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$j=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$k(this,o)}},ComposedDecoder$i=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$k(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$k(et,o){return new ComposedDecoder$i({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$i=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$j(o,tt,rt),this.decoder=new Decoder$j(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$l({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$i(et,o,tt,rt)}function baseX$i({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$i(tt,et);return from$l({prefix:o,name:et,encode:rt,decode:ot=>coerce$i(nt(ot))})}function decode$T(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$J(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<=INT$5;)o[tt++]=et&255|MSB$7,et/=128;for(;et&MSBALL$5;)o[tt++]=et&255|MSB$7,et>>>=7;return o[tt]=et|0,encode$I.bytes=tt-rt+1,o}var decode$S=read$6,MSB$1$5=128,REST$1$5=127;function read$6(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$6.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$5)<=MSB$1$5);return read$6.bytes=ot-rt,tt}var N1$5=Math.pow(2,7),N2$5=Math.pow(2,14),N3$5=Math.pow(2,21),N4$5=Math.pow(2,28),N5$5=Math.pow(2,35),N6$5=Math.pow(2,42),N7$5=Math.pow(2,49),N8$5=Math.pow(2,56),N9$5=Math.pow(2,63),length$5=function(et){return et{const[dt,ht]=decode$R(o.subarray(tt));return tt+=ht,dt};let nt=rt(),ot=DAG_PB_CODE$3;if(nt===18?(nt=0,tt=0):ot=rt(),nt!==0&&nt!==1)throw new RangeError(`Invalid CID version ${nt}`);const it=tt,st=rt(),at=rt(),ct=tt+at,lt=ct-it;return{version:nt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(o,tt){const[rt,nt]=parseCIDtoBytes$3(o,tt),ot=jr.decode(nt);if(ot.version===0&&o[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache$3(ot).set(rt,o),ot}};function parseCIDtoBytes$3(et,o){switch(et[0]){case"Q":{const tt=o??base58btc$i;return[base58btc$i.prefix,tt.decode(`${base58btc$i.prefix}${et}`)]}case base58btc$i.prefix:{const tt=o??base58btc$i;return[base58btc$i.prefix,tt.decode(et)]}case base32$w.prefix:{const tt=o??base32$w;return[base32$w.prefix,tt.decode(et)]}case base36$t.prefix:{const tt=o??base36$t;return[base36$t.prefix,tt.decode(et)]}default:{if(o==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[et[0],o.decode(et)]}}}function toStringV0$3(et,o,tt){const{prefix:rt}=tt;if(rt!==base58btc$i.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const nt=o.get(rt);if(nt==null){const ot=tt.encode(et).slice(1);return o.set(rt,ot),ot}else return nt}function toStringV1$3(et,o,tt){const{prefix:rt}=tt,nt=o.get(rt);if(nt==null){const ot=tt.encode(et);return o.set(rt,ot),ot}else return nt}const DAG_PB_CODE$3=112,SHA_256_CODE$3=18;function encodeCID$3(et,o,tt){const rt=encodingLength$5(et),nt=rt+encodingLength$5(o),ot=new Uint8Array(nt+tt.byteLength);return encodeTo$3(et,ot,0),encodeTo$3(o,ot,rt),ot.set(tt,nt),ot}const cidSymbol$3=Symbol.for("@ipld/js-cid/CID");function equals$c(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt(et[tt]=o,et),[]),alphabetCharsToBytes$e=alphabet$e.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$H(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$e[tt],o),"")}function decode$P(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$e[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$s=from$l({prefix:"🚀",name:"base256emoji",encode:encode$H,decode:decode$P}),base256emoji$t=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$s},Symbol.toStringTag,{value:"Module"})),base64$v=rfc4648$h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$e=rfc4648$h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$f=rfc4648$h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$e=rfc4648$h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$w=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$v,base64pad:base64pad$e,base64url:base64url$f,base64urlpad:base64urlpad$e},Symbol.toStringTag,{value:"Module"})),base8$s=rfc4648$h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$t=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$s},Symbol.toStringTag,{value:"Module"})),identity$g=from$l({prefix:"\0",name:"identity",encode:et=>toString$u(et),decode:et=>fromString$s(et)}),identityBase$e=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$g},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$e={...identityBase$e,...base2$t,...base8$t,...base10$t,...base16$t,...base32$x,...base36$u,...base58$e,...base64$w,...base256emoji$t};function allocUnsafe$d(et=0){return new Uint8Array(et)}function createCodec$e(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$i=createCodec$e("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$e=createCodec$e("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$d(et.length);for(let tt=0;ttnt+ot.length,0));const tt=allocUnsafe$d(o);let rt=0;for(const nt of et)tt.set(nt,rt),rt+=nt.length;return tt}class Parser{constructor(){wt(this,"index",0);wt(this,"input","")}new(o){return this.index=0,this.input=o,this}readAtomically(o){const tt=this.index,rt=o();return rt===void 0&&(this.index=tt),rt}parseWith(o){const tt=o();if(this.index===this.input.length)return tt}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(()=>{const tt=this.readChar();if(tt===o)return tt})}readSeparator(o,tt,rt){return this.readAtomically(()=>{if(!(tt>0&&this.readGivenChar(o)===void 0))return rt()})}readNumber(o,tt,rt,nt){return this.readAtomically(()=>{let ot=0,it=0;const st=this.peekChar();if(st===void 0)return;const at=st==="0",ct=2**(8*nt)-1;for(;;){const lt=this.readAtomically(()=>{const dt=this.readChar();if(dt===void 0)return;const ht=Number.parseInt(dt,o);if(!Number.isNaN(ht))return ht});if(lt===void 0)break;if(ot*=o,ot+=lt,ot>ct||(it+=1,tt!==void 0&&it>tt))return}if(it!==0)return!rt&&at&&it>1?void 0:ot})}readIPv4Addr(){return this.readAtomically(()=>{const o=new Uint8Array(4);for(let tt=0;ttthis.readNumber(10,3,!1,1));if(rt===void 0)return;o[tt]=rt}return o})}readIPv6Addr(){const o=tt=>{for(let rt=0;rtthis.readIPv4Addr());if(it!==void 0)return tt[nt]=it[0],tt[nt+1]=it[1],tt[nt+2]=it[2],tt[nt+3]=it[3],[nt+4,!0]}const ot=this.readSeparator(":",rt,()=>this.readNumber(16,4,!0,2));if(ot===void 0)return[nt,!1];tt[nt]=ot>>8,tt[nt+1]=ot&255}return[tt.length,!1]};return this.readAtomically(()=>{const tt=new Uint8Array(16),[rt,nt]=o(tt);if(rt===16)return tt;if(nt||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;const ot=new Uint8Array(14),it=16-(rt+2),[st]=o(ot.subarray(0,it));return tt.set(ot.subarray(0,st),16-st),tt})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}}const MAX_IPV6_LENGTH=45,MAX_IPV4_LENGTH=15,parser=new Parser;function parseIPv4(et){if(!(et.length>MAX_IPV4_LENGTH))return parser.new(et).parseWith(()=>parser.readIPv4Addr())}function parseIPv6(et){if(et.includes("%")&&(et=et.split("%")[0]),!(et.length>MAX_IPV6_LENGTH))return parser.new(et).parseWith(()=>parser.readIPv6Addr())}function parseIP(et){if(et.includes("%")&&(et=et.split("%")[0]),!(et.length>MAX_IPV6_LENGTH))return parser.new(et).parseWith(()=>parser.readIPAddr())}function fromString$r(et,o="utf8"){const tt=BASES$e[o];if(tt==null)throw new Error(`Unsupported encoding "${o}"`);return tt.decoder.decode(`${tt.prefix}${et}`)}function isIPv4(et){return!!parseIPv4(et)}function isIPv6(et){return!!parseIPv6(et)}function isIP(et){return!!parseIP(et)}const isV4=isIPv4,isV6=isIPv6,toBytes$1=function(et){let o=0;if(et=et.toString().trim(),isV4(et)){const tt=new Uint8Array(o+4);return et.split(/\./g).forEach(rt=>{tt[o++]=parseInt(rt,10)&255}),tt}if(isV6(et)){const tt=et.split(":",8);let rt;for(rt=0;rt0;rt--)ot.push("0");tt.splice.apply(tt,ot)}const nt=new Uint8Array(o+16);for(rt=0;rt>8&255,nt[o++]=ot&255}return nt}throw new Error("invalid ip address")},toString$s=function(et,o=0,tt){o=~~o,tt=tt??et.length-o;const rt=new DataView(et.buffer);if(tt===4){const nt=[];for(let ot=0;ot{const o=createProtocol(...et);codes[o.code]=o,names[o.name]=o});function createProtocol(et,o,tt,rt,nt){return{code:et,size:o,name:tt,resolvable:!!rt,path:!!nt}}function getProtocol(et){if(typeof et=="number"){if(codes[et]!=null)return codes[et];throw new Error(`no protocol with code: ${et}`)}else if(typeof et=="string"){if(names[et]!=null)return names[et];throw new Error(`no protocol with name: ${et}`)}throw new Error(`invalid protocol id type: ${typeof et}`)}getProtocol("ip4");getProtocol("ip6");getProtocol("ipcidr");function convertToString(et,o){switch(getProtocol(et).code){case 4:case 41:return bytes2ip(o);case 42:return bytes2str(o);case 6:case 273:case 33:case 132:return bytes2port(o).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bytes2str(o);case 421:return bytes2mh(o);case 444:return bytes2onion(o);case 445:return bytes2onion(o);case 466:return bytes2mb(o);case 481:return globalThis.encodeURIComponent(bytes2str(o));default:return toString$t(o,"base16")}}function convertToBytes(et,o){switch(getProtocol(et).code){case 4:return ip2bytes(o);case 41:return ip2bytes(o);case 42:return str2bytes(o);case 6:case 273:case 33:case 132:return port2bytes(parseInt(o,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return str2bytes(o);case 421:return mh2bytes(o);case 444:return onion2bytes(o);case 445:return onion32bytes(o);case 466:return mb2bytes(o);case 481:return str2bytes(globalThis.decodeURIComponent(o));default:return fromString$r(o,"base16")}}const decoders=Object.values(bases$e).map(et=>et.decoder),anybaseDecoder=function(){let et=decoders[0].or(decoders[1]);return decoders.slice(2).forEach(o=>et=et.or(o)),et}();function ip2bytes(et){if(!isIP(et))throw new Error("invalid ip address");return toBytes$1(et)}function bytes2ip(et){const o=toString$s(et,0,et.length);if(o==null)throw new Error("ipBuff is required");if(!isIP(o))throw new Error("invalid ip address");return o}function port2bytes(et){const o=new ArrayBuffer(2);return new DataView(o).setUint16(0,et),new Uint8Array(o)}function bytes2port(et){return new DataView(et.buffer).getUint16(et.byteOffset)}function str2bytes(et){const o=fromString$r(et),tt=Uint8Array.from(encode$P(o.length));return concat$3([tt,o],tt.length+o.length)}function bytes2str(et){const o=decode$Z(et);if(et=et.slice(encodingLength$6(o)),et.length!==o)throw new Error("inconsistent lengths");return toString$t(et)}function mh2bytes(et){let o;et[0]==="Q"||et[0]==="1"?o=decode$Q(base58btc$i.decode(`z${et}`)).bytes:o=CID$3.parse(et).multihash.bytes;const tt=Uint8Array.from(encode$P(o.length));return concat$3([tt,o],tt.length+o.length)}function mb2bytes(et){const o=anybaseDecoder.decode(et),tt=Uint8Array.from(encode$P(o.length));return concat$3([tt,o],tt.length+o.length)}function bytes2mb(et){const o=decode$Z(et),tt=et.slice(encodingLength$6(o));if(tt.length!==o)throw new Error("inconsistent lengths");return"u"+toString$t(tt,"base64url")}function bytes2mh(et){const o=decode$Z(et),tt=et.slice(encodingLength$6(o));if(tt.length!==o)throw new Error("inconsistent lengths");return toString$t(tt,"base58btc")}function onion2bytes(et){const o=et.split(":");if(o.length!==2)throw new Error(`failed to parse onion addr: ["'${o.join('", "')}'"]' does not contain a port number`);if(o[0].length!==16)throw new Error(`failed to parse onion addr: ${o[0]} not a Tor onion address.`);const tt=base32$w.decode("b"+o[0]),rt=parseInt(o[1],10);if(rt<1||rt>65536)throw new Error("Port number is not in range(1, 65536)");const nt=port2bytes(rt);return concat$3([tt,nt],tt.length+nt.length)}function onion32bytes(et){const o=et.split(":");if(o.length!==2)throw new Error(`failed to parse onion addr: ["'${o.join('", "')}'"]' does not contain a port number`);if(o[0].length!==56)throw new Error(`failed to parse onion addr: ${o[0]} not a Tor onion3 address.`);const tt=base32$w.decode(`b${o[0]}`),rt=parseInt(o[1],10);if(rt<1||rt>65536)throw new Error("Port number is not in range(1, 65536)");const nt=port2bytes(rt);return concat$3([tt,nt],tt.length+nt.length)}function bytes2onion(et){const o=et.slice(0,et.length-2),tt=et.slice(et.length-2),rt=toString$t(o,"base32"),nt=bytes2port(tt);return`${rt}:${nt}`}function stringToMultiaddrParts(et){et=cleanPath(et);const o=[],tt=[];let rt=null;const nt=et.split("/").slice(1);if(nt.length===1&&nt[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let ot=0;ot=nt.length)throw ParseError("invalid address: "+et);if(st.path===!0){rt=cleanPath(nt.slice(ot).join("/")),o.push([st.code,convertToBytes(st.code,rt)]),tt.push([st.code,rt]);break}const at=convertToBytes(st.code,nt[ot]);o.push([st.code,at]),tt.push([st.code,convertToString(st.code,at)])}return{string:stringTuplesToString(tt),bytes:tuplesToBytes(o),tuples:o,stringTuples:tt,path:rt}}function bytesToMultiaddrParts(et){const o=[],tt=[];let rt=null,nt=0;for(;ntet.length)throw ParseError("Invalid address Uint8Array: "+toString$t(et,"base16"));o.push([ot,ct]);const lt=convertToString(ot,ct);if(tt.push([ot,lt]),st.path===!0){rt=lt;break}}return{bytes:Uint8Array.from(et),string:stringTuplesToString(tt),tuples:o,stringTuples:tt,path:rt}}function stringTuplesToString(et){const o=[];return et.map(tt=>{const rt=getProtocol(tt[0]);return o.push(rt.name),tt.length>1&&tt[1]!=null&&o.push(tt[1]),null}),cleanPath(o.join("/"))}function tuplesToBytes(et){return concat$3(et.map(o=>{const tt=getProtocol(o[0]);let rt=Uint8Array.from(encode$P(tt.code));return o.length>1&&o[1]!=null&&(rt=concat$3([rt,o[1]])),rt}))}function sizeForAddr(et,o){if(et.size>0)return et.size/8;if(et.size===0)return 0;{const tt=decode$Z(o instanceof Uint8Array?o:Uint8Array.from(o));return tt+encodingLength$6(tt)}}function cleanPath(et){return"/"+et.trim().split("/").filter(o=>o).join("/")}function ParseError(et){return new Error("Error parsing address: "+et)}const inspect$1=Symbol.for("nodejs.util.inspect.custom"),symbol=Symbol.for("@multiformats/js-multiaddr/multiaddr"),DNS_CODES=[getProtocol("dns").code,getProtocol("dns4").code,getProtocol("dns6").code,getProtocol("dnsaddr").code];class NoAvailableResolverError extends Error{constructor(o="No available resolver"){super(o),this.name="NoAvailableResolverError"}}var ga,Yn,wn,lo,uo;const Dn=class Dn{constructor(o){wt(this,"bytes");fr(this,Yn);fr(this,wn);fr(this,lo);fr(this,uo);wt(this,ga,!0);o==null&&(o="");let tt;if(o instanceof Uint8Array)tt=bytesToMultiaddrParts(o);else if(typeof o=="string"){if(o.length>0&&o.charAt(0)!=="/")throw new Error(`multiaddr "${o}" must start with a "/"`);tt=stringToMultiaddrParts(o)}else if(isMultiaddr(o))tt=bytesToMultiaddrParts(o.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=tt.bytes,lr(this,Yn,tt.string),lr(this,wn,tt.tuples),lr(this,lo,tt.stringTuples),lr(this,uo,tt.path)}toString(){return Ot(this,Yn)}toJSON(){return this.toString()}toOptions(){let o,tt,rt,nt,ot="";const it=getProtocol("tcp"),st=getProtocol("udp"),at=getProtocol("ip4"),ct=getProtocol("ip6"),lt=getProtocol("dns6"),dt=getProtocol("ip6zone");for(const[mt,ft]of this.stringTuples())mt===dt.code&&(ot=`%${ft??""}`),DNS_CODES.includes(mt)&&(tt=it.name,nt=443,rt=`${ft??""}${ot}`,o=mt===lt.code?6:4),(mt===it.code||mt===st.code)&&(tt=getProtocol(mt).name,nt=parseInt(ft??"")),(mt===at.code||mt===ct.code)&&(tt=getProtocol(mt).name,rt=`${ft??""}${ot}`,o=mt===ct.code?6:4);if(o==null||tt==null||rt==null||nt==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:o,host:rt,transport:tt,port:nt}}protos(){return Ot(this,wn).map(([o])=>Object.assign({},getProtocol(o)))}protoCodes(){return Ot(this,wn).map(([o])=>o)}protoNames(){return Ot(this,wn).map(([o])=>getProtocol(o).name)}tuples(){return Ot(this,wn)}stringTuples(){return Ot(this,lo)}encapsulate(o){return o=new Dn(o),new Dn(this.toString()+o.toString())}decapsulate(o){const tt=o.toString(),rt=this.toString(),nt=rt.lastIndexOf(tt);if(nt<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${o.toString()}`);return new Dn(rt.slice(0,nt))}decapsulateCode(o){const tt=this.tuples();for(let rt=tt.length-1;rt>=0;rt--)if(tt[rt][0]===o)return new Dn(tuplesToBytes(tt.slice(0,rt)));return this}getPeerId(){try{let o=[];this.stringTuples().forEach(([rt,nt])=>{rt===names.p2p.code&&o.push([rt,nt]),rt===names["p2p-circuit"].code&&(o=[])});const tt=o.pop();if((tt==null?void 0:tt[1])!=null){const rt=tt[1];return rt[0]==="Q"||rt[0]==="1"?toString$t(base58btc$i.decode(`z${rt}`),"base58btc"):toString$t(CID$3.parse(rt).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return Ot(this,uo)}equals(o){return equals$c(this.bytes,o.bytes)}async resolve(o){const tt=this.protos().find(ot=>ot.resolvable);if(tt==null)return[this];const rt=resolvers$1.get(tt.name);if(rt==null)throw new NoAvailableResolverError(`no available resolver for ${tt.name}`);return(await rt(this,o)).map(ot=>multiaddr(ot))}nodeAddress(){const o=this.toOptions();if(o.transport!=="tcp"&&o.transport!=="udp")throw new 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){const tt=(o??this).protos();return!(tt.length!==2||tt[0].code!==4&&tt[0].code!==41||tt[1].code!==6&&tt[1].code!==273)}[(ga=symbol,inspect$1)](){return`Multiaddr(${Ot(this,Yn)})`}};Yn=new WeakMap,wn=new WeakMap,lo=new WeakMap,uo=new WeakMap;let Multiaddr=Dn;const resolvers$1=new Map;function isMultiaddr(et){return!!(et!=null&&et[symbol])}function multiaddr(et){return new Multiaddr(et)}const E_CANCELED=new Error("request for lock canceled");var __awaiter$2=function(et,o,tt,rt){function nt(ot){return ot instanceof tt?ot:new tt(function(it){it(ot)})}return new(tt||(tt=Promise))(function(ot,it){function st(lt){try{ct(rt.next(lt))}catch(dt){it(dt)}}function at(lt){try{ct(rt.throw(lt))}catch(dt){it(dt)}}function ct(lt){lt.done?ot(lt.value):nt(lt.value).then(st,at)}ct((rt=rt.apply(et,o||[])).next())})};class Semaphore{constructor(o,tt=E_CANCELED){this._value=o,this._cancelError=tt,this._queue=[],this._weightedWaiters=[]}acquire(o=1,tt=0){if(o<=0)throw new Error(`invalid weight ${o}: must be positive`);return new Promise((rt,nt)=>{const ot={resolve:rt,reject:nt,weight:o,priority:tt},it=findIndexFromEnd(this._queue,st=>tt<=st.priority);it===-1&&o<=this._value?this._dispatchItem(ot):this._queue.splice(it+1,0,ot)})}runExclusive(o){return __awaiter$2(this,arguments,void 0,function*(tt,rt=1,nt=0){const[ot,it]=yield this.acquire(rt,nt);try{return yield tt(ot)}finally{it()}})}waitForUnlock(o=1,tt=0){if(o<=0)throw new Error(`invalid weight ${o}: must be positive`);return this._couldLockImmediately(o,tt)?Promise.resolve():new Promise(rt=>{this._weightedWaiters[o-1]||(this._weightedWaiters[o-1]=[]),insertSorted(this._weightedWaiters[o-1],{resolve:rt,priority:tt})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(o){this._value=o,this._dispatchQueue()}release(o=1){if(o<=0)throw new Error(`invalid weight ${o}: must be positive`);this._value+=o,this._dispatchQueue()}cancel(){this._queue.forEach(o=>o.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(o){const tt=this._value;this._value-=o.weight,o.resolve([tt,this._newReleaser(o.weight)])}_newReleaser(o){let tt=!1;return()=>{tt||(tt=!0,this.release(o))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let o=this._value;o>0;o--){const tt=this._weightedWaiters[o-1];tt&&(tt.forEach(rt=>rt.resolve()),this._weightedWaiters[o-1]=[])}else{const o=this._queue[0].priority;for(let tt=this._value;tt>0;tt--){const rt=this._weightedWaiters[tt-1];if(!rt)continue;const nt=rt.findIndex(ot=>ot.priority<=o);(nt===-1?rt:rt.splice(0,nt)).forEach(ot=>ot.resolve())}}}_couldLockImmediately(o,tt){return(this._queue.length===0||this._queue[0].priorityo.priority<=rt.priority);et.splice(tt+1,0,o)}function findIndexFromEnd(et,o){for(let tt=et.length-1;tt>=0;tt--)if(o(et[tt]))return tt;return-1}var __awaiter$1=function(et,o,tt,rt){function nt(ot){return ot instanceof tt?ot:new tt(function(it){it(ot)})}return new(tt||(tt=Promise))(function(ot,it){function st(lt){try{ct(rt.next(lt))}catch(dt){it(dt)}}function at(lt){try{ct(rt.throw(lt))}catch(dt){it(dt)}}function ct(lt){lt.done?ot(lt.value):nt(lt.value).then(st,at)}ct((rt=rt.apply(et,o||[])).next())})};class Mutex{constructor(o){this._semaphore=new Semaphore(1,o)}acquire(){return __awaiter$1(this,arguments,void 0,function*(o=0){const[,tt]=yield this._semaphore.acquire(1,o);return tt})}runExclusive(o,tt=0){return this._semaphore.runExclusive(()=>o(),1,tt)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(o=0){return this._semaphore.waitForUnlock(1,o)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class PeerManager{constructor(o,tt,rt){wt(this,"connectionManager");wt(this,"core");wt(this,"log");wt(this,"peers",new Map);wt(this,"healthManager");wt(this,"readMutex",new Mutex);wt(this,"writeMutex",new Mutex);wt(this,"writeLockHolder",null);this.connectionManager=o,this.core=tt,this.log=rt,this.healthManager=getHealthManager(),this.healthManager.updateProtocolHealth(this.core.multicodec,0)}getWriteLockHolder(){return this.writeLockHolder}getPeers(){return Array.from(this.peers.values())}async addPeer(o){return this.writeMutex.runExclusive(async()=>{this.writeLockHolder=`addPeer: ${o.id.toString()}`,await this.connectionManager.attemptDial(o.id),this.peers.set(o.id.toString(),o),this.log.info(`Added and dialed peer: ${o.id.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null})}async removePeer(o){return this.writeMutex.runExclusive(()=>{this.writeLockHolder=`removePeer: ${o.toString()}`,this.peers.delete(o.toString()),this.log.info(`Removed peer: ${o.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null})}async getPeerCount(){return this.readMutex.runExclusive(()=>this.peers.size)}async hasPeers(){return this.readMutex.runExclusive(()=>this.peers.size>0)}async removeExcessPeers(o){this.log.info(`Removing ${o} excess peer(s)`);const tt=Array.from(this.peers.values()).slice(0,o);for(const rt of tt)await this.removePeer(rt.id)}async findAndAddPeers(o){const tt=await this.findPeers(o);return tt.length===0?(this.log.warn("No additional peers found"),[]):this.addMultiplePeers(tt)}async findPeers(o){const tt=await this.core.getPeers();return this.readMutex.runExclusive(async()=>tt.filter(nt=>!this.peers.has(nt.id.toString())).slice(0,o))}async addMultiplePeers(o){const tt=[];for(const rt of o)await this.addPeer(rt),tt.push(rt);return tt}}const DEFAULT_NUM_PEERS_TO_USE=2,DEFAULT_MAINTAIN_PEERS_INTERVAL=3e4;class BaseProtocolSDK{constructor(o,tt,rt){wt(this,"core");wt(this,"connectionManager");wt(this,"peerManager");wt(this,"numPeersToUse");wt(this,"maintainPeersIntervalId",null);wt(this,"log");this.core=o,this.connectionManager=tt,this.log=new Logger$1(`sdk:${o.multicodec}`),this.numPeersToUse=(rt==null?void 0:rt.numPeersToUse)??DEFAULT_NUM_PEERS_TO_USE;const nt=(rt==null?void 0:rt.maintainPeersInterval)??DEFAULT_MAINTAIN_PEERS_INTERVAL;this.peerManager=new PeerManager(tt,o,this.log),this.log.info(`Initializing BaseProtocolSDK with numPeersToUse: ${this.numPeersToUse}, maintainPeersInterval: ${nt}ms`),this.startMaintainPeersInterval(nt)}get connectedPeers(){return this.peerManager.getPeers().slice(0,this.numPeersToUse)}async renewPeer(o){this.log.info(`Attempting to renew peer ${o}`);const tt=await this.peerManager.findPeers(1);if(tt.length===0){this.log.error("Failed to find a new peer to replace the disconnected one");return}return await this.peerManager.removePeer(o),await this.peerManager.addPeer(tt[0]),this.log.info(`Successfully renewed peer. New peer: ${tt[0].id}`),tt[0]}stopMaintainPeersInterval(){this.maintainPeersIntervalId?(clearInterval(this.maintainPeersIntervalId),this.maintainPeersIntervalId=null,this.log.info("Maintain peers interval stopped")):this.log.info("Maintain peers interval was not running")}async hasPeers(o={}){const{forceUseAllPeers:tt=!1,maxAttempts:rt=3}=o;this.log.info(`Checking for peers. forceUseAllPeers: ${tt}, maxAttempts: ${rt}`);for(let nt=0;nt0)return this.log.info(`At least one peer connected (${this.connectedPeers.length}), not forcing use of all peers`),!0;if(this.connectedPeers.length>=this.numPeersToUse)return this.log.info(`Required number of peers (${this.numPeersToUse}) reached`),!0;this.log.warn(`Found only ${this.connectedPeers.length}/${this.numPeersToUse} required peers. Retrying...`)}return this.log.error(`Failed to find required number of peers (${this.numPeersToUse}) after ${rt} attempts`),!1}async startMaintainPeersInterval(o){this.log.info(`Starting maintain peers interval with ${o}ms interval`);try{this.maintainPeersIntervalId=setInterval(()=>{this.log.info("Running scheduled peer maintenance"),this.maintainPeers().catch(tt=>{this.log.error("Error during scheduled peer maintenance:",tt)})},o),this.log.info("Maintain peers interval started successfully")}catch(tt){throw this.log.error("Error starting maintain peers interval:",tt),tt}}async maintainPeers(){try{const o=await this.peerManager.getPeerCount(),tt=this.numPeersToUse-o;if(this.log.info(`Current peer count: ${o}, target: ${this.numPeersToUse}`),tt===0){this.log.info("Peer count is at target, no maintenance required");return}tt>0?(this.log.info(`Attempting to add ${tt} peer(s)`),await this.peerManager.findAndAddPeers(tt)):(this.log.info(`Attempting to remove ${Math.abs(tt)} excess peer(s)`),await this.peerManager.removeExcessPeers(Math.abs(tt)));const rt=await this.peerManager.getPeerCount();this.log.info(`Peer maintenance completed. Initial count: ${o}, Final count: ${rt}`)}catch(o){this.log.error("Error during peer maintenance",{error:o})}}}const DEFAULT_KEEP_ALIVE=6e4,DEFAULT_LIGHT_PUSH_FILTER_CHECK=!1,DEFAULT_LIGHT_PUSH_FILTER_CHECK_INTERVAL=1e4,DEFAULT_SUBSCRIBE_OPTIONS={keepAlive:DEFAULT_KEEP_ALIVE,enableLightPushFilterCheck:DEFAULT_LIGHT_PUSH_FILTER_CHECK};function messageHash(et,o){const tt=utf8ToBytes$1(et),rt=utf8ToBytes$1(o.contentTopic),nt=tryConvertTimestampToBytes(o.timestamp),ot=concat$5([tt,o.payload,rt,o.meta,nt].filter(isDefined));return sha256$3(ot)}function tryConvertTimestampToBytes(et){if(!et)return;let o;return typeof et=="bigint"?o=et:o=BigInt(et.valueOf())*1000000n,numberToBytes(o)}function messageHashStr(et,o){const tt=messageHash(et,o);return bytesToHex$1(tt)}const log$h=new Logger$1("sdk:receiver:reliability_monitor"),DEFAULT_MAX_PINGS=3,MESSAGE_VERIFICATION_DELAY=5e3;class ReceiverReliabilityMonitor{constructor(o,tt,rt,nt,ot,it,st){wt(this,"pubsubTopic");wt(this,"getPeers");wt(this,"renewPeer");wt(this,"getContentTopics");wt(this,"protocolSubscribe");wt(this,"addLibp2pEventListener");wt(this,"sendLightPushMessage");wt(this,"receivedMessagesFormPeer",new Set);wt(this,"receivedMessages",new Set);wt(this,"scheduledVerification",new Map);wt(this,"verifiedPeers",new Set);wt(this,"peerFailures",new Map);wt(this,"maxPingFailures",DEFAULT_MAX_PINGS);wt(this,"peerRenewalLocks",new Set);this.pubsubTopic=o,this.getPeers=tt,this.renewPeer=rt,this.getContentTopics=nt,this.protocolSubscribe=ot,this.addLibp2pEventListener=it,this.sendLightPushMessage=st,this.addLibp2pEventListener("peer:disconnect",at=>{const ct=at.detail;this.getPeers().some(lt=>lt.id.equals(ct))&&this.renewAndSubscribePeer(ct)})}setMaxPingFailures(o){o!==void 0&&(this.maxPingFailures=o)}async handlePingResult(o,tt){if(tt!=null&&tt.success){this.peerFailures.delete(o.toString());return}const rt=(this.peerFailures.get(o.toString())||0)+1;if(this.peerFailures.set(o.toString(),rt),rt>=this.maxPingFailures)try{log$h.info(`Attempting to renew ${o.toString()} due to ping failures.`),await this.renewAndSubscribePeer(o),this.peerFailures.delete(o.toString())}catch(nt){log$h.error(`Failed to renew peer ${o.toString()}: ${nt}.`)}}notifyMessageReceived(o,tt){const rt=this.buildMessageHash(tt);return this.verifiedPeers.add(o),this.receivedMessagesFormPeer.add(`${o}-${rt}`),log$h.info(`notifyMessage received debug: ephemeral:${tt.ephemeral} ${bytesToUtf8(tt.payload)}`),log$h.info(`notifyMessage received: peer:${o} message:${rt}`),this.receivedMessages.has(rt)?!0:(this.receivedMessages.add(rt),!1)}notifyMessageSent(o,tt){const rt=o.toString(),nt=this.buildMessageHash(tt);if(log$h.info(`notifyMessage sent debug: ${bytesToUtf8(tt.payload)}`),this.scheduledVerification.has(rt)){log$h.warn(`notifyMessage sent: attempting to schedule verification for pending peer:${rt} message:${nt}`);return}const ot=window.setTimeout(async()=>{const it=this.verifiedPeers.has(rt),st=this.receivedMessagesFormPeer.has(`${rt}-${nt}`);if(it||st){log$h.info(`notifyMessage sent setTimeout: verified that peer pushes filter messages, peer:${rt} message:${nt}`);return}log$h.warn(`notifyMessage sent setTimeout: peer didn't return probe message, attempting renewAndSubscribe, peer:${rt} message:${nt}`),this.scheduledVerification.delete(rt),await this.renewAndSubscribePeer(o)},MESSAGE_VERIFICATION_DELAY);this.scheduledVerification.set(rt,ot)}shouldVerifyPeer(o){const tt=o.toString(),rt=this.verifiedPeers.has(tt),nt=this.scheduledVerification.has(tt);return!(rt||nt)}buildMessageHash(o){return messageHashStr(this.pubsubTopic,o)}async renewAndSubscribePeer(o){const tt=o.toString();try{if(this.peerRenewalLocks.has(tt)){log$h.info(`Peer ${tt} is already being renewed.`);return}this.peerRenewalLocks.add(tt);const rt=await this.renewPeer(o);if(!rt){log$h.warn(`Failed to renew peer ${tt}: No new peer found.`);return}return await this.protocolSubscribe(this.pubsubTopic,rt,this.getContentTopics()),await this.sendLightPushMessage(rt),this.peerFailures.delete(tt),rt}catch(rt){log$h.error(`Failed to renew peer ${tt}: ${rt}.`);return}finally{this.peerRenewalLocks.delete(tt)}}}const Ln=class Ln{static createReceiverMonitor(o,tt,rt,nt,ot,it,st){if(Ln.receiverMonitors.has(o))return Ln.receiverMonitors.get(o);const at=new ReceiverReliabilityMonitor(o,tt,rt,nt,ot,it,st);return Ln.receiverMonitors.set(o,at),at}constructor(){}static stop(o){this.receiverMonitors.delete(o)}static stopAll(){for(const[o,tt]of this.receiverMonitors)tt.setMaxPingFailures(void 0),this.receiverMonitors.delete(o)}};wt(Ln,"receiverMonitors",new Map);let ReliabilityMonitorManager=Ln;const log$g=new Logger$1("sdk:filter:subscription_manager");class SubscriptionManager{constructor(o,tt,rt,nt,ot,it,st){wt(this,"pubsubTopic");wt(this,"protocol");wt(this,"connectionManager");wt(this,"getPeers");wt(this,"renewPeer");wt(this,"libp2p");wt(this,"lightPush");wt(this,"reliabilityMonitor");wt(this,"keepAliveTimeout",DEFAULT_KEEP_ALIVE);wt(this,"keepAliveInterval",null);wt(this,"enableLightPushFilterCheck",DEFAULT_LIGHT_PUSH_FILTER_CHECK);wt(this,"subscriptionCallbacks");this.pubsubTopic=o,this.protocol=tt,this.connectionManager=rt,this.getPeers=nt,this.renewPeer=ot,this.libp2p=it,this.lightPush=st,this.pubsubTopic=o,this.subscriptionCallbacks=new Map,this.reliabilityMonitor=ReliabilityMonitorManager.createReceiverMonitor(this.pubsubTopic,this.getPeers.bind(this),this.renewPeer.bind(this),()=>Array.from(this.subscriptionCallbacks.keys()),this.protocol.subscribe.bind(this.protocol),this.protocol.addLibp2pEventListener.bind(this.protocol),this.sendLightPushCheckMessage.bind(this))}async subscribe(o,tt,rt=DEFAULT_SUBSCRIBE_OPTIONS){this.reliabilityMonitor.setMaxPingFailures(rt.pingsBeforePeerRenewed),this.keepAliveTimeout=rt.keepAlive||DEFAULT_KEEP_ALIVE,this.enableLightPushFilterCheck=(rt==null?void 0:rt.enableLightPushFilterCheck)||DEFAULT_LIGHT_PUSH_FILTER_CHECK;const nt=Array.isArray(o)?o:[o];for(const lt of nt)if(lt.pubsubTopic!==this.pubsubTopic)return{failures:[{error:ProtocolError$1.TOPIC_DECODER_MISMATCH}],successes:[]};this.enableLightPushFilterCheck&&nt.push(createDecoder(this.buildLightPushContentTopic(),this.pubsubTopic));const ot=groupByContentTopic(nt),it=Array.from(ot.keys()),st=this.getPeers().map(async lt=>this.subscribeWithPeerVerification(lt,it)),at=await Promise.allSettled(st),ct=this.handleResult(at,"subscribe");return ot.forEach((lt,dt)=>{const ht={decoders:lt,callback:tt};dt!==this.buildLightPushContentTopic()&&this.subscriptionCallbacks.set(dt,ht)}),this.startSubscriptionsMaintenance(this.keepAliveTimeout),ct}async unsubscribe(o){const tt=this.getPeers().map(async ot=>{const it=await this.protocol.unsubscribe(this.pubsubTopic,ot,o);return o.forEach(st=>{this.subscriptionCallbacks.delete(st)}),it}),rt=await Promise.allSettled(tt),nt=this.handleResult(rt,"unsubscribe");return this.subscriptionCallbacks.size===0&&this.stopSubscriptionsMaintenance(),nt}async ping(o){log$g.info("Sending keep-alive ping");const rt=(o?[o]:this.getPeers().map(ot=>ot.id)).map(ot=>this.pingSpecificPeer(ot)),nt=await Promise.allSettled(rt);return this.handleResult(nt,"ping")}async unsubscribeAll(){const o=this.getPeers().map(async nt=>this.protocol.unsubscribeAll(this.pubsubTopic,nt)),tt=await Promise.allSettled(o);this.subscriptionCallbacks.clear();const rt=this.handleResult(tt,"unsubscribeAll");return this.stopSubscriptionsMaintenance(),rt}async processIncomingMessage(o,tt){if(this.reliabilityMonitor.notifyMessageReceived(tt,o)){log$g.info("Message already received, skipping");return}const{contentTopic:nt}=o,ot=this.subscriptionCallbacks.get(nt);if(!ot){log$g.error("No subscription callback available for ",nt);return}log$g.info("Processing message with content topic ",nt," on pubsub topic ",this.pubsubTopic),await pushMessage(ot,this.pubsubTopic,o)}async subscribeWithPeerVerification(o,tt){const rt=await this.protocol.subscribe(this.pubsubTopic,o,tt);return await this.sendLightPushCheckMessage(o),rt}handleResult(o,tt){const rt={failures:[],successes:[]};for(const nt of o)if(nt.status==="rejected")log$g.error(`Failed to resolve ${tt} promise successfully: `,nt.reason),rt.failures.push({error:ProtocolError$1.GENERIC_FAIL});else{const ot=nt.value;ot.failure?rt.failures.push(ot.failure):rt.successes.push(ot.success)}return rt}async pingSpecificPeer(o){var nt,ot;const tt=this.getPeers().find(it=>it.id.equals(o));if(!tt)return{success:null,failure:{peerId:o,error:ProtocolError$1.NO_PEER_AVAILABLE}};let rt;try{rt=await this.protocol.ping(tt)}catch{rt={success:null,failure:{peerId:o,error:ProtocolError$1.GENERIC_FAIL}}}return log$g.info(`Received result from filter ping peerId:${o.toString()} success:${(nt=rt.success)==null?void 0:nt.toString()} failure:${(ot=rt.failure)==null?void 0:ot.error}`),await this.reliabilityMonitor.handlePingResult(o,rt),rt}startSubscriptionsMaintenance(o){log$g.info("Starting subscriptions maintenance"),this.startKeepAlivePings(o),this.startConnectionListener()}stopSubscriptionsMaintenance(){log$g.info("Stopping subscriptions maintenance"),this.stopKeepAlivePings(),this.stopConnectionListener()}startConnectionListener(){this.connectionManager.addEventListener(EConnectionStateEvents.CONNECTION_STATUS,this.connectionListener.bind(this))}stopConnectionListener(){this.connectionManager.removeEventListener(EConnectionStateEvents.CONNECTION_STATUS,this.connectionListener.bind(this))}async connectionListener({detail:o}){if(!o){this.stopKeepAlivePings();return}try{await this.ping()}catch(tt){log$g.error(`networkStateListener failed to recover: ${tt}`)}this.startKeepAlivePings(this.keepAliveTimeout)}startKeepAlivePings(o){if(this.keepAliveInterval){log$g.info("Recurring pings already set up.");return}this.keepAliveInterval=setInterval(()=>{this.ping()},o)}stopKeepAlivePings(){if(!this.keepAliveInterval){log$g.info("Already stopped recurring pings.");return}log$g.info("Stopping recurring pings."),clearInterval(this.keepAliveInterval),this.keepAliveInterval=null}async sendLightPushCheckMessage(o){if(this.lightPush&&this.libp2p&&this.reliabilityMonitor.shouldVerifyPeer(o.id)){const tt=createEncoder({contentTopic:this.buildLightPushContentTopic(),pubsubTopic:this.pubsubTopic,ephemeral:!0}),rt={payload:new Uint8Array(1)},nt=await tt.toProtoObj(rt);setTimeout(async()=>{const ot=await this.lightPush.protocol.send(tt,rt,o);if(this.reliabilityMonitor.notifyMessageSent(o.id,nt),ot.failure){log$g.error(`failed to send lightPush ping message to peer:${o.id.toString()} ${ot.failure.error}`);return}},DEFAULT_LIGHT_PUSH_FILTER_CHECK_INTERVAL)}}buildLightPushContentTopic(){return`/js-waku-subscription-ping/1/${this.libp2p.peerId.toString()}/utf8`}}async function pushMessage(et,o,tt){const{decoders:rt,callback:nt}=et,{contentTopic:ot}=tt;if(!ot){log$g.warn("Message has no content topic, skipping");return}try{const it=rt.map(at=>at.fromProtoObj(o,tt).then(ct=>ct||Promise.reject("Decoding failed"))),st=await Promise.any(it);await nt(st)}catch(it){log$g.error("Error decoding message",it)}}const log$f=new Logger$1("sdk:filter");class Filter extends BaseProtocolSDK{constructor(tt,rt,nt,ot){super(new FilterCore(async(it,st,at)=>{const ct=this.getActiveSubscription(it);if(!ct){log$f.error(`No subscription locally registered for topic ${it}`);return}await ct.processIncomingMessage(st,at)},tt.configuredPubsubTopics,rt),tt,{numPeersToUse:ot==null?void 0:ot.numPeersToUse});wt(this,"libp2p");wt(this,"lightPush");wt(this,"protocol");wt(this,"activeSubscriptions",new Map);this.libp2p=rt,this.lightPush=nt,this.protocol=this.core,this.activeSubscriptions=new Map}async subscribe(tt,rt,nt,ot=DEFAULT_SUBSCRIBE_OPTIONS){const it=this.getUniquePubsubTopics(tt);if(it.length!==1)return{subscription:null,error:ProtocolError$1.INVALID_DECODER_TOPICS,results:null};const st=it[0],{subscription:at,error:ct}=await this.createSubscription(st,nt);if(ct)return{subscription:null,error:ct,results:null};const{failures:lt,successes:dt}=await at.subscribe(tt,rt,ot);return{subscription:at,error:null,results:{failures:lt,successes:dt}}}async createSubscription(tt,rt){var st;rt={autoRetry:!0,...rt};const nt=typeof tt=="string"?tt:(st=shardInfoToPubsubTopics(tt))==null?void 0:st[0];return ensurePubsubTopicIsConfigured(nt,this.protocol.pubsubTopics),await this.hasPeers(rt)?(log$f.info(`Creating filter subscription with ${this.connectedPeers.length} peers: `,this.connectedPeers.map(at=>at.id.toString())),{error:null,subscription:this.getActiveSubscription(nt)??this.setActiveSubscription(nt,new SubscriptionManager(nt,this.protocol,this.connectionManager,()=>this.connectedPeers,this.renewPeer.bind(this),this.libp2p,this.lightPush))}):{error:ProtocolError$1.NO_PEER_AVAILABLE,subscription:null}}async subscribeWithUnsubscribe(tt,rt,nt=DEFAULT_SUBSCRIBE_OPTIONS){const ot=this.getUniquePubsubTopics(tt);if(ot.length===0)throw Error("Failed to subscribe: no pubsubTopic found on decoders provided.");if(ot.length>1)throw Error("Failed to subscribe: all decoders should have the same pubsub topic. Use createSubscription to be more agile.");const{subscription:it,error:st}=await this.createSubscription(ot[0]);if(st)throw Error(`Failed to create subscription: ${st}`);await it.subscribe(tt,rt,nt);const at=Array.from(groupByContentTopic(Array.isArray(tt)?tt:[tt]).keys());return async()=>{await it.unsubscribe(at)}}toSubscriptionIterator(tt){return toAsyncIterator(this,tt)}getActiveSubscription(tt){return this.activeSubscriptions.get(tt)}setActiveSubscription(tt,rt){return this.activeSubscriptions.set(tt,rt),rt}getUniquePubsubTopics(tt){return Array.isArray(tt)?tt.length===0?[]:[...new Set(tt.map(nt=>nt.pubsubTopic))]:[tt.pubsubTopic]}}function wakuFilter(et,o,tt){return rt=>new Filter(et,rt,o,tt)}const log$e=new Logger$1("sdk:light-push"),DEFAULT_MAX_ATTEMPTS=3,DEFAULT_SEND_OPTIONS={autoRetry:!1,maxAttempts:DEFAULT_MAX_ATTEMPTS};class LightPush{constructor(o,tt,rt){wt(this,"libp2p");wt(this,"numPeersToUse",DEFAULT_NUM_PEERS_TO_USE);wt(this,"protocol");this.libp2p=tt,this.numPeersToUse=(rt==null?void 0:rt.numPeersToUse)??DEFAULT_NUM_PEERS_TO_USE,this.protocol=new LightPushCore(o.configuredPubsubTopics,tt)}async send(o,tt,rt=DEFAULT_SEND_OPTIONS){const nt=[],ot=[],{pubsubTopic:it}=o;try{ensurePubsubTopicIsConfigured(it,this.protocol.pubsubTopics)}catch{return log$e.error("Failed to send waku light push: pubsub topic not configured"),{successes:nt,failures:[{error:ProtocolError$1.TOPIC_NOT_CONFIGURED}]}}const st=await this.getConnectedPeers();if(st.length===0)return{successes:nt,failures:[{error:ProtocolError$1.NO_PEER_AVAILABLE}]};const at=await Promise.allSettled(st.map(ct=>this.protocol.send(o,tt,ct)));for(const ct of at){if(ct.status!=="fulfilled"){log$e.error("Failed unexpectedly while sending:",ct.reason),ot.push({error:ProtocolError$1.GENERIC_FAIL});continue}const{failure:lt,success:dt}=ct.value;if(dt){nt.push(dt);continue}lt&&(ot.push(lt),rt!=null&&rt.autoRetry&&this.attemptRetries(ht=>this.protocol.send(o,tt,ht),rt.maxAttempts))}return getHealthManager().updateProtocolHealth(this.protocol.multicodec,nt.length),{successes:nt,failures:ot}}async attemptRetries(o,tt){var nt;tt=tt||DEFAULT_MAX_ATTEMPTS;const rt=await this.getConnectedPeers();if(rt.length===0){log$e.warn("Cannot retry with no connected peers.");return}for(let ot=0;ot{try{return await this.libp2p.peerStore.get(rt)}catch{return null}}))).filter(rt=>!!rt).filter(rt=>rt.protocols.includes(LightPushCodec)).slice(0,this.numPeersToUse)}}function wakuLightPush(et,o={}){return tt=>new LightPush(et,tt,o)}const DEFAULT_NUM_PEERS=1,log$d=new Logger$1("waku:store:sdk");class Store extends BaseProtocolSDK{constructor(tt,rt,nt){super(new StoreCore(tt.configuredPubsubTopics,rt),tt,{numPeersToUse:DEFAULT_NUM_PEERS});wt(this,"peerIdStrToUse");wt(this,"protocol");this.peerIdStrToUse=nt,this.protocol=this.core}async*queryGenerator(tt,rt){const{pubsubTopic:nt,contentTopics:ot,decodersAsMap:it}=this.validateDecodersAndPubsubTopic(tt),st={pubsubTopic:nt,contentTopics:ot,includeData:!0,paginationForward:!0,...rt},at=(await this.protocol.getPeers({numPeers:this.numPeersToUse,maxBootstrapPeers:1,peerIdStr:this.peerIdStrToUse}))[0];if(!at)throw log$d.error("No peers available to query"),new Error("No peers available to query");log$d.info(`Querying store with options: ${JSON.stringify(rt)}`);const ct=this.protocol.queryPerPage(st,it,at);for await(const lt of ct)yield lt}async queryWithOrderedCallback(tt,rt,nt){log$d.info("Querying store with ordered callback");for await(const ot of this.queryGenerator(tt,nt))if(await this.processMessages(ot,rt))break}async queryWithPromiseCallback(tt,rt,nt){log$d.info("Querying store with promise callback");let ot=!1;for await(const it of this.queryGenerator(tt,nt)){const st=it.map(async at=>{ot||(ot=!!await rt(at))});if(await Promise.all(st),ot)break}}async processMessages(tt,rt){let nt=!1;const it=(await Promise.all(tt)).filter(isDefined);return await Promise.all(it.map(async st=>{st&&!nt&&(nt=!!await rt(st))})),nt}createCursor(tt){return messageHash(tt.pubsubTopic,tt)}validateDecodersAndPubsubTopic(tt){if(tt.length===0)throw log$d.error("No decoders provided"),new Error("No decoders provided");const rt=Array.from(new Set(tt.map(st=>st.pubsubTopic)));if(rt.length>1)throw log$d.error("API does not support querying multiple pubsub topics at once"),new Error("API does not support querying multiple pubsub topics at once");const nt=rt[0];ensurePubsubTopicIsConfigured(nt,this.protocol.pubsubTopics);const ot=new Map;tt.forEach(st=>{if(ot.has(st.contentTopic))throw log$d.error("API does not support different decoder per content topic"),new Error("API does not support different decoder per content topic");ot.set(st.contentTopic,st)});const it=tt.filter(st=>st.pubsubTopic===nt).map(st=>st.contentTopic);if(it.length===0)throw log$d.error(`No decoders found for topic ${nt}`),new Error("No decoders found for topic "+nt);return{pubsubTopic:nt,contentTopics:it,decodersAsMap:ot}}}function wakuStore(et,o){return tt=>new Store(et,tt,o)}const log$c=new Logger$1("wait-for-remote-peer");async function waitForRemotePeer(et,o,tt){o=o!=null&&o.length?o:getEnabledProtocols(et);const rt=et.libp2p.getConnections();if(!et.isStarted())throw Error("Waku node is not started");if(rt.length>0&&!o.includes(Protocols.Relay)&&await waitForMetadata(et,o))return;const nt=[];if(o.includes(Protocols.Relay)){if(!et.relay)throw Error("Cannot wait for Relay peer: protocol not mounted");nt.push(et.relay.waitForPeers())}if(o.includes(Protocols.Store)){if(!et.store)throw Error("Cannot wait for Store peer: protocol not mounted");nt.push(waitForConnectedPeer(StoreCodec,et.libp2p))}if(o.includes(Protocols.LightPush)){if(!et.lightPush)throw Error("Cannot wait for LightPush peer: protocol not mounted");nt.push(waitForConnectedPeer(LightPushCodec,et.libp2p))}if(o.includes(Protocols.Filter)){if(!et.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");nt.push(waitForConnectedPeer(FilterCodecs.SUBSCRIBE,et.libp2p))}tt?await rejectOnTimeout(Promise.all(nt),tt,"Timed out waiting for a remote peer."):await Promise.all(nt)}async function waitForConnectedPeer(et,o){log$c.info(`Waiting for ${et} peer.`),await new Promise(tt=>{const rt=async nt=>{var ot,it;if((it=(ot=nt.detail)==null?void 0:ot.protocols)!=null&&it.includes(et)){const st=o.services.metadata;if(!st){o.removeEventListener("peer:identify",rt),tt();return}try{await st.confirmOrAttemptHandshake(nt.detail.peerId),o.removeEventListener("peer:identify",rt),tt()}catch(at){at.code==="ERR_CONNECTION_BEING_CLOSED"&&log$c.error("Connection closed. Some peers can be on different shard."),log$c.error(`Error waiting for metadata: ${at}`)}}};o.addEventListener("peer:identify",rt)})}async function waitForMetadata(et,o){const tt=et.libp2p.getPeers(),rt=et.libp2p.services.metadata,nt=mapProtocolsToCodecs(o);if(!tt.length||!rt)return log$c.info(`Skipping waitForMetadata due to missing connections:${tt.length} or metadataService:${!!rt}`),!1;for(const ot of tt)try{const it=await et.libp2p.peerStore.get(ot);if(it.protocols.some(at=>nt.has(at))&&!(await rt.confirmOrAttemptHandshake(ot)).error&&(it.protocols.forEach(lt=>{nt.has(lt)&&nt.set(lt,!0)}),Array.from(nt.values()).every(lt=>lt)))return!0}catch(it){it.code==="ERR_CONNECTION_BEING_CLOSED"&&log$c.error("Connection closed. Some peers can be on different shard."),log$c.error(`Error while iterating through peers: ${it}`);continue}return!1}const awaitTimeout=(et,o)=>new Promise((tt,rt)=>setTimeout(()=>rt(Error(o)),et));async function rejectOnTimeout(et,o,tt){await Promise.race([et,awaitTimeout(o,tt)])}function getEnabledProtocols(et){const o=[];return et.relay&&o.push(Protocols.Relay),et.filter&&o.push(Protocols.Filter),et.store&&o.push(Protocols.Store),et.lightPush&&o.push(Protocols.LightPush),o}function mapProtocolsToCodecs(et){const o=new Map,tt={[Protocols.Filter]:FilterCodecs.SUBSCRIBE,[Protocols.LightPush]:LightPushCodec,[Protocols.Store]:StoreCodec};for(const rt of et)tt[rt]&&o.set(tt[rt],!1);return o}const DefaultPingKeepAliveValueSecs=5*60,DefaultRelayKeepAliveValueSecs=5*60,DefaultUserAgent="js-waku",DefaultPingMaxInboundStreams=10,log$b=new Logger$1("waku");class WakuNode{constructor(o,tt,rt,nt,ot){wt(this,"pubsubTopics");wt(this,"libp2p");wt(this,"relay");wt(this,"store");wt(this,"filter");wt(this,"lightPush");wt(this,"connectionManager");wt(this,"health");var ct;this.pubsubTopics=o,this.relay=ot,this.libp2p=rt,nt={filter:!1,lightpush:!1,store:!1,...nt};const it=tt.pingKeepAlive||DefaultPingKeepAliveValueSecs,st=this.relay?tt.relayKeepAlive||DefaultRelayKeepAliveValueSecs:0,at=this.libp2p.peerId.toString();if(this.connectionManager=ConnectionManager.create(at,rt,{pingKeepAlive:it,relayKeepAlive:st},this.pubsubTopics,this.relay),this.health=getHealthManager(),nt.store){let lt;(ct=tt.nodeToUse)!=null&&ct.store&&this.dialMultiaddr(tt.nodeToUse.store,StoreCodec).catch(ht=>{log$b.error("Failed to dial store peer",ht)});const dt=wakuStore(this.connectionManager,lt);this.store=dt(rt)}if(nt.lightpush){const lt=wakuLightPush(this.connectionManager,tt);this.lightPush=lt(rt)}if(nt.filter){const lt=wakuFilter(this.connectionManager,this.lightPush,tt);this.filter=lt(rt)}log$b.info("Waku node created",at,`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`)}get peerId(){return this.libp2p.peerId}get protocols(){return this.libp2p.getProtocols()}async dial(o,tt){const rt=tt??[],nt=this.mapToPeerIdOrMultiaddr(o);typeof tt>"u"&&(this.relay&&rt.push(Protocols.Relay),this.store&&rt.push(Protocols.Store),this.filter&&rt.push(Protocols.Filter),this.lightPush&&rt.push(Protocols.LightPush));const ot=[];return rt.includes(Protocols.Relay)&&(this.relay?this.relay.gossipSub.multicodecs.forEach(it=>ot.push(it)):log$b.error("Relay codec not included in dial codec: protocol not mounted locally")),rt.includes(Protocols.Store)&&(this.store?ot.push(this.store.protocol.multicodec):log$b.error("Store codec not included in dial codec: protocol not mounted locally")),rt.includes(Protocols.LightPush)&&(this.lightPush?ot.push(this.lightPush.protocol.multicodec):log$b.error("Light Push codec not included in dial codec: protocol not mounted locally")),rt.includes(Protocols.Filter)&&(this.filter?ot.push(this.filter.protocol.multicodec):log$b.error("Filter codec not included in dial codec: protocol not mounted locally")),log$b.info(`Dialing to ${nt.toString()} with protocols ${rt}`),this.libp2p.dialProtocol(nt,ot)}async start(){await this.libp2p.start()}async stop(){ReliabilityMonitorManager.stopAll(),this.connectionManager.stop(),await this.libp2p.stop()}async waitForPeers(o,tt){return waitForRemotePeer(this,o,tt)}isStarted(){return this.libp2p.status=="started"}isConnected(){return this.connectionManager.isConnected()}async dialMultiaddr(o,tt){const rt=multiaddr(o);if(!rt.getPeerId())throw new Error("Failed to dial multiaddr: missing peer ID");return await this.libp2p.dialProtocol(rt,[tt]),rt.getPeerId()}mapToPeerIdOrMultiaddr(o){return isPeerId$2(o)?o:multiaddr(o)}}var hs;let InvalidParametersError$3=(hs=class extends Error{constructor(o="Invalid parameters"){super(o),this.name="InvalidParametersError"}},wt(hs,"name","InvalidParametersError"),hs);class InvalidPublicKeyError extends Error{constructor(o="Invalid public key"){super(o),this.name="InvalidPublicKeyError"}}wt(InvalidPublicKeyError,"name","InvalidPublicKeyError");var ps;let UnsupportedKeyTypeError$1=(ps=class extends Error{constructor(o="Unsupported key type"){super(o),this.name="UnsupportedKeyTypeError"}},wt(ps,"name","UnsupportedKeyTypeError"),ps);function equals$b(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$i=base$i,_brrp__multiformats_scope_baseX$h=src$i;let Encoder$i=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$i=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$j(this,o)}},ComposedDecoder$h=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$j(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$j(et,o){return new ComposedDecoder$h({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$h=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$i(o,tt,rt),this.decoder=new Decoder$i(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$k({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$h(et,o,tt,rt)}function baseX$h({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$h(tt,et);return from$k({prefix:o,name:et,encode:rt,decode:ot=>coerce$h(nt(ot))})}function decode$O(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$G(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<=INT$4;)o[tt++]=et&255|MSB$6,et/=128;for(;et&MSBALL$4;)o[tt++]=et&255|MSB$6,et>>>=7;return o[tt]=et|0,encode$F.bytes=tt-rt+1,o}var decode$N=read$5,MSB$1$4=128,REST$1$4=127;function read$5(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$5.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$4)<=MSB$1$4);return read$5.bytes=ot-rt,tt}var N1$4=Math.pow(2,7),N2$4=Math.pow(2,14),N3$4=Math.pow(2,21),N4$4=Math.pow(2,28),N5$4=Math.pow(2,35),N6$4=Math.pow(2,42),N7$4=Math.pow(2,49),N8$4=Math.pow(2,56),N9$4=Math.pow(2,63),length$4=function(et){return et{const[dt,ht]=decode$M(o.subarray(tt));return tt+=ht,dt};let nt=rt(),ot=DAG_PB_CODE$2;if(nt===18?(nt=0,tt=0):ot=rt(),nt!==0&&nt!==1)throw new RangeError(`Invalid CID version ${nt}`);const it=tt,st=rt(),at=rt(),ct=tt+at,lt=ct-it;return{version:nt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(o,tt){const[rt,nt]=parseCIDtoBytes$2(o,tt),ot=Nr.decode(nt);if(ot.version===0&&o[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache$2(ot).set(rt,o),ot}};function parseCIDtoBytes$2(et,o){switch(et[0]){case"Q":{const tt=o??base58btc$h;return[base58btc$h.prefix,tt.decode(`${base58btc$h.prefix}${et}`)]}case base58btc$h.prefix:{const tt=o??base58btc$h;return[base58btc$h.prefix,tt.decode(et)]}case base32$u.prefix:{const tt=o??base32$u;return[base32$u.prefix,tt.decode(et)]}case base36$r.prefix:{const tt=o??base36$r;return[base36$r.prefix,tt.decode(et)]}default:{if(o==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[et[0],o.decode(et)]}}}function toStringV0$2(et,o,tt){const{prefix:rt}=tt;if(rt!==base58btc$h.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const nt=o.get(rt);if(nt==null){const ot=tt.encode(et).slice(1);return o.set(rt,ot),ot}else return nt}function toStringV1$2(et,o,tt){const{prefix:rt}=tt,nt=o.get(rt);if(nt==null){const ot=tt.encode(et);return o.set(rt,ot),ot}else return nt}const DAG_PB_CODE$2=112,SHA_256_CODE$2=18;function encodeCID$2(et,o,tt){const rt=encodingLength$4(et),nt=rt+encodingLength$4(o),ot=new Uint8Array(nt+tt.byteLength);return encodeTo$2(et,ot,0),encodeTo$2(o,ot,rt),ot.set(tt,nt),ot}const cidSymbol$2=Symbol.for("@ipld/js-cid/CID"),code$2=0,name$4="identity",encode$E=coerce$h;function digest$1(et){return create$5(code$2,encode$E(et))}const identity$f={code:code$2,name:name$4,encode:encode$E,digest:digest$1};function equals$9(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;ttBigInt(et))),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends HashMD{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(){const{Ah:o,Al:tt,Bh:rt,Bl:nt,Ch:ot,Cl:it,Dh:st,Dl:at,Eh:ct,El:lt,Fh:dt,Fl:ht,Gh:mt,Gl:ft,Hh:pt,Hl:yt}=this;return[o,tt,rt,nt,ot,it,st,at,ct,lt,dt,ht,mt,ft,pt,yt]}set(o,tt,rt,nt,ot,it,st,at,ct,lt,dt,ht,mt,ft,pt,yt){this.Ah=o|0,this.Al=tt|0,this.Bh=rt|0,this.Bl=nt|0,this.Ch=ot|0,this.Cl=it|0,this.Dh=st|0,this.Dl=at|0,this.Eh=ct|0,this.El=lt|0,this.Fh=dt|0,this.Fl=ht|0,this.Gh=mt|0,this.Gl=ft|0,this.Hh=pt|0,this.Hl=yt|0}process(o,tt){for(let xt=0;xt<16;xt++,tt+=4)SHA512_W_H[xt]=o.getUint32(tt),SHA512_W_L[xt]=o.getUint32(tt+=4);for(let xt=16;xt<80;xt++){const vt=SHA512_W_H[xt-15]|0,Et=SHA512_W_L[xt-15]|0,Ct=u64.rotrSH(vt,Et,1)^u64.rotrSH(vt,Et,8)^u64.shrSH(vt,Et,7),St=u64.rotrSL(vt,Et,1)^u64.rotrSL(vt,Et,8)^u64.shrSL(vt,Et,7),At=SHA512_W_H[xt-2]|0,kt=SHA512_W_L[xt-2]|0,It=u64.rotrSH(At,kt,19)^u64.rotrBH(At,kt,61)^u64.shrSH(At,kt,6),Nt=u64.rotrSL(At,kt,19)^u64.rotrBL(At,kt,61)^u64.shrSL(At,kt,6),Lt=u64.add4L(St,Nt,SHA512_W_L[xt-7],SHA512_W_L[xt-16]),Mt=u64.add4H(Lt,Ct,It,SHA512_W_H[xt-7],SHA512_W_H[xt-16]);SHA512_W_H[xt]=Mt|0,SHA512_W_L[xt]=Lt|0}let{Ah:rt,Al:nt,Bh:ot,Bl:it,Ch:st,Cl:at,Dh:ct,Dl:lt,Eh:dt,El:ht,Fh:mt,Fl:ft,Gh:pt,Gl:yt,Hh:gt,Hl:bt}=this;for(let xt=0;xt<80;xt++){const vt=u64.rotrSH(dt,ht,14)^u64.rotrSH(dt,ht,18)^u64.rotrBH(dt,ht,41),Et=u64.rotrSL(dt,ht,14)^u64.rotrSL(dt,ht,18)^u64.rotrBL(dt,ht,41),Ct=dt&mt^~dt&pt,St=ht&ft^~ht&yt,At=u64.add5L(bt,Et,St,SHA512_Kl[xt],SHA512_W_L[xt]),kt=u64.add5H(At,gt,vt,Ct,SHA512_Kh[xt],SHA512_W_H[xt]),It=At|0,Nt=u64.rotrSH(rt,nt,28)^u64.rotrBH(rt,nt,34)^u64.rotrBH(rt,nt,39),Lt=u64.rotrSL(rt,nt,28)^u64.rotrBL(rt,nt,34)^u64.rotrBL(rt,nt,39),Mt=rt&ot^rt&st^ot&st,zt=nt&it^nt&at^it&at;gt=pt|0,bt=yt|0,pt=mt|0,yt=ft|0,mt=dt|0,ft=ht|0,{h:dt,l:ht}=u64.add(ct|0,lt|0,kt|0,It|0),ct=st|0,lt=at|0,st=ot|0,at=it|0,ot=rt|0,it=nt|0;const Ut=u64.add3L(It,Lt,zt);rt=u64.add3H(Ut,kt,Nt,Mt),nt=Ut|0}({h:rt,l:nt}=u64.add(this.Ah|0,this.Al|0,rt|0,nt|0)),{h:ot,l:it}=u64.add(this.Bh|0,this.Bl|0,ot|0,it|0),{h:st,l:at}=u64.add(this.Ch|0,this.Cl|0,st|0,at|0),{h:ct,l:lt}=u64.add(this.Dh|0,this.Dl|0,ct|0,lt|0),{h:dt,l:ht}=u64.add(this.Eh|0,this.El|0,dt|0,ht|0),{h:mt,l:ft}=u64.add(this.Fh|0,this.Fl|0,mt|0,ft|0),{h:pt,l:yt}=u64.add(this.Gh|0,this.Gl|0,pt|0,yt|0),{h:gt,l:bt}=u64.add(this.Hh|0,this.Hl|0,gt|0,bt|0),this.set(rt,nt,ot,it,st,at,ct,lt,dt,ht,mt,ft,pt,yt,gt,bt)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.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)}}const sha512=wrapConstructor(()=>new SHA512);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$3=BigInt(1),_2n$2=BigInt(2),_8n$2=BigInt(8),VERIFY_DEFAULT={zip215:!0};function validateOpts$1(et){const o=validateBasic(et);return validateObject(et,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...o})}function twistedEdwards(et){const o=validateOpts$1(et),{Fp:tt,n:rt,prehash:nt,hash:ot,randomBytes:it,nByteLength:st,h:at}=o,ct=_2n$2<{try{return{isValid:!0,value:tt.sqrt(Xt*tt.inv(Wt))}}catch{return{isValid:!1,value:_0n$2}}}),mt=o.adjustScalarBytes||(Xt=>Xt),ft=o.domain||((Xt,Wt,Ft)=>{if(abool("phflag",Ft),Wt.length||Ft)throw new Error("Contexts/pre-hash are not supported");return Xt});function pt(Xt,Wt){aInRange("coordinate "+Xt,Wt,_0n$2,ct)}function yt(Xt){if(!(Xt instanceof xt))throw new Error("ExtendedPoint expected")}const gt=memoized((Xt,Wt)=>{const{ex:Ft,ey:qt,ez:Pt}=Xt,Yt=Xt.is0();Wt==null&&(Wt=Yt?_8n$2:tt.inv(Pt));const Qt=lt(Ft*Wt),jt=lt(qt*Wt),Gt=lt(Pt*Wt);if(Yt)return{x:_0n$2,y:_1n$3};if(Gt!==_1n$3)throw new Error("invZ was invalid");return{x:Qt,y:jt}}),bt=memoized(Xt=>{const{a:Wt,d:Ft}=o;if(Xt.is0())throw new Error("bad point: ZERO");const{ex:qt,ey:Pt,ez:Yt,et:Qt}=Xt,jt=lt(qt*qt),Gt=lt(Pt*Pt),rr=lt(Yt*Yt),Ht=lt(rr*rr),dr=lt(jt*Wt),Zt=lt(rr*lt(dr+Gt)),Jt=lt(Ht+lt(Ft*lt(jt*Gt)));if(Zt!==Jt)throw new Error("bad point: equation left != right (1)");const tr=lt(qt*Pt),_t=lt(Yt*Qt);if(tr!==_t)throw new Error("bad point: equation left != right (2)");return!0});class xt{constructor(Wt,Ft,qt,Pt){this.ex=Wt,this.ey=Ft,this.ez=qt,this.et=Pt,pt("x",Wt),pt("y",Ft),pt("z",qt),pt("t",Pt),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(Wt){if(Wt instanceof xt)throw new Error("extended point not allowed");const{x:Ft,y:qt}=Wt||{};return pt("x",Ft),pt("y",qt),new xt(Ft,qt,_1n$3,lt(Ft*qt))}static normalizeZ(Wt){const Ft=tt.invertBatch(Wt.map(qt=>qt.ez));return Wt.map((qt,Pt)=>qt.toAffine(Ft[Pt])).map(xt.fromAffine)}static msm(Wt,Ft){return pippenger(xt,dt,Wt,Ft)}_setWindowSize(Wt){Ct.setWindowSize(this,Wt)}assertValidity(){bt(this)}equals(Wt){yt(Wt);const{ex:Ft,ey:qt,ez:Pt}=this,{ex:Yt,ey:Qt,ez:jt}=Wt,Gt=lt(Ft*jt),rr=lt(Yt*Pt),Ht=lt(qt*jt),dr=lt(Qt*Pt);return Gt===rr&&Ht===dr}is0(){return this.equals(xt.ZERO)}negate(){return new xt(lt(-this.ex),this.ey,this.ez,lt(-this.et))}double(){const{a:Wt}=o,{ex:Ft,ey:qt,ez:Pt}=this,Yt=lt(Ft*Ft),Qt=lt(qt*qt),jt=lt(_2n$2*lt(Pt*Pt)),Gt=lt(Wt*Yt),rr=Ft+qt,Ht=lt(lt(rr*rr)-Yt-Qt),dr=Gt+Qt,Zt=dr-jt,Jt=Gt-Qt,tr=lt(Ht*Zt),_t=lt(dr*Jt),Bt=lt(Ht*Jt),Vt=lt(Zt*dr);return new xt(tr,_t,Vt,Bt)}add(Wt){yt(Wt);const{a:Ft,d:qt}=o,{ex:Pt,ey:Yt,ez:Qt,et:jt}=this,{ex:Gt,ey:rr,ez:Ht,et:dr}=Wt;if(Ft===BigInt(-1)){const pr=lt((Yt-Pt)*(rr+Gt)),wr=lt((Yt+Pt)*(rr-Gt)),_r=lt(wr-pr);if(_r===_0n$2)return this.double();const Tr=lt(Qt*_2n$2*dr),gr=lt(jt*_2n$2*Ht),vr=gr+Tr,ir=wr+pr,Tt=gr-Tr,$t=lt(vr*_r),Rt=lt(ir*Tt),Dt=lt(vr*Tt),Kt=lt(_r*ir);return new xt($t,Rt,Kt,Dt)}const Zt=lt(Pt*Gt),Jt=lt(Yt*rr),tr=lt(jt*qt*dr),_t=lt(Qt*Ht),Bt=lt((Pt+Yt)*(Gt+rr)-Zt-Jt),Vt=_t-tr,er=_t+tr,ar=lt(Jt-Ft*Zt),ur=lt(Bt*Vt),cr=lt(er*ar),hr=lt(Bt*ar),Sr=lt(Vt*er);return new xt(ur,cr,Sr,hr)}subtract(Wt){return this.add(Wt.negate())}wNAF(Wt){return Ct.wNAFCached(this,Wt,xt.normalizeZ)}multiply(Wt){const Ft=Wt;aInRange("scalar",Ft,_1n$3,rt);const{p:qt,f:Pt}=this.wNAF(Ft);return xt.normalizeZ([qt,Pt])[0]}multiplyUnsafe(Wt){const Ft=Wt;return aInRange("scalar",Ft,_0n$2,rt),Ft===_0n$2?Et:this.equals(Et)||Ft===_1n$3?this:this.equals(vt)?this.wNAF(Ft).p:Ct.unsafeLadder(this,Ft)}isSmallOrder(){return this.multiplyUnsafe(at).is0()}isTorsionFree(){return Ct.unsafeLadder(this,rt).is0()}toAffine(Wt){return gt(this,Wt)}clearCofactor(){const{h:Wt}=o;return Wt===_1n$3?this:this.multiplyUnsafe(Wt)}static fromHex(Wt,Ft=!1){const{d:qt,a:Pt}=o,Yt=tt.BYTES;Wt=ensureBytes$1("pointHex",Wt,Yt),abool("zip215",Ft);const Qt=Wt.slice(),jt=Wt[Yt-1];Qt[Yt-1]=jt&-129;const Gt=bytesToNumberLE(Qt),rr=Ft?ct:tt.ORDER;aInRange("pointHex.y",Gt,_0n$2,rr);const Ht=lt(Gt*Gt),dr=lt(Ht-_1n$3),Zt=lt(qt*Ht-Pt);let{isValid:Jt,value:tr}=ht(dr,Zt);if(!Jt)throw new Error("Point.fromHex: invalid y coordinate");const _t=(tr&_1n$3)===_1n$3,Bt=(jt&128)!==0;if(!Ft&&tr===_0n$2&&Bt)throw new Error("Point.fromHex: x=0 and x_0=1");return Bt!==_t&&(tr=lt(-tr)),xt.fromAffine({x:tr,y:Gt})}static fromPrivateKey(Wt){return kt(Wt).point}toRawBytes(){const{x:Wt,y:Ft}=this.toAffine(),qt=numberToBytesLE(Ft,tt.BYTES);return qt[qt.length-1]|=Wt&_1n$3?128:0,qt}toHex(){return bytesToHex$2(this.toRawBytes())}}xt.BASE=new xt(o.Gx,o.Gy,_1n$3,lt(o.Gx*o.Gy)),xt.ZERO=new xt(_0n$2,_1n$3,_1n$3,_0n$2);const{BASE:vt,ZERO:Et}=xt,Ct=wNAF(xt,st*8);function St(Xt){return mod$1(Xt,rt)}function At(Xt){return St(bytesToNumberLE(Xt))}function kt(Xt){const Wt=st;Xt=ensureBytes$1("private key",Xt,Wt);const Ft=ensureBytes$1("hashed private key",ot(Xt),2*Wt),qt=mt(Ft.slice(0,Wt)),Pt=Ft.slice(Wt,2*Wt),Yt=At(qt),Qt=vt.multiply(Yt),jt=Qt.toRawBytes();return{head:qt,prefix:Pt,scalar:Yt,point:Qt,pointBytes:jt}}function It(Xt){return kt(Xt).pointBytes}function Nt(Xt=new Uint8Array,...Wt){const Ft=concatBytes$1(...Wt);return At(ot(ft(Ft,ensureBytes$1("context",Xt),!!nt)))}function Lt(Xt,Wt,Ft={}){Xt=ensureBytes$1("message",Xt),nt&&(Xt=nt(Xt));const{prefix:qt,scalar:Pt,pointBytes:Yt}=kt(Wt),Qt=Nt(Ft.context,qt,Xt),jt=vt.multiply(Qt).toRawBytes(),Gt=Nt(Ft.context,jt,Yt,Xt),rr=St(Qt+Gt*Pt);aInRange("signature.s",rr,_0n$2,rt);const Ht=concatBytes$1(jt,numberToBytesLE(rr,tt.BYTES));return ensureBytes$1("result",Ht,st*2)}const Mt=VERIFY_DEFAULT;function zt(Xt,Wt,Ft,qt=Mt){const{context:Pt,zip215:Yt}=qt,Qt=tt.BYTES;Xt=ensureBytes$1("signature",Xt,2*Qt),Wt=ensureBytes$1("message",Wt),Yt!==void 0&&abool("zip215",Yt),nt&&(Wt=nt(Wt));const jt=bytesToNumberLE(Xt.slice(Qt,2*Qt));let Gt,rr,Ht;try{Gt=xt.fromHex(Ft,Yt),rr=xt.fromHex(Xt.slice(0,Qt),Yt),Ht=vt.multiplyUnsafe(jt)}catch{return!1}if(!Yt&&Gt.isSmallOrder())return!1;const dr=Nt(Pt,rr.toRawBytes(),Gt.toRawBytes(),Wt);return rr.add(Gt.multiplyUnsafe(dr)).subtract(Ht).clearCofactor().equals(xt.ZERO)}return vt._setWindowSize(8),{CURVE:o,getPublicKey:It,sign:Lt,verify:zt,ExtendedPoint:xt,utils:{getExtendedPublicKey:kt,randomPrivateKey:()=>it(tt.BYTES),precompute(Xt=8,Wt=xt.BASE){return Wt._setWindowSize(Xt),Wt.multiply(BigInt(3)),Wt}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$2=BigInt(1);function validateOpts(et){return validateObject(et,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...et})}function montgomery(et){const o=validateOpts(et),{P:tt}=o,rt=bt=>mod$1(bt,tt),nt=o.montgomeryBits,ot=Math.ceil(nt/8),it=o.nByteLength,st=o.adjustScalarBytes||(bt=>bt),at=o.powPminus2||(bt=>pow(bt,tt-BigInt(2),tt));function ct(bt,xt,vt){const Et=rt(bt*(xt-vt));return xt=rt(xt-Et),vt=rt(vt+Et),[xt,vt]}const lt=(o.a-BigInt(2))/BigInt(4);function dt(bt,xt){aInRange("u",bt,_0n$1,tt),aInRange("scalar",xt,_0n$1,tt);const vt=xt,Et=bt;let Ct=_1n$2,St=_0n$1,At=bt,kt=_1n$2,It=_0n$1,Nt;for(let Mt=BigInt(nt-1);Mt>=_0n$1;Mt--){const zt=vt>>Mt&_1n$2;It^=zt,Nt=ct(It,Ct,At),Ct=Nt[0],At=Nt[1],Nt=ct(It,St,kt),St=Nt[0],kt=Nt[1],It=zt;const Ut=Ct+St,Xt=rt(Ut*Ut),Wt=Ct-St,Ft=rt(Wt*Wt),qt=Xt-Ft,Pt=At+kt,Yt=At-kt,Qt=rt(Yt*Ut),jt=rt(Pt*Wt),Gt=Qt+jt,rr=Qt-jt;At=rt(Gt*Gt),kt=rt(Et*rt(rr*rr)),Ct=rt(Xt*Ft),St=rt(qt*(Xt+rt(lt*qt)))}Nt=ct(It,Ct,At),Ct=Nt[0],At=Nt[1],Nt=ct(It,St,kt),St=Nt[0],kt=Nt[1];const Lt=at(St);return rt(Ct*Lt)}function ht(bt){return numberToBytesLE(rt(bt),ot)}function mt(bt){const xt=ensureBytes$1("u coordinate",bt,ot);return it===32&&(xt[31]&=127),bytesToNumberLE(xt)}function ft(bt){const xt=ensureBytes$1("scalar",bt),vt=xt.length;if(vt!==ot&&vt!==it)throw new Error(`Expected ${ot} or ${it} bytes, got ${vt}`);return bytesToNumberLE(st(xt))}function pt(bt,xt){const vt=mt(xt),Et=ft(bt),Ct=dt(vt,Et);if(Ct===_0n$1)throw new Error("Invalid private or public key received");return ht(Ct)}const yt=ht(o.Gu);function gt(bt){return pt(bt,yt)}return{scalarMult:pt,scalarMultBase:gt,getSharedSecret:(bt,xt)=>pt(bt,xt),getPublicKey:bt=>gt(bt),utils:{randomPrivateKey:()=>o.randomBytes(o.nByteLength)},GuBytes:yt}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ED25519_P=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _1n$1=BigInt(1),_2n$1=BigInt(2),_3n$1=BigInt(3),_5n=BigInt(5),_8n$1=BigInt(8);function ed25519_pow_2_252_3(et){const o=BigInt(10),tt=BigInt(20),rt=BigInt(40),nt=BigInt(80),ot=ED25519_P,st=et*et%ot*et%ot,at=pow2$1(st,_2n$1,ot)*st%ot,ct=pow2$1(at,_1n$1,ot)*et%ot,lt=pow2$1(ct,_5n,ot)*ct%ot,dt=pow2$1(lt,o,ot)*lt%ot,ht=pow2$1(dt,tt,ot)*dt%ot,mt=pow2$1(ht,rt,ot)*ht%ot,ft=pow2$1(mt,nt,ot)*mt%ot,pt=pow2$1(ft,nt,ot)*mt%ot,yt=pow2$1(pt,o,ot)*lt%ot;return{pow_p_5_8:pow2$1(yt,_2n$1,ot)*et%ot,b2:st}}function adjustScalarBytes(et){return et[0]&=248,et[31]&=127,et[31]|=64,et}function uvRatio(et,o){const tt=ED25519_P,rt=mod$1(o*o*o,tt),nt=mod$1(rt*rt*o,tt),ot=ed25519_pow_2_252_3(et*nt).pow_p_5_8;let it=mod$1(et*rt*ot,tt);const st=mod$1(o*it*it,tt),at=it,ct=mod$1(it*ED25519_SQRT_M1,tt),lt=st===et,dt=st===mod$1(-et,tt),ht=st===mod$1(-et*ED25519_SQRT_M1,tt);return lt&&(it=at),(dt||ht)&&(it=ct),isNegativeLE(it,tt)&&(it=mod$1(-it,tt)),{isValid:lt||dt,value:it}}const Fp=Field$1(ED25519_P,void 0,!0),ed25519Defaults={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_8n$1,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sha512,randomBytes:randomBytes$1,adjustScalarBytes,uvRatio},ed25519=twistedEdwards(ed25519Defaults),x25519=montgomery({P:ED25519_P,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:et=>{const o=ED25519_P,{pow_p_5_8:tt,b2:rt}=ed25519_pow_2_252_3(et);return mod$1(pow2$1(tt,_3n$1,o)*rt,o)},adjustScalarBytes,randomBytes:randomBytes$1}),PUBLIC_KEY_BYTE_LENGTH=32,PRIVATE_KEY_BYTE_LENGTH=64,KEYS_BYTE_LENGTH=32;function generateKey(){const et=ed25519.utils.randomPrivateKey(),o=ed25519.getPublicKey(et);return{privateKey:concatKeys(et,o),publicKey:o}}function hashAndSign(et,o){const tt=et.subarray(0,KEYS_BYTE_LENGTH);return ed25519.sign(o instanceof Uint8Array?o:o.subarray(),tt)}function hashAndVerify$2(et,o,tt){return ed25519.verify(o,tt instanceof Uint8Array?tt:tt.subarray(),et)}function concatKeys(et,o){const tt=new Uint8Array(PRIVATE_KEY_BYTE_LENGTH);for(let rt=0;rtenumeration(__KeyTypeValues)})(KeyType||(KeyType={}));var PublicKey;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.Type!=null&&(rt.uint32(8),KeyType.codec().encode(tt.Type,rt)),tt.Data!=null&&(rt.uint32(18),rt.bytes(tt.Data)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.Type=KeyType.codec().decode(tt);break}case 2:{ot.Data=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PublicKey||(PublicKey={}));var PrivateKey;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.Type!=null&&(rt.uint32(8),KeyType.codec().encode(tt.Type,rt)),tt.Data!=null&&(rt.uint32(18),rt.bytes(tt.Data)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.Type=KeyType.codec().decode(tt);break}case 2:{ot.Data=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PrivateKey||(PrivateKey={}));/*! * MIT License * * Copyright (c) 2017-2022 Peculiar Ventures, LLC @@ -3934,27 +3934,27 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C `).map(nt=>` ${nt}`).join(` `));const tt=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return o.length?`${tt} : ${o.join(` -`)}`:`${tt} :`}}_a$v=Constructed;typeStore.Constructed=_a$v;Constructed.NAME="CONSTRUCTED";class LocalEndOfContentValueBlock extends ValueBlock{fromBER(o,tt,rt){return tt}toBER(o){return EMPTY_BUFFER$1}}LocalEndOfContentValueBlock.override="EndOfContentValueBlock";var _a$u;class EndOfContent extends BaseBlock{constructor(o={}){super(o,LocalEndOfContentValueBlock),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}_a$u=EndOfContent;typeStore.EndOfContent=_a$u;EndOfContent.NAME=END_OF_CONTENT_NAME;var _a$t;class Null extends BaseBlock{constructor(o={}){super(o,ValueBlock),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(o,tt,rt){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=rt,tt+rt>o.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):tt+rt}toBER(o,tt){const rt=new ArrayBuffer(2);if(!o){const nt=new Uint8Array(rt);nt[0]=5,nt[1]=0}return tt&&tt.write(rt),rt}onAsciiEncoding(){return`${this.constructor.NAME}`}}_a$t=Null;typeStore.Null=_a$t;Null.NAME="NULL";class LocalBooleanValueBlock extends HexBlock(ValueBlock){constructor({value:o,...tt}={}){super(tt),tt.valueHex?this.valueHexView=BufferSourceConverter.toUint8Array(tt.valueHex):this.valueHexView=new Uint8Array(1),o&&(this.value=o)}get value(){for(const o of this.valueHexView)if(o>0)return!0;return!1}set value(o){this.valueHexView[0]=o?255:0}fromBER(o,tt,rt){const nt=BufferSourceConverter.toUint8Array(o);return checkBufferParams(this,nt,tt,rt)?(this.valueHexView=nt.subarray(tt,tt+rt),rt>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,utilDecodeTC.call(this),this.blockLength=rt,tt+rt):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}LocalBooleanValueBlock.NAME="BooleanValueBlock";var _a$s;let Boolean$1=class extends BaseBlock{constructor(o={}){super(o,LocalBooleanValueBlock),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(o){this.valueBlock.value=o}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};_a$s=Boolean$1;typeStore.Boolean=_a$s;Boolean$1.NAME="BOOLEAN";class LocalOctetStringValueBlock extends HexBlock(LocalConstructedValueBlock){constructor({isConstructed:o=!1,...tt}={}){super(tt),this.isConstructed=o}fromBER(o,tt,rt){let nt=0;if(this.isConstructed){if(this.isHexOnly=!1,nt=LocalConstructedValueBlock.prototype.fromBER.call(this,o,tt,rt),nt===-1)return nt;for(let ot=0;ot0&&ct.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=ct.unusedBits}return nt}const ot=BufferSourceConverter.toUint8Array(o);if(!checkBufferParams(this,ot,tt,rt))return-1;const it=ot.subarray(tt,tt+rt);if(this.unusedBits=it[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const st=it.subarray(1);try{if(st.byteLength){const at=localFromBER(st,0,st.byteLength);at.offset!==-1&&at.offset===rt-1&&(this.value=[at.result])}}catch{}}return this.valueHexView=it.subarray(1),this.blockLength=it.length,tt+rt}toBER(o,tt){if(this.isConstructed)return LocalConstructedValueBlock.prototype.toBER.call(this,o,tt);if(o)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return EMPTY_BUFFER$1;const rt=new Uint8Array(this.valueHexView.length+1);return rt[0]=this.unusedBits,rt.set(this.valueHexView,1),rt.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}LocalBitStringValueBlock.NAME="BitStringValueBlock";var _a$q;class BitString extends BaseBlock{constructor({idBlock:o={},lenBlock:tt={},...rt}={}){var nt,ot;(nt=rt.isConstructed)!==null&&nt!==void 0||(rt.isConstructed=!!(!((ot=rt.value)===null||ot===void 0)&&ot.length)),super({idBlock:{isConstructed:rt.isConstructed,...o},lenBlock:{...tt,isIndefiniteForm:!!rt.isIndefiniteForm},...rt},LocalBitStringValueBlock),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(o,tt,rt){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(o,tt,rt)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Constructed.prototype.onAsciiEncoding.call(this);{const o=[],tt=this.valueBlock.valueHexView;for(const nt of tt)o.push(nt.toString(2).padStart(8,"0"));const rt=o.join("");return`${this.constructor.NAME} : ${rt.substring(0,rt.length-this.valueBlock.unusedBits)}`}}}_a$q=BitString;typeStore.BitString=_a$q;BitString.NAME=BIT_STRING_NAME;var _a$p;function viewAdd(et,o){const tt=new Uint8Array([0]),rt=new Uint8Array(et),nt=new Uint8Array(o);let ot=rt.slice(0);const it=ot.length-1,st=nt.slice(0),at=st.length-1;let ct=0;const lt=at=0;ht--,dt++){switch(!0){case dt=ot.length:ot=utilConcatView(new Uint8Array([ct%10]),ot);break;default:ot[it-dt]=ct%10}}return tt[0]>0&&(ot=utilConcatView(tt,ot)),ot}function power2(et){if(et>=powers2.length)for(let o=powers2.length;o<=et;o++){const tt=new Uint8Array([0]);let rt=powers2[o-1].slice(0);for(let nt=rt.length-1;nt>=0;nt--){const ot=new Uint8Array([(rt[nt]<<1)+tt[0]]);tt[0]=ot[0]/10,rt[nt]=ot[0]%10}tt[0]>0&&(rt=utilConcatView(tt,rt)),powers2.push(rt)}return powers2[et]}function viewSub(et,o){let tt=0;const rt=new Uint8Array(et),nt=new Uint8Array(o),ot=rt.slice(0),it=ot.length-1,st=nt.slice(0),at=st.length-1;let ct,lt=0;for(let dt=at;dt>=0;dt--,lt++)switch(ct=ot[it-lt]-st[at-lt]-tt,!0){case ct<0:tt=1,ot[it-lt]=ct+10;break;default:tt=0,ot[it-lt]=ct}if(tt>0)for(let dt=it-at+1;dt>=0;dt--,lt++)if(ct=ot[it-lt]-tt,ct<0)tt=1,ot[it-lt]=ct+10;else{tt=0,ot[it-lt]=ct;break}return ot.slice()}class LocalIntegerValueBlock extends HexBlock(ValueBlock){constructor({value:o,...tt}={}){super(tt),this._valueDec=0,tt.valueHex&&this.setValueHex(),o!==void 0&&(this.valueDec=o)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=utilDecodeTC.call(this)))}set valueDec(o){this._valueDec=o,this.isHexOnly=!1,this.valueHexView=new Uint8Array(utilEncodeTC(o))}get valueDec(){return this._valueDec}fromDER(o,tt,rt,nt=0){const ot=this.fromBER(o,tt,rt);if(ot===-1)return ot;const it=this.valueHexView;return it[0]===0&&it[1]&128?this.valueHexView=it.subarray(1):nt!==0&&it.length1&&(nt=it.length+1),this.valueHexView=it.subarray(nt-it.length)),ot}toDER(o=!1){const tt=this.valueHexView;switch(!0){case(tt[0]&128)!==0:{const rt=new Uint8Array(this.valueHexView.length+1);rt[0]=0,rt.set(tt,1),this.valueHexView=rt}break;case(tt[0]===0&&(tt[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(o)}fromBER(o,tt,rt){const nt=super.fromBER(o,tt,rt);return nt===-1||this.setValueHex(),nt}toBER(o){return o?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const o=this.valueHexView.length*8-1;let tt=new Uint8Array(this.valueHexView.length*8/3),rt=0,nt;const ot=this.valueHexView;let it="",st=!1;for(let at=ot.byteLength-1;at>=0;at--){nt=ot[at];for(let ct=0;ct<8;ct++){if((nt&1)===1)switch(rt){case o:tt=viewSub(power2(rt),tt),it="-";break;default:tt=viewAdd(tt,power2(rt))}rt++,nt>>=1}}for(let at=0;at0;){const ot=new LocalSidValueBlock;if(nt=ot.fromBER(o,nt,rt),nt===-1)return this.blockLength=0,this.error=ot.error,nt;this.value.length===0&&(ot.isFirstSid=!0),this.blockLength+=ot.blockLength,rt-=ot.blockLength,this.value.push(ot)}return nt}toBER(o){const tt=[];for(let rt=0;rtNumber.MAX_SAFE_INTEGER){assertBigInt();const st=BigInt(nt);it.valueBigInt=st}else if(it.valueDec=parseInt(nt,10),isNaN(it.valueDec))return;this.value.length||(it.isFirstSid=!0,ot=!0),this.value.push(it)}while(rt!==-1)}toString(){let o="",tt=!1;for(let rt=0;rt0;){const ot=new LocalRelativeSidValueBlock;if(nt=ot.fromBER(o,nt,rt),nt===-1)return this.blockLength=0,this.error=ot.error,nt;this.blockLength+=ot.blockLength,rt-=ot.blockLength,this.value.push(ot)}return nt}toBER(o,tt){const rt=[];for(let nt=0;nt4)continue;const st=4-it.length;for(let at=it.length-1;at>=0;at--)rt[nt*4+at+st]=it[at]}this.valueBlock.value=o}}LocalUniversalStringValueBlock.NAME="UniversalStringValueBlock";var _a$g;class UniversalString extends LocalUniversalStringValueBlock{constructor({...o}={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}_a$g=UniversalString;typeStore.UniversalString=_a$g;UniversalString.NAME="UniversalString";var _a$f;class NumericString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}_a$f=NumericString;typeStore.NumericString=_a$f;NumericString.NAME="NumericString";var _a$e;class PrintableString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}_a$e=PrintableString;typeStore.PrintableString=_a$e;PrintableString.NAME="PrintableString";var _a$d;class TeletexString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}_a$d=TeletexString;typeStore.TeletexString=_a$d;TeletexString.NAME="TeletexString";var _a$c;class VideotexString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}_a$c=VideotexString;typeStore.VideotexString=_a$c;VideotexString.NAME="VideotexString";var _a$b;class IA5String extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}_a$b=IA5String;typeStore.IA5String=_a$b;IA5String.NAME="IA5String";var _a$a;class GraphicString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}_a$a=GraphicString;typeStore.GraphicString=_a$a;GraphicString.NAME="GraphicString";var _a$9;class VisibleString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}_a$9=VisibleString;typeStore.VisibleString=_a$9;VisibleString.NAME="VisibleString";var _a$8;class GeneralString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}_a$8=GeneralString;typeStore.GeneralString=_a$8;GeneralString.NAME="GeneralString";var _a$7;class CharacterString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}_a$7=CharacterString;typeStore.CharacterString=_a$7;CharacterString.NAME="CharacterString";var _a$6;class UTCTime extends VisibleString{constructor({value:o,valueDate:tt,...rt}={}){if(super(rt),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,o){this.fromString(o),this.valueBlock.valueHexView=new Uint8Array(o.length);for(let nt=0;nt=50?this.year=1900+nt:this.year=2e3+nt,this.month=parseInt(rt[2],10),this.day=parseInt(rt[3],10),this.hour=parseInt(rt[4],10),this.minute=parseInt(rt[5],10),this.second=parseInt(rt[6],10)}toString(o="iso"){if(o==="iso"){const tt=new Array(7);return tt[0]=padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),tt[1]=padNumber(this.month,2),tt[2]=padNumber(this.day,2),tt[3]=padNumber(this.hour,2),tt[4]=padNumber(this.minute,2),tt[5]=padNumber(this.second,2),tt[6]="Z",tt.join("")}return super.toString(o)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}_a$6=UTCTime;typeStore.UTCTime=_a$6;UTCTime.NAME="UTCTime";var _a$5;class GeneralizedTime extends UTCTime{constructor(o={}){var tt;super(o),(tt=this.millisecond)!==null&&tt!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(o){super.fromDate(o),this.millisecond=o.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(o){let tt=!1,rt="",nt="",ot=0,it,st=0,at=0;if(o[o.length-1]==="Z")rt=o.substring(0,o.length-1),tt=!0;else{const dt=new Number(o[o.length-1]);if(isNaN(dt.valueOf()))throw new Error("Wrong input string for conversion");rt=o}if(tt){if(rt.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(rt.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let dt=1,ht=rt.indexOf("+"),mt="";if(ht===-1&&(ht=rt.indexOf("-"),dt=-1),ht!==-1){if(mt=rt.substring(ht+1),rt=rt.substring(0,ht),mt.length!==2&&mt.length!==4)throw new Error("Wrong input string for conversion");let ft=parseInt(mt.substring(0,2),10);if(isNaN(ft.valueOf()))throw new Error("Wrong input string for conversion");if(st=dt*ft,mt.length===4){if(ft=parseInt(mt.substring(2,4),10),isNaN(ft.valueOf()))throw new Error("Wrong input string for conversion");at=dt*ft}}}let ct=rt.indexOf(".");if(ct===-1&&(ct=rt.indexOf(",")),ct!==-1){const dt=new Number(`0${rt.substring(ct)}`);if(isNaN(dt.valueOf()))throw new Error("Wrong input string for conversion");ot=dt.valueOf(),nt=rt.substring(0,ct)}else nt=rt;switch(!0){case nt.length===8:if(it=/(\d{4})(\d{2})(\d{2})/ig,ct!==-1)throw new Error("Wrong input string for conversion");break;case nt.length===10:if(it=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,ct!==-1){let dt=60*ot;this.minute=Math.floor(dt),dt=60*(dt-this.minute),this.second=Math.floor(dt),dt=1e3*(dt-this.second),this.millisecond=Math.floor(dt)}break;case nt.length===12:if(it=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,ct!==-1){let dt=60*ot;this.second=Math.floor(dt),dt=1e3*(dt-this.second),this.millisecond=Math.floor(dt)}break;case nt.length===14:if(it=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,ct!==-1){const dt=1e3*ot;this.millisecond=Math.floor(dt)}break;default:throw new Error("Wrong input string for conversion")}const lt=it.exec(nt);if(lt===null)throw new Error("Wrong input string for conversion");for(let dt=1;dt(et[tt]=o,et),[]),alphabetCharsToBytes$d=alphabet$d.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$D(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$d[tt],o),"")}function decode$K(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$d[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$q=from$k({prefix:"🚀",name:"base256emoji",encode:encode$D,decode:decode$K}),base256emoji$r=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$q},Symbol.toStringTag,{value:"Module"})),base64$t=rfc4648$g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$d=rfc4648$g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$e=rfc4648$g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$d=rfc4648$g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$u=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$t,base64pad:base64pad$d,base64url:base64url$e,base64urlpad:base64urlpad$d},Symbol.toStringTag,{value:"Module"})),base8$q=rfc4648$g({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$r=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$q},Symbol.toStringTag,{value:"Module"})),identity$e=from$k({prefix:"\0",name:"identity",encode:et=>toString$r(et),decode:et=>fromString$q(et)}),identityBase$d=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$e},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;function from$j({name:et,code:o,encode:tt}){return new Hasher$1(et,o,tt)}let Hasher$1=class{constructor(o,tt,rt){wt(this,"name");wt(this,"code");wt(this,"encode");this.name=o,this.code=tt,this.encode=rt}digest(o){if(o instanceof Uint8Array){const tt=this.encode(o);return tt instanceof Uint8Array?create$5(this.code,tt):tt.then(rt=>create$5(this.code,rt))}else throw Error("Unknown type, must be binary type")}};function sha$1(et){return async o=>new Uint8Array(await crypto.subtle.digest(et,o))}const sha256$1=from$j({name:"sha2-256",code:18,encode:sha$1("SHA-256")}),bases$d={...identityBase$d,...base2$r,...base8$r,...base10$r,...base16$r,...base32$v,...base36$s,...base58$d,...base64$u,...base256emoji$r};function allocUnsafe$c(et=0){return new Uint8Array(et)}function createCodec$d(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$h=createCodec$d("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$d=createCodec$d("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$c(et.length);for(let tt=0;tt0&&(o=`0${o}`);const tt=o.length/2,rt=new Uint8Array(tt);let nt=0,ot=0;for(;nt0&&(rt=`0${rt}`),o.push(rt)}),BigInt("0x"+o.join(""))}function pkixToRSAPublicKey(et){const o=pkixToJwk(et);if(rsaKeySize(o)>MAX_RSA_KEY_SIZE)throw new InvalidPublicKeyError("Key size is too large");const tt=sha256$3(PublicKey.encode({Type:KeyType.RSA,Data:et})),rt=create$5(SHA2_256_CODE,tt);return new RSAPublicKey(o,rt)}function isPromise$3(et){return et==null?!1:typeof et.then=="function"&&typeof et.catch=="function"&&typeof et.finally=="function"}function hashAndVerify(et,o,tt){const rt=sha256$1.digest(tt instanceof Uint8Array?tt:tt.subarray());if(isPromise$3(rt))return rt.then(({digest:nt})=>secp256k1.verify(o,nt,et)).catch(nt=>{throw new VerificationError(String(nt))});try{return secp256k1.verify(o,rt.digest,et)}catch(nt){throw new VerificationError(String(nt))}}class Secp256k1PublicKey{constructor(o){wt(this,"type","secp256k1");wt(this,"raw");wt(this,"_key");this._key=validateSecp256k1PublicKey(o),this.raw=compressSecp256k1PublicKey(this._key)}toMultihash(){return identity$f.digest(publicKeyToProtobuf(this))}toCID(){return CID$2.createV1(114,this.toMultihash())}toString(){return base58btc$h.encode(this.toMultihash().bytes).substring(1)}equals(o){return o==null||!(o.raw instanceof Uint8Array)?!1:equals$9(this.raw,o.raw)}verify(o,tt){return hashAndVerify(this._key,tt,o)}}function unmarshalSecp256k1PublicKey(et){return new Secp256k1PublicKey(et)}function compressSecp256k1PublicKey(et){return secp256k1.ProjectivePoint.fromHex(et).toRawBytes(!0)}function validateSecp256k1PublicKey(et){try{return secp256k1.ProjectivePoint.fromHex(et),et}catch(o){throw new InvalidPublicKeyError(String(o))}}async function generateKeyPair(et,o){return generateEd25519KeyPair()}function publicKeyFromProtobuf(et){const{Type:o,Data:tt}=PublicKey.decode(et),rt=tt??new Uint8Array;switch(o){case KeyType.RSA:return pkixToRSAPublicKey(rt);case KeyType.Ed25519:return unmarshalEd25519PublicKey(rt);case KeyType.secp256k1:return unmarshalSecp256k1PublicKey(rt);default:throw new UnsupportedKeyTypeError$1}}function publicKeyFromRaw(et){return et.byteLength===32?unmarshalEd25519PublicKey(et):et.byteLength===33?unmarshalSecp256k1PublicKey(et):pkixToRSAPublicKey(et)}function publicKeyFromMultihash(et){const{Type:o,Data:tt}=PublicKey.decode(et.digest),rt=tt??new Uint8Array;switch(o){case KeyType.Ed25519:return unmarshalEd25519PublicKey(rt);case KeyType.secp256k1:return unmarshalSecp256k1PublicKey(rt);default:throw new UnsupportedKeyTypeError$1}}function publicKeyToProtobuf(et){return PublicKey.encode({Type:KeyType[et.type],Data:et.raw})}const peerIdSymbol$2=Symbol.for("@libp2p/peer-id");var ps;let InvalidParametersError$2=(ps=class extends Error{constructor(o="Invalid parameters"){super(o),this.name="InvalidParametersError"}},wt(ps,"name","InvalidParametersError"),ps);class InvalidCIDError extends Error{constructor(o="Invalid CID"){super(o),this.name="InvalidCIDError"}}wt(InvalidCIDError,"name","InvalidCIDError");class InvalidMultihashError extends Error{constructor(o="Invalid Multihash"){super(o),this.name="InvalidMultihashError"}}wt(InvalidMultihashError,"name","InvalidMultihashError");class UnsupportedKeyTypeError extends Error{constructor(o="Unsupported key type"){super(o),this.name="UnsupportedKeyTypeError"}}wt(UnsupportedKeyTypeError,"name","UnsupportedKeyTypeError");function equals$8(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$h=base$h,_brrp__multiformats_scope_baseX$g=src$h;let Encoder$h=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$h=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$i(this,o)}},ComposedDecoder$g=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$i(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$i(et,o){return new ComposedDecoder$g({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$g=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$h(o,tt,rt),this.decoder=new Decoder$h(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$i({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$g(et,o,tt,rt)}function baseX$g({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$g(tt,et);return from$i({prefix:o,name:et,encode:rt,decode:ot=>coerce$h(nt(ot))})}function decode$J(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$C(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<=INT$3;)o[tt++]=et&255|MSB$5,et/=128;for(;et&MSBALL$3;)o[tt++]=et&255|MSB$5,et>>>=7;return o[tt]=et|0,encode$B.bytes=tt-rt+1,o}var decode$I=read$4,MSB$1$3=128,REST$1$3=127;function read$4(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$4.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$3)<=MSB$1$3);return read$4.bytes=ot-rt,tt}var N1$3=Math.pow(2,7),N2$3=Math.pow(2,14),N3$3=Math.pow(2,21),N4$3=Math.pow(2,28),N5$3=Math.pow(2,35),N6$3=Math.pow(2,42),N7$3=Math.pow(2,49),N8$3=Math.pow(2,56),N9$3=Math.pow(2,63),length$3=function(et){return et{const[dt,ht]=decode$H(o.subarray(tt));return tt+=ht,dt};let nt=rt(),ot=DAG_PB_CODE$1;if(nt===18?(nt=0,tt=0):ot=rt(),nt!==0&&nt!==1)throw new RangeError(`Invalid CID version ${nt}`);const it=tt,st=rt(),at=rt(),ct=tt+at,lt=ct-it;return{version:nt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(o,tt){const[rt,nt]=parseCIDtoBytes$1(o,tt),ot=Dr.decode(nt);if(ot.version===0&&o[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache$1(ot).set(rt,o),ot}};function parseCIDtoBytes$1(et,o){switch(et[0]){case"Q":{const tt=o??base58btc$g;return[base58btc$g.prefix,tt.decode(`${base58btc$g.prefix}${et}`)]}case base58btc$g.prefix:{const tt=o??base58btc$g;return[base58btc$g.prefix,tt.decode(et)]}case base32$s.prefix:{const tt=o??base32$s;return[base32$s.prefix,tt.decode(et)]}case base36$p.prefix:{const tt=o??base36$p;return[base36$p.prefix,tt.decode(et)]}default:{if(o==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[et[0],o.decode(et)]}}}function toStringV0$1(et,o,tt){const{prefix:rt}=tt;if(rt!==base58btc$g.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const nt=o.get(rt);if(nt==null){const ot=tt.encode(et).slice(1);return o.set(rt,ot),ot}else return nt}function toStringV1$1(et,o,tt){const{prefix:rt}=tt,nt=o.get(rt);if(nt==null){const ot=tt.encode(et);return o.set(rt,ot),ot}else return nt}const DAG_PB_CODE$1=112,SHA_256_CODE$1=18;function encodeCID$1(et,o,tt){const rt=encodingLength$3(et),nt=rt+encodingLength$3(o),ot=new Uint8Array(nt+tt.byteLength);return encodeTo$1(et,ot,0),encodeTo$1(o,ot,rt),ot.set(tt,nt),ot}const cidSymbol$1=Symbol.for("@ipld/js-cid/CID"),code$1=0,name$3="identity",encode$A=coerce$h;function digest(et){return create$4(code$1,encode$A(et))}const identity$d={code:code$1,name:name$3,encode:encode$A,digest};function from$h({name:et,code:o,encode:tt}){return new Hasher(et,o,tt)}class Hasher{constructor(o,tt,rt){wt(this,"name");wt(this,"code");wt(this,"encode");this.name=o,this.code=tt,this.encode=rt}digest(o){if(o instanceof Uint8Array){const tt=this.encode(o);return tt instanceof Uint8Array?create$4(this.code,tt):tt.then(rt=>create$4(this.code,rt))}else throw Error("Unknown type, must be binary type")}}function sha(et){return async o=>new Uint8Array(await crypto.subtle.digest(et,o))}const sha256=from$h({name:"sha2-256",code:18,encode:sha("SHA-256")}),base10$o=baseX$g({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$p=Object.freeze(Object.defineProperty({__proto__:null,base10:base10$o},Symbol.toStringTag,{value:"Module"})),base16$o=rfc4648$f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper$c=rfc4648$f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$p=Object.freeze(Object.defineProperty({__proto__:null,base16:base16$o,base16upper:base16upper$c},Symbol.toStringTag,{value:"Module"})),base2$o=rfc4648$f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$p=Object.freeze(Object.defineProperty({__proto__:null,base2:base2$o},Symbol.toStringTag,{value:"Module"})),alphabet$c=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),alphabetBytesToChars$c=alphabet$c.reduce((et,o,tt)=>(et[tt]=o,et),[]),alphabetCharsToBytes$c=alphabet$c.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$z(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$c[tt],o),"")}function decode$F(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$c[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$o=from$i({prefix:"🚀",name:"base256emoji",encode:encode$z,decode:decode$F}),base256emoji$p=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$o},Symbol.toStringTag,{value:"Module"})),base64$r=rfc4648$f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$c=rfc4648$f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$d=rfc4648$f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$c=rfc4648$f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$s=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$r,base64pad:base64pad$c,base64url:base64url$d,base64urlpad:base64urlpad$c},Symbol.toStringTag,{value:"Module"})),base8$o=rfc4648$f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$p=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$o},Symbol.toStringTag,{value:"Module"})),identity$c=from$i({prefix:"\0",name:"identity",encode:et=>toString$p(et),decode:et=>fromString$o(et)}),identityBase$c=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$c},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$c={...identityBase$c,...base2$p,...base8$p,...base10$p,...base16$p,...base32$t,...base36$q,...base58$c,...base64$s,...base256emoji$p};function allocUnsafe$b(et=0){return new Uint8Array(et)}function createCodec$c(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$g=createCodec$c("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$c=createCodec$c("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$b(et.length);for(let tt=0;tt{rt=()=>{it(nt)},o.addEventListener("abort",rt)})])}finally{rt!=null&&o.removeEventListener("abort",rt)}}class QueuelessPushable{constructor(){wt(this,"readNext");wt(this,"haveNext");wt(this,"ended");wt(this,"nextResult");this.ended=!1,this.readNext=pDefer(),this.haveNext=pDefer()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");const o=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=pDefer(),o}async throw(o){return this.ended=!0,o!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(o)),{done:!0,value:void 0}}async return(){const o={done:!0,value:void 0};return await this._push(void 0),o}async push(o,tt){await this._push(o,tt)}async end(o,tt){o!=null?await this.throw(o):await this._push(void 0,tt)}async _push(o,tt){if(o!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;o!=null?this.nextResult={done:!1,value:o}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=pDefer(),await raceSignal(this.readNext.promise,tt==null?void 0:tt.signal,tt)}}function queuelessPushable(){return new QueuelessPushable}class UnexpectedEOFError extends Error{constructor(){super(...arguments);wt(this,"name","UnexpectedEOFError");wt(this,"code","ERR_UNEXPECTED_EOF")}}class CodeError extends Error{constructor(tt,rt){super(tt);wt(this,"code");this.code=rt}}let AbortError$7=class extends CodeError{constructor(tt){super(tt,"ABORT_ERR");wt(this,"type");this.type="aborted",this.name="AbortError"}};function byteStream(et,o){const tt=queuelessPushable();et.sink(tt).catch(async it=>{await tt.end(it)}),et.sink=async it=>{for await(const st of it)await tt.push(st);await tt.end()};let rt=et.source;et.source[Symbol.iterator]!=null?rt=et.source[Symbol.iterator]():et.source[Symbol.asyncIterator]!=null&&(rt=et.source[Symbol.asyncIterator]());const nt=new Uint8ArrayList;return{read:async(it,st)=>{var lt,dt;(lt=st==null?void 0:st.signal)==null||lt.throwIfAborted();let at;const ct=new Promise((ht,mt)=>{var ft;at=()=>{mt(new AbortError$7("Read aborted"))},(ft=st==null?void 0:st.signal)==null||ft.addEventListener("abort",at)});try{if(it==null){const{done:mt,value:ft}=await Promise.race([rt.next(),ct]);return mt===!0?new Uint8ArrayList:ft}for(;nt.byteLength{var at;(at=st==null?void 0:st.signal)==null||at.throwIfAborted(),it instanceof Uint8Array?await tt.push(it,st):await tt.push(it.subarray(),st)},unwrap:()=>{if(nt.byteLength>0){const it=et.source;et.source=async function*(){(o==null?void 0:o.yieldBytes)===!1?yield nt:yield*nt,yield*it}()}return et}}}class InvalidMessageLengthError extends Error{constructor(){super(...arguments);wt(this,"name","InvalidMessageLengthError");wt(this,"code","ERR_INVALID_MSG_LENGTH")}}class InvalidDataLengthError extends Error{constructor(){super(...arguments);wt(this,"name","InvalidDataLengthError");wt(this,"code","ERR_MSG_DATA_TOO_LONG")}}class InvalidDataLengthLengthError extends Error{constructor(){super(...arguments);wt(this,"name","InvalidDataLengthLengthError");wt(this,"code","ERR_MSG_LENGTH_TOO_LONG")}}function lpStream(et,o={}){const tt=byteStream(et,o);o.maxDataLength!=null&&o.maxLengthLength==null&&(o.maxLengthLength=encodingLength$6(o.maxDataLength));const rt=(o==null?void 0:o.lengthDecoder)??decode$Z,nt=(o==null?void 0:o.lengthEncoder)??encode$P;return{read:async it=>{let st=-1;const at=new Uint8ArrayList;for(;;){at.append(await tt.read(1,it));try{st=rt(at)}catch(ct){if(ct instanceof RangeError)continue;throw ct}if(st<0)throw new InvalidMessageLengthError("Invalid message length");if((o==null?void 0:o.maxLengthLength)!=null&&at.byteLength>o.maxLengthLength)throw new InvalidDataLengthLengthError("message length length too long");if(st>-1)break}if((o==null?void 0:o.maxDataLength)!=null&&st>o.maxDataLength)throw new InvalidDataLengthError("message length too long");return tt.read(st,it)},write:async(it,st)=>{await tt.write(new Uint8ArrayList(nt(it.byteLength),it),st)},writeV:async(it,st)=>{const at=new Uint8ArrayList(...it.flatMap(ct=>[nt(ct.byteLength),ct]));await tt.write(at,st)},unwrap:()=>tt.unwrap()}}function pair(){const et=pDefer();let o=!1;return{sink:async tt=>{if(o)throw new Error("already piped");o=!0,et.resolve(tt)},source:async function*(){yield*await et.promise}()}}function duplexPair(){const et=pair(),o=pair();return[{source:et.source,sink:o.sink},{source:o.source,sink:et.sink}]}function alloc$4(et=0){return new Uint8Array(et)}function allocUnsafe$a(et=0){return new Uint8Array(et)}const NOISE_MSG_MAX_LENGTH_BYTES=65535,NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=NOISE_MSG_MAX_LENGTH_BYTES-16;var yl,xl;const DUMP_SESSION_KEYS=!!((xl=(yl=globalThis.process)==null?void 0:yl.env)!=null&&xl.DUMP_SESSION_KEYS);function number$2(et){if(!Number.isSafeInteger(et)||et<0)throw new Error(`positive integer expected, not ${et}`)}function bool(et){if(typeof et!="boolean")throw new Error(`boolean expected, not ${et}`)}function isBytes$1(et){return et instanceof Uint8Array||et!=null&&typeof et=="object"&&et.constructor.name==="Uint8Array"}function bytes(et,...o){if(!isBytes$1(et))throw new Error("Uint8Array expected");if(o.length>0&&!o.includes(et.length))throw new Error(`Uint8Array expected of length ${o}, not of length=${et.length}`)}function exists(et,o=!0){if(et.destroyed)throw new Error("Hash instance has been destroyed");if(o&&et.finished)throw new Error("Hash#digest() has already been called")}function output(et,o){bytes(et);const tt=o.outputLen;if(et.lengthnew Uint32Array(et.buffer,et.byteOffset,Math.floor(et.byteLength/4)),createView=et=>new DataView(et.buffer,et.byteOffset,et.byteLength),isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!isLE)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes(et){if(typeof et!="string")throw new Error(`string expected, got ${typeof et}`);return new Uint8Array(new TextEncoder().encode(et))}function toBytes(et){if(typeof et=="string")et=utf8ToBytes(et);else if(isBytes$1(et))et=copyBytes(et);else throw new Error(`Uint8Array expected, got ${typeof et}`);return et}function checkOpts(et,o){if(o==null||typeof o!="object")throw new Error("options must be defined");return Object.assign(et,o)}function equalBytes(et,o){if(et.length!==o.length)return!1;let tt=0;for(let rt=0;rt(Object.assign(o,et),o);function setBigUint64(et,o,tt,rt){if(typeof et.setBigUint64=="function")return et.setBigUint64(o,tt,rt);const nt=BigInt(32),ot=BigInt(4294967295),it=Number(tt>>nt&ot),st=Number(tt&ot),at=4,ct=0;et.setUint32(o+at,it,rt),et.setUint32(o+ct,st,rt)}function copyBytes(et){return Uint8Array.from(et)}function clean(...et){for(let o=0;oUint8Array.from(et.split("").map(o=>o.charCodeAt(0))),sigma16=_utf8ToBytes("expand 16-byte k"),sigma32=_utf8ToBytes("expand 32-byte k"),sigma16_32=u32(sigma16),sigma32_32=u32(sigma32);sigma32_32.slice();function rotl(et,o){return et<>>32-o}function isAligned32(et){return et.byteOffset%4===0}const BLOCK_LEN=64,BLOCK_LEN32=16,MAX_COUNTER=2**32-1,U32_EMPTY=new Uint32Array;function runCipher(et,o,tt,rt,nt,ot,it,st){const at=nt.length,ct=new Uint8Array(BLOCK_LEN),lt=u32(ct),dt=isAligned32(nt)&&isAligned32(ot),ht=dt?u32(nt):U32_EMPTY,mt=dt?u32(ot):U32_EMPTY;for(let ft=0;ft=MAX_COUNTER)throw new Error("arx: counter overflow");const pt=Math.min(BLOCK_LEN,at-ft);if(dt&&pt===BLOCK_LEN){const gt=ft/4;if(ft%4!==0)throw new Error("arx: invalid block position");for(let yt=0,bt;yt{bytes(st),bytes(at),bytes(ct);const ht=ct.length;if(lt===void 0&&(lt=new Uint8Array(ht)),bytes(lt),number$2(dt),dt<0||dt>=MAX_COUNTER)throw new Error("arx: counter overflow");if(lt.lengthet[o++]&255|(et[o++]&255)<<8;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,o=toBytes(o),bytes(o,32);const tt=u8to16(o,0),rt=u8to16(o,2),nt=u8to16(o,4),ot=u8to16(o,6),it=u8to16(o,8),st=u8to16(o,10),at=u8to16(o,12),ct=u8to16(o,14);this.r[0]=tt&8191,this.r[1]=(tt>>>13|rt<<3)&8191,this.r[2]=(rt>>>10|nt<<6)&7939,this.r[3]=(nt>>>7|ot<<9)&8191,this.r[4]=(ot>>>4|it<<12)&255,this.r[5]=it>>>1&8190,this.r[6]=(it>>>14|st<<2)&8191,this.r[7]=(st>>>11|at<<5)&8065,this.r[8]=(at>>>8|ct<<8)&8191,this.r[9]=ct>>>5&127;for(let lt=0;lt<8;lt++)this.pad[lt]=u8to16(o,16+2*lt)}process(o,tt,rt=!1){const nt=rt?0:2048,{h:ot,r:it}=this,st=it[0],at=it[1],ct=it[2],lt=it[3],dt=it[4],ht=it[5],mt=it[6],ft=it[7],pt=it[8],gt=it[9],yt=u8to16(o,tt+0),bt=u8to16(o,tt+2),xt=u8to16(o,tt+4),vt=u8to16(o,tt+6),Et=u8to16(o,tt+8),Ct=u8to16(o,tt+10),St=u8to16(o,tt+12),At=u8to16(o,tt+14);let kt=ot[0]+(yt&8191),It=ot[1]+((yt>>>13|bt<<3)&8191),Ot=ot[2]+((bt>>>10|xt<<6)&8191),Nt=ot[3]+((xt>>>7|vt<<9)&8191),Yt=ot[4]+((vt>>>4|Et<<12)&8191),Ft=ot[5]+(Et>>>1&8191),Ht=ot[6]+((Et>>>14|Ct<<2)&8191),Qt=ot[7]+((Ct>>>11|St<<5)&8191),Vt=ot[8]+((St>>>8|At<<8)&8191),Bt=ot[9]+(At>>>5|nt),Wt=0,jt=Wt+kt*st+It*(5*gt)+Ot*(5*pt)+Nt*(5*ft)+Yt*(5*mt);Wt=jt>>>13,jt&=8191,jt+=Ft*(5*ht)+Ht*(5*dt)+Qt*(5*lt)+Vt*(5*ct)+Bt*(5*at),Wt+=jt>>>13,jt&=8191;let Xt=Wt+kt*at+It*st+Ot*(5*gt)+Nt*(5*pt)+Yt*(5*ft);Wt=Xt>>>13,Xt&=8191,Xt+=Ft*(5*mt)+Ht*(5*ht)+Qt*(5*dt)+Vt*(5*lt)+Bt*(5*ct),Wt+=Xt>>>13,Xt&=8191;let Kt=Wt+kt*ct+It*at+Ot*st+Nt*(5*gt)+Yt*(5*pt);Wt=Kt>>>13,Kt&=8191,Kt+=Ft*(5*ft)+Ht*(5*mt)+Qt*(5*ht)+Vt*(5*dt)+Bt*(5*lt),Wt+=Kt>>>13,Kt&=8191;let Pt=Wt+kt*lt+It*ct+Ot*at+Nt*st+Yt*(5*gt);Wt=Pt>>>13,Pt&=8191,Pt+=Ft*(5*pt)+Ht*(5*ft)+Qt*(5*mt)+Vt*(5*ht)+Bt*(5*dt),Wt+=Pt>>>13,Pt&=8191;let Gt=Wt+kt*dt+It*lt+Ot*ct+Nt*at+Yt*st;Wt=Gt>>>13,Gt&=8191,Gt+=Ft*(5*gt)+Ht*(5*pt)+Qt*(5*ft)+Vt*(5*mt)+Bt*(5*ht),Wt+=Gt>>>13,Gt&=8191;let tr=Wt+kt*ht+It*dt+Ot*lt+Nt*ct+Yt*at;Wt=tr>>>13,tr&=8191,tr+=Ft*st+Ht*(5*gt)+Qt*(5*pt)+Vt*(5*ft)+Bt*(5*mt),Wt+=tr>>>13,tr&=8191;let zt=Wt+kt*mt+It*ht+Ot*dt+Nt*lt+Yt*ct;Wt=zt>>>13,zt&=8191,zt+=Ft*at+Ht*st+Qt*(5*gt)+Vt*(5*pt)+Bt*(5*ft),Wt+=zt>>>13,zt&=8191;let lr=Wt+kt*ft+It*mt+Ot*ht+Nt*dt+Yt*lt;Wt=lr>>>13,lr&=8191,lr+=Ft*ct+Ht*at+Qt*st+Vt*(5*gt)+Bt*(5*pt),Wt+=lr>>>13,lr&=8191;let rr=Wt+kt*pt+It*ft+Ot*mt+Nt*ht+Yt*dt;Wt=rr>>>13,rr&=8191,rr+=Ft*lt+Ht*ct+Qt*at+Vt*st+Bt*(5*gt),Wt+=rr>>>13,rr&=8191;let Jt=Wt+kt*gt+It*pt+Ot*ft+Nt*mt+Yt*ht;Wt=Jt>>>13,Jt&=8191,Jt+=Ft*dt+Ht*lt+Qt*ct+Vt*at+Bt*st,Wt+=Jt>>>13,Jt&=8191,Wt=(Wt<<2)+Wt|0,Wt=Wt+jt|0,jt=Wt&8191,Wt=Wt>>>13,Xt+=Wt,ot[0]=jt,ot[1]=Xt,ot[2]=Kt,ot[3]=Pt,ot[4]=Gt,ot[5]=tr,ot[6]=zt,ot[7]=lr,ot[8]=rr,ot[9]=Jt}finalize(){const{h:o,pad:tt}=this,rt=new Uint16Array(10);let nt=o[1]>>>13;o[1]&=8191;for(let st=2;st<10;st++)o[st]+=nt,nt=o[st]>>>13,o[st]&=8191;o[0]+=nt*5,nt=o[0]>>>13,o[0]&=8191,o[1]+=nt,nt=o[1]>>>13,o[1]&=8191,o[2]+=nt,rt[0]=o[0]+5,nt=rt[0]>>>13,rt[0]&=8191;for(let st=1;st<10;st++)rt[st]=o[st]+nt,nt=rt[st]>>>13,rt[st]&=8191;rt[9]-=8192;let ot=(nt^1)-1;for(let st=0;st<10;st++)rt[st]&=ot;ot=~ot;for(let st=0;st<10;st++)o[st]=o[st]&ot|rt[st];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 it=o[0]+tt[0];o[0]=it&65535;for(let st=1;st<8;st++)it=(o[st]+tt[st]|0)+(it>>>16)|0,o[st]=it&65535;clean(rt)}update(o){exists(this);const{buffer:tt,blockLen:rt}=this;o=toBytes(o);const nt=o.length;for(let ot=0;ot>>0,o[ot++]=rt[it]>>>8;return o}digest(){const{buffer:o,outputLen:tt}=this;this.digestInto(o);const rt=o.slice(0,tt);return this.destroy(),rt}}function wrapConstructorWithKey(et){const o=(rt,nt)=>et(nt).update(toBytes(rt)).digest(),tt=et(new Uint8Array(32));return o.outputLen=tt.outputLen,o.blockLen=tt.blockLen,o.create=rt=>et(rt),o}const poly1305=wrapConstructorWithKey(et=>new Poly1305(et));function chachaCore(et,o,tt,rt,nt,ot=20){let it=et[0],st=et[1],at=et[2],ct=et[3],lt=o[0],dt=o[1],ht=o[2],mt=o[3],ft=o[4],pt=o[5],gt=o[6],yt=o[7],bt=nt,xt=tt[0],vt=tt[1],Et=tt[2],Ct=it,St=st,At=at,kt=ct,It=lt,Ot=dt,Nt=ht,Yt=mt,Ft=ft,Ht=pt,Qt=gt,Vt=yt,Bt=bt,Wt=xt,jt=vt,Xt=Et;for(let Pt=0;Pt{et.update(o);const tt=o.length%16;tt&&et.update(ZEROS16.subarray(tt))},ZEROS32=new Uint8Array(32);function computeTag(et,o,tt,rt,nt){const ot=et(o,tt,ZEROS32),it=poly1305.create(ot);nt&&updatePadded(it,nt),updatePadded(it,rt);const st=new Uint8Array(16),at=createView(st);setBigUint64(at,0,BigInt(nt?nt.length:0),!0),setBigUint64(at,8,BigInt(rt.length),!0),it.update(st);const ct=it.digest();return clean(ot,st),ct}const _poly1305_aead=et=>(o,tt,rt)=>(bytes(o,32),bytes(tt),{encrypt(ot,it){const st=ot.length,at=st+16;it?bytes(it,at):it=new Uint8Array(at),et(o,tt,ot,it,1);const ct=computeTag(et,o,tt,it.subarray(0,-16),rt);return it.set(ct,st),clean(ct),it},decrypt(ot,it){const st=ot.length,at=st-16;if(st<16)throw new Error("encrypted data must be at least 16 bytes");it?bytes(it,at):it=new Uint8Array(at);const ct=ot.subarray(0,-16),lt=ot.subarray(-16),dt=computeTag(et,o,tt,ct,rt);if(!equalBytes(lt,dt))throw new Error("invalid tag");return et(o,tt,ct,it,1),clean(dt),it}}),chacha20poly1305=wrapCipher({blockSize:64,nonceLength:12,tagLength:16},_poly1305_aead(chacha20));function extract(et,o,tt){return hash$1(et),tt===void 0&&(tt=new Uint8Array(et.outputLen)),hmac(et,toBytes$2(tt),toBytes$2(o))}const HKDF_COUNTER=new Uint8Array([0]),EMPTY_BUFFER=new Uint8Array;function expand(et,o,tt,rt=32){if(hash$1(et),number$4(rt),rt>255*et.outputLen)throw new Error("Length should be <= 255*HashLen");const nt=Math.ceil(rt/et.outputLen);tt===void 0&&(tt=EMPTY_BUFFER);const ot=new Uint8Array(nt*et.outputLen),it=hmac.create(et,o),st=it._cloneInto(),at=new Uint8Array(it.outputLen);for(let ct=0;ctet.generateX25519SharedKey(o.privateKey,tt).subarray(0,32),encrypt:et.chaCha20Poly1305Encrypt,decrypt:et.chaCha20Poly1305Decrypt,hash:et.hashSHA256,hkdf:et.getHKDF}}const uint16BEEncode=et=>{const o=allocUnsafe$a(2);return o[0]=et>>8,o[1]=et,o};uint16BEEncode.bytes=2;const uint16BEDecode=et=>{if(et.length<2)throw RangeError("Could not decode int16BE");if(et instanceof Uint8Array){let o=0;return o+=et[0]<<8,o+=et[1],o}return et.getUint16(0)};uint16BEDecode.bytes=2;function registerMetrics(et){return{xxHandshakeSuccesses:et.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:et.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:et.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:et.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:et.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}function coerce$g(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$m(et){return new TextEncoder().encode(et)}function toString$n(et){return new TextDecoder().decode(et)}function base$g(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$g=base$g,_brrp__multiformats_scope_baseX$f=src$g;let Encoder$g=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$g=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$h(this,o)}},ComposedDecoder$f=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$h(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$h(et,o){return new ComposedDecoder$f({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$f=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$g(o,tt,rt),this.decoder=new Decoder$g(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$g({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$f(et,o,tt,rt)}function baseX$f({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$f(tt,et);return from$g({prefix:o,name:et,encode:rt,decode:ot=>coerce$g(nt(ot))})}function decode$E(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$y(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$b=alphabet$b.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$x(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$b[tt],o),"")}function decode$D(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$b[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$m=from$g({prefix:"🚀",name:"base256emoji",encode:encode$x,decode:decode$D}),base256emoji$n=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$m},Symbol.toStringTag,{value:"Module"})),base32$q=rfc4648$e({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$b=rfc4648$e({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$b=rfc4648$e({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$b=rfc4648$e({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$b=rfc4648$e({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$b=rfc4648$e({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$b=rfc4648$e({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$b=rfc4648$e({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$b=rfc4648$e({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$r=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$q,base32hex:base32hex$b,base32hexpad:base32hexpad$b,base32hexpadupper:base32hexpadupper$b,base32hexupper:base32hexupper$b,base32pad:base32pad$b,base32padupper:base32padupper$b,base32upper:base32upper$b,base32z:base32z$b},Symbol.toStringTag,{value:"Module"})),base36$n=baseX$f({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$b=baseX$f({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$o=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$n,base36upper:base36upper$b},Symbol.toStringTag,{value:"Module"})),base58btc$f=baseX$f({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$b=baseX$f({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$b=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$f,base58flickr:base58flickr$b},Symbol.toStringTag,{value:"Module"})),base64$p=rfc4648$e({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$b=rfc4648$e({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$c=rfc4648$e({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$b=rfc4648$e({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$q=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$p,base64pad:base64pad$b,base64url:base64url$c,base64urlpad:base64urlpad$b},Symbol.toStringTag,{value:"Module"})),base8$m=rfc4648$e({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$n=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$m},Symbol.toStringTag,{value:"Module"})),identity$b=from$g({prefix:"\0",name:"identity",encode:et=>toString$n(et),decode:et=>fromString$m(et)}),identityBase$b=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$b},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$b={...identityBase$b,...base2$n,...base8$n,...base10$n,...base16$n,...base32$r,...base36$o,...base58$b,...base64$q,...base256emoji$n};function createCodec$b(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$f=createCodec$b("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$b=createCodec$b("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$a(et.length);for(let tt=0;ttnt+ot.length,0));const tt=allocUnsafe$a(o);let rt=0;for(const nt of et)tt.set(nt,rt),rt+=nt.length;return tt}function fromString$l(et,o="utf8"){const tt=BASES$b[o];if(tt==null)throw new Error(`Unsupported encoding "${o}"`);return tt.decoder.decode(`${tt.prefix}${et}`)}const is=class is extends Error{constructor(tt="Invalid crypto exchange"){super(tt);wt(this,"code");this.code=is.code}};wt(is,"code","ERR_INVALID_CRYPTO_EXCHANGE");let InvalidCryptoExchangeError=is;const MIN_NONCE=0,MAX_NONCE=4294967295,ERR_MAX_NONCE="Cipherstate has reached maximum n, a new handshake must be performed";class Nonce{constructor(o=MIN_NONCE){wt(this,"n");wt(this,"bytes");wt(this,"view");this.n=o,this.bytes=alloc$4(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>MAX_NONCE)throw new Error(ERR_MAX_NONCE)}}const ZEROLEN=alloc$4(0);class CipherState{constructor(o,tt=void 0,rt=0){wt(this,"k");wt(this,"n");wt(this,"crypto");this.crypto=o,this.k=tt,this.n=new Nonce(rt)}hasKey(){return!!this.k}encryptWithAd(o,tt){if(!this.hasKey())return tt;this.n.assertValue();const rt=this.crypto.encrypt(tt,this.n.getBytes(),o,this.k);return this.n.increment(),rt}decryptWithAd(o,tt,rt){if(!this.hasKey())return tt;this.n.assertValue();const nt=this.crypto.decrypt(tt,this.n.getBytes(),o,this.k,rt);return this.n.increment(),nt}}class SymmetricState{constructor(o,tt){wt(this,"cs");wt(this,"ck");wt(this,"h");wt(this,"crypto");this.crypto=o;const rt=fromString$l(tt,"utf-8");this.h=hashProtocolName(o,rt),this.ck=this.h,this.cs=new CipherState(o)}mixKey(o){const[tt,rt]=this.crypto.hkdf(this.ck,o);this.ck=tt,this.cs=new CipherState(this.crypto,rt)}mixHash(o){this.h=this.crypto.hash(new Uint8ArrayList(this.h,o))}encryptAndHash(o){const tt=this.cs.encryptWithAd(this.h,o);return this.mixHash(tt),tt}decryptAndHash(o){const tt=this.cs.decryptWithAd(this.h,o);return this.mixHash(o),tt}split(){const[o,tt]=this.crypto.hkdf(this.ck,ZEROLEN);return[new CipherState(this.crypto,o),new CipherState(this.crypto,tt)]}}class AbstractHandshakeState{constructor(o){wt(this,"ss");wt(this,"s");wt(this,"e");wt(this,"rs");wt(this,"re");wt(this,"initiator");wt(this,"crypto");const{crypto:tt,protocolName:rt,prologue:nt,initiator:ot,s:it,e:st,rs:at,re:ct}=o;this.crypto=tt,this.ss=new SymmetricState(tt,rt),this.ss.mixHash(nt),this.initiator=ot,this.s=it,this.e=st,this.rs=at,this.re=ct}writeE(){if(this.e)throw new Error("ephemeral keypair is already set");const o=this.crypto.generateKeypair();return this.ss.mixHash(o.publicKey),this.e=o,o.publicKey}writeS(){if(!this.s)throw new Error("static keypair is not set");return this.ss.encryptAndHash(this.s.publicKey)}writeEE(){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.re))}writeES(){if(this.initiator){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}else{if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}}writeSE(){if(this.initiator){if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}else{if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}}readE(o,tt=0){if(this.re)throw new Error("remote ephemeral public key is already set");if(o.byteLength(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.webtransportCerthashes!=null)for(const ot of tt.webtransportCerthashes)rt.uint32(10),rt.bytes(ot);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt)=>{const nt={webtransportCerthashes:[]},ot=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{nt.webtransportCerthashes.push(tt.bytes());break}default:{tt.skipType(it&7);break}}}return nt})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=tt=>decodeMessage(tt,et.codec())})(NoiseExtensions||(NoiseExtensions={}));var NoiseHandshakePayload;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.identityKey!=null&&tt.identityKey.byteLength>0&&(rt.uint32(10),rt.bytes(tt.identityKey)),tt.identitySig!=null&&tt.identitySig.byteLength>0&&(rt.uint32(18),rt.bytes(tt.identitySig)),tt.extensions!=null&&(rt.uint32(34),NoiseExtensions.codec().encode(tt.extensions,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt)=>{const nt={identityKey:alloc$4(0),identitySig:alloc$4(0)},ot=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{nt.identityKey=tt.bytes();break}case 2:{nt.identitySig=tt.bytes();break}case 4:{nt.extensions=NoiseExtensions.codec().decode(tt,tt.uint32());break}default:{tt.skipType(it&7);break}}}return nt})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=tt=>decodeMessage(tt,et.codec())})(NoiseHandshakePayload||(NoiseHandshakePayload={}));async function createHandshakePayload(et,o,tt){const rt=await et.sign(getSignaturePayload(o));return NoiseHandshakePayload.encode({identityKey:publicKeyToProtobuf(et.publicKey),identitySig:rt,extensions:tt})}async function decodeHandshakePayload(et,o,tt){try{const rt=NoiseHandshakePayload.decode(et),nt=publicKeyFromProtobuf(rt.identityKey);if((tt==null?void 0:tt.equals(nt))===!1)throw new Error(`Payload identity key ${nt} does not match expected remote identity key ${tt}`);if(!o)throw new Error("Remote static does not exist");const ot=getSignaturePayload(o);if(!await nt.verify(ot,rt.identitySig))throw new Error("Invalid payload signature");return rt}catch(rt){throw new UnexpectedPeerError(rt.message)}}function getSignaturePayload(et){const o=fromString$l("noise-libp2p-static-key:");return et instanceof Uint8Array?concat$1([o,et],o.length+et.length):(et.prepend(o),et)}async function performHandshakeInitiator(et,o){const{log:tt,connection:rt,crypto:nt,privateKey:ot,prologue:it,s:st,remoteIdentityKey:at,extensions:ct}=et,lt=await createHandshakePayload(ot,st.publicKey,ct),dt=new XXHandshakeState({crypto:nt,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!0,prologue:it,s:st});logLocalStaticKeys(dt.s,tt),tt.trace("Stage 0 - Initiator starting to send first message."),await rt.write(dt.writeMessageA(ZEROLEN),o),tt.trace("Stage 0 - Initiator finished sending first message."),logLocalEphemeralKeys(dt.e,tt),tt.trace("Stage 1 - Initiator waiting to receive first message from responder...");const ht=dt.readMessageB(await rt.read(o));tt.trace("Stage 1 - Initiator received the message."),logRemoteEphemeralKey(dt.re,tt),logRemoteStaticKey(dt.rs,tt),tt.trace("Initiator going to check remote's signature...");const mt=await decodeHandshakePayload(ht,dt.rs,at);tt.trace("All good with the signature!"),tt.trace("Stage 2 - Initiator sending third handshake message."),await rt.write(dt.writeMessageC(lt),o),tt.trace("Stage 2 - Initiator sent message with signed payload.");const[ft,pt]=dt.ss.split();return logCipherState(ft,pt,tt),{payload:mt,encrypt:gt=>ft.encryptWithAd(ZEROLEN,gt),decrypt:(gt,yt)=>pt.decryptWithAd(ZEROLEN,gt,yt)}}async function performHandshakeResponder(et,o){const{log:tt,connection:rt,crypto:nt,privateKey:ot,prologue:it,s:st,remoteIdentityKey:at,extensions:ct}=et,lt=await createHandshakePayload(ot,st.publicKey,ct),dt=new XXHandshakeState({crypto:nt,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!1,prologue:it,s:st});logLocalStaticKeys(dt.s,tt),tt.trace("Stage 0 - Responder waiting to receive first message."),dt.readMessageA(await rt.read(o)),tt.trace("Stage 0 - Responder received first message."),logRemoteEphemeralKey(dt.re,tt),tt.trace("Stage 1 - Responder sending out first message with signed payload and static key."),await rt.write(dt.writeMessageB(lt),o),tt.trace("Stage 1 - Responder sent the second handshake message with signed payload."),logLocalEphemeralKeys(dt.e,tt),tt.trace("Stage 2 - Responder waiting for third handshake message...");const ht=dt.readMessageC(await rt.read(o));tt.trace("Stage 2 - Responder received the message, finished handshake.");const mt=await decodeHandshakePayload(ht,dt.rs,at),[ft,pt]=dt.ss.split();return logCipherState(ft,pt,tt),{payload:mt,encrypt:gt=>pt.encryptWithAd(ZEROLEN,gt),decrypt:(gt,yt)=>ft.decryptWithAd(ZEROLEN,gt,yt)}}const CHACHA_TAG_LENGTH=16;function encryptStream(et,o){return async function*(tt){for await(const rt of tt)for(let nt=0;ntrt.length&&(ot=rt.length);let it;rt instanceof Uint8Array?it=et.encrypt(rt.subarray(nt,ot)):it=et.encrypt(rt.sublist(nt,ot)),o==null||o.encryptedPackets.increment(),yield new Uint8ArrayList(uint16BEEncode(it.byteLength),it)}}}function decryptStream(et,o){return async function*(tt){for await(const rt of tt)for(let nt=0;ntrt.length&&(ot=rt.length),ot-CHACHA_TAG_LENGTHdecode$U(it,{lengthDecoder:uint16BEDecode}),decryptStream(tt,this.metrics),rt),nt}}function noise(et={}){return o=>new Noise(o,et)}const peerDiscoverySymbol$1=Symbol.for("@libp2p/peer-discovery");function setMaxListeners$7(){}const setMaxListeners$6=(et,...o)=>{try{[...o]}catch{}};var Xr,Cl;let TypedEventEmitter$2=(Cl=class extends EventTarget{constructor(){super();hr(this,Xr,new Map);setMaxListeners$6(1/0,this)}listenerCount(tt){const rt=Lt(this,Xr).get(tt);return rt==null?0:rt.length}addEventListener(tt,rt,nt){super.addEventListener(tt,rt,nt);let ot=Lt(this,Xr).get(tt);ot==null&&(ot=[],Lt(this,Xr).set(tt,ot)),ot.push({callback:rt,once:(nt!==!0&&nt!==!1&&(nt==null?void 0:nt.once))??!1})}removeEventListener(tt,rt,nt){super.removeEventListener(tt.toString(),rt??null,nt);let ot=Lt(this,Xr).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==rt),Lt(this,Xr).set(tt,ot))}dispatchEvent(tt){const rt=super.dispatchEvent(tt);let nt=Lt(this,Xr).get(tt.type);return nt==null||(nt=nt.filter(({once:ot})=>!ot),Lt(this,Xr).set(tt.type,nt)),rt}safeDispatchEvent(tt,rt={}){return this.dispatchEvent(new CustomEvent(tt,rt))}},Xr=new WeakMap,Cl);const serviceCapabilities$4=Symbol.for("@libp2p/service-capabilities"),DNS4=base$f("dns4"),DNS6=base$f("dns6"),DNSADDR=base$f("dnsaddr"),DNS$1=or$g(base$f("dns"),DNSADDR,DNS4,DNS6),IP=or$g(base$f("ip4"),base$f("ip6")),TCP$1=or$g(and$1(IP,base$f("tcp")),and$1(DNS$1,base$f("tcp"))),UDP=and$1(IP,base$f("udp")),UTP=and$1(UDP,base$f("utp")),QUIC=and$1(UDP,base$f("quic")),QUICV1=and$1(UDP,base$f("quic-v1")),_WebSockets$1=or$g(and$1(TCP$1,base$f("ws")),and$1(DNS$1,base$f("ws"))),WebSockets$2=or$g(and$1(_WebSockets$1,base$f("p2p")),_WebSockets$1),_WebSocketsSecure$1=or$g(and$1(TCP$1,base$f("wss")),and$1(DNS$1,base$f("wss")),and$1(TCP$1,base$f("tls"),base$f("ws")),and$1(DNS$1,base$f("tls"),base$f("ws"))),WebSocketsSecure$1=or$g(and$1(_WebSocketsSecure$1,base$f("p2p")),_WebSocketsSecure$1),HTTP=or$g(and$1(TCP$1,base$f("http")),and$1(IP,base$f("http")),and$1(DNS$1,base$f("http"))),HTTPS=or$g(and$1(TCP$1,base$f("https")),and$1(IP,base$f("https")),and$1(DNS$1,base$f("https"))),_WebRTCDirect$1=and$1(UDP,base$f("webrtc-direct"),base$f("certhash")),WebRTCDirect$1=or$g(and$1(_WebRTCDirect$1,base$f("p2p")),_WebRTCDirect$1),_WebTransport$1=and$1(QUICV1,base$f("webtransport"),base$f("certhash"),base$f("certhash")),WebTransport$1=or$g(and$1(_WebTransport$1,base$f("p2p")),_WebTransport$1),P2PWebRTCStar=or$g(and$1(WebSockets$2,base$f("p2p-webrtc-star"),base$f("p2p")),and$1(WebSocketsSecure$1,base$f("p2p-webrtc-star"),base$f("p2p")),and$1(WebSockets$2,base$f("p2p-webrtc-star")),and$1(WebSocketsSecure$1,base$f("p2p-webrtc-star"))),P2PWebRTCDirect=or$g(and$1(HTTP,base$f("p2p-webrtc-direct"),base$f("p2p")),and$1(HTTPS,base$f("p2p-webrtc-direct"),base$f("p2p")),and$1(HTTP,base$f("p2p-webrtc-direct")),and$1(HTTPS,base$f("p2p-webrtc-direct"))),Reliable=or$g(_WebSockets$1,_WebSocketsSecure$1,HTTP,HTTPS,P2PWebRTCStar,P2PWebRTCDirect,TCP$1,UTP,QUIC,DNS$1,WebRTCDirect$1,WebTransport$1),_P2P$1=or$g(and$1(Reliable,base$f("p2p")),P2PWebRTCStar,P2PWebRTCDirect,WebRTCDirect$1,WebTransport$1,base$f("p2p")),_Circuit$1=or$g(and$1(_P2P$1,base$f("p2p-circuit"),_P2P$1),and$1(_P2P$1,base$f("p2p-circuit")),and$1(base$f("p2p-circuit"),_P2P$1),and$1(Reliable,base$f("p2p-circuit")),and$1(base$f("p2p-circuit"),Reliable),base$f("p2p-circuit")),CircuitRecursive=()=>or$g(and$1(_Circuit$1,CircuitRecursive),_Circuit$1),Circuit$1=CircuitRecursive(),P2P=or$g(and$1(Circuit$1,_P2P$1,Circuit$1),and$1(_P2P$1,Circuit$1),and$1(Circuit$1,_P2P$1),Circuit$1,_P2P$1);function makeMatchesFunction(et){function o(tt){let rt;try{rt=multiaddr(tt)}catch{return!1}const nt=et(rt.protoNames());return nt===null?!1:nt===!0||nt===!1?nt:nt.length===0}return o}function and$1(...et){function o(tt){if(tt.length(rt=typeof nt=="function"?nt().partialMatch(tt):nt.partialMatch(tt),Array.isArray(rt)&&(tt=rt),rt===null)),rt}return{toString:function(){return"{ "+et.join(" ")+" }"},input:et,matches:makeMatchesFunction(o),partialMatch:o}}function or$g(...et){function o(rt){let nt=null;return et.some(ot=>{const it=typeof ot=="function"?ot().partialMatch(rt):ot.partialMatch(rt);return it!=null?(nt=it,!0):!1}),nt}return{toString:function(){return"{ "+et.join(" ")+" }"},input:et,matches:makeMatchesFunction(o),partialMatch:o}}function base$f(et){const o=et;function tt(nt){let ot;try{ot=multiaddr(nt)}catch{return!1}const it=ot.protoNames();return it.length===1&&it[0]===o}function rt(nt){return nt.length===0?null:nt[0]===o?nt.slice(1):null}return{toString:function(){return o},matches:tt,partialMatch:rt}}const DEFAULT_BOOTSTRAP_TAG_NAME$1="bootstrap",DEFAULT_BOOTSTRAP_TAG_VALUE$1=50,DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT=1e3;var Sl,Al,$l,_l;class Bootstrap extends(_l=TypedEventEmitter$2,$l=peerDiscoverySymbol$1,Al=Symbol.toStringTag,Sl=serviceCapabilities$4,_l){constructor(tt,rt={list:[]}){if(rt.list==null||rt.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super();wt(this,"log");wt(this,"timer");wt(this,"list");wt(this,"timeout");wt(this,"components");wt(this,"_init");wt(this,$l,this);wt(this,Al,"@libp2p/bootstrap");wt(this,Sl,["@libp2p/peer-discovery"]);this.components=tt,this.log=tt.logger.forComponent("libp2p:bootstrap"),this.timeout=rt.timeout??DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT,this.list=[];for(const nt of rt.list){if(!P2P.matches(nt)){this.log.error("Invalid multiaddr");continue}const ot=multiaddr(nt),it=ot.getPeerId();if(it==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}const st={id:peerIdFromString$1(it),multiaddrs:[ot]};this.list.push(st)}this._init=rt}isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(tt=>{this.log.error(tt)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(const tt of this.list){if(await this.components.peerStore.merge(tt.id,{tags:{[this._init.tagName??DEFAULT_BOOTSTRAP_TAG_NAME$1]:{value:this._init.tagValue??DEFAULT_BOOTSTRAP_TAG_VALUE$1,ttl:this._init.tagTTL}},multiaddrs:tt.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:tt}),this.components.connectionManager.openConnection(tt.id).catch(rt=>{this.log.error("could not dial bootstrap peer %p",tt.id,rt)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}}wt(Bootstrap,"tag","bootstrap");function bootstrap(et){return o=>new Bootstrap(o,et)}var gs;let UnsupportedProtocolError$1=(gs=class extends Error{constructor(o="Unsupported protocol error"){super(o),this.name="UnsupportedProtocolError"}},wt(gs,"name","UnsupportedProtocolError"),gs);var ys;let InvalidMessageError$2=(ys=class extends Error{constructor(o="Invalid message"){super(o),this.name="InvalidMessageError"}},wt(ys,"name","InvalidMessageError"),ys);function setMaxListeners$5(){}const setMaxListeners$4=(et,...o)=>{try{[...o]}catch{}},serviceCapabilities$3=Symbol.for("@libp2p/service-capabilities");function equals$5(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$f=base$e,_brrp__multiformats_scope_baseX$e=src$f;let Encoder$f=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$f=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$f(this,o)}},ComposedDecoder$e=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$f(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$f(et,o){return new ComposedDecoder$e({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$e=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$f(o,tt,rt),this.decoder=new Decoder$f(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$f({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$e(et,o,tt,rt)}function baseX$e({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$e(tt,et);return from$f({prefix:o,name:et,encode:rt,decode:ot=>coerce$f(nt(ot))})}function decode$C(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$w(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$a=alphabet$a.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$v(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$a[tt],o),"")}function decode$B(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$a[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$k=from$f({prefix:"🚀",name:"base256emoji",encode:encode$v,decode:decode$B}),base256emoji$l=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$k},Symbol.toStringTag,{value:"Module"})),base32$o=rfc4648$d({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$a=rfc4648$d({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$a=rfc4648$d({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$a=rfc4648$d({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$a=rfc4648$d({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$a=rfc4648$d({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$a=rfc4648$d({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$a=rfc4648$d({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$a=rfc4648$d({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$p=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$o,base32hex:base32hex$a,base32hexpad:base32hexpad$a,base32hexpadupper:base32hexpadupper$a,base32hexupper:base32hexupper$a,base32pad:base32pad$a,base32padupper:base32padupper$a,base32upper:base32upper$a,base32z:base32z$a},Symbol.toStringTag,{value:"Module"})),base36$l=baseX$e({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$a=baseX$e({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$m=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$l,base36upper:base36upper$a},Symbol.toStringTag,{value:"Module"})),base58btc$e=baseX$e({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$a=baseX$e({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$a=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$e,base58flickr:base58flickr$a},Symbol.toStringTag,{value:"Module"})),base64$n=rfc4648$d({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$a=rfc4648$d({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$b=rfc4648$d({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$a=rfc4648$d({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$o=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$n,base64pad:base64pad$a,base64url:base64url$b,base64urlpad:base64urlpad$a},Symbol.toStringTag,{value:"Module"})),base8$k=rfc4648$d({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$l=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$k},Symbol.toStringTag,{value:"Module"})),identity$a=from$f({prefix:"\0",name:"identity",encode:et=>toString$l(et),decode:et=>fromString$k(et)}),identityBase$a=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$a},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;var encode_1$2=encode$u,MSB$4=128,REST$4=127,MSBALL$2=~REST$4,INT$2=Math.pow(2,31);function encode$u(et,o,tt){o=o||[],tt=tt||0;for(var rt=tt;et>=INT$2;)o[tt++]=et&255|MSB$4,et/=128;for(;et&MSBALL$2;)o[tt++]=et&255|MSB$4,et>>>=7;return o[tt]=et|0,encode$u.bytes=tt-rt+1,o}var decode$A=read$3,MSB$1$2=128,REST$1$2=127;function read$3(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$3.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$2)<=MSB$1$2);return read$3.bytes=ot-rt,tt}var N1$2=Math.pow(2,7),N2$2=Math.pow(2,14),N3$2=Math.pow(2,21),N4$2=Math.pow(2,28),N5$2=Math.pow(2,35),N6$2=Math.pow(2,42),N7$2=Math.pow(2,49),N8$2=Math.pow(2,56),N9$2=Math.pow(2,63),length$2=function(et){return et"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$a=createCodec$a("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$9(et.length);for(let tt=0;tt(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.publicKey!=null&&tt.publicKey.byteLength>0&&(rt.uint32(10),rt.bytes(tt.publicKey)),tt.payloadType!=null&&tt.payloadType.byteLength>0&&(rt.uint32(18),rt.bytes(tt.payloadType)),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(26),rt.bytes(tt.payload)),tt.signature!=null&&tt.signature.byteLength>0&&(rt.uint32(42),rt.bytes(tt.signature)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={publicKey:alloc$3(0),payloadType:alloc$3(0),payload:alloc$3(0),signature:alloc$3(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.publicKey=tt.bytes();break}case 2:{ot.payloadType=tt.bytes();break}case 3:{ot.payload=tt.bytes();break}case 5:{ot.signature=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Envelope||(Envelope={}));class InvalidSignatureError extends Error{constructor(o="Invalid signature"){super(o),this.name="InvalidSignatureError"}}const dn=class dn{constructor(o){wt(this,"publicKey");wt(this,"payloadType");wt(this,"payload");wt(this,"signature");wt(this,"marshaled");const{publicKey:tt,payloadType:rt,payload:nt,signature:ot}=o;this.publicKey=tt,this.payloadType=rt,this.payload=nt,this.signature=ot}marshal(){return this.marshaled==null&&(this.marshaled=Envelope.encode({publicKey:publicKeyToProtobuf(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(o){return equals$5(this.marshal(),o.marshal())}async validate(o){const tt=formatSignaturePayload(o,this.payloadType,this.payload);return this.publicKey.verify(tt.subarray(),this.signature)}};wt(dn,"createFromProtobuf",async o=>{const tt=Envelope.decode(o),rt=publicKeyFromProtobuf(tt.publicKey);return new dn({publicKey:rt,payloadType:tt.payloadType,payload:tt.payload,signature:tt.signature})}),wt(dn,"seal",async(o,tt)=>{if(tt==null)throw new Error("Missing private key");const rt=o.domain,nt=o.codec,ot=o.marshal(),it=formatSignaturePayload(rt,nt,ot),st=await tt.sign(it.subarray());return new dn({publicKey:tt.publicKey,payloadType:nt,payload:ot,signature:st})}),wt(dn,"openAndCertify",async(o,tt)=>{const rt=await dn.createFromProtobuf(o);if(!await rt.validate(tt))throw new InvalidSignatureError("Envelope signature is not valid for the given domain");return rt});let RecordEnvelope=dn;const formatSignaturePayload=(et,o,tt)=>{const rt=fromString$j(et),nt=encode$P(rt.byteLength),ot=encode$P(o.length),it=encode$P(tt.length);return new Uint8ArrayList(nt,rt,ot,o,it,tt)};function arrayEquals(et,o){const tt=(rt,nt)=>rt.toString().localeCompare(nt.toString());return et.length!==o.length?!1:(o.sort(tt),et.sort(tt).every((rt,nt)=>o[nt].equals(rt)))}const ENVELOPE_DOMAIN_PEER_RECORD="libp2p-peer-record",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD=Uint8Array.from([3,1]);var PeerRecord$1;(function(et){(function(tt){let rt;tt.codec=()=>(rt==null&&(rt=message$1((nt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),nt.multiaddr!=null&&nt.multiaddr.byteLength>0&&(ot.uint32(10),ot.bytes(nt.multiaddr)),it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{const st={multiaddr:alloc$3(0)},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.multiaddr=nt.bytes();break}default:{nt.skipType(ct&7);break}}}return st})),rt),tt.encode=nt=>encodeMessage(nt,tt.codec()),tt.decode=(nt,ot)=>decodeMessage(nt,tt.codec(),ot)})(et.AddressInfo||(et.AddressInfo={}));let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.peerId!=null&&tt.peerId.byteLength>0&&(rt.uint32(10),rt.bytes(tt.peerId)),tt.seq!=null&&tt.seq!==0n&&(rt.uint32(16),rt.uint64(tt.seq)),tt.addresses!=null)for(const ot of tt.addresses)rt.uint32(26),et.AddressInfo.codec().encode(ot,rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={peerId:alloc$3(0),seq:0n,addresses:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.peerId=tt.bytes();break}case 2:{ot.seq=tt.uint64();break}case 3:{if(((st=nt.limits)==null?void 0:st.addresses)!=null&&ot.addresses.length===nt.limits.addresses)throw new MaxLengthError('Decode error - map field "addresses" had too many elements');ot.addresses.push(et.AddressInfo.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.addresses$}));break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerRecord$1||(PeerRecord$1={}));const on=class on{constructor(o){wt(this,"peerId");wt(this,"multiaddrs");wt(this,"seqNumber");wt(this,"domain",on.DOMAIN);wt(this,"codec",on.CODEC);wt(this,"marshaled");const{peerId:tt,multiaddrs:rt,seqNumber:nt}=o;this.peerId=tt,this.multiaddrs=rt??[],this.seqNumber=nt??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=PeerRecord$1.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(o=>({multiaddr:o.bytes}))})),this.marshaled}equals(o){return!(!(o instanceof on)||!this.peerId.equals(o.peerId)||this.seqNumber!==o.seqNumber||!arrayEquals(this.multiaddrs,o.multiaddrs))}};wt(on,"createFromProtobuf",o=>{const tt=PeerRecord$1.decode(o),rt=peerIdFromMultihash(decode$y(tt.peerId)),nt=(tt.addresses??[]).map(it=>multiaddr(it.multiaddr)),ot=tt.seq;return new on({peerId:rt,multiaddrs:nt,seqNumber:ot})}),wt(on,"DOMAIN",ENVELOPE_DOMAIN_PEER_RECORD),wt(on,"CODEC",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD);let PeerRecord=on;function isAsyncIterable$4(et){return et[Symbol.asyncIterator]!=null}function drain(et){if(isAsyncIterable$4(et))return(async()=>{for await(const o of et);})();for(const o of et);}const CustomEvent$1=globalThis.CustomEvent??Event;async function*parallel(et,o={}){let tt=o.concurrency??1/0;tt<1&&(tt=1/0);const rt=o.ordered==null?!1:o.ordered,nt=new EventTarget,ot=[];let it=pDefer(),st=pDefer(),at=!1,ct,lt=!1;nt.addEventListener("task-complete",()=>{st.resolve()}),Promise.resolve().then(async()=>{try{for await(const ft of et){if(ot.length===tt&&(it=pDefer(),await it.promise),lt)break;const pt={done:!1};ot.push(pt),ft().then(gt=>{pt.done=!0,pt.ok=!0,pt.value=gt,nt.dispatchEvent(new CustomEvent$1("task-complete"))},gt=>{pt.done=!0,pt.err=gt,nt.dispatchEvent(new CustomEvent$1("task-complete"))})}at=!0,nt.dispatchEvent(new CustomEvent$1("task-complete"))}catch(ft){ct=ft,nt.dispatchEvent(new CustomEvent$1("task-complete"))}});function dt(){var ft;return rt?(ft=ot[0])==null?void 0:ft.done:!!ot.find(pt=>pt.done)}function*ht(){for(;ot.length>0&&ot[0].done;){const ft=ot[0];if(ot.shift(),ft.ok)yield ft.value;else throw lt=!0,it.resolve(),ft.err;it.resolve()}}function*mt(){for(;dt();)for(let ft=0;ft{const it=await tt.read(ot);return nt.decode(it)},write:async(nt,ot,it)=>{await tt.write(ot.encode(nt),it)},writeV:async(nt,ot,it)=>{await tt.writeV(nt.map(st=>ot.encode(st)),it)},pb:nt=>({read:async ot=>rt.read(nt,ot),write:async(ot,it)=>rt.write(ot,nt,it),writeV:async(ot,it)=>rt.writeV(ot,nt,it),unwrap:()=>rt}),unwrap:()=>tt.unwrap()};return rt}function coerce$e(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$i(et){return new TextEncoder().encode(et)}function toString$k(et){return new TextDecoder().decode(et)}function base$d(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$e=base$d,_brrp__multiformats_scope_baseX$d=src$e;let Encoder$e=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$e=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$e(this,o)}},ComposedDecoder$d=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$e(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$e(et,o){return new ComposedDecoder$d({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$d=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$e(o,tt,rt),this.decoder=new Decoder$e(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$e({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$d(et,o,tt,rt)}function baseX$d({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$d(tt,et);return from$e({prefix:o,name:et,encode:rt,decode:ot=>coerce$e(nt(ot))})}function decode$x(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$t(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$9=alphabet$9.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$s(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$9[tt],o),"")}function decode$w(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$9[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$i=from$e({prefix:"🚀",name:"base256emoji",encode:encode$s,decode:decode$w}),base256emoji$j=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$i},Symbol.toStringTag,{value:"Module"})),base32$m=rfc4648$c({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$9=rfc4648$c({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$9=rfc4648$c({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$9=rfc4648$c({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$9=rfc4648$c({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$9=rfc4648$c({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$9=rfc4648$c({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$9=rfc4648$c({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$9=rfc4648$c({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$n=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$m,base32hex:base32hex$9,base32hexpad:base32hexpad$9,base32hexpadupper:base32hexpadupper$9,base32hexupper:base32hexupper$9,base32pad:base32pad$9,base32padupper:base32padupper$9,base32upper:base32upper$9,base32z:base32z$9},Symbol.toStringTag,{value:"Module"})),base36$j=baseX$d({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$9=baseX$d({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$k=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$j,base36upper:base36upper$9},Symbol.toStringTag,{value:"Module"})),base58btc$d=baseX$d({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$9=baseX$d({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$9=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$d,base58flickr:base58flickr$9},Symbol.toStringTag,{value:"Module"})),base64$l=rfc4648$c({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$9=rfc4648$c({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$a=rfc4648$c({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$9=rfc4648$c({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$m=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$l,base64pad:base64pad$9,base64url:base64url$a,base64urlpad:base64urlpad$9},Symbol.toStringTag,{value:"Module"})),base8$i=rfc4648$c({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$j=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$i},Symbol.toStringTag,{value:"Module"})),identity$9=from$e({prefix:"\0",name:"identity",encode:et=>toString$k(et),decode:et=>fromString$i(et)}),identityBase$9=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$9},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$9={...identityBase$9,...base2$j,...base8$j,...base10$j,...base16$j,...base32$n,...base36$k,...base58$9,...base64$m,...base256emoji$j};function allocUnsafe$8(et=0){return new Uint8Array(et)}function createCodec$9(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$d=createCodec$9("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$9=createCodec$9("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$8(et.length);for(let tt=0;tt(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.protocolVersion!=null&&(rt.uint32(42),rt.string(tt.protocolVersion)),tt.agentVersion!=null&&(rt.uint32(50),rt.string(tt.agentVersion)),tt.publicKey!=null&&(rt.uint32(10),rt.bytes(tt.publicKey)),tt.listenAddrs!=null)for(const ot of tt.listenAddrs)rt.uint32(18),rt.bytes(ot);if(tt.observedAddr!=null&&(rt.uint32(34),rt.bytes(tt.observedAddr)),tt.protocols!=null)for(const ot of tt.protocols)rt.uint32(26),rt.string(ot);tt.signedPeerRecord!=null&&(rt.uint32(66),rt.bytes(tt.signedPeerRecord)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={listenAddrs:[],protocols:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 5:{ot.protocolVersion=tt.string();break}case 6:{ot.agentVersion=tt.string();break}case 1:{ot.publicKey=tt.bytes();break}case 2:{if(((st=nt.limits)==null?void 0:st.listenAddrs)!=null&&ot.listenAddrs.length===nt.limits.listenAddrs)throw new MaxLengthError('Decode error - map field "listenAddrs" had too many elements');ot.listenAddrs.push(tt.bytes());break}case 4:{ot.observedAddr=tt.bytes();break}case 3:{if(((at=nt.limits)==null?void 0:at.protocols)!=null&&ot.protocols.length===nt.limits.protocols)throw new MaxLengthError('Decode error - map field "protocols" had too many elements');ot.protocols.push(tt.string());break}case 8:{ot.signedPeerRecord=tt.bytes();break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Identify$1||(Identify$1={}));function isElectron$1(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}var isElectron_1=isElectron$1;const detectElectron=getDefaultExportFromCjs(isElectron_1),isEnvWithDom=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,isElectron=detectElectron(),isBrowser=isEnvWithDom&&!isElectron,isElectronMain=isElectron&&!isEnvWithDom,isElectronRenderer=isElectron&&isEnvWithDom,isNode=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!isElectron,isWebWorker=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",defaultValues={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:MAX_IDENTIFY_MESSAGE_SIZE,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:MAX_PUSH_CONCURRENCY};function getCleanMultiaddr(et){if(et!=null&&et.length>0)try{return multiaddr(et)}catch{}}function getAgentVersion(et,o){return o!=null||(o=`${et.name}/${et.version}`,isNode||isElectronMain?o+=` UserAgent=${globalThis.process.version}`:(isBrowser||isWebWorker||isElectronRenderer||isReactNative)&&(o+=` UserAgent=${globalThis.navigator.userAgent}`)),o}async function consumeIdentifyMessage(et,o,tt,rt,nt){if(tt("received identify from %p",rt.remotePeer),nt==null)throw new InvalidMessageError$2("message was null or undefined");const ot={};if(nt.listenAddrs.length>0&&(ot.addresses=nt.listenAddrs.map(at=>({isCertified:!1,multiaddr:multiaddr(at)}))),nt.protocols.length>0&&(ot.protocols=nt.protocols),nt.publicKey!=null){const at=publicKeyFromProtobuf(nt.publicKey);if(!peerIdFromPublicKey(at).equals(rt.remotePeer))throw new InvalidMessageError$2("public key did not match remote PeerId");ot.publicKey=at}let it;if(nt.signedPeerRecord!=null){tt.trace("received signedPeerRecord from %p",rt.remotePeer);let at=nt.signedPeerRecord;const ct=await RecordEnvelope.openAndCertify(at,PeerRecord.DOMAIN);let lt=PeerRecord.createFromProtobuf(ct.payload);const dt=peerIdFromCID(ct.publicKey.toCID());if(!lt.peerId.equals(dt))throw new InvalidMessageError$2("signing key does not match PeerId in the PeerRecord");if(!rt.remotePeer.equals(lt.peerId))throw new InvalidMessageError$2("signing key does not match remote PeerId");let ht;try{ht=await et.get(lt.peerId)}catch(mt){if(mt.name!=="NotFoundError")throw mt}if(ht!=null&&(ot.metadata=ht.metadata,ht.peerRecordEnvelope!=null)){const mt=await RecordEnvelope.createFromProtobuf(ht.peerRecordEnvelope),ft=PeerRecord.createFromProtobuf(mt.payload);ft.seqNumber>=lt.seqNumber&&(tt("sequence number was lower or equal to existing sequence number - stored: %d received: %d",ft.seqNumber,lt.seqNumber),lt=ft,at=ht.peerRecordEnvelope)}ot.peerRecordEnvelope=at,ot.addresses=lt.multiaddrs.map(mt=>({isCertified:!0,multiaddr:mt})),it={seq:lt.seqNumber,addresses:lt.multiaddrs}}else tt("%p did not send a signed peer record",rt.remotePeer);if(tt.trace("patching %p with",rt.remotePeer,ot),await et.patch(rt.remotePeer,ot),nt.agentVersion!=null||nt.protocolVersion!=null){const at={};nt.agentVersion!=null&&(at.AgentVersion=fromString$h(nt.agentVersion)),nt.protocolVersion!=null&&(at.ProtocolVersion=fromString$h(nt.protocolVersion)),tt.trace("merging %p metadata",rt.remotePeer,at),await et.merge(rt.remotePeer,{metadata:at})}const st={peerId:rt.remotePeer,protocolVersion:nt.protocolVersion,agentVersion:nt.agentVersion,publicKey:nt.publicKey,listenAddrs:nt.listenAddrs.map(at=>multiaddr(at)),observedAddr:nt.observedAddr==null?void 0:multiaddr(nt.observedAddr),protocols:nt.protocols,signedPeerRecord:it,connection:rt};return o.safeDispatchEvent("peer:identify",{detail:st}),st}class AbstractIdentify{constructor(o,tt){wt(this,"host");wt(this,"protocol");wt(this,"started");wt(this,"timeout");wt(this,"peerId");wt(this,"privateKey");wt(this,"peerStore");wt(this,"registrar");wt(this,"addressManager");wt(this,"maxInboundStreams");wt(this,"maxOutboundStreams");wt(this,"maxMessageSize");wt(this,"maxObservedAddresses");wt(this,"events");wt(this,"runOnLimitedConnection");wt(this,"log");this.protocol=tt.protocol,this.started=!1,this.peerId=o.peerId,this.privateKey=o.privateKey,this.peerStore=o.peerStore,this.registrar=o.registrar,this.addressManager=o.addressManager,this.events=o.events,this.log=tt.log,this.timeout=tt.timeout??defaultValues.timeout,this.maxInboundStreams=tt.maxInboundStreams??defaultValues.maxInboundStreams,this.maxOutboundStreams=tt.maxOutboundStreams??defaultValues.maxOutboundStreams,this.maxMessageSize=tt.maxMessageSize??defaultValues.maxMessageSize,this.maxObservedAddresses=tt.maxObservedAddresses??defaultValues.maxObservedAddresses,this.runOnLimitedConnection=tt.runOnLimitedConnection??defaultValues.runOnLimitedConnection,this.host={protocolVersion:`${tt.protocolPrefix??defaultValues.protocolPrefix}/${IDENTIFY_PROTOCOL_VERSION}`,agentVersion:getAgentVersion(o.nodeInfo,tt.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:fromString$h(this.host.agentVersion),ProtocolVersion:fromString$h(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,o=>{this.handleProtocol(o).catch(tt=>{this.log.error(tt)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}}var Netmask_1;(function(){var et,o,tt,rt,nt,ot,it,st;st=function(at){var ct,lt,dt,ht;return ct=(at&255<<24)>>>24,lt=(at&255<<16)>>>16,dt=(at&65280)>>>8,ht=at&255,[ct,lt,dt,ht].join(".")},it=function(at){var ct,lt,dt,ht,mt,ft;for(ct=[],dt=ht=0;ht<=3&&at.length!==0;dt=++ht){if(dt>0){if(at[0]!==".")throw new Error("Invalid IP");at=at.substring(1)}ft=o(at),mt=ft[0],lt=ft[1],at=at.substring(lt),ct.push(mt)}if(at.length!==0)throw new Error("Invalid IP");switch(ct.length){case 1:if(ct[0]>4294967295)throw new Error("Invalid IP");return ct[0]>>>0;case 2:if(ct[0]>255||ct[1]>16777215)throw new Error("Invalid IP");return(ct[0]<<24|ct[1])>>>0;case 3:if(ct[0]>255||ct[1]>255||ct[2]>65535)throw new Error("Invalid IP");return(ct[0]<<24|ct[1]<<16|ct[2])>>>0;case 4:if(ct[0]>255||ct[1]>255||ct[2]>255||ct[3]>255)throw new Error("Invalid IP");return(ct[0]<<24|ct[1]<<16|ct[2]<<8|ct[3])>>>0;default:throw new Error("Invalid IP")}},tt=function(at){return at.charCodeAt(0)},rt=tt("0"),ot=tt("a"),nt=tt("A"),o=function(at){var ct,lt,dt,ht,mt;for(ht=0,ct=10,lt="9",dt=0,at.length>1&&at[dt]==="0"&&(at[dt+1]==="x"||at[dt+1]==="X"?(dt+=2,ct=16):"0"<=at[dt+1]&&at[dt+1]<="9"&&(dt++,ct=8,lt="7")),mt=dt;dt>>0;else if(ct===16)if("a"<=at[dt]&&at[dt]<="f")ht=ht*ct+(10+tt(at[dt])-ot)>>>0;else if("A"<=at[dt]&&at[dt]<="F")ht=ht*ct+(10+tt(at[dt])-nt)>>>0;else break;else break;if(ht>4294967295)throw new Error("too large");dt++}if(dt===mt)throw new Error("empty octet");return[ht,dt]},et=function(){function at(ct,lt){var dt,ht,mt;if(typeof ct!="string")throw new Error("Missing `net' parameter");if(lt||(mt=ct.split("/",2),ct=mt[0],lt=mt[1]),lt||(lt=32),typeof lt=="string"&<.indexOf(".")>-1){try{this.maskLong=it(lt)}catch{throw new Error("Invalid mask: "+lt)}for(dt=ht=32;ht>=0;dt=--ht)if(this.maskLong===4294967295<<32-dt>>>0){this.bitmask=dt;break}}else if(lt||lt===0)this.bitmask=parseInt(lt,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(it(ct)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+ct)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+lt);this.size=Math.pow(2,32-this.bitmask),this.base=st(this.netLong),this.mask=st(this.maskLong),this.hostmask=st(~this.maskLong),this.first=this.bitmask<=30?st(this.netLong+1):this.base,this.last=this.bitmask<=30?st(this.netLong+this.size-2):st(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?st(this.netLong+this.size-1):void 0}return at.prototype.contains=function(ct){return typeof ct=="string"&&(ct.indexOf("/")>0||ct.split(".").length!==4)&&(ct=new at(ct)),ct instanceof at?this.contains(ct.base)&&this.contains(ct.broadcast||ct.last):(it(ct)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},at.prototype.next=function(ct){return ct==null&&(ct=1),new at(st(this.netLong+this.size*ct),this.mask)},at.prototype.forEach=function(ct){var lt,dt,ht;for(ht=it(this.first),dt=it(this.last),lt=0;ht<=dt;)ct(st(ht),ht,lt),lt++,ht++},at.prototype.toString=function(){return this.base+"/"+this.bitmask},at}(),Netmask_1=et}).call(commonjsGlobal);const PRIVATE_IP_RANGES=["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"],NETMASK_RANGES=PRIVATE_IP_RANGES.map(et=>new Netmask_1(et));function ipv4Check(et){for(const o of NETMASK_RANGES)if(o.contains(et))return!0;return!1}function isIpv4MappedIpv6(et){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(et)}function ipv4MappedIpv6Check(et){const o=et.split(":");if(o.length<2)return!1;const tt=o[o.length-1].padStart(4,"0"),rt=o[o.length-2].padStart(4,"0"),nt=`${parseInt(rt.substring(0,2),16)}.${parseInt(rt.substring(2),16)}.${parseInt(tt.substring(0,2),16)}.${parseInt(tt.substring(2),16)}`;return ipv4Check(nt)}function isIpv4EmbeddedIpv6(et){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(et)}function ipv4EmbeddedIpv6Check(et){const o=et.split(":"),tt=o[o.length-1];return ipv4Check(tt)}function ipv6Check(et){return/^::$/.test(et)||/^::1$/.test(et)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(et)||/^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(et)||/^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(et)||/^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(et)||/^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(et)||/^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(et)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(et)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(et)||/^ff([0-9a-fA-F]{2,2}):/i.test(et)}function isPrivateIp(et){return isIPv4(et)?ipv4Check(et):isIpv4MappedIpv6(et)?ipv4MappedIpv6Check(et):isIpv4EmbeddedIpv6(et)?ipv4EmbeddedIpv6Check(et):isIPv6(et)?ipv6Check(et):void 0}function coerce$d(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function base$c(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$d=base$c,_brrp__multiformats_scope_baseX$c=src$d;let Encoder$d=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$d=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$d(this,o)}},ComposedDecoder$c=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$d(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$d(et,o){return new ComposedDecoder$c({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$c=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$d(o,tt,rt),this.decoder=new Decoder$d(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$d({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$c(et,o,tt,rt)}function baseX$c({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$c(tt,et);return from$d({prefix:o,name:et,encode:rt,decode:ot=>coerce$d(nt(ot))})}function decode$v(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$r(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<et.toString().split("/").slice(1),func=et=>({match:o=>o.length<1?!1:et(o[0])?o.slice(1):!1,pattern:"fn"}),literal=et=>({match:o=>func(tt=>tt===et).match(o),pattern:et}),string$c=()=>({match:et=>func(o=>typeof o=="string").match(et),pattern:"{string}"}),number$1=()=>({match:et=>func(o=>!isNaN(parseInt(o))).match(et),pattern:"{number}"}),peerId=()=>({match:et=>{if(et.length<2||et[0]!=="p2p"&&et[0]!=="ipfs")return!1;if(et[1].startsWith("Q")||et[1].startsWith("1"))try{base58btc$c.decode(`z${et[1]}`)}catch{return!1}else return!1;return et.slice(2)},pattern:"/p2p/{peerid}"}),certhash=()=>({match:et=>{if(et.length<2||et[0]!=="certhash")return!1;try{base64url$9.decode(et[1])}catch{return!1}return et.slice(2)},pattern:"/certhash/{certhash}"}),optional=et=>({match:o=>{const tt=et.match(o);return tt===!1?o:tt},pattern:`optional(${et.pattern})`}),or$c=(...et)=>({match:o=>{let tt;for(const rt of et){const nt=rt.match(o);nt!==!1&&(tt==null||nt.lengtho.pattern).join(", ")})`}),and=(...et)=>({match:o=>{for(const tt of et){const rt=tt.match(o);if(rt===!1)return!1;o=rt}return o},pattern:`and(${et.map(o=>o.pattern).join(", ")})`});function fmt(...et){function o(nt){let ot=toParts(nt);for(const it of et){const st=it.match(ot);if(st===!1)return!1;ot=st}return ot}function tt(nt){return o(nt)!==!1}function rt(nt){const ot=o(nt);return ot===!1?!1:ot.length===0}return{matchers:et,matches:tt,exactMatch:rt}}const _DNS4=and(literal("dns4"),string$c()),_DNS6=and(literal("dns6"),string$c()),_DNSADDR=and(literal("dnsaddr"),string$c()),_DNS=and(literal("dns"),string$c());fmt(_DNS4,optional(peerId()));fmt(_DNS6,optional(peerId()));fmt(_DNSADDR,optional(peerId()));fmt(or$c(_DNS,_DNSADDR,_DNS4,_DNS6),optional(peerId()));const _IP4=and(literal("ip4"),func(isIPv4)),_IP6=and(literal("ip6"),func(isIPv6)),_IP=or$c(_IP4,_IP6),_IP_OR_DOMAIN=or$c(_IP,_DNS,_DNS4,_DNS6,_DNSADDR),IP_OR_DOMAIN=fmt(or$c(_IP,and(or$c(_DNS,_DNSADDR,_DNS4,_DNS6),optional(peerId())))),_TCP=and(_IP_OR_DOMAIN,literal("tcp"),number$1()),_UDP=and(_IP_OR_DOMAIN,literal("udp"),number$1()),TCP=fmt(and(_TCP,optional(peerId()))),_QUIC=and(_UDP,literal("quic")),_QUICV1=and(_UDP,literal("quic-v1")),QUIC_V0_OR_V1=or$c(_QUIC,_QUICV1),_WEB=or$c(_IP_OR_DOMAIN,_TCP,_UDP,_QUIC,_QUICV1),_WebSockets=or$c(and(_WEB,literal("ws"),optional(peerId()))),WebSockets$1=fmt(_WebSockets),_WebSocketsSecure=or$c(and(_WEB,literal("wss"),optional(peerId())),and(_WEB,literal("tls"),literal("ws"),optional(peerId()))),WebSocketsSecure=fmt(_WebSocketsSecure),_WebRTCDirect=and(_UDP,literal("webrtc-direct"),optional(certhash()),optional(certhash()),optional(peerId())),WebRTCDirect=fmt(_WebRTCDirect),_WebTransport=and(_QUICV1,literal("webtransport"),optional(certhash()),optional(certhash()),optional(peerId())),WebTransport=fmt(_WebTransport),_P2P=or$c(_WebSockets,_WebSocketsSecure,and(_TCP,optional(peerId())),and(QUIC_V0_OR_V1,optional(peerId())),and(_IP_OR_DOMAIN,optional(peerId())),_WebRTCDirect,_WebTransport,peerId()),_Circuit=and(_P2P,literal("p2p-circuit"),peerId()),Circuit=fmt(_Circuit),_WebRTC=or$c(and(_P2P,literal("p2p-circuit"),literal("webrtc"),optional(peerId())),and(_P2P,literal("webrtc"),optional(peerId())),literal("webrtc")),WebRTC=fmt(_WebRTC);or$c(and(_IP_OR_DOMAIN,literal("tcp"),number$1(),literal("http"),optional(peerId())),and(_IP_OR_DOMAIN,literal("http"),optional(peerId())));or$c(and(_IP_OR_DOMAIN,literal("tcp"),or$c(and(literal("443"),literal("http")),and(number$1(),literal("https"))),optional(peerId())),and(_IP_OR_DOMAIN,literal("tls"),literal("http"),optional(peerId())),and(_IP_OR_DOMAIN,literal("https"),optional(peerId())));var Rl,Tl;class Identify extends(Tl=AbstractIdentify,Rl=serviceCapabilities$3,Tl){constructor(tt,rt={}){super(tt,{...rt,protocol:`/${rt.protocolPrefix??defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`,log:tt.logger.forComponent("libp2p:identify")});wt(this,Rl,["@libp2p/identify"]);(rt.runOnConnectionOpen??defaultValues.runOnConnectionOpen)&&tt.events.addEventListener("connection:open",nt=>{const ot=nt.detail;this.identify(ot).catch(it=>{it.name!==UnsupportedProtocolError$1.name&&this.log.error("error during identify trigged by connection:open",it)})})}async _identify(tt,rt={}){let nt;if(rt.signal==null){const ot=AbortSignal.timeout(this.timeout);setMaxListeners$4(1/0,ot),rt={...rt,signal:ot}}try{nt=await tt.newStream(this.protocol,{...rt,runOnLimitedConnection:this.runOnLimitedConnection});const it=await pbStream(nt,{maxDataLength:this.maxMessageSize}).pb(Identify$1).read(rt);return await nt.close(rt),it}catch(ot){throw nt==null||nt.abort(ot),ot}}async identify(tt,rt={}){const nt=await this._identify(tt,rt),{publicKey:ot,protocols:it,observedAddr:st}=nt;if(ot==null)throw new InvalidMessageError$2("public key was missing from identify message");const at=publicKeyFromProtobuf(ot),ct=peerIdFromCID(at.toCID());if(!tt.remotePeer.equals(ct))throw new InvalidMessageError$2("identified peer does not match the expected peer");if(this.peerId.equals(ct))throw new InvalidMessageError$2("identified peer is our own peer id?");const lt=getCleanMultiaddr(st);return this.log("identify completed for peer %p and protocols %o",ct,it),lt!=null&&(this.log("our observed address was %a",lt),isPrivateIp(lt==null?void 0:lt.nodeAddress().address)===!0?this.log("our observed address was private"):this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(this.log("storing our observed address"),this.addressManager.addObservedAddr(lt))),consumeIdentifyMessage(this.peerStore,this.events,this.log,tt,nt)}async handleProtocol(tt){const{connection:rt,stream:nt}=tt,ot=AbortSignal.timeout(this.timeout);setMaxListeners$4(1/0,ot);try{const it=await this.peerStore.get(this.peerId),st=this.addressManager.getAddresses().map(dt=>dt.decapsulateCode(getProtocol("p2p").code));let at=it.peerRecordEnvelope;if(st.length>0&&at==null){const dt=new PeerRecord({peerId:this.peerId,multiaddrs:st});at=(await RecordEnvelope.seal(dt,this.privateKey)).marshal().subarray()}let ct=rt.remoteAddr.bytes;IP_OR_DOMAIN.matches(rt.remoteAddr)||(ct=void 0),await pbStream(nt).pb(Identify$1).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:publicKeyToProtobuf(this.privateKey.publicKey),listenAddrs:st.map(dt=>dt.bytes),signedPeerRecord:at,observedAddr:ct,protocols:it.protocols},{signal:ot}),await nt.close({signal:ot})}catch(it){this.log.error("could not respond to identify request",it),nt.abort(it)}}}function identify(et={}){return o=>new Identify(o,et)}class MuxerClosedError extends Error{constructor(o="The muxer is closed"){super(o),this.name="MuxerClosedError"}}wt(MuxerClosedError,"name","MuxerClosedError");var bs;let InvalidMessageError$1=(bs=class extends Error{constructor(o="Invalid message"){super(o),this.name="InvalidMessageError"}},wt(bs,"name","InvalidMessageError"),bs);var xs;let TooManyOutboundProtocolStreamsError$1=(xs=class extends Error{constructor(o="Too many outbound protocol streams"){super(o),this.name="TooManyOutboundProtocolStreamsError"}},wt(xs,"name","TooManyOutboundProtocolStreamsError"),xs);const serviceCapabilities$2=Symbol.for("@libp2p/service-capabilities");function getIterator(et){if(et!=null){if(typeof et[Symbol.iterator]=="function")return et[Symbol.iterator]();if(typeof et[Symbol.asyncIterator]=="function")return et[Symbol.asyncIterator]();if(typeof et.next=="function")return et}throw new Error("argument is not an iterator or iterable")}function isPromise$2(et){return et==null?!1:typeof et.then=="function"&&typeof et.catch=="function"&&typeof et.finally=="function"}function closeSource(et,o){var rt,nt;const tt=(nt=(rt=getIterator(et)).return)==null?void 0:nt.call(rt);isPromise$2(tt)&&tt.catch(ot=>{o.error("could not cause iterator to return",ot)})}const createAbortError=()=>{const et=new Error("Delay aborted");return et.name="AbortError",et},clearMethods=new WeakMap;function createDelay({clearTimeout:et,setTimeout:o}={}){return(tt,{value:rt,signal:nt}={})=>{if(nt!=null&&nt.aborted)return Promise.reject(createAbortError());let ot,it,st;const at=et??clearTimeout,ct=()=>{at(ot),st(createAbortError())},lt=()=>{nt&&nt.removeEventListener("abort",ct)},dt=new Promise((ht,mt)=>{it=()=>{lt(),ht(rt)},st=mt,ot=(o??setTimeout)(it,tt)});return nt&&nt.addEventListener("abort",ct,{once:!0}),clearMethods.set(dt,()=>{at(ot),ot=null,it()}),dt}}const delay=createDelay();class RateLimitError extends Error{constructor(tt="Rate limit exceeded",rt){super(tt);wt(this,"remainingPoints");wt(this,"msBeforeNext");wt(this,"consumedPoints");wt(this,"isFirstInDuration");this.name="RateLimitError",this.remainingPoints=rt.remainingPoints,this.msBeforeNext=rt.msBeforeNext,this.consumedPoints=rt.consumedPoints,this.isFirstInDuration=rt.isFirstInDuration}}class QueueFullError extends Error{constructor(o="The queue was full"){super(o),this.name="QueueFullError"}}wt(QueueFullError,"name","QueueFullError");class RateLimiter{constructor(o={}){wt(this,"memoryStorage");wt(this,"points");wt(this,"duration");wt(this,"blockDuration");wt(this,"execEvenly");wt(this,"execEvenlyMinDelayMs");wt(this,"keyPrefix");this.points=o.points??4,this.duration=o.duration??1,this.blockDuration=o.blockDuration??0,this.execEvenly=o.execEvenly??!1,this.execEvenlyMinDelayMs=o.execEvenlyMinDelayMs??this.duration*1e3/this.points,this.keyPrefix=o.keyPrefix??"rlflx",this.memoryStorage=new MemoryStorage}async consume(o,tt=1,rt={}){const nt=this.getKey(o),ot=this._getKeySecDuration(rt);let it=this.memoryStorage.incrby(nt,tt,ot);if(it.remainingPoints=Math.max(this.points-it.consumedPoints,0),it.consumedPoints>this.points)throw this.blockDuration>0&&it.consumedPoints<=this.points+tt&&(it=this.memoryStorage.set(nt,it.consumedPoints,this.blockDuration)),new RateLimitError("Rate limit exceeded",it);if(this.execEvenly&&it.msBeforeNext>0&&!it.isFirstInDuration){let st=Math.ceil(it.msBeforeNext/(it.remainingPoints+2));st=0?rt:this.duration)*1e3;return this.memoryStorage.set(this.getKey(o),tt,rt),{remainingPoints:0,msBeforeNext:nt===0?-1:nt,consumedPoints:tt,isFirstInDuration:!1}}get(o){const tt=this.memoryStorage.get(this.getKey(o));return tt!=null&&(tt.remainingPoints=Math.max(this.points-tt.consumedPoints,0)),tt}delete(o){this.memoryStorage.delete(this.getKey(o))}_getKeySecDuration(o){return(o==null?void 0:o.customDuration)!=null&&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)}}class MemoryStorage{constructor(){wt(this,"storage");this.storage=new Map}incrby(o,tt,rt){const nt=this.storage.get(o);if(nt!=null){const ot=nt.expiresAt!=null?nt.expiresAt.getTime()-new Date().getTime():-1;return nt.expiresAt==null||ot>0?(nt.value+=tt,{remainingPoints:0,msBeforeNext:ot,consumedPoints:nt.value,isFirstInDuration:!1}):this.set(o,tt,rt)}return this.set(o,tt,rt)}set(o,tt,rt){const nt=rt*1e3,ot=this.storage.get(o);ot!=null&&clearTimeout(ot.timeoutId);const it={value:tt,expiresAt:nt>0?new Date(Date.now()+nt):void 0};return this.storage.set(o,it),nt>0&&(it.timeoutId=setTimeout(()=>{this.storage.delete(o)},nt),it.timeoutId.unref!=null&&it.timeoutId.unref()),{remainingPoints:0,msBeforeNext:nt===0?-1:nt,consumedPoints:it.value,isFirstInDuration:!0}}get(o){const tt=this.storage.get(o);if(tt!=null)return{remainingPoints:0,msBeforeNext:tt.expiresAt!=null?tt.expiresAt.getTime()-new Date().getTime():-1,consumedPoints:tt.value,isFirstInDuration:!1}}delete(o){const tt=this.storage.get(o);return tt!=null?(tt.timeoutId!=null&&clearTimeout(tt.timeoutId),this.storage.delete(o),!0):!1}}function allocUnsafe$7(et=0){return new Uint8Array(et)}function coerce$c(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$g(et){return new TextEncoder().encode(et)}function toString$j(et){return new TextDecoder().decode(et)}function base$b(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$c=base$b,_brrp__multiformats_scope_baseX$b=src$c;let Encoder$c=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$c=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$b(this,o)}},ComposedDecoder$b=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$b(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$b(et,o){return new ComposedDecoder$b({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$b=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$c(o,tt,rt),this.decoder=new Decoder$c(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$c({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$b(et,o,tt,rt)}function baseX$b({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$b(tt,et);return from$c({prefix:o,name:et,encode:rt,decode:ot=>coerce$c(nt(ot))})}function decode$u(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$q(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$8=alphabet$8.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$p(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$8[tt],o),"")}function decode$t(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$8[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$g=from$c({prefix:"🚀",name:"base256emoji",encode:encode$p,decode:decode$t}),base256emoji$h=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$g},Symbol.toStringTag,{value:"Module"})),base32$k=rfc4648$a({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$8=rfc4648$a({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$8=rfc4648$a({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$8=rfc4648$a({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$8=rfc4648$a({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$8=rfc4648$a({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$8=rfc4648$a({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$8=rfc4648$a({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$8=rfc4648$a({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$l=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$k,base32hex:base32hex$8,base32hexpad:base32hexpad$8,base32hexpadupper:base32hexpadupper$8,base32hexupper:base32hexupper$8,base32pad:base32pad$8,base32padupper:base32padupper$8,base32upper:base32upper$8,base32z:base32z$8},Symbol.toStringTag,{value:"Module"})),base36$h=baseX$b({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$8=baseX$b({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$i=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$h,base36upper:base36upper$8},Symbol.toStringTag,{value:"Module"})),base58btc$b=baseX$b({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$8=baseX$b({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$8=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$b,base58flickr:base58flickr$8},Symbol.toStringTag,{value:"Module"})),base64$j=rfc4648$a({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$8=rfc4648$a({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$8=rfc4648$a({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$8=rfc4648$a({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$k=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$j,base64pad:base64pad$8,base64url:base64url$8,base64urlpad:base64urlpad$8},Symbol.toStringTag,{value:"Module"})),base8$g=rfc4648$a({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$h=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$g},Symbol.toStringTag,{value:"Module"})),identity$8=from$c({prefix:"\0",name:"identity",encode:et=>toString$j(et),decode:et=>fromString$g(et)}),identityBase$8=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$8},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$8={...identityBase$8,...base2$h,...base8$h,...base10$h,...base16$h,...base32$l,...base36$i,...base58$8,...base64$k,...base256emoji$h};function createCodec$8(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$b=createCodec$8("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$8=createCodec$8("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$7(et.length);for(let tt=0;ttthis._maxUnprocessedMessageQueueSize)throw new InvalidMessageError$1("Unprocessed message queue size too large!");const tt=[];for(;this._buffer.length!==0;){if(this._headerInfo==null)try{this._headerInfo=this._decodeHeader(this._buffer)}catch(ct){if(ct.name==="InvalidMessageError")throw ct;break}const{id:rt,type:nt,length:ot,offset:it}=this._headerInfo;if(this._buffer.length-itthis._maxMessageSize)throw new InvalidMessageError$1("Message size too large");return{id:tt>>3,type:it,offset:rt+ot,length:nt}}};const MSB$3=128,REST$3=127;function readVarInt(et,o=0){let tt=0,rt=0,nt=o,ot;const it=et.length;do{if(nt>=it||rt>49)throw o=0,new RangeError("Could not decode varint");ot=et.get(nt++),tt+=rt<28?(ot&REST$3)<=MSB$3);return o=nt-o,{value:tt,offset:o}}const POOL_SIZE=10*1024;let Encoder$b=class{constructor(){wt(this,"_pool");wt(this,"_poolOffset");this._pool=allocUnsafe$7(POOL_SIZE),this._poolOffset=0}write(o,tt){const rt=this._pool;let nt=this._poolOffset;encode$P(o.id<<3|o.type,rt,nt),nt+=encodingLength$6(o.id<<3|o.type),(o.type===MessageTypes.NEW_STREAM||o.type===MessageTypes.MESSAGE_INITIATOR||o.type===MessageTypes.MESSAGE_RECEIVER)&&o.data!=null?(encode$P(o.data.length,rt,nt),nt+=encodingLength$6(o.data.length)):(encode$P(0,rt,nt),nt+=encodingLength$6(0));const ot=rt.subarray(this._poolOffset,nt);POOL_SIZE-nt<100?(this._pool=allocUnsafe$7(POOL_SIZE),this._poolOffset=0):this._poolOffset=nt,tt.append(ot),(o.type===MessageTypes.NEW_STREAM||o.type===MessageTypes.MESSAGE_INITIATOR||o.type===MessageTypes.MESSAGE_RECEIVER)&&o.data!=null&&tt.append(o.data)}};const encoder$1=new Encoder$b;async function*encode$o(et){for await(const o of et){const tt=new Uint8ArrayList;encoder$1.write(o,tt),yield tt}}class StreamInputBufferError extends Error{constructor(o="Stream input buffer error"){super(o),this.name="StreamInputBufferError"}}var vs;let AbortError$6=(vs=class extends Error{constructor(o="The operation was aborted"){super(o),this.name="AbortError"}},wt(vs,"name","AbortError"),vs);class StreamResetError extends Error{constructor(o="The stream has been reset"){super(o),this.name="StreamResetError"}}wt(StreamResetError,"name","StreamResetError");class StreamStateError extends Error{constructor(o="The stream is in an invalid state"){super(o),this.name="StreamStateError"}}wt(StreamStateError,"name","StreamStateError");function setMaxListeners$3(){}const setMaxListeners$2=(et,...o)=>{try{[...o]}catch{}};var Jr,Il;let TypedEventEmitter$1=(Il=class extends EventTarget{constructor(){super();hr(this,Jr,new Map);setMaxListeners$2(1/0,this)}listenerCount(tt){const rt=Lt(this,Jr).get(tt);return rt==null?0:rt.length}addEventListener(tt,rt,nt){super.addEventListener(tt,rt,nt);let ot=Lt(this,Jr).get(tt);ot==null&&(ot=[],Lt(this,Jr).set(tt,ot)),ot.push({callback:rt,once:(nt!==!0&&nt!==!1&&(nt==null?void 0:nt.once))??!1})}removeEventListener(tt,rt,nt){super.removeEventListener(tt.toString(),rt??null,nt);let ot=Lt(this,Jr).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==rt),Lt(this,Jr).set(tt,ot))}dispatchEvent(tt){const rt=super.dispatchEvent(tt);let nt=Lt(this,Jr).get(tt.type);return nt==null||(nt=nt.filter(({once:ot})=>!ot),Lt(this,Jr).set(tt.type,nt)),rt}safeDispatchEvent(tt,rt={}){return this.dispatchEvent(new CustomEvent(tt,rt))}},Jr=new WeakMap,Il);const DEFAULT_SEND_CLOSE_WRITE_TIMEOUT=5e3;function isPromise$1(et){return et==null?!1:typeof et.then=="function"&&typeof et.catch=="function"&&typeof et.finally=="function"}class AbstractStream{constructor(o){wt(this,"id");wt(this,"direction");wt(this,"timeline");wt(this,"protocol");wt(this,"metadata");wt(this,"source");wt(this,"status");wt(this,"readStatus");wt(this,"writeStatus");wt(this,"log");wt(this,"sinkController");wt(this,"sinkEnd");wt(this,"closed");wt(this,"endErr");wt(this,"streamSource");wt(this,"onEnd");wt(this,"onCloseRead");wt(this,"onCloseWrite");wt(this,"onReset");wt(this,"onAbort");wt(this,"sendCloseWriteTimeout");wt(this,"sendingData");this.sinkController=new AbortController,this.sinkEnd=pDefer(),this.closed=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??DEFAULT_SEND_CLOSE_WRITE_TIMEOUT,this.onEnd=o.onEnd,this.onCloseRead=o==null?void 0:o.onCloseRead,this.onCloseWrite=o==null?void 0:o.onCloseWrite,this.onReset=o==null?void 0:o.onReset,this.onAbort=o==null?void 0:o.onAbort,this.source=this.streamSource=pushable({onEnd:tt=>{tt!=null?this.log.trace("source ended with error",tt):this.log.trace("source ended"),this.onSourceEnd(tt)}}),this.sink=this.sink.bind(this)}async sink(o){if(this.writeStatus!=="ready")throw new StreamStateError(`writable end state is "${this.writeStatus}" not "ready"`);try{this.writeStatus="writing";const tt={signal:this.sinkController.signal};if(this.direction==="outbound"){const nt=this.sendNewStream(tt);isPromise$1(nt)&&await nt}const rt=()=>{closeSource(o,this.log)};try{this.sinkController.signal.addEventListener("abort",rt),this.log.trace("sink reading from source");for await(let nt of o){nt=nt instanceof Uint8Array?new Uint8ArrayList(nt):nt;const ot=this.sendData(nt,tt);isPromise$1(ot)&&(this.sendingData=pDefer(),await ot,this.sendingData.resolve(),this.sendingData=void 0)}}finally{this.sinkController.signal.removeEventListener("abort",rt)}this.log.trace('sink finished reading from source, write status is "%s"',this.writeStatus),this.writeStatus==="writing"&&(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(tt){throw this.log.trace("sink ended with error, calling abort with error",tt),this.abort(tt),tt}finally{this.log.trace("resolve sink end"),this.sinkEnd.resolve()}}onSourceEnd(o){var tt;this.timeline.closeRead==null&&(this.timeline.closeRead=Date.now(),this.readStatus="closed",o!=null&&this.endErr==null&&(this.endErr=o),(tt=this.onCloseRead)==null||tt.call(this),this.timeline.closeWrite!=null?(this.log.trace("source and sink ended"),this.timeline.close=Date.now(),this.status!=="aborted"&&this.status!=="reset"&&(this.status="closed"),this.onEnd!=null&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("source ended, waiting for sink to end"))}onSinkEnd(o){var tt;this.timeline.closeWrite==null&&(this.timeline.closeWrite=Date.now(),this.writeStatus="closed",o!=null&&this.endErr==null&&(this.endErr=o),(tt=this.onCloseWrite)==null||tt.call(this),this.timeline.closeRead!=null?(this.log.trace("sink and source ended"),this.timeline.close=Date.now(),this.status!=="aborted"&&this.status!=="reset"&&(this.status="closed"),this.onEnd!=null&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("sink ended, waiting for source to end"))}async close(o){this.log.trace("closing gracefully"),this.status="closing",await raceSignal(Promise.all([this.closeWrite(o),this.closeRead(o),this.closed.promise]),o==null?void 0:o.signal),this.status="closed",this.log.trace("closed gracefully")}async closeRead(o={}){if(this.readStatus==="closing"||this.readStatus==="closed")return;this.log.trace('closing readable end of stream with starting read status "%s"',this.readStatus);const tt=this.readStatus;this.readStatus="closing",this.status!=="reset"&&this.status!=="aborted"&&this.timeline.closeRead==null&&(this.log.trace("send close read to remote"),await this.sendCloseRead(o)),tt==="ready"&&(this.log.trace("ending internal source queue with %d queued bytes",this.streamSource.readableLength),this.streamSource.end()),this.log.trace("closed readable end of stream")}async closeWrite(o={}){this.writeStatus==="closing"||this.writeStatus==="closed"||(this.log.trace('closing writable end of stream with starting write status "%s"',this.writeStatus),this.writeStatus==="ready"&&(this.log.trace("sink was never sunk, sink an empty array"),await raceSignal(this.sink([]),o.signal)),this.writeStatus==="writing"&&(this.sendingData!=null&&await raceSignal(this.sendingData.promise,o.signal),this.log.trace("aborting source passed to .sink"),this.sinkController.abort(),await raceSignal(this.sinkEnd.promise,o.signal)),this.writeStatus="closed",this.log.trace("closed writable end of stream"))}abort(o){var rt;if(this.status==="closed"||this.status==="aborted"||this.status==="reset")return;this.log("abort with error",o),this.log("try to send reset to remote");const tt=this.sendReset();isPromise$1(tt)&&tt.catch(nt=>{this.log.error("error sending reset message",nt)}),this.status="aborted",this.timeline.abort=Date.now(),this._closeSinkAndSource(o),(rt=this.onAbort)==null||rt.call(this,o)}reset(){var tt;if(this.status==="closed"||this.status==="aborted"||this.status==="reset")return;const o=new StreamResetError("stream reset");this.status="reset",this.timeline.reset=Date.now(),this._closeSinkAndSource(o),(tt=this.onReset)==null||tt.call(this)}_closeSinkAndSource(o){this._closeSink(o),this._closeSource(o)}_closeSink(o){this.writeStatus==="writing"&&(this.log.trace("end sink source"),this.sinkController.abort()),this.onSinkEnd(o)}_closeSource(o){this.readStatus!=="closing"&&this.readStatus!=="closed"&&(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(this.readStatus==="closing"||this.readStatus==="closed"){this.log("received remote close write but local source is already closed");return}this.log.trace("remote close write"),this._closeSource()}remoteCloseRead(){if(this.writeStatus==="closing"||this.writeStatus==="closed"){this.log("received remote close read but local sink is already closed");return}this.log.trace("remote close read"),this._closeSink()}destroy(){if(this.status==="closed"||this.status==="aborted"||this.status==="reset"){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}}class MplexStream extends AbstractStream{constructor(tt){super(tt);wt(this,"name");wt(this,"streamId");wt(this,"send");wt(this,"types");wt(this,"maxDataSize");this.types=tt.direction==="outbound"?InitiatorMessageTypes:ReceiverMessageTypes,this.send=tt.send,this.name=tt.name,this.streamId=tt.streamId,this.maxDataSize=tt.maxDataSize}async sendNewStream(){await this.send({id:this.streamId,type:InitiatorMessageTypes.NEW_STREAM,data:new Uint8ArrayList(fromString$f(this.name))})}async sendData(tt){for(tt=tt.sublist();tt.byteLength>0;){const rt=Math.min(tt.byteLength,this.maxDataSize);await this.send({id:this.streamId,type:this.types.MESSAGE,data:tt.sublist(0,rt)}),tt.consume(rt)}}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(et){const{id:o,name:tt,send:rt,onEnd:nt,type:ot="initiator",maxMsgSize:it=MAX_MSG_SIZE}=et;return new MplexStream({id:ot==="initiator"?`i${o}`:`r${o}`,streamId:o,name:`${tt??o}`,direction:ot==="initiator"?"outbound":"inbound",maxDataSize:it,onEnd:nt,send:rt,log:et.logger.forComponent(`libp2p:mplex:stream:${ot}:${o}`)})}const MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION=1024,MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION=1024,MAX_STREAM_BUFFER_SIZE=1024*1024*4,DISCONNECT_THRESHOLD=5,CLOSE_TIMEOUT$2=500;function printMessage(et){const o={...et,type:`${MessageTypeNames[et.type]} (${et.type})`};return et.type===MessageTypes.NEW_STREAM&&(o.data=toString$i(et.data instanceof Uint8Array?et.data:et.data.subarray())),(et.type===MessageTypes.MESSAGE_INITIATOR||et.type===MessageTypes.MESSAGE_RECEIVER)&&(o.data=toString$i(et.data instanceof Uint8Array?et.data:et.data.subarray(),"base16")),o}class MplexStreamMuxer{constructor(o,tt){wt(this,"protocol","/mplex/6.7.0");wt(this,"sink");wt(this,"source");wt(this,"log");wt(this,"_streamId");wt(this,"_streams");wt(this,"_init");wt(this,"_source");wt(this,"closeController");wt(this,"rateLimiter");wt(this,"closeTimeout");wt(this,"logger");tt=tt??{},this.log=o.logger.forComponent("libp2p:mplex"),this.logger=o.logger,this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._init=tt,this.closeTimeout=tt.closeTimeout??CLOSE_TIMEOUT$2,this.sink=this._createSink(),this._source=pushable({objectMode:!0,onEnd:()=>{for(const rt of this._streams.initiators.values())rt.destroy();for(const rt of this._streams.receivers.values())rt.destroy()}}),this.source=pipe(this._source,rt=>encode$o(rt)),this.closeController=new AbortController,this.rateLimiter=new RateLimiter({points:tt.disconnectThreshold??DISCONNECT_THRESHOLD,duration:1})}get streams(){const o=[];for(const tt of this._streams.initiators.values())o.push(tt);for(const tt of this._streams.receivers.values())o.push(tt);return o}newStream(o){if(this.closeController.signal.aborted)throw new MuxerClosedError("Muxer already closed");const tt=this._streamId++;o=o==null?tt.toString():o.toString();const rt=this._streams.initiators;return this._newStream({id:tt,name:o,type:"initiator",registry:rt})}async close(o){if(this.closeController.signal.aborted)return;const tt=(o==null?void 0:o.signal)??AbortSignal.timeout(this.closeTimeout);try{await Promise.all(this.streams.map(async rt=>rt.close({signal:tt}))),this._source.end(),await this._source.onEmpty({signal:tt}),this.closeController.abort()}catch(rt){this.abort(rt)}}abort(o){this.closeController.signal.aborted||(this.streams.forEach(tt=>{tt.abort(o)}),this.closeController.abort(o))}_newReceiverStream(o){const{id:tt,name:rt}=o,nt=this._streams.receivers;return this._newStream({id:tt,name:rt,type:"receiver",registry:nt})}_newStream(o){const{id:tt,name:rt,type:nt,registry:ot}=o;if(this.log("new %s stream %s",nt,tt),nt==="initiator"&&this._streams.initiators.size===(this._init.maxOutboundStreams??MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION))throw new TooManyOutboundProtocolStreamsError$1("Too many outbound streams open");if(ot.has(tt))throw new Error(`${nt} stream ${tt} already exists!`);const at=createStream({id:tt,name:rt,send:async ct=>{this.log.enabled&&this.log.trace("%s stream %s send",nt,tt,printMessage(ct)),this._source.push(ct)},type:nt,onEnd:()=>{this.log("%s stream with id %s and protocol %s ended",nt,tt,at.protocol),ot.delete(tt),this._init.onStreamEnd!=null&&this._init.onStreamEnd(at)},maxMsgSize:this._init.maxMsgSize,logger:this.logger});return ot.set(tt,at),at}_createSink(){return async tt=>{const rt=()=>{closeSource(tt,this.log)};this.closeController.signal.addEventListener("abort",rt);try{const nt=new Decoder$b(this._init.maxMsgSize,this._init.maxUnprocessedMessageQueueSize);for await(const ot of tt)for(const it of nt.write(ot))await this._handleIncoming(it);this._source.end()}catch(nt){this.log("error in sink",nt),this._source.end(nt)}finally{this.closeController.signal.removeEventListener("abort",rt)}}}async _handleIncoming(o){const{id:tt,type:rt}=o;if(this.log.enabled&&this.log.trace("incoming message",printMessage(o)),o.type===MessageTypes.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION)){this.log("too many inbound streams open"),this._source.push({id:tt,type:MessageTypes.RESET_RECEIVER});try{await this.rateLimiter.consume("new-stream",1)}catch{this.log("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),this.abort(new Error("Too many open streams"));return}return}const st=this._newReceiverStream({id:tt,name:toString$i(o.data instanceof Uint8Array?o.data:o.data.subarray())});this._init.onIncomingStream!=null&&this._init.onIncomingStream(st);return}const ot=((rt&1)===1?this._streams.initiators:this._streams.receivers).get(tt);if(ot==null){this.log("missing stream %s for message type %s",tt,MessageTypeNames[rt]);try{await this.rateLimiter.consume("missing-stream",1)}catch{this.log("rate limit hit when receiving messages for streams that do not exist - closing remote connection"),this.abort(new Error("Too many messages for missing streams"));return}return}const it=this._init.maxStreamBufferSize??MAX_STREAM_BUFFER_SIZE;try{switch(rt){case MessageTypes.MESSAGE_INITIATOR:case MessageTypes.MESSAGE_RECEIVER:if(ot.sourceReadableLength()>it)throw this._source.push({id:o.id,type:rt===MessageTypes.MESSAGE_INITIATOR?MessageTypes.RESET_RECEIVER:MessageTypes.RESET_INITIATOR}),new StreamInputBufferError("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers");ot.sourcePush(o.data);break;case MessageTypes.CLOSE_INITIATOR:case MessageTypes.CLOSE_RECEIVER:ot.remoteCloseWrite();break;case MessageTypes.RESET_INITIATOR:case MessageTypes.RESET_RECEIVER:ot.reset();break;default:this.log("unknown message type %s",rt)}}catch(st){this.log.error("error while processing message",st),ot.abort(st)}}}var Pl,Nl;Nl=Symbol.toStringTag,Pl=serviceCapabilities$2;class Mplex{constructor(o,tt={}){wt(this,"protocol","/mplex/6.7.0");wt(this,"_init");wt(this,"components");wt(this,Nl,"@libp2p/mplex");wt(this,Pl,["@libp2p/stream-multiplexing"]);this.components=o,this._init=tt}createStreamMuxer(o={}){return new MplexStreamMuxer(this.components,{...o,...this._init})}}function mplex(et={}){return o=>new Mplex(o,et)}function isAsyncIterable$3(et){return et[Symbol.asyncIterator]!=null}function first(et){if(isAsyncIterable$3(et))return(async()=>{for await(const o of et)return o})();for(const o of et)return o}function equals$4(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt{tt==null||tt.abort(new TimeoutError$3("ping timeout"))}),pipe(tt,async function*(ot){let it=0;for await(const st of ot){if(it+=st.byteLength,it>PING_LENGTH$1){tt==null||tt.abort(new InvalidMessageError$3("Too much data received"));return}yield st}},tt).catch(ot=>{this.log.error("incoming ping from %p failed with error",o.connection.remotePeer,ot),tt==null||tt.abort(ot)}).finally(()=>{const ot=Date.now()-rt;this.log("incoming ping from %p complete in %dms",o.connection.remotePeer,ot)})}async ping(o,tt={}){var at,ct;this.log("pinging %p",o);const rt=Date.now(),nt=randomBytes(PING_LENGTH$1),ot=await this.components.connectionManager.openConnection(o,tt);let it,st=()=>{};if(tt.signal==null){const lt=AbortSignal.timeout(this.timeout);tt={...tt,signal:lt}}try{it=await ot.newStream(this.protocol,{...tt,runOnLimitedConnection:this.runOnLimitedConnection}),st=()=>{it==null||it.abort(new AbortError$9)},(at=tt.signal)==null||at.addEventListener("abort",st,{once:!0});const lt=await pipe([nt],it,async ht=>first(ht)),dt=Date.now()-rt;if(lt==null)throw new ProtocolError(`Did not receive a ping ack after ${dt}ms`);if(!equals$4(nt,lt.subarray()))throw new ProtocolError(`Received wrong ping ack after ${dt}ms`);return this.log("ping %p complete in %dms",ot.remotePeer,dt),dt}catch(lt){throw this.log.error("error while pinging %p",ot.remotePeer,lt),it==null||it.abort(lt),lt}finally{(ct=tt.signal)==null||ct.removeEventListener("abort",st),it!=null&&await it.close()}}}function ping(et={}){return o=>new PingService(o,et)}const transportSymbol=Symbol.for("@libp2p/transport");var FaultTolerance$1;(function(et){et[et.FATAL_ALL=0]="FATAL_ALL",et[et.NO_FATAL=1]="NO_FATAL"})(FaultTolerance$1||(FaultTolerance$1={}));var ws;let AbortError$5=(ws=class extends Error{constructor(o="The operation was aborted"){super(o),this.name="AbortError"}},wt(ws,"name","AbortError"),ws);class ConnectionFailedError extends Error{constructor(o="Connection failed"){super(o),this.name="ConnectionFailedError"}}wt(ConnectionFailedError,"name","ConnectionFailedError");const serviceCapabilities$1=Symbol.for("@libp2p/service-capabilities"),ASSUME_HTTP_CODES=[getProtocol("tcp").code,getProtocol("dns").code,getProtocol("dnsaddr").code,getProtocol("dns4").code,getProtocol("dns6").code];function extractSNI(et){let o;try{o=getProtocol("sni").code}catch{return null}for(const[tt,rt]of et)if(tt===o&&rt!==void 0)return rt;return null}function hasTLS(et){return et.some(([o,tt])=>o===getProtocol("tls").code)}function interpretNext(et,o,tt){const rt=interpreters[getProtocol(et).name];if(rt===void 0)throw new Error(`Can't interpret protocol ${getProtocol(et).name}`);const nt=rt(o,tt);return et===getProtocol("ip6").code?`[${nt}]`:nt}const interpreters={ip4:(et,o)=>et,ip6:(et,o)=>o.length===0?et:`[${et}]`,tcp:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`tcp://${interpretNext(tt[0],tt[1]??"",o)}:${et}`},udp:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`udp://${interpretNext(tt[0],tt[1]??"",o)}:${et}`},dnsaddr:(et,o)=>et,dns4:(et,o)=>et,dns6:(et,o)=>et,dns:(et,o)=>et,ipfs:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/ipfs/${et}`},p2p:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/p2p/${et}`},http:(et,o)=>{const tt=hasTLS(o),rt=extractSNI(o);if(tt&&rt!==null)return`https://${rt}`;const nt=tt?"https://":"http://",ot=o.pop();if(ot===void 0)throw new Error("Unexpected end of multiaddr");let it=interpretNext(ot[0],ot[1]??"",o);return it=it.replace("tcp://",""),`${nt}${it}`},"http-path":(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");const rt=interpretNext(tt[0],tt[1]??"",o),nt=decodeURIComponent(et);return`${rt}/${nt}`},tls:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return interpretNext(tt[0],tt[1]??"",o)},sni:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return interpretNext(tt[0],tt[1]??"",o)},https:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");let rt=interpretNext(tt[0],tt[1]??"",o);return rt=rt.replace("tcp://",""),`https://${rt}`},ws:(et,o)=>{const tt=hasTLS(o),rt=extractSNI(o);if(tt&&rt!==null)return`wss://${rt}`;const nt=tt?"wss://":"ws://",ot=o.pop();if(ot===void 0)throw new Error("Unexpected end of multiaddr");let it=interpretNext(ot[0],ot[1]??"",o);return it=it.replace("tcp://",""),`${nt}${it}`},wss:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");let rt=interpretNext(tt[0],tt[1]??"",o);return rt=rt.replace("tcp://",""),`wss://${rt}`},"p2p-websocket-star":(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/p2p-websocket-star`},"p2p-webrtc-star":(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/p2p-webrtc-star`},"p2p-webrtc-direct":(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/p2p-webrtc-direct`}};function multiaddrToUri(et,o){const rt=multiaddr(et).stringTuples(),nt=rt.pop();if(nt===void 0)throw new Error("Unexpected end of multiaddr");const ot=getProtocol(nt[0]),it=interpreters[ot.name];if(it==null)throw new Error(`No interpreter found for ${ot.name}`);let st=it(nt[1]??"",rt);return ASSUME_HTTP_CODES.includes(nt[0])&&(st=st.replace(/^.*:\/\//,""),nt[1]==="443"?st=`https://${st}`:st=`http://${st}`),(st.startsWith("http://")||st.startsWith("https://"))&&(st=new URL(st).toString(),st.endsWith("/")&&(st=st.substring(0,st.length-1))),st}const ready=async et=>{if(et.readyState>=2)throw new Error("socket closed");et.readyState!==1&&await new Promise((o,tt)=>{function rt(){et.removeEventListener("open",nt),et.removeEventListener("error",ot)}function nt(){rt(),o()}function ot(it){rt(),tt(it.error??new Error(`connect ECONNREFUSED ${et.url}`))}et.addEventListener("open",nt),et.addEventListener("error",ot)})},sink=(et,o)=>(o=o??{},o.closeOnEnd=o.closeOnEnd!==!1,async rt=>{for await(const nt of rt){try{await ready(et)}catch(ot){if(ot.message==="socket closed")break;throw ot}if(et.readyState===et.CLOSING||et.readyState===et.CLOSED)break;et.send(nt)}o.closeOnEnd!=null&&et.readyState<=1&&await new Promise((nt,ot)=>{et.addEventListener("close",it=>{if(it.wasClean||it.code===1006)nt();else{const st=Object.assign(new Error("ws error"),{event:it});ot(st)}}),setTimeout(()=>{et.close()})})});var dom={},eventIterator={};Object.defineProperty(eventIterator,"__esModule",{value:!0});class EventQueue{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(o){if(this.isStopped)return;const tt={value:o,done:!1};if(this.pullQueue.length){const rt=this.pullQueue.shift();rt&&rt.resolve(tt)}else this.pushQueue.push(Promise.resolve(tt)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const o of 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(const tt of this.pullQueue)tt.reject(o);this.pullQueue.length=0}else{const tt=Promise.reject(o);tt.catch(()=>{}),this.pushQueue.push(tt)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:o=>{const tt=this.pushQueue.shift();return tt?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),tt):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((rt,nt)=>{this.pullQueue.push({resolve:rt,reject:nt})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}let EventIterator$1=class{constructor(o,{highWaterMark:tt=100,lowWaterMark:rt=1}={}){const nt=new EventQueue;nt.highWaterMark=tt,nt.lowWaterMark=rt,nt.removeCallback=o({push:ot=>nt.push(ot),stop:()=>nt.stop(),fail:ot=>nt.fail(ot),on:(ot,it)=>{nt.eventHandlers[ot]=it}})||(()=>{}),this[Symbol.asyncIterator]=()=>nt[Symbol.asyncIterator](),Object.freeze(this)}};eventIterator.EventIterator=EventIterator$1;eventIterator.default=EventIterator$1;Object.defineProperty(dom,"__esModule",{value:!0});const event_iterator_1=eventIterator;var EventIterator=dom.EventIterator=event_iterator_1.EventIterator;function subscribe(et,o,tt){return new event_iterator_1.EventIterator(({push:rt})=>(this.addEventListener(et,rt,o),()=>this.removeEventListener(et,rt,o)),tt)}dom.subscribe=subscribe;dom.default=event_iterator_1.EventIterator;function coerce$b(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$e(et){return new TextEncoder().encode(et)}function toString$h(et){return new TextDecoder().decode(et)}function base$a(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$b=base$a,_brrp__multiformats_scope_baseX$a=src$b;let Encoder$a=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$a=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$a(this,o)}},ComposedDecoder$a=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$a(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$a(et,o){return new ComposedDecoder$a({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$a=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$a(o,tt,rt),this.decoder=new Decoder$a(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$b({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$a(et,o,tt,rt)}function baseX$a({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$a(tt,et);return from$b({prefix:o,name:et,encode:rt,decode:ot=>coerce$b(nt(ot))})}function decode$s(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$n(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$7=alphabet$7.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$m(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$7[tt],o),"")}function decode$r(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$7[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$e=from$b({prefix:"🚀",name:"base256emoji",encode:encode$m,decode:decode$r}),base256emoji$f=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$e},Symbol.toStringTag,{value:"Module"})),base32$i=rfc4648$9({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$7=rfc4648$9({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$7=rfc4648$9({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$7=rfc4648$9({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$7=rfc4648$9({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$7=rfc4648$9({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$7=rfc4648$9({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$7=rfc4648$9({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$7=rfc4648$9({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$j=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$i,base32hex:base32hex$7,base32hexpad:base32hexpad$7,base32hexpadupper:base32hexpadupper$7,base32hexupper:base32hexupper$7,base32pad:base32pad$7,base32padupper:base32padupper$7,base32upper:base32upper$7,base32z:base32z$7},Symbol.toStringTag,{value:"Module"})),base36$f=baseX$a({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$7=baseX$a({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$g=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$f,base36upper:base36upper$7},Symbol.toStringTag,{value:"Module"})),base58btc$a=baseX$a({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$7=baseX$a({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$7=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$a,base58flickr:base58flickr$7},Symbol.toStringTag,{value:"Module"})),base64$h=rfc4648$9({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$7=rfc4648$9({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$7=rfc4648$9({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$7=rfc4648$9({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$i=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$h,base64pad:base64pad$7,base64url:base64url$7,base64urlpad:base64urlpad$7},Symbol.toStringTag,{value:"Module"})),base8$e=rfc4648$9({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$f=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$e},Symbol.toStringTag,{value:"Module"})),identity$7=from$b({prefix:"\0",name:"identity",encode:et=>toString$h(et),decode:et=>fromString$e(et)}),identityBase$7=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$7},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$7={...identityBase$7,...base2$f,...base8$f,...base10$f,...base16$f,...base32$j,...base36$g,...base58$7,...base64$i,...base256emoji$f};function allocUnsafe$6(et=0){return new Uint8Array(et)}function createCodec$7(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$a=createCodec$7("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$7=createCodec$7("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$6(et.length);for(let tt=0;tt{et.binaryType="arraybuffer";const o=async()=>{await new Promise((ot,it)=>{if(rt){ot();return}if(nt!=null){it(nt);return}const st=lt=>{et.removeEventListener("open",at),et.removeEventListener("error",ct),lt()},at=()=>{st(ot)},ct=lt=>{st(()=>{it(lt.error??new Error(`connect ECONNREFUSED ${et.url}`))})};et.addEventListener("open",at),et.addEventListener("error",ct)})},tt=async function*(){const ot=new EventIterator(({push:it,stop:st,fail:at})=>{const ct=dt=>{let ht=null;typeof dt.data=="string"&&(ht=fromString$d(dt.data)),isArrayBuffer(dt.data)&&(ht=new Uint8Array(dt.data)),dt.data instanceof Uint8Array&&(ht=dt.data),ht!=null&&it(ht)},lt=dt=>{at(dt.error??new Error("Socket error"))};return et.addEventListener("message",ct),et.addEventListener("error",lt),et.addEventListener("close",st),()=>{et.removeEventListener("message",ct),et.removeEventListener("error",lt),et.removeEventListener("close",st)}},{highWaterMark:1/0});await o();for await(const it of ot)yield isArrayBuffer(it)?new Uint8Array(it):it}();let rt=et.readyState===1,nt;return et.addEventListener("open",()=>{rt=!0,nt=null}),et.addEventListener("close",()=>{rt=!1,nt=null}),et.addEventListener("error",ot=>{rt||(nt=ot.error??new Error(`connect ECONNREFUSED ${et.url}`))}),Object.assign(tt,{connected:o})},duplex=(et,o)=>{o=o??{};const tt=source(et);let rt=o.remoteAddress,nt=o.remotePort;if(et.url!=null)try{const it=new URL(et.url);rt=it.hostname,nt=parseInt(it.port,10)}catch{}if(rt==null||nt==null)throw new Error("Remote connection did not have address and/or port");return{sink:sink(et,o),source:tt,connected:async()=>{await tt.connected()},close:async()=>{(et.readyState===et.CONNECTING||et.readyState===et.OPEN)&&await new Promise(it=>{et.addEventListener("close",()=>{it()}),et.close()})},destroy:()=>{et.terminate!=null?et.terminate():et.close()},remoteAddress:rt,remotePort:nt,socket:et}},WebSocket$1=WebSocket,map={"http:":"ws:","https:":"wss:"},defaultProtocol="ws:",wsurl=(et,o)=>{if(et.startsWith("//")&&(et=`${(o==null?void 0:o.protocol)??defaultProtocol}${et}`),et.startsWith("/")&&o!=null){const rt=o.protocol??defaultProtocol,nt=o.host,ot=o.port!=null&&(nt==null?void 0:nt.endsWith(`:${o.port}`))!==!0?`:${o.port}`:"";et=`${rt}//${nt}${ot}${et}`}const tt=new URL(et);for(const[rt,nt]of Object.entries(map))tt.protocol===rt&&(tt.protocol=nt);return tt};function connect(et,o){const tt=typeof window>"u"?void 0:window.location;o=o??{};const rt=wsurl(et,tt),nt=new WebSocket$1(rt.toString(),o.websocket);return duplex(nt,o)}class CustomProgressEvent extends Event{constructor(tt,rt){super(tt);wt(this,"type");wt(this,"detail");this.type=tt,this.detail=rt}}const CODE_P2P=421,CODE_CIRCUIT=290,CLOSE_TIMEOUT$1=500;function all$1(et){return et.filter(o=>{if(o.protoCodes().includes(CODE_CIRCUIT))return!1;const tt=o.decapsulateCode(CODE_P2P);return WebSockets$2.matches(tt)||WebSocketsSecure$1.matches(tt)})}function wss(et){return et.filter(o=>{if(o.protoCodes().includes(CODE_CIRCUIT))return!1;const tt=o.decapsulateCode(CODE_P2P);return WebSocketsSecure$1.matches(tt)})}function createListener(){throw new Error("WebSocket Servers can not be created in the browser!")}function socketToMaConn(et,o,tt){const rt=tt.logger.forComponent("libp2p:websockets:maconn"),nt=tt.metrics,ot=tt.metricPrefix??"",it={log:rt,async sink(st){try{await et.sink(async function*(){for await(const at of st)at instanceof Uint8Array?yield at:yield at.subarray()}())}catch(at){at.type!=="aborted"&&rt.error(at)}},source:et.source,remoteAddr:o,timeline:{open:Date.now()},async close(st={}){var lt,dt;const at=Date.now();if(st.signal==null){const ht=AbortSignal.timeout(CLOSE_TIMEOUT$1);st={...st,signal:ht}}const ct=()=>{const{host:ht,port:mt}=it.remoteAddr.toOptions();rt("timeout closing stream to %s:%s after %dms, destroying it manually",ht,mt,Date.now()-at),this.abort(new AbortError$5("Socket close timeout"))};(lt=st.signal)==null||lt.addEventListener("abort",ct);try{await et.close()}catch(ht){rt.error("error closing WebSocket gracefully",ht),this.abort(ht)}finally{(dt=st.signal)==null||dt.removeEventListener("abort",ct),it.timeline.close=Date.now()}},abort(st){const{host:at,port:ct}=it.remoteAddr.toOptions();rt("timeout closing stream to %s:%s due to error",at,ct,st),et.destroy(),it.timeline.close=Date.now(),nt==null||nt.increment({[`${ot}error`]:!0})}};return et.socket.addEventListener("close",()=>{nt==null||nt.increment({[`${ot}close`]:!0}),it.timeline.close==null&&(it.timeline.close=Date.now())},{once:!0}),it}var Ol,Ll,Ml;Ml=transportSymbol,Ll=Symbol.toStringTag,Ol=serviceCapabilities$1;class WebSockets{constructor(o,tt){wt(this,"log");wt(this,"init");wt(this,"logger");wt(this,"metrics");wt(this,"components");wt(this,Ml,!0);wt(this,Ll,"@libp2p/websockets");wt(this,Ol,["@libp2p/transport"]);this.log=o.logger.forComponent("libp2p:websockets"),this.logger=o.logger,this.components=o,this.init=tt,o.metrics!=null&&(this.metrics={dialerEvents:o.metrics.registerCounterGroup("libp2p_websockets_dialer_events_total",{label:"event",help:"Total count of WebSockets dialer events by type"})})}async dial(o,tt){var it;this.log("dialing %s",o),tt=tt??{};const rt=await this._connect(o,tt),nt=socketToMaConn(rt,o,{logger:this.logger,metrics:(it=this.metrics)==null?void 0:it.dialerEvents});this.log("new outbound connection %s",nt.remoteAddr);const ot=await tt.upgrader.upgradeOutbound(nt,tt);return this.log("outbound connection %s upgraded",nt.remoteAddr),ot}async _connect(o,tt){var it,st,at,ct,lt;(it=tt==null?void 0:tt.signal)==null||it.throwIfAborted();const rt=o.toOptions();this.log("dialing %s:%s",rt.host,rt.port);const nt=pDefer(),ot=connect(multiaddrToUri(o),this.init);ot.socket.addEventListener("error",()=>{var ht;const dt=new ConnectionFailedError(`Could not connect to ${o.toString()}`);this.log.error("connection error:",dt),(ht=this.metrics)==null||ht.dialerEvents.increment({error:!0}),nt.reject(dt)});try{(st=tt.onProgress)==null||st.call(tt,new CustomProgressEvent("websockets:open-connection")),await raceSignal(Promise.race([ot.connected(),nt.promise]),tt.signal)}catch(dt){throw((at=tt.signal)==null?void 0:at.aborted)===!0&&((ct=this.metrics)==null||ct.dialerEvents.increment({abort:!0})),ot.close().catch(ht=>{this.log.error("error closing raw socket",ht)}),dt}return this.log("connected %s",o),(lt=this.metrics)==null||lt.dialerEvents.increment({connect:!0}),ot}createListener(o){return createListener({logger:this.logger,metrics:this.components.metrics},{...this.init,...o})}listenFilter(o){var tt,rt;return o=Array.isArray(o)?o:[o],((tt=this.init)==null?void 0:tt.filter)!=null?(rt=this.init)==null?void 0:rt.filter(o):isBrowser||isWebWorker?wss(o):all$1(o)}dialFilter(o){return this.listenFilter(o)}}function webSockets(et={}){return o=>new WebSockets(o,et)}const connectionSymbol=Symbol.for("@libp2p/connection"),contentRoutingSymbol=Symbol.for("@libp2p/content-routing"),peerDiscoverySymbol=Symbol.for("@libp2p/peer-discovery"),peerIdSymbol$1=Symbol.for("@libp2p/peer-id");function isPeerId$1(et){return!!(et!=null&&et[peerIdSymbol$1])}const peerRoutingSymbol=Symbol.for("@libp2p/peer-routing"),KEEP_ALIVE="keep-alive";var FaultTolerance;(function(et){et[et.FATAL_ALL=0]="FATAL_ALL",et[et.NO_FATAL=1]="NO_FATAL"})(FaultTolerance||(FaultTolerance={}));var Es;let AbortError$4=(Es=class extends Error{constructor(o="The operation was aborted"){super(o),this.name="AbortError"}},wt(Es,"name","AbortError"),Es);var Cs;let InvalidParametersError$1=(Cs=class extends Error{constructor(o="Invalid parameters"){super(o),this.name="InvalidParametersError"}},wt(Cs,"name","InvalidParametersError"),Cs);class ConnectionClosingError extends Error{constructor(o="The connection is closing"){super(o),this.name="ConnectionClosingError"}}wt(ConnectionClosingError,"name","ConnectionClosingError");class ConnectionClosedError extends Error{constructor(o="The connection is closed"){super(o),this.name="ConnectionClosedError"}}wt(ConnectionClosedError,"name","ConnectionClosedError");var Ss;let NotFoundError$1=(Ss=class extends Error{constructor(o="Not found"){super(o),this.name="NotFoundError"}},wt(Ss,"name","NotFoundError"),Ss);class InvalidPeerIdError extends Error{constructor(o="Invalid PeerID"){super(o),this.name="InvalidPeerIdError"}}wt(InvalidPeerIdError,"name","InvalidPeerIdError");class InvalidMultiaddrError extends Error{constructor(o="Invalid multiaddr"){super(o),this.name="InvalidMultiaddrError"}}wt(InvalidMultiaddrError,"name","InvalidMultiaddrError");var As;let TimeoutError$2=(As=class extends Error{constructor(o="Timed out"){super(o),this.name="TimeoutError"}},wt(As,"name","TimeoutError"),As);class NotStartedError extends Error{constructor(o="Not started"){super(o),this.name="NotStartedError"}}wt(NotStartedError,"name","NotStartedError");class DialError extends Error{constructor(o="Dial error"){super(o),this.name="DialError"}}wt(DialError,"name","DialError");class LimitedConnectionError extends Error{constructor(o="Limited connection"){super(o),this.name="LimitedConnectionError"}}wt(LimitedConnectionError,"name","LimitedConnectionError");class TooManyInboundProtocolStreamsError extends Error{constructor(o="Too many inbound protocol streams"){super(o),this.name="TooManyInboundProtocolStreamsError"}}wt(TooManyInboundProtocolStreamsError,"name","TooManyInboundProtocolStreamsError");class TooManyOutboundProtocolStreamsError extends Error{constructor(o="Too many outbound protocol streams"){super(o),this.name="TooManyOutboundProtocolStreamsError"}}wt(TooManyOutboundProtocolStreamsError,"name","TooManyOutboundProtocolStreamsError");function setMaxListeners$1(){}const setMaxListeners=(et,...o)=>{try{[...o]}catch{}};var en;class TypedEventEmitter extends EventTarget{constructor(){super();hr(this,en,new Map);setMaxListeners(1/0,this)}listenerCount(tt){const rt=Lt(this,en).get(tt);return rt==null?0:rt.length}addEventListener(tt,rt,nt){super.addEventListener(tt,rt,nt);let ot=Lt(this,en).get(tt);ot==null&&(ot=[],Lt(this,en).set(tt,ot)),ot.push({callback:rt,once:(nt!==!0&&nt!==!1&&(nt==null?void 0:nt.once))??!1})}removeEventListener(tt,rt,nt){super.removeEventListener(tt.toString(),rt??null,nt);let ot=Lt(this,en).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==rt),Lt(this,en).set(tt,ot))}dispatchEvent(tt){const rt=super.dispatchEvent(tt);let nt=Lt(this,en).get(tt.type);return nt==null||(nt=nt.filter(({once:ot})=>!ot),Lt(this,en).set(tt.type,nt)),rt}safeDispatchEvent(tt,rt={}){return this.dispatchEvent(new CustomEvent(tt,rt))}}en=new WeakMap;function isStartable(et){return et!=null&&typeof et.start=="function"&&typeof et.stop=="function"}async function start(...et){const o=[];for(const tt of et)isStartable(tt)&&o.push(tt);await Promise.all(o.map(async tt=>{tt.beforeStart!=null&&await tt.beforeStart()})),await Promise.all(o.map(async tt=>{await tt.start()})),await Promise.all(o.map(async tt=>{tt.afterStart!=null&&await tt.afterStart()}))}async function stop(...et){const o=[];for(const tt of et)isStartable(tt)&&o.push(tt);await Promise.all(o.map(async tt=>{tt.beforeStop!=null&&await tt.beforeStop()})),await Promise.all(o.map(async tt=>{await tt.stop()})),await Promise.all(o.map(async tt=>{tt.afterStop!=null&&await tt.afterStop()}))}const serviceCapabilities=Symbol.for("@libp2p/service-capabilities"),serviceDependencies=Symbol.for("@libp2p/service-dependencies");let TimeoutError$1=class extends Error{constructor(o){super(o),this.name="TimeoutError"}},AbortError$3=class extends Error{constructor(o){super(),this.name="AbortError",this.message=o}};const getDOMException=et=>globalThis.DOMException===void 0?new AbortError$3(et):new DOMException(et),getAbortedReason=et=>{const o=et.reason===void 0?getDOMException("This operation was aborted."):et.reason;return o instanceof Error?o:getDOMException(o)};function pTimeout(et,o){const{milliseconds:tt,fallback:rt,message:nt,customTimers:ot={setTimeout,clearTimeout}}=o;let it;const at=new Promise((ct,lt)=>{if(typeof tt!="number"||Math.sign(tt)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${tt}\``);if(o.signal){const{signal:ht}=o;ht.aborted&<(getAbortedReason(ht));const mt=()=>{lt(getAbortedReason(ht))};ht.addEventListener("abort",mt,{once:!0}),et.finally(()=>{ht.removeEventListener("abort",mt)})}if(tt===Number.POSITIVE_INFINITY){et.then(ct,lt);return}const dt=new TimeoutError$1;it=ot.setTimeout.call(void 0,()=>{if(rt){try{ct(rt())}catch(ht){lt(ht)}return}typeof et.cancel=="function"&&et.cancel(),nt===!1?ct():nt instanceof Error?lt(nt):(dt.message=nt??`Promise timed out after ${tt} milliseconds`,lt(dt))},tt),(async()=>{try{ct(await et)}catch(ht){lt(ht)}})()}).finally(()=>{at.clear()});return at.clear=()=>{ot.clearTimeout.call(void 0,it),it=void 0},at}function lowerBound(et,o,tt){let rt=0,nt=et.length;for(;nt>0;){const ot=Math.trunc(nt/2);let it=rt+ot;tt(et[it],o)<=0?(rt=++it,nt-=ot+1):nt=ot}return rt}var tn,Bl;let PriorityQueue$1=(Bl=class{constructor(){hr(this,tn,[])}enqueue(o,tt){tt={priority:0,...tt};const rt={priority:tt.priority,run:o};if(this.size&&Lt(this,tn)[this.size-1].priority>=tt.priority){Lt(this,tn).push(rt);return}const nt=lowerBound(Lt(this,tn),rt,(ot,it)=>it.priority-ot.priority);Lt(this,tn).splice(nt,0,rt)}dequeue(){const o=Lt(this,tn).shift();return o==null?void 0:o.run}filter(o){return Lt(this,tn).filter(tt=>tt.priority===o.priority).map(tt=>tt.run)}get size(){return Lt(this,tn).length}},tn=new WeakMap,Bl);var Xn,Jn,En,ho,eo,fo,Hr,to,Ur,po,Wr,ro,an,mo,$r,nu,ou,iu,su,au,_i,Ls,Ms,es,cu,ts;class PQueue extends EventEmitter$1{constructor(tt){var rt,nt;super();hr(this,$r);hr(this,Xn);hr(this,Jn);hr(this,En,0);hr(this,ho);hr(this,eo);hr(this,fo,0);hr(this,Hr);hr(this,to);hr(this,Ur);hr(this,po);hr(this,Wr,0);hr(this,ro);hr(this,an);hr(this,mo);wt(this,"timeout");if(tt={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:PriorityQueue$1,...tt},!(typeof tt.intervalCap=="number"&&tt.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${((rt=tt.intervalCap)==null?void 0:rt.toString())??""}\` (${typeof tt.intervalCap})`);if(tt.interval===void 0||!(Number.isFinite(tt.interval)&&tt.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${((nt=tt.interval)==null?void 0:nt.toString())??""}\` (${typeof tt.interval})`);ur(this,Xn,tt.carryoverConcurrencyCount),ur(this,Jn,tt.intervalCap===Number.POSITIVE_INFINITY||tt.interval===0),ur(this,ho,tt.intervalCap),ur(this,eo,tt.interval),ur(this,Ur,new tt.queueClass),ur(this,po,tt.queueClass),this.concurrency=tt.concurrency,this.timeout=tt.timeout,ur(this,mo,tt.throwOnTimeout===!0),ur(this,an,tt.autoStart===!1)}get concurrency(){return Lt(this,ro)}set concurrency(tt){if(!(typeof tt=="number"&&tt>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${tt}\` (${typeof tt})`);ur(this,ro,tt),fr(this,$r,es).call(this)}async add(tt,rt={}){return rt={timeout:this.timeout,throwOnTimeout:Lt(this,mo),...rt},new Promise((nt,ot)=>{Lt(this,Ur).enqueue(async()=>{var it;Cn(this,Wr)._++,Cn(this,En)._++;try{(it=rt.signal)==null||it.throwIfAborted();let st=tt({signal:rt.signal});rt.timeout&&(st=pTimeout(Promise.resolve(st),{milliseconds:rt.timeout})),rt.signal&&(st=Promise.race([st,fr(this,$r,cu).call(this,rt.signal)]));const at=await st;nt(at),this.emit("completed",at)}catch(st){if(st instanceof TimeoutError$1&&!rt.throwOnTimeout){nt();return}ot(st),this.emit("error",st)}finally{fr(this,$r,iu).call(this)}},rt),this.emit("add"),fr(this,$r,_i).call(this)})}async addAll(tt,rt){return Promise.all(tt.map(async nt=>this.add(nt,rt)))}start(){return Lt(this,an)?(ur(this,an,!1),fr(this,$r,es).call(this),this):this}pause(){ur(this,an,!0)}clear(){ur(this,Ur,new(Lt(this,po)))}async onEmpty(){Lt(this,Ur).size!==0&&await fr(this,$r,ts).call(this,"empty")}async onSizeLessThan(tt){Lt(this,Ur).sizeLt(this,Ur).size{fr(this,$r,su).call(this)},rt)),!0}return!1},_i=function(){if(Lt(this,Ur).size===0)return Lt(this,Hr)&&clearInterval(Lt(this,Hr)),ur(this,Hr,void 0),this.emit("empty"),Lt(this,Wr)===0&&this.emit("idle"),!1;if(!Lt(this,an)){const tt=!Lt(this,$r,au);if(Lt(this,$r,nu)&&Lt(this,$r,ou)){const rt=Lt(this,Ur).dequeue();return rt?(this.emit("active"),rt(),tt&&fr(this,$r,Ls).call(this),!0):!1}}return!1},Ls=function(){Lt(this,Jn)||Lt(this,Hr)!==void 0||(ur(this,Hr,setInterval(()=>{fr(this,$r,Ms).call(this)},Lt(this,eo))),ur(this,fo,Date.now()+Lt(this,eo)))},Ms=function(){Lt(this,En)===0&&Lt(this,Wr)===0&&Lt(this,Hr)&&(clearInterval(Lt(this,Hr)),ur(this,Hr,void 0)),ur(this,En,Lt(this,Xn)?Lt(this,Wr):0),fr(this,$r,es).call(this)},es=function(){for(;fr(this,$r,_i).call(this););},cu=async function(tt){return new Promise((rt,nt)=>{tt.addEventListener("abort",()=>{nt(tt.reason)},{once:!0})})},ts=async function(tt,rt){return new Promise(nt=>{const ot=()=>{rt&&!rt()||(this.off(tt,ot),nt())};this.on(tt,ot)})};function getTypes(et){const o=[RecordType.A];return et==null?o:Array.isArray(et)?et.length===0?o:et:[et]}function coerce$a(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$c(et){return new TextEncoder().encode(et)}function toString$g(et){return new TextDecoder().decode(et)}function base$9(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$a=base$9,_brrp__multiformats_scope_baseX$9=src$a;let Encoder$9=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$9=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$9(this,o)}},ComposedDecoder$9=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$9(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$9(et,o){return new ComposedDecoder$9({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$9=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$9(o,tt,rt),this.decoder=new Decoder$9(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$a({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$9(et,o,tt,rt)}function baseX$9({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$9(tt,et);return from$a({prefix:o,name:et,encode:rt,decode:ot=>coerce$a(nt(ot))})}function decode$q(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$l(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$6=alphabet$6.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$k(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$6[tt],o),"")}function decode$p(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$6[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$c=from$a({prefix:"🚀",name:"base256emoji",encode:encode$k,decode:decode$p}),base256emoji$d=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$c},Symbol.toStringTag,{value:"Module"})),base32$g=rfc4648$8({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$6=rfc4648$8({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$6=rfc4648$8({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$6=rfc4648$8({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$6=rfc4648$8({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$6=rfc4648$8({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$6=rfc4648$8({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$6=rfc4648$8({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$6=rfc4648$8({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$h=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$g,base32hex:base32hex$6,base32hexpad:base32hexpad$6,base32hexpadupper:base32hexpadupper$6,base32hexupper:base32hexupper$6,base32pad:base32pad$6,base32padupper:base32padupper$6,base32upper:base32upper$6,base32z:base32z$6},Symbol.toStringTag,{value:"Module"})),base36$d=baseX$9({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$6=baseX$9({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$e=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$d,base36upper:base36upper$6},Symbol.toStringTag,{value:"Module"})),base58btc$9=baseX$9({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$6=baseX$9({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$6=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$9,base58flickr:base58flickr$6},Symbol.toStringTag,{value:"Module"})),base64$f=rfc4648$8({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$6=rfc4648$8({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$6=rfc4648$8({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$6=rfc4648$8({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$g=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$f,base64pad:base64pad$6,base64url:base64url$6,base64urlpad:base64urlpad$6},Symbol.toStringTag,{value:"Module"})),base8$c=rfc4648$8({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$d=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$c},Symbol.toStringTag,{value:"Module"})),identity$6=from$a({prefix:"\0",name:"identity",encode:et=>toString$g(et),decode:et=>fromString$c(et)}),identityBase$6=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$6},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$6={...identityBase$6,...base2$d,...base8$d,...base10$d,...base16$d,...base32$h,...base36$e,...base58$6,...base64$g,...base256emoji$d};function allocUnsafe$5(et=0){return new Uint8Array(et)}function createCodec$6(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$9=createCodec$6("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$6=createCodec$6("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$5(et.length);for(let tt=0;tt({name:o.name,type:RecordType[o.type]})),Answer:(et.Answer??et.answers??[]).map(o=>({name:o.name,type:RecordType[o.type],TTL:o.TTL??o.ttl??DEFAULT_TTL,data:o.data instanceof Uint8Array?toString$f(o.data):o.data}))}}const DEFAULT_QUERY_CONCURRENCY=4;function dnsJsonOverHttps(et,o={}){const tt=new PQueue({concurrency:o.queryConcurrency??DEFAULT_QUERY_CONCURRENCY});return async(rt,nt={})=>{var st;const ot=new URLSearchParams;ot.set("name",rt),getTypes(nt.types).forEach(at=>{ot.append("type",RecordType[at])}),(st=nt.onProgress)==null||st.call(nt,new CustomProgressEvent("dns:query",{detail:rt}));const it=await tt.add(async()=>{var lt;const at=await fetch(`${et}?${ot}`,{headers:{accept:"application/dns-json"},signal:nt==null?void 0:nt.signal});if(at.status!==200)throw new Error(`Unexpected HTTP status: ${at.status} - ${at.statusText}`);const ct=toDNSResponse(await at.json());return(lt=nt.onProgress)==null||lt.call(nt,new CustomProgressEvent("dns:response",{detail:ct})),ct},{signal:nt.signal});if(it==null)throw new Error("No DNS response received");return it}}function defaultResolver(){return[dnsJsonOverHttps("https://cloudflare-dns.com/dns-query"),dnsJsonOverHttps("https://dns.google/resolve")]}var hashlru=function(et){if(!et)throw Error("hashlru must have a max value, of type number, greater than 0");var o=0,tt=Object.create(null),rt=Object.create(null);function nt(ot,it){tt[ot]=it,o++,o>=et&&(o=0,rt=tt,tt=Object.create(null))}return{has:function(ot){return tt[ot]!==void 0||rt[ot]!==void 0},remove:function(ot){tt[ot]!==void 0&&(tt[ot]=void 0),rt[ot]!==void 0&&(rt[ot]=void 0)},get:function(ot){var it=tt[ot];if(it!==void 0)return it;if((it=rt[ot])!==void 0)return nt(ot,it),it},set:function(ot,it){tt[ot]!==void 0?tt[ot]=it:nt(ot,it)},clear:function(){tt=Object.create(null),rt=Object.create(null)}}};const hashlru$1=getDefaultExportFromCjs(hashlru);class CachedAnswers{constructor(o){wt(this,"lru");this.lru=hashlru$1(o)}get(o,tt){let rt=!0;const nt=[];for(const ot of tt){const it=this.getAnswers(o,ot);if(it.length===0){rt=!1;break}nt.push(...it)}if(rt)return toDNSResponse({answers:nt})}getAnswers(o,tt){const rt=`${o.toLowerCase()}-${tt}`,nt=this.lru.get(rt);if(nt!=null){const ot=nt.filter(it=>it.expires>Date.now()).map(({expires:it,value:st})=>({...st,TTL:Math.round((it-Date.now())/1e3),type:RecordType[st.type]}));return ot.length===0&&this.lru.remove(rt),ot}return[]}add(o,tt){const rt=`${o.toLowerCase()}-${tt.type}`,nt=this.lru.get(rt)??[];nt.push({expires:Date.now()+(tt.TTL??DEFAULT_TTL)*1e3,value:tt}),this.lru.set(rt,nt)}remove(o,tt){const rt=`${o.toLowerCase()}-${tt}`;this.lru.remove(rt)}clear(){this.lru.clear()}}function cache$1(et){return new CachedAnswers(et)}const DEFAULT_ANSWER_CACHE_SIZE=1e3;class DNS{constructor(o){wt(this,"resolvers");wt(this,"cache");this.resolvers={},this.cache=cache$1(o.cacheSize??DEFAULT_ANSWER_CACHE_SIZE),Object.entries(o.resolvers??{}).forEach(([tt,rt])=>{Array.isArray(rt)||(rt=[rt]),tt.endsWith(".")||(tt=`${tt}.`),this.resolvers[tt]=rt}),this.resolvers["."]==null&&(this.resolvers["."]=defaultResolver())}async query(o,tt={}){var at,ct,lt;const rt=getTypes(tt.types),nt=tt.cached!==!1?this.cache.get(o,rt):void 0;if(nt!=null)return(at=tt.onProgress)==null||at.call(tt,new CustomProgressEvent("dns:cache",{detail:nt})),nt;const ot=`${o.split(".").pop()}.`,it=(this.resolvers[ot]??this.resolvers["."]).sort(()=>Math.random()>.5?-1:1),st=[];for(const dt of it){if(((ct=tt.signal)==null?void 0:ct.aborted)===!0)break;try{const ht=await dt(o,{...tt,types:rt});for(const mt of ht.Answer)this.cache.add(o,mt);return ht}catch(ht){st.push(ht),(lt=tt.onProgress)==null||lt.call(tt,new CustomProgressEvent("dns:error",{detail:ht}))}}throw st.length===1?st[0]:new AggregateError(st,`DNS lookup of ${o} ${rt} failed`)}}var RecordType;(function(et){et[et.A=1]="A",et[et.CNAME=5]="CNAME",et[et.TXT=16]="TXT",et[et.AAAA=28]="AAAA"})(RecordType||(RecordType={}));function dns(et={}){return new DNS(et)}const MAX_RECURSIVE_DEPTH=32,{code:dnsaddrCode}=getProtocol("dnsaddr");class RecursionLimitError extends Error{constructor(o="Max recursive depth reached"){super(o),this.name="RecursionLimitError"}}const dnsaddrResolver=async function(o,tt={}){const rt=tt.maxRecursiveDepth??MAX_RECURSIVE_DEPTH;if(rt===0)throw new RecursionLimitError("Max recursive depth reached");const[,nt]=o.stringTuples().find(([ct])=>ct===dnsaddrCode)??[],it=await((tt==null?void 0:tt.dns)??dns()).query(`_dnsaddr.${nt}`,{signal:tt==null?void 0:tt.signal,types:[RecordType.TXT]}),st=o.getPeerId(),at=[];for(const ct of it.Answer){const lt=ct.data.replace(/["']/g,"").trim().split("=")[1];if(lt==null||st!=null&&!lt.includes(st))continue;const dt=multiaddr(lt);if(lt.startsWith("/dnsaddr")){const ht=await dt.resolve({...tt,maxRecursiveDepth:rt-1});at.push(...ht.map(mt=>mt.toString()))}else at.push(dt.toString())}return at};var isPlainObj=et=>{if(Object.prototype.toString.call(et)!=="[object Object]")return!1;const o=Object.getPrototypeOf(et);return o===null||o===Object.prototype};const isOptionObject=isPlainObj,{hasOwnProperty:hasOwnProperty$1}=Object.prototype,{propertyIsEnumerable}=Object,defineProperty$1=(et,o,tt)=>Object.defineProperty(et,o,{value:tt,writable:!0,enumerable:!0,configurable:!0}),globalThis$1=commonjsGlobal,defaultMergeOptions={concatArrays:!1,ignoreUndefined:!1},getEnumerableOwnPropertyKeys=et=>{const o=[];for(const tt in et)hasOwnProperty$1.call(et,tt)&&o.push(tt);if(Object.getOwnPropertySymbols){const tt=Object.getOwnPropertySymbols(et);for(const rt of tt)propertyIsEnumerable.call(et,rt)&&o.push(rt)}return o};function clone(et){return Array.isArray(et)?cloneArray(et):isOptionObject(et)?cloneOptionObject(et):et}function cloneArray(et){const o=et.slice(0,0);return getEnumerableOwnPropertyKeys(et).forEach(tt=>{defineProperty$1(o,tt,clone(et[tt]))}),o}function cloneOptionObject(et){const o=Object.getPrototypeOf(et)===null?Object.create(null):{};return getEnumerableOwnPropertyKeys(et).forEach(tt=>{defineProperty$1(o,tt,clone(et[tt]))}),o}const mergeKeys=(et,o,tt,rt)=>(tt.forEach(nt=>{typeof o[nt]>"u"&&rt.ignoreUndefined||(nt in et&&et[nt]!==Object.getPrototypeOf(et)?defineProperty$1(et,nt,merge$1(et[nt],o[nt],rt)):defineProperty$1(et,nt,clone(o[nt])))}),et),concatArrays=(et,o,tt)=>{let rt=et.slice(0,0),nt=0;return[et,o].forEach(ot=>{const it=[];for(let st=0;st!it.includes(st)),tt)}),rt};function merge$1(et,o,tt){return tt.concatArrays&&Array.isArray(et)&&Array.isArray(o)?concatArrays(et,o,tt):!isOptionObject(o)||!isOptionObject(et)?clone(o):mergeKeys(et,o,getEnumerableOwnPropertyKeys(o),tt)}var mergeOptions=function(...et){const o=merge$1(clone(defaultMergeOptions),this!==globalThis$1&&this||{},defaultMergeOptions);let tt={_:{}};for(const rt of et)if(rt!==void 0){if(!isOptionObject(rt))throw new TypeError("`"+rt+"` is not an Option Object");tt=merge$1(tt,{_:rt},o)}return tt._};const mergeOptions$1=getDefaultExportFromCjs(mergeOptions),DefaultConfig={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:et=>et},connectionManager:{resolvers:{dnsaddr:dnsaddrResolver}},transportManager:{faultTolerance:FaultTolerance.FATAL_ALL}};async function validateConfig(et){var tt,rt;const o=mergeOptions$1(DefaultConfig,et);if(o.connectionProtector===null&&((rt=(tt=globalThis.process)==null?void 0:tt.env)==null?void 0:rt.LIBP2P_FORCE_PNET)!=null)throw new InvalidParametersError$1("Private network is enforced, but no protector was provided");return o}function coerce$9(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function base$8(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$9=base$8,_brrp__multiformats_scope_baseX$8=src$9;let Encoder$8=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$8=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$8(this,o)}},ComposedDecoder$8=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$8(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$8(et,o){return new ComposedDecoder$8({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$8=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$8(o,tt,rt),this.decoder=new Decoder$8(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$9({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$8(et,o,tt,rt)}function baseX$8({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$8(tt,et);return from$9({prefix:o,name:et,encode:rt,decode:ot=>coerce$9(nt(ot))})}function decode$o(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$j(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<0)return parse$3(et);if(typeof et=="number"&&isFinite(et))return o!=null&&o.long?fmtLong(et):fmtShort(et);throw new Error("Value is not a string or number.")}catch(tt){const rt=isError$1(tt)?`${tt.message}. value=${JSON.stringify(et)}`:"An unknown error has occured.";throw new Error(rt)}}function parse$3(et){if(et=String(et),et.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");const o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(et);if(!o)return NaN;const tt=parseFloat(o[1]),rt=(o[2]||"ms").toLowerCase();switch(rt){case"years":case"year":case"yrs":case"yr":case"y":return tt*y;case"weeks":case"week":case"w":return tt*w;case"days":case"day":case"d":return tt*d;case"hours":case"hour":case"hrs":case"hr":case"h":return tt*h;case"minutes":case"minute":case"mins":case"min":case"m":return tt*m;case"seconds":case"second":case"secs":case"sec":case"s":return tt*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return tt;default:throw new Error(`The unit ${rt} was matched, but no matching case exists.`)}}function fmtShort(et){const o=Math.abs(et);return o>=d?`${Math.round(et/d)}d`:o>=h?`${Math.round(et/h)}h`:o>=m?`${Math.round(et/m)}m`:o>=s?`${Math.round(et/s)}s`:`${et}ms`}function fmtLong(et){const o=Math.abs(et);return o>=d?plural(et,o,d,"day"):o>=h?plural(et,o,h,"hour"):o>=m?plural(et,o,m,"minute"):o>=s?plural(et,o,s,"second"):`${et} ms`}function plural(et,o,tt,rt){const nt=o>=tt*1.5;return`${Math.round(et/tt)} ${rt}${nt?"s":""}`}function isError$1(et){return typeof et=="object"&&et!==null&&"message"in et}function setup(et){tt.debug=tt,tt.default=tt,tt.coerce=at,tt.disable=ot,tt.enable=nt,tt.enabled=it,tt.humanize=ms,tt.destroy=ct,Object.keys(et).forEach(lt=>{tt[lt]=et[lt]}),tt.names=[],tt.skips=[],tt.formatters={};function o(lt){let dt=0;for(let ht=0;ht{if(Ct==="%%")return"%";vt++;const At=tt.formatters[St];if(typeof At=="function"){const kt=gt[vt];Ct=At.call(yt,kt),gt.splice(vt,1),vt--}return Ct}),tt.formatArgs.call(yt,gt),(yt.log||tt.log).apply(yt,gt)}return pt.namespace=lt,pt.useColors=tt.useColors(),pt.color=tt.selectColor(lt),pt.extend=rt,pt.destroy=tt.destroy,Object.defineProperty(pt,"enabled",{enumerable:!0,configurable:!1,get:()=>ht!==null?ht:(mt!==tt.namespaces&&(mt=tt.namespaces,ft=tt.enabled(lt)),ft),set:gt=>{ht=gt}}),typeof tt.init=="function"&&tt.init(pt),pt}function rt(lt,dt){const ht=tt(this.namespace+(typeof dt>"u"?":":dt)+lt);return ht.log=this.log,ht}function nt(lt){tt.save(lt),tt.namespaces=lt,tt.names=[],tt.skips=[];let dt;const ht=(typeof lt=="string"?lt:"").split(/[\s,]+/),mt=ht.length;for(dt=0;dt"-"+dt)].join(",");return tt.enable(""),lt}function it(lt){if(lt[lt.length-1]==="*")return!0;let dt,ht;for(dt=0,ht=tt.skips.length;dt=31||typeof navigator<"u"&&((nt=navigator.userAgent)==null?void 0:nt.toLowerCase().match(/applewebkit\/(\d+)/))}function formatArgs(et){if(et[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+et[0]+(this.useColors?"%c ":" ")+"+"+ms(this.diff),!this.useColors)return;const o="color: "+this.color;et.splice(1,0,o,"color: inherit");let tt=0,rt=0;et[0].replace(/%[a-zA-Z%]/g,nt=>{nt!=="%%"&&(tt++,nt==="%c"&&(rt=tt))}),et.splice(rt,0,o)}const log$a=console.debug??console.log??(()=>{});function save(et){try{et?storage==null||storage.setItem("debug",et):storage==null||storage.removeItem("debug")}catch{}}function load$1(){let et;try{et=storage==null?void 0:storage.getItem("debug")}catch{}return!et&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(et=define_globalThis_process_env_default.DEBUG),et}function localstorage(){try{return localStorage}catch{}}function setupFormatters(et){et.j=function(o){try{return JSON.stringify(o)}catch(tt){return"[UnexpectedJSONParseError]: "+tt.message}}}const weald=setup({formatArgs,save,load:load$1,useColors,setupFormatters,colors,storage,log:log$a});weald.formatters.b=et=>et==null?"undefined":base58btc$8.baseEncode(et);weald.formatters.t=et=>et==null?"undefined":base32$f.baseEncode(et);weald.formatters.m=et=>et==null?"undefined":base64$e.baseEncode(et);weald.formatters.p=et=>et==null?"undefined":et.toString();weald.formatters.c=et=>et==null?"undefined":et.toString();weald.formatters.k=et=>et==null?"undefined":et.toString();weald.formatters.a=et=>et==null?"undefined":et.toString();weald.formatters.e=et=>et==null?"undefined":notEmpty(et.stack)??notEmpty(et.message)??et.toString();function createDisabledLogger(et){const o=()=>{};return o.enabled=!1,o.color="",o.diff=0,o.log=()=>{},o.namespace=et,o.destroy=()=>!0,o.extend=()=>o,o}function defaultLogger(){return{forComponent(et){return logger$2(et)}}}function logger$2(et){let o=createDisabledLogger(`${et}:trace`);return weald.enabled(`${et}:trace`)&&weald.names.map(tt=>tt.toString()).find(tt=>tt.includes(":trace"))!=null&&(o=weald(`${et}:trace`)),Object.assign(weald(et),{error:weald(`${et}:error`),trace:o})}function notEmpty(et){if(et!=null&&(et=et.trim(),et.length!==0))return et}function coerce$8(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function base$7(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$8=base$7,_brrp__multiformats_scope_baseX$7=src$8;let Encoder$7=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$7=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$7(this,o)}},ComposedDecoder$7=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$7(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$7(et,o){return new ComposedDecoder$7({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$7=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$7(o,tt,rt),this.decoder=new Decoder$7(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$8({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$7(et,o,tt,rt)}function baseX$7({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$7(tt,et);return from$8({prefix:o,name:et,encode:rt,decode:ot=>coerce$8(nt(ot))})}const base58btc$7=baseX$7({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"});baseX$7({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var encode_1$1=encode$i,MSB$2=128,REST$2=127,MSBALL$1=~REST$2,INT$1=Math.pow(2,31);function encode$i(et,o,tt){o=o||[],tt=tt||0;for(var rt=tt;et>=INT$1;)o[tt++]=et&255|MSB$2,et/=128;for(;et&MSBALL$1;)o[tt++]=et&255|MSB$2,et>>>=7;return o[tt]=et|0,encode$i.bytes=tt-rt+1,o}var decode$n=read$2,MSB$1$1=128,REST$1$1=127;function read$2(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$2.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$1)<=MSB$1$1);return read$2.bytes=ot-rt,tt}var N1$1=Math.pow(2,7),N2$1=Math.pow(2,14),N3$1=Math.pow(2,21),N4$1=Math.pow(2,28),N5$1=Math.pow(2,35),N6$1=Math.pow(2,42),N7$1=Math.pow(2,49),N8$1=Math.pow(2,56),N9$1=Math.pow(2,63),length$1=function(et){return ettt,next:()=>{const rt=et.next(),nt=rt.value;return rt.done===!0||nt==null?{done:!0,value:void 0}:{done:!1,value:o(nt)}}};return tt}function peerIdFromString(et){const o=decode$l(base58btc$7.decode(`z${et}`));return peerIdFromMultihash(o)}class PeerMap{constructor(o){wt(this,"map");if(this.map=new Map,o!=null)for(const[tt,rt]of o.entries())this.map.set(tt.toString(),{key:tt,value:rt})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(o){return this.map.delete(o.toString())}entries(){return mapIterable(this.map.entries(),o=>[o[1].key,o[1].value])}forEach(o){this.map.forEach((tt,rt)=>{o(tt.value,tt.key,this)})}get(o){var tt;return(tt=this.map.get(o.toString()))==null?void 0:tt.value}has(o){return this.map.has(o.toString())}set(o,tt){this.map.set(o.toString(),{key:o,value:tt})}keys(){return mapIterable(this.map.values(),o=>o.key)}values(){return mapIterable(this.map.values(),o=>o.value)}get size(){return this.map.size}}class PeerSet{constructor(o){wt(this,"set");if(this.set=new Set,o!=null)for(const tt of o)this.set.add(tt.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=>{const tt=peerIdFromString(o[0]);return[tt,tt]})}forEach(o){this.set.forEach(tt=>{const rt=peerIdFromString(tt);o(rt,rt,this)})}has(o){return this.set.has(o.toString())}values(){return mapIterable(this.set.values(),o=>peerIdFromString(o))}intersection(o){const tt=new PeerSet;for(const rt of o)this.has(rt)&&tt.add(rt);return tt}difference(o){const tt=new PeerSet;for(const rt of this)o.has(rt)||tt.add(rt);return tt}union(o){const tt=new PeerSet;for(const rt of o)tt.add(rt);for(const rt of this)tt.add(rt);return tt}}var murmurHash3js={exports:{}};(function(et,o){(function(tt,rt){var nt={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function ot(pt){if(!Array.isArray(pt)&&!ArrayBuffer.isView(pt))return!1;for(var gt=0;gt255)return!1;return!0}function it(pt,gt){return(pt&65535)*gt+(((pt>>>16)*gt&65535)<<16)}function st(pt,gt){return pt<>>32-gt}function at(pt){return pt^=pt>>>16,pt=it(pt,2246822507),pt^=pt>>>13,pt=it(pt,3266489909),pt^=pt>>>16,pt}function ct(pt,gt){pt=[pt[0]>>>16,pt[0]&65535,pt[1]>>>16,pt[1]&65535],gt=[gt[0]>>>16,gt[0]&65535,gt[1]>>>16,gt[1]&65535];var yt=[0,0,0,0];return yt[3]+=pt[3]+gt[3],yt[2]+=yt[3]>>>16,yt[3]&=65535,yt[2]+=pt[2]+gt[2],yt[1]+=yt[2]>>>16,yt[2]&=65535,yt[1]+=pt[1]+gt[1],yt[0]+=yt[1]>>>16,yt[1]&=65535,yt[0]+=pt[0]+gt[0],yt[0]&=65535,[yt[0]<<16|yt[1],yt[2]<<16|yt[3]]}function lt(pt,gt){pt=[pt[0]>>>16,pt[0]&65535,pt[1]>>>16,pt[1]&65535],gt=[gt[0]>>>16,gt[0]&65535,gt[1]>>>16,gt[1]&65535];var yt=[0,0,0,0];return yt[3]+=pt[3]*gt[3],yt[2]+=yt[3]>>>16,yt[3]&=65535,yt[2]+=pt[2]*gt[3],yt[1]+=yt[2]>>>16,yt[2]&=65535,yt[2]+=pt[3]*gt[2],yt[1]+=yt[2]>>>16,yt[2]&=65535,yt[1]+=pt[1]*gt[3],yt[0]+=yt[1]>>>16,yt[1]&=65535,yt[1]+=pt[2]*gt[2],yt[0]+=yt[1]>>>16,yt[1]&=65535,yt[1]+=pt[3]*gt[1],yt[0]+=yt[1]>>>16,yt[1]&=65535,yt[0]+=pt[0]*gt[3]+pt[1]*gt[2]+pt[2]*gt[1]+pt[3]*gt[0],yt[0]&=65535,[yt[0]<<16|yt[1],yt[2]<<16|yt[3]]}function dt(pt,gt){return gt%=64,gt===32?[pt[1],pt[0]]:gt<32?[pt[0]<>>32-gt,pt[1]<>>32-gt]:(gt-=32,[pt[1]<>>32-gt,pt[0]<>>32-gt])}function ht(pt,gt){return gt%=64,gt===0?pt:gt<32?[pt[0]<>>32-gt,pt[1]<>>1]),pt=lt(pt,[4283543511,3981806797]),pt=mt(pt,[0,pt[0]>>>1]),pt=lt(pt,[3301882366,444984403]),pt=mt(pt,[0,pt[0]>>>1]),pt}nt.x86.hash32=function(pt,gt){if(nt.inputValidation&&!ot(pt))return rt;gt=gt||0;for(var yt=pt.length%4,bt=pt.length-yt,xt=gt,vt=0,Et=3432918353,Ct=461845907,St=0;St>>0},nt.x86.hash128=function(pt,gt){if(nt.inputValidation&&!ot(pt))return rt;gt=gt||0;for(var yt=pt.length%16,bt=pt.length-yt,xt=gt,vt=gt,Et=gt,Ct=gt,St=0,At=0,kt=0,It=0,Ot=597399067,Nt=2869860233,Yt=951274213,Ft=2716044179,Ht=0;Ht>>0).toString(16)).slice(-8)+("00000000"+(vt>>>0).toString(16)).slice(-8)+("00000000"+(Et>>>0).toString(16)).slice(-8)+("00000000"+(Ct>>>0).toString(16)).slice(-8)},nt.x64.hash128=function(pt,gt){if(nt.inputValidation&&!ot(pt))return rt;gt=gt||0;for(var yt=pt.length%16,bt=pt.length-yt,xt=[0,gt],vt=[0,gt],Et=[0,0],Ct=[0,0],St=[2277735313,289559509],At=[1291169091,658871167],kt=0;kt>>0).toString(16)).slice(-8)+("00000000"+(xt[1]>>>0).toString(16)).slice(-8)+("00000000"+(vt[0]>>>0).toString(16)).slice(-8)+("00000000"+(vt[1]>>>0).toString(16)).slice(-8)},et.exports&&(o=et.exports=nt),o.murmurHash3=nt})()})(murmurHash3js,murmurHash3js.exports);function alloc$2(et=0){return new Uint8Array(et)}function allocUnsafe$4(et=0){return new Uint8Array(et)}function coerce$7(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$b(et){return new TextEncoder().encode(et)}function toString$e(et){return new TextDecoder().decode(et)}function base$6(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$7=base$6,_brrp__multiformats_scope_baseX$6=src$7;let Encoder$6=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$6=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$6(this,o)}},ComposedDecoder$6=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$6(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$6(et,o){return new ComposedDecoder$6({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$6=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$6(o,tt,rt),this.decoder=new Decoder$6(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$7({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$6(et,o,tt,rt)}function baseX$6({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$6(tt,et);return from$7({prefix:o,name:et,encode:rt,decode:ot=>coerce$7(nt(ot))})}function decode$k(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$h(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$5=alphabet$5.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$g(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$5[tt],o),"")}function decode$j(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$5[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$a=from$7({prefix:"🚀",name:"base256emoji",encode:encode$g,decode:decode$j}),base256emoji$b=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$a},Symbol.toStringTag,{value:"Module"})),base32$d=rfc4648$6({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$5=rfc4648$6({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$5=rfc4648$6({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$5=rfc4648$6({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$5=rfc4648$6({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$5=rfc4648$6({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$5=rfc4648$6({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$5=rfc4648$6({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$5=rfc4648$6({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$e=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$d,base32hex:base32hex$5,base32hexpad:base32hexpad$5,base32hexpadupper:base32hexpadupper$5,base32hexupper:base32hexupper$5,base32pad:base32pad$5,base32padupper:base32padupper$5,base32upper:base32upper$5,base32z:base32z$5},Symbol.toStringTag,{value:"Module"})),base36$b=baseX$6({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$5=baseX$6({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$c=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$b,base36upper:base36upper$5},Symbol.toStringTag,{value:"Module"})),base58btc$6=baseX$6({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$5=baseX$6({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$5=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$6,base58flickr:base58flickr$5},Symbol.toStringTag,{value:"Module"})),base64$c=rfc4648$6({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$5=rfc4648$6({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$5=rfc4648$6({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$5=rfc4648$6({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$d=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$c,base64pad:base64pad$5,base64url:base64url$5,base64urlpad:base64urlpad$5},Symbol.toStringTag,{value:"Module"})),base8$a=rfc4648$6({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$b=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$a},Symbol.toStringTag,{value:"Module"})),identity$5=from$7({prefix:"\0",name:"identity",encode:et=>toString$e(et),decode:et=>fromString$b(et)}),identityBase$5=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$5},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$5={...identityBase$5,...base2$b,...base8$b,...base10$b,...base16$b,...base32$e,...base36$c,...base58$5,...base64$d,...base256emoji$b};function createCodec$5(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$8=createCodec$5("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$5=createCodec$5("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$4(et.length);for(let tt=0;ttMAX_FINGERPRINT_SIZE)throw new TypeError("Invalid Fingerprint Size");const ot=tt.hashV(o,rt),it=alloc$2(nt);for(let st=0;sto.equals(tt))}add(o){if(!(o instanceof Fingerprint))throw new TypeError("Invalid Fingerprint");for(let tt=0;tto.equals(rt));return tt>-1?(this.contents[tt]=null,!0):!1}}const FNV_PRIMES={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},FNV_OFFSETS={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},cachedEncoder=new globalThis.TextEncoder;function fnv1aUint8Array(et,o){const tt=FNV_PRIMES[o];let rt=FNV_OFFSETS[o];for(let nt=0;nt0;){const it=cachedEncoder.encodeInto(ot,tt);ot=ot.slice(it.read);for(let st=0;stNumber(fnv1a$1(et,{size:32})),hashV:(et,o)=>numberToBuffer(fnv1a.hash(et,o))};function numberToBuffer(et){let o=et.toString(16);return o.length%2===1&&(o=`0${o}`),fromString$a(o,"base16")}const maxCuckooCount=500;class CuckooFilter{constructor(o){wt(this,"bucketSize");wt(this,"filterSize");wt(this,"fingerprintSize");wt(this,"buckets");wt(this,"count");wt(this,"hash");wt(this,"seed");this.filterSize=o.filterSize,this.bucketSize=o.bucketSize??4,this.fingerprintSize=o.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=o.hash??fnv1a,this.seed=o.seed??getRandomInt(0,Math.pow(2,10))}add(o){typeof o=="string"&&(o=fromString$a(o));const tt=new Fingerprint(o,this.hash,this.seed,this.fingerprintSize),rt=this.hash.hash(o,this.seed)%this.filterSize,nt=(rt^tt.hash())%this.filterSize;if(this.buckets[rt]==null&&(this.buckets[rt]=new Bucket(this.bucketSize)),this.buckets[nt]==null&&(this.buckets[nt]=new Bucket(this.bucketSize)),this.buckets[rt].add(tt)||this.buckets[nt].add(tt))return this.count++,!0;const ot=[rt,nt];let it=ot[getRandomInt(0,ot.length-1)];this.buckets[it]==null&&(this.buckets[it]=new Bucket(this.bucketSize));for(let st=0;st.002?2:et>1e-5?4:8}function optimize(et,o=.001){const tt=calculateBucketSize(o),rt=MAX_LOAD[tt],nt=Math.round(et/rt),ot=Math.min(Math.ceil(Math.log2(1/o)+Math.log2(2*tt)),MAX_FINGERPRINT_SIZE);return{filterSize:nt,bucketSize:tt,fingerprintSize:ot}}class ScalableCuckooFilter{constructor(o){wt(this,"filterSize");wt(this,"bucketSize");wt(this,"fingerprintSize");wt(this,"scale");wt(this,"filterSeries");wt(this,"hash");wt(this,"seed");this.bucketSize=o.bucketSize??4,this.filterSize=o.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=o.fingerprintSize??2,this.scale=o.scale??2,this.hash=o.hash??fnv1a,this.seed=o.seed??getRandomInt(0,Math.pow(2,10)),this.filterSeries=[new CuckooFilter({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(o){if(typeof o=="string"&&(o=fromString$a(o)),this.has(o))return!0;let tt=this.filterSeries.find(rt=>rt.reliable);if(tt==null){const rt=this.filterSize*Math.pow(this.scale,this.filterSeries.length);tt=new CuckooFilter({filterSize:rt,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(tt)}return tt.add(o)}has(o){typeof o=="string"&&(o=fromString$a(o));for(let tt=0;tto+tt.count,0)}}function createScalableCuckooFilter(et,o=.001,tt){return new ScalableCuckooFilter({...optimize(et,o)})}const peerIdSymbol=Symbol.for("@libp2p/peer-id");function isPeerId(et){return!!(et!=null&&et[peerIdSymbol])}class InvalidParametersError extends Error{constructor(o="Invalid parameters"){super(o),this.name="InvalidParametersError"}}wt(InvalidParametersError,"name","InvalidParametersError");const events={},observable=et=>{et.addEventListener("message",o=>{observable.dispatchEvent("message",et,o)}),et.port!=null&&et.port.addEventListener("message",o=>{observable.dispatchEvent("message",et,o)})};observable.addEventListener=(et,o)=>{events[et]==null&&(events[et]=[]),events[et].push(o)};observable.removeEventListener=(et,o)=>{events[et]!=null&&(events[et]=events[et].filter(tt=>tt===o))};observable.dispatchEvent=function(et,o,tt){events[et]!=null&&events[et].forEach(rt=>rt(o,tt))};const WORKER_REQUEST_READ_LOCK="lock:worker:request-read",WORKER_RELEASE_READ_LOCK="lock:worker:release-read",MASTER_GRANT_READ_LOCK="lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK="lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK="lock:worker:release-write",MASTER_GRANT_WRITE_LOCK="lock:master:grant-write",nanoid=(et=21)=>Math.random().toString().substring(2),handleWorkerLockRequest=(et,o,tt,rt,nt)=>(ot,it)=>{if(it.data.type!==tt)return;const st={type:it.data.type,name:it.data.name,identifier:it.data.identifier};et.dispatchEvent(new MessageEvent(o,{data:{name:st.name,handler:async()=>{ot.postMessage({type:nt,name:st.name,identifier:st.identifier}),await new Promise(at=>{const ct=lt=>{if((lt==null?void 0:lt.data)==null)return;const dt={type:lt.data.type,name:lt.data.name,identifier:lt.data.identifier};dt.type===rt&&dt.identifier===st.identifier&&(ot.removeEventListener("message",ct),at())};ot.addEventListener("message",ct)})}}}))},makeWorkerLockRequest=(et,o,tt,rt)=>async()=>{const nt=nanoid();return globalThis.postMessage({type:o,identifier:nt,name:et}),new Promise(ot=>{const it=st=>{if((st==null?void 0:st.data)==null)return;const at={type:st.data.type,identifier:st.data.identifier};at.type===tt&&at.identifier===nt&&(globalThis.removeEventListener("message",it),ot(()=>{globalThis.postMessage({type:rt,identifier:nt,name:et})}))};globalThis.addEventListener("message",it)})},defaultOptions$4={singleProcess:!1},impl=et=>{if(et=Object.assign({},defaultOptions$4,et),!!globalThis.document||et.singleProcess){const tt=new EventTarget;return observable.addEventListener("message",handleWorkerLockRequest(tt,"requestReadLock",WORKER_REQUEST_READ_LOCK,WORKER_RELEASE_READ_LOCK,MASTER_GRANT_READ_LOCK)),observable.addEventListener("message",handleWorkerLockRequest(tt,"requestWriteLock",WORKER_REQUEST_WRITE_LOCK,WORKER_RELEASE_WRITE_LOCK,MASTER_GRANT_WRITE_LOCK)),tt}return{isWorker:!0,readLock:tt=>makeWorkerLockRequest(tt,WORKER_REQUEST_READ_LOCK,MASTER_GRANT_READ_LOCK,WORKER_RELEASE_READ_LOCK),writeLock:tt=>makeWorkerLockRequest(tt,WORKER_REQUEST_WRITE_LOCK,MASTER_GRANT_WRITE_LOCK,WORKER_RELEASE_WRITE_LOCK)}},mutexes={};let implementation;async function createReleaseable(et,o){let tt;const rt=new Promise(nt=>{tt=nt});return et.add(async()=>pTimeout((async()=>{await new Promise(nt=>{tt(()=>{nt()})})})(),{milliseconds:o.timeout})),rt}const createMutex=(et,o)=>{if(implementation.isWorker===!0)return{readLock:implementation.readLock(et,o),writeLock:implementation.writeLock(et,o)};const tt=new PQueue({concurrency:1});let rt;return{async readLock(){if(rt!=null)return createReleaseable(rt,o);rt=new PQueue({concurrency:o.concurrency,autoStart:!1});const nt=rt,ot=createReleaseable(rt,o);return tt.add(async()=>{nt.start(),await nt.onIdle().then(()=>{rt===nt&&(rt=null)})}),ot},async writeLock(){return rt=null,createReleaseable(tt,o)}}},defaultOptions$3={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function createMortice(et){const o=Object.assign({},defaultOptions$3,et);return implementation==null&&(implementation=impl(o),implementation.isWorker!==!0&&(implementation.addEventListener("requestReadLock",tt=>{mutexes[tt.data.name]!=null&&mutexes[tt.data.name].readLock().then(async rt=>tt.data.handler().finally(()=>{rt()}))}),implementation.addEventListener("requestWriteLock",async tt=>{mutexes[tt.data.name]!=null&&mutexes[tt.data.name].writeLock().then(async rt=>tt.data.handler().finally(()=>{rt()}))}))),mutexes[o.name]==null&&(mutexes[o.name]=createMutex(o.name,o)),mutexes[o.name]}function equals$2(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$6=base$5,_brrp__multiformats_scope_baseX$5=src$6;let Encoder$5=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$5=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$5(this,o)}},ComposedDecoder$5=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$5(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$5(et,o){return new ComposedDecoder$5({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$5=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$5(o,tt,rt),this.decoder=new Decoder$5(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$6({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$5(et,o,tt,rt)}function baseX$5({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$5(tt,et);return from$6({prefix:o,name:et,encode:rt,decode:ot=>coerce$6(nt(ot))})}function decode$i(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$f(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<=INT;)o[tt++]=et&255|MSB,et/=128;for(;et&MSBALL;)o[tt++]=et&255|MSB,et>>>=7;return o[tt]=et|0,encode$e.bytes=tt-rt+1,o}var decode$h=read$1,MSB$1=128,REST$1=127;function read$1(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$1.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1)<=MSB$1);return read$1.bytes=ot-rt,tt}var N1=Math.pow(2,7),N2=Math.pow(2,14),N3=Math.pow(2,21),N4=Math.pow(2,28),N5=Math.pow(2,35),N6=Math.pow(2,42),N7=Math.pow(2,49),N8=Math.pow(2,56),N9=Math.pow(2,63),length=function(et){return et{const[dt,ht]=decode$g(o.subarray(tt));return tt+=ht,dt};let nt=rt(),ot=DAG_PB_CODE;if(nt===18?(nt=0,tt=0):ot=rt(),nt!==0&&nt!==1)throw new RangeError(`Invalid CID version ${nt}`);const it=tt,st=rt(),at=rt(),ct=tt+at,lt=ct-it;return{version:nt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(o,tt){const[rt,nt]=parseCIDtoBytes(o,tt),ot=CID.decode(nt);if(ot.version===0&&o[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache(ot).set(rt,o),ot}}function parseCIDtoBytes(et,o){switch(et[0]){case"Q":{const tt=o??base58btc$5;return[base58btc$5.prefix,tt.decode(`${base58btc$5.prefix}${et}`)]}case base58btc$5.prefix:{const tt=o??base58btc$5;return[base58btc$5.prefix,tt.decode(et)]}case base32$c.prefix:{const tt=o??base32$c;return[base32$c.prefix,tt.decode(et)]}case base36$a.prefix:{const tt=o??base36$a;return[base36$a.prefix,tt.decode(et)]}default:{if(o==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[et[0],o.decode(et)]}}}function toStringV0(et,o,tt){const{prefix:rt}=tt;if(rt!==base58btc$5.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const nt=o.get(rt);if(nt==null){const ot=tt.encode(et).slice(1);return o.set(rt,ot),ot}else return nt}function toStringV1(et,o,tt){const{prefix:rt}=tt,nt=o.get(rt);if(nt==null){const ot=tt.encode(et);return o.set(rt,ot),ot}else return nt}const DAG_PB_CODE=112,SHA_256_CODE=18;function encodeCID(et,o,tt){const rt=encodingLength$2(et),nt=rt+encodingLength$2(o),ot=new Uint8Array(nt+tt.byteLength);return encodeTo(et,ot,0),encodeTo(o,ot,rt),ot.set(tt,nt),ot}const cidSymbol=Symbol.for("@ipld/js-cid/CID");function equals(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt(rt==null&&(rt=message$1((nt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),nt.key!=null&&nt.key!==""&&(ot.uint32(10),ot.string(nt.key)),nt.value!=null&&nt.value.byteLength>0&&(ot.uint32(18),ot.bytes(nt.value)),it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{const st={key:"",value:alloc$1(0)},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.key=nt.string();break}case 2:{st.value=nt.bytes();break}default:{nt.skipType(ct&7);break}}}return st})),rt),tt.encode=nt=>encodeMessage(nt,tt.codec()),tt.decode=(nt,ot)=>decodeMessage(nt,tt.codec(),ot)})(et.Peer$metadataEntry||(et.Peer$metadataEntry={})),function(tt){let rt;tt.codec=()=>(rt==null&&(rt=message$1((nt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),nt.key!=null&&nt.key!==""&&(ot.uint32(10),ot.string(nt.key)),nt.value!=null&&(ot.uint32(18),Tag.codec().encode(nt.value,ot)),it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{var ct;const st={key:""},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.key=nt.string();break}case 2:{st.value=Tag.codec().decode(nt,nt.uint32(),{limits:(ct=it.limits)==null?void 0:ct.value});break}default:{nt.skipType(lt&7);break}}}return st})),rt),tt.encode=nt=>encodeMessage(nt,tt.codec()),tt.decode=(nt,ot)=>decodeMessage(nt,tt.codec(),ot)}(et.Peer$tagsEntry||(et.Peer$tagsEntry={}));let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.addresses!=null)for(const ot of tt.addresses)rt.uint32(10),Address.codec().encode(ot,rt);if(tt.protocols!=null)for(const ot of tt.protocols)rt.uint32(18),rt.string(ot);if(tt.publicKey!=null&&(rt.uint32(34),rt.bytes(tt.publicKey)),tt.peerRecordEnvelope!=null&&(rt.uint32(42),rt.bytes(tt.peerRecordEnvelope)),tt.metadata!=null&&tt.metadata.size!==0)for(const[ot,it]of tt.metadata.entries())rt.uint32(50),et.Peer$metadataEntry.codec().encode({key:ot,value:it},rt);if(tt.tags!=null&&tt.tags.size!==0)for(const[ot,it]of tt.tags.entries())rt.uint32(58),et.Peer$tagsEntry.codec().encode({key:ot,value:it},rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at,ct,lt,dt,ht;const ot={addresses:[],protocols:[],metadata:new Map,tags:new Map},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{if(((st=nt.limits)==null?void 0:st.addresses)!=null&&ot.addresses.length===nt.limits.addresses)throw new MaxLengthError('Decode error - map field "addresses" had too many elements');ot.addresses.push(Address.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.addresses$}));break}case 2:{if(((ct=nt.limits)==null?void 0:ct.protocols)!=null&&ot.protocols.length===nt.limits.protocols)throw new MaxLengthError('Decode error - map field "protocols" had too many elements');ot.protocols.push(tt.string());break}case 4:{ot.publicKey=tt.bytes();break}case 5:{ot.peerRecordEnvelope=tt.bytes();break}case 6:{if(((lt=nt.limits)==null?void 0:lt.metadata)!=null&&ot.metadata.size===nt.limits.metadata)throw new MaxSizeError('Decode error - map field "metadata" had too many elements');const ft=et.Peer$metadataEntry.codec().decode(tt,tt.uint32());ot.metadata.set(ft.key,ft.value);break}case 7:{if(((dt=nt.limits)==null?void 0:dt.tags)!=null&&ot.tags.size===nt.limits.tags)throw new MaxSizeError('Decode error - map field "tags" had too many elements');const ft=et.Peer$tagsEntry.codec().decode(tt,tt.uint32(),{limits:{value:(ht=nt.limits)==null?void 0:ht.tags$value}});ot.tags.set(ft.key,ft.value);break}default:{tt.skipType(mt&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Peer||(Peer={}));var Address;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.multiaddr!=null&&tt.multiaddr.byteLength>0&&(rt.uint32(10),rt.bytes(tt.multiaddr)),tt.isCertified!=null&&(rt.uint32(16),rt.bool(tt.isCertified)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={multiaddr:alloc$1(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.multiaddr=tt.bytes();break}case 2:{ot.isCertified=tt.bool();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Address||(Address={}));var Tag;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.value!=null&&tt.value!==0&&(rt.uint32(8),rt.uint32(tt.value)),tt.expiry!=null&&(rt.uint32(16),rt.uint64(tt.expiry)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={value:0},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.value=tt.uint32();break}case 2:{ot.expiry=tt.uint64();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Tag||(Tag={}));function bytesToPeer(et,o){const tt=Peer.decode(o);if(tt.publicKey!=null&&et.publicKey==null){const ot=publicKeyFromProtobuf(tt.publicKey);et=peerIdFromPublicKey(ot)}const rt=new Map,nt=BigInt(Date.now());for(const[ot,it]of tt.tags.entries())it.expiry!=null&&it.expiry({multiaddr:multiaddr(ot),isCertified:it??!1})),metadata:tt.metadata,peerRecordEnvelope:tt.peerRecordEnvelope??void 0,tags:rt}}function coerce$5(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$9(et){return new TextEncoder().encode(et)}function toString$d(et){return new TextDecoder().decode(et)}function base$4(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$5=base$4,_brrp__multiformats_scope_baseX$4=src$5;let Encoder$4=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$4=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$4(this,o)}},ComposedDecoder$4=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$4(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$4(et,o){return new ComposedDecoder$4({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$4=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$4(o,tt,rt),this.decoder=new Decoder$4(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$5({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$4(et,o,tt,rt)}function baseX$4({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$4(tt,et);return from$5({prefix:o,name:et,encode:rt,decode:ot=>coerce$5(nt(ot))})}function decode$e(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$d(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$4=alphabet$4.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$c(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$4[tt],o),"")}function decode$d(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$4[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$8=from$5({prefix:"🚀",name:"base256emoji",encode:encode$c,decode:decode$d}),base256emoji$9=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$8},Symbol.toStringTag,{value:"Module"})),base32$a=rfc4648$4({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$4=rfc4648$4({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$4=rfc4648$4({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$4=rfc4648$4({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$4=rfc4648$4({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$4=rfc4648$4({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$4=rfc4648$4({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$4=rfc4648$4({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$4=rfc4648$4({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$b=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$a,base32hex:base32hex$4,base32hexpad:base32hexpad$4,base32hexpadupper:base32hexpadupper$4,base32hexupper:base32hexupper$4,base32pad:base32pad$4,base32padupper:base32padupper$4,base32upper:base32upper$4,base32z:base32z$4},Symbol.toStringTag,{value:"Module"})),base36$8=baseX$4({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$4=baseX$4({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$9=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$8,base36upper:base36upper$4},Symbol.toStringTag,{value:"Module"})),base58btc$4=baseX$4({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$4=baseX$4({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$4=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$4,base58flickr:base58flickr$4},Symbol.toStringTag,{value:"Module"})),base64$a=rfc4648$4({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$4=rfc4648$4({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$4=rfc4648$4({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$4=rfc4648$4({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$b=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$a,base64pad:base64pad$4,base64url:base64url$4,base64urlpad:base64urlpad$4},Symbol.toStringTag,{value:"Module"})),base8$8=rfc4648$4({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$9=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$8},Symbol.toStringTag,{value:"Module"})),identity$4=from$5({prefix:"\0",name:"identity",encode:et=>toString$d(et),decode:et=>fromString$9(et)}),identityBase$4=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$4},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$4={...identityBase$4,...base2$9,...base8$9,...base10$9,...base16$9,...base32$b,...base36$9,...base58$4,...base64$b,...base256emoji$9};function allocUnsafe$3(et=0){return new Uint8Array(et)}function createCodec$4(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$7=createCodec$4("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$4=createCodec$4("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$3(et.length);for(let tt=0;tt1&&this._buf[this._buf.byteLength-1]===pathSep;)this._buf=this._buf.subarray(0,-1)}less(o){const tt=this.list(),rt=o.list();for(let nt=0;ntit)return!1}return tt.lengthtt.namespaces()))])}}function namespaceType(et){const o=et.split(":");return o.length<2?"":o.slice(0,-1).join(":")}function namespaceValue(et){const o=et.split(":");return o[o.length-1]}function flatten(et){return[].concat(...et)}const NAMESPACE_COMMON="/peers/";function peerIdToDatastoreKey(et){if(!isPeerId(et)||et.type==null)throw new InvalidParametersError("Invalid PeerId");const o=et.toCID().toString();return new Key(`${NAMESPACE_COMMON}${o}`)}async function dedupeFilterAndSortAddresses(et,o,tt){const rt=new Map;for(const nt of tt){if(nt==null)continue;if(nt.multiaddr instanceof Uint8Array&&(nt.multiaddr=multiaddr(nt.multiaddr)),!isMultiaddr(nt.multiaddr))throw new InvalidParametersError("Multiaddr was invalid");if(!await o(et,nt.multiaddr))continue;const ot=nt.isCertified??!1,it=nt.multiaddr.toString(),st=rt.get(it);st!=null?nt.isCertified=st.isCertified||ot:rt.set(it,{multiaddr:nt.multiaddr,isCertified:ot})}return[...rt.values()].sort((nt,ot)=>nt.multiaddr.toString().localeCompare(ot.multiaddr.toString())).map(({isCertified:nt,multiaddr:ot})=>({isCertified:nt,multiaddr:ot.bytes}))}async function toPeerPB(et,o,tt,rt){if(o==null)throw new InvalidParametersError("Invalid PeerData");if(o.publicKey!=null&&et.publicKey!=null&&!o.publicKey.equals(et.publicKey))throw new InvalidParametersError("publicKey bytes do not match peer id publicKey bytes");const nt=rt.existingPeer;if(nt!=null&&!et.equals(nt.id))throw new InvalidParametersError("peer id did not match existing peer id");let ot=(nt==null?void 0:nt.addresses)??[],it=new Set((nt==null?void 0:nt.protocols)??[]),st=(nt==null?void 0:nt.metadata)??new Map,at=(nt==null?void 0:nt.tags)??new Map,ct=nt==null?void 0:nt.peerRecordEnvelope;if(tt==="patch"){if((o.multiaddrs!=null||o.addresses!=null)&&(ot=[],o.multiaddrs!=null&&ot.push(...o.multiaddrs.map(ht=>({isCertified:!1,multiaddr:ht}))),o.addresses!=null&&ot.push(...o.addresses)),o.protocols!=null&&(it=new Set(o.protocols)),o.metadata!=null){const ht=o.metadata instanceof Map?[...o.metadata.entries()]:Object.entries(o.metadata);st=createSortedMap(ht,{validate:validateMetadata})}if(o.tags!=null){const ht=o.tags instanceof Map?[...o.tags.entries()]:Object.entries(o.tags);at=createSortedMap(ht,{validate:validateTag,map:mapTag})}o.peerRecordEnvelope!=null&&(ct=o.peerRecordEnvelope)}if(tt==="merge"){if(o.multiaddrs!=null&&ot.push(...o.multiaddrs.map(ht=>({isCertified:!1,multiaddr:ht}))),o.addresses!=null&&ot.push(...o.addresses),o.protocols!=null&&(it=new Set([...it,...o.protocols])),o.metadata!=null){const ht=o.metadata instanceof Map?[...o.metadata.entries()]:Object.entries(o.metadata);for(const[mt,ft]of ht)ft==null?st.delete(mt):st.set(mt,ft);st=createSortedMap([...st.entries()],{validate:validateMetadata})}if(o.tags!=null){const ht=o.tags instanceof Map?[...o.tags.entries()]:Object.entries(o.tags),mt=new Map(at);for(const[ft,pt]of ht)pt==null?mt.delete(ft):mt.set(ft,pt);at=createSortedMap([...mt.entries()],{validate:validateTag,map:mapTag})}o.peerRecordEnvelope!=null&&(ct=o.peerRecordEnvelope)}let lt;(nt==null?void 0:nt.id.publicKey)!=null?lt=publicKeyToProtobuf(nt.id.publicKey):o.publicKey!=null?lt=publicKeyToProtobuf(o.publicKey):et.publicKey!=null&&(lt=publicKeyToProtobuf(et.publicKey));const dt={addresses:await dedupeFilterAndSortAddresses(et,rt.addressFilter??(async()=>!0),ot),protocols:[...it.values()].sort((ht,mt)=>ht.localeCompare(mt)),metadata:st,tags:at,publicKey:lt,peerRecordEnvelope:ct};return et.type!=="RSA"&&delete dt.publicKey,dt}function createSortedMap(et,o){var rt;const tt=new Map;for(const[nt,ot]of et)ot!=null&&o.validate(nt,ot);for(const[nt,ot]of et.sort(([it],[st])=>it.localeCompare(st)))ot!=null&&tt.set(nt,((rt=o.map)==null?void 0:rt.call(o,nt,ot))??ot);return tt}function validateMetadata(et,o){if(typeof et!="string")throw new InvalidParametersError("Metadata key must be a string");if(!(o instanceof Uint8Array))throw new InvalidParametersError("Metadata value must be a Uint8Array")}function validateTag(et,o){if(typeof et!="string")throw new InvalidParametersError("Tag name must be a string");if(o.value!=null){if(parseInt(`${o.value}`,10)!==o.value)throw new InvalidParametersError("Tag value must be an integer");if(o.value<0||o.value>100)throw new InvalidParametersError("Tag value must be between 0-100")}if(o.ttl!=null){if(parseInt(`${o.ttl}`,10)!==o.ttl)throw new InvalidParametersError("Tag ttl must be an integer");if(o.ttl<0)throw new InvalidParametersError("Tag ttl must be between greater than 0")}}function mapTag(et,o){let tt;return o.expiry!=null&&(tt=o.expiry),o.ttl!=null&&(tt=BigInt(Date.now()+Number(o.ttl))),{value:o.value??0,expiry:tt}}function decodePeer(et,o,tt){const rt=et.toString().split("/")[2],nt=CID.parse(rt,base32$c),ot=peerIdFromCID(nt),it=tt.get(ot);if(it!=null)return it;const st=bytesToPeer(ot,o);return tt.set(ot,st),st}function mapQuery(et,o){return et==null?{}:{prefix:NAMESPACE_COMMON,filters:(et.filters??[]).map(tt=>({key:rt,value:nt})=>tt(decodePeer(rt,nt,o))),orders:(et.orders??[]).map(tt=>(rt,nt)=>tt(decodePeer(rt.key,rt.value,o),decodePeer(nt.key,nt.value,o)))}}var rn,rs,ns;class PersistentStore{constructor(o,tt={}){hr(this,rn);wt(this,"peerId");wt(this,"datastore");wt(this,"lock");wt(this,"addressFilter");this.peerId=o.peerId,this.datastore=o.datastore,this.addressFilter=tt.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 InvalidParametersError("Cannot delete self peer");await this.datastore.delete(peerIdToDatastoreKey(o))}async load(o){const tt=await this.datastore.get(peerIdToDatastoreKey(o));return bytesToPeer(o,tt)}async save(o,tt){const{existingBuf:rt,existingPeer:nt}=await fr(this,rn,rs).call(this,o),ot=await toPeerPB(o,tt,"patch",{addressFilter:this.addressFilter});return fr(this,rn,ns).call(this,o,ot,rt,nt)}async patch(o,tt){const{existingBuf:rt,existingPeer:nt}=await fr(this,rn,rs).call(this,o),ot=await toPeerPB(o,tt,"patch",{addressFilter:this.addressFilter,existingPeer:nt});return fr(this,rn,ns).call(this,o,ot,rt,nt)}async merge(o,tt){const{existingBuf:rt,existingPeer:nt}=await fr(this,rn,rs).call(this,o),ot=await toPeerPB(o,tt,"merge",{addressFilter:this.addressFilter,existingPeer:nt});return fr(this,rn,ns).call(this,o,ot,rt,nt)}async*all(o){const tt=new PeerMap;for await(const{key:rt,value:nt}of this.datastore.query(mapQuery(o??{},tt))){const ot=decodePeer(rt,nt,tt);ot.id.equals(this.peerId)||(yield ot)}}}rn=new WeakSet,rs=async function(o){try{const tt=await this.datastore.get(peerIdToDatastoreKey(o)),rt=bytesToPeer(o,tt);return{existingBuf:tt,existingPeer:rt}}catch(tt){if(tt.name!=="NotFoundError")throw tt}return{}},ns=async function(o,tt,rt,nt){const ot=Peer.encode(tt);return rt!=null&&equals(ot,rt)?{peer:bytesToPeer(o,ot),previous:nt,updated:!1}:(await this.datastore.put(peerIdToDatastoreKey(o),ot),{peer:bytesToPeer(o,ot),previous:nt,updated:!0})};var Ul,no,os;Ul=Symbol.toStringTag;class PersistentPeerStore{constructor(o,tt={}){hr(this,no);wt(this,"store");wt(this,"events");wt(this,"peerId");wt(this,"log");wt(this,Ul,"@libp2p/peer-store");this.log=o.logger.forComponent("libp2p:peer-store"),this.events=o.events,this.peerId=o.peerId,this.store=new PersistentStore(o,tt)}async forEach(o,tt){this.log.trace("forEach await read lock");const rt=await this.store.lock.readLock();this.log.trace("forEach got read lock");try{for await(const nt of this.store.all(tt))o(nt)}finally{this.log.trace("forEach release read lock"),rt()}}async all(o){this.log.trace("all await read lock");const tt=await this.store.lock.readLock();this.log.trace("all got read lock");try{return await all$2(this.store.all(o))}finally{this.log.trace("all release read lock"),tt()}}async delete(o){this.log.trace("delete await write lock");const tt=await this.store.lock.writeLock();this.log.trace("delete got write lock");try{await this.store.delete(o)}finally{this.log.trace("delete release write lock"),tt()}}async has(o){this.log.trace("has await read lock");const tt=await this.store.lock.readLock();this.log.trace("has got read lock");try{return await this.store.has(o)}finally{this.log.trace("has release read lock"),tt()}}async get(o){this.log.trace("get await read lock");const tt=await this.store.lock.readLock();this.log.trace("get got read lock");try{return await this.store.load(o)}finally{this.log.trace("get release read lock"),tt()}}async save(o,tt){this.log.trace("save await write lock");const rt=await this.store.lock.writeLock();this.log.trace("save got write lock");try{const nt=await this.store.save(o,tt);return fr(this,no,os).call(this,o,nt),nt.peer}finally{this.log.trace("save release write lock"),rt()}}async patch(o,tt){this.log.trace("patch await write lock");const rt=await this.store.lock.writeLock();this.log.trace("patch got write lock");try{const nt=await this.store.patch(o,tt);return fr(this,no,os).call(this,o,nt),nt.peer}finally{this.log.trace("patch release write lock"),rt()}}async merge(o,tt){this.log.trace("merge await write lock");const rt=await this.store.lock.writeLock();this.log.trace("merge got write lock");try{const nt=await this.store.merge(o,tt);return fr(this,no,os).call(this,o,nt),nt.peer}finally{this.log.trace("merge release write lock"),rt()}}async consumePeerRecord(o,tt){const rt=await RecordEnvelope.openAndCertify(o,PeerRecord.DOMAIN),nt=peerIdFromCID(rt.publicKey.toCID());if((tt==null?void 0:tt.equals(nt))===!1)return this.log("envelope peer id was not the expected peer id - expected: %p received: %p",tt,nt),!1;const ot=PeerRecord.createFromProtobuf(rt.payload);let it;try{it=await this.get(nt)}catch(st){if(st.name!=="NotFoundError")throw st}if((it==null?void 0:it.peerRecordEnvelope)!=null){const st=await RecordEnvelope.createFromProtobuf(it.peerRecordEnvelope),at=PeerRecord.createFromProtobuf(st.payload);if(at.seqNumber>=ot.seqNumber)return this.log("sequence number was lower or equal to existing sequence number - stored: %d received: %d",at.seqNumber,ot.seqNumber),!1}return await this.patch(ot.peerId,{peerRecordEnvelope:o,addresses:ot.multiaddrs.map(st=>({isCertified:!0,multiaddr:st}))}),!0}}no=new WeakSet,os=function(o,tt){tt.updated&&(this.peerId.equals(o)?this.events.safeDispatchEvent("self:peer:update",{detail:tt}):this.events.safeDispatchEvent("peer:update",{detail:tt}))};function persistentPeerStore(et,o={}){return new PersistentPeerStore(et,o)}const Ln=class Ln extends Error{constructor(tt="Not Found"){super(tt);wt(this,"name",Ln.name);wt(this,"code",Ln.code)}};wt(Ln,"name","NotFoundError"),wt(Ln,"code","ERR_NOT_FOUND");let NotFoundError=Ln;function peekable(et){const[o,tt]=et[Symbol.asyncIterator]!=null?[et[Symbol.asyncIterator](),Symbol.asyncIterator]:[et[Symbol.iterator](),Symbol.iterator],rt=[];return{peek:()=>o.next(),push:nt=>{rt.push(nt)},next:()=>rt.length>0?{done:!1,value:rt.shift()}:o.next(),[tt](){return this}}}function isAsyncIterable$2(et){return et[Symbol.asyncIterator]!=null}function filter(et,o){let tt=0;if(isAsyncIterable$2(et))return async function*(){for await(const at of et)await o(at,tt++)&&(yield at)}();const rt=peekable(et),{value:nt,done:ot}=rt.next();if(ot===!0)return function*(){}();const it=o(nt,tt++);if(typeof it.then=="function")return async function*(){await it&&(yield nt);for await(const at of rt)await o(at,tt++)&&(yield at)}();const st=o;return function*(){it===!0&&(yield nt);for(const at of rt)st(at,tt++)&&(yield at)}()}function isAsyncIterable$1(et){return et[Symbol.asyncIterator]!=null}function sort(et,o){return isAsyncIterable$1(et)?async function*(){yield*(await all$2(et)).sort(o)}():function*(){yield*all$2(et).sort(o)}()}function isAsyncIterable(et){return et[Symbol.asyncIterator]!=null}function take(et,o){return isAsyncIterable(et)?async function*(){let tt=0;if(!(o<1)){for await(const rt of et)if(yield rt,tt++,tt===o)return}}():function*(){let tt=0;if(!(o<1)){for(const rt of et)if(yield rt,tt++,tt===o)return}}()}class BaseDatastore{put(o,tt,rt){return Promise.reject(new Error(".put is not implemented"))}get(o,tt){return Promise.reject(new Error(".get is not implemented"))}has(o,tt){return Promise.reject(new Error(".has is not implemented"))}delete(o,tt){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(o,tt={}){for await(const{key:rt,value:nt}of o)await this.put(rt,nt,tt),yield rt}async*getMany(o,tt={}){for await(const rt of o)yield{key:rt,value:await this.get(rt,tt)}}async*deleteMany(o,tt={}){for await(const rt of o)await this.delete(rt,tt),yield rt}batch(){let o=[],tt=[];return{put(rt,nt){o.push({key:rt,value:nt})},delete(rt){tt.push(rt)},commit:async rt=>{await drain(this.putMany(o,rt)),o=[],await drain(this.deleteMany(tt,rt)),tt=[]}}}async*_all(o,tt){throw new Error("._all is not implemented")}async*_allKeys(o,tt){throw new Error("._allKeys is not implemented")}query(o,tt){let rt=this._all(o,tt);if(o.prefix!=null){const nt=o.prefix;rt=filter(rt,ot=>ot.key.toString().startsWith(nt))}if(Array.isArray(o.filters)&&(rt=o.filters.reduce((nt,ot)=>filter(nt,ot),rt)),Array.isArray(o.orders)&&(rt=o.orders.reduce((nt,ot)=>sort(nt,ot),rt)),o.offset!=null){let nt=0;const ot=o.offset;rt=filter(rt,()=>nt++>=ot)}return o.limit!=null&&(rt=take(rt,o.limit)),rt}queryKeys(o,tt){let rt=this._allKeys(o,tt);if(o.prefix!=null){const nt=o.prefix;rt=filter(rt,ot=>ot.toString().startsWith(nt))}if(Array.isArray(o.filters)&&(rt=o.filters.reduce((nt,ot)=>filter(nt,ot),rt)),Array.isArray(o.orders)&&(rt=o.orders.reduce((nt,ot)=>sort(nt,ot),rt)),o.offset!=null){const nt=o.offset;let ot=0;rt=filter(rt,()=>ot++>=nt)}return o.limit!=null&&(rt=take(rt,o.limit)),rt}}class MemoryDatastore extends BaseDatastore{constructor(){super();wt(this,"data");this.data=new Map}put(tt,rt){return this.data.set(tt.toString(),rt),tt}get(tt){const rt=this.data.get(tt.toString());if(rt==null)throw new NotFoundError;return rt}has(tt){return this.data.has(tt.toString())}delete(tt){this.data.delete(tt.toString())}*_all(){for(const[tt,rt]of this.data.entries())yield{key:new Key(tt),value:rt}}*_allKeys(){for(const tt of this.data.keys())yield new Key(tt)}}function allocUnsafe$2(et=0){return new Uint8Array(et)}function asUint8Array(et){return et}function concat(et,o){o==null&&(o=et.reduce((nt,ot)=>nt+ot.length,0));const tt=allocUnsafe$2(o);let rt=0;for(const nt of et)tt.set(nt,rt),rt+=nt.length;return tt}function coerce$4(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$7(et){return new TextEncoder().encode(et)}function toString$b(et){return new TextDecoder().decode(et)}function base$3(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$4=base$3,_brrp__multiformats_scope_baseX$3=src$4;let Encoder$3=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$3=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$3(this,o)}},ComposedDecoder$3=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$3(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$3(et,o){return new ComposedDecoder$3({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$3=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$3(o,tt,rt),this.decoder=new Decoder$3(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$4({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$3(et,o,tt,rt)}function baseX$3({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$3(tt,et);return from$4({prefix:o,name:et,encode:rt,decode:ot=>coerce$4(nt(ot))})}function decode$c(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$b(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$3=alphabet$3.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$a(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$3[tt],o),"")}function decode$b(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$3[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$6=from$4({prefix:"🚀",name:"base256emoji",encode:encode$a,decode:decode$b}),base256emoji$7=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$6},Symbol.toStringTag,{value:"Module"})),base32$8=rfc4648$3({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$3=rfc4648$3({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$3=rfc4648$3({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$3=rfc4648$3({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$3=rfc4648$3({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$3=rfc4648$3({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$3=rfc4648$3({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$3=rfc4648$3({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$3=rfc4648$3({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$9=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$8,base32hex:base32hex$3,base32hexpad:base32hexpad$3,base32hexpadupper:base32hexpadupper$3,base32hexupper:base32hexupper$3,base32pad:base32pad$3,base32padupper:base32padupper$3,base32upper:base32upper$3,base32z:base32z$3},Symbol.toStringTag,{value:"Module"})),base36$6=baseX$3({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$3=baseX$3({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$7=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$6,base36upper:base36upper$3},Symbol.toStringTag,{value:"Module"})),base58btc$3=baseX$3({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$3=baseX$3({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$3=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$3,base58flickr:base58flickr$3},Symbol.toStringTag,{value:"Module"})),base64$8=rfc4648$3({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$3=rfc4648$3({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$3=rfc4648$3({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$3=rfc4648$3({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$9=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$8,base64pad:base64pad$3,base64url:base64url$3,base64urlpad:base64urlpad$3},Symbol.toStringTag,{value:"Module"})),base8$6=rfc4648$3({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$7=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$6},Symbol.toStringTag,{value:"Module"})),identity$3=from$4({prefix:"\0",name:"identity",encode:et=>toString$b(et),decode:et=>fromString$7(et)}),identityBase$3=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$3},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$3={...identityBase$3,...base2$7,...base8$7,...base10$7,...base16$7,...base32$9,...base36$7,...base58$3,...base64$9,...base256emoji$7};function createCodec$3(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$6=createCodec$3("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$3=createCodec$3("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$2(et.length);for(let tt=0;ttet;function stripPeerId(et,o){const tt=et.getPeerId();return tt!=null&&peerIdFromString$1(tt).equals(o)&&(et=et.decapsulate(multiaddr(`/p2p/${o.toString()}`))),et}var zl;zl=Symbol.toStringTag;class DefaultAddressManager{constructor(o,tt={}){wt(this,"log");wt(this,"components");wt(this,"listen");wt(this,"announce");wt(this,"observed");wt(this,"announceFilter");wt(this,zl,"@libp2p/address-manager");const{listen:rt=[],announce:nt=[]}=tt;this.components=o,this.log=o.logger.forComponent("libp2p:address-manager"),this.listen=rt.map(ot=>ot.toString()),this.announce=new Set(nt.map(ot=>ot.toString())),this.observed=new Map,this.announceFilter=tt.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(){const o=this.getAnnounceAddrs().concat(this.components.transportManager.getAddrs()).concat([...this.observed.entries()].filter(([tt,rt])=>rt.confident).map(([tt])=>multiaddr(tt))).map(tt=>tt.getPeerId()===this.components.peerId.toString()?tt.decapsulate(`/p2p/${this.components.peerId.toString()}`):tt);this.components.peerStore.patch(this.components.peerId,{multiaddrs:o}).catch(tt=>{this.log.error("error updating addresses",tt)})}getListenAddrs(){return Array.from(this.listen).map(o=>multiaddr(o))}getAnnounceAddrs(){return Array.from(this.announce).map(o=>multiaddr(o))}getObservedAddrs(){return Array.from(this.observed).map(([o])=>multiaddr(o))}addObservedAddr(o){o=stripPeerId(o,this.components.peerId);const tt=o.toString();this.observed.has(tt)||this.observed.set(tt,{confident:!1})}confirmObservedAddr(o){o=stripPeerId(o,this.components.peerId);const tt=o.toString(),nt=(this.observed.get(tt)??{confident:!1}).confident;this.observed.set(tt,{confident:!0}),nt||this._updatePeerStoreAddresses()}removeObservedAddr(o){o=stripPeerId(o,this.components.peerId);const tt=o.toString();this.observed.delete(tt)}getAddresses(){let o=this.getAnnounceAddrs().map(rt=>rt.toString());o.length===0&&(o=this.components.transportManager.getAddrs().map(rt=>rt.toString())),o=o.concat(Array.from(this.observed).filter(([rt,nt])=>nt.confident).map(([rt])=>rt));const tt=new Set(o);return this.announceFilter(Array.from(tt).map(rt=>multiaddr(rt))).map(rt=>{var nt;return((nt=rt.protos().pop())==null?void 0:nt.path)===!0||rt.getPeerId()===this.components.peerId.toString()?rt:rt.encapsulate(`/p2p/${this.components.peerId.toString()}`)})}}var messages;(function(et){et.NOT_STARTED_YET="The libp2p node is not started yet",et.NOT_FOUND="Not found"})(messages||(messages={}));class MissingServiceError extends Error{constructor(o="Missing service"){super(o),this.name="MissingServiceError"}}class UnmetServiceDependenciesError extends Error{constructor(o="Unmet service dependencies"){super(o),this.name="UnmetServiceDependenciesError"}}class NoContentRoutersError extends Error{constructor(o="No content routers available"){super(o),this.name="NoContentRoutersError"}}class NoPeerRoutersError extends Error{constructor(o="No peer routers available"){super(o),this.name="NoPeerRoutersError"}}class QueriedForSelfError extends Error{constructor(o="Should not try to find self"){super(o),this.name="QueriedForSelfError"}}class UnhandledProtocolError extends Error{constructor(o="Unhandled protocol error"){super(o),this.name="UnhandledProtocolError"}}class DuplicateProtocolHandlerError extends Error{constructor(o="Duplicate protocol handler error"){super(o),this.name="DuplicateProtocolHandlerError"}}class DialDeniedError extends Error{constructor(o="Dial denied error"){super(o),this.name="DialDeniedError"}}class NoValidAddressesError extends Error{constructor(o="No valid addresses"){super(o),this.name="NoValidAddressesError"}}class ConnectionInterceptedError extends Error{constructor(o="Connection intercepted"){super(o),this.name="ConnectionInterceptedError"}}class ConnectionDeniedError extends Error{constructor(o="Connection denied"){super(o),this.name="ConnectionDeniedError"}}class MuxerUnavailableError extends Error{constructor(o="Stream is not multiplexed"){super(o),this.name="MuxerUnavailableError"}}class EncryptionFailedError extends Error{constructor(o="Encryption failed"){super(o),this.name="EncryptionFailedError"}}class TransportUnavailableError extends Error{constructor(o="Transport unavailable"){super(o),this.name="TransportUnavailableError"}}class DefaultComponents{constructor(o={}){wt(this,"components",{});wt(this,"_started",!1);this.components={};for(const[tt,rt]of Object.entries(o))this.components[tt]=rt;this.components.logger==null&&(this.components.logger=defaultLogger())}isStarted(){return this._started}async _invokeStartableMethod(o){await Promise.all(Object.values(this.components).filter(tt=>isStartable(tt)).map(async tt=>{var rt;await((rt=tt[o])==null?void 0:rt.call(tt))}))}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")}}const OPTIONAL_SERVICES=["metrics","connectionProtector","dns"],NON_SERVICE_PROPERTIES=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];function defaultComponents(et={}){const o=new DefaultComponents(et);return new Proxy(o,{get(rt,nt,ot){if(typeof nt=="string"&&!NON_SERVICE_PROPERTIES.includes(nt)){const it=o.components[nt];if(it==null&&!OPTIONAL_SERVICES.includes(nt))throw new MissingServiceError(`${nt} not set`);return it}return Reflect.get(rt,nt,ot)},set(rt,nt,ot){return typeof nt=="string"?o.components[nt]=ot:Reflect.set(rt,nt,ot),!0}})}function checkServiceDependencies(et){const o={};for(const tt of Object.values(et.components))for(const rt of getServiceCapabilities(tt))o[rt]=!0;for(const tt of Object.values(et.components))for(const rt of getServiceDependencies(tt))if(o[rt]!==!0)throw new UnmetServiceDependenciesError(`Service "${getServiceName(tt)}" required capability "${rt}" but it was not provided by any component, you may need to add additional configuration when creating your node.`)}function getServiceCapabilities(et){return Array.isArray(et==null?void 0:et[serviceCapabilities])?et[serviceCapabilities]:[]}function getServiceDependencies(et){return Array.isArray(et==null?void 0:et[serviceDependencies])?et[serviceDependencies]:[]}function getServiceName(et){return(et==null?void 0:et[Symbol.toStringTag])??(et==null?void 0:et.toString())??"unknown"}function connectionGater(et={}){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async o=>{const tt=o.stringTuples();return tt[0][0]===4||tt[0][0]===41?!!isPrivateIp(`${tt[0][1]}`):!1},denyInboundConnection:async()=>!1,denyOutboundConnection:async()=>!1,denyInboundEncryptedConnection:async()=>!1,denyOutboundEncryptedConnection:async()=>!1,denyInboundUpgradedConnection:async()=>!1,denyOutboundUpgradedConnection:async()=>!1,filterMultiaddrForPeer:async()=>!0,...et}}function getPeerAddress(et){if(isPeerId$1(et))return{peerId:et,multiaddrs:[]};Array.isArray(et)||(et=[et]);let o;if(et.length>0){const tt=et[0].getPeerId();o=tt==null?void 0:peerIdFromString$1(tt),et.forEach(rt=>{if(!isMultiaddr(rt))throw new InvalidMultiaddrError("Invalid multiaddr");const nt=rt.getPeerId();if(nt==null){if(o!=null)throw new InvalidParametersError$1("Multiaddrs must all have the same peer id or have no peer id")}else{const ot=peerIdFromString$1(nt);if((o==null?void 0:o.equals(ot))!==!0)throw new InvalidParametersError$1("Multiaddrs must all have the same peer id or have no peer id")}})}return{peerId:o,multiaddrs:et}}const DEFAULT_CLOSABLE_PROTOCOLS=["/ipfs/id/1.0.0","/ipfs/id/push/1.0.0","/libp2p/autonat/1.0.0","/libp2p/dcutr"];async function safelyCloseConnectionIfUnused(et,o){var nt;const tt=((nt=et==null?void 0:et.streams)==null?void 0:nt.map(ot=>ot.protocol))??[],rt=(o==null?void 0:o.closableProtocols)??DEFAULT_CLOSABLE_PROTOCOLS;if(!(tt.filter(ot=>ot!=null&&!rt.includes(ot)).length>0))try{await(et==null?void 0:et.close(o))}catch(ot){et==null||et.abort(ot)}}const DIAL_TIMEOUT=5e3,UPGRADE_TIMEOUT=3e3,PROTOCOL_NEGOTIATION_TIMEOUT=2e3,MAX_PEER_ADDRS_TO_DIAL=25,INBOUND_CONNECTION_THRESHOLD=5,MAX_INCOMING_PENDING_CONNECTIONS=10,MAX_PARALLEL_RECONNECTS=5,LAST_DIAL_FAILURE_KEY="last-dial-failure",LAST_DIAL_SUCCESS_KEY="last-dial-success",MAX_DIAL_QUEUE_LENGTH=500,MAX_CONNECTIONS=100,MAX_PARALLEL_DIALS=50,defaultOptions$2={maxConnections:MAX_CONNECTIONS,allow:[]};class ConnectionPruner{constructor(o,tt={}){wt(this,"maxConnections");wt(this,"connectionManager");wt(this,"peerStore");wt(this,"allow");wt(this,"events");wt(this,"log");this.maxConnections=tt.maxConnections??defaultOptions$2.maxConnections,this.allow=tt.allow??defaultOptions$2.allow,this.connectionManager=o.connectionManager,this.peerStore=o.peerStore,this.events=o.events,this.log=o.logger.forComponent("libp2p:connection-manager:connection-pruner"),this.maybePruneConnections=this.maybePruneConnections.bind(this)}start(){this.events.addEventListener("connection:open",this.maybePruneConnections)}stop(){this.events.removeEventListener("connection:open",this.maybePruneConnections)}maybePruneConnections(){this._maybePruneConnections().catch(o=>{this.log.error("error while pruning connections %e",o)})}async _maybePruneConnections(){const o=this.connectionManager.getConnections(),tt=o.length;if(this.log("checking max connections limit %d/%d",tt,this.maxConnections),tt<=this.maxConnections)return;const rt=new PeerMap;for(const st of o){const at=st.remotePeer;if(!rt.has(at)){rt.set(at,0);try{const ct=await this.peerStore.get(at);rt.set(at,[...ct.tags.values()].reduce((lt,dt)=>lt+dt.value,0))}catch(ct){ct.name!=="NotFoundError"&&this.log.error("error loading peer tags",ct)}}}const nt=this.sortConnections(o,rt),ot=Math.max(tt-this.maxConnections,0),it=[];for(const st of nt)if(this.log("too many connections open - closing a connection to %p",st.remotePeer),this.allow.some(ct=>st.remoteAddr.toString().startsWith(ct.toString()))||it.push(st),it.length===ot)break;await Promise.all(it.map(async st=>{await safelyCloseConnectionIfUnused(st,{signal:AbortSignal.timeout(1e3)})})),this.events.safeDispatchEvent("connection:prune",{detail:it})}sortConnections(o,tt){return o.sort((rt,nt)=>{const ot=rt.timeline.open,it=nt.timeline.open;return otit?-1:0}).sort((rt,nt)=>rt.direction==="outbound"&&nt.direction==="inbound"?1:rt.direction==="inbound"&&nt.direction==="outbound"?-1:0).sort((rt,nt)=>rt.streams.length>nt.streams.length?1:rt.streams.length{const ot=tt.get(rt.remotePeer)??0,it=tt.get(nt.remotePeer)??0;return ot>it?1:ot{function st(){tt==null||tt.removeEventListener("abort",lt),et.removeEventListener(o,at),(rt==null?void 0:rt.errorEvent)!=null&&et.removeEventListener(rt.errorEvent,ct)}const at=dt=>{var ht;try{if(((ht=rt==null?void 0:rt.filter)==null?void 0:ht.call(rt,dt))===!1)return}catch(mt){st(),it(mt);return}st(),ot(dt)},ct=dt=>{st(),it(dt.detail)},lt=()=>{st(),it(nt)};tt==null||tt.addEventListener("abort",lt),et.addEventListener(o,at),(rt==null?void 0:rt.errorEvent)!=null&&et.addEventListener(rt.errorEvent,ct)})}class JobRecipient{constructor(o){wt(this,"deferred");wt(this,"signal");var tt;this.signal=o,this.deferred=pDefer(),this.onAbort=this.onAbort.bind(this),(tt=this.signal)==null||tt.addEventListener("abort",this.onAbort)}onAbort(){var o;this.deferred.reject(((o=this.signal)==null?void 0:o.reason)??new AbortError$6)}cleanup(){var o;(o=this.signal)==null||o.removeEventListener("abort",this.onAbort)}}function randomId(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}class Job{constructor(o,tt){wt(this,"id");wt(this,"fn");wt(this,"options");wt(this,"recipients");wt(this,"status");wt(this,"timeline");wt(this,"controller");this.id=randomId(),this.status="queued",this.fn=o,this.options=tt,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,setMaxListeners$2(1/0,this.controller.signal),this.onAbort=this.onAbort.bind(this)}abort(o){this.controller.abort(o)}onAbort(){this.recipients.reduce((tt,rt)=>{var nt;return tt&&((nt=rt.signal)==null?void 0:nt.aborted)===!0},!0)&&(this.controller.abort(new AbortError$6),this.cleanup())}async join(o={}){var rt;const tt=new JobRecipient(o.signal);return this.recipients.push(tt),(rt=o.signal)==null||rt.addEventListener("abort",this.onAbort),tt.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();const o=await raceSignal(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(tt=>{tt.deferred.resolve(o)}),this.status="complete"}catch(o){this.recipients.forEach(tt=>{tt.deferred.reject(o)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(o=>{var tt;o.cleanup(),(tt=o.signal)==null||tt.removeEventListener("abort",this.onAbort)})}}class Queue extends TypedEventEmitter$1{constructor(tt={}){var rt;super();wt(this,"concurrency");wt(this,"maxSize");wt(this,"queue");wt(this,"pending");wt(this,"sort");this.concurrency=tt.concurrency??Number.POSITIVE_INFINITY,this.maxSize=tt.maxSize??Number.POSITIVE_INFINITY,this.pending=0,tt.metricName!=null&&((rt=tt.metrics)==null||rt.registerMetricGroup(tt.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})})),this.sort=tt.sort,this.queue=[]}tryToStartAnother(){if(this.size===0)return queueMicrotask(()=>{this.safeDispatchEvent("empty")}),this.running===0&&queueMicrotask(()=>{this.safeDispatchEvent("idle")}),!1;if(this.pending{for(let rt=0;rt(this.safeDispatchEvent("completed",{detail:it}),this.safeDispatchEvent("success",{detail:{job:nt,result:it}}),it)).catch(it=>{if(nt.status==="queued"){for(let st=0;st{tt.abort(new AbortError$6)}),this.clear()}async onEmpty(tt){this.size!==0&&await raceEvent(this,"empty",tt==null?void 0:tt.signal)}async onSizeLessThan(tt,rt){this.sizethis.size{ht!=null?this.abort():this.clear(),rt.end(ht)},ot=ht=>{ht.detail!=null&&rt.push(ht.detail)},it=ht=>{nt(ht.detail)},st=()=>{nt()},at=()=>{nt(new AbortError$6("Queue aborted"))};this.addEventListener("completed",ot),this.addEventListener("error",it),this.addEventListener("idle",st),(lt=tt==null?void 0:tt.signal)==null||lt.addEventListener("abort",at);try{yield*rt}finally{this.removeEventListener("completed",ot),this.removeEventListener("error",it),this.removeEventListener("idle",st),(dt=tt==null?void 0:tt.signal)==null||dt.removeEventListener("abort",at),nt()}}}class PriorityQueue extends Queue{constructor(o={}){super({...o,sort:(tt,rt)=>tt.options.priority>rt.options.priority?-1:tt.options.prioritynt.toString())),rt}const defaultOptions$1={maxParallelDials:MAX_PARALLEL_DIALS,maxDialQueueLength:MAX_DIAL_QUEUE_LENGTH,maxPeerAddrsToDial:MAX_PEER_ADDRS_TO_DIAL,dialTimeout:DIAL_TIMEOUT,resolvers:{dnsaddr:dnsaddrResolver}};class DialQueue{constructor(o,tt={}){wt(this,"queue");wt(this,"components");wt(this,"addressSorter");wt(this,"maxPeerAddrsToDial");wt(this,"maxDialQueueLength");wt(this,"dialTimeout");wt(this,"shutDownController");wt(this,"connections");wt(this,"log");this.addressSorter=tt.addressSorter,this.maxPeerAddrsToDial=tt.maxPeerAddrsToDial??defaultOptions$1.maxPeerAddrsToDial,this.maxDialQueueLength=tt.maxDialQueueLength??defaultOptions$1.maxDialQueueLength,this.dialTimeout=tt.dialTimeout??defaultOptions$1.dialTimeout,this.connections=tt.connections??new PeerMap,this.log=o.logger.forComponent("libp2p:connection-manager:dial-queue"),this.components=o,this.shutDownController=new AbortController,setMaxListeners(1/0,this.shutDownController.signal);for(const[rt,nt]of Object.entries(tt.resolvers??{}))resolvers$1.set(rt,nt);this.queue=new PriorityQueue({concurrency:tt.maxParallelDials??defaultOptions$1.maxParallelDials,metricName:"libp2p_dial_queue",metrics:o.metrics}),this.queue.addEventListener("error",rt=>{rt.detail.name!==AbortError$4.name&&this.log.error("error in dial queue - %e",rt.detail)})}start(){this.shutDownController=new AbortController,setMaxListeners(1/0,this.shutDownController.signal)}stop(){this.shutDownController.abort(),this.queue.abort()}async dial(o,tt={}){var st,at,ct;const{peerId:rt,multiaddrs:nt}=getPeerAddress(o),ot=Array.from(this.connections.values()).flat().find(lt=>tt.force===!0?!1:lt.remotePeer.equals(rt)?!0:nt.find(dt=>dt.equals(lt.remoteAddr)));if((ot==null?void 0:ot.status)==="open")return this.log("already connected to %a",ot.remoteAddr),(st=tt.onProgress)==null||st.call(tt,new CustomProgressEvent("dial-queue:already-connected")),ot;const it=this.queue.queue.find(lt=>{if((rt==null?void 0:rt.equals(lt.options.peerId))===!0)return!0;const dt=lt.options.multiaddrs;if(dt==null)return!1;for(const ht of nt)if(dt.has(ht.toString()))return!0;return!1});if(it!=null){this.log("joining existing dial target for %p",rt);for(const lt of nt)it.options.multiaddrs.add(lt.toString());return(at=tt.onProgress)==null||at.call(tt,new CustomProgressEvent("dial-queue:already-in-dial-queue")),it.join(tt)}if(this.queue.size>=this.maxDialQueueLength)throw new DialError("Dial queue is full");return this.log("creating dial target for %p",rt,nt.map(lt=>lt.toString())),(ct=tt.onProgress)==null||ct.call(tt,new CustomProgressEvent("dial-queue:add-to-dial-queue")),this.queue.add(async lt=>{var mt,ft;(mt=lt==null?void 0:lt.onProgress)==null||mt.call(lt,new CustomProgressEvent("dial-queue:start-dial"));const dt=this.createDialAbortController(lt==null?void 0:lt.signal);let ht;try{ht=await this.calculateMultiaddrs(rt,lt==null?void 0:lt.multiaddrs,{...lt,signal:dt}),(ft=lt==null?void 0:lt.onProgress)==null||ft.call(lt,new CustomProgressEvent("dial-queue:calculated-addresses",ht)),ht.map(({multiaddr:pt})=>pt.toString()).forEach(pt=>{lt==null||lt.multiaddrs.add(pt)})}catch(pt){throw dt.clear(),pt}try{let pt=0;const gt=[];for(const yt of ht){if(pt===this.maxPeerAddrsToDial)throw this.log("dialed maxPeerAddrsToDial (%d) addresses for %p, not trying any others",pt,rt),new DialError("Peer had more than maxPeerAddrsToDial");pt++;try{const bt=await this.components.transportManager.dial(yt.multiaddr,{...lt,signal:dt});this.log("dial to %a succeeded",yt.multiaddr);try{await this.components.peerStore.merge(bt.remotePeer,{multiaddrs:[bt.remoteAddr],metadata:{[LAST_DIAL_SUCCESS_KEY]:fromString$6(Date.now().toString())}})}catch(xt){this.log.error("could not update last dial failure key for %p",rt,xt)}return bt}catch(bt){if(this.log.error("dial failed to %a",yt.multiaddr,bt),rt!=null)try{await this.components.peerStore.merge(rt,{metadata:{[LAST_DIAL_FAILURE_KEY]:fromString$6(Date.now().toString())}})}catch(xt){this.log.error("could not update last dial failure key for %p",rt,xt)}if(dt.aborted)throw new TimeoutError$2(bt.message);gt.push(bt)}}throw gt.length===1?gt[0]:new AggregateError(gt,"All multiaddr dials failed")}finally{dt.clear()}},{peerId:rt,priority:tt.priority??DEFAULT_DIAL_PRIORITY,multiaddrs:new Set(nt.map(lt=>lt.toString())),signal:tt.signal,onProgress:tt.onProgress})}createDialAbortController(o){const tt=anySignal([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,o]);return setMaxListeners(1/0,tt),tt}async calculateMultiaddrs(o,tt=new Set,rt={}){var dt,ht;const nt=[...tt].map(mt=>({multiaddr:multiaddr(mt),isCertified:!1}));if(o!=null){if(this.components.peerId.equals(o))throw new DialError("Tried to dial self");if(await((ht=(dt=this.components.connectionGater).denyDialPeer)==null?void 0:ht.call(dt,o))===!0)throw new DialDeniedError("The dial request is blocked by gater.allowDialPeer");if(nt.length===0){this.log("loading multiaddrs for %p",o);try{const mt=await this.components.peerStore.get(o);nt.push(...mt.addresses),this.log("loaded multiaddrs for %p",o,nt.map(({multiaddr:ft})=>ft.toString()))}catch(mt){if(mt.name!=="NotFoundError")throw mt}}if(nt.length===0){this.log("looking up multiaddrs for %p in the peer routing",o);try{const mt=await this.components.peerRouting.findPeer(o);this.log("found multiaddrs for %p in the peer routing",o,nt.map(({multiaddr:ft})=>ft.toString())),nt.push(...mt.multiaddrs.map(ft=>({multiaddr:ft,isCertified:!1})))}catch(mt){mt.name!=="NoPeerRoutersError"&&this.log.error("looking up multiaddrs for %p in the peer routing failed",o,mt)}}}let ot=(await Promise.all(nt.map(async mt=>{const ft=await resolveMultiaddrs(mt.multiaddr,{dns:this.components.dns,...rt,log:this.log});return ft.length===1&&ft[0].equals(mt.multiaddr)?mt:ft.map(pt=>({multiaddr:pt,isCertified:!1}))}))).flat();if(o!=null){const mt=`/p2p/${o.toString()}`;ot=ot.map(ft=>{const pt=ft.multiaddr.protos().pop();return(pt==null?void 0:pt.path)===!0?ft:ft.multiaddr.getPeerId()==null?{multiaddr:ft.multiaddr.encapsulate(mt),isCertified:ft.isCertified}:ft})}const it=ot.filter(mt=>{if(this.components.transportManager.dialTransportForMultiaddr(mt.multiaddr)==null)return!1;const ft=mt.multiaddr.getPeerId();return o!=null&&ft!=null?o.equals(ft):!0}),st=new Map;for(const mt of it){const ft=mt.multiaddr.toString(),pt=st.get(ft);if(pt!=null){pt.isCertified=pt.isCertified||mt.isCertified||!1;continue}st.set(ft,mt)}const at=[...st.values()];if(at.length===0)throw new NoValidAddressesError("The dial request has no valid addresses");const ct=[];for(const mt of at)this.components.connectionGater.denyDialMultiaddr!=null&&await this.components.connectionGater.denyDialMultiaddr(mt.multiaddr)||ct.push(mt);const lt=this.addressSorter==null?defaultAddressSorter(ct):ct.sort(this.addressSorter);if(lt.length===0)throw new DialDeniedError("The connection gater denied all addresses in the dial request");return this.log.trace("addresses for %p before filtering",o??"unknown peer",ot.map(({multiaddr:mt})=>mt.toString())),this.log.trace("addresses for %p after filtering",o??"unknown peer",lt.map(({multiaddr:mt})=>mt.toString())),lt}async isDialable(o,tt={}){Array.isArray(o)||(o=[o]);try{const rt=await this.calculateMultiaddrs(void 0,new Set(o.map(nt=>nt.toString())),tt);return tt.runOnLimitedConnection===!1?rt.find(nt=>!Circuit.matches(nt.multiaddr))!=null:!0}catch(rt){this.log.trace("error calculating if multiaddr(s) were dialable",rt)}return!1}}class PeerQueue extends Queue{has(o){return this.find(o)!=null}find(o){return this.queue.find(tt=>o.equals(tt.options.peerId))}}var retry$2={};function RetryOperation(et,o){typeof o=="boolean"&&(o={forever:o}),this._originalTimeouts=JSON.parse(JSON.stringify(et)),this._timeouts=et,this._options=o||{},this._maxRetryTime=o&&o.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var retry_operation=RetryOperation;RetryOperation.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};RetryOperation.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};RetryOperation.prototype.retry=function(et){if(this._timeout&&clearTimeout(this._timeout),!et)return!1;var o=new Date().getTime();if(et&&o-this._operationStart>=this._maxRetryTime)return this._errors.push(et),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(et);var tt=this._timeouts.shift();if(tt===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),tt=this._cachedTimeouts.slice(-1);else return!1;var rt=this;return this._timer=setTimeout(function(){rt._attempts++,rt._operationTimeoutCb&&(rt._timeout=setTimeout(function(){rt._operationTimeoutCb(rt._attempts)},rt._operationTimeout),rt._options.unref&&rt._timeout.unref()),rt._fn(rt._attempts)},tt),this._options.unref&&this._timer.unref(),!0};RetryOperation.prototype.attempt=function(et,o){this._fn=et,o&&(o.timeout&&(this._operationTimeout=o.timeout),o.cb&&(this._operationTimeoutCb=o.cb));var tt=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){tt._operationTimeoutCb()},tt._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};RetryOperation.prototype.try=function(et){console.log("Using RetryOperation.try() is deprecated"),this.attempt(et)};RetryOperation.prototype.start=function(et){console.log("Using RetryOperation.start() is deprecated"),this.attempt(et)};RetryOperation.prototype.start=RetryOperation.prototype.try;RetryOperation.prototype.errors=function(){return this._errors};RetryOperation.prototype.attempts=function(){return this._attempts};RetryOperation.prototype.mainError=function(){if(this._errors.length===0)return null;for(var et={},o=null,tt=0,rt=0;rt=tt&&(o=nt,tt=it)}return o};(function(et){var o=retry_operation;et.operation=function(tt){var rt=et.timeouts(tt);return new o(rt,{forever:tt&&(tt.forever||tt.retries===1/0),unref:tt&&tt.unref,maxRetryTime:tt&&tt.maxRetryTime})},et.timeouts=function(tt){if(tt instanceof Array)return[].concat(tt);var rt={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var nt in tt)rt[nt]=tt[nt];if(rt.minTimeout>rt.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var ot=[],it=0;itobjectToString.call(et)==="[object Error]",errorMessages=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Load failed","Network request failed","fetch failed","terminated"]);function isNetworkError(et){return et&&isError(et)&&et.name==="TypeError"&&typeof et.message=="string"?et.message==="Load failed"?et.stack===void 0:errorMessages.has(et.message):!1}let AbortError$1=class extends Error{constructor(o){super(),o instanceof Error?(this.originalError=o,{message:o}=o):(this.originalError=new Error(o),this.originalError.stack=this.stack),this.name="AbortError",this.message=o}};const decorateErrorWithCounts=(et,o,tt)=>{const rt=tt.retries-(o-1);return et.attemptNumber=o,et.retriesLeft=rt,et};async function pRetry(et,o){return new Promise((tt,rt)=>{o={onFailedAttempt(){},retries:10,shouldRetry:()=>!0,...o};const nt=retry$1.operation(o),ot=()=>{var st;nt.stop(),rt((st=o.signal)==null?void 0:st.reason)};o.signal&&!o.signal.aborted&&o.signal.addEventListener("abort",ot,{once:!0});const it=()=>{var st;(st=o.signal)==null||st.removeEventListener("abort",ot),nt.stop()};nt.attempt(async st=>{try{const at=await et(st);it(),tt(at)}catch(at){try{if(!(at instanceof Error))throw new TypeError(`Non-error was thrown: "${at}". You should only throw errors.`);if(at instanceof AbortError$1)throw at.originalError;if(at instanceof TypeError&&!isNetworkError(at))throw at;if(decorateErrorWithCounts(at,st,o),await o.shouldRetry(at)||(nt.stop(),rt(at)),await o.onFailedAttempt(at),!nt.retry(at))throw nt.mainError()}catch(ct){decorateErrorWithCounts(ct,st,o),it(),rt(ct)}}})})}class ReconnectQueue{constructor(o,tt={}){wt(this,"log");wt(this,"queue");wt(this,"started");wt(this,"peerStore");wt(this,"retries");wt(this,"retryInterval");wt(this,"backoffFactor");wt(this,"connectionManager");wt(this,"events");this.log=o.logger.forComponent("libp2p:reconnect-queue"),this.peerStore=o.peerStore,this.connectionManager=o.connectionManager,this.queue=new PeerQueue({concurrency:tt.maxParallelReconnects??MAX_PARALLEL_RECONNECTS,metricName:"libp2p_reconnect_queue",metrics:o.metrics}),this.started=!1,this.retries=tt.retries??5,this.backoffFactor=tt.backoffFactor,this.retryInterval=tt.retryInterval,this.events=o.events,o.events.addEventListener("peer:disconnect",rt=>{this.maybeReconnect(rt.detail).catch(nt=>{this.log.error("failed to maybe reconnect to %p - %e",rt.detail,nt)})})}async maybeReconnect(o){if(!this.started)return;const tt=await this.peerStore.get(o);hasKeepAliveTag(tt)&&(this.queue.has(o)||this.queue.add(async rt=>{await pRetry(async nt=>{if(this.started)try{await this.connectionManager.openConnection(o,{signal:rt==null?void 0:rt.signal})}catch(ot){throw this.log("reconnecting to %p attempt %d of %d failed - %e",o,nt,this.retries,ot),ot}},{signal:rt==null?void 0:rt.signal,retries:this.retries,factor:this.backoffFactor,minTimeout:this.retryInterval})},{peerId:o}).catch(async rt=>{this.log.error("failed to reconnect to %p - %e",o,rt);const nt={};[...tt.tags.keys()].forEach(ot=>{ot.startsWith(KEEP_ALIVE)&&(nt[ot]=void 0)}),await this.peerStore.merge(o,{tags:nt}),this.events.safeDispatchEvent("peer:reconnect-failure",{detail:o})}).catch(async rt=>{this.log.error("failed to remove keep-alive tag from %p - %e",o,rt)}))}start(){this.started=!0}async afterStart(){Promise.resolve().then(async()=>{const o=await this.peerStore.all({filters:[tt=>hasKeepAliveTag(tt)]});await Promise.all(o.map(async tt=>{await this.connectionManager.openConnection(tt.id).catch(rt=>{this.log.error(rt)})}))}).catch(o=>{this.log.error(o)})}stop(){this.started=!1,this.queue.abort()}}function hasKeepAliveTag(et){for(const o of et.tags.keys())if(o.startsWith(KEEP_ALIVE))return!0;return!1}const DEFAULT_DIAL_PRIORITY=50,defaultOptions={maxConnections:MAX_CONNECTIONS,inboundConnectionThreshold:INBOUND_CONNECTION_THRESHOLD,maxIncomingPendingConnections:MAX_INCOMING_PENDING_CONNECTIONS};var Vl;Vl=Symbol.toStringTag;class DefaultConnectionManager{constructor(o,tt={}){wt(this,"started");wt(this,"connections");wt(this,"allow");wt(this,"deny");wt(this,"maxIncomingPendingConnections");wt(this,"incomingPendingConnections");wt(this,"outboundPendingConnections");wt(this,"maxConnections");wt(this,"dialQueue");wt(this,"reconnectQueue");wt(this,"connectionPruner");wt(this,"inboundConnectionRateLimiter");wt(this,"peerStore");wt(this,"metrics");wt(this,"events");wt(this,"log");wt(this,"peerId");wt(this,Vl,"@libp2p/connection-manager");if(this.maxConnections=tt.maxConnections??defaultOptions.maxConnections,this.maxConnections<1)throw new InvalidParametersError$1("Connection Manager maxConnections must be greater than 0");this.connections=new PeerMap,this.started=!1,this.peerId=o.peerId,this.peerStore=o.peerStore,this.metrics=o.metrics,this.events=o.events,this.log=o.logger.forComponent("libp2p:connection-manager"),this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.allow=(tt.allow??[]).map(rt=>multiaddr(rt)),this.deny=(tt.deny??[]).map(rt=>multiaddr(rt)),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=tt.maxIncomingPendingConnections??defaultOptions.maxIncomingPendingConnections,this.outboundPendingConnections=0,this.inboundConnectionRateLimiter=new RateLimiter({points:tt.inboundConnectionThreshold??defaultOptions.inboundConnectionThreshold,duration:1}),this.connectionPruner=new ConnectionPruner({connectionManager:this,peerStore:o.peerStore,events:o.events,logger:o.logger},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new DialQueue(o,{addressSorter:tt.addressSorter,maxParallelDials:tt.maxParallelDials??MAX_PARALLEL_DIALS,maxDialQueueLength:tt.maxDialQueueLength??MAX_DIAL_QUEUE_LENGTH,maxPeerAddrsToDial:tt.maxPeerAddrsToDial??MAX_PEER_ADDRS_TO_DIAL,dialTimeout:tt.dialTimeout??DIAL_TIMEOUT,resolvers:tt.resolvers??{dnsaddr:dnsaddrResolver},connections:this.connections}),this.reconnectQueue=new ReconnectQueue({events:o.events,peerStore:o.peerStore,logger:o.logger,connectionManager:this},{retries:tt.reconnectRetries,retryInterval:tt.reconnectRetryInterval,backoffFactor:tt.reconnectBackoffFactor,maxParallelReconnects:tt.maxParallelReconnects})}async start(){var o,tt,rt;(o=this.metrics)==null||o.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{const nt={inbound:0,"inbound pending":this.incomingPendingConnections,outbound:0,"outbound pending":this.outboundPendingConnections};for(const ot of this.connections.values())for(const it of ot)nt[it.direction]++;return nt}}),(tt=this.metrics)==null||tt.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{const nt={};for(const ot of this.connections.values())for(const it of ot)for(const st of it.streams){const at=`${st.direction} ${st.protocol??"unnegotiated"}`;nt[at]=(nt[at]??0)+1}return nt}}),(rt=this.metrics)==null||rt.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{const nt={};for(const it of this.connections.values())for(const st of it){const at={};for(const ct of st.streams){const lt=`${ct.direction} ${ct.protocol??"unnegotiated"}`;at[lt]=(at[lt]??0)+1}for(const[ct,lt]of Object.entries(at))nt[ct]=nt[ct]??[],nt[ct].push(lt)}const ot={};for(let[it,st]of Object.entries(nt)){st=st.sort((ct,lt)=>ct-lt);const at=Math.floor(st.length*.9);ot[it]=st[at]}return ot}}),this.events.addEventListener("connection:open",this.onConnect),this.events.addEventListener("connection:close",this.onDisconnect),await start(this.dialQueue,this.reconnectQueue,this.connectionPruner),this.started=!0,this.log("started")}async stop(){this.events.removeEventListener("connection:open",this.onConnect),this.events.removeEventListener("connection:close",this.onDisconnect),await stop(this.reconnectQueue,this.dialQueue,this.connectionPruner);const o=[];for(const tt of this.connections.values())for(const rt of tt)o.push((async()=>{try{await rt.close()}catch(nt){this.log.error(nt)}})());this.log("closing %d connections",o.length),await Promise.all(o),this.connections.clear(),this.log("stopped")}onConnect(o){this._onConnect(o).catch(tt=>{this.log.error(tt)})}async _onConnect(o){const{detail:tt}=o;if(!this.started){await tt.close();return}if(tt.status!=="open")return;const rt=tt.remotePeer,nt=!this.connections.has(rt),ot=this.connections.get(rt)??[];ot.push(tt),this.connections.set(rt,ot),rt.publicKey!=null&&rt.type==="RSA"&&await this.peerStore.patch(rt,{publicKey:rt.publicKey}),nt&&this.events.safeDispatchEvent("peer:connect",{detail:tt.remotePeer})}onDisconnect(o){const{detail:tt}=o,rt=tt.remotePeer,ot=(this.connections.get(rt)??[]).filter(it=>it.id!==tt.id);this.connections.set(rt,ot),ot.length===0&&(this.log("onDisconnect remove all connections for peer %p",rt),this.connections.delete(rt),this.events.safeDispatchEvent("peer:disconnect",{detail:tt.remotePeer}))}getConnections(o){if(o!=null)return this.connections.get(o)??[];let tt=[];for(const rt of this.connections.values())tt=tt.concat(rt);return tt}getConnectionsMap(){return this.connections}async openConnection(o,tt={}){var rt,nt;if(!this.started)throw new NotStartedError("Not started");this.outboundPendingConnections++;try{(rt=tt.signal)==null||rt.throwIfAborted();const{peerId:ot}=getPeerAddress(o);if(this.peerId.equals(ot))throw new InvalidPeerIdError("Can not dial self");if(ot!=null&&tt.force!==!0){this.log("dial %p",ot);const ct=this.getConnections(ot).find(lt=>lt.limits==null);if(ct!=null)return this.log("had an existing non-limited connection to %p",ot),(nt=tt.onProgress)==null||nt.call(tt,new CustomProgressEvent("dial-queue:already-connected")),ct}const it=await this.dialQueue.dial(o,{...tt,priority:tt.priority??DEFAULT_DIAL_PRIORITY});if(it.status!=="open")throw new ConnectionClosedError("Remote closed connection during opening");let st=this.connections.get(it.remotePeer);st==null&&(st=[],this.connections.set(it.remotePeer,st));let at=!1;for(const ct of st)if(ct.id===it.id&&(at=!0),tt.force!==!0&&ct.id!==it.id&&ct.remoteAddr.equals(it.remoteAddr))return it.abort(new InvalidMultiaddrError("Duplicate multiaddr connection")),ct;return at||st.push(it),it}finally{this.outboundPendingConnections--}}async closeConnections(o,tt={}){const rt=this.connections.get(o)??[];await Promise.all(rt.map(async nt=>{try{await nt.close(tt)}catch(ot){nt.abort(ot)}}))}async acceptIncomingConnection(o){if(this.deny.some(nt=>o.remoteAddr.toString().startsWith(nt.toString())))return this.log("connection from %a refused - connection remote address was in deny list",o.remoteAddr),!1;if(this.allow.some(nt=>o.remoteAddr.toString().startsWith(nt.toString())))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.maxIncomingPendingConnections)return this.log("connection from %a refused - incomingPendingConnections exceeded by host",o.remoteAddr),!1;if(o.remoteAddr.isThinWaistAddress()){const nt=o.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(nt,1)}catch{return this.log("connection from %a refused - inboundConnectionThreshold exceeded by host %s",o.remoteAddr,nt),!1}}return this.getConnections().length({id:tt.id,status:o[tt.status],peerId:tt.options.peerId,multiaddrs:[...tt.options.multiaddrs].map(rt=>multiaddr(rt))}))}async isDialable(o,tt={}){return this.dialQueue.isDialable(o,tt)}}class MovingAverage{constructor(o){wt(this,"movingAverage");wt(this,"variance");wt(this,"deviation");wt(this,"forecast");wt(this,"timespan");wt(this,"previousTime");this.timespan=o,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(o,tt){return 1-Math.exp(-(o-tt)/this.timespan)}push(o,tt=Date.now()){if(this.previousTime!=null){const rt=this.alpha(tt,this.previousTime),nt=o-this.movingAverage,ot=rt*nt;this.movingAverage=rt*o+(1-rt)*this.movingAverage,this.variance=(1-rt)*(this.variance+nt*ot),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+rt*nt}else this.movingAverage=o;this.previousTime=tt}}const DEFAULT_TIMEOUT_MULTIPLIER=1.2,DEFAULT_FAILURE_MULTIPLIER=2,DEFAULT_MIN_TIMEOUT=2e3;class AdaptiveTimeout{constructor(o={}){wt(this,"success");wt(this,"failure");wt(this,"next");wt(this,"metric");wt(this,"timeoutMultiplier");wt(this,"failureMultiplier");wt(this,"minTimeout");var tt;this.success=new MovingAverage(o.interval??5e3),this.failure=new MovingAverage(o.interval??5e3),this.next=new MovingAverage(o.interval??5e3),this.failureMultiplier=o.failureMultiplier??DEFAULT_FAILURE_MULTIPLIER,this.timeoutMultiplier=o.timeoutMultiplier??DEFAULT_TIMEOUT_MULTIPLIER,this.minTimeout=o.minTimeout??DEFAULT_MIN_TIMEOUT,o.metricName!=null&&(this.metric=(tt=o.metrics)==null?void 0:tt.registerMetricGroup(o.metricName))}getTimeoutSignal(o={}){const tt=Math.max(Math.round(this.next.movingAverage*(o.timeoutFactor??this.timeoutMultiplier)),this.minTimeout),rt=AbortSignal.timeout(tt),nt=anySignal([o.signal,rt]);return setMaxListeners$2(1/0,nt,rt),nt.start=Date.now(),nt.timeout=tt,nt}cleanUp(o){var rt,nt;const tt=Date.now()-o.start;o.aborted?(this.failure.push(tt),this.next.push(tt*this.failureMultiplier),(rt=this.metric)==null||rt.update({failureMovingAverage:this.failure.movingAverage,failureDeviation:this.failure.deviation,failureForecast:this.failure.forecast,failureVariance:this.failure.variance,failure:tt})):(this.success.push(tt),this.next.push(tt),(nt=this.metric)==null||nt.update({successMovingAverage:this.success.movingAverage,successDeviation:this.success.deviation,successForecast:this.success.forecast,successVariance:this.success.variance,success:tt}))}}const DEFAULT_PING_INTERVAL_MS=1e4,PROTOCOL_VERSION="1.0.0",PROTOCOL_NAME="ping",PROTOCOL_PREFIX="ipfs",PING_LENGTH=32,DEFAULT_ABORT_CONNECTION_ON_PING_FAILURE=!0;var Hl,Wl;Wl=Symbol.toStringTag,Hl=serviceCapabilities;class ConnectionMonitor{constructor(o,tt={}){wt(this,"protocol");wt(this,"components");wt(this,"log");wt(this,"heartbeatInterval");wt(this,"pingIntervalMs");wt(this,"abortController");wt(this,"timeout");wt(this,"abortConnectionOnPingFailure");wt(this,Wl,"@libp2p/connection-monitor");wt(this,Hl,["@libp2p/connection-monitor"]);this.components=o,this.protocol=`/${tt.protocolPrefix??PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`,this.log=o.logger.forComponent("libp2p:connection-monitor"),this.pingIntervalMs=tt.pingInterval??DEFAULT_PING_INTERVAL_MS,this.abortConnectionOnPingFailure=tt.abortConnectionOnPingFailure??DEFAULT_ABORT_CONNECTION_ON_PING_FAILURE,this.timeout=new AdaptiveTimeout({...tt.pingTimeout??{},metrics:o.metrics,metricName:"libp2p_connection_monitor_ping_time_milliseconds"})}start(){this.abortController=new AbortController,setMaxListeners(1/0,this.abortController.signal),this.heartbeatInterval=setInterval(()=>{this.components.connectionManager.getConnections().forEach(o=>{Promise.resolve().then(async()=>{var rt;let tt=Date.now();try{const nt=this.timeout.getTimeoutSignal({signal:(rt=this.abortController)==null?void 0:rt.signal}),ot=await o.newStream(this.protocol,{signal:nt,runOnLimitedConnection:!0}),it=byteStream(ot);tt=Date.now(),await Promise.all([it.write(randomBytes(PING_LENGTH),{signal:nt}),it.read(PING_LENGTH,{signal:nt})]),o.rtt=Date.now()-tt,await it.unwrap().close({signal:nt})}catch(nt){if(nt.name!=="UnsupportedProtocolError")throw nt;o.rtt=(Date.now()-tt)/2}}).catch(tt=>{this.log.error("error during heartbeat",tt),this.abortConnectionOnPingFailure?(this.log.error("aborting connection due to ping failure"),o.abort(tt)):this.log("connection ping failed, but not aborting due to abortConnectionOnPingFailure flag")})})},this.pingIntervalMs)}stop(){var o;(o=this.abortController)==null||o.abort(),this.heartbeatInterval!=null&&clearInterval(this.heartbeatInterval)}}var Gl;Gl=Symbol.toStringTag;class CompoundContentRouting{constructor(o,tt){wt(this,"routers");wt(this,"started");wt(this,"components");wt(this,Gl,"@libp2p/content-routing");this.routers=tt.routers??[],this.started=!1,this.components=o}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}async*findProviders(o,tt={}){if(this.routers.length===0)throw new NoContentRoutersError("No content routers available");const rt=this,nt=new PeerSet;for await(const ot of merge$2(...rt.routers.map(it=>it.findProviders(o,tt))))ot!=null&&(ot.multiaddrs.length>0&&await this.components.peerStore.merge(ot.id,{multiaddrs:ot.multiaddrs}),!nt.has(ot.id)&&(nt.add(ot.id),yield ot))}async provide(o,tt={}){if(this.routers.length===0)throw new NoContentRoutersError("No content routers available");await Promise.all(this.routers.map(async rt=>{await rt.provide(o,tt)}))}async put(o,tt,rt){if(!this.isStarted())throw new NotStartedError;await Promise.all(this.routers.map(async nt=>{await nt.put(o,tt,rt)}))}async get(o,tt){if(!this.isStarted())throw new NotStartedError;return Promise.any(this.routers.map(async rt=>rt.get(o,tt)))}}var Zl;Zl=Symbol.toStringTag;class DefaultPeerRouting{constructor(o,tt={}){wt(this,"log");wt(this,"peerId");wt(this,"peerStore");wt(this,"routers");wt(this,Zl,"@libp2p/peer-routing");this.log=o.logger.forComponent("libp2p:peer-routing"),this.peerId=o.peerId,this.peerStore=o.peerStore,this.routers=tt.routers??[]}async findPeer(o,tt){if(this.routers.length===0)throw new NoPeerRoutersError("No peer routers available");if(o.toString()===this.peerId.toString())throw new QueriedForSelfError("Should not try to find self");const rt=this,nt=merge$2(...this.routers.map(ot=>async function*(){try{yield await ot.findPeer(o,tt)}catch(it){rt.log.error(it)}}()));for await(const ot of nt)if(ot!=null)return ot.multiaddrs.length>0&&await this.peerStore.merge(ot.id,{multiaddrs:ot.multiaddrs}),ot;throw new NotFoundError$1}async*getClosestPeers(o,tt={}){if(this.routers.length===0)throw new NoPeerRoutersError("No peer routers available");const rt=this,nt=createScalableCuckooFilter(1024);for await(const ot of parallel(async function*(){const it=merge$2(...rt.routers.map(st=>st.getClosestPeers(o,tt)));for await(let st of it)yield async()=>{if(st.multiaddrs.length===0)try{st=await rt.findPeer(st.id,{...tt,useCache:!1})}catch(at){rt.log.error("could not find peer multiaddrs",at);return}return st}}()))ot!=null&&(ot.multiaddrs.length>0&&await this.peerStore.merge(ot.id,{multiaddrs:ot.multiaddrs}),!nt.has(ot.id.toMultihash().bytes)&&(nt.add(ot.id.toMultihash().bytes),yield ot))}}var Kl,Ql;class RandomWalk extends(Ql=TypedEventEmitter,Kl=Symbol.toStringTag,Ql){constructor(tt){super();wt(this,"peerRouting");wt(this,"log");wt(this,"walking");wt(this,"walkers");wt(this,"shutdownController");wt(this,"walkController");wt(this,"needNext");wt(this,Kl,"@libp2p/random-walk");this.log=tt.logger.forComponent("libp2p:random-walk"),this.peerRouting=tt.peerRouting,this.walkers=0,this.walking=!1,this.shutdownController=new AbortController,setMaxListeners(1/0,this.shutdownController.signal)}start(){this.shutdownController=new AbortController,setMaxListeners(1/0,this.shutdownController.signal)}stop(){this.shutdownController.abort()}async*walk(tt){var nt,ot;this.walking||this.startWalk(),this.walkers++;const rt=anySignal([this.shutdownController.signal,tt==null?void 0:tt.signal]);setMaxListeners(1/0,rt);try{for(;;)(nt=this.needNext)==null||nt.resolve(),this.needNext=pDefer(),yield(await raceEvent(this,"walk:peer",rt,{errorEvent:"walk:error"})).detail}finally{rt.clear(),this.walkers--,this.walkers===0&&((ot=this.walkController)==null||ot.abort(),this.walkController=void 0)}}startWalk(){this.walking=!0,this.walkController=new AbortController,setMaxListeners(1/0,this.walkController.signal);const tt=anySignal([this.walkController.signal,this.shutdownController.signal]);setMaxListeners(1/0,tt);const rt=Date.now();let nt=0;Promise.resolve().then(async()=>{for(this.log("start walk");this.walkers>0;)try{const ot=randomBytes(32);let it=Date.now();for await(const st of this.peerRouting.getClosestPeers(ot,{signal:tt}))tt.aborted&&this.log("aborting walk"),tt.throwIfAborted(),this.log("found peer %p after %dms for %d walkers",st.id,Date.now()-it,this.walkers),nt++,this.safeDispatchEvent("walk:peer",{detail:st}),this.walkers===1&&this.needNext!=null&&(this.log("wait for need next"),await raceSignal(this.needNext.promise,tt)),it=Date.now();this.log("walk iteration for %b and %d walkers finished, found %d peers",ot,this.walkers,nt)}catch(ot){this.log.error("randomwalk errored",ot),this.safeDispatchEvent("walk:error",{detail:ot})}this.log("no walkers left, ended walk")}).catch(ot=>{this.log.error("randomwalk errored",ot)}).finally(()=>{this.log("finished walk, found %d peers after %dms",nt,Date.now()-rt),this.walking=!1})}}const DEFAULT_MAX_INBOUND_STREAMS=32,DEFAULT_MAX_OUTBOUND_STREAMS=64;var Yl;Yl=Symbol.toStringTag;class DefaultRegistrar{constructor(o){wt(this,"log");wt(this,"topologies");wt(this,"handlers");wt(this,"components");wt(this,Yl,"@libp2p/registrar");this.log=o.logger.forComponent("libp2p:registrar"),this.topologies=new Map,this.handlers=new Map,this.components=o,this._onDisconnect=this._onDisconnect.bind(this),this._onPeerUpdate=this._onPeerUpdate.bind(this),this._onPeerIdentify=this._onPeerIdentify.bind(this),this.components.events.addEventListener("peer:disconnect",this._onDisconnect),this.components.events.addEventListener("peer:update",this._onPeerUpdate),this.components.events.addEventListener("peer:identify",this._onPeerIdentify)}getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(o){const tt=this.handlers.get(o);if(tt==null)throw new UnhandledProtocolError(`No handler registered for protocol ${o}`);return tt}getTopologies(o){const tt=this.topologies.get(o);return tt==null?[]:[...tt.values()]}async handle(o,tt,rt){if(this.handlers.has(o))throw new DuplicateProtocolHandlerError(`Handler already registered for protocol ${o}`);const nt=mergeOptions$1.bind({ignoreUndefined:!0})({maxInboundStreams:DEFAULT_MAX_INBOUND_STREAMS,maxOutboundStreams:DEFAULT_MAX_OUTBOUND_STREAMS},rt);this.handlers.set(o,{handler:tt,options:nt}),await this.components.peerStore.merge(this.components.peerId,{protocols:[o]})}async unhandle(o){(Array.isArray(o)?o:[o]).forEach(rt=>{this.handlers.delete(rt)}),await this.components.peerStore.patch(this.components.peerId,{protocols:this.getProtocols()})}async register(o,tt){if(tt==null)throw new InvalidParametersError$1("invalid topology");const rt=`${(Math.random()*1e9).toString(36)}${Date.now()}`;let nt=this.topologies.get(o);return nt==null&&(nt=new Map,this.topologies.set(o,nt)),nt.set(rt,tt),rt}unregister(o){for(const[tt,rt]of this.topologies.entries())rt.has(o)&&(rt.delete(o),rt.size===0&&this.topologies.delete(tt))}_onDisconnect(o){const tt=o.detail;this.components.peerStore.get(tt).then(rt=>{var nt,ot,it;for(const st of rt.protocols){const at=this.topologies.get(st);if(at!=null)for(const ct of at.values())((nt=ct.filter)==null?void 0:nt.has(tt))!==!1&&((ot=ct.filter)==null||ot.remove(tt),(it=ct.onDisconnect)==null||it.call(ct,tt))}}).catch(rt=>{rt.name!=="NotFoundError"&&this.log.error("could not inform topologies of disconnecting peer %p",tt,rt)})}_onPeerUpdate(o){var ot,it,st;const{peer:tt,previous:rt}=o.detail,nt=((rt==null?void 0:rt.protocols)??[]).filter(at=>!tt.protocols.includes(at));for(const at of nt){const ct=this.topologies.get(at);if(ct!=null)for(const lt of ct.values())((ot=lt.filter)==null?void 0:ot.has(tt.id))!==!1&&((it=lt.filter)==null||it.remove(tt.id),(st=lt.onDisconnect)==null||st.call(lt,tt.id))}}_onPeerIdentify(o){var ot,it,st;const tt=o.detail.protocols,rt=o.detail.connection,nt=o.detail.peerId;for(const at of tt){const ct=this.topologies.get(at);if(ct!=null)for(const lt of ct.values())rt.limits!=null&<.notifyOnLimitedConnection!==!0||((ot=lt.filter)==null?void 0:ot.has(nt))!==!0&&((it=lt.filter)==null||it.add(nt),(st=lt.onConnect)==null||st.call(lt,nt,rt))}}}class TrackedMap extends Map{constructor(tt){super();wt(this,"metric");const{name:rt,metrics:nt}=tt;this.metric=nt.registerMetric(rt),this.updateComponentMetric()}set(tt,rt){return super.set(tt,rt),this.updateComponentMetric(),this}delete(tt){const rt=super.delete(tt);return this.updateComponentMetric(),rt}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}}function trackedMap(et){const{name:o,metrics:tt}=et;let rt;return tt!=null?rt=new TrackedMap({name:o,metrics:tt}):rt=new Map,rt}var Xl;Xl=Symbol.toStringTag;class DefaultTransportManager{constructor(o,tt={}){wt(this,"log");wt(this,"components");wt(this,"transports");wt(this,"listeners");wt(this,"faultTolerance");wt(this,"started");wt(this,Xl,"@libp2p/transport-manager");this.log=o.logger.forComponent("libp2p:transports"),this.components=o,this.started=!1,this.transports=new Map,this.listeners=trackedMap({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=tt.faultTolerance??FaultTolerance.FATAL_ALL}add(o){const tt=o[Symbol.toStringTag];if(tt==null)throw new InvalidParametersError$1("Transport must have a valid tag");if(this.transports.has(tt))throw new InvalidParametersError$1(`There is already a transport with the tag ${tt}`);this.log("adding transport %s",tt),this.transports.set(tt,o),this.listeners.has(tt)||this.listeners.set(tt,[])}isStarted(){return this.started}start(){this.started=!0}async afterStart(){const o=this.components.addressManager.getListenAddrs();await this.listen(o)}async stop(){const o=[];for(const[tt,rt]of this.listeners)for(this.log("closing listeners for %s",tt);rt.length>0;){const nt=rt.pop();nt!=null&&o.push(nt.close())}await Promise.all(o),this.log("all listeners closed");for(const tt of this.listeners.keys())this.listeners.set(tt,[]);this.started=!1}async dial(o,tt){var nt;const rt=this.dialTransportForMultiaddr(o);if(rt==null)throw new TransportUnavailableError(`No transport available for address ${String(o)}`);return(nt=tt==null?void 0:tt.onProgress)==null||nt.call(tt,new CustomProgressEvent("transport-manager:selected-transport",rt[Symbol.toStringTag])),rt.dial(o,{...tt,upgrader:this.components.upgrader})}getAddrs(){let o=[];for(const tt of this.listeners.values())for(const rt of tt)o=[...o,...rt.getAddrs()];return o}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}dialTransportForMultiaddr(o){for(const tt of this.transports.values())if(tt.dialFilter([o]).length>0)return tt}listenTransportForMultiaddr(o){for(const tt of this.transports.values())if(tt.listenFilter([o]).length>0)return tt}async listen(o){if(!this.isStarted())throw new NotStartedError("Not started");if(o==null||o.length===0){this.log("no addresses were provided for listening, this node is dial only");return}const tt=[];for(const[rt,nt]of this.transports.entries()){const ot=nt.listenFilter(o),it=[];for(const ct of ot){this.log("creating listener for %s on %a",rt,ct);const lt=nt.createListener({upgrader:this.components.upgrader});let dt=this.listeners.get(rt)??[];dt==null&&(dt=[],this.listeners.set(rt,dt)),dt.push(lt),lt.addEventListener("listening",()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:lt})}),lt.addEventListener("close",()=>{const ht=dt.findIndex(mt=>mt===lt);dt.splice(ht,1),this.components.events.safeDispatchEvent("transport:close",{detail:lt})}),it.push(lt.listen(ct))}if(it.length===0){tt.push(rt);continue}if((await Promise.allSettled(it)).find(ct=>ct.status==="fulfilled")==null&&this.faultTolerance!==FaultTolerance.NO_FATAL)throw new NoValidAddressesError(`Transport (${rt}) could not listen on any available address`)}if(tt.length===this.transports.size){const rt=`no valid addresses were provided for transports [${tt.join(", ")}]`;if(this.faultTolerance===FaultTolerance.FATAL_ALL)throw new NoValidAddressesError(rt);this.log(`libp2p in dial mode only: ${rt}`)}}async remove(o){const tt=this.listeners.get(o)??[];this.log.trace("removing transport %s",o);const rt=[];for(this.log.trace("closing listeners for %s",o);tt.length>0;){const nt=tt.pop();nt!=null&&rt.push(nt.close())}await Promise.all(rt),this.transports.delete(o),this.listeners.delete(o)}async removeAll(){const o=[];for(const tt of this.transports.keys())o.push(this.remove(tt));await Promise.all(o)}}const PROTOCOL_ID="/multistream/1.0.0",MAX_PROTOCOL_LENGTH=1024;class UnsupportedProtocolError extends Error{constructor(o="Unsupported protocol error"){super(o),this.name="UnsupportedProtocolError"}}wt(UnsupportedProtocolError,"name","UnsupportedProtocolError");class InvalidMessageError extends Error{constructor(o="Invalid message"){super(o),this.name="InvalidMessageError"}}wt(InvalidMessageError,"name","InvalidMessageError");function coerce$3(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$5(et){return new TextEncoder().encode(et)}function toString$a(et){return new TextDecoder().decode(et)}function base$2(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$3=base$2,_brrp__multiformats_scope_baseX$2=src$3;let Encoder$2=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$2=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$2(this,o)}},ComposedDecoder$2=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$2(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$2(et,o){return new ComposedDecoder$2({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$2=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$2(o,tt,rt),this.decoder=new Decoder$2(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$3({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$2(et,o,tt,rt)}function baseX$2({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$2(tt,et);return from$3({prefix:o,name:et,encode:rt,decode:ot=>coerce$3(nt(ot))})}function decode$a(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$9(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$2=alphabet$2.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$8(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$2[tt],o),"")}function decode$9(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$2[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$4=from$3({prefix:"🚀",name:"base256emoji",encode:encode$8,decode:decode$9}),base256emoji$5=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$4},Symbol.toStringTag,{value:"Module"})),base32$6=rfc4648$2({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$2=rfc4648$2({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$2=rfc4648$2({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$2=rfc4648$2({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$2=rfc4648$2({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$2=rfc4648$2({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$2=rfc4648$2({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$2=rfc4648$2({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$2=rfc4648$2({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$7=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$6,base32hex:base32hex$2,base32hexpad:base32hexpad$2,base32hexpadupper:base32hexpadupper$2,base32hexupper:base32hexupper$2,base32pad:base32pad$2,base32padupper:base32padupper$2,base32upper:base32upper$2,base32z:base32z$2},Symbol.toStringTag,{value:"Module"})),base36$4=baseX$2({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$2=baseX$2({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$5=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$4,base36upper:base36upper$2},Symbol.toStringTag,{value:"Module"})),base58btc$2=baseX$2({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$2=baseX$2({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$2=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$2,base58flickr:base58flickr$2},Symbol.toStringTag,{value:"Module"})),base64$6=rfc4648$2({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$2=rfc4648$2({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$2=rfc4648$2({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$2=rfc4648$2({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$7=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$6,base64pad:base64pad$2,base64url:base64url$2,base64urlpad:base64urlpad$2},Symbol.toStringTag,{value:"Module"})),base8$4=rfc4648$2({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$5=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$4},Symbol.toStringTag,{value:"Module"})),identity$2=from$3({prefix:"\0",name:"identity",encode:et=>toString$a(et),decode:et=>fromString$5(et)}),identityBase$2=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$2},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$2={...identityBase$2,...base2$5,...base8$5,...base10$5,...base16$5,...base32$7,...base36$5,...base58$2,...base64$7,...base256emoji$5};function allocUnsafe$1(et=0){return new Uint8Array(et)}function createCodec$2(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$5=createCodec$2("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$2=createCodec$2("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$1(et.length);for(let tt=0;tt0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=rt,tt+rt>o.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):tt+rt}toBER(o,tt){const rt=new ArrayBuffer(2);if(!o){const nt=new Uint8Array(rt);nt[0]=5,nt[1]=0}return tt&&tt.write(rt),rt}onAsciiEncoding(){return`${this.constructor.NAME}`}}_a$t=Null;typeStore.Null=_a$t;Null.NAME="NULL";class LocalBooleanValueBlock extends HexBlock(ValueBlock){constructor({value:o,...tt}={}){super(tt),tt.valueHex?this.valueHexView=BufferSourceConverter.toUint8Array(tt.valueHex):this.valueHexView=new Uint8Array(1),o&&(this.value=o)}get value(){for(const o of this.valueHexView)if(o>0)return!0;return!1}set value(o){this.valueHexView[0]=o?255:0}fromBER(o,tt,rt){const nt=BufferSourceConverter.toUint8Array(o);return checkBufferParams(this,nt,tt,rt)?(this.valueHexView=nt.subarray(tt,tt+rt),rt>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,utilDecodeTC.call(this),this.blockLength=rt,tt+rt):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}LocalBooleanValueBlock.NAME="BooleanValueBlock";var _a$s;let Boolean$1=class extends BaseBlock{constructor(o={}){super(o,LocalBooleanValueBlock),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(o){this.valueBlock.value=o}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};_a$s=Boolean$1;typeStore.Boolean=_a$s;Boolean$1.NAME="BOOLEAN";class LocalOctetStringValueBlock extends HexBlock(LocalConstructedValueBlock){constructor({isConstructed:o=!1,...tt}={}){super(tt),this.isConstructed=o}fromBER(o,tt,rt){let nt=0;if(this.isConstructed){if(this.isHexOnly=!1,nt=LocalConstructedValueBlock.prototype.fromBER.call(this,o,tt,rt),nt===-1)return nt;for(let ot=0;ot0&&ct.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=ct.unusedBits}return nt}const ot=BufferSourceConverter.toUint8Array(o);if(!checkBufferParams(this,ot,tt,rt))return-1;const it=ot.subarray(tt,tt+rt);if(this.unusedBits=it[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const st=it.subarray(1);try{if(st.byteLength){const at=localFromBER(st,0,st.byteLength);at.offset!==-1&&at.offset===rt-1&&(this.value=[at.result])}}catch{}}return this.valueHexView=it.subarray(1),this.blockLength=it.length,tt+rt}toBER(o,tt){if(this.isConstructed)return LocalConstructedValueBlock.prototype.toBER.call(this,o,tt);if(o)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return EMPTY_BUFFER$1;const rt=new Uint8Array(this.valueHexView.length+1);return rt[0]=this.unusedBits,rt.set(this.valueHexView,1),rt.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}LocalBitStringValueBlock.NAME="BitStringValueBlock";var _a$q;class BitString extends BaseBlock{constructor({idBlock:o={},lenBlock:tt={},...rt}={}){var nt,ot;(nt=rt.isConstructed)!==null&&nt!==void 0||(rt.isConstructed=!!(!((ot=rt.value)===null||ot===void 0)&&ot.length)),super({idBlock:{isConstructed:rt.isConstructed,...o},lenBlock:{...tt,isIndefiniteForm:!!rt.isIndefiniteForm},...rt},LocalBitStringValueBlock),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(o,tt,rt){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(o,tt,rt)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Constructed.prototype.onAsciiEncoding.call(this);{const o=[],tt=this.valueBlock.valueHexView;for(const nt of tt)o.push(nt.toString(2).padStart(8,"0"));const rt=o.join("");return`${this.constructor.NAME} : ${rt.substring(0,rt.length-this.valueBlock.unusedBits)}`}}}_a$q=BitString;typeStore.BitString=_a$q;BitString.NAME=BIT_STRING_NAME;var _a$p;function viewAdd(et,o){const tt=new Uint8Array([0]),rt=new Uint8Array(et),nt=new Uint8Array(o);let ot=rt.slice(0);const it=ot.length-1,st=nt.slice(0),at=st.length-1;let ct=0;const lt=at=0;ht--,dt++){switch(!0){case dt=ot.length:ot=utilConcatView(new Uint8Array([ct%10]),ot);break;default:ot[it-dt]=ct%10}}return tt[0]>0&&(ot=utilConcatView(tt,ot)),ot}function power2(et){if(et>=powers2.length)for(let o=powers2.length;o<=et;o++){const tt=new Uint8Array([0]);let rt=powers2[o-1].slice(0);for(let nt=rt.length-1;nt>=0;nt--){const ot=new Uint8Array([(rt[nt]<<1)+tt[0]]);tt[0]=ot[0]/10,rt[nt]=ot[0]%10}tt[0]>0&&(rt=utilConcatView(tt,rt)),powers2.push(rt)}return powers2[et]}function viewSub(et,o){let tt=0;const rt=new Uint8Array(et),nt=new Uint8Array(o),ot=rt.slice(0),it=ot.length-1,st=nt.slice(0),at=st.length-1;let ct,lt=0;for(let dt=at;dt>=0;dt--,lt++)switch(ct=ot[it-lt]-st[at-lt]-tt,!0){case ct<0:tt=1,ot[it-lt]=ct+10;break;default:tt=0,ot[it-lt]=ct}if(tt>0)for(let dt=it-at+1;dt>=0;dt--,lt++)if(ct=ot[it-lt]-tt,ct<0)tt=1,ot[it-lt]=ct+10;else{tt=0,ot[it-lt]=ct;break}return ot.slice()}class LocalIntegerValueBlock extends HexBlock(ValueBlock){constructor({value:o,...tt}={}){super(tt),this._valueDec=0,tt.valueHex&&this.setValueHex(),o!==void 0&&(this.valueDec=o)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=utilDecodeTC.call(this)))}set valueDec(o){this._valueDec=o,this.isHexOnly=!1,this.valueHexView=new Uint8Array(utilEncodeTC(o))}get valueDec(){return this._valueDec}fromDER(o,tt,rt,nt=0){const ot=this.fromBER(o,tt,rt);if(ot===-1)return ot;const it=this.valueHexView;return it[0]===0&&it[1]&128?this.valueHexView=it.subarray(1):nt!==0&&it.length1&&(nt=it.length+1),this.valueHexView=it.subarray(nt-it.length)),ot}toDER(o=!1){const tt=this.valueHexView;switch(!0){case(tt[0]&128)!==0:{const rt=new Uint8Array(this.valueHexView.length+1);rt[0]=0,rt.set(tt,1),this.valueHexView=rt}break;case(tt[0]===0&&(tt[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(o)}fromBER(o,tt,rt){const nt=super.fromBER(o,tt,rt);return nt===-1||this.setValueHex(),nt}toBER(o){return o?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const o=this.valueHexView.length*8-1;let tt=new Uint8Array(this.valueHexView.length*8/3),rt=0,nt;const ot=this.valueHexView;let it="",st=!1;for(let at=ot.byteLength-1;at>=0;at--){nt=ot[at];for(let ct=0;ct<8;ct++){if((nt&1)===1)switch(rt){case o:tt=viewSub(power2(rt),tt),it="-";break;default:tt=viewAdd(tt,power2(rt))}rt++,nt>>=1}}for(let at=0;at0;){const ot=new LocalSidValueBlock;if(nt=ot.fromBER(o,nt,rt),nt===-1)return this.blockLength=0,this.error=ot.error,nt;this.value.length===0&&(ot.isFirstSid=!0),this.blockLength+=ot.blockLength,rt-=ot.blockLength,this.value.push(ot)}return nt}toBER(o){const tt=[];for(let rt=0;rtNumber.MAX_SAFE_INTEGER){assertBigInt();const st=BigInt(nt);it.valueBigInt=st}else if(it.valueDec=parseInt(nt,10),isNaN(it.valueDec))return;this.value.length||(it.isFirstSid=!0,ot=!0),this.value.push(it)}while(rt!==-1)}toString(){let o="",tt=!1;for(let rt=0;rt0;){const ot=new LocalRelativeSidValueBlock;if(nt=ot.fromBER(o,nt,rt),nt===-1)return this.blockLength=0,this.error=ot.error,nt;this.blockLength+=ot.blockLength,rt-=ot.blockLength,this.value.push(ot)}return nt}toBER(o,tt){const rt=[];for(let nt=0;nt4)continue;const st=4-it.length;for(let at=it.length-1;at>=0;at--)rt[nt*4+at+st]=it[at]}this.valueBlock.value=o}}LocalUniversalStringValueBlock.NAME="UniversalStringValueBlock";var _a$g;class UniversalString extends LocalUniversalStringValueBlock{constructor({...o}={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}_a$g=UniversalString;typeStore.UniversalString=_a$g;UniversalString.NAME="UniversalString";var _a$f;class NumericString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}_a$f=NumericString;typeStore.NumericString=_a$f;NumericString.NAME="NumericString";var _a$e;class PrintableString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}_a$e=PrintableString;typeStore.PrintableString=_a$e;PrintableString.NAME="PrintableString";var _a$d;class TeletexString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}_a$d=TeletexString;typeStore.TeletexString=_a$d;TeletexString.NAME="TeletexString";var _a$c;class VideotexString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}_a$c=VideotexString;typeStore.VideotexString=_a$c;VideotexString.NAME="VideotexString";var _a$b;class IA5String extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}_a$b=IA5String;typeStore.IA5String=_a$b;IA5String.NAME="IA5String";var _a$a;class GraphicString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}_a$a=GraphicString;typeStore.GraphicString=_a$a;GraphicString.NAME="GraphicString";var _a$9;class VisibleString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}_a$9=VisibleString;typeStore.VisibleString=_a$9;VisibleString.NAME="VisibleString";var _a$8;class GeneralString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}_a$8=GeneralString;typeStore.GeneralString=_a$8;GeneralString.NAME="GeneralString";var _a$7;class CharacterString extends LocalSimpleStringBlock{constructor(o={}){super(o),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}_a$7=CharacterString;typeStore.CharacterString=_a$7;CharacterString.NAME="CharacterString";var _a$6;class UTCTime extends VisibleString{constructor({value:o,valueDate:tt,...rt}={}){if(super(rt),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,o){this.fromString(o),this.valueBlock.valueHexView=new Uint8Array(o.length);for(let nt=0;nt=50?this.year=1900+nt:this.year=2e3+nt,this.month=parseInt(rt[2],10),this.day=parseInt(rt[3],10),this.hour=parseInt(rt[4],10),this.minute=parseInt(rt[5],10),this.second=parseInt(rt[6],10)}toString(o="iso"){if(o==="iso"){const tt=new Array(7);return tt[0]=padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),tt[1]=padNumber(this.month,2),tt[2]=padNumber(this.day,2),tt[3]=padNumber(this.hour,2),tt[4]=padNumber(this.minute,2),tt[5]=padNumber(this.second,2),tt[6]="Z",tt.join("")}return super.toString(o)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}_a$6=UTCTime;typeStore.UTCTime=_a$6;UTCTime.NAME="UTCTime";var _a$5;class GeneralizedTime extends UTCTime{constructor(o={}){var tt;super(o),(tt=this.millisecond)!==null&&tt!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(o){super.fromDate(o),this.millisecond=o.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(o){let tt=!1,rt="",nt="",ot=0,it,st=0,at=0;if(o[o.length-1]==="Z")rt=o.substring(0,o.length-1),tt=!0;else{const dt=new Number(o[o.length-1]);if(isNaN(dt.valueOf()))throw new Error("Wrong input string for conversion");rt=o}if(tt){if(rt.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(rt.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let dt=1,ht=rt.indexOf("+"),mt="";if(ht===-1&&(ht=rt.indexOf("-"),dt=-1),ht!==-1){if(mt=rt.substring(ht+1),rt=rt.substring(0,ht),mt.length!==2&&mt.length!==4)throw new Error("Wrong input string for conversion");let ft=parseInt(mt.substring(0,2),10);if(isNaN(ft.valueOf()))throw new Error("Wrong input string for conversion");if(st=dt*ft,mt.length===4){if(ft=parseInt(mt.substring(2,4),10),isNaN(ft.valueOf()))throw new Error("Wrong input string for conversion");at=dt*ft}}}let ct=rt.indexOf(".");if(ct===-1&&(ct=rt.indexOf(",")),ct!==-1){const dt=new Number(`0${rt.substring(ct)}`);if(isNaN(dt.valueOf()))throw new Error("Wrong input string for conversion");ot=dt.valueOf(),nt=rt.substring(0,ct)}else nt=rt;switch(!0){case nt.length===8:if(it=/(\d{4})(\d{2})(\d{2})/ig,ct!==-1)throw new Error("Wrong input string for conversion");break;case nt.length===10:if(it=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,ct!==-1){let dt=60*ot;this.minute=Math.floor(dt),dt=60*(dt-this.minute),this.second=Math.floor(dt),dt=1e3*(dt-this.second),this.millisecond=Math.floor(dt)}break;case nt.length===12:if(it=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,ct!==-1){let dt=60*ot;this.second=Math.floor(dt),dt=1e3*(dt-this.second),this.millisecond=Math.floor(dt)}break;case nt.length===14:if(it=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,ct!==-1){const dt=1e3*ot;this.millisecond=Math.floor(dt)}break;default:throw new Error("Wrong input string for conversion")}const lt=it.exec(nt);if(lt===null)throw new Error("Wrong input string for conversion");for(let dt=1;dt(et[tt]=o,et),[]),alphabetCharsToBytes$d=alphabet$d.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$D(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$d[tt],o),"")}function decode$K(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$d[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$q=from$k({prefix:"🚀",name:"base256emoji",encode:encode$D,decode:decode$K}),base256emoji$r=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$q},Symbol.toStringTag,{value:"Module"})),base64$t=rfc4648$g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$d=rfc4648$g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$e=rfc4648$g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$d=rfc4648$g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$u=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$t,base64pad:base64pad$d,base64url:base64url$e,base64urlpad:base64urlpad$d},Symbol.toStringTag,{value:"Module"})),base8$q=rfc4648$g({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$r=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$q},Symbol.toStringTag,{value:"Module"})),identity$e=from$k({prefix:"\0",name:"identity",encode:et=>toString$r(et),decode:et=>fromString$q(et)}),identityBase$d=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$e},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;function from$j({name:et,code:o,encode:tt}){return new Hasher$1(et,o,tt)}let Hasher$1=class{constructor(o,tt,rt){wt(this,"name");wt(this,"code");wt(this,"encode");this.name=o,this.code=tt,this.encode=rt}digest(o){if(o instanceof Uint8Array){const tt=this.encode(o);return tt instanceof Uint8Array?create$5(this.code,tt):tt.then(rt=>create$5(this.code,rt))}else throw Error("Unknown type, must be binary type")}};function sha$1(et){return async o=>new Uint8Array(await crypto.subtle.digest(et,o))}const sha256$1=from$j({name:"sha2-256",code:18,encode:sha$1("SHA-256")}),bases$d={...identityBase$d,...base2$r,...base8$r,...base10$r,...base16$r,...base32$v,...base36$s,...base58$d,...base64$u,...base256emoji$r};function allocUnsafe$c(et=0){return new Uint8Array(et)}function createCodec$d(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$h=createCodec$d("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$d=createCodec$d("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$c(et.length);for(let tt=0;tt0&&(o=`0${o}`);const tt=o.length/2,rt=new Uint8Array(tt);let nt=0,ot=0;for(;nt0&&(rt=`0${rt}`),o.push(rt)}),BigInt("0x"+o.join(""))}function pkixToRSAPublicKey(et){const o=pkixToJwk(et);if(rsaKeySize(o)>MAX_RSA_KEY_SIZE)throw new InvalidPublicKeyError("Key size is too large");const tt=sha256$3(PublicKey.encode({Type:KeyType.RSA,Data:et})),rt=create$5(SHA2_256_CODE,tt);return new RSAPublicKey(o,rt)}function isPromise$3(et){return et==null?!1:typeof et.then=="function"&&typeof et.catch=="function"&&typeof et.finally=="function"}function hashAndVerify(et,o,tt){const rt=sha256$1.digest(tt instanceof Uint8Array?tt:tt.subarray());if(isPromise$3(rt))return rt.then(({digest:nt})=>secp256k1.verify(o,nt,et)).catch(nt=>{throw new VerificationError(String(nt))});try{return secp256k1.verify(o,rt.digest,et)}catch(nt){throw new VerificationError(String(nt))}}class Secp256k1PublicKey{constructor(o){wt(this,"type","secp256k1");wt(this,"raw");wt(this,"_key");this._key=validateSecp256k1PublicKey(o),this.raw=compressSecp256k1PublicKey(this._key)}toMultihash(){return identity$f.digest(publicKeyToProtobuf(this))}toCID(){return CID$2.createV1(114,this.toMultihash())}toString(){return base58btc$h.encode(this.toMultihash().bytes).substring(1)}equals(o){return o==null||!(o.raw instanceof Uint8Array)?!1:equals$9(this.raw,o.raw)}verify(o,tt){return hashAndVerify(this._key,tt,o)}}function unmarshalSecp256k1PublicKey(et){return new Secp256k1PublicKey(et)}function compressSecp256k1PublicKey(et){return secp256k1.ProjectivePoint.fromHex(et).toRawBytes(!0)}function validateSecp256k1PublicKey(et){try{return secp256k1.ProjectivePoint.fromHex(et),et}catch(o){throw new InvalidPublicKeyError(String(o))}}async function generateKeyPair(et,o){return generateEd25519KeyPair()}function publicKeyFromProtobuf(et){const{Type:o,Data:tt}=PublicKey.decode(et),rt=tt??new Uint8Array;switch(o){case KeyType.RSA:return pkixToRSAPublicKey(rt);case KeyType.Ed25519:return unmarshalEd25519PublicKey(rt);case KeyType.secp256k1:return unmarshalSecp256k1PublicKey(rt);default:throw new UnsupportedKeyTypeError$1}}function publicKeyFromRaw(et){return et.byteLength===32?unmarshalEd25519PublicKey(et):et.byteLength===33?unmarshalSecp256k1PublicKey(et):pkixToRSAPublicKey(et)}function publicKeyFromMultihash(et){const{Type:o,Data:tt}=PublicKey.decode(et.digest),rt=tt??new Uint8Array;switch(o){case KeyType.Ed25519:return unmarshalEd25519PublicKey(rt);case KeyType.secp256k1:return unmarshalSecp256k1PublicKey(rt);default:throw new UnsupportedKeyTypeError$1}}function publicKeyToProtobuf(et){return PublicKey.encode({Type:KeyType[et.type],Data:et.raw})}const peerIdSymbol$2=Symbol.for("@libp2p/peer-id");var gs;let InvalidParametersError$2=(gs=class extends Error{constructor(o="Invalid parameters"){super(o),this.name="InvalidParametersError"}},wt(gs,"name","InvalidParametersError"),gs);class InvalidCIDError extends Error{constructor(o="Invalid CID"){super(o),this.name="InvalidCIDError"}}wt(InvalidCIDError,"name","InvalidCIDError");class InvalidMultihashError extends Error{constructor(o="Invalid Multihash"){super(o),this.name="InvalidMultihashError"}}wt(InvalidMultihashError,"name","InvalidMultihashError");class UnsupportedKeyTypeError extends Error{constructor(o="Unsupported key type"){super(o),this.name="UnsupportedKeyTypeError"}}wt(UnsupportedKeyTypeError,"name","UnsupportedKeyTypeError");function equals$8(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$h=base$h,_brrp__multiformats_scope_baseX$g=src$h;let Encoder$h=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$h=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$i(this,o)}},ComposedDecoder$g=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$i(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$i(et,o){return new ComposedDecoder$g({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$g=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$h(o,tt,rt),this.decoder=new Decoder$h(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$i({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$g(et,o,tt,rt)}function baseX$g({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$g(tt,et);return from$i({prefix:o,name:et,encode:rt,decode:ot=>coerce$g(nt(ot))})}function decode$J(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$C(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<=INT$3;)o[tt++]=et&255|MSB$5,et/=128;for(;et&MSBALL$3;)o[tt++]=et&255|MSB$5,et>>>=7;return o[tt]=et|0,encode$B.bytes=tt-rt+1,o}var decode$I=read$4,MSB$1$3=128,REST$1$3=127;function read$4(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$4.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$3)<=MSB$1$3);return read$4.bytes=ot-rt,tt}var N1$3=Math.pow(2,7),N2$3=Math.pow(2,14),N3$3=Math.pow(2,21),N4$3=Math.pow(2,28),N5$3=Math.pow(2,35),N6$3=Math.pow(2,42),N7$3=Math.pow(2,49),N8$3=Math.pow(2,56),N9$3=Math.pow(2,63),length$3=function(et){return et{const[dt,ht]=decode$H(o.subarray(tt));return tt+=ht,dt};let nt=rt(),ot=DAG_PB_CODE$1;if(nt===18?(nt=0,tt=0):ot=rt(),nt!==0&&nt!==1)throw new RangeError(`Invalid CID version ${nt}`);const it=tt,st=rt(),at=rt(),ct=tt+at,lt=ct-it;return{version:nt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(o,tt){const[rt,nt]=parseCIDtoBytes$1(o,tt),ot=Dr.decode(nt);if(ot.version===0&&o[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache$1(ot).set(rt,o),ot}};function parseCIDtoBytes$1(et,o){switch(et[0]){case"Q":{const tt=o??base58btc$g;return[base58btc$g.prefix,tt.decode(`${base58btc$g.prefix}${et}`)]}case base58btc$g.prefix:{const tt=o??base58btc$g;return[base58btc$g.prefix,tt.decode(et)]}case base32$s.prefix:{const tt=o??base32$s;return[base32$s.prefix,tt.decode(et)]}case base36$p.prefix:{const tt=o??base36$p;return[base36$p.prefix,tt.decode(et)]}default:{if(o==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[et[0],o.decode(et)]}}}function toStringV0$1(et,o,tt){const{prefix:rt}=tt;if(rt!==base58btc$g.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const nt=o.get(rt);if(nt==null){const ot=tt.encode(et).slice(1);return o.set(rt,ot),ot}else return nt}function toStringV1$1(et,o,tt){const{prefix:rt}=tt,nt=o.get(rt);if(nt==null){const ot=tt.encode(et);return o.set(rt,ot),ot}else return nt}const DAG_PB_CODE$1=112,SHA_256_CODE$1=18;function encodeCID$1(et,o,tt){const rt=encodingLength$3(et),nt=rt+encodingLength$3(o),ot=new Uint8Array(nt+tt.byteLength);return encodeTo$1(et,ot,0),encodeTo$1(o,ot,rt),ot.set(tt,nt),ot}const cidSymbol$1=Symbol.for("@ipld/js-cid/CID"),code$1=0,name$3="identity",encode$A=coerce$g;function digest(et){return create$4(code$1,encode$A(et))}const identity$d={code:code$1,name:name$3,encode:encode$A,digest};function from$h({name:et,code:o,encode:tt}){return new Hasher(et,o,tt)}class Hasher{constructor(o,tt,rt){wt(this,"name");wt(this,"code");wt(this,"encode");this.name=o,this.code=tt,this.encode=rt}digest(o){if(o instanceof Uint8Array){const tt=this.encode(o);return tt instanceof Uint8Array?create$4(this.code,tt):tt.then(rt=>create$4(this.code,rt))}else throw Error("Unknown type, must be binary type")}}function sha(et){return async o=>new Uint8Array(await crypto.subtle.digest(et,o))}const sha256=from$h({name:"sha2-256",code:18,encode:sha("SHA-256")}),base10$o=baseX$g({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$p=Object.freeze(Object.defineProperty({__proto__:null,base10:base10$o},Symbol.toStringTag,{value:"Module"})),base16$o=rfc4648$f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper$c=rfc4648$f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$p=Object.freeze(Object.defineProperty({__proto__:null,base16:base16$o,base16upper:base16upper$c},Symbol.toStringTag,{value:"Module"})),base2$o=rfc4648$f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$p=Object.freeze(Object.defineProperty({__proto__:null,base2:base2$o},Symbol.toStringTag,{value:"Module"})),alphabet$c=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),alphabetBytesToChars$c=alphabet$c.reduce((et,o,tt)=>(et[tt]=o,et),[]),alphabetCharsToBytes$c=alphabet$c.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$z(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$c[tt],o),"")}function decode$F(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$c[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$o=from$i({prefix:"🚀",name:"base256emoji",encode:encode$z,decode:decode$F}),base256emoji$p=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$o},Symbol.toStringTag,{value:"Module"})),base64$r=rfc4648$f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$c=rfc4648$f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$d=rfc4648$f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$c=rfc4648$f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$s=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$r,base64pad:base64pad$c,base64url:base64url$d,base64urlpad:base64urlpad$c},Symbol.toStringTag,{value:"Module"})),base8$o=rfc4648$f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$p=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$o},Symbol.toStringTag,{value:"Module"})),identity$c=from$i({prefix:"\0",name:"identity",encode:et=>toString$p(et),decode:et=>fromString$o(et)}),identityBase$c=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$c},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$c={...identityBase$c,...base2$p,...base8$p,...base10$p,...base16$p,...base32$t,...base36$q,...base58$c,...base64$s,...base256emoji$p};function allocUnsafe$b(et=0){return new Uint8Array(et)}function createCodec$c(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$g=createCodec$c("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$c=createCodec$c("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$b(et.length);for(let tt=0;tt{rt=()=>{it(nt)},o.addEventListener("abort",rt)})])}finally{rt!=null&&o.removeEventListener("abort",rt)}}class QueuelessPushable{constructor(){wt(this,"readNext");wt(this,"haveNext");wt(this,"ended");wt(this,"nextResult");this.ended=!1,this.readNext=pDefer(),this.haveNext=pDefer()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");const o=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=pDefer(),o}async throw(o){return this.ended=!0,o!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(o)),{done:!0,value:void 0}}async return(){const o={done:!0,value:void 0};return await this._push(void 0),o}async push(o,tt){await this._push(o,tt)}async end(o,tt){o!=null?await this.throw(o):await this._push(void 0,tt)}async _push(o,tt){if(o!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;o!=null?this.nextResult={done:!1,value:o}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=pDefer(),await raceSignal(this.readNext.promise,tt==null?void 0:tt.signal,tt)}}function queuelessPushable(){return new QueuelessPushable}class UnexpectedEOFError extends Error{constructor(){super(...arguments);wt(this,"name","UnexpectedEOFError");wt(this,"code","ERR_UNEXPECTED_EOF")}}class CodeError extends Error{constructor(tt,rt){super(tt);wt(this,"code");this.code=rt}}let AbortError$7=class extends CodeError{constructor(tt){super(tt,"ABORT_ERR");wt(this,"type");this.type="aborted",this.name="AbortError"}};function byteStream(et,o){const tt=queuelessPushable();et.sink(tt).catch(async it=>{await tt.end(it)}),et.sink=async it=>{for await(const st of it)await tt.push(st);await tt.end()};let rt=et.source;et.source[Symbol.iterator]!=null?rt=et.source[Symbol.iterator]():et.source[Symbol.asyncIterator]!=null&&(rt=et.source[Symbol.asyncIterator]());const nt=new Uint8ArrayList;return{read:async(it,st)=>{var lt,dt;(lt=st==null?void 0:st.signal)==null||lt.throwIfAborted();let at;const ct=new Promise((ht,mt)=>{var ft;at=()=>{mt(new AbortError$7("Read aborted"))},(ft=st==null?void 0:st.signal)==null||ft.addEventListener("abort",at)});try{if(it==null){const{done:mt,value:ft}=await Promise.race([rt.next(),ct]);return mt===!0?new Uint8ArrayList:ft}for(;nt.byteLength{var at;(at=st==null?void 0:st.signal)==null||at.throwIfAborted(),it instanceof Uint8Array?await tt.push(it,st):await tt.push(it.subarray(),st)},unwrap:()=>{if(nt.byteLength>0){const it=et.source;et.source=async function*(){(o==null?void 0:o.yieldBytes)===!1?yield nt:yield*nt,yield*it}()}return et}}}class InvalidMessageLengthError extends Error{constructor(){super(...arguments);wt(this,"name","InvalidMessageLengthError");wt(this,"code","ERR_INVALID_MSG_LENGTH")}}class InvalidDataLengthError extends Error{constructor(){super(...arguments);wt(this,"name","InvalidDataLengthError");wt(this,"code","ERR_MSG_DATA_TOO_LONG")}}class InvalidDataLengthLengthError extends Error{constructor(){super(...arguments);wt(this,"name","InvalidDataLengthLengthError");wt(this,"code","ERR_MSG_LENGTH_TOO_LONG")}}function lpStream(et,o={}){const tt=byteStream(et,o);o.maxDataLength!=null&&o.maxLengthLength==null&&(o.maxLengthLength=encodingLength$6(o.maxDataLength));const rt=(o==null?void 0:o.lengthDecoder)??decode$Z,nt=(o==null?void 0:o.lengthEncoder)??encode$P;return{read:async it=>{let st=-1;const at=new Uint8ArrayList;for(;;){at.append(await tt.read(1,it));try{st=rt(at)}catch(ct){if(ct instanceof RangeError)continue;throw ct}if(st<0)throw new InvalidMessageLengthError("Invalid message length");if((o==null?void 0:o.maxLengthLength)!=null&&at.byteLength>o.maxLengthLength)throw new InvalidDataLengthLengthError("message length length too long");if(st>-1)break}if((o==null?void 0:o.maxDataLength)!=null&&st>o.maxDataLength)throw new InvalidDataLengthError("message length too long");return tt.read(st,it)},write:async(it,st)=>{await tt.write(new Uint8ArrayList(nt(it.byteLength),it),st)},writeV:async(it,st)=>{const at=new Uint8ArrayList(...it.flatMap(ct=>[nt(ct.byteLength),ct]));await tt.write(at,st)},unwrap:()=>tt.unwrap()}}function pair(){const et=pDefer();let o=!1;return{sink:async tt=>{if(o)throw new Error("already piped");o=!0,et.resolve(tt)},source:async function*(){yield*await et.promise}()}}function duplexPair(){const et=pair(),o=pair();return[{source:et.source,sink:o.sink},{source:o.source,sink:et.sink}]}function alloc$4(et=0){return new Uint8Array(et)}function allocUnsafe$a(et=0){return new Uint8Array(et)}var define_globalThis_process_env_default$2={};const NOISE_MSG_MAX_LENGTH_BYTES=65535,NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=NOISE_MSG_MAX_LENGTH_BYTES-16,DUMP_SESSION_KEYS=!!(define_globalThis_process_env_default$2!=null&&define_globalThis_process_env_default$2.DUMP_SESSION_KEYS);function number$2(et){if(!Number.isSafeInteger(et)||et<0)throw new Error(`positive integer expected, not ${et}`)}function bool(et){if(typeof et!="boolean")throw new Error(`boolean expected, not ${et}`)}function isBytes$1(et){return et instanceof Uint8Array||et!=null&&typeof et=="object"&&et.constructor.name==="Uint8Array"}function bytes(et,...o){if(!isBytes$1(et))throw new Error("Uint8Array expected");if(o.length>0&&!o.includes(et.length))throw new Error(`Uint8Array expected of length ${o}, not of length=${et.length}`)}function exists(et,o=!0){if(et.destroyed)throw new Error("Hash instance has been destroyed");if(o&&et.finished)throw new Error("Hash#digest() has already been called")}function output(et,o){bytes(et);const tt=o.outputLen;if(et.lengthnew Uint32Array(et.buffer,et.byteOffset,Math.floor(et.byteLength/4)),createView=et=>new DataView(et.buffer,et.byteOffset,et.byteLength),isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!isLE)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes(et){if(typeof et!="string")throw new Error(`string expected, got ${typeof et}`);return new Uint8Array(new TextEncoder().encode(et))}function toBytes(et){if(typeof et=="string")et=utf8ToBytes(et);else if(isBytes$1(et))et=copyBytes(et);else throw new Error(`Uint8Array expected, got ${typeof et}`);return et}function checkOpts(et,o){if(o==null||typeof o!="object")throw new Error("options must be defined");return Object.assign(et,o)}function equalBytes(et,o){if(et.length!==o.length)return!1;let tt=0;for(let rt=0;rt(Object.assign(o,et),o);function setBigUint64(et,o,tt,rt){if(typeof et.setBigUint64=="function")return et.setBigUint64(o,tt,rt);const nt=BigInt(32),ot=BigInt(4294967295),it=Number(tt>>nt&ot),st=Number(tt&ot),at=4,ct=0;et.setUint32(o+at,it,rt),et.setUint32(o+ct,st,rt)}function copyBytes(et){return Uint8Array.from(et)}function clean(...et){for(let o=0;oUint8Array.from(et.split("").map(o=>o.charCodeAt(0))),sigma16=_utf8ToBytes("expand 16-byte k"),sigma32=_utf8ToBytes("expand 32-byte k"),sigma16_32=u32(sigma16),sigma32_32=u32(sigma32);sigma32_32.slice();function rotl(et,o){return et<>>32-o}function isAligned32(et){return et.byteOffset%4===0}const BLOCK_LEN=64,BLOCK_LEN32=16,MAX_COUNTER=2**32-1,U32_EMPTY=new Uint32Array;function runCipher(et,o,tt,rt,nt,ot,it,st){const at=nt.length,ct=new Uint8Array(BLOCK_LEN),lt=u32(ct),dt=isAligned32(nt)&&isAligned32(ot),ht=dt?u32(nt):U32_EMPTY,mt=dt?u32(ot):U32_EMPTY;for(let ft=0;ft=MAX_COUNTER)throw new Error("arx: counter overflow");const pt=Math.min(BLOCK_LEN,at-ft);if(dt&&pt===BLOCK_LEN){const yt=ft/4;if(ft%4!==0)throw new Error("arx: invalid block position");for(let gt=0,bt;gt{bytes(st),bytes(at),bytes(ct);const ht=ct.length;if(lt===void 0&&(lt=new Uint8Array(ht)),bytes(lt),number$2(dt),dt<0||dt>=MAX_COUNTER)throw new Error("arx: counter overflow");if(lt.lengthet[o++]&255|(et[o++]&255)<<8;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,o=toBytes(o),bytes(o,32);const tt=u8to16(o,0),rt=u8to16(o,2),nt=u8to16(o,4),ot=u8to16(o,6),it=u8to16(o,8),st=u8to16(o,10),at=u8to16(o,12),ct=u8to16(o,14);this.r[0]=tt&8191,this.r[1]=(tt>>>13|rt<<3)&8191,this.r[2]=(rt>>>10|nt<<6)&7939,this.r[3]=(nt>>>7|ot<<9)&8191,this.r[4]=(ot>>>4|it<<12)&255,this.r[5]=it>>>1&8190,this.r[6]=(it>>>14|st<<2)&8191,this.r[7]=(st>>>11|at<<5)&8065,this.r[8]=(at>>>8|ct<<8)&8191,this.r[9]=ct>>>5&127;for(let lt=0;lt<8;lt++)this.pad[lt]=u8to16(o,16+2*lt)}process(o,tt,rt=!1){const nt=rt?0:2048,{h:ot,r:it}=this,st=it[0],at=it[1],ct=it[2],lt=it[3],dt=it[4],ht=it[5],mt=it[6],ft=it[7],pt=it[8],yt=it[9],gt=u8to16(o,tt+0),bt=u8to16(o,tt+2),xt=u8to16(o,tt+4),vt=u8to16(o,tt+6),Et=u8to16(o,tt+8),Ct=u8to16(o,tt+10),St=u8to16(o,tt+12),At=u8to16(o,tt+14);let kt=ot[0]+(gt&8191),It=ot[1]+((gt>>>13|bt<<3)&8191),Nt=ot[2]+((bt>>>10|xt<<6)&8191),Lt=ot[3]+((xt>>>7|vt<<9)&8191),Mt=ot[4]+((vt>>>4|Et<<12)&8191),zt=ot[5]+(Et>>>1&8191),Ut=ot[6]+((Et>>>14|Ct<<2)&8191),Xt=ot[7]+((Ct>>>11|St<<5)&8191),Wt=ot[8]+((St>>>8|At<<8)&8191),Ft=ot[9]+(At>>>5|nt),qt=0,Pt=qt+kt*st+It*(5*yt)+Nt*(5*pt)+Lt*(5*ft)+Mt*(5*mt);qt=Pt>>>13,Pt&=8191,Pt+=zt*(5*ht)+Ut*(5*dt)+Xt*(5*lt)+Wt*(5*ct)+Ft*(5*at),qt+=Pt>>>13,Pt&=8191;let Yt=qt+kt*at+It*st+Nt*(5*yt)+Lt*(5*pt)+Mt*(5*ft);qt=Yt>>>13,Yt&=8191,Yt+=zt*(5*mt)+Ut*(5*ht)+Xt*(5*dt)+Wt*(5*lt)+Ft*(5*ct),qt+=Yt>>>13,Yt&=8191;let Qt=qt+kt*ct+It*at+Nt*st+Lt*(5*yt)+Mt*(5*pt);qt=Qt>>>13,Qt&=8191,Qt+=zt*(5*ft)+Ut*(5*mt)+Xt*(5*ht)+Wt*(5*dt)+Ft*(5*lt),qt+=Qt>>>13,Qt&=8191;let jt=qt+kt*lt+It*ct+Nt*at+Lt*st+Mt*(5*yt);qt=jt>>>13,jt&=8191,jt+=zt*(5*pt)+Ut*(5*ft)+Xt*(5*mt)+Wt*(5*ht)+Ft*(5*dt),qt+=jt>>>13,jt&=8191;let Gt=qt+kt*dt+It*lt+Nt*ct+Lt*at+Mt*st;qt=Gt>>>13,Gt&=8191,Gt+=zt*(5*yt)+Ut*(5*pt)+Xt*(5*ft)+Wt*(5*mt)+Ft*(5*ht),qt+=Gt>>>13,Gt&=8191;let rr=qt+kt*ht+It*dt+Nt*lt+Lt*ct+Mt*at;qt=rr>>>13,rr&=8191,rr+=zt*st+Ut*(5*yt)+Xt*(5*pt)+Wt*(5*ft)+Ft*(5*mt),qt+=rr>>>13,rr&=8191;let Ht=qt+kt*mt+It*ht+Nt*dt+Lt*lt+Mt*ct;qt=Ht>>>13,Ht&=8191,Ht+=zt*at+Ut*st+Xt*(5*yt)+Wt*(5*pt)+Ft*(5*ft),qt+=Ht>>>13,Ht&=8191;let dr=qt+kt*ft+It*mt+Nt*ht+Lt*dt+Mt*lt;qt=dr>>>13,dr&=8191,dr+=zt*ct+Ut*at+Xt*st+Wt*(5*yt)+Ft*(5*pt),qt+=dr>>>13,dr&=8191;let Zt=qt+kt*pt+It*ft+Nt*mt+Lt*ht+Mt*dt;qt=Zt>>>13,Zt&=8191,Zt+=zt*lt+Ut*ct+Xt*at+Wt*st+Ft*(5*yt),qt+=Zt>>>13,Zt&=8191;let Jt=qt+kt*yt+It*pt+Nt*ft+Lt*mt+Mt*ht;qt=Jt>>>13,Jt&=8191,Jt+=zt*dt+Ut*lt+Xt*ct+Wt*at+Ft*st,qt+=Jt>>>13,Jt&=8191,qt=(qt<<2)+qt|0,qt=qt+Pt|0,Pt=qt&8191,qt=qt>>>13,Yt+=qt,ot[0]=Pt,ot[1]=Yt,ot[2]=Qt,ot[3]=jt,ot[4]=Gt,ot[5]=rr,ot[6]=Ht,ot[7]=dr,ot[8]=Zt,ot[9]=Jt}finalize(){const{h:o,pad:tt}=this,rt=new Uint16Array(10);let nt=o[1]>>>13;o[1]&=8191;for(let st=2;st<10;st++)o[st]+=nt,nt=o[st]>>>13,o[st]&=8191;o[0]+=nt*5,nt=o[0]>>>13,o[0]&=8191,o[1]+=nt,nt=o[1]>>>13,o[1]&=8191,o[2]+=nt,rt[0]=o[0]+5,nt=rt[0]>>>13,rt[0]&=8191;for(let st=1;st<10;st++)rt[st]=o[st]+nt,nt=rt[st]>>>13,rt[st]&=8191;rt[9]-=8192;let ot=(nt^1)-1;for(let st=0;st<10;st++)rt[st]&=ot;ot=~ot;for(let st=0;st<10;st++)o[st]=o[st]&ot|rt[st];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 it=o[0]+tt[0];o[0]=it&65535;for(let st=1;st<8;st++)it=(o[st]+tt[st]|0)+(it>>>16)|0,o[st]=it&65535;clean(rt)}update(o){exists(this);const{buffer:tt,blockLen:rt}=this;o=toBytes(o);const nt=o.length;for(let ot=0;ot>>0,o[ot++]=rt[it]>>>8;return o}digest(){const{buffer:o,outputLen:tt}=this;this.digestInto(o);const rt=o.slice(0,tt);return this.destroy(),rt}}function wrapConstructorWithKey(et){const o=(rt,nt)=>et(nt).update(toBytes(rt)).digest(),tt=et(new Uint8Array(32));return o.outputLen=tt.outputLen,o.blockLen=tt.blockLen,o.create=rt=>et(rt),o}const poly1305=wrapConstructorWithKey(et=>new Poly1305(et));function chachaCore(et,o,tt,rt,nt,ot=20){let it=et[0],st=et[1],at=et[2],ct=et[3],lt=o[0],dt=o[1],ht=o[2],mt=o[3],ft=o[4],pt=o[5],yt=o[6],gt=o[7],bt=nt,xt=tt[0],vt=tt[1],Et=tt[2],Ct=it,St=st,At=at,kt=ct,It=lt,Nt=dt,Lt=ht,Mt=mt,zt=ft,Ut=pt,Xt=yt,Wt=gt,Ft=bt,qt=xt,Pt=vt,Yt=Et;for(let jt=0;jt{et.update(o);const tt=o.length%16;tt&&et.update(ZEROS16.subarray(tt))},ZEROS32=new Uint8Array(32);function computeTag(et,o,tt,rt,nt){const ot=et(o,tt,ZEROS32),it=poly1305.create(ot);nt&&updatePadded(it,nt),updatePadded(it,rt);const st=new Uint8Array(16),at=createView(st);setBigUint64(at,0,BigInt(nt?nt.length:0),!0),setBigUint64(at,8,BigInt(rt.length),!0),it.update(st);const ct=it.digest();return clean(ot,st),ct}const _poly1305_aead=et=>(o,tt,rt)=>(bytes(o,32),bytes(tt),{encrypt(ot,it){const st=ot.length,at=st+16;it?bytes(it,at):it=new Uint8Array(at),et(o,tt,ot,it,1);const ct=computeTag(et,o,tt,it.subarray(0,-16),rt);return it.set(ct,st),clean(ct),it},decrypt(ot,it){const st=ot.length,at=st-16;if(st<16)throw new Error("encrypted data must be at least 16 bytes");it?bytes(it,at):it=new Uint8Array(at);const ct=ot.subarray(0,-16),lt=ot.subarray(-16),dt=computeTag(et,o,tt,ct,rt);if(!equalBytes(lt,dt))throw new Error("invalid tag");return et(o,tt,ct,it,1),clean(dt),it}}),chacha20poly1305=wrapCipher({blockSize:64,nonceLength:12,tagLength:16},_poly1305_aead(chacha20));function extract(et,o,tt){return hash$1(et),tt===void 0&&(tt=new Uint8Array(et.outputLen)),hmac(et,toBytes$2(tt),toBytes$2(o))}const HKDF_COUNTER=new Uint8Array([0]),EMPTY_BUFFER=new Uint8Array;function expand(et,o,tt,rt=32){if(hash$1(et),number$4(rt),rt>255*et.outputLen)throw new Error("Length should be <= 255*HashLen");const nt=Math.ceil(rt/et.outputLen);tt===void 0&&(tt=EMPTY_BUFFER);const ot=new Uint8Array(nt*et.outputLen),it=hmac.create(et,o),st=it._cloneInto(),at=new Uint8Array(it.outputLen);for(let ct=0;ctet.generateX25519SharedKey(o.privateKey,tt).subarray(0,32),encrypt:et.chaCha20Poly1305Encrypt,decrypt:et.chaCha20Poly1305Decrypt,hash:et.hashSHA256,hkdf:et.getHKDF}}const uint16BEEncode=et=>{const o=allocUnsafe$a(2);return o[0]=et>>8,o[1]=et,o};uint16BEEncode.bytes=2;const uint16BEDecode=et=>{if(et.length<2)throw RangeError("Could not decode int16BE");if(et instanceof Uint8Array){let o=0;return o+=et[0]<<8,o+=et[1],o}return et.getUint16(0)};uint16BEDecode.bytes=2;function registerMetrics(et){return{xxHandshakeSuccesses:et.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:et.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:et.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:et.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:et.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}function coerce$f(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$m(et){return new TextEncoder().encode(et)}function toString$n(et){return new TextDecoder().decode(et)}function base$g(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$g=base$g,_brrp__multiformats_scope_baseX$f=src$g;let Encoder$g=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$g=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$h(this,o)}},ComposedDecoder$f=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$h(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$h(et,o){return new ComposedDecoder$f({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$f=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$g(o,tt,rt),this.decoder=new Decoder$g(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$g({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$f(et,o,tt,rt)}function baseX$f({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$f(tt,et);return from$g({prefix:o,name:et,encode:rt,decode:ot=>coerce$f(nt(ot))})}function decode$E(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$y(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$b=alphabet$b.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$x(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$b[tt],o),"")}function decode$D(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$b[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$m=from$g({prefix:"🚀",name:"base256emoji",encode:encode$x,decode:decode$D}),base256emoji$n=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$m},Symbol.toStringTag,{value:"Module"})),base32$q=rfc4648$e({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$b=rfc4648$e({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$b=rfc4648$e({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$b=rfc4648$e({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$b=rfc4648$e({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$b=rfc4648$e({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$b=rfc4648$e({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$b=rfc4648$e({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$b=rfc4648$e({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$r=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$q,base32hex:base32hex$b,base32hexpad:base32hexpad$b,base32hexpadupper:base32hexpadupper$b,base32hexupper:base32hexupper$b,base32pad:base32pad$b,base32padupper:base32padupper$b,base32upper:base32upper$b,base32z:base32z$b},Symbol.toStringTag,{value:"Module"})),base36$n=baseX$f({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$b=baseX$f({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$o=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$n,base36upper:base36upper$b},Symbol.toStringTag,{value:"Module"})),base58btc$f=baseX$f({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$b=baseX$f({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$b=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$f,base58flickr:base58flickr$b},Symbol.toStringTag,{value:"Module"})),base64$p=rfc4648$e({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$b=rfc4648$e({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$c=rfc4648$e({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$b=rfc4648$e({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$q=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$p,base64pad:base64pad$b,base64url:base64url$c,base64urlpad:base64urlpad$b},Symbol.toStringTag,{value:"Module"})),base8$m=rfc4648$e({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$n=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$m},Symbol.toStringTag,{value:"Module"})),identity$b=from$g({prefix:"\0",name:"identity",encode:et=>toString$n(et),decode:et=>fromString$m(et)}),identityBase$b=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$b},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$b={...identityBase$b,...base2$n,...base8$n,...base10$n,...base16$n,...base32$r,...base36$o,...base58$b,...base64$q,...base256emoji$n};function createCodec$b(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$f=createCodec$b("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$b=createCodec$b("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$a(et.length);for(let tt=0;ttnt+ot.length,0));const tt=allocUnsafe$a(o);let rt=0;for(const nt of et)tt.set(nt,rt),rt+=nt.length;return tt}function fromString$l(et,o="utf8"){const tt=BASES$b[o];if(tt==null)throw new Error(`Unsupported encoding "${o}"`);return tt.decoder.decode(`${tt.prefix}${et}`)}const ss=class ss extends Error{constructor(tt="Invalid crypto exchange"){super(tt);wt(this,"code");this.code=ss.code}};wt(ss,"code","ERR_INVALID_CRYPTO_EXCHANGE");let InvalidCryptoExchangeError=ss;const MIN_NONCE=0,MAX_NONCE=4294967295,ERR_MAX_NONCE="Cipherstate has reached maximum n, a new handshake must be performed";class Nonce{constructor(o=MIN_NONCE){wt(this,"n");wt(this,"bytes");wt(this,"view");this.n=o,this.bytes=alloc$4(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>MAX_NONCE)throw new Error(ERR_MAX_NONCE)}}const ZEROLEN=alloc$4(0);class CipherState{constructor(o,tt=void 0,rt=0){wt(this,"k");wt(this,"n");wt(this,"crypto");this.crypto=o,this.k=tt,this.n=new Nonce(rt)}hasKey(){return!!this.k}encryptWithAd(o,tt){if(!this.hasKey())return tt;this.n.assertValue();const rt=this.crypto.encrypt(tt,this.n.getBytes(),o,this.k);return this.n.increment(),rt}decryptWithAd(o,tt,rt){if(!this.hasKey())return tt;this.n.assertValue();const nt=this.crypto.decrypt(tt,this.n.getBytes(),o,this.k,rt);return this.n.increment(),nt}}class SymmetricState{constructor(o,tt){wt(this,"cs");wt(this,"ck");wt(this,"h");wt(this,"crypto");this.crypto=o;const rt=fromString$l(tt,"utf-8");this.h=hashProtocolName(o,rt),this.ck=this.h,this.cs=new CipherState(o)}mixKey(o){const[tt,rt]=this.crypto.hkdf(this.ck,o);this.ck=tt,this.cs=new CipherState(this.crypto,rt)}mixHash(o){this.h=this.crypto.hash(new Uint8ArrayList(this.h,o))}encryptAndHash(o){const tt=this.cs.encryptWithAd(this.h,o);return this.mixHash(tt),tt}decryptAndHash(o){const tt=this.cs.decryptWithAd(this.h,o);return this.mixHash(o),tt}split(){const[o,tt]=this.crypto.hkdf(this.ck,ZEROLEN);return[new CipherState(this.crypto,o),new CipherState(this.crypto,tt)]}}class AbstractHandshakeState{constructor(o){wt(this,"ss");wt(this,"s");wt(this,"e");wt(this,"rs");wt(this,"re");wt(this,"initiator");wt(this,"crypto");const{crypto:tt,protocolName:rt,prologue:nt,initiator:ot,s:it,e:st,rs:at,re:ct}=o;this.crypto=tt,this.ss=new SymmetricState(tt,rt),this.ss.mixHash(nt),this.initiator=ot,this.s=it,this.e=st,this.rs=at,this.re=ct}writeE(){if(this.e)throw new Error("ephemeral keypair is already set");const o=this.crypto.generateKeypair();return this.ss.mixHash(o.publicKey),this.e=o,o.publicKey}writeS(){if(!this.s)throw new Error("static keypair is not set");return this.ss.encryptAndHash(this.s.publicKey)}writeEE(){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.re))}writeES(){if(this.initiator){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}else{if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}}writeSE(){if(this.initiator){if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}else{if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}}readE(o,tt=0){if(this.re)throw new Error("remote ephemeral public key is already set");if(o.byteLength(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.webtransportCerthashes!=null)for(const ot of tt.webtransportCerthashes)rt.uint32(10),rt.bytes(ot);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt)=>{const nt={webtransportCerthashes:[]},ot=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{nt.webtransportCerthashes.push(tt.bytes());break}default:{tt.skipType(it&7);break}}}return nt})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=tt=>decodeMessage(tt,et.codec())})(NoiseExtensions||(NoiseExtensions={}));var NoiseHandshakePayload;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.identityKey!=null&&tt.identityKey.byteLength>0&&(rt.uint32(10),rt.bytes(tt.identityKey)),tt.identitySig!=null&&tt.identitySig.byteLength>0&&(rt.uint32(18),rt.bytes(tt.identitySig)),tt.extensions!=null&&(rt.uint32(34),NoiseExtensions.codec().encode(tt.extensions,rt)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt)=>{const nt={identityKey:alloc$4(0),identitySig:alloc$4(0)},ot=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{nt.identityKey=tt.bytes();break}case 2:{nt.identitySig=tt.bytes();break}case 4:{nt.extensions=NoiseExtensions.codec().decode(tt,tt.uint32());break}default:{tt.skipType(it&7);break}}}return nt})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=tt=>decodeMessage(tt,et.codec())})(NoiseHandshakePayload||(NoiseHandshakePayload={}));async function createHandshakePayload(et,o,tt){const rt=await et.sign(getSignaturePayload(o));return NoiseHandshakePayload.encode({identityKey:publicKeyToProtobuf(et.publicKey),identitySig:rt,extensions:tt})}async function decodeHandshakePayload(et,o,tt){try{const rt=NoiseHandshakePayload.decode(et),nt=publicKeyFromProtobuf(rt.identityKey);if((tt==null?void 0:tt.equals(nt))===!1)throw new Error(`Payload identity key ${nt} does not match expected remote identity key ${tt}`);if(!o)throw new Error("Remote static does not exist");const ot=getSignaturePayload(o);if(!await nt.verify(ot,rt.identitySig))throw new Error("Invalid payload signature");return rt}catch(rt){throw new UnexpectedPeerError(rt.message)}}function getSignaturePayload(et){const o=fromString$l("noise-libp2p-static-key:");return et instanceof Uint8Array?concat$1([o,et],o.length+et.length):(et.prepend(o),et)}async function performHandshakeInitiator(et,o){const{log:tt,connection:rt,crypto:nt,privateKey:ot,prologue:it,s:st,remoteIdentityKey:at,extensions:ct}=et,lt=await createHandshakePayload(ot,st.publicKey,ct),dt=new XXHandshakeState({crypto:nt,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!0,prologue:it,s:st});logLocalStaticKeys(dt.s,tt),tt.trace("Stage 0 - Initiator starting to send first message."),await rt.write(dt.writeMessageA(ZEROLEN),o),tt.trace("Stage 0 - Initiator finished sending first message."),logLocalEphemeralKeys(dt.e,tt),tt.trace("Stage 1 - Initiator waiting to receive first message from responder...");const ht=dt.readMessageB(await rt.read(o));tt.trace("Stage 1 - Initiator received the message."),logRemoteEphemeralKey(dt.re,tt),logRemoteStaticKey(dt.rs,tt),tt.trace("Initiator going to check remote's signature...");const mt=await decodeHandshakePayload(ht,dt.rs,at);tt.trace("All good with the signature!"),tt.trace("Stage 2 - Initiator sending third handshake message."),await rt.write(dt.writeMessageC(lt),o),tt.trace("Stage 2 - Initiator sent message with signed payload.");const[ft,pt]=dt.ss.split();return logCipherState(ft,pt,tt),{payload:mt,encrypt:yt=>ft.encryptWithAd(ZEROLEN,yt),decrypt:(yt,gt)=>pt.decryptWithAd(ZEROLEN,yt,gt)}}async function performHandshakeResponder(et,o){const{log:tt,connection:rt,crypto:nt,privateKey:ot,prologue:it,s:st,remoteIdentityKey:at,extensions:ct}=et,lt=await createHandshakePayload(ot,st.publicKey,ct),dt=new XXHandshakeState({crypto:nt,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!1,prologue:it,s:st});logLocalStaticKeys(dt.s,tt),tt.trace("Stage 0 - Responder waiting to receive first message."),dt.readMessageA(await rt.read(o)),tt.trace("Stage 0 - Responder received first message."),logRemoteEphemeralKey(dt.re,tt),tt.trace("Stage 1 - Responder sending out first message with signed payload and static key."),await rt.write(dt.writeMessageB(lt),o),tt.trace("Stage 1 - Responder sent the second handshake message with signed payload."),logLocalEphemeralKeys(dt.e,tt),tt.trace("Stage 2 - Responder waiting for third handshake message...");const ht=dt.readMessageC(await rt.read(o));tt.trace("Stage 2 - Responder received the message, finished handshake.");const mt=await decodeHandshakePayload(ht,dt.rs,at),[ft,pt]=dt.ss.split();return logCipherState(ft,pt,tt),{payload:mt,encrypt:yt=>pt.encryptWithAd(ZEROLEN,yt),decrypt:(yt,gt)=>ft.decryptWithAd(ZEROLEN,yt,gt)}}const CHACHA_TAG_LENGTH=16;function encryptStream(et,o){return async function*(tt){for await(const rt of tt)for(let nt=0;ntrt.length&&(ot=rt.length);let it;rt instanceof Uint8Array?it=et.encrypt(rt.subarray(nt,ot)):it=et.encrypt(rt.sublist(nt,ot)),o==null||o.encryptedPackets.increment(),yield new Uint8ArrayList(uint16BEEncode(it.byteLength),it)}}}function decryptStream(et,o){return async function*(tt){for await(const rt of tt)for(let nt=0;ntrt.length&&(ot=rt.length),ot-CHACHA_TAG_LENGTHdecode$U(it,{lengthDecoder:uint16BEDecode}),decryptStream(tt,this.metrics),rt),nt}}function noise(et={}){return o=>new Noise(o,et)}const peerDiscoverySymbol$1=Symbol.for("@libp2p/peer-discovery");function setMaxListeners$7(){}const setMaxListeners$6=(et,...o)=>{try{[...o]}catch{}};var Zr,El;let TypedEventEmitter$2=(El=class extends EventTarget{constructor(){super();fr(this,Zr,new Map);setMaxListeners$6(1/0,this)}listenerCount(tt){const rt=Ot(this,Zr).get(tt);return rt==null?0:rt.length}addEventListener(tt,rt,nt){super.addEventListener(tt,rt,nt);let ot=Ot(this,Zr).get(tt);ot==null&&(ot=[],Ot(this,Zr).set(tt,ot)),ot.push({callback:rt,once:(nt!==!0&&nt!==!1&&(nt==null?void 0:nt.once))??!1})}removeEventListener(tt,rt,nt){super.removeEventListener(tt.toString(),rt??null,nt);let ot=Ot(this,Zr).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==rt),Ot(this,Zr).set(tt,ot))}dispatchEvent(tt){const rt=super.dispatchEvent(tt);let nt=Ot(this,Zr).get(tt.type);return nt==null||(nt=nt.filter(({once:ot})=>!ot),Ot(this,Zr).set(tt.type,nt)),rt}safeDispatchEvent(tt,rt={}){return this.dispatchEvent(new CustomEvent(tt,rt))}},Zr=new WeakMap,El);const serviceCapabilities$4=Symbol.for("@libp2p/service-capabilities"),DNS4=base$f("dns4"),DNS6=base$f("dns6"),DNSADDR=base$f("dnsaddr"),DNS$1=or$g(base$f("dns"),DNSADDR,DNS4,DNS6),IP=or$g(base$f("ip4"),base$f("ip6")),TCP$1=or$g(and$1(IP,base$f("tcp")),and$1(DNS$1,base$f("tcp"))),UDP=and$1(IP,base$f("udp")),UTP=and$1(UDP,base$f("utp")),QUIC=and$1(UDP,base$f("quic")),QUICV1=and$1(UDP,base$f("quic-v1")),_WebSockets$1=or$g(and$1(TCP$1,base$f("ws")),and$1(DNS$1,base$f("ws"))),WebSockets$2=or$g(and$1(_WebSockets$1,base$f("p2p")),_WebSockets$1),_WebSocketsSecure$1=or$g(and$1(TCP$1,base$f("wss")),and$1(DNS$1,base$f("wss")),and$1(TCP$1,base$f("tls"),base$f("ws")),and$1(DNS$1,base$f("tls"),base$f("ws"))),WebSocketsSecure$1=or$g(and$1(_WebSocketsSecure$1,base$f("p2p")),_WebSocketsSecure$1),HTTP=or$g(and$1(TCP$1,base$f("http")),and$1(IP,base$f("http")),and$1(DNS$1,base$f("http"))),HTTPS=or$g(and$1(TCP$1,base$f("https")),and$1(IP,base$f("https")),and$1(DNS$1,base$f("https"))),_WebRTCDirect$1=and$1(UDP,base$f("webrtc-direct"),base$f("certhash")),WebRTCDirect$1=or$g(and$1(_WebRTCDirect$1,base$f("p2p")),_WebRTCDirect$1),_WebTransport$1=and$1(QUICV1,base$f("webtransport"),base$f("certhash"),base$f("certhash")),WebTransport$1=or$g(and$1(_WebTransport$1,base$f("p2p")),_WebTransport$1),P2PWebRTCStar=or$g(and$1(WebSockets$2,base$f("p2p-webrtc-star"),base$f("p2p")),and$1(WebSocketsSecure$1,base$f("p2p-webrtc-star"),base$f("p2p")),and$1(WebSockets$2,base$f("p2p-webrtc-star")),and$1(WebSocketsSecure$1,base$f("p2p-webrtc-star"))),P2PWebRTCDirect=or$g(and$1(HTTP,base$f("p2p-webrtc-direct"),base$f("p2p")),and$1(HTTPS,base$f("p2p-webrtc-direct"),base$f("p2p")),and$1(HTTP,base$f("p2p-webrtc-direct")),and$1(HTTPS,base$f("p2p-webrtc-direct"))),Reliable=or$g(_WebSockets$1,_WebSocketsSecure$1,HTTP,HTTPS,P2PWebRTCStar,P2PWebRTCDirect,TCP$1,UTP,QUIC,DNS$1,WebRTCDirect$1,WebTransport$1),_P2P$1=or$g(and$1(Reliable,base$f("p2p")),P2PWebRTCStar,P2PWebRTCDirect,WebRTCDirect$1,WebTransport$1,base$f("p2p")),_Circuit$1=or$g(and$1(_P2P$1,base$f("p2p-circuit"),_P2P$1),and$1(_P2P$1,base$f("p2p-circuit")),and$1(base$f("p2p-circuit"),_P2P$1),and$1(Reliable,base$f("p2p-circuit")),and$1(base$f("p2p-circuit"),Reliable),base$f("p2p-circuit")),CircuitRecursive=()=>or$g(and$1(_Circuit$1,CircuitRecursive),_Circuit$1),Circuit$1=CircuitRecursive(),P2P=or$g(and$1(Circuit$1,_P2P$1,Circuit$1),and$1(_P2P$1,Circuit$1),and$1(Circuit$1,_P2P$1),Circuit$1,_P2P$1);function makeMatchesFunction(et){function o(tt){let rt;try{rt=multiaddr(tt)}catch{return!1}const nt=et(rt.protoNames());return nt===null?!1:nt===!0||nt===!1?nt:nt.length===0}return o}function and$1(...et){function o(tt){if(tt.length(rt=typeof nt=="function"?nt().partialMatch(tt):nt.partialMatch(tt),Array.isArray(rt)&&(tt=rt),rt===null)),rt}return{toString:function(){return"{ "+et.join(" ")+" }"},input:et,matches:makeMatchesFunction(o),partialMatch:o}}function or$g(...et){function o(rt){let nt=null;return et.some(ot=>{const it=typeof ot=="function"?ot().partialMatch(rt):ot.partialMatch(rt);return it!=null?(nt=it,!0):!1}),nt}return{toString:function(){return"{ "+et.join(" ")+" }"},input:et,matches:makeMatchesFunction(o),partialMatch:o}}function base$f(et){const o=et;function tt(nt){let ot;try{ot=multiaddr(nt)}catch{return!1}const it=ot.protoNames();return it.length===1&&it[0]===o}function rt(nt){return nt.length===0?null:nt[0]===o?nt.slice(1):null}return{toString:function(){return o},matches:tt,partialMatch:rt}}const DEFAULT_BOOTSTRAP_TAG_NAME$1="bootstrap",DEFAULT_BOOTSTRAP_TAG_VALUE$1=50,DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT=1e3;var Cl,Sl,Al,$l;class Bootstrap extends($l=TypedEventEmitter$2,Al=peerDiscoverySymbol$1,Sl=Symbol.toStringTag,Cl=serviceCapabilities$4,$l){constructor(tt,rt={list:[]}){if(rt.list==null||rt.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super();wt(this,"log");wt(this,"timer");wt(this,"list");wt(this,"timeout");wt(this,"components");wt(this,"_init");wt(this,Al,this);wt(this,Sl,"@libp2p/bootstrap");wt(this,Cl,["@libp2p/peer-discovery"]);this.components=tt,this.log=tt.logger.forComponent("libp2p:bootstrap"),this.timeout=rt.timeout??DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT,this.list=[];for(const nt of rt.list){if(!P2P.matches(nt)){this.log.error("Invalid multiaddr");continue}const ot=multiaddr(nt),it=ot.getPeerId();if(it==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}const st={id:peerIdFromString$1(it),multiaddrs:[ot]};this.list.push(st)}this._init=rt}isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(tt=>{this.log.error(tt)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(const tt of this.list){if(await this.components.peerStore.merge(tt.id,{tags:{[this._init.tagName??DEFAULT_BOOTSTRAP_TAG_NAME$1]:{value:this._init.tagValue??DEFAULT_BOOTSTRAP_TAG_VALUE$1,ttl:this._init.tagTTL}},multiaddrs:tt.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:tt}),this.components.connectionManager.openConnection(tt.id).catch(rt=>{this.log.error("could not dial bootstrap peer %p",tt.id,rt)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}}wt(Bootstrap,"tag","bootstrap");function bootstrap(et){return o=>new Bootstrap(o,et)}var bs;let UnsupportedProtocolError$1=(bs=class extends Error{constructor(o="Unsupported protocol error"){super(o),this.name="UnsupportedProtocolError"}},wt(bs,"name","UnsupportedProtocolError"),bs);var ys;let InvalidMessageError$2=(ys=class extends Error{constructor(o="Invalid message"){super(o),this.name="InvalidMessageError"}},wt(ys,"name","InvalidMessageError"),ys);function setMaxListeners$5(){}const setMaxListeners$4=(et,...o)=>{try{[...o]}catch{}},serviceCapabilities$3=Symbol.for("@libp2p/service-capabilities");function equals$5(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$f=base$e,_brrp__multiformats_scope_baseX$e=src$f;let Encoder$f=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$f=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$f(this,o)}},ComposedDecoder$e=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$f(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$f(et,o){return new ComposedDecoder$e({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$e=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$f(o,tt,rt),this.decoder=new Decoder$f(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$f({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$e(et,o,tt,rt)}function baseX$e({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$e(tt,et);return from$f({prefix:o,name:et,encode:rt,decode:ot=>coerce$e(nt(ot))})}function decode$C(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$w(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$a=alphabet$a.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$v(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$a[tt],o),"")}function decode$B(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$a[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$k=from$f({prefix:"🚀",name:"base256emoji",encode:encode$v,decode:decode$B}),base256emoji$l=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$k},Symbol.toStringTag,{value:"Module"})),base32$o=rfc4648$d({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$a=rfc4648$d({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$a=rfc4648$d({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$a=rfc4648$d({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$a=rfc4648$d({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$a=rfc4648$d({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$a=rfc4648$d({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$a=rfc4648$d({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$a=rfc4648$d({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$p=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$o,base32hex:base32hex$a,base32hexpad:base32hexpad$a,base32hexpadupper:base32hexpadupper$a,base32hexupper:base32hexupper$a,base32pad:base32pad$a,base32padupper:base32padupper$a,base32upper:base32upper$a,base32z:base32z$a},Symbol.toStringTag,{value:"Module"})),base36$l=baseX$e({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$a=baseX$e({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$m=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$l,base36upper:base36upper$a},Symbol.toStringTag,{value:"Module"})),base58btc$e=baseX$e({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$a=baseX$e({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$a=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$e,base58flickr:base58flickr$a},Symbol.toStringTag,{value:"Module"})),base64$n=rfc4648$d({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$a=rfc4648$d({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$b=rfc4648$d({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$a=rfc4648$d({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$o=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$n,base64pad:base64pad$a,base64url:base64url$b,base64urlpad:base64urlpad$a},Symbol.toStringTag,{value:"Module"})),base8$k=rfc4648$d({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$l=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$k},Symbol.toStringTag,{value:"Module"})),identity$a=from$f({prefix:"\0",name:"identity",encode:et=>toString$l(et),decode:et=>fromString$k(et)}),identityBase$a=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$a},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;var encode_1$2=encode$u,MSB$4=128,REST$4=127,MSBALL$2=~REST$4,INT$2=Math.pow(2,31);function encode$u(et,o,tt){o=o||[],tt=tt||0;for(var rt=tt;et>=INT$2;)o[tt++]=et&255|MSB$4,et/=128;for(;et&MSBALL$2;)o[tt++]=et&255|MSB$4,et>>>=7;return o[tt]=et|0,encode$u.bytes=tt-rt+1,o}var decode$A=read$3,MSB$1$2=128,REST$1$2=127;function read$3(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$3.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$2)<=MSB$1$2);return read$3.bytes=ot-rt,tt}var N1$2=Math.pow(2,7),N2$2=Math.pow(2,14),N3$2=Math.pow(2,21),N4$2=Math.pow(2,28),N5$2=Math.pow(2,35),N6$2=Math.pow(2,42),N7$2=Math.pow(2,49),N8$2=Math.pow(2,56),N9$2=Math.pow(2,63),length$2=function(et){return et"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$a=createCodec$a("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$9(et.length);for(let tt=0;tt(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.publicKey!=null&&tt.publicKey.byteLength>0&&(rt.uint32(10),rt.bytes(tt.publicKey)),tt.payloadType!=null&&tt.payloadType.byteLength>0&&(rt.uint32(18),rt.bytes(tt.payloadType)),tt.payload!=null&&tt.payload.byteLength>0&&(rt.uint32(26),rt.bytes(tt.payload)),tt.signature!=null&&tt.signature.byteLength>0&&(rt.uint32(42),rt.bytes(tt.signature)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={publicKey:alloc$3(0),payloadType:alloc$3(0),payload:alloc$3(0),signature:alloc$3(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.publicKey=tt.bytes();break}case 2:{ot.payloadType=tt.bytes();break}case 3:{ot.payload=tt.bytes();break}case 5:{ot.signature=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Envelope||(Envelope={}));class InvalidSignatureError extends Error{constructor(o="Invalid signature"){super(o),this.name="InvalidSignatureError"}}const dn=class dn{constructor(o){wt(this,"publicKey");wt(this,"payloadType");wt(this,"payload");wt(this,"signature");wt(this,"marshaled");const{publicKey:tt,payloadType:rt,payload:nt,signature:ot}=o;this.publicKey=tt,this.payloadType=rt,this.payload=nt,this.signature=ot}marshal(){return this.marshaled==null&&(this.marshaled=Envelope.encode({publicKey:publicKeyToProtobuf(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(o){return equals$5(this.marshal(),o.marshal())}async validate(o){const tt=formatSignaturePayload(o,this.payloadType,this.payload);return this.publicKey.verify(tt.subarray(),this.signature)}};wt(dn,"createFromProtobuf",async o=>{const tt=Envelope.decode(o),rt=publicKeyFromProtobuf(tt.publicKey);return new dn({publicKey:rt,payloadType:tt.payloadType,payload:tt.payload,signature:tt.signature})}),wt(dn,"seal",async(o,tt)=>{if(tt==null)throw new Error("Missing private key");const rt=o.domain,nt=o.codec,ot=o.marshal(),it=formatSignaturePayload(rt,nt,ot),st=await tt.sign(it.subarray());return new dn({publicKey:tt.publicKey,payloadType:nt,payload:ot,signature:st})}),wt(dn,"openAndCertify",async(o,tt)=>{const rt=await dn.createFromProtobuf(o);if(!await rt.validate(tt))throw new InvalidSignatureError("Envelope signature is not valid for the given domain");return rt});let RecordEnvelope=dn;const formatSignaturePayload=(et,o,tt)=>{const rt=fromString$j(et),nt=encode$P(rt.byteLength),ot=encode$P(o.length),it=encode$P(tt.length);return new Uint8ArrayList(nt,rt,ot,o,it,tt)};function arrayEquals(et,o){const tt=(rt,nt)=>rt.toString().localeCompare(nt.toString());return et.length!==o.length?!1:(o.sort(tt),et.sort(tt).every((rt,nt)=>o[nt].equals(rt)))}const ENVELOPE_DOMAIN_PEER_RECORD="libp2p-peer-record",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD=Uint8Array.from([3,1]);var PeerRecord$1;(function(et){(function(tt){let rt;tt.codec=()=>(rt==null&&(rt=message$1((nt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),nt.multiaddr!=null&&nt.multiaddr.byteLength>0&&(ot.uint32(10),ot.bytes(nt.multiaddr)),it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{const st={multiaddr:alloc$3(0)},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.multiaddr=nt.bytes();break}default:{nt.skipType(ct&7);break}}}return st})),rt),tt.encode=nt=>encodeMessage(nt,tt.codec()),tt.decode=(nt,ot)=>decodeMessage(nt,tt.codec(),ot)})(et.AddressInfo||(et.AddressInfo={}));let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.peerId!=null&&tt.peerId.byteLength>0&&(rt.uint32(10),rt.bytes(tt.peerId)),tt.seq!=null&&tt.seq!==0n&&(rt.uint32(16),rt.uint64(tt.seq)),tt.addresses!=null)for(const ot of tt.addresses)rt.uint32(26),et.AddressInfo.codec().encode(ot,rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={peerId:alloc$3(0),seq:0n,addresses:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.peerId=tt.bytes();break}case 2:{ot.seq=tt.uint64();break}case 3:{if(((st=nt.limits)==null?void 0:st.addresses)!=null&&ot.addresses.length===nt.limits.addresses)throw new MaxLengthError('Decode error - map field "addresses" had too many elements');ot.addresses.push(et.AddressInfo.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.addresses$}));break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(PeerRecord$1||(PeerRecord$1={}));const on=class on{constructor(o){wt(this,"peerId");wt(this,"multiaddrs");wt(this,"seqNumber");wt(this,"domain",on.DOMAIN);wt(this,"codec",on.CODEC);wt(this,"marshaled");const{peerId:tt,multiaddrs:rt,seqNumber:nt}=o;this.peerId=tt,this.multiaddrs=rt??[],this.seqNumber=nt??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=PeerRecord$1.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(o=>({multiaddr:o.bytes}))})),this.marshaled}equals(o){return!(!(o instanceof on)||!this.peerId.equals(o.peerId)||this.seqNumber!==o.seqNumber||!arrayEquals(this.multiaddrs,o.multiaddrs))}};wt(on,"createFromProtobuf",o=>{const tt=PeerRecord$1.decode(o),rt=peerIdFromMultihash(decode$y(tt.peerId)),nt=(tt.addresses??[]).map(it=>multiaddr(it.multiaddr)),ot=tt.seq;return new on({peerId:rt,multiaddrs:nt,seqNumber:ot})}),wt(on,"DOMAIN",ENVELOPE_DOMAIN_PEER_RECORD),wt(on,"CODEC",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD);let PeerRecord=on;function isAsyncIterable$4(et){return et[Symbol.asyncIterator]!=null}function drain(et){if(isAsyncIterable$4(et))return(async()=>{for await(const o of et);})();for(const o of et);}const CustomEvent$1=globalThis.CustomEvent??Event;async function*parallel(et,o={}){let tt=o.concurrency??1/0;tt<1&&(tt=1/0);const rt=o.ordered==null?!1:o.ordered,nt=new EventTarget,ot=[];let it=pDefer(),st=pDefer(),at=!1,ct,lt=!1;nt.addEventListener("task-complete",()=>{st.resolve()}),Promise.resolve().then(async()=>{try{for await(const ft of et){if(ot.length===tt&&(it=pDefer(),await it.promise),lt)break;const pt={done:!1};ot.push(pt),ft().then(yt=>{pt.done=!0,pt.ok=!0,pt.value=yt,nt.dispatchEvent(new CustomEvent$1("task-complete"))},yt=>{pt.done=!0,pt.err=yt,nt.dispatchEvent(new CustomEvent$1("task-complete"))})}at=!0,nt.dispatchEvent(new CustomEvent$1("task-complete"))}catch(ft){ct=ft,nt.dispatchEvent(new CustomEvent$1("task-complete"))}});function dt(){var ft;return rt?(ft=ot[0])==null?void 0:ft.done:!!ot.find(pt=>pt.done)}function*ht(){for(;ot.length>0&&ot[0].done;){const ft=ot[0];if(ot.shift(),ft.ok)yield ft.value;else throw lt=!0,it.resolve(),ft.err;it.resolve()}}function*mt(){for(;dt();)for(let ft=0;ft{const it=await tt.read(ot);return nt.decode(it)},write:async(nt,ot,it)=>{await tt.write(ot.encode(nt),it)},writeV:async(nt,ot,it)=>{await tt.writeV(nt.map(st=>ot.encode(st)),it)},pb:nt=>({read:async ot=>rt.read(nt,ot),write:async(ot,it)=>rt.write(ot,nt,it),writeV:async(ot,it)=>rt.writeV(ot,nt,it),unwrap:()=>rt}),unwrap:()=>tt.unwrap()};return rt}function coerce$d(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$i(et){return new TextEncoder().encode(et)}function toString$k(et){return new TextDecoder().decode(et)}function base$d(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$e=base$d,_brrp__multiformats_scope_baseX$d=src$e;let Encoder$e=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$e=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$e(this,o)}},ComposedDecoder$d=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$e(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$e(et,o){return new ComposedDecoder$d({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$d=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$e(o,tt,rt),this.decoder=new Decoder$e(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$e({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$d(et,o,tt,rt)}function baseX$d({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$d(tt,et);return from$e({prefix:o,name:et,encode:rt,decode:ot=>coerce$d(nt(ot))})}function decode$x(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$t(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$9=alphabet$9.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$s(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$9[tt],o),"")}function decode$w(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$9[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$i=from$e({prefix:"🚀",name:"base256emoji",encode:encode$s,decode:decode$w}),base256emoji$j=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$i},Symbol.toStringTag,{value:"Module"})),base32$m=rfc4648$c({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$9=rfc4648$c({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$9=rfc4648$c({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$9=rfc4648$c({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$9=rfc4648$c({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$9=rfc4648$c({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$9=rfc4648$c({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$9=rfc4648$c({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$9=rfc4648$c({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$n=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$m,base32hex:base32hex$9,base32hexpad:base32hexpad$9,base32hexpadupper:base32hexpadupper$9,base32hexupper:base32hexupper$9,base32pad:base32pad$9,base32padupper:base32padupper$9,base32upper:base32upper$9,base32z:base32z$9},Symbol.toStringTag,{value:"Module"})),base36$j=baseX$d({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$9=baseX$d({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$k=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$j,base36upper:base36upper$9},Symbol.toStringTag,{value:"Module"})),base58btc$d=baseX$d({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$9=baseX$d({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$9=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$d,base58flickr:base58flickr$9},Symbol.toStringTag,{value:"Module"})),base64$l=rfc4648$c({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$9=rfc4648$c({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$a=rfc4648$c({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$9=rfc4648$c({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$m=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$l,base64pad:base64pad$9,base64url:base64url$a,base64urlpad:base64urlpad$9},Symbol.toStringTag,{value:"Module"})),base8$i=rfc4648$c({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$j=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$i},Symbol.toStringTag,{value:"Module"})),identity$9=from$e({prefix:"\0",name:"identity",encode:et=>toString$k(et),decode:et=>fromString$i(et)}),identityBase$9=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$9},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$9={...identityBase$9,...base2$j,...base8$j,...base10$j,...base16$j,...base32$n,...base36$k,...base58$9,...base64$m,...base256emoji$j};function allocUnsafe$8(et=0){return new Uint8Array(et)}function createCodec$9(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$d=createCodec$9("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$9=createCodec$9("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$8(et.length);for(let tt=0;tt(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.protocolVersion!=null&&(rt.uint32(42),rt.string(tt.protocolVersion)),tt.agentVersion!=null&&(rt.uint32(50),rt.string(tt.agentVersion)),tt.publicKey!=null&&(rt.uint32(10),rt.bytes(tt.publicKey)),tt.listenAddrs!=null)for(const ot of tt.listenAddrs)rt.uint32(18),rt.bytes(ot);if(tt.observedAddr!=null&&(rt.uint32(34),rt.bytes(tt.observedAddr)),tt.protocols!=null)for(const ot of tt.protocols)rt.uint32(26),rt.string(ot);tt.signedPeerRecord!=null&&(rt.uint32(66),rt.bytes(tt.signedPeerRecord)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at;const ot={listenAddrs:[],protocols:[]},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 5:{ot.protocolVersion=tt.string();break}case 6:{ot.agentVersion=tt.string();break}case 1:{ot.publicKey=tt.bytes();break}case 2:{if(((st=nt.limits)==null?void 0:st.listenAddrs)!=null&&ot.listenAddrs.length===nt.limits.listenAddrs)throw new MaxLengthError('Decode error - map field "listenAddrs" had too many elements');ot.listenAddrs.push(tt.bytes());break}case 4:{ot.observedAddr=tt.bytes();break}case 3:{if(((at=nt.limits)==null?void 0:at.protocols)!=null&&ot.protocols.length===nt.limits.protocols)throw new MaxLengthError('Decode error - map field "protocols" had too many elements');ot.protocols.push(tt.string());break}case 8:{ot.signedPeerRecord=tt.bytes();break}default:{tt.skipType(ct&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Identify$1||(Identify$1={}));var define_process_default={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0};function isElectron$1(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof define_process_default<"u"&&typeof define_process_default.versions=="object"&&define_process_default.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}var isElectron_1=isElectron$1;const detectElectron=getDefaultExportFromCjs(isElectron_1),isEnvWithDom=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,isElectron=detectElectron(),isBrowser=isEnvWithDom&&!isElectron,isElectronMain=isElectron&&!isEnvWithDom,isElectronRenderer=isElectron&&isEnvWithDom,isNode=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!isElectron,isWebWorker=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",defaultValues={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:MAX_IDENTIFY_MESSAGE_SIZE,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:MAX_PUSH_CONCURRENCY};function getCleanMultiaddr(et){if(et!=null&&et.length>0)try{return multiaddr(et)}catch{}}function getAgentVersion(et,o){return o!=null||(o=`${et.name}/${et.version}`,isNode||isElectronMain?o+=` UserAgent=${globalThis.process.version}`:(isBrowser||isWebWorker||isElectronRenderer||isReactNative)&&(o+=` UserAgent=${globalThis.navigator.userAgent}`)),o}async function consumeIdentifyMessage(et,o,tt,rt,nt){if(tt("received identify from %p",rt.remotePeer),nt==null)throw new InvalidMessageError$2("message was null or undefined");const ot={};if(nt.listenAddrs.length>0&&(ot.addresses=nt.listenAddrs.map(at=>({isCertified:!1,multiaddr:multiaddr(at)}))),nt.protocols.length>0&&(ot.protocols=nt.protocols),nt.publicKey!=null){const at=publicKeyFromProtobuf(nt.publicKey);if(!peerIdFromPublicKey(at).equals(rt.remotePeer))throw new InvalidMessageError$2("public key did not match remote PeerId");ot.publicKey=at}let it;if(nt.signedPeerRecord!=null){tt.trace("received signedPeerRecord from %p",rt.remotePeer);let at=nt.signedPeerRecord;const ct=await RecordEnvelope.openAndCertify(at,PeerRecord.DOMAIN);let lt=PeerRecord.createFromProtobuf(ct.payload);const dt=peerIdFromCID(ct.publicKey.toCID());if(!lt.peerId.equals(dt))throw new InvalidMessageError$2("signing key does not match PeerId in the PeerRecord");if(!rt.remotePeer.equals(lt.peerId))throw new InvalidMessageError$2("signing key does not match remote PeerId");let ht;try{ht=await et.get(lt.peerId)}catch(mt){if(mt.name!=="NotFoundError")throw mt}if(ht!=null&&(ot.metadata=ht.metadata,ht.peerRecordEnvelope!=null)){const mt=await RecordEnvelope.createFromProtobuf(ht.peerRecordEnvelope),ft=PeerRecord.createFromProtobuf(mt.payload);ft.seqNumber>=lt.seqNumber&&(tt("sequence number was lower or equal to existing sequence number - stored: %d received: %d",ft.seqNumber,lt.seqNumber),lt=ft,at=ht.peerRecordEnvelope)}ot.peerRecordEnvelope=at,ot.addresses=lt.multiaddrs.map(mt=>({isCertified:!0,multiaddr:mt})),it={seq:lt.seqNumber,addresses:lt.multiaddrs}}else tt("%p did not send a signed peer record",rt.remotePeer);if(tt.trace("patching %p with",rt.remotePeer,ot),await et.patch(rt.remotePeer,ot),nt.agentVersion!=null||nt.protocolVersion!=null){const at={};nt.agentVersion!=null&&(at.AgentVersion=fromString$h(nt.agentVersion)),nt.protocolVersion!=null&&(at.ProtocolVersion=fromString$h(nt.protocolVersion)),tt.trace("merging %p metadata",rt.remotePeer,at),await et.merge(rt.remotePeer,{metadata:at})}const st={peerId:rt.remotePeer,protocolVersion:nt.protocolVersion,agentVersion:nt.agentVersion,publicKey:nt.publicKey,listenAddrs:nt.listenAddrs.map(at=>multiaddr(at)),observedAddr:nt.observedAddr==null?void 0:multiaddr(nt.observedAddr),protocols:nt.protocols,signedPeerRecord:it,connection:rt};return o.safeDispatchEvent("peer:identify",{detail:st}),st}class AbstractIdentify{constructor(o,tt){wt(this,"host");wt(this,"protocol");wt(this,"started");wt(this,"timeout");wt(this,"peerId");wt(this,"privateKey");wt(this,"peerStore");wt(this,"registrar");wt(this,"addressManager");wt(this,"maxInboundStreams");wt(this,"maxOutboundStreams");wt(this,"maxMessageSize");wt(this,"maxObservedAddresses");wt(this,"events");wt(this,"runOnLimitedConnection");wt(this,"log");this.protocol=tt.protocol,this.started=!1,this.peerId=o.peerId,this.privateKey=o.privateKey,this.peerStore=o.peerStore,this.registrar=o.registrar,this.addressManager=o.addressManager,this.events=o.events,this.log=tt.log,this.timeout=tt.timeout??defaultValues.timeout,this.maxInboundStreams=tt.maxInboundStreams??defaultValues.maxInboundStreams,this.maxOutboundStreams=tt.maxOutboundStreams??defaultValues.maxOutboundStreams,this.maxMessageSize=tt.maxMessageSize??defaultValues.maxMessageSize,this.maxObservedAddresses=tt.maxObservedAddresses??defaultValues.maxObservedAddresses,this.runOnLimitedConnection=tt.runOnLimitedConnection??defaultValues.runOnLimitedConnection,this.host={protocolVersion:`${tt.protocolPrefix??defaultValues.protocolPrefix}/${IDENTIFY_PROTOCOL_VERSION}`,agentVersion:getAgentVersion(o.nodeInfo,tt.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:fromString$h(this.host.agentVersion),ProtocolVersion:fromString$h(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,o=>{this.handleProtocol(o).catch(tt=>{this.log.error(tt)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}}var Netmask_1;(function(){var et,o,tt,rt,nt,ot,it,st;st=function(at){var ct,lt,dt,ht;return ct=(at&255<<24)>>>24,lt=(at&255<<16)>>>16,dt=(at&65280)>>>8,ht=at&255,[ct,lt,dt,ht].join(".")},it=function(at){var ct,lt,dt,ht,mt,ft;for(ct=[],dt=ht=0;ht<=3&&at.length!==0;dt=++ht){if(dt>0){if(at[0]!==".")throw new Error("Invalid IP");at=at.substring(1)}ft=o(at),mt=ft[0],lt=ft[1],at=at.substring(lt),ct.push(mt)}if(at.length!==0)throw new Error("Invalid IP");switch(ct.length){case 1:if(ct[0]>4294967295)throw new Error("Invalid IP");return ct[0]>>>0;case 2:if(ct[0]>255||ct[1]>16777215)throw new Error("Invalid IP");return(ct[0]<<24|ct[1])>>>0;case 3:if(ct[0]>255||ct[1]>255||ct[2]>65535)throw new Error("Invalid IP");return(ct[0]<<24|ct[1]<<16|ct[2])>>>0;case 4:if(ct[0]>255||ct[1]>255||ct[2]>255||ct[3]>255)throw new Error("Invalid IP");return(ct[0]<<24|ct[1]<<16|ct[2]<<8|ct[3])>>>0;default:throw new Error("Invalid IP")}},tt=function(at){return at.charCodeAt(0)},rt=tt("0"),ot=tt("a"),nt=tt("A"),o=function(at){var ct,lt,dt,ht,mt;for(ht=0,ct=10,lt="9",dt=0,at.length>1&&at[dt]==="0"&&(at[dt+1]==="x"||at[dt+1]==="X"?(dt+=2,ct=16):"0"<=at[dt+1]&&at[dt+1]<="9"&&(dt++,ct=8,lt="7")),mt=dt;dt>>0;else if(ct===16)if("a"<=at[dt]&&at[dt]<="f")ht=ht*ct+(10+tt(at[dt])-ot)>>>0;else if("A"<=at[dt]&&at[dt]<="F")ht=ht*ct+(10+tt(at[dt])-nt)>>>0;else break;else break;if(ht>4294967295)throw new Error("too large");dt++}if(dt===mt)throw new Error("empty octet");return[ht,dt]},et=function(){function at(ct,lt){var dt,ht,mt;if(typeof ct!="string")throw new Error("Missing `net' parameter");if(lt||(mt=ct.split("/",2),ct=mt[0],lt=mt[1]),lt||(lt=32),typeof lt=="string"&<.indexOf(".")>-1){try{this.maskLong=it(lt)}catch{throw new Error("Invalid mask: "+lt)}for(dt=ht=32;ht>=0;dt=--ht)if(this.maskLong===4294967295<<32-dt>>>0){this.bitmask=dt;break}}else if(lt||lt===0)this.bitmask=parseInt(lt,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(it(ct)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+ct)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+lt);this.size=Math.pow(2,32-this.bitmask),this.base=st(this.netLong),this.mask=st(this.maskLong),this.hostmask=st(~this.maskLong),this.first=this.bitmask<=30?st(this.netLong+1):this.base,this.last=this.bitmask<=30?st(this.netLong+this.size-2):st(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?st(this.netLong+this.size-1):void 0}return at.prototype.contains=function(ct){return typeof ct=="string"&&(ct.indexOf("/")>0||ct.split(".").length!==4)&&(ct=new at(ct)),ct instanceof at?this.contains(ct.base)&&this.contains(ct.broadcast||ct.last):(it(ct)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},at.prototype.next=function(ct){return ct==null&&(ct=1),new at(st(this.netLong+this.size*ct),this.mask)},at.prototype.forEach=function(ct){var lt,dt,ht;for(ht=it(this.first),dt=it(this.last),lt=0;ht<=dt;)ct(st(ht),ht,lt),lt++,ht++},at.prototype.toString=function(){return this.base+"/"+this.bitmask},at}(),Netmask_1=et}).call(commonjsGlobal);const PRIVATE_IP_RANGES=["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"],NETMASK_RANGES=PRIVATE_IP_RANGES.map(et=>new Netmask_1(et));function ipv4Check(et){for(const o of NETMASK_RANGES)if(o.contains(et))return!0;return!1}function isIpv4MappedIpv6(et){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(et)}function ipv4MappedIpv6Check(et){const o=et.split(":");if(o.length<2)return!1;const tt=o[o.length-1].padStart(4,"0"),rt=o[o.length-2].padStart(4,"0"),nt=`${parseInt(rt.substring(0,2),16)}.${parseInt(rt.substring(2),16)}.${parseInt(tt.substring(0,2),16)}.${parseInt(tt.substring(2),16)}`;return ipv4Check(nt)}function isIpv4EmbeddedIpv6(et){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(et)}function ipv4EmbeddedIpv6Check(et){const o=et.split(":"),tt=o[o.length-1];return ipv4Check(tt)}function ipv6Check(et){return/^::$/.test(et)||/^::1$/.test(et)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(et)||/^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(et)||/^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(et)||/^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(et)||/^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(et)||/^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(et)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(et)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(et)||/^ff([0-9a-fA-F]{2,2}):/i.test(et)}function isPrivateIp(et){return isIPv4(et)?ipv4Check(et):isIpv4MappedIpv6(et)?ipv4MappedIpv6Check(et):isIpv4EmbeddedIpv6(et)?ipv4EmbeddedIpv6Check(et):isIPv6(et)?ipv6Check(et):void 0}function coerce$c(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function base$c(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$d=base$c,_brrp__multiformats_scope_baseX$c=src$d;let Encoder$d=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$d=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$d(this,o)}},ComposedDecoder$c=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$d(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$d(et,o){return new ComposedDecoder$c({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$c=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$d(o,tt,rt),this.decoder=new Decoder$d(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$d({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$c(et,o,tt,rt)}function baseX$c({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$c(tt,et);return from$d({prefix:o,name:et,encode:rt,decode:ot=>coerce$c(nt(ot))})}function decode$v(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$r(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<et.toString().split("/").slice(1),func=et=>({match:o=>o.length<1?!1:et(o[0])?o.slice(1):!1,pattern:"fn"}),literal=et=>({match:o=>func(tt=>tt===et).match(o),pattern:et}),string$c=()=>({match:et=>func(o=>typeof o=="string").match(et),pattern:"{string}"}),number$1=()=>({match:et=>func(o=>!isNaN(parseInt(o))).match(et),pattern:"{number}"}),peerId=()=>({match:et=>{if(et.length<2||et[0]!=="p2p"&&et[0]!=="ipfs")return!1;if(et[1].startsWith("Q")||et[1].startsWith("1"))try{base58btc$c.decode(`z${et[1]}`)}catch{return!1}else return!1;return et.slice(2)},pattern:"/p2p/{peerid}"}),certhash=()=>({match:et=>{if(et.length<2||et[0]!=="certhash")return!1;try{base64url$9.decode(et[1])}catch{return!1}return et.slice(2)},pattern:"/certhash/{certhash}"}),optional=et=>({match:o=>{const tt=et.match(o);return tt===!1?o:tt},pattern:`optional(${et.pattern})`}),or$c=(...et)=>({match:o=>{let tt;for(const rt of et){const nt=rt.match(o);nt!==!1&&(tt==null||nt.lengtho.pattern).join(", ")})`}),and=(...et)=>({match:o=>{for(const tt of et){const rt=tt.match(o);if(rt===!1)return!1;o=rt}return o},pattern:`and(${et.map(o=>o.pattern).join(", ")})`});function fmt(...et){function o(nt){let ot=toParts(nt);for(const it of et){const st=it.match(ot);if(st===!1)return!1;ot=st}return ot}function tt(nt){return o(nt)!==!1}function rt(nt){const ot=o(nt);return ot===!1?!1:ot.length===0}return{matchers:et,matches:tt,exactMatch:rt}}const _DNS4=and(literal("dns4"),string$c()),_DNS6=and(literal("dns6"),string$c()),_DNSADDR=and(literal("dnsaddr"),string$c()),_DNS=and(literal("dns"),string$c());fmt(_DNS4,optional(peerId()));fmt(_DNS6,optional(peerId()));fmt(_DNSADDR,optional(peerId()));fmt(or$c(_DNS,_DNSADDR,_DNS4,_DNS6),optional(peerId()));const _IP4=and(literal("ip4"),func(isIPv4)),_IP6=and(literal("ip6"),func(isIPv6)),_IP=or$c(_IP4,_IP6),_IP_OR_DOMAIN=or$c(_IP,_DNS,_DNS4,_DNS6,_DNSADDR),IP_OR_DOMAIN=fmt(or$c(_IP,and(or$c(_DNS,_DNSADDR,_DNS4,_DNS6),optional(peerId())))),_TCP=and(_IP_OR_DOMAIN,literal("tcp"),number$1()),_UDP=and(_IP_OR_DOMAIN,literal("udp"),number$1()),TCP=fmt(and(_TCP,optional(peerId()))),_QUIC=and(_UDP,literal("quic")),_QUICV1=and(_UDP,literal("quic-v1")),QUIC_V0_OR_V1=or$c(_QUIC,_QUICV1),_WEB=or$c(_IP_OR_DOMAIN,_TCP,_UDP,_QUIC,_QUICV1),_WebSockets=or$c(and(_WEB,literal("ws"),optional(peerId()))),WebSockets$1=fmt(_WebSockets),_WebSocketsSecure=or$c(and(_WEB,literal("wss"),optional(peerId())),and(_WEB,literal("tls"),literal("ws"),optional(peerId()))),WebSocketsSecure=fmt(_WebSocketsSecure),_WebRTCDirect=and(_UDP,literal("webrtc-direct"),optional(certhash()),optional(certhash()),optional(peerId())),WebRTCDirect=fmt(_WebRTCDirect),_WebTransport=and(_QUICV1,literal("webtransport"),optional(certhash()),optional(certhash()),optional(peerId())),WebTransport=fmt(_WebTransport),_P2P=or$c(_WebSockets,_WebSocketsSecure,and(_TCP,optional(peerId())),and(QUIC_V0_OR_V1,optional(peerId())),and(_IP_OR_DOMAIN,optional(peerId())),_WebRTCDirect,_WebTransport,peerId()),_Circuit=and(_P2P,literal("p2p-circuit"),peerId()),Circuit=fmt(_Circuit),_WebRTC=or$c(and(_P2P,literal("p2p-circuit"),literal("webrtc"),optional(peerId())),and(_P2P,literal("webrtc"),optional(peerId())),literal("webrtc")),WebRTC=fmt(_WebRTC);or$c(and(_IP_OR_DOMAIN,literal("tcp"),number$1(),literal("http"),optional(peerId())),and(_IP_OR_DOMAIN,literal("http"),optional(peerId())));or$c(and(_IP_OR_DOMAIN,literal("tcp"),or$c(and(literal("443"),literal("http")),and(number$1(),literal("https"))),optional(peerId())),and(_IP_OR_DOMAIN,literal("tls"),literal("http"),optional(peerId())),and(_IP_OR_DOMAIN,literal("https"),optional(peerId())));var Rl,_l;class Identify extends(_l=AbstractIdentify,Rl=serviceCapabilities$3,_l){constructor(tt,rt={}){super(tt,{...rt,protocol:`/${rt.protocolPrefix??defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`,log:tt.logger.forComponent("libp2p:identify")});wt(this,Rl,["@libp2p/identify"]);(rt.runOnConnectionOpen??defaultValues.runOnConnectionOpen)&&tt.events.addEventListener("connection:open",nt=>{const ot=nt.detail;this.identify(ot).catch(it=>{it.name!==UnsupportedProtocolError$1.name&&this.log.error("error during identify trigged by connection:open",it)})})}async _identify(tt,rt={}){let nt;if(rt.signal==null){const ot=AbortSignal.timeout(this.timeout);setMaxListeners$4(1/0,ot),rt={...rt,signal:ot}}try{nt=await tt.newStream(this.protocol,{...rt,runOnLimitedConnection:this.runOnLimitedConnection});const it=await pbStream(nt,{maxDataLength:this.maxMessageSize}).pb(Identify$1).read(rt);return await nt.close(rt),it}catch(ot){throw nt==null||nt.abort(ot),ot}}async identify(tt,rt={}){const nt=await this._identify(tt,rt),{publicKey:ot,protocols:it,observedAddr:st}=nt;if(ot==null)throw new InvalidMessageError$2("public key was missing from identify message");const at=publicKeyFromProtobuf(ot),ct=peerIdFromCID(at.toCID());if(!tt.remotePeer.equals(ct))throw new InvalidMessageError$2("identified peer does not match the expected peer");if(this.peerId.equals(ct))throw new InvalidMessageError$2("identified peer is our own peer id?");const lt=getCleanMultiaddr(st);return this.log("identify completed for peer %p and protocols %o",ct,it),lt!=null&&(this.log("our observed address was %a",lt),isPrivateIp(lt==null?void 0:lt.nodeAddress().address)===!0?this.log("our observed address was private"):this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(this.log("storing our observed address"),this.addressManager.addObservedAddr(lt))),consumeIdentifyMessage(this.peerStore,this.events,this.log,tt,nt)}async handleProtocol(tt){const{connection:rt,stream:nt}=tt,ot=AbortSignal.timeout(this.timeout);setMaxListeners$4(1/0,ot);try{const it=await this.peerStore.get(this.peerId),st=this.addressManager.getAddresses().map(dt=>dt.decapsulateCode(getProtocol("p2p").code));let at=it.peerRecordEnvelope;if(st.length>0&&at==null){const dt=new PeerRecord({peerId:this.peerId,multiaddrs:st});at=(await RecordEnvelope.seal(dt,this.privateKey)).marshal().subarray()}let ct=rt.remoteAddr.bytes;IP_OR_DOMAIN.matches(rt.remoteAddr)||(ct=void 0),await pbStream(nt).pb(Identify$1).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:publicKeyToProtobuf(this.privateKey.publicKey),listenAddrs:st.map(dt=>dt.bytes),signedPeerRecord:at,observedAddr:ct,protocols:it.protocols},{signal:ot}),await nt.close({signal:ot})}catch(it){this.log.error("could not respond to identify request",it),nt.abort(it)}}}function identify(et={}){return o=>new Identify(o,et)}class MuxerClosedError extends Error{constructor(o="The muxer is closed"){super(o),this.name="MuxerClosedError"}}wt(MuxerClosedError,"name","MuxerClosedError");var xs;let InvalidMessageError$1=(xs=class extends Error{constructor(o="Invalid message"){super(o),this.name="InvalidMessageError"}},wt(xs,"name","InvalidMessageError"),xs);var vs;let TooManyOutboundProtocolStreamsError$1=(vs=class extends Error{constructor(o="Too many outbound protocol streams"){super(o),this.name="TooManyOutboundProtocolStreamsError"}},wt(vs,"name","TooManyOutboundProtocolStreamsError"),vs);const serviceCapabilities$2=Symbol.for("@libp2p/service-capabilities");function getIterator(et){if(et!=null){if(typeof et[Symbol.iterator]=="function")return et[Symbol.iterator]();if(typeof et[Symbol.asyncIterator]=="function")return et[Symbol.asyncIterator]();if(typeof et.next=="function")return et}throw new Error("argument is not an iterator or iterable")}function isPromise$2(et){return et==null?!1:typeof et.then=="function"&&typeof et.catch=="function"&&typeof et.finally=="function"}function closeSource(et,o){var rt,nt;const tt=(nt=(rt=getIterator(et)).return)==null?void 0:nt.call(rt);isPromise$2(tt)&&tt.catch(ot=>{o.error("could not cause iterator to return",ot)})}const createAbortError=()=>{const et=new Error("Delay aborted");return et.name="AbortError",et},clearMethods=new WeakMap;function createDelay({clearTimeout:et,setTimeout:o}={}){return(tt,{value:rt,signal:nt}={})=>{if(nt!=null&&nt.aborted)return Promise.reject(createAbortError());let ot,it,st;const at=et??clearTimeout,ct=()=>{at(ot),st(createAbortError())},lt=()=>{nt&&nt.removeEventListener("abort",ct)},dt=new Promise((ht,mt)=>{it=()=>{lt(),ht(rt)},st=mt,ot=(o??setTimeout)(it,tt)});return nt&&nt.addEventListener("abort",ct,{once:!0}),clearMethods.set(dt,()=>{at(ot),ot=null,it()}),dt}}const delay=createDelay();class RateLimitError extends Error{constructor(tt="Rate limit exceeded",rt){super(tt);wt(this,"remainingPoints");wt(this,"msBeforeNext");wt(this,"consumedPoints");wt(this,"isFirstInDuration");this.name="RateLimitError",this.remainingPoints=rt.remainingPoints,this.msBeforeNext=rt.msBeforeNext,this.consumedPoints=rt.consumedPoints,this.isFirstInDuration=rt.isFirstInDuration}}class QueueFullError extends Error{constructor(o="The queue was full"){super(o),this.name="QueueFullError"}}wt(QueueFullError,"name","QueueFullError");class RateLimiter{constructor(o={}){wt(this,"memoryStorage");wt(this,"points");wt(this,"duration");wt(this,"blockDuration");wt(this,"execEvenly");wt(this,"execEvenlyMinDelayMs");wt(this,"keyPrefix");this.points=o.points??4,this.duration=o.duration??1,this.blockDuration=o.blockDuration??0,this.execEvenly=o.execEvenly??!1,this.execEvenlyMinDelayMs=o.execEvenlyMinDelayMs??this.duration*1e3/this.points,this.keyPrefix=o.keyPrefix??"rlflx",this.memoryStorage=new MemoryStorage}async consume(o,tt=1,rt={}){const nt=this.getKey(o),ot=this._getKeySecDuration(rt);let it=this.memoryStorage.incrby(nt,tt,ot);if(it.remainingPoints=Math.max(this.points-it.consumedPoints,0),it.consumedPoints>this.points)throw this.blockDuration>0&&it.consumedPoints<=this.points+tt&&(it=this.memoryStorage.set(nt,it.consumedPoints,this.blockDuration)),new RateLimitError("Rate limit exceeded",it);if(this.execEvenly&&it.msBeforeNext>0&&!it.isFirstInDuration){let st=Math.ceil(it.msBeforeNext/(it.remainingPoints+2));st=0?rt:this.duration)*1e3;return this.memoryStorage.set(this.getKey(o),tt,rt),{remainingPoints:0,msBeforeNext:nt===0?-1:nt,consumedPoints:tt,isFirstInDuration:!1}}get(o){const tt=this.memoryStorage.get(this.getKey(o));return tt!=null&&(tt.remainingPoints=Math.max(this.points-tt.consumedPoints,0)),tt}delete(o){this.memoryStorage.delete(this.getKey(o))}_getKeySecDuration(o){return(o==null?void 0:o.customDuration)!=null&&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)}}class MemoryStorage{constructor(){wt(this,"storage");this.storage=new Map}incrby(o,tt,rt){const nt=this.storage.get(o);if(nt!=null){const ot=nt.expiresAt!=null?nt.expiresAt.getTime()-new Date().getTime():-1;return nt.expiresAt==null||ot>0?(nt.value+=tt,{remainingPoints:0,msBeforeNext:ot,consumedPoints:nt.value,isFirstInDuration:!1}):this.set(o,tt,rt)}return this.set(o,tt,rt)}set(o,tt,rt){const nt=rt*1e3,ot=this.storage.get(o);ot!=null&&clearTimeout(ot.timeoutId);const it={value:tt,expiresAt:nt>0?new Date(Date.now()+nt):void 0};return this.storage.set(o,it),nt>0&&(it.timeoutId=setTimeout(()=>{this.storage.delete(o)},nt),it.timeoutId.unref!=null&&it.timeoutId.unref()),{remainingPoints:0,msBeforeNext:nt===0?-1:nt,consumedPoints:it.value,isFirstInDuration:!0}}get(o){const tt=this.storage.get(o);if(tt!=null)return{remainingPoints:0,msBeforeNext:tt.expiresAt!=null?tt.expiresAt.getTime()-new Date().getTime():-1,consumedPoints:tt.value,isFirstInDuration:!1}}delete(o){const tt=this.storage.get(o);return tt!=null?(tt.timeoutId!=null&&clearTimeout(tt.timeoutId),this.storage.delete(o),!0):!1}}function allocUnsafe$7(et=0){return new Uint8Array(et)}function coerce$b(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$g(et){return new TextEncoder().encode(et)}function toString$j(et){return new TextDecoder().decode(et)}function base$b(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$c=base$b,_brrp__multiformats_scope_baseX$b=src$c;let Encoder$c=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$c=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$b(this,o)}},ComposedDecoder$b=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$b(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$b(et,o){return new ComposedDecoder$b({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$b=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$c(o,tt,rt),this.decoder=new Decoder$c(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$c({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$b(et,o,tt,rt)}function baseX$b({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$b(tt,et);return from$c({prefix:o,name:et,encode:rt,decode:ot=>coerce$b(nt(ot))})}function decode$u(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$q(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$8=alphabet$8.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$p(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$8[tt],o),"")}function decode$t(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$8[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$g=from$c({prefix:"🚀",name:"base256emoji",encode:encode$p,decode:decode$t}),base256emoji$h=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$g},Symbol.toStringTag,{value:"Module"})),base32$k=rfc4648$a({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$8=rfc4648$a({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$8=rfc4648$a({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$8=rfc4648$a({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$8=rfc4648$a({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$8=rfc4648$a({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$8=rfc4648$a({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$8=rfc4648$a({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$8=rfc4648$a({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$l=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$k,base32hex:base32hex$8,base32hexpad:base32hexpad$8,base32hexpadupper:base32hexpadupper$8,base32hexupper:base32hexupper$8,base32pad:base32pad$8,base32padupper:base32padupper$8,base32upper:base32upper$8,base32z:base32z$8},Symbol.toStringTag,{value:"Module"})),base36$h=baseX$b({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$8=baseX$b({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$i=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$h,base36upper:base36upper$8},Symbol.toStringTag,{value:"Module"})),base58btc$b=baseX$b({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$8=baseX$b({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$8=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$b,base58flickr:base58flickr$8},Symbol.toStringTag,{value:"Module"})),base64$j=rfc4648$a({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$8=rfc4648$a({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$8=rfc4648$a({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$8=rfc4648$a({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$k=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$j,base64pad:base64pad$8,base64url:base64url$8,base64urlpad:base64urlpad$8},Symbol.toStringTag,{value:"Module"})),base8$g=rfc4648$a({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$h=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$g},Symbol.toStringTag,{value:"Module"})),identity$8=from$c({prefix:"\0",name:"identity",encode:et=>toString$j(et),decode:et=>fromString$g(et)}),identityBase$8=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$8},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$8={...identityBase$8,...base2$h,...base8$h,...base10$h,...base16$h,...base32$l,...base36$i,...base58$8,...base64$k,...base256emoji$h};function createCodec$8(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$b=createCodec$8("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$8=createCodec$8("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$7(et.length);for(let tt=0;ttthis._maxUnprocessedMessageQueueSize)throw new InvalidMessageError$1("Unprocessed message queue size too large!");const tt=[];for(;this._buffer.length!==0;){if(this._headerInfo==null)try{this._headerInfo=this._decodeHeader(this._buffer)}catch(ct){if(ct.name==="InvalidMessageError")throw ct;break}const{id:rt,type:nt,length:ot,offset:it}=this._headerInfo;if(this._buffer.length-itthis._maxMessageSize)throw new InvalidMessageError$1("Message size too large");return{id:tt>>3,type:it,offset:rt+ot,length:nt}}};const MSB$3=128,REST$3=127;function readVarInt(et,o=0){let tt=0,rt=0,nt=o,ot;const it=et.length;do{if(nt>=it||rt>49)throw o=0,new RangeError("Could not decode varint");ot=et.get(nt++),tt+=rt<28?(ot&REST$3)<=MSB$3);return o=nt-o,{value:tt,offset:o}}const POOL_SIZE=10*1024;let Encoder$b=class{constructor(){wt(this,"_pool");wt(this,"_poolOffset");this._pool=allocUnsafe$7(POOL_SIZE),this._poolOffset=0}write(o,tt){const rt=this._pool;let nt=this._poolOffset;encode$P(o.id<<3|o.type,rt,nt),nt+=encodingLength$6(o.id<<3|o.type),(o.type===MessageTypes.NEW_STREAM||o.type===MessageTypes.MESSAGE_INITIATOR||o.type===MessageTypes.MESSAGE_RECEIVER)&&o.data!=null?(encode$P(o.data.length,rt,nt),nt+=encodingLength$6(o.data.length)):(encode$P(0,rt,nt),nt+=encodingLength$6(0));const ot=rt.subarray(this._poolOffset,nt);POOL_SIZE-nt<100?(this._pool=allocUnsafe$7(POOL_SIZE),this._poolOffset=0):this._poolOffset=nt,tt.append(ot),(o.type===MessageTypes.NEW_STREAM||o.type===MessageTypes.MESSAGE_INITIATOR||o.type===MessageTypes.MESSAGE_RECEIVER)&&o.data!=null&&tt.append(o.data)}};const encoder$1=new Encoder$b;async function*encode$o(et){for await(const o of et){const tt=new Uint8ArrayList;encoder$1.write(o,tt),yield tt}}class StreamInputBufferError extends Error{constructor(o="Stream input buffer error"){super(o),this.name="StreamInputBufferError"}}var ws;let AbortError$6=(ws=class extends Error{constructor(o="The operation was aborted"){super(o),this.name="AbortError"}},wt(ws,"name","AbortError"),ws);class StreamResetError extends Error{constructor(o="The stream has been reset"){super(o),this.name="StreamResetError"}}wt(StreamResetError,"name","StreamResetError");class StreamStateError extends Error{constructor(o="The stream is in an invalid state"){super(o),this.name="StreamStateError"}}wt(StreamStateError,"name","StreamStateError");function setMaxListeners$3(){}const setMaxListeners$2=(et,...o)=>{try{[...o]}catch{}};var Jr,Tl;let TypedEventEmitter$1=(Tl=class extends EventTarget{constructor(){super();fr(this,Jr,new Map);setMaxListeners$2(1/0,this)}listenerCount(tt){const rt=Ot(this,Jr).get(tt);return rt==null?0:rt.length}addEventListener(tt,rt,nt){super.addEventListener(tt,rt,nt);let ot=Ot(this,Jr).get(tt);ot==null&&(ot=[],Ot(this,Jr).set(tt,ot)),ot.push({callback:rt,once:(nt!==!0&&nt!==!1&&(nt==null?void 0:nt.once))??!1})}removeEventListener(tt,rt,nt){super.removeEventListener(tt.toString(),rt??null,nt);let ot=Ot(this,Jr).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==rt),Ot(this,Jr).set(tt,ot))}dispatchEvent(tt){const rt=super.dispatchEvent(tt);let nt=Ot(this,Jr).get(tt.type);return nt==null||(nt=nt.filter(({once:ot})=>!ot),Ot(this,Jr).set(tt.type,nt)),rt}safeDispatchEvent(tt,rt={}){return this.dispatchEvent(new CustomEvent(tt,rt))}},Jr=new WeakMap,Tl);const DEFAULT_SEND_CLOSE_WRITE_TIMEOUT=5e3;function isPromise$1(et){return et==null?!1:typeof et.then=="function"&&typeof et.catch=="function"&&typeof et.finally=="function"}class AbstractStream{constructor(o){wt(this,"id");wt(this,"direction");wt(this,"timeline");wt(this,"protocol");wt(this,"metadata");wt(this,"source");wt(this,"status");wt(this,"readStatus");wt(this,"writeStatus");wt(this,"log");wt(this,"sinkController");wt(this,"sinkEnd");wt(this,"closed");wt(this,"endErr");wt(this,"streamSource");wt(this,"onEnd");wt(this,"onCloseRead");wt(this,"onCloseWrite");wt(this,"onReset");wt(this,"onAbort");wt(this,"sendCloseWriteTimeout");wt(this,"sendingData");this.sinkController=new AbortController,this.sinkEnd=pDefer(),this.closed=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??DEFAULT_SEND_CLOSE_WRITE_TIMEOUT,this.onEnd=o.onEnd,this.onCloseRead=o==null?void 0:o.onCloseRead,this.onCloseWrite=o==null?void 0:o.onCloseWrite,this.onReset=o==null?void 0:o.onReset,this.onAbort=o==null?void 0:o.onAbort,this.source=this.streamSource=pushable({onEnd:tt=>{tt!=null?this.log.trace("source ended with error",tt):this.log.trace("source ended"),this.onSourceEnd(tt)}}),this.sink=this.sink.bind(this)}async sink(o){if(this.writeStatus!=="ready")throw new StreamStateError(`writable end state is "${this.writeStatus}" not "ready"`);try{this.writeStatus="writing";const tt={signal:this.sinkController.signal};if(this.direction==="outbound"){const nt=this.sendNewStream(tt);isPromise$1(nt)&&await nt}const rt=()=>{closeSource(o,this.log)};try{this.sinkController.signal.addEventListener("abort",rt),this.log.trace("sink reading from source");for await(let nt of o){nt=nt instanceof Uint8Array?new Uint8ArrayList(nt):nt;const ot=this.sendData(nt,tt);isPromise$1(ot)&&(this.sendingData=pDefer(),await ot,this.sendingData.resolve(),this.sendingData=void 0)}}finally{this.sinkController.signal.removeEventListener("abort",rt)}this.log.trace('sink finished reading from source, write status is "%s"',this.writeStatus),this.writeStatus==="writing"&&(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(tt){throw this.log.trace("sink ended with error, calling abort with error",tt),this.abort(tt),tt}finally{this.log.trace("resolve sink end"),this.sinkEnd.resolve()}}onSourceEnd(o){var tt;this.timeline.closeRead==null&&(this.timeline.closeRead=Date.now(),this.readStatus="closed",o!=null&&this.endErr==null&&(this.endErr=o),(tt=this.onCloseRead)==null||tt.call(this),this.timeline.closeWrite!=null?(this.log.trace("source and sink ended"),this.timeline.close=Date.now(),this.status!=="aborted"&&this.status!=="reset"&&(this.status="closed"),this.onEnd!=null&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("source ended, waiting for sink to end"))}onSinkEnd(o){var tt;this.timeline.closeWrite==null&&(this.timeline.closeWrite=Date.now(),this.writeStatus="closed",o!=null&&this.endErr==null&&(this.endErr=o),(tt=this.onCloseWrite)==null||tt.call(this),this.timeline.closeRead!=null?(this.log.trace("sink and source ended"),this.timeline.close=Date.now(),this.status!=="aborted"&&this.status!=="reset"&&(this.status="closed"),this.onEnd!=null&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("sink ended, waiting for source to end"))}async close(o){this.log.trace("closing gracefully"),this.status="closing",await raceSignal(Promise.all([this.closeWrite(o),this.closeRead(o),this.closed.promise]),o==null?void 0:o.signal),this.status="closed",this.log.trace("closed gracefully")}async closeRead(o={}){if(this.readStatus==="closing"||this.readStatus==="closed")return;this.log.trace('closing readable end of stream with starting read status "%s"',this.readStatus);const tt=this.readStatus;this.readStatus="closing",this.status!=="reset"&&this.status!=="aborted"&&this.timeline.closeRead==null&&(this.log.trace("send close read to remote"),await this.sendCloseRead(o)),tt==="ready"&&(this.log.trace("ending internal source queue with %d queued bytes",this.streamSource.readableLength),this.streamSource.end()),this.log.trace("closed readable end of stream")}async closeWrite(o={}){this.writeStatus==="closing"||this.writeStatus==="closed"||(this.log.trace('closing writable end of stream with starting write status "%s"',this.writeStatus),this.writeStatus==="ready"&&(this.log.trace("sink was never sunk, sink an empty array"),await raceSignal(this.sink([]),o.signal)),this.writeStatus==="writing"&&(this.sendingData!=null&&await raceSignal(this.sendingData.promise,o.signal),this.log.trace("aborting source passed to .sink"),this.sinkController.abort(),await raceSignal(this.sinkEnd.promise,o.signal)),this.writeStatus="closed",this.log.trace("closed writable end of stream"))}abort(o){var rt;if(this.status==="closed"||this.status==="aborted"||this.status==="reset")return;this.log("abort with error",o),this.log("try to send reset to remote");const tt=this.sendReset();isPromise$1(tt)&&tt.catch(nt=>{this.log.error("error sending reset message",nt)}),this.status="aborted",this.timeline.abort=Date.now(),this._closeSinkAndSource(o),(rt=this.onAbort)==null||rt.call(this,o)}reset(){var tt;if(this.status==="closed"||this.status==="aborted"||this.status==="reset")return;const o=new StreamResetError("stream reset");this.status="reset",this.timeline.reset=Date.now(),this._closeSinkAndSource(o),(tt=this.onReset)==null||tt.call(this)}_closeSinkAndSource(o){this._closeSink(o),this._closeSource(o)}_closeSink(o){this.writeStatus==="writing"&&(this.log.trace("end sink source"),this.sinkController.abort()),this.onSinkEnd(o)}_closeSource(o){this.readStatus!=="closing"&&this.readStatus!=="closed"&&(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(this.readStatus==="closing"||this.readStatus==="closed"){this.log("received remote close write but local source is already closed");return}this.log.trace("remote close write"),this._closeSource()}remoteCloseRead(){if(this.writeStatus==="closing"||this.writeStatus==="closed"){this.log("received remote close read but local sink is already closed");return}this.log.trace("remote close read"),this._closeSink()}destroy(){if(this.status==="closed"||this.status==="aborted"||this.status==="reset"){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}}class MplexStream extends AbstractStream{constructor(tt){super(tt);wt(this,"name");wt(this,"streamId");wt(this,"send");wt(this,"types");wt(this,"maxDataSize");this.types=tt.direction==="outbound"?InitiatorMessageTypes:ReceiverMessageTypes,this.send=tt.send,this.name=tt.name,this.streamId=tt.streamId,this.maxDataSize=tt.maxDataSize}async sendNewStream(){await this.send({id:this.streamId,type:InitiatorMessageTypes.NEW_STREAM,data:new Uint8ArrayList(fromString$f(this.name))})}async sendData(tt){for(tt=tt.sublist();tt.byteLength>0;){const rt=Math.min(tt.byteLength,this.maxDataSize);await this.send({id:this.streamId,type:this.types.MESSAGE,data:tt.sublist(0,rt)}),tt.consume(rt)}}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(et){const{id:o,name:tt,send:rt,onEnd:nt,type:ot="initiator",maxMsgSize:it=MAX_MSG_SIZE}=et;return new MplexStream({id:ot==="initiator"?`i${o}`:`r${o}`,streamId:o,name:`${tt??o}`,direction:ot==="initiator"?"outbound":"inbound",maxDataSize:it,onEnd:nt,send:rt,log:et.logger.forComponent(`libp2p:mplex:stream:${ot}:${o}`)})}const MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION=1024,MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION=1024,MAX_STREAM_BUFFER_SIZE=1024*1024*4,DISCONNECT_THRESHOLD=5,CLOSE_TIMEOUT$2=500;function printMessage(et){const o={...et,type:`${MessageTypeNames[et.type]} (${et.type})`};return et.type===MessageTypes.NEW_STREAM&&(o.data=toString$i(et.data instanceof Uint8Array?et.data:et.data.subarray())),(et.type===MessageTypes.MESSAGE_INITIATOR||et.type===MessageTypes.MESSAGE_RECEIVER)&&(o.data=toString$i(et.data instanceof Uint8Array?et.data:et.data.subarray(),"base16")),o}class MplexStreamMuxer{constructor(o,tt){wt(this,"protocol","/mplex/6.7.0");wt(this,"sink");wt(this,"source");wt(this,"log");wt(this,"_streamId");wt(this,"_streams");wt(this,"_init");wt(this,"_source");wt(this,"closeController");wt(this,"rateLimiter");wt(this,"closeTimeout");wt(this,"logger");tt=tt??{},this.log=o.logger.forComponent("libp2p:mplex"),this.logger=o.logger,this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._init=tt,this.closeTimeout=tt.closeTimeout??CLOSE_TIMEOUT$2,this.sink=this._createSink(),this._source=pushable({objectMode:!0,onEnd:()=>{for(const rt of this._streams.initiators.values())rt.destroy();for(const rt of this._streams.receivers.values())rt.destroy()}}),this.source=pipe(this._source,rt=>encode$o(rt)),this.closeController=new AbortController,this.rateLimiter=new RateLimiter({points:tt.disconnectThreshold??DISCONNECT_THRESHOLD,duration:1})}get streams(){const o=[];for(const tt of this._streams.initiators.values())o.push(tt);for(const tt of this._streams.receivers.values())o.push(tt);return o}newStream(o){if(this.closeController.signal.aborted)throw new MuxerClosedError("Muxer already closed");const tt=this._streamId++;o=o==null?tt.toString():o.toString();const rt=this._streams.initiators;return this._newStream({id:tt,name:o,type:"initiator",registry:rt})}async close(o){if(this.closeController.signal.aborted)return;const tt=(o==null?void 0:o.signal)??AbortSignal.timeout(this.closeTimeout);try{await Promise.all(this.streams.map(async rt=>rt.close({signal:tt}))),this._source.end(),await this._source.onEmpty({signal:tt}),this.closeController.abort()}catch(rt){this.abort(rt)}}abort(o){this.closeController.signal.aborted||(this.streams.forEach(tt=>{tt.abort(o)}),this.closeController.abort(o))}_newReceiverStream(o){const{id:tt,name:rt}=o,nt=this._streams.receivers;return this._newStream({id:tt,name:rt,type:"receiver",registry:nt})}_newStream(o){const{id:tt,name:rt,type:nt,registry:ot}=o;if(this.log("new %s stream %s",nt,tt),nt==="initiator"&&this._streams.initiators.size===(this._init.maxOutboundStreams??MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION))throw new TooManyOutboundProtocolStreamsError$1("Too many outbound streams open");if(ot.has(tt))throw new Error(`${nt} stream ${tt} already exists!`);const at=createStream({id:tt,name:rt,send:async ct=>{this.log.enabled&&this.log.trace("%s stream %s send",nt,tt,printMessage(ct)),this._source.push(ct)},type:nt,onEnd:()=>{this.log("%s stream with id %s and protocol %s ended",nt,tt,at.protocol),ot.delete(tt),this._init.onStreamEnd!=null&&this._init.onStreamEnd(at)},maxMsgSize:this._init.maxMsgSize,logger:this.logger});return ot.set(tt,at),at}_createSink(){return async tt=>{const rt=()=>{closeSource(tt,this.log)};this.closeController.signal.addEventListener("abort",rt);try{const nt=new Decoder$b(this._init.maxMsgSize,this._init.maxUnprocessedMessageQueueSize);for await(const ot of tt)for(const it of nt.write(ot))await this._handleIncoming(it);this._source.end()}catch(nt){this.log("error in sink",nt),this._source.end(nt)}finally{this.closeController.signal.removeEventListener("abort",rt)}}}async _handleIncoming(o){const{id:tt,type:rt}=o;if(this.log.enabled&&this.log.trace("incoming message",printMessage(o)),o.type===MessageTypes.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION)){this.log("too many inbound streams open"),this._source.push({id:tt,type:MessageTypes.RESET_RECEIVER});try{await this.rateLimiter.consume("new-stream",1)}catch{this.log("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),this.abort(new Error("Too many open streams"));return}return}const st=this._newReceiverStream({id:tt,name:toString$i(o.data instanceof Uint8Array?o.data:o.data.subarray())});this._init.onIncomingStream!=null&&this._init.onIncomingStream(st);return}const ot=((rt&1)===1?this._streams.initiators:this._streams.receivers).get(tt);if(ot==null){this.log("missing stream %s for message type %s",tt,MessageTypeNames[rt]);try{await this.rateLimiter.consume("missing-stream",1)}catch{this.log("rate limit hit when receiving messages for streams that do not exist - closing remote connection"),this.abort(new Error("Too many messages for missing streams"));return}return}const it=this._init.maxStreamBufferSize??MAX_STREAM_BUFFER_SIZE;try{switch(rt){case MessageTypes.MESSAGE_INITIATOR:case MessageTypes.MESSAGE_RECEIVER:if(ot.sourceReadableLength()>it)throw this._source.push({id:o.id,type:rt===MessageTypes.MESSAGE_INITIATOR?MessageTypes.RESET_RECEIVER:MessageTypes.RESET_INITIATOR}),new StreamInputBufferError("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers");ot.sourcePush(o.data);break;case MessageTypes.CLOSE_INITIATOR:case MessageTypes.CLOSE_RECEIVER:ot.remoteCloseWrite();break;case MessageTypes.RESET_INITIATOR:case MessageTypes.RESET_RECEIVER:ot.reset();break;default:this.log("unknown message type %s",rt)}}catch(st){this.log.error("error while processing message",st),ot.abort(st)}}}var Il,Pl;Pl=Symbol.toStringTag,Il=serviceCapabilities$2;class Mplex{constructor(o,tt={}){wt(this,"protocol","/mplex/6.7.0");wt(this,"_init");wt(this,"components");wt(this,Pl,"@libp2p/mplex");wt(this,Il,["@libp2p/stream-multiplexing"]);this.components=o,this._init=tt}createStreamMuxer(o={}){return new MplexStreamMuxer(this.components,{...o,...this._init})}}function mplex(et={}){return o=>new Mplex(o,et)}function isAsyncIterable$3(et){return et[Symbol.asyncIterator]!=null}function first(et){if(isAsyncIterable$3(et))return(async()=>{for await(const o of et)return o})();for(const o of et)return o}function equals$4(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt{tt==null||tt.abort(new TimeoutError$3("ping timeout"))}),pipe(tt,async function*(ot){let it=0;for await(const st of ot){if(it+=st.byteLength,it>PING_LENGTH$1){tt==null||tt.abort(new InvalidMessageError$3("Too much data received"));return}yield st}},tt).catch(ot=>{this.log.error("incoming ping from %p failed with error",o.connection.remotePeer,ot),tt==null||tt.abort(ot)}).finally(()=>{const ot=Date.now()-rt;this.log("incoming ping from %p complete in %dms",o.connection.remotePeer,ot)})}async ping(o,tt={}){var at,ct;this.log("pinging %p",o);const rt=Date.now(),nt=randomBytes(PING_LENGTH$1),ot=await this.components.connectionManager.openConnection(o,tt);let it,st=()=>{};if(tt.signal==null){const lt=AbortSignal.timeout(this.timeout);tt={...tt,signal:lt}}try{it=await ot.newStream(this.protocol,{...tt,runOnLimitedConnection:this.runOnLimitedConnection}),st=()=>{it==null||it.abort(new AbortError$9)},(at=tt.signal)==null||at.addEventListener("abort",st,{once:!0});const lt=await pipe([nt],it,async ht=>first(ht)),dt=Date.now()-rt;if(lt==null)throw new ProtocolError(`Did not receive a ping ack after ${dt}ms`);if(!equals$4(nt,lt.subarray()))throw new ProtocolError(`Received wrong ping ack after ${dt}ms`);return this.log("ping %p complete in %dms",ot.remotePeer,dt),dt}catch(lt){throw this.log.error("error while pinging %p",ot.remotePeer,lt),it==null||it.abort(lt),lt}finally{(ct=tt.signal)==null||ct.removeEventListener("abort",st),it!=null&&await it.close()}}}function ping(et={}){return o=>new PingService(o,et)}const transportSymbol=Symbol.for("@libp2p/transport");var FaultTolerance$1;(function(et){et[et.FATAL_ALL=0]="FATAL_ALL",et[et.NO_FATAL=1]="NO_FATAL"})(FaultTolerance$1||(FaultTolerance$1={}));var Es;let AbortError$5=(Es=class extends Error{constructor(o="The operation was aborted"){super(o),this.name="AbortError"}},wt(Es,"name","AbortError"),Es);class ConnectionFailedError extends Error{constructor(o="Connection failed"){super(o),this.name="ConnectionFailedError"}}wt(ConnectionFailedError,"name","ConnectionFailedError");const serviceCapabilities$1=Symbol.for("@libp2p/service-capabilities"),ASSUME_HTTP_CODES=[getProtocol("tcp").code,getProtocol("dns").code,getProtocol("dnsaddr").code,getProtocol("dns4").code,getProtocol("dns6").code];function extractSNI(et){let o;try{o=getProtocol("sni").code}catch{return null}for(const[tt,rt]of et)if(tt===o&&rt!==void 0)return rt;return null}function hasTLS(et){return et.some(([o,tt])=>o===getProtocol("tls").code)}function interpretNext(et,o,tt){const rt=interpreters[getProtocol(et).name];if(rt===void 0)throw new Error(`Can't interpret protocol ${getProtocol(et).name}`);const nt=rt(o,tt);return et===getProtocol("ip6").code?`[${nt}]`:nt}const interpreters={ip4:(et,o)=>et,ip6:(et,o)=>o.length===0?et:`[${et}]`,tcp:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`tcp://${interpretNext(tt[0],tt[1]??"",o)}:${et}`},udp:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`udp://${interpretNext(tt[0],tt[1]??"",o)}:${et}`},dnsaddr:(et,o)=>et,dns4:(et,o)=>et,dns6:(et,o)=>et,dns:(et,o)=>et,ipfs:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/ipfs/${et}`},p2p:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/p2p/${et}`},http:(et,o)=>{const tt=hasTLS(o),rt=extractSNI(o);if(tt&&rt!==null)return`https://${rt}`;const nt=tt?"https://":"http://",ot=o.pop();if(ot===void 0)throw new Error("Unexpected end of multiaddr");let it=interpretNext(ot[0],ot[1]??"",o);return it=it.replace("tcp://",""),`${nt}${it}`},"http-path":(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");const rt=interpretNext(tt[0],tt[1]??"",o),nt=decodeURIComponent(et);return`${rt}/${nt}`},tls:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return interpretNext(tt[0],tt[1]??"",o)},sni:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return interpretNext(tt[0],tt[1]??"",o)},https:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");let rt=interpretNext(tt[0],tt[1]??"",o);return rt=rt.replace("tcp://",""),`https://${rt}`},ws:(et,o)=>{const tt=hasTLS(o),rt=extractSNI(o);if(tt&&rt!==null)return`wss://${rt}`;const nt=tt?"wss://":"ws://",ot=o.pop();if(ot===void 0)throw new Error("Unexpected end of multiaddr");let it=interpretNext(ot[0],ot[1]??"",o);return it=it.replace("tcp://",""),`${nt}${it}`},wss:(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");let rt=interpretNext(tt[0],tt[1]??"",o);return rt=rt.replace("tcp://",""),`wss://${rt}`},"p2p-websocket-star":(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/p2p-websocket-star`},"p2p-webrtc-star":(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/p2p-webrtc-star`},"p2p-webrtc-direct":(et,o)=>{const tt=o.pop();if(tt===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(tt[0],tt[1]??"",o)}/p2p-webrtc-direct`}};function multiaddrToUri(et,o){const rt=multiaddr(et).stringTuples(),nt=rt.pop();if(nt===void 0)throw new Error("Unexpected end of multiaddr");const ot=getProtocol(nt[0]),it=interpreters[ot.name];if(it==null)throw new Error(`No interpreter found for ${ot.name}`);let st=it(nt[1]??"",rt);return ASSUME_HTTP_CODES.includes(nt[0])&&(st=st.replace(/^.*:\/\//,""),nt[1]==="443"?st=`https://${st}`:st=`http://${st}`),(st.startsWith("http://")||st.startsWith("https://"))&&(st=new URL(st).toString(),st.endsWith("/")&&(st=st.substring(0,st.length-1))),st}const ready=async et=>{if(et.readyState>=2)throw new Error("socket closed");et.readyState!==1&&await new Promise((o,tt)=>{function rt(){et.removeEventListener("open",nt),et.removeEventListener("error",ot)}function nt(){rt(),o()}function ot(it){rt(),tt(it.error??new Error(`connect ECONNREFUSED ${et.url}`))}et.addEventListener("open",nt),et.addEventListener("error",ot)})},sink=(et,o)=>(o=o??{},o.closeOnEnd=o.closeOnEnd!==!1,async rt=>{for await(const nt of rt){try{await ready(et)}catch(ot){if(ot.message==="socket closed")break;throw ot}if(et.readyState===et.CLOSING||et.readyState===et.CLOSED)break;et.send(nt)}o.closeOnEnd!=null&&et.readyState<=1&&await new Promise((nt,ot)=>{et.addEventListener("close",it=>{if(it.wasClean||it.code===1006)nt();else{const st=Object.assign(new Error("ws error"),{event:it});ot(st)}}),setTimeout(()=>{et.close()})})});var dom={},eventIterator={};Object.defineProperty(eventIterator,"__esModule",{value:!0});class EventQueue{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(o){if(this.isStopped)return;const tt={value:o,done:!1};if(this.pullQueue.length){const rt=this.pullQueue.shift();rt&&rt.resolve(tt)}else this.pushQueue.push(Promise.resolve(tt)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const o of 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(const tt of this.pullQueue)tt.reject(o);this.pullQueue.length=0}else{const tt=Promise.reject(o);tt.catch(()=>{}),this.pushQueue.push(tt)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:o=>{const tt=this.pushQueue.shift();return tt?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),tt):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((rt,nt)=>{this.pullQueue.push({resolve:rt,reject:nt})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}let EventIterator$1=class{constructor(o,{highWaterMark:tt=100,lowWaterMark:rt=1}={}){const nt=new EventQueue;nt.highWaterMark=tt,nt.lowWaterMark=rt,nt.removeCallback=o({push:ot=>nt.push(ot),stop:()=>nt.stop(),fail:ot=>nt.fail(ot),on:(ot,it)=>{nt.eventHandlers[ot]=it}})||(()=>{}),this[Symbol.asyncIterator]=()=>nt[Symbol.asyncIterator](),Object.freeze(this)}};eventIterator.EventIterator=EventIterator$1;eventIterator.default=EventIterator$1;Object.defineProperty(dom,"__esModule",{value:!0});const event_iterator_1=eventIterator;var EventIterator=dom.EventIterator=event_iterator_1.EventIterator;function subscribe(et,o,tt){return new event_iterator_1.EventIterator(({push:rt})=>(this.addEventListener(et,rt,o),()=>this.removeEventListener(et,rt,o)),tt)}dom.subscribe=subscribe;dom.default=event_iterator_1.EventIterator;function coerce$a(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$e(et){return new TextEncoder().encode(et)}function toString$h(et){return new TextDecoder().decode(et)}function base$a(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$b=base$a,_brrp__multiformats_scope_baseX$a=src$b;let Encoder$a=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$a=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$a(this,o)}},ComposedDecoder$a=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$a(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$a(et,o){return new ComposedDecoder$a({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$a=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$a(o,tt,rt),this.decoder=new Decoder$a(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$b({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$a(et,o,tt,rt)}function baseX$a({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$a(tt,et);return from$b({prefix:o,name:et,encode:rt,decode:ot=>coerce$a(nt(ot))})}function decode$s(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$n(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$7=alphabet$7.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$m(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$7[tt],o),"")}function decode$r(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$7[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$e=from$b({prefix:"🚀",name:"base256emoji",encode:encode$m,decode:decode$r}),base256emoji$f=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$e},Symbol.toStringTag,{value:"Module"})),base32$i=rfc4648$9({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$7=rfc4648$9({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$7=rfc4648$9({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$7=rfc4648$9({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$7=rfc4648$9({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$7=rfc4648$9({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$7=rfc4648$9({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$7=rfc4648$9({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$7=rfc4648$9({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$j=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$i,base32hex:base32hex$7,base32hexpad:base32hexpad$7,base32hexpadupper:base32hexpadupper$7,base32hexupper:base32hexupper$7,base32pad:base32pad$7,base32padupper:base32padupper$7,base32upper:base32upper$7,base32z:base32z$7},Symbol.toStringTag,{value:"Module"})),base36$f=baseX$a({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$7=baseX$a({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$g=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$f,base36upper:base36upper$7},Symbol.toStringTag,{value:"Module"})),base58btc$a=baseX$a({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$7=baseX$a({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$7=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$a,base58flickr:base58flickr$7},Symbol.toStringTag,{value:"Module"})),base64$h=rfc4648$9({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$7=rfc4648$9({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$7=rfc4648$9({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$7=rfc4648$9({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$i=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$h,base64pad:base64pad$7,base64url:base64url$7,base64urlpad:base64urlpad$7},Symbol.toStringTag,{value:"Module"})),base8$e=rfc4648$9({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$f=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$e},Symbol.toStringTag,{value:"Module"})),identity$7=from$b({prefix:"\0",name:"identity",encode:et=>toString$h(et),decode:et=>fromString$e(et)}),identityBase$7=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$7},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$7={...identityBase$7,...base2$f,...base8$f,...base10$f,...base16$f,...base32$j,...base36$g,...base58$7,...base64$i,...base256emoji$f};function allocUnsafe$6(et=0){return new Uint8Array(et)}function createCodec$7(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$a=createCodec$7("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$7=createCodec$7("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$6(et.length);for(let tt=0;tt{et.binaryType="arraybuffer";const o=async()=>{await new Promise((ot,it)=>{if(rt){ot();return}if(nt!=null){it(nt);return}const st=lt=>{et.removeEventListener("open",at),et.removeEventListener("error",ct),lt()},at=()=>{st(ot)},ct=lt=>{st(()=>{it(lt.error??new Error(`connect ECONNREFUSED ${et.url}`))})};et.addEventListener("open",at),et.addEventListener("error",ct)})},tt=async function*(){const ot=new EventIterator(({push:it,stop:st,fail:at})=>{const ct=dt=>{let ht=null;typeof dt.data=="string"&&(ht=fromString$d(dt.data)),isArrayBuffer(dt.data)&&(ht=new Uint8Array(dt.data)),dt.data instanceof Uint8Array&&(ht=dt.data),ht!=null&&it(ht)},lt=dt=>{at(dt.error??new Error("Socket error"))};return et.addEventListener("message",ct),et.addEventListener("error",lt),et.addEventListener("close",st),()=>{et.removeEventListener("message",ct),et.removeEventListener("error",lt),et.removeEventListener("close",st)}},{highWaterMark:1/0});await o();for await(const it of ot)yield isArrayBuffer(it)?new Uint8Array(it):it}();let rt=et.readyState===1,nt;return et.addEventListener("open",()=>{rt=!0,nt=null}),et.addEventListener("close",()=>{rt=!1,nt=null}),et.addEventListener("error",ot=>{rt||(nt=ot.error??new Error(`connect ECONNREFUSED ${et.url}`))}),Object.assign(tt,{connected:o})},duplex=(et,o)=>{o=o??{};const tt=source(et);let rt=o.remoteAddress,nt=o.remotePort;if(et.url!=null)try{const it=new URL(et.url);rt=it.hostname,nt=parseInt(it.port,10)}catch{}if(rt==null||nt==null)throw new Error("Remote connection did not have address and/or port");return{sink:sink(et,o),source:tt,connected:async()=>{await tt.connected()},close:async()=>{(et.readyState===et.CONNECTING||et.readyState===et.OPEN)&&await new Promise(it=>{et.addEventListener("close",()=>{it()}),et.close()})},destroy:()=>{et.terminate!=null?et.terminate():et.close()},remoteAddress:rt,remotePort:nt,socket:et}},WebSocket$1=WebSocket,map={"http:":"ws:","https:":"wss:"},defaultProtocol="ws:",wsurl=(et,o)=>{if(et.startsWith("//")&&(et=`${(o==null?void 0:o.protocol)??defaultProtocol}${et}`),et.startsWith("/")&&o!=null){const rt=o.protocol??defaultProtocol,nt=o.host,ot=o.port!=null&&(nt==null?void 0:nt.endsWith(`:${o.port}`))!==!0?`:${o.port}`:"";et=`${rt}//${nt}${ot}${et}`}const tt=new URL(et);for(const[rt,nt]of Object.entries(map))tt.protocol===rt&&(tt.protocol=nt);return tt};function connect(et,o){const tt=typeof window>"u"?void 0:window.location;o=o??{};const rt=wsurl(et,tt),nt=new WebSocket$1(rt.toString(),o.websocket);return duplex(nt,o)}class CustomProgressEvent extends Event{constructor(tt,rt){super(tt);wt(this,"type");wt(this,"detail");this.type=tt,this.detail=rt}}const CODE_P2P=421,CODE_CIRCUIT=290,CLOSE_TIMEOUT$1=500;function all$1(et){return et.filter(o=>{if(o.protoCodes().includes(CODE_CIRCUIT))return!1;const tt=o.decapsulateCode(CODE_P2P);return WebSockets$2.matches(tt)||WebSocketsSecure$1.matches(tt)})}function wss(et){return et.filter(o=>{if(o.protoCodes().includes(CODE_CIRCUIT))return!1;const tt=o.decapsulateCode(CODE_P2P);return WebSocketsSecure$1.matches(tt)})}function createListener(){throw new Error("WebSocket Servers can not be created in the browser!")}function socketToMaConn(et,o,tt){const rt=tt.logger.forComponent("libp2p:websockets:maconn"),nt=tt.metrics,ot=tt.metricPrefix??"",it={log:rt,async sink(st){try{await et.sink(async function*(){for await(const at of st)at instanceof Uint8Array?yield at:yield at.subarray()}())}catch(at){at.type!=="aborted"&&rt.error(at)}},source:et.source,remoteAddr:o,timeline:{open:Date.now()},async close(st={}){var lt,dt;const at=Date.now();if(st.signal==null){const ht=AbortSignal.timeout(CLOSE_TIMEOUT$1);st={...st,signal:ht}}const ct=()=>{const{host:ht,port:mt}=it.remoteAddr.toOptions();rt("timeout closing stream to %s:%s after %dms, destroying it manually",ht,mt,Date.now()-at),this.abort(new AbortError$5("Socket close timeout"))};(lt=st.signal)==null||lt.addEventListener("abort",ct);try{await et.close()}catch(ht){rt.error("error closing WebSocket gracefully",ht),this.abort(ht)}finally{(dt=st.signal)==null||dt.removeEventListener("abort",ct),it.timeline.close=Date.now()}},abort(st){const{host:at,port:ct}=it.remoteAddr.toOptions();rt("timeout closing stream to %s:%s due to error",at,ct,st),et.destroy(),it.timeline.close=Date.now(),nt==null||nt.increment({[`${ot}error`]:!0})}};return et.socket.addEventListener("close",()=>{nt==null||nt.increment({[`${ot}close`]:!0}),it.timeline.close==null&&(it.timeline.close=Date.now())},{once:!0}),it}var Dl,Ll,Ol;Ol=transportSymbol,Ll=Symbol.toStringTag,Dl=serviceCapabilities$1;class WebSockets{constructor(o,tt){wt(this,"log");wt(this,"init");wt(this,"logger");wt(this,"metrics");wt(this,"components");wt(this,Ol,!0);wt(this,Ll,"@libp2p/websockets");wt(this,Dl,["@libp2p/transport"]);this.log=o.logger.forComponent("libp2p:websockets"),this.logger=o.logger,this.components=o,this.init=tt,o.metrics!=null&&(this.metrics={dialerEvents:o.metrics.registerCounterGroup("libp2p_websockets_dialer_events_total",{label:"event",help:"Total count of WebSockets dialer events by type"})})}async dial(o,tt){var it;this.log("dialing %s",o),tt=tt??{};const rt=await this._connect(o,tt),nt=socketToMaConn(rt,o,{logger:this.logger,metrics:(it=this.metrics)==null?void 0:it.dialerEvents});this.log("new outbound connection %s",nt.remoteAddr);const ot=await tt.upgrader.upgradeOutbound(nt,tt);return this.log("outbound connection %s upgraded",nt.remoteAddr),ot}async _connect(o,tt){var it,st,at,ct,lt;(it=tt==null?void 0:tt.signal)==null||it.throwIfAborted();const rt=o.toOptions();this.log("dialing %s:%s",rt.host,rt.port);const nt=pDefer(),ot=connect(multiaddrToUri(o),this.init);ot.socket.addEventListener("error",()=>{var ht;const dt=new ConnectionFailedError(`Could not connect to ${o.toString()}`);this.log.error("connection error:",dt),(ht=this.metrics)==null||ht.dialerEvents.increment({error:!0}),nt.reject(dt)});try{(st=tt.onProgress)==null||st.call(tt,new CustomProgressEvent("websockets:open-connection")),await raceSignal(Promise.race([ot.connected(),nt.promise]),tt.signal)}catch(dt){throw((at=tt.signal)==null?void 0:at.aborted)===!0&&((ct=this.metrics)==null||ct.dialerEvents.increment({abort:!0})),ot.close().catch(ht=>{this.log.error("error closing raw socket",ht)}),dt}return this.log("connected %s",o),(lt=this.metrics)==null||lt.dialerEvents.increment({connect:!0}),ot}createListener(o){return createListener({logger:this.logger,metrics:this.components.metrics},{...this.init,...o})}listenFilter(o){var tt,rt;return o=Array.isArray(o)?o:[o],((tt=this.init)==null?void 0:tt.filter)!=null?(rt=this.init)==null?void 0:rt.filter(o):isBrowser||isWebWorker?wss(o):all$1(o)}dialFilter(o){return this.listenFilter(o)}}function webSockets(et={}){return o=>new WebSockets(o,et)}const connectionSymbol=Symbol.for("@libp2p/connection"),contentRoutingSymbol=Symbol.for("@libp2p/content-routing"),peerDiscoverySymbol=Symbol.for("@libp2p/peer-discovery"),peerIdSymbol$1=Symbol.for("@libp2p/peer-id");function isPeerId$1(et){return!!(et!=null&&et[peerIdSymbol$1])}const peerRoutingSymbol=Symbol.for("@libp2p/peer-routing"),KEEP_ALIVE="keep-alive";var FaultTolerance;(function(et){et[et.FATAL_ALL=0]="FATAL_ALL",et[et.NO_FATAL=1]="NO_FATAL"})(FaultTolerance||(FaultTolerance={}));var Cs;let AbortError$4=(Cs=class extends Error{constructor(o="The operation was aborted"){super(o),this.name="AbortError"}},wt(Cs,"name","AbortError"),Cs);var Ss;let InvalidParametersError$1=(Ss=class extends Error{constructor(o="Invalid parameters"){super(o),this.name="InvalidParametersError"}},wt(Ss,"name","InvalidParametersError"),Ss);class ConnectionClosingError extends Error{constructor(o="The connection is closing"){super(o),this.name="ConnectionClosingError"}}wt(ConnectionClosingError,"name","ConnectionClosingError");class ConnectionClosedError extends Error{constructor(o="The connection is closed"){super(o),this.name="ConnectionClosedError"}}wt(ConnectionClosedError,"name","ConnectionClosedError");var As;let NotFoundError$1=(As=class extends Error{constructor(o="Not found"){super(o),this.name="NotFoundError"}},wt(As,"name","NotFoundError"),As);class InvalidPeerIdError extends Error{constructor(o="Invalid PeerID"){super(o),this.name="InvalidPeerIdError"}}wt(InvalidPeerIdError,"name","InvalidPeerIdError");class InvalidMultiaddrError extends Error{constructor(o="Invalid multiaddr"){super(o),this.name="InvalidMultiaddrError"}}wt(InvalidMultiaddrError,"name","InvalidMultiaddrError");var $s;let TimeoutError$2=($s=class extends Error{constructor(o="Timed out"){super(o),this.name="TimeoutError"}},wt($s,"name","TimeoutError"),$s);class NotStartedError extends Error{constructor(o="Not started"){super(o),this.name="NotStartedError"}}wt(NotStartedError,"name","NotStartedError");class DialError extends Error{constructor(o="Dial error"){super(o),this.name="DialError"}}wt(DialError,"name","DialError");class LimitedConnectionError extends Error{constructor(o="Limited connection"){super(o),this.name="LimitedConnectionError"}}wt(LimitedConnectionError,"name","LimitedConnectionError");class TooManyInboundProtocolStreamsError extends Error{constructor(o="Too many inbound protocol streams"){super(o),this.name="TooManyInboundProtocolStreamsError"}}wt(TooManyInboundProtocolStreamsError,"name","TooManyInboundProtocolStreamsError");class TooManyOutboundProtocolStreamsError extends Error{constructor(o="Too many outbound protocol streams"){super(o),this.name="TooManyOutboundProtocolStreamsError"}}wt(TooManyOutboundProtocolStreamsError,"name","TooManyOutboundProtocolStreamsError");function setMaxListeners$1(){}const setMaxListeners=(et,...o)=>{try{[...o]}catch{}};var en;class TypedEventEmitter extends EventTarget{constructor(){super();fr(this,en,new Map);setMaxListeners(1/0,this)}listenerCount(tt){const rt=Ot(this,en).get(tt);return rt==null?0:rt.length}addEventListener(tt,rt,nt){super.addEventListener(tt,rt,nt);let ot=Ot(this,en).get(tt);ot==null&&(ot=[],Ot(this,en).set(tt,ot)),ot.push({callback:rt,once:(nt!==!0&&nt!==!1&&(nt==null?void 0:nt.once))??!1})}removeEventListener(tt,rt,nt){super.removeEventListener(tt.toString(),rt??null,nt);let ot=Ot(this,en).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==rt),Ot(this,en).set(tt,ot))}dispatchEvent(tt){const rt=super.dispatchEvent(tt);let nt=Ot(this,en).get(tt.type);return nt==null||(nt=nt.filter(({once:ot})=>!ot),Ot(this,en).set(tt.type,nt)),rt}safeDispatchEvent(tt,rt={}){return this.dispatchEvent(new CustomEvent(tt,rt))}}en=new WeakMap;function isStartable(et){return et!=null&&typeof et.start=="function"&&typeof et.stop=="function"}async function start(...et){const o=[];for(const tt of et)isStartable(tt)&&o.push(tt);await Promise.all(o.map(async tt=>{tt.beforeStart!=null&&await tt.beforeStart()})),await Promise.all(o.map(async tt=>{await tt.start()})),await Promise.all(o.map(async tt=>{tt.afterStart!=null&&await tt.afterStart()}))}async function stop(...et){const o=[];for(const tt of et)isStartable(tt)&&o.push(tt);await Promise.all(o.map(async tt=>{tt.beforeStop!=null&&await tt.beforeStop()})),await Promise.all(o.map(async tt=>{await tt.stop()})),await Promise.all(o.map(async tt=>{tt.afterStop!=null&&await tt.afterStop()}))}const serviceCapabilities=Symbol.for("@libp2p/service-capabilities"),serviceDependencies=Symbol.for("@libp2p/service-dependencies");let TimeoutError$1=class extends Error{constructor(o){super(o),this.name="TimeoutError"}},AbortError$3=class extends Error{constructor(o){super(),this.name="AbortError",this.message=o}};const getDOMException=et=>globalThis.DOMException===void 0?new AbortError$3(et):new DOMException(et),getAbortedReason=et=>{const o=et.reason===void 0?getDOMException("This operation was aborted."):et.reason;return o instanceof Error?o:getDOMException(o)};function pTimeout(et,o){const{milliseconds:tt,fallback:rt,message:nt,customTimers:ot={setTimeout,clearTimeout}}=o;let it;const at=new Promise((ct,lt)=>{if(typeof tt!="number"||Math.sign(tt)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${tt}\``);if(o.signal){const{signal:ht}=o;ht.aborted&<(getAbortedReason(ht));const mt=()=>{lt(getAbortedReason(ht))};ht.addEventListener("abort",mt,{once:!0}),et.finally(()=>{ht.removeEventListener("abort",mt)})}if(tt===Number.POSITIVE_INFINITY){et.then(ct,lt);return}const dt=new TimeoutError$1;it=ot.setTimeout.call(void 0,()=>{if(rt){try{ct(rt())}catch(ht){lt(ht)}return}typeof et.cancel=="function"&&et.cancel(),nt===!1?ct():nt instanceof Error?lt(nt):(dt.message=nt??`Promise timed out after ${tt} milliseconds`,lt(dt))},tt),(async()=>{try{ct(await et)}catch(ht){lt(ht)}})()}).finally(()=>{at.clear()});return at.clear=()=>{ot.clearTimeout.call(void 0,it),it=void 0},at}function lowerBound(et,o,tt){let rt=0,nt=et.length;for(;nt>0;){const ot=Math.trunc(nt/2);let it=rt+ot;tt(et[it],o)<=0?(rt=++it,nt-=ot+1):nt=ot}return rt}var tn,Ml;let PriorityQueue$1=(Ml=class{constructor(){fr(this,tn,[])}enqueue(o,tt){tt={priority:0,...tt};const rt={priority:tt.priority,run:o};if(this.size&&Ot(this,tn)[this.size-1].priority>=tt.priority){Ot(this,tn).push(rt);return}const nt=lowerBound(Ot(this,tn),rt,(ot,it)=>it.priority-ot.priority);Ot(this,tn).splice(nt,0,rt)}dequeue(){const o=Ot(this,tn).shift();return o==null?void 0:o.run}filter(o){return Ot(this,tn).filter(tt=>tt.priority===o.priority).map(tt=>tt.run)}get size(){return Ot(this,tn).length}},tn=new WeakMap,Ml);var Zn,Jn,En,ho,eo,fo,Hr,to,Ur,po,Wr,ro,an,mo,kr,ru,nu,ou,iu,su,es,Ms,Bs,ts,au,rs;class PQueue extends EventEmitter$1{constructor(tt){var rt,nt;super();fr(this,kr);fr(this,Zn);fr(this,Jn);fr(this,En,0);fr(this,ho);fr(this,eo);fr(this,fo,0);fr(this,Hr);fr(this,to);fr(this,Ur);fr(this,po);fr(this,Wr,0);fr(this,ro);fr(this,an);fr(this,mo);wt(this,"timeout");if(tt={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:PriorityQueue$1,...tt},!(typeof tt.intervalCap=="number"&&tt.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${((rt=tt.intervalCap)==null?void 0:rt.toString())??""}\` (${typeof tt.intervalCap})`);if(tt.interval===void 0||!(Number.isFinite(tt.interval)&&tt.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${((nt=tt.interval)==null?void 0:nt.toString())??""}\` (${typeof tt.interval})`);lr(this,Zn,tt.carryoverConcurrencyCount),lr(this,Jn,tt.intervalCap===Number.POSITIVE_INFINITY||tt.interval===0),lr(this,ho,tt.intervalCap),lr(this,eo,tt.interval),lr(this,Ur,new tt.queueClass),lr(this,po,tt.queueClass),this.concurrency=tt.concurrency,this.timeout=tt.timeout,lr(this,mo,tt.throwOnTimeout===!0),lr(this,an,tt.autoStart===!1)}get concurrency(){return Ot(this,ro)}set concurrency(tt){if(!(typeof tt=="number"&&tt>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${tt}\` (${typeof tt})`);lr(this,ro,tt),mr(this,kr,ts).call(this)}async add(tt,rt={}){return rt={timeout:this.timeout,throwOnTimeout:Ot(this,mo),...rt},new Promise((nt,ot)=>{Ot(this,Ur).enqueue(async()=>{var it;Cn(this,Wr)._++,Cn(this,En)._++;try{(it=rt.signal)==null||it.throwIfAborted();let st=tt({signal:rt.signal});rt.timeout&&(st=pTimeout(Promise.resolve(st),{milliseconds:rt.timeout})),rt.signal&&(st=Promise.race([st,mr(this,kr,au).call(this,rt.signal)]));const at=await st;nt(at),this.emit("completed",at)}catch(st){if(st instanceof TimeoutError$1&&!rt.throwOnTimeout){nt();return}ot(st),this.emit("error",st)}finally{mr(this,kr,ou).call(this)}},rt),this.emit("add"),mr(this,kr,es).call(this)})}async addAll(tt,rt){return Promise.all(tt.map(async nt=>this.add(nt,rt)))}start(){return Ot(this,an)?(lr(this,an,!1),mr(this,kr,ts).call(this),this):this}pause(){lr(this,an,!0)}clear(){lr(this,Ur,new(Ot(this,po)))}async onEmpty(){Ot(this,Ur).size!==0&&await mr(this,kr,rs).call(this,"empty")}async onSizeLessThan(tt){Ot(this,Ur).sizeOt(this,Ur).size{mr(this,kr,iu).call(this)},rt)),!0}return!1},es=function(){if(Ot(this,Ur).size===0)return Ot(this,Hr)&&clearInterval(Ot(this,Hr)),lr(this,Hr,void 0),this.emit("empty"),Ot(this,Wr)===0&&this.emit("idle"),!1;if(!Ot(this,an)){const tt=!Ot(this,kr,su);if(Ot(this,kr,ru)&&Ot(this,kr,nu)){const rt=Ot(this,Ur).dequeue();return rt?(this.emit("active"),rt(),tt&&mr(this,kr,Ms).call(this),!0):!1}}return!1},Ms=function(){Ot(this,Jn)||Ot(this,Hr)!==void 0||(lr(this,Hr,setInterval(()=>{mr(this,kr,Bs).call(this)},Ot(this,eo))),lr(this,fo,Date.now()+Ot(this,eo)))},Bs=function(){Ot(this,En)===0&&Ot(this,Wr)===0&&Ot(this,Hr)&&(clearInterval(Ot(this,Hr)),lr(this,Hr,void 0)),lr(this,En,Ot(this,Zn)?Ot(this,Wr):0),mr(this,kr,ts).call(this)},ts=function(){for(;mr(this,kr,es).call(this););},au=async function(tt){return new Promise((rt,nt)=>{tt.addEventListener("abort",()=>{nt(tt.reason)},{once:!0})})},rs=async function(tt,rt){return new Promise(nt=>{const ot=()=>{rt&&!rt()||(this.off(tt,ot),nt())};this.on(tt,ot)})};function getTypes(et){const o=[RecordType.A];return et==null?o:Array.isArray(et)?et.length===0?o:et:[et]}function coerce$9(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$c(et){return new TextEncoder().encode(et)}function toString$g(et){return new TextDecoder().decode(et)}function base$9(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$a=base$9,_brrp__multiformats_scope_baseX$9=src$a;let Encoder$9=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$9=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$9(this,o)}},ComposedDecoder$9=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$9(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$9(et,o){return new ComposedDecoder$9({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$9=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$9(o,tt,rt),this.decoder=new Decoder$9(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$a({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$9(et,o,tt,rt)}function baseX$9({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$9(tt,et);return from$a({prefix:o,name:et,encode:rt,decode:ot=>coerce$9(nt(ot))})}function decode$q(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$l(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$6=alphabet$6.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$k(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$6[tt],o),"")}function decode$p(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$6[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$c=from$a({prefix:"🚀",name:"base256emoji",encode:encode$k,decode:decode$p}),base256emoji$d=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$c},Symbol.toStringTag,{value:"Module"})),base32$g=rfc4648$8({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$6=rfc4648$8({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$6=rfc4648$8({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$6=rfc4648$8({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$6=rfc4648$8({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$6=rfc4648$8({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$6=rfc4648$8({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$6=rfc4648$8({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$6=rfc4648$8({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$h=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$g,base32hex:base32hex$6,base32hexpad:base32hexpad$6,base32hexpadupper:base32hexpadupper$6,base32hexupper:base32hexupper$6,base32pad:base32pad$6,base32padupper:base32padupper$6,base32upper:base32upper$6,base32z:base32z$6},Symbol.toStringTag,{value:"Module"})),base36$d=baseX$9({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$6=baseX$9({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$e=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$d,base36upper:base36upper$6},Symbol.toStringTag,{value:"Module"})),base58btc$9=baseX$9({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$6=baseX$9({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$6=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$9,base58flickr:base58flickr$6},Symbol.toStringTag,{value:"Module"})),base64$f=rfc4648$8({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$6=rfc4648$8({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$6=rfc4648$8({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$6=rfc4648$8({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$g=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$f,base64pad:base64pad$6,base64url:base64url$6,base64urlpad:base64urlpad$6},Symbol.toStringTag,{value:"Module"})),base8$c=rfc4648$8({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$d=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$c},Symbol.toStringTag,{value:"Module"})),identity$6=from$a({prefix:"\0",name:"identity",encode:et=>toString$g(et),decode:et=>fromString$c(et)}),identityBase$6=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$6},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$6={...identityBase$6,...base2$d,...base8$d,...base10$d,...base16$d,...base32$h,...base36$e,...base58$6,...base64$g,...base256emoji$d};function allocUnsafe$5(et=0){return new Uint8Array(et)}function createCodec$6(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$9=createCodec$6("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$6=createCodec$6("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$5(et.length);for(let tt=0;tt({name:o.name,type:RecordType[o.type]})),Answer:(et.Answer??et.answers??[]).map(o=>({name:o.name,type:RecordType[o.type],TTL:o.TTL??o.ttl??DEFAULT_TTL,data:o.data instanceof Uint8Array?toString$f(o.data):o.data}))}}const DEFAULT_QUERY_CONCURRENCY=4;function dnsJsonOverHttps(et,o={}){const tt=new PQueue({concurrency:o.queryConcurrency??DEFAULT_QUERY_CONCURRENCY});return async(rt,nt={})=>{var st;const ot=new URLSearchParams;ot.set("name",rt),getTypes(nt.types).forEach(at=>{ot.append("type",RecordType[at])}),(st=nt.onProgress)==null||st.call(nt,new CustomProgressEvent("dns:query",{detail:rt}));const it=await tt.add(async()=>{var lt;const at=await fetch(`${et}?${ot}`,{headers:{accept:"application/dns-json"},signal:nt==null?void 0:nt.signal});if(at.status!==200)throw new Error(`Unexpected HTTP status: ${at.status} - ${at.statusText}`);const ct=toDNSResponse(await at.json());return(lt=nt.onProgress)==null||lt.call(nt,new CustomProgressEvent("dns:response",{detail:ct})),ct},{signal:nt.signal});if(it==null)throw new Error("No DNS response received");return it}}function defaultResolver(){return[dnsJsonOverHttps("https://cloudflare-dns.com/dns-query"),dnsJsonOverHttps("https://dns.google/resolve")]}var hashlru=function(et){if(!et)throw Error("hashlru must have a max value, of type number, greater than 0");var o=0,tt=Object.create(null),rt=Object.create(null);function nt(ot,it){tt[ot]=it,o++,o>=et&&(o=0,rt=tt,tt=Object.create(null))}return{has:function(ot){return tt[ot]!==void 0||rt[ot]!==void 0},remove:function(ot){tt[ot]!==void 0&&(tt[ot]=void 0),rt[ot]!==void 0&&(rt[ot]=void 0)},get:function(ot){var it=tt[ot];if(it!==void 0)return it;if((it=rt[ot])!==void 0)return nt(ot,it),it},set:function(ot,it){tt[ot]!==void 0?tt[ot]=it:nt(ot,it)},clear:function(){tt=Object.create(null),rt=Object.create(null)}}};const hashlru$1=getDefaultExportFromCjs(hashlru);class CachedAnswers{constructor(o){wt(this,"lru");this.lru=hashlru$1(o)}get(o,tt){let rt=!0;const nt=[];for(const ot of tt){const it=this.getAnswers(o,ot);if(it.length===0){rt=!1;break}nt.push(...it)}if(rt)return toDNSResponse({answers:nt})}getAnswers(o,tt){const rt=`${o.toLowerCase()}-${tt}`,nt=this.lru.get(rt);if(nt!=null){const ot=nt.filter(it=>it.expires>Date.now()).map(({expires:it,value:st})=>({...st,TTL:Math.round((it-Date.now())/1e3),type:RecordType[st.type]}));return ot.length===0&&this.lru.remove(rt),ot}return[]}add(o,tt){const rt=`${o.toLowerCase()}-${tt.type}`,nt=this.lru.get(rt)??[];nt.push({expires:Date.now()+(tt.TTL??DEFAULT_TTL)*1e3,value:tt}),this.lru.set(rt,nt)}remove(o,tt){const rt=`${o.toLowerCase()}-${tt}`;this.lru.remove(rt)}clear(){this.lru.clear()}}function cache$1(et){return new CachedAnswers(et)}const DEFAULT_ANSWER_CACHE_SIZE=1e3;class DNS{constructor(o){wt(this,"resolvers");wt(this,"cache");this.resolvers={},this.cache=cache$1(o.cacheSize??DEFAULT_ANSWER_CACHE_SIZE),Object.entries(o.resolvers??{}).forEach(([tt,rt])=>{Array.isArray(rt)||(rt=[rt]),tt.endsWith(".")||(tt=`${tt}.`),this.resolvers[tt]=rt}),this.resolvers["."]==null&&(this.resolvers["."]=defaultResolver())}async query(o,tt={}){var at,ct,lt;const rt=getTypes(tt.types),nt=tt.cached!==!1?this.cache.get(o,rt):void 0;if(nt!=null)return(at=tt.onProgress)==null||at.call(tt,new CustomProgressEvent("dns:cache",{detail:nt})),nt;const ot=`${o.split(".").pop()}.`,it=(this.resolvers[ot]??this.resolvers["."]).sort(()=>Math.random()>.5?-1:1),st=[];for(const dt of it){if(((ct=tt.signal)==null?void 0:ct.aborted)===!0)break;try{const ht=await dt(o,{...tt,types:rt});for(const mt of ht.Answer)this.cache.add(o,mt);return ht}catch(ht){st.push(ht),(lt=tt.onProgress)==null||lt.call(tt,new CustomProgressEvent("dns:error",{detail:ht}))}}throw st.length===1?st[0]:new AggregateError(st,`DNS lookup of ${o} ${rt} failed`)}}var RecordType;(function(et){et[et.A=1]="A",et[et.CNAME=5]="CNAME",et[et.TXT=16]="TXT",et[et.AAAA=28]="AAAA"})(RecordType||(RecordType={}));function dns(et={}){return new DNS(et)}const MAX_RECURSIVE_DEPTH=32,{code:dnsaddrCode}=getProtocol("dnsaddr");class RecursionLimitError extends Error{constructor(o="Max recursive depth reached"){super(o),this.name="RecursionLimitError"}}const dnsaddrResolver=async function(o,tt={}){const rt=tt.maxRecursiveDepth??MAX_RECURSIVE_DEPTH;if(rt===0)throw new RecursionLimitError("Max recursive depth reached");const[,nt]=o.stringTuples().find(([ct])=>ct===dnsaddrCode)??[],it=await((tt==null?void 0:tt.dns)??dns()).query(`_dnsaddr.${nt}`,{signal:tt==null?void 0:tt.signal,types:[RecordType.TXT]}),st=o.getPeerId(),at=[];for(const ct of it.Answer){const lt=ct.data.replace(/["']/g,"").trim().split("=")[1];if(lt==null||st!=null&&!lt.includes(st))continue;const dt=multiaddr(lt);if(lt.startsWith("/dnsaddr")){const ht=await dt.resolve({...tt,maxRecursiveDepth:rt-1});at.push(...ht.map(mt=>mt.toString()))}else at.push(dt.toString())}return at};var isPlainObj=et=>{if(Object.prototype.toString.call(et)!=="[object Object]")return!1;const o=Object.getPrototypeOf(et);return o===null||o===Object.prototype};const isOptionObject=isPlainObj,{hasOwnProperty:hasOwnProperty$1}=Object.prototype,{propertyIsEnumerable}=Object,defineProperty$1=(et,o,tt)=>Object.defineProperty(et,o,{value:tt,writable:!0,enumerable:!0,configurable:!0}),globalThis$1=commonjsGlobal,defaultMergeOptions={concatArrays:!1,ignoreUndefined:!1},getEnumerableOwnPropertyKeys=et=>{const o=[];for(const tt in et)hasOwnProperty$1.call(et,tt)&&o.push(tt);if(Object.getOwnPropertySymbols){const tt=Object.getOwnPropertySymbols(et);for(const rt of tt)propertyIsEnumerable.call(et,rt)&&o.push(rt)}return o};function clone(et){return Array.isArray(et)?cloneArray(et):isOptionObject(et)?cloneOptionObject(et):et}function cloneArray(et){const o=et.slice(0,0);return getEnumerableOwnPropertyKeys(et).forEach(tt=>{defineProperty$1(o,tt,clone(et[tt]))}),o}function cloneOptionObject(et){const o=Object.getPrototypeOf(et)===null?Object.create(null):{};return getEnumerableOwnPropertyKeys(et).forEach(tt=>{defineProperty$1(o,tt,clone(et[tt]))}),o}const mergeKeys=(et,o,tt,rt)=>(tt.forEach(nt=>{typeof o[nt]>"u"&&rt.ignoreUndefined||(nt in et&&et[nt]!==Object.getPrototypeOf(et)?defineProperty$1(et,nt,merge$1(et[nt],o[nt],rt)):defineProperty$1(et,nt,clone(o[nt])))}),et),concatArrays=(et,o,tt)=>{let rt=et.slice(0,0),nt=0;return[et,o].forEach(ot=>{const it=[];for(let st=0;st!it.includes(st)),tt)}),rt};function merge$1(et,o,tt){return tt.concatArrays&&Array.isArray(et)&&Array.isArray(o)?concatArrays(et,o,tt):!isOptionObject(o)||!isOptionObject(et)?clone(o):mergeKeys(et,o,getEnumerableOwnPropertyKeys(o),tt)}var mergeOptions=function(...et){const o=merge$1(clone(defaultMergeOptions),this!==globalThis$1&&this||{},defaultMergeOptions);let tt={_:{}};for(const rt of et)if(rt!==void 0){if(!isOptionObject(rt))throw new TypeError("`"+rt+"` is not an Option Object");tt=merge$1(tt,{_:rt},o)}return tt._};const mergeOptions$1=getDefaultExportFromCjs(mergeOptions);var define_globalThis_process_env_default$1={};const DefaultConfig={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:et=>et},connectionManager:{resolvers:{dnsaddr:dnsaddrResolver}},transportManager:{faultTolerance:FaultTolerance.FATAL_ALL}};async function validateConfig(et){const o=mergeOptions$1(DefaultConfig,et);if(o.connectionProtector===null&&(define_globalThis_process_env_default$1==null?void 0:define_globalThis_process_env_default$1.LIBP2P_FORCE_PNET)!=null)throw new InvalidParametersError$1("Private network is enforced, but no protector was provided");return o}function coerce$8(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function base$8(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$9=base$8,_brrp__multiformats_scope_baseX$8=src$9;let Encoder$8=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$8=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$8(this,o)}},ComposedDecoder$8=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$8(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$8(et,o){return new ComposedDecoder$8({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$8=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$8(o,tt,rt),this.decoder=new Decoder$8(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$9({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$8(et,o,tt,rt)}function baseX$8({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$8(tt,et);return from$9({prefix:o,name:et,encode:rt,decode:ot=>coerce$8(nt(ot))})}function decode$o(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$j(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<0)return parse$3(et);if(typeof et=="number"&&isFinite(et))return o!=null&&o.long?fmtLong(et):fmtShort(et);throw new Error("Value is not a string or number.")}catch(tt){const rt=isError$1(tt)?`${tt.message}. value=${JSON.stringify(et)}`:"An unknown error has occured.";throw new Error(rt)}}function parse$3(et){if(et=String(et),et.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");const o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(et);if(!o)return NaN;const tt=parseFloat(o[1]),rt=(o[2]||"ms").toLowerCase();switch(rt){case"years":case"year":case"yrs":case"yr":case"y":return tt*y;case"weeks":case"week":case"w":return tt*w;case"days":case"day":case"d":return tt*d;case"hours":case"hour":case"hrs":case"hr":case"h":return tt*h;case"minutes":case"minute":case"mins":case"min":case"m":return tt*m;case"seconds":case"second":case"secs":case"sec":case"s":return tt*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return tt;default:throw new Error(`The unit ${rt} was matched, but no matching case exists.`)}}function fmtShort(et){const o=Math.abs(et);return o>=d?`${Math.round(et/d)}d`:o>=h?`${Math.round(et/h)}h`:o>=m?`${Math.round(et/m)}m`:o>=s?`${Math.round(et/s)}s`:`${et}ms`}function fmtLong(et){const o=Math.abs(et);return o>=d?plural(et,o,d,"day"):o>=h?plural(et,o,h,"hour"):o>=m?plural(et,o,m,"minute"):o>=s?plural(et,o,s,"second"):`${et} ms`}function plural(et,o,tt,rt){const nt=o>=tt*1.5;return`${Math.round(et/tt)} ${rt}${nt?"s":""}`}function isError$1(et){return typeof et=="object"&&et!==null&&"message"in et}function setup(et){tt.debug=tt,tt.default=tt,tt.coerce=at,tt.disable=ot,tt.enable=nt,tt.enabled=it,tt.humanize=ms,tt.destroy=ct,Object.keys(et).forEach(lt=>{tt[lt]=et[lt]}),tt.names=[],tt.skips=[],tt.formatters={};function o(lt){let dt=0;for(let ht=0;ht{if(Ct==="%%")return"%";vt++;const At=tt.formatters[St];if(typeof At=="function"){const kt=yt[vt];Ct=At.call(gt,kt),yt.splice(vt,1),vt--}return Ct}),tt.formatArgs.call(gt,yt),(gt.log||tt.log).apply(gt,yt)}return pt.namespace=lt,pt.useColors=tt.useColors(),pt.color=tt.selectColor(lt),pt.extend=rt,pt.destroy=tt.destroy,Object.defineProperty(pt,"enabled",{enumerable:!0,configurable:!1,get:()=>ht!==null?ht:(mt!==tt.namespaces&&(mt=tt.namespaces,ft=tt.enabled(lt)),ft),set:yt=>{ht=yt}}),typeof tt.init=="function"&&tt.init(pt),pt}function rt(lt,dt){const ht=tt(this.namespace+(typeof dt>"u"?":":dt)+lt);return ht.log=this.log,ht}function nt(lt){tt.save(lt),tt.namespaces=lt,tt.names=[],tt.skips=[];let dt;const ht=(typeof lt=="string"?lt:"").split(/[\s,]+/),mt=ht.length;for(dt=0;dt"-"+dt)].join(",");return tt.enable(""),lt}function it(lt){if(lt[lt.length-1]==="*")return!0;let dt,ht;for(dt=0,ht=tt.skips.length;dt=31||typeof navigator<"u"&&((nt=navigator.userAgent)==null?void 0:nt.toLowerCase().match(/applewebkit\/(\d+)/))}function formatArgs(et){if(et[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+et[0]+(this.useColors?"%c ":" ")+"+"+ms(this.diff),!this.useColors)return;const o="color: "+this.color;et.splice(1,0,o,"color: inherit");let tt=0,rt=0;et[0].replace(/%[a-zA-Z%]/g,nt=>{nt!=="%%"&&(tt++,nt==="%c"&&(rt=tt))}),et.splice(rt,0,o)}const log$a=console.debug??console.log??(()=>{});function save(et){try{et?storage==null||storage.setItem("debug",et):storage==null||storage.removeItem("debug")}catch{}}function load$1(){let et;try{et=storage==null?void 0:storage.getItem("debug")}catch{}return!et&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(et=define_globalThis_process_env_default.DEBUG),et}function localstorage(){try{return localStorage}catch{}}function setupFormatters(et){et.j=function(o){try{return JSON.stringify(o)}catch(tt){return"[UnexpectedJSONParseError]: "+tt.message}}}const weald=setup({formatArgs,save,load:load$1,useColors,setupFormatters,colors,storage,log:log$a});weald.formatters.b=et=>et==null?"undefined":base58btc$8.baseEncode(et);weald.formatters.t=et=>et==null?"undefined":base32$f.baseEncode(et);weald.formatters.m=et=>et==null?"undefined":base64$e.baseEncode(et);weald.formatters.p=et=>et==null?"undefined":et.toString();weald.formatters.c=et=>et==null?"undefined":et.toString();weald.formatters.k=et=>et==null?"undefined":et.toString();weald.formatters.a=et=>et==null?"undefined":et.toString();weald.formatters.e=et=>et==null?"undefined":notEmpty(et.stack)??notEmpty(et.message)??et.toString();function createDisabledLogger(et){const o=()=>{};return o.enabled=!1,o.color="",o.diff=0,o.log=()=>{},o.namespace=et,o.destroy=()=>!0,o.extend=()=>o,o}function defaultLogger(){return{forComponent(et){return logger$2(et)}}}function logger$2(et){let o=createDisabledLogger(`${et}:trace`);return weald.enabled(`${et}:trace`)&&weald.names.map(tt=>tt.toString()).find(tt=>tt.includes(":trace"))!=null&&(o=weald(`${et}:trace`)),Object.assign(weald(et),{error:weald(`${et}:error`),trace:o})}function notEmpty(et){if(et!=null&&(et=et.trim(),et.length!==0))return et}function coerce$7(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function base$7(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$8=base$7,_brrp__multiformats_scope_baseX$7=src$8;let Encoder$7=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$7=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$7(this,o)}},ComposedDecoder$7=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$7(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$7(et,o){return new ComposedDecoder$7({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$7=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$7(o,tt,rt),this.decoder=new Decoder$7(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$8({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$7(et,o,tt,rt)}function baseX$7({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$7(tt,et);return from$8({prefix:o,name:et,encode:rt,decode:ot=>coerce$7(nt(ot))})}const base58btc$7=baseX$7({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"});baseX$7({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var encode_1$1=encode$i,MSB$2=128,REST$2=127,MSBALL$1=~REST$2,INT$1=Math.pow(2,31);function encode$i(et,o,tt){o=o||[],tt=tt||0;for(var rt=tt;et>=INT$1;)o[tt++]=et&255|MSB$2,et/=128;for(;et&MSBALL$1;)o[tt++]=et&255|MSB$2,et>>>=7;return o[tt]=et|0,encode$i.bytes=tt-rt+1,o}var decode$n=read$2,MSB$1$1=128,REST$1$1=127;function read$2(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$2.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1$1)<=MSB$1$1);return read$2.bytes=ot-rt,tt}var N1$1=Math.pow(2,7),N2$1=Math.pow(2,14),N3$1=Math.pow(2,21),N4$1=Math.pow(2,28),N5$1=Math.pow(2,35),N6$1=Math.pow(2,42),N7$1=Math.pow(2,49),N8$1=Math.pow(2,56),N9$1=Math.pow(2,63),length$1=function(et){return ettt,next:()=>{const rt=et.next(),nt=rt.value;return rt.done===!0||nt==null?{done:!0,value:void 0}:{done:!1,value:o(nt)}}};return tt}function peerIdFromString(et){const o=decode$l(base58btc$7.decode(`z${et}`));return peerIdFromMultihash(o)}class PeerMap{constructor(o){wt(this,"map");if(this.map=new Map,o!=null)for(const[tt,rt]of o.entries())this.map.set(tt.toString(),{key:tt,value:rt})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(o){return this.map.delete(o.toString())}entries(){return mapIterable(this.map.entries(),o=>[o[1].key,o[1].value])}forEach(o){this.map.forEach((tt,rt)=>{o(tt.value,tt.key,this)})}get(o){var tt;return(tt=this.map.get(o.toString()))==null?void 0:tt.value}has(o){return this.map.has(o.toString())}set(o,tt){this.map.set(o.toString(),{key:o,value:tt})}keys(){return mapIterable(this.map.values(),o=>o.key)}values(){return mapIterable(this.map.values(),o=>o.value)}get size(){return this.map.size}}class PeerSet{constructor(o){wt(this,"set");if(this.set=new Set,o!=null)for(const tt of o)this.set.add(tt.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=>{const tt=peerIdFromString(o[0]);return[tt,tt]})}forEach(o){this.set.forEach(tt=>{const rt=peerIdFromString(tt);o(rt,rt,this)})}has(o){return this.set.has(o.toString())}values(){return mapIterable(this.set.values(),o=>peerIdFromString(o))}intersection(o){const tt=new PeerSet;for(const rt of o)this.has(rt)&&tt.add(rt);return tt}difference(o){const tt=new PeerSet;for(const rt of this)o.has(rt)||tt.add(rt);return tt}union(o){const tt=new PeerSet;for(const rt of o)tt.add(rt);for(const rt of this)tt.add(rt);return tt}}var murmurHash3js={exports:{}};(function(et,o){(function(tt,rt){var nt={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function ot(pt){if(!Array.isArray(pt)&&!ArrayBuffer.isView(pt))return!1;for(var yt=0;yt255)return!1;return!0}function it(pt,yt){return(pt&65535)*yt+(((pt>>>16)*yt&65535)<<16)}function st(pt,yt){return pt<>>32-yt}function at(pt){return pt^=pt>>>16,pt=it(pt,2246822507),pt^=pt>>>13,pt=it(pt,3266489909),pt^=pt>>>16,pt}function ct(pt,yt){pt=[pt[0]>>>16,pt[0]&65535,pt[1]>>>16,pt[1]&65535],yt=[yt[0]>>>16,yt[0]&65535,yt[1]>>>16,yt[1]&65535];var gt=[0,0,0,0];return gt[3]+=pt[3]+yt[3],gt[2]+=gt[3]>>>16,gt[3]&=65535,gt[2]+=pt[2]+yt[2],gt[1]+=gt[2]>>>16,gt[2]&=65535,gt[1]+=pt[1]+yt[1],gt[0]+=gt[1]>>>16,gt[1]&=65535,gt[0]+=pt[0]+yt[0],gt[0]&=65535,[gt[0]<<16|gt[1],gt[2]<<16|gt[3]]}function lt(pt,yt){pt=[pt[0]>>>16,pt[0]&65535,pt[1]>>>16,pt[1]&65535],yt=[yt[0]>>>16,yt[0]&65535,yt[1]>>>16,yt[1]&65535];var gt=[0,0,0,0];return gt[3]+=pt[3]*yt[3],gt[2]+=gt[3]>>>16,gt[3]&=65535,gt[2]+=pt[2]*yt[3],gt[1]+=gt[2]>>>16,gt[2]&=65535,gt[2]+=pt[3]*yt[2],gt[1]+=gt[2]>>>16,gt[2]&=65535,gt[1]+=pt[1]*yt[3],gt[0]+=gt[1]>>>16,gt[1]&=65535,gt[1]+=pt[2]*yt[2],gt[0]+=gt[1]>>>16,gt[1]&=65535,gt[1]+=pt[3]*yt[1],gt[0]+=gt[1]>>>16,gt[1]&=65535,gt[0]+=pt[0]*yt[3]+pt[1]*yt[2]+pt[2]*yt[1]+pt[3]*yt[0],gt[0]&=65535,[gt[0]<<16|gt[1],gt[2]<<16|gt[3]]}function dt(pt,yt){return yt%=64,yt===32?[pt[1],pt[0]]:yt<32?[pt[0]<>>32-yt,pt[1]<>>32-yt]:(yt-=32,[pt[1]<>>32-yt,pt[0]<>>32-yt])}function ht(pt,yt){return yt%=64,yt===0?pt:yt<32?[pt[0]<>>32-yt,pt[1]<>>1]),pt=lt(pt,[4283543511,3981806797]),pt=mt(pt,[0,pt[0]>>>1]),pt=lt(pt,[3301882366,444984403]),pt=mt(pt,[0,pt[0]>>>1]),pt}nt.x86.hash32=function(pt,yt){if(nt.inputValidation&&!ot(pt))return rt;yt=yt||0;for(var gt=pt.length%4,bt=pt.length-gt,xt=yt,vt=0,Et=3432918353,Ct=461845907,St=0;St>>0},nt.x86.hash128=function(pt,yt){if(nt.inputValidation&&!ot(pt))return rt;yt=yt||0;for(var gt=pt.length%16,bt=pt.length-gt,xt=yt,vt=yt,Et=yt,Ct=yt,St=0,At=0,kt=0,It=0,Nt=597399067,Lt=2869860233,Mt=951274213,zt=2716044179,Ut=0;Ut>>0).toString(16)).slice(-8)+("00000000"+(vt>>>0).toString(16)).slice(-8)+("00000000"+(Et>>>0).toString(16)).slice(-8)+("00000000"+(Ct>>>0).toString(16)).slice(-8)},nt.x64.hash128=function(pt,yt){if(nt.inputValidation&&!ot(pt))return rt;yt=yt||0;for(var gt=pt.length%16,bt=pt.length-gt,xt=[0,yt],vt=[0,yt],Et=[0,0],Ct=[0,0],St=[2277735313,289559509],At=[1291169091,658871167],kt=0;kt>>0).toString(16)).slice(-8)+("00000000"+(xt[1]>>>0).toString(16)).slice(-8)+("00000000"+(vt[0]>>>0).toString(16)).slice(-8)+("00000000"+(vt[1]>>>0).toString(16)).slice(-8)},et.exports&&(o=et.exports=nt),o.murmurHash3=nt})()})(murmurHash3js,murmurHash3js.exports);function alloc$2(et=0){return new Uint8Array(et)}function allocUnsafe$4(et=0){return new Uint8Array(et)}function coerce$6(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$b(et){return new TextEncoder().encode(et)}function toString$e(et){return new TextDecoder().decode(et)}function base$6(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$7=base$6,_brrp__multiformats_scope_baseX$6=src$7;let Encoder$6=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$6=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$6(this,o)}},ComposedDecoder$6=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$6(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$6(et,o){return new ComposedDecoder$6({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$6=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$6(o,tt,rt),this.decoder=new Decoder$6(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$7({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$6(et,o,tt,rt)}function baseX$6({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$6(tt,et);return from$7({prefix:o,name:et,encode:rt,decode:ot=>coerce$6(nt(ot))})}function decode$k(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$h(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$5=alphabet$5.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$g(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$5[tt],o),"")}function decode$j(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$5[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$a=from$7({prefix:"🚀",name:"base256emoji",encode:encode$g,decode:decode$j}),base256emoji$b=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$a},Symbol.toStringTag,{value:"Module"})),base32$d=rfc4648$6({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$5=rfc4648$6({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$5=rfc4648$6({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$5=rfc4648$6({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$5=rfc4648$6({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$5=rfc4648$6({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$5=rfc4648$6({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$5=rfc4648$6({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$5=rfc4648$6({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$e=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$d,base32hex:base32hex$5,base32hexpad:base32hexpad$5,base32hexpadupper:base32hexpadupper$5,base32hexupper:base32hexupper$5,base32pad:base32pad$5,base32padupper:base32padupper$5,base32upper:base32upper$5,base32z:base32z$5},Symbol.toStringTag,{value:"Module"})),base36$b=baseX$6({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$5=baseX$6({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$c=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$b,base36upper:base36upper$5},Symbol.toStringTag,{value:"Module"})),base58btc$6=baseX$6({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$5=baseX$6({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$5=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$6,base58flickr:base58flickr$5},Symbol.toStringTag,{value:"Module"})),base64$c=rfc4648$6({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$5=rfc4648$6({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$5=rfc4648$6({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$5=rfc4648$6({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$d=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$c,base64pad:base64pad$5,base64url:base64url$5,base64urlpad:base64urlpad$5},Symbol.toStringTag,{value:"Module"})),base8$a=rfc4648$6({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$b=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$a},Symbol.toStringTag,{value:"Module"})),identity$5=from$7({prefix:"\0",name:"identity",encode:et=>toString$e(et),decode:et=>fromString$b(et)}),identityBase$5=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$5},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$5={...identityBase$5,...base2$b,...base8$b,...base10$b,...base16$b,...base32$e,...base36$c,...base58$5,...base64$d,...base256emoji$b};function createCodec$5(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$8=createCodec$5("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$5=createCodec$5("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$4(et.length);for(let tt=0;ttMAX_FINGERPRINT_SIZE)throw new TypeError("Invalid Fingerprint Size");const ot=tt.hashV(o,rt),it=alloc$2(nt);for(let st=0;sto.equals(tt))}add(o){if(!(o instanceof Fingerprint))throw new TypeError("Invalid Fingerprint");for(let tt=0;tto.equals(rt));return tt>-1?(this.contents[tt]=null,!0):!1}}const FNV_PRIMES={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},FNV_OFFSETS={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},cachedEncoder=new globalThis.TextEncoder;function fnv1aUint8Array(et,o){const tt=FNV_PRIMES[o];let rt=FNV_OFFSETS[o];for(let nt=0;nt0;){const it=cachedEncoder.encodeInto(ot,tt);ot=ot.slice(it.read);for(let st=0;stNumber(fnv1a$1(et,{size:32})),hashV:(et,o)=>numberToBuffer(fnv1a.hash(et,o))};function numberToBuffer(et){let o=et.toString(16);return o.length%2===1&&(o=`0${o}`),fromString$a(o,"base16")}const maxCuckooCount=500;class CuckooFilter{constructor(o){wt(this,"bucketSize");wt(this,"filterSize");wt(this,"fingerprintSize");wt(this,"buckets");wt(this,"count");wt(this,"hash");wt(this,"seed");this.filterSize=o.filterSize,this.bucketSize=o.bucketSize??4,this.fingerprintSize=o.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=o.hash??fnv1a,this.seed=o.seed??getRandomInt(0,Math.pow(2,10))}add(o){typeof o=="string"&&(o=fromString$a(o));const tt=new Fingerprint(o,this.hash,this.seed,this.fingerprintSize),rt=this.hash.hash(o,this.seed)%this.filterSize,nt=(rt^tt.hash())%this.filterSize;if(this.buckets[rt]==null&&(this.buckets[rt]=new Bucket(this.bucketSize)),this.buckets[nt]==null&&(this.buckets[nt]=new Bucket(this.bucketSize)),this.buckets[rt].add(tt)||this.buckets[nt].add(tt))return this.count++,!0;const ot=[rt,nt];let it=ot[getRandomInt(0,ot.length-1)];this.buckets[it]==null&&(this.buckets[it]=new Bucket(this.bucketSize));for(let st=0;st.002?2:et>1e-5?4:8}function optimize(et,o=.001){const tt=calculateBucketSize(o),rt=MAX_LOAD[tt],nt=Math.round(et/rt),ot=Math.min(Math.ceil(Math.log2(1/o)+Math.log2(2*tt)),MAX_FINGERPRINT_SIZE);return{filterSize:nt,bucketSize:tt,fingerprintSize:ot}}class ScalableCuckooFilter{constructor(o){wt(this,"filterSize");wt(this,"bucketSize");wt(this,"fingerprintSize");wt(this,"scale");wt(this,"filterSeries");wt(this,"hash");wt(this,"seed");this.bucketSize=o.bucketSize??4,this.filterSize=o.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=o.fingerprintSize??2,this.scale=o.scale??2,this.hash=o.hash??fnv1a,this.seed=o.seed??getRandomInt(0,Math.pow(2,10)),this.filterSeries=[new CuckooFilter({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(o){if(typeof o=="string"&&(o=fromString$a(o)),this.has(o))return!0;let tt=this.filterSeries.find(rt=>rt.reliable);if(tt==null){const rt=this.filterSize*Math.pow(this.scale,this.filterSeries.length);tt=new CuckooFilter({filterSize:rt,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(tt)}return tt.add(o)}has(o){typeof o=="string"&&(o=fromString$a(o));for(let tt=0;tto+tt.count,0)}}function createScalableCuckooFilter(et,o=.001,tt){return new ScalableCuckooFilter({...optimize(et,o)})}const peerIdSymbol=Symbol.for("@libp2p/peer-id");function isPeerId(et){return!!(et!=null&&et[peerIdSymbol])}class InvalidParametersError extends Error{constructor(o="Invalid parameters"){super(o),this.name="InvalidParametersError"}}wt(InvalidParametersError,"name","InvalidParametersError");const events={},observable=et=>{et.addEventListener("message",o=>{observable.dispatchEvent("message",et,o)}),et.port!=null&&et.port.addEventListener("message",o=>{observable.dispatchEvent("message",et,o)})};observable.addEventListener=(et,o)=>{events[et]==null&&(events[et]=[]),events[et].push(o)};observable.removeEventListener=(et,o)=>{events[et]!=null&&(events[et]=events[et].filter(tt=>tt===o))};observable.dispatchEvent=function(et,o,tt){events[et]!=null&&events[et].forEach(rt=>rt(o,tt))};const WORKER_REQUEST_READ_LOCK="lock:worker:request-read",WORKER_RELEASE_READ_LOCK="lock:worker:release-read",MASTER_GRANT_READ_LOCK="lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK="lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK="lock:worker:release-write",MASTER_GRANT_WRITE_LOCK="lock:master:grant-write",nanoid=(et=21)=>Math.random().toString().substring(2),handleWorkerLockRequest=(et,o,tt,rt,nt)=>(ot,it)=>{if(it.data.type!==tt)return;const st={type:it.data.type,name:it.data.name,identifier:it.data.identifier};et.dispatchEvent(new MessageEvent(o,{data:{name:st.name,handler:async()=>{ot.postMessage({type:nt,name:st.name,identifier:st.identifier}),await new Promise(at=>{const ct=lt=>{if((lt==null?void 0:lt.data)==null)return;const dt={type:lt.data.type,name:lt.data.name,identifier:lt.data.identifier};dt.type===rt&&dt.identifier===st.identifier&&(ot.removeEventListener("message",ct),at())};ot.addEventListener("message",ct)})}}}))},makeWorkerLockRequest=(et,o,tt,rt)=>async()=>{const nt=nanoid();return globalThis.postMessage({type:o,identifier:nt,name:et}),new Promise(ot=>{const it=st=>{if((st==null?void 0:st.data)==null)return;const at={type:st.data.type,identifier:st.data.identifier};at.type===tt&&at.identifier===nt&&(globalThis.removeEventListener("message",it),ot(()=>{globalThis.postMessage({type:rt,identifier:nt,name:et})}))};globalThis.addEventListener("message",it)})},defaultOptions$4={singleProcess:!1},impl=et=>{if(et=Object.assign({},defaultOptions$4,et),!!globalThis.document||et.singleProcess){const tt=new EventTarget;return observable.addEventListener("message",handleWorkerLockRequest(tt,"requestReadLock",WORKER_REQUEST_READ_LOCK,WORKER_RELEASE_READ_LOCK,MASTER_GRANT_READ_LOCK)),observable.addEventListener("message",handleWorkerLockRequest(tt,"requestWriteLock",WORKER_REQUEST_WRITE_LOCK,WORKER_RELEASE_WRITE_LOCK,MASTER_GRANT_WRITE_LOCK)),tt}return{isWorker:!0,readLock:tt=>makeWorkerLockRequest(tt,WORKER_REQUEST_READ_LOCK,MASTER_GRANT_READ_LOCK,WORKER_RELEASE_READ_LOCK),writeLock:tt=>makeWorkerLockRequest(tt,WORKER_REQUEST_WRITE_LOCK,MASTER_GRANT_WRITE_LOCK,WORKER_RELEASE_WRITE_LOCK)}},mutexes={};let implementation;async function createReleaseable(et,o){let tt;const rt=new Promise(nt=>{tt=nt});return et.add(async()=>pTimeout((async()=>{await new Promise(nt=>{tt(()=>{nt()})})})(),{milliseconds:o.timeout})),rt}const createMutex=(et,o)=>{if(implementation.isWorker===!0)return{readLock:implementation.readLock(et,o),writeLock:implementation.writeLock(et,o)};const tt=new PQueue({concurrency:1});let rt;return{async readLock(){if(rt!=null)return createReleaseable(rt,o);rt=new PQueue({concurrency:o.concurrency,autoStart:!1});const nt=rt,ot=createReleaseable(rt,o);return tt.add(async()=>{nt.start(),await nt.onIdle().then(()=>{rt===nt&&(rt=null)})}),ot},async writeLock(){return rt=null,createReleaseable(tt,o)}}},defaultOptions$3={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function createMortice(et){const o=Object.assign({},defaultOptions$3,et);return implementation==null&&(implementation=impl(o),implementation.isWorker!==!0&&(implementation.addEventListener("requestReadLock",tt=>{mutexes[tt.data.name]!=null&&mutexes[tt.data.name].readLock().then(async rt=>tt.data.handler().finally(()=>{rt()}))}),implementation.addEventListener("requestWriteLock",async tt=>{mutexes[tt.data.name]!=null&&mutexes[tt.data.name].writeLock().then(async rt=>tt.data.handler().finally(()=>{rt()}))}))),mutexes[o.name]==null&&(mutexes[o.name]=createMutex(o.name,o)),mutexes[o.name]}function equals$2(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$6=base$5,_brrp__multiformats_scope_baseX$5=src$6;let Encoder$5=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$5=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$5(this,o)}},ComposedDecoder$5=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$5(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$5(et,o){return new ComposedDecoder$5({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$5=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$5(o,tt,rt),this.decoder=new Decoder$5(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$6({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$5(et,o,tt,rt)}function baseX$5({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$5(tt,et);return from$6({prefix:o,name:et,encode:rt,decode:ot=>coerce$5(nt(ot))})}function decode$i(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$f(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<=INT;)o[tt++]=et&255|MSB,et/=128;for(;et&MSBALL;)o[tt++]=et&255|MSB,et>>>=7;return o[tt]=et|0,encode$e.bytes=tt-rt+1,o}var decode$h=read$1,MSB$1=128,REST$1=127;function read$1(et,rt){var tt=0,rt=rt||0,nt=0,ot=rt,it,st=et.length;do{if(ot>=st)throw read$1.bytes=0,new RangeError("Could not decode varint");it=et[ot++],tt+=nt<28?(it&REST$1)<=MSB$1);return read$1.bytes=ot-rt,tt}var N1=Math.pow(2,7),N2=Math.pow(2,14),N3=Math.pow(2,21),N4=Math.pow(2,28),N5=Math.pow(2,35),N6=Math.pow(2,42),N7=Math.pow(2,49),N8=Math.pow(2,56),N9=Math.pow(2,63),length=function(et){return et{const[dt,ht]=decode$g(o.subarray(tt));return tt+=ht,dt};let nt=rt(),ot=DAG_PB_CODE;if(nt===18?(nt=0,tt=0):ot=rt(),nt!==0&&nt!==1)throw new RangeError(`Invalid CID version ${nt}`);const it=tt,st=rt(),at=rt(),ct=tt+at,lt=ct-it;return{version:nt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(o,tt){const[rt,nt]=parseCIDtoBytes(o,tt),ot=CID.decode(nt);if(ot.version===0&&o[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache(ot).set(rt,o),ot}}function parseCIDtoBytes(et,o){switch(et[0]){case"Q":{const tt=o??base58btc$5;return[base58btc$5.prefix,tt.decode(`${base58btc$5.prefix}${et}`)]}case base58btc$5.prefix:{const tt=o??base58btc$5;return[base58btc$5.prefix,tt.decode(et)]}case base32$c.prefix:{const tt=o??base32$c;return[base32$c.prefix,tt.decode(et)]}case base36$a.prefix:{const tt=o??base36$a;return[base36$a.prefix,tt.decode(et)]}default:{if(o==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[et[0],o.decode(et)]}}}function toStringV0(et,o,tt){const{prefix:rt}=tt;if(rt!==base58btc$5.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const nt=o.get(rt);if(nt==null){const ot=tt.encode(et).slice(1);return o.set(rt,ot),ot}else return nt}function toStringV1(et,o,tt){const{prefix:rt}=tt,nt=o.get(rt);if(nt==null){const ot=tt.encode(et);return o.set(rt,ot),ot}else return nt}const DAG_PB_CODE=112,SHA_256_CODE=18;function encodeCID(et,o,tt){const rt=encodingLength$2(et),nt=rt+encodingLength$2(o),ot=new Uint8Array(nt+tt.byteLength);return encodeTo(et,ot,0),encodeTo(o,ot,rt),ot.set(tt,nt),ot}const cidSymbol=Symbol.for("@ipld/js-cid/CID");function equals(et,o){if(et===o)return!0;if(et.byteLength!==o.byteLength)return!1;for(let tt=0;tt(rt==null&&(rt=message$1((nt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),nt.key!=null&&nt.key!==""&&(ot.uint32(10),ot.string(nt.key)),nt.value!=null&&nt.value.byteLength>0&&(ot.uint32(18),ot.bytes(nt.value)),it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{const st={key:"",value:alloc$1(0)},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.key=nt.string();break}case 2:{st.value=nt.bytes();break}default:{nt.skipType(ct&7);break}}}return st})),rt),tt.encode=nt=>encodeMessage(nt,tt.codec()),tt.decode=(nt,ot)=>decodeMessage(nt,tt.codec(),ot)})(et.Peer$metadataEntry||(et.Peer$metadataEntry={})),function(tt){let rt;tt.codec=()=>(rt==null&&(rt=message$1((nt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),nt.key!=null&&nt.key!==""&&(ot.uint32(10),ot.string(nt.key)),nt.value!=null&&(ot.uint32(18),Tag.codec().encode(nt.value,ot)),it.lengthDelimited!==!1&&ot.ldelim()},(nt,ot,it={})=>{var ct;const st={key:""},at=ot==null?nt.len:nt.pos+ot;for(;nt.pos>>3){case 1:{st.key=nt.string();break}case 2:{st.value=Tag.codec().decode(nt,nt.uint32(),{limits:(ct=it.limits)==null?void 0:ct.value});break}default:{nt.skipType(lt&7);break}}}return st})),rt),tt.encode=nt=>encodeMessage(nt,tt.codec()),tt.decode=(nt,ot)=>decodeMessage(nt,tt.codec(),ot)}(et.Peer$tagsEntry||(et.Peer$tagsEntry={}));let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{if(nt.lengthDelimited!==!1&&rt.fork(),tt.addresses!=null)for(const ot of tt.addresses)rt.uint32(10),Address.codec().encode(ot,rt);if(tt.protocols!=null)for(const ot of tt.protocols)rt.uint32(18),rt.string(ot);if(tt.publicKey!=null&&(rt.uint32(34),rt.bytes(tt.publicKey)),tt.peerRecordEnvelope!=null&&(rt.uint32(42),rt.bytes(tt.peerRecordEnvelope)),tt.metadata!=null&&tt.metadata.size!==0)for(const[ot,it]of tt.metadata.entries())rt.uint32(50),et.Peer$metadataEntry.codec().encode({key:ot,value:it},rt);if(tt.tags!=null&&tt.tags.size!==0)for(const[ot,it]of tt.tags.entries())rt.uint32(58),et.Peer$tagsEntry.codec().encode({key:ot,value:it},rt);nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{var st,at,ct,lt,dt,ht;const ot={addresses:[],protocols:[],metadata:new Map,tags:new Map},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{if(((st=nt.limits)==null?void 0:st.addresses)!=null&&ot.addresses.length===nt.limits.addresses)throw new MaxLengthError('Decode error - map field "addresses" had too many elements');ot.addresses.push(Address.codec().decode(tt,tt.uint32(),{limits:(at=nt.limits)==null?void 0:at.addresses$}));break}case 2:{if(((ct=nt.limits)==null?void 0:ct.protocols)!=null&&ot.protocols.length===nt.limits.protocols)throw new MaxLengthError('Decode error - map field "protocols" had too many elements');ot.protocols.push(tt.string());break}case 4:{ot.publicKey=tt.bytes();break}case 5:{ot.peerRecordEnvelope=tt.bytes();break}case 6:{if(((lt=nt.limits)==null?void 0:lt.metadata)!=null&&ot.metadata.size===nt.limits.metadata)throw new MaxSizeError('Decode error - map field "metadata" had too many elements');const ft=et.Peer$metadataEntry.codec().decode(tt,tt.uint32());ot.metadata.set(ft.key,ft.value);break}case 7:{if(((dt=nt.limits)==null?void 0:dt.tags)!=null&&ot.tags.size===nt.limits.tags)throw new MaxSizeError('Decode error - map field "tags" had too many elements');const ft=et.Peer$tagsEntry.codec().decode(tt,tt.uint32(),{limits:{value:(ht=nt.limits)==null?void 0:ht.tags$value}});ot.tags.set(ft.key,ft.value);break}default:{tt.skipType(mt&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Peer||(Peer={}));var Address;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.multiaddr!=null&&tt.multiaddr.byteLength>0&&(rt.uint32(10),rt.bytes(tt.multiaddr)),tt.isCertified!=null&&(rt.uint32(16),rt.bool(tt.isCertified)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={multiaddr:alloc$1(0)},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.multiaddr=tt.bytes();break}case 2:{ot.isCertified=tt.bool();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Address||(Address={}));var Tag;(function(et){let o;et.codec=()=>(o==null&&(o=message$1((tt,rt,nt={})=>{nt.lengthDelimited!==!1&&rt.fork(),tt.value!=null&&tt.value!==0&&(rt.uint32(8),rt.uint32(tt.value)),tt.expiry!=null&&(rt.uint32(16),rt.uint64(tt.expiry)),nt.lengthDelimited!==!1&&rt.ldelim()},(tt,rt,nt={})=>{const ot={value:0},it=rt==null?tt.len:tt.pos+rt;for(;tt.pos>>3){case 1:{ot.value=tt.uint32();break}case 2:{ot.expiry=tt.uint64();break}default:{tt.skipType(st&7);break}}}return ot})),o),et.encode=tt=>encodeMessage(tt,et.codec()),et.decode=(tt,rt)=>decodeMessage(tt,et.codec(),rt)})(Tag||(Tag={}));function bytesToPeer(et,o){const tt=Peer.decode(o);if(tt.publicKey!=null&&et.publicKey==null){const ot=publicKeyFromProtobuf(tt.publicKey);et=peerIdFromPublicKey(ot)}const rt=new Map,nt=BigInt(Date.now());for(const[ot,it]of tt.tags.entries())it.expiry!=null&&it.expiry({multiaddr:multiaddr(ot),isCertified:it??!1})),metadata:tt.metadata,peerRecordEnvelope:tt.peerRecordEnvelope??void 0,tags:rt}}function coerce$4(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$9(et){return new TextEncoder().encode(et)}function toString$d(et){return new TextDecoder().decode(et)}function base$4(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$5=base$4,_brrp__multiformats_scope_baseX$4=src$5;let Encoder$4=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$4=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$4(this,o)}},ComposedDecoder$4=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$4(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$4(et,o){return new ComposedDecoder$4({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$4=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$4(o,tt,rt),this.decoder=new Decoder$4(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$5({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$4(et,o,tt,rt)}function baseX$4({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$4(tt,et);return from$5({prefix:o,name:et,encode:rt,decode:ot=>coerce$4(nt(ot))})}function decode$e(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$d(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$4=alphabet$4.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$c(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$4[tt],o),"")}function decode$d(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$4[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$8=from$5({prefix:"🚀",name:"base256emoji",encode:encode$c,decode:decode$d}),base256emoji$9=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$8},Symbol.toStringTag,{value:"Module"})),base32$a=rfc4648$4({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$4=rfc4648$4({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$4=rfc4648$4({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$4=rfc4648$4({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$4=rfc4648$4({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$4=rfc4648$4({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$4=rfc4648$4({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$4=rfc4648$4({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$4=rfc4648$4({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$b=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$a,base32hex:base32hex$4,base32hexpad:base32hexpad$4,base32hexpadupper:base32hexpadupper$4,base32hexupper:base32hexupper$4,base32pad:base32pad$4,base32padupper:base32padupper$4,base32upper:base32upper$4,base32z:base32z$4},Symbol.toStringTag,{value:"Module"})),base36$8=baseX$4({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$4=baseX$4({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$9=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$8,base36upper:base36upper$4},Symbol.toStringTag,{value:"Module"})),base58btc$4=baseX$4({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$4=baseX$4({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$4=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$4,base58flickr:base58flickr$4},Symbol.toStringTag,{value:"Module"})),base64$a=rfc4648$4({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$4=rfc4648$4({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$4=rfc4648$4({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$4=rfc4648$4({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$b=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$a,base64pad:base64pad$4,base64url:base64url$4,base64urlpad:base64urlpad$4},Symbol.toStringTag,{value:"Module"})),base8$8=rfc4648$4({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$9=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$8},Symbol.toStringTag,{value:"Module"})),identity$4=from$5({prefix:"\0",name:"identity",encode:et=>toString$d(et),decode:et=>fromString$9(et)}),identityBase$4=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$4},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$4={...identityBase$4,...base2$9,...base8$9,...base10$9,...base16$9,...base32$b,...base36$9,...base58$4,...base64$b,...base256emoji$9};function allocUnsafe$3(et=0){return new Uint8Array(et)}function createCodec$4(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$7=createCodec$4("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$4=createCodec$4("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$3(et.length);for(let tt=0;tt1&&this._buf[this._buf.byteLength-1]===pathSep;)this._buf=this._buf.subarray(0,-1)}less(o){const tt=this.list(),rt=o.list();for(let nt=0;ntit)return!1}return tt.lengthtt.namespaces()))])}}function namespaceType(et){const o=et.split(":");return o.length<2?"":o.slice(0,-1).join(":")}function namespaceValue(et){const o=et.split(":");return o[o.length-1]}function flatten(et){return[].concat(...et)}const NAMESPACE_COMMON="/peers/";function peerIdToDatastoreKey(et){if(!isPeerId(et)||et.type==null)throw new InvalidParametersError("Invalid PeerId");const o=et.toCID().toString();return new Key(`${NAMESPACE_COMMON}${o}`)}async function dedupeFilterAndSortAddresses(et,o,tt){const rt=new Map;for(const nt of tt){if(nt==null)continue;if(nt.multiaddr instanceof Uint8Array&&(nt.multiaddr=multiaddr(nt.multiaddr)),!isMultiaddr(nt.multiaddr))throw new InvalidParametersError("Multiaddr was invalid");if(!await o(et,nt.multiaddr))continue;const ot=nt.isCertified??!1,it=nt.multiaddr.toString(),st=rt.get(it);st!=null?nt.isCertified=st.isCertified||ot:rt.set(it,{multiaddr:nt.multiaddr,isCertified:ot})}return[...rt.values()].sort((nt,ot)=>nt.multiaddr.toString().localeCompare(ot.multiaddr.toString())).map(({isCertified:nt,multiaddr:ot})=>({isCertified:nt,multiaddr:ot.bytes}))}async function toPeerPB(et,o,tt,rt){if(o==null)throw new InvalidParametersError("Invalid PeerData");if(o.publicKey!=null&&et.publicKey!=null&&!o.publicKey.equals(et.publicKey))throw new InvalidParametersError("publicKey bytes do not match peer id publicKey bytes");const nt=rt.existingPeer;if(nt!=null&&!et.equals(nt.id))throw new InvalidParametersError("peer id did not match existing peer id");let ot=(nt==null?void 0:nt.addresses)??[],it=new Set((nt==null?void 0:nt.protocols)??[]),st=(nt==null?void 0:nt.metadata)??new Map,at=(nt==null?void 0:nt.tags)??new Map,ct=nt==null?void 0:nt.peerRecordEnvelope;if(tt==="patch"){if((o.multiaddrs!=null||o.addresses!=null)&&(ot=[],o.multiaddrs!=null&&ot.push(...o.multiaddrs.map(ht=>({isCertified:!1,multiaddr:ht}))),o.addresses!=null&&ot.push(...o.addresses)),o.protocols!=null&&(it=new Set(o.protocols)),o.metadata!=null){const ht=o.metadata instanceof Map?[...o.metadata.entries()]:Object.entries(o.metadata);st=createSortedMap(ht,{validate:validateMetadata})}if(o.tags!=null){const ht=o.tags instanceof Map?[...o.tags.entries()]:Object.entries(o.tags);at=createSortedMap(ht,{validate:validateTag,map:mapTag})}o.peerRecordEnvelope!=null&&(ct=o.peerRecordEnvelope)}if(tt==="merge"){if(o.multiaddrs!=null&&ot.push(...o.multiaddrs.map(ht=>({isCertified:!1,multiaddr:ht}))),o.addresses!=null&&ot.push(...o.addresses),o.protocols!=null&&(it=new Set([...it,...o.protocols])),o.metadata!=null){const ht=o.metadata instanceof Map?[...o.metadata.entries()]:Object.entries(o.metadata);for(const[mt,ft]of ht)ft==null?st.delete(mt):st.set(mt,ft);st=createSortedMap([...st.entries()],{validate:validateMetadata})}if(o.tags!=null){const ht=o.tags instanceof Map?[...o.tags.entries()]:Object.entries(o.tags),mt=new Map(at);for(const[ft,pt]of ht)pt==null?mt.delete(ft):mt.set(ft,pt);at=createSortedMap([...mt.entries()],{validate:validateTag,map:mapTag})}o.peerRecordEnvelope!=null&&(ct=o.peerRecordEnvelope)}let lt;(nt==null?void 0:nt.id.publicKey)!=null?lt=publicKeyToProtobuf(nt.id.publicKey):o.publicKey!=null?lt=publicKeyToProtobuf(o.publicKey):et.publicKey!=null&&(lt=publicKeyToProtobuf(et.publicKey));const dt={addresses:await dedupeFilterAndSortAddresses(et,rt.addressFilter??(async()=>!0),ot),protocols:[...it.values()].sort((ht,mt)=>ht.localeCompare(mt)),metadata:st,tags:at,publicKey:lt,peerRecordEnvelope:ct};return et.type!=="RSA"&&delete dt.publicKey,dt}function createSortedMap(et,o){var rt;const tt=new Map;for(const[nt,ot]of et)ot!=null&&o.validate(nt,ot);for(const[nt,ot]of et.sort(([it],[st])=>it.localeCompare(st)))ot!=null&&tt.set(nt,((rt=o.map)==null?void 0:rt.call(o,nt,ot))??ot);return tt}function validateMetadata(et,o){if(typeof et!="string")throw new InvalidParametersError("Metadata key must be a string");if(!(o instanceof Uint8Array))throw new InvalidParametersError("Metadata value must be a Uint8Array")}function validateTag(et,o){if(typeof et!="string")throw new InvalidParametersError("Tag name must be a string");if(o.value!=null){if(parseInt(`${o.value}`,10)!==o.value)throw new InvalidParametersError("Tag value must be an integer");if(o.value<0||o.value>100)throw new InvalidParametersError("Tag value must be between 0-100")}if(o.ttl!=null){if(parseInt(`${o.ttl}`,10)!==o.ttl)throw new InvalidParametersError("Tag ttl must be an integer");if(o.ttl<0)throw new InvalidParametersError("Tag ttl must be between greater than 0")}}function mapTag(et,o){let tt;return o.expiry!=null&&(tt=o.expiry),o.ttl!=null&&(tt=BigInt(Date.now()+Number(o.ttl))),{value:o.value??0,expiry:tt}}function decodePeer(et,o,tt){const rt=et.toString().split("/")[2],nt=CID.parse(rt,base32$c),ot=peerIdFromCID(nt),it=tt.get(ot);if(it!=null)return it;const st=bytesToPeer(ot,o);return tt.set(ot,st),st}function mapQuery(et,o){return et==null?{}:{prefix:NAMESPACE_COMMON,filters:(et.filters??[]).map(tt=>({key:rt,value:nt})=>tt(decodePeer(rt,nt,o))),orders:(et.orders??[]).map(tt=>(rt,nt)=>tt(decodePeer(rt.key,rt.value,o),decodePeer(nt.key,nt.value,o)))}}var rn,ns,os;class PersistentStore{constructor(o,tt={}){fr(this,rn);wt(this,"peerId");wt(this,"datastore");wt(this,"lock");wt(this,"addressFilter");this.peerId=o.peerId,this.datastore=o.datastore,this.addressFilter=tt.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 InvalidParametersError("Cannot delete self peer");await this.datastore.delete(peerIdToDatastoreKey(o))}async load(o){const tt=await this.datastore.get(peerIdToDatastoreKey(o));return bytesToPeer(o,tt)}async save(o,tt){const{existingBuf:rt,existingPeer:nt}=await mr(this,rn,ns).call(this,o),ot=await toPeerPB(o,tt,"patch",{addressFilter:this.addressFilter});return mr(this,rn,os).call(this,o,ot,rt,nt)}async patch(o,tt){const{existingBuf:rt,existingPeer:nt}=await mr(this,rn,ns).call(this,o),ot=await toPeerPB(o,tt,"patch",{addressFilter:this.addressFilter,existingPeer:nt});return mr(this,rn,os).call(this,o,ot,rt,nt)}async merge(o,tt){const{existingBuf:rt,existingPeer:nt}=await mr(this,rn,ns).call(this,o),ot=await toPeerPB(o,tt,"merge",{addressFilter:this.addressFilter,existingPeer:nt});return mr(this,rn,os).call(this,o,ot,rt,nt)}async*all(o){const tt=new PeerMap;for await(const{key:rt,value:nt}of this.datastore.query(mapQuery(o??{},tt))){const ot=decodePeer(rt,nt,tt);ot.id.equals(this.peerId)||(yield ot)}}}rn=new WeakSet,ns=async function(o){try{const tt=await this.datastore.get(peerIdToDatastoreKey(o)),rt=bytesToPeer(o,tt);return{existingBuf:tt,existingPeer:rt}}catch(tt){if(tt.name!=="NotFoundError")throw tt}return{}},os=async function(o,tt,rt,nt){const ot=Peer.encode(tt);return rt!=null&&equals(ot,rt)?{peer:bytesToPeer(o,ot),previous:nt,updated:!1}:(await this.datastore.put(peerIdToDatastoreKey(o),ot),{peer:bytesToPeer(o,ot),previous:nt,updated:!0})};var Fl,no,is;Fl=Symbol.toStringTag;class PersistentPeerStore{constructor(o,tt={}){fr(this,no);wt(this,"store");wt(this,"events");wt(this,"peerId");wt(this,"log");wt(this,Fl,"@libp2p/peer-store");this.log=o.logger.forComponent("libp2p:peer-store"),this.events=o.events,this.peerId=o.peerId,this.store=new PersistentStore(o,tt)}async forEach(o,tt){this.log.trace("forEach await read lock");const rt=await this.store.lock.readLock();this.log.trace("forEach got read lock");try{for await(const nt of this.store.all(tt))o(nt)}finally{this.log.trace("forEach release read lock"),rt()}}async all(o){this.log.trace("all await read lock");const tt=await this.store.lock.readLock();this.log.trace("all got read lock");try{return await all$2(this.store.all(o))}finally{this.log.trace("all release read lock"),tt()}}async delete(o){this.log.trace("delete await write lock");const tt=await this.store.lock.writeLock();this.log.trace("delete got write lock");try{await this.store.delete(o)}finally{this.log.trace("delete release write lock"),tt()}}async has(o){this.log.trace("has await read lock");const tt=await this.store.lock.readLock();this.log.trace("has got read lock");try{return await this.store.has(o)}finally{this.log.trace("has release read lock"),tt()}}async get(o){this.log.trace("get await read lock");const tt=await this.store.lock.readLock();this.log.trace("get got read lock");try{return await this.store.load(o)}finally{this.log.trace("get release read lock"),tt()}}async save(o,tt){this.log.trace("save await write lock");const rt=await this.store.lock.writeLock();this.log.trace("save got write lock");try{const nt=await this.store.save(o,tt);return mr(this,no,is).call(this,o,nt),nt.peer}finally{this.log.trace("save release write lock"),rt()}}async patch(o,tt){this.log.trace("patch await write lock");const rt=await this.store.lock.writeLock();this.log.trace("patch got write lock");try{const nt=await this.store.patch(o,tt);return mr(this,no,is).call(this,o,nt),nt.peer}finally{this.log.trace("patch release write lock"),rt()}}async merge(o,tt){this.log.trace("merge await write lock");const rt=await this.store.lock.writeLock();this.log.trace("merge got write lock");try{const nt=await this.store.merge(o,tt);return mr(this,no,is).call(this,o,nt),nt.peer}finally{this.log.trace("merge release write lock"),rt()}}async consumePeerRecord(o,tt){const rt=await RecordEnvelope.openAndCertify(o,PeerRecord.DOMAIN),nt=peerIdFromCID(rt.publicKey.toCID());if((tt==null?void 0:tt.equals(nt))===!1)return this.log("envelope peer id was not the expected peer id - expected: %p received: %p",tt,nt),!1;const ot=PeerRecord.createFromProtobuf(rt.payload);let it;try{it=await this.get(nt)}catch(st){if(st.name!=="NotFoundError")throw st}if((it==null?void 0:it.peerRecordEnvelope)!=null){const st=await RecordEnvelope.createFromProtobuf(it.peerRecordEnvelope),at=PeerRecord.createFromProtobuf(st.payload);if(at.seqNumber>=ot.seqNumber)return this.log("sequence number was lower or equal to existing sequence number - stored: %d received: %d",at.seqNumber,ot.seqNumber),!1}return await this.patch(ot.peerId,{peerRecordEnvelope:o,addresses:ot.multiaddrs.map(st=>({isCertified:!0,multiaddr:st}))}),!0}}no=new WeakSet,is=function(o,tt){tt.updated&&(this.peerId.equals(o)?this.events.safeDispatchEvent("self:peer:update",{detail:tt}):this.events.safeDispatchEvent("peer:update",{detail:tt}))};function persistentPeerStore(et,o={}){return new PersistentPeerStore(et,o)}const On=class On extends Error{constructor(tt="Not Found"){super(tt);wt(this,"name",On.name);wt(this,"code",On.code)}};wt(On,"name","NotFoundError"),wt(On,"code","ERR_NOT_FOUND");let NotFoundError=On;function peekable(et){const[o,tt]=et[Symbol.asyncIterator]!=null?[et[Symbol.asyncIterator](),Symbol.asyncIterator]:[et[Symbol.iterator](),Symbol.iterator],rt=[];return{peek:()=>o.next(),push:nt=>{rt.push(nt)},next:()=>rt.length>0?{done:!1,value:rt.shift()}:o.next(),[tt](){return this}}}function isAsyncIterable$2(et){return et[Symbol.asyncIterator]!=null}function filter(et,o){let tt=0;if(isAsyncIterable$2(et))return async function*(){for await(const at of et)await o(at,tt++)&&(yield at)}();const rt=peekable(et),{value:nt,done:ot}=rt.next();if(ot===!0)return function*(){}();const it=o(nt,tt++);if(typeof it.then=="function")return async function*(){await it&&(yield nt);for await(const at of rt)await o(at,tt++)&&(yield at)}();const st=o;return function*(){it===!0&&(yield nt);for(const at of rt)st(at,tt++)&&(yield at)}()}function isAsyncIterable$1(et){return et[Symbol.asyncIterator]!=null}function sort(et,o){return isAsyncIterable$1(et)?async function*(){yield*(await all$2(et)).sort(o)}():function*(){yield*all$2(et).sort(o)}()}function isAsyncIterable(et){return et[Symbol.asyncIterator]!=null}function take(et,o){return isAsyncIterable(et)?async function*(){let tt=0;if(!(o<1)){for await(const rt of et)if(yield rt,tt++,tt===o)return}}():function*(){let tt=0;if(!(o<1)){for(const rt of et)if(yield rt,tt++,tt===o)return}}()}class BaseDatastore{put(o,tt,rt){return Promise.reject(new Error(".put is not implemented"))}get(o,tt){return Promise.reject(new Error(".get is not implemented"))}has(o,tt){return Promise.reject(new Error(".has is not implemented"))}delete(o,tt){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(o,tt={}){for await(const{key:rt,value:nt}of o)await this.put(rt,nt,tt),yield rt}async*getMany(o,tt={}){for await(const rt of o)yield{key:rt,value:await this.get(rt,tt)}}async*deleteMany(o,tt={}){for await(const rt of o)await this.delete(rt,tt),yield rt}batch(){let o=[],tt=[];return{put(rt,nt){o.push({key:rt,value:nt})},delete(rt){tt.push(rt)},commit:async rt=>{await drain(this.putMany(o,rt)),o=[],await drain(this.deleteMany(tt,rt)),tt=[]}}}async*_all(o,tt){throw new Error("._all is not implemented")}async*_allKeys(o,tt){throw new Error("._allKeys is not implemented")}query(o,tt){let rt=this._all(o,tt);if(o.prefix!=null){const nt=o.prefix;rt=filter(rt,ot=>ot.key.toString().startsWith(nt))}if(Array.isArray(o.filters)&&(rt=o.filters.reduce((nt,ot)=>filter(nt,ot),rt)),Array.isArray(o.orders)&&(rt=o.orders.reduce((nt,ot)=>sort(nt,ot),rt)),o.offset!=null){let nt=0;const ot=o.offset;rt=filter(rt,()=>nt++>=ot)}return o.limit!=null&&(rt=take(rt,o.limit)),rt}queryKeys(o,tt){let rt=this._allKeys(o,tt);if(o.prefix!=null){const nt=o.prefix;rt=filter(rt,ot=>ot.toString().startsWith(nt))}if(Array.isArray(o.filters)&&(rt=o.filters.reduce((nt,ot)=>filter(nt,ot),rt)),Array.isArray(o.orders)&&(rt=o.orders.reduce((nt,ot)=>sort(nt,ot),rt)),o.offset!=null){const nt=o.offset;let ot=0;rt=filter(rt,()=>ot++>=nt)}return o.limit!=null&&(rt=take(rt,o.limit)),rt}}class MemoryDatastore extends BaseDatastore{constructor(){super();wt(this,"data");this.data=new Map}put(tt,rt){return this.data.set(tt.toString(),rt),tt}get(tt){const rt=this.data.get(tt.toString());if(rt==null)throw new NotFoundError;return rt}has(tt){return this.data.has(tt.toString())}delete(tt){this.data.delete(tt.toString())}*_all(){for(const[tt,rt]of this.data.entries())yield{key:new Key(tt),value:rt}}*_allKeys(){for(const tt of this.data.keys())yield new Key(tt)}}function allocUnsafe$2(et=0){return new Uint8Array(et)}function asUint8Array(et){return et}function concat(et,o){o==null&&(o=et.reduce((nt,ot)=>nt+ot.length,0));const tt=allocUnsafe$2(o);let rt=0;for(const nt of et)tt.set(nt,rt),rt+=nt.length;return tt}function coerce$3(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$7(et){return new TextEncoder().encode(et)}function toString$b(et){return new TextDecoder().decode(et)}function base$3(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$4=base$3,_brrp__multiformats_scope_baseX$3=src$4;let Encoder$3=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$3=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$3(this,o)}},ComposedDecoder$3=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$3(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$3(et,o){return new ComposedDecoder$3({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$3=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$3(o,tt,rt),this.decoder=new Decoder$3(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$4({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$3(et,o,tt,rt)}function baseX$3({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$3(tt,et);return from$4({prefix:o,name:et,encode:rt,decode:ot=>coerce$3(nt(ot))})}function decode$c(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$b(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$3=alphabet$3.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$a(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$3[tt],o),"")}function decode$b(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$3[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$6=from$4({prefix:"🚀",name:"base256emoji",encode:encode$a,decode:decode$b}),base256emoji$7=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$6},Symbol.toStringTag,{value:"Module"})),base32$8=rfc4648$3({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$3=rfc4648$3({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$3=rfc4648$3({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$3=rfc4648$3({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$3=rfc4648$3({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$3=rfc4648$3({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$3=rfc4648$3({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$3=rfc4648$3({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$3=rfc4648$3({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$9=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$8,base32hex:base32hex$3,base32hexpad:base32hexpad$3,base32hexpadupper:base32hexpadupper$3,base32hexupper:base32hexupper$3,base32pad:base32pad$3,base32padupper:base32padupper$3,base32upper:base32upper$3,base32z:base32z$3},Symbol.toStringTag,{value:"Module"})),base36$6=baseX$3({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$3=baseX$3({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$7=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$6,base36upper:base36upper$3},Symbol.toStringTag,{value:"Module"})),base58btc$3=baseX$3({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$3=baseX$3({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$3=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$3,base58flickr:base58flickr$3},Symbol.toStringTag,{value:"Module"})),base64$8=rfc4648$3({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$3=rfc4648$3({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$3=rfc4648$3({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$3=rfc4648$3({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$9=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$8,base64pad:base64pad$3,base64url:base64url$3,base64urlpad:base64urlpad$3},Symbol.toStringTag,{value:"Module"})),base8$6=rfc4648$3({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$7=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$6},Symbol.toStringTag,{value:"Module"})),identity$3=from$4({prefix:"\0",name:"identity",encode:et=>toString$b(et),decode:et=>fromString$7(et)}),identityBase$3=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$3},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$3={...identityBase$3,...base2$7,...base8$7,...base10$7,...base16$7,...base32$9,...base36$7,...base58$3,...base64$9,...base256emoji$7};function createCodec$3(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$6=createCodec$3("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$3=createCodec$3("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$2(et.length);for(let tt=0;ttet;function stripPeerId(et,o){const tt=et.getPeerId();return tt!=null&&peerIdFromString$1(tt).equals(o)&&(et=et.decapsulate(multiaddr(`/p2p/${o.toString()}`))),et}var Ul;Ul=Symbol.toStringTag;class DefaultAddressManager{constructor(o,tt={}){wt(this,"log");wt(this,"components");wt(this,"listen");wt(this,"announce");wt(this,"observed");wt(this,"announceFilter");wt(this,Ul,"@libp2p/address-manager");const{listen:rt=[],announce:nt=[]}=tt;this.components=o,this.log=o.logger.forComponent("libp2p:address-manager"),this.listen=rt.map(ot=>ot.toString()),this.announce=new Set(nt.map(ot=>ot.toString())),this.observed=new Map,this.announceFilter=tt.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(){const o=this.getAnnounceAddrs().concat(this.components.transportManager.getAddrs()).concat([...this.observed.entries()].filter(([tt,rt])=>rt.confident).map(([tt])=>multiaddr(tt))).map(tt=>tt.getPeerId()===this.components.peerId.toString()?tt.decapsulate(`/p2p/${this.components.peerId.toString()}`):tt);this.components.peerStore.patch(this.components.peerId,{multiaddrs:o}).catch(tt=>{this.log.error("error updating addresses",tt)})}getListenAddrs(){return Array.from(this.listen).map(o=>multiaddr(o))}getAnnounceAddrs(){return Array.from(this.announce).map(o=>multiaddr(o))}getObservedAddrs(){return Array.from(this.observed).map(([o])=>multiaddr(o))}addObservedAddr(o){o=stripPeerId(o,this.components.peerId);const tt=o.toString();this.observed.has(tt)||this.observed.set(tt,{confident:!1})}confirmObservedAddr(o){o=stripPeerId(o,this.components.peerId);const tt=o.toString(),nt=(this.observed.get(tt)??{confident:!1}).confident;this.observed.set(tt,{confident:!0}),nt||this._updatePeerStoreAddresses()}removeObservedAddr(o){o=stripPeerId(o,this.components.peerId);const tt=o.toString();this.observed.delete(tt)}getAddresses(){let o=this.getAnnounceAddrs().map(rt=>rt.toString());o.length===0&&(o=this.components.transportManager.getAddrs().map(rt=>rt.toString())),o=o.concat(Array.from(this.observed).filter(([rt,nt])=>nt.confident).map(([rt])=>rt));const tt=new Set(o);return this.announceFilter(Array.from(tt).map(rt=>multiaddr(rt))).map(rt=>{var nt;return((nt=rt.protos().pop())==null?void 0:nt.path)===!0||rt.getPeerId()===this.components.peerId.toString()?rt:rt.encapsulate(`/p2p/${this.components.peerId.toString()}`)})}}var messages;(function(et){et.NOT_STARTED_YET="The libp2p node is not started yet",et.NOT_FOUND="Not found"})(messages||(messages={}));class MissingServiceError extends Error{constructor(o="Missing service"){super(o),this.name="MissingServiceError"}}class UnmetServiceDependenciesError extends Error{constructor(o="Unmet service dependencies"){super(o),this.name="UnmetServiceDependenciesError"}}class NoContentRoutersError extends Error{constructor(o="No content routers available"){super(o),this.name="NoContentRoutersError"}}class NoPeerRoutersError extends Error{constructor(o="No peer routers available"){super(o),this.name="NoPeerRoutersError"}}class QueriedForSelfError extends Error{constructor(o="Should not try to find self"){super(o),this.name="QueriedForSelfError"}}class UnhandledProtocolError extends Error{constructor(o="Unhandled protocol error"){super(o),this.name="UnhandledProtocolError"}}class DuplicateProtocolHandlerError extends Error{constructor(o="Duplicate protocol handler error"){super(o),this.name="DuplicateProtocolHandlerError"}}class DialDeniedError extends Error{constructor(o="Dial denied error"){super(o),this.name="DialDeniedError"}}class NoValidAddressesError extends Error{constructor(o="No valid addresses"){super(o),this.name="NoValidAddressesError"}}class ConnectionInterceptedError extends Error{constructor(o="Connection intercepted"){super(o),this.name="ConnectionInterceptedError"}}class ConnectionDeniedError extends Error{constructor(o="Connection denied"){super(o),this.name="ConnectionDeniedError"}}class MuxerUnavailableError extends Error{constructor(o="Stream is not multiplexed"){super(o),this.name="MuxerUnavailableError"}}class EncryptionFailedError extends Error{constructor(o="Encryption failed"){super(o),this.name="EncryptionFailedError"}}class TransportUnavailableError extends Error{constructor(o="Transport unavailable"){super(o),this.name="TransportUnavailableError"}}class DefaultComponents{constructor(o={}){wt(this,"components",{});wt(this,"_started",!1);this.components={};for(const[tt,rt]of Object.entries(o))this.components[tt]=rt;this.components.logger==null&&(this.components.logger=defaultLogger())}isStarted(){return this._started}async _invokeStartableMethod(o){await Promise.all(Object.values(this.components).filter(tt=>isStartable(tt)).map(async tt=>{var rt;await((rt=tt[o])==null?void 0:rt.call(tt))}))}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")}}const OPTIONAL_SERVICES=["metrics","connectionProtector","dns"],NON_SERVICE_PROPERTIES=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];function defaultComponents(et={}){const o=new DefaultComponents(et);return new Proxy(o,{get(rt,nt,ot){if(typeof nt=="string"&&!NON_SERVICE_PROPERTIES.includes(nt)){const it=o.components[nt];if(it==null&&!OPTIONAL_SERVICES.includes(nt))throw new MissingServiceError(`${nt} not set`);return it}return Reflect.get(rt,nt,ot)},set(rt,nt,ot){return typeof nt=="string"?o.components[nt]=ot:Reflect.set(rt,nt,ot),!0}})}function checkServiceDependencies(et){const o={};for(const tt of Object.values(et.components))for(const rt of getServiceCapabilities(tt))o[rt]=!0;for(const tt of Object.values(et.components))for(const rt of getServiceDependencies(tt))if(o[rt]!==!0)throw new UnmetServiceDependenciesError(`Service "${getServiceName(tt)}" required capability "${rt}" but it was not provided by any component, you may need to add additional configuration when creating your node.`)}function getServiceCapabilities(et){return Array.isArray(et==null?void 0:et[serviceCapabilities])?et[serviceCapabilities]:[]}function getServiceDependencies(et){return Array.isArray(et==null?void 0:et[serviceDependencies])?et[serviceDependencies]:[]}function getServiceName(et){return(et==null?void 0:et[Symbol.toStringTag])??(et==null?void 0:et.toString())??"unknown"}function connectionGater(et={}){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async o=>{const tt=o.stringTuples();return tt[0][0]===4||tt[0][0]===41?!!isPrivateIp(`${tt[0][1]}`):!1},denyInboundConnection:async()=>!1,denyOutboundConnection:async()=>!1,denyInboundEncryptedConnection:async()=>!1,denyOutboundEncryptedConnection:async()=>!1,denyInboundUpgradedConnection:async()=>!1,denyOutboundUpgradedConnection:async()=>!1,filterMultiaddrForPeer:async()=>!0,...et}}function getPeerAddress(et){if(isPeerId$1(et))return{peerId:et,multiaddrs:[]};Array.isArray(et)||(et=[et]);let o;if(et.length>0){const tt=et[0].getPeerId();o=tt==null?void 0:peerIdFromString$1(tt),et.forEach(rt=>{if(!isMultiaddr(rt))throw new InvalidMultiaddrError("Invalid multiaddr");const nt=rt.getPeerId();if(nt==null){if(o!=null)throw new InvalidParametersError$1("Multiaddrs must all have the same peer id or have no peer id")}else{const ot=peerIdFromString$1(nt);if((o==null?void 0:o.equals(ot))!==!0)throw new InvalidParametersError$1("Multiaddrs must all have the same peer id or have no peer id")}})}return{peerId:o,multiaddrs:et}}const DEFAULT_CLOSABLE_PROTOCOLS=["/ipfs/id/1.0.0","/ipfs/id/push/1.0.0","/libp2p/autonat/1.0.0","/libp2p/dcutr"];async function safelyCloseConnectionIfUnused(et,o){var nt;const tt=((nt=et==null?void 0:et.streams)==null?void 0:nt.map(ot=>ot.protocol))??[],rt=(o==null?void 0:o.closableProtocols)??DEFAULT_CLOSABLE_PROTOCOLS;if(!(tt.filter(ot=>ot!=null&&!rt.includes(ot)).length>0))try{await(et==null?void 0:et.close(o))}catch(ot){et==null||et.abort(ot)}}const DIAL_TIMEOUT=5e3,UPGRADE_TIMEOUT=3e3,PROTOCOL_NEGOTIATION_TIMEOUT=2e3,MAX_PEER_ADDRS_TO_DIAL=25,INBOUND_CONNECTION_THRESHOLD=5,MAX_INCOMING_PENDING_CONNECTIONS=10,MAX_PARALLEL_RECONNECTS=5,LAST_DIAL_FAILURE_KEY="last-dial-failure",LAST_DIAL_SUCCESS_KEY="last-dial-success",MAX_DIAL_QUEUE_LENGTH=500,MAX_CONNECTIONS=100,MAX_PARALLEL_DIALS=50,defaultOptions$2={maxConnections:MAX_CONNECTIONS,allow:[]};class ConnectionPruner{constructor(o,tt={}){wt(this,"maxConnections");wt(this,"connectionManager");wt(this,"peerStore");wt(this,"allow");wt(this,"events");wt(this,"log");this.maxConnections=tt.maxConnections??defaultOptions$2.maxConnections,this.allow=tt.allow??defaultOptions$2.allow,this.connectionManager=o.connectionManager,this.peerStore=o.peerStore,this.events=o.events,this.log=o.logger.forComponent("libp2p:connection-manager:connection-pruner"),this.maybePruneConnections=this.maybePruneConnections.bind(this)}start(){this.events.addEventListener("connection:open",this.maybePruneConnections)}stop(){this.events.removeEventListener("connection:open",this.maybePruneConnections)}maybePruneConnections(){this._maybePruneConnections().catch(o=>{this.log.error("error while pruning connections %e",o)})}async _maybePruneConnections(){const o=this.connectionManager.getConnections(),tt=o.length;if(this.log("checking max connections limit %d/%d",tt,this.maxConnections),tt<=this.maxConnections)return;const rt=new PeerMap;for(const st of o){const at=st.remotePeer;if(!rt.has(at)){rt.set(at,0);try{const ct=await this.peerStore.get(at);rt.set(at,[...ct.tags.values()].reduce((lt,dt)=>lt+dt.value,0))}catch(ct){ct.name!=="NotFoundError"&&this.log.error("error loading peer tags",ct)}}}const nt=this.sortConnections(o,rt),ot=Math.max(tt-this.maxConnections,0),it=[];for(const st of nt)if(this.log("too many connections open - closing a connection to %p",st.remotePeer),this.allow.some(ct=>st.remoteAddr.toString().startsWith(ct.toString()))||it.push(st),it.length===ot)break;await Promise.all(it.map(async st=>{await safelyCloseConnectionIfUnused(st,{signal:AbortSignal.timeout(1e3)})})),this.events.safeDispatchEvent("connection:prune",{detail:it})}sortConnections(o,tt){return o.sort((rt,nt)=>{const ot=rt.timeline.open,it=nt.timeline.open;return otit?-1:0}).sort((rt,nt)=>rt.direction==="outbound"&&nt.direction==="inbound"?1:rt.direction==="inbound"&&nt.direction==="outbound"?-1:0).sort((rt,nt)=>rt.streams.length>nt.streams.length?1:rt.streams.length{const ot=tt.get(rt.remotePeer)??0,it=tt.get(nt.remotePeer)??0;return ot>it?1:ot{function st(){tt==null||tt.removeEventListener("abort",lt),et.removeEventListener(o,at),(rt==null?void 0:rt.errorEvent)!=null&&et.removeEventListener(rt.errorEvent,ct)}const at=dt=>{var ht;try{if(((ht=rt==null?void 0:rt.filter)==null?void 0:ht.call(rt,dt))===!1)return}catch(mt){st(),it(mt);return}st(),ot(dt)},ct=dt=>{st(),it(dt.detail)},lt=()=>{st(),it(nt)};tt==null||tt.addEventListener("abort",lt),et.addEventListener(o,at),(rt==null?void 0:rt.errorEvent)!=null&&et.addEventListener(rt.errorEvent,ct)})}class JobRecipient{constructor(o){wt(this,"deferred");wt(this,"signal");var tt;this.signal=o,this.deferred=pDefer(),this.onAbort=this.onAbort.bind(this),(tt=this.signal)==null||tt.addEventListener("abort",this.onAbort)}onAbort(){var o;this.deferred.reject(((o=this.signal)==null?void 0:o.reason)??new AbortError$6)}cleanup(){var o;(o=this.signal)==null||o.removeEventListener("abort",this.onAbort)}}function randomId(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}class Job{constructor(o,tt){wt(this,"id");wt(this,"fn");wt(this,"options");wt(this,"recipients");wt(this,"status");wt(this,"timeline");wt(this,"controller");this.id=randomId(),this.status="queued",this.fn=o,this.options=tt,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,setMaxListeners$2(1/0,this.controller.signal),this.onAbort=this.onAbort.bind(this)}abort(o){this.controller.abort(o)}onAbort(){this.recipients.reduce((tt,rt)=>{var nt;return tt&&((nt=rt.signal)==null?void 0:nt.aborted)===!0},!0)&&(this.controller.abort(new AbortError$6),this.cleanup())}async join(o={}){var rt;const tt=new JobRecipient(o.signal);return this.recipients.push(tt),(rt=o.signal)==null||rt.addEventListener("abort",this.onAbort),tt.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();const o=await raceSignal(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(tt=>{tt.deferred.resolve(o)}),this.status="complete"}catch(o){this.recipients.forEach(tt=>{tt.deferred.reject(o)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(o=>{var tt;o.cleanup(),(tt=o.signal)==null||tt.removeEventListener("abort",this.onAbort)})}}class Queue extends TypedEventEmitter$1{constructor(tt={}){var rt;super();wt(this,"concurrency");wt(this,"maxSize");wt(this,"queue");wt(this,"pending");wt(this,"sort");this.concurrency=tt.concurrency??Number.POSITIVE_INFINITY,this.maxSize=tt.maxSize??Number.POSITIVE_INFINITY,this.pending=0,tt.metricName!=null&&((rt=tt.metrics)==null||rt.registerMetricGroup(tt.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})})),this.sort=tt.sort,this.queue=[]}tryToStartAnother(){if(this.size===0)return queueMicrotask(()=>{this.safeDispatchEvent("empty")}),this.running===0&&queueMicrotask(()=>{this.safeDispatchEvent("idle")}),!1;if(this.pending{for(let rt=0;rt(this.safeDispatchEvent("completed",{detail:it}),this.safeDispatchEvent("success",{detail:{job:nt,result:it}}),it)).catch(it=>{if(nt.status==="queued"){for(let st=0;st{tt.abort(new AbortError$6)}),this.clear()}async onEmpty(tt){this.size!==0&&await raceEvent(this,"empty",tt==null?void 0:tt.signal)}async onSizeLessThan(tt,rt){this.sizethis.size{ht!=null?this.abort():this.clear(),rt.end(ht)},ot=ht=>{ht.detail!=null&&rt.push(ht.detail)},it=ht=>{nt(ht.detail)},st=()=>{nt()},at=()=>{nt(new AbortError$6("Queue aborted"))};this.addEventListener("completed",ot),this.addEventListener("error",it),this.addEventListener("idle",st),(lt=tt==null?void 0:tt.signal)==null||lt.addEventListener("abort",at);try{yield*rt}finally{this.removeEventListener("completed",ot),this.removeEventListener("error",it),this.removeEventListener("idle",st),(dt=tt==null?void 0:tt.signal)==null||dt.removeEventListener("abort",at),nt()}}}class PriorityQueue extends Queue{constructor(o={}){super({...o,sort:(tt,rt)=>tt.options.priority>rt.options.priority?-1:tt.options.prioritynt.toString())),rt}const defaultOptions$1={maxParallelDials:MAX_PARALLEL_DIALS,maxDialQueueLength:MAX_DIAL_QUEUE_LENGTH,maxPeerAddrsToDial:MAX_PEER_ADDRS_TO_DIAL,dialTimeout:DIAL_TIMEOUT,resolvers:{dnsaddr:dnsaddrResolver}};class DialQueue{constructor(o,tt={}){wt(this,"queue");wt(this,"components");wt(this,"addressSorter");wt(this,"maxPeerAddrsToDial");wt(this,"maxDialQueueLength");wt(this,"dialTimeout");wt(this,"shutDownController");wt(this,"connections");wt(this,"log");this.addressSorter=tt.addressSorter,this.maxPeerAddrsToDial=tt.maxPeerAddrsToDial??defaultOptions$1.maxPeerAddrsToDial,this.maxDialQueueLength=tt.maxDialQueueLength??defaultOptions$1.maxDialQueueLength,this.dialTimeout=tt.dialTimeout??defaultOptions$1.dialTimeout,this.connections=tt.connections??new PeerMap,this.log=o.logger.forComponent("libp2p:connection-manager:dial-queue"),this.components=o,this.shutDownController=new AbortController,setMaxListeners(1/0,this.shutDownController.signal);for(const[rt,nt]of Object.entries(tt.resolvers??{}))resolvers$1.set(rt,nt);this.queue=new PriorityQueue({concurrency:tt.maxParallelDials??defaultOptions$1.maxParallelDials,metricName:"libp2p_dial_queue",metrics:o.metrics}),this.queue.addEventListener("error",rt=>{rt.detail.name!==AbortError$4.name&&this.log.error("error in dial queue - %e",rt.detail)})}start(){this.shutDownController=new AbortController,setMaxListeners(1/0,this.shutDownController.signal)}stop(){this.shutDownController.abort(),this.queue.abort()}async dial(o,tt={}){var st,at,ct;const{peerId:rt,multiaddrs:nt}=getPeerAddress(o),ot=Array.from(this.connections.values()).flat().find(lt=>tt.force===!0?!1:lt.remotePeer.equals(rt)?!0:nt.find(dt=>dt.equals(lt.remoteAddr)));if((ot==null?void 0:ot.status)==="open")return this.log("already connected to %a",ot.remoteAddr),(st=tt.onProgress)==null||st.call(tt,new CustomProgressEvent("dial-queue:already-connected")),ot;const it=this.queue.queue.find(lt=>{if((rt==null?void 0:rt.equals(lt.options.peerId))===!0)return!0;const dt=lt.options.multiaddrs;if(dt==null)return!1;for(const ht of nt)if(dt.has(ht.toString()))return!0;return!1});if(it!=null){this.log("joining existing dial target for %p",rt);for(const lt of nt)it.options.multiaddrs.add(lt.toString());return(at=tt.onProgress)==null||at.call(tt,new CustomProgressEvent("dial-queue:already-in-dial-queue")),it.join(tt)}if(this.queue.size>=this.maxDialQueueLength)throw new DialError("Dial queue is full");return this.log("creating dial target for %p",rt,nt.map(lt=>lt.toString())),(ct=tt.onProgress)==null||ct.call(tt,new CustomProgressEvent("dial-queue:add-to-dial-queue")),this.queue.add(async lt=>{var mt,ft;(mt=lt==null?void 0:lt.onProgress)==null||mt.call(lt,new CustomProgressEvent("dial-queue:start-dial"));const dt=this.createDialAbortController(lt==null?void 0:lt.signal);let ht;try{ht=await this.calculateMultiaddrs(rt,lt==null?void 0:lt.multiaddrs,{...lt,signal:dt}),(ft=lt==null?void 0:lt.onProgress)==null||ft.call(lt,new CustomProgressEvent("dial-queue:calculated-addresses",ht)),ht.map(({multiaddr:pt})=>pt.toString()).forEach(pt=>{lt==null||lt.multiaddrs.add(pt)})}catch(pt){throw dt.clear(),pt}try{let pt=0;const yt=[];for(const gt of ht){if(pt===this.maxPeerAddrsToDial)throw this.log("dialed maxPeerAddrsToDial (%d) addresses for %p, not trying any others",pt,rt),new DialError("Peer had more than maxPeerAddrsToDial");pt++;try{const bt=await this.components.transportManager.dial(gt.multiaddr,{...lt,signal:dt});this.log("dial to %a succeeded",gt.multiaddr);try{await this.components.peerStore.merge(bt.remotePeer,{multiaddrs:[bt.remoteAddr],metadata:{[LAST_DIAL_SUCCESS_KEY]:fromString$6(Date.now().toString())}})}catch(xt){this.log.error("could not update last dial failure key for %p",rt,xt)}return bt}catch(bt){if(this.log.error("dial failed to %a",gt.multiaddr,bt),rt!=null)try{await this.components.peerStore.merge(rt,{metadata:{[LAST_DIAL_FAILURE_KEY]:fromString$6(Date.now().toString())}})}catch(xt){this.log.error("could not update last dial failure key for %p",rt,xt)}if(dt.aborted)throw new TimeoutError$2(bt.message);yt.push(bt)}}throw yt.length===1?yt[0]:new AggregateError(yt,"All multiaddr dials failed")}finally{dt.clear()}},{peerId:rt,priority:tt.priority??DEFAULT_DIAL_PRIORITY,multiaddrs:new Set(nt.map(lt=>lt.toString())),signal:tt.signal,onProgress:tt.onProgress})}createDialAbortController(o){const tt=anySignal([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,o]);return setMaxListeners(1/0,tt),tt}async calculateMultiaddrs(o,tt=new Set,rt={}){var dt,ht;const nt=[...tt].map(mt=>({multiaddr:multiaddr(mt),isCertified:!1}));if(o!=null){if(this.components.peerId.equals(o))throw new DialError("Tried to dial self");if(await((ht=(dt=this.components.connectionGater).denyDialPeer)==null?void 0:ht.call(dt,o))===!0)throw new DialDeniedError("The dial request is blocked by gater.allowDialPeer");if(nt.length===0){this.log("loading multiaddrs for %p",o);try{const mt=await this.components.peerStore.get(o);nt.push(...mt.addresses),this.log("loaded multiaddrs for %p",o,nt.map(({multiaddr:ft})=>ft.toString()))}catch(mt){if(mt.name!=="NotFoundError")throw mt}}if(nt.length===0){this.log("looking up multiaddrs for %p in the peer routing",o);try{const mt=await this.components.peerRouting.findPeer(o);this.log("found multiaddrs for %p in the peer routing",o,nt.map(({multiaddr:ft})=>ft.toString())),nt.push(...mt.multiaddrs.map(ft=>({multiaddr:ft,isCertified:!1})))}catch(mt){mt.name!=="NoPeerRoutersError"&&this.log.error("looking up multiaddrs for %p in the peer routing failed",o,mt)}}}let ot=(await Promise.all(nt.map(async mt=>{const ft=await resolveMultiaddrs(mt.multiaddr,{dns:this.components.dns,...rt,log:this.log});return ft.length===1&&ft[0].equals(mt.multiaddr)?mt:ft.map(pt=>({multiaddr:pt,isCertified:!1}))}))).flat();if(o!=null){const mt=`/p2p/${o.toString()}`;ot=ot.map(ft=>{const pt=ft.multiaddr.protos().pop();return(pt==null?void 0:pt.path)===!0?ft:ft.multiaddr.getPeerId()==null?{multiaddr:ft.multiaddr.encapsulate(mt),isCertified:ft.isCertified}:ft})}const it=ot.filter(mt=>{if(this.components.transportManager.dialTransportForMultiaddr(mt.multiaddr)==null)return!1;const ft=mt.multiaddr.getPeerId();return o!=null&&ft!=null?o.equals(ft):!0}),st=new Map;for(const mt of it){const ft=mt.multiaddr.toString(),pt=st.get(ft);if(pt!=null){pt.isCertified=pt.isCertified||mt.isCertified||!1;continue}st.set(ft,mt)}const at=[...st.values()];if(at.length===0)throw new NoValidAddressesError("The dial request has no valid addresses");const ct=[];for(const mt of at)this.components.connectionGater.denyDialMultiaddr!=null&&await this.components.connectionGater.denyDialMultiaddr(mt.multiaddr)||ct.push(mt);const lt=this.addressSorter==null?defaultAddressSorter(ct):ct.sort(this.addressSorter);if(lt.length===0)throw new DialDeniedError("The connection gater denied all addresses in the dial request");return this.log.trace("addresses for %p before filtering",o??"unknown peer",ot.map(({multiaddr:mt})=>mt.toString())),this.log.trace("addresses for %p after filtering",o??"unknown peer",lt.map(({multiaddr:mt})=>mt.toString())),lt}async isDialable(o,tt={}){Array.isArray(o)||(o=[o]);try{const rt=await this.calculateMultiaddrs(void 0,new Set(o.map(nt=>nt.toString())),tt);return tt.runOnLimitedConnection===!1?rt.find(nt=>!Circuit.matches(nt.multiaddr))!=null:!0}catch(rt){this.log.trace("error calculating if multiaddr(s) were dialable",rt)}return!1}}class PeerQueue extends Queue{has(o){return this.find(o)!=null}find(o){return this.queue.find(tt=>o.equals(tt.options.peerId))}}var retry$2={};function RetryOperation(et,o){typeof o=="boolean"&&(o={forever:o}),this._originalTimeouts=JSON.parse(JSON.stringify(et)),this._timeouts=et,this._options=o||{},this._maxRetryTime=o&&o.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var retry_operation=RetryOperation;RetryOperation.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};RetryOperation.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};RetryOperation.prototype.retry=function(et){if(this._timeout&&clearTimeout(this._timeout),!et)return!1;var o=new Date().getTime();if(et&&o-this._operationStart>=this._maxRetryTime)return this._errors.push(et),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(et);var tt=this._timeouts.shift();if(tt===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),tt=this._cachedTimeouts.slice(-1);else return!1;var rt=this;return this._timer=setTimeout(function(){rt._attempts++,rt._operationTimeoutCb&&(rt._timeout=setTimeout(function(){rt._operationTimeoutCb(rt._attempts)},rt._operationTimeout),rt._options.unref&&rt._timeout.unref()),rt._fn(rt._attempts)},tt),this._options.unref&&this._timer.unref(),!0};RetryOperation.prototype.attempt=function(et,o){this._fn=et,o&&(o.timeout&&(this._operationTimeout=o.timeout),o.cb&&(this._operationTimeoutCb=o.cb));var tt=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){tt._operationTimeoutCb()},tt._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};RetryOperation.prototype.try=function(et){console.log("Using RetryOperation.try() is deprecated"),this.attempt(et)};RetryOperation.prototype.start=function(et){console.log("Using RetryOperation.start() is deprecated"),this.attempt(et)};RetryOperation.prototype.start=RetryOperation.prototype.try;RetryOperation.prototype.errors=function(){return this._errors};RetryOperation.prototype.attempts=function(){return this._attempts};RetryOperation.prototype.mainError=function(){if(this._errors.length===0)return null;for(var et={},o=null,tt=0,rt=0;rt=tt&&(o=nt,tt=it)}return o};(function(et){var o=retry_operation;et.operation=function(tt){var rt=et.timeouts(tt);return new o(rt,{forever:tt&&(tt.forever||tt.retries===1/0),unref:tt&&tt.unref,maxRetryTime:tt&&tt.maxRetryTime})},et.timeouts=function(tt){if(tt instanceof Array)return[].concat(tt);var rt={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var nt in tt)rt[nt]=tt[nt];if(rt.minTimeout>rt.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var ot=[],it=0;itobjectToString.call(et)==="[object Error]",errorMessages=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Load failed","Network request failed","fetch failed","terminated"]);function isNetworkError(et){return et&&isError(et)&&et.name==="TypeError"&&typeof et.message=="string"?et.message==="Load failed"?et.stack===void 0:errorMessages.has(et.message):!1}let AbortError$1=class extends Error{constructor(o){super(),o instanceof Error?(this.originalError=o,{message:o}=o):(this.originalError=new Error(o),this.originalError.stack=this.stack),this.name="AbortError",this.message=o}};const decorateErrorWithCounts=(et,o,tt)=>{const rt=tt.retries-(o-1);return et.attemptNumber=o,et.retriesLeft=rt,et};async function pRetry(et,o){return new Promise((tt,rt)=>{o={onFailedAttempt(){},retries:10,shouldRetry:()=>!0,...o};const nt=retry$1.operation(o),ot=()=>{var st;nt.stop(),rt((st=o.signal)==null?void 0:st.reason)};o.signal&&!o.signal.aborted&&o.signal.addEventListener("abort",ot,{once:!0});const it=()=>{var st;(st=o.signal)==null||st.removeEventListener("abort",ot),nt.stop()};nt.attempt(async st=>{try{const at=await et(st);it(),tt(at)}catch(at){try{if(!(at instanceof Error))throw new TypeError(`Non-error was thrown: "${at}". You should only throw errors.`);if(at instanceof AbortError$1)throw at.originalError;if(at instanceof TypeError&&!isNetworkError(at))throw at;if(decorateErrorWithCounts(at,st,o),await o.shouldRetry(at)||(nt.stop(),rt(at)),await o.onFailedAttempt(at),!nt.retry(at))throw nt.mainError()}catch(ct){decorateErrorWithCounts(ct,st,o),it(),rt(ct)}}})})}class ReconnectQueue{constructor(o,tt={}){wt(this,"log");wt(this,"queue");wt(this,"started");wt(this,"peerStore");wt(this,"retries");wt(this,"retryInterval");wt(this,"backoffFactor");wt(this,"connectionManager");wt(this,"events");this.log=o.logger.forComponent("libp2p:reconnect-queue"),this.peerStore=o.peerStore,this.connectionManager=o.connectionManager,this.queue=new PeerQueue({concurrency:tt.maxParallelReconnects??MAX_PARALLEL_RECONNECTS,metricName:"libp2p_reconnect_queue",metrics:o.metrics}),this.started=!1,this.retries=tt.retries??5,this.backoffFactor=tt.backoffFactor,this.retryInterval=tt.retryInterval,this.events=o.events,o.events.addEventListener("peer:disconnect",rt=>{this.maybeReconnect(rt.detail).catch(nt=>{this.log.error("failed to maybe reconnect to %p - %e",rt.detail,nt)})})}async maybeReconnect(o){if(!this.started)return;const tt=await this.peerStore.get(o);hasKeepAliveTag(tt)&&(this.queue.has(o)||this.queue.add(async rt=>{await pRetry(async nt=>{if(this.started)try{await this.connectionManager.openConnection(o,{signal:rt==null?void 0:rt.signal})}catch(ot){throw this.log("reconnecting to %p attempt %d of %d failed - %e",o,nt,this.retries,ot),ot}},{signal:rt==null?void 0:rt.signal,retries:this.retries,factor:this.backoffFactor,minTimeout:this.retryInterval})},{peerId:o}).catch(async rt=>{this.log.error("failed to reconnect to %p - %e",o,rt);const nt={};[...tt.tags.keys()].forEach(ot=>{ot.startsWith(KEEP_ALIVE)&&(nt[ot]=void 0)}),await this.peerStore.merge(o,{tags:nt}),this.events.safeDispatchEvent("peer:reconnect-failure",{detail:o})}).catch(async rt=>{this.log.error("failed to remove keep-alive tag from %p - %e",o,rt)}))}start(){this.started=!0}async afterStart(){Promise.resolve().then(async()=>{const o=await this.peerStore.all({filters:[tt=>hasKeepAliveTag(tt)]});await Promise.all(o.map(async tt=>{await this.connectionManager.openConnection(tt.id).catch(rt=>{this.log.error(rt)})}))}).catch(o=>{this.log.error(o)})}stop(){this.started=!1,this.queue.abort()}}function hasKeepAliveTag(et){for(const o of et.tags.keys())if(o.startsWith(KEEP_ALIVE))return!0;return!1}const DEFAULT_DIAL_PRIORITY=50,defaultOptions={maxConnections:MAX_CONNECTIONS,inboundConnectionThreshold:INBOUND_CONNECTION_THRESHOLD,maxIncomingPendingConnections:MAX_INCOMING_PENDING_CONNECTIONS};var zl;zl=Symbol.toStringTag;class DefaultConnectionManager{constructor(o,tt={}){wt(this,"started");wt(this,"connections");wt(this,"allow");wt(this,"deny");wt(this,"maxIncomingPendingConnections");wt(this,"incomingPendingConnections");wt(this,"outboundPendingConnections");wt(this,"maxConnections");wt(this,"dialQueue");wt(this,"reconnectQueue");wt(this,"connectionPruner");wt(this,"inboundConnectionRateLimiter");wt(this,"peerStore");wt(this,"metrics");wt(this,"events");wt(this,"log");wt(this,"peerId");wt(this,zl,"@libp2p/connection-manager");if(this.maxConnections=tt.maxConnections??defaultOptions.maxConnections,this.maxConnections<1)throw new InvalidParametersError$1("Connection Manager maxConnections must be greater than 0");this.connections=new PeerMap,this.started=!1,this.peerId=o.peerId,this.peerStore=o.peerStore,this.metrics=o.metrics,this.events=o.events,this.log=o.logger.forComponent("libp2p:connection-manager"),this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.allow=(tt.allow??[]).map(rt=>multiaddr(rt)),this.deny=(tt.deny??[]).map(rt=>multiaddr(rt)),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=tt.maxIncomingPendingConnections??defaultOptions.maxIncomingPendingConnections,this.outboundPendingConnections=0,this.inboundConnectionRateLimiter=new RateLimiter({points:tt.inboundConnectionThreshold??defaultOptions.inboundConnectionThreshold,duration:1}),this.connectionPruner=new ConnectionPruner({connectionManager:this,peerStore:o.peerStore,events:o.events,logger:o.logger},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new DialQueue(o,{addressSorter:tt.addressSorter,maxParallelDials:tt.maxParallelDials??MAX_PARALLEL_DIALS,maxDialQueueLength:tt.maxDialQueueLength??MAX_DIAL_QUEUE_LENGTH,maxPeerAddrsToDial:tt.maxPeerAddrsToDial??MAX_PEER_ADDRS_TO_DIAL,dialTimeout:tt.dialTimeout??DIAL_TIMEOUT,resolvers:tt.resolvers??{dnsaddr:dnsaddrResolver},connections:this.connections}),this.reconnectQueue=new ReconnectQueue({events:o.events,peerStore:o.peerStore,logger:o.logger,connectionManager:this},{retries:tt.reconnectRetries,retryInterval:tt.reconnectRetryInterval,backoffFactor:tt.reconnectBackoffFactor,maxParallelReconnects:tt.maxParallelReconnects})}async start(){var o,tt,rt;(o=this.metrics)==null||o.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{const nt={inbound:0,"inbound pending":this.incomingPendingConnections,outbound:0,"outbound pending":this.outboundPendingConnections};for(const ot of this.connections.values())for(const it of ot)nt[it.direction]++;return nt}}),(tt=this.metrics)==null||tt.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{const nt={};for(const ot of this.connections.values())for(const it of ot)for(const st of it.streams){const at=`${st.direction} ${st.protocol??"unnegotiated"}`;nt[at]=(nt[at]??0)+1}return nt}}),(rt=this.metrics)==null||rt.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{const nt={};for(const it of this.connections.values())for(const st of it){const at={};for(const ct of st.streams){const lt=`${ct.direction} ${ct.protocol??"unnegotiated"}`;at[lt]=(at[lt]??0)+1}for(const[ct,lt]of Object.entries(at))nt[ct]=nt[ct]??[],nt[ct].push(lt)}const ot={};for(let[it,st]of Object.entries(nt)){st=st.sort((ct,lt)=>ct-lt);const at=Math.floor(st.length*.9);ot[it]=st[at]}return ot}}),this.events.addEventListener("connection:open",this.onConnect),this.events.addEventListener("connection:close",this.onDisconnect),await start(this.dialQueue,this.reconnectQueue,this.connectionPruner),this.started=!0,this.log("started")}async stop(){this.events.removeEventListener("connection:open",this.onConnect),this.events.removeEventListener("connection:close",this.onDisconnect),await stop(this.reconnectQueue,this.dialQueue,this.connectionPruner);const o=[];for(const tt of this.connections.values())for(const rt of tt)o.push((async()=>{try{await rt.close()}catch(nt){this.log.error(nt)}})());this.log("closing %d connections",o.length),await Promise.all(o),this.connections.clear(),this.log("stopped")}onConnect(o){this._onConnect(o).catch(tt=>{this.log.error(tt)})}async _onConnect(o){const{detail:tt}=o;if(!this.started){await tt.close();return}if(tt.status!=="open")return;const rt=tt.remotePeer,nt=!this.connections.has(rt),ot=this.connections.get(rt)??[];ot.push(tt),this.connections.set(rt,ot),rt.publicKey!=null&&rt.type==="RSA"&&await this.peerStore.patch(rt,{publicKey:rt.publicKey}),nt&&this.events.safeDispatchEvent("peer:connect",{detail:tt.remotePeer})}onDisconnect(o){const{detail:tt}=o,rt=tt.remotePeer,ot=(this.connections.get(rt)??[]).filter(it=>it.id!==tt.id);this.connections.set(rt,ot),ot.length===0&&(this.log("onDisconnect remove all connections for peer %p",rt),this.connections.delete(rt),this.events.safeDispatchEvent("peer:disconnect",{detail:tt.remotePeer}))}getConnections(o){if(o!=null)return this.connections.get(o)??[];let tt=[];for(const rt of this.connections.values())tt=tt.concat(rt);return tt}getConnectionsMap(){return this.connections}async openConnection(o,tt={}){var rt,nt;if(!this.started)throw new NotStartedError("Not started");this.outboundPendingConnections++;try{(rt=tt.signal)==null||rt.throwIfAborted();const{peerId:ot}=getPeerAddress(o);if(this.peerId.equals(ot))throw new InvalidPeerIdError("Can not dial self");if(ot!=null&&tt.force!==!0){this.log("dial %p",ot);const ct=this.getConnections(ot).find(lt=>lt.limits==null);if(ct!=null)return this.log("had an existing non-limited connection to %p",ot),(nt=tt.onProgress)==null||nt.call(tt,new CustomProgressEvent("dial-queue:already-connected")),ct}const it=await this.dialQueue.dial(o,{...tt,priority:tt.priority??DEFAULT_DIAL_PRIORITY});if(it.status!=="open")throw new ConnectionClosedError("Remote closed connection during opening");let st=this.connections.get(it.remotePeer);st==null&&(st=[],this.connections.set(it.remotePeer,st));let at=!1;for(const ct of st)if(ct.id===it.id&&(at=!0),tt.force!==!0&&ct.id!==it.id&&ct.remoteAddr.equals(it.remoteAddr))return it.abort(new InvalidMultiaddrError("Duplicate multiaddr connection")),ct;return at||st.push(it),it}finally{this.outboundPendingConnections--}}async closeConnections(o,tt={}){const rt=this.connections.get(o)??[];await Promise.all(rt.map(async nt=>{try{await nt.close(tt)}catch(ot){nt.abort(ot)}}))}async acceptIncomingConnection(o){if(this.deny.some(nt=>o.remoteAddr.toString().startsWith(nt.toString())))return this.log("connection from %a refused - connection remote address was in deny list",o.remoteAddr),!1;if(this.allow.some(nt=>o.remoteAddr.toString().startsWith(nt.toString())))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.maxIncomingPendingConnections)return this.log("connection from %a refused - incomingPendingConnections exceeded by host",o.remoteAddr),!1;if(o.remoteAddr.isThinWaistAddress()){const nt=o.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(nt,1)}catch{return this.log("connection from %a refused - inboundConnectionThreshold exceeded by host %s",o.remoteAddr,nt),!1}}return this.getConnections().length({id:tt.id,status:o[tt.status],peerId:tt.options.peerId,multiaddrs:[...tt.options.multiaddrs].map(rt=>multiaddr(rt))}))}async isDialable(o,tt={}){return this.dialQueue.isDialable(o,tt)}}class MovingAverage{constructor(o){wt(this,"movingAverage");wt(this,"variance");wt(this,"deviation");wt(this,"forecast");wt(this,"timespan");wt(this,"previousTime");this.timespan=o,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(o,tt){return 1-Math.exp(-(o-tt)/this.timespan)}push(o,tt=Date.now()){if(this.previousTime!=null){const rt=this.alpha(tt,this.previousTime),nt=o-this.movingAverage,ot=rt*nt;this.movingAverage=rt*o+(1-rt)*this.movingAverage,this.variance=(1-rt)*(this.variance+nt*ot),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+rt*nt}else this.movingAverage=o;this.previousTime=tt}}const DEFAULT_TIMEOUT_MULTIPLIER=1.2,DEFAULT_FAILURE_MULTIPLIER=2,DEFAULT_MIN_TIMEOUT=2e3;class AdaptiveTimeout{constructor(o={}){wt(this,"success");wt(this,"failure");wt(this,"next");wt(this,"metric");wt(this,"timeoutMultiplier");wt(this,"failureMultiplier");wt(this,"minTimeout");var tt;this.success=new MovingAverage(o.interval??5e3),this.failure=new MovingAverage(o.interval??5e3),this.next=new MovingAverage(o.interval??5e3),this.failureMultiplier=o.failureMultiplier??DEFAULT_FAILURE_MULTIPLIER,this.timeoutMultiplier=o.timeoutMultiplier??DEFAULT_TIMEOUT_MULTIPLIER,this.minTimeout=o.minTimeout??DEFAULT_MIN_TIMEOUT,o.metricName!=null&&(this.metric=(tt=o.metrics)==null?void 0:tt.registerMetricGroup(o.metricName))}getTimeoutSignal(o={}){const tt=Math.max(Math.round(this.next.movingAverage*(o.timeoutFactor??this.timeoutMultiplier)),this.minTimeout),rt=AbortSignal.timeout(tt),nt=anySignal([o.signal,rt]);return setMaxListeners$2(1/0,nt,rt),nt.start=Date.now(),nt.timeout=tt,nt}cleanUp(o){var rt,nt;const tt=Date.now()-o.start;o.aborted?(this.failure.push(tt),this.next.push(tt*this.failureMultiplier),(rt=this.metric)==null||rt.update({failureMovingAverage:this.failure.movingAverage,failureDeviation:this.failure.deviation,failureForecast:this.failure.forecast,failureVariance:this.failure.variance,failure:tt})):(this.success.push(tt),this.next.push(tt),(nt=this.metric)==null||nt.update({successMovingAverage:this.success.movingAverage,successDeviation:this.success.deviation,successForecast:this.success.forecast,successVariance:this.success.variance,success:tt}))}}const DEFAULT_PING_INTERVAL_MS=1e4,PROTOCOL_VERSION="1.0.0",PROTOCOL_NAME="ping",PROTOCOL_PREFIX="ipfs",PING_LENGTH=32,DEFAULT_ABORT_CONNECTION_ON_PING_FAILURE=!0;var Vl,Hl;Hl=Symbol.toStringTag,Vl=serviceCapabilities;class ConnectionMonitor{constructor(o,tt={}){wt(this,"protocol");wt(this,"components");wt(this,"log");wt(this,"heartbeatInterval");wt(this,"pingIntervalMs");wt(this,"abortController");wt(this,"timeout");wt(this,"abortConnectionOnPingFailure");wt(this,Hl,"@libp2p/connection-monitor");wt(this,Vl,["@libp2p/connection-monitor"]);this.components=o,this.protocol=`/${tt.protocolPrefix??PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`,this.log=o.logger.forComponent("libp2p:connection-monitor"),this.pingIntervalMs=tt.pingInterval??DEFAULT_PING_INTERVAL_MS,this.abortConnectionOnPingFailure=tt.abortConnectionOnPingFailure??DEFAULT_ABORT_CONNECTION_ON_PING_FAILURE,this.timeout=new AdaptiveTimeout({...tt.pingTimeout??{},metrics:o.metrics,metricName:"libp2p_connection_monitor_ping_time_milliseconds"})}start(){this.abortController=new AbortController,setMaxListeners(1/0,this.abortController.signal),this.heartbeatInterval=setInterval(()=>{this.components.connectionManager.getConnections().forEach(o=>{Promise.resolve().then(async()=>{var rt;let tt=Date.now();try{const nt=this.timeout.getTimeoutSignal({signal:(rt=this.abortController)==null?void 0:rt.signal}),ot=await o.newStream(this.protocol,{signal:nt,runOnLimitedConnection:!0}),it=byteStream(ot);tt=Date.now(),await Promise.all([it.write(randomBytes(PING_LENGTH),{signal:nt}),it.read(PING_LENGTH,{signal:nt})]),o.rtt=Date.now()-tt,await it.unwrap().close({signal:nt})}catch(nt){if(nt.name!=="UnsupportedProtocolError")throw nt;o.rtt=(Date.now()-tt)/2}}).catch(tt=>{this.log.error("error during heartbeat",tt),this.abortConnectionOnPingFailure?(this.log.error("aborting connection due to ping failure"),o.abort(tt)):this.log("connection ping failed, but not aborting due to abortConnectionOnPingFailure flag")})})},this.pingIntervalMs)}stop(){var o;(o=this.abortController)==null||o.abort(),this.heartbeatInterval!=null&&clearInterval(this.heartbeatInterval)}}var Wl;Wl=Symbol.toStringTag;class CompoundContentRouting{constructor(o,tt){wt(this,"routers");wt(this,"started");wt(this,"components");wt(this,Wl,"@libp2p/content-routing");this.routers=tt.routers??[],this.started=!1,this.components=o}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}async*findProviders(o,tt={}){if(this.routers.length===0)throw new NoContentRoutersError("No content routers available");const rt=this,nt=new PeerSet;for await(const ot of merge$2(...rt.routers.map(it=>it.findProviders(o,tt))))ot!=null&&(ot.multiaddrs.length>0&&await this.components.peerStore.merge(ot.id,{multiaddrs:ot.multiaddrs}),!nt.has(ot.id)&&(nt.add(ot.id),yield ot))}async provide(o,tt={}){if(this.routers.length===0)throw new NoContentRoutersError("No content routers available");await Promise.all(this.routers.map(async rt=>{await rt.provide(o,tt)}))}async put(o,tt,rt){if(!this.isStarted())throw new NotStartedError;await Promise.all(this.routers.map(async nt=>{await nt.put(o,tt,rt)}))}async get(o,tt){if(!this.isStarted())throw new NotStartedError;return Promise.any(this.routers.map(async rt=>rt.get(o,tt)))}}var Gl;Gl=Symbol.toStringTag;class DefaultPeerRouting{constructor(o,tt={}){wt(this,"log");wt(this,"peerId");wt(this,"peerStore");wt(this,"routers");wt(this,Gl,"@libp2p/peer-routing");this.log=o.logger.forComponent("libp2p:peer-routing"),this.peerId=o.peerId,this.peerStore=o.peerStore,this.routers=tt.routers??[]}async findPeer(o,tt){if(this.routers.length===0)throw new NoPeerRoutersError("No peer routers available");if(o.toString()===this.peerId.toString())throw new QueriedForSelfError("Should not try to find self");const rt=this,nt=merge$2(...this.routers.map(ot=>async function*(){try{yield await ot.findPeer(o,tt)}catch(it){rt.log.error(it)}}()));for await(const ot of nt)if(ot!=null)return ot.multiaddrs.length>0&&await this.peerStore.merge(ot.id,{multiaddrs:ot.multiaddrs}),ot;throw new NotFoundError$1}async*getClosestPeers(o,tt={}){if(this.routers.length===0)throw new NoPeerRoutersError("No peer routers available");const rt=this,nt=createScalableCuckooFilter(1024);for await(const ot of parallel(async function*(){const it=merge$2(...rt.routers.map(st=>st.getClosestPeers(o,tt)));for await(let st of it)yield async()=>{if(st.multiaddrs.length===0)try{st=await rt.findPeer(st.id,{...tt,useCache:!1})}catch(at){rt.log.error("could not find peer multiaddrs",at);return}return st}}()))ot!=null&&(ot.multiaddrs.length>0&&await this.peerStore.merge(ot.id,{multiaddrs:ot.multiaddrs}),!nt.has(ot.id.toMultihash().bytes)&&(nt.add(ot.id.toMultihash().bytes),yield ot))}}var Kl,Ql;class RandomWalk extends(Ql=TypedEventEmitter,Kl=Symbol.toStringTag,Ql){constructor(tt){super();wt(this,"peerRouting");wt(this,"log");wt(this,"walking");wt(this,"walkers");wt(this,"shutdownController");wt(this,"walkController");wt(this,"needNext");wt(this,Kl,"@libp2p/random-walk");this.log=tt.logger.forComponent("libp2p:random-walk"),this.peerRouting=tt.peerRouting,this.walkers=0,this.walking=!1,this.shutdownController=new AbortController,setMaxListeners(1/0,this.shutdownController.signal)}start(){this.shutdownController=new AbortController,setMaxListeners(1/0,this.shutdownController.signal)}stop(){this.shutdownController.abort()}async*walk(tt){var nt,ot;this.walking||this.startWalk(),this.walkers++;const rt=anySignal([this.shutdownController.signal,tt==null?void 0:tt.signal]);setMaxListeners(1/0,rt);try{for(;;)(nt=this.needNext)==null||nt.resolve(),this.needNext=pDefer(),yield(await raceEvent(this,"walk:peer",rt,{errorEvent:"walk:error"})).detail}finally{rt.clear(),this.walkers--,this.walkers===0&&((ot=this.walkController)==null||ot.abort(),this.walkController=void 0)}}startWalk(){this.walking=!0,this.walkController=new AbortController,setMaxListeners(1/0,this.walkController.signal);const tt=anySignal([this.walkController.signal,this.shutdownController.signal]);setMaxListeners(1/0,tt);const rt=Date.now();let nt=0;Promise.resolve().then(async()=>{for(this.log("start walk");this.walkers>0;)try{const ot=randomBytes(32);let it=Date.now();for await(const st of this.peerRouting.getClosestPeers(ot,{signal:tt}))tt.aborted&&this.log("aborting walk"),tt.throwIfAborted(),this.log("found peer %p after %dms for %d walkers",st.id,Date.now()-it,this.walkers),nt++,this.safeDispatchEvent("walk:peer",{detail:st}),this.walkers===1&&this.needNext!=null&&(this.log("wait for need next"),await raceSignal(this.needNext.promise,tt)),it=Date.now();this.log("walk iteration for %b and %d walkers finished, found %d peers",ot,this.walkers,nt)}catch(ot){this.log.error("randomwalk errored",ot),this.safeDispatchEvent("walk:error",{detail:ot})}this.log("no walkers left, ended walk")}).catch(ot=>{this.log.error("randomwalk errored",ot)}).finally(()=>{this.log("finished walk, found %d peers after %dms",nt,Date.now()-rt),this.walking=!1})}}const DEFAULT_MAX_INBOUND_STREAMS=32,DEFAULT_MAX_OUTBOUND_STREAMS=64;var Xl;Xl=Symbol.toStringTag;class DefaultRegistrar{constructor(o){wt(this,"log");wt(this,"topologies");wt(this,"handlers");wt(this,"components");wt(this,Xl,"@libp2p/registrar");this.log=o.logger.forComponent("libp2p:registrar"),this.topologies=new Map,this.handlers=new Map,this.components=o,this._onDisconnect=this._onDisconnect.bind(this),this._onPeerUpdate=this._onPeerUpdate.bind(this),this._onPeerIdentify=this._onPeerIdentify.bind(this),this.components.events.addEventListener("peer:disconnect",this._onDisconnect),this.components.events.addEventListener("peer:update",this._onPeerUpdate),this.components.events.addEventListener("peer:identify",this._onPeerIdentify)}getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(o){const tt=this.handlers.get(o);if(tt==null)throw new UnhandledProtocolError(`No handler registered for protocol ${o}`);return tt}getTopologies(o){const tt=this.topologies.get(o);return tt==null?[]:[...tt.values()]}async handle(o,tt,rt){if(this.handlers.has(o))throw new DuplicateProtocolHandlerError(`Handler already registered for protocol ${o}`);const nt=mergeOptions$1.bind({ignoreUndefined:!0})({maxInboundStreams:DEFAULT_MAX_INBOUND_STREAMS,maxOutboundStreams:DEFAULT_MAX_OUTBOUND_STREAMS},rt);this.handlers.set(o,{handler:tt,options:nt}),await this.components.peerStore.merge(this.components.peerId,{protocols:[o]})}async unhandle(o){(Array.isArray(o)?o:[o]).forEach(rt=>{this.handlers.delete(rt)}),await this.components.peerStore.patch(this.components.peerId,{protocols:this.getProtocols()})}async register(o,tt){if(tt==null)throw new InvalidParametersError$1("invalid topology");const rt=`${(Math.random()*1e9).toString(36)}${Date.now()}`;let nt=this.topologies.get(o);return nt==null&&(nt=new Map,this.topologies.set(o,nt)),nt.set(rt,tt),rt}unregister(o){for(const[tt,rt]of this.topologies.entries())rt.has(o)&&(rt.delete(o),rt.size===0&&this.topologies.delete(tt))}_onDisconnect(o){const tt=o.detail;this.components.peerStore.get(tt).then(rt=>{var nt,ot,it;for(const st of rt.protocols){const at=this.topologies.get(st);if(at!=null)for(const ct of at.values())((nt=ct.filter)==null?void 0:nt.has(tt))!==!1&&((ot=ct.filter)==null||ot.remove(tt),(it=ct.onDisconnect)==null||it.call(ct,tt))}}).catch(rt=>{rt.name!=="NotFoundError"&&this.log.error("could not inform topologies of disconnecting peer %p",tt,rt)})}_onPeerUpdate(o){var ot,it,st;const{peer:tt,previous:rt}=o.detail,nt=((rt==null?void 0:rt.protocols)??[]).filter(at=>!tt.protocols.includes(at));for(const at of nt){const ct=this.topologies.get(at);if(ct!=null)for(const lt of ct.values())((ot=lt.filter)==null?void 0:ot.has(tt.id))!==!1&&((it=lt.filter)==null||it.remove(tt.id),(st=lt.onDisconnect)==null||st.call(lt,tt.id))}}_onPeerIdentify(o){var ot,it,st;const tt=o.detail.protocols,rt=o.detail.connection,nt=o.detail.peerId;for(const at of tt){const ct=this.topologies.get(at);if(ct!=null)for(const lt of ct.values())rt.limits!=null&<.notifyOnLimitedConnection!==!0||((ot=lt.filter)==null?void 0:ot.has(nt))!==!0&&((it=lt.filter)==null||it.add(nt),(st=lt.onConnect)==null||st.call(lt,nt,rt))}}}class TrackedMap extends Map{constructor(tt){super();wt(this,"metric");const{name:rt,metrics:nt}=tt;this.metric=nt.registerMetric(rt),this.updateComponentMetric()}set(tt,rt){return super.set(tt,rt),this.updateComponentMetric(),this}delete(tt){const rt=super.delete(tt);return this.updateComponentMetric(),rt}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}}function trackedMap(et){const{name:o,metrics:tt}=et;let rt;return tt!=null?rt=new TrackedMap({name:o,metrics:tt}):rt=new Map,rt}var Yl;Yl=Symbol.toStringTag;class DefaultTransportManager{constructor(o,tt={}){wt(this,"log");wt(this,"components");wt(this,"transports");wt(this,"listeners");wt(this,"faultTolerance");wt(this,"started");wt(this,Yl,"@libp2p/transport-manager");this.log=o.logger.forComponent("libp2p:transports"),this.components=o,this.started=!1,this.transports=new Map,this.listeners=trackedMap({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=tt.faultTolerance??FaultTolerance.FATAL_ALL}add(o){const tt=o[Symbol.toStringTag];if(tt==null)throw new InvalidParametersError$1("Transport must have a valid tag");if(this.transports.has(tt))throw new InvalidParametersError$1(`There is already a transport with the tag ${tt}`);this.log("adding transport %s",tt),this.transports.set(tt,o),this.listeners.has(tt)||this.listeners.set(tt,[])}isStarted(){return this.started}start(){this.started=!0}async afterStart(){const o=this.components.addressManager.getListenAddrs();await this.listen(o)}async stop(){const o=[];for(const[tt,rt]of this.listeners)for(this.log("closing listeners for %s",tt);rt.length>0;){const nt=rt.pop();nt!=null&&o.push(nt.close())}await Promise.all(o),this.log("all listeners closed");for(const tt of this.listeners.keys())this.listeners.set(tt,[]);this.started=!1}async dial(o,tt){var nt;const rt=this.dialTransportForMultiaddr(o);if(rt==null)throw new TransportUnavailableError(`No transport available for address ${String(o)}`);return(nt=tt==null?void 0:tt.onProgress)==null||nt.call(tt,new CustomProgressEvent("transport-manager:selected-transport",rt[Symbol.toStringTag])),rt.dial(o,{...tt,upgrader:this.components.upgrader})}getAddrs(){let o=[];for(const tt of this.listeners.values())for(const rt of tt)o=[...o,...rt.getAddrs()];return o}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}dialTransportForMultiaddr(o){for(const tt of this.transports.values())if(tt.dialFilter([o]).length>0)return tt}listenTransportForMultiaddr(o){for(const tt of this.transports.values())if(tt.listenFilter([o]).length>0)return tt}async listen(o){if(!this.isStarted())throw new NotStartedError("Not started");if(o==null||o.length===0){this.log("no addresses were provided for listening, this node is dial only");return}const tt=[];for(const[rt,nt]of this.transports.entries()){const ot=nt.listenFilter(o),it=[];for(const ct of ot){this.log("creating listener for %s on %a",rt,ct);const lt=nt.createListener({upgrader:this.components.upgrader});let dt=this.listeners.get(rt)??[];dt==null&&(dt=[],this.listeners.set(rt,dt)),dt.push(lt),lt.addEventListener("listening",()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:lt})}),lt.addEventListener("close",()=>{const ht=dt.findIndex(mt=>mt===lt);dt.splice(ht,1),this.components.events.safeDispatchEvent("transport:close",{detail:lt})}),it.push(lt.listen(ct))}if(it.length===0){tt.push(rt);continue}if((await Promise.allSettled(it)).find(ct=>ct.status==="fulfilled")==null&&this.faultTolerance!==FaultTolerance.NO_FATAL)throw new NoValidAddressesError(`Transport (${rt}) could not listen on any available address`)}if(tt.length===this.transports.size){const rt=`no valid addresses were provided for transports [${tt.join(", ")}]`;if(this.faultTolerance===FaultTolerance.FATAL_ALL)throw new NoValidAddressesError(rt);this.log(`libp2p in dial mode only: ${rt}`)}}async remove(o){const tt=this.listeners.get(o)??[];this.log.trace("removing transport %s",o);const rt=[];for(this.log.trace("closing listeners for %s",o);tt.length>0;){const nt=tt.pop();nt!=null&&rt.push(nt.close())}await Promise.all(rt),this.transports.delete(o),this.listeners.delete(o)}async removeAll(){const o=[];for(const tt of this.transports.keys())o.push(this.remove(tt));await Promise.all(o)}}const PROTOCOL_ID="/multistream/1.0.0",MAX_PROTOCOL_LENGTH=1024;class UnsupportedProtocolError extends Error{constructor(o="Unsupported protocol error"){super(o),this.name="UnsupportedProtocolError"}}wt(UnsupportedProtocolError,"name","UnsupportedProtocolError");class InvalidMessageError extends Error{constructor(o="Invalid message"){super(o),this.name="InvalidMessageError"}}wt(InvalidMessageError,"name","InvalidMessageError");function coerce$2(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$5(et){return new TextEncoder().encode(et)}function toString$a(et){return new TextDecoder().decode(et)}function base$2(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$3=base$2,_brrp__multiformats_scope_baseX$2=src$3;let Encoder$2=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$2=class{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$2(this,o)}},ComposedDecoder$2=class{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or$2(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function or$2(et,o){return new ComposedDecoder$2({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}let Codec$2=class{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$2(o,tt,rt),this.decoder=new Decoder$2(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};function from$3({name:et,prefix:o,encode:tt,decode:rt}){return new Codec$2(et,o,tt,rt)}function baseX$2({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$2(tt,et);return from$3({prefix:o,name:et,encode:rt,decode:ot=>coerce$2(nt(ot))})}function decode$a(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$9(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes$2=alphabet$2.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode$8(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$2[tt],o),"")}function decode$9(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes$2[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji$4=from$3({prefix:"🚀",name:"base256emoji",encode:encode$8,decode:decode$9}),base256emoji$5=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$4},Symbol.toStringTag,{value:"Module"})),base32$6=rfc4648$2({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$2=rfc4648$2({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$2=rfc4648$2({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$2=rfc4648$2({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$2=rfc4648$2({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$2=rfc4648$2({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$2=rfc4648$2({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$2=rfc4648$2({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$2=rfc4648$2({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$7=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$6,base32hex:base32hex$2,base32hexpad:base32hexpad$2,base32hexpadupper:base32hexpadupper$2,base32hexupper:base32hexupper$2,base32pad:base32pad$2,base32padupper:base32padupper$2,base32upper:base32upper$2,base32z:base32z$2},Symbol.toStringTag,{value:"Module"})),base36$4=baseX$2({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$2=baseX$2({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$5=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$4,base36upper:base36upper$2},Symbol.toStringTag,{value:"Module"})),base58btc$2=baseX$2({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$2=baseX$2({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$2=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$2,base58flickr:base58flickr$2},Symbol.toStringTag,{value:"Module"})),base64$6=rfc4648$2({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$2=rfc4648$2({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$2=rfc4648$2({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$2=rfc4648$2({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$7=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$6,base64pad:base64pad$2,base64url:base64url$2,base64urlpad:base64urlpad$2},Symbol.toStringTag,{value:"Module"})),base8$4=rfc4648$2({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$5=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$4},Symbol.toStringTag,{value:"Module"})),identity$2=from$3({prefix:"\0",name:"identity",encode:et=>toString$a(et),decode:et=>fromString$5(et)}),identityBase$2=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$2},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$2={...identityBase$2,...base2$5,...base8$5,...base10$5,...base16$5,...base32$7,...base36$5,...base58$2,...base64$7,...base256emoji$5};function allocUnsafe$1(et=0){return new Uint8Array(et)}function createCodec$2(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$5=createCodec$2("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$2=createCodec$2("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$1(et.length);for(let tt=0;tt{const{sink:xt}=ft.unwrap();await xt(async function*(){let vt=!1;for await(const Et of bt){if(ct&&await lt.promise,at)yield Et;else{ct=!0,tt.log.trace('optimistic: write ["%s", "%s", data(%d)] in sink',PROTOCOL_ID,o,Et.byteLength);const Ct=`${o} `;yield new Uint8ArrayList(Uint8Array.from([19]),fromString$4(`${PROTOCOL_ID} -`),encode$P(Ct.length),fromString$4(Ct),Et).subarray(),tt.log.trace('optimistic: wrote ["%s", "%s", data(%d)] in sink',PROTOCOL_ID,o,Et.byteLength),at=!0,ct=!1,lt.resolve(),pt().catch(St=>{tt.log.error("could not finish optimistic protocol negotiation of %s",o,St)})}vt=!0}vt||await pt()}())};async function pt(){if(it){tt.log.trace("optimistic: already negotiating %s stream",o),await st.promise;return}it=!0;try{at||(tt.log.trace("optimistic: doing send protocol for %s stream",o),await gt()),dt||(tt.log.trace("optimistic: doing read protocol for %s stream",o),await yt())}finally{it=!1,ot=!0,st.resolve()}}async function gt(){if(ct){await lt.promise;return}ct=!0;try{tt.log.trace('optimistic: write ["%s", "%s", data] in source',PROTOCOL_ID,o),await ft.writeV([fromString$4(`${PROTOCOL_ID} +`),encode$P(Ct.length),fromString$4(Ct),Et).subarray(),tt.log.trace('optimistic: wrote ["%s", "%s", data(%d)] in sink',PROTOCOL_ID,o,Et.byteLength),at=!0,ct=!1,lt.resolve(),pt().catch(St=>{tt.log.error("could not finish optimistic protocol negotiation of %s",o,St)})}vt=!0}vt||await pt()}())};async function pt(){if(it){tt.log.trace("optimistic: already negotiating %s stream",o),await st.promise;return}it=!0;try{at||(tt.log.trace("optimistic: doing send protocol for %s stream",o),await yt()),dt||(tt.log.trace("optimistic: doing read protocol for %s stream",o),await gt())}finally{it=!1,ot=!0,st.resolve()}}async function yt(){if(ct){await lt.promise;return}ct=!0;try{tt.log.trace('optimistic: write ["%s", "%s", data] in source',PROTOCOL_ID,o),await ft.writeV([fromString$4(`${PROTOCOL_ID} `),fromString$4(`${o} -`)]),tt.log.trace('optimistic: wrote ["%s", "%s", data] in source',PROTOCOL_ID,o)}finally{at=!0,ct=!1,lt.resolve()}}async function yt(){if(ht){await mt.promise;return}ht=!0;try{tt.log.trace("optimistic: reading multistream select header");let bt=await readString(ft,tt);if(tt.log.trace('optimistic: read multistream select header "%s"',bt),bt===PROTOCOL_ID&&(bt=await readString(ft,tt)),tt.log.trace('optimistic: read protocol "%s", expecting "%s"',bt,o),bt!==o)throw new UnsupportedProtocolError("protocol selection failed")}finally{dt=!0,ht=!1,mt.resolve()}}if(et.source=async function*(){await pt(),tt.log.trace('optimistic: reading data from "%s" stream',o),yield*ft.unwrap().source}(),et.closeRead!=null){const bt=et.closeRead.bind(et);et.closeRead=async xt=>{ot||await pt().catch(vt=>{tt.log.error("could not negotiate protocol before close read",vt)}),await bt(xt)}}if(et.closeWrite!=null){const bt=et.closeWrite.bind(et);et.closeWrite=async xt=>{ot||await pt().catch(vt=>{tt.log.error("could not negotiate protocol before close write",vt)}),await bt(xt)}}if(et.close!=null){const bt=et.close.bind(et);et.close=async xt=>{const vt=[];ct&&vt.push(lt.promise),ht&&vt.push(mt.promise),vt.length>0?await raceSignal(Promise.all(vt),xt==null?void 0:xt.signal):(ot=!0,it=!1,st.resolve()),await bt(xt)}}return{stream:et,protocol:o}}async function handle(et,o,tt){o=Array.isArray(o)?o:[o],tt.log.trace("handle: available protocols %s",o);const rt=lpStream(et,{...tt,maxDataLength:MAX_PROTOCOL_LENGTH,maxLengthLength:2});for(;;){tt.log.trace("handle: reading incoming string");const nt=await readString(rt,tt);if(tt.log.trace('handle: read "%s"',nt),nt===PROTOCOL_ID){tt.log.trace('handle: respond with "%s" for "%s"',PROTOCOL_ID,nt),await write$1(rt,fromString$4(`${PROTOCOL_ID} +`)]),tt.log.trace('optimistic: wrote ["%s", "%s", data] in source',PROTOCOL_ID,o)}finally{at=!0,ct=!1,lt.resolve()}}async function gt(){if(ht){await mt.promise;return}ht=!0;try{tt.log.trace("optimistic: reading multistream select header");let bt=await readString(ft,tt);if(tt.log.trace('optimistic: read multistream select header "%s"',bt),bt===PROTOCOL_ID&&(bt=await readString(ft,tt)),tt.log.trace('optimistic: read protocol "%s", expecting "%s"',bt,o),bt!==o)throw new UnsupportedProtocolError("protocol selection failed")}finally{dt=!0,ht=!1,mt.resolve()}}if(et.source=async function*(){await pt(),tt.log.trace('optimistic: reading data from "%s" stream',o),yield*ft.unwrap().source}(),et.closeRead!=null){const bt=et.closeRead.bind(et);et.closeRead=async xt=>{ot||await pt().catch(vt=>{tt.log.error("could not negotiate protocol before close read",vt)}),await bt(xt)}}if(et.closeWrite!=null){const bt=et.closeWrite.bind(et);et.closeWrite=async xt=>{ot||await pt().catch(vt=>{tt.log.error("could not negotiate protocol before close write",vt)}),await bt(xt)}}if(et.close!=null){const bt=et.close.bind(et);et.close=async xt=>{const vt=[];ct&&vt.push(lt.promise),ht&&vt.push(mt.promise),vt.length>0?await raceSignal(Promise.all(vt),xt==null?void 0:xt.signal):(ot=!0,it=!1,st.resolve()),await bt(xt)}}return{stream:et,protocol:o}}async function handle(et,o,tt){o=Array.isArray(o)?o:[o],tt.log.trace("handle: available protocols %s",o);const rt=lpStream(et,{...tt,maxDataLength:MAX_PROTOCOL_LENGTH,maxLengthLength:2});for(;;){tt.log.trace("handle: reading incoming string");const nt=await readString(rt,tt);if(tt.log.trace('handle: read "%s"',nt),nt===PROTOCOL_ID){tt.log.trace('handle: respond with "%s" for "%s"',PROTOCOL_ID,nt),await write$1(rt,fromString$4(`${PROTOCOL_ID} `),tt),tt.log.trace('handle: responded with "%s" for "%s"',PROTOCOL_ID,nt);continue}if(o.includes(nt))return tt.log.trace('handle: respond with "%s" for "%s"',nt,nt),await write$1(rt,fromString$4(`${nt} `),tt),tt.log.trace('handle: responded with "%s" for "%s"',nt,nt),{stream:rt.unwrap(),protocol:nt};if(nt==="ls"){const ot=new Uint8ArrayList(...o.map(it=>encode$K.single(fromString$4(`${it} `))),fromString$4(` `));tt.log.trace('handle: respond with "%s" for %s',o,nt),await write$1(rt,ot,tt),tt.log.trace('handle: responded with "%s" for %s',o,nt);continue}tt.log.trace('handle: respond with "na" for "%s"',nt),await write$1(rt,fromString$4(`na -`),tt),tt.log('handle: responded with "na" for "%s"',nt)}}const CLOSE_TIMEOUT=500;var Jl,eu;eu=Symbol.toStringTag,Jl=connectionSymbol;class ConnectionImpl{constructor(o){wt(this,"id");wt(this,"remoteAddr");wt(this,"remotePeer");wt(this,"direction");wt(this,"timeline");wt(this,"multiplexer");wt(this,"encryption");wt(this,"status");wt(this,"limits");wt(this,"log");wt(this,"tags");wt(this,"_newStream");wt(this,"_close");wt(this,"_abort");wt(this,"_getStreams");wt(this,eu,"Connection");wt(this,Jl,!0);const{remoteAddr:tt,remotePeer:rt,newStream:nt,close:ot,abort:it,getStreams:st}=o;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=tt,this.remotePeer=rt,this.direction=o.direction,this.status="open",this.timeline=o.timeline,this.multiplexer=o.multiplexer,this.encryption=o.encryption,this.limits=o.limits,this.log=o.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`),this.remoteAddr.getPeerId()==null&&(this.remoteAddr=this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`)),this._newStream=nt,this._close=ot,this._abort=it,this._getStreams=st,this.tags=[]}get streams(){return this._getStreams()}async newStream(o,tt){if(this.status==="closing")throw new ConnectionClosingError("the connection is being closed");if(this.status==="closed")throw new ConnectionClosedError("the connection is closed");if(Array.isArray(o)||(o=[o]),this.limits!=null&&(tt==null?void 0:tt.runOnLimitedConnection)!==!0)throw new LimitedConnectionError("Cannot open protocol stream on limited connection");const rt=await this._newStream(o,tt);return rt.direction="outbound",rt}async close(o={}){if(!(this.status==="closed"||this.status==="closing")){if(this.log("closing connection to %a",this.remoteAddr),this.status="closing",o.signal==null){const tt=AbortSignal.timeout(CLOSE_TIMEOUT);setMaxListeners(1/0,tt),o={...o,signal:tt}}try{this.log.trace("closing underlying transport"),await this._close(o),this.log.trace("updating timeline with close time"),this.status="closed",this.timeline.close=Date.now()}catch(tt){this.log.error("error encountered during graceful close of connection to %a",this.remoteAddr,tt),this.abort(tt)}}}abort(o){this.status!=="closed"&&(this.log.error("aborting connection to %a due to error",this.remoteAddr,o),this.status="closing",this._abort(o),this.status="closed",this.timeline.close=Date.now())}}function createConnection(et){return new ConnectionImpl(et)}function findIncomingStreamLimit(et,o){try{const{options:tt}=o.getHandler(et);return tt.maxInboundStreams}catch(tt){if(tt.name!=="UnhandledProtocolError")throw tt}return DEFAULT_MAX_INBOUND_STREAMS}function findOutgoingStreamLimit(et,o,tt={}){try{const{options:rt}=o.getHandler(et);if(rt.maxOutboundStreams!=null)return rt.maxOutboundStreams}catch(rt){if(rt.name!=="UnhandledProtocolError")throw rt}return tt.maxOutboundStreams??DEFAULT_MAX_OUTBOUND_STREAMS}function countStreams(et,o,tt){let rt=0;return tt.streams.forEach(nt=>{nt.direction===o&&nt.protocol===et&&rt++}),rt}var tu;tu=Symbol.toStringTag;class DefaultUpgrader{constructor(o,tt){wt(this,"components");wt(this,"connectionEncrypters");wt(this,"streamMuxers");wt(this,"inboundUpgradeTimeout");wt(this,"outboundUpgradeTimeout");wt(this,"inboundStreamProtocolNegotiationTimeout");wt(this,"outboundStreamProtocolNegotiationTimeout");wt(this,"events");wt(this,"metrics");wt(this,tu,"@libp2p/upgrader");var rt,nt;this.components=o,this.connectionEncrypters=new Map,tt.connectionEncrypters.forEach(ot=>{this.connectionEncrypters.set(ot.protocol,ot)}),this.streamMuxers=new Map,tt.streamMuxers.forEach(ot=>{this.streamMuxers.set(ot.protocol,ot)}),this.inboundUpgradeTimeout=tt.inboundUpgradeTimeout??UPGRADE_TIMEOUT,this.outboundUpgradeTimeout=tt.outboundUpgradeTimeout??UPGRADE_TIMEOUT,this.inboundStreamProtocolNegotiationTimeout=tt.inboundStreamProtocolNegotiationTimeout??PROTOCOL_NEGOTIATION_TIMEOUT,this.outboundStreamProtocolNegotiationTimeout=tt.outboundStreamProtocolNegotiationTimeout??PROTOCOL_NEGOTIATION_TIMEOUT,this.events=o.events,this.metrics={dials:(rt=o.metrics)==null?void 0:rt.registerCounterGroup("libp2p_connection_manager_dials_total"),errors:(nt=o.metrics)==null?void 0:nt.registerCounterGroup("libp2p_connection_manager_dial_errors_total")}}async shouldBlockConnection(o,...tt){const rt=this.components.connectionGater[o];if(rt==null)return;if(await rt.apply(this.components.connectionGater,tt)===!0)throw new ConnectionInterceptedError(`The multiaddr connection is blocked by gater.${o}`)}async upgradeInbound(o,tt={}){var rt,nt;try{if((rt=this.metrics.dials)==null||rt.increment({inbound:!0}),!await this.components.connectionManager.acceptIncomingConnection(o))throw new ConnectionDeniedError("connection denied");return await this.shouldBlockConnection("denyInboundConnection",o),await this._performUpgrade(o,"inbound",tt)}catch(ot){throw(nt=this.metrics.errors)==null||nt.increment({inbound:!0}),ot}finally{this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(o,tt={}){var rt,nt;try{(rt=this.metrics.dials)==null||rt.increment({outbound:!0});const ot=o.remoteAddr.getPeerId();let it;return ot!=null&&(it=peerIdFromString$1(ot),await this.shouldBlockConnection("denyOutboundConnection",it,o)),await this._performUpgrade(o,"outbound",tt)}catch(ot){throw(nt=this.metrics.errors)==null||nt.increment({outbound:!0}),ot}}async _performUpgrade(o,tt,rt){var ht,mt,ft;let nt,ot,it,st,at;const ct=AbortSignal.timeout(tt==="inbound"?this.inboundUpgradeTimeout:this.outboundUpgradeTimeout),lt=anySignal([ct,rt.signal]);setMaxListeners(1/0,ct,lt),rt.signal=lt,(ht=this.components.metrics)==null||ht.trackMultiaddrConnection(o),o.log.trace("starting the %s connection upgrade",tt);let dt=o;if((rt==null?void 0:rt.skipProtection)!==!0){const pt=this.components.connectionProtector;pt!=null&&(o.log("protecting the %s connection",tt),dt=await pt.protect(o,rt))}try{if(nt=dt,(rt==null?void 0:rt.skipEncryption)!==!0){(mt=rt==null?void 0:rt.onProgress)==null||mt.call(rt,new CustomProgressEvent(`upgrader:encrypt-${tt}-connection`)),{conn:nt,remotePeer:ot,protocol:at}=await(tt==="inbound"?this._encryptInbound(dt,{...rt,signal:lt}):this._encryptOutbound(dt,{...rt,signal:lt}));const pt={...dt,...nt};await this.shouldBlockConnection(tt==="inbound"?"denyInboundEncryptedConnection":"denyOutboundEncryptedConnection",ot,pt)}else{const pt=o.remoteAddr.getPeerId();if(pt==null)throw new InvalidMultiaddrError(`${tt} connection that skipped encryption must have a peer id`);const gt=peerIdFromString$1(pt);at="native",ot=gt}if(ot.equals(this.components.peerId)){const pt=new InvalidPeerIdError("Can not dial self");throw o.abort(pt),pt}if(it=nt,(rt==null?void 0:rt.muxerFactory)!=null)st=rt.muxerFactory;else if(this.streamMuxers.size>0){(ft=rt==null?void 0:rt.onProgress)==null||ft.call(rt,new CustomProgressEvent(`upgrader:multiplex-${tt}-connection`));const pt=await(tt==="inbound"?this._multiplexInbound({...dt,...nt},this.streamMuxers,rt):this._multiplexOutbound({...dt,...nt},this.streamMuxers,rt));st=pt.muxerFactory,it=pt.stream}}catch(pt){throw o.log.error("failed to upgrade inbound connection %s %a - %e",tt==="inbound"?"from":"to",o.remoteAddr,pt),pt}finally{lt.clear()}return await this.shouldBlockConnection(tt==="inbound"?"denyInboundUpgradedConnection":"denyOutboundUpgradedConnection",ot,o),o.log("successfully upgraded %s connection",tt),this._createConnection({cryptoProtocol:at,direction:tt,maConn:o,upgradedConn:it,muxerFactory:st,remotePeer:ot,limits:rt==null?void 0:rt.limits})}_createConnection(o){const{cryptoProtocol:tt,direction:rt,maConn:nt,upgradedConn:ot,remotePeer:it,muxerFactory:st,limits:at}=o;let ct,lt,dt;st!=null&&(ct=st.createStreamMuxer({direction:rt,onIncomingStream:ft=>{dt!=null&&Promise.resolve().then(async()=>{var Et;const pt=this.components.registrar.getProtocols(),gt=AbortSignal.timeout(this.inboundStreamProtocolNegotiationTimeout);setMaxListeners(1/0,gt);const{stream:yt,protocol:bt}=await handle(ft,pt,{signal:gt,log:ft.log,yieldBytes:!1});if(dt==null)return;dt.log("incoming stream opened on %s",bt);const xt=findIncomingStreamLimit(bt,this.components.registrar);if(countStreams(bt,"inbound",dt)===xt){const Ct=new TooManyInboundProtocolStreamsError(`Too many inbound protocol streams for protocol "${bt}" - limit ${xt}`);throw ft.abort(Ct),Ct}ft.source=yt.source,ft.sink=yt.sink,ft.protocol=bt,yt.closeWrite!=null&&(ft.closeWrite=yt.closeWrite),yt.closeRead!=null&&(ft.closeRead=yt.closeRead),yt.close!=null&&(ft.close=yt.close),await this.components.peerStore.merge(it,{protocols:[bt]}),(Et=this.components.metrics)==null||Et.trackProtocolStream(ft,dt),this._onStream({connection:dt,stream:ft,protocol:bt})}).catch(async pt=>{dt.log.error("error handling incoming stream id %s - %e",ft.id,pt),ft.timeline.close==null&&await ft.close()})}}),lt=async(ft,pt={})=>{var yt;if(ct==null)throw new MuxerUnavailableError("Connection is not multiplexed");dt.log.trace("starting new stream for protocols %s",ft);const gt=await ct.newStream();dt.log.trace("started new stream %s for protocols %s",gt.id,ft);try{if(pt.signal==null){gt.log("no abort signal was passed while trying to negotiate protocols %s falling back to default timeout",ft);const Ct=AbortSignal.timeout(this.outboundStreamProtocolNegotiationTimeout);setMaxListeners(1/0,Ct),pt={...pt,signal:Ct}}gt.log.trace("selecting protocol from protocols %s",ft);const{stream:bt,protocol:xt}=await select(gt,ft,{...pt,log:gt.log,yieldBytes:!0});gt.log.trace("selected protocol %s",xt);const vt=findOutgoingStreamLimit(xt,this.components.registrar,pt),Et=countStreams(xt,"outbound",dt);if(Et>=vt){const Ct=new TooManyOutboundProtocolStreamsError(`Too many outbound protocol streams for protocol "${xt}" - ${Et}/${vt}`);throw gt.abort(Ct),Ct}return await this.components.peerStore.merge(it,{protocols:[xt]}),gt.source=bt.source,gt.sink=bt.sink,gt.protocol=xt,bt.closeWrite!=null&&(gt.closeWrite=bt.closeWrite),bt.closeRead!=null&&(gt.closeRead=bt.closeRead),bt.close!=null&&(gt.close=bt.close),(yt=this.components.metrics)==null||yt.trackProtocolStream(gt,dt),gt}catch(bt){throw dt.log.error("could not create new outbound stream on connection %s %a for protocols %s - %e",rt==="inbound"?"from":"to",o.maConn.remoteAddr,ft,bt),gt.timeline.close==null&>.abort(bt),bt}},Promise.all([ct.sink(ot.source),ot.sink(ct.source)]).catch(ft=>{dt.log.error("error piping data through muxer - %e",ft)}));const ht=nt.timeline;nt.timeline=new Proxy(ht,{set:(...ft)=>(ft[1]==="close"&&ft[2]!=null&&ht.close==null&&(async()=>{try{dt.status==="open"&&await dt.close()}catch(pt){dt.log.error("error closing connection after timeline close %e",pt)}finally{this.events.safeDispatchEvent("connection:close",{detail:dt})}})().catch(pt=>{dt.log.error("error thrown while dispatching connection:close event %e",pt)}),Reflect.set(...ft))}),nt.timeline.upgraded=Date.now();const mt=()=>{throw new MuxerUnavailableError("Connection is not multiplexed")};return dt=createConnection({remoteAddr:nt.remoteAddr,remotePeer:it,status:"open",direction:rt,timeline:nt.timeline,multiplexer:ct==null?void 0:ct.protocol,encryption:tt,limits:at,logger:this.components.logger,newStream:lt??mt,getStreams:()=>(ct==null?void 0:ct.streams)??[],close:async ft=>{await(ct==null?void 0:ct.close(ft)),await nt.close(ft)},abort:ft=>{nt.abort(ft),ct==null||ct.abort(ft)}}),this.events.safeDispatchEvent("connection:open",{detail:dt}),dt.__maConnTimeline=ht,dt}_onStream(o){const{connection:tt,stream:rt,protocol:nt}=o,{handler:ot,options:it}=this.components.registrar.getHandler(nt);if(tt.limits!=null&&it.runOnLimitedConnection!==!0)throw new LimitedConnectionError("Cannot open protocol stream on limited connection");ot({connection:tt,stream:rt})}async _encryptInbound(o,tt){const rt=Array.from(this.connectionEncrypters.keys());try{const{stream:nt,protocol:ot}=await handle(o,rt,{...tt,log:o.log}),it=this.connectionEncrypters.get(ot);if(it==null)throw new EncryptionFailedError(`no crypto module found for ${ot}`);return o.log("encrypting inbound connection to %a using %s",o.remoteAddr,ot),{...await it.secureInbound(nt,tt),protocol:ot}}catch(nt){throw o.log.error("encrypting inbound connection from %a failed",o.remoteAddr,nt),new EncryptionFailedError(nt.message)}}async _encryptOutbound(o,tt){const rt=Array.from(this.connectionEncrypters.keys());try{o.log.trace("selecting encrypter from %s",rt);const{stream:nt,protocol:ot}=await select(o,rt,{...tt,log:o.log,yieldBytes:!0}),it=this.connectionEncrypters.get(ot);if(it==null)throw new EncryptionFailedError(`no crypto module found for ${ot}`);return o.log("encrypting outbound connection to %a using %s",o.remoteAddr,ot),{...await it.secureOutbound(nt,tt),protocol:ot}}catch(nt){throw o.log.error("encrypting outbound connection to %a failed",o.remoteAddr,nt),new EncryptionFailedError(nt.message)}}async _multiplexOutbound(o,tt,rt){const nt=Array.from(tt.keys());o.log("outbound selecting muxer %s",nt);try{o.log.trace("selecting stream muxer from %s",nt);const{stream:ot,protocol:it}=await select(o,nt,{...rt,log:o.log,yieldBytes:!0});o.log("selected %s as muxer protocol",it);const st=tt.get(it);return{stream:ot,muxerFactory:st}}catch(ot){throw o.log.error("error multiplexing outbound connection",ot),new MuxerUnavailableError(String(ot))}}async _multiplexInbound(o,tt,rt){const nt=Array.from(tt.keys());o.log("inbound handling muxers %s",nt);try{const{stream:ot,protocol:it}=await handle(o,nt,{...rt,log:o.log}),st=tt.get(it);return{stream:ot,muxerFactory:st}}catch(ot){throw o.log.error("error multiplexing inbound connection",ot),new MuxerUnavailableError(String(ot))}}}const version$3="2.1.8",name$2="libp2p";var go,Bs;class Libp2p extends TypedEventEmitter{constructor(tt){var at,ct,lt,dt,ht,mt;super();hr(this,go);wt(this,"peerId");wt(this,"peerStore");wt(this,"contentRouting");wt(this,"peerRouting");wt(this,"metrics");wt(this,"services");wt(this,"logger");wt(this,"status");wt(this,"components");wt(this,"log");this.status="stopped";const rt=new TypedEventEmitter,nt=rt.dispatchEvent.bind(rt);rt.dispatchEvent=ft=>{const pt=nt(ft),gt=this.dispatchEvent(new CustomEvent(ft.type,{detail:ft.detail}));return pt||gt},setMaxListeners(1/0,rt),this.peerId=tt.peerId,this.logger=tt.logger??defaultLogger(),this.log=this.logger.forComponent("libp2p"),this.services={};const ot=this.components=defaultComponents({peerId:tt.peerId,privateKey:tt.privateKey,nodeInfo:tt.nodeInfo??{name:name$2,version:version$3},logger:this.logger,events:rt,datastore:tt.datastore??new MemoryDatastore,connectionGater:connectionGater(tt.connectionGater),dns:tt.dns});this.peerStore=this.configureComponent("peerStore",persistentPeerStore(ot,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...tt.peerStore})),tt.metrics!=null&&(this.metrics=this.configureComponent("metrics",tt.metrics(this.components))),ot.events.addEventListener("peer:update",ft=>{if(ft.detail.previous==null){const pt={id:ft.detail.peer.id,multiaddrs:ft.detail.peer.addresses.map(gt=>gt.multiaddr)};ot.events.safeDispatchEvent("peer:discovery",{detail:pt})}}),tt.connectionProtector!=null&&this.configureComponent("connectionProtector",tt.connectionProtector(ot)),this.components.upgrader=new DefaultUpgrader(this.components,{connectionEncrypters:(tt.connectionEncrypters??[]).map((ft,pt)=>this.configureComponent(`connection-encryption-${pt}`,ft(this.components))),streamMuxers:(tt.streamMuxers??[]).map((ft,pt)=>this.configureComponent(`stream-muxers-${pt}`,ft(this.components))),inboundUpgradeTimeout:(at=tt.connectionManager)==null?void 0:at.inboundUpgradeTimeout,outboundUpgradeTimeout:(ct=tt.connectionManager)==null?void 0:ct.outboundUpgradeTimeout}),this.configureComponent("transportManager",new DefaultTransportManager(this.components,tt.transportManager)),this.configureComponent("connectionManager",new DefaultConnectionManager(this.components,tt.connectionManager)),((lt=tt.connectionMonitor)==null?void 0:lt.enabled)!==!1&&this.configureComponent("connectionMonitor",new ConnectionMonitor(this.components,tt.connectionMonitor)),this.configureComponent("registrar",new DefaultRegistrar(this.components)),this.configureComponent("addressManager",new DefaultAddressManager(this.components,tt.addresses));const it=(tt.peerRouters??[]).map((ft,pt)=>this.configureComponent(`peer-router-${pt}`,ft(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new DefaultPeerRouting(this.components,{routers:it}));const st=(tt.contentRouters??[]).map((ft,pt)=>this.configureComponent(`content-router-${pt}`,ft(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new CompoundContentRouting(this.components,{routers:st})),this.configureComponent("randomWalk",new RandomWalk(this.components)),(tt.peerDiscovery??[]).forEach((ft,pt)=>{this.configureComponent(`peer-discovery-${pt}`,ft(this.components)).addEventListener("peer",yt=>{fr(this,go,Bs).call(this,yt)})}),(dt=tt.transports)==null||dt.forEach((ft,pt)=>{this.components.transportManager.add(this.configureComponent(`transport-${pt}`,ft(this.components)))}),tt.services!=null)for(const ft of Object.keys(tt.services)){const pt=tt.services[ft],gt=pt(this.components);if(gt==null){this.log.error("service factory %s returned null or undefined instance",ft);continue}this.services[ft]=gt,this.configureComponent(ft,gt),gt[contentRoutingSymbol]!=null&&(this.log("registering service %s for content routing",ft),st.push(gt[contentRoutingSymbol])),gt[peerRoutingSymbol]!=null&&(this.log("registering service %s for peer routing",ft),it.push(gt[peerRoutingSymbol])),gt[peerDiscoverySymbol]!=null&&(this.log("registering service %s for peer discovery",ft),(mt=(ht=gt[peerDiscoverySymbol]).addEventListener)==null||mt.call(ht,"peer",yt=>{fr(this,go,Bs).call(this,yt)}))}checkServiceDependencies(ot)}configureComponent(tt,rt){return rt==null&&this.log.error("component %s was null or undefined",tt),this.components[tt]=rt,rt}async start(){var tt,rt,nt,ot;if(this.status==="stopped"){this.status="starting",this.log("libp2p is starting");try{await((rt=(tt=this.components).beforeStart)==null?void 0:rt.call(tt)),await this.components.start(),await((ot=(nt=this.components).afterStart)==null?void 0:ot.call(nt)),this.status="started",this.safeDispatchEvent("start",{detail:this}),this.log("libp2p has started")}catch(it){throw this.log.error("An error occurred starting libp2p",it),this.status="started",await this.stop(),it}}}async stop(){var tt,rt,nt,ot;this.status==="started"&&(this.log("libp2p is stopping"),this.status="stopping",await((rt=(tt=this.components).beforeStop)==null?void 0:rt.call(tt)),await this.components.stop(),await((ot=(nt=this.components).afterStop)==null?void 0:ot.call(nt)),this.status="stopped",this.safeDispatchEvent("stop",{detail:this}),this.log("libp2p has stopped"))}getConnections(tt){return this.components.connectionManager.getConnections(tt)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){const tt=new PeerSet;for(const rt of this.components.connectionManager.getConnections())tt.add(rt.remotePeer);return Array.from(tt)}async dial(tt,rt={}){return this.components.connectionManager.openConnection(tt,{priority:75,...rt})}async dialProtocol(tt,rt,nt={}){if(rt==null)throw new InvalidParametersError$1("no protocols were provided to open a stream");if(rt=Array.isArray(rt)?rt:[rt],rt.length===0)throw new InvalidParametersError$1("no protocols were provided to open a stream");return(await this.dial(tt,nt)).newStream(rt,nt)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(tt,rt={}){isMultiaddr(tt)&&(tt=peerIdFromString$1(tt.getPeerId()??"")),await this.components.connectionManager.closeConnections(tt,rt)}async getPublicKey(tt,rt={}){if(this.log("getPublicKey %p",tt),tt.publicKey!=null)return tt.publicKey;try{const st=await this.peerStore.get(tt);if(st.id.publicKey!=null)return st.id.publicKey}catch(st){if(st.name!=="NotFoundError")throw st}const nt=concat([fromString$6("/pk/"),tt.toMultihash().bytes]),ot=await this.contentRouting.get(nt,rt),it=publicKeyFromProtobuf(ot);return await this.peerStore.patch(tt,{publicKey:it}),it}async handle(tt,rt,nt){Array.isArray(tt)||(tt=[tt]),await Promise.all(tt.map(async ot=>{await this.components.registrar.handle(ot,rt,nt)}))}async unhandle(tt){Array.isArray(tt)||(tt=[tt]),await Promise.all(tt.map(async rt=>{await this.components.registrar.unhandle(rt)}))}async register(tt,rt){return this.components.registrar.register(tt,rt)}unregister(tt){this.components.registrar.unregister(tt)}async isDialable(tt,rt={}){return this.components.connectionManager.isDialable(tt,rt)}}go=new WeakSet,Bs=function(tt){const{detail:rt}=tt;if(rt.id.toString()===this.peerId.toString()){this.log.error("peer discovery mechanism discovered self");return}this.components.peerStore.merge(rt.id,{multiaddrs:rt.multiaddrs}).catch(nt=>{this.log.error(nt)})};async function createLibp2p(et={}){et.privateKey??(et.privateKey=await generateKeyPair());const o=new Libp2p({...await validateConfig(et),peerId:peerIdFromPrivateKey(et.privateKey)});return et.start!==!1&&await o.start(),o}const enrTree={SANDBOX:"enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im",TEST:"enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im"},DEFAULT_BOOTSTRAP_TAG_NAME="bootstrap",DEFAULT_BOOTSTRAP_TAG_VALUE=50,DEFAULT_BOOTSTRAP_TAG_TTL=1e8,DEFAULT_NODE_REQUIREMENTS={store:1,filter:2,lightPush:2},ERR_INVALID_ID="Invalid record id",MULTIADDR_LENGTH_SIZE=2,__viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"}));/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const _0n=BigInt(0),_1n=BigInt(1),_2n=BigInt(2),_3n=BigInt(3),_8n=BigInt(8),CURVE=Object.freeze({a:_0n,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:_1n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),divNearest=(et,o)=>(et+o/_2n)/o,endo={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(et){const{n:o}=CURVE,tt=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),rt=-_1n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),nt=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),ot=tt,it=BigInt("0x100000000000000000000000000000000"),st=divNearest(ot*et,o),at=divNearest(-rt*et,o);let ct=mod(et-st*tt-at*nt,o),lt=mod(-st*rt-at*ot,o);const dt=ct>it,ht=lt>it;if(dt&&(ct=o-ct),ht&&(lt=o-lt),ct>it||lt>it)throw new Error("splitScalarEndo: Endomorphism failed, k="+et);return{k1neg:dt,k1:ct,k2neg:ht,k2:lt}}},fieldLen=32,groupLen=32,hashLen=32,compressedLen=fieldLen+1,uncompressedLen=2*fieldLen+1;function weierstrass(et){const{a:o,b:tt}=CURVE,rt=mod(et*et),nt=mod(rt*et);return mod(nt+o*et+tt)}const USE_ENDOMORPHISM=CURVE.a===_0n;class ShaError extends Error{constructor(o){super(o)}}function assertJacPoint(et){if(!(et instanceof JacobianPoint))throw new TypeError("JacobianPoint expected")}class JacobianPoint{constructor(o,tt,rt){this.x=o,this.y=tt,this.z=rt}static fromAffine(o){if(!(o instanceof Point))throw new TypeError("JacobianPoint#fromAffine: expected Point");return o.equals(Point.ZERO)?JacobianPoint.ZERO:new JacobianPoint(o.x,o.y,_1n)}static toAffineBatch(o){const tt=invertBatch(o.map(rt=>rt.z));return o.map((rt,nt)=>rt.toAffine(tt[nt]))}static normalizeZ(o){return JacobianPoint.toAffineBatch(o).map(JacobianPoint.fromAffine)}equals(o){assertJacPoint(o);const{x:tt,y:rt,z:nt}=this,{x:ot,y:it,z:st}=o,at=mod(nt*nt),ct=mod(st*st),lt=mod(tt*ct),dt=mod(ot*at),ht=mod(mod(rt*st)*ct),mt=mod(mod(it*nt)*at);return lt===dt&&ht===mt}negate(){return new JacobianPoint(this.x,mod(-this.y),this.z)}double(){const{x:o,y:tt,z:rt}=this,nt=mod(o*o),ot=mod(tt*tt),it=mod(ot*ot),st=o+ot,at=mod(_2n*(mod(st*st)-nt-it)),ct=mod(_3n*nt),lt=mod(ct*ct),dt=mod(lt-_2n*at),ht=mod(ct*(at-dt)-_8n*it),mt=mod(_2n*tt*rt);return new JacobianPoint(dt,ht,mt)}add(o){assertJacPoint(o);const{x:tt,y:rt,z:nt}=this,{x:ot,y:it,z:st}=o;if(ot===_0n||it===_0n)return this;if(tt===_0n||rt===_0n)return o;const at=mod(nt*nt),ct=mod(st*st),lt=mod(tt*ct),dt=mod(ot*at),ht=mod(mod(rt*st)*ct),mt=mod(mod(it*nt)*at),ft=mod(dt-lt),pt=mod(mt-ht);if(ft===_0n)return pt===_0n?this.double():JacobianPoint.ZERO;const gt=mod(ft*ft),yt=mod(ft*gt),bt=mod(lt*gt),xt=mod(pt*pt-yt-_2n*bt),vt=mod(pt*(bt-xt)-ht*yt),Et=mod(nt*st*ft);return new JacobianPoint(xt,vt,Et)}subtract(o){return this.add(o.negate())}multiplyUnsafe(o){const tt=JacobianPoint.ZERO;if(typeof o=="bigint"&&o===_0n)return tt;let rt=normalizeScalar(o);if(rt===_1n)return this;if(!USE_ENDOMORPHISM){let dt=tt,ht=this;for(;rt>_0n;)rt&_1n&&(dt=dt.add(ht)),ht=ht.double(),rt>>=_1n;return dt}let{k1neg:nt,k1:ot,k2neg:it,k2:st}=endo.splitScalar(rt),at=tt,ct=tt,lt=this;for(;ot>_0n||st>_0n;)ot&_1n&&(at=at.add(lt)),st&_1n&&(ct=ct.add(lt)),lt=lt.double(),ot>>=_1n,st>>=_1n;return nt&&(at=at.negate()),it&&(ct=ct.negate()),ct=new JacobianPoint(mod(ct.x*endo.beta),ct.y,ct.z),at.add(ct)}precomputeWindow(o){const tt=USE_ENDOMORPHISM?128/o+1:256/o+1,rt=[];let nt=this,ot=nt;for(let it=0;it>=dt,ft>at&&(ft-=lt,o+=_1n);const pt=mt,gt=mt+Math.abs(ft)-1,yt=ht%2!==0,bt=ft<0;ft===0?it=it.add(constTimeNegate(yt,nt[pt])):ot=ot.add(constTimeNegate(bt,nt[gt]))}return{p:ot,f:it}}multiply(o,tt){let rt=normalizeScalar(o),nt,ot;if(USE_ENDOMORPHISM){const{k1neg:it,k1:st,k2neg:at,k2:ct}=endo.splitScalar(rt);let{p:lt,f:dt}=this.wNAF(st,tt),{p:ht,f:mt}=this.wNAF(ct,tt);lt=constTimeNegate(it,lt),ht=constTimeNegate(at,ht),ht=new JacobianPoint(mod(ht.x*endo.beta),ht.y,ht.z),nt=lt.add(ht),ot=dt.add(mt)}else{const{p:it,f:st}=this.wNAF(rt,tt);nt=it,ot=st}return JacobianPoint.normalizeZ([nt,ot])[0]}toAffine(o){const{x:tt,y:rt,z:nt}=this,ot=this.equals(JacobianPoint.ZERO);o==null&&(o=ot?_8n:invert(nt));const it=o,st=mod(it*it),at=mod(st*it),ct=mod(tt*st),lt=mod(rt*at),dt=mod(nt*it);if(ot)return Point.ZERO;if(dt!==_1n)throw new Error("invZ was invalid");return new Point(ct,lt)}}JacobianPoint.BASE=new JacobianPoint(CURVE.Gx,CURVE.Gy,_1n);JacobianPoint.ZERO=new JacobianPoint(_0n,_1n,_0n);function constTimeNegate(et,o){const tt=o.negate();return et?tt:o}const pointPrecomputes=new WeakMap;class Point{constructor(o,tt){this.x=o,this.y=tt}_setWindowSize(o){this._WINDOW_SIZE=o,pointPrecomputes.delete(this)}hasEvenY(){return this.y%_2n===_0n}static fromCompressedHex(o){const tt=o.length===32,rt=bytesToNumber(tt?o:o.subarray(1));if(!isValidFieldElement(rt))throw new Error("Point is not on curve");const nt=weierstrass(rt);let ot=sqrtMod(nt);const it=(ot&_1n)===_1n;tt?it&&(ot=mod(-ot)):(o[0]&1)===1!==it&&(ot=mod(-ot));const st=new Point(rt,ot);return st.assertValidity(),st}static fromUncompressedHex(o){const tt=bytesToNumber(o.subarray(1,fieldLen+1)),rt=bytesToNumber(o.subarray(fieldLen+1,fieldLen*2+1)),nt=new Point(tt,rt);return nt.assertValidity(),nt}static fromHex(o){const tt=ensureBytes(o),rt=tt.length,nt=tt[0];if(rt===fieldLen)return this.fromCompressedHex(tt);if(rt===compressedLen&&(nt===2||nt===3))return this.fromCompressedHex(tt);if(rt===uncompressedLen&&nt===4)return this.fromUncompressedHex(tt);throw new Error(`Point.fromHex: received invalid point. Expected 32-${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes, not ${rt}`)}static fromPrivateKey(o){return Point.BASE.multiply(normalizePrivateKey(o))}static fromSignature(o,tt,rt){const{r:nt,s:ot}=normalizeSignature(tt);if(![0,1,2,3].includes(rt))throw new Error("Cannot recover: invalid recovery bit");const it=truncateHash(ensureBytes(o)),{n:st}=CURVE,at=rt===2||rt===3?nt+st:nt,ct=invert(at,st),lt=mod(-it*ct,st),dt=mod(ot*ct,st),ht=rt&1?"03":"02",mt=Point.fromHex(ht+numTo32bStr(at)),ft=Point.BASE.multiplyAndAddUnsafe(mt,lt,dt);if(!ft)throw new Error("Cannot recover signature: point at infinify");return ft.assertValidity(),ft}toRawBytes(o=!1){return hexToBytes(this.toHex(o))}toHex(o=!1){const tt=numTo32bStr(this.x);return o?`${this.hasEvenY()?"02":"03"}${tt}`:`04${tt}${numTo32bStr(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const o="Point is not on elliptic curve",{x:tt,y:rt}=this;if(!isValidFieldElement(tt)||!isValidFieldElement(rt))throw new Error(o);const nt=mod(rt*rt),ot=weierstrass(tt);if(mod(nt-ot)!==_0n)throw new Error(o)}equals(o){return this.x===o.x&&this.y===o.y}negate(){return new Point(this.x,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,tt,rt){const nt=JacobianPoint.fromAffine(this),ot=tt===_0n||tt===_1n||this!==Point.BASE?nt.multiplyUnsafe(tt):nt.multiply(tt),it=JacobianPoint.fromAffine(o).multiplyUnsafe(rt),st=ot.add(it);return st.equals(JacobianPoint.ZERO)?void 0:st.toAffine()}}Point.BASE=new Point(CURVE.Gx,CURVE.Gy);Point.ZERO=new Point(_0n,_0n);function sliceDER(et){return Number.parseInt(et[0],16)>=8?"00"+et:et}function parseDERInt(et){if(et.length<2||et[0]!==2)throw new Error(`Invalid signature integer tag: ${bytesToHex(et)}`);const o=et[1],tt=et.subarray(2,o+2);if(!o||tt.length!==o)throw new Error("Invalid signature integer: wrong length");if(tt[0]===0&&tt[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:bytesToNumber(tt),left:et.subarray(o+2)}}function parseDERSignature(et){if(et.length<2||et[0]!=48)throw new Error(`Invalid signature tag: ${bytesToHex(et)}`);if(et[1]!==et.length-2)throw new Error("Invalid signature: incorrect length");const{data:o,left:tt}=parseDERInt(et.subarray(2)),{data:rt,left:nt}=parseDERInt(tt);if(nt.length)throw new Error(`Invalid signature: left bytes after parsing: ${bytesToHex(nt)}`);return{r:o,s:rt}}class Signature{constructor(o,tt){this.r=o,this.s=tt,this.assertValidity()}static fromCompact(o){const tt=o instanceof Uint8Array,rt="Signature.fromCompact";if(typeof o!="string"&&!tt)throw new TypeError(`${rt}: Expected string or Uint8Array`);const nt=tt?bytesToHex(o):o;if(nt.length!==128)throw new Error(`${rt}: Expected 64-byte hex`);return new Signature(hexToNumber(nt.slice(0,64)),hexToNumber(nt.slice(64,128)))}static fromDER(o){const tt=o instanceof Uint8Array;if(typeof o!="string"&&!tt)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:rt,s:nt}=parseDERSignature(tt?o:hexToBytes(o));return new Signature(rt,nt)}static fromHex(o){return this.fromDER(o)}assertValidity(){const{r:o,s:tt}=this;if(!isWithinCurveOrder(o))throw new Error("Invalid Signature: r must be 0 < r < n");if(!isWithinCurveOrder(tt))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const o=CURVE.n>>_1n;return this.s>o}normalizeS(){return this.hasHighS()?new Signature(this.r,mod(-this.s,CURVE.n)):this}toDERRawBytes(){return hexToBytes(this.toDERHex())}toDERHex(){const o=sliceDER(numberToHexUnpadded(this.s)),tt=sliceDER(numberToHexUnpadded(this.r)),rt=o.length/2,nt=tt.length/2,ot=numberToHexUnpadded(rt),it=numberToHexUnpadded(nt);return`30${numberToHexUnpadded(nt+rt+4)}02${it}${tt}02${ot}${o}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return hexToBytes(this.toCompactHex())}toCompactHex(){return numTo32bStr(this.r)+numTo32bStr(this.s)}}function concatBytes(...et){if(!et.every(rt=>rt instanceof Uint8Array))throw new Error("Uint8Array list expected");if(et.length===1)return et[0];const o=et.reduce((rt,nt)=>rt+nt.length,0),tt=new Uint8Array(o);for(let rt=0,nt=0;rto.toString(16).padStart(2,"0"));function bytesToHex(et){if(!(et instanceof Uint8Array))throw new Error("Expected Uint8Array");let o="";for(let tt=0;tt0)return BigInt(et);if(typeof et=="bigint"&&isWithinCurveOrder(et))return et;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function mod(et,o=CURVE.P){const tt=et%o;return tt>=_0n?tt:o+tt}function pow2(et,o){const{P:tt}=CURVE;let rt=et;for(;o-- >_0n;)rt*=rt,rt%=tt;return rt}function sqrtMod(et){const{P:o}=CURVE,tt=BigInt(6),rt=BigInt(11),nt=BigInt(22),ot=BigInt(23),it=BigInt(44),st=BigInt(88),at=et*et*et%o,ct=at*at*et%o,lt=pow2(ct,_3n)*ct%o,dt=pow2(lt,_3n)*ct%o,ht=pow2(dt,_2n)*at%o,mt=pow2(ht,rt)*ht%o,ft=pow2(mt,nt)*mt%o,pt=pow2(ft,it)*ft%o,gt=pow2(pt,st)*pt%o,yt=pow2(gt,it)*ft%o,bt=pow2(yt,_3n)*ct%o,xt=pow2(bt,ot)*mt%o,vt=pow2(xt,tt)*at%o,Et=pow2(vt,_2n);if(Et*Et%o!==et)throw new Error("Cannot find square root");return Et}function invert(et,o=CURVE.P){if(et===_0n||o<=_0n)throw new Error(`invert: expected positive integers, got n=${et} mod=${o}`);let tt=mod(et,o),rt=o,nt=_0n,ot=_1n;for(;tt!==_0n;){const st=rt/tt,at=rt%tt,ct=nt-ot*st;rt=tt,tt=at,nt=ot,ot=ct}if(rt!==_1n)throw new Error("invert: does not exist");return mod(nt,o)}function invertBatch(et,o=CURVE.P){const tt=new Array(et.length),rt=et.reduce((ot,it,st)=>it===_0n?ot:(tt[st]=ot,mod(ot*it,o)),_1n),nt=invert(rt,o);return et.reduceRight((ot,it,st)=>it===_0n?ot:(tt[st]=mod(ot*tt[st],o),mod(ot*it,o)),nt),tt}function bits2int_2(et){const o=et.length*8-groupLen*8,tt=bytesToNumber(et);return o>0?tt>>BigInt(o):tt}function truncateHash(et,o=!1){const tt=bits2int_2(et);if(o)return tt;const{n:rt}=CURVE;return tt>=rt?tt-rt:tt}let _sha256Sync,_hmacSha256Sync;class HmacDrbg{constructor(o,tt){if(this.hashLen=o,this.qByteLen=tt,typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof tt!="number"||tt<2)throw new 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 utils.hmacSha256(this.k,...o)}hmacSync(...o){return _hmacSha256Sync(this.k,...o)}checkSync(){if(typeof _hmacSha256Sync!="function")throw new ShaError("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new 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),o.length!==0&&(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),o.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),o),this.v=this.hmacSync(this.v))}async generate(){this.incr();let o=0;const tt=[];for(;o0)o=BigInt(et);else if(typeof et=="string"){if(et.length!==2*groupLen)throw new Error("Expected 32 bytes of private key");o=hexToNumber(et)}else if(et instanceof Uint8Array){if(et.length!==groupLen)throw new Error("Expected 32 bytes of private key");o=bytesToNumber(et)}else throw new TypeError("Expected valid private key");if(!isWithinCurveOrder(o))throw new Error("Expected private key: 0 < key < n");return o}function normalizePublicKey(et){return et instanceof Point?(et.assertValidity(),et):Point.fromHex(et)}function normalizeSignature(et){if(et instanceof Signature)return et.assertValidity(),et;try{return Signature.fromDER(et)}catch{return Signature.fromCompact(et)}}function bits2int(et){const o=et.length>fieldLen?et.slice(0,fieldLen):et;return bytesToNumber(o)}function bits2octets(et){const o=bits2int(et),tt=mod(o,CURVE.n);return int2octets(tt<_0n?o:tt)}function int2octets(et){return numTo32b(et)}function initSigArgs(et,o,tt){if(et==null)throw new Error(`sign: expected valid message hash, not "${et}"`);const rt=ensureBytes(et),nt=normalizePrivateKey(o),ot=[int2octets(nt),bits2octets(rt)];if(tt!=null){tt===!0&&(tt=utils.randomBytes(fieldLen));const at=ensureBytes(tt);if(at.length!==fieldLen)throw new Error(`sign: Expected ${fieldLen} bytes of extra data`);ot.push(at)}const it=concatBytes(...ot),st=bits2int(rt);return{seed:it,m:st,d:nt}}function finalizeSig(et,o){const{sig:tt,recovery:rt}=et,{der:nt,recovered:ot}=Object.assign({canonical:!0,der:!0},o),it=nt?tt.toDERRawBytes():tt.toCompactRawBytes();return ot?[it,rt]:it}async function sign$1(et,o,tt={}){const{seed:rt,m:nt,d:ot}=initSigArgs(et,o,tt.extraEntropy),it=new HmacDrbg(hashLen,groupLen);await it.reseed(rt);let st;for(;!(st=kmdToSig(await it.generate(),nt,ot,tt.canonical));)await it.reseed();return finalizeSig(st,tt)}const vopts={strict:!0};function verify(et,o,tt,rt=vopts){let nt;try{nt=normalizeSignature(et),o=ensureBytes(o)}catch{return!1}const{r:ot,s:it}=nt;if(rt.strict&&nt.hasHighS())return!1;const st=truncateHash(o);let at;try{at=normalizePublicKey(tt)}catch{return!1}const{n:ct}=CURVE,lt=invert(it,ct),dt=mod(st*lt,ct),ht=mod(ot*lt,ct),mt=Point.BASE.multiplyAndAddUnsafe(at,dt,ht);return mt?mod(mt.x,ct)===ot:!1}Point.BASE._setWindowSize(8);const crypto$1={node:__viteBrowserExternal$1,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},TAGGED_HASH_PREFIXES={},utils={bytesToHex,hexToBytes,concatBytes,mod,invert,isValidPrivateKey(et){try{return normalizePrivateKey(et),!0}catch{return!1}},_bigintTo32Bytes:numTo32b,_normalizePrivateKey:normalizePrivateKey,hashToPrivateKey:et=>{et=ensureBytes(et);const o=groupLen+8;if(et.length1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const tt=mod(bytesToNumber(et),CURVE.n-_1n)+_1n;return numTo32b(tt)},randomBytes:(et=32)=>{if(crypto$1.web)return crypto$1.web.getRandomValues(new Uint8Array(et));if(crypto$1.node){const{randomBytes:o}=crypto$1.node;return Uint8Array.from(o(et))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>utils.hashToPrivateKey(utils.randomBytes(groupLen+8)),precompute(et=8,o=Point.BASE){const tt=o===Point.BASE?o:new Point(o.x,o.y);return tt._setWindowSize(et),tt.multiply(_3n),tt},sha256:async(...et)=>{if(crypto$1.web){const o=await crypto$1.web.subtle.digest("SHA-256",concatBytes(...et));return new Uint8Array(o)}else if(crypto$1.node){const{createHash:o}=crypto$1.node,tt=o("sha256");return et.forEach(rt=>tt.update(rt)),Uint8Array.from(tt.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(et,...o)=>{if(crypto$1.web){const tt=await crypto$1.web.subtle.importKey("raw",et,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),rt=concatBytes(...o),nt=await crypto$1.web.subtle.sign("HMAC",tt,rt);return new Uint8Array(nt)}else if(crypto$1.node){const{createHmac:tt}=crypto$1.node,rt=tt("sha256",et);return o.forEach(nt=>rt.update(nt)),Uint8Array.from(rt.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(et,...o)=>{let tt=TAGGED_HASH_PREFIXES[et];if(tt===void 0){const rt=await utils.sha256(Uint8Array.from(et,nt=>nt.charCodeAt(0)));tt=concatBytes(rt,rt),TAGGED_HASH_PREFIXES[et]=tt}return utils.sha256(tt,...o)},taggedHashSync:(et,...o)=>{if(typeof _sha256Sync!="function")throw new ShaError("sha256Sync is undefined, you need to set it");let tt=TAGGED_HASH_PREFIXES[et];if(tt===void 0){const rt=_sha256Sync(Uint8Array.from(et,nt=>nt.charCodeAt(0)));tt=concatBytes(rt,rt),TAGGED_HASH_PREFIXES[et]=tt}return _sha256Sync(tt,...o)},_JacobianPoint:JacobianPoint};Object.defineProperties(utils,{sha256Sync:{configurable:!1,get(){return _sha256Sync},set(et){_sha256Sync||(_sha256Sync=et)}},hmacSha256Sync:{configurable:!1,get(){return _hmacSha256Sync},set(et){_hmacSha256Sync||(_hmacSha256Sync=et)}}});var sha3$1={exports:{}};/** +`),tt),tt.log('handle: responded with "na" for "%s"',nt)}}const CLOSE_TIMEOUT=500;var Zl,Jl;Jl=Symbol.toStringTag,Zl=connectionSymbol;class ConnectionImpl{constructor(o){wt(this,"id");wt(this,"remoteAddr");wt(this,"remotePeer");wt(this,"direction");wt(this,"timeline");wt(this,"multiplexer");wt(this,"encryption");wt(this,"status");wt(this,"limits");wt(this,"log");wt(this,"tags");wt(this,"_newStream");wt(this,"_close");wt(this,"_abort");wt(this,"_getStreams");wt(this,Jl,"Connection");wt(this,Zl,!0);const{remoteAddr:tt,remotePeer:rt,newStream:nt,close:ot,abort:it,getStreams:st}=o;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=tt,this.remotePeer=rt,this.direction=o.direction,this.status="open",this.timeline=o.timeline,this.multiplexer=o.multiplexer,this.encryption=o.encryption,this.limits=o.limits,this.log=o.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`),this.remoteAddr.getPeerId()==null&&(this.remoteAddr=this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`)),this._newStream=nt,this._close=ot,this._abort=it,this._getStreams=st,this.tags=[]}get streams(){return this._getStreams()}async newStream(o,tt){if(this.status==="closing")throw new ConnectionClosingError("the connection is being closed");if(this.status==="closed")throw new ConnectionClosedError("the connection is closed");if(Array.isArray(o)||(o=[o]),this.limits!=null&&(tt==null?void 0:tt.runOnLimitedConnection)!==!0)throw new LimitedConnectionError("Cannot open protocol stream on limited connection");const rt=await this._newStream(o,tt);return rt.direction="outbound",rt}async close(o={}){if(!(this.status==="closed"||this.status==="closing")){if(this.log("closing connection to %a",this.remoteAddr),this.status="closing",o.signal==null){const tt=AbortSignal.timeout(CLOSE_TIMEOUT);setMaxListeners(1/0,tt),o={...o,signal:tt}}try{this.log.trace("closing underlying transport"),await this._close(o),this.log.trace("updating timeline with close time"),this.status="closed",this.timeline.close=Date.now()}catch(tt){this.log.error("error encountered during graceful close of connection to %a",this.remoteAddr,tt),this.abort(tt)}}}abort(o){this.status!=="closed"&&(this.log.error("aborting connection to %a due to error",this.remoteAddr,o),this.status="closing",this._abort(o),this.status="closed",this.timeline.close=Date.now())}}function createConnection(et){return new ConnectionImpl(et)}function findIncomingStreamLimit(et,o){try{const{options:tt}=o.getHandler(et);return tt.maxInboundStreams}catch(tt){if(tt.name!=="UnhandledProtocolError")throw tt}return DEFAULT_MAX_INBOUND_STREAMS}function findOutgoingStreamLimit(et,o,tt={}){try{const{options:rt}=o.getHandler(et);if(rt.maxOutboundStreams!=null)return rt.maxOutboundStreams}catch(rt){if(rt.name!=="UnhandledProtocolError")throw rt}return tt.maxOutboundStreams??DEFAULT_MAX_OUTBOUND_STREAMS}function countStreams(et,o,tt){let rt=0;return tt.streams.forEach(nt=>{nt.direction===o&&nt.protocol===et&&rt++}),rt}var eu;eu=Symbol.toStringTag;class DefaultUpgrader{constructor(o,tt){wt(this,"components");wt(this,"connectionEncrypters");wt(this,"streamMuxers");wt(this,"inboundUpgradeTimeout");wt(this,"outboundUpgradeTimeout");wt(this,"inboundStreamProtocolNegotiationTimeout");wt(this,"outboundStreamProtocolNegotiationTimeout");wt(this,"events");wt(this,"metrics");wt(this,eu,"@libp2p/upgrader");var rt,nt;this.components=o,this.connectionEncrypters=new Map,tt.connectionEncrypters.forEach(ot=>{this.connectionEncrypters.set(ot.protocol,ot)}),this.streamMuxers=new Map,tt.streamMuxers.forEach(ot=>{this.streamMuxers.set(ot.protocol,ot)}),this.inboundUpgradeTimeout=tt.inboundUpgradeTimeout??UPGRADE_TIMEOUT,this.outboundUpgradeTimeout=tt.outboundUpgradeTimeout??UPGRADE_TIMEOUT,this.inboundStreamProtocolNegotiationTimeout=tt.inboundStreamProtocolNegotiationTimeout??PROTOCOL_NEGOTIATION_TIMEOUT,this.outboundStreamProtocolNegotiationTimeout=tt.outboundStreamProtocolNegotiationTimeout??PROTOCOL_NEGOTIATION_TIMEOUT,this.events=o.events,this.metrics={dials:(rt=o.metrics)==null?void 0:rt.registerCounterGroup("libp2p_connection_manager_dials_total"),errors:(nt=o.metrics)==null?void 0:nt.registerCounterGroup("libp2p_connection_manager_dial_errors_total")}}async shouldBlockConnection(o,...tt){const rt=this.components.connectionGater[o];if(rt==null)return;if(await rt.apply(this.components.connectionGater,tt)===!0)throw new ConnectionInterceptedError(`The multiaddr connection is blocked by gater.${o}`)}async upgradeInbound(o,tt={}){var rt,nt;try{if((rt=this.metrics.dials)==null||rt.increment({inbound:!0}),!await this.components.connectionManager.acceptIncomingConnection(o))throw new ConnectionDeniedError("connection denied");return await this.shouldBlockConnection("denyInboundConnection",o),await this._performUpgrade(o,"inbound",tt)}catch(ot){throw(nt=this.metrics.errors)==null||nt.increment({inbound:!0}),ot}finally{this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(o,tt={}){var rt,nt;try{(rt=this.metrics.dials)==null||rt.increment({outbound:!0});const ot=o.remoteAddr.getPeerId();let it;return ot!=null&&(it=peerIdFromString$1(ot),await this.shouldBlockConnection("denyOutboundConnection",it,o)),await this._performUpgrade(o,"outbound",tt)}catch(ot){throw(nt=this.metrics.errors)==null||nt.increment({outbound:!0}),ot}}async _performUpgrade(o,tt,rt){var ht,mt,ft;let nt,ot,it,st,at;const ct=AbortSignal.timeout(tt==="inbound"?this.inboundUpgradeTimeout:this.outboundUpgradeTimeout),lt=anySignal([ct,rt.signal]);setMaxListeners(1/0,ct,lt),rt.signal=lt,(ht=this.components.metrics)==null||ht.trackMultiaddrConnection(o),o.log.trace("starting the %s connection upgrade",tt);let dt=o;if((rt==null?void 0:rt.skipProtection)!==!0){const pt=this.components.connectionProtector;pt!=null&&(o.log("protecting the %s connection",tt),dt=await pt.protect(o,rt))}try{if(nt=dt,(rt==null?void 0:rt.skipEncryption)!==!0){(mt=rt==null?void 0:rt.onProgress)==null||mt.call(rt,new CustomProgressEvent(`upgrader:encrypt-${tt}-connection`)),{conn:nt,remotePeer:ot,protocol:at}=await(tt==="inbound"?this._encryptInbound(dt,{...rt,signal:lt}):this._encryptOutbound(dt,{...rt,signal:lt}));const pt={...dt,...nt};await this.shouldBlockConnection(tt==="inbound"?"denyInboundEncryptedConnection":"denyOutboundEncryptedConnection",ot,pt)}else{const pt=o.remoteAddr.getPeerId();if(pt==null)throw new InvalidMultiaddrError(`${tt} connection that skipped encryption must have a peer id`);const yt=peerIdFromString$1(pt);at="native",ot=yt}if(ot.equals(this.components.peerId)){const pt=new InvalidPeerIdError("Can not dial self");throw o.abort(pt),pt}if(it=nt,(rt==null?void 0:rt.muxerFactory)!=null)st=rt.muxerFactory;else if(this.streamMuxers.size>0){(ft=rt==null?void 0:rt.onProgress)==null||ft.call(rt,new CustomProgressEvent(`upgrader:multiplex-${tt}-connection`));const pt=await(tt==="inbound"?this._multiplexInbound({...dt,...nt},this.streamMuxers,rt):this._multiplexOutbound({...dt,...nt},this.streamMuxers,rt));st=pt.muxerFactory,it=pt.stream}}catch(pt){throw o.log.error("failed to upgrade inbound connection %s %a - %e",tt==="inbound"?"from":"to",o.remoteAddr,pt),pt}finally{lt.clear()}return await this.shouldBlockConnection(tt==="inbound"?"denyInboundUpgradedConnection":"denyOutboundUpgradedConnection",ot,o),o.log("successfully upgraded %s connection",tt),this._createConnection({cryptoProtocol:at,direction:tt,maConn:o,upgradedConn:it,muxerFactory:st,remotePeer:ot,limits:rt==null?void 0:rt.limits})}_createConnection(o){const{cryptoProtocol:tt,direction:rt,maConn:nt,upgradedConn:ot,remotePeer:it,muxerFactory:st,limits:at}=o;let ct,lt,dt;st!=null&&(ct=st.createStreamMuxer({direction:rt,onIncomingStream:ft=>{dt!=null&&Promise.resolve().then(async()=>{var Et;const pt=this.components.registrar.getProtocols(),yt=AbortSignal.timeout(this.inboundStreamProtocolNegotiationTimeout);setMaxListeners(1/0,yt);const{stream:gt,protocol:bt}=await handle(ft,pt,{signal:yt,log:ft.log,yieldBytes:!1});if(dt==null)return;dt.log("incoming stream opened on %s",bt);const xt=findIncomingStreamLimit(bt,this.components.registrar);if(countStreams(bt,"inbound",dt)===xt){const Ct=new TooManyInboundProtocolStreamsError(`Too many inbound protocol streams for protocol "${bt}" - limit ${xt}`);throw ft.abort(Ct),Ct}ft.source=gt.source,ft.sink=gt.sink,ft.protocol=bt,gt.closeWrite!=null&&(ft.closeWrite=gt.closeWrite),gt.closeRead!=null&&(ft.closeRead=gt.closeRead),gt.close!=null&&(ft.close=gt.close),await this.components.peerStore.merge(it,{protocols:[bt]}),(Et=this.components.metrics)==null||Et.trackProtocolStream(ft,dt),this._onStream({connection:dt,stream:ft,protocol:bt})}).catch(async pt=>{dt.log.error("error handling incoming stream id %s - %e",ft.id,pt),ft.timeline.close==null&&await ft.close()})}}),lt=async(ft,pt={})=>{var gt;if(ct==null)throw new MuxerUnavailableError("Connection is not multiplexed");dt.log.trace("starting new stream for protocols %s",ft);const yt=await ct.newStream();dt.log.trace("started new stream %s for protocols %s",yt.id,ft);try{if(pt.signal==null){yt.log("no abort signal was passed while trying to negotiate protocols %s falling back to default timeout",ft);const Ct=AbortSignal.timeout(this.outboundStreamProtocolNegotiationTimeout);setMaxListeners(1/0,Ct),pt={...pt,signal:Ct}}yt.log.trace("selecting protocol from protocols %s",ft);const{stream:bt,protocol:xt}=await select(yt,ft,{...pt,log:yt.log,yieldBytes:!0});yt.log.trace("selected protocol %s",xt);const vt=findOutgoingStreamLimit(xt,this.components.registrar,pt),Et=countStreams(xt,"outbound",dt);if(Et>=vt){const Ct=new TooManyOutboundProtocolStreamsError(`Too many outbound protocol streams for protocol "${xt}" - ${Et}/${vt}`);throw yt.abort(Ct),Ct}return await this.components.peerStore.merge(it,{protocols:[xt]}),yt.source=bt.source,yt.sink=bt.sink,yt.protocol=xt,bt.closeWrite!=null&&(yt.closeWrite=bt.closeWrite),bt.closeRead!=null&&(yt.closeRead=bt.closeRead),bt.close!=null&&(yt.close=bt.close),(gt=this.components.metrics)==null||gt.trackProtocolStream(yt,dt),yt}catch(bt){throw dt.log.error("could not create new outbound stream on connection %s %a for protocols %s - %e",rt==="inbound"?"from":"to",o.maConn.remoteAddr,ft,bt),yt.timeline.close==null&&yt.abort(bt),bt}},Promise.all([ct.sink(ot.source),ot.sink(ct.source)]).catch(ft=>{dt.log.error("error piping data through muxer - %e",ft)}));const ht=nt.timeline;nt.timeline=new Proxy(ht,{set:(...ft)=>(ft[1]==="close"&&ft[2]!=null&&ht.close==null&&(async()=>{try{dt.status==="open"&&await dt.close()}catch(pt){dt.log.error("error closing connection after timeline close %e",pt)}finally{this.events.safeDispatchEvent("connection:close",{detail:dt})}})().catch(pt=>{dt.log.error("error thrown while dispatching connection:close event %e",pt)}),Reflect.set(...ft))}),nt.timeline.upgraded=Date.now();const mt=()=>{throw new MuxerUnavailableError("Connection is not multiplexed")};return dt=createConnection({remoteAddr:nt.remoteAddr,remotePeer:it,status:"open",direction:rt,timeline:nt.timeline,multiplexer:ct==null?void 0:ct.protocol,encryption:tt,limits:at,logger:this.components.logger,newStream:lt??mt,getStreams:()=>(ct==null?void 0:ct.streams)??[],close:async ft=>{await(ct==null?void 0:ct.close(ft)),await nt.close(ft)},abort:ft=>{nt.abort(ft),ct==null||ct.abort(ft)}}),this.events.safeDispatchEvent("connection:open",{detail:dt}),dt.__maConnTimeline=ht,dt}_onStream(o){const{connection:tt,stream:rt,protocol:nt}=o,{handler:ot,options:it}=this.components.registrar.getHandler(nt);if(tt.limits!=null&&it.runOnLimitedConnection!==!0)throw new LimitedConnectionError("Cannot open protocol stream on limited connection");ot({connection:tt,stream:rt})}async _encryptInbound(o,tt){const rt=Array.from(this.connectionEncrypters.keys());try{const{stream:nt,protocol:ot}=await handle(o,rt,{...tt,log:o.log}),it=this.connectionEncrypters.get(ot);if(it==null)throw new EncryptionFailedError(`no crypto module found for ${ot}`);return o.log("encrypting inbound connection to %a using %s",o.remoteAddr,ot),{...await it.secureInbound(nt,tt),protocol:ot}}catch(nt){throw o.log.error("encrypting inbound connection from %a failed",o.remoteAddr,nt),new EncryptionFailedError(nt.message)}}async _encryptOutbound(o,tt){const rt=Array.from(this.connectionEncrypters.keys());try{o.log.trace("selecting encrypter from %s",rt);const{stream:nt,protocol:ot}=await select(o,rt,{...tt,log:o.log,yieldBytes:!0}),it=this.connectionEncrypters.get(ot);if(it==null)throw new EncryptionFailedError(`no crypto module found for ${ot}`);return o.log("encrypting outbound connection to %a using %s",o.remoteAddr,ot),{...await it.secureOutbound(nt,tt),protocol:ot}}catch(nt){throw o.log.error("encrypting outbound connection to %a failed",o.remoteAddr,nt),new EncryptionFailedError(nt.message)}}async _multiplexOutbound(o,tt,rt){const nt=Array.from(tt.keys());o.log("outbound selecting muxer %s",nt);try{o.log.trace("selecting stream muxer from %s",nt);const{stream:ot,protocol:it}=await select(o,nt,{...rt,log:o.log,yieldBytes:!0});o.log("selected %s as muxer protocol",it);const st=tt.get(it);return{stream:ot,muxerFactory:st}}catch(ot){throw o.log.error("error multiplexing outbound connection",ot),new MuxerUnavailableError(String(ot))}}async _multiplexInbound(o,tt,rt){const nt=Array.from(tt.keys());o.log("inbound handling muxers %s",nt);try{const{stream:ot,protocol:it}=await handle(o,nt,{...rt,log:o.log}),st=tt.get(it);return{stream:ot,muxerFactory:st}}catch(ot){throw o.log.error("error multiplexing inbound connection",ot),new MuxerUnavailableError(String(ot))}}}const version$3="2.1.8",name$2="libp2p";var go,Fs;class Libp2p extends TypedEventEmitter{constructor(tt){var at,ct,lt,dt,ht,mt;super();fr(this,go);wt(this,"peerId");wt(this,"peerStore");wt(this,"contentRouting");wt(this,"peerRouting");wt(this,"metrics");wt(this,"services");wt(this,"logger");wt(this,"status");wt(this,"components");wt(this,"log");this.status="stopped";const rt=new TypedEventEmitter,nt=rt.dispatchEvent.bind(rt);rt.dispatchEvent=ft=>{const pt=nt(ft),yt=this.dispatchEvent(new CustomEvent(ft.type,{detail:ft.detail}));return pt||yt},setMaxListeners(1/0,rt),this.peerId=tt.peerId,this.logger=tt.logger??defaultLogger(),this.log=this.logger.forComponent("libp2p"),this.services={};const ot=this.components=defaultComponents({peerId:tt.peerId,privateKey:tt.privateKey,nodeInfo:tt.nodeInfo??{name:name$2,version:version$3},logger:this.logger,events:rt,datastore:tt.datastore??new MemoryDatastore,connectionGater:connectionGater(tt.connectionGater),dns:tt.dns});this.peerStore=this.configureComponent("peerStore",persistentPeerStore(ot,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...tt.peerStore})),tt.metrics!=null&&(this.metrics=this.configureComponent("metrics",tt.metrics(this.components))),ot.events.addEventListener("peer:update",ft=>{if(ft.detail.previous==null){const pt={id:ft.detail.peer.id,multiaddrs:ft.detail.peer.addresses.map(yt=>yt.multiaddr)};ot.events.safeDispatchEvent("peer:discovery",{detail:pt})}}),tt.connectionProtector!=null&&this.configureComponent("connectionProtector",tt.connectionProtector(ot)),this.components.upgrader=new DefaultUpgrader(this.components,{connectionEncrypters:(tt.connectionEncrypters??[]).map((ft,pt)=>this.configureComponent(`connection-encryption-${pt}`,ft(this.components))),streamMuxers:(tt.streamMuxers??[]).map((ft,pt)=>this.configureComponent(`stream-muxers-${pt}`,ft(this.components))),inboundUpgradeTimeout:(at=tt.connectionManager)==null?void 0:at.inboundUpgradeTimeout,outboundUpgradeTimeout:(ct=tt.connectionManager)==null?void 0:ct.outboundUpgradeTimeout}),this.configureComponent("transportManager",new DefaultTransportManager(this.components,tt.transportManager)),this.configureComponent("connectionManager",new DefaultConnectionManager(this.components,tt.connectionManager)),((lt=tt.connectionMonitor)==null?void 0:lt.enabled)!==!1&&this.configureComponent("connectionMonitor",new ConnectionMonitor(this.components,tt.connectionMonitor)),this.configureComponent("registrar",new DefaultRegistrar(this.components)),this.configureComponent("addressManager",new DefaultAddressManager(this.components,tt.addresses));const it=(tt.peerRouters??[]).map((ft,pt)=>this.configureComponent(`peer-router-${pt}`,ft(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new DefaultPeerRouting(this.components,{routers:it}));const st=(tt.contentRouters??[]).map((ft,pt)=>this.configureComponent(`content-router-${pt}`,ft(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new CompoundContentRouting(this.components,{routers:st})),this.configureComponent("randomWalk",new RandomWalk(this.components)),(tt.peerDiscovery??[]).forEach((ft,pt)=>{this.configureComponent(`peer-discovery-${pt}`,ft(this.components)).addEventListener("peer",gt=>{mr(this,go,Fs).call(this,gt)})}),(dt=tt.transports)==null||dt.forEach((ft,pt)=>{this.components.transportManager.add(this.configureComponent(`transport-${pt}`,ft(this.components)))}),tt.services!=null)for(const ft of Object.keys(tt.services)){const pt=tt.services[ft],yt=pt(this.components);if(yt==null){this.log.error("service factory %s returned null or undefined instance",ft);continue}this.services[ft]=yt,this.configureComponent(ft,yt),yt[contentRoutingSymbol]!=null&&(this.log("registering service %s for content routing",ft),st.push(yt[contentRoutingSymbol])),yt[peerRoutingSymbol]!=null&&(this.log("registering service %s for peer routing",ft),it.push(yt[peerRoutingSymbol])),yt[peerDiscoverySymbol]!=null&&(this.log("registering service %s for peer discovery",ft),(mt=(ht=yt[peerDiscoverySymbol]).addEventListener)==null||mt.call(ht,"peer",gt=>{mr(this,go,Fs).call(this,gt)}))}checkServiceDependencies(ot)}configureComponent(tt,rt){return rt==null&&this.log.error("component %s was null or undefined",tt),this.components[tt]=rt,rt}async start(){var tt,rt,nt,ot;if(this.status==="stopped"){this.status="starting",this.log("libp2p is starting");try{await((rt=(tt=this.components).beforeStart)==null?void 0:rt.call(tt)),await this.components.start(),await((ot=(nt=this.components).afterStart)==null?void 0:ot.call(nt)),this.status="started",this.safeDispatchEvent("start",{detail:this}),this.log("libp2p has started")}catch(it){throw this.log.error("An error occurred starting libp2p",it),this.status="started",await this.stop(),it}}}async stop(){var tt,rt,nt,ot;this.status==="started"&&(this.log("libp2p is stopping"),this.status="stopping",await((rt=(tt=this.components).beforeStop)==null?void 0:rt.call(tt)),await this.components.stop(),await((ot=(nt=this.components).afterStop)==null?void 0:ot.call(nt)),this.status="stopped",this.safeDispatchEvent("stop",{detail:this}),this.log("libp2p has stopped"))}getConnections(tt){return this.components.connectionManager.getConnections(tt)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){const tt=new PeerSet;for(const rt of this.components.connectionManager.getConnections())tt.add(rt.remotePeer);return Array.from(tt)}async dial(tt,rt={}){return this.components.connectionManager.openConnection(tt,{priority:75,...rt})}async dialProtocol(tt,rt,nt={}){if(rt==null)throw new InvalidParametersError$1("no protocols were provided to open a stream");if(rt=Array.isArray(rt)?rt:[rt],rt.length===0)throw new InvalidParametersError$1("no protocols were provided to open a stream");return(await this.dial(tt,nt)).newStream(rt,nt)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(tt,rt={}){isMultiaddr(tt)&&(tt=peerIdFromString$1(tt.getPeerId()??"")),await this.components.connectionManager.closeConnections(tt,rt)}async getPublicKey(tt,rt={}){if(this.log("getPublicKey %p",tt),tt.publicKey!=null)return tt.publicKey;try{const st=await this.peerStore.get(tt);if(st.id.publicKey!=null)return st.id.publicKey}catch(st){if(st.name!=="NotFoundError")throw st}const nt=concat([fromString$6("/pk/"),tt.toMultihash().bytes]),ot=await this.contentRouting.get(nt,rt),it=publicKeyFromProtobuf(ot);return await this.peerStore.patch(tt,{publicKey:it}),it}async handle(tt,rt,nt){Array.isArray(tt)||(tt=[tt]),await Promise.all(tt.map(async ot=>{await this.components.registrar.handle(ot,rt,nt)}))}async unhandle(tt){Array.isArray(tt)||(tt=[tt]),await Promise.all(tt.map(async rt=>{await this.components.registrar.unhandle(rt)}))}async register(tt,rt){return this.components.registrar.register(tt,rt)}unregister(tt){this.components.registrar.unregister(tt)}async isDialable(tt,rt={}){return this.components.connectionManager.isDialable(tt,rt)}}go=new WeakSet,Fs=function(tt){const{detail:rt}=tt;if(rt.id.toString()===this.peerId.toString()){this.log.error("peer discovery mechanism discovered self");return}this.components.peerStore.merge(rt.id,{multiaddrs:rt.multiaddrs}).catch(nt=>{this.log.error(nt)})};async function createLibp2p(et={}){et.privateKey??(et.privateKey=await generateKeyPair());const o=new Libp2p({...await validateConfig(et),peerId:peerIdFromPrivateKey(et.privateKey)});return et.start!==!1&&await o.start(),o}const enrTree={SANDBOX:"enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im",TEST:"enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im"},DEFAULT_BOOTSTRAP_TAG_NAME="bootstrap",DEFAULT_BOOTSTRAP_TAG_VALUE=50,DEFAULT_BOOTSTRAP_TAG_TTL=1e8,DEFAULT_NODE_REQUIREMENTS={store:1,filter:2,lightPush:2},ERR_INVALID_ID="Invalid record id",MULTIADDR_LENGTH_SIZE=2,__viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"}));/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const _0n=BigInt(0),_1n=BigInt(1),_2n=BigInt(2),_3n=BigInt(3),_8n=BigInt(8),CURVE=Object.freeze({a:_0n,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:_1n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),divNearest=(et,o)=>(et+o/_2n)/o,endo={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(et){const{n:o}=CURVE,tt=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),rt=-_1n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),nt=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),ot=tt,it=BigInt("0x100000000000000000000000000000000"),st=divNearest(ot*et,o),at=divNearest(-rt*et,o);let ct=mod(et-st*tt-at*nt,o),lt=mod(-st*rt-at*ot,o);const dt=ct>it,ht=lt>it;if(dt&&(ct=o-ct),ht&&(lt=o-lt),ct>it||lt>it)throw new Error("splitScalarEndo: Endomorphism failed, k="+et);return{k1neg:dt,k1:ct,k2neg:ht,k2:lt}}},fieldLen=32,groupLen=32,hashLen=32,compressedLen=fieldLen+1,uncompressedLen=2*fieldLen+1;function weierstrass(et){const{a:o,b:tt}=CURVE,rt=mod(et*et),nt=mod(rt*et);return mod(nt+o*et+tt)}const USE_ENDOMORPHISM=CURVE.a===_0n;class ShaError extends Error{constructor(o){super(o)}}function assertJacPoint(et){if(!(et instanceof JacobianPoint))throw new TypeError("JacobianPoint expected")}class JacobianPoint{constructor(o,tt,rt){this.x=o,this.y=tt,this.z=rt}static fromAffine(o){if(!(o instanceof Point))throw new TypeError("JacobianPoint#fromAffine: expected Point");return o.equals(Point.ZERO)?JacobianPoint.ZERO:new JacobianPoint(o.x,o.y,_1n)}static toAffineBatch(o){const tt=invertBatch(o.map(rt=>rt.z));return o.map((rt,nt)=>rt.toAffine(tt[nt]))}static normalizeZ(o){return JacobianPoint.toAffineBatch(o).map(JacobianPoint.fromAffine)}equals(o){assertJacPoint(o);const{x:tt,y:rt,z:nt}=this,{x:ot,y:it,z:st}=o,at=mod(nt*nt),ct=mod(st*st),lt=mod(tt*ct),dt=mod(ot*at),ht=mod(mod(rt*st)*ct),mt=mod(mod(it*nt)*at);return lt===dt&&ht===mt}negate(){return new JacobianPoint(this.x,mod(-this.y),this.z)}double(){const{x:o,y:tt,z:rt}=this,nt=mod(o*o),ot=mod(tt*tt),it=mod(ot*ot),st=o+ot,at=mod(_2n*(mod(st*st)-nt-it)),ct=mod(_3n*nt),lt=mod(ct*ct),dt=mod(lt-_2n*at),ht=mod(ct*(at-dt)-_8n*it),mt=mod(_2n*tt*rt);return new JacobianPoint(dt,ht,mt)}add(o){assertJacPoint(o);const{x:tt,y:rt,z:nt}=this,{x:ot,y:it,z:st}=o;if(ot===_0n||it===_0n)return this;if(tt===_0n||rt===_0n)return o;const at=mod(nt*nt),ct=mod(st*st),lt=mod(tt*ct),dt=mod(ot*at),ht=mod(mod(rt*st)*ct),mt=mod(mod(it*nt)*at),ft=mod(dt-lt),pt=mod(mt-ht);if(ft===_0n)return pt===_0n?this.double():JacobianPoint.ZERO;const yt=mod(ft*ft),gt=mod(ft*yt),bt=mod(lt*yt),xt=mod(pt*pt-gt-_2n*bt),vt=mod(pt*(bt-xt)-ht*gt),Et=mod(nt*st*ft);return new JacobianPoint(xt,vt,Et)}subtract(o){return this.add(o.negate())}multiplyUnsafe(o){const tt=JacobianPoint.ZERO;if(typeof o=="bigint"&&o===_0n)return tt;let rt=normalizeScalar(o);if(rt===_1n)return this;if(!USE_ENDOMORPHISM){let dt=tt,ht=this;for(;rt>_0n;)rt&_1n&&(dt=dt.add(ht)),ht=ht.double(),rt>>=_1n;return dt}let{k1neg:nt,k1:ot,k2neg:it,k2:st}=endo.splitScalar(rt),at=tt,ct=tt,lt=this;for(;ot>_0n||st>_0n;)ot&_1n&&(at=at.add(lt)),st&_1n&&(ct=ct.add(lt)),lt=lt.double(),ot>>=_1n,st>>=_1n;return nt&&(at=at.negate()),it&&(ct=ct.negate()),ct=new JacobianPoint(mod(ct.x*endo.beta),ct.y,ct.z),at.add(ct)}precomputeWindow(o){const tt=USE_ENDOMORPHISM?128/o+1:256/o+1,rt=[];let nt=this,ot=nt;for(let it=0;it>=dt,ft>at&&(ft-=lt,o+=_1n);const pt=mt,yt=mt+Math.abs(ft)-1,gt=ht%2!==0,bt=ft<0;ft===0?it=it.add(constTimeNegate(gt,nt[pt])):ot=ot.add(constTimeNegate(bt,nt[yt]))}return{p:ot,f:it}}multiply(o,tt){let rt=normalizeScalar(o),nt,ot;if(USE_ENDOMORPHISM){const{k1neg:it,k1:st,k2neg:at,k2:ct}=endo.splitScalar(rt);let{p:lt,f:dt}=this.wNAF(st,tt),{p:ht,f:mt}=this.wNAF(ct,tt);lt=constTimeNegate(it,lt),ht=constTimeNegate(at,ht),ht=new JacobianPoint(mod(ht.x*endo.beta),ht.y,ht.z),nt=lt.add(ht),ot=dt.add(mt)}else{const{p:it,f:st}=this.wNAF(rt,tt);nt=it,ot=st}return JacobianPoint.normalizeZ([nt,ot])[0]}toAffine(o){const{x:tt,y:rt,z:nt}=this,ot=this.equals(JacobianPoint.ZERO);o==null&&(o=ot?_8n:invert(nt));const it=o,st=mod(it*it),at=mod(st*it),ct=mod(tt*st),lt=mod(rt*at),dt=mod(nt*it);if(ot)return Point.ZERO;if(dt!==_1n)throw new Error("invZ was invalid");return new Point(ct,lt)}}JacobianPoint.BASE=new JacobianPoint(CURVE.Gx,CURVE.Gy,_1n);JacobianPoint.ZERO=new JacobianPoint(_0n,_1n,_0n);function constTimeNegate(et,o){const tt=o.negate();return et?tt:o}const pointPrecomputes=new WeakMap;class Point{constructor(o,tt){this.x=o,this.y=tt}_setWindowSize(o){this._WINDOW_SIZE=o,pointPrecomputes.delete(this)}hasEvenY(){return this.y%_2n===_0n}static fromCompressedHex(o){const tt=o.length===32,rt=bytesToNumber(tt?o:o.subarray(1));if(!isValidFieldElement(rt))throw new Error("Point is not on curve");const nt=weierstrass(rt);let ot=sqrtMod(nt);const it=(ot&_1n)===_1n;tt?it&&(ot=mod(-ot)):(o[0]&1)===1!==it&&(ot=mod(-ot));const st=new Point(rt,ot);return st.assertValidity(),st}static fromUncompressedHex(o){const tt=bytesToNumber(o.subarray(1,fieldLen+1)),rt=bytesToNumber(o.subarray(fieldLen+1,fieldLen*2+1)),nt=new Point(tt,rt);return nt.assertValidity(),nt}static fromHex(o){const tt=ensureBytes(o),rt=tt.length,nt=tt[0];if(rt===fieldLen)return this.fromCompressedHex(tt);if(rt===compressedLen&&(nt===2||nt===3))return this.fromCompressedHex(tt);if(rt===uncompressedLen&&nt===4)return this.fromUncompressedHex(tt);throw new Error(`Point.fromHex: received invalid point. Expected 32-${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes, not ${rt}`)}static fromPrivateKey(o){return Point.BASE.multiply(normalizePrivateKey(o))}static fromSignature(o,tt,rt){const{r:nt,s:ot}=normalizeSignature(tt);if(![0,1,2,3].includes(rt))throw new Error("Cannot recover: invalid recovery bit");const it=truncateHash(ensureBytes(o)),{n:st}=CURVE,at=rt===2||rt===3?nt+st:nt,ct=invert(at,st),lt=mod(-it*ct,st),dt=mod(ot*ct,st),ht=rt&1?"03":"02",mt=Point.fromHex(ht+numTo32bStr(at)),ft=Point.BASE.multiplyAndAddUnsafe(mt,lt,dt);if(!ft)throw new Error("Cannot recover signature: point at infinify");return ft.assertValidity(),ft}toRawBytes(o=!1){return hexToBytes(this.toHex(o))}toHex(o=!1){const tt=numTo32bStr(this.x);return o?`${this.hasEvenY()?"02":"03"}${tt}`:`04${tt}${numTo32bStr(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const o="Point is not on elliptic curve",{x:tt,y:rt}=this;if(!isValidFieldElement(tt)||!isValidFieldElement(rt))throw new Error(o);const nt=mod(rt*rt),ot=weierstrass(tt);if(mod(nt-ot)!==_0n)throw new Error(o)}equals(o){return this.x===o.x&&this.y===o.y}negate(){return new Point(this.x,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,tt,rt){const nt=JacobianPoint.fromAffine(this),ot=tt===_0n||tt===_1n||this!==Point.BASE?nt.multiplyUnsafe(tt):nt.multiply(tt),it=JacobianPoint.fromAffine(o).multiplyUnsafe(rt),st=ot.add(it);return st.equals(JacobianPoint.ZERO)?void 0:st.toAffine()}}Point.BASE=new Point(CURVE.Gx,CURVE.Gy);Point.ZERO=new Point(_0n,_0n);function sliceDER(et){return Number.parseInt(et[0],16)>=8?"00"+et:et}function parseDERInt(et){if(et.length<2||et[0]!==2)throw new Error(`Invalid signature integer tag: ${bytesToHex(et)}`);const o=et[1],tt=et.subarray(2,o+2);if(!o||tt.length!==o)throw new Error("Invalid signature integer: wrong length");if(tt[0]===0&&tt[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:bytesToNumber(tt),left:et.subarray(o+2)}}function parseDERSignature(et){if(et.length<2||et[0]!=48)throw new Error(`Invalid signature tag: ${bytesToHex(et)}`);if(et[1]!==et.length-2)throw new Error("Invalid signature: incorrect length");const{data:o,left:tt}=parseDERInt(et.subarray(2)),{data:rt,left:nt}=parseDERInt(tt);if(nt.length)throw new Error(`Invalid signature: left bytes after parsing: ${bytesToHex(nt)}`);return{r:o,s:rt}}class Signature{constructor(o,tt){this.r=o,this.s=tt,this.assertValidity()}static fromCompact(o){const tt=o instanceof Uint8Array,rt="Signature.fromCompact";if(typeof o!="string"&&!tt)throw new TypeError(`${rt}: Expected string or Uint8Array`);const nt=tt?bytesToHex(o):o;if(nt.length!==128)throw new Error(`${rt}: Expected 64-byte hex`);return new Signature(hexToNumber(nt.slice(0,64)),hexToNumber(nt.slice(64,128)))}static fromDER(o){const tt=o instanceof Uint8Array;if(typeof o!="string"&&!tt)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:rt,s:nt}=parseDERSignature(tt?o:hexToBytes(o));return new Signature(rt,nt)}static fromHex(o){return this.fromDER(o)}assertValidity(){const{r:o,s:tt}=this;if(!isWithinCurveOrder(o))throw new Error("Invalid Signature: r must be 0 < r < n");if(!isWithinCurveOrder(tt))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const o=CURVE.n>>_1n;return this.s>o}normalizeS(){return this.hasHighS()?new Signature(this.r,mod(-this.s,CURVE.n)):this}toDERRawBytes(){return hexToBytes(this.toDERHex())}toDERHex(){const o=sliceDER(numberToHexUnpadded(this.s)),tt=sliceDER(numberToHexUnpadded(this.r)),rt=o.length/2,nt=tt.length/2,ot=numberToHexUnpadded(rt),it=numberToHexUnpadded(nt);return`30${numberToHexUnpadded(nt+rt+4)}02${it}${tt}02${ot}${o}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return hexToBytes(this.toCompactHex())}toCompactHex(){return numTo32bStr(this.r)+numTo32bStr(this.s)}}function concatBytes(...et){if(!et.every(rt=>rt instanceof Uint8Array))throw new Error("Uint8Array list expected");if(et.length===1)return et[0];const o=et.reduce((rt,nt)=>rt+nt.length,0),tt=new Uint8Array(o);for(let rt=0,nt=0;rto.toString(16).padStart(2,"0"));function bytesToHex(et){if(!(et instanceof Uint8Array))throw new Error("Expected Uint8Array");let o="";for(let tt=0;tt0)return BigInt(et);if(typeof et=="bigint"&&isWithinCurveOrder(et))return et;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function mod(et,o=CURVE.P){const tt=et%o;return tt>=_0n?tt:o+tt}function pow2(et,o){const{P:tt}=CURVE;let rt=et;for(;o-- >_0n;)rt*=rt,rt%=tt;return rt}function sqrtMod(et){const{P:o}=CURVE,tt=BigInt(6),rt=BigInt(11),nt=BigInt(22),ot=BigInt(23),it=BigInt(44),st=BigInt(88),at=et*et*et%o,ct=at*at*et%o,lt=pow2(ct,_3n)*ct%o,dt=pow2(lt,_3n)*ct%o,ht=pow2(dt,_2n)*at%o,mt=pow2(ht,rt)*ht%o,ft=pow2(mt,nt)*mt%o,pt=pow2(ft,it)*ft%o,yt=pow2(pt,st)*pt%o,gt=pow2(yt,it)*ft%o,bt=pow2(gt,_3n)*ct%o,xt=pow2(bt,ot)*mt%o,vt=pow2(xt,tt)*at%o,Et=pow2(vt,_2n);if(Et*Et%o!==et)throw new Error("Cannot find square root");return Et}function invert(et,o=CURVE.P){if(et===_0n||o<=_0n)throw new Error(`invert: expected positive integers, got n=${et} mod=${o}`);let tt=mod(et,o),rt=o,nt=_0n,ot=_1n;for(;tt!==_0n;){const st=rt/tt,at=rt%tt,ct=nt-ot*st;rt=tt,tt=at,nt=ot,ot=ct}if(rt!==_1n)throw new Error("invert: does not exist");return mod(nt,o)}function invertBatch(et,o=CURVE.P){const tt=new Array(et.length),rt=et.reduce((ot,it,st)=>it===_0n?ot:(tt[st]=ot,mod(ot*it,o)),_1n),nt=invert(rt,o);return et.reduceRight((ot,it,st)=>it===_0n?ot:(tt[st]=mod(ot*tt[st],o),mod(ot*it,o)),nt),tt}function bits2int_2(et){const o=et.length*8-groupLen*8,tt=bytesToNumber(et);return o>0?tt>>BigInt(o):tt}function truncateHash(et,o=!1){const tt=bits2int_2(et);if(o)return tt;const{n:rt}=CURVE;return tt>=rt?tt-rt:tt}let _sha256Sync,_hmacSha256Sync;class HmacDrbg{constructor(o,tt){if(this.hashLen=o,this.qByteLen=tt,typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof tt!="number"||tt<2)throw new 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 utils.hmacSha256(this.k,...o)}hmacSync(...o){return _hmacSha256Sync(this.k,...o)}checkSync(){if(typeof _hmacSha256Sync!="function")throw new ShaError("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new 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),o.length!==0&&(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),o.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),o),this.v=this.hmacSync(this.v))}async generate(){this.incr();let o=0;const tt=[];for(;o0)o=BigInt(et);else if(typeof et=="string"){if(et.length!==2*groupLen)throw new Error("Expected 32 bytes of private key");o=hexToNumber(et)}else if(et instanceof Uint8Array){if(et.length!==groupLen)throw new Error("Expected 32 bytes of private key");o=bytesToNumber(et)}else throw new TypeError("Expected valid private key");if(!isWithinCurveOrder(o))throw new Error("Expected private key: 0 < key < n");return o}function normalizePublicKey(et){return et instanceof Point?(et.assertValidity(),et):Point.fromHex(et)}function normalizeSignature(et){if(et instanceof Signature)return et.assertValidity(),et;try{return Signature.fromDER(et)}catch{return Signature.fromCompact(et)}}function bits2int(et){const o=et.length>fieldLen?et.slice(0,fieldLen):et;return bytesToNumber(o)}function bits2octets(et){const o=bits2int(et),tt=mod(o,CURVE.n);return int2octets(tt<_0n?o:tt)}function int2octets(et){return numTo32b(et)}function initSigArgs(et,o,tt){if(et==null)throw new Error(`sign: expected valid message hash, not "${et}"`);const rt=ensureBytes(et),nt=normalizePrivateKey(o),ot=[int2octets(nt),bits2octets(rt)];if(tt!=null){tt===!0&&(tt=utils.randomBytes(fieldLen));const at=ensureBytes(tt);if(at.length!==fieldLen)throw new Error(`sign: Expected ${fieldLen} bytes of extra data`);ot.push(at)}const it=concatBytes(...ot),st=bits2int(rt);return{seed:it,m:st,d:nt}}function finalizeSig(et,o){const{sig:tt,recovery:rt}=et,{der:nt,recovered:ot}=Object.assign({canonical:!0,der:!0},o),it=nt?tt.toDERRawBytes():tt.toCompactRawBytes();return ot?[it,rt]:it}async function sign$1(et,o,tt={}){const{seed:rt,m:nt,d:ot}=initSigArgs(et,o,tt.extraEntropy),it=new HmacDrbg(hashLen,groupLen);await it.reseed(rt);let st;for(;!(st=kmdToSig(await it.generate(),nt,ot,tt.canonical));)await it.reseed();return finalizeSig(st,tt)}const vopts={strict:!0};function verify(et,o,tt,rt=vopts){let nt;try{nt=normalizeSignature(et),o=ensureBytes(o)}catch{return!1}const{r:ot,s:it}=nt;if(rt.strict&&nt.hasHighS())return!1;const st=truncateHash(o);let at;try{at=normalizePublicKey(tt)}catch{return!1}const{n:ct}=CURVE,lt=invert(it,ct),dt=mod(st*lt,ct),ht=mod(ot*lt,ct),mt=Point.BASE.multiplyAndAddUnsafe(at,dt,ht);return mt?mod(mt.x,ct)===ot:!1}Point.BASE._setWindowSize(8);const crypto$1={node:__viteBrowserExternal$1,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},TAGGED_HASH_PREFIXES={},utils={bytesToHex,hexToBytes,concatBytes,mod,invert,isValidPrivateKey(et){try{return normalizePrivateKey(et),!0}catch{return!1}},_bigintTo32Bytes:numTo32b,_normalizePrivateKey:normalizePrivateKey,hashToPrivateKey:et=>{et=ensureBytes(et);const o=groupLen+8;if(et.length1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const tt=mod(bytesToNumber(et),CURVE.n-_1n)+_1n;return numTo32b(tt)},randomBytes:(et=32)=>{if(crypto$1.web)return crypto$1.web.getRandomValues(new Uint8Array(et));if(crypto$1.node){const{randomBytes:o}=crypto$1.node;return Uint8Array.from(o(et))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>utils.hashToPrivateKey(utils.randomBytes(groupLen+8)),precompute(et=8,o=Point.BASE){const tt=o===Point.BASE?o:new Point(o.x,o.y);return tt._setWindowSize(et),tt.multiply(_3n),tt},sha256:async(...et)=>{if(crypto$1.web){const o=await crypto$1.web.subtle.digest("SHA-256",concatBytes(...et));return new Uint8Array(o)}else if(crypto$1.node){const{createHash:o}=crypto$1.node,tt=o("sha256");return et.forEach(rt=>tt.update(rt)),Uint8Array.from(tt.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(et,...o)=>{if(crypto$1.web){const tt=await crypto$1.web.subtle.importKey("raw",et,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),rt=concatBytes(...o),nt=await crypto$1.web.subtle.sign("HMAC",tt,rt);return new Uint8Array(nt)}else if(crypto$1.node){const{createHmac:tt}=crypto$1.node,rt=tt("sha256",et);return o.forEach(nt=>rt.update(nt)),Uint8Array.from(rt.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(et,...o)=>{let tt=TAGGED_HASH_PREFIXES[et];if(tt===void 0){const rt=await utils.sha256(Uint8Array.from(et,nt=>nt.charCodeAt(0)));tt=concatBytes(rt,rt),TAGGED_HASH_PREFIXES[et]=tt}return utils.sha256(tt,...o)},taggedHashSync:(et,...o)=>{if(typeof _sha256Sync!="function")throw new ShaError("sha256Sync is undefined, you need to set it");let tt=TAGGED_HASH_PREFIXES[et];if(tt===void 0){const rt=_sha256Sync(Uint8Array.from(et,nt=>nt.charCodeAt(0)));tt=concatBytes(rt,rt),TAGGED_HASH_PREFIXES[et]=tt}return _sha256Sync(tt,...o)},_JacobianPoint:JacobianPoint};Object.defineProperties(utils,{sha256Sync:{configurable:!1,get(){return _sha256Sync},set(et){_sha256Sync||(_sha256Sync=et)}},hmacSha256Sync:{configurable:!1,get(){return _hmacSha256Sync},set(et){_hmacSha256Sync||(_hmacSha256Sync=et)}}});var sha3$1={exports:{}};(function(et){var o={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0};/** * [js-sha3]{@link https://github.com/emn178/js-sha3} * * @version 0.9.3 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2015-2023 * @license MIT - */(function(et){(function(){var o="input is invalid type",tt="finalize already called",rt=typeof window=="object",nt=rt?window:{};nt.JS_SHA3_NO_WINDOW&&(rt=!1);var ot=!rt&&typeof self=="object",it=!nt.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;it?nt=commonjsGlobal:ot&&(nt=self);for(var st=!nt.JS_SHA3_NO_COMMON_JS&&!0&&et.exports,at=!nt.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",ct="0123456789abcdef".split(""),lt=[31,7936,2031616,520093696],dt=[4,1024,262144,67108864],ht=[1,256,65536,16777216],mt=[6,1536,393216,100663296],ft=[0,8,16,24],pt=[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],gt=[224,256,384,512],yt=[128,256],bt=["hex","buffer","arrayBuffer","array","digest"],xt={128:168,256:136},vt=nt.JS_SHA3_NO_NODE_JS||!Array.isArray?function(Rt){return Object.prototype.toString.call(Rt)==="[object Array]"}:Array.isArray,Et=at&&(nt.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(Rt){return typeof Rt=="object"&&Rt.buffer&&Rt.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Ct=function(Rt){var Mt=typeof Rt;if(Mt==="string")return[Rt,!0];if(Mt!=="object"||Rt===null)throw new Error(o);if(at&&Rt.constructor===ArrayBuffer)return[new Uint8Array(Rt),!1];if(!vt(Rt)&&!Et(Rt))throw new Error(o);return[Rt,!1]},St=function(Rt){return Ct(Rt)[0].length===0},At=function(Rt){for(var Mt=[],Ut=0;Ut>5,this.byteCount=this.blockCount<<2,this.outputBlocks=Ut>>5,this.extraBytes=(Ut&31)>>3;for(var Zt=0;Zt<50;++Zt)this.s[Zt]=0}lr.prototype.update=function(Rt){if(this.finalized)throw new Error(tt);var Mt=Ct(Rt);Rt=Mt[0];for(var Ut=Mt[1],Zt=this.blocks,nr=this.byteCount,ar=Rt.length,dr=this.blockCount,cr=0,yr=this.s,pr,gr;cr>2]|=gr<>2]|=(192|gr>>6)<>2]|=(128|gr&63)<=57344?(Zt[pr>>2]|=(224|gr>>12)<>2]|=(128|gr>>6&63)<>2]|=(128|gr&63)<>2]|=(240|gr>>18)<>2]|=(128|gr>>12&63)<>2]|=(128|gr>>6&63)<>2]|=(128|gr&63)<>2]|=Rt[cr]<=nr){for(this.start=pr-nr,this.block=Zt[dr],pr=0;pr>8,Ut=Rt&255;Ut>0;)nr.unshift(Ut),Rt=Rt>>8,Ut=Rt&255,++Zt;return Mt?nr.push(Zt):nr.unshift(Zt),this.update(nr),nr.length},lr.prototype.encodeString=function(Rt){var Mt=Ct(Rt);Rt=Mt[0];var Ut=Mt[1],Zt=0,nr=Rt.length;if(Ut)for(var ar=0;ar=57344?Zt+=3:(dr=65536+((dr&1023)<<10|Rt.charCodeAt(++ar)&1023),Zt+=4)}else Zt=nr;return Zt+=this.encode(Zt*8),this.update(Rt),Zt},lr.prototype.bytepad=function(Rt,Mt){for(var Ut=this.encode(Mt),Zt=0;Zt>2]|=this.padding[Mt&3],this.lastByteIndex===this.byteCount)for(Rt[0]=Rt[Ut],Mt=1;Mt>4&15]+ct[cr&15]+ct[cr>>12&15]+ct[cr>>8&15]+ct[cr>>20&15]+ct[cr>>16&15]+ct[cr>>28&15]+ct[cr>>24&15];ar%Rt===0&&(Mt=At(Mt),Jt(Mt),nr=0)}return Zt&&(cr=Mt[nr],dr+=ct[cr>>4&15]+ct[cr&15],Zt>1&&(dr+=ct[cr>>12&15]+ct[cr>>8&15]),Zt>2&&(dr+=ct[cr>>20&15]+ct[cr>>16&15])),dr},lr.prototype.arrayBuffer=function(){this.finalize();var Rt=this.blockCount,Mt=this.s,Ut=this.outputBlocks,Zt=this.extraBytes,nr=0,ar=0,dr=this.outputBits>>3,cr;Zt?cr=new ArrayBuffer(Ut+1<<2):cr=new ArrayBuffer(dr);for(var yr=new Uint32Array(cr);ar>8&255,dr[cr+2]=yr>>16&255,dr[cr+3]=yr>>24&255;ar%Rt===0&&(Mt=At(Mt),Jt(Mt))}return Zt&&(cr=ar<<2,yr=Mt[nr],dr[cr]=yr&255,Zt>1&&(dr[cr+1]=yr>>8&255),Zt>2&&(dr[cr+2]=yr>>16&255)),dr};function rr(Rt,Mt,Ut){lr.call(this,Rt,Mt,Ut)}rr.prototype=new lr,rr.prototype.finalize=function(){return this.encode(this.outputBits,!0),lr.prototype.finalize.call(this)};var Jt=function(Rt){var Mt,Ut,Zt,nr,ar,dr,cr,yr,pr,gr,Pr,_r,Rr,mr,wr,ir,Tt,$t,_t,Dt,qt,er,sr,br,Ar,xr,Sr,vr,yo,bo,xo,vo,wo,Eo,Co,So,Ao,$o,ko,_o,Ro,To,Io,Po,jo,No,Do,Oo,Lo,Mo,Bo,Fo,Uo,zo,Vo,Ho,Wo,Go,Zo,qo,Ko,Qo,Yo;for(Zt=0;Zt<48;Zt+=2)nr=Rt[0]^Rt[10]^Rt[20]^Rt[30]^Rt[40],ar=Rt[1]^Rt[11]^Rt[21]^Rt[31]^Rt[41],dr=Rt[2]^Rt[12]^Rt[22]^Rt[32]^Rt[42],cr=Rt[3]^Rt[13]^Rt[23]^Rt[33]^Rt[43],yr=Rt[4]^Rt[14]^Rt[24]^Rt[34]^Rt[44],pr=Rt[5]^Rt[15]^Rt[25]^Rt[35]^Rt[45],gr=Rt[6]^Rt[16]^Rt[26]^Rt[36]^Rt[46],Pr=Rt[7]^Rt[17]^Rt[27]^Rt[37]^Rt[47],_r=Rt[8]^Rt[18]^Rt[28]^Rt[38]^Rt[48],Rr=Rt[9]^Rt[19]^Rt[29]^Rt[39]^Rt[49],Mt=_r^(dr<<1|cr>>>31),Ut=Rr^(cr<<1|dr>>>31),Rt[0]^=Mt,Rt[1]^=Ut,Rt[10]^=Mt,Rt[11]^=Ut,Rt[20]^=Mt,Rt[21]^=Ut,Rt[30]^=Mt,Rt[31]^=Ut,Rt[40]^=Mt,Rt[41]^=Ut,Mt=nr^(yr<<1|pr>>>31),Ut=ar^(pr<<1|yr>>>31),Rt[2]^=Mt,Rt[3]^=Ut,Rt[12]^=Mt,Rt[13]^=Ut,Rt[22]^=Mt,Rt[23]^=Ut,Rt[32]^=Mt,Rt[33]^=Ut,Rt[42]^=Mt,Rt[43]^=Ut,Mt=dr^(gr<<1|Pr>>>31),Ut=cr^(Pr<<1|gr>>>31),Rt[4]^=Mt,Rt[5]^=Ut,Rt[14]^=Mt,Rt[15]^=Ut,Rt[24]^=Mt,Rt[25]^=Ut,Rt[34]^=Mt,Rt[35]^=Ut,Rt[44]^=Mt,Rt[45]^=Ut,Mt=yr^(_r<<1|Rr>>>31),Ut=pr^(Rr<<1|_r>>>31),Rt[6]^=Mt,Rt[7]^=Ut,Rt[16]^=Mt,Rt[17]^=Ut,Rt[26]^=Mt,Rt[27]^=Ut,Rt[36]^=Mt,Rt[37]^=Ut,Rt[46]^=Mt,Rt[47]^=Ut,Mt=gr^(nr<<1|ar>>>31),Ut=Pr^(ar<<1|nr>>>31),Rt[8]^=Mt,Rt[9]^=Ut,Rt[18]^=Mt,Rt[19]^=Ut,Rt[28]^=Mt,Rt[29]^=Ut,Rt[38]^=Mt,Rt[39]^=Ut,Rt[48]^=Mt,Rt[49]^=Ut,mr=Rt[0],wr=Rt[1],No=Rt[11]<<4|Rt[10]>>>28,Do=Rt[10]<<4|Rt[11]>>>28,vr=Rt[20]<<3|Rt[21]>>>29,yo=Rt[21]<<3|Rt[20]>>>29,qo=Rt[31]<<9|Rt[30]>>>23,Ko=Rt[30]<<9|Rt[31]>>>23,To=Rt[40]<<18|Rt[41]>>>14,Io=Rt[41]<<18|Rt[40]>>>14,Eo=Rt[2]<<1|Rt[3]>>>31,Co=Rt[3]<<1|Rt[2]>>>31,ir=Rt[13]<<12|Rt[12]>>>20,Tt=Rt[12]<<12|Rt[13]>>>20,Oo=Rt[22]<<10|Rt[23]>>>22,Lo=Rt[23]<<10|Rt[22]>>>22,bo=Rt[33]<<13|Rt[32]>>>19,xo=Rt[32]<<13|Rt[33]>>>19,Qo=Rt[42]<<2|Rt[43]>>>30,Yo=Rt[43]<<2|Rt[42]>>>30,zo=Rt[5]<<30|Rt[4]>>>2,Vo=Rt[4]<<30|Rt[5]>>>2,So=Rt[14]<<6|Rt[15]>>>26,Ao=Rt[15]<<6|Rt[14]>>>26,$t=Rt[25]<<11|Rt[24]>>>21,_t=Rt[24]<<11|Rt[25]>>>21,Mo=Rt[34]<<15|Rt[35]>>>17,Bo=Rt[35]<<15|Rt[34]>>>17,vo=Rt[45]<<29|Rt[44]>>>3,wo=Rt[44]<<29|Rt[45]>>>3,br=Rt[6]<<28|Rt[7]>>>4,Ar=Rt[7]<<28|Rt[6]>>>4,Ho=Rt[17]<<23|Rt[16]>>>9,Wo=Rt[16]<<23|Rt[17]>>>9,$o=Rt[26]<<25|Rt[27]>>>7,ko=Rt[27]<<25|Rt[26]>>>7,Dt=Rt[36]<<21|Rt[37]>>>11,qt=Rt[37]<<21|Rt[36]>>>11,Fo=Rt[47]<<24|Rt[46]>>>8,Uo=Rt[46]<<24|Rt[47]>>>8,Po=Rt[8]<<27|Rt[9]>>>5,jo=Rt[9]<<27|Rt[8]>>>5,xr=Rt[18]<<20|Rt[19]>>>12,Sr=Rt[19]<<20|Rt[18]>>>12,Go=Rt[29]<<7|Rt[28]>>>25,Zo=Rt[28]<<7|Rt[29]>>>25,_o=Rt[38]<<8|Rt[39]>>>24,Ro=Rt[39]<<8|Rt[38]>>>24,er=Rt[48]<<14|Rt[49]>>>18,sr=Rt[49]<<14|Rt[48]>>>18,Rt[0]=mr^~ir&$t,Rt[1]=wr^~Tt&_t,Rt[10]=br^~xr&vr,Rt[11]=Ar^~Sr&yo,Rt[20]=Eo^~So&$o,Rt[21]=Co^~Ao&ko,Rt[30]=Po^~No&Oo,Rt[31]=jo^~Do&Lo,Rt[40]=zo^~Ho&Go,Rt[41]=Vo^~Wo&Zo,Rt[2]=ir^~$t&Dt,Rt[3]=Tt^~_t&qt,Rt[12]=xr^~vr&bo,Rt[13]=Sr^~yo&xo,Rt[22]=So^~$o&_o,Rt[23]=Ao^~ko&Ro,Rt[32]=No^~Oo&Mo,Rt[33]=Do^~Lo&Bo,Rt[42]=Ho^~Go&qo,Rt[43]=Wo^~Zo&Ko,Rt[4]=$t^~Dt&er,Rt[5]=_t^~qt&sr,Rt[14]=vr^~bo&vo,Rt[15]=yo^~xo&wo,Rt[24]=$o^~_o&To,Rt[25]=ko^~Ro&Io,Rt[34]=Oo^~Mo&Fo,Rt[35]=Lo^~Bo&Uo,Rt[44]=Go^~qo&Qo,Rt[45]=Zo^~Ko&Yo,Rt[6]=Dt^~er&mr,Rt[7]=qt^~sr&wr,Rt[16]=bo^~vo&br,Rt[17]=xo^~wo&Ar,Rt[26]=_o^~To&Eo,Rt[27]=Ro^~Io&Co,Rt[36]=Mo^~Fo&Po,Rt[37]=Bo^~Uo&jo,Rt[46]=qo^~Qo&zo,Rt[47]=Ko^~Yo&Vo,Rt[8]=er^~mr&ir,Rt[9]=sr^~wr&Tt,Rt[18]=vo^~br&xr,Rt[19]=wo^~Ar&Sr,Rt[28]=To^~Eo&So,Rt[29]=Io^~Co&Ao,Rt[38]=Fo^~Po&No,Rt[39]=Uo^~jo&Do,Rt[48]=Qo^~zo&Ho,Rt[49]=Yo^~Vo&Wo,Rt[0]^=pt[Zt],Rt[1]^=pt[Zt+1]};if(st)et.exports=Wt;else for(Xt=0;Xtot+MULTIADDR_LENGTH_SIZE+it.bytes.length,0),tt=new Uint8Array(o),rt=new DataView(tt.buffer);let nt=0;return et.forEach(ot=>{if(ot.getPeerId())throw new Error("`multiaddr` field MUST not contain peer id");rt.setUint16(nt,ot.bytes.length),nt+=MULTIADDR_LENGTH_SIZE,tt.set(ot.bytes,nt),nt+=ot.bytes.length}),tt}function encodeWaku2(et){let o=0;return et.lightPush&&(o+=1),o=o<<1,et.filter&&(o+=1),o=o<<1,et.store&&(o+=1),o=o<<1,et.relay&&(o+=1),o}function decodeWaku2(et){const o={relay:!1,store:!1,filter:!1,lightPush:!1};return et%2&&(o.relay=!0),et=et>>1,et%2&&(o.store=!0),et=et>>1,et%2&&(o.filter=!0),et=et>>1,et%2&&(o.lightPush=!0),o}class RawEnr extends Map{constructor(tt={},rt=BigInt(1),nt){super(Object.entries(tt));wt(this,"seq");wt(this,"signature");this.seq=rt,this.signature=nt}set(tt,rt){return this.signature=void 0,this.seq++,super.set(tt,rt)}get id(){const tt=this.get("id");if(!tt)throw new Error("id not found.");return bytesToUtf8(tt)}get publicKey(){switch(this.id){case"v4":return this.get("secp256k1");default:throw new Error(ERR_INVALID_ID)}}get rs(){const tt=this.get("rs");if(tt)return decodeRelayShard(tt)}get rsv(){const tt=this.get("rsv");if(tt)return decodeRelayShard(tt)}get ip(){return getStringValue(this,"ip","ip4")}set ip(tt){setStringValue(this,"ip","ip4",tt)}get tcp(){return getNumberAsStringValue(this,"tcp","tcp")}set tcp(tt){setNumberAsStringValue(this,"tcp","tcp",tt)}get udp(){return getNumberAsStringValue(this,"udp","udp")}set udp(tt){setNumberAsStringValue(this,"udp","udp",tt)}get ip6(){return getStringValue(this,"ip6","ip6")}set ip6(tt){setStringValue(this,"ip6","ip6",tt)}get tcp6(){return getNumberAsStringValue(this,"tcp6","tcp")}set tcp6(tt){setNumberAsStringValue(this,"tcp6","tcp",tt)}get udp6(){return getNumberAsStringValue(this,"udp6","udp")}set udp6(tt){setNumberAsStringValue(this,"udp6","udp",tt)}get multiaddrs(){const tt=this.get("multiaddrs");if(tt)return decodeMultiaddrs(tt)}set multiaddrs(tt){deleteUndefined(this,"multiaddrs",tt,encodeMultiaddrs)}get waku2(){const tt=this.get("waku2");if(tt)return decodeWaku2(tt[0])}set waku2(tt){deleteUndefined(this,"waku2",tt,rt=>new Uint8Array([encodeWaku2(rt)]))}}function getStringValue(et,o,tt){const rt=et.get(o);if(rt)return convertToString(tt,rt)}function getNumberAsStringValue(et,o,tt){const rt=et.get(o);if(rt)return Number(convertToString(tt,rt))}function setStringValue(et,o,tt,rt){deleteUndefined(et,o,rt,convertToBytes.bind({},tt))}function setNumberAsStringValue(et,o,tt,rt){setStringValue(et,o,tt,rt==null?void 0:rt.toString(10))}function deleteUndefined(et,o,tt,rt){tt!==void 0?et.set(o,rt(tt)):et.delete(o)}async function sign(et,o){return sign$1(keccak256(o),et,{der:!1})}function nodeId(et){const tt=Point.fromHex(et).toRawBytes(!1);return bytesToHex$1(keccak256(tt.slice(1)))}const log$9=new Logger$1("enr");var TransportProtocol;(function(et){et.TCP="tcp",et.UDP="udp"})(TransportProtocol||(TransportProtocol={}));var TransportProtocolPerIpVersion;(function(et){et.TCP4="tcp4",et.UDP4="udp4",et.TCP6="tcp6",et.UDP6="udp6"})(TransportProtocolPerIpVersion||(TransportProtocolPerIpVersion={}));const ss=class ss extends RawEnr{constructor(){super(...arguments);wt(this,"peerId");wt(this,"getLocationMultiaddr",locationMultiaddrFromEnrFields.bind({},this))}static create(tt={},rt=BigInt(1),nt){const ot=new ss(tt,rt,nt);try{const it=ot.publicKey;it&&(ot.peerId=createPeerIdFromPublicKey(it))}catch(it){log$9.error("Could not calculate peer id for ENR",it)}return ot}get nodeId(){switch(this.id){case"v4":return this.publicKey?nodeId(this.publicKey):void 0;default:throw new Error(ERR_INVALID_ID)}}get shardInfo(){return this.rs&&this.rsv&&log$9.warn("ENR contains both `rs` and `rsv` fields."),this.rs||this.rsv}setLocationMultiaddr(tt){const rt=tt.protoNames();if(rt.length!==2&&rt[1]!=="udp"&&rt[1]!=="tcp")throw new Error("Invalid multiaddr");const nt=tt.tuples();if(!nt[0][1]||!nt[1][1])throw new Error("Invalid multiaddr");nt[0][0]===4?(this.set("ip",nt[0][1]),this.set(rt[1],nt[1][1])):(this.set("ip6",nt[0][1]),this.set(rt[1]+"6",nt[1][1]))}getAllLocationMultiaddrs(){const tt=[];for(const nt of Object.values(TransportProtocolPerIpVersion)){const ot=this.getLocationMultiaddr(nt);ot&&tt.push(ot)}const rt=this.multiaddrs??[];return tt.concat(rt).map(nt=>this.peerId?nt.encapsulate(`/p2p/${this.peerId.toString()}`):nt)}get peerInfo(){const tt=this.peerId;if(tt)return{id:tt,multiaddrs:this.getAllLocationMultiaddrs()}}getFullMultiaddr(tt){if(this.peerId){const rt=this.getLocationMultiaddr(tt);if(rt)return rt.encapsulate(`/p2p/${this.peerId.toString()}`)}}getFullMultiaddrs(){if(this.peerId&&this.multiaddrs){const tt=this.peerId;return this.multiaddrs.map(rt=>rt.encapsulate(`/p2p/${tt.toString()}`))}return[]}verify(tt,rt){if(!this.get("id")||this.id!=="v4")throw new Error(ERR_INVALID_ID);if(!this.publicKey)throw new Error("Failed to verify ENR: No public key");return verifySignature(rt,keccak256(tt),this.publicKey)}async sign(tt,rt){switch(this.id){case"v4":this.signature=await sign(rt,tt);break;default:throw new Error(ERR_INVALID_ID)}return this.signature}};wt(ss,"RECORD_PREFIX","enr:");let ENR=ss;const version$2="logger/5.7.0";let _permanentCensorErrors=!1,_censorErrors=!1;const LogLevels={debug:1,default:2,info:2,warning:3,error:4,off:5};let _logLevel=LogLevels.default,_globalLogger=null;function _checkNormalize(){try{const et=[];if(["NFD","NFC","NFKD","NFKC"].forEach(o=>{try{if("test".normalize(o)!=="test")throw new Error("bad normalize")}catch{et.push(o)}}),et.length)throw new Error("missing "+et.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(et){return et.message}return null}const _normalizeError=_checkNormalize();var LogLevel;(function(et){et.DEBUG="DEBUG",et.INFO="INFO",et.WARNING="WARNING",et.ERROR="ERROR",et.OFF="OFF"})(LogLevel||(LogLevel={}));var ErrorCode;(function(et){et.UNKNOWN_ERROR="UNKNOWN_ERROR",et.NOT_IMPLEMENTED="NOT_IMPLEMENTED",et.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",et.NETWORK_ERROR="NETWORK_ERROR",et.SERVER_ERROR="SERVER_ERROR",et.TIMEOUT="TIMEOUT",et.BUFFER_OVERRUN="BUFFER_OVERRUN",et.NUMERIC_FAULT="NUMERIC_FAULT",et.MISSING_NEW="MISSING_NEW",et.INVALID_ARGUMENT="INVALID_ARGUMENT",et.MISSING_ARGUMENT="MISSING_ARGUMENT",et.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",et.CALL_EXCEPTION="CALL_EXCEPTION",et.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",et.NONCE_EXPIRED="NONCE_EXPIRED",et.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",et.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",et.TRANSACTION_REPLACED="TRANSACTION_REPLACED",et.ACTION_REJECTED="ACTION_REJECTED"})(ErrorCode||(ErrorCode={}));const HEX="0123456789abcdef";class Logger{constructor(o){Object.defineProperty(this,"version",{enumerable:!0,value:o,writable:!1})}_log(o,tt){const rt=o.toLowerCase();LogLevels[rt]==null&&this.throwArgumentError("invalid log level name","logLevel",o),!(_logLevel>LogLevels[rt])&&console.log.apply(console,tt)}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,tt,rt){if(_censorErrors)return this.makeError("censored error",tt,{});tt||(tt=Logger.errors.UNKNOWN_ERROR),rt||(rt={});const nt=[];Object.keys(rt).forEach(at=>{const ct=rt[at];try{if(ct instanceof Uint8Array){let lt="";for(let dt=0;dt>4],lt+=HEX[ct[dt]&15];nt.push(at+"=Uint8Array(0x"+lt+")")}else nt.push(at+"="+JSON.stringify(ct))}catch{nt.push(at+"="+JSON.stringify(rt[at].toString()))}}),nt.push(`code=${tt}`),nt.push(`version=${this.version}`);const ot=o;let it="";switch(tt){case ErrorCode.NUMERIC_FAULT:{it="NUMERIC_FAULT";const at=o;switch(at){case"overflow":case"underflow":case"division-by-zero":it+="-"+at;break;case"negative-power":case"negative-width":it+="-unsupported";break;case"unbound-bitwise-result":it+="-unbound-result";break}break}case ErrorCode.CALL_EXCEPTION:case ErrorCode.INSUFFICIENT_FUNDS:case ErrorCode.MISSING_NEW:case ErrorCode.NONCE_EXPIRED:case ErrorCode.REPLACEMENT_UNDERPRICED:case ErrorCode.TRANSACTION_REPLACED:case ErrorCode.UNPREDICTABLE_GAS_LIMIT:it=tt;break}it&&(o+=" [ See: https://links.ethers.org/v5-errors-"+it+" ]"),nt.length&&(o+=" ("+nt.join(", ")+")");const st=new Error(o);return st.reason=ot,st.code=tt,Object.keys(rt).forEach(function(at){st[at]=rt[at]}),st}throwError(o,tt,rt){throw this.makeError(o,tt,rt)}throwArgumentError(o,tt,rt){return this.throwError(o,Logger.errors.INVALID_ARGUMENT,{argument:tt,value:rt})}assert(o,tt,rt,nt){o||this.throwError(tt,rt,nt)}assertArgument(o,tt,rt,nt){o||this.throwArgumentError(tt,rt,nt)}checkNormalize(o){_normalizeError&&this.throwError("platform missing String.prototype.normalize",Logger.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:_normalizeError})}checkSafeUint53(o,tt){typeof o=="number"&&(tt==null&&(tt="value not safe"),(o<0||o>=9007199254740991)&&this.throwError(tt,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:o}),o%1&&this.throwError(tt,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:o}))}checkArgumentCount(o,tt,rt){rt?rt=": "+rt:rt="",ott&&this.throwError("too many arguments"+rt,Logger.errors.UNEXPECTED_ARGUMENT,{count:o,expectedCount:tt})}checkNew(o,tt){(o===Object||o==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:tt.name})}checkAbstract(o,tt){o===tt?this.throwError("cannot instantiate abstract class "+JSON.stringify(tt.name)+" directly; use a sub-class",Logger.errors.UNSUPPORTED_OPERATION,{name:o.name,operation:"new"}):(o===Object||o==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:tt.name})}static globalLogger(){return _globalLogger||(_globalLogger=new Logger(version$2)),_globalLogger}static setCensorship(o,tt){if(!o&&tt&&this.globalLogger().throwError("cannot permanently disable censorship",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),_permanentCensorErrors){if(!o)return;this.globalLogger().throwError("error censorship permanent",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}_censorErrors=!!o,_permanentCensorErrors=!!tt}static setLogLevel(o){const tt=LogLevels[o.toLowerCase()];if(tt==null){Logger.globalLogger().warn("invalid log level - "+o);return}_logLevel=tt}static from(o){return new Logger(o)}}Logger.errors=ErrorCode;Logger.levels=LogLevel;const version$1="bytes/5.7.0",logger$1=new Logger(version$1);function isHexable(et){return!!et.toHexString}function addSlice(et){return et.slice||(et.slice=function(){const o=Array.prototype.slice.call(arguments);return addSlice(new Uint8Array(Array.prototype.slice.apply(et,o)))}),et}function isBytesLike(et){return isHexString(et)&&!(et.length%2)||isBytes(et)}function isInteger(et){return typeof et=="number"&&et==et&&et%1===0}function isBytes(et){if(et==null)return!1;if(et.constructor===Uint8Array)return!0;if(typeof et=="string"||!isInteger(et.length)||et.length<0)return!1;for(let o=0;o=256)return!1}return!0}function arrayify(et,o){if(o||(o={}),typeof et=="number"){logger$1.checkSafeUint53(et,"invalid arrayify value");const tt=[];for(;et;)tt.unshift(et&255),et=parseInt(String(et/256));return tt.length===0&&tt.push(0),addSlice(new Uint8Array(tt))}if(o.allowMissingPrefix&&typeof et=="string"&&et.substring(0,2)!=="0x"&&(et="0x"+et),isHexable(et)&&(et=et.toHexString()),isHexString(et)){let tt=et.substring(2);tt.length%2&&(o.hexPad==="left"?tt="0"+tt:o.hexPad==="right"?tt+="0":logger$1.throwArgumentError("hex data is odd-length","value",et));const rt=[];for(let nt=0;nt>4]+HexCharacters[nt&15]}return tt}return logger$1.throwArgumentError("invalid hexlify value","value",et)}const version="rlp/5.7.0",logger=new Logger(version);function arrayifyInteger(et){const o=[];for(;et;)o.unshift(et&255),et>>=8;return o}function unarrayifyInteger(et,o,tt){let rt=0;for(let nt=0;nto+1+rt&&logger.throwError("child data too short",Logger.errors.BUFFER_OVERRUN,{})}return{consumed:1+rt,result:nt}}function _decode(et,o){if(et.length===0&&logger.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{}),et[o]>=248){const tt=et[o]-247;o+1+tt>et.length&&logger.throwError("data short segment too short",Logger.errors.BUFFER_OVERRUN,{});const rt=unarrayifyInteger(et,o+1,tt);return o+1+tt+rt>et.length&&logger.throwError("data long segment too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(et,o,o+1+tt,tt+rt)}else if(et[o]>=192){const tt=et[o]-192;return o+1+tt>et.length&&logger.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(et,o,o+1,tt)}else if(et[o]>=184){const tt=et[o]-183;o+1+tt>et.length&&logger.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const rt=unarrayifyInteger(et,o+1,tt);o+1+tt+rt>et.length&&logger.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const nt=hexlify(et.slice(o+1+tt,o+1+tt+rt));return{consumed:1+tt+rt,result:nt}}else if(et[o]>=128){const tt=et[o]-128;o+1+tt>et.length&&logger.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{});const rt=hexlify(et.slice(o+1,o+1+tt));return{consumed:1+tt,result:rt}}return{consumed:1,result:hexlify(et[o])}}function decode$8(et){const o=arrayify(et),tt=_decode(o,0);return tt.consumed!==o.length&&logger.throwArgumentError("invalid rlp data","data",et),tt.result}function base$1(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$2=base$1,_brrp__multiformats_scope_baseX$1=src$2;const coerce$2=et=>{if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")},fromString$3=et=>new TextEncoder().encode(et),toString$8=et=>new TextDecoder().decode(et);let Encoder$1=class{constructor(o,tt,rt){this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$1=class{constructor(o,tt,rt){if(this.name=o,this.prefix=tt,tt.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=tt.codePointAt(0),this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$1(this,o)}},ComposedDecoder$1=class{constructor(o){this.decoders=o}or(o){return or$1(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const or$1=(et,o)=>new ComposedDecoder$1({...et.decoders||{[et.prefix]:et},...o.decoders||{[o.prefix]:o}});let Codec$1=class{constructor(o,tt,rt,nt){this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$1(o,tt,rt),this.decoder=new Decoder$1(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};const from$2=({name:et,prefix:o,encode:tt,decode:rt})=>new Codec$1(et,o,tt,rt),baseX$1=({prefix:et,name:o,alphabet:tt})=>{const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$1(tt,o);return from$2({prefix:et,name:o,encode:rt,decode:ot=>coerce$2(nt(ot))})},decode$7=(et,o,tt,rt)=>{const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it},encode$6=(et,o,tt)=>{const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it&&(ot+=o[nt&st<from$2({prefix:o,name:et,encode(nt){return encode$6(nt,rt,tt)},decode(nt){return decode$7(nt,rt,tt,et)}}),identity$1=from$2({prefix:"\0",name:"identity",encode:et=>toString$8(et),decode:et=>fromString$3(et)}),identityBase$1=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$1},Symbol.toStringTag,{value:"Module"})),base2$2=rfc4648$1({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$3=Object.freeze(Object.defineProperty({__proto__:null,base2:base2$2},Symbol.toStringTag,{value:"Module"})),base8$2=rfc4648$1({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$3=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$2},Symbol.toStringTag,{value:"Module"})),base10$2=baseX$1({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$3=Object.freeze(Object.defineProperty({__proto__:null,base10:base10$2},Symbol.toStringTag,{value:"Module"})),base16$2=rfc4648$1({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper$1=rfc4648$1({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$3=Object.freeze(Object.defineProperty({__proto__:null,base16:base16$2,base16upper:base16upper$1},Symbol.toStringTag,{value:"Module"})),base32$4=rfc4648$1({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$1=rfc4648$1({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$1=rfc4648$1({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$1=rfc4648$1({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$1=rfc4648$1({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$1=rfc4648$1({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$1=rfc4648$1({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$1=rfc4648$1({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$1=rfc4648$1({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$5=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$4,base32hex:base32hex$1,base32hexpad:base32hexpad$1,base32hexpadupper:base32hexpadupper$1,base32hexupper:base32hexupper$1,base32pad:base32pad$1,base32padupper:base32padupper$1,base32upper:base32upper$1,base32z:base32z$1},Symbol.toStringTag,{value:"Module"})),base36$2=baseX$1({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$1=baseX$1({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$3=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$2,base36upper:base36upper$1},Symbol.toStringTag,{value:"Module"})),base58btc$1=baseX$1({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$1=baseX$1({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$1=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$1,base58flickr:base58flickr$1},Symbol.toStringTag,{value:"Module"})),base64$4=rfc4648$1({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$1=rfc4648$1({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$1=rfc4648$1({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$1=rfc4648$1({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$5=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$4,base64pad:base64pad$1,base64url:base64url$1,base64urlpad:base64urlpad$1},Symbol.toStringTag,{value:"Module"})),alphabet$1=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),alphabetBytesToChars$1=alphabet$1.reduce((et,o,tt)=>(et[tt]=o,et),[]),alphabetCharsToBytes$1=alphabet$1.reduce((et,o,tt)=>(et[o.codePointAt(0)]=tt,et),[]);function encode$5(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$1[tt],o),"")}function decode$6(et){const o=[];for(const tt of et){const rt=alphabetCharsToBytes$1[tt.codePointAt(0)];if(rt===void 0)throw new Error(`Non-base256emoji character: ${tt}`);o.push(rt)}return new Uint8Array(o)}const base256emoji$2=from$2({prefix:"🚀",name:"base256emoji",encode:encode$5,decode:decode$6}),base256emoji$3=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$2},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$1={...identityBase$1,...base2$3,...base8$3,...base10$3,...base16$3,...base32$5,...base36$3,...base58$1,...base64$5,...base256emoji$3};function createCodec$1(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$4=createCodec$1("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$1=createCodec$1("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$h(et.length);for(let tt=0;ttv4Regex$1.test(et),encode(et,o,tt){tt=~~tt,o=o||new Uint8Array(tt+v4Size);const rt=et.length;let nt=0;for(let ot=0;otet.length>0&&v6Regex$1.test(et),encode(et,o,tt){tt=~~tt;let rt=tt+v6Size,nt=-1,ot=0,it=0,st=!0,at=!1;o=o||new Uint8Array(tt+v6Size);for(let ct=0;ct>8),tt=97?lt-=87:lt>=65?lt-=55:(lt-=48,it=it*10+lt),ot=(ot<<4)+lt)}if(st===!1)at===!0?(tt>8),tt=nt+2;ct--)o[ct]=o[ct-2];o[nt]=0,o[nt+1]=0,nt=tt}if(nt!==tt&&nt!==-1)for(tt>rt-2&&(tt=rt-2);rt>nt;)o[--rt]=ttnt?o[--tt]:0;else for(;tt=SURROGATE_B||(et.charCodeAt(ot)&64512)!==SURROGATE_B?o+=3:(rt=ot,o+=4)}}return o}function encode$3(et,o,tt){const rt=et.length;tt==null&&(tt=0),o===void 0&&(o=new Uint8Array(encodingLength$1(et)+tt));let nt=tt;for(let ot=0;ot>6,o[nt++]=128|it&63;else if((it&63488)!==SURROGATE_A)o[nt++]=224|(it&61440)>>12,o[nt++]=128|(it&4032)>>6,o[nt++]=128|it&63;else{const st=ot+1;if(st===rt||it>=SURROGATE_B)o[nt++]=239,o[nt++]=191,o[nt++]=189;else{const at=et.charCodeAt(st);(at&64512)!==SURROGATE_B?(o[nt++]=239,o[nt++]=191,o[nt++]=189):(ot=st,it=65536|(it&1023)<<10|at&1023,o[nt++]=240|(it&1835008)>>18,o[nt++]=128|(it&258048)>>12,o[nt++]=128|(it&4032)>>6,o[nt++]=128|it&63)}}}return encode$3.bytes=nt-tt,o}encode$3.bytes=0;function decode$4(et,o,tt){let rt="";o==null&&(o=0),tt==null&&(tt=et.length);for(let nt=o;nt191&&ot<224)it=(ot&31)<<6|et[nt++]&63;else if(ot>239&&ot<365){it=((ot&7)<<18|(et[nt++]&63)<<12|(et[nt++]&63)<<6|et[nt++]&63)-65536;const st=SURROGATE_A|it>>10&1023;rt+=String.fromCharCode(st),it=SURROGATE_B|it&1023}else it=(ot&15)<<12|(et[nt++]&63)<<6|et[nt++]&63;rt+=String.fromCharCode(it)}return decode$4.bytes=tt-o,rt}decode$4.bytes=0;const isU8Arr=et=>et instanceof Uint8Array;function bytelength(et){return typeof et=="string"?encodingLength$1(et):et.byteLength}function from$1(et){return et instanceof Uint8Array?et:Array.isArray(et)?new Uint8Array(et):encode$3(et)}function write(et,o,tt){if(typeof o!="string")throw new Error("unknown input type");return encode$3(o,et,tt),encode$3.bytes}const P_24=Math.pow(2,24),P_16=Math.pow(2,16),P_8=Math.pow(2,8),readUInt32BE=(et,o)=>et[o]*P_24+et[o+1]*P_16+et[o+2]*P_8+et[o+3],readUInt16BE=(et,o)=>et[o]<<8|et[o+1],writeUInt32BE=(et,o,tt)=>(o=+o,et[tt+3]=o,o=o>>>8,et[tt+2]=o,o=o>>>8,et[tt+1]=o,o=o>>>8,et[tt]=o,tt+4),writeUInt16BE=(et,o,tt)=>(et[tt]=o>>8,et[tt+1]=o&255,tt+2);function copy(et,o,tt,rt,nt){return tt<0&&(rt-=tt,tt=0),rt<0&&(rt=0),nt<0?new Uint8Array(0):tt>=o.length||rt>=nt?0:_copyActual(et,o,tt,rt,nt)}function _copyActual(et,o,tt,rt,nt){nt-rt>o.length-tt&&(nt=rt+o.length-tt);let ot=nt-rt;const it=et.length-rt;return ot>it&&(ot=it),(rt!==0||ntet)}}const name$1=codec({encode(et,o,tt){o||(o=new Uint8Array(name$1.encodingLength(et))),tt||(tt=0);const rt=tt,nt=et.replace(/^\.|\.$/gm,"");if(nt.length){const ot=nt.split(".");for(let it=0;it=et.length)throw new Error("Cannot decode name (buffer overflow)");const st=et[o++];if(ot+=it?0:1,st===0)break;if(st&192)if((st&192)===192){if(o+1>et.length)throw new Error("Cannot decode name (buffer overflow)");const at=readUInt16BE(et,o-1)-49152;if(at>=rt)throw new Error("Cannot decode name (bad pointer)");o=at,rt=at,ot+=it?0:1,it=!0}else throw new Error("Cannot decode name (bad label)");else{if(o+st>et.length)throw new Error("Cannot decode name (buffer overflow)");if(nt+=st+1,nt>254)throw new Error("Cannot decode name (name too long)");tt.push(decode$4(et,o,o+st)),o+=st,ot+=it?0:st}}return name$1.decode.bytes=ot,tt.length===0?".":tt.join(".")},encodingLength(et){return et==="."||et===".."?1:bytelength(et.replace(/^\.|\.$/gm,""))+2}}),string$3=codec({encode(et,o,tt){o||(o=new Uint8Array(string$3.encodingLength(et))),tt||(tt=0);const rt=write(o,et,tt+1);return o[tt]=rt,string$3.encode.bytes=rt+1,o},decode(et,o){o||(o=0);const tt=et[o],rt=decode$4(et,o+1,o+1+tt);return string$3.decode.bytes=tt+1,rt},encodingLength(et){return bytelength(et)+1}}),header=codec({bytes:12,encode(et,o,tt){o||(o=new Uint8Array(header.encodingLength(et))),tt||(tt=0);const rt=(et.flags||0)&32767,nt=et.type==="response"?RESPONSE_FLAG:QUERY_FLAG;return writeUInt16BE(o,et.id||0,tt),writeUInt16BE(o,rt|nt,tt+2),writeUInt16BE(o,et.questions.length,tt+4),writeUInt16BE(o,et.answers.length,tt+6),writeUInt16BE(o,et.authorities.length,tt+8),writeUInt16BE(o,et.additionals.length,tt+10),o},decode(et,o){if(o||(o=0),et.length<12)throw new Error("Header must be 12 bytes");const tt=readUInt16BE(et,o+2);return{id:readUInt16BE(et,o),type:tt&RESPONSE_FLAG?"response":"query",flags:tt&32767,flag_qr:(tt>>15&1)===1,opcode:toString$5(tt>>11&15),flag_aa:(tt>>10&1)===1,flag_tc:(tt>>9&1)===1,flag_rd:(tt>>8&1)===1,flag_ra:(tt>>7&1)===1,flag_z:(tt>>6&1)===1,flag_ad:(tt>>5&1)===1,flag_cd:(tt>>4&1)===1,rcode:toString$6(tt&15),questions:new Array(readUInt16BE(et,o+4)),answers:new Array(readUInt16BE(et,o+6)),authorities:new Array(readUInt16BE(et,o+8)),additionals:new Array(readUInt16BE(et,o+10))}},encodingLength(){return 12}}),runknown=codec({encode(et,o,tt){o||(o=new Uint8Array(runknown.encodingLength(et))),tt||(tt=0);const rt=et.length;return writeUInt16BE(o,rt,tt),copy(et,o,tt+2,0,rt),runknown.encode.bytes=rt+2,o},decode(et,o){o||(o=0);const tt=readUInt16BE(et,o),rt=et.slice(o+2,o+2+tt);return runknown.decode.bytes=tt+2,rt},encodingLength(et){return et.length+2}}),rns=codec({encode(et,o,tt){return o||(o=new Uint8Array(rns.encodingLength(et))),tt||(tt=0),name$1.encode(et,o,tt+2),writeUInt16BE(o,name$1.encode.bytes,tt),rns.encode.bytes=name$1.encode.bytes+2,o},decode(et,o){o||(o=0);const tt=readUInt16BE(et,o),rt=name$1.decode(et,o+2);return rns.decode.bytes=tt+2,rt},encodingLength(et){return name$1.encodingLength(et)+2}}),rsoa=codec({encode(et,o,tt){o||(o=new Uint8Array(rsoa.encodingLength(et))),tt||(tt=0);const rt=tt;return tt+=2,name$1.encode(et.mname,o,tt),tt+=name$1.encode.bytes,name$1.encode(et.rname,o,tt),tt+=name$1.encode.bytes,writeUInt32BE(o,et.serial||0,tt),tt+=4,writeUInt32BE(o,et.refresh||0,tt),tt+=4,writeUInt32BE(o,et.retry||0,tt),tt+=4,writeUInt32BE(o,et.expire||0,tt),tt+=4,writeUInt32BE(o,et.minimum||0,tt),tt+=4,writeUInt16BE(o,tt-rt-2,rt),rsoa.encode.bytes=tt-rt,o},decode(et,o){o||(o=0);const tt=o,rt={};return o+=2,rt.mname=name$1.decode(et,o),o+=name$1.decode.bytes,rt.rname=name$1.decode(et,o),o+=name$1.decode.bytes,rt.serial=readUInt32BE(et,o),o+=4,rt.refresh=readUInt32BE(et,o),o+=4,rt.retry=readUInt32BE(et,o),o+=4,rt.expire=readUInt32BE(et,o),o+=4,rt.minimum=readUInt32BE(et,o),o+=4,rsoa.decode.bytes=o-tt,rt},encodingLength(et){return 22+name$1.encodingLength(et.mname)+name$1.encodingLength(et.rname)}}),rtxt=codec({encode(et,o,tt){Array.isArray(et)||(et=[et]);for(let nt=0;nt0;){const ot=et[o++];if(--rt,rtnew Uint8Array(et),roption=codec({encode(et,o,tt){o||(o=new Uint8Array(roption.encodingLength(et))),tt||(tt=0);const rt=tt,nt=toCode(et.code);if(writeUInt16BE(o,nt,tt),tt+=2,et.data)writeUInt16BE(o,et.data.length,tt),tt+=2,copy(et.data,o,tt),tt+=et.data.length;else switch(nt){case 8:{const ot=et.sourcePrefixLength||0,it=et.family||familyOf(et.ip),st=encode$4(et.ip,alloc),at=Math.ceil(ot/8);writeUInt16BE(o,at+4,tt),tt+=2,writeUInt16BE(o,it,tt),tt+=2,o[tt++]=ot,o[tt++]=et.scopePrefixLength||0,copy(st,o,tt,0,at),tt+=at}break;case 11:et.timeout?(writeUInt16BE(o,2,tt),tt+=2,writeUInt16BE(o,et.timeout,tt),tt+=2):(writeUInt16BE(o,0,tt),tt+=2);break;case 12:{const ot=et.length||0;writeUInt16BE(o,ot,tt),tt+=2,o.fill(0,tt,tt+ot),tt+=ot}break;case 14:{const ot=et.tags.length*2;writeUInt16BE(o,ot,tt),tt+=2;for(const it of et.tags)writeUInt16BE(o,it,tt),tt+=2}break;default:throw new Error(`Unknown roption code: ${et.code}`)}return roption.encode.bytes=tt-rt,o},decode(et,o){o||(o=0);const tt={};tt.code=readUInt16BE(et,o),tt.type=toString$3(tt.code),o+=2;const rt=readUInt16BE(et,o);switch(o+=2,tt.data=et.slice(o,o+rt),tt.code){case 8:tt.family=readUInt16BE(et,o),o+=2,tt.sourcePrefixLength=et[o++],tt.scopePrefixLength=et[o++];{const nt=new Uint8Array(tt.family===1?4:16);copy(et,nt,0,o,o+rt-4),tt.ip=decode$5(nt)}break;case 11:rt>0&&(tt.timeout=readUInt16BE(et,o),o+=2);break;case 14:tt.tags=[];for(let nt=0;nt0;)rt[ot++]=roption.decode(et,o),o+=roption.decode.bytes,nt-=roption.decode.bytes;return ropt.decode.bytes=o-tt,rt},encodingLength(et){return 2+encodingLengthList(et||[],roption)}}),rdnskey=codec({encode(et,o,tt){o||(o=new Uint8Array(rdnskey.encodingLength(et))),tt||(tt=0);const rt=tt,nt=et.key;if(!isU8Arr(nt))throw new Error("Key must be a Buffer");return tt+=2,writeUInt16BE(o,et.flags,tt),tt+=2,o[tt]=rdnskey.PROTOCOL_DNSSEC,tt+=1,o[tt]=et.algorithm,tt+=1,copy(nt,o,tt,0,nt.length),tt+=nt.length,rdnskey.encode.bytes=tt-rt,writeUInt16BE(o,rdnskey.encode.bytes-2,rt),o},decode(et,o){o||(o=0);const tt=o,rt={},nt=readUInt16BE(et,o);if(o+=2,rt.flags=readUInt16BE(et,o),o+=2,et[o]!==rdnskey.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return o+=1,rt.algorithm=et[o],o+=1,rt.key=et.slice(o,tt+nt+2),o+=rt.key.length,rdnskey.decode.bytes=o-tt,rt},encodingLength(et){return 6+bytelength(et.key)}});rdnskey.PROTOCOL_DNSSEC=3;rdnskey.ZONE_KEY=128;rdnskey.SECURE_ENTRYPOINT=32768;const rrrsig=codec({encode(et,o,tt){o||(o=new Uint8Array(rrrsig.encodingLength(et))),tt||(tt=0);const rt=tt,nt=et.signature;if(!isU8Arr(nt))throw new Error("Signature must be a Buffer");return tt+=2,writeUInt16BE(o,toType(et.typeCovered),tt),tt+=2,o[tt]=et.algorithm,tt+=1,o[tt]=et.labels,tt+=1,writeUInt32BE(o,et.originalTTL,tt),tt+=4,writeUInt32BE(o,et.expiration,tt),tt+=4,writeUInt32BE(o,et.inception,tt),tt+=4,writeUInt16BE(o,et.keyTag,tt),tt+=2,name$1.encode(et.signersName,o,tt),tt+=name$1.encode.bytes,copy(nt,o,tt,0,nt.length),tt+=nt.length,rrrsig.encode.bytes=tt-rt,writeUInt16BE(o,rrrsig.encode.bytes-2,rt),o},decode(et,o){o||(o=0);const tt=o,rt={},nt=readUInt16BE(et,o);return o+=2,rt.typeCovered=toString$7(readUInt16BE(et,o)),o+=2,rt.algorithm=et[o],o+=1,rt.labels=et[o],o+=1,rt.originalTTL=readUInt32BE(et,o),o+=4,rt.expiration=readUInt32BE(et,o),o+=4,rt.inception=readUInt32BE(et,o),o+=4,rt.keyTag=readUInt16BE(et,o),o+=2,rt.signersName=name$1.decode(et,o),o+=name$1.decode.bytes,rt.signature=et.slice(o,tt+nt+2),o+=rt.signature.length,rrrsig.decode.bytes=o-tt,rt},encodingLength(et){return 20+name$1.encodingLength(et.signersName)+bytelength(et.signature)}}),rrp=codec({encode(et,o,tt){o||(o=new Uint8Array(rrp.encodingLength(et))),tt||(tt=0);const rt=tt;return tt+=2,name$1.encode(et.mbox||".",o,tt),tt+=name$1.encode.bytes,name$1.encode(et.txt||".",o,tt),tt+=name$1.encode.bytes,rrp.encode.bytes=tt-rt,writeUInt16BE(o,rrp.encode.bytes-2,rt),o},decode(et,o){o||(o=0);const tt=o,rt={};return o+=2,rt.mbox=name$1.decode(et,o)||".",o+=name$1.decode.bytes,rt.txt=name$1.decode(et,o)||".",o+=name$1.decode.bytes,rrp.decode.bytes=o-tt,rt},encodingLength(et){return 2+name$1.encodingLength(et.mbox||".")+name$1.encodingLength(et.txt||".")}}),typebitmap=codec({encode(et,o,tt){o||(o=new Uint8Array(typebitmap.encodingLength(et))),tt||(tt=0);const rt=tt,nt=[];for(let ot=0;ot>8]===void 0&&(nt[it>>8]=[]),nt[it>>8][it>>3&31]|=1<<7-(it&7)}for(let ot=0;ot>8]=Math.max(o[nt>>8]||0,nt&255)}let tt=0;for(let rt=0;rt>15&1)===1,tt.options=ropt.decode(et,o+8),o+=8+ropt.decode.bytes;else{const nt=readUInt16BE(et,o+2);tt.ttl=readUInt32BE(et,o+4),tt.class=toString$4(nt&NOT_FLUSH_MASK),tt.flush=!!(nt&FLUSH_MASK);const ot=renc(tt.type);tt.data=ot.decode(et,o+8),o+=8+ot.decode.bytes}return answer.decode.bytes=o-rt,tt},encodingLength(et){const o=et.data!==null&&et.data!==void 0?et.data:et.options;return name$1.encodingLength(et.name)+8+renc(et.type).encodingLength(o)}}),question=codec({encode(et,o,tt){o||(o=new Uint8Array(question.encodingLength(et))),tt||(tt=0);const rt=tt;return name$1.encode(et.name,o,tt),tt+=name$1.encode.bytes,writeUInt16BE(o,toType(et.type),tt),tt+=2,writeUInt16BE(o,toClass(et.class===void 0?"IN":et.class),tt),tt+=2,question.encode.bytes=tt-rt,et},decode(et,o){o||(o=0);const tt=o,rt={};return rt.name=name$1.decode(et,o),o+=name$1.decode.bytes,rt.type=toString$7(readUInt16BE(et,o)),o+=2,rt.class=toString$4(readUInt16BE(et,o)),o+=2,!!(rt.class&QU_MASK)&&(rt.class&=NOT_QU_MASK),question.decode.bytes=o-tt,rt},encodingLength(et){return name$1.encodingLength(et.name)+4}}),RECURSION_DESIRED=256,packet={encode:function(et,o,tt){const rt=!o;rt&&(o=new Uint8Array(encodingLength(et))),tt||(tt=0);const nt=tt;return et.questions||(et.questions=[]),et.answers||(et.answers=[]),et.authorities||(et.authorities=[]),et.additionals||(et.additionals=[]),header.encode(et,o,tt),tt+=header.encode.bytes,tt=encodeList(et.questions,question,o,tt),tt=encodeList(et.answers,answer,o,tt),tt=encodeList(et.authorities,answer,o,tt),tt=encodeList(et.additionals,answer,o,tt),packet.encode.bytes=tt-nt,rt&&encode$2.bytes!==o.length?o.slice(0,encode$2.bytes):o},decode:function(et,o){o||(o=0);const tt=o,rt=header.decode(et,o);return o+=header.decode.bytes,o=decodeList(rt.questions,question,et,o),o=decodeList(rt.answers,answer,et,o),o=decodeList(rt.authorities,answer,et,o),o=decodeList(rt.additionals,answer,et,o),packet.decode.bytes=o-tt,rt},encodingLength:function(et){return header.encodingLength(et)+encodingLengthList(et.questions||[],question)+encodingLengthList(et.answers||[],answer)+encodingLengthList(et.authorities||[],answer)+encodingLengthList(et.additionals||[],answer)}};packet.encode.bytes=0;packet.decode.bytes=0;const encode$2=packet.encode,decode$3=packet.decode,encodingLength=packet.encodingLength;function encodingLengthList(et,o){let tt=0;for(let rt=0;rt255)throw new Error(`Character #${at} in charset [code=${ct}, char=${o.charAt(at)}] is too high! (max=255)`);if(nt[ct]!==0)throw new Error(`Character [code=${ct}, char=${o.charAt(at)}] is more than once in the charset!`);nt[ct]=at,ot[at]=ct}const it=tt.charCodeAt(0),st={name:et,encodingLength(at){const ct=at.length,lt=ct*.75|0;return at.charCodeAt(ct-1)===it?at.charCodeAt(ct-2)===it?lt-2:lt-1:lt},encode(at,ct,lt){ct==null&&(ct=new Uint8Array(st.encodingLength(at))),lt==null&&(lt=0);let dt=at.length;at.charCodeAt(dt-1)===it&&(at.charCodeAt(dt-2)===it?dt-=2:dt-=1);const ht=dt%4,mt=dt-ht;let ft=lt,pt=0;for(;pt>16,ct[ft++]=gt>>8,ct[ft++]=gt,pt+=4}if(ht===3){const gt=nt[at.charCodeAt(pt)]<<10|nt[at.charCodeAt(pt+1)]<<4|nt[at.charCodeAt(pt+2)]>>2;ct[ft++]=gt>>8,ct[ft++]=gt}else ht===2&&(ct[ft++]=nt[at.charCodeAt(pt)]<<2|nt[at.charCodeAt(pt+1)]>>4);return st.encode.bytes=ft-lt,ct},decode(at,ct,lt){ct==null&&(ct=0),lt==null&&(lt=at.length);const dt=lt-ct,ht=dt%3,mt=ct+dt-ht,ft=[];for(let pt=ct;pt>18&63],ot[gt>>12&63],ot[gt>>6&63],ot[gt&63])}if(ht===2){const pt=(at[lt-2]<<8)+at[lt-1];ft.push(ot[pt>>10],ot[pt>>4&63],ot[pt<<2&63]),rt===PREFERS_PADDING&&ft.push(it)}else if(ht===1){const pt=at[lt-1];ft.push(ot[pt>>2],ot[pt<<4&63]),rt===PREFERS_PADDING&&ft.push(it,it)}return st.decode.bytes=dt,String.fromCharCode.apply(String,ft)}};return st}make("base64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/","=",PREFERS_PADDING);const base64URL=make("base64-url","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_","=",PREFERS_NO_PADDING);let AbortError=typeof global<"u"?global.AbortError:typeof window<"u"?window.AbortError:null;AbortError||(AbortError=class extends Error{constructor(o="Request aborted."){super(o)}});AbortError.prototype.name="AbortError";AbortError.prototype.code="ABORT_ERR";const URL$1=typeof globalThis<"u"&&globalThis.URL||require("url").URL;class HTTPStatusError extends Error{constructor(o,tt,rt){super("status="+tt+" while requesting "+o+" ["+rt+"]"),this.uri=o,this.status=tt,this.method=rt}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";class ResponseError extends Error{constructor(o,tt){super(o),this.cause=tt}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:reduceError(this.cause)}}}ResponseError.prototype.name="ResponseError";ResponseError.prototype.code="RESPONSE_ERR";class TimeoutError extends Error{constructor(o){super("Timeout (t="+o+")."),this.timeout=o}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}TimeoutError.prototype.name="TimeoutError";TimeoutError.prototype.code="ETIMEOUT";const v4Regex=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,v6Regex=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function reduceError(et){if(typeof et=="string")return{message:et};try{const tt=JSON.stringify(et);if(tt!=="{}")return JSON.parse(tt)}catch{}const o={message:String(et.message||et)};return et.code!==void 0&&(o.code=String(et.code)),o}const baseParts=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,httpFlags=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/ig,updFlags=/\[(((pk|name)=([^\]]+)))\]/ig;function parseEndpoint(et){const o=baseParts.exec(et),tt=o[2]||"https:",rt=o[3],nt=o[5],ot=o[6],it=o[7];if(tt==="https:"||tt==="http:"){const st=parseFlags(it,httpFlags);return{name:st.name,protocol:tt,ipv4:st.ipv4,ipv6:st.ipv6,host:rt,port:nt,path:ot,method:st.post?"POST":"GET"}}if(tt==="udp:"||tt==="udp4:"||tt==="udp6:"){const st=parseFlags(it,updFlags),at=/^\[(.*)\]$/.exec(rt);if(at&&tt==="udp4:")throw new Error(`Endpoint parsing error: Cannot use ipv6 host with udp4: (endpoint=${et})`);if(!at&&tt==="udp6:")throw new Error(`Endpoint parsing error: Incorrectly formatted host for udp6: (endpoint=${et})`);return at?new UDP6Endpoint({protocol:"udp6:",ipv6:at[1],port:nt,pk:st.pk,name:st.name}):new UDP4Endpoint({protocol:"udp4:",ipv4:rt,port:nt,pk:st.pk,name:st.name})}throw new InvalidProtocolError(tt,et)}function parseFlags(et,o){o.lastIndex=0;const tt={};for(;;){const rt=o.exec(et);if(!rt)break;rt[2]?tt[rt[3].toLowerCase()]=rt[4]:tt[rt[1].toLowerCase()]=!0}return tt}class InvalidProtocolError extends Error{constructor(o,tt){super(`Invalid Endpoint: unsupported protocol "${o}" for endpoint: ${tt}, supported protocols: ${supportedProtocols.join(", ")}`),this.protocol=o,this.endpoint=tt}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}InvalidProtocolError.prototype.name="InvalidProtocolError";InvalidProtocolError.prototype.code="EPROTOCOL";const supportedProtocols=["http:","https:","udp4:","udp6:"];class BaseEndpoint{constructor(o,tt){this.name=o.name||null,this.protocol=o.protocol;const rt=typeof o.port=="string"?o.port=parseInt(o.port,10):o.port;if(rt==null)this.port=tt?this.protocol==="https:"?443:80:o.pk?443:53;else{if(typeof rt!="number"&&!isNaN(rt))throw new Error(`Invalid Endpoint: port "${o.port}" needs to be a number: ${JSON.stringify(o)}`);this.port=rt}}toJSON(){return this.toString()}}class UDPEndpoint extends BaseEndpoint{constructor(o){super(o,!1),this.pk=o.pk||null}toString(){const o=this.port!==(this.pk?443:53)?`:${this.port}`:"",tt=this.pk?` [pk=${this.pk}]`:"",rt=this.name?` [name=${this.name}]`:"";return`udp://${this.ipv4||`[${this.ipv6}]`}${o}${tt}${rt}`}}class UDP4Endpoint extends UDPEndpoint{constructor(o){if(super(Object.assign({protocol:"udp4:"},o)),!o.ipv4||typeof o.ipv4!="string")throw new Error(`Invalid Endpoint: .ipv4 "${o.ipv4}" needs to be set: ${JSON.stringify(o)}`);this.ipv4=o.ipv4}}class UDP6Endpoint extends UDPEndpoint{constructor(o){if(super(Object.assign({protocol:"udp6:"},o)),!o.ipv6||typeof o.ipv6!="string")throw new Error(`Invalid Endpoint: .ipv6 "${o.ipv6}" needs to be set: ${JSON.stringify(o)}`);this.ipv6=o.ipv6}}function safeHost(et){return v6Regex.test(et)&&!v4Regex.test(et)?`[${et}]`:et}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||typeof o.host!="string")throw new 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){const rt=v6Regex.exec(this.host);rt&&(this.ipv6=rt[1])}this.ipv4||v4Regex.test(this.host)&&(this.ipv4=this.host);const tt=`${this.protocol}//${safeHost(this.host)}:${this.port}${this.path}`;try{this.url=new URL$1(tt)}catch(rt){throw new Error(rt.message+` [${tt}]`)}}toString(){const o=this.protocol==="https:"?"":"http://",tt=this.port!==(this.protocol==="https:"?443:80)?`:${this.port}`:"",rt=this.method!=="GET"?" [post]":"",nt=this.path==="/dns-query"?"":this.path,ot=this.name?` [name=${this.name}]`:"",it=this.ipv4&&this.ipv4!==this.host?` [ipv4=${this.ipv4}]`:"",st=this.ipv6&&this.ipv6!==this.host?` [ipv6=${this.ipv6}]`:"";return`${o}${safeHost(this.host)}${tt}${nt}${rt}${it}${st}${ot}`}}function toEndpoint(et){let o;if(typeof et=="string")o=parseEndpoint(et);else{if(typeof et!="object"||et===null||Array.isArray(et))throw new Error(`Can not convert ${et} to an endpoint`);if(et instanceof BaseEndpoint)return et;o=et}(o.protocol===null||o.protocol===void 0)&&(o.protocol="https:");const tt=o.protocol;if(tt==="udp4:")return new UDP4Endpoint(o);if(tt==="udp6:")return new UDP6Endpoint(o);if(tt==="https:"||tt==="http:")return new HTTPEndpoint(o);throw new InvalidProtocolError(tt,JSON.stringify(o))}const contentType="application/dns-message";function noop$1(){}function queryDns(){throw new Error('Only "doh" endpoints are supported in the browser')}async function loadJSON(et,o,tt,rt){const nt=o?o.localStoragePrefix+o.name:null;if(nt)try{const st=JSON.parse(localStorage.getItem(nt));if(st&&st.time>o.maxTime)return st}catch{}const{data:ot}=await requestRaw(et,"GET",null,tt,rt),it={time:Date.now(),data:JSON.parse(decode$4(ot))};if(nt)try{localStorage.setItem(nt,JSON.stringify(it))}catch{it.time=null}return it}function requestRaw(et,o,tt,rt,nt){return new Promise((ot,it)=>{const st=new URL$1(et);o==="GET"&&tt&&(st.search="?dns="+base64URL.decode(tt));const at=st.toString(),ct=new XMLHttpRequest;ct.open(o,at,!0),ct.setRequestHeader("Accept",contentType),o==="POST"&&ct.setRequestHeader("Content-Type",contentType),ct.responseType="arraybuffer",ct.timeout=rt,ct.ontimeout=lt,ct.onreadystatechange=ht,ct.onerror=ft,ct.onload=dt,o==="POST"?ct.send(tt):ct.send(),nt&&nt.addEventListener("abort",pt);function lt(){mt(new TimeoutError(rt));try{ct.abort()}catch{}}function dt(){if(ct.status!==200)mt(new HTTPStatusError(at,ct.status,o));else{let gt;if(typeof ct.response=="string")gt=encode$3(ct.response);else if(ct.response instanceof Uint8Array)gt=ct.response;else if(Array.isArray(ct.response)||ct.response instanceof ArrayBuffer)gt=new Uint8Array(ct.response);else throw new Error("Unprocessable response "+ct.response);mt(null,gt)}}function ht(){if(ct.readyState>1&&ct.status!==200&&ct.status!==0){mt(new HTTPStatusError(at,ct.status,o));try{ct.abort()}catch{}}}let mt=function(gt,yt){mt=noop$1,nt&&nt.removeEventListener("abort",pt),ot(gt?{error:gt,response:ct}:{data:yt,response:ct})};function ft(){mt(ct.status===200?new Error("Inexplicable XHR Error"):new HTTPStatusError(at,ct.status,o))}function pt(){mt(new AbortError);try{ct.abort()}catch{}}})}function request(et,o,tt,rt,nt){return requestRaw(et,o,tt,rt,nt)}function processResolvers$1(et){return et.filter(o=>o.cors||o.endpoint.cors)}const resolvers={data:[{name:"adfree.usableprivacy.net",endpoint:{protocol:"https:",host:"adfree.usableprivacy.net"},description:`Public updns DoH service with advertising, tracker and malware filters. + */(function(){var tt="input is invalid type",rt="finalize already called",nt=typeof window=="object",ot=nt?window:{};ot.JS_SHA3_NO_WINDOW&&(nt=!1);var it=!nt&&typeof self=="object",st=!ot.JS_SHA3_NO_NODE_JS&&typeof o=="object"&&o.versions&&o.versions.node;st?ot=globalThis:it&&(ot=self);for(var at=!ot.JS_SHA3_NO_COMMON_JS&&!0&&et.exports,ct=!ot.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",lt="0123456789abcdef".split(""),dt=[31,7936,2031616,520093696],ht=[4,1024,262144,67108864],mt=[1,256,65536,16777216],ft=[6,1536,393216,100663296],pt=[0,8,16,24],yt=[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],gt=[224,256,384,512],bt=[128,256],xt=["hex","buffer","arrayBuffer","array","digest"],vt={128:168,256:136},Et=ot.JS_SHA3_NO_NODE_JS||!Array.isArray?function(_t){return Object.prototype.toString.call(_t)==="[object Array]"}:Array.isArray,Ct=ct&&(ot.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(_t){return typeof _t=="object"&&_t.buffer&&_t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,St=function(_t){var Bt=typeof _t;if(Bt==="string")return[_t,!0];if(Bt!=="object"||_t===null)throw new Error(tt);if(ct&&_t.constructor===ArrayBuffer)return[new Uint8Array(_t),!1];if(!Et(_t)&&!Ct(_t))throw new Error(tt);return[_t,!1]},At=function(_t){return St(_t)[0].length===0},kt=function(_t){for(var Bt=[],Vt=0;Vt<_t.length;++Vt)Bt[Vt]=_t[Vt];return Bt},It=function(_t,Bt,Vt){return function(er){return new Zt(_t,Bt,_t).update(er)[Vt]()}},Nt=function(_t,Bt,Vt){return function(er,ar){return new Zt(_t,Bt,ar).update(er)[Vt]()}},Lt=function(_t,Bt,Vt){return function(er,ar,ur,cr){return Pt["cshake"+_t].update(er,ar,ur,cr)[Vt]()}},Mt=function(_t,Bt,Vt){return function(er,ar,ur,cr){return Pt["kmac"+_t].update(er,ar,ur,cr)[Vt]()}},zt=function(_t,Bt,Vt,er){for(var ar=0;ar>5,this.byteCount=this.blockCount<<2,this.outputBlocks=Vt>>5,this.extraBytes=(Vt&31)>>3;for(var er=0;er<50;++er)this.s[er]=0}Zt.prototype.update=function(_t){if(this.finalized)throw new Error(rt);var Bt=St(_t);_t=Bt[0];for(var Vt=Bt[1],er=this.blocks,ar=this.byteCount,ur=_t.length,cr=this.blockCount,hr=0,Sr=this.s,pr,wr;hr>2]|=wr<>2]|=(192|wr>>6)<>2]|=(128|wr&63)<=57344?(er[pr>>2]|=(224|wr>>12)<>2]|=(128|wr>>6&63)<>2]|=(128|wr&63)<>2]|=(240|wr>>18)<>2]|=(128|wr>>12&63)<>2]|=(128|wr>>6&63)<>2]|=(128|wr&63)<>2]|=_t[hr]<=ar){for(this.start=pr-ar,this.block=er[cr],pr=0;pr>8,Vt=_t&255;Vt>0;)ar.unshift(Vt),_t=_t>>8,Vt=_t&255,++er;return Bt?ar.push(er):ar.unshift(er),this.update(ar),ar.length},Zt.prototype.encodeString=function(_t){var Bt=St(_t);_t=Bt[0];var Vt=Bt[1],er=0,ar=_t.length;if(Vt)for(var ur=0;ur<_t.length;++ur){var cr=_t.charCodeAt(ur);cr<128?er+=1:cr<2048?er+=2:cr<55296||cr>=57344?er+=3:(cr=65536+((cr&1023)<<10|_t.charCodeAt(++ur)&1023),er+=4)}else er=ar;return er+=this.encode(er*8),this.update(_t),er},Zt.prototype.bytepad=function(_t,Bt){for(var Vt=this.encode(Bt),er=0;er<_t.length;++er)Vt+=this.encodeString(_t[er]);var ar=(Bt-Vt%Bt)%Bt,ur=[];return ur.length=ar,this.update(ur),this},Zt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var _t=this.blocks,Bt=this.lastByteIndex,Vt=this.blockCount,er=this.s;if(_t[Bt>>2]|=this.padding[Bt&3],this.lastByteIndex===this.byteCount)for(_t[0]=_t[Vt],Bt=1;Bt>4&15]+lt[hr&15]+lt[hr>>12&15]+lt[hr>>8&15]+lt[hr>>20&15]+lt[hr>>16&15]+lt[hr>>28&15]+lt[hr>>24&15];ur%_t===0&&(Bt=kt(Bt),tr(Bt),ar=0)}return er&&(hr=Bt[ar],cr+=lt[hr>>4&15]+lt[hr&15],er>1&&(cr+=lt[hr>>12&15]+lt[hr>>8&15]),er>2&&(cr+=lt[hr>>20&15]+lt[hr>>16&15])),cr},Zt.prototype.arrayBuffer=function(){this.finalize();var _t=this.blockCount,Bt=this.s,Vt=this.outputBlocks,er=this.extraBytes,ar=0,ur=0,cr=this.outputBits>>3,hr;er?hr=new ArrayBuffer(Vt+1<<2):hr=new ArrayBuffer(cr);for(var Sr=new Uint32Array(hr);ur>8&255,cr[hr+2]=Sr>>16&255,cr[hr+3]=Sr>>24&255;ur%_t===0&&(Bt=kt(Bt),tr(Bt))}return er&&(hr=ur<<2,Sr=Bt[ar],cr[hr]=Sr&255,er>1&&(cr[hr+1]=Sr>>8&255),er>2&&(cr[hr+2]=Sr>>16&255)),cr};function Jt(_t,Bt,Vt){Zt.call(this,_t,Bt,Vt)}Jt.prototype=new Zt,Jt.prototype.finalize=function(){return this.encode(this.outputBits,!0),Zt.prototype.finalize.call(this)};var tr=function(_t){var Bt,Vt,er,ar,ur,cr,hr,Sr,pr,wr,_r,Tr,gr,vr,ir,Tt,$t,Rt,Dt,Kt,nr,sr,br,$r,yr,Ar,xr,bo,yo,xo,vo,wo,Eo,Co,So,Ao,$o,ko,Ro,_o,To,Io,Po,jo,No,Do,Lo,Oo,Mo,Bo,Fo,Uo,zo,Vo,Ho,Wo,Go,qo,Ko,Qo,Xo,Yo,Zo;for(er=0;er<48;er+=2)ar=_t[0]^_t[10]^_t[20]^_t[30]^_t[40],ur=_t[1]^_t[11]^_t[21]^_t[31]^_t[41],cr=_t[2]^_t[12]^_t[22]^_t[32]^_t[42],hr=_t[3]^_t[13]^_t[23]^_t[33]^_t[43],Sr=_t[4]^_t[14]^_t[24]^_t[34]^_t[44],pr=_t[5]^_t[15]^_t[25]^_t[35]^_t[45],wr=_t[6]^_t[16]^_t[26]^_t[36]^_t[46],_r=_t[7]^_t[17]^_t[27]^_t[37]^_t[47],Tr=_t[8]^_t[18]^_t[28]^_t[38]^_t[48],gr=_t[9]^_t[19]^_t[29]^_t[39]^_t[49],Bt=Tr^(cr<<1|hr>>>31),Vt=gr^(hr<<1|cr>>>31),_t[0]^=Bt,_t[1]^=Vt,_t[10]^=Bt,_t[11]^=Vt,_t[20]^=Bt,_t[21]^=Vt,_t[30]^=Bt,_t[31]^=Vt,_t[40]^=Bt,_t[41]^=Vt,Bt=ar^(Sr<<1|pr>>>31),Vt=ur^(pr<<1|Sr>>>31),_t[2]^=Bt,_t[3]^=Vt,_t[12]^=Bt,_t[13]^=Vt,_t[22]^=Bt,_t[23]^=Vt,_t[32]^=Bt,_t[33]^=Vt,_t[42]^=Bt,_t[43]^=Vt,Bt=cr^(wr<<1|_r>>>31),Vt=hr^(_r<<1|wr>>>31),_t[4]^=Bt,_t[5]^=Vt,_t[14]^=Bt,_t[15]^=Vt,_t[24]^=Bt,_t[25]^=Vt,_t[34]^=Bt,_t[35]^=Vt,_t[44]^=Bt,_t[45]^=Vt,Bt=Sr^(Tr<<1|gr>>>31),Vt=pr^(gr<<1|Tr>>>31),_t[6]^=Bt,_t[7]^=Vt,_t[16]^=Bt,_t[17]^=Vt,_t[26]^=Bt,_t[27]^=Vt,_t[36]^=Bt,_t[37]^=Vt,_t[46]^=Bt,_t[47]^=Vt,Bt=wr^(ar<<1|ur>>>31),Vt=_r^(ur<<1|ar>>>31),_t[8]^=Bt,_t[9]^=Vt,_t[18]^=Bt,_t[19]^=Vt,_t[28]^=Bt,_t[29]^=Vt,_t[38]^=Bt,_t[39]^=Vt,_t[48]^=Bt,_t[49]^=Vt,vr=_t[0],ir=_t[1],Do=_t[11]<<4|_t[10]>>>28,Lo=_t[10]<<4|_t[11]>>>28,bo=_t[20]<<3|_t[21]>>>29,yo=_t[21]<<3|_t[20]>>>29,Qo=_t[31]<<9|_t[30]>>>23,Xo=_t[30]<<9|_t[31]>>>23,Io=_t[40]<<18|_t[41]>>>14,Po=_t[41]<<18|_t[40]>>>14,Co=_t[2]<<1|_t[3]>>>31,So=_t[3]<<1|_t[2]>>>31,Tt=_t[13]<<12|_t[12]>>>20,$t=_t[12]<<12|_t[13]>>>20,Oo=_t[22]<<10|_t[23]>>>22,Mo=_t[23]<<10|_t[22]>>>22,xo=_t[33]<<13|_t[32]>>>19,vo=_t[32]<<13|_t[33]>>>19,Yo=_t[42]<<2|_t[43]>>>30,Zo=_t[43]<<2|_t[42]>>>30,Vo=_t[5]<<30|_t[4]>>>2,Ho=_t[4]<<30|_t[5]>>>2,Ao=_t[14]<<6|_t[15]>>>26,$o=_t[15]<<6|_t[14]>>>26,Rt=_t[25]<<11|_t[24]>>>21,Dt=_t[24]<<11|_t[25]>>>21,Bo=_t[34]<<15|_t[35]>>>17,Fo=_t[35]<<15|_t[34]>>>17,wo=_t[45]<<29|_t[44]>>>3,Eo=_t[44]<<29|_t[45]>>>3,$r=_t[6]<<28|_t[7]>>>4,yr=_t[7]<<28|_t[6]>>>4,Wo=_t[17]<<23|_t[16]>>>9,Go=_t[16]<<23|_t[17]>>>9,ko=_t[26]<<25|_t[27]>>>7,Ro=_t[27]<<25|_t[26]>>>7,Kt=_t[36]<<21|_t[37]>>>11,nr=_t[37]<<21|_t[36]>>>11,Uo=_t[47]<<24|_t[46]>>>8,zo=_t[46]<<24|_t[47]>>>8,jo=_t[8]<<27|_t[9]>>>5,No=_t[9]<<27|_t[8]>>>5,Ar=_t[18]<<20|_t[19]>>>12,xr=_t[19]<<20|_t[18]>>>12,qo=_t[29]<<7|_t[28]>>>25,Ko=_t[28]<<7|_t[29]>>>25,_o=_t[38]<<8|_t[39]>>>24,To=_t[39]<<8|_t[38]>>>24,sr=_t[48]<<14|_t[49]>>>18,br=_t[49]<<14|_t[48]>>>18,_t[0]=vr^~Tt&Rt,_t[1]=ir^~$t&Dt,_t[10]=$r^~Ar&bo,_t[11]=yr^~xr&yo,_t[20]=Co^~Ao&ko,_t[21]=So^~$o&Ro,_t[30]=jo^~Do&Oo,_t[31]=No^~Lo&Mo,_t[40]=Vo^~Wo&qo,_t[41]=Ho^~Go&Ko,_t[2]=Tt^~Rt&Kt,_t[3]=$t^~Dt&nr,_t[12]=Ar^~bo&xo,_t[13]=xr^~yo&vo,_t[22]=Ao^~ko&_o,_t[23]=$o^~Ro&To,_t[32]=Do^~Oo&Bo,_t[33]=Lo^~Mo&Fo,_t[42]=Wo^~qo&Qo,_t[43]=Go^~Ko&Xo,_t[4]=Rt^~Kt&sr,_t[5]=Dt^~nr&br,_t[14]=bo^~xo&wo,_t[15]=yo^~vo&Eo,_t[24]=ko^~_o&Io,_t[25]=Ro^~To&Po,_t[34]=Oo^~Bo&Uo,_t[35]=Mo^~Fo&zo,_t[44]=qo^~Qo&Yo,_t[45]=Ko^~Xo&Zo,_t[6]=Kt^~sr&vr,_t[7]=nr^~br&ir,_t[16]=xo^~wo&$r,_t[17]=vo^~Eo&yr,_t[26]=_o^~Io&Co,_t[27]=To^~Po&So,_t[36]=Bo^~Uo&jo,_t[37]=Fo^~zo&No,_t[46]=Qo^~Yo&Vo,_t[47]=Xo^~Zo&Ho,_t[8]=sr^~vr&Tt,_t[9]=br^~ir&$t,_t[18]=wo^~$r&Ar,_t[19]=Eo^~yr&xr,_t[28]=Io^~Co&Ao,_t[29]=Po^~So&$o,_t[38]=Uo^~jo&Do,_t[39]=zo^~No&Lo,_t[48]=Yo^~Vo&Wo,_t[49]=Zo^~Ho&Go,_t[0]^=yt[er],_t[1]^=yt[er+1]};if(at)et.exports=Pt;else for(Qt=0;Qtot+MULTIADDR_LENGTH_SIZE+it.bytes.length,0),tt=new Uint8Array(o),rt=new DataView(tt.buffer);let nt=0;return et.forEach(ot=>{if(ot.getPeerId())throw new Error("`multiaddr` field MUST not contain peer id");rt.setUint16(nt,ot.bytes.length),nt+=MULTIADDR_LENGTH_SIZE,tt.set(ot.bytes,nt),nt+=ot.bytes.length}),tt}function encodeWaku2(et){let o=0;return et.lightPush&&(o+=1),o=o<<1,et.filter&&(o+=1),o=o<<1,et.store&&(o+=1),o=o<<1,et.relay&&(o+=1),o}function decodeWaku2(et){const o={relay:!1,store:!1,filter:!1,lightPush:!1};return et%2&&(o.relay=!0),et=et>>1,et%2&&(o.store=!0),et=et>>1,et%2&&(o.filter=!0),et=et>>1,et%2&&(o.lightPush=!0),o}class RawEnr extends Map{constructor(tt={},rt=BigInt(1),nt){super(Object.entries(tt));wt(this,"seq");wt(this,"signature");this.seq=rt,this.signature=nt}set(tt,rt){return this.signature=void 0,this.seq++,super.set(tt,rt)}get id(){const tt=this.get("id");if(!tt)throw new Error("id not found.");return bytesToUtf8(tt)}get publicKey(){switch(this.id){case"v4":return this.get("secp256k1");default:throw new Error(ERR_INVALID_ID)}}get rs(){const tt=this.get("rs");if(tt)return decodeRelayShard(tt)}get rsv(){const tt=this.get("rsv");if(tt)return decodeRelayShard(tt)}get ip(){return getStringValue(this,"ip","ip4")}set ip(tt){setStringValue(this,"ip","ip4",tt)}get tcp(){return getNumberAsStringValue(this,"tcp","tcp")}set tcp(tt){setNumberAsStringValue(this,"tcp","tcp",tt)}get udp(){return getNumberAsStringValue(this,"udp","udp")}set udp(tt){setNumberAsStringValue(this,"udp","udp",tt)}get ip6(){return getStringValue(this,"ip6","ip6")}set ip6(tt){setStringValue(this,"ip6","ip6",tt)}get tcp6(){return getNumberAsStringValue(this,"tcp6","tcp")}set tcp6(tt){setNumberAsStringValue(this,"tcp6","tcp",tt)}get udp6(){return getNumberAsStringValue(this,"udp6","udp")}set udp6(tt){setNumberAsStringValue(this,"udp6","udp",tt)}get multiaddrs(){const tt=this.get("multiaddrs");if(tt)return decodeMultiaddrs(tt)}set multiaddrs(tt){deleteUndefined(this,"multiaddrs",tt,encodeMultiaddrs)}get waku2(){const tt=this.get("waku2");if(tt)return decodeWaku2(tt[0])}set waku2(tt){deleteUndefined(this,"waku2",tt,rt=>new Uint8Array([encodeWaku2(rt)]))}}function getStringValue(et,o,tt){const rt=et.get(o);if(rt)return convertToString(tt,rt)}function getNumberAsStringValue(et,o,tt){const rt=et.get(o);if(rt)return Number(convertToString(tt,rt))}function setStringValue(et,o,tt,rt){deleteUndefined(et,o,rt,convertToBytes.bind({},tt))}function setNumberAsStringValue(et,o,tt,rt){setStringValue(et,o,tt,rt==null?void 0:rt.toString(10))}function deleteUndefined(et,o,tt,rt){tt!==void 0?et.set(o,rt(tt)):et.delete(o)}async function sign(et,o){return sign$1(keccak256(o),et,{der:!1})}function nodeId(et){const tt=Point.fromHex(et).toRawBytes(!1);return bytesToHex$1(keccak256(tt.slice(1)))}const log$9=new Logger$1("enr");var TransportProtocol;(function(et){et.TCP="tcp",et.UDP="udp"})(TransportProtocol||(TransportProtocol={}));var TransportProtocolPerIpVersion;(function(et){et.TCP4="tcp4",et.UDP4="udp4",et.TCP6="tcp6",et.UDP6="udp6"})(TransportProtocolPerIpVersion||(TransportProtocolPerIpVersion={}));const as=class as extends RawEnr{constructor(){super(...arguments);wt(this,"peerId");wt(this,"getLocationMultiaddr",locationMultiaddrFromEnrFields.bind({},this))}static create(tt={},rt=BigInt(1),nt){const ot=new as(tt,rt,nt);try{const it=ot.publicKey;it&&(ot.peerId=createPeerIdFromPublicKey(it))}catch(it){log$9.error("Could not calculate peer id for ENR",it)}return ot}get nodeId(){switch(this.id){case"v4":return this.publicKey?nodeId(this.publicKey):void 0;default:throw new Error(ERR_INVALID_ID)}}get shardInfo(){return this.rs&&this.rsv&&log$9.warn("ENR contains both `rs` and `rsv` fields."),this.rs||this.rsv}setLocationMultiaddr(tt){const rt=tt.protoNames();if(rt.length!==2&&rt[1]!=="udp"&&rt[1]!=="tcp")throw new Error("Invalid multiaddr");const nt=tt.tuples();if(!nt[0][1]||!nt[1][1])throw new Error("Invalid multiaddr");nt[0][0]===4?(this.set("ip",nt[0][1]),this.set(rt[1],nt[1][1])):(this.set("ip6",nt[0][1]),this.set(rt[1]+"6",nt[1][1]))}getAllLocationMultiaddrs(){const tt=[];for(const nt of Object.values(TransportProtocolPerIpVersion)){const ot=this.getLocationMultiaddr(nt);ot&&tt.push(ot)}const rt=this.multiaddrs??[];return tt.concat(rt).map(nt=>this.peerId?nt.encapsulate(`/p2p/${this.peerId.toString()}`):nt)}get peerInfo(){const tt=this.peerId;if(tt)return{id:tt,multiaddrs:this.getAllLocationMultiaddrs()}}getFullMultiaddr(tt){if(this.peerId){const rt=this.getLocationMultiaddr(tt);if(rt)return rt.encapsulate(`/p2p/${this.peerId.toString()}`)}}getFullMultiaddrs(){if(this.peerId&&this.multiaddrs){const tt=this.peerId;return this.multiaddrs.map(rt=>rt.encapsulate(`/p2p/${tt.toString()}`))}return[]}verify(tt,rt){if(!this.get("id")||this.id!=="v4")throw new Error(ERR_INVALID_ID);if(!this.publicKey)throw new Error("Failed to verify ENR: No public key");return verifySignature(rt,keccak256(tt),this.publicKey)}async sign(tt,rt){switch(this.id){case"v4":this.signature=await sign(rt,tt);break;default:throw new Error(ERR_INVALID_ID)}return this.signature}};wt(as,"RECORD_PREFIX","enr:");let ENR=as;const version$2="logger/5.7.0";let _permanentCensorErrors=!1,_censorErrors=!1;const LogLevels={debug:1,default:2,info:2,warning:3,error:4,off:5};let _logLevel=LogLevels.default,_globalLogger=null;function _checkNormalize(){try{const et=[];if(["NFD","NFC","NFKD","NFKC"].forEach(o=>{try{if("test".normalize(o)!=="test")throw new Error("bad normalize")}catch{et.push(o)}}),et.length)throw new Error("missing "+et.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(et){return et.message}return null}const _normalizeError=_checkNormalize();var LogLevel;(function(et){et.DEBUG="DEBUG",et.INFO="INFO",et.WARNING="WARNING",et.ERROR="ERROR",et.OFF="OFF"})(LogLevel||(LogLevel={}));var ErrorCode;(function(et){et.UNKNOWN_ERROR="UNKNOWN_ERROR",et.NOT_IMPLEMENTED="NOT_IMPLEMENTED",et.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",et.NETWORK_ERROR="NETWORK_ERROR",et.SERVER_ERROR="SERVER_ERROR",et.TIMEOUT="TIMEOUT",et.BUFFER_OVERRUN="BUFFER_OVERRUN",et.NUMERIC_FAULT="NUMERIC_FAULT",et.MISSING_NEW="MISSING_NEW",et.INVALID_ARGUMENT="INVALID_ARGUMENT",et.MISSING_ARGUMENT="MISSING_ARGUMENT",et.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",et.CALL_EXCEPTION="CALL_EXCEPTION",et.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",et.NONCE_EXPIRED="NONCE_EXPIRED",et.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",et.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",et.TRANSACTION_REPLACED="TRANSACTION_REPLACED",et.ACTION_REJECTED="ACTION_REJECTED"})(ErrorCode||(ErrorCode={}));const HEX="0123456789abcdef";class Logger{constructor(o){Object.defineProperty(this,"version",{enumerable:!0,value:o,writable:!1})}_log(o,tt){const rt=o.toLowerCase();LogLevels[rt]==null&&this.throwArgumentError("invalid log level name","logLevel",o),!(_logLevel>LogLevels[rt])&&console.log.apply(console,tt)}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,tt,rt){if(_censorErrors)return this.makeError("censored error",tt,{});tt||(tt=Logger.errors.UNKNOWN_ERROR),rt||(rt={});const nt=[];Object.keys(rt).forEach(at=>{const ct=rt[at];try{if(ct instanceof Uint8Array){let lt="";for(let dt=0;dt>4],lt+=HEX[ct[dt]&15];nt.push(at+"=Uint8Array(0x"+lt+")")}else nt.push(at+"="+JSON.stringify(ct))}catch{nt.push(at+"="+JSON.stringify(rt[at].toString()))}}),nt.push(`code=${tt}`),nt.push(`version=${this.version}`);const ot=o;let it="";switch(tt){case ErrorCode.NUMERIC_FAULT:{it="NUMERIC_FAULT";const at=o;switch(at){case"overflow":case"underflow":case"division-by-zero":it+="-"+at;break;case"negative-power":case"negative-width":it+="-unsupported";break;case"unbound-bitwise-result":it+="-unbound-result";break}break}case ErrorCode.CALL_EXCEPTION:case ErrorCode.INSUFFICIENT_FUNDS:case ErrorCode.MISSING_NEW:case ErrorCode.NONCE_EXPIRED:case ErrorCode.REPLACEMENT_UNDERPRICED:case ErrorCode.TRANSACTION_REPLACED:case ErrorCode.UNPREDICTABLE_GAS_LIMIT:it=tt;break}it&&(o+=" [ See: https://links.ethers.org/v5-errors-"+it+" ]"),nt.length&&(o+=" ("+nt.join(", ")+")");const st=new Error(o);return st.reason=ot,st.code=tt,Object.keys(rt).forEach(function(at){st[at]=rt[at]}),st}throwError(o,tt,rt){throw this.makeError(o,tt,rt)}throwArgumentError(o,tt,rt){return this.throwError(o,Logger.errors.INVALID_ARGUMENT,{argument:tt,value:rt})}assert(o,tt,rt,nt){o||this.throwError(tt,rt,nt)}assertArgument(o,tt,rt,nt){o||this.throwArgumentError(tt,rt,nt)}checkNormalize(o){_normalizeError&&this.throwError("platform missing String.prototype.normalize",Logger.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:_normalizeError})}checkSafeUint53(o,tt){typeof o=="number"&&(tt==null&&(tt="value not safe"),(o<0||o>=9007199254740991)&&this.throwError(tt,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:o}),o%1&&this.throwError(tt,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:o}))}checkArgumentCount(o,tt,rt){rt?rt=": "+rt:rt="",ott&&this.throwError("too many arguments"+rt,Logger.errors.UNEXPECTED_ARGUMENT,{count:o,expectedCount:tt})}checkNew(o,tt){(o===Object||o==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:tt.name})}checkAbstract(o,tt){o===tt?this.throwError("cannot instantiate abstract class "+JSON.stringify(tt.name)+" directly; use a sub-class",Logger.errors.UNSUPPORTED_OPERATION,{name:o.name,operation:"new"}):(o===Object||o==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:tt.name})}static globalLogger(){return _globalLogger||(_globalLogger=new Logger(version$2)),_globalLogger}static setCensorship(o,tt){if(!o&&tt&&this.globalLogger().throwError("cannot permanently disable censorship",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),_permanentCensorErrors){if(!o)return;this.globalLogger().throwError("error censorship permanent",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}_censorErrors=!!o,_permanentCensorErrors=!!tt}static setLogLevel(o){const tt=LogLevels[o.toLowerCase()];if(tt==null){Logger.globalLogger().warn("invalid log level - "+o);return}_logLevel=tt}static from(o){return new Logger(o)}}Logger.errors=ErrorCode;Logger.levels=LogLevel;const version$1="bytes/5.7.0",logger$1=new Logger(version$1);function isHexable(et){return!!et.toHexString}function addSlice(et){return et.slice||(et.slice=function(){const o=Array.prototype.slice.call(arguments);return addSlice(new Uint8Array(Array.prototype.slice.apply(et,o)))}),et}function isBytesLike(et){return isHexString(et)&&!(et.length%2)||isBytes(et)}function isInteger(et){return typeof et=="number"&&et==et&&et%1===0}function isBytes(et){if(et==null)return!1;if(et.constructor===Uint8Array)return!0;if(typeof et=="string"||!isInteger(et.length)||et.length<0)return!1;for(let o=0;o=256)return!1}return!0}function arrayify(et,o){if(o||(o={}),typeof et=="number"){logger$1.checkSafeUint53(et,"invalid arrayify value");const tt=[];for(;et;)tt.unshift(et&255),et=parseInt(String(et/256));return tt.length===0&&tt.push(0),addSlice(new Uint8Array(tt))}if(o.allowMissingPrefix&&typeof et=="string"&&et.substring(0,2)!=="0x"&&(et="0x"+et),isHexable(et)&&(et=et.toHexString()),isHexString(et)){let tt=et.substring(2);tt.length%2&&(o.hexPad==="left"?tt="0"+tt:o.hexPad==="right"?tt+="0":logger$1.throwArgumentError("hex data is odd-length","value",et));const rt=[];for(let nt=0;nt>4]+HexCharacters[nt&15]}return tt}return logger$1.throwArgumentError("invalid hexlify value","value",et)}const version="rlp/5.7.0",logger=new Logger(version);function arrayifyInteger(et){const o=[];for(;et;)o.unshift(et&255),et>>=8;return o}function unarrayifyInteger(et,o,tt){let rt=0;for(let nt=0;nto+1+rt&&logger.throwError("child data too short",Logger.errors.BUFFER_OVERRUN,{})}return{consumed:1+rt,result:nt}}function _decode(et,o){if(et.length===0&&logger.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{}),et[o]>=248){const tt=et[o]-247;o+1+tt>et.length&&logger.throwError("data short segment too short",Logger.errors.BUFFER_OVERRUN,{});const rt=unarrayifyInteger(et,o+1,tt);return o+1+tt+rt>et.length&&logger.throwError("data long segment too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(et,o,o+1+tt,tt+rt)}else if(et[o]>=192){const tt=et[o]-192;return o+1+tt>et.length&&logger.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(et,o,o+1,tt)}else if(et[o]>=184){const tt=et[o]-183;o+1+tt>et.length&&logger.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const rt=unarrayifyInteger(et,o+1,tt);o+1+tt+rt>et.length&&logger.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const nt=hexlify(et.slice(o+1+tt,o+1+tt+rt));return{consumed:1+tt+rt,result:nt}}else if(et[o]>=128){const tt=et[o]-128;o+1+tt>et.length&&logger.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{});const rt=hexlify(et.slice(o+1,o+1+tt));return{consumed:1+tt,result:rt}}return{consumed:1,result:hexlify(et[o])}}function decode$8(et){const o=arrayify(et),tt=_decode(o,0);return tt.consumed!==o.length&&logger.throwArgumentError("invalid rlp data","data",et),tt.result}function base$1(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$2=base$1,_brrp__multiformats_scope_baseX$1=src$2;const coerce$1=et=>{if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")},fromString$3=et=>new TextEncoder().encode(et),toString$8=et=>new TextDecoder().decode(et);let Encoder$1=class{constructor(o,tt,rt){this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}},Decoder$1=class{constructor(o,tt,rt){if(this.name=o,this.prefix=tt,tt.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=tt.codePointAt(0),this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or$1(this,o)}},ComposedDecoder$1=class{constructor(o){this.decoders=o}or(o){return or$1(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const or$1=(et,o)=>new ComposedDecoder$1({...et.decoders||{[et.prefix]:et},...o.decoders||{[o.prefix]:o}});let Codec$1=class{constructor(o,tt,rt,nt){this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder$1(o,tt,rt),this.decoder=new Decoder$1(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}};const from$2=({name:et,prefix:o,encode:tt,decode:rt})=>new Codec$1(et,o,tt,rt),baseX$1=({prefix:et,name:o,alphabet:tt})=>{const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX$1(tt,o);return from$2({prefix:et,name:o,encode:rt,decode:ot=>coerce$1(nt(ot))})},decode$7=(et,o,tt,rt)=>{const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it},encode$6=(et,o,tt)=>{const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it&&(ot+=o[nt&st<from$2({prefix:o,name:et,encode(nt){return encode$6(nt,rt,tt)},decode(nt){return decode$7(nt,rt,tt,et)}}),identity$1=from$2({prefix:"\0",name:"identity",encode:et=>toString$8(et),decode:et=>fromString$3(et)}),identityBase$1=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$1},Symbol.toStringTag,{value:"Module"})),base2$2=rfc4648$1({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$3=Object.freeze(Object.defineProperty({__proto__:null,base2:base2$2},Symbol.toStringTag,{value:"Module"})),base8$2=rfc4648$1({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$3=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$2},Symbol.toStringTag,{value:"Module"})),base10$2=baseX$1({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$3=Object.freeze(Object.defineProperty({__proto__:null,base10:base10$2},Symbol.toStringTag,{value:"Module"})),base16$2=rfc4648$1({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper$1=rfc4648$1({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$3=Object.freeze(Object.defineProperty({__proto__:null,base16:base16$2,base16upper:base16upper$1},Symbol.toStringTag,{value:"Module"})),base32$4=rfc4648$1({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$1=rfc4648$1({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$1=rfc4648$1({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$1=rfc4648$1({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$1=rfc4648$1({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$1=rfc4648$1({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$1=rfc4648$1({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$1=rfc4648$1({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$1=rfc4648$1({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$5=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$4,base32hex:base32hex$1,base32hexpad:base32hexpad$1,base32hexpadupper:base32hexpadupper$1,base32hexupper:base32hexupper$1,base32pad:base32pad$1,base32padupper:base32padupper$1,base32upper:base32upper$1,base32z:base32z$1},Symbol.toStringTag,{value:"Module"})),base36$2=baseX$1({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$1=baseX$1({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$3=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$2,base36upper:base36upper$1},Symbol.toStringTag,{value:"Module"})),base58btc$1=baseX$1({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$1=baseX$1({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$1=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$1,base58flickr:base58flickr$1},Symbol.toStringTag,{value:"Module"})),base64$4=rfc4648$1({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$1=rfc4648$1({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$1=rfc4648$1({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$1=rfc4648$1({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$5=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$4,base64pad:base64pad$1,base64url:base64url$1,base64urlpad:base64urlpad$1},Symbol.toStringTag,{value:"Module"})),alphabet$1=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),alphabetBytesToChars$1=alphabet$1.reduce((et,o,tt)=>(et[tt]=o,et),[]),alphabetCharsToBytes$1=alphabet$1.reduce((et,o,tt)=>(et[o.codePointAt(0)]=tt,et),[]);function encode$5(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars$1[tt],o),"")}function decode$6(et){const o=[];for(const tt of et){const rt=alphabetCharsToBytes$1[tt.codePointAt(0)];if(rt===void 0)throw new Error(`Non-base256emoji character: ${tt}`);o.push(rt)}return new Uint8Array(o)}const base256emoji$2=from$2({prefix:"🚀",name:"base256emoji",encode:encode$5,decode:decode$6}),base256emoji$3=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$2},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases$1={...identityBase$1,...base2$3,...base8$3,...base10$3,...base16$3,...base32$5,...base36$3,...base58$1,...base64$5,...base256emoji$3};function createCodec$1(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$4=createCodec$1("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii$1=createCodec$1("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe$h(et.length);for(let tt=0;ttv4Regex$1.test(et),encode(et,o,tt){tt=~~tt,o=o||new Uint8Array(tt+v4Size);const rt=et.length;let nt=0;for(let ot=0;otet.length>0&&v6Regex$1.test(et),encode(et,o,tt){tt=~~tt;let rt=tt+v6Size,nt=-1,ot=0,it=0,st=!0,at=!1;o=o||new Uint8Array(tt+v6Size);for(let ct=0;ct>8),tt=97?lt-=87:lt>=65?lt-=55:(lt-=48,it=it*10+lt),ot=(ot<<4)+lt)}if(st===!1)at===!0?(tt>8),tt=nt+2;ct--)o[ct]=o[ct-2];o[nt]=0,o[nt+1]=0,nt=tt}if(nt!==tt&&nt!==-1)for(tt>rt-2&&(tt=rt-2);rt>nt;)o[--rt]=ttnt?o[--tt]:0;else for(;tt=SURROGATE_B||(et.charCodeAt(ot)&64512)!==SURROGATE_B?o+=3:(rt=ot,o+=4)}}return o}function encode$3(et,o,tt){const rt=et.length;tt==null&&(tt=0),o===void 0&&(o=new Uint8Array(encodingLength$1(et)+tt));let nt=tt;for(let ot=0;ot>6,o[nt++]=128|it&63;else if((it&63488)!==SURROGATE_A)o[nt++]=224|(it&61440)>>12,o[nt++]=128|(it&4032)>>6,o[nt++]=128|it&63;else{const st=ot+1;if(st===rt||it>=SURROGATE_B)o[nt++]=239,o[nt++]=191,o[nt++]=189;else{const at=et.charCodeAt(st);(at&64512)!==SURROGATE_B?(o[nt++]=239,o[nt++]=191,o[nt++]=189):(ot=st,it=65536|(it&1023)<<10|at&1023,o[nt++]=240|(it&1835008)>>18,o[nt++]=128|(it&258048)>>12,o[nt++]=128|(it&4032)>>6,o[nt++]=128|it&63)}}}return encode$3.bytes=nt-tt,o}encode$3.bytes=0;function decode$4(et,o,tt){let rt="";o==null&&(o=0),tt==null&&(tt=et.length);for(let nt=o;nt191&&ot<224)it=(ot&31)<<6|et[nt++]&63;else if(ot>239&&ot<365){it=((ot&7)<<18|(et[nt++]&63)<<12|(et[nt++]&63)<<6|et[nt++]&63)-65536;const st=SURROGATE_A|it>>10&1023;rt+=String.fromCharCode(st),it=SURROGATE_B|it&1023}else it=(ot&15)<<12|(et[nt++]&63)<<6|et[nt++]&63;rt+=String.fromCharCode(it)}return decode$4.bytes=tt-o,rt}decode$4.bytes=0;const isU8Arr=et=>et instanceof Uint8Array;function bytelength(et){return typeof et=="string"?encodingLength$1(et):et.byteLength}function from$1(et){return et instanceof Uint8Array?et:Array.isArray(et)?new Uint8Array(et):encode$3(et)}function write(et,o,tt){if(typeof o!="string")throw new Error("unknown input type");return encode$3(o,et,tt),encode$3.bytes}const P_24=Math.pow(2,24),P_16=Math.pow(2,16),P_8=Math.pow(2,8),readUInt32BE=(et,o)=>et[o]*P_24+et[o+1]*P_16+et[o+2]*P_8+et[o+3],readUInt16BE=(et,o)=>et[o]<<8|et[o+1],writeUInt32BE=(et,o,tt)=>(o=+o,et[tt+3]=o,o=o>>>8,et[tt+2]=o,o=o>>>8,et[tt+1]=o,o=o>>>8,et[tt]=o,tt+4),writeUInt16BE=(et,o,tt)=>(et[tt]=o>>8,et[tt+1]=o&255,tt+2);function copy(et,o,tt,rt,nt){return tt<0&&(rt-=tt,tt=0),rt<0&&(rt=0),nt<0?new Uint8Array(0):tt>=o.length||rt>=nt?0:_copyActual(et,o,tt,rt,nt)}function _copyActual(et,o,tt,rt,nt){nt-rt>o.length-tt&&(nt=rt+o.length-tt);let ot=nt-rt;const it=et.length-rt;return ot>it&&(ot=it),(rt!==0||ntet)}}const name$1=codec({encode(et,o,tt){o||(o=new Uint8Array(name$1.encodingLength(et))),tt||(tt=0);const rt=tt,nt=et.replace(/^\.|\.$/gm,"");if(nt.length){const ot=nt.split(".");for(let it=0;it=et.length)throw new Error("Cannot decode name (buffer overflow)");const st=et[o++];if(ot+=it?0:1,st===0)break;if(st&192)if((st&192)===192){if(o+1>et.length)throw new Error("Cannot decode name (buffer overflow)");const at=readUInt16BE(et,o-1)-49152;if(at>=rt)throw new Error("Cannot decode name (bad pointer)");o=at,rt=at,ot+=it?0:1,it=!0}else throw new Error("Cannot decode name (bad label)");else{if(o+st>et.length)throw new Error("Cannot decode name (buffer overflow)");if(nt+=st+1,nt>254)throw new Error("Cannot decode name (name too long)");tt.push(decode$4(et,o,o+st)),o+=st,ot+=it?0:st}}return name$1.decode.bytes=ot,tt.length===0?".":tt.join(".")},encodingLength(et){return et==="."||et===".."?1:bytelength(et.replace(/^\.|\.$/gm,""))+2}}),string$3=codec({encode(et,o,tt){o||(o=new Uint8Array(string$3.encodingLength(et))),tt||(tt=0);const rt=write(o,et,tt+1);return o[tt]=rt,string$3.encode.bytes=rt+1,o},decode(et,o){o||(o=0);const tt=et[o],rt=decode$4(et,o+1,o+1+tt);return string$3.decode.bytes=tt+1,rt},encodingLength(et){return bytelength(et)+1}}),header=codec({bytes:12,encode(et,o,tt){o||(o=new Uint8Array(header.encodingLength(et))),tt||(tt=0);const rt=(et.flags||0)&32767,nt=et.type==="response"?RESPONSE_FLAG:QUERY_FLAG;return writeUInt16BE(o,et.id||0,tt),writeUInt16BE(o,rt|nt,tt+2),writeUInt16BE(o,et.questions.length,tt+4),writeUInt16BE(o,et.answers.length,tt+6),writeUInt16BE(o,et.authorities.length,tt+8),writeUInt16BE(o,et.additionals.length,tt+10),o},decode(et,o){if(o||(o=0),et.length<12)throw new Error("Header must be 12 bytes");const tt=readUInt16BE(et,o+2);return{id:readUInt16BE(et,o),type:tt&RESPONSE_FLAG?"response":"query",flags:tt&32767,flag_qr:(tt>>15&1)===1,opcode:toString$5(tt>>11&15),flag_aa:(tt>>10&1)===1,flag_tc:(tt>>9&1)===1,flag_rd:(tt>>8&1)===1,flag_ra:(tt>>7&1)===1,flag_z:(tt>>6&1)===1,flag_ad:(tt>>5&1)===1,flag_cd:(tt>>4&1)===1,rcode:toString$6(tt&15),questions:new Array(readUInt16BE(et,o+4)),answers:new Array(readUInt16BE(et,o+6)),authorities:new Array(readUInt16BE(et,o+8)),additionals:new Array(readUInt16BE(et,o+10))}},encodingLength(){return 12}}),runknown=codec({encode(et,o,tt){o||(o=new Uint8Array(runknown.encodingLength(et))),tt||(tt=0);const rt=et.length;return writeUInt16BE(o,rt,tt),copy(et,o,tt+2,0,rt),runknown.encode.bytes=rt+2,o},decode(et,o){o||(o=0);const tt=readUInt16BE(et,o),rt=et.slice(o+2,o+2+tt);return runknown.decode.bytes=tt+2,rt},encodingLength(et){return et.length+2}}),rns=codec({encode(et,o,tt){return o||(o=new Uint8Array(rns.encodingLength(et))),tt||(tt=0),name$1.encode(et,o,tt+2),writeUInt16BE(o,name$1.encode.bytes,tt),rns.encode.bytes=name$1.encode.bytes+2,o},decode(et,o){o||(o=0);const tt=readUInt16BE(et,o),rt=name$1.decode(et,o+2);return rns.decode.bytes=tt+2,rt},encodingLength(et){return name$1.encodingLength(et)+2}}),rsoa=codec({encode(et,o,tt){o||(o=new Uint8Array(rsoa.encodingLength(et))),tt||(tt=0);const rt=tt;return tt+=2,name$1.encode(et.mname,o,tt),tt+=name$1.encode.bytes,name$1.encode(et.rname,o,tt),tt+=name$1.encode.bytes,writeUInt32BE(o,et.serial||0,tt),tt+=4,writeUInt32BE(o,et.refresh||0,tt),tt+=4,writeUInt32BE(o,et.retry||0,tt),tt+=4,writeUInt32BE(o,et.expire||0,tt),tt+=4,writeUInt32BE(o,et.minimum||0,tt),tt+=4,writeUInt16BE(o,tt-rt-2,rt),rsoa.encode.bytes=tt-rt,o},decode(et,o){o||(o=0);const tt=o,rt={};return o+=2,rt.mname=name$1.decode(et,o),o+=name$1.decode.bytes,rt.rname=name$1.decode(et,o),o+=name$1.decode.bytes,rt.serial=readUInt32BE(et,o),o+=4,rt.refresh=readUInt32BE(et,o),o+=4,rt.retry=readUInt32BE(et,o),o+=4,rt.expire=readUInt32BE(et,o),o+=4,rt.minimum=readUInt32BE(et,o),o+=4,rsoa.decode.bytes=o-tt,rt},encodingLength(et){return 22+name$1.encodingLength(et.mname)+name$1.encodingLength(et.rname)}}),rtxt=codec({encode(et,o,tt){Array.isArray(et)||(et=[et]);for(let nt=0;nt0;){const ot=et[o++];if(--rt,rtnew Uint8Array(et),roption=codec({encode(et,o,tt){o||(o=new Uint8Array(roption.encodingLength(et))),tt||(tt=0);const rt=tt,nt=toCode(et.code);if(writeUInt16BE(o,nt,tt),tt+=2,et.data)writeUInt16BE(o,et.data.length,tt),tt+=2,copy(et.data,o,tt),tt+=et.data.length;else switch(nt){case 8:{const ot=et.sourcePrefixLength||0,it=et.family||familyOf(et.ip),st=encode$4(et.ip,alloc),at=Math.ceil(ot/8);writeUInt16BE(o,at+4,tt),tt+=2,writeUInt16BE(o,it,tt),tt+=2,o[tt++]=ot,o[tt++]=et.scopePrefixLength||0,copy(st,o,tt,0,at),tt+=at}break;case 11:et.timeout?(writeUInt16BE(o,2,tt),tt+=2,writeUInt16BE(o,et.timeout,tt),tt+=2):(writeUInt16BE(o,0,tt),tt+=2);break;case 12:{const ot=et.length||0;writeUInt16BE(o,ot,tt),tt+=2,o.fill(0,tt,tt+ot),tt+=ot}break;case 14:{const ot=et.tags.length*2;writeUInt16BE(o,ot,tt),tt+=2;for(const it of et.tags)writeUInt16BE(o,it,tt),tt+=2}break;default:throw new Error(`Unknown roption code: ${et.code}`)}return roption.encode.bytes=tt-rt,o},decode(et,o){o||(o=0);const tt={};tt.code=readUInt16BE(et,o),tt.type=toString$3(tt.code),o+=2;const rt=readUInt16BE(et,o);switch(o+=2,tt.data=et.slice(o,o+rt),tt.code){case 8:tt.family=readUInt16BE(et,o),o+=2,tt.sourcePrefixLength=et[o++],tt.scopePrefixLength=et[o++];{const nt=new Uint8Array(tt.family===1?4:16);copy(et,nt,0,o,o+rt-4),tt.ip=decode$5(nt)}break;case 11:rt>0&&(tt.timeout=readUInt16BE(et,o),o+=2);break;case 14:tt.tags=[];for(let nt=0;nt0;)rt[ot++]=roption.decode(et,o),o+=roption.decode.bytes,nt-=roption.decode.bytes;return ropt.decode.bytes=o-tt,rt},encodingLength(et){return 2+encodingLengthList(et||[],roption)}}),rdnskey=codec({encode(et,o,tt){o||(o=new Uint8Array(rdnskey.encodingLength(et))),tt||(tt=0);const rt=tt,nt=et.key;if(!isU8Arr(nt))throw new Error("Key must be a Buffer");return tt+=2,writeUInt16BE(o,et.flags,tt),tt+=2,o[tt]=rdnskey.PROTOCOL_DNSSEC,tt+=1,o[tt]=et.algorithm,tt+=1,copy(nt,o,tt,0,nt.length),tt+=nt.length,rdnskey.encode.bytes=tt-rt,writeUInt16BE(o,rdnskey.encode.bytes-2,rt),o},decode(et,o){o||(o=0);const tt=o,rt={},nt=readUInt16BE(et,o);if(o+=2,rt.flags=readUInt16BE(et,o),o+=2,et[o]!==rdnskey.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return o+=1,rt.algorithm=et[o],o+=1,rt.key=et.slice(o,tt+nt+2),o+=rt.key.length,rdnskey.decode.bytes=o-tt,rt},encodingLength(et){return 6+bytelength(et.key)}});rdnskey.PROTOCOL_DNSSEC=3;rdnskey.ZONE_KEY=128;rdnskey.SECURE_ENTRYPOINT=32768;const rrrsig=codec({encode(et,o,tt){o||(o=new Uint8Array(rrrsig.encodingLength(et))),tt||(tt=0);const rt=tt,nt=et.signature;if(!isU8Arr(nt))throw new Error("Signature must be a Buffer");return tt+=2,writeUInt16BE(o,toType(et.typeCovered),tt),tt+=2,o[tt]=et.algorithm,tt+=1,o[tt]=et.labels,tt+=1,writeUInt32BE(o,et.originalTTL,tt),tt+=4,writeUInt32BE(o,et.expiration,tt),tt+=4,writeUInt32BE(o,et.inception,tt),tt+=4,writeUInt16BE(o,et.keyTag,tt),tt+=2,name$1.encode(et.signersName,o,tt),tt+=name$1.encode.bytes,copy(nt,o,tt,0,nt.length),tt+=nt.length,rrrsig.encode.bytes=tt-rt,writeUInt16BE(o,rrrsig.encode.bytes-2,rt),o},decode(et,o){o||(o=0);const tt=o,rt={},nt=readUInt16BE(et,o);return o+=2,rt.typeCovered=toString$7(readUInt16BE(et,o)),o+=2,rt.algorithm=et[o],o+=1,rt.labels=et[o],o+=1,rt.originalTTL=readUInt32BE(et,o),o+=4,rt.expiration=readUInt32BE(et,o),o+=4,rt.inception=readUInt32BE(et,o),o+=4,rt.keyTag=readUInt16BE(et,o),o+=2,rt.signersName=name$1.decode(et,o),o+=name$1.decode.bytes,rt.signature=et.slice(o,tt+nt+2),o+=rt.signature.length,rrrsig.decode.bytes=o-tt,rt},encodingLength(et){return 20+name$1.encodingLength(et.signersName)+bytelength(et.signature)}}),rrp=codec({encode(et,o,tt){o||(o=new Uint8Array(rrp.encodingLength(et))),tt||(tt=0);const rt=tt;return tt+=2,name$1.encode(et.mbox||".",o,tt),tt+=name$1.encode.bytes,name$1.encode(et.txt||".",o,tt),tt+=name$1.encode.bytes,rrp.encode.bytes=tt-rt,writeUInt16BE(o,rrp.encode.bytes-2,rt),o},decode(et,o){o||(o=0);const tt=o,rt={};return o+=2,rt.mbox=name$1.decode(et,o)||".",o+=name$1.decode.bytes,rt.txt=name$1.decode(et,o)||".",o+=name$1.decode.bytes,rrp.decode.bytes=o-tt,rt},encodingLength(et){return 2+name$1.encodingLength(et.mbox||".")+name$1.encodingLength(et.txt||".")}}),typebitmap=codec({encode(et,o,tt){o||(o=new Uint8Array(typebitmap.encodingLength(et))),tt||(tt=0);const rt=tt,nt=[];for(let ot=0;ot>8]===void 0&&(nt[it>>8]=[]),nt[it>>8][it>>3&31]|=1<<7-(it&7)}for(let ot=0;ot>8]=Math.max(o[nt>>8]||0,nt&255)}let tt=0;for(let rt=0;rt>15&1)===1,tt.options=ropt.decode(et,o+8),o+=8+ropt.decode.bytes;else{const nt=readUInt16BE(et,o+2);tt.ttl=readUInt32BE(et,o+4),tt.class=toString$4(nt&NOT_FLUSH_MASK),tt.flush=!!(nt&FLUSH_MASK);const ot=renc(tt.type);tt.data=ot.decode(et,o+8),o+=8+ot.decode.bytes}return answer.decode.bytes=o-rt,tt},encodingLength(et){const o=et.data!==null&&et.data!==void 0?et.data:et.options;return name$1.encodingLength(et.name)+8+renc(et.type).encodingLength(o)}}),question=codec({encode(et,o,tt){o||(o=new Uint8Array(question.encodingLength(et))),tt||(tt=0);const rt=tt;return name$1.encode(et.name,o,tt),tt+=name$1.encode.bytes,writeUInt16BE(o,toType(et.type),tt),tt+=2,writeUInt16BE(o,toClass(et.class===void 0?"IN":et.class),tt),tt+=2,question.encode.bytes=tt-rt,et},decode(et,o){o||(o=0);const tt=o,rt={};return rt.name=name$1.decode(et,o),o+=name$1.decode.bytes,rt.type=toString$7(readUInt16BE(et,o)),o+=2,rt.class=toString$4(readUInt16BE(et,o)),o+=2,!!(rt.class&QU_MASK)&&(rt.class&=NOT_QU_MASK),question.decode.bytes=o-tt,rt},encodingLength(et){return name$1.encodingLength(et.name)+4}}),RECURSION_DESIRED=256,packet={encode:function(et,o,tt){const rt=!o;rt&&(o=new Uint8Array(encodingLength(et))),tt||(tt=0);const nt=tt;return et.questions||(et.questions=[]),et.answers||(et.answers=[]),et.authorities||(et.authorities=[]),et.additionals||(et.additionals=[]),header.encode(et,o,tt),tt+=header.encode.bytes,tt=encodeList(et.questions,question,o,tt),tt=encodeList(et.answers,answer,o,tt),tt=encodeList(et.authorities,answer,o,tt),tt=encodeList(et.additionals,answer,o,tt),packet.encode.bytes=tt-nt,rt&&encode$2.bytes!==o.length?o.slice(0,encode$2.bytes):o},decode:function(et,o){o||(o=0);const tt=o,rt=header.decode(et,o);return o+=header.decode.bytes,o=decodeList(rt.questions,question,et,o),o=decodeList(rt.answers,answer,et,o),o=decodeList(rt.authorities,answer,et,o),o=decodeList(rt.additionals,answer,et,o),packet.decode.bytes=o-tt,rt},encodingLength:function(et){return header.encodingLength(et)+encodingLengthList(et.questions||[],question)+encodingLengthList(et.answers||[],answer)+encodingLengthList(et.authorities||[],answer)+encodingLengthList(et.additionals||[],answer)}};packet.encode.bytes=0;packet.decode.bytes=0;const encode$2=packet.encode,decode$3=packet.decode,encodingLength=packet.encodingLength;function encodingLengthList(et,o){let tt=0;for(let rt=0;rt255)throw new Error(`Character #${at} in charset [code=${ct}, char=${o.charAt(at)}] is too high! (max=255)`);if(nt[ct]!==0)throw new Error(`Character [code=${ct}, char=${o.charAt(at)}] is more than once in the charset!`);nt[ct]=at,ot[at]=ct}const it=tt.charCodeAt(0),st={name:et,encodingLength(at){const ct=at.length,lt=ct*.75|0;return at.charCodeAt(ct-1)===it?at.charCodeAt(ct-2)===it?lt-2:lt-1:lt},encode(at,ct,lt){ct==null&&(ct=new Uint8Array(st.encodingLength(at))),lt==null&&(lt=0);let dt=at.length;at.charCodeAt(dt-1)===it&&(at.charCodeAt(dt-2)===it?dt-=2:dt-=1);const ht=dt%4,mt=dt-ht;let ft=lt,pt=0;for(;pt>16,ct[ft++]=yt>>8,ct[ft++]=yt,pt+=4}if(ht===3){const yt=nt[at.charCodeAt(pt)]<<10|nt[at.charCodeAt(pt+1)]<<4|nt[at.charCodeAt(pt+2)]>>2;ct[ft++]=yt>>8,ct[ft++]=yt}else ht===2&&(ct[ft++]=nt[at.charCodeAt(pt)]<<2|nt[at.charCodeAt(pt+1)]>>4);return st.encode.bytes=ft-lt,ct},decode(at,ct,lt){ct==null&&(ct=0),lt==null&&(lt=at.length);const dt=lt-ct,ht=dt%3,mt=ct+dt-ht,ft=[];for(let pt=ct;pt>18&63],ot[yt>>12&63],ot[yt>>6&63],ot[yt&63])}if(ht===2){const pt=(at[lt-2]<<8)+at[lt-1];ft.push(ot[pt>>10],ot[pt>>4&63],ot[pt<<2&63]),rt===PREFERS_PADDING&&ft.push(it)}else if(ht===1){const pt=at[lt-1];ft.push(ot[pt>>2],ot[pt<<4&63]),rt===PREFERS_PADDING&&ft.push(it,it)}return st.decode.bytes=dt,String.fromCharCode.apply(String,ft)}};return st}make("base64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/","=",PREFERS_PADDING);const base64URL=make("base64-url","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_","=",PREFERS_NO_PADDING);let AbortError=typeof globalThis<"u"?globalThis.AbortError:typeof window<"u"?window.AbortError:null;AbortError||(AbortError=class extends Error{constructor(o="Request aborted."){super(o)}});AbortError.prototype.name="AbortError";AbortError.prototype.code="ABORT_ERR";const URL$1=typeof globalThis<"u"&&globalThis.URL||require("url").URL;class HTTPStatusError extends Error{constructor(o,tt,rt){super("status="+tt+" while requesting "+o+" ["+rt+"]"),this.uri=o,this.status=tt,this.method=rt}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";class ResponseError extends Error{constructor(o,tt){super(o),this.cause=tt}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:reduceError(this.cause)}}}ResponseError.prototype.name="ResponseError";ResponseError.prototype.code="RESPONSE_ERR";class TimeoutError extends Error{constructor(o){super("Timeout (t="+o+")."),this.timeout=o}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}TimeoutError.prototype.name="TimeoutError";TimeoutError.prototype.code="ETIMEOUT";const v4Regex=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,v6Regex=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function reduceError(et){if(typeof et=="string")return{message:et};try{const tt=JSON.stringify(et);if(tt!=="{}")return JSON.parse(tt)}catch{}const o={message:String(et.message||et)};return et.code!==void 0&&(o.code=String(et.code)),o}const baseParts=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,httpFlags=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/ig,updFlags=/\[(((pk|name)=([^\]]+)))\]/ig;function parseEndpoint(et){const o=baseParts.exec(et),tt=o[2]||"https:",rt=o[3],nt=o[5],ot=o[6],it=o[7];if(tt==="https:"||tt==="http:"){const st=parseFlags(it,httpFlags);return{name:st.name,protocol:tt,ipv4:st.ipv4,ipv6:st.ipv6,host:rt,port:nt,path:ot,method:st.post?"POST":"GET"}}if(tt==="udp:"||tt==="udp4:"||tt==="udp6:"){const st=parseFlags(it,updFlags),at=/^\[(.*)\]$/.exec(rt);if(at&&tt==="udp4:")throw new Error(`Endpoint parsing error: Cannot use ipv6 host with udp4: (endpoint=${et})`);if(!at&&tt==="udp6:")throw new Error(`Endpoint parsing error: Incorrectly formatted host for udp6: (endpoint=${et})`);return at?new UDP6Endpoint({protocol:"udp6:",ipv6:at[1],port:nt,pk:st.pk,name:st.name}):new UDP4Endpoint({protocol:"udp4:",ipv4:rt,port:nt,pk:st.pk,name:st.name})}throw new InvalidProtocolError(tt,et)}function parseFlags(et,o){o.lastIndex=0;const tt={};for(;;){const rt=o.exec(et);if(!rt)break;rt[2]?tt[rt[3].toLowerCase()]=rt[4]:tt[rt[1].toLowerCase()]=!0}return tt}class InvalidProtocolError extends Error{constructor(o,tt){super(`Invalid Endpoint: unsupported protocol "${o}" for endpoint: ${tt}, supported protocols: ${supportedProtocols.join(", ")}`),this.protocol=o,this.endpoint=tt}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}InvalidProtocolError.prototype.name="InvalidProtocolError";InvalidProtocolError.prototype.code="EPROTOCOL";const supportedProtocols=["http:","https:","udp4:","udp6:"];class BaseEndpoint{constructor(o,tt){this.name=o.name||null,this.protocol=o.protocol;const rt=typeof o.port=="string"?o.port=parseInt(o.port,10):o.port;if(rt==null)this.port=tt?this.protocol==="https:"?443:80:o.pk?443:53;else{if(typeof rt!="number"&&!isNaN(rt))throw new Error(`Invalid Endpoint: port "${o.port}" needs to be a number: ${JSON.stringify(o)}`);this.port=rt}}toJSON(){return this.toString()}}class UDPEndpoint extends BaseEndpoint{constructor(o){super(o,!1),this.pk=o.pk||null}toString(){const o=this.port!==(this.pk?443:53)?`:${this.port}`:"",tt=this.pk?` [pk=${this.pk}]`:"",rt=this.name?` [name=${this.name}]`:"";return`udp://${this.ipv4||`[${this.ipv6}]`}${o}${tt}${rt}`}}class UDP4Endpoint extends UDPEndpoint{constructor(o){if(super(Object.assign({protocol:"udp4:"},o)),!o.ipv4||typeof o.ipv4!="string")throw new Error(`Invalid Endpoint: .ipv4 "${o.ipv4}" needs to be set: ${JSON.stringify(o)}`);this.ipv4=o.ipv4}}class UDP6Endpoint extends UDPEndpoint{constructor(o){if(super(Object.assign({protocol:"udp6:"},o)),!o.ipv6||typeof o.ipv6!="string")throw new Error(`Invalid Endpoint: .ipv6 "${o.ipv6}" needs to be set: ${JSON.stringify(o)}`);this.ipv6=o.ipv6}}function safeHost(et){return v6Regex.test(et)&&!v4Regex.test(et)?`[${et}]`:et}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||typeof o.host!="string")throw new 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){const rt=v6Regex.exec(this.host);rt&&(this.ipv6=rt[1])}this.ipv4||v4Regex.test(this.host)&&(this.ipv4=this.host);const tt=`${this.protocol}//${safeHost(this.host)}:${this.port}${this.path}`;try{this.url=new URL$1(tt)}catch(rt){throw new Error(rt.message+` [${tt}]`)}}toString(){const o=this.protocol==="https:"?"":"http://",tt=this.port!==(this.protocol==="https:"?443:80)?`:${this.port}`:"",rt=this.method!=="GET"?" [post]":"",nt=this.path==="/dns-query"?"":this.path,ot=this.name?` [name=${this.name}]`:"",it=this.ipv4&&this.ipv4!==this.host?` [ipv4=${this.ipv4}]`:"",st=this.ipv6&&this.ipv6!==this.host?` [ipv6=${this.ipv6}]`:"";return`${o}${safeHost(this.host)}${tt}${nt}${rt}${it}${st}${ot}`}}function toEndpoint(et){let o;if(typeof et=="string")o=parseEndpoint(et);else{if(typeof et!="object"||et===null||Array.isArray(et))throw new Error(`Can not convert ${et} to an endpoint`);if(et instanceof BaseEndpoint)return et;o=et}(o.protocol===null||o.protocol===void 0)&&(o.protocol="https:");const tt=o.protocol;if(tt==="udp4:")return new UDP4Endpoint(o);if(tt==="udp6:")return new UDP6Endpoint(o);if(tt==="https:"||tt==="http:")return new HTTPEndpoint(o);throw new InvalidProtocolError(tt,JSON.stringify(o))}const contentType="application/dns-message";function noop$1(){}function queryDns(){throw new Error('Only "doh" endpoints are supported in the browser')}async function loadJSON(et,o,tt,rt){const nt=o?o.localStoragePrefix+o.name:null;if(nt)try{const st=JSON.parse(localStorage.getItem(nt));if(st&&st.time>o.maxTime)return st}catch{}const{data:ot}=await requestRaw(et,"GET",null,tt,rt),it={time:Date.now(),data:JSON.parse(decode$4(ot))};if(nt)try{localStorage.setItem(nt,JSON.stringify(it))}catch{it.time=null}return it}function requestRaw(et,o,tt,rt,nt){return new Promise((ot,it)=>{const st=new URL$1(et);o==="GET"&&tt&&(st.search="?dns="+base64URL.decode(tt));const at=st.toString(),ct=new XMLHttpRequest;ct.open(o,at,!0),ct.setRequestHeader("Accept",contentType),o==="POST"&&ct.setRequestHeader("Content-Type",contentType),ct.responseType="arraybuffer",ct.timeout=rt,ct.ontimeout=lt,ct.onreadystatechange=ht,ct.onerror=ft,ct.onload=dt,o==="POST"?ct.send(tt):ct.send(),nt&&nt.addEventListener("abort",pt);function lt(){mt(new TimeoutError(rt));try{ct.abort()}catch{}}function dt(){if(ct.status!==200)mt(new HTTPStatusError(at,ct.status,o));else{let yt;if(typeof ct.response=="string")yt=encode$3(ct.response);else if(ct.response instanceof Uint8Array)yt=ct.response;else if(Array.isArray(ct.response)||ct.response instanceof ArrayBuffer)yt=new Uint8Array(ct.response);else throw new Error("Unprocessable response "+ct.response);mt(null,yt)}}function ht(){if(ct.readyState>1&&ct.status!==200&&ct.status!==0){mt(new HTTPStatusError(at,ct.status,o));try{ct.abort()}catch{}}}let mt=function(yt,gt){mt=noop$1,nt&&nt.removeEventListener("abort",pt),ot(yt?{error:yt,response:ct}:{data:gt,response:ct})};function ft(){mt(ct.status===200?new Error("Inexplicable XHR Error"):new HTTPStatusError(at,ct.status,o))}function pt(){mt(new AbortError);try{ct.abort()}catch{}}})}function request(et,o,tt,rt,nt){return requestRaw(et,o,tt,rt,nt)}function processResolvers$1(et){return et.filter(o=>o.cors||o.endpoint.cors)}const resolvers={data:[{name:"adfree.usableprivacy.net",endpoint:{protocol:"https:",host:"adfree.usableprivacy.net"},description:`Public updns DoH service with advertising, tracker and malware filters. Hosted 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/ Server 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/ Server 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/ @@ -4040,14 +4040,14 @@ https://www.switch.ch Provides 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. DoH, 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. DoH, 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 -https://www.dnscrypt.uk`,country:"United Kingdom",location:{lat:51.4964,long:-.1224}}],time:1654187067783};function processResolvers(et){const o=et.time===null||et.time===void 0?Date.now():et.time,tt=processResolvers$1(et.data.map(nt=>(nt.endpoint=toEndpoint(Object.assign({name:nt.name},nt.endpoint)),nt))),rt=tt.map(nt=>nt.endpoint);return{data:{resolvers:tt,resolverByName:tt.reduce((nt,ot)=>(nt[ot.name]=ot,nt),{}),endpoints:rt,endpointByName:rt.reduce((nt,ot)=>(nt[ot.name]=ot,nt),{})},time:o}}const backup=processResolvers(resolvers);function toMultiQuery(et){const o=Object.assign({type:"query"},et);return delete o.question,o.questions=[],et.question&&o.questions.push(et.question),o}function queryOne(et,o,tt,rt){return rt&&rt.aborted?Promise.reject(new AbortError):et.protocol==="udp4:"||et.protocol==="udp6:"?queryDns():queryDoh(et,o,tt,rt)}function queryDoh(et,o,tt,rt){return request(et.url,et.method,encode$2(Object.assign({flags:RECURSION_DESIRED},o)),tt,rt).then(function(nt){const ot=nt.data,it=nt.response;let st=nt.error;if(st===void 0)if(ot.length===0)st=new ResponseError("Empty.");else try{const at=decode$3(ot);return at.response=it,at}catch(at){st=new ResponseError("Invalid packet (cause="+at.message+")",at)}throw Object.assign(st,{response:it})})}const UPDATE_URL=new URL$1("https://martinheidegger.github.io/dns-query/resolvers.json");function isNameString(et){return/^@/.test(et)}class Wellknown{constructor(o){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:UPDATE_URL,persist:!1,localStoragePrefix:"dnsquery_",maxAge:3e5},o),this._dataP=null}_data(o,tt){return!o&&this._dataP!==null?this._dataP.then(rt=>rt.timeprocessResolvers({data:rt.data.resolvers,time:rt.time})).catch(()=>tt||backup):Promise.resolve(backup),this._dataP)}data(){return this._data(!1).then(o=>o.data)}endpoints(o){if(o==null)return this.data().then(tt=>tt.endpoints);if(o==="doh"&&(o=filterDoh),o==="dns"&&(o=filterDns),typeof o=="function")return this.data().then(tt=>tt.endpoints.filter(o));if(typeof o=="string"||typeof o[Symbol.iterator]!="function")return Promise.reject(new Error(`Endpoints (${o}) needs to be iterable (array).`));if(o=Array.from(o).filter(Boolean),o.findIndex(isNameString)===-1)try{return Promise.resolve(o.map(toEndpoint))}catch(tt){return Promise.reject(tt)}return this.data().then(tt=>o.map(rt=>{if(isNameString(rt)){const nt=tt.endpointByName[rt.substring(1)];if(!nt)throw new Error(`Endpoint ${rt} is not known.`);return nt}return toEndpoint(rt)}))}}const wellknown=new Wellknown;function isPromise(et){return et===null||typeof et!="object"?!1:typeof et.then=="function"}function toPromise(et){return isPromise(et)?et:Promise.resolve(et)}function query(et,o){return o=Object.assign({retries:5,timeout:3e4},o),et.question?toPromise(o.endpoints).then(tt=>{if(!Array.isArray(tt)||tt.length===0)throw new Error("No endpoints defined to lookup dns records.");return queryN(tt.map(toEndpoint),toMultiQuery(et),o)}).then(tt=>(tt.question=tt.questions[0],delete tt.questions,tt)):Promise.reject(new Error("To request data you need to specify a .question!"))}function queryN(et,o,tt){const rt=et.length===1?et[0]:et[Math.floor(Math.random()*et.length)%et.length];return queryOne(rt,o,tt.timeout,tt.signal).then(nt=>(nt.endpoint=rt.toString(),nt),nt=>{if(nt.name==="AbortError"||tt.retries===0)throw nt.endpoint=rt.toString(),nt;return tt.retries>0&&(tt.retries-=1),queryN(et,o,tt)})}function filterDoh(et){return et.protocol==="https:"||et.protocol==="http:"}function filterDns(et){return et.protocol==="udp4:"||et.protocol==="udp6:"}const log$7=new Logger$1("dns-over-https");class DnsOverHttps{constructor(o,tt=3){wt(this,"endpoints");wt(this,"retries");this.endpoints=o,this.retries=tt}static async create(o,tt){const rt=o??await wellknown.endpoints("doh");return new DnsOverHttps(rt,tt)}async resolveTXT(o){let tt;try{tt=(await query({question:{type:"TXT",name:o}},{endpoints:this.endpoints,retries:this.retries})).answers}catch(ot){throw log$7.error("query failed: ",ot),new Error("DNS query failed")}if(!tt)throw new Error(`Could not resolve ${o}`);const rt=tt.map(ot=>ot.data),nt=[];return rt.forEach(ot=>{typeof ot=="string"?nt.push(ot):Array.isArray(ot)?ot.forEach(it=>{typeof it=="string"?nt.push(it):nt.push(bytesToUtf8(it))}):nt.push(bytesToUtf8(ot))}),nt}}var base32$3={exports:{}};/* +https://www.dnscrypt.uk`,country:"United Kingdom",location:{lat:51.4964,long:-.1224}}],time:1654187067783};function processResolvers(et){const o=et.time===null||et.time===void 0?Date.now():et.time,tt=processResolvers$1(et.data.map(nt=>(nt.endpoint=toEndpoint(Object.assign({name:nt.name},nt.endpoint)),nt))),rt=tt.map(nt=>nt.endpoint);return{data:{resolvers:tt,resolverByName:tt.reduce((nt,ot)=>(nt[ot.name]=ot,nt),{}),endpoints:rt,endpointByName:rt.reduce((nt,ot)=>(nt[ot.name]=ot,nt),{})},time:o}}const backup=processResolvers(resolvers);function toMultiQuery(et){const o=Object.assign({type:"query"},et);return delete o.question,o.questions=[],et.question&&o.questions.push(et.question),o}function queryOne(et,o,tt,rt){return rt&&rt.aborted?Promise.reject(new AbortError):et.protocol==="udp4:"||et.protocol==="udp6:"?queryDns():queryDoh(et,o,tt,rt)}function queryDoh(et,o,tt,rt){return request(et.url,et.method,encode$2(Object.assign({flags:RECURSION_DESIRED},o)),tt,rt).then(function(nt){const ot=nt.data,it=nt.response;let st=nt.error;if(st===void 0)if(ot.length===0)st=new ResponseError("Empty.");else try{const at=decode$3(ot);return at.response=it,at}catch(at){st=new ResponseError("Invalid packet (cause="+at.message+")",at)}throw Object.assign(st,{response:it})})}const UPDATE_URL=new URL$1("https://martinheidegger.github.io/dns-query/resolvers.json");function isNameString(et){return/^@/.test(et)}class Wellknown{constructor(o){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:UPDATE_URL,persist:!1,localStoragePrefix:"dnsquery_",maxAge:3e5},o),this._dataP=null}_data(o,tt){return!o&&this._dataP!==null?this._dataP.then(rt=>rt.timeprocessResolvers({data:rt.data.resolvers,time:rt.time})).catch(()=>tt||backup):Promise.resolve(backup),this._dataP)}data(){return this._data(!1).then(o=>o.data)}endpoints(o){if(o==null)return this.data().then(tt=>tt.endpoints);if(o==="doh"&&(o=filterDoh),o==="dns"&&(o=filterDns),typeof o=="function")return this.data().then(tt=>tt.endpoints.filter(o));if(typeof o=="string"||typeof o[Symbol.iterator]!="function")return Promise.reject(new Error(`Endpoints (${o}) needs to be iterable (array).`));if(o=Array.from(o).filter(Boolean),o.findIndex(isNameString)===-1)try{return Promise.resolve(o.map(toEndpoint))}catch(tt){return Promise.reject(tt)}return this.data().then(tt=>o.map(rt=>{if(isNameString(rt)){const nt=tt.endpointByName[rt.substring(1)];if(!nt)throw new Error(`Endpoint ${rt} is not known.`);return nt}return toEndpoint(rt)}))}}const wellknown=new Wellknown;function isPromise(et){return et===null||typeof et!="object"?!1:typeof et.then=="function"}function toPromise(et){return isPromise(et)?et:Promise.resolve(et)}function query(et,o){return o=Object.assign({retries:5,timeout:3e4},o),et.question?toPromise(o.endpoints).then(tt=>{if(!Array.isArray(tt)||tt.length===0)throw new Error("No endpoints defined to lookup dns records.");return queryN(tt.map(toEndpoint),toMultiQuery(et),o)}).then(tt=>(tt.question=tt.questions[0],delete tt.questions,tt)):Promise.reject(new Error("To request data you need to specify a .question!"))}function queryN(et,o,tt){const rt=et.length===1?et[0]:et[Math.floor(Math.random()*et.length)%et.length];return queryOne(rt,o,tt.timeout,tt.signal).then(nt=>(nt.endpoint=rt.toString(),nt),nt=>{if(nt.name==="AbortError"||tt.retries===0)throw nt.endpoint=rt.toString(),nt;return tt.retries>0&&(tt.retries-=1),queryN(et,o,tt)})}function filterDoh(et){return et.protocol==="https:"||et.protocol==="http:"}function filterDns(et){return et.protocol==="udp4:"||et.protocol==="udp6:"}const log$7=new Logger$1("dns-over-https");class DnsOverHttps{constructor(o,tt=3){wt(this,"endpoints");wt(this,"retries");this.endpoints=o,this.retries=tt}static async create(o,tt){const rt=o??await wellknown.endpoints("doh");return new DnsOverHttps(rt,tt)}async resolveTXT(o){let tt;try{tt=(await query({question:{type:"TXT",name:o}},{endpoints:this.endpoints,retries:this.retries})).answers}catch(ot){throw log$7.error("query failed: ",ot),new Error("DNS query failed")}if(!tt)throw new Error(`Could not resolve ${o}`);const rt=tt.map(ot=>ot.data),nt=[];return rt.forEach(ot=>{typeof ot=="string"?nt.push(ot):Array.isArray(ot)?ot.forEach(it=>{typeof it=="string"?nt.push(it):nt.push(bytesToUtf8(it))}):nt.push(bytesToUtf8(ot))}),nt}}var base32$3={exports:{}};(function(et){var o={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0};/* * [hi-base32]{@link https://github.com/emn178/hi-base32} * * @version 0.5.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2015-2018 * @license MIT - */(function(et){(function(){var o=typeof window=="object"?window:{},tt=!o.HI_BASE32_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;tt&&(o=commonjsGlobal);var rt=!o.HI_BASE32_NO_COMMON_JS&&!0&&et.exports,nt="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),ot={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},it=[0,0,0,0,0,0,0,0],st=function(gt,yt){yt.length>10&&(yt="..."+yt.substr(-10));var bt=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+gt+" bytes: "+yt+" <-");throw bt.position=gt,bt},at=function(gt){for(var yt="",bt=gt.length,xt=0,vt=0,Et,Ct;xt191&&Et<=223?(Ct=Et&31,vt=1):Et<=239?(Ct=Et&15,vt=2):Et<=247?(Ct=Et&7,vt=3):st(xt,yt);for(var St=0;St191)&&st(xt,yt),Ct<<=6,Ct+=Et&63;Ct>=55296&&Ct<=57343&&st(xt,yt),Ct>1114111&&st(xt,yt),Ct<=65535?yt+=String.fromCharCode(Ct):(Ct-=65536,yt+=String.fromCharCode((Ct>>10)+55296),yt+=String.fromCharCode((Ct&1023)+56320))}return yt},ct=function(gt){if(gt==="")return[];if(!/^[A-Z2-7=]+$/.test(gt))throw new Error("Invalid base32 characters");gt=gt.replace(/=/g,"");for(var yt,bt,xt,vt,Et,Ct,St,At,kt=[],It=0,Ot=gt.length,Nt=0,Yt=Ot>>3<<3;Nt>>2)&255,kt[It++]=(bt<<6|xt<<1|vt>>>4)&255,kt[It++]=(vt<<4|Et>>>1)&255,kt[It++]=(Et<<7|Ct<<2|St>>>3)&255,kt[It++]=(St<<5|At)&255;var Ft=Ot-Yt;return Ft===2?(yt=ot[gt.charAt(Nt++)],bt=ot[gt.charAt(Nt++)],kt[It++]=(yt<<3|bt>>>2)&255):Ft===4?(yt=ot[gt.charAt(Nt++)],bt=ot[gt.charAt(Nt++)],xt=ot[gt.charAt(Nt++)],vt=ot[gt.charAt(Nt++)],kt[It++]=(yt<<3|bt>>>2)&255,kt[It++]=(bt<<6|xt<<1|vt>>>4)&255):Ft===5?(yt=ot[gt.charAt(Nt++)],bt=ot[gt.charAt(Nt++)],xt=ot[gt.charAt(Nt++)],vt=ot[gt.charAt(Nt++)],Et=ot[gt.charAt(Nt++)],kt[It++]=(yt<<3|bt>>>2)&255,kt[It++]=(bt<<6|xt<<1|vt>>>4)&255,kt[It++]=(vt<<4|Et>>>1)&255):Ft===7&&(yt=ot[gt.charAt(Nt++)],bt=ot[gt.charAt(Nt++)],xt=ot[gt.charAt(Nt++)],vt=ot[gt.charAt(Nt++)],Et=ot[gt.charAt(Nt++)],Ct=ot[gt.charAt(Nt++)],St=ot[gt.charAt(Nt++)],kt[It++]=(yt<<3|bt>>>2)&255,kt[It++]=(bt<<6|xt<<1|vt>>>4)&255,kt[It++]=(vt<<4|Et>>>1)&255,kt[It++]=(Et<<7|Ct<<2|St>>>3)&255),kt},lt=function(gt){for(var yt,bt,xt,vt,Et,Ct="",St=gt.length,At=0,kt=parseInt(St/5)*5;At>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[(bt<<4|xt>>>4)&31]+nt[(xt<<1|vt>>>7)&31]+nt[vt>>>2&31]+nt[(vt<<3|Et>>>5)&31]+nt[Et&31];var It=St-kt;return It===1?(yt=gt.charCodeAt(At),Ct+=nt[yt>>>3]+nt[yt<<2&31]+"======"):It===2?(yt=gt.charCodeAt(At++),bt=gt.charCodeAt(At),Ct+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[bt<<4&31]+"===="):It===3?(yt=gt.charCodeAt(At++),bt=gt.charCodeAt(At++),xt=gt.charCodeAt(At),Ct+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[(bt<<4|xt>>>4)&31]+nt[xt<<1&31]+"==="):It===4&&(yt=gt.charCodeAt(At++),bt=gt.charCodeAt(At++),xt=gt.charCodeAt(At++),vt=gt.charCodeAt(At),Ct+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[(bt<<4|xt>>>4)&31]+nt[(xt<<1|vt>>>7)&31]+nt[vt>>>2&31]+nt[vt<<3&31]+"="),Ct},dt=function(gt){var yt,bt,xt,vt,Et,Ct,St=!1,At="",kt=0,It,Ot=0,Nt=gt.length;if(gt==="")return At;do{for(it[0]=it[5],it[1]=it[6],it[2]=it[7],It=Ot;kt>6,it[It++]=128|Ct&63):Ct<55296||Ct>=57344?(it[It++]=224|Ct>>12,it[It++]=128|Ct>>6&63,it[It++]=128|Ct&63):(Ct=65536+((Ct&1023)<<10|gt.charCodeAt(++kt)&1023),it[It++]=240|Ct>>18,it[It++]=128|Ct>>12&63,it[It++]=128|Ct>>6&63,it[It++]=128|Ct&63);Ot=It-5,kt===Nt&&++kt,kt>Nt&&It<6&&(St=!0),yt=it[0],It>4?(bt=it[1],xt=it[2],vt=it[3],Et=it[4],At+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[(bt<<4|xt>>>4)&31]+nt[(xt<<1|vt>>>7)&31]+nt[vt>>>2&31]+nt[(vt<<3|Et>>>5)&31]+nt[Et&31]):It===1?At+=nt[yt>>>3]+nt[yt<<2&31]+"======":It===2?(bt=it[1],At+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[bt<<4&31]+"===="):It===3?(bt=it[1],xt=it[2],At+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[(bt<<4|xt>>>4)&31]+nt[xt<<1&31]+"==="):(bt=it[1],xt=it[2],vt=it[3],At+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[(bt<<4|xt>>>4)&31]+nt[(xt<<1|vt>>>7)&31]+nt[vt>>>2&31]+nt[vt<<3&31]+"=")}while(!St);return At},ht=function(gt){for(var yt,bt,xt,vt,Et,Ct="",St=gt.length,At=0,kt=parseInt(St/5)*5;At>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[(bt<<4|xt>>>4)&31]+nt[(xt<<1|vt>>>7)&31]+nt[vt>>>2&31]+nt[(vt<<3|Et>>>5)&31]+nt[Et&31];var It=St-kt;return It===1?(yt=gt[At],Ct+=nt[yt>>>3]+nt[yt<<2&31]+"======"):It===2?(yt=gt[At++],bt=gt[At],Ct+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[bt<<4&31]+"===="):It===3?(yt=gt[At++],bt=gt[At++],xt=gt[At],Ct+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[(bt<<4|xt>>>4)&31]+nt[xt<<1&31]+"==="):It===4&&(yt=gt[At++],bt=gt[At++],xt=gt[At++],vt=gt[At],Ct+=nt[yt>>>3]+nt[(yt<<2|bt>>>6)&31]+nt[bt>>>1&31]+nt[(bt<<4|xt>>>4)&31]+nt[(xt<<1|vt>>>7)&31]+nt[vt>>>2&31]+nt[vt<<3&31]+"="),Ct},mt=function(gt,yt){var bt=typeof gt!="string";return bt&>.constructor===ArrayBuffer&&(gt=new Uint8Array(gt)),bt?ht(gt):yt?lt(gt):dt(gt)},ft=function(gt,yt){if(!yt)return at(ct(gt));if(gt==="")return"";if(!/^[A-Z2-7=]+$/.test(gt))throw new Error("Invalid base32 characters");var bt,xt,vt,Et,Ct,St,At,kt,It="",Ot=gt.indexOf("=");Ot===-1&&(Ot=gt.length);for(var Nt=0,Yt=Ot>>3<<3;Nt>>2)&255)+String.fromCharCode((xt<<6|vt<<1|Et>>>4)&255)+String.fromCharCode((Et<<4|Ct>>>1)&255)+String.fromCharCode((Ct<<7|St<<2|At>>>3)&255)+String.fromCharCode((At<<5|kt)&255);var Ft=Ot-Yt;return Ft===2?(bt=ot[gt.charAt(Nt++)],xt=ot[gt.charAt(Nt++)],It+=String.fromCharCode((bt<<3|xt>>>2)&255)):Ft===4?(bt=ot[gt.charAt(Nt++)],xt=ot[gt.charAt(Nt++)],vt=ot[gt.charAt(Nt++)],Et=ot[gt.charAt(Nt++)],It+=String.fromCharCode((bt<<3|xt>>>2)&255)+String.fromCharCode((xt<<6|vt<<1|Et>>>4)&255)):Ft===5?(bt=ot[gt.charAt(Nt++)],xt=ot[gt.charAt(Nt++)],vt=ot[gt.charAt(Nt++)],Et=ot[gt.charAt(Nt++)],Ct=ot[gt.charAt(Nt++)],It+=String.fromCharCode((bt<<3|xt>>>2)&255)+String.fromCharCode((xt<<6|vt<<1|Et>>>4)&255)+String.fromCharCode((Et<<4|Ct>>>1)&255)):Ft===7&&(bt=ot[gt.charAt(Nt++)],xt=ot[gt.charAt(Nt++)],vt=ot[gt.charAt(Nt++)],Et=ot[gt.charAt(Nt++)],Ct=ot[gt.charAt(Nt++)],St=ot[gt.charAt(Nt++)],At=ot[gt.charAt(Nt++)],It+=String.fromCharCode((bt<<3|xt>>>2)&255)+String.fromCharCode((xt<<6|vt<<1|Et>>>4)&255)+String.fromCharCode((Et<<4|Ct>>>1)&255)+String.fromCharCode((Ct<<7|St<<2|At>>>3)&255)),It},pt={encode:mt,decode:ft};ft.asBytes=ct,rt?et.exports=pt:o.base32=pt})()})(base32$3);var base32Exports=base32$3.exports;const base32$2=getDefaultExportFromCjs(base32Exports);function coerce$1(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$1(et){return new TextEncoder().encode(et)}function toString$2(et){return new TextDecoder().decode(et)}function base(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);yt!==bt;){for(var Et=ft[yt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");gt=Ct,yt++}for(var At=xt-gt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");yt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-yt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(gt+(bt-St)),kt=gt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$1=base,_brrp__multiformats_scope_baseX=src$1;class Encoder{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}}class Decoder{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or(this,o)}}class ComposedDecoder{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function or(et,o){return new ComposedDecoder({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}class Codec{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder(o,tt,rt),this.decoder=new Decoder(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}}function from({name:et,prefix:o,encode:tt,decode:rt}){return new Codec(et,o,tt,rt)}function baseX({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX(tt,et);return from({prefix:o,name:et,encode:rt,decode:ot=>coerce$1(nt(ot))})}function decode$2(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$1(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes=alphabet.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars[tt],o),"")}function decode$1(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji=from({prefix:"🚀",name:"base256emoji",encode,decode:decode$1}),base256emoji$1=Object.freeze(Object.defineProperty({__proto__:null,base256emoji},Symbol.toStringTag,{value:"Module"})),base32=rfc4648({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper=rfc4648({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad=rfc4648({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper=rfc4648({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex=rfc4648({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper=rfc4648({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad=rfc4648({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper=rfc4648({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z=rfc4648({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$1=Object.freeze(Object.defineProperty({__proto__:null,base32,base32hex,base32hexpad,base32hexpadupper,base32hexupper,base32pad,base32padupper,base32upper,base32z},Symbol.toStringTag,{value:"Module"})),base36=baseX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper=baseX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$1=Object.freeze(Object.defineProperty({__proto__:null,base36,base36upper},Symbol.toStringTag,{value:"Module"})),base58btc=baseX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr=baseX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58=Object.freeze(Object.defineProperty({__proto__:null,base58btc,base58flickr},Symbol.toStringTag,{value:"Module"})),base64$2=rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad=rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url=rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad=rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$3=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$2,base64pad,base64url,base64urlpad},Symbol.toStringTag,{value:"Module"})),base8=rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$1=Object.freeze(Object.defineProperty({__proto__:null,base8},Symbol.toStringTag,{value:"Module"})),identity=from({prefix:"\0",name:"identity",encode:et=>toString$2(et),decode:et=>fromString$1(et)}),identityBase=Object.freeze(Object.defineProperty({__proto__:null,identity},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases={...identityBase,...base2$1,...base8$1,...base10$1,...base16$1,...base32$1,...base36$1,...base58,...base64$3,...base256emoji$1};function allocUnsafe(et=0){return new Uint8Array(et)}function createCodec(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$2=createCodec("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii=createCodec("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe(et.length);for(let tt=0;tt=et.relay&&o.store>=et.store&&o.filter>=et.filter&&o.lightPush>=et.lightPush}function isNewPeer(et,o){if(!et.nodeId)return!1;for(const tt of o)if(et.nodeId===tt.nodeId)return!1;return!0}function addCapabilities(et,o){et.relay&&(o.relay+=1),et.store&&(o.store+=1),et.filter&&(o.filter+=1),et.lightPush&&(o.lightPush+=1)}function helpsSatisfyCapabilities(et,o,tt){if(isSatisfied(o,tt))throw"Internal Error: Waku2 wanted capabilities are already fulfilled";const rt=missingCapabilities(o,tt);return rt.relay&&et.relay||rt.store&&et.store||rt.filter&&et.filter||rt.lightPush&&et.lightPush}function missingCapabilities(et,o){return{relay:o.relaythis._search(ot,it));return log$5.info("retrieved peers: ",st.map(at=>{var ct,lt;return{id:(ct=at.peerId)==null?void 0:ct.toString(),multiaddrs:(lt=at.multiaddrs)==null?void 0:lt.map(dt=>dt.toString())}})),st}async*getNextPeer(o,tt){const rt=Math.floor(Math.random()*o.length),{publicKey:nt,domain:ot}=ENRTree.parseTree(o[rt]),it={domain:ot,publicKey:nt,visits:{}};for await(const st of yieldNodesUntilCapabilitiesFulfilled(tt,this._errorTolerance,()=>this._search(ot,it)))yield st}async _search(o,tt){try{const rt=await this._getTXTRecord(o,tt);tt.visits[o]=!0;let nt,ot;const it=getEntryType(rt);try{switch(it){case ENRTree.ROOT_PREFIX:return nt=ENRTree.parseAndVerifyRoot(rt,tt.publicKey),await this._search(nt,tt);case ENRTree.BRANCH_PREFIX:return ot=ENRTree.parseBranch(rt),nt=selectRandomPath(ot,tt),await this._search(nt,tt);case ENRTree.RECORD_PREFIX:return EnrDecoder.fromString(rt);default:return null}}catch(st){return log$5.error(`Failed to search DNS tree ${it} at subdomain ${o}: ${st}`),null}}catch(rt){return log$5.error(`Failed to retrieve TXT record at subdomain ${o}: ${rt}`),null}}async _getTXTRecord(o,tt){if(this._DNSTreeCache[o])return this._DNSTreeCache[o];const rt=o!==tt.domain?`${o}.${tt.domain}`:tt.domain,nt=await this.dns.resolveTXT(rt);if(!nt.length)throw new Error("Received empty result array while fetching TXT record");if(!nt[0].length)throw new Error("Received empty TXT record");const ot=nt.join("");return this._DNSTreeCache[o]=ot,ot}}function getEntryType(et){return et.startsWith(ENRTree.ROOT_PREFIX)?ENRTree.ROOT_PREFIX:et.startsWith(ENRTree.BRANCH_PREFIX)?ENRTree.BRANCH_PREFIX:et.startsWith(ENRTree.RECORD_PREFIX)?ENRTree.RECORD_PREFIX:""}function selectRandomPath(et,o){const tt={};for(const[nt,ot]of et.entries())o.visits[ot]&&(tt[nt]=!0);if(Object.keys(tt).length===et.length)throw new Error("Unresolvable circular path detected");let rt;do rt=Math.floor(Math.random()*et.length);while(tt[rt]);return et[rt]}const log$4=new Logger$1("peer-discovery-dns");class PeerDiscoveryDns extends TypedEventEmitter$3{constructor(tt,rt){super();wt(this,"nextPeer");wt(this,"_started");wt(this,"_components");wt(this,"_options");this._started=!1,this._components=tt,this._options=rt;const{enrUrls:nt}=rt;log$4.info("Use following EIP-1459 ENR Tree URLs: ",nt)}async start(){log$4.info("Starting peer discovery via dns"),this._started=!0,await this.findPeers()}async findPeers(){if(!this.nextPeer){let{enrUrls:tt}=this._options;Array.isArray(tt)||(tt=[tt]);const{wantedNodeCapabilityCount:rt}=this._options,nt=await DnsNodeDiscovery.dnsOverHttp();this.nextPeer=nt.getNextPeer.bind(nt,tt,rt)}for await(const tt of this.nextPeer()){if(!this._started)return;const{peerInfo:rt,shardInfo:nt}=tt;if(!rt)continue;const ot={[DEFAULT_BOOTSTRAP_TAG_NAME]:{value:this._options.tagValue??DEFAULT_BOOTSTRAP_TAG_VALUE,ttl:this._options.tagTTL??DEFAULT_BOOTSTRAP_TAG_TTL}};let it=!1;await this._components.peerStore.has(rt.id)?(await this._components.peerStore.get(rt.id)).tags.has(DEFAULT_BOOTSTRAP_TAG_NAME)||(it=!0,await this._components.peerStore.merge(rt.id,{tags:ot})):(it=!0,await this._components.peerStore.save(rt.id,{tags:ot,...nt&&{metadata:{shardInfo:encodeRelayShard(nt)}}})),it&&this.dispatchEvent(new CustomEvent("peer",{detail:rt}))}}stop(){this._started=!1}get[peerDiscoverySymbol$2](){return!0}get[Symbol.toStringTag](){return DNS_DISCOVERY_TAG}}function wakuDnsDiscovery(et,o=DEFAULT_NODE_REQUIREMENTS){return tt=>new PeerDiscoveryDns(tt,{enrUrls:et,wantedNodeCapabilityCount:o})}class PeerExchangeRPC{constructor(o){wt(this,"proto");this.proto=o}static createRequest(o){const{numPeers:tt}=o;return new PeerExchangeRPC({query:{numPeers:tt},response:void 0})}encode(){return PeerExchangeRPC$1.encode(this.proto)}static decode(o){const tt=PeerExchangeRPC$1.decode(o);return new PeerExchangeRPC(tt)}get query(){return this.proto.query}get response(){return this.proto.response}}const PeerExchangeCodec="/vac/waku/peer-exchange/2.0.0-alpha1",log$3=new Logger$1("peer-exchange");class WakuPeerExchange extends BaseProtocol{constructor(o,tt){super(PeerExchangeCodec,o,log$3,tt)}async query(o){const{numPeers:tt,peerId:rt}=o,nt=PeerExchangeRPC.createRequest({numPeers:BigInt(tt)}),ot=await this.components.peerStore.get(rt);if(!ot)return{peerInfos:null,error:ProtocolError$1.NO_PEER_AVAILABLE};let it;try{it=await this.getStream(ot)}catch(at){return log$3.error("Failed to get stream",at),{peerInfos:null,error:ProtocolError$1.NO_STREAM_AVAILABLE}}const st=await pipe([nt.encode()],encode$K,it,decode$U,async at=>await all$2(at));try{const at=new Uint8ArrayList;st.forEach(dt=>{at.append(dt)});const{response:ct}=PeerExchangeRPC.decode(at);return ct?{peerInfos:await Promise.all(ct.peerInfos.map(dt=>dt.enr).filter(isDefined).map(async dt=>({ENR:await EnrDecoder.fromRLP(dt)}))),error:null}:(log$3.error("PeerExchangeRPC message did not contains a `response` field"),{peerInfos:null,error:ProtocolError$1.EMPTY_PAYLOAD})}catch(at){return log$3.error("Failed to decode push reply",at),{peerInfos:null,error:ProtocolError$1.DECODE_FAILED}}}}const log$2=new Logger$1("peer-exchange-discovery"),DEFAULT_PEER_EXCHANGE_REQUEST_NODES=10,DEFAULT_PEER_EXCHANGE_QUERY_INTERVAL_MS=10*1e3,DEFAULT_MAX_RETRIES=3,DEFAULT_PEER_EXCHANGE_TAG_NAME=Tags.PEER_EXCHANGE,DEFAULT_PEER_EXCHANGE_TAG_VALUE=50,DEFAULT_PEER_EXCHANGE_TAG_TTL=1e8;class PeerExchangeDiscovery extends TypedEventEmitter$3{constructor(tt,rt,nt={}){super();wt(this,"components");wt(this,"peerExchange");wt(this,"options");wt(this,"isStarted");wt(this,"queryingPeers",new Set);wt(this,"queryAttempts",new Map);wt(this,"handleDiscoveredPeer",tt=>{const{protocols:rt,peerId:nt}=tt.detail;!rt.includes(PeerExchangeCodec)||this.queryingPeers.has(nt.toString())||(this.queryingPeers.add(nt.toString()),this.startRecurringQueries(nt).catch(ot=>log$2.error(`Error querying peer ${ot}`)))});wt(this,"startRecurringQueries",async tt=>{const rt=tt.toString(),{queryInterval:nt=DEFAULT_PEER_EXCHANGE_QUERY_INTERVAL_MS,maxRetries:ot=DEFAULT_MAX_RETRIES}=this.options;log$2.info(`Querying peer: ${rt} (attempt ${this.queryAttempts.get(rt)??1})`),await this.query(tt);const it=this.queryAttempts.get(rt)??1;if(it>ot){this.abortQueriesForPeer(rt);return}setTimeout(()=>{this.queryAttempts.set(rt,it+1),this.startRecurringQueries(tt).catch(st=>{log$2.error(`Error in startRecurringQueries: ${st}`)})},nt*it)});this.components=tt,this.peerExchange=new WakuPeerExchange(tt,rt),this.options=nt,this.isStarted=!1}start(){this.isStarted||(this.dispatchEvent(new CustomEvent("waku:peer-exchange:started",{detail:!0})),log$2.info("Starting peer exchange node discovery, discovering peers"),this.components.events.addEventListener("peer:identify",this.handleDiscoveredPeer))}stop(){this.isStarted&&(log$2.info("Stopping peer exchange node discovery"),this.isStarted=!1,this.queryingPeers.clear(),this.components.events.removeEventListener("peer:identify",this.handleDiscoveredPeer))}get[peerDiscoverySymbol$2](){return!0}get[Symbol.toStringTag](){return"@waku/peer-exchange"}async query(tt){const{error:rt,peerInfos:nt}=await this.peerExchange.query({numPeers:DEFAULT_PEER_EXCHANGE_REQUEST_NODES,peerId:tt});if(rt)return log$2.error("Peer exchange query failed",rt),{error:rt,peerInfos:null};for(const ot of nt){const{ENR:it}=ot;if(!it){log$2.warn("No ENR in peerInfo object, skipping");continue}const{peerId:st,peerInfo:at,shardInfo:ct}=it;if(!st||!at)continue;if(await this.components.peerStore.has(st)){const{hasMultiaddrDiff:dt,hasShardDiff:ht}=await this.checkPeerInfoDiff(at,ct);if(dt||ht){log$2.info(`Peer ${st.toString()} has updated multiaddrs or shardInfo, updating`),dt&&(log$2.info(`Peer ${st.toString()} has updated multiaddrs, updating`),await this.components.peerStore.patch(st,{multiaddrs:at.multiaddrs})),ht&&ct&&(log$2.info(`Peer ${st.toString()} has updated shardInfo, updating`),await this.components.peerStore.merge(st,{metadata:{shardInfo:encodeRelayShard(ct)}}),this.dispatchEvent(new CustomEvent("peer",{detail:{id:st,multiaddrs:at.multiaddrs}})));continue}}await this.components.peerStore.save(st,{tags:{[DEFAULT_PEER_EXCHANGE_TAG_NAME]:{value:this.options.tagValue??DEFAULT_PEER_EXCHANGE_TAG_VALUE,ttl:this.options.tagTTL??DEFAULT_PEER_EXCHANGE_TAG_TTL}},...ct&&{metadata:{shardInfo:encodeRelayShard(ct)}},...at.multiaddrs&&{multiaddrs:at.multiaddrs}}),log$2.info(`Discovered peer: ${st.toString()}`),this.dispatchEvent(new CustomEvent("peer",{detail:{id:st,multiaddrs:at.multiaddrs}}))}return{error:null,peerInfos:nt}}abortQueriesForPeer(tt){log$2.info(`Aborting queries for peer: ${tt}`),this.queryingPeers.delete(tt),this.queryAttempts.delete(tt)}async checkPeerInfoDiff(tt,rt){const{id:nt}=tt,ot=await this.components.peerStore.get(nt),it=ot.addresses.map(dt=>dt.multiaddr.toString()),st=tt.multiaddrs.map(dt=>dt.toString()),at=it.some(dt=>!st.includes(dt));let ct=!1;const lt=ot.metadata.get("shardInfo");if(lt){const dt=decodeRelayShard(lt);(dt||rt)&&(ct=dt.clusterId!==(rt==null?void 0:rt.clusterId)||dt.shards.some(ht=>!(rt!=null&&rt.shards.includes(ht))))}return{hasMultiaddrDiff:at,hasShardDiff:ct}}}function wakuPeerExchangeDiscovery(et){return o=>new PeerExchangeDiscovery(o,et)}const log$1=new Logger$1("peer-exchange-discovery"),DEFAULT_LOCAL_TAG_NAME=Tags.LOCAL,DEFAULT_LOCAL_TAG_VALUE=50,DEFAULT_LOCAL_TAG_TTL=1e8;class LocalPeerCacheDiscovery extends TypedEventEmitter$3{constructor(tt,rt){super();wt(this,"components");wt(this,"options");wt(this,"isStarted");wt(this,"peers",[]);wt(this,"handleNewPeers",tt=>{const{peerId:rt,listenAddrs:nt}=tt.detail,ot=getWsMultiaddrFromMultiaddrs(nt),it=this.getPeersFromLocalStorage(),st=it.findIndex(at=>at.id===rt.toString());st>=0?it[st].address=ot.toString():it.push({id:rt.toString(),address:ot.toString()}),this.peers=it,this.savePeersToLocalStorage()});this.components=tt,this.options=rt,this.isStarted=!1,this.peers=this.getPeersFromLocalStorage()}get[Symbol.toStringTag](){return"@waku/local-peer-cache-discovery"}async start(){var tt,rt,nt;if(!this.isStarted){log$1.info("Starting Local Storage Discovery"),this.components.events.addEventListener("peer:identify",this.handleNewPeers);for(const{id:ot,address:it}of this.peers){const st=peerIdFromString$1(ot);await this.components.peerStore.has(st)||(await this.components.peerStore.save(st,{multiaddrs:[multiaddr(it)],tags:{[((tt=this.options)==null?void 0:tt.tagName)??DEFAULT_LOCAL_TAG_NAME]:{value:((rt=this.options)==null?void 0:rt.tagValue)??DEFAULT_LOCAL_TAG_VALUE,ttl:((nt=this.options)==null?void 0:nt.tagTTL)??DEFAULT_LOCAL_TAG_TTL}}}),this.dispatchEvent(new CustomEvent("peer",{detail:{id:st,multiaddrs:[multiaddr(it)]}})))}log$1.info(`Discovered ${this.peers.length} peers`),this.isStarted=!0}}stop(){this.isStarted&&(log$1.info("Stopping Local Storage Discovery"),this.components.events.removeEventListener("peer:identify",this.handleNewPeers),this.isStarted=!1,this.savePeersToLocalStorage())}getPeersFromLocalStorage(){try{const tt=localStorage.getItem("waku:peers");return tt?JSON.parse(tt).filter(isValidStoredPeer):[]}catch(tt){return log$1.error("Error parsing peers from local storage:",tt),[]}}savePeersToLocalStorage(){try{localStorage.setItem("waku:peers",JSON.stringify(this.peers))}catch(tt){log$1.error("Error saving peers to local storage:",tt)}}}function isValidStoredPeer(et){return et&&typeof et=="object"&&typeof et.id=="string"&&typeof et.address=="string"}function wakuLocalPeerCacheDiscovery(){return(et,o)=>new LocalPeerCacheDiscovery(et,o)}function defaultPeerDiscoveries(et){const o=[enrTree.SANDBOX,enrTree.TEST];return[wakuDnsDiscovery(o),wakuLocalPeerCacheDiscovery(),wakuPeerExchangeDiscovery(et)]}const log=new Logger$1("sdk:create");async function defaultLibp2p(et,o,tt){var ot,it;!(o!=null&&o.hideWebSocketInfo)&&((ot=process==null?void 0:process.env)==null?void 0:ot.NODE_ENV)!=="test"&&(console.info("%cIgnore WebSocket connection failures","background: gray; color: white; font-size: x-large"),console.info("%cWaku tries to discover peers and some of them are expected to fail","background: gray; color: white; font-size: x-large"));const rt=et?{metadata:wakuMetadata(et)}:{},nt=(o==null?void 0:o.filterMultiaddrs)===!1||((it=process==null?void 0:process.env)==null?void 0:it.NODE_ENV)==="test"?all$1:wss;return createLibp2p({transports:[webSockets({filter:nt})],streamMuxers:[mplex()],connectionEncrypters:[noise()],...o,services:{identify:identify({agentVersion:tt??DefaultUserAgent}),ping:ping({maxInboundStreams:(o==null?void 0:o.pingMaxInboundStreams)??DefaultPingMaxInboundStreams}),...rt,...o==null?void 0:o.services}})}async function createLibp2pAndUpdateOptions(et){const{networkConfig:o}=et,tt=derivePubsubTopicsFromNetworkConfig(o??DefaultNetworkConfig);log.info("Creating Waku node with pubsub topics",tt);const rt=(et==null?void 0:et.libp2p)??{},nt=rt.peerDiscovery??[];return et!=null&&et.defaultBootstrap&&nt.push(...defaultPeerDiscoveries(tt)),et!=null&&et.bootstrapPeers&&nt.push(bootstrap({list:et.bootstrapPeers})),rt.peerDiscovery=nt,{libp2p:await defaultLibp2p(tt,rt,et==null?void 0:et.userAgent),pubsubTopics:tt}}async function createLightNode(et={}){const{libp2p:o,pubsubTopics:tt}=await createLibp2pAndUpdateOptions(et);return new WakuNode(tt,et,o,{store:!0,lightpush:!0,filter:!0})}React.createContext({decoder:void 0,encoder:void 0});const useCreateNode=et=>{const{factory:o,options:tt,protocols:rt=[]}=et,[nt,ot]=React.useState(void 0),[it,st]=React.useState(!0),[at,ct]=React.useState(void 0);return React.useEffect(()=>{let lt=!1;return st(!0),o(tt).then(async dt=>{lt||(await dt.start(),await waitForRemotePeer(dt,rt),ot(dt),st(!1))}).catch(dt=>{st(!1),ct(`Failed at creating node: ${(dt==null?void 0:dt.message)||"no message"}`)}),()=>{lt=!0}},[]),{node:nt,error:at,isLoading:it}},useCreateLightNode=et=>useCreateNode({...et,factory:createLightNode}),WakuContext=React.createContext({node:void 0,isLoading:!1,error:void 0}),useWaku=()=>React.useContext(WakuContext),LightNodeProvider=et=>{const o=useCreateLightNode({options:et.options,protocols:et.protocols});return React.createElement(WakuContext.Provider,{value:o},et.children)};/** + */(function(){var tt=typeof window=="object"?window:{},rt=!tt.HI_BASE32_NO_NODE_JS&&typeof o=="object"&&o.versions&&o.versions.node;rt&&(tt=globalThis);var nt=!tt.HI_BASE32_NO_COMMON_JS&&!0&&et.exports,ot="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),it={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},st=[0,0,0,0,0,0,0,0],at=function(gt,bt){bt.length>10&&(bt="..."+bt.substr(-10));var xt=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+gt+" bytes: "+bt+" <-");throw xt.position=gt,xt},ct=function(gt){for(var bt="",xt=gt.length,vt=0,Et=0,Ct,St;vt191&&Ct<=223?(St=Ct&31,Et=1):Ct<=239?(St=Ct&15,Et=2):Ct<=247?(St=Ct&7,Et=3):at(vt,bt);for(var At=0;At191)&&at(vt,bt),St<<=6,St+=Ct&63;St>=55296&&St<=57343&&at(vt,bt),St>1114111&&at(vt,bt),St<=65535?bt+=String.fromCharCode(St):(St-=65536,bt+=String.fromCharCode((St>>10)+55296),bt+=String.fromCharCode((St&1023)+56320))}return bt},lt=function(gt){if(gt==="")return[];if(!/^[A-Z2-7=]+$/.test(gt))throw new Error("Invalid base32 characters");gt=gt.replace(/=/g,"");for(var bt,xt,vt,Et,Ct,St,At,kt,It=[],Nt=0,Lt=gt.length,Mt=0,zt=Lt>>3<<3;Mt>>2)&255,It[Nt++]=(xt<<6|vt<<1|Et>>>4)&255,It[Nt++]=(Et<<4|Ct>>>1)&255,It[Nt++]=(Ct<<7|St<<2|At>>>3)&255,It[Nt++]=(At<<5|kt)&255;var Ut=Lt-zt;return Ut===2?(bt=it[gt.charAt(Mt++)],xt=it[gt.charAt(Mt++)],It[Nt++]=(bt<<3|xt>>>2)&255):Ut===4?(bt=it[gt.charAt(Mt++)],xt=it[gt.charAt(Mt++)],vt=it[gt.charAt(Mt++)],Et=it[gt.charAt(Mt++)],It[Nt++]=(bt<<3|xt>>>2)&255,It[Nt++]=(xt<<6|vt<<1|Et>>>4)&255):Ut===5?(bt=it[gt.charAt(Mt++)],xt=it[gt.charAt(Mt++)],vt=it[gt.charAt(Mt++)],Et=it[gt.charAt(Mt++)],Ct=it[gt.charAt(Mt++)],It[Nt++]=(bt<<3|xt>>>2)&255,It[Nt++]=(xt<<6|vt<<1|Et>>>4)&255,It[Nt++]=(Et<<4|Ct>>>1)&255):Ut===7&&(bt=it[gt.charAt(Mt++)],xt=it[gt.charAt(Mt++)],vt=it[gt.charAt(Mt++)],Et=it[gt.charAt(Mt++)],Ct=it[gt.charAt(Mt++)],St=it[gt.charAt(Mt++)],At=it[gt.charAt(Mt++)],It[Nt++]=(bt<<3|xt>>>2)&255,It[Nt++]=(xt<<6|vt<<1|Et>>>4)&255,It[Nt++]=(Et<<4|Ct>>>1)&255,It[Nt++]=(Ct<<7|St<<2|At>>>3)&255),It},dt=function(gt){for(var bt,xt,vt,Et,Ct,St="",At=gt.length,kt=0,It=parseInt(At/5)*5;kt>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[(xt<<4|vt>>>4)&31]+ot[(vt<<1|Et>>>7)&31]+ot[Et>>>2&31]+ot[(Et<<3|Ct>>>5)&31]+ot[Ct&31];var Nt=At-It;return Nt===1?(bt=gt.charCodeAt(kt),St+=ot[bt>>>3]+ot[bt<<2&31]+"======"):Nt===2?(bt=gt.charCodeAt(kt++),xt=gt.charCodeAt(kt),St+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[xt<<4&31]+"===="):Nt===3?(bt=gt.charCodeAt(kt++),xt=gt.charCodeAt(kt++),vt=gt.charCodeAt(kt),St+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[(xt<<4|vt>>>4)&31]+ot[vt<<1&31]+"==="):Nt===4&&(bt=gt.charCodeAt(kt++),xt=gt.charCodeAt(kt++),vt=gt.charCodeAt(kt++),Et=gt.charCodeAt(kt),St+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[(xt<<4|vt>>>4)&31]+ot[(vt<<1|Et>>>7)&31]+ot[Et>>>2&31]+ot[Et<<3&31]+"="),St},ht=function(gt){var bt,xt,vt,Et,Ct,St,At=!1,kt="",It=0,Nt,Lt=0,Mt=gt.length;if(gt==="")return kt;do{for(st[0]=st[5],st[1]=st[6],st[2]=st[7],Nt=Lt;It>6,st[Nt++]=128|St&63):St<55296||St>=57344?(st[Nt++]=224|St>>12,st[Nt++]=128|St>>6&63,st[Nt++]=128|St&63):(St=65536+((St&1023)<<10|gt.charCodeAt(++It)&1023),st[Nt++]=240|St>>18,st[Nt++]=128|St>>12&63,st[Nt++]=128|St>>6&63,st[Nt++]=128|St&63);Lt=Nt-5,It===Mt&&++It,It>Mt&&Nt<6&&(At=!0),bt=st[0],Nt>4?(xt=st[1],vt=st[2],Et=st[3],Ct=st[4],kt+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[(xt<<4|vt>>>4)&31]+ot[(vt<<1|Et>>>7)&31]+ot[Et>>>2&31]+ot[(Et<<3|Ct>>>5)&31]+ot[Ct&31]):Nt===1?kt+=ot[bt>>>3]+ot[bt<<2&31]+"======":Nt===2?(xt=st[1],kt+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[xt<<4&31]+"===="):Nt===3?(xt=st[1],vt=st[2],kt+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[(xt<<4|vt>>>4)&31]+ot[vt<<1&31]+"==="):(xt=st[1],vt=st[2],Et=st[3],kt+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[(xt<<4|vt>>>4)&31]+ot[(vt<<1|Et>>>7)&31]+ot[Et>>>2&31]+ot[Et<<3&31]+"=")}while(!At);return kt},mt=function(gt){for(var bt,xt,vt,Et,Ct,St="",At=gt.length,kt=0,It=parseInt(At/5)*5;kt>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[(xt<<4|vt>>>4)&31]+ot[(vt<<1|Et>>>7)&31]+ot[Et>>>2&31]+ot[(Et<<3|Ct>>>5)&31]+ot[Ct&31];var Nt=At-It;return Nt===1?(bt=gt[kt],St+=ot[bt>>>3]+ot[bt<<2&31]+"======"):Nt===2?(bt=gt[kt++],xt=gt[kt],St+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[xt<<4&31]+"===="):Nt===3?(bt=gt[kt++],xt=gt[kt++],vt=gt[kt],St+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[(xt<<4|vt>>>4)&31]+ot[vt<<1&31]+"==="):Nt===4&&(bt=gt[kt++],xt=gt[kt++],vt=gt[kt++],Et=gt[kt],St+=ot[bt>>>3]+ot[(bt<<2|xt>>>6)&31]+ot[xt>>>1&31]+ot[(xt<<4|vt>>>4)&31]+ot[(vt<<1|Et>>>7)&31]+ot[Et>>>2&31]+ot[Et<<3&31]+"="),St},ft=function(gt,bt){var xt=typeof gt!="string";return xt&>.constructor===ArrayBuffer&&(gt=new Uint8Array(gt)),xt?mt(gt):bt?dt(gt):ht(gt)},pt=function(gt,bt){if(!bt)return ct(lt(gt));if(gt==="")return"";if(!/^[A-Z2-7=]+$/.test(gt))throw new Error("Invalid base32 characters");var xt,vt,Et,Ct,St,At,kt,It,Nt="",Lt=gt.indexOf("=");Lt===-1&&(Lt=gt.length);for(var Mt=0,zt=Lt>>3<<3;Mt>>2)&255)+String.fromCharCode((vt<<6|Et<<1|Ct>>>4)&255)+String.fromCharCode((Ct<<4|St>>>1)&255)+String.fromCharCode((St<<7|At<<2|kt>>>3)&255)+String.fromCharCode((kt<<5|It)&255);var Ut=Lt-zt;return Ut===2?(xt=it[gt.charAt(Mt++)],vt=it[gt.charAt(Mt++)],Nt+=String.fromCharCode((xt<<3|vt>>>2)&255)):Ut===4?(xt=it[gt.charAt(Mt++)],vt=it[gt.charAt(Mt++)],Et=it[gt.charAt(Mt++)],Ct=it[gt.charAt(Mt++)],Nt+=String.fromCharCode((xt<<3|vt>>>2)&255)+String.fromCharCode((vt<<6|Et<<1|Ct>>>4)&255)):Ut===5?(xt=it[gt.charAt(Mt++)],vt=it[gt.charAt(Mt++)],Et=it[gt.charAt(Mt++)],Ct=it[gt.charAt(Mt++)],St=it[gt.charAt(Mt++)],Nt+=String.fromCharCode((xt<<3|vt>>>2)&255)+String.fromCharCode((vt<<6|Et<<1|Ct>>>4)&255)+String.fromCharCode((Ct<<4|St>>>1)&255)):Ut===7&&(xt=it[gt.charAt(Mt++)],vt=it[gt.charAt(Mt++)],Et=it[gt.charAt(Mt++)],Ct=it[gt.charAt(Mt++)],St=it[gt.charAt(Mt++)],At=it[gt.charAt(Mt++)],kt=it[gt.charAt(Mt++)],Nt+=String.fromCharCode((xt<<3|vt>>>2)&255)+String.fromCharCode((vt<<6|Et<<1|Ct>>>4)&255)+String.fromCharCode((Ct<<4|St>>>1)&255)+String.fromCharCode((St<<7|At<<2|kt>>>3)&255)),Nt},yt={encode:ft,decode:pt};pt.asBytes=lt,nt?et.exports=yt:tt.base32=yt})()})(base32$3);var base32Exports=base32$3.exports;const base32$2=getDefaultExportFromCjs(base32Exports);function coerce(et){if(et instanceof Uint8Array&&et.constructor.name==="Uint8Array")return et;if(et instanceof ArrayBuffer)return new Uint8Array(et);if(ArrayBuffer.isView(et))return new Uint8Array(et.buffer,et.byteOffset,et.byteLength);throw new Error("Unknown type, must be binary type")}function fromString$1(et){return new TextEncoder().encode(et)}function toString$2(et){return new TextDecoder().decode(et)}function base(et,o){if(et.length>=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),rt=0;rt>>0,vt=new Uint8Array(xt);gt!==bt;){for(var Et=ft[gt],Ct=0,St=xt-1;(Et!==0||Ct>>0,vt[St]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=Ct,gt++}for(var At=xt-yt;At!==xt&&vt[At]===0;)At++;for(var kt=at.repeat(pt);At>>0,xt=new Uint8Array(bt);ft[pt];){var vt=tt[ft.charCodeAt(pt)];if(vt===255)return;for(var Et=0,Ct=bt-1;(vt!==0||Et>>0,xt[Ct]=vt%256>>>0,vt=vt/256>>>0;if(vt!==0)throw new Error("Non-zero carry");gt=Et,pt++}if(ft[pt]!==" "){for(var St=bt-gt;St!==bt&&xt[St]===0;)St++;for(var At=new Uint8Array(yt+(bt-St)),kt=yt;St!==bt;)At[kt++]=xt[St++];return At}}}function mt(ft){var pt=ht(ft);if(pt)return pt;throw new Error(`Non-${o} character`)}return{encode:dt,decodeUnsafe:ht,decode:mt}}var src$1=base,_brrp__multiformats_scope_baseX=src$1;class Encoder{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");this.name=o,this.prefix=tt,this.baseEncode=rt}encode(o){if(o instanceof Uint8Array)return`${this.prefix}${this.baseEncode(o)}`;throw Error("Unknown type, must be binary type")}}class Decoder{constructor(o,tt,rt){wt(this,"name");wt(this,"prefix");wt(this,"baseDecode");wt(this,"prefixCodePoint");this.name=o,this.prefix=tt;const nt=tt.codePointAt(0);if(nt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=nt,this.baseDecode=rt}decode(o){if(typeof o=="string"){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))}else throw Error("Can only multibase decode strings")}or(o){return or(this,o)}}class ComposedDecoder{constructor(o){wt(this,"decoders");this.decoders=o}or(o){return or(this,o)}decode(o){const tt=o[0],rt=this.decoders[tt];if(rt!=null)return rt.decode(o);throw RangeError(`Unable to decode multibase string ${JSON.stringify(o)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function or(et,o){return new ComposedDecoder({...et.decoders??{[et.prefix]:et},...o.decoders??{[o.prefix]:o}})}class Codec{constructor(o,tt,rt,nt){wt(this,"name");wt(this,"prefix");wt(this,"baseEncode");wt(this,"baseDecode");wt(this,"encoder");wt(this,"decoder");this.name=o,this.prefix=tt,this.baseEncode=rt,this.baseDecode=nt,this.encoder=new Encoder(o,tt,rt),this.decoder=new Decoder(o,tt,nt)}encode(o){return this.encoder.encode(o)}decode(o){return this.decoder.decode(o)}}function from({name:et,prefix:o,encode:tt,decode:rt}){return new Codec(et,o,tt,rt)}function baseX({name:et,prefix:o,alphabet:tt}){const{encode:rt,decode:nt}=_brrp__multiformats_scope_baseX(tt,et);return from({prefix:o,name:et,encode:rt,decode:ot=>coerce(nt(ot))})}function decode$2(et,o,tt,rt){const nt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$1(et,o,tt){const rt=o[o.length-1]==="=",nt=(1<tt;)it-=tt,ot+=o[nt&st>>it];if(it!==0&&(ot+=o[nt&st<(et[tt]=o,et),[]),alphabetCharsToBytes=alphabet.reduce((et,o,tt)=>{const rt=o.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${o}`);return et[rt]=tt,et},[]);function encode(et){return et.reduce((o,tt)=>(o+=alphabetBytesToChars[tt],o),"")}function decode$1(et){const o=[];for(const tt of et){const rt=tt.codePointAt(0);if(rt==null)throw new Error(`Invalid character: ${tt}`);const nt=alphabetCharsToBytes[rt];if(nt==null)throw new Error(`Non-base256emoji character: ${tt}`);o.push(nt)}return new Uint8Array(o)}const base256emoji=from({prefix:"🚀",name:"base256emoji",encode,decode:decode$1}),base256emoji$1=Object.freeze(Object.defineProperty({__proto__:null,base256emoji},Symbol.toStringTag,{value:"Module"})),base32=rfc4648({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper=rfc4648({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad=rfc4648({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper=rfc4648({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex=rfc4648({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper=rfc4648({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad=rfc4648({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper=rfc4648({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z=rfc4648({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$1=Object.freeze(Object.defineProperty({__proto__:null,base32,base32hex,base32hexpad,base32hexpadupper,base32hexupper,base32pad,base32padupper,base32upper,base32z},Symbol.toStringTag,{value:"Module"})),base36=baseX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper=baseX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$1=Object.freeze(Object.defineProperty({__proto__:null,base36,base36upper},Symbol.toStringTag,{value:"Module"})),base58btc=baseX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr=baseX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58=Object.freeze(Object.defineProperty({__proto__:null,base58btc,base58flickr},Symbol.toStringTag,{value:"Module"})),base64$2=rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad=rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url=rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad=rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$3=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$2,base64pad,base64url,base64urlpad},Symbol.toStringTag,{value:"Module"})),base8=rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$1=Object.freeze(Object.defineProperty({__proto__:null,base8},Symbol.toStringTag,{value:"Module"})),identity=from({prefix:"\0",name:"identity",encode:et=>toString$2(et),decode:et=>fromString$1(et)}),identityBase=Object.freeze(Object.defineProperty({__proto__:null,identity},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases={...identityBase,...base2$1,...base8$1,...base10$1,...base16$1,...base32$1,...base36$1,...base58,...base64$3,...base256emoji$1};function allocUnsafe(et=0){return new Uint8Array(et)}function createCodec(et,o,tt,rt){return{name:et,prefix:o,encoder:{name:et,prefix:o,encode:tt},decoder:{decode:rt}}}const string$2=createCodec("utf8","u",et=>"u"+new TextDecoder("utf8").decode(et),et=>new TextEncoder().encode(et.substring(1))),ascii=createCodec("ascii","a",et=>{let o="a";for(let tt=0;tt{et=et.substring(1);const o=allocUnsafe(et.length);for(let tt=0;tt=et.relay&&o.store>=et.store&&o.filter>=et.filter&&o.lightPush>=et.lightPush}function isNewPeer(et,o){if(!et.nodeId)return!1;for(const tt of o)if(et.nodeId===tt.nodeId)return!1;return!0}function addCapabilities(et,o){et.relay&&(o.relay+=1),et.store&&(o.store+=1),et.filter&&(o.filter+=1),et.lightPush&&(o.lightPush+=1)}function helpsSatisfyCapabilities(et,o,tt){if(isSatisfied(o,tt))throw"Internal Error: Waku2 wanted capabilities are already fulfilled";const rt=missingCapabilities(o,tt);return rt.relay&&et.relay||rt.store&&et.store||rt.filter&&et.filter||rt.lightPush&&et.lightPush}function missingCapabilities(et,o){return{relay:o.relaythis._search(ot,it));return log$5.info("retrieved peers: ",st.map(at=>{var ct,lt;return{id:(ct=at.peerId)==null?void 0:ct.toString(),multiaddrs:(lt=at.multiaddrs)==null?void 0:lt.map(dt=>dt.toString())}})),st}async*getNextPeer(o,tt){const rt=Math.floor(Math.random()*o.length),{publicKey:nt,domain:ot}=ENRTree.parseTree(o[rt]),it={domain:ot,publicKey:nt,visits:{}};for await(const st of yieldNodesUntilCapabilitiesFulfilled(tt,this._errorTolerance,()=>this._search(ot,it)))yield st}async _search(o,tt){try{const rt=await this._getTXTRecord(o,tt);tt.visits[o]=!0;let nt,ot;const it=getEntryType(rt);try{switch(it){case ENRTree.ROOT_PREFIX:return nt=ENRTree.parseAndVerifyRoot(rt,tt.publicKey),await this._search(nt,tt);case ENRTree.BRANCH_PREFIX:return ot=ENRTree.parseBranch(rt),nt=selectRandomPath(ot,tt),await this._search(nt,tt);case ENRTree.RECORD_PREFIX:return EnrDecoder.fromString(rt);default:return null}}catch(st){return log$5.error(`Failed to search DNS tree ${it} at subdomain ${o}: ${st}`),null}}catch(rt){return log$5.error(`Failed to retrieve TXT record at subdomain ${o}: ${rt}`),null}}async _getTXTRecord(o,tt){if(this._DNSTreeCache[o])return this._DNSTreeCache[o];const rt=o!==tt.domain?`${o}.${tt.domain}`:tt.domain,nt=await this.dns.resolveTXT(rt);if(!nt.length)throw new Error("Received empty result array while fetching TXT record");if(!nt[0].length)throw new Error("Received empty TXT record");const ot=nt.join("");return this._DNSTreeCache[o]=ot,ot}}function getEntryType(et){return et.startsWith(ENRTree.ROOT_PREFIX)?ENRTree.ROOT_PREFIX:et.startsWith(ENRTree.BRANCH_PREFIX)?ENRTree.BRANCH_PREFIX:et.startsWith(ENRTree.RECORD_PREFIX)?ENRTree.RECORD_PREFIX:""}function selectRandomPath(et,o){const tt={};for(const[nt,ot]of et.entries())o.visits[ot]&&(tt[nt]=!0);if(Object.keys(tt).length===et.length)throw new Error("Unresolvable circular path detected");let rt;do rt=Math.floor(Math.random()*et.length);while(tt[rt]);return et[rt]}const log$4=new Logger$1("peer-discovery-dns");class PeerDiscoveryDns extends TypedEventEmitter$3{constructor(tt,rt){super();wt(this,"nextPeer");wt(this,"_started");wt(this,"_components");wt(this,"_options");this._started=!1,this._components=tt,this._options=rt;const{enrUrls:nt}=rt;log$4.info("Use following EIP-1459 ENR Tree URLs: ",nt)}async start(){log$4.info("Starting peer discovery via dns"),this._started=!0,await this.findPeers()}async findPeers(){if(!this.nextPeer){let{enrUrls:tt}=this._options;Array.isArray(tt)||(tt=[tt]);const{wantedNodeCapabilityCount:rt}=this._options,nt=await DnsNodeDiscovery.dnsOverHttp();this.nextPeer=nt.getNextPeer.bind(nt,tt,rt)}for await(const tt of this.nextPeer()){if(!this._started)return;const{peerInfo:rt,shardInfo:nt}=tt;if(!rt)continue;const ot={[DEFAULT_BOOTSTRAP_TAG_NAME]:{value:this._options.tagValue??DEFAULT_BOOTSTRAP_TAG_VALUE,ttl:this._options.tagTTL??DEFAULT_BOOTSTRAP_TAG_TTL}};let it=!1;await this._components.peerStore.has(rt.id)?(await this._components.peerStore.get(rt.id)).tags.has(DEFAULT_BOOTSTRAP_TAG_NAME)||(it=!0,await this._components.peerStore.merge(rt.id,{tags:ot})):(it=!0,await this._components.peerStore.save(rt.id,{tags:ot,...nt&&{metadata:{shardInfo:encodeRelayShard(nt)}}})),it&&this.dispatchEvent(new CustomEvent("peer",{detail:rt}))}}stop(){this._started=!1}get[peerDiscoverySymbol$2](){return!0}get[Symbol.toStringTag](){return DNS_DISCOVERY_TAG}}function wakuDnsDiscovery(et,o=DEFAULT_NODE_REQUIREMENTS){return tt=>new PeerDiscoveryDns(tt,{enrUrls:et,wantedNodeCapabilityCount:o})}class PeerExchangeRPC{constructor(o){wt(this,"proto");this.proto=o}static createRequest(o){const{numPeers:tt}=o;return new PeerExchangeRPC({query:{numPeers:tt},response:void 0})}encode(){return PeerExchangeRPC$1.encode(this.proto)}static decode(o){const tt=PeerExchangeRPC$1.decode(o);return new PeerExchangeRPC(tt)}get query(){return this.proto.query}get response(){return this.proto.response}}const PeerExchangeCodec="/vac/waku/peer-exchange/2.0.0-alpha1",log$3=new Logger$1("peer-exchange");class WakuPeerExchange extends BaseProtocol{constructor(o,tt){super(PeerExchangeCodec,o,log$3,tt)}async query(o){const{numPeers:tt,peerId:rt}=o,nt=PeerExchangeRPC.createRequest({numPeers:BigInt(tt)}),ot=await this.components.peerStore.get(rt);if(!ot)return{peerInfos:null,error:ProtocolError$1.NO_PEER_AVAILABLE};let it;try{it=await this.getStream(ot)}catch(at){return log$3.error("Failed to get stream",at),{peerInfos:null,error:ProtocolError$1.NO_STREAM_AVAILABLE}}const st=await pipe([nt.encode()],encode$K,it,decode$U,async at=>await all$2(at));try{const at=new Uint8ArrayList;st.forEach(dt=>{at.append(dt)});const{response:ct}=PeerExchangeRPC.decode(at);return ct?{peerInfos:await Promise.all(ct.peerInfos.map(dt=>dt.enr).filter(isDefined).map(async dt=>({ENR:await EnrDecoder.fromRLP(dt)}))),error:null}:(log$3.error("PeerExchangeRPC message did not contains a `response` field"),{peerInfos:null,error:ProtocolError$1.EMPTY_PAYLOAD})}catch(at){return log$3.error("Failed to decode push reply",at),{peerInfos:null,error:ProtocolError$1.DECODE_FAILED}}}}const log$2=new Logger$1("peer-exchange-discovery"),DEFAULT_PEER_EXCHANGE_REQUEST_NODES=10,DEFAULT_PEER_EXCHANGE_QUERY_INTERVAL_MS=10*1e3,DEFAULT_MAX_RETRIES=3,DEFAULT_PEER_EXCHANGE_TAG_NAME=Tags.PEER_EXCHANGE,DEFAULT_PEER_EXCHANGE_TAG_VALUE=50,DEFAULT_PEER_EXCHANGE_TAG_TTL=1e8;class PeerExchangeDiscovery extends TypedEventEmitter$3{constructor(tt,rt,nt={}){super();wt(this,"components");wt(this,"peerExchange");wt(this,"options");wt(this,"isStarted");wt(this,"queryingPeers",new Set);wt(this,"queryAttempts",new Map);wt(this,"handleDiscoveredPeer",tt=>{const{protocols:rt,peerId:nt}=tt.detail;!rt.includes(PeerExchangeCodec)||this.queryingPeers.has(nt.toString())||(this.queryingPeers.add(nt.toString()),this.startRecurringQueries(nt).catch(ot=>log$2.error(`Error querying peer ${ot}`)))});wt(this,"startRecurringQueries",async tt=>{const rt=tt.toString(),{queryInterval:nt=DEFAULT_PEER_EXCHANGE_QUERY_INTERVAL_MS,maxRetries:ot=DEFAULT_MAX_RETRIES}=this.options;log$2.info(`Querying peer: ${rt} (attempt ${this.queryAttempts.get(rt)??1})`),await this.query(tt);const it=this.queryAttempts.get(rt)??1;if(it>ot){this.abortQueriesForPeer(rt);return}setTimeout(()=>{this.queryAttempts.set(rt,it+1),this.startRecurringQueries(tt).catch(st=>{log$2.error(`Error in startRecurringQueries: ${st}`)})},nt*it)});this.components=tt,this.peerExchange=new WakuPeerExchange(tt,rt),this.options=nt,this.isStarted=!1}start(){this.isStarted||(this.dispatchEvent(new CustomEvent("waku:peer-exchange:started",{detail:!0})),log$2.info("Starting peer exchange node discovery, discovering peers"),this.components.events.addEventListener("peer:identify",this.handleDiscoveredPeer))}stop(){this.isStarted&&(log$2.info("Stopping peer exchange node discovery"),this.isStarted=!1,this.queryingPeers.clear(),this.components.events.removeEventListener("peer:identify",this.handleDiscoveredPeer))}get[peerDiscoverySymbol$2](){return!0}get[Symbol.toStringTag](){return"@waku/peer-exchange"}async query(tt){const{error:rt,peerInfos:nt}=await this.peerExchange.query({numPeers:DEFAULT_PEER_EXCHANGE_REQUEST_NODES,peerId:tt});if(rt)return log$2.error("Peer exchange query failed",rt),{error:rt,peerInfos:null};for(const ot of nt){const{ENR:it}=ot;if(!it){log$2.warn("No ENR in peerInfo object, skipping");continue}const{peerId:st,peerInfo:at,shardInfo:ct}=it;if(!st||!at)continue;if(await this.components.peerStore.has(st)){const{hasMultiaddrDiff:dt,hasShardDiff:ht}=await this.checkPeerInfoDiff(at,ct);if(dt||ht){log$2.info(`Peer ${st.toString()} has updated multiaddrs or shardInfo, updating`),dt&&(log$2.info(`Peer ${st.toString()} has updated multiaddrs, updating`),await this.components.peerStore.patch(st,{multiaddrs:at.multiaddrs})),ht&&ct&&(log$2.info(`Peer ${st.toString()} has updated shardInfo, updating`),await this.components.peerStore.merge(st,{metadata:{shardInfo:encodeRelayShard(ct)}}),this.dispatchEvent(new CustomEvent("peer",{detail:{id:st,multiaddrs:at.multiaddrs}})));continue}}await this.components.peerStore.save(st,{tags:{[DEFAULT_PEER_EXCHANGE_TAG_NAME]:{value:this.options.tagValue??DEFAULT_PEER_EXCHANGE_TAG_VALUE,ttl:this.options.tagTTL??DEFAULT_PEER_EXCHANGE_TAG_TTL}},...ct&&{metadata:{shardInfo:encodeRelayShard(ct)}},...at.multiaddrs&&{multiaddrs:at.multiaddrs}}),log$2.info(`Discovered peer: ${st.toString()}`),this.dispatchEvent(new CustomEvent("peer",{detail:{id:st,multiaddrs:at.multiaddrs}}))}return{error:null,peerInfos:nt}}abortQueriesForPeer(tt){log$2.info(`Aborting queries for peer: ${tt}`),this.queryingPeers.delete(tt),this.queryAttempts.delete(tt)}async checkPeerInfoDiff(tt,rt){const{id:nt}=tt,ot=await this.components.peerStore.get(nt),it=ot.addresses.map(dt=>dt.multiaddr.toString()),st=tt.multiaddrs.map(dt=>dt.toString()),at=it.some(dt=>!st.includes(dt));let ct=!1;const lt=ot.metadata.get("shardInfo");if(lt){const dt=decodeRelayShard(lt);(dt||rt)&&(ct=dt.clusterId!==(rt==null?void 0:rt.clusterId)||dt.shards.some(ht=>!(rt!=null&&rt.shards.includes(ht))))}return{hasMultiaddrDiff:at,hasShardDiff:ct}}}function wakuPeerExchangeDiscovery(et){return o=>new PeerExchangeDiscovery(o,et)}const log$1=new Logger$1("peer-exchange-discovery"),DEFAULT_LOCAL_TAG_NAME=Tags.LOCAL,DEFAULT_LOCAL_TAG_VALUE=50,DEFAULT_LOCAL_TAG_TTL=1e8;class LocalPeerCacheDiscovery extends TypedEventEmitter$3{constructor(tt,rt){super();wt(this,"components");wt(this,"options");wt(this,"isStarted");wt(this,"peers",[]);wt(this,"handleNewPeers",tt=>{const{peerId:rt,listenAddrs:nt}=tt.detail,ot=getWsMultiaddrFromMultiaddrs(nt),it=this.getPeersFromLocalStorage(),st=it.findIndex(at=>at.id===rt.toString());st>=0?it[st].address=ot.toString():it.push({id:rt.toString(),address:ot.toString()}),this.peers=it,this.savePeersToLocalStorage()});this.components=tt,this.options=rt,this.isStarted=!1,this.peers=this.getPeersFromLocalStorage()}get[Symbol.toStringTag](){return"@waku/local-peer-cache-discovery"}async start(){var tt,rt,nt;if(!this.isStarted){log$1.info("Starting Local Storage Discovery"),this.components.events.addEventListener("peer:identify",this.handleNewPeers);for(const{id:ot,address:it}of this.peers){const st=peerIdFromString$1(ot);await this.components.peerStore.has(st)||(await this.components.peerStore.save(st,{multiaddrs:[multiaddr(it)],tags:{[((tt=this.options)==null?void 0:tt.tagName)??DEFAULT_LOCAL_TAG_NAME]:{value:((rt=this.options)==null?void 0:rt.tagValue)??DEFAULT_LOCAL_TAG_VALUE,ttl:((nt=this.options)==null?void 0:nt.tagTTL)??DEFAULT_LOCAL_TAG_TTL}}}),this.dispatchEvent(new CustomEvent("peer",{detail:{id:st,multiaddrs:[multiaddr(it)]}})))}log$1.info(`Discovered ${this.peers.length} peers`),this.isStarted=!0}}stop(){this.isStarted&&(log$1.info("Stopping Local Storage Discovery"),this.components.events.removeEventListener("peer:identify",this.handleNewPeers),this.isStarted=!1,this.savePeersToLocalStorage())}getPeersFromLocalStorage(){try{const tt=localStorage.getItem("waku:peers");return tt?JSON.parse(tt).filter(isValidStoredPeer):[]}catch(tt){return log$1.error("Error parsing peers from local storage:",tt),[]}}savePeersToLocalStorage(){try{localStorage.setItem("waku:peers",JSON.stringify(this.peers))}catch(tt){log$1.error("Error saving peers to local storage:",tt)}}}function isValidStoredPeer(et){return et&&typeof et=="object"&&typeof et.id=="string"&&typeof et.address=="string"}function wakuLocalPeerCacheDiscovery(){return(et,o)=>new LocalPeerCacheDiscovery(et,o)}function defaultPeerDiscoveries(et){const o=[enrTree.SANDBOX,enrTree.TEST];return[wakuDnsDiscovery(o),wakuLocalPeerCacheDiscovery(),wakuPeerExchangeDiscovery(et)]}const log=new Logger$1("sdk:create");async function defaultLibp2p(et,o,tt){o!=null&&o.hideWebSocketInfo||(console.info("%cIgnore WebSocket connection failures","background: gray; color: white; font-size: x-large"),console.info("%cWaku tries to discover peers and some of them are expected to fail","background: gray; color: white; font-size: x-large"));const rt=et?{metadata:wakuMetadata(et)}:{},nt=(o==null?void 0:o.filterMultiaddrs)===!1?all$1:wss;return createLibp2p({transports:[webSockets({filter:nt})],streamMuxers:[mplex()],connectionEncrypters:[noise()],...o,services:{identify:identify({agentVersion:tt??DefaultUserAgent}),ping:ping({maxInboundStreams:(o==null?void 0:o.pingMaxInboundStreams)??DefaultPingMaxInboundStreams}),...rt,...o==null?void 0:o.services}})}async function createLibp2pAndUpdateOptions(et){const{networkConfig:o}=et,tt=derivePubsubTopicsFromNetworkConfig(o??DefaultNetworkConfig);log.info("Creating Waku node with pubsub topics",tt);const rt=(et==null?void 0:et.libp2p)??{},nt=rt.peerDiscovery??[];return et!=null&&et.defaultBootstrap&&nt.push(...defaultPeerDiscoveries(tt)),et!=null&&et.bootstrapPeers&&nt.push(bootstrap({list:et.bootstrapPeers})),rt.peerDiscovery=nt,{libp2p:await defaultLibp2p(tt,rt,et==null?void 0:et.userAgent),pubsubTopics:tt}}async function createLightNode(et={}){const{libp2p:o,pubsubTopics:tt}=await createLibp2pAndUpdateOptions(et);return new WakuNode(tt,et,o,{store:!0,lightpush:!0,filter:!0})}React.createContext({decoder:void 0,encoder:void 0});const useCreateNode=et=>{const{factory:o,options:tt,protocols:rt=[]}=et,[nt,ot]=React.useState(void 0),[it,st]=React.useState(!0),[at,ct]=React.useState(void 0);return React.useEffect(()=>{let lt=!1;return st(!0),o(tt).then(async dt=>{lt||(await dt.start(),await waitForRemotePeer(dt,rt),ot(dt),st(!1))}).catch(dt=>{st(!1),ct(`Failed at creating node: ${(dt==null?void 0:dt.message)||"no message"}`)}),()=>{lt=!0}},[]),{node:nt,error:at,isLoading:it}},useCreateLightNode=et=>useCreateNode({...et,factory:createLightNode}),WakuContext=React.createContext({node:void 0,isLoading:!1,error:void 0}),useWaku=()=>React.useContext(WakuContext),LightNodeProvider=et=>{const o=useCreateLightNode({options:et.options,protocols:et.protocols});return React.createElement(WakuContext.Provider,{value:o},et.children)};/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. @@ -4082,7 +4082,7 @@ https://www.dnscrypt.uk`,country:"United Kingdom",location:{lat:51.4964,long:-.1 * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const LoaderCircle=createLucideIcon("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),Header=({wakuStatus:et})=>{const{address:o,isConnected:tt}=useAccount(),{disconnect:rt}=useDisconnect(),{isLoading:nt,error:ot,node:it}=useWaku(),[st,at]=reactExports.useState(0),ct=useLocation(),{data:lt}=useEnsName({address:o});reactExports.useEffect(()=>{if(it){const ht=()=>{at(it.libp2p.getConnections().length)};return ht(),it.libp2p.addEventListener("peer:connect",ht),it.libp2p.addEventListener("peer:disconnect",ht),()=>{it.libp2p.removeEventListener("peer:connect",ht),it.libp2p.removeEventListener("peer:disconnect",ht)}}},[it]);const dt=ht=>{switch(ht){case"success":return"bg-green-500";case"in-progress":return"bg-yellow-500";case"error":return"bg-red-500"}};return jsxRuntimeExports.jsx("header",{className:"border-b",children:jsxRuntimeExports.jsx("div",{className:"container mx-auto px-4 py-2 md:py-4",children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center space-y-2 md:space-y-0",children:[jsxRuntimeExports.jsxs("div",{className:"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4 w-full md:w-auto",children:[jsxRuntimeExports.jsx("h1",{className:"text-xl md:text-2xl font-bold",children:"BuddyBook"}),jsxRuntimeExports.jsx("nav",{className:"w-full md:w-auto",children:jsxRuntimeExports.jsxs("ul",{className:"flex justify-center md:justify-start space-x-4",children:[jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsx(Link,{to:"/create",className:`text-sm ${ct.pathname==="/create"?"text-primary font-semibold":"text-muted-foreground"}`,children:"Create Chain"})}),jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsx(Link,{to:"/view",className:`text-sm ${ct.pathname==="/view"?"text-primary font-semibold":"text-muted-foreground"}`,children:"View Chains"})}),jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsx(Link,{to:"/telemetry",className:`text-sm ${ct.pathname==="/telemetry"?"text-primary font-semibold":"text-muted-foreground"}`,children:"Telemetry"})})]})})]}),jsxRuntimeExports.jsxs("div",{className:"flex flex-wrap justify-center md:justify-end items-center gap-2 w-full md:w-auto",children:[jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-2 text-xs md:text-sm",children:nt?jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Connecting..."})]}):ot?jsxRuntimeExports.jsx("span",{className:"text-destructive",children:"Network Error"}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Filter:"}),jsxRuntimeExports.jsx("div",{className:`w-2 h-2 md:w-3 md:h-3 rounded-full ${dt(et.filter)}`})]}),jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Store:"}),jsxRuntimeExports.jsx("div",{className:`w-2 h-2 md:w-3 md:h-3 rounded-full ${dt(et.store)}`})]}),jsxRuntimeExports.jsx("span",{className:"text-xs md:text-sm text-muted-foreground hidden md:inline",children:st>0?`${st} peer${st===1?"":"s"}`:"Connecting..."})]})}),jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[nt?jsxRuntimeExports.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):ot?jsxRuntimeExports.jsx("span",{className:"text-xs md:text-sm text-red-500",children:"Waku Error"}):jsxRuntimeExports.jsxs("span",{className:"text-xs md:text-sm text-muted-foreground hidden md:inline",children:["Waku Connections: ",st]}),tt?jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntimeExports.jsx("span",{className:"text-xs md:text-sm text-muted-foreground truncate max-w-[120px] md:max-w-none",children:lt||(o?`${o.slice(0,6)}...${o.slice(-4)}`:"")}),jsxRuntimeExports.jsx(Button,{variant:"outline",size:"sm",onClick:()=>rt(),children:"Logout"})]}):jsxRuntimeExports.jsx(ConnectKitButton,{})]})]})]})})})},Input=reactExports.forwardRef(({className:et,type:o,...tt},rt)=>jsxRuntimeExports.jsx("input",{type:o,className:cn("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",et),ref:rt,...tt}));Input.displayName="Input";const Textarea=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",et),ref:tt,...o}));Textarea.displayName="Textarea";var NODES=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Primitive=NODES.reduce((et,o)=>{const tt=reactExports.forwardRef((rt,nt)=>{const{asChild:ot,...it}=rt,st=ot?Slot:o;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),jsxRuntimeExports.jsx(st,{...it,ref:nt})});return tt.displayName=`Primitive.${o}`,{...et,[o]:tt}},{});function dispatchDiscreteCustomEvent(et,o){et&&reactDomExports.flushSync(()=>et.dispatchEvent(o))}var NAME="Label",Label$1=reactExports.forwardRef((et,o)=>jsxRuntimeExports.jsx(Primitive.label,{...et,ref:o,onMouseDown:tt=>{var nt;tt.target.closest("button, input, select, textarea")||((nt=et.onMouseDown)==null||nt.call(et,tt),!tt.defaultPrevented&&tt.detail>1&&tt.preventDefault())}}));Label$1.displayName=NAME;var Root$3=Label$1;const labelVariants=cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Label=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx(Root$3,{ref:tt,className:cn(labelVariants(),et),...o}));Label.displayName=Root$3.displayName;const Card=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("div",{ref:tt,className:cn("rounded-lg border bg-card text-card-foreground shadow-sm p-4 md:p-6",et),...o}));Card.displayName="Card";const CardHeader=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("div",{ref:tt,className:cn("flex flex-col space-y-1.5 p-4 md:p-6",et),...o}));CardHeader.displayName="CardHeader";const CardTitle=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("h3",{ref:tt,className:cn("font-semibold leading-none tracking-tight",et),...o}));CardTitle.displayName="CardTitle";const CardDescription=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("p",{ref:tt,className:cn("text-sm text-muted-foreground",et),...o}));CardDescription.displayName="CardDescription";const CardContent=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("div",{ref:tt,className:cn("p-6 pt-0",et),...o}));CardContent.displayName="CardContent";const CardFooter=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("div",{ref:tt,className:cn("flex items-center p-6 pt-0",et),...o}));CardFooter.displayName="CardFooter";function composeEventHandlers(et,o,{checkForDefaultPrevented:tt=!0}={}){return function(nt){if(et==null||et(nt),tt===!1||!nt.defaultPrevented)return o==null?void 0:o(nt)}}function createContext2(et,o){const tt=reactExports.createContext(o),rt=ot=>{const{children:it,...st}=ot,at=reactExports.useMemo(()=>st,Object.values(st));return jsxRuntimeExports.jsx(tt.Provider,{value:at,children:it})};rt.displayName=et+"Provider";function nt(ot){const it=reactExports.useContext(tt);if(it)return it;if(o!==void 0)return o;throw new Error(`\`${ot}\` must be used within \`${et}\``)}return[rt,nt]}function createContextScope(et,o=[]){let tt=[];function rt(ot,it){const st=reactExports.createContext(it),at=tt.length;tt=[...tt,it];const ct=dt=>{var yt;const{scope:ht,children:mt,...ft}=dt,pt=((yt=ht==null?void 0:ht[et])==null?void 0:yt[at])||st,gt=reactExports.useMemo(()=>ft,Object.values(ft));return jsxRuntimeExports.jsx(pt.Provider,{value:gt,children:mt})};ct.displayName=ot+"Provider";function lt(dt,ht){var pt;const mt=((pt=ht==null?void 0:ht[et])==null?void 0:pt[at])||st,ft=reactExports.useContext(mt);if(ft)return ft;if(it!==void 0)return it;throw new Error(`\`${dt}\` must be used within \`${ot}\``)}return[ct,lt]}const nt=()=>{const ot=tt.map(it=>reactExports.createContext(it));return function(st){const at=(st==null?void 0:st[et])||ot;return reactExports.useMemo(()=>({[`__scope${et}`]:{...st,[et]:at}}),[st,at])}};return nt.scopeName=et,[rt,composeContextScopes(nt,...o)]}function composeContextScopes(...et){const o=et[0];if(et.length===1)return o;const tt=()=>{const rt=et.map(nt=>({useScope:nt(),scopeName:nt.scopeName}));return function(ot){const it=rt.reduce((st,{useScope:at,scopeName:ct})=>{const dt=at(ot)[`__scope${ct}`];return{...st,...dt}},{});return reactExports.useMemo(()=>({[`__scope${o.scopeName}`]:it}),[it])}};return tt.scopeName=o.scopeName,tt}var useLayoutEffect2=globalThis!=null&&globalThis.document?reactExports.useLayoutEffect:()=>{},useReactId=React$1.useId||(()=>{}),count$1=0;function useId(et){const[o,tt]=reactExports.useState(useReactId());return useLayoutEffect2(()=>{et||tt(rt=>rt??String(count$1++))},[et]),et||(o?`radix-${o}`:"")}function useCallbackRef$1(et){const o=reactExports.useRef(et);return reactExports.useEffect(()=>{o.current=et}),reactExports.useMemo(()=>(...tt)=>{var rt;return(rt=o.current)==null?void 0:rt.call(o,...tt)},[])}function useControllableState({prop:et,defaultProp:o,onChange:tt=()=>{}}){const[rt,nt]=useUncontrolledState({defaultProp:o,onChange:tt}),ot=et!==void 0,it=ot?et:rt,st=useCallbackRef$1(tt),at=reactExports.useCallback(ct=>{if(ot){const dt=typeof ct=="function"?ct(et):ct;dt!==et&&st(dt)}else nt(ct)},[ot,et,nt,st]);return[it,at]}function useUncontrolledState({defaultProp:et,onChange:o}){const tt=reactExports.useState(et),[rt]=tt,nt=reactExports.useRef(rt),ot=useCallbackRef$1(o);return reactExports.useEffect(()=>{nt.current!==rt&&(ot(rt),nt.current=rt)},[rt,nt,ot]),tt}function useEscapeKeydown(et,o=globalThis==null?void 0:globalThis.document){const tt=useCallbackRef$1(et);reactExports.useEffect(()=>{const rt=nt=>{nt.key==="Escape"&&tt(nt)};return o.addEventListener("keydown",rt,{capture:!0}),()=>o.removeEventListener("keydown",rt,{capture:!0})},[tt,o])}var DISMISSABLE_LAYER_NAME="DismissableLayer",CONTEXT_UPDATE="dismissableLayer.update",POINTER_DOWN_OUTSIDE="dismissableLayer.pointerDownOutside",FOCUS_OUTSIDE="dismissableLayer.focusOutside",originalBodyPointerEvents,DismissableLayerContext=reactExports.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),DismissableLayer=reactExports.forwardRef((et,o)=>{const{disableOutsidePointerEvents:tt=!1,onEscapeKeyDown:rt,onPointerDownOutside:nt,onFocusOutside:ot,onInteractOutside:it,onDismiss:st,...at}=et,ct=reactExports.useContext(DismissableLayerContext),[lt,dt]=reactExports.useState(null),ht=(lt==null?void 0:lt.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,mt]=reactExports.useState({}),ft=useComposedRefs(o,St=>dt(St)),pt=Array.from(ct.layers),[gt]=[...ct.layersWithOutsidePointerEventsDisabled].slice(-1),yt=pt.indexOf(gt),bt=lt?pt.indexOf(lt):-1,xt=ct.layersWithOutsidePointerEventsDisabled.size>0,vt=bt>=yt,Et=usePointerDownOutside(St=>{const At=St.target,kt=[...ct.branches].some(It=>It.contains(At));!vt||kt||(nt==null||nt(St),it==null||it(St),St.defaultPrevented||st==null||st())},ht),Ct=useFocusOutside(St=>{const At=St.target;[...ct.branches].some(It=>It.contains(At))||(ot==null||ot(St),it==null||it(St),St.defaultPrevented||st==null||st())},ht);return useEscapeKeydown(St=>{bt===ct.layers.size-1&&(rt==null||rt(St),!St.defaultPrevented&&st&&(St.preventDefault(),st()))},ht),reactExports.useEffect(()=>{if(lt)return tt&&(ct.layersWithOutsidePointerEventsDisabled.size===0&&(originalBodyPointerEvents=ht.body.style.pointerEvents,ht.body.style.pointerEvents="none"),ct.layersWithOutsidePointerEventsDisabled.add(lt)),ct.layers.add(lt),dispatchUpdate(),()=>{tt&&ct.layersWithOutsidePointerEventsDisabled.size===1&&(ht.body.style.pointerEvents=originalBodyPointerEvents)}},[lt,ht,tt,ct]),reactExports.useEffect(()=>()=>{lt&&(ct.layers.delete(lt),ct.layersWithOutsidePointerEventsDisabled.delete(lt),dispatchUpdate())},[lt,ct]),reactExports.useEffect(()=>{const St=()=>mt({});return document.addEventListener(CONTEXT_UPDATE,St),()=>document.removeEventListener(CONTEXT_UPDATE,St)},[]),jsxRuntimeExports.jsx(Primitive.div,{...at,ref:ft,style:{pointerEvents:xt?vt?"auto":"none":void 0,...et.style},onFocusCapture:composeEventHandlers(et.onFocusCapture,Ct.onFocusCapture),onBlurCapture:composeEventHandlers(et.onBlurCapture,Ct.onBlurCapture),onPointerDownCapture:composeEventHandlers(et.onPointerDownCapture,Et.onPointerDownCapture)})});DismissableLayer.displayName=DISMISSABLE_LAYER_NAME;var BRANCH_NAME="DismissableLayerBranch",DismissableLayerBranch=reactExports.forwardRef((et,o)=>{const tt=reactExports.useContext(DismissableLayerContext),rt=reactExports.useRef(null),nt=useComposedRefs(o,rt);return reactExports.useEffect(()=>{const ot=rt.current;if(ot)return tt.branches.add(ot),()=>{tt.branches.delete(ot)}},[tt.branches]),jsxRuntimeExports.jsx(Primitive.div,{...et,ref:nt})});DismissableLayerBranch.displayName=BRANCH_NAME;function usePointerDownOutside(et,o=globalThis==null?void 0:globalThis.document){const tt=useCallbackRef$1(et),rt=reactExports.useRef(!1),nt=reactExports.useRef(()=>{});return reactExports.useEffect(()=>{const ot=st=>{if(st.target&&!rt.current){let at=function(){handleAndDispatchCustomEvent(POINTER_DOWN_OUTSIDE,tt,ct,{discrete:!0})};const ct={originalEvent:st};st.pointerType==="touch"?(o.removeEventListener("click",nt.current),nt.current=at,o.addEventListener("click",nt.current,{once:!0})):at()}else o.removeEventListener("click",nt.current);rt.current=!1},it=window.setTimeout(()=>{o.addEventListener("pointerdown",ot)},0);return()=>{window.clearTimeout(it),o.removeEventListener("pointerdown",ot),o.removeEventListener("click",nt.current)}},[o,tt]),{onPointerDownCapture:()=>rt.current=!0}}function useFocusOutside(et,o=globalThis==null?void 0:globalThis.document){const tt=useCallbackRef$1(et),rt=reactExports.useRef(!1);return reactExports.useEffect(()=>{const nt=ot=>{ot.target&&!rt.current&&handleAndDispatchCustomEvent(FOCUS_OUTSIDE,tt,{originalEvent:ot},{discrete:!1})};return o.addEventListener("focusin",nt),()=>o.removeEventListener("focusin",nt)},[o,tt]),{onFocusCapture:()=>rt.current=!0,onBlurCapture:()=>rt.current=!1}}function dispatchUpdate(){const et=new CustomEvent(CONTEXT_UPDATE);document.dispatchEvent(et)}function handleAndDispatchCustomEvent(et,o,tt,{discrete:rt}){const nt=tt.originalEvent.target,ot=new CustomEvent(et,{bubbles:!1,cancelable:!0,detail:tt});o&&nt.addEventListener(et,o,{once:!0}),rt?dispatchDiscreteCustomEvent(nt,ot):nt.dispatchEvent(ot)}var AUTOFOCUS_ON_MOUNT="focusScope.autoFocusOnMount",AUTOFOCUS_ON_UNMOUNT="focusScope.autoFocusOnUnmount",EVENT_OPTIONS={bubbles:!1,cancelable:!0},FOCUS_SCOPE_NAME="FocusScope",FocusScope=reactExports.forwardRef((et,o)=>{const{loop:tt=!1,trapped:rt=!1,onMountAutoFocus:nt,onUnmountAutoFocus:ot,...it}=et,[st,at]=reactExports.useState(null),ct=useCallbackRef$1(nt),lt=useCallbackRef$1(ot),dt=reactExports.useRef(null),ht=useComposedRefs(o,pt=>at(pt)),mt=reactExports.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;reactExports.useEffect(()=>{if(rt){let pt=function(xt){if(mt.paused||!st)return;const vt=xt.target;st.contains(vt)?dt.current=vt:focus(dt.current,{select:!0})},gt=function(xt){if(mt.paused||!st)return;const vt=xt.relatedTarget;vt!==null&&(st.contains(vt)||focus(dt.current,{select:!0}))},yt=function(xt){if(document.activeElement===document.body)for(const Et of xt)Et.removedNodes.length>0&&focus(st)};document.addEventListener("focusin",pt),document.addEventListener("focusout",gt);const bt=new MutationObserver(yt);return st&&bt.observe(st,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",pt),document.removeEventListener("focusout",gt),bt.disconnect()}}},[rt,st,mt.paused]),reactExports.useEffect(()=>{if(st){focusScopesStack.add(mt);const pt=document.activeElement;if(!st.contains(pt)){const yt=new CustomEvent(AUTOFOCUS_ON_MOUNT,EVENT_OPTIONS);st.addEventListener(AUTOFOCUS_ON_MOUNT,ct),st.dispatchEvent(yt),yt.defaultPrevented||(focusFirst(removeLinks(getTabbableCandidates(st)),{select:!0}),document.activeElement===pt&&focus(st))}return()=>{st.removeEventListener(AUTOFOCUS_ON_MOUNT,ct),setTimeout(()=>{const yt=new CustomEvent(AUTOFOCUS_ON_UNMOUNT,EVENT_OPTIONS);st.addEventListener(AUTOFOCUS_ON_UNMOUNT,lt),st.dispatchEvent(yt),yt.defaultPrevented||focus(pt??document.body,{select:!0}),st.removeEventListener(AUTOFOCUS_ON_UNMOUNT,lt),focusScopesStack.remove(mt)},0)}}},[st,ct,lt,mt]);const ft=reactExports.useCallback(pt=>{if(!tt&&!rt||mt.paused)return;const gt=pt.key==="Tab"&&!pt.altKey&&!pt.ctrlKey&&!pt.metaKey,yt=document.activeElement;if(gt&&yt){const bt=pt.currentTarget,[xt,vt]=getTabbableEdges(bt);xt&&vt?!pt.shiftKey&&yt===vt?(pt.preventDefault(),tt&&focus(xt,{select:!0})):pt.shiftKey&&yt===xt&&(pt.preventDefault(),tt&&focus(vt,{select:!0})):yt===bt&&pt.preventDefault()}},[tt,rt,mt.paused]);return jsxRuntimeExports.jsx(Primitive.div,{tabIndex:-1,...it,ref:ht,onKeyDown:ft})});FocusScope.displayName=FOCUS_SCOPE_NAME;function focusFirst(et,{select:o=!1}={}){const tt=document.activeElement;for(const rt of et)if(focus(rt,{select:o}),document.activeElement!==tt)return}function getTabbableEdges(et){const o=getTabbableCandidates(et),tt=findVisible(o,et),rt=findVisible(o.reverse(),et);return[tt,rt]}function getTabbableCandidates(et){const o=[],tt=document.createTreeWalker(et,NodeFilter.SHOW_ELEMENT,{acceptNode:rt=>{const nt=rt.tagName==="INPUT"&&rt.type==="hidden";return rt.disabled||rt.hidden||nt?NodeFilter.FILTER_SKIP:rt.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;tt.nextNode();)o.push(tt.currentNode);return o}function findVisible(et,o){for(const tt of et)if(!isHidden(tt,{upTo:o}))return tt}function isHidden(et,{upTo:o}){if(getComputedStyle(et).visibility==="hidden")return!0;for(;et;){if(o!==void 0&&et===o)return!1;if(getComputedStyle(et).display==="none")return!0;et=et.parentElement}return!1}function isSelectableInput(et){return et instanceof HTMLInputElement&&"select"in et}function focus(et,{select:o=!1}={}){if(et&&et.focus){const tt=document.activeElement;et.focus({preventScroll:!0}),et!==tt&&isSelectableInput(et)&&o&&et.select()}}var focusScopesStack=createFocusScopesStack();function createFocusScopesStack(){let et=[];return{add(o){const tt=et[0];o!==tt&&(tt==null||tt.pause()),et=arrayRemove(et,o),et.unshift(o)},remove(o){var tt;et=arrayRemove(et,o),(tt=et[0])==null||tt.resume()}}}function arrayRemove(et,o){const tt=[...et],rt=tt.indexOf(o);return rt!==-1&&tt.splice(rt,1),tt}function removeLinks(et){return et.filter(o=>o.tagName!=="A")}var PORTAL_NAME$1="Portal",Portal$1=reactExports.forwardRef((et,o)=>{var st;const{container:tt,...rt}=et,[nt,ot]=reactExports.useState(!1);useLayoutEffect2(()=>ot(!0),[]);const it=tt||nt&&((st=globalThis==null?void 0:globalThis.document)==null?void 0:st.body);return it?ReactDOM.createPortal(jsxRuntimeExports.jsx(Primitive.div,{...rt,ref:o}),it):null});Portal$1.displayName=PORTAL_NAME$1;function useStateMachine$1(et,o){return reactExports.useReducer((tt,rt)=>o[tt][rt]??tt,et)}var Presence=et=>{const{present:o,children:tt}=et,rt=usePresence(o),nt=typeof tt=="function"?tt({present:rt.isPresent}):reactExports.Children.only(tt),ot=useComposedRefs(rt.ref,getElementRef(nt));return typeof tt=="function"||rt.isPresent?reactExports.cloneElement(nt,{ref:ot}):null};Presence.displayName="Presence";function usePresence(et){const[o,tt]=reactExports.useState(),rt=reactExports.useRef({}),nt=reactExports.useRef(et),ot=reactExports.useRef("none"),it=et?"mounted":"unmounted",[st,at]=useStateMachine$1(it,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return reactExports.useEffect(()=>{const ct=getAnimationName(rt.current);ot.current=st==="mounted"?ct:"none"},[st]),useLayoutEffect2(()=>{const ct=rt.current,lt=nt.current;if(lt!==et){const ht=ot.current,mt=getAnimationName(ct);et?at("MOUNT"):mt==="none"||(ct==null?void 0:ct.display)==="none"?at("UNMOUNT"):at(lt&&ht!==mt?"ANIMATION_OUT":"UNMOUNT"),nt.current=et}},[et,at]),useLayoutEffect2(()=>{if(o){let ct;const lt=o.ownerDocument.defaultView??window,dt=mt=>{const pt=getAnimationName(rt.current).includes(mt.animationName);if(mt.target===o&&pt&&(at("ANIMATION_END"),!nt.current)){const gt=o.style.animationFillMode;o.style.animationFillMode="forwards",ct=lt.setTimeout(()=>{o.style.animationFillMode==="forwards"&&(o.style.animationFillMode=gt)})}},ht=mt=>{mt.target===o&&(ot.current=getAnimationName(rt.current))};return o.addEventListener("animationstart",ht),o.addEventListener("animationcancel",dt),o.addEventListener("animationend",dt),()=>{lt.clearTimeout(ct),o.removeEventListener("animationstart",ht),o.removeEventListener("animationcancel",dt),o.removeEventListener("animationend",dt)}}else at("ANIMATION_END")},[o,at]),{isPresent:["mounted","unmountSuspended"].includes(st),ref:reactExports.useCallback(ct=>{ct&&(rt.current=getComputedStyle(ct)),tt(ct)},[])}}function getAnimationName(et){return(et==null?void 0:et.animationName)||"none"}function getElementRef(et){var rt,nt;let o=(rt=Object.getOwnPropertyDescriptor(et.props,"ref"))==null?void 0:rt.get,tt=o&&"isReactWarning"in o&&o.isReactWarning;return tt?et.ref:(o=(nt=Object.getOwnPropertyDescriptor(et,"ref"))==null?void 0:nt.get,tt=o&&"isReactWarning"in o&&o.isReactWarning,tt?et.props.ref:et.props.ref||et.ref)}var count=0;function useFocusGuards(){reactExports.useEffect(()=>{const et=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",et[0]??createFocusGuard()),document.body.insertAdjacentElement("beforeend",et[1]??createFocusGuard()),count++,()=>{count===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(o=>o.remove()),count--}},[])}function createFocusGuard(){const et=document.createElement("span");return et.setAttribute("data-radix-focus-guard",""),et.tabIndex=0,et.style.outline="none",et.style.opacity="0",et.style.position="fixed",et.style.pointerEvents="none",et}var zeroRightClassName="right-scroll-bar-position",fullWidthClassName="width-before-scroll-bar",noScrollbarsClassName="with-scroll-bars-hidden",removedBarSizeVariable="--removed-body-scroll-bar-size";function assignRef(et,o){return typeof et=="function"?et(o):et&&(et.current=o),et}function useCallbackRef(et,o){var tt=reactExports.useState(function(){return{value:et,callback:o,facade:{get current(){return tt.value},set current(rt){var nt=tt.value;nt!==rt&&(tt.value=rt,tt.callback(rt,nt))}}}})[0];return tt.callback=o,tt.facade}var useIsomorphicLayoutEffect=typeof window<"u"?reactExports.useLayoutEffect:reactExports.useEffect,currentValues=new WeakMap;function useMergeRefs(et,o){var tt=useCallbackRef(null,function(rt){return et.forEach(function(nt){return assignRef(nt,rt)})});return useIsomorphicLayoutEffect(function(){var rt=currentValues.get(tt);if(rt){var nt=new Set(rt),ot=new Set(et),it=tt.current;nt.forEach(function(st){ot.has(st)||assignRef(st,null)}),ot.forEach(function(st){nt.has(st)||assignRef(st,it)})}currentValues.set(tt,et)},[et]),tt}function ItoI(et){return et}function innerCreateMedium(et,o){o===void 0&&(o=ItoI);var tt=[],rt=!1,nt={read:function(){if(rt)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return tt.length?tt[tt.length-1]:et},useMedium:function(ot){var it=o(ot,rt);return tt.push(it),function(){tt=tt.filter(function(st){return st!==it})}},assignSyncMedium:function(ot){for(rt=!0;tt.length;){var it=tt;tt=[],it.forEach(ot)}tt={push:function(st){return ot(st)},filter:function(){return tt}}},assignMedium:function(ot){rt=!0;var it=[];if(tt.length){var st=tt;tt=[],st.forEach(ot),it=tt}var at=function(){var lt=it;it=[],lt.forEach(ot)},ct=function(){return Promise.resolve().then(at)};ct(),tt={push:function(lt){it.push(lt),ct()},filter:function(lt){return it=it.filter(lt),tt}}}};return nt}function createSidecarMedium(et){et===void 0&&(et={});var o=innerCreateMedium(null);return o.options=__assign({async:!0,ssr:!1},et),o}var SideCar$1=function(et){var o=et.sideCar,tt=__rest(et,["sideCar"]);if(!o)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var rt=o.read();if(!rt)throw new Error("Sidecar medium not found");return reactExports.createElement(rt,__assign({},tt))};SideCar$1.isSideCarExport=!0;function exportSidecar(et,o){return et.useMedium(o),SideCar$1}var effectCar=createSidecarMedium(),nothing=function(){},RemoveScroll=reactExports.forwardRef(function(et,o){var tt=reactExports.useRef(null),rt=reactExports.useState({onScrollCapture:nothing,onWheelCapture:nothing,onTouchMoveCapture:nothing}),nt=rt[0],ot=rt[1],it=et.forwardProps,st=et.children,at=et.className,ct=et.removeScrollBar,lt=et.enabled,dt=et.shards,ht=et.sideCar,mt=et.noIsolation,ft=et.inert,pt=et.allowPinchZoom,gt=et.as,yt=gt===void 0?"div":gt,bt=et.gapMode,xt=__rest(et,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),vt=ht,Et=useMergeRefs([tt,o]),Ct=__assign(__assign({},xt),nt);return reactExports.createElement(reactExports.Fragment,null,lt&&reactExports.createElement(vt,{sideCar:effectCar,removeScrollBar:ct,shards:dt,noIsolation:mt,inert:ft,setCallbacks:ot,allowPinchZoom:!!pt,lockRef:tt,gapMode:bt}),it?reactExports.cloneElement(reactExports.Children.only(st),__assign(__assign({},Ct),{ref:Et})):reactExports.createElement(yt,__assign({},Ct,{className:at,ref:Et}),st))});RemoveScroll.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};RemoveScroll.classNames={fullWidth:fullWidthClassName,zeroRight:zeroRightClassName};var getNonce=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function makeStyleTag(){if(!document)return null;var et=document.createElement("style");et.type="text/css";var o=getNonce();return o&&et.setAttribute("nonce",o),et}function injectStyles(et,o){et.styleSheet?et.styleSheet.cssText=o:et.appendChild(document.createTextNode(o))}function insertStyleTag(et){var o=document.head||document.getElementsByTagName("head")[0];o.appendChild(et)}var stylesheetSingleton=function(){var et=0,o=null;return{add:function(tt){et==0&&(o=makeStyleTag())&&(injectStyles(o,tt),insertStyleTag(o)),et++},remove:function(){et--,!et&&o&&(o.parentNode&&o.parentNode.removeChild(o),o=null)}}},styleHookSingleton=function(){var et=stylesheetSingleton();return function(o,tt){reactExports.useEffect(function(){return et.add(o),function(){et.remove()}},[o&&tt])}},styleSingleton=function(){var et=styleHookSingleton(),o=function(tt){var rt=tt.styles,nt=tt.dynamic;return et(rt,nt),null};return o},zeroGap={left:0,top:0,right:0,gap:0},parse$2=function(et){return parseInt(et||"",10)||0},getOffset=function(et){var o=window.getComputedStyle(document.body),tt=o[et==="padding"?"paddingLeft":"marginLeft"],rt=o[et==="padding"?"paddingTop":"marginTop"],nt=o[et==="padding"?"paddingRight":"marginRight"];return[parse$2(tt),parse$2(rt),parse$2(nt)]},getGapWidth=function(et){if(et===void 0&&(et="margin"),typeof window>"u")return zeroGap;var o=getOffset(et),tt=document.documentElement.clientWidth,rt=window.innerWidth;return{left:o[0],top:o[1],right:o[2],gap:Math.max(0,rt-tt+o[2]-o[0])}},Style=styleSingleton(),lockAttribute="data-scroll-locked",getStyles=function(et,o,tt,rt){var nt=et.left,ot=et.top,it=et.right,st=et.gap;return tt===void 0&&(tt="margin"),` + */const LoaderCircle=createLucideIcon("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),Header=({wakuStatus:et})=>{const{address:o,isConnected:tt}=useAccount(),{disconnect:rt}=useDisconnect(),{isLoading:nt,error:ot,node:it}=useWaku(),[st,at]=reactExports.useState(0),ct=useLocation(),{data:lt}=useEnsName({address:o});reactExports.useEffect(()=>{if(it){const ht=()=>{at(it.libp2p.getConnections().length)};return ht(),it.libp2p.addEventListener("peer:connect",ht),it.libp2p.addEventListener("peer:disconnect",ht),()=>{it.libp2p.removeEventListener("peer:connect",ht),it.libp2p.removeEventListener("peer:disconnect",ht)}}},[it]);const dt=ht=>{switch(ht){case"success":return"bg-green-500";case"in-progress":return"bg-yellow-500";case"error":return"bg-red-500"}};return jsxRuntimeExports.jsx("header",{className:"border-b",children:jsxRuntimeExports.jsx("div",{className:"container mx-auto px-4 py-2 md:py-4",children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center space-y-2 md:space-y-0",children:[jsxRuntimeExports.jsxs("div",{className:"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4 w-full md:w-auto",children:[jsxRuntimeExports.jsx("h1",{className:"text-xl md:text-2xl font-bold",children:"BuddyBook"}),jsxRuntimeExports.jsx("nav",{className:"w-full md:w-auto",children:jsxRuntimeExports.jsxs("ul",{className:"flex justify-center md:justify-start space-x-4",children:[jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsx(Link,{to:"/create",className:`text-sm ${ct.pathname==="/create"?"text-primary font-semibold":"text-muted-foreground"}`,children:"Create Chain"})}),jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsx(Link,{to:"/view",className:`text-sm ${ct.pathname==="/view"?"text-primary font-semibold":"text-muted-foreground"}`,children:"View Chains"})}),jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsx(Link,{to:"/telemetry",className:`text-sm ${ct.pathname==="/telemetry"?"text-primary font-semibold":"text-muted-foreground"}`,children:"Telemetry"})})]})})]}),jsxRuntimeExports.jsxs("div",{className:"flex flex-wrap justify-center md:justify-end items-center gap-2 w-full md:w-auto",children:[jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-2 text-xs md:text-sm",children:nt?jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Connecting..."})]}):ot?jsxRuntimeExports.jsx("span",{className:"text-destructive",children:"Network Error"}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Filter:"}),jsxRuntimeExports.jsx("div",{className:`w-2 h-2 md:w-3 md:h-3 rounded-full ${dt(et.filter)}`})]}),jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Store:"}),jsxRuntimeExports.jsx("div",{className:`w-2 h-2 md:w-3 md:h-3 rounded-full ${dt(et.store)}`})]}),jsxRuntimeExports.jsx("span",{className:"text-xs md:text-sm text-muted-foreground hidden md:inline",children:st>0?`${st} peer${st===1?"":"s"}`:"Connecting..."})]})}),jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[nt?jsxRuntimeExports.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):ot?jsxRuntimeExports.jsx("span",{className:"text-xs md:text-sm text-red-500",children:"Waku Error"}):jsxRuntimeExports.jsxs("span",{className:"text-xs md:text-sm text-muted-foreground hidden md:inline",children:["Waku Connections: ",st]}),tt?jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntimeExports.jsx("span",{className:"text-xs md:text-sm text-muted-foreground truncate max-w-[120px] md:max-w-none",children:lt||(o?`${o.slice(0,6)}...${o.slice(-4)}`:"")}),jsxRuntimeExports.jsx(Button,{variant:"outline",size:"sm",onClick:()=>rt(),children:"Logout"})]}):jsxRuntimeExports.jsx(ConnectKitButton,{})]})]})]})})})},Input=reactExports.forwardRef(({className:et,type:o,...tt},rt)=>jsxRuntimeExports.jsx("input",{type:o,className:cn("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",et),ref:rt,...tt}));Input.displayName="Input";const Textarea=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",et),ref:tt,...o}));Textarea.displayName="Textarea";var NODES=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Primitive=NODES.reduce((et,o)=>{const tt=reactExports.forwardRef((rt,nt)=>{const{asChild:ot,...it}=rt,st=ot?Slot:o;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),jsxRuntimeExports.jsx(st,{...it,ref:nt})});return tt.displayName=`Primitive.${o}`,{...et,[o]:tt}},{});function dispatchDiscreteCustomEvent(et,o){et&&reactDomExports.flushSync(()=>et.dispatchEvent(o))}var NAME="Label",Label$1=reactExports.forwardRef((et,o)=>jsxRuntimeExports.jsx(Primitive.label,{...et,ref:o,onMouseDown:tt=>{var nt;tt.target.closest("button, input, select, textarea")||((nt=et.onMouseDown)==null||nt.call(et,tt),!tt.defaultPrevented&&tt.detail>1&&tt.preventDefault())}}));Label$1.displayName=NAME;var Root$3=Label$1;const labelVariants=cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Label=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx(Root$3,{ref:tt,className:cn(labelVariants(),et),...o}));Label.displayName=Root$3.displayName;const Card=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("div",{ref:tt,className:cn("rounded-lg border bg-card text-card-foreground shadow-sm p-4 md:p-6",et),...o}));Card.displayName="Card";const CardHeader=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("div",{ref:tt,className:cn("flex flex-col space-y-1.5 p-4 md:p-6",et),...o}));CardHeader.displayName="CardHeader";const CardTitle=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("h3",{ref:tt,className:cn("font-semibold leading-none tracking-tight",et),...o}));CardTitle.displayName="CardTitle";const CardDescription=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("p",{ref:tt,className:cn("text-sm text-muted-foreground",et),...o}));CardDescription.displayName="CardDescription";const CardContent=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("div",{ref:tt,className:cn("p-6 pt-0",et),...o}));CardContent.displayName="CardContent";const CardFooter=reactExports.forwardRef(({className:et,...o},tt)=>jsxRuntimeExports.jsx("div",{ref:tt,className:cn("flex items-center p-6 pt-0",et),...o}));CardFooter.displayName="CardFooter";function composeEventHandlers(et,o,{checkForDefaultPrevented:tt=!0}={}){return function(nt){if(et==null||et(nt),tt===!1||!nt.defaultPrevented)return o==null?void 0:o(nt)}}function createContext2(et,o){const tt=reactExports.createContext(o),rt=ot=>{const{children:it,...st}=ot,at=reactExports.useMemo(()=>st,Object.values(st));return jsxRuntimeExports.jsx(tt.Provider,{value:at,children:it})};rt.displayName=et+"Provider";function nt(ot){const it=reactExports.useContext(tt);if(it)return it;if(o!==void 0)return o;throw new Error(`\`${ot}\` must be used within \`${et}\``)}return[rt,nt]}function createContextScope(et,o=[]){let tt=[];function rt(ot,it){const st=reactExports.createContext(it),at=tt.length;tt=[...tt,it];const ct=dt=>{var gt;const{scope:ht,children:mt,...ft}=dt,pt=((gt=ht==null?void 0:ht[et])==null?void 0:gt[at])||st,yt=reactExports.useMemo(()=>ft,Object.values(ft));return jsxRuntimeExports.jsx(pt.Provider,{value:yt,children:mt})};ct.displayName=ot+"Provider";function lt(dt,ht){var pt;const mt=((pt=ht==null?void 0:ht[et])==null?void 0:pt[at])||st,ft=reactExports.useContext(mt);if(ft)return ft;if(it!==void 0)return it;throw new Error(`\`${dt}\` must be used within \`${ot}\``)}return[ct,lt]}const nt=()=>{const ot=tt.map(it=>reactExports.createContext(it));return function(st){const at=(st==null?void 0:st[et])||ot;return reactExports.useMemo(()=>({[`__scope${et}`]:{...st,[et]:at}}),[st,at])}};return nt.scopeName=et,[rt,composeContextScopes(nt,...o)]}function composeContextScopes(...et){const o=et[0];if(et.length===1)return o;const tt=()=>{const rt=et.map(nt=>({useScope:nt(),scopeName:nt.scopeName}));return function(ot){const it=rt.reduce((st,{useScope:at,scopeName:ct})=>{const dt=at(ot)[`__scope${ct}`];return{...st,...dt}},{});return reactExports.useMemo(()=>({[`__scope${o.scopeName}`]:it}),[it])}};return tt.scopeName=o.scopeName,tt}var useLayoutEffect2=globalThis!=null&&globalThis.document?reactExports.useLayoutEffect:()=>{},useReactId=React$1.useId||(()=>{}),count$1=0;function useId(et){const[o,tt]=reactExports.useState(useReactId());return useLayoutEffect2(()=>{et||tt(rt=>rt??String(count$1++))},[et]),et||(o?`radix-${o}`:"")}function useCallbackRef$1(et){const o=reactExports.useRef(et);return reactExports.useEffect(()=>{o.current=et}),reactExports.useMemo(()=>(...tt)=>{var rt;return(rt=o.current)==null?void 0:rt.call(o,...tt)},[])}function useControllableState({prop:et,defaultProp:o,onChange:tt=()=>{}}){const[rt,nt]=useUncontrolledState({defaultProp:o,onChange:tt}),ot=et!==void 0,it=ot?et:rt,st=useCallbackRef$1(tt),at=reactExports.useCallback(ct=>{if(ot){const dt=typeof ct=="function"?ct(et):ct;dt!==et&&st(dt)}else nt(ct)},[ot,et,nt,st]);return[it,at]}function useUncontrolledState({defaultProp:et,onChange:o}){const tt=reactExports.useState(et),[rt]=tt,nt=reactExports.useRef(rt),ot=useCallbackRef$1(o);return reactExports.useEffect(()=>{nt.current!==rt&&(ot(rt),nt.current=rt)},[rt,nt,ot]),tt}function useEscapeKeydown(et,o=globalThis==null?void 0:globalThis.document){const tt=useCallbackRef$1(et);reactExports.useEffect(()=>{const rt=nt=>{nt.key==="Escape"&&tt(nt)};return o.addEventListener("keydown",rt,{capture:!0}),()=>o.removeEventListener("keydown",rt,{capture:!0})},[tt,o])}var DISMISSABLE_LAYER_NAME="DismissableLayer",CONTEXT_UPDATE="dismissableLayer.update",POINTER_DOWN_OUTSIDE="dismissableLayer.pointerDownOutside",FOCUS_OUTSIDE="dismissableLayer.focusOutside",originalBodyPointerEvents,DismissableLayerContext=reactExports.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),DismissableLayer=reactExports.forwardRef((et,o)=>{const{disableOutsidePointerEvents:tt=!1,onEscapeKeyDown:rt,onPointerDownOutside:nt,onFocusOutside:ot,onInteractOutside:it,onDismiss:st,...at}=et,ct=reactExports.useContext(DismissableLayerContext),[lt,dt]=reactExports.useState(null),ht=(lt==null?void 0:lt.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,mt]=reactExports.useState({}),ft=useComposedRefs(o,St=>dt(St)),pt=Array.from(ct.layers),[yt]=[...ct.layersWithOutsidePointerEventsDisabled].slice(-1),gt=pt.indexOf(yt),bt=lt?pt.indexOf(lt):-1,xt=ct.layersWithOutsidePointerEventsDisabled.size>0,vt=bt>=gt,Et=usePointerDownOutside(St=>{const At=St.target,kt=[...ct.branches].some(It=>It.contains(At));!vt||kt||(nt==null||nt(St),it==null||it(St),St.defaultPrevented||st==null||st())},ht),Ct=useFocusOutside(St=>{const At=St.target;[...ct.branches].some(It=>It.contains(At))||(ot==null||ot(St),it==null||it(St),St.defaultPrevented||st==null||st())},ht);return useEscapeKeydown(St=>{bt===ct.layers.size-1&&(rt==null||rt(St),!St.defaultPrevented&&st&&(St.preventDefault(),st()))},ht),reactExports.useEffect(()=>{if(lt)return tt&&(ct.layersWithOutsidePointerEventsDisabled.size===0&&(originalBodyPointerEvents=ht.body.style.pointerEvents,ht.body.style.pointerEvents="none"),ct.layersWithOutsidePointerEventsDisabled.add(lt)),ct.layers.add(lt),dispatchUpdate(),()=>{tt&&ct.layersWithOutsidePointerEventsDisabled.size===1&&(ht.body.style.pointerEvents=originalBodyPointerEvents)}},[lt,ht,tt,ct]),reactExports.useEffect(()=>()=>{lt&&(ct.layers.delete(lt),ct.layersWithOutsidePointerEventsDisabled.delete(lt),dispatchUpdate())},[lt,ct]),reactExports.useEffect(()=>{const St=()=>mt({});return document.addEventListener(CONTEXT_UPDATE,St),()=>document.removeEventListener(CONTEXT_UPDATE,St)},[]),jsxRuntimeExports.jsx(Primitive.div,{...at,ref:ft,style:{pointerEvents:xt?vt?"auto":"none":void 0,...et.style},onFocusCapture:composeEventHandlers(et.onFocusCapture,Ct.onFocusCapture),onBlurCapture:composeEventHandlers(et.onBlurCapture,Ct.onBlurCapture),onPointerDownCapture:composeEventHandlers(et.onPointerDownCapture,Et.onPointerDownCapture)})});DismissableLayer.displayName=DISMISSABLE_LAYER_NAME;var BRANCH_NAME="DismissableLayerBranch",DismissableLayerBranch=reactExports.forwardRef((et,o)=>{const tt=reactExports.useContext(DismissableLayerContext),rt=reactExports.useRef(null),nt=useComposedRefs(o,rt);return reactExports.useEffect(()=>{const ot=rt.current;if(ot)return tt.branches.add(ot),()=>{tt.branches.delete(ot)}},[tt.branches]),jsxRuntimeExports.jsx(Primitive.div,{...et,ref:nt})});DismissableLayerBranch.displayName=BRANCH_NAME;function usePointerDownOutside(et,o=globalThis==null?void 0:globalThis.document){const tt=useCallbackRef$1(et),rt=reactExports.useRef(!1),nt=reactExports.useRef(()=>{});return reactExports.useEffect(()=>{const ot=st=>{if(st.target&&!rt.current){let at=function(){handleAndDispatchCustomEvent(POINTER_DOWN_OUTSIDE,tt,ct,{discrete:!0})};const ct={originalEvent:st};st.pointerType==="touch"?(o.removeEventListener("click",nt.current),nt.current=at,o.addEventListener("click",nt.current,{once:!0})):at()}else o.removeEventListener("click",nt.current);rt.current=!1},it=window.setTimeout(()=>{o.addEventListener("pointerdown",ot)},0);return()=>{window.clearTimeout(it),o.removeEventListener("pointerdown",ot),o.removeEventListener("click",nt.current)}},[o,tt]),{onPointerDownCapture:()=>rt.current=!0}}function useFocusOutside(et,o=globalThis==null?void 0:globalThis.document){const tt=useCallbackRef$1(et),rt=reactExports.useRef(!1);return reactExports.useEffect(()=>{const nt=ot=>{ot.target&&!rt.current&&handleAndDispatchCustomEvent(FOCUS_OUTSIDE,tt,{originalEvent:ot},{discrete:!1})};return o.addEventListener("focusin",nt),()=>o.removeEventListener("focusin",nt)},[o,tt]),{onFocusCapture:()=>rt.current=!0,onBlurCapture:()=>rt.current=!1}}function dispatchUpdate(){const et=new CustomEvent(CONTEXT_UPDATE);document.dispatchEvent(et)}function handleAndDispatchCustomEvent(et,o,tt,{discrete:rt}){const nt=tt.originalEvent.target,ot=new CustomEvent(et,{bubbles:!1,cancelable:!0,detail:tt});o&&nt.addEventListener(et,o,{once:!0}),rt?dispatchDiscreteCustomEvent(nt,ot):nt.dispatchEvent(ot)}var AUTOFOCUS_ON_MOUNT="focusScope.autoFocusOnMount",AUTOFOCUS_ON_UNMOUNT="focusScope.autoFocusOnUnmount",EVENT_OPTIONS={bubbles:!1,cancelable:!0},FOCUS_SCOPE_NAME="FocusScope",FocusScope=reactExports.forwardRef((et,o)=>{const{loop:tt=!1,trapped:rt=!1,onMountAutoFocus:nt,onUnmountAutoFocus:ot,...it}=et,[st,at]=reactExports.useState(null),ct=useCallbackRef$1(nt),lt=useCallbackRef$1(ot),dt=reactExports.useRef(null),ht=useComposedRefs(o,pt=>at(pt)),mt=reactExports.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;reactExports.useEffect(()=>{if(rt){let pt=function(xt){if(mt.paused||!st)return;const vt=xt.target;st.contains(vt)?dt.current=vt:focus(dt.current,{select:!0})},yt=function(xt){if(mt.paused||!st)return;const vt=xt.relatedTarget;vt!==null&&(st.contains(vt)||focus(dt.current,{select:!0}))},gt=function(xt){if(document.activeElement===document.body)for(const Et of xt)Et.removedNodes.length>0&&focus(st)};document.addEventListener("focusin",pt),document.addEventListener("focusout",yt);const bt=new MutationObserver(gt);return st&&bt.observe(st,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",pt),document.removeEventListener("focusout",yt),bt.disconnect()}}},[rt,st,mt.paused]),reactExports.useEffect(()=>{if(st){focusScopesStack.add(mt);const pt=document.activeElement;if(!st.contains(pt)){const gt=new CustomEvent(AUTOFOCUS_ON_MOUNT,EVENT_OPTIONS);st.addEventListener(AUTOFOCUS_ON_MOUNT,ct),st.dispatchEvent(gt),gt.defaultPrevented||(focusFirst(removeLinks(getTabbableCandidates(st)),{select:!0}),document.activeElement===pt&&focus(st))}return()=>{st.removeEventListener(AUTOFOCUS_ON_MOUNT,ct),setTimeout(()=>{const gt=new CustomEvent(AUTOFOCUS_ON_UNMOUNT,EVENT_OPTIONS);st.addEventListener(AUTOFOCUS_ON_UNMOUNT,lt),st.dispatchEvent(gt),gt.defaultPrevented||focus(pt??document.body,{select:!0}),st.removeEventListener(AUTOFOCUS_ON_UNMOUNT,lt),focusScopesStack.remove(mt)},0)}}},[st,ct,lt,mt]);const ft=reactExports.useCallback(pt=>{if(!tt&&!rt||mt.paused)return;const yt=pt.key==="Tab"&&!pt.altKey&&!pt.ctrlKey&&!pt.metaKey,gt=document.activeElement;if(yt&>){const bt=pt.currentTarget,[xt,vt]=getTabbableEdges(bt);xt&&vt?!pt.shiftKey&>===vt?(pt.preventDefault(),tt&&focus(xt,{select:!0})):pt.shiftKey&>===xt&&(pt.preventDefault(),tt&&focus(vt,{select:!0})):gt===bt&&pt.preventDefault()}},[tt,rt,mt.paused]);return jsxRuntimeExports.jsx(Primitive.div,{tabIndex:-1,...it,ref:ht,onKeyDown:ft})});FocusScope.displayName=FOCUS_SCOPE_NAME;function focusFirst(et,{select:o=!1}={}){const tt=document.activeElement;for(const rt of et)if(focus(rt,{select:o}),document.activeElement!==tt)return}function getTabbableEdges(et){const o=getTabbableCandidates(et),tt=findVisible(o,et),rt=findVisible(o.reverse(),et);return[tt,rt]}function getTabbableCandidates(et){const o=[],tt=document.createTreeWalker(et,NodeFilter.SHOW_ELEMENT,{acceptNode:rt=>{const nt=rt.tagName==="INPUT"&&rt.type==="hidden";return rt.disabled||rt.hidden||nt?NodeFilter.FILTER_SKIP:rt.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;tt.nextNode();)o.push(tt.currentNode);return o}function findVisible(et,o){for(const tt of et)if(!isHidden(tt,{upTo:o}))return tt}function isHidden(et,{upTo:o}){if(getComputedStyle(et).visibility==="hidden")return!0;for(;et;){if(o!==void 0&&et===o)return!1;if(getComputedStyle(et).display==="none")return!0;et=et.parentElement}return!1}function isSelectableInput(et){return et instanceof HTMLInputElement&&"select"in et}function focus(et,{select:o=!1}={}){if(et&&et.focus){const tt=document.activeElement;et.focus({preventScroll:!0}),et!==tt&&isSelectableInput(et)&&o&&et.select()}}var focusScopesStack=createFocusScopesStack();function createFocusScopesStack(){let et=[];return{add(o){const tt=et[0];o!==tt&&(tt==null||tt.pause()),et=arrayRemove(et,o),et.unshift(o)},remove(o){var tt;et=arrayRemove(et,o),(tt=et[0])==null||tt.resume()}}}function arrayRemove(et,o){const tt=[...et],rt=tt.indexOf(o);return rt!==-1&&tt.splice(rt,1),tt}function removeLinks(et){return et.filter(o=>o.tagName!=="A")}var PORTAL_NAME$1="Portal",Portal$1=reactExports.forwardRef((et,o)=>{var st;const{container:tt,...rt}=et,[nt,ot]=reactExports.useState(!1);useLayoutEffect2(()=>ot(!0),[]);const it=tt||nt&&((st=globalThis==null?void 0:globalThis.document)==null?void 0:st.body);return it?ReactDOM.createPortal(jsxRuntimeExports.jsx(Primitive.div,{...rt,ref:o}),it):null});Portal$1.displayName=PORTAL_NAME$1;function useStateMachine$1(et,o){return reactExports.useReducer((tt,rt)=>o[tt][rt]??tt,et)}var Presence=et=>{const{present:o,children:tt}=et,rt=usePresence(o),nt=typeof tt=="function"?tt({present:rt.isPresent}):reactExports.Children.only(tt),ot=useComposedRefs(rt.ref,getElementRef(nt));return typeof tt=="function"||rt.isPresent?reactExports.cloneElement(nt,{ref:ot}):null};Presence.displayName="Presence";function usePresence(et){const[o,tt]=reactExports.useState(),rt=reactExports.useRef({}),nt=reactExports.useRef(et),ot=reactExports.useRef("none"),it=et?"mounted":"unmounted",[st,at]=useStateMachine$1(it,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return reactExports.useEffect(()=>{const ct=getAnimationName(rt.current);ot.current=st==="mounted"?ct:"none"},[st]),useLayoutEffect2(()=>{const ct=rt.current,lt=nt.current;if(lt!==et){const ht=ot.current,mt=getAnimationName(ct);et?at("MOUNT"):mt==="none"||(ct==null?void 0:ct.display)==="none"?at("UNMOUNT"):at(lt&&ht!==mt?"ANIMATION_OUT":"UNMOUNT"),nt.current=et}},[et,at]),useLayoutEffect2(()=>{if(o){let ct;const lt=o.ownerDocument.defaultView??window,dt=mt=>{const pt=getAnimationName(rt.current).includes(mt.animationName);if(mt.target===o&&pt&&(at("ANIMATION_END"),!nt.current)){const yt=o.style.animationFillMode;o.style.animationFillMode="forwards",ct=lt.setTimeout(()=>{o.style.animationFillMode==="forwards"&&(o.style.animationFillMode=yt)})}},ht=mt=>{mt.target===o&&(ot.current=getAnimationName(rt.current))};return o.addEventListener("animationstart",ht),o.addEventListener("animationcancel",dt),o.addEventListener("animationend",dt),()=>{lt.clearTimeout(ct),o.removeEventListener("animationstart",ht),o.removeEventListener("animationcancel",dt),o.removeEventListener("animationend",dt)}}else at("ANIMATION_END")},[o,at]),{isPresent:["mounted","unmountSuspended"].includes(st),ref:reactExports.useCallback(ct=>{ct&&(rt.current=getComputedStyle(ct)),tt(ct)},[])}}function getAnimationName(et){return(et==null?void 0:et.animationName)||"none"}function getElementRef(et){var rt,nt;let o=(rt=Object.getOwnPropertyDescriptor(et.props,"ref"))==null?void 0:rt.get,tt=o&&"isReactWarning"in o&&o.isReactWarning;return tt?et.ref:(o=(nt=Object.getOwnPropertyDescriptor(et,"ref"))==null?void 0:nt.get,tt=o&&"isReactWarning"in o&&o.isReactWarning,tt?et.props.ref:et.props.ref||et.ref)}var count=0;function useFocusGuards(){reactExports.useEffect(()=>{const et=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",et[0]??createFocusGuard()),document.body.insertAdjacentElement("beforeend",et[1]??createFocusGuard()),count++,()=>{count===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(o=>o.remove()),count--}},[])}function createFocusGuard(){const et=document.createElement("span");return et.setAttribute("data-radix-focus-guard",""),et.tabIndex=0,et.style.outline="none",et.style.opacity="0",et.style.position="fixed",et.style.pointerEvents="none",et}var zeroRightClassName="right-scroll-bar-position",fullWidthClassName="width-before-scroll-bar",noScrollbarsClassName="with-scroll-bars-hidden",removedBarSizeVariable="--removed-body-scroll-bar-size";function assignRef(et,o){return typeof et=="function"?et(o):et&&(et.current=o),et}function useCallbackRef(et,o){var tt=reactExports.useState(function(){return{value:et,callback:o,facade:{get current(){return tt.value},set current(rt){var nt=tt.value;nt!==rt&&(tt.value=rt,tt.callback(rt,nt))}}}})[0];return tt.callback=o,tt.facade}var useIsomorphicLayoutEffect=typeof window<"u"?reactExports.useLayoutEffect:reactExports.useEffect,currentValues=new WeakMap;function useMergeRefs(et,o){var tt=useCallbackRef(null,function(rt){return et.forEach(function(nt){return assignRef(nt,rt)})});return useIsomorphicLayoutEffect(function(){var rt=currentValues.get(tt);if(rt){var nt=new Set(rt),ot=new Set(et),it=tt.current;nt.forEach(function(st){ot.has(st)||assignRef(st,null)}),ot.forEach(function(st){nt.has(st)||assignRef(st,it)})}currentValues.set(tt,et)},[et]),tt}function ItoI(et){return et}function innerCreateMedium(et,o){o===void 0&&(o=ItoI);var tt=[],rt=!1,nt={read:function(){if(rt)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return tt.length?tt[tt.length-1]:et},useMedium:function(ot){var it=o(ot,rt);return tt.push(it),function(){tt=tt.filter(function(st){return st!==it})}},assignSyncMedium:function(ot){for(rt=!0;tt.length;){var it=tt;tt=[],it.forEach(ot)}tt={push:function(st){return ot(st)},filter:function(){return tt}}},assignMedium:function(ot){rt=!0;var it=[];if(tt.length){var st=tt;tt=[],st.forEach(ot),it=tt}var at=function(){var lt=it;it=[],lt.forEach(ot)},ct=function(){return Promise.resolve().then(at)};ct(),tt={push:function(lt){it.push(lt),ct()},filter:function(lt){return it=it.filter(lt),tt}}}};return nt}function createSidecarMedium(et){et===void 0&&(et={});var o=innerCreateMedium(null);return o.options=__assign({async:!0,ssr:!1},et),o}var SideCar$1=function(et){var o=et.sideCar,tt=__rest(et,["sideCar"]);if(!o)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var rt=o.read();if(!rt)throw new Error("Sidecar medium not found");return reactExports.createElement(rt,__assign({},tt))};SideCar$1.isSideCarExport=!0;function exportSidecar(et,o){return et.useMedium(o),SideCar$1}var effectCar=createSidecarMedium(),nothing=function(){},RemoveScroll=reactExports.forwardRef(function(et,o){var tt=reactExports.useRef(null),rt=reactExports.useState({onScrollCapture:nothing,onWheelCapture:nothing,onTouchMoveCapture:nothing}),nt=rt[0],ot=rt[1],it=et.forwardProps,st=et.children,at=et.className,ct=et.removeScrollBar,lt=et.enabled,dt=et.shards,ht=et.sideCar,mt=et.noIsolation,ft=et.inert,pt=et.allowPinchZoom,yt=et.as,gt=yt===void 0?"div":yt,bt=et.gapMode,xt=__rest(et,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),vt=ht,Et=useMergeRefs([tt,o]),Ct=__assign(__assign({},xt),nt);return reactExports.createElement(reactExports.Fragment,null,lt&&reactExports.createElement(vt,{sideCar:effectCar,removeScrollBar:ct,shards:dt,noIsolation:mt,inert:ft,setCallbacks:ot,allowPinchZoom:!!pt,lockRef:tt,gapMode:bt}),it?reactExports.cloneElement(reactExports.Children.only(st),__assign(__assign({},Ct),{ref:Et})):reactExports.createElement(gt,__assign({},Ct,{className:at,ref:Et}),st))});RemoveScroll.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};RemoveScroll.classNames={fullWidth:fullWidthClassName,zeroRight:zeroRightClassName};var getNonce=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function makeStyleTag(){if(!document)return null;var et=document.createElement("style");et.type="text/css";var o=getNonce();return o&&et.setAttribute("nonce",o),et}function injectStyles(et,o){et.styleSheet?et.styleSheet.cssText=o:et.appendChild(document.createTextNode(o))}function insertStyleTag(et){var o=document.head||document.getElementsByTagName("head")[0];o.appendChild(et)}var stylesheetSingleton=function(){var et=0,o=null;return{add:function(tt){et==0&&(o=makeStyleTag())&&(injectStyles(o,tt),insertStyleTag(o)),et++},remove:function(){et--,!et&&o&&(o.parentNode&&o.parentNode.removeChild(o),o=null)}}},styleHookSingleton=function(){var et=stylesheetSingleton();return function(o,tt){reactExports.useEffect(function(){return et.add(o),function(){et.remove()}},[o&&tt])}},styleSingleton=function(){var et=styleHookSingleton(),o=function(tt){var rt=tt.styles,nt=tt.dynamic;return et(rt,nt),null};return o},zeroGap={left:0,top:0,right:0,gap:0},parse$2=function(et){return parseInt(et||"",10)||0},getOffset=function(et){var o=window.getComputedStyle(document.body),tt=o[et==="padding"?"paddingLeft":"marginLeft"],rt=o[et==="padding"?"paddingTop":"marginTop"],nt=o[et==="padding"?"paddingRight":"marginRight"];return[parse$2(tt),parse$2(rt),parse$2(nt)]},getGapWidth=function(et){if(et===void 0&&(et="margin"),typeof window>"u")return zeroGap;var o=getOffset(et),tt=document.documentElement.clientWidth,rt=window.innerWidth;return{left:o[0],top:o[1],right:o[2],gap:Math.max(0,rt-tt+o[2]-o[0])}},Style=styleSingleton(),lockAttribute="data-scroll-locked",getStyles=function(et,o,tt,rt){var nt=et.left,ot=et.top,it=et.right,st=et.gap;return tt===void 0&&(tt="margin"),` .`.concat(noScrollbarsClassName,` { overflow: hidden `).concat(rt,`; padding-right: `).concat(st,"px ").concat(rt,`; @@ -4119,10 +4119,10 @@ https://www.dnscrypt.uk`,country:"United Kingdom",location:{lat:51.4964,long:-.1 body[`).concat(lockAttribute,`] { `).concat(removedBarSizeVariable,": ").concat(st,`px; } -`)},getCurrentUseCounter=function(){var et=parseInt(document.body.getAttribute(lockAttribute)||"0",10);return isFinite(et)?et:0},useLockAttribute=function(){reactExports.useEffect(function(){return document.body.setAttribute(lockAttribute,(getCurrentUseCounter()+1).toString()),function(){var et=getCurrentUseCounter()-1;et<=0?document.body.removeAttribute(lockAttribute):document.body.setAttribute(lockAttribute,et.toString())}},[])},RemoveScrollBar=function(et){var o=et.noRelative,tt=et.noImportant,rt=et.gapMode,nt=rt===void 0?"margin":rt;useLockAttribute();var ot=reactExports.useMemo(function(){return getGapWidth(nt)},[nt]);return reactExports.createElement(Style,{styles:getStyles(ot,!o,nt,tt?"":"!important")})},passiveSupported=!1;if(typeof window<"u")try{var options=Object.defineProperty({},"passive",{get:function(){return passiveSupported=!0,!0}});window.addEventListener("test",options,options),window.removeEventListener("test",options,options)}catch{passiveSupported=!1}var nonPassive=passiveSupported?{passive:!1}:!1,alwaysContainsScroll=function(et){return et.tagName==="TEXTAREA"},elementCanBeScrolled=function(et,o){if(!(et instanceof Element))return!1;var tt=window.getComputedStyle(et);return tt[o]!=="hidden"&&!(tt.overflowY===tt.overflowX&&!alwaysContainsScroll(et)&&tt[o]==="visible")},elementCouldBeVScrolled=function(et){return elementCanBeScrolled(et,"overflowY")},elementCouldBeHScrolled=function(et){return elementCanBeScrolled(et,"overflowX")},locationCouldBeScrolled=function(et,o){var tt=o.ownerDocument,rt=o;do{typeof ShadowRoot<"u"&&rt instanceof ShadowRoot&&(rt=rt.host);var nt=elementCouldBeScrolled(et,rt);if(nt){var ot=getScrollVariables(et,rt),it=ot[1],st=ot[2];if(it>st)return!0}rt=rt.parentNode}while(rt&&rt!==tt.body);return!1},getVScrollVariables=function(et){var o=et.scrollTop,tt=et.scrollHeight,rt=et.clientHeight;return[o,tt,rt]},getHScrollVariables=function(et){var o=et.scrollLeft,tt=et.scrollWidth,rt=et.clientWidth;return[o,tt,rt]},elementCouldBeScrolled=function(et,o){return et==="v"?elementCouldBeVScrolled(o):elementCouldBeHScrolled(o)},getScrollVariables=function(et,o){return et==="v"?getVScrollVariables(o):getHScrollVariables(o)},getDirectionFactor=function(et,o){return et==="h"&&o==="rtl"?-1:1},handleScroll=function(et,o,tt,rt,nt){var ot=getDirectionFactor(et,window.getComputedStyle(o).direction),it=ot*rt,st=tt.target,at=o.contains(st),ct=!1,lt=it>0,dt=0,ht=0;do{var mt=getScrollVariables(et,st),ft=mt[0],pt=mt[1],gt=mt[2],yt=pt-gt-ot*ft;(ft||yt)&&elementCouldBeScrolled(et,st)&&(dt+=yt,ht+=ft),st instanceof ShadowRoot?st=st.host:st=st.parentNode}while(!at&&st!==document.body||at&&(o.contains(st)||o===st));return(lt&&(Math.abs(dt)<1||!nt)||!lt&&(Math.abs(ht)<1||!nt))&&(ct=!0),ct},getTouchXY=function(et){return"changedTouches"in et?[et.changedTouches[0].clientX,et.changedTouches[0].clientY]:[0,0]},getDeltaXY=function(et){return[et.deltaX,et.deltaY]},extractRef=function(et){return et&&"current"in et?et.current:et},deltaCompare=function(et,o){return et[0]===o[0]&&et[1]===o[1]},generateStyle=function(et){return` +`)},getCurrentUseCounter=function(){var et=parseInt(document.body.getAttribute(lockAttribute)||"0",10);return isFinite(et)?et:0},useLockAttribute=function(){reactExports.useEffect(function(){return document.body.setAttribute(lockAttribute,(getCurrentUseCounter()+1).toString()),function(){var et=getCurrentUseCounter()-1;et<=0?document.body.removeAttribute(lockAttribute):document.body.setAttribute(lockAttribute,et.toString())}},[])},RemoveScrollBar=function(et){var o=et.noRelative,tt=et.noImportant,rt=et.gapMode,nt=rt===void 0?"margin":rt;useLockAttribute();var ot=reactExports.useMemo(function(){return getGapWidth(nt)},[nt]);return reactExports.createElement(Style,{styles:getStyles(ot,!o,nt,tt?"":"!important")})},passiveSupported=!1;if(typeof window<"u")try{var options=Object.defineProperty({},"passive",{get:function(){return passiveSupported=!0,!0}});window.addEventListener("test",options,options),window.removeEventListener("test",options,options)}catch{passiveSupported=!1}var nonPassive=passiveSupported?{passive:!1}:!1,alwaysContainsScroll=function(et){return et.tagName==="TEXTAREA"},elementCanBeScrolled=function(et,o){if(!(et instanceof Element))return!1;var tt=window.getComputedStyle(et);return tt[o]!=="hidden"&&!(tt.overflowY===tt.overflowX&&!alwaysContainsScroll(et)&&tt[o]==="visible")},elementCouldBeVScrolled=function(et){return elementCanBeScrolled(et,"overflowY")},elementCouldBeHScrolled=function(et){return elementCanBeScrolled(et,"overflowX")},locationCouldBeScrolled=function(et,o){var tt=o.ownerDocument,rt=o;do{typeof ShadowRoot<"u"&&rt instanceof ShadowRoot&&(rt=rt.host);var nt=elementCouldBeScrolled(et,rt);if(nt){var ot=getScrollVariables(et,rt),it=ot[1],st=ot[2];if(it>st)return!0}rt=rt.parentNode}while(rt&&rt!==tt.body);return!1},getVScrollVariables=function(et){var o=et.scrollTop,tt=et.scrollHeight,rt=et.clientHeight;return[o,tt,rt]},getHScrollVariables=function(et){var o=et.scrollLeft,tt=et.scrollWidth,rt=et.clientWidth;return[o,tt,rt]},elementCouldBeScrolled=function(et,o){return et==="v"?elementCouldBeVScrolled(o):elementCouldBeHScrolled(o)},getScrollVariables=function(et,o){return et==="v"?getVScrollVariables(o):getHScrollVariables(o)},getDirectionFactor=function(et,o){return et==="h"&&o==="rtl"?-1:1},handleScroll=function(et,o,tt,rt,nt){var ot=getDirectionFactor(et,window.getComputedStyle(o).direction),it=ot*rt,st=tt.target,at=o.contains(st),ct=!1,lt=it>0,dt=0,ht=0;do{var mt=getScrollVariables(et,st),ft=mt[0],pt=mt[1],yt=mt[2],gt=pt-yt-ot*ft;(ft||gt)&&elementCouldBeScrolled(et,st)&&(dt+=gt,ht+=ft),st instanceof ShadowRoot?st=st.host:st=st.parentNode}while(!at&&st!==document.body||at&&(o.contains(st)||o===st));return(lt&&(Math.abs(dt)<1||!nt)||!lt&&(Math.abs(ht)<1||!nt))&&(ct=!0),ct},getTouchXY=function(et){return"changedTouches"in et?[et.changedTouches[0].clientX,et.changedTouches[0].clientY]:[0,0]},getDeltaXY=function(et){return[et.deltaX,et.deltaY]},extractRef=function(et){return et&&"current"in et?et.current:et},deltaCompare=function(et,o){return et[0]===o[0]&&et[1]===o[1]},generateStyle=function(et){return` .block-interactivity-`.concat(et,` {pointer-events: none;} .allow-interactivity-`).concat(et,` {pointer-events: all;} -`)},idCounter=0,lockStack=[];function RemoveScrollSideCar(et){var o=reactExports.useRef([]),tt=reactExports.useRef([0,0]),rt=reactExports.useRef(),nt=reactExports.useState(idCounter++)[0],ot=reactExports.useState(styleSingleton)[0],it=reactExports.useRef(et);reactExports.useEffect(function(){it.current=et},[et]),reactExports.useEffect(function(){if(et.inert){document.body.classList.add("block-interactivity-".concat(nt));var pt=__spreadArray([et.lockRef.current],(et.shards||[]).map(extractRef),!0).filter(Boolean);return pt.forEach(function(gt){return gt.classList.add("allow-interactivity-".concat(nt))}),function(){document.body.classList.remove("block-interactivity-".concat(nt)),pt.forEach(function(gt){return gt.classList.remove("allow-interactivity-".concat(nt))})}}},[et.inert,et.lockRef.current,et.shards]);var st=reactExports.useCallback(function(pt,gt){if("touches"in pt&&pt.touches.length===2||pt.type==="wheel"&&pt.ctrlKey)return!it.current.allowPinchZoom;var yt=getTouchXY(pt),bt=tt.current,xt="deltaX"in pt?pt.deltaX:bt[0]-yt[0],vt="deltaY"in pt?pt.deltaY:bt[1]-yt[1],Et,Ct=pt.target,St=Math.abs(xt)>Math.abs(vt)?"h":"v";if("touches"in pt&&St==="h"&&Ct.type==="range")return!1;var At=locationCouldBeScrolled(St,Ct);if(!At)return!0;if(At?Et=St:(Et=St==="v"?"h":"v",At=locationCouldBeScrolled(St,Ct)),!At)return!1;if(!rt.current&&"changedTouches"in pt&&(xt||vt)&&(rt.current=Et),!Et)return!0;var kt=rt.current||Et;return handleScroll(kt,gt,pt,kt==="h"?xt:vt,!0)},[]),at=reactExports.useCallback(function(pt){var gt=pt;if(!(!lockStack.length||lockStack[lockStack.length-1]!==ot)){var yt="deltaY"in gt?getDeltaXY(gt):getTouchXY(gt),bt=o.current.filter(function(Et){return Et.name===gt.type&&(Et.target===gt.target||gt.target===Et.shadowParent)&&deltaCompare(Et.delta,yt)})[0];if(bt&&bt.should){gt.cancelable&>.preventDefault();return}if(!bt){var xt=(it.current.shards||[]).map(extractRef).filter(Boolean).filter(function(Et){return Et.contains(gt.target)}),vt=xt.length>0?st(gt,xt[0]):!it.current.noIsolation;vt&>.cancelable&>.preventDefault()}}},[]),ct=reactExports.useCallback(function(pt,gt,yt,bt){var xt={name:pt,delta:gt,target:yt,should:bt,shadowParent:getOutermostShadowParent(yt)};o.current.push(xt),setTimeout(function(){o.current=o.current.filter(function(vt){return vt!==xt})},1)},[]),lt=reactExports.useCallback(function(pt){tt.current=getTouchXY(pt),rt.current=void 0},[]),dt=reactExports.useCallback(function(pt){ct(pt.type,getDeltaXY(pt),pt.target,st(pt,et.lockRef.current))},[]),ht=reactExports.useCallback(function(pt){ct(pt.type,getTouchXY(pt),pt.target,st(pt,et.lockRef.current))},[]);reactExports.useEffect(function(){return lockStack.push(ot),et.setCallbacks({onScrollCapture:dt,onWheelCapture:dt,onTouchMoveCapture:ht}),document.addEventListener("wheel",at,nonPassive),document.addEventListener("touchmove",at,nonPassive),document.addEventListener("touchstart",lt,nonPassive),function(){lockStack=lockStack.filter(function(pt){return pt!==ot}),document.removeEventListener("wheel",at,nonPassive),document.removeEventListener("touchmove",at,nonPassive),document.removeEventListener("touchstart",lt,nonPassive)}},[]);var mt=et.removeScrollBar,ft=et.inert;return reactExports.createElement(reactExports.Fragment,null,ft?reactExports.createElement(ot,{styles:generateStyle(nt)}):null,mt?reactExports.createElement(RemoveScrollBar,{gapMode:et.gapMode}):null)}function getOutermostShadowParent(et){for(var o=null;et!==null;)et instanceof ShadowRoot&&(o=et.host,et=et.host),et=et.parentNode;return o}const SideCar=exportSidecar(effectCar,RemoveScrollSideCar);var ReactRemoveScroll=reactExports.forwardRef(function(et,o){return reactExports.createElement(RemoveScroll,__assign({},et,{ref:o,sideCar:SideCar}))});ReactRemoveScroll.classNames=RemoveScroll.classNames;var getDefaultParent=function(et){if(typeof document>"u")return null;var o=Array.isArray(et)?et[0]:et;return o.ownerDocument.body},counterMap=new WeakMap,uncontrolledNodes=new WeakMap,markerMap={},lockCount=0,unwrapHost=function(et){return et&&(et.host||unwrapHost(et.parentNode))},correctTargets=function(et,o){return o.map(function(tt){if(et.contains(tt))return tt;var rt=unwrapHost(tt);return rt&&et.contains(rt)?rt:(console.error("aria-hidden",tt,"in not contained inside",et,". Doing nothing"),null)}).filter(function(tt){return!!tt})},applyAttributeToOthers=function(et,o,tt,rt){var nt=correctTargets(o,Array.isArray(et)?et:[et]);markerMap[tt]||(markerMap[tt]=new WeakMap);var ot=markerMap[tt],it=[],st=new Set,at=new Set(nt),ct=function(dt){!dt||st.has(dt)||(st.add(dt),ct(dt.parentNode))};nt.forEach(ct);var lt=function(dt){!dt||at.has(dt)||Array.prototype.forEach.call(dt.children,function(ht){if(st.has(ht))lt(ht);else try{var mt=ht.getAttribute(rt),ft=mt!==null&&mt!=="false",pt=(counterMap.get(ht)||0)+1,gt=(ot.get(ht)||0)+1;counterMap.set(ht,pt),ot.set(ht,gt),it.push(ht),pt===1&&ft&&uncontrolledNodes.set(ht,!0),gt===1&&ht.setAttribute(tt,"true"),ft||ht.setAttribute(rt,"true")}catch(yt){console.error("aria-hidden: cannot operate on ",ht,yt)}})};return lt(o),st.clear(),lockCount++,function(){it.forEach(function(dt){var ht=counterMap.get(dt)-1,mt=ot.get(dt)-1;counterMap.set(dt,ht),ot.set(dt,mt),ht||(uncontrolledNodes.has(dt)||dt.removeAttribute(rt),uncontrolledNodes.delete(dt)),mt||dt.removeAttribute(tt)}),lockCount--,lockCount||(counterMap=new WeakMap,counterMap=new WeakMap,uncontrolledNodes=new WeakMap,markerMap={})}},hideOthers=function(et,o,tt){tt===void 0&&(tt="data-aria-hidden");var rt=Array.from(Array.isArray(et)?et:[et]),nt=getDefaultParent(et);return nt?(rt.push.apply(rt,Array.from(nt.querySelectorAll("[aria-live]"))),applyAttributeToOthers(rt,nt,tt,"aria-hidden")):function(){return null}},DIALOG_NAME="Dialog",[createDialogContext,createDialogScope]=createContextScope(DIALOG_NAME),[DialogProvider,useDialogContext]=createDialogContext(DIALOG_NAME),Dialog$1=et=>{const{__scopeDialog:o,children:tt,open:rt,defaultOpen:nt,onOpenChange:ot,modal:it=!0}=et,st=reactExports.useRef(null),at=reactExports.useRef(null),[ct=!1,lt]=useControllableState({prop:rt,defaultProp:nt,onChange:ot});return jsxRuntimeExports.jsx(DialogProvider,{scope:o,triggerRef:st,contentRef:at,contentId:useId(),titleId:useId(),descriptionId:useId(),open:ct,onOpenChange:lt,onOpenToggle:reactExports.useCallback(()=>lt(dt=>!dt),[lt]),modal:it,children:tt})};Dialog$1.displayName=DIALOG_NAME;var TRIGGER_NAME="DialogTrigger",DialogTrigger$1=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(TRIGGER_NAME,tt),ot=useComposedRefs(o,nt.triggerRef);return jsxRuntimeExports.jsx(Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":nt.open,"aria-controls":nt.contentId,"data-state":getState(nt.open),...rt,ref:ot,onClick:composeEventHandlers(et.onClick,nt.onOpenToggle)})});DialogTrigger$1.displayName=TRIGGER_NAME;var PORTAL_NAME="DialogPortal",[PortalProvider,usePortalContext]=createDialogContext(PORTAL_NAME,{forceMount:void 0}),DialogPortal$1=et=>{const{__scopeDialog:o,forceMount:tt,children:rt,container:nt}=et,ot=useDialogContext(PORTAL_NAME,o);return jsxRuntimeExports.jsx(PortalProvider,{scope:o,forceMount:tt,children:reactExports.Children.map(rt,it=>jsxRuntimeExports.jsx(Presence,{present:tt||ot.open,children:jsxRuntimeExports.jsx(Portal$1,{asChild:!0,container:nt,children:it})}))})};DialogPortal$1.displayName=PORTAL_NAME;var OVERLAY_NAME="DialogOverlay",DialogOverlay$1=reactExports.forwardRef((et,o)=>{const tt=usePortalContext(OVERLAY_NAME,et.__scopeDialog),{forceMount:rt=tt.forceMount,...nt}=et,ot=useDialogContext(OVERLAY_NAME,et.__scopeDialog);return ot.modal?jsxRuntimeExports.jsx(Presence,{present:rt||ot.open,children:jsxRuntimeExports.jsx(DialogOverlayImpl,{...nt,ref:o})}):null});DialogOverlay$1.displayName=OVERLAY_NAME;var DialogOverlayImpl=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(OVERLAY_NAME,tt);return jsxRuntimeExports.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,shards:[nt.contentRef],children:jsxRuntimeExports.jsx(Primitive.div,{"data-state":getState(nt.open),...rt,ref:o,style:{pointerEvents:"auto",...rt.style}})})}),CONTENT_NAME="DialogContent",DialogContent$1=reactExports.forwardRef((et,o)=>{const tt=usePortalContext(CONTENT_NAME,et.__scopeDialog),{forceMount:rt=tt.forceMount,...nt}=et,ot=useDialogContext(CONTENT_NAME,et.__scopeDialog);return jsxRuntimeExports.jsx(Presence,{present:rt||ot.open,children:ot.modal?jsxRuntimeExports.jsx(DialogContentModal,{...nt,ref:o}):jsxRuntimeExports.jsx(DialogContentNonModal,{...nt,ref:o})})});DialogContent$1.displayName=CONTENT_NAME;var DialogContentModal=reactExports.forwardRef((et,o)=>{const tt=useDialogContext(CONTENT_NAME,et.__scopeDialog),rt=reactExports.useRef(null),nt=useComposedRefs(o,tt.contentRef,rt);return reactExports.useEffect(()=>{const ot=rt.current;if(ot)return hideOthers(ot)},[]),jsxRuntimeExports.jsx(DialogContentImpl,{...et,ref:nt,trapFocus:tt.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(et.onCloseAutoFocus,ot=>{var it;ot.preventDefault(),(it=tt.triggerRef.current)==null||it.focus()}),onPointerDownOutside:composeEventHandlers(et.onPointerDownOutside,ot=>{const it=ot.detail.originalEvent,st=it.button===0&&it.ctrlKey===!0;(it.button===2||st)&&ot.preventDefault()}),onFocusOutside:composeEventHandlers(et.onFocusOutside,ot=>ot.preventDefault())})}),DialogContentNonModal=reactExports.forwardRef((et,o)=>{const tt=useDialogContext(CONTENT_NAME,et.__scopeDialog),rt=reactExports.useRef(!1),nt=reactExports.useRef(!1);return jsxRuntimeExports.jsx(DialogContentImpl,{...et,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:ot=>{var it,st;(it=et.onCloseAutoFocus)==null||it.call(et,ot),ot.defaultPrevented||(rt.current||(st=tt.triggerRef.current)==null||st.focus(),ot.preventDefault()),rt.current=!1,nt.current=!1},onInteractOutside:ot=>{var at,ct;(at=et.onInteractOutside)==null||at.call(et,ot),ot.defaultPrevented||(rt.current=!0,ot.detail.originalEvent.type==="pointerdown"&&(nt.current=!0));const it=ot.target;((ct=tt.triggerRef.current)==null?void 0:ct.contains(it))&&ot.preventDefault(),ot.detail.originalEvent.type==="focusin"&&nt.current&&ot.preventDefault()}})}),DialogContentImpl=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,trapFocus:rt,onOpenAutoFocus:nt,onCloseAutoFocus:ot,...it}=et,st=useDialogContext(CONTENT_NAME,tt),at=reactExports.useRef(null),ct=useComposedRefs(o,at);return useFocusGuards(),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(FocusScope,{asChild:!0,loop:!0,trapped:rt,onMountAutoFocus:nt,onUnmountAutoFocus:ot,children:jsxRuntimeExports.jsx(DismissableLayer,{role:"dialog",id:st.contentId,"aria-describedby":st.descriptionId,"aria-labelledby":st.titleId,"data-state":getState(st.open),...it,ref:ct,onDismiss:()=>st.onOpenChange(!1)})}),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(TitleWarning,{titleId:st.titleId}),jsxRuntimeExports.jsx(DescriptionWarning,{contentRef:at,descriptionId:st.descriptionId})]})]})}),TITLE_NAME="DialogTitle",DialogTitle$1=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(TITLE_NAME,tt);return jsxRuntimeExports.jsx(Primitive.h2,{id:nt.titleId,...rt,ref:o})});DialogTitle$1.displayName=TITLE_NAME;var DESCRIPTION_NAME="DialogDescription",DialogDescription$1=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(DESCRIPTION_NAME,tt);return jsxRuntimeExports.jsx(Primitive.p,{id:nt.descriptionId,...rt,ref:o})});DialogDescription$1.displayName=DESCRIPTION_NAME;var CLOSE_NAME="DialogClose",DialogClose=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(CLOSE_NAME,tt);return jsxRuntimeExports.jsx(Primitive.button,{type:"button",...rt,ref:o,onClick:composeEventHandlers(et.onClick,()=>nt.onOpenChange(!1))})});DialogClose.displayName=CLOSE_NAME;function getState(et){return et?"open":"closed"}var TITLE_WARNING_NAME="DialogTitleWarning",[WarningProvider,useWarningContext]=createContext2(TITLE_WARNING_NAME,{contentName:CONTENT_NAME,titleName:TITLE_NAME,docsSlug:"dialog"}),TitleWarning=({titleId:et})=>{const o=useWarningContext(TITLE_WARNING_NAME),tt=`\`${o.contentName}\` requires a \`${o.titleName}\` for the component to be accessible for screen reader users. +`)},idCounter=0,lockStack=[];function RemoveScrollSideCar(et){var o=reactExports.useRef([]),tt=reactExports.useRef([0,0]),rt=reactExports.useRef(),nt=reactExports.useState(idCounter++)[0],ot=reactExports.useState(styleSingleton)[0],it=reactExports.useRef(et);reactExports.useEffect(function(){it.current=et},[et]),reactExports.useEffect(function(){if(et.inert){document.body.classList.add("block-interactivity-".concat(nt));var pt=__spreadArray([et.lockRef.current],(et.shards||[]).map(extractRef),!0).filter(Boolean);return pt.forEach(function(yt){return yt.classList.add("allow-interactivity-".concat(nt))}),function(){document.body.classList.remove("block-interactivity-".concat(nt)),pt.forEach(function(yt){return yt.classList.remove("allow-interactivity-".concat(nt))})}}},[et.inert,et.lockRef.current,et.shards]);var st=reactExports.useCallback(function(pt,yt){if("touches"in pt&&pt.touches.length===2||pt.type==="wheel"&&pt.ctrlKey)return!it.current.allowPinchZoom;var gt=getTouchXY(pt),bt=tt.current,xt="deltaX"in pt?pt.deltaX:bt[0]-gt[0],vt="deltaY"in pt?pt.deltaY:bt[1]-gt[1],Et,Ct=pt.target,St=Math.abs(xt)>Math.abs(vt)?"h":"v";if("touches"in pt&&St==="h"&&Ct.type==="range")return!1;var At=locationCouldBeScrolled(St,Ct);if(!At)return!0;if(At?Et=St:(Et=St==="v"?"h":"v",At=locationCouldBeScrolled(St,Ct)),!At)return!1;if(!rt.current&&"changedTouches"in pt&&(xt||vt)&&(rt.current=Et),!Et)return!0;var kt=rt.current||Et;return handleScroll(kt,yt,pt,kt==="h"?xt:vt,!0)},[]),at=reactExports.useCallback(function(pt){var yt=pt;if(!(!lockStack.length||lockStack[lockStack.length-1]!==ot)){var gt="deltaY"in yt?getDeltaXY(yt):getTouchXY(yt),bt=o.current.filter(function(Et){return Et.name===yt.type&&(Et.target===yt.target||yt.target===Et.shadowParent)&&deltaCompare(Et.delta,gt)})[0];if(bt&&bt.should){yt.cancelable&&yt.preventDefault();return}if(!bt){var xt=(it.current.shards||[]).map(extractRef).filter(Boolean).filter(function(Et){return Et.contains(yt.target)}),vt=xt.length>0?st(yt,xt[0]):!it.current.noIsolation;vt&&yt.cancelable&&yt.preventDefault()}}},[]),ct=reactExports.useCallback(function(pt,yt,gt,bt){var xt={name:pt,delta:yt,target:gt,should:bt,shadowParent:getOutermostShadowParent(gt)};o.current.push(xt),setTimeout(function(){o.current=o.current.filter(function(vt){return vt!==xt})},1)},[]),lt=reactExports.useCallback(function(pt){tt.current=getTouchXY(pt),rt.current=void 0},[]),dt=reactExports.useCallback(function(pt){ct(pt.type,getDeltaXY(pt),pt.target,st(pt,et.lockRef.current))},[]),ht=reactExports.useCallback(function(pt){ct(pt.type,getTouchXY(pt),pt.target,st(pt,et.lockRef.current))},[]);reactExports.useEffect(function(){return lockStack.push(ot),et.setCallbacks({onScrollCapture:dt,onWheelCapture:dt,onTouchMoveCapture:ht}),document.addEventListener("wheel",at,nonPassive),document.addEventListener("touchmove",at,nonPassive),document.addEventListener("touchstart",lt,nonPassive),function(){lockStack=lockStack.filter(function(pt){return pt!==ot}),document.removeEventListener("wheel",at,nonPassive),document.removeEventListener("touchmove",at,nonPassive),document.removeEventListener("touchstart",lt,nonPassive)}},[]);var mt=et.removeScrollBar,ft=et.inert;return reactExports.createElement(reactExports.Fragment,null,ft?reactExports.createElement(ot,{styles:generateStyle(nt)}):null,mt?reactExports.createElement(RemoveScrollBar,{gapMode:et.gapMode}):null)}function getOutermostShadowParent(et){for(var o=null;et!==null;)et instanceof ShadowRoot&&(o=et.host,et=et.host),et=et.parentNode;return o}const SideCar=exportSidecar(effectCar,RemoveScrollSideCar);var ReactRemoveScroll=reactExports.forwardRef(function(et,o){return reactExports.createElement(RemoveScroll,__assign({},et,{ref:o,sideCar:SideCar}))});ReactRemoveScroll.classNames=RemoveScroll.classNames;var getDefaultParent=function(et){if(typeof document>"u")return null;var o=Array.isArray(et)?et[0]:et;return o.ownerDocument.body},counterMap=new WeakMap,uncontrolledNodes=new WeakMap,markerMap={},lockCount=0,unwrapHost=function(et){return et&&(et.host||unwrapHost(et.parentNode))},correctTargets=function(et,o){return o.map(function(tt){if(et.contains(tt))return tt;var rt=unwrapHost(tt);return rt&&et.contains(rt)?rt:(console.error("aria-hidden",tt,"in not contained inside",et,". Doing nothing"),null)}).filter(function(tt){return!!tt})},applyAttributeToOthers=function(et,o,tt,rt){var nt=correctTargets(o,Array.isArray(et)?et:[et]);markerMap[tt]||(markerMap[tt]=new WeakMap);var ot=markerMap[tt],it=[],st=new Set,at=new Set(nt),ct=function(dt){!dt||st.has(dt)||(st.add(dt),ct(dt.parentNode))};nt.forEach(ct);var lt=function(dt){!dt||at.has(dt)||Array.prototype.forEach.call(dt.children,function(ht){if(st.has(ht))lt(ht);else try{var mt=ht.getAttribute(rt),ft=mt!==null&&mt!=="false",pt=(counterMap.get(ht)||0)+1,yt=(ot.get(ht)||0)+1;counterMap.set(ht,pt),ot.set(ht,yt),it.push(ht),pt===1&&ft&&uncontrolledNodes.set(ht,!0),yt===1&&ht.setAttribute(tt,"true"),ft||ht.setAttribute(rt,"true")}catch(gt){console.error("aria-hidden: cannot operate on ",ht,gt)}})};return lt(o),st.clear(),lockCount++,function(){it.forEach(function(dt){var ht=counterMap.get(dt)-1,mt=ot.get(dt)-1;counterMap.set(dt,ht),ot.set(dt,mt),ht||(uncontrolledNodes.has(dt)||dt.removeAttribute(rt),uncontrolledNodes.delete(dt)),mt||dt.removeAttribute(tt)}),lockCount--,lockCount||(counterMap=new WeakMap,counterMap=new WeakMap,uncontrolledNodes=new WeakMap,markerMap={})}},hideOthers=function(et,o,tt){tt===void 0&&(tt="data-aria-hidden");var rt=Array.from(Array.isArray(et)?et:[et]),nt=getDefaultParent(et);return nt?(rt.push.apply(rt,Array.from(nt.querySelectorAll("[aria-live]"))),applyAttributeToOthers(rt,nt,tt,"aria-hidden")):function(){return null}},DIALOG_NAME="Dialog",[createDialogContext,createDialogScope]=createContextScope(DIALOG_NAME),[DialogProvider,useDialogContext]=createDialogContext(DIALOG_NAME),Dialog$1=et=>{const{__scopeDialog:o,children:tt,open:rt,defaultOpen:nt,onOpenChange:ot,modal:it=!0}=et,st=reactExports.useRef(null),at=reactExports.useRef(null),[ct=!1,lt]=useControllableState({prop:rt,defaultProp:nt,onChange:ot});return jsxRuntimeExports.jsx(DialogProvider,{scope:o,triggerRef:st,contentRef:at,contentId:useId(),titleId:useId(),descriptionId:useId(),open:ct,onOpenChange:lt,onOpenToggle:reactExports.useCallback(()=>lt(dt=>!dt),[lt]),modal:it,children:tt})};Dialog$1.displayName=DIALOG_NAME;var TRIGGER_NAME="DialogTrigger",DialogTrigger$1=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(TRIGGER_NAME,tt),ot=useComposedRefs(o,nt.triggerRef);return jsxRuntimeExports.jsx(Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":nt.open,"aria-controls":nt.contentId,"data-state":getState(nt.open),...rt,ref:ot,onClick:composeEventHandlers(et.onClick,nt.onOpenToggle)})});DialogTrigger$1.displayName=TRIGGER_NAME;var PORTAL_NAME="DialogPortal",[PortalProvider,usePortalContext]=createDialogContext(PORTAL_NAME,{forceMount:void 0}),DialogPortal$1=et=>{const{__scopeDialog:o,forceMount:tt,children:rt,container:nt}=et,ot=useDialogContext(PORTAL_NAME,o);return jsxRuntimeExports.jsx(PortalProvider,{scope:o,forceMount:tt,children:reactExports.Children.map(rt,it=>jsxRuntimeExports.jsx(Presence,{present:tt||ot.open,children:jsxRuntimeExports.jsx(Portal$1,{asChild:!0,container:nt,children:it})}))})};DialogPortal$1.displayName=PORTAL_NAME;var OVERLAY_NAME="DialogOverlay",DialogOverlay$1=reactExports.forwardRef((et,o)=>{const tt=usePortalContext(OVERLAY_NAME,et.__scopeDialog),{forceMount:rt=tt.forceMount,...nt}=et,ot=useDialogContext(OVERLAY_NAME,et.__scopeDialog);return ot.modal?jsxRuntimeExports.jsx(Presence,{present:rt||ot.open,children:jsxRuntimeExports.jsx(DialogOverlayImpl,{...nt,ref:o})}):null});DialogOverlay$1.displayName=OVERLAY_NAME;var DialogOverlayImpl=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(OVERLAY_NAME,tt);return jsxRuntimeExports.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,shards:[nt.contentRef],children:jsxRuntimeExports.jsx(Primitive.div,{"data-state":getState(nt.open),...rt,ref:o,style:{pointerEvents:"auto",...rt.style}})})}),CONTENT_NAME="DialogContent",DialogContent$1=reactExports.forwardRef((et,o)=>{const tt=usePortalContext(CONTENT_NAME,et.__scopeDialog),{forceMount:rt=tt.forceMount,...nt}=et,ot=useDialogContext(CONTENT_NAME,et.__scopeDialog);return jsxRuntimeExports.jsx(Presence,{present:rt||ot.open,children:ot.modal?jsxRuntimeExports.jsx(DialogContentModal,{...nt,ref:o}):jsxRuntimeExports.jsx(DialogContentNonModal,{...nt,ref:o})})});DialogContent$1.displayName=CONTENT_NAME;var DialogContentModal=reactExports.forwardRef((et,o)=>{const tt=useDialogContext(CONTENT_NAME,et.__scopeDialog),rt=reactExports.useRef(null),nt=useComposedRefs(o,tt.contentRef,rt);return reactExports.useEffect(()=>{const ot=rt.current;if(ot)return hideOthers(ot)},[]),jsxRuntimeExports.jsx(DialogContentImpl,{...et,ref:nt,trapFocus:tt.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(et.onCloseAutoFocus,ot=>{var it;ot.preventDefault(),(it=tt.triggerRef.current)==null||it.focus()}),onPointerDownOutside:composeEventHandlers(et.onPointerDownOutside,ot=>{const it=ot.detail.originalEvent,st=it.button===0&&it.ctrlKey===!0;(it.button===2||st)&&ot.preventDefault()}),onFocusOutside:composeEventHandlers(et.onFocusOutside,ot=>ot.preventDefault())})}),DialogContentNonModal=reactExports.forwardRef((et,o)=>{const tt=useDialogContext(CONTENT_NAME,et.__scopeDialog),rt=reactExports.useRef(!1),nt=reactExports.useRef(!1);return jsxRuntimeExports.jsx(DialogContentImpl,{...et,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:ot=>{var it,st;(it=et.onCloseAutoFocus)==null||it.call(et,ot),ot.defaultPrevented||(rt.current||(st=tt.triggerRef.current)==null||st.focus(),ot.preventDefault()),rt.current=!1,nt.current=!1},onInteractOutside:ot=>{var at,ct;(at=et.onInteractOutside)==null||at.call(et,ot),ot.defaultPrevented||(rt.current=!0,ot.detail.originalEvent.type==="pointerdown"&&(nt.current=!0));const it=ot.target;((ct=tt.triggerRef.current)==null?void 0:ct.contains(it))&&ot.preventDefault(),ot.detail.originalEvent.type==="focusin"&&nt.current&&ot.preventDefault()}})}),DialogContentImpl=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,trapFocus:rt,onOpenAutoFocus:nt,onCloseAutoFocus:ot,...it}=et,st=useDialogContext(CONTENT_NAME,tt),at=reactExports.useRef(null),ct=useComposedRefs(o,at);return useFocusGuards(),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(FocusScope,{asChild:!0,loop:!0,trapped:rt,onMountAutoFocus:nt,onUnmountAutoFocus:ot,children:jsxRuntimeExports.jsx(DismissableLayer,{role:"dialog",id:st.contentId,"aria-describedby":st.descriptionId,"aria-labelledby":st.titleId,"data-state":getState(st.open),...it,ref:ct,onDismiss:()=>st.onOpenChange(!1)})}),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(TitleWarning,{titleId:st.titleId}),jsxRuntimeExports.jsx(DescriptionWarning,{contentRef:at,descriptionId:st.descriptionId})]})]})}),TITLE_NAME="DialogTitle",DialogTitle$1=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(TITLE_NAME,tt);return jsxRuntimeExports.jsx(Primitive.h2,{id:nt.titleId,...rt,ref:o})});DialogTitle$1.displayName=TITLE_NAME;var DESCRIPTION_NAME="DialogDescription",DialogDescription$1=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(DESCRIPTION_NAME,tt);return jsxRuntimeExports.jsx(Primitive.p,{id:nt.descriptionId,...rt,ref:o})});DialogDescription$1.displayName=DESCRIPTION_NAME;var CLOSE_NAME="DialogClose",DialogClose=reactExports.forwardRef((et,o)=>{const{__scopeDialog:tt,...rt}=et,nt=useDialogContext(CLOSE_NAME,tt);return jsxRuntimeExports.jsx(Primitive.button,{type:"button",...rt,ref:o,onClick:composeEventHandlers(et.onClick,()=>nt.onOpenChange(!1))})});DialogClose.displayName=CLOSE_NAME;function getState(et){return et?"open":"closed"}var TITLE_WARNING_NAME="DialogTitleWarning",[WarningProvider,useWarningContext]=createContext2(TITLE_WARNING_NAME,{contentName:CONTENT_NAME,titleName:TITLE_NAME,docsSlug:"dialog"}),TitleWarning=({titleId:et})=>{const o=useWarningContext(TITLE_WARNING_NAME),tt=`\`${o.contentName}\` requires a \`${o.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${o.titleName}\`, you can wrap it with our VisuallyHidden component. @@ -4130,33 +4130,33 @@ For more information, see https://radix-ui.com/primitives/docs/components/${o.do * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT - */var qrcodegen;(et=>{const o=class Er{constructor(at,ct,lt,dt){if(this.version=at,this.errorCorrectionLevel=ct,this.modules=[],this.isFunction=[],atEr.MAX_VERSION)throw new RangeError("Version value out of range");if(dt<-1||dt>7)throw new RangeError("Mask value out of range");this.size=at*4+17;let ht=[];for(let ft=0;ft7)throw new RangeError("Invalid value");let ft,pt;for(ft=lt;;ft++){const xt=Er.getNumDataCodewords(ft,ct)*8,vt=it.getTotalBits(at,ft);if(vt<=xt){pt=vt;break}if(ft>=dt)throw new RangeError("Data too long")}for(const xt of[Er.Ecc.MEDIUM,Er.Ecc.QUARTILE,Er.Ecc.HIGH])mt&&pt<=Er.getNumDataCodewords(ft,xt)*8&&(ct=xt);let gt=[];for(const xt of at){tt(xt.mode.modeBits,4,gt),tt(xt.numChars,xt.mode.numCharCountBits(ft),gt);for(const vt of xt.getData())gt.push(vt)}nt(gt.length==pt);const yt=Er.getNumDataCodewords(ft,ct)*8;nt(gt.length<=yt),tt(0,Math.min(4,yt-gt.length),gt),tt(0,(8-gt.length%8)%8,gt),nt(gt.length%8==0);for(let xt=236;gt.lengthbt[vt>>>3]|=xt<<7-(vt&7)),new Er(ft,ct,bt,ht)}getModule(at,ct){return 0<=at&&at>>9)*1335;const dt=(ct<<10|lt)^21522;nt(dt>>>15==0);for(let ht=0;ht<=5;ht++)this.setFunctionModule(8,ht,rt(dt,ht));this.setFunctionModule(8,7,rt(dt,6)),this.setFunctionModule(8,8,rt(dt,7)),this.setFunctionModule(7,8,rt(dt,8));for(let ht=9;ht<15;ht++)this.setFunctionModule(14-ht,8,rt(dt,ht));for(let ht=0;ht<8;ht++)this.setFunctionModule(this.size-1-ht,8,rt(dt,ht));for(let ht=8;ht<15;ht++)this.setFunctionModule(8,this.size-15+ht,rt(dt,ht));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let at=this.version;for(let lt=0;lt<12;lt++)at=at<<1^(at>>>11)*7973;const ct=this.version<<12|at;nt(ct>>>18==0);for(let lt=0;lt<18;lt++){const dt=rt(ct,lt),ht=this.size-11+lt%3,mt=Math.floor(lt/3);this.setFunctionModule(ht,mt,dt),this.setFunctionModule(mt,ht,dt)}}drawFinderPattern(at,ct){for(let lt=-4;lt<=4;lt++)for(let dt=-4;dt<=4;dt++){const ht=Math.max(Math.abs(dt),Math.abs(lt)),mt=at+dt,ft=ct+lt;0<=mt&&mt{(xt!=pt-ht||Et>=ft)&&bt.push(vt[xt])});return nt(bt.length==mt),bt}drawCodewords(at){if(at.length!=Math.floor(Er.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let ct=0;for(let lt=this.size-1;lt>=1;lt-=2){lt==6&&(lt=5);for(let dt=0;dt>>3],7-(ct&7)),ct++)}}nt(ct==at.length*8)}applyMask(at){if(at<0||at>7)throw new RangeError("Mask value out of range");for(let ct=0;ct5&&at++):(this.finderPenaltyAddHistory(ft,pt),mt||(at+=this.finderPenaltyCountPatterns(pt)*Er.PENALTY_N3),mt=this.modules[ht][gt],ft=1);at+=this.finderPenaltyTerminateAndCount(mt,ft,pt)*Er.PENALTY_N3}for(let ht=0;ht5&&at++):(this.finderPenaltyAddHistory(ft,pt),mt||(at+=this.finderPenaltyCountPatterns(pt)*Er.PENALTY_N3),mt=this.modules[gt][ht],ft=1);at+=this.finderPenaltyTerminateAndCount(mt,ft,pt)*Er.PENALTY_N3}for(let ht=0;htmt+(ft?1:0),ct);const lt=this.size*this.size,dt=Math.ceil(Math.abs(ct*20-lt*10)/lt)-1;return nt(0<=dt&&dt<=9),at+=dt*Er.PENALTY_N4,nt(0<=at&&at<=2568888),at}getAlignmentPatternPositions(){if(this.version==1)return[];{const at=Math.floor(this.version/7)+2,ct=this.version==32?26:Math.ceil((this.version*4+4)/(at*2-2))*2;let lt=[6];for(let dt=this.size-7;lt.lengthEr.MAX_VERSION)throw new RangeError("Version number out of range");let ct=(16*at+128)*at+64;if(at>=2){const lt=Math.floor(at/7)+2;ct-=(25*lt-10)*lt-55,at>=7&&(ct-=36)}return nt(208<=ct&&ct<=29648),ct}static getNumDataCodewords(at,ct){return Math.floor(Er.getNumRawDataModules(at)/8)-Er.ECC_CODEWORDS_PER_BLOCK[ct.ordinal][at]*Er.NUM_ERROR_CORRECTION_BLOCKS[ct.ordinal][at]}static reedSolomonComputeDivisor(at){if(at<1||at>255)throw new RangeError("Degree out of range");let ct=[];for(let dt=0;dt0);for(const dt of at){const ht=dt^lt.shift();lt.push(0),ct.forEach((mt,ft)=>lt[ft]^=Er.reedSolomonMultiply(mt,ht))}return lt}static reedSolomonMultiply(at,ct){if(at>>>8||ct>>>8)throw new RangeError("Byte out of range");let lt=0;for(let dt=7;dt>=0;dt--)lt=lt<<1^(lt>>>7)*285,lt^=(ct>>>dt&1)*at;return nt(lt>>>8==0),lt}finderPenaltyCountPatterns(at){const ct=at[1];nt(ct<=this.size*3);const lt=ct>0&&at[2]==ct&&at[3]==ct*3&&at[4]==ct&&at[5]==ct;return(lt&&at[0]>=ct*4&&at[6]>=ct?1:0)+(lt&&at[6]>=ct*4&&at[0]>=ct?1:0)}finderPenaltyTerminateAndCount(at,ct,lt){return at&&(this.finderPenaltyAddHistory(ct,lt),ct=0),ct+=this.size,this.finderPenaltyAddHistory(ct,lt),this.finderPenaltyCountPatterns(lt)}finderPenaltyAddHistory(at,ct){ct[0]==0&&(at+=this.size),ct.pop(),ct.unshift(at)}};o.MIN_VERSION=1,o.MAX_VERSION=40,o.PENALTY_N1=3,o.PENALTY_N2=3,o.PENALTY_N3=40,o.PENALTY_N4=10,o.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],o.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],et.QrCode=o;function tt(st,at,ct){if(at<0||at>31||st>>>at)throw new RangeError("Value out of range");for(let lt=at-1;lt>=0;lt--)ct.push(st>>>lt&1)}function rt(st,at){return(st>>>at&1)!=0}function nt(st){if(!st)throw new Error("Assertion error")}const ot=class Tr{constructor(at,ct,lt){if(this.mode=at,this.numChars=ct,this.bitData=lt,ct<0)throw new RangeError("Invalid argument");this.bitData=lt.slice()}static makeBytes(at){let ct=[];for(const lt of at)tt(lt,8,ct);return new Tr(Tr.Mode.BYTE,at.length,ct)}static makeNumeric(at){if(!Tr.isNumeric(at))throw new RangeError("String contains non-numeric characters");let ct=[];for(let lt=0;lt=1<{(o=>{const tt=class{constructor(nt,ot){this.ordinal=nt,this.formatBits=ot}};tt.LOW=new tt(0,1),tt.MEDIUM=new tt(1,0),tt.QUARTILE=new tt(2,3),tt.HIGH=new tt(3,2),o.Ecc=tt})(et.QrCode||(et.QrCode={}))})(qrcodegen||(qrcodegen={}));(et=>{(o=>{const tt=class{constructor(nt,ot){this.modeBits=nt,this.numBitsCharCount=ot}numCharCountBits(nt){return this.numBitsCharCount[Math.floor((nt+7)/17)]}};tt.NUMERIC=new tt(1,[10,12,14]),tt.ALPHANUMERIC=new tt(2,[9,11,13]),tt.BYTE=new tt(4,[8,16,16]),tt.KANJI=new tt(8,[8,10,12]),tt.ECI=new tt(7,[0,0,0]),o.Mode=tt})(et.QrSegment||(et.QrSegment={}))})(qrcodegen||(qrcodegen={}));var qrcodegen_default=qrcodegen;/** + */var qrcodegen;(et=>{const o=class Er{constructor(at,ct,lt,dt){if(this.version=at,this.errorCorrectionLevel=ct,this.modules=[],this.isFunction=[],atEr.MAX_VERSION)throw new RangeError("Version value out of range");if(dt<-1||dt>7)throw new RangeError("Mask value out of range");this.size=at*4+17;let ht=[];for(let ft=0;ft7)throw new RangeError("Invalid value");let ft,pt;for(ft=lt;;ft++){const xt=Er.getNumDataCodewords(ft,ct)*8,vt=it.getTotalBits(at,ft);if(vt<=xt){pt=vt;break}if(ft>=dt)throw new RangeError("Data too long")}for(const xt of[Er.Ecc.MEDIUM,Er.Ecc.QUARTILE,Er.Ecc.HIGH])mt&&pt<=Er.getNumDataCodewords(ft,xt)*8&&(ct=xt);let yt=[];for(const xt of at){tt(xt.mode.modeBits,4,yt),tt(xt.numChars,xt.mode.numCharCountBits(ft),yt);for(const vt of xt.getData())yt.push(vt)}nt(yt.length==pt);const gt=Er.getNumDataCodewords(ft,ct)*8;nt(yt.length<=gt),tt(0,Math.min(4,gt-yt.length),yt),tt(0,(8-yt.length%8)%8,yt),nt(yt.length%8==0);for(let xt=236;yt.lengthbt[vt>>>3]|=xt<<7-(vt&7)),new Er(ft,ct,bt,ht)}getModule(at,ct){return 0<=at&&at>>9)*1335;const dt=(ct<<10|lt)^21522;nt(dt>>>15==0);for(let ht=0;ht<=5;ht++)this.setFunctionModule(8,ht,rt(dt,ht));this.setFunctionModule(8,7,rt(dt,6)),this.setFunctionModule(8,8,rt(dt,7)),this.setFunctionModule(7,8,rt(dt,8));for(let ht=9;ht<15;ht++)this.setFunctionModule(14-ht,8,rt(dt,ht));for(let ht=0;ht<8;ht++)this.setFunctionModule(this.size-1-ht,8,rt(dt,ht));for(let ht=8;ht<15;ht++)this.setFunctionModule(8,this.size-15+ht,rt(dt,ht));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let at=this.version;for(let lt=0;lt<12;lt++)at=at<<1^(at>>>11)*7973;const ct=this.version<<12|at;nt(ct>>>18==0);for(let lt=0;lt<18;lt++){const dt=rt(ct,lt),ht=this.size-11+lt%3,mt=Math.floor(lt/3);this.setFunctionModule(ht,mt,dt),this.setFunctionModule(mt,ht,dt)}}drawFinderPattern(at,ct){for(let lt=-4;lt<=4;lt++)for(let dt=-4;dt<=4;dt++){const ht=Math.max(Math.abs(dt),Math.abs(lt)),mt=at+dt,ft=ct+lt;0<=mt&&mt{(xt!=pt-ht||Et>=ft)&&bt.push(vt[xt])});return nt(bt.length==mt),bt}drawCodewords(at){if(at.length!=Math.floor(Er.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let ct=0;for(let lt=this.size-1;lt>=1;lt-=2){lt==6&&(lt=5);for(let dt=0;dt>>3],7-(ct&7)),ct++)}}nt(ct==at.length*8)}applyMask(at){if(at<0||at>7)throw new RangeError("Mask value out of range");for(let ct=0;ct5&&at++):(this.finderPenaltyAddHistory(ft,pt),mt||(at+=this.finderPenaltyCountPatterns(pt)*Er.PENALTY_N3),mt=this.modules[ht][yt],ft=1);at+=this.finderPenaltyTerminateAndCount(mt,ft,pt)*Er.PENALTY_N3}for(let ht=0;ht5&&at++):(this.finderPenaltyAddHistory(ft,pt),mt||(at+=this.finderPenaltyCountPatterns(pt)*Er.PENALTY_N3),mt=this.modules[yt][ht],ft=1);at+=this.finderPenaltyTerminateAndCount(mt,ft,pt)*Er.PENALTY_N3}for(let ht=0;htmt+(ft?1:0),ct);const lt=this.size*this.size,dt=Math.ceil(Math.abs(ct*20-lt*10)/lt)-1;return nt(0<=dt&&dt<=9),at+=dt*Er.PENALTY_N4,nt(0<=at&&at<=2568888),at}getAlignmentPatternPositions(){if(this.version==1)return[];{const at=Math.floor(this.version/7)+2,ct=this.version==32?26:Math.ceil((this.version*4+4)/(at*2-2))*2;let lt=[6];for(let dt=this.size-7;lt.lengthEr.MAX_VERSION)throw new RangeError("Version number out of range");let ct=(16*at+128)*at+64;if(at>=2){const lt=Math.floor(at/7)+2;ct-=(25*lt-10)*lt-55,at>=7&&(ct-=36)}return nt(208<=ct&&ct<=29648),ct}static getNumDataCodewords(at,ct){return Math.floor(Er.getNumRawDataModules(at)/8)-Er.ECC_CODEWORDS_PER_BLOCK[ct.ordinal][at]*Er.NUM_ERROR_CORRECTION_BLOCKS[ct.ordinal][at]}static reedSolomonComputeDivisor(at){if(at<1||at>255)throw new RangeError("Degree out of range");let ct=[];for(let dt=0;dt0);for(const dt of at){const ht=dt^lt.shift();lt.push(0),ct.forEach((mt,ft)=>lt[ft]^=Er.reedSolomonMultiply(mt,ht))}return lt}static reedSolomonMultiply(at,ct){if(at>>>8||ct>>>8)throw new RangeError("Byte out of range");let lt=0;for(let dt=7;dt>=0;dt--)lt=lt<<1^(lt>>>7)*285,lt^=(ct>>>dt&1)*at;return nt(lt>>>8==0),lt}finderPenaltyCountPatterns(at){const ct=at[1];nt(ct<=this.size*3);const lt=ct>0&&at[2]==ct&&at[3]==ct*3&&at[4]==ct&&at[5]==ct;return(lt&&at[0]>=ct*4&&at[6]>=ct?1:0)+(lt&&at[6]>=ct*4&&at[0]>=ct?1:0)}finderPenaltyTerminateAndCount(at,ct,lt){return at&&(this.finderPenaltyAddHistory(ct,lt),ct=0),ct+=this.size,this.finderPenaltyAddHistory(ct,lt),this.finderPenaltyCountPatterns(lt)}finderPenaltyAddHistory(at,ct){ct[0]==0&&(at+=this.size),ct.pop(),ct.unshift(at)}};o.MIN_VERSION=1,o.MAX_VERSION=40,o.PENALTY_N1=3,o.PENALTY_N2=3,o.PENALTY_N3=40,o.PENALTY_N4=10,o.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],o.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],et.QrCode=o;function tt(st,at,ct){if(at<0||at>31||st>>>at)throw new RangeError("Value out of range");for(let lt=at-1;lt>=0;lt--)ct.push(st>>>lt&1)}function rt(st,at){return(st>>>at&1)!=0}function nt(st){if(!st)throw new Error("Assertion error")}const ot=class Ir{constructor(at,ct,lt){if(this.mode=at,this.numChars=ct,this.bitData=lt,ct<0)throw new RangeError("Invalid argument");this.bitData=lt.slice()}static makeBytes(at){let ct=[];for(const lt of at)tt(lt,8,ct);return new Ir(Ir.Mode.BYTE,at.length,ct)}static makeNumeric(at){if(!Ir.isNumeric(at))throw new RangeError("String contains non-numeric characters");let ct=[];for(let lt=0;lt=1<{(o=>{const tt=class{constructor(nt,ot){this.ordinal=nt,this.formatBits=ot}};tt.LOW=new tt(0,1),tt.MEDIUM=new tt(1,0),tt.QUARTILE=new tt(2,3),tt.HIGH=new tt(3,2),o.Ecc=tt})(et.QrCode||(et.QrCode={}))})(qrcodegen||(qrcodegen={}));(et=>{(o=>{const tt=class{constructor(nt,ot){this.modeBits=nt,this.numBitsCharCount=ot}numCharCountBits(nt){return this.numBitsCharCount[Math.floor((nt+7)/17)]}};tt.NUMERIC=new tt(1,[10,12,14]),tt.ALPHANUMERIC=new tt(2,[9,11,13]),tt.BYTE=new tt(4,[8,16,16]),tt.KANJI=new tt(8,[8,10,12]),tt.ECI=new tt(7,[0,0,0]),o.Mode=tt})(et.QrSegment||(et.QrSegment={}))})(qrcodegen||(qrcodegen={}));var qrcodegen_default=qrcodegen;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC - */var ERROR_LEVEL_MAP={L:qrcodegen_default.QrCode.Ecc.LOW,M:qrcodegen_default.QrCode.Ecc.MEDIUM,Q:qrcodegen_default.QrCode.Ecc.QUARTILE,H:qrcodegen_default.QrCode.Ecc.HIGH},DEFAULT_SIZE=128,DEFAULT_LEVEL="L",DEFAULT_BGCOLOR="#FFFFFF",DEFAULT_FGCOLOR="#000000",DEFAULT_INCLUDEMARGIN=!1,DEFAULT_MINVERSION=1,SPEC_MARGIN_SIZE=4,DEFAULT_MARGIN_SIZE=0,DEFAULT_IMG_SCALE=.1;function generatePath(et,o=0){const tt=[];return et.forEach(function(rt,nt){let ot=null;rt.forEach(function(it,st){if(!it&&ot!==null){tt.push(`M${ot+o} ${nt+o}h${st-ot}v1H${ot+o}z`),ot=null;return}if(st===rt.length-1){if(!it)return;ot===null?tt.push(`M${st+o},${nt+o} h1v1H${st+o}z`):tt.push(`M${ot+o},${nt+o} h${st+1-ot}v1H${ot+o}z`);return}it&&ot===null&&(ot=st)})}),tt.join("")}function excavateModules(et,o){return et.slice().map((tt,rt)=>rt=o.y+o.h?tt:tt.map((nt,ot)=>ot=o.x+o.w?nt:!1))}function getImageSettings(et,o,tt,rt){if(rt==null)return null;const nt=et.length+tt*2,ot=Math.floor(o*DEFAULT_IMG_SCALE),it=nt/o,st=(rt.width||ot)*it,at=(rt.height||ot)*it,ct=rt.x==null?et.length/2-st/2:rt.x*it,lt=rt.y==null?et.length/2-at/2:rt.y*it,dt=rt.opacity==null?1:rt.opacity;let ht=null;if(rt.excavate){let ft=Math.floor(ct),pt=Math.floor(lt),gt=Math.ceil(st+ct-ft),yt=Math.ceil(at+lt-pt);ht={x:ft,y:pt,w:gt,h:yt}}const mt=rt.crossOrigin;return{x:ct,y:lt,h:at,w:st,excavation:ht,opacity:dt,crossOrigin:mt}}function getMarginSize(et,o){return o!=null?Math.max(Math.floor(o),0):et?SPEC_MARGIN_SIZE:DEFAULT_MARGIN_SIZE}function useQRCode({value:et,level:o,minVersion:tt,includeMargin:rt,marginSize:nt,imageSettings:ot,size:it}){let st=React.useMemo(()=>{const ht=qrcodegen_default.QrSegment.makeSegments(et);return qrcodegen_default.QrCode.encodeSegments(ht,ERROR_LEVEL_MAP[o],tt)},[et,o,tt]);const{cells:at,margin:ct,numCells:lt,calculatedImageSettings:dt}=React.useMemo(()=>{let ht=st.getModules();const mt=getMarginSize(rt,nt),ft=ht.length+mt*2,pt=getImageSettings(ht,it,mt,ot);return{cells:ht,margin:mt,numCells:ft,calculatedImageSettings:pt}},[st,it,ot,rt,nt]);return{qrcode:st,margin:ct,cells:at,numCells:lt,calculatedImageSettings:dt}}var SUPPORTS_PATH2D=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),QRCodeCanvas=React.forwardRef(function(o,tt){const rt=o,{value:nt,size:ot=DEFAULT_SIZE,level:it=DEFAULT_LEVEL,bgColor:st=DEFAULT_BGCOLOR,fgColor:at=DEFAULT_FGCOLOR,includeMargin:ct=DEFAULT_INCLUDEMARGIN,minVersion:lt=DEFAULT_MINVERSION,marginSize:dt,imageSettings:ht}=rt,ft=__objRest(rt,["value","size","level","bgColor","fgColor","includeMargin","minVersion","marginSize","imageSettings"]),{style:pt}=ft,gt=__objRest(ft,["style"]),yt=ht==null?void 0:ht.src,bt=React.useRef(null),xt=React.useRef(null),vt=React.useCallback(Yt=>{bt.current=Yt,typeof tt=="function"?tt(Yt):tt&&(tt.current=Yt)},[tt]),[Et,Ct]=React.useState(!1),{margin:St,cells:At,numCells:kt,calculatedImageSettings:It}=useQRCode({value:nt,level:it,minVersion:lt,includeMargin:ct,marginSize:dt,imageSettings:ht,size:ot});React.useEffect(()=>{if(bt.current!=null){const Yt=bt.current,Ft=Yt.getContext("2d");if(!Ft)return;let Ht=At;const Qt=xt.current,Vt=It!=null&&Qt!==null&&Qt.complete&&Qt.naturalHeight!==0&&Qt.naturalWidth!==0;Vt&&It.excavation!=null&&(Ht=excavateModules(At,It.excavation));const Bt=window.devicePixelRatio||1;Yt.height=Yt.width=ot*Bt;const Wt=ot/kt*Bt;Ft.scale(Wt,Wt),Ft.fillStyle=st,Ft.fillRect(0,0,kt,kt),Ft.fillStyle=at,SUPPORTS_PATH2D?Ft.fill(new Path2D(generatePath(Ht,St))):At.forEach(function(jt,Xt){jt.forEach(function(Kt,Pt){Kt&&Ft.fillRect(Pt+St,Xt+St,1,1)})}),It&&(Ft.globalAlpha=It.opacity),Vt&&Ft.drawImage(Qt,It.x+St,It.y+St,It.w,It.h)}}),React.useEffect(()=>{Ct(!1)},[yt]);const Ot=__spreadValues({height:ot,width:ot},pt);let Nt=null;return yt!=null&&(Nt=React.createElement("img",{src:yt,key:yt,style:{display:"none"},onLoad:()=>{Ct(!0)},ref:xt,crossOrigin:It==null?void 0:It.crossOrigin})),React.createElement(React.Fragment,null,React.createElement("canvas",__spreadValues({style:Ot,height:ot,width:ot,ref:vt,role:"img"},gt)),Nt)});QRCodeCanvas.displayName="QRCodeCanvas";var QRCodeSVG=React.forwardRef(function(o,tt){const rt=o,{value:nt,size:ot=DEFAULT_SIZE,level:it=DEFAULT_LEVEL,bgColor:st=DEFAULT_BGCOLOR,fgColor:at=DEFAULT_FGCOLOR,includeMargin:ct=DEFAULT_INCLUDEMARGIN,minVersion:lt=DEFAULT_MINVERSION,title:dt,marginSize:ht,imageSettings:mt}=rt,ft=__objRest(rt,["value","size","level","bgColor","fgColor","includeMargin","minVersion","title","marginSize","imageSettings"]),{margin:pt,cells:gt,numCells:yt,calculatedImageSettings:bt}=useQRCode({value:nt,level:it,minVersion:lt,includeMargin:ct,marginSize:ht,imageSettings:mt,size:ot});let xt=gt,vt=null;mt!=null&&bt!=null&&(bt.excavation!=null&&(xt=excavateModules(gt,bt.excavation)),vt=React.createElement("image",{href:mt.src,height:bt.h,width:bt.w,x:bt.x+pt,y:bt.y+pt,preserveAspectRatio:"none",opacity:bt.opacity,crossOrigin:bt.crossOrigin}));const Et=generatePath(xt,pt);return React.createElement("svg",__spreadValues({height:ot,width:ot,viewBox:`0 0 ${yt} ${yt}`,ref:tt,role:"img"},ft),!!dt&&React.createElement("title",null,dt),React.createElement("path",{fill:st,d:`M0,0 h${yt}v${yt}H0z`,shapeRendering:"crispEdges"}),React.createElement("path",{fill:at,d:Et,shapeRendering:"crispEdges"}),vt)});QRCodeSVG.displayName="QRCodeSVG";const QRCode=({text:et,width:o=256,height:tt=256})=>{const[rt,nt]=reactExports.useState(!1),ot=async()=>{await navigator.clipboard.writeText(et),nt(!0),setTimeout(()=>nt(!1),2e3)};return jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[jsxRuntimeExports.jsx(QRCodeSVG,{value:et,size:Math.min(o,tt)}),jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntimeExports.jsx("input",{type:"text",value:et,readOnly:!0,className:"flex-1 px-3 py-2 text-sm border rounded-md bg-muted"}),jsxRuntimeExports.jsx(Button,{variant:"outline",size:"icon",onClick:ot,children:rt?jsxRuntimeExports.jsx(Check,{className:"h-4 w-4"}):jsxRuntimeExports.jsx(Copy,{className:"h-4 w-4"})})]})]})};var byteToHex=[];for(var i=0;i<256;++i)byteToHex.push((i+256).toString(16).slice(1));function unsafeStringify(et,o=0){return(byteToHex[et[o+0]]+byteToHex[et[o+1]]+byteToHex[et[o+2]]+byteToHex[et[o+3]]+"-"+byteToHex[et[o+4]]+byteToHex[et[o+5]]+"-"+byteToHex[et[o+6]]+byteToHex[et[o+7]]+"-"+byteToHex[et[o+8]]+byteToHex[et[o+9]]+"-"+byteToHex[et[o+10]]+byteToHex[et[o+11]]+byteToHex[et[o+12]]+byteToHex[et[o+13]]+byteToHex[et[o+14]]+byteToHex[et[o+15]]).toLowerCase()}var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}var randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const native={randomUUID};function v4(et,o,tt){if(native.randomUUID&&!o&&!et)return native.randomUUID();et=et||{};var rt=et.random||(et.rng||rng)();return rt[6]=rt[6]&15|64,rt[8]=rt[8]&63|128,unsafeStringify(rt)}var src={exports:{}},indexLight={exports:{}},indexMinimal={},minimal={},aspromise=asPromise$1;function asPromise$1(et,o){for(var tt=new Array(arguments.length-1),rt=0,nt=2,ot=!0;nt1&&st.charAt(at)==="=";)++ct;return Math.ceil(st.length*3)/4-ct};for(var tt=new Array(64),rt=new Array(123),nt=0;nt<64;)rt[tt[nt]=nt<26?nt+65:nt<52?nt+71:nt<62?nt-4:nt-59|43]=nt++;o.encode=function(st,at,ct){for(var lt=null,dt=[],ht=0,mt=0,ft;at>2],ft=(pt&3)<<4,mt=1;break;case 1:dt[ht++]=tt[ft|pt>>4],ft=(pt&15)<<2,mt=2;break;case 2:dt[ht++]=tt[ft|pt>>6],dt[ht++]=tt[pt&63],mt=0;break}ht>8191&&((lt||(lt=[])).push(String.fromCharCode.apply(String,dt)),ht=0)}return mt&&(dt[ht++]=tt[ft],dt[ht++]=61,mt===1&&(dt[ht++]=61)),lt?(ht&<.push(String.fromCharCode.apply(String,dt.slice(0,ht))),lt.join("")):String.fromCharCode.apply(String,dt.slice(0,ht))};var ot="invalid encoding";o.decode=function(st,at,ct){for(var lt=ct,dt=0,ht,mt=0;mt1)break;if((ft=rt[ft])===void 0)throw Error(ot);switch(dt){case 0:ht=ft,dt=1;break;case 1:at[ct++]=ht<<2|(ft&48)>>4,ht=ft,dt=2;break;case 2:at[ct++]=(ht&15)<<4|(ft&60)>>2,ht=ft,dt=3;break;case 3:at[ct++]=(ht&3)<<6|ft,dt=0;break}}if(dt===1)throw Error(ot);return ct-lt},o.test=function(st){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(st)}})(base64$1);var eventemitter=EventEmitter;function EventEmitter(){this._listeners={}}EventEmitter.prototype.on=function(o,tt,rt){return(this._listeners[o]||(this._listeners[o]=[])).push({fn:tt,ctx:rt||this}),this};EventEmitter.prototype.off=function(o,tt){if(o===void 0)this._listeners={};else if(tt===void 0)this._listeners[o]=[];else for(var rt=this._listeners[o],nt=0;nt0?0:2147483648,ot,it);else if(isNaN(nt))rt(2143289344,ot,it);else if(nt>34028234663852886e22)rt((st<<31|2139095040)>>>0,ot,it);else if(nt<11754943508222875e-54)rt((st<<31|Math.round(nt/1401298464324817e-60))>>>0,ot,it);else{var at=Math.floor(Math.log(nt)/Math.LN2),ct=Math.round(nt*Math.pow(2,-at)*8388608)&8388607;rt((st<<31|at+127<<23|ct)>>>0,ot,it)}}et.writeFloatLE=o.bind(null,writeUintLE),et.writeFloatBE=o.bind(null,writeUintBE);function tt(rt,nt,ot){var it=rt(nt,ot),st=(it>>31)*2+1,at=it>>>23&255,ct=it&8388607;return at===255?ct?NaN:st*(1/0):at===0?st*1401298464324817e-60*ct:st*Math.pow(2,at-150)*(ct+8388608)}et.readFloatLE=tt.bind(null,readUintLE),et.readFloatBE=tt.bind(null,readUintBE)}(),typeof Float64Array<"u"?function(){var o=new Float64Array([-0]),tt=new Uint8Array(o.buffer),rt=tt[7]===128;function nt(at,ct,lt){o[0]=at,ct[lt]=tt[0],ct[lt+1]=tt[1],ct[lt+2]=tt[2],ct[lt+3]=tt[3],ct[lt+4]=tt[4],ct[lt+5]=tt[5],ct[lt+6]=tt[6],ct[lt+7]=tt[7]}function ot(at,ct,lt){o[0]=at,ct[lt]=tt[7],ct[lt+1]=tt[6],ct[lt+2]=tt[5],ct[lt+3]=tt[4],ct[lt+4]=tt[3],ct[lt+5]=tt[2],ct[lt+6]=tt[1],ct[lt+7]=tt[0]}et.writeDoubleLE=rt?nt:ot,et.writeDoubleBE=rt?ot:nt;function it(at,ct){return tt[0]=at[ct],tt[1]=at[ct+1],tt[2]=at[ct+2],tt[3]=at[ct+3],tt[4]=at[ct+4],tt[5]=at[ct+5],tt[6]=at[ct+6],tt[7]=at[ct+7],o[0]}function st(at,ct){return tt[7]=at[ct],tt[6]=at[ct+1],tt[5]=at[ct+2],tt[4]=at[ct+3],tt[3]=at[ct+4],tt[2]=at[ct+5],tt[1]=at[ct+6],tt[0]=at[ct+7],o[0]}et.readDoubleLE=rt?it:st,et.readDoubleBE=rt?st:it}():function(){function o(rt,nt,ot,it,st,at){var ct=it<0?1:0;if(ct&&(it=-it),it===0)rt(0,st,at+nt),rt(1/it>0?0:2147483648,st,at+ot);else if(isNaN(it))rt(0,st,at+nt),rt(2146959360,st,at+ot);else if(it>17976931348623157e292)rt(0,st,at+nt),rt((ct<<31|2146435072)>>>0,st,at+ot);else{var lt;if(it<22250738585072014e-324)lt=it/5e-324,rt(lt>>>0,st,at+nt),rt((ct<<31|lt/4294967296)>>>0,st,at+ot);else{var dt=Math.floor(Math.log(it)/Math.LN2);dt===1024&&(dt=1023),lt=it*Math.pow(2,-dt),rt(lt*4503599627370496>>>0,st,at+nt),rt((ct<<31|dt+1023<<20|lt*1048576&1048575)>>>0,st,at+ot)}}}et.writeDoubleLE=o.bind(null,writeUintLE,0,4),et.writeDoubleBE=o.bind(null,writeUintBE,4,0);function tt(rt,nt,ot,it,st){var at=rt(it,st+nt),ct=rt(it,st+ot),lt=(ct>>31)*2+1,dt=ct>>>20&2047,ht=4294967296*(ct&1048575)+at;return dt===2047?ht?NaN:lt*(1/0):dt===0?lt*5e-324*ht:lt*Math.pow(2,dt-1075)*(ht+4503599627370496)}et.readDoubleLE=tt.bind(null,readUintLE,0,4),et.readDoubleBE=tt.bind(null,readUintBE,4,0)}(),et}function writeUintLE(et,o,tt){o[tt]=et&255,o[tt+1]=et>>>8&255,o[tt+2]=et>>>16&255,o[tt+3]=et>>>24}function writeUintBE(et,o,tt){o[tt]=et>>>24,o[tt+1]=et>>>16&255,o[tt+2]=et>>>8&255,o[tt+3]=et&255}function readUintLE(et,o){return(et[o]|et[o+1]<<8|et[o+2]<<16|et[o+3]<<24)>>>0}function readUintBE(et,o){return(et[o]<<24|et[o+1]<<16|et[o+2]<<8|et[o+3])>>>0}var inquire_1=inquire$1;function inquire$1(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(et){}return null}var utf8$2={};(function(et){var o=et;o.length=function(rt){for(var nt=0,ot=0,it=0;it191&<<224?at[ct++]=(lt&31)<<6|rt[nt++]&63:lt>239&<<365?(lt=((lt&7)<<18|(rt[nt++]&63)<<12|(rt[nt++]&63)<<6|rt[nt++]&63)-65536,at[ct++]=55296+(lt>>10),at[ct++]=56320+(lt&1023)):at[ct++]=(lt&15)<<12|(rt[nt++]&63)<<6|rt[nt++]&63,ct>8191&&((st||(st=[])).push(String.fromCharCode.apply(String,at)),ct=0);return st?(ct&&st.push(String.fromCharCode.apply(String,at.slice(0,ct))),st.join("")):String.fromCharCode.apply(String,at.slice(0,ct))},o.write=function(rt,nt,ot){for(var it=ot,st,at,ct=0;ct>6|192,nt[ot++]=st&63|128):(st&64512)===55296&&((at=rt.charCodeAt(ct+1))&64512)===56320?(st=65536+((st&1023)<<10)+(at&1023),++ct,nt[ot++]=st>>18|240,nt[ot++]=st>>12&63|128,nt[ot++]=st>>6&63|128,nt[ot++]=st&63|128):(nt[ot++]=st>>12|224,nt[ot++]=st>>6&63|128,nt[ot++]=st&63|128);return ot-it}})(utf8$2);var pool_1=pool;function pool(et,o,tt){var rt=tt||8192,nt=rt>>>1,ot=null,it=rt;return function(at){if(at<1||at>nt)return et(at);it+at>rt&&(ot=et(rt),it=0);var ct=o.call(ot,it,it+=at);return it&7&&(it=(it|7)+1),ct}}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=o;var et=requireMinimal();function o(ot,it){this.lo=ot>>>0,this.hi=it>>>0}var tt=o.zero=new o(0,0);tt.toNumber=function(){return 0},tt.zzEncode=tt.zzDecode=function(){return this},tt.length=function(){return 1};var rt=o.zeroHash="\0\0\0\0\0\0\0\0";o.fromNumber=function(it){if(it===0)return tt;var st=it<0;st&&(it=-it);var at=it>>>0,ct=(it-at)/4294967296>>>0;return st&&(ct=~ct>>>0,at=~at>>>0,++at>4294967295&&(at=0,++ct>4294967295&&(ct=0))),new o(at,ct)},o.from=function(it){if(typeof it=="number")return o.fromNumber(it);if(et.isString(it))if(et.Long)it=et.Long.fromString(it);else return o.fromNumber(parseInt(it,10));return it.low||it.high?new o(it.low>>>0,it.high>>>0):tt},o.prototype.toNumber=function(it){if(!it&&this.hi>>>31){var st=~this.lo+1>>>0,at=~this.hi>>>0;return st||(at=at+1>>>0),-(st+at*4294967296)}return this.lo+this.hi*4294967296},o.prototype.toLong=function(it){return et.Long?new et.Long(this.lo|0,this.hi|0,!!it):{low:this.lo|0,high:this.hi|0,unsigned:!!it}};var nt=String.prototype.charCodeAt;return o.fromHash=function(it){return it===rt?tt:new o((nt.call(it,0)|nt.call(it,1)<<8|nt.call(it,2)<<16|nt.call(it,3)<<24)>>>0,(nt.call(it,4)|nt.call(it,5)<<8|nt.call(it,6)<<16|nt.call(it,7)<<24)>>>0)},o.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},o.prototype.zzEncode=function(){var it=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^it)>>>0,this.lo=(this.lo<<1^it)>>>0,this},o.prototype.zzDecode=function(){var it=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^it)>>>0,this.hi=(this.hi>>>1^it)>>>0,this},o.prototype.length=function(){var it=this.lo,st=(this.lo>>>28|this.hi<<4)>>>0,at=this.hi>>>24;return at===0?st===0?it<16384?it<128?1:2:it<2097152?3:4:st<16384?st<128?5:6:st<2097152?7:8:at<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(et){var o=et;o.asPromise=aspromise,o.base64=base64$1,o.EventEmitter=eventemitter,o.float=float,o.inquire=inquire_1,o.utf8=utf8$2,o.pool=pool_1,o.LongBits=requireLongbits(),o.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),o.global=o.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||commonjsGlobal,o.emptyArray=Object.freeze?Object.freeze([]):[],o.emptyObject=Object.freeze?Object.freeze({}):{},o.isInteger=Number.isInteger||function(ot){return typeof ot=="number"&&isFinite(ot)&&Math.floor(ot)===ot},o.isString=function(ot){return typeof ot=="string"||ot instanceof String},o.isObject=function(ot){return ot&&typeof ot=="object"},o.isset=o.isSet=function(ot,it){var st=ot[it];return st!=null&&ot.hasOwnProperty(it)?typeof st!="object"||(Array.isArray(st)?st.length:Object.keys(st).length)>0:!1},o.Buffer=function(){try{var nt=o.inquire("buffer").Buffer;return nt.prototype.utf8Write?nt:null}catch{return null}}(),o._Buffer_from=null,o._Buffer_allocUnsafe=null,o.newBuffer=function(ot){return typeof ot=="number"?o.Buffer?o._Buffer_allocUnsafe(ot):new o.Array(ot):o.Buffer?o._Buffer_from(ot):typeof Uint8Array>"u"?ot:new Uint8Array(ot)},o.Array=typeof Uint8Array<"u"?Uint8Array:Array,o.Long=o.global.dcodeIO&&o.global.dcodeIO.Long||o.global.Long||o.inquire("long"),o.key2Re=/^true|false|0|1$/,o.key32Re=/^-?(?:0|[1-9][0-9]*)$/,o.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,o.longToHash=function(ot){return ot?o.LongBits.from(ot).toHash():o.LongBits.zeroHash},o.longFromHash=function(ot,it){var st=o.LongBits.fromHash(ot);return o.Long?o.Long.fromBits(st.lo,st.hi,it):st.toNumber(!!it)};function tt(nt,ot,it){for(var st=Object.keys(ot),at=0;at-1;--ct)if(it[at[ct]]===1&&this[at[ct]]!==void 0&&this[at[ct]]!==null)return at[ct]}},o.oneOfSetter=function(ot){return function(it){for(var st=0;st127;)o[tt++]=et&127|128,et>>>=7;o[tt]=et}function VarintOp(et,o){this.len=et,this.next=void 0,this.val=o}VarintOp.prototype=Object.create(Op.prototype);VarintOp.prototype.fn=writeVarint32;Writer$1.prototype.uint32=function et(o){return this.len+=(this.tail=this.tail.next=new VarintOp((o=o>>>0)<128?1:o<16384?2:o<2097152?3:o<268435456?4:5,o)).len,this};Writer$1.prototype.int32=function et(o){return o<0?this._push(writeVarint64,10,LongBits$1.fromNumber(o)):this.uint32(o)};Writer$1.prototype.sint32=function et(o){return this.uint32((o<<1^o>>31)>>>0)};function writeVarint64(et,o,tt){for(;et.hi;)o[tt++]=et.lo&127|128,et.lo=(et.lo>>>7|et.hi<<25)>>>0,et.hi>>>=7;for(;et.lo>127;)o[tt++]=et.lo&127|128,et.lo=et.lo>>>7;o[tt++]=et.lo}Writer$1.prototype.uint64=function et(o){var tt=LongBits$1.from(o);return this._push(writeVarint64,tt.length(),tt)};Writer$1.prototype.int64=Writer$1.prototype.uint64;Writer$1.prototype.sint64=function et(o){var tt=LongBits$1.from(o).zzEncode();return this._push(writeVarint64,tt.length(),tt)};Writer$1.prototype.bool=function et(o){return this._push(writeByte,1,o?1:0)};function writeFixed32(et,o,tt){o[tt]=et&255,o[tt+1]=et>>>8&255,o[tt+2]=et>>>16&255,o[tt+3]=et>>>24}Writer$1.prototype.fixed32=function et(o){return this._push(writeFixed32,4,o>>>0)};Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32;Writer$1.prototype.fixed64=function et(o){var tt=LongBits$1.from(o);return this._push(writeFixed32,4,tt.lo)._push(writeFixed32,4,tt.hi)};Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64;Writer$1.prototype.float=function et(o){return this._push(util$8.float.writeFloatLE,4,o)};Writer$1.prototype.double=function et(o){return this._push(util$8.float.writeDoubleLE,8,o)};var writeBytes=util$8.Array.prototype.set?function et(o,tt,rt){tt.set(o,rt)}:function et(o,tt,rt){for(var nt=0;nt>>0;if(!tt)return this._push(writeByte,1,0);if(util$8.isString(o)){var rt=Writer$1.alloc(tt=base64.length(o));base64.decode(o,rt,0),o=rt}return this.uint32(tt)._push(writeBytes,tt,o)};Writer$1.prototype.string=function et(o){var tt=utf8$1.length(o);return tt?this.uint32(tt)._push(utf8$1.write,tt,o):this._push(writeByte,1,0)};Writer$1.prototype.fork=function et(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this};Writer$1.prototype.reset=function et(){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$1.prototype.ldelim=function et(){var o=this.head,tt=this.tail,rt=this.len;return this.reset().uint32(rt),rt&&(this.tail.next=o.next,this.tail=tt,this.len+=rt),this};Writer$1.prototype.finish=function et(){for(var o=this.head.next,tt=this.constructor.alloc(this.len),rt=0;o;)o.fn(o.val,tt,rt),rt+=o.len,o=o.next;return tt};Writer$1._configure=function(et){BufferWriter$1=et,Writer$1.create=create$2(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$7=requireMinimal();function BufferWriter(){Writer.call(this)}BufferWriter._configure=function(){BufferWriter.alloc=util$7._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$7.Buffer&&util$7.Buffer.prototype instanceof Uint8Array&&util$7.Buffer.prototype.set.name==="set"?function(o,tt,rt){tt.set(o,rt)}:function(o,tt,rt){if(o.copy)o.copy(tt,rt,0,o.length);else for(var nt=0;nt>>0;return this.uint32(tt),tt&&this._push(BufferWriter.writeBytesBuffer,tt,o),this};function writeStringBuffer(et,o,tt){et.length<40?util$7.utf8.write(et,o,tt):o.utf8Write?o.utf8Write(et,tt):o.write(et,tt)}BufferWriter.prototype.string=function et(o){var tt=util$7.Buffer.byteLength(o);return this.uint32(tt),tt&&this._push(writeStringBuffer,tt,o),this};BufferWriter._configure();var reader=Reader$1,util$6=requireMinimal(),BufferReader$1,LongBits=util$6.LongBits,utf8=util$6.utf8;function indexOutOfRange(et,o){return RangeError("index out of range: "+et.pos+" + "+(o||1)+" > "+et.len)}function Reader$1(et){this.buf=et,this.pos=0,this.len=et.length}var create_array=typeof Uint8Array<"u"?function et(o){if(o instanceof Uint8Array||Array.isArray(o))return new Reader$1(o);throw Error("illegal buffer")}:function et(o){if(Array.isArray(o))return new Reader$1(o);throw Error("illegal buffer")},create$1=function et(){return util$6.Buffer?function(tt){return(Reader$1.create=function(nt){return util$6.Buffer.isBuffer(nt)?new BufferReader$1(nt):create_array(nt)})(tt)}:create_array};Reader$1.create=create$1();Reader$1.prototype._slice=util$6.Array.prototype.subarray||util$6.Array.prototype.slice;Reader$1.prototype.uint32=function et(){var o=4294967295;return function(){if(o=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(o=(o|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&15)<<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$1.prototype.int32=function et(){return this.uint32()|0};Reader$1.prototype.sint32=function et(){var o=this.uint32();return o>>>1^-(o&1)|0};function readLongVarint(){var et=new LongBits(0,0),o=0;if(this.len-this.pos>4){for(;o<4;++o)if(et.lo=(et.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et;if(et.lo=(et.lo|(this.buf[this.pos]&127)<<28)>>>0,et.hi=(et.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return et;o=0}else{for(;o<3;++o){if(this.pos>=this.len)throw indexOutOfRange(this);if(et.lo=(et.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}return et.lo=(et.lo|(this.buf[this.pos++]&127)<>>0,et}if(this.len-this.pos>4){for(;o<5;++o)if(et.hi=(et.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}else for(;o<5;++o){if(this.pos>=this.len)throw indexOutOfRange(this);if(et.hi=(et.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}throw Error("invalid varint encoding")}Reader$1.prototype.bool=function et(){return this.uint32()!==0};function readFixed32_end(et,o){return(et[o-4]|et[o-3]<<8|et[o-2]<<16|et[o-1]<<24)>>>0}Reader$1.prototype.fixed32=function et(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)};Reader$1.prototype.sfixed32=function et(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.prototype.float=function et(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var o=util$6.float.readFloatLE(this.buf,this.pos);return this.pos+=4,o};Reader$1.prototype.double=function et(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var o=util$6.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,o};Reader$1.prototype.bytes=function et(){var o=this.uint32(),tt=this.pos,rt=this.pos+o;if(rt>this.len)throw indexOutOfRange(this,o);if(this.pos+=o,Array.isArray(this.buf))return this.buf.slice(tt,rt);if(tt===rt){var nt=util$6.Buffer;return nt?nt.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,tt,rt)};Reader$1.prototype.string=function et(){var o=this.bytes();return utf8.read(o,0,o.length)};Reader$1.prototype.skip=function et(o){if(typeof o=="number"){if(this.pos+o>this.len)throw indexOutOfRange(this,o);this.pos+=o}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this};Reader$1.prototype.skipType=function(et){switch(et){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(et=this.uint32()&7)!==4;)this.skipType(et);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+et+" at offset "+this.pos)}return this};Reader$1._configure=function(et){BufferReader$1=et,Reader$1.create=create$1(),BufferReader$1._configure();var o=util$6.Long?"toLong":"toNumber";util$6.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[o](!1)},uint64:function(){return readLongVarint.call(this)[o](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[o](!1)},fixed64:function(){return readFixed64.call(this)[o](!0)},sfixed64:function(){return readFixed64.call(this)[o](!1)}})};var reader_buffer=BufferReader,Reader=reader;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$5=requireMinimal();function BufferReader(et){Reader.call(this,et)}BufferReader._configure=function(){util$5.Buffer&&(BufferReader.prototype._slice=util$5.Buffer.prototype.slice)};BufferReader.prototype.string=function et(){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();var rpc={},service$1=Service$1,util$4=requireMinimal();(Service$1.prototype=Object.create(util$4.EventEmitter.prototype)).constructor=Service$1;function Service$1(et,o,tt){if(typeof et!="function")throw TypeError("rpcImpl must be a function");util$4.EventEmitter.call(this),this.rpcImpl=et,this.requestDelimited=!!o,this.responseDelimited=!!tt}Service$1.prototype.rpcCall=function et(o,tt,rt,nt,ot){if(!nt)throw TypeError("request must be specified");var it=this;if(!ot)return util$4.asPromise(et,it,o,tt,rt,nt);if(!it.rpcImpl){setTimeout(function(){ot(Error("already ended"))},0);return}try{return it.rpcImpl(o,tt[it.requestDelimited?"encodeDelimited":"encode"](nt).finish(),function(at,ct){if(at)return it.emit("error",at,o),ot(at);if(ct===null){it.end(!0);return}if(!(ct instanceof rt))try{ct=rt[it.responseDelimited?"decodeDelimited":"decode"](ct)}catch(lt){return it.emit("error",lt,o),ot(lt)}return it.emit("data",ct,o),ot(null,ct)})}catch(st){it.emit("error",st,o),setTimeout(function(){ot(st)},0);return}};Service$1.prototype.end=function et(o){return this.rpcImpl&&(o||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this};(function(et){var o=et;o.Service=service$1})(rpc);var roots={};(function(et){var o=et;o.build="minimal",o.Writer=writer,o.BufferWriter=writer_buffer,o.Reader=reader,o.BufferReader=reader_buffer,o.util=requireMinimal(),o.rpc=rpc,o.roots=roots,o.configure=tt;function tt(){o.util._configure(),o.Writer._configure(o.BufferWriter),o.Reader._configure(o.BufferReader)}tt()})(indexMinimal);var util$3={exports:{}},codegen_1=codegen;function codegen(et,o){typeof et=="string"&&(o=et,et=void 0);var tt=[];function rt(ot){if(typeof ot!="string"){var it=nt();if(codegen.verbose&&console.log("codegen: "+it),it="return "+it,ot){for(var st=Object.keys(ot),at=new Array(st.length+1),ct=new Array(st.length),lt=0;ltrt=o.y+o.h?tt:tt.map((nt,ot)=>ot=o.x+o.w?nt:!1))}function getImageSettings(et,o,tt,rt){if(rt==null)return null;const nt=et.length+tt*2,ot=Math.floor(o*DEFAULT_IMG_SCALE),it=nt/o,st=(rt.width||ot)*it,at=(rt.height||ot)*it,ct=rt.x==null?et.length/2-st/2:rt.x*it,lt=rt.y==null?et.length/2-at/2:rt.y*it,dt=rt.opacity==null?1:rt.opacity;let ht=null;if(rt.excavate){let ft=Math.floor(ct),pt=Math.floor(lt),yt=Math.ceil(st+ct-ft),gt=Math.ceil(at+lt-pt);ht={x:ft,y:pt,w:yt,h:gt}}const mt=rt.crossOrigin;return{x:ct,y:lt,h:at,w:st,excavation:ht,opacity:dt,crossOrigin:mt}}function getMarginSize(et,o){return o!=null?Math.max(Math.floor(o),0):et?SPEC_MARGIN_SIZE:DEFAULT_MARGIN_SIZE}function useQRCode({value:et,level:o,minVersion:tt,includeMargin:rt,marginSize:nt,imageSettings:ot,size:it}){let st=React.useMemo(()=>{const ht=qrcodegen_default.QrSegment.makeSegments(et);return qrcodegen_default.QrCode.encodeSegments(ht,ERROR_LEVEL_MAP[o],tt)},[et,o,tt]);const{cells:at,margin:ct,numCells:lt,calculatedImageSettings:dt}=React.useMemo(()=>{let ht=st.getModules();const mt=getMarginSize(rt,nt),ft=ht.length+mt*2,pt=getImageSettings(ht,it,mt,ot);return{cells:ht,margin:mt,numCells:ft,calculatedImageSettings:pt}},[st,it,ot,rt,nt]);return{qrcode:st,margin:ct,cells:at,numCells:lt,calculatedImageSettings:dt}}var SUPPORTS_PATH2D=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),QRCodeCanvas=React.forwardRef(function(o,tt){const rt=o,{value:nt,size:ot=DEFAULT_SIZE,level:it=DEFAULT_LEVEL,bgColor:st=DEFAULT_BGCOLOR,fgColor:at=DEFAULT_FGCOLOR,includeMargin:ct=DEFAULT_INCLUDEMARGIN,minVersion:lt=DEFAULT_MINVERSION,marginSize:dt,imageSettings:ht}=rt,ft=__objRest(rt,["value","size","level","bgColor","fgColor","includeMargin","minVersion","marginSize","imageSettings"]),{style:pt}=ft,yt=__objRest(ft,["style"]),gt=ht==null?void 0:ht.src,bt=React.useRef(null),xt=React.useRef(null),vt=React.useCallback(Mt=>{bt.current=Mt,typeof tt=="function"?tt(Mt):tt&&(tt.current=Mt)},[tt]),[Et,Ct]=React.useState(!1),{margin:St,cells:At,numCells:kt,calculatedImageSettings:It}=useQRCode({value:nt,level:it,minVersion:lt,includeMargin:ct,marginSize:dt,imageSettings:ht,size:ot});React.useEffect(()=>{if(bt.current!=null){const Mt=bt.current,zt=Mt.getContext("2d");if(!zt)return;let Ut=At;const Xt=xt.current,Wt=It!=null&&Xt!==null&&Xt.complete&&Xt.naturalHeight!==0&&Xt.naturalWidth!==0;Wt&&It.excavation!=null&&(Ut=excavateModules(At,It.excavation));const Ft=window.devicePixelRatio||1;Mt.height=Mt.width=ot*Ft;const qt=ot/kt*Ft;zt.scale(qt,qt),zt.fillStyle=st,zt.fillRect(0,0,kt,kt),zt.fillStyle=at,SUPPORTS_PATH2D?zt.fill(new Path2D(generatePath(Ut,St))):At.forEach(function(Pt,Yt){Pt.forEach(function(Qt,jt){Qt&&zt.fillRect(jt+St,Yt+St,1,1)})}),It&&(zt.globalAlpha=It.opacity),Wt&&zt.drawImage(Xt,It.x+St,It.y+St,It.w,It.h)}}),React.useEffect(()=>{Ct(!1)},[gt]);const Nt=__spreadValues({height:ot,width:ot},pt);let Lt=null;return gt!=null&&(Lt=React.createElement("img",{src:gt,key:gt,style:{display:"none"},onLoad:()=>{Ct(!0)},ref:xt,crossOrigin:It==null?void 0:It.crossOrigin})),React.createElement(React.Fragment,null,React.createElement("canvas",__spreadValues({style:Nt,height:ot,width:ot,ref:vt,role:"img"},yt)),Lt)});QRCodeCanvas.displayName="QRCodeCanvas";var QRCodeSVG=React.forwardRef(function(o,tt){const rt=o,{value:nt,size:ot=DEFAULT_SIZE,level:it=DEFAULT_LEVEL,bgColor:st=DEFAULT_BGCOLOR,fgColor:at=DEFAULT_FGCOLOR,includeMargin:ct=DEFAULT_INCLUDEMARGIN,minVersion:lt=DEFAULT_MINVERSION,title:dt,marginSize:ht,imageSettings:mt}=rt,ft=__objRest(rt,["value","size","level","bgColor","fgColor","includeMargin","minVersion","title","marginSize","imageSettings"]),{margin:pt,cells:yt,numCells:gt,calculatedImageSettings:bt}=useQRCode({value:nt,level:it,minVersion:lt,includeMargin:ct,marginSize:ht,imageSettings:mt,size:ot});let xt=yt,vt=null;mt!=null&&bt!=null&&(bt.excavation!=null&&(xt=excavateModules(yt,bt.excavation)),vt=React.createElement("image",{href:mt.src,height:bt.h,width:bt.w,x:bt.x+pt,y:bt.y+pt,preserveAspectRatio:"none",opacity:bt.opacity,crossOrigin:bt.crossOrigin}));const Et=generatePath(xt,pt);return React.createElement("svg",__spreadValues({height:ot,width:ot,viewBox:`0 0 ${gt} ${gt}`,ref:tt,role:"img"},ft),!!dt&&React.createElement("title",null,dt),React.createElement("path",{fill:st,d:`M0,0 h${gt}v${gt}H0z`,shapeRendering:"crispEdges"}),React.createElement("path",{fill:at,d:Et,shapeRendering:"crispEdges"}),vt)});QRCodeSVG.displayName="QRCodeSVG";const QRCode=({text:et,width:o=256,height:tt=256})=>{const[rt,nt]=reactExports.useState(!1),ot=async()=>{await navigator.clipboard.writeText(et),nt(!0),setTimeout(()=>nt(!1),2e3)};return jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[jsxRuntimeExports.jsx(QRCodeSVG,{value:et,size:Math.min(o,tt)}),jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntimeExports.jsx("input",{type:"text",value:et,readOnly:!0,className:"flex-1 px-3 py-2 text-sm border rounded-md bg-muted"}),jsxRuntimeExports.jsx(Button,{variant:"outline",size:"icon",onClick:ot,children:rt?jsxRuntimeExports.jsx(Check,{className:"h-4 w-4"}):jsxRuntimeExports.jsx(Copy,{className:"h-4 w-4"})})]})]})};var byteToHex=[];for(var i=0;i<256;++i)byteToHex.push((i+256).toString(16).slice(1));function unsafeStringify(et,o=0){return(byteToHex[et[o+0]]+byteToHex[et[o+1]]+byteToHex[et[o+2]]+byteToHex[et[o+3]]+"-"+byteToHex[et[o+4]]+byteToHex[et[o+5]]+"-"+byteToHex[et[o+6]]+byteToHex[et[o+7]]+"-"+byteToHex[et[o+8]]+byteToHex[et[o+9]]+"-"+byteToHex[et[o+10]]+byteToHex[et[o+11]]+byteToHex[et[o+12]]+byteToHex[et[o+13]]+byteToHex[et[o+14]]+byteToHex[et[o+15]]).toLowerCase()}var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}var randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const native={randomUUID};function v4(et,o,tt){if(native.randomUUID&&!o&&!et)return native.randomUUID();et=et||{};var rt=et.random||(et.rng||rng)();return rt[6]=rt[6]&15|64,rt[8]=rt[8]&63|128,unsafeStringify(rt)}var src={exports:{}},indexLight={exports:{}},indexMinimal={},minimal={},aspromise=asPromise$1;function asPromise$1(et,o){for(var tt=new Array(arguments.length-1),rt=0,nt=2,ot=!0;nt1&&st.charAt(at)==="=";)++ct;return Math.ceil(st.length*3)/4-ct};for(var tt=new Array(64),rt=new Array(123),nt=0;nt<64;)rt[tt[nt]=nt<26?nt+65:nt<52?nt+71:nt<62?nt-4:nt-59|43]=nt++;o.encode=function(st,at,ct){for(var lt=null,dt=[],ht=0,mt=0,ft;at>2],ft=(pt&3)<<4,mt=1;break;case 1:dt[ht++]=tt[ft|pt>>4],ft=(pt&15)<<2,mt=2;break;case 2:dt[ht++]=tt[ft|pt>>6],dt[ht++]=tt[pt&63],mt=0;break}ht>8191&&((lt||(lt=[])).push(String.fromCharCode.apply(String,dt)),ht=0)}return mt&&(dt[ht++]=tt[ft],dt[ht++]=61,mt===1&&(dt[ht++]=61)),lt?(ht&<.push(String.fromCharCode.apply(String,dt.slice(0,ht))),lt.join("")):String.fromCharCode.apply(String,dt.slice(0,ht))};var ot="invalid encoding";o.decode=function(st,at,ct){for(var lt=ct,dt=0,ht,mt=0;mt1)break;if((ft=rt[ft])===void 0)throw Error(ot);switch(dt){case 0:ht=ft,dt=1;break;case 1:at[ct++]=ht<<2|(ft&48)>>4,ht=ft,dt=2;break;case 2:at[ct++]=(ht&15)<<4|(ft&60)>>2,ht=ft,dt=3;break;case 3:at[ct++]=(ht&3)<<6|ft,dt=0;break}}if(dt===1)throw Error(ot);return ct-lt},o.test=function(st){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(st)}})(base64$1);var eventemitter=EventEmitter;function EventEmitter(){this._listeners={}}EventEmitter.prototype.on=function(o,tt,rt){return(this._listeners[o]||(this._listeners[o]=[])).push({fn:tt,ctx:rt||this}),this};EventEmitter.prototype.off=function(o,tt){if(o===void 0)this._listeners={};else if(tt===void 0)this._listeners[o]=[];else for(var rt=this._listeners[o],nt=0;nt0?0:2147483648,ot,it);else if(isNaN(nt))rt(2143289344,ot,it);else if(nt>34028234663852886e22)rt((st<<31|2139095040)>>>0,ot,it);else if(nt<11754943508222875e-54)rt((st<<31|Math.round(nt/1401298464324817e-60))>>>0,ot,it);else{var at=Math.floor(Math.log(nt)/Math.LN2),ct=Math.round(nt*Math.pow(2,-at)*8388608)&8388607;rt((st<<31|at+127<<23|ct)>>>0,ot,it)}}et.writeFloatLE=o.bind(null,writeUintLE),et.writeFloatBE=o.bind(null,writeUintBE);function tt(rt,nt,ot){var it=rt(nt,ot),st=(it>>31)*2+1,at=it>>>23&255,ct=it&8388607;return at===255?ct?NaN:st*(1/0):at===0?st*1401298464324817e-60*ct:st*Math.pow(2,at-150)*(ct+8388608)}et.readFloatLE=tt.bind(null,readUintLE),et.readFloatBE=tt.bind(null,readUintBE)}(),typeof Float64Array<"u"?function(){var o=new Float64Array([-0]),tt=new Uint8Array(o.buffer),rt=tt[7]===128;function nt(at,ct,lt){o[0]=at,ct[lt]=tt[0],ct[lt+1]=tt[1],ct[lt+2]=tt[2],ct[lt+3]=tt[3],ct[lt+4]=tt[4],ct[lt+5]=tt[5],ct[lt+6]=tt[6],ct[lt+7]=tt[7]}function ot(at,ct,lt){o[0]=at,ct[lt]=tt[7],ct[lt+1]=tt[6],ct[lt+2]=tt[5],ct[lt+3]=tt[4],ct[lt+4]=tt[3],ct[lt+5]=tt[2],ct[lt+6]=tt[1],ct[lt+7]=tt[0]}et.writeDoubleLE=rt?nt:ot,et.writeDoubleBE=rt?ot:nt;function it(at,ct){return tt[0]=at[ct],tt[1]=at[ct+1],tt[2]=at[ct+2],tt[3]=at[ct+3],tt[4]=at[ct+4],tt[5]=at[ct+5],tt[6]=at[ct+6],tt[7]=at[ct+7],o[0]}function st(at,ct){return tt[7]=at[ct],tt[6]=at[ct+1],tt[5]=at[ct+2],tt[4]=at[ct+3],tt[3]=at[ct+4],tt[2]=at[ct+5],tt[1]=at[ct+6],tt[0]=at[ct+7],o[0]}et.readDoubleLE=rt?it:st,et.readDoubleBE=rt?st:it}():function(){function o(rt,nt,ot,it,st,at){var ct=it<0?1:0;if(ct&&(it=-it),it===0)rt(0,st,at+nt),rt(1/it>0?0:2147483648,st,at+ot);else if(isNaN(it))rt(0,st,at+nt),rt(2146959360,st,at+ot);else if(it>17976931348623157e292)rt(0,st,at+nt),rt((ct<<31|2146435072)>>>0,st,at+ot);else{var lt;if(it<22250738585072014e-324)lt=it/5e-324,rt(lt>>>0,st,at+nt),rt((ct<<31|lt/4294967296)>>>0,st,at+ot);else{var dt=Math.floor(Math.log(it)/Math.LN2);dt===1024&&(dt=1023),lt=it*Math.pow(2,-dt),rt(lt*4503599627370496>>>0,st,at+nt),rt((ct<<31|dt+1023<<20|lt*1048576&1048575)>>>0,st,at+ot)}}}et.writeDoubleLE=o.bind(null,writeUintLE,0,4),et.writeDoubleBE=o.bind(null,writeUintBE,4,0);function tt(rt,nt,ot,it,st){var at=rt(it,st+nt),ct=rt(it,st+ot),lt=(ct>>31)*2+1,dt=ct>>>20&2047,ht=4294967296*(ct&1048575)+at;return dt===2047?ht?NaN:lt*(1/0):dt===0?lt*5e-324*ht:lt*Math.pow(2,dt-1075)*(ht+4503599627370496)}et.readDoubleLE=tt.bind(null,readUintLE,0,4),et.readDoubleBE=tt.bind(null,readUintBE,4,0)}(),et}function writeUintLE(et,o,tt){o[tt]=et&255,o[tt+1]=et>>>8&255,o[tt+2]=et>>>16&255,o[tt+3]=et>>>24}function writeUintBE(et,o,tt){o[tt]=et>>>24,o[tt+1]=et>>>16&255,o[tt+2]=et>>>8&255,o[tt+3]=et&255}function readUintLE(et,o){return(et[o]|et[o+1]<<8|et[o+2]<<16|et[o+3]<<24)>>>0}function readUintBE(et,o){return(et[o]<<24|et[o+1]<<16|et[o+2]<<8|et[o+3])>>>0}var inquire_1=inquire$1;function inquire$1(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(et){}return null}var utf8$2={};(function(et){var o=et;o.length=function(rt){for(var nt=0,ot=0,it=0;it191&<<224?at[ct++]=(lt&31)<<6|rt[nt++]&63:lt>239&<<365?(lt=((lt&7)<<18|(rt[nt++]&63)<<12|(rt[nt++]&63)<<6|rt[nt++]&63)-65536,at[ct++]=55296+(lt>>10),at[ct++]=56320+(lt&1023)):at[ct++]=(lt&15)<<12|(rt[nt++]&63)<<6|rt[nt++]&63,ct>8191&&((st||(st=[])).push(String.fromCharCode.apply(String,at)),ct=0);return st?(ct&&st.push(String.fromCharCode.apply(String,at.slice(0,ct))),st.join("")):String.fromCharCode.apply(String,at.slice(0,ct))},o.write=function(rt,nt,ot){for(var it=ot,st,at,ct=0;ct>6|192,nt[ot++]=st&63|128):(st&64512)===55296&&((at=rt.charCodeAt(ct+1))&64512)===56320?(st=65536+((st&1023)<<10)+(at&1023),++ct,nt[ot++]=st>>18|240,nt[ot++]=st>>12&63|128,nt[ot++]=st>>6&63|128,nt[ot++]=st&63|128):(nt[ot++]=st>>12|224,nt[ot++]=st>>6&63|128,nt[ot++]=st&63|128);return ot-it}})(utf8$2);var pool_1=pool;function pool(et,o,tt){var rt=tt||8192,nt=rt>>>1,ot=null,it=rt;return function(at){if(at<1||at>nt)return et(at);it+at>rt&&(ot=et(rt),it=0);var ct=o.call(ot,it,it+=at);return it&7&&(it=(it|7)+1),ct}}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=o;var et=requireMinimal();function o(ot,it){this.lo=ot>>>0,this.hi=it>>>0}var tt=o.zero=new o(0,0);tt.toNumber=function(){return 0},tt.zzEncode=tt.zzDecode=function(){return this},tt.length=function(){return 1};var rt=o.zeroHash="\0\0\0\0\0\0\0\0";o.fromNumber=function(it){if(it===0)return tt;var st=it<0;st&&(it=-it);var at=it>>>0,ct=(it-at)/4294967296>>>0;return st&&(ct=~ct>>>0,at=~at>>>0,++at>4294967295&&(at=0,++ct>4294967295&&(ct=0))),new o(at,ct)},o.from=function(it){if(typeof it=="number")return o.fromNumber(it);if(et.isString(it))if(et.Long)it=et.Long.fromString(it);else return o.fromNumber(parseInt(it,10));return it.low||it.high?new o(it.low>>>0,it.high>>>0):tt},o.prototype.toNumber=function(it){if(!it&&this.hi>>>31){var st=~this.lo+1>>>0,at=~this.hi>>>0;return st||(at=at+1>>>0),-(st+at*4294967296)}return this.lo+this.hi*4294967296},o.prototype.toLong=function(it){return et.Long?new et.Long(this.lo|0,this.hi|0,!!it):{low:this.lo|0,high:this.hi|0,unsigned:!!it}};var nt=String.prototype.charCodeAt;return o.fromHash=function(it){return it===rt?tt:new o((nt.call(it,0)|nt.call(it,1)<<8|nt.call(it,2)<<16|nt.call(it,3)<<24)>>>0,(nt.call(it,4)|nt.call(it,5)<<8|nt.call(it,6)<<16|nt.call(it,7)<<24)>>>0)},o.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},o.prototype.zzEncode=function(){var it=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^it)>>>0,this.lo=(this.lo<<1^it)>>>0,this},o.prototype.zzDecode=function(){var it=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^it)>>>0,this.hi=(this.hi>>>1^it)>>>0,this},o.prototype.length=function(){var it=this.lo,st=(this.lo>>>28|this.hi<<4)>>>0,at=this.hi>>>24;return at===0?st===0?it<16384?it<128?1:2:it<2097152?3:4:st<16384?st<128?5:6:st<2097152?7:8:at<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(et){var o=et;o.asPromise=aspromise,o.base64=base64$1,o.EventEmitter=eventemitter,o.float=float,o.inquire=inquire_1,o.utf8=utf8$2,o.pool=pool_1,o.LongBits=requireLongbits(),o.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node),o.global=o.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||commonjsGlobal,o.emptyArray=Object.freeze?Object.freeze([]):[],o.emptyObject=Object.freeze?Object.freeze({}):{},o.isInteger=Number.isInteger||function(ot){return typeof ot=="number"&&isFinite(ot)&&Math.floor(ot)===ot},o.isString=function(ot){return typeof ot=="string"||ot instanceof String},o.isObject=function(ot){return ot&&typeof ot=="object"},o.isset=o.isSet=function(ot,it){var st=ot[it];return st!=null&&ot.hasOwnProperty(it)?typeof st!="object"||(Array.isArray(st)?st.length:Object.keys(st).length)>0:!1},o.Buffer=function(){try{var nt=o.inquire("buffer").Buffer;return nt.prototype.utf8Write?nt:null}catch{return null}}(),o._Buffer_from=null,o._Buffer_allocUnsafe=null,o.newBuffer=function(ot){return typeof ot=="number"?o.Buffer?o._Buffer_allocUnsafe(ot):new o.Array(ot):o.Buffer?o._Buffer_from(ot):typeof Uint8Array>"u"?ot:new Uint8Array(ot)},o.Array=typeof Uint8Array<"u"?Uint8Array:Array,o.Long=o.global.dcodeIO&&o.global.dcodeIO.Long||o.global.Long||o.inquire("long"),o.key2Re=/^true|false|0|1$/,o.key32Re=/^-?(?:0|[1-9][0-9]*)$/,o.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,o.longToHash=function(ot){return ot?o.LongBits.from(ot).toHash():o.LongBits.zeroHash},o.longFromHash=function(ot,it){var st=o.LongBits.fromHash(ot);return o.Long?o.Long.fromBits(st.lo,st.hi,it):st.toNumber(!!it)};function tt(nt,ot,it){for(var st=Object.keys(ot),at=0;at-1;--ct)if(it[at[ct]]===1&&this[at[ct]]!==void 0&&this[at[ct]]!==null)return at[ct]}},o.oneOfSetter=function(ot){return function(it){for(var st=0;st127;)o[tt++]=et&127|128,et>>>=7;o[tt]=et}function VarintOp(et,o){this.len=et,this.next=void 0,this.val=o}VarintOp.prototype=Object.create(Op.prototype);VarintOp.prototype.fn=writeVarint32;Writer$1.prototype.uint32=function et(o){return this.len+=(this.tail=this.tail.next=new VarintOp((o=o>>>0)<128?1:o<16384?2:o<2097152?3:o<268435456?4:5,o)).len,this};Writer$1.prototype.int32=function et(o){return o<0?this._push(writeVarint64,10,LongBits$1.fromNumber(o)):this.uint32(o)};Writer$1.prototype.sint32=function et(o){return this.uint32((o<<1^o>>31)>>>0)};function writeVarint64(et,o,tt){for(;et.hi;)o[tt++]=et.lo&127|128,et.lo=(et.lo>>>7|et.hi<<25)>>>0,et.hi>>>=7;for(;et.lo>127;)o[tt++]=et.lo&127|128,et.lo=et.lo>>>7;o[tt++]=et.lo}Writer$1.prototype.uint64=function et(o){var tt=LongBits$1.from(o);return this._push(writeVarint64,tt.length(),tt)};Writer$1.prototype.int64=Writer$1.prototype.uint64;Writer$1.prototype.sint64=function et(o){var tt=LongBits$1.from(o).zzEncode();return this._push(writeVarint64,tt.length(),tt)};Writer$1.prototype.bool=function et(o){return this._push(writeByte,1,o?1:0)};function writeFixed32(et,o,tt){o[tt]=et&255,o[tt+1]=et>>>8&255,o[tt+2]=et>>>16&255,o[tt+3]=et>>>24}Writer$1.prototype.fixed32=function et(o){return this._push(writeFixed32,4,o>>>0)};Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32;Writer$1.prototype.fixed64=function et(o){var tt=LongBits$1.from(o);return this._push(writeFixed32,4,tt.lo)._push(writeFixed32,4,tt.hi)};Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64;Writer$1.prototype.float=function et(o){return this._push(util$7.float.writeFloatLE,4,o)};Writer$1.prototype.double=function et(o){return this._push(util$7.float.writeDoubleLE,8,o)};var writeBytes=util$7.Array.prototype.set?function et(o,tt,rt){tt.set(o,rt)}:function et(o,tt,rt){for(var nt=0;nt>>0;if(!tt)return this._push(writeByte,1,0);if(util$7.isString(o)){var rt=Writer$1.alloc(tt=base64.length(o));base64.decode(o,rt,0),o=rt}return this.uint32(tt)._push(writeBytes,tt,o)};Writer$1.prototype.string=function et(o){var tt=utf8$1.length(o);return tt?this.uint32(tt)._push(utf8$1.write,tt,o):this._push(writeByte,1,0)};Writer$1.prototype.fork=function et(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this};Writer$1.prototype.reset=function et(){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$1.prototype.ldelim=function et(){var o=this.head,tt=this.tail,rt=this.len;return this.reset().uint32(rt),rt&&(this.tail.next=o.next,this.tail=tt,this.len+=rt),this};Writer$1.prototype.finish=function et(){for(var o=this.head.next,tt=this.constructor.alloc(this.len),rt=0;o;)o.fn(o.val,tt,rt),rt+=o.len,o=o.next;return tt};Writer$1._configure=function(et){BufferWriter$1=et,Writer$1.create=create$2(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$6=requireMinimal();function BufferWriter(){Writer.call(this)}BufferWriter._configure=function(){BufferWriter.alloc=util$6._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$6.Buffer&&util$6.Buffer.prototype instanceof Uint8Array&&util$6.Buffer.prototype.set.name==="set"?function(o,tt,rt){tt.set(o,rt)}:function(o,tt,rt){if(o.copy)o.copy(tt,rt,0,o.length);else for(var nt=0;nt>>0;return this.uint32(tt),tt&&this._push(BufferWriter.writeBytesBuffer,tt,o),this};function writeStringBuffer(et,o,tt){et.length<40?util$6.utf8.write(et,o,tt):o.utf8Write?o.utf8Write(et,tt):o.write(et,tt)}BufferWriter.prototype.string=function et(o){var tt=util$6.Buffer.byteLength(o);return this.uint32(tt),tt&&this._push(writeStringBuffer,tt,o),this};BufferWriter._configure();var reader=Reader$1,util$5=requireMinimal(),BufferReader$1,LongBits=util$5.LongBits,utf8=util$5.utf8;function indexOutOfRange(et,o){return RangeError("index out of range: "+et.pos+" + "+(o||1)+" > "+et.len)}function Reader$1(et){this.buf=et,this.pos=0,this.len=et.length}var create_array=typeof Uint8Array<"u"?function et(o){if(o instanceof Uint8Array||Array.isArray(o))return new Reader$1(o);throw Error("illegal buffer")}:function et(o){if(Array.isArray(o))return new Reader$1(o);throw Error("illegal buffer")},create$1=function et(){return util$5.Buffer?function(tt){return(Reader$1.create=function(nt){return util$5.Buffer.isBuffer(nt)?new BufferReader$1(nt):create_array(nt)})(tt)}:create_array};Reader$1.create=create$1();Reader$1.prototype._slice=util$5.Array.prototype.subarray||util$5.Array.prototype.slice;Reader$1.prototype.uint32=function et(){var o=4294967295;return function(){if(o=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(o=(o|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&15)<<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$1.prototype.int32=function et(){return this.uint32()|0};Reader$1.prototype.sint32=function et(){var o=this.uint32();return o>>>1^-(o&1)|0};function readLongVarint(){var et=new LongBits(0,0),o=0;if(this.len-this.pos>4){for(;o<4;++o)if(et.lo=(et.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et;if(et.lo=(et.lo|(this.buf[this.pos]&127)<<28)>>>0,et.hi=(et.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return et;o=0}else{for(;o<3;++o){if(this.pos>=this.len)throw indexOutOfRange(this);if(et.lo=(et.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}return et.lo=(et.lo|(this.buf[this.pos++]&127)<>>0,et}if(this.len-this.pos>4){for(;o<5;++o)if(et.hi=(et.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}else for(;o<5;++o){if(this.pos>=this.len)throw indexOutOfRange(this);if(et.hi=(et.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}throw Error("invalid varint encoding")}Reader$1.prototype.bool=function et(){return this.uint32()!==0};function readFixed32_end(et,o){return(et[o-4]|et[o-3]<<8|et[o-2]<<16|et[o-1]<<24)>>>0}Reader$1.prototype.fixed32=function et(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)};Reader$1.prototype.sfixed32=function et(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.prototype.float=function et(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var o=util$5.float.readFloatLE(this.buf,this.pos);return this.pos+=4,o};Reader$1.prototype.double=function et(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var o=util$5.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,o};Reader$1.prototype.bytes=function et(){var o=this.uint32(),tt=this.pos,rt=this.pos+o;if(rt>this.len)throw indexOutOfRange(this,o);if(this.pos+=o,Array.isArray(this.buf))return this.buf.slice(tt,rt);if(tt===rt){var nt=util$5.Buffer;return nt?nt.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,tt,rt)};Reader$1.prototype.string=function et(){var o=this.bytes();return utf8.read(o,0,o.length)};Reader$1.prototype.skip=function et(o){if(typeof o=="number"){if(this.pos+o>this.len)throw indexOutOfRange(this,o);this.pos+=o}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this};Reader$1.prototype.skipType=function(et){switch(et){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(et=this.uint32()&7)!==4;)this.skipType(et);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+et+" at offset "+this.pos)}return this};Reader$1._configure=function(et){BufferReader$1=et,Reader$1.create=create$1(),BufferReader$1._configure();var o=util$5.Long?"toLong":"toNumber";util$5.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[o](!1)},uint64:function(){return readLongVarint.call(this)[o](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[o](!1)},fixed64:function(){return readFixed64.call(this)[o](!0)},sfixed64:function(){return readFixed64.call(this)[o](!1)}})};var reader_buffer=BufferReader,Reader=reader;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$4=requireMinimal();function BufferReader(et){Reader.call(this,et)}BufferReader._configure=function(){util$4.Buffer&&(BufferReader.prototype._slice=util$4.Buffer.prototype.slice)};BufferReader.prototype.string=function et(){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();var rpc={},service$1=Service$1,util$3=requireMinimal();(Service$1.prototype=Object.create(util$3.EventEmitter.prototype)).constructor=Service$1;function Service$1(et,o,tt){if(typeof et!="function")throw TypeError("rpcImpl must be a function");util$3.EventEmitter.call(this),this.rpcImpl=et,this.requestDelimited=!!o,this.responseDelimited=!!tt}Service$1.prototype.rpcCall=function et(o,tt,rt,nt,ot){if(!nt)throw TypeError("request must be specified");var it=this;if(!ot)return util$3.asPromise(et,it,o,tt,rt,nt);if(!it.rpcImpl){setTimeout(function(){ot(Error("already ended"))},0);return}try{return it.rpcImpl(o,tt[it.requestDelimited?"encodeDelimited":"encode"](nt).finish(),function(at,ct){if(at)return it.emit("error",at,o),ot(at);if(ct===null){it.end(!0);return}if(!(ct instanceof rt))try{ct=rt[it.responseDelimited?"decodeDelimited":"decode"](ct)}catch(lt){return it.emit("error",lt,o),ot(lt)}return it.emit("data",ct,o),ot(null,ct)})}catch(st){it.emit("error",st,o),setTimeout(function(){ot(st)},0);return}};Service$1.prototype.end=function et(o){return this.rpcImpl&&(o||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this};(function(et){var o=et;o.Service=service$1})(rpc);var roots={};(function(et){var o=et;o.build="minimal",o.Writer=writer,o.BufferWriter=writer_buffer,o.Reader=reader,o.BufferReader=reader_buffer,o.util=requireMinimal(),o.rpc=rpc,o.roots=roots,o.configure=tt;function tt(){o.util._configure(),o.Writer._configure(o.BufferWriter),o.Reader._configure(o.BufferReader)}tt()})(indexMinimal);var util$2={exports:{}},codegen_1=codegen;function codegen(et,o){typeof et=="string"&&(o=et,et=void 0);var tt=[];function rt(ot){if(typeof ot!="string"){var it=nt();if(codegen.verbose&&console.log("codegen: "+it),it="return "+it,ot){for(var st=Object.keys(ot),at=new Array(st.length+1),ct=new Array(st.length),lt=0;lt0&&it[ct-1]!==".."?it.splice(--ct,2):st?it.splice(ct,1):++ct:it[ct]==="."?it.splice(ct,1):++ct;return at+it.join("/")};o.resolve=function(ot,it,st){return st||(it=rt(it)),tt(it)?it:(st||(ot=rt(ot)),(ot=ot.replace(/(?:\/|^)[^/]+$/,"")).length?rt(ot+"/"+it):it)}})(path);var types$2={},hasRequiredTypes;function requireTypes(){return hasRequiredTypes||(hasRequiredTypes=1,function(et){var o=et,tt=requireUtil(),rt=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function nt(ot,it){var st=0,at={};for(it|=0;st-1&&this.oneof.splice(st,1),it.partOf=null,this},rt.prototype.onAdd=function(it){et.prototype.onAdd.call(this,it);for(var st=this,at=0;atht)return!0}return!1},at.isReservedName=function(dt,ht){if(dt){for(var mt=0;mt0;){var ft=dt.shift();if(mt.nested&&mt.nested[ft]){if(mt=mt.nested[ft],!(mt instanceof at))throw Error("path conflicts with non-namespace objects")}else mt.add(mt=new at(ft))}return ht&&mt.addJSON(ht),mt},at.prototype.resolveAll=function(){for(var dt=this.nestedArray,ht=0;ht-1)return ft}else if(ft instanceof at&&(ft=ft.lookup(dt.slice(1),ht,!0)))return ft}else for(var pt=0;pt>>3){");for(var st=0;st>>3){")("case 1: k=r.%s(); break",at.keyType)("case 2:"),o.basic[ct]===void 0?it("value=types[%i].decode(r,r.uint32())",st):it("value=r.%s()",ct),it("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),o.long[at.keyType]!==void 0?it('%s[typeof k==="object"?util.longToHash(k):k]=value',lt):it("%s[k]=value",lt)):at.repeated?(it("if(!(%s&&%s.length))",lt,lt)("%s=[]",lt),o.packed[ct]!==void 0&&it("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos>>0",ct,ct);break;case"int32":case"sint32":case"sfixed32":it("m%s=d%s|0",ct,ct);break;case"uint64":ft=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":it("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",ct,ct,ft)('else if(typeof d%s==="string")',ct)("m%s=parseInt(d%s,10)",ct,ct)('else if(typeof d%s==="number")',ct)("m%s=d%s",ct,ct)('else if(typeof d%s==="object")',ct)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",ct,ct,ct,ft?"true":"");break;case"bytes":it('if(typeof d%s==="string")',ct)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",ct,ct,ct)("else if(d%s.length >= 0)",ct)("m%s=d%s",ct,ct);break;case"string":it("m%s=String(d%s)",ct,ct);break;case"bool":it("m%s=Boolean(d%s)",ct,ct);break}}return it}o.fromObject=function(st){var at=st.fieldsArray,ct=rt.codegen(["d"],st.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!at.length)return ct("return new this.ctor");ct("var m=new this.ctor");for(var lt=0;lt>>0,m%s.high>>>0).toNumber(%s):m%s",ct,ct,ct,ct,lt?"true":"",ct);break;case"bytes":it("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",ct,ct,ct,ct,ct);break;default:it("d%s=m%s",ct,ct);break}}return it}o.toObject=function(st){var at=st.fieldsArray.slice().sort(rt.compareFieldsById);if(!at.length)return rt.codegen()("return {}");for(var ct=rt.codegen(["m","o"],st.name+"$toObject")("if(!o)")("o={}")("var d={}"),lt=[],dt=[],ht=[],mt=0;mt-1){var Ot=kt.substring(It);if(Ot in st)return Ot}return null}function vt(kt,It){try{if(nt.isString(It)&&It.charAt(0)==="{"&&(It=JSON.parse(It)),!nt.isString(It))gt.setOptions(It.options).addJSON(It.nested);else{it.filename=kt;var Ot=it(It,gt,ft),Nt,Yt=0;if(Ot.imports)for(;Yt-1)){if(gt.files.push(kt),kt in st){yt?vt(kt,st[kt]):(++Ct,setTimeout(function(){--Ct,vt(kt,st[kt])}));return}if(yt){var Ot;try{Ot=nt.fs.readFileSync(kt).toString("utf8")}catch(Nt){It||bt(Nt);return}vt(kt,Ot)}else++Ct,gt.fetch(kt,function(Nt,Yt){if(--Ct,!!pt){if(Nt){It?Ct||bt(null,gt):bt(Nt);return}vt(kt,Yt)}})}}var Ct=0;nt.isString(mt)&&(mt=[mt]);for(var St=0,At;St-1&&this.deferred.splice(ft,1)}}else if(mt instanceof tt)lt.test(mt.name)&&delete mt.parent[mt.name];else if(mt instanceof et){for(var pt=0;pt0)mt[gt]=ht(mt[gt]||{},ft,pt);else{var yt=mt[gt];yt&&(pt=[].concat(yt).concat(pt)),mt[gt]=pt}return mt}if(typeof ct!="object")throw TypeError("dst must be an object");if(!lt)throw TypeError("path must be specified");return lt=lt.split("."),ht(ct,lt,dt)},Object.defineProperty(et,"decorateRoot",{get:function(){return o.decorated||(o.decorated=new(requireRoot()))}}),util$3.exports}var object,hasRequiredObject;function requireObject(){if(hasRequiredObject)return object;hasRequiredObject=1,object=tt,tt.className="ReflectionObject";var et=requireUtil(),o;function tt(rt,nt){if(!et.isString(rt))throw TypeError("name must be a string");if(nt&&!et.isObject(nt))throw TypeError("options must be an object");this.options=nt,this.parsedOptions=null,this.name=rt,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(tt.prototype,{root:{get:function(){for(var rt=this;rt.parent!==null;)rt=rt.parent;return rt}},fullName:{get:function(){for(var rt=[this.name],nt=this.parent;nt;)rt.unshift(nt.name),nt=nt.parent;return rt.join(".")}}}),tt.prototype.toJSON=function(){throw Error()},tt.prototype.onAdd=function(nt){this.parent&&this.parent!==nt&&this.parent.remove(this),this.parent=nt,this.resolved=!1;var ot=nt.root;ot instanceof o&&ot._handleAdd(this)},tt.prototype.onRemove=function(nt){var ot=nt.root;ot instanceof o&&ot._handleRemove(this),this.parent=null,this.resolved=!1},tt.prototype.resolve=function(){return this.resolved?this:(this.root instanceof o&&(this.resolved=!0),this)},tt.prototype.getOption=function(nt){if(this.options)return this.options[nt]},tt.prototype.setOption=function(nt,ot,it){return(!it||!this.options||this.options[nt]===void 0)&&((this.options||(this.options={}))[nt]=ot),this},tt.prototype.setParsedOption=function(nt,ot,it){this.parsedOptions||(this.parsedOptions=[]);var st=this.parsedOptions;if(it){var at=st.find(function(dt){return Object.prototype.hasOwnProperty.call(dt,nt)});if(at){var ct=at[nt];et.setProperty(ct,it,ot)}else at={},at[nt]=et.setProperty({},it,ot),st.push(at)}else{var lt={};lt[nt]=ot,st.push(lt)}return this},tt.prototype.setOptions=function(nt,ot){if(nt)for(var it=Object.keys(nt),st=0;st>>0,(it.id<<3|4)>>>0):ot("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",st,at,(it.id<<3|2)>>>0)}function nt(ot){for(var it=tt.codegen(["m","w"],ot.name+"$encode")("if(!w)")("w=Writer.create()"),st,at,ct=ot.fieldsArray.slice().sort(tt.compareFieldsById),st=0;st>>0,8|o.mapKey[lt.keyType],lt.keyType),mt===void 0?it("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",dt,at):it(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|mt,ht,at),it("}")("}")):lt.repeated?(it("if(%s!=null&&%s.length){",at,at),lt.packed&&o.packed[ht]!==void 0?it("w.uint32(%i).fork()",(lt.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",at)("w.%s(%s[i])",ht,at)("w.ldelim()"):(it("for(var i=0;i<%s.length;++i)",at),mt===void 0?rt(it,lt,dt,at+"[i]"):it("w.uint32(%i).%s(%s[i])",(lt.id<<3|mt)>>>0,ht,at)),it("}")):(lt.optional&&it("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",at,lt.name),mt===void 0?rt(it,lt,dt,at):it("w.uint32(%i).%s(%s)",(lt.id<<3|mt)>>>0,ht,at))}return it("return w")}return encoder_1}var protobuf$2=indexLight.exports=indexMinimal;protobuf$2.build="light";function load(et,o,tt){return typeof o=="function"?(tt=o,o=new protobuf$2.Root):o||(o=new protobuf$2.Root),o.load(et,tt)}protobuf$2.load=load;function loadSync(et,o){return o||(o=new protobuf$2.Root),o.loadSync(et)}protobuf$2.loadSync=loadSync;protobuf$2.encoder=requireEncoder();protobuf$2.decoder=requireDecoder();protobuf$2.verifier=requireVerifier();protobuf$2.converter=requireConverter();protobuf$2.ReflectionObject=requireObject();protobuf$2.Namespace=requireNamespace();protobuf$2.Root=requireRoot();protobuf$2.Enum=require_enum();protobuf$2.Type=requireType();protobuf$2.Field=requireField();protobuf$2.OneOf=requireOneof();protobuf$2.MapField=requireMapfield();protobuf$2.Service=requireService();protobuf$2.Method=requireMethod();protobuf$2.Message=message;protobuf$2.wrappers=wrappers;protobuf$2.types=requireTypes();protobuf$2.util=requireUtil();protobuf$2.ReflectionObject._configure(protobuf$2.Root);protobuf$2.Namespace._configure(protobuf$2.Type,protobuf$2.Service,protobuf$2.Enum);protobuf$2.Root._configure(protobuf$2.Type);protobuf$2.Field._configure(protobuf$2.Type);var indexLightExports=indexLight.exports,tokenize_1=tokenize$1,delimRe=/[\s{}=;:[\],'"()<>]/g,stringDoubleRe=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,stringSingleRe=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,setCommentRe=/^ *[*/]+ */,setCommentAltRe=/^\s*\*?\/*/,setCommentSplitRe=/\n/g,whitespaceRe=/\s/,unescapeRe=/\\(.?)/g,unescapeMap={0:"\0",r:"\r",n:` -`,t:" "};function unescape$1(et){return et.replace(unescapeRe,function(o,tt){switch(tt){case"\\":case"":return tt;default:return unescapeMap[tt]||""}})}tokenize$1.unescape=unescape$1;function tokenize$1(et,o){et=et.toString();var tt=0,rt=et.length,nt=1,ot=0,it={},st=[],at=null;function ct(vt){return Error("illegal "+vt+" (line "+nt+")")}function lt(){var vt=at==="'"?stringSingleRe:stringDoubleRe;vt.lastIndex=tt-1;var Et=vt.exec(et);if(!Et)throw ct("string");return tt=vt.lastIndex,gt(at),at=null,unescape$1(Et[1])}function dt(vt){return et.charAt(vt)}function ht(vt,Et,Ct){var St={type:et.charAt(vt++),lineEmpty:!1,leading:Ct},At;o?At=2:At=3;var kt=vt-At,It;do if(--kt<0||(It=et.charAt(kt))===` -`){St.lineEmpty=!0;break}while(It===" "||It===" ");for(var Ot=et.substring(vt,Et).split(setCommentSplitRe),Nt=0;Nt0&&it[ct-1]!==".."?it.splice(--ct,2):st?it.splice(ct,1):++ct:it[ct]==="."?it.splice(ct,1):++ct;return at+it.join("/")};o.resolve=function(ot,it,st){return st||(it=rt(it)),tt(it)?it:(st||(ot=rt(ot)),(ot=ot.replace(/(?:\/|^)[^/]+$/,"")).length?rt(ot+"/"+it):it)}})(path);var types$2={},hasRequiredTypes;function requireTypes(){return hasRequiredTypes||(hasRequiredTypes=1,function(et){var o=et,tt=requireUtil(),rt=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function nt(ot,it){var st=0,at={};for(it|=0;st-1&&this.oneof.splice(st,1),it.partOf=null,this},rt.prototype.onAdd=function(it){et.prototype.onAdd.call(this,it);for(var st=this,at=0;atht)return!0}return!1},at.isReservedName=function(dt,ht){if(dt){for(var mt=0;mt0;){var ft=dt.shift();if(mt.nested&&mt.nested[ft]){if(mt=mt.nested[ft],!(mt instanceof at))throw Error("path conflicts with non-namespace objects")}else mt.add(mt=new at(ft))}return ht&&mt.addJSON(ht),mt},at.prototype.resolveAll=function(){for(var dt=this.nestedArray,ht=0;ht-1)return ft}else if(ft instanceof at&&(ft=ft.lookup(dt.slice(1),ht,!0)))return ft}else for(var pt=0;pt>>3){");for(var st=0;st>>3){")("case 1: k=r.%s(); break",at.keyType)("case 2:"),o.basic[ct]===void 0?it("value=types[%i].decode(r,r.uint32())",st):it("value=r.%s()",ct),it("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),o.long[at.keyType]!==void 0?it('%s[typeof k==="object"?util.longToHash(k):k]=value',lt):it("%s[k]=value",lt)):at.repeated?(it("if(!(%s&&%s.length))",lt,lt)("%s=[]",lt),o.packed[ct]!==void 0&&it("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos>>0",ct,ct);break;case"int32":case"sint32":case"sfixed32":it("m%s=d%s|0",ct,ct);break;case"uint64":ft=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":it("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",ct,ct,ft)('else if(typeof d%s==="string")',ct)("m%s=parseInt(d%s,10)",ct,ct)('else if(typeof d%s==="number")',ct)("m%s=d%s",ct,ct)('else if(typeof d%s==="object")',ct)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",ct,ct,ct,ft?"true":"");break;case"bytes":it('if(typeof d%s==="string")',ct)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",ct,ct,ct)("else if(d%s.length >= 0)",ct)("m%s=d%s",ct,ct);break;case"string":it("m%s=String(d%s)",ct,ct);break;case"bool":it("m%s=Boolean(d%s)",ct,ct);break}}return it}o.fromObject=function(st){var at=st.fieldsArray,ct=rt.codegen(["d"],st.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!at.length)return ct("return new this.ctor");ct("var m=new this.ctor");for(var lt=0;lt>>0,m%s.high>>>0).toNumber(%s):m%s",ct,ct,ct,ct,lt?"true":"",ct);break;case"bytes":it("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",ct,ct,ct,ct,ct);break;default:it("d%s=m%s",ct,ct);break}}return it}o.toObject=function(st){var at=st.fieldsArray.slice().sort(rt.compareFieldsById);if(!at.length)return rt.codegen()("return {}");for(var ct=rt.codegen(["m","o"],st.name+"$toObject")("if(!o)")("o={}")("var d={}"),lt=[],dt=[],ht=[],mt=0;mt-1){var Nt=kt.substring(It);if(Nt in st)return Nt}return null}function vt(kt,It){try{if(nt.isString(It)&&It.charAt(0)==="{"&&(It=JSON.parse(It)),!nt.isString(It))yt.setOptions(It.options).addJSON(It.nested);else{it.filename=kt;var Nt=it(It,yt,ft),Lt,Mt=0;if(Nt.imports)for(;Mt-1)){if(yt.files.push(kt),kt in st){gt?vt(kt,st[kt]):(++Ct,setTimeout(function(){--Ct,vt(kt,st[kt])}));return}if(gt){var Nt;try{Nt=nt.fs.readFileSync(kt).toString("utf8")}catch(Lt){It||bt(Lt);return}vt(kt,Nt)}else++Ct,yt.fetch(kt,function(Lt,Mt){if(--Ct,!!pt){if(Lt){It?Ct||bt(null,yt):bt(Lt);return}vt(kt,Mt)}})}}var Ct=0;nt.isString(mt)&&(mt=[mt]);for(var St=0,At;St-1&&this.deferred.splice(ft,1)}}else if(mt instanceof tt)lt.test(mt.name)&&delete mt.parent[mt.name];else if(mt instanceof et){for(var pt=0;pt0)mt[yt]=ht(mt[yt]||{},ft,pt);else{var gt=mt[yt];gt&&(pt=[].concat(gt).concat(pt)),mt[yt]=pt}return mt}if(typeof ct!="object")throw TypeError("dst must be an object");if(!lt)throw TypeError("path must be specified");return lt=lt.split("."),ht(ct,lt,dt)},Object.defineProperty(et,"decorateRoot",{get:function(){return o.decorated||(o.decorated=new(requireRoot()))}}),util$2.exports}var object,hasRequiredObject;function requireObject(){if(hasRequiredObject)return object;hasRequiredObject=1,object=tt,tt.className="ReflectionObject";var et=requireUtil(),o;function tt(rt,nt){if(!et.isString(rt))throw TypeError("name must be a string");if(nt&&!et.isObject(nt))throw TypeError("options must be an object");this.options=nt,this.parsedOptions=null,this.name=rt,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(tt.prototype,{root:{get:function(){for(var rt=this;rt.parent!==null;)rt=rt.parent;return rt}},fullName:{get:function(){for(var rt=[this.name],nt=this.parent;nt;)rt.unshift(nt.name),nt=nt.parent;return rt.join(".")}}}),tt.prototype.toJSON=function(){throw Error()},tt.prototype.onAdd=function(nt){this.parent&&this.parent!==nt&&this.parent.remove(this),this.parent=nt,this.resolved=!1;var ot=nt.root;ot instanceof o&&ot._handleAdd(this)},tt.prototype.onRemove=function(nt){var ot=nt.root;ot instanceof o&&ot._handleRemove(this),this.parent=null,this.resolved=!1},tt.prototype.resolve=function(){return this.resolved?this:(this.root instanceof o&&(this.resolved=!0),this)},tt.prototype.getOption=function(nt){if(this.options)return this.options[nt]},tt.prototype.setOption=function(nt,ot,it){return(!it||!this.options||this.options[nt]===void 0)&&((this.options||(this.options={}))[nt]=ot),this},tt.prototype.setParsedOption=function(nt,ot,it){this.parsedOptions||(this.parsedOptions=[]);var st=this.parsedOptions;if(it){var at=st.find(function(dt){return Object.prototype.hasOwnProperty.call(dt,nt)});if(at){var ct=at[nt];et.setProperty(ct,it,ot)}else at={},at[nt]=et.setProperty({},it,ot),st.push(at)}else{var lt={};lt[nt]=ot,st.push(lt)}return this},tt.prototype.setOptions=function(nt,ot){if(nt)for(var it=Object.keys(nt),st=0;st>>0,(it.id<<3|4)>>>0):ot("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",st,at,(it.id<<3|2)>>>0)}function nt(ot){for(var it=tt.codegen(["m","w"],ot.name+"$encode")("if(!w)")("w=Writer.create()"),st,at,ct=ot.fieldsArray.slice().sort(tt.compareFieldsById),st=0;st>>0,8|o.mapKey[lt.keyType],lt.keyType),mt===void 0?it("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",dt,at):it(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|mt,ht,at),it("}")("}")):lt.repeated?(it("if(%s!=null&&%s.length){",at,at),lt.packed&&o.packed[ht]!==void 0?it("w.uint32(%i).fork()",(lt.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",at)("w.%s(%s[i])",ht,at)("w.ldelim()"):(it("for(var i=0;i<%s.length;++i)",at),mt===void 0?rt(it,lt,dt,at+"[i]"):it("w.uint32(%i).%s(%s[i])",(lt.id<<3|mt)>>>0,ht,at)),it("}")):(lt.optional&&it("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",at,lt.name),mt===void 0?rt(it,lt,dt,at):it("w.uint32(%i).%s(%s)",(lt.id<<3|mt)>>>0,ht,at))}return it("return w")}return encoder_1}var protobuf$2=indexLight.exports=indexMinimal;protobuf$2.build="light";function load(et,o,tt){return typeof o=="function"?(tt=o,o=new protobuf$2.Root):o||(o=new protobuf$2.Root),o.load(et,tt)}protobuf$2.load=load;function loadSync(et,o){return o||(o=new protobuf$2.Root),o.loadSync(et)}protobuf$2.loadSync=loadSync;protobuf$2.encoder=requireEncoder();protobuf$2.decoder=requireDecoder();protobuf$2.verifier=requireVerifier();protobuf$2.converter=requireConverter();protobuf$2.ReflectionObject=requireObject();protobuf$2.Namespace=requireNamespace();protobuf$2.Root=requireRoot();protobuf$2.Enum=require_enum();protobuf$2.Type=requireType();protobuf$2.Field=requireField();protobuf$2.OneOf=requireOneof();protobuf$2.MapField=requireMapfield();protobuf$2.Service=requireService();protobuf$2.Method=requireMethod();protobuf$2.Message=message;protobuf$2.wrappers=wrappers;protobuf$2.types=requireTypes();protobuf$2.util=requireUtil();protobuf$2.ReflectionObject._configure(protobuf$2.Root);protobuf$2.Namespace._configure(protobuf$2.Type,protobuf$2.Service,protobuf$2.Enum);protobuf$2.Root._configure(protobuf$2.Type);protobuf$2.Field._configure(protobuf$2.Type);var indexLightExports=indexLight.exports,tokenize_1=tokenize$1,delimRe=/[\s{}=;:[\],'"()<>]/g,stringDoubleRe=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,stringSingleRe=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,setCommentRe=/^ *[*/]+ */,setCommentAltRe=/^\s*\*?\/*/,setCommentSplitRe=/\n/g,whitespaceRe=/\s/,unescapeRe=/\\(.?)/g,unescapeMap={0:"\0",r:"\r",n:` +`,t:" "};function unescape$1(et){return et.replace(unescapeRe,function(o,tt){switch(tt){case"\\":case"":return tt;default:return unescapeMap[tt]||""}})}tokenize$1.unescape=unescape$1;function tokenize$1(et,o){et=et.toString();var tt=0,rt=et.length,nt=1,ot=0,it={},st=[],at=null;function ct(vt){return Error("illegal "+vt+" (line "+nt+")")}function lt(){var vt=at==="'"?stringSingleRe:stringDoubleRe;vt.lastIndex=tt-1;var Et=vt.exec(et);if(!Et)throw ct("string");return tt=vt.lastIndex,yt(at),at=null,unescape$1(Et[1])}function dt(vt){return et.charAt(vt)}function ht(vt,Et,Ct){var St={type:et.charAt(vt++),lineEmpty:!1,leading:Ct},At;o?At=2:At=3;var kt=vt-At,It;do if(--kt<0||(It=et.charAt(kt))===` +`){St.lineEmpty=!0;break}while(It===" "||It===" ");for(var Nt=et.substring(vt,Et).split(setCommentSplitRe),Lt=0;Lt0)return st.shift();if(at)return lt();var vt,Et,Ct,St,At,kt=tt===0;do{if(tt===rt)return null;for(vt=!1;whitespaceRe.test(Ct=dt(tt));)if(Ct===` `&&(kt=!0,++nt),++tt===rt)return null;if(dt(tt)==="/"){if(++tt===rt)throw ct("comment");if(dt(tt)==="/")if(o){if(St=tt,At=!1,mt(tt-1)){At=!0;do if(tt=ft(tt),tt===rt||(tt++,!kt))break;while(mt(tt))}else tt=Math.min(rt,ft(tt)+1);At&&(ht(St,tt,kt),kt=!0),nt++,vt=!0}else{for(At=dt(St=tt+1)==="/";dt(++tt)!==` `;)if(tt===rt)return null;++tt,At&&(ht(St,tt-1,kt),kt=!0),++nt,vt=!0}else if((Ct=dt(tt))==="*"){St=tt+1,At=o||dt(St)==="*";do{if(Ct===` -`&&++nt,++tt===rt)throw ct("comment");Et=Ct,Ct=dt(tt)}while(Et!=="*"||Ct!=="/");++tt,At&&(ht(St,tt-2,kt),kt=!0),vt=!0}else return"/"}}while(vt);var It=tt;delimRe.lastIndex=0;var Ot=delimRe.test(dt(It++));if(!Ot)for(;It");var Ut=ot();if(!nameRe$1.test(Ut))throw bt(Ut,"name");at("=");var Zt=new MapField(yt(Ut),St(ot()),Rt,Mt);Nt(Zt,function(ar){if(ar==="option")jt(Zt,ar),at(";");else throw bt(ar)},function(){Gt(Zt)}),Jt.add(Zt)}function Vt(Jt,Rt){if(!nameRe$1.test(Rt=ot()))throw bt(Rt,"name");var Mt=new OneOf(yt(Rt));Nt(Mt,function(Zt){Zt==="option"?(jt(Mt,Zt),at(";")):(it(Zt),Ft(Mt,"optional"))}),Jt.add(Mt)}function Bt(Jt,Rt){if(!nameRe$1.test(Rt=ot()))throw bt(Rt,"name");var Mt=new Enum(Rt);Nt(Mt,function(Zt){switch(Zt){case"option":jt(Mt,Zt),at(";");break;case"reserved":Et(Mt.reserved||(Mt.reserved=[]),!0);break;default:Wt(Mt,Zt)}}),Jt.add(Mt)}function Wt(Jt,Rt){if(!nameRe$1.test(Rt))throw bt(Rt,"name");at("=");var Mt=St(ot(),!0),Ut={options:void 0};Ut.setOption=function(Zt,nr){this.options===void 0&&(this.options={}),this.options[Zt]=nr},Nt(Ut,function(nr){if(nr==="option")jt(Ut,nr),at(";");else throw bt(nr)},function(){Gt(Ut)}),Jt.add(Rt,Mt,Ut.comment,Ut.options)}function jt(Jt,Rt){var Mt=at("(",!0);if(!typeRefRe.test(Rt=ot()))throw bt(Rt,"name");var Ut=Rt,Zt=Ut,nr;Mt&&(at(")"),Ut="("+Ut+")",Zt=Ut,Rt=st(),fqTypeRefRe.test(Rt)&&(nr=Rt.slice(1),Ut+=Rt,ot())),at("=");var ar=Xt(Jt,Ut);Pt(Jt,Zt,ar,nr)}function Xt(Jt,Rt){if(at("{",!0)){for(var Mt={};!at("}",!0);){if(!nameRe$1.test(rr=ot()))throw bt(rr,"name");if(rr===null)throw bt(rr,"end of input");var Ut,Zt=rr;if(at(":",!0),st()==="{")Ut=Xt(Jt,Rt+"."+rr);else if(st()==="["){Ut=[];var nr;if(at("[",!0)){do nr=vt(),Ut.push(nr);while(at(",",!0));at("]"),typeof nr<"u"&&Kt(Jt,Rt+"."+rr,nr)}}else Ut=vt(),Kt(Jt,Rt+"."+rr,Ut);var ar=Mt[Zt];ar&&(Ut=[].concat(ar).concat(Ut)),Mt[Zt]=Ut,at(",",!0),at(";",!0)}return Mt}var dr=vt();return Kt(Jt,Rt,dr),dr}function Kt(Jt,Rt,Mt){Jt.setOption&&Jt.setOption(Rt,Mt)}function Pt(Jt,Rt,Mt,Ut){Jt.setParsedOption&&Jt.setParsedOption(Rt,Mt,Ut)}function Gt(Jt){if(at("[",!0)){do jt(Jt,"option");while(at(",",!0));at("]")}return Jt}function tr(Jt,Rt){if(!nameRe$1.test(Rt=ot()))throw bt(Rt,"service name");var Mt=new Service(Rt);Nt(Mt,function(Zt){if(!Ot(Mt,Zt))if(Zt==="rpc")zt(Mt,Zt);else throw bt(Zt)}),Jt.add(Mt)}function zt(Jt,Rt){var Mt=ct(),Ut=Rt;if(!nameRe$1.test(Rt=ot()))throw bt(Rt,"name");var Zt=Rt,nr,ar,dr,cr;if(at("("),at("stream",!0)&&(ar=!0),!typeRefRe.test(Rt=ot())||(nr=Rt,at(")"),at("returns"),at("("),at("stream",!0)&&(cr=!0),!typeRefRe.test(Rt=ot())))throw bt(Rt);dr=Rt,at(")");var yr=new Method(Zt,Ut,nr,dr,ar,cr);yr.comment=Mt,Nt(yr,function(gr){if(gr==="option")jt(yr,gr),at(";");else throw bt(gr)}),Jt.add(yr)}function lr(Jt,Rt){if(!typeRefRe.test(Rt=ot()))throw bt(Rt,"reference");var Mt=Rt;Nt(null,function(Zt){switch(Zt){case"required":case"repeated":Ft(Jt,Zt,Mt);break;case"optional":pt?Ft(Jt,"proto3_optional",Mt):Ft(Jt,"optional",Mt);break;default:if(!pt||!typeRefRe.test(Zt))throw bt(Zt);it(Zt),Ft(Jt,"optional",Mt);break}})}for(var rr;(rr=ot())!==null;)switch(rr){case"package":if(!lt)throw bt(rr);At();break;case"import":if(!lt)throw bt(rr);kt();break;case"syntax":if(!lt)throw bt(rr);It();break;case"option":jt(gt,rr),at(";");break;default:if(Ot(gt,rr)){lt=!1;continue}throw bt(rr)}return parse$1.filename=null,{package:dt,imports:ht,weakImports:mt,syntax:ft,root:o}}var common_1=common,commonRe=/\/|\./;function common(et,o){commonRe.test(et)||(et="google/protobuf/"+et+".proto",o={nested:{google:{nested:{protobuf:{nested:o}}}}}),common[et]=o}common("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}});var timeType;common("duration",{Duration:timeType={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}});common("timestamp",{Timestamp:timeType});common("empty",{Empty:{fields:{}}});common("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}});common("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}});common("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}});common.get=function et(o){return common[o]||null};var protobuf$1=src.exports=indexLightExports;protobuf$1.build="full";protobuf$1.tokenize=tokenize_1;protobuf$1.parse=parse_1;protobuf$1.common=common_1;protobuf$1.Root._configure(protobuf$1.Type,protobuf$1.parse,protobuf$1.common);var srcExports=src.exports,protobufjs=srcExports;const protobuf=getDefaultExportFromCjs(protobufjs),WAKU_NODE_OPTIONS={defaultBootstrap:!0,nodeToUse:{store:"/dns4/store-02.ac-cn-hongkong-c.status.staging.status.im/tcp/443/wss/p2p/16Uiu2HAmU7xtcwytXpGpeDrfyhJkiFvTkQbLB9upL5MXPLGceG9K"}},contentTopic="/buddybook-dogfood/1/chain/proto",encoder=createEncoder({contentTopic,ephemeral:!1}),decoder=createDecoder(contentTopic),block=new protobuf.Type("block").add(new protobuf.Field("chainUUID",1,"string")).add(new protobuf.Field("blockUUID",2,"string")).add(new protobuf.Field("title",3,"string")).add(new protobuf.Field("description",4,"string")).add(new protobuf.Field("signedMessage",5,"string")).add(new protobuf.Field("timestamp",6,"uint64")).add(new protobuf.Field("signatures",7,"string","repeated")).add(new protobuf.Field("parentBlockUUID",8,"string"));function createMessage({chainUUID:et,blockUUID:o,title:tt,description:rt,signedMessage:nt,timestamp:ot,signatures:it,parentBlockUUID:st}){const at=block.create({chainUUID:et,blockUUID:o,title:tt,description:rt,signedMessage:nt,timestamp:ot,signatures:it.map(lt=>JSON.stringify(lt)),parentBlockUUID:st});return{payload:block.encode(at).finish()}}async function*getMessagesFromStore(et){console.time("getMessagesFromStore");for await(const o of et.store.queryGenerator([decoder])){const tt=await Promise.all(o);for(const rt of tt){if(console.log(rt),!(rt!=null&&rt.payload))continue;const nt=block.decode(rt.payload);nt.signatures=nt.signatures.map(ot=>JSON.parse(ot)),yield nt}}console.timeEnd("getMessagesFromStore")}async function subscribeToFilter(et,o){const{error:tt,subscription:rt,results:nt}=await et.filter.subscribe([decoder],ot=>{if(console.log("message received from filter",ot),ot.payload){const it=block.decode(ot.payload);it.signatures=it.signatures.map(st=>JSON.parse(st)),o(it)}},{forceUseAllPeers:!0});if(console.log("results",nt),tt&&console.log("Error subscribing to filter",tt),!rt||tt||nt.successes.length===0||nt.failures.length>0)throw new Error("Failed to subscribe to filter")}function useWalletPrompt(){const{isConnected:et}=useAccount(),{connect:o,connectors:tt}=useConnect$1();return{ensureWalletConnected:()=>{if(!et){const nt=tt[0];return nt&&o({connector:nt}),!1}return!0}}}const DEFAULT_FORM_DATA={title:"Devcon24 DeFi Dynamo",description:"A revolutionary blockchain for Devcon 24, focusing on scalable DeFi solutions and cross-chain interoperability.",uuid:v4()},ChainCreationForm=()=>{const[et,o]=reactExports.useState(DEFAULT_FORM_DATA),[tt,rt]=reactExports.useState({}),[nt,ot]=reactExports.useState(!1),[it,st]=reactExports.useState(!1),[at,ct]=reactExports.useState(!1),[lt,dt]=reactExports.useState(null),[ht,mt]=reactExports.useState(null),[ft,pt]=reactExports.useState(null),{node:gt}=useWaku(),{address:yt}=useAccount(),{signMessage:bt}=useSignMessage({mutation:{async onSuccess(kt){if(!yt||!gt)return;mt(kt);const It=v4();pt(It);const Ot=createMessage({chainUUID:et.uuid,blockUUID:It,title:et.title,description:et.description,signedMessage:kt,timestamp:Date.now(),signatures:[{address:yt,signature:kt}],parentBlockUUID:null});await(gt==null?void 0:gt.lightPush.send(encoder,Ot)),ct(!0),st(!1)},onError(kt){console.error("Error signing message:",kt),st(!1),dt("Error signing message. Please try again.")}}}),{ensureWalletConnected:xt}=useWalletPrompt(),vt=kt=>{const{name:It,value:Ot}=kt.target;o(Nt=>({...Nt,[It]:Ot})),tt[It]&&rt(Nt=>({...Nt,[It]:void 0}))},Et=()=>{const kt={};return et.title.trim()||(kt.title="Title is required"),et.description.trim()||(kt.description="Description is required"),rt(kt),Object.keys(kt).length===0},Ct=kt=>{kt.preventDefault(),xt()&&Et()&&ot(!0)},St=async()=>{st(!0),dt(null);const kt=`Create Chain: +`&&++nt,++tt===rt)throw ct("comment");Et=Ct,Ct=dt(tt)}while(Et!=="*"||Ct!=="/");++tt,At&&(ht(St,tt-2,kt),kt=!0),vt=!0}else return"/"}}while(vt);var It=tt;delimRe.lastIndex=0;var Nt=delimRe.test(dt(It++));if(!Nt)for(;It");var Bt=ot();if(!nameRe$1.test(Bt))throw bt(Bt,"name");at("=");var Vt=new MapField(gt(Bt),St(ot()),tr,_t);Lt(Vt,function(ar){if(ar==="option")Pt(Vt,ar),at(";");else throw bt(ar)},function(){Gt(Vt)}),Jt.add(Vt)}function Wt(Jt,tr){if(!nameRe$1.test(tr=ot()))throw bt(tr,"name");var _t=new OneOf(gt(tr));Lt(_t,function(Vt){Vt==="option"?(Pt(_t,Vt),at(";")):(it(Vt),zt(_t,"optional"))}),Jt.add(_t)}function Ft(Jt,tr){if(!nameRe$1.test(tr=ot()))throw bt(tr,"name");var _t=new Enum(tr);Lt(_t,function(Vt){switch(Vt){case"option":Pt(_t,Vt),at(";");break;case"reserved":Et(_t.reserved||(_t.reserved=[]),!0);break;default:qt(_t,Vt)}}),Jt.add(_t)}function qt(Jt,tr){if(!nameRe$1.test(tr))throw bt(tr,"name");at("=");var _t=St(ot(),!0),Bt={options:void 0};Bt.setOption=function(Vt,er){this.options===void 0&&(this.options={}),this.options[Vt]=er},Lt(Bt,function(er){if(er==="option")Pt(Bt,er),at(";");else throw bt(er)},function(){Gt(Bt)}),Jt.add(tr,_t,Bt.comment,Bt.options)}function Pt(Jt,tr){var _t=at("(",!0);if(!typeRefRe.test(tr=ot()))throw bt(tr,"name");var Bt=tr,Vt=Bt,er;_t&&(at(")"),Bt="("+Bt+")",Vt=Bt,tr=st(),fqTypeRefRe.test(tr)&&(er=tr.slice(1),Bt+=tr,ot())),at("=");var ar=Yt(Jt,Bt);jt(Jt,Vt,ar,er)}function Yt(Jt,tr){if(at("{",!0)){for(var _t={};!at("}",!0);){if(!nameRe$1.test(Zt=ot()))throw bt(Zt,"name");if(Zt===null)throw bt(Zt,"end of input");var Bt,Vt=Zt;if(at(":",!0),st()==="{")Bt=Yt(Jt,tr+"."+Zt);else if(st()==="["){Bt=[];var er;if(at("[",!0)){do er=vt(),Bt.push(er);while(at(",",!0));at("]"),typeof er<"u"&&Qt(Jt,tr+"."+Zt,er)}}else Bt=vt(),Qt(Jt,tr+"."+Zt,Bt);var ar=_t[Vt];ar&&(Bt=[].concat(ar).concat(Bt)),_t[Vt]=Bt,at(",",!0),at(";",!0)}return _t}var ur=vt();return Qt(Jt,tr,ur),ur}function Qt(Jt,tr,_t){Jt.setOption&&Jt.setOption(tr,_t)}function jt(Jt,tr,_t,Bt){Jt.setParsedOption&&Jt.setParsedOption(tr,_t,Bt)}function Gt(Jt){if(at("[",!0)){do Pt(Jt,"option");while(at(",",!0));at("]")}return Jt}function rr(Jt,tr){if(!nameRe$1.test(tr=ot()))throw bt(tr,"service name");var _t=new Service(tr);Lt(_t,function(Vt){if(!Nt(_t,Vt))if(Vt==="rpc")Ht(_t,Vt);else throw bt(Vt)}),Jt.add(_t)}function Ht(Jt,tr){var _t=ct(),Bt=tr;if(!nameRe$1.test(tr=ot()))throw bt(tr,"name");var Vt=tr,er,ar,ur,cr;if(at("("),at("stream",!0)&&(ar=!0),!typeRefRe.test(tr=ot())||(er=tr,at(")"),at("returns"),at("("),at("stream",!0)&&(cr=!0),!typeRefRe.test(tr=ot())))throw bt(tr);ur=tr,at(")");var hr=new Method(Vt,Bt,er,ur,ar,cr);hr.comment=_t,Lt(hr,function(pr){if(pr==="option")Pt(hr,pr),at(";");else throw bt(pr)}),Jt.add(hr)}function dr(Jt,tr){if(!typeRefRe.test(tr=ot()))throw bt(tr,"reference");var _t=tr;Lt(null,function(Vt){switch(Vt){case"required":case"repeated":zt(Jt,Vt,_t);break;case"optional":pt?zt(Jt,"proto3_optional",_t):zt(Jt,"optional",_t);break;default:if(!pt||!typeRefRe.test(Vt))throw bt(Vt);it(Vt),zt(Jt,"optional",_t);break}})}for(var Zt;(Zt=ot())!==null;)switch(Zt){case"package":if(!lt)throw bt(Zt);At();break;case"import":if(!lt)throw bt(Zt);kt();break;case"syntax":if(!lt)throw bt(Zt);It();break;case"option":Pt(yt,Zt),at(";");break;default:if(Nt(yt,Zt)){lt=!1;continue}throw bt(Zt)}return parse$1.filename=null,{package:dt,imports:ht,weakImports:mt,syntax:ft,root:o}}var common_1=common,commonRe=/\/|\./;function common(et,o){commonRe.test(et)||(et="google/protobuf/"+et+".proto",o={nested:{google:{nested:{protobuf:{nested:o}}}}}),common[et]=o}common("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}});var timeType;common("duration",{Duration:timeType={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}});common("timestamp",{Timestamp:timeType});common("empty",{Empty:{fields:{}}});common("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}});common("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}});common("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}});common.get=function et(o){return common[o]||null};var protobuf$1=src.exports=indexLightExports;protobuf$1.build="full";protobuf$1.tokenize=tokenize_1;protobuf$1.parse=parse_1;protobuf$1.common=common_1;protobuf$1.Root._configure(protobuf$1.Type,protobuf$1.parse,protobuf$1.common);var srcExports=src.exports,protobufjs=srcExports;const protobuf=getDefaultExportFromCjs(protobufjs),contentTopic="/buddybook-dogfood/1/chain/proto",encoder=createEncoder({contentTopic,ephemeral:!1}),decoder=createDecoder(contentTopic),block=new protobuf.Type("block").add(new protobuf.Field("chainUUID",1,"string")).add(new protobuf.Field("blockUUID",2,"string")).add(new protobuf.Field("title",3,"string")).add(new protobuf.Field("description",4,"string")).add(new protobuf.Field("signedMessage",5,"string")).add(new protobuf.Field("timestamp",6,"uint64")).add(new protobuf.Field("signatures",7,"string","repeated")).add(new protobuf.Field("parentBlockUUID",8,"string"));function createMessage({chainUUID:et,blockUUID:o,title:tt,description:rt,signedMessage:nt,timestamp:ot,signatures:it,parentBlockUUID:st}){const at=block.create({chainUUID:et,blockUUID:o,title:tt,description:rt,signedMessage:nt,timestamp:ot,signatures:it.map(lt=>JSON.stringify(lt)),parentBlockUUID:st});return{payload:block.encode(at).finish()}}async function*getMessagesFromStore(et){console.time("getMessagesFromStore");for await(const o of et.store.queryGenerator([decoder])){const tt=await Promise.all(o);for(const rt of tt){if(console.log(rt),!(rt!=null&&rt.payload))continue;const nt=block.decode(rt.payload);nt.signatures=nt.signatures.map(ot=>JSON.parse(ot)),yield nt}}console.timeEnd("getMessagesFromStore")}async function subscribeToFilter(et,o){const{error:tt,subscription:rt,results:nt}=await et.filter.subscribe([decoder],ot=>{if(console.log("message received from filter",ot),ot.payload){const it=block.decode(ot.payload);it.signatures=it.signatures.map(st=>JSON.parse(st)),o(it)}},{forceUseAllPeers:!0});if(console.log("results",nt),tt&&console.log("Error subscribing to filter",tt),!rt||tt||nt.successes.length===0||nt.failures.length>0)throw new Error("Failed to subscribe to filter")}function useWalletPrompt(){const{isConnected:et}=useAccount(),{connect:o,connectors:tt}=useConnect$1();return{ensureWalletConnected:()=>{if(!et){const nt=tt[0];return nt&&o({connector:nt}),!1}return!0}}}const DEFAULT_FORM_DATA={title:"Devcon24 DeFi Dynamo",description:"A revolutionary blockchain for Devcon 24, focusing on scalable DeFi solutions and cross-chain interoperability.",uuid:v4()},ChainCreationForm=()=>{const[et,o]=reactExports.useState(DEFAULT_FORM_DATA),[tt,rt]=reactExports.useState({}),[nt,ot]=reactExports.useState(!1),[it,st]=reactExports.useState(!1),[at,ct]=reactExports.useState(!1),[lt,dt]=reactExports.useState(null),[ht,mt]=reactExports.useState(null),[ft,pt]=reactExports.useState(null),{node:yt}=useWaku(),{address:gt}=useAccount(),{signMessage:bt}=useSignMessage({mutation:{async onSuccess(kt){if(!gt||!yt)return;mt(kt);const It=v4();pt(It);const Nt=createMessage({chainUUID:et.uuid,blockUUID:It,title:et.title,description:et.description,signedMessage:kt,timestamp:Date.now(),signatures:[{address:gt,signature:kt}],parentBlockUUID:null});await(yt==null?void 0:yt.lightPush.send(encoder,Nt)),ct(!0),st(!1)},onError(kt){console.error("Error signing message:",kt),st(!1),dt("Error signing message. Please try again.")}}}),{ensureWalletConnected:xt}=useWalletPrompt(),vt=kt=>{const{name:It,value:Nt}=kt.target;o(Lt=>({...Lt,[It]:Nt})),tt[It]&&rt(Lt=>({...Lt,[It]:void 0}))},Et=()=>{const kt={};return et.title.trim()||(kt.title="Title is required"),et.description.trim()||(kt.description="Description is required"),rt(kt),Object.keys(kt).length===0},Ct=kt=>{kt.preventDefault(),xt()&&Et()&&ot(!0)},St=async()=>{st(!0),dt(null);const kt=`Create Chain: Chain UUID: ${et.uuid} Title: ${et.title} Description: ${et.description} Timestamp: ${new Date().getTime()} - Signed by: ${yt}`;bt({message:kt})},At=()=>{ot(!1),ct(!1),st(!1),dt(null),pt(null)};return jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-2xl mx-auto",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsx(CardTitle,{children:"Create a New Chain"})}),jsxRuntimeExports.jsx(CardContent,{children:jsxRuntimeExports.jsxs("form",{onSubmit:Ct,className:"space-y-6",children:[jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[jsxRuntimeExports.jsx(Label,{htmlFor:"title",children:"Chain Title"}),jsxRuntimeExports.jsx(Input,{type:"text",id:"title",name:"title",value:et.title,onChange:vt,maxLength:50}),tt.title&&jsxRuntimeExports.jsx("p",{className:"text-sm text-destructive",children:tt.title})]}),jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[jsxRuntimeExports.jsx(Label,{htmlFor:"description",children:"Chain Description"}),jsxRuntimeExports.jsx(Textarea,{id:"description",name:"description",value:et.description,onChange:vt,maxLength:500}),tt.description&&jsxRuntimeExports.jsx("p",{className:"text-sm text-destructive",children:tt.description})]}),jsxRuntimeExports.jsx(Button,{type:"submit",className:"w-full",children:"Create Chain"})]})}),jsxRuntimeExports.jsx(Dialog,{open:nt,onOpenChange:At,children:jsxRuntimeExports.jsxs(DialogContent,{children:[jsxRuntimeExports.jsx(DialogHeader,{children:jsxRuntimeExports.jsx(DialogTitle,{children:at?"Chain Created":"Chain Preview"})}),at?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:ht&&ft&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[jsxRuntimeExports.jsx(QRCode,{text:`${window.location.origin}/sign/${et.uuid}/${ft}`,width:200,height:200}),jsxRuntimeExports.jsx("p",{className:"text-sm text-center break-all",children:`${window.location.origin}/sign/${et.uuid}/${ft}`}),jsxRuntimeExports.jsx(Button,{onClick:()=>navigator.clipboard.writeText(`${window.location.origin}/sign/${et.uuid}/${ft}`),variant:"outline",children:"Copy Link"})]})})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[jsxRuntimeExports.jsx("h4",{className:"text-xl font-semibold",children:et.title}),jsxRuntimeExports.jsx("p",{className:"text-muted-foreground",children:et.description}),lt&&jsxRuntimeExports.jsx("p",{className:"text-sm text-destructive",children:lt})]}),jsxRuntimeExports.jsxs(DialogFooter,{className:"sm:justify-start",children:[jsxRuntimeExports.jsx(Button,{type:"button",variant:"secondary",onClick:At,children:"Edit"}),jsxRuntimeExports.jsx(Button,{type:"button",onClick:St,disabled:it,children:it?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing..."]}):"Sign"})]})]})]})})]})},SignChain=({block:et,chainsData:o,onSuccess:tt})=>{const[rt,nt]=reactExports.useState(!1),[ot,it]=reactExports.useState(!1),[st,at]=reactExports.useState(null),[ct,lt]=reactExports.useState(!1),{address:dt}=useAccount(),{data:ht}=useEnsName({address:dt}),{node:mt}=useWaku(),{ensureWalletConnected:ft}=useWalletPrompt();reactExports.useEffect(()=>{if(dt){const yt=xt=>{if(xt.signatures.some(Ct=>Ct.address.toLowerCase()===dt.toLowerCase()))return!0;const vt=o.find(Ct=>Ct.blockUUID===xt.parentBlockUUID);return vt&&yt(vt)?!0:o.filter(Ct=>Ct.parentBlockUUID===xt.blockUUID).some(Ct=>yt(Ct))},bt=yt(et);lt(bt)}},[dt,et,o]);const{signMessage:pt}=useSignMessage({mutation:{async onSuccess(yt){if(!dt||!mt)return;if(et.signatures.some(xt=>xt.address.toLowerCase()===dt.toLowerCase())){at("You have already signed this chain."),it(!1);return}const bt={chainUUID:et.chainUUID,blockUUID:v4(),title:et.title,description:et.description,signedMessage:yt,timestamp:Date.now(),signatures:[{address:dt,signature:yt}],parentBlockUUID:et.blockUUID};try{const xt=createMessage(bt),{failures:vt,successes:Et}=await mt.lightPush.send(encoder,xt);if(vt.length>0||Et.length===0)throw new Error("Failed to send message to Waku network");tt(bt),nt(!1)}catch(xt){console.error("Error creating new block:",xt),at("Failed to create new block. Please try again.")}finally{it(!1)}},onError(yt){console.error("Error signing message:",yt),at("Error signing message. Please try again."),it(!1)}}}),gt=()=>{if(!ft())return;if(ct){at("You have already signed this chain.");return}it(!0),at(null);const yt=`Sign Block: + Signed by: ${gt}`;bt({message:kt})},At=()=>{ot(!1),ct(!1),st(!1),dt(null),pt(null)};return jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-2xl mx-auto",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsx(CardTitle,{children:"Create a New Chain"})}),jsxRuntimeExports.jsx(CardContent,{children:jsxRuntimeExports.jsxs("form",{onSubmit:Ct,className:"space-y-6",children:[jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[jsxRuntimeExports.jsx(Label,{htmlFor:"title",children:"Chain Title"}),jsxRuntimeExports.jsx(Input,{type:"text",id:"title",name:"title",value:et.title,onChange:vt,maxLength:50}),tt.title&&jsxRuntimeExports.jsx("p",{className:"text-sm text-destructive",children:tt.title})]}),jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[jsxRuntimeExports.jsx(Label,{htmlFor:"description",children:"Chain Description"}),jsxRuntimeExports.jsx(Textarea,{id:"description",name:"description",value:et.description,onChange:vt,maxLength:500}),tt.description&&jsxRuntimeExports.jsx("p",{className:"text-sm text-destructive",children:tt.description})]}),jsxRuntimeExports.jsx(Button,{type:"submit",className:"w-full",children:"Create Chain"})]})}),jsxRuntimeExports.jsx(Dialog,{open:nt,onOpenChange:At,children:jsxRuntimeExports.jsxs(DialogContent,{children:[jsxRuntimeExports.jsx(DialogHeader,{children:jsxRuntimeExports.jsx(DialogTitle,{children:at?"Chain Created":"Chain Preview"})}),at?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:ht&&ft&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[jsxRuntimeExports.jsx(QRCode,{text:`${window.location.origin}/sign/${et.uuid}/${ft}`,width:200,height:200}),jsxRuntimeExports.jsx("p",{className:"text-sm text-center break-all",children:`${window.location.origin}/sign/${et.uuid}/${ft}`}),jsxRuntimeExports.jsx(Button,{onClick:()=>navigator.clipboard.writeText(`${window.location.origin}/sign/${et.uuid}/${ft}`),variant:"outline",children:"Copy Link"})]})})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[jsxRuntimeExports.jsx("h4",{className:"text-xl font-semibold",children:et.title}),jsxRuntimeExports.jsx("p",{className:"text-muted-foreground",children:et.description}),lt&&jsxRuntimeExports.jsx("p",{className:"text-sm text-destructive",children:lt})]}),jsxRuntimeExports.jsxs(DialogFooter,{className:"sm:justify-start",children:[jsxRuntimeExports.jsx(Button,{type:"button",variant:"secondary",onClick:At,children:"Edit"}),jsxRuntimeExports.jsx(Button,{type:"button",onClick:St,disabled:it,children:it?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing..."]}):"Sign"})]})]})]})})]})},SignChain=({block:et,chainsData:o,onSuccess:tt})=>{const[rt,nt]=reactExports.useState(!1),[ot,it]=reactExports.useState(!1),[st,at]=reactExports.useState(null),[ct,lt]=reactExports.useState(!1),{address:dt}=useAccount(),{data:ht}=useEnsName({address:dt}),{node:mt}=useWaku(),{ensureWalletConnected:ft}=useWalletPrompt();reactExports.useEffect(()=>{if(dt){const gt=xt=>{if(xt.signatures.some(Ct=>Ct.address.toLowerCase()===dt.toLowerCase()))return!0;const vt=o.find(Ct=>Ct.blockUUID===xt.parentBlockUUID);return vt&>(vt)?!0:o.filter(Ct=>Ct.parentBlockUUID===xt.blockUUID).some(Ct=>gt(Ct))},bt=gt(et);lt(bt)}},[dt,et,o]);const{signMessage:pt}=useSignMessage({mutation:{async onSuccess(gt){if(!dt||!mt)return;if(et.signatures.some(xt=>xt.address.toLowerCase()===dt.toLowerCase())){at("You have already signed this chain."),it(!1);return}const bt={chainUUID:et.chainUUID,blockUUID:v4(),title:et.title,description:et.description,signedMessage:gt,timestamp:Date.now(),signatures:[{address:dt,signature:gt}],parentBlockUUID:et.blockUUID};try{const xt=createMessage(bt),{failures:vt,successes:Et}=await mt.lightPush.send(encoder,xt);if(vt.length>0||Et.length===0)throw new Error("Failed to send message to Waku network");tt(bt),nt(!1)}catch(xt){console.error("Error creating new block:",xt),at("Failed to create new block. Please try again.")}finally{it(!1)}},onError(gt){console.error("Error signing message:",gt),at("Error signing message. Please try again."),it(!1)}}}),yt=()=>{if(!ft())return;if(ct){at("You have already signed this chain.");return}it(!0),at(null);const gt=`Sign Block: Chain UUID: ${et.chainUUID} Block UUID: ${et.blockUUID} Title: ${et.title} Description: ${et.description} Timestamp: ${new Date().getTime()} Parent Block UUID: ${et.parentBlockUUID} - Signed by: ${ht||dt}`;pt({message:yt})};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Button,{onClick:()=>nt(!0),disabled:ct,children:ct?"Already Signed":"Sign Chain"}),jsxRuntimeExports.jsx(Dialog,{open:rt,onOpenChange:nt,children:jsxRuntimeExports.jsxs(DialogContent,{className:"sm:max-w-md",children:[jsxRuntimeExports.jsxs(DialogHeader,{children:[jsxRuntimeExports.jsx(DialogTitle,{children:"Sign Chain"}),jsxRuntimeExports.jsx(DialogDescription,{children:ct?"You have already signed this chain.":"Review the block details and sign to add your signature to the chain."})]}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-4",children:[jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[jsxRuntimeExports.jsx("h4",{className:"font-medium",children:"Block Details"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:et.title}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:et.description})]}),jsxRuntimeExports.jsx(QRCode,{text:`${window.location.origin}/sign/${et.chainUUID}/${et.blockUUID}`})]}),st&&jsxRuntimeExports.jsx("p",{className:"text-sm text-destructive",children:st}),jsxRuntimeExports.jsxs(DialogFooter,{children:[jsxRuntimeExports.jsx(Button,{variant:"secondary",onClick:()=>nt(!1),children:"Cancel"}),jsxRuntimeExports.jsx(Button,{onClick:gt,disabled:ot||ct,children:ot?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing..."]}):ct?"Already Signed":"Sign"})]})]})})]})},ChainList=({chainsData:et,onChainUpdate:o,isLoading:tt})=>{const rt=it=>{o(it)},nt=(it,st=0)=>{const at=et.filter(dt=>dt.parentBlockUUID===it.blockUUID),ct=it.signatures.length+at.reduce((dt,ht)=>dt+ht.signatures.length,0),lt=`${window.location.origin}/sign/${it.chainUUID??it.blockUUID}/${it.blockUUID}`;return jsxRuntimeExports.jsxs("li",{className:"mb-4",children:[jsxRuntimeExports.jsxs("div",{className:"flex items-start",children:[jsxRuntimeExports.jsx("div",{className:"mr-4 mt-2",children:st>0&&jsxRuntimeExports.jsx("div",{className:"w-6 h-6 border-l-2 border-b-2 border-gray-300"})}),st===0?jsxRuntimeExports.jsxs(Card,{className:"flex-grow",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsx(CardTitle,{children:it.title})}),jsxRuntimeExports.jsxs(CardContent,{children:[jsxRuntimeExports.jsx("p",{children:it.description}),jsxRuntimeExports.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Created at: ",new Date(it.timestamp).toLocaleString()]}),jsxRuntimeExports.jsxs("p",{className:"text-sm text-muted-foreground",children:["Total Signatures: ",ct]}),jsxRuntimeExports.jsxs("p",{className:"text-sm text-muted-foreground",children:["Block UUID: ",it.blockUUID]}),jsxRuntimeExports.jsxs("div",{className:"mt-2 space-x-2",children:[jsxRuntimeExports.jsx(SignChain,{block:it,chainsData:et,onSuccess:rt}),jsxRuntimeExports.jsxs(Dialog,{children:[jsxRuntimeExports.jsx(DialogTrigger,{asChild:!0,children:jsxRuntimeExports.jsx(Button,{variant:"outline",children:"Share"})}),jsxRuntimeExports.jsxs(DialogContent,{className:"sm:max-w-md",children:[jsxRuntimeExports.jsxs(DialogHeader,{children:[jsxRuntimeExports.jsx(DialogTitle,{children:"Share this Chain"}),jsxRuntimeExports.jsx(DialogDescription,{children:"Share this chain with others to collect their signatures."})]}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[jsxRuntimeExports.jsx(QRCode,{text:lt,width:200,height:200}),jsxRuntimeExports.jsx("p",{className:"text-sm text-center break-all",children:lt}),jsxRuntimeExports.jsx(Button,{onClick:()=>navigator.clipboard.writeText(lt),variant:"outline",children:"Copy Link"})]})]})]})]})]})]}):jsxRuntimeExports.jsx("div",{className:"flex-grow",children:jsxRuntimeExports.jsx(SignerName,{address:it.signatures[0].address})})]}),at.length>0&&jsxRuntimeExports.jsx("ul",{className:"ml-8 mt-2",children:at.map(dt=>nt(dt,st+1))})]},`${it.blockUUID}-${st}`)},ot=et.filter(it=>!it.parentBlockUUID);return jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-4xl mx-auto",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsxs(CardTitle,{children:["Existing Chains",tt&&jsxRuntimeExports.jsxs("span",{className:"ml-2 inline-flex items-center text-muted-foreground text-sm font-normal",children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Loading more chains..."]})]})}),jsxRuntimeExports.jsx(CardContent,{children:ot.length===0&&!tt?jsxRuntimeExports.jsx("p",{children:"No chains found."}):jsxRuntimeExports.jsx("ul",{className:"space-y-4",children:ot.map(it=>nt(it,0))})})]})},SignerName=({address:et})=>{const{data:o}=useEnsName({address:et});return jsxRuntimeExports.jsxs("p",{className:"text-sm",children:["Signed by: ",o||`${et.slice(0,6)}...${et.slice(-4)}`]})};var DirectionContext=reactExports.createContext(void 0);function useDirection(et){const o=reactExports.useContext(DirectionContext);return et||o||"ltr"}function clamp(et,[o,tt]){return Math.min(tt,Math.max(o,et))}function useStateMachine(et,o){return reactExports.useReducer((tt,rt)=>o[tt][rt]??tt,et)}var SCROLL_AREA_NAME="ScrollArea",[createScrollAreaContext,createScrollAreaScope]=createContextScope(SCROLL_AREA_NAME),[ScrollAreaProvider,useScrollAreaContext]=createScrollAreaContext(SCROLL_AREA_NAME),ScrollArea$1=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,type:rt="hover",dir:nt,scrollHideDelay:ot=600,...it}=et,[st,at]=reactExports.useState(null),[ct,lt]=reactExports.useState(null),[dt,ht]=reactExports.useState(null),[mt,ft]=reactExports.useState(null),[pt,gt]=reactExports.useState(null),[yt,bt]=reactExports.useState(0),[xt,vt]=reactExports.useState(0),[Et,Ct]=reactExports.useState(!1),[St,At]=reactExports.useState(!1),kt=useComposedRefs(o,Ot=>at(Ot)),It=useDirection(nt);return jsxRuntimeExports.jsx(ScrollAreaProvider,{scope:tt,type:rt,dir:It,scrollHideDelay:ot,scrollArea:st,viewport:ct,onViewportChange:lt,content:dt,onContentChange:ht,scrollbarX:mt,onScrollbarXChange:ft,scrollbarXEnabled:Et,onScrollbarXEnabledChange:Ct,scrollbarY:pt,onScrollbarYChange:gt,scrollbarYEnabled:St,onScrollbarYEnabledChange:At,onCornerWidthChange:bt,onCornerHeightChange:vt,children:jsxRuntimeExports.jsx(Primitive.div,{dir:It,...it,ref:kt,style:{position:"relative","--radix-scroll-area-corner-width":yt+"px","--radix-scroll-area-corner-height":xt+"px",...et.style}})})});ScrollArea$1.displayName=SCROLL_AREA_NAME;var VIEWPORT_NAME="ScrollAreaViewport",ScrollAreaViewport=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,children:rt,asChild:nt,nonce:ot,...it}=et,st=useScrollAreaContext(VIEWPORT_NAME,tt),at=reactExports.useRef(null),ct=useComposedRefs(o,at,st.onViewportChange);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("style",{dangerouslySetInnerHTML:{__html:` + Signed by: ${ht||dt}`;pt({message:gt})};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Button,{onClick:()=>nt(!0),disabled:ct,children:ct?"Already Signed":"Sign Chain"}),jsxRuntimeExports.jsx(Dialog,{open:rt,onOpenChange:nt,children:jsxRuntimeExports.jsxs(DialogContent,{className:"sm:max-w-md",children:[jsxRuntimeExports.jsxs(DialogHeader,{children:[jsxRuntimeExports.jsx(DialogTitle,{children:"Sign Chain"}),jsxRuntimeExports.jsx(DialogDescription,{children:ct?"You have already signed this chain.":"Review the block details and sign to add your signature to the chain."})]}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-4",children:[jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[jsxRuntimeExports.jsx("h4",{className:"font-medium",children:"Block Details"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:et.title}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:et.description})]}),jsxRuntimeExports.jsx(QRCode,{text:`${window.location.origin}/sign/${et.chainUUID}/${et.blockUUID}`})]}),st&&jsxRuntimeExports.jsx("p",{className:"text-sm text-destructive",children:st}),jsxRuntimeExports.jsxs(DialogFooter,{children:[jsxRuntimeExports.jsx(Button,{variant:"secondary",onClick:()=>nt(!1),children:"Cancel"}),jsxRuntimeExports.jsx(Button,{onClick:yt,disabled:ot||ct,children:ot?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing..."]}):ct?"Already Signed":"Sign"})]})]})})]})},ChainList=({chainsData:et,onChainUpdate:o,isLoading:tt})=>{const rt=it=>{o(it)},nt=(it,st=0)=>{const at=et.filter(dt=>dt.parentBlockUUID===it.blockUUID),ct=it.signatures.length+at.reduce((dt,ht)=>dt+ht.signatures.length,0),lt=`${window.location.origin}/sign/${it.chainUUID??it.blockUUID}/${it.blockUUID}`;return jsxRuntimeExports.jsxs("li",{className:"mb-4",children:[jsxRuntimeExports.jsxs("div",{className:"flex items-start",children:[jsxRuntimeExports.jsx("div",{className:"mr-4 mt-2",children:st>0&&jsxRuntimeExports.jsx("div",{className:"w-6 h-6 border-l-2 border-b-2 border-gray-300"})}),st===0?jsxRuntimeExports.jsxs(Card,{className:"flex-grow",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsx(CardTitle,{children:it.title})}),jsxRuntimeExports.jsxs(CardContent,{children:[jsxRuntimeExports.jsx("p",{children:it.description}),jsxRuntimeExports.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Created at: ",new Date(it.timestamp).toLocaleString()]}),jsxRuntimeExports.jsxs("p",{className:"text-sm text-muted-foreground",children:["Total Signatures: ",ct]}),jsxRuntimeExports.jsxs("p",{className:"text-sm text-muted-foreground",children:["Block UUID: ",it.blockUUID]}),jsxRuntimeExports.jsxs("div",{className:"mt-2 space-x-2",children:[jsxRuntimeExports.jsx(SignChain,{block:it,chainsData:et,onSuccess:rt}),jsxRuntimeExports.jsxs(Dialog,{children:[jsxRuntimeExports.jsx(DialogTrigger,{asChild:!0,children:jsxRuntimeExports.jsx(Button,{variant:"outline",children:"Share"})}),jsxRuntimeExports.jsxs(DialogContent,{className:"sm:max-w-md",children:[jsxRuntimeExports.jsxs(DialogHeader,{children:[jsxRuntimeExports.jsx(DialogTitle,{children:"Share this Chain"}),jsxRuntimeExports.jsx(DialogDescription,{children:"Share this chain with others to collect their signatures."})]}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[jsxRuntimeExports.jsx(QRCode,{text:lt,width:200,height:200}),jsxRuntimeExports.jsx("p",{className:"text-sm text-center break-all",children:lt}),jsxRuntimeExports.jsx(Button,{onClick:()=>navigator.clipboard.writeText(lt),variant:"outline",children:"Copy Link"})]})]})]})]})]})]}):jsxRuntimeExports.jsx("div",{className:"flex-grow",children:jsxRuntimeExports.jsx(SignerName,{address:it.signatures[0].address})})]}),at.length>0&&jsxRuntimeExports.jsx("ul",{className:"ml-8 mt-2",children:at.map(dt=>nt(dt,st+1))})]},`${it.blockUUID}-${st}`)},ot=et.filter(it=>!it.parentBlockUUID);return jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-4xl mx-auto",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsxs(CardTitle,{children:["Existing Chains",tt&&jsxRuntimeExports.jsxs("span",{className:"ml-2 inline-flex items-center text-muted-foreground text-sm font-normal",children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Loading more chains..."]})]})}),jsxRuntimeExports.jsx(CardContent,{children:ot.length===0&&!tt?jsxRuntimeExports.jsx("p",{children:"No chains found."}):jsxRuntimeExports.jsx("ul",{className:"space-y-4",children:ot.map(it=>nt(it,0))})})]})},SignerName=({address:et})=>{const{data:o}=useEnsName({address:et});return jsxRuntimeExports.jsxs("p",{className:"text-sm",children:["Signed by: ",o||`${et.slice(0,6)}...${et.slice(-4)}`]})};var DirectionContext=reactExports.createContext(void 0);function useDirection(et){const o=reactExports.useContext(DirectionContext);return et||o||"ltr"}function clamp(et,[o,tt]){return Math.min(tt,Math.max(o,et))}function useStateMachine(et,o){return reactExports.useReducer((tt,rt)=>o[tt][rt]??tt,et)}var SCROLL_AREA_NAME="ScrollArea",[createScrollAreaContext,createScrollAreaScope]=createContextScope(SCROLL_AREA_NAME),[ScrollAreaProvider,useScrollAreaContext]=createScrollAreaContext(SCROLL_AREA_NAME),ScrollArea$1=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,type:rt="hover",dir:nt,scrollHideDelay:ot=600,...it}=et,[st,at]=reactExports.useState(null),[ct,lt]=reactExports.useState(null),[dt,ht]=reactExports.useState(null),[mt,ft]=reactExports.useState(null),[pt,yt]=reactExports.useState(null),[gt,bt]=reactExports.useState(0),[xt,vt]=reactExports.useState(0),[Et,Ct]=reactExports.useState(!1),[St,At]=reactExports.useState(!1),kt=useComposedRefs(o,Nt=>at(Nt)),It=useDirection(nt);return jsxRuntimeExports.jsx(ScrollAreaProvider,{scope:tt,type:rt,dir:It,scrollHideDelay:ot,scrollArea:st,viewport:ct,onViewportChange:lt,content:dt,onContentChange:ht,scrollbarX:mt,onScrollbarXChange:ft,scrollbarXEnabled:Et,onScrollbarXEnabledChange:Ct,scrollbarY:pt,onScrollbarYChange:yt,scrollbarYEnabled:St,onScrollbarYEnabledChange:At,onCornerWidthChange:bt,onCornerHeightChange:vt,children:jsxRuntimeExports.jsx(Primitive.div,{dir:It,...it,ref:kt,style:{position:"relative","--radix-scroll-area-corner-width":gt+"px","--radix-scroll-area-corner-height":xt+"px",...et.style}})})});ScrollArea$1.displayName=SCROLL_AREA_NAME;var VIEWPORT_NAME="ScrollAreaViewport",ScrollAreaViewport=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,children:rt,asChild:nt,nonce:ot,...it}=et,st=useScrollAreaContext(VIEWPORT_NAME,tt),at=reactExports.useRef(null),ct=useComposedRefs(o,at,st.onViewportChange);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("style",{dangerouslySetInnerHTML:{__html:` [data-radix-scroll-area-viewport] { scrollbar-width: none; -ms-overflow-style: none; @@ -4173,7 +4173,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${o.do :where([data-radix-scroll-area-content]) { flex-grow: 1; } -`},nonce:ot}),jsxRuntimeExports.jsx(Primitive.div,{"data-radix-scroll-area-viewport":"",...it,asChild:nt,ref:ct,style:{overflowX:st.scrollbarXEnabled?"scroll":"hidden",overflowY:st.scrollbarYEnabled?"scroll":"hidden",...et.style},children:getSubtree({asChild:nt,children:rt},lt=>jsxRuntimeExports.jsx("div",{"data-radix-scroll-area-content":"",ref:st.onContentChange,style:{minWidth:st.scrollbarXEnabled?"fit-content":void 0},children:lt}))})]})});ScrollAreaViewport.displayName=VIEWPORT_NAME;var SCROLLBAR_NAME="ScrollAreaScrollbar",ScrollAreaScrollbar=reactExports.forwardRef((et,o)=>{const{forceMount:tt,...rt}=et,nt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),{onScrollbarXEnabledChange:ot,onScrollbarYEnabledChange:it}=nt,st=et.orientation==="horizontal";return reactExports.useEffect(()=>(st?ot(!0):it(!0),()=>{st?ot(!1):it(!1)}),[st,ot,it]),nt.type==="hover"?jsxRuntimeExports.jsx(ScrollAreaScrollbarHover,{...rt,ref:o,forceMount:tt}):nt.type==="scroll"?jsxRuntimeExports.jsx(ScrollAreaScrollbarScroll,{...rt,ref:o,forceMount:tt}):nt.type==="auto"?jsxRuntimeExports.jsx(ScrollAreaScrollbarAuto,{...rt,ref:o,forceMount:tt}):nt.type==="always"?jsxRuntimeExports.jsx(ScrollAreaScrollbarVisible,{...rt,ref:o}):null});ScrollAreaScrollbar.displayName=SCROLLBAR_NAME;var ScrollAreaScrollbarHover=reactExports.forwardRef((et,o)=>{const{forceMount:tt,...rt}=et,nt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),[ot,it]=reactExports.useState(!1);return reactExports.useEffect(()=>{const st=nt.scrollArea;let at=0;if(st){const ct=()=>{window.clearTimeout(at),it(!0)},lt=()=>{at=window.setTimeout(()=>it(!1),nt.scrollHideDelay)};return st.addEventListener("pointerenter",ct),st.addEventListener("pointerleave",lt),()=>{window.clearTimeout(at),st.removeEventListener("pointerenter",ct),st.removeEventListener("pointerleave",lt)}}},[nt.scrollArea,nt.scrollHideDelay]),jsxRuntimeExports.jsx(Presence,{present:tt||ot,children:jsxRuntimeExports.jsx(ScrollAreaScrollbarAuto,{"data-state":ot?"visible":"hidden",...rt,ref:o})})}),ScrollAreaScrollbarScroll=reactExports.forwardRef((et,o)=>{const{forceMount:tt,...rt}=et,nt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),ot=et.orientation==="horizontal",it=useDebounceCallback(()=>at("SCROLL_END"),100),[st,at]=useStateMachine("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return reactExports.useEffect(()=>{if(st==="idle"){const ct=window.setTimeout(()=>at("HIDE"),nt.scrollHideDelay);return()=>window.clearTimeout(ct)}},[st,nt.scrollHideDelay,at]),reactExports.useEffect(()=>{const ct=nt.viewport,lt=ot?"scrollLeft":"scrollTop";if(ct){let dt=ct[lt];const ht=()=>{const mt=ct[lt];dt!==mt&&(at("SCROLL"),it()),dt=mt};return ct.addEventListener("scroll",ht),()=>ct.removeEventListener("scroll",ht)}},[nt.viewport,ot,at,it]),jsxRuntimeExports.jsx(Presence,{present:tt||st!=="hidden",children:jsxRuntimeExports.jsx(ScrollAreaScrollbarVisible,{"data-state":st==="hidden"?"hidden":"visible",...rt,ref:o,onPointerEnter:composeEventHandlers(et.onPointerEnter,()=>at("POINTER_ENTER")),onPointerLeave:composeEventHandlers(et.onPointerLeave,()=>at("POINTER_LEAVE"))})})}),ScrollAreaScrollbarAuto=reactExports.forwardRef((et,o)=>{const tt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),{forceMount:rt,...nt}=et,[ot,it]=reactExports.useState(!1),st=et.orientation==="horizontal",at=useDebounceCallback(()=>{if(tt.viewport){const ct=tt.viewport.offsetWidth{const{orientation:tt="vertical",...rt}=et,nt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),ot=reactExports.useRef(null),it=reactExports.useRef(0),[st,at]=reactExports.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),ct=getThumbRatio(st.viewport,st.content),lt={...rt,sizes:st,onSizesChange:at,hasThumb:ct>0&&ct<1,onThumbChange:ht=>ot.current=ht,onThumbPointerUp:()=>it.current=0,onThumbPointerDown:ht=>it.current=ht};function dt(ht,mt){return getScrollPositionFromPointer(ht,it.current,st,mt)}return tt==="horizontal"?jsxRuntimeExports.jsx(ScrollAreaScrollbarX,{...lt,ref:o,onThumbPositionChange:()=>{if(nt.viewport&&ot.current){const ht=nt.viewport.scrollLeft,mt=getThumbOffsetFromScroll(ht,st,nt.dir);ot.current.style.transform=`translate3d(${mt}px, 0, 0)`}},onWheelScroll:ht=>{nt.viewport&&(nt.viewport.scrollLeft=ht)},onDragScroll:ht=>{nt.viewport&&(nt.viewport.scrollLeft=dt(ht,nt.dir))}}):tt==="vertical"?jsxRuntimeExports.jsx(ScrollAreaScrollbarY,{...lt,ref:o,onThumbPositionChange:()=>{if(nt.viewport&&ot.current){const ht=nt.viewport.scrollTop,mt=getThumbOffsetFromScroll(ht,st);ot.current.style.transform=`translate3d(0, ${mt}px, 0)`}},onWheelScroll:ht=>{nt.viewport&&(nt.viewport.scrollTop=ht)},onDragScroll:ht=>{nt.viewport&&(nt.viewport.scrollTop=dt(ht))}}):null}),ScrollAreaScrollbarX=reactExports.forwardRef((et,o)=>{const{sizes:tt,onSizesChange:rt,...nt}=et,ot=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),[it,st]=reactExports.useState(),at=reactExports.useRef(null),ct=useComposedRefs(o,at,ot.onScrollbarXChange);return reactExports.useEffect(()=>{at.current&&st(getComputedStyle(at.current))},[at]),jsxRuntimeExports.jsx(ScrollAreaScrollbarImpl,{"data-orientation":"horizontal",...nt,ref:ct,sizes:tt,style:{bottom:0,left:ot.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:ot.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":getThumbSize(tt)+"px",...et.style},onThumbPointerDown:lt=>et.onThumbPointerDown(lt.x),onDragScroll:lt=>et.onDragScroll(lt.x),onWheelScroll:(lt,dt)=>{if(ot.viewport){const ht=ot.viewport.scrollLeft+lt.deltaX;et.onWheelScroll(ht),isScrollingWithinScrollbarBounds(ht,dt)&<.preventDefault()}},onResize:()=>{at.current&&ot.viewport&&it&&rt({content:ot.viewport.scrollWidth,viewport:ot.viewport.offsetWidth,scrollbar:{size:at.current.clientWidth,paddingStart:toInt(it.paddingLeft),paddingEnd:toInt(it.paddingRight)}})}})}),ScrollAreaScrollbarY=reactExports.forwardRef((et,o)=>{const{sizes:tt,onSizesChange:rt,...nt}=et,ot=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),[it,st]=reactExports.useState(),at=reactExports.useRef(null),ct=useComposedRefs(o,at,ot.onScrollbarYChange);return reactExports.useEffect(()=>{at.current&&st(getComputedStyle(at.current))},[at]),jsxRuntimeExports.jsx(ScrollAreaScrollbarImpl,{"data-orientation":"vertical",...nt,ref:ct,sizes:tt,style:{top:0,right:ot.dir==="ltr"?0:void 0,left:ot.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":getThumbSize(tt)+"px",...et.style},onThumbPointerDown:lt=>et.onThumbPointerDown(lt.y),onDragScroll:lt=>et.onDragScroll(lt.y),onWheelScroll:(lt,dt)=>{if(ot.viewport){const ht=ot.viewport.scrollTop+lt.deltaY;et.onWheelScroll(ht),isScrollingWithinScrollbarBounds(ht,dt)&<.preventDefault()}},onResize:()=>{at.current&&ot.viewport&&it&&rt({content:ot.viewport.scrollHeight,viewport:ot.viewport.offsetHeight,scrollbar:{size:at.current.clientHeight,paddingStart:toInt(it.paddingTop),paddingEnd:toInt(it.paddingBottom)}})}})}),[ScrollbarProvider,useScrollbarContext]=createScrollAreaContext(SCROLLBAR_NAME),ScrollAreaScrollbarImpl=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,sizes:rt,hasThumb:nt,onThumbChange:ot,onThumbPointerUp:it,onThumbPointerDown:st,onThumbPositionChange:at,onDragScroll:ct,onWheelScroll:lt,onResize:dt,...ht}=et,mt=useScrollAreaContext(SCROLLBAR_NAME,tt),[ft,pt]=reactExports.useState(null),gt=useComposedRefs(o,kt=>pt(kt)),yt=reactExports.useRef(null),bt=reactExports.useRef(""),xt=mt.viewport,vt=rt.content-rt.viewport,Et=useCallbackRef$1(lt),Ct=useCallbackRef$1(at),St=useDebounceCallback(dt,10);function At(kt){if(yt.current){const It=kt.clientX-yt.current.left,Ot=kt.clientY-yt.current.top;ct({x:It,y:Ot})}}return reactExports.useEffect(()=>{const kt=It=>{const Ot=It.target;(ft==null?void 0:ft.contains(Ot))&&Et(It,vt)};return document.addEventListener("wheel",kt,{passive:!1}),()=>document.removeEventListener("wheel",kt,{passive:!1})},[xt,ft,vt,Et]),reactExports.useEffect(Ct,[rt,Ct]),useResizeObserver(ft,St),useResizeObserver(mt.content,St),jsxRuntimeExports.jsx(ScrollbarProvider,{scope:tt,scrollbar:ft,hasThumb:nt,onThumbChange:useCallbackRef$1(ot),onThumbPointerUp:useCallbackRef$1(it),onThumbPositionChange:Ct,onThumbPointerDown:useCallbackRef$1(st),children:jsxRuntimeExports.jsx(Primitive.div,{...ht,ref:gt,style:{position:"absolute",...ht.style},onPointerDown:composeEventHandlers(et.onPointerDown,kt=>{kt.button===0&&(kt.target.setPointerCapture(kt.pointerId),yt.current=ft.getBoundingClientRect(),bt.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",mt.viewport&&(mt.viewport.style.scrollBehavior="auto"),At(kt))}),onPointerMove:composeEventHandlers(et.onPointerMove,At),onPointerUp:composeEventHandlers(et.onPointerUp,kt=>{const It=kt.target;It.hasPointerCapture(kt.pointerId)&&It.releasePointerCapture(kt.pointerId),document.body.style.webkitUserSelect=bt.current,mt.viewport&&(mt.viewport.style.scrollBehavior=""),yt.current=null})})})}),THUMB_NAME="ScrollAreaThumb",ScrollAreaThumb=reactExports.forwardRef((et,o)=>{const{forceMount:tt,...rt}=et,nt=useScrollbarContext(THUMB_NAME,et.__scopeScrollArea);return jsxRuntimeExports.jsx(Presence,{present:tt||nt.hasThumb,children:jsxRuntimeExports.jsx(ScrollAreaThumbImpl,{ref:o,...rt})})}),ScrollAreaThumbImpl=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,style:rt,...nt}=et,ot=useScrollAreaContext(THUMB_NAME,tt),it=useScrollbarContext(THUMB_NAME,tt),{onThumbPositionChange:st}=it,at=useComposedRefs(o,dt=>it.onThumbChange(dt)),ct=reactExports.useRef(),lt=useDebounceCallback(()=>{ct.current&&(ct.current(),ct.current=void 0)},100);return reactExports.useEffect(()=>{const dt=ot.viewport;if(dt){const ht=()=>{if(lt(),!ct.current){const mt=addUnlinkedScrollListener(dt,st);ct.current=mt,st()}};return st(),dt.addEventListener("scroll",ht),()=>dt.removeEventListener("scroll",ht)}},[ot.viewport,lt,st]),jsxRuntimeExports.jsx(Primitive.div,{"data-state":it.hasThumb?"visible":"hidden",...nt,ref:at,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...rt},onPointerDownCapture:composeEventHandlers(et.onPointerDownCapture,dt=>{const mt=dt.target.getBoundingClientRect(),ft=dt.clientX-mt.left,pt=dt.clientY-mt.top;it.onThumbPointerDown({x:ft,y:pt})}),onPointerUp:composeEventHandlers(et.onPointerUp,it.onThumbPointerUp)})});ScrollAreaThumb.displayName=THUMB_NAME;var CORNER_NAME="ScrollAreaCorner",ScrollAreaCorner=reactExports.forwardRef((et,o)=>{const tt=useScrollAreaContext(CORNER_NAME,et.__scopeScrollArea),rt=!!(tt.scrollbarX&&tt.scrollbarY);return tt.type!=="scroll"&&rt?jsxRuntimeExports.jsx(ScrollAreaCornerImpl,{...et,ref:o}):null});ScrollAreaCorner.displayName=CORNER_NAME;var ScrollAreaCornerImpl=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,...rt}=et,nt=useScrollAreaContext(CORNER_NAME,tt),[ot,it]=reactExports.useState(0),[st,at]=reactExports.useState(0),ct=!!(ot&&st);return useResizeObserver(nt.scrollbarX,()=>{var dt;const lt=((dt=nt.scrollbarX)==null?void 0:dt.offsetHeight)||0;nt.onCornerHeightChange(lt),at(lt)}),useResizeObserver(nt.scrollbarY,()=>{var dt;const lt=((dt=nt.scrollbarY)==null?void 0:dt.offsetWidth)||0;nt.onCornerWidthChange(lt),it(lt)}),ct?jsxRuntimeExports.jsx(Primitive.div,{...rt,ref:o,style:{width:ot,height:st,position:"absolute",right:nt.dir==="ltr"?0:void 0,left:nt.dir==="rtl"?0:void 0,bottom:0,...et.style}}):null});function toInt(et){return et?parseInt(et,10):0}function getThumbRatio(et,o){const tt=et/o;return isNaN(tt)?0:tt}function getThumbSize(et){const o=getThumbRatio(et.viewport,et.content),tt=et.scrollbar.paddingStart+et.scrollbar.paddingEnd,rt=(et.scrollbar.size-tt)*o;return Math.max(rt,18)}function getScrollPositionFromPointer(et,o,tt,rt="ltr"){const nt=getThumbSize(tt),ot=nt/2,it=o||ot,st=nt-it,at=tt.scrollbar.paddingStart+it,ct=tt.scrollbar.size-tt.scrollbar.paddingEnd-st,lt=tt.content-tt.viewport,dt=rt==="ltr"?[0,lt]:[lt*-1,0];return linearScale([at,ct],dt)(et)}function getThumbOffsetFromScroll(et,o,tt="ltr"){const rt=getThumbSize(o),nt=o.scrollbar.paddingStart+o.scrollbar.paddingEnd,ot=o.scrollbar.size-nt,it=o.content-o.viewport,st=ot-rt,at=tt==="ltr"?[0,it]:[it*-1,0],ct=clamp(et,at);return linearScale([0,it],[0,st])(ct)}function linearScale(et,o){return tt=>{if(et[0]===et[1]||o[0]===o[1])return o[0];const rt=(o[1]-o[0])/(et[1]-et[0]);return o[0]+rt*(tt-et[0])}}function isScrollingWithinScrollbarBounds(et,o){return et>0&&et{})=>{let tt={left:et.scrollLeft,top:et.scrollTop},rt=0;return function nt(){const ot={left:et.scrollLeft,top:et.scrollTop},it=tt.left!==ot.left,st=tt.top!==ot.top;(it||st)&&o(),tt=ot,rt=window.requestAnimationFrame(nt)}(),()=>window.cancelAnimationFrame(rt)};function useDebounceCallback(et,o){const tt=useCallbackRef$1(et),rt=reactExports.useRef(0);return reactExports.useEffect(()=>()=>window.clearTimeout(rt.current),[]),reactExports.useCallback(()=>{window.clearTimeout(rt.current),rt.current=window.setTimeout(tt,o)},[tt,o])}function useResizeObserver(et,o){const tt=useCallbackRef$1(o);useLayoutEffect2(()=>{let rt=0;if(et){const nt=new ResizeObserver(()=>{cancelAnimationFrame(rt),rt=window.requestAnimationFrame(tt)});return nt.observe(et),()=>{window.cancelAnimationFrame(rt),nt.unobserve(et)}}},[et,tt])}function getSubtree(et,o){const{asChild:tt,children:rt}=et;if(!tt)return typeof o=="function"?o(rt):o;const nt=reactExports.Children.only(rt);return reactExports.cloneElement(nt,{children:typeof o=="function"?o(nt.props.children):o})}var Root=ScrollArea$1,Viewport=ScrollAreaViewport,Corner=ScrollAreaCorner;const ScrollArea=reactExports.forwardRef(({className:et,children:o,...tt},rt)=>jsxRuntimeExports.jsxs(Root,{ref:rt,className:cn("relative overflow-hidden",et),...tt,children:[jsxRuntimeExports.jsx(Viewport,{className:"h-full w-full rounded-[inherit]",children:o}),jsxRuntimeExports.jsx(ScrollBar,{}),jsxRuntimeExports.jsx(Corner,{})]}));ScrollArea.displayName=Root.displayName;const ScrollBar=reactExports.forwardRef(({className:et,orientation:o="vertical",...tt},rt)=>jsxRuntimeExports.jsx(ScrollAreaScrollbar,{ref:rt,orientation:o,className:cn("flex touch-none select-none transition-colors",o==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",o==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",et),...tt,children:jsxRuntimeExports.jsx(ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));ScrollBar.displayName=ScrollAreaScrollbar.displayName;const privacyPolicy=` +`},nonce:ot}),jsxRuntimeExports.jsx(Primitive.div,{"data-radix-scroll-area-viewport":"",...it,asChild:nt,ref:ct,style:{overflowX:st.scrollbarXEnabled?"scroll":"hidden",overflowY:st.scrollbarYEnabled?"scroll":"hidden",...et.style},children:getSubtree({asChild:nt,children:rt},lt=>jsxRuntimeExports.jsx("div",{"data-radix-scroll-area-content":"",ref:st.onContentChange,style:{minWidth:st.scrollbarXEnabled?"fit-content":void 0},children:lt}))})]})});ScrollAreaViewport.displayName=VIEWPORT_NAME;var SCROLLBAR_NAME="ScrollAreaScrollbar",ScrollAreaScrollbar=reactExports.forwardRef((et,o)=>{const{forceMount:tt,...rt}=et,nt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),{onScrollbarXEnabledChange:ot,onScrollbarYEnabledChange:it}=nt,st=et.orientation==="horizontal";return reactExports.useEffect(()=>(st?ot(!0):it(!0),()=>{st?ot(!1):it(!1)}),[st,ot,it]),nt.type==="hover"?jsxRuntimeExports.jsx(ScrollAreaScrollbarHover,{...rt,ref:o,forceMount:tt}):nt.type==="scroll"?jsxRuntimeExports.jsx(ScrollAreaScrollbarScroll,{...rt,ref:o,forceMount:tt}):nt.type==="auto"?jsxRuntimeExports.jsx(ScrollAreaScrollbarAuto,{...rt,ref:o,forceMount:tt}):nt.type==="always"?jsxRuntimeExports.jsx(ScrollAreaScrollbarVisible,{...rt,ref:o}):null});ScrollAreaScrollbar.displayName=SCROLLBAR_NAME;var ScrollAreaScrollbarHover=reactExports.forwardRef((et,o)=>{const{forceMount:tt,...rt}=et,nt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),[ot,it]=reactExports.useState(!1);return reactExports.useEffect(()=>{const st=nt.scrollArea;let at=0;if(st){const ct=()=>{window.clearTimeout(at),it(!0)},lt=()=>{at=window.setTimeout(()=>it(!1),nt.scrollHideDelay)};return st.addEventListener("pointerenter",ct),st.addEventListener("pointerleave",lt),()=>{window.clearTimeout(at),st.removeEventListener("pointerenter",ct),st.removeEventListener("pointerleave",lt)}}},[nt.scrollArea,nt.scrollHideDelay]),jsxRuntimeExports.jsx(Presence,{present:tt||ot,children:jsxRuntimeExports.jsx(ScrollAreaScrollbarAuto,{"data-state":ot?"visible":"hidden",...rt,ref:o})})}),ScrollAreaScrollbarScroll=reactExports.forwardRef((et,o)=>{const{forceMount:tt,...rt}=et,nt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),ot=et.orientation==="horizontal",it=useDebounceCallback(()=>at("SCROLL_END"),100),[st,at]=useStateMachine("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return reactExports.useEffect(()=>{if(st==="idle"){const ct=window.setTimeout(()=>at("HIDE"),nt.scrollHideDelay);return()=>window.clearTimeout(ct)}},[st,nt.scrollHideDelay,at]),reactExports.useEffect(()=>{const ct=nt.viewport,lt=ot?"scrollLeft":"scrollTop";if(ct){let dt=ct[lt];const ht=()=>{const mt=ct[lt];dt!==mt&&(at("SCROLL"),it()),dt=mt};return ct.addEventListener("scroll",ht),()=>ct.removeEventListener("scroll",ht)}},[nt.viewport,ot,at,it]),jsxRuntimeExports.jsx(Presence,{present:tt||st!=="hidden",children:jsxRuntimeExports.jsx(ScrollAreaScrollbarVisible,{"data-state":st==="hidden"?"hidden":"visible",...rt,ref:o,onPointerEnter:composeEventHandlers(et.onPointerEnter,()=>at("POINTER_ENTER")),onPointerLeave:composeEventHandlers(et.onPointerLeave,()=>at("POINTER_LEAVE"))})})}),ScrollAreaScrollbarAuto=reactExports.forwardRef((et,o)=>{const tt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),{forceMount:rt,...nt}=et,[ot,it]=reactExports.useState(!1),st=et.orientation==="horizontal",at=useDebounceCallback(()=>{if(tt.viewport){const ct=tt.viewport.offsetWidth{const{orientation:tt="vertical",...rt}=et,nt=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),ot=reactExports.useRef(null),it=reactExports.useRef(0),[st,at]=reactExports.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),ct=getThumbRatio(st.viewport,st.content),lt={...rt,sizes:st,onSizesChange:at,hasThumb:ct>0&&ct<1,onThumbChange:ht=>ot.current=ht,onThumbPointerUp:()=>it.current=0,onThumbPointerDown:ht=>it.current=ht};function dt(ht,mt){return getScrollPositionFromPointer(ht,it.current,st,mt)}return tt==="horizontal"?jsxRuntimeExports.jsx(ScrollAreaScrollbarX,{...lt,ref:o,onThumbPositionChange:()=>{if(nt.viewport&&ot.current){const ht=nt.viewport.scrollLeft,mt=getThumbOffsetFromScroll(ht,st,nt.dir);ot.current.style.transform=`translate3d(${mt}px, 0, 0)`}},onWheelScroll:ht=>{nt.viewport&&(nt.viewport.scrollLeft=ht)},onDragScroll:ht=>{nt.viewport&&(nt.viewport.scrollLeft=dt(ht,nt.dir))}}):tt==="vertical"?jsxRuntimeExports.jsx(ScrollAreaScrollbarY,{...lt,ref:o,onThumbPositionChange:()=>{if(nt.viewport&&ot.current){const ht=nt.viewport.scrollTop,mt=getThumbOffsetFromScroll(ht,st);ot.current.style.transform=`translate3d(0, ${mt}px, 0)`}},onWheelScroll:ht=>{nt.viewport&&(nt.viewport.scrollTop=ht)},onDragScroll:ht=>{nt.viewport&&(nt.viewport.scrollTop=dt(ht))}}):null}),ScrollAreaScrollbarX=reactExports.forwardRef((et,o)=>{const{sizes:tt,onSizesChange:rt,...nt}=et,ot=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),[it,st]=reactExports.useState(),at=reactExports.useRef(null),ct=useComposedRefs(o,at,ot.onScrollbarXChange);return reactExports.useEffect(()=>{at.current&&st(getComputedStyle(at.current))},[at]),jsxRuntimeExports.jsx(ScrollAreaScrollbarImpl,{"data-orientation":"horizontal",...nt,ref:ct,sizes:tt,style:{bottom:0,left:ot.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:ot.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":getThumbSize(tt)+"px",...et.style},onThumbPointerDown:lt=>et.onThumbPointerDown(lt.x),onDragScroll:lt=>et.onDragScroll(lt.x),onWheelScroll:(lt,dt)=>{if(ot.viewport){const ht=ot.viewport.scrollLeft+lt.deltaX;et.onWheelScroll(ht),isScrollingWithinScrollbarBounds(ht,dt)&<.preventDefault()}},onResize:()=>{at.current&&ot.viewport&&it&&rt({content:ot.viewport.scrollWidth,viewport:ot.viewport.offsetWidth,scrollbar:{size:at.current.clientWidth,paddingStart:toInt(it.paddingLeft),paddingEnd:toInt(it.paddingRight)}})}})}),ScrollAreaScrollbarY=reactExports.forwardRef((et,o)=>{const{sizes:tt,onSizesChange:rt,...nt}=et,ot=useScrollAreaContext(SCROLLBAR_NAME,et.__scopeScrollArea),[it,st]=reactExports.useState(),at=reactExports.useRef(null),ct=useComposedRefs(o,at,ot.onScrollbarYChange);return reactExports.useEffect(()=>{at.current&&st(getComputedStyle(at.current))},[at]),jsxRuntimeExports.jsx(ScrollAreaScrollbarImpl,{"data-orientation":"vertical",...nt,ref:ct,sizes:tt,style:{top:0,right:ot.dir==="ltr"?0:void 0,left:ot.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":getThumbSize(tt)+"px",...et.style},onThumbPointerDown:lt=>et.onThumbPointerDown(lt.y),onDragScroll:lt=>et.onDragScroll(lt.y),onWheelScroll:(lt,dt)=>{if(ot.viewport){const ht=ot.viewport.scrollTop+lt.deltaY;et.onWheelScroll(ht),isScrollingWithinScrollbarBounds(ht,dt)&<.preventDefault()}},onResize:()=>{at.current&&ot.viewport&&it&&rt({content:ot.viewport.scrollHeight,viewport:ot.viewport.offsetHeight,scrollbar:{size:at.current.clientHeight,paddingStart:toInt(it.paddingTop),paddingEnd:toInt(it.paddingBottom)}})}})}),[ScrollbarProvider,useScrollbarContext]=createScrollAreaContext(SCROLLBAR_NAME),ScrollAreaScrollbarImpl=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,sizes:rt,hasThumb:nt,onThumbChange:ot,onThumbPointerUp:it,onThumbPointerDown:st,onThumbPositionChange:at,onDragScroll:ct,onWheelScroll:lt,onResize:dt,...ht}=et,mt=useScrollAreaContext(SCROLLBAR_NAME,tt),[ft,pt]=reactExports.useState(null),yt=useComposedRefs(o,kt=>pt(kt)),gt=reactExports.useRef(null),bt=reactExports.useRef(""),xt=mt.viewport,vt=rt.content-rt.viewport,Et=useCallbackRef$1(lt),Ct=useCallbackRef$1(at),St=useDebounceCallback(dt,10);function At(kt){if(gt.current){const It=kt.clientX-gt.current.left,Nt=kt.clientY-gt.current.top;ct({x:It,y:Nt})}}return reactExports.useEffect(()=>{const kt=It=>{const Nt=It.target;(ft==null?void 0:ft.contains(Nt))&&Et(It,vt)};return document.addEventListener("wheel",kt,{passive:!1}),()=>document.removeEventListener("wheel",kt,{passive:!1})},[xt,ft,vt,Et]),reactExports.useEffect(Ct,[rt,Ct]),useResizeObserver(ft,St),useResizeObserver(mt.content,St),jsxRuntimeExports.jsx(ScrollbarProvider,{scope:tt,scrollbar:ft,hasThumb:nt,onThumbChange:useCallbackRef$1(ot),onThumbPointerUp:useCallbackRef$1(it),onThumbPositionChange:Ct,onThumbPointerDown:useCallbackRef$1(st),children:jsxRuntimeExports.jsx(Primitive.div,{...ht,ref:yt,style:{position:"absolute",...ht.style},onPointerDown:composeEventHandlers(et.onPointerDown,kt=>{kt.button===0&&(kt.target.setPointerCapture(kt.pointerId),gt.current=ft.getBoundingClientRect(),bt.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",mt.viewport&&(mt.viewport.style.scrollBehavior="auto"),At(kt))}),onPointerMove:composeEventHandlers(et.onPointerMove,At),onPointerUp:composeEventHandlers(et.onPointerUp,kt=>{const It=kt.target;It.hasPointerCapture(kt.pointerId)&&It.releasePointerCapture(kt.pointerId),document.body.style.webkitUserSelect=bt.current,mt.viewport&&(mt.viewport.style.scrollBehavior=""),gt.current=null})})})}),THUMB_NAME="ScrollAreaThumb",ScrollAreaThumb=reactExports.forwardRef((et,o)=>{const{forceMount:tt,...rt}=et,nt=useScrollbarContext(THUMB_NAME,et.__scopeScrollArea);return jsxRuntimeExports.jsx(Presence,{present:tt||nt.hasThumb,children:jsxRuntimeExports.jsx(ScrollAreaThumbImpl,{ref:o,...rt})})}),ScrollAreaThumbImpl=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,style:rt,...nt}=et,ot=useScrollAreaContext(THUMB_NAME,tt),it=useScrollbarContext(THUMB_NAME,tt),{onThumbPositionChange:st}=it,at=useComposedRefs(o,dt=>it.onThumbChange(dt)),ct=reactExports.useRef(),lt=useDebounceCallback(()=>{ct.current&&(ct.current(),ct.current=void 0)},100);return reactExports.useEffect(()=>{const dt=ot.viewport;if(dt){const ht=()=>{if(lt(),!ct.current){const mt=addUnlinkedScrollListener(dt,st);ct.current=mt,st()}};return st(),dt.addEventListener("scroll",ht),()=>dt.removeEventListener("scroll",ht)}},[ot.viewport,lt,st]),jsxRuntimeExports.jsx(Primitive.div,{"data-state":it.hasThumb?"visible":"hidden",...nt,ref:at,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...rt},onPointerDownCapture:composeEventHandlers(et.onPointerDownCapture,dt=>{const mt=dt.target.getBoundingClientRect(),ft=dt.clientX-mt.left,pt=dt.clientY-mt.top;it.onThumbPointerDown({x:ft,y:pt})}),onPointerUp:composeEventHandlers(et.onPointerUp,it.onThumbPointerUp)})});ScrollAreaThumb.displayName=THUMB_NAME;var CORNER_NAME="ScrollAreaCorner",ScrollAreaCorner=reactExports.forwardRef((et,o)=>{const tt=useScrollAreaContext(CORNER_NAME,et.__scopeScrollArea),rt=!!(tt.scrollbarX&&tt.scrollbarY);return tt.type!=="scroll"&&rt?jsxRuntimeExports.jsx(ScrollAreaCornerImpl,{...et,ref:o}):null});ScrollAreaCorner.displayName=CORNER_NAME;var ScrollAreaCornerImpl=reactExports.forwardRef((et,o)=>{const{__scopeScrollArea:tt,...rt}=et,nt=useScrollAreaContext(CORNER_NAME,tt),[ot,it]=reactExports.useState(0),[st,at]=reactExports.useState(0),ct=!!(ot&&st);return useResizeObserver(nt.scrollbarX,()=>{var dt;const lt=((dt=nt.scrollbarX)==null?void 0:dt.offsetHeight)||0;nt.onCornerHeightChange(lt),at(lt)}),useResizeObserver(nt.scrollbarY,()=>{var dt;const lt=((dt=nt.scrollbarY)==null?void 0:dt.offsetWidth)||0;nt.onCornerWidthChange(lt),it(lt)}),ct?jsxRuntimeExports.jsx(Primitive.div,{...rt,ref:o,style:{width:ot,height:st,position:"absolute",right:nt.dir==="ltr"?0:void 0,left:nt.dir==="rtl"?0:void 0,bottom:0,...et.style}}):null});function toInt(et){return et?parseInt(et,10):0}function getThumbRatio(et,o){const tt=et/o;return isNaN(tt)?0:tt}function getThumbSize(et){const o=getThumbRatio(et.viewport,et.content),tt=et.scrollbar.paddingStart+et.scrollbar.paddingEnd,rt=(et.scrollbar.size-tt)*o;return Math.max(rt,18)}function getScrollPositionFromPointer(et,o,tt,rt="ltr"){const nt=getThumbSize(tt),ot=nt/2,it=o||ot,st=nt-it,at=tt.scrollbar.paddingStart+it,ct=tt.scrollbar.size-tt.scrollbar.paddingEnd-st,lt=tt.content-tt.viewport,dt=rt==="ltr"?[0,lt]:[lt*-1,0];return linearScale([at,ct],dt)(et)}function getThumbOffsetFromScroll(et,o,tt="ltr"){const rt=getThumbSize(o),nt=o.scrollbar.paddingStart+o.scrollbar.paddingEnd,ot=o.scrollbar.size-nt,it=o.content-o.viewport,st=ot-rt,at=tt==="ltr"?[0,it]:[it*-1,0],ct=clamp(et,at);return linearScale([0,it],[0,st])(ct)}function linearScale(et,o){return tt=>{if(et[0]===et[1]||o[0]===o[1])return o[0];const rt=(o[1]-o[0])/(et[1]-et[0]);return o[0]+rt*(tt-et[0])}}function isScrollingWithinScrollbarBounds(et,o){return et>0&&et{})=>{let tt={left:et.scrollLeft,top:et.scrollTop},rt=0;return function nt(){const ot={left:et.scrollLeft,top:et.scrollTop},it=tt.left!==ot.left,st=tt.top!==ot.top;(it||st)&&o(),tt=ot,rt=window.requestAnimationFrame(nt)}(),()=>window.cancelAnimationFrame(rt)};function useDebounceCallback(et,o){const tt=useCallbackRef$1(et),rt=reactExports.useRef(0);return reactExports.useEffect(()=>()=>window.clearTimeout(rt.current),[]),reactExports.useCallback(()=>{window.clearTimeout(rt.current),rt.current=window.setTimeout(tt,o)},[tt,o])}function useResizeObserver(et,o){const tt=useCallbackRef$1(o);useLayoutEffect2(()=>{let rt=0;if(et){const nt=new ResizeObserver(()=>{cancelAnimationFrame(rt),rt=window.requestAnimationFrame(tt)});return nt.observe(et),()=>{window.cancelAnimationFrame(rt),nt.unobserve(et)}}},[et,tt])}function getSubtree(et,o){const{asChild:tt,children:rt}=et;if(!tt)return typeof o=="function"?o(rt):o;const nt=reactExports.Children.only(rt);return reactExports.cloneElement(nt,{children:typeof o=="function"?o(nt.props.children):o})}var Root=ScrollArea$1,Viewport=ScrollAreaViewport,Corner=ScrollAreaCorner;const ScrollArea=reactExports.forwardRef(({className:et,children:o,...tt},rt)=>jsxRuntimeExports.jsxs(Root,{ref:rt,className:cn("relative overflow-hidden",et),...tt,children:[jsxRuntimeExports.jsx(Viewport,{className:"h-full w-full rounded-[inherit]",children:o}),jsxRuntimeExports.jsx(ScrollBar,{}),jsxRuntimeExports.jsx(Corner,{})]}));ScrollArea.displayName=Root.displayName;const ScrollBar=reactExports.forwardRef(({className:et,orientation:o="vertical",...tt},rt)=>jsxRuntimeExports.jsx(ScrollAreaScrollbar,{ref:rt,orientation:o,className:cn("flex touch-none select-none transition-colors",o==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",o==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",et),...tt,children:jsxRuntimeExports.jsx(ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));ScrollBar.displayName=ScrollAreaScrollbar.displayName;const privacyPolicy=` # Waku - Dogfooding Website *Last updated: 22 August 2024* @@ -4257,16 +4257,16 @@ To the extent that you have any questions about the Privacy Policy, please conta This document is licensed under CC-BY-SA. `;function ok$1(){}function unreachable(){}function stringify$1(et,o){const tt={};return(et[et.length-1]===""?[...et,""]:et).join((tt.padRight?" ":"")+","+(tt.padLeft===!1?"":" ")).trim()}const nameRe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nameReJsx=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,emptyOptions$2={};function name(et,o){return(emptyOptions$2.jsx?nameReJsx:nameRe).test(et)}const re=/[ \t\n\f\r]/g;function whitespace(et){return typeof et=="object"?et.type==="text"?empty$1(et.value):!1:empty$1(et)}function empty$1(et){return et.replace(re,"")===""}class Schema{constructor(o,tt,rt){this.property=o,this.normal=tt,rt&&(this.space=rt)}}Schema.prototype.property={};Schema.prototype.normal={};Schema.prototype.space=null;function merge(et,o){const tt={},rt={};let nt=-1;for(;++nt4&&tt.slice(0,4)==="data"&&valid.test(o)){if(o.charAt(4)==="-"){const ot=o.slice(5).replace(dash,camelcase);rt="data"+ot.charAt(0).toUpperCase()+ot.slice(1)}else{const ot=o.slice(4);if(!dash.test(ot)){let it=ot.replace(cap$1,kebab);it.charAt(0)!=="-"&&(it="-"+it),o="data"+it}}nt=DefinedInfo}return new nt(rt,o)}function kebab(et){return"-"+et.toLowerCase()}function camelcase(et){return et.charAt(1).toUpperCase()}const hastToReact={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},html$1=merge([xml,xlink,xmlns,aria,html$2],"html"),svg=merge([xml,xlink,xmlns,aria,svg$1],"svg");function stringify(et){return et.join(" ").trim()}var cjs={},COMMENT_REGEX=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,NEWLINE_REGEX=/\n/g,WHITESPACE_REGEX=/^\s*/,PROPERTY_REGEX=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,COLON_REGEX=/^:\s*/,VALUE_REGEX=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,SEMICOLON_REGEX=/^[;\s]*/,TRIM_REGEX=/^\s+|\s+$/g,NEWLINE=` -`,FORWARD_SLASH="/",ASTERISK="*",EMPTY_STRING="",TYPE_COMMENT="comment",TYPE_DECLARATION="declaration",inlineStyleParser=function(et,o){if(typeof et!="string")throw new TypeError("First argument must be a string");if(!et)return[];o=o||{};var tt=1,rt=1;function nt(ft){var pt=ft.match(NEWLINE_REGEX);pt&&(tt+=pt.length);var gt=ft.lastIndexOf(NEWLINE);rt=~gt?ft.length-gt:rt+ft.length}function ot(){var ft={line:tt,column:rt};return function(pt){return pt.position=new it(ft),ct(),pt}}function it(ft){this.start=ft,this.end={line:tt,column:rt},this.source=o.source}it.prototype.content=et;function st(ft){var pt=new Error(o.source+":"+tt+":"+rt+": "+ft);if(pt.reason=ft,pt.filename=o.source,pt.line=tt,pt.column=rt,pt.source=et,!o.silent)throw pt}function at(ft){var pt=ft.exec(et);if(pt){var gt=pt[0];return nt(gt),et=et.slice(gt.length),pt}}function ct(){at(WHITESPACE_REGEX)}function lt(ft){var pt;for(ft=ft||[];pt=dt();)pt!==!1&&ft.push(pt);return ft}function dt(){var ft=ot();if(!(FORWARD_SLASH!=et.charAt(0)||ASTERISK!=et.charAt(1))){for(var pt=2;EMPTY_STRING!=et.charAt(pt)&&(ASTERISK!=et.charAt(pt)||FORWARD_SLASH!=et.charAt(pt+1));)++pt;if(pt+=2,EMPTY_STRING===et.charAt(pt-1))return st("End of comment missing");var gt=et.slice(2,pt-2);return rt+=2,nt(gt),et=et.slice(pt),rt+=2,ft({type:TYPE_COMMENT,comment:gt})}}function ht(){var ft=ot(),pt=at(PROPERTY_REGEX);if(pt){if(dt(),!at(COLON_REGEX))return st("property missing ':'");var gt=at(VALUE_REGEX),yt=ft({type:TYPE_DECLARATION,property:trim(pt[0].replace(COMMENT_REGEX,EMPTY_STRING)),value:gt?trim(gt[0].replace(COMMENT_REGEX,EMPTY_STRING)):EMPTY_STRING});return at(SEMICOLON_REGEX),yt}}function mt(){var ft=[];lt(ft);for(var pt;pt=ht();)pt!==!1&&(ft.push(pt),lt(ft));return ft}return ct(),mt()};function trim(et){return et?et.replace(TRIM_REGEX,EMPTY_STRING):EMPTY_STRING}var __importDefault=commonjsGlobal&&commonjsGlobal.__importDefault||function(et){return et&&et.__esModule?et:{default:et}};Object.defineProperty(cjs,"__esModule",{value:!0});var _default=cjs.default=StyleToObject,inline_style_parser_1=__importDefault(inlineStyleParser);function StyleToObject(et,o){var tt=null;if(!et||typeof et!="string")return tt;var rt=(0,inline_style_parser_1.default)(et),nt=typeof o=="function";return rt.forEach(function(ot){if(ot.type==="declaration"){var it=ot.property,st=ot.value;nt?o(it,st,ot):st&&(tt=tt||{},tt[it]=st)}}),tt}const styleToObject=_default.default||_default,pointEnd=point$2("end"),pointStart=point$2("start");function point$2(et){return o;function o(tt){const rt=tt&&tt.position&&tt.position[et]||{};if(typeof rt.line=="number"&&rt.line>0&&typeof rt.column=="number"&&rt.column>0)return{line:rt.line,column:rt.column,offset:typeof rt.offset=="number"&&rt.offset>-1?rt.offset:void 0}}}function position$1(et){const o=pointStart(et),tt=pointEnd(et);if(o&&tt)return{start:o,end:tt}}function stringifyPosition(et){return!et||typeof et!="object"?"":"position"in et||"type"in et?position(et.position):"start"in et||"end"in et?position(et):"line"in et||"column"in et?point$1(et):""}function point$1(et){return index(et&&et.line)+":"+index(et&&et.column)}function position(et){return point$1(et&&et.start)+"-"+point$1(et&&et.end)}function index(et){return et&&typeof et=="number"?et:1}class VFileMessage extends Error{constructor(o,tt,rt){super(),typeof tt=="string"&&(rt=tt,tt=void 0);let nt="",ot={},it=!1;if(tt&&("line"in tt&&"column"in tt?ot={place:tt}:"start"in tt&&"end"in tt?ot={place:tt}:"type"in tt?ot={ancestors:[tt],place:tt.position}:ot={...tt}),typeof o=="string"?nt=o:!ot.cause&&o&&(it=!0,nt=o.message,ot.cause=o),!ot.ruleId&&!ot.source&&typeof rt=="string"){const at=rt.indexOf(":");at===-1?ot.ruleId=rt:(ot.source=rt.slice(0,at),ot.ruleId=rt.slice(at+1))}if(!ot.place&&ot.ancestors&&ot.ancestors){const at=ot.ancestors[ot.ancestors.length-1];at&&(ot.place=at.position)}const st=ot.place&&"start"in ot.place?ot.place.start:ot.place;this.ancestors=ot.ancestors||void 0,this.cause=ot.cause||void 0,this.column=st?st.column:void 0,this.fatal=void 0,this.file,this.message=nt,this.line=st?st.line:void 0,this.name=stringifyPosition(ot.place)||"1:1",this.place=ot.place||void 0,this.reason=this.message,this.ruleId=ot.ruleId||void 0,this.source=ot.source||void 0,this.stack=it&&ot.cause&&typeof ot.cause.stack=="string"?ot.cause.stack:"",this.actual,this.expected,this.note,this.url}}VFileMessage.prototype.file="";VFileMessage.prototype.name="";VFileMessage.prototype.reason="";VFileMessage.prototype.message="";VFileMessage.prototype.stack="";VFileMessage.prototype.column=void 0;VFileMessage.prototype.line=void 0;VFileMessage.prototype.ancestors=void 0;VFileMessage.prototype.cause=void 0;VFileMessage.prototype.fatal=void 0;VFileMessage.prototype.place=void 0;VFileMessage.prototype.ruleId=void 0;VFileMessage.prototype.source=void 0;const own$3={}.hasOwnProperty,emptyMap=new Map,cap=/[A-Z]/g,dashSomething=/-([a-z])/g,tableElements=new Set(["table","tbody","thead","tfoot","tr"]),tableCellElement=new Set(["td","th"]),docs="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function toJsxRuntime(et,o){if(!o||o.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const tt=o.filePath||void 0;let rt;if(o.development){if(typeof o.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");rt=developmentCreate(tt,o.jsxDEV)}else{if(typeof o.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof o.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");rt=productionCreate(tt,o.jsx,o.jsxs)}const nt={Fragment:o.Fragment,ancestors:[],components:o.components||{},create:rt,elementAttributeNameCase:o.elementAttributeNameCase||"react",evaluater:o.createEvaluater?o.createEvaluater():void 0,filePath:tt,ignoreInvalidStyle:o.ignoreInvalidStyle||!1,passKeys:o.passKeys!==!1,passNode:o.passNode||!1,schema:o.space==="svg"?svg:html$1,stylePropertyNameCase:o.stylePropertyNameCase||"dom",tableCellAlignToStyle:o.tableCellAlignToStyle!==!1},ot=one$1(nt,et,void 0);return ot&&typeof ot!="string"?ot:nt.create(et,nt.Fragment,{children:ot||void 0},void 0)}function one$1(et,o,tt){if(o.type==="element")return element$1(et,o,tt);if(o.type==="mdxFlowExpression"||o.type==="mdxTextExpression")return mdxExpression(et,o);if(o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement")return mdxJsxElement(et,o,tt);if(o.type==="mdxjsEsm")return mdxEsm(et,o);if(o.type==="root")return root$1(et,o,tt);if(o.type==="text")return text$3(et,o)}function element$1(et,o,tt){const rt=et.schema;let nt=rt;o.tagName.toLowerCase()==="svg"&&rt.space==="html"&&(nt=svg,et.schema=nt),et.ancestors.push(o);const ot=findComponentFromName(et,o.tagName,!1),it=createElementProps(et,o);let st=createChildren(et,o);return tableElements.has(o.tagName)&&(st=st.filter(function(at){return typeof at=="string"?!whitespace(at):!0})),addNode(et,it,ot,o),addChildren(it,st),et.ancestors.pop(),et.schema=rt,et.create(o,ot,it,tt)}function mdxExpression(et,o){if(o.data&&o.data.estree&&et.evaluater){const rt=o.data.estree.body[0];return rt.type,et.evaluater.evaluateExpression(rt.expression)}crashEstree(et,o.position)}function mdxEsm(et,o){if(o.data&&o.data.estree&&et.evaluater)return et.evaluater.evaluateProgram(o.data.estree);crashEstree(et,o.position)}function mdxJsxElement(et,o,tt){const rt=et.schema;let nt=rt;o.name==="svg"&&rt.space==="html"&&(nt=svg,et.schema=nt),et.ancestors.push(o);const ot=o.name===null?et.Fragment:findComponentFromName(et,o.name,!0),it=createJsxElementProps(et,o),st=createChildren(et,o);return addNode(et,it,ot,o),addChildren(it,st),et.ancestors.pop(),et.schema=rt,et.create(o,ot,it,tt)}function root$1(et,o,tt){const rt={};return addChildren(rt,createChildren(et,o)),et.create(o,et.Fragment,rt,tt)}function text$3(et,o){return o.value}function addNode(et,o,tt,rt){typeof tt!="string"&&tt!==et.Fragment&&et.passNode&&(o.node=rt)}function addChildren(et,o){if(o.length>0){const tt=o.length>1?o:o[0];tt&&(et.children=tt)}}function productionCreate(et,o,tt){return rt;function rt(nt,ot,it,st){const ct=Array.isArray(it.children)?tt:o;return st?ct(ot,it,st):ct(ot,it)}}function developmentCreate(et,o){return tt;function tt(rt,nt,ot,it){const st=Array.isArray(ot.children),at=pointStart(rt);return o(nt,ot,it,st,{columnNumber:at?at.column-1:void 0,fileName:et,lineNumber:at?at.line:void 0},void 0)}}function createElementProps(et,o){const tt={};let rt,nt;for(nt in o.properties)if(nt!=="children"&&own$3.call(o.properties,nt)){const ot=createProperty(et,nt,o.properties[nt]);if(ot){const[it,st]=ot;et.tableCellAlignToStyle&&it==="align"&&typeof st=="string"&&tableCellElement.has(o.tagName)?rt=st:tt[it]=st}}if(rt){const ot=tt.style||(tt.style={});ot[et.stylePropertyNameCase==="css"?"text-align":"textAlign"]=rt}return tt}function createJsxElementProps(et,o){const tt={};for(const rt of o.attributes)if(rt.type==="mdxJsxExpressionAttribute")if(rt.data&&rt.data.estree&&et.evaluater){const ot=rt.data.estree.body[0];ot.type;const it=ot.expression;it.type;const st=it.properties[0];st.type,Object.assign(tt,et.evaluater.evaluateExpression(st.argument))}else crashEstree(et,o.position);else{const nt=rt.name;let ot;if(rt.value&&typeof rt.value=="object")if(rt.value.data&&rt.value.data.estree&&et.evaluater){const st=rt.value.data.estree.body[0];st.type,ot=et.evaluater.evaluateExpression(st.expression)}else crashEstree(et,o.position);else ot=rt.value===null?!0:rt.value;tt[nt]=ot}return tt}function createChildren(et,o){const tt=[];let rt=-1;const nt=et.passKeys?new Map:emptyMap;for(;++rtnt?0:nt+o:o=o>nt?nt:o,tt=tt>0?tt:0,rt.length<1e4)it=Array.from(rt),it.unshift(o,tt),et.splice(...it);else for(tt&&et.splice(o,tt);ot0?(splice(et,et.length,0,o),et):o}const hasOwnProperty={}.hasOwnProperty;function combineExtensions(et){const o={};let tt=-1;for(;++tt13&&tt<32||tt>126&&tt<160||tt>55295&&tt<57344||tt>64975&&tt<65008||(tt&65535)===65535||(tt&65535)===65534||tt>1114111?"�":String.fromCodePoint(tt)}function normalizeIdentifier(et){return et.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const asciiAlpha=regexCheck(/[A-Za-z]/),asciiAlphanumeric=regexCheck(/[\dA-Za-z]/),asciiAtext=regexCheck(/[#-'*+\--9=?A-Z^-~]/);function asciiControl(et){return et!==null&&(et<32||et===127)}const asciiDigit=regexCheck(/\d/),asciiHexDigit=regexCheck(/[\dA-Fa-f]/),asciiPunctuation=regexCheck(/[!-/:-@[-`{-~]/);function markdownLineEnding(et){return et!==null&&et<-2}function markdownLineEndingOrSpace(et){return et!==null&&(et<0||et===32)}function markdownSpace(et){return et===-2||et===-1||et===32}const unicodePunctuation=regexCheck(new RegExp("\\p{P}|\\p{S}","u")),unicodeWhitespace=regexCheck(/\s/);function regexCheck(et){return o;function o(tt){return tt!==null&&tt>-1&&et.test(String.fromCharCode(tt))}}function normalizeUri(et){const o=[];let tt=-1,rt=0,nt=0;for(;++tt55295&&ot<57344){const st=et.charCodeAt(tt+1);ot<56320&&st>56319&&st<57344?(it=String.fromCharCode(ot,st),nt=1):it="�"}else it=String.fromCharCode(ot);it&&(o.push(et.slice(rt,tt),encodeURIComponent(it)),rt=tt+nt+1,it=""),nt&&(tt+=nt,nt=0)}return o.join("")+et.slice(rt)}function factorySpace(et,o,tt,rt){const nt=rt?rt-1:Number.POSITIVE_INFINITY;let ot=0;return it;function it(at){return markdownSpace(at)?(et.enter(tt),st(at)):o(at)}function st(at){return markdownSpace(at)&&ot++it))return;const St=o.events.length;let At=St,kt,It;for(;At--;)if(o.events[At][0]==="exit"&&o.events[At][1].type==="chunkFlow"){if(kt){It=o.events[At][1].end;break}kt=!0}for(yt(rt),Ct=St;Ctxt;){const Et=tt[vt];o.containerState=Et[1],Et[0].exit.call(o,et)}tt.length=xt}function bt(){nt.write([null]),ot=void 0,nt=void 0,o.containerState._closeFlow=void 0}}function tokenizeContainer(et,o,tt){return factorySpace(et,et.attempt(this.parser.constructs.document,o,tt),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function classifyCharacter(et){if(et===null||markdownLineEndingOrSpace(et)||unicodeWhitespace(et))return 1;if(unicodePunctuation(et))return 2}function resolveAll(et,o,tt){const rt=[];let nt=-1;for(;++nt1&&et[tt][1].end.offset-et[tt][1].start.offset>1?2:1;const dt=Object.assign({},et[rt][1].end),ht=Object.assign({},et[tt][1].start);movePoint(dt,-at),movePoint(ht,at),it={type:at>1?"strongSequence":"emphasisSequence",start:dt,end:Object.assign({},et[rt][1].end)},st={type:at>1?"strongSequence":"emphasisSequence",start:Object.assign({},et[tt][1].start),end:ht},ot={type:at>1?"strongText":"emphasisText",start:Object.assign({},et[rt][1].end),end:Object.assign({},et[tt][1].start)},nt={type:at>1?"strong":"emphasis",start:Object.assign({},it.start),end:Object.assign({},st.end)},et[rt][1].end=Object.assign({},it.start),et[tt][1].start=Object.assign({},st.end),ct=[],et[rt][1].end.offset-et[rt][1].start.offset&&(ct=push(ct,[["enter",et[rt][1],o],["exit",et[rt][1],o]])),ct=push(ct,[["enter",nt,o],["enter",it,o],["exit",it,o],["enter",ot,o]]),ct=push(ct,resolveAll(o.parser.constructs.insideSpan.null,et.slice(rt+1,tt),o)),ct=push(ct,[["exit",ot,o],["enter",st,o],["exit",st,o],["exit",nt,o]]),et[tt][1].end.offset-et[tt][1].start.offset?(lt=2,ct=push(ct,[["enter",et[tt][1],o],["exit",et[tt][1],o]])):lt=0,splice(et,rt-1,tt-rt+3,ct),tt=rt+ct.length-lt-2;break}}for(tt=-1;++tt0&&markdownSpace(Ct)?factorySpace(et,bt,"linePrefix",ot+1)(Ct):bt(Ct)}function bt(Ct){return Ct===null||markdownLineEnding(Ct)?et.check(nonLazyContinuation,pt,vt)(Ct):(et.enter("codeFlowValue"),xt(Ct))}function xt(Ct){return Ct===null||markdownLineEnding(Ct)?(et.exit("codeFlowValue"),bt(Ct)):(et.consume(Ct),xt)}function vt(Ct){return et.exit("codeFenced"),o(Ct)}function Et(Ct,St,At){let kt=0;return It;function It(Ht){return Ct.enter("lineEnding"),Ct.consume(Ht),Ct.exit("lineEnding"),Ot}function Ot(Ht){return Ct.enter("codeFencedFence"),markdownSpace(Ht)?factorySpace(Ct,Nt,"linePrefix",rt.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Ht):Nt(Ht)}function Nt(Ht){return Ht===st?(Ct.enter("codeFencedFenceSequence"),Yt(Ht)):At(Ht)}function Yt(Ht){return Ht===st?(kt++,Ct.consume(Ht),Yt):kt>=it?(Ct.exit("codeFencedFenceSequence"),markdownSpace(Ht)?factorySpace(Ct,Ft,"whitespace")(Ht):Ft(Ht)):At(Ht)}function Ft(Ht){return Ht===null||markdownLineEnding(Ht)?(Ct.exit("codeFencedFence"),St(Ht)):At(Ht)}}}function tokenizeNonLazyContinuation(et,o,tt){const rt=this;return nt;function nt(it){return it===null?tt(it):(et.enter("lineEnding"),et.consume(it),et.exit("lineEnding"),ot)}function ot(it){return rt.parser.lazy[rt.now().line]?tt(it):o(it)}}const codeIndented={name:"codeIndented",tokenize:tokenizeCodeIndented},furtherStart={tokenize:tokenizeFurtherStart,partial:!0};function tokenizeCodeIndented(et,o,tt){const rt=this;return nt;function nt(ct){return et.enter("codeIndented"),factorySpace(et,ot,"linePrefix",5)(ct)}function ot(ct){const lt=rt.events[rt.events.length-1];return lt&<[1].type==="linePrefix"&<[2].sliceSerialize(lt[1],!0).length>=4?it(ct):tt(ct)}function it(ct){return ct===null?at(ct):markdownLineEnding(ct)?et.attempt(furtherStart,it,at)(ct):(et.enter("codeFlowValue"),st(ct))}function st(ct){return ct===null||markdownLineEnding(ct)?(et.exit("codeFlowValue"),it(ct)):(et.consume(ct),st)}function at(ct){return et.exit("codeIndented"),o(ct)}}function tokenizeFurtherStart(et,o,tt){const rt=this;return nt;function nt(it){return rt.parser.lazy[rt.now().line]?tt(it):markdownLineEnding(it)?(et.enter("lineEnding"),et.consume(it),et.exit("lineEnding"),nt):factorySpace(et,ot,"linePrefix",5)(it)}function ot(it){const st=rt.events[rt.events.length-1];return st&&st[1].type==="linePrefix"&&st[2].sliceSerialize(st[1],!0).length>=4?o(it):markdownLineEnding(it)?nt(it):tt(it)}}const codeText={name:"codeText",tokenize:tokenizeCodeText,resolve:resolveCodeText,previous};function resolveCodeText(et){let o=et.length-4,tt=3,rt,nt;if((et[tt][1].type==="lineEnding"||et[tt][1].type==="space")&&(et[o][1].type==="lineEnding"||et[o][1].type==="space")){for(rt=tt;++rt=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+o+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return othis.left.length?this.right.slice(this.right.length-rt+this.left.length,this.right.length-o+this.left.length).reverse():this.left.slice(o).concat(this.right.slice(this.right.length-rt+this.left.length).reverse())}splice(o,tt,rt){const nt=tt||0;this.setCursor(Math.trunc(o));const ot=this.right.splice(this.right.length-nt,Number.POSITIVE_INFINITY);return rt&&chunkedPush(this.left,rt),ot.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(o){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(o)}pushMany(o){this.setCursor(Number.POSITIVE_INFINITY),chunkedPush(this.left,o)}unshift(o){this.setCursor(0),this.right.push(o)}unshiftMany(o){this.setCursor(0),chunkedPush(this.right,o.reverse())}setCursor(o){if(!(o===this.left.length||o>this.left.length&&this.right.length===0||o<0&&this.left.length===0))if(o=4?o(it):et.interrupt(rt.parser.constructs.flow,tt,o)(it)}}function factoryDestination(et,o,tt,rt,nt,ot,it,st,at){const ct=at||Number.POSITIVE_INFINITY;let lt=0;return dt;function dt(yt){return yt===60?(et.enter(rt),et.enter(nt),et.enter(ot),et.consume(yt),et.exit(ot),ht):yt===null||yt===32||yt===41||asciiControl(yt)?tt(yt):(et.enter(rt),et.enter(it),et.enter(st),et.enter("chunkString",{contentType:"string"}),pt(yt))}function ht(yt){return yt===62?(et.enter(ot),et.consume(yt),et.exit(ot),et.exit(nt),et.exit(rt),o):(et.enter(st),et.enter("chunkString",{contentType:"string"}),mt(yt))}function mt(yt){return yt===62?(et.exit("chunkString"),et.exit(st),ht(yt)):yt===null||yt===60||markdownLineEnding(yt)?tt(yt):(et.consume(yt),yt===92?ft:mt)}function ft(yt){return yt===60||yt===62||yt===92?(et.consume(yt),mt):mt(yt)}function pt(yt){return!lt&&(yt===null||yt===41||markdownLineEndingOrSpace(yt))?(et.exit("chunkString"),et.exit(st),et.exit(it),et.exit(rt),o(yt)):lt999||mt===null||mt===91||mt===93&&!at||mt===94&&!st&&"_hiddenFootnoteSupport"in it.parser.constructs?tt(mt):mt===93?(et.exit(ot),et.enter(nt),et.consume(mt),et.exit(nt),et.exit(rt),o):markdownLineEnding(mt)?(et.enter("lineEnding"),et.consume(mt),et.exit("lineEnding"),lt):(et.enter("chunkString",{contentType:"string"}),dt(mt))}function dt(mt){return mt===null||mt===91||mt===93||markdownLineEnding(mt)||st++>999?(et.exit("chunkString"),lt(mt)):(et.consume(mt),at||(at=!markdownSpace(mt)),mt===92?ht:dt)}function ht(mt){return mt===91||mt===92||mt===93?(et.consume(mt),st++,dt):dt(mt)}}function factoryTitle(et,o,tt,rt,nt,ot){let it;return st;function st(ht){return ht===34||ht===39||ht===40?(et.enter(rt),et.enter(nt),et.consume(ht),et.exit(nt),it=ht===40?41:ht,at):tt(ht)}function at(ht){return ht===it?(et.enter(nt),et.consume(ht),et.exit(nt),et.exit(rt),o):(et.enter(ot),ct(ht))}function ct(ht){return ht===it?(et.exit(ot),at(it)):ht===null?tt(ht):markdownLineEnding(ht)?(et.enter("lineEnding"),et.consume(ht),et.exit("lineEnding"),factorySpace(et,ct,"linePrefix")):(et.enter("chunkString",{contentType:"string"}),lt(ht))}function lt(ht){return ht===it||ht===null||markdownLineEnding(ht)?(et.exit("chunkString"),ct(ht)):(et.consume(ht),ht===92?dt:lt)}function dt(ht){return ht===it||ht===92?(et.consume(ht),lt):lt(ht)}}function factoryWhitespace(et,o){let tt;return rt;function rt(nt){return markdownLineEnding(nt)?(et.enter("lineEnding"),et.consume(nt),et.exit("lineEnding"),tt=!0,rt):markdownSpace(nt)?factorySpace(et,rt,tt?"linePrefix":"lineSuffix")(nt):o(nt)}}const definition={name:"definition",tokenize:tokenizeDefinition},titleBefore={tokenize:tokenizeTitleBefore,partial:!0};function tokenizeDefinition(et,o,tt){const rt=this;let nt;return ot;function ot(mt){return et.enter("definition"),it(mt)}function it(mt){return factoryLabel.call(rt,et,st,tt,"definitionLabel","definitionLabelMarker","definitionLabelString")(mt)}function st(mt){return nt=normalizeIdentifier(rt.sliceSerialize(rt.events[rt.events.length-1][1]).slice(1,-1)),mt===58?(et.enter("definitionMarker"),et.consume(mt),et.exit("definitionMarker"),at):tt(mt)}function at(mt){return markdownLineEndingOrSpace(mt)?factoryWhitespace(et,ct)(mt):ct(mt)}function ct(mt){return factoryDestination(et,lt,tt,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(mt)}function lt(mt){return et.attempt(titleBefore,dt,dt)(mt)}function dt(mt){return markdownSpace(mt)?factorySpace(et,ht,"whitespace")(mt):ht(mt)}function ht(mt){return mt===null||markdownLineEnding(mt)?(et.exit("definition"),rt.parser.defined.push(nt),o(mt)):tt(mt)}}function tokenizeTitleBefore(et,o,tt){return rt;function rt(st){return markdownLineEndingOrSpace(st)?factoryWhitespace(et,nt)(st):tt(st)}function nt(st){return factoryTitle(et,ot,tt,"definitionTitle","definitionTitleMarker","definitionTitleString")(st)}function ot(st){return markdownSpace(st)?factorySpace(et,it,"whitespace")(st):it(st)}function it(st){return st===null||markdownLineEnding(st)?o(st):tt(st)}}const hardBreakEscape={name:"hardBreakEscape",tokenize:tokenizeHardBreakEscape};function tokenizeHardBreakEscape(et,o,tt){return rt;function rt(ot){return et.enter("hardBreakEscape"),et.consume(ot),nt}function nt(ot){return markdownLineEnding(ot)?(et.exit("hardBreakEscape"),o(ot)):tt(ot)}}const headingAtx={name:"headingAtx",tokenize:tokenizeHeadingAtx,resolve:resolveHeadingAtx};function resolveHeadingAtx(et,o){let tt=et.length-2,rt=3,nt,ot;return et[rt][1].type==="whitespace"&&(rt+=2),tt-2>rt&&et[tt][1].type==="whitespace"&&(tt-=2),et[tt][1].type==="atxHeadingSequence"&&(rt===tt-1||tt-4>rt&&et[tt-2][1].type==="whitespace")&&(tt-=rt+1===tt?2:4),tt>rt&&(nt={type:"atxHeadingText",start:et[rt][1].start,end:et[tt][1].end},ot={type:"chunkText",start:et[rt][1].start,end:et[tt][1].end,contentType:"text"},splice(et,rt,tt-rt+1,[["enter",nt,o],["enter",ot,o],["exit",ot,o],["exit",nt,o]])),et}function tokenizeHeadingAtx(et,o,tt){let rt=0;return nt;function nt(lt){return et.enter("atxHeading"),ot(lt)}function ot(lt){return et.enter("atxHeadingSequence"),it(lt)}function it(lt){return lt===35&&rt++<6?(et.consume(lt),it):lt===null||markdownLineEndingOrSpace(lt)?(et.exit("atxHeadingSequence"),st(lt)):tt(lt)}function st(lt){return lt===35?(et.enter("atxHeadingSequence"),at(lt)):lt===null||markdownLineEnding(lt)?(et.exit("atxHeading"),o(lt)):markdownSpace(lt)?factorySpace(et,st,"whitespace")(lt):(et.enter("atxHeadingText"),ct(lt))}function at(lt){return lt===35?(et.consume(lt),at):(et.exit("atxHeadingSequence"),st(lt))}function ct(lt){return lt===null||lt===35||markdownLineEndingOrSpace(lt)?(et.exit("atxHeadingText"),st(lt)):(et.consume(lt),ct)}}const htmlBlockNames=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],htmlRawNames=["pre","script","style","textarea"],htmlFlow={name:"htmlFlow",tokenize:tokenizeHtmlFlow,resolveTo:resolveToHtmlFlow,concrete:!0},blankLineBefore={tokenize:tokenizeBlankLineBefore,partial:!0},nonLazyContinuationStart={tokenize:tokenizeNonLazyContinuationStart,partial:!0};function resolveToHtmlFlow(et){let o=et.length;for(;o--&&!(et[o][0]==="enter"&&et[o][1].type==="htmlFlow"););return o>1&&et[o-2][1].type==="linePrefix"&&(et[o][1].start=et[o-2][1].start,et[o+1][1].start=et[o-2][1].start,et.splice(o-2,2)),et}function tokenizeHtmlFlow(et,o,tt){const rt=this;let nt,ot,it,st,at;return ct;function ct(Pt){return lt(Pt)}function lt(Pt){return et.enter("htmlFlow"),et.enter("htmlFlowData"),et.consume(Pt),dt}function dt(Pt){return Pt===33?(et.consume(Pt),ht):Pt===47?(et.consume(Pt),ot=!0,pt):Pt===63?(et.consume(Pt),nt=3,rt.interrupt?o:jt):asciiAlpha(Pt)?(et.consume(Pt),it=String.fromCharCode(Pt),gt):tt(Pt)}function ht(Pt){return Pt===45?(et.consume(Pt),nt=2,mt):Pt===91?(et.consume(Pt),nt=5,st=0,ft):asciiAlpha(Pt)?(et.consume(Pt),nt=4,rt.interrupt?o:jt):tt(Pt)}function mt(Pt){return Pt===45?(et.consume(Pt),rt.interrupt?o:jt):tt(Pt)}function ft(Pt){const Gt="CDATA[";return Pt===Gt.charCodeAt(st++)?(et.consume(Pt),st===Gt.length?rt.interrupt?o:Nt:ft):tt(Pt)}function pt(Pt){return asciiAlpha(Pt)?(et.consume(Pt),it=String.fromCharCode(Pt),gt):tt(Pt)}function gt(Pt){if(Pt===null||Pt===47||Pt===62||markdownLineEndingOrSpace(Pt)){const Gt=Pt===47,tr=it.toLowerCase();return!Gt&&!ot&&htmlRawNames.includes(tr)?(nt=1,rt.interrupt?o(Pt):Nt(Pt)):htmlBlockNames.includes(it.toLowerCase())?(nt=6,Gt?(et.consume(Pt),yt):rt.interrupt?o(Pt):Nt(Pt)):(nt=7,rt.interrupt&&!rt.parser.lazy[rt.now().line]?tt(Pt):ot?bt(Pt):xt(Pt))}return Pt===45||asciiAlphanumeric(Pt)?(et.consume(Pt),it+=String.fromCharCode(Pt),gt):tt(Pt)}function yt(Pt){return Pt===62?(et.consume(Pt),rt.interrupt?o:Nt):tt(Pt)}function bt(Pt){return markdownSpace(Pt)?(et.consume(Pt),bt):It(Pt)}function xt(Pt){return Pt===47?(et.consume(Pt),It):Pt===58||Pt===95||asciiAlpha(Pt)?(et.consume(Pt),vt):markdownSpace(Pt)?(et.consume(Pt),xt):It(Pt)}function vt(Pt){return Pt===45||Pt===46||Pt===58||Pt===95||asciiAlphanumeric(Pt)?(et.consume(Pt),vt):Et(Pt)}function Et(Pt){return Pt===61?(et.consume(Pt),Ct):markdownSpace(Pt)?(et.consume(Pt),Et):xt(Pt)}function Ct(Pt){return Pt===null||Pt===60||Pt===61||Pt===62||Pt===96?tt(Pt):Pt===34||Pt===39?(et.consume(Pt),at=Pt,St):markdownSpace(Pt)?(et.consume(Pt),Ct):At(Pt)}function St(Pt){return Pt===at?(et.consume(Pt),at=null,kt):Pt===null||markdownLineEnding(Pt)?tt(Pt):(et.consume(Pt),St)}function At(Pt){return Pt===null||Pt===34||Pt===39||Pt===47||Pt===60||Pt===61||Pt===62||Pt===96||markdownLineEndingOrSpace(Pt)?Et(Pt):(et.consume(Pt),At)}function kt(Pt){return Pt===47||Pt===62||markdownSpace(Pt)?xt(Pt):tt(Pt)}function It(Pt){return Pt===62?(et.consume(Pt),Ot):tt(Pt)}function Ot(Pt){return Pt===null||markdownLineEnding(Pt)?Nt(Pt):markdownSpace(Pt)?(et.consume(Pt),Ot):tt(Pt)}function Nt(Pt){return Pt===45&&nt===2?(et.consume(Pt),Qt):Pt===60&&nt===1?(et.consume(Pt),Vt):Pt===62&&nt===4?(et.consume(Pt),Xt):Pt===63&&nt===3?(et.consume(Pt),jt):Pt===93&&nt===5?(et.consume(Pt),Wt):markdownLineEnding(Pt)&&(nt===6||nt===7)?(et.exit("htmlFlowData"),et.check(blankLineBefore,Kt,Yt)(Pt)):Pt===null||markdownLineEnding(Pt)?(et.exit("htmlFlowData"),Yt(Pt)):(et.consume(Pt),Nt)}function Yt(Pt){return et.check(nonLazyContinuationStart,Ft,Kt)(Pt)}function Ft(Pt){return et.enter("lineEnding"),et.consume(Pt),et.exit("lineEnding"),Ht}function Ht(Pt){return Pt===null||markdownLineEnding(Pt)?Yt(Pt):(et.enter("htmlFlowData"),Nt(Pt))}function Qt(Pt){return Pt===45?(et.consume(Pt),jt):Nt(Pt)}function Vt(Pt){return Pt===47?(et.consume(Pt),it="",Bt):Nt(Pt)}function Bt(Pt){if(Pt===62){const Gt=it.toLowerCase();return htmlRawNames.includes(Gt)?(et.consume(Pt),Xt):Nt(Pt)}return asciiAlpha(Pt)&&it.length<8?(et.consume(Pt),it+=String.fromCharCode(Pt),Bt):Nt(Pt)}function Wt(Pt){return Pt===93?(et.consume(Pt),jt):Nt(Pt)}function jt(Pt){return Pt===62?(et.consume(Pt),Xt):Pt===45&&nt===2?(et.consume(Pt),jt):Nt(Pt)}function Xt(Pt){return Pt===null||markdownLineEnding(Pt)?(et.exit("htmlFlowData"),Kt(Pt)):(et.consume(Pt),Xt)}function Kt(Pt){return et.exit("htmlFlow"),o(Pt)}}function tokenizeNonLazyContinuationStart(et,o,tt){const rt=this;return nt;function nt(it){return markdownLineEnding(it)?(et.enter("lineEnding"),et.consume(it),et.exit("lineEnding"),ot):tt(it)}function ot(it){return rt.parser.lazy[rt.now().line]?tt(it):o(it)}}function tokenizeBlankLineBefore(et,o,tt){return rt;function rt(nt){return et.enter("lineEnding"),et.consume(nt),et.exit("lineEnding"),et.attempt(blankLine,o,tt)}}const htmlText={name:"htmlText",tokenize:tokenizeHtmlText};function tokenizeHtmlText(et,o,tt){const rt=this;let nt,ot,it;return st;function st(jt){return et.enter("htmlText"),et.enter("htmlTextData"),et.consume(jt),at}function at(jt){return jt===33?(et.consume(jt),ct):jt===47?(et.consume(jt),Et):jt===63?(et.consume(jt),xt):asciiAlpha(jt)?(et.consume(jt),At):tt(jt)}function ct(jt){return jt===45?(et.consume(jt),lt):jt===91?(et.consume(jt),ot=0,ft):asciiAlpha(jt)?(et.consume(jt),bt):tt(jt)}function lt(jt){return jt===45?(et.consume(jt),mt):tt(jt)}function dt(jt){return jt===null?tt(jt):jt===45?(et.consume(jt),ht):markdownLineEnding(jt)?(it=dt,Vt(jt)):(et.consume(jt),dt)}function ht(jt){return jt===45?(et.consume(jt),mt):dt(jt)}function mt(jt){return jt===62?Qt(jt):jt===45?ht(jt):dt(jt)}function ft(jt){const Xt="CDATA[";return jt===Xt.charCodeAt(ot++)?(et.consume(jt),ot===Xt.length?pt:ft):tt(jt)}function pt(jt){return jt===null?tt(jt):jt===93?(et.consume(jt),gt):markdownLineEnding(jt)?(it=pt,Vt(jt)):(et.consume(jt),pt)}function gt(jt){return jt===93?(et.consume(jt),yt):pt(jt)}function yt(jt){return jt===62?Qt(jt):jt===93?(et.consume(jt),yt):pt(jt)}function bt(jt){return jt===null||jt===62?Qt(jt):markdownLineEnding(jt)?(it=bt,Vt(jt)):(et.consume(jt),bt)}function xt(jt){return jt===null?tt(jt):jt===63?(et.consume(jt),vt):markdownLineEnding(jt)?(it=xt,Vt(jt)):(et.consume(jt),xt)}function vt(jt){return jt===62?Qt(jt):xt(jt)}function Et(jt){return asciiAlpha(jt)?(et.consume(jt),Ct):tt(jt)}function Ct(jt){return jt===45||asciiAlphanumeric(jt)?(et.consume(jt),Ct):St(jt)}function St(jt){return markdownLineEnding(jt)?(it=St,Vt(jt)):markdownSpace(jt)?(et.consume(jt),St):Qt(jt)}function At(jt){return jt===45||asciiAlphanumeric(jt)?(et.consume(jt),At):jt===47||jt===62||markdownLineEndingOrSpace(jt)?kt(jt):tt(jt)}function kt(jt){return jt===47?(et.consume(jt),Qt):jt===58||jt===95||asciiAlpha(jt)?(et.consume(jt),It):markdownLineEnding(jt)?(it=kt,Vt(jt)):markdownSpace(jt)?(et.consume(jt),kt):Qt(jt)}function It(jt){return jt===45||jt===46||jt===58||jt===95||asciiAlphanumeric(jt)?(et.consume(jt),It):Ot(jt)}function Ot(jt){return jt===61?(et.consume(jt),Nt):markdownLineEnding(jt)?(it=Ot,Vt(jt)):markdownSpace(jt)?(et.consume(jt),Ot):kt(jt)}function Nt(jt){return jt===null||jt===60||jt===61||jt===62||jt===96?tt(jt):jt===34||jt===39?(et.consume(jt),nt=jt,Yt):markdownLineEnding(jt)?(it=Nt,Vt(jt)):markdownSpace(jt)?(et.consume(jt),Nt):(et.consume(jt),Ft)}function Yt(jt){return jt===nt?(et.consume(jt),nt=void 0,Ht):jt===null?tt(jt):markdownLineEnding(jt)?(it=Yt,Vt(jt)):(et.consume(jt),Yt)}function Ft(jt){return jt===null||jt===34||jt===39||jt===60||jt===61||jt===96?tt(jt):jt===47||jt===62||markdownLineEndingOrSpace(jt)?kt(jt):(et.consume(jt),Ft)}function Ht(jt){return jt===47||jt===62||markdownLineEndingOrSpace(jt)?kt(jt):tt(jt)}function Qt(jt){return jt===62?(et.consume(jt),et.exit("htmlTextData"),et.exit("htmlText"),o):tt(jt)}function Vt(jt){return et.exit("htmlTextData"),et.enter("lineEnding"),et.consume(jt),et.exit("lineEnding"),Bt}function Bt(jt){return markdownSpace(jt)?factorySpace(et,Wt,"linePrefix",rt.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(jt):Wt(jt)}function Wt(jt){return et.enter("htmlTextData"),it(jt)}}const labelEnd={name:"labelEnd",tokenize:tokenizeLabelEnd,resolveTo:resolveToLabelEnd,resolveAll:resolveAllLabelEnd},resourceConstruct={tokenize:tokenizeResource},referenceFullConstruct={tokenize:tokenizeReferenceFull},referenceCollapsedConstruct={tokenize:tokenizeReferenceCollapsed};function resolveAllLabelEnd(et){let o=-1;for(;++o=3&&(ct===null||markdownLineEnding(ct))?(et.exit("thematicBreak"),o(ct)):tt(ct)}function at(ct){return ct===nt?(et.consume(ct),rt++,at):(et.exit("thematicBreakSequence"),markdownSpace(ct)?factorySpace(et,st,"whitespace")(ct):st(ct))}}const list$1={name:"list",tokenize:tokenizeListStart,continuation:{tokenize:tokenizeListContinuation},exit:tokenizeListEnd},listItemPrefixWhitespaceConstruct={tokenize:tokenizeListItemPrefixWhitespace,partial:!0},indentConstruct={tokenize:tokenizeIndent,partial:!0};function tokenizeListStart(et,o,tt){const rt=this,nt=rt.events[rt.events.length-1];let ot=nt&&nt[1].type==="linePrefix"?nt[2].sliceSerialize(nt[1],!0).length:0,it=0;return st;function st(mt){const ft=rt.containerState.type||(mt===42||mt===43||mt===45?"listUnordered":"listOrdered");if(ft==="listUnordered"?!rt.containerState.marker||mt===rt.containerState.marker:asciiDigit(mt)){if(rt.containerState.type||(rt.containerState.type=ft,et.enter(ft,{_container:!0})),ft==="listUnordered")return et.enter("listItemPrefix"),mt===42||mt===45?et.check(thematicBreak$1,tt,ct)(mt):ct(mt);if(!rt.interrupt||mt===49)return et.enter("listItemPrefix"),et.enter("listItemValue"),at(mt)}return tt(mt)}function at(mt){return asciiDigit(mt)&&++it<10?(et.consume(mt),at):(!rt.interrupt||it<2)&&(rt.containerState.marker?mt===rt.containerState.marker:mt===41||mt===46)?(et.exit("listItemValue"),ct(mt)):tt(mt)}function ct(mt){return et.enter("listItemMarker"),et.consume(mt),et.exit("listItemMarker"),rt.containerState.marker=rt.containerState.marker||mt,et.check(blankLine,rt.interrupt?tt:lt,et.attempt(listItemPrefixWhitespaceConstruct,ht,dt))}function lt(mt){return rt.containerState.initialBlankLine=!0,ot++,ht(mt)}function dt(mt){return markdownSpace(mt)?(et.enter("listItemPrefixWhitespace"),et.consume(mt),et.exit("listItemPrefixWhitespace"),ht):tt(mt)}function ht(mt){return rt.containerState.size=ot+rt.sliceSerialize(et.exit("listItemPrefix"),!0).length,o(mt)}}function tokenizeListContinuation(et,o,tt){const rt=this;return rt.containerState._closeFlow=void 0,et.check(blankLine,nt,ot);function nt(st){return rt.containerState.furtherBlankLines=rt.containerState.furtherBlankLines||rt.containerState.initialBlankLine,factorySpace(et,o,"listItemIndent",rt.containerState.size+1)(st)}function ot(st){return rt.containerState.furtherBlankLines||!markdownSpace(st)?(rt.containerState.furtherBlankLines=void 0,rt.containerState.initialBlankLine=void 0,it(st)):(rt.containerState.furtherBlankLines=void 0,rt.containerState.initialBlankLine=void 0,et.attempt(indentConstruct,o,it)(st))}function it(st){return rt.containerState._closeFlow=!0,rt.interrupt=void 0,factorySpace(et,et.attempt(list$1,o,tt),"linePrefix",rt.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(st)}}function tokenizeIndent(et,o,tt){const rt=this;return factorySpace(et,nt,"listItemIndent",rt.containerState.size+1);function nt(ot){const it=rt.events[rt.events.length-1];return it&&it[1].type==="listItemIndent"&&it[2].sliceSerialize(it[1],!0).length===rt.containerState.size?o(ot):tt(ot)}}function tokenizeListEnd(et){et.exit(this.containerState.type)}function tokenizeListItemPrefixWhitespace(et,o,tt){const rt=this;return factorySpace(et,nt,"listItemPrefixWhitespace",rt.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function nt(ot){const it=rt.events[rt.events.length-1];return!markdownSpace(ot)&&it&&it[1].type==="listItemPrefixWhitespace"?o(ot):tt(ot)}}const setextUnderline={name:"setextUnderline",tokenize:tokenizeSetextUnderline,resolveTo:resolveToSetextUnderline};function resolveToSetextUnderline(et,o){let tt=et.length,rt,nt,ot;for(;tt--;)if(et[tt][0]==="enter"){if(et[tt][1].type==="content"){rt=tt;break}et[tt][1].type==="paragraph"&&(nt=tt)}else et[tt][1].type==="content"&&et.splice(tt,1),!ot&&et[tt][1].type==="definition"&&(ot=tt);const it={type:"setextHeading",start:Object.assign({},et[nt][1].start),end:Object.assign({},et[et.length-1][1].end)};return et[nt][1].type="setextHeadingText",ot?(et.splice(nt,0,["enter",it,o]),et.splice(ot+1,0,["exit",et[rt][1],o]),et[rt][1].end=Object.assign({},et[ot][1].end)):et[rt][1]=it,et.push(["exit",it,o]),et}function tokenizeSetextUnderline(et,o,tt){const rt=this;let nt;return ot;function ot(ct){let lt=rt.events.length,dt;for(;lt--;)if(rt.events[lt][1].type!=="lineEnding"&&rt.events[lt][1].type!=="linePrefix"&&rt.events[lt][1].type!=="content"){dt=rt.events[lt][1].type==="paragraph";break}return!rt.parser.lazy[rt.now().line]&&(rt.interrupt||dt)?(et.enter("setextHeadingLine"),nt=ct,it(ct)):tt(ct)}function it(ct){return et.enter("setextHeadingLineSequence"),st(ct)}function st(ct){return ct===nt?(et.consume(ct),st):(et.exit("setextHeadingLineSequence"),markdownSpace(ct)?factorySpace(et,at,"lineSuffix")(ct):at(ct))}function at(ct){return ct===null||markdownLineEnding(ct)?(et.exit("setextHeadingLine"),o(ct)):tt(ct)}}const flow$1={tokenize:initializeFlow};function initializeFlow(et){const o=this,tt=et.attempt(blankLine,rt,et.attempt(this.parser.constructs.flowInitial,nt,factorySpace(et,et.attempt(this.parser.constructs.flow,nt,et.attempt(content,nt)),"linePrefix")));return tt;function rt(ot){if(ot===null){et.consume(ot);return}return et.enter("lineEndingBlank"),et.consume(ot),et.exit("lineEndingBlank"),o.currentConstruct=void 0,tt}function nt(ot){if(ot===null){et.consume(ot);return}return et.enter("lineEnding"),et.consume(ot),et.exit("lineEnding"),o.currentConstruct=void 0,tt}}const resolver={resolveAll:createResolver()},string$1=initializeFactory("string"),text$2=initializeFactory("text");function initializeFactory(et){return{tokenize:o,resolveAll:createResolver(et==="text"?resolveAllLineSuffixes:void 0)};function o(tt){const rt=this,nt=this.parser.constructs[et],ot=tt.attempt(nt,it,st);return it;function it(lt){return ct(lt)?ot(lt):st(lt)}function st(lt){if(lt===null){tt.consume(lt);return}return tt.enter("data"),tt.consume(lt),at}function at(lt){return ct(lt)?(tt.exit("data"),ot(lt)):(tt.consume(lt),at)}function ct(lt){if(lt===null)return!0;const dt=nt[lt];let ht=-1;if(dt)for(;++ht-1){const st=it[0];typeof st=="string"?it[0]=st.slice(rt):it.shift()}ot>0&&it.push(et[nt].slice(0,ot))}return it}function serializeChunks(et,o){let tt=-1;const rt=[];let nt;for(;++tt0&&typeof rt.column=="number"&&rt.column>0)return{line:rt.line,column:rt.column,offset:typeof rt.offset=="number"&&rt.offset>-1?rt.offset:void 0}}}function position$1(et){const o=pointStart(et),tt=pointEnd(et);if(o&&tt)return{start:o,end:tt}}function stringifyPosition(et){return!et||typeof et!="object"?"":"position"in et||"type"in et?position(et.position):"start"in et||"end"in et?position(et):"line"in et||"column"in et?point$1(et):""}function point$1(et){return index(et&&et.line)+":"+index(et&&et.column)}function position(et){return point$1(et&&et.start)+"-"+point$1(et&&et.end)}function index(et){return et&&typeof et=="number"?et:1}class VFileMessage extends Error{constructor(o,tt,rt){super(),typeof tt=="string"&&(rt=tt,tt=void 0);let nt="",ot={},it=!1;if(tt&&("line"in tt&&"column"in tt?ot={place:tt}:"start"in tt&&"end"in tt?ot={place:tt}:"type"in tt?ot={ancestors:[tt],place:tt.position}:ot={...tt}),typeof o=="string"?nt=o:!ot.cause&&o&&(it=!0,nt=o.message,ot.cause=o),!ot.ruleId&&!ot.source&&typeof rt=="string"){const at=rt.indexOf(":");at===-1?ot.ruleId=rt:(ot.source=rt.slice(0,at),ot.ruleId=rt.slice(at+1))}if(!ot.place&&ot.ancestors&&ot.ancestors){const at=ot.ancestors[ot.ancestors.length-1];at&&(ot.place=at.position)}const st=ot.place&&"start"in ot.place?ot.place.start:ot.place;this.ancestors=ot.ancestors||void 0,this.cause=ot.cause||void 0,this.column=st?st.column:void 0,this.fatal=void 0,this.file,this.message=nt,this.line=st?st.line:void 0,this.name=stringifyPosition(ot.place)||"1:1",this.place=ot.place||void 0,this.reason=this.message,this.ruleId=ot.ruleId||void 0,this.source=ot.source||void 0,this.stack=it&&ot.cause&&typeof ot.cause.stack=="string"?ot.cause.stack:"",this.actual,this.expected,this.note,this.url}}VFileMessage.prototype.file="";VFileMessage.prototype.name="";VFileMessage.prototype.reason="";VFileMessage.prototype.message="";VFileMessage.prototype.stack="";VFileMessage.prototype.column=void 0;VFileMessage.prototype.line=void 0;VFileMessage.prototype.ancestors=void 0;VFileMessage.prototype.cause=void 0;VFileMessage.prototype.fatal=void 0;VFileMessage.prototype.place=void 0;VFileMessage.prototype.ruleId=void 0;VFileMessage.prototype.source=void 0;const own$3={}.hasOwnProperty,emptyMap=new Map,cap=/[A-Z]/g,dashSomething=/-([a-z])/g,tableElements=new Set(["table","tbody","thead","tfoot","tr"]),tableCellElement=new Set(["td","th"]),docs="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function toJsxRuntime(et,o){if(!o||o.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const tt=o.filePath||void 0;let rt;if(o.development){if(typeof o.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");rt=developmentCreate(tt,o.jsxDEV)}else{if(typeof o.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof o.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");rt=productionCreate(tt,o.jsx,o.jsxs)}const nt={Fragment:o.Fragment,ancestors:[],components:o.components||{},create:rt,elementAttributeNameCase:o.elementAttributeNameCase||"react",evaluater:o.createEvaluater?o.createEvaluater():void 0,filePath:tt,ignoreInvalidStyle:o.ignoreInvalidStyle||!1,passKeys:o.passKeys!==!1,passNode:o.passNode||!1,schema:o.space==="svg"?svg:html$1,stylePropertyNameCase:o.stylePropertyNameCase||"dom",tableCellAlignToStyle:o.tableCellAlignToStyle!==!1},ot=one$1(nt,et,void 0);return ot&&typeof ot!="string"?ot:nt.create(et,nt.Fragment,{children:ot||void 0},void 0)}function one$1(et,o,tt){if(o.type==="element")return element$1(et,o,tt);if(o.type==="mdxFlowExpression"||o.type==="mdxTextExpression")return mdxExpression(et,o);if(o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement")return mdxJsxElement(et,o,tt);if(o.type==="mdxjsEsm")return mdxEsm(et,o);if(o.type==="root")return root$1(et,o,tt);if(o.type==="text")return text$3(et,o)}function element$1(et,o,tt){const rt=et.schema;let nt=rt;o.tagName.toLowerCase()==="svg"&&rt.space==="html"&&(nt=svg,et.schema=nt),et.ancestors.push(o);const ot=findComponentFromName(et,o.tagName,!1),it=createElementProps(et,o);let st=createChildren(et,o);return tableElements.has(o.tagName)&&(st=st.filter(function(at){return typeof at=="string"?!whitespace(at):!0})),addNode(et,it,ot,o),addChildren(it,st),et.ancestors.pop(),et.schema=rt,et.create(o,ot,it,tt)}function mdxExpression(et,o){if(o.data&&o.data.estree&&et.evaluater){const rt=o.data.estree.body[0];return rt.type,et.evaluater.evaluateExpression(rt.expression)}crashEstree(et,o.position)}function mdxEsm(et,o){if(o.data&&o.data.estree&&et.evaluater)return et.evaluater.evaluateProgram(o.data.estree);crashEstree(et,o.position)}function mdxJsxElement(et,o,tt){const rt=et.schema;let nt=rt;o.name==="svg"&&rt.space==="html"&&(nt=svg,et.schema=nt),et.ancestors.push(o);const ot=o.name===null?et.Fragment:findComponentFromName(et,o.name,!0),it=createJsxElementProps(et,o),st=createChildren(et,o);return addNode(et,it,ot,o),addChildren(it,st),et.ancestors.pop(),et.schema=rt,et.create(o,ot,it,tt)}function root$1(et,o,tt){const rt={};return addChildren(rt,createChildren(et,o)),et.create(o,et.Fragment,rt,tt)}function text$3(et,o){return o.value}function addNode(et,o,tt,rt){typeof tt!="string"&&tt!==et.Fragment&&et.passNode&&(o.node=rt)}function addChildren(et,o){if(o.length>0){const tt=o.length>1?o:o[0];tt&&(et.children=tt)}}function productionCreate(et,o,tt){return rt;function rt(nt,ot,it,st){const ct=Array.isArray(it.children)?tt:o;return st?ct(ot,it,st):ct(ot,it)}}function developmentCreate(et,o){return tt;function tt(rt,nt,ot,it){const st=Array.isArray(ot.children),at=pointStart(rt);return o(nt,ot,it,st,{columnNumber:at?at.column-1:void 0,fileName:et,lineNumber:at?at.line:void 0},void 0)}}function createElementProps(et,o){const tt={};let rt,nt;for(nt in o.properties)if(nt!=="children"&&own$3.call(o.properties,nt)){const ot=createProperty(et,nt,o.properties[nt]);if(ot){const[it,st]=ot;et.tableCellAlignToStyle&&it==="align"&&typeof st=="string"&&tableCellElement.has(o.tagName)?rt=st:tt[it]=st}}if(rt){const ot=tt.style||(tt.style={});ot[et.stylePropertyNameCase==="css"?"text-align":"textAlign"]=rt}return tt}function createJsxElementProps(et,o){const tt={};for(const rt of o.attributes)if(rt.type==="mdxJsxExpressionAttribute")if(rt.data&&rt.data.estree&&et.evaluater){const ot=rt.data.estree.body[0];ot.type;const it=ot.expression;it.type;const st=it.properties[0];st.type,Object.assign(tt,et.evaluater.evaluateExpression(st.argument))}else crashEstree(et,o.position);else{const nt=rt.name;let ot;if(rt.value&&typeof rt.value=="object")if(rt.value.data&&rt.value.data.estree&&et.evaluater){const st=rt.value.data.estree.body[0];st.type,ot=et.evaluater.evaluateExpression(st.expression)}else crashEstree(et,o.position);else ot=rt.value===null?!0:rt.value;tt[nt]=ot}return tt}function createChildren(et,o){const tt=[];let rt=-1;const nt=et.passKeys?new Map:emptyMap;for(;++rtnt?0:nt+o:o=o>nt?nt:o,tt=tt>0?tt:0,rt.length<1e4)it=Array.from(rt),it.unshift(o,tt),et.splice(...it);else for(tt&&et.splice(o,tt);ot0?(splice(et,et.length,0,o),et):o}const hasOwnProperty={}.hasOwnProperty;function combineExtensions(et){const o={};let tt=-1;for(;++tt13&&tt<32||tt>126&&tt<160||tt>55295&&tt<57344||tt>64975&&tt<65008||(tt&65535)===65535||(tt&65535)===65534||tt>1114111?"�":String.fromCodePoint(tt)}function normalizeIdentifier(et){return et.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const asciiAlpha=regexCheck(/[A-Za-z]/),asciiAlphanumeric=regexCheck(/[\dA-Za-z]/),asciiAtext=regexCheck(/[#-'*+\--9=?A-Z^-~]/);function asciiControl(et){return et!==null&&(et<32||et===127)}const asciiDigit=regexCheck(/\d/),asciiHexDigit=regexCheck(/[\dA-Fa-f]/),asciiPunctuation=regexCheck(/[!-/:-@[-`{-~]/);function markdownLineEnding(et){return et!==null&&et<-2}function markdownLineEndingOrSpace(et){return et!==null&&(et<0||et===32)}function markdownSpace(et){return et===-2||et===-1||et===32}const unicodePunctuation=regexCheck(new RegExp("\\p{P}|\\p{S}","u")),unicodeWhitespace=regexCheck(/\s/);function regexCheck(et){return o;function o(tt){return tt!==null&&tt>-1&&et.test(String.fromCharCode(tt))}}function normalizeUri(et){const o=[];let tt=-1,rt=0,nt=0;for(;++tt55295&&ot<57344){const st=et.charCodeAt(tt+1);ot<56320&&st>56319&&st<57344?(it=String.fromCharCode(ot,st),nt=1):it="�"}else it=String.fromCharCode(ot);it&&(o.push(et.slice(rt,tt),encodeURIComponent(it)),rt=tt+nt+1,it=""),nt&&(tt+=nt,nt=0)}return o.join("")+et.slice(rt)}function factorySpace(et,o,tt,rt){const nt=rt?rt-1:Number.POSITIVE_INFINITY;let ot=0;return it;function it(at){return markdownSpace(at)?(et.enter(tt),st(at)):o(at)}function st(at){return markdownSpace(at)&&ot++it))return;const St=o.events.length;let At=St,kt,It;for(;At--;)if(o.events[At][0]==="exit"&&o.events[At][1].type==="chunkFlow"){if(kt){It=o.events[At][1].end;break}kt=!0}for(gt(rt),Ct=St;Ctxt;){const Et=tt[vt];o.containerState=Et[1],Et[0].exit.call(o,et)}tt.length=xt}function bt(){nt.write([null]),ot=void 0,nt=void 0,o.containerState._closeFlow=void 0}}function tokenizeContainer(et,o,tt){return factorySpace(et,et.attempt(this.parser.constructs.document,o,tt),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function classifyCharacter(et){if(et===null||markdownLineEndingOrSpace(et)||unicodeWhitespace(et))return 1;if(unicodePunctuation(et))return 2}function resolveAll(et,o,tt){const rt=[];let nt=-1;for(;++nt1&&et[tt][1].end.offset-et[tt][1].start.offset>1?2:1;const dt=Object.assign({},et[rt][1].end),ht=Object.assign({},et[tt][1].start);movePoint(dt,-at),movePoint(ht,at),it={type:at>1?"strongSequence":"emphasisSequence",start:dt,end:Object.assign({},et[rt][1].end)},st={type:at>1?"strongSequence":"emphasisSequence",start:Object.assign({},et[tt][1].start),end:ht},ot={type:at>1?"strongText":"emphasisText",start:Object.assign({},et[rt][1].end),end:Object.assign({},et[tt][1].start)},nt={type:at>1?"strong":"emphasis",start:Object.assign({},it.start),end:Object.assign({},st.end)},et[rt][1].end=Object.assign({},it.start),et[tt][1].start=Object.assign({},st.end),ct=[],et[rt][1].end.offset-et[rt][1].start.offset&&(ct=push(ct,[["enter",et[rt][1],o],["exit",et[rt][1],o]])),ct=push(ct,[["enter",nt,o],["enter",it,o],["exit",it,o],["enter",ot,o]]),ct=push(ct,resolveAll(o.parser.constructs.insideSpan.null,et.slice(rt+1,tt),o)),ct=push(ct,[["exit",ot,o],["enter",st,o],["exit",st,o],["exit",nt,o]]),et[tt][1].end.offset-et[tt][1].start.offset?(lt=2,ct=push(ct,[["enter",et[tt][1],o],["exit",et[tt][1],o]])):lt=0,splice(et,rt-1,tt-rt+3,ct),tt=rt+ct.length-lt-2;break}}for(tt=-1;++tt0&&markdownSpace(Ct)?factorySpace(et,bt,"linePrefix",ot+1)(Ct):bt(Ct)}function bt(Ct){return Ct===null||markdownLineEnding(Ct)?et.check(nonLazyContinuation,pt,vt)(Ct):(et.enter("codeFlowValue"),xt(Ct))}function xt(Ct){return Ct===null||markdownLineEnding(Ct)?(et.exit("codeFlowValue"),bt(Ct)):(et.consume(Ct),xt)}function vt(Ct){return et.exit("codeFenced"),o(Ct)}function Et(Ct,St,At){let kt=0;return It;function It(Ut){return Ct.enter("lineEnding"),Ct.consume(Ut),Ct.exit("lineEnding"),Nt}function Nt(Ut){return Ct.enter("codeFencedFence"),markdownSpace(Ut)?factorySpace(Ct,Lt,"linePrefix",rt.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Ut):Lt(Ut)}function Lt(Ut){return Ut===st?(Ct.enter("codeFencedFenceSequence"),Mt(Ut)):At(Ut)}function Mt(Ut){return Ut===st?(kt++,Ct.consume(Ut),Mt):kt>=it?(Ct.exit("codeFencedFenceSequence"),markdownSpace(Ut)?factorySpace(Ct,zt,"whitespace")(Ut):zt(Ut)):At(Ut)}function zt(Ut){return Ut===null||markdownLineEnding(Ut)?(Ct.exit("codeFencedFence"),St(Ut)):At(Ut)}}}function tokenizeNonLazyContinuation(et,o,tt){const rt=this;return nt;function nt(it){return it===null?tt(it):(et.enter("lineEnding"),et.consume(it),et.exit("lineEnding"),ot)}function ot(it){return rt.parser.lazy[rt.now().line]?tt(it):o(it)}}const codeIndented={name:"codeIndented",tokenize:tokenizeCodeIndented},furtherStart={tokenize:tokenizeFurtherStart,partial:!0};function tokenizeCodeIndented(et,o,tt){const rt=this;return nt;function nt(ct){return et.enter("codeIndented"),factorySpace(et,ot,"linePrefix",5)(ct)}function ot(ct){const lt=rt.events[rt.events.length-1];return lt&<[1].type==="linePrefix"&<[2].sliceSerialize(lt[1],!0).length>=4?it(ct):tt(ct)}function it(ct){return ct===null?at(ct):markdownLineEnding(ct)?et.attempt(furtherStart,it,at)(ct):(et.enter("codeFlowValue"),st(ct))}function st(ct){return ct===null||markdownLineEnding(ct)?(et.exit("codeFlowValue"),it(ct)):(et.consume(ct),st)}function at(ct){return et.exit("codeIndented"),o(ct)}}function tokenizeFurtherStart(et,o,tt){const rt=this;return nt;function nt(it){return rt.parser.lazy[rt.now().line]?tt(it):markdownLineEnding(it)?(et.enter("lineEnding"),et.consume(it),et.exit("lineEnding"),nt):factorySpace(et,ot,"linePrefix",5)(it)}function ot(it){const st=rt.events[rt.events.length-1];return st&&st[1].type==="linePrefix"&&st[2].sliceSerialize(st[1],!0).length>=4?o(it):markdownLineEnding(it)?nt(it):tt(it)}}const codeText={name:"codeText",tokenize:tokenizeCodeText,resolve:resolveCodeText,previous};function resolveCodeText(et){let o=et.length-4,tt=3,rt,nt;if((et[tt][1].type==="lineEnding"||et[tt][1].type==="space")&&(et[o][1].type==="lineEnding"||et[o][1].type==="space")){for(rt=tt;++rt=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+o+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return othis.left.length?this.right.slice(this.right.length-rt+this.left.length,this.right.length-o+this.left.length).reverse():this.left.slice(o).concat(this.right.slice(this.right.length-rt+this.left.length).reverse())}splice(o,tt,rt){const nt=tt||0;this.setCursor(Math.trunc(o));const ot=this.right.splice(this.right.length-nt,Number.POSITIVE_INFINITY);return rt&&chunkedPush(this.left,rt),ot.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(o){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(o)}pushMany(o){this.setCursor(Number.POSITIVE_INFINITY),chunkedPush(this.left,o)}unshift(o){this.setCursor(0),this.right.push(o)}unshiftMany(o){this.setCursor(0),chunkedPush(this.right,o.reverse())}setCursor(o){if(!(o===this.left.length||o>this.left.length&&this.right.length===0||o<0&&this.left.length===0))if(o=4?o(it):et.interrupt(rt.parser.constructs.flow,tt,o)(it)}}function factoryDestination(et,o,tt,rt,nt,ot,it,st,at){const ct=at||Number.POSITIVE_INFINITY;let lt=0;return dt;function dt(gt){return gt===60?(et.enter(rt),et.enter(nt),et.enter(ot),et.consume(gt),et.exit(ot),ht):gt===null||gt===32||gt===41||asciiControl(gt)?tt(gt):(et.enter(rt),et.enter(it),et.enter(st),et.enter("chunkString",{contentType:"string"}),pt(gt))}function ht(gt){return gt===62?(et.enter(ot),et.consume(gt),et.exit(ot),et.exit(nt),et.exit(rt),o):(et.enter(st),et.enter("chunkString",{contentType:"string"}),mt(gt))}function mt(gt){return gt===62?(et.exit("chunkString"),et.exit(st),ht(gt)):gt===null||gt===60||markdownLineEnding(gt)?tt(gt):(et.consume(gt),gt===92?ft:mt)}function ft(gt){return gt===60||gt===62||gt===92?(et.consume(gt),mt):mt(gt)}function pt(gt){return!lt&&(gt===null||gt===41||markdownLineEndingOrSpace(gt))?(et.exit("chunkString"),et.exit(st),et.exit(it),et.exit(rt),o(gt)):lt999||mt===null||mt===91||mt===93&&!at||mt===94&&!st&&"_hiddenFootnoteSupport"in it.parser.constructs?tt(mt):mt===93?(et.exit(ot),et.enter(nt),et.consume(mt),et.exit(nt),et.exit(rt),o):markdownLineEnding(mt)?(et.enter("lineEnding"),et.consume(mt),et.exit("lineEnding"),lt):(et.enter("chunkString",{contentType:"string"}),dt(mt))}function dt(mt){return mt===null||mt===91||mt===93||markdownLineEnding(mt)||st++>999?(et.exit("chunkString"),lt(mt)):(et.consume(mt),at||(at=!markdownSpace(mt)),mt===92?ht:dt)}function ht(mt){return mt===91||mt===92||mt===93?(et.consume(mt),st++,dt):dt(mt)}}function factoryTitle(et,o,tt,rt,nt,ot){let it;return st;function st(ht){return ht===34||ht===39||ht===40?(et.enter(rt),et.enter(nt),et.consume(ht),et.exit(nt),it=ht===40?41:ht,at):tt(ht)}function at(ht){return ht===it?(et.enter(nt),et.consume(ht),et.exit(nt),et.exit(rt),o):(et.enter(ot),ct(ht))}function ct(ht){return ht===it?(et.exit(ot),at(it)):ht===null?tt(ht):markdownLineEnding(ht)?(et.enter("lineEnding"),et.consume(ht),et.exit("lineEnding"),factorySpace(et,ct,"linePrefix")):(et.enter("chunkString",{contentType:"string"}),lt(ht))}function lt(ht){return ht===it||ht===null||markdownLineEnding(ht)?(et.exit("chunkString"),ct(ht)):(et.consume(ht),ht===92?dt:lt)}function dt(ht){return ht===it||ht===92?(et.consume(ht),lt):lt(ht)}}function factoryWhitespace(et,o){let tt;return rt;function rt(nt){return markdownLineEnding(nt)?(et.enter("lineEnding"),et.consume(nt),et.exit("lineEnding"),tt=!0,rt):markdownSpace(nt)?factorySpace(et,rt,tt?"linePrefix":"lineSuffix")(nt):o(nt)}}const definition={name:"definition",tokenize:tokenizeDefinition},titleBefore={tokenize:tokenizeTitleBefore,partial:!0};function tokenizeDefinition(et,o,tt){const rt=this;let nt;return ot;function ot(mt){return et.enter("definition"),it(mt)}function it(mt){return factoryLabel.call(rt,et,st,tt,"definitionLabel","definitionLabelMarker","definitionLabelString")(mt)}function st(mt){return nt=normalizeIdentifier(rt.sliceSerialize(rt.events[rt.events.length-1][1]).slice(1,-1)),mt===58?(et.enter("definitionMarker"),et.consume(mt),et.exit("definitionMarker"),at):tt(mt)}function at(mt){return markdownLineEndingOrSpace(mt)?factoryWhitespace(et,ct)(mt):ct(mt)}function ct(mt){return factoryDestination(et,lt,tt,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(mt)}function lt(mt){return et.attempt(titleBefore,dt,dt)(mt)}function dt(mt){return markdownSpace(mt)?factorySpace(et,ht,"whitespace")(mt):ht(mt)}function ht(mt){return mt===null||markdownLineEnding(mt)?(et.exit("definition"),rt.parser.defined.push(nt),o(mt)):tt(mt)}}function tokenizeTitleBefore(et,o,tt){return rt;function rt(st){return markdownLineEndingOrSpace(st)?factoryWhitespace(et,nt)(st):tt(st)}function nt(st){return factoryTitle(et,ot,tt,"definitionTitle","definitionTitleMarker","definitionTitleString")(st)}function ot(st){return markdownSpace(st)?factorySpace(et,it,"whitespace")(st):it(st)}function it(st){return st===null||markdownLineEnding(st)?o(st):tt(st)}}const hardBreakEscape={name:"hardBreakEscape",tokenize:tokenizeHardBreakEscape};function tokenizeHardBreakEscape(et,o,tt){return rt;function rt(ot){return et.enter("hardBreakEscape"),et.consume(ot),nt}function nt(ot){return markdownLineEnding(ot)?(et.exit("hardBreakEscape"),o(ot)):tt(ot)}}const headingAtx={name:"headingAtx",tokenize:tokenizeHeadingAtx,resolve:resolveHeadingAtx};function resolveHeadingAtx(et,o){let tt=et.length-2,rt=3,nt,ot;return et[rt][1].type==="whitespace"&&(rt+=2),tt-2>rt&&et[tt][1].type==="whitespace"&&(tt-=2),et[tt][1].type==="atxHeadingSequence"&&(rt===tt-1||tt-4>rt&&et[tt-2][1].type==="whitespace")&&(tt-=rt+1===tt?2:4),tt>rt&&(nt={type:"atxHeadingText",start:et[rt][1].start,end:et[tt][1].end},ot={type:"chunkText",start:et[rt][1].start,end:et[tt][1].end,contentType:"text"},splice(et,rt,tt-rt+1,[["enter",nt,o],["enter",ot,o],["exit",ot,o],["exit",nt,o]])),et}function tokenizeHeadingAtx(et,o,tt){let rt=0;return nt;function nt(lt){return et.enter("atxHeading"),ot(lt)}function ot(lt){return et.enter("atxHeadingSequence"),it(lt)}function it(lt){return lt===35&&rt++<6?(et.consume(lt),it):lt===null||markdownLineEndingOrSpace(lt)?(et.exit("atxHeadingSequence"),st(lt)):tt(lt)}function st(lt){return lt===35?(et.enter("atxHeadingSequence"),at(lt)):lt===null||markdownLineEnding(lt)?(et.exit("atxHeading"),o(lt)):markdownSpace(lt)?factorySpace(et,st,"whitespace")(lt):(et.enter("atxHeadingText"),ct(lt))}function at(lt){return lt===35?(et.consume(lt),at):(et.exit("atxHeadingSequence"),st(lt))}function ct(lt){return lt===null||lt===35||markdownLineEndingOrSpace(lt)?(et.exit("atxHeadingText"),st(lt)):(et.consume(lt),ct)}}const htmlBlockNames=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],htmlRawNames=["pre","script","style","textarea"],htmlFlow={name:"htmlFlow",tokenize:tokenizeHtmlFlow,resolveTo:resolveToHtmlFlow,concrete:!0},blankLineBefore={tokenize:tokenizeBlankLineBefore,partial:!0},nonLazyContinuationStart={tokenize:tokenizeNonLazyContinuationStart,partial:!0};function resolveToHtmlFlow(et){let o=et.length;for(;o--&&!(et[o][0]==="enter"&&et[o][1].type==="htmlFlow"););return o>1&&et[o-2][1].type==="linePrefix"&&(et[o][1].start=et[o-2][1].start,et[o+1][1].start=et[o-2][1].start,et.splice(o-2,2)),et}function tokenizeHtmlFlow(et,o,tt){const rt=this;let nt,ot,it,st,at;return ct;function ct(jt){return lt(jt)}function lt(jt){return et.enter("htmlFlow"),et.enter("htmlFlowData"),et.consume(jt),dt}function dt(jt){return jt===33?(et.consume(jt),ht):jt===47?(et.consume(jt),ot=!0,pt):jt===63?(et.consume(jt),nt=3,rt.interrupt?o:Pt):asciiAlpha(jt)?(et.consume(jt),it=String.fromCharCode(jt),yt):tt(jt)}function ht(jt){return jt===45?(et.consume(jt),nt=2,mt):jt===91?(et.consume(jt),nt=5,st=0,ft):asciiAlpha(jt)?(et.consume(jt),nt=4,rt.interrupt?o:Pt):tt(jt)}function mt(jt){return jt===45?(et.consume(jt),rt.interrupt?o:Pt):tt(jt)}function ft(jt){const Gt="CDATA[";return jt===Gt.charCodeAt(st++)?(et.consume(jt),st===Gt.length?rt.interrupt?o:Lt:ft):tt(jt)}function pt(jt){return asciiAlpha(jt)?(et.consume(jt),it=String.fromCharCode(jt),yt):tt(jt)}function yt(jt){if(jt===null||jt===47||jt===62||markdownLineEndingOrSpace(jt)){const Gt=jt===47,rr=it.toLowerCase();return!Gt&&!ot&&htmlRawNames.includes(rr)?(nt=1,rt.interrupt?o(jt):Lt(jt)):htmlBlockNames.includes(it.toLowerCase())?(nt=6,Gt?(et.consume(jt),gt):rt.interrupt?o(jt):Lt(jt)):(nt=7,rt.interrupt&&!rt.parser.lazy[rt.now().line]?tt(jt):ot?bt(jt):xt(jt))}return jt===45||asciiAlphanumeric(jt)?(et.consume(jt),it+=String.fromCharCode(jt),yt):tt(jt)}function gt(jt){return jt===62?(et.consume(jt),rt.interrupt?o:Lt):tt(jt)}function bt(jt){return markdownSpace(jt)?(et.consume(jt),bt):It(jt)}function xt(jt){return jt===47?(et.consume(jt),It):jt===58||jt===95||asciiAlpha(jt)?(et.consume(jt),vt):markdownSpace(jt)?(et.consume(jt),xt):It(jt)}function vt(jt){return jt===45||jt===46||jt===58||jt===95||asciiAlphanumeric(jt)?(et.consume(jt),vt):Et(jt)}function Et(jt){return jt===61?(et.consume(jt),Ct):markdownSpace(jt)?(et.consume(jt),Et):xt(jt)}function Ct(jt){return jt===null||jt===60||jt===61||jt===62||jt===96?tt(jt):jt===34||jt===39?(et.consume(jt),at=jt,St):markdownSpace(jt)?(et.consume(jt),Ct):At(jt)}function St(jt){return jt===at?(et.consume(jt),at=null,kt):jt===null||markdownLineEnding(jt)?tt(jt):(et.consume(jt),St)}function At(jt){return jt===null||jt===34||jt===39||jt===47||jt===60||jt===61||jt===62||jt===96||markdownLineEndingOrSpace(jt)?Et(jt):(et.consume(jt),At)}function kt(jt){return jt===47||jt===62||markdownSpace(jt)?xt(jt):tt(jt)}function It(jt){return jt===62?(et.consume(jt),Nt):tt(jt)}function Nt(jt){return jt===null||markdownLineEnding(jt)?Lt(jt):markdownSpace(jt)?(et.consume(jt),Nt):tt(jt)}function Lt(jt){return jt===45&&nt===2?(et.consume(jt),Xt):jt===60&&nt===1?(et.consume(jt),Wt):jt===62&&nt===4?(et.consume(jt),Yt):jt===63&&nt===3?(et.consume(jt),Pt):jt===93&&nt===5?(et.consume(jt),qt):markdownLineEnding(jt)&&(nt===6||nt===7)?(et.exit("htmlFlowData"),et.check(blankLineBefore,Qt,Mt)(jt)):jt===null||markdownLineEnding(jt)?(et.exit("htmlFlowData"),Mt(jt)):(et.consume(jt),Lt)}function Mt(jt){return et.check(nonLazyContinuationStart,zt,Qt)(jt)}function zt(jt){return et.enter("lineEnding"),et.consume(jt),et.exit("lineEnding"),Ut}function Ut(jt){return jt===null||markdownLineEnding(jt)?Mt(jt):(et.enter("htmlFlowData"),Lt(jt))}function Xt(jt){return jt===45?(et.consume(jt),Pt):Lt(jt)}function Wt(jt){return jt===47?(et.consume(jt),it="",Ft):Lt(jt)}function Ft(jt){if(jt===62){const Gt=it.toLowerCase();return htmlRawNames.includes(Gt)?(et.consume(jt),Yt):Lt(jt)}return asciiAlpha(jt)&&it.length<8?(et.consume(jt),it+=String.fromCharCode(jt),Ft):Lt(jt)}function qt(jt){return jt===93?(et.consume(jt),Pt):Lt(jt)}function Pt(jt){return jt===62?(et.consume(jt),Yt):jt===45&&nt===2?(et.consume(jt),Pt):Lt(jt)}function Yt(jt){return jt===null||markdownLineEnding(jt)?(et.exit("htmlFlowData"),Qt(jt)):(et.consume(jt),Yt)}function Qt(jt){return et.exit("htmlFlow"),o(jt)}}function tokenizeNonLazyContinuationStart(et,o,tt){const rt=this;return nt;function nt(it){return markdownLineEnding(it)?(et.enter("lineEnding"),et.consume(it),et.exit("lineEnding"),ot):tt(it)}function ot(it){return rt.parser.lazy[rt.now().line]?tt(it):o(it)}}function tokenizeBlankLineBefore(et,o,tt){return rt;function rt(nt){return et.enter("lineEnding"),et.consume(nt),et.exit("lineEnding"),et.attempt(blankLine,o,tt)}}const htmlText={name:"htmlText",tokenize:tokenizeHtmlText};function tokenizeHtmlText(et,o,tt){const rt=this;let nt,ot,it;return st;function st(Pt){return et.enter("htmlText"),et.enter("htmlTextData"),et.consume(Pt),at}function at(Pt){return Pt===33?(et.consume(Pt),ct):Pt===47?(et.consume(Pt),Et):Pt===63?(et.consume(Pt),xt):asciiAlpha(Pt)?(et.consume(Pt),At):tt(Pt)}function ct(Pt){return Pt===45?(et.consume(Pt),lt):Pt===91?(et.consume(Pt),ot=0,ft):asciiAlpha(Pt)?(et.consume(Pt),bt):tt(Pt)}function lt(Pt){return Pt===45?(et.consume(Pt),mt):tt(Pt)}function dt(Pt){return Pt===null?tt(Pt):Pt===45?(et.consume(Pt),ht):markdownLineEnding(Pt)?(it=dt,Wt(Pt)):(et.consume(Pt),dt)}function ht(Pt){return Pt===45?(et.consume(Pt),mt):dt(Pt)}function mt(Pt){return Pt===62?Xt(Pt):Pt===45?ht(Pt):dt(Pt)}function ft(Pt){const Yt="CDATA[";return Pt===Yt.charCodeAt(ot++)?(et.consume(Pt),ot===Yt.length?pt:ft):tt(Pt)}function pt(Pt){return Pt===null?tt(Pt):Pt===93?(et.consume(Pt),yt):markdownLineEnding(Pt)?(it=pt,Wt(Pt)):(et.consume(Pt),pt)}function yt(Pt){return Pt===93?(et.consume(Pt),gt):pt(Pt)}function gt(Pt){return Pt===62?Xt(Pt):Pt===93?(et.consume(Pt),gt):pt(Pt)}function bt(Pt){return Pt===null||Pt===62?Xt(Pt):markdownLineEnding(Pt)?(it=bt,Wt(Pt)):(et.consume(Pt),bt)}function xt(Pt){return Pt===null?tt(Pt):Pt===63?(et.consume(Pt),vt):markdownLineEnding(Pt)?(it=xt,Wt(Pt)):(et.consume(Pt),xt)}function vt(Pt){return Pt===62?Xt(Pt):xt(Pt)}function Et(Pt){return asciiAlpha(Pt)?(et.consume(Pt),Ct):tt(Pt)}function Ct(Pt){return Pt===45||asciiAlphanumeric(Pt)?(et.consume(Pt),Ct):St(Pt)}function St(Pt){return markdownLineEnding(Pt)?(it=St,Wt(Pt)):markdownSpace(Pt)?(et.consume(Pt),St):Xt(Pt)}function At(Pt){return Pt===45||asciiAlphanumeric(Pt)?(et.consume(Pt),At):Pt===47||Pt===62||markdownLineEndingOrSpace(Pt)?kt(Pt):tt(Pt)}function kt(Pt){return Pt===47?(et.consume(Pt),Xt):Pt===58||Pt===95||asciiAlpha(Pt)?(et.consume(Pt),It):markdownLineEnding(Pt)?(it=kt,Wt(Pt)):markdownSpace(Pt)?(et.consume(Pt),kt):Xt(Pt)}function It(Pt){return Pt===45||Pt===46||Pt===58||Pt===95||asciiAlphanumeric(Pt)?(et.consume(Pt),It):Nt(Pt)}function Nt(Pt){return Pt===61?(et.consume(Pt),Lt):markdownLineEnding(Pt)?(it=Nt,Wt(Pt)):markdownSpace(Pt)?(et.consume(Pt),Nt):kt(Pt)}function Lt(Pt){return Pt===null||Pt===60||Pt===61||Pt===62||Pt===96?tt(Pt):Pt===34||Pt===39?(et.consume(Pt),nt=Pt,Mt):markdownLineEnding(Pt)?(it=Lt,Wt(Pt)):markdownSpace(Pt)?(et.consume(Pt),Lt):(et.consume(Pt),zt)}function Mt(Pt){return Pt===nt?(et.consume(Pt),nt=void 0,Ut):Pt===null?tt(Pt):markdownLineEnding(Pt)?(it=Mt,Wt(Pt)):(et.consume(Pt),Mt)}function zt(Pt){return Pt===null||Pt===34||Pt===39||Pt===60||Pt===61||Pt===96?tt(Pt):Pt===47||Pt===62||markdownLineEndingOrSpace(Pt)?kt(Pt):(et.consume(Pt),zt)}function Ut(Pt){return Pt===47||Pt===62||markdownLineEndingOrSpace(Pt)?kt(Pt):tt(Pt)}function Xt(Pt){return Pt===62?(et.consume(Pt),et.exit("htmlTextData"),et.exit("htmlText"),o):tt(Pt)}function Wt(Pt){return et.exit("htmlTextData"),et.enter("lineEnding"),et.consume(Pt),et.exit("lineEnding"),Ft}function Ft(Pt){return markdownSpace(Pt)?factorySpace(et,qt,"linePrefix",rt.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Pt):qt(Pt)}function qt(Pt){return et.enter("htmlTextData"),it(Pt)}}const labelEnd={name:"labelEnd",tokenize:tokenizeLabelEnd,resolveTo:resolveToLabelEnd,resolveAll:resolveAllLabelEnd},resourceConstruct={tokenize:tokenizeResource},referenceFullConstruct={tokenize:tokenizeReferenceFull},referenceCollapsedConstruct={tokenize:tokenizeReferenceCollapsed};function resolveAllLabelEnd(et){let o=-1;for(;++o=3&&(ct===null||markdownLineEnding(ct))?(et.exit("thematicBreak"),o(ct)):tt(ct)}function at(ct){return ct===nt?(et.consume(ct),rt++,at):(et.exit("thematicBreakSequence"),markdownSpace(ct)?factorySpace(et,st,"whitespace")(ct):st(ct))}}const list$1={name:"list",tokenize:tokenizeListStart,continuation:{tokenize:tokenizeListContinuation},exit:tokenizeListEnd},listItemPrefixWhitespaceConstruct={tokenize:tokenizeListItemPrefixWhitespace,partial:!0},indentConstruct={tokenize:tokenizeIndent,partial:!0};function tokenizeListStart(et,o,tt){const rt=this,nt=rt.events[rt.events.length-1];let ot=nt&&nt[1].type==="linePrefix"?nt[2].sliceSerialize(nt[1],!0).length:0,it=0;return st;function st(mt){const ft=rt.containerState.type||(mt===42||mt===43||mt===45?"listUnordered":"listOrdered");if(ft==="listUnordered"?!rt.containerState.marker||mt===rt.containerState.marker:asciiDigit(mt)){if(rt.containerState.type||(rt.containerState.type=ft,et.enter(ft,{_container:!0})),ft==="listUnordered")return et.enter("listItemPrefix"),mt===42||mt===45?et.check(thematicBreak$1,tt,ct)(mt):ct(mt);if(!rt.interrupt||mt===49)return et.enter("listItemPrefix"),et.enter("listItemValue"),at(mt)}return tt(mt)}function at(mt){return asciiDigit(mt)&&++it<10?(et.consume(mt),at):(!rt.interrupt||it<2)&&(rt.containerState.marker?mt===rt.containerState.marker:mt===41||mt===46)?(et.exit("listItemValue"),ct(mt)):tt(mt)}function ct(mt){return et.enter("listItemMarker"),et.consume(mt),et.exit("listItemMarker"),rt.containerState.marker=rt.containerState.marker||mt,et.check(blankLine,rt.interrupt?tt:lt,et.attempt(listItemPrefixWhitespaceConstruct,ht,dt))}function lt(mt){return rt.containerState.initialBlankLine=!0,ot++,ht(mt)}function dt(mt){return markdownSpace(mt)?(et.enter("listItemPrefixWhitespace"),et.consume(mt),et.exit("listItemPrefixWhitespace"),ht):tt(mt)}function ht(mt){return rt.containerState.size=ot+rt.sliceSerialize(et.exit("listItemPrefix"),!0).length,o(mt)}}function tokenizeListContinuation(et,o,tt){const rt=this;return rt.containerState._closeFlow=void 0,et.check(blankLine,nt,ot);function nt(st){return rt.containerState.furtherBlankLines=rt.containerState.furtherBlankLines||rt.containerState.initialBlankLine,factorySpace(et,o,"listItemIndent",rt.containerState.size+1)(st)}function ot(st){return rt.containerState.furtherBlankLines||!markdownSpace(st)?(rt.containerState.furtherBlankLines=void 0,rt.containerState.initialBlankLine=void 0,it(st)):(rt.containerState.furtherBlankLines=void 0,rt.containerState.initialBlankLine=void 0,et.attempt(indentConstruct,o,it)(st))}function it(st){return rt.containerState._closeFlow=!0,rt.interrupt=void 0,factorySpace(et,et.attempt(list$1,o,tt),"linePrefix",rt.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(st)}}function tokenizeIndent(et,o,tt){const rt=this;return factorySpace(et,nt,"listItemIndent",rt.containerState.size+1);function nt(ot){const it=rt.events[rt.events.length-1];return it&&it[1].type==="listItemIndent"&&it[2].sliceSerialize(it[1],!0).length===rt.containerState.size?o(ot):tt(ot)}}function tokenizeListEnd(et){et.exit(this.containerState.type)}function tokenizeListItemPrefixWhitespace(et,o,tt){const rt=this;return factorySpace(et,nt,"listItemPrefixWhitespace",rt.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function nt(ot){const it=rt.events[rt.events.length-1];return!markdownSpace(ot)&&it&&it[1].type==="listItemPrefixWhitespace"?o(ot):tt(ot)}}const setextUnderline={name:"setextUnderline",tokenize:tokenizeSetextUnderline,resolveTo:resolveToSetextUnderline};function resolveToSetextUnderline(et,o){let tt=et.length,rt,nt,ot;for(;tt--;)if(et[tt][0]==="enter"){if(et[tt][1].type==="content"){rt=tt;break}et[tt][1].type==="paragraph"&&(nt=tt)}else et[tt][1].type==="content"&&et.splice(tt,1),!ot&&et[tt][1].type==="definition"&&(ot=tt);const it={type:"setextHeading",start:Object.assign({},et[nt][1].start),end:Object.assign({},et[et.length-1][1].end)};return et[nt][1].type="setextHeadingText",ot?(et.splice(nt,0,["enter",it,o]),et.splice(ot+1,0,["exit",et[rt][1],o]),et[rt][1].end=Object.assign({},et[ot][1].end)):et[rt][1]=it,et.push(["exit",it,o]),et}function tokenizeSetextUnderline(et,o,tt){const rt=this;let nt;return ot;function ot(ct){let lt=rt.events.length,dt;for(;lt--;)if(rt.events[lt][1].type!=="lineEnding"&&rt.events[lt][1].type!=="linePrefix"&&rt.events[lt][1].type!=="content"){dt=rt.events[lt][1].type==="paragraph";break}return!rt.parser.lazy[rt.now().line]&&(rt.interrupt||dt)?(et.enter("setextHeadingLine"),nt=ct,it(ct)):tt(ct)}function it(ct){return et.enter("setextHeadingLineSequence"),st(ct)}function st(ct){return ct===nt?(et.consume(ct),st):(et.exit("setextHeadingLineSequence"),markdownSpace(ct)?factorySpace(et,at,"lineSuffix")(ct):at(ct))}function at(ct){return ct===null||markdownLineEnding(ct)?(et.exit("setextHeadingLine"),o(ct)):tt(ct)}}const flow$1={tokenize:initializeFlow};function initializeFlow(et){const o=this,tt=et.attempt(blankLine,rt,et.attempt(this.parser.constructs.flowInitial,nt,factorySpace(et,et.attempt(this.parser.constructs.flow,nt,et.attempt(content,nt)),"linePrefix")));return tt;function rt(ot){if(ot===null){et.consume(ot);return}return et.enter("lineEndingBlank"),et.consume(ot),et.exit("lineEndingBlank"),o.currentConstruct=void 0,tt}function nt(ot){if(ot===null){et.consume(ot);return}return et.enter("lineEnding"),et.consume(ot),et.exit("lineEnding"),o.currentConstruct=void 0,tt}}const resolver={resolveAll:createResolver()},string$1=initializeFactory("string"),text$2=initializeFactory("text");function initializeFactory(et){return{tokenize:o,resolveAll:createResolver(et==="text"?resolveAllLineSuffixes:void 0)};function o(tt){const rt=this,nt=this.parser.constructs[et],ot=tt.attempt(nt,it,st);return it;function it(lt){return ct(lt)?ot(lt):st(lt)}function st(lt){if(lt===null){tt.consume(lt);return}return tt.enter("data"),tt.consume(lt),at}function at(lt){return ct(lt)?(tt.exit("data"),ot(lt)):(tt.consume(lt),at)}function ct(lt){if(lt===null)return!0;const dt=nt[lt];let ht=-1;if(dt)for(;++ht-1){const st=it[0];typeof st=="string"?it[0]=st.slice(rt):it.shift()}ot>0&&it.push(et[nt].slice(0,ot))}return it}function serializeChunks(et,o){let tt=-1;const rt=[];let nt;for(;++tt0){const qt=$t.tokenStack[$t.tokenStack.length-1];(qt[1]||defaultOnError).call($t,void 0,qt[0])}for(Tt.position={start:point(ir.length>0?ir[0][1].start:{line:1,column:1,offset:0}),end:point(ir.length>0?ir[ir.length-2][1].end:{line:1,column:1,offset:0})},Dt=-1;++Dt0){const Kt=$t.tokenStack[$t.tokenStack.length-1];(Kt[1]||defaultOnError).call($t,void 0,Kt[0])}for(Tt.position={start:point(ir.length>0?ir[0][1].start:{line:1,column:1,offset:0}),end:point(ir.length>0?ir[ir.length-2][1].end:{line:1,column:1,offset:0})},Dt=-1;++Dt1?"-"+st:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(it)}]};et.patch(o,at);const ct={type:"element",tagName:"sup",properties:{},children:[at]};return et.patch(o,ct),et.applyData(o,ct)}function heading(et,o){const tt={type:"element",tagName:"h"+o.depth,properties:{},children:et.all(o)};return et.patch(o,tt),et.applyData(o,tt)}function html(et,o){if(et.options.allowDangerousHtml){const tt={type:"raw",value:o.value};return et.patch(o,tt),et.applyData(o,tt)}}function revert(et,o){const tt=o.referenceType;let rt="]";if(tt==="collapsed"?rt+="[]":tt==="full"&&(rt+="["+(o.label||o.identifier)+"]"),o.type==="imageReference")return[{type:"text",value:"!["+o.alt+rt}];const nt=et.all(o),ot=nt[0];ot&&ot.type==="text"?ot.value="["+ot.value:nt.unshift({type:"text",value:"["});const it=nt[nt.length-1];return it&&it.type==="text"?it.value+=rt:nt.push({type:"text",value:rt}),nt}function imageReference(et,o){const tt=String(o.identifier).toUpperCase(),rt=et.definitionById.get(tt);if(!rt)return revert(et,o);const nt={src:normalizeUri(rt.url||""),alt:o.alt};rt.title!==null&&rt.title!==void 0&&(nt.title=rt.title);const ot={type:"element",tagName:"img",properties:nt,children:[]};return et.patch(o,ot),et.applyData(o,ot)}function image(et,o){const tt={src:normalizeUri(o.url)};o.alt!==null&&o.alt!==void 0&&(tt.alt=o.alt),o.title!==null&&o.title!==void 0&&(tt.title=o.title);const rt={type:"element",tagName:"img",properties:tt,children:[]};return et.patch(o,rt),et.applyData(o,rt)}function inlineCode(et,o){const tt={type:"text",value:o.value.replace(/\r?\n|\r/g," ")};et.patch(o,tt);const rt={type:"element",tagName:"code",properties:{},children:[tt]};return et.patch(o,rt),et.applyData(o,rt)}function linkReference(et,o){const tt=String(o.identifier).toUpperCase(),rt=et.definitionById.get(tt);if(!rt)return revert(et,o);const nt={href:normalizeUri(rt.url||"")};rt.title!==null&&rt.title!==void 0&&(nt.title=rt.title);const ot={type:"element",tagName:"a",properties:nt,children:et.all(o)};return et.patch(o,ot),et.applyData(o,ot)}function link(et,o){const tt={href:normalizeUri(o.url)};o.title!==null&&o.title!==void 0&&(tt.title=o.title);const rt={type:"element",tagName:"a",properties:tt,children:et.all(o)};return et.patch(o,rt),et.applyData(o,rt)}function listItem(et,o,tt){const rt=et.all(o),nt=tt?listLoose(tt):listItemLoose(o),ot={},it=[];if(typeof o.checked=="boolean"){const lt=rt[0];let dt;lt&<.type==="element"&<.tagName==="p"?dt=lt:(dt={type:"element",tagName:"p",properties:{},children:[]},rt.unshift(dt)),dt.children.length>0&&dt.children.unshift({type:"text",value:" "}),dt.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:o.checked,disabled:!0},children:[]}),ot.className=["task-list-item"]}let st=-1;for(;++st1}function list(et,o){const tt={},rt=et.all(o);let nt=-1;for(typeof o.start=="number"&&o.start!==1&&(tt.start=o.start);++nt0){const it={type:"element",tagName:"tbody",properties:{},children:et.wrap(tt,!0)},st=pointStart(o.children[1]),at=pointEnd(o.children[o.children.length-1]);st&&at&&(it.position={start:st,end:at}),nt.push(it)}const ot={type:"element",tagName:"table",properties:{},children:et.wrap(nt,!0)};return et.patch(o,ot),et.applyData(o,ot)}function tableRow(et,o,tt){const rt=tt?tt.children:void 0,ot=(rt?rt.indexOf(o):1)===0?"th":"td",it=tt&&tt.type==="table"?tt.align:void 0,st=it?it.length:o.children.length;let at=-1;const ct=[];for(;++at0,!0),rt[0]),nt=rt.index+rt[0].length,rt=tt.exec(o);return ot.push(trimLine(o.slice(nt),nt>0,!1)),ot.join("")}function trimLine(et,o,tt){let rt=0,nt=et.length;if(o){let ot=et.codePointAt(rt);for(;ot===tab||ot===space;)rt++,ot=et.codePointAt(rt)}if(tt){let ot=et.codePointAt(nt-1);for(;ot===tab||ot===space;)nt--,ot=et.codePointAt(nt-1)}return nt>rt?et.slice(rt,nt):""}function text(et,o){const tt={type:"text",value:trimLines(String(o.value))};return et.patch(o,tt),et.applyData(o,tt)}function thematicBreak(et,o){const tt={type:"element",tagName:"hr",properties:{},children:[]};return et.patch(o,tt),et.applyData(o,tt)}const handlers={blockquote,break:hardBreak,code,delete:strikethrough,emphasis,footnoteReference,heading,html,imageReference,image,inlineCode,linkReference,link,listItem,list,paragraph,root,strong,table,tableCell,tableRow,text,thematicBreak,toml:ignore,yaml:ignore,definition:ignore,footnoteDefinition:ignore};function ignore(){}const VOID=-1,PRIMITIVE=0,ARRAY=1,OBJECT=2,DATE=3,REGEXP=4,MAP=5,SET=6,ERROR=7,BIGINT=8,env$1=typeof self=="object"?self:globalThis,deserializer=(et,o)=>{const tt=(nt,ot)=>(et.set(ot,nt),nt),rt=nt=>{if(et.has(nt))return et.get(nt);const[ot,it]=o[nt];switch(ot){case PRIMITIVE:case VOID:return tt(it,nt);case ARRAY:{const st=tt([],nt);for(const at of it)st.push(rt(at));return st}case OBJECT:{const st=tt({},nt);for(const[at,ct]of it)st[rt(at)]=rt(ct);return st}case DATE:return tt(new Date(it),nt);case REGEXP:{const{source:st,flags:at}=it;return tt(new RegExp(st,at),nt)}case MAP:{const st=tt(new Map,nt);for(const[at,ct]of it)st.set(rt(at),rt(ct));return st}case SET:{const st=tt(new Set,nt);for(const at of it)st.add(rt(at));return st}case ERROR:{const{name:st,message:at}=it;return tt(new env$1[st](at),nt)}case BIGINT:return tt(BigInt(it),nt);case"BigInt":return tt(Object(BigInt(it)),nt)}return tt(new env$1[ot](it),nt)};return rt},deserialize=et=>deserializer(new Map,et)(0),EMPTY="",{toString}={},{keys}=Object,typeOf=et=>{const o=typeof et;if(o!=="object"||!et)return[PRIMITIVE,o];const tt=toString.call(et).slice(8,-1);switch(tt){case"Array":return[ARRAY,EMPTY];case"Object":return[OBJECT,EMPTY];case"Date":return[DATE,EMPTY];case"RegExp":return[REGEXP,EMPTY];case"Map":return[MAP,EMPTY];case"Set":return[SET,EMPTY]}return tt.includes("Array")?[ARRAY,tt]:tt.includes("Error")?[ERROR,tt]:[OBJECT,tt]},shouldSkip=([et,o])=>et===PRIMITIVE&&(o==="function"||o==="symbol"),serializer=(et,o,tt,rt)=>{const nt=(it,st)=>{const at=rt.push(it)-1;return tt.set(st,at),at},ot=it=>{if(tt.has(it))return tt.get(it);let[st,at]=typeOf(it);switch(st){case PRIMITIVE:{let lt=it;switch(at){case"bigint":st=BIGINT,lt=it.toString();break;case"function":case"symbol":if(et)throw new TypeError("unable to serialize "+at);lt=null;break;case"undefined":return nt([VOID],it)}return nt([st,lt],it)}case ARRAY:{if(at)return nt([at,[...it]],it);const lt=[],dt=nt([st,lt],it);for(const ht of it)lt.push(ot(ht));return dt}case OBJECT:{if(at)switch(at){case"BigInt":return nt([at,it.toString()],it);case"Boolean":case"Number":case"String":return nt([at,it.valueOf()],it)}if(o&&"toJSON"in it)return ot(it.toJSON());const lt=[],dt=nt([st,lt],it);for(const ht of keys(it))(et||!shouldSkip(typeOf(it[ht])))&<.push([ot(ht),ot(it[ht])]);return dt}case DATE:return nt([st,it.toISOString()],it);case REGEXP:{const{source:lt,flags:dt}=it;return nt([st,{source:lt,flags:dt}],it)}case MAP:{const lt=[],dt=nt([st,lt],it);for(const[ht,mt]of it)(et||!(shouldSkip(typeOf(ht))||shouldSkip(typeOf(mt))))&<.push([ot(ht),ot(mt)]);return dt}case SET:{const lt=[],dt=nt([st,lt],it);for(const ht of it)(et||!shouldSkip(typeOf(ht)))&<.push(ot(ht));return dt}}const{message:ct}=it;return nt([st,{name:at,message:ct}],it)};return ot},serialize=(et,{json:o,lossy:tt}={})=>{const rt=[];return serializer(!(o||tt),!!o,new Map,rt)(et),rt},structuredClone$1=typeof structuredClone=="function"?(et,o)=>o&&("json"in o||"lossy"in o)?deserialize(serialize(et,o)):structuredClone(et):(et,o)=>deserialize(serialize(et,o));function defaultFootnoteBackContent(et,o){const tt=[{type:"text",value:"↩"}];return o>1&&tt.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(o)}]}),tt}function defaultFootnoteBackLabel(et,o){return"Back to reference "+(et+1)+(o>1?"-"+o:"")}function footer(et){const o=typeof et.options.clobberPrefix=="string"?et.options.clobberPrefix:"user-content-",tt=et.options.footnoteBackContent||defaultFootnoteBackContent,rt=et.options.footnoteBackLabel||defaultFootnoteBackLabel,nt=et.options.footnoteLabel||"Footnotes",ot=et.options.footnoteLabelTagName||"h2",it=et.options.footnoteLabelProperties||{className:["sr-only"]},st=[];let at=-1;for(;++at0&&ft.push({type:"text",value:" "});let bt=typeof tt=="string"?tt:tt(at,mt);typeof bt=="string"&&(bt={type:"text",value:bt}),ft.push({type:"element",tagName:"a",properties:{href:"#"+o+"fnref-"+ht+(mt>1?"-"+mt:""),dataFootnoteBackref:"",ariaLabel:typeof rt=="string"?rt:rt(at,mt),className:["data-footnote-backref"]},children:Array.isArray(bt)?bt:[bt]})}const gt=lt[lt.length-1];if(gt&>.type==="element"&>.tagName==="p"){const bt=gt.children[gt.children.length-1];bt&&bt.type==="text"?bt.value+=" ":gt.children.push({type:"text",value:" "}),gt.children.push(...ft)}else lt.push(...ft);const yt={type:"element",tagName:"li",properties:{id:o+"fn-"+ht},children:et.wrap(lt,!0)};et.patch(ct,yt),st.push(yt)}if(st.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:ot,properties:{...structuredClone$1(it),id:"footnote-label"},children:[{type:"text",value:nt}]},{type:"text",value:` +`});const ct={type:"element",tagName:"li",properties:ot,children:it};return et.patch(o,ct),et.applyData(o,ct)}function listLoose(et){let o=!1;if(et.type==="list"){o=et.spread||!1;const tt=et.children;let rt=-1;for(;!o&&++rt1}function list(et,o){const tt={},rt=et.all(o);let nt=-1;for(typeof o.start=="number"&&o.start!==1&&(tt.start=o.start);++nt0){const it={type:"element",tagName:"tbody",properties:{},children:et.wrap(tt,!0)},st=pointStart(o.children[1]),at=pointEnd(o.children[o.children.length-1]);st&&at&&(it.position={start:st,end:at}),nt.push(it)}const ot={type:"element",tagName:"table",properties:{},children:et.wrap(nt,!0)};return et.patch(o,ot),et.applyData(o,ot)}function tableRow(et,o,tt){const rt=tt?tt.children:void 0,ot=(rt?rt.indexOf(o):1)===0?"th":"td",it=tt&&tt.type==="table"?tt.align:void 0,st=it?it.length:o.children.length;let at=-1;const ct=[];for(;++at0,!0),rt[0]),nt=rt.index+rt[0].length,rt=tt.exec(o);return ot.push(trimLine(o.slice(nt),nt>0,!1)),ot.join("")}function trimLine(et,o,tt){let rt=0,nt=et.length;if(o){let ot=et.codePointAt(rt);for(;ot===tab||ot===space;)rt++,ot=et.codePointAt(rt)}if(tt){let ot=et.codePointAt(nt-1);for(;ot===tab||ot===space;)nt--,ot=et.codePointAt(nt-1)}return nt>rt?et.slice(rt,nt):""}function text(et,o){const tt={type:"text",value:trimLines(String(o.value))};return et.patch(o,tt),et.applyData(o,tt)}function thematicBreak(et,o){const tt={type:"element",tagName:"hr",properties:{},children:[]};return et.patch(o,tt),et.applyData(o,tt)}const handlers={blockquote,break:hardBreak,code,delete:strikethrough,emphasis,footnoteReference,heading,html,imageReference,image,inlineCode,linkReference,link,listItem,list,paragraph,root,strong,table,tableCell,tableRow,text,thematicBreak,toml:ignore,yaml:ignore,definition:ignore,footnoteDefinition:ignore};function ignore(){}const VOID=-1,PRIMITIVE=0,ARRAY=1,OBJECT=2,DATE=3,REGEXP=4,MAP=5,SET=6,ERROR=7,BIGINT=8,env=typeof self=="object"?self:globalThis,deserializer=(et,o)=>{const tt=(nt,ot)=>(et.set(ot,nt),nt),rt=nt=>{if(et.has(nt))return et.get(nt);const[ot,it]=o[nt];switch(ot){case PRIMITIVE:case VOID:return tt(it,nt);case ARRAY:{const st=tt([],nt);for(const at of it)st.push(rt(at));return st}case OBJECT:{const st=tt({},nt);for(const[at,ct]of it)st[rt(at)]=rt(ct);return st}case DATE:return tt(new Date(it),nt);case REGEXP:{const{source:st,flags:at}=it;return tt(new RegExp(st,at),nt)}case MAP:{const st=tt(new Map,nt);for(const[at,ct]of it)st.set(rt(at),rt(ct));return st}case SET:{const st=tt(new Set,nt);for(const at of it)st.add(rt(at));return st}case ERROR:{const{name:st,message:at}=it;return tt(new env[st](at),nt)}case BIGINT:return tt(BigInt(it),nt);case"BigInt":return tt(Object(BigInt(it)),nt)}return tt(new env[ot](it),nt)};return rt},deserialize=et=>deserializer(new Map,et)(0),EMPTY="",{toString}={},{keys}=Object,typeOf=et=>{const o=typeof et;if(o!=="object"||!et)return[PRIMITIVE,o];const tt=toString.call(et).slice(8,-1);switch(tt){case"Array":return[ARRAY,EMPTY];case"Object":return[OBJECT,EMPTY];case"Date":return[DATE,EMPTY];case"RegExp":return[REGEXP,EMPTY];case"Map":return[MAP,EMPTY];case"Set":return[SET,EMPTY]}return tt.includes("Array")?[ARRAY,tt]:tt.includes("Error")?[ERROR,tt]:[OBJECT,tt]},shouldSkip=([et,o])=>et===PRIMITIVE&&(o==="function"||o==="symbol"),serializer=(et,o,tt,rt)=>{const nt=(it,st)=>{const at=rt.push(it)-1;return tt.set(st,at),at},ot=it=>{if(tt.has(it))return tt.get(it);let[st,at]=typeOf(it);switch(st){case PRIMITIVE:{let lt=it;switch(at){case"bigint":st=BIGINT,lt=it.toString();break;case"function":case"symbol":if(et)throw new TypeError("unable to serialize "+at);lt=null;break;case"undefined":return nt([VOID],it)}return nt([st,lt],it)}case ARRAY:{if(at)return nt([at,[...it]],it);const lt=[],dt=nt([st,lt],it);for(const ht of it)lt.push(ot(ht));return dt}case OBJECT:{if(at)switch(at){case"BigInt":return nt([at,it.toString()],it);case"Boolean":case"Number":case"String":return nt([at,it.valueOf()],it)}if(o&&"toJSON"in it)return ot(it.toJSON());const lt=[],dt=nt([st,lt],it);for(const ht of keys(it))(et||!shouldSkip(typeOf(it[ht])))&<.push([ot(ht),ot(it[ht])]);return dt}case DATE:return nt([st,it.toISOString()],it);case REGEXP:{const{source:lt,flags:dt}=it;return nt([st,{source:lt,flags:dt}],it)}case MAP:{const lt=[],dt=nt([st,lt],it);for(const[ht,mt]of it)(et||!(shouldSkip(typeOf(ht))||shouldSkip(typeOf(mt))))&<.push([ot(ht),ot(mt)]);return dt}case SET:{const lt=[],dt=nt([st,lt],it);for(const ht of it)(et||!shouldSkip(typeOf(ht)))&<.push(ot(ht));return dt}}const{message:ct}=it;return nt([st,{name:at,message:ct}],it)};return ot},serialize=(et,{json:o,lossy:tt}={})=>{const rt=[];return serializer(!(o||tt),!!o,new Map,rt)(et),rt},structuredClone$1=typeof structuredClone=="function"?(et,o)=>o&&("json"in o||"lossy"in o)?deserialize(serialize(et,o)):structuredClone(et):(et,o)=>deserialize(serialize(et,o));function defaultFootnoteBackContent(et,o){const tt=[{type:"text",value:"↩"}];return o>1&&tt.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(o)}]}),tt}function defaultFootnoteBackLabel(et,o){return"Back to reference "+(et+1)+(o>1?"-"+o:"")}function footer(et){const o=typeof et.options.clobberPrefix=="string"?et.options.clobberPrefix:"user-content-",tt=et.options.footnoteBackContent||defaultFootnoteBackContent,rt=et.options.footnoteBackLabel||defaultFootnoteBackLabel,nt=et.options.footnoteLabel||"Footnotes",ot=et.options.footnoteLabelTagName||"h2",it=et.options.footnoteLabelProperties||{className:["sr-only"]},st=[];let at=-1;for(;++at0&&ft.push({type:"text",value:" "});let bt=typeof tt=="string"?tt:tt(at,mt);typeof bt=="string"&&(bt={type:"text",value:bt}),ft.push({type:"element",tagName:"a",properties:{href:"#"+o+"fnref-"+ht+(mt>1?"-"+mt:""),dataFootnoteBackref:"",ariaLabel:typeof rt=="string"?rt:rt(at,mt),className:["data-footnote-backref"]},children:Array.isArray(bt)?bt:[bt]})}const yt=lt[lt.length-1];if(yt&&yt.type==="element"&&yt.tagName==="p"){const bt=yt.children[yt.children.length-1];bt&&bt.type==="text"?bt.value+=" ":yt.children.push({type:"text",value:" "}),yt.children.push(...ft)}else lt.push(...ft);const gt={type:"element",tagName:"li",properties:{id:o+"fn-"+ht},children:et.wrap(lt,!0)};et.patch(ct,gt),st.push(gt)}if(st.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:ot,properties:{...structuredClone$1(it),id:"footnote-label"},children:[{type:"text",value:nt}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:et.wrap(st,!0)},{type:"text",value:` -`}]}}const convert=function(et){if(et==null)return ok;if(typeof et=="function")return castFactory(et);if(typeof et=="object")return Array.isArray(et)?anyFactory(et):propsFactory(et);if(typeof et=="string")return typeFactory(et);throw new Error("Expected function, string, or object as test")};function anyFactory(et){const o=[];let tt=-1;for(;++tt":""))+")"})}return ht;function ht(){let mt=empty,ft,pt,gt;if((!o||ot(at,ct,lt[lt.length-1]||void 0))&&(mt=toResult(tt(at,lt)),mt[0]===EXIT))return mt;if("children"in at&&at.children){const yt=at;if(yt.children&&mt[0]!==SKIP)for(pt=(rt?yt.children.length:-1)+it,gt=lt.concat(yt);pt>-1&&pt":""))+")"})}return ht;function ht(){let mt=empty,ft,pt,yt;if((!o||ot(at,ct,lt[lt.length-1]||void 0))&&(mt=toResult(tt(at,lt)),mt[0]===EXIT))return mt;if("children"in at&&at.children){const gt=at;if(gt.children&&mt[0]!==SKIP)for(pt=(rt?gt.children.length:-1)+it,yt=lt.concat(gt);pt>-1&&pt0&&tt.push({type:"text",value:` `}),tt}function trimMarkdownSpaceStart(et){let o=0,tt=et.charCodeAt(o);for(;tt===9||tt===32;)o++,tt=et.charCodeAt(o);return et.slice(o)}function toHast(et,o){const tt=createState(et,o),rt=tt.one(et,void 0),nt=footer(tt),ot=Array.isArray(rt)?{type:"root",children:rt}:rt||{type:"root",children:[]};return nt&&ot.children.push({type:"text",value:` -`},nt),ot}function remarkRehype(et,o){return et&&"run"in et?async function(tt,rt){const nt=toHast(tt,{file:rt,...o});await et.run(nt,rt)}:function(tt,rt){return toHast(tt,{file:rt,...et||o})}}function bail(et){if(et)throw et}var hasOwn=Object.prototype.hasOwnProperty,toStr=Object.prototype.toString,defineProperty=Object.defineProperty,gOPD=Object.getOwnPropertyDescriptor,isArray=function et(o){return typeof Array.isArray=="function"?Array.isArray(o):toStr.call(o)==="[object Array]"},isPlainObject$1=function et(o){if(!o||toStr.call(o)!=="[object Object]")return!1;var tt=hasOwn.call(o,"constructor"),rt=o.constructor&&o.constructor.prototype&&hasOwn.call(o.constructor.prototype,"isPrototypeOf");if(o.constructor&&!tt&&!rt)return!1;var nt;for(nt in o);return typeof nt>"u"||hasOwn.call(o,nt)},setProperty=function et(o,tt){defineProperty&&tt.name==="__proto__"?defineProperty(o,tt.name,{enumerable:!0,configurable:!0,value:tt.newValue,writable:!0}):o[tt.name]=tt.newValue},getProperty=function et(o,tt){if(tt==="__proto__")if(hasOwn.call(o,tt)){if(gOPD)return gOPD(o,tt).value}else return;return o[tt]},extend=function et(){var o,tt,rt,nt,ot,it,st=arguments[0],at=1,ct=arguments.length,lt=!1;for(typeof st=="boolean"&&(lt=st,st=arguments[1]||{},at=2),(st==null||typeof st!="object"&&typeof st!="function")&&(st={});atit.length;let at;st&&it.push(nt);try{at=et.apply(this,it)}catch(ct){const lt=ct;if(st&&tt)throw lt;return nt(lt)}st||(at&&at.then&&typeof at.then=="function"?at.then(ot,nt):at instanceof Error?nt(at):ot(at))}function nt(it,...st){tt||(tt=!0,o(it,...st))}function ot(it){nt(null,it)}}const minpath={basename,dirname,extname,join,sep:"/"};function basename(et,o){if(o!==void 0&&typeof o!="string")throw new TypeError('"ext" argument must be a string');assertPath$1(et);let tt=0,rt=-1,nt=et.length,ot;if(o===void 0||o.length===0||o.length>et.length){for(;nt--;)if(et.codePointAt(nt)===47){if(ot){tt=nt+1;break}}else rt<0&&(ot=!0,rt=nt+1);return rt<0?"":et.slice(tt,rt)}if(o===et)return"";let it=-1,st=o.length-1;for(;nt--;)if(et.codePointAt(nt)===47){if(ot){tt=nt+1;break}}else it<0&&(ot=!0,it=nt+1),st>-1&&(et.codePointAt(nt)===o.codePointAt(st--)?st<0&&(rt=nt):(st=-1,rt=it));return tt===rt?rt=it:rt<0&&(rt=et.length),et.slice(tt,rt)}function dirname(et){if(assertPath$1(et),et.length===0)return".";let o=-1,tt=et.length,rt;for(;--tt;)if(et.codePointAt(tt)===47){if(rt){o=tt;break}}else rt||(rt=!0);return o<0?et.codePointAt(0)===47?"/":".":o===1&&et.codePointAt(0)===47?"//":et.slice(0,o)}function extname(et){assertPath$1(et);let o=et.length,tt=-1,rt=0,nt=-1,ot=0,it;for(;o--;){const st=et.codePointAt(o);if(st===47){if(it){rt=o+1;break}continue}tt<0&&(it=!0,tt=o+1),st===46?nt<0?nt=o:ot!==1&&(ot=1):nt>-1&&(ot=-1)}return nt<0||tt<0||ot===0||ot===1&&nt===tt-1&&nt===rt+1?"":et.slice(nt,tt)}function join(...et){let o=-1,tt;for(;++o0&&et.codePointAt(et.length-1)===47&&(tt+="/"),o?"/"+tt:tt}function normalizeString(et,o){let tt="",rt=0,nt=-1,ot=0,it=-1,st,at;for(;++it<=et.length;){if(it2){if(at=tt.lastIndexOf("/"),at!==tt.length-1){at<0?(tt="",rt=0):(tt=tt.slice(0,at),rt=tt.length-1-tt.lastIndexOf("/")),nt=it,ot=0;continue}}else if(tt.length>0){tt="",rt=0,nt=it,ot=0;continue}}o&&(tt=tt.length>0?tt+"/..":"..",rt=2)}else tt.length>0?tt+="/"+et.slice(nt+1,it):tt=et.slice(nt+1,it),rt=it-nt-1;nt=it,ot=0}else st===46&&ot>-1?ot++:ot=-1}return tt}function assertPath$1(et){if(typeof et!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(et))}const minproc={cwd};function cwd(){return"/"}function isUrl(et){return!!(et!==null&&typeof et=="object"&&"href"in et&&et.href&&"protocol"in et&&et.protocol&&et.auth===void 0)}function urlToPath(et){if(typeof et=="string")et=new URL(et);else if(!isUrl(et)){const o=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+et+"`");throw o.code="ERR_INVALID_ARG_TYPE",o}if(et.protocol!=="file:"){const o=new TypeError("The URL must be of scheme file");throw o.code="ERR_INVALID_URL_SCHEME",o}return getPathFromURLPosix(et)}function getPathFromURLPosix(et){if(et.hostname!==""){const rt=new TypeError('File URL host must be "localhost" or empty on darwin');throw rt.code="ERR_INVALID_FILE_URL_HOST",rt}const o=et.pathname;let tt=-1;for(;++tt0){let[mt,...ft]=lt;const pt=rt[ht][1];isPlainObject(pt)&&isPlainObject(mt)&&(mt=extend$1(!0,pt,mt)),rt[ht]=[ct,mt,...ft]}}}}const unified=new Processor().freeze();function assertParser(et,o){if(typeof o!="function")throw new TypeError("Cannot `"+et+"` without `parser`")}function assertCompiler(et,o){if(typeof o!="function")throw new TypeError("Cannot `"+et+"` without `compiler`")}function assertUnfrozen(et,o){if(o)throw new Error("Cannot call `"+et+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function assertNode(et){if(!isPlainObject(et)||typeof et.type!="string")throw new TypeError("Expected node, got `"+et+"`")}function assertDone(et,o,tt){if(!tt)throw new Error("`"+et+"` finished async. Use `"+o+"` instead")}function vfile(et){return looksLikeAVFile(et)?et:new VFile(et)}function looksLikeAVFile(et){return!!(et&&typeof et=="object"&&"message"in et&&"messages"in et)}function looksLikeAValue(et){return typeof et=="string"||isUint8Array(et)}function isUint8Array(et){return!!(et&&typeof et=="object"&&"byteLength"in et&&"byteOffset"in et)}const changelog="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",emptyPlugins=[],emptyRemarkRehypeOptions={allowDangerousHtml:!0},safeProtocol=/^(https?|ircs?|mailto|xmpp)$/i,deprecations=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Markdown(et){const o=et.allowedElements,tt=et.allowElement,rt=et.children||"",nt=et.className,ot=et.components,it=et.disallowedElements,st=et.rehypePlugins||emptyPlugins,at=et.remarkPlugins||emptyPlugins,ct=et.remarkRehypeOptions?{...et.remarkRehypeOptions,...emptyRemarkRehypeOptions}:emptyRemarkRehypeOptions,lt=et.skipHtml,dt=et.unwrapDisallowed,ht=et.urlTransform||defaultUrlTransform,mt=unified().use(remarkParse).use(at).use(remarkRehype,ct).use(st),ft=new VFile;typeof rt=="string"&&(ft.value=rt);for(const bt of deprecations)Object.hasOwn(et,bt.from)&&(""+bt.from+(bt.to?"use `"+bt.to+"` instead":"remove it")+changelog+bt.id,void 0);const pt=mt.parse(ft);let gt=mt.runSync(pt,ft);return nt&&(gt={type:"element",tagName:"div",properties:{className:nt},children:gt.type==="root"?gt.children:[gt]}),visit(gt,yt),toJsxRuntime(gt,{Fragment:jsxRuntimeExports.Fragment,components:ot,ignoreInvalidStyle:!0,jsx:jsxRuntimeExports.jsx,jsxs:jsxRuntimeExports.jsxs,passKeys:!0,passNode:!0});function yt(bt,xt,vt){if(bt.type==="raw"&&vt&&typeof xt=="number")return lt?vt.children.splice(xt,1):vt.children[xt]={type:"text",value:bt.value},xt;if(bt.type==="element"){let Et;for(Et in urlAttributes)if(Object.hasOwn(urlAttributes,Et)&&Object.hasOwn(bt.properties,Et)){const Ct=bt.properties[Et],St=urlAttributes[Et];(St===null||St.includes(bt.tagName))&&(bt.properties[Et]=ht(String(Ct||""),Et,bt))}}if(bt.type==="element"){let Et=o?!o.includes(bt.tagName):it?it.includes(bt.tagName):!1;if(!Et&&tt&&typeof xt=="number"&&(Et=!tt(bt,xt,vt)),Et&&vt&&typeof xt=="number")return dt&&bt.children?vt.children.splice(xt,1,...bt.children):vt.children.splice(xt,1),xt}}}function defaultUrlTransform(et){const o=et.indexOf(":"),tt=et.indexOf("?"),rt=et.indexOf("#"),nt=et.indexOf("/");return o<0||nt>-1&&o>nt||tt>-1&&o>tt||rt>-1&&o>rt||safeProtocol.test(et.slice(0,o))?et:""}const PrivacyPolicyOptIn=({onOptIn:et})=>{const[o,tt]=reactExports.useState(!1);return jsxRuntimeExports.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:[jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-md",children:[jsxRuntimeExports.jsx(CardHeader,{className:"space-y-2",children:jsxRuntimeExports.jsx(CardTitle,{className:"text-xl sm:text-2xl",children:"Privacy Policy & Data Collection"})}),jsxRuntimeExports.jsx(CardContent,{children:jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[jsxRuntimeExports.jsx("p",{className:"text-sm sm:text-base text-muted-foreground",children:"We collect data to improve our services. This data is anonymous and helps us understand how our application is used. You can opt-in or opt-out of this data collection."}),jsxRuntimeExports.jsx(Button,{variant:"link",onClick:()=>tt(!0),className:"px-0 text-sm sm:text-base",children:"View Full Privacy Policy"})]})}),jsxRuntimeExports.jsxs(CardFooter,{className:"flex flex-col sm:flex-row gap-3 sm:gap-4",children:[jsxRuntimeExports.jsx(Button,{variant:"outline",onClick:()=>et(!1),className:"w-full sm:w-auto",children:"Opt Out"}),jsxRuntimeExports.jsx(Button,{onClick:()=>et(!0),className:"w-full sm:w-auto",children:"Opt In"})]})]}),jsxRuntimeExports.jsx(Dialog,{open:o,onOpenChange:tt,children:jsxRuntimeExports.jsxs(DialogContent,{className:"w-[95vw] max-w-4xl max-h-[90vh] p-4 sm:p-6",children:[jsxRuntimeExports.jsx(DialogHeader,{children:jsxRuntimeExports.jsx(DialogTitle,{className:"text-xl sm:text-2xl",children:"Privacy Policy"})}),jsxRuntimeExports.jsx(ScrollArea,{className:"mt-4 h-[50vh] sm:h-[60vh]",children:jsxRuntimeExports.jsx(DialogDescription,{className:"space-y-4",children:jsxRuntimeExports.jsx(Markdown,{className:"prose dark:prose-invert max-w-none text-sm sm:text-base",children:privacyPolicy})})})]})})]})},PrivacyPolicyPage=()=>{const[et,o]=reactExports.useState(!1);reactExports.useEffect(()=>{const rt=localStorage.getItem("privacyPolicyOptIn");rt!==null&&o(rt==="true")},[]);const tt=()=>{const rt=!et;o(rt),localStorage.setItem("privacyPolicyOptIn",rt.toString())};return jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-4xl mx-auto p-4 sm:p-6",children:[jsxRuntimeExports.jsx(CardHeader,{className:"space-y-2",children:jsxRuntimeExports.jsx(CardTitle,{className:"text-2xl sm:text-3xl",children:"Privacy Policy Settings"})}),jsxRuntimeExports.jsx(CardContent,{children:jsxRuntimeExports.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[jsxRuntimeExports.jsx("p",{className:"text-sm sm:text-base text-muted-foreground",children:"We collect data to improve our services. This data is anonymous and helps us understand how our application is used."}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[jsxRuntimeExports.jsxs("p",{className:"font-semibold",children:["Current status: ",et?"Opted In":"Opted Out"]}),jsxRuntimeExports.jsx(Button,{onClick:tt,className:"w-full sm:w-auto",children:et?"Opt Out":"Opt In"})]})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"text-lg sm:text-xl font-semibold mb-4",children:"Privacy Policy"}),jsxRuntimeExports.jsx(ScrollArea,{className:"h-[50vh] sm:h-[60vh] border rounded-md p-2 sm:p-4",children:jsxRuntimeExports.jsx(Markdown,{className:"prose dark:prose-invert max-w-none text-sm sm:text-base",children:privacyPolicy})})]})]})})]})},SignSharedChain=({chainsData:et,onChainUpdate:o,isLoading:tt})=>{const{chainUUID:rt,blockUUID:nt}=useParams(),[ot,it]=reactExports.useState(null),st=useNavigate();return reactExports.useEffect(()=>{const at=et.find(ct=>ct.chainUUID===rt&&ct.blockUUID===nt);at&&it(at)},[et,rt,nt]),tt&&!ot?jsxRuntimeExports.jsx(Card,{className:"w-full max-w-md mx-auto",children:jsxRuntimeExports.jsxs(CardContent,{className:"flex flex-col items-center justify-center py-8 space-y-4",children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Looking for chain..."})]})}):ot?jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-2xl mx-auto",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsx(CardTitle,{children:"Sign Shared Chain"})}),jsxRuntimeExports.jsxs(CardContent,{children:[jsxRuntimeExports.jsx("h2",{className:"text-xl font-semibold mb-2",children:ot.title}),jsxRuntimeExports.jsx("p",{className:"mb-4",children:ot.description}),jsxRuntimeExports.jsx(SignChain,{block:ot,chainsData:et,onSuccess:o})]})]}):jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-md mx-auto",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsx(CardTitle,{children:"Chain Not Found"})}),jsxRuntimeExports.jsxs(CardContent,{children:[jsxRuntimeExports.jsx("p",{className:"mb-4",children:"The requested chain or block could not be found."}),jsxRuntimeExports.jsx(Button,{onClick:()=>st("/view"),children:"View All Chains"})]})]})};function App(){const[et,o]=reactExports.useState(!1),[tt,rt]=reactExports.useState([]),{isLoading:nt,error:ot,node:it}=useWaku(),[st,at]=reactExports.useState({filter:"in-progress",store:"in-progress"}),[ct,lt]=reactExports.useState(null),[dt,ht]=reactExports.useState(!0);reactExports.useEffect(()=>{const gt=localStorage.getItem("telemetryOptIn");gt!==null&<(gt==="true")},[]),reactExports.useEffect(()=>{nt||!it||it.libp2p.getConnections().length===0||tt.length>0||et||(o(!0),ft())},[it,nt,st]);const mt=gt=>{lt(gt),localStorage.setItem("telemetryOptIn",gt.toString())};if(nt)return jsxRuntimeExports.jsx("div",{className:"min-h-screen bg-background text-foreground",children:jsxRuntimeExports.jsxs("div",{className:"container mx-auto px-4 py-16 flex flex-col items-center justify-center space-y-4",children:[jsxRuntimeExports.jsx("h1",{className:"text-2xl md:text-4xl font-bold",children:"BuddyBook"}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin"}),jsxRuntimeExports.jsx("p",{className:"text-muted-foreground",children:"Connecting to Waku's decentralized network..."})]})]})});const ft=async()=>{console.log("Starting message listening");try{at(yt=>({...yt,store:"in-progress"})),ht(!0);const gt=getMessagesFromStore(it);for await(const yt of gt)rt(bt=>bt.some(vt=>vt.blockUUID===yt.blockUUID)?bt:[...bt,yt]);at(yt=>({...yt,store:"success"}))}catch(gt){console.error("Error fetching messages from store:",gt),at(yt=>({...yt,store:"error"}))}finally{ht(!1)}try{at(gt=>({...gt,filter:"in-progress"})),await subscribeToFilter(it,gt=>{pt(gt)}),at(gt=>({...gt,filter:"success"}))}catch(gt){console.error("Error subscribing to filter:",gt),at(yt=>({...yt,filter:"error"}))}};if(ot)return jsxRuntimeExports.jsxs("div",{className:"min-h-screen bg-background text-foreground flex flex-col justify-center items-center",children:[jsxRuntimeExports.jsx("p",{className:"text-red-500",children:"Error connecting to Waku network"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:ot.toString()})]});const pt=gt=>{rt(yt=>yt.some(xt=>xt.blockUUID===gt.blockUUID)?yt:[...yt,gt])};return ct===null?jsxRuntimeExports.jsx(PrivacyPolicyOptIn,{onOptIn:mt}):jsxRuntimeExports.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[jsxRuntimeExports.jsx(Header,{wakuStatus:st}),jsxRuntimeExports.jsx("main",{className:"container mx-auto px-4 py-4 md:py-8 max-w-7xl",children:jsxRuntimeExports.jsxs(Routes,{children:[jsxRuntimeExports.jsx(Route,{path:"/create",element:jsxRuntimeExports.jsx(ChainCreationForm,{})}),jsxRuntimeExports.jsx(Route,{path:"/view",element:jsxRuntimeExports.jsx(ChainList,{chainsData:tt,onChainUpdate:pt,isLoading:dt})}),jsxRuntimeExports.jsx(Route,{path:"/",element:jsxRuntimeExports.jsx(Home,{})}),jsxRuntimeExports.jsx(Route,{path:"/sign/:chainUUID/:blockUUID",element:jsxRuntimeExports.jsx(SignSharedChain,{chainsData:tt,onChainUpdate:pt,isLoading:dt})}),jsxRuntimeExports.jsx(Route,{path:"/telemetry",element:jsxRuntimeExports.jsx(PrivacyPolicyPage,{})}),jsxRuntimeExports.jsx(Route,{path:"*",element:jsxRuntimeExports.jsx(Navigate,{to:"/",replace:!0})})]})})]})}const Home=()=>jsxRuntimeExports.jsxs("div",{className:"space-y-4 md:space-y-6 p-4 md:p-6",children:[jsxRuntimeExports.jsx("h1",{className:"text-2xl md:text-4xl font-bold",children:"BuddyBook"}),jsxRuntimeExports.jsxs("div",{className:"w-full max-w-sm mx-auto p-4 md:p-6 bg-card rounded-lg shadow-md",children:[jsxRuntimeExports.jsx(Link,{to:"/create",children:jsxRuntimeExports.jsx(Button,{className:"w-full mb-4",children:"Create New Chain"})}),jsxRuntimeExports.jsx("p",{className:"text-sm md:text-base text-muted-foreground",children:"Click the button above to start creating a new chain."})]}),jsxRuntimeExports.jsx("p",{className:"text-xs md:text-sm text-muted-foreground text-center",children:"Welcome to BuddyBook - Create and share your chains!"})]});var util;(function(et){et.assertEqual=nt=>nt;function o(nt){}et.assertIs=o;function tt(nt){throw new Error}et.assertNever=tt,et.arrayToEnum=nt=>{const ot={};for(const it of nt)ot[it]=it;return ot},et.getValidEnumValues=nt=>{const ot=et.objectKeys(nt).filter(st=>typeof nt[nt[st]]!="number"),it={};for(const st of ot)it[st]=nt[st];return et.objectValues(it)},et.objectValues=nt=>et.objectKeys(nt).map(function(ot){return nt[ot]}),et.objectKeys=typeof Object.keys=="function"?nt=>Object.keys(nt):nt=>{const ot=[];for(const it in nt)Object.prototype.hasOwnProperty.call(nt,it)&&ot.push(it);return ot},et.find=(nt,ot)=>{for(const it of nt)if(ot(it))return it},et.isInteger=typeof Number.isInteger=="function"?nt=>Number.isInteger(nt):nt=>typeof nt=="number"&&isFinite(nt)&&Math.floor(nt)===nt;function rt(nt,ot=" | "){return nt.map(it=>typeof it=="string"?`'${it}'`:it).join(ot)}et.joinValues=rt,et.jsonStringifyReplacer=(nt,ot)=>typeof ot=="bigint"?ot.toString():ot})(util||(util={}));var objectUtil;(function(et){et.mergeShapes=(o,tt)=>({...o,...tt})})(objectUtil||(objectUtil={}));const ZodParsedType=util.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),getParsedType=et=>{switch(typeof et){case"undefined":return ZodParsedType.undefined;case"string":return ZodParsedType.string;case"number":return isNaN(et)?ZodParsedType.nan:ZodParsedType.number;case"boolean":return ZodParsedType.boolean;case"function":return ZodParsedType.function;case"bigint":return ZodParsedType.bigint;case"symbol":return ZodParsedType.symbol;case"object":return Array.isArray(et)?ZodParsedType.array:et===null?ZodParsedType.null:et.then&&typeof et.then=="function"&&et.catch&&typeof et.catch=="function"?ZodParsedType.promise:typeof Map<"u"&&et instanceof Map?ZodParsedType.map:typeof Set<"u"&&et instanceof Set?ZodParsedType.set:typeof Date<"u"&&et instanceof Date?ZodParsedType.date:ZodParsedType.object;default:return ZodParsedType.unknown}},ZodIssueCode=util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),quotelessJson=et=>JSON.stringify(et,null,2).replace(/"([^"]+)":/g,"$1:");class ZodError extends Error{constructor(o){super(),this.issues=[],this.addIssue=rt=>{this.issues=[...this.issues,rt]},this.addIssues=(rt=[])=>{this.issues=[...this.issues,...rt]};const tt=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,tt):this.__proto__=tt,this.name="ZodError",this.issues=o}get errors(){return this.issues}format(o){const tt=o||function(ot){return ot.message},rt={_errors:[]},nt=ot=>{for(const it of ot.issues)if(it.code==="invalid_union")it.unionErrors.map(nt);else if(it.code==="invalid_return_type")nt(it.returnTypeError);else if(it.code==="invalid_arguments")nt(it.argumentsError);else if(it.path.length===0)rt._errors.push(tt(it));else{let st=rt,at=0;for(;attt.message){const tt={},rt=[];for(const nt of this.issues)nt.path.length>0?(tt[nt.path[0]]=tt[nt.path[0]]||[],tt[nt.path[0]].push(o(nt))):rt.push(o(nt));return{formErrors:rt,fieldErrors:tt}}get formErrors(){return this.flatten()}}ZodError.create=et=>new ZodError(et);const errorMap=(et,o)=>{let tt;switch(et.code){case ZodIssueCode.invalid_type:et.received===ZodParsedType.undefined?tt="Required":tt=`Expected ${et.expected}, received ${et.received}`;break;case ZodIssueCode.invalid_literal:tt=`Invalid literal value, expected ${JSON.stringify(et.expected,util.jsonStringifyReplacer)}`;break;case ZodIssueCode.unrecognized_keys:tt=`Unrecognized key(s) in object: ${util.joinValues(et.keys,", ")}`;break;case ZodIssueCode.invalid_union:tt="Invalid input";break;case ZodIssueCode.invalid_union_discriminator:tt=`Invalid discriminator value. Expected ${util.joinValues(et.options)}`;break;case ZodIssueCode.invalid_enum_value:tt=`Invalid enum value. Expected ${util.joinValues(et.options)}, received '${et.received}'`;break;case ZodIssueCode.invalid_arguments:tt="Invalid function arguments";break;case ZodIssueCode.invalid_return_type:tt="Invalid function return type";break;case ZodIssueCode.invalid_date:tt="Invalid date";break;case ZodIssueCode.invalid_string:typeof et.validation=="object"?"includes"in et.validation?(tt=`Invalid input: must include "${et.validation.includes}"`,typeof et.validation.position=="number"&&(tt=`${tt} at one or more positions greater than or equal to ${et.validation.position}`)):"startsWith"in et.validation?tt=`Invalid input: must start with "${et.validation.startsWith}"`:"endsWith"in et.validation?tt=`Invalid input: must end with "${et.validation.endsWith}"`:util.assertNever(et.validation):et.validation!=="regex"?tt=`Invalid ${et.validation}`:tt="Invalid";break;case ZodIssueCode.too_small:et.type==="array"?tt=`Array must contain ${et.exact?"exactly":et.inclusive?"at least":"more than"} ${et.minimum} element(s)`:et.type==="string"?tt=`String must contain ${et.exact?"exactly":et.inclusive?"at least":"over"} ${et.minimum} character(s)`:et.type==="number"?tt=`Number must be ${et.exact?"exactly equal to ":et.inclusive?"greater than or equal to ":"greater than "}${et.minimum}`:et.type==="date"?tt=`Date must be ${et.exact?"exactly equal to ":et.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(et.minimum))}`:tt="Invalid input";break;case ZodIssueCode.too_big:et.type==="array"?tt=`Array must contain ${et.exact?"exactly":et.inclusive?"at most":"less than"} ${et.maximum} element(s)`:et.type==="string"?tt=`String must contain ${et.exact?"exactly":et.inclusive?"at most":"under"} ${et.maximum} character(s)`:et.type==="number"?tt=`Number must be ${et.exact?"exactly":et.inclusive?"less than or equal to":"less than"} ${et.maximum}`:et.type==="bigint"?tt=`BigInt must be ${et.exact?"exactly":et.inclusive?"less than or equal to":"less than"} ${et.maximum}`:et.type==="date"?tt=`Date must be ${et.exact?"exactly":et.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(et.maximum))}`:tt="Invalid input";break;case ZodIssueCode.custom:tt="Invalid input";break;case ZodIssueCode.invalid_intersection_types:tt="Intersection results could not be merged";break;case ZodIssueCode.not_multiple_of:tt=`Number must be a multiple of ${et.multipleOf}`;break;case ZodIssueCode.not_finite:tt="Number must be finite";break;default:tt=o.defaultError,util.assertNever(et)}return{message:tt}};let overrideErrorMap=errorMap;function setErrorMap(et){overrideErrorMap=et}function getErrorMap(){return overrideErrorMap}const makeIssue=et=>{const{data:o,path:tt,errorMaps:rt,issueData:nt}=et,ot=[...tt,...nt.path||[]],it={...nt,path:ot};if(nt.message!==void 0)return{...nt,path:ot,message:nt.message};let st="";const at=rt.filter(ct=>!!ct).slice().reverse();for(const ct of at)st=ct(it,{data:o,defaultError:st}).message;return{...nt,path:ot,message:st}},EMPTY_PATH=[];function addIssueToContext(et,o){const tt=getErrorMap(),rt=makeIssue({issueData:o,data:et.data,path:et.path,errorMaps:[et.common.contextualErrorMap,et.schemaErrorMap,tt,tt===errorMap?void 0:errorMap].filter(nt=>!!nt)});et.common.issues.push(rt)}class ParseStatus{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(o,tt){const rt=[];for(const nt of tt){if(nt.status==="aborted")return INVALID;nt.status==="dirty"&&o.dirty(),rt.push(nt.value)}return{status:o.value,value:rt}}static async mergeObjectAsync(o,tt){const rt=[];for(const nt of tt){const ot=await nt.key,it=await nt.value;rt.push({key:ot,value:it})}return ParseStatus.mergeObjectSync(o,rt)}static mergeObjectSync(o,tt){const rt={};for(const nt of tt){const{key:ot,value:it}=nt;if(ot.status==="aborted"||it.status==="aborted")return INVALID;ot.status==="dirty"&&o.dirty(),it.status==="dirty"&&o.dirty(),ot.value!=="__proto__"&&(typeof it.value<"u"||nt.alwaysSet)&&(rt[ot.value]=it.value)}return{status:o.value,value:rt}}}const INVALID=Object.freeze({status:"aborted"}),DIRTY=et=>({status:"dirty",value:et}),OK=et=>({status:"valid",value:et}),isAborted=et=>et.status==="aborted",isDirty=et=>et.status==="dirty",isValid=et=>et.status==="valid",isAsync=et=>typeof Promise<"u"&&et instanceof Promise;function __classPrivateFieldGet(et,o,tt,rt){if(typeof o=="function"?et!==o||!rt:!o.has(et))throw new TypeError("Cannot read private member from an object whose class did not declare it");return o.get(et)}function __classPrivateFieldSet(et,o,tt,rt,nt){if(typeof o=="function"?et!==o||!nt:!o.has(et))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o.set(et,tt),tt}typeof SuppressedError=="function"&&SuppressedError;var errorUtil;(function(et){et.errToObj=o=>typeof o=="string"?{message:o}:o||{},et.toString=o=>typeof o=="string"?o:o==null?void 0:o.message})(errorUtil||(errorUtil={}));var _ZodEnum_cache,_ZodNativeEnum_cache;class ParseInputLazyPath{constructor(o,tt,rt,nt){this._cachedPath=[],this.parent=o,this.data=tt,this._path=rt,this._key=nt}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const handleResult=(et,o)=>{if(isValid(o))return{success:!0,data:o.value};if(!et.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const tt=new ZodError(et.common.issues);return this._error=tt,this._error}}};function processCreateParams(et){if(!et)return{};const{errorMap:o,invalid_type_error:tt,required_error:rt,description:nt}=et;if(o&&(tt||rt))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return o?{errorMap:o,description:nt}:{errorMap:(it,st)=>{var at,ct;const{message:lt}=et;return it.code==="invalid_enum_value"?{message:lt??st.defaultError}:typeof st.data>"u"?{message:(at=lt??rt)!==null&&at!==void 0?at:st.defaultError}:it.code!=="invalid_type"?{message:st.defaultError}:{message:(ct=lt??tt)!==null&&ct!==void 0?ct:st.defaultError}},description:nt}}class ZodType{constructor(o){this.spa=this.safeParseAsync,this._def=o,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(o){return getParsedType(o.data)}_getOrReturnCtx(o,tt){return tt||{common:o.parent.common,data:o.data,parsedType:getParsedType(o.data),schemaErrorMap:this._def.errorMap,path:o.path,parent:o.parent}}_processInputParams(o){return{status:new ParseStatus,ctx:{common:o.parent.common,data:o.data,parsedType:getParsedType(o.data),schemaErrorMap:this._def.errorMap,path:o.path,parent:o.parent}}}_parseSync(o){const tt=this._parse(o);if(isAsync(tt))throw new Error("Synchronous parse encountered promise.");return tt}_parseAsync(o){const tt=this._parse(o);return Promise.resolve(tt)}parse(o,tt){const rt=this.safeParse(o,tt);if(rt.success)return rt.data;throw rt.error}safeParse(o,tt){var rt;const nt={common:{issues:[],async:(rt=tt==null?void 0:tt.async)!==null&&rt!==void 0?rt:!1,contextualErrorMap:tt==null?void 0:tt.errorMap},path:(tt==null?void 0:tt.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:o,parsedType:getParsedType(o)},ot=this._parseSync({data:o,path:nt.path,parent:nt});return handleResult(nt,ot)}async parseAsync(o,tt){const rt=await this.safeParseAsync(o,tt);if(rt.success)return rt.data;throw rt.error}async safeParseAsync(o,tt){const rt={common:{issues:[],contextualErrorMap:tt==null?void 0:tt.errorMap,async:!0},path:(tt==null?void 0:tt.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:o,parsedType:getParsedType(o)},nt=this._parse({data:o,path:rt.path,parent:rt}),ot=await(isAsync(nt)?nt:Promise.resolve(nt));return handleResult(rt,ot)}refine(o,tt){const rt=nt=>typeof tt=="string"||typeof tt>"u"?{message:tt}:typeof tt=="function"?tt(nt):tt;return this._refinement((nt,ot)=>{const it=o(nt),st=()=>ot.addIssue({code:ZodIssueCode.custom,...rt(nt)});return typeof Promise<"u"&&it instanceof Promise?it.then(at=>at?!0:(st(),!1)):it?!0:(st(),!1)})}refinement(o,tt){return this._refinement((rt,nt)=>o(rt)?!0:(nt.addIssue(typeof tt=="function"?tt(rt,nt):tt),!1))}_refinement(o){return new ZodEffects({schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"refinement",refinement:o}})}superRefine(o){return this._refinement(o)}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this,this._def)}promise(){return ZodPromise.create(this,this._def)}or(o){return ZodUnion.create([this,o],this._def)}and(o){return ZodIntersection.create(this,o,this._def)}transform(o){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"transform",transform:o}})}default(o){const tt=typeof o=="function"?o:()=>o;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:tt,typeName:ZodFirstPartyTypeKind.ZodDefault})}brand(){return new ZodBranded({typeName:ZodFirstPartyTypeKind.ZodBranded,type:this,...processCreateParams(this._def)})}catch(o){const tt=typeof o=="function"?o:()=>o;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:tt,typeName:ZodFirstPartyTypeKind.ZodCatch})}describe(o){const tt=this.constructor;return new tt({...this._def,description:o})}pipe(o){return ZodPipeline.create(this,o)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cuidRegex=/^c[^\s-]{8,}$/i,cuid2Regex=/^[0-9a-z]+$/,ulidRegex=/^[0-9A-HJKMNP-TV-Z]{26}$/,uuidRegex=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,nanoidRegex=/^[a-z0-9_-]{21}$/i,durationRegex=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,emailRegex=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_emojiRegex="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let emojiRegex;const ipv4Regex=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6Regex=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,base64Regex=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dateRegexSource="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",dateRegex=new RegExp(`^${dateRegexSource}$`);function timeRegexSource(et){let o="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return et.precision?o=`${o}\\.\\d{${et.precision}}`:et.precision==null&&(o=`${o}(\\.\\d+)?`),o}function timeRegex(et){return new RegExp(`^${timeRegexSource(et)}$`)}function datetimeRegex(et){let o=`${dateRegexSource}T${timeRegexSource(et)}`;const tt=[];return tt.push(et.local?"Z?":"Z"),et.offset&&tt.push("([+-]\\d{2}:?\\d{2})"),o=`${o}(${tt.join("|")})`,new RegExp(`^${o}$`)}function isValidIP(et,o){return!!((o==="v4"||!o)&&ipv4Regex.test(et)||(o==="v6"||!o)&&ipv6Regex.test(et))}class ZodString extends ZodType{_parse(o){if(this._def.coerce&&(o.data=String(o.data)),this._getType(o)!==ZodParsedType.string){const ot=this._getOrReturnCtx(o);return addIssueToContext(ot,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.string,received:ot.parsedType}),INVALID}const rt=new ParseStatus;let nt;for(const ot of this._def.checks)if(ot.kind==="min")o.data.lengthot.value&&(nt=this._getOrReturnCtx(o,nt),addIssueToContext(nt,{code:ZodIssueCode.too_big,maximum:ot.value,type:"string",inclusive:!0,exact:!1,message:ot.message}),rt.dirty());else if(ot.kind==="length"){const it=o.data.length>ot.value,st=o.data.lengtho.test(nt),{validation:tt,code:ZodIssueCode.invalid_string,...errorUtil.errToObj(rt)})}_addCheck(o){return new ZodString({...this._def,checks:[...this._def.checks,o]})}email(o){return this._addCheck({kind:"email",...errorUtil.errToObj(o)})}url(o){return this._addCheck({kind:"url",...errorUtil.errToObj(o)})}emoji(o){return this._addCheck({kind:"emoji",...errorUtil.errToObj(o)})}uuid(o){return this._addCheck({kind:"uuid",...errorUtil.errToObj(o)})}nanoid(o){return this._addCheck({kind:"nanoid",...errorUtil.errToObj(o)})}cuid(o){return this._addCheck({kind:"cuid",...errorUtil.errToObj(o)})}cuid2(o){return this._addCheck({kind:"cuid2",...errorUtil.errToObj(o)})}ulid(o){return this._addCheck({kind:"ulid",...errorUtil.errToObj(o)})}base64(o){return this._addCheck({kind:"base64",...errorUtil.errToObj(o)})}ip(o){return this._addCheck({kind:"ip",...errorUtil.errToObj(o)})}datetime(o){var tt,rt;return typeof o=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:o}):this._addCheck({kind:"datetime",precision:typeof(o==null?void 0:o.precision)>"u"?null:o==null?void 0:o.precision,offset:(tt=o==null?void 0:o.offset)!==null&&tt!==void 0?tt:!1,local:(rt=o==null?void 0:o.local)!==null&&rt!==void 0?rt:!1,...errorUtil.errToObj(o==null?void 0:o.message)})}date(o){return this._addCheck({kind:"date",message:o})}time(o){return typeof o=="string"?this._addCheck({kind:"time",precision:null,message:o}):this._addCheck({kind:"time",precision:typeof(o==null?void 0:o.precision)>"u"?null:o==null?void 0:o.precision,...errorUtil.errToObj(o==null?void 0:o.message)})}duration(o){return this._addCheck({kind:"duration",...errorUtil.errToObj(o)})}regex(o,tt){return this._addCheck({kind:"regex",regex:o,...errorUtil.errToObj(tt)})}includes(o,tt){return this._addCheck({kind:"includes",value:o,position:tt==null?void 0:tt.position,...errorUtil.errToObj(tt==null?void 0:tt.message)})}startsWith(o,tt){return this._addCheck({kind:"startsWith",value:o,...errorUtil.errToObj(tt)})}endsWith(o,tt){return this._addCheck({kind:"endsWith",value:o,...errorUtil.errToObj(tt)})}min(o,tt){return this._addCheck({kind:"min",value:o,...errorUtil.errToObj(tt)})}max(o,tt){return this._addCheck({kind:"max",value:o,...errorUtil.errToObj(tt)})}length(o,tt){return this._addCheck({kind:"length",value:o,...errorUtil.errToObj(tt)})}nonempty(o){return this.min(1,errorUtil.errToObj(o))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(o=>o.kind==="datetime")}get isDate(){return!!this._def.checks.find(o=>o.kind==="date")}get isTime(){return!!this._def.checks.find(o=>o.kind==="time")}get isDuration(){return!!this._def.checks.find(o=>o.kind==="duration")}get isEmail(){return!!this._def.checks.find(o=>o.kind==="email")}get isURL(){return!!this._def.checks.find(o=>o.kind==="url")}get isEmoji(){return!!this._def.checks.find(o=>o.kind==="emoji")}get isUUID(){return!!this._def.checks.find(o=>o.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(o=>o.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(o=>o.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(o=>o.kind==="cuid2")}get isULID(){return!!this._def.checks.find(o=>o.kind==="ulid")}get isIP(){return!!this._def.checks.find(o=>o.kind==="ip")}get isBase64(){return!!this._def.checks.find(o=>o.kind==="base64")}get minLength(){let o=null;for(const tt of this._def.checks)tt.kind==="min"&&(o===null||tt.value>o)&&(o=tt.value);return o}get maxLength(){let o=null;for(const tt of this._def.checks)tt.kind==="max"&&(o===null||tt.value{var o;return new ZodString({checks:[],typeName:ZodFirstPartyTypeKind.ZodString,coerce:(o=et==null?void 0:et.coerce)!==null&&o!==void 0?o:!1,...processCreateParams(et)})};function floatSafeRemainder(et,o){const tt=(et.toString().split(".")[1]||"").length,rt=(o.toString().split(".")[1]||"").length,nt=tt>rt?tt:rt,ot=parseInt(et.toFixed(nt).replace(".","")),it=parseInt(o.toFixed(nt).replace(".",""));return ot%it/Math.pow(10,nt)}class ZodNumber extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(o){if(this._def.coerce&&(o.data=Number(o.data)),this._getType(o)!==ZodParsedType.number){const ot=this._getOrReturnCtx(o);return addIssueToContext(ot,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.number,received:ot.parsedType}),INVALID}let rt;const nt=new ParseStatus;for(const ot of this._def.checks)ot.kind==="int"?util.isInteger(o.data)||(rt=this._getOrReturnCtx(o,rt),addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:"integer",received:"float",message:ot.message}),nt.dirty()):ot.kind==="min"?(ot.inclusive?o.dataot.value:o.data>=ot.value)&&(rt=this._getOrReturnCtx(o,rt),addIssueToContext(rt,{code:ZodIssueCode.too_big,maximum:ot.value,type:"number",inclusive:ot.inclusive,exact:!1,message:ot.message}),nt.dirty()):ot.kind==="multipleOf"?floatSafeRemainder(o.data,ot.value)!==0&&(rt=this._getOrReturnCtx(o,rt),addIssueToContext(rt,{code:ZodIssueCode.not_multiple_of,multipleOf:ot.value,message:ot.message}),nt.dirty()):ot.kind==="finite"?Number.isFinite(o.data)||(rt=this._getOrReturnCtx(o,rt),addIssueToContext(rt,{code:ZodIssueCode.not_finite,message:ot.message}),nt.dirty()):util.assertNever(ot);return{status:nt.value,value:o.data}}gte(o,tt){return this.setLimit("min",o,!0,errorUtil.toString(tt))}gt(o,tt){return this.setLimit("min",o,!1,errorUtil.toString(tt))}lte(o,tt){return this.setLimit("max",o,!0,errorUtil.toString(tt))}lt(o,tt){return this.setLimit("max",o,!1,errorUtil.toString(tt))}setLimit(o,tt,rt,nt){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:o,value:tt,inclusive:rt,message:errorUtil.toString(nt)}]})}_addCheck(o){return new ZodNumber({...this._def,checks:[...this._def.checks,o]})}int(o){return this._addCheck({kind:"int",message:errorUtil.toString(o)})}positive(o){return this._addCheck({kind:"min",value:0,inclusive:!1,message:errorUtil.toString(o)})}negative(o){return this._addCheck({kind:"max",value:0,inclusive:!1,message:errorUtil.toString(o)})}nonpositive(o){return this._addCheck({kind:"max",value:0,inclusive:!0,message:errorUtil.toString(o)})}nonnegative(o){return this._addCheck({kind:"min",value:0,inclusive:!0,message:errorUtil.toString(o)})}multipleOf(o,tt){return this._addCheck({kind:"multipleOf",value:o,message:errorUtil.toString(tt)})}finite(o){return this._addCheck({kind:"finite",message:errorUtil.toString(o)})}safe(o){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:errorUtil.toString(o)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:errorUtil.toString(o)})}get minValue(){let o=null;for(const tt of this._def.checks)tt.kind==="min"&&(o===null||tt.value>o)&&(o=tt.value);return o}get maxValue(){let o=null;for(const tt of this._def.checks)tt.kind==="max"&&(o===null||tt.valueo.kind==="int"||o.kind==="multipleOf"&&util.isInteger(o.value))}get isFinite(){let o=null,tt=null;for(const rt of this._def.checks){if(rt.kind==="finite"||rt.kind==="int"||rt.kind==="multipleOf")return!0;rt.kind==="min"?(tt===null||rt.value>tt)&&(tt=rt.value):rt.kind==="max"&&(o===null||rt.valuenew ZodNumber({checks:[],typeName:ZodFirstPartyTypeKind.ZodNumber,coerce:(et==null?void 0:et.coerce)||!1,...processCreateParams(et)});class ZodBigInt extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(o){if(this._def.coerce&&(o.data=BigInt(o.data)),this._getType(o)!==ZodParsedType.bigint){const ot=this._getOrReturnCtx(o);return addIssueToContext(ot,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.bigint,received:ot.parsedType}),INVALID}let rt;const nt=new ParseStatus;for(const ot of this._def.checks)ot.kind==="min"?(ot.inclusive?o.dataot.value:o.data>=ot.value)&&(rt=this._getOrReturnCtx(o,rt),addIssueToContext(rt,{code:ZodIssueCode.too_big,type:"bigint",maximum:ot.value,inclusive:ot.inclusive,message:ot.message}),nt.dirty()):ot.kind==="multipleOf"?o.data%ot.value!==BigInt(0)&&(rt=this._getOrReturnCtx(o,rt),addIssueToContext(rt,{code:ZodIssueCode.not_multiple_of,multipleOf:ot.value,message:ot.message}),nt.dirty()):util.assertNever(ot);return{status:nt.value,value:o.data}}gte(o,tt){return this.setLimit("min",o,!0,errorUtil.toString(tt))}gt(o,tt){return this.setLimit("min",o,!1,errorUtil.toString(tt))}lte(o,tt){return this.setLimit("max",o,!0,errorUtil.toString(tt))}lt(o,tt){return this.setLimit("max",o,!1,errorUtil.toString(tt))}setLimit(o,tt,rt,nt){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:o,value:tt,inclusive:rt,message:errorUtil.toString(nt)}]})}_addCheck(o){return new ZodBigInt({...this._def,checks:[...this._def.checks,o]})}positive(o){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:errorUtil.toString(o)})}negative(o){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:errorUtil.toString(o)})}nonpositive(o){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:errorUtil.toString(o)})}nonnegative(o){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:errorUtil.toString(o)})}multipleOf(o,tt){return this._addCheck({kind:"multipleOf",value:o,message:errorUtil.toString(tt)})}get minValue(){let o=null;for(const tt of this._def.checks)tt.kind==="min"&&(o===null||tt.value>o)&&(o=tt.value);return o}get maxValue(){let o=null;for(const tt of this._def.checks)tt.kind==="max"&&(o===null||tt.value{var o;return new ZodBigInt({checks:[],typeName:ZodFirstPartyTypeKind.ZodBigInt,coerce:(o=et==null?void 0:et.coerce)!==null&&o!==void 0?o:!1,...processCreateParams(et)})};class ZodBoolean extends ZodType{_parse(o){if(this._def.coerce&&(o.data=!!o.data),this._getType(o)!==ZodParsedType.boolean){const rt=this._getOrReturnCtx(o);return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.boolean,received:rt.parsedType}),INVALID}return OK(o.data)}}ZodBoolean.create=et=>new ZodBoolean({typeName:ZodFirstPartyTypeKind.ZodBoolean,coerce:(et==null?void 0:et.coerce)||!1,...processCreateParams(et)});class ZodDate extends ZodType{_parse(o){if(this._def.coerce&&(o.data=new Date(o.data)),this._getType(o)!==ZodParsedType.date){const ot=this._getOrReturnCtx(o);return addIssueToContext(ot,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.date,received:ot.parsedType}),INVALID}if(isNaN(o.data.getTime())){const ot=this._getOrReturnCtx(o);return addIssueToContext(ot,{code:ZodIssueCode.invalid_date}),INVALID}const rt=new ParseStatus;let nt;for(const ot of this._def.checks)ot.kind==="min"?o.data.getTime()ot.value&&(nt=this._getOrReturnCtx(o,nt),addIssueToContext(nt,{code:ZodIssueCode.too_big,message:ot.message,inclusive:!0,exact:!1,maximum:ot.value,type:"date"}),rt.dirty()):util.assertNever(ot);return{status:rt.value,value:new Date(o.data.getTime())}}_addCheck(o){return new ZodDate({...this._def,checks:[...this._def.checks,o]})}min(o,tt){return this._addCheck({kind:"min",value:o.getTime(),message:errorUtil.toString(tt)})}max(o,tt){return this._addCheck({kind:"max",value:o.getTime(),message:errorUtil.toString(tt)})}get minDate(){let o=null;for(const tt of this._def.checks)tt.kind==="min"&&(o===null||tt.value>o)&&(o=tt.value);return o!=null?new Date(o):null}get maxDate(){let o=null;for(const tt of this._def.checks)tt.kind==="max"&&(o===null||tt.valuenew ZodDate({checks:[],coerce:(et==null?void 0:et.coerce)||!1,typeName:ZodFirstPartyTypeKind.ZodDate,...processCreateParams(et)});class ZodSymbol extends ZodType{_parse(o){if(this._getType(o)!==ZodParsedType.symbol){const rt=this._getOrReturnCtx(o);return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.symbol,received:rt.parsedType}),INVALID}return OK(o.data)}}ZodSymbol.create=et=>new ZodSymbol({typeName:ZodFirstPartyTypeKind.ZodSymbol,...processCreateParams(et)});class ZodUndefined extends ZodType{_parse(o){if(this._getType(o)!==ZodParsedType.undefined){const rt=this._getOrReturnCtx(o);return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.undefined,received:rt.parsedType}),INVALID}return OK(o.data)}}ZodUndefined.create=et=>new ZodUndefined({typeName:ZodFirstPartyTypeKind.ZodUndefined,...processCreateParams(et)});class ZodNull extends ZodType{_parse(o){if(this._getType(o)!==ZodParsedType.null){const rt=this._getOrReturnCtx(o);return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.null,received:rt.parsedType}),INVALID}return OK(o.data)}}ZodNull.create=et=>new ZodNull({typeName:ZodFirstPartyTypeKind.ZodNull,...processCreateParams(et)});class ZodAny extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(o){return OK(o.data)}}ZodAny.create=et=>new ZodAny({typeName:ZodFirstPartyTypeKind.ZodAny,...processCreateParams(et)});class ZodUnknown extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(o){return OK(o.data)}}ZodUnknown.create=et=>new ZodUnknown({typeName:ZodFirstPartyTypeKind.ZodUnknown,...processCreateParams(et)});class ZodNever extends ZodType{_parse(o){const tt=this._getOrReturnCtx(o);return addIssueToContext(tt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.never,received:tt.parsedType}),INVALID}}ZodNever.create=et=>new ZodNever({typeName:ZodFirstPartyTypeKind.ZodNever,...processCreateParams(et)});class ZodVoid extends ZodType{_parse(o){if(this._getType(o)!==ZodParsedType.undefined){const rt=this._getOrReturnCtx(o);return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.void,received:rt.parsedType}),INVALID}return OK(o.data)}}ZodVoid.create=et=>new ZodVoid({typeName:ZodFirstPartyTypeKind.ZodVoid,...processCreateParams(et)});class ZodArray extends ZodType{_parse(o){const{ctx:tt,status:rt}=this._processInputParams(o),nt=this._def;if(tt.parsedType!==ZodParsedType.array)return addIssueToContext(tt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:tt.parsedType}),INVALID;if(nt.exactLength!==null){const it=tt.data.length>nt.exactLength.value,st=tt.data.lengthnt.maxLength.value&&(addIssueToContext(tt,{code:ZodIssueCode.too_big,maximum:nt.maxLength.value,type:"array",inclusive:!0,exact:!1,message:nt.maxLength.message}),rt.dirty()),tt.common.async)return Promise.all([...tt.data].map((it,st)=>nt.type._parseAsync(new ParseInputLazyPath(tt,it,tt.path,st)))).then(it=>ParseStatus.mergeArray(rt,it));const ot=[...tt.data].map((it,st)=>nt.type._parseSync(new ParseInputLazyPath(tt,it,tt.path,st)));return ParseStatus.mergeArray(rt,ot)}get element(){return this._def.type}min(o,tt){return new ZodArray({...this._def,minLength:{value:o,message:errorUtil.toString(tt)}})}max(o,tt){return new ZodArray({...this._def,maxLength:{value:o,message:errorUtil.toString(tt)}})}length(o,tt){return new ZodArray({...this._def,exactLength:{value:o,message:errorUtil.toString(tt)}})}nonempty(o){return this.min(1,o)}}ZodArray.create=(et,o)=>new ZodArray({type:et,minLength:null,maxLength:null,exactLength:null,typeName:ZodFirstPartyTypeKind.ZodArray,...processCreateParams(o)});function deepPartialify(et){if(et instanceof ZodObject){const o={};for(const tt in et.shape){const rt=et.shape[tt];o[tt]=ZodOptional.create(deepPartialify(rt))}return new ZodObject({...et._def,shape:()=>o})}else return et instanceof ZodArray?new ZodArray({...et._def,type:deepPartialify(et.element)}):et instanceof ZodOptional?ZodOptional.create(deepPartialify(et.unwrap())):et instanceof ZodNullable?ZodNullable.create(deepPartialify(et.unwrap())):et instanceof ZodTuple?ZodTuple.create(et.items.map(o=>deepPartialify(o))):et}class ZodObject extends ZodType{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const o=this._def.shape(),tt=util.objectKeys(o);return this._cached={shape:o,keys:tt}}_parse(o){if(this._getType(o)!==ZodParsedType.object){const ct=this._getOrReturnCtx(o);return addIssueToContext(ct,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:ct.parsedType}),INVALID}const{status:rt,ctx:nt}=this._processInputParams(o),{shape:ot,keys:it}=this._getCached(),st=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip"))for(const ct in nt.data)it.includes(ct)||st.push(ct);const at=[];for(const ct of it){const lt=ot[ct],dt=nt.data[ct];at.push({key:{status:"valid",value:ct},value:lt._parse(new ParseInputLazyPath(nt,dt,nt.path,ct)),alwaysSet:ct in nt.data})}if(this._def.catchall instanceof ZodNever){const ct=this._def.unknownKeys;if(ct==="passthrough")for(const lt of st)at.push({key:{status:"valid",value:lt},value:{status:"valid",value:nt.data[lt]}});else if(ct==="strict")st.length>0&&(addIssueToContext(nt,{code:ZodIssueCode.unrecognized_keys,keys:st}),rt.dirty());else if(ct!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const ct=this._def.catchall;for(const lt of st){const dt=nt.data[lt];at.push({key:{status:"valid",value:lt},value:ct._parse(new ParseInputLazyPath(nt,dt,nt.path,lt)),alwaysSet:lt in nt.data})}}return nt.common.async?Promise.resolve().then(async()=>{const ct=[];for(const lt of at){const dt=await lt.key,ht=await lt.value;ct.push({key:dt,value:ht,alwaysSet:lt.alwaysSet})}return ct}).then(ct=>ParseStatus.mergeObjectSync(rt,ct)):ParseStatus.mergeObjectSync(rt,at)}get shape(){return this._def.shape()}strict(o){return errorUtil.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...o!==void 0?{errorMap:(tt,rt)=>{var nt,ot,it,st;const at=(it=(ot=(nt=this._def).errorMap)===null||ot===void 0?void 0:ot.call(nt,tt,rt).message)!==null&&it!==void 0?it:rt.defaultError;return tt.code==="unrecognized_keys"?{message:(st=errorUtil.errToObj(o).message)!==null&&st!==void 0?st:at}:{message:at}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(o){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...o})})}merge(o){return new ZodObject({unknownKeys:o._def.unknownKeys,catchall:o._def.catchall,shape:()=>({...this._def.shape(),...o._def.shape()}),typeName:ZodFirstPartyTypeKind.ZodObject})}setKey(o,tt){return this.augment({[o]:tt})}catchall(o){return new ZodObject({...this._def,catchall:o})}pick(o){const tt={};return util.objectKeys(o).forEach(rt=>{o[rt]&&this.shape[rt]&&(tt[rt]=this.shape[rt])}),new ZodObject({...this._def,shape:()=>tt})}omit(o){const tt={};return util.objectKeys(this.shape).forEach(rt=>{o[rt]||(tt[rt]=this.shape[rt])}),new ZodObject({...this._def,shape:()=>tt})}deepPartial(){return deepPartialify(this)}partial(o){const tt={};return util.objectKeys(this.shape).forEach(rt=>{const nt=this.shape[rt];o&&!o[rt]?tt[rt]=nt:tt[rt]=nt.optional()}),new ZodObject({...this._def,shape:()=>tt})}required(o){const tt={};return util.objectKeys(this.shape).forEach(rt=>{if(o&&!o[rt])tt[rt]=this.shape[rt];else{let ot=this.shape[rt];for(;ot instanceof ZodOptional;)ot=ot._def.innerType;tt[rt]=ot}}),new ZodObject({...this._def,shape:()=>tt})}keyof(){return createZodEnum(util.objectKeys(this.shape))}}ZodObject.create=(et,o)=>new ZodObject({shape:()=>et,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(o)});ZodObject.strictCreate=(et,o)=>new ZodObject({shape:()=>et,unknownKeys:"strict",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(o)});ZodObject.lazycreate=(et,o)=>new ZodObject({shape:et,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(o)});class ZodUnion extends ZodType{_parse(o){const{ctx:tt}=this._processInputParams(o),rt=this._def.options;function nt(ot){for(const st of ot)if(st.result.status==="valid")return st.result;for(const st of ot)if(st.result.status==="dirty")return tt.common.issues.push(...st.ctx.common.issues),st.result;const it=ot.map(st=>new ZodError(st.ctx.common.issues));return addIssueToContext(tt,{code:ZodIssueCode.invalid_union,unionErrors:it}),INVALID}if(tt.common.async)return Promise.all(rt.map(async ot=>{const it={...tt,common:{...tt.common,issues:[]},parent:null};return{result:await ot._parseAsync({data:tt.data,path:tt.path,parent:it}),ctx:it}})).then(nt);{let ot;const it=[];for(const at of rt){const ct={...tt,common:{...tt.common,issues:[]},parent:null},lt=at._parseSync({data:tt.data,path:tt.path,parent:ct});if(lt.status==="valid")return lt;lt.status==="dirty"&&!ot&&(ot={result:lt,ctx:ct}),ct.common.issues.length&&it.push(ct.common.issues)}if(ot)return tt.common.issues.push(...ot.ctx.common.issues),ot.result;const st=it.map(at=>new ZodError(at));return addIssueToContext(tt,{code:ZodIssueCode.invalid_union,unionErrors:st}),INVALID}}get options(){return this._def.options}}ZodUnion.create=(et,o)=>new ZodUnion({options:et,typeName:ZodFirstPartyTypeKind.ZodUnion,...processCreateParams(o)});const getDiscriminator=et=>et instanceof ZodLazy?getDiscriminator(et.schema):et instanceof ZodEffects?getDiscriminator(et.innerType()):et instanceof ZodLiteral?[et.value]:et instanceof ZodEnum?et.options:et instanceof ZodNativeEnum?util.objectValues(et.enum):et instanceof ZodDefault?getDiscriminator(et._def.innerType):et instanceof ZodUndefined?[void 0]:et instanceof ZodNull?[null]:et instanceof ZodOptional?[void 0,...getDiscriminator(et.unwrap())]:et instanceof ZodNullable?[null,...getDiscriminator(et.unwrap())]:et instanceof ZodBranded||et instanceof ZodReadonly?getDiscriminator(et.unwrap()):et instanceof ZodCatch?getDiscriminator(et._def.innerType):[];class ZodDiscriminatedUnion extends ZodType{_parse(o){const{ctx:tt}=this._processInputParams(o);if(tt.parsedType!==ZodParsedType.object)return addIssueToContext(tt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:tt.parsedType}),INVALID;const rt=this.discriminator,nt=tt.data[rt],ot=this.optionsMap.get(nt);return ot?tt.common.async?ot._parseAsync({data:tt.data,path:tt.path,parent:tt}):ot._parseSync({data:tt.data,path:tt.path,parent:tt}):(addIssueToContext(tt,{code:ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[rt]}),INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(o,tt,rt){const nt=new Map;for(const ot of tt){const it=getDiscriminator(ot.shape[o]);if(!it.length)throw new Error(`A discriminator value for key \`${o}\` could not be extracted from all schema options`);for(const st of it){if(nt.has(st))throw new Error(`Discriminator property ${String(o)} has duplicate value ${String(st)}`);nt.set(st,ot)}}return new ZodDiscriminatedUnion({typeName:ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:o,options:tt,optionsMap:nt,...processCreateParams(rt)})}}function mergeValues(et,o){const tt=getParsedType(et),rt=getParsedType(o);if(et===o)return{valid:!0,data:et};if(tt===ZodParsedType.object&&rt===ZodParsedType.object){const nt=util.objectKeys(o),ot=util.objectKeys(et).filter(st=>nt.indexOf(st)!==-1),it={...et,...o};for(const st of ot){const at=mergeValues(et[st],o[st]);if(!at.valid)return{valid:!1};it[st]=at.data}return{valid:!0,data:it}}else if(tt===ZodParsedType.array&&rt===ZodParsedType.array){if(et.length!==o.length)return{valid:!1};const nt=[];for(let ot=0;ot{if(isAborted(ot)||isAborted(it))return INVALID;const st=mergeValues(ot.value,it.value);return st.valid?((isDirty(ot)||isDirty(it))&&tt.dirty(),{status:tt.value,value:st.data}):(addIssueToContext(rt,{code:ZodIssueCode.invalid_intersection_types}),INVALID)};return rt.common.async?Promise.all([this._def.left._parseAsync({data:rt.data,path:rt.path,parent:rt}),this._def.right._parseAsync({data:rt.data,path:rt.path,parent:rt})]).then(([ot,it])=>nt(ot,it)):nt(this._def.left._parseSync({data:rt.data,path:rt.path,parent:rt}),this._def.right._parseSync({data:rt.data,path:rt.path,parent:rt}))}}ZodIntersection.create=(et,o,tt)=>new ZodIntersection({left:et,right:o,typeName:ZodFirstPartyTypeKind.ZodIntersection,...processCreateParams(tt)});class ZodTuple extends ZodType{_parse(o){const{status:tt,ctx:rt}=this._processInputParams(o);if(rt.parsedType!==ZodParsedType.array)return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:rt.parsedType}),INVALID;if(rt.data.lengththis._def.items.length&&(addIssueToContext(rt,{code:ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),tt.dirty());const ot=[...rt.data].map((it,st)=>{const at=this._def.items[st]||this._def.rest;return at?at._parse(new ParseInputLazyPath(rt,it,rt.path,st)):null}).filter(it=>!!it);return rt.common.async?Promise.all(ot).then(it=>ParseStatus.mergeArray(tt,it)):ParseStatus.mergeArray(tt,ot)}get items(){return this._def.items}rest(o){return new ZodTuple({...this._def,rest:o})}}ZodTuple.create=(et,o)=>{if(!Array.isArray(et))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:et,typeName:ZodFirstPartyTypeKind.ZodTuple,rest:null,...processCreateParams(o)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(o){const{status:tt,ctx:rt}=this._processInputParams(o);if(rt.parsedType!==ZodParsedType.object)return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:rt.parsedType}),INVALID;const nt=[],ot=this._def.keyType,it=this._def.valueType;for(const st in rt.data)nt.push({key:ot._parse(new ParseInputLazyPath(rt,st,rt.path,st)),value:it._parse(new ParseInputLazyPath(rt,rt.data[st],rt.path,st)),alwaysSet:st in rt.data});return rt.common.async?ParseStatus.mergeObjectAsync(tt,nt):ParseStatus.mergeObjectSync(tt,nt)}get element(){return this._def.valueType}static create(o,tt,rt){return tt instanceof ZodType?new ZodRecord({keyType:o,valueType:tt,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(rt)}):new ZodRecord({keyType:ZodString.create(),valueType:o,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(tt)})}}class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(o){const{status:tt,ctx:rt}=this._processInputParams(o);if(rt.parsedType!==ZodParsedType.map)return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.map,received:rt.parsedType}),INVALID;const nt=this._def.keyType,ot=this._def.valueType,it=[...rt.data.entries()].map(([st,at],ct)=>({key:nt._parse(new ParseInputLazyPath(rt,st,rt.path,[ct,"key"])),value:ot._parse(new ParseInputLazyPath(rt,at,rt.path,[ct,"value"]))}));if(rt.common.async){const st=new Map;return Promise.resolve().then(async()=>{for(const at of it){const ct=await at.key,lt=await at.value;if(ct.status==="aborted"||lt.status==="aborted")return INVALID;(ct.status==="dirty"||lt.status==="dirty")&&tt.dirty(),st.set(ct.value,lt.value)}return{status:tt.value,value:st}})}else{const st=new Map;for(const at of it){const ct=at.key,lt=at.value;if(ct.status==="aborted"||lt.status==="aborted")return INVALID;(ct.status==="dirty"||lt.status==="dirty")&&tt.dirty(),st.set(ct.value,lt.value)}return{status:tt.value,value:st}}}}ZodMap.create=(et,o,tt)=>new ZodMap({valueType:o,keyType:et,typeName:ZodFirstPartyTypeKind.ZodMap,...processCreateParams(tt)});class ZodSet extends ZodType{_parse(o){const{status:tt,ctx:rt}=this._processInputParams(o);if(rt.parsedType!==ZodParsedType.set)return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.set,received:rt.parsedType}),INVALID;const nt=this._def;nt.minSize!==null&&rt.data.sizent.maxSize.value&&(addIssueToContext(rt,{code:ZodIssueCode.too_big,maximum:nt.maxSize.value,type:"set",inclusive:!0,exact:!1,message:nt.maxSize.message}),tt.dirty());const ot=this._def.valueType;function it(at){const ct=new Set;for(const lt of at){if(lt.status==="aborted")return INVALID;lt.status==="dirty"&&tt.dirty(),ct.add(lt.value)}return{status:tt.value,value:ct}}const st=[...rt.data.values()].map((at,ct)=>ot._parse(new ParseInputLazyPath(rt,at,rt.path,ct)));return rt.common.async?Promise.all(st).then(at=>it(at)):it(st)}min(o,tt){return new ZodSet({...this._def,minSize:{value:o,message:errorUtil.toString(tt)}})}max(o,tt){return new ZodSet({...this._def,maxSize:{value:o,message:errorUtil.toString(tt)}})}size(o,tt){return this.min(o,tt).max(o,tt)}nonempty(o){return this.min(1,o)}}ZodSet.create=(et,o)=>new ZodSet({valueType:et,minSize:null,maxSize:null,typeName:ZodFirstPartyTypeKind.ZodSet,...processCreateParams(o)});class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(o){const{ctx:tt}=this._processInputParams(o);if(tt.parsedType!==ZodParsedType.function)return addIssueToContext(tt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.function,received:tt.parsedType}),INVALID;function rt(st,at){return makeIssue({data:st,path:tt.path,errorMaps:[tt.common.contextualErrorMap,tt.schemaErrorMap,getErrorMap(),errorMap].filter(ct=>!!ct),issueData:{code:ZodIssueCode.invalid_arguments,argumentsError:at}})}function nt(st,at){return makeIssue({data:st,path:tt.path,errorMaps:[tt.common.contextualErrorMap,tt.schemaErrorMap,getErrorMap(),errorMap].filter(ct=>!!ct),issueData:{code:ZodIssueCode.invalid_return_type,returnTypeError:at}})}const ot={errorMap:tt.common.contextualErrorMap},it=tt.data;if(this._def.returns instanceof ZodPromise){const st=this;return OK(async function(...at){const ct=new ZodError([]),lt=await st._def.args.parseAsync(at,ot).catch(mt=>{throw ct.addIssue(rt(at,mt)),ct}),dt=await Reflect.apply(it,this,lt);return await st._def.returns._def.type.parseAsync(dt,ot).catch(mt=>{throw ct.addIssue(nt(dt,mt)),ct})})}else{const st=this;return OK(function(...at){const ct=st._def.args.safeParse(at,ot);if(!ct.success)throw new ZodError([rt(at,ct.error)]);const lt=Reflect.apply(it,this,ct.data),dt=st._def.returns.safeParse(lt,ot);if(!dt.success)throw new ZodError([nt(lt,dt.error)]);return dt.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...o){return new ZodFunction({...this._def,args:ZodTuple.create(o).rest(ZodUnknown.create())})}returns(o){return new ZodFunction({...this._def,returns:o})}implement(o){return this.parse(o)}strictImplement(o){return this.parse(o)}static create(o,tt,rt){return new ZodFunction({args:o||ZodTuple.create([]).rest(ZodUnknown.create()),returns:tt||ZodUnknown.create(),typeName:ZodFirstPartyTypeKind.ZodFunction,...processCreateParams(rt)})}}class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(o){const{ctx:tt}=this._processInputParams(o);return this._def.getter()._parse({data:tt.data,path:tt.path,parent:tt})}}ZodLazy.create=(et,o)=>new ZodLazy({getter:et,typeName:ZodFirstPartyTypeKind.ZodLazy,...processCreateParams(o)});class ZodLiteral extends ZodType{_parse(o){if(o.data!==this._def.value){const tt=this._getOrReturnCtx(o);return addIssueToContext(tt,{received:tt.data,code:ZodIssueCode.invalid_literal,expected:this._def.value}),INVALID}return{status:"valid",value:o.data}}get value(){return this._def.value}}ZodLiteral.create=(et,o)=>new ZodLiteral({value:et,typeName:ZodFirstPartyTypeKind.ZodLiteral,...processCreateParams(o)});function createZodEnum(et,o){return new ZodEnum({values:et,typeName:ZodFirstPartyTypeKind.ZodEnum,...processCreateParams(o)})}class ZodEnum extends ZodType{constructor(){super(...arguments),_ZodEnum_cache.set(this,void 0)}_parse(o){if(typeof o.data!="string"){const tt=this._getOrReturnCtx(o),rt=this._def.values;return addIssueToContext(tt,{expected:util.joinValues(rt),received:tt.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(__classPrivateFieldGet(this,_ZodEnum_cache)||__classPrivateFieldSet(this,_ZodEnum_cache,new Set(this._def.values)),!__classPrivateFieldGet(this,_ZodEnum_cache).has(o.data)){const tt=this._getOrReturnCtx(o),rt=this._def.values;return addIssueToContext(tt,{received:tt.data,code:ZodIssueCode.invalid_enum_value,options:rt}),INVALID}return OK(o.data)}get options(){return this._def.values}get enum(){const o={};for(const tt of this._def.values)o[tt]=tt;return o}get Values(){const o={};for(const tt of this._def.values)o[tt]=tt;return o}get Enum(){const o={};for(const tt of this._def.values)o[tt]=tt;return o}extract(o,tt=this._def){return ZodEnum.create(o,{...this._def,...tt})}exclude(o,tt=this._def){return ZodEnum.create(this.options.filter(rt=>!o.includes(rt)),{...this._def,...tt})}}_ZodEnum_cache=new WeakMap;ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{constructor(){super(...arguments),_ZodNativeEnum_cache.set(this,void 0)}_parse(o){const tt=util.getValidEnumValues(this._def.values),rt=this._getOrReturnCtx(o);if(rt.parsedType!==ZodParsedType.string&&rt.parsedType!==ZodParsedType.number){const nt=util.objectValues(tt);return addIssueToContext(rt,{expected:util.joinValues(nt),received:rt.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(__classPrivateFieldGet(this,_ZodNativeEnum_cache)||__classPrivateFieldSet(this,_ZodNativeEnum_cache,new Set(util.getValidEnumValues(this._def.values))),!__classPrivateFieldGet(this,_ZodNativeEnum_cache).has(o.data)){const nt=util.objectValues(tt);return addIssueToContext(rt,{received:rt.data,code:ZodIssueCode.invalid_enum_value,options:nt}),INVALID}return OK(o.data)}get enum(){return this._def.values}}_ZodNativeEnum_cache=new WeakMap;ZodNativeEnum.create=(et,o)=>new ZodNativeEnum({values:et,typeName:ZodFirstPartyTypeKind.ZodNativeEnum,...processCreateParams(o)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(o){const{ctx:tt}=this._processInputParams(o);if(tt.parsedType!==ZodParsedType.promise&&tt.common.async===!1)return addIssueToContext(tt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.promise,received:tt.parsedType}),INVALID;const rt=tt.parsedType===ZodParsedType.promise?tt.data:Promise.resolve(tt.data);return OK(rt.then(nt=>this._def.type.parseAsync(nt,{path:tt.path,errorMap:tt.common.contextualErrorMap})))}}ZodPromise.create=(et,o)=>new ZodPromise({type:et,typeName:ZodFirstPartyTypeKind.ZodPromise,...processCreateParams(o)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ZodFirstPartyTypeKind.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(o){const{status:tt,ctx:rt}=this._processInputParams(o),nt=this._def.effect||null,ot={addIssue:it=>{addIssueToContext(rt,it),it.fatal?tt.abort():tt.dirty()},get path(){return rt.path}};if(ot.addIssue=ot.addIssue.bind(ot),nt.type==="preprocess"){const it=nt.transform(rt.data,ot);if(rt.common.async)return Promise.resolve(it).then(async st=>{if(tt.value==="aborted")return INVALID;const at=await this._def.schema._parseAsync({data:st,path:rt.path,parent:rt});return at.status==="aborted"?INVALID:at.status==="dirty"||tt.value==="dirty"?DIRTY(at.value):at});{if(tt.value==="aborted")return INVALID;const st=this._def.schema._parseSync({data:it,path:rt.path,parent:rt});return st.status==="aborted"?INVALID:st.status==="dirty"||tt.value==="dirty"?DIRTY(st.value):st}}if(nt.type==="refinement"){const it=st=>{const at=nt.refinement(st,ot);if(rt.common.async)return Promise.resolve(at);if(at instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return st};if(rt.common.async===!1){const st=this._def.schema._parseSync({data:rt.data,path:rt.path,parent:rt});return st.status==="aborted"?INVALID:(st.status==="dirty"&&tt.dirty(),it(st.value),{status:tt.value,value:st.value})}else return this._def.schema._parseAsync({data:rt.data,path:rt.path,parent:rt}).then(st=>st.status==="aborted"?INVALID:(st.status==="dirty"&&tt.dirty(),it(st.value).then(()=>({status:tt.value,value:st.value}))))}if(nt.type==="transform")if(rt.common.async===!1){const it=this._def.schema._parseSync({data:rt.data,path:rt.path,parent:rt});if(!isValid(it))return it;const st=nt.transform(it.value,ot);if(st instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:tt.value,value:st}}else return this._def.schema._parseAsync({data:rt.data,path:rt.path,parent:rt}).then(it=>isValid(it)?Promise.resolve(nt.transform(it.value,ot)).then(st=>({status:tt.value,value:st})):it);util.assertNever(nt)}}ZodEffects.create=(et,o,tt)=>new ZodEffects({schema:et,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:o,...processCreateParams(tt)});ZodEffects.createWithPreprocess=(et,o,tt)=>new ZodEffects({schema:o,effect:{type:"preprocess",transform:et},typeName:ZodFirstPartyTypeKind.ZodEffects,...processCreateParams(tt)});class ZodOptional extends ZodType{_parse(o){return this._getType(o)===ZodParsedType.undefined?OK(void 0):this._def.innerType._parse(o)}unwrap(){return this._def.innerType}}ZodOptional.create=(et,o)=>new ZodOptional({innerType:et,typeName:ZodFirstPartyTypeKind.ZodOptional,...processCreateParams(o)});class ZodNullable extends ZodType{_parse(o){return this._getType(o)===ZodParsedType.null?OK(null):this._def.innerType._parse(o)}unwrap(){return this._def.innerType}}ZodNullable.create=(et,o)=>new ZodNullable({innerType:et,typeName:ZodFirstPartyTypeKind.ZodNullable,...processCreateParams(o)});class ZodDefault extends ZodType{_parse(o){const{ctx:tt}=this._processInputParams(o);let rt=tt.data;return tt.parsedType===ZodParsedType.undefined&&(rt=this._def.defaultValue()),this._def.innerType._parse({data:rt,path:tt.path,parent:tt})}removeDefault(){return this._def.innerType}}ZodDefault.create=(et,o)=>new ZodDefault({innerType:et,typeName:ZodFirstPartyTypeKind.ZodDefault,defaultValue:typeof o.default=="function"?o.default:()=>o.default,...processCreateParams(o)});class ZodCatch extends ZodType{_parse(o){const{ctx:tt}=this._processInputParams(o),rt={...tt,common:{...tt.common,issues:[]}},nt=this._def.innerType._parse({data:rt.data,path:rt.path,parent:{...rt}});return isAsync(nt)?nt.then(ot=>({status:"valid",value:ot.status==="valid"?ot.value:this._def.catchValue({get error(){return new ZodError(rt.common.issues)},input:rt.data})})):{status:"valid",value:nt.status==="valid"?nt.value:this._def.catchValue({get error(){return new ZodError(rt.common.issues)},input:rt.data})}}removeCatch(){return this._def.innerType}}ZodCatch.create=(et,o)=>new ZodCatch({innerType:et,typeName:ZodFirstPartyTypeKind.ZodCatch,catchValue:typeof o.catch=="function"?o.catch:()=>o.catch,...processCreateParams(o)});class ZodNaN extends ZodType{_parse(o){if(this._getType(o)!==ZodParsedType.nan){const rt=this._getOrReturnCtx(o);return addIssueToContext(rt,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.nan,received:rt.parsedType}),INVALID}return{status:"valid",value:o.data}}}ZodNaN.create=et=>new ZodNaN({typeName:ZodFirstPartyTypeKind.ZodNaN,...processCreateParams(et)});const BRAND=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(o){const{ctx:tt}=this._processInputParams(o),rt=tt.data;return this._def.type._parse({data:rt,path:tt.path,parent:tt})}unwrap(){return this._def.type}}class ZodPipeline extends ZodType{_parse(o){const{status:tt,ctx:rt}=this._processInputParams(o);if(rt.common.async)return(async()=>{const ot=await this._def.in._parseAsync({data:rt.data,path:rt.path,parent:rt});return ot.status==="aborted"?INVALID:ot.status==="dirty"?(tt.dirty(),DIRTY(ot.value)):this._def.out._parseAsync({data:ot.value,path:rt.path,parent:rt})})();{const nt=this._def.in._parseSync({data:rt.data,path:rt.path,parent:rt});return nt.status==="aborted"?INVALID:nt.status==="dirty"?(tt.dirty(),{status:"dirty",value:nt.value}):this._def.out._parseSync({data:nt.value,path:rt.path,parent:rt})}}static create(o,tt){return new ZodPipeline({in:o,out:tt,typeName:ZodFirstPartyTypeKind.ZodPipeline})}}class ZodReadonly extends ZodType{_parse(o){const tt=this._def.innerType._parse(o),rt=nt=>(isValid(nt)&&(nt.value=Object.freeze(nt.value)),nt);return isAsync(tt)?tt.then(nt=>rt(nt)):rt(tt)}unwrap(){return this._def.innerType}}ZodReadonly.create=(et,o)=>new ZodReadonly({innerType:et,typeName:ZodFirstPartyTypeKind.ZodReadonly,...processCreateParams(o)});function custom(et,o={},tt){return et?ZodAny.create().superRefine((rt,nt)=>{var ot,it;if(!et(rt)){const st=typeof o=="function"?o(rt):typeof o=="string"?{message:o}:o,at=(it=(ot=st.fatal)!==null&&ot!==void 0?ot:tt)!==null&&it!==void 0?it:!0,ct=typeof st=="string"?{message:st}:st;nt.addIssue({code:"custom",...ct,fatal:at})}}):ZodAny.create()}const late={object:ZodObject.lazycreate};var ZodFirstPartyTypeKind;(function(et){et.ZodString="ZodString",et.ZodNumber="ZodNumber",et.ZodNaN="ZodNaN",et.ZodBigInt="ZodBigInt",et.ZodBoolean="ZodBoolean",et.ZodDate="ZodDate",et.ZodSymbol="ZodSymbol",et.ZodUndefined="ZodUndefined",et.ZodNull="ZodNull",et.ZodAny="ZodAny",et.ZodUnknown="ZodUnknown",et.ZodNever="ZodNever",et.ZodVoid="ZodVoid",et.ZodArray="ZodArray",et.ZodObject="ZodObject",et.ZodUnion="ZodUnion",et.ZodDiscriminatedUnion="ZodDiscriminatedUnion",et.ZodIntersection="ZodIntersection",et.ZodTuple="ZodTuple",et.ZodRecord="ZodRecord",et.ZodMap="ZodMap",et.ZodSet="ZodSet",et.ZodFunction="ZodFunction",et.ZodLazy="ZodLazy",et.ZodLiteral="ZodLiteral",et.ZodEnum="ZodEnum",et.ZodEffects="ZodEffects",et.ZodNativeEnum="ZodNativeEnum",et.ZodOptional="ZodOptional",et.ZodNullable="ZodNullable",et.ZodDefault="ZodDefault",et.ZodCatch="ZodCatch",et.ZodPromise="ZodPromise",et.ZodBranded="ZodBranded",et.ZodPipeline="ZodPipeline",et.ZodReadonly="ZodReadonly"})(ZodFirstPartyTypeKind||(ZodFirstPartyTypeKind={}));const instanceOfType=(et,o={message:`Input not instance of ${et.name}`})=>custom(tt=>tt instanceof et,o),stringType=ZodString.create,numberType=ZodNumber.create,nanType=ZodNaN.create,bigIntType=ZodBigInt.create,booleanType=ZodBoolean.create,dateType=ZodDate.create,symbolType=ZodSymbol.create,undefinedType=ZodUndefined.create,nullType=ZodNull.create,anyType=ZodAny.create,unknownType=ZodUnknown.create,neverType=ZodNever.create,voidType=ZodVoid.create,arrayType=ZodArray.create,objectType=ZodObject.create,strictObjectType=ZodObject.strictCreate,unionType=ZodUnion.create,discriminatedUnionType=ZodDiscriminatedUnion.create,intersectionType=ZodIntersection.create,tupleType=ZodTuple.create,recordType=ZodRecord.create,mapType=ZodMap.create,setType=ZodSet.create,functionType=ZodFunction.create,lazyType=ZodLazy.create,literalType=ZodLiteral.create,enumType=ZodEnum.create,nativeEnumType=ZodNativeEnum.create,promiseType=ZodPromise.create,effectsType=ZodEffects.create,optionalType=ZodOptional.create,nullableType=ZodNullable.create,preprocessType=ZodEffects.createWithPreprocess,pipelineType=ZodPipeline.create,ostring=()=>stringType().optional(),onumber=()=>numberType().optional(),oboolean=()=>booleanType().optional(),coerce={string:et=>ZodString.create({...et,coerce:!0}),number:et=>ZodNumber.create({...et,coerce:!0}),boolean:et=>ZodBoolean.create({...et,coerce:!0}),bigint:et=>ZodBigInt.create({...et,coerce:!0}),date:et=>ZodDate.create({...et,coerce:!0})},NEVER=INVALID;var z=Object.freeze({__proto__:null,defaultErrorMap:errorMap,setErrorMap,getErrorMap,makeIssue,EMPTY_PATH,addIssueToContext,ParseStatus,INVALID,DIRTY,OK,isAborted,isDirty,isValid,isAsync,get util(){return util},get objectUtil(){return objectUtil},ZodParsedType,getParsedType,ZodType,datetimeRegex,ZodString,ZodNumber,ZodBigInt,ZodBoolean,ZodDate,ZodSymbol,ZodUndefined,ZodNull,ZodAny,ZodUnknown,ZodNever,ZodVoid,ZodArray,ZodObject,ZodUnion,ZodDiscriminatedUnion,ZodIntersection,ZodTuple,ZodRecord,ZodMap,ZodSet,ZodFunction,ZodLazy,ZodLiteral,ZodEnum,ZodNativeEnum,ZodPromise,ZodEffects,ZodTransformer:ZodEffects,ZodOptional,ZodNullable,ZodDefault,ZodCatch,ZodNaN,BRAND,ZodBranded,ZodPipeline,ZodReadonly,custom,Schema:ZodType,ZodSchema:ZodType,late,get ZodFirstPartyTypeKind(){return ZodFirstPartyTypeKind},coerce,any:anyType,array:arrayType,bigint:bigIntType,boolean:booleanType,date:dateType,discriminatedUnion:discriminatedUnionType,effect:effectsType,enum:enumType,function:functionType,instanceof:instanceOfType,intersection:intersectionType,lazy:lazyType,literal:literalType,map:mapType,nan:nanType,nativeEnum:nativeEnumType,never:neverType,null:nullType,nullable:nullableType,number:numberType,object:objectType,oboolean,onumber,optional:optionalType,ostring,pipeline:pipelineType,preprocess:preprocessType,promise:promiseType,record:recordType,set:setType,strictObject:strictObjectType,string:stringType,symbol:symbolType,transformer:effectsType,tuple:tupleType,undefined:undefinedType,union:unionType,unknown:unknownType,void:voidType,NEVER,ZodIssueCode,quotelessJson,ZodError}),define_process_env_default={};function createEnv(et){const o=et.runtimeEnvStrict??et.runtimeEnv??define_process_env_default;if(et.emptyStringAsUndefined??!1)for(const[Ct,St]of Object.entries(o))St===""&&delete o[Ct];if(!!et.skipValidation)return o;const nt=typeof et.client=="object"?et.client:{},ot=typeof et.server=="object"?et.server:{},it=typeof et.shared=="object"?et.shared:{},st=z.object(nt),at=z.object(ot),ct=z.object(it),lt=et.isServer??typeof window>"u",dt=st.merge(ct),ht=at.merge(ct).merge(st),mt=lt?ht.safeParse(o):dt.safeParse(o),ft=et.onValidationError??(Ct=>{throw console.error("❌ Invalid environment variables:",Ct.flatten().fieldErrors),new Error("Invalid environment variables")}),pt=et.onInvalidAccess??(Ct=>{throw new Error("❌ Attempted to access a server-side environment variable on the client")});if(mt.success===!1)return ft(mt.error);const gt=Ct=>et.clientPrefix?!Ct.startsWith(et.clientPrefix)&&!(Ct in ct.shape):!0,yt=Ct=>lt||!gt(Ct),bt=Ct=>Ct==="__esModule"||Ct==="$$typeof",xt=(et.extends??[]).reduce((Ct,St)=>Object.assign(Ct,St),{}),vt=Object.assign(mt.data,xt);return new Proxy(vt,{get(Ct,St){if(typeof St=="string"&&!bt(St))return yt(St)?Reflect.get(Ct,St):pt(St)}})}const __vite_import_meta_env__={BASE_URL:"/buddybook/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_WALLETCONNECT_PROJECT_ID:"1d93edc21291f98e3bed6ff7617ff539"},env=createEnv({clientPrefix:"VITE_",client:{VITE_WALLETCONNECT_PROJECT_ID:z.string().min(1)},runtimeEnv:__vite_import_meta_env__}),config=createConfig(defaultConfig({appName:"BuddyBook",walletConnectProjectId:env.VITE_WALLETCONNECT_PROJECT_ID,chains:[mainnet],transports:{[mainnet.id]:http()}})),queryClient=new QueryClient;createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(reactExports.StrictMode,{children:jsxRuntimeExports.jsx(WagmiProvider,{config,children:jsxRuntimeExports.jsx(QueryClientProvider,{client:queryClient,children:jsxRuntimeExports.jsx(ConnectKitProvider,{children:jsxRuntimeExports.jsx(LightNodeProvider,{options:WAKU_NODE_OPTIONS,children:jsxRuntimeExports.jsx(BrowserRouter,{children:jsxRuntimeExports.jsx(App,{})})})})})})}));export{isHex as A,BytesSizeMismatchError as B,dijkstraExports as C,EventEmitter$1 as E,HttpRequestError as H,InvalidAddressError as I,__vitePreload as _,stringToHex as a,bytesToHex$3 as b,concat$6 as c,commonjsGlobal as d,encodeAbiParameters as e,encodeFunctionData as f,getAugmentedNamespace as g,getDefaultExportFromCjs as h,isAddress as i,browserExports as j,keccak256$1 as k,tslib_es6$1 as l,buffer as m,numberToHex as n,allocUnsafe$h as o,BASES$1 as p,fromString$2 as q,detect as r,size$2 as s,toHex as t,__viteBrowserExternal$1 as u,BaseError$3 as v,getUrl as w,stringify$2 as x,decodeErrorResult as y,call as z}; +`},nt),ot}function remarkRehype(et,o){return et&&"run"in et?async function(tt,rt){const nt=toHast(tt,{file:rt,...o});await et.run(nt,rt)}:function(tt,rt){return toHast(tt,{file:rt,...et||o})}}function bail(et){if(et)throw et}var hasOwn=Object.prototype.hasOwnProperty,toStr=Object.prototype.toString,defineProperty=Object.defineProperty,gOPD=Object.getOwnPropertyDescriptor,isArray=function et(o){return typeof Array.isArray=="function"?Array.isArray(o):toStr.call(o)==="[object Array]"},isPlainObject$1=function et(o){if(!o||toStr.call(o)!=="[object Object]")return!1;var tt=hasOwn.call(o,"constructor"),rt=o.constructor&&o.constructor.prototype&&hasOwn.call(o.constructor.prototype,"isPrototypeOf");if(o.constructor&&!tt&&!rt)return!1;var nt;for(nt in o);return typeof nt>"u"||hasOwn.call(o,nt)},setProperty=function et(o,tt){defineProperty&&tt.name==="__proto__"?defineProperty(o,tt.name,{enumerable:!0,configurable:!0,value:tt.newValue,writable:!0}):o[tt.name]=tt.newValue},getProperty=function et(o,tt){if(tt==="__proto__")if(hasOwn.call(o,tt)){if(gOPD)return gOPD(o,tt).value}else return;return o[tt]},extend=function et(){var o,tt,rt,nt,ot,it,st=arguments[0],at=1,ct=arguments.length,lt=!1;for(typeof st=="boolean"&&(lt=st,st=arguments[1]||{},at=2),(st==null||typeof st!="object"&&typeof st!="function")&&(st={});atit.length;let at;st&&it.push(nt);try{at=et.apply(this,it)}catch(ct){const lt=ct;if(st&&tt)throw lt;return nt(lt)}st||(at&&at.then&&typeof at.then=="function"?at.then(ot,nt):at instanceof Error?nt(at):ot(at))}function nt(it,...st){tt||(tt=!0,o(it,...st))}function ot(it){nt(null,it)}}const minpath={basename,dirname,extname,join,sep:"/"};function basename(et,o){if(o!==void 0&&typeof o!="string")throw new TypeError('"ext" argument must be a string');assertPath$1(et);let tt=0,rt=-1,nt=et.length,ot;if(o===void 0||o.length===0||o.length>et.length){for(;nt--;)if(et.codePointAt(nt)===47){if(ot){tt=nt+1;break}}else rt<0&&(ot=!0,rt=nt+1);return rt<0?"":et.slice(tt,rt)}if(o===et)return"";let it=-1,st=o.length-1;for(;nt--;)if(et.codePointAt(nt)===47){if(ot){tt=nt+1;break}}else it<0&&(ot=!0,it=nt+1),st>-1&&(et.codePointAt(nt)===o.codePointAt(st--)?st<0&&(rt=nt):(st=-1,rt=it));return tt===rt?rt=it:rt<0&&(rt=et.length),et.slice(tt,rt)}function dirname(et){if(assertPath$1(et),et.length===0)return".";let o=-1,tt=et.length,rt;for(;--tt;)if(et.codePointAt(tt)===47){if(rt){o=tt;break}}else rt||(rt=!0);return o<0?et.codePointAt(0)===47?"/":".":o===1&&et.codePointAt(0)===47?"//":et.slice(0,o)}function extname(et){assertPath$1(et);let o=et.length,tt=-1,rt=0,nt=-1,ot=0,it;for(;o--;){const st=et.codePointAt(o);if(st===47){if(it){rt=o+1;break}continue}tt<0&&(it=!0,tt=o+1),st===46?nt<0?nt=o:ot!==1&&(ot=1):nt>-1&&(ot=-1)}return nt<0||tt<0||ot===0||ot===1&&nt===tt-1&&nt===rt+1?"":et.slice(nt,tt)}function join(...et){let o=-1,tt;for(;++o0&&et.codePointAt(et.length-1)===47&&(tt+="/"),o?"/"+tt:tt}function normalizeString(et,o){let tt="",rt=0,nt=-1,ot=0,it=-1,st,at;for(;++it<=et.length;){if(it2){if(at=tt.lastIndexOf("/"),at!==tt.length-1){at<0?(tt="",rt=0):(tt=tt.slice(0,at),rt=tt.length-1-tt.lastIndexOf("/")),nt=it,ot=0;continue}}else if(tt.length>0){tt="",rt=0,nt=it,ot=0;continue}}o&&(tt=tt.length>0?tt+"/..":"..",rt=2)}else tt.length>0?tt+="/"+et.slice(nt+1,it):tt=et.slice(nt+1,it),rt=it-nt-1;nt=it,ot=0}else st===46&&ot>-1?ot++:ot=-1}return tt}function assertPath$1(et){if(typeof et!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(et))}const minproc={cwd};function cwd(){return"/"}function isUrl(et){return!!(et!==null&&typeof et=="object"&&"href"in et&&et.href&&"protocol"in et&&et.protocol&&et.auth===void 0)}function urlToPath(et){if(typeof et=="string")et=new URL(et);else if(!isUrl(et)){const o=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+et+"`");throw o.code="ERR_INVALID_ARG_TYPE",o}if(et.protocol!=="file:"){const o=new TypeError("The URL must be of scheme file");throw o.code="ERR_INVALID_URL_SCHEME",o}return getPathFromURLPosix(et)}function getPathFromURLPosix(et){if(et.hostname!==""){const rt=new TypeError('File URL host must be "localhost" or empty on darwin');throw rt.code="ERR_INVALID_FILE_URL_HOST",rt}const o=et.pathname;let tt=-1;for(;++tt0){let[mt,...ft]=lt;const pt=rt[ht][1];isPlainObject(pt)&&isPlainObject(mt)&&(mt=extend$1(!0,pt,mt)),rt[ht]=[ct,mt,...ft]}}}}const unified=new Processor().freeze();function assertParser(et,o){if(typeof o!="function")throw new TypeError("Cannot `"+et+"` without `parser`")}function assertCompiler(et,o){if(typeof o!="function")throw new TypeError("Cannot `"+et+"` without `compiler`")}function assertUnfrozen(et,o){if(o)throw new Error("Cannot call `"+et+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function assertNode(et){if(!isPlainObject(et)||typeof et.type!="string")throw new TypeError("Expected node, got `"+et+"`")}function assertDone(et,o,tt){if(!tt)throw new Error("`"+et+"` finished async. Use `"+o+"` instead")}function vfile(et){return looksLikeAVFile(et)?et:new VFile(et)}function looksLikeAVFile(et){return!!(et&&typeof et=="object"&&"message"in et&&"messages"in et)}function looksLikeAValue(et){return typeof et=="string"||isUint8Array(et)}function isUint8Array(et){return!!(et&&typeof et=="object"&&"byteLength"in et&&"byteOffset"in et)}const changelog="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",emptyPlugins=[],emptyRemarkRehypeOptions={allowDangerousHtml:!0},safeProtocol=/^(https?|ircs?|mailto|xmpp)$/i,deprecations=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Markdown(et){const o=et.allowedElements,tt=et.allowElement,rt=et.children||"",nt=et.className,ot=et.components,it=et.disallowedElements,st=et.rehypePlugins||emptyPlugins,at=et.remarkPlugins||emptyPlugins,ct=et.remarkRehypeOptions?{...et.remarkRehypeOptions,...emptyRemarkRehypeOptions}:emptyRemarkRehypeOptions,lt=et.skipHtml,dt=et.unwrapDisallowed,ht=et.urlTransform||defaultUrlTransform,mt=unified().use(remarkParse).use(at).use(remarkRehype,ct).use(st),ft=new VFile;typeof rt=="string"&&(ft.value=rt);for(const bt of deprecations)Object.hasOwn(et,bt.from)&&(""+bt.from+(bt.to?"use `"+bt.to+"` instead":"remove it")+changelog+bt.id,void 0);const pt=mt.parse(ft);let yt=mt.runSync(pt,ft);return nt&&(yt={type:"element",tagName:"div",properties:{className:nt},children:yt.type==="root"?yt.children:[yt]}),visit(yt,gt),toJsxRuntime(yt,{Fragment:jsxRuntimeExports.Fragment,components:ot,ignoreInvalidStyle:!0,jsx:jsxRuntimeExports.jsx,jsxs:jsxRuntimeExports.jsxs,passKeys:!0,passNode:!0});function gt(bt,xt,vt){if(bt.type==="raw"&&vt&&typeof xt=="number")return lt?vt.children.splice(xt,1):vt.children[xt]={type:"text",value:bt.value},xt;if(bt.type==="element"){let Et;for(Et in urlAttributes)if(Object.hasOwn(urlAttributes,Et)&&Object.hasOwn(bt.properties,Et)){const Ct=bt.properties[Et],St=urlAttributes[Et];(St===null||St.includes(bt.tagName))&&(bt.properties[Et]=ht(String(Ct||""),Et,bt))}}if(bt.type==="element"){let Et=o?!o.includes(bt.tagName):it?it.includes(bt.tagName):!1;if(!Et&&tt&&typeof xt=="number"&&(Et=!tt(bt,xt,vt)),Et&&vt&&typeof xt=="number")return dt&&bt.children?vt.children.splice(xt,1,...bt.children):vt.children.splice(xt,1),xt}}}function defaultUrlTransform(et){const o=et.indexOf(":"),tt=et.indexOf("?"),rt=et.indexOf("#"),nt=et.indexOf("/");return o<0||nt>-1&&o>nt||tt>-1&&o>tt||rt>-1&&o>rt||safeProtocol.test(et.slice(0,o))?et:""}const PrivacyPolicyOptIn=({onOptIn:et})=>{const[o,tt]=reactExports.useState(!1);return jsxRuntimeExports.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:[jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-md",children:[jsxRuntimeExports.jsx(CardHeader,{className:"space-y-2",children:jsxRuntimeExports.jsx(CardTitle,{className:"text-xl sm:text-2xl",children:"Privacy Policy & Data Collection"})}),jsxRuntimeExports.jsx(CardContent,{children:jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[jsxRuntimeExports.jsx("p",{className:"text-sm sm:text-base text-muted-foreground",children:"We collect data to improve our services. This data is anonymous and helps us understand how our application is used. You can opt-in or opt-out of this data collection."}),jsxRuntimeExports.jsx(Button,{variant:"link",onClick:()=>tt(!0),className:"px-0 text-sm sm:text-base",children:"View Full Privacy Policy"})]})}),jsxRuntimeExports.jsxs(CardFooter,{className:"flex flex-col sm:flex-row gap-3 sm:gap-4",children:[jsxRuntimeExports.jsx(Button,{variant:"outline",onClick:()=>et(!1),className:"w-full sm:w-auto",children:"Opt Out"}),jsxRuntimeExports.jsx(Button,{onClick:()=>et(!0),className:"w-full sm:w-auto",children:"Opt In"})]})]}),jsxRuntimeExports.jsx(Dialog,{open:o,onOpenChange:tt,children:jsxRuntimeExports.jsxs(DialogContent,{className:"w-[95vw] max-w-4xl max-h-[90vh] p-4 sm:p-6",children:[jsxRuntimeExports.jsx(DialogHeader,{children:jsxRuntimeExports.jsx(DialogTitle,{className:"text-xl sm:text-2xl",children:"Privacy Policy"})}),jsxRuntimeExports.jsx(ScrollArea,{className:"mt-4 h-[50vh] sm:h-[60vh]",children:jsxRuntimeExports.jsx(DialogDescription,{className:"space-y-4",children:jsxRuntimeExports.jsx(Markdown,{className:"prose dark:prose-invert max-w-none text-sm sm:text-base",children:privacyPolicy})})})]})})]})},PrivacyPolicyPage=()=>{const[et,o]=reactExports.useState(!1);reactExports.useEffect(()=>{const rt=localStorage.getItem("privacyPolicyOptIn");rt!==null&&o(rt==="true")},[]);const tt=()=>{const rt=!et;o(rt),localStorage.setItem("privacyPolicyOptIn",rt.toString())};return jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-4xl mx-auto p-4 sm:p-6",children:[jsxRuntimeExports.jsx(CardHeader,{className:"space-y-2",children:jsxRuntimeExports.jsx(CardTitle,{className:"text-2xl sm:text-3xl",children:"Privacy Policy Settings"})}),jsxRuntimeExports.jsx(CardContent,{children:jsxRuntimeExports.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[jsxRuntimeExports.jsx("p",{className:"text-sm sm:text-base text-muted-foreground",children:"We collect data to improve our services. This data is anonymous and helps us understand how our application is used."}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[jsxRuntimeExports.jsxs("p",{className:"font-semibold",children:["Current status: ",et?"Opted In":"Opted Out"]}),jsxRuntimeExports.jsx(Button,{onClick:tt,className:"w-full sm:w-auto",children:et?"Opt Out":"Opt In"})]})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"text-lg sm:text-xl font-semibold mb-4",children:"Privacy Policy"}),jsxRuntimeExports.jsx(ScrollArea,{className:"h-[50vh] sm:h-[60vh] border rounded-md p-2 sm:p-4",children:jsxRuntimeExports.jsx(Markdown,{className:"prose dark:prose-invert max-w-none text-sm sm:text-base",children:privacyPolicy})})]})]})})]})},SignSharedChain=({chainsData:et,onChainUpdate:o,isLoading:tt})=>{const{chainUUID:rt,blockUUID:nt}=useParams(),[ot,it]=reactExports.useState(null),st=useNavigate();return reactExports.useEffect(()=>{const at=et.find(ct=>ct.chainUUID===rt&&ct.blockUUID===nt);at&&it(at)},[et,rt,nt]),tt&&!ot?jsxRuntimeExports.jsx(Card,{className:"w-full max-w-md mx-auto",children:jsxRuntimeExports.jsxs(CardContent,{className:"flex flex-col items-center justify-center py-8 space-y-4",children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Looking for chain..."})]})}):ot?jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-2xl mx-auto",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsx(CardTitle,{children:"Sign Shared Chain"})}),jsxRuntimeExports.jsxs(CardContent,{children:[jsxRuntimeExports.jsx("h2",{className:"text-xl font-semibold mb-2",children:ot.title}),jsxRuntimeExports.jsx("p",{className:"mb-4",children:ot.description}),jsxRuntimeExports.jsx(SignChain,{block:ot,chainsData:et,onSuccess:o})]})]}):jsxRuntimeExports.jsxs(Card,{className:"w-full max-w-md mx-auto",children:[jsxRuntimeExports.jsx(CardHeader,{children:jsxRuntimeExports.jsx(CardTitle,{children:"Chain Not Found"})}),jsxRuntimeExports.jsxs(CardContent,{children:[jsxRuntimeExports.jsx("p",{className:"mb-4",children:"The requested chain or block could not be found."}),jsxRuntimeExports.jsx(Button,{onClick:()=>st("/view"),children:"View All Chains"})]})]})};function App(){const[et,o]=reactExports.useState(!1),[tt,rt]=reactExports.useState([]),{isLoading:nt,error:ot,node:it}=useWaku(),[st,at]=reactExports.useState({filter:"in-progress",store:"in-progress"}),[ct,lt]=reactExports.useState(null),[dt,ht]=reactExports.useState(!0);reactExports.useEffect(()=>{const yt=localStorage.getItem("telemetryOptIn");yt!==null&<(yt==="true")},[]),reactExports.useEffect(()=>{nt||!it||it.libp2p.getConnections().length===0||tt.length>0||et||(o(!0),ft())},[it,nt,st]);const mt=yt=>{lt(yt),localStorage.setItem("telemetryOptIn",yt.toString())};if(nt)return jsxRuntimeExports.jsx("div",{className:"min-h-screen bg-background text-foreground",children:jsxRuntimeExports.jsxs("div",{className:"container mx-auto px-4 py-16 flex flex-col items-center justify-center space-y-4",children:[jsxRuntimeExports.jsx("h1",{className:"text-2xl md:text-4xl font-bold",children:"BuddyBook"}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[jsxRuntimeExports.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin"}),jsxRuntimeExports.jsx("p",{className:"text-muted-foreground",children:"Connecting to Waku's decentralized network..."})]})]})});const ft=async()=>{console.log("Starting message listening");try{at(gt=>({...gt,store:"in-progress"})),ht(!0);const yt=getMessagesFromStore(it);for await(const gt of yt)rt(bt=>bt.some(vt=>vt.blockUUID===gt.blockUUID)?bt:[...bt,gt]);at(gt=>({...gt,store:"success"}))}catch(yt){console.error("Error fetching messages from store:",yt),at(gt=>({...gt,store:"error"}))}finally{ht(!1)}try{at(yt=>({...yt,filter:"in-progress"})),await subscribeToFilter(it,yt=>{pt(yt)}),at(yt=>({...yt,filter:"success"}))}catch(yt){console.error("Error subscribing to filter:",yt),at(gt=>({...gt,filter:"error"}))}};if(ot)return console.error("Waku error:",ot),jsxRuntimeExports.jsxs("div",{className:"min-h-screen bg-background text-foreground flex flex-col justify-center items-center",children:[jsxRuntimeExports.jsx("p",{className:"text-red-500",children:"Error connecting to Waku network"}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:ot.toString()})]});const pt=yt=>{rt(gt=>gt.some(xt=>xt.blockUUID===yt.blockUUID)?gt:[...gt,yt])};return ct===null?jsxRuntimeExports.jsx(PrivacyPolicyOptIn,{onOptIn:mt}):jsxRuntimeExports.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[jsxRuntimeExports.jsx(Header,{wakuStatus:st}),jsxRuntimeExports.jsx("main",{className:"container mx-auto px-4 py-4 md:py-8 max-w-7xl",children:jsxRuntimeExports.jsxs(Routes,{children:[jsxRuntimeExports.jsx(Route,{path:"/create",element:jsxRuntimeExports.jsx(ChainCreationForm,{})}),jsxRuntimeExports.jsx(Route,{path:"/view",element:jsxRuntimeExports.jsx(ChainList,{chainsData:tt,onChainUpdate:pt,isLoading:dt})}),jsxRuntimeExports.jsx(Route,{path:"/",element:jsxRuntimeExports.jsx(Home,{})}),jsxRuntimeExports.jsx(Route,{path:"/sign/:chainUUID/:blockUUID",element:jsxRuntimeExports.jsx(SignSharedChain,{chainsData:tt,onChainUpdate:pt,isLoading:dt})}),jsxRuntimeExports.jsx(Route,{path:"/telemetry",element:jsxRuntimeExports.jsx(PrivacyPolicyPage,{})}),jsxRuntimeExports.jsx(Route,{path:"*",element:jsxRuntimeExports.jsx(Navigate,{to:"/",replace:!0})})]})})]})}const Home=()=>jsxRuntimeExports.jsxs("div",{className:"space-y-4 md:space-y-6 p-4 md:p-6",children:[jsxRuntimeExports.jsx("h1",{className:"text-2xl md:text-4xl font-bold",children:"BuddyBook"}),jsxRuntimeExports.jsxs("div",{className:"w-full max-w-sm mx-auto p-4 md:p-6 bg-card rounded-lg shadow-md",children:[jsxRuntimeExports.jsx(Link,{to:"/create",children:jsxRuntimeExports.jsx(Button,{className:"w-full mb-4",children:"Create New Chain"})}),jsxRuntimeExports.jsx("p",{className:"text-sm md:text-base text-muted-foreground",children:"Click the button above to start creating a new chain."})]}),jsxRuntimeExports.jsx("p",{className:"text-xs md:text-sm text-muted-foreground text-center",children:"Welcome to BuddyBook - Create and share your chains!"})]}),projectId="1d93edc21291f98e3bed6ff7617ff539",config=createConfig(defaultConfig({appName:"BuddyBook",walletConnectProjectId:projectId,chains:[mainnet],transports:{[mainnet.id]:http()}})),WAKU_NODE_OPTIONS={defaultBootstrap:!0,libp2p:{addresses:{listen:[]},connectionManager:{minConnections:2}},protocols:[Protocols.Store,Protocols.Filter,Protocols.LightPush]};typeof globalThis>"u"&&(window.global=window);typeof buffer$2.Buffer>"u"&&(window.Buffer=buffer$2.Buffer);const queryClient=new QueryClient;createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(reactExports.StrictMode,{children:jsxRuntimeExports.jsx(WagmiProvider,{config,children:jsxRuntimeExports.jsx(QueryClientProvider,{client:queryClient,children:jsxRuntimeExports.jsx(ConnectKitProvider,{children:jsxRuntimeExports.jsx(LightNodeProvider,{options:WAKU_NODE_OPTIONS,children:jsxRuntimeExports.jsx(BrowserRouter,{basename:"/",children:jsxRuntimeExports.jsx(App,{})})})})})})}));export{isHex as A,BytesSizeMismatchError as B,dijkstraExports as C,EventEmitter$1 as E,HttpRequestError as H,InvalidAddressError as I,__vitePreload as _,stringToHex as a,bytesToHex$3 as b,concat$6 as c,commonjsGlobal as d,encodeAbiParameters as e,encodeFunctionData as f,getAugmentedNamespace as g,getDefaultExportFromCjs as h,isAddress as i,browserExports as j,keccak256$1 as k,tslib_es6$1 as l,buffer$2 as m,numberToHex as n,allocUnsafe$h as o,BASES$1 as p,fromString$2 as q,detect as r,size$2 as s,toHex as t,__viteBrowserExternal$1 as u,BaseError$3 as v,getUrl as w,stringify$2 as x,decodeErrorResult as y,call as z}; diff --git a/buddybook/assets/index.es-BvE4YOl7.js b/buddybook/assets/index.es-BvE4YOl7.js deleted file mode 100644 index 18fef38..0000000 --- a/buddybook/assets/index.es-BvE4YOl7.js +++ /dev/null @@ -1,70 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Vk_Kr0Nw.js","assets/index-CLqSQ1yP.js","assets/index-Dt_CGZqf.css"])))=>i.map(i=>d[i]); -import{g as Tv,o as U4,p as $4,d as ji,q as Ar,r as z4,h as S0,_ as j4}from"./index-CLqSQ1yP.js";import{e as Hi,J as I0}from"./events-CHFTlyqt.js";import{r as M0,i as xh}from"./inherits_browser-Dprisln6.js";var xe={};/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var Vl=function(r,e){return Vl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},Vl(r,e)};function k4(r,e){Vl(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var Gl=function(){return Gl=Object.assign||function(e){for(var t,i=1,n=arguments.length;i=0;u--)(f=r[u])&&(a=(n<3?f(a):n>3?f(e,t,a):f(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a}function V4(r,e){return function(t,i){e(t,i,r)}}function G4(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function W4(r,e,t,i){function n(a){return a instanceof t?a:new t(function(f){f(a)})}return new(t||(t=Promise))(function(a,f){function u(y){try{p(i.next(y))}catch(A){f(A)}}function b(y){try{p(i.throw(y))}catch(A){f(A)}}function p(y){y.done?a(y.value):n(y.value).then(u,b)}p((i=i.apply(r,e||[])).next())})}function J4(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,f;return f={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function u(p){return function(y){return b([p,y])}}function b(p){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(a=p[0]&2?n.return:p[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,p[1])).done)return a;switch(n=0,a&&(p=[p[0]&2,a.value]),p[0]){case 0:case 1:a=p;break;case 4:return t.label++,{value:p[1],done:!1};case 5:t.label++,n=p[1],p=[0];continue;case 7:p=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(p[0]===6||p[0]===2)){t=0;continue}if(p[0]===3&&(!a||p[1]>a[0]&&p[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Dv(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,a=[],f;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(u){f={error:u}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(f)throw f.error}}return a}function X4(){for(var r=[],e=0;e1||u(R,O)})})}function u(R,O){try{b(i[R](O))}catch(N){A(a[0][3],N)}}function b(R){R.value instanceof lc?Promise.resolve(R.value.v).then(p,y):A(a[0][2],R)}function p(R){u("next",R)}function y(R){u("throw",R)}function A(R,O){R(O),a.shift(),a.length&&u(a[0][0],a[0][1])}}function t8(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,a){e[n]=r[n]?function(f){return(t=!t)?{value:lc(r[n](f)),done:n==="return"}:a?a(f):f}:a}}function r8(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Wl=="function"?Wl(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(a){t[a]=r[a]&&function(f){return new Promise(function(u,b){f=r[a](f),n(u,b,f.done,f.value)})}}function n(a,f,u,b){Promise.resolve(b).then(function(p){a({value:p,done:u})},f)}}function i8(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function n8(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function s8(r){return r&&r.__esModule?r:{default:r}}function a8(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function o8(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}const c8=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Gl},__asyncDelegator:t8,__asyncGenerator:e8,__asyncValues:r8,__await:lc,__awaiter:W4,__classPrivateFieldGet:a8,__classPrivateFieldSet:o8,__createBinding:Y4,__decorate:K4,__exportStar:Q4,__extends:k4,__generator:J4,__importDefault:s8,__importStar:n8,__makeTemplateObject:i8,__metadata:G4,__param:V4,__read:Dv,__rest:H4,__spread:X4,__spreadArrays:Z4,__values:Wl},Symbol.toStringTag,{value:"Module"})),Sh=Tv(c8);var sl={},ko={},s1;function f8(){if(s1)return ko;s1=1,Object.defineProperty(ko,"__esModule",{value:!0}),ko.delay=void 0;function r(e){return new Promise(t=>{setTimeout(()=>{t(!0)},e)})}return ko.delay=r,ko}var ra={},al={},ia={},a1;function h8(){return a1||(a1=1,Object.defineProperty(ia,"__esModule",{value:!0}),ia.ONE_THOUSAND=ia.ONE_HUNDRED=void 0,ia.ONE_HUNDRED=100,ia.ONE_THOUSAND=1e3),ia}var ol={},o1;function u8(){return o1||(o1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ONE_YEAR=r.FOUR_WEEKS=r.THREE_WEEKS=r.TWO_WEEKS=r.ONE_WEEK=r.THIRTY_DAYS=r.SEVEN_DAYS=r.FIVE_DAYS=r.THREE_DAYS=r.ONE_DAY=r.TWENTY_FOUR_HOURS=r.TWELVE_HOURS=r.SIX_HOURS=r.THREE_HOURS=r.ONE_HOUR=r.SIXTY_MINUTES=r.THIRTY_MINUTES=r.TEN_MINUTES=r.FIVE_MINUTES=r.ONE_MINUTE=r.SIXTY_SECONDS=r.THIRTY_SECONDS=r.TEN_SECONDS=r.FIVE_SECONDS=r.ONE_SECOND=void 0,r.ONE_SECOND=1,r.FIVE_SECONDS=5,r.TEN_SECONDS=10,r.THIRTY_SECONDS=30,r.SIXTY_SECONDS=60,r.ONE_MINUTE=r.SIXTY_SECONDS,r.FIVE_MINUTES=r.ONE_MINUTE*5,r.TEN_MINUTES=r.ONE_MINUTE*10,r.THIRTY_MINUTES=r.ONE_MINUTE*30,r.SIXTY_MINUTES=r.ONE_MINUTE*60,r.ONE_HOUR=r.SIXTY_MINUTES,r.THREE_HOURS=r.ONE_HOUR*3,r.SIX_HOURS=r.ONE_HOUR*6,r.TWELVE_HOURS=r.ONE_HOUR*12,r.TWENTY_FOUR_HOURS=r.ONE_HOUR*24,r.ONE_DAY=r.TWENTY_FOUR_HOURS,r.THREE_DAYS=r.ONE_DAY*3,r.FIVE_DAYS=r.ONE_DAY*5,r.SEVEN_DAYS=r.ONE_DAY*7,r.THIRTY_DAYS=r.ONE_DAY*30,r.ONE_WEEK=r.SEVEN_DAYS,r.TWO_WEEKS=r.ONE_WEEK*2,r.THREE_WEEKS=r.ONE_WEEK*3,r.FOUR_WEEKS=r.ONE_WEEK*4,r.ONE_YEAR=r.ONE_DAY*365}(ol)),ol}var c1;function Fv(){return c1||(c1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Sh;e.__exportStar(h8(),r),e.__exportStar(u8(),r)}(al)),al}var f1;function l8(){if(f1)return ra;f1=1,Object.defineProperty(ra,"__esModule",{value:!0}),ra.fromMiliseconds=ra.toMiliseconds=void 0;const r=Fv();function e(i){return i*r.ONE_THOUSAND}ra.toMiliseconds=e;function t(i){return Math.floor(i/r.ONE_THOUSAND)}return ra.fromMiliseconds=t,ra}var h1;function d8(){return h1||(h1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Sh;e.__exportStar(f8(),r),e.__exportStar(l8(),r)}(sl)),sl}var Ha={},u1;function p8(){if(u1)return Ha;u1=1,Object.defineProperty(Ha,"__esModule",{value:!0}),Ha.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(t){if(this.timestamps.has(t))throw new Error(`Watch already started for label: ${t}`);this.timestamps.set(t,{started:Date.now()})}stop(t){const i=this.get(t);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${t}`);const n=Date.now()-i.started;this.timestamps.set(t,{started:i.started,elapsed:n})}get(t){const i=this.timestamps.get(t);if(typeof i>"u")throw new Error(`No timestamp found for label: ${t}`);return i}elapsed(t){const i=this.get(t);return i.elapsed||Date.now()-i.started}}return Ha.Watch=r,Ha.default=r,Ha}var cl={},Ho={},l1;function g8(){if(l1)return Ho;l1=1,Object.defineProperty(Ho,"__esModule",{value:!0}),Ho.IWatch=void 0;class r{}return Ho.IWatch=r,Ho}var d1;function v8(){return d1||(d1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),Sh.__exportStar(g8(),r)}(cl)),cl}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Sh;e.__exportStar(d8(),r),e.__exportStar(p8(),r),e.__exportStar(v8(),r),e.__exportStar(Fv(),r)})(xe);var Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.getLocalStorage=Vt.getLocalStorageOrThrow=Vt.getCrypto=Vt.getCryptoOrThrow=Bv=Vt.getLocation=Vt.getLocationOrThrow=P0=Vt.getNavigator=Vt.getNavigatorOrThrow=Ih=Vt.getDocument=Vt.getDocumentOrThrow=Vt.getFromWindowOrThrow=Vt.getFromWindow=void 0;function ma(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Vt.getFromWindow=ma;function co(r){const e=ma(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Vt.getFromWindowOrThrow=co;function b8(){return co("document")}Vt.getDocumentOrThrow=b8;function m8(){return ma("document")}var Ih=Vt.getDocument=m8;function y8(){return co("navigator")}Vt.getNavigatorOrThrow=y8;function w8(){return ma("navigator")}var P0=Vt.getNavigator=w8;function _8(){return co("location")}Vt.getLocationOrThrow=_8;function A8(){return ma("location")}var Bv=Vt.getLocation=A8;function E8(){return co("crypto")}Vt.getCryptoOrThrow=E8;function x8(){return ma("crypto")}Vt.getCrypto=x8;function S8(){return co("localStorage")}Vt.getLocalStorageOrThrow=S8;function I8(){return ma("localStorage")}Vt.getLocalStorage=I8;var O0={};Object.defineProperty(O0,"__esModule",{value:!0});var qv=O0.getWindowMetadata=void 0;const p1=Vt;function M8(){let r,e;try{r=p1.getDocumentOrThrow(),e=p1.getLocationOrThrow()}catch{return null}function t(){const A=r.getElementsByTagName("link"),R=[];for(let O=0;O-1){const W=N.getAttribute("href");if(W)if(W.toLowerCase().indexOf("https:")===-1&&W.toLowerCase().indexOf("http:")===-1&&W.indexOf("//")!==0){let Q=e.protocol+"//"+e.host;if(W.indexOf("/")===0)Q+=W;else{const j=e.pathname.split("/");j.pop();const Y=j.join("/");Q+=Y+"/"+W}R.push(Q)}else if(W.indexOf("//")===0){const Q=e.protocol+W;R.push(Q)}else R.push(W)}}return R}function i(...A){const R=r.getElementsByTagName("meta");for(let O=0;ON.getAttribute(W)).filter(W=>W?A.includes(W):!1);if(K.length&&K){const W=N.getAttribute("content");if(W)return W}}return""}function n(){let A=i("name","og:site_name","og:title","twitter:title");return A||(A=r.title),A}function a(){return i("description","og:description","twitter:description","keywords")}const f=n(),u=a(),b=e.origin,p=t();return{description:u,url:b,icons:p,name:f}}qv=O0.getWindowMetadata=M8;var dc={},P8=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Lv="%[a-f0-9]{2}",g1=new RegExp("("+Lv+")|([^%]+?)","gi"),v1=new RegExp("("+Lv+")+","gi");function Jl(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],Jl(t),Jl(i))}function O8(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(g1)||[],t=1;t{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];const t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]},T8=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),a=0;aj==null,f=Symbol("encodeFragmentIdentifier");function u(j){switch(j.arrayFormat){case"index":return Y=>(U,k)=>{const G=U.length;return k===void 0||j.skipNull&&k===null||j.skipEmptyString&&k===""?U:k===null?[...U,[y(Y,j),"[",G,"]"].join("")]:[...U,[y(Y,j),"[",y(G,j),"]=",y(k,j)].join("")]};case"bracket":return Y=>(U,k)=>k===void 0||j.skipNull&&k===null||j.skipEmptyString&&k===""?U:k===null?[...U,[y(Y,j),"[]"].join("")]:[...U,[y(Y,j),"[]=",y(k,j)].join("")];case"colon-list-separator":return Y=>(U,k)=>k===void 0||j.skipNull&&k===null||j.skipEmptyString&&k===""?U:k===null?[...U,[y(Y,j),":list="].join("")]:[...U,[y(Y,j),":list=",y(k,j)].join("")];case"comma":case"separator":case"bracket-separator":{const Y=j.arrayFormat==="bracket-separator"?"[]=":"=";return U=>(k,G)=>G===void 0||j.skipNull&&G===null||j.skipEmptyString&&G===""?k:(G=G===null?"":G,k.length===0?[[y(U,j),Y,y(G,j)].join("")]:[[k,y(G,j)].join(j.arrayFormatSeparator)])}default:return Y=>(U,k)=>k===void 0||j.skipNull&&k===null||j.skipEmptyString&&k===""?U:k===null?[...U,y(Y,j)]:[...U,[y(Y,j),"=",y(k,j)].join("")]}}function b(j){let Y;switch(j.arrayFormat){case"index":return(U,k,G)=>{if(Y=/\[(\d*)\]$/.exec(U),U=U.replace(/\[\d*\]$/,""),!Y){G[U]=k;return}G[U]===void 0&&(G[U]={}),G[U][Y[1]]=k};case"bracket":return(U,k,G)=>{if(Y=/(\[\])$/.exec(U),U=U.replace(/\[\]$/,""),!Y){G[U]=k;return}if(G[U]===void 0){G[U]=[k];return}G[U]=[].concat(G[U],k)};case"colon-list-separator":return(U,k,G)=>{if(Y=/(:list)$/.exec(U),U=U.replace(/:list$/,""),!Y){G[U]=k;return}if(G[U]===void 0){G[U]=[k];return}G[U]=[].concat(G[U],k)};case"comma":case"separator":return(U,k,G)=>{const x=typeof k=="string"&&k.includes(j.arrayFormatSeparator),B=typeof k=="string"&&!x&&A(k,j).includes(j.arrayFormatSeparator);k=B?A(k,j):k;const ae=x||B?k.split(j.arrayFormatSeparator).map(le=>A(le,j)):k===null?k:A(k,j);G[U]=ae};case"bracket-separator":return(U,k,G)=>{const x=/(\[\])$/.test(U);if(U=U.replace(/\[\]$/,""),!x){G[U]=k&&A(k,j);return}const B=k===null?[]:k.split(j.arrayFormatSeparator).map(ae=>A(ae,j));if(G[U]===void 0){G[U]=B;return}G[U]=[].concat(G[U],B)};default:return(U,k,G)=>{if(G[U]===void 0){G[U]=k;return}G[U]=[].concat(G[U],k)}}}function p(j){if(typeof j!="string"||j.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function y(j,Y){return Y.encode?Y.strict?e(j):encodeURIComponent(j):j}function A(j,Y){return Y.decode?t(j):j}function R(j){return Array.isArray(j)?j.sort():typeof j=="object"?R(Object.keys(j)).sort((Y,U)=>Number(Y)-Number(U)).map(Y=>j[Y]):j}function O(j){const Y=j.indexOf("#");return Y!==-1&&(j=j.slice(0,Y)),j}function N(j){let Y="";const U=j.indexOf("#");return U!==-1&&(Y=j.slice(U)),Y}function K(j){j=O(j);const Y=j.indexOf("?");return Y===-1?"":j.slice(Y+1)}function W(j,Y){return Y.parseNumbers&&!Number.isNaN(Number(j))&&typeof j=="string"&&j.trim()!==""?j=Number(j):Y.parseBooleans&&j!==null&&(j.toLowerCase()==="true"||j.toLowerCase()==="false")&&(j=j.toLowerCase()==="true"),j}function Q(j,Y){Y=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},Y),p(Y.arrayFormatSeparator);const U=b(Y),k=Object.create(null);if(typeof j!="string"||(j=j.trim().replace(/^[?#&]/,""),!j))return k;for(const G of j.split("&")){if(G==="")continue;let[x,B]=i(Y.decode?G.replace(/\+/g," "):G,"=");B=B===void 0?null:["comma","separator","bracket-separator"].includes(Y.arrayFormat)?B:A(B,Y),U(A(x,Y),B,k)}for(const G of Object.keys(k)){const x=k[G];if(typeof x=="object"&&x!==null)for(const B of Object.keys(x))x[B]=W(x[B],Y);else k[G]=W(x,Y)}return Y.sort===!1?k:(Y.sort===!0?Object.keys(k).sort():Object.keys(k).sort(Y.sort)).reduce((G,x)=>{const B=k[x];return B&&typeof B=="object"&&!Array.isArray(B)?G[x]=R(B):G[x]=B,G},Object.create(null))}r.extract=K,r.parse=Q,r.stringify=(j,Y)=>{if(!j)return"";Y=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},Y),p(Y.arrayFormatSeparator);const U=B=>Y.skipNull&&a(j[B])||Y.skipEmptyString&&j[B]==="",k=u(Y),G={};for(const B of Object.keys(j))U(B)||(G[B]=j[B]);const x=Object.keys(G);return Y.sort!==!1&&x.sort(Y.sort),x.map(B=>{const ae=j[B];return ae===void 0?"":ae===null?y(B,Y):Array.isArray(ae)?ae.length===0&&Y.arrayFormat==="bracket-separator"?y(B,Y)+"[]":ae.reduce(k(B),[]).join("&"):y(B,Y)+"="+y(ae,Y)}).filter(B=>B.length>0).join("&")},r.parseUrl=(j,Y)=>{Y=Object.assign({decode:!0},Y);const[U,k]=i(j,"#");return Object.assign({url:U.split("?")[0]||"",query:Q(K(j),Y)},Y&&Y.parseFragmentIdentifier&&k?{fragmentIdentifier:A(k,Y)}:{})},r.stringifyUrl=(j,Y)=>{Y=Object.assign({encode:!0,strict:!0,[f]:!0},Y);const U=O(j.url).split("?")[0]||"",k=r.extract(j.url),G=r.parse(k,{sort:!1}),x=Object.assign(G,j.query);let B=r.stringify(x,Y);B&&(B=`?${B}`);let ae=N(j.url);return j.fragmentIdentifier&&(ae=`#${Y[f]?y(j.fragmentIdentifier,Y):j.fragmentIdentifier}`),`${U}${B}${ae}`},r.pick=(j,Y,U)=>{U=Object.assign({parseFragmentIdentifier:!0,[f]:!1},U);const{url:k,query:G,fragmentIdentifier:x}=r.parseUrl(j,U);return r.stringifyUrl({url:k,query:n(G,Y),fragmentIdentifier:x},U)},r.exclude=(j,Y,U)=>{const k=Array.isArray(Y)?G=>!Y.includes(G):(G,x)=>!Y(G,x);return r.pick(j,k,U)}})(dc);var R0={},Mh={},mt={},Uv={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});function e(u,b){var p=u>>>16&65535,y=u&65535,A=b>>>16&65535,R=b&65535;return y*R+(p*R+y*A<<16>>>0)|0}r.mul=Math.imul||e;function t(u,b){return u+b|0}r.add=t;function i(u,b){return u-b|0}r.sub=i;function n(u,b){return u<>>32-b}r.rotl=n;function a(u,b){return u<<32-b|u>>>b}r.rotr=a;function f(u){return typeof u=="number"&&isFinite(u)&&Math.floor(u)===u}r.isInteger=Number.isInteger||f,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(u){return r.isInteger(u)&&u>=-r.MAX_SAFE_INTEGER&&u<=r.MAX_SAFE_INTEGER}})(Uv);Object.defineProperty(mt,"__esModule",{value:!0});var $v=Uv;function D8(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}mt.readInt16BE=D8;function F8(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}mt.readUint16BE=F8;function B8(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}mt.readInt16LE=B8;function q8(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}mt.readUint16LE=q8;function zv(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}mt.writeUint16BE=zv;mt.writeInt16BE=zv;function jv(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}mt.writeUint16LE=jv;mt.writeInt16LE=jv;function Yl(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}mt.readInt32BE=Yl;function Ql(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}mt.readUint32BE=Ql;function Xl(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}mt.readInt32LE=Xl;function Zl(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}mt.readUint32LE=Zl;function ah(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}mt.writeUint32BE=ah;mt.writeInt32BE=ah;function oh(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}mt.writeUint32LE=oh;mt.writeInt32LE=oh;function L8(r,e){e===void 0&&(e=0);var t=Yl(r,e),i=Yl(r,e+4);return t*4294967296+i-(i>>31)*4294967296}mt.readInt64BE=L8;function U8(r,e){e===void 0&&(e=0);var t=Ql(r,e),i=Ql(r,e+4);return t*4294967296+i}mt.readUint64BE=U8;function $8(r,e){e===void 0&&(e=0);var t=Xl(r,e),i=Xl(r,e+4);return i*4294967296+t-(t>>31)*4294967296}mt.readInt64LE=$8;function z8(r,e){e===void 0&&(e=0);var t=Zl(r,e),i=Zl(r,e+4);return i*4294967296+t}mt.readUint64LE=z8;function kv(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),ah(r/4294967296>>>0,e,t),ah(r>>>0,e,t+4),e}mt.writeUint64BE=kv;mt.writeInt64BE=kv;function Hv(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),oh(r>>>0,e,t),oh(r/4294967296>>>0,e,t+4),e}mt.writeUint64LE=Hv;mt.writeInt64LE=Hv;function j8(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,a=r/8+t-1;a>=t;a--)i+=e[a]*n,n*=256;return i}mt.readUintBE=j8;function k8(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,a=t;a=i;a--)t[a]=e/n&255,n*=256;return t}mt.writeUintBE=H8;function K8(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!$v.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,a=i;a>>16|v<<16,F=F+v|0,x^=F,x=x>>>20|x<<12,U=U+B|0,_^=U,_=_>>>16|_<<16,m=m+_|0,B^=m,B=B>>>20|B<<12,k=k+ae|0,I^=k,I=I>>>16|I<<16,c=c+I|0,ae^=c,ae=ae>>>20|ae<<12,G=G+le|0,M^=G,M=M>>>16|M<<16,h=h+M|0,le^=h,le=le>>>20|le<<12,k=k+ae|0,I^=k,I=I>>>24|I<<8,c=c+I|0,ae^=c,ae=ae>>>25|ae<<7,G=G+le|0,M^=G,M=M>>>24|M<<8,h=h+M|0,le^=h,le=le>>>25|le<<7,U=U+B|0,_^=U,_=_>>>24|_<<8,m=m+_|0,B^=m,B=B>>>25|B<<7,Y=Y+x|0,v^=Y,v=v>>>24|v<<8,F=F+v|0,x^=F,x=x>>>25|x<<7,Y=Y+B|0,M^=Y,M=M>>>16|M<<16,c=c+M|0,B^=c,B=B>>>20|B<<12,U=U+ae|0,v^=U,v=v>>>16|v<<16,h=h+v|0,ae^=h,ae=ae>>>20|ae<<12,k=k+le|0,_^=k,_=_>>>16|_<<16,F=F+_|0,le^=F,le=le>>>20|le<<12,G=G+x|0,I^=G,I=I>>>16|I<<16,m=m+I|0,x^=m,x=x>>>20|x<<12,k=k+le|0,_^=k,_=_>>>24|_<<8,F=F+_|0,le^=F,le=le>>>25|le<<7,G=G+x|0,I^=G,I=I>>>24|I<<8,m=m+I|0,x^=m,x=x>>>25|x<<7,U=U+ae|0,v^=U,v=v>>>24|v<<8,h=h+v|0,ae^=h,ae=ae>>>25|ae<<7,Y=Y+B|0,M^=Y,M=M>>>24|M<<8,c=c+M|0,B^=c,B=B>>>25|B<<7;Ur.writeUint32LE(Y+i|0,r,0),Ur.writeUint32LE(U+n|0,r,4),Ur.writeUint32LE(k+a|0,r,8),Ur.writeUint32LE(G+f|0,r,12),Ur.writeUint32LE(x+u|0,r,16),Ur.writeUint32LE(B+b|0,r,20),Ur.writeUint32LE(ae+p|0,r,24),Ur.writeUint32LE(le+y|0,r,28),Ur.writeUint32LE(F+A|0,r,32),Ur.writeUint32LE(m+R|0,r,36),Ur.writeUint32LE(c+O|0,r,40),Ur.writeUint32LE(h+N|0,r,44),Ur.writeUint32LE(v+K|0,r,48),Ur.writeUint32LE(_+W|0,r,52),Ur.writeUint32LE(I+Q|0,r,56),Ur.writeUint32LE(M+j|0,r,60)}function Kv(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var Vv={},Us={};Object.defineProperty(Us,"__esModule",{value:!0});function s_(r,e,t){return~(r-1)&e|r-1&t}Us.select=s_;function a_(r,e){return(r|0)-(e|0)-1>>>31&1}Us.lessOrEqual=a_;function Gv(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}Us.compare=Gv;function o_(r,e){return r.length===0||e.length===0?!1:Gv(r,e)!==0}Us.equal=o_;(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=Us,t=Ei;r.DIGEST_LENGTH=16;var i=function(){function f(u){this.digestLength=r.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var b=u[0]|u[1]<<8;this._r[0]=b&8191;var p=u[2]|u[3]<<8;this._r[1]=(b>>>13|p<<3)&8191;var y=u[4]|u[5]<<8;this._r[2]=(p>>>10|y<<6)&7939;var A=u[6]|u[7]<<8;this._r[3]=(y>>>7|A<<9)&8191;var R=u[8]|u[9]<<8;this._r[4]=(A>>>4|R<<12)&255,this._r[5]=R>>>1&8190;var O=u[10]|u[11]<<8;this._r[6]=(R>>>14|O<<2)&8191;var N=u[12]|u[13]<<8;this._r[7]=(O>>>11|N<<5)&8065;var K=u[14]|u[15]<<8;this._r[8]=(N>>>8|K<<8)&8191,this._r[9]=K>>>5&127,this._pad[0]=u[16]|u[17]<<8,this._pad[1]=u[18]|u[19]<<8,this._pad[2]=u[20]|u[21]<<8,this._pad[3]=u[22]|u[23]<<8,this._pad[4]=u[24]|u[25]<<8,this._pad[5]=u[26]|u[27]<<8,this._pad[6]=u[28]|u[29]<<8,this._pad[7]=u[30]|u[31]<<8}return f.prototype._blocks=function(u,b,p){for(var y=this._fin?0:2048,A=this._h[0],R=this._h[1],O=this._h[2],N=this._h[3],K=this._h[4],W=this._h[5],Q=this._h[6],j=this._h[7],Y=this._h[8],U=this._h[9],k=this._r[0],G=this._r[1],x=this._r[2],B=this._r[3],ae=this._r[4],le=this._r[5],F=this._r[6],m=this._r[7],c=this._r[8],h=this._r[9];p>=16;){var v=u[b+0]|u[b+1]<<8;A+=v&8191;var _=u[b+2]|u[b+3]<<8;R+=(v>>>13|_<<3)&8191;var I=u[b+4]|u[b+5]<<8;O+=(_>>>10|I<<6)&8191;var M=u[b+6]|u[b+7]<<8;N+=(I>>>7|M<<9)&8191;var S=u[b+8]|u[b+9]<<8;K+=(M>>>4|S<<12)&8191,W+=S>>>1&8191;var d=u[b+10]|u[b+11]<<8;Q+=(S>>>14|d<<2)&8191;var g=u[b+12]|u[b+13]<<8;j+=(d>>>11|g<<5)&8191;var T=u[b+14]|u[b+15]<<8;Y+=(g>>>8|T<<8)&8191,U+=T>>>5|y;var Z=0,se=Z;se+=A*k,se+=R*(5*h),se+=O*(5*c),se+=N*(5*m),se+=K*(5*F),Z=se>>>13,se&=8191,se+=W*(5*le),se+=Q*(5*ae),se+=j*(5*B),se+=Y*(5*x),se+=U*(5*G),Z+=se>>>13,se&=8191;var P=Z;P+=A*G,P+=R*k,P+=O*(5*h),P+=N*(5*c),P+=K*(5*m),Z=P>>>13,P&=8191,P+=W*(5*F),P+=Q*(5*le),P+=j*(5*ae),P+=Y*(5*B),P+=U*(5*x),Z+=P>>>13,P&=8191;var ee=Z;ee+=A*x,ee+=R*G,ee+=O*k,ee+=N*(5*h),ee+=K*(5*c),Z=ee>>>13,ee&=8191,ee+=W*(5*m),ee+=Q*(5*F),ee+=j*(5*le),ee+=Y*(5*ae),ee+=U*(5*B),Z+=ee>>>13,ee&=8191;var q=Z;q+=A*B,q+=R*x,q+=O*G,q+=N*k,q+=K*(5*h),Z=q>>>13,q&=8191,q+=W*(5*c),q+=Q*(5*m),q+=j*(5*F),q+=Y*(5*le),q+=U*(5*ae),Z+=q>>>13,q&=8191;var z=Z;z+=A*ae,z+=R*B,z+=O*x,z+=N*G,z+=K*k,Z=z>>>13,z&=8191,z+=W*(5*h),z+=Q*(5*c),z+=j*(5*m),z+=Y*(5*F),z+=U*(5*le),Z+=z>>>13,z&=8191;var H=Z;H+=A*le,H+=R*ae,H+=O*B,H+=N*x,H+=K*G,Z=H>>>13,H&=8191,H+=W*k,H+=Q*(5*h),H+=j*(5*c),H+=Y*(5*m),H+=U*(5*F),Z+=H>>>13,H&=8191;var w=Z;w+=A*F,w+=R*le,w+=O*ae,w+=N*B,w+=K*x,Z=w>>>13,w&=8191,w+=W*G,w+=Q*k,w+=j*(5*h),w+=Y*(5*c),w+=U*(5*m),Z+=w>>>13,w&=8191;var $=Z;$+=A*m,$+=R*F,$+=O*le,$+=N*ae,$+=K*B,Z=$>>>13,$&=8191,$+=W*x,$+=Q*G,$+=j*k,$+=Y*(5*h),$+=U*(5*c),Z+=$>>>13,$&=8191;var ne=Z;ne+=A*c,ne+=R*m,ne+=O*F,ne+=N*le,ne+=K*ae,Z=ne>>>13,ne&=8191,ne+=W*B,ne+=Q*x,ne+=j*G,ne+=Y*k,ne+=U*(5*h),Z+=ne>>>13,ne&=8191;var ce=Z;ce+=A*h,ce+=R*c,ce+=O*m,ce+=N*F,ce+=K*le,Z=ce>>>13,ce&=8191,ce+=W*ae,ce+=Q*B,ce+=j*x,ce+=Y*G,ce+=U*k,Z+=ce>>>13,ce&=8191,Z=(Z<<2)+Z|0,Z=Z+se|0,se=Z&8191,Z=Z>>>13,P+=Z,A=se,R=P,O=ee,N=q,K=z,W=H,Q=w,j=$,Y=ne,U=ce,b+=16,p-=16}this._h[0]=A,this._h[1]=R,this._h[2]=O,this._h[3]=N,this._h[4]=K,this._h[5]=W,this._h[6]=Q,this._h[7]=j,this._h[8]=Y,this._h[9]=U},f.prototype.finish=function(u,b){b===void 0&&(b=0);var p=new Uint16Array(10),y,A,R,O;if(this._leftover){for(O=this._leftover,this._buffer[O++]=1;O<16;O++)this._buffer[O]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(y=this._h[1]>>>13,this._h[1]&=8191,O=2;O<10;O++)this._h[O]+=y,y=this._h[O]>>>13,this._h[O]&=8191;for(this._h[0]+=y*5,y=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=y,y=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=y,p[0]=this._h[0]+5,y=p[0]>>>13,p[0]&=8191,O=1;O<10;O++)p[O]=this._h[O]+y,y=p[O]>>>13,p[O]&=8191;for(p[9]-=8192,A=(y^1)-1,O=0;O<10;O++)p[O]&=A;for(A=~A,O=0;O<10;O++)this._h[O]=this._h[O]&A|p[O];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,R=this._h[0]+this._pad[0],this._h[0]=R&65535,O=1;O<8;O++)R=(this._h[O]+this._pad[O]|0)+(R>>>16)|0,this._h[O]=R&65535;return u[b+0]=this._h[0]>>>0,u[b+1]=this._h[0]>>>8,u[b+2]=this._h[1]>>>0,u[b+3]=this._h[1]>>>8,u[b+4]=this._h[2]>>>0,u[b+5]=this._h[2]>>>8,u[b+6]=this._h[3]>>>0,u[b+7]=this._h[3]>>>8,u[b+8]=this._h[4]>>>0,u[b+9]=this._h[4]>>>8,u[b+10]=this._h[5]>>>0,u[b+11]=this._h[5]>>>8,u[b+12]=this._h[6]>>>0,u[b+13]=this._h[6]>>>8,u[b+14]=this._h[7]>>>0,u[b+15]=this._h[7]>>>8,this._finished=!0,this},f.prototype.update=function(u){var b=0,p=u.length,y;if(this._leftover){y=16-this._leftover,y>p&&(y=p);for(var A=0;A=16&&(y=p-p%16,this._blocks(u,b,y),b+=y,p-=y),p){for(var A=0;A16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var O=new Uint8Array(16);O.set(p,O.length-p.length);var N=new Uint8Array(32);e.stream(this._key,O,N,4);var K=y.length+this.tagLength,W;if(R){if(R.length!==K)throw new Error("ChaCha20Poly1305: incorrect destination length");W=R}else W=new Uint8Array(K);return e.streamXOR(this._key,O,y,W,4),this._authenticate(W.subarray(W.length-this.tagLength,W.length),N,W.subarray(0,W.length-this.tagLength),A),i.wipe(O),W},b.prototype.open=function(p,y,A,R){if(p.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(y.length0&&O.update(f.subarray(R.length%16))),O.update(A),A.length%16>0&&O.update(f.subarray(A.length%16));var N=new Uint8Array(8);R&&n.writeUint64LE(R.length,N),O.update(N),n.writeUint64LE(A.length,N),O.update(N);for(var K=O.digest(),W=0;Wthis.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i256)throw new Error("randomString charset is too long");let R="";const O=y.length,N=256-256%O;for(;p>0;){const K=n(Math.ceil(p*256/N),A);for(let W=0;W0;W++){const Q=K[W];Q0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=b[y++],p--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(p>=this.blockSize&&(y=a(this._temp,this._state,b,y,p),p%=this.blockSize);p>0;)this._buffer[this._bufferLength++]=b[y++],p--;return this},u.prototype.finish=function(b){if(!this._finished){var p=this._bytesHashed,y=this._bufferLength,A=p/536870912|0,R=p<<3,O=p%64<56?64:128;this._buffer[y]=128;for(var N=y+1;N0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},u.prototype.restoreState=function(b){return this._state.set(b.state),this._bufferLength=b.bufferLength,b.buffer&&this._buffer.set(b.buffer),this._bytesHashed=b.bytesHashed,this._finished=!1,this},u.prototype.cleanSavedState=function(b){t.wipe(b.state),b.buffer&&t.wipe(b.buffer),b.bufferLength=0,b.bytesHashed=0},u}();r.SHA256=i;var n=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function a(u,b,p,y,A){for(;A>=64;){for(var R=b[0],O=b[1],N=b[2],K=b[3],W=b[4],Q=b[5],j=b[6],Y=b[7],U=0;U<16;U++){var k=y+U*4;u[U]=e.readUint32BE(p,k)}for(var U=16;U<64;U++){var G=u[U-2],x=(G>>>17|G<<15)^(G>>>19|G<<13)^G>>>10;G=u[U-15];var B=(G>>>7|G<<25)^(G>>>18|G<<14)^G>>>3;u[U]=(x+u[U-7]|0)+(B+u[U-16]|0)}for(var U=0;U<64;U++){var x=(((W>>>6|W<<26)^(W>>>11|W<<21)^(W>>>25|W<<7))+(W&Q^~W&j)|0)+(Y+(n[U]+u[U]|0)|0)|0,B=((R>>>2|R<<30)^(R>>>13|R<<19)^(R>>>22|R<<10))+(R&O^R&N^O&N)|0;Y=j,j=Q,Q=W,W=K+x|0,K=N,N=O,O=R,R=x+B|0}b[0]+=R,b[1]+=O,b[2]+=N,b[3]+=K,b[4]+=W,b[5]+=Q,b[6]+=j,b[7]+=Y,y+=64,A-=64}return y}function f(u){var b=new i;b.update(u);var p=b.digest();return b.clean(),p}r.hash=f})(Ac);var C0={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.sharedKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.scalarMultBase=r.scalarMult=r.SHARED_KEY_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=void 0;const e=$s,t=Ei;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function i(U){const k=new Float64Array(16);if(U)for(let G=0;G>16&1),G[le-1]&=65535;G[15]=x[15]-32767-(G[14]>>16&1);const ae=G[15]>>16&1;G[14]&=65535,u(x,G,1-ae)}for(let B=0;B<16;B++)U[2*B]=x[B]&255,U[2*B+1]=x[B]>>8}function p(U,k){for(let G=0;G<16;G++)U[G]=k[2*G]+(k[2*G+1]<<8);U[15]&=32767}function y(U,k,G){for(let x=0;x<16;x++)U[x]=k[x]+G[x]}function A(U,k,G){for(let x=0;x<16;x++)U[x]=k[x]-G[x]}function R(U,k,G){let x,B,ae=0,le=0,F=0,m=0,c=0,h=0,v=0,_=0,I=0,M=0,S=0,d=0,g=0,T=0,Z=0,se=0,P=0,ee=0,q=0,z=0,H=0,w=0,$=0,ne=0,ce=0,he=0,ye=0,we=0,Ce=0,Qe=0,Oe=0,Te=G[0],Ie=G[1],me=G[2],Re=G[3],De=G[4],ve=G[5],Ne=G[6],Se=G[7],be=G[8],Le=G[9],Me=G[10],_e=G[11],He=G[12],Ve=G[13],Ee=G[14],Ke=G[15];x=k[0],ae+=x*Te,le+=x*Ie,F+=x*me,m+=x*Re,c+=x*De,h+=x*ve,v+=x*Ne,_+=x*Se,I+=x*be,M+=x*Le,S+=x*Me,d+=x*_e,g+=x*He,T+=x*Ve,Z+=x*Ee,se+=x*Ke,x=k[1],le+=x*Te,F+=x*Ie,m+=x*me,c+=x*Re,h+=x*De,v+=x*ve,_+=x*Ne,I+=x*Se,M+=x*be,S+=x*Le,d+=x*Me,g+=x*_e,T+=x*He,Z+=x*Ve,se+=x*Ee,P+=x*Ke,x=k[2],F+=x*Te,m+=x*Ie,c+=x*me,h+=x*Re,v+=x*De,_+=x*ve,I+=x*Ne,M+=x*Se,S+=x*be,d+=x*Le,g+=x*Me,T+=x*_e,Z+=x*He,se+=x*Ve,P+=x*Ee,ee+=x*Ke,x=k[3],m+=x*Te,c+=x*Ie,h+=x*me,v+=x*Re,_+=x*De,I+=x*ve,M+=x*Ne,S+=x*Se,d+=x*be,g+=x*Le,T+=x*Me,Z+=x*_e,se+=x*He,P+=x*Ve,ee+=x*Ee,q+=x*Ke,x=k[4],c+=x*Te,h+=x*Ie,v+=x*me,_+=x*Re,I+=x*De,M+=x*ve,S+=x*Ne,d+=x*Se,g+=x*be,T+=x*Le,Z+=x*Me,se+=x*_e,P+=x*He,ee+=x*Ve,q+=x*Ee,z+=x*Ke,x=k[5],h+=x*Te,v+=x*Ie,_+=x*me,I+=x*Re,M+=x*De,S+=x*ve,d+=x*Ne,g+=x*Se,T+=x*be,Z+=x*Le,se+=x*Me,P+=x*_e,ee+=x*He,q+=x*Ve,z+=x*Ee,H+=x*Ke,x=k[6],v+=x*Te,_+=x*Ie,I+=x*me,M+=x*Re,S+=x*De,d+=x*ve,g+=x*Ne,T+=x*Se,Z+=x*be,se+=x*Le,P+=x*Me,ee+=x*_e,q+=x*He,z+=x*Ve,H+=x*Ee,w+=x*Ke,x=k[7],_+=x*Te,I+=x*Ie,M+=x*me,S+=x*Re,d+=x*De,g+=x*ve,T+=x*Ne,Z+=x*Se,se+=x*be,P+=x*Le,ee+=x*Me,q+=x*_e,z+=x*He,H+=x*Ve,w+=x*Ee,$+=x*Ke,x=k[8],I+=x*Te,M+=x*Ie,S+=x*me,d+=x*Re,g+=x*De,T+=x*ve,Z+=x*Ne,se+=x*Se,P+=x*be,ee+=x*Le,q+=x*Me,z+=x*_e,H+=x*He,w+=x*Ve,$+=x*Ee,ne+=x*Ke,x=k[9],M+=x*Te,S+=x*Ie,d+=x*me,g+=x*Re,T+=x*De,Z+=x*ve,se+=x*Ne,P+=x*Se,ee+=x*be,q+=x*Le,z+=x*Me,H+=x*_e,w+=x*He,$+=x*Ve,ne+=x*Ee,ce+=x*Ke,x=k[10],S+=x*Te,d+=x*Ie,g+=x*me,T+=x*Re,Z+=x*De,se+=x*ve,P+=x*Ne,ee+=x*Se,q+=x*be,z+=x*Le,H+=x*Me,w+=x*_e,$+=x*He,ne+=x*Ve,ce+=x*Ee,he+=x*Ke,x=k[11],d+=x*Te,g+=x*Ie,T+=x*me,Z+=x*Re,se+=x*De,P+=x*ve,ee+=x*Ne,q+=x*Se,z+=x*be,H+=x*Le,w+=x*Me,$+=x*_e,ne+=x*He,ce+=x*Ve,he+=x*Ee,ye+=x*Ke,x=k[12],g+=x*Te,T+=x*Ie,Z+=x*me,se+=x*Re,P+=x*De,ee+=x*ve,q+=x*Ne,z+=x*Se,H+=x*be,w+=x*Le,$+=x*Me,ne+=x*_e,ce+=x*He,he+=x*Ve,ye+=x*Ee,we+=x*Ke,x=k[13],T+=x*Te,Z+=x*Ie,se+=x*me,P+=x*Re,ee+=x*De,q+=x*ve,z+=x*Ne,H+=x*Se,w+=x*be,$+=x*Le,ne+=x*Me,ce+=x*_e,he+=x*He,ye+=x*Ve,we+=x*Ee,Ce+=x*Ke,x=k[14],Z+=x*Te,se+=x*Ie,P+=x*me,ee+=x*Re,q+=x*De,z+=x*ve,H+=x*Ne,w+=x*Se,$+=x*be,ne+=x*Le,ce+=x*Me,he+=x*_e,ye+=x*He,we+=x*Ve,Ce+=x*Ee,Qe+=x*Ke,x=k[15],se+=x*Te,P+=x*Ie,ee+=x*me,q+=x*Re,z+=x*De,H+=x*ve,w+=x*Ne,$+=x*Se,ne+=x*be,ce+=x*Le,he+=x*Me,ye+=x*_e,we+=x*He,Ce+=x*Ve,Qe+=x*Ee,Oe+=x*Ke,ae+=38*P,le+=38*ee,F+=38*q,m+=38*z,c+=38*H,h+=38*w,v+=38*$,_+=38*ne,I+=38*ce,M+=38*he,S+=38*ye,d+=38*we,g+=38*Ce,T+=38*Qe,Z+=38*Oe,B=1,x=ae+B+65535,B=Math.floor(x/65536),ae=x-B*65536,x=le+B+65535,B=Math.floor(x/65536),le=x-B*65536,x=F+B+65535,B=Math.floor(x/65536),F=x-B*65536,x=m+B+65535,B=Math.floor(x/65536),m=x-B*65536,x=c+B+65535,B=Math.floor(x/65536),c=x-B*65536,x=h+B+65535,B=Math.floor(x/65536),h=x-B*65536,x=v+B+65535,B=Math.floor(x/65536),v=x-B*65536,x=_+B+65535,B=Math.floor(x/65536),_=x-B*65536,x=I+B+65535,B=Math.floor(x/65536),I=x-B*65536,x=M+B+65535,B=Math.floor(x/65536),M=x-B*65536,x=S+B+65535,B=Math.floor(x/65536),S=x-B*65536,x=d+B+65535,B=Math.floor(x/65536),d=x-B*65536,x=g+B+65535,B=Math.floor(x/65536),g=x-B*65536,x=T+B+65535,B=Math.floor(x/65536),T=x-B*65536,x=Z+B+65535,B=Math.floor(x/65536),Z=x-B*65536,x=se+B+65535,B=Math.floor(x/65536),se=x-B*65536,ae+=B-1+37*(B-1),B=1,x=ae+B+65535,B=Math.floor(x/65536),ae=x-B*65536,x=le+B+65535,B=Math.floor(x/65536),le=x-B*65536,x=F+B+65535,B=Math.floor(x/65536),F=x-B*65536,x=m+B+65535,B=Math.floor(x/65536),m=x-B*65536,x=c+B+65535,B=Math.floor(x/65536),c=x-B*65536,x=h+B+65535,B=Math.floor(x/65536),h=x-B*65536,x=v+B+65535,B=Math.floor(x/65536),v=x-B*65536,x=_+B+65535,B=Math.floor(x/65536),_=x-B*65536,x=I+B+65535,B=Math.floor(x/65536),I=x-B*65536,x=M+B+65535,B=Math.floor(x/65536),M=x-B*65536,x=S+B+65535,B=Math.floor(x/65536),S=x-B*65536,x=d+B+65535,B=Math.floor(x/65536),d=x-B*65536,x=g+B+65535,B=Math.floor(x/65536),g=x-B*65536,x=T+B+65535,B=Math.floor(x/65536),T=x-B*65536,x=Z+B+65535,B=Math.floor(x/65536),Z=x-B*65536,x=se+B+65535,B=Math.floor(x/65536),se=x-B*65536,ae+=B-1+37*(B-1),U[0]=ae,U[1]=le,U[2]=F,U[3]=m,U[4]=c,U[5]=h,U[6]=v,U[7]=_,U[8]=I,U[9]=M,U[10]=S,U[11]=d,U[12]=g,U[13]=T,U[14]=Z,U[15]=se}function O(U,k){R(U,k,k)}function N(U,k){const G=i();for(let x=0;x<16;x++)G[x]=k[x];for(let x=253;x>=0;x--)O(G,G),x!==2&&x!==4&&R(G,G,k);for(let x=0;x<16;x++)U[x]=G[x]}function K(U,k){const G=new Uint8Array(32),x=new Float64Array(80),B=i(),ae=i(),le=i(),F=i(),m=i(),c=i();for(let I=0;I<31;I++)G[I]=U[I];G[31]=U[31]&127|64,G[0]&=248,p(x,k);for(let I=0;I<16;I++)ae[I]=x[I];B[0]=F[0]=1;for(let I=254;I>=0;--I){const M=G[I>>>3]>>>(I&7)&1;u(B,ae,M),u(le,F,M),y(m,B,le),A(B,B,le),y(le,ae,F),A(ae,ae,F),O(F,m),O(c,B),R(B,le,B),R(le,ae,m),y(m,B,le),A(B,B,le),O(ae,B),A(le,F,c),R(B,le,a),y(B,B,F),R(le,le,B),R(B,F,c),R(F,ae,x),O(ae,m),u(B,ae,M),u(le,F,M)}for(let I=0;I<16;I++)x[I+16]=B[I],x[I+32]=le[I],x[I+48]=ae[I],x[I+64]=F[I];const h=x.subarray(32),v=x.subarray(16);N(h,h),R(v,v,h);const _=new Uint8Array(32);return b(_,v),_}r.scalarMult=K;function W(U){return K(U,n)}r.scalarMultBase=W;function Q(U){if(U.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const k=new Uint8Array(U);return{publicKey:W(k),secretKey:k}}r.generateKeyPairFromSeed=Q;function j(U){const k=(0,e.randomBytes)(32,U),G=Q(k);return(0,t.wipe)(k),G}r.generateKeyPair=j;function Y(U,k,G=!1){if(U.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(k.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const x=K(U,k);if(G){let B=0;for(let ae=0;aen+a.length,0));const t=U4(e);let i=0;for(const n of r)t.set(n,i),i+=n.length;return t}function Er(r,e="utf8"){const t=$4[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Yv={};const __="elliptic",A_="6.5.7",E_="EC cryptography",x_="lib/elliptic.js",S_=["lib"],I_={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},M_={type:"git",url:"git@github.com:indutny/elliptic"},P_=["EC","Elliptic","curve","Cryptography"],O_="Fedor Indutny ",R_="MIT",N_={url:"https://github.com/indutny/elliptic/issues"},C_="https://github.com/indutny/elliptic",T_={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},D_={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},F_={name:__,version:A_,description:E_,main:x_,files:S_,scripts:I_,repository:M_,keywords:P_,author:O_,license:R_,bugs:N_,homepage:C_,devDependencies:T_,dependencies:D_};var xi={},T0={exports:{}};T0.exports;(function(r){(function(e,t){function i(F,m){if(!F)throw new Error(m||"Assertion failed")}function n(F,m){F.super_=m;var c=function(){};c.prototype=m.prototype,F.prototype=new c,F.prototype.constructor=F}function a(F,m,c){if(a.isBN(F))return F;this.negative=0,this.words=null,this.length=0,this.red=null,F!==null&&((m==="le"||m==="be")&&(c=m,m=10),this._init(F||0,m||10,c||"be"))}typeof e=="object"?e.exports=a:t.BN=a,a.BN=a,a.wordSize=26;var f;try{typeof window<"u"&&typeof window.Buffer<"u"?f=window.Buffer:f=M0.Buffer}catch{}a.isBN=function(m){return m instanceof a?!0:m!==null&&typeof m=="object"&&m.constructor.wordSize===a.wordSize&&Array.isArray(m.words)},a.max=function(m,c){return m.cmp(c)>0?m:c},a.min=function(m,c){return m.cmp(c)<0?m:c},a.prototype._init=function(m,c,h){if(typeof m=="number")return this._initNumber(m,c,h);if(typeof m=="object")return this._initArray(m,c,h);c==="hex"&&(c=16),i(c===(c|0)&&c>=2&&c<=36),m=m.toString().replace(/\s+/g,"");var v=0;m[0]==="-"&&(v++,this.negative=1),v=0;v-=3)I=m[v]|m[v-1]<<8|m[v-2]<<16,this.words[_]|=I<>>26-M&67108863,M+=24,M>=26&&(M-=26,_++);else if(h==="le")for(v=0,_=0;v>>26-M&67108863,M+=24,M>=26&&(M-=26,_++);return this.strip()};function u(F,m){var c=F.charCodeAt(m);return c>=65&&c<=70?c-55:c>=97&&c<=102?c-87:c-48&15}function b(F,m,c){var h=u(F,c);return c-1>=m&&(h|=u(F,c-1)<<4),h}a.prototype._parseHex=function(m,c,h){this.length=Math.ceil((m.length-c)/6),this.words=new Array(this.length);for(var v=0;v=c;v-=2)M=b(m,c,v)<<_,this.words[I]|=M&67108863,_>=18?(_-=18,I+=1,this.words[I]|=M>>>26):_+=8;else{var S=m.length-c;for(v=S%2===0?c+1:c;v=18?(_-=18,I+=1,this.words[I]|=M>>>26):_+=8}this.strip()};function p(F,m,c,h){for(var v=0,_=Math.min(F.length,c),I=m;I<_;I++){var M=F.charCodeAt(I)-48;v*=h,M>=49?v+=M-49+10:M>=17?v+=M-17+10:v+=M}return v}a.prototype._parseBase=function(m,c,h){this.words=[0],this.length=1;for(var v=0,_=1;_<=67108863;_*=c)v++;v--,_=_/c|0;for(var I=m.length-h,M=I%v,S=Math.min(I,I-M)+h,d=0,g=h;g1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?""};var y=["","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"],A=[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],R=[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];a.prototype.toString=function(m,c){m=m||10,c=c|0||1;var h;if(m===16||m==="hex"){h="";for(var v=0,_=0,I=0;I>>24-v&16777215,_!==0||I!==this.length-1?h=y[6-S.length]+S+h:h=S+h,v+=2,v>=26&&(v-=26,I--)}for(_!==0&&(h=_.toString(16)+h);h.length%c!==0;)h="0"+h;return this.negative!==0&&(h="-"+h),h}if(m===(m|0)&&m>=2&&m<=36){var d=A[m],g=R[m];h="";var T=this.clone();for(T.negative=0;!T.isZero();){var Z=T.modn(g).toString(m);T=T.idivn(g),T.isZero()?h=Z+h:h=y[d-Z.length]+Z+h}for(this.isZero()&&(h="0"+h);h.length%c!==0;)h="0"+h;return this.negative!==0&&(h="-"+h),h}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var m=this.words[0];return this.length===2?m+=this.words[1]*67108864:this.length===3&&this.words[2]===1?m+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-m:m},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(m,c){return i(typeof f<"u"),this.toArrayLike(f,m,c)},a.prototype.toArray=function(m,c){return this.toArrayLike(Array,m,c)},a.prototype.toArrayLike=function(m,c,h){var v=this.byteLength(),_=h||Math.max(1,v);i(v<=_,"byte array longer than desired length"),i(_>0,"Requested array length <= 0"),this.strip();var I=c==="le",M=new m(_),S,d,g=this.clone();if(I){for(d=0;!g.isZero();d++)S=g.andln(255),g.iushrn(8),M[d]=S;for(;d<_;d++)M[d]=0}else{for(d=0;d<_-v;d++)M[d]=0;for(d=0;!g.isZero();d++)S=g.andln(255),g.iushrn(8),M[_-d-1]=S}return M},Math.clz32?a.prototype._countBits=function(m){return 32-Math.clz32(m)}:a.prototype._countBits=function(m){var c=m,h=0;return c>=4096&&(h+=13,c>>>=13),c>=64&&(h+=7,c>>>=7),c>=8&&(h+=4,c>>>=4),c>=2&&(h+=2,c>>>=2),h+c},a.prototype._zeroBits=function(m){if(m===0)return 26;var c=m,h=0;return c&8191||(h+=13,c>>>=13),c&127||(h+=7,c>>>=7),c&15||(h+=4,c>>>=4),c&3||(h+=2,c>>>=2),c&1||h++,h},a.prototype.bitLength=function(){var m=this.words[this.length-1],c=this._countBits(m);return(this.length-1)*26+c};function O(F){for(var m=new Array(F.bitLength()),c=0;c>>v}return m}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var m=0,c=0;cm.length?this.clone().ior(m):m.clone().ior(this)},a.prototype.uor=function(m){return this.length>m.length?this.clone().iuor(m):m.clone().iuor(this)},a.prototype.iuand=function(m){var c;this.length>m.length?c=m:c=this;for(var h=0;hm.length?this.clone().iand(m):m.clone().iand(this)},a.prototype.uand=function(m){return this.length>m.length?this.clone().iuand(m):m.clone().iuand(this)},a.prototype.iuxor=function(m){var c,h;this.length>m.length?(c=this,h=m):(c=m,h=this);for(var v=0;vm.length?this.clone().ixor(m):m.clone().ixor(this)},a.prototype.uxor=function(m){return this.length>m.length?this.clone().iuxor(m):m.clone().iuxor(this)},a.prototype.inotn=function(m){i(typeof m=="number"&&m>=0);var c=Math.ceil(m/26)|0,h=m%26;this._expand(c),h>0&&c--;for(var v=0;v0&&(this.words[v]=~this.words[v]&67108863>>26-h),this.strip()},a.prototype.notn=function(m){return this.clone().inotn(m)},a.prototype.setn=function(m,c){i(typeof m=="number"&&m>=0);var h=m/26|0,v=m%26;return this._expand(h+1),c?this.words[h]=this.words[h]|1<m.length?(h=this,v=m):(h=m,v=this);for(var _=0,I=0;I>>26;for(;_!==0&&I>>26;if(this.length=h.length,_!==0)this.words[this.length]=_,this.length++;else if(h!==this)for(;Im.length?this.clone().iadd(m):m.clone().iadd(this)},a.prototype.isub=function(m){if(m.negative!==0){m.negative=0;var c=this.iadd(m);return m.negative=1,c._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(m),this.negative=1,this._normSign();var h=this.cmp(m);if(h===0)return this.negative=0,this.length=1,this.words[0]=0,this;var v,_;h>0?(v=this,_=m):(v=m,_=this);for(var I=0,M=0;M<_.length;M++)c=(v.words[M]|0)-(_.words[M]|0)+I,I=c>>26,this.words[M]=c&67108863;for(;I!==0&&M>26,this.words[M]=c&67108863;if(I===0&&M>>26,T=S&67108863,Z=Math.min(d,m.length-1),se=Math.max(0,d-F.length+1);se<=Z;se++){var P=d-se|0;v=F.words[P]|0,_=m.words[se]|0,I=v*_+T,g+=I/67108864|0,T=I&67108863}c.words[d]=T|0,S=g|0}return S!==0?c.words[d]=S|0:c.length--,c.strip()}var K=function(m,c,h){var v=m.words,_=c.words,I=h.words,M=0,S,d,g,T=v[0]|0,Z=T&8191,se=T>>>13,P=v[1]|0,ee=P&8191,q=P>>>13,z=v[2]|0,H=z&8191,w=z>>>13,$=v[3]|0,ne=$&8191,ce=$>>>13,he=v[4]|0,ye=he&8191,we=he>>>13,Ce=v[5]|0,Qe=Ce&8191,Oe=Ce>>>13,Te=v[6]|0,Ie=Te&8191,me=Te>>>13,Re=v[7]|0,De=Re&8191,ve=Re>>>13,Ne=v[8]|0,Se=Ne&8191,be=Ne>>>13,Le=v[9]|0,Me=Le&8191,_e=Le>>>13,He=_[0]|0,Ve=He&8191,Ee=He>>>13,Ke=_[1]|0,ut=Ke&8191,Ge=Ke>>>13,_t=_[2]|0,lt=_t&8191,Je=_t>>>13,Et=_[3]|0,It=Et&8191,Fe=Et>>>13,Xe=_[4]|0,tt=Xe&8191,Be=Xe>>>13,et=_[5]|0,Ze=et&8191,$e=et>>>13,ft=_[6]|0,rt=ft&8191,ze=ft>>>13,it=_[7]|0,st=it&8191,qe=it>>>13,Ye=_[8]|0,ht=Ye&8191,je=Ye>>>13,Tt=_[9]|0,Dt=Tt&8191,at=Tt>>>13;h.negative=m.negative^c.negative,h.length=19,S=Math.imul(Z,Ve),d=Math.imul(Z,Ee),d=d+Math.imul(se,Ve)|0,g=Math.imul(se,Ee);var bt=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(bt>>>26)|0,bt&=67108863,S=Math.imul(ee,Ve),d=Math.imul(ee,Ee),d=d+Math.imul(q,Ve)|0,g=Math.imul(q,Ee),S=S+Math.imul(Z,ut)|0,d=d+Math.imul(Z,Ge)|0,d=d+Math.imul(se,ut)|0,g=g+Math.imul(se,Ge)|0;var Cr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,S=Math.imul(H,Ve),d=Math.imul(H,Ee),d=d+Math.imul(w,Ve)|0,g=Math.imul(w,Ee),S=S+Math.imul(ee,ut)|0,d=d+Math.imul(ee,Ge)|0,d=d+Math.imul(q,ut)|0,g=g+Math.imul(q,Ge)|0,S=S+Math.imul(Z,lt)|0,d=d+Math.imul(Z,Je)|0,d=d+Math.imul(se,lt)|0,g=g+Math.imul(se,Je)|0;var Tr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Tr>>>26)|0,Tr&=67108863,S=Math.imul(ne,Ve),d=Math.imul(ne,Ee),d=d+Math.imul(ce,Ve)|0,g=Math.imul(ce,Ee),S=S+Math.imul(H,ut)|0,d=d+Math.imul(H,Ge)|0,d=d+Math.imul(w,ut)|0,g=g+Math.imul(w,Ge)|0,S=S+Math.imul(ee,lt)|0,d=d+Math.imul(ee,Je)|0,d=d+Math.imul(q,lt)|0,g=g+Math.imul(q,Je)|0,S=S+Math.imul(Z,It)|0,d=d+Math.imul(Z,Fe)|0,d=d+Math.imul(se,It)|0,g=g+Math.imul(se,Fe)|0;var Dr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Dr>>>26)|0,Dr&=67108863,S=Math.imul(ye,Ve),d=Math.imul(ye,Ee),d=d+Math.imul(we,Ve)|0,g=Math.imul(we,Ee),S=S+Math.imul(ne,ut)|0,d=d+Math.imul(ne,Ge)|0,d=d+Math.imul(ce,ut)|0,g=g+Math.imul(ce,Ge)|0,S=S+Math.imul(H,lt)|0,d=d+Math.imul(H,Je)|0,d=d+Math.imul(w,lt)|0,g=g+Math.imul(w,Je)|0,S=S+Math.imul(ee,It)|0,d=d+Math.imul(ee,Fe)|0,d=d+Math.imul(q,It)|0,g=g+Math.imul(q,Fe)|0,S=S+Math.imul(Z,tt)|0,d=d+Math.imul(Z,Be)|0,d=d+Math.imul(se,tt)|0,g=g+Math.imul(se,Be)|0;var Fr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Fr>>>26)|0,Fr&=67108863,S=Math.imul(Qe,Ve),d=Math.imul(Qe,Ee),d=d+Math.imul(Oe,Ve)|0,g=Math.imul(Oe,Ee),S=S+Math.imul(ye,ut)|0,d=d+Math.imul(ye,Ge)|0,d=d+Math.imul(we,ut)|0,g=g+Math.imul(we,Ge)|0,S=S+Math.imul(ne,lt)|0,d=d+Math.imul(ne,Je)|0,d=d+Math.imul(ce,lt)|0,g=g+Math.imul(ce,Je)|0,S=S+Math.imul(H,It)|0,d=d+Math.imul(H,Fe)|0,d=d+Math.imul(w,It)|0,g=g+Math.imul(w,Fe)|0,S=S+Math.imul(ee,tt)|0,d=d+Math.imul(ee,Be)|0,d=d+Math.imul(q,tt)|0,g=g+Math.imul(q,Be)|0,S=S+Math.imul(Z,Ze)|0,d=d+Math.imul(Z,$e)|0,d=d+Math.imul(se,Ze)|0,g=g+Math.imul(se,$e)|0;var Br=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Br>>>26)|0,Br&=67108863,S=Math.imul(Ie,Ve),d=Math.imul(Ie,Ee),d=d+Math.imul(me,Ve)|0,g=Math.imul(me,Ee),S=S+Math.imul(Qe,ut)|0,d=d+Math.imul(Qe,Ge)|0,d=d+Math.imul(Oe,ut)|0,g=g+Math.imul(Oe,Ge)|0,S=S+Math.imul(ye,lt)|0,d=d+Math.imul(ye,Je)|0,d=d+Math.imul(we,lt)|0,g=g+Math.imul(we,Je)|0,S=S+Math.imul(ne,It)|0,d=d+Math.imul(ne,Fe)|0,d=d+Math.imul(ce,It)|0,g=g+Math.imul(ce,Fe)|0,S=S+Math.imul(H,tt)|0,d=d+Math.imul(H,Be)|0,d=d+Math.imul(w,tt)|0,g=g+Math.imul(w,Be)|0,S=S+Math.imul(ee,Ze)|0,d=d+Math.imul(ee,$e)|0,d=d+Math.imul(q,Ze)|0,g=g+Math.imul(q,$e)|0,S=S+Math.imul(Z,rt)|0,d=d+Math.imul(Z,ze)|0,d=d+Math.imul(se,rt)|0,g=g+Math.imul(se,ze)|0;var er=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(er>>>26)|0,er&=67108863,S=Math.imul(De,Ve),d=Math.imul(De,Ee),d=d+Math.imul(ve,Ve)|0,g=Math.imul(ve,Ee),S=S+Math.imul(Ie,ut)|0,d=d+Math.imul(Ie,Ge)|0,d=d+Math.imul(me,ut)|0,g=g+Math.imul(me,Ge)|0,S=S+Math.imul(Qe,lt)|0,d=d+Math.imul(Qe,Je)|0,d=d+Math.imul(Oe,lt)|0,g=g+Math.imul(Oe,Je)|0,S=S+Math.imul(ye,It)|0,d=d+Math.imul(ye,Fe)|0,d=d+Math.imul(we,It)|0,g=g+Math.imul(we,Fe)|0,S=S+Math.imul(ne,tt)|0,d=d+Math.imul(ne,Be)|0,d=d+Math.imul(ce,tt)|0,g=g+Math.imul(ce,Be)|0,S=S+Math.imul(H,Ze)|0,d=d+Math.imul(H,$e)|0,d=d+Math.imul(w,Ze)|0,g=g+Math.imul(w,$e)|0,S=S+Math.imul(ee,rt)|0,d=d+Math.imul(ee,ze)|0,d=d+Math.imul(q,rt)|0,g=g+Math.imul(q,ze)|0,S=S+Math.imul(Z,st)|0,d=d+Math.imul(Z,qe)|0,d=d+Math.imul(se,st)|0,g=g+Math.imul(se,qe)|0;var Qr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Qr>>>26)|0,Qr&=67108863,S=Math.imul(Se,Ve),d=Math.imul(Se,Ee),d=d+Math.imul(be,Ve)|0,g=Math.imul(be,Ee),S=S+Math.imul(De,ut)|0,d=d+Math.imul(De,Ge)|0,d=d+Math.imul(ve,ut)|0,g=g+Math.imul(ve,Ge)|0,S=S+Math.imul(Ie,lt)|0,d=d+Math.imul(Ie,Je)|0,d=d+Math.imul(me,lt)|0,g=g+Math.imul(me,Je)|0,S=S+Math.imul(Qe,It)|0,d=d+Math.imul(Qe,Fe)|0,d=d+Math.imul(Oe,It)|0,g=g+Math.imul(Oe,Fe)|0,S=S+Math.imul(ye,tt)|0,d=d+Math.imul(ye,Be)|0,d=d+Math.imul(we,tt)|0,g=g+Math.imul(we,Be)|0,S=S+Math.imul(ne,Ze)|0,d=d+Math.imul(ne,$e)|0,d=d+Math.imul(ce,Ze)|0,g=g+Math.imul(ce,$e)|0,S=S+Math.imul(H,rt)|0,d=d+Math.imul(H,ze)|0,d=d+Math.imul(w,rt)|0,g=g+Math.imul(w,ze)|0,S=S+Math.imul(ee,st)|0,d=d+Math.imul(ee,qe)|0,d=d+Math.imul(q,st)|0,g=g+Math.imul(q,qe)|0,S=S+Math.imul(Z,ht)|0,d=d+Math.imul(Z,je)|0,d=d+Math.imul(se,ht)|0,g=g+Math.imul(se,je)|0;var Gi=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Gi>>>26)|0,Gi&=67108863,S=Math.imul(Me,Ve),d=Math.imul(Me,Ee),d=d+Math.imul(_e,Ve)|0,g=Math.imul(_e,Ee),S=S+Math.imul(Se,ut)|0,d=d+Math.imul(Se,Ge)|0,d=d+Math.imul(be,ut)|0,g=g+Math.imul(be,Ge)|0,S=S+Math.imul(De,lt)|0,d=d+Math.imul(De,Je)|0,d=d+Math.imul(ve,lt)|0,g=g+Math.imul(ve,Je)|0,S=S+Math.imul(Ie,It)|0,d=d+Math.imul(Ie,Fe)|0,d=d+Math.imul(me,It)|0,g=g+Math.imul(me,Fe)|0,S=S+Math.imul(Qe,tt)|0,d=d+Math.imul(Qe,Be)|0,d=d+Math.imul(Oe,tt)|0,g=g+Math.imul(Oe,Be)|0,S=S+Math.imul(ye,Ze)|0,d=d+Math.imul(ye,$e)|0,d=d+Math.imul(we,Ze)|0,g=g+Math.imul(we,$e)|0,S=S+Math.imul(ne,rt)|0,d=d+Math.imul(ne,ze)|0,d=d+Math.imul(ce,rt)|0,g=g+Math.imul(ce,ze)|0,S=S+Math.imul(H,st)|0,d=d+Math.imul(H,qe)|0,d=d+Math.imul(w,st)|0,g=g+Math.imul(w,qe)|0,S=S+Math.imul(ee,ht)|0,d=d+Math.imul(ee,je)|0,d=d+Math.imul(q,ht)|0,g=g+Math.imul(q,je)|0,S=S+Math.imul(Z,Dt)|0,d=d+Math.imul(Z,at)|0,d=d+Math.imul(se,Dt)|0,g=g+Math.imul(se,at)|0;var Xr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,S=Math.imul(Me,ut),d=Math.imul(Me,Ge),d=d+Math.imul(_e,ut)|0,g=Math.imul(_e,Ge),S=S+Math.imul(Se,lt)|0,d=d+Math.imul(Se,Je)|0,d=d+Math.imul(be,lt)|0,g=g+Math.imul(be,Je)|0,S=S+Math.imul(De,It)|0,d=d+Math.imul(De,Fe)|0,d=d+Math.imul(ve,It)|0,g=g+Math.imul(ve,Fe)|0,S=S+Math.imul(Ie,tt)|0,d=d+Math.imul(Ie,Be)|0,d=d+Math.imul(me,tt)|0,g=g+Math.imul(me,Be)|0,S=S+Math.imul(Qe,Ze)|0,d=d+Math.imul(Qe,$e)|0,d=d+Math.imul(Oe,Ze)|0,g=g+Math.imul(Oe,$e)|0,S=S+Math.imul(ye,rt)|0,d=d+Math.imul(ye,ze)|0,d=d+Math.imul(we,rt)|0,g=g+Math.imul(we,ze)|0,S=S+Math.imul(ne,st)|0,d=d+Math.imul(ne,qe)|0,d=d+Math.imul(ce,st)|0,g=g+Math.imul(ce,qe)|0,S=S+Math.imul(H,ht)|0,d=d+Math.imul(H,je)|0,d=d+Math.imul(w,ht)|0,g=g+Math.imul(w,je)|0,S=S+Math.imul(ee,Dt)|0,d=d+Math.imul(ee,at)|0,d=d+Math.imul(q,Dt)|0,g=g+Math.imul(q,at)|0;var Wi=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Wi>>>26)|0,Wi&=67108863,S=Math.imul(Me,lt),d=Math.imul(Me,Je),d=d+Math.imul(_e,lt)|0,g=Math.imul(_e,Je),S=S+Math.imul(Se,It)|0,d=d+Math.imul(Se,Fe)|0,d=d+Math.imul(be,It)|0,g=g+Math.imul(be,Fe)|0,S=S+Math.imul(De,tt)|0,d=d+Math.imul(De,Be)|0,d=d+Math.imul(ve,tt)|0,g=g+Math.imul(ve,Be)|0,S=S+Math.imul(Ie,Ze)|0,d=d+Math.imul(Ie,$e)|0,d=d+Math.imul(me,Ze)|0,g=g+Math.imul(me,$e)|0,S=S+Math.imul(Qe,rt)|0,d=d+Math.imul(Qe,ze)|0,d=d+Math.imul(Oe,rt)|0,g=g+Math.imul(Oe,ze)|0,S=S+Math.imul(ye,st)|0,d=d+Math.imul(ye,qe)|0,d=d+Math.imul(we,st)|0,g=g+Math.imul(we,qe)|0,S=S+Math.imul(ne,ht)|0,d=d+Math.imul(ne,je)|0,d=d+Math.imul(ce,ht)|0,g=g+Math.imul(ce,je)|0,S=S+Math.imul(H,Dt)|0,d=d+Math.imul(H,at)|0,d=d+Math.imul(w,Dt)|0,g=g+Math.imul(w,at)|0;var Ji=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Ji>>>26)|0,Ji&=67108863,S=Math.imul(Me,It),d=Math.imul(Me,Fe),d=d+Math.imul(_e,It)|0,g=Math.imul(_e,Fe),S=S+Math.imul(Se,tt)|0,d=d+Math.imul(Se,Be)|0,d=d+Math.imul(be,tt)|0,g=g+Math.imul(be,Be)|0,S=S+Math.imul(De,Ze)|0,d=d+Math.imul(De,$e)|0,d=d+Math.imul(ve,Ze)|0,g=g+Math.imul(ve,$e)|0,S=S+Math.imul(Ie,rt)|0,d=d+Math.imul(Ie,ze)|0,d=d+Math.imul(me,rt)|0,g=g+Math.imul(me,ze)|0,S=S+Math.imul(Qe,st)|0,d=d+Math.imul(Qe,qe)|0,d=d+Math.imul(Oe,st)|0,g=g+Math.imul(Oe,qe)|0,S=S+Math.imul(ye,ht)|0,d=d+Math.imul(ye,je)|0,d=d+Math.imul(we,ht)|0,g=g+Math.imul(we,je)|0,S=S+Math.imul(ne,Dt)|0,d=d+Math.imul(ne,at)|0,d=d+Math.imul(ce,Dt)|0,g=g+Math.imul(ce,at)|0;var Zr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,S=Math.imul(Me,tt),d=Math.imul(Me,Be),d=d+Math.imul(_e,tt)|0,g=Math.imul(_e,Be),S=S+Math.imul(Se,Ze)|0,d=d+Math.imul(Se,$e)|0,d=d+Math.imul(be,Ze)|0,g=g+Math.imul(be,$e)|0,S=S+Math.imul(De,rt)|0,d=d+Math.imul(De,ze)|0,d=d+Math.imul(ve,rt)|0,g=g+Math.imul(ve,ze)|0,S=S+Math.imul(Ie,st)|0,d=d+Math.imul(Ie,qe)|0,d=d+Math.imul(me,st)|0,g=g+Math.imul(me,qe)|0,S=S+Math.imul(Qe,ht)|0,d=d+Math.imul(Qe,je)|0,d=d+Math.imul(Oe,ht)|0,g=g+Math.imul(Oe,je)|0,S=S+Math.imul(ye,Dt)|0,d=d+Math.imul(ye,at)|0,d=d+Math.imul(we,Dt)|0,g=g+Math.imul(we,at)|0;var Si=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Si>>>26)|0,Si&=67108863,S=Math.imul(Me,Ze),d=Math.imul(Me,$e),d=d+Math.imul(_e,Ze)|0,g=Math.imul(_e,$e),S=S+Math.imul(Se,rt)|0,d=d+Math.imul(Se,ze)|0,d=d+Math.imul(be,rt)|0,g=g+Math.imul(be,ze)|0,S=S+Math.imul(De,st)|0,d=d+Math.imul(De,qe)|0,d=d+Math.imul(ve,st)|0,g=g+Math.imul(ve,qe)|0,S=S+Math.imul(Ie,ht)|0,d=d+Math.imul(Ie,je)|0,d=d+Math.imul(me,ht)|0,g=g+Math.imul(me,je)|0,S=S+Math.imul(Qe,Dt)|0,d=d+Math.imul(Qe,at)|0,d=d+Math.imul(Oe,Dt)|0,g=g+Math.imul(Oe,at)|0;var Ii=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,S=Math.imul(Me,rt),d=Math.imul(Me,ze),d=d+Math.imul(_e,rt)|0,g=Math.imul(_e,ze),S=S+Math.imul(Se,st)|0,d=d+Math.imul(Se,qe)|0,d=d+Math.imul(be,st)|0,g=g+Math.imul(be,qe)|0,S=S+Math.imul(De,ht)|0,d=d+Math.imul(De,je)|0,d=d+Math.imul(ve,ht)|0,g=g+Math.imul(ve,je)|0,S=S+Math.imul(Ie,Dt)|0,d=d+Math.imul(Ie,at)|0,d=d+Math.imul(me,Dt)|0,g=g+Math.imul(me,at)|0;var lr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(lr>>>26)|0,lr&=67108863,S=Math.imul(Me,st),d=Math.imul(Me,qe),d=d+Math.imul(_e,st)|0,g=Math.imul(_e,qe),S=S+Math.imul(Se,ht)|0,d=d+Math.imul(Se,je)|0,d=d+Math.imul(be,ht)|0,g=g+Math.imul(be,je)|0,S=S+Math.imul(De,Dt)|0,d=d+Math.imul(De,at)|0,d=d+Math.imul(ve,Dt)|0,g=g+Math.imul(ve,at)|0;var Yi=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Yi>>>26)|0,Yi&=67108863,S=Math.imul(Me,ht),d=Math.imul(Me,je),d=d+Math.imul(_e,ht)|0,g=Math.imul(_e,je),S=S+Math.imul(Se,Dt)|0,d=d+Math.imul(Se,at)|0,d=d+Math.imul(be,Dt)|0,g=g+Math.imul(be,at)|0;var Qi=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,S=Math.imul(Me,Dt),d=Math.imul(Me,at),d=d+Math.imul(_e,Dt)|0,g=Math.imul(_e,at);var Xi=(M+S|0)+((d&8191)<<13)|0;return M=(g+(d>>>13)|0)+(Xi>>>26)|0,Xi&=67108863,I[0]=bt,I[1]=Cr,I[2]=Tr,I[3]=Dr,I[4]=Fr,I[5]=Br,I[6]=er,I[7]=Qr,I[8]=Gi,I[9]=Xr,I[10]=Wi,I[11]=Ji,I[12]=Zr,I[13]=Si,I[14]=Ii,I[15]=lr,I[16]=Yi,I[17]=Qi,I[18]=Xi,M!==0&&(I[19]=M,h.length++),h};Math.imul||(K=N);function W(F,m,c){c.negative=m.negative^F.negative,c.length=F.length+m.length;for(var h=0,v=0,_=0;_>>26)|0,v+=I>>>26,I&=67108863}c.words[_]=M,h=I,I=v}return h!==0?c.words[_]=h:c.length--,c.strip()}function Q(F,m,c){var h=new j;return h.mulp(F,m,c)}a.prototype.mulTo=function(m,c){var h,v=this.length+m.length;return this.length===10&&m.length===10?h=K(this,m,c):v<63?h=N(this,m,c):v<1024?h=W(this,m,c):h=Q(this,m,c),h};function j(F,m){this.x=F,this.y=m}j.prototype.makeRBT=function(m){for(var c=new Array(m),h=a.prototype._countBits(m)-1,v=0;v>=1;return v},j.prototype.permute=function(m,c,h,v,_,I){for(var M=0;M>>1)_++;return 1<<_+1+v},j.prototype.conjugate=function(m,c,h){if(!(h<=1))for(var v=0;v>>13,h[2*I+1]=_&8191,_=_>>>13;for(I=2*c;I>=26,c+=v/67108864|0,c+=_>>>26,this.words[h]=_&67108863}return c!==0&&(this.words[h]=c,this.length++),this},a.prototype.muln=function(m){return this.clone().imuln(m)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(m){var c=O(m);if(c.length===0)return new a(1);for(var h=this,v=0;v=0);var c=m%26,h=(m-c)/26,v=67108863>>>26-c<<26-c,_;if(c!==0){var I=0;for(_=0;_>>26-c}I&&(this.words[_]=I,this.length++)}if(h!==0){for(_=this.length-1;_>=0;_--)this.words[_+h]=this.words[_];for(_=0;_=0);var v;c?v=(c-c%26)/26:v=0;var _=m%26,I=Math.min((m-_)/26,this.length),M=67108863^67108863>>>_<<_,S=h;if(v-=I,v=Math.max(0,v),S){for(var d=0;dI)for(this.length-=I,d=0;d=0&&(g!==0||d>=v);d--){var T=this.words[d]|0;this.words[d]=g<<26-_|T>>>_,g=T&M}return S&&g!==0&&(S.words[S.length++]=g),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(m,c,h){return i(this.negative===0),this.iushrn(m,c,h)},a.prototype.shln=function(m){return this.clone().ishln(m)},a.prototype.ushln=function(m){return this.clone().iushln(m)},a.prototype.shrn=function(m){return this.clone().ishrn(m)},a.prototype.ushrn=function(m){return this.clone().iushrn(m)},a.prototype.testn=function(m){i(typeof m=="number"&&m>=0);var c=m%26,h=(m-c)/26,v=1<=0);var c=m%26,h=(m-c)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=h)return this;if(c!==0&&h++,this.length=Math.min(h,this.length),c!==0){var v=67108863^67108863>>>c<=67108864;c++)this.words[c]-=67108864,c===this.length-1?this.words[c+1]=1:this.words[c+1]++;return this.length=Math.max(this.length,c+1),this},a.prototype.isubn=function(m){if(i(typeof m=="number"),i(m<67108864),m<0)return this.iaddn(-m);if(this.negative!==0)return this.negative=0,this.iaddn(m),this.negative=1,this;if(this.words[0]-=m,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var c=0;c>26)-(S/67108864|0),this.words[_+h]=I&67108863}for(;_>26,this.words[_+h]=I&67108863;if(M===0)return this.strip();for(i(M===-1),M=0,_=0;_>26,this.words[_]=I&67108863;return this.negative=1,this.strip()},a.prototype._wordDiv=function(m,c){var h=this.length-m.length,v=this.clone(),_=m,I=_.words[_.length-1]|0,M=this._countBits(I);h=26-M,h!==0&&(_=_.ushln(h),v.iushln(h),I=_.words[_.length-1]|0);var S=v.length-_.length,d;if(c!=="mod"){d=new a(null),d.length=S+1,d.words=new Array(d.length);for(var g=0;g=0;Z--){var se=(v.words[_.length+Z]|0)*67108864+(v.words[_.length+Z-1]|0);for(se=Math.min(se/I|0,67108863),v._ishlnsubmul(_,se,Z);v.negative!==0;)se--,v.negative=0,v._ishlnsubmul(_,1,Z),v.isZero()||(v.negative^=1);d&&(d.words[Z]=se)}return d&&d.strip(),v.strip(),c!=="div"&&h!==0&&v.iushrn(h),{div:d||null,mod:v}},a.prototype.divmod=function(m,c,h){if(i(!m.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var v,_,I;return this.negative!==0&&m.negative===0?(I=this.neg().divmod(m,c),c!=="mod"&&(v=I.div.neg()),c!=="div"&&(_=I.mod.neg(),h&&_.negative!==0&&_.iadd(m)),{div:v,mod:_}):this.negative===0&&m.negative!==0?(I=this.divmod(m.neg(),c),c!=="mod"&&(v=I.div.neg()),{div:v,mod:I.mod}):this.negative&m.negative?(I=this.neg().divmod(m.neg(),c),c!=="div"&&(_=I.mod.neg(),h&&_.negative!==0&&_.isub(m)),{div:I.div,mod:_}):m.length>this.length||this.cmp(m)<0?{div:new a(0),mod:this}:m.length===1?c==="div"?{div:this.divn(m.words[0]),mod:null}:c==="mod"?{div:null,mod:new a(this.modn(m.words[0]))}:{div:this.divn(m.words[0]),mod:new a(this.modn(m.words[0]))}:this._wordDiv(m,c)},a.prototype.div=function(m){return this.divmod(m,"div",!1).div},a.prototype.mod=function(m){return this.divmod(m,"mod",!1).mod},a.prototype.umod=function(m){return this.divmod(m,"mod",!0).mod},a.prototype.divRound=function(m){var c=this.divmod(m);if(c.mod.isZero())return c.div;var h=c.div.negative!==0?c.mod.isub(m):c.mod,v=m.ushrn(1),_=m.andln(1),I=h.cmp(v);return I<0||_===1&&I===0?c.div:c.div.negative!==0?c.div.isubn(1):c.div.iaddn(1)},a.prototype.modn=function(m){i(m<=67108863);for(var c=(1<<26)%m,h=0,v=this.length-1;v>=0;v--)h=(c*h+(this.words[v]|0))%m;return h},a.prototype.idivn=function(m){i(m<=67108863);for(var c=0,h=this.length-1;h>=0;h--){var v=(this.words[h]|0)+c*67108864;this.words[h]=v/m|0,c=v%m}return this.strip()},a.prototype.divn=function(m){return this.clone().idivn(m)},a.prototype.egcd=function(m){i(m.negative===0),i(!m.isZero());var c=this,h=m.clone();c.negative!==0?c=c.umod(m):c=c.clone();for(var v=new a(1),_=new a(0),I=new a(0),M=new a(1),S=0;c.isEven()&&h.isEven();)c.iushrn(1),h.iushrn(1),++S;for(var d=h.clone(),g=c.clone();!c.isZero();){for(var T=0,Z=1;!(c.words[0]&Z)&&T<26;++T,Z<<=1);if(T>0)for(c.iushrn(T);T-- >0;)(v.isOdd()||_.isOdd())&&(v.iadd(d),_.isub(g)),v.iushrn(1),_.iushrn(1);for(var se=0,P=1;!(h.words[0]&P)&&se<26;++se,P<<=1);if(se>0)for(h.iushrn(se);se-- >0;)(I.isOdd()||M.isOdd())&&(I.iadd(d),M.isub(g)),I.iushrn(1),M.iushrn(1);c.cmp(h)>=0?(c.isub(h),v.isub(I),_.isub(M)):(h.isub(c),I.isub(v),M.isub(_))}return{a:I,b:M,gcd:h.iushln(S)}},a.prototype._invmp=function(m){i(m.negative===0),i(!m.isZero());var c=this,h=m.clone();c.negative!==0?c=c.umod(m):c=c.clone();for(var v=new a(1),_=new a(0),I=h.clone();c.cmpn(1)>0&&h.cmpn(1)>0;){for(var M=0,S=1;!(c.words[0]&S)&&M<26;++M,S<<=1);if(M>0)for(c.iushrn(M);M-- >0;)v.isOdd()&&v.iadd(I),v.iushrn(1);for(var d=0,g=1;!(h.words[0]&g)&&d<26;++d,g<<=1);if(d>0)for(h.iushrn(d);d-- >0;)_.isOdd()&&_.iadd(I),_.iushrn(1);c.cmp(h)>=0?(c.isub(h),v.isub(_)):(h.isub(c),_.isub(v))}var T;return c.cmpn(1)===0?T=v:T=_,T.cmpn(0)<0&&T.iadd(m),T},a.prototype.gcd=function(m){if(this.isZero())return m.abs();if(m.isZero())return this.abs();var c=this.clone(),h=m.clone();c.negative=0,h.negative=0;for(var v=0;c.isEven()&&h.isEven();v++)c.iushrn(1),h.iushrn(1);do{for(;c.isEven();)c.iushrn(1);for(;h.isEven();)h.iushrn(1);var _=c.cmp(h);if(_<0){var I=c;c=h,h=I}else if(_===0||h.cmpn(1)===0)break;c.isub(h)}while(!0);return h.iushln(v)},a.prototype.invm=function(m){return this.egcd(m).a.umod(m)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(m){return this.words[0]&m},a.prototype.bincn=function(m){i(typeof m=="number");var c=m%26,h=(m-c)/26,v=1<>>26,M&=67108863,this.words[I]=M}return _!==0&&(this.words[I]=_,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(m){var c=m<0;if(this.negative!==0&&!c)return-1;if(this.negative===0&&c)return 1;this.strip();var h;if(this.length>1)h=1;else{c&&(m=-m),i(m<=67108863,"Number is too big");var v=this.words[0]|0;h=v===m?0:vm.length)return 1;if(this.length=0;h--){var v=this.words[h]|0,_=m.words[h]|0;if(v!==_){v<_?c=-1:v>_&&(c=1);break}}return c},a.prototype.gtn=function(m){return this.cmpn(m)===1},a.prototype.gt=function(m){return this.cmp(m)===1},a.prototype.gten=function(m){return this.cmpn(m)>=0},a.prototype.gte=function(m){return this.cmp(m)>=0},a.prototype.ltn=function(m){return this.cmpn(m)===-1},a.prototype.lt=function(m){return this.cmp(m)===-1},a.prototype.lten=function(m){return this.cmpn(m)<=0},a.prototype.lte=function(m){return this.cmp(m)<=0},a.prototype.eqn=function(m){return this.cmpn(m)===0},a.prototype.eq=function(m){return this.cmp(m)===0},a.red=function(m){return new ae(m)},a.prototype.toRed=function(m){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),m.convertTo(this)._forceRed(m)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(m){return this.red=m,this},a.prototype.forceRed=function(m){return i(!this.red,"Already a number in reduction context"),this._forceRed(m)},a.prototype.redAdd=function(m){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,m)},a.prototype.redIAdd=function(m){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,m)},a.prototype.redSub=function(m){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,m)},a.prototype.redISub=function(m){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,m)},a.prototype.redShl=function(m){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,m)},a.prototype.redMul=function(m){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,m),this.red.mul(this,m)},a.prototype.redIMul=function(m){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,m),this.red.imul(this,m)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(m){return i(this.red&&!m.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,m)};var Y={k256:null,p224:null,p192:null,p25519:null};function U(F,m){this.name=F,this.p=new a(m,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}U.prototype._tmp=function(){var m=new a(null);return m.words=new Array(Math.ceil(this.n/13)),m},U.prototype.ireduce=function(m){var c=m,h;do this.split(c,this.tmp),c=this.imulK(c),c=c.iadd(this.tmp),h=c.bitLength();while(h>this.n);var v=h0?c.isub(this.p):c.strip!==void 0?c.strip():c._strip(),c},U.prototype.split=function(m,c){m.iushrn(this.n,0,c)},U.prototype.imulK=function(m){return m.imul(this.k)};function k(){U.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(k,U),k.prototype.split=function(m,c){for(var h=4194303,v=Math.min(m.length,9),_=0;_>>22,I=M}I>>>=22,m.words[_-10]=I,I===0&&m.length>10?m.length-=10:m.length-=9},k.prototype.imulK=function(m){m.words[m.length]=0,m.words[m.length+1]=0,m.length+=2;for(var c=0,h=0;h>>=26,m.words[h]=_,c=v}return c!==0&&(m.words[m.length++]=c),m},a._prime=function(m){if(Y[m])return Y[m];var c;if(m==="k256")c=new k;else if(m==="p224")c=new G;else if(m==="p192")c=new x;else if(m==="p25519")c=new B;else throw new Error("Unknown prime "+m);return Y[m]=c,c};function ae(F){if(typeof F=="string"){var m=a._prime(F);this.m=m.p,this.prime=m}else i(F.gtn(1),"modulus must be greater than 1"),this.m=F,this.prime=null}ae.prototype._verify1=function(m){i(m.negative===0,"red works only with positives"),i(m.red,"red works only with red numbers")},ae.prototype._verify2=function(m,c){i((m.negative|c.negative)===0,"red works only with positives"),i(m.red&&m.red===c.red,"red works only with red numbers")},ae.prototype.imod=function(m){return this.prime?this.prime.ireduce(m)._forceRed(this):m.umod(this.m)._forceRed(this)},ae.prototype.neg=function(m){return m.isZero()?m.clone():this.m.sub(m)._forceRed(this)},ae.prototype.add=function(m,c){this._verify2(m,c);var h=m.add(c);return h.cmp(this.m)>=0&&h.isub(this.m),h._forceRed(this)},ae.prototype.iadd=function(m,c){this._verify2(m,c);var h=m.iadd(c);return h.cmp(this.m)>=0&&h.isub(this.m),h},ae.prototype.sub=function(m,c){this._verify2(m,c);var h=m.sub(c);return h.cmpn(0)<0&&h.iadd(this.m),h._forceRed(this)},ae.prototype.isub=function(m,c){this._verify2(m,c);var h=m.isub(c);return h.cmpn(0)<0&&h.iadd(this.m),h},ae.prototype.shl=function(m,c){return this._verify1(m),this.imod(m.ushln(c))},ae.prototype.imul=function(m,c){return this._verify2(m,c),this.imod(m.imul(c))},ae.prototype.mul=function(m,c){return this._verify2(m,c),this.imod(m.mul(c))},ae.prototype.isqr=function(m){return this.imul(m,m.clone())},ae.prototype.sqr=function(m){return this.mul(m,m)},ae.prototype.sqrt=function(m){if(m.isZero())return m.clone();var c=this.m.andln(3);if(i(c%2===1),c===3){var h=this.m.add(new a(1)).iushrn(2);return this.pow(m,h)}for(var v=this.m.subn(1),_=0;!v.isZero()&&v.andln(1)===0;)_++,v.iushrn(1);i(!v.isZero());var I=new a(1).toRed(this),M=I.redNeg(),S=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new a(2*d*d).toRed(this);this.pow(d,S).cmp(M)!==0;)d.redIAdd(M);for(var g=this.pow(d,v),T=this.pow(m,v.addn(1).iushrn(1)),Z=this.pow(m,v),se=_;Z.cmp(I)!==0;){for(var P=Z,ee=0;P.cmp(I)!==0;ee++)P=P.redSqr();i(ee=0;_--){for(var g=c.words[_],T=d-1;T>=0;T--){var Z=g>>T&1;if(I!==v[0]&&(I=this.sqr(I)),Z===0&&M===0){S=0;continue}M<<=1,M|=Z,S++,!(S!==h&&(_!==0||T!==0))&&(I=this.mul(I,v[M]),S=0,M=0)}d=26}return I},ae.prototype.convertTo=function(m){var c=m.umod(this.m);return c===m?c.clone():c},ae.prototype.convertFrom=function(m){var c=m.clone();return c.red=null,c},a.mont=function(m){return new le(m)};function le(F){ae.call(this,F),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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)}n(le,ae),le.prototype.convertTo=function(m){return this.imod(m.ushln(this.shift))},le.prototype.convertFrom=function(m){var c=this.imod(m.mul(this.rinv));return c.red=null,c},le.prototype.imul=function(m,c){if(m.isZero()||c.isZero())return m.words[0]=0,m.length=1,m;var h=m.imul(c),v=h.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=h.isub(v).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},le.prototype.mul=function(m,c){if(m.isZero()||c.isZero())return new a(0)._forceRed(this);var h=m.mul(c),v=h.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=h.isub(v).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},le.prototype.invm=function(m){var c=this.imod(m._invmp(this.m).mul(this.r2));return c._forceRed(this)}})(r,ji)})(T0);var bs=T0.exports,ya=Qv;function Qv(r,e){if(!r)throw new Error(e||"Assertion failed")}Qv.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var D0={};(function(r){var e=r;function t(a,f){if(Array.isArray(a))return a.slice();if(!a)return[];var u=[];if(typeof a!="string"){for(var b=0;b>8,A=p&255;y?u.push(y,A):u.push(A)}return u}e.toArray=t;function i(a){return a.length===1?"0"+a:a}e.zero2=i;function n(a){for(var f="",u=0;u(K>>1)-1?Q=(K>>1)-j:Q=j,W.isubn(Q)):Q=0,O[N]=Q,W.iushrn(1)}return O}e.getNAF=a;function f(y,A){var R=[[],[]];y=y.clone(),A=A.clone();for(var O=0,N=0,K;y.cmpn(-O)>0||A.cmpn(-N)>0;){var W=y.andln(3)+O&3,Q=A.andln(3)+N&3;W===3&&(W=-1),Q===3&&(Q=-1);var j;W&1?(K=y.andln(7)+O&7,(K===3||K===5)&&Q===2?j=-W:j=W):j=0,R[0].push(j);var Y;Q&1?(K=A.andln(7)+N&7,(K===3||K===5)&&W===2?Y=-Q:Y=Q):Y=0,R[1].push(Y),2*O===j+1&&(O=1-O),2*N===Y+1&&(N=1-N),y.iushrn(1),A.iushrn(1)}return R}e.getJSF=f;function u(y,A,R){var O="_"+A;y.prototype[A]=function(){return this[O]!==void 0?this[O]:this[O]=R.call(this)}}e.cachedProperty=u;function b(y){return typeof y=="string"?e.toArray(y,"hex"):y}e.parseBytes=b;function p(y){return new t(y,"hex","le")}e.intFromLE=p})(xi);var F0={exports:{}},fl;F0.exports=function(e){return fl||(fl=new Fs(null)),fl.generate(e)};function Fs(r){this.rand=r}F0.exports.Rand=Fs;Fs.prototype.generate=function(e){return this._rand(e)};Fs.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Nh=zs;zs.prototype.point=function(){throw new Error("Not implemented")};zs.prototype.validate=function(){throw new Error("Not implemented")};zs.prototype._fixedNafMul=function(e,t){fh(e.precomputed);var i=e._getDoubles(),n=ch(t,1,this._bitLength),a=(1<=u;p--)b=(b<<1)+n[p];f.push(b)}for(var y=this.jpoint(null,null,null),A=this.jpoint(null,null,null),R=a;R>0;R--){for(u=0;u=0;b--){for(var p=0;b>=0&&f[b]===0;b--)p++;if(b>=0&&p++,u=u.dblp(p),b<0)break;var y=f[b];fh(y!==0),e.type==="affine"?y>0?u=u.mixedAdd(a[y-1>>1]):u=u.mixedAdd(a[-y-1>>1].neg()):y>0?u=u.add(a[y-1>>1]):u=u.add(a[-y-1>>1].neg())}return e.type==="affine"?u.toP():u};zs.prototype._wnafMulAdd=function(e,t,i,n,a){var f=this._wnafT1,u=this._wnafT2,b=this._wnafT3,p=0,y,A,R;for(y=0;y=1;y-=2){var N=y-1,K=y;if(f[N]!==1||f[K]!==1){b[N]=ch(i[N],f[N],this._bitLength),b[K]=ch(i[K],f[K],this._bitLength),p=Math.max(b[N].length,p),p=Math.max(b[K].length,p);continue}var W=[t[N],null,null,t[K]];t[N].y.cmp(t[K].y)===0?(W[1]=t[N].add(t[K]),W[2]=t[N].toJ().mixedAdd(t[K].neg())):t[N].y.cmp(t[K].y.redNeg())===0?(W[1]=t[N].toJ().mixedAdd(t[K]),W[2]=t[N].add(t[K].neg())):(W[1]=t[N].toJ().mixedAdd(t[K]),W[2]=t[N].toJ().mixedAdd(t[K].neg()));var Q=[-3,-1,-5,-7,0,7,5,1,3],j=B_(i[N],i[K]);for(p=Math.max(j[0].length,p),b[N]=new Array(p),b[K]=new Array(p),A=0;A=0;y--){for(var x=0;y>=0;){var B=!0;for(A=0;A=0&&x++,k=k.dblp(x),y<0)break;for(A=0;A0?R=u[A][ae-1>>1]:ae<0&&(R=u[A][-ae-1>>1].neg()),R.type==="affine"?k=k.mixedAdd(R):k=k.add(R))}}for(y=0;y=Math.ceil((e.bitLength()+1)/t.step):!1};Ki.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,a=0;a=0&&(O=p,N=y),A.negative&&(A=A.neg(),R=R.neg()),O.negative&&(O=O.neg(),N=N.neg()),[{a:A,b:R},{a:O,b:N}]};Vi.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],a=n.b.mul(e).divRound(this.n),f=i.b.neg().mul(e).divRound(this.n),u=a.mul(i.a),b=f.mul(n.a),p=a.mul(i.b),y=f.mul(n.b),A=e.sub(u).sub(b),R=p.add(y).neg();return{k1:A,k2:R}};Vi.prototype.pointFromX=function(e,t){e=new nr(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var a=n.fromRed().isOdd();return(t&&!a||!t&&a)&&(n=n.redNeg()),this.point(e,n)};Vi.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),a=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(a).cmpn(0)===0};Vi.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,a=this._endoWnafT2,f=0;f":""};Ir.prototype.isInfinity=function(){return this.inf};Ir.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};Ir.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),a=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),f=a.redSqr().redISub(this.x.redAdd(this.x)),u=a.redMul(this.x.redSub(f)).redISub(this.y);return this.curve.point(f,u)};Ir.prototype.getX=function(){return this.x.fromRed()};Ir.prototype.getY=function(){return this.y.fromRed()};Ir.prototype.mul=function(e){return e=new nr(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Ir.prototype.mulAdd=function(e,t,i){var n=[this,t],a=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,a):this.curve._wnafMulAdd(1,n,a,2)};Ir.prototype.jmulAdd=function(e,t,i){var n=[this,t],a=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,a,!0):this.curve._wnafMulAdd(1,n,a,2,!0)};Ir.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Ir.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(a){return a.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};Ir.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Rr(r,e,t,i){fo.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new nr(0)):(this.x=new nr(e,16),this.y=new nr(t,16),this.z=new nr(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}q0(Rr,fo.BasePoint);Vi.prototype.jpoint=function(e,t,i){return new Rr(this,e,t,i)};Rr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};Rr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Rr.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),a=e.x.redMul(i),f=this.y.redMul(t.redMul(e.z)),u=e.y.redMul(i.redMul(this.z)),b=n.redSub(a),p=f.redSub(u);if(b.cmpn(0)===0)return p.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var y=b.redSqr(),A=y.redMul(b),R=n.redMul(y),O=p.redSqr().redIAdd(A).redISub(R).redISub(R),N=p.redMul(R.redISub(O)).redISub(f.redMul(A)),K=this.z.redMul(e.z).redMul(b);return this.curve.jpoint(O,N,K)};Rr.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),a=this.y,f=e.y.redMul(t).redMul(this.z),u=i.redSub(n),b=a.redSub(f);if(u.cmpn(0)===0)return b.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var p=u.redSqr(),y=p.redMul(u),A=i.redMul(p),R=b.redSqr().redIAdd(y).redISub(A).redISub(A),O=b.redMul(A.redISub(R)).redISub(a.redMul(y)),N=this.z.redMul(u);return this.curve.jpoint(R,O,N)};Rr.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(a),this.x.cmp(i)===0)return!0}};Rr.prototype.inspect=function(){return this.isInfinity()?"":""};Rr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Xa=bs,Zv=xh,Ch=Nh,$_=xi;function ho(r){Ch.call(this,"mont",r),this.a=new Xa(r.a,16).toRed(this.red),this.b=new Xa(r.b,16).toRed(this.red),this.i4=new Xa(4).toRed(this.red).redInvm(),this.two=new Xa(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Zv(ho,Ch);var z_=ho;ho.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),a=n.redSqrt();return a.redSqr().cmp(n)===0};function Sr(r,e,t){Ch.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Xa(e,16),this.z=new Xa(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Zv(Sr,Ch.BasePoint);ho.prototype.decodePoint=function(e,t){return this.point($_.toArray(e,t),1)};ho.prototype.point=function(e,t){return new Sr(this,e,t)};ho.prototype.pointFromJSON=function(e){return Sr.fromJSON(this,e)};Sr.prototype.precompute=function(){};Sr.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};Sr.fromJSON=function(e,t){return new Sr(e,t[0],t[1]||e.one)};Sr.prototype.inspect=function(){return this.isInfinity()?"":""};Sr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};Sr.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),a=t.redSub(n),f=t.redMul(n),u=a.redMul(n.redAdd(this.curve.a24.redMul(a)));return this.curve.point(f,u)};Sr.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};Sr.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),a=e.x.redAdd(e.z),f=e.x.redSub(e.z),u=f.redMul(i),b=a.redMul(n),p=t.z.redMul(u.redAdd(b).redSqr()),y=t.x.redMul(u.redISub(b).redSqr());return this.curve.point(p,y)};Sr.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),a=this,f=[];t.cmpn(0)!==0;t.iushrn(1))f.push(t.andln(1));for(var u=f.length-1;u>=0;u--)f[u]===0?(i=i.diffAdd(n,a),n=n.dbl()):(n=i.diffAdd(n,a),i=i.dbl());return n};Sr.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};Sr.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};Sr.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};Sr.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};Sr.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var j_=xi,ls=bs,eb=xh,Th=Nh,k_=j_.assert;function Hn(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,Th.call(this,"edwards",r),this.a=new ls(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new ls(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new ls(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),k_(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}eb(Hn,Th);var H_=Hn;Hn.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Hn.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Hn.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};Hn.prototype.pointFromX=function(e,t){e=new ls(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),a=this.one.redSub(this.c2.redMul(this.d).redMul(i)),f=n.redMul(a.redInvm()),u=f.redSqrt();if(u.redSqr().redSub(f).cmp(this.zero)!==0)throw new Error("invalid point");var b=u.fromRed().isOdd();return(t&&!b||!t&&b)&&(u=u.redNeg()),this.point(e,u)};Hn.prototype.pointFromY=function(e,t){e=new ls(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),a=i.redMul(this.d).redMul(this.c2).redSub(this.a),f=n.redMul(a.redInvm());if(f.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var u=f.redSqrt();if(u.redSqr().redSub(f).cmp(this.zero)!==0)throw new Error("invalid point");return u.fromRed().isOdd()!==t&&(u=u.redNeg()),this.point(u,e)};Hn.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),a=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(a)===0};function Wt(r,e,t,i,n){Th.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new ls(e,16),this.y=new ls(t,16),this.z=i?new ls(i,16):this.curve.one,this.t=n&&new ls(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}eb(Wt,Th.BasePoint);Hn.prototype.pointFromJSON=function(e){return Wt.fromJSON(this,e)};Hn.prototype.point=function(e,t,i,n){return new Wt(this,e,t,i,n)};Wt.fromJSON=function(e,t){return new Wt(e,t[0],t[1],t[2])};Wt.prototype.inspect=function(){return this.isInfinity()?"":""};Wt.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Wt.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),a=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),f=n.redAdd(t),u=f.redSub(i),b=n.redSub(t),p=a.redMul(u),y=f.redMul(b),A=a.redMul(b),R=u.redMul(f);return this.curve.point(p,y,R,A)};Wt.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,a,f,u,b,p;if(this.curve.twisted){u=this.curve._mulA(t);var y=u.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(y.redSub(this.curve.two)),a=y.redMul(u.redSub(i)),f=y.redSqr().redSub(y).redSub(y)):(b=this.z.redSqr(),p=y.redSub(b).redISub(b),n=e.redSub(t).redISub(i).redMul(p),a=y.redMul(u.redSub(i)),f=y.redMul(p))}else u=t.redAdd(i),b=this.curve._mulC(this.z).redSqr(),p=u.redSub(b).redSub(b),n=this.curve._mulC(e.redISub(u)).redMul(p),a=this.curve._mulC(u).redMul(t.redISub(i)),f=u.redMul(p);return this.curve.point(n,a,f)};Wt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Wt.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),a=this.z.redMul(e.z.redAdd(e.z)),f=i.redSub(t),u=a.redSub(n),b=a.redAdd(n),p=i.redAdd(t),y=f.redMul(u),A=b.redMul(p),R=f.redMul(p),O=u.redMul(b);return this.curve.point(y,A,O,R)};Wt.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),a=this.y.redMul(e.y),f=this.curve.d.redMul(n).redMul(a),u=i.redSub(f),b=i.redAdd(f),p=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(a),y=t.redMul(u).redMul(p),A,R;return this.curve.twisted?(A=t.redMul(b).redMul(a.redSub(this.curve._mulA(n))),R=u.redMul(b)):(A=t.redMul(b).redMul(a.redSub(n)),R=this.curve._mulC(u).redMul(b)),this.curve.point(y,A,R)};Wt.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Wt.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Wt.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Wt.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Wt.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Wt.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Wt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Wt.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Wt.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Wt.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Wt.prototype.toP=Wt.prototype.normalize;Wt.prototype.mixedAdd=Wt.prototype.add;(function(r){var e=r;e.base=Nh,e.short=U_,e.mont=z_,e.edwards=H_})(B0);var Dh={},Fh={},Ot={},K_=ya,V_=xh;Ot.inherits=V_;function G_(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function W_(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=a&63|128):G_(r,n)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=a>>18|240,t[i++]=a>>12&63|128,t[i++]=a>>6&63|128,t[i++]=a&63|128):(t[i++]=a>>12|224,t[i++]=a>>6&63|128,t[i++]=a&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ot.htonl=tb;function Y_(r,e){for(var t="",i=0;i>>0}return a}Ot.join32=Q_;function X_(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=a>>>16&255,t[n+2]=a>>>8&255,t[n+3]=a&255):(t[n+3]=a>>>24,t[n+2]=a>>>16&255,t[n+1]=a>>>8&255,t[n]=a&255)}return t}Ot.split32=X_;function Z_(r,e){return r>>>e|r<<32-e}Ot.rotr32=Z_;function e7(r,e){return r<>>32-e}Ot.rotl32=e7;function t7(r,e){return r+e>>>0}Ot.sum32=t7;function r7(r,e,t){return r+e+t>>>0}Ot.sum32_3=r7;function i7(r,e,t,i){return r+e+t+i>>>0}Ot.sum32_4=i7;function n7(r,e,t,i,n){return r+e+t+i+n>>>0}Ot.sum32_5=n7;function s7(r,e,t,i){var n=r[e],a=r[e+1],f=i+a>>>0,u=(f>>0,r[e+1]=f}Ot.sum64=s7;function a7(r,e,t,i){var n=e+i>>>0,a=(n>>0}Ot.sum64_hi=a7;function o7(r,e,t,i){var n=e+i;return n>>>0}Ot.sum64_lo=o7;function c7(r,e,t,i,n,a,f,u){var b=0,p=e;p=p+i>>>0,b+=p>>0,b+=p>>0,b+=p>>0}Ot.sum64_4_hi=c7;function f7(r,e,t,i,n,a,f,u){var b=e+i+a+u;return b>>>0}Ot.sum64_4_lo=f7;function h7(r,e,t,i,n,a,f,u,b,p){var y=0,A=e;A=A+i>>>0,y+=A>>0,y+=A>>0,y+=A>>0,y+=A>>0}Ot.sum64_5_hi=h7;function u7(r,e,t,i,n,a,f,u,b,p){var y=e+i+a+u+p;return y>>>0}Ot.sum64_5_lo=u7;function l7(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ot.rotr64_hi=l7;function d7(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ot.rotr64_lo=d7;function p7(r,e,t){return r>>>t}Ot.shr64_hi=p7;function g7(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ot.shr64_lo=g7;var uo={},_1=Ot,v7=ya;function Bh(){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}uo.BlockHash=Bh;Bh.prototype.update=function(e,t){if(e=_1.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=_1.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[a++]=e>>>16&255,n[a++]=e>>>8&255,n[a++]=e&255}else for(n[a++]=e&255,n[a++]=e>>>8&255,n[a++]=e>>>16&255,n[a++]=e>>>24&255,n[a++]=0,n[a++]=0,n[a++]=0,n[a++]=0,f=8;f>>3}Kn.g0_256=_7;function A7(r){return Nn(r,17)^Nn(r,19)^r>>>10}Kn.g1_256=A7;var ro=Ot,E7=uo,x7=Kn,hl=ro.rotl32,Ko=ro.sum32,S7=ro.sum32_5,I7=x7.ft_1,ob=E7.BlockHash,M7=[1518500249,1859775393,2400959708,3395469782];function Un(){if(!(this instanceof Un))return new Un;ob.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}ro.inherits(Un,ob);var P7=Un;Un.blockSize=512;Un.outSize=160;Un.hmacStrength=80;Un.padLength=64;Un.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;nthis.blockSize&&(e=new this.Hash().update(e).digest()),g9(e.length<=this.blockSize);for(var t=e.length;t=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var y9=Ls;Ls.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var a=0;a=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Ls.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=ua.toArray(i,n||"hex"),this._update(i));for(var a=[];a.length"};var hh=bs,L0=xi,E9=L0.assert;function qh(r,e){if(r instanceof qh)return r;this._importDER(r,e)||(E9(r.r&&r.s,"Signature without r or s"),this.r=new hh(r.r,16),this.s=new hh(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var x9=qh;function S9(){this.place=0}function pl(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,a=0,f=e.place;a>>=0;return n<=127?!1:(e.place=f,n)}function I1(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}qh.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=I1(t),i=I1(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];gl(n,t.length),n=n.concat(t),n.push(2),gl(n,i.length);var a=n.concat(i),f=[48];return gl(f,a.length),f=f.concat(a),L0.encode(f,e)};var la=bs,yb=y9,I9=xi,vl=Dh,M9=Xv,wb=I9.assert,U0=A9,Lh=x9;function ki(r){if(!(this instanceof ki))return new ki(r);typeof r=="string"&&(wb(Object.prototype.hasOwnProperty.call(vl,r),"Unknown curve "+r),r=vl[r]),r instanceof vl.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var P9=ki;ki.prototype.keyPair=function(e){return new U0(this,e)};ki.prototype.keyFromPrivate=function(e,t){return U0.fromPrivate(this,e,t)};ki.prototype.keyFromPublic=function(e,t){return U0.fromPublic(this,e,t)};ki.prototype.genKeyPair=function(e){e||(e={});for(var t=new yb({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||M9(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new la(2));;){var a=new la(t.generate(i));if(!(a.cmp(n)>0))return a.iaddn(1),this.keyFromPrivate(a)}};ki.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};ki.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new la(e,16));for(var a=this.n.byteLength(),f=t.getPrivate().toArray("be",a),u=e.toArray("be",a),b=new yb({hash:this.hash,entropy:f,nonce:u,pers:n.pers,persEnc:n.persEnc||"utf8"}),p=this.n.sub(new la(1)),y=0;;y++){var A=n.k?n.k(y):new la(b.generate(this.n.byteLength()));if(A=this._truncateToN(A,!0),!(A.cmpn(1)<=0||A.cmp(p)>=0)){var R=this.g.mul(A);if(!R.isInfinity()){var O=R.getX(),N=O.umod(this.n);if(N.cmpn(0)!==0){var K=A.invm(this.n).mul(N.mul(t.getPrivate()).iadd(e));if(K=K.umod(this.n),K.cmpn(0)!==0){var W=(R.getY().isOdd()?1:0)|(O.cmp(N)!==0?2:0);return n.canonical&&K.cmp(this.nh)>0&&(K=this.n.sub(K),W^=1),new Lh({r:N,s:K,recoveryParam:W})}}}}}};ki.prototype.verify=function(e,t,i,n){e=this._truncateToN(new la(e,16)),i=this.keyFromPublic(i,n),t=new Lh(t,"hex");var a=t.r,f=t.s;if(a.cmpn(1)<0||a.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),b=u.mul(e).umod(this.n),p=u.mul(a).umod(this.n),y;return this.curve._maxwellTrick?(y=this.g.jmulAdd(b,i.getPublic(),p),y.isInfinity()?!1:y.eqXToP(a)):(y=this.g.mulAdd(b,i.getPublic(),p),y.isInfinity()?!1:y.getX().umod(this.n).cmp(a)===0)};ki.prototype.recoverPubKey=function(r,e,t,i){wb((3&t)===t,"The recovery param is more than two bits"),e=new Lh(e,i);var n=this.n,a=new la(r),f=e.r,u=e.s,b=t&1,p=t>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&p)throw new Error("Unable to find sencond key candinate");p?f=this.curve.pointFromX(f.add(this.curve.n),b):f=this.curve.pointFromX(f,b);var y=e.r.invm(n),A=n.sub(a).mul(y).umod(n),R=u.mul(y).umod(n);return this.g.mulAdd(A,f,R)};ki.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new Lh(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var a;try{a=this.recoverPubKey(r,e,n)}catch{continue}if(a.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var xc=xi,_b=xc.assert,M1=xc.parseBytes,go=xc.cachedProperty;function xr(r,e){this.eddsa=r,this._secret=M1(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=M1(e.pub)}xr.fromPublic=function(e,t){return t instanceof xr?t:new xr(e,{pub:t})};xr.fromSecret=function(e,t){return t instanceof xr?t:new xr(e,{secret:t})};xr.prototype.secret=function(){return this._secret};go(xr,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});go(xr,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});go(xr,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});go(xr,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});go(xr,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});go(xr,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});xr.prototype.sign=function(e){return _b(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};xr.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};xr.prototype.getSecret=function(e){return _b(this._secret,"KeyPair is public only"),xc.encode(this.secret(),e)};xr.prototype.getPublic=function(e){return xc.encode(this.pubBytes(),e)};var O9=xr,R9=bs,Uh=xi,P1=Uh.assert,$h=Uh.cachedProperty,N9=Uh.parseBytes;function wa(r,e){this.eddsa=r,typeof e!="object"&&(e=N9(e)),Array.isArray(e)&&(P1(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),P1(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof R9&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}$h(wa,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});$h(wa,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});$h(wa,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});$h(wa,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});wa.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};wa.prototype.toHex=function(){return Uh.encode(this.toBytes(),"hex").toUpperCase()};var C9=wa,T9=Fh,D9=Dh,so=xi,F9=so.assert,Ab=so.parseBytes,Eb=O9,O1=C9;function ui(r){if(F9(r==="ed25519","only tested with ed25519 so far"),!(this instanceof ui))return new ui(r);r=D9[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=T9.sha512}var B9=ui;ui.prototype.sign=function(e,t){e=Ab(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),a=this.g.mul(n),f=this.encodePoint(a),u=this.hashInt(f,i.pubBytes(),e).mul(i.priv()),b=n.add(u).umod(this.curve.n);return this.makeSignature({R:a,S:b,Rencoded:f})};ui.prototype.verify=function(e,t,i){if(e=Ab(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),a=this.hashInt(t.Rencoded(),n.pubBytes(),e),f=this.g.mul(t.S()),u=t.R().add(n.pub().mul(a));return u.eq(f)};ui.prototype.hashInt=function(){for(var e=this.hash(),t=0;t0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=b[y++],p--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(p>=this.blockSize&&(y=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,b,y,p),p%=this.blockSize);p>0;)this._buffer[this._bufferLength++]=b[y++],p--;return this},u.prototype.finish=function(b){if(!this._finished){var p=this._bytesHashed,y=this._bufferLength,A=p/536870912|0,R=p<<3,O=p%128<112?128:256;this._buffer[y]=128;for(var N=y+1;N0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},u.prototype.restoreState=function(b){return this._stateHi.set(b.stateHi),this._stateLo.set(b.stateLo),this._bufferLength=b.bufferLength,b.buffer&&this._buffer.set(b.buffer),this._bytesHashed=b.bytesHashed,this._finished=!1,this},u.prototype.cleanSavedState=function(b){t.wipe(b.stateHi),t.wipe(b.stateLo),b.buffer&&t.wipe(b.buffer),b.bufferLength=0,b.bytesHashed=0},u}();r.SHA512=i;var n=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function a(u,b,p,y,A,R,O){for(var N=p[0],K=p[1],W=p[2],Q=p[3],j=p[4],Y=p[5],U=p[6],k=p[7],G=y[0],x=y[1],B=y[2],ae=y[3],le=y[4],F=y[5],m=y[6],c=y[7],h,v,_,I,M,S,d,g;O>=128;){for(var T=0;T<16;T++){var Z=8*T+R;u[T]=e.readUint32BE(A,Z),b[T]=e.readUint32BE(A,Z+4)}for(var T=0;T<80;T++){var se=N,P=K,ee=W,q=Q,z=j,H=Y,w=U,$=k,ne=G,ce=x,he=B,ye=ae,we=le,Ce=F,Qe=m,Oe=c;if(h=k,v=c,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=(j>>>14|le<<18)^(j>>>18|le<<14)^(le>>>9|j<<23),v=(le>>>14|j<<18)^(le>>>18|j<<14)^(j>>>9|le<<23),M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,h=j&Y^~j&U,v=le&F^~le&m,M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,h=n[T*2],v=n[T*2+1],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,h=u[T%16],v=b[T%16],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,_=d&65535|g<<16,I=M&65535|S<<16,h=_,v=I,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=(N>>>28|G<<4)^(G>>>2|N<<30)^(G>>>7|N<<25),v=(G>>>28|N<<4)^(N>>>2|G<<30)^(N>>>7|G<<25),M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,h=N&K^N&W^K&W,v=G&x^G&B^x&B,M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,$=d&65535|g<<16,Oe=M&65535|S<<16,h=q,v=ye,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=_,v=I,M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,q=d&65535|g<<16,ye=M&65535|S<<16,K=se,W=P,Q=ee,j=q,Y=z,U=H,k=w,N=$,x=ne,B=ce,ae=he,le=ye,F=we,m=Ce,c=Qe,G=Oe,T%16===15)for(var Z=0;Z<16;Z++)h=u[Z],v=b[Z],M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=u[(Z+9)%16],v=b[(Z+9)%16],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,_=u[(Z+1)%16],I=b[(Z+1)%16],h=(_>>>1|I<<31)^(_>>>8|I<<24)^_>>>7,v=(I>>>1|_<<31)^(I>>>8|_<<24)^(I>>>7|_<<25),M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,_=u[(Z+14)%16],I=b[(Z+14)%16],h=(_>>>19|I<<13)^(I>>>29|_<<3)^_>>>6,v=(I>>>19|_<<13)^(_>>>29|I<<3)^(I>>>6|_<<26),M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,u[Z]=d&65535|g<<16,b[Z]=M&65535|S<<16}h=N,v=G,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[0],v=y[0],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[0]=N=d&65535|g<<16,y[0]=G=M&65535|S<<16,h=K,v=x,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[1],v=y[1],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[1]=K=d&65535|g<<16,y[1]=x=M&65535|S<<16,h=W,v=B,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[2],v=y[2],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[2]=W=d&65535|g<<16,y[2]=B=M&65535|S<<16,h=Q,v=ae,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[3],v=y[3],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[3]=Q=d&65535|g<<16,y[3]=ae=M&65535|S<<16,h=j,v=le,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[4],v=y[4],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[4]=j=d&65535|g<<16,y[4]=le=M&65535|S<<16,h=Y,v=F,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[5],v=y[5],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[5]=Y=d&65535|g<<16,y[5]=F=M&65535|S<<16,h=U,v=m,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[6],v=y[6],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[6]=U=d&65535|g<<16,y[6]=m=M&65535|S<<16,h=k,v=c,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[7],v=y[7],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[7]=k=d&65535|g<<16,y[7]=c=M&65535|S<<16,R+=128,O-=128}return R}function f(u){var b=new i;b.update(u);var p=b.digest();return b.clean(),p}r.hash=f})(xb);(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertSecretKeyToX25519=r.convertPublicKeyToX25519=r.verify=r.sign=r.extractPublicKeyFromSecretKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.SEED_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=r.SIGNATURE_LENGTH=void 0;const e=$s,t=xb,i=Ei;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function n(q){const z=new Float64Array(16);if(q)for(let H=0;H>16&1),H[ce-1]&=65535;H[15]=w[15]-32767-(H[14]>>16&1);const ne=H[15]>>16&1;H[14]&=65535,K(w,H,1-ne)}for(let $=0;$<16;$++)q[2*$]=w[$]&255,q[2*$+1]=w[$]>>8}function Q(q,z){let H=0;for(let w=0;w<32;w++)H|=q[w]^z[w];return(1&H-1>>>8)-1}function j(q,z){const H=new Uint8Array(32),w=new Uint8Array(32);return W(H,q),W(w,z),Q(H,w)}function Y(q){const z=new Uint8Array(32);return W(z,q),z[0]&1}function U(q,z){for(let H=0;H<16;H++)q[H]=z[2*H]+(z[2*H+1]<<8);q[15]&=32767}function k(q,z,H){for(let w=0;w<16;w++)q[w]=z[w]+H[w]}function G(q,z,H){for(let w=0;w<16;w++)q[w]=z[w]-H[w]}function x(q,z,H){let w,$,ne=0,ce=0,he=0,ye=0,we=0,Ce=0,Qe=0,Oe=0,Te=0,Ie=0,me=0,Re=0,De=0,ve=0,Ne=0,Se=0,be=0,Le=0,Me=0,_e=0,He=0,Ve=0,Ee=0,Ke=0,ut=0,Ge=0,_t=0,lt=0,Je=0,Et=0,It=0,Fe=H[0],Xe=H[1],tt=H[2],Be=H[3],et=H[4],Ze=H[5],$e=H[6],ft=H[7],rt=H[8],ze=H[9],it=H[10],st=H[11],qe=H[12],Ye=H[13],ht=H[14],je=H[15];w=z[0],ne+=w*Fe,ce+=w*Xe,he+=w*tt,ye+=w*Be,we+=w*et,Ce+=w*Ze,Qe+=w*$e,Oe+=w*ft,Te+=w*rt,Ie+=w*ze,me+=w*it,Re+=w*st,De+=w*qe,ve+=w*Ye,Ne+=w*ht,Se+=w*je,w=z[1],ce+=w*Fe,he+=w*Xe,ye+=w*tt,we+=w*Be,Ce+=w*et,Qe+=w*Ze,Oe+=w*$e,Te+=w*ft,Ie+=w*rt,me+=w*ze,Re+=w*it,De+=w*st,ve+=w*qe,Ne+=w*Ye,Se+=w*ht,be+=w*je,w=z[2],he+=w*Fe,ye+=w*Xe,we+=w*tt,Ce+=w*Be,Qe+=w*et,Oe+=w*Ze,Te+=w*$e,Ie+=w*ft,me+=w*rt,Re+=w*ze,De+=w*it,ve+=w*st,Ne+=w*qe,Se+=w*Ye,be+=w*ht,Le+=w*je,w=z[3],ye+=w*Fe,we+=w*Xe,Ce+=w*tt,Qe+=w*Be,Oe+=w*et,Te+=w*Ze,Ie+=w*$e,me+=w*ft,Re+=w*rt,De+=w*ze,ve+=w*it,Ne+=w*st,Se+=w*qe,be+=w*Ye,Le+=w*ht,Me+=w*je,w=z[4],we+=w*Fe,Ce+=w*Xe,Qe+=w*tt,Oe+=w*Be,Te+=w*et,Ie+=w*Ze,me+=w*$e,Re+=w*ft,De+=w*rt,ve+=w*ze,Ne+=w*it,Se+=w*st,be+=w*qe,Le+=w*Ye,Me+=w*ht,_e+=w*je,w=z[5],Ce+=w*Fe,Qe+=w*Xe,Oe+=w*tt,Te+=w*Be,Ie+=w*et,me+=w*Ze,Re+=w*$e,De+=w*ft,ve+=w*rt,Ne+=w*ze,Se+=w*it,be+=w*st,Le+=w*qe,Me+=w*Ye,_e+=w*ht,He+=w*je,w=z[6],Qe+=w*Fe,Oe+=w*Xe,Te+=w*tt,Ie+=w*Be,me+=w*et,Re+=w*Ze,De+=w*$e,ve+=w*ft,Ne+=w*rt,Se+=w*ze,be+=w*it,Le+=w*st,Me+=w*qe,_e+=w*Ye,He+=w*ht,Ve+=w*je,w=z[7],Oe+=w*Fe,Te+=w*Xe,Ie+=w*tt,me+=w*Be,Re+=w*et,De+=w*Ze,ve+=w*$e,Ne+=w*ft,Se+=w*rt,be+=w*ze,Le+=w*it,Me+=w*st,_e+=w*qe,He+=w*Ye,Ve+=w*ht,Ee+=w*je,w=z[8],Te+=w*Fe,Ie+=w*Xe,me+=w*tt,Re+=w*Be,De+=w*et,ve+=w*Ze,Ne+=w*$e,Se+=w*ft,be+=w*rt,Le+=w*ze,Me+=w*it,_e+=w*st,He+=w*qe,Ve+=w*Ye,Ee+=w*ht,Ke+=w*je,w=z[9],Ie+=w*Fe,me+=w*Xe,Re+=w*tt,De+=w*Be,ve+=w*et,Ne+=w*Ze,Se+=w*$e,be+=w*ft,Le+=w*rt,Me+=w*ze,_e+=w*it,He+=w*st,Ve+=w*qe,Ee+=w*Ye,Ke+=w*ht,ut+=w*je,w=z[10],me+=w*Fe,Re+=w*Xe,De+=w*tt,ve+=w*Be,Ne+=w*et,Se+=w*Ze,be+=w*$e,Le+=w*ft,Me+=w*rt,_e+=w*ze,He+=w*it,Ve+=w*st,Ee+=w*qe,Ke+=w*Ye,ut+=w*ht,Ge+=w*je,w=z[11],Re+=w*Fe,De+=w*Xe,ve+=w*tt,Ne+=w*Be,Se+=w*et,be+=w*Ze,Le+=w*$e,Me+=w*ft,_e+=w*rt,He+=w*ze,Ve+=w*it,Ee+=w*st,Ke+=w*qe,ut+=w*Ye,Ge+=w*ht,_t+=w*je,w=z[12],De+=w*Fe,ve+=w*Xe,Ne+=w*tt,Se+=w*Be,be+=w*et,Le+=w*Ze,Me+=w*$e,_e+=w*ft,He+=w*rt,Ve+=w*ze,Ee+=w*it,Ke+=w*st,ut+=w*qe,Ge+=w*Ye,_t+=w*ht,lt+=w*je,w=z[13],ve+=w*Fe,Ne+=w*Xe,Se+=w*tt,be+=w*Be,Le+=w*et,Me+=w*Ze,_e+=w*$e,He+=w*ft,Ve+=w*rt,Ee+=w*ze,Ke+=w*it,ut+=w*st,Ge+=w*qe,_t+=w*Ye,lt+=w*ht,Je+=w*je,w=z[14],Ne+=w*Fe,Se+=w*Xe,be+=w*tt,Le+=w*Be,Me+=w*et,_e+=w*Ze,He+=w*$e,Ve+=w*ft,Ee+=w*rt,Ke+=w*ze,ut+=w*it,Ge+=w*st,_t+=w*qe,lt+=w*Ye,Je+=w*ht,Et+=w*je,w=z[15],Se+=w*Fe,be+=w*Xe,Le+=w*tt,Me+=w*Be,_e+=w*et,He+=w*Ze,Ve+=w*$e,Ee+=w*ft,Ke+=w*rt,ut+=w*ze,Ge+=w*it,_t+=w*st,lt+=w*qe,Je+=w*Ye,Et+=w*ht,It+=w*je,ne+=38*be,ce+=38*Le,he+=38*Me,ye+=38*_e,we+=38*He,Ce+=38*Ve,Qe+=38*Ee,Oe+=38*Ke,Te+=38*ut,Ie+=38*Ge,me+=38*_t,Re+=38*lt,De+=38*Je,ve+=38*Et,Ne+=38*It,$=1,w=ne+$+65535,$=Math.floor(w/65536),ne=w-$*65536,w=ce+$+65535,$=Math.floor(w/65536),ce=w-$*65536,w=he+$+65535,$=Math.floor(w/65536),he=w-$*65536,w=ye+$+65535,$=Math.floor(w/65536),ye=w-$*65536,w=we+$+65535,$=Math.floor(w/65536),we=w-$*65536,w=Ce+$+65535,$=Math.floor(w/65536),Ce=w-$*65536,w=Qe+$+65535,$=Math.floor(w/65536),Qe=w-$*65536,w=Oe+$+65535,$=Math.floor(w/65536),Oe=w-$*65536,w=Te+$+65535,$=Math.floor(w/65536),Te=w-$*65536,w=Ie+$+65535,$=Math.floor(w/65536),Ie=w-$*65536,w=me+$+65535,$=Math.floor(w/65536),me=w-$*65536,w=Re+$+65535,$=Math.floor(w/65536),Re=w-$*65536,w=De+$+65535,$=Math.floor(w/65536),De=w-$*65536,w=ve+$+65535,$=Math.floor(w/65536),ve=w-$*65536,w=Ne+$+65535,$=Math.floor(w/65536),Ne=w-$*65536,w=Se+$+65535,$=Math.floor(w/65536),Se=w-$*65536,ne+=$-1+37*($-1),$=1,w=ne+$+65535,$=Math.floor(w/65536),ne=w-$*65536,w=ce+$+65535,$=Math.floor(w/65536),ce=w-$*65536,w=he+$+65535,$=Math.floor(w/65536),he=w-$*65536,w=ye+$+65535,$=Math.floor(w/65536),ye=w-$*65536,w=we+$+65535,$=Math.floor(w/65536),we=w-$*65536,w=Ce+$+65535,$=Math.floor(w/65536),Ce=w-$*65536,w=Qe+$+65535,$=Math.floor(w/65536),Qe=w-$*65536,w=Oe+$+65535,$=Math.floor(w/65536),Oe=w-$*65536,w=Te+$+65535,$=Math.floor(w/65536),Te=w-$*65536,w=Ie+$+65535,$=Math.floor(w/65536),Ie=w-$*65536,w=me+$+65535,$=Math.floor(w/65536),me=w-$*65536,w=Re+$+65535,$=Math.floor(w/65536),Re=w-$*65536,w=De+$+65535,$=Math.floor(w/65536),De=w-$*65536,w=ve+$+65535,$=Math.floor(w/65536),ve=w-$*65536,w=Ne+$+65535,$=Math.floor(w/65536),Ne=w-$*65536,w=Se+$+65535,$=Math.floor(w/65536),Se=w-$*65536,ne+=$-1+37*($-1),q[0]=ne,q[1]=ce,q[2]=he,q[3]=ye,q[4]=we,q[5]=Ce,q[6]=Qe,q[7]=Oe,q[8]=Te,q[9]=Ie,q[10]=me,q[11]=Re,q[12]=De,q[13]=ve,q[14]=Ne,q[15]=Se}function B(q,z){x(q,z,z)}function ae(q,z){const H=n();let w;for(w=0;w<16;w++)H[w]=z[w];for(w=253;w>=0;w--)B(H,H),w!==2&&w!==4&&x(H,H,z);for(w=0;w<16;w++)q[w]=H[w]}function le(q,z){const H=n();let w;for(w=0;w<16;w++)H[w]=z[w];for(w=250;w>=0;w--)B(H,H),w!==1&&x(H,H,z);for(w=0;w<16;w++)q[w]=H[w]}function F(q,z){const H=n(),w=n(),$=n(),ne=n(),ce=n(),he=n(),ye=n(),we=n(),Ce=n();G(H,q[1],q[0]),G(Ce,z[1],z[0]),x(H,H,Ce),k(w,q[0],q[1]),k(Ce,z[0],z[1]),x(w,w,Ce),x($,q[3],z[3]),x($,$,p),x(ne,q[2],z[2]),k(ne,ne,ne),G(ce,w,H),G(he,ne,$),k(ye,ne,$),k(we,w,H),x(q[0],ce,he),x(q[1],we,ye),x(q[2],ye,he),x(q[3],ce,we)}function m(q,z,H){for(let w=0;w<4;w++)K(q[w],z[w],H)}function c(q,z){const H=n(),w=n(),$=n();ae($,z[2]),x(H,z[0],$),x(w,z[1],$),W(q,w),q[31]^=Y(H)<<7}function h(q,z,H){O(q[0],f),O(q[1],u),O(q[2],u),O(q[3],f);for(let w=255;w>=0;--w){const $=H[w/8|0]>>(w&7)&1;m(q,z,$),F(z,q),F(q,q),m(q,z,$)}}function v(q,z){const H=[n(),n(),n(),n()];O(H[0],y),O(H[1],A),O(H[2],u),x(H[3],y,A),h(q,H,z)}function _(q){if(q.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const z=(0,t.hash)(q);z[0]&=248,z[31]&=127,z[31]|=64;const H=new Uint8Array(32),w=[n(),n(),n(),n()];v(w,z),c(H,w);const $=new Uint8Array(64);return $.set(q),$.set(H,32),{publicKey:H,secretKey:$}}r.generateKeyPairFromSeed=_;function I(q){const z=(0,e.randomBytes)(32,q),H=_(z);return(0,i.wipe)(z),H}r.generateKeyPair=I;function M(q){if(q.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(q.subarray(32))}r.extractPublicKeyFromSecretKey=M;const S=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function d(q,z){let H,w,$,ne;for(w=63;w>=32;--w){for(H=0,$=w-32,ne=w-12;$>4)*S[$],H=z[$]>>8,z[$]&=255;for($=0;$<32;$++)z[$]-=H*S[$];for(w=0;w<32;w++)z[w+1]+=z[w]>>8,q[w]=z[w]&255}function g(q){const z=new Float64Array(64);for(let H=0;H<64;H++)z[H]=q[H];for(let H=0;H<64;H++)q[H]=0;d(q,z)}function T(q,z){const H=new Float64Array(64),w=[n(),n(),n(),n()],$=(0,t.hash)(q.subarray(0,32));$[0]&=248,$[31]&=127,$[31]|=64;const ne=new Uint8Array(64);ne.set($.subarray(32),32);const ce=new t.SHA512;ce.update(ne.subarray(32)),ce.update(z);const he=ce.digest();ce.clean(),g(he),v(w,he),c(ne,w),ce.reset(),ce.update(ne.subarray(0,32)),ce.update(q.subarray(32)),ce.update(z);const ye=ce.digest();g(ye);for(let we=0;we<32;we++)H[we]=he[we];for(let we=0;we<32;we++)for(let Ce=0;Ce<32;Ce++)H[we+Ce]+=ye[we]*$[Ce];return d(ne.subarray(32),H),ne}r.sign=T;function Z(q,z){const H=n(),w=n(),$=n(),ne=n(),ce=n(),he=n(),ye=n();return O(q[2],u),U(q[1],z),B($,q[1]),x(ne,$,b),G($,$,q[2]),k(ne,q[2],ne),B(ce,ne),B(he,ce),x(ye,he,ce),x(H,ye,$),x(H,H,ne),le(H,H),x(H,H,$),x(H,H,ne),x(H,H,ne),x(q[0],H,ne),B(w,q[0]),x(w,w,ne),j(w,$)&&x(q[0],q[0],R),B(w,q[0]),x(w,w,ne),j(w,$)?-1:(Y(q[0])===z[31]>>7&&G(q[0],f,q[0]),x(q[3],q[0],q[1]),0)}function se(q,z,H){const w=new Uint8Array(32),$=[n(),n(),n(),n()],ne=[n(),n(),n(),n()];if(H.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(Z(ne,q))return!1;const ce=new t.SHA512;ce.update(H.subarray(0,32)),ce.update(q),ce.update(z);const he=ce.digest();return g(he),h($,ne,he),v(ne,H.subarray(32)),F($,ne),c(w,$),!Q(H,w)}r.verify=se;function P(q){let z=[n(),n(),n(),n()];if(Z(z,q))throw new Error("Ed25519: invalid public key");let H=n(),w=n(),$=z[1];k(H,u,$),G(w,u,$),ae(w,w),x(H,H,w);let ne=new Uint8Array(32);return W(ne,H),ne}r.convertPublicKeyToX25519=P;function ee(q){const z=(0,t.hash)(q.subarray(0,32));z[0]&=248,z[31]&=127,z[31]|=64;const H=new Uint8Array(z.subarray(0,32));return(0,i.wipe)(z),H}r.convertSecretKeyToX25519=ee})($0);const q9="EdDSA",L9="JWT",uh=".",zh="base64url",Sb="utf8",Ib="utf8",U9=":",$9="did",z9="key",R1="base58btc",j9="z",k9="K36",H9=32,K9=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),V9=r=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function ga(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return V9(r)}catch{return r}}function vs(r){return typeof r=="string"?r:K9(r)||""}function N1(r){return ga(Er(Ar(r,zh),Sb))}function lh(r){return Er(Ar(vs(r),Sb),zh)}function Mb(r){const e=Ar(k9,R1),t=j9+Er(Yf([e,r]),R1);return[$9,z9,t].join(U9)}function G9(r){return Er(r,zh)}function W9(r){return Ar(r,zh)}function J9(r){return Ar([lh(r.header),lh(r.payload)].join(uh),Ib)}function Y9(r){return[lh(r.header),lh(r.payload),G9(r.signature)].join(uh)}function n0(r){const e=r.split(uh),t=N1(e[0]),i=N1(e[1]),n=W9(e[2]),a=Ar(e.slice(0,2).join(uh),Ib);return{header:t,payload:i,signature:n,data:a}}function C1(r=$s.randomBytes(H9)){return $0.generateKeyPairFromSeed(r)}async function Q9(r,e,t,i,n=xe.fromMiliseconds(Date.now())){const a={alg:q9,typ:L9},f=Mb(i.publicKey),u=n+t,b={iss:f,sub:r,aud:e,iat:n,exp:u},p=J9({header:a,payload:b}),y=$0.sign(i.secretKey,p);return Y9({header:a,payload:b,signature:y})}const X9={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var Z9={};const eA=":";function ac(r){const[e,t]=r.split(eA);return{namespace:e,reference:t}}function T1(r,e=[]){const t=[];return Object.keys(r).forEach(i=>{if(e.length&&!e.includes(i))return;const n=r[i];t.push(...n.accounts)}),t}function Pb(r,e){return r.includes(":")?[r]:e.chains||[]}var tA=Object.defineProperty,D1=Object.getOwnPropertySymbols,rA=Object.prototype.hasOwnProperty,iA=Object.prototype.propertyIsEnumerable,F1=(r,e,t)=>e in r?tA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,B1=(r,e)=>{for(var t in e||(e={}))rA.call(e,t)&&F1(r,t,e[t]);if(D1)for(var t of D1(e))iA.call(e,t)&&F1(r,t,e[t]);return r};const nA="ReactNative",wi={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},sA="js";function dh(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function vo(){return!Ih()&&!!P0()&&navigator.product===nA}function Sc(){return!dh()&&!!P0()&&!!Ih()}function Ic(){return vo()?wi.reactNative:dh()?wi.node:Sc()?wi.browser:wi.unknown}function aA(){var r;try{return vo()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function oA(r,e){let t=dc.parse(r);return t=B1(B1({},t),e),r=dc.stringify(t),r}function Ob(){return qv()||{name:"",description:"",url:"",icons:[""]}}function cA(){if(Ic()===wi.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:t,Version:i}=global.Platform;return[t,i].join("-")}const r=z4();if(r===null)return"unknown";const e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function fA(){var r;const e=Ic();return e===wi.browser?[e,((r=Bv())==null?void 0:r.host)||"unknown"].join(":"):e}function Rb(r,e,t){const i=cA(),n=fA();return[[r,e].join("-"),[sA,t].join("-"),i,n].join("/")}function hA({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:a,useOnCloseEvent:f,bundleId:u}){const b=t.split("?"),p=Rb(r,e,i),y={auth:n,ua:p,projectId:a,useOnCloseEvent:f||void 0,origin:u||void 0},A=oA(b[1]||"",y);return b[0]+"?"+A}function fa(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Nb(r){return Object.fromEntries(r.entries())}function Cb(r){return new Map(Object.entries(r))}function oa(r=xe.FIVE_MINUTES,e){const t=xe.toMiliseconds(r||xe.FIVE_MINUTES);let i,n,a;return{resolve:f=>{a&&i&&(clearTimeout(a),i(f))},reject:f=>{a&&n&&(clearTimeout(a),n(f))},done:()=>new Promise((f,u)=>{a=setTimeout(()=>{u(new Error(e))},t),i=f,n=u})}}function Za(r,e,t){return new Promise(async(i,n)=>{const a=setTimeout(()=>n(new Error(t)),e);try{const f=await r;i(f)}catch(f){n(f)}clearTimeout(a)})}function Tb(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function uA(r){return Tb("topic",r)}function lA(r){return Tb("id",r)}function Db(r){const[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function vr(r,e){return xe.fromMiliseconds(Date.now()+xe.toMiliseconds(r))}function Rs(r){return Date.now()>=xe.toMiliseconds(r)}function St(r,e){return`${r}${e?`:${e}`:""}`}function Qf(r=[],e=[]){return[...new Set([...r,...e])]}async function dA({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const n=typeof t=="string"?JSON.parse(t):t,a=n==null?void 0:n.href;if(typeof a!="string")return;const f=pA(a,r,e),u=Ic();if(u===wi.browser){if(!((i=Ih())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}f.startsWith("https://")||f.startsWith("http://")?window.open(f,"_blank","noreferrer noopener"):window.open(f,vA()?"_blank":"_self","noreferrer noopener")}else u===wi.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(f)}catch(n){console.error(n)}}function pA(r,e,t){const i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){const a=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${a}${bA(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function gA(r,e){let t="";try{if(Sc()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function q1(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function L1(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function z0(){return typeof process<"u"&&Z9.IS_VITEST==="true"}function vA(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function bA(r,e=!1){const t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Fb(r){return Buffer.from(r,"base64").toString("utf-8")}var Bb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function mA(r){var e=r.default;if(typeof e=="function"){var t=function(){return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),t}var qb={exports:{}};/** -* [js-sha3]{@link https://github.com/emn178/js-sha3} -* -* @version 0.8.0 -* @author Chen, Yi-Cyuan [emn178@gmail.com] -* @copyright Chen, Yi-Cyuan 2015-2018 -* @license MIT -*/(function(r){(function(){var e="input is invalid type",t="finalize already called",i=typeof window=="object",n=i?window:{};n.JS_SHA3_NO_WINDOW&&(i=!1);var a=!i&&typeof self=="object",f=!n.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;f?n=Bb:a&&(n=self);var u=!n.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,b=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",p="0123456789abcdef".split(""),y=[31,7936,2031616,520093696],A=[4,1024,262144,67108864],R=[1,256,65536,16777216],O=[6,1536,393216,100663296],N=[0,8,16,24],K=[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],W=[224,256,384,512],Q=[128,256],j=["hex","buffer","arrayBuffer","array","digest"],Y={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(P){return Object.prototype.toString.call(P)==="[object Array]"}),b&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(P){return typeof P=="object"&&P.buffer&&P.buffer.constructor===ArrayBuffer});for(var U=function(P,ee,q){return function(z){return new T(P,ee,P).update(z)[q]()}},k=function(P,ee,q){return function(z,H){return new T(P,ee,H).update(z)[q]()}},G=function(P,ee,q){return function(z,H,w,$){return h["cshake"+P].update(z,H,w,$)[q]()}},x=function(P,ee,q){return function(z,H,w,$){return h["kmac"+P].update(z,H,w,$)[q]()}},B=function(P,ee,q,z){for(var H=0;H>5,this.byteCount=this.blockCount<<2,this.outputBlocks=q>>5,this.extraBytes=(q&31)>>3;for(var z=0;z<50;++z)this.s[z]=0}T.prototype.update=function(P){if(this.finalized)throw new Error(t);var ee,q=typeof P;if(q!=="string"){if(q==="object"){if(P===null)throw new Error(e);if(b&&P.constructor===ArrayBuffer)P=new Uint8Array(P);else if(!Array.isArray(P)&&(!b||!ArrayBuffer.isView(P)))throw new Error(e)}else throw new Error(e);ee=!0}for(var z=this.blocks,H=this.byteCount,w=P.length,$=this.blockCount,ne=0,ce=this.s,he,ye;ne>2]|=P[ne]<>2]|=ye<>2]|=(192|ye>>6)<>2]|=(128|ye&63)<=57344?(z[he>>2]|=(224|ye>>12)<>2]|=(128|ye>>6&63)<>2]|=(128|ye&63)<>2]|=(240|ye>>18)<>2]|=(128|ye>>12&63)<>2]|=(128|ye>>6&63)<>2]|=(128|ye&63)<=H){for(this.start=he-H,this.block=z[$],he=0;he<$;++he)ce[he]^=z[he];se(ce),this.reset=!0}else this.start=he}return this},T.prototype.encode=function(P,ee){var q=P&255,z=1,H=[q];for(P=P>>8,q=P&255;q>0;)H.unshift(q),P=P>>8,q=P&255,++z;return ee?H.push(z):H.unshift(z),this.update(H),H.length},T.prototype.encodeString=function(P){var ee,q=typeof P;if(q!=="string"){if(q==="object"){if(P===null)throw new Error(e);if(b&&P.constructor===ArrayBuffer)P=new Uint8Array(P);else if(!Array.isArray(P)&&(!b||!ArrayBuffer.isView(P)))throw new Error(e)}else throw new Error(e);ee=!0}var z=0,H=P.length;if(ee)z=H;else for(var w=0;w=57344?z+=3:($=65536+(($&1023)<<10|P.charCodeAt(++w)&1023),z+=4)}return z+=this.encode(z*8),this.update(P),z},T.prototype.bytepad=function(P,ee){for(var q=this.encode(ee),z=0;z>2]|=this.padding[ee&3],this.lastByteIndex===this.byteCount)for(P[0]=P[q],ee=1;ee>4&15]+p[ne&15]+p[ne>>12&15]+p[ne>>8&15]+p[ne>>20&15]+p[ne>>16&15]+p[ne>>28&15]+p[ne>>24&15];w%P===0&&(se(ee),H=0)}return z&&(ne=ee[H],$+=p[ne>>4&15]+p[ne&15],z>1&&($+=p[ne>>12&15]+p[ne>>8&15]),z>2&&($+=p[ne>>20&15]+p[ne>>16&15])),$},T.prototype.arrayBuffer=function(){this.finalize();var P=this.blockCount,ee=this.s,q=this.outputBlocks,z=this.extraBytes,H=0,w=0,$=this.outputBits>>3,ne;z?ne=new ArrayBuffer(q+1<<2):ne=new ArrayBuffer($);for(var ce=new Uint32Array(ne);w>8&255,$[ne+2]=ce>>16&255,$[ne+3]=ce>>24&255;w%P===0&&se(ee)}return z&&(ne=w<<2,ce=ee[H],$[ne]=ce&255,z>1&&($[ne+1]=ce>>8&255),z>2&&($[ne+2]=ce>>16&255)),$};function Z(P,ee,q){T.call(this,P,ee,q)}Z.prototype=new T,Z.prototype.finalize=function(){return this.encode(this.outputBits,!0),T.prototype.finalize.call(this)};var se=function(P){var ee,q,z,H,w,$,ne,ce,he,ye,we,Ce,Qe,Oe,Te,Ie,me,Re,De,ve,Ne,Se,be,Le,Me,_e,He,Ve,Ee,Ke,ut,Ge,_t,lt,Je,Et,It,Fe,Xe,tt,Be,et,Ze,$e,ft,rt,ze,it,st,qe,Ye,ht,je,Tt,Dt,at,bt,Cr,Tr,Dr,Fr,Br,er;for(z=0;z<48;z+=2)H=P[0]^P[10]^P[20]^P[30]^P[40],w=P[1]^P[11]^P[21]^P[31]^P[41],$=P[2]^P[12]^P[22]^P[32]^P[42],ne=P[3]^P[13]^P[23]^P[33]^P[43],ce=P[4]^P[14]^P[24]^P[34]^P[44],he=P[5]^P[15]^P[25]^P[35]^P[45],ye=P[6]^P[16]^P[26]^P[36]^P[46],we=P[7]^P[17]^P[27]^P[37]^P[47],Ce=P[8]^P[18]^P[28]^P[38]^P[48],Qe=P[9]^P[19]^P[29]^P[39]^P[49],ee=Ce^($<<1|ne>>>31),q=Qe^(ne<<1|$>>>31),P[0]^=ee,P[1]^=q,P[10]^=ee,P[11]^=q,P[20]^=ee,P[21]^=q,P[30]^=ee,P[31]^=q,P[40]^=ee,P[41]^=q,ee=H^(ce<<1|he>>>31),q=w^(he<<1|ce>>>31),P[2]^=ee,P[3]^=q,P[12]^=ee,P[13]^=q,P[22]^=ee,P[23]^=q,P[32]^=ee,P[33]^=q,P[42]^=ee,P[43]^=q,ee=$^(ye<<1|we>>>31),q=ne^(we<<1|ye>>>31),P[4]^=ee,P[5]^=q,P[14]^=ee,P[15]^=q,P[24]^=ee,P[25]^=q,P[34]^=ee,P[35]^=q,P[44]^=ee,P[45]^=q,ee=ce^(Ce<<1|Qe>>>31),q=he^(Qe<<1|Ce>>>31),P[6]^=ee,P[7]^=q,P[16]^=ee,P[17]^=q,P[26]^=ee,P[27]^=q,P[36]^=ee,P[37]^=q,P[46]^=ee,P[47]^=q,ee=ye^(H<<1|w>>>31),q=we^(w<<1|H>>>31),P[8]^=ee,P[9]^=q,P[18]^=ee,P[19]^=q,P[28]^=ee,P[29]^=q,P[38]^=ee,P[39]^=q,P[48]^=ee,P[49]^=q,Oe=P[0],Te=P[1],rt=P[11]<<4|P[10]>>>28,ze=P[10]<<4|P[11]>>>28,Ve=P[20]<<3|P[21]>>>29,Ee=P[21]<<3|P[20]>>>29,Dr=P[31]<<9|P[30]>>>23,Fr=P[30]<<9|P[31]>>>23,et=P[40]<<18|P[41]>>>14,Ze=P[41]<<18|P[40]>>>14,lt=P[2]<<1|P[3]>>>31,Je=P[3]<<1|P[2]>>>31,Ie=P[13]<<12|P[12]>>>20,me=P[12]<<12|P[13]>>>20,it=P[22]<<10|P[23]>>>22,st=P[23]<<10|P[22]>>>22,Ke=P[33]<<13|P[32]>>>19,ut=P[32]<<13|P[33]>>>19,Br=P[42]<<2|P[43]>>>30,er=P[43]<<2|P[42]>>>30,Tt=P[5]<<30|P[4]>>>2,Dt=P[4]<<30|P[5]>>>2,Et=P[14]<<6|P[15]>>>26,It=P[15]<<6|P[14]>>>26,Re=P[25]<<11|P[24]>>>21,De=P[24]<<11|P[25]>>>21,qe=P[34]<<15|P[35]>>>17,Ye=P[35]<<15|P[34]>>>17,Ge=P[45]<<29|P[44]>>>3,_t=P[44]<<29|P[45]>>>3,Le=P[6]<<28|P[7]>>>4,Me=P[7]<<28|P[6]>>>4,at=P[17]<<23|P[16]>>>9,bt=P[16]<<23|P[17]>>>9,Fe=P[26]<<25|P[27]>>>7,Xe=P[27]<<25|P[26]>>>7,ve=P[36]<<21|P[37]>>>11,Ne=P[37]<<21|P[36]>>>11,ht=P[47]<<24|P[46]>>>8,je=P[46]<<24|P[47]>>>8,$e=P[8]<<27|P[9]>>>5,ft=P[9]<<27|P[8]>>>5,_e=P[18]<<20|P[19]>>>12,He=P[19]<<20|P[18]>>>12,Cr=P[29]<<7|P[28]>>>25,Tr=P[28]<<7|P[29]>>>25,tt=P[38]<<8|P[39]>>>24,Be=P[39]<<8|P[38]>>>24,Se=P[48]<<14|P[49]>>>18,be=P[49]<<14|P[48]>>>18,P[0]=Oe^~Ie&Re,P[1]=Te^~me&De,P[10]=Le^~_e&Ve,P[11]=Me^~He&Ee,P[20]=lt^~Et&Fe,P[21]=Je^~It&Xe,P[30]=$e^~rt&it,P[31]=ft^~ze&st,P[40]=Tt^~at&Cr,P[41]=Dt^~bt&Tr,P[2]=Ie^~Re&ve,P[3]=me^~De&Ne,P[12]=_e^~Ve&Ke,P[13]=He^~Ee&ut,P[22]=Et^~Fe&tt,P[23]=It^~Xe&Be,P[32]=rt^~it&qe,P[33]=ze^~st&Ye,P[42]=at^~Cr&Dr,P[43]=bt^~Tr&Fr,P[4]=Re^~ve&Se,P[5]=De^~Ne&be,P[14]=Ve^~Ke&Ge,P[15]=Ee^~ut&_t,P[24]=Fe^~tt&et,P[25]=Xe^~Be&Ze,P[34]=it^~qe&ht,P[35]=st^~Ye&je,P[44]=Cr^~Dr&Br,P[45]=Tr^~Fr&er,P[6]=ve^~Se&Oe,P[7]=Ne^~be&Te,P[16]=Ke^~Ge&Le,P[17]=ut^~_t&Me,P[26]=tt^~et<,P[27]=Be^~Ze&Je,P[36]=qe^~ht&$e,P[37]=Ye^~je&ft,P[46]=Dr^~Br&Tt,P[47]=Fr^~er&Dt,P[8]=Se^~Oe&Ie,P[9]=be^~Te&me,P[18]=Ge^~Le&_e,P[19]=_t^~Me&He,P[28]=et^~lt&Et,P[29]=Ze^~Je&It,P[38]=ht^~$e&rt,P[39]=je^~ft&ze,P[48]=Br^~Tt&at,P[49]=er^~Dt&bt,P[0]^=K[z],P[1]^=K[z+1]};if(u)r.exports=h;else for(_=0;_{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(r){return r.message}return null}const j1=_A();var s0;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(s0||(s0={}));var hn;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(hn||(hn={}));const k1="0123456789abcdef";let Or=class gr{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const i=e.toLowerCase();Xf[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(z1>Xf[i])&&console.log.apply(console,t)}debug(...e){this._log(gr.levels.DEBUG,e)}info(...e){this._log(gr.levels.INFO,e)}warn(...e){this._log(gr.levels.WARNING,e)}makeError(e,t,i){if($1)return this.makeError("censored error",t,{});t||(t=gr.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(b=>{const p=i[b];try{if(p instanceof Uint8Array){let y="";for(let A=0;A>4],y+=k1[p[A]&15];n.push(b+"=Uint8Array(0x"+y+")")}else n.push(b+"="+JSON.stringify(p))}catch{n.push(b+"="+JSON.stringify(i[b].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);const a=e;let f="";switch(t){case hn.NUMERIC_FAULT:{f="NUMERIC_FAULT";const b=e;switch(b){case"overflow":case"underflow":case"division-by-zero":f+="-"+b;break;case"negative-power":case"negative-width":f+="-unsupported";break;case"unbound-bitwise-result":f+="-unbound-result";break}break}case hn.CALL_EXCEPTION:case hn.INSUFFICIENT_FUNDS:case hn.MISSING_NEW:case hn.NONCE_EXPIRED:case hn.REPLACEMENT_UNDERPRICED:case hn.TRANSACTION_REPLACED:case hn.UNPREDICTABLE_GAS_LIMIT:f=t;break}f&&(e+=" [ See: https://links.ethers.org/v5-errors-"+f+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const u=new Error(e);return u.reason=a,u.code=t,Object.keys(i).forEach(function(b){u[b]=i[b]}),u}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,gr.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){j1&&this.throwError("platform missing String.prototype.normalize",gr.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:j1})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,gr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,gr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,gr.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",gr.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",gr.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",gr.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return bl||(bl=new gr(wA)),bl}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",gr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),U1){if(!e)return;this.globalLogger().throwError("error censorship permanent",gr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}$1=!!e,U1=!!t}static setLogLevel(e){const t=Xf[e.toLowerCase()];if(t==null){gr.globalLogger().warn("invalid log level - "+e);return}z1=t}static from(e){return new gr(e)}};Or.errors=hn,Or.levels=s0;const AA="bytes/5.7.0",cr=new Or(AA);function Lb(r){return!!r.toHexString}function eo(r){return r.slice||(r.slice=function(){const e=Array.prototype.slice.call(arguments);return eo(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function EA(r){return _i(r)&&!(r.length%2)||bo(r)}function H1(r){return typeof r=="number"&&r==r&&r%1===0}function bo(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!H1(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function ir(r,e){if(e||(e={}),typeof r=="number"){cr.checkSafeUint53(r,"invalid arrayify value");const t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),eo(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Lb(r)&&(r=r.toHexString()),_i(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":cr.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let n=0;nir(n)),t=e.reduce((n,a)=>n+a.length,0),i=new Uint8Array(t);return e.reduce((n,a)=>(i.set(a,n),n+a.length),0),eo(i)}function SA(r,e){r=ir(r),r.length>e&&cr.throwArgumentError("value out of range","value",arguments[0]);const t=new Uint8Array(e);return t.set(r,e-r.length),eo(t)}function _i(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}const ml="0123456789abcdef";function ci(r,e){if(e||(e={}),typeof r=="number"){cr.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=ml[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Lb(r))return r.toHexString();if(_i(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":cr.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(bo(r)){let t="0x";for(let i=0;i>4]+ml[n&15]}return t}return cr.throwArgumentError("invalid hexlify value","value",r)}function IA(r){if(typeof r!="string")r=ci(r);else if(!_i(r)||r.length%2)return null;return(r.length-2)/2}function K1(r,e,t){return typeof r!="string"?r=ci(r):(!_i(r)||r.length%2)&&cr.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Dn(r,e){for(typeof r!="string"?r=ci(r):_i(r)||cr.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&cr.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function Ub(r){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(EA(r)){let t=ir(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=ci(t.slice(0,32)),e.s=ci(t.slice(32,64))):t.length===65?(e.r=ci(t.slice(0,32)),e.s=ci(t.slice(32,64)),e.v=t[64]):cr.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:cr.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=ci(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){const n=SA(ir(e._vs),32);e._vs=ci(n);const a=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=a:e.recoveryParam!==a&&cr.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;const f=ci(n);e.s==null?e.s=f:e.s!==f&&cr.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?cr.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&cr.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!_i(e.r)?cr.throwArgumentError("signature missing or invalid r","signature",r):e.r=Dn(e.r,32),e.s==null||!_i(e.s)?cr.throwArgumentError("signature missing or invalid s","signature",r):e.s=Dn(e.s,32);const t=ir(e.s);t[0]>=128&&cr.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);const i=ci(t);e._vs&&(_i(e._vs)||cr.throwArgumentError("signature invalid _vs","signature",r),e._vs=Dn(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&cr.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function j0(r){return"0x"+yA.keccak_256(ir(r))}var $b={exports:{}},MA={},PA=Object.freeze({__proto__:null,default:MA}),OA=mA(PA);(function(r){(function(e,t){function i(c,h){if(!c)throw new Error(h||"Assertion failed")}function n(c,h){c.super_=h;var v=function(){};v.prototype=h.prototype,c.prototype=new v,c.prototype.constructor=c}function a(c,h,v){if(a.isBN(c))return c;this.negative=0,this.words=null,this.length=0,this.red=null,c!==null&&((h==="le"||h==="be")&&(v=h,h=10),this._init(c||0,h||10,v||"be"))}typeof e=="object"?e.exports=a:t.BN=a,a.BN=a,a.wordSize=26;var f;try{typeof window<"u"&&typeof window.Buffer<"u"?f=window.Buffer:f=OA.Buffer}catch{}a.isBN=function(c){return c instanceof a?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===a.wordSize&&Array.isArray(c.words)},a.max=function(c,h){return c.cmp(h)>0?c:h},a.min=function(c,h){return c.cmp(h)<0?c:h},a.prototype._init=function(c,h,v){if(typeof c=="number")return this._initNumber(c,h,v);if(typeof c=="object")return this._initArray(c,h,v);h==="hex"&&(h=16),i(h===(h|0)&&h>=2&&h<=36),c=c.toString().replace(/\s+/g,"");var _=0;c[0]==="-"&&(_++,this.negative=1),_=0;_-=3)M=c[_]|c[_-1]<<8|c[_-2]<<16,this.words[I]|=M<>>26-S&67108863,S+=24,S>=26&&(S-=26,I++);else if(v==="le")for(_=0,I=0;_>>26-S&67108863,S+=24,S>=26&&(S-=26,I++);return this._strip()};function u(c,h){var v=c.charCodeAt(h);if(v>=48&&v<=57)return v-48;if(v>=65&&v<=70)return v-55;if(v>=97&&v<=102)return v-87;i(!1,"Invalid character in "+c)}function b(c,h,v){var _=u(c,v);return v-1>=h&&(_|=u(c,v-1)<<4),_}a.prototype._parseHex=function(c,h,v){this.length=Math.ceil((c.length-h)/6),this.words=new Array(this.length);for(var _=0;_=h;_-=2)S=b(c,h,_)<=18?(I-=18,M+=1,this.words[M]|=S>>>26):I+=8;else{var d=c.length-h;for(_=d%2===0?h+1:h;_=18?(I-=18,M+=1,this.words[M]|=S>>>26):I+=8}this._strip()};function p(c,h,v,_){for(var I=0,M=0,S=Math.min(c.length,v),d=h;d=49?M=g-49+10:g>=17?M=g-17+10:M=g,i(g>=0&&M<_,"Invalid character"),I+=M}return I}a.prototype._parseBase=function(c,h,v){this.words=[0],this.length=1;for(var _=0,I=1;I<=67108863;I*=h)_++;_--,I=I/h|0;for(var M=c.length-v,S=M%_,d=Math.min(M,M-S)+v,g=0,T=v;T1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=A}catch{a.prototype.inspect=A}else a.prototype.inspect=A;function A(){return(this.red?""}var R=["","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"],O=[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],N=[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];a.prototype.toString=function(c,h){c=c||10,h=h|0||1;var v;if(c===16||c==="hex"){v="";for(var _=0,I=0,M=0;M>>24-_&16777215,_+=2,_>=26&&(_-=26,M--),I!==0||M!==this.length-1?v=R[6-d.length]+d+v:v=d+v}for(I!==0&&(v=I.toString(16)+v);v.length%h!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(c===(c|0)&&c>=2&&c<=36){var g=O[c],T=N[c];v="";var Z=this.clone();for(Z.negative=0;!Z.isZero();){var se=Z.modrn(T).toString(c);Z=Z.idivn(T),Z.isZero()?v=se+v:v=R[g-se.length]+se+v}for(this.isZero()&&(v="0"+v);v.length%h!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},a.prototype.toJSON=function(){return this.toString(16,2)},f&&(a.prototype.toBuffer=function(c,h){return this.toArrayLike(f,c,h)}),a.prototype.toArray=function(c,h){return this.toArrayLike(Array,c,h)};var K=function(c,h){return c.allocUnsafe?c.allocUnsafe(h):new c(h)};a.prototype.toArrayLike=function(c,h,v){this._strip();var _=this.byteLength(),I=v||Math.max(1,_);i(_<=I,"byte array longer than desired length"),i(I>0,"Requested array length <= 0");var M=K(c,I),S=h==="le"?"LE":"BE";return this["_toArrayLike"+S](M,_),M},a.prototype._toArrayLikeLE=function(c,h){for(var v=0,_=0,I=0,M=0;I>8&255),v>16&255),M===6?(v>24&255),_=0,M=0):(_=S>>>24,M+=2)}if(v=0&&(c[v--]=S>>8&255),v>=0&&(c[v--]=S>>16&255),M===6?(v>=0&&(c[v--]=S>>24&255),_=0,M=0):(_=S>>>24,M+=2)}if(v>=0)for(c[v--]=_;v>=0;)c[v--]=0},Math.clz32?a.prototype._countBits=function(c){return 32-Math.clz32(c)}:a.prototype._countBits=function(c){var h=c,v=0;return h>=4096&&(v+=13,h>>>=13),h>=64&&(v+=7,h>>>=7),h>=8&&(v+=4,h>>>=4),h>=2&&(v+=2,h>>>=2),v+h},a.prototype._zeroBits=function(c){if(c===0)return 26;var h=c,v=0;return h&8191||(v+=13,h>>>=13),h&127||(v+=7,h>>>=7),h&15||(v+=4,h>>>=4),h&3||(v+=2,h>>>=2),h&1||v++,v},a.prototype.bitLength=function(){var c=this.words[this.length-1],h=this._countBits(c);return(this.length-1)*26+h};function W(c){for(var h=new Array(c.bitLength()),v=0;v>>I&1}return h}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,h=0;hc.length?this.clone().ior(c):c.clone().ior(this)},a.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},a.prototype.iuand=function(c){var h;this.length>c.length?h=c:h=this;for(var v=0;vc.length?this.clone().iand(c):c.clone().iand(this)},a.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},a.prototype.iuxor=function(c){var h,v;this.length>c.length?(h=this,v=c):(h=c,v=this);for(var _=0;_c.length?this.clone().ixor(c):c.clone().ixor(this)},a.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},a.prototype.inotn=function(c){i(typeof c=="number"&&c>=0);var h=Math.ceil(c/26)|0,v=c%26;this._expand(h),v>0&&h--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-v),this._strip()},a.prototype.notn=function(c){return this.clone().inotn(c)},a.prototype.setn=function(c,h){i(typeof c=="number"&&c>=0);var v=c/26|0,_=c%26;return this._expand(v+1),h?this.words[v]=this.words[v]|1<<_:this.words[v]=this.words[v]&~(1<<_),this._strip()},a.prototype.iadd=function(c){var h;if(this.negative!==0&&c.negative===0)return this.negative=0,h=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,h=this.isub(c),c.negative=1,h._normSign();var v,_;this.length>c.length?(v=this,_=c):(v=c,_=this);for(var I=0,M=0;M<_.length;M++)h=(v.words[M]|0)+(_.words[M]|0)+I,this.words[M]=h&67108863,I=h>>>26;for(;I!==0&&M>>26;if(this.length=v.length,I!==0)this.words[this.length]=I,this.length++;else if(v!==this)for(;Mc.length?this.clone().iadd(c):c.clone().iadd(this)},a.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var h=this.iadd(c);return c.negative=1,h._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var v=this.cmp(c);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,I;v>0?(_=this,I=c):(_=c,I=this);for(var M=0,S=0;S>26,this.words[S]=h&67108863;for(;M!==0&&S<_.length;S++)h=(_.words[S]|0)+M,M=h>>26,this.words[S]=h&67108863;if(M===0&&S<_.length&&_!==this)for(;S<_.length;S++)this.words[S]=_.words[S];return this.length=Math.max(this.length,S),_!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(c){return this.clone().isub(c)};function Q(c,h,v){v.negative=h.negative^c.negative;var _=c.length+h.length|0;v.length=_,_=_-1|0;var I=c.words[0]|0,M=h.words[0]|0,S=I*M,d=S&67108863,g=S/67108864|0;v.words[0]=d;for(var T=1;T<_;T++){for(var Z=g>>>26,se=g&67108863,P=Math.min(T,h.length-1),ee=Math.max(0,T-c.length+1);ee<=P;ee++){var q=T-ee|0;I=c.words[q]|0,M=h.words[ee]|0,S=I*M+se,Z+=S/67108864|0,se=S&67108863}v.words[T]=se|0,g=Z|0}return g!==0?v.words[T]=g|0:v.length--,v._strip()}var j=function(c,h,v){var _=c.words,I=h.words,M=v.words,S=0,d,g,T,Z=_[0]|0,se=Z&8191,P=Z>>>13,ee=_[1]|0,q=ee&8191,z=ee>>>13,H=_[2]|0,w=H&8191,$=H>>>13,ne=_[3]|0,ce=ne&8191,he=ne>>>13,ye=_[4]|0,we=ye&8191,Ce=ye>>>13,Qe=_[5]|0,Oe=Qe&8191,Te=Qe>>>13,Ie=_[6]|0,me=Ie&8191,Re=Ie>>>13,De=_[7]|0,ve=De&8191,Ne=De>>>13,Se=_[8]|0,be=Se&8191,Le=Se>>>13,Me=_[9]|0,_e=Me&8191,He=Me>>>13,Ve=I[0]|0,Ee=Ve&8191,Ke=Ve>>>13,ut=I[1]|0,Ge=ut&8191,_t=ut>>>13,lt=I[2]|0,Je=lt&8191,Et=lt>>>13,It=I[3]|0,Fe=It&8191,Xe=It>>>13,tt=I[4]|0,Be=tt&8191,et=tt>>>13,Ze=I[5]|0,$e=Ze&8191,ft=Ze>>>13,rt=I[6]|0,ze=rt&8191,it=rt>>>13,st=I[7]|0,qe=st&8191,Ye=st>>>13,ht=I[8]|0,je=ht&8191,Tt=ht>>>13,Dt=I[9]|0,at=Dt&8191,bt=Dt>>>13;v.negative=c.negative^h.negative,v.length=19,d=Math.imul(se,Ee),g=Math.imul(se,Ke),g=g+Math.imul(P,Ee)|0,T=Math.imul(P,Ke);var Cr=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,d=Math.imul(q,Ee),g=Math.imul(q,Ke),g=g+Math.imul(z,Ee)|0,T=Math.imul(z,Ke),d=d+Math.imul(se,Ge)|0,g=g+Math.imul(se,_t)|0,g=g+Math.imul(P,Ge)|0,T=T+Math.imul(P,_t)|0;var Tr=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Tr>>>26)|0,Tr&=67108863,d=Math.imul(w,Ee),g=Math.imul(w,Ke),g=g+Math.imul($,Ee)|0,T=Math.imul($,Ke),d=d+Math.imul(q,Ge)|0,g=g+Math.imul(q,_t)|0,g=g+Math.imul(z,Ge)|0,T=T+Math.imul(z,_t)|0,d=d+Math.imul(se,Je)|0,g=g+Math.imul(se,Et)|0,g=g+Math.imul(P,Je)|0,T=T+Math.imul(P,Et)|0;var Dr=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Dr>>>26)|0,Dr&=67108863,d=Math.imul(ce,Ee),g=Math.imul(ce,Ke),g=g+Math.imul(he,Ee)|0,T=Math.imul(he,Ke),d=d+Math.imul(w,Ge)|0,g=g+Math.imul(w,_t)|0,g=g+Math.imul($,Ge)|0,T=T+Math.imul($,_t)|0,d=d+Math.imul(q,Je)|0,g=g+Math.imul(q,Et)|0,g=g+Math.imul(z,Je)|0,T=T+Math.imul(z,Et)|0,d=d+Math.imul(se,Fe)|0,g=g+Math.imul(se,Xe)|0,g=g+Math.imul(P,Fe)|0,T=T+Math.imul(P,Xe)|0;var Fr=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Fr>>>26)|0,Fr&=67108863,d=Math.imul(we,Ee),g=Math.imul(we,Ke),g=g+Math.imul(Ce,Ee)|0,T=Math.imul(Ce,Ke),d=d+Math.imul(ce,Ge)|0,g=g+Math.imul(ce,_t)|0,g=g+Math.imul(he,Ge)|0,T=T+Math.imul(he,_t)|0,d=d+Math.imul(w,Je)|0,g=g+Math.imul(w,Et)|0,g=g+Math.imul($,Je)|0,T=T+Math.imul($,Et)|0,d=d+Math.imul(q,Fe)|0,g=g+Math.imul(q,Xe)|0,g=g+Math.imul(z,Fe)|0,T=T+Math.imul(z,Xe)|0,d=d+Math.imul(se,Be)|0,g=g+Math.imul(se,et)|0,g=g+Math.imul(P,Be)|0,T=T+Math.imul(P,et)|0;var Br=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Br>>>26)|0,Br&=67108863,d=Math.imul(Oe,Ee),g=Math.imul(Oe,Ke),g=g+Math.imul(Te,Ee)|0,T=Math.imul(Te,Ke),d=d+Math.imul(we,Ge)|0,g=g+Math.imul(we,_t)|0,g=g+Math.imul(Ce,Ge)|0,T=T+Math.imul(Ce,_t)|0,d=d+Math.imul(ce,Je)|0,g=g+Math.imul(ce,Et)|0,g=g+Math.imul(he,Je)|0,T=T+Math.imul(he,Et)|0,d=d+Math.imul(w,Fe)|0,g=g+Math.imul(w,Xe)|0,g=g+Math.imul($,Fe)|0,T=T+Math.imul($,Xe)|0,d=d+Math.imul(q,Be)|0,g=g+Math.imul(q,et)|0,g=g+Math.imul(z,Be)|0,T=T+Math.imul(z,et)|0,d=d+Math.imul(se,$e)|0,g=g+Math.imul(se,ft)|0,g=g+Math.imul(P,$e)|0,T=T+Math.imul(P,ft)|0;var er=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(er>>>26)|0,er&=67108863,d=Math.imul(me,Ee),g=Math.imul(me,Ke),g=g+Math.imul(Re,Ee)|0,T=Math.imul(Re,Ke),d=d+Math.imul(Oe,Ge)|0,g=g+Math.imul(Oe,_t)|0,g=g+Math.imul(Te,Ge)|0,T=T+Math.imul(Te,_t)|0,d=d+Math.imul(we,Je)|0,g=g+Math.imul(we,Et)|0,g=g+Math.imul(Ce,Je)|0,T=T+Math.imul(Ce,Et)|0,d=d+Math.imul(ce,Fe)|0,g=g+Math.imul(ce,Xe)|0,g=g+Math.imul(he,Fe)|0,T=T+Math.imul(he,Xe)|0,d=d+Math.imul(w,Be)|0,g=g+Math.imul(w,et)|0,g=g+Math.imul($,Be)|0,T=T+Math.imul($,et)|0,d=d+Math.imul(q,$e)|0,g=g+Math.imul(q,ft)|0,g=g+Math.imul(z,$e)|0,T=T+Math.imul(z,ft)|0,d=d+Math.imul(se,ze)|0,g=g+Math.imul(se,it)|0,g=g+Math.imul(P,ze)|0,T=T+Math.imul(P,it)|0;var Qr=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Qr>>>26)|0,Qr&=67108863,d=Math.imul(ve,Ee),g=Math.imul(ve,Ke),g=g+Math.imul(Ne,Ee)|0,T=Math.imul(Ne,Ke),d=d+Math.imul(me,Ge)|0,g=g+Math.imul(me,_t)|0,g=g+Math.imul(Re,Ge)|0,T=T+Math.imul(Re,_t)|0,d=d+Math.imul(Oe,Je)|0,g=g+Math.imul(Oe,Et)|0,g=g+Math.imul(Te,Je)|0,T=T+Math.imul(Te,Et)|0,d=d+Math.imul(we,Fe)|0,g=g+Math.imul(we,Xe)|0,g=g+Math.imul(Ce,Fe)|0,T=T+Math.imul(Ce,Xe)|0,d=d+Math.imul(ce,Be)|0,g=g+Math.imul(ce,et)|0,g=g+Math.imul(he,Be)|0,T=T+Math.imul(he,et)|0,d=d+Math.imul(w,$e)|0,g=g+Math.imul(w,ft)|0,g=g+Math.imul($,$e)|0,T=T+Math.imul($,ft)|0,d=d+Math.imul(q,ze)|0,g=g+Math.imul(q,it)|0,g=g+Math.imul(z,ze)|0,T=T+Math.imul(z,it)|0,d=d+Math.imul(se,qe)|0,g=g+Math.imul(se,Ye)|0,g=g+Math.imul(P,qe)|0,T=T+Math.imul(P,Ye)|0;var Gi=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Gi>>>26)|0,Gi&=67108863,d=Math.imul(be,Ee),g=Math.imul(be,Ke),g=g+Math.imul(Le,Ee)|0,T=Math.imul(Le,Ke),d=d+Math.imul(ve,Ge)|0,g=g+Math.imul(ve,_t)|0,g=g+Math.imul(Ne,Ge)|0,T=T+Math.imul(Ne,_t)|0,d=d+Math.imul(me,Je)|0,g=g+Math.imul(me,Et)|0,g=g+Math.imul(Re,Je)|0,T=T+Math.imul(Re,Et)|0,d=d+Math.imul(Oe,Fe)|0,g=g+Math.imul(Oe,Xe)|0,g=g+Math.imul(Te,Fe)|0,T=T+Math.imul(Te,Xe)|0,d=d+Math.imul(we,Be)|0,g=g+Math.imul(we,et)|0,g=g+Math.imul(Ce,Be)|0,T=T+Math.imul(Ce,et)|0,d=d+Math.imul(ce,$e)|0,g=g+Math.imul(ce,ft)|0,g=g+Math.imul(he,$e)|0,T=T+Math.imul(he,ft)|0,d=d+Math.imul(w,ze)|0,g=g+Math.imul(w,it)|0,g=g+Math.imul($,ze)|0,T=T+Math.imul($,it)|0,d=d+Math.imul(q,qe)|0,g=g+Math.imul(q,Ye)|0,g=g+Math.imul(z,qe)|0,T=T+Math.imul(z,Ye)|0,d=d+Math.imul(se,je)|0,g=g+Math.imul(se,Tt)|0,g=g+Math.imul(P,je)|0,T=T+Math.imul(P,Tt)|0;var Xr=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,d=Math.imul(_e,Ee),g=Math.imul(_e,Ke),g=g+Math.imul(He,Ee)|0,T=Math.imul(He,Ke),d=d+Math.imul(be,Ge)|0,g=g+Math.imul(be,_t)|0,g=g+Math.imul(Le,Ge)|0,T=T+Math.imul(Le,_t)|0,d=d+Math.imul(ve,Je)|0,g=g+Math.imul(ve,Et)|0,g=g+Math.imul(Ne,Je)|0,T=T+Math.imul(Ne,Et)|0,d=d+Math.imul(me,Fe)|0,g=g+Math.imul(me,Xe)|0,g=g+Math.imul(Re,Fe)|0,T=T+Math.imul(Re,Xe)|0,d=d+Math.imul(Oe,Be)|0,g=g+Math.imul(Oe,et)|0,g=g+Math.imul(Te,Be)|0,T=T+Math.imul(Te,et)|0,d=d+Math.imul(we,$e)|0,g=g+Math.imul(we,ft)|0,g=g+Math.imul(Ce,$e)|0,T=T+Math.imul(Ce,ft)|0,d=d+Math.imul(ce,ze)|0,g=g+Math.imul(ce,it)|0,g=g+Math.imul(he,ze)|0,T=T+Math.imul(he,it)|0,d=d+Math.imul(w,qe)|0,g=g+Math.imul(w,Ye)|0,g=g+Math.imul($,qe)|0,T=T+Math.imul($,Ye)|0,d=d+Math.imul(q,je)|0,g=g+Math.imul(q,Tt)|0,g=g+Math.imul(z,je)|0,T=T+Math.imul(z,Tt)|0,d=d+Math.imul(se,at)|0,g=g+Math.imul(se,bt)|0,g=g+Math.imul(P,at)|0,T=T+Math.imul(P,bt)|0;var Wi=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Wi>>>26)|0,Wi&=67108863,d=Math.imul(_e,Ge),g=Math.imul(_e,_t),g=g+Math.imul(He,Ge)|0,T=Math.imul(He,_t),d=d+Math.imul(be,Je)|0,g=g+Math.imul(be,Et)|0,g=g+Math.imul(Le,Je)|0,T=T+Math.imul(Le,Et)|0,d=d+Math.imul(ve,Fe)|0,g=g+Math.imul(ve,Xe)|0,g=g+Math.imul(Ne,Fe)|0,T=T+Math.imul(Ne,Xe)|0,d=d+Math.imul(me,Be)|0,g=g+Math.imul(me,et)|0,g=g+Math.imul(Re,Be)|0,T=T+Math.imul(Re,et)|0,d=d+Math.imul(Oe,$e)|0,g=g+Math.imul(Oe,ft)|0,g=g+Math.imul(Te,$e)|0,T=T+Math.imul(Te,ft)|0,d=d+Math.imul(we,ze)|0,g=g+Math.imul(we,it)|0,g=g+Math.imul(Ce,ze)|0,T=T+Math.imul(Ce,it)|0,d=d+Math.imul(ce,qe)|0,g=g+Math.imul(ce,Ye)|0,g=g+Math.imul(he,qe)|0,T=T+Math.imul(he,Ye)|0,d=d+Math.imul(w,je)|0,g=g+Math.imul(w,Tt)|0,g=g+Math.imul($,je)|0,T=T+Math.imul($,Tt)|0,d=d+Math.imul(q,at)|0,g=g+Math.imul(q,bt)|0,g=g+Math.imul(z,at)|0,T=T+Math.imul(z,bt)|0;var Ji=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Ji>>>26)|0,Ji&=67108863,d=Math.imul(_e,Je),g=Math.imul(_e,Et),g=g+Math.imul(He,Je)|0,T=Math.imul(He,Et),d=d+Math.imul(be,Fe)|0,g=g+Math.imul(be,Xe)|0,g=g+Math.imul(Le,Fe)|0,T=T+Math.imul(Le,Xe)|0,d=d+Math.imul(ve,Be)|0,g=g+Math.imul(ve,et)|0,g=g+Math.imul(Ne,Be)|0,T=T+Math.imul(Ne,et)|0,d=d+Math.imul(me,$e)|0,g=g+Math.imul(me,ft)|0,g=g+Math.imul(Re,$e)|0,T=T+Math.imul(Re,ft)|0,d=d+Math.imul(Oe,ze)|0,g=g+Math.imul(Oe,it)|0,g=g+Math.imul(Te,ze)|0,T=T+Math.imul(Te,it)|0,d=d+Math.imul(we,qe)|0,g=g+Math.imul(we,Ye)|0,g=g+Math.imul(Ce,qe)|0,T=T+Math.imul(Ce,Ye)|0,d=d+Math.imul(ce,je)|0,g=g+Math.imul(ce,Tt)|0,g=g+Math.imul(he,je)|0,T=T+Math.imul(he,Tt)|0,d=d+Math.imul(w,at)|0,g=g+Math.imul(w,bt)|0,g=g+Math.imul($,at)|0,T=T+Math.imul($,bt)|0;var Zr=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,d=Math.imul(_e,Fe),g=Math.imul(_e,Xe),g=g+Math.imul(He,Fe)|0,T=Math.imul(He,Xe),d=d+Math.imul(be,Be)|0,g=g+Math.imul(be,et)|0,g=g+Math.imul(Le,Be)|0,T=T+Math.imul(Le,et)|0,d=d+Math.imul(ve,$e)|0,g=g+Math.imul(ve,ft)|0,g=g+Math.imul(Ne,$e)|0,T=T+Math.imul(Ne,ft)|0,d=d+Math.imul(me,ze)|0,g=g+Math.imul(me,it)|0,g=g+Math.imul(Re,ze)|0,T=T+Math.imul(Re,it)|0,d=d+Math.imul(Oe,qe)|0,g=g+Math.imul(Oe,Ye)|0,g=g+Math.imul(Te,qe)|0,T=T+Math.imul(Te,Ye)|0,d=d+Math.imul(we,je)|0,g=g+Math.imul(we,Tt)|0,g=g+Math.imul(Ce,je)|0,T=T+Math.imul(Ce,Tt)|0,d=d+Math.imul(ce,at)|0,g=g+Math.imul(ce,bt)|0,g=g+Math.imul(he,at)|0,T=T+Math.imul(he,bt)|0;var Si=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Si>>>26)|0,Si&=67108863,d=Math.imul(_e,Be),g=Math.imul(_e,et),g=g+Math.imul(He,Be)|0,T=Math.imul(He,et),d=d+Math.imul(be,$e)|0,g=g+Math.imul(be,ft)|0,g=g+Math.imul(Le,$e)|0,T=T+Math.imul(Le,ft)|0,d=d+Math.imul(ve,ze)|0,g=g+Math.imul(ve,it)|0,g=g+Math.imul(Ne,ze)|0,T=T+Math.imul(Ne,it)|0,d=d+Math.imul(me,qe)|0,g=g+Math.imul(me,Ye)|0,g=g+Math.imul(Re,qe)|0,T=T+Math.imul(Re,Ye)|0,d=d+Math.imul(Oe,je)|0,g=g+Math.imul(Oe,Tt)|0,g=g+Math.imul(Te,je)|0,T=T+Math.imul(Te,Tt)|0,d=d+Math.imul(we,at)|0,g=g+Math.imul(we,bt)|0,g=g+Math.imul(Ce,at)|0,T=T+Math.imul(Ce,bt)|0;var Ii=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,d=Math.imul(_e,$e),g=Math.imul(_e,ft),g=g+Math.imul(He,$e)|0,T=Math.imul(He,ft),d=d+Math.imul(be,ze)|0,g=g+Math.imul(be,it)|0,g=g+Math.imul(Le,ze)|0,T=T+Math.imul(Le,it)|0,d=d+Math.imul(ve,qe)|0,g=g+Math.imul(ve,Ye)|0,g=g+Math.imul(Ne,qe)|0,T=T+Math.imul(Ne,Ye)|0,d=d+Math.imul(me,je)|0,g=g+Math.imul(me,Tt)|0,g=g+Math.imul(Re,je)|0,T=T+Math.imul(Re,Tt)|0,d=d+Math.imul(Oe,at)|0,g=g+Math.imul(Oe,bt)|0,g=g+Math.imul(Te,at)|0,T=T+Math.imul(Te,bt)|0;var lr=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(lr>>>26)|0,lr&=67108863,d=Math.imul(_e,ze),g=Math.imul(_e,it),g=g+Math.imul(He,ze)|0,T=Math.imul(He,it),d=d+Math.imul(be,qe)|0,g=g+Math.imul(be,Ye)|0,g=g+Math.imul(Le,qe)|0,T=T+Math.imul(Le,Ye)|0,d=d+Math.imul(ve,je)|0,g=g+Math.imul(ve,Tt)|0,g=g+Math.imul(Ne,je)|0,T=T+Math.imul(Ne,Tt)|0,d=d+Math.imul(me,at)|0,g=g+Math.imul(me,bt)|0,g=g+Math.imul(Re,at)|0,T=T+Math.imul(Re,bt)|0;var Yi=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Yi>>>26)|0,Yi&=67108863,d=Math.imul(_e,qe),g=Math.imul(_e,Ye),g=g+Math.imul(He,qe)|0,T=Math.imul(He,Ye),d=d+Math.imul(be,je)|0,g=g+Math.imul(be,Tt)|0,g=g+Math.imul(Le,je)|0,T=T+Math.imul(Le,Tt)|0,d=d+Math.imul(ve,at)|0,g=g+Math.imul(ve,bt)|0,g=g+Math.imul(Ne,at)|0,T=T+Math.imul(Ne,bt)|0;var Qi=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,d=Math.imul(_e,je),g=Math.imul(_e,Tt),g=g+Math.imul(He,je)|0,T=Math.imul(He,Tt),d=d+Math.imul(be,at)|0,g=g+Math.imul(be,bt)|0,g=g+Math.imul(Le,at)|0,T=T+Math.imul(Le,bt)|0;var Xi=(S+d|0)+((g&8191)<<13)|0;S=(T+(g>>>13)|0)+(Xi>>>26)|0,Xi&=67108863,d=Math.imul(_e,at),g=Math.imul(_e,bt),g=g+Math.imul(He,at)|0,T=Math.imul(He,bt);var js=(S+d|0)+((g&8191)<<13)|0;return S=(T+(g>>>13)|0)+(js>>>26)|0,js&=67108863,M[0]=Cr,M[1]=Tr,M[2]=Dr,M[3]=Fr,M[4]=Br,M[5]=er,M[6]=Qr,M[7]=Gi,M[8]=Xr,M[9]=Wi,M[10]=Ji,M[11]=Zr,M[12]=Si,M[13]=Ii,M[14]=lr,M[15]=Yi,M[16]=Qi,M[17]=Xi,M[18]=js,S!==0&&(M[19]=S,v.length++),v};Math.imul||(j=Q);function Y(c,h,v){v.negative=h.negative^c.negative,v.length=c.length+h.length;for(var _=0,I=0,M=0;M>>26)|0,I+=S>>>26,S&=67108863}v.words[M]=d,_=S,S=I}return _!==0?v.words[M]=_:v.length--,v._strip()}function U(c,h,v){return Y(c,h,v)}a.prototype.mulTo=function(c,h){var v,_=this.length+c.length;return this.length===10&&c.length===10?v=j(this,c,h):_<63?v=Q(this,c,h):_<1024?v=Y(this,c,h):v=U(this,c,h),v},a.prototype.mul=function(c){var h=new a(null);return h.words=new Array(this.length+c.length),this.mulTo(c,h)},a.prototype.mulf=function(c){var h=new a(null);return h.words=new Array(this.length+c.length),U(this,c,h)},a.prototype.imul=function(c){return this.clone().mulTo(c,this)},a.prototype.imuln=function(c){var h=c<0;h&&(c=-c),i(typeof c=="number"),i(c<67108864);for(var v=0,_=0;_>=26,v+=I/67108864|0,v+=M>>>26,this.words[_]=M&67108863}return v!==0&&(this.words[_]=v,this.length++),h?this.ineg():this},a.prototype.muln=function(c){return this.clone().imuln(c)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(c){var h=W(c);if(h.length===0)return new a(1);for(var v=this,_=0;_=0);var h=c%26,v=(c-h)/26,_=67108863>>>26-h<<26-h,I;if(h!==0){var M=0;for(I=0;I>>26-h}M&&(this.words[I]=M,this.length++)}if(v!==0){for(I=this.length-1;I>=0;I--)this.words[I+v]=this.words[I];for(I=0;I=0);var _;h?_=(h-h%26)/26:_=0;var I=c%26,M=Math.min((c-I)/26,this.length),S=67108863^67108863>>>I<M)for(this.length-=M,g=0;g=0&&(T!==0||g>=_);g--){var Z=this.words[g]|0;this.words[g]=T<<26-I|Z>>>I,T=Z&S}return d&&T!==0&&(d.words[d.length++]=T),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(c,h,v){return i(this.negative===0),this.iushrn(c,h,v)},a.prototype.shln=function(c){return this.clone().ishln(c)},a.prototype.ushln=function(c){return this.clone().iushln(c)},a.prototype.shrn=function(c){return this.clone().ishrn(c)},a.prototype.ushrn=function(c){return this.clone().iushrn(c)},a.prototype.testn=function(c){i(typeof c=="number"&&c>=0);var h=c%26,v=(c-h)/26,_=1<=0);var h=c%26,v=(c-h)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(h!==0&&v++,this.length=Math.min(v,this.length),h!==0){var _=67108863^67108863>>>h<=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+1),this},a.prototype.isubn=function(c){if(i(typeof c=="number"),i(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var h=0;h>26)-(d/67108864|0),this.words[I+v]=M&67108863}for(;I>26,this.words[I+v]=M&67108863;if(S===0)return this._strip();for(i(S===-1),S=0,I=0;I>26,this.words[I]=M&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(c,h){var v=this.length-c.length,_=this.clone(),I=c,M=I.words[I.length-1]|0,S=this._countBits(M);v=26-S,v!==0&&(I=I.ushln(v),_.iushln(v),M=I.words[I.length-1]|0);var d=_.length-I.length,g;if(h!=="mod"){g=new a(null),g.length=d+1,g.words=new Array(g.length);for(var T=0;T=0;se--){var P=(_.words[I.length+se]|0)*67108864+(_.words[I.length+se-1]|0);for(P=Math.min(P/M|0,67108863),_._ishlnsubmul(I,P,se);_.negative!==0;)P--,_.negative=0,_._ishlnsubmul(I,1,se),_.isZero()||(_.negative^=1);g&&(g.words[se]=P)}return g&&g._strip(),_._strip(),h!=="div"&&v!==0&&_.iushrn(v),{div:g||null,mod:_}},a.prototype.divmod=function(c,h,v){if(i(!c.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var _,I,M;return this.negative!==0&&c.negative===0?(M=this.neg().divmod(c,h),h!=="mod"&&(_=M.div.neg()),h!=="div"&&(I=M.mod.neg(),v&&I.negative!==0&&I.iadd(c)),{div:_,mod:I}):this.negative===0&&c.negative!==0?(M=this.divmod(c.neg(),h),h!=="mod"&&(_=M.div.neg()),{div:_,mod:M.mod}):this.negative&c.negative?(M=this.neg().divmod(c.neg(),h),h!=="div"&&(I=M.mod.neg(),v&&I.negative!==0&&I.isub(c)),{div:M.div,mod:I}):c.length>this.length||this.cmp(c)<0?{div:new a(0),mod:this}:c.length===1?h==="div"?{div:this.divn(c.words[0]),mod:null}:h==="mod"?{div:null,mod:new a(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new a(this.modrn(c.words[0]))}:this._wordDiv(c,h)},a.prototype.div=function(c){return this.divmod(c,"div",!1).div},a.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},a.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},a.prototype.divRound=function(c){var h=this.divmod(c);if(h.mod.isZero())return h.div;var v=h.div.negative!==0?h.mod.isub(c):h.mod,_=c.ushrn(1),I=c.andln(1),M=v.cmp(_);return M<0||I===1&&M===0?h.div:h.div.negative!==0?h.div.isubn(1):h.div.iaddn(1)},a.prototype.modrn=function(c){var h=c<0;h&&(c=-c),i(c<=67108863);for(var v=(1<<26)%c,_=0,I=this.length-1;I>=0;I--)_=(v*_+(this.words[I]|0))%c;return h?-_:_},a.prototype.modn=function(c){return this.modrn(c)},a.prototype.idivn=function(c){var h=c<0;h&&(c=-c),i(c<=67108863);for(var v=0,_=this.length-1;_>=0;_--){var I=(this.words[_]|0)+v*67108864;this.words[_]=I/c|0,v=I%c}return this._strip(),h?this.ineg():this},a.prototype.divn=function(c){return this.clone().idivn(c)},a.prototype.egcd=function(c){i(c.negative===0),i(!c.isZero());var h=this,v=c.clone();h.negative!==0?h=h.umod(c):h=h.clone();for(var _=new a(1),I=new a(0),M=new a(0),S=new a(1),d=0;h.isEven()&&v.isEven();)h.iushrn(1),v.iushrn(1),++d;for(var g=v.clone(),T=h.clone();!h.isZero();){for(var Z=0,se=1;!(h.words[0]&se)&&Z<26;++Z,se<<=1);if(Z>0)for(h.iushrn(Z);Z-- >0;)(_.isOdd()||I.isOdd())&&(_.iadd(g),I.isub(T)),_.iushrn(1),I.iushrn(1);for(var P=0,ee=1;!(v.words[0]&ee)&&P<26;++P,ee<<=1);if(P>0)for(v.iushrn(P);P-- >0;)(M.isOdd()||S.isOdd())&&(M.iadd(g),S.isub(T)),M.iushrn(1),S.iushrn(1);h.cmp(v)>=0?(h.isub(v),_.isub(M),I.isub(S)):(v.isub(h),M.isub(_),S.isub(I))}return{a:M,b:S,gcd:v.iushln(d)}},a.prototype._invmp=function(c){i(c.negative===0),i(!c.isZero());var h=this,v=c.clone();h.negative!==0?h=h.umod(c):h=h.clone();for(var _=new a(1),I=new a(0),M=v.clone();h.cmpn(1)>0&&v.cmpn(1)>0;){for(var S=0,d=1;!(h.words[0]&d)&&S<26;++S,d<<=1);if(S>0)for(h.iushrn(S);S-- >0;)_.isOdd()&&_.iadd(M),_.iushrn(1);for(var g=0,T=1;!(v.words[0]&T)&&g<26;++g,T<<=1);if(g>0)for(v.iushrn(g);g-- >0;)I.isOdd()&&I.iadd(M),I.iushrn(1);h.cmp(v)>=0?(h.isub(v),_.isub(I)):(v.isub(h),I.isub(_))}var Z;return h.cmpn(1)===0?Z=_:Z=I,Z.cmpn(0)<0&&Z.iadd(c),Z},a.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var h=this.clone(),v=c.clone();h.negative=0,v.negative=0;for(var _=0;h.isEven()&&v.isEven();_++)h.iushrn(1),v.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;v.isEven();)v.iushrn(1);var I=h.cmp(v);if(I<0){var M=h;h=v,v=M}else if(I===0||v.cmpn(1)===0)break;h.isub(v)}while(!0);return v.iushln(_)},a.prototype.invm=function(c){return this.egcd(c).a.umod(c)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(c){return this.words[0]&c},a.prototype.bincn=function(c){i(typeof c=="number");var h=c%26,v=(c-h)/26,_=1<>>26,S&=67108863,this.words[M]=S}return I!==0&&(this.words[M]=I,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(c){var h=c<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this._strip();var v;if(this.length>1)v=1;else{h&&(c=-c),i(c<=67108863,"Number is too big");var _=this.words[0]|0;v=_===c?0:_c.length)return 1;if(this.length=0;v--){var _=this.words[v]|0,I=c.words[v]|0;if(_!==I){_I&&(h=1);break}}return h},a.prototype.gtn=function(c){return this.cmpn(c)===1},a.prototype.gt=function(c){return this.cmp(c)===1},a.prototype.gten=function(c){return this.cmpn(c)>=0},a.prototype.gte=function(c){return this.cmp(c)>=0},a.prototype.ltn=function(c){return this.cmpn(c)===-1},a.prototype.lt=function(c){return this.cmp(c)===-1},a.prototype.lten=function(c){return this.cmpn(c)<=0},a.prototype.lte=function(c){return this.cmp(c)<=0},a.prototype.eqn=function(c){return this.cmpn(c)===0},a.prototype.eq=function(c){return this.cmp(c)===0},a.red=function(c){return new F(c)},a.prototype.toRed=function(c){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(c){return this.red=c,this},a.prototype.forceRed=function(c){return i(!this.red,"Already a number in reduction context"),this._forceRed(c)},a.prototype.redAdd=function(c){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},a.prototype.redIAdd=function(c){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},a.prototype.redSub=function(c){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},a.prototype.redISub=function(c){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},a.prototype.redShl=function(c){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},a.prototype.redMul=function(c){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},a.prototype.redIMul=function(c){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(c){return i(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var k={k256:null,p224:null,p192:null,p25519:null};function G(c,h){this.name=c,this.p=new a(h,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}G.prototype._tmp=function(){var c=new a(null);return c.words=new Array(Math.ceil(this.n/13)),c},G.prototype.ireduce=function(c){var h=c,v;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),v=h.bitLength();while(v>this.n);var _=v0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},G.prototype.split=function(c,h){c.iushrn(this.n,0,h)},G.prototype.imulK=function(c){return c.imul(this.k)};function x(){G.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(x,G),x.prototype.split=function(c,h){for(var v=4194303,_=Math.min(c.length,9),I=0;I<_;I++)h.words[I]=c.words[I];if(h.length=_,c.length<=9){c.words[0]=0,c.length=1;return}var M=c.words[9];for(h.words[h.length++]=M&v,I=10;I>>22,M=S}M>>>=22,c.words[I-10]=M,M===0&&c.length>10?c.length-=10:c.length-=9},x.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var h=0,v=0;v>>=26,c.words[v]=I,h=_}return h!==0&&(c.words[c.length++]=h),c},a._prime=function(c){if(k[c])return k[c];var h;if(c==="k256")h=new x;else if(c==="p224")h=new B;else if(c==="p192")h=new ae;else if(c==="p25519")h=new le;else throw new Error("Unknown prime "+c);return k[c]=h,h};function F(c){if(typeof c=="string"){var h=a._prime(c);this.m=h.p,this.prime=h}else i(c.gtn(1),"modulus must be greater than 1"),this.m=c,this.prime=null}F.prototype._verify1=function(c){i(c.negative===0,"red works only with positives"),i(c.red,"red works only with red numbers")},F.prototype._verify2=function(c,h){i((c.negative|h.negative)===0,"red works only with positives"),i(c.red&&c.red===h.red,"red works only with red numbers")},F.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(y(c,c.umod(this.m)._forceRed(this)),c)},F.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},F.prototype.add=function(c,h){this._verify2(c,h);var v=c.add(h);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},F.prototype.iadd=function(c,h){this._verify2(c,h);var v=c.iadd(h);return v.cmp(this.m)>=0&&v.isub(this.m),v},F.prototype.sub=function(c,h){this._verify2(c,h);var v=c.sub(h);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},F.prototype.isub=function(c,h){this._verify2(c,h);var v=c.isub(h);return v.cmpn(0)<0&&v.iadd(this.m),v},F.prototype.shl=function(c,h){return this._verify1(c),this.imod(c.ushln(h))},F.prototype.imul=function(c,h){return this._verify2(c,h),this.imod(c.imul(h))},F.prototype.mul=function(c,h){return this._verify2(c,h),this.imod(c.mul(h))},F.prototype.isqr=function(c){return this.imul(c,c.clone())},F.prototype.sqr=function(c){return this.mul(c,c)},F.prototype.sqrt=function(c){if(c.isZero())return c.clone();var h=this.m.andln(3);if(i(h%2===1),h===3){var v=this.m.add(new a(1)).iushrn(2);return this.pow(c,v)}for(var _=this.m.subn(1),I=0;!_.isZero()&&_.andln(1)===0;)I++,_.iushrn(1);i(!_.isZero());var M=new a(1).toRed(this),S=M.redNeg(),d=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new a(2*g*g).toRed(this);this.pow(g,d).cmp(S)!==0;)g.redIAdd(S);for(var T=this.pow(g,_),Z=this.pow(c,_.addn(1).iushrn(1)),se=this.pow(c,_),P=I;se.cmp(M)!==0;){for(var ee=se,q=0;ee.cmp(M)!==0;q++)ee=ee.redSqr();i(q=0;I--){for(var T=h.words[I],Z=g-1;Z>=0;Z--){var se=T>>Z&1;if(M!==_[0]&&(M=this.sqr(M)),se===0&&S===0){d=0;continue}S<<=1,S|=se,d++,!(d!==v&&(I!==0||Z!==0))&&(M=this.mul(M,_[S]),d=0,S=0)}g=26}return M},F.prototype.convertTo=function(c){var h=c.umod(this.m);return h===c?h.clone():h},F.prototype.convertFrom=function(c){var h=c.clone();return h.red=null,h},a.mont=function(c){return new m(c)};function m(c){F.call(this,c),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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)}n(m,F),m.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},m.prototype.convertFrom=function(c){var h=this.imod(c.mul(this.rinv));return h.red=null,h},m.prototype.imul=function(c,h){if(c.isZero()||h.isZero())return c.words[0]=0,c.length=1,c;var v=c.imul(h),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=v.isub(_).iushrn(this.shift),M=I;return I.cmp(this.m)>=0?M=I.isub(this.m):I.cmpn(0)<0&&(M=I.iadd(this.m)),M._forceRed(this)},m.prototype.mul=function(c,h){if(c.isZero()||h.isZero())return new a(0)._forceRed(this);var v=c.mul(h),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=v.isub(_).iushrn(this.shift),M=I;return I.cmp(this.m)>=0?M=I.isub(this.m):I.cmpn(0)<0&&(M=I.iadd(this.m)),M._forceRed(this)},m.prototype.invm=function(c){var h=this.imod(c._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(r,Bb)})($b);var vt=$b.exports;const zb="bignumber/5.7.0";var ph=vt.BN;const cs=new Or(zb),yl={},V1=9007199254740991;function RA(r){return r!=null&&(Gt.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||_i(r)||typeof r=="bigint"||bo(r))}let G1=!1;class Gt{constructor(e,t){e!==yl&&cs.throwError("cannot call constructor directly; use BigNumber.from",Or.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return si(Pt(this).fromTwos(e))}toTwos(e){return si(Pt(this).toTwos(e))}abs(){return this._hex[0]==="-"?Gt.from(this._hex.substring(1)):this}add(e){return si(Pt(this).add(Pt(e)))}sub(e){return si(Pt(this).sub(Pt(e)))}div(e){return Gt.from(e).isZero()&&Fi("division-by-zero","div"),si(Pt(this).div(Pt(e)))}mul(e){return si(Pt(this).mul(Pt(e)))}mod(e){const t=Pt(e);return t.isNeg()&&Fi("division-by-zero","mod"),si(Pt(this).umod(t))}pow(e){const t=Pt(e);return t.isNeg()&&Fi("negative-power","pow"),si(Pt(this).pow(t))}and(e){const t=Pt(e);return(this.isNegative()||t.isNeg())&&Fi("unbound-bitwise-result","and"),si(Pt(this).and(t))}or(e){const t=Pt(e);return(this.isNegative()||t.isNeg())&&Fi("unbound-bitwise-result","or"),si(Pt(this).or(t))}xor(e){const t=Pt(e);return(this.isNegative()||t.isNeg())&&Fi("unbound-bitwise-result","xor"),si(Pt(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&Fi("negative-width","mask"),si(Pt(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Fi("negative-width","shl"),si(Pt(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Fi("negative-width","shr"),si(Pt(this).shrn(e))}eq(e){return Pt(this).eq(Pt(e))}lt(e){return Pt(this).lt(Pt(e))}lte(e){return Pt(this).lte(Pt(e))}gt(e){return Pt(this).gt(Pt(e))}gte(e){return Pt(this).gte(Pt(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Pt(this).isZero()}toNumber(){try{return Pt(this).toNumber()}catch{Fi("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return cs.throwError("this platform does not support BigInt",Or.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?G1||(G1=!0,cs.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?cs.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Or.errors.UNEXPECTED_ARGUMENT,{}):cs.throwError("BigNumber.toString does not accept parameters",Or.errors.UNEXPECTED_ARGUMENT,{})),Pt(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof Gt)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new Gt(yl,pc(e)):e.match(/^-?[0-9]+$/)?new Gt(yl,pc(new ph(e))):cs.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Fi("underflow","BigNumber.from",e),(e>=V1||e<=-V1)&&Fi("overflow","BigNumber.from",e),Gt.from(String(e));const t=e;if(typeof t=="bigint")return Gt.from(t.toString());if(bo(t))return Gt.from(ci(t));if(t)if(t.toHexString){const i=t.toHexString();if(typeof i=="string")return Gt.from(i)}else{let i=t._hex;if(i==null&&t.type==="BigNumber"&&(i=t.hex),typeof i=="string"&&(_i(i)||i[0]==="-"&&_i(i.substring(1))))return Gt.from(i)}return cs.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function pc(r){if(typeof r!="string")return pc(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&cs.throwArgumentError("invalid hex","value",r),r=pc(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function si(r){return Gt.from(pc(r))}function Pt(r){const e=Gt.from(r).toHexString();return e[0]==="-"?new ph("-"+e.substring(3),16):new ph(e.substring(2),16)}function Fi(r,e,t){const i={fault:r,operation:e};return t!=null&&(i.value=t),cs.throwError(r,Or.errors.NUMERIC_FAULT,i)}function NA(r){return new ph(r,36).toString(16)}const Wr=new Or(zb),oc={},jb=Gt.from(0),kb=Gt.from(-1);function Hb(r,e,t,i){const n={fault:e,operation:t};return i!==void 0&&(n.value=i),Wr.throwError(r,Or.errors.NUMERIC_FAULT,n)}let cc="0";for(;cc.length<256;)cc+=cc;function k0(r){if(typeof r!="number")try{r=Gt.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+cc.substring(0,r):Wr.throwArgumentError("invalid decimal size","decimals",r)}function wl(r,e){e==null&&(e=0);const t=k0(e);r=Gt.from(r);const i=r.lt(jb);i&&(r=r.mul(kb));let n=r.mod(t).toString();for(;n.length2&&Wr.throwArgumentError("too many decimal points","value",r);let a=n[0],f=n[1];for(a||(a="0"),f||(f="0");f[f.length-1]==="0";)f=f.substring(0,f.length-1);for(f.length>t.length-1&&Hb("fractional component exceeds decimals","underflow","parseFixed"),f===""&&(f="0");f.lengthe[f]==null?b:(typeof e[f]!==u&&Wr.throwArgumentError("invalid fixed format ("+f+" not "+u+")","format."+f,e[f]),e[f]);t=a("signed","boolean",t),i=a("width","number",i),n=a("decimals","number",n)}return i%8&&Wr.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Wr.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new a0(oc,t,i,n)}},Kb=class Vr{constructor(e,t,i,n){e!==oc&&Wr.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Or.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Wr.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=ns(this._value,this.format.decimals),i=ns(e._value,e.format.decimals);return Vr.fromValue(t.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=ns(this._value,this.format.decimals),i=ns(e._value,e.format.decimals);return Vr.fromValue(t.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=ns(this._value,this.format.decimals),i=ns(e._value,e.format.decimals);return Vr.fromValue(t.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=ns(this._value,this.format.decimals),i=ns(e._value,e.format.decimals);return Vr.fromValue(t.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Vr.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(t=t.subUnsafe(W1.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Vr.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(t=t.addUnsafe(W1.toFormat(t.format))),t}round(e){e==null&&(e=0);const t=this.toString().split(".");if(t.length===1&&t.push("0"),(e<0||e>80||e%1)&&Wr.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const i=Vr.from("1"+cc.substring(0,e),this.format),n=CA.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(n).floor().divUnsafe(i)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&Wr.throwArgumentError("invalid byte width","width",e);const t=Gt.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Dn(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Vr.fromString(this._value,e)}static fromValue(e,t,i){return i==null&&t!=null&&!RA(t)&&(i=t,t=null),t==null&&(t=0),i==null&&(i="fixed"),Vr.fromString(wl(e,t),_l.from(i))}static fromString(e,t){t==null&&(t="fixed");const i=_l.from(t),n=ns(e,i.decimals);!i.signed&&n.lt(jb)&&Hb("unsigned value cannot be negative","overflow","value",e);let a=null;i.signed?a=n.toTwos(i.width).toHexString():(a=n.toHexString(),a=Dn(a,i.width/8));const f=wl(n,i.decimals);return new Vr(oc,a,f,i)}static fromBytes(e,t){t==null&&(t="fixed");const i=_l.from(t);if(ir(e).length>i.width/8)throw new Error("overflow");let n=Gt.from(e);i.signed&&(n=n.fromTwos(i.width));const a=n.toTwos((i.signed?0:1)+i.width).toHexString(),f=wl(n,i.decimals);return new Vr(oc,a,f,i)}static from(e,t){if(typeof e=="string")return Vr.fromString(e,t);if(bo(e))return Vr.fromBytes(e,t);try{return Vr.fromValue(e,0,t)}catch(i){if(i.code!==Or.errors.INVALID_ARGUMENT)throw i}return Wr.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}};const W1=Kb.from(1),CA=Kb.from("0.5"),TA="strings/5.7.0",DA=new Or(TA);var gh;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(gh||(gh={}));var J1;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(J1||(J1={}));function Al(r,e=gh.current){e!=gh.current&&(DA.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;const a=r.charCodeAt(i);if(i>=r.length||(a&64512)!==56320)throw new Error("invalid utf-8 string");const f=65536+((n&1023)<<10)+(a&1023);t.push(f>>18|240),t.push(f>>12&63|128),t.push(f>>6&63|128),t.push(f&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return ir(t)}function FA(r){if(r.length%4!==0)throw new Error("bad data");let e=[];for(let t=0;t{let a=n.split(":");t+=parseInt(a[0],16),i[t]=e(a[1])}),i}function Y1(r){let e=0;return r.split(",").map(t=>{let i=t.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let n=e+parseInt(i[0],16);return e=parseInt(i[1],16),{l:n,h:e}})}Y1("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(r=>parseInt(r,16)),El("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),El("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),El("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",FA),Y1("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function BA(r){r=atob(r);const e=[];for(let t=0;t0&&Array.isArray(u)?n(u,f-1):t.push(u)})};return n(r,e),t}function qA(r){const e={};for(let t=0;t>--b&1}const A=31,R=Math.pow(2,A),O=R>>>1,N=O>>1,K=R-1;let W=0;for(let k=0;k1;){let le=G+x>>>1;k>>1|y(),B=B<<1^O,ae=(ae^O)<<1|O|1;j=B,Y=1+ae-B}let U=i-4;return Q.map(k=>{switch(k-U){case 3:return U+65792+(r[u++]<<16|r[u++]<<8|r[u++]);case 2:return U+256+(r[u++]<<8|r[u++]);case 1:return U+r[u++];default:return k-1}})}function UA(r){let e=0;return()=>r[e++]}function $A(r){return UA(LA(r))}function zA(r){return r&1?~r>>1:r>>1}function jA(r,e){let t=Array(r);for(let i=0;ie[f]):t}function HA(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(VA(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(GA(t,r))}return qA(Vb(e))}function KA(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(t)}return e}function Gb(r,e,t){let i=Array(r).fill(void 0).map(()=>[]);for(let n=0;ni[f].push(a));return i}function VA(r,e){let t=1+e(),i=e(),n=KA(e),a=Gb(n.length,1+r,e);return Vb(a.map((f,u)=>{const b=f[0],p=f.slice(1);return Array(n[u]).fill(void 0).map((y,A)=>{let R=A*i;return[b+A*t,p.map(O=>O+R)]})}))}function GA(r,e){let t=1+e();return Gb(t,1+r,e).map(i=>[i[0],i.slice(1)])}function WA(r){let e=vh(r).sort((i,n)=>i-n);return t();function t(){let i=[];for(;;){let p=vh(r,e);if(p.length==0)break;i.push({set:new Set(p),node:t()})}i.sort((p,y)=>y.set.size-p.set.size);let n=r(),a=n%3;n=n/3|0;let f=!!(n&1);n>>=1;let u=n==1,b=n==2;return{branches:i,valid:a,fe0f:f,save:u,check:b}}}function JA(){return $A(BA("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=="))}const Lf=JA();new Set(vh(Lf)),new Set(vh(Lf)),HA(Lf),WA(Lf);const YA=new Uint8Array(32);YA.fill(0);const QA=`Ethereum Signed Message: -`;function Wb(r){return typeof r=="string"&&(r=Al(r)),j0(xA([Al(QA),Al(String(r.length)),r]))}const XA="address/5.7.0",ic=new Or(XA);function X1(r){_i(r,20)||ic.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);const i=ir(j0(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}const ZA=9007199254740991;function eE(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const H0={};for(let r=0;r<10;r++)H0[String(r)]=String(r);for(let r=0;r<26;r++)H0[String.fromCharCode(65+r)]=String(10+r);const Z1=Math.floor(eE(ZA));function tE(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>H0[i]).join("");for(;e.length>=Z1;){let i=e.substring(0,Z1);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function rE(r){let e=null;if(typeof r!="string"&&ic.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=X1(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&ic.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==tE(r)&&ic.throwArgumentError("bad icap checksum","address",r),e=NA(r.substring(4));e.length<40;)e="0"+e;e=X1("0x"+e)}else ic.throwArgumentError("invalid address","address",r);return e}function Go(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}const iE=new Uint8Array(32);iE.fill(0),Gt.from(-1);const nE=Gt.from(0),sE=Gt.from(1);Gt.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Dn(sE.toHexString(),32),Dn(nE.toHexString(),32);var Sn={},Rt={},Mc=Jb;function Jb(r,e){if(!r)throw new Error(e||"Assertion failed")}Jb.equal=function(r,e,t){if(r!=e)throw new Error(t||"Assertion failed: "+r+" != "+e)};var o0={exports:{}};typeof Object.create=="function"?o0.exports=function(r,e){e&&(r.super_=e,r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:o0.exports=function(r,e){if(e){r.super_=e;var t=function(){};t.prototype=e.prototype,r.prototype=new t,r.prototype.constructor=r}};var aE=Mc,oE=o0.exports;Rt.inherits=oE;function cE(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function fE(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=a&63|128):cE(r,n)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=a>>18|240,t[i++]=a>>12&63|128,t[i++]=a>>6&63|128,t[i++]=a&63|128):(t[i++]=a>>12|224,t[i++]=a>>6&63|128,t[i++]=a&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Rt.htonl=Yb;function uE(r,e){for(var t="",i=0;i>>0}return a}Rt.join32=lE;function dE(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=a>>>16&255,t[n+2]=a>>>8&255,t[n+3]=a&255):(t[n+3]=a>>>24,t[n+2]=a>>>16&255,t[n+1]=a>>>8&255,t[n]=a&255)}return t}Rt.split32=dE;function pE(r,e){return r>>>e|r<<32-e}Rt.rotr32=pE;function gE(r,e){return r<>>32-e}Rt.rotl32=gE;function vE(r,e){return r+e>>>0}Rt.sum32=vE;function bE(r,e,t){return r+e+t>>>0}Rt.sum32_3=bE;function mE(r,e,t,i){return r+e+t+i>>>0}Rt.sum32_4=mE;function yE(r,e,t,i,n){return r+e+t+i+n>>>0}Rt.sum32_5=yE;function wE(r,e,t,i){var n=r[e],a=r[e+1],f=i+a>>>0,u=(f>>0,r[e+1]=f}Rt.sum64=wE;function _E(r,e,t,i){var n=e+i>>>0,a=(n>>0}Rt.sum64_hi=_E;function AE(r,e,t,i){var n=e+i;return n>>>0}Rt.sum64_lo=AE;function EE(r,e,t,i,n,a,f,u){var b=0,p=e;p=p+i>>>0,b+=p>>0,b+=p>>0,b+=p>>0}Rt.sum64_4_hi=EE;function xE(r,e,t,i,n,a,f,u){var b=e+i+a+u;return b>>>0}Rt.sum64_4_lo=xE;function SE(r,e,t,i,n,a,f,u,b,p){var y=0,A=e;A=A+i>>>0,y+=A>>0,y+=A>>0,y+=A>>0,y+=A>>0}Rt.sum64_5_hi=SE;function IE(r,e,t,i,n,a,f,u,b,p){var y=e+i+a+u+p;return y>>>0}Rt.sum64_5_lo=IE;function ME(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Rt.rotr64_hi=ME;function PE(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Rt.rotr64_lo=PE;function OE(r,e,t){return r>>>t}Rt.shr64_hi=OE;function RE(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Rt.shr64_lo=RE;var mo={},eg=Rt,NE=Mc;function Uf(){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}mo.BlockHash=Uf,Uf.prototype.update=function(r,e){if(r=eg.toArray(r,e),this.pending?this.pending=this.pending.concat(r):this.pending=r,this.pendingTotal+=r.length,this.pending.length>=this._delta8){r=this.pending;var t=r.length%this._delta8;this.pending=r.slice(r.length-t,r.length),this.pending.length===0&&(this.pending=null),r=eg.join32(r,0,r.length-t,this.endian);for(var i=0;i>>24&255,i[n++]=r>>>16&255,i[n++]=r>>>8&255,i[n++]=r&255}else for(i[n++]=r&255,i[n++]=r>>>8&255,i[n++]=r>>>16&255,i[n++]=r>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,a=8;a>>3}Vn.g0_256=BE;function qE(r){return Fn(r,17)^Fn(r,19)^r>>>10}Vn.g1_256=qE;var ao=Rt,LE=mo,UE=Vn,xl=ao.rotl32,Wo=ao.sum32,$E=ao.sum32_5,zE=UE.ft_1,r2=LE.BlockHash,jE=[1518500249,1859775393,2400959708,3395469782];function On(){if(!(this instanceof On))return new On;r2.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}ao.inherits(On,r2);var kE=On;On.blockSize=512,On.outSize=160,On.hmacStrength=80,On.padLength=64,On.prototype._update=function(r,e){for(var t=this.W,i=0;i<16;i++)t[i]=r[e+i];for(;ithis.blockSize&&(r=new this.Hash().update(r).digest()),Rx(r.length<=this.blockSize);for(var e=r.length;e>8,R=y&255;A?b.push(A,R):b.push(R)}return b}t.toArray=i;function n(f){return f.length===1?"0"+f:f}t.zero2=n;function a(f){for(var u="",b=0;b(R>>1)-1?K=(R>>1)-W:K=W,O.isubn(K)):K=0,A[N]=K,O.iushrn(1)}return A}t.getNAF=i;function n(b,p){var y=[[],[]];b=b.clone(),p=p.clone();for(var A=0,R=0,O;b.cmpn(-A)>0||p.cmpn(-R)>0;){var N=b.andln(3)+A&3,K=p.andln(3)+R&3;N===3&&(N=-1),K===3&&(K=-1);var W;N&1?(O=b.andln(7)+A&7,(O===3||O===5)&&K===2?W=-N:W=N):W=0,y[0].push(W);var Q;K&1?(O=p.andln(7)+R&7,(O===3||O===5)&&N===2?Q=-K:Q=K):Q=0,y[1].push(Q),2*A===W+1&&(A=1-A),2*R===Q+1&&(R=1-R),b.iushrn(1),p.iushrn(1)}return y}t.getJSF=n;function a(b,p,y){var A="_"+p;b.prototype[p]=function(){return this[A]!==void 0?this[A]:this[A]=y.call(this)}}t.cachedProperty=a;function f(b){return typeof b=="string"?t.toArray(b,"hex"):b}t.parseBytes=f;function u(b){return new vt(b,"hex","le")}t.intFromLE=u}),zf=Ai.getNAF,Tx=Ai.getJSF,bh=Ai.assert;function Ts(r,e){this.type=r,this.p=new vt(e.p,16),this.red=e.prime?vt.red(e.prime):vt.mont(this.p),this.zero=new vt(0).toRed(this.red),this.one=new vt(1).toRed(this.red),this.two=new vt(2).toRed(this.red),this.n=e.n&&new vt(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var _a=Ts;Ts.prototype.point=function(){throw new Error("Not implemented")},Ts.prototype.validate=function(){throw new Error("Not implemented")},Ts.prototype._fixedNafMul=function(r,e){bh(r.precomputed);var t=r._getDoubles(),i=zf(e,1,this._bitLength),n=(1<=f;b--)u=(u<<1)+i[b];a.push(u)}for(var p=this.jpoint(null,null,null),y=this.jpoint(null,null,null),A=n;A>0;A--){for(f=0;f=0;u--){for(var b=0;u>=0&&a[u]===0;u--)b++;if(u>=0&&b++,f=f.dblp(b),u<0)break;var p=a[u];bh(p!==0),r.type==="affine"?p>0?f=f.mixedAdd(n[p-1>>1]):f=f.mixedAdd(n[-p-1>>1].neg()):p>0?f=f.add(n[p-1>>1]):f=f.add(n[-p-1>>1].neg())}return r.type==="affine"?f.toP():f},Ts.prototype._wnafMulAdd=function(r,e,t,i,n){var a=this._wnafT1,f=this._wnafT2,u=this._wnafT3,b=0,p,y,A;for(p=0;p=1;p-=2){var O=p-1,N=p;if(a[O]!==1||a[N]!==1){u[O]=zf(t[O],a[O],this._bitLength),u[N]=zf(t[N],a[N],this._bitLength),b=Math.max(u[O].length,b),b=Math.max(u[N].length,b);continue}var K=[e[O],null,null,e[N]];e[O].y.cmp(e[N].y)===0?(K[1]=e[O].add(e[N]),K[2]=e[O].toJ().mixedAdd(e[N].neg())):e[O].y.cmp(e[N].y.redNeg())===0?(K[1]=e[O].toJ().mixedAdd(e[N]),K[2]=e[O].add(e[N].neg())):(K[1]=e[O].toJ().mixedAdd(e[N]),K[2]=e[O].toJ().mixedAdd(e[N].neg()));var W=[-3,-1,-5,-7,0,7,5,1,3],Q=Tx(t[O],t[N]);for(b=Math.max(Q[0].length,b),u[O]=new Array(b),u[N]=new Array(b),y=0;y=0;p--){for(var G=0;p>=0;){var x=!0;for(y=0;y=0&&G++,U=U.dblp(G),p<0)break;for(y=0;y0?A=f[y][B-1>>1]:B<0&&(A=f[y][-B-1>>1].neg()),A.type==="affine"?U=U.mixedAdd(A):U=U.add(A))}}for(p=0;p=Math.ceil((r.bitLength()+1)/e.step):!1},Bi.prototype._getDoubles=function(r,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var t=[this],i=this,n=0;n=0&&(R=b,O=p),y.negative&&(y=y.neg(),A=A.neg()),R.negative&&(R=R.neg(),O=O.neg()),[{a:y,b:A},{a:R,b:O}]},zi.prototype._endoSplit=function(r){var e=this.endo.basis,t=e[0],i=e[1],n=i.b.mul(r).divRound(this.n),a=t.b.neg().mul(r).divRound(this.n),f=n.mul(t.a),u=a.mul(i.a),b=n.mul(t.b),p=a.mul(i.b),y=r.sub(f).sub(u),A=b.add(p).neg();return{k1:y,k2:A}},zi.prototype.pointFromX=function(r,e){r=new vt(r,16),r.red||(r=r.toRed(this.red));var t=r.redSqr().redMul(r).redIAdd(r.redMul(this.a)).redIAdd(this.b),i=t.redSqrt();if(i.redSqr().redSub(t).cmp(this.zero)!==0)throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(r,i)},zi.prototype.validate=function(r){if(r.inf)return!0;var e=r.x,t=r.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return t.redSqr().redISub(n).cmpn(0)===0},zi.prototype._endoWnafMulAdd=function(r,e,t){for(var i=this._endoWnafT1,n=this._endoWnafT2,a=0;a":""},yr.prototype.isInfinity=function(){return this.inf},yr.prototype.add=function(r){if(this.inf)return r;if(r.inf)return this;if(this.eq(r))return this.dbl();if(this.neg().eq(r))return this.curve.point(null,null);if(this.x.cmp(r.x)===0)return this.curve.point(null,null);var e=this.y.redSub(r.y);e.cmpn(0)!==0&&(e=e.redMul(this.x.redSub(r.x).redInvm()));var t=e.redSqr().redISub(this.x).redISub(r.x),i=e.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,i)},yr.prototype.dbl=function(){if(this.inf)return this;var r=this.y.redAdd(this.y);if(r.cmpn(0)===0)return this.curve.point(null,null);var e=this.curve.a,t=this.x.redSqr(),i=r.redInvm(),n=t.redAdd(t).redIAdd(t).redIAdd(e).redMul(i),a=n.redSqr().redISub(this.x.redAdd(this.x)),f=n.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,f)},yr.prototype.getX=function(){return this.x.fromRed()},yr.prototype.getY=function(){return this.y.fromRed()},yr.prototype.mul=function(r){return r=new vt(r,16),this.isInfinity()?this:this._hasDoubles(r)?this.curve._fixedNafMul(this,r):this.curve.endo?this.curve._endoWnafMulAdd([this],[r]):this.curve._wnafMul(this,r)},yr.prototype.mulAdd=function(r,e,t){var i=[this,e],n=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},yr.prototype.jmulAdd=function(r,e,t){var i=[this,e],n=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},yr.prototype.eq=function(r){return this===r||this.inf===r.inf&&(this.inf||this.x.cmp(r.x)===0&&this.y.cmp(r.y)===0)},yr.prototype.neg=function(r){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(r&&this.precomputed){var t=this.precomputed,i=function(n){return n.neg()};e.precomputed={naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e},yr.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var r=this.curve.jpoint(this.x,this.y,this.curve.one);return r};function Pr(r,e,t,i){_a.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new vt(0)):(this.x=new vt(e,16),this.y=new vt(t,16),this.z=new vt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}V0(Pr,_a.BasePoint),zi.prototype.jpoint=function(r,e,t){return new Pr(this,r,e,t)},Pr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var r=this.z.redInvm(),e=r.redSqr(),t=this.x.redMul(e),i=this.y.redMul(e).redMul(r);return this.curve.point(t,i)},Pr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Pr.prototype.add=function(r){if(this.isInfinity())return r;if(r.isInfinity())return this;var e=r.z.redSqr(),t=this.z.redSqr(),i=this.x.redMul(e),n=r.x.redMul(t),a=this.y.redMul(e.redMul(r.z)),f=r.y.redMul(t.redMul(this.z)),u=i.redSub(n),b=a.redSub(f);if(u.cmpn(0)===0)return b.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var p=u.redSqr(),y=p.redMul(u),A=i.redMul(p),R=b.redSqr().redIAdd(y).redISub(A).redISub(A),O=b.redMul(A.redISub(R)).redISub(a.redMul(y)),N=this.z.redMul(r.z).redMul(u);return this.curve.jpoint(R,O,N)},Pr.prototype.mixedAdd=function(r){if(this.isInfinity())return r.toJ();if(r.isInfinity())return this;var e=this.z.redSqr(),t=this.x,i=r.x.redMul(e),n=this.y,a=r.y.redMul(e).redMul(this.z),f=t.redSub(i),u=n.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=f.redSqr(),p=b.redMul(f),y=t.redMul(b),A=u.redSqr().redIAdd(p).redISub(y).redISub(y),R=u.redMul(y.redISub(A)).redISub(n.redMul(p)),O=this.z.redMul(f);return this.curve.jpoint(A,R,O)},Pr.prototype.dblp=function(r){if(r===0)return this;if(this.isInfinity())return this;if(!r)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var t=this;for(e=0;e=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}},Pr.prototype.inspect=function(){return this.isInfinity()?"":""},Pr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Zf=wo(function(r,e){var t=e;t.base=_a,t.short=Fx,t.mont=null,t.edwards=null}),eh=wo(function(r,e){var t=e,i=Ai.assert;function n(u){u.type==="short"?this.curve=new Zf.short(u):u.type==="edwards"?this.curve=new Zf.edwards(u):this.curve=new Zf.mont(u),this.g=this.curve.g,this.n=this.curve.n,this.hash=u.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function a(u,b){Object.defineProperty(t,u,{configurable:!0,enumerable:!0,get:function(){var p=new n(b);return Object.defineProperty(t,u,{configurable:!0,enumerable:!0,value:p}),p}})}a("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:Sn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("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:Sn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("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:Sn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("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:Sn.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"]}),a("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:Sn.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"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Sn.sha256,gRed:!1,g:["9"]}),a("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:Sn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var f;try{f=null.crash()}catch{f=void 0}a("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:Sn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})});function Ds(r){if(!(this instanceof Ds))return new Ds(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ln.toArray(r.entropy,r.entropyEnc||"hex"),t=ln.toArray(r.nonce,r.nonceEnc||"hex"),i=ln.toArray(r.pers,r.persEnc||"hex");K0(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var ng=Ds;Ds.prototype._init=function(r,e,t){var i=r.concat(e).concat(t);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(r.concat(t||[])),this._reseed=1},Ds.prototype.generate=function(r,e,t,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof e!="string"&&(i=t,t=e,e=null),t&&(t=ln.toArray(t,i||"hex"),this._update(t));for(var n=[];n.length"};var Bx=Ai.assert;function jh(r,e){if(r instanceof jh)return r;this._importDER(r,e)||(Bx(r.r&&r.s,"Signature without r or s"),this.r=new vt(r.r,16),this.s=new vt(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var jf=jh;function qx(){this.place=0}function Ol(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,a=0,f=e.place;a>>=0;return n<=127?!1:(e.place=f,n)}function sg(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}jh.prototype.toDER=function(r){var e=this.r.toArray(),t=this.s.toArray();for(e[0]&128&&(e=[0].concat(e)),t[0]&128&&(t=[0].concat(t)),e=sg(e),t=sg(t);!t[0]&&!(t[1]&128);)t=t.slice(1);var i=[2];Rl(i,e.length),i=i.concat(e),i.push(2),Rl(i,t.length);var n=i.concat(t),a=[48];return Rl(a,n.length),a=a.concat(n),Ai.encode(a,r)};var Lx=function(){throw new Error("unsupported")},p2=Ai.assert;function Ui(r){if(!(this instanceof Ui))return new Ui(r);typeof r=="string"&&(p2(Object.prototype.hasOwnProperty.call(eh,r),"Unknown curve "+r),r=eh[r]),r instanceof eh.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var Ux=Ui;Ui.prototype.keyPair=function(r){return new Pl(this,r)},Ui.prototype.keyFromPrivate=function(r,e){return Pl.fromPrivate(this,r,e)},Ui.prototype.keyFromPublic=function(r,e){return Pl.fromPublic(this,r,e)},Ui.prototype.genKeyPair=function(r){r||(r={});for(var e=new ng({hash:this.hash,pers:r.pers,persEnc:r.persEnc||"utf8",entropy:r.entropy||Lx(this.hash.hmacStrength),entropyEnc:r.entropy&&r.entropyEnc||"utf8",nonce:this.n.toArray()}),t=this.n.byteLength(),i=this.n.sub(new vt(2));;){var n=new vt(e.generate(t));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},Ui.prototype._truncateToN=function(r,e){var t=r.byteLength()*8-this.n.bitLength();return t>0&&(r=r.ushrn(t)),!e&&r.cmp(this.n)>=0?r.sub(this.n):r},Ui.prototype.sign=function(r,e,t,i){typeof t=="object"&&(i=t,t=null),i||(i={}),e=this.keyFromPrivate(e,t),r=this._truncateToN(new vt(r,16));for(var n=this.n.byteLength(),a=e.getPrivate().toArray("be",n),f=r.toArray("be",n),u=new ng({hash:this.hash,entropy:a,nonce:f,pers:i.pers,persEnc:i.persEnc||"utf8"}),b=this.n.sub(new vt(1)),p=0;;p++){var y=i.k?i.k(p):new vt(u.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(b)>=0)){var A=this.g.mul(y);if(!A.isInfinity()){var R=A.getX(),O=R.umod(this.n);if(O.cmpn(0)!==0){var N=y.invm(this.n).mul(O.mul(e.getPrivate()).iadd(r));if(N=N.umod(this.n),N.cmpn(0)!==0){var K=(A.getY().isOdd()?1:0)|(R.cmp(O)!==0?2:0);return i.canonical&&N.cmp(this.nh)>0&&(N=this.n.sub(N),K^=1),new jf({r:O,s:N,recoveryParam:K})}}}}}},Ui.prototype.verify=function(r,e,t,i){r=this._truncateToN(new vt(r,16)),t=this.keyFromPublic(t,i),e=new jf(e,"hex");var n=e.r,a=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var f=a.invm(this.n),u=f.mul(r).umod(this.n),b=f.mul(n).umod(this.n),p;return this.curve._maxwellTrick?(p=this.g.jmulAdd(u,t.getPublic(),b),p.isInfinity()?!1:p.eqXToP(n)):(p=this.g.mulAdd(u,t.getPublic(),b),p.isInfinity()?!1:p.getX().umod(this.n).cmp(n)===0)},Ui.prototype.recoverPubKey=function(r,e,t,i){p2((3&t)===t,"The recovery param is more than two bits"),e=new jf(e,i);var n=this.n,a=new vt(r),f=e.r,u=e.s,b=t&1,p=t>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&p)throw new Error("Unable to find sencond key candinate");p?f=this.curve.pointFromX(f.add(this.curve.n),b):f=this.curve.pointFromX(f,b);var y=e.r.invm(n),A=n.sub(a).mul(y).umod(n),R=u.mul(y).umod(n);return this.g.mulAdd(A,f,R)},Ui.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new jf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var a;try{a=this.recoverPubKey(r,e,n)}catch{continue}if(a.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var $x=wo(function(r,e){var t=e;t.version="6.5.4",t.utils=Ai,t.rand=function(){throw new Error("unsupported")},t.curve=Zf,t.curves=eh,t.ec=Ux,t.eddsa=null}),zx=$x.ec;const jx="signing-key/5.7.0",h0=new Or(jx);let Nl=null;function Ns(){return Nl||(Nl=new zx("secp256k1")),Nl}class kx{constructor(e){Go(this,"curve","secp256k1"),Go(this,"privateKey",ci(e)),IA(this.privateKey)!==32&&h0.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=Ns().keyFromPrivate(ir(this.privateKey));Go(this,"publicKey","0x"+t.getPublic(!1,"hex")),Go(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Go(this,"_isSigningKey",!0)}_addPoint(e){const t=Ns().keyFromPublic(ir(this.publicKey)),i=Ns().keyFromPublic(ir(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=Ns().keyFromPrivate(ir(this.privateKey)),i=ir(e);i.length!==32&&h0.throwArgumentError("bad digest length","digest",e);const n=t.sign(i,{canonical:!0});return Ub({recoveryParam:n.recoveryParam,r:Dn("0x"+n.r.toString(16),32),s:Dn("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=Ns().keyFromPrivate(ir(this.privateKey)),i=Ns().keyFromPublic(ir(g2(e)));return Dn("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function Hx(r,e){const t=Ub(e),i={r:ir(t.r),s:ir(t.s)};return"0x"+Ns().recoverPubKey(ir(r),i,t.recoveryParam).encode("hex",!1)}function g2(r,e){const t=ir(r);return t.length===32?new kx(t).publicKey:t.length===33?"0x"+Ns().keyFromPublic(t).getPublic(!1,"hex"):t.length===65?ci(t):h0.throwArgumentError("invalid public or private key","key","[REDACTED]")}var ag;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(ag||(ag={}));function Kx(r){const e=g2(r);return rE(K1(j0(K1(e,1)),12))}function Vx(r,e){return Kx(Hx(ir(r),e))}const Gx="https://rpc.walletconnect.org/v1";async function Wx(r,e,t,i,n,a){switch(t.t){case"eip191":return Jx(r,e,t.s);case"eip1271":return await Yx(r,e,t.s,i,n,a);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function Jx(r,e,t){return Vx(Wb(e),t).toLowerCase()===r.toLowerCase()}async function Yx(r,e,t,i,n,a){try{const f="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",b="0000000000000000000000000000000000000000000000000000000000000041",p=t.substring(2),y=Wb(e).substring(2),A=f+y+u+b+p,R=await fetch(`${a||Gx}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:Qx(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:A},"latest"]})}),{result:O}=await R.json();return O?O.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function Qx(){return Date.now()+Math.floor(Math.random()*1e3)}var Xx=Object.defineProperty,Zx=Object.defineProperties,eS=Object.getOwnPropertyDescriptors,og=Object.getOwnPropertySymbols,tS=Object.prototype.hasOwnProperty,rS=Object.prototype.propertyIsEnumerable,cg=(r,e,t)=>e in r?Xx(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,iS=(r,e)=>{for(var t in e||(e={}))tS.call(e,t)&&cg(r,t,e[t]);if(og)for(var t of og(e))rS.call(e,t)&&cg(r,t,e[t]);return r},nS=(r,e)=>Zx(r,eS(e));const sS="did:pkh:",G0=r=>r==null?void 0:r.split(":"),v2=r=>{const e=r&&G0(r);if(e)return r.includes(sS)?e[3]:e[1]},fg=r=>{const e=r&&G0(r);if(e)return e[2]+":"+e[3]},mh=r=>{const e=r&&G0(r);if(e)return e.pop()};async function hg(r){const{cacao:e,projectId:t}=r,{s:i,p:n}=e,a=b2(n,n.iss),f=mh(n.iss);return await Wx(f,a,i,v2(n.iss),t)}const b2=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=mh(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0;const a=`URI: ${r.aud||r.uri}`,f=`Version: ${r.version}`,u=`Chain ID: ${v2(e)}`,b=`Nonce: ${r.nonce}`,p=`Issued At: ${r.iat}`,y=r.exp?`Expiration Time: ${r.exp}`:void 0,A=r.nbf?`Not Before: ${r.nbf}`:void 0,R=r.requestId?`Request ID: ${r.requestId}`:void 0,O=r.resources?`Resources:${r.resources.map(K=>` -- ${K}`).join("")}`:void 0,N=th(r.resources);if(N){const K=gc(N);n=pS(n,K)}return[t,i,"",n,"",a,f,u,b,p,y,A,R,O].filter(K=>K!=null).join(` -`)};function aS(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function oS(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function va(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{const a=i[n];if(!Array.isArray(a))throw new Error(`Ability limits ${n} must be an array of objects, found: ${a}`);if(!a.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);a.forEach(f=>{if(typeof f!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${f}`)})})})}function cS(r,e,t,i={}){return t==null||t.sort((n,a)=>n.localeCompare(a)),{att:{[r]:fS(e,t,i)}}}function fS(r,e,t={}){e=e==null?void 0:e.sort((n,a)=>n.localeCompare(a));const i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function m2(r){return va(r),`urn:recap:${aS(r).replace(/=/g,"")}`}function gc(r){const e=oS(r.replace("urn:recap:",""));return va(e),e}function hS(r,e,t){const i=cS(r,e,t);return m2(i)}function uS(r){return r&&r.includes("urn:recap:")}function lS(r,e){const t=gc(r),i=gc(e),n=dS(t,i);return m2(n)}function dS(r,e){va(r),va(e);const t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,a)=>n.localeCompare(a)),i={att:{}};return t.forEach(n=>{var a,f;Object.keys(((a=r.att)==null?void 0:a[n])||{}).concat(Object.keys(((f=e.att)==null?void 0:f[n])||{})).sort((u,b)=>u.localeCompare(b)).forEach(u=>{var b,p;i.att[n]=nS(iS({},i.att[n]),{[u]:((b=r.att[n])==null?void 0:b[u])||((p=e.att[n])==null?void 0:p[u])})})}),i}function pS(r="",e){va(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;const i=[];let n=0;Object.keys(e.att).forEach(u=>{const b=Object.keys(e.att[u]).map(A=>({ability:A.split("/")[0],action:A.split("/")[1]}));b.sort((A,R)=>A.action.localeCompare(R.action));const p={};b.forEach(A=>{p[A.ability]||(p[A.ability]=[]),p[A.ability].push(A.action)});const y=Object.keys(p).map(A=>(n++,`(${n}) '${A}': '${p[A].join("', '")}' for '${u}'.`));i.push(y.join(", ").replace(".,","."))});const a=i.join(" "),f=`${t}${a}`;return`${r?r+" ":""}${f}`}function ug(r){var e;const t=gc(r);va(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function lg(r){const e=gc(r);va(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var a;(a=n==null?void 0:n[0])!=null&&a.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function th(r){if(!r)return;const e=r==null?void 0:r[r.length-1];return uS(e)?e:void 0}const y2="base10",Jr="base16",Bs="base64pad",Yo="base64url",Pc="utf8",w2=0,ds=1,Oc=2,gS=0,dg=1,fc=12,W0=32;function vS(){const r=C0.generateKeyPair();return{privateKey:Er(r.secretKey,Jr),publicKey:Er(r.publicKey,Jr)}}function u0(){const r=$s.randomBytes(W0);return Er(r,Jr)}function bS(r,e){const t=C0.sharedKey(Ar(r,Jr),Ar(e,Jr),!0),i=new d_(Ac.SHA256,t).expand(W0);return Er(i,Jr)}function rh(r){const e=Ac.hash(Ar(r,Jr));return Er(e,Jr)}function fs(r){const e=Ac.hash(Ar(r,Pc));return Er(e,Jr)}function _2(r){return Ar(`${r}`,y2)}function ba(r){return Number(Er(r,y2))}function mS(r){const e=_2(typeof r.type<"u"?r.type:w2);if(ba(e)===ds&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?Ar(r.senderPublicKey,Jr):void 0,i=typeof r.iv<"u"?Ar(r.iv,Jr):$s.randomBytes(fc),n=new R0.ChaCha20Poly1305(Ar(r.symKey,Jr)).seal(i,Ar(r.message,Pc));return A2({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function yS(r,e){const t=_2(Oc),i=$s.randomBytes(fc),n=Ar(r,Pc);return A2({type:t,sealed:n,iv:i,encoding:e})}function wS(r){const e=new R0.ChaCha20Poly1305(Ar(r.symKey,Jr)),{sealed:t,iv:i}=vc({encoded:r.encoded,encoding:r==null?void 0:r.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return Er(n,Pc)}function _S(r,e){const{sealed:t}=vc({encoded:r,encoding:e});return Er(t,Pc)}function A2(r){const{encoding:e=Bs}=r;if(ba(r.type)===Oc)return Er(Yf([r.type,r.sealed]),e);if(ba(r.type)===ds){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Er(Yf([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return Er(Yf([r.type,r.iv,r.sealed]),e)}function vc(r){const{encoded:e,encoding:t=Bs}=r,i=Ar(e,t),n=i.slice(gS,dg),a=dg;if(ba(n)===ds){const p=a+W0,y=p+fc,A=i.slice(a,p),R=i.slice(p,y),O=i.slice(y);return{type:n,sealed:O,iv:R,senderPublicKey:A}}if(ba(n)===Oc){const p=i.slice(a),y=$s.randomBytes(fc);return{type:n,sealed:p,iv:y}}const f=a+fc,u=i.slice(a,f),b=i.slice(f);return{type:n,sealed:b,iv:u}}function AS(r,e){const t=vc({encoded:r,encoding:e==null?void 0:e.encoding});return E2({type:ba(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?Er(t.senderPublicKey,Jr):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function E2(r){const e=(r==null?void 0:r.type)||w2;if(e===ds){if(typeof(r==null?void 0:r.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(r==null?void 0:r.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r==null?void 0:r.senderPublicKey,receiverPublicKey:r==null?void 0:r.receiverPublicKey}}function pg(r){return r.type===ds&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function gg(r){return r.type===Oc}function ES(r){return new Yv.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function xS(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function SS(r){return Buffer.from(xS(r),"base64")}function IS(r,e){const[t,i,n]=r.split("."),a=SS(n);if(a.length!==64)throw new Error("Invalid signature length");const f=a.slice(0,32).toString("hex"),u=a.slice(32,64).toString("hex"),b=`${t}.${i}`,p=new Ac.SHA256().update(Buffer.from(b)).digest(),y=ES(e),A=Buffer.from(p).toString("hex");if(!y.verify(A,{r:f,s:u}))throw new Error("Invalid signature");return n0(r).payload}const MS="irn";function l0(r){return(r==null?void 0:r.relay)||{protocol:MS}}function nc(r){const e=X9[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var PS=Object.defineProperty,OS=Object.defineProperties,RS=Object.getOwnPropertyDescriptors,vg=Object.getOwnPropertySymbols,NS=Object.prototype.hasOwnProperty,CS=Object.prototype.propertyIsEnumerable,bg=(r,e,t)=>e in r?PS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,mg=(r,e)=>{for(var t in e||(e={}))NS.call(e,t)&&bg(r,t,e[t]);if(vg)for(var t of vg(e))CS.call(e,t)&&bg(r,t,e[t]);return r},TS=(r,e)=>OS(r,RS(e));function DS(r,e="-"){const t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){const a=n.replace(i,""),f=r[n];t[a]=f}}),t}function yg(r){if(!r.includes("wc:")){const b=Fb(r);b!=null&&b.includes("wc:")&&(r=b)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),a=typeof t<"u"?r.substring(t):"",f=dc.parse(a),u=typeof f.methods=="string"?f.methods.split(","):void 0;return{protocol:i,topic:FS(n[0]),version:parseInt(n[1],10),symKey:f.symKey,relay:DS(f),methods:u,expiryTimestamp:f.expiryTimestamp?parseInt(f.expiryTimestamp,10):void 0}}function FS(r){return r.startsWith("//")?r.substring(2):r}function BS(r,e="-"){const t="relay",i={};return Object.keys(r).forEach(n=>{const a=t+e+n;r[n]&&(i[a]=r[n])}),i}function wg(r){return`${r.protocol}:${r.topic}@${r.version}?`+dc.stringify(mg(TS(mg({symKey:r.symKey},BS(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function kf(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function _o(r){const e=[];return r.forEach(t=>{const[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function qS(r){const e=[];return Object.values(r).forEach(t=>{e.push(..._o(t.accounts))}),e}function LS(r,e){const t=[];return Object.values(r).forEach(i=>{_o(i.accounts).includes(e)&&t.push(...i.methods)}),t}function US(r,e){const t=[];return Object.values(r).forEach(i=>{_o(i.accounts).includes(e)&&t.push(...i.events)}),t}function J0(r){return r.includes(":")}function sc(r){return J0(r)?r.split(":")[0]:r}function $S(r){const e={};return r==null||r.forEach(t=>{const[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function _g(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=$S(e);for(const[i,n]of Object.entries(t))n.methods?n.methods=Qf(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}const zS={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},jS={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Ae(r,e){const{message:t,code:i}=jS[r];return{message:e?`${t} ${e}`:t,code:i}}function Ut(r,e){const{message:t,code:i}=zS[r];return{message:e?`${t} ${e}`:t,code:i}}function jn(r,e){return!!Array.isArray(r)}function bc(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function fi(r){return typeof r>"u"}function fr(r,e){return e&&fi(r)?!0:typeof r=="string"&&!!r.trim().length}function Y0(r,e){return typeof r=="number"&&!isNaN(r)}function kS(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t);let a=!0;return fa(n,i)?(i.forEach(f=>{const{accounts:u,methods:b,events:p}=r.namespaces[f],y=_o(u),A=t[f];(!fa(Pb(f,A),y)||!fa(A.methods,b)||!fa(A.events,p))&&(a=!1)}),a):!1}function yh(r){return fr(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function HS(r){if(fr(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&yh(t)}}return!1}function KS(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(fr(r,!1)){if(e(r))return!0;const t=Fb(r);return e(t)}}catch{}return!1}function VS(r){var e;return(e=r==null?void 0:r.proposer)==null?void 0:e.publicKey}function GS(r){return r==null?void 0:r.topic}function WS(r,e){let t=null;return fr(r==null?void 0:r.publicKey,!1)||(t=Ae("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function Ag(r){let e=!0;return jn(r)?r.length&&(e=r.every(t=>fr(t,!1))):e=!1,e}function JS(r,e,t){let i=null;return jn(e)&&e.length?e.forEach(n=>{i||yh(n)||(i=Ut("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):yh(r)||(i=Ut("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function YS(r,e,t){let i=null;return Object.entries(r).forEach(([n,a])=>{if(i)return;const f=JS(n,Pb(n,a),`${e} ${t}`);f&&(i=f)}),i}function QS(r,e){let t=null;return jn(r)?r.forEach(i=>{t||HS(i)||(t=Ut("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Ut("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function XS(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=QS(i==null?void 0:i.accounts,`${e} namespace`);n&&(t=n)}),t}function ZS(r,e){let t=null;return Ag(r==null?void 0:r.methods)?Ag(r==null?void 0:r.events)||(t=Ut("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Ut("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function x2(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=ZS(i,`${e}, namespace`);n&&(t=n)}),t}function eI(r,e,t){let i=null;if(r&&bc(r)){const n=x2(r,e);n&&(i=n);const a=YS(r,e,t);a&&(i=a)}else i=Ae("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Cl(r,e){let t=null;if(r&&bc(r)){const i=x2(r,e);i&&(t=i);const n=XS(r,e);n&&(t=n)}else t=Ae("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function S2(r){return fr(r.protocol,!0)}function tI(r,e){let t=!1;return r?r&&jn(r)&&r.length&&r.forEach(i=>{t=S2(i)}):t=!0,t}function rI(r){return typeof r=="number"}function oi(r){return typeof r<"u"&&typeof r!==null}function iI(r){return!(!r||typeof r!="object"||!r.code||!Y0(r.code)||!r.message||!fr(r.message,!1))}function nI(r){return!(fi(r)||!fr(r.method,!1))}function sI(r){return!(fi(r)||fi(r.result)&&fi(r.error)||!Y0(r.id)||!fr(r.jsonrpc,!1))}function aI(r){return!(fi(r)||!fr(r.name,!1))}function Eg(r,e){return!(!yh(e)||!qS(r).includes(e))}function oI(r,e,t){return fr(t,!1)?LS(r,e).includes(t):!1}function cI(r,e,t){return fr(t,!1)?US(r,e).includes(t):!1}function xg(r,e,t){let i=null;const n=fI(r),a=hI(e),f=Object.keys(n),u=Object.keys(a),b=Sg(Object.keys(r)),p=Sg(Object.keys(e)),y=b.filter(A=>!p.includes(A));return y.length&&(i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. - Required: ${y.toString()} - Received: ${Object.keys(e).toString()}`)),fa(f,u)||(i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. - Required: ${f.toString()} - Approved: ${u.toString()}`)),Object.keys(e).forEach(A=>{if(!A.includes(":")||i)return;const R=_o(e[A].accounts);R.includes(A)||(i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${A} - Required: ${A} - Approved: ${R.toString()}`))}),f.forEach(A=>{i||(fa(n[A].methods,a[A].methods)?fa(n[A].events,a[A].events)||(i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${A}`)):i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${A}`))}),i}function fI(r){const e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function Sg(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function hI(r){const e={};return Object.keys(r).forEach(t=>{if(t.includes(":"))e[t]=r[t];else{const i=_o(r[t].accounts);i==null||i.forEach(n=>{e[n]={accounts:r[t].accounts.filter(a=>a.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}}),e}function uI(r,e){return Y0(r)&&r<=e.max&&r>=e.min}function Ig(){const r=Ic();return new Promise(e=>{switch(r){case wi.browser:e(lI());break;case wi.reactNative:e(dI());break;case wi.node:e(pI());break;default:e(!0)}})}function lI(){return Sc()&&(navigator==null?void 0:navigator.onLine)}async function dI(){if(vo()&&typeof global<"u"&&global!=null&&global.NetInfo){const r=await(global==null?void 0:global.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function pI(){return!0}function gI(r){switch(Ic()){case wi.browser:vI(r);break;case wi.reactNative:bI(r);break}}function vI(r){!vo()&&Sc()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function bI(r){vo()&&typeof global<"u"&&global!=null&&global.NetInfo&&(global==null||global.NetInfo.addEventListener(e=>r(e==null?void 0:e.isConnected)))}const Tl={};class Qo{static get(e){return Tl[e]}static set(e,t){Tl[e]=t}static delete(e){delete Tl[e]}}class Aa{}let mI=class extends Aa{constructor(e){super()}};const Mg=xe.FIVE_SECONDS,Ao={pulse:"heartbeat_pulse"};let yI=class I2 extends mI{constructor(e){super(e),this.events=new Hi.EventEmitter,this.interval=Mg,this.interval=(e==null?void 0:e.interval)||Mg}static async init(e){const t=new I2(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),xe.toMiliseconds(this.interval))}pulse(){this.events.emit(Ao.pulse)}};const wI=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,_I=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,AI=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function EI(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){xI(r);return}return e}function xI(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Hf(r,e={}){if(typeof r!="string")return r;const t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){const i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!AI.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(wI.test(r)||_I.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,EI)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function SI(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function _r(r,...e){try{return SI(r(...e))}catch(t){return Promise.reject(t)}}function II(r){const e=typeof r;return r===null||e!=="object"&&e!=="function"}function MI(r){const e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function ih(r){if(II(r))return String(r);if(MI(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return ih(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function M2(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const d0="base64:";function PI(r){if(typeof r=="string")return r;M2();const e=Buffer.from(r).toString("base64");return d0+e}function OI(r){return typeof r!="string"||!r.startsWith(d0)?r:(M2(),Buffer.from(r.slice(d0.length),"base64"))}function ai(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function RI(...r){return ai(r.join(":"))}function Kf(r){return r=ai(r),r?r+":":""}const NI="memory",CI=()=>{const r=new Map;return{name:NI,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function TI(r={}){const e={mounts:{"":r.driver||CI()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=p=>{for(const y of e.mountpoints)if(p.startsWith(y))return{base:y,relativeKey:p.slice(y.length),driver:e.mounts[y]};return{base:"",relativeKey:p,driver:e.mounts[""]}},i=(p,y)=>e.mountpoints.filter(A=>A.startsWith(p)||y&&p.startsWith(A)).map(A=>({relativeBase:p.length>A.length?p.slice(A.length):void 0,mountpoint:A,driver:e.mounts[A]})),n=(p,y)=>{if(e.watching){y=ai(y);for(const A of e.watchListeners)A(p,y)}},a=async()=>{if(!e.watching){e.watching=!0;for(const p in e.mounts)e.unwatch[p]=await Pg(e.mounts[p],n,p)}},f=async()=>{if(e.watching){for(const p in e.unwatch)await e.unwatch[p]();e.unwatch={},e.watching=!1}},u=(p,y,A)=>{const R=new Map,O=N=>{let K=R.get(N.base);return K||(K={driver:N.driver,base:N.base,items:[]},R.set(N.base,K)),K};for(const N of p){const K=typeof N=="string",W=ai(K?N:N.key),Q=K?void 0:N.value,j=K||!N.options?y:{...y,...N.options},Y=t(W);O(Y).items.push({key:W,value:Q,relativeKey:Y.relativeKey,options:j})}return Promise.all([...R.values()].map(N=>A(N))).then(N=>N.flat())},b={hasItem(p,y={}){p=ai(p);const{relativeKey:A,driver:R}=t(p);return _r(R.hasItem,A,y)},getItem(p,y={}){p=ai(p);const{relativeKey:A,driver:R}=t(p);return _r(R.getItem,A,y).then(O=>Hf(O))},getItems(p,y){return u(p,y,A=>A.driver.getItems?_r(A.driver.getItems,A.items.map(R=>({key:R.relativeKey,options:R.options})),y).then(R=>R.map(O=>({key:RI(A.base,O.key),value:Hf(O.value)}))):Promise.all(A.items.map(R=>_r(A.driver.getItem,R.relativeKey,R.options).then(O=>({key:R.key,value:Hf(O)})))))},getItemRaw(p,y={}){p=ai(p);const{relativeKey:A,driver:R}=t(p);return R.getItemRaw?_r(R.getItemRaw,A,y):_r(R.getItem,A,y).then(O=>OI(O))},async setItem(p,y,A={}){if(y===void 0)return b.removeItem(p);p=ai(p);const{relativeKey:R,driver:O}=t(p);O.setItem&&(await _r(O.setItem,R,ih(y),A),O.watch||n("update",p))},async setItems(p,y){await u(p,y,async A=>{if(A.driver.setItems)return _r(A.driver.setItems,A.items.map(R=>({key:R.relativeKey,value:ih(R.value),options:R.options})),y);A.driver.setItem&&await Promise.all(A.items.map(R=>_r(A.driver.setItem,R.relativeKey,ih(R.value),R.options)))})},async setItemRaw(p,y,A={}){if(y===void 0)return b.removeItem(p,A);p=ai(p);const{relativeKey:R,driver:O}=t(p);if(O.setItemRaw)await _r(O.setItemRaw,R,y,A);else if(O.setItem)await _r(O.setItem,R,PI(y),A);else return;O.watch||n("update",p)},async removeItem(p,y={}){typeof y=="boolean"&&(y={removeMeta:y}),p=ai(p);const{relativeKey:A,driver:R}=t(p);R.removeItem&&(await _r(R.removeItem,A,y),(y.removeMeta||y.removeMata)&&await _r(R.removeItem,A+"$",y),R.watch||n("remove",p))},async getMeta(p,y={}){typeof y=="boolean"&&(y={nativeOnly:y}),p=ai(p);const{relativeKey:A,driver:R}=t(p),O=Object.create(null);if(R.getMeta&&Object.assign(O,await _r(R.getMeta,A,y)),!y.nativeOnly){const N=await _r(R.getItem,A+"$",y).then(K=>Hf(K));N&&typeof N=="object"&&(typeof N.atime=="string"&&(N.atime=new Date(N.atime)),typeof N.mtime=="string"&&(N.mtime=new Date(N.mtime)),Object.assign(O,N))}return O},setMeta(p,y,A={}){return this.setItem(p+"$",y,A)},removeMeta(p,y={}){return this.removeItem(p+"$",y)},async getKeys(p,y={}){p=Kf(p);const A=i(p,!0);let R=[];const O=[];for(const N of A){const K=await _r(N.driver.getKeys,N.relativeBase,y);for(const W of K){const Q=N.mountpoint+ai(W);R.some(j=>Q.startsWith(j))||O.push(Q)}R=[N.mountpoint,...R.filter(W=>!W.startsWith(N.mountpoint))]}return p?O.filter(N=>N.startsWith(p)&&N[N.length-1]!=="$"):O.filter(N=>N[N.length-1]!=="$")},async clear(p,y={}){p=Kf(p),await Promise.all(i(p,!1).map(async A=>{if(A.driver.clear)return _r(A.driver.clear,A.relativeBase,y);if(A.driver.removeItem){const R=await A.driver.getKeys(A.relativeBase||"",y);return Promise.all(R.map(O=>A.driver.removeItem(O,y)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(p=>Og(p)))},async watch(p){return await a(),e.watchListeners.push(p),async()=>{e.watchListeners=e.watchListeners.filter(y=>y!==p),e.watchListeners.length===0&&await f()}},async unwatch(){e.watchListeners=[],await f()},mount(p,y){if(p=Kf(p),p&&e.mounts[p])throw new Error(`already mounted at ${p}`);return p&&(e.mountpoints.push(p),e.mountpoints.sort((A,R)=>R.length-A.length)),e.mounts[p]=y,e.watching&&Promise.resolve(Pg(y,n,p)).then(A=>{e.unwatch[p]=A}).catch(console.error),b},async unmount(p,y=!0){p=Kf(p),!(!p||!e.mounts[p])&&(e.watching&&p in e.unwatch&&(e.unwatch[p](),delete e.unwatch[p]),y&&await Og(e.mounts[p]),e.mountpoints=e.mountpoints.filter(A=>A!==p),delete e.mounts[p])},getMount(p=""){p=ai(p)+":";const y=t(p);return{driver:y.driver,base:y.base}},getMounts(p="",y={}){return p=ai(p),i(p,y.parents).map(R=>({driver:R.driver,base:R.mountpoint}))},keys:(p,y={})=>b.getKeys(p,y),get:(p,y={})=>b.getItem(p,y),set:(p,y,A={})=>b.setItem(p,y,A),has:(p,y={})=>b.hasItem(p,y),del:(p,y={})=>b.removeItem(p,y),remove:(p,y={})=>b.removeItem(p,y)};return b}function Pg(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function Og(r){typeof r.dispose=="function"&&await _r(r.dispose)}function Ea(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function P2(r,e){const t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);const i=Ea(t);return(n,a)=>i.then(f=>a(f.transaction(e,n).objectStore(e)))}let Dl;function Rc(){return Dl||(Dl=P2("keyval-store","keyval")),Dl}function Rg(r,e=Rc()){return e("readonly",t=>Ea(t.get(r)))}function DI(r,e,t=Rc()){return t("readwrite",i=>(i.put(e,r),Ea(i.transaction)))}function FI(r,e=Rc()){return e("readwrite",t=>(t.delete(r),Ea(t.transaction)))}function BI(r=Rc()){return r("readwrite",e=>(e.clear(),Ea(e.transaction)))}function qI(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Ea(r.transaction)}function LI(r=Rc()){return r("readonly",e=>{if(e.getAllKeys)return Ea(e.getAllKeys());const t=[];return qI(e,i=>t.push(i.key)).then(()=>t)})}const UI="idb-keyval";var $I=(r={})=>{const e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n;let i;return r.dbName&&r.storeName&&(i=P2(r.dbName,r.storeName)),{name:UI,options:r,async hasItem(n){return!(typeof await Rg(t(n),i)>"u")},async getItem(n){return await Rg(t(n),i)??null},setItem(n,a){return DI(t(n),a,i)},removeItem(n){return FI(t(n),i)},getKeys(){return LI(i)},clear(){return BI(i)}}};const zI="WALLET_CONNECT_V2_INDEXED_DB",jI="keyvaluestorage";let kI=class{constructor(){this.indexedDb=TI({driver:$I({dbName:zI,storeName:jI})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,vs(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Fl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},nh={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Fl<"u"&&Fl.localStorage?nh.exports=Fl.localStorage:typeof window<"u"&&window.localStorage?nh.exports=window.localStorage:nh.exports=new e})();function HI(r){var e;return[r[0],ga((e=r[1])!=null?e:"")]}class KI{constructor(){this.localStorage=nh.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(HI)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return ga(t)}async setItem(e,t){this.localStorage.setItem(e,vs(t))}async removeItem(e){this.localStorage.removeItem(e)}}const VI="wc_storage_version",Ng=1,GI=async(r,e,t)=>{const i=VI,n=await e.getItem(i);if(n&&n>=Ng){t(e);return}const a=await r.getKeys();if(!a.length){t(e);return}const f=[];for(;a.length;){const u=a.shift();if(!u)continue;const b=u.toLowerCase();if(b.includes("wc@")||b.includes("walletconnect")||b.includes("wc_")||b.includes("wallet_connect")){const p=await r.getItem(u);await e.setItem(u,p),f.push(u)}}await e.setItem(i,Ng),t(e),WI(r,f)},WI=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})};let JI=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new KI;this.storage=e;try{const t=new kI;GI(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};function YI(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}var QI=XI;function XI(r,e,t){var i=t&&t.stringify||YI,n=1;if(typeof r=="object"&&r!==null){var a=e.length+n;if(a===1)return r;var f=new Array(a);f[0]=i(r);for(var u=1;u-1?A:0,r.charCodeAt(O+1)){case 100:case 102:if(y>=b||e[y]==null)break;A=b||e[y]==null)break;A=b||e[y]===void 0)break;A",A=O+2,O++;break}p+=i(e[y]),A=O+2,O++;break;case 115:if(y>=b)break;A-1&&(a=!1);const f=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");const u=r.level||"info",b=Object.create(t);b.log||(b.log=yc),Object.defineProperty(b,"levelVal",{get:y}),Object.defineProperty(b,"level",{get:A,set:R});const p={transmit:e,serialize:n,asObject:r.browser.asObject,levels:f,timestamp:sM(r)};b.levels=Ln.levels,b.level=u,b.setMaxListeners=b.getMaxListeners=b.emit=b.addListener=b.on=b.prependListener=b.once=b.prependOnceListener=b.removeListener=b.removeAllListeners=b.listeners=b.listenerCount=b.eventNames=b.write=b.flush=yc,b.serializers=i,b._serialize=n,b._stdErrSerialize=a,b.child=O,e&&(b._logEvent=p0());function y(){return this.level==="silent"?1/0:this.levels.values[this.level]}function A(){return this._level}function R(N){if(N!=="silent"&&!this.levels.values[N])throw Error("unknown level "+N);this._level=N,Ka(p,b,"error","log"),Ka(p,b,"fatal","error"),Ka(p,b,"warn","error"),Ka(p,b,"info","log"),Ka(p,b,"debug","log"),Ka(p,b,"trace","log")}function O(N,K){if(!N)throw new Error("missing bindings for child Pino");K=K||{},n&&N.serializers&&(K.serializers=N.serializers);const W=K.serializers;if(n&&W){var Q=Object.assign({},i,W),j=r.browser.serialize===!0?Object.keys(Q):n;delete N.serializers,kh([N],j,Q,this._stdErrSerialize)}function Y(U){this._childLevel=(U._childLevel|0)+1,this.error=Va(U,N,"error"),this.fatal=Va(U,N,"fatal"),this.warn=Va(U,N,"warn"),this.info=Va(U,N,"info"),this.debug=Va(U,N,"debug"),this.trace=Va(U,N,"trace"),Q&&(this.serializers=Q,this._serialize=j),e&&(this._logEvent=p0([].concat(U._logEvent.bindings,N)))}return Y.prototype=this,new Y(this)}return b}Ln.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};Ln.stdSerializers=ZI;Ln.stdTimeFunctions=Object.assign({},{nullTime:O2,epochTime:R2,unixTime:aM,isoTime:oM});function Ka(r,e,t,i){const n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?yc:n[t]?n[t]:mc[t]||mc[i]||yc,tM(r,e,t)}function tM(r,e,t){!r.transmit&&e[t]===yc||(e[t]=function(i){return function(){const a=r.timestamp(),f=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===mc?mc:this;for(var b=0;b-1&&a in t&&(r[n][a]=t[a](r[n][a]))}function Va(r,e,t){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;nthis.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const t=e.value;return e=e.next,{done:!1,value:t}}}}},N2=class{constructor(e,t=Q0){this.level=e??"error",this.levelValue=Ja.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new Tg(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===Ja.levels.values.error?console.error(e):t===Ja.levels.values.warn?console.warn(e):t===Ja.levels.values.debug?console.debug(e):t===Ja.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(vs({timestamp:new Date().toISOString(),log:e}));const t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new Tg(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push(vs({extraMetadata:e})),new Blob(t,{type:"application/json"})}},uM=class{constructor(e,t=Q0){this.baseChunkLogger=new N2(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}};class lM{constructor(e,t=Q0){this.baseChunkLogger=new N2(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var dM=Object.defineProperty,pM=Object.defineProperties,gM=Object.getOwnPropertyDescriptors,Dg=Object.getOwnPropertySymbols,vM=Object.prototype.hasOwnProperty,bM=Object.prototype.propertyIsEnumerable,Fg=(r,e,t)=>e in r?dM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,wh=(r,e)=>{for(var t in e||(e={}))vM.call(e,t)&&Fg(r,t,e[t]);if(Dg)for(var t of Dg(e))bM.call(e,t)&&Fg(r,t,e[t]);return r},_h=(r,e)=>pM(r,gM(e));function Hh(r){return _h(wh({},r),{level:(r==null?void 0:r.level)||fM.level})}function mM(r,e=Cc){return r[e]||""}function yM(r,e,t=Cc){return r[t]=e,r}function di(r,e=Cc){let t="";return typeof r.bindings>"u"?t=mM(r,e):t=r.bindings().context||"",t}function wM(r,e,t=Cc){const i=di(r,t);return i.trim()?`${i}/${e}`:e}function Yr(r,e,t=Cc){const i=wM(r,e,t),n=r.child({context:i});return yM(n,i,t)}function _M(r){var e,t;const i=new uM((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Nc(_h(wh({},r.opts),{level:"trace",browser:_h(wh({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function AM(r){var e;const t=new lM((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Nc(_h(wh({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function EM(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?_M(r):AM(r)}let xM=class extends Aa{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},SM=class extends Aa{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},IM=class{constructor(e,t){this.logger=e,this.core=t}},MM=class extends Aa{constructor(e,t){super(),this.relayer=e,this.logger=t}},PM=class extends Aa{constructor(e){super()}},OM=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}},RM=class extends Aa{constructor(e,t){super(),this.relayer=e,this.logger=t}},NM=class extends Aa{constructor(e,t){super(),this.core=e,this.logger=t}},CM=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},TM=class{constructor(e,t){this.projectId=e,this.logger=t}},DM=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}},FM=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},BM=class{constructor(e){this.client=e}};const qM="PARSE_ERROR",LM="INVALID_REQUEST",UM="METHOD_NOT_FOUND",$M="INVALID_PARAMS",C2="INTERNAL_ERROR",X0="SERVER_ERROR",zM=[-32700,-32600,-32601,-32602,-32603],hc={[qM]:{code:-32700,message:"Parse error"},[LM]:{code:-32600,message:"Invalid Request"},[UM]:{code:-32601,message:"Method not found"},[$M]:{code:-32602,message:"Invalid params"},[C2]:{code:-32603,message:"Internal error"},[X0]:{code:-32e3,message:"Server error"}},T2=X0;function jM(r){return zM.includes(r)}function Bg(r){return Object.keys(hc).includes(r)?hc[r]:hc[T2]}function kM(r){const e=Object.values(hc).find(t=>t.code===r);return e||hc[T2]}function D2(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var F2={};/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var g0=function(r,e){return g0=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},g0(r,e)};function HM(r,e){g0(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var v0=function(){return v0=Object.assign||function(e){for(var t,i=1,n=arguments.length;i=0;u--)(f=r[u])&&(a=(n<3?f(a):n>3?f(e,t,a):f(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a}function GM(r,e){return function(t,i){e(t,i,r)}}function WM(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function JM(r,e,t,i){function n(a){return a instanceof t?a:new t(function(f){f(a)})}return new(t||(t=Promise))(function(a,f){function u(y){try{p(i.next(y))}catch(A){f(A)}}function b(y){try{p(i.throw(y))}catch(A){f(A)}}function p(y){y.done?a(y.value):n(y.value).then(u,b)}p((i=i.apply(r,e||[])).next())})}function YM(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,f;return f={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function u(p){return function(y){return b([p,y])}}function b(p){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(a=p[0]&2?n.return:p[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,p[1])).done)return a;switch(n=0,a&&(p=[p[0]&2,a.value]),p[0]){case 0:case 1:a=p;break;case 4:return t.label++,{value:p[1],done:!1};case 5:t.label++,n=p[1],p=[0];continue;case 7:p=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(p[0]===6||p[0]===2)){t=0;continue}if(p[0]===3&&(!a||p[1]>a[0]&&p[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function B2(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,a=[],f;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(u){f={error:u}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(f)throw f.error}}return a}function ZM(){for(var r=[],e=0;e1||u(R,O)})})}function u(R,O){try{b(i[R](O))}catch(N){A(a[0][3],N)}}function b(R){R.value instanceof wc?Promise.resolve(R.value.v).then(p,y):A(a[0][2],R)}function p(R){u("next",R)}function y(R){u("throw",R)}function A(R,O){R(O),a.shift(),a.length&&u(a[0][0],a[0][1])}}function rP(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,a){e[n]=r[n]?function(f){return(t=!t)?{value:wc(r[n](f)),done:n==="return"}:a?a(f):f}:a}}function iP(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof b0=="function"?b0(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(a){t[a]=r[a]&&function(f){return new Promise(function(u,b){f=r[a](f),n(u,b,f.done,f.value)})}}function n(a,f,u,b){Promise.resolve(b).then(function(p){a({value:p,done:u})},f)}}function nP(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function sP(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function aP(r){return r&&r.__esModule?r:{default:r}}function oP(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function cP(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}const fP=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return v0},__asyncDelegator:rP,__asyncGenerator:tP,__asyncValues:iP,__await:wc,__awaiter:JM,__classPrivateFieldGet:oP,__classPrivateFieldSet:cP,__createBinding:QM,__decorate:VM,__exportStar:XM,__extends:HM,__generator:YM,__importDefault:aP,__importStar:sP,__makeTemplateObject:nP,__metadata:WM,__param:GM,__read:B2,__rest:KM,__spread:ZM,__spreadArrays:eP,__values:b0},Symbol.toStringTag,{value:"Module"})),hP=Tv(fP);var ss={},qg;function uP(){if(qg)return ss;qg=1,Object.defineProperty(ss,"__esModule",{value:!0}),ss.isBrowserCryptoAvailable=ss.getSubtleCrypto=ss.getBrowerCrypto=void 0;function r(){return(ji===null||ji===void 0?void 0:ji.crypto)||(ji===null||ji===void 0?void 0:ji.msCrypto)||{}}ss.getBrowerCrypto=r;function e(){const i=r();return i.subtle||i.webkitSubtle}ss.getSubtleCrypto=e;function t(){return!!r()&&!!e()}return ss.isBrowserCryptoAvailable=t,ss}var as={},Lg;function lP(){if(Lg)return as;Lg=1,Object.defineProperty(as,"__esModule",{value:!0}),as.isBrowser=as.isNode=as.isReactNative=void 0;function r(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}as.isReactNative=r;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}as.isNode=e;function t(){return!r()&&!e()}return as.isBrowser=t,as}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=hP;e.__exportStar(uP(),r),e.__exportStar(lP(),r)})(F2);function Cs(r=3){const e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function ha(r=6){return BigInt(Cs(r))}function qs(r,e,t){return{id:t||Cs(),jsonrpc:"2.0",method:r,params:e}}function Kh(r,e){return{id:r,jsonrpc:"2.0",result:e}}function Vh(r,e,t){return{id:r,jsonrpc:"2.0",error:dP(e)}}function dP(r,e){return typeof r>"u"?Bg(C2):(typeof r=="string"&&(r=Object.assign(Object.assign({},Bg(X0)),{message:r})),jM(r.code)&&(r=kM(r.code)),r)}class pP{}class gP extends pP{constructor(){super()}}class vP extends gP{constructor(e){super()}}const bP="^https?:",mP="^wss?:";function yP(r){const e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function q2(r,e){const t=yP(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function Ug(r){return q2(r,bP)}function $g(r){return q2(r,mP)}function wP(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function L2(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function Z0(r){return L2(r)&&"method"in r}function Gh(r){return L2(r)&&(Mn(r)||$i(r))}function Mn(r){return"result"in r}function $i(r){return"error"in r}let gn=class extends vP{constructor(e){super(e),this.events=new Hi.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(qs(e.method,e.params||[],e.id||ha().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(a){n(a)}this.events.on(`${e.id}`,a=>{$i(a)?n(a.error):i(a.result)});try{await this.connection.send(e,t)}catch(a){n(a)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Gh(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};const _P=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),AP=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",zg=r=>r.split("?")[0],jg=10,EP=_P();let xP=class{constructor(e){if(this.url=e,this.events=new Hi.EventEmitter,this.registering=!1,!$g(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(vs(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!$g(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),n(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{const n=new URLSearchParams(e).get("origin"),a=F2.isReactNative()?{headers:{origin:n}}:{rejectUnauthorized:!wP(e)},f=new EP(e,[],a);AP()?f.onerror=u=>{const b=u;i(this.emitError(b.error))}:f.on("error",u=>{i(this.emitError(u))}),f.onopen=()=>{this.onOpen(f),t(f)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?ga(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),a=Vh(e,n);this.events.emit("payload",a)}parseError(e,t=this.url){return D2(e,zg(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>jg&&this.events.setMaxListeners(jg)}emitError(e){const t=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${zg(this.url)}`));return this.events.emit("register_error",t),t}};var Ah={exports:{}};Ah.exports;(function(r,e){var t=200,i="__lodash_hash_undefined__",n=1,a=2,f=9007199254740991,u="[object Arguments]",b="[object Array]",p="[object AsyncFunction]",y="[object Boolean]",A="[object Date]",R="[object Error]",O="[object Function]",N="[object GeneratorFunction]",K="[object Map]",W="[object Number]",Q="[object Null]",j="[object Object]",Y="[object Promise]",U="[object Proxy]",k="[object RegExp]",G="[object Set]",x="[object String]",B="[object Symbol]",ae="[object Undefined]",le="[object WeakMap]",F="[object ArrayBuffer]",m="[object DataView]",c="[object Float32Array]",h="[object Float64Array]",v="[object Int8Array]",_="[object Int16Array]",I="[object Int32Array]",M="[object Uint8Array]",S="[object Uint8ClampedArray]",d="[object Uint16Array]",g="[object Uint32Array]",T=/[\\^$.*+?()[\]{}|]/g,Z=/^\[object .+?Constructor\]$/,se=/^(?:0|[1-9]\d*)$/,P={};P[c]=P[h]=P[v]=P[_]=P[I]=P[M]=P[S]=P[d]=P[g]=!0,P[u]=P[b]=P[F]=P[y]=P[m]=P[A]=P[R]=P[O]=P[K]=P[W]=P[j]=P[k]=P[G]=P[x]=P[le]=!1;var ee=typeof ji=="object"&&ji&&ji.Object===Object&&ji,q=typeof self=="object"&&self&&self.Object===Object&&self,z=ee||q||Function("return this")(),H=e&&!e.nodeType&&e,w=H&&!0&&r&&!r.nodeType&&r,$=w&&w.exports===H,ne=$&&ee.process,ce=function(){try{return ne&&ne.binding&&ne.binding("util")}catch{}}(),he=ce&&ce.isTypedArray;function ye(V,te){for(var pe=-1,Ue=V==null?0:V.length,jt=0,pt=[];++pe-1}function Br(V,te){var pe=this.__data__,Ue=ks(pe,V);return Ue<0?(++this.size,pe.push([V,te])):pe[Ue][1]=te,this}bt.prototype.clear=Cr,bt.prototype.delete=Tr,bt.prototype.get=Dr,bt.prototype.has=Fr,bt.prototype.set=Br;function er(V){var te=-1,pe=V==null?0:V.length;for(this.clear();++tehr))return!1;var kt=pt.get(V);if(kt&&pt.get(te))return kt==te;var sr=-1,ei=!0,ur=pe&a?new Zr:void 0;for(pt.set(V,te),pt.set(te,V);++sr-1&&V%1==0&&V-1&&V%1==0&&V<=f}function Jc(V){var te=typeof V;return V!=null&&(te=="object"||te=="function")}function Vs(V){return V!=null&&typeof V=="object"}var Yc=he?Oe(he):qc;function tu(V){return Zh(V)?Fc(V):Lc(V)}function zt(){return[]}function $t(){return!1}r.exports=eu})(Ah,Ah.exports);var SP=Ah.exports;const IP=S0(SP),U2="wc",$2=2,ed="core",kn=`${U2}@2:${ed}:`,MP={name:ed,logger:"error"},PP={database:":memory:"},OP="crypto",kg="client_ed25519_seed",RP=xe.ONE_DAY,NP="keychain",CP="0.3",TP="messages",DP="0.3",FP=xe.SIX_HOURS,BP="publisher",z2="irn",qP="error",j2="wss://relay.walletconnect.org",LP="relayer",Gr={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},UP="_subscription",qi={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},$P=.1,m0="2.17.0",Kt={link_mode:"link_mode",relay:"relay"},zP="0.3",jP="WALLETCONNECT_CLIENT_ID",Hg="WALLETCONNECT_LINK_MODE_APPS",Pn={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},kP="subscription",HP="0.3",KP=xe.FIVE_SECONDS*1e3,VP="pairing",GP="0.3",Xo={wc_pairingDelete:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:xe.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:xe.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:0},res:{ttl:xe.ONE_DAY,prompt:!1,tag:0}}},ca={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},on={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},WP="history",JP="0.3",YP="expirer",Li={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},QP="0.3",XP="verify-api",ZP="https://verify.walletconnect.com",k2="https://verify.walletconnect.org",uc=k2,eO=`${uc}/v3`,tO=[ZP,k2],rO="echo",iO="https://echo.walletconnect.com",xn={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},os={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},cn={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},sa={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},aa={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Zo={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},nO=.1,sO="event-client",aO=86400,oO="https://pulse.walletconnect.org/batch";function cO(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,U=new Uint8Array(Y);Q!==j;){for(var k=N[Q],G=0,x=Y-1;(k!==0||G>>0,U[x]=k%u>>>0,k=k/u>>>0;if(k!==0)throw new Error("Non-zero carry");W=G,Q++}for(var B=Y-W;B!==Y&&U[B]===0;)B++;for(var ae=b.repeat(K);B>>0,Y=new Uint8Array(j);N[K];){var U=t[N.charCodeAt(K)];if(U===255)return;for(var k=0,G=j-1;(U!==0||k>>0,Y[G]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");Q=k,K++}if(N[K]!==" "){for(var x=j-Q;x!==j&&Y[x]===0;)x++;for(var B=new Uint8Array(W+(j-x)),ae=W;x!==j;)B[ae++]=Y[x++];return B}}}function O(N){var K=R(N);if(K)return K;throw new Error(`Non-${e} character`)}return{encode:A,decodeUnsafe:R,decode:O}}var fO=cO,hO=fO;const H2=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},uO=r=>new TextEncoder().encode(r),lO=r=>new TextDecoder().decode(r);class dO{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class pO{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return K2(this,e)}}class gO{constructor(e){this.decoders=e}or(e){return K2(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const K2=(r,e)=>new gO({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class vO{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new dO(e,t,i),this.decoder=new pO(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Wh=({name:r,prefix:e,encode:t,decode:i})=>new vO(r,e,t,i),Tc=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=hO(t,e);return Wh({prefix:r,name:e,encode:i,decode:a=>H2(n(a))})},bO=(r,e,t,i)=>{const n={};for(let y=0;y=8&&(u-=8,f[p++]=255&b>>u)}if(u>=t||255&b<<8-u)throw new SyntaxError("Unexpected end of data");return f},mO=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<t;)f-=t,a+=e[n&u>>f];if(f&&(a+=e[n&u<Wh({prefix:e,name:r,encode(n){return mO(n,i,t)},decode(n){return bO(n,i,t,r)}}),yO=Wh({prefix:"\0",name:"identity",encode:r=>lO(r),decode:r=>uO(r)});var wO=Object.freeze({__proto__:null,identity:yO});const _O=Nr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var AO=Object.freeze({__proto__:null,base2:_O});const EO=Nr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var xO=Object.freeze({__proto__:null,base8:EO});const SO=Tc({prefix:"9",name:"base10",alphabet:"0123456789"});var IO=Object.freeze({__proto__:null,base10:SO});const MO=Nr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),PO=Nr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var OO=Object.freeze({__proto__:null,base16:MO,base16upper:PO});const RO=Nr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),NO=Nr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),CO=Nr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),TO=Nr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),DO=Nr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),FO=Nr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),BO=Nr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),qO=Nr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),LO=Nr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var UO=Object.freeze({__proto__:null,base32:RO,base32upper:NO,base32pad:CO,base32padupper:TO,base32hex:DO,base32hexupper:FO,base32hexpad:BO,base32hexpadupper:qO,base32z:LO});const $O=Tc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zO=Tc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jO=Object.freeze({__proto__:null,base36:$O,base36upper:zO});const kO=Tc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),HO=Tc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var KO=Object.freeze({__proto__:null,base58btc:kO,base58flickr:HO});const VO=Nr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),GO=Nr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),WO=Nr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),JO=Nr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var YO=Object.freeze({__proto__:null,base64:VO,base64pad:GO,base64url:WO,base64urlpad:JO});const V2=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),QO=V2.reduce((r,e,t)=>(r[t]=e,r),[]),XO=V2.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ZO(r){return r.reduce((e,t)=>(e+=QO[t],e),"")}function eR(r){const e=[];for(const t of r){const i=XO[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const tR=Wh({prefix:"🚀",name:"base256emoji",encode:ZO,decode:eR});var rR=Object.freeze({__proto__:null,base256emoji:tR}),iR=G2,Kg=128,nR=127,sR=~nR,aR=Math.pow(2,31);function G2(r,e,t){e=e||[],t=t||0;for(var i=t;r>=aR;)e[t++]=r&255|Kg,r/=128;for(;r&sR;)e[t++]=r&255|Kg,r>>>=7;return e[t]=r|0,G2.bytes=t-i+1,e}var oR=y0,cR=128,Vg=127;function y0(r,i){var t=0,i=i||0,n=0,a=i,f,u=r.length;do{if(a>=u)throw y0.bytes=0,new RangeError("Could not decode varint");f=r[a++],t+=n<28?(f&Vg)<=cR);return y0.bytes=a-i,t}var fR=Math.pow(2,7),hR=Math.pow(2,14),uR=Math.pow(2,21),lR=Math.pow(2,28),dR=Math.pow(2,35),pR=Math.pow(2,42),gR=Math.pow(2,49),vR=Math.pow(2,56),bR=Math.pow(2,63),mR=function(r){return r(W2.encode(r,e,t),e),Wg=r=>W2.encodingLength(r),w0=(r,e)=>{const t=e.byteLength,i=Wg(r),n=i+Wg(t),a=new Uint8Array(n+t);return Gg(r,a,0),Gg(t,a,i),a.set(e,n),new wR(r,t,e,a)};class wR{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const J2=({name:r,code:e,encode:t})=>new _R(r,e,t);class _R{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?w0(this.code,t):t.then(i=>w0(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Y2=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),AR=J2({name:"sha2-256",code:18,encode:Y2("SHA-256")}),ER=J2({name:"sha2-512",code:19,encode:Y2("SHA-512")});var xR=Object.freeze({__proto__:null,sha256:AR,sha512:ER});const Q2=0,SR="identity",X2=H2,IR=r=>w0(Q2,X2(r)),MR={code:Q2,name:SR,encode:X2,digest:IR};var PR=Object.freeze({__proto__:null,identity:MR});new TextEncoder,new TextDecoder;const Jg={...wO,...AO,...xO,...IO,...OO,...UO,...jO,...KO,...YO,...rR};({...xR,...PR});function OR(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Z2(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const Yg=Z2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ql=Z2("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);const e=OR(r.length);for(let t=0;t{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:a}=Ae("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(a)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=Yr(t,this.name)}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Nb(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Cb(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class TR{constructor(e,t,i){this.core=e,this.logger=t,this.name=OP,this.randomSessionIdentifier=u0(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),a=C1(n);return Mb(a.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=vS();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const a=await this.getClientSeed(),f=C1(a),u=this.randomSessionIdentifier;return await Q9(u,n,RP,f)},this.generateSharedKey=(n,a,f)=>{this.isInitialized();const u=this.getPrivateKey(n),b=bS(u,a);return this.setSymKey(b,f)},this.setSymKey=async(n,a)=>{this.isInitialized();const f=a||rh(n);return await this.keychain.set(f,n),f},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,a,f)=>{this.isInitialized();const u=E2(f),b=vs(a);if(gg(u))return yS(b,f==null?void 0:f.encoding);if(pg(u)){const R=u.senderPublicKey,O=u.receiverPublicKey;n=await this.generateSharedKey(R,O)}const p=this.getSymKey(n),{type:y,senderPublicKey:A}=u;return mS({type:y,symKey:p,message:b,senderPublicKey:A,encoding:f==null?void 0:f.encoding})},this.decode=async(n,a,f)=>{this.isInitialized();const u=AS(a,f);if(gg(u)){const b=_S(a,f==null?void 0:f.encoding);return ga(b)}if(pg(u)){const b=u.receiverPublicKey,p=u.senderPublicKey;n=await this.generateSharedKey(b,p)}try{const b=this.getSymKey(n),p=wS({symKey:b,encoded:a,encoding:f==null?void 0:f.encoding});return ga(p)}catch(b){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(b)}},this.getPayloadType=(n,a=Bs)=>{const f=vc({encoded:n,encoding:a});return ba(f.type)},this.getPayloadSenderPublicKey=(n,a=Bs)=>{const f=vc({encoded:n,encoding:a});return f.senderPublicKey?Er(f.senderPublicKey,Jr):void 0},this.core=e,this.logger=Yr(t,this.name),this.keychain=i||new CR(this.core,this.logger)}get context(){return di(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(kg)}catch{e=u0(),await this.keychain.set(kg,e)}return NR(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class DR extends IM{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=TP,this.version=DP,this.initialized=!1,this.storagePrefix=kn,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();const a=fs(n);let f=this.messages.get(i);return typeof f>"u"&&(f={}),typeof f[a]<"u"||(f[a]=n,this.messages.set(i,f),await this.persist()),a},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const a=this.get(i),f=fs(n);return typeof a[f]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Yr(e,this.name),this.core=t}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Nb(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Cb(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class FR extends MM{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Hi.EventEmitter,this.name=BP,this.queue=new Map,this.publishTimeout=xe.toMiliseconds(xe.ONE_MINUTE),this.failedPublishTimeout=xe.toMiliseconds(xe.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,a)=>{var f;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:a}});const u=(a==null?void 0:a.ttl)||FP,b=l0(a),p=(a==null?void 0:a.prompt)||!1,y=(a==null?void 0:a.tag)||0,A=(a==null?void 0:a.id)||ha().toString(),R={topic:i,message:n,opts:{ttl:u,relay:b,prompt:p,tag:y,id:A,attestation:a==null?void 0:a.attestation}},O=`Failed to publish payload, please try again. id:${A} tag:${y}`,N=Date.now();let K,W=1;try{for(;K===void 0;){if(Date.now()-N>this.publishTimeout)throw new Error(O);this.logger.trace({id:A,attempts:W},`publisher.publish - attempt ${W}`),K=await await Za(this.rpcPublish(i,n,u,b,p,y,A,a==null?void 0:a.attestation).catch(Q=>this.logger.warn(Q)),this.publishTimeout,O),W++,K||await new Promise(Q=>setTimeout(Q,this.failedPublishTimeout))}this.relayer.events.emit(Gr.publish,R),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:A,topic:i,message:n,opts:a}})}catch(Q){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(Q),(f=a==null?void 0:a.internal)!=null&&f.throwOnFailedPublish)throw Q;this.queue.set(A,R)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=Yr(t,this.name),this.registerEventListeners()}get context(){return di(this.logger)}rpcPublish(e,t,i,n,a,f,u,b){var p,y,A,R;const O={method:nc(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:a,tag:f,attestation:b},id:u};return fi((p=O.params)==null?void 0:p.prompt)&&((y=O.params)==null||delete y.prompt),fi((A=O.params)==null?void 0:A.tag)&&((R=O.params)==null||delete R.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:O}),this.relayer.request(O)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(Ao.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Gr.connection_stalled);return}this.checkQueue()}),this.relayer.on(Gr.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class BR{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const n=i.filter(a=>a!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var qR=Object.defineProperty,LR=Object.defineProperties,UR=Object.getOwnPropertyDescriptors,Qg=Object.getOwnPropertySymbols,$R=Object.prototype.hasOwnProperty,zR=Object.prototype.propertyIsEnumerable,Xg=(r,e,t)=>e in r?qR(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ec=(r,e)=>{for(var t in e||(e={}))$R.call(e,t)&&Xg(r,t,e[t]);if(Qg)for(var t of Qg(e))zR.call(e,t)&&Xg(r,t,e[t]);return r},Ll=(r,e)=>LR(r,UR(e));class jR extends RM{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new BR,this.events=new Hi.EventEmitter,this.name=kP,this.version=HP,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=kn,this.subscribeTimeout=xe.toMiliseconds(xe.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const a=l0(n),f={topic:i,relay:a,transportType:n==null?void 0:n.transportType};this.pending.set(i,f);const u=await this.rpcSubscribe(i,a,n==null?void 0:n.transportType);return typeof u=="string"&&(this.onSubscribe(u,f),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),u}catch(a){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(a),a}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof(n==null?void 0:n.id)<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((a,f)=>{const u=new xe.Watch;u.start(n);const b=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(b),u.stop(n),a(!0)),u.elapsed(n)>=KP&&(clearInterval(b),u.stop(n),f(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=Yr(t,this.name),this.clientId=""}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const n=l0(i);await this.rpcUnsubscribe(e,t,n);const a=Ut("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,a),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i=Kt.relay){i===Kt.relay&&await this.restartToComplete();const n={method:nc(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{const a=fs(e+this.clientId);return i===Kt.link_mode?(setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(f=>this.logger.warn(f))},xe.toMiliseconds(xe.ONE_SECOND)),a):await await Za(this.relayer.request(n).catch(f=>this.logger.warn(f)),this.subscribeTimeout)?a:null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Gr.connection_stalled)}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:nc(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Za(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Gr.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:nc(t.protocol).batchFetchMessages,params:{topics:e.map(a=>a.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Za(this.relayer.request(i).catch(a=>this.logger.warn(a)),this.subscribeTimeout)}catch{this.relayer.events.emit(Gr.connection_stalled)}return n}rpcUnsubscribe(e,t,i){const n={method:nc(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Ll(ec({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,ec({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,ec({},t)),this.topicMap.set(t.topic,e),this.events.emit(Pn.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=Ae("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Pn.deleted,Ll(ec({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Pn.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=Ae("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);jn(t)&&this.onBatchSubscribe(t.map((i,n)=>Ll(ec({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(Ao.pulse,async()=>{await this.checkPending()}),this.events.on(Pn.created,async e=>{const t=Pn.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(Pn.deleted,async e=>{const t=Pn.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}}var kR=Object.defineProperty,Zg=Object.getOwnPropertySymbols,HR=Object.prototype.hasOwnProperty,KR=Object.prototype.propertyIsEnumerable,ev=(r,e,t)=>e in r?kR(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,VR=(r,e)=>{for(var t in e||(e={}))HR.call(e,t)&&ev(r,t,e[t]);if(Zg)for(var t of Zg(e))KR.call(e,t)&&ev(r,t,e[t]);return r};class GR extends PM{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Hi.EventEmitter,this.name=LP,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=xe.toMiliseconds(xe.THIRTY_SECONDS+xe.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");const a=t.id||ha().toString();await this.toEstablishConnection();try{const f=this.provider.request(t);this.requestsInFlight.set(a,{promise:f,request:t}),this.logger.trace({id:a,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const u=await new Promise(async(b,p)=>{const y=()=>{p(new Error(`relayer.request - publish interrupted, id: ${a}`))};this.provider.on(qi.disconnect,y);const A=await f;this.provider.off(qi.disconnect,y),b(A)});return this.logger.trace({id:a,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),u}catch(f){throw this.logger.debug(`Failed to Publish Request: ${a}`),f}finally{this.requestsInFlight.delete(a)}},this.resetPingTimeout=()=>{if(dh())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Gr.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Gr.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(qi.payload,this.onPayloadHandler),this.provider.on(qi.connect,this.onConnectHandler),this.provider.on(qi.disconnect,this.onDisconnectHandler),this.provider.on(qi.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Yr(e.logger,this.name):Nc(Hh({level:e.logger||qP})),this.messages=new DR(this.logger,e.core),this.subscriber=new jR(this,this.logger),this.publisher=new FR(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||j2,this.projectId=e.projectId,this.bundleId=aA(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return di(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:Kt.relay})}async subscribe(e,t){var i;this.isInitialized(),(t==null?void 0:t.transportType)==="relay"&&await this.toEstablishConnection();let n=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"",a;const f=u=>{u.topic===e&&(this.subscriber.off(Pn.created,f),a())};return await Promise.all([new Promise(u=>{a=u,this.subscriber.on(Pn.created,f)}),new Promise(async u=>{n=await this.subscriber.subscribe(e,t)||n,u()})]),n}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await Za(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{const n=()=>{this.provider.off(qi.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(qi.disconnect,n),await Za(this.provider.connect(),xe.toMiliseconds(xe.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(a=>{i(a)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(a=>{this.logger.error(a),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);const i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Ig())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const n=vr(xe.FIVE_MINUTES),a={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,a)}this.events.emit(Gr.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,a;if(dh())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((a=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||a.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(f){this.logger.warn(f)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new gn(new xP(hA({sdkVersion:m0,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Z0(e)){if(!e.method.endsWith(UP))return;const t=e.params,{topic:i,message:n,publishedAt:a,attestation:f}=t.data,u={topic:i,message:n,publishedAt:a,transportType:Kt.relay,attestation:f};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(VR({type:"event",event:t.id},u)),this.events.emit(t.id,u),await this.acknowledgePayload(e),await this.onMessageEvent(u)}else Gh(e)&&this.events.emit(Gr.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Gr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=Kh(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(qi.payload,this.onPayloadHandler),this.provider.off(qi.connect,this.onConnectHandler),this.provider.off(qi.disconnect,this.onDisconnectHandler),this.provider.off(qi.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Ig();gI(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Gr.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},xe.toMiliseconds($P))))}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var WR=Object.defineProperty,tv=Object.getOwnPropertySymbols,JR=Object.prototype.hasOwnProperty,YR=Object.prototype.propertyIsEnumerable,rv=(r,e,t)=>e in r?WR(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,iv=(r,e)=>{for(var t in e||(e={}))JR.call(e,t)&&rv(r,t,e[t]);if(tv)for(var t of tv(e))YR.call(e,t)&&rv(r,t,e[t]);return r};class xa extends OM{constructor(e,t,i,n=kn,a=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=zP,this.cached=[],this.initialized=!1,this.storagePrefix=kn,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(f=>{this.getKey&&f!==null&&!fi(f)?this.map.set(this.getKey(f),f):VS(f)?this.map.set(f.id,f):GS(f)&&this.map.set(f.topic,f)}),this.cached=[],this.initialized=!0)},this.set=async(f,u)=>{this.isInitialized(),this.map.has(f)?await this.update(f,u):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:f,value:u}),this.map.set(f,u),await this.persist())},this.get=f=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:f}),this.getData(f)),this.getAll=f=>(this.isInitialized(),f?this.values.filter(u=>Object.keys(f).every(b=>IP(u[b],f[b]))):this.values),this.update=async(f,u)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:f,update:u});const b=iv(iv({},this.getData(f)),u);this.map.set(f,b),await this.persist()},this.delete=async(f,u)=>{this.isInitialized(),this.map.has(f)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:f,reason:u}),this.map.delete(f),this.addToRecentlyDeleted(f),await this.persist())},this.logger=Yr(t,this.name),this.storagePrefix=n,this.getKey=a}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:n}=Ae("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=Ae("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=Ae("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class QR{constructor(e,t){this.core=e,this.logger=t,this.name=VP,this.version=GP,this.events=new I0,this.initialized=!1,this.storagePrefix=kn,this.ignoredPayloadTypes=[ds],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=u0(),a=await this.core.crypto.setSymKey(n),f=vr(xe.FIVE_MINUTES),u={protocol:z2},b={topic:a,expiry:f,relay:u,active:!1,methods:i==null?void 0:i.methods},p=wg({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:n,relay:u,expiryTimestamp:f,methods:i==null?void 0:i.methods});return this.events.emit(ca.create,b),this.core.expirer.set(a,f),await this.pairings.set(a,b),await this.core.relayer.subscribe(a,{transportType:i==null?void 0:i.transportType}),{topic:a,uri:p}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i==null?void 0:i.uri,trace:[xn.pairing_started]}});this.isValidPair(i,n);const{topic:a,symKey:f,relay:u,expiryTimestamp:b,methods:p}=yg(i.uri);n.props.properties.topic=a,n.addTrace(xn.pairing_uri_validation_success),n.addTrace(xn.pairing_uri_not_expired);let y;if(this.pairings.keys.includes(a)){if(y=this.pairings.get(a),n.addTrace(xn.existing_pairing),y.active)throw n.setError(os.active_pairing_already_exists),new Error(`Pairing already exists: ${a}. Please try again with a new connection URI.`);n.addTrace(xn.pairing_not_expired)}const A=b||vr(xe.FIVE_MINUTES),R={topic:a,relay:u,expiry:A,active:!1,methods:p};this.core.expirer.set(a,A),await this.pairings.set(a,R),n.addTrace(xn.store_new_pairing),i.activatePairing&&await this.activate({topic:a}),this.events.emit(ca.create,R),n.addTrace(xn.emit_inactive_pairing),this.core.crypto.keychain.has(a)||await this.core.crypto.setSymKey(f,a),n.addTrace(xn.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(os.no_internet_connection)}try{await this.core.relayer.subscribe(a,{relay:u})}catch(O){throw n.setError(os.subscribe_pairing_topic_failure),O}return n.addTrace(xn.subscribe_pairing_topic_success),R},this.activate=async({topic:i})=>{this.isInitialized();const n=vr(xe.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.pairings.keys.includes(n)){const a=await this.sendRequest(n,"wc_pairingPing",{}),{done:f,resolve:u,reject:b}=oa();this.events.once(St("pairing_ping",a),({error:p})=>{p?b(p):u()}),await f()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",Ut("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:a,expiry:f,methods:u}=i,b=this.core.crypto.keychain.get(n);return wg({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:b,relay:a,expiryTimestamp:f,methods:u})},this.sendRequest=async(i,n,a)=>{const f=qs(n,a),u=await this.core.crypto.encode(i,f),b=Xo[n].req;return this.core.history.set(i,f),this.core.relayer.publish(i,u,b),f.id},this.sendResult=async(i,n,a)=>{const f=Kh(i,a),u=await this.core.crypto.encode(n,f),b=await this.core.history.get(n,i),p=Xo[b.request.method].res;await this.core.relayer.publish(n,u,p),await this.core.history.resolve(f)},this.sendError=async(i,n,a)=>{const f=Vh(i,a),u=await this.core.crypto.encode(n,f),b=await this.core.history.get(n,i),p=Xo[b.request.method]?Xo[b.request.method].res:Xo.unregistered_method.res;await this.core.relayer.publish(n,u,p),await this.core.history.resolve(f)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Ut("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>Rs(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:a}=i;switch(a.method){case"wc_pairingPing":return this.onPairingPingRequest(n,a);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,a);default:return this.onUnknownRpcMethodRequest(n,a)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:a}=i,f=(await this.core.history.get(n,a.id)).request.method;switch(f){case"wc_pairingPing":return this.onPairingPingResponse(n,a);default:return this.onUnknownRpcMethodResponse(f)}},this.onPairingPingRequest=async(i,n)=>{const{id:a}=n;try{this.isValidPing({topic:i}),await this.sendResult(a,i,!0),this.events.emit(ca.ping,{id:a,topic:i})}catch(f){await this.sendError(a,i,f),this.logger.error(f)}},this.onPairingPingResponse=(i,n)=>{const{id:a}=n;setTimeout(()=>{Mn(n)?this.events.emit(St("pairing_ping",a),{}):$i(n)&&this.events.emit(St("pairing_ping",a),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:a}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(ca.delete,{id:a,topic:i})}catch(f){await this.sendError(a,i,f),this.logger.error(f)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:a,method:f}=n;try{if(this.registeredMethods.includes(f))return;const u=Ut("WC_METHOD_UNSUPPORTED",f);await this.sendError(a,i,u),this.logger.error(u)}catch(u){await this.sendError(a,i,u),this.logger.error(u)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Ut("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var a;if(!oi(i)){const{message:u}=Ae("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(os.malformed_pairing_uri),new Error(u)}if(!KS(i.uri)){const{message:u}=Ae("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(os.malformed_pairing_uri),new Error(u)}const f=yg(i==null?void 0:i.uri);if(!((a=f==null?void 0:f.relay)!=null&&a.protocol)){const{message:u}=Ae("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(os.malformed_pairing_uri),new Error(u)}if(!(f!=null&&f.symKey)){const{message:u}=Ae("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(os.malformed_pairing_uri),new Error(u)}if(f!=null&&f.expiryTimestamp&&xe.toMiliseconds(f==null?void 0:f.expiryTimestamp){if(!oi(i)){const{message:a}=Ae("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(a)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!oi(i)){const{message:a}=Ae("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(a)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!fr(i,!1)){const{message:n}=Ae("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=Ae("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Rs(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=Ae("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=Yr(t,this.name),this.pairings=new xa(this.core,this.logger,this.name,this.storagePrefix)}get context(){return di(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Gr.message,async e=>{const{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===Kt.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const a=await this.core.crypto.decode(t,i);try{Z0(a)?(this.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a})):Gh(a)&&(await this.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a}),this.core.history.delete(t,a.id))}catch(f){this.logger.error(f)}})}registerExpirerEvents(){this.core.expirer.on(Li.expired,async e=>{const{topic:t}=Db(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(ca.expire,{topic:t}))})}}class XR extends SM{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Hi.EventEmitter,this.name=WP,this.version=JP,this.cached=[],this.initialized=!1,this.storagePrefix=kn,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,a)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:a}),this.records.has(n.id))return;const f={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:a,expiry:vr(xe.THIRTY_DAYS)};this.records.set(f.id,f),this.persist(),this.events.emit(on.created,f)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=$i(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(on.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(a=>{if(a.topic===i){if(typeof n<"u"&&a.id!==n)return;this.records.delete(a.id),this.events.emit(on.deleted,a)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Yr(t,this.name)}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:qs(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=Ae("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(on.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=Ae("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(on.created,e=>{const t=on.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(on.updated,e=>{const t=on.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(on.deleted,e=>{const t=on.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(Ao.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{xe.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(on.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class ZR extends NM{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Hi.EventEmitter,this.name=YP,this.version=QP,this.cached=[],this.initialized=!1,this.storagePrefix=kn,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();const a=this.formatTarget(i),f={target:a,expiry:n};this.expirations.set(a,f),this.checkExpiry(a,f),this.events.emit(Li.created,{target:a,expiration:f})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),a=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Li.deleted,{target:n,expiration:a})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Yr(t,this.name)}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return uA(e);if(typeof e=="number")return lA(e);const{message:t}=Ae("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Li.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=Ae("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=Ae("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;xe.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Li.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(Ao.pulse,()=>this.checkExpirations()),this.events.on(Li.created,e=>{const t=Li.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Li.expired,e=>{const t=Li.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Li.deleted,e=>{const t=Li.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.getLocalStorage=Qt.getLocalStorageOrThrow=Qt.getCrypto=Qt.getCryptoOrThrow=Qt.getLocation=Qt.getLocationOrThrow=Qt.getNavigator=Qt.getNavigatorOrThrow=em=Qt.getDocument=Qt.getDocumentOrThrow=Qt.getFromWindowOrThrow=Qt.getFromWindow=void 0;function Sa(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Qt.getFromWindow=Sa;function Eo(r){const e=Sa(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Qt.getFromWindowOrThrow=Eo;function eN(){return Eo("document")}Qt.getDocumentOrThrow=eN;function tN(){return Sa("document")}var em=Qt.getDocument=tN;function rN(){return Eo("navigator")}Qt.getNavigatorOrThrow=rN;function iN(){return Sa("navigator")}Qt.getNavigator=iN;function nN(){return Eo("location")}Qt.getLocationOrThrow=nN;function sN(){return Sa("location")}Qt.getLocation=sN;function aN(){return Eo("crypto")}Qt.getCryptoOrThrow=aN;function oN(){return Sa("crypto")}Qt.getCrypto=oN;function cN(){return Eo("localStorage")}Qt.getLocalStorageOrThrow=cN;function fN(){return Sa("localStorage")}Qt.getLocalStorage=fN;class hN extends CM{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=XP,this.verifyUrlV3=eO,this.storagePrefix=kn,this.version=$2,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&xe.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt){if(!Sc()||this.isDevEnv)return;const a=window.location.origin,{id:f,decryptedId:u}=n,b=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${a}&id=${f}&decryptedId=${u}`;try{const p=em(),y=this.startAbortTimer(xe.ONE_SECOND*5),A=await new Promise((R,O)=>{const N=()=>{window.removeEventListener("message",W),p.body.removeChild(K),O("attestation aborted")};this.abortController.signal.addEventListener("abort",N);const K=p.createElement("iframe");K.src=b,K.style.display="none",K.addEventListener("error",N,{signal:this.abortController.signal});const W=Q=>{if(Q.data&&typeof Q.data=="string")try{const j=JSON.parse(Q.data);if(j.type==="verify_attestation"){if(n0(j.attestation).payload.id!==f)return;clearInterval(y),p.body.removeChild(K),this.abortController.signal.removeEventListener("abort",N),window.removeEventListener("message",W),R(j.attestation===null?"":j.attestation)}}catch(j){this.logger.warn(j)}};p.body.appendChild(K),window.addEventListener("message",W,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",A),A}catch(p){this.logger.warn(p)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:a,hash:f,encryptedId:u}=n;if(a===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(a){if(n0(a).payload.id!==u)return;const p=await this.isValidJwtAttestation(a);if(p){if(!p.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return p}}if(!f)return;const b=this.getVerifyUrl(n==null?void 0:n.verifyUrl);return this.fetchAttestation(f,b)},this.fetchAttestation=async(n,a)=>{this.logger.debug(`resolving attestation: ${n} from url: ${a}`);const f=this.startAbortTimer(xe.ONE_SECOND*5),u=await fetch(`${a}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(f),u.status===200?await u.json():void 0},this.getVerifyUrl=n=>{let a=n||uc;return tO.includes(a)||(this.logger.info(`verify url: ${a}, not included in trusted list, assigning default: ${uc}`),a=uc),a},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(xe.FIVE_SECONDS),a=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await a.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{const a=await this.getPublicKey();try{if(a)return this.validateAttestation(n,a)}catch(u){this.logger.error(u),this.logger.warn("error validating attestation")}const f=await this.fetchAndPersistPublicKey();try{if(f)return this.validateAttestation(n,f)}catch(u){this.logger.error(u),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async a=>{const f=await this.fetchPublicKey();f&&(await this.persistPublicKey(f),a(f))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,a)=>{const f=IS(n,a.publicKey),u={hasExpired:xe.toMiliseconds(f.exp)this.abortController.abort(),xe.toMiliseconds(e))}}class uN extends TM{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=rO,this.registerDeviceToken=async i=>{const{clientId:n,token:a,notificationType:f,enableEncrypted:u=!1}=i,b=`${iO}/${this.projectId}/clients`;await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:f,token:a,always_raw:u})})},this.logger=Yr(t,this.context)}}var lN=Object.defineProperty,nv=Object.getOwnPropertySymbols,dN=Object.prototype.hasOwnProperty,pN=Object.prototype.propertyIsEnumerable,sv=(r,e,t)=>e in r?lN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tc=(r,e)=>{for(var t in e||(e={}))dN.call(e,t)&&sv(r,t,e[t]);if(nv)for(var t of nv(e))pN.call(e,t)&&sv(r,t,e[t]);return r};class gN extends DM{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=sO,this.storagePrefix=kn,this.storageVersion=nO,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!z0())try{const n={eventId:L1(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Rb(this.core.relayer.protocol,this.core.relayer.version,m0)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:a="ERROR",type:f="",properties:{topic:u,trace:b}}=n,p=L1(),y=this.core.projectId||"",A=Date.now(),R=tc({eventId:p,timestamp:A,props:{event:a,type:f,properties:{topic:u,trace:b}},bundleId:y,domain:this.getAppDomain()},this.setMethods(p));return this.telemetryEnabled&&(this.events.set(p,R),this.shouldPersist=!0),R},this.getEvent=n=>{const{eventId:a,topic:f}=n;if(a)return this.events.get(a);const u=Array.from(this.events.values()).find(b=>b.props.properties.topic===f);if(u)return tc(tc({},u),this.setMethods(u.eventId))},this.deleteEvent=n=>{const{eventId:a}=n;this.events.delete(a),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(Ao.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{xe.fromMiliseconds(Date.now())-xe.fromMiliseconds(n.timestamp)>aO&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:a=>this.addTrace(n,a),setError:a=>this.setError(n,a)}),this.addTrace=(n,a)=>{const f=this.events.get(n);f&&(f.props.properties.trace.push(a),this.events.set(n,f),this.shouldPersist=!0)},this.setError=(n,a)=>{const f=this.events.get(n);f&&(f.props.type=a,f.timestamp=Date.now(),this.events.set(n,f),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(a=>{this.events.set(a.eventId,tc(tc({},a),this.setMethods(a.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[a,f]of this.events)f.props.type&&n.push(f);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const a of n)this.events.delete(a.eventId),this.shouldPersist=!0}catch(a){this.logger.warn(a)}},this.sendEvent=async n=>{const a=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${oO}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${m0}${a}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Ob().url,this.logger=Yr(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var vN=Object.defineProperty,av=Object.getOwnPropertySymbols,bN=Object.prototype.hasOwnProperty,mN=Object.prototype.propertyIsEnumerable,ov=(r,e,t)=>e in r?vN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,cv=(r,e)=>{for(var t in e||(e={}))bN.call(e,t)&&ov(r,t,e[t]);if(av)for(var t of av(e))mN.call(e,t)&&ov(r,t,e[t]);return r};class td extends xM{constructor(e){var t;super(e),this.protocol=U2,this.version=$2,this.name=ed,this.events=new Hi.EventEmitter,this.initialized=!1,this.on=(f,u)=>this.events.on(f,u),this.once=(f,u)=>this.events.once(f,u),this.off=(f,u)=>this.events.off(f,u),this.removeListener=(f,u)=>this.events.removeListener(f,u),this.dispatchEnvelope=({topic:f,message:u,sessionExists:b})=>{if(!f||!u)return;const p={topic:f,message:u,publishedAt:Date.now(),transportType:Kt.link_mode};this.relayer.onLinkMessageEvent(p,{sessionExists:b})},this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||j2,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Hh({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:MP.logger}),{logger:n,chunkLoggerController:a}=EM({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=a,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var f,u;(f=this.logChunkController)!=null&&f.downloadLogsBlobInBrowser&&((u=this.logChunkController)==null||u.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Yr(n,this.name),this.heartbeat=new yI,this.crypto=new TR(this,this.logger,e==null?void 0:e.keychain),this.history=new XR(this,this.logger),this.expirer=new ZR(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new JI(cv(cv({},PP),e==null?void 0:e.storageOptions)),this.relayer=new GR({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new QR(this,this.logger),this.verify=new hN(this,this.logger,this.storage),this.echoClient=new uN(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new gN(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const t=new td(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(jP,i),t}get context(){return di(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Hg,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(Hg)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const yN=td,tm="wc",rm=2,im="client",rd=`${tm}@${rm}:${im}:`,Ul={name:im,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},fv="WALLETCONNECT_DEEPLINK_CHOICE",wN="proposal",nm="Proposal expired",_N="session",Ga=xe.SEVEN_DAYS,AN="engine",wr={wc_sessionPropose:{req:{ttl:xe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:xe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:xe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:xe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:xe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1119}}},$l={min:xe.FIVE_MINUTES,max:xe.SEVEN_DAYS},En={idle:"IDLE",active:"ACTIVE"},EN="request",xN=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],SN="wc",IN="auth",MN="authKeys",PN="pairingTopics",ON="requests",Jh=`${SN}@${1.5}:${IN}:`,sh=`${Jh}:PUB_KEY`;var RN=Object.defineProperty,NN=Object.defineProperties,CN=Object.getOwnPropertyDescriptors,hv=Object.getOwnPropertySymbols,TN=Object.prototype.hasOwnProperty,DN=Object.prototype.propertyIsEnumerable,uv=(r,e,t)=>e in r?RN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rr=(r,e)=>{for(var t in e||(e={}))TN.call(e,t)&&uv(r,t,e[t]);if(hv)for(var t of hv(e))DN.call(e,t)&&uv(r,t,e[t]);return r},fn=(r,e)=>NN(r,CN(e));class FN extends BM{constructor(e){super(e),this.name=AN,this.events=new I0,this.initialized=!1,this.requestQueue={state:En.idle,queue:[]},this.sessionRequestQueue={state:En.idle,queue:[]},this.requestQueueDelay=xe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(wr)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},xe.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=fn(rr({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:a,optionalNamespaces:f,sessionProperties:u,relays:b}=i;let p=n,y,A=!1;try{p&&(A=this.client.core.pairing.pairings.get(p).active)}catch(U){throw this.client.logger.error(`connect() -> pairing.get(${p}) failed`),U}if(!p||!A){const{topic:U,uri:k}=await this.client.core.pairing.create();p=U,y=k}if(!p){const{message:U}=Ae("NO_MATCHING_KEY",`connect() pairing topic: ${p}`);throw new Error(U)}const R=await this.client.core.crypto.generateKeyPair(),O=wr.wc_sessionPropose.req.ttl||xe.FIVE_MINUTES,N=vr(O),K=rr({requiredNamespaces:a,optionalNamespaces:f,relays:b??[{protocol:z2}],proposer:{publicKey:R,metadata:this.client.metadata},expiryTimestamp:N,pairingTopic:p},u&&{sessionProperties:u}),{reject:W,resolve:Q,done:j}=oa(O,nm);this.events.once(St("session_connect"),async({error:U,session:k})=>{if(U)W(U);else if(k){k.self.publicKey=R;const G=fn(rr({},k),{pairingTopic:K.pairingTopic,requiredNamespaces:K.requiredNamespaces,optionalNamespaces:K.optionalNamespaces,transportType:Kt.relay});await this.client.session.set(k.topic,G),await this.setExpiry(k.topic,k.expiry),p&&await this.client.core.pairing.updateMetadata({topic:p,metadata:k.peer.metadata}),this.cleanupDuplicatePairings(G),Q(G)}});const Y=await this.sendRequest({topic:p,method:"wc_sessionPropose",params:K,throwOnFailedPublish:!0});return await this.setProposal(Y,rr({id:Y},K)),{uri:y,approval:j}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,a;const f=this.client.core.eventClient.createEvent({properties:{topic:(i=t==null?void 0:t.id)==null?void 0:i.toString(),trace:[cn.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(B){throw f.setError(sa.no_internet_connection),B}try{await this.isValidProposalId(t==null?void 0:t.id)}catch(B){throw this.client.logger.error(`approve() -> proposal.get(${t==null?void 0:t.id}) failed`),f.setError(sa.proposal_not_found),B}try{await this.isValidApprove(t)}catch(B){throw this.client.logger.error("approve() -> isValidApprove() failed"),f.setError(sa.session_approve_namespace_validation_failure),B}const{id:u,relayProtocol:b,namespaces:p,sessionProperties:y,sessionConfig:A}=t,R=this.client.proposal.get(u);this.client.core.eventClient.deleteEvent({eventId:f.eventId});const{pairingTopic:O,proposer:N,requiredNamespaces:K,optionalNamespaces:W}=R;let Q=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:O});Q||(Q=(a=this.client.core.eventClient)==null?void 0:a.createEvent({type:cn.session_approve_started,properties:{topic:O,trace:[cn.session_approve_started,cn.session_namespaces_validation_success]}}));const j=await this.client.core.crypto.generateKeyPair(),Y=N.publicKey,U=await this.client.core.crypto.generateSharedKey(j,Y),k=rr(rr({relay:{protocol:b??"irn"},namespaces:p,controller:{publicKey:j,metadata:this.client.metadata},expiry:vr(Ga)},y&&{sessionProperties:y}),A&&{sessionConfig:A}),G=Kt.relay;Q.addTrace(cn.subscribing_session_topic);try{await this.client.core.relayer.subscribe(U,{transportType:G})}catch(B){throw Q.setError(sa.subscribe_session_topic_failure),B}Q.addTrace(cn.subscribe_session_topic_success);const x=fn(rr({},k),{topic:U,requiredNamespaces:K,optionalNamespaces:W,pairingTopic:O,acknowledged:!1,self:k.controller,peer:{publicKey:N.publicKey,metadata:N.metadata},controller:j,transportType:Kt.relay});await this.client.session.set(U,x),Q.addTrace(cn.store_session);try{Q.addTrace(cn.publishing_session_settle),await this.sendRequest({topic:U,method:"wc_sessionSettle",params:k,throwOnFailedPublish:!0}).catch(B=>{throw Q==null||Q.setError(sa.session_settle_publish_failure),B}),Q.addTrace(cn.session_settle_publish_success),Q.addTrace(cn.publishing_session_approve),await this.sendResult({id:u,topic:O,result:{relay:{protocol:b??"irn"},responderPublicKey:j},throwOnFailedPublish:!0}).catch(B=>{throw Q==null||Q.setError(sa.session_approve_publish_failure),B}),Q.addTrace(cn.session_approve_publish_success)}catch(B){throw this.client.logger.error(B),this.client.session.delete(U,Ut("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(U),B}return this.client.core.eventClient.deleteEvent({eventId:Q.eventId}),await this.client.core.pairing.updateMetadata({topic:O,metadata:N.metadata}),await this.client.proposal.delete(u,Ut("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:O}),await this.setExpiry(U,vr(Ga)),{topic:U,acknowledged:()=>Promise.resolve(this.client.session.get(U))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(f){throw this.client.logger.error("reject() -> isValidReject() failed"),f}const{id:i,reason:n}=t;let a;try{a=this.client.proposal.get(i).pairingTopic}catch(f){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),f}a&&(await this.sendError({id:i,topic:a,error:n,rpcOpts:wr.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Ut("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(A){throw this.client.logger.error("update() -> isValidUpdate() failed"),A}const{topic:i,namespaces:n}=t,{done:a,resolve:f,reject:u}=oa(),b=Cs(),p=ha().toString(),y=this.client.session.get(i).namespaces;return this.events.once(St("session_update",b),({error:A})=>{A?u(A):f()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:b,relayRpcId:p}).catch(A=>{this.client.logger.error(A),this.client.session.update(i,{namespaces:y}),u(A)}),{acknowledged:a}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(b){throw this.client.logger.error("extend() -> isValidExtend() failed"),b}const{topic:i}=t,n=Cs(),{done:a,resolve:f,reject:u}=oa();return this.events.once(St("session_extend",n),({error:b})=>{b?u(b):f()}),await this.setExpiry(i,vr(Ga)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(b=>{u(b)}),{acknowledged:a}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(N){throw this.client.logger.error("request() -> isValidRequest() failed"),N}const{chainId:i,request:n,topic:a,expiry:f=wr.wc_sessionRequest.req.ttl}=t,u=this.client.session.get(a);(u==null?void 0:u.transportType)===Kt.relay&&await this.confirmOnlineStateOrThrow();const b=Cs(),p=ha().toString(),{done:y,resolve:A,reject:R}=oa(f,"Request expired. Please try again.");this.events.once(St("session_request",b),({error:N,result:K})=>{N?R(N):A(K)});const O=this.getAppLinkIfEnabled(u.peer.metadata,u.transportType);return O?(await this.sendRequest({clientRpcId:b,relayRpcId:p,topic:a,method:"wc_sessionRequest",params:{request:fn(rr({},n),{expiryTimestamp:vr(f)}),chainId:i},expiry:f,throwOnFailedPublish:!0,appLink:O}).catch(N=>R(N)),this.client.events.emit("session_request_sent",{topic:a,request:n,chainId:i,id:b}),await y()):await Promise.all([new Promise(async N=>{await this.sendRequest({clientRpcId:b,relayRpcId:p,topic:a,method:"wc_sessionRequest",params:{request:fn(rr({},n),{expiryTimestamp:vr(f)}),chainId:i},expiry:f,throwOnFailedPublish:!0}).catch(K=>R(K)),this.client.events.emit("session_request_sent",{topic:a,request:n,chainId:i,id:b}),N()}),new Promise(async N=>{var K;if(!((K=u.sessionConfig)!=null&&K.disableDeepLink)){const W=await gA(this.client.core.storage,fv);await dA({id:b,topic:a,wcDeepLink:W})}N()}),y()]).then(N=>N[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:n}=t,{id:a}=n,f=this.client.session.get(i);f.transportType===Kt.relay&&await this.confirmOnlineStateOrThrow();const u=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);Mn(n)?await this.sendResult({id:a,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:u}):$i(n)&&await this.sendError({id:a,topic:i,error:n.error,appLink:u}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=t;if(this.client.session.keys.includes(i)){const n=Cs(),a=ha().toString(),{done:f,resolve:u,reject:b}=oa();this.events.once(St("session_ping",n),({error:p})=>{p?b(p):u()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:a}),f()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:n,chainId:a}=t,f=ha().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:a},throwOnFailedPublish:!0,relayRpcId:f})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Ut("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=Ae("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>kS(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);const a=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),f=a?Kt.link_mode:Kt.relay;f===Kt.relay&&await this.confirmOnlineStateOrThrow();const{chains:u,statement:b="",uri:p,domain:y,nonce:A,type:R,exp:O,nbf:N,methods:K=[],expiry:W}=t,Q=[...t.resources||[]],{topic:j,uri:Y}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:f});this.client.logger.info({message:"Generated new pairing",pairing:{topic:j,uri:Y}});const U=await this.client.core.crypto.generateKeyPair(),k=rh(U);if(await Promise.all([this.client.auth.authKeys.set(sh,{responseTopic:k,publicKey:U}),this.client.auth.pairingTopics.set(k,{topic:k,pairingTopic:j})]),await this.client.core.relayer.subscribe(k,{transportType:f}),this.client.logger.info(`sending request to new pairing topic: ${j}`),K.length>0){const{namespace:M}=ac(u[0]);let S=hS(M,"request",K);th(Q)&&(S=lS(S,Q.pop())),Q.push(S)}const G=W&&W>wr.wc_sessionAuthenticate.req.ttl?W:wr.wc_sessionAuthenticate.req.ttl,x={authPayload:{type:R??"caip122",chains:u,statement:b,aud:p,domain:y,version:"1",nonce:A,iat:new Date().toISOString(),exp:O,nbf:N,resources:Q},requester:{publicKey:U,metadata:this.client.metadata},expiryTimestamp:vr(G)},B={eip155:{chains:u,methods:[...new Set(["personal_sign",...K])],events:["chainChanged","accountsChanged"]}},ae={requiredNamespaces:{},optionalNamespaces:B,relays:[{protocol:"irn"}],pairingTopic:j,proposer:{publicKey:U,metadata:this.client.metadata},expiryTimestamp:vr(wr.wc_sessionPropose.req.ttl)},{done:le,resolve:F,reject:m}=oa(G,"Request expired"),c=async({error:M,session:S})=>{if(this.events.off(St("session_request",v),h),M)m(M);else if(S){S.self.publicKey=U,await this.client.session.set(S.topic,S),await this.setExpiry(S.topic,S.expiry),j&&await this.client.core.pairing.updateMetadata({topic:j,metadata:S.peer.metadata});const d=this.client.session.get(S.topic);await this.deleteProposal(_),F({session:d})}},h=async M=>{var S,d,g;if(await this.deletePendingAuthRequest(v,{message:"fulfilled",code:0}),M.error){const z=Ut("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return M.error.code===z.code?void 0:(this.events.off(St("session_connect"),c),m(M.error.message))}await this.deleteProposal(_),this.events.off(St("session_connect"),c);const{cacaos:T,responder:Z}=M.result,se=[],P=[];for(const z of T){await hg({cacao:z,projectId:this.client.core.projectId})||(this.client.logger.error(z,"Signature verification failed"),m(Ut("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:H}=z,w=th(H.resources),$=[fg(H.iss)],ne=mh(H.iss);if(w){const ce=ug(w),he=lg(w);se.push(...ce),$.push(...he)}for(const ce of $)P.push(`${ce}:${ne}`)}const ee=await this.client.core.crypto.generateSharedKey(U,Z.publicKey);let q;se.length>0&&(q={topic:ee,acknowledged:!0,self:{publicKey:U,metadata:this.client.metadata},peer:Z,controller:Z.publicKey,expiry:vr(Ga),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:j,namespaces:_g([...new Set(se)],[...new Set(P)]),transportType:f},await this.client.core.relayer.subscribe(ee,{transportType:f}),await this.client.session.set(ee,q),j&&await this.client.core.pairing.updateMetadata({topic:j,metadata:Z.metadata}),q=this.client.session.get(ee)),(S=this.client.metadata.redirect)!=null&&S.linkMode&&(d=Z.metadata.redirect)!=null&&d.linkMode&&(g=Z.metadata.redirect)!=null&&g.universal&&i&&(this.client.core.addLinkModeSupportedApp(Z.metadata.redirect.universal),this.client.session.update(ee,{transportType:Kt.link_mode})),F({auths:T,session:q})},v=Cs(),_=Cs();this.events.once(St("session_connect"),c),this.events.once(St("session_request",v),h);let I;try{if(a){const M=qs("wc_sessionAuthenticate",x,v);this.client.core.history.set(j,M);const S=await this.client.core.crypto.encode("",M,{type:Oc,encoding:Yo});I=kf(i,j,S)}else await Promise.all([this.sendRequest({topic:j,method:"wc_sessionAuthenticate",params:x,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:v}),this.sendRequest({topic:j,method:"wc_sessionPropose",params:ae,expiry:wr.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:_})])}catch(M){throw this.events.off(St("session_connect"),c),this.events.off(St("session_request",v),h),M}return await this.setProposal(_,rr({id:_},ae)),await this.setAuthRequest(v,{request:fn(rr({},x),{verifyContext:{}}),pairingTopic:j,transportType:f}),{uri:I??Y,response:le}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:n}=t,a=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[aa.authenticated_session_approve_started]}});try{this.isInitialized()}catch(W){throw a.setError(Zo.no_internet_connection),W}const f=this.getPendingAuthRequest(i);if(!f)throw a.setError(Zo.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const u=f.transportType||Kt.relay;u===Kt.relay&&await this.confirmOnlineStateOrThrow();const b=f.requester.publicKey,p=await this.client.core.crypto.generateKeyPair(),y=rh(b),A={type:ds,receiverPublicKey:b,senderPublicKey:p},R=[],O=[];for(const W of n){if(!await hg({cacao:W,projectId:this.client.core.projectId})){a.setError(Zo.invalid_cacao);const k=Ut("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:y,error:k,encodeOpts:A}),new Error(k.message)}a.addTrace(aa.cacaos_verified);const{p:Q}=W,j=th(Q.resources),Y=[fg(Q.iss)],U=mh(Q.iss);if(j){const k=ug(j),G=lg(j);R.push(...k),Y.push(...G)}for(const k of Y)O.push(`${k}:${U}`)}const N=await this.client.core.crypto.generateSharedKey(p,b);a.addTrace(aa.create_authenticated_session_topic);let K;if((R==null?void 0:R.length)>0){K={topic:N,acknowledged:!0,self:{publicKey:p,metadata:this.client.metadata},peer:{publicKey:b,metadata:f.requester.metadata},controller:b,expiry:vr(Ga),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:f.pairingTopic,namespaces:_g([...new Set(R)],[...new Set(O)]),transportType:u},a.addTrace(aa.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(N,{transportType:u})}catch(W){throw a.setError(Zo.subscribe_authenticated_session_topic_failure),W}a.addTrace(aa.subscribe_authenticated_session_topic_success),await this.client.session.set(N,K),a.addTrace(aa.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:f.requester.metadata})}a.addTrace(aa.publishing_authenticated_session_approve);try{await this.sendResult({topic:y,id:i,result:{cacaos:n,responder:{publicKey:p,metadata:this.client.metadata}},encodeOpts:A,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(f.requester.metadata,u)})}catch(W){throw a.setError(Zo.authenticated_session_approve_publish_failure),W}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:f.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:a.eventId}),{session:K}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:i,reason:n}=t,a=this.getPendingAuthRequest(i);if(!a)throw new Error(`Could not find pending auth request with id ${i}`);a.transportType===Kt.relay&&await this.confirmOnlineStateOrThrow();const f=a.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),b=rh(f),p={type:ds,receiverPublicKey:f,senderPublicKey:u};await this.sendError({id:i,topic:b,error:n,encodeOpts:p,rpcOpts:wr.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(a.requester.metadata,a.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Ut("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:n}=t;return b2(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(a=>{var f,u;return((f=a.peerMetadata)==null?void 0:f.url)&&((u=a.peerMetadata)==null?void 0:u.url)===t.peer.metadata.url&&a.topic&&a.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(a=>this.client.core.pairing.disconnect({topic:a.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;const{topic:n,expirerHasDeleted:a=!1,emitEvent:f=!0,id:u=0}=t,{self:b}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Ut("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(b.publicKey)&&await this.client.core.crypto.deleteKeyPair(b.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),a||this.client.core.expirer.del(n),this.client.core.storage.removeItem(fv).catch(p=>this.client.logger.warn(p)),this.getPendingSessionRequests().forEach(p=>{p.topic===n&&this.deletePendingSessionRequest(p.id,Ut("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=En.idle),f&&this.client.events.emit("session_delete",{id:u,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{const n=this.client.proposal.get(t),a=this.client.core.eventClient.getEvent({topic:n.pairingTopic});a==null||a.setError(sa.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Ut("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(a=>a.id!==t),n&&(this.sessionRequestQueue.state=En.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,vr(wr.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:n,pairingTopic:a,transportType:f=Kt.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:a,verifyContext:n.verifyContext,transportType:f})},this.setPendingSessionRequest=async t=>{const{id:i,topic:n,params:a,verifyContext:f}=t,u=a.request.expiryTimestamp||vr(wr.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,u),await this.client.pendingRequest.set(i,{id:i,topic:n,params:a,verifyContext:f})},this.sendRequest=async t=>{const{topic:i,method:n,params:a,expiry:f,relayRpcId:u,clientRpcId:b,throwOnFailedPublish:p,appLink:y}=t,A=qs(n,a,b);let R;const O=!!y;try{const W=O?Yo:Bs;R=await this.client.core.crypto.encode(i,A,{encoding:W})}catch(W){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),W}let N;if(xN.includes(n)){const W=fs(JSON.stringify(A)),Q=fs(R);N=await this.client.core.verify.register({id:Q,decryptedId:W})}const K=wr[n].req;if(K.attestation=N,f&&(K.ttl=f),u&&(K.id=u),this.client.core.history.set(i,A),O){const W=kf(y,i,R);await global.Linking.openURL(W,this.client.name)}else{const W=wr[n].req;f&&(W.ttl=f),u&&(W.id=u),p?(W.internal=fn(rr({},W.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,R,W)):this.client.core.relayer.publish(i,R,W).catch(Q=>this.client.logger.error(Q))}return A.id},this.sendResult=async t=>{const{id:i,topic:n,result:a,throwOnFailedPublish:f,encodeOpts:u,appLink:b}=t,p=Kh(i,a);let y;const A=b&&typeof(global==null?void 0:global.Linking)<"u";try{const O=A?Yo:Bs;y=await this.client.core.crypto.encode(n,p,fn(rr({},u||{}),{encoding:O}))}catch(O){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),O}let R;try{R=await this.client.core.history.get(n,i)}catch(O){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),O}if(A){const O=kf(b,n,y);await global.Linking.openURL(O,this.client.name)}else{const O=wr[R.request.method].res;f?(O.internal=fn(rr({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,y,O)):this.client.core.relayer.publish(n,y,O).catch(N=>this.client.logger.error(N))}await this.client.core.history.resolve(p)},this.sendError=async t=>{const{id:i,topic:n,error:a,encodeOpts:f,rpcOpts:u,appLink:b}=t,p=Vh(i,a);let y;const A=b&&typeof(global==null?void 0:global.Linking)<"u";try{const O=A?Yo:Bs;y=await this.client.core.crypto.encode(n,p,fn(rr({},f||{}),{encoding:O}))}catch(O){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),O}let R;try{R=await this.client.core.history.get(n,i)}catch(O){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),O}if(A){const O=kf(b,n,y);await global.Linking.openURL(O,this.client.name)}else{const O=u||wr[R.request.method].res;this.client.core.relayer.publish(n,y,O)}await this.client.core.history.resolve(p)},this.cleanup=async()=>{const t=[],i=[];this.client.session.getAll().forEach(n=>{let a=!1;Rs(n.expiry)&&(a=!0),this.client.core.crypto.keychain.has(n.topic)||(a=!0),a&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Rs(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===En.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=En.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=En.idle},this.processRequest=async t=>{const{topic:i,payload:n,attestation:a,transportType:f,encryptedId:u}=t,b=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:b}))switch(b){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:a,encryptedId:u});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:a,encryptedId:u,transportType:f});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:a,encryptedId:u,transportType:f});default:return this.client.logger.info(`Unsupported request method ${b}`)}},this.onRelayEventResponse=async t=>{const{topic:i,payload:n,transportType:a}=t,f=(await this.client.core.history.get(i,n.id)).request.method;switch(f){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,a);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${f}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:i}=t,{message:n}=Ae("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{const{topic:i,requestMethod:n}=t,a=this.expectedPairingMethodMap.get(i);return!a||a.includes(n)?!1:!!(a.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{const{topic:i,payload:n,attestation:a,encryptedId:f}=t,{params:u,id:b}=n;try{const p=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(rr({},n.params));const y=u.expiryTimestamp||vr(wr.wc_sessionPropose.req.ttl),A=rr({id:b,pairingTopic:i,expiryTimestamp:y},u);await this.setProposal(b,A);const R=await this.getVerifyContext({attestationId:a,hash:fs(JSON.stringify(n)),encryptedId:f,metadata:A.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),p==null||p.setError(os.proposal_listener_not_found)),p==null||p.addTrace(xn.emit_session_proposal),this.client.events.emit("session_proposal",{id:b,params:A,verifyContext:R})}catch(p){await this.sendError({id:b,topic:i,error:p,rpcOpts:wr.wc_sessionPropose.autoReject}),this.client.logger.error(p)}},this.onSessionProposeResponse=async(t,i,n)=>{const{id:a}=i;if(Mn(i)){const{result:f}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:f});const u=this.client.proposal.get(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:u});const b=u.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:b});const p=f.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:p});const y=await this.client.core.crypto.generateSharedKey(b,p);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:y});const A=await this.client.core.relayer.subscribe(y,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:A}),await this.client.core.pairing.activate({topic:t})}else if($i(i)){await this.client.proposal.delete(a,Ut("USER_DISCONNECTED"));const f=St("session_connect");if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners, 954`);this.events.emit(St("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{const{id:n,params:a}=i;try{this.isValidSessionSettleRequest(a);const{relay:f,controller:u,expiry:b,namespaces:p,sessionProperties:y,sessionConfig:A}=i.params,R=fn(rr(rr({topic:t,relay:f,expiry:b,namespaces:p,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:u.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:u.publicKey,metadata:u.metadata}},y&&{sessionProperties:y}),A&&{sessionConfig:A}),{transportType:Kt.relay}),O=St("session_connect");if(this.events.listenerCount(O)===0)throw new Error(`emitting ${O} without any listeners 997`);this.events.emit(St("session_connect"),{session:R}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(f){await this.sendError({id:n,topic:t,error:f}),this.client.logger.error(f)}},this.onSessionSettleResponse=async(t,i)=>{const{id:n}=i;Mn(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(St("session_approve",n),{})):$i(i)&&(await this.client.session.delete(t,Ut("USER_DISCONNECTED")),this.events.emit(St("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:n,id:a}=i;try{const f=`${t}_session_update`,u=Qo.get(f);if(u&&this.isRequestOutOfSync(u,a)){this.client.logger.info(`Discarding out of sync request - ${a}`),this.sendError({id:a,topic:t,error:Ut("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(rr({topic:t},n));try{Qo.set(f,a),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:a,topic:t,result:!0,throwOnFailedPublish:!0})}catch(b){throw Qo.delete(f),b}this.client.events.emit("session_update",{id:a,topic:t,params:n})}catch(f){await this.sendError({id:a,topic:t,error:f}),this.client.logger.error(f)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{const{id:n}=i,a=St("session_update",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Mn(i)?this.events.emit(St("session_update",n),{}):$i(i)&&this.events.emit(St("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,vr(Ga)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(a){await this.sendError({id:n,topic:t,error:a}),this.client.logger.error(a)}},this.onSessionExtendResponse=(t,i)=>{const{id:n}=i,a=St("session_extend",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Mn(i)?this.events.emit(St("session_extend",n),{}):$i(i)&&this.events.emit(St("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{const{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(a){await this.sendError({id:n,topic:t,error:a}),this.client.logger.error(a)}},this.onSessionPingResponse=(t,i)=>{const{id:n}=i,a=St("session_ping",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);setTimeout(()=>{Mn(i)?this.events.emit(St("session_ping",n),{}):$i(i)&&this.events.emit(St("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(a=>{this.client.core.relayer.once(Gr.publish,async()=>{a(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Ut("USER_DISCONNECTED")})]).catch(a=>this.client.logger.error(a))}catch(a){this.client.logger.error(a)}},this.onSessionRequest=async t=>{var i,n,a;const{topic:f,payload:u,attestation:b,encryptedId:p,transportType:y}=t,{id:A,params:R}=u;try{await this.isValidRequest(rr({topic:f},R));const O=this.client.session.get(f),N=await this.getVerifyContext({attestationId:b,hash:fs(JSON.stringify(qs("wc_sessionRequest",R,A))),encryptedId:p,metadata:O.peer.metadata,transportType:y}),K={id:A,topic:f,params:R,verifyContext:N};await this.setPendingSessionRequest(K),y===Kt.link_mode&&(i=O.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=O.peer.metadata.redirect)==null?void 0:n.universal),(a=this.client.signConfig)!=null&&a.disableRequestQueue?this.emitSessionRequest(K):(this.addSessionRequestToSessionRequestQueue(K),this.processSessionRequestQueue())}catch(O){await this.sendError({id:A,topic:f,error:O}),this.client.logger.error(O)}},this.onSessionRequestResponse=(t,i)=>{const{id:n}=i,a=St("session_request",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Mn(i)?this.events.emit(St("session_request",n),{result:i.result}):$i(i)&&this.events.emit(St("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{const{id:n,params:a}=i;try{const f=`${t}_session_event_${a.event.name}`,u=Qo.get(f);if(u&&this.isRequestOutOfSync(u,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(rr({topic:t},a)),this.client.events.emit("session_event",{id:n,topic:t,params:a}),Qo.set(f,n)}catch(f){await this.sendError({id:n,topic:t,error:f}),this.client.logger.error(f)}},this.onSessionAuthenticateResponse=(t,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Mn(i)?this.events.emit(St("session_request",n),{result:i.result}):$i(i)&&this.events.emit(St("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;const{topic:n,payload:a,attestation:f,encryptedId:u,transportType:b}=t;try{const{requester:p,authPayload:y,expiryTimestamp:A}=a.params,R=await this.getVerifyContext({attestationId:f,hash:fs(JSON.stringify(a)),encryptedId:u,metadata:p.metadata,transportType:b}),O={requester:p,pairingTopic:n,id:a.id,authPayload:y,verifyContext:R,expiryTimestamp:A};await this.setAuthRequest(a.id,{request:O,pairingTopic:n,transportType:b}),b===Kt.link_mode&&(i=p.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(p.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:a.params,id:a.id,verifyContext:R})}catch(p){this.client.logger.error(p);const y=a.params.requester.publicKey,A=await this.client.core.crypto.generateKeyPair(),R=this.getAppLinkIfEnabled(a.params.requester.metadata,b),O={type:ds,receiverPublicKey:y,senderPublicKey:A};await this.sendError({id:a.id,topic:n,error:p,encodeOpts:O,rpcOpts:wr.wc_sessionAuthenticate.autoReject,appLink:R})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=En.idle,this.processSessionRequestQueue()},xe.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(a=>a.topic===t&&a.request.method==="wc_sessionRequest").forEach(a=>{const f=a.request.id,u=St("session_request",f);if(this.events.listenerCount(u)===0)throw new Error(`emitting ${u} without any listeners`);this.events.emit(St("session_request",a.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===En.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=En.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:qs("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!oi(t)){const{message:b}=Ae("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(b)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:a,sessionProperties:f,relays:u}=t;if(fi(i)||await this.isValidPairingTopic(i),!tI(u)){const{message:b}=Ae("MISSING_OR_INVALID",`connect() relays: ${u}`);throw new Error(b)}!fi(n)&&bc(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!fi(a)&&bc(a)!==0&&this.validateNamespaces(a,"optionalNamespaces"),fi(f)||this.validateSessionProps(f,"sessionProperties")},this.validateNamespaces=(t,i)=>{const n=eI(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!oi(t))throw new Error(Ae("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:n,relayProtocol:a,sessionProperties:f}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const u=this.client.proposal.get(i),b=Cl(n,"approve()");if(b)throw new Error(b.message);const p=xg(u.requiredNamespaces,n,"approve()");if(p)throw new Error(p.message);if(!fr(a,!0)){const{message:y}=Ae("MISSING_OR_INVALID",`approve() relayProtocol: ${a}`);throw new Error(y)}fi(f)||this.validateSessionProps(f,"sessionProperties")},this.isValidReject=async t=>{if(!oi(t)){const{message:a}=Ae("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(a)}const{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!iI(n)){const{message:a}=Ae("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidSessionSettleRequest=t=>{if(!oi(t)){const{message:p}=Ae("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(p)}const{relay:i,controller:n,namespaces:a,expiry:f}=t;if(!S2(i)){const{message:p}=Ae("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(p)}const u=WS(n,"onSessionSettleRequest()");if(u)throw new Error(u.message);const b=Cl(a,"onSessionSettleRequest()");if(b)throw new Error(b.message);if(Rs(f)){const{message:p}=Ae("EXPIRED","onSessionSettleRequest()");throw new Error(p)}},this.isValidUpdate=async t=>{if(!oi(t)){const{message:b}=Ae("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(b)}const{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const a=this.client.session.get(i),f=Cl(n,"update()");if(f)throw new Error(f.message);const u=xg(a.requiredNamespaces,n,"update()");if(u)throw new Error(u.message)},this.isValidExtend=async t=>{if(!oi(t)){const{message:n}=Ae("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!oi(t)){const{message:b}=Ae("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(b)}const{topic:i,request:n,chainId:a,expiry:f}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:u}=this.client.session.get(i);if(!Eg(u,a)){const{message:b}=Ae("MISSING_OR_INVALID",`request() chainId: ${a}`);throw new Error(b)}if(!nI(n)){const{message:b}=Ae("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(b)}if(!oI(u,a,n.method)){const{message:b}=Ae("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(b)}if(f&&!uI(f,$l)){const{message:b}=Ae("MISSING_OR_INVALID",`request() expiry: ${f}. Expiry must be a number (in seconds) between ${$l.min} and ${$l.max}`);throw new Error(b)}},this.isValidRespond=async t=>{var i;if(!oi(t)){const{message:f}=Ae("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(f)}const{topic:n,response:a}=t;try{await this.isValidSessionTopic(n)}catch(f){throw(i=t==null?void 0:t.response)!=null&&i.id&&this.cleanupAfterResponse(t),f}if(!sI(a)){const{message:f}=Ae("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(a)}`);throw new Error(f)}},this.isValidPing=async t=>{if(!oi(t)){const{message:n}=Ae("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!oi(t)){const{message:u}=Ae("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(u)}const{topic:i,event:n,chainId:a}=t;await this.isValidSessionTopic(i);const{namespaces:f}=this.client.session.get(i);if(!Eg(f,a)){const{message:u}=Ae("MISSING_OR_INVALID",`emit() chainId: ${a}`);throw new Error(u)}if(!aI(n)){const{message:u}=Ae("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(u)}if(!cI(f,a,n.name)){const{message:u}=Ae("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(u)}},this.isValidDisconnect=async t=>{if(!oi(t)){const{message:n}=Ae("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{const{chains:i,uri:n,domain:a,nonce:f}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!fr(n,!1))throw new Error("uri is required parameter");if(!fr(a,!1))throw new Error("domain is required parameter");if(!fr(f,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(b=>ac(b).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:u}=ac(i[0]);if(u!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:i,hash:n,encryptedId:a,metadata:f,transportType:u}=t,b={verified:{verifyUrl:f.verifyUrl||uc,validation:"UNKNOWN",origin:f.url||""}};try{if(u===Kt.link_mode){const y=this.getAppLinkIfEnabled(f,u);return b.verified.validation=y&&new URL(y).origin===new URL(f.url).origin?"VALID":"INVALID",b}const p=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:a,verifyUrl:f.verifyUrl});p&&(b.verified.origin=p.origin,b.verified.isScam=p.isScam,b.verified.validation=p.origin===new URL(f.url).origin?"VALID":"INVALID")}catch(p){this.client.logger.warn(p)}return this.client.logger.debug(`Verify context: ${JSON.stringify(b)}`),b},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!fr(n,!1)){const{message:a}=Ae("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(a)}})},this.getPendingAuthRequest=t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const a=this.recentlyDeletedLimit/2;for(const f of this.recentlyDeletedMap.keys()){if(n++>=a)break;this.recentlyDeletedMap.delete(f)}}},this.checkRecentlyDeleted=t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:n}=Ae("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,a,f,u,b,p,y,A,R;return!t||i!==Kt.link_mode?!1:((a=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:a.linkMode)===!0&&((u=(f=this.client.metadata)==null?void 0:f.redirect)==null?void 0:u.universal)!==void 0&&((p=(b=this.client.metadata)==null?void 0:b.redirect)==null?void 0:p.universal)!==""&&((y=t==null?void 0:t.redirect)==null?void 0:y.universal)!==void 0&&((A=t==null?void 0:t.redirect)==null?void 0:A.universal)!==""&&((R=t==null?void 0:t.redirect)==null?void 0:R.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t==null?void 0:t.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=q1(t,"topic")||"",n=decodeURIComponent(q1(t,"wc_ev")||""),a=this.client.session.keys.includes(i);a&&this.client.session.update(i,{transportType:Kt.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:a})},this.registerLinkModeListeners=async()=>{var t;if(z0()||vo()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Gr.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:n,transportType:a}=e,{publicKey:f}=this.client.auth.authKeys.keys.includes(sh)?this.client.auth.authKeys.get(sh):{responseTopic:void 0,publicKey:void 0},u=await this.client.core.crypto.decode(t,i,{receiverPublicKey:f,encoding:a===Kt.link_mode?Yo:Bs});try{Z0(u)?(this.client.core.history.set(t,u),this.onRelayEventRequest({topic:t,payload:u,attestation:n,transportType:a,encryptedId:fs(i)})):Gh(u)?(await this.client.core.history.resolve(u),await this.onRelayEventResponse({topic:t,payload:u,transportType:a}),this.client.core.history.delete(t,u.id)):this.onRelayEventUnknownPayload({topic:t,payload:u,transportType:a})}catch(b){this.client.logger.error(b)}}registerExpirerEvents(){this.client.core.expirer.on(Li.expired,async e=>{const{topic:t,id:i}=Db(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Ae("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Ae("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(ca.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(ca.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!fr(e,!1)){const{message:t}=Ae("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=Ae("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Rs(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=Ae("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!fr(e,!1)){const{message:t}=Ae("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=Ae("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Rs(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=Ae("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=Ae("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(fr(e,!1)){const{message:t}=Ae("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=Ae("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!rI(e)){const{message:t}=Ae("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=Ae("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Rs(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=Ae("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class BN extends xa{constructor(e,t){super(e,t,wN,rd),this.core=e,this.logger=t}}class qN extends xa{constructor(e,t){super(e,t,_N,rd),this.core=e,this.logger=t}}class LN extends xa{constructor(e,t){super(e,t,EN,rd,i=>i.id),this.core=e,this.logger=t}}class UN extends xa{constructor(e,t){super(e,t,MN,Jh,()=>sh),this.core=e,this.logger=t}}class $N extends xa{constructor(e,t){super(e,t,PN,Jh),this.core=e,this.logger=t}}class zN extends xa{constructor(e,t){super(e,t,ON,Jh,i=>i.id),this.core=e,this.logger=t}}class jN{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new UN(this.core,this.logger),this.pairingTopics=new $N(this.core,this.logger),this.requests=new zN(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class id extends FM{constructor(e){super(e),this.protocol=tm,this.version=rm,this.name=Ul.name,this.events=new Hi.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(a){throw this.logger.error(a.message),a}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=(e==null?void 0:e.name)||Ul.name,this.metadata=(e==null?void 0:e.metadata)||Ob(),this.signConfig=e==null?void 0:e.signConfig;const t=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Nc(Hh({level:(e==null?void 0:e.logger)||Ul.logger}));this.core=(e==null?void 0:e.core)||new yN(e),this.logger=Yr(t,this.name),this.session=new qN(this.core,this.logger),this.proposal=new BN(this.core,this.logger),this.pendingRequest=new LN(this.core,this.logger),this.engine=new FN(this),this.auth=new jN(this.core,this.logger)}static async init(e){const t=new id(e);return await t.initialize(),t}get context(){return di(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var _0={exports:{}};(function(r,e){var t=typeof self<"u"?self:ji,i=function(){function a(){this.fetch=!1,this.DOMException=t.DOMException}return a.prototype=t,new a}();(function(a){(function(f){var u={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function b(h){return h&&DataView.prototype.isPrototypeOf(h)}if(u.arrayBuffer)var p=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],y=ArrayBuffer.isView||function(h){return h&&p.indexOf(Object.prototype.toString.call(h))>-1};function A(h){if(typeof h!="string"&&(h=String(h)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(h))throw new TypeError("Invalid character in header field name");return h.toLowerCase()}function R(h){return typeof h!="string"&&(h=String(h)),h}function O(h){var v={next:function(){var _=h.shift();return{done:_===void 0,value:_}}};return u.iterable&&(v[Symbol.iterator]=function(){return v}),v}function N(h){this.map={},h instanceof N?h.forEach(function(v,_){this.append(_,v)},this):Array.isArray(h)?h.forEach(function(v){this.append(v[0],v[1])},this):h&&Object.getOwnPropertyNames(h).forEach(function(v){this.append(v,h[v])},this)}N.prototype.append=function(h,v){h=A(h),v=R(v);var _=this.map[h];this.map[h]=_?_+", "+v:v},N.prototype.delete=function(h){delete this.map[A(h)]},N.prototype.get=function(h){return h=A(h),this.has(h)?this.map[h]:null},N.prototype.has=function(h){return this.map.hasOwnProperty(A(h))},N.prototype.set=function(h,v){this.map[A(h)]=R(v)},N.prototype.forEach=function(h,v){for(var _ in this.map)this.map.hasOwnProperty(_)&&h.call(v,this.map[_],_,this)},N.prototype.keys=function(){var h=[];return this.forEach(function(v,_){h.push(_)}),O(h)},N.prototype.values=function(){var h=[];return this.forEach(function(v){h.push(v)}),O(h)},N.prototype.entries=function(){var h=[];return this.forEach(function(v,_){h.push([_,v])}),O(h)},u.iterable&&(N.prototype[Symbol.iterator]=N.prototype.entries);function K(h){if(h.bodyUsed)return Promise.reject(new TypeError("Already read"));h.bodyUsed=!0}function W(h){return new Promise(function(v,_){h.onload=function(){v(h.result)},h.onerror=function(){_(h.error)}})}function Q(h){var v=new FileReader,_=W(v);return v.readAsArrayBuffer(h),_}function j(h){var v=new FileReader,_=W(v);return v.readAsText(h),_}function Y(h){for(var v=new Uint8Array(h),_=new Array(v.length),I=0;I-1?v:h}function B(h,v){v=v||{};var _=v.body;if(h instanceof B){if(h.bodyUsed)throw new TypeError("Already read");this.url=h.url,this.credentials=h.credentials,v.headers||(this.headers=new N(h.headers)),this.method=h.method,this.mode=h.mode,this.signal=h.signal,!_&&h._bodyInit!=null&&(_=h._bodyInit,h.bodyUsed=!0)}else this.url=String(h);if(this.credentials=v.credentials||this.credentials||"same-origin",(v.headers||!this.headers)&&(this.headers=new N(v.headers)),this.method=x(v.method||this.method||"GET"),this.mode=v.mode||this.mode||null,this.signal=v.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&_)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(_)}B.prototype.clone=function(){return new B(this,{body:this._bodyInit})};function ae(h){var v=new FormData;return h.trim().split("&").forEach(function(_){if(_){var I=_.split("="),M=I.shift().replace(/\+/g," "),S=I.join("=").replace(/\+/g," ");v.append(decodeURIComponent(M),decodeURIComponent(S))}}),v}function le(h){var v=new N,_=h.replace(/\r?\n[\t ]+/g," ");return _.split(/\r?\n/).forEach(function(I){var M=I.split(":"),S=M.shift().trim();if(S){var d=M.join(":").trim();v.append(S,d)}}),v}k.call(B.prototype);function F(h,v){v||(v={}),this.type="default",this.status=v.status===void 0?200:v.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in v?v.statusText:"OK",this.headers=new N(v.headers),this.url=v.url||"",this._initBody(h)}k.call(F.prototype),F.prototype.clone=function(){return new F(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new N(this.headers),url:this.url})},F.error=function(){var h=new F(null,{status:0,statusText:""});return h.type="error",h};var m=[301,302,303,307,308];F.redirect=function(h,v){if(m.indexOf(v)===-1)throw new RangeError("Invalid status code");return new F(null,{status:v,headers:{location:h}})},f.DOMException=a.DOMException;try{new f.DOMException}catch{f.DOMException=function(v,_){this.message=v,this.name=_;var I=Error(v);this.stack=I.stack},f.DOMException.prototype=Object.create(Error.prototype),f.DOMException.prototype.constructor=f.DOMException}function c(h,v){return new Promise(function(_,I){var M=new B(h,v);if(M.signal&&M.signal.aborted)return I(new f.DOMException("Aborted","AbortError"));var S=new XMLHttpRequest;function d(){S.abort()}S.onload=function(){var g={status:S.status,statusText:S.statusText,headers:le(S.getAllResponseHeaders()||"")};g.url="responseURL"in S?S.responseURL:g.headers.get("X-Request-URL");var T="response"in S?S.response:S.responseText;_(new F(T,g))},S.onerror=function(){I(new TypeError("Network request failed"))},S.ontimeout=function(){I(new TypeError("Network request failed"))},S.onabort=function(){I(new f.DOMException("Aborted","AbortError"))},S.open(M.method,M.url,!0),M.credentials==="include"?S.withCredentials=!0:M.credentials==="omit"&&(S.withCredentials=!1),"responseType"in S&&u.blob&&(S.responseType="blob"),M.headers.forEach(function(g,T){S.setRequestHeader(T,g)}),M.signal&&(M.signal.addEventListener("abort",d),S.onreadystatechange=function(){S.readyState===4&&M.signal.removeEventListener("abort",d)}),S.send(typeof M._bodyInit>"u"?null:M._bodyInit)})}return c.polyfill=!0,a.fetch||(a.fetch=c,a.Headers=N,a.Request=B,a.Response=F),f.Headers=N,f.Request=B,f.Response=F,f.fetch=c,Object.defineProperty(f,"__esModule",{value:!0}),f})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=i;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,r.exports=e})(_0,_0.exports);var kN=_0.exports;const lv=S0(kN);var HN=Object.defineProperty,KN=Object.defineProperties,VN=Object.getOwnPropertyDescriptors,dv=Object.getOwnPropertySymbols,GN=Object.prototype.hasOwnProperty,WN=Object.prototype.propertyIsEnumerable,pv=(r,e,t)=>e in r?HN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,gv=(r,e)=>{for(var t in e||(e={}))GN.call(e,t)&&pv(r,t,e[t]);if(dv)for(var t of dv(e))WN.call(e,t)&&pv(r,t,e[t]);return r},vv=(r,e)=>KN(r,VN(e));const JN={Accept:"application/json","Content-Type":"application/json"},YN="POST",bv={headers:JN,method:YN},mv=10;class Gn{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new Hi.EventEmitter,this.isAvailable=!1,this.registering=!1,!Ug(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=t}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const t=vs(e),i=await(await lv(this.url,vv(gv({},bv),{body:t}))).json();this.onPayload({data:i})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!Ug(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),n(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return n(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=vs({id:1,jsonrpc:"2.0",method:"test",params:[]});await lv(e,vv(gv({},bv),{body:t}))}this.onOpen()}catch(t){const i=this.parseError(t);throw this.events.emit("register_error",i),this.onClose(),i}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?ga(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),a=Vh(e,n);this.events.emit("payload",a)}parseError(e,t=this.url){return D2(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>mv&&this.events.setMaxListeners(mv)}}const yv="error",QN="wss://relay.walletconnect.org",XN="wc",ZN="universal_provider",wv=`${XN}@2:${ZN}:`,sm="https://rpc.walletconnect.org/v1/",Ya="generic",eC=`${sm}bundler`,vn={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var rc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},A0={exports:{}};/** -* @license -* Lodash -* Copyright OpenJS Foundation and other contributors -* Released under MIT license -* Based on Underscore.js 1.8.3 -* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors -*/(function(r,e){(function(){var t,i="4.17.21",n=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",f="Expected a function",u="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",p=500,y="__lodash_placeholder__",A=1,R=2,O=4,N=1,K=2,W=1,Q=2,j=4,Y=8,U=16,k=32,G=64,x=128,B=256,ae=512,le=30,F="...",m=800,c=16,h=1,v=2,_=3,I=1/0,M=9007199254740991,S=17976931348623157e292,d=NaN,g=4294967295,T=g-1,Z=g>>>1,se=[["ary",x],["bind",W],["bindKey",Q],["curry",Y],["curryRight",U],["flip",ae],["partial",k],["partialRight",G],["rearg",B]],P="[object Arguments]",ee="[object Array]",q="[object AsyncFunction]",z="[object Boolean]",H="[object Date]",w="[object DOMException]",$="[object Error]",ne="[object Function]",ce="[object GeneratorFunction]",he="[object Map]",ye="[object Number]",we="[object Null]",Ce="[object Object]",Qe="[object Promise]",Oe="[object Proxy]",Te="[object RegExp]",Ie="[object Set]",me="[object String]",Re="[object Symbol]",De="[object Undefined]",ve="[object WeakMap]",Ne="[object WeakSet]",Se="[object ArrayBuffer]",be="[object DataView]",Le="[object Float32Array]",Me="[object Float64Array]",_e="[object Int8Array]",He="[object Int16Array]",Ve="[object Int32Array]",Ee="[object Uint8Array]",Ke="[object Uint8ClampedArray]",ut="[object Uint16Array]",Ge="[object Uint32Array]",_t=/\b__p \+= '';/g,lt=/\b(__p \+=) '' \+/g,Je=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Et=/&(?:amp|lt|gt|quot|#39);/g,It=/[&<>"']/g,Fe=RegExp(Et.source),Xe=RegExp(It.source),tt=/<%-([\s\S]+?)%>/g,Be=/<%([\s\S]+?)%>/g,et=/<%=([\s\S]+?)%>/g,Ze=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$e=/^\w*$/,ft=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rt=/[\\^$.*+?()[\]{}|]/g,ze=RegExp(rt.source),it=/^\s+/,st=/\s/,qe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ye=/\{\n\/\* \[wrapped with (.+)\] \*/,ht=/,? & /,je=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Tt=/[()=,{}\[\]\/\s]/,Dt=/\\(\\)?/g,at=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,bt=/\w*$/,Cr=/^[-+]0x[0-9a-f]+$/i,Tr=/^0b[01]+$/i,Dr=/^\[object .+?Constructor\]$/,Fr=/^0o[0-7]+$/i,Br=/^(?:0|[1-9]\d*)$/,er=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Qr=/($^)/,Gi=/['\n\r\u2028\u2029\\]/g,Xr="\\ud800-\\udfff",Wi="\\u0300-\\u036f",Ji="\\ufe20-\\ufe2f",Zr="\\u20d0-\\u20ff",Si=Wi+Ji+Zr,Ii="\\u2700-\\u27bf",lr="a-z\\xdf-\\xf6\\xf8-\\xff",Yi="\\xac\\xb1\\xd7\\xf7",Qi="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Xi="\\u2000-\\u206f",js=" \\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",Dc="A-Z\\xc0-\\xd6\\xd8-\\xde",Fc="\\ufe0e\\ufe0f",ks=Yi+Qi+Xi+js,xo="['’]",Hs="["+Xr+"]",So="["+ks+"]",Ks="["+Si+"]",Bc="\\d+",Yh="["+Ii+"]",qc="["+lr+"]",Lc="[^"+Xr+ks+Bc+Ii+lr+Dc+"]",Ma="\\ud83c[\\udffb-\\udfff]",Qh="(?:"+Ks+"|"+Ma+")",Uc="[^"+Xr+"]",Pa="(?:\\ud83c[\\udde6-\\uddff]){2}",ms="[\\ud800-\\udbff][\\udc00-\\udfff]",pi="["+Dc+"]",$c="\\u200d",zc="(?:"+qc+"|"+Lc+")",bn="(?:"+pi+"|"+Lc+")",jc="(?:"+xo+"(?:d|ll|m|re|s|t|ve))?",kc="(?:"+xo+"(?:D|LL|M|RE|S|T|VE))?",Hc=Qh+"?",Kc="["+Fc+"]?",Xh="(?:"+$c+"(?:"+[Uc,Pa,ms].join("|")+")"+Kc+Hc+")*",Wn="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Vc="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Gc=Kc+Hc+Xh,Oa="(?:"+[Yh,Pa,ms].join("|")+")"+Gc,Zh="(?:"+[Uc+Ks+"?",Ks,Pa,ms,Hs].join("|")+")",Io=RegExp(xo,"g"),eu=RegExp(Ks,"g"),Ra=RegExp(Ma+"(?="+Ma+")|"+Zh+Gc,"g"),Wc=RegExp([pi+"?"+qc+"+"+jc+"(?="+[So,pi,"$"].join("|")+")",bn+"+"+kc+"(?="+[So,pi+zc,"$"].join("|")+")",pi+"?"+zc+"+"+jc,pi+"+"+kc,Vc,Wn,Bc,Oa].join("|"),"g"),Jc=RegExp("["+$c+Xr+Si+Fc+"]"),Vs=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Yc=["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"],tu=-1,zt={};zt[Le]=zt[Me]=zt[_e]=zt[He]=zt[Ve]=zt[Ee]=zt[Ke]=zt[ut]=zt[Ge]=!0,zt[P]=zt[ee]=zt[Se]=zt[z]=zt[be]=zt[H]=zt[$]=zt[ne]=zt[he]=zt[ye]=zt[Ce]=zt[Te]=zt[Ie]=zt[me]=zt[ve]=!1;var $t={};$t[P]=$t[ee]=$t[Se]=$t[be]=$t[z]=$t[H]=$t[Le]=$t[Me]=$t[_e]=$t[He]=$t[Ve]=$t[he]=$t[ye]=$t[Ce]=$t[Te]=$t[Ie]=$t[me]=$t[Re]=$t[Ee]=$t[Ke]=$t[ut]=$t[Ge]=!0,$t[$]=$t[ne]=$t[ve]=!1;var V={À:"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"},te={"&":"&","<":"<",">":">",'"':""","'":"'"},pe={"&":"&","<":"<",">":">",""":'"',"'":"'"},Ue={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},jt=parseFloat,pt=parseInt,Jt=typeof rc=="object"&&rc&&rc.Object===Object&&rc,hr=typeof self=="object"&&self&&self.Object===Object&&self,Nt=Jt||hr||Function("return this")(),kt=e&&!e.nodeType&&e,sr=kt&&!0&&r&&!r.nodeType&&r,ei=sr&&sr.exports===kt,ur=ei&&Jt.process,Yt=function(){try{var re=sr&&sr.require&&sr.require("util").types;return re||ur&&ur.binding&&ur.binding("util")}catch{}}(),jr=Yt&&Yt.isArrayBuffer,Zi=Yt&&Yt.isDate,Mi=Yt&&Yt.isMap,mn=Yt&&Yt.isRegExp,Mo=Yt&&Yt.isSet,Gs=Yt&&Yt.isTypedArray;function br(re,fe,oe){switch(oe.length){case 0:return re.call(fe);case 1:return re.call(fe,oe[0]);case 2:return re.call(fe,oe[0],oe[1]);case 3:return re.call(fe,oe[0],oe[1],oe[2])}return re.apply(fe,oe)}function cm(re,fe,oe,ke){for(var dt=-1,Ft=re==null?0:re.length;++dt-1}function ru(re,fe,oe){for(var ke=-1,dt=re==null?0:re.length;++ke-1;);return oe}function dd(re,fe){for(var oe=re.length;oe--&&Na(fe,re[oe],0)>-1;);return oe}function bm(re,fe){for(var oe=re.length,ke=0;oe--;)re[oe]===fe&&++ke;return ke}var mm=au(V),ym=au(te);function wm(re){return"\\"+Ue[re]}function _m(re,fe){return re==null?t:re[fe]}function Ca(re){return Jc.test(re)}function Am(re){return Vs.test(re)}function Em(re){for(var fe,oe=[];!(fe=re.next()).done;)oe.push(fe.value);return oe}function hu(re){var fe=-1,oe=Array(re.size);return re.forEach(function(ke,dt){oe[++fe]=[dt,ke]}),oe}function pd(re,fe){return function(oe){return re(fe(oe))}}function _s(re,fe){for(var oe=-1,ke=re.length,dt=0,Ft=[];++oe-1}function h6(s,o){var l=this.__data__,E=gf(l,s);return E<0?(++this.size,l.push([s,o])):l[E][1]=o,this}Jn.prototype.clear=a6,Jn.prototype.delete=o6,Jn.prototype.get=c6,Jn.prototype.has=f6,Jn.prototype.set=h6;function Yn(s){var o=-1,l=s==null?0:s.length;for(this.clear();++o=o?s:o)),s}function Ni(s,o,l,E,C,L){var J,X=o&A,ie=o&R,ue=o&O;if(l&&(J=C?l(s,E,C,L):l(s)),J!==t)return J;if(!Zt(s))return s;var de=gt(s);if(de){if(J=py(s),!X)return ti(s,J)}else{var ge=Lr(s),Pe=ge==ne||ge==ce;if(Ms(s))return Yd(s,X);if(ge==Ce||ge==P||Pe&&!C){if(J=ie||Pe?{}:gp(s),!X)return ie?iy(s,I6(J,s)):ry(s,Id(J,s))}else{if(!$t[ge])return C?s:{};J=gy(s,ge,X)}}L||(L=new tn);var We=L.get(s);if(We)return We;L.set(s,J),Hp(s)?s.forEach(function(ct){J.add(Ni(ct,o,l,ct,s,L))}):jp(s)&&s.forEach(function(ct,xt){J.set(xt,Ni(ct,o,l,xt,s,L))});var ot=ue?ie?Bu:Fu:ie?ii:mr,wt=de?t:ot(s);return Pi(wt||s,function(ct,xt){wt&&(xt=ct,ct=s[xt]),Do(J,xt,Ni(ct,o,l,xt,s,L))}),J}function M6(s){var o=mr(s);return function(l){return Md(l,s,o)}}function Md(s,o,l){var E=l.length;if(s==null)return!E;for(s=Ht(s);E--;){var C=l[E],L=o[C],J=s[C];if(J===t&&!(C in s)||!L(J))return!1}return!0}function Pd(s,o,l){if(typeof s!="function")throw new Oi(f);return zo(function(){s.apply(t,l)},o)}function Fo(s,o,l,E){var C=-1,L=Qc,J=!0,X=s.length,ie=[],ue=o.length;if(!X)return ie;l&&(o=Xt(o,gi(l))),E?(L=ru,J=!1):o.length>=n&&(L=Po,J=!1,o=new Ys(o));e:for(;++CC?0:C+l),E=E===t||E>C?C:yt(E),E<0&&(E+=C),E=l>E?0:Vp(E);l0&&l(X)?o>1?Mr(X,o-1,l,E,C):ws(C,X):E||(C[C.length]=X)}return C}var bu=rp(),Nd=rp(!0);function yn(s,o){return s&&bu(s,o,mr)}function mu(s,o){return s&&Nd(s,o,mr)}function bf(s,o){return ys(o,function(l){return ts(s[l])})}function Xs(s,o){o=Ss(o,s);for(var l=0,E=o.length;s!=null&&lo}function R6(s,o){return s!=null&&Lt.call(s,o)}function N6(s,o){return s!=null&&o in Ht(s)}function C6(s,o,l){return s>=qr(o,l)&&s=120&&de.length>=120)?new Ys(J&&de):t}de=s[0];var ge=-1,Pe=X[0];e:for(;++ge-1;)X!==s&&cf.call(X,ie,1),cf.call(s,ie,1);return s}function jd(s,o){for(var l=s?o.length:0,E=l-1;l--;){var C=o[l];if(l==E||C!==L){var L=C;es(C)?cf.call(s,C,1):Pu(s,C)}}return s}function Su(s,o){return s+uf(Ad()*(o-s+1))}function K6(s,o,l,E){for(var C=-1,L=pr(hf((o-s)/(l||1)),0),J=oe(L);L--;)J[E?L:++C]=s,s+=l;return J}function Iu(s,o){var l="";if(!s||o<1||o>M)return l;do o%2&&(l+=s),o=uf(o/2),o&&(s+=s);while(o);return l}function At(s,o){return ku(mp(s,o,ni),s+"")}function V6(s){return Sd(ka(s))}function G6(s,o){var l=ka(s);return Pf(l,Qs(o,0,l.length))}function Lo(s,o,l,E){if(!Zt(s))return s;o=Ss(o,s);for(var C=-1,L=o.length,J=L-1,X=s;X!=null&&++CC?0:C+o),l=l>C?C:l,l<0&&(l+=C),C=o>l?0:l-o>>>0,o>>>=0;for(var L=oe(C);++E>>1,J=s[L];J!==null&&!bi(J)&&(l?J<=o:J=n){var ue=o?null:oy(s);if(ue)return Zc(ue);J=!1,C=Po,ie=new Ys}else ie=o?[]:X;e:for(;++E=E?s:Ci(s,o,l)}var Jd=Lm||function(s){return Nt.clearTimeout(s)};function Yd(s,o){if(o)return s.slice();var l=s.length,E=bd?bd(l):new s.constructor(l);return s.copy(E),E}function Cu(s){var o=new s.constructor(s.byteLength);return new af(o).set(new af(s)),o}function X6(s,o){var l=o?Cu(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.byteLength)}function Z6(s){var o=new s.constructor(s.source,bt.exec(s));return o.lastIndex=s.lastIndex,o}function ey(s){return To?Ht(To.call(s)):{}}function Qd(s,o){var l=o?Cu(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.length)}function Xd(s,o){if(s!==o){var l=s!==t,E=s===null,C=s===s,L=bi(s),J=o!==t,X=o===null,ie=o===o,ue=bi(o);if(!X&&!ue&&!L&&s>o||L&&J&&ie&&!X&&!ue||E&&J&&ie||!l&&ie||!C)return 1;if(!E&&!L&&!ue&&s=X)return ie;var ue=l[E];return ie*(ue=="desc"?-1:1)}}return s.index-o.index}function Zd(s,o,l,E){for(var C=-1,L=s.length,J=l.length,X=-1,ie=o.length,ue=pr(L-J,0),de=oe(ie+ue),ge=!E;++X1?l[C-1]:t,J=C>2?l[2]:t;for(L=s.length>3&&typeof L=="function"?(C--,L):t,J&&Hr(l[0],l[1],J)&&(L=C<3?t:L,C=1),o=Ht(o);++E-1?C[L?o[J]:J]:t}}function sp(s){return Zn(function(o){var l=o.length,E=l,C=Ri.prototype.thru;for(s&&o.reverse();E--;){var L=o[E];if(typeof L!="function")throw new Oi(f);if(C&&!J&&If(L)=="wrapper")var J=new Ri([],!0)}for(E=J?E:l;++E1&&Ct.reverse(),de&&ieX))return!1;var ue=L.get(s),de=L.get(o);if(ue&&de)return ue==o&&de==s;var ge=-1,Pe=!0,We=l&K?new Ys:t;for(L.set(s,o),L.set(o,s);++ge1?"& ":"")+o[E],o=o.join(l>2?", ":" "),s.replace(qe,`{ -/* [wrapped with `+o+`] */ -`)}function by(s){return gt(s)||ta(s)||!!(wd&&s&&s[wd])}function es(s,o){var l=typeof s;return o=o??M,!!o&&(l=="number"||l!="symbol"&&Br.test(s))&&s>-1&&s%1==0&&s0){if(++o>=m)return arguments[0]}else o=0;return s.apply(t,arguments)}}function Pf(s,o){var l=-1,E=s.length,C=E-1;for(o=o===t?E:o;++l1?s[o-1]:t;return l=typeof l=="function"?(s.pop(),l):t,Rp(s,l)});function Np(s){var o=D(s);return o.__chain__=!0,o}function P3(s,o){return o(s),s}function Of(s,o){return o(s)}var O3=Zn(function(s){var o=s.length,l=o?s[0]:0,E=this.__wrapped__,C=function(L){return vu(L,s)};return o>1||this.__actions__.length||!(E instanceof Mt)||!es(l)?this.thru(C):(E=E.slice(l,+l+(o?1:0)),E.__actions__.push({func:Of,args:[C],thisArg:t}),new Ri(E,this.__chain__).thru(function(L){return o&&!L.length&&L.push(t),L}))});function R3(){return Np(this)}function N3(){return new Ri(this.value(),this.__chain__)}function C3(){this.__values__===t&&(this.__values__=Kp(this.value()));var s=this.__index__>=this.__values__.length,o=s?t:this.__values__[this.__index__++];return{done:s,value:o}}function T3(){return this}function D3(s){for(var o,l=this;l instanceof pf;){var E=xp(l);E.__index__=0,E.__values__=t,o?C.__wrapped__=E:o=E;var C=E;l=l.__wrapped__}return C.__wrapped__=s,o}function F3(){var s=this.__wrapped__;if(s instanceof Mt){var o=s;return this.__actions__.length&&(o=new Mt(this)),o=o.reverse(),o.__actions__.push({func:Of,args:[Hu],thisArg:t}),new Ri(o,this.__chain__)}return this.thru(Hu)}function B3(){return Gd(this.__wrapped__,this.__actions__)}var q3=_f(function(s,o,l){Lt.call(s,l)?++s[l]:Qn(s,l,1)});function L3(s,o,l){var E=gt(s)?ad:P6;return l&&Hr(s,o,l)&&(o=t),E(s,nt(o,3))}function U3(s,o){var l=gt(s)?ys:Rd;return l(s,nt(o,3))}var $3=np(Sp),z3=np(Ip);function j3(s,o){return Mr(Rf(s,o),1)}function k3(s,o){return Mr(Rf(s,o),I)}function H3(s,o,l){return l=l===t?1:yt(l),Mr(Rf(s,o),l)}function Cp(s,o){var l=gt(s)?Pi:Es;return l(s,nt(o,3))}function Tp(s,o){var l=gt(s)?fm:Od;return l(s,nt(o,3))}var K3=_f(function(s,o,l){Lt.call(s,l)?s[l].push(o):Qn(s,l,[o])});function V3(s,o,l,E){s=ri(s)?s:ka(s),l=l&&!E?yt(l):0;var C=s.length;return l<0&&(l=pr(C+l,0)),Ff(s)?l<=C&&s.indexOf(o,l)>-1:!!C&&Na(s,o,l)>-1}var G3=At(function(s,o,l){var E=-1,C=typeof o=="function",L=ri(s)?oe(s.length):[];return Es(s,function(J){L[++E]=C?br(o,J,l):Bo(J,o,l)}),L}),W3=_f(function(s,o,l){Qn(s,l,o)});function Rf(s,o){var l=gt(s)?Xt:Bd;return l(s,nt(o,3))}function J3(s,o,l,E){return s==null?[]:(gt(o)||(o=o==null?[]:[o]),l=E?t:l,gt(l)||(l=l==null?[]:[l]),$d(s,o,l))}var Y3=_f(function(s,o,l){s[l?0:1].push(o)},function(){return[[],[]]});function Q3(s,o,l){var E=gt(s)?iu:hd,C=arguments.length<3;return E(s,nt(o,4),l,C,Es)}function X3(s,o,l){var E=gt(s)?hm:hd,C=arguments.length<3;return E(s,nt(o,4),l,C,Od)}function Z3(s,o){var l=gt(s)?ys:Rd;return l(s,Tf(nt(o,3)))}function ew(s){var o=gt(s)?Sd:V6;return o(s)}function tw(s,o,l){(l?Hr(s,o,l):o===t)?o=1:o=yt(o);var E=gt(s)?E6:G6;return E(s,o)}function rw(s){var o=gt(s)?x6:J6;return o(s)}function iw(s){if(s==null)return 0;if(ri(s))return Ff(s)?Ta(s):s.length;var o=Lr(s);return o==he||o==Ie?s.size:Au(s).length}function nw(s,o,l){var E=gt(s)?nu:Y6;return l&&Hr(s,o,l)&&(o=t),E(s,nt(o,3))}var sw=At(function(s,o){if(s==null)return[];var l=o.length;return l>1&&Hr(s,o[0],o[1])?o=[]:l>2&&Hr(o[0],o[1],o[2])&&(o=[o[0]]),$d(s,Mr(o,1),[])}),Nf=Um||function(){return Nt.Date.now()};function aw(s,o){if(typeof o!="function")throw new Oi(f);return s=yt(s),function(){if(--s<1)return o.apply(this,arguments)}}function Dp(s,o,l){return o=l?t:o,o=s&&o==null?s.length:o,Xn(s,x,t,t,t,t,o)}function Fp(s,o){var l;if(typeof o!="function")throw new Oi(f);return s=yt(s),function(){return--s>0&&(l=o.apply(this,arguments)),s<=1&&(o=t),l}}var Vu=At(function(s,o,l){var E=W;if(l.length){var C=_s(l,za(Vu));E|=k}return Xn(s,E,o,l,C)}),Bp=At(function(s,o,l){var E=W|Q;if(l.length){var C=_s(l,za(Bp));E|=k}return Xn(o,E,s,l,C)});function qp(s,o,l){o=l?t:o;var E=Xn(s,Y,t,t,t,t,t,o);return E.placeholder=qp.placeholder,E}function Lp(s,o,l){o=l?t:o;var E=Xn(s,U,t,t,t,t,t,o);return E.placeholder=Lp.placeholder,E}function Up(s,o,l){var E,C,L,J,X,ie,ue=0,de=!1,ge=!1,Pe=!0;if(typeof s!="function")throw new Oi(f);o=Di(o)||0,Zt(l)&&(de=!!l.leading,ge="maxWait"in l,L=ge?pr(Di(l.maxWait)||0,o):L,Pe="trailing"in l?!!l.trailing:Pe);function We(or){var nn=E,is=C;return E=C=t,ue=or,J=s.apply(is,nn),J}function ot(or){return ue=or,X=zo(xt,o),de?We(or):J}function wt(or){var nn=or-ie,is=or-ue,n1=o-nn;return ge?qr(n1,L-is):n1}function ct(or){var nn=or-ie,is=or-ue;return ie===t||nn>=o||nn<0||ge&&is>=L}function xt(){var or=Nf();if(ct(or))return Ct(or);X=zo(xt,wt(or))}function Ct(or){return X=t,Pe&&E?We(or):(E=C=t,J)}function mi(){X!==t&&Jd(X),ue=0,E=ie=C=X=t}function Kr(){return X===t?J:Ct(Nf())}function yi(){var or=Nf(),nn=ct(or);if(E=arguments,C=this,ie=or,nn){if(X===t)return ot(ie);if(ge)return Jd(X),X=zo(xt,o),We(ie)}return X===t&&(X=zo(xt,o)),J}return yi.cancel=mi,yi.flush=Kr,yi}var ow=At(function(s,o){return Pd(s,1,o)}),cw=At(function(s,o,l){return Pd(s,Di(o)||0,l)});function fw(s){return Xn(s,ae)}function Cf(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new Oi(f);var l=function(){var E=arguments,C=o?o.apply(this,E):E[0],L=l.cache;if(L.has(C))return L.get(C);var J=s.apply(this,E);return l.cache=L.set(C,J)||L,J};return l.cache=new(Cf.Cache||Yn),l}Cf.Cache=Yn;function Tf(s){if(typeof s!="function")throw new Oi(f);return function(){var o=arguments;switch(o.length){case 0:return!s.call(this);case 1:return!s.call(this,o[0]);case 2:return!s.call(this,o[0],o[1]);case 3:return!s.call(this,o[0],o[1],o[2])}return!s.apply(this,o)}}function hw(s){return Fp(2,s)}var uw=Q6(function(s,o){o=o.length==1&>(o[0])?Xt(o[0],gi(nt())):Xt(Mr(o,1),gi(nt()));var l=o.length;return At(function(E){for(var C=-1,L=qr(E.length,l);++C=o}),ta=Td(function(){return arguments}())?Td:function(s){return tr(s)&&Lt.call(s,"callee")&&!yd.call(s,"callee")},gt=oe.isArray,Iw=jr?gi(jr):D6;function ri(s){return s!=null&&Df(s.length)&&!ts(s)}function ar(s){return tr(s)&&ri(s)}function Mw(s){return s===!0||s===!1||tr(s)&&kr(s)==z}var Ms=zm||nl,Pw=Zi?gi(Zi):F6;function Ow(s){return tr(s)&&s.nodeType===1&&!jo(s)}function Rw(s){if(s==null)return!0;if(ri(s)&&(gt(s)||typeof s=="string"||typeof s.splice=="function"||Ms(s)||ja(s)||ta(s)))return!s.length;var o=Lr(s);if(o==he||o==Ie)return!s.size;if($o(s))return!Au(s).length;for(var l in s)if(Lt.call(s,l))return!1;return!0}function Nw(s,o){return qo(s,o)}function Cw(s,o,l){l=typeof l=="function"?l:t;var E=l?l(s,o):t;return E===t?qo(s,o,t,l):!!E}function Wu(s){if(!tr(s))return!1;var o=kr(s);return o==$||o==w||typeof s.message=="string"&&typeof s.name=="string"&&!jo(s)}function Tw(s){return typeof s=="number"&&_d(s)}function ts(s){if(!Zt(s))return!1;var o=kr(s);return o==ne||o==ce||o==q||o==Oe}function zp(s){return typeof s=="number"&&s==yt(s)}function Df(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=M}function Zt(s){var o=typeof s;return s!=null&&(o=="object"||o=="function")}function tr(s){return s!=null&&typeof s=="object"}var jp=Mi?gi(Mi):q6;function Dw(s,o){return s===o||_u(s,o,Lu(o))}function Fw(s,o,l){return l=typeof l=="function"?l:t,_u(s,o,Lu(o),l)}function Bw(s){return kp(s)&&s!=+s}function qw(s){if(wy(s))throw new dt(a);return Dd(s)}function Lw(s){return s===null}function Uw(s){return s==null}function kp(s){return typeof s=="number"||tr(s)&&kr(s)==ye}function jo(s){if(!tr(s)||kr(s)!=Ce)return!1;var o=of(s);if(o===null)return!0;var l=Lt.call(o,"constructor")&&o.constructor;return typeof l=="function"&&l instanceof l&&rf.call(l)==Fm}var Ju=mn?gi(mn):L6;function $w(s){return zp(s)&&s>=-M&&s<=M}var Hp=Mo?gi(Mo):U6;function Ff(s){return typeof s=="string"||!gt(s)&&tr(s)&&kr(s)==me}function bi(s){return typeof s=="symbol"||tr(s)&&kr(s)==Re}var ja=Gs?gi(Gs):$6;function zw(s){return s===t}function jw(s){return tr(s)&&Lr(s)==ve}function kw(s){return tr(s)&&kr(s)==Ne}var Hw=Sf(Eu),Kw=Sf(function(s,o){return s<=o});function Kp(s){if(!s)return[];if(ri(s))return Ff(s)?en(s):ti(s);if(Oo&&s[Oo])return Em(s[Oo]());var o=Lr(s),l=o==he?hu:o==Ie?Zc:ka;return l(s)}function rs(s){if(!s)return s===0?s:0;if(s=Di(s),s===I||s===-I){var o=s<0?-1:1;return o*S}return s===s?s:0}function yt(s){var o=rs(s),l=o%1;return o===o?l?o-l:o:0}function Vp(s){return s?Qs(yt(s),0,g):0}function Di(s){if(typeof s=="number")return s;if(bi(s))return d;if(Zt(s)){var o=typeof s.valueOf=="function"?s.valueOf():s;s=Zt(o)?o+"":o}if(typeof s!="string")return s===0?s:+s;s=ud(s);var l=Tr.test(s);return l||Fr.test(s)?pt(s.slice(2),l?2:8):Cr.test(s)?d:+s}function Gp(s){return wn(s,ii(s))}function Vw(s){return s?Qs(yt(s),-M,M):s===0?s:0}function Bt(s){return s==null?"":vi(s)}var Gw=Ua(function(s,o){if($o(o)||ri(o)){wn(o,mr(o),s);return}for(var l in o)Lt.call(o,l)&&Do(s,l,o[l])}),Wp=Ua(function(s,o){wn(o,ii(o),s)}),Bf=Ua(function(s,o,l,E){wn(o,ii(o),s,E)}),Ww=Ua(function(s,o,l,E){wn(o,mr(o),s,E)}),Jw=Zn(vu);function Yw(s,o){var l=La(s);return o==null?l:Id(l,o)}var Qw=At(function(s,o){s=Ht(s);var l=-1,E=o.length,C=E>2?o[2]:t;for(C&&Hr(o[0],o[1],C)&&(E=1);++l1),L}),wn(s,Bu(s),l),E&&(l=Ni(l,A|R|O,cy));for(var C=o.length;C--;)Pu(l,o[C]);return l});function g5(s,o){return Yp(s,Tf(nt(o)))}var v5=Zn(function(s,o){return s==null?{}:k6(s,o)});function Yp(s,o){if(s==null)return{};var l=Xt(Bu(s),function(E){return[E]});return o=nt(o),zd(s,l,function(E,C){return o(E,C[0])})}function b5(s,o,l){o=Ss(o,s);var E=-1,C=o.length;for(C||(C=1,s=t);++Eo){var E=s;s=o,o=E}if(l||s%1||o%1){var C=Ad();return qr(s+C*(o-s+jt("1e-"+((C+"").length-1))),o)}return Su(s,o)}var P5=$a(function(s,o,l){return o=o.toLowerCase(),s+(l?Zp(o):o)});function Zp(s){return Xu(Bt(s).toLowerCase())}function e1(s){return s=Bt(s),s&&s.replace(er,mm).replace(eu,"")}function O5(s,o,l){s=Bt(s),o=vi(o);var E=s.length;l=l===t?E:Qs(yt(l),0,E);var C=l;return l-=o.length,l>=0&&s.slice(l,C)==o}function R5(s){return s=Bt(s),s&&Xe.test(s)?s.replace(It,ym):s}function N5(s){return s=Bt(s),s&&ze.test(s)?s.replace(rt,"\\$&"):s}var C5=$a(function(s,o,l){return s+(l?"-":"")+o.toLowerCase()}),T5=$a(function(s,o,l){return s+(l?" ":"")+o.toLowerCase()}),D5=ip("toLowerCase");function F5(s,o,l){s=Bt(s),o=yt(o);var E=o?Ta(s):0;if(!o||E>=o)return s;var C=(o-E)/2;return xf(uf(C),l)+s+xf(hf(C),l)}function B5(s,o,l){s=Bt(s),o=yt(o);var E=o?Ta(s):0;return o&&E>>0,l?(s=Bt(s),s&&(typeof o=="string"||o!=null&&!Ju(o))&&(o=vi(o),!o&&Ca(s))?Is(en(s),0,l):s.split(o,l)):[]}var k5=$a(function(s,o,l){return s+(l?" ":"")+Xu(o)});function H5(s,o,l){return s=Bt(s),l=l==null?0:Qs(yt(l),0,s.length),o=vi(o),s.slice(l,l+o.length)==o}function K5(s,o,l){var E=D.templateSettings;l&&Hr(s,o,l)&&(o=t),s=Bt(s),o=Bf({},o,E,hp);var C=Bf({},o.imports,E.imports,hp),L=mr(C),J=fu(C,L),X,ie,ue=0,de=o.interpolate||Qr,ge="__p += '",Pe=uu((o.escape||Qr).source+"|"+de.source+"|"+(de===et?at:Qr).source+"|"+(o.evaluate||Qr).source+"|$","g"),We="//# sourceURL="+(Lt.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++tu+"]")+` -`;s.replace(Pe,function(ct,xt,Ct,mi,Kr,yi){return Ct||(Ct=mi),ge+=s.slice(ue,yi).replace(Gi,wm),xt&&(X=!0,ge+=`' + -__e(`+xt+`) + -'`),Kr&&(ie=!0,ge+=`'; -`+Kr+`; -__p += '`),Ct&&(ge+=`' + -((__t = (`+Ct+`)) == null ? '' : __t) + -'`),ue=yi+ct.length,ct}),ge+=`'; -`;var ot=Lt.call(o,"variable")&&o.variable;if(!ot)ge=`with (obj) { -`+ge+` -} -`;else if(Tt.test(ot))throw new dt(u);ge=(ie?ge.replace(_t,""):ge).replace(lt,"$1").replace(Je,"$1;"),ge="function("+(ot||"obj")+`) { -`+(ot?"":`obj || (obj = {}); -`)+"var __t, __p = ''"+(X?", __e = _.escape":"")+(ie?`, __j = Array.prototype.join; -function print() { __p += __j.call(arguments, '') } -`:`; -`)+ge+`return __p -}`;var wt=r1(function(){return Ft(L,We+"return "+ge).apply(t,J)});if(wt.source=ge,Wu(wt))throw wt;return wt}function V5(s){return Bt(s).toLowerCase()}function G5(s){return Bt(s).toUpperCase()}function W5(s,o,l){if(s=Bt(s),s&&(l||o===t))return ud(s);if(!s||!(o=vi(o)))return s;var E=en(s),C=en(o),L=ld(E,C),J=dd(E,C)+1;return Is(E,L,J).join("")}function J5(s,o,l){if(s=Bt(s),s&&(l||o===t))return s.slice(0,gd(s)+1);if(!s||!(o=vi(o)))return s;var E=en(s),C=dd(E,en(o))+1;return Is(E,0,C).join("")}function Y5(s,o,l){if(s=Bt(s),s&&(l||o===t))return s.replace(it,"");if(!s||!(o=vi(o)))return s;var E=en(s),C=ld(E,en(o));return Is(E,C).join("")}function Q5(s,o){var l=le,E=F;if(Zt(o)){var C="separator"in o?o.separator:C;l="length"in o?yt(o.length):l,E="omission"in o?vi(o.omission):E}s=Bt(s);var L=s.length;if(Ca(s)){var J=en(s);L=J.length}if(l>=L)return s;var X=l-Ta(E);if(X<1)return E;var ie=J?Is(J,0,X).join(""):s.slice(0,X);if(C===t)return ie+E;if(J&&(X+=ie.length-X),Ju(C)){if(s.slice(X).search(C)){var ue,de=ie;for(C.global||(C=uu(C.source,Bt(bt.exec(C))+"g")),C.lastIndex=0;ue=C.exec(de);)var ge=ue.index;ie=ie.slice(0,ge===t?X:ge)}}else if(s.indexOf(vi(C),X)!=X){var Pe=ie.lastIndexOf(C);Pe>-1&&(ie=ie.slice(0,Pe))}return ie+E}function X5(s){return s=Bt(s),s&&Fe.test(s)?s.replace(Et,Mm):s}var Z5=$a(function(s,o,l){return s+(l?" ":"")+o.toUpperCase()}),Xu=ip("toUpperCase");function t1(s,o,l){return s=Bt(s),o=l?t:o,o===t?Am(s)?Rm(s):dm(s):s.match(o)||[]}var r1=At(function(s,o){try{return br(s,t,o)}catch(l){return Wu(l)?l:new dt(l)}}),e4=Zn(function(s,o){return Pi(o,function(l){l=_n(l),Qn(s,l,Vu(s[l],s))}),s});function t4(s){var o=s==null?0:s.length,l=nt();return s=o?Xt(s,function(E){if(typeof E[1]!="function")throw new Oi(f);return[l(E[0]),E[1]]}):[],At(function(E){for(var C=-1;++CM)return[];var l=g,E=qr(s,g);o=nt(o),s-=g;for(var C=cu(E,o);++l0||o<0)?new Mt(l):(s<0?l=l.takeRight(-s):s&&(l=l.drop(s)),o!==t&&(o=yt(o),l=o<0?l.dropRight(-o):l.take(o-s)),l)},Mt.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},Mt.prototype.toArray=function(){return this.take(g)},yn(Mt.prototype,function(s,o){var l=/^(?:filter|find|map|reject)|While$/.test(o),E=/^(?:head|last)$/.test(o),C=D[E?"take"+(o=="last"?"Right":""):o],L=E||/^find/.test(o);C&&(D.prototype[o]=function(){var J=this.__wrapped__,X=E?[1]:arguments,ie=J instanceof Mt,ue=X[0],de=ie||gt(J),ge=function(xt){var Ct=C.apply(D,ws([xt],X));return E&&Pe?Ct[0]:Ct};de&&l&&typeof ue=="function"&&ue.length!=1&&(ie=de=!1);var Pe=this.__chain__,We=!!this.__actions__.length,ot=L&&!Pe,wt=ie&&!We;if(!L&&de){J=wt?J:new Mt(this);var ct=s.apply(J,X);return ct.__actions__.push({func:Of,args:[ge],thisArg:t}),new Ri(ct,Pe)}return ot&&wt?s.apply(this,X):(ct=this.thru(ge),ot?E?ct.value()[0]:ct.value():ct)})}),Pi(["pop","push","shift","sort","splice","unshift"],function(s){var o=ef[s],l=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",E=/^(?:pop|shift)$/.test(s);D.prototype[s]=function(){var C=arguments;if(E&&!this.__chain__){var L=this.value();return o.apply(gt(L)?L:[],C)}return this[l](function(J){return o.apply(gt(J)?J:[],C)})}}),yn(Mt.prototype,function(s,o){var l=D[o];if(l){var E=l.name+"";Lt.call(qa,E)||(qa[E]=[]),qa[E].push({name:o,func:l})}}),qa[Af(t,Q).name]=[{name:"wrapper",func:t}],Mt.prototype.clone=Xm,Mt.prototype.reverse=Zm,Mt.prototype.value=e6,D.prototype.at=O3,D.prototype.chain=R3,D.prototype.commit=N3,D.prototype.next=C3,D.prototype.plant=D3,D.prototype.reverse=F3,D.prototype.toJSON=D.prototype.valueOf=D.prototype.value=B3,D.prototype.first=D.prototype.head,Oo&&(D.prototype[Oo]=T3),D},Da=Nm();sr?((sr.exports=Da)._=Da,kt._=Da):Nt._=Da}).call(rc)})(A0,A0.exports);var tC=Object.defineProperty,rC=Object.defineProperties,iC=Object.getOwnPropertyDescriptors,_v=Object.getOwnPropertySymbols,nC=Object.prototype.hasOwnProperty,sC=Object.prototype.propertyIsEnumerable,Av=(r,e,t)=>e in r?tC(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Gf=(r,e)=>{for(var t in e||(e={}))nC.call(e,t)&&Av(r,t,e[t]);if(_v)for(var t of _v(e))sC.call(e,t)&&Av(r,t,e[t]);return r},aC=(r,e)=>rC(r,iC(e));function pn(r,e,t){var i;const n=ac(r);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${sm}?chainId=${n.namespace}:${n.reference}&projectId=${t}`}function Ia(r){return r.includes(":")?r.split(":")[1]:r}function am(r){return r.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function oC(r,e){const t=Object.keys(e.namespaces).filter(n=>n.includes(r));if(!t.length)return[];const i=[];return t.forEach(n=>{const a=e.namespaces[n].accounts;i.push(...a)}),i}function zl(r={},e={}){const t=Ev(r),i=Ev(e);return A0.exports.merge(t,i)}function Ev(r){var e,t,i,n;const a={};if(!bc(r))return a;for(const[f,u]of Object.entries(r)){const b=J0(f)?[f]:u.chains,p=u.methods||[],y=u.events||[],A=u.rpcMap||{},R=sc(f);a[R]=aC(Gf(Gf({},a[R]),u),{chains:Qf(b,(e=a[R])==null?void 0:e.chains),methods:Qf(p,(t=a[R])==null?void 0:t.methods),events:Qf(y,(i=a[R])==null?void 0:i.events),rpcMap:Gf(Gf({},A),(n=a[R])==null?void 0:n.rpcMap)})}return a}function cC(r){return r.includes(":")?r.split(":")[2]:r}function xv(r){const e={};for(const[t,i]of Object.entries(r)){const n=i.methods||[],a=i.events||[],f=i.accounts||[],u=J0(t)?[t]:i.chains?i.chains:am(i.accounts);e[t]={chains:u,methods:n,events:a,accounts:f}}return e}function jl(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):(r=r.includes(":")?r.split(":")[1]:r,isNaN(Number(r))?r:Number(r))}const om={},qt=r=>om[r],kl=(r,e)=>{om[r]=e};class fC{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||pn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new gn(new Gn(i,qt("disableProviderPing")))}}var hC=Object.defineProperty,uC=Object.defineProperties,lC=Object.getOwnPropertyDescriptors,Sv=Object.getOwnPropertySymbols,dC=Object.prototype.hasOwnProperty,pC=Object.prototype.propertyIsEnumerable,Iv=(r,e,t)=>e in r?hC(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Mv=(r,e)=>{for(var t in e||(e={}))dC.call(e,t)&&Iv(r,t,e[t]);if(Sv)for(var t of Sv(e))pC.call(e,t)&&Iv(r,t,e[t]);return r},Pv=(r,e)=>uC(r,lC(e));class gC{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const i=t||pn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new gn(new Gn(i,qt("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=parseInt(Ia(t));e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let n=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const a=parseInt(n,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:n}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,i,n;const a=(i=(t=e.request)==null?void 0:t.params)==null?void 0:i[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const f=this.client.session.get(e.topic),u=((n=f==null?void 0:f.sessionProperties)==null?void 0:n.capabilities)||{};if(u!=null&&u[a])return u==null?void 0:u[a];const b=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Pv(Mv({},f.sessionProperties||{}),{capabilities:Pv(Mv({},u||{}),{[a]:b})})})}catch(p){console.warn("Failed to update session with capabilities",p)}return b}async getCallStatus(e){var t,i;const n=this.client.session.get(e.topic),a=(t=n.sessionProperties)==null?void 0:t.bundler_name;if(a){const u=this.getBundlerUrl(e.chainId,a);try{return await this.getUserOperationReceipt(u,e)}catch(b){console.warn("Failed to fetch call status from bundler",b,u)}}const f=(i=n.sessionProperties)==null?void 0:i.bundler_url;if(f)try{return await this.getUserOperationReceipt(f,e)}catch(u){console.warn("Failed to fetch call status from custom bundler",u,f)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const n=new URL(e),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(qs("eth_getUserOperationReceipt",[(i=t.request.params)==null?void 0:i[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(e,t){return`${eC}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}class vC{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||pn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new gn(new Gn(i,qt("disableProviderPing")))}}class bC{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||pn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new gn(new Gn(i,qt("disableProviderPing")))}}class mC{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||pn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||pn(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new gn(new Gn(i,qt("disableProviderPing")))}}class yC{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),n=Ia(t);e[n]=this.createHttpProvider(n,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new gn(new Gn(i,qt("disableProviderPing")))}}class wC{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||pn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new gn(new Gn(i,qt("disableProviderPing")))}}class _C{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||pn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new gn(new Gn(i,qt("disableProviderPing")))}}class AC{constructor(e){this.name="near",this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||pn(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||pn(e,this.namespace);return typeof i>"u"?void 0:new gn(new Gn(i,qt("disableProviderPing")))}}class EC{constructor(e){this.name=Ya,this.namespace=e.namespace,this.events=qt("events"),this.client=qt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(n=>{const a=ac(n);i[`${a.namespace}:${a.reference}`]=this.createHttpProvider(n)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||pn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new gn(new Gn(i,qt("disableProviderPing")))}}var xC=Object.defineProperty,SC=Object.defineProperties,IC=Object.getOwnPropertyDescriptors,Ov=Object.getOwnPropertySymbols,MC=Object.prototype.hasOwnProperty,PC=Object.prototype.propertyIsEnumerable,Rv=(r,e,t)=>e in r?xC(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Wf=(r,e)=>{for(var t in e||(e={}))MC.call(e,t)&&Rv(r,t,e[t]);if(Ov)for(var t of Ov(e))PC.call(e,t)&&Rv(r,t,e[t]);return r},Hl=(r,e)=>SC(r,IC(e));class nd{constructor(e){this.events=new I0,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Nc(Hh({level:(e==null?void 0:e.logger)||yv})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new nd(e);return await t.initialize(),t}async request(e,t,i){const[n,a]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:Wf({},e),chainId:`${n}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,n){const a=new Date().getTime();this.request(e,i,n).then(f=>t(null,Kh(a,f))).catch(f=>t(f,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Ut("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:n}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const a=await n();if(this.session=a.session,this.session){const f=xv(this.session.namespaces);this.namespaces=zl(this.namespaces,f),this.persist("namespaces",this.namespaces),this.onConnect()}return a}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});i&&(this.uri=i,this.events.emit("display_uri",i)),await n().then(a=>{this.session=a;const f=xv(a.namespaces);this.namespaces=zl(this.namespaces,f),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==nm)throw a;t++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,n]=this.validateChain(e),a=this.getProvider(i);a.name===Ya?a.setDefaultChain(`${i}:${n}`,t):a.setDefaultChain(n,t)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(jn(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await id.init({core:this.providerOpts.core,logger:this.providerOpts.logger||yv,relayUrl:this.providerOpts.relayUrl||QN,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(t=>sc(t)))];kl("client",this.client),kl("events",this.events),kl("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const i=oC(t,this.session),n=am(i),a=zl(this.namespaces,this.optionalNamespaces),f=Hl(Wf({},a[t]),{accounts:i,chains:n});switch(t){case"eip155":this.rpcProviders[t]=new gC({namespace:f});break;case"algorand":this.rpcProviders[t]=new mC({namespace:f});break;case"solana":this.rpcProviders[t]=new vC({namespace:f});break;case"cosmos":this.rpcProviders[t]=new bC({namespace:f});break;case"polkadot":this.rpcProviders[t]=new fC({namespace:f});break;case"cip34":this.rpcProviders[t]=new yC({namespace:f});break;case"elrond":this.rpcProviders[t]=new wC({namespace:f});break;case"multiversx":this.rpcProviders[t]=new _C({namespace:f});break;case"near":this.rpcProviders[t]=new AC({namespace:f});break;default:this.rpcProviders[Ya]?this.rpcProviders[Ya].updateNamespace(f):this.rpcProviders[Ya]=new EC({namespace:f})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:i}=t;if(i.name==="accountsChanged"){const n=i.data;n&&jn(n)&&this.events.emit("accountsChanged",n.map(cC))}else if(i.name==="chainChanged"){const n=t.chainId,a=t.event.data,f=sc(n),u=jl(n)!==jl(a)?`${f}:${jl(a)}`:n;this.onChainChanged(u)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;const{namespaces:n}=t,a=(i=this.client)==null?void 0:i.session.get(e);this.session=Hl(Wf({},a),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Hl(Wf({},Ut("USER_DISCONNECTED")),{data:e.topic}))}),this.on(vn.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Ya]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:n}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=n,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(f=>sc(f)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const n=sc(Object.keys(this.namespaces)[0]),a=this.rpcProviders[n].getDefaultChain();return[n,a]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,n]=this.validateChain(e);n&&(t||this.getProvider(i).setDefaultChain(n),this.namespaces[i]?this.namespaces[i].defaultChain=n:this.namespaces[`${i}:${n}`]?this.namespaces[`${i}:${n}`].defaultChain=n:this.namespaces[`${i}:${n}`]={defaultChain:n},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${wv}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${wv}/${e}`)}}const OC=nd,RC="wc",NC="ethereum_provider",CC=`${RC}@2:${NC}:`,TC="https://rpc.walletconnect.org/v1/",E0=["eth_sendTransaction","personal_sign"],DC=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],x0=["chainChanged","accountsChanged"],FC=["chainChanged","accountsChanged","message","disconnect","connect"];var BC=Object.defineProperty,qC=Object.defineProperties,LC=Object.getOwnPropertyDescriptors,Nv=Object.getOwnPropertySymbols,UC=Object.prototype.hasOwnProperty,$C=Object.prototype.propertyIsEnumerable,Cv=(r,e,t)=>e in r?BC(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Qa=(r,e)=>{for(var t in e||(e={}))UC.call(e,t)&&Cv(r,t,e[t]);if(Nv)for(var t of Nv(e))$C.call(e,t)&&Cv(r,t,e[t]);return r},Kl=(r,e)=>qC(r,LC(e));function Eh(r){return Number(r[0].split(":")[1])}function Jf(r){return`0x${r.toString(16)}`}function zC(r){const{chains:e,optionalChains:t,methods:i,optionalMethods:n,events:a,optionalEvents:f,rpcMap:u}=r;if(!jn(e))throw new Error("Invalid chains");const b={chains:e,methods:i||E0,events:a||x0,rpcMap:Qa({},e.length?{[Eh(e)]:u[Eh(e)]}:{})},p=a==null?void 0:a.filter(O=>!x0.includes(O)),y=i==null?void 0:i.filter(O=>!E0.includes(O));if(!t&&!f&&!n&&!(p!=null&&p.length)&&!(y!=null&&y.length))return{required:e.length?b:void 0};const A=(p==null?void 0:p.length)&&(y==null?void 0:y.length)||!t,R={chains:[...new Set(A?b.chains.concat(t||[]):t)],methods:[...new Set(b.methods.concat(n!=null&&n.length?n:DC))],events:[...new Set(b.events.concat(f!=null&&f.length?f:FC))],rpcMap:u};return{required:e.length?b:void 0,optional:t.length?R:void 0}}class sd{constructor(){this.events=new Hi.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=CC,this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new sd;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,i){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),i)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:t,optional:i}=zC(this.rpc);try{const n=await new Promise(async(f,u)=>{var b;this.rpc.showQrModal&&((b=this.modal)==null||b.subscribeModal(p=>{!p.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),u(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Kl(Qa({namespaces:Qa({},t&&{[this.namespace]:t})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(p=>{f(p)}).catch(p=>{u(new Error(p.message))})});if(!n)return;const a=T1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Jf(this.chainId)})}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(a,f)=>{var u;this.rpc.showQrModal&&((u=this.modal)==null||u.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Kl(Qa({},e),{chains:this.rpc.chains}),t).then(b=>{a(b)}).catch(b=>{f(new Error(b.message))})}),n=i.session;if(n){const a=T1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Jf(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:t}=e,{event:i}=t;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",Jf(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",Kl(Qa({},Ut("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,i;this.rpc.showQrModal&&((t=this.modal)==null||t.closeModal(),(i=this.modal)==null||i.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",Jf(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,i,n]=e.split(":");return{chainId:`${t}:${i}`,address:n}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,i;const n=(t=e==null?void 0:e.chains)!=null?t:[],a=(i=e==null?void 0:e.optionalChains)!=null?i:[],f=n.concat(a);if(!f.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const u=n.length?(e==null?void 0:e.methods)||E0:[],b=n.length?(e==null?void 0:e.events)||x0:[],p=(e==null?void 0:e.optionalMethods)||[],y=(e==null?void 0:e.optionalEvents)||[],A=(e==null?void 0:e.rpcMap)||this.buildRpcMap(f,e.projectId),R=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:n==null?void 0:n.map(O=>this.formatChainId(O)),optionalChains:a.map(O=>this.formatChainId(O)),methods:u,events:b,optionalMethods:p,optionalEvents:y,rpcMap:A,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:R,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const i={};return e.forEach(n=>{i[n]=this.getRpcUrl(n,t)}),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Eh(this.rpc.chains):Eh(this.rpc.optionalChains),this.signer=await OC.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let t;try{const{WalletConnectModal:i}=await j4(()=>import("./index-Vk_Kr0Nw.js").then(n=>n.i),__vite__mapDeps([0,1,2]));t=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(Qa({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:i,rpcMap:n}=e;t&&jn(t)&&(this.rpc.chains=t.map(a=>this.formatChainId(a)),t.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)})),i&&jn(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i==null?void 0:i.map(a=>this.formatChainId(a)),i.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)}))}getRpcUrl(e,t){var i;return((i=this.rpc.rpcMap)==null?void 0:i[e])||`${TC}?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t==null?void 0:t.accounts),this.setAccounts(t==null?void 0:t.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(t=>this.signer.logger.warn(t))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(t=>this.parseAccount(t))}}const dT=sd;export{dT as EthereumProvider,FC as OPTIONAL_EVENTS,DC as OPTIONAL_METHODS,x0 as REQUIRED_EVENTS,E0 as REQUIRED_METHODS,sd as default}; diff --git a/buddybook/assets/index.es-pymM7oJc.js b/buddybook/assets/index.es-pymM7oJc.js new file mode 100644 index 0000000..0f88f27 --- /dev/null +++ b/buddybook/assets/index.es-pymM7oJc.js @@ -0,0 +1,70 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-1C-dIFy4.js","assets/index-mI-wCQlz.js","assets/index-Dt_CGZqf.css"])))=>i.map(i=>d[i]); +import{g as Cv,o as z8,p as j8,d as Dv,q as Ar,r as k8,h as Sd,_ as F8}from"./index-mI-wCQlz.js";import{e as Fi,J as Id}from"./events-_Z2_TJp5.js";import{r as Md,i as xh}from"./inherits_browser-DVmoQh9i.js";var xe={};/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var Vl=function(r,e){return Vl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},Vl(r,e)};function H8(r,e){Vl(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var Gl=function(){return Gl=Object.assign||function(e){for(var t,i=1,n=arguments.length;i=0;u--)(f=r[u])&&(a=(n<3?f(a):n>3?f(e,t,a):f(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a}function G8(r,e){return function(t,i){e(t,i,r)}}function W8(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function J8(r,e,t,i){function n(a){return a instanceof t?a:new t(function(f){f(a)})}return new(t||(t=Promise))(function(a,f){function u(y){try{p(i.next(y))}catch(A){f(A)}}function b(y){try{p(i.throw(y))}catch(A){f(A)}}function p(y){y.done?a(y.value):n(y.value).then(u,b)}p((i=i.apply(r,e||[])).next())})}function Y8(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,f;return f={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function u(p){return function(y){return b([p,y])}}function b(p){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(a=p[0]&2?n.return:p[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,p[1])).done)return a;switch(n=0,a&&(p=[p[0]&2,a.value]),p[0]){case 0:case 1:a=p;break;case 4:return t.label++,{value:p[1],done:!1};case 5:t.label++,n=p[1],p=[0];continue;case 7:p=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(p[0]===6||p[0]===2)){t=0;continue}if(p[0]===3&&(!a||p[1]>a[0]&&p[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Lv(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,a=[],f;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(u){f={error:u}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(f)throw f.error}}return a}function Z8(){for(var r=[],e=0;e1||u(R,O)})})}function u(R,O){try{b(i[R](O))}catch(N){A(a[0][3],N)}}function b(R){R.value instanceof lc?Promise.resolve(R.value.v).then(p,y):A(a[0][2],R)}function p(R){u("next",R)}function y(R){u("throw",R)}function A(R,O){R(O),a.shift(),a.length&&u(a[0][0],a[0][1])}}function r4(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,a){e[n]=r[n]?function(f){return(t=!t)?{value:lc(r[n](f)),done:n==="return"}:a?a(f):f}:a}}function i4(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Wl=="function"?Wl(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(a){t[a]=r[a]&&function(f){return new Promise(function(u,b){f=r[a](f),n(u,b,f.done,f.value)})}}function n(a,f,u,b){Promise.resolve(b).then(function(p){a({value:p,done:u})},f)}}function n4(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function s4(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function a4(r){return r&&r.__esModule?r:{default:r}}function o4(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function c4(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}const f4=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Gl},__asyncDelegator:r4,__asyncGenerator:t4,__asyncValues:i4,__await:lc,__awaiter:J8,__classPrivateFieldGet:o4,__classPrivateFieldSet:c4,__createBinding:Q8,__decorate:V8,__exportStar:X8,__extends:H8,__generator:Y8,__importDefault:a4,__importStar:s4,__makeTemplateObject:n4,__metadata:W8,__param:G8,__read:Lv,__rest:K8,__spread:Z8,__spreadArrays:e4,__values:Wl},Symbol.toStringTag,{value:"Module"})),Sh=Cv(f4);var sl={},Fo={},s1;function h4(){if(s1)return Fo;s1=1,Object.defineProperty(Fo,"__esModule",{value:!0}),Fo.delay=void 0;function r(e){return new Promise(t=>{setTimeout(()=>{t(!0)},e)})}return Fo.delay=r,Fo}var ta={},al={},ra={},a1;function u4(){return a1||(a1=1,Object.defineProperty(ra,"__esModule",{value:!0}),ra.ONE_THOUSAND=ra.ONE_HUNDRED=void 0,ra.ONE_HUNDRED=100,ra.ONE_THOUSAND=1e3),ra}var ol={},o1;function l4(){return o1||(o1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ONE_YEAR=r.FOUR_WEEKS=r.THREE_WEEKS=r.TWO_WEEKS=r.ONE_WEEK=r.THIRTY_DAYS=r.SEVEN_DAYS=r.FIVE_DAYS=r.THREE_DAYS=r.ONE_DAY=r.TWENTY_FOUR_HOURS=r.TWELVE_HOURS=r.SIX_HOURS=r.THREE_HOURS=r.ONE_HOUR=r.SIXTY_MINUTES=r.THIRTY_MINUTES=r.TEN_MINUTES=r.FIVE_MINUTES=r.ONE_MINUTE=r.SIXTY_SECONDS=r.THIRTY_SECONDS=r.TEN_SECONDS=r.FIVE_SECONDS=r.ONE_SECOND=void 0,r.ONE_SECOND=1,r.FIVE_SECONDS=5,r.TEN_SECONDS=10,r.THIRTY_SECONDS=30,r.SIXTY_SECONDS=60,r.ONE_MINUTE=r.SIXTY_SECONDS,r.FIVE_MINUTES=r.ONE_MINUTE*5,r.TEN_MINUTES=r.ONE_MINUTE*10,r.THIRTY_MINUTES=r.ONE_MINUTE*30,r.SIXTY_MINUTES=r.ONE_MINUTE*60,r.ONE_HOUR=r.SIXTY_MINUTES,r.THREE_HOURS=r.ONE_HOUR*3,r.SIX_HOURS=r.ONE_HOUR*6,r.TWELVE_HOURS=r.ONE_HOUR*12,r.TWENTY_FOUR_HOURS=r.ONE_HOUR*24,r.ONE_DAY=r.TWENTY_FOUR_HOURS,r.THREE_DAYS=r.ONE_DAY*3,r.FIVE_DAYS=r.ONE_DAY*5,r.SEVEN_DAYS=r.ONE_DAY*7,r.THIRTY_DAYS=r.ONE_DAY*30,r.ONE_WEEK=r.SEVEN_DAYS,r.TWO_WEEKS=r.ONE_WEEK*2,r.THREE_WEEKS=r.ONE_WEEK*3,r.FOUR_WEEKS=r.ONE_WEEK*4,r.ONE_YEAR=r.ONE_DAY*365}(ol)),ol}var c1;function qv(){return c1||(c1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Sh;e.__exportStar(u4(),r),e.__exportStar(l4(),r)}(al)),al}var f1;function d4(){if(f1)return ta;f1=1,Object.defineProperty(ta,"__esModule",{value:!0}),ta.fromMiliseconds=ta.toMiliseconds=void 0;const r=qv();function e(i){return i*r.ONE_THOUSAND}ta.toMiliseconds=e;function t(i){return Math.floor(i/r.ONE_THOUSAND)}return ta.fromMiliseconds=t,ta}var h1;function p4(){return h1||(h1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Sh;e.__exportStar(h4(),r),e.__exportStar(d4(),r)}(sl)),sl}var Ha={},u1;function g4(){if(u1)return Ha;u1=1,Object.defineProperty(Ha,"__esModule",{value:!0}),Ha.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(t){if(this.timestamps.has(t))throw new Error(`Watch already started for label: ${t}`);this.timestamps.set(t,{started:Date.now()})}stop(t){const i=this.get(t);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${t}`);const n=Date.now()-i.started;this.timestamps.set(t,{started:i.started,elapsed:n})}get(t){const i=this.timestamps.get(t);if(typeof i>"u")throw new Error(`No timestamp found for label: ${t}`);return i}elapsed(t){const i=this.get(t);return i.elapsed||Date.now()-i.started}}return Ha.Watch=r,Ha.default=r,Ha}var cl={},Ho={},l1;function v4(){if(l1)return Ho;l1=1,Object.defineProperty(Ho,"__esModule",{value:!0}),Ho.IWatch=void 0;class r{}return Ho.IWatch=r,Ho}var d1;function b4(){return d1||(d1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),Sh.__exportStar(v4(),r)}(cl)),cl}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Sh;e.__exportStar(p4(),r),e.__exportStar(g4(),r),e.__exportStar(b4(),r),e.__exportStar(qv(),r)})(xe);var Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.getLocalStorage=Vt.getLocalStorageOrThrow=Vt.getCrypto=Vt.getCryptoOrThrow=Bv=Vt.getLocation=Vt.getLocationOrThrow=Pd=Vt.getNavigator=Vt.getNavigatorOrThrow=Ih=Vt.getDocument=Vt.getDocumentOrThrow=Vt.getFromWindowOrThrow=Vt.getFromWindow=void 0;function ma(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Vt.getFromWindow=ma;function co(r){const e=ma(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Vt.getFromWindowOrThrow=co;function m4(){return co("document")}Vt.getDocumentOrThrow=m4;function y4(){return ma("document")}var Ih=Vt.getDocument=y4;function w4(){return co("navigator")}Vt.getNavigatorOrThrow=w4;function _4(){return ma("navigator")}var Pd=Vt.getNavigator=_4;function A4(){return co("location")}Vt.getLocationOrThrow=A4;function E4(){return ma("location")}var Bv=Vt.getLocation=E4;function x4(){return co("crypto")}Vt.getCryptoOrThrow=x4;function S4(){return ma("crypto")}Vt.getCrypto=S4;function I4(){return co("localStorage")}Vt.getLocalStorageOrThrow=I4;function M4(){return ma("localStorage")}Vt.getLocalStorage=M4;var Od={};Object.defineProperty(Od,"__esModule",{value:!0});var Uv=Od.getWindowMetadata=void 0;const p1=Vt;function P4(){let r,e;try{r=p1.getDocumentOrThrow(),e=p1.getLocationOrThrow()}catch{return null}function t(){const A=r.getElementsByTagName("link"),R=[];for(let O=0;O-1){const W=N.getAttribute("href");if(W)if(W.toLowerCase().indexOf("https:")===-1&&W.toLowerCase().indexOf("http:")===-1&&W.indexOf("//")!==0){let Q=e.protocol+"//"+e.host;if(W.indexOf("/")===0)Q+=W;else{const k=e.pathname.split("/");k.pop();const Y=k.join("/");Q+=Y+"/"+W}R.push(Q)}else if(W.indexOf("//")===0){const Q=e.protocol+W;R.push(Q)}else R.push(W)}}return R}function i(...A){const R=r.getElementsByTagName("meta");for(let O=0;ON.getAttribute(W)).filter(W=>W?A.includes(W):!1);if(K.length&&K){const W=N.getAttribute("content");if(W)return W}}return""}function n(){let A=i("name","og:site_name","og:title","twitter:title");return A||(A=r.title),A}function a(){return i("description","og:description","twitter:description","keywords")}const f=n(),u=a(),b=e.origin,p=t();return{description:u,url:b,icons:p,name:f}}Uv=Od.getWindowMetadata=P4;var dc={},O4=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),$v="%[a-f0-9]{2}",g1=new RegExp("("+$v+")|([^%]+?)","gi"),v1=new RegExp("("+$v+")+","gi");function Jl(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],Jl(t),Jl(i))}function R4(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(g1)||[],t=1;t{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];const t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]},D4=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),a=0;ak==null,f=Symbol("encodeFragmentIdentifier");function u(k){switch(k.arrayFormat){case"index":return Y=>($,F)=>{const G=$.length;return F===void 0||k.skipNull&&F===null||k.skipEmptyString&&F===""?$:F===null?[...$,[y(Y,k),"[",G,"]"].join("")]:[...$,[y(Y,k),"[",y(G,k),"]=",y(F,k)].join("")]};case"bracket":return Y=>($,F)=>F===void 0||k.skipNull&&F===null||k.skipEmptyString&&F===""?$:F===null?[...$,[y(Y,k),"[]"].join("")]:[...$,[y(Y,k),"[]=",y(F,k)].join("")];case"colon-list-separator":return Y=>($,F)=>F===void 0||k.skipNull&&F===null||k.skipEmptyString&&F===""?$:F===null?[...$,[y(Y,k),":list="].join("")]:[...$,[y(Y,k),":list=",y(F,k)].join("")];case"comma":case"separator":case"bracket-separator":{const Y=k.arrayFormat==="bracket-separator"?"[]=":"=";return $=>(F,G)=>G===void 0||k.skipNull&&G===null||k.skipEmptyString&&G===""?F:(G=G===null?"":G,F.length===0?[[y($,k),Y,y(G,k)].join("")]:[[F,y(G,k)].join(k.arrayFormatSeparator)])}default:return Y=>($,F)=>F===void 0||k.skipNull&&F===null||k.skipEmptyString&&F===""?$:F===null?[...$,y(Y,k)]:[...$,[y(Y,k),"=",y(F,k)].join("")]}}function b(k){let Y;switch(k.arrayFormat){case"index":return($,F,G)=>{if(Y=/\[(\d*)\]$/.exec($),$=$.replace(/\[\d*\]$/,""),!Y){G[$]=F;return}G[$]===void 0&&(G[$]={}),G[$][Y[1]]=F};case"bracket":return($,F,G)=>{if(Y=/(\[\])$/.exec($),$=$.replace(/\[\]$/,""),!Y){G[$]=F;return}if(G[$]===void 0){G[$]=[F];return}G[$]=[].concat(G[$],F)};case"colon-list-separator":return($,F,G)=>{if(Y=/(:list)$/.exec($),$=$.replace(/:list$/,""),!Y){G[$]=F;return}if(G[$]===void 0){G[$]=[F];return}G[$]=[].concat(G[$],F)};case"comma":case"separator":return($,F,G)=>{const x=typeof F=="string"&&F.includes(k.arrayFormatSeparator),q=typeof F=="string"&&!x&&A(F,k).includes(k.arrayFormatSeparator);F=q?A(F,k):F;const ae=x||q?F.split(k.arrayFormatSeparator).map(le=>A(le,k)):F===null?F:A(F,k);G[$]=ae};case"bracket-separator":return($,F,G)=>{const x=/(\[\])$/.test($);if($=$.replace(/\[\]$/,""),!x){G[$]=F&&A(F,k);return}const q=F===null?[]:F.split(k.arrayFormatSeparator).map(ae=>A(ae,k));if(G[$]===void 0){G[$]=q;return}G[$]=[].concat(G[$],q)};default:return($,F,G)=>{if(G[$]===void 0){G[$]=F;return}G[$]=[].concat(G[$],F)}}}function p(k){if(typeof k!="string"||k.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function y(k,Y){return Y.encode?Y.strict?e(k):encodeURIComponent(k):k}function A(k,Y){return Y.decode?t(k):k}function R(k){return Array.isArray(k)?k.sort():typeof k=="object"?R(Object.keys(k)).sort((Y,$)=>Number(Y)-Number($)).map(Y=>k[Y]):k}function O(k){const Y=k.indexOf("#");return Y!==-1&&(k=k.slice(0,Y)),k}function N(k){let Y="";const $=k.indexOf("#");return $!==-1&&(Y=k.slice($)),Y}function K(k){k=O(k);const Y=k.indexOf("?");return Y===-1?"":k.slice(Y+1)}function W(k,Y){return Y.parseNumbers&&!Number.isNaN(Number(k))&&typeof k=="string"&&k.trim()!==""?k=Number(k):Y.parseBooleans&&k!==null&&(k.toLowerCase()==="true"||k.toLowerCase()==="false")&&(k=k.toLowerCase()==="true"),k}function Q(k,Y){Y=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},Y),p(Y.arrayFormatSeparator);const $=b(Y),F=Object.create(null);if(typeof k!="string"||(k=k.trim().replace(/^[?#&]/,""),!k))return F;for(const G of k.split("&")){if(G==="")continue;let[x,q]=i(Y.decode?G.replace(/\+/g," "):G,"=");q=q===void 0?null:["comma","separator","bracket-separator"].includes(Y.arrayFormat)?q:A(q,Y),$(A(x,Y),q,F)}for(const G of Object.keys(F)){const x=F[G];if(typeof x=="object"&&x!==null)for(const q of Object.keys(x))x[q]=W(x[q],Y);else F[G]=W(x,Y)}return Y.sort===!1?F:(Y.sort===!0?Object.keys(F).sort():Object.keys(F).sort(Y.sort)).reduce((G,x)=>{const q=F[x];return q&&typeof q=="object"&&!Array.isArray(q)?G[x]=R(q):G[x]=q,G},Object.create(null))}r.extract=K,r.parse=Q,r.stringify=(k,Y)=>{if(!k)return"";Y=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},Y),p(Y.arrayFormatSeparator);const $=q=>Y.skipNull&&a(k[q])||Y.skipEmptyString&&k[q]==="",F=u(Y),G={};for(const q of Object.keys(k))$(q)||(G[q]=k[q]);const x=Object.keys(G);return Y.sort!==!1&&x.sort(Y.sort),x.map(q=>{const ae=k[q];return ae===void 0?"":ae===null?y(q,Y):Array.isArray(ae)?ae.length===0&&Y.arrayFormat==="bracket-separator"?y(q,Y)+"[]":ae.reduce(F(q),[]).join("&"):y(q,Y)+"="+y(ae,Y)}).filter(q=>q.length>0).join("&")},r.parseUrl=(k,Y)=>{Y=Object.assign({decode:!0},Y);const[$,F]=i(k,"#");return Object.assign({url:$.split("?")[0]||"",query:Q(K(k),Y)},Y&&Y.parseFragmentIdentifier&&F?{fragmentIdentifier:A(F,Y)}:{})},r.stringifyUrl=(k,Y)=>{Y=Object.assign({encode:!0,strict:!0,[f]:!0},Y);const $=O(k.url).split("?")[0]||"",F=r.extract(k.url),G=r.parse(F,{sort:!1}),x=Object.assign(G,k.query);let q=r.stringify(x,Y);q&&(q=`?${q}`);let ae=N(k.url);return k.fragmentIdentifier&&(ae=`#${Y[f]?y(k.fragmentIdentifier,Y):k.fragmentIdentifier}`),`${$}${q}${ae}`},r.pick=(k,Y,$)=>{$=Object.assign({parseFragmentIdentifier:!0,[f]:!1},$);const{url:F,query:G,fragmentIdentifier:x}=r.parseUrl(k,$);return r.stringifyUrl({url:F,query:n(G,Y),fragmentIdentifier:x},$)},r.exclude=(k,Y,$)=>{const F=Array.isArray(Y)?G=>!Y.includes(G):(G,x)=>!Y(G,x);return r.pick(k,F,$)}})(dc);var Rd={},Mh={},mt={},zv={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});function e(u,b){var p=u>>>16&65535,y=u&65535,A=b>>>16&65535,R=b&65535;return y*R+(p*R+y*A<<16>>>0)|0}r.mul=Math.imul||e;function t(u,b){return u+b|0}r.add=t;function i(u,b){return u-b|0}r.sub=i;function n(u,b){return u<>>32-b}r.rotl=n;function a(u,b){return u<<32-b|u>>>b}r.rotr=a;function f(u){return typeof u=="number"&&isFinite(u)&&Math.floor(u)===u}r.isInteger=Number.isInteger||f,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(u){return r.isInteger(u)&&u>=-r.MAX_SAFE_INTEGER&&u<=r.MAX_SAFE_INTEGER}})(zv);Object.defineProperty(mt,"__esModule",{value:!0});var jv=zv;function L4(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}mt.readInt16BE=L4;function q4(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}mt.readUint16BE=q4;function B4(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}mt.readInt16LE=B4;function U4(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}mt.readUint16LE=U4;function kv(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}mt.writeUint16BE=kv;mt.writeInt16BE=kv;function Fv(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}mt.writeUint16LE=Fv;mt.writeInt16LE=Fv;function Yl(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}mt.readInt32BE=Yl;function Ql(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}mt.readUint32BE=Ql;function Xl(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}mt.readInt32LE=Xl;function Zl(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}mt.readUint32LE=Zl;function ah(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}mt.writeUint32BE=ah;mt.writeInt32BE=ah;function oh(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}mt.writeUint32LE=oh;mt.writeInt32LE=oh;function $4(r,e){e===void 0&&(e=0);var t=Yl(r,e),i=Yl(r,e+4);return t*4294967296+i-(i>>31)*4294967296}mt.readInt64BE=$4;function z4(r,e){e===void 0&&(e=0);var t=Ql(r,e),i=Ql(r,e+4);return t*4294967296+i}mt.readUint64BE=z4;function j4(r,e){e===void 0&&(e=0);var t=Xl(r,e),i=Xl(r,e+4);return i*4294967296+t-(t>>31)*4294967296}mt.readInt64LE=j4;function k4(r,e){e===void 0&&(e=0);var t=Zl(r,e),i=Zl(r,e+4);return i*4294967296+t}mt.readUint64LE=k4;function Hv(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),ah(r/4294967296>>>0,e,t),ah(r>>>0,e,t+4),e}mt.writeUint64BE=Hv;mt.writeInt64BE=Hv;function Kv(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),oh(r>>>0,e,t),oh(r/4294967296>>>0,e,t+4),e}mt.writeUint64LE=Kv;mt.writeInt64LE=Kv;function F4(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,a=r/8+t-1;a>=t;a--)i+=e[a]*n,n*=256;return i}mt.readUintBE=F4;function H4(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,a=t;a=i;a--)t[a]=e/n&255,n*=256;return t}mt.writeUintBE=K4;function V4(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!jv.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,a=i;a>>16|v<<16,L=L+v|0,x^=L,x=x>>>20|x<<12,$=$+q|0,_^=$,_=_>>>16|_<<16,m=m+_|0,q^=m,q=q>>>20|q<<12,F=F+ae|0,I^=F,I=I>>>16|I<<16,c=c+I|0,ae^=c,ae=ae>>>20|ae<<12,G=G+le|0,M^=G,M=M>>>16|M<<16,h=h+M|0,le^=h,le=le>>>20|le<<12,F=F+ae|0,I^=F,I=I>>>24|I<<8,c=c+I|0,ae^=c,ae=ae>>>25|ae<<7,G=G+le|0,M^=G,M=M>>>24|M<<8,h=h+M|0,le^=h,le=le>>>25|le<<7,$=$+q|0,_^=$,_=_>>>24|_<<8,m=m+_|0,q^=m,q=q>>>25|q<<7,Y=Y+x|0,v^=Y,v=v>>>24|v<<8,L=L+v|0,x^=L,x=x>>>25|x<<7,Y=Y+q|0,M^=Y,M=M>>>16|M<<16,c=c+M|0,q^=c,q=q>>>20|q<<12,$=$+ae|0,v^=$,v=v>>>16|v<<16,h=h+v|0,ae^=h,ae=ae>>>20|ae<<12,F=F+le|0,_^=F,_=_>>>16|_<<16,L=L+_|0,le^=L,le=le>>>20|le<<12,G=G+x|0,I^=G,I=I>>>16|I<<16,m=m+I|0,x^=m,x=x>>>20|x<<12,F=F+le|0,_^=F,_=_>>>24|_<<8,L=L+_|0,le^=L,le=le>>>25|le<<7,G=G+x|0,I^=G,I=I>>>24|I<<8,m=m+I|0,x^=m,x=x>>>25|x<<7,$=$+ae|0,v^=$,v=v>>>24|v<<8,h=h+v|0,ae^=h,ae=ae>>>25|ae<<7,Y=Y+q|0,M^=Y,M=M>>>24|M<<8,c=c+M|0,q^=c,q=q>>>25|q<<7;$r.writeUint32LE(Y+i|0,r,0),$r.writeUint32LE($+n|0,r,4),$r.writeUint32LE(F+a|0,r,8),$r.writeUint32LE(G+f|0,r,12),$r.writeUint32LE(x+u|0,r,16),$r.writeUint32LE(q+b|0,r,20),$r.writeUint32LE(ae+p|0,r,24),$r.writeUint32LE(le+y|0,r,28),$r.writeUint32LE(L+A|0,r,32),$r.writeUint32LE(m+R|0,r,36),$r.writeUint32LE(c+O|0,r,40),$r.writeUint32LE(h+N|0,r,44),$r.writeUint32LE(v+K|0,r,48),$r.writeUint32LE(_+W|0,r,52),$r.writeUint32LE(I+Q|0,r,56),$r.writeUint32LE(M+k|0,r,60)}function Vv(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var Gv={},Us={};Object.defineProperty(Us,"__esModule",{value:!0});function a_(r,e,t){return~(r-1)&e|r-1&t}Us.select=a_;function o_(r,e){return(r|0)-(e|0)-1>>>31&1}Us.lessOrEqual=o_;function Wv(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}Us.compare=Wv;function c_(r,e){return r.length===0||e.length===0?!1:Wv(r,e)!==0}Us.equal=c_;(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=Us,t=Ei;r.DIGEST_LENGTH=16;var i=function(){function f(u){this.digestLength=r.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var b=u[0]|u[1]<<8;this._r[0]=b&8191;var p=u[2]|u[3]<<8;this._r[1]=(b>>>13|p<<3)&8191;var y=u[4]|u[5]<<8;this._r[2]=(p>>>10|y<<6)&7939;var A=u[6]|u[7]<<8;this._r[3]=(y>>>7|A<<9)&8191;var R=u[8]|u[9]<<8;this._r[4]=(A>>>4|R<<12)&255,this._r[5]=R>>>1&8190;var O=u[10]|u[11]<<8;this._r[6]=(R>>>14|O<<2)&8191;var N=u[12]|u[13]<<8;this._r[7]=(O>>>11|N<<5)&8065;var K=u[14]|u[15]<<8;this._r[8]=(N>>>8|K<<8)&8191,this._r[9]=K>>>5&127,this._pad[0]=u[16]|u[17]<<8,this._pad[1]=u[18]|u[19]<<8,this._pad[2]=u[20]|u[21]<<8,this._pad[3]=u[22]|u[23]<<8,this._pad[4]=u[24]|u[25]<<8,this._pad[5]=u[26]|u[27]<<8,this._pad[6]=u[28]|u[29]<<8,this._pad[7]=u[30]|u[31]<<8}return f.prototype._blocks=function(u,b,p){for(var y=this._fin?0:2048,A=this._h[0],R=this._h[1],O=this._h[2],N=this._h[3],K=this._h[4],W=this._h[5],Q=this._h[6],k=this._h[7],Y=this._h[8],$=this._h[9],F=this._r[0],G=this._r[1],x=this._r[2],q=this._r[3],ae=this._r[4],le=this._r[5],L=this._r[6],m=this._r[7],c=this._r[8],h=this._r[9];p>=16;){var v=u[b+0]|u[b+1]<<8;A+=v&8191;var _=u[b+2]|u[b+3]<<8;R+=(v>>>13|_<<3)&8191;var I=u[b+4]|u[b+5]<<8;O+=(_>>>10|I<<6)&8191;var M=u[b+6]|u[b+7]<<8;N+=(I>>>7|M<<9)&8191;var S=u[b+8]|u[b+9]<<8;K+=(M>>>4|S<<12)&8191,W+=S>>>1&8191;var d=u[b+10]|u[b+11]<<8;Q+=(S>>>14|d<<2)&8191;var g=u[b+12]|u[b+13]<<8;k+=(d>>>11|g<<5)&8191;var C=u[b+14]|u[b+15]<<8;Y+=(g>>>8|C<<8)&8191,$+=C>>>5|y;var Z=0,se=Z;se+=A*F,se+=R*(5*h),se+=O*(5*c),se+=N*(5*m),se+=K*(5*L),Z=se>>>13,se&=8191,se+=W*(5*le),se+=Q*(5*ae),se+=k*(5*q),se+=Y*(5*x),se+=$*(5*G),Z+=se>>>13,se&=8191;var P=Z;P+=A*G,P+=R*F,P+=O*(5*h),P+=N*(5*c),P+=K*(5*m),Z=P>>>13,P&=8191,P+=W*(5*L),P+=Q*(5*le),P+=k*(5*ae),P+=Y*(5*q),P+=$*(5*x),Z+=P>>>13,P&=8191;var ee=Z;ee+=A*x,ee+=R*G,ee+=O*F,ee+=N*(5*h),ee+=K*(5*c),Z=ee>>>13,ee&=8191,ee+=W*(5*m),ee+=Q*(5*L),ee+=k*(5*le),ee+=Y*(5*ae),ee+=$*(5*q),Z+=ee>>>13,ee&=8191;var B=Z;B+=A*q,B+=R*x,B+=O*G,B+=N*F,B+=K*(5*h),Z=B>>>13,B&=8191,B+=W*(5*c),B+=Q*(5*m),B+=k*(5*L),B+=Y*(5*le),B+=$*(5*ae),Z+=B>>>13,B&=8191;var j=Z;j+=A*ae,j+=R*q,j+=O*x,j+=N*G,j+=K*F,Z=j>>>13,j&=8191,j+=W*(5*h),j+=Q*(5*c),j+=k*(5*m),j+=Y*(5*L),j+=$*(5*le),Z+=j>>>13,j&=8191;var H=Z;H+=A*le,H+=R*ae,H+=O*q,H+=N*x,H+=K*G,Z=H>>>13,H&=8191,H+=W*F,H+=Q*(5*h),H+=k*(5*c),H+=Y*(5*m),H+=$*(5*L),Z+=H>>>13,H&=8191;var w=Z;w+=A*L,w+=R*le,w+=O*ae,w+=N*q,w+=K*x,Z=w>>>13,w&=8191,w+=W*G,w+=Q*F,w+=k*(5*h),w+=Y*(5*c),w+=$*(5*m),Z+=w>>>13,w&=8191;var z=Z;z+=A*m,z+=R*L,z+=O*le,z+=N*ae,z+=K*q,Z=z>>>13,z&=8191,z+=W*x,z+=Q*G,z+=k*F,z+=Y*(5*h),z+=$*(5*c),Z+=z>>>13,z&=8191;var ne=Z;ne+=A*c,ne+=R*m,ne+=O*L,ne+=N*le,ne+=K*ae,Z=ne>>>13,ne&=8191,ne+=W*q,ne+=Q*x,ne+=k*G,ne+=Y*F,ne+=$*(5*h),Z+=ne>>>13,ne&=8191;var ce=Z;ce+=A*h,ce+=R*c,ce+=O*m,ce+=N*L,ce+=K*le,Z=ce>>>13,ce&=8191,ce+=W*ae,ce+=Q*q,ce+=k*x,ce+=Y*G,ce+=$*F,Z+=ce>>>13,ce&=8191,Z=(Z<<2)+Z|0,Z=Z+se|0,se=Z&8191,Z=Z>>>13,P+=Z,A=se,R=P,O=ee,N=B,K=j,W=H,Q=w,k=z,Y=ne,$=ce,b+=16,p-=16}this._h[0]=A,this._h[1]=R,this._h[2]=O,this._h[3]=N,this._h[4]=K,this._h[5]=W,this._h[6]=Q,this._h[7]=k,this._h[8]=Y,this._h[9]=$},f.prototype.finish=function(u,b){b===void 0&&(b=0);var p=new Uint16Array(10),y,A,R,O;if(this._leftover){for(O=this._leftover,this._buffer[O++]=1;O<16;O++)this._buffer[O]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(y=this._h[1]>>>13,this._h[1]&=8191,O=2;O<10;O++)this._h[O]+=y,y=this._h[O]>>>13,this._h[O]&=8191;for(this._h[0]+=y*5,y=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=y,y=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=y,p[0]=this._h[0]+5,y=p[0]>>>13,p[0]&=8191,O=1;O<10;O++)p[O]=this._h[O]+y,y=p[O]>>>13,p[O]&=8191;for(p[9]-=8192,A=(y^1)-1,O=0;O<10;O++)p[O]&=A;for(A=~A,O=0;O<10;O++)this._h[O]=this._h[O]&A|p[O];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,R=this._h[0]+this._pad[0],this._h[0]=R&65535,O=1;O<8;O++)R=(this._h[O]+this._pad[O]|0)+(R>>>16)|0,this._h[O]=R&65535;return u[b+0]=this._h[0]>>>0,u[b+1]=this._h[0]>>>8,u[b+2]=this._h[1]>>>0,u[b+3]=this._h[1]>>>8,u[b+4]=this._h[2]>>>0,u[b+5]=this._h[2]>>>8,u[b+6]=this._h[3]>>>0,u[b+7]=this._h[3]>>>8,u[b+8]=this._h[4]>>>0,u[b+9]=this._h[4]>>>8,u[b+10]=this._h[5]>>>0,u[b+11]=this._h[5]>>>8,u[b+12]=this._h[6]>>>0,u[b+13]=this._h[6]>>>8,u[b+14]=this._h[7]>>>0,u[b+15]=this._h[7]>>>8,this._finished=!0,this},f.prototype.update=function(u){var b=0,p=u.length,y;if(this._leftover){y=16-this._leftover,y>p&&(y=p);for(var A=0;A=16&&(y=p-p%16,this._blocks(u,b,y),b+=y,p-=y),p){for(var A=0;A16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var O=new Uint8Array(16);O.set(p,O.length-p.length);var N=new Uint8Array(32);e.stream(this._key,O,N,4);var K=y.length+this.tagLength,W;if(R){if(R.length!==K)throw new Error("ChaCha20Poly1305: incorrect destination length");W=R}else W=new Uint8Array(K);return e.streamXOR(this._key,O,y,W,4),this._authenticate(W.subarray(W.length-this.tagLength,W.length),N,W.subarray(0,W.length-this.tagLength),A),i.wipe(O),W},b.prototype.open=function(p,y,A,R){if(p.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(y.length0&&O.update(f.subarray(R.length%16))),O.update(A),A.length%16>0&&O.update(f.subarray(A.length%16));var N=new Uint8Array(8);R&&n.writeUint64LE(R.length,N),O.update(N),n.writeUint64LE(A.length,N),O.update(N);for(var K=O.digest(),W=0;Wthis.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i256)throw new Error("randomString charset is too long");let R="";const O=y.length,N=256-256%O;for(;p>0;){const K=n(Math.ceil(p*256/N),A);for(let W=0;W0;W++){const Q=K[W];Q0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=b[y++],p--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(p>=this.blockSize&&(y=a(this._temp,this._state,b,y,p),p%=this.blockSize);p>0;)this._buffer[this._bufferLength++]=b[y++],p--;return this},u.prototype.finish=function(b){if(!this._finished){var p=this._bytesHashed,y=this._bufferLength,A=p/536870912|0,R=p<<3,O=p%64<56?64:128;this._buffer[y]=128;for(var N=y+1;N0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},u.prototype.restoreState=function(b){return this._state.set(b.state),this._bufferLength=b.bufferLength,b.buffer&&this._buffer.set(b.buffer),this._bytesHashed=b.bytesHashed,this._finished=!1,this},u.prototype.cleanSavedState=function(b){t.wipe(b.state),b.buffer&&t.wipe(b.buffer),b.bufferLength=0,b.bytesHashed=0},u}();r.SHA256=i;var n=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function a(u,b,p,y,A){for(;A>=64;){for(var R=b[0],O=b[1],N=b[2],K=b[3],W=b[4],Q=b[5],k=b[6],Y=b[7],$=0;$<16;$++){var F=y+$*4;u[$]=e.readUint32BE(p,F)}for(var $=16;$<64;$++){var G=u[$-2],x=(G>>>17|G<<15)^(G>>>19|G<<13)^G>>>10;G=u[$-15];var q=(G>>>7|G<<25)^(G>>>18|G<<14)^G>>>3;u[$]=(x+u[$-7]|0)+(q+u[$-16]|0)}for(var $=0;$<64;$++){var x=(((W>>>6|W<<26)^(W>>>11|W<<21)^(W>>>25|W<<7))+(W&Q^~W&k)|0)+(Y+(n[$]+u[$]|0)|0)|0,q=((R>>>2|R<<30)^(R>>>13|R<<19)^(R>>>22|R<<10))+(R&O^R&N^O&N)|0;Y=k,k=Q,Q=W,W=K+x|0,K=N,N=O,O=R,R=x+q|0}b[0]+=R,b[1]+=O,b[2]+=N,b[3]+=K,b[4]+=W,b[5]+=Q,b[6]+=k,b[7]+=Y,y+=64,A-=64}return y}function f(u){var b=new i;b.update(u);var p=b.digest();return b.clean(),p}r.hash=f})(Ac);var Td={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.sharedKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.scalarMultBase=r.scalarMult=r.SHARED_KEY_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=void 0;const e=$s,t=Ei;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function i($){const F=new Float64Array(16);if($)for(let G=0;G<$.length;G++)F[G]=$[G];return F}const n=new Uint8Array(32);n[0]=9;const a=i([56129,1]);function f($){let F=1;for(let G=0;G<16;G++){let x=$[G]+F+65535;F=Math.floor(x/65536),$[G]=x-F*65536}$[0]+=F-1+37*(F-1)}function u($,F,G){const x=~(G-1);for(let q=0;q<16;q++){const ae=x&($[q]^F[q]);$[q]^=ae,F[q]^=ae}}function b($,F){const G=i(),x=i();for(let q=0;q<16;q++)x[q]=F[q];f(x),f(x),f(x);for(let q=0;q<2;q++){G[0]=x[0]-65517;for(let le=1;le<15;le++)G[le]=x[le]-65535-(G[le-1]>>16&1),G[le-1]&=65535;G[15]=x[15]-32767-(G[14]>>16&1);const ae=G[15]>>16&1;G[14]&=65535,u(x,G,1-ae)}for(let q=0;q<16;q++)$[2*q]=x[q]&255,$[2*q+1]=x[q]>>8}function p($,F){for(let G=0;G<16;G++)$[G]=F[2*G]+(F[2*G+1]<<8);$[15]&=32767}function y($,F,G){for(let x=0;x<16;x++)$[x]=F[x]+G[x]}function A($,F,G){for(let x=0;x<16;x++)$[x]=F[x]-G[x]}function R($,F,G){let x,q,ae=0,le=0,L=0,m=0,c=0,h=0,v=0,_=0,I=0,M=0,S=0,d=0,g=0,C=0,Z=0,se=0,P=0,ee=0,B=0,j=0,H=0,w=0,z=0,ne=0,ce=0,he=0,ye=0,we=0,Te=0,Qe=0,Oe=0,Ce=G[0],Ie=G[1],me=G[2],Re=G[3],De=G[4],ve=G[5],Ne=G[6],Se=G[7],be=G[8],Ue=G[9],Me=G[10],_e=G[11],He=G[12],Ve=G[13],Ee=G[14],Ke=G[15];x=F[0],ae+=x*Ce,le+=x*Ie,L+=x*me,m+=x*Re,c+=x*De,h+=x*ve,v+=x*Ne,_+=x*Se,I+=x*be,M+=x*Ue,S+=x*Me,d+=x*_e,g+=x*He,C+=x*Ve,Z+=x*Ee,se+=x*Ke,x=F[1],le+=x*Ce,L+=x*Ie,m+=x*me,c+=x*Re,h+=x*De,v+=x*ve,_+=x*Ne,I+=x*Se,M+=x*be,S+=x*Ue,d+=x*Me,g+=x*_e,C+=x*He,Z+=x*Ve,se+=x*Ee,P+=x*Ke,x=F[2],L+=x*Ce,m+=x*Ie,c+=x*me,h+=x*Re,v+=x*De,_+=x*ve,I+=x*Ne,M+=x*Se,S+=x*be,d+=x*Ue,g+=x*Me,C+=x*_e,Z+=x*He,se+=x*Ve,P+=x*Ee,ee+=x*Ke,x=F[3],m+=x*Ce,c+=x*Ie,h+=x*me,v+=x*Re,_+=x*De,I+=x*ve,M+=x*Ne,S+=x*Se,d+=x*be,g+=x*Ue,C+=x*Me,Z+=x*_e,se+=x*He,P+=x*Ve,ee+=x*Ee,B+=x*Ke,x=F[4],c+=x*Ce,h+=x*Ie,v+=x*me,_+=x*Re,I+=x*De,M+=x*ve,S+=x*Ne,d+=x*Se,g+=x*be,C+=x*Ue,Z+=x*Me,se+=x*_e,P+=x*He,ee+=x*Ve,B+=x*Ee,j+=x*Ke,x=F[5],h+=x*Ce,v+=x*Ie,_+=x*me,I+=x*Re,M+=x*De,S+=x*ve,d+=x*Ne,g+=x*Se,C+=x*be,Z+=x*Ue,se+=x*Me,P+=x*_e,ee+=x*He,B+=x*Ve,j+=x*Ee,H+=x*Ke,x=F[6],v+=x*Ce,_+=x*Ie,I+=x*me,M+=x*Re,S+=x*De,d+=x*ve,g+=x*Ne,C+=x*Se,Z+=x*be,se+=x*Ue,P+=x*Me,ee+=x*_e,B+=x*He,j+=x*Ve,H+=x*Ee,w+=x*Ke,x=F[7],_+=x*Ce,I+=x*Ie,M+=x*me,S+=x*Re,d+=x*De,g+=x*ve,C+=x*Ne,Z+=x*Se,se+=x*be,P+=x*Ue,ee+=x*Me,B+=x*_e,j+=x*He,H+=x*Ve,w+=x*Ee,z+=x*Ke,x=F[8],I+=x*Ce,M+=x*Ie,S+=x*me,d+=x*Re,g+=x*De,C+=x*ve,Z+=x*Ne,se+=x*Se,P+=x*be,ee+=x*Ue,B+=x*Me,j+=x*_e,H+=x*He,w+=x*Ve,z+=x*Ee,ne+=x*Ke,x=F[9],M+=x*Ce,S+=x*Ie,d+=x*me,g+=x*Re,C+=x*De,Z+=x*ve,se+=x*Ne,P+=x*Se,ee+=x*be,B+=x*Ue,j+=x*Me,H+=x*_e,w+=x*He,z+=x*Ve,ne+=x*Ee,ce+=x*Ke,x=F[10],S+=x*Ce,d+=x*Ie,g+=x*me,C+=x*Re,Z+=x*De,se+=x*ve,P+=x*Ne,ee+=x*Se,B+=x*be,j+=x*Ue,H+=x*Me,w+=x*_e,z+=x*He,ne+=x*Ve,ce+=x*Ee,he+=x*Ke,x=F[11],d+=x*Ce,g+=x*Ie,C+=x*me,Z+=x*Re,se+=x*De,P+=x*ve,ee+=x*Ne,B+=x*Se,j+=x*be,H+=x*Ue,w+=x*Me,z+=x*_e,ne+=x*He,ce+=x*Ve,he+=x*Ee,ye+=x*Ke,x=F[12],g+=x*Ce,C+=x*Ie,Z+=x*me,se+=x*Re,P+=x*De,ee+=x*ve,B+=x*Ne,j+=x*Se,H+=x*be,w+=x*Ue,z+=x*Me,ne+=x*_e,ce+=x*He,he+=x*Ve,ye+=x*Ee,we+=x*Ke,x=F[13],C+=x*Ce,Z+=x*Ie,se+=x*me,P+=x*Re,ee+=x*De,B+=x*ve,j+=x*Ne,H+=x*Se,w+=x*be,z+=x*Ue,ne+=x*Me,ce+=x*_e,he+=x*He,ye+=x*Ve,we+=x*Ee,Te+=x*Ke,x=F[14],Z+=x*Ce,se+=x*Ie,P+=x*me,ee+=x*Re,B+=x*De,j+=x*ve,H+=x*Ne,w+=x*Se,z+=x*be,ne+=x*Ue,ce+=x*Me,he+=x*_e,ye+=x*He,we+=x*Ve,Te+=x*Ee,Qe+=x*Ke,x=F[15],se+=x*Ce,P+=x*Ie,ee+=x*me,B+=x*Re,j+=x*De,H+=x*ve,w+=x*Ne,z+=x*Se,ne+=x*be,ce+=x*Ue,he+=x*Me,ye+=x*_e,we+=x*He,Te+=x*Ve,Qe+=x*Ee,Oe+=x*Ke,ae+=38*P,le+=38*ee,L+=38*B,m+=38*j,c+=38*H,h+=38*w,v+=38*z,_+=38*ne,I+=38*ce,M+=38*he,S+=38*ye,d+=38*we,g+=38*Te,C+=38*Qe,Z+=38*Oe,q=1,x=ae+q+65535,q=Math.floor(x/65536),ae=x-q*65536,x=le+q+65535,q=Math.floor(x/65536),le=x-q*65536,x=L+q+65535,q=Math.floor(x/65536),L=x-q*65536,x=m+q+65535,q=Math.floor(x/65536),m=x-q*65536,x=c+q+65535,q=Math.floor(x/65536),c=x-q*65536,x=h+q+65535,q=Math.floor(x/65536),h=x-q*65536,x=v+q+65535,q=Math.floor(x/65536),v=x-q*65536,x=_+q+65535,q=Math.floor(x/65536),_=x-q*65536,x=I+q+65535,q=Math.floor(x/65536),I=x-q*65536,x=M+q+65535,q=Math.floor(x/65536),M=x-q*65536,x=S+q+65535,q=Math.floor(x/65536),S=x-q*65536,x=d+q+65535,q=Math.floor(x/65536),d=x-q*65536,x=g+q+65535,q=Math.floor(x/65536),g=x-q*65536,x=C+q+65535,q=Math.floor(x/65536),C=x-q*65536,x=Z+q+65535,q=Math.floor(x/65536),Z=x-q*65536,x=se+q+65535,q=Math.floor(x/65536),se=x-q*65536,ae+=q-1+37*(q-1),q=1,x=ae+q+65535,q=Math.floor(x/65536),ae=x-q*65536,x=le+q+65535,q=Math.floor(x/65536),le=x-q*65536,x=L+q+65535,q=Math.floor(x/65536),L=x-q*65536,x=m+q+65535,q=Math.floor(x/65536),m=x-q*65536,x=c+q+65535,q=Math.floor(x/65536),c=x-q*65536,x=h+q+65535,q=Math.floor(x/65536),h=x-q*65536,x=v+q+65535,q=Math.floor(x/65536),v=x-q*65536,x=_+q+65535,q=Math.floor(x/65536),_=x-q*65536,x=I+q+65535,q=Math.floor(x/65536),I=x-q*65536,x=M+q+65535,q=Math.floor(x/65536),M=x-q*65536,x=S+q+65535,q=Math.floor(x/65536),S=x-q*65536,x=d+q+65535,q=Math.floor(x/65536),d=x-q*65536,x=g+q+65535,q=Math.floor(x/65536),g=x-q*65536,x=C+q+65535,q=Math.floor(x/65536),C=x-q*65536,x=Z+q+65535,q=Math.floor(x/65536),Z=x-q*65536,x=se+q+65535,q=Math.floor(x/65536),se=x-q*65536,ae+=q-1+37*(q-1),$[0]=ae,$[1]=le,$[2]=L,$[3]=m,$[4]=c,$[5]=h,$[6]=v,$[7]=_,$[8]=I,$[9]=M,$[10]=S,$[11]=d,$[12]=g,$[13]=C,$[14]=Z,$[15]=se}function O($,F){R($,F,F)}function N($,F){const G=i();for(let x=0;x<16;x++)G[x]=F[x];for(let x=253;x>=0;x--)O(G,G),x!==2&&x!==4&&R(G,G,F);for(let x=0;x<16;x++)$[x]=G[x]}function K($,F){const G=new Uint8Array(32),x=new Float64Array(80),q=i(),ae=i(),le=i(),L=i(),m=i(),c=i();for(let I=0;I<31;I++)G[I]=$[I];G[31]=$[31]&127|64,G[0]&=248,p(x,F);for(let I=0;I<16;I++)ae[I]=x[I];q[0]=L[0]=1;for(let I=254;I>=0;--I){const M=G[I>>>3]>>>(I&7)&1;u(q,ae,M),u(le,L,M),y(m,q,le),A(q,q,le),y(le,ae,L),A(ae,ae,L),O(L,m),O(c,q),R(q,le,q),R(le,ae,m),y(m,q,le),A(q,q,le),O(ae,q),A(le,L,c),R(q,le,a),y(q,q,L),R(le,le,q),R(q,L,c),R(L,ae,x),O(ae,m),u(q,ae,M),u(le,L,M)}for(let I=0;I<16;I++)x[I+16]=q[I],x[I+32]=le[I],x[I+48]=ae[I],x[I+64]=L[I];const h=x.subarray(32),v=x.subarray(16);N(h,h),R(v,v,h);const _=new Uint8Array(32);return b(_,v),_}r.scalarMult=K;function W($){return K($,n)}r.scalarMultBase=W;function Q($){if($.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const F=new Uint8Array($);return{publicKey:W(F),secretKey:F}}r.generateKeyPairFromSeed=Q;function k($){const F=(0,e.randomBytes)(32,$),G=Q(F);return(0,t.wipe)(F),G}r.generateKeyPair=k;function Y($,F,G=!1){if($.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(F.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const x=K($,F);if(G){let q=0;for(let ae=0;aen+a.length,0));const t=z8(e);let i=0;for(const n of r)t.set(n,i),i+=n.length;return t}function Er(r,e="utf8"){const t=j8[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Qv={};const A_="elliptic",E_="6.5.7",x_="EC cryptography",S_="lib/elliptic.js",I_=["lib"],M_={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},P_={type:"git",url:"git@github.com:indutny/elliptic"},O_=["EC","Elliptic","curve","Cryptography"],R_="Fedor Indutny ",N_="MIT",T_={url:"https://github.com/indutny/elliptic/issues"},C_="https://github.com/indutny/elliptic",D_={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},L_={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},q_={name:A_,version:E_,description:x_,main:S_,files:I_,scripts:M_,repository:P_,keywords:O_,author:R_,license:N_,bugs:T_,homepage:C_,devDependencies:D_,dependencies:L_};var xi={},Cd={exports:{}};Cd.exports;(function(r){(function(e,t){function i(L,m){if(!L)throw new Error(m||"Assertion failed")}function n(L,m){L.super_=m;var c=function(){};c.prototype=m.prototype,L.prototype=new c,L.prototype.constructor=L}function a(L,m,c){if(a.isBN(L))return L;this.negative=0,this.words=null,this.length=0,this.red=null,L!==null&&((m==="le"||m==="be")&&(c=m,m=10),this._init(L||0,m||10,c||"be"))}typeof e=="object"?e.exports=a:t.BN=a,a.BN=a,a.wordSize=26;var f;try{typeof window<"u"&&typeof window.Buffer<"u"?f=window.Buffer:f=Md.Buffer}catch{}a.isBN=function(m){return m instanceof a?!0:m!==null&&typeof m=="object"&&m.constructor.wordSize===a.wordSize&&Array.isArray(m.words)},a.max=function(m,c){return m.cmp(c)>0?m:c},a.min=function(m,c){return m.cmp(c)<0?m:c},a.prototype._init=function(m,c,h){if(typeof m=="number")return this._initNumber(m,c,h);if(typeof m=="object")return this._initArray(m,c,h);c==="hex"&&(c=16),i(c===(c|0)&&c>=2&&c<=36),m=m.toString().replace(/\s+/g,"");var v=0;m[0]==="-"&&(v++,this.negative=1),v=0;v-=3)I=m[v]|m[v-1]<<8|m[v-2]<<16,this.words[_]|=I<>>26-M&67108863,M+=24,M>=26&&(M-=26,_++);else if(h==="le")for(v=0,_=0;v>>26-M&67108863,M+=24,M>=26&&(M-=26,_++);return this.strip()};function u(L,m){var c=L.charCodeAt(m);return c>=65&&c<=70?c-55:c>=97&&c<=102?c-87:c-48&15}function b(L,m,c){var h=u(L,c);return c-1>=m&&(h|=u(L,c-1)<<4),h}a.prototype._parseHex=function(m,c,h){this.length=Math.ceil((m.length-c)/6),this.words=new Array(this.length);for(var v=0;v=c;v-=2)M=b(m,c,v)<<_,this.words[I]|=M&67108863,_>=18?(_-=18,I+=1,this.words[I]|=M>>>26):_+=8;else{var S=m.length-c;for(v=S%2===0?c+1:c;v=18?(_-=18,I+=1,this.words[I]|=M>>>26):_+=8}this.strip()};function p(L,m,c,h){for(var v=0,_=Math.min(L.length,c),I=m;I<_;I++){var M=L.charCodeAt(I)-48;v*=h,M>=49?v+=M-49+10:M>=17?v+=M-17+10:v+=M}return v}a.prototype._parseBase=function(m,c,h){this.words=[0],this.length=1;for(var v=0,_=1;_<=67108863;_*=c)v++;v--,_=_/c|0;for(var I=m.length-h,M=I%v,S=Math.min(I,I-M)+h,d=0,g=h;g1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?""};var y=["","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"],A=[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],R=[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];a.prototype.toString=function(m,c){m=m||10,c=c|0||1;var h;if(m===16||m==="hex"){h="";for(var v=0,_=0,I=0;I>>24-v&16777215,_!==0||I!==this.length-1?h=y[6-S.length]+S+h:h=S+h,v+=2,v>=26&&(v-=26,I--)}for(_!==0&&(h=_.toString(16)+h);h.length%c!==0;)h="0"+h;return this.negative!==0&&(h="-"+h),h}if(m===(m|0)&&m>=2&&m<=36){var d=A[m],g=R[m];h="";var C=this.clone();for(C.negative=0;!C.isZero();){var Z=C.modn(g).toString(m);C=C.idivn(g),C.isZero()?h=Z+h:h=y[d-Z.length]+Z+h}for(this.isZero()&&(h="0"+h);h.length%c!==0;)h="0"+h;return this.negative!==0&&(h="-"+h),h}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var m=this.words[0];return this.length===2?m+=this.words[1]*67108864:this.length===3&&this.words[2]===1?m+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-m:m},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(m,c){return i(typeof f<"u"),this.toArrayLike(f,m,c)},a.prototype.toArray=function(m,c){return this.toArrayLike(Array,m,c)},a.prototype.toArrayLike=function(m,c,h){var v=this.byteLength(),_=h||Math.max(1,v);i(v<=_,"byte array longer than desired length"),i(_>0,"Requested array length <= 0"),this.strip();var I=c==="le",M=new m(_),S,d,g=this.clone();if(I){for(d=0;!g.isZero();d++)S=g.andln(255),g.iushrn(8),M[d]=S;for(;d<_;d++)M[d]=0}else{for(d=0;d<_-v;d++)M[d]=0;for(d=0;!g.isZero();d++)S=g.andln(255),g.iushrn(8),M[_-d-1]=S}return M},Math.clz32?a.prototype._countBits=function(m){return 32-Math.clz32(m)}:a.prototype._countBits=function(m){var c=m,h=0;return c>=4096&&(h+=13,c>>>=13),c>=64&&(h+=7,c>>>=7),c>=8&&(h+=4,c>>>=4),c>=2&&(h+=2,c>>>=2),h+c},a.prototype._zeroBits=function(m){if(m===0)return 26;var c=m,h=0;return c&8191||(h+=13,c>>>=13),c&127||(h+=7,c>>>=7),c&15||(h+=4,c>>>=4),c&3||(h+=2,c>>>=2),c&1||h++,h},a.prototype.bitLength=function(){var m=this.words[this.length-1],c=this._countBits(m);return(this.length-1)*26+c};function O(L){for(var m=new Array(L.bitLength()),c=0;c>>v}return m}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var m=0,c=0;cm.length?this.clone().ior(m):m.clone().ior(this)},a.prototype.uor=function(m){return this.length>m.length?this.clone().iuor(m):m.clone().iuor(this)},a.prototype.iuand=function(m){var c;this.length>m.length?c=m:c=this;for(var h=0;hm.length?this.clone().iand(m):m.clone().iand(this)},a.prototype.uand=function(m){return this.length>m.length?this.clone().iuand(m):m.clone().iuand(this)},a.prototype.iuxor=function(m){var c,h;this.length>m.length?(c=this,h=m):(c=m,h=this);for(var v=0;vm.length?this.clone().ixor(m):m.clone().ixor(this)},a.prototype.uxor=function(m){return this.length>m.length?this.clone().iuxor(m):m.clone().iuxor(this)},a.prototype.inotn=function(m){i(typeof m=="number"&&m>=0);var c=Math.ceil(m/26)|0,h=m%26;this._expand(c),h>0&&c--;for(var v=0;v0&&(this.words[v]=~this.words[v]&67108863>>26-h),this.strip()},a.prototype.notn=function(m){return this.clone().inotn(m)},a.prototype.setn=function(m,c){i(typeof m=="number"&&m>=0);var h=m/26|0,v=m%26;return this._expand(h+1),c?this.words[h]=this.words[h]|1<m.length?(h=this,v=m):(h=m,v=this);for(var _=0,I=0;I>>26;for(;_!==0&&I>>26;if(this.length=h.length,_!==0)this.words[this.length]=_,this.length++;else if(h!==this)for(;Im.length?this.clone().iadd(m):m.clone().iadd(this)},a.prototype.isub=function(m){if(m.negative!==0){m.negative=0;var c=this.iadd(m);return m.negative=1,c._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(m),this.negative=1,this._normSign();var h=this.cmp(m);if(h===0)return this.negative=0,this.length=1,this.words[0]=0,this;var v,_;h>0?(v=this,_=m):(v=m,_=this);for(var I=0,M=0;M<_.length;M++)c=(v.words[M]|0)-(_.words[M]|0)+I,I=c>>26,this.words[M]=c&67108863;for(;I!==0&&M>26,this.words[M]=c&67108863;if(I===0&&M>>26,C=S&67108863,Z=Math.min(d,m.length-1),se=Math.max(0,d-L.length+1);se<=Z;se++){var P=d-se|0;v=L.words[P]|0,_=m.words[se]|0,I=v*_+C,g+=I/67108864|0,C=I&67108863}c.words[d]=C|0,S=g|0}return S!==0?c.words[d]=S|0:c.length--,c.strip()}var K=function(m,c,h){var v=m.words,_=c.words,I=h.words,M=0,S,d,g,C=v[0]|0,Z=C&8191,se=C>>>13,P=v[1]|0,ee=P&8191,B=P>>>13,j=v[2]|0,H=j&8191,w=j>>>13,z=v[3]|0,ne=z&8191,ce=z>>>13,he=v[4]|0,ye=he&8191,we=he>>>13,Te=v[5]|0,Qe=Te&8191,Oe=Te>>>13,Ce=v[6]|0,Ie=Ce&8191,me=Ce>>>13,Re=v[7]|0,De=Re&8191,ve=Re>>>13,Ne=v[8]|0,Se=Ne&8191,be=Ne>>>13,Ue=v[9]|0,Me=Ue&8191,_e=Ue>>>13,He=_[0]|0,Ve=He&8191,Ee=He>>>13,Ke=_[1]|0,ut=Ke&8191,Ge=Ke>>>13,_t=_[2]|0,lt=_t&8191,Je=_t>>>13,Et=_[3]|0,It=Et&8191,Le=Et>>>13,Xe=_[4]|0,tt=Xe&8191,qe=Xe>>>13,et=_[5]|0,Ze=et&8191,ze=et>>>13,ft=_[6]|0,rt=ft&8191,je=ft>>>13,it=_[7]|0,st=it&8191,Be=it>>>13,Ye=_[8]|0,ht=Ye&8191,ke=Ye>>>13,Ct=_[9]|0,Dt=Ct&8191,at=Ct>>>13;h.negative=m.negative^c.negative,h.length=19,S=Math.imul(Z,Ve),d=Math.imul(Z,Ee),d=d+Math.imul(se,Ve)|0,g=Math.imul(se,Ee);var bt=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(bt>>>26)|0,bt&=67108863,S=Math.imul(ee,Ve),d=Math.imul(ee,Ee),d=d+Math.imul(B,Ve)|0,g=Math.imul(B,Ee),S=S+Math.imul(Z,ut)|0,d=d+Math.imul(Z,Ge)|0,d=d+Math.imul(se,ut)|0,g=g+Math.imul(se,Ge)|0;var Tr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Tr>>>26)|0,Tr&=67108863,S=Math.imul(H,Ve),d=Math.imul(H,Ee),d=d+Math.imul(w,Ve)|0,g=Math.imul(w,Ee),S=S+Math.imul(ee,ut)|0,d=d+Math.imul(ee,Ge)|0,d=d+Math.imul(B,ut)|0,g=g+Math.imul(B,Ge)|0,S=S+Math.imul(Z,lt)|0,d=d+Math.imul(Z,Je)|0,d=d+Math.imul(se,lt)|0,g=g+Math.imul(se,Je)|0;var Cr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,S=Math.imul(ne,Ve),d=Math.imul(ne,Ee),d=d+Math.imul(ce,Ve)|0,g=Math.imul(ce,Ee),S=S+Math.imul(H,ut)|0,d=d+Math.imul(H,Ge)|0,d=d+Math.imul(w,ut)|0,g=g+Math.imul(w,Ge)|0,S=S+Math.imul(ee,lt)|0,d=d+Math.imul(ee,Je)|0,d=d+Math.imul(B,lt)|0,g=g+Math.imul(B,Je)|0,S=S+Math.imul(Z,It)|0,d=d+Math.imul(Z,Le)|0,d=d+Math.imul(se,It)|0,g=g+Math.imul(se,Le)|0;var Dr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Dr>>>26)|0,Dr&=67108863,S=Math.imul(ye,Ve),d=Math.imul(ye,Ee),d=d+Math.imul(we,Ve)|0,g=Math.imul(we,Ee),S=S+Math.imul(ne,ut)|0,d=d+Math.imul(ne,Ge)|0,d=d+Math.imul(ce,ut)|0,g=g+Math.imul(ce,Ge)|0,S=S+Math.imul(H,lt)|0,d=d+Math.imul(H,Je)|0,d=d+Math.imul(w,lt)|0,g=g+Math.imul(w,Je)|0,S=S+Math.imul(ee,It)|0,d=d+Math.imul(ee,Le)|0,d=d+Math.imul(B,It)|0,g=g+Math.imul(B,Le)|0,S=S+Math.imul(Z,tt)|0,d=d+Math.imul(Z,qe)|0,d=d+Math.imul(se,tt)|0,g=g+Math.imul(se,qe)|0;var Lr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Lr>>>26)|0,Lr&=67108863,S=Math.imul(Qe,Ve),d=Math.imul(Qe,Ee),d=d+Math.imul(Oe,Ve)|0,g=Math.imul(Oe,Ee),S=S+Math.imul(ye,ut)|0,d=d+Math.imul(ye,Ge)|0,d=d+Math.imul(we,ut)|0,g=g+Math.imul(we,Ge)|0,S=S+Math.imul(ne,lt)|0,d=d+Math.imul(ne,Je)|0,d=d+Math.imul(ce,lt)|0,g=g+Math.imul(ce,Je)|0,S=S+Math.imul(H,It)|0,d=d+Math.imul(H,Le)|0,d=d+Math.imul(w,It)|0,g=g+Math.imul(w,Le)|0,S=S+Math.imul(ee,tt)|0,d=d+Math.imul(ee,qe)|0,d=d+Math.imul(B,tt)|0,g=g+Math.imul(B,qe)|0,S=S+Math.imul(Z,Ze)|0,d=d+Math.imul(Z,ze)|0,d=d+Math.imul(se,Ze)|0,g=g+Math.imul(se,ze)|0;var qr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(qr>>>26)|0,qr&=67108863,S=Math.imul(Ie,Ve),d=Math.imul(Ie,Ee),d=d+Math.imul(me,Ve)|0,g=Math.imul(me,Ee),S=S+Math.imul(Qe,ut)|0,d=d+Math.imul(Qe,Ge)|0,d=d+Math.imul(Oe,ut)|0,g=g+Math.imul(Oe,Ge)|0,S=S+Math.imul(ye,lt)|0,d=d+Math.imul(ye,Je)|0,d=d+Math.imul(we,lt)|0,g=g+Math.imul(we,Je)|0,S=S+Math.imul(ne,It)|0,d=d+Math.imul(ne,Le)|0,d=d+Math.imul(ce,It)|0,g=g+Math.imul(ce,Le)|0,S=S+Math.imul(H,tt)|0,d=d+Math.imul(H,qe)|0,d=d+Math.imul(w,tt)|0,g=g+Math.imul(w,qe)|0,S=S+Math.imul(ee,Ze)|0,d=d+Math.imul(ee,ze)|0,d=d+Math.imul(B,Ze)|0,g=g+Math.imul(B,ze)|0,S=S+Math.imul(Z,rt)|0,d=d+Math.imul(Z,je)|0,d=d+Math.imul(se,rt)|0,g=g+Math.imul(se,je)|0;var er=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(er>>>26)|0,er&=67108863,S=Math.imul(De,Ve),d=Math.imul(De,Ee),d=d+Math.imul(ve,Ve)|0,g=Math.imul(ve,Ee),S=S+Math.imul(Ie,ut)|0,d=d+Math.imul(Ie,Ge)|0,d=d+Math.imul(me,ut)|0,g=g+Math.imul(me,Ge)|0,S=S+Math.imul(Qe,lt)|0,d=d+Math.imul(Qe,Je)|0,d=d+Math.imul(Oe,lt)|0,g=g+Math.imul(Oe,Je)|0,S=S+Math.imul(ye,It)|0,d=d+Math.imul(ye,Le)|0,d=d+Math.imul(we,It)|0,g=g+Math.imul(we,Le)|0,S=S+Math.imul(ne,tt)|0,d=d+Math.imul(ne,qe)|0,d=d+Math.imul(ce,tt)|0,g=g+Math.imul(ce,qe)|0,S=S+Math.imul(H,Ze)|0,d=d+Math.imul(H,ze)|0,d=d+Math.imul(w,Ze)|0,g=g+Math.imul(w,ze)|0,S=S+Math.imul(ee,rt)|0,d=d+Math.imul(ee,je)|0,d=d+Math.imul(B,rt)|0,g=g+Math.imul(B,je)|0,S=S+Math.imul(Z,st)|0,d=d+Math.imul(Z,Be)|0,d=d+Math.imul(se,st)|0,g=g+Math.imul(se,Be)|0;var Qr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Qr>>>26)|0,Qr&=67108863,S=Math.imul(Se,Ve),d=Math.imul(Se,Ee),d=d+Math.imul(be,Ve)|0,g=Math.imul(be,Ee),S=S+Math.imul(De,ut)|0,d=d+Math.imul(De,Ge)|0,d=d+Math.imul(ve,ut)|0,g=g+Math.imul(ve,Ge)|0,S=S+Math.imul(Ie,lt)|0,d=d+Math.imul(Ie,Je)|0,d=d+Math.imul(me,lt)|0,g=g+Math.imul(me,Je)|0,S=S+Math.imul(Qe,It)|0,d=d+Math.imul(Qe,Le)|0,d=d+Math.imul(Oe,It)|0,g=g+Math.imul(Oe,Le)|0,S=S+Math.imul(ye,tt)|0,d=d+Math.imul(ye,qe)|0,d=d+Math.imul(we,tt)|0,g=g+Math.imul(we,qe)|0,S=S+Math.imul(ne,Ze)|0,d=d+Math.imul(ne,ze)|0,d=d+Math.imul(ce,Ze)|0,g=g+Math.imul(ce,ze)|0,S=S+Math.imul(H,rt)|0,d=d+Math.imul(H,je)|0,d=d+Math.imul(w,rt)|0,g=g+Math.imul(w,je)|0,S=S+Math.imul(ee,st)|0,d=d+Math.imul(ee,Be)|0,d=d+Math.imul(B,st)|0,g=g+Math.imul(B,Be)|0,S=S+Math.imul(Z,ht)|0,d=d+Math.imul(Z,ke)|0,d=d+Math.imul(se,ht)|0,g=g+Math.imul(se,ke)|0;var Vi=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Vi>>>26)|0,Vi&=67108863,S=Math.imul(Me,Ve),d=Math.imul(Me,Ee),d=d+Math.imul(_e,Ve)|0,g=Math.imul(_e,Ee),S=S+Math.imul(Se,ut)|0,d=d+Math.imul(Se,Ge)|0,d=d+Math.imul(be,ut)|0,g=g+Math.imul(be,Ge)|0,S=S+Math.imul(De,lt)|0,d=d+Math.imul(De,Je)|0,d=d+Math.imul(ve,lt)|0,g=g+Math.imul(ve,Je)|0,S=S+Math.imul(Ie,It)|0,d=d+Math.imul(Ie,Le)|0,d=d+Math.imul(me,It)|0,g=g+Math.imul(me,Le)|0,S=S+Math.imul(Qe,tt)|0,d=d+Math.imul(Qe,qe)|0,d=d+Math.imul(Oe,tt)|0,g=g+Math.imul(Oe,qe)|0,S=S+Math.imul(ye,Ze)|0,d=d+Math.imul(ye,ze)|0,d=d+Math.imul(we,Ze)|0,g=g+Math.imul(we,ze)|0,S=S+Math.imul(ne,rt)|0,d=d+Math.imul(ne,je)|0,d=d+Math.imul(ce,rt)|0,g=g+Math.imul(ce,je)|0,S=S+Math.imul(H,st)|0,d=d+Math.imul(H,Be)|0,d=d+Math.imul(w,st)|0,g=g+Math.imul(w,Be)|0,S=S+Math.imul(ee,ht)|0,d=d+Math.imul(ee,ke)|0,d=d+Math.imul(B,ht)|0,g=g+Math.imul(B,ke)|0,S=S+Math.imul(Z,Dt)|0,d=d+Math.imul(Z,at)|0,d=d+Math.imul(se,Dt)|0,g=g+Math.imul(se,at)|0;var Xr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,S=Math.imul(Me,ut),d=Math.imul(Me,Ge),d=d+Math.imul(_e,ut)|0,g=Math.imul(_e,Ge),S=S+Math.imul(Se,lt)|0,d=d+Math.imul(Se,Je)|0,d=d+Math.imul(be,lt)|0,g=g+Math.imul(be,Je)|0,S=S+Math.imul(De,It)|0,d=d+Math.imul(De,Le)|0,d=d+Math.imul(ve,It)|0,g=g+Math.imul(ve,Le)|0,S=S+Math.imul(Ie,tt)|0,d=d+Math.imul(Ie,qe)|0,d=d+Math.imul(me,tt)|0,g=g+Math.imul(me,qe)|0,S=S+Math.imul(Qe,Ze)|0,d=d+Math.imul(Qe,ze)|0,d=d+Math.imul(Oe,Ze)|0,g=g+Math.imul(Oe,ze)|0,S=S+Math.imul(ye,rt)|0,d=d+Math.imul(ye,je)|0,d=d+Math.imul(we,rt)|0,g=g+Math.imul(we,je)|0,S=S+Math.imul(ne,st)|0,d=d+Math.imul(ne,Be)|0,d=d+Math.imul(ce,st)|0,g=g+Math.imul(ce,Be)|0,S=S+Math.imul(H,ht)|0,d=d+Math.imul(H,ke)|0,d=d+Math.imul(w,ht)|0,g=g+Math.imul(w,ke)|0,S=S+Math.imul(ee,Dt)|0,d=d+Math.imul(ee,at)|0,d=d+Math.imul(B,Dt)|0,g=g+Math.imul(B,at)|0;var Gi=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Gi>>>26)|0,Gi&=67108863,S=Math.imul(Me,lt),d=Math.imul(Me,Je),d=d+Math.imul(_e,lt)|0,g=Math.imul(_e,Je),S=S+Math.imul(Se,It)|0,d=d+Math.imul(Se,Le)|0,d=d+Math.imul(be,It)|0,g=g+Math.imul(be,Le)|0,S=S+Math.imul(De,tt)|0,d=d+Math.imul(De,qe)|0,d=d+Math.imul(ve,tt)|0,g=g+Math.imul(ve,qe)|0,S=S+Math.imul(Ie,Ze)|0,d=d+Math.imul(Ie,ze)|0,d=d+Math.imul(me,Ze)|0,g=g+Math.imul(me,ze)|0,S=S+Math.imul(Qe,rt)|0,d=d+Math.imul(Qe,je)|0,d=d+Math.imul(Oe,rt)|0,g=g+Math.imul(Oe,je)|0,S=S+Math.imul(ye,st)|0,d=d+Math.imul(ye,Be)|0,d=d+Math.imul(we,st)|0,g=g+Math.imul(we,Be)|0,S=S+Math.imul(ne,ht)|0,d=d+Math.imul(ne,ke)|0,d=d+Math.imul(ce,ht)|0,g=g+Math.imul(ce,ke)|0,S=S+Math.imul(H,Dt)|0,d=d+Math.imul(H,at)|0,d=d+Math.imul(w,Dt)|0,g=g+Math.imul(w,at)|0;var Wi=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Wi>>>26)|0,Wi&=67108863,S=Math.imul(Me,It),d=Math.imul(Me,Le),d=d+Math.imul(_e,It)|0,g=Math.imul(_e,Le),S=S+Math.imul(Se,tt)|0,d=d+Math.imul(Se,qe)|0,d=d+Math.imul(be,tt)|0,g=g+Math.imul(be,qe)|0,S=S+Math.imul(De,Ze)|0,d=d+Math.imul(De,ze)|0,d=d+Math.imul(ve,Ze)|0,g=g+Math.imul(ve,ze)|0,S=S+Math.imul(Ie,rt)|0,d=d+Math.imul(Ie,je)|0,d=d+Math.imul(me,rt)|0,g=g+Math.imul(me,je)|0,S=S+Math.imul(Qe,st)|0,d=d+Math.imul(Qe,Be)|0,d=d+Math.imul(Oe,st)|0,g=g+Math.imul(Oe,Be)|0,S=S+Math.imul(ye,ht)|0,d=d+Math.imul(ye,ke)|0,d=d+Math.imul(we,ht)|0,g=g+Math.imul(we,ke)|0,S=S+Math.imul(ne,Dt)|0,d=d+Math.imul(ne,at)|0,d=d+Math.imul(ce,Dt)|0,g=g+Math.imul(ce,at)|0;var Zr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,S=Math.imul(Me,tt),d=Math.imul(Me,qe),d=d+Math.imul(_e,tt)|0,g=Math.imul(_e,qe),S=S+Math.imul(Se,Ze)|0,d=d+Math.imul(Se,ze)|0,d=d+Math.imul(be,Ze)|0,g=g+Math.imul(be,ze)|0,S=S+Math.imul(De,rt)|0,d=d+Math.imul(De,je)|0,d=d+Math.imul(ve,rt)|0,g=g+Math.imul(ve,je)|0,S=S+Math.imul(Ie,st)|0,d=d+Math.imul(Ie,Be)|0,d=d+Math.imul(me,st)|0,g=g+Math.imul(me,Be)|0,S=S+Math.imul(Qe,ht)|0,d=d+Math.imul(Qe,ke)|0,d=d+Math.imul(Oe,ht)|0,g=g+Math.imul(Oe,ke)|0,S=S+Math.imul(ye,Dt)|0,d=d+Math.imul(ye,at)|0,d=d+Math.imul(we,Dt)|0,g=g+Math.imul(we,at)|0;var Si=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Si>>>26)|0,Si&=67108863,S=Math.imul(Me,Ze),d=Math.imul(Me,ze),d=d+Math.imul(_e,Ze)|0,g=Math.imul(_e,ze),S=S+Math.imul(Se,rt)|0,d=d+Math.imul(Se,je)|0,d=d+Math.imul(be,rt)|0,g=g+Math.imul(be,je)|0,S=S+Math.imul(De,st)|0,d=d+Math.imul(De,Be)|0,d=d+Math.imul(ve,st)|0,g=g+Math.imul(ve,Be)|0,S=S+Math.imul(Ie,ht)|0,d=d+Math.imul(Ie,ke)|0,d=d+Math.imul(me,ht)|0,g=g+Math.imul(me,ke)|0,S=S+Math.imul(Qe,Dt)|0,d=d+Math.imul(Qe,at)|0,d=d+Math.imul(Oe,Dt)|0,g=g+Math.imul(Oe,at)|0;var Ii=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,S=Math.imul(Me,rt),d=Math.imul(Me,je),d=d+Math.imul(_e,rt)|0,g=Math.imul(_e,je),S=S+Math.imul(Se,st)|0,d=d+Math.imul(Se,Be)|0,d=d+Math.imul(be,st)|0,g=g+Math.imul(be,Be)|0,S=S+Math.imul(De,ht)|0,d=d+Math.imul(De,ke)|0,d=d+Math.imul(ve,ht)|0,g=g+Math.imul(ve,ke)|0,S=S+Math.imul(Ie,Dt)|0,d=d+Math.imul(Ie,at)|0,d=d+Math.imul(me,Dt)|0,g=g+Math.imul(me,at)|0;var lr=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(lr>>>26)|0,lr&=67108863,S=Math.imul(Me,st),d=Math.imul(Me,Be),d=d+Math.imul(_e,st)|0,g=Math.imul(_e,Be),S=S+Math.imul(Se,ht)|0,d=d+Math.imul(Se,ke)|0,d=d+Math.imul(be,ht)|0,g=g+Math.imul(be,ke)|0,S=S+Math.imul(De,Dt)|0,d=d+Math.imul(De,at)|0,d=d+Math.imul(ve,Dt)|0,g=g+Math.imul(ve,at)|0;var Ji=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Ji>>>26)|0,Ji&=67108863,S=Math.imul(Me,ht),d=Math.imul(Me,ke),d=d+Math.imul(_e,ht)|0,g=Math.imul(_e,ke),S=S+Math.imul(Se,Dt)|0,d=d+Math.imul(Se,at)|0,d=d+Math.imul(be,Dt)|0,g=g+Math.imul(be,at)|0;var Yi=(M+S|0)+((d&8191)<<13)|0;M=(g+(d>>>13)|0)+(Yi>>>26)|0,Yi&=67108863,S=Math.imul(Me,Dt),d=Math.imul(Me,at),d=d+Math.imul(_e,Dt)|0,g=Math.imul(_e,at);var Qi=(M+S|0)+((d&8191)<<13)|0;return M=(g+(d>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,I[0]=bt,I[1]=Tr,I[2]=Cr,I[3]=Dr,I[4]=Lr,I[5]=qr,I[6]=er,I[7]=Qr,I[8]=Vi,I[9]=Xr,I[10]=Gi,I[11]=Wi,I[12]=Zr,I[13]=Si,I[14]=Ii,I[15]=lr,I[16]=Ji,I[17]=Yi,I[18]=Qi,M!==0&&(I[19]=M,h.length++),h};Math.imul||(K=N);function W(L,m,c){c.negative=m.negative^L.negative,c.length=L.length+m.length;for(var h=0,v=0,_=0;_>>26)|0,v+=I>>>26,I&=67108863}c.words[_]=M,h=I,I=v}return h!==0?c.words[_]=h:c.length--,c.strip()}function Q(L,m,c){var h=new k;return h.mulp(L,m,c)}a.prototype.mulTo=function(m,c){var h,v=this.length+m.length;return this.length===10&&m.length===10?h=K(this,m,c):v<63?h=N(this,m,c):v<1024?h=W(this,m,c):h=Q(this,m,c),h};function k(L,m){this.x=L,this.y=m}k.prototype.makeRBT=function(m){for(var c=new Array(m),h=a.prototype._countBits(m)-1,v=0;v>=1;return v},k.prototype.permute=function(m,c,h,v,_,I){for(var M=0;M>>1)_++;return 1<<_+1+v},k.prototype.conjugate=function(m,c,h){if(!(h<=1))for(var v=0;v>>13,h[2*I+1]=_&8191,_=_>>>13;for(I=2*c;I>=26,c+=v/67108864|0,c+=_>>>26,this.words[h]=_&67108863}return c!==0&&(this.words[h]=c,this.length++),this},a.prototype.muln=function(m){return this.clone().imuln(m)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(m){var c=O(m);if(c.length===0)return new a(1);for(var h=this,v=0;v=0);var c=m%26,h=(m-c)/26,v=67108863>>>26-c<<26-c,_;if(c!==0){var I=0;for(_=0;_>>26-c}I&&(this.words[_]=I,this.length++)}if(h!==0){for(_=this.length-1;_>=0;_--)this.words[_+h]=this.words[_];for(_=0;_=0);var v;c?v=(c-c%26)/26:v=0;var _=m%26,I=Math.min((m-_)/26,this.length),M=67108863^67108863>>>_<<_,S=h;if(v-=I,v=Math.max(0,v),S){for(var d=0;dI)for(this.length-=I,d=0;d=0&&(g!==0||d>=v);d--){var C=this.words[d]|0;this.words[d]=g<<26-_|C>>>_,g=C&M}return S&&g!==0&&(S.words[S.length++]=g),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(m,c,h){return i(this.negative===0),this.iushrn(m,c,h)},a.prototype.shln=function(m){return this.clone().ishln(m)},a.prototype.ushln=function(m){return this.clone().iushln(m)},a.prototype.shrn=function(m){return this.clone().ishrn(m)},a.prototype.ushrn=function(m){return this.clone().iushrn(m)},a.prototype.testn=function(m){i(typeof m=="number"&&m>=0);var c=m%26,h=(m-c)/26,v=1<=0);var c=m%26,h=(m-c)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=h)return this;if(c!==0&&h++,this.length=Math.min(h,this.length),c!==0){var v=67108863^67108863>>>c<=67108864;c++)this.words[c]-=67108864,c===this.length-1?this.words[c+1]=1:this.words[c+1]++;return this.length=Math.max(this.length,c+1),this},a.prototype.isubn=function(m){if(i(typeof m=="number"),i(m<67108864),m<0)return this.iaddn(-m);if(this.negative!==0)return this.negative=0,this.iaddn(m),this.negative=1,this;if(this.words[0]-=m,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var c=0;c>26)-(S/67108864|0),this.words[_+h]=I&67108863}for(;_>26,this.words[_+h]=I&67108863;if(M===0)return this.strip();for(i(M===-1),M=0,_=0;_>26,this.words[_]=I&67108863;return this.negative=1,this.strip()},a.prototype._wordDiv=function(m,c){var h=this.length-m.length,v=this.clone(),_=m,I=_.words[_.length-1]|0,M=this._countBits(I);h=26-M,h!==0&&(_=_.ushln(h),v.iushln(h),I=_.words[_.length-1]|0);var S=v.length-_.length,d;if(c!=="mod"){d=new a(null),d.length=S+1,d.words=new Array(d.length);for(var g=0;g=0;Z--){var se=(v.words[_.length+Z]|0)*67108864+(v.words[_.length+Z-1]|0);for(se=Math.min(se/I|0,67108863),v._ishlnsubmul(_,se,Z);v.negative!==0;)se--,v.negative=0,v._ishlnsubmul(_,1,Z),v.isZero()||(v.negative^=1);d&&(d.words[Z]=se)}return d&&d.strip(),v.strip(),c!=="div"&&h!==0&&v.iushrn(h),{div:d||null,mod:v}},a.prototype.divmod=function(m,c,h){if(i(!m.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var v,_,I;return this.negative!==0&&m.negative===0?(I=this.neg().divmod(m,c),c!=="mod"&&(v=I.div.neg()),c!=="div"&&(_=I.mod.neg(),h&&_.negative!==0&&_.iadd(m)),{div:v,mod:_}):this.negative===0&&m.negative!==0?(I=this.divmod(m.neg(),c),c!=="mod"&&(v=I.div.neg()),{div:v,mod:I.mod}):this.negative&m.negative?(I=this.neg().divmod(m.neg(),c),c!=="div"&&(_=I.mod.neg(),h&&_.negative!==0&&_.isub(m)),{div:I.div,mod:_}):m.length>this.length||this.cmp(m)<0?{div:new a(0),mod:this}:m.length===1?c==="div"?{div:this.divn(m.words[0]),mod:null}:c==="mod"?{div:null,mod:new a(this.modn(m.words[0]))}:{div:this.divn(m.words[0]),mod:new a(this.modn(m.words[0]))}:this._wordDiv(m,c)},a.prototype.div=function(m){return this.divmod(m,"div",!1).div},a.prototype.mod=function(m){return this.divmod(m,"mod",!1).mod},a.prototype.umod=function(m){return this.divmod(m,"mod",!0).mod},a.prototype.divRound=function(m){var c=this.divmod(m);if(c.mod.isZero())return c.div;var h=c.div.negative!==0?c.mod.isub(m):c.mod,v=m.ushrn(1),_=m.andln(1),I=h.cmp(v);return I<0||_===1&&I===0?c.div:c.div.negative!==0?c.div.isubn(1):c.div.iaddn(1)},a.prototype.modn=function(m){i(m<=67108863);for(var c=(1<<26)%m,h=0,v=this.length-1;v>=0;v--)h=(c*h+(this.words[v]|0))%m;return h},a.prototype.idivn=function(m){i(m<=67108863);for(var c=0,h=this.length-1;h>=0;h--){var v=(this.words[h]|0)+c*67108864;this.words[h]=v/m|0,c=v%m}return this.strip()},a.prototype.divn=function(m){return this.clone().idivn(m)},a.prototype.egcd=function(m){i(m.negative===0),i(!m.isZero());var c=this,h=m.clone();c.negative!==0?c=c.umod(m):c=c.clone();for(var v=new a(1),_=new a(0),I=new a(0),M=new a(1),S=0;c.isEven()&&h.isEven();)c.iushrn(1),h.iushrn(1),++S;for(var d=h.clone(),g=c.clone();!c.isZero();){for(var C=0,Z=1;!(c.words[0]&Z)&&C<26;++C,Z<<=1);if(C>0)for(c.iushrn(C);C-- >0;)(v.isOdd()||_.isOdd())&&(v.iadd(d),_.isub(g)),v.iushrn(1),_.iushrn(1);for(var se=0,P=1;!(h.words[0]&P)&&se<26;++se,P<<=1);if(se>0)for(h.iushrn(se);se-- >0;)(I.isOdd()||M.isOdd())&&(I.iadd(d),M.isub(g)),I.iushrn(1),M.iushrn(1);c.cmp(h)>=0?(c.isub(h),v.isub(I),_.isub(M)):(h.isub(c),I.isub(v),M.isub(_))}return{a:I,b:M,gcd:h.iushln(S)}},a.prototype._invmp=function(m){i(m.negative===0),i(!m.isZero());var c=this,h=m.clone();c.negative!==0?c=c.umod(m):c=c.clone();for(var v=new a(1),_=new a(0),I=h.clone();c.cmpn(1)>0&&h.cmpn(1)>0;){for(var M=0,S=1;!(c.words[0]&S)&&M<26;++M,S<<=1);if(M>0)for(c.iushrn(M);M-- >0;)v.isOdd()&&v.iadd(I),v.iushrn(1);for(var d=0,g=1;!(h.words[0]&g)&&d<26;++d,g<<=1);if(d>0)for(h.iushrn(d);d-- >0;)_.isOdd()&&_.iadd(I),_.iushrn(1);c.cmp(h)>=0?(c.isub(h),v.isub(_)):(h.isub(c),_.isub(v))}var C;return c.cmpn(1)===0?C=v:C=_,C.cmpn(0)<0&&C.iadd(m),C},a.prototype.gcd=function(m){if(this.isZero())return m.abs();if(m.isZero())return this.abs();var c=this.clone(),h=m.clone();c.negative=0,h.negative=0;for(var v=0;c.isEven()&&h.isEven();v++)c.iushrn(1),h.iushrn(1);do{for(;c.isEven();)c.iushrn(1);for(;h.isEven();)h.iushrn(1);var _=c.cmp(h);if(_<0){var I=c;c=h,h=I}else if(_===0||h.cmpn(1)===0)break;c.isub(h)}while(!0);return h.iushln(v)},a.prototype.invm=function(m){return this.egcd(m).a.umod(m)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(m){return this.words[0]&m},a.prototype.bincn=function(m){i(typeof m=="number");var c=m%26,h=(m-c)/26,v=1<>>26,M&=67108863,this.words[I]=M}return _!==0&&(this.words[I]=_,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(m){var c=m<0;if(this.negative!==0&&!c)return-1;if(this.negative===0&&c)return 1;this.strip();var h;if(this.length>1)h=1;else{c&&(m=-m),i(m<=67108863,"Number is too big");var v=this.words[0]|0;h=v===m?0:vm.length)return 1;if(this.length=0;h--){var v=this.words[h]|0,_=m.words[h]|0;if(v!==_){v<_?c=-1:v>_&&(c=1);break}}return c},a.prototype.gtn=function(m){return this.cmpn(m)===1},a.prototype.gt=function(m){return this.cmp(m)===1},a.prototype.gten=function(m){return this.cmpn(m)>=0},a.prototype.gte=function(m){return this.cmp(m)>=0},a.prototype.ltn=function(m){return this.cmpn(m)===-1},a.prototype.lt=function(m){return this.cmp(m)===-1},a.prototype.lten=function(m){return this.cmpn(m)<=0},a.prototype.lte=function(m){return this.cmp(m)<=0},a.prototype.eqn=function(m){return this.cmpn(m)===0},a.prototype.eq=function(m){return this.cmp(m)===0},a.red=function(m){return new ae(m)},a.prototype.toRed=function(m){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),m.convertTo(this)._forceRed(m)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(m){return this.red=m,this},a.prototype.forceRed=function(m){return i(!this.red,"Already a number in reduction context"),this._forceRed(m)},a.prototype.redAdd=function(m){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,m)},a.prototype.redIAdd=function(m){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,m)},a.prototype.redSub=function(m){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,m)},a.prototype.redISub=function(m){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,m)},a.prototype.redShl=function(m){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,m)},a.prototype.redMul=function(m){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,m),this.red.mul(this,m)},a.prototype.redIMul=function(m){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,m),this.red.imul(this,m)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(m){return i(this.red&&!m.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,m)};var Y={k256:null,p224:null,p192:null,p25519:null};function $(L,m){this.name=L,this.p=new a(m,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}$.prototype._tmp=function(){var m=new a(null);return m.words=new Array(Math.ceil(this.n/13)),m},$.prototype.ireduce=function(m){var c=m,h;do this.split(c,this.tmp),c=this.imulK(c),c=c.iadd(this.tmp),h=c.bitLength();while(h>this.n);var v=h0?c.isub(this.p):c.strip!==void 0?c.strip():c._strip(),c},$.prototype.split=function(m,c){m.iushrn(this.n,0,c)},$.prototype.imulK=function(m){return m.imul(this.k)};function F(){$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(F,$),F.prototype.split=function(m,c){for(var h=4194303,v=Math.min(m.length,9),_=0;_>>22,I=M}I>>>=22,m.words[_-10]=I,I===0&&m.length>10?m.length-=10:m.length-=9},F.prototype.imulK=function(m){m.words[m.length]=0,m.words[m.length+1]=0,m.length+=2;for(var c=0,h=0;h>>=26,m.words[h]=_,c=v}return c!==0&&(m.words[m.length++]=c),m},a._prime=function(m){if(Y[m])return Y[m];var c;if(m==="k256")c=new F;else if(m==="p224")c=new G;else if(m==="p192")c=new x;else if(m==="p25519")c=new q;else throw new Error("Unknown prime "+m);return Y[m]=c,c};function ae(L){if(typeof L=="string"){var m=a._prime(L);this.m=m.p,this.prime=m}else i(L.gtn(1),"modulus must be greater than 1"),this.m=L,this.prime=null}ae.prototype._verify1=function(m){i(m.negative===0,"red works only with positives"),i(m.red,"red works only with red numbers")},ae.prototype._verify2=function(m,c){i((m.negative|c.negative)===0,"red works only with positives"),i(m.red&&m.red===c.red,"red works only with red numbers")},ae.prototype.imod=function(m){return this.prime?this.prime.ireduce(m)._forceRed(this):m.umod(this.m)._forceRed(this)},ae.prototype.neg=function(m){return m.isZero()?m.clone():this.m.sub(m)._forceRed(this)},ae.prototype.add=function(m,c){this._verify2(m,c);var h=m.add(c);return h.cmp(this.m)>=0&&h.isub(this.m),h._forceRed(this)},ae.prototype.iadd=function(m,c){this._verify2(m,c);var h=m.iadd(c);return h.cmp(this.m)>=0&&h.isub(this.m),h},ae.prototype.sub=function(m,c){this._verify2(m,c);var h=m.sub(c);return h.cmpn(0)<0&&h.iadd(this.m),h._forceRed(this)},ae.prototype.isub=function(m,c){this._verify2(m,c);var h=m.isub(c);return h.cmpn(0)<0&&h.iadd(this.m),h},ae.prototype.shl=function(m,c){return this._verify1(m),this.imod(m.ushln(c))},ae.prototype.imul=function(m,c){return this._verify2(m,c),this.imod(m.imul(c))},ae.prototype.mul=function(m,c){return this._verify2(m,c),this.imod(m.mul(c))},ae.prototype.isqr=function(m){return this.imul(m,m.clone())},ae.prototype.sqr=function(m){return this.mul(m,m)},ae.prototype.sqrt=function(m){if(m.isZero())return m.clone();var c=this.m.andln(3);if(i(c%2===1),c===3){var h=this.m.add(new a(1)).iushrn(2);return this.pow(m,h)}for(var v=this.m.subn(1),_=0;!v.isZero()&&v.andln(1)===0;)_++,v.iushrn(1);i(!v.isZero());var I=new a(1).toRed(this),M=I.redNeg(),S=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new a(2*d*d).toRed(this);this.pow(d,S).cmp(M)!==0;)d.redIAdd(M);for(var g=this.pow(d,v),C=this.pow(m,v.addn(1).iushrn(1)),Z=this.pow(m,v),se=_;Z.cmp(I)!==0;){for(var P=Z,ee=0;P.cmp(I)!==0;ee++)P=P.redSqr();i(ee=0;_--){for(var g=c.words[_],C=d-1;C>=0;C--){var Z=g>>C&1;if(I!==v[0]&&(I=this.sqr(I)),Z===0&&M===0){S=0;continue}M<<=1,M|=Z,S++,!(S!==h&&(_!==0||C!==0))&&(I=this.mul(I,v[M]),S=0,M=0)}d=26}return I},ae.prototype.convertTo=function(m){var c=m.umod(this.m);return c===m?c.clone():c},ae.prototype.convertFrom=function(m){var c=m.clone();return c.red=null,c},a.mont=function(m){return new le(m)};function le(L){ae.call(this,L),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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)}n(le,ae),le.prototype.convertTo=function(m){return this.imod(m.ushln(this.shift))},le.prototype.convertFrom=function(m){var c=this.imod(m.mul(this.rinv));return c.red=null,c},le.prototype.imul=function(m,c){if(m.isZero()||c.isZero())return m.words[0]=0,m.length=1,m;var h=m.imul(c),v=h.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=h.isub(v).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},le.prototype.mul=function(m,c){if(m.isZero()||c.isZero())return new a(0)._forceRed(this);var h=m.mul(c),v=h.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=h.isub(v).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},le.prototype.invm=function(m){var c=this.imod(m._invmp(this.m).mul(this.r2));return c._forceRed(this)}})(r,Dv)})(Cd);var vs=Cd.exports,ya=Xv;function Xv(r,e){if(!r)throw new Error(e||"Assertion failed")}Xv.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Dd={};(function(r){var e=r;function t(a,f){if(Array.isArray(a))return a.slice();if(!a)return[];var u=[];if(typeof a!="string"){for(var b=0;b>8,A=p&255;y?u.push(y,A):u.push(A)}return u}e.toArray=t;function i(a){return a.length===1?"0"+a:a}e.zero2=i;function n(a){for(var f="",u=0;u(K>>1)-1?Q=(K>>1)-k:Q=k,W.isubn(Q)):Q=0,O[N]=Q,W.iushrn(1)}return O}e.getNAF=a;function f(y,A){var R=[[],[]];y=y.clone(),A=A.clone();for(var O=0,N=0,K;y.cmpn(-O)>0||A.cmpn(-N)>0;){var W=y.andln(3)+O&3,Q=A.andln(3)+N&3;W===3&&(W=-1),Q===3&&(Q=-1);var k;W&1?(K=y.andln(7)+O&7,(K===3||K===5)&&Q===2?k=-W:k=W):k=0,R[0].push(k);var Y;Q&1?(K=A.andln(7)+N&7,(K===3||K===5)&&W===2?Y=-Q:Y=Q):Y=0,R[1].push(Y),2*O===k+1&&(O=1-O),2*N===Y+1&&(N=1-N),y.iushrn(1),A.iushrn(1)}return R}e.getJSF=f;function u(y,A,R){var O="_"+A;y.prototype[A]=function(){return this[O]!==void 0?this[O]:this[O]=R.call(this)}}e.cachedProperty=u;function b(y){return typeof y=="string"?e.toArray(y,"hex"):y}e.parseBytes=b;function p(y){return new t(y,"hex","le")}e.intFromLE=p})(xi);var Ld={exports:{}},fl;Ld.exports=function(e){return fl||(fl=new Ds(null)),fl.generate(e)};function Ds(r){this.rand=r}Ld.exports.Rand=Ds;Ds.prototype.generate=function(e){return this._rand(e)};Ds.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Nh=zs;zs.prototype.point=function(){throw new Error("Not implemented")};zs.prototype.validate=function(){throw new Error("Not implemented")};zs.prototype._fixedNafMul=function(e,t){fh(e.precomputed);var i=e._getDoubles(),n=ch(t,1,this._bitLength),a=(1<=u;p--)b=(b<<1)+n[p];f.push(b)}for(var y=this.jpoint(null,null,null),A=this.jpoint(null,null,null),R=a;R>0;R--){for(u=0;u=0;b--){for(var p=0;b>=0&&f[b]===0;b--)p++;if(b>=0&&p++,u=u.dblp(p),b<0)break;var y=f[b];fh(y!==0),e.type==="affine"?y>0?u=u.mixedAdd(a[y-1>>1]):u=u.mixedAdd(a[-y-1>>1].neg()):y>0?u=u.add(a[y-1>>1]):u=u.add(a[-y-1>>1].neg())}return e.type==="affine"?u.toP():u};zs.prototype._wnafMulAdd=function(e,t,i,n,a){var f=this._wnafT1,u=this._wnafT2,b=this._wnafT3,p=0,y,A,R;for(y=0;y=1;y-=2){var N=y-1,K=y;if(f[N]!==1||f[K]!==1){b[N]=ch(i[N],f[N],this._bitLength),b[K]=ch(i[K],f[K],this._bitLength),p=Math.max(b[N].length,p),p=Math.max(b[K].length,p);continue}var W=[t[N],null,null,t[K]];t[N].y.cmp(t[K].y)===0?(W[1]=t[N].add(t[K]),W[2]=t[N].toJ().mixedAdd(t[K].neg())):t[N].y.cmp(t[K].y.redNeg())===0?(W[1]=t[N].toJ().mixedAdd(t[K]),W[2]=t[N].add(t[K].neg())):(W[1]=t[N].toJ().mixedAdd(t[K]),W[2]=t[N].toJ().mixedAdd(t[K].neg()));var Q=[-3,-1,-5,-7,0,7,5,1,3],k=B_(i[N],i[K]);for(p=Math.max(k[0].length,p),b[N]=new Array(p),b[K]=new Array(p),A=0;A=0;y--){for(var x=0;y>=0;){var q=!0;for(A=0;A=0&&x++,F=F.dblp(x),y<0)break;for(A=0;A0?R=u[A][ae-1>>1]:ae<0&&(R=u[A][-ae-1>>1].neg()),R.type==="affine"?F=F.mixedAdd(R):F=F.add(R))}}for(y=0;y=Math.ceil((e.bitLength()+1)/t.step):!1};Hi.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,a=0;a=0&&(O=p,N=y),A.negative&&(A=A.neg(),R=R.neg()),O.negative&&(O=O.neg(),N=N.neg()),[{a:A,b:R},{a:O,b:N}]};Ki.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],a=n.b.mul(e).divRound(this.n),f=i.b.neg().mul(e).divRound(this.n),u=a.mul(i.a),b=f.mul(n.a),p=a.mul(i.b),y=f.mul(n.b),A=e.sub(u).sub(b),R=p.add(y).neg();return{k1:A,k2:R}};Ki.prototype.pointFromX=function(e,t){e=new nr(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var a=n.fromRed().isOdd();return(t&&!a||!t&&a)&&(n=n.redNeg()),this.point(e,n)};Ki.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),a=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(a).cmpn(0)===0};Ki.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,a=this._endoWnafT2,f=0;f":""};Ir.prototype.isInfinity=function(){return this.inf};Ir.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};Ir.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),a=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),f=a.redSqr().redISub(this.x.redAdd(this.x)),u=a.redMul(this.x.redSub(f)).redISub(this.y);return this.curve.point(f,u)};Ir.prototype.getX=function(){return this.x.fromRed()};Ir.prototype.getY=function(){return this.y.fromRed()};Ir.prototype.mul=function(e){return e=new nr(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Ir.prototype.mulAdd=function(e,t,i){var n=[this,t],a=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,a):this.curve._wnafMulAdd(1,n,a,2)};Ir.prototype.jmulAdd=function(e,t,i){var n=[this,t],a=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,a,!0):this.curve._wnafMulAdd(1,n,a,2,!0)};Ir.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Ir.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(a){return a.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};Ir.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Rr(r,e,t,i){fo.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new nr(0)):(this.x=new nr(e,16),this.y=new nr(t,16),this.z=new nr(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Bd(Rr,fo.BasePoint);Ki.prototype.jpoint=function(e,t,i){return new Rr(this,e,t,i)};Rr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};Rr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Rr.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),a=e.x.redMul(i),f=this.y.redMul(t.redMul(e.z)),u=e.y.redMul(i.redMul(this.z)),b=n.redSub(a),p=f.redSub(u);if(b.cmpn(0)===0)return p.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var y=b.redSqr(),A=y.redMul(b),R=n.redMul(y),O=p.redSqr().redIAdd(A).redISub(R).redISub(R),N=p.redMul(R.redISub(O)).redISub(f.redMul(A)),K=this.z.redMul(e.z).redMul(b);return this.curve.jpoint(O,N,K)};Rr.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),a=this.y,f=e.y.redMul(t).redMul(this.z),u=i.redSub(n),b=a.redSub(f);if(u.cmpn(0)===0)return b.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var p=u.redSqr(),y=p.redMul(u),A=i.redMul(p),R=b.redSqr().redIAdd(y).redISub(A).redISub(A),O=b.redMul(A.redISub(R)).redISub(a.redMul(y)),N=this.z.redMul(u);return this.curve.jpoint(R,O,N)};Rr.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(a),this.x.cmp(i)===0)return!0}};Rr.prototype.inspect=function(){return this.isInfinity()?"":""};Rr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Xa=vs,eb=xh,Th=Nh,j_=xi;function ho(r){Th.call(this,"mont",r),this.a=new Xa(r.a,16).toRed(this.red),this.b=new Xa(r.b,16).toRed(this.red),this.i4=new Xa(4).toRed(this.red).redInvm(),this.two=new Xa(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}eb(ho,Th);var k_=ho;ho.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),a=n.redSqrt();return a.redSqr().cmp(n)===0};function Sr(r,e,t){Th.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Xa(e,16),this.z=new Xa(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}eb(Sr,Th.BasePoint);ho.prototype.decodePoint=function(e,t){return this.point(j_.toArray(e,t),1)};ho.prototype.point=function(e,t){return new Sr(this,e,t)};ho.prototype.pointFromJSON=function(e){return Sr.fromJSON(this,e)};Sr.prototype.precompute=function(){};Sr.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};Sr.fromJSON=function(e,t){return new Sr(e,t[0],t[1]||e.one)};Sr.prototype.inspect=function(){return this.isInfinity()?"":""};Sr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};Sr.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),a=t.redSub(n),f=t.redMul(n),u=a.redMul(n.redAdd(this.curve.a24.redMul(a)));return this.curve.point(f,u)};Sr.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};Sr.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),a=e.x.redAdd(e.z),f=e.x.redSub(e.z),u=f.redMul(i),b=a.redMul(n),p=t.z.redMul(u.redAdd(b).redSqr()),y=t.x.redMul(u.redISub(b).redSqr());return this.curve.point(p,y)};Sr.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),a=this,f=[];t.cmpn(0)!==0;t.iushrn(1))f.push(t.andln(1));for(var u=f.length-1;u>=0;u--)f[u]===0?(i=i.diffAdd(n,a),n=n.dbl()):(n=i.diffAdd(n,a),i=i.dbl());return n};Sr.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};Sr.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};Sr.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};Sr.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};Sr.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var F_=xi,us=vs,tb=xh,Ch=Nh,H_=F_.assert;function Fn(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,Ch.call(this,"edwards",r),this.a=new us(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new us(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new us(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),H_(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}tb(Fn,Ch);var K_=Fn;Fn.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Fn.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Fn.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};Fn.prototype.pointFromX=function(e,t){e=new us(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),a=this.one.redSub(this.c2.redMul(this.d).redMul(i)),f=n.redMul(a.redInvm()),u=f.redSqrt();if(u.redSqr().redSub(f).cmp(this.zero)!==0)throw new Error("invalid point");var b=u.fromRed().isOdd();return(t&&!b||!t&&b)&&(u=u.redNeg()),this.point(e,u)};Fn.prototype.pointFromY=function(e,t){e=new us(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),a=i.redMul(this.d).redMul(this.c2).redSub(this.a),f=n.redMul(a.redInvm());if(f.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var u=f.redSqrt();if(u.redSqr().redSub(f).cmp(this.zero)!==0)throw new Error("invalid point");return u.fromRed().isOdd()!==t&&(u=u.redNeg()),this.point(u,e)};Fn.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),a=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(a)===0};function Wt(r,e,t,i,n){Ch.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new us(e,16),this.y=new us(t,16),this.z=i?new us(i,16):this.curve.one,this.t=n&&new us(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}tb(Wt,Ch.BasePoint);Fn.prototype.pointFromJSON=function(e){return Wt.fromJSON(this,e)};Fn.prototype.point=function(e,t,i,n){return new Wt(this,e,t,i,n)};Wt.fromJSON=function(e,t){return new Wt(e,t[0],t[1],t[2])};Wt.prototype.inspect=function(){return this.isInfinity()?"":""};Wt.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Wt.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),a=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),f=n.redAdd(t),u=f.redSub(i),b=n.redSub(t),p=a.redMul(u),y=f.redMul(b),A=a.redMul(b),R=u.redMul(f);return this.curve.point(p,y,R,A)};Wt.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,a,f,u,b,p;if(this.curve.twisted){u=this.curve._mulA(t);var y=u.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(y.redSub(this.curve.two)),a=y.redMul(u.redSub(i)),f=y.redSqr().redSub(y).redSub(y)):(b=this.z.redSqr(),p=y.redSub(b).redISub(b),n=e.redSub(t).redISub(i).redMul(p),a=y.redMul(u.redSub(i)),f=y.redMul(p))}else u=t.redAdd(i),b=this.curve._mulC(this.z).redSqr(),p=u.redSub(b).redSub(b),n=this.curve._mulC(e.redISub(u)).redMul(p),a=this.curve._mulC(u).redMul(t.redISub(i)),f=u.redMul(p);return this.curve.point(n,a,f)};Wt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Wt.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),a=this.z.redMul(e.z.redAdd(e.z)),f=i.redSub(t),u=a.redSub(n),b=a.redAdd(n),p=i.redAdd(t),y=f.redMul(u),A=b.redMul(p),R=f.redMul(p),O=u.redMul(b);return this.curve.point(y,A,O,R)};Wt.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),a=this.y.redMul(e.y),f=this.curve.d.redMul(n).redMul(a),u=i.redSub(f),b=i.redAdd(f),p=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(a),y=t.redMul(u).redMul(p),A,R;return this.curve.twisted?(A=t.redMul(b).redMul(a.redSub(this.curve._mulA(n))),R=u.redMul(b)):(A=t.redMul(b).redMul(a.redSub(n)),R=this.curve._mulC(u).redMul(b)),this.curve.point(y,A,R)};Wt.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Wt.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Wt.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Wt.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Wt.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Wt.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Wt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Wt.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Wt.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Wt.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Wt.prototype.toP=Wt.prototype.normalize;Wt.prototype.mixedAdd=Wt.prototype.add;(function(r){var e=r;e.base=Nh,e.short=z_,e.mont=k_,e.edwards=K_})(qd);var Dh={},Lh={},Ot={},V_=ya,G_=xh;Ot.inherits=G_;function W_(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function J_(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=a&63|128):W_(r,n)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=a>>18|240,t[i++]=a>>12&63|128,t[i++]=a>>6&63|128,t[i++]=a&63|128):(t[i++]=a>>12|224,t[i++]=a>>6&63|128,t[i++]=a&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ot.htonl=rb;function Q_(r,e){for(var t="",i=0;i>>0}return a}Ot.join32=X_;function Z_(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=a>>>16&255,t[n+2]=a>>>8&255,t[n+3]=a&255):(t[n+3]=a>>>24,t[n+2]=a>>>16&255,t[n+1]=a>>>8&255,t[n]=a&255)}return t}Ot.split32=Z_;function e7(r,e){return r>>>e|r<<32-e}Ot.rotr32=e7;function t7(r,e){return r<>>32-e}Ot.rotl32=t7;function r7(r,e){return r+e>>>0}Ot.sum32=r7;function i7(r,e,t){return r+e+t>>>0}Ot.sum32_3=i7;function n7(r,e,t,i){return r+e+t+i>>>0}Ot.sum32_4=n7;function s7(r,e,t,i,n){return r+e+t+i+n>>>0}Ot.sum32_5=s7;function a7(r,e,t,i){var n=r[e],a=r[e+1],f=i+a>>>0,u=(f>>0,r[e+1]=f}Ot.sum64=a7;function o7(r,e,t,i){var n=e+i>>>0,a=(n>>0}Ot.sum64_hi=o7;function c7(r,e,t,i){var n=e+i;return n>>>0}Ot.sum64_lo=c7;function f7(r,e,t,i,n,a,f,u){var b=0,p=e;p=p+i>>>0,b+=p>>0,b+=p>>0,b+=p>>0}Ot.sum64_4_hi=f7;function h7(r,e,t,i,n,a,f,u){var b=e+i+a+u;return b>>>0}Ot.sum64_4_lo=h7;function u7(r,e,t,i,n,a,f,u,b,p){var y=0,A=e;A=A+i>>>0,y+=A>>0,y+=A>>0,y+=A>>0,y+=A>>0}Ot.sum64_5_hi=u7;function l7(r,e,t,i,n,a,f,u,b,p){var y=e+i+a+u+p;return y>>>0}Ot.sum64_5_lo=l7;function d7(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ot.rotr64_hi=d7;function p7(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ot.rotr64_lo=p7;function g7(r,e,t){return r>>>t}Ot.shr64_hi=g7;function v7(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ot.shr64_lo=v7;var uo={},_1=Ot,b7=ya;function qh(){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}uo.BlockHash=qh;qh.prototype.update=function(e,t){if(e=_1.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=_1.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[a++]=e>>>16&255,n[a++]=e>>>8&255,n[a++]=e&255}else for(n[a++]=e&255,n[a++]=e>>>8&255,n[a++]=e>>>16&255,n[a++]=e>>>24&255,n[a++]=0,n[a++]=0,n[a++]=0,n[a++]=0,f=8;f>>3}Hn.g0_256=A7;function E7(r){return Rn(r,17)^Rn(r,19)^r>>>10}Hn.g1_256=E7;var ro=Ot,x7=uo,S7=Hn,hl=ro.rotl32,Ko=ro.sum32,I7=ro.sum32_5,M7=S7.ft_1,cb=x7.BlockHash,P7=[1518500249,1859775393,2400959708,3395469782];function Un(){if(!(this instanceof Un))return new Un;cb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}ro.inherits(Un,cb);var O7=Un;Un.blockSize=512;Un.outSize=160;Un.hmacStrength=80;Un.padLength=64;Un.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;nthis.blockSize&&(e=new this.Hash().update(e).digest()),v9(e.length<=this.blockSize);for(var t=e.length;t=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var w9=Bs;Bs.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var a=0;a=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Bs.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=ha.toArray(i,n||"hex"),this._update(i));for(var a=[];a.length"};var hh=vs,Ud=xi,x9=Ud.assert;function Bh(r,e){if(r instanceof Bh)return r;this._importDER(r,e)||(x9(r.r&&r.s,"Signature without r or s"),this.r=new hh(r.r,16),this.s=new hh(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var S9=Bh;function I9(){this.place=0}function pl(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,a=0,f=e.place;a>>=0;return n<=127?!1:(e.place=f,n)}function I1(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Bh.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=I1(t),i=I1(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];gl(n,t.length),n=n.concat(t),n.push(2),gl(n,i.length);var a=n.concat(i),f=[48];return gl(f,a.length),f=f.concat(a),Ud.encode(f,e)};var ua=vs,wb=w9,M9=xi,vl=Dh,P9=Zv,_b=M9.assert,$d=E9,Uh=S9;function ki(r){if(!(this instanceof ki))return new ki(r);typeof r=="string"&&(_b(Object.prototype.hasOwnProperty.call(vl,r),"Unknown curve "+r),r=vl[r]),r instanceof vl.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var O9=ki;ki.prototype.keyPair=function(e){return new $d(this,e)};ki.prototype.keyFromPrivate=function(e,t){return $d.fromPrivate(this,e,t)};ki.prototype.keyFromPublic=function(e,t){return $d.fromPublic(this,e,t)};ki.prototype.genKeyPair=function(e){e||(e={});for(var t=new wb({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||P9(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new ua(2));;){var a=new ua(t.generate(i));if(!(a.cmp(n)>0))return a.iaddn(1),this.keyFromPrivate(a)}};ki.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};ki.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new ua(e,16));for(var a=this.n.byteLength(),f=t.getPrivate().toArray("be",a),u=e.toArray("be",a),b=new wb({hash:this.hash,entropy:f,nonce:u,pers:n.pers,persEnc:n.persEnc||"utf8"}),p=this.n.sub(new ua(1)),y=0;;y++){var A=n.k?n.k(y):new ua(b.generate(this.n.byteLength()));if(A=this._truncateToN(A,!0),!(A.cmpn(1)<=0||A.cmp(p)>=0)){var R=this.g.mul(A);if(!R.isInfinity()){var O=R.getX(),N=O.umod(this.n);if(N.cmpn(0)!==0){var K=A.invm(this.n).mul(N.mul(t.getPrivate()).iadd(e));if(K=K.umod(this.n),K.cmpn(0)!==0){var W=(R.getY().isOdd()?1:0)|(O.cmp(N)!==0?2:0);return n.canonical&&K.cmp(this.nh)>0&&(K=this.n.sub(K),W^=1),new Uh({r:N,s:K,recoveryParam:W})}}}}}};ki.prototype.verify=function(e,t,i,n){e=this._truncateToN(new ua(e,16)),i=this.keyFromPublic(i,n),t=new Uh(t,"hex");var a=t.r,f=t.s;if(a.cmpn(1)<0||a.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),b=u.mul(e).umod(this.n),p=u.mul(a).umod(this.n),y;return this.curve._maxwellTrick?(y=this.g.jmulAdd(b,i.getPublic(),p),y.isInfinity()?!1:y.eqXToP(a)):(y=this.g.mulAdd(b,i.getPublic(),p),y.isInfinity()?!1:y.getX().umod(this.n).cmp(a)===0)};ki.prototype.recoverPubKey=function(r,e,t,i){_b((3&t)===t,"The recovery param is more than two bits"),e=new Uh(e,i);var n=this.n,a=new ua(r),f=e.r,u=e.s,b=t&1,p=t>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&p)throw new Error("Unable to find sencond key candinate");p?f=this.curve.pointFromX(f.add(this.curve.n),b):f=this.curve.pointFromX(f,b);var y=e.r.invm(n),A=n.sub(a).mul(y).umod(n),R=u.mul(y).umod(n);return this.g.mulAdd(A,f,R)};ki.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new Uh(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var a;try{a=this.recoverPubKey(r,e,n)}catch{continue}if(a.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var xc=xi,Ab=xc.assert,M1=xc.parseBytes,go=xc.cachedProperty;function xr(r,e){this.eddsa=r,this._secret=M1(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=M1(e.pub)}xr.fromPublic=function(e,t){return t instanceof xr?t:new xr(e,{pub:t})};xr.fromSecret=function(e,t){return t instanceof xr?t:new xr(e,{secret:t})};xr.prototype.secret=function(){return this._secret};go(xr,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});go(xr,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});go(xr,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});go(xr,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});go(xr,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});go(xr,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});xr.prototype.sign=function(e){return Ab(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};xr.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};xr.prototype.getSecret=function(e){return Ab(this._secret,"KeyPair is public only"),xc.encode(this.secret(),e)};xr.prototype.getPublic=function(e){return xc.encode(this.pubBytes(),e)};var R9=xr,N9=vs,$h=xi,P1=$h.assert,zh=$h.cachedProperty,T9=$h.parseBytes;function wa(r,e){this.eddsa=r,typeof e!="object"&&(e=T9(e)),Array.isArray(e)&&(P1(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),P1(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof N9&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}zh(wa,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});zh(wa,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});zh(wa,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});zh(wa,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});wa.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};wa.prototype.toHex=function(){return $h.encode(this.toBytes(),"hex").toUpperCase()};var C9=wa,D9=Lh,L9=Dh,so=xi,q9=so.assert,Eb=so.parseBytes,xb=R9,O1=C9;function ui(r){if(q9(r==="ed25519","only tested with ed25519 so far"),!(this instanceof ui))return new ui(r);r=L9[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=D9.sha512}var B9=ui;ui.prototype.sign=function(e,t){e=Eb(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),a=this.g.mul(n),f=this.encodePoint(a),u=this.hashInt(f,i.pubBytes(),e).mul(i.priv()),b=n.add(u).umod(this.curve.n);return this.makeSignature({R:a,S:b,Rencoded:f})};ui.prototype.verify=function(e,t,i){if(e=Eb(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),a=this.hashInt(t.Rencoded(),n.pubBytes(),e),f=this.g.mul(t.S()),u=t.R().add(n.pub().mul(a));return u.eq(f)};ui.prototype.hashInt=function(){for(var e=this.hash(),t=0;t0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=b[y++],p--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(p>=this.blockSize&&(y=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,b,y,p),p%=this.blockSize);p>0;)this._buffer[this._bufferLength++]=b[y++],p--;return this},u.prototype.finish=function(b){if(!this._finished){var p=this._bytesHashed,y=this._bufferLength,A=p/536870912|0,R=p<<3,O=p%128<112?128:256;this._buffer[y]=128;for(var N=y+1;N0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},u.prototype.restoreState=function(b){return this._stateHi.set(b.stateHi),this._stateLo.set(b.stateLo),this._bufferLength=b.bufferLength,b.buffer&&this._buffer.set(b.buffer),this._bytesHashed=b.bytesHashed,this._finished=!1,this},u.prototype.cleanSavedState=function(b){t.wipe(b.stateHi),t.wipe(b.stateLo),b.buffer&&t.wipe(b.buffer),b.bufferLength=0,b.bytesHashed=0},u}();r.SHA512=i;var n=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function a(u,b,p,y,A,R,O){for(var N=p[0],K=p[1],W=p[2],Q=p[3],k=p[4],Y=p[5],$=p[6],F=p[7],G=y[0],x=y[1],q=y[2],ae=y[3],le=y[4],L=y[5],m=y[6],c=y[7],h,v,_,I,M,S,d,g;O>=128;){for(var C=0;C<16;C++){var Z=8*C+R;u[C]=e.readUint32BE(A,Z),b[C]=e.readUint32BE(A,Z+4)}for(var C=0;C<80;C++){var se=N,P=K,ee=W,B=Q,j=k,H=Y,w=$,z=F,ne=G,ce=x,he=q,ye=ae,we=le,Te=L,Qe=m,Oe=c;if(h=F,v=c,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=(k>>>14|le<<18)^(k>>>18|le<<14)^(le>>>9|k<<23),v=(le>>>14|k<<18)^(le>>>18|k<<14)^(k>>>9|le<<23),M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,h=k&Y^~k&$,v=le&L^~le&m,M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,h=n[C*2],v=n[C*2+1],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,h=u[C%16],v=b[C%16],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,_=d&65535|g<<16,I=M&65535|S<<16,h=_,v=I,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=(N>>>28|G<<4)^(G>>>2|N<<30)^(G>>>7|N<<25),v=(G>>>28|N<<4)^(N>>>2|G<<30)^(N>>>7|G<<25),M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,h=N&K^N&W^K&W,v=G&x^G&q^x&q,M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,z=d&65535|g<<16,Oe=M&65535|S<<16,h=B,v=ye,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=_,v=I,M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,B=d&65535|g<<16,ye=M&65535|S<<16,K=se,W=P,Q=ee,k=B,Y=j,$=H,F=w,N=z,x=ne,q=ce,ae=he,le=ye,L=we,m=Te,c=Qe,G=Oe,C%16===15)for(var Z=0;Z<16;Z++)h=u[Z],v=b[Z],M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=u[(Z+9)%16],v=b[(Z+9)%16],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,_=u[(Z+1)%16],I=b[(Z+1)%16],h=(_>>>1|I<<31)^(_>>>8|I<<24)^_>>>7,v=(I>>>1|_<<31)^(I>>>8|_<<24)^(I>>>7|_<<25),M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,_=u[(Z+14)%16],I=b[(Z+14)%16],h=(_>>>19|I<<13)^(I>>>29|_<<3)^_>>>6,v=(I>>>19|_<<13)^(_>>>29|I<<3)^(I>>>6|_<<26),M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,u[Z]=d&65535|g<<16,b[Z]=M&65535|S<<16}h=N,v=G,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[0],v=y[0],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[0]=N=d&65535|g<<16,y[0]=G=M&65535|S<<16,h=K,v=x,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[1],v=y[1],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[1]=K=d&65535|g<<16,y[1]=x=M&65535|S<<16,h=W,v=q,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[2],v=y[2],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[2]=W=d&65535|g<<16,y[2]=q=M&65535|S<<16,h=Q,v=ae,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[3],v=y[3],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[3]=Q=d&65535|g<<16,y[3]=ae=M&65535|S<<16,h=k,v=le,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[4],v=y[4],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[4]=k=d&65535|g<<16,y[4]=le=M&65535|S<<16,h=Y,v=L,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[5],v=y[5],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[5]=Y=d&65535|g<<16,y[5]=L=M&65535|S<<16,h=$,v=m,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[6],v=y[6],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[6]=$=d&65535|g<<16,y[6]=m=M&65535|S<<16,h=F,v=c,M=v&65535,S=v>>>16,d=h&65535,g=h>>>16,h=p[7],v=y[7],M+=v&65535,S+=v>>>16,d+=h&65535,g+=h>>>16,S+=M>>>16,d+=S>>>16,g+=d>>>16,p[7]=F=d&65535|g<<16,y[7]=c=M&65535|S<<16,R+=128,O-=128}return R}function f(u){var b=new i;b.update(u);var p=b.digest();return b.clean(),p}r.hash=f})(Sb);(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertSecretKeyToX25519=r.convertPublicKeyToX25519=r.verify=r.sign=r.extractPublicKeyFromSecretKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.SEED_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=r.SIGNATURE_LENGTH=void 0;const e=$s,t=Sb,i=Ei;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function n(B){const j=new Float64Array(16);if(B)for(let H=0;H>16&1),H[ce-1]&=65535;H[15]=w[15]-32767-(H[14]>>16&1);const ne=H[15]>>16&1;H[14]&=65535,K(w,H,1-ne)}for(let z=0;z<16;z++)B[2*z]=w[z]&255,B[2*z+1]=w[z]>>8}function Q(B,j){let H=0;for(let w=0;w<32;w++)H|=B[w]^j[w];return(1&H-1>>>8)-1}function k(B,j){const H=new Uint8Array(32),w=new Uint8Array(32);return W(H,B),W(w,j),Q(H,w)}function Y(B){const j=new Uint8Array(32);return W(j,B),j[0]&1}function $(B,j){for(let H=0;H<16;H++)B[H]=j[2*H]+(j[2*H+1]<<8);B[15]&=32767}function F(B,j,H){for(let w=0;w<16;w++)B[w]=j[w]+H[w]}function G(B,j,H){for(let w=0;w<16;w++)B[w]=j[w]-H[w]}function x(B,j,H){let w,z,ne=0,ce=0,he=0,ye=0,we=0,Te=0,Qe=0,Oe=0,Ce=0,Ie=0,me=0,Re=0,De=0,ve=0,Ne=0,Se=0,be=0,Ue=0,Me=0,_e=0,He=0,Ve=0,Ee=0,Ke=0,ut=0,Ge=0,_t=0,lt=0,Je=0,Et=0,It=0,Le=H[0],Xe=H[1],tt=H[2],qe=H[3],et=H[4],Ze=H[5],ze=H[6],ft=H[7],rt=H[8],je=H[9],it=H[10],st=H[11],Be=H[12],Ye=H[13],ht=H[14],ke=H[15];w=j[0],ne+=w*Le,ce+=w*Xe,he+=w*tt,ye+=w*qe,we+=w*et,Te+=w*Ze,Qe+=w*ze,Oe+=w*ft,Ce+=w*rt,Ie+=w*je,me+=w*it,Re+=w*st,De+=w*Be,ve+=w*Ye,Ne+=w*ht,Se+=w*ke,w=j[1],ce+=w*Le,he+=w*Xe,ye+=w*tt,we+=w*qe,Te+=w*et,Qe+=w*Ze,Oe+=w*ze,Ce+=w*ft,Ie+=w*rt,me+=w*je,Re+=w*it,De+=w*st,ve+=w*Be,Ne+=w*Ye,Se+=w*ht,be+=w*ke,w=j[2],he+=w*Le,ye+=w*Xe,we+=w*tt,Te+=w*qe,Qe+=w*et,Oe+=w*Ze,Ce+=w*ze,Ie+=w*ft,me+=w*rt,Re+=w*je,De+=w*it,ve+=w*st,Ne+=w*Be,Se+=w*Ye,be+=w*ht,Ue+=w*ke,w=j[3],ye+=w*Le,we+=w*Xe,Te+=w*tt,Qe+=w*qe,Oe+=w*et,Ce+=w*Ze,Ie+=w*ze,me+=w*ft,Re+=w*rt,De+=w*je,ve+=w*it,Ne+=w*st,Se+=w*Be,be+=w*Ye,Ue+=w*ht,Me+=w*ke,w=j[4],we+=w*Le,Te+=w*Xe,Qe+=w*tt,Oe+=w*qe,Ce+=w*et,Ie+=w*Ze,me+=w*ze,Re+=w*ft,De+=w*rt,ve+=w*je,Ne+=w*it,Se+=w*st,be+=w*Be,Ue+=w*Ye,Me+=w*ht,_e+=w*ke,w=j[5],Te+=w*Le,Qe+=w*Xe,Oe+=w*tt,Ce+=w*qe,Ie+=w*et,me+=w*Ze,Re+=w*ze,De+=w*ft,ve+=w*rt,Ne+=w*je,Se+=w*it,be+=w*st,Ue+=w*Be,Me+=w*Ye,_e+=w*ht,He+=w*ke,w=j[6],Qe+=w*Le,Oe+=w*Xe,Ce+=w*tt,Ie+=w*qe,me+=w*et,Re+=w*Ze,De+=w*ze,ve+=w*ft,Ne+=w*rt,Se+=w*je,be+=w*it,Ue+=w*st,Me+=w*Be,_e+=w*Ye,He+=w*ht,Ve+=w*ke,w=j[7],Oe+=w*Le,Ce+=w*Xe,Ie+=w*tt,me+=w*qe,Re+=w*et,De+=w*Ze,ve+=w*ze,Ne+=w*ft,Se+=w*rt,be+=w*je,Ue+=w*it,Me+=w*st,_e+=w*Be,He+=w*Ye,Ve+=w*ht,Ee+=w*ke,w=j[8],Ce+=w*Le,Ie+=w*Xe,me+=w*tt,Re+=w*qe,De+=w*et,ve+=w*Ze,Ne+=w*ze,Se+=w*ft,be+=w*rt,Ue+=w*je,Me+=w*it,_e+=w*st,He+=w*Be,Ve+=w*Ye,Ee+=w*ht,Ke+=w*ke,w=j[9],Ie+=w*Le,me+=w*Xe,Re+=w*tt,De+=w*qe,ve+=w*et,Ne+=w*Ze,Se+=w*ze,be+=w*ft,Ue+=w*rt,Me+=w*je,_e+=w*it,He+=w*st,Ve+=w*Be,Ee+=w*Ye,Ke+=w*ht,ut+=w*ke,w=j[10],me+=w*Le,Re+=w*Xe,De+=w*tt,ve+=w*qe,Ne+=w*et,Se+=w*Ze,be+=w*ze,Ue+=w*ft,Me+=w*rt,_e+=w*je,He+=w*it,Ve+=w*st,Ee+=w*Be,Ke+=w*Ye,ut+=w*ht,Ge+=w*ke,w=j[11],Re+=w*Le,De+=w*Xe,ve+=w*tt,Ne+=w*qe,Se+=w*et,be+=w*Ze,Ue+=w*ze,Me+=w*ft,_e+=w*rt,He+=w*je,Ve+=w*it,Ee+=w*st,Ke+=w*Be,ut+=w*Ye,Ge+=w*ht,_t+=w*ke,w=j[12],De+=w*Le,ve+=w*Xe,Ne+=w*tt,Se+=w*qe,be+=w*et,Ue+=w*Ze,Me+=w*ze,_e+=w*ft,He+=w*rt,Ve+=w*je,Ee+=w*it,Ke+=w*st,ut+=w*Be,Ge+=w*Ye,_t+=w*ht,lt+=w*ke,w=j[13],ve+=w*Le,Ne+=w*Xe,Se+=w*tt,be+=w*qe,Ue+=w*et,Me+=w*Ze,_e+=w*ze,He+=w*ft,Ve+=w*rt,Ee+=w*je,Ke+=w*it,ut+=w*st,Ge+=w*Be,_t+=w*Ye,lt+=w*ht,Je+=w*ke,w=j[14],Ne+=w*Le,Se+=w*Xe,be+=w*tt,Ue+=w*qe,Me+=w*et,_e+=w*Ze,He+=w*ze,Ve+=w*ft,Ee+=w*rt,Ke+=w*je,ut+=w*it,Ge+=w*st,_t+=w*Be,lt+=w*Ye,Je+=w*ht,Et+=w*ke,w=j[15],Se+=w*Le,be+=w*Xe,Ue+=w*tt,Me+=w*qe,_e+=w*et,He+=w*Ze,Ve+=w*ze,Ee+=w*ft,Ke+=w*rt,ut+=w*je,Ge+=w*it,_t+=w*st,lt+=w*Be,Je+=w*Ye,Et+=w*ht,It+=w*ke,ne+=38*be,ce+=38*Ue,he+=38*Me,ye+=38*_e,we+=38*He,Te+=38*Ve,Qe+=38*Ee,Oe+=38*Ke,Ce+=38*ut,Ie+=38*Ge,me+=38*_t,Re+=38*lt,De+=38*Je,ve+=38*Et,Ne+=38*It,z=1,w=ne+z+65535,z=Math.floor(w/65536),ne=w-z*65536,w=ce+z+65535,z=Math.floor(w/65536),ce=w-z*65536,w=he+z+65535,z=Math.floor(w/65536),he=w-z*65536,w=ye+z+65535,z=Math.floor(w/65536),ye=w-z*65536,w=we+z+65535,z=Math.floor(w/65536),we=w-z*65536,w=Te+z+65535,z=Math.floor(w/65536),Te=w-z*65536,w=Qe+z+65535,z=Math.floor(w/65536),Qe=w-z*65536,w=Oe+z+65535,z=Math.floor(w/65536),Oe=w-z*65536,w=Ce+z+65535,z=Math.floor(w/65536),Ce=w-z*65536,w=Ie+z+65535,z=Math.floor(w/65536),Ie=w-z*65536,w=me+z+65535,z=Math.floor(w/65536),me=w-z*65536,w=Re+z+65535,z=Math.floor(w/65536),Re=w-z*65536,w=De+z+65535,z=Math.floor(w/65536),De=w-z*65536,w=ve+z+65535,z=Math.floor(w/65536),ve=w-z*65536,w=Ne+z+65535,z=Math.floor(w/65536),Ne=w-z*65536,w=Se+z+65535,z=Math.floor(w/65536),Se=w-z*65536,ne+=z-1+37*(z-1),z=1,w=ne+z+65535,z=Math.floor(w/65536),ne=w-z*65536,w=ce+z+65535,z=Math.floor(w/65536),ce=w-z*65536,w=he+z+65535,z=Math.floor(w/65536),he=w-z*65536,w=ye+z+65535,z=Math.floor(w/65536),ye=w-z*65536,w=we+z+65535,z=Math.floor(w/65536),we=w-z*65536,w=Te+z+65535,z=Math.floor(w/65536),Te=w-z*65536,w=Qe+z+65535,z=Math.floor(w/65536),Qe=w-z*65536,w=Oe+z+65535,z=Math.floor(w/65536),Oe=w-z*65536,w=Ce+z+65535,z=Math.floor(w/65536),Ce=w-z*65536,w=Ie+z+65535,z=Math.floor(w/65536),Ie=w-z*65536,w=me+z+65535,z=Math.floor(w/65536),me=w-z*65536,w=Re+z+65535,z=Math.floor(w/65536),Re=w-z*65536,w=De+z+65535,z=Math.floor(w/65536),De=w-z*65536,w=ve+z+65535,z=Math.floor(w/65536),ve=w-z*65536,w=Ne+z+65535,z=Math.floor(w/65536),Ne=w-z*65536,w=Se+z+65535,z=Math.floor(w/65536),Se=w-z*65536,ne+=z-1+37*(z-1),B[0]=ne,B[1]=ce,B[2]=he,B[3]=ye,B[4]=we,B[5]=Te,B[6]=Qe,B[7]=Oe,B[8]=Ce,B[9]=Ie,B[10]=me,B[11]=Re,B[12]=De,B[13]=ve,B[14]=Ne,B[15]=Se}function q(B,j){x(B,j,j)}function ae(B,j){const H=n();let w;for(w=0;w<16;w++)H[w]=j[w];for(w=253;w>=0;w--)q(H,H),w!==2&&w!==4&&x(H,H,j);for(w=0;w<16;w++)B[w]=H[w]}function le(B,j){const H=n();let w;for(w=0;w<16;w++)H[w]=j[w];for(w=250;w>=0;w--)q(H,H),w!==1&&x(H,H,j);for(w=0;w<16;w++)B[w]=H[w]}function L(B,j){const H=n(),w=n(),z=n(),ne=n(),ce=n(),he=n(),ye=n(),we=n(),Te=n();G(H,B[1],B[0]),G(Te,j[1],j[0]),x(H,H,Te),F(w,B[0],B[1]),F(Te,j[0],j[1]),x(w,w,Te),x(z,B[3],j[3]),x(z,z,p),x(ne,B[2],j[2]),F(ne,ne,ne),G(ce,w,H),G(he,ne,z),F(ye,ne,z),F(we,w,H),x(B[0],ce,he),x(B[1],we,ye),x(B[2],ye,he),x(B[3],ce,we)}function m(B,j,H){for(let w=0;w<4;w++)K(B[w],j[w],H)}function c(B,j){const H=n(),w=n(),z=n();ae(z,j[2]),x(H,j[0],z),x(w,j[1],z),W(B,w),B[31]^=Y(H)<<7}function h(B,j,H){O(B[0],f),O(B[1],u),O(B[2],u),O(B[3],f);for(let w=255;w>=0;--w){const z=H[w/8|0]>>(w&7)&1;m(B,j,z),L(j,B),L(B,B),m(B,j,z)}}function v(B,j){const H=[n(),n(),n(),n()];O(H[0],y),O(H[1],A),O(H[2],u),x(H[3],y,A),h(B,H,j)}function _(B){if(B.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const j=(0,t.hash)(B);j[0]&=248,j[31]&=127,j[31]|=64;const H=new Uint8Array(32),w=[n(),n(),n(),n()];v(w,j),c(H,w);const z=new Uint8Array(64);return z.set(B),z.set(H,32),{publicKey:H,secretKey:z}}r.generateKeyPairFromSeed=_;function I(B){const j=(0,e.randomBytes)(32,B),H=_(j);return(0,i.wipe)(j),H}r.generateKeyPair=I;function M(B){if(B.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(B.subarray(32))}r.extractPublicKeyFromSecretKey=M;const S=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function d(B,j){let H,w,z,ne;for(w=63;w>=32;--w){for(H=0,z=w-32,ne=w-12;z>4)*S[z],H=j[z]>>8,j[z]&=255;for(z=0;z<32;z++)j[z]-=H*S[z];for(w=0;w<32;w++)j[w+1]+=j[w]>>8,B[w]=j[w]&255}function g(B){const j=new Float64Array(64);for(let H=0;H<64;H++)j[H]=B[H];for(let H=0;H<64;H++)B[H]=0;d(B,j)}function C(B,j){const H=new Float64Array(64),w=[n(),n(),n(),n()],z=(0,t.hash)(B.subarray(0,32));z[0]&=248,z[31]&=127,z[31]|=64;const ne=new Uint8Array(64);ne.set(z.subarray(32),32);const ce=new t.SHA512;ce.update(ne.subarray(32)),ce.update(j);const he=ce.digest();ce.clean(),g(he),v(w,he),c(ne,w),ce.reset(),ce.update(ne.subarray(0,32)),ce.update(B.subarray(32)),ce.update(j);const ye=ce.digest();g(ye);for(let we=0;we<32;we++)H[we]=he[we];for(let we=0;we<32;we++)for(let Te=0;Te<32;Te++)H[we+Te]+=ye[we]*z[Te];return d(ne.subarray(32),H),ne}r.sign=C;function Z(B,j){const H=n(),w=n(),z=n(),ne=n(),ce=n(),he=n(),ye=n();return O(B[2],u),$(B[1],j),q(z,B[1]),x(ne,z,b),G(z,z,B[2]),F(ne,B[2],ne),q(ce,ne),q(he,ce),x(ye,he,ce),x(H,ye,z),x(H,H,ne),le(H,H),x(H,H,z),x(H,H,ne),x(H,H,ne),x(B[0],H,ne),q(w,B[0]),x(w,w,ne),k(w,z)&&x(B[0],B[0],R),q(w,B[0]),x(w,w,ne),k(w,z)?-1:(Y(B[0])===j[31]>>7&&G(B[0],f,B[0]),x(B[3],B[0],B[1]),0)}function se(B,j,H){const w=new Uint8Array(32),z=[n(),n(),n(),n()],ne=[n(),n(),n(),n()];if(H.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(Z(ne,B))return!1;const ce=new t.SHA512;ce.update(H.subarray(0,32)),ce.update(B),ce.update(j);const he=ce.digest();return g(he),h(z,ne,he),v(ne,H.subarray(32)),L(z,ne),c(w,z),!Q(H,w)}r.verify=se;function P(B){let j=[n(),n(),n(),n()];if(Z(j,B))throw new Error("Ed25519: invalid public key");let H=n(),w=n(),z=j[1];F(H,u,z),G(w,u,z),ae(w,w),x(H,H,w);let ne=new Uint8Array(32);return W(ne,H),ne}r.convertPublicKeyToX25519=P;function ee(B){const j=(0,t.hash)(B.subarray(0,32));j[0]&=248,j[31]&=127,j[31]|=64;const H=new Uint8Array(j.subarray(0,32));return(0,i.wipe)(j),H}r.convertSecretKeyToX25519=ee})(zd);const U9="EdDSA",$9="JWT",uh=".",jh="base64url",Ib="utf8",Mb="utf8",z9=":",j9="did",k9="key",R1="base58btc",F9="z",H9="K36",K9=32,V9=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),G9=r=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function ga(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return G9(r)}catch{return r}}function gs(r){return typeof r=="string"?r:V9(r)||""}function N1(r){return ga(Er(Ar(r,jh),Ib))}function lh(r){return Er(Ar(gs(r),Ib),jh)}function Pb(r){const e=Ar(H9,R1),t=F9+Er(Yf([e,r]),R1);return[j9,k9,t].join(z9)}function W9(r){return Er(r,jh)}function J9(r){return Ar(r,jh)}function Y9(r){return Ar([lh(r.header),lh(r.payload)].join(uh),Mb)}function Q9(r){return[lh(r.header),lh(r.payload),W9(r.signature)].join(uh)}function nd(r){const e=r.split(uh),t=N1(e[0]),i=N1(e[1]),n=J9(e[2]),a=Ar(e.slice(0,2).join(uh),Mb);return{header:t,payload:i,signature:n,data:a}}function T1(r=$s.randomBytes(K9)){return zd.generateKeyPairFromSeed(r)}async function X9(r,e,t,i,n=xe.fromMiliseconds(Date.now())){const a={alg:U9,typ:$9},f=Pb(i.publicKey),u=n+t,b={iss:f,sub:r,aud:e,iat:n,exp:u},p=Y9({header:a,payload:b}),y=zd.sign(i.secretKey,p);return Q9({header:a,payload:b,signature:y})}const Z9={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var la={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0},eA={};const tA=":";function ac(r){const[e,t]=r.split(tA);return{namespace:e,reference:t}}function C1(r,e=[]){const t=[];return Object.keys(r).forEach(i=>{if(e.length&&!e.includes(i))return;const n=r[i];t.push(...n.accounts)}),t}function Ob(r,e){return r.includes(":")?[r]:e.chains||[]}var rA=Object.defineProperty,D1=Object.getOwnPropertySymbols,iA=Object.prototype.hasOwnProperty,nA=Object.prototype.propertyIsEnumerable,L1=(r,e,t)=>e in r?rA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,q1=(r,e)=>{for(var t in e||(e={}))iA.call(e,t)&&L1(r,t,e[t]);if(D1)for(var t of D1(e))nA.call(e,t)&&L1(r,t,e[t]);return r};const sA="ReactNative",wi={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},aA="js";function dh(){return typeof la<"u"&&typeof la.versions<"u"&&typeof la.versions.node<"u"}function vo(){return!Ih()&&!!Pd()&&navigator.product===sA}function Sc(){return!dh()&&!!Pd()&&!!Ih()}function Ic(){return vo()?wi.reactNative:dh()?wi.node:Sc()?wi.browser:wi.unknown}function oA(){var r;try{return vo()&&typeof globalThis<"u"&&typeof(globalThis==null?void 0:globalThis.Application)<"u"?(r=globalThis.Application)==null?void 0:r.applicationId:void 0}catch{return}}function cA(r,e){let t=dc.parse(r);return t=q1(q1({},t),e),r=dc.stringify(t),r}function Rb(){return Uv()||{name:"",description:"",url:"",icons:[""]}}function fA(){if(Ic()===wi.reactNative&&typeof globalThis<"u"&&typeof(globalThis==null?void 0:globalThis.Platform)<"u"){const{OS:t,Version:i}=globalThis.Platform;return[t,i].join("-")}const r=k8();if(r===null)return"unknown";const e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function hA(){var r;const e=Ic();return e===wi.browser?[e,((r=Bv())==null?void 0:r.host)||"unknown"].join(":"):e}function Nb(r,e,t){const i=fA(),n=hA();return[[r,e].join("-"),[aA,t].join("-"),i,n].join("/")}function uA({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:a,useOnCloseEvent:f,bundleId:u}){const b=t.split("?"),p=Nb(r,e,i),y={auth:n,ua:p,projectId:a,useOnCloseEvent:f||void 0,origin:u||void 0},A=cA(b[1]||"",y);return b[0]+"?"+A}function ca(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Tb(r){return Object.fromEntries(r.entries())}function Cb(r){return new Map(Object.entries(r))}function aa(r=xe.FIVE_MINUTES,e){const t=xe.toMiliseconds(r||xe.FIVE_MINUTES);let i,n,a;return{resolve:f=>{a&&i&&(clearTimeout(a),i(f))},reject:f=>{a&&n&&(clearTimeout(a),n(f))},done:()=>new Promise((f,u)=>{a=setTimeout(()=>{u(new Error(e))},t),i=f,n=u})}}function Za(r,e,t){return new Promise(async(i,n)=>{const a=setTimeout(()=>n(new Error(t)),e);try{const f=await r;i(f)}catch(f){n(f)}clearTimeout(a)})}function Db(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function lA(r){return Db("topic",r)}function dA(r){return Db("id",r)}function Lb(r){const[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function vr(r,e){return xe.fromMiliseconds(Date.now()+xe.toMiliseconds(r))}function Os(r){return Date.now()>=xe.toMiliseconds(r)}function St(r,e){return`${r}${e?`:${e}`:""}`}function Qf(r=[],e=[]){return[...new Set([...r,...e])]}async function pA({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const n=typeof t=="string"?JSON.parse(t):t,a=n==null?void 0:n.href;if(typeof a!="string")return;const f=gA(a,r,e),u=Ic();if(u===wi.browser){if(!((i=Ih())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}f.startsWith("https://")||f.startsWith("http://")?window.open(f,"_blank","noreferrer noopener"):window.open(f,bA()?"_blank":"_self","noreferrer noopener")}else u===wi.reactNative&&typeof(globalThis==null?void 0:globalThis.Linking)<"u"&&await globalThis.Linking.openURL(f)}catch(n){console.error(n)}}function gA(r,e,t){const i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){const a=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${a}${mA(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function vA(r,e){let t="";try{if(Sc()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function B1(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function U1(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function jd(){return typeof la<"u"&&eA.IS_VITEST==="true"}function bA(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function mA(r,e=!1){const t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function qb(r){return Buffer.from(r,"base64").toString("utf-8")}var Bb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function yA(r){var e=r.default;if(typeof e=="function"){var t=function(){return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),t}var Ub={exports:{}};/** +* [js-sha3]{@link https://github.com/emn178/js-sha3} +* +* @version 0.8.0 +* @author Chen, Yi-Cyuan [emn178@gmail.com] +* @copyright Chen, Yi-Cyuan 2015-2018 +* @license MIT +*/(function(r){(function(){var e="input is invalid type",t="finalize already called",i=typeof window=="object",n=i?window:{};n.JS_SHA3_NO_WINDOW&&(i=!1);var a=!i&&typeof self=="object",f=!n.JS_SHA3_NO_NODE_JS&&typeof la=="object"&&la.versions&&la.versions.node;f?n=Bb:a&&(n=self);var u=!n.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,b=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",p="0123456789abcdef".split(""),y=[31,7936,2031616,520093696],A=[4,1024,262144,67108864],R=[1,256,65536,16777216],O=[6,1536,393216,100663296],N=[0,8,16,24],K=[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],W=[224,256,384,512],Q=[128,256],k=["hex","buffer","arrayBuffer","array","digest"],Y={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(P){return Object.prototype.toString.call(P)==="[object Array]"}),b&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(P){return typeof P=="object"&&P.buffer&&P.buffer.constructor===ArrayBuffer});for(var $=function(P,ee,B){return function(j){return new C(P,ee,P).update(j)[B]()}},F=function(P,ee,B){return function(j,H){return new C(P,ee,H).update(j)[B]()}},G=function(P,ee,B){return function(j,H,w,z){return h["cshake"+P].update(j,H,w,z)[B]()}},x=function(P,ee,B){return function(j,H,w,z){return h["kmac"+P].update(j,H,w,z)[B]()}},q=function(P,ee,B,j){for(var H=0;H>5,this.byteCount=this.blockCount<<2,this.outputBlocks=B>>5,this.extraBytes=(B&31)>>3;for(var j=0;j<50;++j)this.s[j]=0}C.prototype.update=function(P){if(this.finalized)throw new Error(t);var ee,B=typeof P;if(B!=="string"){if(B==="object"){if(P===null)throw new Error(e);if(b&&P.constructor===ArrayBuffer)P=new Uint8Array(P);else if(!Array.isArray(P)&&(!b||!ArrayBuffer.isView(P)))throw new Error(e)}else throw new Error(e);ee=!0}for(var j=this.blocks,H=this.byteCount,w=P.length,z=this.blockCount,ne=0,ce=this.s,he,ye;ne>2]|=P[ne]<>2]|=ye<>2]|=(192|ye>>6)<>2]|=(128|ye&63)<=57344?(j[he>>2]|=(224|ye>>12)<>2]|=(128|ye>>6&63)<>2]|=(128|ye&63)<>2]|=(240|ye>>18)<>2]|=(128|ye>>12&63)<>2]|=(128|ye>>6&63)<>2]|=(128|ye&63)<=H){for(this.start=he-H,this.block=j[z],he=0;he>8,B=P&255;B>0;)H.unshift(B),P=P>>8,B=P&255,++j;return ee?H.push(j):H.unshift(j),this.update(H),H.length},C.prototype.encodeString=function(P){var ee,B=typeof P;if(B!=="string"){if(B==="object"){if(P===null)throw new Error(e);if(b&&P.constructor===ArrayBuffer)P=new Uint8Array(P);else if(!Array.isArray(P)&&(!b||!ArrayBuffer.isView(P)))throw new Error(e)}else throw new Error(e);ee=!0}var j=0,H=P.length;if(ee)j=H;else for(var w=0;w=57344?j+=3:(z=65536+((z&1023)<<10|P.charCodeAt(++w)&1023),j+=4)}return j+=this.encode(j*8),this.update(P),j},C.prototype.bytepad=function(P,ee){for(var B=this.encode(ee),j=0;j>2]|=this.padding[ee&3],this.lastByteIndex===this.byteCount)for(P[0]=P[B],ee=1;ee>4&15]+p[ne&15]+p[ne>>12&15]+p[ne>>8&15]+p[ne>>20&15]+p[ne>>16&15]+p[ne>>28&15]+p[ne>>24&15];w%P===0&&(se(ee),H=0)}return j&&(ne=ee[H],z+=p[ne>>4&15]+p[ne&15],j>1&&(z+=p[ne>>12&15]+p[ne>>8&15]),j>2&&(z+=p[ne>>20&15]+p[ne>>16&15])),z},C.prototype.arrayBuffer=function(){this.finalize();var P=this.blockCount,ee=this.s,B=this.outputBlocks,j=this.extraBytes,H=0,w=0,z=this.outputBits>>3,ne;j?ne=new ArrayBuffer(B+1<<2):ne=new ArrayBuffer(z);for(var ce=new Uint32Array(ne);w>8&255,z[ne+2]=ce>>16&255,z[ne+3]=ce>>24&255;w%P===0&&se(ee)}return j&&(ne=w<<2,ce=ee[H],z[ne]=ce&255,j>1&&(z[ne+1]=ce>>8&255),j>2&&(z[ne+2]=ce>>16&255)),z};function Z(P,ee,B){C.call(this,P,ee,B)}Z.prototype=new C,Z.prototype.finalize=function(){return this.encode(this.outputBits,!0),C.prototype.finalize.call(this)};var se=function(P){var ee,B,j,H,w,z,ne,ce,he,ye,we,Te,Qe,Oe,Ce,Ie,me,Re,De,ve,Ne,Se,be,Ue,Me,_e,He,Ve,Ee,Ke,ut,Ge,_t,lt,Je,Et,It,Le,Xe,tt,qe,et,Ze,ze,ft,rt,je,it,st,Be,Ye,ht,ke,Ct,Dt,at,bt,Tr,Cr,Dr,Lr,qr,er;for(j=0;j<48;j+=2)H=P[0]^P[10]^P[20]^P[30]^P[40],w=P[1]^P[11]^P[21]^P[31]^P[41],z=P[2]^P[12]^P[22]^P[32]^P[42],ne=P[3]^P[13]^P[23]^P[33]^P[43],ce=P[4]^P[14]^P[24]^P[34]^P[44],he=P[5]^P[15]^P[25]^P[35]^P[45],ye=P[6]^P[16]^P[26]^P[36]^P[46],we=P[7]^P[17]^P[27]^P[37]^P[47],Te=P[8]^P[18]^P[28]^P[38]^P[48],Qe=P[9]^P[19]^P[29]^P[39]^P[49],ee=Te^(z<<1|ne>>>31),B=Qe^(ne<<1|z>>>31),P[0]^=ee,P[1]^=B,P[10]^=ee,P[11]^=B,P[20]^=ee,P[21]^=B,P[30]^=ee,P[31]^=B,P[40]^=ee,P[41]^=B,ee=H^(ce<<1|he>>>31),B=w^(he<<1|ce>>>31),P[2]^=ee,P[3]^=B,P[12]^=ee,P[13]^=B,P[22]^=ee,P[23]^=B,P[32]^=ee,P[33]^=B,P[42]^=ee,P[43]^=B,ee=z^(ye<<1|we>>>31),B=ne^(we<<1|ye>>>31),P[4]^=ee,P[5]^=B,P[14]^=ee,P[15]^=B,P[24]^=ee,P[25]^=B,P[34]^=ee,P[35]^=B,P[44]^=ee,P[45]^=B,ee=ce^(Te<<1|Qe>>>31),B=he^(Qe<<1|Te>>>31),P[6]^=ee,P[7]^=B,P[16]^=ee,P[17]^=B,P[26]^=ee,P[27]^=B,P[36]^=ee,P[37]^=B,P[46]^=ee,P[47]^=B,ee=ye^(H<<1|w>>>31),B=we^(w<<1|H>>>31),P[8]^=ee,P[9]^=B,P[18]^=ee,P[19]^=B,P[28]^=ee,P[29]^=B,P[38]^=ee,P[39]^=B,P[48]^=ee,P[49]^=B,Oe=P[0],Ce=P[1],rt=P[11]<<4|P[10]>>>28,je=P[10]<<4|P[11]>>>28,Ve=P[20]<<3|P[21]>>>29,Ee=P[21]<<3|P[20]>>>29,Dr=P[31]<<9|P[30]>>>23,Lr=P[30]<<9|P[31]>>>23,et=P[40]<<18|P[41]>>>14,Ze=P[41]<<18|P[40]>>>14,lt=P[2]<<1|P[3]>>>31,Je=P[3]<<1|P[2]>>>31,Ie=P[13]<<12|P[12]>>>20,me=P[12]<<12|P[13]>>>20,it=P[22]<<10|P[23]>>>22,st=P[23]<<10|P[22]>>>22,Ke=P[33]<<13|P[32]>>>19,ut=P[32]<<13|P[33]>>>19,qr=P[42]<<2|P[43]>>>30,er=P[43]<<2|P[42]>>>30,Ct=P[5]<<30|P[4]>>>2,Dt=P[4]<<30|P[5]>>>2,Et=P[14]<<6|P[15]>>>26,It=P[15]<<6|P[14]>>>26,Re=P[25]<<11|P[24]>>>21,De=P[24]<<11|P[25]>>>21,Be=P[34]<<15|P[35]>>>17,Ye=P[35]<<15|P[34]>>>17,Ge=P[45]<<29|P[44]>>>3,_t=P[44]<<29|P[45]>>>3,Ue=P[6]<<28|P[7]>>>4,Me=P[7]<<28|P[6]>>>4,at=P[17]<<23|P[16]>>>9,bt=P[16]<<23|P[17]>>>9,Le=P[26]<<25|P[27]>>>7,Xe=P[27]<<25|P[26]>>>7,ve=P[36]<<21|P[37]>>>11,Ne=P[37]<<21|P[36]>>>11,ht=P[47]<<24|P[46]>>>8,ke=P[46]<<24|P[47]>>>8,ze=P[8]<<27|P[9]>>>5,ft=P[9]<<27|P[8]>>>5,_e=P[18]<<20|P[19]>>>12,He=P[19]<<20|P[18]>>>12,Tr=P[29]<<7|P[28]>>>25,Cr=P[28]<<7|P[29]>>>25,tt=P[38]<<8|P[39]>>>24,qe=P[39]<<8|P[38]>>>24,Se=P[48]<<14|P[49]>>>18,be=P[49]<<14|P[48]>>>18,P[0]=Oe^~Ie&Re,P[1]=Ce^~me&De,P[10]=Ue^~_e&Ve,P[11]=Me^~He&Ee,P[20]=lt^~Et&Le,P[21]=Je^~It&Xe,P[30]=ze^~rt&it,P[31]=ft^~je&st,P[40]=Ct^~at&Tr,P[41]=Dt^~bt&Cr,P[2]=Ie^~Re&ve,P[3]=me^~De&Ne,P[12]=_e^~Ve&Ke,P[13]=He^~Ee&ut,P[22]=Et^~Le&tt,P[23]=It^~Xe&qe,P[32]=rt^~it&Be,P[33]=je^~st&Ye,P[42]=at^~Tr&Dr,P[43]=bt^~Cr&Lr,P[4]=Re^~ve&Se,P[5]=De^~Ne&be,P[14]=Ve^~Ke&Ge,P[15]=Ee^~ut&_t,P[24]=Le^~tt&et,P[25]=Xe^~qe&Ze,P[34]=it^~Be&ht,P[35]=st^~Ye&ke,P[44]=Tr^~Dr&qr,P[45]=Cr^~Lr&er,P[6]=ve^~Se&Oe,P[7]=Ne^~be&Ce,P[16]=Ke^~Ge&Ue,P[17]=ut^~_t&Me,P[26]=tt^~et<,P[27]=qe^~Ze&Je,P[36]=Be^~ht&ze,P[37]=Ye^~ke&ft,P[46]=Dr^~qr&Ct,P[47]=Lr^~er&Dt,P[8]=Se^~Oe&Ie,P[9]=be^~Ce&me,P[18]=Ge^~Ue&_e,P[19]=_t^~Me&He,P[28]=et^~lt&Et,P[29]=Ze^~Je&It,P[38]=ht^~ze&rt,P[39]=ke^~ft&je,P[48]=qr^~Ct&at,P[49]=er^~Dt&bt,P[0]^=K[j],P[1]^=K[j+1]};if(u)r.exports=h;else for(_=0;_{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(r){return r.message}return null}const k1=AA();var sd;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(sd||(sd={}));var fn;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(fn||(fn={}));const F1="0123456789abcdef";let Or=class gr{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const i=e.toLowerCase();Xf[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(j1>Xf[i])&&console.log.apply(console,t)}debug(...e){this._log(gr.levels.DEBUG,e)}info(...e){this._log(gr.levels.INFO,e)}warn(...e){this._log(gr.levels.WARNING,e)}makeError(e,t,i){if(z1)return this.makeError("censored error",t,{});t||(t=gr.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(b=>{const p=i[b];try{if(p instanceof Uint8Array){let y="";for(let A=0;A>4],y+=F1[p[A]&15];n.push(b+"=Uint8Array(0x"+y+")")}else n.push(b+"="+JSON.stringify(p))}catch{n.push(b+"="+JSON.stringify(i[b].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);const a=e;let f="";switch(t){case fn.NUMERIC_FAULT:{f="NUMERIC_FAULT";const b=e;switch(b){case"overflow":case"underflow":case"division-by-zero":f+="-"+b;break;case"negative-power":case"negative-width":f+="-unsupported";break;case"unbound-bitwise-result":f+="-unbound-result";break}break}case fn.CALL_EXCEPTION:case fn.INSUFFICIENT_FUNDS:case fn.MISSING_NEW:case fn.NONCE_EXPIRED:case fn.REPLACEMENT_UNDERPRICED:case fn.TRANSACTION_REPLACED:case fn.UNPREDICTABLE_GAS_LIMIT:f=t;break}f&&(e+=" [ See: https://links.ethers.org/v5-errors-"+f+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const u=new Error(e);return u.reason=a,u.code=t,Object.keys(i).forEach(function(b){u[b]=i[b]}),u}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,gr.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){k1&&this.throwError("platform missing String.prototype.normalize",gr.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:k1})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,gr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,gr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,gr.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",gr.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",gr.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",gr.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return bl||(bl=new gr(_A)),bl}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",gr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),$1){if(!e)return;this.globalLogger().throwError("error censorship permanent",gr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}z1=!!e,$1=!!t}static setLogLevel(e){const t=Xf[e.toLowerCase()];if(t==null){gr.globalLogger().warn("invalid log level - "+e);return}j1=t}static from(e){return new gr(e)}};Or.errors=fn,Or.levels=sd;const EA="bytes/5.7.0",cr=new Or(EA);function $b(r){return!!r.toHexString}function eo(r){return r.slice||(r.slice=function(){const e=Array.prototype.slice.call(arguments);return eo(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function xA(r){return _i(r)&&!(r.length%2)||bo(r)}function H1(r){return typeof r=="number"&&r==r&&r%1===0}function bo(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!H1(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function ir(r,e){if(e||(e={}),typeof r=="number"){cr.checkSafeUint53(r,"invalid arrayify value");const t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),eo(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),$b(r)&&(r=r.toHexString()),_i(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":cr.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let n=0;nir(n)),t=e.reduce((n,a)=>n+a.length,0),i=new Uint8Array(t);return e.reduce((n,a)=>(i.set(a,n),n+a.length),0),eo(i)}function IA(r,e){r=ir(r),r.length>e&&cr.throwArgumentError("value out of range","value",arguments[0]);const t=new Uint8Array(e);return t.set(r,e-r.length),eo(t)}function _i(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}const ml="0123456789abcdef";function ci(r,e){if(e||(e={}),typeof r=="number"){cr.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=ml[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),$b(r))return r.toHexString();if(_i(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":cr.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(bo(r)){let t="0x";for(let i=0;i>4]+ml[n&15]}return t}return cr.throwArgumentError("invalid hexlify value","value",r)}function MA(r){if(typeof r!="string")r=ci(r);else if(!_i(r)||r.length%2)return null;return(r.length-2)/2}function K1(r,e,t){return typeof r!="string"?r=ci(r):(!_i(r)||r.length%2)&&cr.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Cn(r,e){for(typeof r!="string"?r=ci(r):_i(r)||cr.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&cr.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function zb(r){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(xA(r)){let t=ir(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=ci(t.slice(0,32)),e.s=ci(t.slice(32,64))):t.length===65?(e.r=ci(t.slice(0,32)),e.s=ci(t.slice(32,64)),e.v=t[64]):cr.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:cr.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=ci(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){const n=IA(ir(e._vs),32);e._vs=ci(n);const a=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=a:e.recoveryParam!==a&&cr.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;const f=ci(n);e.s==null?e.s=f:e.s!==f&&cr.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?cr.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&cr.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!_i(e.r)?cr.throwArgumentError("signature missing or invalid r","signature",r):e.r=Cn(e.r,32),e.s==null||!_i(e.s)?cr.throwArgumentError("signature missing or invalid s","signature",r):e.s=Cn(e.s,32);const t=ir(e.s);t[0]>=128&&cr.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);const i=ci(t);e._vs&&(_i(e._vs)||cr.throwArgumentError("signature invalid _vs","signature",r),e._vs=Cn(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&cr.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function kd(r){return"0x"+wA.keccak_256(ir(r))}var jb={exports:{}},PA={},OA=Object.freeze({__proto__:null,default:PA}),RA=yA(OA);(function(r){(function(e,t){function i(c,h){if(!c)throw new Error(h||"Assertion failed")}function n(c,h){c.super_=h;var v=function(){};v.prototype=h.prototype,c.prototype=new v,c.prototype.constructor=c}function a(c,h,v){if(a.isBN(c))return c;this.negative=0,this.words=null,this.length=0,this.red=null,c!==null&&((h==="le"||h==="be")&&(v=h,h=10),this._init(c||0,h||10,v||"be"))}typeof e=="object"?e.exports=a:t.BN=a,a.BN=a,a.wordSize=26;var f;try{typeof window<"u"&&typeof window.Buffer<"u"?f=window.Buffer:f=RA.Buffer}catch{}a.isBN=function(c){return c instanceof a?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===a.wordSize&&Array.isArray(c.words)},a.max=function(c,h){return c.cmp(h)>0?c:h},a.min=function(c,h){return c.cmp(h)<0?c:h},a.prototype._init=function(c,h,v){if(typeof c=="number")return this._initNumber(c,h,v);if(typeof c=="object")return this._initArray(c,h,v);h==="hex"&&(h=16),i(h===(h|0)&&h>=2&&h<=36),c=c.toString().replace(/\s+/g,"");var _=0;c[0]==="-"&&(_++,this.negative=1),_=0;_-=3)M=c[_]|c[_-1]<<8|c[_-2]<<16,this.words[I]|=M<>>26-S&67108863,S+=24,S>=26&&(S-=26,I++);else if(v==="le")for(_=0,I=0;_>>26-S&67108863,S+=24,S>=26&&(S-=26,I++);return this._strip()};function u(c,h){var v=c.charCodeAt(h);if(v>=48&&v<=57)return v-48;if(v>=65&&v<=70)return v-55;if(v>=97&&v<=102)return v-87;i(!1,"Invalid character in "+c)}function b(c,h,v){var _=u(c,v);return v-1>=h&&(_|=u(c,v-1)<<4),_}a.prototype._parseHex=function(c,h,v){this.length=Math.ceil((c.length-h)/6),this.words=new Array(this.length);for(var _=0;_=h;_-=2)S=b(c,h,_)<=18?(I-=18,M+=1,this.words[M]|=S>>>26):I+=8;else{var d=c.length-h;for(_=d%2===0?h+1:h;_=18?(I-=18,M+=1,this.words[M]|=S>>>26):I+=8}this._strip()};function p(c,h,v,_){for(var I=0,M=0,S=Math.min(c.length,v),d=h;d=49?M=g-49+10:g>=17?M=g-17+10:M=g,i(g>=0&&M<_,"Invalid character"),I+=M}return I}a.prototype._parseBase=function(c,h,v){this.words=[0],this.length=1;for(var _=0,I=1;I<=67108863;I*=h)_++;_--,I=I/h|0;for(var M=c.length-v,S=M%_,d=Math.min(M,M-S)+v,g=0,C=v;C1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=A}catch{a.prototype.inspect=A}else a.prototype.inspect=A;function A(){return(this.red?""}var R=["","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"],O=[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],N=[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];a.prototype.toString=function(c,h){c=c||10,h=h|0||1;var v;if(c===16||c==="hex"){v="";for(var _=0,I=0,M=0;M>>24-_&16777215,_+=2,_>=26&&(_-=26,M--),I!==0||M!==this.length-1?v=R[6-d.length]+d+v:v=d+v}for(I!==0&&(v=I.toString(16)+v);v.length%h!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(c===(c|0)&&c>=2&&c<=36){var g=O[c],C=N[c];v="";var Z=this.clone();for(Z.negative=0;!Z.isZero();){var se=Z.modrn(C).toString(c);Z=Z.idivn(C),Z.isZero()?v=se+v:v=R[g-se.length]+se+v}for(this.isZero()&&(v="0"+v);v.length%h!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},a.prototype.toJSON=function(){return this.toString(16,2)},f&&(a.prototype.toBuffer=function(c,h){return this.toArrayLike(f,c,h)}),a.prototype.toArray=function(c,h){return this.toArrayLike(Array,c,h)};var K=function(c,h){return c.allocUnsafe?c.allocUnsafe(h):new c(h)};a.prototype.toArrayLike=function(c,h,v){this._strip();var _=this.byteLength(),I=v||Math.max(1,_);i(_<=I,"byte array longer than desired length"),i(I>0,"Requested array length <= 0");var M=K(c,I),S=h==="le"?"LE":"BE";return this["_toArrayLike"+S](M,_),M},a.prototype._toArrayLikeLE=function(c,h){for(var v=0,_=0,I=0,M=0;I>8&255),v>16&255),M===6?(v>24&255),_=0,M=0):(_=S>>>24,M+=2)}if(v=0&&(c[v--]=S>>8&255),v>=0&&(c[v--]=S>>16&255),M===6?(v>=0&&(c[v--]=S>>24&255),_=0,M=0):(_=S>>>24,M+=2)}if(v>=0)for(c[v--]=_;v>=0;)c[v--]=0},Math.clz32?a.prototype._countBits=function(c){return 32-Math.clz32(c)}:a.prototype._countBits=function(c){var h=c,v=0;return h>=4096&&(v+=13,h>>>=13),h>=64&&(v+=7,h>>>=7),h>=8&&(v+=4,h>>>=4),h>=2&&(v+=2,h>>>=2),v+h},a.prototype._zeroBits=function(c){if(c===0)return 26;var h=c,v=0;return h&8191||(v+=13,h>>>=13),h&127||(v+=7,h>>>=7),h&15||(v+=4,h>>>=4),h&3||(v+=2,h>>>=2),h&1||v++,v},a.prototype.bitLength=function(){var c=this.words[this.length-1],h=this._countBits(c);return(this.length-1)*26+h};function W(c){for(var h=new Array(c.bitLength()),v=0;v>>I&1}return h}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,h=0;hc.length?this.clone().ior(c):c.clone().ior(this)},a.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},a.prototype.iuand=function(c){var h;this.length>c.length?h=c:h=this;for(var v=0;vc.length?this.clone().iand(c):c.clone().iand(this)},a.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},a.prototype.iuxor=function(c){var h,v;this.length>c.length?(h=this,v=c):(h=c,v=this);for(var _=0;_c.length?this.clone().ixor(c):c.clone().ixor(this)},a.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},a.prototype.inotn=function(c){i(typeof c=="number"&&c>=0);var h=Math.ceil(c/26)|0,v=c%26;this._expand(h),v>0&&h--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-v),this._strip()},a.prototype.notn=function(c){return this.clone().inotn(c)},a.prototype.setn=function(c,h){i(typeof c=="number"&&c>=0);var v=c/26|0,_=c%26;return this._expand(v+1),h?this.words[v]=this.words[v]|1<<_:this.words[v]=this.words[v]&~(1<<_),this._strip()},a.prototype.iadd=function(c){var h;if(this.negative!==0&&c.negative===0)return this.negative=0,h=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,h=this.isub(c),c.negative=1,h._normSign();var v,_;this.length>c.length?(v=this,_=c):(v=c,_=this);for(var I=0,M=0;M<_.length;M++)h=(v.words[M]|0)+(_.words[M]|0)+I,this.words[M]=h&67108863,I=h>>>26;for(;I!==0&&M>>26;if(this.length=v.length,I!==0)this.words[this.length]=I,this.length++;else if(v!==this)for(;Mc.length?this.clone().iadd(c):c.clone().iadd(this)},a.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var h=this.iadd(c);return c.negative=1,h._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var v=this.cmp(c);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,I;v>0?(_=this,I=c):(_=c,I=this);for(var M=0,S=0;S>26,this.words[S]=h&67108863;for(;M!==0&&S<_.length;S++)h=(_.words[S]|0)+M,M=h>>26,this.words[S]=h&67108863;if(M===0&&S<_.length&&_!==this)for(;S<_.length;S++)this.words[S]=_.words[S];return this.length=Math.max(this.length,S),_!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(c){return this.clone().isub(c)};function Q(c,h,v){v.negative=h.negative^c.negative;var _=c.length+h.length|0;v.length=_,_=_-1|0;var I=c.words[0]|0,M=h.words[0]|0,S=I*M,d=S&67108863,g=S/67108864|0;v.words[0]=d;for(var C=1;C<_;C++){for(var Z=g>>>26,se=g&67108863,P=Math.min(C,h.length-1),ee=Math.max(0,C-c.length+1);ee<=P;ee++){var B=C-ee|0;I=c.words[B]|0,M=h.words[ee]|0,S=I*M+se,Z+=S/67108864|0,se=S&67108863}v.words[C]=se|0,g=Z|0}return g!==0?v.words[C]=g|0:v.length--,v._strip()}var k=function(c,h,v){var _=c.words,I=h.words,M=v.words,S=0,d,g,C,Z=_[0]|0,se=Z&8191,P=Z>>>13,ee=_[1]|0,B=ee&8191,j=ee>>>13,H=_[2]|0,w=H&8191,z=H>>>13,ne=_[3]|0,ce=ne&8191,he=ne>>>13,ye=_[4]|0,we=ye&8191,Te=ye>>>13,Qe=_[5]|0,Oe=Qe&8191,Ce=Qe>>>13,Ie=_[6]|0,me=Ie&8191,Re=Ie>>>13,De=_[7]|0,ve=De&8191,Ne=De>>>13,Se=_[8]|0,be=Se&8191,Ue=Se>>>13,Me=_[9]|0,_e=Me&8191,He=Me>>>13,Ve=I[0]|0,Ee=Ve&8191,Ke=Ve>>>13,ut=I[1]|0,Ge=ut&8191,_t=ut>>>13,lt=I[2]|0,Je=lt&8191,Et=lt>>>13,It=I[3]|0,Le=It&8191,Xe=It>>>13,tt=I[4]|0,qe=tt&8191,et=tt>>>13,Ze=I[5]|0,ze=Ze&8191,ft=Ze>>>13,rt=I[6]|0,je=rt&8191,it=rt>>>13,st=I[7]|0,Be=st&8191,Ye=st>>>13,ht=I[8]|0,ke=ht&8191,Ct=ht>>>13,Dt=I[9]|0,at=Dt&8191,bt=Dt>>>13;v.negative=c.negative^h.negative,v.length=19,d=Math.imul(se,Ee),g=Math.imul(se,Ke),g=g+Math.imul(P,Ee)|0,C=Math.imul(P,Ke);var Tr=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Tr>>>26)|0,Tr&=67108863,d=Math.imul(B,Ee),g=Math.imul(B,Ke),g=g+Math.imul(j,Ee)|0,C=Math.imul(j,Ke),d=d+Math.imul(se,Ge)|0,g=g+Math.imul(se,_t)|0,g=g+Math.imul(P,Ge)|0,C=C+Math.imul(P,_t)|0;var Cr=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,d=Math.imul(w,Ee),g=Math.imul(w,Ke),g=g+Math.imul(z,Ee)|0,C=Math.imul(z,Ke),d=d+Math.imul(B,Ge)|0,g=g+Math.imul(B,_t)|0,g=g+Math.imul(j,Ge)|0,C=C+Math.imul(j,_t)|0,d=d+Math.imul(se,Je)|0,g=g+Math.imul(se,Et)|0,g=g+Math.imul(P,Je)|0,C=C+Math.imul(P,Et)|0;var Dr=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Dr>>>26)|0,Dr&=67108863,d=Math.imul(ce,Ee),g=Math.imul(ce,Ke),g=g+Math.imul(he,Ee)|0,C=Math.imul(he,Ke),d=d+Math.imul(w,Ge)|0,g=g+Math.imul(w,_t)|0,g=g+Math.imul(z,Ge)|0,C=C+Math.imul(z,_t)|0,d=d+Math.imul(B,Je)|0,g=g+Math.imul(B,Et)|0,g=g+Math.imul(j,Je)|0,C=C+Math.imul(j,Et)|0,d=d+Math.imul(se,Le)|0,g=g+Math.imul(se,Xe)|0,g=g+Math.imul(P,Le)|0,C=C+Math.imul(P,Xe)|0;var Lr=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Lr>>>26)|0,Lr&=67108863,d=Math.imul(we,Ee),g=Math.imul(we,Ke),g=g+Math.imul(Te,Ee)|0,C=Math.imul(Te,Ke),d=d+Math.imul(ce,Ge)|0,g=g+Math.imul(ce,_t)|0,g=g+Math.imul(he,Ge)|0,C=C+Math.imul(he,_t)|0,d=d+Math.imul(w,Je)|0,g=g+Math.imul(w,Et)|0,g=g+Math.imul(z,Je)|0,C=C+Math.imul(z,Et)|0,d=d+Math.imul(B,Le)|0,g=g+Math.imul(B,Xe)|0,g=g+Math.imul(j,Le)|0,C=C+Math.imul(j,Xe)|0,d=d+Math.imul(se,qe)|0,g=g+Math.imul(se,et)|0,g=g+Math.imul(P,qe)|0,C=C+Math.imul(P,et)|0;var qr=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(qr>>>26)|0,qr&=67108863,d=Math.imul(Oe,Ee),g=Math.imul(Oe,Ke),g=g+Math.imul(Ce,Ee)|0,C=Math.imul(Ce,Ke),d=d+Math.imul(we,Ge)|0,g=g+Math.imul(we,_t)|0,g=g+Math.imul(Te,Ge)|0,C=C+Math.imul(Te,_t)|0,d=d+Math.imul(ce,Je)|0,g=g+Math.imul(ce,Et)|0,g=g+Math.imul(he,Je)|0,C=C+Math.imul(he,Et)|0,d=d+Math.imul(w,Le)|0,g=g+Math.imul(w,Xe)|0,g=g+Math.imul(z,Le)|0,C=C+Math.imul(z,Xe)|0,d=d+Math.imul(B,qe)|0,g=g+Math.imul(B,et)|0,g=g+Math.imul(j,qe)|0,C=C+Math.imul(j,et)|0,d=d+Math.imul(se,ze)|0,g=g+Math.imul(se,ft)|0,g=g+Math.imul(P,ze)|0,C=C+Math.imul(P,ft)|0;var er=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(er>>>26)|0,er&=67108863,d=Math.imul(me,Ee),g=Math.imul(me,Ke),g=g+Math.imul(Re,Ee)|0,C=Math.imul(Re,Ke),d=d+Math.imul(Oe,Ge)|0,g=g+Math.imul(Oe,_t)|0,g=g+Math.imul(Ce,Ge)|0,C=C+Math.imul(Ce,_t)|0,d=d+Math.imul(we,Je)|0,g=g+Math.imul(we,Et)|0,g=g+Math.imul(Te,Je)|0,C=C+Math.imul(Te,Et)|0,d=d+Math.imul(ce,Le)|0,g=g+Math.imul(ce,Xe)|0,g=g+Math.imul(he,Le)|0,C=C+Math.imul(he,Xe)|0,d=d+Math.imul(w,qe)|0,g=g+Math.imul(w,et)|0,g=g+Math.imul(z,qe)|0,C=C+Math.imul(z,et)|0,d=d+Math.imul(B,ze)|0,g=g+Math.imul(B,ft)|0,g=g+Math.imul(j,ze)|0,C=C+Math.imul(j,ft)|0,d=d+Math.imul(se,je)|0,g=g+Math.imul(se,it)|0,g=g+Math.imul(P,je)|0,C=C+Math.imul(P,it)|0;var Qr=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Qr>>>26)|0,Qr&=67108863,d=Math.imul(ve,Ee),g=Math.imul(ve,Ke),g=g+Math.imul(Ne,Ee)|0,C=Math.imul(Ne,Ke),d=d+Math.imul(me,Ge)|0,g=g+Math.imul(me,_t)|0,g=g+Math.imul(Re,Ge)|0,C=C+Math.imul(Re,_t)|0,d=d+Math.imul(Oe,Je)|0,g=g+Math.imul(Oe,Et)|0,g=g+Math.imul(Ce,Je)|0,C=C+Math.imul(Ce,Et)|0,d=d+Math.imul(we,Le)|0,g=g+Math.imul(we,Xe)|0,g=g+Math.imul(Te,Le)|0,C=C+Math.imul(Te,Xe)|0,d=d+Math.imul(ce,qe)|0,g=g+Math.imul(ce,et)|0,g=g+Math.imul(he,qe)|0,C=C+Math.imul(he,et)|0,d=d+Math.imul(w,ze)|0,g=g+Math.imul(w,ft)|0,g=g+Math.imul(z,ze)|0,C=C+Math.imul(z,ft)|0,d=d+Math.imul(B,je)|0,g=g+Math.imul(B,it)|0,g=g+Math.imul(j,je)|0,C=C+Math.imul(j,it)|0,d=d+Math.imul(se,Be)|0,g=g+Math.imul(se,Ye)|0,g=g+Math.imul(P,Be)|0,C=C+Math.imul(P,Ye)|0;var Vi=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Vi>>>26)|0,Vi&=67108863,d=Math.imul(be,Ee),g=Math.imul(be,Ke),g=g+Math.imul(Ue,Ee)|0,C=Math.imul(Ue,Ke),d=d+Math.imul(ve,Ge)|0,g=g+Math.imul(ve,_t)|0,g=g+Math.imul(Ne,Ge)|0,C=C+Math.imul(Ne,_t)|0,d=d+Math.imul(me,Je)|0,g=g+Math.imul(me,Et)|0,g=g+Math.imul(Re,Je)|0,C=C+Math.imul(Re,Et)|0,d=d+Math.imul(Oe,Le)|0,g=g+Math.imul(Oe,Xe)|0,g=g+Math.imul(Ce,Le)|0,C=C+Math.imul(Ce,Xe)|0,d=d+Math.imul(we,qe)|0,g=g+Math.imul(we,et)|0,g=g+Math.imul(Te,qe)|0,C=C+Math.imul(Te,et)|0,d=d+Math.imul(ce,ze)|0,g=g+Math.imul(ce,ft)|0,g=g+Math.imul(he,ze)|0,C=C+Math.imul(he,ft)|0,d=d+Math.imul(w,je)|0,g=g+Math.imul(w,it)|0,g=g+Math.imul(z,je)|0,C=C+Math.imul(z,it)|0,d=d+Math.imul(B,Be)|0,g=g+Math.imul(B,Ye)|0,g=g+Math.imul(j,Be)|0,C=C+Math.imul(j,Ye)|0,d=d+Math.imul(se,ke)|0,g=g+Math.imul(se,Ct)|0,g=g+Math.imul(P,ke)|0,C=C+Math.imul(P,Ct)|0;var Xr=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,d=Math.imul(_e,Ee),g=Math.imul(_e,Ke),g=g+Math.imul(He,Ee)|0,C=Math.imul(He,Ke),d=d+Math.imul(be,Ge)|0,g=g+Math.imul(be,_t)|0,g=g+Math.imul(Ue,Ge)|0,C=C+Math.imul(Ue,_t)|0,d=d+Math.imul(ve,Je)|0,g=g+Math.imul(ve,Et)|0,g=g+Math.imul(Ne,Je)|0,C=C+Math.imul(Ne,Et)|0,d=d+Math.imul(me,Le)|0,g=g+Math.imul(me,Xe)|0,g=g+Math.imul(Re,Le)|0,C=C+Math.imul(Re,Xe)|0,d=d+Math.imul(Oe,qe)|0,g=g+Math.imul(Oe,et)|0,g=g+Math.imul(Ce,qe)|0,C=C+Math.imul(Ce,et)|0,d=d+Math.imul(we,ze)|0,g=g+Math.imul(we,ft)|0,g=g+Math.imul(Te,ze)|0,C=C+Math.imul(Te,ft)|0,d=d+Math.imul(ce,je)|0,g=g+Math.imul(ce,it)|0,g=g+Math.imul(he,je)|0,C=C+Math.imul(he,it)|0,d=d+Math.imul(w,Be)|0,g=g+Math.imul(w,Ye)|0,g=g+Math.imul(z,Be)|0,C=C+Math.imul(z,Ye)|0,d=d+Math.imul(B,ke)|0,g=g+Math.imul(B,Ct)|0,g=g+Math.imul(j,ke)|0,C=C+Math.imul(j,Ct)|0,d=d+Math.imul(se,at)|0,g=g+Math.imul(se,bt)|0,g=g+Math.imul(P,at)|0,C=C+Math.imul(P,bt)|0;var Gi=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Gi>>>26)|0,Gi&=67108863,d=Math.imul(_e,Ge),g=Math.imul(_e,_t),g=g+Math.imul(He,Ge)|0,C=Math.imul(He,_t),d=d+Math.imul(be,Je)|0,g=g+Math.imul(be,Et)|0,g=g+Math.imul(Ue,Je)|0,C=C+Math.imul(Ue,Et)|0,d=d+Math.imul(ve,Le)|0,g=g+Math.imul(ve,Xe)|0,g=g+Math.imul(Ne,Le)|0,C=C+Math.imul(Ne,Xe)|0,d=d+Math.imul(me,qe)|0,g=g+Math.imul(me,et)|0,g=g+Math.imul(Re,qe)|0,C=C+Math.imul(Re,et)|0,d=d+Math.imul(Oe,ze)|0,g=g+Math.imul(Oe,ft)|0,g=g+Math.imul(Ce,ze)|0,C=C+Math.imul(Ce,ft)|0,d=d+Math.imul(we,je)|0,g=g+Math.imul(we,it)|0,g=g+Math.imul(Te,je)|0,C=C+Math.imul(Te,it)|0,d=d+Math.imul(ce,Be)|0,g=g+Math.imul(ce,Ye)|0,g=g+Math.imul(he,Be)|0,C=C+Math.imul(he,Ye)|0,d=d+Math.imul(w,ke)|0,g=g+Math.imul(w,Ct)|0,g=g+Math.imul(z,ke)|0,C=C+Math.imul(z,Ct)|0,d=d+Math.imul(B,at)|0,g=g+Math.imul(B,bt)|0,g=g+Math.imul(j,at)|0,C=C+Math.imul(j,bt)|0;var Wi=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Wi>>>26)|0,Wi&=67108863,d=Math.imul(_e,Je),g=Math.imul(_e,Et),g=g+Math.imul(He,Je)|0,C=Math.imul(He,Et),d=d+Math.imul(be,Le)|0,g=g+Math.imul(be,Xe)|0,g=g+Math.imul(Ue,Le)|0,C=C+Math.imul(Ue,Xe)|0,d=d+Math.imul(ve,qe)|0,g=g+Math.imul(ve,et)|0,g=g+Math.imul(Ne,qe)|0,C=C+Math.imul(Ne,et)|0,d=d+Math.imul(me,ze)|0,g=g+Math.imul(me,ft)|0,g=g+Math.imul(Re,ze)|0,C=C+Math.imul(Re,ft)|0,d=d+Math.imul(Oe,je)|0,g=g+Math.imul(Oe,it)|0,g=g+Math.imul(Ce,je)|0,C=C+Math.imul(Ce,it)|0,d=d+Math.imul(we,Be)|0,g=g+Math.imul(we,Ye)|0,g=g+Math.imul(Te,Be)|0,C=C+Math.imul(Te,Ye)|0,d=d+Math.imul(ce,ke)|0,g=g+Math.imul(ce,Ct)|0,g=g+Math.imul(he,ke)|0,C=C+Math.imul(he,Ct)|0,d=d+Math.imul(w,at)|0,g=g+Math.imul(w,bt)|0,g=g+Math.imul(z,at)|0,C=C+Math.imul(z,bt)|0;var Zr=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,d=Math.imul(_e,Le),g=Math.imul(_e,Xe),g=g+Math.imul(He,Le)|0,C=Math.imul(He,Xe),d=d+Math.imul(be,qe)|0,g=g+Math.imul(be,et)|0,g=g+Math.imul(Ue,qe)|0,C=C+Math.imul(Ue,et)|0,d=d+Math.imul(ve,ze)|0,g=g+Math.imul(ve,ft)|0,g=g+Math.imul(Ne,ze)|0,C=C+Math.imul(Ne,ft)|0,d=d+Math.imul(me,je)|0,g=g+Math.imul(me,it)|0,g=g+Math.imul(Re,je)|0,C=C+Math.imul(Re,it)|0,d=d+Math.imul(Oe,Be)|0,g=g+Math.imul(Oe,Ye)|0,g=g+Math.imul(Ce,Be)|0,C=C+Math.imul(Ce,Ye)|0,d=d+Math.imul(we,ke)|0,g=g+Math.imul(we,Ct)|0,g=g+Math.imul(Te,ke)|0,C=C+Math.imul(Te,Ct)|0,d=d+Math.imul(ce,at)|0,g=g+Math.imul(ce,bt)|0,g=g+Math.imul(he,at)|0,C=C+Math.imul(he,bt)|0;var Si=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Si>>>26)|0,Si&=67108863,d=Math.imul(_e,qe),g=Math.imul(_e,et),g=g+Math.imul(He,qe)|0,C=Math.imul(He,et),d=d+Math.imul(be,ze)|0,g=g+Math.imul(be,ft)|0,g=g+Math.imul(Ue,ze)|0,C=C+Math.imul(Ue,ft)|0,d=d+Math.imul(ve,je)|0,g=g+Math.imul(ve,it)|0,g=g+Math.imul(Ne,je)|0,C=C+Math.imul(Ne,it)|0,d=d+Math.imul(me,Be)|0,g=g+Math.imul(me,Ye)|0,g=g+Math.imul(Re,Be)|0,C=C+Math.imul(Re,Ye)|0,d=d+Math.imul(Oe,ke)|0,g=g+Math.imul(Oe,Ct)|0,g=g+Math.imul(Ce,ke)|0,C=C+Math.imul(Ce,Ct)|0,d=d+Math.imul(we,at)|0,g=g+Math.imul(we,bt)|0,g=g+Math.imul(Te,at)|0,C=C+Math.imul(Te,bt)|0;var Ii=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,d=Math.imul(_e,ze),g=Math.imul(_e,ft),g=g+Math.imul(He,ze)|0,C=Math.imul(He,ft),d=d+Math.imul(be,je)|0,g=g+Math.imul(be,it)|0,g=g+Math.imul(Ue,je)|0,C=C+Math.imul(Ue,it)|0,d=d+Math.imul(ve,Be)|0,g=g+Math.imul(ve,Ye)|0,g=g+Math.imul(Ne,Be)|0,C=C+Math.imul(Ne,Ye)|0,d=d+Math.imul(me,ke)|0,g=g+Math.imul(me,Ct)|0,g=g+Math.imul(Re,ke)|0,C=C+Math.imul(Re,Ct)|0,d=d+Math.imul(Oe,at)|0,g=g+Math.imul(Oe,bt)|0,g=g+Math.imul(Ce,at)|0,C=C+Math.imul(Ce,bt)|0;var lr=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(lr>>>26)|0,lr&=67108863,d=Math.imul(_e,je),g=Math.imul(_e,it),g=g+Math.imul(He,je)|0,C=Math.imul(He,it),d=d+Math.imul(be,Be)|0,g=g+Math.imul(be,Ye)|0,g=g+Math.imul(Ue,Be)|0,C=C+Math.imul(Ue,Ye)|0,d=d+Math.imul(ve,ke)|0,g=g+Math.imul(ve,Ct)|0,g=g+Math.imul(Ne,ke)|0,C=C+Math.imul(Ne,Ct)|0,d=d+Math.imul(me,at)|0,g=g+Math.imul(me,bt)|0,g=g+Math.imul(Re,at)|0,C=C+Math.imul(Re,bt)|0;var Ji=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Ji>>>26)|0,Ji&=67108863,d=Math.imul(_e,Be),g=Math.imul(_e,Ye),g=g+Math.imul(He,Be)|0,C=Math.imul(He,Ye),d=d+Math.imul(be,ke)|0,g=g+Math.imul(be,Ct)|0,g=g+Math.imul(Ue,ke)|0,C=C+Math.imul(Ue,Ct)|0,d=d+Math.imul(ve,at)|0,g=g+Math.imul(ve,bt)|0,g=g+Math.imul(Ne,at)|0,C=C+Math.imul(Ne,bt)|0;var Yi=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Yi>>>26)|0,Yi&=67108863,d=Math.imul(_e,ke),g=Math.imul(_e,Ct),g=g+Math.imul(He,ke)|0,C=Math.imul(He,Ct),d=d+Math.imul(be,at)|0,g=g+Math.imul(be,bt)|0,g=g+Math.imul(Ue,at)|0,C=C+Math.imul(Ue,bt)|0;var Qi=(S+d|0)+((g&8191)<<13)|0;S=(C+(g>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,d=Math.imul(_e,at),g=Math.imul(_e,bt),g=g+Math.imul(He,at)|0,C=Math.imul(He,bt);var js=(S+d|0)+((g&8191)<<13)|0;return S=(C+(g>>>13)|0)+(js>>>26)|0,js&=67108863,M[0]=Tr,M[1]=Cr,M[2]=Dr,M[3]=Lr,M[4]=qr,M[5]=er,M[6]=Qr,M[7]=Vi,M[8]=Xr,M[9]=Gi,M[10]=Wi,M[11]=Zr,M[12]=Si,M[13]=Ii,M[14]=lr,M[15]=Ji,M[16]=Yi,M[17]=Qi,M[18]=js,S!==0&&(M[19]=S,v.length++),v};Math.imul||(k=Q);function Y(c,h,v){v.negative=h.negative^c.negative,v.length=c.length+h.length;for(var _=0,I=0,M=0;M>>26)|0,I+=S>>>26,S&=67108863}v.words[M]=d,_=S,S=I}return _!==0?v.words[M]=_:v.length--,v._strip()}function $(c,h,v){return Y(c,h,v)}a.prototype.mulTo=function(c,h){var v,_=this.length+c.length;return this.length===10&&c.length===10?v=k(this,c,h):_<63?v=Q(this,c,h):_<1024?v=Y(this,c,h):v=$(this,c,h),v},a.prototype.mul=function(c){var h=new a(null);return h.words=new Array(this.length+c.length),this.mulTo(c,h)},a.prototype.mulf=function(c){var h=new a(null);return h.words=new Array(this.length+c.length),$(this,c,h)},a.prototype.imul=function(c){return this.clone().mulTo(c,this)},a.prototype.imuln=function(c){var h=c<0;h&&(c=-c),i(typeof c=="number"),i(c<67108864);for(var v=0,_=0;_>=26,v+=I/67108864|0,v+=M>>>26,this.words[_]=M&67108863}return v!==0&&(this.words[_]=v,this.length++),h?this.ineg():this},a.prototype.muln=function(c){return this.clone().imuln(c)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(c){var h=W(c);if(h.length===0)return new a(1);for(var v=this,_=0;_=0);var h=c%26,v=(c-h)/26,_=67108863>>>26-h<<26-h,I;if(h!==0){var M=0;for(I=0;I>>26-h}M&&(this.words[I]=M,this.length++)}if(v!==0){for(I=this.length-1;I>=0;I--)this.words[I+v]=this.words[I];for(I=0;I=0);var _;h?_=(h-h%26)/26:_=0;var I=c%26,M=Math.min((c-I)/26,this.length),S=67108863^67108863>>>I<M)for(this.length-=M,g=0;g=0&&(C!==0||g>=_);g--){var Z=this.words[g]|0;this.words[g]=C<<26-I|Z>>>I,C=Z&S}return d&&C!==0&&(d.words[d.length++]=C),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(c,h,v){return i(this.negative===0),this.iushrn(c,h,v)},a.prototype.shln=function(c){return this.clone().ishln(c)},a.prototype.ushln=function(c){return this.clone().iushln(c)},a.prototype.shrn=function(c){return this.clone().ishrn(c)},a.prototype.ushrn=function(c){return this.clone().iushrn(c)},a.prototype.testn=function(c){i(typeof c=="number"&&c>=0);var h=c%26,v=(c-h)/26,_=1<=0);var h=c%26,v=(c-h)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(h!==0&&v++,this.length=Math.min(v,this.length),h!==0){var _=67108863^67108863>>>h<=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+1),this},a.prototype.isubn=function(c){if(i(typeof c=="number"),i(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var h=0;h>26)-(d/67108864|0),this.words[I+v]=M&67108863}for(;I>26,this.words[I+v]=M&67108863;if(S===0)return this._strip();for(i(S===-1),S=0,I=0;I>26,this.words[I]=M&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(c,h){var v=this.length-c.length,_=this.clone(),I=c,M=I.words[I.length-1]|0,S=this._countBits(M);v=26-S,v!==0&&(I=I.ushln(v),_.iushln(v),M=I.words[I.length-1]|0);var d=_.length-I.length,g;if(h!=="mod"){g=new a(null),g.length=d+1,g.words=new Array(g.length);for(var C=0;C=0;se--){var P=(_.words[I.length+se]|0)*67108864+(_.words[I.length+se-1]|0);for(P=Math.min(P/M|0,67108863),_._ishlnsubmul(I,P,se);_.negative!==0;)P--,_.negative=0,_._ishlnsubmul(I,1,se),_.isZero()||(_.negative^=1);g&&(g.words[se]=P)}return g&&g._strip(),_._strip(),h!=="div"&&v!==0&&_.iushrn(v),{div:g||null,mod:_}},a.prototype.divmod=function(c,h,v){if(i(!c.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var _,I,M;return this.negative!==0&&c.negative===0?(M=this.neg().divmod(c,h),h!=="mod"&&(_=M.div.neg()),h!=="div"&&(I=M.mod.neg(),v&&I.negative!==0&&I.iadd(c)),{div:_,mod:I}):this.negative===0&&c.negative!==0?(M=this.divmod(c.neg(),h),h!=="mod"&&(_=M.div.neg()),{div:_,mod:M.mod}):this.negative&c.negative?(M=this.neg().divmod(c.neg(),h),h!=="div"&&(I=M.mod.neg(),v&&I.negative!==0&&I.isub(c)),{div:M.div,mod:I}):c.length>this.length||this.cmp(c)<0?{div:new a(0),mod:this}:c.length===1?h==="div"?{div:this.divn(c.words[0]),mod:null}:h==="mod"?{div:null,mod:new a(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new a(this.modrn(c.words[0]))}:this._wordDiv(c,h)},a.prototype.div=function(c){return this.divmod(c,"div",!1).div},a.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},a.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},a.prototype.divRound=function(c){var h=this.divmod(c);if(h.mod.isZero())return h.div;var v=h.div.negative!==0?h.mod.isub(c):h.mod,_=c.ushrn(1),I=c.andln(1),M=v.cmp(_);return M<0||I===1&&M===0?h.div:h.div.negative!==0?h.div.isubn(1):h.div.iaddn(1)},a.prototype.modrn=function(c){var h=c<0;h&&(c=-c),i(c<=67108863);for(var v=(1<<26)%c,_=0,I=this.length-1;I>=0;I--)_=(v*_+(this.words[I]|0))%c;return h?-_:_},a.prototype.modn=function(c){return this.modrn(c)},a.prototype.idivn=function(c){var h=c<0;h&&(c=-c),i(c<=67108863);for(var v=0,_=this.length-1;_>=0;_--){var I=(this.words[_]|0)+v*67108864;this.words[_]=I/c|0,v=I%c}return this._strip(),h?this.ineg():this},a.prototype.divn=function(c){return this.clone().idivn(c)},a.prototype.egcd=function(c){i(c.negative===0),i(!c.isZero());var h=this,v=c.clone();h.negative!==0?h=h.umod(c):h=h.clone();for(var _=new a(1),I=new a(0),M=new a(0),S=new a(1),d=0;h.isEven()&&v.isEven();)h.iushrn(1),v.iushrn(1),++d;for(var g=v.clone(),C=h.clone();!h.isZero();){for(var Z=0,se=1;!(h.words[0]&se)&&Z<26;++Z,se<<=1);if(Z>0)for(h.iushrn(Z);Z-- >0;)(_.isOdd()||I.isOdd())&&(_.iadd(g),I.isub(C)),_.iushrn(1),I.iushrn(1);for(var P=0,ee=1;!(v.words[0]&ee)&&P<26;++P,ee<<=1);if(P>0)for(v.iushrn(P);P-- >0;)(M.isOdd()||S.isOdd())&&(M.iadd(g),S.isub(C)),M.iushrn(1),S.iushrn(1);h.cmp(v)>=0?(h.isub(v),_.isub(M),I.isub(S)):(v.isub(h),M.isub(_),S.isub(I))}return{a:M,b:S,gcd:v.iushln(d)}},a.prototype._invmp=function(c){i(c.negative===0),i(!c.isZero());var h=this,v=c.clone();h.negative!==0?h=h.umod(c):h=h.clone();for(var _=new a(1),I=new a(0),M=v.clone();h.cmpn(1)>0&&v.cmpn(1)>0;){for(var S=0,d=1;!(h.words[0]&d)&&S<26;++S,d<<=1);if(S>0)for(h.iushrn(S);S-- >0;)_.isOdd()&&_.iadd(M),_.iushrn(1);for(var g=0,C=1;!(v.words[0]&C)&&g<26;++g,C<<=1);if(g>0)for(v.iushrn(g);g-- >0;)I.isOdd()&&I.iadd(M),I.iushrn(1);h.cmp(v)>=0?(h.isub(v),_.isub(I)):(v.isub(h),I.isub(_))}var Z;return h.cmpn(1)===0?Z=_:Z=I,Z.cmpn(0)<0&&Z.iadd(c),Z},a.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var h=this.clone(),v=c.clone();h.negative=0,v.negative=0;for(var _=0;h.isEven()&&v.isEven();_++)h.iushrn(1),v.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;v.isEven();)v.iushrn(1);var I=h.cmp(v);if(I<0){var M=h;h=v,v=M}else if(I===0||v.cmpn(1)===0)break;h.isub(v)}while(!0);return v.iushln(_)},a.prototype.invm=function(c){return this.egcd(c).a.umod(c)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(c){return this.words[0]&c},a.prototype.bincn=function(c){i(typeof c=="number");var h=c%26,v=(c-h)/26,_=1<>>26,S&=67108863,this.words[M]=S}return I!==0&&(this.words[M]=I,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(c){var h=c<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this._strip();var v;if(this.length>1)v=1;else{h&&(c=-c),i(c<=67108863,"Number is too big");var _=this.words[0]|0;v=_===c?0:_c.length)return 1;if(this.length=0;v--){var _=this.words[v]|0,I=c.words[v]|0;if(_!==I){_I&&(h=1);break}}return h},a.prototype.gtn=function(c){return this.cmpn(c)===1},a.prototype.gt=function(c){return this.cmp(c)===1},a.prototype.gten=function(c){return this.cmpn(c)>=0},a.prototype.gte=function(c){return this.cmp(c)>=0},a.prototype.ltn=function(c){return this.cmpn(c)===-1},a.prototype.lt=function(c){return this.cmp(c)===-1},a.prototype.lten=function(c){return this.cmpn(c)<=0},a.prototype.lte=function(c){return this.cmp(c)<=0},a.prototype.eqn=function(c){return this.cmpn(c)===0},a.prototype.eq=function(c){return this.cmp(c)===0},a.red=function(c){return new L(c)},a.prototype.toRed=function(c){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(c){return this.red=c,this},a.prototype.forceRed=function(c){return i(!this.red,"Already a number in reduction context"),this._forceRed(c)},a.prototype.redAdd=function(c){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},a.prototype.redIAdd=function(c){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},a.prototype.redSub=function(c){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},a.prototype.redISub=function(c){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},a.prototype.redShl=function(c){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},a.prototype.redMul=function(c){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},a.prototype.redIMul=function(c){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(c){return i(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var F={k256:null,p224:null,p192:null,p25519:null};function G(c,h){this.name=c,this.p=new a(h,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}G.prototype._tmp=function(){var c=new a(null);return c.words=new Array(Math.ceil(this.n/13)),c},G.prototype.ireduce=function(c){var h=c,v;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),v=h.bitLength();while(v>this.n);var _=v0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},G.prototype.split=function(c,h){c.iushrn(this.n,0,h)},G.prototype.imulK=function(c){return c.imul(this.k)};function x(){G.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(x,G),x.prototype.split=function(c,h){for(var v=4194303,_=Math.min(c.length,9),I=0;I<_;I++)h.words[I]=c.words[I];if(h.length=_,c.length<=9){c.words[0]=0,c.length=1;return}var M=c.words[9];for(h.words[h.length++]=M&v,I=10;I>>22,M=S}M>>>=22,c.words[I-10]=M,M===0&&c.length>10?c.length-=10:c.length-=9},x.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var h=0,v=0;v>>=26,c.words[v]=I,h=_}return h!==0&&(c.words[c.length++]=h),c},a._prime=function(c){if(F[c])return F[c];var h;if(c==="k256")h=new x;else if(c==="p224")h=new q;else if(c==="p192")h=new ae;else if(c==="p25519")h=new le;else throw new Error("Unknown prime "+c);return F[c]=h,h};function L(c){if(typeof c=="string"){var h=a._prime(c);this.m=h.p,this.prime=h}else i(c.gtn(1),"modulus must be greater than 1"),this.m=c,this.prime=null}L.prototype._verify1=function(c){i(c.negative===0,"red works only with positives"),i(c.red,"red works only with red numbers")},L.prototype._verify2=function(c,h){i((c.negative|h.negative)===0,"red works only with positives"),i(c.red&&c.red===h.red,"red works only with red numbers")},L.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(y(c,c.umod(this.m)._forceRed(this)),c)},L.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},L.prototype.add=function(c,h){this._verify2(c,h);var v=c.add(h);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},L.prototype.iadd=function(c,h){this._verify2(c,h);var v=c.iadd(h);return v.cmp(this.m)>=0&&v.isub(this.m),v},L.prototype.sub=function(c,h){this._verify2(c,h);var v=c.sub(h);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},L.prototype.isub=function(c,h){this._verify2(c,h);var v=c.isub(h);return v.cmpn(0)<0&&v.iadd(this.m),v},L.prototype.shl=function(c,h){return this._verify1(c),this.imod(c.ushln(h))},L.prototype.imul=function(c,h){return this._verify2(c,h),this.imod(c.imul(h))},L.prototype.mul=function(c,h){return this._verify2(c,h),this.imod(c.mul(h))},L.prototype.isqr=function(c){return this.imul(c,c.clone())},L.prototype.sqr=function(c){return this.mul(c,c)},L.prototype.sqrt=function(c){if(c.isZero())return c.clone();var h=this.m.andln(3);if(i(h%2===1),h===3){var v=this.m.add(new a(1)).iushrn(2);return this.pow(c,v)}for(var _=this.m.subn(1),I=0;!_.isZero()&&_.andln(1)===0;)I++,_.iushrn(1);i(!_.isZero());var M=new a(1).toRed(this),S=M.redNeg(),d=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new a(2*g*g).toRed(this);this.pow(g,d).cmp(S)!==0;)g.redIAdd(S);for(var C=this.pow(g,_),Z=this.pow(c,_.addn(1).iushrn(1)),se=this.pow(c,_),P=I;se.cmp(M)!==0;){for(var ee=se,B=0;ee.cmp(M)!==0;B++)ee=ee.redSqr();i(B=0;I--){for(var C=h.words[I],Z=g-1;Z>=0;Z--){var se=C>>Z&1;if(M!==_[0]&&(M=this.sqr(M)),se===0&&S===0){d=0;continue}S<<=1,S|=se,d++,!(d!==v&&(I!==0||Z!==0))&&(M=this.mul(M,_[S]),d=0,S=0)}g=26}return M},L.prototype.convertTo=function(c){var h=c.umod(this.m);return h===c?h.clone():h},L.prototype.convertFrom=function(c){var h=c.clone();return h.red=null,h},a.mont=function(c){return new m(c)};function m(c){L.call(this,c),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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)}n(m,L),m.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},m.prototype.convertFrom=function(c){var h=this.imod(c.mul(this.rinv));return h.red=null,h},m.prototype.imul=function(c,h){if(c.isZero()||h.isZero())return c.words[0]=0,c.length=1,c;var v=c.imul(h),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=v.isub(_).iushrn(this.shift),M=I;return I.cmp(this.m)>=0?M=I.isub(this.m):I.cmpn(0)<0&&(M=I.iadd(this.m)),M._forceRed(this)},m.prototype.mul=function(c,h){if(c.isZero()||h.isZero())return new a(0)._forceRed(this);var v=c.mul(h),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=v.isub(_).iushrn(this.shift),M=I;return I.cmp(this.m)>=0?M=I.isub(this.m):I.cmpn(0)<0&&(M=I.iadd(this.m)),M._forceRed(this)},m.prototype.invm=function(c){var h=this.imod(c._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(r,Bb)})(jb);var vt=jb.exports;const kb="bignumber/5.7.0";var ph=vt.BN;const os=new Or(kb),yl={},V1=9007199254740991;function NA(r){return r!=null&&(Gt.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||_i(r)||typeof r=="bigint"||bo(r))}let G1=!1;class Gt{constructor(e,t){e!==yl&&os.throwError("cannot call constructor directly; use BigNumber.from",Or.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return si(Pt(this).fromTwos(e))}toTwos(e){return si(Pt(this).toTwos(e))}abs(){return this._hex[0]==="-"?Gt.from(this._hex.substring(1)):this}add(e){return si(Pt(this).add(Pt(e)))}sub(e){return si(Pt(this).sub(Pt(e)))}div(e){return Gt.from(e).isZero()&&Li("division-by-zero","div"),si(Pt(this).div(Pt(e)))}mul(e){return si(Pt(this).mul(Pt(e)))}mod(e){const t=Pt(e);return t.isNeg()&&Li("division-by-zero","mod"),si(Pt(this).umod(t))}pow(e){const t=Pt(e);return t.isNeg()&&Li("negative-power","pow"),si(Pt(this).pow(t))}and(e){const t=Pt(e);return(this.isNegative()||t.isNeg())&&Li("unbound-bitwise-result","and"),si(Pt(this).and(t))}or(e){const t=Pt(e);return(this.isNegative()||t.isNeg())&&Li("unbound-bitwise-result","or"),si(Pt(this).or(t))}xor(e){const t=Pt(e);return(this.isNegative()||t.isNeg())&&Li("unbound-bitwise-result","xor"),si(Pt(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&Li("negative-width","mask"),si(Pt(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Li("negative-width","shl"),si(Pt(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Li("negative-width","shr"),si(Pt(this).shrn(e))}eq(e){return Pt(this).eq(Pt(e))}lt(e){return Pt(this).lt(Pt(e))}lte(e){return Pt(this).lte(Pt(e))}gt(e){return Pt(this).gt(Pt(e))}gte(e){return Pt(this).gte(Pt(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Pt(this).isZero()}toNumber(){try{return Pt(this).toNumber()}catch{Li("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return os.throwError("this platform does not support BigInt",Or.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?G1||(G1=!0,os.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?os.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Or.errors.UNEXPECTED_ARGUMENT,{}):os.throwError("BigNumber.toString does not accept parameters",Or.errors.UNEXPECTED_ARGUMENT,{})),Pt(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof Gt)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new Gt(yl,pc(e)):e.match(/^-?[0-9]+$/)?new Gt(yl,pc(new ph(e))):os.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Li("underflow","BigNumber.from",e),(e>=V1||e<=-V1)&&Li("overflow","BigNumber.from",e),Gt.from(String(e));const t=e;if(typeof t=="bigint")return Gt.from(t.toString());if(bo(t))return Gt.from(ci(t));if(t)if(t.toHexString){const i=t.toHexString();if(typeof i=="string")return Gt.from(i)}else{let i=t._hex;if(i==null&&t.type==="BigNumber"&&(i=t.hex),typeof i=="string"&&(_i(i)||i[0]==="-"&&_i(i.substring(1))))return Gt.from(i)}return os.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function pc(r){if(typeof r!="string")return pc(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&os.throwArgumentError("invalid hex","value",r),r=pc(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function si(r){return Gt.from(pc(r))}function Pt(r){const e=Gt.from(r).toHexString();return e[0]==="-"?new ph("-"+e.substring(3),16):new ph(e.substring(2),16)}function Li(r,e,t){const i={fault:r,operation:e};return t!=null&&(i.value=t),os.throwError(r,Or.errors.NUMERIC_FAULT,i)}function TA(r){return new ph(r,36).toString(16)}const Wr=new Or(kb),oc={},Fb=Gt.from(0),Hb=Gt.from(-1);function Kb(r,e,t,i){const n={fault:e,operation:t};return i!==void 0&&(n.value=i),Wr.throwError(r,Or.errors.NUMERIC_FAULT,n)}let cc="0";for(;cc.length<256;)cc+=cc;function Fd(r){if(typeof r!="number")try{r=Gt.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+cc.substring(0,r):Wr.throwArgumentError("invalid decimal size","decimals",r)}function wl(r,e){e==null&&(e=0);const t=Fd(e);r=Gt.from(r);const i=r.lt(Fb);i&&(r=r.mul(Hb));let n=r.mod(t).toString();for(;n.length2&&Wr.throwArgumentError("too many decimal points","value",r);let a=n[0],f=n[1];for(a||(a="0"),f||(f="0");f[f.length-1]==="0";)f=f.substring(0,f.length-1);for(f.length>t.length-1&&Kb("fractional component exceeds decimals","underflow","parseFixed"),f===""&&(f="0");f.lengthe[f]==null?b:(typeof e[f]!==u&&Wr.throwArgumentError("invalid fixed format ("+f+" not "+u+")","format."+f,e[f]),e[f]);t=a("signed","boolean",t),i=a("width","number",i),n=a("decimals","number",n)}return i%8&&Wr.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Wr.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new ad(oc,t,i,n)}},Vb=class Vr{constructor(e,t,i,n){e!==oc&&Wr.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Or.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Wr.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=is(this._value,this.format.decimals),i=is(e._value,e.format.decimals);return Vr.fromValue(t.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=is(this._value,this.format.decimals),i=is(e._value,e.format.decimals);return Vr.fromValue(t.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=is(this._value,this.format.decimals),i=is(e._value,e.format.decimals);return Vr.fromValue(t.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=is(this._value,this.format.decimals),i=is(e._value,e.format.decimals);return Vr.fromValue(t.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Vr.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(t=t.subUnsafe(W1.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Vr.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(t=t.addUnsafe(W1.toFormat(t.format))),t}round(e){e==null&&(e=0);const t=this.toString().split(".");if(t.length===1&&t.push("0"),(e<0||e>80||e%1)&&Wr.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const i=Vr.from("1"+cc.substring(0,e),this.format),n=CA.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(n).floor().divUnsafe(i)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&Wr.throwArgumentError("invalid byte width","width",e);const t=Gt.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Cn(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Vr.fromString(this._value,e)}static fromValue(e,t,i){return i==null&&t!=null&&!NA(t)&&(i=t,t=null),t==null&&(t=0),i==null&&(i="fixed"),Vr.fromString(wl(e,t),_l.from(i))}static fromString(e,t){t==null&&(t="fixed");const i=_l.from(t),n=is(e,i.decimals);!i.signed&&n.lt(Fb)&&Kb("unsigned value cannot be negative","overflow","value",e);let a=null;i.signed?a=n.toTwos(i.width).toHexString():(a=n.toHexString(),a=Cn(a,i.width/8));const f=wl(n,i.decimals);return new Vr(oc,a,f,i)}static fromBytes(e,t){t==null&&(t="fixed");const i=_l.from(t);if(ir(e).length>i.width/8)throw new Error("overflow");let n=Gt.from(e);i.signed&&(n=n.fromTwos(i.width));const a=n.toTwos((i.signed?0:1)+i.width).toHexString(),f=wl(n,i.decimals);return new Vr(oc,a,f,i)}static from(e,t){if(typeof e=="string")return Vr.fromString(e,t);if(bo(e))return Vr.fromBytes(e,t);try{return Vr.fromValue(e,0,t)}catch(i){if(i.code!==Or.errors.INVALID_ARGUMENT)throw i}return Wr.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}};const W1=Vb.from(1),CA=Vb.from("0.5"),DA="strings/5.7.0",LA=new Or(DA);var gh;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(gh||(gh={}));var J1;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(J1||(J1={}));function Al(r,e=gh.current){e!=gh.current&&(LA.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;const a=r.charCodeAt(i);if(i>=r.length||(a&64512)!==56320)throw new Error("invalid utf-8 string");const f=65536+((n&1023)<<10)+(a&1023);t.push(f>>18|240),t.push(f>>12&63|128),t.push(f>>6&63|128),t.push(f&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return ir(t)}function qA(r){if(r.length%4!==0)throw new Error("bad data");let e=[];for(let t=0;t{let a=n.split(":");t+=parseInt(a[0],16),i[t]=e(a[1])}),i}function Y1(r){let e=0;return r.split(",").map(t=>{let i=t.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let n=e+parseInt(i[0],16);return e=parseInt(i[1],16),{l:n,h:e}})}Y1("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(r=>parseInt(r,16)),El("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),El("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),El("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",qA),Y1("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function BA(r){r=atob(r);const e=[];for(let t=0;t0&&Array.isArray(u)?n(u,f-1):t.push(u)})};return n(r,e),t}function UA(r){const e={};for(let t=0;t>--b&1}const A=31,R=Math.pow(2,A),O=R>>>1,N=O>>1,K=R-1;let W=0;for(let F=0;F1;){let le=G+x>>>1;F>>1|y(),q=q<<1^O,ae=(ae^O)<<1|O|1;k=q,Y=1+ae-q}let $=i-4;return Q.map(F=>{switch(F-$){case 3:return $+65792+(r[u++]<<16|r[u++]<<8|r[u++]);case 2:return $+256+(r[u++]<<8|r[u++]);case 1:return $+r[u++];default:return F-1}})}function zA(r){let e=0;return()=>r[e++]}function jA(r){return zA($A(r))}function kA(r){return r&1?~r>>1:r>>1}function FA(r,e){let t=Array(r);for(let i=0;ie[f]):t}function KA(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(GA(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(WA(t,r))}return UA(Gb(e))}function VA(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(t)}return e}function Wb(r,e,t){let i=Array(r).fill(void 0).map(()=>[]);for(let n=0;ni[f].push(a));return i}function GA(r,e){let t=1+e(),i=e(),n=VA(e),a=Wb(n.length,1+r,e);return Gb(a.map((f,u)=>{const b=f[0],p=f.slice(1);return Array(n[u]).fill(void 0).map((y,A)=>{let R=A*i;return[b+A*t,p.map(O=>O+R)]})}))}function WA(r,e){let t=1+e();return Wb(t,1+r,e).map(i=>[i[0],i.slice(1)])}function JA(r){let e=vh(r).sort((i,n)=>i-n);return t();function t(){let i=[];for(;;){let p=vh(r,e);if(p.length==0)break;i.push({set:new Set(p),node:t()})}i.sort((p,y)=>y.set.size-p.set.size);let n=r(),a=n%3;n=n/3|0;let f=!!(n&1);n>>=1;let u=n==1,b=n==2;return{branches:i,valid:a,fe0f:f,save:u,check:b}}}function YA(){return jA(BA("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=="))}const Uf=YA();new Set(vh(Uf)),new Set(vh(Uf)),KA(Uf),JA(Uf);const QA=new Uint8Array(32);QA.fill(0);const XA=`Ethereum Signed Message: +`;function Jb(r){return typeof r=="string"&&(r=Al(r)),kd(SA([Al(XA),Al(String(r.length)),r]))}const ZA="address/5.7.0",ic=new Or(ZA);function X1(r){_i(r,20)||ic.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);const i=ir(kd(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}const eE=9007199254740991;function tE(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const Hd={};for(let r=0;r<10;r++)Hd[String(r)]=String(r);for(let r=0;r<26;r++)Hd[String.fromCharCode(65+r)]=String(10+r);const Z1=Math.floor(tE(eE));function rE(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Hd[i]).join("");for(;e.length>=Z1;){let i=e.substring(0,Z1);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function iE(r){let e=null;if(typeof r!="string"&&ic.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=X1(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&ic.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==rE(r)&&ic.throwArgumentError("bad icap checksum","address",r),e=TA(r.substring(4));e.length<40;)e="0"+e;e=X1("0x"+e)}else ic.throwArgumentError("invalid address","address",r);return e}function Go(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}const nE=new Uint8Array(32);nE.fill(0),Gt.from(-1);const sE=Gt.from(0),aE=Gt.from(1);Gt.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Cn(aE.toHexString(),32),Cn(sE.toHexString(),32);var xn={},Rt={},Mc=Yb;function Yb(r,e){if(!r)throw new Error(e||"Assertion failed")}Yb.equal=function(r,e,t){if(r!=e)throw new Error(t||"Assertion failed: "+r+" != "+e)};var od={exports:{}};typeof Object.create=="function"?od.exports=function(r,e){e&&(r.super_=e,r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:od.exports=function(r,e){if(e){r.super_=e;var t=function(){};t.prototype=e.prototype,r.prototype=new t,r.prototype.constructor=r}};var oE=Mc,cE=od.exports;Rt.inherits=cE;function fE(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function hE(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=a&63|128):fE(r,n)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=a>>18|240,t[i++]=a>>12&63|128,t[i++]=a>>6&63|128,t[i++]=a&63|128):(t[i++]=a>>12|224,t[i++]=a>>6&63|128,t[i++]=a&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Rt.htonl=Qb;function lE(r,e){for(var t="",i=0;i>>0}return a}Rt.join32=dE;function pE(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=a>>>16&255,t[n+2]=a>>>8&255,t[n+3]=a&255):(t[n+3]=a>>>24,t[n+2]=a>>>16&255,t[n+1]=a>>>8&255,t[n]=a&255)}return t}Rt.split32=pE;function gE(r,e){return r>>>e|r<<32-e}Rt.rotr32=gE;function vE(r,e){return r<>>32-e}Rt.rotl32=vE;function bE(r,e){return r+e>>>0}Rt.sum32=bE;function mE(r,e,t){return r+e+t>>>0}Rt.sum32_3=mE;function yE(r,e,t,i){return r+e+t+i>>>0}Rt.sum32_4=yE;function wE(r,e,t,i,n){return r+e+t+i+n>>>0}Rt.sum32_5=wE;function _E(r,e,t,i){var n=r[e],a=r[e+1],f=i+a>>>0,u=(f>>0,r[e+1]=f}Rt.sum64=_E;function AE(r,e,t,i){var n=e+i>>>0,a=(n>>0}Rt.sum64_hi=AE;function EE(r,e,t,i){var n=e+i;return n>>>0}Rt.sum64_lo=EE;function xE(r,e,t,i,n,a,f,u){var b=0,p=e;p=p+i>>>0,b+=p>>0,b+=p>>0,b+=p>>0}Rt.sum64_4_hi=xE;function SE(r,e,t,i,n,a,f,u){var b=e+i+a+u;return b>>>0}Rt.sum64_4_lo=SE;function IE(r,e,t,i,n,a,f,u,b,p){var y=0,A=e;A=A+i>>>0,y+=A>>0,y+=A>>0,y+=A>>0,y+=A>>0}Rt.sum64_5_hi=IE;function ME(r,e,t,i,n,a,f,u,b,p){var y=e+i+a+u+p;return y>>>0}Rt.sum64_5_lo=ME;function PE(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Rt.rotr64_hi=PE;function OE(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Rt.rotr64_lo=OE;function RE(r,e,t){return r>>>t}Rt.shr64_hi=RE;function NE(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Rt.shr64_lo=NE;var mo={},eg=Rt,TE=Mc;function $f(){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}mo.BlockHash=$f,$f.prototype.update=function(r,e){if(r=eg.toArray(r,e),this.pending?this.pending=this.pending.concat(r):this.pending=r,this.pendingTotal+=r.length,this.pending.length>=this._delta8){r=this.pending;var t=r.length%this._delta8;this.pending=r.slice(r.length-t,r.length),this.pending.length===0&&(this.pending=null),r=eg.join32(r,0,r.length-t,this.endian);for(var i=0;i>>24&255,i[n++]=r>>>16&255,i[n++]=r>>>8&255,i[n++]=r&255}else for(i[n++]=r&255,i[n++]=r>>>8&255,i[n++]=r>>>16&255,i[n++]=r>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,a=8;a>>3}Kn.g0_256=BE;function UE(r){return Dn(r,17)^Dn(r,19)^r>>>10}Kn.g1_256=UE;var ao=Rt,$E=mo,zE=Kn,xl=ao.rotl32,Wo=ao.sum32,jE=ao.sum32_5,kE=zE.ft_1,im=$E.BlockHash,FE=[1518500249,1859775393,2400959708,3395469782];function Pn(){if(!(this instanceof Pn))return new Pn;im.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}ao.inherits(Pn,im);var HE=Pn;Pn.blockSize=512,Pn.outSize=160,Pn.hmacStrength=80,Pn.padLength=64,Pn.prototype._update=function(r,e){for(var t=this.W,i=0;i<16;i++)t[i]=r[e+i];for(;ithis.blockSize&&(r=new this.Hash().update(r).digest()),Nx(r.length<=this.blockSize);for(var e=r.length;e>8,R=y&255;A?b.push(A,R):b.push(R)}return b}t.toArray=i;function n(f){return f.length===1?"0"+f:f}t.zero2=n;function a(f){for(var u="",b=0;b(R>>1)-1?K=(R>>1)-W:K=W,O.isubn(K)):K=0,A[N]=K,O.iushrn(1)}return A}t.getNAF=i;function n(b,p){var y=[[],[]];b=b.clone(),p=p.clone();for(var A=0,R=0,O;b.cmpn(-A)>0||p.cmpn(-R)>0;){var N=b.andln(3)+A&3,K=p.andln(3)+R&3;N===3&&(N=-1),K===3&&(K=-1);var W;N&1?(O=b.andln(7)+A&7,(O===3||O===5)&&K===2?W=-N:W=N):W=0,y[0].push(W);var Q;K&1?(O=p.andln(7)+R&7,(O===3||O===5)&&N===2?Q=-K:Q=K):Q=0,y[1].push(Q),2*A===W+1&&(A=1-A),2*R===Q+1&&(R=1-R),b.iushrn(1),p.iushrn(1)}return y}t.getJSF=n;function a(b,p,y){var A="_"+p;b.prototype[p]=function(){return this[A]!==void 0?this[A]:this[A]=y.call(this)}}t.cachedProperty=a;function f(b){return typeof b=="string"?t.toArray(b,"hex"):b}t.parseBytes=f;function u(b){return new vt(b,"hex","le")}t.intFromLE=u}),jf=Ai.getNAF,Dx=Ai.getJSF,bh=Ai.assert;function Ts(r,e){this.type=r,this.p=new vt(e.p,16),this.red=e.prime?vt.red(e.prime):vt.mont(this.p),this.zero=new vt(0).toRed(this.red),this.one=new vt(1).toRed(this.red),this.two=new vt(2).toRed(this.red),this.n=e.n&&new vt(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var _a=Ts;Ts.prototype.point=function(){throw new Error("Not implemented")},Ts.prototype.validate=function(){throw new Error("Not implemented")},Ts.prototype._fixedNafMul=function(r,e){bh(r.precomputed);var t=r._getDoubles(),i=jf(e,1,this._bitLength),n=(1<=f;b--)u=(u<<1)+i[b];a.push(u)}for(var p=this.jpoint(null,null,null),y=this.jpoint(null,null,null),A=n;A>0;A--){for(f=0;f=0;u--){for(var b=0;u>=0&&a[u]===0;u--)b++;if(u>=0&&b++,f=f.dblp(b),u<0)break;var p=a[u];bh(p!==0),r.type==="affine"?p>0?f=f.mixedAdd(n[p-1>>1]):f=f.mixedAdd(n[-p-1>>1].neg()):p>0?f=f.add(n[p-1>>1]):f=f.add(n[-p-1>>1].neg())}return r.type==="affine"?f.toP():f},Ts.prototype._wnafMulAdd=function(r,e,t,i,n){var a=this._wnafT1,f=this._wnafT2,u=this._wnafT3,b=0,p,y,A;for(p=0;p=1;p-=2){var O=p-1,N=p;if(a[O]!==1||a[N]!==1){u[O]=jf(t[O],a[O],this._bitLength),u[N]=jf(t[N],a[N],this._bitLength),b=Math.max(u[O].length,b),b=Math.max(u[N].length,b);continue}var K=[e[O],null,null,e[N]];e[O].y.cmp(e[N].y)===0?(K[1]=e[O].add(e[N]),K[2]=e[O].toJ().mixedAdd(e[N].neg())):e[O].y.cmp(e[N].y.redNeg())===0?(K[1]=e[O].toJ().mixedAdd(e[N]),K[2]=e[O].add(e[N].neg())):(K[1]=e[O].toJ().mixedAdd(e[N]),K[2]=e[O].toJ().mixedAdd(e[N].neg()));var W=[-3,-1,-5,-7,0,7,5,1,3],Q=Dx(t[O],t[N]);for(b=Math.max(Q[0].length,b),u[O]=new Array(b),u[N]=new Array(b),y=0;y=0;p--){for(var G=0;p>=0;){var x=!0;for(y=0;y=0&&G++,$=$.dblp(G),p<0)break;for(y=0;y0?A=f[y][q-1>>1]:q<0&&(A=f[y][-q-1>>1].neg()),A.type==="affine"?$=$.mixedAdd(A):$=$.add(A))}}for(p=0;p=Math.ceil((r.bitLength()+1)/e.step):!1},qi.prototype._getDoubles=function(r,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var t=[this],i=this,n=0;n=0&&(R=b,O=p),y.negative&&(y=y.neg(),A=A.neg()),R.negative&&(R=R.neg(),O=O.neg()),[{a:y,b:A},{a:R,b:O}]},ji.prototype._endoSplit=function(r){var e=this.endo.basis,t=e[0],i=e[1],n=i.b.mul(r).divRound(this.n),a=t.b.neg().mul(r).divRound(this.n),f=n.mul(t.a),u=a.mul(i.a),b=n.mul(t.b),p=a.mul(i.b),y=r.sub(f).sub(u),A=b.add(p).neg();return{k1:y,k2:A}},ji.prototype.pointFromX=function(r,e){r=new vt(r,16),r.red||(r=r.toRed(this.red));var t=r.redSqr().redMul(r).redIAdd(r.redMul(this.a)).redIAdd(this.b),i=t.redSqrt();if(i.redSqr().redSub(t).cmp(this.zero)!==0)throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(r,i)},ji.prototype.validate=function(r){if(r.inf)return!0;var e=r.x,t=r.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return t.redSqr().redISub(n).cmpn(0)===0},ji.prototype._endoWnafMulAdd=function(r,e,t){for(var i=this._endoWnafT1,n=this._endoWnafT2,a=0;a":""},yr.prototype.isInfinity=function(){return this.inf},yr.prototype.add=function(r){if(this.inf)return r;if(r.inf)return this;if(this.eq(r))return this.dbl();if(this.neg().eq(r))return this.curve.point(null,null);if(this.x.cmp(r.x)===0)return this.curve.point(null,null);var e=this.y.redSub(r.y);e.cmpn(0)!==0&&(e=e.redMul(this.x.redSub(r.x).redInvm()));var t=e.redSqr().redISub(this.x).redISub(r.x),i=e.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,i)},yr.prototype.dbl=function(){if(this.inf)return this;var r=this.y.redAdd(this.y);if(r.cmpn(0)===0)return this.curve.point(null,null);var e=this.curve.a,t=this.x.redSqr(),i=r.redInvm(),n=t.redAdd(t).redIAdd(t).redIAdd(e).redMul(i),a=n.redSqr().redISub(this.x.redAdd(this.x)),f=n.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,f)},yr.prototype.getX=function(){return this.x.fromRed()},yr.prototype.getY=function(){return this.y.fromRed()},yr.prototype.mul=function(r){return r=new vt(r,16),this.isInfinity()?this:this._hasDoubles(r)?this.curve._fixedNafMul(this,r):this.curve.endo?this.curve._endoWnafMulAdd([this],[r]):this.curve._wnafMul(this,r)},yr.prototype.mulAdd=function(r,e,t){var i=[this,e],n=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},yr.prototype.jmulAdd=function(r,e,t){var i=[this,e],n=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},yr.prototype.eq=function(r){return this===r||this.inf===r.inf&&(this.inf||this.x.cmp(r.x)===0&&this.y.cmp(r.y)===0)},yr.prototype.neg=function(r){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(r&&this.precomputed){var t=this.precomputed,i=function(n){return n.neg()};e.precomputed={naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e},yr.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var r=this.curve.jpoint(this.x,this.y,this.curve.one);return r};function Pr(r,e,t,i){_a.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new vt(0)):(this.x=new vt(e,16),this.y=new vt(t,16),this.z=new vt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Vd(Pr,_a.BasePoint),ji.prototype.jpoint=function(r,e,t){return new Pr(this,r,e,t)},Pr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var r=this.z.redInvm(),e=r.redSqr(),t=this.x.redMul(e),i=this.y.redMul(e).redMul(r);return this.curve.point(t,i)},Pr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Pr.prototype.add=function(r){if(this.isInfinity())return r;if(r.isInfinity())return this;var e=r.z.redSqr(),t=this.z.redSqr(),i=this.x.redMul(e),n=r.x.redMul(t),a=this.y.redMul(e.redMul(r.z)),f=r.y.redMul(t.redMul(this.z)),u=i.redSub(n),b=a.redSub(f);if(u.cmpn(0)===0)return b.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var p=u.redSqr(),y=p.redMul(u),A=i.redMul(p),R=b.redSqr().redIAdd(y).redISub(A).redISub(A),O=b.redMul(A.redISub(R)).redISub(a.redMul(y)),N=this.z.redMul(r.z).redMul(u);return this.curve.jpoint(R,O,N)},Pr.prototype.mixedAdd=function(r){if(this.isInfinity())return r.toJ();if(r.isInfinity())return this;var e=this.z.redSqr(),t=this.x,i=r.x.redMul(e),n=this.y,a=r.y.redMul(e).redMul(this.z),f=t.redSub(i),u=n.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=f.redSqr(),p=b.redMul(f),y=t.redMul(b),A=u.redSqr().redIAdd(p).redISub(y).redISub(y),R=u.redMul(y.redISub(A)).redISub(n.redMul(p)),O=this.z.redMul(f);return this.curve.jpoint(A,R,O)},Pr.prototype.dblp=function(r){if(r===0)return this;if(this.isInfinity())return this;if(!r)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var t=this;for(e=0;e=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}},Pr.prototype.inspect=function(){return this.isInfinity()?"":""},Pr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Zf=wo(function(r,e){var t=e;t.base=_a,t.short=qx,t.mont=null,t.edwards=null}),eh=wo(function(r,e){var t=e,i=Ai.assert;function n(u){u.type==="short"?this.curve=new Zf.short(u):u.type==="edwards"?this.curve=new Zf.edwards(u):this.curve=new Zf.mont(u),this.g=this.curve.g,this.n=this.curve.n,this.hash=u.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function a(u,b){Object.defineProperty(t,u,{configurable:!0,enumerable:!0,get:function(){var p=new n(b);return Object.defineProperty(t,u,{configurable:!0,enumerable:!0,value:p}),p}})}a("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:xn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("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:xn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("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:xn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("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:xn.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"]}),a("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:xn.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"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:xn.sha256,gRed:!1,g:["9"]}),a("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:xn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var f;try{f=null.crash()}catch{f=void 0}a("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:xn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})});function Cs(r){if(!(this instanceof Cs))return new Cs(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=un.toArray(r.entropy,r.entropyEnc||"hex"),t=un.toArray(r.nonce,r.nonceEnc||"hex"),i=un.toArray(r.pers,r.persEnc||"hex");Kd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var ng=Cs;Cs.prototype._init=function(r,e,t){var i=r.concat(e).concat(t);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(r.concat(t||[])),this._reseed=1},Cs.prototype.generate=function(r,e,t,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof e!="string"&&(i=t,t=e,e=null),t&&(t=un.toArray(t,i||"hex"),this._update(t));for(var n=[];n.length"};var Bx=Ai.assert;function kh(r,e){if(r instanceof kh)return r;this._importDER(r,e)||(Bx(r.r&&r.s,"Signature without r or s"),this.r=new vt(r.r,16),this.s=new vt(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var kf=kh;function Ux(){this.place=0}function Ol(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,a=0,f=e.place;a>>=0;return n<=127?!1:(e.place=f,n)}function sg(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}kh.prototype.toDER=function(r){var e=this.r.toArray(),t=this.s.toArray();for(e[0]&128&&(e=[0].concat(e)),t[0]&128&&(t=[0].concat(t)),e=sg(e),t=sg(t);!t[0]&&!(t[1]&128);)t=t.slice(1);var i=[2];Rl(i,e.length),i=i.concat(e),i.push(2),Rl(i,t.length);var n=i.concat(t),a=[48];return Rl(a,n.length),a=a.concat(n),Ai.encode(a,r)};var $x=function(){throw new Error("unsupported")},gm=Ai.assert;function $i(r){if(!(this instanceof $i))return new $i(r);typeof r=="string"&&(gm(Object.prototype.hasOwnProperty.call(eh,r),"Unknown curve "+r),r=eh[r]),r instanceof eh.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var zx=$i;$i.prototype.keyPair=function(r){return new Pl(this,r)},$i.prototype.keyFromPrivate=function(r,e){return Pl.fromPrivate(this,r,e)},$i.prototype.keyFromPublic=function(r,e){return Pl.fromPublic(this,r,e)},$i.prototype.genKeyPair=function(r){r||(r={});for(var e=new ng({hash:this.hash,pers:r.pers,persEnc:r.persEnc||"utf8",entropy:r.entropy||$x(this.hash.hmacStrength),entropyEnc:r.entropy&&r.entropyEnc||"utf8",nonce:this.n.toArray()}),t=this.n.byteLength(),i=this.n.sub(new vt(2));;){var n=new vt(e.generate(t));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},$i.prototype._truncateToN=function(r,e){var t=r.byteLength()*8-this.n.bitLength();return t>0&&(r=r.ushrn(t)),!e&&r.cmp(this.n)>=0?r.sub(this.n):r},$i.prototype.sign=function(r,e,t,i){typeof t=="object"&&(i=t,t=null),i||(i={}),e=this.keyFromPrivate(e,t),r=this._truncateToN(new vt(r,16));for(var n=this.n.byteLength(),a=e.getPrivate().toArray("be",n),f=r.toArray("be",n),u=new ng({hash:this.hash,entropy:a,nonce:f,pers:i.pers,persEnc:i.persEnc||"utf8"}),b=this.n.sub(new vt(1)),p=0;;p++){var y=i.k?i.k(p):new vt(u.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(b)>=0)){var A=this.g.mul(y);if(!A.isInfinity()){var R=A.getX(),O=R.umod(this.n);if(O.cmpn(0)!==0){var N=y.invm(this.n).mul(O.mul(e.getPrivate()).iadd(r));if(N=N.umod(this.n),N.cmpn(0)!==0){var K=(A.getY().isOdd()?1:0)|(R.cmp(O)!==0?2:0);return i.canonical&&N.cmp(this.nh)>0&&(N=this.n.sub(N),K^=1),new kf({r:O,s:N,recoveryParam:K})}}}}}},$i.prototype.verify=function(r,e,t,i){r=this._truncateToN(new vt(r,16)),t=this.keyFromPublic(t,i),e=new kf(e,"hex");var n=e.r,a=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var f=a.invm(this.n),u=f.mul(r).umod(this.n),b=f.mul(n).umod(this.n),p;return this.curve._maxwellTrick?(p=this.g.jmulAdd(u,t.getPublic(),b),p.isInfinity()?!1:p.eqXToP(n)):(p=this.g.mulAdd(u,t.getPublic(),b),p.isInfinity()?!1:p.getX().umod(this.n).cmp(n)===0)},$i.prototype.recoverPubKey=function(r,e,t,i){gm((3&t)===t,"The recovery param is more than two bits"),e=new kf(e,i);var n=this.n,a=new vt(r),f=e.r,u=e.s,b=t&1,p=t>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&p)throw new Error("Unable to find sencond key candinate");p?f=this.curve.pointFromX(f.add(this.curve.n),b):f=this.curve.pointFromX(f,b);var y=e.r.invm(n),A=n.sub(a).mul(y).umod(n),R=u.mul(y).umod(n);return this.g.mulAdd(A,f,R)},$i.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new kf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var a;try{a=this.recoverPubKey(r,e,n)}catch{continue}if(a.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var jx=wo(function(r,e){var t=e;t.version="6.5.4",t.utils=Ai,t.rand=function(){throw new Error("unsupported")},t.curve=Zf,t.curves=eh,t.ec=zx,t.eddsa=null}),kx=jx.ec;const Fx="signing-key/5.7.0",hd=new Or(Fx);let Nl=null;function Rs(){return Nl||(Nl=new kx("secp256k1")),Nl}class Hx{constructor(e){Go(this,"curve","secp256k1"),Go(this,"privateKey",ci(e)),MA(this.privateKey)!==32&&hd.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=Rs().keyFromPrivate(ir(this.privateKey));Go(this,"publicKey","0x"+t.getPublic(!1,"hex")),Go(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Go(this,"_isSigningKey",!0)}_addPoint(e){const t=Rs().keyFromPublic(ir(this.publicKey)),i=Rs().keyFromPublic(ir(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=Rs().keyFromPrivate(ir(this.privateKey)),i=ir(e);i.length!==32&&hd.throwArgumentError("bad digest length","digest",e);const n=t.sign(i,{canonical:!0});return zb({recoveryParam:n.recoveryParam,r:Cn("0x"+n.r.toString(16),32),s:Cn("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=Rs().keyFromPrivate(ir(this.privateKey)),i=Rs().keyFromPublic(ir(vm(e)));return Cn("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function Kx(r,e){const t=zb(e),i={r:ir(t.r),s:ir(t.s)};return"0x"+Rs().recoverPubKey(ir(r),i,t.recoveryParam).encode("hex",!1)}function vm(r,e){const t=ir(r);return t.length===32?new Hx(t).publicKey:t.length===33?"0x"+Rs().keyFromPublic(t).getPublic(!1,"hex"):t.length===65?ci(t):hd.throwArgumentError("invalid public or private key","key","[REDACTED]")}var ag;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(ag||(ag={}));function Vx(r){const e=vm(r);return iE(K1(kd(K1(e,1)),12))}function Gx(r,e){return Vx(Kx(ir(r),e))}const Wx="https://rpc.walletconnect.org/v1";async function Jx(r,e,t,i,n,a){switch(t.t){case"eip191":return Yx(r,e,t.s);case"eip1271":return await Qx(r,e,t.s,i,n,a);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function Yx(r,e,t){return Gx(Jb(e),t).toLowerCase()===r.toLowerCase()}async function Qx(r,e,t,i,n,a){try{const f="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",b="0000000000000000000000000000000000000000000000000000000000000041",p=t.substring(2),y=Jb(e).substring(2),A=f+y+u+b+p,R=await fetch(`${a||Wx}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:Xx(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:A},"latest"]})}),{result:O}=await R.json();return O?O.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function Xx(){return Date.now()+Math.floor(Math.random()*1e3)}var Zx=Object.defineProperty,eS=Object.defineProperties,tS=Object.getOwnPropertyDescriptors,og=Object.getOwnPropertySymbols,rS=Object.prototype.hasOwnProperty,iS=Object.prototype.propertyIsEnumerable,cg=(r,e,t)=>e in r?Zx(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nS=(r,e)=>{for(var t in e||(e={}))rS.call(e,t)&&cg(r,t,e[t]);if(og)for(var t of og(e))iS.call(e,t)&&cg(r,t,e[t]);return r},sS=(r,e)=>eS(r,tS(e));const aS="did:pkh:",Gd=r=>r==null?void 0:r.split(":"),bm=r=>{const e=r&&Gd(r);if(e)return r.includes(aS)?e[3]:e[1]},fg=r=>{const e=r&&Gd(r);if(e)return e[2]+":"+e[3]},mh=r=>{const e=r&&Gd(r);if(e)return e.pop()};async function hg(r){const{cacao:e,projectId:t}=r,{s:i,p:n}=e,a=mm(n,n.iss),f=mh(n.iss);return await Jx(f,a,i,bm(n.iss),t)}const mm=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=mh(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0;const a=`URI: ${r.aud||r.uri}`,f=`Version: ${r.version}`,u=`Chain ID: ${bm(e)}`,b=`Nonce: ${r.nonce}`,p=`Issued At: ${r.iat}`,y=r.exp?`Expiration Time: ${r.exp}`:void 0,A=r.nbf?`Not Before: ${r.nbf}`:void 0,R=r.requestId?`Request ID: ${r.requestId}`:void 0,O=r.resources?`Resources:${r.resources.map(K=>` +- ${K}`).join("")}`:void 0,N=th(r.resources);if(N){const K=gc(N);n=gS(n,K)}return[t,i,"",n,"",a,f,u,b,p,y,A,R,O].filter(K=>K!=null).join(` +`)};function oS(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function cS(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function va(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{const a=i[n];if(!Array.isArray(a))throw new Error(`Ability limits ${n} must be an array of objects, found: ${a}`);if(!a.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);a.forEach(f=>{if(typeof f!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${f}`)})})})}function fS(r,e,t,i={}){return t==null||t.sort((n,a)=>n.localeCompare(a)),{att:{[r]:hS(e,t,i)}}}function hS(r,e,t={}){e=e==null?void 0:e.sort((n,a)=>n.localeCompare(a));const i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function ym(r){return va(r),`urn:recap:${oS(r).replace(/=/g,"")}`}function gc(r){const e=cS(r.replace("urn:recap:",""));return va(e),e}function uS(r,e,t){const i=fS(r,e,t);return ym(i)}function lS(r){return r&&r.includes("urn:recap:")}function dS(r,e){const t=gc(r),i=gc(e),n=pS(t,i);return ym(n)}function pS(r,e){va(r),va(e);const t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,a)=>n.localeCompare(a)),i={att:{}};return t.forEach(n=>{var a,f;Object.keys(((a=r.att)==null?void 0:a[n])||{}).concat(Object.keys(((f=e.att)==null?void 0:f[n])||{})).sort((u,b)=>u.localeCompare(b)).forEach(u=>{var b,p;i.att[n]=sS(nS({},i.att[n]),{[u]:((b=r.att[n])==null?void 0:b[u])||((p=e.att[n])==null?void 0:p[u])})})}),i}function gS(r="",e){va(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;const i=[];let n=0;Object.keys(e.att).forEach(u=>{const b=Object.keys(e.att[u]).map(A=>({ability:A.split("/")[0],action:A.split("/")[1]}));b.sort((A,R)=>A.action.localeCompare(R.action));const p={};b.forEach(A=>{p[A.ability]||(p[A.ability]=[]),p[A.ability].push(A.action)});const y=Object.keys(p).map(A=>(n++,`(${n}) '${A}': '${p[A].join("', '")}' for '${u}'.`));i.push(y.join(", ").replace(".,","."))});const a=i.join(" "),f=`${t}${a}`;return`${r?r+" ":""}${f}`}function ug(r){var e;const t=gc(r);va(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function lg(r){const e=gc(r);va(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var a;(a=n==null?void 0:n[0])!=null&&a.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function th(r){if(!r)return;const e=r==null?void 0:r[r.length-1];return lS(e)?e:void 0}const wm="base10",Jr="base16",Ls="base64pad",Yo="base64url",Pc="utf8",_m=0,ls=1,Oc=2,vS=0,dg=1,fc=12,Wd=32;function bS(){const r=Td.generateKeyPair();return{privateKey:Er(r.secretKey,Jr),publicKey:Er(r.publicKey,Jr)}}function ud(){const r=$s.randomBytes(Wd);return Er(r,Jr)}function mS(r,e){const t=Td.sharedKey(Ar(r,Jr),Ar(e,Jr),!0),i=new p_(Ac.SHA256,t).expand(Wd);return Er(i,Jr)}function rh(r){const e=Ac.hash(Ar(r,Jr));return Er(e,Jr)}function cs(r){const e=Ac.hash(Ar(r,Pc));return Er(e,Jr)}function Am(r){return Ar(`${r}`,wm)}function ba(r){return Number(Er(r,wm))}function yS(r){const e=Am(typeof r.type<"u"?r.type:_m);if(ba(e)===ls&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?Ar(r.senderPublicKey,Jr):void 0,i=typeof r.iv<"u"?Ar(r.iv,Jr):$s.randomBytes(fc),n=new Rd.ChaCha20Poly1305(Ar(r.symKey,Jr)).seal(i,Ar(r.message,Pc));return Em({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function wS(r,e){const t=Am(Oc),i=$s.randomBytes(fc),n=Ar(r,Pc);return Em({type:t,sealed:n,iv:i,encoding:e})}function _S(r){const e=new Rd.ChaCha20Poly1305(Ar(r.symKey,Jr)),{sealed:t,iv:i}=vc({encoded:r.encoded,encoding:r==null?void 0:r.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return Er(n,Pc)}function AS(r,e){const{sealed:t}=vc({encoded:r,encoding:e});return Er(t,Pc)}function Em(r){const{encoding:e=Ls}=r;if(ba(r.type)===Oc)return Er(Yf([r.type,r.sealed]),e);if(ba(r.type)===ls){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Er(Yf([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return Er(Yf([r.type,r.iv,r.sealed]),e)}function vc(r){const{encoded:e,encoding:t=Ls}=r,i=Ar(e,t),n=i.slice(vS,dg),a=dg;if(ba(n)===ls){const p=a+Wd,y=p+fc,A=i.slice(a,p),R=i.slice(p,y),O=i.slice(y);return{type:n,sealed:O,iv:R,senderPublicKey:A}}if(ba(n)===Oc){const p=i.slice(a),y=$s.randomBytes(fc);return{type:n,sealed:p,iv:y}}const f=a+fc,u=i.slice(a,f),b=i.slice(f);return{type:n,sealed:b,iv:u}}function ES(r,e){const t=vc({encoded:r,encoding:e==null?void 0:e.encoding});return xm({type:ba(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?Er(t.senderPublicKey,Jr):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function xm(r){const e=(r==null?void 0:r.type)||_m;if(e===ls){if(typeof(r==null?void 0:r.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(r==null?void 0:r.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r==null?void 0:r.senderPublicKey,receiverPublicKey:r==null?void 0:r.receiverPublicKey}}function pg(r){return r.type===ls&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function gg(r){return r.type===Oc}function xS(r){return new Qv.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function SS(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function IS(r){return Buffer.from(SS(r),"base64")}function MS(r,e){const[t,i,n]=r.split("."),a=IS(n);if(a.length!==64)throw new Error("Invalid signature length");const f=a.slice(0,32).toString("hex"),u=a.slice(32,64).toString("hex"),b=`${t}.${i}`,p=new Ac.SHA256().update(Buffer.from(b)).digest(),y=xS(e),A=Buffer.from(p).toString("hex");if(!y.verify(A,{r:f,s:u}))throw new Error("Invalid signature");return nd(r).payload}const PS="irn";function ld(r){return(r==null?void 0:r.relay)||{protocol:PS}}function nc(r){const e=Z9[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var OS=Object.defineProperty,RS=Object.defineProperties,NS=Object.getOwnPropertyDescriptors,vg=Object.getOwnPropertySymbols,TS=Object.prototype.hasOwnProperty,CS=Object.prototype.propertyIsEnumerable,bg=(r,e,t)=>e in r?OS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,mg=(r,e)=>{for(var t in e||(e={}))TS.call(e,t)&&bg(r,t,e[t]);if(vg)for(var t of vg(e))CS.call(e,t)&&bg(r,t,e[t]);return r},DS=(r,e)=>RS(r,NS(e));function LS(r,e="-"){const t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){const a=n.replace(i,""),f=r[n];t[a]=f}}),t}function yg(r){if(!r.includes("wc:")){const b=qb(r);b!=null&&b.includes("wc:")&&(r=b)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),a=typeof t<"u"?r.substring(t):"",f=dc.parse(a),u=typeof f.methods=="string"?f.methods.split(","):void 0;return{protocol:i,topic:qS(n[0]),version:parseInt(n[1],10),symKey:f.symKey,relay:LS(f),methods:u,expiryTimestamp:f.expiryTimestamp?parseInt(f.expiryTimestamp,10):void 0}}function qS(r){return r.startsWith("//")?r.substring(2):r}function BS(r,e="-"){const t="relay",i={};return Object.keys(r).forEach(n=>{const a=t+e+n;r[n]&&(i[a]=r[n])}),i}function wg(r){return`${r.protocol}:${r.topic}@${r.version}?`+dc.stringify(mg(DS(mg({symKey:r.symKey},BS(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Ff(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function _o(r){const e=[];return r.forEach(t=>{const[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function US(r){const e=[];return Object.values(r).forEach(t=>{e.push(..._o(t.accounts))}),e}function $S(r,e){const t=[];return Object.values(r).forEach(i=>{_o(i.accounts).includes(e)&&t.push(...i.methods)}),t}function zS(r,e){const t=[];return Object.values(r).forEach(i=>{_o(i.accounts).includes(e)&&t.push(...i.events)}),t}function Jd(r){return r.includes(":")}function sc(r){return Jd(r)?r.split(":")[0]:r}function jS(r){const e={};return r==null||r.forEach(t=>{const[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function _g(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=jS(e);for(const[i,n]of Object.entries(t))n.methods?n.methods=Qf(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}const kS={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},FS={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Ae(r,e){const{message:t,code:i}=FS[r];return{message:e?`${t} ${e}`:t,code:i}}function $t(r,e){const{message:t,code:i}=kS[r];return{message:e?`${t} ${e}`:t,code:i}}function jn(r,e){return!!Array.isArray(r)}function bc(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function fi(r){return typeof r>"u"}function fr(r,e){return e&&fi(r)?!0:typeof r=="string"&&!!r.trim().length}function Yd(r,e){return typeof r=="number"&&!isNaN(r)}function HS(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t);let a=!0;return ca(n,i)?(i.forEach(f=>{const{accounts:u,methods:b,events:p}=r.namespaces[f],y=_o(u),A=t[f];(!ca(Ob(f,A),y)||!ca(A.methods,b)||!ca(A.events,p))&&(a=!1)}),a):!1}function yh(r){return fr(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function KS(r){if(fr(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&yh(t)}}return!1}function VS(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(fr(r,!1)){if(e(r))return!0;const t=qb(r);return e(t)}}catch{}return!1}function GS(r){var e;return(e=r==null?void 0:r.proposer)==null?void 0:e.publicKey}function WS(r){return r==null?void 0:r.topic}function JS(r,e){let t=null;return fr(r==null?void 0:r.publicKey,!1)||(t=Ae("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function Ag(r){let e=!0;return jn(r)?r.length&&(e=r.every(t=>fr(t,!1))):e=!1,e}function YS(r,e,t){let i=null;return jn(e)&&e.length?e.forEach(n=>{i||yh(n)||(i=$t("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):yh(r)||(i=$t("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function QS(r,e,t){let i=null;return Object.entries(r).forEach(([n,a])=>{if(i)return;const f=YS(n,Ob(n,a),`${e} ${t}`);f&&(i=f)}),i}function XS(r,e){let t=null;return jn(r)?r.forEach(i=>{t||KS(i)||(t=$t("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=$t("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function ZS(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=XS(i==null?void 0:i.accounts,`${e} namespace`);n&&(t=n)}),t}function eI(r,e){let t=null;return Ag(r==null?void 0:r.methods)?Ag(r==null?void 0:r.events)||(t=$t("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=$t("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Sm(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=eI(i,`${e}, namespace`);n&&(t=n)}),t}function tI(r,e,t){let i=null;if(r&&bc(r)){const n=Sm(r,e);n&&(i=n);const a=QS(r,e,t);a&&(i=a)}else i=Ae("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Tl(r,e){let t=null;if(r&&bc(r)){const i=Sm(r,e);i&&(t=i);const n=ZS(r,e);n&&(t=n)}else t=Ae("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Im(r){return fr(r.protocol,!0)}function rI(r,e){let t=!1;return r?r&&jn(r)&&r.length&&r.forEach(i=>{t=Im(i)}):t=!0,t}function iI(r){return typeof r=="number"}function oi(r){return typeof r<"u"&&typeof r!==null}function nI(r){return!(!r||typeof r!="object"||!r.code||!Yd(r.code)||!r.message||!fr(r.message,!1))}function sI(r){return!(fi(r)||!fr(r.method,!1))}function aI(r){return!(fi(r)||fi(r.result)&&fi(r.error)||!Yd(r.id)||!fr(r.jsonrpc,!1))}function oI(r){return!(fi(r)||!fr(r.name,!1))}function Eg(r,e){return!(!yh(e)||!US(r).includes(e))}function cI(r,e,t){return fr(t,!1)?$S(r,e).includes(t):!1}function fI(r,e,t){return fr(t,!1)?zS(r,e).includes(t):!1}function xg(r,e,t){let i=null;const n=hI(r),a=uI(e),f=Object.keys(n),u=Object.keys(a),b=Sg(Object.keys(r)),p=Sg(Object.keys(e)),y=b.filter(A=>!p.includes(A));return y.length&&(i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. + Required: ${y.toString()} + Received: ${Object.keys(e).toString()}`)),ca(f,u)||(i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. + Required: ${f.toString()} + Approved: ${u.toString()}`)),Object.keys(e).forEach(A=>{if(!A.includes(":")||i)return;const R=_o(e[A].accounts);R.includes(A)||(i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${A} + Required: ${A} + Approved: ${R.toString()}`))}),f.forEach(A=>{i||(ca(n[A].methods,a[A].methods)?ca(n[A].events,a[A].events)||(i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${A}`)):i=Ae("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${A}`))}),i}function hI(r){const e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function Sg(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function uI(r){const e={};return Object.keys(r).forEach(t=>{if(t.includes(":"))e[t]=r[t];else{const i=_o(r[t].accounts);i==null||i.forEach(n=>{e[n]={accounts:r[t].accounts.filter(a=>a.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}}),e}function lI(r,e){return Yd(r)&&r<=e.max&&r>=e.min}function Ig(){const r=Ic();return new Promise(e=>{switch(r){case wi.browser:e(dI());break;case wi.reactNative:e(pI());break;case wi.node:e(gI());break;default:e(!0)}})}function dI(){return Sc()&&(navigator==null?void 0:navigator.onLine)}async function pI(){if(vo()&&typeof globalThis<"u"&&globalThis!=null&&globalThis.NetInfo){const r=await(globalThis==null?void 0:globalThis.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function gI(){return!0}function vI(r){switch(Ic()){case wi.browser:bI(r);break;case wi.reactNative:mI(r);break}}function bI(r){!vo()&&Sc()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function mI(r){vo()&&typeof globalThis<"u"&&globalThis!=null&&globalThis.NetInfo&&(globalThis==null||globalThis.NetInfo.addEventListener(e=>r(e==null?void 0:e.isConnected)))}const Cl={};class Qo{static get(e){return Cl[e]}static set(e,t){Cl[e]=t}static delete(e){delete Cl[e]}}class Aa{}let yI=class extends Aa{constructor(e){super()}};const Mg=xe.FIVE_SECONDS,Ao={pulse:"heartbeat_pulse"};let wI=class Mm extends yI{constructor(e){super(e),this.events=new Fi.EventEmitter,this.interval=Mg,this.interval=(e==null?void 0:e.interval)||Mg}static async init(e){const t=new Mm(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),xe.toMiliseconds(this.interval))}pulse(){this.events.emit(Ao.pulse)}};const _I=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,AI=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,EI=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function xI(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){SI(r);return}return e}function SI(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Hf(r,e={}){if(typeof r!="string")return r;const t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){const i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!EI.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(_I.test(r)||AI.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,xI)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function II(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function _r(r,...e){try{return II(r(...e))}catch(t){return Promise.reject(t)}}function MI(r){const e=typeof r;return r===null||e!=="object"&&e!=="function"}function PI(r){const e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function ih(r){if(MI(r))return String(r);if(PI(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return ih(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Pm(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const dd="base64:";function OI(r){if(typeof r=="string")return r;Pm();const e=Buffer.from(r).toString("base64");return dd+e}function RI(r){return typeof r!="string"||!r.startsWith(dd)?r:(Pm(),Buffer.from(r.slice(dd.length),"base64"))}function ai(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function NI(...r){return ai(r.join(":"))}function Kf(r){return r=ai(r),r?r+":":""}const TI="memory",CI=()=>{const r=new Map;return{name:TI,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function DI(r={}){const e={mounts:{"":r.driver||CI()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=p=>{for(const y of e.mountpoints)if(p.startsWith(y))return{base:y,relativeKey:p.slice(y.length),driver:e.mounts[y]};return{base:"",relativeKey:p,driver:e.mounts[""]}},i=(p,y)=>e.mountpoints.filter(A=>A.startsWith(p)||y&&p.startsWith(A)).map(A=>({relativeBase:p.length>A.length?p.slice(A.length):void 0,mountpoint:A,driver:e.mounts[A]})),n=(p,y)=>{if(e.watching){y=ai(y);for(const A of e.watchListeners)A(p,y)}},a=async()=>{if(!e.watching){e.watching=!0;for(const p in e.mounts)e.unwatch[p]=await Pg(e.mounts[p],n,p)}},f=async()=>{if(e.watching){for(const p in e.unwatch)await e.unwatch[p]();e.unwatch={},e.watching=!1}},u=(p,y,A)=>{const R=new Map,O=N=>{let K=R.get(N.base);return K||(K={driver:N.driver,base:N.base,items:[]},R.set(N.base,K)),K};for(const N of p){const K=typeof N=="string",W=ai(K?N:N.key),Q=K?void 0:N.value,k=K||!N.options?y:{...y,...N.options},Y=t(W);O(Y).items.push({key:W,value:Q,relativeKey:Y.relativeKey,options:k})}return Promise.all([...R.values()].map(N=>A(N))).then(N=>N.flat())},b={hasItem(p,y={}){p=ai(p);const{relativeKey:A,driver:R}=t(p);return _r(R.hasItem,A,y)},getItem(p,y={}){p=ai(p);const{relativeKey:A,driver:R}=t(p);return _r(R.getItem,A,y).then(O=>Hf(O))},getItems(p,y){return u(p,y,A=>A.driver.getItems?_r(A.driver.getItems,A.items.map(R=>({key:R.relativeKey,options:R.options})),y).then(R=>R.map(O=>({key:NI(A.base,O.key),value:Hf(O.value)}))):Promise.all(A.items.map(R=>_r(A.driver.getItem,R.relativeKey,R.options).then(O=>({key:R.key,value:Hf(O)})))))},getItemRaw(p,y={}){p=ai(p);const{relativeKey:A,driver:R}=t(p);return R.getItemRaw?_r(R.getItemRaw,A,y):_r(R.getItem,A,y).then(O=>RI(O))},async setItem(p,y,A={}){if(y===void 0)return b.removeItem(p);p=ai(p);const{relativeKey:R,driver:O}=t(p);O.setItem&&(await _r(O.setItem,R,ih(y),A),O.watch||n("update",p))},async setItems(p,y){await u(p,y,async A=>{if(A.driver.setItems)return _r(A.driver.setItems,A.items.map(R=>({key:R.relativeKey,value:ih(R.value),options:R.options})),y);A.driver.setItem&&await Promise.all(A.items.map(R=>_r(A.driver.setItem,R.relativeKey,ih(R.value),R.options)))})},async setItemRaw(p,y,A={}){if(y===void 0)return b.removeItem(p,A);p=ai(p);const{relativeKey:R,driver:O}=t(p);if(O.setItemRaw)await _r(O.setItemRaw,R,y,A);else if(O.setItem)await _r(O.setItem,R,OI(y),A);else return;O.watch||n("update",p)},async removeItem(p,y={}){typeof y=="boolean"&&(y={removeMeta:y}),p=ai(p);const{relativeKey:A,driver:R}=t(p);R.removeItem&&(await _r(R.removeItem,A,y),(y.removeMeta||y.removeMata)&&await _r(R.removeItem,A+"$",y),R.watch||n("remove",p))},async getMeta(p,y={}){typeof y=="boolean"&&(y={nativeOnly:y}),p=ai(p);const{relativeKey:A,driver:R}=t(p),O=Object.create(null);if(R.getMeta&&Object.assign(O,await _r(R.getMeta,A,y)),!y.nativeOnly){const N=await _r(R.getItem,A+"$",y).then(K=>Hf(K));N&&typeof N=="object"&&(typeof N.atime=="string"&&(N.atime=new Date(N.atime)),typeof N.mtime=="string"&&(N.mtime=new Date(N.mtime)),Object.assign(O,N))}return O},setMeta(p,y,A={}){return this.setItem(p+"$",y,A)},removeMeta(p,y={}){return this.removeItem(p+"$",y)},async getKeys(p,y={}){p=Kf(p);const A=i(p,!0);let R=[];const O=[];for(const N of A){const K=await _r(N.driver.getKeys,N.relativeBase,y);for(const W of K){const Q=N.mountpoint+ai(W);R.some(k=>Q.startsWith(k))||O.push(Q)}R=[N.mountpoint,...R.filter(W=>!W.startsWith(N.mountpoint))]}return p?O.filter(N=>N.startsWith(p)&&N[N.length-1]!=="$"):O.filter(N=>N[N.length-1]!=="$")},async clear(p,y={}){p=Kf(p),await Promise.all(i(p,!1).map(async A=>{if(A.driver.clear)return _r(A.driver.clear,A.relativeBase,y);if(A.driver.removeItem){const R=await A.driver.getKeys(A.relativeBase||"",y);return Promise.all(R.map(O=>A.driver.removeItem(O,y)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(p=>Og(p)))},async watch(p){return await a(),e.watchListeners.push(p),async()=>{e.watchListeners=e.watchListeners.filter(y=>y!==p),e.watchListeners.length===0&&await f()}},async unwatch(){e.watchListeners=[],await f()},mount(p,y){if(p=Kf(p),p&&e.mounts[p])throw new Error(`already mounted at ${p}`);return p&&(e.mountpoints.push(p),e.mountpoints.sort((A,R)=>R.length-A.length)),e.mounts[p]=y,e.watching&&Promise.resolve(Pg(y,n,p)).then(A=>{e.unwatch[p]=A}).catch(console.error),b},async unmount(p,y=!0){p=Kf(p),!(!p||!e.mounts[p])&&(e.watching&&p in e.unwatch&&(e.unwatch[p](),delete e.unwatch[p]),y&&await Og(e.mounts[p]),e.mountpoints=e.mountpoints.filter(A=>A!==p),delete e.mounts[p])},getMount(p=""){p=ai(p)+":";const y=t(p);return{driver:y.driver,base:y.base}},getMounts(p="",y={}){return p=ai(p),i(p,y.parents).map(R=>({driver:R.driver,base:R.mountpoint}))},keys:(p,y={})=>b.getKeys(p,y),get:(p,y={})=>b.getItem(p,y),set:(p,y,A={})=>b.setItem(p,y,A),has:(p,y={})=>b.hasItem(p,y),del:(p,y={})=>b.removeItem(p,y),remove:(p,y={})=>b.removeItem(p,y)};return b}function Pg(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function Og(r){typeof r.dispose=="function"&&await _r(r.dispose)}function Ea(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function Om(r,e){const t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);const i=Ea(t);return(n,a)=>i.then(f=>a(f.transaction(e,n).objectStore(e)))}let Dl;function Rc(){return Dl||(Dl=Om("keyval-store","keyval")),Dl}function Rg(r,e=Rc()){return e("readonly",t=>Ea(t.get(r)))}function LI(r,e,t=Rc()){return t("readwrite",i=>(i.put(e,r),Ea(i.transaction)))}function qI(r,e=Rc()){return e("readwrite",t=>(t.delete(r),Ea(t.transaction)))}function BI(r=Rc()){return r("readwrite",e=>(e.clear(),Ea(e.transaction)))}function UI(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Ea(r.transaction)}function $I(r=Rc()){return r("readonly",e=>{if(e.getAllKeys)return Ea(e.getAllKeys());const t=[];return UI(e,i=>t.push(i.key)).then(()=>t)})}const zI="idb-keyval";var jI=(r={})=>{const e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n;let i;return r.dbName&&r.storeName&&(i=Om(r.dbName,r.storeName)),{name:zI,options:r,async hasItem(n){return!(typeof await Rg(t(n),i)>"u")},async getItem(n){return await Rg(t(n),i)??null},setItem(n,a){return LI(t(n),a,i)},removeItem(n){return qI(t(n),i)},getKeys(){return $I(i)},clear(){return BI(i)}}};const kI="WALLET_CONNECT_V2_INDEXED_DB",FI="keyvaluestorage";let HI=class{constructor(){this.indexedDb=DI({driver:jI({dbName:kI,storeName:FI})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,gs(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Ll=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},nh={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ll<"u"&&Ll.localStorage?nh.exports=Ll.localStorage:typeof window<"u"&&window.localStorage?nh.exports=window.localStorage:nh.exports=new e})();function KI(r){var e;return[r[0],ga((e=r[1])!=null?e:"")]}class VI{constructor(){this.localStorage=nh.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(KI)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return ga(t)}async setItem(e,t){this.localStorage.setItem(e,gs(t))}async removeItem(e){this.localStorage.removeItem(e)}}const GI="wc_storage_version",Ng=1,WI=async(r,e,t)=>{const i=GI,n=await e.getItem(i);if(n&&n>=Ng){t(e);return}const a=await r.getKeys();if(!a.length){t(e);return}const f=[];for(;a.length;){const u=a.shift();if(!u)continue;const b=u.toLowerCase();if(b.includes("wc@")||b.includes("walletconnect")||b.includes("wc_")||b.includes("wallet_connect")){const p=await r.getItem(u);await e.setItem(u,p),f.push(u)}}await e.setItem(i,Ng),t(e),JI(r,f)},JI=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})};let YI=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new VI;this.storage=e;try{const t=new HI;WI(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};function QI(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}var XI=ZI;function ZI(r,e,t){var i=t&&t.stringify||QI,n=1;if(typeof r=="object"&&r!==null){var a=e.length+n;if(a===1)return r;var f=new Array(a);f[0]=i(r);for(var u=1;u-1?A:0,r.charCodeAt(O+1)){case 100:case 102:if(y>=b||e[y]==null)break;A=b||e[y]==null)break;A=b||e[y]===void 0)break;A",A=O+2,O++;break}p+=i(e[y]),A=O+2,O++;break;case 115:if(y>=b)break;A-1&&(a=!1);const f=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");const u=r.level||"info",b=Object.create(t);b.log||(b.log=yc),Object.defineProperty(b,"levelVal",{get:y}),Object.defineProperty(b,"level",{get:A,set:R});const p={transmit:e,serialize:n,asObject:r.browser.asObject,levels:f,timestamp:aM(r)};b.levels=Bn.levels,b.level=u,b.setMaxListeners=b.getMaxListeners=b.emit=b.addListener=b.on=b.prependListener=b.once=b.prependOnceListener=b.removeListener=b.removeAllListeners=b.listeners=b.listenerCount=b.eventNames=b.write=b.flush=yc,b.serializers=i,b._serialize=n,b._stdErrSerialize=a,b.child=O,e&&(b._logEvent=pd());function y(){return this.level==="silent"?1/0:this.levels.values[this.level]}function A(){return this._level}function R(N){if(N!=="silent"&&!this.levels.values[N])throw Error("unknown level "+N);this._level=N,Ka(p,b,"error","log"),Ka(p,b,"fatal","error"),Ka(p,b,"warn","error"),Ka(p,b,"info","log"),Ka(p,b,"debug","log"),Ka(p,b,"trace","log")}function O(N,K){if(!N)throw new Error("missing bindings for child Pino");K=K||{},n&&N.serializers&&(K.serializers=N.serializers);const W=K.serializers;if(n&&W){var Q=Object.assign({},i,W),k=r.browser.serialize===!0?Object.keys(Q):n;delete N.serializers,Fh([N],k,Q,this._stdErrSerialize)}function Y($){this._childLevel=($._childLevel|0)+1,this.error=Va($,N,"error"),this.fatal=Va($,N,"fatal"),this.warn=Va($,N,"warn"),this.info=Va($,N,"info"),this.debug=Va($,N,"debug"),this.trace=Va($,N,"trace"),Q&&(this.serializers=Q,this._serialize=k),e&&(this._logEvent=pd([].concat($._logEvent.bindings,N)))}return Y.prototype=this,new Y(this)}return b}Bn.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};Bn.stdSerializers=eM;Bn.stdTimeFunctions=Object.assign({},{nullTime:Rm,epochTime:Nm,unixTime:oM,isoTime:cM});function Ka(r,e,t,i){const n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?yc:n[t]?n[t]:mc[t]||mc[i]||yc,rM(r,e,t)}function rM(r,e,t){!r.transmit&&e[t]===yc||(e[t]=function(i){return function(){const a=r.timestamp(),f=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===mc?mc:this;for(var b=0;b-1&&a in t&&(r[n][a]=t[a](r[n][a]))}function Va(r,e,t){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;nthis.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const t=e.value;return e=e.next,{done:!1,value:t}}}}},Tm=class{constructor(e,t=Qd){this.level=e??"error",this.levelValue=Ja.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new Cg(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===Ja.levels.values.error?console.error(e):t===Ja.levels.values.warn?console.warn(e):t===Ja.levels.values.debug?console.debug(e):t===Ja.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(gs({timestamp:new Date().toISOString(),log:e}));const t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new Cg(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push(gs({extraMetadata:e})),new Blob(t,{type:"application/json"})}},lM=class{constructor(e,t=Qd){this.baseChunkLogger=new Tm(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}};class dM{constructor(e,t=Qd){this.baseChunkLogger=new Tm(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var pM=Object.defineProperty,gM=Object.defineProperties,vM=Object.getOwnPropertyDescriptors,Dg=Object.getOwnPropertySymbols,bM=Object.prototype.hasOwnProperty,mM=Object.prototype.propertyIsEnumerable,Lg=(r,e,t)=>e in r?pM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,wh=(r,e)=>{for(var t in e||(e={}))bM.call(e,t)&&Lg(r,t,e[t]);if(Dg)for(var t of Dg(e))mM.call(e,t)&&Lg(r,t,e[t]);return r},_h=(r,e)=>gM(r,vM(e));function Hh(r){return _h(wh({},r),{level:(r==null?void 0:r.level)||hM.level})}function yM(r,e=Tc){return r[e]||""}function wM(r,e,t=Tc){return r[t]=e,r}function di(r,e=Tc){let t="";return typeof r.bindings>"u"?t=yM(r,e):t=r.bindings().context||"",t}function _M(r,e,t=Tc){const i=di(r,t);return i.trim()?`${i}/${e}`:e}function Yr(r,e,t=Tc){const i=_M(r,e,t),n=r.child({context:i});return wM(n,i,t)}function AM(r){var e,t;const i=new lM((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Nc(_h(wh({},r.opts),{level:"trace",browser:_h(wh({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function EM(r){var e;const t=new dM((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Nc(_h(wh({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function xM(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?AM(r):EM(r)}let SM=class extends Aa{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},IM=class extends Aa{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},MM=class{constructor(e,t){this.logger=e,this.core=t}},PM=class extends Aa{constructor(e,t){super(),this.relayer=e,this.logger=t}},OM=class extends Aa{constructor(e){super()}},RM=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}},NM=class extends Aa{constructor(e,t){super(),this.relayer=e,this.logger=t}},TM=class extends Aa{constructor(e,t){super(),this.core=e,this.logger=t}},CM=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},DM=class{constructor(e,t){this.projectId=e,this.logger=t}},LM=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}},qM=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},BM=class{constructor(e){this.client=e}};const UM="PARSE_ERROR",$M="INVALID_REQUEST",zM="METHOD_NOT_FOUND",jM="INVALID_PARAMS",Cm="INTERNAL_ERROR",Xd="SERVER_ERROR",kM=[-32700,-32600,-32601,-32602,-32603],hc={[UM]:{code:-32700,message:"Parse error"},[$M]:{code:-32600,message:"Invalid Request"},[zM]:{code:-32601,message:"Method not found"},[jM]:{code:-32602,message:"Invalid params"},[Cm]:{code:-32603,message:"Internal error"},[Xd]:{code:-32e3,message:"Server error"}},Dm=Xd;function FM(r){return kM.includes(r)}function qg(r){return Object.keys(hc).includes(r)?hc[r]:hc[Dm]}function HM(r){const e=Object.values(hc).find(t=>t.code===r);return e||hc[Dm]}function Lm(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var qm={};/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var gd=function(r,e){return gd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},gd(r,e)};function KM(r,e){gd(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var vd=function(){return vd=Object.assign||function(e){for(var t,i=1,n=arguments.length;i=0;u--)(f=r[u])&&(a=(n<3?f(a):n>3?f(e,t,a):f(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a}function WM(r,e){return function(t,i){e(t,i,r)}}function JM(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function YM(r,e,t,i){function n(a){return a instanceof t?a:new t(function(f){f(a)})}return new(t||(t=Promise))(function(a,f){function u(y){try{p(i.next(y))}catch(A){f(A)}}function b(y){try{p(i.throw(y))}catch(A){f(A)}}function p(y){y.done?a(y.value):n(y.value).then(u,b)}p((i=i.apply(r,e||[])).next())})}function QM(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,f;return f={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function u(p){return function(y){return b([p,y])}}function b(p){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(a=p[0]&2?n.return:p[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,p[1])).done)return a;switch(n=0,a&&(p=[p[0]&2,a.value]),p[0]){case 0:case 1:a=p;break;case 4:return t.label++,{value:p[1],done:!1};case 5:t.label++,n=p[1],p=[0];continue;case 7:p=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(p[0]===6||p[0]===2)){t=0;continue}if(p[0]===3&&(!a||p[1]>a[0]&&p[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Bm(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,a=[],f;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(u){f={error:u}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(f)throw f.error}}return a}function eP(){for(var r=[],e=0;e1||u(R,O)})})}function u(R,O){try{b(i[R](O))}catch(N){A(a[0][3],N)}}function b(R){R.value instanceof wc?Promise.resolve(R.value.v).then(p,y):A(a[0][2],R)}function p(R){u("next",R)}function y(R){u("throw",R)}function A(R,O){R(O),a.shift(),a.length&&u(a[0][0],a[0][1])}}function iP(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,a){e[n]=r[n]?function(f){return(t=!t)?{value:wc(r[n](f)),done:n==="return"}:a?a(f):f}:a}}function nP(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof bd=="function"?bd(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(a){t[a]=r[a]&&function(f){return new Promise(function(u,b){f=r[a](f),n(u,b,f.done,f.value)})}}function n(a,f,u,b){Promise.resolve(b).then(function(p){a({value:p,done:u})},f)}}function sP(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function aP(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function oP(r){return r&&r.__esModule?r:{default:r}}function cP(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function fP(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}const hP=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return vd},__asyncDelegator:iP,__asyncGenerator:rP,__asyncValues:nP,__await:wc,__awaiter:YM,__classPrivateFieldGet:cP,__classPrivateFieldSet:fP,__createBinding:XM,__decorate:GM,__exportStar:ZM,__extends:KM,__generator:QM,__importDefault:oP,__importStar:aP,__makeTemplateObject:sP,__metadata:JM,__param:WM,__read:Bm,__rest:VM,__spread:eP,__spreadArrays:tP,__values:bd},Symbol.toStringTag,{value:"Module"})),uP=Cv(hP);var ns={},Bg;function lP(){if(Bg)return ns;Bg=1,Object.defineProperty(ns,"__esModule",{value:!0}),ns.isBrowserCryptoAvailable=ns.getSubtleCrypto=ns.getBrowerCrypto=void 0;function r(){return(globalThis==null?void 0:globalThis.crypto)||(globalThis==null?void 0:globalThis.msCrypto)||{}}ns.getBrowerCrypto=r;function e(){const i=r();return i.subtle||i.webkitSubtle}ns.getSubtleCrypto=e;function t(){return!!r()&&!!e()}return ns.isBrowserCryptoAvailable=t,ns}var ss={},Ug;function dP(){if(Ug)return ss;Ug=1;var r={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0};Object.defineProperty(ss,"__esModule",{value:!0}),ss.isBrowser=ss.isNode=ss.isReactNative=void 0;function e(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}ss.isReactNative=e;function t(){return typeof r<"u"&&typeof r.versions<"u"&&typeof r.versions.node<"u"}ss.isNode=t;function i(){return!e()&&!t()}return ss.isBrowser=i,ss}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=uP;e.__exportStar(lP(),r),e.__exportStar(dP(),r)})(qm);function Ns(r=3){const e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function fa(r=6){return BigInt(Ns(r))}function qs(r,e,t){return{id:t||Ns(),jsonrpc:"2.0",method:r,params:e}}function Kh(r,e){return{id:r,jsonrpc:"2.0",result:e}}function Vh(r,e,t){return{id:r,jsonrpc:"2.0",error:pP(e)}}function pP(r,e){return typeof r>"u"?qg(Cm):(typeof r=="string"&&(r=Object.assign(Object.assign({},qg(Xd)),{message:r})),FM(r.code)&&(r=HM(r.code)),r)}class gP{}class vP extends gP{constructor(){super()}}class bP extends vP{constructor(e){super()}}const mP="^https?:",yP="^wss?:";function wP(r){const e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Um(r,e){const t=wP(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function $g(r){return Um(r,mP)}function zg(r){return Um(r,yP)}function _P(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function $m(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function Zd(r){return $m(r)&&"method"in r}function Gh(r){return $m(r)&&(In(r)||zi(r))}function In(r){return"result"in r}function zi(r){return"error"in r}let pn=class extends bP{constructor(e){super(e),this.events=new Fi.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(qs(e.method,e.params||[],e.id||fa().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(a){n(a)}this.events.on(`${e.id}`,a=>{zi(a)?n(a.error):i(a.result)});try{await this.connection.send(e,t)}catch(a){n(a)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Gh(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};const AP=()=>typeof WebSocket<"u"?WebSocket:typeof globalThis<"u"&&typeof globalThis.WebSocket<"u"?globalThis.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),EP=()=>typeof WebSocket<"u"||typeof globalThis<"u"&&typeof globalThis.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",jg=r=>r.split("?")[0],kg=10,xP=AP();let SP=class{constructor(e){if(this.url=e,this.events=new Fi.EventEmitter,this.registering=!1,!zg(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(gs(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!zg(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),n(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{const n=new URLSearchParams(e).get("origin"),a=qm.isReactNative()?{headers:{origin:n}}:{rejectUnauthorized:!_P(e)},f=new xP(e,[],a);EP()?f.onerror=u=>{const b=u;i(this.emitError(b.error))}:f.on("error",u=>{i(this.emitError(u))}),f.onopen=()=>{this.onOpen(f),t(f)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?ga(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),a=Vh(e,n);this.events.emit("payload",a)}parseError(e,t=this.url){return Lm(e,jg(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>kg&&this.events.setMaxListeners(kg)}emitError(e){const t=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${jg(this.url)}`));return this.events.emit("register_error",t),t}};var Ah={exports:{}};Ah.exports;(function(r,e){var t=200,i="__lodash_hash_undefined__",n=1,a=2,f=9007199254740991,u="[object Arguments]",b="[object Array]",p="[object AsyncFunction]",y="[object Boolean]",A="[object Date]",R="[object Error]",O="[object Function]",N="[object GeneratorFunction]",K="[object Map]",W="[object Number]",Q="[object Null]",k="[object Object]",Y="[object Promise]",$="[object Proxy]",F="[object RegExp]",G="[object Set]",x="[object String]",q="[object Symbol]",ae="[object Undefined]",le="[object WeakMap]",L="[object ArrayBuffer]",m="[object DataView]",c="[object Float32Array]",h="[object Float64Array]",v="[object Int8Array]",_="[object Int16Array]",I="[object Int32Array]",M="[object Uint8Array]",S="[object Uint8ClampedArray]",d="[object Uint16Array]",g="[object Uint32Array]",C=/[\\^$.*+?()[\]{}|]/g,Z=/^\[object .+?Constructor\]$/,se=/^(?:0|[1-9]\d*)$/,P={};P[c]=P[h]=P[v]=P[_]=P[I]=P[M]=P[S]=P[d]=P[g]=!0,P[u]=P[b]=P[L]=P[y]=P[m]=P[A]=P[R]=P[O]=P[K]=P[W]=P[k]=P[F]=P[G]=P[x]=P[le]=!1;var ee=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,B=typeof self=="object"&&self&&self.Object===Object&&self,j=ee||B||Function("return this")(),H=e&&!e.nodeType&&e,w=H&&!0&&r&&!r.nodeType&&r,z=w&&w.exports===H,ne=z&&ee.process,ce=function(){try{return ne&&ne.binding&&ne.binding("util")}catch{}}(),he=ce&&ce.isTypedArray;function ye(V,te){for(var pe=-1,$e=V==null?0:V.length,kt=0,pt=[];++pe<$e;){var Jt=V[pe];te(Jt,pe,V)&&(pt[kt++]=Jt)}return pt}function we(V,te){for(var pe=-1,$e=te.length,kt=V.length;++pe<$e;)V[kt+pe]=te[pe];return V}function Te(V,te){for(var pe=-1,$e=V==null?0:V.length;++pe<$e;)if(te(V[pe],pe,V))return!0;return!1}function Qe(V,te){for(var pe=-1,$e=Array(V);++pe-1}function qr(V,te){var pe=this.__data__,$e=ks(pe,V);return $e<0?(++this.size,pe.push([V,te])):pe[$e][1]=te,this}bt.prototype.clear=Tr,bt.prototype.delete=Cr,bt.prototype.get=Dr,bt.prototype.has=Lr,bt.prototype.set=qr;function er(V){var te=-1,pe=V==null?0:V.length;for(this.clear();++tehr))return!1;var Ft=pt.get(V);if(Ft&&pt.get(te))return Ft==te;var sr=-1,ei=!0,ur=pe&a?new Zr:void 0;for(pt.set(V,te),pt.set(te,V);++sr-1&&V%1==0&&V-1&&V%1==0&&V<=f}function Jc(V){var te=typeof V;return V!=null&&(te=="object"||te=="function")}function Ks(V){return V!=null&&typeof V=="object"}var Yc=he?Oe(he):Bc;function tu(V){return Zh(V)?Lc(V):Uc(V)}function jt(){return[]}function zt(){return!1}r.exports=eu})(Ah,Ah.exports);var IP=Ah.exports;const MP=Sd(IP),zm="wc",jm=2,e0="core",kn=`${zm}@2:${e0}:`,PP={name:e0,logger:"error"},OP={database:":memory:"},RP="crypto",Fg="client_ed25519_seed",NP=xe.ONE_DAY,TP="keychain",CP="0.3",DP="messages",LP="0.3",qP=xe.SIX_HOURS,BP="publisher",km="irn",UP="error",Fm="wss://relay.walletconnect.org",$P="relayer",Gr={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},zP="_subscription",Bi={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},jP=.1,md="2.17.0",Kt={link_mode:"link_mode",relay:"relay"},kP="0.3",FP="WALLETCONNECT_CLIENT_ID",Hg="WALLETCONNECT_LINK_MODE_APPS",Mn={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},HP="subscription",KP="0.3",VP=xe.FIVE_SECONDS*1e3,GP="pairing",WP="0.3",Xo={wc_pairingDelete:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:xe.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:xe.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:0},res:{ttl:xe.ONE_DAY,prompt:!1,tag:0}}},oa={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},an={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},JP="history",YP="0.3",QP="expirer",Ui={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},XP="0.3",ZP="verify-api",eO="https://verify.walletconnect.com",Hm="https://verify.walletconnect.org",uc=Hm,tO=`${uc}/v3`,rO=[eO,Hm],iO="echo",nO="https://echo.walletconnect.com",En={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},as={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},on={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},na={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},sa={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Zo={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},sO=.1,aO="event-client",oO=86400,cO="https://pulse.walletconnect.org/batch";function fO(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,$=new Uint8Array(Y);Q!==k;){for(var F=N[Q],G=0,x=Y-1;(F!==0||G>>0,$[x]=F%u>>>0,F=F/u>>>0;if(F!==0)throw new Error("Non-zero carry");W=G,Q++}for(var q=Y-W;q!==Y&&$[q]===0;)q++;for(var ae=b.repeat(K);q>>0,Y=new Uint8Array(k);N[K];){var $=t[N.charCodeAt(K)];if($===255)return;for(var F=0,G=k-1;($!==0||F>>0,Y[G]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");Q=F,K++}if(N[K]!==" "){for(var x=k-Q;x!==k&&Y[x]===0;)x++;for(var q=new Uint8Array(W+(k-x)),ae=W;x!==k;)q[ae++]=Y[x++];return q}}}function O(N){var K=R(N);if(K)return K;throw new Error(`Non-${e} character`)}return{encode:A,decodeUnsafe:R,decode:O}}var hO=fO,uO=hO;const Km=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},lO=r=>new TextEncoder().encode(r),dO=r=>new TextDecoder().decode(r);class pO{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class gO{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Vm(this,e)}}class vO{constructor(e){this.decoders=e}or(e){return Vm(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Vm=(r,e)=>new vO({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class bO{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new pO(e,t,i),this.decoder=new gO(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Wh=({name:r,prefix:e,encode:t,decode:i})=>new bO(r,e,t,i),Cc=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=uO(t,e);return Wh({prefix:r,name:e,encode:i,decode:a=>Km(n(a))})},mO=(r,e,t,i)=>{const n={};for(let y=0;y=8&&(u-=8,f[p++]=255&b>>u)}if(u>=t||255&b<<8-u)throw new SyntaxError("Unexpected end of data");return f},yO=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<t;)f-=t,a+=e[n&u>>f];if(f&&(a+=e[n&u<Wh({prefix:e,name:r,encode(n){return yO(n,i,t)},decode(n){return mO(n,i,t,r)}}),wO=Wh({prefix:"\0",name:"identity",encode:r=>dO(r),decode:r=>lO(r)});var _O=Object.freeze({__proto__:null,identity:wO});const AO=Nr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var EO=Object.freeze({__proto__:null,base2:AO});const xO=Nr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var SO=Object.freeze({__proto__:null,base8:xO});const IO=Cc({prefix:"9",name:"base10",alphabet:"0123456789"});var MO=Object.freeze({__proto__:null,base10:IO});const PO=Nr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),OO=Nr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var RO=Object.freeze({__proto__:null,base16:PO,base16upper:OO});const NO=Nr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),TO=Nr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),CO=Nr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),DO=Nr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),LO=Nr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qO=Nr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),BO=Nr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),UO=Nr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),$O=Nr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var zO=Object.freeze({__proto__:null,base32:NO,base32upper:TO,base32pad:CO,base32padupper:DO,base32hex:LO,base32hexupper:qO,base32hexpad:BO,base32hexpadupper:UO,base32z:$O});const jO=Cc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),kO=Cc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var FO=Object.freeze({__proto__:null,base36:jO,base36upper:kO});const HO=Cc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),KO=Cc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var VO=Object.freeze({__proto__:null,base58btc:HO,base58flickr:KO});const GO=Nr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),WO=Nr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),JO=Nr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),YO=Nr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var QO=Object.freeze({__proto__:null,base64:GO,base64pad:WO,base64url:JO,base64urlpad:YO});const Gm=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),XO=Gm.reduce((r,e,t)=>(r[t]=e,r),[]),ZO=Gm.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function eR(r){return r.reduce((e,t)=>(e+=XO[t],e),"")}function tR(r){const e=[];for(const t of r){const i=ZO[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const rR=Wh({prefix:"🚀",name:"base256emoji",encode:eR,decode:tR});var iR=Object.freeze({__proto__:null,base256emoji:rR}),nR=Wm,Kg=128,sR=127,aR=~sR,oR=Math.pow(2,31);function Wm(r,e,t){e=e||[],t=t||0;for(var i=t;r>=oR;)e[t++]=r&255|Kg,r/=128;for(;r&aR;)e[t++]=r&255|Kg,r>>>=7;return e[t]=r|0,Wm.bytes=t-i+1,e}var cR=yd,fR=128,Vg=127;function yd(r,i){var t=0,i=i||0,n=0,a=i,f,u=r.length;do{if(a>=u)throw yd.bytes=0,new RangeError("Could not decode varint");f=r[a++],t+=n<28?(f&Vg)<=fR);return yd.bytes=a-i,t}var hR=Math.pow(2,7),uR=Math.pow(2,14),lR=Math.pow(2,21),dR=Math.pow(2,28),pR=Math.pow(2,35),gR=Math.pow(2,42),vR=Math.pow(2,49),bR=Math.pow(2,56),mR=Math.pow(2,63),yR=function(r){return r(Jm.encode(r,e,t),e),Wg=r=>Jm.encodingLength(r),wd=(r,e)=>{const t=e.byteLength,i=Wg(r),n=i+Wg(t),a=new Uint8Array(n+t);return Gg(r,a,0),Gg(t,a,i),a.set(e,n),new _R(r,t,e,a)};class _R{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const Ym=({name:r,code:e,encode:t})=>new AR(r,e,t);class AR{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?wd(this.code,t):t.then(i=>wd(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Qm=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),ER=Ym({name:"sha2-256",code:18,encode:Qm("SHA-256")}),xR=Ym({name:"sha2-512",code:19,encode:Qm("SHA-512")});var SR=Object.freeze({__proto__:null,sha256:ER,sha512:xR});const Xm=0,IR="identity",Zm=Km,MR=r=>wd(Xm,Zm(r)),PR={code:Xm,name:IR,encode:Zm,digest:MR};var OR=Object.freeze({__proto__:null,identity:PR});new TextEncoder,new TextDecoder;const Jg={..._O,...EO,...SO,...MO,...RO,...zO,...FO,...VO,...QO,...iR};({...SR,...OR});function RR(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function e2(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const Yg=e2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Bl=e2("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);const e=RR(r.length);for(let t=0;t{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:a}=Ae("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(a)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=Yr(t,this.name)}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Tb(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Cb(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class DR{constructor(e,t,i){this.core=e,this.logger=t,this.name=RP,this.randomSessionIdentifier=ud(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),a=T1(n);return Pb(a.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=bS();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const a=await this.getClientSeed(),f=T1(a),u=this.randomSessionIdentifier;return await X9(u,n,NP,f)},this.generateSharedKey=(n,a,f)=>{this.isInitialized();const u=this.getPrivateKey(n),b=mS(u,a);return this.setSymKey(b,f)},this.setSymKey=async(n,a)=>{this.isInitialized();const f=a||rh(n);return await this.keychain.set(f,n),f},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,a,f)=>{this.isInitialized();const u=xm(f),b=gs(a);if(gg(u))return wS(b,f==null?void 0:f.encoding);if(pg(u)){const R=u.senderPublicKey,O=u.receiverPublicKey;n=await this.generateSharedKey(R,O)}const p=this.getSymKey(n),{type:y,senderPublicKey:A}=u;return yS({type:y,symKey:p,message:b,senderPublicKey:A,encoding:f==null?void 0:f.encoding})},this.decode=async(n,a,f)=>{this.isInitialized();const u=ES(a,f);if(gg(u)){const b=AS(a,f==null?void 0:f.encoding);return ga(b)}if(pg(u)){const b=u.receiverPublicKey,p=u.senderPublicKey;n=await this.generateSharedKey(b,p)}try{const b=this.getSymKey(n),p=_S({symKey:b,encoded:a,encoding:f==null?void 0:f.encoding});return ga(p)}catch(b){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(b)}},this.getPayloadType=(n,a=Ls)=>{const f=vc({encoded:n,encoding:a});return ba(f.type)},this.getPayloadSenderPublicKey=(n,a=Ls)=>{const f=vc({encoded:n,encoding:a});return f.senderPublicKey?Er(f.senderPublicKey,Jr):void 0},this.core=e,this.logger=Yr(t,this.name),this.keychain=i||new CR(this.core,this.logger)}get context(){return di(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Fg)}catch{e=ud(),await this.keychain.set(Fg,e)}return TR(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class LR extends MM{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=DP,this.version=LP,this.initialized=!1,this.storagePrefix=kn,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();const a=cs(n);let f=this.messages.get(i);return typeof f>"u"&&(f={}),typeof f[a]<"u"||(f[a]=n,this.messages.set(i,f),await this.persist()),a},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const a=this.get(i),f=cs(n);return typeof a[f]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Yr(e,this.name),this.core=t}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Tb(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Cb(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class qR extends PM{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Fi.EventEmitter,this.name=BP,this.queue=new Map,this.publishTimeout=xe.toMiliseconds(xe.ONE_MINUTE),this.failedPublishTimeout=xe.toMiliseconds(xe.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,a)=>{var f;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:a}});const u=(a==null?void 0:a.ttl)||qP,b=ld(a),p=(a==null?void 0:a.prompt)||!1,y=(a==null?void 0:a.tag)||0,A=(a==null?void 0:a.id)||fa().toString(),R={topic:i,message:n,opts:{ttl:u,relay:b,prompt:p,tag:y,id:A,attestation:a==null?void 0:a.attestation}},O=`Failed to publish payload, please try again. id:${A} tag:${y}`,N=Date.now();let K,W=1;try{for(;K===void 0;){if(Date.now()-N>this.publishTimeout)throw new Error(O);this.logger.trace({id:A,attempts:W},`publisher.publish - attempt ${W}`),K=await await Za(this.rpcPublish(i,n,u,b,p,y,A,a==null?void 0:a.attestation).catch(Q=>this.logger.warn(Q)),this.publishTimeout,O),W++,K||await new Promise(Q=>setTimeout(Q,this.failedPublishTimeout))}this.relayer.events.emit(Gr.publish,R),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:A,topic:i,message:n,opts:a}})}catch(Q){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(Q),(f=a==null?void 0:a.internal)!=null&&f.throwOnFailedPublish)throw Q;this.queue.set(A,R)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=Yr(t,this.name),this.registerEventListeners()}get context(){return di(this.logger)}rpcPublish(e,t,i,n,a,f,u,b){var p,y,A,R;const O={method:nc(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:a,tag:f,attestation:b},id:u};return fi((p=O.params)==null?void 0:p.prompt)&&((y=O.params)==null||delete y.prompt),fi((A=O.params)==null?void 0:A.tag)&&((R=O.params)==null||delete R.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:O}),this.relayer.request(O)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(Ao.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Gr.connection_stalled);return}this.checkQueue()}),this.relayer.on(Gr.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class BR{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const n=i.filter(a=>a!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var UR=Object.defineProperty,$R=Object.defineProperties,zR=Object.getOwnPropertyDescriptors,Qg=Object.getOwnPropertySymbols,jR=Object.prototype.hasOwnProperty,kR=Object.prototype.propertyIsEnumerable,Xg=(r,e,t)=>e in r?UR(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ec=(r,e)=>{for(var t in e||(e={}))jR.call(e,t)&&Xg(r,t,e[t]);if(Qg)for(var t of Qg(e))kR.call(e,t)&&Xg(r,t,e[t]);return r},Ul=(r,e)=>$R(r,zR(e));class FR extends NM{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new BR,this.events=new Fi.EventEmitter,this.name=HP,this.version=KP,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=kn,this.subscribeTimeout=xe.toMiliseconds(xe.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const a=ld(n),f={topic:i,relay:a,transportType:n==null?void 0:n.transportType};this.pending.set(i,f);const u=await this.rpcSubscribe(i,a,n==null?void 0:n.transportType);return typeof u=="string"&&(this.onSubscribe(u,f),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),u}catch(a){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(a),a}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof(n==null?void 0:n.id)<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((a,f)=>{const u=new xe.Watch;u.start(n);const b=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(b),u.stop(n),a(!0)),u.elapsed(n)>=VP&&(clearInterval(b),u.stop(n),f(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=Yr(t,this.name),this.clientId=""}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const n=ld(i);await this.rpcUnsubscribe(e,t,n);const a=$t("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,a),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i=Kt.relay){i===Kt.relay&&await this.restartToComplete();const n={method:nc(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{const a=cs(e+this.clientId);return i===Kt.link_mode?(setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(f=>this.logger.warn(f))},xe.toMiliseconds(xe.ONE_SECOND)),a):await await Za(this.relayer.request(n).catch(f=>this.logger.warn(f)),this.subscribeTimeout)?a:null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Gr.connection_stalled)}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:nc(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Za(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Gr.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:nc(t.protocol).batchFetchMessages,params:{topics:e.map(a=>a.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Za(this.relayer.request(i).catch(a=>this.logger.warn(a)),this.subscribeTimeout)}catch{this.relayer.events.emit(Gr.connection_stalled)}return n}rpcUnsubscribe(e,t,i){const n={method:nc(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Ul(ec({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,ec({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,ec({},t)),this.topicMap.set(t.topic,e),this.events.emit(Mn.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=Ae("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Mn.deleted,Ul(ec({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Mn.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=Ae("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);jn(t)&&this.onBatchSubscribe(t.map((i,n)=>Ul(ec({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(Ao.pulse,async()=>{await this.checkPending()}),this.events.on(Mn.created,async e=>{const t=Mn.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(Mn.deleted,async e=>{const t=Mn.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}}var HR=Object.defineProperty,Zg=Object.getOwnPropertySymbols,KR=Object.prototype.hasOwnProperty,VR=Object.prototype.propertyIsEnumerable,ev=(r,e,t)=>e in r?HR(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,GR=(r,e)=>{for(var t in e||(e={}))KR.call(e,t)&&ev(r,t,e[t]);if(Zg)for(var t of Zg(e))VR.call(e,t)&&ev(r,t,e[t]);return r};class WR extends OM{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Fi.EventEmitter,this.name=$P,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=xe.toMiliseconds(xe.THIRTY_SECONDS+xe.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");const a=t.id||fa().toString();await this.toEstablishConnection();try{const f=this.provider.request(t);this.requestsInFlight.set(a,{promise:f,request:t}),this.logger.trace({id:a,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const u=await new Promise(async(b,p)=>{const y=()=>{p(new Error(`relayer.request - publish interrupted, id: ${a}`))};this.provider.on(Bi.disconnect,y);const A=await f;this.provider.off(Bi.disconnect,y),b(A)});return this.logger.trace({id:a,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),u}catch(f){throw this.logger.debug(`Failed to Publish Request: ${a}`),f}finally{this.requestsInFlight.delete(a)}},this.resetPingTimeout=()=>{if(dh())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Gr.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Gr.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Bi.payload,this.onPayloadHandler),this.provider.on(Bi.connect,this.onConnectHandler),this.provider.on(Bi.disconnect,this.onDisconnectHandler),this.provider.on(Bi.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Yr(e.logger,this.name):Nc(Hh({level:e.logger||UP})),this.messages=new LR(this.logger,e.core),this.subscriber=new FR(this,this.logger),this.publisher=new qR(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||Fm,this.projectId=e.projectId,this.bundleId=oA(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return di(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:Kt.relay})}async subscribe(e,t){var i;this.isInitialized(),(t==null?void 0:t.transportType)==="relay"&&await this.toEstablishConnection();let n=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"",a;const f=u=>{u.topic===e&&(this.subscriber.off(Mn.created,f),a())};return await Promise.all([new Promise(u=>{a=u,this.subscriber.on(Mn.created,f)}),new Promise(async u=>{n=await this.subscriber.subscribe(e,t)||n,u()})]),n}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await Za(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{const n=()=>{this.provider.off(Bi.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(Bi.disconnect,n),await Za(this.provider.connect(),xe.toMiliseconds(xe.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(a=>{i(a)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(a=>{this.logger.error(a),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);const i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Ig())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const n=vr(xe.FIVE_MINUTES),a={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,a)}this.events.emit(Gr.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,a;if(dh())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((a=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||a.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(f){this.logger.warn(f)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new pn(new SP(uA({sdkVersion:md,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Zd(e)){if(!e.method.endsWith(zP))return;const t=e.params,{topic:i,message:n,publishedAt:a,attestation:f}=t.data,u={topic:i,message:n,publishedAt:a,transportType:Kt.relay,attestation:f};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(GR({type:"event",event:t.id},u)),this.events.emit(t.id,u),await this.acknowledgePayload(e),await this.onMessageEvent(u)}else Gh(e)&&this.events.emit(Gr.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Gr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=Kh(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(Bi.payload,this.onPayloadHandler),this.provider.off(Bi.connect,this.onConnectHandler),this.provider.off(Bi.disconnect,this.onDisconnectHandler),this.provider.off(Bi.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Ig();vI(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Gr.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},xe.toMiliseconds(jP))))}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var JR=Object.defineProperty,tv=Object.getOwnPropertySymbols,YR=Object.prototype.hasOwnProperty,QR=Object.prototype.propertyIsEnumerable,rv=(r,e,t)=>e in r?JR(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,iv=(r,e)=>{for(var t in e||(e={}))YR.call(e,t)&&rv(r,t,e[t]);if(tv)for(var t of tv(e))QR.call(e,t)&&rv(r,t,e[t]);return r};class xa extends RM{constructor(e,t,i,n=kn,a=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=kP,this.cached=[],this.initialized=!1,this.storagePrefix=kn,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(f=>{this.getKey&&f!==null&&!fi(f)?this.map.set(this.getKey(f),f):GS(f)?this.map.set(f.id,f):WS(f)&&this.map.set(f.topic,f)}),this.cached=[],this.initialized=!0)},this.set=async(f,u)=>{this.isInitialized(),this.map.has(f)?await this.update(f,u):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:f,value:u}),this.map.set(f,u),await this.persist())},this.get=f=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:f}),this.getData(f)),this.getAll=f=>(this.isInitialized(),f?this.values.filter(u=>Object.keys(f).every(b=>MP(u[b],f[b]))):this.values),this.update=async(f,u)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:f,update:u});const b=iv(iv({},this.getData(f)),u);this.map.set(f,b),await this.persist()},this.delete=async(f,u)=>{this.isInitialized(),this.map.has(f)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:f,reason:u}),this.map.delete(f),this.addToRecentlyDeleted(f),await this.persist())},this.logger=Yr(t,this.name),this.storagePrefix=n,this.getKey=a}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:n}=Ae("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=Ae("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=Ae("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class XR{constructor(e,t){this.core=e,this.logger=t,this.name=GP,this.version=WP,this.events=new Id,this.initialized=!1,this.storagePrefix=kn,this.ignoredPayloadTypes=[ls],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=ud(),a=await this.core.crypto.setSymKey(n),f=vr(xe.FIVE_MINUTES),u={protocol:km},b={topic:a,expiry:f,relay:u,active:!1,methods:i==null?void 0:i.methods},p=wg({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:n,relay:u,expiryTimestamp:f,methods:i==null?void 0:i.methods});return this.events.emit(oa.create,b),this.core.expirer.set(a,f),await this.pairings.set(a,b),await this.core.relayer.subscribe(a,{transportType:i==null?void 0:i.transportType}),{topic:a,uri:p}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i==null?void 0:i.uri,trace:[En.pairing_started]}});this.isValidPair(i,n);const{topic:a,symKey:f,relay:u,expiryTimestamp:b,methods:p}=yg(i.uri);n.props.properties.topic=a,n.addTrace(En.pairing_uri_validation_success),n.addTrace(En.pairing_uri_not_expired);let y;if(this.pairings.keys.includes(a)){if(y=this.pairings.get(a),n.addTrace(En.existing_pairing),y.active)throw n.setError(as.active_pairing_already_exists),new Error(`Pairing already exists: ${a}. Please try again with a new connection URI.`);n.addTrace(En.pairing_not_expired)}const A=b||vr(xe.FIVE_MINUTES),R={topic:a,relay:u,expiry:A,active:!1,methods:p};this.core.expirer.set(a,A),await this.pairings.set(a,R),n.addTrace(En.store_new_pairing),i.activatePairing&&await this.activate({topic:a}),this.events.emit(oa.create,R),n.addTrace(En.emit_inactive_pairing),this.core.crypto.keychain.has(a)||await this.core.crypto.setSymKey(f,a),n.addTrace(En.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(as.no_internet_connection)}try{await this.core.relayer.subscribe(a,{relay:u})}catch(O){throw n.setError(as.subscribe_pairing_topic_failure),O}return n.addTrace(En.subscribe_pairing_topic_success),R},this.activate=async({topic:i})=>{this.isInitialized();const n=vr(xe.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.pairings.keys.includes(n)){const a=await this.sendRequest(n,"wc_pairingPing",{}),{done:f,resolve:u,reject:b}=aa();this.events.once(St("pairing_ping",a),({error:p})=>{p?b(p):u()}),await f()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",$t("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:a,expiry:f,methods:u}=i,b=this.core.crypto.keychain.get(n);return wg({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:b,relay:a,expiryTimestamp:f,methods:u})},this.sendRequest=async(i,n,a)=>{const f=qs(n,a),u=await this.core.crypto.encode(i,f),b=Xo[n].req;return this.core.history.set(i,f),this.core.relayer.publish(i,u,b),f.id},this.sendResult=async(i,n,a)=>{const f=Kh(i,a),u=await this.core.crypto.encode(n,f),b=await this.core.history.get(n,i),p=Xo[b.request.method].res;await this.core.relayer.publish(n,u,p),await this.core.history.resolve(f)},this.sendError=async(i,n,a)=>{const f=Vh(i,a),u=await this.core.crypto.encode(n,f),b=await this.core.history.get(n,i),p=Xo[b.request.method]?Xo[b.request.method].res:Xo.unregistered_method.res;await this.core.relayer.publish(n,u,p),await this.core.history.resolve(f)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,$t("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>Os(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:a}=i;switch(a.method){case"wc_pairingPing":return this.onPairingPingRequest(n,a);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,a);default:return this.onUnknownRpcMethodRequest(n,a)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:a}=i,f=(await this.core.history.get(n,a.id)).request.method;switch(f){case"wc_pairingPing":return this.onPairingPingResponse(n,a);default:return this.onUnknownRpcMethodResponse(f)}},this.onPairingPingRequest=async(i,n)=>{const{id:a}=n;try{this.isValidPing({topic:i}),await this.sendResult(a,i,!0),this.events.emit(oa.ping,{id:a,topic:i})}catch(f){await this.sendError(a,i,f),this.logger.error(f)}},this.onPairingPingResponse=(i,n)=>{const{id:a}=n;setTimeout(()=>{In(n)?this.events.emit(St("pairing_ping",a),{}):zi(n)&&this.events.emit(St("pairing_ping",a),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:a}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(oa.delete,{id:a,topic:i})}catch(f){await this.sendError(a,i,f),this.logger.error(f)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:a,method:f}=n;try{if(this.registeredMethods.includes(f))return;const u=$t("WC_METHOD_UNSUPPORTED",f);await this.sendError(a,i,u),this.logger.error(u)}catch(u){await this.sendError(a,i,u),this.logger.error(u)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error($t("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var a;if(!oi(i)){const{message:u}=Ae("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(as.malformed_pairing_uri),new Error(u)}if(!VS(i.uri)){const{message:u}=Ae("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(as.malformed_pairing_uri),new Error(u)}const f=yg(i==null?void 0:i.uri);if(!((a=f==null?void 0:f.relay)!=null&&a.protocol)){const{message:u}=Ae("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(as.malformed_pairing_uri),new Error(u)}if(!(f!=null&&f.symKey)){const{message:u}=Ae("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(as.malformed_pairing_uri),new Error(u)}if(f!=null&&f.expiryTimestamp&&xe.toMiliseconds(f==null?void 0:f.expiryTimestamp){if(!oi(i)){const{message:a}=Ae("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(a)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!oi(i)){const{message:a}=Ae("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(a)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!fr(i,!1)){const{message:n}=Ae("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=Ae("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Os(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=Ae("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=Yr(t,this.name),this.pairings=new xa(this.core,this.logger,this.name,this.storagePrefix)}get context(){return di(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Gr.message,async e=>{const{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===Kt.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const a=await this.core.crypto.decode(t,i);try{Zd(a)?(this.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a})):Gh(a)&&(await this.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a}),this.core.history.delete(t,a.id))}catch(f){this.logger.error(f)}})}registerExpirerEvents(){this.core.expirer.on(Ui.expired,async e=>{const{topic:t}=Lb(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(oa.expire,{topic:t}))})}}class ZR extends IM{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Fi.EventEmitter,this.name=JP,this.version=YP,this.cached=[],this.initialized=!1,this.storagePrefix=kn,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,a)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:a}),this.records.has(n.id))return;const f={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:a,expiry:vr(xe.THIRTY_DAYS)};this.records.set(f.id,f),this.persist(),this.events.emit(an.created,f)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=zi(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(an.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(a=>{if(a.topic===i){if(typeof n<"u"&&a.id!==n)return;this.records.delete(a.id),this.events.emit(an.deleted,a)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Yr(t,this.name)}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:qs(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=Ae("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(an.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=Ae("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(an.created,e=>{const t=an.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(an.updated,e=>{const t=an.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(an.deleted,e=>{const t=an.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(Ao.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{xe.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(an.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}class eN extends TM{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Fi.EventEmitter,this.name=QP,this.version=XP,this.cached=[],this.initialized=!1,this.storagePrefix=kn,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();const a=this.formatTarget(i),f={target:a,expiry:n};this.expirations.set(a,f),this.checkExpiry(a,f),this.events.emit(Ui.created,{target:a,expiration:f})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),a=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Ui.deleted,{target:n,expiration:a})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Yr(t,this.name)}get context(){return di(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return lA(e);if(typeof e=="number")return dA(e);const{message:t}=Ae("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Ui.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=Ae("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=Ae("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;xe.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Ui.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(Ao.pulse,()=>this.checkExpirations()),this.events.on(Ui.created,e=>{const t=Ui.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ui.expired,e=>{const t=Ui.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ui.deleted,e=>{const t=Ui.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.getLocalStorage=Qt.getLocalStorageOrThrow=Qt.getCrypto=Qt.getCryptoOrThrow=Qt.getLocation=Qt.getLocationOrThrow=Qt.getNavigator=Qt.getNavigatorOrThrow=t2=Qt.getDocument=Qt.getDocumentOrThrow=Qt.getFromWindowOrThrow=Qt.getFromWindow=void 0;function Sa(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Qt.getFromWindow=Sa;function Eo(r){const e=Sa(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Qt.getFromWindowOrThrow=Eo;function tN(){return Eo("document")}Qt.getDocumentOrThrow=tN;function rN(){return Sa("document")}var t2=Qt.getDocument=rN;function iN(){return Eo("navigator")}Qt.getNavigatorOrThrow=iN;function nN(){return Sa("navigator")}Qt.getNavigator=nN;function sN(){return Eo("location")}Qt.getLocationOrThrow=sN;function aN(){return Sa("location")}Qt.getLocation=aN;function oN(){return Eo("crypto")}Qt.getCryptoOrThrow=oN;function cN(){return Sa("crypto")}Qt.getCrypto=cN;function fN(){return Eo("localStorage")}Qt.getLocalStorageOrThrow=fN;function hN(){return Sa("localStorage")}Qt.getLocalStorage=hN;class uN extends CM{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=ZP,this.verifyUrlV3=tO,this.storagePrefix=kn,this.version=jm,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&xe.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt){if(!Sc()||this.isDevEnv)return;const a=window.location.origin,{id:f,decryptedId:u}=n,b=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${a}&id=${f}&decryptedId=${u}`;try{const p=t2(),y=this.startAbortTimer(xe.ONE_SECOND*5),A=await new Promise((R,O)=>{const N=()=>{window.removeEventListener("message",W),p.body.removeChild(K),O("attestation aborted")};this.abortController.signal.addEventListener("abort",N);const K=p.createElement("iframe");K.src=b,K.style.display="none",K.addEventListener("error",N,{signal:this.abortController.signal});const W=Q=>{if(Q.data&&typeof Q.data=="string")try{const k=JSON.parse(Q.data);if(k.type==="verify_attestation"){if(nd(k.attestation).payload.id!==f)return;clearInterval(y),p.body.removeChild(K),this.abortController.signal.removeEventListener("abort",N),window.removeEventListener("message",W),R(k.attestation===null?"":k.attestation)}}catch(k){this.logger.warn(k)}};p.body.appendChild(K),window.addEventListener("message",W,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",A),A}catch(p){this.logger.warn(p)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:a,hash:f,encryptedId:u}=n;if(a===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(a){if(nd(a).payload.id!==u)return;const p=await this.isValidJwtAttestation(a);if(p){if(!p.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return p}}if(!f)return;const b=this.getVerifyUrl(n==null?void 0:n.verifyUrl);return this.fetchAttestation(f,b)},this.fetchAttestation=async(n,a)=>{this.logger.debug(`resolving attestation: ${n} from url: ${a}`);const f=this.startAbortTimer(xe.ONE_SECOND*5),u=await fetch(`${a}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(f),u.status===200?await u.json():void 0},this.getVerifyUrl=n=>{let a=n||uc;return rO.includes(a)||(this.logger.info(`verify url: ${a}, not included in trusted list, assigning default: ${uc}`),a=uc),a},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(xe.FIVE_SECONDS),a=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await a.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{const a=await this.getPublicKey();try{if(a)return this.validateAttestation(n,a)}catch(u){this.logger.error(u),this.logger.warn("error validating attestation")}const f=await this.fetchAndPersistPublicKey();try{if(f)return this.validateAttestation(n,f)}catch(u){this.logger.error(u),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async a=>{const f=await this.fetchPublicKey();f&&(await this.persistPublicKey(f),a(f))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,a)=>{const f=MS(n,a.publicKey),u={hasExpired:xe.toMiliseconds(f.exp)this.abortController.abort(),xe.toMiliseconds(e))}}class lN extends DM{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=iO,this.registerDeviceToken=async i=>{const{clientId:n,token:a,notificationType:f,enableEncrypted:u=!1}=i,b=`${nO}/${this.projectId}/clients`;await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:f,token:a,always_raw:u})})},this.logger=Yr(t,this.context)}}var dN=Object.defineProperty,nv=Object.getOwnPropertySymbols,pN=Object.prototype.hasOwnProperty,gN=Object.prototype.propertyIsEnumerable,sv=(r,e,t)=>e in r?dN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tc=(r,e)=>{for(var t in e||(e={}))pN.call(e,t)&&sv(r,t,e[t]);if(nv)for(var t of nv(e))gN.call(e,t)&&sv(r,t,e[t]);return r};class vN extends LM{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=aO,this.storagePrefix=kn,this.storageVersion=sO,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!jd())try{const n={eventId:U1(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Nb(this.core.relayer.protocol,this.core.relayer.version,md)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:a="ERROR",type:f="",properties:{topic:u,trace:b}}=n,p=U1(),y=this.core.projectId||"",A=Date.now(),R=tc({eventId:p,timestamp:A,props:{event:a,type:f,properties:{topic:u,trace:b}},bundleId:y,domain:this.getAppDomain()},this.setMethods(p));return this.telemetryEnabled&&(this.events.set(p,R),this.shouldPersist=!0),R},this.getEvent=n=>{const{eventId:a,topic:f}=n;if(a)return this.events.get(a);const u=Array.from(this.events.values()).find(b=>b.props.properties.topic===f);if(u)return tc(tc({},u),this.setMethods(u.eventId))},this.deleteEvent=n=>{const{eventId:a}=n;this.events.delete(a),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(Ao.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{xe.fromMiliseconds(Date.now())-xe.fromMiliseconds(n.timestamp)>oO&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:a=>this.addTrace(n,a),setError:a=>this.setError(n,a)}),this.addTrace=(n,a)=>{const f=this.events.get(n);f&&(f.props.properties.trace.push(a),this.events.set(n,f),this.shouldPersist=!0)},this.setError=(n,a)=>{const f=this.events.get(n);f&&(f.props.type=a,f.timestamp=Date.now(),this.events.set(n,f),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(a=>{this.events.set(a.eventId,tc(tc({},a),this.setMethods(a.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[a,f]of this.events)f.props.type&&n.push(f);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const a of n)this.events.delete(a.eventId),this.shouldPersist=!0}catch(a){this.logger.warn(a)}},this.sendEvent=async n=>{const a=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${cO}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${md}${a}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Rb().url,this.logger=Yr(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var bN=Object.defineProperty,av=Object.getOwnPropertySymbols,mN=Object.prototype.hasOwnProperty,yN=Object.prototype.propertyIsEnumerable,ov=(r,e,t)=>e in r?bN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,cv=(r,e)=>{for(var t in e||(e={}))mN.call(e,t)&&ov(r,t,e[t]);if(av)for(var t of av(e))yN.call(e,t)&&ov(r,t,e[t]);return r};class t0 extends SM{constructor(e){var t;super(e),this.protocol=zm,this.version=jm,this.name=e0,this.events=new Fi.EventEmitter,this.initialized=!1,this.on=(f,u)=>this.events.on(f,u),this.once=(f,u)=>this.events.once(f,u),this.off=(f,u)=>this.events.off(f,u),this.removeListener=(f,u)=>this.events.removeListener(f,u),this.dispatchEnvelope=({topic:f,message:u,sessionExists:b})=>{if(!f||!u)return;const p={topic:f,message:u,publishedAt:Date.now(),transportType:Kt.link_mode};this.relayer.onLinkMessageEvent(p,{sessionExists:b})},this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Fm,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Hh({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:PP.logger}),{logger:n,chunkLoggerController:a}=xM({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=a,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var f,u;(f=this.logChunkController)!=null&&f.downloadLogsBlobInBrowser&&((u=this.logChunkController)==null||u.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Yr(n,this.name),this.heartbeat=new wI,this.crypto=new DR(this,this.logger,e==null?void 0:e.keychain),this.history=new ZR(this,this.logger),this.expirer=new eN(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new YI(cv(cv({},OP),e==null?void 0:e.storageOptions)),this.relayer=new WR({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new XR(this,this.logger),this.verify=new uN(this,this.logger,this.storage),this.echoClient=new lN(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new vN(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const t=new t0(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(FP,i),t}get context(){return di(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Hg,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(Hg)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const wN=t0,r2="wc",i2=2,n2="client",r0=`${r2}@${i2}:${n2}:`,$l={name:n2,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},fv="WALLETCONNECT_DEEPLINK_CHOICE",_N="proposal",s2="Proposal expired",AN="session",Ga=xe.SEVEN_DAYS,EN="engine",wr={wc_sessionPropose:{req:{ttl:xe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:xe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:xe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:xe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:xe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:xe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:xe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:xe.FIVE_MINUTES,prompt:!1,tag:1119}}},zl={min:xe.FIVE_MINUTES,max:xe.SEVEN_DAYS},An={idle:"IDLE",active:"ACTIVE"},xN="request",SN=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],IN="wc",MN="auth",PN="authKeys",ON="pairingTopics",RN="requests",Jh=`${IN}@${1.5}:${MN}:`,sh=`${Jh}:PUB_KEY`;var NN=Object.defineProperty,TN=Object.defineProperties,CN=Object.getOwnPropertyDescriptors,hv=Object.getOwnPropertySymbols,DN=Object.prototype.hasOwnProperty,LN=Object.prototype.propertyIsEnumerable,uv=(r,e,t)=>e in r?NN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rr=(r,e)=>{for(var t in e||(e={}))DN.call(e,t)&&uv(r,t,e[t]);if(hv)for(var t of hv(e))LN.call(e,t)&&uv(r,t,e[t]);return r},cn=(r,e)=>TN(r,CN(e));class qN extends BM{constructor(e){super(e),this.name=EN,this.events=new Id,this.initialized=!1,this.requestQueue={state:An.idle,queue:[]},this.sessionRequestQueue={state:An.idle,queue:[]},this.requestQueueDelay=xe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(wr)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},xe.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=cn(rr({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:a,optionalNamespaces:f,sessionProperties:u,relays:b}=i;let p=n,y,A=!1;try{p&&(A=this.client.core.pairing.pairings.get(p).active)}catch($){throw this.client.logger.error(`connect() -> pairing.get(${p}) failed`),$}if(!p||!A){const{topic:$,uri:F}=await this.client.core.pairing.create();p=$,y=F}if(!p){const{message:$}=Ae("NO_MATCHING_KEY",`connect() pairing topic: ${p}`);throw new Error($)}const R=await this.client.core.crypto.generateKeyPair(),O=wr.wc_sessionPropose.req.ttl||xe.FIVE_MINUTES,N=vr(O),K=rr({requiredNamespaces:a,optionalNamespaces:f,relays:b??[{protocol:km}],proposer:{publicKey:R,metadata:this.client.metadata},expiryTimestamp:N,pairingTopic:p},u&&{sessionProperties:u}),{reject:W,resolve:Q,done:k}=aa(O,s2);this.events.once(St("session_connect"),async({error:$,session:F})=>{if($)W($);else if(F){F.self.publicKey=R;const G=cn(rr({},F),{pairingTopic:K.pairingTopic,requiredNamespaces:K.requiredNamespaces,optionalNamespaces:K.optionalNamespaces,transportType:Kt.relay});await this.client.session.set(F.topic,G),await this.setExpiry(F.topic,F.expiry),p&&await this.client.core.pairing.updateMetadata({topic:p,metadata:F.peer.metadata}),this.cleanupDuplicatePairings(G),Q(G)}});const Y=await this.sendRequest({topic:p,method:"wc_sessionPropose",params:K,throwOnFailedPublish:!0});return await this.setProposal(Y,rr({id:Y},K)),{uri:y,approval:k}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,a;const f=this.client.core.eventClient.createEvent({properties:{topic:(i=t==null?void 0:t.id)==null?void 0:i.toString(),trace:[on.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(q){throw f.setError(na.no_internet_connection),q}try{await this.isValidProposalId(t==null?void 0:t.id)}catch(q){throw this.client.logger.error(`approve() -> proposal.get(${t==null?void 0:t.id}) failed`),f.setError(na.proposal_not_found),q}try{await this.isValidApprove(t)}catch(q){throw this.client.logger.error("approve() -> isValidApprove() failed"),f.setError(na.session_approve_namespace_validation_failure),q}const{id:u,relayProtocol:b,namespaces:p,sessionProperties:y,sessionConfig:A}=t,R=this.client.proposal.get(u);this.client.core.eventClient.deleteEvent({eventId:f.eventId});const{pairingTopic:O,proposer:N,requiredNamespaces:K,optionalNamespaces:W}=R;let Q=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:O});Q||(Q=(a=this.client.core.eventClient)==null?void 0:a.createEvent({type:on.session_approve_started,properties:{topic:O,trace:[on.session_approve_started,on.session_namespaces_validation_success]}}));const k=await this.client.core.crypto.generateKeyPair(),Y=N.publicKey,$=await this.client.core.crypto.generateSharedKey(k,Y),F=rr(rr({relay:{protocol:b??"irn"},namespaces:p,controller:{publicKey:k,metadata:this.client.metadata},expiry:vr(Ga)},y&&{sessionProperties:y}),A&&{sessionConfig:A}),G=Kt.relay;Q.addTrace(on.subscribing_session_topic);try{await this.client.core.relayer.subscribe($,{transportType:G})}catch(q){throw Q.setError(na.subscribe_session_topic_failure),q}Q.addTrace(on.subscribe_session_topic_success);const x=cn(rr({},F),{topic:$,requiredNamespaces:K,optionalNamespaces:W,pairingTopic:O,acknowledged:!1,self:F.controller,peer:{publicKey:N.publicKey,metadata:N.metadata},controller:k,transportType:Kt.relay});await this.client.session.set($,x),Q.addTrace(on.store_session);try{Q.addTrace(on.publishing_session_settle),await this.sendRequest({topic:$,method:"wc_sessionSettle",params:F,throwOnFailedPublish:!0}).catch(q=>{throw Q==null||Q.setError(na.session_settle_publish_failure),q}),Q.addTrace(on.session_settle_publish_success),Q.addTrace(on.publishing_session_approve),await this.sendResult({id:u,topic:O,result:{relay:{protocol:b??"irn"},responderPublicKey:k},throwOnFailedPublish:!0}).catch(q=>{throw Q==null||Q.setError(na.session_approve_publish_failure),q}),Q.addTrace(on.session_approve_publish_success)}catch(q){throw this.client.logger.error(q),this.client.session.delete($,$t("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe($),q}return this.client.core.eventClient.deleteEvent({eventId:Q.eventId}),await this.client.core.pairing.updateMetadata({topic:O,metadata:N.metadata}),await this.client.proposal.delete(u,$t("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:O}),await this.setExpiry($,vr(Ga)),{topic:$,acknowledged:()=>Promise.resolve(this.client.session.get($))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(f){throw this.client.logger.error("reject() -> isValidReject() failed"),f}const{id:i,reason:n}=t;let a;try{a=this.client.proposal.get(i).pairingTopic}catch(f){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),f}a&&(await this.sendError({id:i,topic:a,error:n,rpcOpts:wr.wc_sessionPropose.reject}),await this.client.proposal.delete(i,$t("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(A){throw this.client.logger.error("update() -> isValidUpdate() failed"),A}const{topic:i,namespaces:n}=t,{done:a,resolve:f,reject:u}=aa(),b=Ns(),p=fa().toString(),y=this.client.session.get(i).namespaces;return this.events.once(St("session_update",b),({error:A})=>{A?u(A):f()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:b,relayRpcId:p}).catch(A=>{this.client.logger.error(A),this.client.session.update(i,{namespaces:y}),u(A)}),{acknowledged:a}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(b){throw this.client.logger.error("extend() -> isValidExtend() failed"),b}const{topic:i}=t,n=Ns(),{done:a,resolve:f,reject:u}=aa();return this.events.once(St("session_extend",n),({error:b})=>{b?u(b):f()}),await this.setExpiry(i,vr(Ga)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(b=>{u(b)}),{acknowledged:a}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(N){throw this.client.logger.error("request() -> isValidRequest() failed"),N}const{chainId:i,request:n,topic:a,expiry:f=wr.wc_sessionRequest.req.ttl}=t,u=this.client.session.get(a);(u==null?void 0:u.transportType)===Kt.relay&&await this.confirmOnlineStateOrThrow();const b=Ns(),p=fa().toString(),{done:y,resolve:A,reject:R}=aa(f,"Request expired. Please try again.");this.events.once(St("session_request",b),({error:N,result:K})=>{N?R(N):A(K)});const O=this.getAppLinkIfEnabled(u.peer.metadata,u.transportType);return O?(await this.sendRequest({clientRpcId:b,relayRpcId:p,topic:a,method:"wc_sessionRequest",params:{request:cn(rr({},n),{expiryTimestamp:vr(f)}),chainId:i},expiry:f,throwOnFailedPublish:!0,appLink:O}).catch(N=>R(N)),this.client.events.emit("session_request_sent",{topic:a,request:n,chainId:i,id:b}),await y()):await Promise.all([new Promise(async N=>{await this.sendRequest({clientRpcId:b,relayRpcId:p,topic:a,method:"wc_sessionRequest",params:{request:cn(rr({},n),{expiryTimestamp:vr(f)}),chainId:i},expiry:f,throwOnFailedPublish:!0}).catch(K=>R(K)),this.client.events.emit("session_request_sent",{topic:a,request:n,chainId:i,id:b}),N()}),new Promise(async N=>{var K;if(!((K=u.sessionConfig)!=null&&K.disableDeepLink)){const W=await vA(this.client.core.storage,fv);await pA({id:b,topic:a,wcDeepLink:W})}N()}),y()]).then(N=>N[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:n}=t,{id:a}=n,f=this.client.session.get(i);f.transportType===Kt.relay&&await this.confirmOnlineStateOrThrow();const u=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);In(n)?await this.sendResult({id:a,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:u}):zi(n)&&await this.sendError({id:a,topic:i,error:n.error,appLink:u}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=t;if(this.client.session.keys.includes(i)){const n=Ns(),a=fa().toString(),{done:f,resolve:u,reject:b}=aa();this.events.once(St("session_ping",n),({error:p})=>{p?b(p):u()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:a}),f()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:n,chainId:a}=t,f=fa().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:a},throwOnFailedPublish:!0,relayRpcId:f})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:$t("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=Ae("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>HS(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);const a=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),f=a?Kt.link_mode:Kt.relay;f===Kt.relay&&await this.confirmOnlineStateOrThrow();const{chains:u,statement:b="",uri:p,domain:y,nonce:A,type:R,exp:O,nbf:N,methods:K=[],expiry:W}=t,Q=[...t.resources||[]],{topic:k,uri:Y}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:f});this.client.logger.info({message:"Generated new pairing",pairing:{topic:k,uri:Y}});const $=await this.client.core.crypto.generateKeyPair(),F=rh($);if(await Promise.all([this.client.auth.authKeys.set(sh,{responseTopic:F,publicKey:$}),this.client.auth.pairingTopics.set(F,{topic:F,pairingTopic:k})]),await this.client.core.relayer.subscribe(F,{transportType:f}),this.client.logger.info(`sending request to new pairing topic: ${k}`),K.length>0){const{namespace:M}=ac(u[0]);let S=uS(M,"request",K);th(Q)&&(S=dS(S,Q.pop())),Q.push(S)}const G=W&&W>wr.wc_sessionAuthenticate.req.ttl?W:wr.wc_sessionAuthenticate.req.ttl,x={authPayload:{type:R??"caip122",chains:u,statement:b,aud:p,domain:y,version:"1",nonce:A,iat:new Date().toISOString(),exp:O,nbf:N,resources:Q},requester:{publicKey:$,metadata:this.client.metadata},expiryTimestamp:vr(G)},q={eip155:{chains:u,methods:[...new Set(["personal_sign",...K])],events:["chainChanged","accountsChanged"]}},ae={requiredNamespaces:{},optionalNamespaces:q,relays:[{protocol:"irn"}],pairingTopic:k,proposer:{publicKey:$,metadata:this.client.metadata},expiryTimestamp:vr(wr.wc_sessionPropose.req.ttl)},{done:le,resolve:L,reject:m}=aa(G,"Request expired"),c=async({error:M,session:S})=>{if(this.events.off(St("session_request",v),h),M)m(M);else if(S){S.self.publicKey=$,await this.client.session.set(S.topic,S),await this.setExpiry(S.topic,S.expiry),k&&await this.client.core.pairing.updateMetadata({topic:k,metadata:S.peer.metadata});const d=this.client.session.get(S.topic);await this.deleteProposal(_),L({session:d})}},h=async M=>{var S,d,g;if(await this.deletePendingAuthRequest(v,{message:"fulfilled",code:0}),M.error){const j=$t("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return M.error.code===j.code?void 0:(this.events.off(St("session_connect"),c),m(M.error.message))}await this.deleteProposal(_),this.events.off(St("session_connect"),c);const{cacaos:C,responder:Z}=M.result,se=[],P=[];for(const j of C){await hg({cacao:j,projectId:this.client.core.projectId})||(this.client.logger.error(j,"Signature verification failed"),m($t("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:H}=j,w=th(H.resources),z=[fg(H.iss)],ne=mh(H.iss);if(w){const ce=ug(w),he=lg(w);se.push(...ce),z.push(...he)}for(const ce of z)P.push(`${ce}:${ne}`)}const ee=await this.client.core.crypto.generateSharedKey($,Z.publicKey);let B;se.length>0&&(B={topic:ee,acknowledged:!0,self:{publicKey:$,metadata:this.client.metadata},peer:Z,controller:Z.publicKey,expiry:vr(Ga),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:k,namespaces:_g([...new Set(se)],[...new Set(P)]),transportType:f},await this.client.core.relayer.subscribe(ee,{transportType:f}),await this.client.session.set(ee,B),k&&await this.client.core.pairing.updateMetadata({topic:k,metadata:Z.metadata}),B=this.client.session.get(ee)),(S=this.client.metadata.redirect)!=null&&S.linkMode&&(d=Z.metadata.redirect)!=null&&d.linkMode&&(g=Z.metadata.redirect)!=null&&g.universal&&i&&(this.client.core.addLinkModeSupportedApp(Z.metadata.redirect.universal),this.client.session.update(ee,{transportType:Kt.link_mode})),L({auths:C,session:B})},v=Ns(),_=Ns();this.events.once(St("session_connect"),c),this.events.once(St("session_request",v),h);let I;try{if(a){const M=qs("wc_sessionAuthenticate",x,v);this.client.core.history.set(k,M);const S=await this.client.core.crypto.encode("",M,{type:Oc,encoding:Yo});I=Ff(i,k,S)}else await Promise.all([this.sendRequest({topic:k,method:"wc_sessionAuthenticate",params:x,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:v}),this.sendRequest({topic:k,method:"wc_sessionPropose",params:ae,expiry:wr.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:_})])}catch(M){throw this.events.off(St("session_connect"),c),this.events.off(St("session_request",v),h),M}return await this.setProposal(_,rr({id:_},ae)),await this.setAuthRequest(v,{request:cn(rr({},x),{verifyContext:{}}),pairingTopic:k,transportType:f}),{uri:I??Y,response:le}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:n}=t,a=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[sa.authenticated_session_approve_started]}});try{this.isInitialized()}catch(W){throw a.setError(Zo.no_internet_connection),W}const f=this.getPendingAuthRequest(i);if(!f)throw a.setError(Zo.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const u=f.transportType||Kt.relay;u===Kt.relay&&await this.confirmOnlineStateOrThrow();const b=f.requester.publicKey,p=await this.client.core.crypto.generateKeyPair(),y=rh(b),A={type:ls,receiverPublicKey:b,senderPublicKey:p},R=[],O=[];for(const W of n){if(!await hg({cacao:W,projectId:this.client.core.projectId})){a.setError(Zo.invalid_cacao);const F=$t("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:y,error:F,encodeOpts:A}),new Error(F.message)}a.addTrace(sa.cacaos_verified);const{p:Q}=W,k=th(Q.resources),Y=[fg(Q.iss)],$=mh(Q.iss);if(k){const F=ug(k),G=lg(k);R.push(...F),Y.push(...G)}for(const F of Y)O.push(`${F}:${$}`)}const N=await this.client.core.crypto.generateSharedKey(p,b);a.addTrace(sa.create_authenticated_session_topic);let K;if((R==null?void 0:R.length)>0){K={topic:N,acknowledged:!0,self:{publicKey:p,metadata:this.client.metadata},peer:{publicKey:b,metadata:f.requester.metadata},controller:b,expiry:vr(Ga),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:f.pairingTopic,namespaces:_g([...new Set(R)],[...new Set(O)]),transportType:u},a.addTrace(sa.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(N,{transportType:u})}catch(W){throw a.setError(Zo.subscribe_authenticated_session_topic_failure),W}a.addTrace(sa.subscribe_authenticated_session_topic_success),await this.client.session.set(N,K),a.addTrace(sa.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:f.requester.metadata})}a.addTrace(sa.publishing_authenticated_session_approve);try{await this.sendResult({topic:y,id:i,result:{cacaos:n,responder:{publicKey:p,metadata:this.client.metadata}},encodeOpts:A,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(f.requester.metadata,u)})}catch(W){throw a.setError(Zo.authenticated_session_approve_publish_failure),W}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:f.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:a.eventId}),{session:K}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:i,reason:n}=t,a=this.getPendingAuthRequest(i);if(!a)throw new Error(`Could not find pending auth request with id ${i}`);a.transportType===Kt.relay&&await this.confirmOnlineStateOrThrow();const f=a.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),b=rh(f),p={type:ls,receiverPublicKey:f,senderPublicKey:u};await this.sendError({id:i,topic:b,error:n,encodeOpts:p,rpcOpts:wr.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(a.requester.metadata,a.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,$t("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:n}=t;return mm(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(a=>{var f,u;return((f=a.peerMetadata)==null?void 0:f.url)&&((u=a.peerMetadata)==null?void 0:u.url)===t.peer.metadata.url&&a.topic&&a.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(a=>this.client.core.pairing.disconnect({topic:a.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;const{topic:n,expirerHasDeleted:a=!1,emitEvent:f=!0,id:u=0}=t,{self:b}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,$t("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(b.publicKey)&&await this.client.core.crypto.deleteKeyPair(b.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),a||this.client.core.expirer.del(n),this.client.core.storage.removeItem(fv).catch(p=>this.client.logger.warn(p)),this.getPendingSessionRequests().forEach(p=>{p.topic===n&&this.deletePendingSessionRequest(p.id,$t("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=An.idle),f&&this.client.events.emit("session_delete",{id:u,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{const n=this.client.proposal.get(t),a=this.client.core.eventClient.getEvent({topic:n.pairingTopic});a==null||a.setError(na.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,$t("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(a=>a.id!==t),n&&(this.sessionRequestQueue.state=An.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,vr(wr.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:n,pairingTopic:a,transportType:f=Kt.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:a,verifyContext:n.verifyContext,transportType:f})},this.setPendingSessionRequest=async t=>{const{id:i,topic:n,params:a,verifyContext:f}=t,u=a.request.expiryTimestamp||vr(wr.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,u),await this.client.pendingRequest.set(i,{id:i,topic:n,params:a,verifyContext:f})},this.sendRequest=async t=>{const{topic:i,method:n,params:a,expiry:f,relayRpcId:u,clientRpcId:b,throwOnFailedPublish:p,appLink:y}=t,A=qs(n,a,b);let R;const O=!!y;try{const W=O?Yo:Ls;R=await this.client.core.crypto.encode(i,A,{encoding:W})}catch(W){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),W}let N;if(SN.includes(n)){const W=cs(JSON.stringify(A)),Q=cs(R);N=await this.client.core.verify.register({id:Q,decryptedId:W})}const K=wr[n].req;if(K.attestation=N,f&&(K.ttl=f),u&&(K.id=u),this.client.core.history.set(i,A),O){const W=Ff(y,i,R);await globalThis.Linking.openURL(W,this.client.name)}else{const W=wr[n].req;f&&(W.ttl=f),u&&(W.id=u),p?(W.internal=cn(rr({},W.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,R,W)):this.client.core.relayer.publish(i,R,W).catch(Q=>this.client.logger.error(Q))}return A.id},this.sendResult=async t=>{const{id:i,topic:n,result:a,throwOnFailedPublish:f,encodeOpts:u,appLink:b}=t,p=Kh(i,a);let y;const A=b&&typeof(globalThis==null?void 0:globalThis.Linking)<"u";try{const O=A?Yo:Ls;y=await this.client.core.crypto.encode(n,p,cn(rr({},u||{}),{encoding:O}))}catch(O){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),O}let R;try{R=await this.client.core.history.get(n,i)}catch(O){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),O}if(A){const O=Ff(b,n,y);await globalThis.Linking.openURL(O,this.client.name)}else{const O=wr[R.request.method].res;f?(O.internal=cn(rr({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,y,O)):this.client.core.relayer.publish(n,y,O).catch(N=>this.client.logger.error(N))}await this.client.core.history.resolve(p)},this.sendError=async t=>{const{id:i,topic:n,error:a,encodeOpts:f,rpcOpts:u,appLink:b}=t,p=Vh(i,a);let y;const A=b&&typeof(globalThis==null?void 0:globalThis.Linking)<"u";try{const O=A?Yo:Ls;y=await this.client.core.crypto.encode(n,p,cn(rr({},f||{}),{encoding:O}))}catch(O){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),O}let R;try{R=await this.client.core.history.get(n,i)}catch(O){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),O}if(A){const O=Ff(b,n,y);await globalThis.Linking.openURL(O,this.client.name)}else{const O=u||wr[R.request.method].res;this.client.core.relayer.publish(n,y,O)}await this.client.core.history.resolve(p)},this.cleanup=async()=>{const t=[],i=[];this.client.session.getAll().forEach(n=>{let a=!1;Os(n.expiry)&&(a=!0),this.client.core.crypto.keychain.has(n.topic)||(a=!0),a&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Os(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===An.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=An.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=An.idle},this.processRequest=async t=>{const{topic:i,payload:n,attestation:a,transportType:f,encryptedId:u}=t,b=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:b}))switch(b){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:a,encryptedId:u});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:a,encryptedId:u,transportType:f});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:a,encryptedId:u,transportType:f});default:return this.client.logger.info(`Unsupported request method ${b}`)}},this.onRelayEventResponse=async t=>{const{topic:i,payload:n,transportType:a}=t,f=(await this.client.core.history.get(i,n.id)).request.method;switch(f){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,a);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${f}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:i}=t,{message:n}=Ae("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{const{topic:i,requestMethod:n}=t,a=this.expectedPairingMethodMap.get(i);return!a||a.includes(n)?!1:!!(a.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{const{topic:i,payload:n,attestation:a,encryptedId:f}=t,{params:u,id:b}=n;try{const p=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(rr({},n.params));const y=u.expiryTimestamp||vr(wr.wc_sessionPropose.req.ttl),A=rr({id:b,pairingTopic:i,expiryTimestamp:y},u);await this.setProposal(b,A);const R=await this.getVerifyContext({attestationId:a,hash:cs(JSON.stringify(n)),encryptedId:f,metadata:A.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),p==null||p.setError(as.proposal_listener_not_found)),p==null||p.addTrace(En.emit_session_proposal),this.client.events.emit("session_proposal",{id:b,params:A,verifyContext:R})}catch(p){await this.sendError({id:b,topic:i,error:p,rpcOpts:wr.wc_sessionPropose.autoReject}),this.client.logger.error(p)}},this.onSessionProposeResponse=async(t,i,n)=>{const{id:a}=i;if(In(i)){const{result:f}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:f});const u=this.client.proposal.get(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:u});const b=u.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:b});const p=f.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:p});const y=await this.client.core.crypto.generateSharedKey(b,p);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:y});const A=await this.client.core.relayer.subscribe(y,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:A}),await this.client.core.pairing.activate({topic:t})}else if(zi(i)){await this.client.proposal.delete(a,$t("USER_DISCONNECTED"));const f=St("session_connect");if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners, 954`);this.events.emit(St("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{const{id:n,params:a}=i;try{this.isValidSessionSettleRequest(a);const{relay:f,controller:u,expiry:b,namespaces:p,sessionProperties:y,sessionConfig:A}=i.params,R=cn(rr(rr({topic:t,relay:f,expiry:b,namespaces:p,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:u.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:u.publicKey,metadata:u.metadata}},y&&{sessionProperties:y}),A&&{sessionConfig:A}),{transportType:Kt.relay}),O=St("session_connect");if(this.events.listenerCount(O)===0)throw new Error(`emitting ${O} without any listeners 997`);this.events.emit(St("session_connect"),{session:R}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(f){await this.sendError({id:n,topic:t,error:f}),this.client.logger.error(f)}},this.onSessionSettleResponse=async(t,i)=>{const{id:n}=i;In(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(St("session_approve",n),{})):zi(i)&&(await this.client.session.delete(t,$t("USER_DISCONNECTED")),this.events.emit(St("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:n,id:a}=i;try{const f=`${t}_session_update`,u=Qo.get(f);if(u&&this.isRequestOutOfSync(u,a)){this.client.logger.info(`Discarding out of sync request - ${a}`),this.sendError({id:a,topic:t,error:$t("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(rr({topic:t},n));try{Qo.set(f,a),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:a,topic:t,result:!0,throwOnFailedPublish:!0})}catch(b){throw Qo.delete(f),b}this.client.events.emit("session_update",{id:a,topic:t,params:n})}catch(f){await this.sendError({id:a,topic:t,error:f}),this.client.logger.error(f)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{const{id:n}=i,a=St("session_update",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);In(i)?this.events.emit(St("session_update",n),{}):zi(i)&&this.events.emit(St("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,vr(Ga)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(a){await this.sendError({id:n,topic:t,error:a}),this.client.logger.error(a)}},this.onSessionExtendResponse=(t,i)=>{const{id:n}=i,a=St("session_extend",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);In(i)?this.events.emit(St("session_extend",n),{}):zi(i)&&this.events.emit(St("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{const{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(a){await this.sendError({id:n,topic:t,error:a}),this.client.logger.error(a)}},this.onSessionPingResponse=(t,i)=>{const{id:n}=i,a=St("session_ping",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);setTimeout(()=>{In(i)?this.events.emit(St("session_ping",n),{}):zi(i)&&this.events.emit(St("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(a=>{this.client.core.relayer.once(Gr.publish,async()=>{a(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:$t("USER_DISCONNECTED")})]).catch(a=>this.client.logger.error(a))}catch(a){this.client.logger.error(a)}},this.onSessionRequest=async t=>{var i,n,a;const{topic:f,payload:u,attestation:b,encryptedId:p,transportType:y}=t,{id:A,params:R}=u;try{await this.isValidRequest(rr({topic:f},R));const O=this.client.session.get(f),N=await this.getVerifyContext({attestationId:b,hash:cs(JSON.stringify(qs("wc_sessionRequest",R,A))),encryptedId:p,metadata:O.peer.metadata,transportType:y}),K={id:A,topic:f,params:R,verifyContext:N};await this.setPendingSessionRequest(K),y===Kt.link_mode&&(i=O.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=O.peer.metadata.redirect)==null?void 0:n.universal),(a=this.client.signConfig)!=null&&a.disableRequestQueue?this.emitSessionRequest(K):(this.addSessionRequestToSessionRequestQueue(K),this.processSessionRequestQueue())}catch(O){await this.sendError({id:A,topic:f,error:O}),this.client.logger.error(O)}},this.onSessionRequestResponse=(t,i)=>{const{id:n}=i,a=St("session_request",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);In(i)?this.events.emit(St("session_request",n),{result:i.result}):zi(i)&&this.events.emit(St("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{const{id:n,params:a}=i;try{const f=`${t}_session_event_${a.event.name}`,u=Qo.get(f);if(u&&this.isRequestOutOfSync(u,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(rr({topic:t},a)),this.client.events.emit("session_event",{id:n,topic:t,params:a}),Qo.set(f,n)}catch(f){await this.sendError({id:n,topic:t,error:f}),this.client.logger.error(f)}},this.onSessionAuthenticateResponse=(t,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),In(i)?this.events.emit(St("session_request",n),{result:i.result}):zi(i)&&this.events.emit(St("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;const{topic:n,payload:a,attestation:f,encryptedId:u,transportType:b}=t;try{const{requester:p,authPayload:y,expiryTimestamp:A}=a.params,R=await this.getVerifyContext({attestationId:f,hash:cs(JSON.stringify(a)),encryptedId:u,metadata:p.metadata,transportType:b}),O={requester:p,pairingTopic:n,id:a.id,authPayload:y,verifyContext:R,expiryTimestamp:A};await this.setAuthRequest(a.id,{request:O,pairingTopic:n,transportType:b}),b===Kt.link_mode&&(i=p.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(p.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:a.params,id:a.id,verifyContext:R})}catch(p){this.client.logger.error(p);const y=a.params.requester.publicKey,A=await this.client.core.crypto.generateKeyPair(),R=this.getAppLinkIfEnabled(a.params.requester.metadata,b),O={type:ls,receiverPublicKey:y,senderPublicKey:A};await this.sendError({id:a.id,topic:n,error:p,encodeOpts:O,rpcOpts:wr.wc_sessionAuthenticate.autoReject,appLink:R})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=An.idle,this.processSessionRequestQueue()},xe.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(a=>a.topic===t&&a.request.method==="wc_sessionRequest").forEach(a=>{const f=a.request.id,u=St("session_request",f);if(this.events.listenerCount(u)===0)throw new Error(`emitting ${u} without any listeners`);this.events.emit(St("session_request",a.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===An.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=An.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:qs("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!oi(t)){const{message:b}=Ae("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(b)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:a,sessionProperties:f,relays:u}=t;if(fi(i)||await this.isValidPairingTopic(i),!rI(u)){const{message:b}=Ae("MISSING_OR_INVALID",`connect() relays: ${u}`);throw new Error(b)}!fi(n)&&bc(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!fi(a)&&bc(a)!==0&&this.validateNamespaces(a,"optionalNamespaces"),fi(f)||this.validateSessionProps(f,"sessionProperties")},this.validateNamespaces=(t,i)=>{const n=tI(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!oi(t))throw new Error(Ae("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:n,relayProtocol:a,sessionProperties:f}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const u=this.client.proposal.get(i),b=Tl(n,"approve()");if(b)throw new Error(b.message);const p=xg(u.requiredNamespaces,n,"approve()");if(p)throw new Error(p.message);if(!fr(a,!0)){const{message:y}=Ae("MISSING_OR_INVALID",`approve() relayProtocol: ${a}`);throw new Error(y)}fi(f)||this.validateSessionProps(f,"sessionProperties")},this.isValidReject=async t=>{if(!oi(t)){const{message:a}=Ae("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(a)}const{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!nI(n)){const{message:a}=Ae("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidSessionSettleRequest=t=>{if(!oi(t)){const{message:p}=Ae("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(p)}const{relay:i,controller:n,namespaces:a,expiry:f}=t;if(!Im(i)){const{message:p}=Ae("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(p)}const u=JS(n,"onSessionSettleRequest()");if(u)throw new Error(u.message);const b=Tl(a,"onSessionSettleRequest()");if(b)throw new Error(b.message);if(Os(f)){const{message:p}=Ae("EXPIRED","onSessionSettleRequest()");throw new Error(p)}},this.isValidUpdate=async t=>{if(!oi(t)){const{message:b}=Ae("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(b)}const{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const a=this.client.session.get(i),f=Tl(n,"update()");if(f)throw new Error(f.message);const u=xg(a.requiredNamespaces,n,"update()");if(u)throw new Error(u.message)},this.isValidExtend=async t=>{if(!oi(t)){const{message:n}=Ae("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!oi(t)){const{message:b}=Ae("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(b)}const{topic:i,request:n,chainId:a,expiry:f}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:u}=this.client.session.get(i);if(!Eg(u,a)){const{message:b}=Ae("MISSING_OR_INVALID",`request() chainId: ${a}`);throw new Error(b)}if(!sI(n)){const{message:b}=Ae("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(b)}if(!cI(u,a,n.method)){const{message:b}=Ae("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(b)}if(f&&!lI(f,zl)){const{message:b}=Ae("MISSING_OR_INVALID",`request() expiry: ${f}. Expiry must be a number (in seconds) between ${zl.min} and ${zl.max}`);throw new Error(b)}},this.isValidRespond=async t=>{var i;if(!oi(t)){const{message:f}=Ae("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(f)}const{topic:n,response:a}=t;try{await this.isValidSessionTopic(n)}catch(f){throw(i=t==null?void 0:t.response)!=null&&i.id&&this.cleanupAfterResponse(t),f}if(!aI(a)){const{message:f}=Ae("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(a)}`);throw new Error(f)}},this.isValidPing=async t=>{if(!oi(t)){const{message:n}=Ae("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!oi(t)){const{message:u}=Ae("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(u)}const{topic:i,event:n,chainId:a}=t;await this.isValidSessionTopic(i);const{namespaces:f}=this.client.session.get(i);if(!Eg(f,a)){const{message:u}=Ae("MISSING_OR_INVALID",`emit() chainId: ${a}`);throw new Error(u)}if(!oI(n)){const{message:u}=Ae("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(u)}if(!fI(f,a,n.name)){const{message:u}=Ae("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(u)}},this.isValidDisconnect=async t=>{if(!oi(t)){const{message:n}=Ae("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{const{chains:i,uri:n,domain:a,nonce:f}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!fr(n,!1))throw new Error("uri is required parameter");if(!fr(a,!1))throw new Error("domain is required parameter");if(!fr(f,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(b=>ac(b).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:u}=ac(i[0]);if(u!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:i,hash:n,encryptedId:a,metadata:f,transportType:u}=t,b={verified:{verifyUrl:f.verifyUrl||uc,validation:"UNKNOWN",origin:f.url||""}};try{if(u===Kt.link_mode){const y=this.getAppLinkIfEnabled(f,u);return b.verified.validation=y&&new URL(y).origin===new URL(f.url).origin?"VALID":"INVALID",b}const p=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:a,verifyUrl:f.verifyUrl});p&&(b.verified.origin=p.origin,b.verified.isScam=p.isScam,b.verified.validation=p.origin===new URL(f.url).origin?"VALID":"INVALID")}catch(p){this.client.logger.warn(p)}return this.client.logger.debug(`Verify context: ${JSON.stringify(b)}`),b},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!fr(n,!1)){const{message:a}=Ae("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(a)}})},this.getPendingAuthRequest=t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const a=this.recentlyDeletedLimit/2;for(const f of this.recentlyDeletedMap.keys()){if(n++>=a)break;this.recentlyDeletedMap.delete(f)}}},this.checkRecentlyDeleted=t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:n}=Ae("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,a,f,u,b,p,y,A,R;return!t||i!==Kt.link_mode?!1:((a=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:a.linkMode)===!0&&((u=(f=this.client.metadata)==null?void 0:f.redirect)==null?void 0:u.universal)!==void 0&&((p=(b=this.client.metadata)==null?void 0:b.redirect)==null?void 0:p.universal)!==""&&((y=t==null?void 0:t.redirect)==null?void 0:y.universal)!==void 0&&((A=t==null?void 0:t.redirect)==null?void 0:A.universal)!==""&&((R=t==null?void 0:t.redirect)==null?void 0:R.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(globalThis==null?void 0:globalThis.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t==null?void 0:t.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=B1(t,"topic")||"",n=decodeURIComponent(B1(t,"wc_ev")||""),a=this.client.session.keys.includes(i);a&&this.client.session.update(i,{transportType:Kt.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:a})},this.registerLinkModeListeners=async()=>{var t;if(jd()||vo()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=globalThis==null?void 0:globalThis.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=Ae("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Gr.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:n,transportType:a}=e,{publicKey:f}=this.client.auth.authKeys.keys.includes(sh)?this.client.auth.authKeys.get(sh):{responseTopic:void 0,publicKey:void 0},u=await this.client.core.crypto.decode(t,i,{receiverPublicKey:f,encoding:a===Kt.link_mode?Yo:Ls});try{Zd(u)?(this.client.core.history.set(t,u),this.onRelayEventRequest({topic:t,payload:u,attestation:n,transportType:a,encryptedId:cs(i)})):Gh(u)?(await this.client.core.history.resolve(u),await this.onRelayEventResponse({topic:t,payload:u,transportType:a}),this.client.core.history.delete(t,u.id)):this.onRelayEventUnknownPayload({topic:t,payload:u,transportType:a})}catch(b){this.client.logger.error(b)}}registerExpirerEvents(){this.client.core.expirer.on(Ui.expired,async e=>{const{topic:t,id:i}=Lb(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Ae("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Ae("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(oa.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(oa.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!fr(e,!1)){const{message:t}=Ae("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=Ae("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Os(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=Ae("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!fr(e,!1)){const{message:t}=Ae("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=Ae("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Os(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=Ae("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=Ae("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(fr(e,!1)){const{message:t}=Ae("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=Ae("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!iI(e)){const{message:t}=Ae("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=Ae("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Os(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=Ae("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class BN extends xa{constructor(e,t){super(e,t,_N,r0),this.core=e,this.logger=t}}class UN extends xa{constructor(e,t){super(e,t,AN,r0),this.core=e,this.logger=t}}class $N extends xa{constructor(e,t){super(e,t,xN,r0,i=>i.id),this.core=e,this.logger=t}}class zN extends xa{constructor(e,t){super(e,t,PN,Jh,()=>sh),this.core=e,this.logger=t}}class jN extends xa{constructor(e,t){super(e,t,ON,Jh),this.core=e,this.logger=t}}class kN extends xa{constructor(e,t){super(e,t,RN,Jh,i=>i.id),this.core=e,this.logger=t}}class FN{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new zN(this.core,this.logger),this.pairingTopics=new jN(this.core,this.logger),this.requests=new kN(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class i0 extends qM{constructor(e){super(e),this.protocol=r2,this.version=i2,this.name=$l.name,this.events=new Fi.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(a){throw this.logger.error(a.message),a}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=(e==null?void 0:e.name)||$l.name,this.metadata=(e==null?void 0:e.metadata)||Rb(),this.signConfig=e==null?void 0:e.signConfig;const t=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Nc(Hh({level:(e==null?void 0:e.logger)||$l.logger}));this.core=(e==null?void 0:e.core)||new wN(e),this.logger=Yr(t,this.name),this.session=new UN(this.core,this.logger),this.proposal=new BN(this.core,this.logger),this.pendingRequest=new $N(this.core,this.logger),this.engine=new qN(this),this.auth=new FN(this.core,this.logger)}static async init(e){const t=new i0(e);return await t.initialize(),t}get context(){return di(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var _d={exports:{}};(function(r,e){var t=typeof self<"u"?self:Dv,i=function(){function a(){this.fetch=!1,this.DOMException=t.DOMException}return a.prototype=t,new a}();(function(a){(function(f){var u={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function b(h){return h&&DataView.prototype.isPrototypeOf(h)}if(u.arrayBuffer)var p=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],y=ArrayBuffer.isView||function(h){return h&&p.indexOf(Object.prototype.toString.call(h))>-1};function A(h){if(typeof h!="string"&&(h=String(h)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(h))throw new TypeError("Invalid character in header field name");return h.toLowerCase()}function R(h){return typeof h!="string"&&(h=String(h)),h}function O(h){var v={next:function(){var _=h.shift();return{done:_===void 0,value:_}}};return u.iterable&&(v[Symbol.iterator]=function(){return v}),v}function N(h){this.map={},h instanceof N?h.forEach(function(v,_){this.append(_,v)},this):Array.isArray(h)?h.forEach(function(v){this.append(v[0],v[1])},this):h&&Object.getOwnPropertyNames(h).forEach(function(v){this.append(v,h[v])},this)}N.prototype.append=function(h,v){h=A(h),v=R(v);var _=this.map[h];this.map[h]=_?_+", "+v:v},N.prototype.delete=function(h){delete this.map[A(h)]},N.prototype.get=function(h){return h=A(h),this.has(h)?this.map[h]:null},N.prototype.has=function(h){return this.map.hasOwnProperty(A(h))},N.prototype.set=function(h,v){this.map[A(h)]=R(v)},N.prototype.forEach=function(h,v){for(var _ in this.map)this.map.hasOwnProperty(_)&&h.call(v,this.map[_],_,this)},N.prototype.keys=function(){var h=[];return this.forEach(function(v,_){h.push(_)}),O(h)},N.prototype.values=function(){var h=[];return this.forEach(function(v){h.push(v)}),O(h)},N.prototype.entries=function(){var h=[];return this.forEach(function(v,_){h.push([_,v])}),O(h)},u.iterable&&(N.prototype[Symbol.iterator]=N.prototype.entries);function K(h){if(h.bodyUsed)return Promise.reject(new TypeError("Already read"));h.bodyUsed=!0}function W(h){return new Promise(function(v,_){h.onload=function(){v(h.result)},h.onerror=function(){_(h.error)}})}function Q(h){var v=new FileReader,_=W(v);return v.readAsArrayBuffer(h),_}function k(h){var v=new FileReader,_=W(v);return v.readAsText(h),_}function Y(h){for(var v=new Uint8Array(h),_=new Array(v.length),I=0;I-1?v:h}function q(h,v){v=v||{};var _=v.body;if(h instanceof q){if(h.bodyUsed)throw new TypeError("Already read");this.url=h.url,this.credentials=h.credentials,v.headers||(this.headers=new N(h.headers)),this.method=h.method,this.mode=h.mode,this.signal=h.signal,!_&&h._bodyInit!=null&&(_=h._bodyInit,h.bodyUsed=!0)}else this.url=String(h);if(this.credentials=v.credentials||this.credentials||"same-origin",(v.headers||!this.headers)&&(this.headers=new N(v.headers)),this.method=x(v.method||this.method||"GET"),this.mode=v.mode||this.mode||null,this.signal=v.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&_)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(_)}q.prototype.clone=function(){return new q(this,{body:this._bodyInit})};function ae(h){var v=new FormData;return h.trim().split("&").forEach(function(_){if(_){var I=_.split("="),M=I.shift().replace(/\+/g," "),S=I.join("=").replace(/\+/g," ");v.append(decodeURIComponent(M),decodeURIComponent(S))}}),v}function le(h){var v=new N,_=h.replace(/\r?\n[\t ]+/g," ");return _.split(/\r?\n/).forEach(function(I){var M=I.split(":"),S=M.shift().trim();if(S){var d=M.join(":").trim();v.append(S,d)}}),v}F.call(q.prototype);function L(h,v){v||(v={}),this.type="default",this.status=v.status===void 0?200:v.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in v?v.statusText:"OK",this.headers=new N(v.headers),this.url=v.url||"",this._initBody(h)}F.call(L.prototype),L.prototype.clone=function(){return new L(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new N(this.headers),url:this.url})},L.error=function(){var h=new L(null,{status:0,statusText:""});return h.type="error",h};var m=[301,302,303,307,308];L.redirect=function(h,v){if(m.indexOf(v)===-1)throw new RangeError("Invalid status code");return new L(null,{status:v,headers:{location:h}})},f.DOMException=a.DOMException;try{new f.DOMException}catch{f.DOMException=function(v,_){this.message=v,this.name=_;var I=Error(v);this.stack=I.stack},f.DOMException.prototype=Object.create(Error.prototype),f.DOMException.prototype.constructor=f.DOMException}function c(h,v){return new Promise(function(_,I){var M=new q(h,v);if(M.signal&&M.signal.aborted)return I(new f.DOMException("Aborted","AbortError"));var S=new XMLHttpRequest;function d(){S.abort()}S.onload=function(){var g={status:S.status,statusText:S.statusText,headers:le(S.getAllResponseHeaders()||"")};g.url="responseURL"in S?S.responseURL:g.headers.get("X-Request-URL");var C="response"in S?S.response:S.responseText;_(new L(C,g))},S.onerror=function(){I(new TypeError("Network request failed"))},S.ontimeout=function(){I(new TypeError("Network request failed"))},S.onabort=function(){I(new f.DOMException("Aborted","AbortError"))},S.open(M.method,M.url,!0),M.credentials==="include"?S.withCredentials=!0:M.credentials==="omit"&&(S.withCredentials=!1),"responseType"in S&&u.blob&&(S.responseType="blob"),M.headers.forEach(function(g,C){S.setRequestHeader(C,g)}),M.signal&&(M.signal.addEventListener("abort",d),S.onreadystatechange=function(){S.readyState===4&&M.signal.removeEventListener("abort",d)}),S.send(typeof M._bodyInit>"u"?null:M._bodyInit)})}return c.polyfill=!0,a.fetch||(a.fetch=c,a.Headers=N,a.Request=q,a.Response=L),f.Headers=N,f.Request=q,f.Response=L,f.fetch=c,Object.defineProperty(f,"__esModule",{value:!0}),f})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=i;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,r.exports=e})(_d,_d.exports);var HN=_d.exports;const lv=Sd(HN);var KN=Object.defineProperty,VN=Object.defineProperties,GN=Object.getOwnPropertyDescriptors,dv=Object.getOwnPropertySymbols,WN=Object.prototype.hasOwnProperty,JN=Object.prototype.propertyIsEnumerable,pv=(r,e,t)=>e in r?KN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,gv=(r,e)=>{for(var t in e||(e={}))WN.call(e,t)&&pv(r,t,e[t]);if(dv)for(var t of dv(e))JN.call(e,t)&&pv(r,t,e[t]);return r},vv=(r,e)=>VN(r,GN(e));const YN={Accept:"application/json","Content-Type":"application/json"},QN="POST",bv={headers:YN,method:QN},mv=10;class Vn{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new Fi.EventEmitter,this.isAvailable=!1,this.registering=!1,!$g(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=t}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const t=gs(e),i=await(await lv(this.url,vv(gv({},bv),{body:t}))).json();this.onPayload({data:i})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!$g(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),n(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return n(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=gs({id:1,jsonrpc:"2.0",method:"test",params:[]});await lv(e,vv(gv({},bv),{body:t}))}this.onOpen()}catch(t){const i=this.parseError(t);throw this.events.emit("register_error",i),this.onClose(),i}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?ga(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),a=Vh(e,n);this.events.emit("payload",a)}parseError(e,t=this.url){return Lm(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>mv&&this.events.setMaxListeners(mv)}}const yv="error",XN="wss://relay.walletconnect.org",ZN="wc",eT="universal_provider",wv=`${ZN}@2:${eT}:`,a2="https://rpc.walletconnect.org/v1/",Ya="generic",tT=`${a2}bundler`,gn={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var rc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},Ad={exports:{}};/** +* @license +* Lodash +* Copyright OpenJS Foundation and other contributors +* Released under MIT license +* Based on Underscore.js 1.8.3 +* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +*/(function(r,e){(function(){var t,i="4.17.21",n=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",f="Expected a function",u="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",p=500,y="__lodash_placeholder__",A=1,R=2,O=4,N=1,K=2,W=1,Q=2,k=4,Y=8,$=16,F=32,G=64,x=128,q=256,ae=512,le=30,L="...",m=800,c=16,h=1,v=2,_=3,I=1/0,M=9007199254740991,S=17976931348623157e292,d=NaN,g=4294967295,C=g-1,Z=g>>>1,se=[["ary",x],["bind",W],["bindKey",Q],["curry",Y],["curryRight",$],["flip",ae],["partial",F],["partialRight",G],["rearg",q]],P="[object Arguments]",ee="[object Array]",B="[object AsyncFunction]",j="[object Boolean]",H="[object Date]",w="[object DOMException]",z="[object Error]",ne="[object Function]",ce="[object GeneratorFunction]",he="[object Map]",ye="[object Number]",we="[object Null]",Te="[object Object]",Qe="[object Promise]",Oe="[object Proxy]",Ce="[object RegExp]",Ie="[object Set]",me="[object String]",Re="[object Symbol]",De="[object Undefined]",ve="[object WeakMap]",Ne="[object WeakSet]",Se="[object ArrayBuffer]",be="[object DataView]",Ue="[object Float32Array]",Me="[object Float64Array]",_e="[object Int8Array]",He="[object Int16Array]",Ve="[object Int32Array]",Ee="[object Uint8Array]",Ke="[object Uint8ClampedArray]",ut="[object Uint16Array]",Ge="[object Uint32Array]",_t=/\b__p \+= '';/g,lt=/\b(__p \+=) '' \+/g,Je=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Et=/&(?:amp|lt|gt|quot|#39);/g,It=/[&<>"']/g,Le=RegExp(Et.source),Xe=RegExp(It.source),tt=/<%-([\s\S]+?)%>/g,qe=/<%([\s\S]+?)%>/g,et=/<%=([\s\S]+?)%>/g,Ze=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ze=/^\w*$/,ft=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rt=/[\\^$.*+?()[\]{}|]/g,je=RegExp(rt.source),it=/^\s+/,st=/\s/,Be=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ye=/\{\n\/\* \[wrapped with (.+)\] \*/,ht=/,? & /,ke=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ct=/[()=,{}\[\]\/\s]/,Dt=/\\(\\)?/g,at=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,bt=/\w*$/,Tr=/^[-+]0x[0-9a-f]+$/i,Cr=/^0b[01]+$/i,Dr=/^\[object .+?Constructor\]$/,Lr=/^0o[0-7]+$/i,qr=/^(?:0|[1-9]\d*)$/,er=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Qr=/($^)/,Vi=/['\n\r\u2028\u2029\\]/g,Xr="\\ud800-\\udfff",Gi="\\u0300-\\u036f",Wi="\\ufe20-\\ufe2f",Zr="\\u20d0-\\u20ff",Si=Gi+Wi+Zr,Ii="\\u2700-\\u27bf",lr="a-z\\xdf-\\xf6\\xf8-\\xff",Ji="\\xac\\xb1\\xd7\\xf7",Yi="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Qi="\\u2000-\\u206f",js=" \\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",Dc="A-Z\\xc0-\\xd6\\xd8-\\xde",Lc="\\ufe0e\\ufe0f",ks=Ji+Yi+Qi+js,xo="['’]",Fs="["+Xr+"]",So="["+ks+"]",Hs="["+Si+"]",qc="\\d+",Yh="["+Ii+"]",Bc="["+lr+"]",Uc="[^"+Xr+ks+qc+Ii+lr+Dc+"]",Ma="\\ud83c[\\udffb-\\udfff]",Qh="(?:"+Hs+"|"+Ma+")",$c="[^"+Xr+"]",Pa="(?:\\ud83c[\\udde6-\\uddff]){2}",bs="[\\ud800-\\udbff][\\udc00-\\udfff]",pi="["+Dc+"]",zc="\\u200d",jc="(?:"+Bc+"|"+Uc+")",vn="(?:"+pi+"|"+Uc+")",kc="(?:"+xo+"(?:d|ll|m|re|s|t|ve))?",Fc="(?:"+xo+"(?:D|LL|M|RE|S|T|VE))?",Hc=Qh+"?",Kc="["+Lc+"]?",Xh="(?:"+zc+"(?:"+[$c,Pa,bs].join("|")+")"+Kc+Hc+")*",Gn="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Vc="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Gc=Kc+Hc+Xh,Oa="(?:"+[Yh,Pa,bs].join("|")+")"+Gc,Zh="(?:"+[$c+Hs+"?",Hs,Pa,bs,Fs].join("|")+")",Io=RegExp(xo,"g"),eu=RegExp(Hs,"g"),Ra=RegExp(Ma+"(?="+Ma+")|"+Zh+Gc,"g"),Wc=RegExp([pi+"?"+Bc+"+"+kc+"(?="+[So,pi,"$"].join("|")+")",vn+"+"+Fc+"(?="+[So,pi+jc,"$"].join("|")+")",pi+"?"+jc+"+"+kc,pi+"+"+Fc,Vc,Gn,qc,Oa].join("|"),"g"),Jc=RegExp("["+zc+Xr+Si+Lc+"]"),Ks=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Yc=["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"],tu=-1,jt={};jt[Ue]=jt[Me]=jt[_e]=jt[He]=jt[Ve]=jt[Ee]=jt[Ke]=jt[ut]=jt[Ge]=!0,jt[P]=jt[ee]=jt[Se]=jt[j]=jt[be]=jt[H]=jt[z]=jt[ne]=jt[he]=jt[ye]=jt[Te]=jt[Ce]=jt[Ie]=jt[me]=jt[ve]=!1;var zt={};zt[P]=zt[ee]=zt[Se]=zt[be]=zt[j]=zt[H]=zt[Ue]=zt[Me]=zt[_e]=zt[He]=zt[Ve]=zt[he]=zt[ye]=zt[Te]=zt[Ce]=zt[Ie]=zt[me]=zt[Re]=zt[Ee]=zt[Ke]=zt[ut]=zt[Ge]=!0,zt[z]=zt[ne]=zt[ve]=!1;var V={À:"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"},te={"&":"&","<":"<",">":">",'"':""","'":"'"},pe={"&":"&","<":"<",">":">",""":'"',"'":"'"},$e={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kt=parseFloat,pt=parseInt,Jt=typeof rc=="object"&&rc&&rc.Object===Object&&rc,hr=typeof self=="object"&&self&&self.Object===Object&&self,Nt=Jt||hr||Function("return this")(),Ft=e&&!e.nodeType&&e,sr=Ft&&!0&&r&&!r.nodeType&&r,ei=sr&&sr.exports===Ft,ur=ei&&Jt.process,Yt=function(){try{var re=sr&&sr.require&&sr.require("util").types;return re||ur&&ur.binding&&ur.binding("util")}catch{}}(),kr=Yt&&Yt.isArrayBuffer,Xi=Yt&&Yt.isDate,Mi=Yt&&Yt.isMap,bn=Yt&&Yt.isRegExp,Mo=Yt&&Yt.isSet,Vs=Yt&&Yt.isTypedArray;function br(re,fe,oe){switch(oe.length){case 0:return re.call(fe);case 1:return re.call(fe,oe[0]);case 2:return re.call(fe,oe[0],oe[1]);case 3:return re.call(fe,oe[0],oe[1],oe[2])}return re.apply(fe,oe)}function f2(re,fe,oe,Fe){for(var dt=-1,Lt=re==null?0:re.length;++dt-1}function ru(re,fe,oe){for(var Fe=-1,dt=re==null?0:re.length;++Fe-1;);return oe}function d0(re,fe){for(var oe=re.length;oe--&&Na(fe,re[oe],0)>-1;);return oe}function m2(re,fe){for(var oe=re.length,Fe=0;oe--;)re[oe]===fe&&++Fe;return Fe}var y2=au(V),w2=au(te);function _2(re){return"\\"+$e[re]}function A2(re,fe){return re==null?t:re[fe]}function Ta(re){return Jc.test(re)}function E2(re){return Ks.test(re)}function x2(re){for(var fe,oe=[];!(fe=re.next()).done;)oe.push(fe.value);return oe}function hu(re){var fe=-1,oe=Array(re.size);return re.forEach(function(Fe,dt){oe[++fe]=[dt,Fe]}),oe}function p0(re,fe){return function(oe){return re(fe(oe))}}function ws(re,fe){for(var oe=-1,Fe=re.length,dt=0,Lt=[];++oe-1}function uy(s,o){var l=this.__data__,E=gf(l,s);return E<0?(++this.size,l.push([s,o])):l[E][1]=o,this}Wn.prototype.clear=oy,Wn.prototype.delete=cy,Wn.prototype.get=fy,Wn.prototype.has=hy,Wn.prototype.set=uy;function Jn(s){var o=-1,l=s==null?0:s.length;for(this.clear();++o=o?s:o)),s}function Ni(s,o,l,E,T,U){var J,X=o&A,ie=o&R,ue=o&O;if(l&&(J=T?l(s,E,T,U):l(s)),J!==t)return J;if(!Zt(s))return s;var de=gt(s);if(de){if(J=g6(s),!X)return ti(s,J)}else{var ge=Ur(s),Pe=ge==ne||ge==ce;if(Is(s))return Y0(s,X);if(ge==Te||ge==P||Pe&&!T){if(J=ie||Pe?{}:gp(s),!X)return ie?n6(s,My(J,s)):i6(s,I0(J,s))}else{if(!zt[ge])return T?s:{};J=v6(s,ge,X)}}U||(U=new en);var We=U.get(s);if(We)return We;U.set(s,J),Hp(s)?s.forEach(function(ct){J.add(Ni(ct,o,l,ct,s,U))}):kp(s)&&s.forEach(function(ct,xt){J.set(xt,Ni(ct,o,l,xt,s,U))});var ot=ue?ie?qu:Lu:ie?ii:mr,wt=de?t:ot(s);return Pi(wt||s,function(ct,xt){wt&&(xt=ct,ct=s[xt]),Do(J,xt,Ni(ct,o,l,xt,s,U))}),J}function Py(s){var o=mr(s);return function(l){return M0(l,s,o)}}function M0(s,o,l){var E=l.length;if(s==null)return!E;for(s=Ht(s);E--;){var T=l[E],U=o[T],J=s[T];if(J===t&&!(T in s)||!U(J))return!1}return!0}function P0(s,o,l){if(typeof s!="function")throw new Oi(f);return jo(function(){s.apply(t,l)},o)}function Lo(s,o,l,E){var T=-1,U=Qc,J=!0,X=s.length,ie=[],ue=o.length;if(!X)return ie;l&&(o=Xt(o,gi(l))),E?(U=ru,J=!1):o.length>=n&&(U=Po,J=!1,o=new Js(o));e:for(;++TT?0:T+l),E=E===t||E>T?T:yt(E),E<0&&(E+=T),E=l>E?0:Vp(E);l0&&l(X)?o>1?Mr(X,o-1,l,E,T):ys(T,X):E||(T[T.length]=X)}return T}var bu=rp(),N0=rp(!0);function mn(s,o){return s&&bu(s,o,mr)}function mu(s,o){return s&&N0(s,o,mr)}function bf(s,o){return ms(o,function(l){return es(s[l])})}function Qs(s,o){o=xs(o,s);for(var l=0,E=o.length;s!=null&&lo}function Ny(s,o){return s!=null&&Ut.call(s,o)}function Ty(s,o){return s!=null&&o in Ht(s)}function Cy(s,o,l){return s>=Br(o,l)&&s=120&&de.length>=120)?new Js(J&&de):t}de=s[0];var ge=-1,Pe=X[0];e:for(;++ge-1;)X!==s&&cf.call(X,ie,1),cf.call(s,ie,1);return s}function k0(s,o){for(var l=s?o.length:0,E=l-1;l--;){var T=o[l];if(l==E||T!==U){var U=T;Zn(T)?cf.call(s,T,1):Pu(s,T)}}return s}function Su(s,o){return s+uf(A0()*(o-s+1))}function Vy(s,o,l,E){for(var T=-1,U=pr(hf((o-s)/(l||1)),0),J=oe(U);U--;)J[E?U:++T]=s,s+=l;return J}function Iu(s,o){var l="";if(!s||o<1||o>M)return l;do o%2&&(l+=s),o=uf(o/2),o&&(s+=s);while(o);return l}function At(s,o){return Fu(mp(s,o,ni),s+"")}function Gy(s){return S0(Fa(s))}function Wy(s,o){var l=Fa(s);return Pf(l,Ys(o,0,l.length))}function Uo(s,o,l,E){if(!Zt(s))return s;o=xs(o,s);for(var T=-1,U=o.length,J=U-1,X=s;X!=null&&++TT?0:T+o),l=l>T?T:l,l<0&&(l+=T),T=o>l?0:l-o>>>0,o>>>=0;for(var U=oe(T);++E>>1,J=s[U];J!==null&&!bi(J)&&(l?J<=o:J=n){var ue=o?null:c6(s);if(ue)return Zc(ue);J=!1,T=Po,ie=new Js}else ie=o?[]:X;e:for(;++E=E?s:Ti(s,o,l)}var J0=$2||function(s){return Nt.clearTimeout(s)};function Y0(s,o){if(o)return s.slice();var l=s.length,E=b0?b0(l):new s.constructor(l);return s.copy(E),E}function Tu(s){var o=new s.constructor(s.byteLength);return new af(o).set(new af(s)),o}function Zy(s,o){var l=o?Tu(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.byteLength)}function e6(s){var o=new s.constructor(s.source,bt.exec(s));return o.lastIndex=s.lastIndex,o}function t6(s){return Co?Ht(Co.call(s)):{}}function Q0(s,o){var l=o?Tu(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.length)}function X0(s,o){if(s!==o){var l=s!==t,E=s===null,T=s===s,U=bi(s),J=o!==t,X=o===null,ie=o===o,ue=bi(o);if(!X&&!ue&&!U&&s>o||U&&J&&ie&&!X&&!ue||E&&J&&ie||!l&&ie||!T)return 1;if(!E&&!U&&!ue&&s=X)return ie;var ue=l[E];return ie*(ue=="desc"?-1:1)}}return s.index-o.index}function Z0(s,o,l,E){for(var T=-1,U=s.length,J=l.length,X=-1,ie=o.length,ue=pr(U-J,0),de=oe(ie+ue),ge=!E;++X1?l[T-1]:t,J=T>2?l[2]:t;for(U=s.length>3&&typeof U=="function"?(T--,U):t,J&&Hr(l[0],l[1],J)&&(U=T<3?t:U,T=1),o=Ht(o);++E-1?T[U?o[J]:J]:t}}function sp(s){return Xn(function(o){var l=o.length,E=l,T=Ri.prototype.thru;for(s&&o.reverse();E--;){var U=o[E];if(typeof U!="function")throw new Oi(f);if(T&&!J&&If(U)=="wrapper")var J=new Ri([],!0)}for(E=J?E:l;++E1&&Tt.reverse(),de&&ieX))return!1;var ue=U.get(s),de=U.get(o);if(ue&&de)return ue==o&&de==s;var ge=-1,Pe=!0,We=l&K?new Js:t;for(U.set(s,o),U.set(o,s);++ge1?"& ":"")+o[E],o=o.join(l>2?", ":" "),s.replace(Be,`{ +/* [wrapped with `+o+`] */ +`)}function m6(s){return gt(s)||ea(s)||!!(w0&&s&&s[w0])}function Zn(s,o){var l=typeof s;return o=o??M,!!o&&(l=="number"||l!="symbol"&&qr.test(s))&&s>-1&&s%1==0&&s0){if(++o>=m)return arguments[0]}else o=0;return s.apply(t,arguments)}}function Pf(s,o){var l=-1,E=s.length,T=E-1;for(o=o===t?E:o;++l1?s[o-1]:t;return l=typeof l=="function"?(s.pop(),l):t,Rp(s,l)});function Np(s){var o=D(s);return o.__chain__=!0,o}function O3(s,o){return o(s),s}function Of(s,o){return o(s)}var R3=Xn(function(s){var o=s.length,l=o?s[0]:0,E=this.__wrapped__,T=function(U){return vu(U,s)};return o>1||this.__actions__.length||!(E instanceof Mt)||!Zn(l)?this.thru(T):(E=E.slice(l,+l+(o?1:0)),E.__actions__.push({func:Of,args:[T],thisArg:t}),new Ri(E,this.__chain__).thru(function(U){return o&&!U.length&&U.push(t),U}))});function N3(){return Np(this)}function T3(){return new Ri(this.value(),this.__chain__)}function C3(){this.__values__===t&&(this.__values__=Kp(this.value()));var s=this.__index__>=this.__values__.length,o=s?t:this.__values__[this.__index__++];return{done:s,value:o}}function D3(){return this}function L3(s){for(var o,l=this;l instanceof pf;){var E=xp(l);E.__index__=0,E.__values__=t,o?T.__wrapped__=E:o=E;var T=E;l=l.__wrapped__}return T.__wrapped__=s,o}function q3(){var s=this.__wrapped__;if(s instanceof Mt){var o=s;return this.__actions__.length&&(o=new Mt(this)),o=o.reverse(),o.__actions__.push({func:Of,args:[Hu],thisArg:t}),new Ri(o,this.__chain__)}return this.thru(Hu)}function B3(){return G0(this.__wrapped__,this.__actions__)}var U3=_f(function(s,o,l){Ut.call(s,l)?++s[l]:Yn(s,l,1)});function $3(s,o,l){var E=gt(s)?a0:Oy;return l&&Hr(s,o,l)&&(o=t),E(s,nt(o,3))}function z3(s,o){var l=gt(s)?ms:R0;return l(s,nt(o,3))}var j3=np(Sp),k3=np(Ip);function F3(s,o){return Mr(Rf(s,o),1)}function H3(s,o){return Mr(Rf(s,o),I)}function K3(s,o,l){return l=l===t?1:yt(l),Mr(Rf(s,o),l)}function Tp(s,o){var l=gt(s)?Pi:As;return l(s,nt(o,3))}function Cp(s,o){var l=gt(s)?h2:O0;return l(s,nt(o,3))}var V3=_f(function(s,o,l){Ut.call(s,l)?s[l].push(o):Yn(s,l,[o])});function G3(s,o,l,E){s=ri(s)?s:Fa(s),l=l&&!E?yt(l):0;var T=s.length;return l<0&&(l=pr(T+l,0)),Lf(s)?l<=T&&s.indexOf(o,l)>-1:!!T&&Na(s,o,l)>-1}var W3=At(function(s,o,l){var E=-1,T=typeof o=="function",U=ri(s)?oe(s.length):[];return As(s,function(J){U[++E]=T?br(o,J,l):qo(J,o,l)}),U}),J3=_f(function(s,o,l){Yn(s,l,o)});function Rf(s,o){var l=gt(s)?Xt:q0;return l(s,nt(o,3))}function Y3(s,o,l,E){return s==null?[]:(gt(o)||(o=o==null?[]:[o]),l=E?t:l,gt(l)||(l=l==null?[]:[l]),z0(s,o,l))}var Q3=_f(function(s,o,l){s[l?0:1].push(o)},function(){return[[],[]]});function X3(s,o,l){var E=gt(s)?iu:h0,T=arguments.length<3;return E(s,nt(o,4),l,T,As)}function Z3(s,o,l){var E=gt(s)?u2:h0,T=arguments.length<3;return E(s,nt(o,4),l,T,O0)}function ew(s,o){var l=gt(s)?ms:R0;return l(s,Cf(nt(o,3)))}function tw(s){var o=gt(s)?S0:Gy;return o(s)}function rw(s,o,l){(l?Hr(s,o,l):o===t)?o=1:o=yt(o);var E=gt(s)?xy:Wy;return E(s,o)}function iw(s){var o=gt(s)?Sy:Yy;return o(s)}function nw(s){if(s==null)return 0;if(ri(s))return Lf(s)?Ca(s):s.length;var o=Ur(s);return o==he||o==Ie?s.size:Au(s).length}function sw(s,o,l){var E=gt(s)?nu:Qy;return l&&Hr(s,o,l)&&(o=t),E(s,nt(o,3))}var aw=At(function(s,o){if(s==null)return[];var l=o.length;return l>1&&Hr(s,o[0],o[1])?o=[]:l>2&&Hr(o[0],o[1],o[2])&&(o=[o[0]]),z0(s,Mr(o,1),[])}),Nf=z2||function(){return Nt.Date.now()};function ow(s,o){if(typeof o!="function")throw new Oi(f);return s=yt(s),function(){if(--s<1)return o.apply(this,arguments)}}function Dp(s,o,l){return o=l?t:o,o=s&&o==null?s.length:o,Qn(s,x,t,t,t,t,o)}function Lp(s,o){var l;if(typeof o!="function")throw new Oi(f);return s=yt(s),function(){return--s>0&&(l=o.apply(this,arguments)),s<=1&&(o=t),l}}var Vu=At(function(s,o,l){var E=W;if(l.length){var T=ws(l,ja(Vu));E|=F}return Qn(s,E,o,l,T)}),qp=At(function(s,o,l){var E=W|Q;if(l.length){var T=ws(l,ja(qp));E|=F}return Qn(o,E,s,l,T)});function Bp(s,o,l){o=l?t:o;var E=Qn(s,Y,t,t,t,t,t,o);return E.placeholder=Bp.placeholder,E}function Up(s,o,l){o=l?t:o;var E=Qn(s,$,t,t,t,t,t,o);return E.placeholder=Up.placeholder,E}function $p(s,o,l){var E,T,U,J,X,ie,ue=0,de=!1,ge=!1,Pe=!0;if(typeof s!="function")throw new Oi(f);o=Di(o)||0,Zt(l)&&(de=!!l.leading,ge="maxWait"in l,U=ge?pr(Di(l.maxWait)||0,o):U,Pe="trailing"in l?!!l.trailing:Pe);function We(or){var rn=E,rs=T;return E=T=t,ue=or,J=s.apply(rs,rn),J}function ot(or){return ue=or,X=jo(xt,o),de?We(or):J}function wt(or){var rn=or-ie,rs=or-ue,n1=o-rn;return ge?Br(n1,U-rs):n1}function ct(or){var rn=or-ie,rs=or-ue;return ie===t||rn>=o||rn<0||ge&&rs>=U}function xt(){var or=Nf();if(ct(or))return Tt(or);X=jo(xt,wt(or))}function Tt(or){return X=t,Pe&&E?We(or):(E=T=t,J)}function mi(){X!==t&&J0(X),ue=0,E=ie=T=X=t}function Kr(){return X===t?J:Tt(Nf())}function yi(){var or=Nf(),rn=ct(or);if(E=arguments,T=this,ie=or,rn){if(X===t)return ot(ie);if(ge)return J0(X),X=jo(xt,o),We(ie)}return X===t&&(X=jo(xt,o)),J}return yi.cancel=mi,yi.flush=Kr,yi}var cw=At(function(s,o){return P0(s,1,o)}),fw=At(function(s,o,l){return P0(s,Di(o)||0,l)});function hw(s){return Qn(s,ae)}function Tf(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new Oi(f);var l=function(){var E=arguments,T=o?o.apply(this,E):E[0],U=l.cache;if(U.has(T))return U.get(T);var J=s.apply(this,E);return l.cache=U.set(T,J)||U,J};return l.cache=new(Tf.Cache||Jn),l}Tf.Cache=Jn;function Cf(s){if(typeof s!="function")throw new Oi(f);return function(){var o=arguments;switch(o.length){case 0:return!s.call(this);case 1:return!s.call(this,o[0]);case 2:return!s.call(this,o[0],o[1]);case 3:return!s.call(this,o[0],o[1],o[2])}return!s.apply(this,o)}}function uw(s){return Lp(2,s)}var lw=Xy(function(s,o){o=o.length==1&>(o[0])?Xt(o[0],gi(nt())):Xt(Mr(o,1),gi(nt()));var l=o.length;return At(function(E){for(var T=-1,U=Br(E.length,l);++T=o}),ea=C0(function(){return arguments}())?C0:function(s){return tr(s)&&Ut.call(s,"callee")&&!y0.call(s,"callee")},gt=oe.isArray,Mw=kr?gi(kr):Ly;function ri(s){return s!=null&&Df(s.length)&&!es(s)}function ar(s){return tr(s)&&ri(s)}function Pw(s){return s===!0||s===!1||tr(s)&&Fr(s)==j}var Is=k2||nl,Ow=Xi?gi(Xi):qy;function Rw(s){return tr(s)&&s.nodeType===1&&!ko(s)}function Nw(s){if(s==null)return!0;if(ri(s)&&(gt(s)||typeof s=="string"||typeof s.splice=="function"||Is(s)||ka(s)||ea(s)))return!s.length;var o=Ur(s);if(o==he||o==Ie)return!s.size;if(zo(s))return!Au(s).length;for(var l in s)if(Ut.call(s,l))return!1;return!0}function Tw(s,o){return Bo(s,o)}function Cw(s,o,l){l=typeof l=="function"?l:t;var E=l?l(s,o):t;return E===t?Bo(s,o,t,l):!!E}function Wu(s){if(!tr(s))return!1;var o=Fr(s);return o==z||o==w||typeof s.message=="string"&&typeof s.name=="string"&&!ko(s)}function Dw(s){return typeof s=="number"&&_0(s)}function es(s){if(!Zt(s))return!1;var o=Fr(s);return o==ne||o==ce||o==B||o==Oe}function jp(s){return typeof s=="number"&&s==yt(s)}function Df(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=M}function Zt(s){var o=typeof s;return s!=null&&(o=="object"||o=="function")}function tr(s){return s!=null&&typeof s=="object"}var kp=Mi?gi(Mi):Uy;function Lw(s,o){return s===o||_u(s,o,Uu(o))}function qw(s,o,l){return l=typeof l=="function"?l:t,_u(s,o,Uu(o),l)}function Bw(s){return Fp(s)&&s!=+s}function Uw(s){if(_6(s))throw new dt(a);return D0(s)}function $w(s){return s===null}function zw(s){return s==null}function Fp(s){return typeof s=="number"||tr(s)&&Fr(s)==ye}function ko(s){if(!tr(s)||Fr(s)!=Te)return!1;var o=of(s);if(o===null)return!0;var l=Ut.call(o,"constructor")&&o.constructor;return typeof l=="function"&&l instanceof l&&rf.call(l)==q2}var Ju=bn?gi(bn):$y;function jw(s){return jp(s)&&s>=-M&&s<=M}var Hp=Mo?gi(Mo):zy;function Lf(s){return typeof s=="string"||!gt(s)&&tr(s)&&Fr(s)==me}function bi(s){return typeof s=="symbol"||tr(s)&&Fr(s)==Re}var ka=Vs?gi(Vs):jy;function kw(s){return s===t}function Fw(s){return tr(s)&&Ur(s)==ve}function Hw(s){return tr(s)&&Fr(s)==Ne}var Kw=Sf(Eu),Vw=Sf(function(s,o){return s<=o});function Kp(s){if(!s)return[];if(ri(s))return Lf(s)?Zi(s):ti(s);if(Oo&&s[Oo])return x2(s[Oo]());var o=Ur(s),l=o==he?hu:o==Ie?Zc:Fa;return l(s)}function ts(s){if(!s)return s===0?s:0;if(s=Di(s),s===I||s===-I){var o=s<0?-1:1;return o*S}return s===s?s:0}function yt(s){var o=ts(s),l=o%1;return o===o?l?o-l:o:0}function Vp(s){return s?Ys(yt(s),0,g):0}function Di(s){if(typeof s=="number")return s;if(bi(s))return d;if(Zt(s)){var o=typeof s.valueOf=="function"?s.valueOf():s;s=Zt(o)?o+"":o}if(typeof s!="string")return s===0?s:+s;s=u0(s);var l=Cr.test(s);return l||Lr.test(s)?pt(s.slice(2),l?2:8):Tr.test(s)?d:+s}function Gp(s){return yn(s,ii(s))}function Gw(s){return s?Ys(yt(s),-M,M):s===0?s:0}function qt(s){return s==null?"":vi(s)}var Ww=$a(function(s,o){if(zo(o)||ri(o)){yn(o,mr(o),s);return}for(var l in o)Ut.call(o,l)&&Do(s,l,o[l])}),Wp=$a(function(s,o){yn(o,ii(o),s)}),qf=$a(function(s,o,l,E){yn(o,ii(o),s,E)}),Jw=$a(function(s,o,l,E){yn(o,mr(o),s,E)}),Yw=Xn(vu);function Qw(s,o){var l=Ua(s);return o==null?l:I0(l,o)}var Xw=At(function(s,o){s=Ht(s);var l=-1,E=o.length,T=E>2?o[2]:t;for(T&&Hr(o[0],o[1],T)&&(E=1);++l1),U}),yn(s,qu(s),l),E&&(l=Ni(l,A|R|O,f6));for(var T=o.length;T--;)Pu(l,o[T]);return l});function v5(s,o){return Yp(s,Cf(nt(o)))}var b5=Xn(function(s,o){return s==null?{}:Hy(s,o)});function Yp(s,o){if(s==null)return{};var l=Xt(qu(s),function(E){return[E]});return o=nt(o),j0(s,l,function(E,T){return o(E,T[0])})}function m5(s,o,l){o=xs(o,s);var E=-1,T=o.length;for(T||(T=1,s=t);++Eo){var E=s;s=o,o=E}if(l||s%1||o%1){var T=A0();return Br(s+T*(o-s+kt("1e-"+((T+"").length-1))),o)}return Su(s,o)}var O5=za(function(s,o,l){return o=o.toLowerCase(),s+(l?Zp(o):o)});function Zp(s){return Xu(qt(s).toLowerCase())}function e1(s){return s=qt(s),s&&s.replace(er,y2).replace(eu,"")}function R5(s,o,l){s=qt(s),o=vi(o);var E=s.length;l=l===t?E:Ys(yt(l),0,E);var T=l;return l-=o.length,l>=0&&s.slice(l,T)==o}function N5(s){return s=qt(s),s&&Xe.test(s)?s.replace(It,w2):s}function T5(s){return s=qt(s),s&&je.test(s)?s.replace(rt,"\\$&"):s}var C5=za(function(s,o,l){return s+(l?"-":"")+o.toLowerCase()}),D5=za(function(s,o,l){return s+(l?" ":"")+o.toLowerCase()}),L5=ip("toLowerCase");function q5(s,o,l){s=qt(s),o=yt(o);var E=o?Ca(s):0;if(!o||E>=o)return s;var T=(o-E)/2;return xf(uf(T),l)+s+xf(hf(T),l)}function B5(s,o,l){s=qt(s),o=yt(o);var E=o?Ca(s):0;return o&&E>>0,l?(s=qt(s),s&&(typeof o=="string"||o!=null&&!Ju(o))&&(o=vi(o),!o&&Ta(s))?Ss(Zi(s),0,l):s.split(o,l)):[]}var H5=za(function(s,o,l){return s+(l?" ":"")+Xu(o)});function K5(s,o,l){return s=qt(s),l=l==null?0:Ys(yt(l),0,s.length),o=vi(o),s.slice(l,l+o.length)==o}function V5(s,o,l){var E=D.templateSettings;l&&Hr(s,o,l)&&(o=t),s=qt(s),o=qf({},o,E,hp);var T=qf({},o.imports,E.imports,hp),U=mr(T),J=fu(T,U),X,ie,ue=0,de=o.interpolate||Qr,ge="__p += '",Pe=uu((o.escape||Qr).source+"|"+de.source+"|"+(de===et?at:Qr).source+"|"+(o.evaluate||Qr).source+"|$","g"),We="//# sourceURL="+(Ut.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++tu+"]")+` +`;s.replace(Pe,function(ct,xt,Tt,mi,Kr,yi){return Tt||(Tt=mi),ge+=s.slice(ue,yi).replace(Vi,_2),xt&&(X=!0,ge+=`' + +__e(`+xt+`) + +'`),Kr&&(ie=!0,ge+=`'; +`+Kr+`; +__p += '`),Tt&&(ge+=`' + +((__t = (`+Tt+`)) == null ? '' : __t) + +'`),ue=yi+ct.length,ct}),ge+=`'; +`;var ot=Ut.call(o,"variable")&&o.variable;if(!ot)ge=`with (obj) { +`+ge+` +} +`;else if(Ct.test(ot))throw new dt(u);ge=(ie?ge.replace(_t,""):ge).replace(lt,"$1").replace(Je,"$1;"),ge="function("+(ot||"obj")+`) { +`+(ot?"":`obj || (obj = {}); +`)+"var __t, __p = ''"+(X?", __e = _.escape":"")+(ie?`, __j = Array.prototype.join; +function print() { __p += __j.call(arguments, '') } +`:`; +`)+ge+`return __p +}`;var wt=r1(function(){return Lt(U,We+"return "+ge).apply(t,J)});if(wt.source=ge,Wu(wt))throw wt;return wt}function G5(s){return qt(s).toLowerCase()}function W5(s){return qt(s).toUpperCase()}function J5(s,o,l){if(s=qt(s),s&&(l||o===t))return u0(s);if(!s||!(o=vi(o)))return s;var E=Zi(s),T=Zi(o),U=l0(E,T),J=d0(E,T)+1;return Ss(E,U,J).join("")}function Y5(s,o,l){if(s=qt(s),s&&(l||o===t))return s.slice(0,g0(s)+1);if(!s||!(o=vi(o)))return s;var E=Zi(s),T=d0(E,Zi(o))+1;return Ss(E,0,T).join("")}function Q5(s,o,l){if(s=qt(s),s&&(l||o===t))return s.replace(it,"");if(!s||!(o=vi(o)))return s;var E=Zi(s),T=l0(E,Zi(o));return Ss(E,T).join("")}function X5(s,o){var l=le,E=L;if(Zt(o)){var T="separator"in o?o.separator:T;l="length"in o?yt(o.length):l,E="omission"in o?vi(o.omission):E}s=qt(s);var U=s.length;if(Ta(s)){var J=Zi(s);U=J.length}if(l>=U)return s;var X=l-Ca(E);if(X<1)return E;var ie=J?Ss(J,0,X).join(""):s.slice(0,X);if(T===t)return ie+E;if(J&&(X+=ie.length-X),Ju(T)){if(s.slice(X).search(T)){var ue,de=ie;for(T.global||(T=uu(T.source,qt(bt.exec(T))+"g")),T.lastIndex=0;ue=T.exec(de);)var ge=ue.index;ie=ie.slice(0,ge===t?X:ge)}}else if(s.indexOf(vi(T),X)!=X){var Pe=ie.lastIndexOf(T);Pe>-1&&(ie=ie.slice(0,Pe))}return ie+E}function Z5(s){return s=qt(s),s&&Le.test(s)?s.replace(Et,P2):s}var e8=za(function(s,o,l){return s+(l?" ":"")+o.toUpperCase()}),Xu=ip("toUpperCase");function t1(s,o,l){return s=qt(s),o=l?t:o,o===t?E2(s)?N2(s):p2(s):s.match(o)||[]}var r1=At(function(s,o){try{return br(s,t,o)}catch(l){return Wu(l)?l:new dt(l)}}),t8=Xn(function(s,o){return Pi(o,function(l){l=wn(l),Yn(s,l,Vu(s[l],s))}),s});function r8(s){var o=s==null?0:s.length,l=nt();return s=o?Xt(s,function(E){if(typeof E[1]!="function")throw new Oi(f);return[l(E[0]),E[1]]}):[],At(function(E){for(var T=-1;++TM)return[];var l=g,E=Br(s,g);o=nt(o),s-=g;for(var T=cu(E,o);++l0||o<0)?new Mt(l):(s<0?l=l.takeRight(-s):s&&(l=l.drop(s)),o!==t&&(o=yt(o),l=o<0?l.dropRight(-o):l.take(o-s)),l)},Mt.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},Mt.prototype.toArray=function(){return this.take(g)},mn(Mt.prototype,function(s,o){var l=/^(?:filter|find|map|reject)|While$/.test(o),E=/^(?:head|last)$/.test(o),T=D[E?"take"+(o=="last"?"Right":""):o],U=E||/^find/.test(o);T&&(D.prototype[o]=function(){var J=this.__wrapped__,X=E?[1]:arguments,ie=J instanceof Mt,ue=X[0],de=ie||gt(J),ge=function(xt){var Tt=T.apply(D,ys([xt],X));return E&&Pe?Tt[0]:Tt};de&&l&&typeof ue=="function"&&ue.length!=1&&(ie=de=!1);var Pe=this.__chain__,We=!!this.__actions__.length,ot=U&&!Pe,wt=ie&&!We;if(!U&&de){J=wt?J:new Mt(this);var ct=s.apply(J,X);return ct.__actions__.push({func:Of,args:[ge],thisArg:t}),new Ri(ct,Pe)}return ot&&wt?s.apply(this,X):(ct=this.thru(ge),ot?E?ct.value()[0]:ct.value():ct)})}),Pi(["pop","push","shift","sort","splice","unshift"],function(s){var o=ef[s],l=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",E=/^(?:pop|shift)$/.test(s);D.prototype[s]=function(){var T=arguments;if(E&&!this.__chain__){var U=this.value();return o.apply(gt(U)?U:[],T)}return this[l](function(J){return o.apply(gt(J)?J:[],T)})}}),mn(Mt.prototype,function(s,o){var l=D[o];if(l){var E=l.name+"";Ut.call(Ba,E)||(Ba[E]=[]),Ba[E].push({name:o,func:l})}}),Ba[Af(t,Q).name]=[{name:"wrapper",func:t}],Mt.prototype.clone=Z2,Mt.prototype.reverse=ey,Mt.prototype.value=ty,D.prototype.at=R3,D.prototype.chain=N3,D.prototype.commit=T3,D.prototype.next=C3,D.prototype.plant=L3,D.prototype.reverse=q3,D.prototype.toJSON=D.prototype.valueOf=D.prototype.value=B3,D.prototype.first=D.prototype.head,Oo&&(D.prototype[Oo]=D3),D},Da=T2();sr?((sr.exports=Da)._=Da,Ft._=Da):Nt._=Da}).call(rc)})(Ad,Ad.exports);var rT=Object.defineProperty,iT=Object.defineProperties,nT=Object.getOwnPropertyDescriptors,_v=Object.getOwnPropertySymbols,sT=Object.prototype.hasOwnProperty,aT=Object.prototype.propertyIsEnumerable,Av=(r,e,t)=>e in r?rT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Gf=(r,e)=>{for(var t in e||(e={}))sT.call(e,t)&&Av(r,t,e[t]);if(_v)for(var t of _v(e))aT.call(e,t)&&Av(r,t,e[t]);return r},oT=(r,e)=>iT(r,nT(e));function dn(r,e,t){var i;const n=ac(r);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${a2}?chainId=${n.namespace}:${n.reference}&projectId=${t}`}function Ia(r){return r.includes(":")?r.split(":")[1]:r}function o2(r){return r.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function cT(r,e){const t=Object.keys(e.namespaces).filter(n=>n.includes(r));if(!t.length)return[];const i=[];return t.forEach(n=>{const a=e.namespaces[n].accounts;i.push(...a)}),i}function jl(r={},e={}){const t=Ev(r),i=Ev(e);return Ad.exports.merge(t,i)}function Ev(r){var e,t,i,n;const a={};if(!bc(r))return a;for(const[f,u]of Object.entries(r)){const b=Jd(f)?[f]:u.chains,p=u.methods||[],y=u.events||[],A=u.rpcMap||{},R=sc(f);a[R]=oT(Gf(Gf({},a[R]),u),{chains:Qf(b,(e=a[R])==null?void 0:e.chains),methods:Qf(p,(t=a[R])==null?void 0:t.methods),events:Qf(y,(i=a[R])==null?void 0:i.events),rpcMap:Gf(Gf({},A),(n=a[R])==null?void 0:n.rpcMap)})}return a}function fT(r){return r.includes(":")?r.split(":")[2]:r}function xv(r){const e={};for(const[t,i]of Object.entries(r)){const n=i.methods||[],a=i.events||[],f=i.accounts||[],u=Jd(t)?[t]:i.chains?i.chains:o2(i.accounts);e[t]={chains:u,methods:n,events:a,accounts:f}}return e}function kl(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):(r=r.includes(":")?r.split(":")[1]:r,isNaN(Number(r))?r:Number(r))}const c2={},Bt=r=>c2[r],Fl=(r,e)=>{c2[r]=e};class hT{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||dn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new pn(new Vn(i,Bt("disableProviderPing")))}}var uT=Object.defineProperty,lT=Object.defineProperties,dT=Object.getOwnPropertyDescriptors,Sv=Object.getOwnPropertySymbols,pT=Object.prototype.hasOwnProperty,gT=Object.prototype.propertyIsEnumerable,Iv=(r,e,t)=>e in r?uT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Mv=(r,e)=>{for(var t in e||(e={}))pT.call(e,t)&&Iv(r,t,e[t]);if(Sv)for(var t of Sv(e))gT.call(e,t)&&Iv(r,t,e[t]);return r},Pv=(r,e)=>lT(r,dT(e));class vT{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const i=t||dn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new pn(new Vn(i,Bt("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=parseInt(Ia(t));e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let n=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const a=parseInt(n,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:n}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,i,n;const a=(i=(t=e.request)==null?void 0:t.params)==null?void 0:i[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const f=this.client.session.get(e.topic),u=((n=f==null?void 0:f.sessionProperties)==null?void 0:n.capabilities)||{};if(u!=null&&u[a])return u==null?void 0:u[a];const b=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Pv(Mv({},f.sessionProperties||{}),{capabilities:Pv(Mv({},u||{}),{[a]:b})})})}catch(p){console.warn("Failed to update session with capabilities",p)}return b}async getCallStatus(e){var t,i;const n=this.client.session.get(e.topic),a=(t=n.sessionProperties)==null?void 0:t.bundler_name;if(a){const u=this.getBundlerUrl(e.chainId,a);try{return await this.getUserOperationReceipt(u,e)}catch(b){console.warn("Failed to fetch call status from bundler",b,u)}}const f=(i=n.sessionProperties)==null?void 0:i.bundler_url;if(f)try{return await this.getUserOperationReceipt(f,e)}catch(u){console.warn("Failed to fetch call status from custom bundler",u,f)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const n=new URL(e),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(qs("eth_getUserOperationReceipt",[(i=t.request.params)==null?void 0:i[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(e,t){return`${tT}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}class bT{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||dn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new pn(new Vn(i,Bt("disableProviderPing")))}}class mT{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||dn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new pn(new Vn(i,Bt("disableProviderPing")))}}class yT{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||dn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||dn(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new pn(new Vn(i,Bt("disableProviderPing")))}}class wT{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),n=Ia(t);e[n]=this.createHttpProvider(n,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new pn(new Vn(i,Bt("disableProviderPing")))}}class _T{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||dn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new pn(new Vn(i,Bt("disableProviderPing")))}}class AT{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ia(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||dn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new pn(new Vn(i,Bt("disableProviderPing")))}}class ET{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||dn(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||dn(e,this.namespace);return typeof i>"u"?void 0:new pn(new Vn(i,Bt("disableProviderPing")))}}class xT{constructor(e){this.name=Ya,this.namespace=e.namespace,this.events=Bt("events"),this.client=Bt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(gn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(n=>{const a=ac(n);i[`${a.namespace}:${a.reference}`]=this.createHttpProvider(n)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||dn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new pn(new Vn(i,Bt("disableProviderPing")))}}var ST=Object.defineProperty,IT=Object.defineProperties,MT=Object.getOwnPropertyDescriptors,Ov=Object.getOwnPropertySymbols,PT=Object.prototype.hasOwnProperty,OT=Object.prototype.propertyIsEnumerable,Rv=(r,e,t)=>e in r?ST(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Wf=(r,e)=>{for(var t in e||(e={}))PT.call(e,t)&&Rv(r,t,e[t]);if(Ov)for(var t of Ov(e))OT.call(e,t)&&Rv(r,t,e[t]);return r},Hl=(r,e)=>IT(r,MT(e));class n0{constructor(e){this.events=new Id,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Nc(Hh({level:(e==null?void 0:e.logger)||yv})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new n0(e);return await t.initialize(),t}async request(e,t,i){const[n,a]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:Wf({},e),chainId:`${n}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,n){const a=new Date().getTime();this.request(e,i,n).then(f=>t(null,Kh(a,f))).catch(f=>t(f,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:$t("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:n}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const a=await n();if(this.session=a.session,this.session){const f=xv(this.session.namespaces);this.namespaces=jl(this.namespaces,f),this.persist("namespaces",this.namespaces),this.onConnect()}return a}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});i&&(this.uri=i,this.events.emit("display_uri",i)),await n().then(a=>{this.session=a;const f=xv(a.namespaces);this.namespaces=jl(this.namespaces,f),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==s2)throw a;t++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,n]=this.validateChain(e),a=this.getProvider(i);a.name===Ya?a.setDefaultChain(`${i}:${n}`,t):a.setDefaultChain(n,t)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(jn(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await i0.init({core:this.providerOpts.core,logger:this.providerOpts.logger||yv,relayUrl:this.providerOpts.relayUrl||XN,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(t=>sc(t)))];Fl("client",this.client),Fl("events",this.events),Fl("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const i=cT(t,this.session),n=o2(i),a=jl(this.namespaces,this.optionalNamespaces),f=Hl(Wf({},a[t]),{accounts:i,chains:n});switch(t){case"eip155":this.rpcProviders[t]=new vT({namespace:f});break;case"algorand":this.rpcProviders[t]=new yT({namespace:f});break;case"solana":this.rpcProviders[t]=new bT({namespace:f});break;case"cosmos":this.rpcProviders[t]=new mT({namespace:f});break;case"polkadot":this.rpcProviders[t]=new hT({namespace:f});break;case"cip34":this.rpcProviders[t]=new wT({namespace:f});break;case"elrond":this.rpcProviders[t]=new _T({namespace:f});break;case"multiversx":this.rpcProviders[t]=new AT({namespace:f});break;case"near":this.rpcProviders[t]=new ET({namespace:f});break;default:this.rpcProviders[Ya]?this.rpcProviders[Ya].updateNamespace(f):this.rpcProviders[Ya]=new xT({namespace:f})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:i}=t;if(i.name==="accountsChanged"){const n=i.data;n&&jn(n)&&this.events.emit("accountsChanged",n.map(fT))}else if(i.name==="chainChanged"){const n=t.chainId,a=t.event.data,f=sc(n),u=kl(n)!==kl(a)?`${f}:${kl(a)}`:n;this.onChainChanged(u)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;const{namespaces:n}=t,a=(i=this.client)==null?void 0:i.session.get(e);this.session=Hl(Wf({},a),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Hl(Wf({},$t("USER_DISCONNECTED")),{data:e.topic}))}),this.on(gn.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Ya]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:n}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=n,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(f=>sc(f)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const n=sc(Object.keys(this.namespaces)[0]),a=this.rpcProviders[n].getDefaultChain();return[n,a]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,n]=this.validateChain(e);n&&(t||this.getProvider(i).setDefaultChain(n),this.namespaces[i]?this.namespaces[i].defaultChain=n:this.namespaces[`${i}:${n}`]?this.namespaces[`${i}:${n}`].defaultChain=n:this.namespaces[`${i}:${n}`]={defaultChain:n},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${wv}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${wv}/${e}`)}}const RT=n0,NT="wc",TT="ethereum_provider",CT=`${NT}@2:${TT}:`,DT="https://rpc.walletconnect.org/v1/",Ed=["eth_sendTransaction","personal_sign"],LT=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],xd=["chainChanged","accountsChanged"],qT=["chainChanged","accountsChanged","message","disconnect","connect"];var BT=Object.defineProperty,UT=Object.defineProperties,$T=Object.getOwnPropertyDescriptors,Nv=Object.getOwnPropertySymbols,zT=Object.prototype.hasOwnProperty,jT=Object.prototype.propertyIsEnumerable,Tv=(r,e,t)=>e in r?BT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Qa=(r,e)=>{for(var t in e||(e={}))zT.call(e,t)&&Tv(r,t,e[t]);if(Nv)for(var t of Nv(e))jT.call(e,t)&&Tv(r,t,e[t]);return r},Kl=(r,e)=>UT(r,$T(e));function Eh(r){return Number(r[0].split(":")[1])}function Jf(r){return`0x${r.toString(16)}`}function kT(r){const{chains:e,optionalChains:t,methods:i,optionalMethods:n,events:a,optionalEvents:f,rpcMap:u}=r;if(!jn(e))throw new Error("Invalid chains");const b={chains:e,methods:i||Ed,events:a||xd,rpcMap:Qa({},e.length?{[Eh(e)]:u[Eh(e)]}:{})},p=a==null?void 0:a.filter(O=>!xd.includes(O)),y=i==null?void 0:i.filter(O=>!Ed.includes(O));if(!t&&!f&&!n&&!(p!=null&&p.length)&&!(y!=null&&y.length))return{required:e.length?b:void 0};const A=(p==null?void 0:p.length)&&(y==null?void 0:y.length)||!t,R={chains:[...new Set(A?b.chains.concat(t||[]):t)],methods:[...new Set(b.methods.concat(n!=null&&n.length?n:LT))],events:[...new Set(b.events.concat(f!=null&&f.length?f:qT))],rpcMap:u};return{required:e.length?b:void 0,optional:t.length?R:void 0}}class s0{constructor(){this.events=new Fi.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=CT,this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new s0;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,i){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),i)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:t,optional:i}=kT(this.rpc);try{const n=await new Promise(async(f,u)=>{var b;this.rpc.showQrModal&&((b=this.modal)==null||b.subscribeModal(p=>{!p.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),u(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Kl(Qa({namespaces:Qa({},t&&{[this.namespace]:t})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(p=>{f(p)}).catch(p=>{u(new Error(p.message))})});if(!n)return;const a=C1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Jf(this.chainId)})}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(a,f)=>{var u;this.rpc.showQrModal&&((u=this.modal)==null||u.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Kl(Qa({},e),{chains:this.rpc.chains}),t).then(b=>{a(b)}).catch(b=>{f(new Error(b.message))})}),n=i.session;if(n){const a=C1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Jf(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:t}=e,{event:i}=t;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",Jf(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",Kl(Qa({},$t("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,i;this.rpc.showQrModal&&((t=this.modal)==null||t.closeModal(),(i=this.modal)==null||i.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",Jf(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,i,n]=e.split(":");return{chainId:`${t}:${i}`,address:n}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,i;const n=(t=e==null?void 0:e.chains)!=null?t:[],a=(i=e==null?void 0:e.optionalChains)!=null?i:[],f=n.concat(a);if(!f.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const u=n.length?(e==null?void 0:e.methods)||Ed:[],b=n.length?(e==null?void 0:e.events)||xd:[],p=(e==null?void 0:e.optionalMethods)||[],y=(e==null?void 0:e.optionalEvents)||[],A=(e==null?void 0:e.rpcMap)||this.buildRpcMap(f,e.projectId),R=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:n==null?void 0:n.map(O=>this.formatChainId(O)),optionalChains:a.map(O=>this.formatChainId(O)),methods:u,events:b,optionalMethods:p,optionalEvents:y,rpcMap:A,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:R,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const i={};return e.forEach(n=>{i[n]=this.getRpcUrl(n,t)}),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Eh(this.rpc.chains):Eh(this.rpc.optionalChains),this.signer=await RT.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let t;try{const{WalletConnectModal:i}=await F8(()=>import("./index-1C-dIFy4.js").then(n=>n.i),__vite__mapDeps([0,1,2]));t=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(Qa({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:i,rpcMap:n}=e;t&&jn(t)&&(this.rpc.chains=t.map(a=>this.formatChainId(a)),t.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)})),i&&jn(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i==null?void 0:i.map(a=>this.formatChainId(a)),i.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)}))}getRpcUrl(e,t){var i;return((i=this.rpc.rpcMap)==null?void 0:i[e])||`${DT}?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t==null?void 0:t.accounts),this.setAccounts(t==null?void 0:t.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(t=>this.signer.logger.warn(t))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(t=>this.parseAccount(t))}}const pC=s0;export{pC as EthereumProvider,qT as OPTIONAL_EVENTS,LT as OPTIONAL_METHODS,xd as REQUIRED_EVENTS,Ed as REQUIRED_METHODS,s0 as default}; diff --git a/buddybook/assets/inherits_browser-Dprisln6.js b/buddybook/assets/inherits_browser-DVmoQh9i.js similarity index 85% rename from buddybook/assets/inherits_browser-Dprisln6.js rename to buddybook/assets/inherits_browser-DVmoQh9i.js index a813dd8..a1cbf43 100644 --- a/buddybook/assets/inherits_browser-Dprisln6.js +++ b/buddybook/assets/inherits_browser-DVmoQh9i.js @@ -1 +1 @@ -import{g as n,u as s}from"./index-CLqSQ1yP.js";const a=n(s);var r={exports:{}};typeof Object.create=="function"?r.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(e,t){if(t){e.super_=t;var o=function(){};o.prototype=t.prototype,e.prototype=new o,e.prototype.constructor=e}};var u=r.exports;export{u as i,a as r}; +import{g as n,u as s}from"./index-mI-wCQlz.js";const a=n(s);var r={exports:{}};typeof Object.create=="function"?r.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(e,t){if(t){e.super_=t;var o=function(){};o.prototype=t.prototype,e.prototype=new o,e.prototype.constructor=e}};var u=r.exports;export{u as i,a as r}; diff --git a/buddybook/favicon.svg b/buddybook/favicon.svg new file mode 100644 index 0000000..f7a9afc --- /dev/null +++ b/buddybook/favicon.svg @@ -0,0 +1,4 @@ + + + B + \ No newline at end of file diff --git a/buddybook/index.html b/buddybook/index.html index d134a9f..449deca 100644 --- a/buddybook/index.html +++ b/buddybook/index.html @@ -2,11 +2,26 @@ + + BuddyBook Dogfood - - + + +
diff --git a/flush-notes/404.html b/flush-notes/404.html index d70d021..77e4ea9 100644 --- a/flush-notes/404.html +++ b/flush-notes/404.html @@ -1 +1 @@ -Share notes

Loading...

\ No newline at end of file +Share notes

Loading...

\ No newline at end of file diff --git a/flush-notes/_next/static/rp4Ih8fj9YecDRnymfEUx/_buildManifest.js b/flush-notes/_next/static/YbqkI6PxL4I-BPyh4Nimw/_buildManifest.js similarity index 100% rename from flush-notes/_next/static/rp4Ih8fj9YecDRnymfEUx/_buildManifest.js rename to flush-notes/_next/static/YbqkI6PxL4I-BPyh4Nimw/_buildManifest.js diff --git a/flush-notes/_next/static/rp4Ih8fj9YecDRnymfEUx/_ssgManifest.js b/flush-notes/_next/static/YbqkI6PxL4I-BPyh4Nimw/_ssgManifest.js similarity index 100% rename from flush-notes/_next/static/rp4Ih8fj9YecDRnymfEUx/_ssgManifest.js rename to flush-notes/_next/static/YbqkI6PxL4I-BPyh4Nimw/_ssgManifest.js diff --git a/flush-notes/index.html b/flush-notes/index.html index 738618e..7e1a04d 100644 --- a/flush-notes/index.html +++ b/flush-notes/index.html @@ -1 +1 @@ -Share notes

Loading...

\ No newline at end of file +Share notes

Loading...

\ No newline at end of file diff --git a/flush-notes/index.txt b/flush-notes/index.txt index f6e52b7..54789f0 100644 --- a/flush-notes/index.txt +++ b/flush-notes/index.txt @@ -1,6 +1,6 @@ 1:HL["/_next/static/media/a34f9d1faa5f3315-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}] 2:HL["/_next/static/css/93e318bfbcd18d37.css","style",{"crossOrigin":""}] -0:["rp4Ih8fj9YecDRnymfEUx",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/93e318bfbcd18d37.css","precedence":"next","crossOrigin":""}]],"$L4"]]]] +0:["YbqkI6PxL4I-BPyh4Nimw",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/93e318bfbcd18d37.css","precedence":"next","crossOrigin":""}]],"$L4"]]]] 5:I[5685,["948","static/chunks/948-50bbf5866eb892b4.js","185","static/chunks/app/layout-6076b03a814c7003.js"],""] 6:I[6954,[],""] 7:I[7264,[],""] diff --git a/flush-notes/view.html b/flush-notes/view.html index ed9d86b..b559220 100644 --- a/flush-notes/view.html +++ b/flush-notes/view.html @@ -1 +1 @@ -Share notes

Loading...

\ No newline at end of file +Share notes

Loading...

\ No newline at end of file diff --git a/flush-notes/view.txt b/flush-notes/view.txt index 7092210..5baea3c 100644 --- a/flush-notes/view.txt +++ b/flush-notes/view.txt @@ -1,6 +1,6 @@ 1:HL["/_next/static/media/a34f9d1faa5f3315-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}] 2:HL["/_next/static/css/93e318bfbcd18d37.css","style",{"crossOrigin":""}] -0:["rp4Ih8fj9YecDRnymfEUx",[[["",{"children":["view",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/93e318bfbcd18d37.css","precedence":"next","crossOrigin":""}]],"$L4"]]]] +0:["YbqkI6PxL4I-BPyh4Nimw",[[["",{"children":["view",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/93e318bfbcd18d37.css","precedence":"next","crossOrigin":""}]],"$L4"]]]] 5:I[5685,["948","static/chunks/948-50bbf5866eb892b4.js","185","static/chunks/app/layout-6076b03a814c7003.js"],""] 6:I[6954,[],""] 7:I[7264,[],""]