-
Notifications
You must be signed in to change notification settings - Fork 2
/
359.c7360f00b9b465e065e4.js
1 lines (1 loc) · 237 KB
/
359.c7360f00b9b465e065e4.js
1
"use strict";(self.webpackChunktimeless_frontend=self.webpackChunktimeless_frontend||[]).push([[359],{50359:(ur,D,K)=>{K.r(D),K.d(D,{EthereumProvider:()=>$0,OPTIONAL_EVENTS:()=>wl,OPTIONAL_METHODS:()=>bl,REQUIRED_EVENTS:()=>Wi,REQUIRED_METHODS:()=>Hi,default:()=>Ji});var S=K(34553),Le=K(93105),We=K.n(Le),Ze=K(91573),xe=K(37651),Ve=K(52632),Ge=K(41027),it=K(72180),he=K(81361),$=K(14611),tr=(K(63581),K(38541),K(32257),K(9964));const Kh={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}};function Vr(s,e){return!!Array.isArray(s)&&(!(typeof e<"u"&&s.length)||s.every(e))}var np=K(3226),Zn=K(38960),Ae=K(66486),fn=K(52399);class ip extends fn.q{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class sp extends fn.q{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class cp extends fn.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class ap extends fn.q{constructor(e){super()}}class lp extends fn.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class fp extends fn.q{constructor(e,t){super(),this.core=e,this.logger=t}}var Ni=K(62757),xa=function(s,e,t){if(t||2===arguments.length)for(var l,o=0,a=e.length;o<a;o++)(l||!(o in e))&&(l||(l=Array.prototype.slice.call(e,0,o)),l[o]=e[o]);return s.concat(l||Array.prototype.slice.call(e))},vp=function(e,t,o){this.name=e,this.version=t,this.os=o,this.type="browser"},bp=function(e){this.version=e,this.type="node",this.name="node",this.os=process.platform},wp=function(e,t,o,a){this.name=e,this.version=t,this.os=o,this.bot=a,this.type="bot-device"},Ep=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},Ip=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null},Sp=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Np=[["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",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],Ca=[["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 Ta(s){var e=function(s){return""!==s&&Np.reduce(function(e,t){var o=t[0];if(e)return e;var l=t[1].exec(s);return!!l&&[o,l]},!1)}(s);if(!e)return null;var t=e[0],o=e[1];if("searchbot"===t)return new Ep;var a=o[1]&&o[1].split(".").join("_").split("_").slice(0,3);a?a.length<3&&(a=xa(xa([],a,!0),function(s){for(var e=[],t=0;t<s;t++)e.push("0");return e}(3-a.length),!0)):a=[];var l=a.join("."),f=function(s){for(var e=0,t=Ca.length;e<t;e++){var o=Ca[e],a=o[0];if(o[1].exec(s))return a}return null}(s),g=Sp.exec(s);return g&&g[1]?new wp(t,l,f,g[1]):new vp(t,l,f)}var Pi=K(45418),Ap=K(31846),xi=K(34955);function eo(s,e){return s.includes(":")?[s]:e.chains||[]}const yt="base16",ro="base64pad",no="utf8";function oo(){const s=(0,Ve.randomBytes)(32);return(0,he.BB)(s,yt)}function dn(s){const e=(0,Ge.vp)((0,he.mL)(s,no));return(0,he.BB)(e,yt)}function zn(s){return Number((0,he.BB)(s,"base10"))}function Ci(s){const e=(0,he.mL)(s,ro),t=e.slice(0,1);if(1===zn(t)){const g=33,O=g+12,w=e.slice(1,g),R=e.slice(g,O);return{type:t,sealed:e.slice(O),iv:R,senderPublicKey:w}}const l=e.slice(1,13);return{type:t,sealed:e.slice(13),iv:l}}function Ma(s){const e=s?.type||0;if(1===e){if(typeof s?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof s?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:s?.senderPublicKey,receiverPublicKey:s?.receiverPublicKey}}function La(s){return 1===s.type&&"string"==typeof s.senderPublicKey&&"string"==typeof s.receiverPublicKey}var Gp=Object.defineProperty,ka=Object.getOwnPropertySymbols,Jp=Object.prototype.hasOwnProperty,Qp=Object.prototype.propertyIsEnumerable,qa=(s,e,t)=>e in s?Gp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Za=(s,e)=>{for(var t in e||(e={}))Jp.call(e,t)&&qa(s,t,e[t]);if(ka)for(var t of ka(e))Qp.call(e,t)&&qa(s,t,e[t]);return s};const eg="js";function ao(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ka(){return!(0,Pi.getDocument)()&&!!(0,Pi.getNavigator)()&&"ReactNative"===navigator.product}function uo(){return!ao()&&!!(0,Pi.getNavigator)()}function Ai(){return Ka()?"react-native":ao()?"node":uo()?"browser":"unknown"}function sg(s,e,t){const o=function(){if("react-native"===Ai()&&typeof global<"u"&&typeof(null==global?void 0:global.Platform)<"u"){const{OS:t,Version:o}=global.Platform;return[t,o].join("-")}const s=function(s){return s?Ta(s):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new Ip:"undefined"!=typeof navigator?Ta(navigator.userAgent):"undefined"!=typeof process&&process.version?new bp(process.version.slice(1)):null}();if(null===s)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return"browser"===s.type?[e,s.name,s.version].join("-"):[e,s.version].join("-")}(),a=function(){var s;const e=Ai();return"browser"===e?[e,(null==(s=(0,Pi.getLocation)())?void 0:s.host)||"unknown"].join(":"):e}();return[[s,e].join("-"),[eg,t].join("-"),o,a].join("/")}function Wr(s,e){return s.filter(t=>e.includes(t)).length===s.length}function Va(s){return Object.fromEntries(s.entries())}function Ba(s){return new Map(Object.entries(s))}function _n(s=$.FIVE_MINUTES,e){const t=(0,$.toMiliseconds)(s||$.FIVE_MINUTES);let o,a,l;return{resolve:f=>{l&&o&&(clearTimeout(l),o(f))},reject:f=>{l&&a&&(clearTimeout(l),a(f))},done:()=>new Promise((f,g)=>{l=setTimeout(()=>{g(new Error(e))},t),o=f,a=g})}}function Ti(s,e,t){return new Promise(function(){var o=(0,S.Z)(function*(a,l){const f=setTimeout(()=>l(new Error(t)),e);try{a(yield s)}catch(g){l(g)}clearTimeout(f)});return function(a,l){return o.apply(this,arguments)}}())}function Ha(s,e){if("string"==typeof e&&e.startsWith(`${s}:`))return e;if("topic"===s.toLowerCase()){if("string"!=typeof e)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}if("id"===s.toLowerCase()){if("number"!=typeof e)throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function Wa(s){const[e,t]=s.split(":"),o={id:void 0,topic:void 0};if("topic"===e&&"string"==typeof t)o.topic=t;else{if("id"!==e||!Number.isInteger(Number(t)))throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);o.id=Number(t)}return o}function Wt(s,e){return(0,$.fromMiliseconds)((e||Date.now())+(0,$.toMiliseconds)(s))}function Ir(s){return Date.now()>=(0,$.toMiliseconds)(s)}function st(s,e){return`${s}${e?`:${e}`:""}`}function lo(){return(lo=(0,S.Z)(function*({id:s,topic:e,wcDeepLink:t}){try{if(!t)return;let a=("string"==typeof t?JSON.parse(t):t)?.href;if("string"!=typeof a)return;a.endsWith("/")&&(a=a.slice(0,-1));const l=`${a}/wc?requestId=${s}&sessionTopic=${e}`,f=Ai();"browser"===f?l.startsWith("https://")?window.open(l,"_blank","noreferrer noopener"):window.open(l,"_self","noreferrer noopener"):"react-native"===f&&typeof(null==global?void 0:global.Linking)<"u"&&(yield global.Linking.openURL(l))}catch(o){console.error(o)}})).apply(this,arguments)}function fo(s){return s?.relay||{protocol:"irn"}}function ji(s){const e=tr.RELAY_JSONRPC[s];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${s}`);return e}var pg=Object.defineProperty,Ga=Object.getOwnPropertySymbols,gg=Object.prototype.hasOwnProperty,_g=Object.prototype.propertyIsEnumerable,Ja=(s,e,t)=>e in s?pg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;function mg(s,e="-"){const t={},o="relay"+e;return Object.keys(s).forEach(a=>{if(a.startsWith(o)){const l=a.replace(o,"");t[l]=s[a]}}),t}function bg(s){return s.startsWith("//")?s.substring(2):s}function bn(s){const e=[];return s.forEach(t=>{const[o,a]=t.split(":");e.push(`${o}:${a}`)}),e}const Dg={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}},Fg={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 Q(s,e){const{message:t,code:o}=Fg[s];return{message:e?`${t} ${e}`:t,code:o}}function at(s,e){const{message:t,code:o}=Dg[s];return{message:e?`${t} ${e}`:t,code:o}}function Kn(s,e){return!!Array.isArray(s)&&(!(typeof e<"u"&&s.length)||s.every(e))}function wn(s){return Object.getPrototypeOf(s)===Object.prototype&&Object.keys(s).length}function mt(s){return typeof s>"u"}function ut(s,e){return!(!e||!mt(s))||"string"==typeof s&&!!s.trim().length}function ho(s,e){return!(!e||!mt(s))||"number"==typeof s&&!isNaN(s)}function $i(s){return!(!ut(s,!1)||!s.includes(":"))&&2===s.split(":").length}function tu(s){let e=!0;return Kn(s)?s.length&&(e=s.every(t=>ut(t,!1))):e=!1,e}function ru(s,e){let t=null;return Object.values(s).forEach(o=>{if(t)return;const a=function(s,e){let t=null;return tu(s?.methods)?tu(s?.events)||(t=at("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=at("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}(o,`${e}, namespace`);a&&(t=a)}),t}function Di(s,e){let t=null;if(s&&wn(s)){const o=ru(s,e);o&&(t=o);const a=function(s,e){let t=null;return Object.values(s).forEach(o=>{if(t)return;const a=function(s,e){let t=null;return Kn(s)?s.forEach(o=>{t||function(s){if(ut(s,!1)&&s.includes(":")){const e=s.split(":");if(3===e.length){const t=e[0]+":"+e[1];return!!e[2]&&$i(t)}}return!1}(o)||(t=at("UNSUPPORTED_ACCOUNTS",`${e}, account ${o} should be a string and conform to "namespace:chainId:address" format`))}):t=at("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}(o?.accounts,`${e} namespace`);a&&(t=a)}),t}(s,e);a&&(t=a)}else t=Q("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function nu(s){return ut(s.protocol,!0)}function It(s){return typeof s<"u"&&null!==typeof s}function iu(s,e){return!(!$i(e)||!function(s){const e=[];return Object.values(s).forEach(t=>{e.push(...bn(t.accounts))}),e}(s).includes(e))}function po(s,e,t){let o=null;const a=function(s){const e={};return Object.keys(s).forEach(t=>{var o;t.includes(":")?e[t]=s[t]:null==(o=s[t].chains)||o.forEach(a=>{e[a]={methods:s[t].methods,events:s[t].events}})}),e}(s),l=function(s){const e={};return Object.keys(s).forEach(t=>{t.includes(":")?e[t]=s[t]:bn(s[t].accounts)?.forEach(a=>{e[a]={accounts:s[t].accounts.filter(l=>l.includes(`${a}:`)),methods:s[t].methods,events:s[t].events}})}),e}(e),f=Object.keys(a),g=Object.keys(l),O=su(Object.keys(s)),w=su(Object.keys(e)),R=O.filter(T=>!w.includes(T));return R.length&&(o=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.\n Required: ${R.toString()}\n Received: ${Object.keys(e).toString()}`)),Wr(f,g)||(o=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces.\n Required: ${f.toString()}\n Approved: ${g.toString()}`)),Object.keys(e).forEach(T=>{if(!T.includes(":")||o)return;const H=bn(e[T].accounts);H.includes(T)||(o=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${T}\n Required: ${T}\n Approved: ${H.toString()}`))}),f.forEach(T=>{o||(Wr(a[T].methods,l[T].methods)?Wr(a[T].events,l[T].events)||(o=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${T}`)):o=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${T}`))}),o}function su(s){return[...new Set(s.map(e=>e.includes(":")?e.split(":")[0]:e))]}var Or=K(10321),$e=K(22339),o_=K(57808),c_=K(6856),a_=K.n(c_),f_=function(s,e){if(s.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),o=0;o<t.length;o++)t[o]=255;for(var a=0;a<s.length;a++){var l=s.charAt(a),f=l.charCodeAt(0);if(255!==t[f])throw new TypeError(l+" is ambiguous");t[f]=a}var g=s.length,O=s.charAt(0),w=Math.log(g)/Math.log(256),R=Math.log(256)/Math.log(g);function H(Z){if("string"!=typeof Z)throw new TypeError("Expected String");if(0===Z.length)return new Uint8Array;var B=0;if(" "!==Z[B]){for(var Y=0,Fe=0;Z[B]===O;)Y++,B++;for(var Qe=(Z.length-B)*w+1>>>0,De=new Uint8Array(Qe);Z[B];){var _e=t[Z.charCodeAt(B)];if(255===_e)return;for(var re=0,Ie=Qe-1;(0!==_e||re<Fe)&&-1!==Ie;Ie--,re++)De[Ie]=(_e+=g*De[Ie]>>>0)%256>>>0,_e=_e/256>>>0;if(0!==_e)throw new Error("Non-zero carry");Fe=re,B++}if(" "!==Z[B]){for(var Ue=Qe-Fe;Ue!==Qe&&0===De[Ue];)Ue++;for(var lt=new Uint8Array(Y+(Qe-Ue)),Cr=Y;Ue!==Qe;)lt[Cr++]=De[Ue++];return lt}}}return{encode:function(Z){if(Z instanceof Uint8Array||(ArrayBuffer.isView(Z)?Z=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength):Array.isArray(Z)&&(Z=Uint8Array.from(Z))),!(Z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===Z.length)return"";for(var B=0,Y=0,Fe=0,Qe=Z.length;Fe!==Qe&&0===Z[Fe];)Fe++,B++;for(var De=(Qe-Fe)*R+1>>>0,_e=new Uint8Array(De);Fe!==Qe;){for(var re=Z[Fe],Ie=0,Ue=De-1;(0!==re||Ie<Y)&&-1!==Ue;Ue--,Ie++)_e[Ue]=(re+=256*_e[Ue]>>>0)%g>>>0,re=re/g>>>0;if(0!==re)throw new Error("Non-zero carry");Y=Ie,Fe++}for(var lt=De-Y;lt!==De&&0===_e[lt];)lt++;for(var Cr=O.repeat(B);lt<De;++lt)Cr+=s.charAt(_e[lt]);return Cr},decodeUnsafe:H,decode:function(Z){var B=H(Z);if(B)return B;throw new Error(`Non-${e} character`)}}};const ou=s=>{if(s instanceof Uint8Array&&"Uint8Array"===s.constructor.name)return s;if(s instanceof ArrayBuffer)return new Uint8Array(s);if(ArrayBuffer.isView(s))return new Uint8Array(s.buffer,s.byteOffset,s.byteLength);throw new Error("Unknown type, must be binary type")};class p_{constructor(e,t,o){this.name=e,this.prefix=t,this.baseEncode=o}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class g_{constructor(e,t,o){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=o}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return cu(this,e)}}class __{constructor(e){this.decoders=e}or(e){return cu(this,e)}decode(e){const o=this.decoders[e[0]];if(o)return o.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const cu=(s,e)=>new __({...s.decoders||{[s.prefix]:s},...e.decoders||{[e.prefix]:e}});class y_{constructor(e,t,o,a){this.name=e,this.prefix=t,this.baseEncode=o,this.baseDecode=a,this.encoder=new p_(e,t,o),this.decoder=new g_(e,t,a)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Fi=({name:s,prefix:e,encode:t,decode:o})=>new y_(s,e,t,o),Vn=({prefix:s,name:e,alphabet:t})=>{const{encode:o,decode:a}=f_(t,e);return Fi({prefix:s,name:e,encode:o,decode:l=>ou(a(l))})},dt=({name:s,prefix:e,bitsPerChar:t,alphabet:o})=>Fi({prefix:e,name:s,encode:a=>((s,e,t)=>{const o="="===e[e.length-1],a=(1<<t)-1;let l="",f=0,g=0;for(let O=0;O<s.length;++O)for(g=g<<8|s[O],f+=8;f>t;)f-=t,l+=e[a&g>>f];if(f&&(l+=e[a&g<<t-f]),o)for(;l.length*t&7;)l+="=";return l})(a,o,t),decode:a=>((s,e,t,o)=>{const a={};for(let R=0;R<e.length;++R)a[e[R]]=R;let l=s.length;for(;"="===s[l-1];)--l;const f=new Uint8Array(l*t/8|0);let g=0,O=0,w=0;for(let R=0;R<l;++R){const T=a[s[R]];if(void 0===T)throw new SyntaxError(`Non-${o} character`);O=O<<t|T,g+=t,g>=8&&(g-=8,f[w++]=255&O>>g)}if(g>=t||255&O<<8-g)throw new SyntaxError("Unexpected end of data");return f})(a,o,t,s)}),b_=Fi({prefix:"\0",name:"identity",encode:s=>(s=>(new TextDecoder).decode(s))(s),decode:s=>(s=>(new TextEncoder).encode(s))(s)});var w_=Object.freeze({__proto__:null,identity:b_});const E_=dt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var I_=Object.freeze({__proto__:null,base2:E_});const O_=dt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var S_=Object.freeze({__proto__:null,base8:O_});const N_=Vn({prefix:"9",name:"base10",alphabet:"0123456789"});var P_=Object.freeze({__proto__:null,base10:N_});const x_=dt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),R_=dt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var C_=Object.freeze({__proto__:null,base16:x_,base16upper:R_});const A_=dt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),T_=dt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),j_=dt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$_=dt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),D_=dt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),F_=dt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),U_=dt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),M_=dt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),L_=dt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var k_=Object.freeze({__proto__:null,base32:A_,base32upper:T_,base32pad:j_,base32padupper:$_,base32hex:D_,base32hexupper:F_,base32hexpad:U_,base32hexpadupper:M_,base32z:L_});const q_=Vn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Z_=Vn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var z_=Object.freeze({__proto__:null,base36:q_,base36upper:Z_});const K_=Vn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),V_=Vn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var B_=Object.freeze({__proto__:null,base58btc:K_,base58flickr:V_});const H_=dt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),W_=dt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),G_=dt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),J_=dt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Q_=Object.freeze({__proto__:null,base64:H_,base64pad:W_,base64url:G_,base64urlpad:J_});const au=Array.from("\u{1f680}\u{1fa90}\u2604\u{1f6f0}\u{1f30c}\u{1f311}\u{1f312}\u{1f313}\u{1f314}\u{1f315}\u{1f316}\u{1f317}\u{1f318}\u{1f30d}\u{1f30f}\u{1f30e}\u{1f409}\u2600\u{1f4bb}\u{1f5a5}\u{1f4be}\u{1f4bf}\u{1f602}\u2764\u{1f60d}\u{1f923}\u{1f60a}\u{1f64f}\u{1f495}\u{1f62d}\u{1f618}\u{1f44d}\u{1f605}\u{1f44f}\u{1f601}\u{1f525}\u{1f970}\u{1f494}\u{1f496}\u{1f499}\u{1f622}\u{1f914}\u{1f606}\u{1f644}\u{1f4aa}\u{1f609}\u263a\u{1f44c}\u{1f917}\u{1f49c}\u{1f614}\u{1f60e}\u{1f607}\u{1f339}\u{1f926}\u{1f389}\u{1f49e}\u270c\u2728\u{1f937}\u{1f631}\u{1f60c}\u{1f338}\u{1f64c}\u{1f60b}\u{1f497}\u{1f49a}\u{1f60f}\u{1f49b}\u{1f642}\u{1f493}\u{1f929}\u{1f604}\u{1f600}\u{1f5a4}\u{1f603}\u{1f4af}\u{1f648}\u{1f447}\u{1f3b6}\u{1f612}\u{1f92d}\u2763\u{1f61c}\u{1f48b}\u{1f440}\u{1f62a}\u{1f611}\u{1f4a5}\u{1f64b}\u{1f61e}\u{1f629}\u{1f621}\u{1f92a}\u{1f44a}\u{1f973}\u{1f625}\u{1f924}\u{1f449}\u{1f483}\u{1f633}\u270b\u{1f61a}\u{1f61d}\u{1f634}\u{1f31f}\u{1f62c}\u{1f643}\u{1f340}\u{1f337}\u{1f63b}\u{1f613}\u2b50\u2705\u{1f97a}\u{1f308}\u{1f608}\u{1f918}\u{1f4a6}\u2714\u{1f623}\u{1f3c3}\u{1f490}\u2639\u{1f38a}\u{1f498}\u{1f620}\u261d\u{1f615}\u{1f33a}\u{1f382}\u{1f33b}\u{1f610}\u{1f595}\u{1f49d}\u{1f64a}\u{1f639}\u{1f5e3}\u{1f4ab}\u{1f480}\u{1f451}\u{1f3b5}\u{1f91e}\u{1f61b}\u{1f534}\u{1f624}\u{1f33c}\u{1f62b}\u26bd\u{1f919}\u2615\u{1f3c6}\u{1f92b}\u{1f448}\u{1f62e}\u{1f646}\u{1f37b}\u{1f343}\u{1f436}\u{1f481}\u{1f632}\u{1f33f}\u{1f9e1}\u{1f381}\u26a1\u{1f31e}\u{1f388}\u274c\u270a\u{1f44b}\u{1f630}\u{1f928}\u{1f636}\u{1f91d}\u{1f6b6}\u{1f4b0}\u{1f353}\u{1f4a2}\u{1f91f}\u{1f641}\u{1f6a8}\u{1f4a8}\u{1f92c}\u2708\u{1f380}\u{1f37a}\u{1f913}\u{1f619}\u{1f49f}\u{1f331}\u{1f616}\u{1f476}\u{1f974}\u25b6\u27a1\u2753\u{1f48e}\u{1f4b8}\u2b07\u{1f628}\u{1f31a}\u{1f98b}\u{1f637}\u{1f57a}\u26a0\u{1f645}\u{1f61f}\u{1f635}\u{1f44e}\u{1f932}\u{1f920}\u{1f927}\u{1f4cc}\u{1f535}\u{1f485}\u{1f9d0}\u{1f43e}\u{1f352}\u{1f617}\u{1f911}\u{1f30a}\u{1f92f}\u{1f437}\u260e\u{1f4a7}\u{1f62f}\u{1f486}\u{1f446}\u{1f3a4}\u{1f647}\u{1f351}\u2744\u{1f334}\u{1f4a3}\u{1f438}\u{1f48c}\u{1f4cd}\u{1f940}\u{1f922}\u{1f445}\u{1f4a1}\u{1f4a9}\u{1f450}\u{1f4f8}\u{1f47b}\u{1f910}\u{1f92e}\u{1f3bc}\u{1f975}\u{1f6a9}\u{1f34e}\u{1f34a}\u{1f47c}\u{1f48d}\u{1f4e3}\u{1f942}"),Y_=au.reduce((s,e,t)=>(s[t]=e,s),[]),X_=au.reduce((s,e,t)=>(s[e.codePointAt(0)]=t,s),[]),ry=Fi({prefix:"\u{1f680}",name:"base256emoji",encode:function(s){return s.reduce((e,t)=>e+Y_[t],"")},decode:function(s){const e=[];for(const t of s){const o=X_[t.codePointAt(0)];if(void 0===o)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}});var ny=Object.freeze({__proto__:null,base256emoji:ry}),cy=Math.pow(2,31),ly=Math.pow(2,7),fy=Math.pow(2,14),dy=Math.pow(2,21),hy=Math.pow(2,28),py=Math.pow(2,35),gy=Math.pow(2,42),_y=Math.pow(2,49),yy=Math.pow(2,56),my=Math.pow(2,63),by={encode:function lu(s,e,t){e=e||[];for(var o=t=t||0;s>=cy;)e[t++]=255&s|128,s/=128;for(;-128&s;)e[t++]=255&s|128,s>>>=7;return e[t]=0|s,lu.bytes=t-o+1,e},decode:function go(s,e){var l,t=0,o=0,a=e=e||0,f=s.length;do{if(a>=f)throw go.bytes=0,new RangeError("Could not decode varint");l=s[a++],t+=o<28?(127&l)<<o:(127&l)*Math.pow(2,o),o+=7}while(l>=128);return go.bytes=a-e,t},encodingLength:function(s){return s<ly?1:s<fy?2:s<dy?3:s<hy?4:s<py?5:s<gy?6:s<_y?7:s<yy?8:s<my?9:10}},du=by;const hu=(s,e,t=0)=>(du.encode(s,e,t),e),pu=s=>du.encodingLength(s),_o=(s,e)=>{const t=e.byteLength,o=pu(s),a=o+pu(t),l=new Uint8Array(a+t);return hu(s,l,0),hu(t,l,o),l.set(e,a),new wy(s,t,e,l)};class wy{constructor(e,t,o,a){this.code=e,this.size=t,this.digest=o,this.bytes=a}}const gu=({name:s,code:e,encode:t})=>new Ey(s,e,t);class Ey{constructor(e,t,o){this.name=e,this.code=t,this.encode=o}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?_o(this.code,t):t.then(o=>_o(this.code,o))}throw Error("Unknown type, must be binary type")}}const _u=s=>function(){var e=(0,S.Z)(function*(t){return new Uint8Array(yield crypto.subtle.digest(s,t))});return function(t){return e.apply(this,arguments)}}(),Iy=gu({name:"sha2-256",code:18,encode:_u("SHA-256")}),Oy=gu({name:"sha2-512",code:19,encode:_u("SHA-512")});Object.freeze({__proto__:null,sha256:Iy,sha512:Oy});const mu=ou;Object.freeze({__proto__:null,identity:{code:0,name:"identity",encode:mu,digest:s=>_o(0,mu(s))}}),new TextEncoder,new TextDecoder;const vu={...w_,...I_,...S_,...P_,...C_,...k_,...z_,...B_,...Q_,...ny};function bu(s){return null!=globalThis.Buffer?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):s}function wu(s,e,t,o){return{name:s,prefix:e,encoder:{name:s,prefix:e,encode:t},decoder:{decode:o}}}const Eu=wu("utf8","u",s=>"u"+new TextDecoder("utf8").decode(s),s=>(new TextEncoder).encode(s.substring(1))),yo=wu("ascii","a",s=>{let e="a";for(let t=0;t<s.length;t++)e+=String.fromCharCode(s[t]);return e},s=>{const e=function(s=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?bu(globalThis.Buffer.allocUnsafe(s)):new Uint8Array(s)}((s=s.substring(1)).length);for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e}),Ry={utf8:Eu,"utf-8":Eu,hex:vu.base16,latin1:yo,ascii:yo,binary:yo,...vu},Sr="wc@2:core:",jy={database:":memory:"},Ou="client_ed25519_seed",Dy=$.ONE_DAY,ky=$.SIX_HOURS,Nu="wss://relay.walletconnect.com",Pu="wss://relay.walletconnect.org",Vy=$.ONE_SECOND/2,rr_created="subscription_created",rr_deleted="subscription_deleted",Yy=1e3*$.FIVE_SECONDS,Hn={wc_pairingDelete:{req:{ttl:$.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:$.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:$.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:$.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:$.ONE_DAY,prompt:!1,tag:0},res:{ttl:$.ONE_DAY,prompt:!1,tag:0}}},Ft_expired="expirer_expired",vo="verify-api",xu="https://verify.walletconnect.com";class sm{constructor(e,t){var o=this;this.core=e,this.logger=t,this.keychain=new Map,this.name="keychain",this.version="0.3",this.initialized=!1,this.storagePrefix=Sr,this.init=(0,S.Z)(function*(){if(!o.initialized){const a=yield o.getKeyChain();typeof a<"u"&&(o.keychain=a),o.initialized=!0}}),this.has=a=>(this.isInitialized(),this.keychain.has(a)),this.set=function(){var a=(0,S.Z)(function*(l,f){o.isInitialized(),o.keychain.set(l,f),yield o.persist()});return function(l,f){return a.apply(this,arguments)}}(),this.get=a=>{this.isInitialized();const l=this.keychain.get(a);if(typeof l>"u"){const{message:f}=Q("NO_MATCHING_KEY",`${this.name}: ${a}`);throw new Error(f)}return l},this.del=function(){var a=(0,S.Z)(function*(l){o.isInitialized(),o.keychain.delete(l),yield o.persist()});return function(l){return a.apply(this,arguments)}}(),this.core=e,this.logger=(0,Ae.generateChildLogger)(t,this.name)}get context(){return(0,Ae.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}setKeyChain(e){var t=this;return(0,S.Z)(function*(){yield t.core.storage.setItem(t.storageKey,Va(e))})()}getKeyChain(){var e=this;return(0,S.Z)(function*(){const t=yield e.core.storage.getItem(e.storageKey);return typeof t<"u"?Ba(t):void 0})()}persist(){var e=this;return(0,S.Z)(function*(){yield e.setKeyChain(e.keychain)})()}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}class om{constructor(e,t,o){var a=this;this.core=e,this.logger=t,this.name="crypto",this.initialized=!1,this.init=(0,S.Z)(function*(){a.initialized||(yield a.keychain.init(),a.initialized=!0)}),this.hasKeys=l=>(this.isInitialized(),this.keychain.has(l)),this.getClientId=(0,S.Z)(function*(){a.isInitialized();const l=yield a.getClientSeed(),f=Ni.generateKeyPair(l);return Ni.encodeIss(f.publicKey)}),this.generateKeyPair=()=>{this.isInitialized();const l=function(){const s=it.Au();return{privateKey:(0,he.BB)(s.secretKey,yt),publicKey:(0,he.BB)(s.publicKey,yt)}}();return this.setPrivateKey(l.publicKey,l.privateKey)},this.signJWT=function(){var l=(0,S.Z)(function*(f){a.isInitialized();const g=yield a.getClientSeed(),O=Ni.generateKeyPair(g),w=oo(),R=Dy;return yield Ni.signJWT(w,f,R,O)});return function(f){return l.apply(this,arguments)}}(),this.generateSharedKey=(l,f,g)=>{this.isInitialized();const w=function(s,e){const t=it.gi((0,he.mL)(s,yt),(0,he.mL)(e,yt)),o=new xe.t(Ge.mE,t).expand(32);return(0,he.BB)(o,yt)}(this.getPrivateKey(l),f);return this.setSymKey(w,g)},this.setSymKey=function(){var l=(0,S.Z)(function*(f,g){a.isInitialized();const O=g||function(s){const e=(0,Ge.vp)((0,he.mL)(s,yt));return(0,he.BB)(e,yt)}(f);return yield a.keychain.set(O,f),O});return function(f,g){return l.apply(this,arguments)}}(),this.deleteKeyPair=function(){var l=(0,S.Z)(function*(f){a.isInitialized(),yield a.keychain.del(f)});return function(f){return l.apply(this,arguments)}}(),this.deleteSymKey=function(){var l=(0,S.Z)(function*(f){a.isInitialized(),yield a.keychain.del(f)});return function(f){return l.apply(this,arguments)}}(),this.encode=function(){var l=(0,S.Z)(function*(f,g,O){a.isInitialized();const w=Ma(O),R=function(s){return"string"==typeof s?s:(s=>JSON.stringify(s,(e,t)=>"bigint"==typeof t?t.toString()+"n":t))(s)||""}(g);if(La(w)){const Z=w.senderPublicKey,B=w.receiverPublicKey;f=yield a.generateSharedKey(Z,B)}const T=a.getSymKey(f),{type:H,senderPublicKey:te}=w;return function(s){const e=function(s){return(0,he.mL)(`${s}`,"base10")}(typeof s.type<"u"?s.type:0);if(1===zn(e)&&typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof s.senderPublicKey<"u"?(0,he.mL)(s.senderPublicKey,yt):void 0,o=typeof s.iv<"u"?(0,he.mL)(s.iv,yt):(0,Ve.randomBytes)(12);return function(s){if(1===zn(s.type)){if(typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,he.BB)((0,he.zo)([s.type,s.senderPublicKey,s.iv,s.sealed]),ro)}return(0,he.BB)((0,he.zo)([s.type,s.iv,s.sealed]),ro)}({type:e,sealed:new Ze.OK((0,he.mL)(s.symKey,yt)).seal(o,(0,he.mL)(s.message,no)),iv:o,senderPublicKey:t})}({type:H,symKey:T,message:R,senderPublicKey:te})});return function(f,g,O){return l.apply(this,arguments)}}(),this.decode=function(){var l=(0,S.Z)(function*(f,g,O){a.isInitialized();const w=function(s,e){const t=Ci(s);return Ma({type:zn(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?(0,he.BB)(t.senderPublicKey,yt):void 0,receiverPublicKey:e?.receiverPublicKey})}(g,O);if(La(w)){const R=w.receiverPublicKey,T=w.senderPublicKey;f=yield a.generateSharedKey(R,T)}try{const T=function(s){const e=new Ze.OK((0,he.mL)(s.symKey,yt)),{sealed:t,iv:o}=Ci(s.encoded),a=e.open(o,t);if(null===a)throw new Error("Failed to decrypt");return(0,he.BB)(a,no)}({symKey:a.getSymKey(f),encoded:g});return function(s){if("string"!=typeof s)throw new Error("Cannot safe json parse value of type "+typeof s);try{return(s=>{const t=s.replace(/([\[:])?(\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,'$1"$2n"$3');return JSON.parse(t,(o,a)=>"string"==typeof a&&a.match(/^\d+n$/)?BigInt(a.substring(0,a.length-1)):a)})(s)}catch{return s}}(T)}catch(R){a.logger.error(`Failed to decode message from topic: '${f}', clientId: '${yield a.getClientId()}'`),a.logger.error(R)}});return function(f,g,O){return l.apply(this,arguments)}}(),this.getPayloadType=l=>zn(Ci(l).type),this.getPayloadSenderPublicKey=l=>{const f=Ci(l);return f.senderPublicKey?(0,he.BB)(f.senderPublicKey,yt):void 0},this.core=e,this.logger=(0,Ae.generateChildLogger)(t,this.name),this.keychain=o||new sm(this.core,this.logger)}get context(){return(0,Ae.getLoggerContext)(this.logger)}setPrivateKey(e,t){var o=this;return(0,S.Z)(function*(){return yield o.keychain.set(e,t),e})()}getPrivateKey(e){return this.keychain.get(e)}getClientSeed(){var e=this;return(0,S.Z)(function*(){let t="";try{t=e.keychain.get(Ou)}catch{t=oo(),yield e.keychain.set(Ou,t)}return function(s,e="utf8"){const t=Ry[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return"utf8"!==e&&"utf-8"!==e||null==globalThis.Buffer||null==globalThis.Buffer.from?t.decoder.decode(`${t.prefix}${s}`):bu(globalThis.Buffer.from(s,"utf-8"))}(t,"base16")})()}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}class cm extends class{constructor(e,t){this.logger=e,this.core=t}}{constructor(e,t){var o;super(e,t),o=this,this.logger=e,this.core=t,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=Sr,this.init=(0,S.Z)(function*(){if(!o.initialized){o.logger.trace("Initialized");try{const a=yield o.getRelayerMessages();typeof a<"u"&&(o.messages=a),o.logger.debug(`Successfully Restored records for ${o.name}`),o.logger.trace({type:"method",method:"restore",size:o.messages.size})}catch(a){o.logger.debug(`Failed to Restore records for ${o.name}`),o.logger.error(a)}finally{o.initialized=!0}}}),this.set=function(){var a=(0,S.Z)(function*(l,f){o.isInitialized();const g=dn(f);let O=o.messages.get(l);return typeof O>"u"&&(O={}),typeof O[g]<"u"||(O[g]=f,o.messages.set(l,O),yield o.persist()),g});return function(l,f){return a.apply(this,arguments)}}(),this.get=a=>{this.isInitialized();let l=this.messages.get(a);return typeof l>"u"&&(l={}),l},this.has=(a,l)=>(this.isInitialized(),typeof this.get(a)[dn(l)]<"u"),this.del=function(){var a=(0,S.Z)(function*(l){o.isInitialized(),o.messages.delete(l),yield o.persist()});return function(l){return a.apply(this,arguments)}}(),this.logger=(0,Ae.generateChildLogger)(e,this.name),this.core=t}get context(){return(0,Ae.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}setRelayerMessages(e){var t=this;return(0,S.Z)(function*(){yield t.core.storage.setItem(t.storageKey,Va(e))})()}getRelayerMessages(){var e=this;return(0,S.Z)(function*(){const t=yield e.core.storage.getItem(e.storageKey);return typeof t<"u"?Ba(t):void 0})()}persist(){var e=this;return(0,S.Z)(function*(){yield e.setRelayerMessages(e.messages)})()}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}class am extends cp{constructor(e,t){var o;super(e,t),o=this,this.relayer=e,this.logger=t,this.events=new Le.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=(0,$.toMiliseconds)($.TEN_SECONDS),this.queueTimeout=(0,$.toMiliseconds)($.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=function(){var a=(0,S.Z)(function*(l,f,g){o.logger.debug("Publishing Payload"),o.logger.trace({type:"method",method:"publish",params:{topic:l,message:f,opts:g}});try{const O=g?.ttl||ky,w=fo(g),R=g?.prompt||!1,T=g?.tag||0,H=g?.id||(0,$e.getBigIntRpcId)().toString(),te={topic:l,message:f,opts:{ttl:O,relay:w,prompt:R,tag:T,id:H}},Z=setTimeout(()=>o.queue.set(H,te),o.queueTimeout);try{yield yield Ti(o.rpcPublish(l,f,O,w,R,T,H),o.publishTimeout),clearTimeout(Z),o.relayer.events.emit("relayer_publish",te)}catch{return o.logger.debug("Publishing Payload stalled"),void(o.needsTransportRestart=!0)}o.logger.debug("Successfully Published Payload"),o.logger.trace({type:"method",method:"publish",params:{topic:l,message:f,opts:g}})}catch(O){throw o.logger.debug("Failed to Publish Payload"),o.logger.error(O),O}});return function(l,f,g){return a.apply(this,arguments)}}(),this.on=(a,l)=>{this.events.on(a,l)},this.once=(a,l)=>{this.events.once(a,l)},this.off=(a,l)=>{this.events.off(a,l)},this.removeListener=(a,l)=>{this.events.removeListener(a,l)},this.relayer=e,this.logger=(0,Ae.generateChildLogger)(t,this.name),this.registerEventListeners()}get context(){return(0,Ae.getLoggerContext)(this.logger)}rpcPublish(e,t,o,a,l,f,g){var O,w,R,T;const H={method:ji(a.protocol).publish,params:{topic:e,message:t,ttl:o,prompt:l,tag:f},id:g};return mt(null==(O=H.params)?void 0:O.prompt)&&(null==(w=H.params)||delete w.prompt),mt(null==(R=H.params)?void 0:R.tag)&&(null==(T=H.params)||delete T.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:H}),this.relayer.request(H)}onPublish(e){this.queue.delete(e)}checkQueue(){var e=this;this.queue.forEach(function(){var t=(0,S.Z)(function*(o){const{topic:a,message:l,opts:f}=o;yield e.publish(a,l,f)});return function(o){return t.apply(this,arguments)}}())}registerEventListeners(){this.relayer.core.heartbeat.on(Zn.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit("relayer_connection_stalled");this.checkQueue()}),this.relayer.on("relayer_message_ack",e=>{this.onPublish(e.id.toString())})}}class um{constructor(){this.map=new Map,this.set=(e,t)=>{const o=this.get(e);this.exists(e,t)||this.map.set(e,[...o,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const o=this.get(e);if(!this.exists(e,t))return;const a=o.filter(l=>l!==t);a.length?this.map.set(e,a):this.map.delete(e)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var lm=Object.defineProperty,fm=Object.defineProperties,dm=Object.getOwnPropertyDescriptors,Ru=Object.getOwnPropertySymbols,hm=Object.prototype.hasOwnProperty,pm=Object.prototype.propertyIsEnumerable,Cu=(s,e,t)=>e in s?lm(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Wn=(s,e)=>{for(var t in e||(e={}))hm.call(e,t)&&Cu(s,t,e[t]);if(Ru)for(var t of Ru(e))pm.call(e,t)&&Cu(s,t,e[t]);return s},bo=(s,e)=>fm(s,dm(e));class gm extends lp{constructor(e,t){var o;super(e,t),o=this,this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new um,this.events=new Le.EventEmitter,this.name="subscription",this.version="0.3",this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Sr,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=(0,S.Z)(function*(){o.initialized||(o.logger.trace("Initialized"),yield o.restart(),o.registerEventListeners(),o.onEnable(),o.clientId=yield o.relayer.core.crypto.getClientId())}),this.subscribe=function(){var a=(0,S.Z)(function*(l,f){yield o.restartToComplete(),o.isInitialized(),o.logger.debug("Subscribing Topic"),o.logger.trace({type:"method",method:"subscribe",params:{topic:l,opts:f}});try{const g=fo(f),O={topic:l,relay:g};o.pending.set(l,O);const w=yield o.rpcSubscribe(l,g);return o.onSubscribe(w,O),o.logger.debug("Successfully Subscribed Topic"),o.logger.trace({type:"method",method:"subscribe",params:{topic:l,opts:f}}),w}catch(g){throw o.logger.debug("Failed to Subscribe Topic"),o.logger.error(g),g}});return function(l,f){return a.apply(this,arguments)}}(),this.unsubscribe=function(){var a=(0,S.Z)(function*(l,f){yield o.restartToComplete(),o.isInitialized(),typeof f?.id<"u"?yield o.unsubscribeById(l,f.id,f):yield o.unsubscribeByTopic(l,f)});return function(l,f){return a.apply(this,arguments)}}(),this.isSubscribed=function(){var a=(0,S.Z)(function*(l){return!!o.topics.includes(l)||(yield new Promise((f,g)=>{const O=new $.Watch;O.start(o.pendingSubscriptionWatchLabel);const w=setInterval(()=>{!o.pending.has(l)&&o.topics.includes(l)&&(clearInterval(w),O.stop(o.pendingSubscriptionWatchLabel),f(!0)),O.elapsed(o.pendingSubscriptionWatchLabel)>=Yy&&(clearInterval(w),O.stop(o.pendingSubscriptionWatchLabel),g(new Error("Subscription resolution timeout")))},o.pollingInterval)}).catch(()=>!1))});return function(l){return a.apply(this,arguments)}}(),this.on=(a,l)=>{this.events.on(a,l)},this.once=(a,l)=>{this.events.once(a,l)},this.off=(a,l)=>{this.events.off(a,l)},this.removeListener=(a,l)=>{this.events.removeListener(a,l)},this.restart=(0,S.Z)(function*(){o.restartInProgress=!0,yield o.restore(),yield o.reset(),o.restartInProgress=!1}),this.relayer=e,this.logger=(0,Ae.generateChildLogger)(t,this.name),this.clientId=""}get context(){return(0,Ae.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let o=!1;try{o=this.getSubscription(e).topic===t}catch{}return o}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}unsubscribeByTopic(e,t){var o=this;return(0,S.Z)(function*(){const a=o.topicMap.get(e);yield Promise.all(a.map(function(){var l=(0,S.Z)(function*(f){return yield o.unsubscribeById(e,f,t)});return function(f){return l.apply(this,arguments)}}()))})()}unsubscribeById(e,t,o){var a=this;return(0,S.Z)(function*(){a.logger.debug("Unsubscribing Topic"),a.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:o}});try{const l=fo(o);yield a.rpcUnsubscribe(e,t,l);const f=at("USER_DISCONNECTED",`${a.name}, ${e}`);yield a.onUnsubscribe(e,t,f),a.logger.debug("Successfully Unsubscribed Topic"),a.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:o}})}catch(l){throw a.logger.debug("Failed to Unsubscribe Topic"),a.logger.error(l),l}})()}rpcSubscribe(e,t){var o=this;return(0,S.Z)(function*(){const a={method:ji(t.protocol).subscribe,params:{topic:e}};o.logger.debug("Outgoing Relay Payload"),o.logger.trace({type:"payload",direction:"outgoing",request:a});try{yield yield Ti(o.relayer.request(a),o.subscribeTimeout)}catch{o.logger.debug("Outgoing Relay Subscribe Payload stalled"),o.relayer.events.emit("relayer_connection_stalled")}return dn(e+o.clientId)})()}rpcBatchSubscribe(e){var t=this;return(0,S.Z)(function*(){if(!e.length)return;const a={method:ji(e[0].relay.protocol).batchSubscribe,params:{topics:e.map(l=>l.topic)}};t.logger.debug("Outgoing Relay Payload"),t.logger.trace({type:"payload",direction:"outgoing",request:a});try{return yield yield Ti(t.relayer.request(a),t.subscribeTimeout)}catch{t.logger.debug("Outgoing Relay Payload stalled"),t.relayer.events.emit("relayer_connection_stalled")}})()}rpcUnsubscribe(e,t,o){const a={method:ji(o.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:a}),this.relayer.request(a)}onSubscribe(e,t){this.setSubscription(e,bo(Wn({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,Wn({},t)),this.pending.delete(t.topic)})}onUnsubscribe(e,t,o){var a=this;return(0,S.Z)(function*(){a.events.removeAllListeners(t),a.hasSubscription(t,e)&&a.deleteSubscription(t,o),yield a.relayer.messages.del(e)})()}setRelayerSubscriptions(e){var t=this;return(0,S.Z)(function*(){yield t.relayer.core.storage.setItem(t.storageKey,e)})()}getRelayerSubscriptions(){var e=this;return(0,S.Z)(function*(){return yield e.relayer.core.storage.getItem(e.storageKey)})()}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t))}addSubscription(e,t){this.subscriptions.set(e,Wn({},t)),this.topicMap.set(t.topic,e),this.events.emit(rr_created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:o}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(o)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const o=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(o.topic,e),this.events.emit(rr_deleted,bo(Wn({},o),{reason:t}))}persist(){var e=this;return(0,S.Z)(function*(){yield e.setRelayerSubscriptions(e.values),e.events.emit("subscription_sync")})()}reset(){var e=this;return(0,S.Z)(function*(){if(e.cached.length){const t=Math.ceil(e.cached.length/e.batchSubscribeTopicsLimit);for(let o=0;o<t;o++){const a=e.cached.splice(0,e.batchSubscribeTopicsLimit);yield e.batchSubscribe(a)}}e.events.emit("subscription_resubscribed")})()}restore(){var e=this;return(0,S.Z)(function*(){try{const t=yield e.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(e.subscriptions.size){const{message:o}=Q("RESTORE_WILL_OVERRIDE",e.name);throw e.logger.error(o),e.logger.error(`${e.name}: ${JSON.stringify(e.values)}`),new Error(o)}e.cached=t,e.logger.debug(`Successfully Restored subscriptions for ${e.name}`),e.logger.trace({type:"method",method:"restore",subscriptions:e.values})}catch(t){e.logger.debug(`Failed to Restore subscriptions for ${e.name}`),e.logger.error(t)}})()}batchSubscribe(e){var t=this;return(0,S.Z)(function*(){if(!e.length)return;const o=yield t.rpcBatchSubscribe(e);Kn(o)&&t.onBatchSubscribe(o.map((a,l)=>bo(Wn({},e[l]),{id:a})))})()}onConnect(){var e=this;return(0,S.Z)(function*(){e.restartInProgress||(yield e.restart(),e.onEnable())})()}onDisconnect(){this.onDisable()}checkPending(){var e=this;return(0,S.Z)(function*(){if(e.relayer.transportExplicitlyClosed)return;const t=[];e.pending.forEach(o=>{t.push(o)}),yield e.batchSubscribe(t)})()}registerEventListeners(){var e=this;this.relayer.core.heartbeat.on(Zn.HEARTBEAT_EVENTS.pulse,(0,S.Z)(function*(){yield e.checkPending()})),this.relayer.on("relayer_connect",(0,S.Z)(function*(){yield e.onConnect()})),this.relayer.on("relayer_disconnect",()=>{this.onDisconnect()}),this.events.on(rr_created,function(){var t=(0,S.Z)(function*(o){const a=rr_created;e.logger.info(`Emitting ${a}`),e.logger.debug({type:"event",event:a,data:o}),yield e.persist()});return function(o){return t.apply(this,arguments)}}()),this.events.on(rr_deleted,function(){var t=(0,S.Z)(function*(o){const a=rr_deleted;e.logger.info(`Emitting ${a}`),e.logger.debug({type:"event",event:a,data:o}),yield e.persist()});return function(o){return t.apply(this,arguments)}}())}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}restartToComplete(){var e=this;return(0,S.Z)(function*(){e.restartInProgress&&(yield new Promise(t=>{const o=setInterval(()=>{e.restartInProgress||(clearInterval(o),t())},e.pollingInterval)}))})()}}var _m=Object.defineProperty,Au=Object.getOwnPropertySymbols,ym=Object.prototype.hasOwnProperty,mm=Object.prototype.propertyIsEnumerable,Tu=(s,e,t)=>e in s?_m(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;class bm extends ap{constructor(e){var t;super(e),t=this,this.protocol="wc",this.version=2,this.events=new Le.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=function(){var o=(0,S.Z)(function*(a){t.logger.debug("Publishing Request Payload");try{return yield t.toEstablishConnection(),yield t.provider.request(a)}catch(l){throw t.logger.debug("Failed to Publish Request"),t.logger.error(l),l}});return function(a){return o.apply(this,arguments)}}(),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,Ae.generateChildLogger)(e.logger,this.name):(0,Ae.pino)((0,Ae.getDefaultLoggerOptions)({level:e.logger||"error"})),this.messages=new cm(this.logger,e.core),this.subscriber=new gm(this,this.logger),this.publisher=new am(this,this.logger),this.relayUrl=e?.relayUrl||Nu,this.projectId=e.projectId,this.provider={}}init(){var e=this;return(0,S.Z)(function*(){e.logger.trace("Initialized"),yield e.createProvider(),yield Promise.all([e.messages.init(),e.subscriber.init()]);try{yield e.transportOpen()}catch{e.logger.warn(`Connection via ${e.relayUrl} failed, attempting to connect via failover domain ${Pu}...`),yield e.restartTransport(Pu)}e.registerEventListeners(),e.initialized=!0,setTimeout((0,S.Z)(function*(){0===e.subscriber.topics.length&&(e.logger.info("No topics subscribed to after init, closing transport"),yield e.transportClose(),e.transportExplicitlyClosed=!1)}),1e4)})()}get context(){return(0,Ae.getLoggerContext)(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}publish(e,t,o){var a=this;return(0,S.Z)(function*(){a.isInitialized(),yield a.publisher.publish(e,t,o),yield a.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()})})()}subscribe(e,t){var o=this;return(0,S.Z)(function*(){var a;o.isInitialized();let l=(null==(a=o.subscriber.topicMap.get(e))?void 0:a[0])||"";return l||(yield Promise.all([new Promise(f=>{o.subscriber.once(rr_created,g=>{g.topic===e&&f()})}),new Promise(function(){var f=(0,S.Z)(function*(g){l=yield o.subscriber.subscribe(e,t),g()});return function(g){return f.apply(this,arguments)}}())]),l)})()}unsubscribe(e,t){var o=this;return(0,S.Z)(function*(){o.isInitialized(),yield o.subscriber.unsubscribe(e,t)})()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}transportClose(){var e=this;return(0,S.Z)(function*(){e.transportExplicitlyClosed=!0,e.connected&&(yield e.provider.disconnect(),e.events.emit("relayer_transport_closed"))})()}transportOpen(e){var t=this;return(0,S.Z)(function*(){if(t.transportExplicitlyClosed=!1,!t.reconnecting){t.relayUrl=e||t.relayUrl,t.reconnecting=!0;try{yield Promise.all([new Promise(o=>{t.initialized||o(),t.subscriber.once("subscription_resubscribed",()=>{o()})}),yield Promise.race([new Promise(function(){var o=(0,S.Z)(function*(a,l){yield Ti(t.provider.connect(),1e4,`Socket stalled when trying to connect to ${t.relayUrl}`).catch(f=>l(f)).then(()=>a()).finally(()=>t.removeListener("relayer_transport_closed",t.rejectTransportOpen))});return function(a,l){return o.apply(this,arguments)}}()),new Promise(o=>t.once("relayer_transport_closed",t.rejectTransportOpen))])])}catch(o){if(t.logger.error(o),!t.isConnectionStalled(o.message))throw o;t.events.emit("relayer_transport_closed")}finally{t.reconnecting=!1}}})()}restartTransport(e){var t=this;return(0,S.Z)(function*(){t.transportExplicitlyClosed||t.reconnecting||(t.relayUrl=e||t.relayUrl,t.connected&&(yield Promise.all([new Promise(o=>{t.provider.once("disconnect",()=>{o()})}),t.transportClose()])),yield t.createProvider(),yield t.transportOpen())})()}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}createProvider(){var e=this;return(0,S.Z)(function*(){const t=yield e.core.crypto.signJWT(e.relayUrl);e.provider=new Or.r(new o_.Z(function({protocol:s,version:e,relayUrl:t,sdkVersion:o,auth:a,projectId:l,useOnCloseEvent:f}){const g=t.split("?"),O=sg(s,e,o),R=function(s,e){let t=xi.parse(s);return t=Za(Za({},t),e),xi.stringify(t)}(g[1]||"",{auth:a,ua:O,projectId:l,useOnCloseEvent:f||void 0});return g[0]+"?"+R}({sdkVersion:"2.9.1",protocol:e.protocol,version:e.version,relayUrl:e.relayUrl,projectId:e.projectId,auth:t,useOnCloseEvent:!0}))),e.registerProviderListeners()})()}recordMessageEvent(e){var t=this;return(0,S.Z)(function*(){const{topic:o,message:a}=e;yield t.messages.set(o,a)})()}shouldIgnoreMessageEvent(e){var t=this;return(0,S.Z)(function*(){const{topic:o,message:a}=e;if(!a||0===a.length)return t.logger.debug(`Ignoring invalid/empty message: ${a}`),!0;if(!(yield t.subscriber.isSubscribed(o)))return t.logger.debug(`Ignoring message for non-subscribed topic ${o}`),!0;const l=t.messages.has(o,a);return l&&t.logger.debug(`Ignoring duplicate message: ${a}`),l})()}onProviderPayload(e){var t=this;return(0,S.Z)(function*(){if(t.logger.debug("Incoming Relay Payload"),t.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,$e.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const o=e.params,{topic:a,message:l,publishedAt:f}=o.data,g={topic:a,message:l,publishedAt:f};t.logger.debug("Emitting Relayer Payload"),t.logger.trace(((s,e)=>{for(var t in e||(e={}))ym.call(e,t)&&Tu(s,t,e[t]);if(Au)for(var t of Au(e))mm.call(e,t)&&Tu(s,t,e[t]);return s})({type:"event",event:o.id},g)),t.events.emit(o.id,g),yield t.acknowledgePayload(e),yield t.onMessageEvent(g)}else(0,$e.isJsonRpcResponse)(e)&&t.events.emit("relayer_message_ack",e)})()}onMessageEvent(e){var t=this;return(0,S.Z)(function*(){(yield t.shouldIgnoreMessageEvent(e))||(t.events.emit("relayer_message",e),yield t.recordMessageEvent(e))})()}acknowledgePayload(e){var t=this;return(0,S.Z)(function*(){const o=(0,$e.formatJsonRpcResult)(e.id,!0);yield t.provider.connection.send(o)})()}registerProviderListeners(){this.provider.on("payload",e=>this.onProviderPayload(e)),this.provider.on("connect",()=>{this.events.emit("relayer_connect")}),this.provider.on("disconnect",()=>{this.onProviderDisconnect()}),this.provider.on("error",e=>{this.logger.error(e),this.events.emit("relayer_error",e)})}registerEventListeners(){var e=this;this.events.on("relayer_connection_stalled",(0,S.Z)(function*(){yield e.restartTransport()}))}onProviderDisconnect(){this.events.emit("relayer_disconnect"),this.attemptToReconnect()}attemptToReconnect(){var e=this;this.transportExplicitlyClosed||setTimeout((0,S.Z)(function*(){yield e.restartTransport()}),(0,$.toMiliseconds)(Vy))}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}toEstablishConnection(){var e=this;return(0,S.Z)(function*(){if(!e.connected){if(e.connecting)return yield new Promise(t=>{const o=setInterval(()=>{e.connected&&(clearInterval(o),t())},e.connectionStatusPollingInterval)});yield e.restartTransport()}})()}}var wm=Object.defineProperty,ju=Object.getOwnPropertySymbols,Em=Object.prototype.hasOwnProperty,Im=Object.prototype.propertyIsEnumerable,$u=(s,e,t)=>e in s?wm(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Du=(s,e)=>{for(var t in e||(e={}))Em.call(e,t)&&$u(s,t,e[t]);if(ju)for(var t of ju(e))Im.call(e,t)&&$u(s,t,e[t]);return s};class Ui extends class{constructor(e,t,o,a){this.core=e,this.logger=t,this.name=o}}{constructor(e,t,o,a=Sr,l){var f;super(e,t,o,a),f=this,this.core=e,this.logger=t,this.name=o,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Sr,this.init=(0,S.Z)(function*(){f.initialized||(f.logger.trace("Initialized"),yield f.restore(),f.cached.forEach(g=>{f.getKey&&null!==g&&!mt(g)?f.map.set(f.getKey(g),g):function(s){var e;return null==(e=s?.proposer)?void 0:e.publicKey}(g)?f.map.set(g.id,g):g?.topic&&f.map.set(g.topic,g)}),f.cached=[],f.initialized=!0)}),this.set=function(){var g=(0,S.Z)(function*(O,w){f.isInitialized(),f.map.has(O)?yield f.update(O,w):(f.logger.debug("Setting value"),f.logger.trace({type:"method",method:"set",key:O,value:w}),f.map.set(O,w),yield f.persist())});return function(O,w){return g.apply(this,arguments)}}(),this.get=g=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:g}),this.getData(g)),this.getAll=g=>(this.isInitialized(),g?this.values.filter(O=>Object.keys(g).every(w=>a_()(O[w],g[w]))):this.values),this.update=function(){var g=(0,S.Z)(function*(O,w){f.isInitialized(),f.logger.debug("Updating value"),f.logger.trace({type:"method",method:"update",key:O,update:w});const R=Du(Du({},f.getData(O)),w);f.map.set(O,R),yield f.persist()});return function(O,w){return g.apply(this,arguments)}}(),this.delete=function(){var g=(0,S.Z)(function*(O,w){f.isInitialized(),f.map.has(O)&&(f.logger.debug("Deleting value"),f.logger.trace({type:"method",method:"delete",key:O,reason:w}),f.map.delete(O),yield f.persist())});return function(O,w){return g.apply(this,arguments)}}(),this.logger=(0,Ae.generateChildLogger)(t,this.name),this.storagePrefix=a,this.getKey=l}get context(){return(0,Ae.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}setDataStore(e){var t=this;return(0,S.Z)(function*(){yield t.core.storage.setItem(t.storageKey,e)})()}getDataStore(){var e=this;return(0,S.Z)(function*(){return yield e.core.storage.getItem(e.storageKey)})()}getData(e){const t=this.map.get(e);if(!t){const{message:o}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(o),new Error(o)}return t}persist(){var e=this;return(0,S.Z)(function*(){yield e.setDataStore(e.values)})()}restore(){var e=this;return(0,S.Z)(function*(){try{const t=yield e.getDataStore();if(typeof t>"u"||!t.length)return;if(e.map.size){const{message:o}=Q("RESTORE_WILL_OVERRIDE",e.name);throw e.logger.error(o),new Error(o)}e.cached=t,e.logger.debug(`Successfully Restored value for ${e.name}`),e.logger.trace({type:"method",method:"restore",value:e.values})}catch(t){e.logger.debug(`Failed to Restore value for ${e.name}`),e.logger.error(t)}})()}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Om{constructor(e,t){var o=this;this.core=e,this.logger=t,this.name="pairing",this.version="0.3",this.events=new(We()),this.initialized=!1,this.storagePrefix=Sr,this.ignoredPayloadTypes=[1],this.registeredMethods=[],this.init=(0,S.Z)(function*(){o.initialized||(yield o.pairings.init(),yield o.cleanup(),o.registerRelayerEvents(),o.registerExpirerEvents(),o.initialized=!0,o.logger.trace("Initialized"))}),this.register=({methods:a})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...a])]},this.create=(0,S.Z)(function*(){o.isInitialized();const a=oo(),l=yield o.core.crypto.setSymKey(a),f=Wt($.FIVE_MINUTES),g={protocol:"irn"},O={topic:l,expiry:f,relay:g,active:!1},w=function(s){return`${s.protocol}:${s.topic}@${s.version}?`+xi.stringify(((s,e)=>{for(var t in e||(e={}))gg.call(e,t)&&Ja(s,t,e[t]);if(Ga)for(var t of Ga(e))_g.call(e,t)&&Ja(s,t,e[t]);return s})({symKey:s.symKey},function(s,e="-"){const o={};return Object.keys(s).forEach(a=>{s[a]&&(o["relay"+e+a]=s[a])}),o}(s.relay)))}({protocol:o.core.protocol,version:o.core.version,topic:l,symKey:a,relay:g});return yield o.pairings.set(l,O),yield o.core.relayer.subscribe(l),o.core.expirer.set(l,f),{topic:l,uri:w}}),this.pair=function(){var a=(0,S.Z)(function*(l){o.isInitialized(),o.isValidPair(l);const{topic:f,symKey:g,relay:O}=function(s){const e=s.indexOf(":"),t=-1!==s.indexOf("?")?s.indexOf("?"):void 0,o=s.substring(0,e),a=s.substring(e+1,t).split("@"),l=typeof t<"u"?s.substring(t):"",f=xi.parse(l);return{protocol:o,topic:bg(a[0]),version:parseInt(a[1],10),symKey:f.symKey,relay:mg(f)}}(l.uri);if(o.pairings.keys.includes(f))throw new Error(`Pairing already exists: ${f}`);if(o.core.crypto.hasKeys(f))throw new Error(`Keychain already exists: ${f}`);const w=Wt($.FIVE_MINUTES),R={topic:f,relay:O,expiry:w,active:!1};return yield o.pairings.set(f,R),yield o.core.crypto.setSymKey(g,f),yield o.core.relayer.subscribe(f,{relay:O}),o.core.expirer.set(f,w),l.activatePairing&&(yield o.activate({topic:f})),R});return function(l){return a.apply(this,arguments)}}(),this.activate=function(){var a=(0,S.Z)(function*({topic:l}){o.isInitialized();const f=Wt($.THIRTY_DAYS);yield o.pairings.update(l,{active:!0,expiry:f}),o.core.expirer.set(l,f)});return function(l){return a.apply(this,arguments)}}(),this.ping=function(){var a=(0,S.Z)(function*(l){o.isInitialized(),yield o.isValidPing(l);const{topic:f}=l;if(o.pairings.keys.includes(f)){const g=yield o.sendRequest(f,"wc_pairingPing",{}),{done:O,resolve:w,reject:R}=_n();o.events.once(st("pairing_ping",g),({error:T})=>{T?R(T):w()}),yield O()}});return function(l){return a.apply(this,arguments)}}(),this.updateExpiry=function(){var a=(0,S.Z)(function*({topic:l,expiry:f}){o.isInitialized(),yield o.pairings.update(l,{expiry:f})});return function(l){return a.apply(this,arguments)}}(),this.updateMetadata=function(){var a=(0,S.Z)(function*({topic:l,metadata:f}){o.isInitialized(),yield o.pairings.update(l,{peerMetadata:f})});return function(l){return a.apply(this,arguments)}}(),this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=function(){var a=(0,S.Z)(function*(l){o.isInitialized(),yield o.isValidDisconnect(l);const{topic:f}=l;o.pairings.keys.includes(f)&&(yield o.sendRequest(f,"wc_pairingDelete",at("USER_DISCONNECTED")),yield o.deletePairing(f))});return function(l){return a.apply(this,arguments)}}(),this.sendRequest=function(){var a=(0,S.Z)(function*(l,f,g){const O=(0,$e.formatJsonRpcRequest)(f,g),w=yield o.core.crypto.encode(l,O),R=Hn[f].req;return o.core.history.set(l,O),o.core.relayer.publish(l,w,R),O.id});return function(l,f,g){return a.apply(this,arguments)}}(),this.sendResult=function(){var a=(0,S.Z)(function*(l,f,g){const O=(0,$e.formatJsonRpcResult)(l,g),w=yield o.core.crypto.encode(f,O),R=yield o.core.history.get(f,l),T=Hn[R.request.method].res;yield o.core.relayer.publish(f,w,T),yield o.core.history.resolve(O)});return function(l,f,g){return a.apply(this,arguments)}}(),this.sendError=function(){var a=(0,S.Z)(function*(l,f,g){const O=(0,$e.formatJsonRpcError)(l,g),w=yield o.core.crypto.encode(f,O),R=yield o.core.history.get(f,l),T=Hn[R.request.method]?Hn[R.request.method].res:Hn.unregistered_method.res;yield o.core.relayer.publish(f,w,T),yield o.core.history.resolve(O)});return function(l,f,g){return a.apply(this,arguments)}}(),this.deletePairing=function(){var a=(0,S.Z)(function*(l,f){yield o.core.relayer.unsubscribe(l),yield Promise.all([o.pairings.delete(l,at("USER_DISCONNECTED")),o.core.crypto.deleteSymKey(l),f?Promise.resolve():o.core.expirer.del(l)])});return function(l,f){return a.apply(this,arguments)}}(),this.cleanup=(0,S.Z)(function*(){const a=o.pairings.getAll().filter(l=>Ir(l.expiry));yield Promise.all(a.map(l=>o.deletePairing(l.topic)))}),this.onRelayEventRequest=a=>{const{topic:l,payload:f}=a;switch(f.method){case"wc_pairingPing":return this.onPairingPingRequest(l,f);case"wc_pairingDelete":return this.onPairingDeleteRequest(l,f);default:return this.onUnknownRpcMethodRequest(l,f)}},this.onRelayEventResponse=function(){var a=(0,S.Z)(function*(l){const{topic:f,payload:g}=l,O=(yield o.core.history.get(f,g.id)).request.method;return"wc_pairingPing"===O?o.onPairingPingResponse(f,g):o.onUnknownRpcMethodResponse(O)});return function(l){return a.apply(this,arguments)}}(),this.onPairingPingRequest=function(){var a=(0,S.Z)(function*(l,f){const{id:g}=f;try{o.isValidPing({topic:l}),yield o.sendResult(g,l,!0),o.events.emit("pairing_ping",{id:g,topic:l})}catch(O){yield o.sendError(g,l,O),o.logger.error(O)}});return function(l,f){return a.apply(this,arguments)}}(),this.onPairingPingResponse=(a,l)=>{const{id:f}=l;setTimeout(()=>{(0,$e.isJsonRpcResult)(l)?this.events.emit(st("pairing_ping",f),{}):(0,$e.isJsonRpcError)(l)&&this.events.emit(st("pairing_ping",f),{error:l.error})},500)},this.onPairingDeleteRequest=function(){var a=(0,S.Z)(function*(l,f){const{id:g}=f;try{o.isValidDisconnect({topic:l}),yield o.deletePairing(l),o.events.emit("pairing_delete",{id:g,topic:l})}catch(O){yield o.sendError(g,l,O),o.logger.error(O)}});return function(l,f){return a.apply(this,arguments)}}(),this.onUnknownRpcMethodRequest=function(){var a=(0,S.Z)(function*(l,f){const{id:g,method:O}=f;try{if(o.registeredMethods.includes(O))return;const w=at("WC_METHOD_UNSUPPORTED",O);yield o.sendError(g,l,w),o.logger.error(w)}catch(w){yield o.sendError(g,l,w),o.logger.error(w)}});return function(l,f){return a.apply(this,arguments)}}(),this.onUnknownRpcMethodResponse=a=>{this.registeredMethods.includes(a)||this.logger.error(at("WC_METHOD_UNSUPPORTED",a))},this.isValidPair=a=>{if(!It(a)){const{message:l}=Q("MISSING_OR_INVALID",`pair() params: ${a}`);throw new Error(l)}if(!function(s){if(ut(s,!1))try{return typeof new URL(s)<"u"}catch{return!1}return!1}(a.uri)){const{message:l}=Q("MISSING_OR_INVALID",`pair() uri: ${a.uri}`);throw new Error(l)}},this.isValidPing=function(){var a=(0,S.Z)(function*(l){if(!It(l)){const{message:g}=Q("MISSING_OR_INVALID",`ping() params: ${l}`);throw new Error(g)}const{topic:f}=l;yield o.isValidPairingTopic(f)});return function(l){return a.apply(this,arguments)}}(),this.isValidDisconnect=function(){var a=(0,S.Z)(function*(l){if(!It(l)){const{message:g}=Q("MISSING_OR_INVALID",`disconnect() params: ${l}`);throw new Error(g)}const{topic:f}=l;yield o.isValidPairingTopic(f)});return function(l){return a.apply(this,arguments)}}(),this.isValidPairingTopic=function(){var a=(0,S.Z)(function*(l){if(!ut(l,!1)){const{message:f}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${l}`);throw new Error(f)}if(!o.pairings.keys.includes(l)){const{message:f}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${l}`);throw new Error(f)}if(Ir(o.pairings.get(l).expiry)){yield o.deletePairing(l);const{message:f}=Q("EXPIRED",`pairing topic: ${l}`);throw new Error(f)}});return function(l){return a.apply(this,arguments)}}(),this.core=e,this.logger=(0,Ae.generateChildLogger)(t,this.name),this.pairings=new Ui(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,Ae.getLoggerContext)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){var e=this;this.core.relayer.on("relayer_message",function(){var t=(0,S.Z)(function*(o){const{topic:a,message:l}=o;if(!e.pairings.keys.includes(a)||e.ignoredPayloadTypes.includes(e.core.crypto.getPayloadType(l)))return;const f=yield e.core.crypto.decode(a,l);(0,$e.isJsonRpcRequest)(f)?(e.core.history.set(a,f),e.onRelayEventRequest({topic:a,payload:f})):(0,$e.isJsonRpcResponse)(f)&&(yield e.core.history.resolve(f),yield e.onRelayEventResponse({topic:a,payload:f}),e.core.history.delete(a,f.id))});return function(o){return t.apply(this,arguments)}}())}registerExpirerEvents(){var e=this;this.core.expirer.on(Ft_expired,function(){var t=(0,S.Z)(function*(o){const{topic:a}=Wa(o.target);a&&e.pairings.keys.includes(a)&&(yield e.deletePairing(a,!0),e.events.emit("pairing_expire",{topic:a}))});return function(o){return t.apply(this,arguments)}}())}}class Sm extends sp{constructor(e,t){var o;super(e,t),o=this,this.core=e,this.logger=t,this.records=new Map,this.events=new Le.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Sr,this.init=(0,S.Z)(function*(){o.initialized||(o.logger.trace("Initialized"),yield o.restore(),o.cached.forEach(a=>o.records.set(a.id,a)),o.cached=[],o.registerEventListeners(),o.initialized=!0)}),this.set=(a,l,f)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:a,request:l,chainId:f}),this.records.has(l.id))return;const g={id:l.id,topic:a,request:{method:l.method,params:l.params||null},chainId:f,expiry:Wt($.THIRTY_DAYS)};this.records.set(g.id,g),this.events.emit("history_created",g)},this.resolve=function(){var a=(0,S.Z)(function*(l){if(o.isInitialized(),o.logger.debug("Updating JSON-RPC response history record"),o.logger.trace({type:"method",method:"update",response:l}),!o.records.has(l.id))return;const f=yield o.getRecord(l.id);typeof f.response>"u"&&(f.response=(0,$e.isJsonRpcError)(l)?{error:l.error}:{result:l.result},o.records.set(f.id,f),o.events.emit("history_updated",f))});return function(l){return a.apply(this,arguments)}}(),this.get=function(){var a=(0,S.Z)(function*(l,f){return o.isInitialized(),o.logger.debug("Getting record"),o.logger.trace({type:"method",method:"get",topic:l,id:f}),yield o.getRecord(f)});return function(l,f){return a.apply(this,arguments)}}(),this.delete=(a,l)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:l}),this.values.forEach(f=>{if(f.topic===a){if(typeof l<"u"&&f.id!==l)return;this.records.delete(f.id),this.events.emit("history_deleted",f)}})},this.exists=function(){var a=(0,S.Z)(function*(l,f){return o.isInitialized(),!!o.records.has(f)&&(yield o.getRecord(f)).topic===l});return function(l,f){return a.apply(this,arguments)}}(),this.on=(a,l)=>{this.events.on(a,l)},this.once=(a,l)=>{this.events.once(a,l)},this.off=(a,l)=>{this.events.off(a,l)},this.removeListener=(a,l)=>{this.events.removeListener(a,l)},this.logger=(0,Ae.generateChildLogger)(t,this.name)}get context(){return(0,Ae.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const o={topic:t.topic,request:(0,$e.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(o)}),e}setJsonRpcRecords(e){var t=this;return(0,S.Z)(function*(){yield t.core.storage.setItem(t.storageKey,e)})()}getJsonRpcRecords(){var e=this;return(0,S.Z)(function*(){return yield e.core.storage.getItem(e.storageKey)})()}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:o}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(o)}return t}persist(){var e=this;return(0,S.Z)(function*(){yield e.setJsonRpcRecords(e.values),e.events.emit("history_sync")})()}restore(){var e=this;return(0,S.Z)(function*(){try{const t=yield e.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(e.records.size){const{message:o}=Q("RESTORE_WILL_OVERRIDE",e.name);throw e.logger.error(o),new Error(o)}e.cached=t,e.logger.debug(`Successfully Restored records for ${e.name}`),e.logger.trace({type:"method",method:"restore",records:e.values})}catch(t){e.logger.debug(`Failed to Restore records for ${e.name}`),e.logger.error(t)}})()}registerEventListeners(){this.events.on("history_created",e=>{const t="history_created";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.events.on("history_updated",e=>{const t="history_updated";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.events.on("history_deleted",e=>{const t="history_deleted";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.core.heartbeat.on(Zn.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(e=>{(0,$.toMiliseconds)(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id))})}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Nm extends fp{constructor(e,t){var o;super(e,t),o=this,this.core=e,this.logger=t,this.expirations=new Map,this.events=new Le.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Sr,this.init=(0,S.Z)(function*(){o.initialized||(o.logger.trace("Initialized"),yield o.restore(),o.cached.forEach(a=>o.expirations.set(a.target,a)),o.cached=[],o.registerEventListeners(),o.initialized=!0)}),this.has=a=>{try{const l=this.formatTarget(a);return typeof this.getExpiration(l)<"u"}catch{return!1}},this.set=(a,l)=>{this.isInitialized();const f=this.formatTarget(a),g={target:f,expiry:l};this.expirations.set(f,g),this.checkExpiry(f,g),this.events.emit("expirer_created",{target:f,expiration:g})},this.get=a=>{this.isInitialized();const l=this.formatTarget(a);return this.getExpiration(l)},this.del=a=>{if(this.isInitialized(),this.has(a)){const l=this.formatTarget(a),f=this.getExpiration(l);this.expirations.delete(l),this.events.emit("expirer_deleted",{target:l,expiration:f})}},this.on=(a,l)=>{this.events.on(a,l)},this.once=(a,l)=>{this.events.once(a,l)},this.off=(a,l)=>{this.events.off(a,l)},this.removeListener=(a,l)=>{this.events.removeListener(a,l)},this.logger=(0,Ae.generateChildLogger)(t,this.name)}get context(){return(0,Ae.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return Ha("topic",e);if("number"==typeof e)return function(s){return Ha("id",s)}(e);const{message:t}=Q("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}setExpirations(e){var t=this;return(0,S.Z)(function*(){yield t.core.storage.setItem(t.storageKey,e)})()}getExpirations(){var e=this;return(0,S.Z)(function*(){return yield e.core.storage.getItem(e.storageKey)})()}persist(){var e=this;return(0,S.Z)(function*(){yield e.setExpirations(e.values),e.events.emit("expirer_sync")})()}restore(){var e=this;return(0,S.Z)(function*(){try{const t=yield e.getExpirations();if(typeof t>"u"||!t.length)return;if(e.expirations.size){const{message:o}=Q("RESTORE_WILL_OVERRIDE",e.name);throw e.logger.error(o),new Error(o)}e.cached=t,e.logger.debug(`Successfully Restored expirations for ${e.name}`),e.logger.trace({type:"method",method:"restore",expirations:e.values})}catch(t){e.logger.debug(`Failed to Restore expirations for ${e.name}`),e.logger.error(t)}})()}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:o}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(o),new Error(o)}return t}checkExpiry(e,t){const{expiry:o}=t;(0,$.toMiliseconds)(o)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Ft_expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(Zn.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on("expirer_created",e=>{const t="expirer_created";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ft_expired,e=>{const t=Ft_expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on("expirer_deleted",e=>{const t="expirer_deleted";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Pm extends class{constructor(e,t){this.projectId=e,this.logger=t}}{constructor(e,t){var o;super(e,t),o=this,this.projectId=e,this.logger=t,this.name=vo,this.initialized=!1,this.init=function(){var a=(0,S.Z)(function*(l){Ka()||!uo()||(o.verifyUrl=l?.verifyUrl||xu,yield o.createIframe())});return function(l){return a.apply(this,arguments)}}(),this.register=function(){var a=(0,S.Z)(function*(l){var f;if(o.initialized||(yield o.init()),o.iframe)try{null==(f=o.iframe.contentWindow)||f.postMessage(l.attestationId,o.verifyUrl),o.logger.info(`postMessage sent: ${l.attestationId} ${o.verifyUrl}`)}catch{}});return function(l){return a.apply(this,arguments)}}(),this.resolve=function(){var a=(0,S.Z)(function*(l){var f;if(o.isDevEnv)return"";o.logger.info(`resolving attestation: ${l.attestationId}`);const g=o.startAbortTimer($.FIVE_SECONDS),O=yield fetch(`${o.verifyUrl}/attestation/${l.attestationId}`,{signal:o.abortController.signal});return clearTimeout(g),200===O.status?null==(f=yield O.json())?void 0:f.origin:""});return function(l){return a.apply(this,arguments)}}(),this.createIframe=(0,S.Z)(function*(){try{yield Promise.race([new Promise((a,l)=>{if(document.getElementById(vo))return a();const f=document.createElement("iframe");f.setAttribute("id",vo),f.setAttribute("src",`${o.verifyUrl}/${o.projectId}`),f.style.display="none",f.addEventListener("load",()=>{o.initialized=!0,a()}),f.addEventListener("error",g=>{l(g)}),document.body.append(f),o.iframe=f}),new Promise(a=>{setTimeout(()=>a("iframe load timeout"),(0,$.toMiliseconds)($.ONE_SECOND/2))})])}catch(a){o.logger.error(`Verify iframe failed to load: ${o.verifyUrl}`),o.logger.error(a)}}),this.logger=(0,Ae.generateChildLogger)(t,this.name),this.verifyUrl=xu,this.abortController=new AbortController,this.isDevEnv=ao()&&process.env.IS_VITEST}get context(){return(0,Ae.getLoggerContext)(this.logger)}startAbortTimer(e){return setTimeout(()=>this.abortController.abort(),(0,$.toMiliseconds)(e))}}var xm=Object.defineProperty,Fu=Object.getOwnPropertySymbols,Rm=Object.prototype.hasOwnProperty,Cm=Object.prototype.propertyIsEnumerable,Uu=(s,e,t)=>e in s?xm(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Mu=(s,e)=>{for(var t in e||(e={}))Rm.call(e,t)&&Uu(s,t,e[t]);if(Fu)for(var t of Fu(e))Cm.call(e,t)&&Uu(s,t,e[t]);return s};class wo extends ip{constructor(e){super(e),this.protocol="wc",this.version=2,this.name="core",this.events=new Le.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Nu;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,Ae.pino)((0,Ae.getDefaultLoggerOptions)({level:e?.logger||"error"}));this.logger=(0,Ae.generateChildLogger)(t,this.name),this.heartbeat=new Zn.HeartBeat,this.crypto=new om(this,this.logger,e?.keychain),this.history=new Sm(this,this.logger),this.expirer=new Nm(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new np.ZP(Mu(Mu({},jy),e?.storageOptions)),this.relayer=new bm({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Om(this,this.logger),this.verify=new Pm(this.projectId||"",this.logger)}static init(e){return(0,S.Z)(function*(){const t=new wo(e);yield t.initialize();const o=yield t.crypto.getClientId();return yield t.storage.setItem("WALLETCONNECT_CLIENT_ID",o),t})()}get context(){return(0,Ae.getLoggerContext)(this.logger)}start(){var e=this;return(0,S.Z)(function*(){e.initialized||(yield e.initialize())})()}initialize(){var e=this;return(0,S.Z)(function*(){e.logger.trace("Initialized");try{yield e.crypto.init(),yield e.history.init(),yield e.expirer.init(),yield e.relayer.init(),yield e.heartbeat.init(),yield e.pairing.init(),e.initialized=!0,e.logger.info("Core Initialization Success")}catch(t){throw e.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),e.logger.error(t.message),t}})()}}const Am=wo,Eo="wc@2:client:",Zu="Proposal expired",Mi=$.SEVEN_DAYS,Gn={wc_sessionPropose:{req:{ttl:$.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:$.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:$.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:$.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:$.ONE_DAY,prompt:!1,tag:1104},res:{ttl:$.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:$.ONE_DAY,prompt:!1,tag:1106},res:{ttl:$.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:$.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:$.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:$.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:$.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:$.ONE_DAY,prompt:!1,tag:1112},res:{ttl:$.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:$.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:$.THIRTY_SECONDS,prompt:!1,tag:1115}}},Oo={min:$.FIVE_MINUTES,max:$.SEVEN_DAYS},Um=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var Mm=Object.defineProperty,Lm=Object.defineProperties,km=Object.getOwnPropertyDescriptors,zu=Object.getOwnPropertySymbols,qm=Object.prototype.hasOwnProperty,Zm=Object.prototype.propertyIsEnumerable,Ku=(s,e,t)=>e in s?Mm(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ut=(s,e)=>{for(var t in e||(e={}))qm.call(e,t)&&Ku(s,t,e[t]);if(zu)for(var t of zu(e))Zm.call(e,t)&&Ku(s,t,e[t]);return s},So=(s,e)=>Lm(s,km(e));class zm extends class{constructor(e){this.client=e}}{constructor(e){var t;super(e),t=this,this.name="engine",this.events=new(We()),this.initialized=!1,this.ignoredPayloadTypes=[1],this.requestQueue={state:"idle",requests:[]},this.requestQueueDelay=$.ONE_SECOND,this.init=(0,S.Z)(function*(){t.initialized||(yield t.cleanup(),t.registerRelayerEvents(),t.registerExpirerEvents(),t.client.core.pairing.register({methods:Object.keys(Gn)}),t.initialized=!0,setTimeout(()=>{t.requestQueue.requests=t.getPendingSessionRequests(),t.processRequestQueue()},(0,$.toMiliseconds)(t.requestQueueDelay)))}),this.connect=function(){var o=(0,S.Z)(function*(a){t.isInitialized();const l=So(Ut({},a),{requiredNamespaces:a.requiredNamespaces||{},optionalNamespaces:a.optionalNamespaces||{}});yield t.isValidConnect(l);const{pairingTopic:f,requiredNamespaces:g,optionalNamespaces:O,sessionProperties:w,relays:R}=l;let H,T=f,te=!1;if(T&&(te=t.client.core.pairing.pairings.get(T).active),!T||!te){const{topic:re,uri:Ie}=yield t.client.core.pairing.create();T=re,H=Ie}const Z=yield t.client.core.crypto.generateKeyPair(),B=Ut({requiredNamespaces:g,optionalNamespaces:O,relays:R??[{protocol:"irn"}],proposer:{publicKey:Z,metadata:t.client.metadata}},w&&{sessionProperties:w}),{reject:Y,resolve:Fe,done:Qe}=_n($.FIVE_MINUTES,Zu);if(t.events.once(st("session_connect"),function(){var re=(0,S.Z)(function*({error:Ie,session:Ue}){if(Ie)Y(Ie);else if(Ue){Ue.self.publicKey=Z;const lt=So(Ut({},Ue),{requiredNamespaces:Ue.requiredNamespaces,optionalNamespaces:Ue.optionalNamespaces});yield t.client.session.set(Ue.topic,lt),yield t.setExpiry(Ue.topic,Ue.expiry),T&&(yield t.client.core.pairing.updateMetadata({topic:T,metadata:Ue.peer.metadata})),Fe(lt)}});return function(Ie){return re.apply(this,arguments)}}()),!T){const{message:re}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${T}`);throw new Error(re)}const De=yield t.sendRequest(T,"wc_sessionPropose",B),_e=Wt($.FIVE_MINUTES);return yield t.setProposal(De,Ut({id:De,expiry:_e},B)),{uri:H,approval:Qe}});return function(a){return o.apply(this,arguments)}}(),this.pair=function(){var o=(0,S.Z)(function*(a){return t.isInitialized(),yield t.client.core.pairing.pair(a)});return function(a){return o.apply(this,arguments)}}(),this.approve=function(){var o=(0,S.Z)(function*(a){t.isInitialized(),yield t.isValidApprove(a);const{id:l,relayProtocol:f,namespaces:g,sessionProperties:O}=a,w=t.client.proposal.get(l);let{pairingTopic:R,proposer:T,requiredNamespaces:H,optionalNamespaces:te}=w;R=R||"",wn(H)||(H=function(s,e){const t=Di(s,"approve()");if(t)throw new Error(t.message);const o={};for(const[a,l]of Object.entries(s))o[a]={methods:l.methods,events:l.events,chains:l.accounts.map(f=>`${f.split(":")[0]}:${f.split(":")[1]}`)};return o}(g));const Z=yield t.client.core.crypto.generateKeyPair(),B=T.publicKey,Y=yield t.client.core.crypto.generateSharedKey(Z,B);R&&l&&(yield t.client.core.pairing.updateMetadata({topic:R,metadata:T.metadata}),yield t.sendResult(l,R,{relay:{protocol:f??"irn"},responderPublicKey:Z}),yield t.client.proposal.delete(l,at("USER_DISCONNECTED")),yield t.client.core.pairing.activate({topic:R}));const Fe=Ut({relay:{protocol:f??"irn"},namespaces:g,requiredNamespaces:H,optionalNamespaces:te,pairingTopic:R,controller:{publicKey:Z,metadata:t.client.metadata},expiry:Wt(Mi)},O&&{sessionProperties:O});yield t.client.core.relayer.subscribe(Y),yield t.sendRequest(Y,"wc_sessionSettle",Fe);const Qe=So(Ut({},Fe),{topic:Y,pairingTopic:R,acknowledged:!1,self:Fe.controller,peer:{publicKey:T.publicKey,metadata:T.metadata},controller:Z});return yield t.client.session.set(Y,Qe),yield t.setExpiry(Y,Wt(Mi)),{topic:Y,acknowledged:()=>new Promise(De=>setTimeout(()=>De(t.client.session.get(Y)),500))}});return function(a){return o.apply(this,arguments)}}(),this.reject=function(){var o=(0,S.Z)(function*(a){t.isInitialized(),yield t.isValidReject(a);const{id:l,reason:f}=a,{pairingTopic:g}=t.client.proposal.get(l);g&&(yield t.sendError(l,g,f),yield t.client.proposal.delete(l,at("USER_DISCONNECTED")))});return function(a){return o.apply(this,arguments)}}(),this.update=function(){var o=(0,S.Z)(function*(a){t.isInitialized(),yield t.isValidUpdate(a);const{topic:l,namespaces:f}=a,g=yield t.sendRequest(l,"wc_sessionUpdate",{namespaces:f}),{done:O,resolve:w,reject:R}=_n();return t.events.once(st("session_update",g),({error:T})=>{T?R(T):w()}),yield t.client.session.update(l,{namespaces:f}),{acknowledged:O}});return function(a){return o.apply(this,arguments)}}(),this.extend=function(){var o=(0,S.Z)(function*(a){t.isInitialized(),yield t.isValidExtend(a);const{topic:l}=a,f=yield t.sendRequest(l,"wc_sessionExtend",{}),{done:g,resolve:O,reject:w}=_n();return t.events.once(st("session_extend",f),({error:R})=>{R?w(R):O()}),yield t.setExpiry(l,Wt(Mi)),{acknowledged:g}});return function(a){return o.apply(this,arguments)}}(),this.request=function(){var o=(0,S.Z)(function*(a){t.isInitialized(),yield t.isValidRequest(a);const{chainId:l,request:f,topic:g,expiry:O}=a,w=yield t.sendRequest(g,"wc_sessionRequest",{request:f,chainId:l},O),{done:R,resolve:T,reject:H}=_n(O);return t.events.once(st("session_request",w),({error:Z,result:B})=>{Z?H(Z):T(B)}),t.client.events.emit("session_request_sent",{topic:g,request:f,chainId:l,id:w}),function(s){lo.apply(this,arguments)}({id:w,topic:g,wcDeepLink:yield t.client.core.storage.getItem("WALLETCONNECT_DEEPLINK_CHOICE")}),yield R()});return function(a){return o.apply(this,arguments)}}(),this.respond=function(){var o=(0,S.Z)(function*(a){t.isInitialized(),yield t.isValidRespond(a);const{topic:l,response:f}=a,{id:g}=f;(0,$e.isJsonRpcResult)(f)?yield t.sendResult(g,l,f.result):(0,$e.isJsonRpcError)(f)&&(yield t.sendError(g,l,f.error)),t.cleanupAfterResponse(a)});return function(a){return o.apply(this,arguments)}}(),this.ping=function(){var o=(0,S.Z)(function*(a){t.isInitialized(),yield t.isValidPing(a);const{topic:l}=a;if(t.client.session.keys.includes(l)){const f=yield t.sendRequest(l,"wc_sessionPing",{}),{done:g,resolve:O,reject:w}=_n();t.events.once(st("session_ping",f),({error:R})=>{R?w(R):O()}),yield g()}else t.client.core.pairing.pairings.keys.includes(l)&&(yield t.client.core.pairing.ping({topic:l}))});return function(a){return o.apply(this,arguments)}}(),this.emit=function(){var o=(0,S.Z)(function*(a){t.isInitialized(),yield t.isValidEmit(a);const{topic:l,event:f,chainId:g}=a;yield t.sendRequest(l,"wc_sessionEvent",{event:f,chainId:g})});return function(a){return o.apply(this,arguments)}}(),this.disconnect=function(){var o=(0,S.Z)(function*(a){t.isInitialized(),yield t.isValidDisconnect(a);const{topic:l}=a;if(t.client.session.keys.includes(l)){const f=(0,$e.getBigIntRpcId)().toString();let g;const O=w=>{w?.id.toString()===f&&(t.client.core.relayer.events.removeListener("relayer_message_ack",O),g())};yield Promise.all([new Promise(w=>{g=w,t.client.core.relayer.on("relayer_message_ack",O)}),t.sendRequest(l,"wc_sessionDelete",at("USER_DISCONNECTED"),void 0,f)]),yield t.deleteSession(l)}else yield t.client.core.pairing.disconnect({topic:l})});return function(a){return o.apply(this,arguments)}}(),this.find=o=>(this.isInitialized(),this.client.session.getAll().filter(a=>function(s,e){const{requiredNamespaces:t}=e,o=Object.keys(s.namespaces),a=Object.keys(t);let l=!0;return!!Wr(a,o)&&(o.forEach(f=>{const{accounts:g,methods:O,events:w}=s.namespaces[f],R=bn(g),T=t[f];Wr(eo(f,T),R)&&Wr(T.methods,O)&&Wr(T.events,w)||(l=!1)}),l)}(a,o))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=function(){var o=(0,S.Z)(function*(a){if(a.pairingTopic)try{const l=t.client.core.pairing.pairings.get(a.pairingTopic),f=t.client.core.pairing.pairings.getAll().filter(g=>{var O,w;return(null==(O=g.peerMetadata)?void 0:O.url)&&(null==(w=g.peerMetadata)?void 0:w.url)===a.peer.metadata.url&&g.topic&&g.topic!==l.topic});if(0===f.length)return;t.client.logger.info(`Cleaning up ${f.length} duplicate pairing(s)`),yield Promise.all(f.map(g=>t.client.core.pairing.disconnect({topic:g.topic}))),t.client.logger.info("Duplicate pairings clean up finished")}catch(l){t.client.logger.error(l)}});return function(a){return o.apply(this,arguments)}}(),this.deleteSession=function(){var o=(0,S.Z)(function*(a,l){const{self:f}=t.client.session.get(a);yield t.client.core.relayer.unsubscribe(a),t.client.session.delete(a,at("USER_DISCONNECTED")),t.client.core.crypto.keychain.has(f.publicKey)&&(yield t.client.core.crypto.deleteKeyPair(f.publicKey)),t.client.core.crypto.keychain.has(a)&&(yield t.client.core.crypto.deleteSymKey(a)),l||t.client.core.expirer.del(a)});return function(a,l){return o.apply(this,arguments)}}(),this.deleteProposal=function(){var o=(0,S.Z)(function*(a,l){yield Promise.all([t.client.proposal.delete(a,at("USER_DISCONNECTED")),l?Promise.resolve():t.client.core.expirer.del(a)])});return function(a,l){return o.apply(this,arguments)}}(),this.deletePendingSessionRequest=function(){var o=(0,S.Z)(function*(a,l,f=!1){yield Promise.all([t.client.pendingRequest.delete(a,l),f?Promise.resolve():t.client.core.expirer.del(a)]),t.requestQueue.requests=t.requestQueue.requests.filter(g=>g.id!==a),f&&(t.requestQueue.state="idle")});return function(a,l){return o.apply(this,arguments)}}(),this.setExpiry=function(){var o=(0,S.Z)(function*(a,l){t.client.session.keys.includes(a)&&(yield t.client.session.update(a,{expiry:l})),t.client.core.expirer.set(a,l)});return function(a,l){return o.apply(this,arguments)}}(),this.setProposal=function(){var o=(0,S.Z)(function*(a,l){yield t.client.proposal.set(a,l),t.client.core.expirer.set(a,l.expiry)});return function(a,l){return o.apply(this,arguments)}}(),this.setPendingSessionRequest=function(){var o=(0,S.Z)(function*(a){const l=Gn.wc_sessionRequest.req.ttl,{id:f,topic:g,params:O}=a;yield t.client.pendingRequest.set(f,{id:f,topic:g,params:O}),l&&t.client.core.expirer.set(f,Wt(l))});return function(a){return o.apply(this,arguments)}}(),this.sendRequest=function(){var o=(0,S.Z)(function*(a,l,f,g,O){const w=(0,$e.formatJsonRpcRequest)(l,f);if(uo()&&Um.includes(l)){const H=dn(JSON.stringify(w));yield t.client.core.verify.register({attestationId:H})}const R=yield t.client.core.crypto.encode(a,w),T=Gn[l].req;return g&&(T.ttl=g),O&&(T.id=O),t.client.core.history.set(a,w),t.client.core.relayer.publish(a,R,T),w.id});return function(a,l,f,g,O){return o.apply(this,arguments)}}(),this.sendResult=function(){var o=(0,S.Z)(function*(a,l,f){const g=(0,$e.formatJsonRpcResult)(a,f),O=yield t.client.core.crypto.encode(l,g),w=yield t.client.core.history.get(l,a);t.client.core.relayer.publish(l,O,Gn[w.request.method].res),yield t.client.core.history.resolve(g)});return function(a,l,f){return o.apply(this,arguments)}}(),this.sendError=function(){var o=(0,S.Z)(function*(a,l,f){const g=(0,$e.formatJsonRpcError)(a,f),O=yield t.client.core.crypto.encode(l,g),w=yield t.client.core.history.get(l,a);t.client.core.relayer.publish(l,O,Gn[w.request.method].res),yield t.client.core.history.resolve(g)});return function(a,l,f){return o.apply(this,arguments)}}(),this.cleanup=(0,S.Z)(function*(){const o=[],a=[];t.client.session.getAll().forEach(l=>{Ir(l.expiry)&&o.push(l.topic)}),t.client.proposal.getAll().forEach(l=>{Ir(l.expiry)&&a.push(l.id)}),yield Promise.all([...o.map(l=>t.deleteSession(l)),...a.map(l=>t.deleteProposal(l))])}),this.onRelayEventRequest=o=>{const{topic:a,payload:l}=o,f=l.method;switch(f){case"wc_sessionPropose":return this.onSessionProposeRequest(a,l);case"wc_sessionSettle":return this.onSessionSettleRequest(a,l);case"wc_sessionUpdate":return this.onSessionUpdateRequest(a,l);case"wc_sessionExtend":return this.onSessionExtendRequest(a,l);case"wc_sessionPing":return this.onSessionPingRequest(a,l);case"wc_sessionDelete":return this.onSessionDeleteRequest(a,l);case"wc_sessionRequest":return this.onSessionRequest(a,l);case"wc_sessionEvent":return this.onSessionEventRequest(a,l);default:return this.client.logger.info(`Unsupported request method ${f}`)}},this.onRelayEventResponse=function(){var o=(0,S.Z)(function*(a){const{topic:l,payload:f}=a,g=(yield t.client.core.history.get(l,f.id)).request.method;switch(g){case"wc_sessionPropose":return t.onSessionProposeResponse(l,f);case"wc_sessionSettle":return t.onSessionSettleResponse(l,f);case"wc_sessionUpdate":return t.onSessionUpdateResponse(l,f);case"wc_sessionExtend":return t.onSessionExtendResponse(l,f);case"wc_sessionPing":return t.onSessionPingResponse(l,f);case"wc_sessionRequest":return t.onSessionRequestResponse(l,f);default:return t.client.logger.info(`Unsupported response method ${g}`)}});return function(a){return o.apply(this,arguments)}}(),this.onRelayEventUnknownPayload=o=>{const{topic:a}=o,{message:l}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${a} is not identifiable as a JSON-RPC request or a response.`);throw new Error(l)},this.onSessionProposeRequest=function(){var o=(0,S.Z)(function*(a,l){const{params:f,id:g}=l;try{t.isValidConnect(Ut({},l.params));const O=Wt($.FIVE_MINUTES),w=Ut({id:g,pairingTopic:a,expiry:O},f);yield t.setProposal(g,w);const R=dn(JSON.stringify(l)),T=yield t.getVerifyContext(R,w.proposer.metadata);t.client.events.emit("session_proposal",{id:g,params:w,verifyContext:T})}catch(O){yield t.sendError(g,a,O),t.client.logger.error(O)}});return function(a,l){return o.apply(this,arguments)}}(),this.onSessionProposeResponse=function(){var o=(0,S.Z)(function*(a,l){const{id:f}=l;if((0,$e.isJsonRpcResult)(l)){const{result:g}=l;t.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:g});const O=t.client.proposal.get(f);t.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:O});const w=O.proposer.publicKey;t.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:w});const R=g.responderPublicKey;t.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:R});const T=yield t.client.core.crypto.generateSharedKey(w,R);t.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:T});const H=yield t.client.core.relayer.subscribe(T);t.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:H}),yield t.client.core.pairing.activate({topic:a})}else(0,$e.isJsonRpcError)(l)&&(yield t.client.proposal.delete(f,at("USER_DISCONNECTED")),t.events.emit(st("session_connect"),{error:l.error}))});return function(a,l){return o.apply(this,arguments)}}(),this.onSessionSettleRequest=function(){var o=(0,S.Z)(function*(a,l){const{id:f,params:g}=l;try{t.isValidSessionSettleRequest(g);const{relay:O,controller:w,expiry:R,namespaces:T,requiredNamespaces:H,optionalNamespaces:te,sessionProperties:Z,pairingTopic:B}=l.params,Y=Ut({topic:a,relay:O,expiry:R,namespaces:T,acknowledged:!0,pairingTopic:B,requiredNamespaces:H,optionalNamespaces:te,controller:w.publicKey,self:{publicKey:"",metadata:t.client.metadata},peer:{publicKey:w.publicKey,metadata:w.metadata}},Z&&{sessionProperties:Z});yield t.sendResult(l.id,a,!0),t.events.emit(st("session_connect"),{session:Y}),t.cleanupDuplicatePairings(Y)}catch(O){yield t.sendError(f,a,O),t.client.logger.error(O)}});return function(a,l){return o.apply(this,arguments)}}(),this.onSessionSettleResponse=function(){var o=(0,S.Z)(function*(a,l){const{id:f}=l;(0,$e.isJsonRpcResult)(l)?(yield t.client.session.update(a,{acknowledged:!0}),t.events.emit(st("session_approve",f),{})):(0,$e.isJsonRpcError)(l)&&(yield t.client.session.delete(a,at("USER_DISCONNECTED")),t.events.emit(st("session_approve",f),{error:l.error}))});return function(a,l){return o.apply(this,arguments)}}(),this.onSessionUpdateRequest=function(){var o=(0,S.Z)(function*(a,l){const{params:f,id:g}=l;try{t.isValidUpdate(Ut({topic:a},f)),yield t.client.session.update(a,{namespaces:f.namespaces}),yield t.sendResult(g,a,!0),t.client.events.emit("session_update",{id:g,topic:a,params:f})}catch(O){yield t.sendError(g,a,O),t.client.logger.error(O)}});return function(a,l){return o.apply(this,arguments)}}(),this.onSessionUpdateResponse=(o,a)=>{const{id:l}=a;(0,$e.isJsonRpcResult)(a)?this.events.emit(st("session_update",l),{}):(0,$e.isJsonRpcError)(a)&&this.events.emit(st("session_update",l),{error:a.error})},this.onSessionExtendRequest=function(){var o=(0,S.Z)(function*(a,l){const{id:f}=l;try{t.isValidExtend({topic:a}),yield t.setExpiry(a,Wt(Mi)),yield t.sendResult(f,a,!0),t.client.events.emit("session_extend",{id:f,topic:a})}catch(g){yield t.sendError(f,a,g),t.client.logger.error(g)}});return function(a,l){return o.apply(this,arguments)}}(),this.onSessionExtendResponse=(o,a)=>{const{id:l}=a;(0,$e.isJsonRpcResult)(a)?this.events.emit(st("session_extend",l),{}):(0,$e.isJsonRpcError)(a)&&this.events.emit(st("session_extend",l),{error:a.error})},this.onSessionPingRequest=function(){var o=(0,S.Z)(function*(a,l){const{id:f}=l;try{t.isValidPing({topic:a}),yield t.sendResult(f,a,!0),t.client.events.emit("session_ping",{id:f,topic:a})}catch(g){yield t.sendError(f,a,g),t.client.logger.error(g)}});return function(a,l){return o.apply(this,arguments)}}(),this.onSessionPingResponse=(o,a)=>{const{id:l}=a;setTimeout(()=>{(0,$e.isJsonRpcResult)(a)?this.events.emit(st("session_ping",l),{}):(0,$e.isJsonRpcError)(a)&&this.events.emit(st("session_ping",l),{error:a.error})},500)},this.onSessionDeleteRequest=function(){var o=(0,S.Z)(function*(a,l){const{id:f}=l;try{t.isValidDisconnect({topic:a,reason:l.params}),yield Promise.all([new Promise(g=>{t.client.core.relayer.once("relayer_publish",(0,S.Z)(function*(){g(yield t.deleteSession(a))}))}),t.sendResult(f,a,!0)]),t.client.events.emit("session_delete",{id:f,topic:a})}catch(g){t.client.logger.error(g)}});return function(a,l){return o.apply(this,arguments)}}(),this.onSessionRequest=function(){var o=(0,S.Z)(function*(a,l){const{id:f,params:g}=l;try{t.isValidRequest(Ut({topic:a},g)),yield t.setPendingSessionRequest({id:f,topic:a,params:g}),t.addRequestToQueue({id:f,topic:a,params:g}),yield t.processRequestQueue()}catch(O){yield t.sendError(f,a,O),t.client.logger.error(O)}});return function(a,l){return o.apply(this,arguments)}}(),this.onSessionRequestResponse=(o,a)=>{const{id:l}=a;(0,$e.isJsonRpcResult)(a)?this.events.emit(st("session_request",l),{result:a.result}):(0,$e.isJsonRpcError)(a)&&this.events.emit(st("session_request",l),{error:a.error})},this.onSessionEventRequest=function(){var o=(0,S.Z)(function*(a,l){const{id:f,params:g}=l;try{t.isValidEmit(Ut({topic:a},g)),t.client.events.emit("session_event",{id:f,topic:a,params:g})}catch(O){yield t.sendError(f,a,O),t.client.logger.error(O)}});return function(a,l){return o.apply(this,arguments)}}(),this.addRequestToQueue=o=>{this.requestQueue.requests.push(o)},this.cleanupAfterResponse=o=>{this.deletePendingSessionRequest(o.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.requestQueue.state="idle",this.processRequestQueue()},(0,$.toMiliseconds)(this.requestQueueDelay))},this.processRequestQueue=(0,S.Z)(function*(){if("active"===t.requestQueue.state)return void t.client.logger.info("session request queue is already active.");const o=t.requestQueue.requests[0];if(o)try{const{id:a,topic:l,params:f}=o,g=dn(JSON.stringify({id:a,params:f})),O=t.client.session.get(l),w=yield t.getVerifyContext(g,O.peer.metadata);t.requestQueue.state="active",t.client.events.emit("session_request",{id:a,topic:l,params:f,verifyContext:w})}catch(a){t.client.logger.error(a)}else t.client.logger.info("session request queue is empty.")}),this.isValidConnect=function(){var o=(0,S.Z)(function*(a){if(!It(a)){const{message:R}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(a)}`);throw new Error(R)}const{pairingTopic:l,requiredNamespaces:f,optionalNamespaces:g,sessionProperties:O,relays:w}=a;if(mt(l)||(yield t.isValidPairingTopic(l)),!function(s,e){let t=!1;return s?s&&Kn(s)&&s.length&&s.forEach(o=>{t=nu(o)}):t=!0,t}(w)){const{message:R}=Q("MISSING_OR_INVALID",`connect() relays: ${w}`);throw new Error(R)}!mt(f)&&0!==wn(f)&&t.validateNamespaces(f,"requiredNamespaces"),!mt(g)&&0!==wn(g)&&t.validateNamespaces(g,"optionalNamespaces"),mt(O)||t.validateSessionProps(O,"sessionProperties")});return function(a){return o.apply(this,arguments)}}(),this.validateNamespaces=(o,a)=>{const l=function(s,e,t){let o=null;if(s&&wn(s)){const a=ru(s,e);a&&(o=a);const l=function(s,e,t){let o=null;return Object.entries(s).forEach(([a,l])=>{if(o)return;const f=function(s,e,t){let o=null;return Kn(e)&&e.length?e.forEach(a=>{o||$i(a)||(o=at("UNSUPPORTED_CHAINS",`${t}, chain ${a} should be a string and conform to "namespace:chainId" format`))}):$i(s)||(o=at("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),o}(a,eo(a,l),`${e} ${t}`);f&&(o=f)}),o}(s,e,t);l&&(o=l)}else o=Q("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return o}(o,"connect()",a);if(l)throw new Error(l.message)},this.isValidApprove=function(){var o=(0,S.Z)(function*(a){if(!It(a))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${a}`).message);const{id:l,namespaces:f,relayProtocol:g,sessionProperties:O}=a;yield t.isValidProposalId(l);const w=t.client.proposal.get(l),R=Di(f,"approve()");if(R)throw new Error(R.message);const T=po(w.requiredNamespaces,f,"approve()");if(T)throw new Error(T.message);if(!ut(g,!0)){const{message:H}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${g}`);throw new Error(H)}mt(O)||t.validateSessionProps(O,"sessionProperties")});return function(a){return o.apply(this,arguments)}}(),this.isValidReject=function(){var o=(0,S.Z)(function*(a){if(!It(a)){const{message:g}=Q("MISSING_OR_INVALID",`reject() params: ${a}`);throw new Error(g)}const{id:l,reason:f}=a;if(yield t.isValidProposalId(l),!((s=f)&&"object"==typeof s&&s.code&&ho(s.code,!1)&&s.message&&ut(s.message,!1))){const{message:g}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(f)}`);throw new Error(g)}var s});return function(a){return o.apply(this,arguments)}}(),this.isValidSessionSettleRequest=o=>{if(!It(o)){const{message:R}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${o}`);throw new Error(R)}const{relay:a,controller:l,namespaces:f,expiry:g}=o;if(!nu(a)){const{message:R}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(R)}const O=function(s,e){let t=null;return ut(s?.publicKey,!1)||(t=Q("MISSING_OR_INVALID","onSessionSettleRequest() controller public key should be a string")),t}(l);if(O)throw new Error(O.message);const w=Di(f,"onSessionSettleRequest()");if(w)throw new Error(w.message);if(Ir(g)){const{message:R}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(R)}},this.isValidUpdate=function(){var o=(0,S.Z)(function*(a){if(!It(a)){const{message:R}=Q("MISSING_OR_INVALID",`update() params: ${a}`);throw new Error(R)}const{topic:l,namespaces:f}=a;yield t.isValidSessionTopic(l);const g=t.client.session.get(l),O=Di(f,"update()");if(O)throw new Error(O.message);const w=po(g.requiredNamespaces,f,"update()");if(w)throw new Error(w.message)});return function(a){return o.apply(this,arguments)}}(),this.isValidExtend=function(){var o=(0,S.Z)(function*(a){if(!It(a)){const{message:f}=Q("MISSING_OR_INVALID",`extend() params: ${a}`);throw new Error(f)}const{topic:l}=a;yield t.isValidSessionTopic(l)});return function(a){return o.apply(this,arguments)}}(),this.isValidRequest=function(){var o=(0,S.Z)(function*(a){if(!It(a)){const{message:R}=Q("MISSING_OR_INVALID",`request() params: ${a}`);throw new Error(R)}const{topic:l,request:f,chainId:g,expiry:O}=a;yield t.isValidSessionTopic(l);const{namespaces:w}=t.client.session.get(l);if(!iu(w,g)){const{message:R}=Q("MISSING_OR_INVALID",`request() chainId: ${g}`);throw new Error(R)}if(mt(s=f)||!ut(s.method,!1)){const{message:R}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(f)}`);throw new Error(R)}var s;if(!function(s,e,t){return!!ut(t,!1)&&function(s,e){const t=[];return Object.values(s).forEach(o=>{bn(o.accounts).includes(e)&&t.push(...o.methods)}),t}(s,e).includes(t)}(w,g,f.method)){const{message:R}=Q("MISSING_OR_INVALID",`request() method: ${f.method}`);throw new Error(R)}if(O&&!function(s,e){return ho(s,!1)&&s<=e.max&&s>=e.min}(O,Oo)){const{message:R}=Q("MISSING_OR_INVALID",`request() expiry: ${O}. Expiry must be a number (in seconds) between ${Oo.min} and ${Oo.max}`);throw new Error(R)}});return function(a){return o.apply(this,arguments)}}(),this.isValidRespond=function(){var o=(0,S.Z)(function*(a){if(!It(a)){const{message:g}=Q("MISSING_OR_INVALID",`respond() params: ${a}`);throw new Error(g)}const{topic:l,response:f}=a;if(yield t.isValidSessionTopic(l),mt(s=f)||mt(s.result)&&mt(s.error)||!ho(s.id,!1)||!ut(s.jsonrpc,!1)){const{message:g}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(f)}`);throw new Error(g)}var s});return function(a){return o.apply(this,arguments)}}(),this.isValidPing=function(){var o=(0,S.Z)(function*(a){if(!It(a)){const{message:f}=Q("MISSING_OR_INVALID",`ping() params: ${a}`);throw new Error(f)}const{topic:l}=a;yield t.isValidSessionOrPairingTopic(l)});return function(a){return o.apply(this,arguments)}}(),this.isValidEmit=function(){var o=(0,S.Z)(function*(a){if(!It(a)){const{message:w}=Q("MISSING_OR_INVALID",`emit() params: ${a}`);throw new Error(w)}const{topic:l,event:f,chainId:g}=a;yield t.isValidSessionTopic(l);const{namespaces:O}=t.client.session.get(l);if(!iu(O,g)){const{message:w}=Q("MISSING_OR_INVALID",`emit() chainId: ${g}`);throw new Error(w)}if(mt(s=f)||!ut(s.name,!1)){const{message:w}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(f)}`);throw new Error(w)}var s;if(!function(s,e,t){return!!ut(t,!1)&&function(s,e){const t=[];return Object.values(s).forEach(o=>{bn(o.accounts).includes(e)&&t.push(...o.events)}),t}(s,e).includes(t)}(O,g,f.name)){const{message:w}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(f)}`);throw new Error(w)}});return function(a){return o.apply(this,arguments)}}(),this.isValidDisconnect=function(){var o=(0,S.Z)(function*(a){if(!It(a)){const{message:f}=Q("MISSING_OR_INVALID",`disconnect() params: ${a}`);throw new Error(f)}const{topic:l}=a;yield t.isValidSessionOrPairingTopic(l)});return function(a){return o.apply(this,arguments)}}(),this.getVerifyContext=function(){var o=(0,S.Z)(function*(a,l){const f={verified:{verifyUrl:l.verifyUrl||"",validation:"UNKNOWN",origin:l.url||""}};try{const g=yield t.client.core.verify.resolve({attestationId:a,verifyUrl:l.verifyUrl});g&&(f.verified.origin=g,f.verified.validation=g===l.url?"VALID":"INVALID")}catch(g){t.client.logger.error(g)}return t.client.logger.info(`Verify context: ${JSON.stringify(f)}`),f});return function(a,l){return o.apply(this,arguments)}}(),this.validateSessionProps=(o,a)=>{Object.values(o).forEach(l=>{if(!ut(l,!1)){const{message:f}=Q("MISSING_OR_INVALID",`${a} must be in Record<string, string> format. Received: ${JSON.stringify(l)}`);throw new Error(f)}})}}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){var e=this;this.client.core.relayer.on("relayer_message",function(){var t=(0,S.Z)(function*(o){const{topic:a,message:l}=o;if(e.ignoredPayloadTypes.includes(e.client.core.crypto.getPayloadType(l)))return;const f=yield e.client.core.crypto.decode(a,l);(0,$e.isJsonRpcRequest)(f)?(e.client.core.history.set(a,f),e.onRelayEventRequest({topic:a,payload:f})):(0,$e.isJsonRpcResponse)(f)?(yield e.client.core.history.resolve(f),yield e.onRelayEventResponse({topic:a,payload:f}),e.client.core.history.delete(a,f.id)):e.onRelayEventUnknownPayload({topic:a,payload:f})});return function(o){return t.apply(this,arguments)}}())}registerExpirerEvents(){var e=this;this.client.core.expirer.on(Ft_expired,function(){var t=(0,S.Z)(function*(o){const{topic:a,id:l}=Wa(o.target);if(l&&e.client.pendingRequest.keys.includes(l))return yield e.deletePendingSessionRequest(l,Q("EXPIRED"),!0);a?e.client.session.keys.includes(a)&&(yield e.deleteSession(a,!0),e.client.events.emit("session_expire",{topic:a})):l&&(yield e.deleteProposal(l,!0),e.client.events.emit("proposal_expire",{id:l}))});return function(o){return t.apply(this,arguments)}}())}isValidPairingTopic(e){if(!ut(e,!1)){const{message:t}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Ir(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=Q("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}isValidSessionTopic(e){var t=this;return(0,S.Z)(function*(){if(!ut(e,!1)){const{message:o}=Q("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(o)}if(!t.client.session.keys.includes(e)){const{message:o}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(o)}if(Ir(t.client.session.get(e).expiry)){yield t.deleteSession(e);const{message:o}=Q("EXPIRED",`session topic: ${e}`);throw new Error(o)}})()}isValidSessionOrPairingTopic(e){var t=this;return(0,S.Z)(function*(){if(t.client.session.keys.includes(e))yield t.isValidSessionTopic(e);else{if(!t.client.core.pairing.pairings.keys.includes(e)){if(ut(e,!1)){const{message:o}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(o)}{const{message:o}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(o)}}t.isValidPairingTopic(e)}})()}isValidProposalId(e){var t=this;return(0,S.Z)(function*(){if("number"!=typeof e){const{message:o}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(o)}if(!t.client.proposal.keys.includes(e)){const{message:o}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(o)}if(Ir(t.client.proposal.get(e).expiry)){yield t.deleteProposal(e);const{message:o}=Q("EXPIRED",`proposal id: ${e}`);throw new Error(o)}})()}}class Km extends Ui{constructor(e,t){super(e,t,"proposal",Eo),this.core=e,this.logger=t}}class Vm extends Ui{constructor(e,t){super(e,t,"session",Eo),this.core=e,this.logger=t}}class Bm extends Ui{constructor(e,t){super(e,t,"request",Eo,o=>o.id),this.core=e,this.logger=t}}class No extends class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}{constructor(e){var t;super(e),t=this,this.protocol="wc",this.version=2,this.name="client",this.events=new Le.EventEmitter,this.on=(a,l)=>this.events.on(a,l),this.once=(a,l)=>this.events.once(a,l),this.off=(a,l)=>this.events.off(a,l),this.removeListener=(a,l)=>this.events.removeListener(a,l),this.removeAllListeners=a=>this.events.removeAllListeners(a),this.connect=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.connect(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.pair=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.pair(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.approve=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.approve(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.reject=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.reject(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.update=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.update(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.extend=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.extend(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.request=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.request(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.respond=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.respond(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.ping=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.ping(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.emit=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.emit(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.disconnect=function(){var a=(0,S.Z)(function*(l){try{return yield t.engine.disconnect(l)}catch(f){throw t.logger.error(f.message),f}});return function(l){return a.apply(this,arguments)}}(),this.find=a=>{try{return this.engine.find(a)}catch(l){throw this.logger.error(l.message),l}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(a){throw this.logger.error(a.message),a}},this.name=e?.name||"client",this.metadata=e?.metadata||(0,Ap.D)()||{name:"",description:"",url:"",icons:[""]};const o=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,Ae.pino)((0,Ae.getDefaultLoggerOptions)({level:e?.logger||"error"}));this.core=e?.core||new Am(e),this.logger=(0,Ae.generateChildLogger)(o,this.name),this.session=new Vm(this.core,this.logger),this.proposal=new Km(this.core,this.logger),this.pendingRequest=new Bm(this.core,this.logger),this.engine=new zm(this)}static init(e){return(0,S.Z)(function*(){const t=new No(e);return yield t.initialize(),t})()}get context(){return(0,Ae.getLoggerContext)(this.logger)}get pairing(){return this.core.pairing.pairings}initialize(){var e=this;return(0,S.Z)(function*(){e.logger.trace("Initialized");try{yield e.core.start(),yield e.session.init(),yield e.proposal.init(),yield e.pendingRequest.init(),yield e.engine.init(),e.core.verify.init({verifyUrl:e.metadata.verifyUrl}),e.logger.info("SignClient Initialization Success")}catch(t){throw e.logger.info("SignClient Initialization Failure"),e.logger.error(t.message),t}})()}}function ir(s=[],e=[]){return[...new Set([...s,...e])]}function Zi(s){return s.includes(":")}function Yn(s){return Zi(s)?s.split(":")[0]:s}K(7092),K(47274),K(49290);const Mv={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}};function xr(s,e){const{message:t,code:o}=Mv[s];return{message:e?`${t} ${e}`:t,code:o}}function On(s,e){return!!Array.isArray(s)&&(!(typeof e<"u"&&s.length)||s.every(e))}var Yr=K(6930);const dl="wc@2:universal_provider:";var s,e,Xn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Fo={exports:{}};s=Fo,e=Fo.exports,function(){var t,f="Expected a function",O="__lodash_hash_undefined__",R="__lodash_placeholder__",Xr=1/0,Ar=9007199254740991,sr=4294967295,K0=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],Sn="[object Arguments]",Yi="[object Array]",ti="[object Boolean]",ri="[object Date]",Xi="[object Error]",es="[object Function]",Nl="[object GeneratorFunction]",Gt="[object Map]",ni="[object Number]",lr="[object Object]",Pl="[object Promise]",ii="[object RegExp]",Jt="[object Set]",si="[object String]",ts="[object Symbol]",oi="[object WeakMap]",ci="[object ArrayBuffer]",Nn="[object DataView]",Zo="[object Float32Array]",zo="[object Float64Array]",Ko="[object Int8Array]",Vo="[object Int16Array]",Bo="[object Int32Array]",Ho="[object Uint8Array]",Wo="[object Uint8ClampedArray]",Go="[object Uint16Array]",Jo="[object Uint32Array]",Q0=/\b__p \+= '';/g,Y0=/\b(__p \+=) '' \+/g,X0=/(__e\(.*?\)|\b__t\)) \+\n'';/g,xl=/&(?:amp|lt|gt|quot|#39);/g,Rl=/[&<>"']/g,eb=RegExp(xl.source),tb=RegExp(Rl.source),rb=/<%-([\s\S]+?)%>/g,nb=/<%([\s\S]+?)%>/g,Cl=/<%=([\s\S]+?)%>/g,ib=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,sb=/^\w*$/,ob=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Qo=/[\\^$.*+?()[\]{}|]/g,cb=RegExp(Qo.source),Yo=/^\s+/,ab=/\s/,ub=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,lb=/\{\n\/\* \[wrapped with (.+)\] \*/,fb=/,? & /,db=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,hb=/[()=,{}\[\]\/\s]/,pb=/\\(\\)?/g,gb=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Al=/\w*$/,_b=/^[-+]0x[0-9a-f]+$/i,yb=/^0b[01]+$/i,mb=/^\[object .+?Constructor\]$/,vb=/^0o[0-7]+$/i,bb=/^(?:0|[1-9]\d*)$/,wb=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,rs=/($^)/,Eb=/['\n\r\u2028\u2029\\]/g,ns="\\ud800-\\udfff",Tl="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",jl="\\u2700-\\u27bf",$l="a-z\\xdf-\\xf6\\xf8-\\xff",Dl="A-Z\\xc0-\\xd6\\xd8-\\xde",Fl="\\ufe0e\\ufe0f",Ul="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Cb="["+ns+"]",Ml="["+Ul+"]",is="["+Tl+"]",Ll="\\d+",Ab="["+jl+"]",kl="["+$l+"]",ql="[^"+ns+Ul+Ll+jl+$l+Dl+"]",ec="\\ud83c[\\udffb-\\udfff]",Zl="[^"+ns+"]",tc="(?:\\ud83c[\\udde6-\\uddff]){2}",rc="[\\ud800-\\udbff][\\udc00-\\udfff]",Pn="["+Dl+"]",Kl="(?:"+kl+"|"+ql+")",jb="(?:"+Pn+"|"+ql+")",Vl="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Bl="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",Hl="(?:"+is+"|"+ec+")?",Wl="["+Fl+"]?",Gl=Wl+Hl+"(?:\\u200d(?:"+[Zl,tc,rc].join("|")+")"+Wl+Hl+")*",Ub="(?:"+[Ab,tc,rc].join("|")+")"+Gl,Mb="(?:"+[Zl+is+"?",is,tc,rc,Cb].join("|")+")",Lb=RegExp("['\u2019]","g"),kb=RegExp(is,"g"),nc=RegExp(ec+"(?="+ec+")|"+Mb+Gl,"g"),qb=RegExp([Pn+"?"+kl+"+"+Vl+"(?="+[Ml,Pn,"$"].join("|")+")",jb+"+"+Bl+"(?="+[Ml,Pn+Kl,"$"].join("|")+")",Pn+"?"+Kl+"+"+Vl,Pn+"+"+Bl,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ll,Ub].join("|"),"g"),Zb=RegExp("[\\u200d"+ns+Tl+Fl+"]"),zb=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Kb=["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"],Vb=-1,He={};He[Zo]=He[zo]=He[Ko]=He[Vo]=He[Bo]=He[Ho]=He[Wo]=He[Go]=He[Jo]=!0,He[Sn]=He[Yi]=He[ci]=He[ti]=He[Nn]=He[ri]=He[Xi]=He[es]=He[Gt]=He[ni]=He[lr]=He[ii]=He[Jt]=He[si]=He[oi]=!1;var Be={};Be[Sn]=Be[Yi]=Be[ci]=Be[Nn]=Be[ti]=Be[ri]=Be[Zo]=Be[zo]=Be[Ko]=Be[Vo]=Be[Bo]=Be[Gt]=Be[ni]=Be[lr]=Be[ii]=Be[Jt]=Be[si]=Be[ts]=Be[Ho]=Be[Wo]=Be[Go]=Be[Jo]=!0,Be[Xi]=Be[es]=Be[oi]=!1;var Gb={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Jb=parseFloat,Qb=parseInt,Jl="object"==typeof Xn&&Xn&&Xn.Object===Object&&Xn,Yb="object"==typeof self&&self&&self.Object===Object&&self,ht=Jl||Yb||Function("return this")(),ic=e&&!e.nodeType&&e,en=ic&&s&&!s.nodeType&&s,Ql=en&&en.exports===ic,sc=Ql&&Jl.process,kt=function(){try{return en&&en.require&&en.require("util").types||sc&&sc.binding&&sc.binding("util")}catch{}}(),Yl=kt&&kt.isArrayBuffer,Xl=kt&&kt.isDate,ef=kt&&kt.isMap,tf=kt&&kt.isRegExp,rf=kt&&kt.isSet,nf=kt&&kt.isTypedArray;function Rt(C,M,j){switch(j.length){case 0:return C.call(M);case 1:return C.call(M,j[0]);case 2:return C.call(M,j[0],j[1]);case 3:return C.call(M,j[0],j[1],j[2])}return C.apply(M,j)}function Xb(C,M,j,X){for(var ye=-1,Me=null==C?0:C.length;++ye<Me;){var ot=C[ye];M(X,ot,j(ot),C)}return X}function qt(C,M){for(var j=-1,X=null==C?0:C.length;++j<X&&!1!==M(C[j],j,C););return C}function ew(C,M){for(var j=null==C?0:C.length;j--&&!1!==M(C[j],j,C););return C}function sf(C,M){for(var j=-1,X=null==C?0:C.length;++j<X;)if(!M(C[j],j,C))return!1;return!0}function Tr(C,M){for(var j=-1,X=null==C?0:C.length,ye=0,Me=[];++j<X;){var ot=C[j];M(ot,j,C)&&(Me[ye++]=ot)}return Me}function ss(C,M){return!(null==C||!C.length)&&xn(C,M,0)>-1}function oc(C,M,j){for(var X=-1,ye=null==C?0:C.length;++X<ye;)if(j(M,C[X]))return!0;return!1}function Je(C,M){for(var j=-1,X=null==C?0:C.length,ye=Array(X);++j<X;)ye[j]=M(C[j],j,C);return ye}function jr(C,M){for(var j=-1,X=M.length,ye=C.length;++j<X;)C[ye+j]=M[j];return C}function cc(C,M,j,X){var ye=-1,Me=null==C?0:C.length;for(X&&Me&&(j=C[++ye]);++ye<Me;)j=M(j,C[ye],ye,C);return j}function tw(C,M,j,X){var ye=null==C?0:C.length;for(X&&ye&&(j=C[--ye]);ye--;)j=M(j,C[ye],ye,C);return j}function ac(C,M){for(var j=-1,X=null==C?0:C.length;++j<X;)if(M(C[j],j,C))return!0;return!1}var rw=uc("length");function of(C,M,j){var X;return j(C,function(ye,Me,ot){if(M(ye,Me,ot))return X=Me,!1}),X}function os(C,M,j,X){for(var ye=C.length,Me=j+(X?1:-1);X?Me--:++Me<ye;)if(M(C[Me],Me,C))return Me;return-1}function xn(C,M,j){return M==M?function(C,M,j){for(var X=j-1,ye=C.length;++X<ye;)if(C[X]===M)return X;return-1}(C,M,j):os(C,cf,j)}function sw(C,M,j,X){for(var ye=j-1,Me=C.length;++ye<Me;)if(X(C[ye],M))return ye;return-1}function cf(C){return C!=C}function af(C,M){var j=null==C?0:C.length;return j?fc(C,M)/j:NaN}function uc(C){return function(M){return null==M?t:M[C]}}function lc(C){return function(M){return null==C?t:C[M]}}function uf(C,M,j,X,ye){return ye(C,function(Me,ot,Ke){j=X?(X=!1,Me):M(j,Me,ot,Ke)}),j}function fc(C,M){for(var j,X=-1,ye=C.length;++X<ye;){var Me=M(C[X]);Me!==t&&(j=j===t?Me:j+Me)}return j}function dc(C,M){for(var j=-1,X=Array(C);++j<C;)X[j]=M(j);return X}function lf(C){return C&&C.slice(0,pf(C)+1).replace(Yo,"")}function Ct(C){return function(M){return C(M)}}function hc(C,M){return Je(M,function(j){return C[j]})}function ai(C,M){return C.has(M)}function ff(C,M){for(var j=-1,X=C.length;++j<X&&xn(M,C[j],0)>-1;);return j}function df(C,M){for(var j=C.length;j--&&xn(M,C[j],0)>-1;);return j}function aw(C,M){for(var j=C.length,X=0;j--;)C[j]===M&&++X;return X}var uw=lc({\u00c0:"A",\u00c1:"A",\u00c2:"A",\u00c3:"A",\u00c4:"A",\u00c5:"A",\u00e0:"a",\u00e1:"a",\u00e2:"a",\u00e3:"a",\u00e4:"a",\u00e5:"a",\u00c7:"C",\u00e7:"c",\u00d0:"D",\u00f0:"d",\u00c8:"E",\u00c9:"E",\u00ca:"E",\u00cb:"E",\u00e8:"e",\u00e9:"e",\u00ea:"e",\u00eb:"e",\u00cc:"I",\u00cd:"I",\u00ce:"I",\u00cf:"I",\u00ec:"i",\u00ed:"i",\u00ee:"i",\u00ef:"i",\u00d1:"N",\u00f1:"n",\u00d2:"O",\u00d3:"O",\u00d4:"O",\u00d5:"O",\u00d6:"O",\u00d8:"O",\u00f2:"o",\u00f3:"o",\u00f4:"o",\u00f5:"o",\u00f6:"o",\u00f8:"o",\u00d9:"U",\u00da:"U",\u00db:"U",\u00dc:"U",\u00f9:"u",\u00fa:"u",\u00fb:"u",\u00fc:"u",\u00dd:"Y",\u00fd:"y",\u00ff:"y",\u00c6:"Ae",\u00e6:"ae",\u00de:"Th",\u00fe:"th",\u00df:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010a:"C",\u010c:"C",\u0107:"c",\u0109:"c",\u010b:"c",\u010d:"c",\u010e:"D",\u0110:"D",\u010f:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011a:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011b:"e",\u011c:"G",\u011e:"G",\u0120:"G",\u0122:"G",\u011d:"g",\u011f:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012a:"I",\u012c:"I",\u012e:"I",\u0130:"I",\u0129:"i",\u012b:"i",\u012d:"i",\u012f:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013b:"L",\u013d:"L",\u013f:"L",\u0141:"L",\u013a:"l",\u013c:"l",\u013e:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014a:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014b:"n",\u014c:"O",\u014e:"O",\u0150:"O",\u014d:"o",\u014f:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015a:"S",\u015c:"S",\u015e:"S",\u0160:"S",\u015b:"s",\u015d:"s",\u015f:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016a:"U",\u016c:"U",\u016e:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016b:"u",\u016d:"u",\u016f:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017b:"Z",\u017d:"Z",\u017a:"z",\u017c:"z",\u017e:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017f:"s"}),lw=lc({"&":"&","<":"<",">":">",'"':""","'":"'"});function fw(C){return"\\"+Gb[C]}function Rn(C){return Zb.test(C)}function pc(C){var M=-1,j=Array(C.size);return C.forEach(function(X,ye){j[++M]=[ye,X]}),j}function hf(C,M){return function(j){return C(M(j))}}function $r(C,M){for(var j=-1,X=C.length,ye=0,Me=[];++j<X;){var ot=C[j];(ot===M||ot===R)&&(C[j]=R,Me[ye++]=j)}return Me}function cs(C){var M=-1,j=Array(C.size);return C.forEach(function(X){j[++M]=X}),j}function Cn(C){return Rn(C)?function(C){for(var M=nc.lastIndex=0;nc.test(C);)++M;return M}(C):rw(C)}function Qt(C){return Rn(C)?function(C){return C.match(nc)||[]}(C):function(C){return C.split("")}(C)}function pf(C){for(var M=C.length;M--&&ab.test(C.charAt(M)););return M}var mw=lc({"&":"&","<":"<",">":">",""":'"',"'":"'"}),An=function C(M){var r,j=(M=null==M?ht:An.defaults(ht.Object(),M,An.pick(ht,Kb))).Array,X=M.Date,ye=M.Error,Me=M.Function,ot=M.Math,Ke=M.Object,gc=M.RegExp,Iw=M.String,Zt=M.TypeError,as=j.prototype,Tn=Ke.prototype,us=M["__core-js_shared__"],ls=Me.prototype.toString,ze=Tn.hasOwnProperty,Sw=0,gf=(r=/[^.]+$/.exec(us&&us.keys&&us.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",fs=Tn.toString,Nw=ls.call(Ke),Pw=ht._,xw=gc("^"+ls.call(ze).replace(Qo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ds=Ql?M.Buffer:t,Dr=M.Symbol,hs=M.Uint8Array,_f=ds?ds.allocUnsafe:t,ps=hf(Ke.getPrototypeOf,Ke),yf=Ke.create,mf=Tn.propertyIsEnumerable,gs=as.splice,vf=Dr?Dr.isConcatSpreadable:t,ui=Dr?Dr.iterator:t,tn=Dr?Dr.toStringTag:t,_s=function(){try{var r=cn(Ke,"defineProperty");return r({},"",{}),r}catch{}}(),Rw=M.clearTimeout!==ht.clearTimeout&&M.clearTimeout,Cw=X&&X.now!==ht.Date.now&&X.now,Aw=M.setTimeout!==ht.setTimeout&&M.setTimeout,ys=ot.ceil,ms=ot.floor,_c=Ke.getOwnPropertySymbols,Tw=ds?ds.isBuffer:t,bf=M.isFinite,jw=as.join,$w=hf(Ke.keys,Ke),ct=ot.max,gt=ot.min,Dw=X.now,Fw=M.parseInt,wf=ot.random,Uw=as.reverse,yc=cn(M,"DataView"),li=cn(M,"Map"),mc=cn(M,"Promise"),jn=cn(M,"Set"),fi=cn(M,"WeakMap"),di=cn(Ke,"create"),vs=fi&&new fi,$n={},Mw=an(yc),Lw=an(li),kw=an(mc),qw=an(jn),Zw=an(fi),bs=Dr?Dr.prototype:t,hi=bs?bs.valueOf:t,Ef=bs?bs.toString:t;function _(r){if(et(r)&&!ve(r)&&!(r instanceof Ne)){if(r instanceof zt)return r;if(ze.call(r,"__wrapped__"))return Id(r)}return new zt(r)}var Dn=function(){function r(){}return function(n){if(!Ye(n))return{};if(yf)return yf(n);r.prototype=n;var u=new r;return r.prototype=t,u}}();function ws(){}function zt(r,n){this.__wrapped__=r,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=t}function Ne(r){this.__wrapped__=r,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=sr,this.__views__=[]}function rn(r){var n=-1,u=null==r?0:r.length;for(this.clear();++n<u;){var d=r[n];this.set(d[0],d[1])}}function fr(r){var n=-1,u=null==r?0:r.length;for(this.clear();++n<u;){var d=r[n];this.set(d[0],d[1])}}function dr(r){var n=-1,u=null==r?0:r.length;for(this.clear();++n<u;){var d=r[n];this.set(d[0],d[1])}}function nn(r){var n=-1,u=null==r?0:r.length;for(this.__data__=new dr;++n<u;)this.add(r[n])}function Yt(r){var n=this.__data__=new fr(r);this.size=n.size}function If(r,n){var u=ve(r),d=!u&&un(r),h=!u&&!d&&kr(r),y=!u&&!d&&!h&&Ln(r),N=u||d||h||y,P=N?dc(r.length,Iw):[],A=P.length;for(var L in r)(n||ze.call(r,L))&&(!N||!("length"==L||h&&("offset"==L||"parent"==L)||y&&("buffer"==L||"byteLength"==L||"byteOffset"==L)||_r(L,A)))&&P.push(L);return P}function Of(r){var n=r.length;return n?r[Rc(0,n-1)]:t}function p1(r,n){return Ds(St(r),sn(n,0,r.length))}function g1(r){return Ds(St(r))}function vc(r,n,u){(u!==t&&!Xt(r[n],u)||u===t&&!(n in r))&&hr(r,n,u)}function pi(r,n,u){var d=r[n];(!ze.call(r,n)||!Xt(d,u)||u===t&&!(n in r))&&hr(r,n,u)}function Es(r,n){for(var u=r.length;u--;)if(Xt(r[u][0],n))return u;return-1}function _1(r,n,u,d){return Fr(r,function(h,y,N){n(d,h,u(h),N)}),d}function Sf(r,n){return r&&cr(n,ft(n),r)}function hr(r,n,u){"__proto__"==n&&_s?_s(r,n,{configurable:!0,enumerable:!0,value:u,writable:!0}):r[n]=u}function bc(r,n){for(var u=-1,d=n.length,h=j(d),y=null==r;++u<d;)h[u]=y?t:ea(r,n[u]);return h}function sn(r,n,u){return r==r&&(u!==t&&(r=r<=u?r:u),n!==t&&(r=r>=n?r:n)),r}function Kt(r,n,u,d,h,y){var N,P=1&n,A=2&n,L=4&n;if(u&&(N=h?u(r,d,h,y):u(r)),N!==t)return N;if(!Ye(r))return r;var k=ve(r);if(k){if(N=function(r){var n=r.length,u=new r.constructor(n);return n&&"string"==typeof r[0]&&ze.call(r,"index")&&(u.index=r.index,u.input=r.input),u}(r),!P)return St(r,N)}else{var q=_t(r),W=q==es||q==Nl;if(kr(r))return Gf(r,P);if(q==lr||q==Sn||W&&!h){if(N=A||W?{}:pd(r),!P)return A?function(r,n){return cr(r,dd(r),n)}(r,function(r,n){return r&&cr(n,Pt(n),r)}(N,r)):function(r,n){return cr(r,zc(r),n)}(r,Sf(N,r))}else{if(!Be[q])return h?r:{};N=function(r,n,u){var d=r.constructor;switch(n){case ci:return Fc(r);case ti:case ri:return new d(+r);case Nn:return function(r,n){var u=n?Fc(r.buffer):r.buffer;return new r.constructor(u,r.byteOffset,r.byteLength)}(r,u);case Zo:case zo:case Ko:case Vo:case Bo:case Ho:case Wo:case Go:case Jo:return Jf(r,u);case Gt:return new d;case ni:case si:return new d(r);case ii:return function(r){var n=new r.constructor(r.source,Al.exec(r));return n.lastIndex=r.lastIndex,n}(r);case Jt:return new d;case ts:return function(r){return hi?Ke(hi.call(r)):{}}(r)}}(r,q,P)}}y||(y=new Yt);var ee=y.get(r);if(ee)return ee;y.set(r,N),zd(r)?r.forEach(function(oe){N.add(Kt(oe,n,u,oe,r,y))}):qd(r)&&r.forEach(function(oe,Se){N.set(Se,Kt(oe,n,u,Se,r,y))});var Ee=k?t:(L?A?kc:Lc:A?Pt:ft)(r);return qt(Ee||r,function(oe,Se){Ee&&(oe=r[Se=oe]),pi(N,Se,Kt(oe,n,u,Se,r,y))}),N}function Nf(r,n,u){var d=u.length;if(null==r)return!d;for(r=Ke(r);d--;){var h=u[d],N=r[h];if(N===t&&!(h in r)||!(0,n[h])(N))return!1}return!0}function Pf(r,n,u){if("function"!=typeof r)throw new Zt(f);return wi(function(){r.apply(t,u)},n)}function gi(r,n,u,d){var h=-1,y=ss,N=!0,P=r.length,A=[],L=n.length;if(!P)return A;u&&(n=Je(n,Ct(u))),d?(y=oc,N=!1):n.length>=200&&(y=ai,N=!1,n=new nn(n));e:for(;++h<P;){var k=r[h],q=null==u?k:u(k);if(k=d||0!==k?k:0,N&&q==q){for(var W=L;W--;)if(n[W]===q)continue e;A.push(k)}else y(n,q,d)||A.push(k)}return A}_.templateSettings={escape:rb,evaluate:nb,interpolate:Cl,variable:"",imports:{_}},(_.prototype=ws.prototype).constructor=_,(zt.prototype=Dn(ws.prototype)).constructor=zt,(Ne.prototype=Dn(ws.prototype)).constructor=Ne,rn.prototype.clear=function(){this.__data__=di?di(null):{},this.size=0},rn.prototype.delete=function(r){var n=this.has(r)&&delete this.__data__[r];return this.size-=n?1:0,n},rn.prototype.get=function(r){var n=this.__data__;if(di){var u=n[r];return u===O?t:u}return ze.call(n,r)?n[r]:t},rn.prototype.has=function(r){var n=this.__data__;return di?n[r]!==t:ze.call(n,r)},rn.prototype.set=function(r,n){var u=this.__data__;return this.size+=this.has(r)?0:1,u[r]=di&&n===t?O:n,this},fr.prototype.clear=function(){this.__data__=[],this.size=0},fr.prototype.delete=function(r){var n=this.__data__,u=Es(n,r);return!(u<0||(u==n.length-1?n.pop():gs.call(n,u,1),--this.size,0))},fr.prototype.get=function(r){var n=this.__data__,u=Es(n,r);return u<0?t:n[u][1]},fr.prototype.has=function(r){return Es(this.__data__,r)>-1},fr.prototype.set=function(r,n){var u=this.__data__,d=Es(u,r);return d<0?(++this.size,u.push([r,n])):u[d][1]=n,this},dr.prototype.clear=function(){this.size=0,this.__data__={hash:new rn,map:new(li||fr),string:new rn}},dr.prototype.delete=function(r){var n=$s(this,r).delete(r);return this.size-=n?1:0,n},dr.prototype.get=function(r){return $s(this,r).get(r)},dr.prototype.has=function(r){return $s(this,r).has(r)},dr.prototype.set=function(r,n){var u=$s(this,r),d=u.size;return u.set(r,n),this.size+=u.size==d?0:1,this},nn.prototype.add=nn.prototype.push=function(r){return this.__data__.set(r,O),this},nn.prototype.has=function(r){return this.__data__.has(r)},Yt.prototype.clear=function(){this.__data__=new fr,this.size=0},Yt.prototype.delete=function(r){var n=this.__data__,u=n.delete(r);return this.size=n.size,u},Yt.prototype.get=function(r){return this.__data__.get(r)},Yt.prototype.has=function(r){return this.__data__.has(r)},Yt.prototype.set=function(r,n){var u=this.__data__;if(u instanceof fr){var d=u.__data__;if(!li||d.length<199)return d.push([r,n]),this.size=++u.size,this;u=this.__data__=new dr(d)}return u.set(r,n),this.size=u.size,this};var Fr=ed(or),xf=ed(Ec,!0);function v1(r,n){var u=!0;return Fr(r,function(d,h,y){return u=!!n(d,h,y)}),u}function Is(r,n,u){for(var d=-1,h=r.length;++d<h;){var y=r[d],N=n(y);if(null!=N&&(P===t?N==N&&!Tt(N):u(N,P)))var P=N,A=y}return A}function Rf(r,n){var u=[];return Fr(r,function(d,h,y){n(d,h,y)&&u.push(d)}),u}function pt(r,n,u,d,h){var y=-1,N=r.length;for(u||(u=aE),h||(h=[]);++y<N;){var P=r[y];n>0&&u(P)?n>1?pt(P,n-1,u,d,h):jr(h,P):d||(h[h.length]=P)}return h}var wc=td(),Cf=td(!0);function or(r,n){return r&&wc(r,n,ft)}function Ec(r,n){return r&&Cf(r,n,ft)}function Os(r,n){return Tr(n,function(u){return yr(r[u])})}function on(r,n){for(var u=0,d=(n=Mr(n,r)).length;null!=r&&u<d;)r=r[ar(n[u++])];return u&&u==d?r:t}function Af(r,n,u){var d=n(r);return ve(r)?d:jr(d,u(r))}function vt(r){return null==r?r===t?"[object Undefined]":"[object Null]":tn&&tn in Ke(r)?function(r){var n=ze.call(r,tn),u=r[tn];try{r[tn]=t;var d=!0}catch{}var h=fs.call(r);return d&&(n?r[tn]=u:delete r[tn]),h}(r):function(r){return fs.call(r)}(r)}function Ic(r,n){return r>n}function w1(r,n){return null!=r&&ze.call(r,n)}function E1(r,n){return null!=r&&n in Ke(r)}function Oc(r,n,u){for(var d=u?oc:ss,h=r[0].length,y=r.length,N=y,P=j(y),A=1/0,L=[];N--;){var k=r[N];N&&n&&(k=Je(k,Ct(n))),A=gt(k.length,A),P[N]=!u&&(n||h>=120&&k.length>=120)?new nn(N&&k):t}k=r[0];var q=-1,W=P[0];e:for(;++q<h&&L.length<A;){var ee=k[q],se=n?n(ee):ee;if(ee=u||0!==ee?ee:0,!(W?ai(W,se):d(L,se,u))){for(N=y;--N;){var Ee=P[N];if(!(Ee?ai(Ee,se):d(r[N],se,u)))continue e}W&&W.push(se),L.push(ee)}}return L}function _i(r,n,u){var d=null==(r=md(r,n=Mr(n,r)))?r:r[ar(Bt(n))];return null==d?t:Rt(d,r,u)}function Tf(r){return et(r)&&vt(r)==Sn}function yi(r,n,u,d,h){return r===n||(null==r||null==n||!et(r)&&!et(n)?r!=r&&n!=n:function(r,n,u,d,h,y){var N=ve(r),P=ve(n),A=N?Yi:_t(r),L=P?Yi:_t(n),k=(A=A==Sn?lr:A)==lr,q=(L=L==Sn?lr:L)==lr,W=A==L;if(W&&kr(r)){if(!kr(n))return!1;N=!0,k=!1}if(W&&!k)return y||(y=new Yt),N||Ln(r)?fd(r,n,u,d,h,y):function(r,n,u,d,h,y,N){switch(u){case Nn:if(r.byteLength!=n.byteLength||r.byteOffset!=n.byteOffset)return!1;r=r.buffer,n=n.buffer;case ci:return!(r.byteLength!=n.byteLength||!y(new hs(r),new hs(n)));case ti:case ri:case ni:return Xt(+r,+n);case Xi:return r.name==n.name&&r.message==n.message;case ii:case si:return r==n+"";case Gt:var P=pc;case Jt:if(P||(P=cs),r.size!=n.size&&!(1&d))return!1;var L=N.get(r);if(L)return L==n;d|=2,N.set(r,n);var k=fd(P(r),P(n),d,h,y,N);return N.delete(r),k;case ts:if(hi)return hi.call(r)==hi.call(n)}return!1}(r,n,A,u,d,h,y);if(!(1&u)){var ee=k&&ze.call(r,"__wrapped__"),se=q&&ze.call(n,"__wrapped__");if(ee||se){var Ee=ee?r.value():r,oe=se?n.value():n;return y||(y=new Yt),h(Ee,oe,u,d,y)}}return!!W&&(y||(y=new Yt),function(r,n,u,d,h,y){var N=1&u,P=Lc(r),A=P.length;if(A!=Lc(n).length&&!N)return!1;for(var q=A;q--;){var W=P[q];if(!(N?W in n:ze.call(n,W)))return!1}var ee=y.get(r),se=y.get(n);if(ee&&se)return ee==n&&se==r;var Ee=!0;y.set(r,n),y.set(n,r);for(var oe=N;++q<A;){var Se=r[W=P[q]],Pe=n[W];if(d)var jt=N?d(Pe,Se,W,n,r,y):d(Se,Pe,W,r,n,y);if(!(jt===t?Se===Pe||h(Se,Pe,u,d,y):jt)){Ee=!1;break}oe||(oe="constructor"==W)}if(Ee&&!oe){var wt=r.constructor,$t=n.constructor;wt!=$t&&"constructor"in r&&"constructor"in n&&!("function"==typeof wt&&wt instanceof wt&&"function"==typeof $t&&$t instanceof $t)&&(Ee=!1)}return y.delete(r),y.delete(n),Ee}(r,n,u,d,h,y))}(r,n,u,d,yi,h))}function Sc(r,n,u,d){var h=u.length,y=h,N=!d;if(null==r)return!y;for(r=Ke(r);h--;){var P=u[h];if(N&&P[2]?P[1]!==r[P[0]]:!(P[0]in r))return!1}for(;++h<y;){var A=(P=u[h])[0],L=r[A],k=P[1];if(N&&P[2]){if(L===t&&!(A in r))return!1}else{var q=new Yt;if(d)var W=d(L,k,A,r,n,q);if(!(W===t?yi(k,L,3,d,q):W))return!1}}return!0}function jf(r){return!(!Ye(r)||function(r){return!!gf&&gf in r}(r))&&(yr(r)?xw:mb).test(an(r))}function $f(r){return"function"==typeof r?r:null==r?xt:"object"==typeof r?ve(r)?Uf(r[0],r[1]):Ff(r):rh(r)}function Nc(r){if(!bi(r))return $w(r);var n=[];for(var u in Ke(r))ze.call(r,u)&&"constructor"!=u&&n.push(u);return n}function Pc(r,n){return r<n}function Df(r,n){var u=-1,d=Nt(r)?j(r.length):[];return Fr(r,function(h,y,N){d[++u]=n(h,y,N)}),d}function Ff(r){var n=Zc(r);return 1==n.length&&n[0][2]?_d(n[0][0],n[0][1]):function(u){return u===r||Sc(u,r,n)}}function Uf(r,n){return Kc(r)&&gd(n)?_d(ar(r),n):function(u){var d=ea(u,r);return d===t&&d===n?ta(u,r):yi(n,d,3)}}function Ss(r,n,u,d,h){r!==n&&wc(n,function(y,N){if(h||(h=new Yt),Ye(y))!function(r,n,u,d,h,y,N){var P=Bc(r,u),A=Bc(n,u),L=N.get(A);if(L)vc(r,u,L);else{var k=y?y(P,A,u+"",r,n,N):t,q=k===t;if(q){var W=ve(A),ee=!W&&kr(A),se=!W&&!ee&&Ln(A);k=A,W||ee||se?ve(P)?k=P:rt(P)?k=St(P):ee?(q=!1,k=Gf(A,!0)):se?(q=!1,k=Jf(A,!0)):k=[]:Ei(A)||un(A)?(k=P,un(P)?k=Bd(P):(!Ye(P)||yr(P))&&(k=pd(A))):q=!1}q&&(N.set(A,k),h(k,A,d,y,N),N.delete(A)),vc(r,u,k)}}(r,n,N,u,Ss,d,h);else{var P=d?d(Bc(r,N),y,N+"",r,n,h):t;P===t&&(P=y),vc(r,N,P)}},Pt)}function Mf(r,n){var u=r.length;if(u)return _r(n+=n<0?u:0,u)?r[n]:t}function Lf(r,n,u){n=n.length?Je(n,function(y){return ve(y)?function(N){return on(N,1===y.length?y[0]:y)}:y}):[xt];var d=-1;return n=Je(n,Ct(ne())),function(C,M){var j=C.length;for(C.sort(function(y,N){return function(r,n,u){for(var d=-1,h=r.criteria,y=n.criteria,N=h.length,P=u.length;++d<N;){var A=Qf(h[d],y[d]);if(A)return d>=P?A:A*("desc"==u[d]?-1:1)}return r.index-n.index}(y,N,u)});j--;)C[j]=C[j].value;return C}(Df(r,function(y,N,P){return{criteria:Je(n,function(L){return L(y)}),index:++d,value:y}}))}function kf(r,n,u){for(var d=-1,h=n.length,y={};++d<h;){var N=n[d],P=on(r,N);u(P,N)&&mi(y,Mr(N,r),P)}return y}function xc(r,n,u,d){var h=d?sw:xn,y=-1,N=n.length,P=r;for(r===n&&(n=St(n)),u&&(P=Je(r,Ct(u)));++y<N;)for(var A=0,L=n[y],k=u?u(L):L;(A=h(P,k,A,d))>-1;)P!==r&&gs.call(P,A,1),gs.call(r,A,1);return r}function qf(r,n){for(var u=r?n.length:0,d=u-1;u--;){var h=n[u];if(u==d||h!==y){var y=h;_r(h)?gs.call(r,h,1):Tc(r,h)}}return r}function Rc(r,n){return r+ms(wf()*(n-r+1))}function Cc(r,n){var u="";if(!r||n<1||n>Ar)return u;do{n%2&&(u+=r),(n=ms(n/2))&&(r+=r)}while(n);return u}function Oe(r,n){return Hc(yd(r,n,xt),r+"")}function U1(r){return Of(kn(r))}function M1(r,n){var u=kn(r);return Ds(u,sn(n,0,u.length))}function mi(r,n,u,d){if(!Ye(r))return r;for(var h=-1,y=(n=Mr(n,r)).length,N=y-1,P=r;null!=P&&++h<y;){var A=ar(n[h]),L=u;if("__proto__"===A||"constructor"===A||"prototype"===A)return r;if(h!=N){var k=P[A];(L=d?d(k,A,P):t)===t&&(L=Ye(k)?k:_r(n[h+1])?[]:{})}pi(P,A,L),P=P[A]}return r}var Zf=vs?function(r,n){return vs.set(r,n),r}:xt,L1=_s?function(r,n){return _s(r,"toString",{configurable:!0,enumerable:!1,value:na(n),writable:!0})}:xt;function k1(r){return Ds(kn(r))}function Vt(r,n,u){var d=-1,h=r.length;n<0&&(n=-n>h?0:h+n),(u=u>h?h:u)<0&&(u+=h),h=n>u?0:u-n>>>0,n>>>=0;for(var y=j(h);++d<h;)y[d]=r[d+n];return y}function q1(r,n){var u;return Fr(r,function(d,h,y){return!(u=n(d,h,y))}),!!u}function Ns(r,n,u){var d=0,h=null==r?d:r.length;if("number"==typeof n&&n==n&&h<=2147483647){for(;d<h;){var y=d+h>>>1,N=r[y];null!==N&&!Tt(N)&&(u?N<=n:N<n)?d=y+1:h=y}return h}return Ac(r,n,xt,u)}function Ac(r,n,u,d){var h=0,y=null==r?0:r.length;if(0===y)return 0;for(var N=(n=u(n))!=n,P=null===n,A=Tt(n),L=n===t;h<y;){var k=ms((h+y)/2),q=u(r[k]),W=q!==t,ee=null===q,se=q==q,Ee=Tt(q);if(N)var oe=d||se;else oe=L?se&&(d||W):P?se&&W&&(d||!ee):A?se&&W&&!ee&&(d||!Ee):!ee&&!Ee&&(d?q<=n:q<n);oe?h=k+1:y=k}return gt(y,4294967294)}function zf(r,n){for(var u=-1,d=r.length,h=0,y=[];++u<d;){var N=r[u],P=n?n(N):N;if(!u||!Xt(P,A)){var A=P;y[h++]=0===N?0:N}}return y}function Kf(r){return"number"==typeof r?r:Tt(r)?NaN:+r}function At(r){if("string"==typeof r)return r;if(ve(r))return Je(r,At)+"";if(Tt(r))return Ef?Ef.call(r):"";var n=r+"";return"0"==n&&1/r==-Xr?"-0":n}function Ur(r,n,u){var d=-1,h=ss,y=r.length,N=!0,P=[],A=P;if(u)N=!1,h=oc;else if(y>=200){var L=n?null:Y1(r);if(L)return cs(L);N=!1,h=ai,A=new nn}else A=n?[]:P;e:for(;++d<y;){var k=r[d],q=n?n(k):k;if(k=u||0!==k?k:0,N&&q==q){for(var W=A.length;W--;)if(A[W]===q)continue e;n&&A.push(q),P.push(k)}else h(A,q,u)||(A!==P&&A.push(q),P.push(k))}return P}function Tc(r,n){return null==(r=md(r,n=Mr(n,r)))||delete r[ar(Bt(n))]}function Vf(r,n,u,d){return mi(r,n,u(on(r,n)),d)}function Ps(r,n,u,d){for(var h=r.length,y=d?h:-1;(d?y--:++y<h)&&n(r[y],y,r););return u?Vt(r,d?0:y,d?y+1:h):Vt(r,d?y+1:0,d?h:y)}function Bf(r,n){var u=r;return u instanceof Ne&&(u=u.value()),cc(n,function(d,h){return h.func.apply(h.thisArg,jr([d],h.args))},u)}function jc(r,n,u){var d=r.length;if(d<2)return d?Ur(r[0]):[];for(var h=-1,y=j(d);++h<d;)for(var N=r[h],P=-1;++P<d;)P!=h&&(y[h]=gi(y[h]||N,r[P],n,u));return Ur(pt(y,1),n,u)}function Hf(r,n,u){for(var d=-1,h=r.length,y=n.length,N={};++d<h;)u(N,r[d],d<y?n[d]:t);return N}function $c(r){return rt(r)?r:[]}function Dc(r){return"function"==typeof r?r:xt}function Mr(r,n){return ve(r)?r:Kc(r,n)?[r]:Ed(qe(r))}var Z1=Oe;function Lr(r,n,u){var d=r.length;return u=u===t?d:u,!n&&u>=d?r:Vt(r,n,u)}var Wf=Rw||function(r){return ht.clearTimeout(r)};function Gf(r,n){if(n)return r.slice();var u=r.length,d=_f?_f(u):new r.constructor(u);return r.copy(d),d}function Fc(r){var n=new r.constructor(r.byteLength);return new hs(n).set(new hs(r)),n}function Jf(r,n){var u=n?Fc(r.buffer):r.buffer;return new r.constructor(u,r.byteOffset,r.length)}function Qf(r,n){if(r!==n){var u=r!==t,d=null===r,h=r==r,y=Tt(r),N=n!==t,P=null===n,A=n==n,L=Tt(n);if(!P&&!L&&!y&&r>n||y&&N&&A&&!P&&!L||d&&N&&A||!u&&A||!h)return 1;if(!d&&!y&&!L&&r<n||L&&u&&h&&!d&&!y||P&&u&&h||!N&&h||!A)return-1}return 0}function Yf(r,n,u,d){for(var h=-1,y=r.length,N=u.length,P=-1,A=n.length,L=ct(y-N,0),k=j(A+L),q=!d;++P<A;)k[P]=n[P];for(;++h<N;)(q||h<y)&&(k[u[h]]=r[h]);for(;L--;)k[P++]=r[h++];return k}function Xf(r,n,u,d){for(var h=-1,y=r.length,N=-1,P=u.length,A=-1,L=n.length,k=ct(y-P,0),q=j(k+L),W=!d;++h<k;)q[h]=r[h];for(var ee=h;++A<L;)q[ee+A]=n[A];for(;++N<P;)(W||h<y)&&(q[ee+u[N]]=r[h++]);return q}function St(r,n){var u=-1,d=r.length;for(n||(n=j(d));++u<d;)n[u]=r[u];return n}function cr(r,n,u,d){var h=!u;u||(u={});for(var y=-1,N=n.length;++y<N;){var P=n[y],A=d?d(u[P],r[P],P,u,r):t;A===t&&(A=r[P]),h?hr(u,P,A):pi(u,P,A)}return u}function xs(r,n){return function(u,d){var h=ve(u)?Xb:_1,y=n?n():{};return h(u,r,ne(d,2),y)}}function Fn(r){return Oe(function(n,u){var d=-1,h=u.length,y=h>1?u[h-1]:t,N=h>2?u[2]:t;for(y=r.length>3&&"function"==typeof y?(h--,y):t,N&&bt(u[0],u[1],N)&&(y=h<3?t:y,h=1),n=Ke(n);++d<h;){var P=u[d];P&&r(n,P,d,y)}return n})}function ed(r,n){return function(u,d){if(null==u)return u;if(!Nt(u))return r(u,d);for(var h=u.length,y=n?h:-1,N=Ke(u);(n?y--:++y<h)&&!1!==d(N[y],y,N););return u}}function td(r){return function(n,u,d){for(var h=-1,y=Ke(n),N=d(n),P=N.length;P--;){var A=N[r?P:++h];if(!1===u(y[A],A,y))break}return n}}function rd(r){return function(n){var u=Rn(n=qe(n))?Qt(n):t,d=u?u[0]:n.charAt(0),h=u?Lr(u,1).join(""):n.slice(1);return d[r]()+h}}function Un(r){return function(n){return cc(eh(Xd(n).replace(Lb,"")),r,"")}}function vi(r){return function(){var n=arguments;switch(n.length){case 0:return new r;case 1:return new r(n[0]);case 2:return new r(n[0],n[1]);case 3:return new r(n[0],n[1],n[2]);case 4:return new r(n[0],n[1],n[2],n[3]);case 5:return new r(n[0],n[1],n[2],n[3],n[4]);case 6:return new r(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new r(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var u=Dn(r.prototype),d=r.apply(u,n);return Ye(d)?d:u}}function nd(r){return function(n,u,d){var h=Ke(n);if(!Nt(n)){var y=ne(u,3);n=ft(n),u=function(P){return y(h[P],P,h)}}var N=r(n,u,d);return N>-1?h[y?n[N]:N]:t}}function id(r){return gr(function(n){var u=n.length,d=u,h=zt.prototype.thru;for(r&&n.reverse();d--;){var y=n[d];if("function"!=typeof y)throw new Zt(f);if(h&&!N&&"wrapper"==js(y))var N=new zt([],!0)}for(d=N?d:u;++d<u;){var P=js(y=n[d]),A="wrapper"==P?qc(y):t;N=A&&Vc(A[0])&&424==A[1]&&!A[4].length&&1==A[9]?N[js(A[0])].apply(N,A[3]):1==y.length&&Vc(y)?N[P]():N.thru(y)}return function(){var L=arguments,k=L[0];if(N&&1==L.length&&ve(k))return N.plant(k).value();for(var q=0,W=u?n[q].apply(this,L):k;++q<u;)W=n[q].call(this,W);return W}})}function Rs(r,n,u,d,h,y,N,P,A,L){var k=128&n,q=1&n,W=2&n,ee=24&n,se=512&n,Ee=W?t:vi(r);return function oe(){for(var Se=arguments.length,Pe=j(Se),jt=Se;jt--;)Pe[jt]=arguments[jt];if(ee)var wt=Mn(oe),$t=aw(Pe,wt);if(d&&(Pe=Yf(Pe,d,h,ee)),y&&(Pe=Xf(Pe,y,N,ee)),Se-=$t,ee&&Se<L){var nt=$r(Pe,wt);return cd(r,n,Rs,oe.placeholder,u,Pe,nt,P,A,L-Se)}var er=q?u:this,vr=W?er[r]:r;return Se=Pe.length,P?Pe=_E(Pe,P):se&&Se>1&&Pe.reverse(),k&&A<Se&&(Pe.length=A),this&&this!==ht&&this instanceof oe&&(vr=Ee||vi(vr)),vr.apply(er,Pe)}}function sd(r,n){return function(u,d){return function(r,n,u,d){return or(r,function(h,y,N){n(d,u(h),y,N)}),d}(u,r,n(d),{})}}function Cs(r,n){return function(u,d){var h;if(u===t&&d===t)return n;if(u!==t&&(h=u),d!==t){if(h===t)return d;"string"==typeof u||"string"==typeof d?(u=At(u),d=At(d)):(u=Kf(u),d=Kf(d)),h=r(u,d)}return h}}function Uc(r){return gr(function(n){return n=Je(n,Ct(ne())),Oe(function(u){var d=this;return r(n,function(h){return Rt(h,d,u)})})})}function As(r,n){var u=(n=n===t?" ":At(n)).length;if(u<2)return u?Cc(n,r):n;var d=Cc(n,ys(r/Cn(n)));return Rn(n)?Lr(Qt(d),0,r).join(""):d.slice(0,r)}function od(r){return function(n,u,d){return d&&"number"!=typeof d&&bt(n,u,d)&&(u=d=t),n=mr(n),u===t?(u=n,n=0):u=mr(u),function(r,n,u,d){for(var h=-1,y=ct(ys((n-r)/(u||1)),0),N=j(y);y--;)N[d?y:++h]=r,r+=u;return N}(n,u,d=d===t?n<u?1:-1:mr(d),r)}}function Ts(r){return function(n,u){return"string"==typeof n&&"string"==typeof u||(n=Ht(n),u=Ht(u)),r(n,u)}}function cd(r,n,u,d,h,y,N,P,A,L){var k=8&n;n|=k?32:64,4&(n&=~(k?64:32))||(n&=-4);var Ee=[r,n,h,k?y:t,k?N:t,k?t:y,k?t:N,P,A,L],oe=u.apply(t,Ee);return Vc(r)&&vd(oe,Ee),oe.placeholder=d,bd(oe,r,n)}function Mc(r){var n=ot[r];return function(u,d){if(u=Ht(u),(d=null==d?0:gt(we(d),292))&&bf(u)){var h=(qe(u)+"e").split("e");return+((h=(qe(n(h[0]+"e"+(+h[1]+d)))+"e").split("e"))[0]+"e"+(+h[1]-d))}return n(u)}}var Y1=jn&&1/cs(new jn([,-0]))[1]==Xr?function(r){return new jn(r)}:oa;function ad(r){return function(n){var u=_t(n);return u==Gt?pc(n):u==Jt?function(C){var M=-1,j=Array(C.size);return C.forEach(function(X){j[++M]=[X,X]}),j}(n):function(C,M){return Je(M,function(j){return[j,C[j]]})}(n,r(n))}}function pr(r,n,u,d,h,y,N,P){var A=2&n;if(!A&&"function"!=typeof r)throw new Zt(f);var L=d?d.length:0;if(L||(n&=-97,d=h=t),N=N===t?N:ct(we(N),0),P=P===t?P:we(P),L-=h?h.length:0,64&n){var k=d,q=h;d=h=t}var W=A?t:qc(r),ee=[r,n,u,d,h,k,q,y,N,P];if(W&&function(r,n){var u=r[1],d=n[1],h=u|d;if(!(h<131||(128==d&&8==u||128==d&&256==u&&r[7].length<=n[8]||384==d&&n[7].length<=n[8]&&8==u)))return r;1&d&&(r[2]=n[2],h|=1&u?0:4);var P=n[3];if(P){var A=r[3];r[3]=A?Yf(A,P,n[4]):P,r[4]=A?$r(r[3],R):n[4]}(P=n[5])&&(r[5]=(A=r[5])?Xf(A,P,n[6]):P,r[6]=A?$r(r[5],R):n[6]),(P=n[7])&&(r[7]=P),128&d&&(r[8]=null==r[8]?n[8]:gt(r[8],n[8])),null==r[9]&&(r[9]=n[9]),r[0]=n[0],r[1]=h}(ee,W),r=ee[0],n=ee[1],u=ee[2],d=ee[3],h=ee[4],!(P=ee[9]=ee[9]===t?A?0:r.length:ct(ee[9]-L,0))&&24&n&&(n&=-25),n&&1!=n)se=8==n||16==n?function(r,n,u){var d=vi(r);return function h(){for(var y=arguments.length,N=j(y),P=y,A=Mn(h);P--;)N[P]=arguments[P];var L=y<3&&N[0]!==A&&N[y-1]!==A?[]:$r(N,A);return(y-=L.length)<u?cd(r,n,Rs,h.placeholder,t,N,L,t,t,u-y):Rt(this&&this!==ht&&this instanceof h?d:r,this,N)}}(r,n,P):32!=n&&33!=n||h.length?Rs.apply(t,ee):function(r,n,u,d){var h=1&n,y=vi(r);return function N(){for(var P=-1,A=arguments.length,L=-1,k=d.length,q=j(k+A),W=this&&this!==ht&&this instanceof N?y:r;++L<k;)q[L]=d[L];for(;A--;)q[L++]=arguments[++P];return Rt(W,h?u:this,q)}}(r,n,u,d);else var se=function(r,n,u){var d=1&n,h=vi(r);return function y(){return(this&&this!==ht&&this instanceof y?h:r).apply(d?u:this,arguments)}}(r,n,u);return bd((W?Zf:vd)(se,ee),r,n)}function ud(r,n,u,d){return r===t||Xt(r,Tn[u])&&!ze.call(d,u)?n:r}function ld(r,n,u,d,h,y){return Ye(r)&&Ye(n)&&(y.set(n,r),Ss(r,n,t,ld,y),y.delete(n)),r}function X1(r){return Ei(r)?t:r}function fd(r,n,u,d,h,y){var N=1&u,P=r.length,A=n.length;if(P!=A&&!(N&&A>P))return!1;var L=y.get(r),k=y.get(n);if(L&&k)return L==n&&k==r;var q=-1,W=!0,ee=2&u?new nn:t;for(y.set(r,n),y.set(n,r);++q<P;){var se=r[q],Ee=n[q];if(d)var oe=N?d(Ee,se,q,n,r,y):d(se,Ee,q,r,n,y);if(oe!==t){if(oe)continue;W=!1;break}if(ee){if(!ac(n,function(Se,Pe){if(!ai(ee,Pe)&&(se===Se||h(se,Se,u,d,y)))return ee.push(Pe)})){W=!1;break}}else if(se!==Ee&&!h(se,Ee,u,d,y)){W=!1;break}}return y.delete(r),y.delete(n),W}function gr(r){return Hc(yd(r,t,Nd),r+"")}function Lc(r){return Af(r,ft,zc)}function kc(r){return Af(r,Pt,dd)}var qc=vs?function(r){return vs.get(r)}:oa;function js(r){for(var n=r.name+"",u=$n[n],d=ze.call($n,n)?u.length:0;d--;){var h=u[d],y=h.func;if(null==y||y==r)return h.name}return n}function Mn(r){return(ze.call(_,"placeholder")?_:r).placeholder}function ne(){var r=_.iteratee||ia;return r=r===ia?$f:r,arguments.length?r(arguments[0],arguments[1]):r}function $s(r,n){var u=r.__data__;return function(r){var n=typeof r;return"string"==n||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r}(n)?u["string"==typeof n?"string":"hash"]:u.map}function Zc(r){for(var n=ft(r),u=n.length;u--;){var d=n[u],h=r[d];n[u]=[d,h,gd(h)]}return n}function cn(r,n){var u=function(C,M){return null==C?t:C[M]}(r,n);return jf(u)?u:t}var zc=_c?function(r){return null==r?[]:(r=Ke(r),Tr(_c(r),function(n){return mf.call(r,n)}))}:ca,dd=_c?function(r){for(var n=[];r;)jr(n,zc(r)),r=ps(r);return n}:ca,_t=vt;function hd(r,n,u){for(var d=-1,h=(n=Mr(n,r)).length,y=!1;++d<h;){var N=ar(n[d]);if(!(y=null!=r&&u(r,N)))break;r=r[N]}return y||++d!=h?y:!!(h=null==r?0:r.length)&&qs(h)&&_r(N,h)&&(ve(r)||un(r))}function pd(r){return"function"!=typeof r.constructor||bi(r)?{}:Dn(ps(r))}function aE(r){return ve(r)||un(r)||!!(vf&&r&&r[vf])}function _r(r,n){var u=typeof r;return!!(n=n??Ar)&&("number"==u||"symbol"!=u&&bb.test(r))&&r>-1&&r%1==0&&r<n}function bt(r,n,u){if(!Ye(u))return!1;var d=typeof n;return!!("number"==d?Nt(u)&&_r(n,u.length):"string"==d&&n in u)&&Xt(u[n],r)}function Kc(r,n){if(ve(r))return!1;var u=typeof r;return!("number"!=u&&"symbol"!=u&&"boolean"!=u&&null!=r&&!Tt(r))||sb.test(r)||!ib.test(r)||null!=n&&r in Ke(n)}function Vc(r){var n=js(r),u=_[n];if("function"!=typeof u||!(n in Ne.prototype))return!1;if(r===u)return!0;var d=qc(u);return!!d&&r===d[0]}(yc&&_t(new yc(new ArrayBuffer(1)))!=Nn||li&&_t(new li)!=Gt||mc&&_t(mc.resolve())!=Pl||jn&&_t(new jn)!=Jt||fi&&_t(new fi)!=oi)&&(_t=function(r){var n=vt(r),u=n==lr?r.constructor:t,d=u?an(u):"";if(d)switch(d){case Mw:return Nn;case Lw:return Gt;case kw:return Pl;case qw:return Jt;case Zw:return oi}return n});var fE=us?yr:aa;function bi(r){var n=r&&r.constructor;return r===("function"==typeof n&&n.prototype||Tn)}function gd(r){return r==r&&!Ye(r)}function _d(r,n){return function(u){return null!=u&&u[r]===n&&(n!==t||r in Ke(u))}}function yd(r,n,u){return n=ct(n===t?r.length-1:n,0),function(){for(var d=arguments,h=-1,y=ct(d.length-n,0),N=j(y);++h<y;)N[h]=d[n+h];h=-1;for(var P=j(n+1);++h<n;)P[h]=d[h];return P[n]=u(N),Rt(r,this,P)}}function md(r,n){return n.length<2?r:on(r,Vt(n,0,-1))}function _E(r,n){for(var u=r.length,d=gt(n.length,u),h=St(r);d--;){var y=n[d];r[d]=_r(y,u)?h[y]:t}return r}function Bc(r,n){if(("constructor"!==n||"function"!=typeof r[n])&&"__proto__"!=n)return r[n]}var vd=wd(Zf),wi=Aw||function(r,n){return ht.setTimeout(r,n)},Hc=wd(L1);function bd(r,n,u){var d=n+"";return Hc(r,function(r,n){var u=n.length;if(!u)return r;var d=u-1;return n[d]=(u>1?"& ":"")+n[d],n=n.join(u>2?", ":" "),r.replace(ub,"{\n/* [wrapped with "+n+"] */\n")}(d,function(r,n){return qt(K0,function(u){var d="_."+u[0];n&u[1]&&!ss(r,d)&&r.push(d)}),r.sort()}(function(r){var n=r.match(lb);return n?n[1].split(fb):[]}(d),u)))}function wd(r){var n=0,u=0;return function(){var d=Dw(),h=16-(d-u);if(u=d,h>0){if(++n>=800)return arguments[0]}else n=0;return r.apply(t,arguments)}}function Ds(r,n){var u=-1,d=r.length,h=d-1;for(n=n===t?d:n;++u<n;){var y=Rc(u,h),N=r[y];r[y]=r[u],r[u]=N}return r.length=n,r}var n,u,Ed=(n=Ls(function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(ob,function(u,d,h,y){n.push(h?y.replace(pb,"$1"):d||u)}),n},function(d){return 500===u.size&&u.clear(),d}),u=n.cache,n);function ar(r){if("string"==typeof r||Tt(r))return r;var n=r+"";return"0"==n&&1/r==-Xr?"-0":n}function an(r){if(null!=r){try{return ls.call(r)}catch{}try{return r+""}catch{}}return""}function Id(r){if(r instanceof Ne)return r.clone();var n=new zt(r.__wrapped__,r.__chain__);return n.__actions__=St(r.__actions__),n.__index__=r.__index__,n.__values__=r.__values__,n}var wE=Oe(function(r,n){return rt(r)?gi(r,pt(n,1,rt,!0)):[]}),EE=Oe(function(r,n){var u=Bt(n);return rt(u)&&(u=t),rt(r)?gi(r,pt(n,1,rt,!0),ne(u,2)):[]}),IE=Oe(function(r,n){var u=Bt(n);return rt(u)&&(u=t),rt(r)?gi(r,pt(n,1,rt,!0),t,u):[]});function Od(r,n,u){var d=null==r?0:r.length;if(!d)return-1;var h=null==u?0:we(u);return h<0&&(h=ct(d+h,0)),os(r,ne(n,3),h)}function Sd(r,n,u){var d=null==r?0:r.length;if(!d)return-1;var h=d-1;return u!==t&&(h=we(u),h=u<0?ct(d+h,0):gt(h,d-1)),os(r,ne(n,3),h,!0)}function Nd(r){return null!=r&&r.length?pt(r,1):[]}function Pd(r){return r&&r.length?r[0]:t}var $E=Oe(function(r){var n=Je(r,$c);return n.length&&n[0]===r[0]?Oc(n):[]}),DE=Oe(function(r){var n=Bt(r),u=Je(r,$c);return n===Bt(u)?n=t:u.pop(),u.length&&u[0]===r[0]?Oc(u,ne(n,2)):[]}),FE=Oe(function(r){var n=Bt(r),u=Je(r,$c);return(n="function"==typeof n?n:t)&&u.pop(),u.length&&u[0]===r[0]?Oc(u,t,n):[]});function Bt(r){var n=null==r?0:r.length;return n?r[n-1]:t}var kE=Oe(xd);function xd(r,n){return r&&r.length&&n&&n.length?xc(r,n):r}var zE=gr(function(r,n){var u=null==r?0:r.length,d=bc(r,n);return qf(r,Je(n,function(h){return _r(h,u)?+h:h}).sort(Qf)),d});function Wc(r){return null==r?r:Uw.call(r)}var sI=Oe(function(r){return Ur(pt(r,1,rt,!0))}),oI=Oe(function(r){var n=Bt(r);return rt(n)&&(n=t),Ur(pt(r,1,rt,!0),ne(n,2))}),cI=Oe(function(r){var n=Bt(r);return n="function"==typeof n?n:t,Ur(pt(r,1,rt,!0),t,n)});function Gc(r){if(!r||!r.length)return[];var n=0;return r=Tr(r,function(u){if(rt(u))return n=ct(u.length,n),!0}),dc(n,function(u){return Je(r,uc(u))})}function Rd(r,n){if(!r||!r.length)return[];var u=Gc(r);return null==n?u:Je(u,function(d){return Rt(n,t,d)})}var fI=Oe(function(r,n){return rt(r)?gi(r,n):[]}),dI=Oe(function(r){return jc(Tr(r,rt))}),hI=Oe(function(r){var n=Bt(r);return rt(n)&&(n=t),jc(Tr(r,rt),ne(n,2))}),pI=Oe(function(r){var n=Bt(r);return n="function"==typeof n?n:t,jc(Tr(r,rt),t,n)}),gI=Oe(Gc),mI=Oe(function(r){var n=r.length,u=n>1?r[n-1]:t;return u="function"==typeof u?(r.pop(),u):t,Rd(r,u)});function Cd(r){var n=_(r);return n.__chain__=!0,n}function Fs(r,n){return n(r)}var bI=gr(function(r){var n=r.length,u=n?r[0]:0,d=this.__wrapped__,h=function(y){return bc(y,r)};return!(n>1||this.__actions__.length)&&d instanceof Ne&&_r(u)?((d=d.slice(u,+u+(n?1:0))).__actions__.push({func:Fs,args:[h],thisArg:t}),new zt(d,this.__chain__).thru(function(y){return n&&!y.length&&y.push(t),y})):this.thru(h)}),xI=xs(function(r,n,u){ze.call(r,u)?++r[u]:hr(r,u,1)}),AI=nd(Od),TI=nd(Sd);function Ad(r,n){return(ve(r)?qt:Fr)(r,ne(n,3))}function Td(r,n){return(ve(r)?ew:xf)(r,ne(n,3))}var FI=xs(function(r,n,u){ze.call(r,u)?r[u].push(n):hr(r,u,[n])}),MI=Oe(function(r,n,u){var d=-1,h="function"==typeof n,y=Nt(r)?j(r.length):[];return Fr(r,function(N){y[++d]=h?Rt(n,N,u):_i(N,n,u)}),y}),LI=xs(function(r,n,u){hr(r,u,n)});function Us(r,n){return(ve(r)?Je:Df)(r,ne(n,3))}var qI=xs(function(r,n,u){r[u?0:1].push(n)},function(){return[[],[]]}),JI=Oe(function(r,n){if(null==r)return[];var u=n.length;return u>1&&bt(r,n[0],n[1])?n=[]:u>2&&bt(n[0],n[1],n[2])&&(n=[n[0]]),Lf(r,pt(n,1),[])}),Ms=Cw||function(){return ht.Date.now()};function jd(r,n,u){return n=u?t:n,pr(r,128,t,t,t,t,n=r&&null==n?r.length:n)}function $d(r,n){var u;if("function"!=typeof n)throw new Zt(f);return r=we(r),function(){return--r>0&&(u=n.apply(this,arguments)),r<=1&&(n=t),u}}var Jc=Oe(function(r,n,u){var d=1;if(u.length){var h=$r(u,Mn(Jc));d|=32}return pr(r,d,n,u,h)}),Dd=Oe(function(r,n,u){var d=3;if(u.length){var h=$r(u,Mn(Dd));d|=32}return pr(n,d,r,u,h)});function Md(r,n,u){var d,h,y,N,P,A,L=0,k=!1,q=!1,W=!0;if("function"!=typeof r)throw new Zt(f);function ee(nt){var er=d,vr=h;return d=h=t,L=nt,N=r.apply(vr,er)}function se(nt){return L=nt,P=wi(Se,n),k?ee(nt):N}function oe(nt){var er=nt-A;return A===t||er>=n||er<0||q&&nt-L>=y}function Se(){var nt=Ms();if(oe(nt))return Pe(nt);P=wi(Se,function(nt){var nh=n-(nt-A);return q?gt(nh,y-(nt-L)):nh}(nt))}function Pe(nt){return P=t,W&&d?ee(nt):(d=h=t,N)}function $t(){var nt=Ms(),er=oe(nt);if(d=arguments,h=this,A=nt,er){if(P===t)return se(A);if(q)return Wf(P),P=wi(Se,n),ee(A)}return P===t&&(P=wi(Se,n)),N}return n=Ht(n)||0,Ye(u)&&(k=!!u.leading,y=(q="maxWait"in u)?ct(Ht(u.maxWait)||0,n):y,W="trailing"in u?!!u.trailing:W),$t.cancel=function(){P!==t&&Wf(P),L=0,d=A=h=P=t},$t.flush=function(){return P===t?N:Pe(Ms())},$t}var YI=Oe(function(r,n){return Pf(r,1,n)}),XI=Oe(function(r,n,u){return Pf(r,Ht(n)||0,u)});function Ls(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new Zt(f);var u=function(){var d=arguments,h=n?n.apply(this,d):d[0],y=u.cache;if(y.has(h))return y.get(h);var N=r.apply(this,d);return u.cache=y.set(h,N)||y,N};return u.cache=new(Ls.Cache||dr),u}function ks(r){if("function"!=typeof r)throw new Zt(f);return function(){var n=arguments;switch(n.length){case 0:return!r.call(this);case 1:return!r.call(this,n[0]);case 2:return!r.call(this,n[0],n[1]);case 3:return!r.call(this,n[0],n[1],n[2])}return!r.apply(this,n)}}Ls.Cache=dr;var rO=Z1(function(r,n){var u=(n=1==n.length&&ve(n[0])?Je(n[0],Ct(ne())):Je(pt(n,1),Ct(ne()))).length;return Oe(function(d){for(var h=-1,y=gt(d.length,u);++h<y;)d[h]=n[h].call(this,d[h]);return Rt(r,this,d)})}),Qc=Oe(function(r,n){var u=$r(n,Mn(Qc));return pr(r,32,t,n,u)}),Ld=Oe(function(r,n){var u=$r(n,Mn(Ld));return pr(r,64,t,n,u)}),nO=gr(function(r,n){return pr(r,256,t,t,t,n)});function Xt(r,n){return r===n||r!=r&&n!=n}var gO=Ts(Ic),_O=Ts(function(r,n){return r>=n}),un=Tf(function(){return arguments}())?Tf:function(r){return et(r)&&ze.call(r,"callee")&&!mf.call(r,"callee")},ve=j.isArray,yO=Yl?Ct(Yl):function(r){return et(r)&&vt(r)==ci};function Nt(r){return null!=r&&qs(r.length)&&!yr(r)}function rt(r){return et(r)&&Nt(r)}var kr=Tw||aa,vO=Xl?Ct(Xl):function(r){return et(r)&&vt(r)==ri};function Yc(r){if(!et(r))return!1;var n=vt(r);return n==Xi||"[object DOMException]"==n||"string"==typeof r.message&&"string"==typeof r.name&&!Ei(r)}function yr(r){if(!Ye(r))return!1;var n=vt(r);return n==es||n==Nl||"[object AsyncFunction]"==n||"[object Proxy]"==n}function kd(r){return"number"==typeof r&&r==we(r)}function qs(r){return"number"==typeof r&&r>-1&&r%1==0&&r<=Ar}function Ye(r){var n=typeof r;return null!=r&&("object"==n||"function"==n)}function et(r){return null!=r&&"object"==typeof r}var qd=ef?Ct(ef):function(r){return et(r)&&_t(r)==Gt};function Zd(r){return"number"==typeof r||et(r)&&vt(r)==ni}function Ei(r){if(!et(r)||vt(r)!=lr)return!1;var n=ps(r);if(null===n)return!0;var u=ze.call(n,"constructor")&&n.constructor;return"function"==typeof u&&u instanceof u&&ls.call(u)==Nw}var Xc=tf?Ct(tf):function(r){return et(r)&&vt(r)==ii},zd=rf?Ct(rf):function(r){return et(r)&&_t(r)==Jt};function Zs(r){return"string"==typeof r||!ve(r)&&et(r)&&vt(r)==si}function Tt(r){return"symbol"==typeof r||et(r)&&vt(r)==ts}var Ln=nf?Ct(nf):function(r){return et(r)&&qs(r.length)&&!!He[vt(r)]},DO=Ts(Pc),FO=Ts(function(r,n){return r<=n});function Kd(r){if(!r)return[];if(Nt(r))return Zs(r)?Qt(r):St(r);if(ui&&r[ui])return function(C){for(var M,j=[];!(M=C.next()).done;)j.push(M.value);return j}(r[ui]());var n=_t(r);return(n==Gt?pc:n==Jt?cs:kn)(r)}function mr(r){return r?(r=Ht(r))===Xr||r===-Xr?17976931348623157e292*(r<0?-1:1):r==r?r:0:0===r?r:0}function we(r){var n=mr(r),u=n%1;return n==n?u?n-u:n:0}function Vd(r){return r?sn(we(r),0,sr):0}function Ht(r){if("number"==typeof r)return r;if(Tt(r))return NaN;if(Ye(r)){var n="function"==typeof r.valueOf?r.valueOf():r;r=Ye(n)?n+"":n}if("string"!=typeof r)return 0===r?r:+r;r=lf(r);var u=yb.test(r);return u||vb.test(r)?Qb(r.slice(2),u?2:8):_b.test(r)?NaN:+r}function Bd(r){return cr(r,Pt(r))}function qe(r){return null==r?"":At(r)}var MO=Fn(function(r,n){if(bi(n)||Nt(n))cr(n,ft(n),r);else for(var u in n)ze.call(n,u)&&pi(r,u,n[u])}),Hd=Fn(function(r,n){cr(n,Pt(n),r)}),zs=Fn(function(r,n,u,d){cr(n,Pt(n),r,d)}),LO=Fn(function(r,n,u,d){cr(n,ft(n),r,d)}),kO=gr(bc),ZO=Oe(function(r,n){r=Ke(r);var u=-1,d=n.length,h=d>2?n[2]:t;for(h&&bt(n[0],n[1],h)&&(d=1);++u<d;)for(var y=n[u],N=Pt(y),P=-1,A=N.length;++P<A;){var L=N[P],k=r[L];(k===t||Xt(k,Tn[L])&&!ze.call(r,L))&&(r[L]=y[L])}return r}),zO=Oe(function(r){return r.push(t,ld),Rt(Wd,t,r)});function ea(r,n,u){var d=null==r?t:on(r,n);return d===t?u:d}function ta(r,n){return null!=r&&hd(r,n,E1)}var XO=sd(function(r,n,u){null!=n&&"function"!=typeof n.toString&&(n=fs.call(n)),r[n]=u},na(xt)),eS=sd(function(r,n,u){null!=n&&"function"!=typeof n.toString&&(n=fs.call(n)),ze.call(r,n)?r[n].push(u):r[n]=[u]},ne),tS=Oe(_i);function ft(r){return Nt(r)?If(r):Nc(r)}function Pt(r){return Nt(r)?If(r,!0):function(r){if(!Ye(r))return function(r){var n=[];if(null!=r)for(var u in Ke(r))n.push(u);return n}(r);var n=bi(r),u=[];for(var d in r)"constructor"==d&&(n||!ze.call(r,d))||u.push(d);return u}(r)}var iS=Fn(function(r,n,u){Ss(r,n,u)}),Wd=Fn(function(r,n,u,d){Ss(r,n,u,d)}),sS=gr(function(r,n){var u={};if(null==r)return u;var d=!1;n=Je(n,function(y){return y=Mr(y,r),d||(d=y.length>1),y}),cr(r,kc(r),u),d&&(u=Kt(u,7,X1));for(var h=n.length;h--;)Tc(u,n[h]);return u}),cS=gr(function(r,n){return null==r?{}:function(r,n){return kf(r,n,function(u,d){return ta(r,d)})}(r,n)});function Gd(r,n){if(null==r)return{};var u=Je(kc(r),function(d){return[d]});return n=ne(n),kf(r,u,function(d,h){return n(d,h[0])})}var Jd=ad(ft),Qd=ad(Pt);function kn(r){return null==r?[]:hc(r,ft(r))}var vS=Un(function(r,n,u){return n=n.toLowerCase(),r+(u?Yd(n):n)});function Yd(r){return ra(qe(r).toLowerCase())}function Xd(r){return(r=qe(r))&&r.replace(wb,uw).replace(kb,"")}var IS=Un(function(r,n,u){return r+(u?"-":"")+n.toLowerCase()}),OS=Un(function(r,n,u){return r+(u?" ":"")+n.toLowerCase()}),SS=rd("toLowerCase"),TS=Un(function(r,n,u){return r+(u?"_":"")+n.toLowerCase()}),$S=Un(function(r,n,u){return r+(u?" ":"")+ra(n)}),KS=Un(function(r,n,u){return r+(u?" ":"")+n.toUpperCase()}),ra=rd("toUpperCase");function eh(r,n,u){return r=qe(r),(n=u?t:n)===t?function(C){return zb.test(C)}(r)?function(C){return C.match(qb)||[]}(r):function(C){return C.match(db)||[]}(r):r.match(n)||[]}var th=Oe(function(r,n){try{return Rt(r,t,n)}catch(u){return Yc(u)?u:new ye(u)}}),VS=gr(function(r,n){return qt(n,function(u){u=ar(u),hr(r,u,Jc(r[u],r))}),r});function na(r){return function(){return r}}var GS=id(),JS=id(!0);function xt(r){return r}function ia(r){return $f("function"==typeof r?r:Kt(r,1))}var XS=Oe(function(r,n){return function(u){return _i(u,r,n)}}),eN=Oe(function(r,n){return function(u){return _i(r,u,n)}});function sa(r,n,u){var d=ft(n),h=Os(n,d);null==u&&(!Ye(n)||!h.length&&d.length)&&(u=n,n=r,r=this,h=Os(n,ft(n)));var y=!(Ye(u)&&"chain"in u&&!u.chain),N=yr(r);return qt(h,function(P){var A=n[P];r[P]=A,N&&(r.prototype[P]=function(){var L=this.__chain__;if(y||L){var k=r(this.__wrapped__),q=k.__actions__=St(this.__actions__);return q.push({func:A,args:arguments,thisArg:r}),k.__chain__=L,k}return A.apply(r,jr([this.value()],arguments))})}),r}function oa(){}var nN=Uc(Je),iN=Uc(sf),sN=Uc(ac);function rh(r){return Kc(r)?uc(ar(r)):function(r){return function(n){return on(n,r)}}(r)}var cN=od(),aN=od(!0);function ca(){return[]}function aa(){return!1}var gN=Cs(function(r,n){return r+n},0),_N=Mc("ceil"),yN=Cs(function(r,n){return r/n},1),mN=Mc("floor"),SN=Cs(function(r,n){return r*n},1),NN=Mc("round"),PN=Cs(function(r,n){return r-n},0);return _.after=function(r,n){if("function"!=typeof n)throw new Zt(f);return r=we(r),function(){if(--r<1)return n.apply(this,arguments)}},_.ary=jd,_.assign=MO,_.assignIn=Hd,_.assignInWith=zs,_.assignWith=LO,_.at=kO,_.before=$d,_.bind=Jc,_.bindAll=VS,_.bindKey=Dd,_.castArray=function(){if(!arguments.length)return[];var r=arguments[0];return ve(r)?r:[r]},_.chain=Cd,_.chunk=function(r,n,u){n=(u?bt(r,n,u):n===t)?1:ct(we(n),0);var d=null==r?0:r.length;if(!d||n<1)return[];for(var h=0,y=0,N=j(ys(d/n));h<d;)N[y++]=Vt(r,h,h+=n);return N},_.compact=function(r){for(var n=-1,u=null==r?0:r.length,d=0,h=[];++n<u;){var y=r[n];y&&(h[d++]=y)}return h},_.concat=function(){var r=arguments.length;if(!r)return[];for(var n=j(r-1),u=arguments[0],d=r;d--;)n[d-1]=arguments[d];return jr(ve(u)?St(u):[u],pt(n,1))},_.cond=function(r){var n=null==r?0:r.length,u=ne();return r=n?Je(r,function(d){if("function"!=typeof d[1])throw new Zt(f);return[u(d[0]),d[1]]}):[],Oe(function(d){for(var h=-1;++h<n;){var y=r[h];if(Rt(y[0],this,d))return Rt(y[1],this,d)}})},_.conforms=function(r){return function(r){var n=ft(r);return function(u){return Nf(u,r,n)}}(Kt(r,1))},_.constant=na,_.countBy=xI,_.create=function(r,n){var u=Dn(r);return null==n?u:Sf(u,n)},_.curry=function Fd(r,n,u){var d=pr(r,8,t,t,t,t,t,n=u?t:n);return d.placeholder=Fd.placeholder,d},_.curryRight=function Ud(r,n,u){var d=pr(r,16,t,t,t,t,t,n=u?t:n);return d.placeholder=Ud.placeholder,d},_.debounce=Md,_.defaults=ZO,_.defaultsDeep=zO,_.defer=YI,_.delay=XI,_.difference=wE,_.differenceBy=EE,_.differenceWith=IE,_.drop=function(r,n,u){var d=null==r?0:r.length;return d?Vt(r,(n=u||n===t?1:we(n))<0?0:n,d):[]},_.dropRight=function(r,n,u){var d=null==r?0:r.length;return d?Vt(r,0,(n=d-(n=u||n===t?1:we(n)))<0?0:n):[]},_.dropRightWhile=function(r,n){return r&&r.length?Ps(r,ne(n,3),!0,!0):[]},_.dropWhile=function(r,n){return r&&r.length?Ps(r,ne(n,3),!0):[]},_.fill=function(r,n,u,d){var h=null==r?0:r.length;return h?(u&&"number"!=typeof u&&bt(r,n,u)&&(u=0,d=h),function(r,n,u,d){var h=r.length;for((u=we(u))<0&&(u=-u>h?0:h+u),(d=d===t||d>h?h:we(d))<0&&(d+=h),d=u>d?0:Vd(d);u<d;)r[u++]=n;return r}(r,n,u,d)):[]},_.filter=function(r,n){return(ve(r)?Tr:Rf)(r,ne(n,3))},_.flatMap=function(r,n){return pt(Us(r,n),1)},_.flatMapDeep=function(r,n){return pt(Us(r,n),Xr)},_.flatMapDepth=function(r,n,u){return u=u===t?1:we(u),pt(Us(r,n),u)},_.flatten=Nd,_.flattenDeep=function(r){return null!=r&&r.length?pt(r,Xr):[]},_.flattenDepth=function(r,n){return null!=r&&r.length?pt(r,n=n===t?1:we(n)):[]},_.flip=function(r){return pr(r,512)},_.flow=GS,_.flowRight=JS,_.fromPairs=function(r){for(var n=-1,u=null==r?0:r.length,d={};++n<u;){var h=r[n];d[h[0]]=h[1]}return d},_.functions=function(r){return null==r?[]:Os(r,ft(r))},_.functionsIn=function(r){return null==r?[]:Os(r,Pt(r))},_.groupBy=FI,_.initial=function(r){return null!=r&&r.length?Vt(r,0,-1):[]},_.intersection=$E,_.intersectionBy=DE,_.intersectionWith=FE,_.invert=XO,_.invertBy=eS,_.invokeMap=MI,_.iteratee=ia,_.keyBy=LI,_.keys=ft,_.keysIn=Pt,_.map=Us,_.mapKeys=function(r,n){var u={};return n=ne(n,3),or(r,function(d,h,y){hr(u,n(d,h,y),d)}),u},_.mapValues=function(r,n){var u={};return n=ne(n,3),or(r,function(d,h,y){hr(u,h,n(d,h,y))}),u},_.matches=function(r){return Ff(Kt(r,1))},_.matchesProperty=function(r,n){return Uf(r,Kt(n,1))},_.memoize=Ls,_.merge=iS,_.mergeWith=Wd,_.method=XS,_.methodOf=eN,_.mixin=sa,_.negate=ks,_.nthArg=function(r){return r=we(r),Oe(function(n){return Mf(n,r)})},_.omit=sS,_.omitBy=function(r,n){return Gd(r,ks(ne(n)))},_.once=function(r){return $d(2,r)},_.orderBy=function(r,n,u,d){return null==r?[]:(ve(n)||(n=null==n?[]:[n]),ve(u=d?t:u)||(u=null==u?[]:[u]),Lf(r,n,u))},_.over=nN,_.overArgs=rO,_.overEvery=iN,_.overSome=sN,_.partial=Qc,_.partialRight=Ld,_.partition=qI,_.pick=cS,_.pickBy=Gd,_.property=rh,_.propertyOf=function(r){return function(n){return null==r?t:on(r,n)}},_.pull=kE,_.pullAll=xd,_.pullAllBy=function(r,n,u){return r&&r.length&&n&&n.length?xc(r,n,ne(u,2)):r},_.pullAllWith=function(r,n,u){return r&&r.length&&n&&n.length?xc(r,n,t,u):r},_.pullAt=zE,_.range=cN,_.rangeRight=aN,_.rearg=nO,_.reject=function(r,n){return(ve(r)?Tr:Rf)(r,ks(ne(n,3)))},_.remove=function(r,n){var u=[];if(!r||!r.length)return u;var d=-1,h=[],y=r.length;for(n=ne(n,3);++d<y;){var N=r[d];n(N,d,r)&&(u.push(N),h.push(d))}return qf(r,h),u},_.rest=function(r,n){if("function"!=typeof r)throw new Zt(f);return Oe(r,n=n===t?n:we(n))},_.reverse=Wc,_.sampleSize=function(r,n,u){return n=(u?bt(r,n,u):n===t)?1:we(n),(ve(r)?p1:M1)(r,n)},_.set=function(r,n,u){return null==r?r:mi(r,n,u)},_.setWith=function(r,n,u,d){return d="function"==typeof d?d:t,null==r?r:mi(r,n,u,d)},_.shuffle=function(r){return(ve(r)?g1:k1)(r)},_.slice=function(r,n,u){var d=null==r?0:r.length;return d?(u&&"number"!=typeof u&&bt(r,n,u)?(n=0,u=d):(n=null==n?0:we(n),u=u===t?d:we(u)),Vt(r,n,u)):[]},_.sortBy=JI,_.sortedUniq=function(r){return r&&r.length?zf(r):[]},_.sortedUniqBy=function(r,n){return r&&r.length?zf(r,ne(n,2)):[]},_.split=function(r,n,u){return u&&"number"!=typeof u&&bt(r,n,u)&&(n=u=t),(u=u===t?sr:u>>>0)?(r=qe(r))&&("string"==typeof n||null!=n&&!Xc(n))&&!(n=At(n))&&Rn(r)?Lr(Qt(r),0,u):r.split(n,u):[]},_.spread=function(r,n){if("function"!=typeof r)throw new Zt(f);return n=null==n?0:ct(we(n),0),Oe(function(u){var d=u[n],h=Lr(u,0,n);return d&&jr(h,d),Rt(r,this,h)})},_.tail=function(r){var n=null==r?0:r.length;return n?Vt(r,1,n):[]},_.take=function(r,n,u){return r&&r.length?Vt(r,0,(n=u||n===t?1:we(n))<0?0:n):[]},_.takeRight=function(r,n,u){var d=null==r?0:r.length;return d?Vt(r,(n=d-(n=u||n===t?1:we(n)))<0?0:n,d):[]},_.takeRightWhile=function(r,n){return r&&r.length?Ps(r,ne(n,3),!1,!0):[]},_.takeWhile=function(r,n){return r&&r.length?Ps(r,ne(n,3)):[]},_.tap=function(r,n){return n(r),r},_.throttle=function(r,n,u){var d=!0,h=!0;if("function"!=typeof r)throw new Zt(f);return Ye(u)&&(d="leading"in u?!!u.leading:d,h="trailing"in u?!!u.trailing:h),Md(r,n,{leading:d,maxWait:n,trailing:h})},_.thru=Fs,_.toArray=Kd,_.toPairs=Jd,_.toPairsIn=Qd,_.toPath=function(r){return ve(r)?Je(r,ar):Tt(r)?[r]:St(Ed(qe(r)))},_.toPlainObject=Bd,_.transform=function(r,n,u){var d=ve(r),h=d||kr(r)||Ln(r);if(n=ne(n,4),null==u){var y=r&&r.constructor;u=h?d?new y:[]:Ye(r)&&yr(y)?Dn(ps(r)):{}}return(h?qt:or)(r,function(N,P,A){return n(u,N,P,A)}),u},_.unary=function(r){return jd(r,1)},_.union=sI,_.unionBy=oI,_.unionWith=cI,_.uniq=function(r){return r&&r.length?Ur(r):[]},_.uniqBy=function(r,n){return r&&r.length?Ur(r,ne(n,2)):[]},_.uniqWith=function(r,n){return n="function"==typeof n?n:t,r&&r.length?Ur(r,t,n):[]},_.unset=function(r,n){return null==r||Tc(r,n)},_.unzip=Gc,_.unzipWith=Rd,_.update=function(r,n,u){return null==r?r:Vf(r,n,Dc(u))},_.updateWith=function(r,n,u,d){return d="function"==typeof d?d:t,null==r?r:Vf(r,n,Dc(u),d)},_.values=kn,_.valuesIn=function(r){return null==r?[]:hc(r,Pt(r))},_.without=fI,_.words=eh,_.wrap=function(r,n){return Qc(Dc(n),r)},_.xor=dI,_.xorBy=hI,_.xorWith=pI,_.zip=gI,_.zipObject=function(r,n){return Hf(r||[],n||[],pi)},_.zipObjectDeep=function(r,n){return Hf(r||[],n||[],mi)},_.zipWith=mI,_.entries=Jd,_.entriesIn=Qd,_.extend=Hd,_.extendWith=zs,sa(_,_),_.add=gN,_.attempt=th,_.camelCase=vS,_.capitalize=Yd,_.ceil=_N,_.clamp=function(r,n,u){return u===t&&(u=n,n=t),u!==t&&(u=(u=Ht(u))==u?u:0),n!==t&&(n=(n=Ht(n))==n?n:0),sn(Ht(r),n,u)},_.clone=function(r){return Kt(r,4)},_.cloneDeep=function(r){return Kt(r,5)},_.cloneDeepWith=function(r,n){return Kt(r,5,n="function"==typeof n?n:t)},_.cloneWith=function(r,n){return Kt(r,4,n="function"==typeof n?n:t)},_.conformsTo=function(r,n){return null==n||Nf(r,n,ft(n))},_.deburr=Xd,_.defaultTo=function(r,n){return null==r||r!=r?n:r},_.divide=yN,_.endsWith=function(r,n,u){r=qe(r),n=At(n);var d=r.length,h=u=u===t?d:sn(we(u),0,d);return(u-=n.length)>=0&&r.slice(u,h)==n},_.eq=Xt,_.escape=function(r){return(r=qe(r))&&tb.test(r)?r.replace(Rl,lw):r},_.escapeRegExp=function(r){return(r=qe(r))&&cb.test(r)?r.replace(Qo,"\\$&"):r},_.every=function(r,n,u){var d=ve(r)?sf:v1;return u&&bt(r,n,u)&&(n=t),d(r,ne(n,3))},_.find=AI,_.findIndex=Od,_.findKey=function(r,n){return of(r,ne(n,3),or)},_.findLast=TI,_.findLastIndex=Sd,_.findLastKey=function(r,n){return of(r,ne(n,3),Ec)},_.floor=mN,_.forEach=Ad,_.forEachRight=Td,_.forIn=function(r,n){return null==r?r:wc(r,ne(n,3),Pt)},_.forInRight=function(r,n){return null==r?r:Cf(r,ne(n,3),Pt)},_.forOwn=function(r,n){return r&&or(r,ne(n,3))},_.forOwnRight=function(r,n){return r&&Ec(r,ne(n,3))},_.get=ea,_.gt=gO,_.gte=_O,_.has=function(r,n){return null!=r&&hd(r,n,w1)},_.hasIn=ta,_.head=Pd,_.identity=xt,_.includes=function(r,n,u,d){r=Nt(r)?r:kn(r),u=u&&!d?we(u):0;var h=r.length;return u<0&&(u=ct(h+u,0)),Zs(r)?u<=h&&r.indexOf(n,u)>-1:!!h&&xn(r,n,u)>-1},_.indexOf=function(r,n,u){var d=null==r?0:r.length;if(!d)return-1;var h=null==u?0:we(u);return h<0&&(h=ct(d+h,0)),xn(r,n,h)},_.inRange=function(r,n,u){return n=mr(n),u===t?(u=n,n=0):u=mr(u),function(r,n,u){return r>=gt(n,u)&&r<ct(n,u)}(r=Ht(r),n,u)},_.invoke=tS,_.isArguments=un,_.isArray=ve,_.isArrayBuffer=yO,_.isArrayLike=Nt,_.isArrayLikeObject=rt,_.isBoolean=function(r){return!0===r||!1===r||et(r)&&vt(r)==ti},_.isBuffer=kr,_.isDate=vO,_.isElement=function(r){return et(r)&&1===r.nodeType&&!Ei(r)},_.isEmpty=function(r){if(null==r)return!0;if(Nt(r)&&(ve(r)||"string"==typeof r||"function"==typeof r.splice||kr(r)||Ln(r)||un(r)))return!r.length;var n=_t(r);if(n==Gt||n==Jt)return!r.size;if(bi(r))return!Nc(r).length;for(var u in r)if(ze.call(r,u))return!1;return!0},_.isEqual=function(r,n){return yi(r,n)},_.isEqualWith=function(r,n,u){var d=(u="function"==typeof u?u:t)?u(r,n):t;return d===t?yi(r,n,t,u):!!d},_.isError=Yc,_.isFinite=function(r){return"number"==typeof r&&bf(r)},_.isFunction=yr,_.isInteger=kd,_.isLength=qs,_.isMap=qd,_.isMatch=function(r,n){return r===n||Sc(r,n,Zc(n))},_.isMatchWith=function(r,n,u){return u="function"==typeof u?u:t,Sc(r,n,Zc(n),u)},_.isNaN=function(r){return Zd(r)&&r!=+r},_.isNative=function(r){if(fE(r))throw new ye("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return jf(r)},_.isNil=function(r){return null==r},_.isNull=function(r){return null===r},_.isNumber=Zd,_.isObject=Ye,_.isObjectLike=et,_.isPlainObject=Ei,_.isRegExp=Xc,_.isSafeInteger=function(r){return kd(r)&&r>=-Ar&&r<=Ar},_.isSet=zd,_.isString=Zs,_.isSymbol=Tt,_.isTypedArray=Ln,_.isUndefined=function(r){return r===t},_.isWeakMap=function(r){return et(r)&&_t(r)==oi},_.isWeakSet=function(r){return et(r)&&"[object WeakSet]"==vt(r)},_.join=function(r,n){return null==r?"":jw.call(r,n)},_.kebabCase=IS,_.last=Bt,_.lastIndexOf=function(r,n,u){var d=null==r?0:r.length;if(!d)return-1;var h=d;return u!==t&&(h=(h=we(u))<0?ct(d+h,0):gt(h,d-1)),n==n?function(C,M,j){for(var X=j+1;X--;)if(C[X]===M)return X;return X}(r,n,h):os(r,cf,h,!0)},_.lowerCase=OS,_.lowerFirst=SS,_.lt=DO,_.lte=FO,_.max=function(r){return r&&r.length?Is(r,xt,Ic):t},_.maxBy=function(r,n){return r&&r.length?Is(r,ne(n,2),Ic):t},_.mean=function(r){return af(r,xt)},_.meanBy=function(r,n){return af(r,ne(n,2))},_.min=function(r){return r&&r.length?Is(r,xt,Pc):t},_.minBy=function(r,n){return r&&r.length?Is(r,ne(n,2),Pc):t},_.stubArray=ca,_.stubFalse=aa,_.stubObject=function(){return{}},_.stubString=function(){return""},_.stubTrue=function(){return!0},_.multiply=SN,_.nth=function(r,n){return r&&r.length?Mf(r,we(n)):t},_.noConflict=function(){return ht._===this&&(ht._=Pw),this},_.noop=oa,_.now=Ms,_.pad=function(r,n,u){r=qe(r);var d=(n=we(n))?Cn(r):0;if(!n||d>=n)return r;var h=(n-d)/2;return As(ms(h),u)+r+As(ys(h),u)},_.padEnd=function(r,n,u){r=qe(r);var d=(n=we(n))?Cn(r):0;return n&&d<n?r+As(n-d,u):r},_.padStart=function(r,n,u){r=qe(r);var d=(n=we(n))?Cn(r):0;return n&&d<n?As(n-d,u)+r:r},_.parseInt=function(r,n,u){return u||null==n?n=0:n&&(n=+n),Fw(qe(r).replace(Yo,""),n||0)},_.random=function(r,n,u){if(u&&"boolean"!=typeof u&&bt(r,n,u)&&(n=u=t),u===t&&("boolean"==typeof n?(u=n,n=t):"boolean"==typeof r&&(u=r,r=t)),r===t&&n===t?(r=0,n=1):(r=mr(r),n===t?(n=r,r=0):n=mr(n)),r>n){var d=r;r=n,n=d}if(u||r%1||n%1){var h=wf();return gt(r+h*(n-r+Jb("1e-"+((h+"").length-1))),n)}return Rc(r,n)},_.reduce=function(r,n,u){var d=ve(r)?cc:uf,h=arguments.length<3;return d(r,ne(n,4),u,h,Fr)},_.reduceRight=function(r,n,u){var d=ve(r)?tw:uf,h=arguments.length<3;return d(r,ne(n,4),u,h,xf)},_.repeat=function(r,n,u){return n=(u?bt(r,n,u):n===t)?1:we(n),Cc(qe(r),n)},_.replace=function(){var r=arguments,n=qe(r[0]);return r.length<3?n:n.replace(r[1],r[2])},_.result=function(r,n,u){var d=-1,h=(n=Mr(n,r)).length;for(h||(h=1,r=t);++d<h;){var y=null==r?t:r[ar(n[d])];y===t&&(d=h,y=u),r=yr(y)?y.call(r):y}return r},_.round=NN,_.runInContext=C,_.sample=function(r){return(ve(r)?Of:U1)(r)},_.size=function(r){if(null==r)return 0;if(Nt(r))return Zs(r)?Cn(r):r.length;var n=_t(r);return n==Gt||n==Jt?r.size:Nc(r).length},_.snakeCase=TS,_.some=function(r,n,u){var d=ve(r)?ac:q1;return u&&bt(r,n,u)&&(n=t),d(r,ne(n,3))},_.sortedIndex=function(r,n){return Ns(r,n)},_.sortedIndexBy=function(r,n,u){return Ac(r,n,ne(u,2))},_.sortedIndexOf=function(r,n){var u=null==r?0:r.length;if(u){var d=Ns(r,n);if(d<u&&Xt(r[d],n))return d}return-1},_.sortedLastIndex=function(r,n){return Ns(r,n,!0)},_.sortedLastIndexBy=function(r,n,u){return Ac(r,n,ne(u,2),!0)},_.sortedLastIndexOf=function(r,n){if(null!=r&&r.length){var d=Ns(r,n,!0)-1;if(Xt(r[d],n))return d}return-1},_.startCase=$S,_.startsWith=function(r,n,u){return r=qe(r),u=null==u?0:sn(we(u),0,r.length),n=At(n),r.slice(u,u+n.length)==n},_.subtract=PN,_.sum=function(r){return r&&r.length?fc(r,xt):0},_.sumBy=function(r,n){return r&&r.length?fc(r,ne(n,2)):0},_.template=function(r,n,u){var d=_.templateSettings;u&&bt(r,n,u)&&(n=t),r=qe(r),n=zs({},n,d,ud);var P,A,h=zs({},n.imports,d.imports,ud),y=ft(h),N=hc(h,y),L=0,k=n.interpolate||rs,q="__p += '",W=gc((n.escape||rs).source+"|"+k.source+"|"+(k===Cl?gb:rs).source+"|"+(n.evaluate||rs).source+"|$","g"),ee="//# sourceURL="+(ze.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Vb+"]")+"\n";r.replace(W,function(oe,Se,Pe,jt,wt,$t){return Pe||(Pe=jt),q+=r.slice(L,$t).replace(Eb,fw),Se&&(P=!0,q+="' +\n__e("+Se+") +\n'"),wt&&(A=!0,q+="';\n"+wt+";\n__p += '"),Pe&&(q+="' +\n((__t = ("+Pe+")) == null ? '' : __t) +\n'"),L=$t+oe.length,oe}),q+="';\n";var se=ze.call(n,"variable")&&n.variable;if(se){if(hb.test(se))throw new ye("Invalid `variable` option passed into `_.template`")}else q="with (obj) {\n"+q+"\n}\n";q=(A?q.replace(Q0,""):q).replace(Y0,"$1").replace(X0,"$1;"),q="function("+(se||"obj")+") {\n"+(se?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(P?", __e = _.escape":"")+(A?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+q+"return __p\n}";var Ee=th(function(){return Me(y,ee+"return "+q).apply(t,N)});if(Ee.source=q,Yc(Ee))throw Ee;return Ee},_.times=function(r,n){if((r=we(r))<1||r>Ar)return[];var u=sr,d=gt(r,sr);n=ne(n),r-=sr;for(var h=dc(d,n);++u<r;)n(u);return h},_.toFinite=mr,_.toInteger=we,_.toLength=Vd,_.toLower=function(r){return qe(r).toLowerCase()},_.toNumber=Ht,_.toSafeInteger=function(r){return r?sn(we(r),-Ar,Ar):0===r?r:0},_.toString=qe,_.toUpper=function(r){return qe(r).toUpperCase()},_.trim=function(r,n,u){if((r=qe(r))&&(u||n===t))return lf(r);if(!r||!(n=At(n)))return r;var d=Qt(r),h=Qt(n);return Lr(d,ff(d,h),df(d,h)+1).join("")},_.trimEnd=function(r,n,u){if((r=qe(r))&&(u||n===t))return r.slice(0,pf(r)+1);if(!r||!(n=At(n)))return r;var d=Qt(r);return Lr(d,0,df(d,Qt(n))+1).join("")},_.trimStart=function(r,n,u){if((r=qe(r))&&(u||n===t))return r.replace(Yo,"");if(!r||!(n=At(n)))return r;var d=Qt(r);return Lr(d,ff(d,Qt(n))).join("")},_.truncate=function(r,n){var u=30,d="...";if(Ye(n)){var h="separator"in n?n.separator:h;u="length"in n?we(n.length):u,d="omission"in n?At(n.omission):d}var y=(r=qe(r)).length;if(Rn(r)){var N=Qt(r);y=N.length}if(u>=y)return r;var P=u-Cn(d);if(P<1)return d;var A=N?Lr(N,0,P).join(""):r.slice(0,P);if(h===t)return A+d;if(N&&(P+=A.length-P),Xc(h)){if(r.slice(P).search(h)){var L,k=A;for(h.global||(h=gc(h.source,qe(Al.exec(h))+"g")),h.lastIndex=0;L=h.exec(k);)var q=L.index;A=A.slice(0,q===t?P:q)}}else if(r.indexOf(At(h),P)!=P){var W=A.lastIndexOf(h);W>-1&&(A=A.slice(0,W))}return A+d},_.unescape=function(r){return(r=qe(r))&&eb.test(r)?r.replace(xl,mw):r},_.uniqueId=function(r){var n=++Sw;return qe(r)+n},_.upperCase=KS,_.upperFirst=ra,_.each=Ad,_.eachRight=Td,_.first=Pd,sa(_,function(){var r={};return or(_,function(n,u){ze.call(_.prototype,u)||(r[u]=n)}),r}(),{chain:!1}),_.VERSION="4.17.21",qt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){_[r].placeholder=_}),qt(["drop","take"],function(r,n){Ne.prototype[r]=function(u){u=u===t?1:ct(we(u),0);var d=this.__filtered__&&!n?new Ne(this):this.clone();return d.__filtered__?d.__takeCount__=gt(u,d.__takeCount__):d.__views__.push({size:gt(u,sr),type:r+(d.__dir__<0?"Right":"")}),d},Ne.prototype[r+"Right"]=function(u){return this.reverse()[r](u).reverse()}}),qt(["filter","map","takeWhile"],function(r,n){var u=n+1,d=1==u||3==u;Ne.prototype[r]=function(h){var y=this.clone();return y.__iteratees__.push({iteratee:ne(h,3),type:u}),y.__filtered__=y.__filtered__||d,y}}),qt(["head","last"],function(r,n){var u="take"+(n?"Right":"");Ne.prototype[r]=function(){return this[u](1).value()[0]}}),qt(["initial","tail"],function(r,n){var u="drop"+(n?"":"Right");Ne.prototype[r]=function(){return this.__filtered__?new Ne(this):this[u](1)}}),Ne.prototype.compact=function(){return this.filter(xt)},Ne.prototype.find=function(r){return this.filter(r).head()},Ne.prototype.findLast=function(r){return this.reverse().find(r)},Ne.prototype.invokeMap=Oe(function(r,n){return"function"==typeof r?new Ne(this):this.map(function(u){return _i(u,r,n)})}),Ne.prototype.reject=function(r){return this.filter(ks(ne(r)))},Ne.prototype.slice=function(r,n){r=we(r);var u=this;return u.__filtered__&&(r>0||n<0)?new Ne(u):(r<0?u=u.takeRight(-r):r&&(u=u.drop(r)),n!==t&&(u=(n=we(n))<0?u.dropRight(-n):u.take(n-r)),u)},Ne.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},Ne.prototype.toArray=function(){return this.take(sr)},or(Ne.prototype,function(r,n){var u=/^(?:filter|find|map|reject)|While$/.test(n),d=/^(?:head|last)$/.test(n),h=_[d?"take"+("last"==n?"Right":""):n],y=d||/^find/.test(n);h&&(_.prototype[n]=function(){var N=this.__wrapped__,P=d?[1]:arguments,A=N instanceof Ne,L=P[0],k=A||ve(N),q=function(Se){var Pe=h.apply(_,jr([Se],P));return d&&W?Pe[0]:Pe};k&&u&&"function"==typeof L&&1!=L.length&&(A=k=!1);var W=this.__chain__,ee=!!this.__actions__.length,se=y&&!W,Ee=A&&!ee;if(!y&&k){N=Ee?N:new Ne(this);var oe=r.apply(N,P);return oe.__actions__.push({func:Fs,args:[q],thisArg:t}),new zt(oe,W)}return se&&Ee?r.apply(this,P):(oe=this.thru(q),se?d?oe.value()[0]:oe.value():oe)})}),qt(["pop","push","shift","sort","splice","unshift"],function(r){var n=as[r],u=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",d=/^(?:pop|shift)$/.test(r);_.prototype[r]=function(){var h=arguments;if(d&&!this.__chain__){var y=this.value();return n.apply(ve(y)?y:[],h)}return this[u](function(N){return n.apply(ve(N)?N:[],h)})}}),or(Ne.prototype,function(r,n){var u=_[n];if(u){var d=u.name+"";ze.call($n,d)||($n[d]=[]),$n[d].push({name:n,func:u})}}),$n[Rs(t,2).name]=[{name:"wrapper",func:t}],Ne.prototype.clone=function(){var r=new Ne(this.__wrapped__);return r.__actions__=St(this.__actions__),r.__dir__=this.__dir__,r.__filtered__=this.__filtered__,r.__iteratees__=St(this.__iteratees__),r.__takeCount__=this.__takeCount__,r.__views__=St(this.__views__),r},Ne.prototype.reverse=function(){if(this.__filtered__){var r=new Ne(this);r.__dir__=-1,r.__filtered__=!0}else(r=this.clone()).__dir__*=-1;return r},Ne.prototype.value=function(){var r=this.__wrapped__.value(),n=this.__dir__,u=ve(r),d=n<0,h=u?r.length:0,y=function(r,n,u){for(var d=-1,h=u.length;++d<h;){var y=u[d],N=y.size;switch(y.type){case"drop":r+=N;break;case"dropRight":n-=N;break;case"take":n=gt(n,r+N);break;case"takeRight":r=ct(r,n-N)}}return{start:r,end:n}}(0,h,this.__views__),N=y.start,P=y.end,A=P-N,L=d?P:N-1,k=this.__iteratees__,q=k.length,W=0,ee=gt(A,this.__takeCount__);if(!u||!d&&h==A&&ee==A)return Bf(r,this.__actions__);var se=[];e:for(;A--&&W<ee;){for(var Ee=-1,oe=r[L+=n];++Ee<q;){var Se=k[Ee],jt=Se.type,wt=(0,Se.iteratee)(oe);if(2==jt)oe=wt;else if(!wt){if(1==jt)continue e;break e}}se[W++]=oe}return se},_.prototype.at=bI,_.prototype.chain=function(){return Cd(this)},_.prototype.commit=function(){return new zt(this.value(),this.__chain__)},_.prototype.next=function(){this.__values__===t&&(this.__values__=Kd(this.value()));var r=this.__index__>=this.__values__.length;return{done:r,value:r?t:this.__values__[this.__index__++]}},_.prototype.plant=function(r){for(var n,u=this;u instanceof ws;){var d=Id(u);d.__index__=0,d.__values__=t,n?h.__wrapped__=d:n=d;var h=d;u=u.__wrapped__}return h.__wrapped__=r,n},_.prototype.reverse=function(){var r=this.__wrapped__;if(r instanceof Ne){var n=r;return this.__actions__.length&&(n=new Ne(this)),(n=n.reverse()).__actions__.push({func:Fs,args:[Wc],thisArg:t}),new zt(n,this.__chain__)}return this.thru(Wc)},_.prototype.toJSON=_.prototype.valueOf=_.prototype.value=function(){return Bf(this.__wrapped__,this.__actions__)},_.prototype.first=_.prototype.head,ui&&(_.prototype[ui]=function(){return this}),_}();en?((en.exports=An)._=An,ic._=An):ht._=An}.call(Xn);var t0=Object.defineProperty,r0=Object.defineProperties,n0=Object.getOwnPropertyDescriptors,hl=Object.getOwnPropertySymbols,i0=Object.prototype.hasOwnProperty,s0=Object.prototype.propertyIsEnumerable,pl=(s,e,t)=>e in s?t0(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Vi=(s,e)=>{for(var t in e||(e={}))i0.call(e,t)&&pl(s,t,e[t]);if(hl)for(var t of hl(e))s0.call(e,t)&&pl(s,t,e[t]);return s},o0=(s,e)=>r0(s,n0(e));function Lt(s,e,t){let o;const a=Uo(s);return e.rpcMap&&(o=e.rpcMap[a]),o||(o=`https://rpc.walletconnect.com/v1?chainId=eip155:${a}&projectId=${t}`),o}function Uo(s){return s.includes("eip155")?Number(s.split(":")[1]):Number(s)}function gl(s){return s.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function _l(s){var e,t,o,a;const l={};if(!function(s){return Object.getPrototypeOf(s)===Object.prototype&&Object.keys(s).length}(s))return l;for(const[f,g]of Object.entries(s)){const O=Zi(f)?[f]:g.chains,w=g.methods||[],R=g.events||[],T=g.rpcMap||{},H=Yn(f);l[H]=o0(Vi(Vi({},l[H]),g),{chains:ir(O,null==(e=l[H])?void 0:e.chains),methods:ir(w,null==(t=l[H])?void 0:t.methods),events:ir(R,null==(o=l[H])?void 0:o.events),rpcMap:Vi(Vi({},T),null==(a=l[H])?void 0:a.rpcMap)})}return l}function u0(s){return s.includes(":")?s.split(":")[2]:s}function l0(s){const e={};for(const[t,o]of Object.entries(s)){const a=o.methods||[],l=o.events||[],f=o.accounts||[],g=Zi(t)?[t]:o.chains?o.chains:gl(o.accounts);e[t]={chains:g,methods:a,events:l,accounts:f}}return e}const yl={},tt=s=>yl[s],Mo=(s,e)=>{yl[s]=e};class f0{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=tt("events"),this.client=tt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const o=t||Lt(`${this.name}:${e}`,this.namespace);if(!o)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,o)}this.events.emit("default_chain_changed",`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var o;e[t]=this.createHttpProvider(t,null==(o=this.namespace.rpcMap)?void 0:o[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const o=this.createHttpProvider(e,t);o&&(this.httpProviders[e]=o)}createHttpProvider(e,t){const o=t||Lt(e,this.namespace);return typeof o>"u"?void 0:new Or.r(new Yr.Z(o,tt("disableProviderPing")))}}class d0{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=tt("events"),this.client=tt("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}request(e){var t=this;return(0,S.Z)(function*(){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return t.getAccounts();case"wallet_switchEthereumChain":return yield t.handleSwitchChain(e);case"eth_chainId":return parseInt(t.getDefaultChain())}return t.namespace.methods.includes(e.request.method)?yield t.client.request(e):t.getHttpProvider().request(e.request)})()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){const o=Uo(e);if(!this.httpProviders[o]){const a=t||Lt(`${this.name}:${o}`,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${o}`);this.setHttpProvider(o,a)}this.chainId=o,this.events.emit("default_chain_changed",`${this.name}:${o}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const o=t||Lt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);return typeof o>"u"?void 0:new Or.r(new Yr.k(o,tt("disableProviderPing")))}setHttpProvider(e,t){const o=this.createHttpProvider(e,t);o&&(this.httpProviders[e]=o)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var o;const a=Uo(t);e[a]=this.createHttpProvider(a,null==(o=this.namespace.rpcMap)?void 0:o[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}handleSwitchChain(e){var t=this;return(0,S.Z)(function*(){var o,a;let l=e.request.params?null==(o=e.request.params[0])?void 0:o.chainId:"0x0";l=l.startsWith("0x")?l:`0x${l}`;const f=parseInt(l,16);if(t.isChainApproved(f))t.setDefaultChain(`${f}`);else{if(!t.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${f}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);yield t.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:l}]},chainId:null==(a=t.namespace.chains)?void 0:a[0]}),t.setDefaultChain(`${f}`)}return null})()}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}}class h0{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=tt("events"),this.client=tt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const o=t||Lt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!o)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,o)}this.chainId=e,this.events.emit("default_chain_changed",`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var o;e[t]=this.createHttpProvider(t,null==(o=this.namespace.rpcMap)?void 0:o[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const o=this.createHttpProvider(e,t);o&&(this.httpProviders[e]=o)}createHttpProvider(e,t){const o=t||Lt(e,this.namespace,this.client.core.projectId);return typeof o>"u"?void 0:new Or.r(new Yr.Z(o,tt("disableProviderPing")))}}class p0{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=tt("events"),this.client=tt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const o=t||Lt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!o)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,o)}this.events.emit("default_chain_changed",`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var o;e[t]=this.createHttpProvider(t,null==(o=this.namespace.rpcMap)?void 0:o[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const o=this.createHttpProvider(e,t);o&&(this.httpProviders[e]=o)}createHttpProvider(e,t){const o=t||Lt(e,this.namespace,this.client.core.projectId);return typeof o>"u"?void 0:new Or.r(new Yr.Z(o,tt("disableProviderPing")))}}class g0{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=tt("events"),this.client=tt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const o=t||this.getCardanoRPCUrl(e);if(!o)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,o)}this.events.emit("default_chain_changed",`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const o=this.getCardanoRPCUrl(t);e[t]=this.createHttpProvider(t,o)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const o=this.createHttpProvider(e,t);o&&(this.httpProviders[e]=o)}createHttpProvider(e,t){const o=t||this.getCardanoRPCUrl(e);return typeof o>"u"?void 0:new Or.r(new Yr.Z(o,tt("disableProviderPing")))}}class _0{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=tt("events"),this.client=tt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const o=t||Lt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!o)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,o)}this.chainId=e,this.events.emit("default_chain_changed",`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var o;e[t]=this.createHttpProvider(t,null==(o=this.namespace.rpcMap)?void 0:o[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const o=this.createHttpProvider(e,t);o&&(this.httpProviders[e]=o)}createHttpProvider(e,t){const o=t||Lt(e,this.namespace,this.client.core.projectId);return typeof o>"u"?void 0:new Or.r(new Yr.Z(o,tt("disableProviderPing")))}}class y0{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=tt("events"),this.client=tt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const o=t||Lt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!o)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,o)}this.chainId=e,this.events.emit("default_chain_changed",`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var o;e[t]=this.createHttpProvider(t,null==(o=this.namespace.rpcMap)?void 0:o[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const o=this.createHttpProvider(e,t);o&&(this.httpProviders[e]=o)}createHttpProvider(e,t){const o=t||Lt(e,this.namespace,this.client.core.projectId);return typeof o>"u"?void 0:new Or.r(new Yr.Z(o,tt("disableProviderPing")))}}var m0=Object.defineProperty,v0=Object.defineProperties,b0=Object.getOwnPropertyDescriptors,ml=Object.getOwnPropertySymbols,w0=Object.prototype.hasOwnProperty,E0=Object.prototype.propertyIsEnumerable,vl=(s,e,t)=>e in s?m0(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Bi=(s,e)=>{for(var t in e||(e={}))w0.call(e,t)&&vl(s,t,e[t]);if(ml)for(var t of ml(e))E0.call(e,t)&&vl(s,t,e[t]);return s},Lo=(s,e)=>v0(s,b0(e));class ko{constructor(e){this.events=new(We()),this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,Ae.pino)((0,Ae.getDefaultLoggerOptions)({level:e?.logger||"error"})),this.disableProviderPing=e?.disableProviderPing||!1}static init(e){return(0,S.Z)(function*(){const t=new ko(e);return yield t.initialize(),t})()}request(e,t){var o=this;return(0,S.Z)(function*(){const[a,l]=o.validateChain(t);if(!o.session)throw new Error("Please call connect() before request()");return yield o.getProvider(a).request({request:Bi({},e),chainId:`${a}:${l}`,topic:o.session.topic})})()}sendAsync(e,t,o){this.request(e,o).then(a=>t(null,a)).catch(a=>t(a,void 0))}enable(){var e=this;return(0,S.Z)(function*(){if(!e.client)throw new Error("Sign Client not initialized");return e.session||(yield e.connect({namespaces:e.namespaces,optionalNamespaces:e.optionalNamespaces,sessionProperties:e.sessionProperties})),yield e.requestAccounts()})()}disconnect(){var e=this;return(0,S.Z)(function*(){var t;if(!e.session)throw new Error("Please call connect() before enable()");yield e.client.disconnect({topic:null==(t=e.session)?void 0:t.topic,reason:xr("USER_DISCONNECTED")}),yield e.cleanup()})()}connect(e){var t=this;return(0,S.Z)(function*(){if(!t.client)throw new Error("Sign Client not initialized");if(t.setNamespaces(e),yield t.cleanupPendingPairings(),!e.skipPairing)return yield t.pair(e.pairingTopic)})()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}pair(e){var t=this;return(0,S.Z)(function*(){t.shouldAbortPairingAttempt=!1;let o=0;do{if(t.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(o>=t.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:a,approval:l}=yield t.client.connect({pairingTopic:e,requiredNamespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,sessionProperties:t.sessionProperties});a&&(t.uri=a,t.events.emit("display_uri",a)),yield l().then(f=>{t.session=f,t.namespaces||(t.namespaces=l0(f.namespaces),t.persist("namespaces",t.namespaces))}).catch(f=>{if(f.message!==Zu)throw f;o++})}while(!t.session);return t.onConnect(),t.session})()}setDefaultChain(e,t){try{if(!this.session)return;const[o,a]=this.validateChain(e);this.getProvider(o).setDefaultChain(a,t)}catch(o){if(!/Please call connect/.test(o.message))throw o}}cleanupPendingPairings(e={}){var t=this;return(0,S.Z)(function*(){t.logger.info("Cleaning up inactive pairings...");const o=t.client.pairing.getAll();if(On(o)){for(const a of o)e.deletePairings?t.client.core.expirer.set(a.topic,0):yield t.client.core.relayer.subscriber.unsubscribe(a.topic);t.logger.info(`Inactive pairings cleared: ${o.length}`)}})()}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}checkStorage(){var e=this;return(0,S.Z)(function*(){e.namespaces=yield e.getFromStore("namespaces"),e.optionalNamespaces=(yield e.getFromStore("optionalNamespaces"))||{},e.client.session.length&&(e.session=e.client.session.get(e.client.session.keys[e.client.session.keys.length-1]),e.createProviders())})()}initialize(){var e=this;return(0,S.Z)(function*(){e.logger.trace("Initialized"),yield e.createClient(),yield e.checkStorage(),e.registerEventListeners()})()}createClient(){var e=this;return(0,S.Z)(function*(){e.client=e.providerOpts.client||(yield No.init({logger:e.providerOpts.logger||"error",relayUrl:e.providerOpts.relayUrl||"wss://relay.walletconnect.com",projectId:e.providerOpts.projectId,metadata:e.providerOpts.metadata,storageOptions:e.providerOpts.storageOptions,storage:e.providerOpts.storage,name:e.providerOpts.name})),e.logger.trace("SignClient Initialized")})()}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(t=>Yn(t)))];Mo("client",this.client),Mo("events",this.events),Mo("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const o=function(s,e){const t=Object.keys(e.namespaces).filter(a=>a.includes(s));if(!t.length)return[];const o=[];return t.forEach(a=>{o.push(...e.namespaces[a].accounts)}),o}(t,this.session),a=gl(o),l=function(s={},e={}){const t=_l(s),o=_l(e);return Fo.exports.merge(t,o)}(this.namespaces,this.optionalNamespaces),f=Lo(Bi({},l[t]),{accounts:o,chains:a});switch(t){case"eip155":this.rpcProviders[t]=new d0({namespace:f});break;case"solana":this.rpcProviders[t]=new h0({namespace:f});break;case"cosmos":this.rpcProviders[t]=new p0({namespace:f});break;case"polkadot":this.rpcProviders[t]=new f0({namespace:f});break;case"cip34":this.rpcProviders[t]=new g0({namespace:f});break;case"elrond":this.rpcProviders[t]=new _0({namespace:f});break;case"multiversx":this.rpcProviders[t]=new y0({namespace:f})}})}registerEventListeners(){var e=this;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:o}=t,{event:a}=o;if("accountsChanged"===a.name){const l=a.data;l&&On(l)&&this.events.emit("accountsChanged",l.map(u0))}else"chainChanged"===a.name?this.onChainChanged(o.chainId):this.events.emit(a.name,a.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:o})=>{var a;const{namespaces:l}=o,f=null==(a=this.client)?void 0:a.session.get(t);this.session=Lo(Bi({},f),{namespaces:l}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:o})}),this.client.on("session_delete",function(){var t=(0,S.Z)(function*(o){yield e.cleanup(),e.events.emit("session_delete",o),e.events.emit("disconnect",Lo(Bi({},xr("USER_DISCONNECTED")),{data:o.topic}))});return function(o){return t.apply(this,arguments)}}()),this.on("default_chain_changed",t=>{this.onChainChanged(t,!0)})}getProvider(e){if(!this.rpcProviders[e])throw new Error(`Provider not found: ${e}`);return this.rpcProviders[e]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:o,sessionProperties:a}=e;t&&Object.keys(t).length&&(this.namespaces=t),o&&Object.keys(o).length&&(this.optionalNamespaces=o),this.sessionProperties=a,this.persist("namespaces",t),this.persist("optionalNamespaces",o)}validateChain(e){const[t,o]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,o];if(t&&!Object.keys(this.namespaces||{}).map(f=>Yn(f)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&o)return[t,o];const a=Yn(Object.keys(this.namespaces)[0]);return[a,this.rpcProviders[a].getDefaultChain()]}requestAccounts(){var e=this;return(0,S.Z)(function*(){const[t]=e.validateChain();return yield e.getProvider(t).requestAccounts()})()}onChainChanged(e,t=!1){var o;if(!this.namespaces)return;const[a,l]=this.validateChain(e);t||this.getProvider(a).setDefaultChain(l),(null!=(o=this.namespaces[a])?o:this.namespaces[`${a}:${l}`]).defaultChain=l,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",l)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}cleanup(){var e=this;return(0,S.Z)(function*(){e.session=void 0,e.namespaces=void 0,e.optionalNamespaces=void 0,e.sessionProperties=void 0,e.persist("namespaces",void 0),e.persist("optionalNamespaces",void 0),e.persist("sessionProperties",void 0),yield e.cleanupPendingPairings({deletePairings:!0})})()}persist(e,t){this.client.core.storage.setItem(`${dl}/${e}`,t)}getFromStore(e){var t=this;return(0,S.Z)(function*(){return yield t.client.core.storage.getItem(`${dl}/${e}`)})()}}const I0=ko,Hi=["eth_sendTransaction","personal_sign"],bl=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],Wi=["chainChanged","accountsChanged"],wl=["message","disconnect","connect"];var x0=Object.defineProperty,R0=Object.defineProperties,C0=Object.getOwnPropertyDescriptors,El=Object.getOwnPropertySymbols,A0=Object.prototype.hasOwnProperty,T0=Object.prototype.propertyIsEnumerable,Il=(s,e,t)=>e in s?x0(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ei=(s,e)=>{for(var t in e||(e={}))A0.call(e,t)&&Il(s,t,e[t]);if(El)for(var t of El(e))T0.call(e,t)&&Il(s,t,e[t]);return s},Ol=(s,e)=>R0(s,C0(e));function Gi(s){return Number(s[0].split(":")[1])}function qo(s){return`0x${s.toString(16)}`}class Ji{constructor(){this.events=new Le.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY="wc@2:ethereum_provider:",this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static init(e){return(0,S.Z)(function*(){const t=new Ji;return yield t.initialize(e),t})()}request(e){var t=this;return(0,S.Z)(function*(){return yield t.signer.request(e,t.formatChainId(t.chainId))})()}sendAsync(e,t){this.signer.sendAsync(e,t,this.formatChainId(this.chainId))}get connected(){return!!this.signer.client&&this.signer.client.core.relayer.connected}get connecting(){return!!this.signer.client&&this.signer.client.core.relayer.connecting}enable(){var e=this;return(0,S.Z)(function*(){return e.session||(yield e.connect()),yield e.request({method:"eth_requestAccounts"})})()}connect(e){var t=this;return(0,S.Z)(function*(){if(!t.signer.client)throw new Error("Provider not initialized. Call init() first");t.loadConnectOpts(e);const{required:o,optional:a}=function(s){const{chains:e,optionalChains:t,methods:o,optionalMethods:a,events:l,optionalEvents:f,rpcMap:g}=s;if(!Vr(e))throw new Error("Invalid chains");const O={chains:e,methods:o||Hi,events:l||Wi,rpcMap:ei({},e.length?{[Gi(e)]:g[Gi(e)]}:{})},w=l?.filter(te=>!Wi.includes(te)),R=o?.filter(te=>!Hi.includes(te));if(!(t||f||a||null!=w&&w.length||null!=R&&R.length))return{required:e.length?O:void 0};const H={chains:[...new Set(w?.length&&R?.length||!t?O.chains.concat(t||[]):t)],methods:[...new Set(O.methods.concat(null!=a&&a.length?a:bl))],events:[...new Set(O.events.concat(f||wl))],rpcMap:g};return{required:e.length?O:void 0,optional:t.length?H:void 0}}(t.rpc);try{const l=yield new Promise(function(){var g=(0,S.Z)(function*(O,w){var R;t.rpc.showQrModal&&(null==(R=t.modal)||R.subscribeModal(T=>{!T.open&&!t.signer.session&&(t.signer.abortPairingAttempt(),w(new Error("Connection request reset. Please try again.")))})),yield t.signer.connect(Ol(ei({namespaces:ei({},o&&{[t.namespace]:o})},a&&{optionalNamespaces:{[t.namespace]:a}}),{pairingTopic:e?.pairingTopic})).then(T=>{O(T)}).catch(T=>{w(new Error(T.message))})});return function(O,w){return g.apply(this,arguments)}}());if(!l)return;t.setChainIds(t.rpc.chains);const f=function(s,e=[]){const t=[];return Object.keys(s).forEach(o=>{e.length&&!e.includes(o)||t.push(...s[o].accounts)}),t}(l.namespaces,[t.namespace]);t.setAccounts(f),t.events.emit("connect",{chainId:qo(t.chainId)})}catch(l){throw t.signer.logger.error(l),l}finally{t.modal&&t.modal.closeModal()}})()}disconnect(){var e=this;return(0,S.Z)(function*(){e.session&&(yield e.signer.disconnect()),e.reset()})()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:t}=e,{event:o}=t;"accountsChanged"===o.name?(this.accounts=this.parseAccounts(o.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===o.name?this.setChainId(this.formatChainId(o.data)):this.events.emit(o.name,o.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",qo(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",Ol(ei({},function(s,e){const{message:t,code:o}=Kh[s];return{message:e?`${t} ${e}`:t,code:o}}("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,o;this.rpc.showQrModal&&(null==(t=this.modal)||t.closeModal(),null==(o=this.modal)||o.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return"string"==typeof e&&e.startsWith(`${this.namespace}:`)}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter(o=>this.isCompatibleChainId(o)).map(o=>this.parseChainId(o));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",qo(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,o,a]=e.split(":");return{chainId:`${t}:${o}`,address:a}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,o;const a=null!=(t=e?.chains)?t:[],l=null!=(o=e?.optionalChains)?o:[],f=a.concat(l);if(!f.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=a.length?e?.methods||Hi:[],O=a.length?e?.events||Wi:[],w=e?.optionalMethods||[],R=e?.optionalEvents||[],T=e?.rpcMap||this.buildRpcMap(f,e.projectId),H=e?.qrModalOptions||void 0;return{chains:a?.map(te=>this.formatChainId(te)),optionalChains:l.map(te=>this.formatChainId(te)),methods:g,events:O,optionalMethods:w,optionalEvents:R,rpcMap:T,showQrModal:!(null==e||!e.showQrModal),qrModalOptions:H,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const o={};return e.forEach(a=>{o[a]=this.getRpcUrl(a,t)}),o}initialize(e){var t=this;return(0,S.Z)(function*(){if(t.rpc=t.getRpcConfig(e),t.chainId=Gi(t.rpc.chains.length?t.rpc.chains:t.rpc.optionalChains),t.signer=yield I0.init({projectId:t.rpc.projectId,metadata:t.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions}),t.registerEventListeners(),yield t.loadPersistedSession(),t.rpc.showQrModal){let o;try{const{WalletConnectModal:a}=yield K.e(2687).then(K.bind(K,52687));o=a}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(o)try{t.modal=new o(ei({walletConnectVersion:2,projectId:t.rpc.projectId,standaloneChains:t.rpc.chains},t.rpc.qrModalOptions))}catch(a){throw t.signer.logger.error(a),new Error("Could not generate WalletConnectModal Instance")}}})()}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:o,rpcMap:a}=e;t&&Vr(t)&&(this.rpc.chains=t.map(l=>this.formatChainId(l)),t.forEach(l=>{this.rpc.rpcMap[l]=a?.[l]||this.getRpcUrl(l)})),o&&Vr(o)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=o?.map(l=>this.formatChainId(l)),o.forEach(l=>{this.rpc.rpcMap[l]=a?.[l]||this.getRpcUrl(l)}))}getRpcUrl(e,t){var o;return(null==(o=this.rpc.rpcMap)?void 0:o[e])||`https://rpc.walletconnect.com/v1/?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}loadPersistedSession(){var e=this;return(0,S.Z)(function*(){if(!e.session)return;const t=yield e.signer.client.core.storage.getItem(`${e.STORAGE_KEY}/chainId`),o=e.session.namespaces[`${e.namespace}:${t}`]?e.session.namespaces[`${e.namespace}:${t}`]:e.session.namespaces[e.namespace];e.setChainIds(t?[e.formatChainId(t)]:o?.accounts),e.setAccounts(o?.accounts)})()}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return"string"==typeof e||e instanceof String?[this.parseAccount(e)]:e.map(t=>this.parseAccount(t))}}const $0=Ji},63581:(ur,D)=>{function K(Te){let je;return"undefined"!=typeof window&&void 0!==window[Te]&&(je=window[Te]),je}function S(Te){const je=K(Te);if(!je)throw new Error(`${Te} is not defined in Window`);return je}Object.defineProperty(D,"__esModule",{value:!0}),D.getLocalStorage=D.getLocalStorageOrThrow=D.getCrypto=D.getCryptoOrThrow=D.getLocation=D.getLocationOrThrow=D.getNavigator=D.getNavigatorOrThrow=D.getDocument=D.getDocumentOrThrow=D.getFromWindowOrThrow=D.getFromWindow=void 0,D.getFromWindow=K,D.getFromWindowOrThrow=S,D.getDocumentOrThrow=function(){return S("document")},D.getDocument=function(){return K("document")},D.getNavigatorOrThrow=function(){return S("navigator")},D.getNavigator=function(){return K("navigator")},D.getLocationOrThrow=function(){return S("location")},D.getLocation=function(){return K("location")},D.getCryptoOrThrow=function(){return S("crypto")},D.getCrypto=function(){return K("crypto")},D.getLocalStorageOrThrow=function(){return S("localStorage")},D.getLocalStorage=function(){return K("localStorage")}},38541:(ur,D,K)=>{K(63581)},32257:(ur,D,K)=>{const S=K(82915),Le=K(65361),We=K(95967),Ze=K(10979),Ve=Symbol("encodeFragmentIdentifier");function he(p){if("string"!=typeof p||1!==p.length)throw new TypeError("arrayFormatSeparator must be single character string")}function $(p,b){return b.encode?b.strict?S(p):encodeURIComponent(p):p}function be(p,b){return b.decode?Le(p):p}function Te(p){return Array.isArray(p)?p.sort():"object"==typeof p?Te(Object.keys(p)).sort((b,m)=>Number(b)-Number(m)).map(b=>p[b]):p}function je(p){const b=p.indexOf("#");return-1!==b&&(p=p.slice(0,b)),p}function ge(p){const b=(p=je(p)).indexOf("?");return-1===b?"":p.slice(b+1)}function Re(p,b){return b.parseNumbers&&!Number.isNaN(Number(p))&&"string"==typeof p&&""!==p.trim()?p=Number(p):b.parseBooleans&&null!==p&&("true"===p.toLowerCase()||"false"===p.toLowerCase())&&(p="true"===p.toLowerCase()),p}function Ce(p,b){he((b=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},b)).arrayFormatSeparator);const m=function(p){let b;switch(p.arrayFormat){case"index":return(m,I,x)=>{b=/\[(\d*)\]$/.exec(m),m=m.replace(/\[\d*\]$/,""),b?(void 0===x[m]&&(x[m]={}),x[m][b[1]]=I):x[m]=I};case"bracket":return(m,I,x)=>{b=/(\[\])$/.exec(m),x[m=m.replace(/\[\]$/,"")]=b?void 0!==x[m]?[].concat(x[m],I):[I]:I};case"colon-list-separator":return(m,I,x)=>{b=/(:list)$/.exec(m),x[m=m.replace(/:list$/,"")]=b?void 0!==x[m]?[].concat(x[m],I):[I]:I};case"comma":case"separator":return(m,I,x)=>{const z="string"==typeof I&&I.includes(p.arrayFormatSeparator),F="string"==typeof I&&!z&&be(I,p).includes(p.arrayFormatSeparator);I=F?be(I,p):I;const me=z||F?I.split(p.arrayFormatSeparator).map(qr=>be(qr,p)):null===I?I:be(I,p);x[m]=me};case"bracket-separator":return(m,I,x)=>{const z=/(\[\])$/.test(m);if(m=m.replace(/\[\]$/,""),!z)return void(x[m]=I&&be(I,p));const F=null===I?[]:I.split(p.arrayFormatSeparator).map(me=>be(me,p));x[m]=void 0!==x[m]?[].concat(x[m],F):F};default:return(m,I,x)=>{x[m]=void 0!==x[m]?[].concat(x[m],I):I}}}(b),I=Object.create(null);if("string"!=typeof p||!(p=p.trim().replace(/^[?#&]/,"")))return I;for(const x of p.split("&")){if(""===x)continue;let[z,F]=We(b.decode?x.replace(/\+/g," "):x,"=");F=void 0===F?null:["comma","separator","bracket-separator"].includes(b.arrayFormat)?F:be(F,b),m(be(z,b),F,I)}for(const x of Object.keys(I)){const z=I[x];if("object"==typeof z&&null!==z)for(const F of Object.keys(z))z[F]=Re(z[F],b);else I[x]=Re(z,b)}return!1===b.sort?I:(!0===b.sort?Object.keys(I).sort():Object.keys(I).sort(b.sort)).reduce((x,z)=>{const F=I[z];return x[z]=Boolean(F)&&"object"==typeof F&&!Array.isArray(F)?Te(F):F,x},Object.create(null))}D.extract=ge,D.parse=Ce,D.stringify=(p,b)=>{if(!p)return"";he((b=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},b)).arrayFormatSeparator);const m=F=>b.skipNull&&(p=>null==p)(p[F])||b.skipEmptyString&&""===p[F],I=function(p){switch(p.arrayFormat){case"index":return b=>(m,I)=>{const x=m.length;return void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,[$(b,p),"[",x,"]"].join("")]:[...m,[$(b,p),"[",$(x,p),"]=",$(I,p)].join("")]};case"bracket":return b=>(m,I)=>void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,[$(b,p),"[]"].join("")]:[...m,[$(b,p),"[]=",$(I,p)].join("")];case"colon-list-separator":return b=>(m,I)=>void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,[$(b,p),":list="].join("")]:[...m,[$(b,p),":list=",$(I,p)].join("")];case"comma":case"separator":case"bracket-separator":{const b="bracket-separator"===p.arrayFormat?"[]=":"=";return m=>(I,x)=>void 0===x||p.skipNull&&null===x||p.skipEmptyString&&""===x?I:(x=null===x?"":x,0===I.length?[[$(m,p),b,$(x,p)].join("")]:[[I,$(x,p)].join(p.arrayFormatSeparator)])}default:return b=>(m,I)=>void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,$(b,p)]:[...m,[$(b,p),"=",$(I,p)].join("")]}}(b),x={};for(const F of Object.keys(p))m(F)||(x[F]=p[F]);const z=Object.keys(x);return!1!==b.sort&&z.sort(b.sort),z.map(F=>{const me=p[F];return void 0===me?"":null===me?$(F,b):Array.isArray(me)?0===me.length&&"bracket-separator"===b.arrayFormat?$(F,b)+"[]":me.reduce(I(F),[]).join("&"):$(F,b)+"="+$(me,b)}).filter(F=>F.length>0).join("&")},D.parseUrl=(p,b)=>{b=Object.assign({decode:!0},b);const[m,I]=We(p,"#");return Object.assign({url:m.split("?")[0]||"",query:Ce(ge(p),b)},b&&b.parseFragmentIdentifier&&I?{fragmentIdentifier:be(I,b)}:{})},D.stringifyUrl=(p,b)=>{b=Object.assign({encode:!0,strict:!0,[Ve]:!0},b);const m=je(p.url).split("?")[0]||"",I=D.extract(p.url),x=D.parse(I,{sort:!1}),z=Object.assign(x,p.query);let F=D.stringify(z,b);F&&(F=`?${F}`);let me=function(p){let b="";const m=p.indexOf("#");return-1!==m&&(b=p.slice(m)),b}(p.url);return p.fragmentIdentifier&&(me=`#${b[Ve]?$(p.fragmentIdentifier,b):p.fragmentIdentifier}`),`${m}${F}${me}`},D.pick=(p,b,m)=>{m=Object.assign({parseFragmentIdentifier:!0,[Ve]:!1},m);const{url:I,query:x,fragmentIdentifier:z}=D.parseUrl(p,m);return D.stringifyUrl({url:I,query:Ze(x,b),fragmentIdentifier:z},m)},D.exclude=(p,b,m)=>{const I=Array.isArray(b)?x=>!b.includes(x):(x,z)=>!b(x,z);return D.pick(p,I,m)}},45418:(ur,D)=>{function K(Te){let je;return"undefined"!=typeof window&&void 0!==window[Te]&&(je=window[Te]),je}function S(Te){const je=K(Te);if(!je)throw new Error(`${Te} is not defined in Window`);return je}Object.defineProperty(D,"__esModule",{value:!0}),D.getLocalStorage=D.getLocalStorageOrThrow=D.getCrypto=D.getCryptoOrThrow=D.getLocation=D.getLocationOrThrow=D.getNavigator=D.getNavigatorOrThrow=D.getDocument=D.getDocumentOrThrow=D.getFromWindowOrThrow=D.getFromWindow=void 0,D.getFromWindow=K,D.getFromWindowOrThrow=S,D.getDocumentOrThrow=function(){return S("document")},D.getDocument=function(){return K("document")},D.getNavigatorOrThrow=function(){return S("navigator")},D.getNavigator=function(){return K("navigator")},D.getLocationOrThrow=function(){return S("location")},D.getLocation=function(){return K("location")},D.getCryptoOrThrow=function(){return S("crypto")},D.getCrypto=function(){return K("crypto")},D.getLocalStorageOrThrow=function(){return S("localStorage")},D.getLocalStorage=function(){return K("localStorage")}},31846:(ur,D,K)=>{D.D=void 0;const Le=K(45418);D.D=function(){let Ze,xe;try{Ze=Le.getDocumentOrThrow(),xe=Le.getLocationOrThrow()}catch{return null}function Ge(...ge){const Re=Ze.getElementsByTagName("meta");for(let Ce=0;Ce<Re.length;Ce++){const p=Re[Ce],b=["itemprop","property","name"].map(m=>p.getAttribute(m)).filter(m=>!!m&&ge.includes(m));if(b.length&&b){const m=p.getAttribute("content");if(m)return m}}return""}const $=function(){let ge=Ge("name","og:site_name","og:title","twitter:title");return ge||(ge=Ze.title),ge}();return{description:Ge("description","og:description","twitter:description","keywords"),url:xe.origin,icons:function(){const ge=Ze.getElementsByTagName("link"),Re=[];for(let Ce=0;Ce<ge.length;Ce++){const p=ge[Ce],b=p.getAttribute("rel");if(b&&b.toLowerCase().indexOf("icon")>-1){const m=p.getAttribute("href");if(m)if(-1===m.toLowerCase().indexOf("https:")&&-1===m.toLowerCase().indexOf("http:")&&0!==m.indexOf("//")){let I=xe.protocol+"//"+xe.host;if(0===m.indexOf("/"))I+=m;else{const x=xe.pathname.split("/");x.pop(),I+=x.join("/")+"/"+m}Re.push(I)}else 0===m.indexOf("//")?Re.push(xe.protocol+m):Re.push(m)}}return Re}(),name:$}}},34955:(ur,D,K)=>{const S=K(82915),Le=K(65361),We=K(95967),Ze=K(10979),Ve=Symbol("encodeFragmentIdentifier");function he(p){if("string"!=typeof p||1!==p.length)throw new TypeError("arrayFormatSeparator must be single character string")}function $(p,b){return b.encode?b.strict?S(p):encodeURIComponent(p):p}function be(p,b){return b.decode?Le(p):p}function Te(p){return Array.isArray(p)?p.sort():"object"==typeof p?Te(Object.keys(p)).sort((b,m)=>Number(b)-Number(m)).map(b=>p[b]):p}function je(p){const b=p.indexOf("#");return-1!==b&&(p=p.slice(0,b)),p}function ge(p){const b=(p=je(p)).indexOf("?");return-1===b?"":p.slice(b+1)}function Re(p,b){return b.parseNumbers&&!Number.isNaN(Number(p))&&"string"==typeof p&&""!==p.trim()?p=Number(p):b.parseBooleans&&null!==p&&("true"===p.toLowerCase()||"false"===p.toLowerCase())&&(p="true"===p.toLowerCase()),p}function Ce(p,b){he((b=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},b)).arrayFormatSeparator);const m=function(p){let b;switch(p.arrayFormat){case"index":return(m,I,x)=>{b=/\[(\d*)\]$/.exec(m),m=m.replace(/\[\d*\]$/,""),b?(void 0===x[m]&&(x[m]={}),x[m][b[1]]=I):x[m]=I};case"bracket":return(m,I,x)=>{b=/(\[\])$/.exec(m),x[m=m.replace(/\[\]$/,"")]=b?void 0!==x[m]?[].concat(x[m],I):[I]:I};case"colon-list-separator":return(m,I,x)=>{b=/(:list)$/.exec(m),x[m=m.replace(/:list$/,"")]=b?void 0!==x[m]?[].concat(x[m],I):[I]:I};case"comma":case"separator":return(m,I,x)=>{const z="string"==typeof I&&I.includes(p.arrayFormatSeparator),F="string"==typeof I&&!z&&be(I,p).includes(p.arrayFormatSeparator);I=F?be(I,p):I;const me=z||F?I.split(p.arrayFormatSeparator).map(qr=>be(qr,p)):null===I?I:be(I,p);x[m]=me};case"bracket-separator":return(m,I,x)=>{const z=/(\[\])$/.test(m);if(m=m.replace(/\[\]$/,""),!z)return void(x[m]=I&&be(I,p));const F=null===I?[]:I.split(p.arrayFormatSeparator).map(me=>be(me,p));x[m]=void 0!==x[m]?[].concat(x[m],F):F};default:return(m,I,x)=>{x[m]=void 0!==x[m]?[].concat(x[m],I):I}}}(b),I=Object.create(null);if("string"!=typeof p||!(p=p.trim().replace(/^[?#&]/,"")))return I;for(const x of p.split("&")){if(""===x)continue;let[z,F]=We(b.decode?x.replace(/\+/g," "):x,"=");F=void 0===F?null:["comma","separator","bracket-separator"].includes(b.arrayFormat)?F:be(F,b),m(be(z,b),F,I)}for(const x of Object.keys(I)){const z=I[x];if("object"==typeof z&&null!==z)for(const F of Object.keys(z))z[F]=Re(z[F],b);else I[x]=Re(z,b)}return!1===b.sort?I:(!0===b.sort?Object.keys(I).sort():Object.keys(I).sort(b.sort)).reduce((x,z)=>{const F=I[z];return x[z]=Boolean(F)&&"object"==typeof F&&!Array.isArray(F)?Te(F):F,x},Object.create(null))}D.extract=ge,D.parse=Ce,D.stringify=(p,b)=>{if(!p)return"";he((b=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},b)).arrayFormatSeparator);const m=F=>b.skipNull&&(p=>null==p)(p[F])||b.skipEmptyString&&""===p[F],I=function(p){switch(p.arrayFormat){case"index":return b=>(m,I)=>{const x=m.length;return void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,[$(b,p),"[",x,"]"].join("")]:[...m,[$(b,p),"[",$(x,p),"]=",$(I,p)].join("")]};case"bracket":return b=>(m,I)=>void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,[$(b,p),"[]"].join("")]:[...m,[$(b,p),"[]=",$(I,p)].join("")];case"colon-list-separator":return b=>(m,I)=>void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,[$(b,p),":list="].join("")]:[...m,[$(b,p),":list=",$(I,p)].join("")];case"comma":case"separator":case"bracket-separator":{const b="bracket-separator"===p.arrayFormat?"[]=":"=";return m=>(I,x)=>void 0===x||p.skipNull&&null===x||p.skipEmptyString&&""===x?I:(x=null===x?"":x,0===I.length?[[$(m,p),b,$(x,p)].join("")]:[[I,$(x,p)].join(p.arrayFormatSeparator)])}default:return b=>(m,I)=>void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,$(b,p)]:[...m,[$(b,p),"=",$(I,p)].join("")]}}(b),x={};for(const F of Object.keys(p))m(F)||(x[F]=p[F]);const z=Object.keys(x);return!1!==b.sort&&z.sort(b.sort),z.map(F=>{const me=p[F];return void 0===me?"":null===me?$(F,b):Array.isArray(me)?0===me.length&&"bracket-separator"===b.arrayFormat?$(F,b)+"[]":me.reduce(I(F),[]).join("&"):$(F,b)+"="+$(me,b)}).filter(F=>F.length>0).join("&")},D.parseUrl=(p,b)=>{b=Object.assign({decode:!0},b);const[m,I]=We(p,"#");return Object.assign({url:m.split("?")[0]||"",query:Ce(ge(p),b)},b&&b.parseFragmentIdentifier&&I?{fragmentIdentifier:be(I,b)}:{})},D.stringifyUrl=(p,b)=>{b=Object.assign({encode:!0,strict:!0,[Ve]:!0},b);const m=je(p.url).split("?")[0]||"",I=D.extract(p.url),x=D.parse(I,{sort:!1}),z=Object.assign(x,p.query);let F=D.stringify(z,b);F&&(F=`?${F}`);let me=function(p){let b="";const m=p.indexOf("#");return-1!==m&&(b=p.slice(m)),b}(p.url);return p.fragmentIdentifier&&(me=`#${b[Ve]?$(p.fragmentIdentifier,b):p.fragmentIdentifier}`),`${m}${F}${me}`},D.pick=(p,b,m)=>{m=Object.assign({parseFragmentIdentifier:!0,[Ve]:!1},m);const{url:I,query:x,fragmentIdentifier:z}=D.parseUrl(p,m);return D.stringifyUrl({url:I,query:Ze(x,b),fragmentIdentifier:z},m)},D.exclude=(p,b,m)=>{const I=Array.isArray(b)?x=>!b.includes(x):(x,z)=>!b(x,z);return D.pick(p,I,m)}},7092:(ur,D)=>{function K(Te){let je;return"undefined"!=typeof window&&void 0!==window[Te]&&(je=window[Te]),je}function S(Te){const je=K(Te);if(!je)throw new Error(`${Te} is not defined in Window`);return je}Object.defineProperty(D,"__esModule",{value:!0}),D.getLocalStorage=D.getLocalStorageOrThrow=D.getCrypto=D.getCryptoOrThrow=D.getLocation=D.getLocationOrThrow=D.getNavigator=D.getNavigatorOrThrow=D.getDocument=D.getDocumentOrThrow=D.getFromWindowOrThrow=D.getFromWindow=void 0,D.getFromWindow=K,D.getFromWindowOrThrow=S,D.getDocumentOrThrow=function(){return S("document")},D.getDocument=function(){return K("document")},D.getNavigatorOrThrow=function(){return S("navigator")},D.getNavigator=function(){return K("navigator")},D.getLocationOrThrow=function(){return S("location")},D.getLocation=function(){return K("location")},D.getCryptoOrThrow=function(){return S("crypto")},D.getCrypto=function(){return K("crypto")},D.getLocalStorageOrThrow=function(){return S("localStorage")},D.getLocalStorage=function(){return K("localStorage")}},47274:(ur,D,K)=>{K(7092)},49290:(ur,D,K)=>{const S=K(82915),Le=K(65361),We=K(95967),Ze=K(10979),Ve=Symbol("encodeFragmentIdentifier");function he(p){if("string"!=typeof p||1!==p.length)throw new TypeError("arrayFormatSeparator must be single character string")}function $(p,b){return b.encode?b.strict?S(p):encodeURIComponent(p):p}function be(p,b){return b.decode?Le(p):p}function Te(p){return Array.isArray(p)?p.sort():"object"==typeof p?Te(Object.keys(p)).sort((b,m)=>Number(b)-Number(m)).map(b=>p[b]):p}function je(p){const b=p.indexOf("#");return-1!==b&&(p=p.slice(0,b)),p}function ge(p){const b=(p=je(p)).indexOf("?");return-1===b?"":p.slice(b+1)}function Re(p,b){return b.parseNumbers&&!Number.isNaN(Number(p))&&"string"==typeof p&&""!==p.trim()?p=Number(p):b.parseBooleans&&null!==p&&("true"===p.toLowerCase()||"false"===p.toLowerCase())&&(p="true"===p.toLowerCase()),p}function Ce(p,b){he((b=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},b)).arrayFormatSeparator);const m=function(p){let b;switch(p.arrayFormat){case"index":return(m,I,x)=>{b=/\[(\d*)\]$/.exec(m),m=m.replace(/\[\d*\]$/,""),b?(void 0===x[m]&&(x[m]={}),x[m][b[1]]=I):x[m]=I};case"bracket":return(m,I,x)=>{b=/(\[\])$/.exec(m),x[m=m.replace(/\[\]$/,"")]=b?void 0!==x[m]?[].concat(x[m],I):[I]:I};case"colon-list-separator":return(m,I,x)=>{b=/(:list)$/.exec(m),x[m=m.replace(/:list$/,"")]=b?void 0!==x[m]?[].concat(x[m],I):[I]:I};case"comma":case"separator":return(m,I,x)=>{const z="string"==typeof I&&I.includes(p.arrayFormatSeparator),F="string"==typeof I&&!z&&be(I,p).includes(p.arrayFormatSeparator);I=F?be(I,p):I;const me=z||F?I.split(p.arrayFormatSeparator).map(qr=>be(qr,p)):null===I?I:be(I,p);x[m]=me};case"bracket-separator":return(m,I,x)=>{const z=/(\[\])$/.test(m);if(m=m.replace(/\[\]$/,""),!z)return void(x[m]=I&&be(I,p));const F=null===I?[]:I.split(p.arrayFormatSeparator).map(me=>be(me,p));x[m]=void 0!==x[m]?[].concat(x[m],F):F};default:return(m,I,x)=>{x[m]=void 0!==x[m]?[].concat(x[m],I):I}}}(b),I=Object.create(null);if("string"!=typeof p||!(p=p.trim().replace(/^[?#&]/,"")))return I;for(const x of p.split("&")){if(""===x)continue;let[z,F]=We(b.decode?x.replace(/\+/g," "):x,"=");F=void 0===F?null:["comma","separator","bracket-separator"].includes(b.arrayFormat)?F:be(F,b),m(be(z,b),F,I)}for(const x of Object.keys(I)){const z=I[x];if("object"==typeof z&&null!==z)for(const F of Object.keys(z))z[F]=Re(z[F],b);else I[x]=Re(z,b)}return!1===b.sort?I:(!0===b.sort?Object.keys(I).sort():Object.keys(I).sort(b.sort)).reduce((x,z)=>{const F=I[z];return x[z]=Boolean(F)&&"object"==typeof F&&!Array.isArray(F)?Te(F):F,x},Object.create(null))}D.extract=ge,D.parse=Ce,D.stringify=(p,b)=>{if(!p)return"";he((b=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},b)).arrayFormatSeparator);const m=F=>b.skipNull&&(p=>null==p)(p[F])||b.skipEmptyString&&""===p[F],I=function(p){switch(p.arrayFormat){case"index":return b=>(m,I)=>{const x=m.length;return void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,[$(b,p),"[",x,"]"].join("")]:[...m,[$(b,p),"[",$(x,p),"]=",$(I,p)].join("")]};case"bracket":return b=>(m,I)=>void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,[$(b,p),"[]"].join("")]:[...m,[$(b,p),"[]=",$(I,p)].join("")];case"colon-list-separator":return b=>(m,I)=>void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,[$(b,p),":list="].join("")]:[...m,[$(b,p),":list=",$(I,p)].join("")];case"comma":case"separator":case"bracket-separator":{const b="bracket-separator"===p.arrayFormat?"[]=":"=";return m=>(I,x)=>void 0===x||p.skipNull&&null===x||p.skipEmptyString&&""===x?I:(x=null===x?"":x,0===I.length?[[$(m,p),b,$(x,p)].join("")]:[[I,$(x,p)].join(p.arrayFormatSeparator)])}default:return b=>(m,I)=>void 0===I||p.skipNull&&null===I||p.skipEmptyString&&""===I?m:null===I?[...m,$(b,p)]:[...m,[$(b,p),"=",$(I,p)].join("")]}}(b),x={};for(const F of Object.keys(p))m(F)||(x[F]=p[F]);const z=Object.keys(x);return!1!==b.sort&&z.sort(b.sort),z.map(F=>{const me=p[F];return void 0===me?"":null===me?$(F,b):Array.isArray(me)?0===me.length&&"bracket-separator"===b.arrayFormat?$(F,b)+"[]":me.reduce(I(F),[]).join("&"):$(F,b)+"="+$(me,b)}).filter(F=>F.length>0).join("&")},D.parseUrl=(p,b)=>{b=Object.assign({decode:!0},b);const[m,I]=We(p,"#");return Object.assign({url:m.split("?")[0]||"",query:Ce(ge(p),b)},b&&b.parseFragmentIdentifier&&I?{fragmentIdentifier:be(I,b)}:{})},D.stringifyUrl=(p,b)=>{b=Object.assign({encode:!0,strict:!0,[Ve]:!0},b);const m=je(p.url).split("?")[0]||"",I=D.extract(p.url),x=D.parse(I,{sort:!1}),z=Object.assign(x,p.query);let F=D.stringify(z,b);F&&(F=`?${F}`);let me=function(p){let b="";const m=p.indexOf("#");return-1!==m&&(b=p.slice(m)),b}(p.url);return p.fragmentIdentifier&&(me=`#${b[Ve]?$(p.fragmentIdentifier,b):p.fragmentIdentifier}`),`${m}${F}${me}`},D.pick=(p,b,m)=>{m=Object.assign({parseFragmentIdentifier:!0,[Ve]:!1},m);const{url:I,query:x,fragmentIdentifier:z}=D.parseUrl(p,m);return D.stringifyUrl({url:I,query:Ze(x,b),fragmentIdentifier:z},m)},D.exclude=(p,b,m)=>{const I=Array.isArray(b)?x=>!b.includes(x):(x,z)=>!b(x,z);return D.pick(p,I,m)}}}]);