@dcl/auth-site 1.6.1-8975190511.commit-956871c → 1.6.1-9565705163.commit-3066ab8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ import{p as ri,b as D1,d as Z3,r as t6,g as Ie,B as ca,e as Di,a as Tl,c as Zi,f as Fl,o as ad,_ as e6}from"./index-0a6a1b27.js";import{t as r6}from"./tslib.es6-c2094241.js";var cd=globalThis&&globalThis.__spreadArray||function(r,t,e){if(e||arguments.length===2)for(var i=0,s=t.length,a;i<s;i++)(a||!(i in t))&&(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return r.concat(a||Array.prototype.slice.call(t))},i6=function(){function r(t,e,i){this.name=t,this.version=e,this.os=i,this.type="browser"}return r}(),n6=function(){function r(t){this.version=t,this.type="node",this.name="node",this.os=ri.platform}return r}(),s6=function(){function r(t,e,i,s){this.name=t,this.version=e,this.os=i,this.bot=s,this.type="bot-device"}return r}(),o6=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),a6=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),c6=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,u6=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,ud=3,h6=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",c6]],hd=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function l6(r){return r?ld(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new a6:typeof navigator<"u"?ld(navigator.userAgent):p6()}function f6(r){return r!==""&&h6.reduce(function(t,e){var i=e[0],s=e[1];if(t)return t;var a=s.exec(r);return!!a&&[i,a]},!1)}function ld(r){var t=f6(r);if(!t)return null;var e=t[0],i=t[1];if(e==="searchbot")return new o6;var s=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);s?s.length<ud&&(s=cd(cd([],s,!0),g6(ud-s.length),!0)):s=[];var a=s.join("."),u=d6(r),l=u6.exec(r);return l&&l[1]?new s6(e,a,u,l[1]):new i6(e,a,u)}function d6(r){for(var t=0,e=hd.length;t<e;t++){var i=hd[t],s=i[0],a=i[1],u=a.exec(r);if(u)return s}return null}function p6(){var r=typeof ri<"u"&&ri.version;return r?new n6(ri.version.slice(1)):null}function g6(r){for(var t=[],e=0;e<r;e++)t.push("0");return t}var yt={};const ua=D1(r6);var xh={},jo={},fd;function m6(){if(fd)return jo;fd=1,Object.defineProperty(jo,"__esModule",{value:!0}),jo.delay=void 0;function r(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}return jo.delay=r,jo}var ys={},Mh={},ws={},dd;function v6(){return dd||(dd=1,Object.defineProperty(ws,"__esModule",{value:!0}),ws.ONE_THOUSAND=ws.ONE_HUNDRED=void 0,ws.ONE_HUNDRED=100,ws.ONE_THOUSAND=1e3),ws}var Ch={},pd;function y6(){return pd||(pd=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}(Ch)),Ch}var gd;function x1(){return gd||(gd=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=ua;t.__exportStar(v6(),r),t.__exportStar(y6(),r)}(Mh)),Mh}var md;function w6(){if(md)return ys;md=1,Object.defineProperty(ys,"__esModule",{value:!0}),ys.fromMiliseconds=ys.toMiliseconds=void 0;const r=x1();function t(i){return i*r.ONE_THOUSAND}ys.toMiliseconds=t;function e(i){return Math.floor(i/r.ONE_THOUSAND)}return ys.fromMiliseconds=e,ys}var vd;function b6(){return vd||(vd=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=ua;t.__exportStar(m6(),r),t.__exportStar(w6(),r)}(xh)),xh}var Qs={},yd;function _6(){if(yd)return Qs;yd=1,Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const i=this.get(e);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);const s=Date.now()-i.started;this.timestamps.set(e,{started:i.started,elapsed:s})}get(e){const i=this.timestamps.get(e);if(typeof i>"u")throw new Error(`No timestamp found for label: ${e}`);return i}elapsed(e){const i=this.get(e);return i.elapsed||Date.now()-i.started}}return Qs.Watch=r,Qs.default=r,Qs}var Ph={},$o={},wd;function E6(){if(wd)return $o;wd=1,Object.defineProperty($o,"__esModule",{value:!0}),$o.IWatch=void 0;class r{}return $o.IWatch=r,$o}var bd;function A6(){return bd||(bd=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),ua.__exportStar(E6(),r)}(Ph)),Ph}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=ua;t.__exportStar(b6(),r),t.__exportStar(_6(),r),t.__exportStar(A6(),r),t.__exportStar(x1(),r)})(yt);var je={};Object.defineProperty(je,"__esModule",{value:!0});je.getLocalStorage=je.getLocalStorageOrThrow=je.getCrypto=je.getCryptoOrThrow=M1=je.getLocation=je.getLocationOrThrow=Bl=je.getNavigator=je.getNavigatorOrThrow=Ul=je.getDocument=je.getDocumentOrThrow=je.getFromWindowOrThrow=je.getFromWindow=void 0;function xs(r){let t;return typeof window<"u"&&typeof window[r]<"u"&&(t=window[r]),t}je.getFromWindow=xs;function lo(r){const t=xs(r);if(!t)throw new Error(`${r} is not defined in Window`);return t}je.getFromWindowOrThrow=lo;function S6(){return lo("document")}je.getDocumentOrThrow=S6;function I6(){return xs("document")}var Ul=je.getDocument=I6;function D6(){return lo("navigator")}je.getNavigatorOrThrow=D6;function x6(){return xs("navigator")}var Bl=je.getNavigator=x6;function M6(){return lo("location")}je.getLocationOrThrow=M6;function C6(){return xs("location")}var M1=je.getLocation=C6;function P6(){return lo("crypto")}je.getCryptoOrThrow=P6;function O6(){return xs("crypto")}je.getCrypto=O6;function N6(){return lo("localStorage")}je.getLocalStorageOrThrow=N6;function R6(){return xs("localStorage")}je.getLocalStorage=R6;var Ll={};Object.defineProperty(Ll,"__esModule",{value:!0});var C1=Ll.getWindowMetadata=void 0;const _d=je;function T6(){let r,t;try{r=_d.getDocumentOrThrow(),t=_d.getLocationOrThrow()}catch{return null}function e(){const E=r.getElementsByTagName("link"),x=[];for(let I=0;I<E.length;I++){const N=E[I],Y=N.getAttribute("rel");if(Y&&Y.toLowerCase().indexOf("icon")>-1){const G=N.getAttribute("href");if(G)if(G.toLowerCase().indexOf("https:")===-1&&G.toLowerCase().indexOf("http:")===-1&&G.indexOf("//")!==0){let tt=t.protocol+"//"+t.host;if(G.indexOf("/")===0)tt+=G;else{const K=t.pathname.split("/");K.pop();const V=K.join("/");tt+=V+"/"+G}x.push(tt)}else if(G.indexOf("//")===0){const tt=t.protocol+G;x.push(tt)}else x.push(G)}}return x}function i(...E){const x=r.getElementsByTagName("meta");for(let I=0;I<x.length;I++){const N=x[I],Y=["itemprop","property","name"].map(G=>N.getAttribute(G)).filter(G=>G?E.includes(G):!1);if(Y.length&&Y){const G=N.getAttribute("content");if(G)return G}}return""}function s(){let E=i("name","og:site_name","og:title","twitter:title");return E||(E=r.title),E}function a(){return i("description","og:description","twitter:description","keywords")}const u=s(),l=a(),m=t.origin,f=e();return{description:l,url:m,icons:f,name:u}}C1=Ll.getWindowMetadata=T6;var ea={},F6=r=>encodeURIComponent(r).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),P1="%[a-f0-9]{2}",Ed=new RegExp("("+P1+")|([^%]+?)","gi"),Ad=new RegExp("("+P1+")+","gi");function ul(r,t){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;t=t||1;var e=r.slice(0,t),i=r.slice(t);return Array.prototype.concat.call([],ul(e),ul(i))}function U6(r){try{return decodeURIComponent(r)}catch{for(var t=r.match(Ed)||[],e=1;e<t.length;e++)r=ul(t,e).join(""),t=r.match(Ed)||[];return r}}function B6(r){for(var t={"%FE%FF":"��","%FF%FE":"��"},e=Ad.exec(r);e;){try{t[e[0]]=decodeURIComponent(e[0])}catch{var i=U6(e[0]);i!==e[0]&&(t[e[0]]=i)}e=Ad.exec(r)}t["%C2"]="�";for(var s=Object.keys(t),a=0;a<s.length;a++){var u=s[a];r=r.replace(new RegExp(u,"g"),t[u])}return r}var L6=function(r){if(typeof r!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof r+"`");try{return r=r.replace(/\+/g," "),decodeURIComponent(r)}catch{return B6(r)}},q6=(r,t)=>{if(!(typeof r=="string"&&typeof t=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(t==="")return[r];const e=r.indexOf(t);return e===-1?[r]:[r.slice(0,e),r.slice(e+t.length)]},j6=function(r,t){for(var e={},i=Object.keys(r),s=Array.isArray(t),a=0;a<i.length;a++){var u=i[a],l=r[u];(s?t.indexOf(u)!==-1:t(u,l,r))&&(e[u]=l)}return e};(function(r){const t=F6,e=L6,i=q6,s=j6,a=K=>K==null,u=Symbol("encodeFragmentIdentifier");function l(K){switch(K.arrayFormat){case"index":return V=>(B,z)=>{const $=B.length;return z===void 0||K.skipNull&&z===null||K.skipEmptyString&&z===""?B:z===null?[...B,[w(V,K),"[",$,"]"].join("")]:[...B,[w(V,K),"[",w($,K),"]=",w(z,K)].join("")]};case"bracket":return V=>(B,z)=>z===void 0||K.skipNull&&z===null||K.skipEmptyString&&z===""?B:z===null?[...B,[w(V,K),"[]"].join("")]:[...B,[w(V,K),"[]=",w(z,K)].join("")];case"colon-list-separator":return V=>(B,z)=>z===void 0||K.skipNull&&z===null||K.skipEmptyString&&z===""?B:z===null?[...B,[w(V,K),":list="].join("")]:[...B,[w(V,K),":list=",w(z,K)].join("")];case"comma":case"separator":case"bracket-separator":{const V=K.arrayFormat==="bracket-separator"?"[]=":"=";return B=>(z,$)=>$===void 0||K.skipNull&&$===null||K.skipEmptyString&&$===""?z:($=$===null?"":$,z.length===0?[[w(B,K),V,w($,K)].join("")]:[[z,w($,K)].join(K.arrayFormatSeparator)])}default:return V=>(B,z)=>z===void 0||K.skipNull&&z===null||K.skipEmptyString&&z===""?B:z===null?[...B,w(V,K)]:[...B,[w(V,K),"=",w(z,K)].join("")]}}function m(K){let V;switch(K.arrayFormat){case"index":return(B,z,$)=>{if(V=/\[(\d*)\]$/.exec(B),B=B.replace(/\[\d*\]$/,""),!V){$[B]=z;return}$[B]===void 0&&($[B]={}),$[B][V[1]]=z};case"bracket":return(B,z,$)=>{if(V=/(\[\])$/.exec(B),B=B.replace(/\[\]$/,""),!V){$[B]=z;return}if($[B]===void 0){$[B]=[z];return}$[B]=[].concat($[B],z)};case"colon-list-separator":return(B,z,$)=>{if(V=/(:list)$/.exec(B),B=B.replace(/:list$/,""),!V){$[B]=z;return}if($[B]===void 0){$[B]=[z];return}$[B]=[].concat($[B],z)};case"comma":case"separator":return(B,z,$)=>{const v=typeof z=="string"&&z.includes(K.arrayFormatSeparator),T=typeof z=="string"&&!v&&E(z,K).includes(K.arrayFormatSeparator);z=T?E(z,K):z;const nt=v||T?z.split(K.arrayFormatSeparator).map(ft=>E(ft,K)):z===null?z:E(z,K);$[B]=nt};case"bracket-separator":return(B,z,$)=>{const v=/(\[\])$/.test(B);if(B=B.replace(/\[\]$/,""),!v){$[B]=z&&E(z,K);return}const T=z===null?[]:z.split(K.arrayFormatSeparator).map(nt=>E(nt,K));if($[B]===void 0){$[B]=T;return}$[B]=[].concat($[B],T)};default:return(B,z,$)=>{if($[B]===void 0){$[B]=z;return}$[B]=[].concat($[B],z)}}}function f(K){if(typeof K!="string"||K.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function w(K,V){return V.encode?V.strict?t(K):encodeURIComponent(K):K}function E(K,V){return V.decode?e(K):K}function x(K){return Array.isArray(K)?K.sort():typeof K=="object"?x(Object.keys(K)).sort((V,B)=>Number(V)-Number(B)).map(V=>K[V]):K}function I(K){const V=K.indexOf("#");return V!==-1&&(K=K.slice(0,V)),K}function N(K){let V="";const B=K.indexOf("#");return B!==-1&&(V=K.slice(B)),V}function Y(K){K=I(K);const V=K.indexOf("?");return V===-1?"":K.slice(V+1)}function G(K,V){return V.parseNumbers&&!Number.isNaN(Number(K))&&typeof K=="string"&&K.trim()!==""?K=Number(K):V.parseBooleans&&K!==null&&(K.toLowerCase()==="true"||K.toLowerCase()==="false")&&(K=K.toLowerCase()==="true"),K}function tt(K,V){V=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},V),f(V.arrayFormatSeparator);const B=m(V),z=Object.create(null);if(typeof K!="string"||(K=K.trim().replace(/^[?#&]/,""),!K))return z;for(const $ of K.split("&")){if($==="")continue;let[v,T]=i(V.decode?$.replace(/\+/g," "):$,"=");T=T===void 0?null:["comma","separator","bracket-separator"].includes(V.arrayFormat)?T:E(T,V),B(E(v,V),T,z)}for(const $ of Object.keys(z)){const v=z[$];if(typeof v=="object"&&v!==null)for(const T of Object.keys(v))v[T]=G(v[T],V);else z[$]=G(v,V)}return V.sort===!1?z:(V.sort===!0?Object.keys(z).sort():Object.keys(z).sort(V.sort)).reduce(($,v)=>{const T=z[v];return T&&typeof T=="object"&&!Array.isArray(T)?$[v]=x(T):$[v]=T,$},Object.create(null))}r.extract=Y,r.parse=tt,r.stringify=(K,V)=>{if(!K)return"";V=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},V),f(V.arrayFormatSeparator);const B=T=>V.skipNull&&a(K[T])||V.skipEmptyString&&K[T]==="",z=l(V),$={};for(const T of Object.keys(K))B(T)||($[T]=K[T]);const v=Object.keys($);return V.sort!==!1&&v.sort(V.sort),v.map(T=>{const nt=K[T];return nt===void 0?"":nt===null?w(T,V):Array.isArray(nt)?nt.length===0&&V.arrayFormat==="bracket-separator"?w(T,V)+"[]":nt.reduce(z(T),[]).join("&"):w(T,V)+"="+w(nt,V)}).filter(T=>T.length>0).join("&")},r.parseUrl=(K,V)=>{V=Object.assign({decode:!0},V);const[B,z]=i(K,"#");return Object.assign({url:B.split("?")[0]||"",query:tt(Y(K),V)},V&&V.parseFragmentIdentifier&&z?{fragmentIdentifier:E(z,V)}:{})},r.stringifyUrl=(K,V)=>{V=Object.assign({encode:!0,strict:!0,[u]:!0},V);const B=I(K.url).split("?")[0]||"",z=r.extract(K.url),$=r.parse(z,{sort:!1}),v=Object.assign($,K.query);let T=r.stringify(v,V);T&&(T=`?${T}`);let nt=N(K.url);return K.fragmentIdentifier&&(nt=`#${V[u]?w(K.fragmentIdentifier,V):K.fragmentIdentifier}`),`${B}${T}${nt}`},r.pick=(K,V,B)=>{B=Object.assign({parseFragmentIdentifier:!0,[u]:!1},B);const{url:z,query:$,fragmentIdentifier:v}=r.parseUrl(K,B);return r.stringifyUrl({url:z,query:s($,V),fragmentIdentifier:v},B)},r.exclude=(K,V,B)=>{const z=Array.isArray(V)?$=>!V.includes($):($,v)=>!V($,v);return r.pick(K,z,B)}})(ea);var ql={},nu={},oe={},O1={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});function t(l,m){var f=l>>>16&65535,w=l&65535,E=m>>>16&65535,x=m&65535;return w*x+(f*x+w*E<<16>>>0)|0}r.mul=Math.imul||t;function e(l,m){return l+m|0}r.add=e;function i(l,m){return l-m|0}r.sub=i;function s(l,m){return l<<m|l>>>32-m}r.rotl=s;function a(l,m){return l<<32-m|l>>>m}r.rotr=a;function u(l){return typeof l=="number"&&isFinite(l)&&Math.floor(l)===l}r.isInteger=Number.isInteger||u,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(l){return r.isInteger(l)&&l>=-r.MAX_SAFE_INTEGER&&l<=r.MAX_SAFE_INTEGER}})(O1);Object.defineProperty(oe,"__esModule",{value:!0});var N1=O1;function $6(r,t){return t===void 0&&(t=0),(r[t+0]<<8|r[t+1])<<16>>16}oe.readInt16BE=$6;function z6(r,t){return t===void 0&&(t=0),(r[t+0]<<8|r[t+1])>>>0}oe.readUint16BE=z6;function k6(r,t){return t===void 0&&(t=0),(r[t+1]<<8|r[t])<<16>>16}oe.readInt16LE=k6;function H6(r,t){return t===void 0&&(t=0),(r[t+1]<<8|r[t])>>>0}oe.readUint16LE=H6;function R1(r,t,e){return t===void 0&&(t=new Uint8Array(2)),e===void 0&&(e=0),t[e+0]=r>>>8,t[e+1]=r>>>0,t}oe.writeUint16BE=R1;oe.writeInt16BE=R1;function T1(r,t,e){return t===void 0&&(t=new Uint8Array(2)),e===void 0&&(e=0),t[e+0]=r>>>0,t[e+1]=r>>>8,t}oe.writeUint16LE=T1;oe.writeInt16LE=T1;function hl(r,t){return t===void 0&&(t=0),r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3]}oe.readInt32BE=hl;function ll(r,t){return t===void 0&&(t=0),(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}oe.readUint32BE=ll;function fl(r,t){return t===void 0&&(t=0),r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t]}oe.readInt32LE=fl;function dl(r,t){return t===void 0&&(t=0),(r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t])>>>0}oe.readUint32LE=dl;function Hc(r,t,e){return t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0),t[e+0]=r>>>24,t[e+1]=r>>>16,t[e+2]=r>>>8,t[e+3]=r>>>0,t}oe.writeUint32BE=Hc;oe.writeInt32BE=Hc;function Kc(r,t,e){return t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0),t[e+0]=r>>>0,t[e+1]=r>>>8,t[e+2]=r>>>16,t[e+3]=r>>>24,t}oe.writeUint32LE=Kc;oe.writeInt32LE=Kc;function K6(r,t){t===void 0&&(t=0);var e=hl(r,t),i=hl(r,t+4);return e*4294967296+i-(i>>31)*4294967296}oe.readInt64BE=K6;function V6(r,t){t===void 0&&(t=0);var e=ll(r,t),i=ll(r,t+4);return e*4294967296+i}oe.readUint64BE=V6;function G6(r,t){t===void 0&&(t=0);var e=fl(r,t),i=fl(r,t+4);return i*4294967296+e-(e>>31)*4294967296}oe.readInt64LE=G6;function W6(r,t){t===void 0&&(t=0);var e=dl(r,t),i=dl(r,t+4);return i*4294967296+e}oe.readUint64LE=W6;function F1(r,t,e){return t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0),Hc(r/4294967296>>>0,t,e),Hc(r>>>0,t,e+4),t}oe.writeUint64BE=F1;oe.writeInt64BE=F1;function U1(r,t,e){return t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0),Kc(r>>>0,t,e),Kc(r/4294967296>>>0,t,e+4),t}oe.writeUint64LE=U1;oe.writeInt64LE=U1;function Y6(r,t,e){if(e===void 0&&(e=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>t.length-e)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,s=1,a=r/8+e-1;a>=e;a--)i+=t[a]*s,s*=256;return i}oe.readUintBE=Y6;function Q6(r,t,e){if(e===void 0&&(e=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>t.length-e)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,s=1,a=e;a<e+r/8;a++)i+=t[a]*s,s*=256;return i}oe.readUintLE=Q6;function J6(r,t,e,i){if(e===void 0&&(e=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!N1.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var s=1,a=r/8+i-1;a>=i;a--)e[a]=t/s&255,s*=256;return e}oe.writeUintBE=J6;function X6(r,t,e,i){if(e===void 0&&(e=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!N1.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var s=1,a=i;a<i+r/8;a++)e[a]=t/s&255,s*=256;return e}oe.writeUintLE=X6;function Z6(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat32(t)}oe.readFloat32BE=Z6;function t_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat32(t,!0)}oe.readFloat32LE=t_;function e_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat64(t)}oe.readFloat64BE=e_;function r_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat64(t,!0)}oe.readFloat64LE=r_;function i_(r,t,e){t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0);var i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setFloat32(e,r),t}oe.writeFloat32BE=i_;function n_(r,t,e){t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0);var i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setFloat32(e,r,!0),t}oe.writeFloat32LE=n_;function s_(r,t,e){t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0);var i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setFloat64(e,r),t}oe.writeFloat64BE=s_;function o_(r,t,e){t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0);var i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setFloat64(e,r,!0),t}oe.writeFloat64LE=o_;var si={};Object.defineProperty(si,"__esModule",{value:!0});function a_(r){for(var t=0;t<r.length;t++)r[t]=0;return r}si.wipe=a_;Object.defineProperty(nu,"__esModule",{value:!0});var _r=oe,pl=si,c_=20;function u_(r,t,e){for(var i=1634760805,s=857760878,a=2036477234,u=1797285236,l=e[3]<<24|e[2]<<16|e[1]<<8|e[0],m=e[7]<<24|e[6]<<16|e[5]<<8|e[4],f=e[11]<<24|e[10]<<16|e[9]<<8|e[8],w=e[15]<<24|e[14]<<16|e[13]<<8|e[12],E=e[19]<<24|e[18]<<16|e[17]<<8|e[16],x=e[23]<<24|e[22]<<16|e[21]<<8|e[20],I=e[27]<<24|e[26]<<16|e[25]<<8|e[24],N=e[31]<<24|e[30]<<16|e[29]<<8|e[28],Y=t[3]<<24|t[2]<<16|t[1]<<8|t[0],G=t[7]<<24|t[6]<<16|t[5]<<8|t[4],tt=t[11]<<24|t[10]<<16|t[9]<<8|t[8],K=t[15]<<24|t[14]<<16|t[13]<<8|t[12],V=i,B=s,z=a,$=u,v=l,T=m,nt=f,ft=w,pt=E,mt=x,h=I,y=N,b=Y,M=G,C=tt,R=K,j=0;j<c_;j+=2)V=V+v|0,b^=V,b=b>>>32-16|b<<16,pt=pt+b|0,v^=pt,v=v>>>32-12|v<<12,B=B+T|0,M^=B,M=M>>>32-16|M<<16,mt=mt+M|0,T^=mt,T=T>>>32-12|T<<12,z=z+nt|0,C^=z,C=C>>>32-16|C<<16,h=h+C|0,nt^=h,nt=nt>>>32-12|nt<<12,$=$+ft|0,R^=$,R=R>>>32-16|R<<16,y=y+R|0,ft^=y,ft=ft>>>32-12|ft<<12,z=z+nt|0,C^=z,C=C>>>32-8|C<<8,h=h+C|0,nt^=h,nt=nt>>>32-7|nt<<7,$=$+ft|0,R^=$,R=R>>>32-8|R<<8,y=y+R|0,ft^=y,ft=ft>>>32-7|ft<<7,B=B+T|0,M^=B,M=M>>>32-8|M<<8,mt=mt+M|0,T^=mt,T=T>>>32-7|T<<7,V=V+v|0,b^=V,b=b>>>32-8|b<<8,pt=pt+b|0,v^=pt,v=v>>>32-7|v<<7,V=V+T|0,R^=V,R=R>>>32-16|R<<16,h=h+R|0,T^=h,T=T>>>32-12|T<<12,B=B+nt|0,b^=B,b=b>>>32-16|b<<16,y=y+b|0,nt^=y,nt=nt>>>32-12|nt<<12,z=z+ft|0,M^=z,M=M>>>32-16|M<<16,pt=pt+M|0,ft^=pt,ft=ft>>>32-12|ft<<12,$=$+v|0,C^=$,C=C>>>32-16|C<<16,mt=mt+C|0,v^=mt,v=v>>>32-12|v<<12,z=z+ft|0,M^=z,M=M>>>32-8|M<<8,pt=pt+M|0,ft^=pt,ft=ft>>>32-7|ft<<7,$=$+v|0,C^=$,C=C>>>32-8|C<<8,mt=mt+C|0,v^=mt,v=v>>>32-7|v<<7,B=B+nt|0,b^=B,b=b>>>32-8|b<<8,y=y+b|0,nt^=y,nt=nt>>>32-7|nt<<7,V=V+T|0,R^=V,R=R>>>32-8|R<<8,h=h+R|0,T^=h,T=T>>>32-7|T<<7;_r.writeUint32LE(V+i|0,r,0),_r.writeUint32LE(B+s|0,r,4),_r.writeUint32LE(z+a|0,r,8),_r.writeUint32LE($+u|0,r,12),_r.writeUint32LE(v+l|0,r,16),_r.writeUint32LE(T+m|0,r,20),_r.writeUint32LE(nt+f|0,r,24),_r.writeUint32LE(ft+w|0,r,28),_r.writeUint32LE(pt+E|0,r,32),_r.writeUint32LE(mt+x|0,r,36),_r.writeUint32LE(h+I|0,r,40),_r.writeUint32LE(y+N|0,r,44),_r.writeUint32LE(b+Y|0,r,48),_r.writeUint32LE(M+G|0,r,52),_r.writeUint32LE(C+tt|0,r,56),_r.writeUint32LE(R+K|0,r,60)}function B1(r,t,e,i,s){if(s===void 0&&(s=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<e.length)throw new Error("ChaCha: destination is shorter than source");var a,u;if(s===0){if(t.length!==8&&t.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");a=new Uint8Array(16),u=a.length-t.length,a.set(t,u)}else{if(t.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");a=t,u=s}for(var l=new Uint8Array(64),m=0;m<e.length;m+=64){u_(l,a,r);for(var f=m;f<m+64&&f<e.length;f++)i[f]=e[f]^l[f-m];l_(a,0,u)}return pl.wipe(l),s===0&&pl.wipe(a),i}nu.streamXOR=B1;function h_(r,t,e,i){return i===void 0&&(i=0),pl.wipe(e),B1(r,t,e,e,i)}nu.stream=h_;function l_(r,t,e){for(var i=1;e--;)i=i+(r[t]&255)|0,r[t]=i&255,i>>>=8,t++;if(i>0)throw new Error("ChaCha: counter overflow")}var L1={},Qn={};Object.defineProperty(Qn,"__esModule",{value:!0});function f_(r,t,e){return~(r-1)&t|r-1&e}Qn.select=f_;function d_(r,t){return(r|0)-(t|0)-1>>>31&1}Qn.lessOrEqual=d_;function q1(r,t){if(r.length!==t.length)return 0;for(var e=0,i=0;i<r.length;i++)e|=r[i]^t[i];return 1&e-1>>>8}Qn.compare=q1;function p_(r,t){return r.length===0||t.length===0?!1:q1(r,t)!==0}Qn.equal=p_;(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=Qn,e=si;r.DIGEST_LENGTH=16;var i=function(){function u(l){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 m=l[0]|l[1]<<8;this._r[0]=m&8191;var f=l[2]|l[3]<<8;this._r[1]=(m>>>13|f<<3)&8191;var w=l[4]|l[5]<<8;this._r[2]=(f>>>10|w<<6)&7939;var E=l[6]|l[7]<<8;this._r[3]=(w>>>7|E<<9)&8191;var x=l[8]|l[9]<<8;this._r[4]=(E>>>4|x<<12)&255,this._r[5]=x>>>1&8190;var I=l[10]|l[11]<<8;this._r[6]=(x>>>14|I<<2)&8191;var N=l[12]|l[13]<<8;this._r[7]=(I>>>11|N<<5)&8065;var Y=l[14]|l[15]<<8;this._r[8]=(N>>>8|Y<<8)&8191,this._r[9]=Y>>>5&127,this._pad[0]=l[16]|l[17]<<8,this._pad[1]=l[18]|l[19]<<8,this._pad[2]=l[20]|l[21]<<8,this._pad[3]=l[22]|l[23]<<8,this._pad[4]=l[24]|l[25]<<8,this._pad[5]=l[26]|l[27]<<8,this._pad[6]=l[28]|l[29]<<8,this._pad[7]=l[30]|l[31]<<8}return u.prototype._blocks=function(l,m,f){for(var w=this._fin?0:2048,E=this._h[0],x=this._h[1],I=this._h[2],N=this._h[3],Y=this._h[4],G=this._h[5],tt=this._h[6],K=this._h[7],V=this._h[8],B=this._h[9],z=this._r[0],$=this._r[1],v=this._r[2],T=this._r[3],nt=this._r[4],ft=this._r[5],pt=this._r[6],mt=this._r[7],h=this._r[8],y=this._r[9];f>=16;){var b=l[m+0]|l[m+1]<<8;E+=b&8191;var M=l[m+2]|l[m+3]<<8;x+=(b>>>13|M<<3)&8191;var C=l[m+4]|l[m+5]<<8;I+=(M>>>10|C<<6)&8191;var R=l[m+6]|l[m+7]<<8;N+=(C>>>7|R<<9)&8191;var j=l[m+8]|l[m+9]<<8;Y+=(R>>>4|j<<12)&8191,G+=j>>>1&8191;var S=l[m+10]|l[m+11]<<8;tt+=(j>>>14|S<<2)&8191;var p=l[m+12]|l[m+13]<<8;K+=(S>>>11|p<<5)&8191;var O=l[m+14]|l[m+15]<<8;V+=(p>>>8|O<<8)&8191,B+=O>>>5|w;var it=0,lt=it;lt+=E*z,lt+=x*(5*y),lt+=I*(5*h),lt+=N*(5*mt),lt+=Y*(5*pt),it=lt>>>13,lt&=8191,lt+=G*(5*ft),lt+=tt*(5*nt),lt+=K*(5*T),lt+=V*(5*v),lt+=B*(5*$),it+=lt>>>13,lt&=8191;var _=it;_+=E*$,_+=x*z,_+=I*(5*y),_+=N*(5*h),_+=Y*(5*mt),it=_>>>13,_&=8191,_+=G*(5*pt),_+=tt*(5*ft),_+=K*(5*nt),_+=V*(5*T),_+=B*(5*v),it+=_>>>13,_&=8191;var Z=it;Z+=E*v,Z+=x*$,Z+=I*z,Z+=N*(5*y),Z+=Y*(5*h),it=Z>>>13,Z&=8191,Z+=G*(5*mt),Z+=tt*(5*pt),Z+=K*(5*ft),Z+=V*(5*nt),Z+=B*(5*T),it+=Z>>>13,Z&=8191;var U=it;U+=E*T,U+=x*v,U+=I*$,U+=N*z,U+=Y*(5*y),it=U>>>13,U&=8191,U+=G*(5*h),U+=tt*(5*mt),U+=K*(5*pt),U+=V*(5*ft),U+=B*(5*nt),it+=U>>>13,U&=8191;var L=it;L+=E*nt,L+=x*T,L+=I*v,L+=N*$,L+=Y*z,it=L>>>13,L&=8191,L+=G*(5*y),L+=tt*(5*h),L+=K*(5*mt),L+=V*(5*pt),L+=B*(5*ft),it+=L>>>13,L&=8191;var k=it;k+=E*ft,k+=x*nt,k+=I*T,k+=N*v,k+=Y*$,it=k>>>13,k&=8191,k+=G*z,k+=tt*(5*y),k+=K*(5*h),k+=V*(5*mt),k+=B*(5*pt),it+=k>>>13,k&=8191;var d=it;d+=E*pt,d+=x*ft,d+=I*nt,d+=N*T,d+=Y*v,it=d>>>13,d&=8191,d+=G*$,d+=tt*z,d+=K*(5*y),d+=V*(5*h),d+=B*(5*mt),it+=d>>>13,d&=8191;var F=it;F+=E*mt,F+=x*pt,F+=I*ft,F+=N*nt,F+=Y*T,it=F>>>13,F&=8191,F+=G*v,F+=tt*$,F+=K*z,F+=V*(5*y),F+=B*(5*h),it+=F>>>13,F&=8191;var et=it;et+=E*h,et+=x*mt,et+=I*pt,et+=N*ft,et+=Y*nt,it=et>>>13,et&=8191,et+=G*T,et+=tt*v,et+=K*$,et+=V*z,et+=B*(5*y),it+=et>>>13,et&=8191;var ut=it;ut+=E*y,ut+=x*h,ut+=I*mt,ut+=N*pt,ut+=Y*ft,it=ut>>>13,ut&=8191,ut+=G*nt,ut+=tt*T,ut+=K*v,ut+=V*$,ut+=B*z,it+=ut>>>13,ut&=8191,it=(it<<2)+it|0,it=it+lt|0,lt=it&8191,it=it>>>13,_+=it,E=lt,x=_,I=Z,N=U,Y=L,G=k,tt=d,K=F,V=et,B=ut,m+=16,f-=16}this._h[0]=E,this._h[1]=x,this._h[2]=I,this._h[3]=N,this._h[4]=Y,this._h[5]=G,this._h[6]=tt,this._h[7]=K,this._h[8]=V,this._h[9]=B},u.prototype.finish=function(l,m){m===void 0&&(m=0);var f=new Uint16Array(10),w,E,x,I;if(this._leftover){for(I=this._leftover,this._buffer[I++]=1;I<16;I++)this._buffer[I]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(w=this._h[1]>>>13,this._h[1]&=8191,I=2;I<10;I++)this._h[I]+=w,w=this._h[I]>>>13,this._h[I]&=8191;for(this._h[0]+=w*5,w=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=w,w=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=w,f[0]=this._h[0]+5,w=f[0]>>>13,f[0]&=8191,I=1;I<10;I++)f[I]=this._h[I]+w,w=f[I]>>>13,f[I]&=8191;for(f[9]-=8192,E=(w^1)-1,I=0;I<10;I++)f[I]&=E;for(E=~E,I=0;I<10;I++)this._h[I]=this._h[I]&E|f[I];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,x=this._h[0]+this._pad[0],this._h[0]=x&65535,I=1;I<8;I++)x=(this._h[I]+this._pad[I]|0)+(x>>>16)|0,this._h[I]=x&65535;return l[m+0]=this._h[0]>>>0,l[m+1]=this._h[0]>>>8,l[m+2]=this._h[1]>>>0,l[m+3]=this._h[1]>>>8,l[m+4]=this._h[2]>>>0,l[m+5]=this._h[2]>>>8,l[m+6]=this._h[3]>>>0,l[m+7]=this._h[3]>>>8,l[m+8]=this._h[4]>>>0,l[m+9]=this._h[4]>>>8,l[m+10]=this._h[5]>>>0,l[m+11]=this._h[5]>>>8,l[m+12]=this._h[6]>>>0,l[m+13]=this._h[6]>>>8,l[m+14]=this._h[7]>>>0,l[m+15]=this._h[7]>>>8,this._finished=!0,this},u.prototype.update=function(l){var m=0,f=l.length,w;if(this._leftover){w=16-this._leftover,w>f&&(w=f);for(var E=0;E<w;E++)this._buffer[this._leftover+E]=l[m+E];if(f-=w,m+=w,this._leftover+=w,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(f>=16&&(w=f-f%16,this._blocks(l,m,w),m+=w,f-=w),f){for(var E=0;E<f;E++)this._buffer[this._leftover+E]=l[m+E];this._leftover+=f}return this},u.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var l=new Uint8Array(16);return this.finish(l),l},u.prototype.clean=function(){return e.wipe(this._buffer),e.wipe(this._r),e.wipe(this._h),e.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},u}();r.Poly1305=i;function s(u,l){var m=new i(u);m.update(l);var f=m.digest();return m.clean(),f}r.oneTimeAuth=s;function a(u,l){return u.length!==r.DIGEST_LENGTH||l.length!==r.DIGEST_LENGTH?!1:t.equal(u,l)}r.equal=a})(L1);(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=nu,e=L1,i=si,s=oe,a=Qn;r.KEY_LENGTH=32,r.NONCE_LENGTH=12,r.TAG_LENGTH=16;var u=new Uint8Array(16),l=function(){function m(f){if(this.nonceLength=r.NONCE_LENGTH,this.tagLength=r.TAG_LENGTH,f.length!==r.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(f)}return m.prototype.seal=function(f,w,E,x){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var I=new Uint8Array(16);I.set(f,I.length-f.length);var N=new Uint8Array(32);t.stream(this._key,I,N,4);var Y=w.length+this.tagLength,G;if(x){if(x.length!==Y)throw new Error("ChaCha20Poly1305: incorrect destination length");G=x}else G=new Uint8Array(Y);return t.streamXOR(this._key,I,w,G,4),this._authenticate(G.subarray(G.length-this.tagLength,G.length),N,G.subarray(0,G.length-this.tagLength),E),i.wipe(I),G},m.prototype.open=function(f,w,E,x){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(w.length<this.tagLength)return null;var I=new Uint8Array(16);I.set(f,I.length-f.length);var N=new Uint8Array(32);t.stream(this._key,I,N,4);var Y=new Uint8Array(this.tagLength);if(this._authenticate(Y,N,w.subarray(0,w.length-this.tagLength),E),!a.equal(Y,w.subarray(w.length-this.tagLength,w.length)))return null;var G=w.length-this.tagLength,tt;if(x){if(x.length!==G)throw new Error("ChaCha20Poly1305: incorrect destination length");tt=x}else tt=new Uint8Array(G);return t.streamXOR(this._key,I,w.subarray(0,w.length-this.tagLength),tt,4),i.wipe(I),tt},m.prototype.clean=function(){return i.wipe(this._key),this},m.prototype._authenticate=function(f,w,E,x){var I=new e.Poly1305(w);x&&(I.update(x),x.length%16>0&&I.update(u.subarray(x.length%16))),I.update(E),E.length%16>0&&I.update(u.subarray(E.length%16));var N=new Uint8Array(8);x&&s.writeUint64LE(x.length,N),I.update(N),s.writeUint64LE(E.length,N),I.update(N);for(var Y=I.digest(),G=0;G<Y.length;G++)f[G]=Y[G];I.clean(),i.wipe(Y),i.wipe(N)},m}();r.ChaCha20Poly1305=l})(ql);var j1={},ha={},jl={};Object.defineProperty(jl,"__esModule",{value:!0});function g_(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}jl.isSerializableHash=g_;Object.defineProperty(ha,"__esModule",{value:!0});var Gi=jl,m_=Qn,v_=si,$1=function(){function r(t,e){this._finished=!1,this._inner=new t,this._outer=new t,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);e.length>this.blockSize?this._inner.update(e).finish(i).clean():i.set(e);for(var s=0;s<i.length;s++)i[s]^=54;this._inner.update(i);for(var s=0;s<i.length;s++)i[s]^=106;this._outer.update(i),Gi.isSerializableHash(this._inner)&&Gi.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),v_.wipe(i)}return r.prototype.reset=function(){if(!Gi.isSerializableHash(this._inner)||!Gi.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.clean=function(){Gi.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Gi.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},r.prototype.update=function(t){return this._inner.update(t),this},r.prototype.finish=function(t){return this._finished?(this._outer.finish(t),this):(this._inner.finish(t),this._outer.update(t.subarray(0,this.digestLength)).finish(t),this._finished=!0,this)},r.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},r.prototype.saveState=function(){if(!Gi.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},r.prototype.restoreState=function(t){if(!Gi.isSerializableHash(this._inner)||!Gi.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(t),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.cleanSavedState=function(t){if(!Gi.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(t)},r}();ha.HMAC=$1;function y_(r,t,e){var i=new $1(r,t);i.update(e);var s=i.digest();return i.clean(),s}ha.hmac=y_;ha.equal=m_.equal;Object.defineProperty(j1,"__esModule",{value:!0});var Sd=ha,Id=si,w_=function(){function r(t,e,i,s){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=t,this._info=s;var a=Sd.hmac(this._hash,i,e);this._hmac=new Sd.HMAC(t,a),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var t=this._counter[0];if(t===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),t>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(t){for(var e=new Uint8Array(t),i=0;i<e.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),e[i]=this._buffer[this._bufpos++];return e},r.prototype.clean=function(){this._hmac.clean(),Id.wipe(this._buffer),Id.wipe(this._counter),this._bufpos=0},r}(),b_=j1.HKDF=w_,fo={},su={},ou={};Object.defineProperty(ou,"__esModule",{value:!0});ou.BrowserRandomSource=void 0;const Dd=65536;class __{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const t=typeof self<"u"?self.crypto||self.msCrypto:null;t&&t.getRandomValues!==void 0&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const e=new Uint8Array(t);for(let i=0;i<e.length;i+=Dd)this._crypto.getRandomValues(e.subarray(i,i+Math.min(e.length-i,Dd)));return e}}ou.BrowserRandomSource=__;var au={};Object.defineProperty(au,"__esModule",{value:!0});au.NodeRandomSource=void 0;const E_=si;class A_{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Z3<"u"){const t=t6();t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let e=this._crypto.randomBytes(t);if(e.length!==t)throw new Error("NodeRandomSource: got fewer bytes than requested");const i=new Uint8Array(t);for(let s=0;s<i.length;s++)i[s]=e[s];return(0,E_.wipe)(e),i}}au.NodeRandomSource=A_;Object.defineProperty(su,"__esModule",{value:!0});su.SystemRandomSource=void 0;const S_=ou,I_=au;class D_{constructor(){if(this.isAvailable=!1,this.name="",this._source=new S_.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new I_.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}}su.SystemRandomSource=D_;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.randomStringForEntropy=r.randomString=r.randomUint32=r.randomBytes=r.defaultRandomSource=void 0;const t=su,e=oe,i=si;r.defaultRandomSource=new t.SystemRandomSource;function s(f,w=r.defaultRandomSource){return w.randomBytes(f)}r.randomBytes=s;function a(f=r.defaultRandomSource){const w=s(4,f),E=(0,e.readUint32LE)(w);return(0,i.wipe)(w),E}r.randomUint32=a;const u="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function l(f,w=u,E=r.defaultRandomSource){if(w.length<2)throw new Error("randomString charset is too short");if(w.length>256)throw new Error("randomString charset is too long");let x="";const I=w.length,N=256-256%I;for(;f>0;){const Y=s(Math.ceil(f*256/N),E);for(let G=0;G<Y.length&&f>0;G++){const tt=Y[G];tt<N&&(x+=w.charAt(tt%I),f--)}(0,i.wipe)(Y)}return x}r.randomString=l;function m(f,w=u,E=r.defaultRandomSource){const x=Math.ceil(f/(Math.log(w.length)/Math.LN2));return l(x,w,E)}r.randomStringForEntropy=m})(fo);var cu={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=oe,e=si;r.DIGEST_LENGTH=32,r.BLOCK_SIZE=64;var i=function(){function l(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return l.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},l.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},l.prototype.clean=function(){e.wipe(this._buffer),e.wipe(this._temp),this.reset()},l.prototype.update=function(m,f){if(f===void 0&&(f=m.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var w=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&f>0;)this._buffer[this._bufferLength++]=m[w++],f--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(w=a(this._temp,this._state,m,w,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=m[w++],f--;return this},l.prototype.finish=function(m){if(!this._finished){var f=this._bytesHashed,w=this._bufferLength,E=f/536870912|0,x=f<<3,I=f%64<56?64:128;this._buffer[w]=128;for(var N=w+1;N<I-8;N++)this._buffer[N]=0;t.writeUint32BE(E,this._buffer,I-8),t.writeUint32BE(x,this._buffer,I-4),a(this._temp,this._state,this._buffer,0,I),this._finished=!0}for(var N=0;N<this.digestLength/4;N++)t.writeUint32BE(this._state[N],m,N*4);return this},l.prototype.digest=function(){var m=new Uint8Array(this.digestLength);return this.finish(m),m},l.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},l.prototype.restoreState=function(m){return this._state.set(m.state),this._bufferLength=m.bufferLength,m.buffer&&this._buffer.set(m.buffer),this._bytesHashed=m.bytesHashed,this._finished=!1,this},l.prototype.cleanSavedState=function(m){e.wipe(m.state),m.buffer&&e.wipe(m.buffer),m.bufferLength=0,m.bytesHashed=0},l}();r.SHA256=i;var s=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(l,m,f,w,E){for(;E>=64;){for(var x=m[0],I=m[1],N=m[2],Y=m[3],G=m[4],tt=m[5],K=m[6],V=m[7],B=0;B<16;B++){var z=w+B*4;l[B]=t.readUint32BE(f,z)}for(var B=16;B<64;B++){var $=l[B-2],v=($>>>17|$<<32-17)^($>>>19|$<<32-19)^$>>>10;$=l[B-15];var T=($>>>7|$<<32-7)^($>>>18|$<<32-18)^$>>>3;l[B]=(v+l[B-7]|0)+(T+l[B-16]|0)}for(var B=0;B<64;B++){var v=(((G>>>6|G<<26)^(G>>>11|G<<21)^(G>>>25|G<<7))+(G&tt^~G&K)|0)+(V+(s[B]+l[B]|0)|0)|0,T=((x>>>2|x<<32-2)^(x>>>13|x<<32-13)^(x>>>22|x<<32-22))+(x&I^x&N^I&N)|0;V=K,K=tt,tt=G,G=Y+v|0,Y=N,N=I,I=x,x=v+T|0}m[0]+=x,m[1]+=I,m[2]+=N,m[3]+=Y,m[4]+=G,m[5]+=tt,m[6]+=K,m[7]+=V,w+=64,E-=64}return w}function u(l){var m=new i;m.update(l);var f=m.digest();return m.clean(),f}r.hash=u})(cu);var $l={};(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 t=fo,e=si;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function i(B){const z=new Float64Array(16);if(B)for(let $=0;$<B.length;$++)z[$]=B[$];return z}const s=new Uint8Array(32);s[0]=9;const a=i([56129,1]);function u(B){let z=1;for(let $=0;$<16;$++){let v=B[$]+z+65535;z=Math.floor(v/65536),B[$]=v-z*65536}B[0]+=z-1+37*(z-1)}function l(B,z,$){const v=~($-1);for(let T=0;T<16;T++){const nt=v&(B[T]^z[T]);B[T]^=nt,z[T]^=nt}}function m(B,z){const $=i(),v=i();for(let T=0;T<16;T++)v[T]=z[T];u(v),u(v),u(v);for(let T=0;T<2;T++){$[0]=v[0]-65517;for(let ft=1;ft<15;ft++)$[ft]=v[ft]-65535-($[ft-1]>>16&1),$[ft-1]&=65535;$[15]=v[15]-32767-($[14]>>16&1);const nt=$[15]>>16&1;$[14]&=65535,l(v,$,1-nt)}for(let T=0;T<16;T++)B[2*T]=v[T]&255,B[2*T+1]=v[T]>>8}function f(B,z){for(let $=0;$<16;$++)B[$]=z[2*$]+(z[2*$+1]<<8);B[15]&=32767}function w(B,z,$){for(let v=0;v<16;v++)B[v]=z[v]+$[v]}function E(B,z,$){for(let v=0;v<16;v++)B[v]=z[v]-$[v]}function x(B,z,$){let v,T,nt=0,ft=0,pt=0,mt=0,h=0,y=0,b=0,M=0,C=0,R=0,j=0,S=0,p=0,O=0,it=0,lt=0,_=0,Z=0,U=0,L=0,k=0,d=0,F=0,et=0,ut=0,at=0,Mt=0,Pt=0,It=0,Ee=0,$t=0,xt=$[0],Bt=$[1],_t=$[2],Et=$[3],Vt=$[4],wt=$[5],At=$[6],Ut=$[7],bt=$[8],Ct=$[9],Lt=$[10],Ot=$[11],Nt=$[12],se=$[13],Tt=$[14],Rt=$[15];v=z[0],nt+=v*xt,ft+=v*Bt,pt+=v*_t,mt+=v*Et,h+=v*Vt,y+=v*wt,b+=v*At,M+=v*Ut,C+=v*bt,R+=v*Ct,j+=v*Lt,S+=v*Ot,p+=v*Nt,O+=v*se,it+=v*Tt,lt+=v*Rt,v=z[1],ft+=v*xt,pt+=v*Bt,mt+=v*_t,h+=v*Et,y+=v*Vt,b+=v*wt,M+=v*At,C+=v*Ut,R+=v*bt,j+=v*Ct,S+=v*Lt,p+=v*Ot,O+=v*Nt,it+=v*se,lt+=v*Tt,_+=v*Rt,v=z[2],pt+=v*xt,mt+=v*Bt,h+=v*_t,y+=v*Et,b+=v*Vt,M+=v*wt,C+=v*At,R+=v*Ut,j+=v*bt,S+=v*Ct,p+=v*Lt,O+=v*Ot,it+=v*Nt,lt+=v*se,_+=v*Tt,Z+=v*Rt,v=z[3],mt+=v*xt,h+=v*Bt,y+=v*_t,b+=v*Et,M+=v*Vt,C+=v*wt,R+=v*At,j+=v*Ut,S+=v*bt,p+=v*Ct,O+=v*Lt,it+=v*Ot,lt+=v*Nt,_+=v*se,Z+=v*Tt,U+=v*Rt,v=z[4],h+=v*xt,y+=v*Bt,b+=v*_t,M+=v*Et,C+=v*Vt,R+=v*wt,j+=v*At,S+=v*Ut,p+=v*bt,O+=v*Ct,it+=v*Lt,lt+=v*Ot,_+=v*Nt,Z+=v*se,U+=v*Tt,L+=v*Rt,v=z[5],y+=v*xt,b+=v*Bt,M+=v*_t,C+=v*Et,R+=v*Vt,j+=v*wt,S+=v*At,p+=v*Ut,O+=v*bt,it+=v*Ct,lt+=v*Lt,_+=v*Ot,Z+=v*Nt,U+=v*se,L+=v*Tt,k+=v*Rt,v=z[6],b+=v*xt,M+=v*Bt,C+=v*_t,R+=v*Et,j+=v*Vt,S+=v*wt,p+=v*At,O+=v*Ut,it+=v*bt,lt+=v*Ct,_+=v*Lt,Z+=v*Ot,U+=v*Nt,L+=v*se,k+=v*Tt,d+=v*Rt,v=z[7],M+=v*xt,C+=v*Bt,R+=v*_t,j+=v*Et,S+=v*Vt,p+=v*wt,O+=v*At,it+=v*Ut,lt+=v*bt,_+=v*Ct,Z+=v*Lt,U+=v*Ot,L+=v*Nt,k+=v*se,d+=v*Tt,F+=v*Rt,v=z[8],C+=v*xt,R+=v*Bt,j+=v*_t,S+=v*Et,p+=v*Vt,O+=v*wt,it+=v*At,lt+=v*Ut,_+=v*bt,Z+=v*Ct,U+=v*Lt,L+=v*Ot,k+=v*Nt,d+=v*se,F+=v*Tt,et+=v*Rt,v=z[9],R+=v*xt,j+=v*Bt,S+=v*_t,p+=v*Et,O+=v*Vt,it+=v*wt,lt+=v*At,_+=v*Ut,Z+=v*bt,U+=v*Ct,L+=v*Lt,k+=v*Ot,d+=v*Nt,F+=v*se,et+=v*Tt,ut+=v*Rt,v=z[10],j+=v*xt,S+=v*Bt,p+=v*_t,O+=v*Et,it+=v*Vt,lt+=v*wt,_+=v*At,Z+=v*Ut,U+=v*bt,L+=v*Ct,k+=v*Lt,d+=v*Ot,F+=v*Nt,et+=v*se,ut+=v*Tt,at+=v*Rt,v=z[11],S+=v*xt,p+=v*Bt,O+=v*_t,it+=v*Et,lt+=v*Vt,_+=v*wt,Z+=v*At,U+=v*Ut,L+=v*bt,k+=v*Ct,d+=v*Lt,F+=v*Ot,et+=v*Nt,ut+=v*se,at+=v*Tt,Mt+=v*Rt,v=z[12],p+=v*xt,O+=v*Bt,it+=v*_t,lt+=v*Et,_+=v*Vt,Z+=v*wt,U+=v*At,L+=v*Ut,k+=v*bt,d+=v*Ct,F+=v*Lt,et+=v*Ot,ut+=v*Nt,at+=v*se,Mt+=v*Tt,Pt+=v*Rt,v=z[13],O+=v*xt,it+=v*Bt,lt+=v*_t,_+=v*Et,Z+=v*Vt,U+=v*wt,L+=v*At,k+=v*Ut,d+=v*bt,F+=v*Ct,et+=v*Lt,ut+=v*Ot,at+=v*Nt,Mt+=v*se,Pt+=v*Tt,It+=v*Rt,v=z[14],it+=v*xt,lt+=v*Bt,_+=v*_t,Z+=v*Et,U+=v*Vt,L+=v*wt,k+=v*At,d+=v*Ut,F+=v*bt,et+=v*Ct,ut+=v*Lt,at+=v*Ot,Mt+=v*Nt,Pt+=v*se,It+=v*Tt,Ee+=v*Rt,v=z[15],lt+=v*xt,_+=v*Bt,Z+=v*_t,U+=v*Et,L+=v*Vt,k+=v*wt,d+=v*At,F+=v*Ut,et+=v*bt,ut+=v*Ct,at+=v*Lt,Mt+=v*Ot,Pt+=v*Nt,It+=v*se,Ee+=v*Tt,$t+=v*Rt,nt+=38*_,ft+=38*Z,pt+=38*U,mt+=38*L,h+=38*k,y+=38*d,b+=38*F,M+=38*et,C+=38*ut,R+=38*at,j+=38*Mt,S+=38*Pt,p+=38*It,O+=38*Ee,it+=38*$t,T=1,v=nt+T+65535,T=Math.floor(v/65536),nt=v-T*65536,v=ft+T+65535,T=Math.floor(v/65536),ft=v-T*65536,v=pt+T+65535,T=Math.floor(v/65536),pt=v-T*65536,v=mt+T+65535,T=Math.floor(v/65536),mt=v-T*65536,v=h+T+65535,T=Math.floor(v/65536),h=v-T*65536,v=y+T+65535,T=Math.floor(v/65536),y=v-T*65536,v=b+T+65535,T=Math.floor(v/65536),b=v-T*65536,v=M+T+65535,T=Math.floor(v/65536),M=v-T*65536,v=C+T+65535,T=Math.floor(v/65536),C=v-T*65536,v=R+T+65535,T=Math.floor(v/65536),R=v-T*65536,v=j+T+65535,T=Math.floor(v/65536),j=v-T*65536,v=S+T+65535,T=Math.floor(v/65536),S=v-T*65536,v=p+T+65535,T=Math.floor(v/65536),p=v-T*65536,v=O+T+65535,T=Math.floor(v/65536),O=v-T*65536,v=it+T+65535,T=Math.floor(v/65536),it=v-T*65536,v=lt+T+65535,T=Math.floor(v/65536),lt=v-T*65536,nt+=T-1+37*(T-1),T=1,v=nt+T+65535,T=Math.floor(v/65536),nt=v-T*65536,v=ft+T+65535,T=Math.floor(v/65536),ft=v-T*65536,v=pt+T+65535,T=Math.floor(v/65536),pt=v-T*65536,v=mt+T+65535,T=Math.floor(v/65536),mt=v-T*65536,v=h+T+65535,T=Math.floor(v/65536),h=v-T*65536,v=y+T+65535,T=Math.floor(v/65536),y=v-T*65536,v=b+T+65535,T=Math.floor(v/65536),b=v-T*65536,v=M+T+65535,T=Math.floor(v/65536),M=v-T*65536,v=C+T+65535,T=Math.floor(v/65536),C=v-T*65536,v=R+T+65535,T=Math.floor(v/65536),R=v-T*65536,v=j+T+65535,T=Math.floor(v/65536),j=v-T*65536,v=S+T+65535,T=Math.floor(v/65536),S=v-T*65536,v=p+T+65535,T=Math.floor(v/65536),p=v-T*65536,v=O+T+65535,T=Math.floor(v/65536),O=v-T*65536,v=it+T+65535,T=Math.floor(v/65536),it=v-T*65536,v=lt+T+65535,T=Math.floor(v/65536),lt=v-T*65536,nt+=T-1+37*(T-1),B[0]=nt,B[1]=ft,B[2]=pt,B[3]=mt,B[4]=h,B[5]=y,B[6]=b,B[7]=M,B[8]=C,B[9]=R,B[10]=j,B[11]=S,B[12]=p,B[13]=O,B[14]=it,B[15]=lt}function I(B,z){x(B,z,z)}function N(B,z){const $=i();for(let v=0;v<16;v++)$[v]=z[v];for(let v=253;v>=0;v--)I($,$),v!==2&&v!==4&&x($,$,z);for(let v=0;v<16;v++)B[v]=$[v]}function Y(B,z){const $=new Uint8Array(32),v=new Float64Array(80),T=i(),nt=i(),ft=i(),pt=i(),mt=i(),h=i();for(let C=0;C<31;C++)$[C]=B[C];$[31]=B[31]&127|64,$[0]&=248,f(v,z);for(let C=0;C<16;C++)nt[C]=v[C];T[0]=pt[0]=1;for(let C=254;C>=0;--C){const R=$[C>>>3]>>>(C&7)&1;l(T,nt,R),l(ft,pt,R),w(mt,T,ft),E(T,T,ft),w(ft,nt,pt),E(nt,nt,pt),I(pt,mt),I(h,T),x(T,ft,T),x(ft,nt,mt),w(mt,T,ft),E(T,T,ft),I(nt,T),E(ft,pt,h),x(T,ft,a),w(T,T,pt),x(ft,ft,T),x(T,pt,h),x(pt,nt,v),I(nt,mt),l(T,nt,R),l(ft,pt,R)}for(let C=0;C<16;C++)v[C+16]=T[C],v[C+32]=ft[C],v[C+48]=nt[C],v[C+64]=pt[C];const y=v.subarray(32),b=v.subarray(16);N(y,y),x(b,b,y);const M=new Uint8Array(32);return m(M,b),M}r.scalarMult=Y;function G(B){return Y(B,s)}r.scalarMultBase=G;function tt(B){if(B.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const z=new Uint8Array(B);return{publicKey:G(z),secretKey:z}}r.generateKeyPairFromSeed=tt;function K(B){const z=(0,t.randomBytes)(32,B),$=tt(z);return(0,e.wipe)(z),$}r.generateKeyPair=K;function V(B,z,$=!1){if(B.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(z.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const v=Y(B,z);if($){let T=0;for(let nt=0;nt<v.length;nt++)T|=v[nt];if(T===0)throw new Error("X25519: invalid shared key")}return v}r.sharedKey=V})($l);function z1(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function gl(r,t){t||(t=r.reduce((s,a)=>s+a.length,0));const e=z1(t);let i=0;for(const s of r)e.set(s,i),i+=s.length;return e}function x_(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),i=0;i<e.length;i++)e[i]=255;for(var s=0;s<r.length;s++){var a=r.charAt(s),u=a.charCodeAt(0);if(e[u]!==255)throw new TypeError(a+" is ambiguous");e[u]=s}var l=r.length,m=r.charAt(0),f=Math.log(l)/Math.log(256),w=Math.log(256)/Math.log(l);function E(N){if(N instanceof Uint8Array||(ArrayBuffer.isView(N)?N=new Uint8Array(N.buffer,N.byteOffset,N.byteLength):Array.isArray(N)&&(N=Uint8Array.from(N))),!(N instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(N.length===0)return"";for(var Y=0,G=0,tt=0,K=N.length;tt!==K&&N[tt]===0;)tt++,Y++;for(var V=(K-tt)*w+1>>>0,B=new Uint8Array(V);tt!==K;){for(var z=N[tt],$=0,v=V-1;(z!==0||$<G)&&v!==-1;v--,$++)z+=256*B[v]>>>0,B[v]=z%l>>>0,z=z/l>>>0;if(z!==0)throw new Error("Non-zero carry");G=$,tt++}for(var T=V-G;T!==V&&B[T]===0;)T++;for(var nt=m.repeat(Y);T<V;++T)nt+=r.charAt(B[T]);return nt}function x(N){if(typeof N!="string")throw new TypeError("Expected String");if(N.length===0)return new Uint8Array;var Y=0;if(N[Y]!==" "){for(var G=0,tt=0;N[Y]===m;)G++,Y++;for(var K=(N.length-Y)*f+1>>>0,V=new Uint8Array(K);N[Y];){var B=e[N.charCodeAt(Y)];if(B===255)return;for(var z=0,$=K-1;(B!==0||z<tt)&&$!==-1;$--,z++)B+=l*V[$]>>>0,V[$]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");tt=z,Y++}if(N[Y]!==" "){for(var v=K-tt;v!==K&&V[v]===0;)v++;for(var T=new Uint8Array(G+(K-v)),nt=G;v!==K;)T[nt++]=V[v++];return T}}}function I(N){var Y=x(N);if(Y)return Y;throw new Error(`Non-${t} character`)}return{encode:E,decodeUnsafe:x,decode:I}}var M_=x_,C_=M_;const P_=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")},O_=r=>new TextEncoder().encode(r),N_=r=>new TextDecoder().decode(r);class R_{constructor(t,e,i){this.name=t,this.prefix=e,this.baseEncode=i}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class T_{constructor(t,e,i){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=i}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return k1(this,t)}}class F_{constructor(t){this.decoders=t}or(t){return k1(this,t)}decode(t){const e=t[0],i=this.decoders[e];if(i)return i.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const k1=(r,t)=>new F_({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});class U_{constructor(t,e,i,s){this.name=t,this.prefix=e,this.baseEncode=i,this.baseDecode=s,this.encoder=new R_(t,e,i),this.decoder=new T_(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const uu=({name:r,prefix:t,encode:e,decode:i})=>new U_(r,t,e,i),la=({prefix:r,name:t,alphabet:e})=>{const{encode:i,decode:s}=C_(e,t);return uu({prefix:r,name:t,encode:i,decode:a=>P_(s(a))})},B_=(r,t,e,i)=>{const s={};for(let w=0;w<t.length;++w)s[t[w]]=w;let a=r.length;for(;r[a-1]==="=";)--a;const u=new Uint8Array(a*e/8|0);let l=0,m=0,f=0;for(let w=0;w<a;++w){const E=s[r[w]];if(E===void 0)throw new SyntaxError(`Non-${i} character`);m=m<<e|E,l+=e,l>=8&&(l-=8,u[f++]=255&m>>l)}if(l>=e||255&m<<8-l)throw new SyntaxError("Unexpected end of data");return u},L_=(r,t,e)=>{const i=t[t.length-1]==="=",s=(1<<e)-1;let a="",u=0,l=0;for(let m=0;m<r.length;++m)for(l=l<<8|r[m],u+=8;u>e;)u-=e,a+=t[s&l>>u];if(u&&(a+=t[s&l<<e-u]),i)for(;a.length*e&7;)a+="=";return a},vr=({name:r,prefix:t,bitsPerChar:e,alphabet:i})=>uu({prefix:t,name:r,encode(s){return L_(s,i,e)},decode(s){return B_(s,i,e,r)}}),q_=uu({prefix:"\0",name:"identity",encode:r=>N_(r),decode:r=>O_(r)}),j_=Object.freeze(Object.defineProperty({__proto__:null,identity:q_},Symbol.toStringTag,{value:"Module"})),$_=vr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),z_=Object.freeze(Object.defineProperty({__proto__:null,base2:$_},Symbol.toStringTag,{value:"Module"})),k_=vr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),H_=Object.freeze(Object.defineProperty({__proto__:null,base8:k_},Symbol.toStringTag,{value:"Module"})),K_=la({prefix:"9",name:"base10",alphabet:"0123456789"}),V_=Object.freeze(Object.defineProperty({__proto__:null,base10:K_},Symbol.toStringTag,{value:"Module"})),G_=vr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),W_=vr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Y_=Object.freeze(Object.defineProperty({__proto__:null,base16:G_,base16upper:W_},Symbol.toStringTag,{value:"Module"})),Q_=vr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),J_=vr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),X_=vr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Z_=vr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tE=vr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),eE=vr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rE=vr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),iE=vr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nE=vr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),sE=Object.freeze(Object.defineProperty({__proto__:null,base32:Q_,base32hex:tE,base32hexpad:rE,base32hexpadupper:iE,base32hexupper:eE,base32pad:X_,base32padupper:Z_,base32upper:J_,base32z:nE},Symbol.toStringTag,{value:"Module"})),oE=la({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),aE=la({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),cE=Object.freeze(Object.defineProperty({__proto__:null,base36:oE,base36upper:aE},Symbol.toStringTag,{value:"Module"})),uE=la({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),hE=la({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),lE=Object.freeze(Object.defineProperty({__proto__:null,base58btc:uE,base58flickr:hE},Symbol.toStringTag,{value:"Module"})),fE=vr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),dE=vr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pE=vr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),gE=vr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),mE=Object.freeze(Object.defineProperty({__proto__:null,base64:fE,base64pad:dE,base64url:pE,base64urlpad:gE},Symbol.toStringTag,{value:"Module"})),H1=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),vE=H1.reduce((r,t,e)=>(r[e]=t,r),[]),yE=H1.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function wE(r){return r.reduce((t,e)=>(t+=vE[e],t),"")}function bE(r){const t=[];for(const e of r){const i=yE[e.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(i)}return new Uint8Array(t)}const _E=uu({prefix:"🚀",name:"base256emoji",encode:wE,decode:bE}),EE=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:_E},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const xd={...j_,...z_,...H_,...V_,...Y_,...sE,...cE,...lE,...mE,...EE};function K1(r,t,e,i){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:i}}}const Md=K1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Oh=K1("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);const t=z1(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),V1={utf8:Md,"utf-8":Md,hex:xd.base16,latin1:Oh,ascii:Oh,binary:Oh,...xd};function Kr(r,t="utf8"){const e=V1[t];if(!e)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):e.decoder.decode(`${e.prefix}${r}`)}function Tr(r,t="utf8"){const e=V1[t];if(!e)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}const AE={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"}},SE=":";function Tc(r){const[t,e]=r.split(SE);return{namespace:t,reference:e}}function Cd(r,t=[]){const e=[];return Object.keys(r).forEach(i=>{if(t.length&&!t.includes(i))return;const s=r[i];e.push(...s.accounts)}),e}function G1(r,t){return r.includes(":")?[r]:t.chains||[]}var IE=Object.defineProperty,Pd=Object.getOwnPropertySymbols,DE=Object.prototype.hasOwnProperty,xE=Object.prototype.propertyIsEnumerable,Od=(r,t,e)=>t in r?IE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nd=(r,t)=>{for(var e in t||(t={}))DE.call(t,e)&&Od(r,e,t[e]);if(Pd)for(var e of Pd(t))xE.call(t,e)&&Od(r,e,t[e]);return r};const ME="ReactNative",ei={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},CE="js";function ra(){return typeof ri<"u"&&typeof ri.versions<"u"&&typeof ri.versions.node<"u"}function po(){return!Ul()&&!!Bl()&&navigator.product===ME}function go(){return!ra()&&!!Bl()&&!!Ul()}function fa(){return po()?ei.reactNative:ra()?ei.node:go()?ei.browser:ei.unknown}function PE(){var r;try{return po()&&typeof Ie<"u"&&typeof(Ie==null?void 0:Ie.Application)<"u"?(r=Ie.Application)==null?void 0:r.applicationId:void 0}catch{return}}function OE(r,t){let e=ea.parse(r);return e=Nd(Nd({},e),t),r=ea.stringify(e),r}function NE(){return C1()||{name:"",description:"",url:"",icons:[""]}}function RE(){if(fa()===ei.reactNative&&typeof Ie<"u"&&typeof(Ie==null?void 0:Ie.Platform)<"u"){const{OS:e,Version:i}=Ie.Platform;return[e,i].join("-")}const r=l6();if(r===null)return"unknown";const t=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[t,r.name,r.version].join("-"):[t,r.version].join("-")}function TE(){var r;const t=fa();return t===ei.browser?[t,((r=M1())==null?void 0:r.host)||"unknown"].join(":"):t}function FE(r,t,e){const i=RE(),s=TE();return[[r,t].join("-"),[CE,e].join("-"),i,s].join("/")}function UE({protocol:r,version:t,relayUrl:e,sdkVersion:i,auth:s,projectId:a,useOnCloseEvent:u,bundleId:l}){const m=e.split("?"),f=FE(r,t,i),w={auth:s,ua:f,projectId:a,useOnCloseEvent:u||void 0,origin:l||void 0},E=OE(m[1]||"",w);return m[0]+"?"+E}function Es(r,t){return r.filter(e=>t.includes(e)).length===r.length}function W1(r){return Object.fromEntries(r.entries())}function Y1(r){return new Map(Object.entries(r))}function _s(r=yt.FIVE_MINUTES,t){const e=yt.toMiliseconds(r||yt.FIVE_MINUTES);let i,s,a;return{resolve:u=>{a&&i&&(clearTimeout(a),i(u))},reject:u=>{a&&s&&(clearTimeout(a),s(u))},done:()=>new Promise((u,l)=>{a=setTimeout(()=>{l(new Error(t))},e),i=u,s=l})}}function so(r,t,e){return new Promise(async(i,s)=>{const a=setTimeout(()=>s(new Error(e)),t);try{const u=await r;i(u)}catch(u){s(u)}clearTimeout(a)})}function Q1(r,t){if(typeof t=="string"&&t.startsWith(`${r}:`))return t;if(r.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(r.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${r}`)}function BE(r){return Q1("topic",r)}function LE(r){return Q1("id",r)}function J1(r){const[t,e]=r.split(":"),i={id:void 0,topic:void 0};if(t==="topic"&&typeof e=="string")i.topic=e;else if(t==="id"&&Number.isInteger(Number(e)))i.id=Number(e);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${e}`);return i}function gr(r,t){return yt.fromMiliseconds((t||Date.now())+yt.toMiliseconds(r))}function Hn(r){return Date.now()>=yt.toMiliseconds(r)}function de(r,t){return`${r}${t?`:${t}`:""}`}function Fc(r=[],t=[]){return[...new Set([...r,...t])]}async function qE({id:r,topic:t,wcDeepLink:e}){try{if(!e)return;const i=typeof e=="string"?JSON.parse(e):e;let s=i==null?void 0:i.href;if(typeof s!="string")return;s.endsWith("/")&&(s=s.slice(0,-1));const a=`${s}/wc?requestId=${r}&sessionTopic=${t}`,u=fa();u===ei.browser?a.startsWith("https://")||a.startsWith("http://")?window.open(a,"_blank","noreferrer noopener"):window.open(a,"_self","noreferrer noopener"):u===ei.reactNative&&typeof(Ie==null?void 0:Ie.Linking)<"u"&&await Ie.Linking.openURL(a)}catch(i){console.error(i)}}async function jE(r,t){try{return await r.getItem(t)||(go()?localStorage.getItem(t):void 0)}catch(e){console.error(e)}}var X1=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ie<"u"?Ie:typeof self<"u"?self:{};function $E(r){var t=r.default;if(typeof t=="function"){var e=function(){return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var Z1={exports:{}};/**
2
+ * [js-sha3]{@link https://github.com/emn178/js-sha3}
3
+ *
4
+ * @version 0.8.0
5
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
6
+ * @copyright Chen, Yi-Cyuan 2015-2018
7
+ * @license MIT
8
+ */(function(r){(function(){var t="input is invalid type",e="finalize already called",i=typeof window=="object",s=i?window:{};s.JS_SHA3_NO_WINDOW&&(i=!1);var a=!i&&typeof self=="object",u=!s.JS_SHA3_NO_NODE_JS&&typeof ri=="object"&&ri.versions&&ri.versions.node;u?s=X1:a&&(s=self);var l=!s.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,m=!s.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),w=[31,7936,2031616,520093696],E=[4,1024,262144,67108864],x=[1,256,65536,16777216],I=[6,1536,393216,100663296],N=[0,8,16,24],Y=[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],G=[224,256,384,512],tt=[128,256],K=["hex","buffer","arrayBuffer","array","digest"],V={128:168,256:136};(s.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(_){return Object.prototype.toString.call(_)==="[object Array]"}),m&&(s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(_){return typeof _=="object"&&_.buffer&&_.buffer.constructor===ArrayBuffer});for(var B=function(_,Z,U){return function(L){return new O(_,Z,_).update(L)[U]()}},z=function(_,Z,U){return function(L,k){return new O(_,Z,k).update(L)[U]()}},$=function(_,Z,U){return function(L,k,d,F){return y["cshake"+_].update(L,k,d,F)[U]()}},v=function(_,Z,U){return function(L,k,d,F){return y["kmac"+_].update(L,k,d,F)[U]()}},T=function(_,Z,U,L){for(var k=0;k<K.length;++k){var d=K[k];_[d]=Z(U,L,d)}return _},nt=function(_,Z){var U=B(_,Z,"hex");return U.create=function(){return new O(_,Z,_)},U.update=function(L){return U.create().update(L)},T(U,B,_,Z)},ft=function(_,Z){var U=z(_,Z,"hex");return U.create=function(L){return new O(_,Z,L)},U.update=function(L,k){return U.create(k).update(L)},T(U,z,_,Z)},pt=function(_,Z){var U=V[_],L=$(_,Z,"hex");return L.create=function(k,d,F){return!d&&!F?y["shake"+_].create(k):new O(_,Z,k).bytepad([d,F],U)},L.update=function(k,d,F,et){return L.create(d,F,et).update(k)},T(L,$,_,Z)},mt=function(_,Z){var U=V[_],L=v(_,Z,"hex");return L.create=function(k,d,F){return new it(_,Z,d).bytepad(["KMAC",F],U).bytepad([k],U)},L.update=function(k,d,F,et){return L.create(k,F,et).update(d)},T(L,v,_,Z)},h=[{name:"keccak",padding:x,bits:G,createMethod:nt},{name:"sha3",padding:I,bits:G,createMethod:nt},{name:"shake",padding:w,bits:tt,createMethod:ft},{name:"cshake",padding:E,bits:tt,createMethod:pt},{name:"kmac",padding:E,bits:tt,createMethod:mt}],y={},b=[],M=0;M<h.length;++M)for(var C=h[M],R=C.bits,j=0;j<R.length;++j){var S=C.name+"_"+R[j];if(b.push(S),y[S]=C.createMethod(R[j],C.padding),C.name!=="sha3"){var p=C.name+R[j];b.push(p),y[p]=y[S]}}function O(_,Z,U){this.blocks=[],this.s=[],this.padding=Z,this.outputBits=U,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(_<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=U>>5,this.extraBytes=(U&31)>>3;for(var L=0;L<50;++L)this.s[L]=0}O.prototype.update=function(_){if(this.finalized)throw new Error(e);var Z,U=typeof _;if(U!=="string"){if(U==="object"){if(_===null)throw new Error(t);if(m&&_.constructor===ArrayBuffer)_=new Uint8Array(_);else if(!Array.isArray(_)&&(!m||!ArrayBuffer.isView(_)))throw new Error(t)}else throw new Error(t);Z=!0}for(var L=this.blocks,k=this.byteCount,d=_.length,F=this.blockCount,et=0,ut=this.s,at,Mt;et<d;){if(this.reset)for(this.reset=!1,L[0]=this.block,at=1;at<F+1;++at)L[at]=0;if(Z)for(at=this.start;et<d&&at<k;++et)L[at>>2]|=_[et]<<N[at++&3];else for(at=this.start;et<d&&at<k;++et)Mt=_.charCodeAt(et),Mt<128?L[at>>2]|=Mt<<N[at++&3]:Mt<2048?(L[at>>2]|=(192|Mt>>6)<<N[at++&3],L[at>>2]|=(128|Mt&63)<<N[at++&3]):Mt<55296||Mt>=57344?(L[at>>2]|=(224|Mt>>12)<<N[at++&3],L[at>>2]|=(128|Mt>>6&63)<<N[at++&3],L[at>>2]|=(128|Mt&63)<<N[at++&3]):(Mt=65536+((Mt&1023)<<10|_.charCodeAt(++et)&1023),L[at>>2]|=(240|Mt>>18)<<N[at++&3],L[at>>2]|=(128|Mt>>12&63)<<N[at++&3],L[at>>2]|=(128|Mt>>6&63)<<N[at++&3],L[at>>2]|=(128|Mt&63)<<N[at++&3]);if(this.lastByteIndex=at,at>=k){for(this.start=at-k,this.block=L[F],at=0;at<F;++at)ut[at]^=L[at];lt(ut),this.reset=!0}else this.start=at}return this},O.prototype.encode=function(_,Z){var U=_&255,L=1,k=[U];for(_=_>>8,U=_&255;U>0;)k.unshift(U),_=_>>8,U=_&255,++L;return Z?k.push(L):k.unshift(L),this.update(k),k.length},O.prototype.encodeString=function(_){var Z,U=typeof _;if(U!=="string"){if(U==="object"){if(_===null)throw new Error(t);if(m&&_.constructor===ArrayBuffer)_=new Uint8Array(_);else if(!Array.isArray(_)&&(!m||!ArrayBuffer.isView(_)))throw new Error(t)}else throw new Error(t);Z=!0}var L=0,k=_.length;if(Z)L=k;else for(var d=0;d<_.length;++d){var F=_.charCodeAt(d);F<128?L+=1:F<2048?L+=2:F<55296||F>=57344?L+=3:(F=65536+((F&1023)<<10|_.charCodeAt(++d)&1023),L+=4)}return L+=this.encode(L*8),this.update(_),L},O.prototype.bytepad=function(_,Z){for(var U=this.encode(Z),L=0;L<_.length;++L)U+=this.encodeString(_[L]);var k=Z-U%Z,d=[];return d.length=k,this.update(d),this},O.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var _=this.blocks,Z=this.lastByteIndex,U=this.blockCount,L=this.s;if(_[Z>>2]|=this.padding[Z&3],this.lastByteIndex===this.byteCount)for(_[0]=_[U],Z=1;Z<U+1;++Z)_[Z]=0;for(_[U-1]|=2147483648,Z=0;Z<U;++Z)L[Z]^=_[Z];lt(L)}},O.prototype.toString=O.prototype.hex=function(){this.finalize();for(var _=this.blockCount,Z=this.s,U=this.outputBlocks,L=this.extraBytes,k=0,d=0,F="",et;d<U;){for(k=0;k<_&&d<U;++k,++d)et=Z[k],F+=f[et>>4&15]+f[et&15]+f[et>>12&15]+f[et>>8&15]+f[et>>20&15]+f[et>>16&15]+f[et>>28&15]+f[et>>24&15];d%_===0&&(lt(Z),k=0)}return L&&(et=Z[k],F+=f[et>>4&15]+f[et&15],L>1&&(F+=f[et>>12&15]+f[et>>8&15]),L>2&&(F+=f[et>>20&15]+f[et>>16&15])),F},O.prototype.arrayBuffer=function(){this.finalize();var _=this.blockCount,Z=this.s,U=this.outputBlocks,L=this.extraBytes,k=0,d=0,F=this.outputBits>>3,et;L?et=new ArrayBuffer(U+1<<2):et=new ArrayBuffer(F);for(var ut=new Uint32Array(et);d<U;){for(k=0;k<_&&d<U;++k,++d)ut[d]=Z[k];d%_===0&&lt(Z)}return L&&(ut[k]=Z[k],et=et.slice(0,F)),et},O.prototype.buffer=O.prototype.arrayBuffer,O.prototype.digest=O.prototype.array=function(){this.finalize();for(var _=this.blockCount,Z=this.s,U=this.outputBlocks,L=this.extraBytes,k=0,d=0,F=[],et,ut;d<U;){for(k=0;k<_&&d<U;++k,++d)et=d<<2,ut=Z[k],F[et]=ut&255,F[et+1]=ut>>8&255,F[et+2]=ut>>16&255,F[et+3]=ut>>24&255;d%_===0&&lt(Z)}return L&&(et=d<<2,ut=Z[k],F[et]=ut&255,L>1&&(F[et+1]=ut>>8&255),L>2&&(F[et+2]=ut>>16&255)),F};function it(_,Z,U){O.call(this,_,Z,U)}it.prototype=new O,it.prototype.finalize=function(){return this.encode(this.outputBits,!0),O.prototype.finalize.call(this)};var lt=function(_){var Z,U,L,k,d,F,et,ut,at,Mt,Pt,It,Ee,$t,xt,Bt,_t,Et,Vt,wt,At,Ut,bt,Ct,Lt,Ot,Nt,se,Tt,Rt,Ke,ce,pe,Ve,ye,_e,Ar,Gt,zt,De,Wt,Kt,Ae,Jt,Xt,xe,Zt,Yt,Ce,Qt,qt,Te,te,Pe,xi,Oe,le,oi,ai,ci,ui,hi,ar;for(L=0;L<48;L+=2)k=_[0]^_[10]^_[20]^_[30]^_[40],d=_[1]^_[11]^_[21]^_[31]^_[41],F=_[2]^_[12]^_[22]^_[32]^_[42],et=_[3]^_[13]^_[23]^_[33]^_[43],ut=_[4]^_[14]^_[24]^_[34]^_[44],at=_[5]^_[15]^_[25]^_[35]^_[45],Mt=_[6]^_[16]^_[26]^_[36]^_[46],Pt=_[7]^_[17]^_[27]^_[37]^_[47],It=_[8]^_[18]^_[28]^_[38]^_[48],Ee=_[9]^_[19]^_[29]^_[39]^_[49],Z=It^(F<<1|et>>>31),U=Ee^(et<<1|F>>>31),_[0]^=Z,_[1]^=U,_[10]^=Z,_[11]^=U,_[20]^=Z,_[21]^=U,_[30]^=Z,_[31]^=U,_[40]^=Z,_[41]^=U,Z=k^(ut<<1|at>>>31),U=d^(at<<1|ut>>>31),_[2]^=Z,_[3]^=U,_[12]^=Z,_[13]^=U,_[22]^=Z,_[23]^=U,_[32]^=Z,_[33]^=U,_[42]^=Z,_[43]^=U,Z=F^(Mt<<1|Pt>>>31),U=et^(Pt<<1|Mt>>>31),_[4]^=Z,_[5]^=U,_[14]^=Z,_[15]^=U,_[24]^=Z,_[25]^=U,_[34]^=Z,_[35]^=U,_[44]^=Z,_[45]^=U,Z=ut^(It<<1|Ee>>>31),U=at^(Ee<<1|It>>>31),_[6]^=Z,_[7]^=U,_[16]^=Z,_[17]^=U,_[26]^=Z,_[27]^=U,_[36]^=Z,_[37]^=U,_[46]^=Z,_[47]^=U,Z=Mt^(k<<1|d>>>31),U=Pt^(d<<1|k>>>31),_[8]^=Z,_[9]^=U,_[18]^=Z,_[19]^=U,_[28]^=Z,_[29]^=U,_[38]^=Z,_[39]^=U,_[48]^=Z,_[49]^=U,$t=_[0],xt=_[1],xe=_[11]<<4|_[10]>>>28,Zt=_[10]<<4|_[11]>>>28,se=_[20]<<3|_[21]>>>29,Tt=_[21]<<3|_[20]>>>29,ci=_[31]<<9|_[30]>>>23,ui=_[30]<<9|_[31]>>>23,Kt=_[40]<<18|_[41]>>>14,Ae=_[41]<<18|_[40]>>>14,Ve=_[2]<<1|_[3]>>>31,ye=_[3]<<1|_[2]>>>31,Bt=_[13]<<12|_[12]>>>20,_t=_[12]<<12|_[13]>>>20,Yt=_[22]<<10|_[23]>>>22,Ce=_[23]<<10|_[22]>>>22,Rt=_[33]<<13|_[32]>>>19,Ke=_[32]<<13|_[33]>>>19,hi=_[42]<<2|_[43]>>>30,ar=_[43]<<2|_[42]>>>30,Pe=_[5]<<30|_[4]>>>2,xi=_[4]<<30|_[5]>>>2,_e=_[14]<<6|_[15]>>>26,Ar=_[15]<<6|_[14]>>>26,Et=_[25]<<11|_[24]>>>21,Vt=_[24]<<11|_[25]>>>21,Qt=_[34]<<15|_[35]>>>17,qt=_[35]<<15|_[34]>>>17,ce=_[45]<<29|_[44]>>>3,pe=_[44]<<29|_[45]>>>3,Ct=_[6]<<28|_[7]>>>4,Lt=_[7]<<28|_[6]>>>4,Oe=_[17]<<23|_[16]>>>9,le=_[16]<<23|_[17]>>>9,Gt=_[26]<<25|_[27]>>>7,zt=_[27]<<25|_[26]>>>7,wt=_[36]<<21|_[37]>>>11,At=_[37]<<21|_[36]>>>11,Te=_[47]<<24|_[46]>>>8,te=_[46]<<24|_[47]>>>8,Jt=_[8]<<27|_[9]>>>5,Xt=_[9]<<27|_[8]>>>5,Ot=_[18]<<20|_[19]>>>12,Nt=_[19]<<20|_[18]>>>12,oi=_[29]<<7|_[28]>>>25,ai=_[28]<<7|_[29]>>>25,De=_[38]<<8|_[39]>>>24,Wt=_[39]<<8|_[38]>>>24,Ut=_[48]<<14|_[49]>>>18,bt=_[49]<<14|_[48]>>>18,_[0]=$t^~Bt&Et,_[1]=xt^~_t&Vt,_[10]=Ct^~Ot&se,_[11]=Lt^~Nt&Tt,_[20]=Ve^~_e&Gt,_[21]=ye^~Ar&zt,_[30]=Jt^~xe&Yt,_[31]=Xt^~Zt&Ce,_[40]=Pe^~Oe&oi,_[41]=xi^~le&ai,_[2]=Bt^~Et&wt,_[3]=_t^~Vt&At,_[12]=Ot^~se&Rt,_[13]=Nt^~Tt&Ke,_[22]=_e^~Gt&De,_[23]=Ar^~zt&Wt,_[32]=xe^~Yt&Qt,_[33]=Zt^~Ce&qt,_[42]=Oe^~oi&ci,_[43]=le^~ai&ui,_[4]=Et^~wt&Ut,_[5]=Vt^~At&bt,_[14]=se^~Rt&ce,_[15]=Tt^~Ke&pe,_[24]=Gt^~De&Kt,_[25]=zt^~Wt&Ae,_[34]=Yt^~Qt&Te,_[35]=Ce^~qt&te,_[44]=oi^~ci&hi,_[45]=ai^~ui&ar,_[6]=wt^~Ut&$t,_[7]=At^~bt&xt,_[16]=Rt^~ce&Ct,_[17]=Ke^~pe&Lt,_[26]=De^~Kt&Ve,_[27]=Wt^~Ae&ye,_[36]=Qt^~Te&Jt,_[37]=qt^~te&Xt,_[46]=ci^~hi&Pe,_[47]=ui^~ar&xi,_[8]=Ut^~$t&Bt,_[9]=bt^~xt&_t,_[18]=ce^~Ct&Ot,_[19]=pe^~Lt&Nt,_[28]=Kt^~Ve&_e,_[29]=Ae^~ye&Ar,_[38]=Te^~Jt&xe,_[39]=te^~Xt&Zt,_[48]=hi^~Pe&Oe,_[49]=ar^~xi&le,_[0]^=Y[L],_[1]^=Y[L+1]};if(l)r.exports=y;else for(M=0;M<b.length;++M)s[b[M]]=y[b[M]]})()})(Z1);var zE=Z1.exports;const kE="logger/5.7.0";let Rd=!1,Td=!1;const Uc={debug:1,default:2,info:2,warning:3,error:4,off:5};let Fd=Uc.default,Nh=null;function HE(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test".normalize(t)!=="test")throw new Error("bad normalize")}catch{r.push(t)}}),r.length)throw new Error("missing "+r.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(r){return r.message}return null}const Ud=HE();var ml;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(ml||(ml={}));var Ui;(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"})(Ui||(Ui={}));const Bd="0123456789abcdef";let mr=class or{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const i=t.toLowerCase();Uc[i]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(Fd>Uc[i])&&console.log.apply(console,e)}debug(...t){this._log(or.levels.DEBUG,t)}info(...t){this._log(or.levels.INFO,t)}warn(...t){this._log(or.levels.WARNING,t)}makeError(t,e,i){if(Td)return this.makeError("censored error",e,{});e||(e=or.errors.UNKNOWN_ERROR),i||(i={});const s=[];Object.keys(i).forEach(m=>{const f=i[m];try{if(f instanceof Uint8Array){let w="";for(let E=0;E<f.length;E++)w+=Bd[f[E]>>4],w+=Bd[f[E]&15];s.push(m+"=Uint8Array(0x"+w+")")}else s.push(m+"="+JSON.stringify(f))}catch{s.push(m+"="+JSON.stringify(i[m].toString()))}}),s.push(`code=${e}`),s.push(`version=${this.version}`);const a=t;let u="";switch(e){case Ui.NUMERIC_FAULT:{u="NUMERIC_FAULT";const m=t;switch(m){case"overflow":case"underflow":case"division-by-zero":u+="-"+m;break;case"negative-power":case"negative-width":u+="-unsupported";break;case"unbound-bitwise-result":u+="-unbound-result";break}break}case Ui.CALL_EXCEPTION:case Ui.INSUFFICIENT_FUNDS:case Ui.MISSING_NEW:case Ui.NONCE_EXPIRED:case Ui.REPLACEMENT_UNDERPRICED:case Ui.TRANSACTION_REPLACED:case Ui.UNPREDICTABLE_GAS_LIMIT:u=e;break}u&&(t+=" [ See: https://links.ethers.org/v5-errors-"+u+" ]"),s.length&&(t+=" ("+s.join(", ")+")");const l=new Error(t);return l.reason=a,l.code=e,Object.keys(i).forEach(function(m){l[m]=i[m]}),l}throwError(t,e,i){throw this.makeError(t,e,i)}throwArgumentError(t,e,i){return this.throwError(t,or.errors.INVALID_ARGUMENT,{argument:e,value:i})}assert(t,e,i,s){t||this.throwError(e,i,s)}assertArgument(t,e,i,s){t||this.throwArgumentError(e,i,s)}checkNormalize(t){Ud&&this.throwError("platform missing String.prototype.normalize",or.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Ud})}checkSafeUint53(t,e){typeof t=="number"&&(e==null&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,or.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,or.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,i){i?i=": "+i:i="",t<e&&this.throwError("missing argument"+i,or.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+i,or.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){(t===Object||t==null)&&this.throwError("missing new",or.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",or.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",or.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Nh||(Nh=new or(kE)),Nh}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",or.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Rd){if(!t)return;this.globalLogger().throwError("error censorship permanent",or.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Td=!!t,Rd=!!e}static setLogLevel(t){const e=Uc[t.toLowerCase()];if(e==null){or.globalLogger().warn("invalid log level - "+t);return}Fd=e}static from(t){return new or(t)}};mr.errors=Ui,mr.levels=ml;const KE="bytes/5.7.0",Ze=new mr(KE);function tg(r){return!!r.toHexString}function oo(r){return r.slice||(r.slice=function(){const t=Array.prototype.slice.call(arguments);return oo(new Uint8Array(Array.prototype.slice.apply(r,t)))}),r}function VE(r){return ii(r)&&!(r.length%2)||mo(r)}function Ld(r){return typeof r=="number"&&r==r&&r%1===0}function mo(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!Ld(r.length)||r.length<0)return!1;for(let t=0;t<r.length;t++){const e=r[t];if(!Ld(e)||e<0||e>=256)return!1}return!0}function Ye(r,t){if(t||(t={}),typeof r=="number"){Ze.checkSafeUint53(r,"invalid arrayify value");const e=[];for(;r;)e.unshift(r&255),r=parseInt(String(r/256));return e.length===0&&e.push(0),oo(new Uint8Array(e))}if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),tg(r)&&(r=r.toHexString()),ii(r)){let e=r.substring(2);e.length%2&&(t.hexPad==="left"?e="0"+e:t.hexPad==="right"?e+="0":Ze.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let s=0;s<e.length;s+=2)i.push(parseInt(e.substring(s,s+2),16));return oo(new Uint8Array(i))}return mo(r)?oo(new Uint8Array(r)):Ze.throwArgumentError("invalid arrayify value","value",r)}function GE(r){const t=r.map(s=>Ye(s)),e=t.reduce((s,a)=>s+a.length,0),i=new Uint8Array(e);return t.reduce((s,a)=>(i.set(a,s),s+a.length),0),oo(i)}function WE(r,t){r=Ye(r),r.length>t&&Ze.throwArgumentError("value out of range","value",arguments[0]);const e=new Uint8Array(t);return e.set(r,t-r.length),oo(e)}function ii(r,t){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||t&&r.length!==2+2*t)}const Rh="0123456789abcdef";function Pr(r,t){if(t||(t={}),typeof r=="number"){Ze.checkSafeUint53(r,"invalid hexlify value");let e="";for(;r;)e=Rh[r&15]+e,r=Math.floor(r/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),tg(r))return r.toHexString();if(ii(r))return r.length%2&&(t.hexPad==="left"?r="0x0"+r.substring(2):t.hexPad==="right"?r+="0":Ze.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(mo(r)){let e="0x";for(let i=0;i<r.length;i++){let s=r[i];e+=Rh[(s&240)>>4]+Rh[s&15]}return e}return Ze.throwArgumentError("invalid hexlify value","value",r)}function YE(r){if(typeof r!="string")r=Pr(r);else if(!ii(r)||r.length%2)return null;return(r.length-2)/2}function qd(r,t,e){return typeof r!="string"?r=Pr(r):(!ii(r)||r.length%2)&&Ze.throwArgumentError("invalid hexData","value",r),t=2+2*t,e!=null?"0x"+r.substring(t,2+2*e):"0x"+r.substring(t)}function nn(r,t){for(typeof r!="string"?r=Pr(r):ii(r)||Ze.throwArgumentError("invalid hex string","value",r),r.length>2*t+2&&Ze.throwArgumentError("value out of range","value",arguments[1]);r.length<2*t+2;)r="0x0"+r.substring(2);return r}function eg(r){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(VE(r)){let e=Ye(r);e.length===64?(t.v=27+(e[32]>>7),e[32]&=127,t.r=Pr(e.slice(0,32)),t.s=Pr(e.slice(32,64))):e.length===65?(t.r=Pr(e.slice(0,32)),t.s=Pr(e.slice(32,64)),t.v=e[64]):Ze.throwArgumentError("invalid signature string","signature",r),t.v<27&&(t.v===0||t.v===1?t.v+=27:Ze.throwArgumentError("signature invalid v byte","signature",r)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(e[32]|=128),t._vs=Pr(e.slice(32,64))}else{if(t.r=r.r,t.s=r.s,t.v=r.v,t.recoveryParam=r.recoveryParam,t._vs=r._vs,t._vs!=null){const s=WE(Ye(t._vs),32);t._vs=Pr(s);const a=s[0]>=128?1:0;t.recoveryParam==null?t.recoveryParam=a:t.recoveryParam!==a&&Ze.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),s[0]&=127;const u=Pr(s);t.s==null?t.s=u:t.s!==u&&Ze.throwArgumentError("signature v mismatch _vs","signature",r)}if(t.recoveryParam==null)t.v==null?Ze.throwArgumentError("signature missing v and recoveryParam","signature",r):t.v===0||t.v===1?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(t.v==null)t.v=27+t.recoveryParam;else{const s=t.v===0||t.v===1?t.v:1-t.v%2;t.recoveryParam!==s&&Ze.throwArgumentError("signature recoveryParam mismatch v","signature",r)}t.r==null||!ii(t.r)?Ze.throwArgumentError("signature missing or invalid r","signature",r):t.r=nn(t.r,32),t.s==null||!ii(t.s)?Ze.throwArgumentError("signature missing or invalid s","signature",r):t.s=nn(t.s,32);const e=Ye(t.s);e[0]>=128&&Ze.throwArgumentError("signature s out of range","signature",r),t.recoveryParam&&(e[0]|=128);const i=Pr(e);t._vs&&(ii(t._vs)||Ze.throwArgumentError("signature invalid _vs","signature",r),t._vs=nn(t._vs,32)),t._vs==null?t._vs=i:t._vs!==i&&Ze.throwArgumentError("signature _vs mismatch v and s","signature",r)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}function zl(r){return"0x"+zE.keccak_256(Ye(r))}var rg={exports:{}},QE={},JE=Object.freeze({__proto__:null,default:QE}),XE=$E(JE);(function(r){(function(t,e){function i(h,y){if(!h)throw new Error(y||"Assertion failed")}function s(h,y){h.super_=y;var b=function(){};b.prototype=y.prototype,h.prototype=new b,h.prototype.constructor=h}function a(h,y,b){if(a.isBN(h))return h;this.negative=0,this.words=null,this.length=0,this.red=null,h!==null&&((y==="le"||y==="be")&&(b=y,y=10),this._init(h||0,y||10,b||"be"))}typeof t=="object"?t.exports=a:e.BN=a,a.BN=a,a.wordSize=26;var u;try{typeof window<"u"&&typeof window.Buffer<"u"?u=window.Buffer:u=XE.Buffer}catch{}a.isBN=function(h){return h instanceof a?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===a.wordSize&&Array.isArray(h.words)},a.max=function(h,y){return h.cmp(y)>0?h:y},a.min=function(h,y){return h.cmp(y)<0?h:y},a.prototype._init=function(h,y,b){if(typeof h=="number")return this._initNumber(h,y,b);if(typeof h=="object")return this._initArray(h,y,b);y==="hex"&&(y=16),i(y===(y|0)&&y>=2&&y<=36),h=h.toString().replace(/\s+/g,"");var M=0;h[0]==="-"&&(M++,this.negative=1),M<h.length&&(y===16?this._parseHex(h,M,b):(this._parseBase(h,y,M),b==="le"&&this._initArray(this.toArray(),y,b)))},a.prototype._initNumber=function(h,y,b){h<0&&(this.negative=1,h=-h),h<67108864?(this.words=[h&67108863],this.length=1):h<4503599627370496?(this.words=[h&67108863,h/67108864&67108863],this.length=2):(i(h<9007199254740992),this.words=[h&67108863,h/67108864&67108863,1],this.length=3),b==="le"&&this._initArray(this.toArray(),y,b)},a.prototype._initArray=function(h,y,b){if(i(typeof h.length=="number"),h.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(h.length/3),this.words=new Array(this.length);for(var M=0;M<this.length;M++)this.words[M]=0;var C,R,j=0;if(b==="be")for(M=h.length-1,C=0;M>=0;M-=3)R=h[M]|h[M-1]<<8|h[M-2]<<16,this.words[C]|=R<<j&67108863,this.words[C+1]=R>>>26-j&67108863,j+=24,j>=26&&(j-=26,C++);else if(b==="le")for(M=0,C=0;M<h.length;M+=3)R=h[M]|h[M+1]<<8|h[M+2]<<16,this.words[C]|=R<<j&67108863,this.words[C+1]=R>>>26-j&67108863,j+=24,j>=26&&(j-=26,C++);return this._strip()};function l(h,y){var b=h.charCodeAt(y);if(b>=48&&b<=57)return b-48;if(b>=65&&b<=70)return b-55;if(b>=97&&b<=102)return b-87;i(!1,"Invalid character in "+h)}function m(h,y,b){var M=l(h,b);return b-1>=y&&(M|=l(h,b-1)<<4),M}a.prototype._parseHex=function(h,y,b){this.length=Math.ceil((h.length-y)/6),this.words=new Array(this.length);for(var M=0;M<this.length;M++)this.words[M]=0;var C=0,R=0,j;if(b==="be")for(M=h.length-1;M>=y;M-=2)j=m(h,y,M)<<C,this.words[R]|=j&67108863,C>=18?(C-=18,R+=1,this.words[R]|=j>>>26):C+=8;else{var S=h.length-y;for(M=S%2===0?y+1:y;M<h.length;M+=2)j=m(h,y,M)<<C,this.words[R]|=j&67108863,C>=18?(C-=18,R+=1,this.words[R]|=j>>>26):C+=8}this._strip()};function f(h,y,b,M){for(var C=0,R=0,j=Math.min(h.length,b),S=y;S<j;S++){var p=h.charCodeAt(S)-48;C*=M,p>=49?R=p-49+10:p>=17?R=p-17+10:R=p,i(p>=0&&R<M,"Invalid character"),C+=R}return C}a.prototype._parseBase=function(h,y,b){this.words=[0],this.length=1;for(var M=0,C=1;C<=67108863;C*=y)M++;M--,C=C/y|0;for(var R=h.length-b,j=R%M,S=Math.min(R,R-j)+b,p=0,O=b;O<S;O+=M)p=f(h,O,O+M,y),this.imuln(C),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p);if(j!==0){var it=1;for(p=f(h,O,h.length,y),O=0;O<j;O++)it*=y;this.imuln(it),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p)}this._strip()},a.prototype.copy=function(h){h.words=new Array(this.length);for(var y=0;y<this.length;y++)h.words[y]=this.words[y];h.length=this.length,h.negative=this.negative,h.red=this.red};function w(h,y){h.words=y.words,h.length=y.length,h.negative=y.negative,h.red=y.red}if(a.prototype._move=function(h){w(h,this)},a.prototype.clone=function(){var h=new a(null);return this.copy(h),h},a.prototype._expand=function(h){for(;this.length<h;)this.words[this.length++]=0;return this},a.prototype._strip=function(){for(;this.length>1&&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")]=E}catch{a.prototype.inspect=E}else a.prototype.inspect=E;function E(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","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"],I=[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(h,y){h=h||10,y=y|0||1;var b;if(h===16||h==="hex"){b="";for(var M=0,C=0,R=0;R<this.length;R++){var j=this.words[R],S=((j<<M|C)&16777215).toString(16);C=j>>>24-M&16777215,M+=2,M>=26&&(M-=26,R--),C!==0||R!==this.length-1?b=x[6-S.length]+S+b:b=S+b}for(C!==0&&(b=C.toString(16)+b);b.length%y!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(h===(h|0)&&h>=2&&h<=36){var p=I[h],O=N[h];b="";var it=this.clone();for(it.negative=0;!it.isZero();){var lt=it.modrn(O).toString(h);it=it.idivn(O),it.isZero()?b=lt+b:b=x[p-lt.length]+lt+b}for(this.isZero()&&(b="0"+b);b.length%y!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},a.prototype.toJSON=function(){return this.toString(16,2)},u&&(a.prototype.toBuffer=function(h,y){return this.toArrayLike(u,h,y)}),a.prototype.toArray=function(h,y){return this.toArrayLike(Array,h,y)};var Y=function(h,y){return h.allocUnsafe?h.allocUnsafe(y):new h(y)};a.prototype.toArrayLike=function(h,y,b){this._strip();var M=this.byteLength(),C=b||Math.max(1,M);i(M<=C,"byte array longer than desired length"),i(C>0,"Requested array length <= 0");var R=Y(h,C),j=y==="le"?"LE":"BE";return this["_toArrayLike"+j](R,M),R},a.prototype._toArrayLikeLE=function(h,y){for(var b=0,M=0,C=0,R=0;C<this.length;C++){var j=this.words[C]<<R|M;h[b++]=j&255,b<h.length&&(h[b++]=j>>8&255),b<h.length&&(h[b++]=j>>16&255),R===6?(b<h.length&&(h[b++]=j>>24&255),M=0,R=0):(M=j>>>24,R+=2)}if(b<h.length)for(h[b++]=M;b<h.length;)h[b++]=0},a.prototype._toArrayLikeBE=function(h,y){for(var b=h.length-1,M=0,C=0,R=0;C<this.length;C++){var j=this.words[C]<<R|M;h[b--]=j&255,b>=0&&(h[b--]=j>>8&255),b>=0&&(h[b--]=j>>16&255),R===6?(b>=0&&(h[b--]=j>>24&255),M=0,R=0):(M=j>>>24,R+=2)}if(b>=0)for(h[b--]=M;b>=0;)h[b--]=0},Math.clz32?a.prototype._countBits=function(h){return 32-Math.clz32(h)}:a.prototype._countBits=function(h){var y=h,b=0;return y>=4096&&(b+=13,y>>>=13),y>=64&&(b+=7,y>>>=7),y>=8&&(b+=4,y>>>=4),y>=2&&(b+=2,y>>>=2),b+y},a.prototype._zeroBits=function(h){if(h===0)return 26;var y=h,b=0;return y&8191||(b+=13,y>>>=13),y&127||(b+=7,y>>>=7),y&15||(b+=4,y>>>=4),y&3||(b+=2,y>>>=2),y&1||b++,b},a.prototype.bitLength=function(){var h=this.words[this.length-1],y=this._countBits(h);return(this.length-1)*26+y};function G(h){for(var y=new Array(h.bitLength()),b=0;b<y.length;b++){var M=b/26|0,C=b%26;y[b]=h.words[M]>>>C&1}return y}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,y=0;y<this.length;y++){var b=this._zeroBits(this.words[y]);if(h+=b,b!==26)break}return h},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(h){return this.negative!==0?this.abs().inotn(h).iaddn(1):this.clone()},a.prototype.fromTwos=function(h){return this.testn(h-1)?this.notn(h).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(h){for(;this.length<h.length;)this.words[this.length++]=0;for(var y=0;y<h.length;y++)this.words[y]=this.words[y]|h.words[y];return this._strip()},a.prototype.ior=function(h){return i((this.negative|h.negative)===0),this.iuor(h)},a.prototype.or=function(h){return this.length>h.length?this.clone().ior(h):h.clone().ior(this)},a.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},a.prototype.iuand=function(h){var y;this.length>h.length?y=h:y=this;for(var b=0;b<y.length;b++)this.words[b]=this.words[b]&h.words[b];return this.length=y.length,this._strip()},a.prototype.iand=function(h){return i((this.negative|h.negative)===0),this.iuand(h)},a.prototype.and=function(h){return this.length>h.length?this.clone().iand(h):h.clone().iand(this)},a.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},a.prototype.iuxor=function(h){var y,b;this.length>h.length?(y=this,b=h):(y=h,b=this);for(var M=0;M<b.length;M++)this.words[M]=y.words[M]^b.words[M];if(this!==y)for(;M<y.length;M++)this.words[M]=y.words[M];return this.length=y.length,this._strip()},a.prototype.ixor=function(h){return i((this.negative|h.negative)===0),this.iuxor(h)},a.prototype.xor=function(h){return this.length>h.length?this.clone().ixor(h):h.clone().ixor(this)},a.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},a.prototype.inotn=function(h){i(typeof h=="number"&&h>=0);var y=Math.ceil(h/26)|0,b=h%26;this._expand(y),b>0&&y--;for(var M=0;M<y;M++)this.words[M]=~this.words[M]&67108863;return b>0&&(this.words[M]=~this.words[M]&67108863>>26-b),this._strip()},a.prototype.notn=function(h){return this.clone().inotn(h)},a.prototype.setn=function(h,y){i(typeof h=="number"&&h>=0);var b=h/26|0,M=h%26;return this._expand(b+1),y?this.words[b]=this.words[b]|1<<M:this.words[b]=this.words[b]&~(1<<M),this._strip()},a.prototype.iadd=function(h){var y;if(this.negative!==0&&h.negative===0)return this.negative=0,y=this.isub(h),this.negative^=1,this._normSign();if(this.negative===0&&h.negative!==0)return h.negative=0,y=this.isub(h),h.negative=1,y._normSign();var b,M;this.length>h.length?(b=this,M=h):(b=h,M=this);for(var C=0,R=0;R<M.length;R++)y=(b.words[R]|0)+(M.words[R]|0)+C,this.words[R]=y&67108863,C=y>>>26;for(;C!==0&&R<b.length;R++)y=(b.words[R]|0)+C,this.words[R]=y&67108863,C=y>>>26;if(this.length=b.length,C!==0)this.words[this.length]=C,this.length++;else if(b!==this)for(;R<b.length;R++)this.words[R]=b.words[R];return this},a.prototype.add=function(h){var y;return h.negative!==0&&this.negative===0?(h.negative=0,y=this.sub(h),h.negative^=1,y):h.negative===0&&this.negative!==0?(this.negative=0,y=h.sub(this),this.negative=1,y):this.length>h.length?this.clone().iadd(h):h.clone().iadd(this)},a.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var y=this.iadd(h);return h.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var b=this.cmp(h);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,C;b>0?(M=this,C=h):(M=h,C=this);for(var R=0,j=0;j<C.length;j++)y=(M.words[j]|0)-(C.words[j]|0)+R,R=y>>26,this.words[j]=y&67108863;for(;R!==0&&j<M.length;j++)y=(M.words[j]|0)+R,R=y>>26,this.words[j]=y&67108863;if(R===0&&j<M.length&&M!==this)for(;j<M.length;j++)this.words[j]=M.words[j];return this.length=Math.max(this.length,j),M!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(h){return this.clone().isub(h)};function tt(h,y,b){b.negative=y.negative^h.negative;var M=h.length+y.length|0;b.length=M,M=M-1|0;var C=h.words[0]|0,R=y.words[0]|0,j=C*R,S=j&67108863,p=j/67108864|0;b.words[0]=S;for(var O=1;O<M;O++){for(var it=p>>>26,lt=p&67108863,_=Math.min(O,y.length-1),Z=Math.max(0,O-h.length+1);Z<=_;Z++){var U=O-Z|0;C=h.words[U]|0,R=y.words[Z]|0,j=C*R+lt,it+=j/67108864|0,lt=j&67108863}b.words[O]=lt|0,p=it|0}return p!==0?b.words[O]=p|0:b.length--,b._strip()}var K=function(h,y,b){var M=h.words,C=y.words,R=b.words,j=0,S,p,O,it=M[0]|0,lt=it&8191,_=it>>>13,Z=M[1]|0,U=Z&8191,L=Z>>>13,k=M[2]|0,d=k&8191,F=k>>>13,et=M[3]|0,ut=et&8191,at=et>>>13,Mt=M[4]|0,Pt=Mt&8191,It=Mt>>>13,Ee=M[5]|0,$t=Ee&8191,xt=Ee>>>13,Bt=M[6]|0,_t=Bt&8191,Et=Bt>>>13,Vt=M[7]|0,wt=Vt&8191,At=Vt>>>13,Ut=M[8]|0,bt=Ut&8191,Ct=Ut>>>13,Lt=M[9]|0,Ot=Lt&8191,Nt=Lt>>>13,se=C[0]|0,Tt=se&8191,Rt=se>>>13,Ke=C[1]|0,ce=Ke&8191,pe=Ke>>>13,Ve=C[2]|0,ye=Ve&8191,_e=Ve>>>13,Ar=C[3]|0,Gt=Ar&8191,zt=Ar>>>13,De=C[4]|0,Wt=De&8191,Kt=De>>>13,Ae=C[5]|0,Jt=Ae&8191,Xt=Ae>>>13,xe=C[6]|0,Zt=xe&8191,Yt=xe>>>13,Ce=C[7]|0,Qt=Ce&8191,qt=Ce>>>13,Te=C[8]|0,te=Te&8191,Pe=Te>>>13,xi=C[9]|0,Oe=xi&8191,le=xi>>>13;b.negative=h.negative^y.negative,b.length=19,S=Math.imul(lt,Tt),p=Math.imul(lt,Rt),p=p+Math.imul(_,Tt)|0,O=Math.imul(_,Rt);var oi=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(oi>>>26)|0,oi&=67108863,S=Math.imul(U,Tt),p=Math.imul(U,Rt),p=p+Math.imul(L,Tt)|0,O=Math.imul(L,Rt),S=S+Math.imul(lt,ce)|0,p=p+Math.imul(lt,pe)|0,p=p+Math.imul(_,ce)|0,O=O+Math.imul(_,pe)|0;var ai=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(ai>>>26)|0,ai&=67108863,S=Math.imul(d,Tt),p=Math.imul(d,Rt),p=p+Math.imul(F,Tt)|0,O=Math.imul(F,Rt),S=S+Math.imul(U,ce)|0,p=p+Math.imul(U,pe)|0,p=p+Math.imul(L,ce)|0,O=O+Math.imul(L,pe)|0,S=S+Math.imul(lt,ye)|0,p=p+Math.imul(lt,_e)|0,p=p+Math.imul(_,ye)|0,O=O+Math.imul(_,_e)|0;var ci=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(ci>>>26)|0,ci&=67108863,S=Math.imul(ut,Tt),p=Math.imul(ut,Rt),p=p+Math.imul(at,Tt)|0,O=Math.imul(at,Rt),S=S+Math.imul(d,ce)|0,p=p+Math.imul(d,pe)|0,p=p+Math.imul(F,ce)|0,O=O+Math.imul(F,pe)|0,S=S+Math.imul(U,ye)|0,p=p+Math.imul(U,_e)|0,p=p+Math.imul(L,ye)|0,O=O+Math.imul(L,_e)|0,S=S+Math.imul(lt,Gt)|0,p=p+Math.imul(lt,zt)|0,p=p+Math.imul(_,Gt)|0,O=O+Math.imul(_,zt)|0;var ui=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(ui>>>26)|0,ui&=67108863,S=Math.imul(Pt,Tt),p=Math.imul(Pt,Rt),p=p+Math.imul(It,Tt)|0,O=Math.imul(It,Rt),S=S+Math.imul(ut,ce)|0,p=p+Math.imul(ut,pe)|0,p=p+Math.imul(at,ce)|0,O=O+Math.imul(at,pe)|0,S=S+Math.imul(d,ye)|0,p=p+Math.imul(d,_e)|0,p=p+Math.imul(F,ye)|0,O=O+Math.imul(F,_e)|0,S=S+Math.imul(U,Gt)|0,p=p+Math.imul(U,zt)|0,p=p+Math.imul(L,Gt)|0,O=O+Math.imul(L,zt)|0,S=S+Math.imul(lt,Wt)|0,p=p+Math.imul(lt,Kt)|0,p=p+Math.imul(_,Wt)|0,O=O+Math.imul(_,Kt)|0;var hi=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(hi>>>26)|0,hi&=67108863,S=Math.imul($t,Tt),p=Math.imul($t,Rt),p=p+Math.imul(xt,Tt)|0,O=Math.imul(xt,Rt),S=S+Math.imul(Pt,ce)|0,p=p+Math.imul(Pt,pe)|0,p=p+Math.imul(It,ce)|0,O=O+Math.imul(It,pe)|0,S=S+Math.imul(ut,ye)|0,p=p+Math.imul(ut,_e)|0,p=p+Math.imul(at,ye)|0,O=O+Math.imul(at,_e)|0,S=S+Math.imul(d,Gt)|0,p=p+Math.imul(d,zt)|0,p=p+Math.imul(F,Gt)|0,O=O+Math.imul(F,zt)|0,S=S+Math.imul(U,Wt)|0,p=p+Math.imul(U,Kt)|0,p=p+Math.imul(L,Wt)|0,O=O+Math.imul(L,Kt)|0,S=S+Math.imul(lt,Jt)|0,p=p+Math.imul(lt,Xt)|0,p=p+Math.imul(_,Jt)|0,O=O+Math.imul(_,Xt)|0;var ar=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(ar>>>26)|0,ar&=67108863,S=Math.imul(_t,Tt),p=Math.imul(_t,Rt),p=p+Math.imul(Et,Tt)|0,O=Math.imul(Et,Rt),S=S+Math.imul($t,ce)|0,p=p+Math.imul($t,pe)|0,p=p+Math.imul(xt,ce)|0,O=O+Math.imul(xt,pe)|0,S=S+Math.imul(Pt,ye)|0,p=p+Math.imul(Pt,_e)|0,p=p+Math.imul(It,ye)|0,O=O+Math.imul(It,_e)|0,S=S+Math.imul(ut,Gt)|0,p=p+Math.imul(ut,zt)|0,p=p+Math.imul(at,Gt)|0,O=O+Math.imul(at,zt)|0,S=S+Math.imul(d,Wt)|0,p=p+Math.imul(d,Kt)|0,p=p+Math.imul(F,Wt)|0,O=O+Math.imul(F,Kt)|0,S=S+Math.imul(U,Jt)|0,p=p+Math.imul(U,Xt)|0,p=p+Math.imul(L,Jt)|0,O=O+Math.imul(L,Xt)|0,S=S+Math.imul(lt,Zt)|0,p=p+Math.imul(lt,Yt)|0,p=p+Math.imul(_,Zt)|0,O=O+Math.imul(_,Yt)|0;var qi=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(qi>>>26)|0,qi&=67108863,S=Math.imul(wt,Tt),p=Math.imul(wt,Rt),p=p+Math.imul(At,Tt)|0,O=Math.imul(At,Rt),S=S+Math.imul(_t,ce)|0,p=p+Math.imul(_t,pe)|0,p=p+Math.imul(Et,ce)|0,O=O+Math.imul(Et,pe)|0,S=S+Math.imul($t,ye)|0,p=p+Math.imul($t,_e)|0,p=p+Math.imul(xt,ye)|0,O=O+Math.imul(xt,_e)|0,S=S+Math.imul(Pt,Gt)|0,p=p+Math.imul(Pt,zt)|0,p=p+Math.imul(It,Gt)|0,O=O+Math.imul(It,zt)|0,S=S+Math.imul(ut,Wt)|0,p=p+Math.imul(ut,Kt)|0,p=p+Math.imul(at,Wt)|0,O=O+Math.imul(at,Kt)|0,S=S+Math.imul(d,Jt)|0,p=p+Math.imul(d,Xt)|0,p=p+Math.imul(F,Jt)|0,O=O+Math.imul(F,Xt)|0,S=S+Math.imul(U,Zt)|0,p=p+Math.imul(U,Yt)|0,p=p+Math.imul(L,Zt)|0,O=O+Math.imul(L,Yt)|0,S=S+Math.imul(lt,Qt)|0,p=p+Math.imul(lt,qt)|0,p=p+Math.imul(_,Qt)|0,O=O+Math.imul(_,qt)|0;var Xn=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(Xn>>>26)|0,Xn&=67108863,S=Math.imul(bt,Tt),p=Math.imul(bt,Rt),p=p+Math.imul(Ct,Tt)|0,O=Math.imul(Ct,Rt),S=S+Math.imul(wt,ce)|0,p=p+Math.imul(wt,pe)|0,p=p+Math.imul(At,ce)|0,O=O+Math.imul(At,pe)|0,S=S+Math.imul(_t,ye)|0,p=p+Math.imul(_t,_e)|0,p=p+Math.imul(Et,ye)|0,O=O+Math.imul(Et,_e)|0,S=S+Math.imul($t,Gt)|0,p=p+Math.imul($t,zt)|0,p=p+Math.imul(xt,Gt)|0,O=O+Math.imul(xt,zt)|0,S=S+Math.imul(Pt,Wt)|0,p=p+Math.imul(Pt,Kt)|0,p=p+Math.imul(It,Wt)|0,O=O+Math.imul(It,Kt)|0,S=S+Math.imul(ut,Jt)|0,p=p+Math.imul(ut,Xt)|0,p=p+Math.imul(at,Jt)|0,O=O+Math.imul(at,Xt)|0,S=S+Math.imul(d,Zt)|0,p=p+Math.imul(d,Yt)|0,p=p+Math.imul(F,Zt)|0,O=O+Math.imul(F,Yt)|0,S=S+Math.imul(U,Qt)|0,p=p+Math.imul(U,qt)|0,p=p+Math.imul(L,Qt)|0,O=O+Math.imul(L,qt)|0,S=S+Math.imul(lt,te)|0,p=p+Math.imul(lt,Pe)|0,p=p+Math.imul(_,te)|0,O=O+Math.imul(_,Pe)|0;var ji=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(ji>>>26)|0,ji&=67108863,S=Math.imul(Ot,Tt),p=Math.imul(Ot,Rt),p=p+Math.imul(Nt,Tt)|0,O=Math.imul(Nt,Rt),S=S+Math.imul(bt,ce)|0,p=p+Math.imul(bt,pe)|0,p=p+Math.imul(Ct,ce)|0,O=O+Math.imul(Ct,pe)|0,S=S+Math.imul(wt,ye)|0,p=p+Math.imul(wt,_e)|0,p=p+Math.imul(At,ye)|0,O=O+Math.imul(At,_e)|0,S=S+Math.imul(_t,Gt)|0,p=p+Math.imul(_t,zt)|0,p=p+Math.imul(Et,Gt)|0,O=O+Math.imul(Et,zt)|0,S=S+Math.imul($t,Wt)|0,p=p+Math.imul($t,Kt)|0,p=p+Math.imul(xt,Wt)|0,O=O+Math.imul(xt,Kt)|0,S=S+Math.imul(Pt,Jt)|0,p=p+Math.imul(Pt,Xt)|0,p=p+Math.imul(It,Jt)|0,O=O+Math.imul(It,Xt)|0,S=S+Math.imul(ut,Zt)|0,p=p+Math.imul(ut,Yt)|0,p=p+Math.imul(at,Zt)|0,O=O+Math.imul(at,Yt)|0,S=S+Math.imul(d,Qt)|0,p=p+Math.imul(d,qt)|0,p=p+Math.imul(F,Qt)|0,O=O+Math.imul(F,qt)|0,S=S+Math.imul(U,te)|0,p=p+Math.imul(U,Pe)|0,p=p+Math.imul(L,te)|0,O=O+Math.imul(L,Pe)|0,S=S+Math.imul(lt,Oe)|0,p=p+Math.imul(lt,le)|0,p=p+Math.imul(_,Oe)|0,O=O+Math.imul(_,le)|0;var Zn=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(Zn>>>26)|0,Zn&=67108863,S=Math.imul(Ot,ce),p=Math.imul(Ot,pe),p=p+Math.imul(Nt,ce)|0,O=Math.imul(Nt,pe),S=S+Math.imul(bt,ye)|0,p=p+Math.imul(bt,_e)|0,p=p+Math.imul(Ct,ye)|0,O=O+Math.imul(Ct,_e)|0,S=S+Math.imul(wt,Gt)|0,p=p+Math.imul(wt,zt)|0,p=p+Math.imul(At,Gt)|0,O=O+Math.imul(At,zt)|0,S=S+Math.imul(_t,Wt)|0,p=p+Math.imul(_t,Kt)|0,p=p+Math.imul(Et,Wt)|0,O=O+Math.imul(Et,Kt)|0,S=S+Math.imul($t,Jt)|0,p=p+Math.imul($t,Xt)|0,p=p+Math.imul(xt,Jt)|0,O=O+Math.imul(xt,Xt)|0,S=S+Math.imul(Pt,Zt)|0,p=p+Math.imul(Pt,Yt)|0,p=p+Math.imul(It,Zt)|0,O=O+Math.imul(It,Yt)|0,S=S+Math.imul(ut,Qt)|0,p=p+Math.imul(ut,qt)|0,p=p+Math.imul(at,Qt)|0,O=O+Math.imul(at,qt)|0,S=S+Math.imul(d,te)|0,p=p+Math.imul(d,Pe)|0,p=p+Math.imul(F,te)|0,O=O+Math.imul(F,Pe)|0,S=S+Math.imul(U,Oe)|0,p=p+Math.imul(U,le)|0,p=p+Math.imul(L,Oe)|0,O=O+Math.imul(L,le)|0;var ts=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(ts>>>26)|0,ts&=67108863,S=Math.imul(Ot,ye),p=Math.imul(Ot,_e),p=p+Math.imul(Nt,ye)|0,O=Math.imul(Nt,_e),S=S+Math.imul(bt,Gt)|0,p=p+Math.imul(bt,zt)|0,p=p+Math.imul(Ct,Gt)|0,O=O+Math.imul(Ct,zt)|0,S=S+Math.imul(wt,Wt)|0,p=p+Math.imul(wt,Kt)|0,p=p+Math.imul(At,Wt)|0,O=O+Math.imul(At,Kt)|0,S=S+Math.imul(_t,Jt)|0,p=p+Math.imul(_t,Xt)|0,p=p+Math.imul(Et,Jt)|0,O=O+Math.imul(Et,Xt)|0,S=S+Math.imul($t,Zt)|0,p=p+Math.imul($t,Yt)|0,p=p+Math.imul(xt,Zt)|0,O=O+Math.imul(xt,Yt)|0,S=S+Math.imul(Pt,Qt)|0,p=p+Math.imul(Pt,qt)|0,p=p+Math.imul(It,Qt)|0,O=O+Math.imul(It,qt)|0,S=S+Math.imul(ut,te)|0,p=p+Math.imul(ut,Pe)|0,p=p+Math.imul(at,te)|0,O=O+Math.imul(at,Pe)|0,S=S+Math.imul(d,Oe)|0,p=p+Math.imul(d,le)|0,p=p+Math.imul(F,Oe)|0,O=O+Math.imul(F,le)|0;var $i=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+($i>>>26)|0,$i&=67108863,S=Math.imul(Ot,Gt),p=Math.imul(Ot,zt),p=p+Math.imul(Nt,Gt)|0,O=Math.imul(Nt,zt),S=S+Math.imul(bt,Wt)|0,p=p+Math.imul(bt,Kt)|0,p=p+Math.imul(Ct,Wt)|0,O=O+Math.imul(Ct,Kt)|0,S=S+Math.imul(wt,Jt)|0,p=p+Math.imul(wt,Xt)|0,p=p+Math.imul(At,Jt)|0,O=O+Math.imul(At,Xt)|0,S=S+Math.imul(_t,Zt)|0,p=p+Math.imul(_t,Yt)|0,p=p+Math.imul(Et,Zt)|0,O=O+Math.imul(Et,Yt)|0,S=S+Math.imul($t,Qt)|0,p=p+Math.imul($t,qt)|0,p=p+Math.imul(xt,Qt)|0,O=O+Math.imul(xt,qt)|0,S=S+Math.imul(Pt,te)|0,p=p+Math.imul(Pt,Pe)|0,p=p+Math.imul(It,te)|0,O=O+Math.imul(It,Pe)|0,S=S+Math.imul(ut,Oe)|0,p=p+Math.imul(ut,le)|0,p=p+Math.imul(at,Oe)|0,O=O+Math.imul(at,le)|0;var On=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(On>>>26)|0,On&=67108863,S=Math.imul(Ot,Wt),p=Math.imul(Ot,Kt),p=p+Math.imul(Nt,Wt)|0,O=Math.imul(Nt,Kt),S=S+Math.imul(bt,Jt)|0,p=p+Math.imul(bt,Xt)|0,p=p+Math.imul(Ct,Jt)|0,O=O+Math.imul(Ct,Xt)|0,S=S+Math.imul(wt,Zt)|0,p=p+Math.imul(wt,Yt)|0,p=p+Math.imul(At,Zt)|0,O=O+Math.imul(At,Yt)|0,S=S+Math.imul(_t,Qt)|0,p=p+Math.imul(_t,qt)|0,p=p+Math.imul(Et,Qt)|0,O=O+Math.imul(Et,qt)|0,S=S+Math.imul($t,te)|0,p=p+Math.imul($t,Pe)|0,p=p+Math.imul(xt,te)|0,O=O+Math.imul(xt,Pe)|0,S=S+Math.imul(Pt,Oe)|0,p=p+Math.imul(Pt,le)|0,p=p+Math.imul(It,Oe)|0,O=O+Math.imul(It,le)|0;var Nn=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,S=Math.imul(Ot,Jt),p=Math.imul(Ot,Xt),p=p+Math.imul(Nt,Jt)|0,O=Math.imul(Nt,Xt),S=S+Math.imul(bt,Zt)|0,p=p+Math.imul(bt,Yt)|0,p=p+Math.imul(Ct,Zt)|0,O=O+Math.imul(Ct,Yt)|0,S=S+Math.imul(wt,Qt)|0,p=p+Math.imul(wt,qt)|0,p=p+Math.imul(At,Qt)|0,O=O+Math.imul(At,qt)|0,S=S+Math.imul(_t,te)|0,p=p+Math.imul(_t,Pe)|0,p=p+Math.imul(Et,te)|0,O=O+Math.imul(Et,Pe)|0,S=S+Math.imul($t,Oe)|0,p=p+Math.imul($t,le)|0,p=p+Math.imul(xt,Oe)|0,O=O+Math.imul(xt,le)|0;var Sr=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(Sr>>>26)|0,Sr&=67108863,S=Math.imul(Ot,Zt),p=Math.imul(Ot,Yt),p=p+Math.imul(Nt,Zt)|0,O=Math.imul(Nt,Yt),S=S+Math.imul(bt,Qt)|0,p=p+Math.imul(bt,qt)|0,p=p+Math.imul(Ct,Qt)|0,O=O+Math.imul(Ct,qt)|0,S=S+Math.imul(wt,te)|0,p=p+Math.imul(wt,Pe)|0,p=p+Math.imul(At,te)|0,O=O+Math.imul(At,Pe)|0,S=S+Math.imul(_t,Oe)|0,p=p+Math.imul(_t,le)|0,p=p+Math.imul(Et,Oe)|0,O=O+Math.imul(Et,le)|0;var es=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(es>>>26)|0,es&=67108863,S=Math.imul(Ot,Qt),p=Math.imul(Ot,qt),p=p+Math.imul(Nt,Qt)|0,O=Math.imul(Nt,qt),S=S+Math.imul(bt,te)|0,p=p+Math.imul(bt,Pe)|0,p=p+Math.imul(Ct,te)|0,O=O+Math.imul(Ct,Pe)|0,S=S+Math.imul(wt,Oe)|0,p=p+Math.imul(wt,le)|0,p=p+Math.imul(At,Oe)|0,O=O+Math.imul(At,le)|0;var rs=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(rs>>>26)|0,rs&=67108863,S=Math.imul(Ot,te),p=Math.imul(Ot,Pe),p=p+Math.imul(Nt,te)|0,O=Math.imul(Nt,Pe),S=S+Math.imul(bt,Oe)|0,p=p+Math.imul(bt,le)|0,p=p+Math.imul(Ct,Oe)|0,O=O+Math.imul(Ct,le)|0;var is=(j+S|0)+((p&8191)<<13)|0;j=(O+(p>>>13)|0)+(is>>>26)|0,is&=67108863,S=Math.imul(Ot,Oe),p=Math.imul(Ot,le),p=p+Math.imul(Nt,Oe)|0,O=Math.imul(Nt,le);var ns=(j+S|0)+((p&8191)<<13)|0;return j=(O+(p>>>13)|0)+(ns>>>26)|0,ns&=67108863,R[0]=oi,R[1]=ai,R[2]=ci,R[3]=ui,R[4]=hi,R[5]=ar,R[6]=qi,R[7]=Xn,R[8]=ji,R[9]=Zn,R[10]=ts,R[11]=$i,R[12]=On,R[13]=Nn,R[14]=Sr,R[15]=es,R[16]=rs,R[17]=is,R[18]=ns,j!==0&&(R[19]=j,b.length++),b};Math.imul||(K=tt);function V(h,y,b){b.negative=y.negative^h.negative,b.length=h.length+y.length;for(var M=0,C=0,R=0;R<b.length-1;R++){var j=C;C=0;for(var S=M&67108863,p=Math.min(R,y.length-1),O=Math.max(0,R-h.length+1);O<=p;O++){var it=R-O,lt=h.words[it]|0,_=y.words[O]|0,Z=lt*_,U=Z&67108863;j=j+(Z/67108864|0)|0,U=U+S|0,S=U&67108863,j=j+(U>>>26)|0,C+=j>>>26,j&=67108863}b.words[R]=S,M=j,j=C}return M!==0?b.words[R]=M:b.length--,b._strip()}function B(h,y,b){return V(h,y,b)}a.prototype.mulTo=function(h,y){var b,M=this.length+h.length;return this.length===10&&h.length===10?b=K(this,h,y):M<63?b=tt(this,h,y):M<1024?b=V(this,h,y):b=B(this,h,y),b},a.prototype.mul=function(h){var y=new a(null);return y.words=new Array(this.length+h.length),this.mulTo(h,y)},a.prototype.mulf=function(h){var y=new a(null);return y.words=new Array(this.length+h.length),B(this,h,y)},a.prototype.imul=function(h){return this.clone().mulTo(h,this)},a.prototype.imuln=function(h){var y=h<0;y&&(h=-h),i(typeof h=="number"),i(h<67108864);for(var b=0,M=0;M<this.length;M++){var C=(this.words[M]|0)*h,R=(C&67108863)+(b&67108863);b>>=26,b+=C/67108864|0,b+=R>>>26,this.words[M]=R&67108863}return b!==0&&(this.words[M]=b,this.length++),y?this.ineg():this},a.prototype.muln=function(h){return this.clone().imuln(h)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(h){var y=G(h);if(y.length===0)return new a(1);for(var b=this,M=0;M<y.length&&y[M]===0;M++,b=b.sqr());if(++M<y.length)for(var C=b.sqr();M<y.length;M++,C=C.sqr())y[M]!==0&&(b=b.mul(C));return b},a.prototype.iushln=function(h){i(typeof h=="number"&&h>=0);var y=h%26,b=(h-y)/26,M=67108863>>>26-y<<26-y,C;if(y!==0){var R=0;for(C=0;C<this.length;C++){var j=this.words[C]&M,S=(this.words[C]|0)-j<<y;this.words[C]=S|R,R=j>>>26-y}R&&(this.words[C]=R,this.length++)}if(b!==0){for(C=this.length-1;C>=0;C--)this.words[C+b]=this.words[C];for(C=0;C<b;C++)this.words[C]=0;this.length+=b}return this._strip()},a.prototype.ishln=function(h){return i(this.negative===0),this.iushln(h)},a.prototype.iushrn=function(h,y,b){i(typeof h=="number"&&h>=0);var M;y?M=(y-y%26)/26:M=0;var C=h%26,R=Math.min((h-C)/26,this.length),j=67108863^67108863>>>C<<C,S=b;if(M-=R,M=Math.max(0,M),S){for(var p=0;p<R;p++)S.words[p]=this.words[p];S.length=R}if(R!==0)if(this.length>R)for(this.length-=R,p=0;p<this.length;p++)this.words[p]=this.words[p+R];else this.words[0]=0,this.length=1;var O=0;for(p=this.length-1;p>=0&&(O!==0||p>=M);p--){var it=this.words[p]|0;this.words[p]=O<<26-C|it>>>C,O=it&j}return S&&O!==0&&(S.words[S.length++]=O),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(h,y,b){return i(this.negative===0),this.iushrn(h,y,b)},a.prototype.shln=function(h){return this.clone().ishln(h)},a.prototype.ushln=function(h){return this.clone().iushln(h)},a.prototype.shrn=function(h){return this.clone().ishrn(h)},a.prototype.ushrn=function(h){return this.clone().iushrn(h)},a.prototype.testn=function(h){i(typeof h=="number"&&h>=0);var y=h%26,b=(h-y)/26,M=1<<y;if(this.length<=b)return!1;var C=this.words[b];return!!(C&M)},a.prototype.imaskn=function(h){i(typeof h=="number"&&h>=0);var y=h%26,b=(h-y)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(y!==0&&b++,this.length=Math.min(b,this.length),y!==0){var M=67108863^67108863>>>y<<y;this.words[this.length-1]&=M}return this._strip()},a.prototype.maskn=function(h){return this.clone().imaskn(h)},a.prototype.iaddn=function(h){return i(typeof h=="number"),i(h<67108864),h<0?this.isubn(-h):this.negative!==0?this.length===1&&(this.words[0]|0)<=h?(this.words[0]=h-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(h),this.negative=1,this):this._iaddn(h)},a.prototype._iaddn=function(h){this.words[0]+=h;for(var y=0;y<this.length&&this.words[y]>=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},a.prototype.isubn=function(h){if(i(typeof h=="number"),i(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y<this.length&&this.words[y]<0;y++)this.words[y]+=67108864,this.words[y+1]-=1;return this._strip()},a.prototype.addn=function(h){return this.clone().iaddn(h)},a.prototype.subn=function(h){return this.clone().isubn(h)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(h,y,b){var M=h.length+b,C;this._expand(M);var R,j=0;for(C=0;C<h.length;C++){R=(this.words[C+b]|0)+j;var S=(h.words[C]|0)*y;R-=S&67108863,j=(R>>26)-(S/67108864|0),this.words[C+b]=R&67108863}for(;C<this.length-b;C++)R=(this.words[C+b]|0)+j,j=R>>26,this.words[C+b]=R&67108863;if(j===0)return this._strip();for(i(j===-1),j=0,C=0;C<this.length;C++)R=-(this.words[C]|0)+j,j=R>>26,this.words[C]=R&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(h,y){var b=this.length-h.length,M=this.clone(),C=h,R=C.words[C.length-1]|0,j=this._countBits(R);b=26-j,b!==0&&(C=C.ushln(b),M.iushln(b),R=C.words[C.length-1]|0);var S=M.length-C.length,p;if(y!=="mod"){p=new a(null),p.length=S+1,p.words=new Array(p.length);for(var O=0;O<p.length;O++)p.words[O]=0}var it=M.clone()._ishlnsubmul(C,1,S);it.negative===0&&(M=it,p&&(p.words[S]=1));for(var lt=S-1;lt>=0;lt--){var _=(M.words[C.length+lt]|0)*67108864+(M.words[C.length+lt-1]|0);for(_=Math.min(_/R|0,67108863),M._ishlnsubmul(C,_,lt);M.negative!==0;)_--,M.negative=0,M._ishlnsubmul(C,1,lt),M.isZero()||(M.negative^=1);p&&(p.words[lt]=_)}return p&&p._strip(),M._strip(),y!=="div"&&b!==0&&M.iushrn(b),{div:p||null,mod:M}},a.prototype.divmod=function(h,y,b){if(i(!h.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var M,C,R;return this.negative!==0&&h.negative===0?(R=this.neg().divmod(h,y),y!=="mod"&&(M=R.div.neg()),y!=="div"&&(C=R.mod.neg(),b&&C.negative!==0&&C.iadd(h)),{div:M,mod:C}):this.negative===0&&h.negative!==0?(R=this.divmod(h.neg(),y),y!=="mod"&&(M=R.div.neg()),{div:M,mod:R.mod}):this.negative&h.negative?(R=this.neg().divmod(h.neg(),y),y!=="div"&&(C=R.mod.neg(),b&&C.negative!==0&&C.isub(h)),{div:R.div,mod:C}):h.length>this.length||this.cmp(h)<0?{div:new a(0),mod:this}:h.length===1?y==="div"?{div:this.divn(h.words[0]),mod:null}:y==="mod"?{div:null,mod:new a(this.modrn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new a(this.modrn(h.words[0]))}:this._wordDiv(h,y)},a.prototype.div=function(h){return this.divmod(h,"div",!1).div},a.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},a.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},a.prototype.divRound=function(h){var y=this.divmod(h);if(y.mod.isZero())return y.div;var b=y.div.negative!==0?y.mod.isub(h):y.mod,M=h.ushrn(1),C=h.andln(1),R=b.cmp(M);return R<0||C===1&&R===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},a.prototype.modrn=function(h){var y=h<0;y&&(h=-h),i(h<=67108863);for(var b=(1<<26)%h,M=0,C=this.length-1;C>=0;C--)M=(b*M+(this.words[C]|0))%h;return y?-M:M},a.prototype.modn=function(h){return this.modrn(h)},a.prototype.idivn=function(h){var y=h<0;y&&(h=-h),i(h<=67108863);for(var b=0,M=this.length-1;M>=0;M--){var C=(this.words[M]|0)+b*67108864;this.words[M]=C/h|0,b=C%h}return this._strip(),y?this.ineg():this},a.prototype.divn=function(h){return this.clone().idivn(h)},a.prototype.egcd=function(h){i(h.negative===0),i(!h.isZero());var y=this,b=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var M=new a(1),C=new a(0),R=new a(0),j=new a(1),S=0;y.isEven()&&b.isEven();)y.iushrn(1),b.iushrn(1),++S;for(var p=b.clone(),O=y.clone();!y.isZero();){for(var it=0,lt=1;!(y.words[0]&lt)&&it<26;++it,lt<<=1);if(it>0)for(y.iushrn(it);it-- >0;)(M.isOdd()||C.isOdd())&&(M.iadd(p),C.isub(O)),M.iushrn(1),C.iushrn(1);for(var _=0,Z=1;!(b.words[0]&Z)&&_<26;++_,Z<<=1);if(_>0)for(b.iushrn(_);_-- >0;)(R.isOdd()||j.isOdd())&&(R.iadd(p),j.isub(O)),R.iushrn(1),j.iushrn(1);y.cmp(b)>=0?(y.isub(b),M.isub(R),C.isub(j)):(b.isub(y),R.isub(M),j.isub(C))}return{a:R,b:j,gcd:b.iushln(S)}},a.prototype._invmp=function(h){i(h.negative===0),i(!h.isZero());var y=this,b=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var M=new a(1),C=new a(0),R=b.clone();y.cmpn(1)>0&&b.cmpn(1)>0;){for(var j=0,S=1;!(y.words[0]&S)&&j<26;++j,S<<=1);if(j>0)for(y.iushrn(j);j-- >0;)M.isOdd()&&M.iadd(R),M.iushrn(1);for(var p=0,O=1;!(b.words[0]&O)&&p<26;++p,O<<=1);if(p>0)for(b.iushrn(p);p-- >0;)C.isOdd()&&C.iadd(R),C.iushrn(1);y.cmp(b)>=0?(y.isub(b),M.isub(C)):(b.isub(y),C.isub(M))}var it;return y.cmpn(1)===0?it=M:it=C,it.cmpn(0)<0&&it.iadd(h),it},a.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var y=this.clone(),b=h.clone();y.negative=0,b.negative=0;for(var M=0;y.isEven()&&b.isEven();M++)y.iushrn(1),b.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;b.isEven();)b.iushrn(1);var C=y.cmp(b);if(C<0){var R=y;y=b,b=R}else if(C===0||b.cmpn(1)===0)break;y.isub(b)}while(!0);return b.iushln(M)},a.prototype.invm=function(h){return this.egcd(h).a.umod(h)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(h){return this.words[0]&h},a.prototype.bincn=function(h){i(typeof h=="number");var y=h%26,b=(h-y)/26,M=1<<y;if(this.length<=b)return this._expand(b+1),this.words[b]|=M,this;for(var C=M,R=b;C!==0&&R<this.length;R++){var j=this.words[R]|0;j+=C,C=j>>>26,j&=67108863,this.words[R]=j}return C!==0&&(this.words[R]=C,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(h){var y=h<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var b;if(this.length>1)b=1;else{y&&(h=-h),i(h<=67108863,"Number is too big");var M=this.words[0]|0;b=M===h?0:M<h?-1:1}return this.negative!==0?-b|0:b},a.prototype.cmp=function(h){if(this.negative!==0&&h.negative===0)return-1;if(this.negative===0&&h.negative!==0)return 1;var y=this.ucmp(h);return this.negative!==0?-y|0:y},a.prototype.ucmp=function(h){if(this.length>h.length)return 1;if(this.length<h.length)return-1;for(var y=0,b=this.length-1;b>=0;b--){var M=this.words[b]|0,C=h.words[b]|0;if(M!==C){M<C?y=-1:M>C&&(y=1);break}}return y},a.prototype.gtn=function(h){return this.cmpn(h)===1},a.prototype.gt=function(h){return this.cmp(h)===1},a.prototype.gten=function(h){return this.cmpn(h)>=0},a.prototype.gte=function(h){return this.cmp(h)>=0},a.prototype.ltn=function(h){return this.cmpn(h)===-1},a.prototype.lt=function(h){return this.cmp(h)===-1},a.prototype.lten=function(h){return this.cmpn(h)<=0},a.prototype.lte=function(h){return this.cmp(h)<=0},a.prototype.eqn=function(h){return this.cmpn(h)===0},a.prototype.eq=function(h){return this.cmp(h)===0},a.red=function(h){return new pt(h)},a.prototype.toRed=function(h){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(h){return this.red=h,this},a.prototype.forceRed=function(h){return i(!this.red,"Already a number in reduction context"),this._forceRed(h)},a.prototype.redAdd=function(h){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},a.prototype.redIAdd=function(h){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},a.prototype.redSub=function(h){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},a.prototype.redISub=function(h){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},a.prototype.redShl=function(h){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},a.prototype.redMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},a.prototype.redIMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},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(h){return i(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var z={k256:null,p224:null,p192:null,p25519:null};function $(h,y){this.name=h,this.p=new a(y,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 h=new a(null);return h.words=new Array(Math.ceil(this.n/13)),h},$.prototype.ireduce=function(h){var y=h,b;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),b=y.bitLength();while(b>this.n);var M=b<this.n?-1:y.ucmp(this.p);return M===0?(y.words[0]=0,y.length=1):M>0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},$.prototype.split=function(h,y){h.iushrn(this.n,0,y)},$.prototype.imulK=function(h){return h.imul(this.k)};function v(){$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(v,$),v.prototype.split=function(h,y){for(var b=4194303,M=Math.min(h.length,9),C=0;C<M;C++)y.words[C]=h.words[C];if(y.length=M,h.length<=9){h.words[0]=0,h.length=1;return}var R=h.words[9];for(y.words[y.length++]=R&b,C=10;C<h.length;C++){var j=h.words[C]|0;h.words[C-10]=(j&b)<<4|R>>>22,R=j}R>>>=22,h.words[C-10]=R,R===0&&h.length>10?h.length-=10:h.length-=9},v.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var y=0,b=0;b<h.length;b++){var M=h.words[b]|0;y+=M*977,h.words[b]=y&67108863,y=M*64+(y/67108864|0)}return h.words[h.length-1]===0&&(h.length--,h.words[h.length-1]===0&&h.length--),h};function T(){$.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(T,$);function nt(){$.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(nt,$);function ft(){$.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(ft,$),ft.prototype.imulK=function(h){for(var y=0,b=0;b<h.length;b++){var M=(h.words[b]|0)*19+y,C=M&67108863;M>>>=26,h.words[b]=C,y=M}return y!==0&&(h.words[h.length++]=y),h},a._prime=function(h){if(z[h])return z[h];var y;if(h==="k256")y=new v;else if(h==="p224")y=new T;else if(h==="p192")y=new nt;else if(h==="p25519")y=new ft;else throw new Error("Unknown prime "+h);return z[h]=y,y};function pt(h){if(typeof h=="string"){var y=a._prime(h);this.m=y.p,this.prime=y}else i(h.gtn(1),"modulus must be greater than 1"),this.m=h,this.prime=null}pt.prototype._verify1=function(h){i(h.negative===0,"red works only with positives"),i(h.red,"red works only with red numbers")},pt.prototype._verify2=function(h,y){i((h.negative|y.negative)===0,"red works only with positives"),i(h.red&&h.red===y.red,"red works only with red numbers")},pt.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):(w(h,h.umod(this.m)._forceRed(this)),h)},pt.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},pt.prototype.add=function(h,y){this._verify2(h,y);var b=h.add(y);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},pt.prototype.iadd=function(h,y){this._verify2(h,y);var b=h.iadd(y);return b.cmp(this.m)>=0&&b.isub(this.m),b},pt.prototype.sub=function(h,y){this._verify2(h,y);var b=h.sub(y);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},pt.prototype.isub=function(h,y){this._verify2(h,y);var b=h.isub(y);return b.cmpn(0)<0&&b.iadd(this.m),b},pt.prototype.shl=function(h,y){return this._verify1(h),this.imod(h.ushln(y))},pt.prototype.imul=function(h,y){return this._verify2(h,y),this.imod(h.imul(y))},pt.prototype.mul=function(h,y){return this._verify2(h,y),this.imod(h.mul(y))},pt.prototype.isqr=function(h){return this.imul(h,h.clone())},pt.prototype.sqr=function(h){return this.mul(h,h)},pt.prototype.sqrt=function(h){if(h.isZero())return h.clone();var y=this.m.andln(3);if(i(y%2===1),y===3){var b=this.m.add(new a(1)).iushrn(2);return this.pow(h,b)}for(var M=this.m.subn(1),C=0;!M.isZero()&&M.andln(1)===0;)C++,M.iushrn(1);i(!M.isZero());var R=new a(1).toRed(this),j=R.redNeg(),S=this.m.subn(1).iushrn(1),p=this.m.bitLength();for(p=new a(2*p*p).toRed(this);this.pow(p,S).cmp(j)!==0;)p.redIAdd(j);for(var O=this.pow(p,M),it=this.pow(h,M.addn(1).iushrn(1)),lt=this.pow(h,M),_=C;lt.cmp(R)!==0;){for(var Z=lt,U=0;Z.cmp(R)!==0;U++)Z=Z.redSqr();i(U<_);var L=this.pow(O,new a(1).iushln(_-U-1));it=it.redMul(L),O=L.redSqr(),lt=lt.redMul(O),_=U}return it},pt.prototype.invm=function(h){var y=h._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},pt.prototype.pow=function(h,y){if(y.isZero())return new a(1).toRed(this);if(y.cmpn(1)===0)return h.clone();var b=4,M=new Array(1<<b);M[0]=new a(1).toRed(this),M[1]=h;for(var C=2;C<M.length;C++)M[C]=this.mul(M[C-1],h);var R=M[0],j=0,S=0,p=y.bitLength()%26;for(p===0&&(p=26),C=y.length-1;C>=0;C--){for(var O=y.words[C],it=p-1;it>=0;it--){var lt=O>>it&1;if(R!==M[0]&&(R=this.sqr(R)),lt===0&&j===0){S=0;continue}j<<=1,j|=lt,S++,!(S!==b&&(C!==0||it!==0))&&(R=this.mul(R,M[j]),S=0,j=0)}p=26}return R},pt.prototype.convertTo=function(h){var y=h.umod(this.m);return y===h?y.clone():y},pt.prototype.convertFrom=function(h){var y=h.clone();return y.red=null,y},a.mont=function(h){return new mt(h)};function mt(h){pt.call(this,h),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)}s(mt,pt),mt.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},mt.prototype.convertFrom=function(h){var y=this.imod(h.mul(this.rinv));return y.red=null,y},mt.prototype.imul=function(h,y){if(h.isZero()||y.isZero())return h.words[0]=0,h.length=1,h;var b=h.imul(y),M=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),C=b.isub(M).iushrn(this.shift),R=C;return C.cmp(this.m)>=0?R=C.isub(this.m):C.cmpn(0)<0&&(R=C.iadd(this.m)),R._forceRed(this)},mt.prototype.mul=function(h,y){if(h.isZero()||y.isZero())return new a(0)._forceRed(this);var b=h.mul(y),M=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),C=b.isub(M).iushrn(this.shift),R=C;return C.cmp(this.m)>=0?R=C.isub(this.m):C.cmpn(0)<0&&(R=C.iadd(this.m)),R._forceRed(this)},mt.prototype.invm=function(h){var y=this.imod(h._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(r,X1)})(rg);var ne=rg.exports;const ig="bignumber/5.7.0";var Vc=ne.BN;const Sn=new mr(ig),Th={},jd=9007199254740991;function ZE(r){return r!=null&&(Fr.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||ii(r)||typeof r=="bigint"||mo(r))}let $d=!1,Fr=class Fi{constructor(t,e){t!==Th&&Sn.throwError("cannot call constructor directly; use BigNumber.from",mr.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return $r(me(this).fromTwos(t))}toTwos(t){return $r(me(this).toTwos(t))}abs(){return this._hex[0]==="-"?Fi.from(this._hex.substring(1)):this}add(t){return $r(me(this).add(me(t)))}sub(t){return $r(me(this).sub(me(t)))}div(t){return Fi.from(t).isZero()&&wi("division-by-zero","div"),$r(me(this).div(me(t)))}mul(t){return $r(me(this).mul(me(t)))}mod(t){const e=me(t);return e.isNeg()&&wi("division-by-zero","mod"),$r(me(this).umod(e))}pow(t){const e=me(t);return e.isNeg()&&wi("negative-power","pow"),$r(me(this).pow(e))}and(t){const e=me(t);return(this.isNegative()||e.isNeg())&&wi("unbound-bitwise-result","and"),$r(me(this).and(e))}or(t){const e=me(t);return(this.isNegative()||e.isNeg())&&wi("unbound-bitwise-result","or"),$r(me(this).or(e))}xor(t){const e=me(t);return(this.isNegative()||e.isNeg())&&wi("unbound-bitwise-result","xor"),$r(me(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&wi("negative-width","mask"),$r(me(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&wi("negative-width","shl"),$r(me(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&wi("negative-width","shr"),$r(me(this).shrn(t))}eq(t){return me(this).eq(me(t))}lt(t){return me(this).lt(me(t))}lte(t){return me(this).lte(me(t))}gt(t){return me(this).gt(me(t))}gte(t){return me(this).gte(me(t))}isNegative(){return this._hex[0]==="-"}isZero(){return me(this).isZero()}toNumber(){try{return me(this).toNumber()}catch{wi("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return Sn.throwError("this platform does not support BigInt",mr.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?$d||($d=!0,Sn.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?Sn.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",mr.errors.UNEXPECTED_ARGUMENT,{}):Sn.throwError("BigNumber.toString does not accept parameters",mr.errors.UNEXPECTED_ARGUMENT,{})),me(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof Fi)return t;if(typeof t=="string")return t.match(/^-?0x[0-9a-f]+$/i)?new Fi(Th,ia(t)):t.match(/^-?[0-9]+$/)?new Fi(Th,ia(new Vc(t))):Sn.throwArgumentError("invalid BigNumber string","value",t);if(typeof t=="number")return t%1&&wi("underflow","BigNumber.from",t),(t>=jd||t<=-jd)&&wi("overflow","BigNumber.from",t),Fi.from(String(t));const e=t;if(typeof e=="bigint")return Fi.from(e.toString());if(mo(e))return Fi.from(Pr(e));if(e)if(e.toHexString){const i=e.toHexString();if(typeof i=="string")return Fi.from(i)}else{let i=e._hex;if(i==null&&e.type==="BigNumber"&&(i=e.hex),typeof i=="string"&&(ii(i)||i[0]==="-"&&ii(i.substring(1))))return Fi.from(i)}return Sn.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}};function ia(r){if(typeof r!="string")return ia(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&Sn.throwArgumentError("invalid hex","value",r),r=ia(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 $r(r){return Fr.from(ia(r))}function me(r){const t=Fr.from(r).toHexString();return t[0]==="-"?new Vc("-"+t.substring(3),16):new Vc(t.substring(2),16)}function wi(r,t,e){const i={fault:r,operation:t};return e!=null&&(i.value=e),Sn.throwError(r,mr.errors.NUMERIC_FAULT,i)}function t5(r){return new Vc(r,36).toString(16)}const Or=new mr(ig),Xo={},ng=Fr.from(0),sg=Fr.from(-1);function og(r,t,e,i){const s={fault:t,operation:e};return i!==void 0&&(s.value=i),Or.throwError(r,mr.errors.NUMERIC_FAULT,s)}let Zo="0";for(;Zo.length<256;)Zo+=Zo;function kl(r){if(typeof r!="number")try{r=Fr.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+Zo.substring(0,r):Or.throwArgumentError("invalid decimal size","decimals",r)}function Fh(r,t){t==null&&(t=0);const e=kl(t);r=Fr.from(r);const i=r.lt(ng);i&&(r=r.mul(sg));let s=r.mod(e).toString();for(;s.length<e.length-1;)s="0"+s;s=s.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=r.div(e).toString();return e.length===1?r=a:r=a+"."+s,i&&(r="-"+r),r}function _n(r,t){t==null&&(t=0);const e=kl(t);(typeof r!="string"||!r.match(/^-?[0-9.]+$/))&&Or.throwArgumentError("invalid decimal value","value",r);const i=r.substring(0,1)==="-";i&&(r=r.substring(1)),r==="."&&Or.throwArgumentError("missing value","value",r);const s=r.split(".");s.length>2&&Or.throwArgumentError("too many decimal points","value",r);let a=s[0],u=s[1];for(a||(a="0"),u||(u="0");u[u.length-1]==="0";)u=u.substring(0,u.length-1);for(u.length>e.length-1&&og("fractional component exceeds decimals","underflow","parseFixed"),u===""&&(u="0");u.length<e.length-1;)u+="0";const l=Fr.from(a),m=Fr.from(u);let f=l.mul(e).add(m);return i&&(f=f.mul(sg)),f}let Uh=class vl{constructor(t,e,i,s){t!==Xo&&Or.throwError("cannot use FixedFormat constructor; use FixedFormat.from",mr.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=e,this.width=i,this.decimals=s,this.name=(e?"":"u")+"fixed"+String(i)+"x"+String(s),this._multiplier=kl(s),Object.freeze(this)}static from(t){if(t instanceof vl)return t;typeof t=="number"&&(t=`fixed128x${t}`);let e=!0,i=128,s=18;if(typeof t=="string"){if(t!=="fixed")if(t==="ufixed")e=!1;else{const a=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);a||Or.throwArgumentError("invalid fixed format","format",t),e=a[1]!=="u",i=parseInt(a[2]),s=parseInt(a[3])}}else if(t){const a=(u,l,m)=>t[u]==null?m:(typeof t[u]!==l&&Or.throwArgumentError("invalid fixed format ("+u+" not "+l+")","format."+u,t[u]),t[u]);e=a("signed","boolean",e),i=a("width","number",i),s=a("decimals","number",s)}return i%8&&Or.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),s>80&&Or.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",s),new vl(Xo,e,i,s)}},ag=class Cr{constructor(t,e,i,s){t!==Xo&&Or.throwError("cannot use FixedNumber constructor; use FixedNumber.from",mr.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=s,this._hex=e,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&Or.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const e=_n(this._value,this.format.decimals),i=_n(t._value,t.format.decimals);return Cr.fromValue(e.add(i),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const e=_n(this._value,this.format.decimals),i=_n(t._value,t.format.decimals);return Cr.fromValue(e.sub(i),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const e=_n(this._value,this.format.decimals),i=_n(t._value,t.format.decimals);return Cr.fromValue(e.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const e=_n(this._value,this.format.decimals),i=_n(t._value,t.format.decimals);return Cr.fromValue(e.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");t.length===1&&t.push("0");let e=Cr.from(t[0],this.format);const i=!t[1].match(/^(0*)$/);return this.isNegative()&&i&&(e=e.subUnsafe(zd.toFormat(e.format))),e}ceiling(){const t=this.toString().split(".");t.length===1&&t.push("0");let e=Cr.from(t[0],this.format);const i=!t[1].match(/^(0*)$/);return!this.isNegative()&&i&&(e=e.addUnsafe(zd.toFormat(e.format))),e}round(t){t==null&&(t=0);const e=this.toString().split(".");if(e.length===1&&e.push("0"),(t<0||t>80||t%1)&&Or.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;const i=Cr.from("1"+Zo.substring(0,t),this.format),s=e5.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(s).floor().divUnsafe(i)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(t){if(t==null)return this._hex;t%8&&Or.throwArgumentError("invalid byte width","width",t);const e=Fr.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString();return nn(e,t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return Cr.fromString(this._value,t)}static fromValue(t,e,i){return i==null&&e!=null&&!ZE(e)&&(i=e,e=null),e==null&&(e=0),i==null&&(i="fixed"),Cr.fromString(Fh(t,e),Uh.from(i))}static fromString(t,e){e==null&&(e="fixed");const i=Uh.from(e),s=_n(t,i.decimals);!i.signed&&s.lt(ng)&&og("unsigned value cannot be negative","overflow","value",t);let a=null;i.signed?a=s.toTwos(i.width).toHexString():(a=s.toHexString(),a=nn(a,i.width/8));const u=Fh(s,i.decimals);return new Cr(Xo,a,u,i)}static fromBytes(t,e){e==null&&(e="fixed");const i=Uh.from(e);if(Ye(t).length>i.width/8)throw new Error("overflow");let s=Fr.from(t);i.signed&&(s=s.fromTwos(i.width));const a=s.toTwos((i.signed?0:1)+i.width).toHexString(),u=Fh(s,i.decimals);return new Cr(Xo,a,u,i)}static from(t,e){if(typeof t=="string")return Cr.fromString(t,e);if(mo(t))return Cr.fromBytes(t,e);try{return Cr.fromValue(t,0,e)}catch(i){if(i.code!==mr.errors.INVALID_ARGUMENT)throw i}return Or.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!!(t&&t._isFixedNumber)}};const zd=ag.from(1),e5=ag.from("0.5"),r5="strings/5.7.0",i5=new mr(r5);var Gc;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(Gc||(Gc={}));var kd;(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"})(kd||(kd={}));function Bh(r,t=Gc.current){t!=Gc.current&&(i5.checkNormalize(),r=r.normalize(t));let e=[];for(let i=0;i<r.length;i++){const s=r.charCodeAt(i);if(s<128)e.push(s);else if(s<2048)e.push(s>>6|192),e.push(s&63|128);else if((s&64512)==55296){i++;const a=r.charCodeAt(i);if(i>=r.length||(a&64512)!==56320)throw new Error("invalid utf-8 string");const u=65536+((s&1023)<<10)+(a&1023);e.push(u>>18|240),e.push(u>>12&63|128),e.push(u>>6&63|128),e.push(u&63|128)}else e.push(s>>12|224),e.push(s>>6&63|128),e.push(s&63|128)}return Ye(e)}function n5(r){if(r.length%4!==0)throw new Error("bad data");let t=[];for(let e=0;e<r.length;e+=4)t.push(parseInt(r.substring(e,e+4),16));return t}function Lh(r,t){t||(t=function(s){return[parseInt(s,16)]});let e=0,i={};return r.split(",").forEach(s=>{let a=s.split(":");e+=parseInt(a[0],16),i[e]=t(a[1])}),i}function Hd(r){let t=0;return r.split(",").map(e=>{let i=e.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let s=t+parseInt(i[0],16);return t=parseInt(i[1],16),{l:s,h:t}})}Hd("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)),Lh("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"),Lh("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"),Lh("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",n5),Hd("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 s5(r){r=atob(r);const t=[];for(let e=0;e<r.length;e++)t.push(r.charCodeAt(e));return Ye(t)}function cg(r,t){t==null&&(t=1);const e=[],i=e.forEach,s=function(a,u){i.call(a,function(l){u>0&&Array.isArray(l)?s(l,u-1):e.push(l)})};return s(r,t),e}function o5(r){const t={};for(let e=0;e<r.length;e++){const i=r[e];t[i[0]]=i[1]}return t}function a5(r){let t=0;function e(){return r[t++]<<8|r[t++]}let i=e(),s=1,a=[0,1];for(let z=1;z<i;z++)a.push(s+=e());let u=e(),l=t;t+=u;let m=0,f=0;function w(){return m==0&&(f=f<<8|r[t++],m=8),f>>--m&1}const E=31,x=Math.pow(2,E),I=x>>>1,N=I>>1,Y=x-1;let G=0;for(let z=0;z<E;z++)G=G<<1|w();let tt=[],K=0,V=x;for(;;){let z=Math.floor(((G-K+1)*s-1)/V),$=0,v=i;for(;v-$>1;){let ft=$+v>>>1;z<a[ft]?v=ft:$=ft}if($==0)break;tt.push($);let T=K+Math.floor(V*a[$]/s),nt=K+Math.floor(V*a[$+1]/s)-1;for(;!((T^nt)&I);)G=G<<1&Y|w(),T=T<<1&Y,nt=nt<<1&Y|1;for(;T&~nt&N;)G=G&I|G<<1&Y>>>1|w(),T=T<<1^I,nt=(nt^I)<<1|I|1;K=T,V=1+nt-T}let B=i-4;return tt.map(z=>{switch(z-B){case 3:return B+65792+(r[l++]<<16|r[l++]<<8|r[l++]);case 2:return B+256+(r[l++]<<8|r[l++]);case 1:return B+r[l++];default:return z-1}})}function c5(r){let t=0;return()=>r[t++]}function u5(r){return c5(a5(r))}function h5(r){return r&1?~r>>1:r>>1}function l5(r,t){let e=Array(r);for(let i=0;i<r;i++)e[i]=1+t();return e}function Kd(r,t){let e=Array(r);for(let i=0,s=-1;i<r;i++)e[i]=s+=1+t();return e}function f5(r,t){let e=Array(r);for(let i=0,s=0;i<r;i++)e[i]=s+=h5(t());return e}function Wc(r,t){let e=Kd(r(),r),i=r(),s=Kd(i,r),a=l5(i,r);for(let u=0;u<i;u++)for(let l=0;l<a[u];l++)e.push(s[u]+l);return t?e.map(u=>t[u]):e}function d5(r){let t=[];for(;;){let e=r();if(e==0)break;t.push(g5(e,r))}for(;;){let e=r()-1;if(e<0)break;t.push(m5(e,r))}return o5(cg(t))}function p5(r){let t=[];for(;;){let e=r();if(e==0)break;t.push(e)}return t}function ug(r,t,e){let i=Array(r).fill(void 0).map(()=>[]);for(let s=0;s<t;s++)f5(r,e).forEach((a,u)=>i[u].push(a));return i}function g5(r,t){let e=1+t(),i=t(),s=p5(t),a=ug(s.length,1+r,t);return cg(a.map((u,l)=>{const m=u[0],f=u.slice(1);return Array(s[l]).fill(void 0).map((w,E)=>{let x=E*i;return[m+E*e,f.map(I=>I+x)]})}))}function m5(r,t){let e=1+t();return ug(e,1+r,t).map(i=>[i[0],i.slice(1)])}function v5(r){let t=Wc(r).sort((i,s)=>i-s);return e();function e(){let i=[];for(;;){let f=Wc(r,t);if(f.length==0)break;i.push({set:new Set(f),node:e()})}i.sort((f,w)=>w.set.size-f.set.size);let s=r(),a=s%3;s=s/3|0;let u=!!(s&1);s>>=1;let l=s==1,m=s==2;return{branches:i,valid:a,fe0f:u,save:l,check:m}}}function y5(){return u5(s5("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 Ac=y5();new Set(Wc(Ac)),new Set(Wc(Ac)),d5(Ac),v5(Ac);const w5=new Uint8Array(32);w5.fill(0);const b5=`Ethereum Signed Message:
9
+ `;function hg(r){return typeof r=="string"&&(r=Bh(r)),zl(GE([Bh(b5),Bh(String(r.length)),r]))}const _5="address/5.7.0",Yo=new mr(_5);function Vd(r){ii(r,20)||Yo.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const t=r.substring(2).split(""),e=new Uint8Array(40);for(let s=0;s<40;s++)e[s]=t[s].charCodeAt(0);const i=Ye(zl(e));for(let s=0;s<40;s+=2)i[s>>1]>>4>=8&&(t[s]=t[s].toUpperCase()),(i[s>>1]&15)>=8&&(t[s+1]=t[s+1].toUpperCase());return"0x"+t.join("")}const E5=9007199254740991;function A5(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const Hl={};for(let r=0;r<10;r++)Hl[String(r)]=String(r);for(let r=0;r<26;r++)Hl[String.fromCharCode(65+r)]=String(10+r);const Gd=Math.floor(A5(E5));function S5(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let t=r.split("").map(i=>Hl[i]).join("");for(;t.length>=Gd;){let i=t.substring(0,Gd);t=parseInt(i,10)%97+t.substring(i.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}function I5(r){let t=null;if(typeof r!="string"&&Yo.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),t=Vd(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==r&&Yo.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)!==S5(r)&&Yo.throwArgumentError("bad icap checksum","address",r),t=t5(r.substring(4));t.length<40;)t="0"+t;t=Vd("0x"+t)}else Yo.throwArgumentError("invalid address","address",r);return t}function zo(r,t,e){Object.defineProperty(r,t,{enumerable:!0,value:e,writable:!1})}const D5=new Uint8Array(32);D5.fill(0),Fr.from(-1);const x5=Fr.from(0),M5=Fr.from(1);Fr.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),nn(M5.toHexString(),32),nn(x5.toHexString(),32);var Yi={},ve={},da=lg;function lg(r,t){if(!r)throw new Error(t||"Assertion failed")}lg.equal=function(r,t,e){if(r!=t)throw new Error(e||"Assertion failed: "+r+" != "+t)};var yl={exports:{}};typeof Object.create=="function"?yl.exports=function(r,t){t&&(r.super_=t,r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:yl.exports=function(r,t){if(t){r.super_=t;var e=function(){};e.prototype=t.prototype,r.prototype=new e,r.prototype.constructor=r}};var C5=da,P5=yl.exports;ve.inherits=P5;function O5(r,t){return(r.charCodeAt(t)&64512)!==55296||t<0||t+1>=r.length?!1:(r.charCodeAt(t+1)&64512)===56320}function N5(r,t){if(Array.isArray(r))return r.slice();if(!r)return[];var e=[];if(typeof r=="string")if(t){if(t==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),s=0;s<r.length;s+=2)e.push(parseInt(r[s]+r[s+1],16))}else for(var i=0,s=0;s<r.length;s++){var a=r.charCodeAt(s);a<128?e[i++]=a:a<2048?(e[i++]=a>>6|192,e[i++]=a&63|128):O5(r,s)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++s)&1023),e[i++]=a>>18|240,e[i++]=a>>12&63|128,e[i++]=a>>6&63|128,e[i++]=a&63|128):(e[i++]=a>>12|224,e[i++]=a>>6&63|128,e[i++]=a&63|128)}else for(s=0;s<r.length;s++)e[s]=r[s]|0;return e}ve.toArray=N5;function R5(r){for(var t="",e=0;e<r.length;e++)t+=dg(r[e].toString(16));return t}ve.toHex=R5;function fg(r){var t=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return t>>>0}ve.htonl=fg;function T5(r,t){for(var e="",i=0;i<r.length;i++){var s=r[i];t==="little"&&(s=fg(s)),e+=pg(s.toString(16))}return e}ve.toHex32=T5;function dg(r){return r.length===1?"0"+r:r}ve.zero2=dg;function pg(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}ve.zero8=pg;function F5(r,t,e,i){var s=e-t;C5(s%4===0);for(var a=new Array(s/4),u=0,l=t;u<a.length;u++,l+=4){var m;i==="big"?m=r[l]<<24|r[l+1]<<16|r[l+2]<<8|r[l+3]:m=r[l+3]<<24|r[l+2]<<16|r[l+1]<<8|r[l],a[u]=m>>>0}return a}ve.join32=F5;function U5(r,t){for(var e=new Array(r.length*4),i=0,s=0;i<r.length;i++,s+=4){var a=r[i];t==="big"?(e[s]=a>>>24,e[s+1]=a>>>16&255,e[s+2]=a>>>8&255,e[s+3]=a&255):(e[s+3]=a>>>24,e[s+2]=a>>>16&255,e[s+1]=a>>>8&255,e[s]=a&255)}return e}ve.split32=U5;function B5(r,t){return r>>>t|r<<32-t}ve.rotr32=B5;function L5(r,t){return r<<t|r>>>32-t}ve.rotl32=L5;function q5(r,t){return r+t>>>0}ve.sum32=q5;function j5(r,t,e){return r+t+e>>>0}ve.sum32_3=j5;function $5(r,t,e,i){return r+t+e+i>>>0}ve.sum32_4=$5;function z5(r,t,e,i,s){return r+t+e+i+s>>>0}ve.sum32_5=z5;function k5(r,t,e,i){var s=r[t],a=r[t+1],u=i+a>>>0,l=(u<i?1:0)+e+s;r[t]=l>>>0,r[t+1]=u}ve.sum64=k5;function H5(r,t,e,i){var s=t+i>>>0,a=(s<t?1:0)+r+e;return a>>>0}ve.sum64_hi=H5;function K5(r,t,e,i){var s=t+i;return s>>>0}ve.sum64_lo=K5;function V5(r,t,e,i,s,a,u,l){var m=0,f=t;f=f+i>>>0,m+=f<t?1:0,f=f+a>>>0,m+=f<a?1:0,f=f+l>>>0,m+=f<l?1:0;var w=r+e+s+u+m;return w>>>0}ve.sum64_4_hi=V5;function G5(r,t,e,i,s,a,u,l){var m=t+i+a+l;return m>>>0}ve.sum64_4_lo=G5;function W5(r,t,e,i,s,a,u,l,m,f){var w=0,E=t;E=E+i>>>0,w+=E<t?1:0,E=E+a>>>0,w+=E<a?1:0,E=E+l>>>0,w+=E<l?1:0,E=E+f>>>0,w+=E<f?1:0;var x=r+e+s+u+m+w;return x>>>0}ve.sum64_5_hi=W5;function Y5(r,t,e,i,s,a,u,l,m,f){var w=t+i+a+l+f;return w>>>0}ve.sum64_5_lo=Y5;function Q5(r,t,e){var i=t<<32-e|r>>>e;return i>>>0}ve.rotr64_hi=Q5;function J5(r,t,e){var i=r<<32-e|t>>>e;return i>>>0}ve.rotr64_lo=J5;function X5(r,t,e){return r>>>e}ve.shr64_hi=X5;function Z5(r,t,e){var i=r<<32-e|t>>>e;return i>>>0}ve.shr64_lo=Z5;var vo={},Wd=ve,tA=da;function Sc(){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}vo.BlockHash=Sc,Sc.prototype.update=function(r,t){if(r=Wd.toArray(r,t),this.pending?this.pending=this.pending.concat(r):this.pending=r,this.pendingTotal+=r.length,this.pending.length>=this._delta8){r=this.pending;var e=r.length%this._delta8;this.pending=r.slice(r.length-e,r.length),this.pending.length===0&&(this.pending=null),r=Wd.join32(r,0,r.length-e,this.endian);for(var i=0;i<r.length;i+=this._delta32)this._update(r,i,i+this._delta32)}return this},Sc.prototype.digest=function(r){return this.update(this._pad()),tA(this.pending===null),this._digest(r)},Sc.prototype._pad=function(){var r=this.pendingTotal,t=this._delta8,e=t-(r+this.padLength)%t,i=new Array(e+this.padLength);i[0]=128;for(var s=1;s<e;s++)i[s]=0;if(r<<=3,this.endian==="big"){for(var a=8;a<this.padLength;a++)i[s++]=0;i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=r>>>24&255,i[s++]=r>>>16&255,i[s++]=r>>>8&255,i[s++]=r&255}else for(i[s++]=r&255,i[s++]=r>>>8&255,i[s++]=r>>>16&255,i[s++]=r>>>24&255,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,a=8;a<this.padLength;a++)i[s++]=0;return i};var to={},hn={},eA=ve,sn=eA.rotr32;function rA(r,t,e,i){if(r===0)return gg(t,e,i);if(r===1||r===3)return vg(t,e,i);if(r===2)return mg(t,e,i)}hn.ft_1=rA;function gg(r,t,e){return r&t^~r&e}hn.ch32=gg;function mg(r,t,e){return r&t^r&e^t&e}hn.maj32=mg;function vg(r,t,e){return r^t^e}hn.p32=vg;function iA(r){return sn(r,2)^sn(r,13)^sn(r,22)}hn.s0_256=iA;function nA(r){return sn(r,6)^sn(r,11)^sn(r,25)}hn.s1_256=nA;function sA(r){return sn(r,7)^sn(r,18)^r>>>3}hn.g0_256=sA;function oA(r){return sn(r,17)^sn(r,19)^r>>>10}hn.g1_256=oA;var uo=ve,aA=vo,cA=hn,qh=uo.rotl32,ko=uo.sum32,uA=uo.sum32_5,hA=cA.ft_1,yg=aA.BlockHash,lA=[1518500249,1859775393,2400959708,3395469782];function tn(){if(!(this instanceof tn))return new tn;yg.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}uo.inherits(tn,yg);var fA=tn;tn.blockSize=512,tn.outSize=160,tn.hmacStrength=80,tn.padLength=64,tn.prototype._update=function(r,t){for(var e=this.W,i=0;i<16;i++)e[i]=r[t+i];for(;i<e.length;i++)e[i]=qh(e[i-3]^e[i-8]^e[i-14]^e[i-16],1);var s=this.h[0],a=this.h[1],u=this.h[2],l=this.h[3],m=this.h[4];for(i=0;i<e.length;i++){var f=~~(i/20),w=uA(qh(s,5),hA(f,a,u,l),m,e[i],lA[f]);m=l,l=u,u=qh(a,30),a=s,s=w}this.h[0]=ko(this.h[0],s),this.h[1]=ko(this.h[1],a),this.h[2]=ko(this.h[2],u),this.h[3]=ko(this.h[3],l),this.h[4]=ko(this.h[4],m)},tn.prototype._digest=function(r){return r==="hex"?uo.toHex32(this.h,"big"):uo.split32(this.h,"big")};var ho=ve,dA=vo,yo=hn,pA=da,Ri=ho.sum32,gA=ho.sum32_4,mA=ho.sum32_5,vA=yo.ch32,yA=yo.maj32,wA=yo.s0_256,bA=yo.s1_256,_A=yo.g0_256,EA=yo.g1_256,wg=dA.BlockHash,AA=[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 en(){if(!(this instanceof en))return new en;wg.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=AA,this.W=new Array(64)}ho.inherits(en,wg);var bg=en;en.blockSize=512,en.outSize=256,en.hmacStrength=192,en.padLength=64,en.prototype._update=function(r,t){for(var e=this.W,i=0;i<16;i++)e[i]=r[t+i];for(;i<e.length;i++)e[i]=gA(EA(e[i-2]),e[i-7],_A(e[i-15]),e[i-16]);var s=this.h[0],a=this.h[1],u=this.h[2],l=this.h[3],m=this.h[4],f=this.h[5],w=this.h[6],E=this.h[7];for(pA(this.k.length===e.length),i=0;i<e.length;i++){var x=mA(E,bA(m),vA(m,f,w),this.k[i],e[i]),I=Ri(wA(s),yA(s,a,u));E=w,w=f,f=m,m=Ri(l,x),l=u,u=a,a=s,s=Ri(x,I)}this.h[0]=Ri(this.h[0],s),this.h[1]=Ri(this.h[1],a),this.h[2]=Ri(this.h[2],u),this.h[3]=Ri(this.h[3],l),this.h[4]=Ri(this.h[4],m),this.h[5]=Ri(this.h[5],f),this.h[6]=Ri(this.h[6],w),this.h[7]=Ri(this.h[7],E)},en.prototype._digest=function(r){return r==="hex"?ho.toHex32(this.h,"big"):ho.split32(this.h,"big")};var wl=ve,_g=bg;function In(){if(!(this instanceof In))return new In;_g.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}wl.inherits(In,_g);var SA=In;In.blockSize=512,In.outSize=224,In.hmacStrength=192,In.padLength=64,In.prototype._digest=function(r){return r==="hex"?wl.toHex32(this.h.slice(0,7),"big"):wl.split32(this.h.slice(0,7),"big")};var Vr=ve,IA=vo,DA=da,on=Vr.rotr64_hi,an=Vr.rotr64_lo,Eg=Vr.shr64_hi,Ag=Vr.shr64_lo,kn=Vr.sum64,jh=Vr.sum64_hi,$h=Vr.sum64_lo,xA=Vr.sum64_4_hi,MA=Vr.sum64_4_lo,CA=Vr.sum64_5_hi,PA=Vr.sum64_5_lo,Sg=IA.BlockHash,OA=[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 Bi(){if(!(this instanceof Bi))return new Bi;Sg.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=OA,this.W=new Array(160)}Vr.inherits(Bi,Sg);var Ig=Bi;Bi.blockSize=1024,Bi.outSize=512,Bi.hmacStrength=192,Bi.padLength=128,Bi.prototype._prepareBlock=function(r,t){for(var e=this.W,i=0;i<32;i++)e[i]=r[t+i];for(;i<e.length;i+=2){var s=zA(e[i-4],e[i-3]),a=kA(e[i-4],e[i-3]),u=e[i-14],l=e[i-13],m=jA(e[i-30],e[i-29]),f=$A(e[i-30],e[i-29]),w=e[i-32],E=e[i-31];e[i]=xA(s,a,u,l,m,f,w,E),e[i+1]=MA(s,a,u,l,m,f,w,E)}},Bi.prototype._update=function(r,t){this._prepareBlock(r,t);var e=this.W,i=this.h[0],s=this.h[1],a=this.h[2],u=this.h[3],l=this.h[4],m=this.h[5],f=this.h[6],w=this.h[7],E=this.h[8],x=this.h[9],I=this.h[10],N=this.h[11],Y=this.h[12],G=this.h[13],tt=this.h[14],K=this.h[15];DA(this.k.length===e.length);for(var V=0;V<e.length;V+=2){var B=tt,z=K,$=LA(E,x),v=qA(E,x),T=NA(E,x,I,N,Y),nt=RA(E,x,I,N,Y,G),ft=this.k[V],pt=this.k[V+1],mt=e[V],h=e[V+1],y=CA(B,z,$,v,T,nt,ft,pt,mt,h),b=PA(B,z,$,v,T,nt,ft,pt,mt,h);B=UA(i,s),z=BA(i,s),$=TA(i,s,a,u,l),v=FA(i,s,a,u,l,m);var M=jh(B,z,$,v),C=$h(B,z,$,v);tt=Y,K=G,Y=I,G=N,I=E,N=x,E=jh(f,w,y,b),x=$h(w,w,y,b),f=l,w=m,l=a,m=u,a=i,u=s,i=jh(y,b,M,C),s=$h(y,b,M,C)}kn(this.h,0,i,s),kn(this.h,2,a,u),kn(this.h,4,l,m),kn(this.h,6,f,w),kn(this.h,8,E,x),kn(this.h,10,I,N),kn(this.h,12,Y,G),kn(this.h,14,tt,K)},Bi.prototype._digest=function(r){return r==="hex"?Vr.toHex32(this.h,"big"):Vr.split32(this.h,"big")};function NA(r,t,e,i,s){var a=r&e^~r&s;return a<0&&(a+=4294967296),a}function RA(r,t,e,i,s,a){var u=t&i^~t&a;return u<0&&(u+=4294967296),u}function TA(r,t,e,i,s){var a=r&e^r&s^e&s;return a<0&&(a+=4294967296),a}function FA(r,t,e,i,s,a){var u=t&i^t&a^i&a;return u<0&&(u+=4294967296),u}function UA(r,t){var e=on(r,t,28),i=on(t,r,2),s=on(t,r,7),a=e^i^s;return a<0&&(a+=4294967296),a}function BA(r,t){var e=an(r,t,28),i=an(t,r,2),s=an(t,r,7),a=e^i^s;return a<0&&(a+=4294967296),a}function LA(r,t){var e=on(r,t,14),i=on(r,t,18),s=on(t,r,9),a=e^i^s;return a<0&&(a+=4294967296),a}function qA(r,t){var e=an(r,t,14),i=an(r,t,18),s=an(t,r,9),a=e^i^s;return a<0&&(a+=4294967296),a}function jA(r,t){var e=on(r,t,1),i=on(r,t,8),s=Eg(r,t,7),a=e^i^s;return a<0&&(a+=4294967296),a}function $A(r,t){var e=an(r,t,1),i=an(r,t,8),s=Ag(r,t,7),a=e^i^s;return a<0&&(a+=4294967296),a}function zA(r,t){var e=on(r,t,19),i=on(t,r,29),s=Eg(r,t,6),a=e^i^s;return a<0&&(a+=4294967296),a}function kA(r,t){var e=an(r,t,19),i=an(t,r,29),s=Ag(r,t,6),a=e^i^s;return a<0&&(a+=4294967296),a}var bl=ve,Dg=Ig;function Dn(){if(!(this instanceof Dn))return new Dn;Dg.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}bl.inherits(Dn,Dg);var HA=Dn;Dn.blockSize=1024,Dn.outSize=384,Dn.hmacStrength=192,Dn.padLength=128,Dn.prototype._digest=function(r){return r==="hex"?bl.toHex32(this.h.slice(0,12),"big"):bl.split32(this.h.slice(0,12),"big")},to.sha1=fA,to.sha224=SA,to.sha256=bg,to.sha384=HA,to.sha512=Ig;var xg={},Is=ve,KA=vo,Ic=Is.rotl32,Yd=Is.sum32,Ho=Is.sum32_3,Qd=Is.sum32_4,Mg=KA.BlockHash;function Qi(){if(!(this instanceof Qi))return new Qi;Mg.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Is.inherits(Qi,Mg),xg.ripemd160=Qi,Qi.blockSize=512,Qi.outSize=160,Qi.hmacStrength=192,Qi.padLength=64,Qi.prototype._update=function(r,t){for(var e=this.h[0],i=this.h[1],s=this.h[2],a=this.h[3],u=this.h[4],l=e,m=i,f=s,w=a,E=u,x=0;x<80;x++){var I=Yd(Ic(Qd(e,Jd(x,i,s,a),r[WA[x]+t],VA(x)),QA[x]),u);e=u,u=a,a=Ic(s,10),s=i,i=I,I=Yd(Ic(Qd(l,Jd(79-x,m,f,w),r[YA[x]+t],GA(x)),JA[x]),E),l=E,E=w,w=Ic(f,10),f=m,m=I}I=Ho(this.h[1],s,w),this.h[1]=Ho(this.h[2],a,E),this.h[2]=Ho(this.h[3],u,l),this.h[3]=Ho(this.h[4],e,m),this.h[4]=Ho(this.h[0],i,f),this.h[0]=I},Qi.prototype._digest=function(r){return r==="hex"?Is.toHex32(this.h,"little"):Is.split32(this.h,"little")};function Jd(r,t,e,i){return r<=15?t^e^i:r<=31?t&e|~t&i:r<=47?(t|~e)^i:r<=63?t&i|e&~i:t^(e|~i)}function VA(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function GA(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var WA=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],YA=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],QA=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],JA=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],XA=ve,ZA=da;function ao(r,t,e){if(!(this instanceof ao))return new ao(r,t,e);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(XA.toArray(t,e))}var t8=ao;ao.prototype._init=function(r){r.length>this.blockSize&&(r=new this.Hash().update(r).digest()),ZA(r.length<=this.blockSize);for(var t=r.length;t<this.blockSize;t++)r.push(0);for(t=0;t<r.length;t++)r[t]^=54;for(this.inner=new this.Hash().update(r),t=0;t<r.length;t++)r[t]^=106;this.outer=new this.Hash().update(r)},ao.prototype.update=function(r,t){return this.inner.update(r,t),this},ao.prototype.digest=function(r){return this.outer.update(this.inner.digest()),this.outer.digest(r)},function(r){var t=r;t.utils=ve,t.common=vo,t.sha=to,t.ripemd=xg,t.hmac=t8,t.sha1=t.sha.sha1,t.sha256=t.sha.sha256,t.sha224=t.sha.sha224,t.sha384=t.sha.sha384,t.sha512=t.sha.sha512,t.ripemd160=t.ripemd.ripemd160}(Yi);function wo(r,t,e){return e={path:t,exports:{},require:function(i,s){return e8(i,s??e.path)}},r(e,e.exports),e.exports}function e8(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Kl=Cg;function Cg(r,t){if(!r)throw new Error(t||"Assertion failed")}Cg.equal=function(r,t,e){if(r!=t)throw new Error(e||"Assertion failed: "+r+" != "+t)};var Li=wo(function(r,t){var e=t;function i(u,l){if(Array.isArray(u))return u.slice();if(!u)return[];var m=[];if(typeof u!="string"){for(var f=0;f<u.length;f++)m[f]=u[f]|0;return m}if(l==="hex"){u=u.replace(/[^a-z0-9]+/ig,""),u.length%2!==0&&(u="0"+u);for(var f=0;f<u.length;f+=2)m.push(parseInt(u[f]+u[f+1],16))}else for(var f=0;f<u.length;f++){var w=u.charCodeAt(f),E=w>>8,x=w&255;E?m.push(E,x):m.push(x)}return m}e.toArray=i;function s(u){return u.length===1?"0"+u:u}e.zero2=s;function a(u){for(var l="",m=0;m<u.length;m++)l+=s(u[m].toString(16));return l}e.toHex=a,e.encode=function(u,l){return l==="hex"?a(u):u}}),ni=wo(function(r,t){var e=t;e.assert=Kl,e.toArray=Li.toArray,e.zero2=Li.zero2,e.toHex=Li.toHex,e.encode=Li.encode;function i(m,f,w){var E=new Array(Math.max(m.bitLength(),w)+1);E.fill(0);for(var x=1<<f+1,I=m.clone(),N=0;N<E.length;N++){var Y,G=I.andln(x-1);I.isOdd()?(G>(x>>1)-1?Y=(x>>1)-G:Y=G,I.isubn(Y)):Y=0,E[N]=Y,I.iushrn(1)}return E}e.getNAF=i;function s(m,f){var w=[[],[]];m=m.clone(),f=f.clone();for(var E=0,x=0,I;m.cmpn(-E)>0||f.cmpn(-x)>0;){var N=m.andln(3)+E&3,Y=f.andln(3)+x&3;N===3&&(N=-1),Y===3&&(Y=-1);var G;N&1?(I=m.andln(7)+E&7,(I===3||I===5)&&Y===2?G=-N:G=N):G=0,w[0].push(G);var tt;Y&1?(I=f.andln(7)+x&7,(I===3||I===5)&&N===2?tt=-Y:tt=Y):tt=0,w[1].push(tt),2*E===G+1&&(E=1-E),2*x===tt+1&&(x=1-x),m.iushrn(1),f.iushrn(1)}return w}e.getJSF=s;function a(m,f,w){var E="_"+f;m.prototype[f]=function(){return this[E]!==void 0?this[E]:this[E]=w.call(this)}}e.cachedProperty=a;function u(m){return typeof m=="string"?e.toArray(m,"hex"):m}e.parseBytes=u;function l(m){return new ne(m,"hex","le")}e.intFromLE=l}),Dc=ni.getNAF,r8=ni.getJSF,Yc=ni.assert;function Vn(r,t){this.type=r,this.p=new ne(t.p,16),this.red=t.prime?ne.red(t.prime):ne.mont(this.p),this.zero=new ne(0).toRed(this.red),this.one=new ne(1).toRed(this.red),this.two=new ne(2).toRed(this.red),this.n=t.n&&new ne(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.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 e=this.n&&this.p.div(this.n);!e||e.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Ms=Vn;Vn.prototype.point=function(){throw new Error("Not implemented")},Vn.prototype.validate=function(){throw new Error("Not implemented")},Vn.prototype._fixedNafMul=function(r,t){Yc(r.precomputed);var e=r._getDoubles(),i=Dc(t,1,this._bitLength),s=(1<<e.step+1)-(e.step%2===0?2:1);s/=3;var a=[],u,l;for(u=0;u<i.length;u+=e.step){l=0;for(var m=u+e.step-1;m>=u;m--)l=(l<<1)+i[m];a.push(l)}for(var f=this.jpoint(null,null,null),w=this.jpoint(null,null,null),E=s;E>0;E--){for(u=0;u<a.length;u++)l=a[u],l===E?w=w.mixedAdd(e.points[u]):l===-E&&(w=w.mixedAdd(e.points[u].neg()));f=f.add(w)}return f.toP()},Vn.prototype._wnafMul=function(r,t){var e=4,i=r._getNAFPoints(e);e=i.wnd;for(var s=i.points,a=Dc(t,e,this._bitLength),u=this.jpoint(null,null,null),l=a.length-1;l>=0;l--){for(var m=0;l>=0&&a[l]===0;l--)m++;if(l>=0&&m++,u=u.dblp(m),l<0)break;var f=a[l];Yc(f!==0),r.type==="affine"?f>0?u=u.mixedAdd(s[f-1>>1]):u=u.mixedAdd(s[-f-1>>1].neg()):f>0?u=u.add(s[f-1>>1]):u=u.add(s[-f-1>>1].neg())}return r.type==="affine"?u.toP():u},Vn.prototype._wnafMulAdd=function(r,t,e,i,s){var a=this._wnafT1,u=this._wnafT2,l=this._wnafT3,m=0,f,w,E;for(f=0;f<i;f++){E=t[f];var x=E._getNAFPoints(r);a[f]=x.wnd,u[f]=x.points}for(f=i-1;f>=1;f-=2){var I=f-1,N=f;if(a[I]!==1||a[N]!==1){l[I]=Dc(e[I],a[I],this._bitLength),l[N]=Dc(e[N],a[N],this._bitLength),m=Math.max(l[I].length,m),m=Math.max(l[N].length,m);continue}var Y=[t[I],null,null,t[N]];t[I].y.cmp(t[N].y)===0?(Y[1]=t[I].add(t[N]),Y[2]=t[I].toJ().mixedAdd(t[N].neg())):t[I].y.cmp(t[N].y.redNeg())===0?(Y[1]=t[I].toJ().mixedAdd(t[N]),Y[2]=t[I].add(t[N].neg())):(Y[1]=t[I].toJ().mixedAdd(t[N]),Y[2]=t[I].toJ().mixedAdd(t[N].neg()));var G=[-3,-1,-5,-7,0,7,5,1,3],tt=r8(e[I],e[N]);for(m=Math.max(tt[0].length,m),l[I]=new Array(m),l[N]=new Array(m),w=0;w<m;w++){var K=tt[0][w]|0,V=tt[1][w]|0;l[I][w]=G[(K+1)*3+(V+1)],l[N][w]=0,u[I]=Y}}var B=this.jpoint(null,null,null),z=this._wnafT4;for(f=m;f>=0;f--){for(var $=0;f>=0;){var v=!0;for(w=0;w<i;w++)z[w]=l[w][f]|0,z[w]!==0&&(v=!1);if(!v)break;$++,f--}if(f>=0&&$++,B=B.dblp($),f<0)break;for(w=0;w<i;w++){var T=z[w];T!==0&&(T>0?E=u[w][T-1>>1]:T<0&&(E=u[w][-T-1>>1].neg()),E.type==="affine"?B=B.mixedAdd(E):B=B.add(E))}}for(f=0;f<i;f++)u[f]=null;return s?B:B.toP()};function bi(r,t){this.curve=r,this.type=t,this.precomputed=null}Vn.BasePoint=bi,bi.prototype.eq=function(){throw new Error("Not implemented")},bi.prototype.validate=function(){return this.curve.validate(this)},Vn.prototype.decodePoint=function(r,t){r=ni.toArray(r,t);var e=this.p.byteLength();if((r[0]===4||r[0]===6||r[0]===7)&&r.length-1===2*e){r[0]===6?Yc(r[r.length-1]%2===0):r[0]===7&&Yc(r[r.length-1]%2===1);var i=this.point(r.slice(1,1+e),r.slice(1+e,1+2*e));return i}else if((r[0]===2||r[0]===3)&&r.length-1===e)return this.pointFromX(r.slice(1,1+e),r[0]===3);throw new Error("Unknown point format")},bi.prototype.encodeCompressed=function(r){return this.encode(r,!0)},bi.prototype._encode=function(r){var t=this.curve.p.byteLength(),e=this.getX().toArray("be",t);return r?[this.getY().isEven()?2:3].concat(e):[4].concat(e,this.getY().toArray("be",t))},bi.prototype.encode=function(r,t){return ni.encode(this._encode(t),r)},bi.prototype.precompute=function(r){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,r),t.beta=this._getBeta(),this.precomputed=t,this},bi.prototype._hasDoubles=function(r){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((r.bitLength()+1)/t.step):!1},bi.prototype._getDoubles=function(r,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var e=[this],i=this,s=0;s<t;s+=r){for(var a=0;a<r;a++)i=i.dbl();e.push(i)}return{step:r,points:e}},bi.prototype._getNAFPoints=function(r){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],e=(1<<r)-1,i=e===1?null:this.dbl(),s=1;s<e;s++)t[s]=t[s-1].add(i);return{wnd:r,points:t}},bi.prototype._getBeta=function(){return null},bi.prototype.dblp=function(r){for(var t=this,e=0;e<r;e++)t=t.dbl();return t};var Vl=wo(function(r){typeof Object.create=="function"?r.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(t,e){if(e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}}}),i8=ni.assert;function Ii(r){Ms.call(this,"short",r),this.a=new ne(r.a,16).toRed(this.red),this.b=new ne(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Vl(Ii,Ms);var n8=Ii;Ii.prototype._getEndomorphism=function(r){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,e;if(r.beta)t=new ne(r.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=i[0].cmp(i[1])<0?i[0]:i[1],t=t.toRed(this.red)}if(r.lambda)e=new ne(r.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?e=s[0]:(e=s[1],i8(this.g.mul(e).x.cmp(this.g.x.redMul(t))===0))}var a;return r.basis?a=r.basis.map(function(u){return{a:new ne(u.a,16),b:new ne(u.b,16)}}):a=this._getEndoBasis(e),{beta:t,lambda:e,basis:a}}},Ii.prototype._getEndoRoots=function(r){var t=r===this.p?this.red:ne.mont(r),e=new ne(2).toRed(t).redInvm(),i=e.redNeg(),s=new ne(3).toRed(t).redNeg().redSqrt().redMul(e),a=i.redAdd(s).fromRed(),u=i.redSub(s).fromRed();return[a,u]},Ii.prototype._getEndoBasis=function(r){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),e=r,i=this.n.clone(),s=new ne(1),a=new ne(0),u=new ne(0),l=new ne(1),m,f,w,E,x,I,N,Y=0,G,tt;e.cmpn(0)!==0;){var K=i.div(e);G=i.sub(K.mul(e)),tt=u.sub(K.mul(s));var V=l.sub(K.mul(a));if(!w&&G.cmp(t)<0)m=N.neg(),f=s,w=G.neg(),E=tt;else if(w&&++Y===2)break;N=G,i=e,e=G,u=s,s=tt,l=a,a=V}x=G.neg(),I=tt;var B=w.sqr().add(E.sqr()),z=x.sqr().add(I.sqr());return z.cmp(B)>=0&&(x=m,I=f),w.negative&&(w=w.neg(),E=E.neg()),x.negative&&(x=x.neg(),I=I.neg()),[{a:w,b:E},{a:x,b:I}]},Ii.prototype._endoSplit=function(r){var t=this.endo.basis,e=t[0],i=t[1],s=i.b.mul(r).divRound(this.n),a=e.b.neg().mul(r).divRound(this.n),u=s.mul(e.a),l=a.mul(i.a),m=s.mul(e.b),f=a.mul(i.b),w=r.sub(u).sub(l),E=m.add(f).neg();return{k1:w,k2:E}},Ii.prototype.pointFromX=function(r,t){r=new ne(r,16),r.red||(r=r.toRed(this.red));var e=r.redSqr().redMul(r).redIAdd(r.redMul(this.a)).redIAdd(this.b),i=e.redSqrt();if(i.redSqr().redSub(e).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(r,i)},Ii.prototype.validate=function(r){if(r.inf)return!0;var t=r.x,e=r.y,i=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return e.redSqr().redISub(s).cmpn(0)===0},Ii.prototype._endoWnafMulAdd=function(r,t,e){for(var i=this._endoWnafT1,s=this._endoWnafT2,a=0;a<r.length;a++){var u=this._endoSplit(t[a]),l=r[a],m=l._getBeta();u.k1.negative&&(u.k1.ineg(),l=l.neg(!0)),u.k2.negative&&(u.k2.ineg(),m=m.neg(!0)),i[a*2]=l,i[a*2+1]=m,s[a*2]=u.k1,s[a*2+1]=u.k2}for(var f=this._wnafMulAdd(1,i,s,a*2,e),w=0;w<a*2;w++)i[w]=null,s[w]=null;return f};function hr(r,t,e,i){Ms.BasePoint.call(this,r,"affine"),t===null&&e===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new ne(t,16),this.y=new ne(e,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}Vl(hr,Ms.BasePoint),Ii.prototype.point=function(r,t,e){return new hr(this,r,t,e)},Ii.prototype.pointFromJSON=function(r,t){return hr.fromJSON(this,r,t)},hr.prototype._getBeta=function(){if(this.curve.endo){var r=this.precomputed;if(r&&r.beta)return r.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(r){var e=this.curve,i=function(s){return e.point(s.x.redMul(e.endo.beta),s.y)};r.beta=t,t.precomputed={beta:null,naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t}},hr.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},hr.fromJSON=function(r,t,e){typeof t=="string"&&(t=JSON.parse(t));var i=r.point(t[0],t[1],e);if(!t[2])return i;function s(u){return r.point(u[0],u[1],e)}var a=t[2];return i.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[i].concat(a.doubles.points.map(s))},naf:a.naf&&{wnd:a.naf.wnd,points:[i].concat(a.naf.points.map(s))}},i},hr.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},hr.prototype.isInfinity=function(){return this.inf},hr.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 t=this.y.redSub(r.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(r.x).redInvm()));var e=t.redSqr().redISub(this.x).redISub(r.x),i=t.redMul(this.x.redSub(e)).redISub(this.y);return this.curve.point(e,i)},hr.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 t=this.curve.a,e=this.x.redSqr(),i=r.redInvm(),s=e.redAdd(e).redIAdd(e).redIAdd(t).redMul(i),a=s.redSqr().redISub(this.x.redAdd(this.x)),u=s.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,u)},hr.prototype.getX=function(){return this.x.fromRed()},hr.prototype.getY=function(){return this.y.fromRed()},hr.prototype.mul=function(r){return r=new ne(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)},hr.prototype.mulAdd=function(r,t,e){var i=[this,t],s=[r,e];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)},hr.prototype.jmulAdd=function(r,t,e){var i=[this,t],s=[r,e];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)},hr.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)},hr.prototype.neg=function(r){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(r&&this.precomputed){var e=this.precomputed,i=function(s){return s.neg()};t.precomputed={naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(i)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(i)}}}return t},hr.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 dr(r,t,e,i){Ms.BasePoint.call(this,r,"jacobian"),t===null&&e===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new ne(0)):(this.x=new ne(t,16),this.y=new ne(e,16),this.z=new ne(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}Vl(dr,Ms.BasePoint),Ii.prototype.jpoint=function(r,t,e){return new dr(this,r,t,e)},dr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var r=this.z.redInvm(),t=r.redSqr(),e=this.x.redMul(t),i=this.y.redMul(t).redMul(r);return this.curve.point(e,i)},dr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},dr.prototype.add=function(r){if(this.isInfinity())return r;if(r.isInfinity())return this;var t=r.z.redSqr(),e=this.z.redSqr(),i=this.x.redMul(t),s=r.x.redMul(e),a=this.y.redMul(t.redMul(r.z)),u=r.y.redMul(e.redMul(this.z)),l=i.redSub(s),m=a.redSub(u);if(l.cmpn(0)===0)return m.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var f=l.redSqr(),w=f.redMul(l),E=i.redMul(f),x=m.redSqr().redIAdd(w).redISub(E).redISub(E),I=m.redMul(E.redISub(x)).redISub(a.redMul(w)),N=this.z.redMul(r.z).redMul(l);return this.curve.jpoint(x,I,N)},dr.prototype.mixedAdd=function(r){if(this.isInfinity())return r.toJ();if(r.isInfinity())return this;var t=this.z.redSqr(),e=this.x,i=r.x.redMul(t),s=this.y,a=r.y.redMul(t).redMul(this.z),u=e.redSub(i),l=s.redSub(a);if(u.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var m=u.redSqr(),f=m.redMul(u),w=e.redMul(m),E=l.redSqr().redIAdd(f).redISub(w).redISub(w),x=l.redMul(w.redISub(E)).redISub(s.redMul(f)),I=this.z.redMul(u);return this.curve.jpoint(E,x,I)},dr.prototype.dblp=function(r){if(r===0)return this;if(this.isInfinity())return this;if(!r)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var e=this;for(t=0;t<r;t++)e=e.dbl();return e}var i=this.curve.a,s=this.curve.tinv,a=this.x,u=this.y,l=this.z,m=l.redSqr().redSqr(),f=u.redAdd(u);for(t=0;t<r;t++){var w=a.redSqr(),E=f.redSqr(),x=E.redSqr(),I=w.redAdd(w).redIAdd(w).redIAdd(i.redMul(m)),N=a.redMul(E),Y=I.redSqr().redISub(N.redAdd(N)),G=N.redISub(Y),tt=I.redMul(G);tt=tt.redIAdd(tt).redISub(x);var K=f.redMul(l);t+1<r&&(m=m.redMul(x)),a=Y,l=K,f=tt}return this.curve.jpoint(a,f.redMul(s),l)},dr.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},dr.prototype._zeroDbl=function(){var r,t,e;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),u=this.x.redAdd(s).redSqr().redISub(i).redISub(a);u=u.redIAdd(u);var l=i.redAdd(i).redIAdd(i),m=l.redSqr().redISub(u).redISub(u),f=a.redIAdd(a);f=f.redIAdd(f),f=f.redIAdd(f),r=m,t=l.redMul(u.redISub(m)).redISub(f),e=this.y.redAdd(this.y)}else{var w=this.x.redSqr(),E=this.y.redSqr(),x=E.redSqr(),I=this.x.redAdd(E).redSqr().redISub(w).redISub(x);I=I.redIAdd(I);var N=w.redAdd(w).redIAdd(w),Y=N.redSqr(),G=x.redIAdd(x);G=G.redIAdd(G),G=G.redIAdd(G),r=Y.redISub(I).redISub(I),t=N.redMul(I.redISub(r)).redISub(G),e=this.y.redMul(this.z),e=e.redIAdd(e)}return this.curve.jpoint(r,t,e)},dr.prototype._threeDbl=function(){var r,t,e;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),u=this.x.redAdd(s).redSqr().redISub(i).redISub(a);u=u.redIAdd(u);var l=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),m=l.redSqr().redISub(u).redISub(u);r=m;var f=a.redIAdd(a);f=f.redIAdd(f),f=f.redIAdd(f),t=l.redMul(u.redISub(m)).redISub(f),e=this.y.redAdd(this.y)}else{var w=this.z.redSqr(),E=this.y.redSqr(),x=this.x.redMul(E),I=this.x.redSub(w).redMul(this.x.redAdd(w));I=I.redAdd(I).redIAdd(I);var N=x.redIAdd(x);N=N.redIAdd(N);var Y=N.redAdd(N);r=I.redSqr().redISub(Y),e=this.y.redAdd(this.z).redSqr().redISub(E).redISub(w);var G=E.redSqr();G=G.redIAdd(G),G=G.redIAdd(G),G=G.redIAdd(G),t=I.redMul(N.redISub(r)).redISub(G)}return this.curve.jpoint(r,t,e)},dr.prototype._dbl=function(){var r=this.curve.a,t=this.x,e=this.y,i=this.z,s=i.redSqr().redSqr(),a=t.redSqr(),u=e.redSqr(),l=a.redAdd(a).redIAdd(a).redIAdd(r.redMul(s)),m=t.redAdd(t);m=m.redIAdd(m);var f=m.redMul(u),w=l.redSqr().redISub(f.redAdd(f)),E=f.redISub(w),x=u.redSqr();x=x.redIAdd(x),x=x.redIAdd(x),x=x.redIAdd(x);var I=l.redMul(E).redISub(x),N=e.redAdd(e).redMul(i);return this.curve.jpoint(w,I,N)},dr.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var r=this.x.redSqr(),t=this.y.redSqr(),e=this.z.redSqr(),i=t.redSqr(),s=r.redAdd(r).redIAdd(r),a=s.redSqr(),u=this.x.redAdd(t).redSqr().redISub(r).redISub(i);u=u.redIAdd(u),u=u.redAdd(u).redIAdd(u),u=u.redISub(a);var l=u.redSqr(),m=i.redIAdd(i);m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m);var f=s.redIAdd(u).redSqr().redISub(a).redISub(l).redISub(m),w=t.redMul(f);w=w.redIAdd(w),w=w.redIAdd(w);var E=this.x.redMul(l).redISub(w);E=E.redIAdd(E),E=E.redIAdd(E);var x=this.y.redMul(f.redMul(m.redISub(f)).redISub(u.redMul(l)));x=x.redIAdd(x),x=x.redIAdd(x),x=x.redIAdd(x);var I=this.z.redAdd(u).redSqr().redISub(e).redISub(l);return this.curve.jpoint(E,x,I)},dr.prototype.mul=function(r,t){return r=new ne(r,t),this.curve._wnafMul(this,r)},dr.prototype.eq=function(r){if(r.type==="affine")return this.eq(r.toJ());if(this===r)return!0;var t=this.z.redSqr(),e=r.z.redSqr();if(this.x.redMul(e).redISub(r.x.redMul(t)).cmpn(0)!==0)return!1;var i=t.redMul(this.z),s=e.redMul(r.z);return this.y.redMul(s).redISub(r.y.redMul(i)).cmpn(0)===0},dr.prototype.eqXToP=function(r){var t=this.z.redSqr(),e=r.toRed(this.curve.red).redMul(t);if(this.x.cmp(e)===0)return!0;for(var i=r.clone(),s=this.curve.redN.redMul(t);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(s),this.x.cmp(e)===0)return!0}},dr.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},dr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Bc=wo(function(r,t){var e=t;e.base=Ms,e.short=n8,e.mont=null,e.edwards=null}),Lc=wo(function(r,t){var e=t,i=ni.assert;function s(l){l.type==="short"?this.curve=new Bc.short(l):l.type==="edwards"?this.curve=new Bc.edwards(l):this.curve=new Bc.mont(l),this.g=this.curve.g,this.n=this.curve.n,this.hash=l.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=s;function a(l,m){Object.defineProperty(e,l,{configurable:!0,enumerable:!0,get:function(){var f=new s(m);return Object.defineProperty(e,l,{configurable:!0,enumerable:!0,value:f}),f}})}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:Yi.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:Yi.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:Yi.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:Yi.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:Yi.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:Yi.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:Yi.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var u;try{u=null.crash()}catch{u=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:Yi.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",u]})});function Gn(r){if(!(this instanceof Gn))return new Gn(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 t=Li.toArray(r.entropy,r.entropyEnc||"hex"),e=Li.toArray(r.nonce,r.nonceEnc||"hex"),i=Li.toArray(r.pers,r.persEnc||"hex");Kl(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,e,i)}var Xd=Gn;Gn.prototype._init=function(r,t,e){var i=r.concat(t).concat(e);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},Gn.prototype._hmac=function(){return new Yi.hmac(this.hash,this.K)},Gn.prototype._update=function(r){var t=this._hmac().update(this.V).update([0]);r&&(t=t.update(r)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),r&&(this.K=this._hmac().update(this.V).update([1]).update(r).digest(),this.V=this._hmac().update(this.V).digest())},Gn.prototype.reseed=function(r,t,e,i){typeof t!="string"&&(i=e,e=t,t=null),r=Li.toArray(r,t),e=Li.toArray(e,i),Kl(r.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(r.concat(e||[])),this._reseed=1},Gn.prototype.generate=function(r,t,e,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(i=e,e=t,t=null),e&&(e=Li.toArray(e,i||"hex"),this._update(e));for(var s=[];s.length<r;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var a=s.slice(0,r);return this._update(e),this._reseed++,Li.encode(a,t)};var zh=ni.assert;function Er(r,t){this.ec=r,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var kh=Er;Er.fromPublic=function(r,t,e){return t instanceof Er?t:new Er(r,{pub:t,pubEnc:e})},Er.fromPrivate=function(r,t,e){return t instanceof Er?t:new Er(r,{priv:t,privEnc:e})},Er.prototype.validate=function(){var r=this.getPublic();return r.isInfinity()?{result:!1,reason:"Invalid public key"}:r.validate()?r.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Er.prototype.getPublic=function(r,t){return typeof r=="string"&&(t=r,r=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,r):this.pub},Er.prototype.getPrivate=function(r){return r==="hex"?this.priv.toString(16,2):this.priv},Er.prototype._importPrivate=function(r,t){this.priv=new ne(r,t||16),this.priv=this.priv.umod(this.ec.curve.n)},Er.prototype._importPublic=function(r,t){if(r.x||r.y){this.ec.curve.type==="mont"?zh(r.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&zh(r.x&&r.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(r.x,r.y);return}this.pub=this.ec.curve.decodePoint(r,t)},Er.prototype.derive=function(r){return r.validate()||zh(r.validate(),"public point not validated"),r.mul(this.priv).getX()},Er.prototype.sign=function(r,t,e){return this.ec.sign(r,this,t,e)},Er.prototype.verify=function(r,t){return this.ec.verify(r,t,this)},Er.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var s8=ni.assert;function hu(r,t){if(r instanceof hu)return r;this._importDER(r,t)||(s8(r.r&&r.s,"Signature without r or s"),this.r=new ne(r.r,16),this.s=new ne(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var xc=hu;function o8(){this.place=0}function Hh(r,t){var e=r[t.place++];if(!(e&128))return e;var i=e&15;if(i===0||i>4)return!1;for(var s=0,a=0,u=t.place;a<i;a++,u++)s<<=8,s|=r[u],s>>>=0;return s<=127?!1:(t.place=u,s)}function Zd(r){for(var t=0,e=r.length-1;!r[t]&&!(r[t+1]&128)&&t<e;)t++;return t===0?r:r.slice(t)}hu.prototype._importDER=function(r,t){r=ni.toArray(r,t);var e=new o8;if(r[e.place++]!==48)return!1;var i=Hh(r,e);if(i===!1||i+e.place!==r.length||r[e.place++]!==2)return!1;var s=Hh(r,e);if(s===!1)return!1;var a=r.slice(e.place,s+e.place);if(e.place+=s,r[e.place++]!==2)return!1;var u=Hh(r,e);if(u===!1||r.length!==u+e.place)return!1;var l=r.slice(e.place,u+e.place);if(a[0]===0)if(a[1]&128)a=a.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new ne(a),this.s=new ne(l),this.recoveryParam=null,!0};function Kh(r,t){if(t<128){r.push(t);return}var e=1+(Math.log(t)/Math.LN2>>>3);for(r.push(e|128);--e;)r.push(t>>>(e<<3)&255);r.push(t)}hu.prototype.toDER=function(r){var t=this.r.toArray(),e=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),e[0]&128&&(e=[0].concat(e)),t=Zd(t),e=Zd(e);!e[0]&&!(e[1]&128);)e=e.slice(1);var i=[2];Kh(i,t.length),i=i.concat(t),i.push(2),Kh(i,e.length);var s=i.concat(e),a=[48];return Kh(a,s.length),a=a.concat(s),ni.encode(a,r)};var a8=function(){throw new Error("unsupported")},Pg=ni.assert;function Ai(r){if(!(this instanceof Ai))return new Ai(r);typeof r=="string"&&(Pg(Object.prototype.hasOwnProperty.call(Lc,r),"Unknown curve "+r),r=Lc[r]),r instanceof Lc.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 c8=Ai;Ai.prototype.keyPair=function(r){return new kh(this,r)},Ai.prototype.keyFromPrivate=function(r,t){return kh.fromPrivate(this,r,t)},Ai.prototype.keyFromPublic=function(r,t){return kh.fromPublic(this,r,t)},Ai.prototype.genKeyPair=function(r){r||(r={});for(var t=new Xd({hash:this.hash,pers:r.pers,persEnc:r.persEnc||"utf8",entropy:r.entropy||a8(this.hash.hmacStrength),entropyEnc:r.entropy&&r.entropyEnc||"utf8",nonce:this.n.toArray()}),e=this.n.byteLength(),i=this.n.sub(new ne(2));;){var s=new ne(t.generate(e));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Ai.prototype._truncateToN=function(r,t){var e=r.byteLength()*8-this.n.bitLength();return e>0&&(r=r.ushrn(e)),!t&&r.cmp(this.n)>=0?r.sub(this.n):r},Ai.prototype.sign=function(r,t,e,i){typeof e=="object"&&(i=e,e=null),i||(i={}),t=this.keyFromPrivate(t,e),r=this._truncateToN(new ne(r,16));for(var s=this.n.byteLength(),a=t.getPrivate().toArray("be",s),u=r.toArray("be",s),l=new Xd({hash:this.hash,entropy:a,nonce:u,pers:i.pers,persEnc:i.persEnc||"utf8"}),m=this.n.sub(new ne(1)),f=0;;f++){var w=i.k?i.k(f):new ne(l.generate(this.n.byteLength()));if(w=this._truncateToN(w,!0),!(w.cmpn(1)<=0||w.cmp(m)>=0)){var E=this.g.mul(w);if(!E.isInfinity()){var x=E.getX(),I=x.umod(this.n);if(I.cmpn(0)!==0){var N=w.invm(this.n).mul(I.mul(t.getPrivate()).iadd(r));if(N=N.umod(this.n),N.cmpn(0)!==0){var Y=(E.getY().isOdd()?1:0)|(x.cmp(I)!==0?2:0);return i.canonical&&N.cmp(this.nh)>0&&(N=this.n.sub(N),Y^=1),new xc({r:I,s:N,recoveryParam:Y})}}}}}},Ai.prototype.verify=function(r,t,e,i){r=this._truncateToN(new ne(r,16)),e=this.keyFromPublic(e,i),t=new xc(t,"hex");var s=t.r,a=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var u=a.invm(this.n),l=u.mul(r).umod(this.n),m=u.mul(s).umod(this.n),f;return this.curve._maxwellTrick?(f=this.g.jmulAdd(l,e.getPublic(),m),f.isInfinity()?!1:f.eqXToP(s)):(f=this.g.mulAdd(l,e.getPublic(),m),f.isInfinity()?!1:f.getX().umod(this.n).cmp(s)===0)},Ai.prototype.recoverPubKey=function(r,t,e,i){Pg((3&e)===e,"The recovery param is more than two bits"),t=new xc(t,i);var s=this.n,a=new ne(r),u=t.r,l=t.s,m=e&1,f=e>>1;if(u.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");f?u=this.curve.pointFromX(u.add(this.curve.n),m):u=this.curve.pointFromX(u,m);var w=t.r.invm(s),E=s.sub(a).mul(w).umod(s),x=l.mul(w).umod(s);return this.g.mulAdd(E,u,x)},Ai.prototype.getKeyRecoveryParam=function(r,t,e,i){if(t=new xc(t,i),t.recoveryParam!==null)return t.recoveryParam;for(var s=0;s<4;s++){var a;try{a=this.recoverPubKey(r,t,s)}catch{continue}if(a.eq(e))return s}throw new Error("Unable to find valid recovery factor")};var u8=wo(function(r,t){var e=t;e.version="6.5.4",e.utils=ni,e.rand=function(){throw new Error("unsupported")},e.curve=Bc,e.curves=Lc,e.ec=c8,e.eddsa=null}),h8=u8.ec;const l8="signing-key/5.7.0",_l=new mr(l8);let Vh=null;function rn(){return Vh||(Vh=new h8("secp256k1")),Vh}class f8{constructor(t){zo(this,"curve","secp256k1"),zo(this,"privateKey",Pr(t)),YE(this.privateKey)!==32&&_l.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const e=rn().keyFromPrivate(Ye(this.privateKey));zo(this,"publicKey","0x"+e.getPublic(!1,"hex")),zo(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),zo(this,"_isSigningKey",!0)}_addPoint(t){const e=rn().keyFromPublic(Ye(this.publicKey)),i=rn().keyFromPublic(Ye(t));return"0x"+e.pub.add(i.pub).encodeCompressed("hex")}signDigest(t){const e=rn().keyFromPrivate(Ye(this.privateKey)),i=Ye(t);i.length!==32&&_l.throwArgumentError("bad digest length","digest",t);const s=e.sign(i,{canonical:!0});return eg({recoveryParam:s.recoveryParam,r:nn("0x"+s.r.toString(16),32),s:nn("0x"+s.s.toString(16),32)})}computeSharedSecret(t){const e=rn().keyFromPrivate(Ye(this.privateKey)),i=rn().keyFromPublic(Ye(Og(t)));return nn("0x"+e.derive(i.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}}function d8(r,t){const e=eg(t),i={r:Ye(e.r),s:Ye(e.s)};return"0x"+rn().recoverPubKey(Ye(r),i,e.recoveryParam).encode("hex",!1)}function Og(r,t){const e=Ye(r);if(e.length===32){const i=new f8(e);return t?"0x"+rn().keyFromPrivate(e).getPublic(!0,"hex"):i.publicKey}else{if(e.length===33)return t?Pr(e):"0x"+rn().keyFromPublic(e).getPublic(!1,"hex");if(e.length===65)return t?"0x"+rn().keyFromPublic(e).getPublic(!0,"hex"):Pr(e)}return _l.throwArgumentError("invalid public or private key","key","[REDACTED]")}var tp;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(tp||(tp={}));function p8(r){const t=Og(r);return I5(qd(zl(qd(t,1)),12))}function g8(r,t){return p8(d8(Ye(r),t))}const m8="https://rpc.walletconnect.com/v1";async function v8(r,t,e,i,s,a){switch(e.t){case"eip191":return y8(r,t,e.s);case"eip1271":return await w8(r,t,e.s,i,s,a);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${e.t}`)}}function y8(r,t,e){return g8(hg(t),e).toLowerCase()===r.toLowerCase()}async function w8(r,t,e,i,s,a){try{const u="0x1626ba7e",l="0000000000000000000000000000000000000000000000000000000000000040",m="0000000000000000000000000000000000000000000000000000000000000041",f=e.substring(2),w=hg(t).substring(2),E=u+w+l+m+f,x=await fetch(`${a||m8}/?chainId=${i}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:b8(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:E},"latest"]})}),{result:I}=await x.json();return I?I.slice(0,u.length).toLowerCase()===u.toLowerCase():!1}catch(u){return console.error("isValidEip1271Signature: ",u),!1}}function b8(){return Date.now()+Math.floor(Math.random()*1e3)}var _8=Object.defineProperty,E8=Object.defineProperties,A8=Object.getOwnPropertyDescriptors,ep=Object.getOwnPropertySymbols,S8=Object.prototype.hasOwnProperty,I8=Object.prototype.propertyIsEnumerable,rp=(r,t,e)=>t in r?_8(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,D8=(r,t)=>{for(var e in t||(t={}))S8.call(t,e)&&rp(r,e,t[e]);if(ep)for(var e of ep(t))I8.call(t,e)&&rp(r,e,t[e]);return r},x8=(r,t)=>E8(r,A8(t));const M8="did:pkh:",Gl=r=>r==null?void 0:r.split(":"),Ng=r=>{const t=r&&Gl(r);if(t)return r.includes(M8)?t[3]:t[1]},ip=r=>{const t=r&&Gl(r);if(t)return t[2]+":"+t[3]},Qc=r=>{const t=r&&Gl(r);if(t)return t.pop()};async function np(r){const{cacao:t,projectId:e}=r,{s:i,p:s}=t,a=Rg(s,s.iss),u=Qc(s.iss);return await v8(u,a,i,Ng(s.iss),e)}const Rg=(r,t)=>{const e=`${r.domain} wants you to sign in with your Ethereum account:`,i=Qc(t);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=r.statement||void 0;const a=`URI: ${r.aud||r.uri}`,u=`Version: ${r.version}`,l=`Chain ID: ${Ng(t)}`,m=`Nonce: ${r.nonce}`,f=`Issued At: ${r.iat}`,w=r.resources?`Resources:${r.resources.map(x=>`
10
+ - ${x}`).join("")}`:void 0,E=qc(r.resources);if(E){const x=na(E);s=B8(s,x)}return[e,i,"",s,"",a,u,l,m,f,w].filter(x=>x!=null).join(`
11
+ `)};function C8(r){return ca.from(JSON.stringify(r)).toString("base64")}function P8(r){return JSON.parse(ca.from(r,"base64").toString("utf-8"))}function Ds(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const t=Object.keys(r.att);if(!(t!=null&&t.length))throw new Error("No resources found in `att` property");t.forEach(e=>{const i=r.att[e];if(Array.isArray(i))throw new Error(`Resource must be an object: ${e}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${e}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${e}`);Object.keys(i).forEach(s=>{const a=i[s];if(!Array.isArray(a))throw new Error(`Ability limits ${s} must be an array of objects, found: ${a}`);if(!a.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);a.forEach(u=>{if(typeof u!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${u}`)})})})}function O8(r,t,e,i={}){return e==null||e.sort((s,a)=>s.localeCompare(a)),{att:{[r]:N8(t,e,i)}}}function N8(r,t,e={}){t=t==null?void 0:t.sort((s,a)=>s.localeCompare(a));const i=t.map(s=>({[`${r}/${s}`]:[e]}));return Object.assign({},...i)}function Tg(r){return Ds(r),`urn:recap:${C8(r).replace(/=/g,"")}`}function na(r){const t=P8(r.replace("urn:recap:",""));return Ds(t),t}function R8(r,t,e){const i=O8(r,t,e);return Tg(i)}function T8(r){return r&&r.includes("urn:recap:")}function F8(r,t){const e=na(r),i=na(t),s=U8(e,i);return Tg(s)}function U8(r,t){Ds(r),Ds(t);const e=Object.keys(r.att).concat(Object.keys(t.att)).sort((s,a)=>s.localeCompare(a)),i={att:{}};return e.forEach(s=>{var a,u;Object.keys(((a=r.att)==null?void 0:a[s])||{}).concat(Object.keys(((u=t.att)==null?void 0:u[s])||{})).sort((l,m)=>l.localeCompare(m)).forEach(l=>{var m,f;i.att[s]=x8(D8({},i.att[s]),{[l]:((m=r.att[s])==null?void 0:m[l])||((f=t.att[s])==null?void 0:f[l])})})}),i}function B8(r="",t){Ds(t);const e="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(e))return r;const i=[];let s=0;Object.keys(t.att).forEach(l=>{const m=Object.keys(t.att[l]).map(E=>({ability:E.split("/")[0],action:E.split("/")[1]}));m.sort((E,x)=>E.action.localeCompare(x.action));const f={};m.forEach(E=>{f[E.ability]||(f[E.ability]=[]),f[E.ability].push(E.action)});const w=Object.keys(f).map(E=>(s++,`(${s}) '${E}': '${f[E].join("', '")}' for '${l}'.`));i.push(w.join(", ").replace(".,","."))});const a=i.join(" "),u=`${e}${a}`;return`${r?r+" ":""}${u}`}function sp(r){var t;const e=na(r);Ds(e);const i=(t=e.att)==null?void 0:t.eip155;return i?Object.keys(i).map(s=>s.split("/")[1]):[]}function op(r){const t=na(r);Ds(t);const e=[];return Object.values(t.att).forEach(i=>{Object.values(i).forEach(s=>{var a;(a=s==null?void 0:s[0])!=null&&a.chains&&e.push(s[0].chains)})}),[...new Set(e.flat())]}function qc(r){if(!r)return;const t=r==null?void 0:r[r.length-1];return T8(t)?t:void 0}const Fg="base10",Rr="base16",El="base64pad",Wl="utf8",Ug=0,xn=1,L8=0,ap=1,Al=12,Yl=32;function q8(){const r=$l.generateKeyPair();return{privateKey:Tr(r.secretKey,Rr),publicKey:Tr(r.publicKey,Rr)}}function Sl(){const r=fo.randomBytes(Yl);return Tr(r,Rr)}function j8(r,t){const e=$l.sharedKey(Kr(r,Rr),Kr(t,Rr),!0),i=new b_(cu.SHA256,e).expand(Yl);return Tr(i,Rr)}function jc(r){const t=cu.hash(Kr(r,Rr));return Tr(t,Rr)}function As(r){const t=cu.hash(Kr(r,Wl));return Tr(t,Rr)}function $8(r){return Kr(`${r}`,Fg)}function pa(r){return Number(Tr(r,Fg))}function z8(r){const t=$8(typeof r.type<"u"?r.type:Ug);if(pa(t)===xn&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const e=typeof r.senderPublicKey<"u"?Kr(r.senderPublicKey,Rr):void 0,i=typeof r.iv<"u"?Kr(r.iv,Rr):fo.randomBytes(Al),s=new ql.ChaCha20Poly1305(Kr(r.symKey,Rr)).seal(i,Kr(r.message,Wl));return H8({type:t,sealed:s,iv:i,senderPublicKey:e})}function k8(r){const t=new ql.ChaCha20Poly1305(Kr(r.symKey,Rr)),{sealed:e,iv:i}=Jc(r.encoded),s=t.open(i,e);if(s===null)throw new Error("Failed to decrypt");return Tr(s,Wl)}function H8(r){if(pa(r.type)===xn){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Tr(gl([r.type,r.senderPublicKey,r.iv,r.sealed]),El)}return Tr(gl([r.type,r.iv,r.sealed]),El)}function Jc(r){const t=Kr(r,El),e=t.slice(L8,ap),i=ap;if(pa(e)===xn){const l=i+Yl,m=l+Al,f=t.slice(i,l),w=t.slice(l,m),E=t.slice(m);return{type:e,sealed:E,iv:w,senderPublicKey:f}}const s=i+Al,a=t.slice(i,s),u=t.slice(s);return{type:e,sealed:u,iv:a}}function K8(r,t){const e=Jc(r);return Bg({type:pa(e.type),senderPublicKey:typeof e.senderPublicKey<"u"?Tr(e.senderPublicKey,Rr):void 0,receiverPublicKey:t==null?void 0:t.receiverPublicKey})}function Bg(r){const t=(r==null?void 0:r.type)||Ug;if(t===xn){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:t,senderPublicKey:r==null?void 0:r.senderPublicKey,receiverPublicKey:r==null?void 0:r.receiverPublicKey}}function cp(r){return r.type===xn&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}const V8="irn";function Il(r){return(r==null?void 0:r.relay)||{protocol:V8}}function Qo(r){const t=AE[r];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${r}`);return t}var G8=Object.defineProperty,W8=Object.defineProperties,Y8=Object.getOwnPropertyDescriptors,up=Object.getOwnPropertySymbols,Q8=Object.prototype.hasOwnProperty,J8=Object.prototype.propertyIsEnumerable,hp=(r,t,e)=>t in r?G8(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lp=(r,t)=>{for(var e in t||(t={}))Q8.call(t,e)&&hp(r,e,t[e]);if(up)for(var e of up(t))J8.call(t,e)&&hp(r,e,t[e]);return r},X8=(r,t)=>W8(r,Y8(t));function Z8(r,t="-"){const e={},i="relay"+t;return Object.keys(r).forEach(s=>{if(s.startsWith(i)){const a=s.replace(i,""),u=r[s];e[a]=u}}),e}function fp(r){r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const t=r.indexOf(":"),e=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,t),s=r.substring(t+1,e).split("@"),a=typeof e<"u"?r.substring(e):"",u=ea.parse(a),l=typeof u.methods=="string"?u.methods.split(","):void 0;return{protocol:i,topic:t4(s[0]),version:parseInt(s[1],10),symKey:u.symKey,relay:Z8(u),methods:l,expiryTimestamp:u.expiryTimestamp?parseInt(u.expiryTimestamp,10):void 0}}function t4(r){return r.startsWith("//")?r.substring(2):r}function e4(r,t="-"){const e="relay",i={};return Object.keys(r).forEach(s=>{const a=e+t+s;r[s]&&(i[a]=r[s])}),i}function r4(r){return`${r.protocol}:${r.topic}@${r.version}?`+ea.stringify(lp(X8(lp({symKey:r.symKey},e4(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function bo(r){const t=[];return r.forEach(e=>{const[i,s]=e.split(":");t.push(`${i}:${s}`)}),t}function i4(r){const t=[];return Object.values(r).forEach(e=>{t.push(...bo(e.accounts))}),t}function n4(r,t){const e=[];return Object.values(r).forEach(i=>{bo(i.accounts).includes(t)&&e.push(...i.methods)}),e}function s4(r,t){const e=[];return Object.values(r).forEach(i=>{bo(i.accounts).includes(t)&&e.push(...i.events)}),e}function Ql(r){return r.includes(":")}function Jo(r){return Ql(r)?r.split(":")[0]:r}function o4(r){const t={};return r==null||r.forEach(e=>{const[i,s]=e.split(":");t[i]||(t[i]={accounts:[],chains:[],events:[]}),t[i].accounts.push(e),t[i].chains.push(`${i}:${s}`)}),t}function dp(r,t){t=t.map(i=>i.replace("did:pkh:",""));const e=o4(t);for(const[i,s]of Object.entries(e))s.methods?s.methods=Fc(s.methods,r):s.methods=r,s.events=["chainChanged","accountsChanged"];return e}const a4={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}},c4={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 gt(r,t){const{message:e,code:i}=c4[r];return{message:t?`${e} ${t}`:e,code:i}}function Re(r,t){const{message:e,code:i}=a4[r];return{message:t?`${e} ${t}`:e,code:i}}function un(r,t){return Array.isArray(r)?typeof t<"u"&&r.length?r.every(t):!0:!1}function sa(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function Nr(r){return typeof r>"u"}function tr(r,t){return t&&Nr(r)?!0:typeof r=="string"&&!!r.trim().length}function Jl(r,t){return t&&Nr(r)?!0:typeof r=="number"&&!isNaN(r)}function u4(r,t){const{requiredNamespaces:e}=t,i=Object.keys(r.namespaces),s=Object.keys(e);let a=!0;return Es(s,i)?(i.forEach(u=>{const{accounts:l,methods:m,events:f}=r.namespaces[u],w=bo(l),E=e[u];(!Es(G1(u,E),w)||!Es(E.methods,m)||!Es(E.events,f))&&(a=!1)}),a):!1}function Xc(r){return tr(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function h4(r){if(tr(r,!1)&&r.includes(":")){const t=r.split(":");if(t.length===3){const e=t[0]+":"+t[1];return!!t[2]&&Xc(e)}}return!1}function l4(r){if(tr(r,!1))try{return typeof new URL(r)<"u"}catch{return!1}return!1}function f4(r){var t;return(t=r==null?void 0:r.proposer)==null?void 0:t.publicKey}function d4(r){return r==null?void 0:r.topic}function p4(r,t){let e=null;return tr(r==null?void 0:r.publicKey,!1)||(e=gt("MISSING_OR_INVALID",`${t} controller public key should be a string`)),e}function pp(r){let t=!0;return un(r)?r.length&&(t=r.every(e=>tr(e,!1))):t=!1,t}function g4(r,t,e){let i=null;return un(t)&&t.length?t.forEach(s=>{i||Xc(s)||(i=Re("UNSUPPORTED_CHAINS",`${e}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):Xc(r)||(i=Re("UNSUPPORTED_CHAINS",`${e}, 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 m4(r,t,e){let i=null;return Object.entries(r).forEach(([s,a])=>{if(i)return;const u=g4(s,G1(s,a),`${t} ${e}`);u&&(i=u)}),i}function v4(r,t){let e=null;return un(r)?r.forEach(i=>{e||h4(i)||(e=Re("UNSUPPORTED_ACCOUNTS",`${t}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):e=Re("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),e}function y4(r,t){let e=null;return Object.values(r).forEach(i=>{if(e)return;const s=v4(i==null?void 0:i.accounts,`${t} namespace`);s&&(e=s)}),e}function w4(r,t){let e=null;return pp(r==null?void 0:r.methods)?pp(r==null?void 0:r.events)||(e=Re("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):e=Re("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),e}function Lg(r,t){let e=null;return Object.values(r).forEach(i=>{if(e)return;const s=w4(i,`${t}, namespace`);s&&(e=s)}),e}function b4(r,t,e){let i=null;if(r&&sa(r)){const s=Lg(r,t);s&&(i=s);const a=m4(r,t,e);a&&(i=a)}else i=gt("MISSING_OR_INVALID",`${t}, ${e} should be an object with data`);return i}function Gh(r,t){let e=null;if(r&&sa(r)){const i=Lg(r,t);i&&(e=i);const s=y4(r,t);s&&(e=s)}else e=gt("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return e}function qg(r){return tr(r.protocol,!0)}function _4(r,t){let e=!1;return t&&!r?e=!0:r&&un(r)&&r.length&&r.forEach(i=>{e=qg(i)}),e}function E4(r){return typeof r=="number"}function kr(r){return typeof r<"u"&&typeof r!==null}function A4(r){return!(!r||typeof r!="object"||!r.code||!Jl(r.code,!1)||!r.message||!tr(r.message,!1))}function S4(r){return!(Nr(r)||!tr(r.method,!1))}function I4(r){return!(Nr(r)||Nr(r.result)&&Nr(r.error)||!Jl(r.id,!1)||!tr(r.jsonrpc,!1))}function D4(r){return!(Nr(r)||!tr(r.name,!1))}function gp(r,t){return!(!Xc(t)||!i4(r).includes(t))}function x4(r,t,e){return tr(e,!1)?n4(r,t).includes(e):!1}function M4(r,t,e){return tr(e,!1)?s4(r,t).includes(e):!1}function mp(r,t,e){let i=null;const s=C4(r),a=P4(t),u=Object.keys(s),l=Object.keys(a),m=vp(Object.keys(r)),f=vp(Object.keys(t)),w=m.filter(E=>!f.includes(E));return w.length&&(i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces keys don't satisfy requiredNamespaces.
12
+ Required: ${w.toString()}
13
+ Received: ${Object.keys(t).toString()}`)),Es(u,l)||(i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces chains don't satisfy required namespaces.
14
+ Required: ${u.toString()}
15
+ Approved: ${l.toString()}`)),Object.keys(t).forEach(E=>{if(!E.includes(":")||i)return;const x=bo(t[E].accounts);x.includes(E)||(i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces accounts don't satisfy namespace accounts for ${E}
16
+ Required: ${E}
17
+ Approved: ${x.toString()}`))}),u.forEach(E=>{i||(Es(s[E].methods,a[E].methods)?Es(s[E].events,a[E].events)||(i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces events don't satisfy namespace events for ${E}`)):i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces methods don't satisfy namespace methods for ${E}`))}),i}function C4(r){const t={};return Object.keys(r).forEach(e=>{var i;e.includes(":")?t[e]=r[e]:(i=r[e].chains)==null||i.forEach(s=>{t[s]={methods:r[e].methods,events:r[e].events}})}),t}function vp(r){return[...new Set(r.map(t=>t.includes(":")?t.split(":")[0]:t))]}function P4(r){const t={};return Object.keys(r).forEach(e=>{if(e.includes(":"))t[e]=r[e];else{const i=bo(r[e].accounts);i==null||i.forEach(s=>{t[s]={accounts:r[e].accounts.filter(a=>a.includes(`${s}:`)),methods:r[e].methods,events:r[e].events}})}}),t}function O4(r,t){return Jl(r,!1)&&r<=t.max&&r>=t.min}function yp(){const r=fa();return new Promise(t=>{switch(r){case ei.browser:t(N4());break;case ei.reactNative:t(R4());break;case ei.node:t(T4());break;default:t(!0)}})}function N4(){return go()&&(navigator==null?void 0:navigator.onLine)}async function R4(){if(po()&&typeof Ie<"u"&&Ie!=null&&Ie.NetInfo){const r=await(Ie==null?void 0:Ie.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function T4(){return!0}function F4(r){switch(fa()){case ei.browser:U4(r);break;case ei.reactNative:B4(r);break}}function U4(r){!po()&&go()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function B4(r){var t;po()&&typeof Ie<"u"&&Ie!=null&&Ie.NetInfo&&((t=Ie)==null||t.NetInfo.addEventListener(e=>r(e==null?void 0:e.isConnected)))}const Wh={};class Ko{static get(t){return Wh[t]}static set(t,e){Wh[t]=e}static delete(t){delete Wh[t]}}const L4=/"(?:_|\\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*:/,q4=/"(?: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*:/,j4=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function $4(r,t){if(r==="__proto__"||r==="constructor"&&t&&typeof t=="object"&&"prototype"in t){z4(r);return}return t}function z4(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Mc(r,t={}){if(typeof r!="string")return r;const e=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return e.slice(1,-1);if(e.length<=9){const i=e.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(!j4.test(r)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(L4.test(r)||q4.test(r)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,$4)}return JSON.parse(r)}catch(i){if(t.strict)throw i;return r}}function k4(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function lr(r,...t){try{return k4(r(...t))}catch(e){return Promise.reject(e)}}function H4(r){const t=typeof r;return r===null||t!=="object"&&t!=="function"}function K4(r){const t=Object.getPrototypeOf(r);return!t||t.isPrototypeOf(Object)}function $c(r){if(H4(r))return String(r);if(K4(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return $c(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function jg(){if(typeof ca===void 0)throw new TypeError("[unstorage] Buffer is not supported!")}const Dl="base64:";function V4(r){if(typeof r=="string")return r;jg();const t=ca.from(r).toString("base64");return Dl+t}function G4(r){return typeof r!="string"||!r.startsWith(Dl)?r:(jg(),ca.from(r.slice(Dl.length),"base64"))}function zr(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function W4(...r){return zr(r.join(":"))}function Cc(r){return r=zr(r),r?r+":":""}const Y4="memory",Q4=()=>{const r=new Map;return{name:Y4,options:{},hasItem(t){return r.has(t)},getItem(t){return r.get(t)??null},getItemRaw(t){return r.get(t)??null},setItem(t,e){r.set(t,e)},setItemRaw(t,e){r.set(t,e)},removeItem(t){r.delete(t)},getKeys(){return Array.from(r.keys())},clear(){r.clear()},dispose(){r.clear()}}};function J4(r={}){const t={mounts:{"":r.driver||Q4()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},e=f=>{for(const w of t.mountpoints)if(f.startsWith(w))return{base:w,relativeKey:f.slice(w.length),driver:t.mounts[w]};return{base:"",relativeKey:f,driver:t.mounts[""]}},i=(f,w)=>t.mountpoints.filter(E=>E.startsWith(f)||w&&f.startsWith(E)).map(E=>({relativeBase:f.length>E.length?f.slice(E.length):void 0,mountpoint:E,driver:t.mounts[E]})),s=(f,w)=>{if(t.watching){w=zr(w);for(const E of t.watchListeners)E(f,w)}},a=async()=>{if(!t.watching){t.watching=!0;for(const f in t.mounts)t.unwatch[f]=await wp(t.mounts[f],s,f)}},u=async()=>{if(t.watching){for(const f in t.unwatch)await t.unwatch[f]();t.unwatch={},t.watching=!1}},l=(f,w,E)=>{const x=new Map,I=N=>{let Y=x.get(N.base);return Y||(Y={driver:N.driver,base:N.base,items:[]},x.set(N.base,Y)),Y};for(const N of f){const Y=typeof N=="string",G=zr(Y?N:N.key),tt=Y?void 0:N.value,K=Y||!N.options?w:{...w,...N.options},V=e(G);I(V).items.push({key:G,value:tt,relativeKey:V.relativeKey,options:K})}return Promise.all([...x.values()].map(N=>E(N))).then(N=>N.flat())},m={hasItem(f,w={}){f=zr(f);const{relativeKey:E,driver:x}=e(f);return lr(x.hasItem,E,w)},getItem(f,w={}){f=zr(f);const{relativeKey:E,driver:x}=e(f);return lr(x.getItem,E,w).then(I=>Mc(I))},getItems(f,w){return l(f,w,E=>E.driver.getItems?lr(E.driver.getItems,E.items.map(x=>({key:x.relativeKey,options:x.options})),w).then(x=>x.map(I=>({key:W4(E.base,I.key),value:Mc(I.value)}))):Promise.all(E.items.map(x=>lr(E.driver.getItem,x.relativeKey,x.options).then(I=>({key:x.key,value:Mc(I)})))))},getItemRaw(f,w={}){f=zr(f);const{relativeKey:E,driver:x}=e(f);return x.getItemRaw?lr(x.getItemRaw,E,w):lr(x.getItem,E,w).then(I=>G4(I))},async setItem(f,w,E={}){if(w===void 0)return m.removeItem(f);f=zr(f);const{relativeKey:x,driver:I}=e(f);I.setItem&&(await lr(I.setItem,x,$c(w),E),I.watch||s("update",f))},async setItems(f,w){await l(f,w,async E=>{if(E.driver.setItems)return lr(E.driver.setItems,E.items.map(x=>({key:x.relativeKey,value:$c(x.value),options:x.options})),w);E.driver.setItem&&await Promise.all(E.items.map(x=>lr(E.driver.setItem,x.relativeKey,$c(x.value),x.options)))})},async setItemRaw(f,w,E={}){if(w===void 0)return m.removeItem(f,E);f=zr(f);const{relativeKey:x,driver:I}=e(f);if(I.setItemRaw)await lr(I.setItemRaw,x,w,E);else if(I.setItem)await lr(I.setItem,x,V4(w),E);else return;I.watch||s("update",f)},async removeItem(f,w={}){typeof w=="boolean"&&(w={removeMeta:w}),f=zr(f);const{relativeKey:E,driver:x}=e(f);x.removeItem&&(await lr(x.removeItem,E,w),(w.removeMeta||w.removeMata)&&await lr(x.removeItem,E+"$",w),x.watch||s("remove",f))},async getMeta(f,w={}){typeof w=="boolean"&&(w={nativeOnly:w}),f=zr(f);const{relativeKey:E,driver:x}=e(f),I=Object.create(null);if(x.getMeta&&Object.assign(I,await lr(x.getMeta,E,w)),!w.nativeOnly){const N=await lr(x.getItem,E+"$",w).then(Y=>Mc(Y));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(I,N))}return I},setMeta(f,w,E={}){return this.setItem(f+"$",w,E)},removeMeta(f,w={}){return this.removeItem(f+"$",w)},async getKeys(f,w={}){f=Cc(f);const E=i(f,!0);let x=[];const I=[];for(const N of E){const G=(await lr(N.driver.getKeys,N.relativeBase,w)).map(tt=>N.mountpoint+zr(tt)).filter(tt=>!x.some(K=>tt.startsWith(K)));I.push(...G),x=[N.mountpoint,...x.filter(tt=>!tt.startsWith(N.mountpoint))]}return f?I.filter(N=>N.startsWith(f)&&!N.endsWith("$")):I.filter(N=>!N.endsWith("$"))},async clear(f,w={}){f=Cc(f),await Promise.all(i(f,!1).map(async E=>{if(E.driver.clear)return lr(E.driver.clear,E.relativeBase,w);if(E.driver.removeItem){const x=await E.driver.getKeys(E.relativeBase||"",w);return Promise.all(x.map(I=>E.driver.removeItem(I,w)))}}))},async dispose(){await Promise.all(Object.values(t.mounts).map(f=>bp(f)))},async watch(f){return await a(),t.watchListeners.push(f),async()=>{t.watchListeners=t.watchListeners.filter(w=>w!==f),t.watchListeners.length===0&&await u()}},async unwatch(){t.watchListeners=[],await u()},mount(f,w){if(f=Cc(f),f&&t.mounts[f])throw new Error(`already mounted at ${f}`);return f&&(t.mountpoints.push(f),t.mountpoints.sort((E,x)=>x.length-E.length)),t.mounts[f]=w,t.watching&&Promise.resolve(wp(w,s,f)).then(E=>{t.unwatch[f]=E}).catch(console.error),m},async unmount(f,w=!0){f=Cc(f),!(!f||!t.mounts[f])&&(t.watching&&f in t.unwatch&&(t.unwatch[f](),delete t.unwatch[f]),w&&await bp(t.mounts[f]),t.mountpoints=t.mountpoints.filter(E=>E!==f),delete t.mounts[f])},getMount(f=""){f=zr(f)+":";const w=e(f);return{driver:w.driver,base:w.base}},getMounts(f="",w={}){return f=zr(f),i(f,w.parents).map(x=>({driver:x.driver,base:x.mountpoint}))}};return m}function wp(r,t,e){return r.watch?r.watch((i,s)=>t(i,e+s)):()=>{}}async function bp(r){typeof r.dispose=="function"&&await lr(r.dispose)}function Cs(r){return new Promise((t,e)=>{r.oncomplete=r.onsuccess=()=>t(r.result),r.onabort=r.onerror=()=>e(r.error)})}function $g(r,t){const e=indexedDB.open(r);e.onupgradeneeded=()=>e.result.createObjectStore(t);const i=Cs(e);return(s,a)=>i.then(u=>a(u.transaction(t,s).objectStore(t)))}let Yh;function ga(){return Yh||(Yh=$g("keyval-store","keyval")),Yh}function _p(r,t=ga()){return t("readonly",e=>Cs(e.get(r)))}function X4(r,t,e=ga()){return e("readwrite",i=>(i.put(t,r),Cs(i.transaction)))}function Z4(r,t=ga()){return t("readwrite",e=>(e.delete(r),Cs(e.transaction)))}function tS(r=ga()){return r("readwrite",t=>(t.clear(),Cs(t.transaction)))}function eS(r,t){return r.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},Cs(r.transaction)}function rS(r=ga()){return r("readonly",t=>{if(t.getAllKeys)return Cs(t.getAllKeys());const e=[];return eS(t,i=>e.push(i.key)).then(()=>e)})}const iS=r=>JSON.stringify(r,(t,e)=>typeof e=="bigint"?e.toString()+"n":e),nS=r=>{const t=/([\[:])?(\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,e=r.replace(t,'$1"$2n"$3');return JSON.parse(e,(i,s)=>typeof s=="string"&&s.match(/^\d+n$/)?BigInt(s.substring(0,s.length-1)):s)};function ma(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return nS(r)}catch{return r}}function Mn(r){return typeof r=="string"?r:iS(r)||""}const sS="idb-keyval";var oS=(r={})=>{const t=r.base&&r.base.length>0?`${r.base}:`:"",e=s=>t+s;let i;return r.dbName&&r.storeName&&(i=$g(r.dbName,r.storeName)),{name:sS,options:r,async hasItem(s){return!(typeof await _p(e(s),i)>"u")},async getItem(s){return await _p(e(s),i)??null},setItem(s,a){return X4(e(s),a,i)},removeItem(s){return Z4(e(s),i)},getKeys(){return rS(i)},clear(){return tS(i)}}};const aS="WALLET_CONNECT_V2_INDEXED_DB",cS="keyvaluestorage";let uS=class{constructor(){this.indexedDb=J4({driver:oS({dbName:aS,storeName:cS})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(t=>[t.key,t.value])}async getItem(t){const e=await this.indexedDb.getItem(t);if(e!==null)return e}async setItem(t,e){await this.indexedDb.setItem(t,Mn(e))}async removeItem(t){await this.indexedDb.removeItem(t)}};var Qh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ie<"u"?Ie:typeof self<"u"?self:{},zc={exports:{}};(function(){let r;function t(){}r=t,r.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},r.prototype.setItem=function(e,i){this[e]=String(i)},r.prototype.removeItem=function(e){delete this[e]},r.prototype.clear=function(){const e=this;Object.keys(e).forEach(function(i){e[i]=void 0,delete e[i]})},r.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Qh<"u"&&Qh.localStorage?zc.exports=Qh.localStorage:typeof window<"u"&&window.localStorage?zc.exports=window.localStorage:zc.exports=new t})();function hS(r){var t;return[r[0],ma((t=r[1])!=null?t:"")]}class lS{constructor(){this.localStorage=zc.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(hS)}async getItem(t){const e=this.localStorage.getItem(t);if(e!==null)return ma(e)}async setItem(t,e){this.localStorage.setItem(t,Mn(e))}async removeItem(t){this.localStorage.removeItem(t)}}const fS="wc_storage_version",Ep=1,dS=async(r,t,e)=>{const i=fS,s=await t.getItem(i);if(s&&s>=Ep){e(t);return}const a=await r.getKeys();if(!a.length){e(t);return}const u=[];for(;a.length;){const l=a.shift();if(!l)continue;const m=l.toLowerCase();if(m.includes("wc@")||m.includes("walletconnect")||m.includes("wc_")||m.includes("wallet_connect")){const f=await r.getItem(l);await t.setItem(l,f),u.push(l)}}await t.setItem(i,Ep),e(t),pS(r,u)},pS=async(r,t)=>{t.length&&t.forEach(async e=>{await r.removeItem(e)})};let gS=class{constructor(){this.initialized=!1,this.setInitialized=e=>{this.storage=e,this.initialized=!0};const t=new lS;this.storage=t;try{const e=new uS;dS(t,e,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(t){return await this.initialize(),this.storage.getItem(t)}async setItem(t,e){return await this.initialize(),this.storage.setItem(t,e)}async removeItem(t){return await this.initialize(),this.storage.removeItem(t)}async initialize(){this.initialized||await new Promise(t=>{const e=setInterval(()=>{this.initialized&&(clearInterval(e),t())},20)})}};class Ps{}let mS=class extends Ps{constructor(t){super()}};const Ap=yt.FIVE_SECONDS,va={pulse:"heartbeat_pulse"};let vS=class zg extends mS{constructor(t){super(t),this.events=new Di.EventEmitter,this.interval=Ap,this.interval=(t==null?void 0:t.interval)||Ap}static async init(t){const e=new zg(t);return await e.init(),e}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),yt.toMiliseconds(this.interval))}pulse(){this.events.emit(va.pulse)}};function yS(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}var wS=bS;function bS(r,t,e){var i=e&&e.stringify||yS,s=1;if(typeof r=="object"&&r!==null){var a=t.length+s;if(a===1)return r;var u=new Array(a);u[0]=i(r);for(var l=1;l<a;l++)u[l]=i(t[l]);return u.join(" ")}if(typeof r!="string")return r;var m=t.length;if(m===0)return r;for(var f="",w=1-s,E=-1,x=r&&r.length||0,I=0;I<x;){if(r.charCodeAt(I)===37&&I+1<x){switch(E=E>-1?E:0,r.charCodeAt(I+1)){case 100:case 102:if(w>=m||t[w]==null)break;E<I&&(f+=r.slice(E,I)),f+=Number(t[w]),E=I+2,I++;break;case 105:if(w>=m||t[w]==null)break;E<I&&(f+=r.slice(E,I)),f+=Math.floor(Number(t[w])),E=I+2,I++;break;case 79:case 111:case 106:if(w>=m||t[w]===void 0)break;E<I&&(f+=r.slice(E,I));var N=typeof t[w];if(N==="string"){f+="'"+t[w]+"'",E=I+2,I++;break}if(N==="function"){f+=t[w].name||"<anonymous>",E=I+2,I++;break}f+=i(t[w]),E=I+2,I++;break;case 115:if(w>=m)break;E<I&&(f+=r.slice(E,I)),f+=String(t[w]),E=I+2,I++;break;case 37:E<I&&(f+=r.slice(E,I)),f+="%",E=I+2,I++,w--;break}++w}++I}return E===-1?r:(E<x&&(f+=r.slice(E)),f)}const Sp=wS;var eo=cn;const oa=PS().console||{},_S={mapHttpRequest:Pc,mapHttpResponse:Pc,wrapRequestSerializer:Jh,wrapResponseSerializer:Jh,wrapErrorSerializer:Jh,req:Pc,res:Pc,err:DS};function ES(r,t){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(t):!1}function cn(r){r=r||{},r.browser=r.browser||{};const t=r.browser.transmit;if(t&&typeof t.send!="function")throw Error("pino: transmit option must have a send function");const e=r.browser.write||oa;r.browser.write&&(r.browser.asObject=!0);const i=r.serializers||{},s=ES(r.browser.serialize,i);let a=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(a=!1);const u=["error","fatal","warn","info","debug","trace"];typeof e=="function"&&(e.error=e.fatal=e.warn=e.info=e.debug=e.trace=e),r.enabled===!1&&(r.level="silent");const l=r.level||"info",m=Object.create(e);m.log||(m.log=aa),Object.defineProperty(m,"levelVal",{get:w}),Object.defineProperty(m,"level",{get:E,set:x});const f={transmit:t,serialize:s,asObject:r.browser.asObject,levels:u,timestamp:xS(r)};m.levels=cn.levels,m.level=l,m.setMaxListeners=m.getMaxListeners=m.emit=m.addListener=m.on=m.prependListener=m.once=m.prependOnceListener=m.removeListener=m.removeAllListeners=m.listeners=m.listenerCount=m.eventNames=m.write=m.flush=aa,m.serializers=i,m._serialize=s,m._stdErrSerialize=a,m.child=I,t&&(m._logEvent=xl());function w(){return this.level==="silent"?1/0:this.levels.values[this.level]}function E(){return this._level}function x(N){if(N!=="silent"&&!this.levels.values[N])throw Error("unknown level "+N);this._level=N,Js(f,m,"error","log"),Js(f,m,"fatal","error"),Js(f,m,"warn","error"),Js(f,m,"info","log"),Js(f,m,"debug","log"),Js(f,m,"trace","log")}function I(N,Y){if(!N)throw new Error("missing bindings for child Pino");Y=Y||{},s&&N.serializers&&(Y.serializers=N.serializers);const G=Y.serializers;if(s&&G){var tt=Object.assign({},i,G),K=r.browser.serialize===!0?Object.keys(tt):s;delete N.serializers,lu([N],K,tt,this._stdErrSerialize)}function V(B){this._childLevel=(B._childLevel|0)+1,this.error=Xs(B,N,"error"),this.fatal=Xs(B,N,"fatal"),this.warn=Xs(B,N,"warn"),this.info=Xs(B,N,"info"),this.debug=Xs(B,N,"debug"),this.trace=Xs(B,N,"trace"),tt&&(this.serializers=tt,this._serialize=K),t&&(this._logEvent=xl([].concat(B._logEvent.bindings,N)))}return V.prototype=this,new V(this)}return m}cn.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"}};cn.stdSerializers=_S;cn.stdTimeFunctions=Object.assign({},{nullTime:kg,epochTime:Hg,unixTime:MS,isoTime:CS});function Js(r,t,e,i){const s=Object.getPrototypeOf(t);t[e]=t.levelVal>t.levels.values[e]?aa:s[e]?s[e]:oa[e]||oa[i]||aa,AS(r,t,e)}function AS(r,t,e){!r.transmit&&t[e]===aa||(t[e]=function(i){return function(){const a=r.timestamp(),u=new Array(arguments.length),l=Object.getPrototypeOf&&Object.getPrototypeOf(this)===oa?oa:this;for(var m=0;m<u.length;m++)u[m]=arguments[m];if(r.serialize&&!r.asObject&&lu(u,this._serialize,this.serializers,this._stdErrSerialize),r.asObject?i.call(l,SS(this,e,u,a)):i.apply(l,u),r.transmit){const f=r.transmit.level||t.level,w=cn.levels.values[f],E=cn.levels.values[e];if(E<w)return;IS(this,{ts:a,methodLevel:e,methodValue:E,transmitLevel:f,transmitValue:cn.levels.values[r.transmit.level||t.level],send:r.transmit.send,val:t.levelVal},u)}}}(t[e]))}function SS(r,t,e,i){r._serialize&&lu(e,r._serialize,r.serializers,r._stdErrSerialize);const s=e.slice();let a=s[0];const u={};i&&(u.time=i),u.level=cn.levels.values[t];let l=(r._childLevel|0)+1;if(l<1&&(l=1),a!==null&&typeof a=="object"){for(;l--&&typeof s[0]=="object";)Object.assign(u,s.shift());a=s.length?Sp(s.shift(),s):void 0}else typeof a=="string"&&(a=Sp(s.shift(),s));return a!==void 0&&(u.msg=a),u}function lu(r,t,e,i){for(const s in r)if(i&&r[s]instanceof Error)r[s]=cn.stdSerializers.err(r[s]);else if(typeof r[s]=="object"&&!Array.isArray(r[s]))for(const a in r[s])t&&t.indexOf(a)>-1&&a in e&&(r[s][a]=e[a](r[s][a]))}function Xs(r,t,e){return function(){const i=new Array(1+arguments.length);i[0]=t;for(var s=1;s<i.length;s++)i[s]=arguments[s-1];return r[e].apply(this,i)}}function IS(r,t,e){const i=t.send,s=t.ts,a=t.methodLevel,u=t.methodValue,l=t.val,m=r._logEvent.bindings;lu(e,r._serialize||Object.keys(r.serializers),r.serializers,r._stdErrSerialize===void 0?!0:r._stdErrSerialize),r._logEvent.ts=s,r._logEvent.messages=e.filter(function(f){return m.indexOf(f)===-1}),r._logEvent.level.label=a,r._logEvent.level.value=u,i(a,r._logEvent,l),r._logEvent=xl(m)}function xl(r){return{ts:0,messages:[],bindings:r||[],level:{label:"",value:0}}}function DS(r){const t={type:r.constructor.name,msg:r.message,stack:r.stack};for(const e in r)t[e]===void 0&&(t[e]=r[e]);return t}function xS(r){return typeof r.timestamp=="function"?r.timestamp:r.timestamp===!1?kg:Hg}function Pc(){return{}}function Jh(r){return r}function aa(){}function kg(){return!1}function Hg(){return Date.now()}function MS(){return Math.round(Date.now()/1e3)}function CS(){return new Date(Date.now()).toISOString()}function PS(){function r(t){return typeof t<"u"&&t}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return r(self)||r(window)||r(this)||{}}}const ya=Tl(eo),OS={level:"info"},wa="custom_context",Xl=1e3*1024;let NS=class{constructor(t){this.nodeValue=t,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Ip=class{constructor(t){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=t,this.sizeInBytes=0}append(t){const e=new NS(t);if(e.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${t} with size ${e.size}`);for(;this.size+e.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=e),this.tail=e):(this.head=e,this.tail=e),this.lengthInNodes++,this.sizeInBytes+=e.size}shift(){if(!this.head)return;const t=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=t.size}toArray(){const t=[];let e=this.head;for(;e!==null;)t.push(e.value),e=e.next;return t}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let t=this.head;return{next:()=>{if(!t)return{done:!0,value:null};const e=t.value;return t=t.next,{done:!1,value:e}}}}},Kg=class{constructor(t,e=Xl){this.level=t??"error",this.levelValue=eo.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=e,this.logs=new Ip(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(t,e){e===eo.levels.values.error?console.error(t):e===eo.levels.values.warn?console.warn(t):e===eo.levels.values.debug?console.debug(t):e===eo.levels.values.trace?console.trace(t):console.log(t)}appendToLogs(t){this.logs.append(Mn({timestamp:new Date().toISOString(),log:t}));const e=typeof t=="string"?JSON.parse(t).level:t.level;e>=this.levelValue&&this.forwardToConsole(t,e)}getLogs(){return this.logs}clearLogs(){this.logs=new Ip(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(t){const e=this.getLogArray();return e.push(Mn({extraMetadata:t})),new Blob(e,{type:"application/json"})}},RS=class{constructor(t,e=Xl){this.baseChunkLogger=new Kg(t,e)}write(t){this.baseChunkLogger.appendToLogs(t)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}downloadLogsBlobInBrowser(t){const e=URL.createObjectURL(this.logsToBlob(t)),i=document.createElement("a");i.href=e,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(e)}},TS=class{constructor(t,e=Xl){this.baseChunkLogger=new Kg(t,e)}write(t){this.baseChunkLogger.appendToLogs(t)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}};var FS=Object.defineProperty,US=Object.defineProperties,BS=Object.getOwnPropertyDescriptors,Dp=Object.getOwnPropertySymbols,LS=Object.prototype.hasOwnProperty,qS=Object.prototype.propertyIsEnumerable,xp=(r,t,e)=>t in r?FS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zc=(r,t)=>{for(var e in t||(t={}))LS.call(t,e)&&xp(r,e,t[e]);if(Dp)for(var e of Dp(t))qS.call(t,e)&&xp(r,e,t[e]);return r},tu=(r,t)=>US(r,BS(t));function fu(r){return tu(Zc({},r),{level:(r==null?void 0:r.level)||OS.level})}function jS(r,t=wa){return r[t]||""}function $S(r,t,e=wa){return r[e]=t,r}function Gr(r,t=wa){let e="";return typeof r.bindings>"u"?e=jS(r,t):e=r.bindings().context||"",e}function zS(r,t,e=wa){const i=Gr(r,e);return i.trim()?`${i}/${t}`:t}function Wr(r,t,e=wa){const i=zS(r,t,e),s=r.child({context:i});return $S(s,i,e)}function kS(r){var t,e;const i=new RS((t=r.opts)==null?void 0:t.level,r.maxSizeInBytes);return{logger:ya(tu(Zc({},r.opts),{level:"trace",browser:tu(Zc({},(e=r.opts)==null?void 0:e.browser),{write:s=>i.write(s)})})),chunkLoggerController:i}}function HS(r){var t;const e=new TS((t=r.opts)==null?void 0:t.level,r.maxSizeInBytes);return{logger:ya(tu(Zc({},r.opts),{level:"trace"}),e),chunkLoggerController:e}}function KS(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?kS(r):HS(r)}let VS=class extends Ps{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}},GS=class extends Ps{constructor(t,e){super(),this.core=t,this.logger=e,this.records=new Map}},WS=class{constructor(t,e){this.logger=t,this.core=e}},YS=class extends Ps{constructor(t,e){super(),this.relayer=t,this.logger=e}},QS=class extends Ps{constructor(t){super()}},JS=class{constructor(t,e,i,s){this.core=t,this.logger=e,this.name=i}},XS=class extends Ps{constructor(t,e){super(),this.relayer=t,this.logger=e}},ZS=class extends Ps{constructor(t,e){super(),this.core=t,this.logger=e}},tI=class{constructor(t,e){this.projectId=t,this.logger=e}},eI=class{constructor(t,e){this.projectId=t,this.logger=e}},rI=class{constructor(t){this.opts=t,this.protocol="wc",this.version=2}},iI=class{constructor(t){this.client=t}};var Zl={},Vg={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=oe,e=si;r.DIGEST_LENGTH=64,r.BLOCK_SIZE=128;var i=function(){function l(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return l.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},l.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},l.prototype.clean=function(){e.wipe(this._buffer),e.wipe(this._tempHi),e.wipe(this._tempLo),this.reset()},l.prototype.update=function(m,f){if(f===void 0&&(f=m.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var w=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<r.BLOCK_SIZE&&f>0;)this._buffer[this._bufferLength++]=m[w++],f--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(w=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,m,w,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=m[w++],f--;return this},l.prototype.finish=function(m){if(!this._finished){var f=this._bytesHashed,w=this._bufferLength,E=f/536870912|0,x=f<<3,I=f%128<112?128:256;this._buffer[w]=128;for(var N=w+1;N<I-8;N++)this._buffer[N]=0;t.writeUint32BE(E,this._buffer,I-8),t.writeUint32BE(x,this._buffer,I-4),a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,I),this._finished=!0}for(var N=0;N<this.digestLength/8;N++)t.writeUint32BE(this._stateHi[N],m,N*8),t.writeUint32BE(this._stateLo[N],m,N*8+4);return this},l.prototype.digest=function(){var m=new Uint8Array(this.digestLength);return this.finish(m),m},l.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},l.prototype.restoreState=function(m){return this._stateHi.set(m.stateHi),this._stateLo.set(m.stateLo),this._bufferLength=m.bufferLength,m.buffer&&this._buffer.set(m.buffer),this._bytesHashed=m.bytesHashed,this._finished=!1,this},l.prototype.cleanSavedState=function(m){e.wipe(m.stateHi),e.wipe(m.stateLo),m.buffer&&e.wipe(m.buffer),m.bufferLength=0,m.bytesHashed=0},l}();r.SHA512=i;var s=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(l,m,f,w,E,x,I){for(var N=f[0],Y=f[1],G=f[2],tt=f[3],K=f[4],V=f[5],B=f[6],z=f[7],$=w[0],v=w[1],T=w[2],nt=w[3],ft=w[4],pt=w[5],mt=w[6],h=w[7],y,b,M,C,R,j,S,p;I>=128;){for(var O=0;O<16;O++){var it=8*O+x;l[O]=t.readUint32BE(E,it),m[O]=t.readUint32BE(E,it+4)}for(var O=0;O<80;O++){var lt=N,_=Y,Z=G,U=tt,L=K,k=V,d=B,F=z,et=$,ut=v,at=T,Mt=nt,Pt=ft,It=pt,Ee=mt,$t=h;if(y=z,b=h,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=(K>>>14|ft<<32-14)^(K>>>18|ft<<32-18)^(ft>>>41-32|K<<32-(41-32)),b=(ft>>>14|K<<32-14)^(ft>>>18|K<<32-18)^(K>>>41-32|ft<<32-(41-32)),R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,y=K&V^~K&B,b=ft&pt^~ft&mt,R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,y=s[O*2],b=s[O*2+1],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,y=l[O%16],b=m[O%16],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,M=S&65535|p<<16,C=R&65535|j<<16,y=M,b=C,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=(N>>>28|$<<32-28)^($>>>34-32|N<<32-(34-32))^($>>>39-32|N<<32-(39-32)),b=($>>>28|N<<32-28)^(N>>>34-32|$<<32-(34-32))^(N>>>39-32|$<<32-(39-32)),R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,y=N&Y^N&G^Y&G,b=$&v^$&T^v&T,R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,F=S&65535|p<<16,$t=R&65535|j<<16,y=U,b=Mt,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=M,b=C,R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,U=S&65535|p<<16,Mt=R&65535|j<<16,Y=lt,G=_,tt=Z,K=U,V=L,B=k,z=d,N=F,v=et,T=ut,nt=at,ft=Mt,pt=Pt,mt=It,h=Ee,$=$t,O%16===15)for(var it=0;it<16;it++)y=l[it],b=m[it],R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=l[(it+9)%16],b=m[(it+9)%16],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,M=l[(it+1)%16],C=m[(it+1)%16],y=(M>>>1|C<<32-1)^(M>>>8|C<<32-8)^M>>>7,b=(C>>>1|M<<32-1)^(C>>>8|M<<32-8)^(C>>>7|M<<32-7),R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,M=l[(it+14)%16],C=m[(it+14)%16],y=(M>>>19|C<<32-19)^(C>>>61-32|M<<32-(61-32))^M>>>6,b=(C>>>19|M<<32-19)^(M>>>61-32|C<<32-(61-32))^(C>>>6|M<<32-6),R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,l[it]=S&65535|p<<16,m[it]=R&65535|j<<16}y=N,b=$,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=f[0],b=w[0],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,f[0]=N=S&65535|p<<16,w[0]=$=R&65535|j<<16,y=Y,b=v,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=f[1],b=w[1],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,f[1]=Y=S&65535|p<<16,w[1]=v=R&65535|j<<16,y=G,b=T,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=f[2],b=w[2],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,f[2]=G=S&65535|p<<16,w[2]=T=R&65535|j<<16,y=tt,b=nt,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=f[3],b=w[3],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,f[3]=tt=S&65535|p<<16,w[3]=nt=R&65535|j<<16,y=K,b=ft,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=f[4],b=w[4],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,f[4]=K=S&65535|p<<16,w[4]=ft=R&65535|j<<16,y=V,b=pt,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=f[5],b=w[5],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,f[5]=V=S&65535|p<<16,w[5]=pt=R&65535|j<<16,y=B,b=mt,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=f[6],b=w[6],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,f[6]=B=S&65535|p<<16,w[6]=mt=R&65535|j<<16,y=z,b=h,R=b&65535,j=b>>>16,S=y&65535,p=y>>>16,y=f[7],b=w[7],R+=b&65535,j+=b>>>16,S+=y&65535,p+=y>>>16,j+=R>>>16,S+=j>>>16,p+=S>>>16,f[7]=z=S&65535|p<<16,w[7]=h=R&65535|j<<16,x+=128,I-=128}return x}function u(l){var m=new i;m.update(l);var f=m.digest();return m.clean(),f}r.hash=u})(Vg);(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 t=fo,e=Vg,i=si;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function s(U){const L=new Float64Array(16);if(U)for(let k=0;k<U.length;k++)L[k]=U[k];return L}const a=new Uint8Array(32);a[0]=9;const u=s(),l=s([1]),m=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),f=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),w=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),E=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),x=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function I(U,L){for(let k=0;k<16;k++)U[k]=L[k]|0}function N(U){let L=1;for(let k=0;k<16;k++){let d=U[k]+L+65535;L=Math.floor(d/65536),U[k]=d-L*65536}U[0]+=L-1+37*(L-1)}function Y(U,L,k){const d=~(k-1);for(let F=0;F<16;F++){const et=d&(U[F]^L[F]);U[F]^=et,L[F]^=et}}function G(U,L){const k=s(),d=s();for(let F=0;F<16;F++)d[F]=L[F];N(d),N(d),N(d);for(let F=0;F<2;F++){k[0]=d[0]-65517;for(let ut=1;ut<15;ut++)k[ut]=d[ut]-65535-(k[ut-1]>>16&1),k[ut-1]&=65535;k[15]=d[15]-32767-(k[14]>>16&1);const et=k[15]>>16&1;k[14]&=65535,Y(d,k,1-et)}for(let F=0;F<16;F++)U[2*F]=d[F]&255,U[2*F+1]=d[F]>>8}function tt(U,L){let k=0;for(let d=0;d<32;d++)k|=U[d]^L[d];return(1&k-1>>>8)-1}function K(U,L){const k=new Uint8Array(32),d=new Uint8Array(32);return G(k,U),G(d,L),tt(k,d)}function V(U){const L=new Uint8Array(32);return G(L,U),L[0]&1}function B(U,L){for(let k=0;k<16;k++)U[k]=L[2*k]+(L[2*k+1]<<8);U[15]&=32767}function z(U,L,k){for(let d=0;d<16;d++)U[d]=L[d]+k[d]}function $(U,L,k){for(let d=0;d<16;d++)U[d]=L[d]-k[d]}function v(U,L,k){let d,F,et=0,ut=0,at=0,Mt=0,Pt=0,It=0,Ee=0,$t=0,xt=0,Bt=0,_t=0,Et=0,Vt=0,wt=0,At=0,Ut=0,bt=0,Ct=0,Lt=0,Ot=0,Nt=0,se=0,Tt=0,Rt=0,Ke=0,ce=0,pe=0,Ve=0,ye=0,_e=0,Ar=0,Gt=k[0],zt=k[1],De=k[2],Wt=k[3],Kt=k[4],Ae=k[5],Jt=k[6],Xt=k[7],xe=k[8],Zt=k[9],Yt=k[10],Ce=k[11],Qt=k[12],qt=k[13],Te=k[14],te=k[15];d=L[0],et+=d*Gt,ut+=d*zt,at+=d*De,Mt+=d*Wt,Pt+=d*Kt,It+=d*Ae,Ee+=d*Jt,$t+=d*Xt,xt+=d*xe,Bt+=d*Zt,_t+=d*Yt,Et+=d*Ce,Vt+=d*Qt,wt+=d*qt,At+=d*Te,Ut+=d*te,d=L[1],ut+=d*Gt,at+=d*zt,Mt+=d*De,Pt+=d*Wt,It+=d*Kt,Ee+=d*Ae,$t+=d*Jt,xt+=d*Xt,Bt+=d*xe,_t+=d*Zt,Et+=d*Yt,Vt+=d*Ce,wt+=d*Qt,At+=d*qt,Ut+=d*Te,bt+=d*te,d=L[2],at+=d*Gt,Mt+=d*zt,Pt+=d*De,It+=d*Wt,Ee+=d*Kt,$t+=d*Ae,xt+=d*Jt,Bt+=d*Xt,_t+=d*xe,Et+=d*Zt,Vt+=d*Yt,wt+=d*Ce,At+=d*Qt,Ut+=d*qt,bt+=d*Te,Ct+=d*te,d=L[3],Mt+=d*Gt,Pt+=d*zt,It+=d*De,Ee+=d*Wt,$t+=d*Kt,xt+=d*Ae,Bt+=d*Jt,_t+=d*Xt,Et+=d*xe,Vt+=d*Zt,wt+=d*Yt,At+=d*Ce,Ut+=d*Qt,bt+=d*qt,Ct+=d*Te,Lt+=d*te,d=L[4],Pt+=d*Gt,It+=d*zt,Ee+=d*De,$t+=d*Wt,xt+=d*Kt,Bt+=d*Ae,_t+=d*Jt,Et+=d*Xt,Vt+=d*xe,wt+=d*Zt,At+=d*Yt,Ut+=d*Ce,bt+=d*Qt,Ct+=d*qt,Lt+=d*Te,Ot+=d*te,d=L[5],It+=d*Gt,Ee+=d*zt,$t+=d*De,xt+=d*Wt,Bt+=d*Kt,_t+=d*Ae,Et+=d*Jt,Vt+=d*Xt,wt+=d*xe,At+=d*Zt,Ut+=d*Yt,bt+=d*Ce,Ct+=d*Qt,Lt+=d*qt,Ot+=d*Te,Nt+=d*te,d=L[6],Ee+=d*Gt,$t+=d*zt,xt+=d*De,Bt+=d*Wt,_t+=d*Kt,Et+=d*Ae,Vt+=d*Jt,wt+=d*Xt,At+=d*xe,Ut+=d*Zt,bt+=d*Yt,Ct+=d*Ce,Lt+=d*Qt,Ot+=d*qt,Nt+=d*Te,se+=d*te,d=L[7],$t+=d*Gt,xt+=d*zt,Bt+=d*De,_t+=d*Wt,Et+=d*Kt,Vt+=d*Ae,wt+=d*Jt,At+=d*Xt,Ut+=d*xe,bt+=d*Zt,Ct+=d*Yt,Lt+=d*Ce,Ot+=d*Qt,Nt+=d*qt,se+=d*Te,Tt+=d*te,d=L[8],xt+=d*Gt,Bt+=d*zt,_t+=d*De,Et+=d*Wt,Vt+=d*Kt,wt+=d*Ae,At+=d*Jt,Ut+=d*Xt,bt+=d*xe,Ct+=d*Zt,Lt+=d*Yt,Ot+=d*Ce,Nt+=d*Qt,se+=d*qt,Tt+=d*Te,Rt+=d*te,d=L[9],Bt+=d*Gt,_t+=d*zt,Et+=d*De,Vt+=d*Wt,wt+=d*Kt,At+=d*Ae,Ut+=d*Jt,bt+=d*Xt,Ct+=d*xe,Lt+=d*Zt,Ot+=d*Yt,Nt+=d*Ce,se+=d*Qt,Tt+=d*qt,Rt+=d*Te,Ke+=d*te,d=L[10],_t+=d*Gt,Et+=d*zt,Vt+=d*De,wt+=d*Wt,At+=d*Kt,Ut+=d*Ae,bt+=d*Jt,Ct+=d*Xt,Lt+=d*xe,Ot+=d*Zt,Nt+=d*Yt,se+=d*Ce,Tt+=d*Qt,Rt+=d*qt,Ke+=d*Te,ce+=d*te,d=L[11],Et+=d*Gt,Vt+=d*zt,wt+=d*De,At+=d*Wt,Ut+=d*Kt,bt+=d*Ae,Ct+=d*Jt,Lt+=d*Xt,Ot+=d*xe,Nt+=d*Zt,se+=d*Yt,Tt+=d*Ce,Rt+=d*Qt,Ke+=d*qt,ce+=d*Te,pe+=d*te,d=L[12],Vt+=d*Gt,wt+=d*zt,At+=d*De,Ut+=d*Wt,bt+=d*Kt,Ct+=d*Ae,Lt+=d*Jt,Ot+=d*Xt,Nt+=d*xe,se+=d*Zt,Tt+=d*Yt,Rt+=d*Ce,Ke+=d*Qt,ce+=d*qt,pe+=d*Te,Ve+=d*te,d=L[13],wt+=d*Gt,At+=d*zt,Ut+=d*De,bt+=d*Wt,Ct+=d*Kt,Lt+=d*Ae,Ot+=d*Jt,Nt+=d*Xt,se+=d*xe,Tt+=d*Zt,Rt+=d*Yt,Ke+=d*Ce,ce+=d*Qt,pe+=d*qt,Ve+=d*Te,ye+=d*te,d=L[14],At+=d*Gt,Ut+=d*zt,bt+=d*De,Ct+=d*Wt,Lt+=d*Kt,Ot+=d*Ae,Nt+=d*Jt,se+=d*Xt,Tt+=d*xe,Rt+=d*Zt,Ke+=d*Yt,ce+=d*Ce,pe+=d*Qt,Ve+=d*qt,ye+=d*Te,_e+=d*te,d=L[15],Ut+=d*Gt,bt+=d*zt,Ct+=d*De,Lt+=d*Wt,Ot+=d*Kt,Nt+=d*Ae,se+=d*Jt,Tt+=d*Xt,Rt+=d*xe,Ke+=d*Zt,ce+=d*Yt,pe+=d*Ce,Ve+=d*Qt,ye+=d*qt,_e+=d*Te,Ar+=d*te,et+=38*bt,ut+=38*Ct,at+=38*Lt,Mt+=38*Ot,Pt+=38*Nt,It+=38*se,Ee+=38*Tt,$t+=38*Rt,xt+=38*Ke,Bt+=38*ce,_t+=38*pe,Et+=38*Ve,Vt+=38*ye,wt+=38*_e,At+=38*Ar,F=1,d=et+F+65535,F=Math.floor(d/65536),et=d-F*65536,d=ut+F+65535,F=Math.floor(d/65536),ut=d-F*65536,d=at+F+65535,F=Math.floor(d/65536),at=d-F*65536,d=Mt+F+65535,F=Math.floor(d/65536),Mt=d-F*65536,d=Pt+F+65535,F=Math.floor(d/65536),Pt=d-F*65536,d=It+F+65535,F=Math.floor(d/65536),It=d-F*65536,d=Ee+F+65535,F=Math.floor(d/65536),Ee=d-F*65536,d=$t+F+65535,F=Math.floor(d/65536),$t=d-F*65536,d=xt+F+65535,F=Math.floor(d/65536),xt=d-F*65536,d=Bt+F+65535,F=Math.floor(d/65536),Bt=d-F*65536,d=_t+F+65535,F=Math.floor(d/65536),_t=d-F*65536,d=Et+F+65535,F=Math.floor(d/65536),Et=d-F*65536,d=Vt+F+65535,F=Math.floor(d/65536),Vt=d-F*65536,d=wt+F+65535,F=Math.floor(d/65536),wt=d-F*65536,d=At+F+65535,F=Math.floor(d/65536),At=d-F*65536,d=Ut+F+65535,F=Math.floor(d/65536),Ut=d-F*65536,et+=F-1+37*(F-1),F=1,d=et+F+65535,F=Math.floor(d/65536),et=d-F*65536,d=ut+F+65535,F=Math.floor(d/65536),ut=d-F*65536,d=at+F+65535,F=Math.floor(d/65536),at=d-F*65536,d=Mt+F+65535,F=Math.floor(d/65536),Mt=d-F*65536,d=Pt+F+65535,F=Math.floor(d/65536),Pt=d-F*65536,d=It+F+65535,F=Math.floor(d/65536),It=d-F*65536,d=Ee+F+65535,F=Math.floor(d/65536),Ee=d-F*65536,d=$t+F+65535,F=Math.floor(d/65536),$t=d-F*65536,d=xt+F+65535,F=Math.floor(d/65536),xt=d-F*65536,d=Bt+F+65535,F=Math.floor(d/65536),Bt=d-F*65536,d=_t+F+65535,F=Math.floor(d/65536),_t=d-F*65536,d=Et+F+65535,F=Math.floor(d/65536),Et=d-F*65536,d=Vt+F+65535,F=Math.floor(d/65536),Vt=d-F*65536,d=wt+F+65535,F=Math.floor(d/65536),wt=d-F*65536,d=At+F+65535,F=Math.floor(d/65536),At=d-F*65536,d=Ut+F+65535,F=Math.floor(d/65536),Ut=d-F*65536,et+=F-1+37*(F-1),U[0]=et,U[1]=ut,U[2]=at,U[3]=Mt,U[4]=Pt,U[5]=It,U[6]=Ee,U[7]=$t,U[8]=xt,U[9]=Bt,U[10]=_t,U[11]=Et,U[12]=Vt,U[13]=wt,U[14]=At,U[15]=Ut}function T(U,L){v(U,L,L)}function nt(U,L){const k=s();let d;for(d=0;d<16;d++)k[d]=L[d];for(d=253;d>=0;d--)T(k,k),d!==2&&d!==4&&v(k,k,L);for(d=0;d<16;d++)U[d]=k[d]}function ft(U,L){const k=s();let d;for(d=0;d<16;d++)k[d]=L[d];for(d=250;d>=0;d--)T(k,k),d!==1&&v(k,k,L);for(d=0;d<16;d++)U[d]=k[d]}function pt(U,L){const k=s(),d=s(),F=s(),et=s(),ut=s(),at=s(),Mt=s(),Pt=s(),It=s();$(k,U[1],U[0]),$(It,L[1],L[0]),v(k,k,It),z(d,U[0],U[1]),z(It,L[0],L[1]),v(d,d,It),v(F,U[3],L[3]),v(F,F,f),v(et,U[2],L[2]),z(et,et,et),$(ut,d,k),$(at,et,F),z(Mt,et,F),z(Pt,d,k),v(U[0],ut,at),v(U[1],Pt,Mt),v(U[2],Mt,at),v(U[3],ut,Pt)}function mt(U,L,k){for(let d=0;d<4;d++)Y(U[d],L[d],k)}function h(U,L){const k=s(),d=s(),F=s();nt(F,L[2]),v(k,L[0],F),v(d,L[1],F),G(U,d),U[31]^=V(k)<<7}function y(U,L,k){I(U[0],u),I(U[1],l),I(U[2],l),I(U[3],u);for(let d=255;d>=0;--d){const F=k[d/8|0]>>(d&7)&1;mt(U,L,F),pt(L,U),pt(U,U),mt(U,L,F)}}function b(U,L){const k=[s(),s(),s(),s()];I(k[0],w),I(k[1],E),I(k[2],l),v(k[3],w,E),y(U,k,L)}function M(U){if(U.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const L=(0,e.hash)(U);L[0]&=248,L[31]&=127,L[31]|=64;const k=new Uint8Array(32),d=[s(),s(),s(),s()];b(d,L),h(k,d);const F=new Uint8Array(64);return F.set(U),F.set(k,32),{publicKey:k,secretKey:F}}r.generateKeyPairFromSeed=M;function C(U){const L=(0,t.randomBytes)(32,U),k=M(L);return(0,i.wipe)(L),k}r.generateKeyPair=C;function R(U){if(U.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(U.subarray(32))}r.extractPublicKeyFromSecretKey=R;const j=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 S(U,L){let k,d,F,et;for(d=63;d>=32;--d){for(k=0,F=d-32,et=d-12;F<et;++F)L[F]+=k-16*L[d]*j[F-(d-32)],k=Math.floor((L[F]+128)/256),L[F]-=k*256;L[F]+=k,L[d]=0}for(k=0,F=0;F<32;F++)L[F]+=k-(L[31]>>4)*j[F],k=L[F]>>8,L[F]&=255;for(F=0;F<32;F++)L[F]-=k*j[F];for(d=0;d<32;d++)L[d+1]+=L[d]>>8,U[d]=L[d]&255}function p(U){const L=new Float64Array(64);for(let k=0;k<64;k++)L[k]=U[k];for(let k=0;k<64;k++)U[k]=0;S(U,L)}function O(U,L){const k=new Float64Array(64),d=[s(),s(),s(),s()],F=(0,e.hash)(U.subarray(0,32));F[0]&=248,F[31]&=127,F[31]|=64;const et=new Uint8Array(64);et.set(F.subarray(32),32);const ut=new e.SHA512;ut.update(et.subarray(32)),ut.update(L);const at=ut.digest();ut.clean(),p(at),b(d,at),h(et,d),ut.reset(),ut.update(et.subarray(0,32)),ut.update(U.subarray(32)),ut.update(L);const Mt=ut.digest();p(Mt);for(let Pt=0;Pt<32;Pt++)k[Pt]=at[Pt];for(let Pt=0;Pt<32;Pt++)for(let It=0;It<32;It++)k[Pt+It]+=Mt[Pt]*F[It];return S(et.subarray(32),k),et}r.sign=O;function it(U,L){const k=s(),d=s(),F=s(),et=s(),ut=s(),at=s(),Mt=s();return I(U[2],l),B(U[1],L),T(F,U[1]),v(et,F,m),$(F,F,U[2]),z(et,U[2],et),T(ut,et),T(at,ut),v(Mt,at,ut),v(k,Mt,F),v(k,k,et),ft(k,k),v(k,k,F),v(k,k,et),v(k,k,et),v(U[0],k,et),T(d,U[0]),v(d,d,et),K(d,F)&&v(U[0],U[0],x),T(d,U[0]),v(d,d,et),K(d,F)?-1:(V(U[0])===L[31]>>7&&$(U[0],u,U[0]),v(U[3],U[0],U[1]),0)}function lt(U,L,k){const d=new Uint8Array(32),F=[s(),s(),s(),s()],et=[s(),s(),s(),s()];if(k.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(it(et,U))return!1;const ut=new e.SHA512;ut.update(k.subarray(0,32)),ut.update(U),ut.update(L);const at=ut.digest();return p(at),y(F,et,at),b(et,k.subarray(32)),pt(F,et),h(d,F),!tt(k,d)}r.verify=lt;function _(U){let L=[s(),s(),s(),s()];if(it(L,U))throw new Error("Ed25519: invalid public key");let k=s(),d=s(),F=L[1];z(k,l,F),$(d,l,F),nt(d,d),v(k,k,d);let et=new Uint8Array(32);return G(et,k),et}r.convertPublicKeyToX25519=_;function Z(U){const L=(0,e.hash)(U.subarray(0,32));L[0]&=248,L[31]&=127,L[31]|=64;const k=new Uint8Array(L.subarray(0,32));return(0,i.wipe)(L),k}r.convertSecretKeyToX25519=Z})(Zl);const nI="EdDSA",sI="JWT",Gg=".",Wg="base64url",oI="utf8",aI="utf8",cI=":",uI="did",hI="key",Mp="base58btc",lI="z",fI="K36",dI=32;function eu(r){return Tr(Kr(Mn(r),oI),Wg)}function Yg(r){const t=Kr(fI,Mp),e=lI+Tr(gl([t,r]),Mp);return[uI,hI,e].join(cI)}function pI(r){return Tr(r,Wg)}function gI(r){return Kr([eu(r.header),eu(r.payload)].join(Gg),aI)}function mI(r){return[eu(r.header),eu(r.payload),pI(r.signature)].join(Gg)}function Cp(r=fo.randomBytes(dI)){return Zl.generateKeyPairFromSeed(r)}async function vI(r,t,e,i,s=yt.fromMiliseconds(Date.now())){const a={alg:nI,typ:sI},u=Yg(i.publicKey),l=s+e,m={iss:u,sub:r,aud:t,iat:s,exp:l},f=gI({header:a,payload:m}),w=Zl.sign(i.secretKey,f);return mI({header:a,payload:m,signature:w})}const yI="PARSE_ERROR",wI="INVALID_REQUEST",bI="METHOD_NOT_FOUND",_I="INVALID_PARAMS",Qg="INTERNAL_ERROR",tf="SERVER_ERROR",EI=[-32700,-32600,-32601,-32602,-32603],ta={[yI]:{code:-32700,message:"Parse error"},[wI]:{code:-32600,message:"Invalid Request"},[bI]:{code:-32601,message:"Method not found"},[_I]:{code:-32602,message:"Invalid params"},[Qg]:{code:-32603,message:"Internal error"},[tf]:{code:-32e3,message:"Server error"}},Jg=tf;function AI(r){return EI.includes(r)}function Pp(r){return Object.keys(ta).includes(r)?ta[r]:ta[Jg]}function SI(r){const t=Object.values(ta).find(e=>e.code===r);return t||ta[Jg]}function Xg(r,t,e){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${e} RPC url at ${t}`):r}var Zg={},En={},Op;function II(){if(Op)return En;Op=1,Object.defineProperty(En,"__esModule",{value:!0}),En.isBrowserCryptoAvailable=En.getSubtleCrypto=En.getBrowerCrypto=void 0;function r(){return(Zi===null||Zi===void 0?void 0:Zi.crypto)||(Zi===null||Zi===void 0?void 0:Zi.msCrypto)||{}}En.getBrowerCrypto=r;function t(){const i=r();return i.subtle||i.webkitSubtle}En.getSubtleCrypto=t;function e(){return!!r()&&!!t()}return En.isBrowserCryptoAvailable=e,En}var An={},Np;function DI(){if(Np)return An;Np=1,Object.defineProperty(An,"__esModule",{value:!0}),An.isBrowser=An.isNode=An.isReactNative=void 0;function r(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}An.isReactNative=r;function t(){return typeof ri<"u"&&typeof ri.versions<"u"&&typeof ri.versions.node<"u"}An.isNode=t;function e(){return!r()&&!t()}return An.isBrowser=e,An}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=ua;t.__exportStar(II(),r),t.__exportStar(DI(),r)})(Zg);function Kn(r=3){const t=Date.now()*Math.pow(10,r),e=Math.floor(Math.random()*Math.pow(10,r));return t+e}function Ss(r=6){return BigInt(Kn(r))}function co(r,t,e){return{id:e||Kn(),jsonrpc:"2.0",method:r,params:t}}function du(r,t){return{id:r,jsonrpc:"2.0",result:t}}function pu(r,t,e){return{id:r,jsonrpc:"2.0",error:xI(t,e)}}function xI(r,t){return typeof r>"u"?Pp(Qg):(typeof r=="string"&&(r=Object.assign(Object.assign({},Pp(tf)),{message:r})),typeof t<"u"&&(r.data=t),AI(r.code)&&(r=SI(r.code)),r)}class MI{}class CI extends MI{constructor(){super()}}class PI extends CI{constructor(t){super()}}const OI="^https?:",NI="^wss?:";function RI(r){const t=r.match(new RegExp(/^\w+:/,"gi"));if(!(!t||!t.length))return t[0]}function tm(r,t){const e=RI(r);return typeof e>"u"?!1:new RegExp(t).test(e)}function Rp(r){return tm(r,OI)}function Tp(r){return tm(r,NI)}function TI(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function em(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function ef(r){return em(r)&&"method"in r}function gu(r){return em(r)&&(Ji(r)||Si(r))}function Ji(r){return"result"in r}function Si(r){return"error"in r}class Cn extends PI{constructor(t){super(t),this.events=new Di.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async request(t,e){return this.requestStrict(co(t.method,t.params||[],t.id||Ss().toString()),e)}async requestStrict(t,e){return new Promise(async(i,s)=>{if(!this.connection.connected)try{await this.open()}catch(a){s(a)}this.events.on(`${t.id}`,a=>{Si(a)?s(a.error):i(a.result)});try{await this.connection.send(t,e)}catch(a){s(a)}})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),gu(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0)}}var Xh,Fp;function FI(){return Fp||(Fp=1,Xh=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}),Xh}const UI=()=>typeof WebSocket<"u"?WebSocket:typeof Ie<"u"&&typeof Ie.WebSocket<"u"?Ie.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:FI(),BI=()=>typeof WebSocket<"u"||typeof Ie<"u"&&typeof Ie.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Up=r=>r.split("?")[0],Bp=10,LI=UI();let qI=class{constructor(t){if(this.url=t,this.events=new Di.EventEmitter,this.registering=!1,!Tp(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,e)=>{if(typeof this.socket>"u"){e(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),t()},this.socket.close()})}async send(t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Mn(t))}catch(e){this.onError(t.id,e)}}register(t=this.url){if(!Tp(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((i,s)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),s(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return s(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=t,this.registering=!0,new Promise((e,i)=>{const s=new URLSearchParams(t).get("origin"),a=Zg.isReactNative()?{headers:{origin:s}}:{rejectUnauthorized:!TI(t)},u=new LI(t,[],a);BI()?u.onerror=l=>{const m=l;i(this.emitError(m.error))}:u.on("error",l=>{i(this.emitError(l))}),u.onopen=()=>{this.onOpen(u),e(u)}})}onOpen(t){t.onmessage=e=>this.onPayload(e),t.onclose=e=>this.onClose(e),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?ma(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const i=this.parseError(e),s=i.message||i.toString(),a=pu(t,s);this.events.emit("payload",a)}parseError(t,e=this.url){return Xg(t,Up(e),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Bp&&this.events.setMaxListeners(Bp)}emitError(t){const e=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${Up(this.url)}`));return this.events.emit("register_error",e),e}};var ru={exports:{}};ru.exports;(function(r,t){var e=200,i="__lodash_hash_undefined__",s=1,a=2,u=9007199254740991,l="[object Arguments]",m="[object Array]",f="[object AsyncFunction]",w="[object Boolean]",E="[object Date]",x="[object Error]",I="[object Function]",N="[object GeneratorFunction]",Y="[object Map]",G="[object Number]",tt="[object Null]",K="[object Object]",V="[object Promise]",B="[object Proxy]",z="[object RegExp]",$="[object Set]",v="[object String]",T="[object Symbol]",nt="[object Undefined]",ft="[object WeakMap]",pt="[object ArrayBuffer]",mt="[object DataView]",h="[object Float32Array]",y="[object Float64Array]",b="[object Int8Array]",M="[object Int16Array]",C="[object Int32Array]",R="[object Uint8Array]",j="[object Uint8ClampedArray]",S="[object Uint16Array]",p="[object Uint32Array]",O=/[\\^$.*+?()[\]{}|]/g,it=/^\[object .+?Constructor\]$/,lt=/^(?:0|[1-9]\d*)$/,_={};_[h]=_[y]=_[b]=_[M]=_[C]=_[R]=_[j]=_[S]=_[p]=!0,_[l]=_[m]=_[pt]=_[w]=_[mt]=_[E]=_[x]=_[I]=_[Y]=_[G]=_[K]=_[z]=_[$]=_[v]=_[ft]=!1;var Z=typeof Zi=="object"&&Zi&&Zi.Object===Object&&Zi,U=typeof self=="object"&&self&&self.Object===Object&&self,L=Z||U||Function("return this")(),k=t&&!t.nodeType&&t,d=k&&!0&&r&&!r.nodeType&&r,F=d&&d.exports===k,et=F&&Z.process,ut=function(){try{return et&&et.binding&&et.binding("util")}catch{}}(),at=ut&&ut.isTypedArray;function Mt(q,Q){for(var ht=-1,St=q==null?0:q.length,Be=0,re=[];++ht<St;){var $e=q[ht];Q($e,ht,q)&&(re[Be++]=$e)}return re}function Pt(q,Q){for(var ht=-1,St=Q.length,Be=q.length;++ht<St;)q[Be+ht]=Q[ht];return q}function It(q,Q){for(var ht=-1,St=q==null?0:q.length;++ht<St;)if(Q(q[ht],ht,q))return!0;return!1}function Ee(q,Q){for(var ht=-1,St=Array(q);++ht<q;)St[ht]=Q(ht);return St}function $t(q){return function(Q){return q(Q)}}function xt(q,Q){return q.has(Q)}function Bt(q,Q){return q==null?void 0:q[Q]}function _t(q){var Q=-1,ht=Array(q.size);return q.forEach(function(St,Be){ht[++Q]=[Be,St]}),ht}function Et(q,Q){return function(ht){return q(Q(ht))}}function Vt(q){var Q=-1,ht=Array(q.size);return q.forEach(function(St){ht[++Q]=St}),ht}var wt=Array.prototype,At=Function.prototype,Ut=Object.prototype,bt=L["__core-js_shared__"],Ct=At.toString,Lt=Ut.hasOwnProperty,Ot=function(){var q=/[^.]+$/.exec(bt&&bt.keys&&bt.keys.IE_PROTO||"");return q?"Symbol(src)_1."+q:""}(),Nt=Ut.toString,se=RegExp("^"+Ct.call(Lt).replace(O,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Tt=F?L.Buffer:void 0,Rt=L.Symbol,Ke=L.Uint8Array,ce=Ut.propertyIsEnumerable,pe=wt.splice,Ve=Rt?Rt.toStringTag:void 0,ye=Object.getOwnPropertySymbols,_e=Tt?Tt.isBuffer:void 0,Ar=Et(Object.keys,Object),Gt=Yr(L,"DataView"),zt=Yr(L,"Map"),De=Yr(L,"Promise"),Wt=Yr(L,"Set"),Kt=Yr(L,"WeakMap"),Ae=Yr(Object,"create"),Jt=ln(Gt),Xt=ln(zt),xe=ln(De),Zt=ln(Wt),Yt=ln(Kt),Ce=Rt?Rt.prototype:void 0,Qt=Ce?Ce.valueOf:void 0;function qt(q){var Q=-1,ht=q==null?0:q.length;for(this.clear();++Q<ht;){var St=q[Q];this.set(St[0],St[1])}}function Te(){this.__data__=Ae?Ae(null):{},this.size=0}function te(q){var Q=this.has(q)&&delete this.__data__[q];return this.size-=Q?1:0,Q}function Pe(q){var Q=this.__data__;if(Ae){var ht=Q[q];return ht===i?void 0:ht}return Lt.call(Q,q)?Q[q]:void 0}function xi(q){var Q=this.__data__;return Ae?Q[q]!==void 0:Lt.call(Q,q)}function Oe(q,Q){var ht=this.__data__;return this.size+=this.has(q)?0:1,ht[q]=Ae&&Q===void 0?i:Q,this}qt.prototype.clear=Te,qt.prototype.delete=te,qt.prototype.get=Pe,qt.prototype.has=xi,qt.prototype.set=Oe;function le(q){var Q=-1,ht=q==null?0:q.length;for(this.clear();++Q<ht;){var St=q[Q];this.set(St[0],St[1])}}function oi(){this.__data__=[],this.size=0}function ai(q){var Q=this.__data__,ht=ss(Q,q);if(ht<0)return!1;var St=Q.length-1;return ht==St?Q.pop():pe.call(Q,ht,1),--this.size,!0}function ci(q){var Q=this.__data__,ht=ss(Q,q);return ht<0?void 0:Q[ht][1]}function ui(q){return ss(this.__data__,q)>-1}function hi(q,Q){var ht=this.__data__,St=ss(ht,q);return St<0?(++this.size,ht.push([q,Q])):ht[St][1]=Q,this}le.prototype.clear=oi,le.prototype.delete=ai,le.prototype.get=ci,le.prototype.has=ui,le.prototype.set=hi;function ar(q){var Q=-1,ht=q==null?0:q.length;for(this.clear();++Q<ht;){var St=q[Q];this.set(St[0],St[1])}}function qi(){this.size=0,this.__data__={hash:new qt,map:new(zt||le),string:new qt}}function Xn(q){var Q=Rn(this,q).delete(q);return this.size-=Q?1:0,Q}function ji(q){return Rn(this,q).get(q)}function Zn(q){return Rn(this,q).has(q)}function ts(q,Q){var ht=Rn(this,q),St=ht.size;return ht.set(q,Q),this.size+=ht.size==St?0:1,this}ar.prototype.clear=qi,ar.prototype.delete=Xn,ar.prototype.get=ji,ar.prototype.has=Zn,ar.prototype.set=ts;function $i(q){var Q=-1,ht=q==null?0:q.length;for(this.__data__=new ar;++Q<ht;)this.add(q[Q])}function On(q){return this.__data__.set(q,i),this}function Nn(q){return this.__data__.has(q)}$i.prototype.add=$i.prototype.push=On,$i.prototype.has=Nn;function Sr(q){var Q=this.__data__=new le(q);this.size=Q.size}function es(){this.__data__=new le,this.size=0}function rs(q){var Q=this.__data__,ht=Q.delete(q);return this.size=Q.size,ht}function is(q){return this.__data__.get(q)}function ns(q){return this.__data__.has(q)}function _a(q,Q){var ht=this.__data__;if(ht instanceof le){var St=ht.__data__;if(!zt||St.length<e-1)return St.push([q,Q]),this.size=++ht.size,this;ht=this.__data__=new ar(St)}return ht.set(q,Q),this.size=ht.size,this}Sr.prototype.clear=es,Sr.prototype.delete=rs,Sr.prototype.get=is,Sr.prototype.has=ns,Sr.prototype.set=_a;function Ea(q,Q){var ht=Fs(q),St=!ht&&Ta(q),Be=!ht&&!St&&Ao(q),re=!ht&&!St&&!Be&&Ba(q),$e=ht||St||Be||re,er=$e?Ee(q.length,String):[],we=er.length;for(var Le in q)(Q||Lt.call(q,Le))&&!($e&&(Le=="length"||Be&&(Le=="offset"||Le=="parent")||re&&(Le=="buffer"||Le=="byteLength"||Le=="byteOffset")||Ca(Le,we)))&&er.push(Le);return er}function ss(q,Q){for(var ht=q.length;ht--;)if(Ra(q[ht][0],Q))return ht;return-1}function _o(q,Q,ht){var St=Q(q);return Fs(q)?St:Pt(St,ht(q))}function os(q){return q==null?q===void 0?nt:tt:Ve&&Ve in Object(q)?xa(q):bu(q)}function Eo(q){return cs(q)&&os(q)==l}function as(q,Q,ht,St,Be){return q===Q?!0:q==null||Q==null||!cs(q)&&!cs(Q)?q!==q&&Q!==Q:Aa(q,Q,ht,St,as,Be)}function Aa(q,Q,ht,St,Be,re){var $e=Fs(q),er=Fs(Q),we=$e?m:zi(q),Le=er?m:zi(Q);we=we==l?K:we,Le=Le==l?K:Le;var Qe=we==K,Ur=Le==K,rr=we==Le;if(rr&&Ao(q)){if(!Ao(Q))return!1;$e=!0,Qe=!1}if(rr&&!Qe)return re||(re=new Sr),$e||Ba(q)?Rs(q,Q,ht,St,Be,re):wu(q,Q,we,ht,St,Be,re);if(!(ht&s)){var ze=Qe&&Lt.call(q,"__wrapped__"),Ir=Ur&&Lt.call(Q,"__wrapped__");if(ze||Ir){var Mi=ze?q.value():q,li=Ir?Q.value():Q;return re||(re=new Sr),Be(Mi,li,ht,St,re)}}return rr?(re||(re=new Sr),Da(q,Q,ht,St,Be,re)):!1}function yu(q){if(!Ua(q)||Oa(q))return!1;var Q=Us(q)?se:it;return Q.test(ln(q))}function Sa(q){return cs(q)&&Fa(q.length)&&!!_[os(q)]}function Ia(q){if(!Na(q))return Ar(q);var Q=[];for(var ht in Object(q))Lt.call(q,ht)&&ht!="constructor"&&Q.push(ht);return Q}function Rs(q,Q,ht,St,Be,re){var $e=ht&s,er=q.length,we=Q.length;if(er!=we&&!($e&&we>er))return!1;var Le=re.get(q);if(Le&&re.get(Q))return Le==Q;var Qe=-1,Ur=!0,rr=ht&a?new $i:void 0;for(re.set(q,Q),re.set(Q,q);++Qe<er;){var ze=q[Qe],Ir=Q[Qe];if(St)var Mi=$e?St(Ir,ze,Qe,Q,q,re):St(ze,Ir,Qe,q,Q,re);if(Mi!==void 0){if(Mi)continue;Ur=!1;break}if(rr){if(!It(Q,function(li,ki){if(!xt(rr,ki)&&(ze===li||Be(ze,li,ht,St,re)))return rr.push(ki)})){Ur=!1;break}}else if(!(ze===Ir||Be(ze,Ir,ht,St,re))){Ur=!1;break}}return re.delete(q),re.delete(Q),Ur}function wu(q,Q,ht,St,Be,re,$e){switch(ht){case mt:if(q.byteLength!=Q.byteLength||q.byteOffset!=Q.byteOffset)return!1;q=q.buffer,Q=Q.buffer;case pt:return!(q.byteLength!=Q.byteLength||!re(new Ke(q),new Ke(Q)));case w:case E:case G:return Ra(+q,+Q);case x:return q.name==Q.name&&q.message==Q.message;case z:case v:return q==Q+"";case Y:var er=_t;case $:var we=St&s;if(er||(er=Vt),q.size!=Q.size&&!we)return!1;var Le=$e.get(q);if(Le)return Le==Q;St|=a,$e.set(q,Q);var Qe=Rs(er(q),er(Q),St,Be,re,$e);return $e.delete(q),Qe;case T:if(Qt)return Qt.call(q)==Qt.call(Q)}return!1}function Da(q,Q,ht,St,Be,re){var $e=ht&s,er=Ts(q),we=er.length,Le=Ts(Q),Qe=Le.length;if(we!=Qe&&!$e)return!1;for(var Ur=we;Ur--;){var rr=er[Ur];if(!($e?rr in Q:Lt.call(Q,rr)))return!1}var ze=re.get(q);if(ze&&re.get(Q))return ze==Q;var Ir=!0;re.set(q,Q),re.set(Q,q);for(var Mi=$e;++Ur<we;){rr=er[Ur];var li=q[rr],ki=Q[rr];if(St)var So=$e?St(ki,li,rr,Q,q,re):St(li,ki,rr,q,Q,re);if(!(So===void 0?li===ki||Be(li,ki,ht,St,re):So)){Ir=!1;break}Mi||(Mi=rr=="constructor")}if(Ir&&!Mi){var us=q.constructor,cr=Q.constructor;us!=cr&&"constructor"in q&&"constructor"in Q&&!(typeof us=="function"&&us instanceof us&&typeof cr=="function"&&cr instanceof cr)&&(Ir=!1)}return re.delete(q),re.delete(Q),Ir}function Ts(q){return _o(q,Au,Ma)}function Rn(q,Q){var ht=q.__data__;return Pa(Q)?ht[typeof Q=="string"?"string":"hash"]:ht.map}function Yr(q,Q){var ht=Bt(q,Q);return yu(ht)?ht:void 0}function xa(q){var Q=Lt.call(q,Ve),ht=q[Ve];try{q[Ve]=void 0;var St=!0}catch{}var Be=Nt.call(q);return St&&(Q?q[Ve]=ht:delete q[Ve]),Be}var Ma=ye?function(q){return q==null?[]:(q=Object(q),Mt(ye(q),function(Q){return ce.call(q,Q)}))}:Ue,zi=os;(Gt&&zi(new Gt(new ArrayBuffer(1)))!=mt||zt&&zi(new zt)!=Y||De&&zi(De.resolve())!=V||Wt&&zi(new Wt)!=$||Kt&&zi(new Kt)!=ft)&&(zi=function(q){var Q=os(q),ht=Q==K?q.constructor:void 0,St=ht?ln(ht):"";if(St)switch(St){case Jt:return mt;case Xt:return Y;case xe:return V;case Zt:return $;case Yt:return ft}return Q});function Ca(q,Q){return Q=Q??u,!!Q&&(typeof q=="number"||lt.test(q))&&q>-1&&q%1==0&&q<Q}function Pa(q){var Q=typeof q;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?q!=="__proto__":q===null}function Oa(q){return!!Ot&&Ot in q}function Na(q){var Q=q&&q.constructor,ht=typeof Q=="function"&&Q.prototype||Ut;return q===ht}function bu(q){return Nt.call(q)}function ln(q){if(q!=null){try{return Ct.call(q)}catch{}try{return q+""}catch{}}return""}function Ra(q,Q){return q===Q||q!==q&&Q!==Q}var Ta=Eo(function(){return arguments}())?Eo:function(q){return cs(q)&&Lt.call(q,"callee")&&!ce.call(q,"callee")},Fs=Array.isArray;function _u(q){return q!=null&&Fa(q.length)&&!Us(q)}var Ao=_e||Fe;function Eu(q,Q){return as(q,Q)}function Us(q){if(!Ua(q))return!1;var Q=os(q);return Q==I||Q==N||Q==f||Q==B}function Fa(q){return typeof q=="number"&&q>-1&&q%1==0&&q<=u}function Ua(q){var Q=typeof q;return q!=null&&(Q=="object"||Q=="function")}function cs(q){return q!=null&&typeof q=="object"}var Ba=at?$t(at):Sa;function Au(q){return _u(q)?Ea(q):Ia(q)}function Ue(){return[]}function Fe(){return!1}r.exports=Eu})(ru,ru.exports);var jI=ru.exports;const $I=Tl(jI);function zI(r,t){return t=t||{},new Promise(function(e,i){var s=new XMLHttpRequest,a=[],u=[],l={},m=function(){return{ok:(s.status/100|0)==2,statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:m,headers:{keys:function(){return a},entries:function(){return u},get:function(w){return l[w.toLowerCase()]},has:function(w){return w.toLowerCase()in l}}}};for(var f in s.open(t.method||"get",r,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(w,E,x){a.push(E=E.toLowerCase()),u.push([E,x]),l[E]=l[E]?l[E]+","+x:x}),e(m())},s.onerror=i,s.withCredentials=t.credentials=="include",t.headers)s.setRequestHeader(f,t.headers[f]);s.send(t.body||null)})}const kI=Object.freeze(Object.defineProperty({__proto__:null,default:zI},Symbol.toStringTag,{value:"Module"})),Lp=D1(kI);var HI=self.fetch||(self.fetch=Lp.default||Lp);const KI=Tl(HI);function VI(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),i=0;i<e.length;i++)e[i]=255;for(var s=0;s<r.length;s++){var a=r.charAt(s),u=a.charCodeAt(0);if(e[u]!==255)throw new TypeError(a+" is ambiguous");e[u]=s}var l=r.length,m=r.charAt(0),f=Math.log(l)/Math.log(256),w=Math.log(256)/Math.log(l);function E(N){if(N instanceof Uint8Array||(ArrayBuffer.isView(N)?N=new Uint8Array(N.buffer,N.byteOffset,N.byteLength):Array.isArray(N)&&(N=Uint8Array.from(N))),!(N instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(N.length===0)return"";for(var Y=0,G=0,tt=0,K=N.length;tt!==K&&N[tt]===0;)tt++,Y++;for(var V=(K-tt)*w+1>>>0,B=new Uint8Array(V);tt!==K;){for(var z=N[tt],$=0,v=V-1;(z!==0||$<G)&&v!==-1;v--,$++)z+=256*B[v]>>>0,B[v]=z%l>>>0,z=z/l>>>0;if(z!==0)throw new Error("Non-zero carry");G=$,tt++}for(var T=V-G;T!==V&&B[T]===0;)T++;for(var nt=m.repeat(Y);T<V;++T)nt+=r.charAt(B[T]);return nt}function x(N){if(typeof N!="string")throw new TypeError("Expected String");if(N.length===0)return new Uint8Array;var Y=0;if(N[Y]!==" "){for(var G=0,tt=0;N[Y]===m;)G++,Y++;for(var K=(N.length-Y)*f+1>>>0,V=new Uint8Array(K);N[Y];){var B=e[N.charCodeAt(Y)];if(B===255)return;for(var z=0,$=K-1;(B!==0||z<tt)&&$!==-1;$--,z++)B+=l*V[$]>>>0,V[$]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");tt=z,Y++}if(N[Y]!==" "){for(var v=K-tt;v!==K&&V[v]===0;)v++;for(var T=new Uint8Array(G+(K-v)),nt=G;v!==K;)T[nt++]=V[v++];return T}}}function I(N){var Y=x(N);if(Y)return Y;throw new Error(`Non-${t} character`)}return{encode:E,decodeUnsafe:x,decode:I}}var GI=VI,WI=GI;const rm=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")},YI=r=>new TextEncoder().encode(r),QI=r=>new TextDecoder().decode(r);class JI{constructor(t,e,i){this.name=t,this.prefix=e,this.baseEncode=i}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}let XI=class{constructor(t,e,i){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=i}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return im(this,t)}},ZI=class{constructor(t){this.decoders=t}or(t){return im(this,t)}decode(t){const e=t[0],i=this.decoders[e];if(i)return i.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const im=(r,t)=>new ZI({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});let tD=class{constructor(t,e,i,s){this.name=t,this.prefix=e,this.baseEncode=i,this.baseDecode=s,this.encoder=new JI(t,e,i),this.decoder=new XI(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};const mu=({name:r,prefix:t,encode:e,decode:i})=>new tD(r,t,e,i),ba=({prefix:r,name:t,alphabet:e})=>{const{encode:i,decode:s}=WI(e,t);return mu({prefix:r,name:t,encode:i,decode:a=>rm(s(a))})},eD=(r,t,e,i)=>{const s={};for(let w=0;w<t.length;++w)s[t[w]]=w;let a=r.length;for(;r[a-1]==="=";)--a;const u=new Uint8Array(a*e/8|0);let l=0,m=0,f=0;for(let w=0;w<a;++w){const E=s[r[w]];if(E===void 0)throw new SyntaxError(`Non-${i} character`);m=m<<e|E,l+=e,l>=8&&(l-=8,u[f++]=255&m>>l)}if(l>=e||255&m<<8-l)throw new SyntaxError("Unexpected end of data");return u},rD=(r,t,e)=>{const i=t[t.length-1]==="=",s=(1<<e)-1;let a="",u=0,l=0;for(let m=0;m<r.length;++m)for(l=l<<8|r[m],u+=8;u>e;)u-=e,a+=t[s&l>>u];if(u&&(a+=t[s&l<<e-u]),i)for(;a.length*e&7;)a+="=";return a},yr=({name:r,prefix:t,bitsPerChar:e,alphabet:i})=>mu({prefix:t,name:r,encode(s){return rD(s,i,e)},decode(s){return eD(s,i,e,r)}}),iD=mu({prefix:"\0",name:"identity",encode:r=>QI(r),decode:r=>YI(r)});var nD=Object.freeze({__proto__:null,identity:iD});const sD=yr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oD=Object.freeze({__proto__:null,base2:sD});const aD=yr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var cD=Object.freeze({__proto__:null,base8:aD});const uD=ba({prefix:"9",name:"base10",alphabet:"0123456789"});var hD=Object.freeze({__proto__:null,base10:uD});const lD=yr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fD=yr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var dD=Object.freeze({__proto__:null,base16:lD,base16upper:fD});const pD=yr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gD=yr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mD=yr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vD=yr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yD=yr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wD=yr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bD=yr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_D=yr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ED=yr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var AD=Object.freeze({__proto__:null,base32:pD,base32upper:gD,base32pad:mD,base32padupper:vD,base32hex:yD,base32hexupper:wD,base32hexpad:bD,base32hexpadupper:_D,base32z:ED});const SD=ba({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ID=ba({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var DD=Object.freeze({__proto__:null,base36:SD,base36upper:ID});const xD=ba({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),MD=ba({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var CD=Object.freeze({__proto__:null,base58btc:xD,base58flickr:MD});const PD=yr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),OD=yr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ND=yr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),RD=yr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var TD=Object.freeze({__proto__:null,base64:PD,base64pad:OD,base64url:ND,base64urlpad:RD});const nm=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),FD=nm.reduce((r,t,e)=>(r[e]=t,r),[]),UD=nm.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function BD(r){return r.reduce((t,e)=>(t+=FD[e],t),"")}function LD(r){const t=[];for(const e of r){const i=UD[e.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(i)}return new Uint8Array(t)}const qD=mu({prefix:"🚀",name:"base256emoji",encode:BD,decode:LD});var jD=Object.freeze({__proto__:null,base256emoji:qD}),$D=sm,qp=128,zD=127,kD=~zD,HD=Math.pow(2,31);function sm(r,t,e){t=t||[],e=e||0;for(var i=e;r>=HD;)t[e++]=r&255|qp,r/=128;for(;r&kD;)t[e++]=r&255|qp,r>>>=7;return t[e]=r|0,sm.bytes=e-i+1,t}var KD=Ml,VD=128,jp=127;function Ml(r,i){var e=0,i=i||0,s=0,a=i,u,l=r.length;do{if(a>=l)throw Ml.bytes=0,new RangeError("Could not decode varint");u=r[a++],e+=s<28?(u&jp)<<s:(u&jp)*Math.pow(2,s),s+=7}while(u>=VD);return Ml.bytes=a-i,e}var GD=Math.pow(2,7),WD=Math.pow(2,14),YD=Math.pow(2,21),QD=Math.pow(2,28),JD=Math.pow(2,35),XD=Math.pow(2,42),ZD=Math.pow(2,49),tx=Math.pow(2,56),ex=Math.pow(2,63),rx=function(r){return r<GD?1:r<WD?2:r<YD?3:r<QD?4:r<JD?5:r<XD?6:r<ZD?7:r<tx?8:r<ex?9:10},ix={encode:$D,decode:KD,encodingLength:rx},om=ix;const $p=(r,t,e=0)=>(om.encode(r,t,e),t),zp=r=>om.encodingLength(r),Cl=(r,t)=>{const e=t.byteLength,i=zp(r),s=i+zp(e),a=new Uint8Array(s+e);return $p(r,a,0),$p(e,a,i),a.set(t,s),new nx(r,e,t,a)};class nx{constructor(t,e,i,s){this.code=t,this.size=e,this.digest=i,this.bytes=s}}const am=({name:r,code:t,encode:e})=>new sx(r,t,e);class sx{constructor(t,e,i){this.name=t,this.code=e,this.encode=i}digest(t){if(t instanceof Uint8Array){const e=this.encode(t);return e instanceof Uint8Array?Cl(this.code,e):e.then(i=>Cl(this.code,i))}else throw Error("Unknown type, must be binary type")}}const cm=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),ox=am({name:"sha2-256",code:18,encode:cm("SHA-256")}),ax=am({name:"sha2-512",code:19,encode:cm("SHA-512")});var cx=Object.freeze({__proto__:null,sha256:ox,sha512:ax});const um=0,ux="identity",hm=rm,hx=r=>Cl(um,hm(r)),lx={code:um,name:ux,encode:hm,digest:hx};var fx=Object.freeze({__proto__:null,identity:lx});new TextEncoder,new TextDecoder;const kp={...nD,...oD,...cD,...hD,...dD,...AD,...DD,...CD,...TD,...jD};({...cx,...fx});function dx(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function lm(r,t,e,i){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:i}}}const Hp=lm("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Zh=lm("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);const t=dx(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),px={utf8:Hp,"utf-8":Hp,hex:kp.base16,latin1:Zh,ascii:Zh,binary:Zh,...kp};function gx(r,t="utf8"){const e=px[t];if(!e)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):e.decoder.decode(`${e.prefix}${r}`)}const fm="wc",mx=2,rf="core",Wn=`${fm}@2:${rf}:`,vx={name:rf,logger:"error"},yx={database:":memory:"},wx="crypto",Kp="client_ed25519_seed",bx=yt.ONE_DAY,_x="keychain",Ex="0.3",Ax="messages",Sx="0.3",Ix=yt.SIX_HOURS,Dx="publisher",dm="irn",xx="error",pm="wss://relay.walletconnect.com",Vp="wss://relay.walletconnect.org",Mx="relayer",Hr={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"},Cx="_subscription",_i={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Px=yt.ONE_SECOND,Ox="2.13.3",Nx=1e4,Rx="0.3",Tx="WALLETCONNECT_CLIENT_ID",Xi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Fx="subscription",Ux="0.3",Bx=yt.FIVE_SECONDS*1e3,Lx="pairing",qx="0.3",Vo={wc_pairingDelete:{req:{ttl:yt.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:yt.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:yt.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:yt.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:yt.ONE_DAY,prompt:!1,tag:0},res:{ttl:yt.ONE_DAY,prompt:!1,tag:0}}},io={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Ti={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},jx="history",$x="0.3",zx="expirer",Ei={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},kx="0.3",tl="verify-api",no="https://verify.walletconnect.com",Pl="https://verify.walletconnect.org",Hx=[no,Pl],Kx="echo",Vx="https://echo.walletconnect.com";class Gx{constructor(t,e){this.core=t,this.logger=e,this.keychain=new Map,this.name=_x,this.version=Ex,this.initialized=!1,this.storagePrefix=Wn,this.init=async()=>{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,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist()},this.get=i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:a}=gt("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(a)}return s},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=t,this.logger=Wr(e,this.name)}get context(){return Gr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,W1(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Y1(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Wx{constructor(t,e,i){this.core=t,this.logger=e,this.name=wx,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=s=>(this.isInitialized(),this.keychain.has(s)),this.getClientId=async()=>{this.isInitialized();const s=await this.getClientSeed(),a=Cp(s);return Yg(a.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const s=q8();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();const a=await this.getClientSeed(),u=Cp(a),l=Sl();return await vI(l,s,bx,u)},this.generateSharedKey=(s,a,u)=>{this.isInitialized();const l=this.getPrivateKey(s),m=j8(l,a);return this.setSymKey(m,u)},this.setSymKey=async(s,a)=>{this.isInitialized();const u=a||jc(s);return await this.keychain.set(u,s),u},this.deleteKeyPair=async s=>{this.isInitialized(),await this.keychain.del(s)},this.deleteSymKey=async s=>{this.isInitialized(),await this.keychain.del(s)},this.encode=async(s,a,u)=>{this.isInitialized();const l=Bg(u),m=Mn(a);if(cp(l)){const x=l.senderPublicKey,I=l.receiverPublicKey;s=await this.generateSharedKey(x,I)}const f=this.getSymKey(s),{type:w,senderPublicKey:E}=l;return z8({type:w,symKey:f,message:m,senderPublicKey:E})},this.decode=async(s,a,u)=>{this.isInitialized();const l=K8(a,u);if(cp(l)){const m=l.receiverPublicKey,f=l.senderPublicKey;s=await this.generateSharedKey(m,f)}try{const m=this.getSymKey(s),f=k8({symKey:m,encoded:a});return ma(f)}catch(m){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(m)}},this.getPayloadType=s=>{const a=Jc(s);return pa(a.type)},this.getPayloadSenderPublicKey=s=>{const a=Jc(s);return a.senderPublicKey?Tr(a.senderPublicKey,Rr):void 0},this.core=t,this.logger=Wr(e,this.name),this.keychain=i||new Gx(this.core,this.logger)}get context(){return Gr(this.logger)}async setPrivateKey(t,e){return await this.keychain.set(t,e),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(Kp)}catch{t=Sl(),await this.keychain.set(Kp,t)}return gx(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Yx extends WS{constructor(t,e){super(t,e),this.logger=t,this.core=e,this.messages=new Map,this.name=Ax,this.version=Sx,this.initialized=!1,this.storagePrefix=Wn,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,s)=>{this.isInitialized();const a=As(s);let u=this.messages.get(i);return typeof u>"u"&&(u={}),typeof u[a]<"u"||(u[a]=s,this.messages.set(i,u),await this.persist()),a},this.get=i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s},this.has=(i,s)=>{this.isInitialized();const a=this.get(i),u=As(s);return typeof a[u]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Wr(t,this.name),this.core=e}get context(){return Gr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,W1(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Y1(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Qx extends YS{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.events=new Di.EventEmitter,this.name=Dx,this.queue=new Map,this.publishTimeout=yt.toMiliseconds(yt.ONE_MINUTE),this.failedPublishTimeout=yt.toMiliseconds(yt.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,s,a)=>{var u;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:a}});const l=(a==null?void 0:a.ttl)||Ix,m=Il(a),f=(a==null?void 0:a.prompt)||!1,w=(a==null?void 0:a.tag)||0,E=(a==null?void 0:a.id)||Ss().toString(),x={topic:i,message:s,opts:{ttl:l,relay:m,prompt:f,tag:w,id:E}},I=`Failed to publish payload, please try again. id:${E} tag:${w}`,N=Date.now();let Y,G=1;try{for(;Y===void 0;){if(Date.now()-N>this.publishTimeout)throw new Error(I);this.logger.trace({id:E,attempts:G},`publisher.publish - attempt ${G}`),Y=await await so(this.rpcPublish(i,s,l,m,f,w,E).catch(tt=>this.logger.warn(tt)),this.publishTimeout,I),G++,Y||await new Promise(tt=>setTimeout(tt,this.failedPublishTimeout))}this.relayer.events.emit(Hr.publish,x),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:E,topic:i,message:s,opts:a}})}catch(tt){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(tt),(u=a==null?void 0:a.internal)!=null&&u.throwOnFailedPublish)throw tt;this.queue.set(E,x)}},this.on=(i,s)=>{this.events.on(i,s)},this.once=(i,s)=>{this.events.once(i,s)},this.off=(i,s)=>{this.events.off(i,s)},this.removeListener=(i,s)=>{this.events.removeListener(i,s)},this.relayer=t,this.logger=Wr(e,this.name),this.registerEventListeners()}get context(){return Gr(this.logger)}rpcPublish(t,e,i,s,a,u,l){var m,f,w,E;const x={method:Qo(s.protocol).publish,params:{topic:t,message:e,ttl:i,prompt:a,tag:u},id:l};return Nr((m=x.params)==null?void 0:m.prompt)&&((f=x.params)==null||delete f.prompt),Nr((w=x.params)==null?void 0:w.tag)&&((E=x.params)==null||delete E.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:x}),this.relayer.request(x)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{const{topic:e,message:i,opts:s}=t;await this.publish(e,i,s)})}registerEventListeners(){this.relayer.core.heartbeat.on(va.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Hr.connection_stalled);return}this.checkQueue()}),this.relayer.on(Hr.message_ack,t=>{this.removeRequestFromQueue(t.id.toString())})}}class Jx{constructor(){this.map=new Map,this.set=(t,e)=>{const i=this.get(t);this.exists(t,e)||this.map.set(t,[...i,e])},this.get=t=>this.map.get(t)||[],this.exists=(t,e)=>this.get(t).includes(e),this.delete=(t,e)=>{if(typeof e>"u"){this.map.delete(t);return}if(!this.map.has(t))return;const i=this.get(t);if(!this.exists(t,e))return;const s=i.filter(a=>a!==e);if(!s.length){this.map.delete(t);return}this.map.set(t,s)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Xx=Object.defineProperty,Zx=Object.defineProperties,t7=Object.getOwnPropertyDescriptors,Gp=Object.getOwnPropertySymbols,e7=Object.prototype.hasOwnProperty,r7=Object.prototype.propertyIsEnumerable,Wp=(r,t,e)=>t in r?Xx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Go=(r,t)=>{for(var e in t||(t={}))e7.call(t,e)&&Wp(r,e,t[e]);if(Gp)for(var e of Gp(t))r7.call(t,e)&&Wp(r,e,t[e]);return r},el=(r,t)=>Zx(r,t7(t));class i7 extends XS{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.subscriptions=new Map,this.topicMap=new Jx,this.events=new Di.EventEmitter,this.name=Fx,this.version=Ux,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Wn,this.subscribeTimeout=yt.toMiliseconds(yt.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())},this.subscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const a=Il(s),u={topic:i,relay:a};this.pending.set(i,u);const l=await this.rpcSubscribe(i,a);return typeof l=="string"&&(this.onSubscribe(l,u),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}})),l}catch(a){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(a),a}},this.unsubscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),typeof(s==null?void 0:s.id)<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const s=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((a,u)=>{const l=new yt.Watch;l.start(s);const m=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(m),l.stop(s),a(!0)),l.elapsed(s)>=Bx&&(clearInterval(m),l.stop(s),u(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,s)=>{this.events.on(i,s)},this.once=(i,s)=>{this.events.once(i,s)},this.off=(i,s)=>{this.events.off(i,s)},this.removeListener=(i,s)=>{this.events.removeListener(i,s)},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=t,this.logger=Wr(e,this.name),this.clientId=""}get context(){return Gr(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(t,e){let i=!1;try{i=this.getSubscription(t).topic===e}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,e){const i=this.topicMap.get(t);await Promise.all(i.map(async s=>await this.unsubscribeById(t,s,e)))}async unsubscribeById(t,e,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:i}});try{const s=Il(i);await this.rpcUnsubscribe(t,e,s);const a=Re("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,e,a),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:i}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(t,e){const i={method:Qo(e.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await so(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)?As(t+this.clientId):null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Hr.connection_stalled)}return null}async rpcBatchSubscribe(t){if(!t.length)return;const e=t[0].relay,i={method:Qo(e.protocol).batchSubscribe,params:{topics:t.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await so(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Hr.connection_stalled)}}async rpcBatchFetchMessages(t){if(!t.length)return;const e=t[0].relay,i={method:Qo(e.protocol).batchFetchMessages,params:{topics:t.map(a=>a.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let s;try{s=await await so(this.relayer.request(i).catch(a=>this.logger.warn(a)),this.subscribeTimeout)}catch{this.relayer.events.emit(Hr.connection_stalled)}return s}rpcUnsubscribe(t,e,i){const s={method:Qo(i.protocol).unsubscribe,params:{topic:t,id:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(t,e){this.setSubscription(t,el(Go({},e),{id:t})),this.pending.delete(e.topic)}onBatchSubscribe(t){t.length&&t.forEach(e=>{this.setSubscription(e.id,Go({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(t,e,i){this.events.removeAllListeners(e),this.hasSubscription(e,t)&&this.deleteSubscription(e,i),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,e){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:e}),this.addSubscription(t,e)}addSubscription(t,e){this.subscriptions.set(t,Go({},e)),this.topicMap.set(e.topic,t),this.events.emit(Xi.created,e)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const e=this.subscriptions.get(t);if(!e){const{message:i}=gt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(i)}return e}deleteSubscription(t,e){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:e});const i=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(i.topic,t),this.events.emit(Xi.deleted,el(Go({},i),{reason:e}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Xi.sync)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let e=0;e<t;e++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(i),await this.batchSubscribe(i)}}this.events.emit(Xi.resubscribed)}async restore(){try{const t=await this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){const{message:e}=gt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const e=await this.rpcBatchSubscribe(t);un(e)&&this.onBatchSubscribe(e.map((i,s)=>el(Go({},t[s]),{id:i})))}async batchFetchMessages(t){if(!t.length)return;this.logger.trace(`Fetching batch messages for ${t.length} subscriptions`);const e=await this.rpcBatchFetchMessages(t);e&&e.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(e.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const t=[];this.pending.forEach(e=>{t.push(e)}),await this.batchSubscribe(t),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(va.pulse,async()=>{await this.checkPending()}),this.events.on(Xi.created,async t=>{const e=Xi.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()}),this.events.on(Xi.deleted,async t=>{const e=Xi.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{const e=setInterval(()=>{this.restartInProgress||(clearInterval(e),t())},this.pollingInterval)})}}var n7=Object.defineProperty,Yp=Object.getOwnPropertySymbols,s7=Object.prototype.hasOwnProperty,o7=Object.prototype.propertyIsEnumerable,Qp=(r,t,e)=>t in r?n7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,a7=(r,t)=>{for(var e in t||(t={}))s7.call(t,e)&&Qp(r,e,t[e]);if(Yp)for(var e of Yp(t))o7.call(t,e)&&Qp(r,e,t[e]);return r};class c7 extends QS{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new Di.EventEmitter,this.name=Mx,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=yt.toMiliseconds(yt.THIRTY_SECONDS+yt.ONE_SECOND),this.request=async e=>{var i,s;this.logger.debug("Publishing Request Payload");const a=e.id||Ss().toString();await this.toEstablishConnection();try{const u=this.provider.request(e);this.requestsInFlight.set(a,{promise:u,request:e}),this.logger.trace({id:a,method:e.method,topic:(i=e.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const l=await new Promise(async(m,f)=>{const w=()=>{f(new Error(`relayer.request - publish interrupted, id: ${a}`))};this.provider.on(_i.disconnect,w);const E=await u;this.provider.off(_i.disconnect,w),m(E)});return this.logger.trace({id:a,method:e.method,topic:(s=e.params)==null?void 0:s.topic},"relayer.request - published"),l}catch(u){throw this.logger.debug(`Failed to Publish Request: ${a}`),u}finally{this.requestsInFlight.delete(a)}},this.resetPingTimeout=()=>{if(ra())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,i,s;(s=(i=(e=this.provider)==null?void 0:e.connection)==null?void 0:i.socket)==null||s.terminate()},this.heartBeatTimeout)}catch(e){this.logger.warn(e)}},this.onPayloadHandler=e=>{this.onProviderPayload(e),this.resetPingTimeout()},this.onConnectHandler=()=>{this.startPingTimeout(),this.events.emit(Hr.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=e=>{this.logger.error(e),this.events.emit(Hr.error,e),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(_i.payload,this.onPayloadHandler),this.provider.on(_i.connect,this.onConnectHandler),this.provider.on(_i.disconnect,this.onDisconnectHandler),this.provider.on(_i.error,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?Wr(t.logger,this.name):ya(fu({level:t.logger||xx})),this.messages=new Yx(this.logger,t.core),this.subscriber=new i7(this,this.logger),this.publisher=new Qx(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||pm,this.projectId=t.projectId,this.bundleId=PE(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${Vp}...`),await this.restartTransport(Vp)}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&this.subscriber.pending.size===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},Nx)}get context(){return Gr(this.logger)}get connected(){var t,e,i;return((i=(e=(t=this.provider)==null?void 0:t.connection)==null?void 0:e.socket)==null?void 0:i.readyState)===1}get connecting(){var t,e,i;return((i=(e=(t=this.provider)==null?void 0:t.connection)==null?void 0:e.socket)==null?void 0:i.readyState)===0}async publish(t,e,i){this.isInitialized(),await this.publisher.publish(t,e,i),await this.recordMessageEvent({topic:t,message:e,publishedAt:Date.now()})}async subscribe(t,e){var i;this.isInitialized();let s=((i=this.subscriber.topicMap.get(t))==null?void 0:i[0])||"",a;const u=l=>{l.topic===t&&(this.subscriber.off(Xi.created,u),a())};return await Promise.all([new Promise(l=>{a=l,this.subscriber.on(Xi.created,u)}),new Promise(async l=>{s=await this.subscriber.subscribe(t,e)||s,l()})]),s}async unsubscribe(t,e){this.isInitialized(),await this.subscriber.unsubscribe(t,e)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(t=>t.promise))}catch(t){this.logger.warn(t)}this.hasExperiencedNetworkDisruption||this.connected?await so(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(t){await this.confirmOnlineStateOrThrow(),t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(e,i)=>{const s=()=>{this.provider.off(_i.disconnect,s),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(_i.disconnect,s),await so(this.provider.connect(),yt.toMiliseconds(yt.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(a=>{i(a)}),await this.subscriber.start(),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){this.logger.error(e);const i=e;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw e}finally{this.connectionAttemptInProgress=!1}}async restartTransport(t){this.connectionAttemptInProgress||(this.relayUrl=t||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await yp())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(t){if((t==null?void 0:t.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const e=t.sort((i,s)=>i.publishedAt-s.publishedAt);this.logger.trace(`Batch of ${e.length} message events sorted`);for(const i of e)try{await this.onMessageEvent(i)}catch(s){this.logger.warn(s)}this.logger.trace(`Batch of ${e.length} message events processed`)}startPingTimeout(){var t,e,i,s,a;if(ra())try{(e=(t=this.provider)==null?void 0:t.connection)!=null&&e.socket&&((a=(s=(i=this.provider)==null?void 0:i.connection)==null?void 0:s.socket)==null||a.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(u){this.logger.warn(u)}}isConnectionStalled(t){return this.staleConnectionErrors.some(e=>t.includes(e))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Cn(new qI(UE({sdkVersion:Ox,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:e,message:i}=t;await this.messages.set(e,i)}async shouldIgnoreMessageEvent(t){const{topic:e,message:i}=t;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(e))return this.logger.debug(`Ignoring message for non-subscribed topic ${e}`),!0;const s=this.messages.has(e,i);return s&&this.logger.debug(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),ef(t)){if(!t.method.endsWith(Cx))return;const e=t.params,{topic:i,message:s,publishedAt:a}=e.data,u={topic:i,message:s,publishedAt:a};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(a7({type:"event",event:e.id},u)),this.events.emit(e.id,u),await this.acknowledgePayload(t),await this.onMessageEvent(u)}else gu(t)&&this.events.emit(Hr.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(Hr.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const e=du(t.id,!0);await this.provider.connection.send(e)}unregisterProviderListeners(){this.provider.off(_i.payload,this.onPayloadHandler),this.provider.off(_i.connect,this.onConnectHandler),this.provider.off(_i.disconnect,this.onDisconnectHandler),this.provider.off(_i.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let t=await yp();F4(async e=>{t!==e&&(t=e,e?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(Hr.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&setTimeout(async()=>{await this.transportOpen().catch(t=>this.logger.error(t))},yt.toMiliseconds(Px))}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(t=>{const e=setInterval(()=>{this.connected&&(clearInterval(e),t())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var u7=Object.defineProperty,Jp=Object.getOwnPropertySymbols,h7=Object.prototype.hasOwnProperty,l7=Object.prototype.propertyIsEnumerable,Xp=(r,t,e)=>t in r?u7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zp=(r,t)=>{for(var e in t||(t={}))h7.call(t,e)&&Xp(r,e,t[e]);if(Jp)for(var e of Jp(t))l7.call(t,e)&&Xp(r,e,t[e]);return r};class Os extends JS{constructor(t,e,i,s=Wn,a=void 0){super(t,e,i,s),this.core=t,this.logger=e,this.name=i,this.map=new Map,this.version=Rx,this.cached=[],this.initialized=!1,this.storagePrefix=Wn,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(u=>{this.getKey&&u!==null&&!Nr(u)?this.map.set(this.getKey(u),u):f4(u)?this.map.set(u.id,u):d4(u)&&this.map.set(u.topic,u)}),this.cached=[],this.initialized=!0)},this.set=async(u,l)=>{this.isInitialized(),this.map.has(u)?await this.update(u,l):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:u,value:l}),this.map.set(u,l),await this.persist())},this.get=u=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:u}),this.getData(u)),this.getAll=u=>(this.isInitialized(),u?this.values.filter(l=>Object.keys(u).every(m=>$I(l[m],u[m]))):this.values),this.update=async(u,l)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:u,update:l});const m=Zp(Zp({},this.getData(u)),l);this.map.set(u,m),await this.persist()},this.delete=async(u,l)=>{this.isInitialized(),this.map.has(u)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:u,reason:l}),this.map.delete(u),this.addToRecentlyDeleted(u),await this.persist())},this.logger=Wr(e,this.name),this.storagePrefix=s,this.getKey=a}get context(){return Gr(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(t){this.recentlyDeleted.push(t),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const e=this.map.get(t);if(!e){if(this.recentlyDeleted.includes(t)){const{message:s}=gt("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}const{message:i}=gt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(i),new Error(i)}return e}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:e}=gt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class f7{constructor(t,e){this.core=t,this.logger=e,this.name=Lx,this.version=qx,this.events=new Fl,this.initialized=!1,this.storagePrefix=Wn,this.ignoredPayloadTypes=[xn],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 s=Sl(),a=await this.core.crypto.setSymKey(s),u=gr(yt.FIVE_MINUTES),l={protocol:dm},m={topic:a,expiry:u,relay:l,active:!1},f=r4({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:s,relay:l,expiryTimestamp:u,methods:i==null?void 0:i.methods});return this.core.expirer.set(a,u),await this.pairings.set(a,m),await this.core.relayer.subscribe(a),{topic:a,uri:f}},this.pair=async i=>{this.isInitialized(),this.isValidPair(i);const{topic:s,symKey:a,relay:u,expiryTimestamp:l,methods:m}=fp(i.uri);let f;if(this.pairings.keys.includes(s)&&(f=this.pairings.get(s),f.active))throw new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);const w=l||gr(yt.FIVE_MINUTES),E={topic:s,relay:u,expiry:w,active:!1,methods:m};return this.core.expirer.set(s,w),await this.pairings.set(s,E),i.activatePairing&&await this.activate({topic:s}),this.events.emit(io.create,E),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(a,s),await this.core.relayer.subscribe(s,{relay:u}),E},this.activate=async({topic:i})=>{this.isInitialized();const s=gr(yt.THIRTY_DAYS);this.core.expirer.set(i,s),await this.pairings.update(i,{active:!0,expiry:s})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:s}=i;if(this.pairings.keys.includes(s)){const a=await this.sendRequest(s,"wc_pairingPing",{}),{done:u,resolve:l,reject:m}=_s();this.events.once(de("pairing_ping",a),({error:f})=>{f?m(f):l()}),await u()}},this.updateExpiry=async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s})},this.updateMetadata=async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",Re("USER_DISCONNECTED")),await this.deletePairing(s))},this.sendRequest=async(i,s,a)=>{const u=co(s,a),l=await this.core.crypto.encode(i,u),m=Vo[s].req;return this.core.history.set(i,u),this.core.relayer.publish(i,l,m),u.id},this.sendResult=async(i,s,a)=>{const u=du(i,a),l=await this.core.crypto.encode(s,u),m=await this.core.history.get(s,i),f=Vo[m.request.method].res;await this.core.relayer.publish(s,l,f),await this.core.history.resolve(u)},this.sendError=async(i,s,a)=>{const u=pu(i,a),l=await this.core.crypto.encode(s,u),m=await this.core.history.get(s,i),f=Vo[m.request.method]?Vo[m.request.method].res:Vo.unregistered_method.res;await this.core.relayer.publish(s,l,f),await this.core.history.resolve(u)},this.deletePairing=async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Re("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(s=>Hn(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)))},this.onRelayEventRequest=i=>{const{topic:s,payload:a}=i;switch(a.method){case"wc_pairingPing":return this.onPairingPingRequest(s,a);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,a);default:return this.onUnknownRpcMethodRequest(s,a)}},this.onRelayEventResponse=async i=>{const{topic:s,payload:a}=i,u=(await this.core.history.get(s,a.id)).request.method;switch(u){case"wc_pairingPing":return this.onPairingPingResponse(s,a);default:return this.onUnknownRpcMethodResponse(u)}},this.onPairingPingRequest=async(i,s)=>{const{id:a}=s;try{this.isValidPing({topic:i}),await this.sendResult(a,i,!0),this.events.emit(io.ping,{id:a,topic:i})}catch(u){await this.sendError(a,i,u),this.logger.error(u)}},this.onPairingPingResponse=(i,s)=>{const{id:a}=s;setTimeout(()=>{Ji(s)?this.events.emit(de("pairing_ping",a),{}):Si(s)&&this.events.emit(de("pairing_ping",a),{error:s.error})},500)},this.onPairingDeleteRequest=async(i,s)=>{const{id:a}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(io.delete,{id:a,topic:i})}catch(u){await this.sendError(a,i,u),this.logger.error(u)}},this.onUnknownRpcMethodRequest=async(i,s)=>{const{id:a,method:u}=s;try{if(this.registeredMethods.includes(u))return;const l=Re("WC_METHOD_UNSUPPORTED",u);await this.sendError(a,i,l),this.logger.error(l)}catch(l){await this.sendError(a,i,l),this.logger.error(l)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Re("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=i=>{var s;if(!kr(i)){const{message:u}=gt("MISSING_OR_INVALID",`pair() params: ${i}`);throw new Error(u)}if(!l4(i.uri)){const{message:u}=gt("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw new Error(u)}const a=fp(i.uri);if(!((s=a==null?void 0:a.relay)!=null&&s.protocol)){const{message:u}=gt("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(u)}if(!(a!=null&&a.symKey)){const{message:u}=gt("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(u)}if(a!=null&&a.expiryTimestamp&&yt.toMiliseconds(a==null?void 0:a.expiryTimestamp)<Date.now()){const{message:u}=gt("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(u)}},this.isValidPing=async i=>{if(!kr(i)){const{message:a}=gt("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(a)}const{topic:s}=i;await this.isValidPairingTopic(s)},this.isValidDisconnect=async i=>{if(!kr(i)){const{message:a}=gt("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(a)}const{topic:s}=i;await this.isValidPairingTopic(s)},this.isValidPairingTopic=async i=>{if(!tr(i,!1)){const{message:s}=gt("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=gt("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(Hn(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=gt("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}},this.core=t,this.logger=Wr(e,this.name),this.pairings=new Os(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Gr(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(Hr.message,async t=>{const{topic:e,message:i}=t;if(!this.pairings.keys.includes(e)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(e,i);try{ef(s)?(this.core.history.set(e,s),this.onRelayEventRequest({topic:e,payload:s})):gu(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:e,payload:s}),this.core.history.delete(e,s.id))}catch(a){this.logger.error(a)}})}registerExpirerEvents(){this.core.expirer.on(Ei.expired,async t=>{const{topic:e}=J1(t.target);e&&this.pairings.keys.includes(e)&&(await this.deletePairing(e,!0),this.events.emit(io.expire,{topic:e}))})}}class d7 extends GS{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.records=new Map,this.events=new Di.EventEmitter,this.name=jx,this.version=$x,this.cached=[],this.initialized=!1,this.storagePrefix=Wn,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,s,a)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:a}),this.records.has(s.id))return;const u={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:a,expiry:gr(yt.THIRTY_DAYS)};this.records.set(u.id,u),this.persist(),this.events.emit(Ti.created,u)},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 s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=Si(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.persist(),this.events.emit(Ti.updated,s))},this.get=async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s)),this.delete=(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(a=>{if(a.topic===i){if(typeof s<"u"&&a.id!==s)return;this.records.delete(a.id),this.events.emit(Ti.deleted,a)}}),this.persist()},this.exists=async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:!1),this.on=(i,s)=>{this.events.on(i,s)},this.once=(i,s)=>{this.events.once(i,s)},this.off=(i,s)=>{this.events.off(i,s)},this.removeListener=(i,s)=>{this.events.removeListener(i,s)},this.logger=Wr(e,this.name)}get context(){return Gr(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 t=[];return this.values.forEach(e=>{if(typeof e.response<"u")return;const i={topic:e.topic,request:co(e.request.method,e.request.params,e.id),chainId:e.chainId};return t.push(i)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const e=this.records.get(t);if(!e){const{message:i}=gt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(i)}return e}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Ti.sync)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:e}=gt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(Ti.created,t=>{const e=Ti.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.events.on(Ti.updated,t=>{const e=Ti.updated;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.events.on(Ti.deleted,t=>{const e=Ti.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.core.heartbeat.on(va.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let t=!1;this.records.forEach(e=>{yt.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.records.delete(e.id),this.events.emit(Ti.deleted,e,!1),t=!0)}),t&&this.persist()}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class p7 extends ZS{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.expirations=new Map,this.events=new Di.EventEmitter,this.name=zx,this.version=kx,this.cached=[],this.initialized=!1,this.storagePrefix=Wn,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 s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return!1}},this.set=(i,s)=>{this.isInitialized();const a=this.formatTarget(i),u={target:a,expiry:s};this.expirations.set(a,u),this.checkExpiry(a,u),this.events.emit(Ei.created,{target:a,expiration:u})},this.get=i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)},this.del=i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),a=this.getExpiration(s);this.expirations.delete(s),this.events.emit(Ei.deleted,{target:s,expiration:a})}},this.on=(i,s)=>{this.events.on(i,s)},this.once=(i,s)=>{this.events.once(i,s)},this.off=(i,s)=>{this.events.off(i,s)},this.removeListener=(i,s)=>{this.events.removeListener(i,s)},this.logger=Wr(e,this.name)}get context(){return Gr(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(t){if(typeof t=="string")return BE(t);if(typeof t=="number")return LE(t);const{message:e}=gt("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(e)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Ei.sync)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:e}=gt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const e=this.expirations.get(t);if(!e){const{message:i}=gt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.warn(i),new Error(i)}return e}checkExpiry(t,e){const{expiry:i}=e;yt.toMiliseconds(i)-Date.now()<=0&&this.expire(t,e)}expire(t,e){this.expirations.delete(t),this.events.emit(Ei.expired,{target:t,expiration:e})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,e)=>this.checkExpiry(e,t))}registerEventListeners(){this.core.heartbeat.on(va.pulse,()=>this.checkExpirations()),this.events.on(Ei.created,t=>{const e=Ei.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(Ei.expired,t=>{const e=Ei.expired;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(Ei.deleted,t=>{const e=Ei.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class g7 extends tI{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.name=tl,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async i=>{if(this.verifyDisabled||po()||!go())return;const s=this.getVerifyUrl(i==null?void 0:i.verifyUrl);this.verifyUrl!==s&&this.removeIframe(),this.verifyUrl=s;try{await this.createIframe()}catch(a){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(a)}if(!this.initialized){this.removeIframe(),this.verifyUrl=Pl;try{await this.createIframe()}catch(a){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(a),this.verifyDisabled=!0}}},this.register=async i=>{this.initialized?this.sendPost(i.attestationId):(this.addToQueue(i.attestationId),await this.init())},this.resolve=async i=>{if(this.isDevEnv)return"";const s=this.getVerifyUrl(i==null?void 0:i.verifyUrl);let a;try{a=await this.fetchAttestation(i.attestationId,s)}catch(u){this.logger.info(`failed to resolve attestation: ${i.attestationId} from url: ${s}`),this.logger.info(u),a=await this.fetchAttestation(i.attestationId,Pl)}return a},this.fetchAttestation=async(i,s)=>{this.logger.info(`resolving attestation: ${i} from url: ${s}`);const a=this.startAbortTimer(yt.ONE_SECOND*2),u=await fetch(`${s}/attestation/${i}`,{signal:this.abortController.signal});return clearTimeout(a),u.status===200?await u.json():void 0},this.addToQueue=i=>{this.queue.push(i)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(i=>this.sendPost(i)),this.queue=[])},this.sendPost=i=>{var s;try{if(!this.iframe)return;(s=this.iframe.contentWindow)==null||s.postMessage(i,"*"),this.logger.info(`postMessage sent: ${i} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let i;const s=a=>{a.data==="verify_ready"&&(this.onInit(),window.removeEventListener("message",s),i())};await Promise.race([new Promise(a=>{const u=document.getElementById(tl);if(u)return this.iframe=u,this.onInit(),a();window.addEventListener("message",s);const l=document.createElement("iframe");l.id=tl,l.src=`${this.verifyUrl}/${this.projectId}`,l.style.display="none",document.body.append(l),this.iframe=l,i=a}),new Promise((a,u)=>setTimeout(()=>{window.removeEventListener("message",s),u("verify iframe load timeout")},yt.toMiliseconds(yt.FIVE_SECONDS)))])},this.onInit=()=>{this.initialized=!0,this.processQueue()},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=i=>{let s=i||no;return Hx.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${no}`),s=no),s},this.logger=Wr(e,this.name),this.verifyUrl=no,this.abortController=new AbortController,this.isDevEnv=ra()&&{}.IS_VITEST}get context(){return Gr(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),yt.toMiliseconds(t))}}let m7=class extends eI{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.context=Kx,this.registerDeviceToken=async i=>{const{clientId:s,token:a,notificationType:u,enableEncrypted:l=!1}=i,m=`${Vx}/${this.projectId}/clients`;await KI(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:u,token:a,always_raw:l})})},this.logger=Wr(e,this.context)}};var v7=Object.defineProperty,t1=Object.getOwnPropertySymbols,y7=Object.prototype.hasOwnProperty,w7=Object.prototype.propertyIsEnumerable,e1=(r,t,e)=>t in r?v7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,r1=(r,t)=>{for(var e in t||(t={}))y7.call(t,e)&&e1(r,e,t[e]);if(t1)for(var e of t1(t))w7.call(t,e)&&e1(r,e,t[e]);return r};let b7=class gm extends VS{constructor(t){var e;super(t),this.protocol=fm,this.version=mx,this.name=rf,this.events=new Di.EventEmitter,this.initialized=!1,this.on=(u,l)=>this.events.on(u,l),this.once=(u,l)=>this.events.once(u,l),this.off=(u,l)=>this.events.off(u,l),this.removeListener=(u,l)=>this.events.removeListener(u,l),this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||pm,this.customStoragePrefix=t!=null&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";const i=fu({level:typeof(t==null?void 0:t.logger)=="string"&&t.logger?t.logger:vx.logger}),{logger:s,chunkLoggerController:a}=KS({opts:i,maxSizeInBytes:t==null?void 0:t.maxLogBlobSizeInBytes,loggerOverride:t==null?void 0:t.logger});this.logChunkController=a,(e=this.logChunkController)!=null&&e.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var u,l;(u=this.logChunkController)!=null&&u.downloadLogsBlobInBrowser&&((l=this.logChunkController)==null||l.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Wr(s,this.name),this.heartbeat=new vS,this.crypto=new Wx(this,this.logger,t==null?void 0:t.keychain),this.history=new d7(this,this.logger),this.expirer=new p7(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new gS(r1(r1({},yx),t==null?void 0:t.storageOptions)),this.relayer=new c7({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new f7(this,this.logger),this.verify=new g7(this.projectId||"",this.logger),this.echoClient=new m7(this.projectId||"",this.logger)}static async init(t){const e=new gm(t);await e.initialize();const i=await e.crypto.getClientId();return await e.storage.setItem(Tx,i),e}get context(){return Gr(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var t;return(t=this.logChunkController)==null?void 0:t.logsToBlob({clientId:await this.crypto.getClientId()})}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.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}};const _7=b7,mm="wc",vm=2,ym="client",nf=`${mm}@${vm}:${ym}:`,rl={name:ym,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},i1="WALLETCONNECT_DEEPLINK_CHOICE",E7="proposal",wm="Proposal expired",A7="session",Zs=yt.SEVEN_DAYS,S7="engine",pr={wc_sessionPropose:{req:{ttl:yt.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:yt.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:yt.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:yt.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:yt.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:yt.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:yt.ONE_DAY,prompt:!1,tag:1104},res:{ttl:yt.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:yt.ONE_DAY,prompt:!1,tag:1106},res:{ttl:yt.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:yt.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:yt.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:yt.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:yt.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:yt.ONE_DAY,prompt:!1,tag:1112},res:{ttl:yt.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:yt.ONE_DAY,prompt:!1,tag:1114},res:{ttl:yt.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:yt.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:yt.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:yt.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:yt.FIVE_MINUTES,prompt:!1,tag:1119}}},il={min:yt.FIVE_MINUTES,max:yt.SEVEN_DAYS},Wi={idle:"IDLE",active:"ACTIVE"},I7="request",D7=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"],x7="wc",M7="auth",C7="authKeys",P7="pairingTopics",O7="requests",vu=`${x7}@${1.5}:${M7}:`,kc=`${vu}:PUB_KEY`;var N7=Object.defineProperty,R7=Object.defineProperties,T7=Object.getOwnPropertyDescriptors,n1=Object.getOwnPropertySymbols,F7=Object.prototype.hasOwnProperty,U7=Object.prototype.propertyIsEnumerable,s1=(r,t,e)=>t in r?N7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sr=(r,t)=>{for(var e in t||(t={}))F7.call(t,e)&&s1(r,e,t[e]);if(n1)for(var e of n1(t))U7.call(t,e)&&s1(r,e,t[e]);return r},bs=(r,t)=>R7(r,T7(t));class B7 extends iI{constructor(t){super(t),this.name=S7,this.events=new Fl,this.initialized=!1,this.requestQueue={state:Wi.idle,queue:[]},this.sessionRequestQueue={state:Wi.idle,queue:[]},this.requestQueueDelay=yt.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(pr)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},yt.toMiliseconds(this.requestQueueDelay)))},this.connect=async e=>{await this.isInitialized();const i=bs(sr({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:s,requiredNamespaces:a,optionalNamespaces:u,sessionProperties:l,relays:m}=i;let f=s,w,E=!1;try{f&&(E=this.client.core.pairing.pairings.get(f).active)}catch(B){throw this.client.logger.error(`connect() -> pairing.get(${f}) failed`),B}if(!f||!E){const{topic:B,uri:z}=await this.client.core.pairing.create();f=B,w=z}if(!f){const{message:B}=gt("NO_MATCHING_KEY",`connect() pairing topic: ${f}`);throw new Error(B)}const x=await this.client.core.crypto.generateKeyPair(),I=pr.wc_sessionPropose.req.ttl||yt.FIVE_MINUTES,N=gr(I),Y=sr({requiredNamespaces:a,optionalNamespaces:u,relays:m??[{protocol:dm}],proposer:{publicKey:x,metadata:this.client.metadata},expiryTimestamp:N,pairingTopic:f},l&&{sessionProperties:l}),{reject:G,resolve:tt,done:K}=_s(I,wm);this.events.once(de("session_connect"),async({error:B,session:z})=>{if(B)G(B);else if(z){z.self.publicKey=x;const $=bs(sr({},z),{pairingTopic:Y.pairingTopic,requiredNamespaces:Y.requiredNamespaces,optionalNamespaces:Y.optionalNamespaces});await this.client.session.set(z.topic,$),await this.setExpiry(z.topic,z.expiry),f&&await this.client.core.pairing.updateMetadata({topic:f,metadata:z.peer.metadata}),this.cleanupDuplicatePairings($),tt($)}});const V=await this.sendRequest({topic:f,method:"wc_sessionPropose",params:Y,throwOnFailedPublish:!0});return await this.setProposal(V,sr({id:V},Y)),{uri:w,approval:K}},this.pair=async e=>{await this.isInitialized();try{return await this.client.core.pairing.pair(e)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async e=>{await this.isInitialized();try{await this.isValidApprove(e)}catch(K){throw this.client.logger.error("approve() -> isValidApprove() failed"),K}const{id:i,relayProtocol:s,namespaces:a,sessionProperties:u,sessionConfig:l}=e;let m;try{m=this.client.proposal.get(i)}catch(K){throw this.client.logger.error(`approve() -> proposal.get(${i}) failed`),K}const{pairingTopic:f,proposer:w,requiredNamespaces:E,optionalNamespaces:x}=m,I=await this.client.core.crypto.generateKeyPair(),N=w.publicKey,Y=await this.client.core.crypto.generateSharedKey(I,N),G=sr(sr({relay:{protocol:s??"irn"},namespaces:a,controller:{publicKey:I,metadata:this.client.metadata},expiry:gr(Zs)},u&&{sessionProperties:u}),l&&{sessionConfig:l});await this.client.core.relayer.subscribe(Y);const tt=bs(sr({},G),{topic:Y,requiredNamespaces:E,optionalNamespaces:x,pairingTopic:f,acknowledged:!1,self:G.controller,peer:{publicKey:w.publicKey,metadata:w.metadata},controller:I});await this.client.session.set(Y,tt);try{await this.sendResult({id:i,topic:f,result:{relay:{protocol:s??"irn"},responderPublicKey:I},throwOnFailedPublish:!0}),await this.sendRequest({topic:Y,method:"wc_sessionSettle",params:G,throwOnFailedPublish:!0})}catch(K){throw this.client.logger.error(K),this.client.session.delete(Y,Re("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(Y),K}return await this.client.core.pairing.updateMetadata({topic:f,metadata:w.metadata}),await this.client.proposal.delete(i,Re("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(Y,gr(Zs)),{topic:Y,acknowledged:()=>new Promise(K=>setTimeout(()=>K(this.client.session.get(Y)),500))}},this.reject=async e=>{await this.isInitialized();try{await this.isValidReject(e)}catch(u){throw this.client.logger.error("reject() -> isValidReject() failed"),u}const{id:i,reason:s}=e;let a;try{a=this.client.proposal.get(i).pairingTopic}catch(u){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),u}a&&(await this.sendError({id:i,topic:a,error:s,rpcOpts:pr.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Re("USER_DISCONNECTED")))},this.update=async e=>{await this.isInitialized();try{await this.isValidUpdate(e)}catch(E){throw this.client.logger.error("update() -> isValidUpdate() failed"),E}const{topic:i,namespaces:s}=e,{done:a,resolve:u,reject:l}=_s(),m=Kn(),f=Ss().toString(),w=this.client.session.get(i).namespaces;return this.events.once(de("session_update",m),({error:E})=>{E?l(E):u()}),await this.client.session.update(i,{namespaces:s}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:m,relayRpcId:f}).catch(E=>{this.client.logger.error(E),this.client.session.update(i,{namespaces:w}),l(E)}),{acknowledged:a}},this.extend=async e=>{await this.isInitialized();try{await this.isValidExtend(e)}catch(m){throw this.client.logger.error("extend() -> isValidExtend() failed"),m}const{topic:i}=e,s=Kn(),{done:a,resolve:u,reject:l}=_s();return this.events.once(de("session_extend",s),({error:m})=>{m?l(m):u()}),await this.setExpiry(i,gr(Zs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(m=>{l(m)}),{acknowledged:a}},this.request=async e=>{await this.isInitialized();try{await this.isValidRequest(e)}catch(I){throw this.client.logger.error("request() -> isValidRequest() failed"),I}const{chainId:i,request:s,topic:a,expiry:u=pr.wc_sessionRequest.req.ttl}=e,l=this.client.session.get(a),m=Kn(),f=Ss().toString(),{done:w,resolve:E,reject:x}=_s(u,"Request expired. Please try again.");return this.events.once(de("session_request",m),({error:I,result:N})=>{I?x(I):E(N)}),await Promise.all([new Promise(async I=>{await this.sendRequest({clientRpcId:m,relayRpcId:f,topic:a,method:"wc_sessionRequest",params:{request:bs(sr({},s),{expiryTimestamp:gr(u)}),chainId:i},expiry:u,throwOnFailedPublish:!0}).catch(N=>x(N)),this.client.events.emit("session_request_sent",{topic:a,request:s,chainId:i,id:m}),I()}),new Promise(async I=>{var N;if(!((N=l.sessionConfig)!=null&&N.disableDeepLink)){const Y=await jE(this.client.core.storage,i1);qE({id:m,topic:a,wcDeepLink:Y})}I()}),w()]).then(I=>I[2])},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:i,response:s}=e,{id:a}=s;Ji(s)?await this.sendResult({id:a,topic:i,result:s.result,throwOnFailedPublish:!0}):Si(s)&&await this.sendError({id:a,topic:i,error:s.error}),this.cleanupAfterResponse(e)},this.ping=async e=>{await this.isInitialized();try{await this.isValidPing(e)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:i}=e;if(this.client.session.keys.includes(i)){const s=Kn(),a=Ss().toString(),{done:u,resolve:l,reject:m}=_s();this.events.once(de("session_ping",s),({error:f})=>{f?m(f):l()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:a}),u()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async e=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:i,event:s,chainId:a}=e,u=Ss().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:s,chainId:a},throwOnFailedPublish:!0,relayRpcId:u})},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:i}=e;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Re("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:s}=gt("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(s)}},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter(i=>u4(i,e))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async e=>{this.isInitialized(),this.isValidAuthenticate(e);const{chains:i,statement:s="",uri:a,domain:u,nonce:l,type:m,exp:f,nbf:w,methods:E=[],expiry:x}=e,I=[...e.resources||[]],{topic:N,uri:Y}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"]});this.client.logger.info({message:"Generated new pairing",pairing:{topic:N,uri:Y}});const G=await this.client.core.crypto.generateKeyPair(),tt=jc(G);if(await Promise.all([this.client.auth.authKeys.set(kc,{responseTopic:tt,publicKey:G}),this.client.auth.pairingTopics.set(tt,{topic:tt,pairingTopic:N})]),await this.client.core.relayer.subscribe(tt),this.client.logger.info(`sending request to new pairing topic: ${N}`),E.length>0){const{namespace:h}=Tc(i[0]);let y=R8(h,"request",E);qc(I)&&(y=F8(y,I.pop())),I.push(y)}const K=x&&x>pr.wc_sessionAuthenticate.req.ttl?x:pr.wc_sessionAuthenticate.req.ttl,V={authPayload:{type:m??"caip122",chains:i,statement:s,aud:a,domain:u,version:"1",nonce:l,iat:new Date().toISOString(),exp:f,nbf:w,resources:I},requester:{publicKey:G,metadata:this.client.metadata},expiryTimestamp:gr(K)},B={eip155:{chains:i,methods:[...new Set(["personal_sign",...E])],events:["chainChanged","accountsChanged"]}},z={requiredNamespaces:{},optionalNamespaces:B,relays:[{protocol:"irn"}],pairingTopic:N,proposer:{publicKey:G,metadata:this.client.metadata},expiryTimestamp:gr(pr.wc_sessionPropose.req.ttl)},{done:$,resolve:v,reject:T}=_s(K,"Request expired"),nt=async({error:h,session:y})=>{if(this.events.off(de("session_request",pt),ft),h)T(h);else if(y){y.self.publicKey=G,await this.client.session.set(y.topic,y),await this.setExpiry(y.topic,y.expiry),N&&await this.client.core.pairing.updateMetadata({topic:N,metadata:y.peer.metadata});const b=this.client.session.get(y.topic);await this.deleteProposal(mt),v({session:b})}},ft=async h=>{if(await this.deletePendingAuthRequest(pt,{message:"fulfilled",code:0}),h.error){const S=Re("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return h.error.code===S.code?void 0:(this.events.off(de("session_connect"),nt),T(h.error.message))}await this.deleteProposal(mt),this.events.off(de("session_connect"),nt);const{cacaos:y,responder:b}=h.result,M=[],C=[];for(const S of y){await np({cacao:S,projectId:this.client.core.projectId})||(this.client.logger.error(S,"Signature verification failed"),T(Re("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p}=S,O=qc(p.resources),it=[ip(p.iss)],lt=Qc(p.iss);if(O){const _=sp(O),Z=op(O);M.push(..._),it.push(...Z)}for(const _ of it)C.push(`${_}:${lt}`)}const R=await this.client.core.crypto.generateSharedKey(G,b.publicKey);let j;M.length>0&&(j={topic:R,acknowledged:!0,self:{publicKey:G,metadata:this.client.metadata},peer:b,controller:b.publicKey,expiry:gr(Zs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:N,namespaces:dp([...new Set(M)],[...new Set(C)])},await this.client.core.relayer.subscribe(R),await this.client.session.set(R,j),j=this.client.session.get(R)),v({auths:y,session:j})},pt=Kn(),mt=Kn();this.events.once(de("session_connect"),nt),this.events.once(de("session_request",pt),ft);try{await Promise.all([this.sendRequest({topic:N,method:"wc_sessionAuthenticate",params:V,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:pt}),this.sendRequest({topic:N,method:"wc_sessionPropose",params:z,expiry:pr.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:mt})])}catch(h){throw this.events.off(de("session_connect"),nt),this.events.off(de("session_request",pt),ft),h}return await this.setProposal(mt,sr({id:mt},z)),await this.setAuthRequest(pt,{request:bs(sr({},V),{verifyContext:{}}),pairingTopic:N}),{uri:Y,response:$}},this.approveSessionAuthenticate=async e=>{this.isInitialized();const{id:i,auths:s}=e,a=this.getPendingAuthRequest(i);if(!a)throw new Error(`Could not find pending auth request with id ${i}`);const u=a.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),m=jc(u),f={type:xn,receiverPublicKey:u,senderPublicKey:l},w=[],E=[];for(const N of s){if(!await np({cacao:N,projectId:this.client.core.projectId})){const V=Re("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:m,error:V,encodeOpts:f}),new Error(V.message)}const{p:Y}=N,G=qc(Y.resources),tt=[ip(Y.iss)],K=Qc(Y.iss);if(G){const V=sp(G),B=op(G);w.push(...V),tt.push(...B)}for(const V of tt)E.push(`${V}:${K}`)}const x=await this.client.core.crypto.generateSharedKey(l,u);let I;return(w==null?void 0:w.length)>0&&(I={topic:x,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:u,metadata:a.requester.metadata},controller:u,expiry:gr(Zs),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:"",namespaces:dp([...new Set(w)],[...new Set(E)])},await this.client.core.relayer.subscribe(x),await this.client.session.set(x,I)),await this.sendResult({topic:m,id:i,result:{cacaos:s,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:f,throwOnFailedPublish:!0}),await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:a.pairingTopic}),{session:I}},this.rejectSessionAuthenticate=async e=>{await this.isInitialized();const{id:i,reason:s}=e,a=this.getPendingAuthRequest(i);if(!a)throw new Error(`Could not find pending auth request with id ${i}`);const u=a.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),m=jc(u),f={type:xn,receiverPublicKey:u,senderPublicKey:l};await this.sendError({id:i,topic:m,error:s,encodeOpts:f,rpcOpts:pr.wc_sessionAuthenticate.reject}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Re("USER_DISCONNECTED"))},this.formatAuthMessage=e=>{this.isInitialized();const{request:i,iss:s}=e;return Rg(i,s)},this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const i=this.client.core.pairing.pairings.get(e.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(a=>{var u,l;return((u=a.peerMetadata)==null?void 0:u.url)&&((l=a.peerMetadata)==null?void 0:l.url)===e.peer.metadata.url&&a.topic&&a.topic!==i.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.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 e=>{var i;const{topic:s,expirerHasDeleted:a=!1,emitEvent:u=!0,id:l=0}=e,{self:m}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,Re("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(m.publicKey)&&await this.client.core.crypto.deleteKeyPair(m.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),a||this.client.core.expirer.del(s),this.client.core.storage.removeItem(i1).catch(f=>this.client.logger.warn(f)),this.getPendingSessionRequests().forEach(f=>{f.topic===s&&this.deletePendingSessionRequest(f.id,Re("USER_DISCONNECTED"))}),s===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Wi.idle),u&&this.client.events.emit("session_delete",{id:l,topic:s})},this.deleteProposal=async(e,i)=>{await Promise.all([this.client.proposal.delete(e,Re("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")},this.deletePendingSessionRequest=async(e,i,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,i),s?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(a=>a.id!==e),s&&(this.sessionRequestQueue.state=Wi.idle,this.client.events.emit("session_request_expire",{id:e}))},this.deletePendingAuthRequest=async(e,i,s=!1)=>{await Promise.all([this.client.auth.requests.delete(e,i),s?Promise.resolve():this.client.core.expirer.del(e)])},this.setExpiry=async(e,i)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,i),await this.client.session.update(e,{expiry:i}))},this.setProposal=async(e,i)=>{this.client.core.expirer.set(e,gr(pr.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,i)},this.setAuthRequest=async(e,i)=>{const{request:s,pairingTopic:a}=i;this.client.core.expirer.set(e,s.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:e,pairingTopic:a,verifyContext:s.verifyContext})},this.setPendingSessionRequest=async e=>{const{id:i,topic:s,params:a,verifyContext:u}=e,l=a.request.expiryTimestamp||gr(pr.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,l),await this.client.pendingRequest.set(i,{id:i,topic:s,params:a,verifyContext:u})},this.sendRequest=async e=>{const{topic:i,method:s,params:a,expiry:u,relayRpcId:l,clientRpcId:m,throwOnFailedPublish:f}=e,w=co(s,a,m);if(go()&&D7.includes(s)){const I=As(JSON.stringify(w));this.client.core.verify.register({attestationId:I})}let E;try{E=await this.client.core.crypto.encode(i,w)}catch(I){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),I}const x=pr[s].req;return u&&(x.ttl=u),l&&(x.id=l),this.client.core.history.set(i,w),f?(x.internal=bs(sr({},x.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,E,x)):this.client.core.relayer.publish(i,E,x).catch(I=>this.client.logger.error(I)),w.id},this.sendResult=async e=>{const{id:i,topic:s,result:a,throwOnFailedPublish:u,encodeOpts:l}=e,m=du(i,a);let f;try{f=await this.client.core.crypto.encode(s,m,l)}catch(x){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),x}let w;try{w=await this.client.core.history.get(s,i)}catch(x){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${i}) failed`),x}const E=pr[w.request.method].res;u?(E.internal=bs(sr({},E.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,f,E)):this.client.core.relayer.publish(s,f,E).catch(x=>this.client.logger.error(x)),await this.client.core.history.resolve(m)},this.sendError=async e=>{const{id:i,topic:s,error:a,encodeOpts:u,rpcOpts:l}=e,m=pu(i,a);let f;try{f=await this.client.core.crypto.encode(s,m,u)}catch(x){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),x}let w;try{w=await this.client.core.history.get(s,i)}catch(x){throw this.client.logger.error(`sendError() -> history.get(${s}, ${i}) failed`),x}const E=l||pr[w.request.method].res;this.client.core.relayer.publish(s,f,E),await this.client.core.history.resolve(m)},this.cleanup=async()=>{const e=[],i=[];this.client.session.getAll().forEach(s=>{let a=!1;Hn(s.expiry)&&(a=!0),this.client.core.crypto.keychain.has(s.topic)||(a=!0),a&&e.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{Hn(s.expiryTimestamp)&&i.push(s.id)}),await Promise.all([...e.map(s=>this.deleteSession({topic:s})),...i.map(s=>this.deleteProposal(s))])},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Wi.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=Wi.active;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise(i=>setTimeout(i,300))}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Wi.idle},this.processRequest=e=>{const{topic:i,payload:s}=e,a=s.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:a}))switch(a){case"wc_sessionPropose":return this.onSessionProposeRequest(i,s);case"wc_sessionSettle":return this.onSessionSettleRequest(i,s);case"wc_sessionUpdate":return this.onSessionUpdateRequest(i,s);case"wc_sessionExtend":return this.onSessionExtendRequest(i,s);case"wc_sessionPing":return this.onSessionPingRequest(i,s);case"wc_sessionDelete":return this.onSessionDeleteRequest(i,s);case"wc_sessionRequest":return this.onSessionRequest(i,s);case"wc_sessionEvent":return this.onSessionEventRequest(i,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateRequest(i,s);default:return this.client.logger.info(`Unsupported request method ${a}`)}},this.onRelayEventResponse=async e=>{const{topic:i,payload:s}=e,a=(await this.client.core.history.get(i,s.id)).request.method;switch(a){case"wc_sessionPropose":return this.onSessionProposeResponse(i,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,s);case"wc_sessionExtend":return this.onSessionExtendResponse(i,s);case"wc_sessionPing":return this.onSessionPingResponse(i,s);case"wc_sessionRequest":return this.onSessionRequestResponse(i,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,s);default:return this.client.logger.info(`Unsupported response method ${a}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:i}=e,{message:s}=gt("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)},this.shouldIgnorePairingRequest=e=>{const{topic:i,requestMethod:s}=e,a=this.expectedPairingMethodMap.get(i);return!a||a.includes(s)?!1:!!(a.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async(e,i)=>{const{params:s,id:a}=i;try{this.isValidConnect(sr({},i.params));const u=s.expiryTimestamp||gr(pr.wc_sessionPropose.req.ttl),l=sr({id:a,pairingTopic:e,expiryTimestamp:u},s);await this.setProposal(a,l);const m=As(JSON.stringify(i)),f=await this.getVerifyContext(m,l.proposer.metadata);this.client.events.emit("session_proposal",{id:a,params:l,verifyContext:f})}catch(u){await this.sendError({id:a,topic:e,error:u,rpcOpts:pr.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(e,i)=>{const{id:s}=i;if(Ji(i)){const{result:a}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:a});const u=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:u});const l=u.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:l});const m=a.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:m});const f=await this.client.core.crypto.generateSharedKey(l,m);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:f});const w=await this.client.core.relayer.subscribe(f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:w}),await this.client.core.pairing.activate({topic:e})}else if(Si(i)){await this.client.proposal.delete(s,Re("USER_DISCONNECTED"));const a=de("session_connect");if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners, 954`);this.events.emit(de("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(e,i)=>{const{id:s,params:a}=i;try{this.isValidSessionSettleRequest(a);const{relay:u,controller:l,expiry:m,namespaces:f,sessionProperties:w,sessionConfig:E}=i.params,x=sr(sr({topic:e,relay:u,expiry:m,namespaces:f,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:l.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:l.publicKey,metadata:l.metadata}},w&&{sessionProperties:w}),E&&{sessionConfig:E});await this.sendResult({id:i.id,topic:e,result:!0,throwOnFailedPublish:!0});const I=de("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(de("session_connect"),{session:x})}catch(u){await this.sendError({id:s,topic:e,error:u}),this.client.logger.error(u)}},this.onSessionSettleResponse=async(e,i)=>{const{id:s}=i;Ji(i)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(de("session_approve",s),{})):Si(i)&&(await this.client.session.delete(e,Re("USER_DISCONNECTED")),this.events.emit(de("session_approve",s),{error:i.error}))},this.onSessionUpdateRequest=async(e,i)=>{const{params:s,id:a}=i;try{const u=`${e}_session_update`,l=Ko.get(u);if(l&&this.isRequestOutOfSync(l,a)){this.client.logger.info(`Discarding out of sync request - ${a}`),this.sendError({id:a,topic:e,error:Re("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(sr({topic:e},s));try{Ko.set(u,a),await this.client.session.update(e,{namespaces:s.namespaces}),await this.sendResult({id:a,topic:e,result:!0,throwOnFailedPublish:!0})}catch(m){throw Ko.delete(u),m}this.client.events.emit("session_update",{id:a,topic:e,params:s})}catch(u){await this.sendError({id:a,topic:e,error:u}),this.client.logger.error(u)}},this.isRequestOutOfSync=(e,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,i)=>{const{id:s}=i,a=de("session_update",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Ji(i)?this.events.emit(de("session_update",s),{}):Si(i)&&this.events.emit(de("session_update",s),{error:i.error})},this.onSessionExtendRequest=async(e,i)=>{const{id:s}=i;try{this.isValidExtend({topic:e}),await this.setExpiry(e,gr(Zs)),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:e})}catch(a){await this.sendError({id:s,topic:e,error:a}),this.client.logger.error(a)}},this.onSessionExtendResponse=(e,i)=>{const{id:s}=i,a=de("session_extend",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Ji(i)?this.events.emit(de("session_extend",s),{}):Si(i)&&this.events.emit(de("session_extend",s),{error:i.error})},this.onSessionPingRequest=async(e,i)=>{const{id:s}=i;try{this.isValidPing({topic:e}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:e})}catch(a){await this.sendError({id:s,topic:e,error:a}),this.client.logger.error(a)}},this.onSessionPingResponse=(e,i)=>{const{id:s}=i,a=de("session_ping",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);setTimeout(()=>{Ji(i)?this.events.emit(de("session_ping",s),{}):Si(i)&&this.events.emit(de("session_ping",s),{error:i.error})},500)},this.onSessionDeleteRequest=async(e,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:e,reason:i.params}),await Promise.all([new Promise(a=>{this.client.core.relayer.once(Hr.publish,async()=>{a(await this.deleteSession({topic:e,id:s}))})}),this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:Re("USER_DISCONNECTED")})])}catch(a){this.client.logger.error(a)}},this.onSessionRequest=async(e,i)=>{var s;const{id:a,params:u}=i;try{await this.isValidRequest(sr({topic:e},u));const l=As(JSON.stringify(co("wc_sessionRequest",u,a))),m=this.client.session.get(e),f=await this.getVerifyContext(l,m.peer.metadata),w={id:a,topic:e,params:u,verifyContext:f};await this.setPendingSessionRequest(w),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(w):(this.addSessionRequestToSessionRequestQueue(w),this.processSessionRequestQueue())}catch(l){await this.sendError({id:a,topic:e,error:l}),this.client.logger.error(l)}},this.onSessionRequestResponse=(e,i)=>{const{id:s}=i,a=de("session_request",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Ji(i)?this.events.emit(de("session_request",s),{result:i.result}):Si(i)&&this.events.emit(de("session_request",s),{error:i.error})},this.onSessionEventRequest=async(e,i)=>{const{id:s,params:a}=i;try{const u=`${e}_session_event_${a.event.name}`,l=Ko.get(u);if(l&&this.isRequestOutOfSync(l,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(sr({topic:e},a)),this.client.events.emit("session_event",{id:s,topic:e,params:a}),Ko.set(u,s)}catch(u){await this.sendError({id:s,topic:e,error:u}),this.client.logger.error(u)}},this.onSessionAuthenticateResponse=(e,i)=>{const{id:s}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:i}),Ji(i)?this.events.emit(de("session_request",s),{result:i.result}):Si(i)&&this.events.emit(de("session_request",s),{error:i.error})},this.onSessionAuthenticateRequest=async(e,i)=>{try{const{requester:s,authPayload:a,expiryTimestamp:u}=i.params,l=As(JSON.stringify(i)),m=await this.getVerifyContext(l,this.client.metadata),f={requester:s,pairingTopic:e,id:i.id,authPayload:a,verifyContext:m,expiryTimestamp:u};await this.setAuthRequest(i.id,{request:f,pairingTopic:e}),this.client.events.emit("session_authenticate",{topic:e,params:i.params,id:i.id})}catch(s){this.client.logger.error(s);const a=i.params.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),l={type:xn,receiverPublicKey:a,senderPublicKey:u};await this.sendError({id:i.id,topic:e,error:s,encodeOpts:l,rpcOpts:pr.wc_sessionAuthenticate.autoReject})}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Wi.idle,this.processSessionRequestQueue()},yt.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:e,error:i})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(a=>a.topic===e&&a.request.method==="wc_sessionRequest").forEach(a=>{const u=a.request.id,l=de("session_request",u);if(this.events.listenerCount(l)===0)throw new Error(`emitting ${l} without any listeners`);this.events.emit(de("session_request",a.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Wi.active){this.client.logger.info("session request queue is already active.");return}const e=this.sessionRequestQueue.queue[0];if(!e){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Wi.active,this.emitSessionRequest(e)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=e=>{this.client.events.emit("session_request",e)},this.onPairingCreated=e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const i=this.client.proposal.getAll().find(s=>s.pairingTopic===e.topic);i&&this.onSessionProposeRequest(e.topic,co("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id))},this.isValidConnect=async e=>{if(!kr(e)){const{message:m}=gt("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(m)}const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:a,sessionProperties:u,relays:l}=e;if(Nr(i)||await this.isValidPairingTopic(i),!_4(l,!0)){const{message:m}=gt("MISSING_OR_INVALID",`connect() relays: ${l}`);throw new Error(m)}!Nr(s)&&sa(s)!==0&&this.validateNamespaces(s,"requiredNamespaces"),!Nr(a)&&sa(a)!==0&&this.validateNamespaces(a,"optionalNamespaces"),Nr(u)||this.validateSessionProps(u,"sessionProperties")},this.validateNamespaces=(e,i)=>{const s=b4(e,"connect()",i);if(s)throw new Error(s.message)},this.isValidApprove=async e=>{if(!kr(e))throw new Error(gt("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:i,namespaces:s,relayProtocol:a,sessionProperties:u}=e;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const l=this.client.proposal.get(i),m=Gh(s,"approve()");if(m)throw new Error(m.message);const f=mp(l.requiredNamespaces,s,"approve()");if(f)throw new Error(f.message);if(!tr(a,!0)){const{message:w}=gt("MISSING_OR_INVALID",`approve() relayProtocol: ${a}`);throw new Error(w)}Nr(u)||this.validateSessionProps(u,"sessionProperties")},this.isValidReject=async e=>{if(!kr(e)){const{message:a}=gt("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(a)}const{id:i,reason:s}=e;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!A4(s)){const{message:a}=gt("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(a)}},this.isValidSessionSettleRequest=e=>{if(!kr(e)){const{message:f}=gt("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(f)}const{relay:i,controller:s,namespaces:a,expiry:u}=e;if(!qg(i)){const{message:f}=gt("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(f)}const l=p4(s,"onSessionSettleRequest()");if(l)throw new Error(l.message);const m=Gh(a,"onSessionSettleRequest()");if(m)throw new Error(m.message);if(Hn(u)){const{message:f}=gt("EXPIRED","onSessionSettleRequest()");throw new Error(f)}},this.isValidUpdate=async e=>{if(!kr(e)){const{message:m}=gt("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(m)}const{topic:i,namespaces:s}=e;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const a=this.client.session.get(i),u=Gh(s,"update()");if(u)throw new Error(u.message);const l=mp(a.requiredNamespaces,s,"update()");if(l)throw new Error(l.message)},this.isValidExtend=async e=>{if(!kr(e)){const{message:s}=gt("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(s)}const{topic:i}=e;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async e=>{if(!kr(e)){const{message:m}=gt("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(m)}const{topic:i,request:s,chainId:a,expiry:u}=e;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:l}=this.client.session.get(i);if(!gp(l,a)){const{message:m}=gt("MISSING_OR_INVALID",`request() chainId: ${a}`);throw new Error(m)}if(!S4(s)){const{message:m}=gt("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(m)}if(!x4(l,a,s.method)){const{message:m}=gt("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(m)}if(u&&!O4(u,il)){const{message:m}=gt("MISSING_OR_INVALID",`request() expiry: ${u}. Expiry must be a number (in seconds) between ${il.min} and ${il.max}`);throw new Error(m)}},this.isValidRespond=async e=>{var i;if(!kr(e)){const{message:u}=gt("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(u)}const{topic:s,response:a}=e;try{await this.isValidSessionTopic(s)}catch(u){throw(i=e==null?void 0:e.response)!=null&&i.id&&this.cleanupAfterResponse(e),u}if(!I4(a)){const{message:u}=gt("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(a)}`);throw new Error(u)}},this.isValidPing=async e=>{if(!kr(e)){const{message:s}=gt("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(s)}const{topic:i}=e;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async e=>{if(!kr(e)){const{message:l}=gt("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(l)}const{topic:i,event:s,chainId:a}=e;await this.isValidSessionTopic(i);const{namespaces:u}=this.client.session.get(i);if(!gp(u,a)){const{message:l}=gt("MISSING_OR_INVALID",`emit() chainId: ${a}`);throw new Error(l)}if(!D4(s)){const{message:l}=gt("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(l)}if(!M4(u,a,s.name)){const{message:l}=gt("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(l)}},this.isValidDisconnect=async e=>{if(!kr(e)){const{message:s}=gt("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(s)}const{topic:i}=e;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=e=>{const{chains:i,uri:s,domain:a,nonce:u}=e;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!tr(s,!1))throw new Error("uri is required parameter");if(!tr(a,!1))throw new Error("domain is required parameter");if(!tr(u,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(m=>Tc(m).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:l}=Tc(i[0]);if(l!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async(e,i)=>{const s={verified:{verifyUrl:i.verifyUrl||no,validation:"UNKNOWN",origin:i.url||""}};try{const a=await this.client.core.verify.resolve({attestationId:e,verifyUrl:i.verifyUrl});a&&(s.verified.origin=a.origin,s.verified.isScam=a.isScam,s.verified.validation=a.origin===new URL(i.url).origin?"VALID":"INVALID")}catch(a){this.client.logger.info(a)}return this.client.logger.info(`Verify context: ${JSON.stringify(s)}`),s},this.validateSessionProps=(e,i)=>{Object.values(e).forEach(s=>{if(!tr(s,!1)){const{message:a}=gt("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(s)}`);throw new Error(a)}})},this.getPendingAuthRequest=e=>{const i=this.client.auth.requests.get(e);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(e,i)=>{if(this.recentlyDeletedMap.set(e,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const a=this.recentlyDeletedLimit/2;for(const u of this.recentlyDeletedMap.keys()){if(s++>=a)break;this.recentlyDeletedMap.delete(u)}}},this.checkRecentlyDeleted=e=>{const i=this.recentlyDeletedMap.get(e);if(i){const{message:s}=gt("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${e}`);throw new Error(s)}}}async isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Hr.message,async t=>{const{topic:e,message:i}=t,{publicKey:s}=this.client.auth.authKeys.keys.includes(kc)?this.client.auth.authKeys.get(kc):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(e,i,{receiverPublicKey:s});try{ef(a)?(this.client.core.history.set(e,a),this.onRelayEventRequest({topic:e,payload:a})):gu(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:e,payload:a}),this.client.core.history.delete(e,a.id)):this.onRelayEventUnknownPayload({topic:e,payload:a})}catch(u){this.client.logger.error(u)}})}registerExpirerEvents(){this.client.core.expirer.on(Ei.expired,async t=>{const{topic:e,id:i}=J1(t.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,gt("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,gt("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession({topic:e,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:e})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(io.create,t=>this.onPairingCreated(t)),this.client.core.pairing.events.on(io.delete,t=>{this.addToRecentlyDeleted(t.topic,"pairing")})}isValidPairingTopic(t){if(!tr(t,!1)){const{message:e}=gt("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=gt("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(e)}if(Hn(this.client.core.pairing.pairings.get(t).expiry)){const{message:e}=gt("EXPIRED",`pairing topic: ${t}`);throw new Error(e)}}async isValidSessionTopic(t){if(!tr(t,!1)){const{message:e}=gt("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(e)}if(this.checkRecentlyDeleted(t),!this.client.session.keys.includes(t)){const{message:e}=gt("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(e)}if(Hn(this.client.session.get(t).expiry)){await this.deleteSession({topic:t});const{message:e}=gt("EXPIRED",`session topic: ${t}`);throw new Error(e)}if(!this.client.core.crypto.keychain.has(t)){const{message:e}=gt("MISSING_OR_INVALID",`session topic does not exist in keychain: ${t}`);throw await this.deleteSession({topic:t}),new Error(e)}}async isValidSessionOrPairingTopic(t){if(this.checkRecentlyDeleted(t),this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else if(this.client.core.pairing.pairings.keys.includes(t))this.isValidPairingTopic(t);else if(tr(t,!1)){const{message:e}=gt("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(e)}else{const{message:e}=gt("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(e)}}async isValidProposalId(t){if(!E4(t)){const{message:e}=gt("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(e)}if(!this.client.proposal.keys.includes(t)){const{message:e}=gt("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(e)}if(Hn(this.client.proposal.get(t).expiryTimestamp)){await this.deleteProposal(t);const{message:e}=gt("EXPIRED",`proposal id: ${t}`);throw new Error(e)}}}class L7 extends Os{constructor(t,e){super(t,e,E7,nf),this.core=t,this.logger=e}}class q7 extends Os{constructor(t,e){super(t,e,A7,nf),this.core=t,this.logger=e}}class j7 extends Os{constructor(t,e){super(t,e,I7,nf,i=>i.id),this.core=t,this.logger=e}}class $7 extends Os{constructor(t,e){super(t,e,C7,vu,()=>kc),this.core=t,this.logger=e}}class z7 extends Os{constructor(t,e){super(t,e,P7,vu),this.core=t,this.logger=e}}class k7 extends Os{constructor(t,e){super(t,e,O7,vu,i=>i.id),this.core=t,this.logger=e}}class H7{constructor(t,e){this.core=t,this.logger=e,this.authKeys=new $7(this.core,this.logger),this.pairingTopics=new z7(this.core,this.logger),this.requests=new k7(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class sf extends rI{constructor(t){super(t),this.protocol=mm,this.version=vm,this.name=rl.name,this.events=new Di.EventEmitter,this.on=(i,s)=>this.events.on(i,s),this.once=(i,s)=>this.events.once(i,s),this.off=(i,s)=>this.events.off(i,s),this.removeListener=(i,s)=>this.events.removeListener(i,s),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(s){throw this.logger.error(s.message),s}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(s){throw this.logger.error(s.message),s}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(s){throw this.logger.error(s.message),s}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(s){throw this.logger.error(s.message),s}},this.update=async i=>{try{return await this.engine.update(i)}catch(s){throw this.logger.error(s.message),s}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(s){throw this.logger.error(s.message),s}},this.request=async i=>{try{return await this.engine.request(i)}catch(s){throw this.logger.error(s.message),s}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(s){throw this.logger.error(s.message),s}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(s){throw this.logger.error(s.message),s}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(s){throw this.logger.error(s.message),s}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(s){throw this.logger.error(s.message),s}},this.find=i=>{try{return this.engine.find(i)}catch(s){throw this.logger.error(s.message),s}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async i=>{try{return await this.engine.authenticate(i)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(s){throw this.logger.error(s.message),s}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}},this.name=(t==null?void 0:t.name)||rl.name,this.metadata=(t==null?void 0:t.metadata)||NE(),this.signConfig=t==null?void 0:t.signConfig;const e=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:ya(fu({level:(t==null?void 0:t.logger)||rl.logger}));this.core=(t==null?void 0:t.core)||new _7(t),this.logger=Wr(e,this.name),this.session=new q7(this.core,this.logger),this.proposal=new L7(this.core,this.logger),this.pendingRequest=new j7(this.core,this.logger),this.engine=new B7(this),this.auth=new H7(this.core,this.logger)}static async init(t){const e=new sf(t);return await e.initialize(),e}get context(){return Gr(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.engine.init(),await this.auth.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}}var K7=Object.defineProperty,V7=Object.defineProperties,G7=Object.getOwnPropertyDescriptors,o1=Object.getOwnPropertySymbols,W7=Object.prototype.hasOwnProperty,Y7=Object.prototype.propertyIsEnumerable,a1=(r,t,e)=>t in r?K7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,c1=(r,t)=>{for(var e in t||(t={}))W7.call(t,e)&&a1(r,e,t[e]);if(o1)for(var e of o1(t))Y7.call(t,e)&&a1(r,e,t[e]);return r},u1=(r,t)=>V7(r,G7(t));const Q7={Accept:"application/json","Content-Type":"application/json"},J7="POST",h1={headers:Q7,method:J7},l1=10;class Jn{constructor(t,e=!1){if(this.url=t,this.disableProviderPing=e,this.events=new Di.EventEmitter,this.isAvailable=!1,this.registering=!1,!Rp(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=e}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t){this.isAvailable||await this.register();try{const e=Mn(t),i=await(await ad(this.url,u1(c1({},h1),{body:e}))).json();this.onPayload({data:i})}catch(e){this.onError(t.id,e)}}async register(t=this.url){if(!Rp(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((i,s)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),s(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return s(new Error("HTTP connection is missing or invalid"));i()})})}this.url=t,this.registering=!0;try{if(!this.disableProviderPing){const e=Mn({id:1,jsonrpc:"2.0",method:"test",params:[]});await ad(t,u1(c1({},h1),{body:e}))}this.onOpen()}catch(e){const i=this.parseError(e);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(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?ma(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const i=this.parseError(e),s=i.message||i.toString(),a=pu(t,s);this.events.emit("payload",a)}parseError(t,e=this.url){return Xg(t,e,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>l1&&this.events.setMaxListeners(l1)}}const f1="error",X7="wss://relay.walletconnect.com",Z7="wc",t9="universal_provider",d1=`${Z7}@2:${t9}:`,e9="https://rpc.walletconnect.com/v1/",Pn={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Wo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ie<"u"?Ie:typeof self<"u"?self:{},Ol={exports:{}};/**
18
+ * @license
19
+ * Lodash <https://lodash.com/>
20
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
21
+ * Released under MIT license <https://lodash.com/license>
22
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
23
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
24
+ */(function(r,t){(function(){var e,i="4.17.21",s=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",u="Expected a function",l="Invalid `variable` option passed into `_.template`",m="__lodash_hash_undefined__",f=500,w="__lodash_placeholder__",E=1,x=2,I=4,N=1,Y=2,G=1,tt=2,K=4,V=8,B=16,z=32,$=64,v=128,T=256,nt=512,ft=30,pt="...",mt=800,h=16,y=1,b=2,M=3,C=1/0,R=9007199254740991,j=17976931348623157e292,S=0/0,p=4294967295,O=p-1,it=p>>>1,lt=[["ary",v],["bind",G],["bindKey",tt],["curry",V],["curryRight",B],["flip",nt],["partial",z],["partialRight",$],["rearg",T]],_="[object Arguments]",Z="[object Array]",U="[object AsyncFunction]",L="[object Boolean]",k="[object Date]",d="[object DOMException]",F="[object Error]",et="[object Function]",ut="[object GeneratorFunction]",at="[object Map]",Mt="[object Number]",Pt="[object Null]",It="[object Object]",Ee="[object Promise]",$t="[object Proxy]",xt="[object RegExp]",Bt="[object Set]",_t="[object String]",Et="[object Symbol]",Vt="[object Undefined]",wt="[object WeakMap]",At="[object WeakSet]",Ut="[object ArrayBuffer]",bt="[object DataView]",Ct="[object Float32Array]",Lt="[object Float64Array]",Ot="[object Int8Array]",Nt="[object Int16Array]",se="[object Int32Array]",Tt="[object Uint8Array]",Rt="[object Uint8ClampedArray]",Ke="[object Uint16Array]",ce="[object Uint32Array]",pe=/\b__p \+= '';/g,Ve=/\b(__p \+=) '' \+/g,ye=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_e=/&(?:amp|lt|gt|quot|#39);/g,Ar=/[&<>"']/g,Gt=RegExp(_e.source),zt=RegExp(Ar.source),De=/<%-([\s\S]+?)%>/g,Wt=/<%([\s\S]+?)%>/g,Kt=/<%=([\s\S]+?)%>/g,Ae=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jt=/^\w*$/,Xt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xe=/[\\^$.*+?()[\]{}|]/g,Zt=RegExp(xe.source),Yt=/^\s+/,Ce=/\s/,Qt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,qt=/\{\n\/\* \[wrapped with (.+)\] \*/,Te=/,? & /,te=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Pe=/[()=,{}\[\]\/\s]/,xi=/\\(\\)?/g,Oe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,le=/\w*$/,oi=/^[-+]0x[0-9a-f]+$/i,ai=/^0b[01]+$/i,ci=/^\[object .+?Constructor\]$/,ui=/^0o[0-7]+$/i,hi=/^(?:0|[1-9]\d*)$/,ar=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,qi=/($^)/,Xn=/['\n\r\u2028\u2029\\]/g,ji="\\ud800-\\udfff",Zn="\\u0300-\\u036f",ts="\\ufe20-\\ufe2f",$i="\\u20d0-\\u20ff",On=Zn+ts+$i,Nn="\\u2700-\\u27bf",Sr="a-z\\xdf-\\xf6\\xf8-\\xff",es="\\xac\\xb1\\xd7\\xf7",rs="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",is="\\u2000-\\u206f",ns=" \\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",_a="A-Z\\xc0-\\xd6\\xd8-\\xde",Ea="\\ufe0e\\ufe0f",ss=es+rs+is+ns,_o="['’]",os="["+ji+"]",Eo="["+ss+"]",as="["+On+"]",Aa="\\d+",yu="["+Nn+"]",Sa="["+Sr+"]",Ia="[^"+ji+ss+Aa+Nn+Sr+_a+"]",Rs="\\ud83c[\\udffb-\\udfff]",wu="(?:"+as+"|"+Rs+")",Da="[^"+ji+"]",Ts="(?:\\ud83c[\\udde6-\\uddff]){2}",Rn="[\\ud800-\\udbff][\\udc00-\\udfff]",Yr="["+_a+"]",xa="\\u200d",Ma="(?:"+Sa+"|"+Ia+")",zi="(?:"+Yr+"|"+Ia+")",Ca="(?:"+_o+"(?:d|ll|m|re|s|t|ve))?",Pa="(?:"+_o+"(?:D|LL|M|RE|S|T|VE))?",Oa=wu+"?",Na="["+Ea+"]?",bu="(?:"+xa+"(?:"+[Da,Ts,Rn].join("|")+")"+Na+Oa+")*",ln="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ra="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ta=Na+Oa+bu,Fs="(?:"+[yu,Ts,Rn].join("|")+")"+Ta,_u="(?:"+[Da+as+"?",as,Ts,Rn,os].join("|")+")",Ao=RegExp(_o,"g"),Eu=RegExp(as,"g"),Us=RegExp(Rs+"(?="+Rs+")|"+_u+Ta,"g"),Fa=RegExp([Yr+"?"+Sa+"+"+Ca+"(?="+[Eo,Yr,"$"].join("|")+")",zi+"+"+Pa+"(?="+[Eo,Yr+Ma,"$"].join("|")+")",Yr+"?"+Ma+"+"+Ca,Yr+"+"+Pa,Ra,ln,Aa,Fs].join("|"),"g"),Ua=RegExp("["+xa+ji+On+Ea+"]"),cs=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ba=["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"],Au=-1,Ue={};Ue[Ct]=Ue[Lt]=Ue[Ot]=Ue[Nt]=Ue[se]=Ue[Tt]=Ue[Rt]=Ue[Ke]=Ue[ce]=!0,Ue[_]=Ue[Z]=Ue[Ut]=Ue[L]=Ue[bt]=Ue[k]=Ue[F]=Ue[et]=Ue[at]=Ue[Mt]=Ue[It]=Ue[xt]=Ue[Bt]=Ue[_t]=Ue[wt]=!1;var Fe={};Fe[_]=Fe[Z]=Fe[Ut]=Fe[bt]=Fe[L]=Fe[k]=Fe[Ct]=Fe[Lt]=Fe[Ot]=Fe[Nt]=Fe[se]=Fe[at]=Fe[Mt]=Fe[It]=Fe[xt]=Fe[Bt]=Fe[_t]=Fe[Et]=Fe[Tt]=Fe[Rt]=Fe[Ke]=Fe[ce]=!0,Fe[F]=Fe[et]=Fe[wt]=!1;var q={À:"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"},Q={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ht={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},St={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Be=parseFloat,re=parseInt,$e=typeof Wo=="object"&&Wo&&Wo.Object===Object&&Wo,er=typeof self=="object"&&self&&self.Object===Object&&self,we=$e||er||Function("return this")(),Le=t&&!t.nodeType&&t,Qe=Le&&!0&&r&&!r.nodeType&&r,Ur=Qe&&Qe.exports===Le,rr=Ur&&$e.process,ze=function(){try{var J=Qe&&Qe.require&&Qe.require("util").types;return J||rr&&rr.binding&&rr.binding("util")}catch{}}(),Ir=ze&&ze.isArrayBuffer,Mi=ze&&ze.isDate,li=ze&&ze.isMap,ki=ze&&ze.isRegExp,So=ze&&ze.isSet,us=ze&&ze.isTypedArray;function cr(J,st,rt){switch(rt.length){case 0:return J.call(st);case 1:return J.call(st,rt[0]);case 2:return J.call(st,rt[0],rt[1]);case 3:return J.call(st,rt[0],rt[1],rt[2])}return J.apply(st,rt)}function Em(J,st,rt,Dt){for(var ee=-1,Se=J==null?0:J.length;++ee<Se;){var ir=J[ee];st(Dt,ir,rt(ir),J)}return Dt}function fi(J,st){for(var rt=-1,Dt=J==null?0:J.length;++rt<Dt&&st(J[rt],rt,J)!==!1;);return J}function Am(J,st){for(var rt=J==null?0:J.length;rt--&&st(J[rt],rt,J)!==!1;);return J}function cf(J,st){for(var rt=-1,Dt=J==null?0:J.length;++rt<Dt;)if(!st(J[rt],rt,J))return!1;return!0}function Tn(J,st){for(var rt=-1,Dt=J==null?0:J.length,ee=0,Se=[];++rt<Dt;){var ir=J[rt];st(ir,rt,J)&&(Se[ee++]=ir)}return Se}function La(J,st){var rt=J==null?0:J.length;return!!rt&&Bs(J,st,0)>-1}function Su(J,st,rt){for(var Dt=-1,ee=J==null?0:J.length;++Dt<ee;)if(rt(st,J[Dt]))return!0;return!1}function ke(J,st){for(var rt=-1,Dt=J==null?0:J.length,ee=Array(Dt);++rt<Dt;)ee[rt]=st(J[rt],rt,J);return ee}function Fn(J,st){for(var rt=-1,Dt=st.length,ee=J.length;++rt<Dt;)J[ee+rt]=st[rt];return J}function Iu(J,st,rt,Dt){var ee=-1,Se=J==null?0:J.length;for(Dt&&Se&&(rt=J[++ee]);++ee<Se;)rt=st(rt,J[ee],ee,J);return rt}function Sm(J,st,rt,Dt){var ee=J==null?0:J.length;for(Dt&&ee&&(rt=J[--ee]);ee--;)rt=st(rt,J[ee],ee,J);return rt}function Du(J,st){for(var rt=-1,Dt=J==null?0:J.length;++rt<Dt;)if(st(J[rt],rt,J))return!0;return!1}var Im=xu("length");function Dm(J){return J.split("")}function xm(J){return J.match(te)||[]}function uf(J,st,rt){var Dt;return rt(J,function(ee,Se,ir){if(st(ee,Se,ir))return Dt=Se,!1}),Dt}function qa(J,st,rt,Dt){for(var ee=J.length,Se=rt+(Dt?1:-1);Dt?Se--:++Se<ee;)if(st(J[Se],Se,J))return Se;return-1}function Bs(J,st,rt){return st===st?qm(J,st,rt):qa(J,hf,rt)}function Mm(J,st,rt,Dt){for(var ee=rt-1,Se=J.length;++ee<Se;)if(Dt(J[ee],st))return ee;return-1}function hf(J){return J!==J}function lf(J,st){var rt=J==null?0:J.length;return rt?Cu(J,st)/rt:S}function xu(J){return function(st){return st==null?e:st[J]}}function Mu(J){return function(st){return J==null?e:J[st]}}function ff(J,st,rt,Dt,ee){return ee(J,function(Se,ir,qe){rt=Dt?(Dt=!1,Se):st(rt,Se,ir,qe)}),rt}function Cm(J,st){var rt=J.length;for(J.sort(st);rt--;)J[rt]=J[rt].value;return J}function Cu(J,st){for(var rt,Dt=-1,ee=J.length;++Dt<ee;){var Se=st(J[Dt]);Se!==e&&(rt=rt===e?Se:rt+Se)}return rt}function Pu(J,st){for(var rt=-1,Dt=Array(J);++rt<J;)Dt[rt]=st(rt);return Dt}function Pm(J,st){return ke(st,function(rt){return[rt,J[rt]]})}function df(J){return J&&J.slice(0,vf(J)+1).replace(Yt,"")}function Qr(J){return function(st){return J(st)}}function Ou(J,st){return ke(st,function(rt){return J[rt]})}function Io(J,st){return J.has(st)}function pf(J,st){for(var rt=-1,Dt=J.length;++rt<Dt&&Bs(st,J[rt],0)>-1;);return rt}function gf(J,st){for(var rt=J.length;rt--&&Bs(st,J[rt],0)>-1;);return rt}function Om(J,st){for(var rt=J.length,Dt=0;rt--;)J[rt]===st&&++Dt;return Dt}var Nm=Mu(q),Rm=Mu(Q);function Tm(J){return"\\"+St[J]}function Fm(J,st){return J==null?e:J[st]}function Ls(J){return Ua.test(J)}function Um(J){return cs.test(J)}function Bm(J){for(var st,rt=[];!(st=J.next()).done;)rt.push(st.value);return rt}function Nu(J){var st=-1,rt=Array(J.size);return J.forEach(function(Dt,ee){rt[++st]=[ee,Dt]}),rt}function mf(J,st){return function(rt){return J(st(rt))}}function Un(J,st){for(var rt=-1,Dt=J.length,ee=0,Se=[];++rt<Dt;){var ir=J[rt];(ir===st||ir===w)&&(J[rt]=w,Se[ee++]=rt)}return Se}function ja(J){var st=-1,rt=Array(J.size);return J.forEach(function(Dt){rt[++st]=Dt}),rt}function Lm(J){var st=-1,rt=Array(J.size);return J.forEach(function(Dt){rt[++st]=[Dt,Dt]}),rt}function qm(J,st,rt){for(var Dt=rt-1,ee=J.length;++Dt<ee;)if(J[Dt]===st)return Dt;return-1}function jm(J,st,rt){for(var Dt=rt+1;Dt--;)if(J[Dt]===st)return Dt;return Dt}function qs(J){return Ls(J)?zm(J):Im(J)}function Ci(J){return Ls(J)?km(J):Dm(J)}function vf(J){for(var st=J.length;st--&&Ce.test(J.charAt(st)););return st}var $m=Mu(ht);function zm(J){for(var st=Us.lastIndex=0;Us.test(J);)++st;return st}function km(J){return J.match(Us)||[]}function Hm(J){return J.match(Fa)||[]}var Km=function J(st){st=st==null?we:js.defaults(we.Object(),st,js.pick(we,Ba));var rt=st.Array,Dt=st.Date,ee=st.Error,Se=st.Function,ir=st.Math,qe=st.Object,Ru=st.RegExp,Vm=st.String,di=st.TypeError,$a=rt.prototype,Gm=Se.prototype,$s=qe.prototype,za=st["__core-js_shared__"],ka=Gm.toString,Ne=$s.hasOwnProperty,Wm=0,yf=function(){var n=/[^.]+$/.exec(za&&za.keys&&za.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),Ha=$s.toString,Ym=ka.call(qe),Qm=we._,Jm=Ru("^"+ka.call(Ne).replace(xe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ka=Ur?st.Buffer:e,Bn=st.Symbol,Va=st.Uint8Array,wf=Ka?Ka.allocUnsafe:e,Ga=mf(qe.getPrototypeOf,qe),bf=qe.create,_f=$s.propertyIsEnumerable,Wa=$a.splice,Ef=Bn?Bn.isConcatSpreadable:e,Do=Bn?Bn.iterator:e,hs=Bn?Bn.toStringTag:e,Ya=function(){try{var n=gs(qe,"defineProperty");return n({},"",{}),n}catch{}}(),Xm=st.clearTimeout!==we.clearTimeout&&st.clearTimeout,Zm=Dt&&Dt.now!==we.Date.now&&Dt.now,tv=st.setTimeout!==we.setTimeout&&st.setTimeout,Qa=ir.ceil,Ja=ir.floor,Tu=qe.getOwnPropertySymbols,ev=Ka?Ka.isBuffer:e,Af=st.isFinite,rv=$a.join,iv=mf(qe.keys,qe),nr=ir.max,wr=ir.min,nv=Dt.now,sv=st.parseInt,Sf=ir.random,ov=$a.reverse,Fu=gs(st,"DataView"),xo=gs(st,"Map"),Uu=gs(st,"Promise"),zs=gs(st,"Set"),Mo=gs(st,"WeakMap"),Co=gs(qe,"create"),Xa=Mo&&new Mo,ks={},av=ms(Fu),cv=ms(xo),uv=ms(Uu),hv=ms(zs),lv=ms(Mo),Za=Bn?Bn.prototype:e,Po=Za?Za.valueOf:e,If=Za?Za.toString:e;function D(n){if(We(n)&&!ie(n)&&!(n instanceof ge)){if(n instanceof pi)return n;if(Ne.call(n,"__wrapped__"))return D0(n)}return new pi(n)}var Hs=function(){function n(){}return function(o){if(!Ge(o))return{};if(bf)return bf(o);n.prototype=o;var c=new n;return n.prototype=e,c}}();function tc(){}function pi(n,o){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=e}D.templateSettings={escape:De,evaluate:Wt,interpolate:Kt,variable:"",imports:{_:D}},D.prototype=tc.prototype,D.prototype.constructor=D,pi.prototype=Hs(tc.prototype),pi.prototype.constructor=pi;function ge(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function fv(){var n=new ge(this.__wrapped__);return n.__actions__=Br(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=Br(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=Br(this.__views__),n}function dv(){if(this.__filtered__){var n=new ge(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function pv(){var n=this.__wrapped__.value(),o=this.__dir__,c=ie(n),g=o<0,A=c?n.length:0,P=Dy(0,A,this.__views__),H=P.start,W=P.end,X=W-H,ot=g?W:H-1,ct=this.__iteratees__,dt=ct.length,vt=0,Ft=wr(X,this.__takeCount__);if(!c||!g&&A==X&&Ft==X)return Yf(n,this.__actions__);var kt=[];t:for(;X--&&vt<Ft;){ot+=o;for(var ue=-1,Ht=n[ot];++ue<dt;){var fe=ct[ue],be=fe.iteratee,Zr=fe.type,Mr=be(Ht);if(Zr==b)Ht=Mr;else if(!Mr){if(Zr==y)continue t;break t}}kt[vt++]=Ht}return kt}ge.prototype=Hs(tc.prototype),ge.prototype.constructor=ge;function ls(n){var o=-1,c=n==null?0:n.length;for(this.clear();++o<c;){var g=n[o];this.set(g[0],g[1])}}function gv(){this.__data__=Co?Co(null):{},this.size=0}function mv(n){var o=this.has(n)&&delete this.__data__[n];return this.size-=o?1:0,o}function vv(n){var o=this.__data__;if(Co){var c=o[n];return c===m?e:c}return Ne.call(o,n)?o[n]:e}function yv(n){var o=this.__data__;return Co?o[n]!==e:Ne.call(o,n)}function wv(n,o){var c=this.__data__;return this.size+=this.has(n)?0:1,c[n]=Co&&o===e?m:o,this}ls.prototype.clear=gv,ls.prototype.delete=mv,ls.prototype.get=vv,ls.prototype.has=yv,ls.prototype.set=wv;function fn(n){var o=-1,c=n==null?0:n.length;for(this.clear();++o<c;){var g=n[o];this.set(g[0],g[1])}}function bv(){this.__data__=[],this.size=0}function _v(n){var o=this.__data__,c=ec(o,n);if(c<0)return!1;var g=o.length-1;return c==g?o.pop():Wa.call(o,c,1),--this.size,!0}function Ev(n){var o=this.__data__,c=ec(o,n);return c<0?e:o[c][1]}function Av(n){return ec(this.__data__,n)>-1}function Sv(n,o){var c=this.__data__,g=ec(c,n);return g<0?(++this.size,c.push([n,o])):c[g][1]=o,this}fn.prototype.clear=bv,fn.prototype.delete=_v,fn.prototype.get=Ev,fn.prototype.has=Av,fn.prototype.set=Sv;function dn(n){var o=-1,c=n==null?0:n.length;for(this.clear();++o<c;){var g=n[o];this.set(g[0],g[1])}}function Iv(){this.size=0,this.__data__={hash:new ls,map:new(xo||fn),string:new ls}}function Dv(n){var o=dc(this,n).delete(n);return this.size-=o?1:0,o}function xv(n){return dc(this,n).get(n)}function Mv(n){return dc(this,n).has(n)}function Cv(n,o){var c=dc(this,n),g=c.size;return c.set(n,o),this.size+=c.size==g?0:1,this}dn.prototype.clear=Iv,dn.prototype.delete=Dv,dn.prototype.get=xv,dn.prototype.has=Mv,dn.prototype.set=Cv;function fs(n){var o=-1,c=n==null?0:n.length;for(this.__data__=new dn;++o<c;)this.add(n[o])}function Pv(n){return this.__data__.set(n,m),this}function Ov(n){return this.__data__.has(n)}fs.prototype.add=fs.prototype.push=Pv,fs.prototype.has=Ov;function Pi(n){var o=this.__data__=new fn(n);this.size=o.size}function Nv(){this.__data__=new fn,this.size=0}function Rv(n){var o=this.__data__,c=o.delete(n);return this.size=o.size,c}function Tv(n){return this.__data__.get(n)}function Fv(n){return this.__data__.has(n)}function Uv(n,o){var c=this.__data__;if(c instanceof fn){var g=c.__data__;if(!xo||g.length<s-1)return g.push([n,o]),this.size=++c.size,this;c=this.__data__=new dn(g)}return c.set(n,o),this.size=c.size,this}Pi.prototype.clear=Nv,Pi.prototype.delete=Rv,Pi.prototype.get=Tv,Pi.prototype.has=Fv,Pi.prototype.set=Uv;function Df(n,o){var c=ie(n),g=!c&&vs(n),A=!c&&!g&&zn(n),P=!c&&!g&&!A&&Ws(n),H=c||g||A||P,W=H?Pu(n.length,Vm):[],X=W.length;for(var ot in n)(o||Ne.call(n,ot))&&!(H&&(ot=="length"||A&&(ot=="offset"||ot=="parent")||P&&(ot=="buffer"||ot=="byteLength"||ot=="byteOffset")||vn(ot,X)))&&W.push(ot);return W}function xf(n){var o=n.length;return o?n[Gu(0,o-1)]:e}function Bv(n,o){return pc(Br(n),ds(o,0,n.length))}function Lv(n){return pc(Br(n))}function Bu(n,o,c){(c!==e&&!Oi(n[o],c)||c===e&&!(o in n))&&pn(n,o,c)}function Oo(n,o,c){var g=n[o];(!(Ne.call(n,o)&&Oi(g,c))||c===e&&!(o in n))&&pn(n,o,c)}function ec(n,o){for(var c=n.length;c--;)if(Oi(n[c][0],o))return c;return-1}function qv(n,o,c,g){return Ln(n,function(A,P,H){o(g,A,c(A),H)}),g}function Mf(n,o){return n&&Ki(o,ur(o),n)}function jv(n,o){return n&&Ki(o,qr(o),n)}function pn(n,o,c){o=="__proto__"&&Ya?Ya(n,o,{configurable:!0,enumerable:!0,value:c,writable:!0}):n[o]=c}function Lu(n,o){for(var c=-1,g=o.length,A=rt(g),P=n==null;++c<g;)A[c]=P?e:yh(n,o[c]);return A}function ds(n,o,c){return n===n&&(c!==e&&(n=n<=c?n:c),o!==e&&(n=n>=o?n:o)),n}function gi(n,o,c,g,A,P){var H,W=o&E,X=o&x,ot=o&I;if(c&&(H=A?c(n,g,A,P):c(n)),H!==e)return H;if(!Ge(n))return n;var ct=ie(n);if(ct){if(H=My(n),!W)return Br(n,H)}else{var dt=br(n),vt=dt==et||dt==ut;if(zn(n))return Xf(n,W);if(dt==It||dt==_||vt&&!A){if(H=X||vt?{}:v0(n),!W)return X?vy(n,jv(H,n)):my(n,Mf(H,n))}else{if(!Fe[dt])return A?n:{};H=Cy(n,dt,W)}}P||(P=new Pi);var Ft=P.get(n);if(Ft)return Ft;P.set(n,H),V0(n)?n.forEach(function(Ht){H.add(gi(Ht,o,c,Ht,n,P))}):H0(n)&&n.forEach(function(Ht,fe){H.set(fe,gi(Ht,o,c,fe,n,P))});var kt=ot?X?nh:ih:X?qr:ur,ue=ct?e:kt(n);return fi(ue||n,function(Ht,fe){ue&&(fe=Ht,Ht=n[fe]),Oo(H,fe,gi(Ht,o,c,fe,n,P))}),H}function $v(n){var o=ur(n);return function(c){return Cf(c,n,o)}}function Cf(n,o,c){var g=c.length;if(n==null)return!g;for(n=qe(n);g--;){var A=c[g],P=o[A],H=n[A];if(H===e&&!(A in n)||!P(H))return!1}return!0}function Pf(n,o,c){if(typeof n!="function")throw new di(u);return Lo(function(){n.apply(e,c)},o)}function No(n,o,c,g){var A=-1,P=La,H=!0,W=n.length,X=[],ot=o.length;if(!W)return X;c&&(o=ke(o,Qr(c))),g?(P=Su,H=!1):o.length>=s&&(P=Io,H=!1,o=new fs(o));t:for(;++A<W;){var ct=n[A],dt=c==null?ct:c(ct);if(ct=g||ct!==0?ct:0,H&&dt===dt){for(var vt=ot;vt--;)if(o[vt]===dt)continue t;X.push(ct)}else P(o,dt,g)||X.push(ct)}return X}var Ln=i0(Hi),Of=i0(ju,!0);function zv(n,o){var c=!0;return Ln(n,function(g,A,P){return c=!!o(g,A,P),c}),c}function rc(n,o,c){for(var g=-1,A=n.length;++g<A;){var P=n[g],H=o(P);if(H!=null&&(W===e?H===H&&!Xr(H):c(H,W)))var W=H,X=P}return X}function kv(n,o,c,g){var A=n.length;for(c=ae(c),c<0&&(c=-c>A?0:A+c),g=g===e||g>A?A:ae(g),g<0&&(g+=A),g=c>g?0:W0(g);c<g;)n[c++]=o;return n}function Nf(n,o){var c=[];return Ln(n,function(g,A,P){o(g,A,P)&&c.push(g)}),c}function fr(n,o,c,g,A){var P=-1,H=n.length;for(c||(c=Oy),A||(A=[]);++P<H;){var W=n[P];o>0&&c(W)?o>1?fr(W,o-1,c,g,A):Fn(A,W):g||(A[A.length]=W)}return A}var qu=n0(),Rf=n0(!0);function Hi(n,o){return n&&qu(n,o,ur)}function ju(n,o){return n&&Rf(n,o,ur)}function ic(n,o){return Tn(o,function(c){return yn(n[c])})}function ps(n,o){o=jn(o,n);for(var c=0,g=o.length;n!=null&&c<g;)n=n[Vi(o[c++])];return c&&c==g?n:e}function Tf(n,o,c){var g=o(n);return ie(n)?g:Fn(g,c(n))}function Dr(n){return n==null?n===e?Vt:Pt:hs&&hs in qe(n)?Iy(n):Ly(n)}function $u(n,o){return n>o}function Hv(n,o){return n!=null&&Ne.call(n,o)}function Kv(n,o){return n!=null&&o in qe(n)}function Vv(n,o,c){return n>=wr(o,c)&&n<nr(o,c)}function zu(n,o,c){for(var g=c?Su:La,A=n[0].length,P=n.length,H=P,W=rt(P),X=1/0,ot=[];H--;){var ct=n[H];H&&o&&(ct=ke(ct,Qr(o))),X=wr(ct.length,X),W[H]=!c&&(o||A>=120&&ct.length>=120)?new fs(H&&ct):e}ct=n[0];var dt=-1,vt=W[0];t:for(;++dt<A&&ot.length<X;){var Ft=ct[dt],kt=o?o(Ft):Ft;if(Ft=c||Ft!==0?Ft:0,!(vt?Io(vt,kt):g(ot,kt,c))){for(H=P;--H;){var ue=W[H];if(!(ue?Io(ue,kt):g(n[H],kt,c)))continue t}vt&&vt.push(kt),ot.push(Ft)}}return ot}function Gv(n,o,c,g){return Hi(n,function(A,P,H){o(g,c(A),P,H)}),g}function Ro(n,o,c){o=jn(o,n),n=_0(n,o);var g=n==null?n:n[Vi(vi(o))];return g==null?e:cr(g,n,c)}function Ff(n){return We(n)&&Dr(n)==_}function Wv(n){return We(n)&&Dr(n)==Ut}function Yv(n){return We(n)&&Dr(n)==k}function To(n,o,c,g,A){return n===o?!0:n==null||o==null||!We(n)&&!We(o)?n!==n&&o!==o:Qv(n,o,c,g,To,A)}function Qv(n,o,c,g,A,P){var H=ie(n),W=ie(o),X=H?Z:br(n),ot=W?Z:br(o);X=X==_?It:X,ot=ot==_?It:ot;var ct=X==It,dt=ot==It,vt=X==ot;if(vt&&zn(n)){if(!zn(o))return!1;H=!0,ct=!1}if(vt&&!ct)return P||(P=new Pi),H||Ws(n)?p0(n,o,c,g,A,P):Ay(n,o,X,c,g,A,P);if(!(c&N)){var Ft=ct&&Ne.call(n,"__wrapped__"),kt=dt&&Ne.call(o,"__wrapped__");if(Ft||kt){var ue=Ft?n.value():n,Ht=kt?o.value():o;return P||(P=new Pi),A(ue,Ht,c,g,P)}}return vt?(P||(P=new Pi),Sy(n,o,c,g,A,P)):!1}function Jv(n){return We(n)&&br(n)==at}function ku(n,o,c,g){var A=c.length,P=A,H=!g;if(n==null)return!P;for(n=qe(n);A--;){var W=c[A];if(H&&W[2]?W[1]!==n[W[0]]:!(W[0]in n))return!1}for(;++A<P;){W=c[A];var X=W[0],ot=n[X],ct=W[1];if(H&&W[2]){if(ot===e&&!(X in n))return!1}else{var dt=new Pi;if(g)var vt=g(ot,ct,X,n,o,dt);if(!(vt===e?To(ct,ot,N|Y,g,dt):vt))return!1}}return!0}function Uf(n){if(!Ge(n)||Ry(n))return!1;var o=yn(n)?Jm:ci;return o.test(ms(n))}function Xv(n){return We(n)&&Dr(n)==xt}function Zv(n){return We(n)&&br(n)==Bt}function ty(n){return We(n)&&bc(n.length)&&!!Ue[Dr(n)]}function Bf(n){return typeof n=="function"?n:n==null?jr:typeof n=="object"?ie(n)?jf(n[0],n[1]):qf(n):sd(n)}function Hu(n){if(!Bo(n))return iv(n);var o=[];for(var c in qe(n))Ne.call(n,c)&&c!="constructor"&&o.push(c);return o}function ey(n){if(!Ge(n))return By(n);var o=Bo(n),c=[];for(var g in n)g=="constructor"&&(o||!Ne.call(n,g))||c.push(g);return c}function Ku(n,o){return n<o}function Lf(n,o){var c=-1,g=Lr(n)?rt(n.length):[];return Ln(n,function(A,P,H){g[++c]=o(A,P,H)}),g}function qf(n){var o=oh(n);return o.length==1&&o[0][2]?w0(o[0][0],o[0][1]):function(c){return c===n||ku(c,n,o)}}function jf(n,o){return ch(n)&&y0(o)?w0(Vi(n),o):function(c){var g=yh(c,n);return g===e&&g===o?wh(c,n):To(o,g,N|Y)}}function nc(n,o,c,g,A){n!==o&&qu(o,function(P,H){if(A||(A=new Pi),Ge(P))ry(n,o,H,c,nc,g,A);else{var W=g?g(hh(n,H),P,H+"",n,o,A):e;W===e&&(W=P),Bu(n,H,W)}},qr)}function ry(n,o,c,g,A,P,H){var W=hh(n,c),X=hh(o,c),ot=H.get(X);if(ot){Bu(n,c,ot);return}var ct=P?P(W,X,c+"",n,o,H):e,dt=ct===e;if(dt){var vt=ie(X),Ft=!vt&&zn(X),kt=!vt&&!Ft&&Ws(X);ct=X,vt||Ft||kt?ie(W)?ct=W:Je(W)?ct=Br(W):Ft?(dt=!1,ct=Xf(X,!0)):kt?(dt=!1,ct=Zf(X,!0)):ct=[]:qo(X)||vs(X)?(ct=W,vs(W)?ct=Y0(W):(!Ge(W)||yn(W))&&(ct=v0(X))):dt=!1}dt&&(H.set(X,ct),A(ct,X,g,P,H),H.delete(X)),Bu(n,c,ct)}function $f(n,o){var c=n.length;if(c)return o+=o<0?c:0,vn(o,c)?n[o]:e}function zf(n,o,c){o.length?o=ke(o,function(P){return ie(P)?function(H){return ps(H,P.length===1?P[0]:P)}:P}):o=[jr];var g=-1;o=ke(o,Qr(jt()));var A=Lf(n,function(P,H,W){var X=ke(o,function(ot){return ot(P)});return{criteria:X,index:++g,value:P}});return Cm(A,function(P,H){return gy(P,H,c)})}function iy(n,o){return kf(n,o,function(c,g){return wh(n,g)})}function kf(n,o,c){for(var g=-1,A=o.length,P={};++g<A;){var H=o[g],W=ps(n,H);c(W,H)&&Fo(P,jn(H,n),W)}return P}function ny(n){return function(o){return ps(o,n)}}function Vu(n,o,c,g){var A=g?Mm:Bs,P=-1,H=o.length,W=n;for(n===o&&(o=Br(o)),c&&(W=ke(n,Qr(c)));++P<H;)for(var X=0,ot=o[P],ct=c?c(ot):ot;(X=A(W,ct,X,g))>-1;)W!==n&&Wa.call(W,X,1),Wa.call(n,X,1);return n}function Hf(n,o){for(var c=n?o.length:0,g=c-1;c--;){var A=o[c];if(c==g||A!==P){var P=A;vn(A)?Wa.call(n,A,1):Qu(n,A)}}return n}function Gu(n,o){return n+Ja(Sf()*(o-n+1))}function sy(n,o,c,g){for(var A=-1,P=nr(Qa((o-n)/(c||1)),0),H=rt(P);P--;)H[g?P:++A]=n,n+=c;return H}function Wu(n,o){var c="";if(!n||o<1||o>R)return c;do o%2&&(c+=n),o=Ja(o/2),o&&(n+=n);while(o);return c}function he(n,o){return lh(b0(n,o,jr),n+"")}function oy(n){return xf(Ys(n))}function ay(n,o){var c=Ys(n);return pc(c,ds(o,0,c.length))}function Fo(n,o,c,g){if(!Ge(n))return n;o=jn(o,n);for(var A=-1,P=o.length,H=P-1,W=n;W!=null&&++A<P;){var X=Vi(o[A]),ot=c;if(X==="__proto__"||X==="constructor"||X==="prototype")return n;if(A!=H){var ct=W[X];ot=g?g(ct,X,W):e,ot===e&&(ot=Ge(ct)?ct:vn(o[A+1])?[]:{})}Oo(W,X,ot),W=W[X]}return n}var Kf=Xa?function(n,o){return Xa.set(n,o),n}:jr,cy=Ya?function(n,o){return Ya(n,"toString",{configurable:!0,enumerable:!1,value:_h(o),writable:!0})}:jr;function uy(n){return pc(Ys(n))}function mi(n,o,c){var g=-1,A=n.length;o<0&&(o=-o>A?0:A+o),c=c>A?A:c,c<0&&(c+=A),A=o>c?0:c-o>>>0,o>>>=0;for(var P=rt(A);++g<A;)P[g]=n[g+o];return P}function hy(n,o){var c;return Ln(n,function(g,A,P){return c=o(g,A,P),!c}),!!c}function sc(n,o,c){var g=0,A=n==null?g:n.length;if(typeof o=="number"&&o===o&&A<=it){for(;g<A;){var P=g+A>>>1,H=n[P];H!==null&&!Xr(H)&&(c?H<=o:H<o)?g=P+1:A=P}return A}return Yu(n,o,jr,c)}function Yu(n,o,c,g){var A=0,P=n==null?0:n.length;if(P===0)return 0;o=c(o);for(var H=o!==o,W=o===null,X=Xr(o),ot=o===e;A<P;){var ct=Ja((A+P)/2),dt=c(n[ct]),vt=dt!==e,Ft=dt===null,kt=dt===dt,ue=Xr(dt);if(H)var Ht=g||kt;else ot?Ht=kt&&(g||vt):W?Ht=kt&&vt&&(g||!Ft):X?Ht=kt&&vt&&!Ft&&(g||!ue):Ft||ue?Ht=!1:Ht=g?dt<=o:dt<o;Ht?A=ct+1:P=ct}return wr(P,O)}function Vf(n,o){for(var c=-1,g=n.length,A=0,P=[];++c<g;){var H=n[c],W=o?o(H):H;if(!c||!Oi(W,X)){var X=W;P[A++]=H===0?0:H}}return P}function Gf(n){return typeof n=="number"?n:Xr(n)?S:+n}function Jr(n){if(typeof n=="string")return n;if(ie(n))return ke(n,Jr)+"";if(Xr(n))return If?If.call(n):"";var o=n+"";return o=="0"&&1/n==-C?"-0":o}function qn(n,o,c){var g=-1,A=La,P=n.length,H=!0,W=[],X=W;if(c)H=!1,A=Su;else if(P>=s){var ot=o?null:_y(n);if(ot)return ja(ot);H=!1,A=Io,X=new fs}else X=o?[]:W;t:for(;++g<P;){var ct=n[g],dt=o?o(ct):ct;if(ct=c||ct!==0?ct:0,H&&dt===dt){for(var vt=X.length;vt--;)if(X[vt]===dt)continue t;o&&X.push(dt),W.push(ct)}else A(X,dt,c)||(X!==W&&X.push(dt),W.push(ct))}return W}function Qu(n,o){return o=jn(o,n),n=_0(n,o),n==null||delete n[Vi(vi(o))]}function Wf(n,o,c,g){return Fo(n,o,c(ps(n,o)),g)}function oc(n,o,c,g){for(var A=n.length,P=g?A:-1;(g?P--:++P<A)&&o(n[P],P,n););return c?mi(n,g?0:P,g?P+1:A):mi(n,g?P+1:0,g?A:P)}function Yf(n,o){var c=n;return c instanceof ge&&(c=c.value()),Iu(o,function(g,A){return A.func.apply(A.thisArg,Fn([g],A.args))},c)}function Ju(n,o,c){var g=n.length;if(g<2)return g?qn(n[0]):[];for(var A=-1,P=rt(g);++A<g;)for(var H=n[A],W=-1;++W<g;)W!=A&&(P[A]=No(P[A]||H,n[W],o,c));return qn(fr(P,1),o,c)}function Qf(n,o,c){for(var g=-1,A=n.length,P=o.length,H={};++g<A;){var W=g<P?o[g]:e;c(H,n[g],W)}return H}function Xu(n){return Je(n)?n:[]}function Zu(n){return typeof n=="function"?n:jr}function jn(n,o){return ie(n)?n:ch(n,o)?[n]:I0(Me(n))}var ly=he;function $n(n,o,c){var g=n.length;return c=c===e?g:c,!o&&c>=g?n:mi(n,o,c)}var Jf=Xm||function(n){return we.clearTimeout(n)};function Xf(n,o){if(o)return n.slice();var c=n.length,g=wf?wf(c):new n.constructor(c);return n.copy(g),g}function th(n){var o=new n.constructor(n.byteLength);return new Va(o).set(new Va(n)),o}function fy(n,o){var c=o?th(n.buffer):n.buffer;return new n.constructor(c,n.byteOffset,n.byteLength)}function dy(n){var o=new n.constructor(n.source,le.exec(n));return o.lastIndex=n.lastIndex,o}function py(n){return Po?qe(Po.call(n)):{}}function Zf(n,o){var c=o?th(n.buffer):n.buffer;return new n.constructor(c,n.byteOffset,n.length)}function t0(n,o){if(n!==o){var c=n!==e,g=n===null,A=n===n,P=Xr(n),H=o!==e,W=o===null,X=o===o,ot=Xr(o);if(!W&&!ot&&!P&&n>o||P&&H&&X&&!W&&!ot||g&&H&&X||!c&&X||!A)return 1;if(!g&&!P&&!ot&&n<o||ot&&c&&A&&!g&&!P||W&&c&&A||!H&&A||!X)return-1}return 0}function gy(n,o,c){for(var g=-1,A=n.criteria,P=o.criteria,H=A.length,W=c.length;++g<H;){var X=t0(A[g],P[g]);if(X){if(g>=W)return X;var ot=c[g];return X*(ot=="desc"?-1:1)}}return n.index-o.index}function e0(n,o,c,g){for(var A=-1,P=n.length,H=c.length,W=-1,X=o.length,ot=nr(P-H,0),ct=rt(X+ot),dt=!g;++W<X;)ct[W]=o[W];for(;++A<H;)(dt||A<P)&&(ct[c[A]]=n[A]);for(;ot--;)ct[W++]=n[A++];return ct}function r0(n,o,c,g){for(var A=-1,P=n.length,H=-1,W=c.length,X=-1,ot=o.length,ct=nr(P-W,0),dt=rt(ct+ot),vt=!g;++A<ct;)dt[A]=n[A];for(var Ft=A;++X<ot;)dt[Ft+X]=o[X];for(;++H<W;)(vt||A<P)&&(dt[Ft+c[H]]=n[A++]);return dt}function Br(n,o){var c=-1,g=n.length;for(o||(o=rt(g));++c<g;)o[c]=n[c];return o}function Ki(n,o,c,g){var A=!c;c||(c={});for(var P=-1,H=o.length;++P<H;){var W=o[P],X=g?g(c[W],n[W],W,c,n):e;X===e&&(X=n[W]),A?pn(c,W,X):Oo(c,W,X)}return c}function my(n,o){return Ki(n,ah(n),o)}function vy(n,o){return Ki(n,g0(n),o)}function ac(n,o){return function(c,g){var A=ie(c)?Em:qv,P=o?o():{};return A(c,n,jt(g,2),P)}}function Ks(n){return he(function(o,c){var g=-1,A=c.length,P=A>1?c[A-1]:e,H=A>2?c[2]:e;for(P=n.length>3&&typeof P=="function"?(A--,P):e,H&&xr(c[0],c[1],H)&&(P=A<3?e:P,A=1),o=qe(o);++g<A;){var W=c[g];W&&n(o,W,g,P)}return o})}function i0(n,o){return function(c,g){if(c==null)return c;if(!Lr(c))return n(c,g);for(var A=c.length,P=o?A:-1,H=qe(c);(o?P--:++P<A)&&g(H[P],P,H)!==!1;);return c}}function n0(n){return function(o,c,g){for(var A=-1,P=qe(o),H=g(o),W=H.length;W--;){var X=H[n?W:++A];if(c(P[X],X,P)===!1)break}return o}}function yy(n,o,c){var g=o&G,A=Uo(n);function P(){var H=this&&this!==we&&this instanceof P?A:n;return H.apply(g?c:this,arguments)}return P}function s0(n){return function(o){o=Me(o);var c=Ls(o)?Ci(o):e,g=c?c[0]:o.charAt(0),A=c?$n(c,1).join(""):o.slice(1);return g[n]()+A}}function Vs(n){return function(o){return Iu(id(rd(o).replace(Ao,"")),n,"")}}function Uo(n){return function(){var o=arguments;switch(o.length){case 0:return new n;case 1:return new n(o[0]);case 2:return new n(o[0],o[1]);case 3:return new n(o[0],o[1],o[2]);case 4:return new n(o[0],o[1],o[2],o[3]);case 5:return new n(o[0],o[1],o[2],o[3],o[4]);case 6:return new n(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new n(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var c=Hs(n.prototype),g=n.apply(c,o);return Ge(g)?g:c}}function wy(n,o,c){var g=Uo(n);function A(){for(var P=arguments.length,H=rt(P),W=P,X=Gs(A);W--;)H[W]=arguments[W];var ot=P<3&&H[0]!==X&&H[P-1]!==X?[]:Un(H,X);if(P-=ot.length,P<c)return h0(n,o,cc,A.placeholder,e,H,ot,e,e,c-P);var ct=this&&this!==we&&this instanceof A?g:n;return cr(ct,this,H)}return A}function o0(n){return function(o,c,g){var A=qe(o);if(!Lr(o)){var P=jt(c,3);o=ur(o),c=function(W){return P(A[W],W,A)}}var H=n(o,c,g);return H>-1?A[P?o[H]:H]:e}}function a0(n){return mn(function(o){var c=o.length,g=c,A=pi.prototype.thru;for(n&&o.reverse();g--;){var P=o[g];if(typeof P!="function")throw new di(u);if(A&&!H&&fc(P)=="wrapper")var H=new pi([],!0)}for(g=H?g:c;++g<c;){P=o[g];var W=fc(P),X=W=="wrapper"?sh(P):e;X&&uh(X[0])&&X[1]==(v|V|z|T)&&!X[4].length&&X[9]==1?H=H[fc(X[0])].apply(H,X[3]):H=P.length==1&&uh(P)?H[W]():H.thru(P)}return function(){var ot=arguments,ct=ot[0];if(H&&ot.length==1&&ie(ct))return H.plant(ct).value();for(var dt=0,vt=c?o[dt].apply(this,ot):ct;++dt<c;)vt=o[dt].call(this,vt);return vt}})}function cc(n,o,c,g,A,P,H,W,X,ot){var ct=o&v,dt=o&G,vt=o&tt,Ft=o&(V|B),kt=o&nt,ue=vt?e:Uo(n);function Ht(){for(var fe=arguments.length,be=rt(fe),Zr=fe;Zr--;)be[Zr]=arguments[Zr];if(Ft)var Mr=Gs(Ht),ti=Om(be,Mr);if(g&&(be=e0(be,g,A,Ft)),P&&(be=r0(be,P,H,Ft)),fe-=ti,Ft&&fe<ot){var Xe=Un(be,Mr);return h0(n,o,cc,Ht.placeholder,c,be,Xe,W,X,ot-fe)}var Ni=dt?c:this,bn=vt?Ni[n]:n;return fe=be.length,W?be=qy(be,W):kt&&fe>1&&be.reverse(),ct&&X<fe&&(be.length=X),this&&this!==we&&this instanceof Ht&&(bn=ue||Uo(bn)),bn.apply(Ni,be)}return Ht}function c0(n,o){return function(c,g){return Gv(c,n,o(g),{})}}function uc(n,o){return function(c,g){var A;if(c===e&&g===e)return o;if(c!==e&&(A=c),g!==e){if(A===e)return g;typeof c=="string"||typeof g=="string"?(c=Jr(c),g=Jr(g)):(c=Gf(c),g=Gf(g)),A=n(c,g)}return A}}function eh(n){return mn(function(o){return o=ke(o,Qr(jt())),he(function(c){var g=this;return n(o,function(A){return cr(A,g,c)})})})}function hc(n,o){o=o===e?" ":Jr(o);var c=o.length;if(c<2)return c?Wu(o,n):o;var g=Wu(o,Qa(n/qs(o)));return Ls(o)?$n(Ci(g),0,n).join(""):g.slice(0,n)}function by(n,o,c,g){var A=o&G,P=Uo(n);function H(){for(var W=-1,X=arguments.length,ot=-1,ct=g.length,dt=rt(ct+X),vt=this&&this!==we&&this instanceof H?P:n;++ot<ct;)dt[ot]=g[ot];for(;X--;)dt[ot++]=arguments[++W];return cr(vt,A?c:this,dt)}return H}function u0(n){return function(o,c,g){return g&&typeof g!="number"&&xr(o,c,g)&&(c=g=e),o=wn(o),c===e?(c=o,o=0):c=wn(c),g=g===e?o<c?1:-1:wn(g),sy(o,c,g,n)}}function lc(n){return function(o,c){return typeof o=="string"&&typeof c=="string"||(o=yi(o),c=yi(c)),n(o,c)}}function h0(n,o,c,g,A,P,H,W,X,ot){var ct=o&V,dt=ct?H:e,vt=ct?e:H,Ft=ct?P:e,kt=ct?e:P;o|=ct?z:$,o&=~(ct?$:z),o&K||(o&=~(G|tt));var ue=[n,o,A,Ft,dt,kt,vt,W,X,ot],Ht=c.apply(e,ue);return uh(n)&&E0(Ht,ue),Ht.placeholder=g,A0(Ht,n,o)}function rh(n){var o=ir[n];return function(c,g){if(c=yi(c),g=g==null?0:wr(ae(g),292),g&&Af(c)){var A=(Me(c)+"e").split("e"),P=o(A[0]+"e"+(+A[1]+g));return A=(Me(P)+"e").split("e"),+(A[0]+"e"+(+A[1]-g))}return o(c)}}var _y=zs&&1/ja(new zs([,-0]))[1]==C?function(n){return new zs(n)}:Sh;function l0(n){return function(o){var c=br(o);return c==at?Nu(o):c==Bt?Lm(o):Pm(o,n(o))}}function gn(n,o,c,g,A,P,H,W){var X=o&tt;if(!X&&typeof n!="function")throw new di(u);var ot=g?g.length:0;if(ot||(o&=~(z|$),g=A=e),H=H===e?H:nr(ae(H),0),W=W===e?W:ae(W),ot-=A?A.length:0,o&$){var ct=g,dt=A;g=A=e}var vt=X?e:sh(n),Ft=[n,o,c,g,A,ct,dt,P,H,W];if(vt&&Uy(Ft,vt),n=Ft[0],o=Ft[1],c=Ft[2],g=Ft[3],A=Ft[4],W=Ft[9]=Ft[9]===e?X?0:n.length:nr(Ft[9]-ot,0),!W&&o&(V|B)&&(o&=~(V|B)),!o||o==G)var kt=yy(n,o,c);else o==V||o==B?kt=wy(n,o,W):(o==z||o==(G|z))&&!A.length?kt=by(n,o,c,g):kt=cc.apply(e,Ft);var ue=vt?Kf:E0;return A0(ue(kt,Ft),n,o)}function f0(n,o,c,g){return n===e||Oi(n,$s[c])&&!Ne.call(g,c)?o:n}function d0(n,o,c,g,A,P){return Ge(n)&&Ge(o)&&(P.set(o,n),nc(n,o,e,d0,P),P.delete(o)),n}function Ey(n){return qo(n)?e:n}function p0(n,o,c,g,A,P){var H=c&N,W=n.length,X=o.length;if(W!=X&&!(H&&X>W))return!1;var ot=P.get(n),ct=P.get(o);if(ot&&ct)return ot==o&&ct==n;var dt=-1,vt=!0,Ft=c&Y?new fs:e;for(P.set(n,o),P.set(o,n);++dt<W;){var kt=n[dt],ue=o[dt];if(g)var Ht=H?g(ue,kt,dt,o,n,P):g(kt,ue,dt,n,o,P);if(Ht!==e){if(Ht)continue;vt=!1;break}if(Ft){if(!Du(o,function(fe,be){if(!Io(Ft,be)&&(kt===fe||A(kt,fe,c,g,P)))return Ft.push(be)})){vt=!1;break}}else if(!(kt===ue||A(kt,ue,c,g,P))){vt=!1;break}}return P.delete(n),P.delete(o),vt}function Ay(n,o,c,g,A,P,H){switch(c){case bt:if(n.byteLength!=o.byteLength||n.byteOffset!=o.byteOffset)return!1;n=n.buffer,o=o.buffer;case Ut:return!(n.byteLength!=o.byteLength||!P(new Va(n),new Va(o)));case L:case k:case Mt:return Oi(+n,+o);case F:return n.name==o.name&&n.message==o.message;case xt:case _t:return n==o+"";case at:var W=Nu;case Bt:var X=g&N;if(W||(W=ja),n.size!=o.size&&!X)return!1;var ot=H.get(n);if(ot)return ot==o;g|=Y,H.set(n,o);var ct=p0(W(n),W(o),g,A,P,H);return H.delete(n),ct;case Et:if(Po)return Po.call(n)==Po.call(o)}return!1}function Sy(n,o,c,g,A,P){var H=c&N,W=ih(n),X=W.length,ot=ih(o),ct=ot.length;if(X!=ct&&!H)return!1;for(var dt=X;dt--;){var vt=W[dt];if(!(H?vt in o:Ne.call(o,vt)))return!1}var Ft=P.get(n),kt=P.get(o);if(Ft&&kt)return Ft==o&&kt==n;var ue=!0;P.set(n,o),P.set(o,n);for(var Ht=H;++dt<X;){vt=W[dt];var fe=n[vt],be=o[vt];if(g)var Zr=H?g(be,fe,vt,o,n,P):g(fe,be,vt,n,o,P);if(!(Zr===e?fe===be||A(fe,be,c,g,P):Zr)){ue=!1;break}Ht||(Ht=vt=="constructor")}if(ue&&!Ht){var Mr=n.constructor,ti=o.constructor;Mr!=ti&&"constructor"in n&&"constructor"in o&&!(typeof Mr=="function"&&Mr instanceof Mr&&typeof ti=="function"&&ti instanceof ti)&&(ue=!1)}return P.delete(n),P.delete(o),ue}function mn(n){return lh(b0(n,e,C0),n+"")}function ih(n){return Tf(n,ur,ah)}function nh(n){return Tf(n,qr,g0)}var sh=Xa?function(n){return Xa.get(n)}:Sh;function fc(n){for(var o=n.name+"",c=ks[o],g=Ne.call(ks,o)?c.length:0;g--;){var A=c[g],P=A.func;if(P==null||P==n)return A.name}return o}function Gs(n){var o=Ne.call(D,"placeholder")?D:n;return o.placeholder}function jt(){var n=D.iteratee||Eh;return n=n===Eh?Bf:n,arguments.length?n(arguments[0],arguments[1]):n}function dc(n,o){var c=n.__data__;return Ny(o)?c[typeof o=="string"?"string":"hash"]:c.map}function oh(n){for(var o=ur(n),c=o.length;c--;){var g=o[c],A=n[g];o[c]=[g,A,y0(A)]}return o}function gs(n,o){var c=Fm(n,o);return Uf(c)?c:e}function Iy(n){var o=Ne.call(n,hs),c=n[hs];try{n[hs]=e;var g=!0}catch{}var A=Ha.call(n);return g&&(o?n[hs]=c:delete n[hs]),A}var ah=Tu?function(n){return n==null?[]:(n=qe(n),Tn(Tu(n),function(o){return _f.call(n,o)}))}:Ih,g0=Tu?function(n){for(var o=[];n;)Fn(o,ah(n)),n=Ga(n);return o}:Ih,br=Dr;(Fu&&br(new Fu(new ArrayBuffer(1)))!=bt||xo&&br(new xo)!=at||Uu&&br(Uu.resolve())!=Ee||zs&&br(new zs)!=Bt||Mo&&br(new Mo)!=wt)&&(br=function(n){var o=Dr(n),c=o==It?n.constructor:e,g=c?ms(c):"";if(g)switch(g){case av:return bt;case cv:return at;case uv:return Ee;case hv:return Bt;case lv:return wt}return o});function Dy(n,o,c){for(var g=-1,A=c.length;++g<A;){var P=c[g],H=P.size;switch(P.type){case"drop":n+=H;break;case"dropRight":o-=H;break;case"take":o=wr(o,n+H);break;case"takeRight":n=nr(n,o-H);break}}return{start:n,end:o}}function xy(n){var o=n.match(qt);return o?o[1].split(Te):[]}function m0(n,o,c){o=jn(o,n);for(var g=-1,A=o.length,P=!1;++g<A;){var H=Vi(o[g]);if(!(P=n!=null&&c(n,H)))break;n=n[H]}return P||++g!=A?P:(A=n==null?0:n.length,!!A&&bc(A)&&vn(H,A)&&(ie(n)||vs(n)))}function My(n){var o=n.length,c=new n.constructor(o);return o&&typeof n[0]=="string"&&Ne.call(n,"index")&&(c.index=n.index,c.input=n.input),c}function v0(n){return typeof n.constructor=="function"&&!Bo(n)?Hs(Ga(n)):{}}function Cy(n,o,c){var g=n.constructor;switch(o){case Ut:return th(n);case L:case k:return new g(+n);case bt:return fy(n,c);case Ct:case Lt:case Ot:case Nt:case se:case Tt:case Rt:case Ke:case ce:return Zf(n,c);case at:return new g;case Mt:case _t:return new g(n);case xt:return dy(n);case Bt:return new g;case Et:return py(n)}}function Py(n,o){var c=o.length;if(!c)return n;var g=c-1;return o[g]=(c>1?"& ":"")+o[g],o=o.join(c>2?", ":" "),n.replace(Qt,`{
25
+ /* [wrapped with `+o+`] */
26
+ `)}function Oy(n){return ie(n)||vs(n)||!!(Ef&&n&&n[Ef])}function vn(n,o){var c=typeof n;return o=o??R,!!o&&(c=="number"||c!="symbol"&&hi.test(n))&&n>-1&&n%1==0&&n<o}function xr(n,o,c){if(!Ge(c))return!1;var g=typeof o;return(g=="number"?Lr(c)&&vn(o,c.length):g=="string"&&o in c)?Oi(c[o],n):!1}function ch(n,o){if(ie(n))return!1;var c=typeof n;return c=="number"||c=="symbol"||c=="boolean"||n==null||Xr(n)?!0:Jt.test(n)||!Ae.test(n)||o!=null&&n in qe(o)}function Ny(n){var o=typeof n;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?n!=="__proto__":n===null}function uh(n){var o=fc(n),c=D[o];if(typeof c!="function"||!(o in ge.prototype))return!1;if(n===c)return!0;var g=sh(c);return!!g&&n===g[0]}function Ry(n){return!!yf&&yf in n}var Ty=za?yn:Dh;function Bo(n){var o=n&&n.constructor,c=typeof o=="function"&&o.prototype||$s;return n===c}function y0(n){return n===n&&!Ge(n)}function w0(n,o){return function(c){return c==null?!1:c[n]===o&&(o!==e||n in qe(c))}}function Fy(n){var o=yc(n,function(g){return c.size===f&&c.clear(),g}),c=o.cache;return o}function Uy(n,o){var c=n[1],g=o[1],A=c|g,P=A<(G|tt|v),H=g==v&&c==V||g==v&&c==T&&n[7].length<=o[8]||g==(v|T)&&o[7].length<=o[8]&&c==V;if(!(P||H))return n;g&G&&(n[2]=o[2],A|=c&G?0:K);var W=o[3];if(W){var X=n[3];n[3]=X?e0(X,W,o[4]):W,n[4]=X?Un(n[3],w):o[4]}return W=o[5],W&&(X=n[5],n[5]=X?r0(X,W,o[6]):W,n[6]=X?Un(n[5],w):o[6]),W=o[7],W&&(n[7]=W),g&v&&(n[8]=n[8]==null?o[8]:wr(n[8],o[8])),n[9]==null&&(n[9]=o[9]),n[0]=o[0],n[1]=A,n}function By(n){var o=[];if(n!=null)for(var c in qe(n))o.push(c);return o}function Ly(n){return Ha.call(n)}function b0(n,o,c){return o=nr(o===e?n.length-1:o,0),function(){for(var g=arguments,A=-1,P=nr(g.length-o,0),H=rt(P);++A<P;)H[A]=g[o+A];A=-1;for(var W=rt(o+1);++A<o;)W[A]=g[A];return W[o]=c(H),cr(n,this,W)}}function _0(n,o){return o.length<2?n:ps(n,mi(o,0,-1))}function qy(n,o){for(var c=n.length,g=wr(o.length,c),A=Br(n);g--;){var P=o[g];n[g]=vn(P,c)?A[P]:e}return n}function hh(n,o){if(!(o==="constructor"&&typeof n[o]=="function")&&o!="__proto__")return n[o]}var E0=S0(Kf),Lo=tv||function(n,o){return we.setTimeout(n,o)},lh=S0(cy);function A0(n,o,c){var g=o+"";return lh(n,Py(g,jy(xy(g),c)))}function S0(n){var o=0,c=0;return function(){var g=nv(),A=h-(g-c);if(c=g,A>0){if(++o>=mt)return arguments[0]}else o=0;return n.apply(e,arguments)}}function pc(n,o){var c=-1,g=n.length,A=g-1;for(o=o===e?g:o;++c<o;){var P=Gu(c,A),H=n[P];n[P]=n[c],n[c]=H}return n.length=o,n}var I0=Fy(function(n){var o=[];return n.charCodeAt(0)===46&&o.push(""),n.replace(Xt,function(c,g,A,P){o.push(A?P.replace(xi,"$1"):g||c)}),o});function Vi(n){if(typeof n=="string"||Xr(n))return n;var o=n+"";return o=="0"&&1/n==-C?"-0":o}function ms(n){if(n!=null){try{return ka.call(n)}catch{}try{return n+""}catch{}}return""}function jy(n,o){return fi(lt,function(c){var g="_."+c[0];o&c[1]&&!La(n,g)&&n.push(g)}),n.sort()}function D0(n){if(n instanceof ge)return n.clone();var o=new pi(n.__wrapped__,n.__chain__);return o.__actions__=Br(n.__actions__),o.__index__=n.__index__,o.__values__=n.__values__,o}function $y(n,o,c){(c?xr(n,o,c):o===e)?o=1:o=nr(ae(o),0);var g=n==null?0:n.length;if(!g||o<1)return[];for(var A=0,P=0,H=rt(Qa(g/o));A<g;)H[P++]=mi(n,A,A+=o);return H}function zy(n){for(var o=-1,c=n==null?0:n.length,g=0,A=[];++o<c;){var P=n[o];P&&(A[g++]=P)}return A}function ky(){var n=arguments.length;if(!n)return[];for(var o=rt(n-1),c=arguments[0],g=n;g--;)o[g-1]=arguments[g];return Fn(ie(c)?Br(c):[c],fr(o,1))}var Hy=he(function(n,o){return Je(n)?No(n,fr(o,1,Je,!0)):[]}),Ky=he(function(n,o){var c=vi(o);return Je(c)&&(c=e),Je(n)?No(n,fr(o,1,Je,!0),jt(c,2)):[]}),Vy=he(function(n,o){var c=vi(o);return Je(c)&&(c=e),Je(n)?No(n,fr(o,1,Je,!0),e,c):[]});function Gy(n,o,c){var g=n==null?0:n.length;return g?(o=c||o===e?1:ae(o),mi(n,o<0?0:o,g)):[]}function Wy(n,o,c){var g=n==null?0:n.length;return g?(o=c||o===e?1:ae(o),o=g-o,mi(n,0,o<0?0:o)):[]}function Yy(n,o){return n&&n.length?oc(n,jt(o,3),!0,!0):[]}function Qy(n,o){return n&&n.length?oc(n,jt(o,3),!0):[]}function Jy(n,o,c,g){var A=n==null?0:n.length;return A?(c&&typeof c!="number"&&xr(n,o,c)&&(c=0,g=A),kv(n,o,c,g)):[]}function x0(n,o,c){var g=n==null?0:n.length;if(!g)return-1;var A=c==null?0:ae(c);return A<0&&(A=nr(g+A,0)),qa(n,jt(o,3),A)}function M0(n,o,c){var g=n==null?0:n.length;if(!g)return-1;var A=g-1;return c!==e&&(A=ae(c),A=c<0?nr(g+A,0):wr(A,g-1)),qa(n,jt(o,3),A,!0)}function C0(n){var o=n==null?0:n.length;return o?fr(n,1):[]}function Xy(n){var o=n==null?0:n.length;return o?fr(n,C):[]}function Zy(n,o){var c=n==null?0:n.length;return c?(o=o===e?1:ae(o),fr(n,o)):[]}function tw(n){for(var o=-1,c=n==null?0:n.length,g={};++o<c;){var A=n[o];g[A[0]]=A[1]}return g}function P0(n){return n&&n.length?n[0]:e}function ew(n,o,c){var g=n==null?0:n.length;if(!g)return-1;var A=c==null?0:ae(c);return A<0&&(A=nr(g+A,0)),Bs(n,o,A)}function rw(n){var o=n==null?0:n.length;return o?mi(n,0,-1):[]}var iw=he(function(n){var o=ke(n,Xu);return o.length&&o[0]===n[0]?zu(o):[]}),nw=he(function(n){var o=vi(n),c=ke(n,Xu);return o===vi(c)?o=e:c.pop(),c.length&&c[0]===n[0]?zu(c,jt(o,2)):[]}),sw=he(function(n){var o=vi(n),c=ke(n,Xu);return o=typeof o=="function"?o:e,o&&c.pop(),c.length&&c[0]===n[0]?zu(c,e,o):[]});function ow(n,o){return n==null?"":rv.call(n,o)}function vi(n){var o=n==null?0:n.length;return o?n[o-1]:e}function aw(n,o,c){var g=n==null?0:n.length;if(!g)return-1;var A=g;return c!==e&&(A=ae(c),A=A<0?nr(g+A,0):wr(A,g-1)),o===o?jm(n,o,A):qa(n,hf,A,!0)}function cw(n,o){return n&&n.length?$f(n,ae(o)):e}var uw=he(O0);function O0(n,o){return n&&n.length&&o&&o.length?Vu(n,o):n}function hw(n,o,c){return n&&n.length&&o&&o.length?Vu(n,o,jt(c,2)):n}function lw(n,o,c){return n&&n.length&&o&&o.length?Vu(n,o,e,c):n}var fw=mn(function(n,o){var c=n==null?0:n.length,g=Lu(n,o);return Hf(n,ke(o,function(A){return vn(A,c)?+A:A}).sort(t0)),g});function dw(n,o){var c=[];if(!(n&&n.length))return c;var g=-1,A=[],P=n.length;for(o=jt(o,3);++g<P;){var H=n[g];o(H,g,n)&&(c.push(H),A.push(g))}return Hf(n,A),c}function fh(n){return n==null?n:ov.call(n)}function pw(n,o,c){var g=n==null?0:n.length;return g?(c&&typeof c!="number"&&xr(n,o,c)?(o=0,c=g):(o=o==null?0:ae(o),c=c===e?g:ae(c)),mi(n,o,c)):[]}function gw(n,o){return sc(n,o)}function mw(n,o,c){return Yu(n,o,jt(c,2))}function vw(n,o){var c=n==null?0:n.length;if(c){var g=sc(n,o);if(g<c&&Oi(n[g],o))return g}return-1}function yw(n,o){return sc(n,o,!0)}function ww(n,o,c){return Yu(n,o,jt(c,2),!0)}function bw(n,o){var c=n==null?0:n.length;if(c){var g=sc(n,o,!0)-1;if(Oi(n[g],o))return g}return-1}function _w(n){return n&&n.length?Vf(n):[]}function Ew(n,o){return n&&n.length?Vf(n,jt(o,2)):[]}function Aw(n){var o=n==null?0:n.length;return o?mi(n,1,o):[]}function Sw(n,o,c){return n&&n.length?(o=c||o===e?1:ae(o),mi(n,0,o<0?0:o)):[]}function Iw(n,o,c){var g=n==null?0:n.length;return g?(o=c||o===e?1:ae(o),o=g-o,mi(n,o<0?0:o,g)):[]}function Dw(n,o){return n&&n.length?oc(n,jt(o,3),!1,!0):[]}function xw(n,o){return n&&n.length?oc(n,jt(o,3)):[]}var Mw=he(function(n){return qn(fr(n,1,Je,!0))}),Cw=he(function(n){var o=vi(n);return Je(o)&&(o=e),qn(fr(n,1,Je,!0),jt(o,2))}),Pw=he(function(n){var o=vi(n);return o=typeof o=="function"?o:e,qn(fr(n,1,Je,!0),e,o)});function Ow(n){return n&&n.length?qn(n):[]}function Nw(n,o){return n&&n.length?qn(n,jt(o,2)):[]}function Rw(n,o){return o=typeof o=="function"?o:e,n&&n.length?qn(n,e,o):[]}function dh(n){if(!(n&&n.length))return[];var o=0;return n=Tn(n,function(c){if(Je(c))return o=nr(c.length,o),!0}),Pu(o,function(c){return ke(n,xu(c))})}function N0(n,o){if(!(n&&n.length))return[];var c=dh(n);return o==null?c:ke(c,function(g){return cr(o,e,g)})}var Tw=he(function(n,o){return Je(n)?No(n,o):[]}),Fw=he(function(n){return Ju(Tn(n,Je))}),Uw=he(function(n){var o=vi(n);return Je(o)&&(o=e),Ju(Tn(n,Je),jt(o,2))}),Bw=he(function(n){var o=vi(n);return o=typeof o=="function"?o:e,Ju(Tn(n,Je),e,o)}),Lw=he(dh);function qw(n,o){return Qf(n||[],o||[],Oo)}function jw(n,o){return Qf(n||[],o||[],Fo)}var $w=he(function(n){var o=n.length,c=o>1?n[o-1]:e;return c=typeof c=="function"?(n.pop(),c):e,N0(n,c)});function R0(n){var o=D(n);return o.__chain__=!0,o}function zw(n,o){return o(n),n}function gc(n,o){return o(n)}var kw=mn(function(n){var o=n.length,c=o?n[0]:0,g=this.__wrapped__,A=function(P){return Lu(P,n)};return o>1||this.__actions__.length||!(g instanceof ge)||!vn(c)?this.thru(A):(g=g.slice(c,+c+(o?1:0)),g.__actions__.push({func:gc,args:[A],thisArg:e}),new pi(g,this.__chain__).thru(function(P){return o&&!P.length&&P.push(e),P}))});function Hw(){return R0(this)}function Kw(){return new pi(this.value(),this.__chain__)}function Vw(){this.__values__===e&&(this.__values__=G0(this.value()));var n=this.__index__>=this.__values__.length,o=n?e:this.__values__[this.__index__++];return{done:n,value:o}}function Gw(){return this}function Ww(n){for(var o,c=this;c instanceof tc;){var g=D0(c);g.__index__=0,g.__values__=e,o?A.__wrapped__=g:o=g;var A=g;c=c.__wrapped__}return A.__wrapped__=n,o}function Yw(){var n=this.__wrapped__;if(n instanceof ge){var o=n;return this.__actions__.length&&(o=new ge(this)),o=o.reverse(),o.__actions__.push({func:gc,args:[fh],thisArg:e}),new pi(o,this.__chain__)}return this.thru(fh)}function Qw(){return Yf(this.__wrapped__,this.__actions__)}var Jw=ac(function(n,o,c){Ne.call(n,c)?++n[c]:pn(n,c,1)});function Xw(n,o,c){var g=ie(n)?cf:zv;return c&&xr(n,o,c)&&(o=e),g(n,jt(o,3))}function Zw(n,o){var c=ie(n)?Tn:Nf;return c(n,jt(o,3))}var tb=o0(x0),eb=o0(M0);function rb(n,o){return fr(mc(n,o),1)}function ib(n,o){return fr(mc(n,o),C)}function nb(n,o,c){return c=c===e?1:ae(c),fr(mc(n,o),c)}function T0(n,o){var c=ie(n)?fi:Ln;return c(n,jt(o,3))}function F0(n,o){var c=ie(n)?Am:Of;return c(n,jt(o,3))}var sb=ac(function(n,o,c){Ne.call(n,c)?n[c].push(o):pn(n,c,[o])});function ob(n,o,c,g){n=Lr(n)?n:Ys(n),c=c&&!g?ae(c):0;var A=n.length;return c<0&&(c=nr(A+c,0)),_c(n)?c<=A&&n.indexOf(o,c)>-1:!!A&&Bs(n,o,c)>-1}var ab=he(function(n,o,c){var g=-1,A=typeof o=="function",P=Lr(n)?rt(n.length):[];return Ln(n,function(H){P[++g]=A?cr(o,H,c):Ro(H,o,c)}),P}),cb=ac(function(n,o,c){pn(n,c,o)});function mc(n,o){var c=ie(n)?ke:Lf;return c(n,jt(o,3))}function ub(n,o,c,g){return n==null?[]:(ie(o)||(o=o==null?[]:[o]),c=g?e:c,ie(c)||(c=c==null?[]:[c]),zf(n,o,c))}var hb=ac(function(n,o,c){n[c?0:1].push(o)},function(){return[[],[]]});function lb(n,o,c){var g=ie(n)?Iu:ff,A=arguments.length<3;return g(n,jt(o,4),c,A,Ln)}function fb(n,o,c){var g=ie(n)?Sm:ff,A=arguments.length<3;return g(n,jt(o,4),c,A,Of)}function db(n,o){var c=ie(n)?Tn:Nf;return c(n,wc(jt(o,3)))}function pb(n){var o=ie(n)?xf:oy;return o(n)}function gb(n,o,c){(c?xr(n,o,c):o===e)?o=1:o=ae(o);var g=ie(n)?Bv:ay;return g(n,o)}function mb(n){var o=ie(n)?Lv:uy;return o(n)}function vb(n){if(n==null)return 0;if(Lr(n))return _c(n)?qs(n):n.length;var o=br(n);return o==at||o==Bt?n.size:Hu(n).length}function yb(n,o,c){var g=ie(n)?Du:hy;return c&&xr(n,o,c)&&(o=e),g(n,jt(o,3))}var wb=he(function(n,o){if(n==null)return[];var c=o.length;return c>1&&xr(n,o[0],o[1])?o=[]:c>2&&xr(o[0],o[1],o[2])&&(o=[o[0]]),zf(n,fr(o,1),[])}),vc=Zm||function(){return we.Date.now()};function bb(n,o){if(typeof o!="function")throw new di(u);return n=ae(n),function(){if(--n<1)return o.apply(this,arguments)}}function U0(n,o,c){return o=c?e:o,o=n&&o==null?n.length:o,gn(n,v,e,e,e,e,o)}function B0(n,o){var c;if(typeof o!="function")throw new di(u);return n=ae(n),function(){return--n>0&&(c=o.apply(this,arguments)),n<=1&&(o=e),c}}var ph=he(function(n,o,c){var g=G;if(c.length){var A=Un(c,Gs(ph));g|=z}return gn(n,g,o,c,A)}),L0=he(function(n,o,c){var g=G|tt;if(c.length){var A=Un(c,Gs(L0));g|=z}return gn(o,g,n,c,A)});function q0(n,o,c){o=c?e:o;var g=gn(n,V,e,e,e,e,e,o);return g.placeholder=q0.placeholder,g}function j0(n,o,c){o=c?e:o;var g=gn(n,B,e,e,e,e,e,o);return g.placeholder=j0.placeholder,g}function $0(n,o,c){var g,A,P,H,W,X,ot=0,ct=!1,dt=!1,vt=!0;if(typeof n!="function")throw new di(u);o=yi(o)||0,Ge(c)&&(ct=!!c.leading,dt="maxWait"in c,P=dt?nr(yi(c.maxWait)||0,o):P,vt="trailing"in c?!!c.trailing:vt);function Ft(Xe){var Ni=g,bn=A;return g=A=e,ot=Xe,H=n.apply(bn,Ni),H}function kt(Xe){return ot=Xe,W=Lo(fe,o),ct?Ft(Xe):H}function ue(Xe){var Ni=Xe-X,bn=Xe-ot,od=o-Ni;return dt?wr(od,P-bn):od}function Ht(Xe){var Ni=Xe-X,bn=Xe-ot;return X===e||Ni>=o||Ni<0||dt&&bn>=P}function fe(){var Xe=vc();if(Ht(Xe))return be(Xe);W=Lo(fe,ue(Xe))}function be(Xe){return W=e,vt&&g?Ft(Xe):(g=A=e,H)}function Zr(){W!==e&&Jf(W),ot=0,g=X=A=W=e}function Mr(){return W===e?H:be(vc())}function ti(){var Xe=vc(),Ni=Ht(Xe);if(g=arguments,A=this,X=Xe,Ni){if(W===e)return kt(X);if(dt)return Jf(W),W=Lo(fe,o),Ft(X)}return W===e&&(W=Lo(fe,o)),H}return ti.cancel=Zr,ti.flush=Mr,ti}var _b=he(function(n,o){return Pf(n,1,o)}),Eb=he(function(n,o,c){return Pf(n,yi(o)||0,c)});function Ab(n){return gn(n,nt)}function yc(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new di(u);var c=function(){var g=arguments,A=o?o.apply(this,g):g[0],P=c.cache;if(P.has(A))return P.get(A);var H=n.apply(this,g);return c.cache=P.set(A,H)||P,H};return c.cache=new(yc.Cache||dn),c}yc.Cache=dn;function wc(n){if(typeof n!="function")throw new di(u);return function(){var o=arguments;switch(o.length){case 0:return!n.call(this);case 1:return!n.call(this,o[0]);case 2:return!n.call(this,o[0],o[1]);case 3:return!n.call(this,o[0],o[1],o[2])}return!n.apply(this,o)}}function Sb(n){return B0(2,n)}var Ib=ly(function(n,o){o=o.length==1&&ie(o[0])?ke(o[0],Qr(jt())):ke(fr(o,1),Qr(jt()));var c=o.length;return he(function(g){for(var A=-1,P=wr(g.length,c);++A<P;)g[A]=o[A].call(this,g[A]);return cr(n,this,g)})}),gh=he(function(n,o){var c=Un(o,Gs(gh));return gn(n,z,e,o,c)}),z0=he(function(n,o){var c=Un(o,Gs(z0));return gn(n,$,e,o,c)}),Db=mn(function(n,o){return gn(n,T,e,e,e,o)});function xb(n,o){if(typeof n!="function")throw new di(u);return o=o===e?o:ae(o),he(n,o)}function Mb(n,o){if(typeof n!="function")throw new di(u);return o=o==null?0:nr(ae(o),0),he(function(c){var g=c[o],A=$n(c,0,o);return g&&Fn(A,g),cr(n,this,A)})}function Cb(n,o,c){var g=!0,A=!0;if(typeof n!="function")throw new di(u);return Ge(c)&&(g="leading"in c?!!c.leading:g,A="trailing"in c?!!c.trailing:A),$0(n,o,{leading:g,maxWait:o,trailing:A})}function Pb(n){return U0(n,1)}function Ob(n,o){return gh(Zu(o),n)}function Nb(){if(!arguments.length)return[];var n=arguments[0];return ie(n)?n:[n]}function Rb(n){return gi(n,I)}function Tb(n,o){return o=typeof o=="function"?o:e,gi(n,I,o)}function Fb(n){return gi(n,E|I)}function Ub(n,o){return o=typeof o=="function"?o:e,gi(n,E|I,o)}function Bb(n,o){return o==null||Cf(n,o,ur(o))}function Oi(n,o){return n===o||n!==n&&o!==o}var Lb=lc($u),qb=lc(function(n,o){return n>=o}),vs=Ff(function(){return arguments}())?Ff:function(n){return We(n)&&Ne.call(n,"callee")&&!_f.call(n,"callee")},ie=rt.isArray,jb=Ir?Qr(Ir):Wv;function Lr(n){return n!=null&&bc(n.length)&&!yn(n)}function Je(n){return We(n)&&Lr(n)}function $b(n){return n===!0||n===!1||We(n)&&Dr(n)==L}var zn=ev||Dh,zb=Mi?Qr(Mi):Yv;function kb(n){return We(n)&&n.nodeType===1&&!qo(n)}function Hb(n){if(n==null)return!0;if(Lr(n)&&(ie(n)||typeof n=="string"||typeof n.splice=="function"||zn(n)||Ws(n)||vs(n)))return!n.length;var o=br(n);if(o==at||o==Bt)return!n.size;if(Bo(n))return!Hu(n).length;for(var c in n)if(Ne.call(n,c))return!1;return!0}function Kb(n,o){return To(n,o)}function Vb(n,o,c){c=typeof c=="function"?c:e;var g=c?c(n,o):e;return g===e?To(n,o,e,c):!!g}function mh(n){if(!We(n))return!1;var o=Dr(n);return o==F||o==d||typeof n.message=="string"&&typeof n.name=="string"&&!qo(n)}function Gb(n){return typeof n=="number"&&Af(n)}function yn(n){if(!Ge(n))return!1;var o=Dr(n);return o==et||o==ut||o==U||o==$t}function k0(n){return typeof n=="number"&&n==ae(n)}function bc(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=R}function Ge(n){var o=typeof n;return n!=null&&(o=="object"||o=="function")}function We(n){return n!=null&&typeof n=="object"}var H0=li?Qr(li):Jv;function Wb(n,o){return n===o||ku(n,o,oh(o))}function Yb(n,o,c){return c=typeof c=="function"?c:e,ku(n,o,oh(o),c)}function Qb(n){return K0(n)&&n!=+n}function Jb(n){if(Ty(n))throw new ee(a);return Uf(n)}function Xb(n){return n===null}function Zb(n){return n==null}function K0(n){return typeof n=="number"||We(n)&&Dr(n)==Mt}function qo(n){if(!We(n)||Dr(n)!=It)return!1;var o=Ga(n);if(o===null)return!0;var c=Ne.call(o,"constructor")&&o.constructor;return typeof c=="function"&&c instanceof c&&ka.call(c)==Ym}var vh=ki?Qr(ki):Xv;function t2(n){return k0(n)&&n>=-R&&n<=R}var V0=So?Qr(So):Zv;function _c(n){return typeof n=="string"||!ie(n)&&We(n)&&Dr(n)==_t}function Xr(n){return typeof n=="symbol"||We(n)&&Dr(n)==Et}var Ws=us?Qr(us):ty;function e2(n){return n===e}function r2(n){return We(n)&&br(n)==wt}function i2(n){return We(n)&&Dr(n)==At}var n2=lc(Ku),s2=lc(function(n,o){return n<=o});function G0(n){if(!n)return[];if(Lr(n))return _c(n)?Ci(n):Br(n);if(Do&&n[Do])return Bm(n[Do]());var o=br(n),c=o==at?Nu:o==Bt?ja:Ys;return c(n)}function wn(n){if(!n)return n===0?n:0;if(n=yi(n),n===C||n===-C){var o=n<0?-1:1;return o*j}return n===n?n:0}function ae(n){var o=wn(n),c=o%1;return o===o?c?o-c:o:0}function W0(n){return n?ds(ae(n),0,p):0}function yi(n){if(typeof n=="number")return n;if(Xr(n))return S;if(Ge(n)){var o=typeof n.valueOf=="function"?n.valueOf():n;n=Ge(o)?o+"":o}if(typeof n!="string")return n===0?n:+n;n=df(n);var c=ai.test(n);return c||ui.test(n)?re(n.slice(2),c?2:8):oi.test(n)?S:+n}function Y0(n){return Ki(n,qr(n))}function o2(n){return n?ds(ae(n),-R,R):n===0?n:0}function Me(n){return n==null?"":Jr(n)}var a2=Ks(function(n,o){if(Bo(o)||Lr(o)){Ki(o,ur(o),n);return}for(var c in o)Ne.call(o,c)&&Oo(n,c,o[c])}),Q0=Ks(function(n,o){Ki(o,qr(o),n)}),Ec=Ks(function(n,o,c,g){Ki(o,qr(o),n,g)}),c2=Ks(function(n,o,c,g){Ki(o,ur(o),n,g)}),u2=mn(Lu);function h2(n,o){var c=Hs(n);return o==null?c:Mf(c,o)}var l2=he(function(n,o){n=qe(n);var c=-1,g=o.length,A=g>2?o[2]:e;for(A&&xr(o[0],o[1],A)&&(g=1);++c<g;)for(var P=o[c],H=qr(P),W=-1,X=H.length;++W<X;){var ot=H[W],ct=n[ot];(ct===e||Oi(ct,$s[ot])&&!Ne.call(n,ot))&&(n[ot]=P[ot])}return n}),f2=he(function(n){return n.push(e,d0),cr(J0,e,n)});function d2(n,o){return uf(n,jt(o,3),Hi)}function p2(n,o){return uf(n,jt(o,3),ju)}function g2(n,o){return n==null?n:qu(n,jt(o,3),qr)}function m2(n,o){return n==null?n:Rf(n,jt(o,3),qr)}function v2(n,o){return n&&Hi(n,jt(o,3))}function y2(n,o){return n&&ju(n,jt(o,3))}function w2(n){return n==null?[]:ic(n,ur(n))}function b2(n){return n==null?[]:ic(n,qr(n))}function yh(n,o,c){var g=n==null?e:ps(n,o);return g===e?c:g}function _2(n,o){return n!=null&&m0(n,o,Hv)}function wh(n,o){return n!=null&&m0(n,o,Kv)}var E2=c0(function(n,o,c){o!=null&&typeof o.toString!="function"&&(o=Ha.call(o)),n[o]=c},_h(jr)),A2=c0(function(n,o,c){o!=null&&typeof o.toString!="function"&&(o=Ha.call(o)),Ne.call(n,o)?n[o].push(c):n[o]=[c]},jt),S2=he(Ro);function ur(n){return Lr(n)?Df(n):Hu(n)}function qr(n){return Lr(n)?Df(n,!0):ey(n)}function I2(n,o){var c={};return o=jt(o,3),Hi(n,function(g,A,P){pn(c,o(g,A,P),g)}),c}function D2(n,o){var c={};return o=jt(o,3),Hi(n,function(g,A,P){pn(c,A,o(g,A,P))}),c}var x2=Ks(function(n,o,c){nc(n,o,c)}),J0=Ks(function(n,o,c,g){nc(n,o,c,g)}),M2=mn(function(n,o){var c={};if(n==null)return c;var g=!1;o=ke(o,function(P){return P=jn(P,n),g||(g=P.length>1),P}),Ki(n,nh(n),c),g&&(c=gi(c,E|x|I,Ey));for(var A=o.length;A--;)Qu(c,o[A]);return c});function C2(n,o){return X0(n,wc(jt(o)))}var P2=mn(function(n,o){return n==null?{}:iy(n,o)});function X0(n,o){if(n==null)return{};var c=ke(nh(n),function(g){return[g]});return o=jt(o),kf(n,c,function(g,A){return o(g,A[0])})}function O2(n,o,c){o=jn(o,n);var g=-1,A=o.length;for(A||(A=1,n=e);++g<A;){var P=n==null?e:n[Vi(o[g])];P===e&&(g=A,P=c),n=yn(P)?P.call(n):P}return n}function N2(n,o,c){return n==null?n:Fo(n,o,c)}function R2(n,o,c,g){return g=typeof g=="function"?g:e,n==null?n:Fo(n,o,c,g)}var Z0=l0(ur),td=l0(qr);function T2(n,o,c){var g=ie(n),A=g||zn(n)||Ws(n);if(o=jt(o,4),c==null){var P=n&&n.constructor;A?c=g?new P:[]:Ge(n)?c=yn(P)?Hs(Ga(n)):{}:c={}}return(A?fi:Hi)(n,function(H,W,X){return o(c,H,W,X)}),c}function F2(n,o){return n==null?!0:Qu(n,o)}function U2(n,o,c){return n==null?n:Wf(n,o,Zu(c))}function B2(n,o,c,g){return g=typeof g=="function"?g:e,n==null?n:Wf(n,o,Zu(c),g)}function Ys(n){return n==null?[]:Ou(n,ur(n))}function L2(n){return n==null?[]:Ou(n,qr(n))}function q2(n,o,c){return c===e&&(c=o,o=e),c!==e&&(c=yi(c),c=c===c?c:0),o!==e&&(o=yi(o),o=o===o?o:0),ds(yi(n),o,c)}function j2(n,o,c){return o=wn(o),c===e?(c=o,o=0):c=wn(c),n=yi(n),Vv(n,o,c)}function $2(n,o,c){if(c&&typeof c!="boolean"&&xr(n,o,c)&&(o=c=e),c===e&&(typeof o=="boolean"?(c=o,o=e):typeof n=="boolean"&&(c=n,n=e)),n===e&&o===e?(n=0,o=1):(n=wn(n),o===e?(o=n,n=0):o=wn(o)),n>o){var g=n;n=o,o=g}if(c||n%1||o%1){var A=Sf();return wr(n+A*(o-n+Be("1e-"+((A+"").length-1))),o)}return Gu(n,o)}var z2=Vs(function(n,o,c){return o=o.toLowerCase(),n+(c?ed(o):o)});function ed(n){return bh(Me(n).toLowerCase())}function rd(n){return n=Me(n),n&&n.replace(ar,Nm).replace(Eu,"")}function k2(n,o,c){n=Me(n),o=Jr(o);var g=n.length;c=c===e?g:ds(ae(c),0,g);var A=c;return c-=o.length,c>=0&&n.slice(c,A)==o}function H2(n){return n=Me(n),n&&zt.test(n)?n.replace(Ar,Rm):n}function K2(n){return n=Me(n),n&&Zt.test(n)?n.replace(xe,"\\$&"):n}var V2=Vs(function(n,o,c){return n+(c?"-":"")+o.toLowerCase()}),G2=Vs(function(n,o,c){return n+(c?" ":"")+o.toLowerCase()}),W2=s0("toLowerCase");function Y2(n,o,c){n=Me(n),o=ae(o);var g=o?qs(n):0;if(!o||g>=o)return n;var A=(o-g)/2;return hc(Ja(A),c)+n+hc(Qa(A),c)}function Q2(n,o,c){n=Me(n),o=ae(o);var g=o?qs(n):0;return o&&g<o?n+hc(o-g,c):n}function J2(n,o,c){n=Me(n),o=ae(o);var g=o?qs(n):0;return o&&g<o?hc(o-g,c)+n:n}function X2(n,o,c){return c||o==null?o=0:o&&(o=+o),sv(Me(n).replace(Yt,""),o||0)}function Z2(n,o,c){return(c?xr(n,o,c):o===e)?o=1:o=ae(o),Wu(Me(n),o)}function t3(){var n=arguments,o=Me(n[0]);return n.length<3?o:o.replace(n[1],n[2])}var e3=Vs(function(n,o,c){return n+(c?"_":"")+o.toLowerCase()});function r3(n,o,c){return c&&typeof c!="number"&&xr(n,o,c)&&(o=c=e),c=c===e?p:c>>>0,c?(n=Me(n),n&&(typeof o=="string"||o!=null&&!vh(o))&&(o=Jr(o),!o&&Ls(n))?$n(Ci(n),0,c):n.split(o,c)):[]}var i3=Vs(function(n,o,c){return n+(c?" ":"")+bh(o)});function n3(n,o,c){return n=Me(n),c=c==null?0:ds(ae(c),0,n.length),o=Jr(o),n.slice(c,c+o.length)==o}function s3(n,o,c){var g=D.templateSettings;c&&xr(n,o,c)&&(o=e),n=Me(n),o=Ec({},o,g,f0);var A=Ec({},o.imports,g.imports,f0),P=ur(A),H=Ou(A,P),W,X,ot=0,ct=o.interpolate||qi,dt="__p += '",vt=Ru((o.escape||qi).source+"|"+ct.source+"|"+(ct===Kt?Oe:qi).source+"|"+(o.evaluate||qi).source+"|$","g"),Ft="//# sourceURL="+(Ne.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Au+"]")+`
27
+ `;n.replace(vt,function(Ht,fe,be,Zr,Mr,ti){return be||(be=Zr),dt+=n.slice(ot,ti).replace(Xn,Tm),fe&&(W=!0,dt+=`' +
28
+ __e(`+fe+`) +
29
+ '`),Mr&&(X=!0,dt+=`';
30
+ `+Mr+`;
31
+ __p += '`),be&&(dt+=`' +
32
+ ((__t = (`+be+`)) == null ? '' : __t) +
33
+ '`),ot=ti+Ht.length,Ht}),dt+=`';
34
+ `;var kt=Ne.call(o,"variable")&&o.variable;if(!kt)dt=`with (obj) {
35
+ `+dt+`
36
+ }
37
+ `;else if(Pe.test(kt))throw new ee(l);dt=(X?dt.replace(pe,""):dt).replace(Ve,"$1").replace(ye,"$1;"),dt="function("+(kt||"obj")+`) {
38
+ `+(kt?"":`obj || (obj = {});
39
+ `)+"var __t, __p = ''"+(W?", __e = _.escape":"")+(X?`, __j = Array.prototype.join;
40
+ function print() { __p += __j.call(arguments, '') }
41
+ `:`;
42
+ `)+dt+`return __p
43
+ }`;var ue=nd(function(){return Se(P,Ft+"return "+dt).apply(e,H)});if(ue.source=dt,mh(ue))throw ue;return ue}function o3(n){return Me(n).toLowerCase()}function a3(n){return Me(n).toUpperCase()}function c3(n,o,c){if(n=Me(n),n&&(c||o===e))return df(n);if(!n||!(o=Jr(o)))return n;var g=Ci(n),A=Ci(o),P=pf(g,A),H=gf(g,A)+1;return $n(g,P,H).join("")}function u3(n,o,c){if(n=Me(n),n&&(c||o===e))return n.slice(0,vf(n)+1);if(!n||!(o=Jr(o)))return n;var g=Ci(n),A=gf(g,Ci(o))+1;return $n(g,0,A).join("")}function h3(n,o,c){if(n=Me(n),n&&(c||o===e))return n.replace(Yt,"");if(!n||!(o=Jr(o)))return n;var g=Ci(n),A=pf(g,Ci(o));return $n(g,A).join("")}function l3(n,o){var c=ft,g=pt;if(Ge(o)){var A="separator"in o?o.separator:A;c="length"in o?ae(o.length):c,g="omission"in o?Jr(o.omission):g}n=Me(n);var P=n.length;if(Ls(n)){var H=Ci(n);P=H.length}if(c>=P)return n;var W=c-qs(g);if(W<1)return g;var X=H?$n(H,0,W).join(""):n.slice(0,W);if(A===e)return X+g;if(H&&(W+=X.length-W),vh(A)){if(n.slice(W).search(A)){var ot,ct=X;for(A.global||(A=Ru(A.source,Me(le.exec(A))+"g")),A.lastIndex=0;ot=A.exec(ct);)var dt=ot.index;X=X.slice(0,dt===e?W:dt)}}else if(n.indexOf(Jr(A),W)!=W){var vt=X.lastIndexOf(A);vt>-1&&(X=X.slice(0,vt))}return X+g}function f3(n){return n=Me(n),n&&Gt.test(n)?n.replace(_e,$m):n}var d3=Vs(function(n,o,c){return n+(c?" ":"")+o.toUpperCase()}),bh=s0("toUpperCase");function id(n,o,c){return n=Me(n),o=c?e:o,o===e?Um(n)?Hm(n):xm(n):n.match(o)||[]}var nd=he(function(n,o){try{return cr(n,e,o)}catch(c){return mh(c)?c:new ee(c)}}),p3=mn(function(n,o){return fi(o,function(c){c=Vi(c),pn(n,c,ph(n[c],n))}),n});function g3(n){var o=n==null?0:n.length,c=jt();return n=o?ke(n,function(g){if(typeof g[1]!="function")throw new di(u);return[c(g[0]),g[1]]}):[],he(function(g){for(var A=-1;++A<o;){var P=n[A];if(cr(P[0],this,g))return cr(P[1],this,g)}})}function m3(n){return $v(gi(n,E))}function _h(n){return function(){return n}}function v3(n,o){return n==null||n!==n?o:n}var y3=a0(),w3=a0(!0);function jr(n){return n}function Eh(n){return Bf(typeof n=="function"?n:gi(n,E))}function b3(n){return qf(gi(n,E))}function _3(n,o){return jf(n,gi(o,E))}var E3=he(function(n,o){return function(c){return Ro(c,n,o)}}),A3=he(function(n,o){return function(c){return Ro(n,c,o)}});function Ah(n,o,c){var g=ur(o),A=ic(o,g);c==null&&!(Ge(o)&&(A.length||!g.length))&&(c=o,o=n,n=this,A=ic(o,ur(o)));var P=!(Ge(c)&&"chain"in c)||!!c.chain,H=yn(n);return fi(A,function(W){var X=o[W];n[W]=X,H&&(n.prototype[W]=function(){var ot=this.__chain__;if(P||ot){var ct=n(this.__wrapped__),dt=ct.__actions__=Br(this.__actions__);return dt.push({func:X,args:arguments,thisArg:n}),ct.__chain__=ot,ct}return X.apply(n,Fn([this.value()],arguments))})}),n}function S3(){return we._===this&&(we._=Qm),this}function Sh(){}function I3(n){return n=ae(n),he(function(o){return $f(o,n)})}var D3=eh(ke),x3=eh(cf),M3=eh(Du);function sd(n){return ch(n)?xu(Vi(n)):ny(n)}function C3(n){return function(o){return n==null?e:ps(n,o)}}var P3=u0(),O3=u0(!0);function Ih(){return[]}function Dh(){return!1}function N3(){return{}}function R3(){return""}function T3(){return!0}function F3(n,o){if(n=ae(n),n<1||n>R)return[];var c=p,g=wr(n,p);o=jt(o),n-=p;for(var A=Pu(g,o);++c<n;)o(c);return A}function U3(n){return ie(n)?ke(n,Vi):Xr(n)?[n]:Br(I0(Me(n)))}function B3(n){var o=++Wm;return Me(n)+o}var L3=uc(function(n,o){return n+o},0),q3=rh("ceil"),j3=uc(function(n,o){return n/o},1),$3=rh("floor");function z3(n){return n&&n.length?rc(n,jr,$u):e}function k3(n,o){return n&&n.length?rc(n,jt(o,2),$u):e}function H3(n){return lf(n,jr)}function K3(n,o){return lf(n,jt(o,2))}function V3(n){return n&&n.length?rc(n,jr,Ku):e}function G3(n,o){return n&&n.length?rc(n,jt(o,2),Ku):e}var W3=uc(function(n,o){return n*o},1),Y3=rh("round"),Q3=uc(function(n,o){return n-o},0);function J3(n){return n&&n.length?Cu(n,jr):0}function X3(n,o){return n&&n.length?Cu(n,jt(o,2)):0}return D.after=bb,D.ary=U0,D.assign=a2,D.assignIn=Q0,D.assignInWith=Ec,D.assignWith=c2,D.at=u2,D.before=B0,D.bind=ph,D.bindAll=p3,D.bindKey=L0,D.castArray=Nb,D.chain=R0,D.chunk=$y,D.compact=zy,D.concat=ky,D.cond=g3,D.conforms=m3,D.constant=_h,D.countBy=Jw,D.create=h2,D.curry=q0,D.curryRight=j0,D.debounce=$0,D.defaults=l2,D.defaultsDeep=f2,D.defer=_b,D.delay=Eb,D.difference=Hy,D.differenceBy=Ky,D.differenceWith=Vy,D.drop=Gy,D.dropRight=Wy,D.dropRightWhile=Yy,D.dropWhile=Qy,D.fill=Jy,D.filter=Zw,D.flatMap=rb,D.flatMapDeep=ib,D.flatMapDepth=nb,D.flatten=C0,D.flattenDeep=Xy,D.flattenDepth=Zy,D.flip=Ab,D.flow=y3,D.flowRight=w3,D.fromPairs=tw,D.functions=w2,D.functionsIn=b2,D.groupBy=sb,D.initial=rw,D.intersection=iw,D.intersectionBy=nw,D.intersectionWith=sw,D.invert=E2,D.invertBy=A2,D.invokeMap=ab,D.iteratee=Eh,D.keyBy=cb,D.keys=ur,D.keysIn=qr,D.map=mc,D.mapKeys=I2,D.mapValues=D2,D.matches=b3,D.matchesProperty=_3,D.memoize=yc,D.merge=x2,D.mergeWith=J0,D.method=E3,D.methodOf=A3,D.mixin=Ah,D.negate=wc,D.nthArg=I3,D.omit=M2,D.omitBy=C2,D.once=Sb,D.orderBy=ub,D.over=D3,D.overArgs=Ib,D.overEvery=x3,D.overSome=M3,D.partial=gh,D.partialRight=z0,D.partition=hb,D.pick=P2,D.pickBy=X0,D.property=sd,D.propertyOf=C3,D.pull=uw,D.pullAll=O0,D.pullAllBy=hw,D.pullAllWith=lw,D.pullAt=fw,D.range=P3,D.rangeRight=O3,D.rearg=Db,D.reject=db,D.remove=dw,D.rest=xb,D.reverse=fh,D.sampleSize=gb,D.set=N2,D.setWith=R2,D.shuffle=mb,D.slice=pw,D.sortBy=wb,D.sortedUniq=_w,D.sortedUniqBy=Ew,D.split=r3,D.spread=Mb,D.tail=Aw,D.take=Sw,D.takeRight=Iw,D.takeRightWhile=Dw,D.takeWhile=xw,D.tap=zw,D.throttle=Cb,D.thru=gc,D.toArray=G0,D.toPairs=Z0,D.toPairsIn=td,D.toPath=U3,D.toPlainObject=Y0,D.transform=T2,D.unary=Pb,D.union=Mw,D.unionBy=Cw,D.unionWith=Pw,D.uniq=Ow,D.uniqBy=Nw,D.uniqWith=Rw,D.unset=F2,D.unzip=dh,D.unzipWith=N0,D.update=U2,D.updateWith=B2,D.values=Ys,D.valuesIn=L2,D.without=Tw,D.words=id,D.wrap=Ob,D.xor=Fw,D.xorBy=Uw,D.xorWith=Bw,D.zip=Lw,D.zipObject=qw,D.zipObjectDeep=jw,D.zipWith=$w,D.entries=Z0,D.entriesIn=td,D.extend=Q0,D.extendWith=Ec,Ah(D,D),D.add=L3,D.attempt=nd,D.camelCase=z2,D.capitalize=ed,D.ceil=q3,D.clamp=q2,D.clone=Rb,D.cloneDeep=Fb,D.cloneDeepWith=Ub,D.cloneWith=Tb,D.conformsTo=Bb,D.deburr=rd,D.defaultTo=v3,D.divide=j3,D.endsWith=k2,D.eq=Oi,D.escape=H2,D.escapeRegExp=K2,D.every=Xw,D.find=tb,D.findIndex=x0,D.findKey=d2,D.findLast=eb,D.findLastIndex=M0,D.findLastKey=p2,D.floor=$3,D.forEach=T0,D.forEachRight=F0,D.forIn=g2,D.forInRight=m2,D.forOwn=v2,D.forOwnRight=y2,D.get=yh,D.gt=Lb,D.gte=qb,D.has=_2,D.hasIn=wh,D.head=P0,D.identity=jr,D.includes=ob,D.indexOf=ew,D.inRange=j2,D.invoke=S2,D.isArguments=vs,D.isArray=ie,D.isArrayBuffer=jb,D.isArrayLike=Lr,D.isArrayLikeObject=Je,D.isBoolean=$b,D.isBuffer=zn,D.isDate=zb,D.isElement=kb,D.isEmpty=Hb,D.isEqual=Kb,D.isEqualWith=Vb,D.isError=mh,D.isFinite=Gb,D.isFunction=yn,D.isInteger=k0,D.isLength=bc,D.isMap=H0,D.isMatch=Wb,D.isMatchWith=Yb,D.isNaN=Qb,D.isNative=Jb,D.isNil=Zb,D.isNull=Xb,D.isNumber=K0,D.isObject=Ge,D.isObjectLike=We,D.isPlainObject=qo,D.isRegExp=vh,D.isSafeInteger=t2,D.isSet=V0,D.isString=_c,D.isSymbol=Xr,D.isTypedArray=Ws,D.isUndefined=e2,D.isWeakMap=r2,D.isWeakSet=i2,D.join=ow,D.kebabCase=V2,D.last=vi,D.lastIndexOf=aw,D.lowerCase=G2,D.lowerFirst=W2,D.lt=n2,D.lte=s2,D.max=z3,D.maxBy=k3,D.mean=H3,D.meanBy=K3,D.min=V3,D.minBy=G3,D.stubArray=Ih,D.stubFalse=Dh,D.stubObject=N3,D.stubString=R3,D.stubTrue=T3,D.multiply=W3,D.nth=cw,D.noConflict=S3,D.noop=Sh,D.now=vc,D.pad=Y2,D.padEnd=Q2,D.padStart=J2,D.parseInt=X2,D.random=$2,D.reduce=lb,D.reduceRight=fb,D.repeat=Z2,D.replace=t3,D.result=O2,D.round=Y3,D.runInContext=J,D.sample=pb,D.size=vb,D.snakeCase=e3,D.some=yb,D.sortedIndex=gw,D.sortedIndexBy=mw,D.sortedIndexOf=vw,D.sortedLastIndex=yw,D.sortedLastIndexBy=ww,D.sortedLastIndexOf=bw,D.startCase=i3,D.startsWith=n3,D.subtract=Q3,D.sum=J3,D.sumBy=X3,D.template=s3,D.times=F3,D.toFinite=wn,D.toInteger=ae,D.toLength=W0,D.toLower=o3,D.toNumber=yi,D.toSafeInteger=o2,D.toString=Me,D.toUpper=a3,D.trim=c3,D.trimEnd=u3,D.trimStart=h3,D.truncate=l3,D.unescape=f3,D.uniqueId=B3,D.upperCase=d3,D.upperFirst=bh,D.each=T0,D.eachRight=F0,D.first=P0,Ah(D,function(){var n={};return Hi(D,function(o,c){Ne.call(D.prototype,c)||(n[c]=o)}),n}(),{chain:!1}),D.VERSION=i,fi(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){D[n].placeholder=D}),fi(["drop","take"],function(n,o){ge.prototype[n]=function(c){c=c===e?1:nr(ae(c),0);var g=this.__filtered__&&!o?new ge(this):this.clone();return g.__filtered__?g.__takeCount__=wr(c,g.__takeCount__):g.__views__.push({size:wr(c,p),type:n+(g.__dir__<0?"Right":"")}),g},ge.prototype[n+"Right"]=function(c){return this.reverse()[n](c).reverse()}}),fi(["filter","map","takeWhile"],function(n,o){var c=o+1,g=c==y||c==M;ge.prototype[n]=function(A){var P=this.clone();return P.__iteratees__.push({iteratee:jt(A,3),type:c}),P.__filtered__=P.__filtered__||g,P}}),fi(["head","last"],function(n,o){var c="take"+(o?"Right":"");ge.prototype[n]=function(){return this[c](1).value()[0]}}),fi(["initial","tail"],function(n,o){var c="drop"+(o?"":"Right");ge.prototype[n]=function(){return this.__filtered__?new ge(this):this[c](1)}}),ge.prototype.compact=function(){return this.filter(jr)},ge.prototype.find=function(n){return this.filter(n).head()},ge.prototype.findLast=function(n){return this.reverse().find(n)},ge.prototype.invokeMap=he(function(n,o){return typeof n=="function"?new ge(this):this.map(function(c){return Ro(c,n,o)})}),ge.prototype.reject=function(n){return this.filter(wc(jt(n)))},ge.prototype.slice=function(n,o){n=ae(n);var c=this;return c.__filtered__&&(n>0||o<0)?new ge(c):(n<0?c=c.takeRight(-n):n&&(c=c.drop(n)),o!==e&&(o=ae(o),c=o<0?c.dropRight(-o):c.take(o-n)),c)},ge.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},ge.prototype.toArray=function(){return this.take(p)},Hi(ge.prototype,function(n,o){var c=/^(?:filter|find|map|reject)|While$/.test(o),g=/^(?:head|last)$/.test(o),A=D[g?"take"+(o=="last"?"Right":""):o],P=g||/^find/.test(o);A&&(D.prototype[o]=function(){var H=this.__wrapped__,W=g?[1]:arguments,X=H instanceof ge,ot=W[0],ct=X||ie(H),dt=function(fe){var be=A.apply(D,Fn([fe],W));return g&&vt?be[0]:be};ct&&c&&typeof ot=="function"&&ot.length!=1&&(X=ct=!1);var vt=this.__chain__,Ft=!!this.__actions__.length,kt=P&&!vt,ue=X&&!Ft;if(!P&&ct){H=ue?H:new ge(this);var Ht=n.apply(H,W);return Ht.__actions__.push({func:gc,args:[dt],thisArg:e}),new pi(Ht,vt)}return kt&&ue?n.apply(this,W):(Ht=this.thru(dt),kt?g?Ht.value()[0]:Ht.value():Ht)})}),fi(["pop","push","shift","sort","splice","unshift"],function(n){var o=$a[n],c=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",g=/^(?:pop|shift)$/.test(n);D.prototype[n]=function(){var A=arguments;if(g&&!this.__chain__){var P=this.value();return o.apply(ie(P)?P:[],A)}return this[c](function(H){return o.apply(ie(H)?H:[],A)})}}),Hi(ge.prototype,function(n,o){var c=D[o];if(c){var g=c.name+"";Ne.call(ks,g)||(ks[g]=[]),ks[g].push({name:o,func:c})}}),ks[cc(e,tt).name]=[{name:"wrapper",func:e}],ge.prototype.clone=fv,ge.prototype.reverse=dv,ge.prototype.value=pv,D.prototype.at=kw,D.prototype.chain=Hw,D.prototype.commit=Kw,D.prototype.next=Vw,D.prototype.plant=Ww,D.prototype.reverse=Yw,D.prototype.toJSON=D.prototype.valueOf=D.prototype.value=Qw,D.prototype.first=D.prototype.head,Do&&(D.prototype[Do]=Gw),D},js=Km();Qe?((Qe.exports=js)._=js,Le._=js):we._=js}).call(Wo)})(Ol,Ol.exports);var r9=Object.defineProperty,i9=Object.defineProperties,n9=Object.getOwnPropertyDescriptors,p1=Object.getOwnPropertySymbols,s9=Object.prototype.hasOwnProperty,o9=Object.prototype.propertyIsEnumerable,g1=(r,t,e)=>t in r?r9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Oc=(r,t)=>{for(var e in t||(t={}))s9.call(t,e)&&g1(r,e,t[e]);if(p1)for(var e of p1(t))o9.call(t,e)&&g1(r,e,t[e]);return r},a9=(r,t)=>i9(r,n9(t));function Yn(r,t,e){var i;const s=Tc(r);return((i=t.rpcMap)==null?void 0:i[s.reference])||`${e9}?chainId=${s.namespace}:${s.reference}&projectId=${e}`}function Ns(r){return r.includes(":")?r.split(":")[1]:r}function bm(r){return r.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function c9(r,t){const e=Object.keys(t.namespaces).filter(s=>s.includes(r));if(!e.length)return[];const i=[];return e.forEach(s=>{const a=t.namespaces[s].accounts;i.push(...a)}),i}function nl(r={},t={}){const e=m1(r),i=m1(t);return Ol.exports.merge(e,i)}function m1(r){var t,e,i,s;const a={};if(!sa(r))return a;for(const[u,l]of Object.entries(r)){const m=Ql(u)?[u]:l.chains,f=l.methods||[],w=l.events||[],E=l.rpcMap||{},x=Jo(u);a[x]=a9(Oc(Oc({},a[x]),l),{chains:Fc(m,(t=a[x])==null?void 0:t.chains),methods:Fc(f,(e=a[x])==null?void 0:e.methods),events:Fc(w,(i=a[x])==null?void 0:i.events),rpcMap:Oc(Oc({},E),(s=a[x])==null?void 0:s.rpcMap)})}return a}function u9(r){return r.includes(":")?r.split(":")[2]:r}function v1(r){const t={};for(const[e,i]of Object.entries(r)){const s=i.methods||[],a=i.events||[],u=i.accounts||[],l=Ql(e)?[e]:i.chains?i.chains:bm(i.accounts);t[e]={chains:l,methods:s,events:a,accounts:u}}return t}function sl(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 _m={},He=r=>_m[r],ol=(r,t)=>{_m[r]=t};class h9{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Jn(i,He("disableProviderPing")))}}var l9=Object.defineProperty,f9=Object.defineProperties,d9=Object.getOwnPropertyDescriptors,y1=Object.getOwnPropertySymbols,p9=Object.prototype.hasOwnProperty,g9=Object.prototype.propertyIsEnumerable,w1=(r,t,e)=>t in r?l9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,b1=(r,t)=>{for(var e in t||(t={}))p9.call(t,e)&&w1(r,e,t[e]);if(y1)for(var e of y1(t))g9.call(t,e)&&w1(r,e,t[e]);return r},_1=(r,t)=>f9(r,d9(t));class m9{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(t)}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const i=e||Yn(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Jn(i,He("disableProviderPing")))}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=parseInt(Ns(e));t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,i;let s=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const a=parseInt(s,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:s}]},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(t){return this.namespace.chains.includes(`${this.name}:${t}`)}async getCapabilities(t){var e,i,s;const a=(i=(e=t.request)==null?void 0:e.params)==null?void 0:i[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const u=this.client.session.get(t.topic),l=((s=u==null?void 0:u.sessionProperties)==null?void 0:s.capabilities)||{};if(l!=null&&l[a])return l==null?void 0:l[a];const m=await this.client.request(t);try{await this.client.session.update(t.topic,{sessionProperties:_1(b1({},u.sessionProperties||{}),{capabilities:_1(b1({},l||{}),{[a]:m})})})}catch(f){console.warn("Failed to update session with capabilities",f)}return m}}class v9{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Jn(i,He("disableProviderPing")))}}class y9{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Jn(i,He("disableProviderPing")))}}class w9{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const i=this.getCardanoRPCUrl(e),s=Ns(e);t[s]=this.createHttpProvider(s,i)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||this.getCardanoRPCUrl(t);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Jn(i,He("disableProviderPing")))}}class b9{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Jn(i,He("disableProviderPing")))}}class _9{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Jn(i,He("disableProviderPing")))}}class E9{constructor(t){this.name="near",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const i=e||Yn(`${this.name}:${t}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,i)}this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;t[e]=this.createHttpProvider(e,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace);return typeof i>"u"?void 0:new Cn(new Jn(i,He("disableProviderPing")))}}var A9=Object.defineProperty,S9=Object.defineProperties,I9=Object.getOwnPropertyDescriptors,E1=Object.getOwnPropertySymbols,D9=Object.prototype.hasOwnProperty,x9=Object.prototype.propertyIsEnumerable,A1=(r,t,e)=>t in r?A9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nc=(r,t)=>{for(var e in t||(t={}))D9.call(t,e)&&A1(r,e,t[e]);if(E1)for(var e of E1(t))x9.call(t,e)&&A1(r,e,t[e]);return r},al=(r,t)=>S9(r,I9(t));class of{constructor(t){this.events=new Fl,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:ya(fu({level:(t==null?void 0:t.logger)||f1})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const e=new of(t);return await e.initialize(),e}async request(t,e,i){const[s,a]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Nc({},t),chainId:`${s}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(t,e,i,s){const a=new Date().getTime();this.request(t,i,s).then(u=>e(null,du(a,u))).catch(u=>e(u,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 t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:Re("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}async authenticate(t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:e,response:i}=await this.client.authenticate(t);e&&(this.uri=e,this.events.emit("display_uri",e));const s=await i();if(this.session=s.session,this.session){const a=v1(this.session.namespaces);this.namespaces=nl(this.namespaces,a),this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:s}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});i&&(this.uri=i,this.events.emit("display_uri",i)),await s().then(a=>{this.session=a;const u=v1(a.namespaces);this.namespaces=nl(this.namespaces,u),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==wm)throw a;e++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[i,s]=this.validateChain(t);this.getProvider(i).setDefaultChain(s,e)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(un(e)){for(const i of e)t.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${e.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 t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await sf.init({logger:this.providerOpts.logger||f1,relayUrl:this.providerOpts.relayUrl||X7,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),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 t=[...new Set(Object.keys(this.session.namespaces).map(e=>Jo(e)))];ol("client",this.client),ol("events",this.events),ol("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const i=c9(e,this.session),s=bm(i),a=nl(this.namespaces,this.optionalNamespaces),u=al(Nc({},a[e]),{accounts:i,chains:s});switch(e){case"eip155":this.rpcProviders[e]=new m9({namespace:u});break;case"solana":this.rpcProviders[e]=new v9({namespace:u});break;case"cosmos":this.rpcProviders[e]=new y9({namespace:u});break;case"polkadot":this.rpcProviders[e]=new h9({namespace:u});break;case"cip34":this.rpcProviders[e]=new w9({namespace:u});break;case"elrond":this.rpcProviders[e]=new b9({namespace:u});break;case"multiversx":this.rpcProviders[e]=new _9({namespace:u});break;case"near":this.rpcProviders[e]=new E9({namespace:u});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:e}=t,{event:i}=e;if(i.name==="accountsChanged"){const s=i.data;s&&un(s)&&this.events.emit("accountsChanged",s.map(u9))}else if(i.name==="chainChanged"){const s=e.chainId,a=e.event.data,u=Jo(s),l=sl(s)!==sl(a)?`${u}:${sl(a)}`:s;this.onChainChanged(l)}else this.events.emit(i.name,i.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var i;const{namespaces:s}=e,a=(i=this.client)==null?void 0:i.session.get(t);this.session=al(Nc({},a),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",al(Nc({},Re("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Pn.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e,optionalNamespaces:i,sessionProperties:s}=t;e&&Object.keys(e).length&&(this.namespaces=e),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=s,this.persist("namespaces",e),this.persist("optionalNamespaces",i)}validateChain(t){const[e,i]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,i];if(e&&!Object.keys(this.namespaces||{}).map(u=>Jo(u)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&i)return[e,i];const s=Jo(Object.keys(this.namespaces)[0]),a=this.rpcProviders[s].getDefaultChain();return[s,a]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,e=!1){if(!this.namespaces)return;const[i,s]=this.validateChain(t);s&&(e||this.getProvider(i).setDefaultChain(s),this.namespaces[i]?this.namespaces[i].defaultChain=s:this.namespaces[`${i}:${s}`]?this.namespaces[`${i}:${s}`].defaultChain=s:this.namespaces[`${i}:${s}`]={defaultChain:s},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",s))}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(t,e){this.client.core.storage.setItem(`${d1}/${t}`,e)}async getFromStore(t){return await this.client.core.storage.getItem(`${d1}/${t}`)}}const M9=of,C9="wc",P9="ethereum_provider",O9=`${C9}@2:${P9}:`,N9="https://rpc.walletconnect.com/v1/",Nl=["eth_sendTransaction","personal_sign"],R9=["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"],Rl=["chainChanged","accountsChanged"],T9=["chainChanged","accountsChanged","message","disconnect","connect"];var F9=Object.defineProperty,U9=Object.defineProperties,B9=Object.getOwnPropertyDescriptors,S1=Object.getOwnPropertySymbols,L9=Object.prototype.hasOwnProperty,q9=Object.prototype.propertyIsEnumerable,I1=(r,t,e)=>t in r?F9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ro=(r,t)=>{for(var e in t||(t={}))L9.call(t,e)&&I1(r,e,t[e]);if(S1)for(var e of S1(t))q9.call(t,e)&&I1(r,e,t[e]);return r},cl=(r,t)=>U9(r,B9(t));function iu(r){return Number(r[0].split(":")[1])}function Rc(r){return`0x${r.toString(16)}`}function j9(r){const{chains:t,optionalChains:e,methods:i,optionalMethods:s,events:a,optionalEvents:u,rpcMap:l}=r;if(!un(t))throw new Error("Invalid chains");const m={chains:t,methods:i||Nl,events:a||Rl,rpcMap:ro({},t.length?{[iu(t)]:l[iu(t)]}:{})},f=a==null?void 0:a.filter(I=>!Rl.includes(I)),w=i==null?void 0:i.filter(I=>!Nl.includes(I));if(!e&&!u&&!s&&!(f!=null&&f.length)&&!(w!=null&&w.length))return{required:t.length?m:void 0};const E=(f==null?void 0:f.length)&&(w==null?void 0:w.length)||!e,x={chains:[...new Set(E?m.chains.concat(e||[]):e)],methods:[...new Set(m.methods.concat(s!=null&&s.length?s:R9))],events:[...new Set(m.events.concat(u!=null&&u.length?u:T9))],rpcMap:l};return{required:t.length?m:void 0,optional:e.length?x:void 0}}class af{constructor(){this.events=new Di.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=O9,this.on=(t,e)=>(this.events.on(t,e),this),this.once=(t,e)=>(this.events.once(t,e),this),this.removeListener=(t,e)=>(this.events.removeListener(t,e),this),this.off=(t,e)=>(this.events.off(t,e),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const e=new af;return await e.initialize(t),e}async request(t,e){return await this.signer.request(t,this.formatChainId(this.chainId),e)}sendAsync(t,e,i){this.signer.sendAsync(t,e,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(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:e,optional:i}=j9(this.rpc);try{const s=await new Promise(async(u,l)=>{var m;this.rpc.showQrModal&&((m=this.modal)==null||m.subscribeModal(f=>{!f.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),l(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(cl(ro({namespaces:ro({},e&&{[this.namespace]:e})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(f=>{u(f)}).catch(f=>{l(new Error(f.message))})});if(!s)return;const a=Cd(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Rc(this.chainId)})}catch(s){throw this.signer.logger.error(s),s}finally{this.modal&&this.modal.closeModal()}}async authenticate(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:t==null?void 0:t.chains});try{const e=await new Promise(async(s,a)=>{var u;this.rpc.showQrModal&&((u=this.modal)==null||u.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(cl(ro({},t),{chains:this.rpc.chains})).then(l=>{s(l)}).catch(l=>{a(new Error(l.message))})}),i=e.session;if(i){const s=Cd(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:Rc(this.chainId)})}return e}catch(e){throw this.signer.logger.error(e),e}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",t=>{const{params:e}=t,{event:i}=e;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",t)}),this.signer.on("chainChanged",t=>{const e=parseInt(t);this.chainId=e,this.events.emit("chainChanged",Rc(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",cl(ro({},Re("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var e,i;this.rpc.showQrModal&&((e=this.modal)==null||e.closeModal(),(i=this.modal)==null||i.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const e=t.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));e.length&&(this.chainId=e[0],this.events.emit("chainChanged",Rc(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const e=this.parseChainId(t);this.chainId=e,this.switchEthereumChain(e)}}parseAccountId(t){const[e,i,s]=t.split(":");return{chainId:`${e}:${i}`,address:s}}setAccounts(t){this.accounts=t.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var e,i;const s=(e=t==null?void 0:t.chains)!=null?e:[],a=(i=t==null?void 0:t.optionalChains)!=null?i:[],u=s.concat(a);if(!u.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const l=s.length?(t==null?void 0:t.methods)||Nl:[],m=s.length?(t==null?void 0:t.events)||Rl:[],f=(t==null?void 0:t.optionalMethods)||[],w=(t==null?void 0:t.optionalEvents)||[],E=(t==null?void 0:t.rpcMap)||this.buildRpcMap(u,t.projectId),x=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:s==null?void 0:s.map(I=>this.formatChainId(I)),optionalChains:a.map(I=>this.formatChainId(I)),methods:l,events:m,optionalMethods:f,optionalEvents:w,rpcMap:E,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:x,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,e){const i={};return t.forEach(s=>{i[s]=this.getRpcUrl(s,e)}),i}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?iu(this.rpc.chains):iu(this.rpc.optionalChains),this.signer=await M9.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{const{WalletConnectModal:i}=await e6(()=>import("./index-ea674524.js").then(s=>s.i),["assets/index-ea674524.js","assets/index-0a6a1b27.js","assets/index-5c0930d1.css"]);e=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(ro({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:e,optionalChains:i,rpcMap:s}=t;e&&un(e)&&(this.rpc.chains=e.map(a=>this.formatChainId(a)),e.forEach(a=>{this.rpc.rpcMap[a]=(s==null?void 0:s[a])||this.getRpcUrl(a)})),i&&un(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i==null?void 0:i.map(a=>this.formatChainId(a)),i.forEach(a=>{this.rpc.rpcMap[a]=(s==null?void 0:s[a])||this.getRpcUrl(a)}))}getRpcUrl(t,e){var i;return((i=this.rpc.rpcMap)==null?void 0:i[t])||`${N9}?chainId=eip155:${t}&projectId=${e||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),e=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:e==null?void 0:e.accounts),this.setAccounts(e==null?void 0:e.accounts)}catch(t){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(t),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(e=>this.parseAccount(e))}}const pM=af;export{pM as EthereumProvider,T9 as OPTIONAL_EVENTS,R9 as OPTIONAL_METHODS,Rl as REQUIRED_EVENTS,Nl as REQUIRED_METHODS,af as default};
44
+ //# sourceMappingURL=index.es-b3caf9c9.js.map