@wormhole-foundation/wormhole-connect 2.4.0-beta.2-development → 2.4.0-beta.3-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/assets/{aptos-C2a0dQjT.js → aptos-BaxuZv2A.js} +2 -2
  2. package/dist/assets/{ccip-OC0Vc4gm.js → ccip-Br2IvhSW.js} +1 -1
  3. package/dist/assets/{evm-BqmuByVY.js → evm-CEkHuuN5.js} +3 -3
  4. package/dist/assets/{evm-DVLSeRFU.js → evm-DajrgWJp.js} +2 -2
  5. package/dist/assets/{index-BeEE7MyN.js → index-B8SSPOGN.js} +1 -1
  6. package/dist/assets/{index-CODUkWzQ.js → index-BGgxsbk4.js} +1 -1
  7. package/dist/assets/{index-iO-U9jSW.js → index-BIKKjy76.js} +2 -2
  8. package/dist/assets/{index-CB3XpWtg.js → index-BWKZaYh0.js} +1 -1
  9. package/dist/assets/{index-CvqWMPrS.js → index-BxMnYxyf.js} +1 -1
  10. package/dist/assets/{index-PnI0Le4b.js → index-CIIbEJG8.js} +1 -1
  11. package/dist/assets/{index-BIdhtTCf.js → index-D1RqQWR4.js} +1 -1
  12. package/dist/assets/{index-BVlgnsQb.js → index-DVzhMXXA.js} +1 -1
  13. package/dist/assets/{index-COKaKwn8.js → index-DnDUIJZk.js} +1 -1
  14. package/dist/assets/{index-Dcsj5S2N.js → index-DwbsyLxo.js} +1 -1
  15. package/dist/assets/index-GDpnrg5w.js +1 -0
  16. package/dist/assets/{index-M4NDMEge.js → index-ICy6eYwP.js} +1 -1
  17. package/dist/assets/{index-C1Dta-NJ.js → index-Zgbd9ue1.js} +1 -1
  18. package/dist/assets/{index-BZDxvV4g.js → index-ndTMsj-g.js} +1 -1
  19. package/dist/assets/{index-CBMmMx3W.js → index-ylKZk0sO.js} +1 -1
  20. package/dist/assets/{index-C-kVvSEJ.js → index-z2SBICrL.js} +1 -1
  21. package/dist/assets/{index.es-j8vEfzbO.js → index.es-AACkekVm.js} +6 -6
  22. package/dist/assets/{solana-pOvS3swt.js → solana-Cli5bij_.js} +2 -2
  23. package/dist/assets/solana-DlYSFsGk.js +2 -0
  24. package/dist/assets/solanaEmbed.esm-P5uPPwsm.js +37 -0
  25. package/dist/assets/{sui-DZhbOaP_.js → sui-76yNbUUP.js} +2 -2
  26. package/dist/main.js +114 -114
  27. package/lib/{aptos-DnLzj1Pw.js → aptos-CSvcKEJm.js} +1 -1
  28. package/lib/{aptos-UMYBfX-e.mjs → aptos-D3RPZgif.mjs} +5 -5
  29. package/lib/{aptos-BFg97d8i.js → aptos-WpCc6eOD.js} +2 -2
  30. package/lib/{aptos-BPPKNPmY.mjs → aptos-cEXzuL5b.mjs} +2 -2
  31. package/lib/{base64-dhNbNdy2.js → base64-C73YLbqA.js} +1 -1
  32. package/lib/{base64-BxOseFtQ.mjs → base64-D3sIs-fw.mjs} +1 -1
  33. package/lib/{ccip-Cc7zIRbR.mjs → ccip-BJTawxQ_.mjs} +1 -1
  34. package/lib/{ccip-DnuA-mnD.js → ccip-CaksatNz.js} +1 -1
  35. package/lib/{chunk-IMTC3J2M-DmAiw2IO.js → chunk-IMTC3J2M-DKXvnM6O.js} +1 -1
  36. package/lib/{chunk-IMTC3J2M-C3XVaTOx.mjs → chunk-IMTC3J2M-Dsnj4Vih.mjs} +3 -3
  37. package/lib/{evm-2u0XA9Kv.mjs → evm-Bs0OjXvE.mjs} +5 -5
  38. package/lib/{evm-DBg_gIux.js → evm-DNBYBo_p.js} +1 -1
  39. package/lib/{evm-BPMdXFY7.mjs → evm-D_aPV3AL.mjs} +6 -6
  40. package/lib/{evm-jazxlq_v.js → evm-Wv2nh7z1.js} +3 -3
  41. package/lib/{index-BEqeue2k.js → index--95bwciz.js} +1 -1
  42. package/lib/{index-DYo59dOt.mjs → index-9pPnVz73.mjs} +2 -2
  43. package/lib/{index-DrYmbAqE.mjs → index-B2VBT3u7.mjs} +2 -2
  44. package/lib/{index-CvO9BKU8.js → index-BCrWCNUq.js} +1 -1
  45. package/lib/{index-B9gGuUKR.js → index-BH-EfOl1.js} +1 -1
  46. package/lib/{index-_Tjd635F.js → index-BZpnoMd1.js} +1 -1
  47. package/lib/{index-DpL4G1gV.js → index-BeGnKztN.js} +1 -1
  48. package/lib/{index-cibSzunr.mjs → index-BpKxYGa-.mjs} +2 -2
  49. package/lib/{index-C_8uENxB.js → index-BrFIzqtL.js} +1 -1
  50. package/lib/{index-CLSG0-PT.mjs → index-BtA_-iXv.mjs} +2 -2
  51. package/lib/{index-BZO8YmLX.js → index-BvdMRpl6.js} +1 -1
  52. package/lib/{index-BH5x8knT.mjs → index-Bx5QNYj7.mjs} +1 -1
  53. package/lib/{index-BZijFWem.js → index-Bzn58Yhp.js} +1 -1
  54. package/lib/{index-C7jR2tws.js → index-C5rfYL4K.js} +1 -1
  55. package/lib/{index-DSVsrZrI.js → index-C6Hp_1yF.js} +1 -1
  56. package/lib/{index-geFlOFCr.js → index-CMw2Uill.js} +1 -1
  57. package/lib/{index-CLqF0DXs.mjs → index-COqO8I1C.mjs} +1 -1
  58. package/lib/{index-ndWybTXw.mjs → index-CUMRJ8yy.mjs} +10142 -9468
  59. package/lib/{index-B71D5i2u.js → index-CUSJAO56.js} +1 -1
  60. package/lib/{index-Ce7gKFw8.js → index-Cb51fnZM.js} +1 -1
  61. package/lib/{index-BH-QrHNF.mjs → index-CcEA2K6Q.mjs} +1 -1
  62. package/lib/{index-D6PJJHPq.mjs → index-Ci0LEPmE.mjs} +2 -2
  63. package/lib/{index-gsKAo8iZ.js → index-CjgM-0OC.js} +1 -1
  64. package/lib/{index-C0mg2EaP.js → index-Cvtp4dgE.js} +120 -120
  65. package/lib/{index-DxHy5H3l.mjs → index-D0NbpzAg.mjs} +1 -1
  66. package/lib/{index-DBF3Orza.mjs → index-D19OP8Mu.mjs} +2 -2
  67. package/lib/{index-CwnW1iXz.js → index-D7f2-3wk.js} +1 -1
  68. package/lib/{index-BudY-hBZ.js → index-DCRe22Ms.js} +1 -1
  69. package/lib/{index-INXKBIVC.mjs → index-DGGMUOzp.mjs} +3 -3
  70. package/lib/{index-BhZP5awL.js → index-DIqG9W_r.js} +1 -1
  71. package/lib/{index-DqPgH3Y4.js → index-DLeUCqIq.js} +1 -1
  72. package/lib/{index-CyPQH2yv.js → index-DNBuc7tl.js} +1 -1
  73. package/lib/{index-C2ecpt8K.mjs → index-DRMwoM8a.mjs} +4 -4
  74. package/lib/{index-B6Sz2PUf.mjs → index-DRYbBPuh.mjs} +2 -2
  75. package/lib/{index-Dw6DmujE.mjs → index-DS_rORqD.mjs} +1 -1
  76. package/lib/{index-DbgMQX1m.mjs → index-DYrT7_2n.mjs} +1 -1
  77. package/lib/{index-C7SwBJ74.mjs → index-DfPjBy3w.mjs} +1 -1
  78. package/lib/{index-BbuYs0Vv.mjs → index-DqRhhSXa.mjs} +2 -2
  79. package/lib/{index-CVVdam36.mjs → index-DwhWt2Jt.mjs} +1 -1
  80. package/lib/{index-Cleh-XCA.mjs → index-KpBoUsX2.mjs} +1 -1
  81. package/lib/{index-3LktUEbt.js → index-ZK1P1tUH.js} +1 -1
  82. package/lib/{index-CrDmkPiL.mjs → index-ctEY-xjJ.mjs} +3 -3
  83. package/lib/{index-DCXyETk0.mjs → index-e3oHdOB4.mjs} +1 -1
  84. package/lib/{index-CSWNAyvZ.mjs → index-q570DLLo.mjs} +2 -2
  85. package/lib/{index-CiFOveV0.js → index-tzTI5R9c.js} +1 -1
  86. package/lib/{index-DS1ZxkfX.js → index-v-_ti7Rn.js} +1 -1
  87. package/lib/{index.es-DaqXRV0H.mjs → index.es-By1LsNow.mjs} +5 -5
  88. package/lib/{index.es-D-KoMtU-.js → index.es-Czhf3Th8.js} +2 -2
  89. package/lib/index.js +1 -1
  90. package/lib/index.mjs +1 -1
  91. package/lib/{signer-CGCrqc_x.mjs → signer-CcpDR9mm.mjs} +1 -1
  92. package/lib/{signer-Cr8jlyL3.js → signer-jV9Ixq8U.js} +1 -1
  93. package/lib/{solana-BkE0Vobm.js → solana-4YAkIi-J.js} +1 -1
  94. package/lib/{solana-YmPJnJBl.mjs → solana-Bo2aMvX4.mjs} +4 -4
  95. package/lib/solana-DA02fWu7.mjs +17 -0
  96. package/lib/solana-DVFk6Z5q.js +1 -0
  97. package/lib/{solanaEmbed.esm-QawbC8eJ.mjs → solanaEmbed.esm-4CS_00aM.mjs} +1 -1
  98. package/lib/{solanaEmbed.esm-LQoue5a0.js → solanaEmbed.esm-B-rprhcd.js} +1 -1
  99. package/lib/{sui-BwFJqgyM.mjs → sui-BGaWik82.mjs} +1 -1
  100. package/lib/{sui-DZg5qrE0.js → sui-BgD7gx67.js} +1 -1
  101. package/lib/{sui-C88m3bWr.mjs → sui-DLOfqNsy.mjs} +5 -5
  102. package/lib/{sui-CIDA-hM_.js → sui-MorjdPyy.js} +1 -1
  103. package/package.json +5 -5
  104. package/dist/assets/events-7fnqQH7x.js +0 -1
  105. package/dist/assets/index-n50xdA-U.js +0 -1
  106. package/dist/assets/solana-D-pftkkJ.js +0 -2
  107. package/dist/assets/solanaEmbed.esm-DPIgn-PE.js +0 -37
  108. package/lib/solana-Bq3a7vGW.mjs +0 -17
  109. package/lib/solana-Bw-7Gaje.js +0 -1
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BfryJIfK.js","main.js","main.css"])))=>i.map(i=>d[i]);
2
- import{br as Ao,bs as Ow,i as ee,j as Rw,_ as $w}from"../main.js";import{e as gt,s as Do}from"./events-7fnqQH7x.js";import{s as qo,x as kh,r as zh,H as Nw,c as Hh,q as Ss}from"./evm-BqmuByVY.js";import{c as q}from"./index-DvKDhWs8.js";import{I as ur,f as dt,t as nt,c as $u,C as Cw,d as Tw,r as xw,a as Ar,g as Vh,i as bt,b as Ns,e as Nu,h as Aw,j as Dw,k as Cs,p as Kh,T as Ts,l as xs,E as ze,m as qw,y as Qe,P as Cu,Q as jw,n as Uw,o as jo,q as As,s as Wt,_ as Mw,u as Lw,v as Tu}from"./index-LX0nX22N.js";import{o as xu}from"./browser-ponyfill-BT2q7JIC.js";var se={};Object.defineProperty(se,"__esModule",{value:!0});se.getLocalStorage=se.getLocalStorageOrThrow=se.getCrypto=se.getCryptoOrThrow=se.getLocation=se.getLocationOrThrow=se.getNavigator=se.getNavigatorOrThrow=se.getDocument=se.getDocumentOrThrow=se.getFromWindowOrThrow=se.getFromWindow=void 0;function hr(a){let t;return typeof window<"u"&&typeof window[a]<"u"&&(t=window[a]),t}se.getFromWindow=hr;function jr(a){const t=hr(a);if(!t)throw new Error(`${a} is not defined in Window`);return t}se.getFromWindowOrThrow=jr;function kw(){return jr("document")}se.getDocumentOrThrow=kw;function zw(){return hr("document")}se.getDocument=zw;function Hw(){return jr("navigator")}se.getNavigatorOrThrow=Hw;function Vw(){return hr("navigator")}se.getNavigator=Vw;function Kw(){return jr("location")}se.getLocationOrThrow=Kw;function Fw(){return hr("location")}se.getLocation=Fw;function Ww(){return jr("crypto")}se.getCryptoOrThrow=Ww;function Bw(){return hr("crypto")}se.getCrypto=Bw;function Gw(){return jr("localStorage")}se.getLocalStorageOrThrow=Gw;function Qw(){return hr("localStorage")}se.getLocalStorage=Qw;var Uo={};Object.defineProperty(Uo,"__esModule",{value:!0});Uo.getWindowMetadata=void 0;const Au=se;function Jw(){let a,t;try{a=Au.getDocumentOrThrow(),t=Au.getLocationOrThrow()}catch{return null}function r(){const S=a.getElementsByTagName("link"),R=[];for(let j=0;j<S.length;j++){const x=S[j],K=x.getAttribute("rel");if(K&&K.toLowerCase().indexOf("icon")>-1){const A=x.getAttribute("href");if(A)if(A.toLowerCase().indexOf("https:")===-1&&A.toLowerCase().indexOf("http:")===-1&&A.indexOf("//")!==0){let G=t.protocol+"//"+t.host;if(A.indexOf("/")===0)G+=A;else{const pe=t.pathname.split("/");pe.pop();const J=pe.join("/");G+=J+"/"+A}R.push(G)}else if(A.indexOf("//")===0){const G=t.protocol+A;R.push(G)}else R.push(A)}}return R}function s(...S){const R=a.getElementsByTagName("meta");for(let j=0;j<R.length;j++){const x=R[j],K=["itemprop","property","name"].map(A=>x.getAttribute(A)).filter(A=>A?S.includes(A):!1);if(K.length&&K){const A=x.getAttribute("content");if(A)return A}}return""}function o(){let S=s("name","og:site_name","og:title","twitter:title");return S||(S=a.title),S}function u(){return s("description","og:description","twitter:description","keywords")}const l=o(),g=u(),w=t.origin,b=r();return{description:g,url:w,icons:b,name:l}}Uo.getWindowMetadata=Jw;function Yw(a,t=[]){const r=[];return Object.keys(a).forEach(s=>{if(t.length&&!t.includes(s))return;const o=a[s];r.push(...o.accounts)}),r}const Zw={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 Xw(a,t){const{message:r,code:s}=Zw[a];return{message:r,code:s}}function wo(a,t){return!!Array.isArray(a)}var Ur={};/*! *****************************************************************************
2
+ import{br as Ao,bs as ot,i as ee,j as Ow,bt as Do,_ as Rw}from"../main.js";import{s as qo,x as kh,r as zh,H as $w,c as Hh,q as Ss}from"./evm-CEkHuuN5.js";import{c as q}from"./index-DvKDhWs8.js";import{I as ur,f as gt,t as nt,c as $u,C as Nw,d as Cw,r as Tw,a as Ar,g as Vh,i as bt,b as Ns,e as Nu,h as xw,j as Aw,k as Cs,p as Kh,T as Ts,l as xs,E as ze,m as Dw,y as Qe,P as Cu,Q as qw,n as jw,o as jo,q as As,s as Wt,_ as Uw,u as Mw,v as Tu}from"./index-LX0nX22N.js";import{o as xu}from"./browser-ponyfill-BT2q7JIC.js";var se={};Object.defineProperty(se,"__esModule",{value:!0});se.getLocalStorage=se.getLocalStorageOrThrow=se.getCrypto=se.getCryptoOrThrow=se.getLocation=se.getLocationOrThrow=se.getNavigator=se.getNavigatorOrThrow=se.getDocument=se.getDocumentOrThrow=se.getFromWindowOrThrow=se.getFromWindow=void 0;function hr(a){let t;return typeof window<"u"&&typeof window[a]<"u"&&(t=window[a]),t}se.getFromWindow=hr;function jr(a){const t=hr(a);if(!t)throw new Error(`${a} is not defined in Window`);return t}se.getFromWindowOrThrow=jr;function Lw(){return jr("document")}se.getDocumentOrThrow=Lw;function kw(){return hr("document")}se.getDocument=kw;function zw(){return jr("navigator")}se.getNavigatorOrThrow=zw;function Hw(){return hr("navigator")}se.getNavigator=Hw;function Vw(){return jr("location")}se.getLocationOrThrow=Vw;function Kw(){return hr("location")}se.getLocation=Kw;function Fw(){return jr("crypto")}se.getCryptoOrThrow=Fw;function Ww(){return hr("crypto")}se.getCrypto=Ww;function Bw(){return jr("localStorage")}se.getLocalStorageOrThrow=Bw;function Gw(){return hr("localStorage")}se.getLocalStorage=Gw;var Uo={};Object.defineProperty(Uo,"__esModule",{value:!0});Uo.getWindowMetadata=void 0;const Au=se;function Qw(){let a,t;try{a=Au.getDocumentOrThrow(),t=Au.getLocationOrThrow()}catch{return null}function r(){const S=a.getElementsByTagName("link"),R=[];for(let j=0;j<S.length;j++){const x=S[j],K=x.getAttribute("rel");if(K&&K.toLowerCase().indexOf("icon")>-1){const A=x.getAttribute("href");if(A)if(A.toLowerCase().indexOf("https:")===-1&&A.toLowerCase().indexOf("http:")===-1&&A.indexOf("//")!==0){let G=t.protocol+"//"+t.host;if(A.indexOf("/")===0)G+=A;else{const pe=t.pathname.split("/");pe.pop();const J=pe.join("/");G+=J+"/"+A}R.push(G)}else if(A.indexOf("//")===0){const G=t.protocol+A;R.push(G)}else R.push(A)}}return R}function s(...S){const R=a.getElementsByTagName("meta");for(let j=0;j<R.length;j++){const x=R[j],K=["itemprop","property","name"].map(A=>x.getAttribute(A)).filter(A=>A?S.includes(A):!1);if(K.length&&K){const A=x.getAttribute("content");if(A)return A}}return""}function o(){let S=s("name","og:site_name","og:title","twitter:title");return S||(S=a.title),S}function u(){return s("description","og:description","twitter:description","keywords")}const l=o(),g=u(),w=t.origin,b=r();return{description:g,url:w,icons:b,name:l}}Uo.getWindowMetadata=Qw;function Jw(a,t=[]){const r=[];return Object.keys(a).forEach(s=>{if(t.length&&!t.includes(s))return;const o=a[s];r.push(...o.accounts)}),r}const Yw={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 Zw(a,t){const{message:r,code:s}=Yw[a];return{message:r,code:s}}function wo(a,t){return!!Array.isArray(a)}var Ur={};/*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
@@ -12,22 +12,22 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var _o=function(a,t){return _o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)s.hasOwnProperty(o)&&(r[o]=s[o])},_o(a,t)};function e_(a,t){_o(a,t);function r(){this.constructor=a}a.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var bo=function(){return bo=Object.assign||function(t){for(var r,s=1,o=arguments.length;s<o;s++){r=arguments[s];for(var u in r)Object.prototype.hasOwnProperty.call(r,u)&&(t[u]=r[u])}return t},bo.apply(this,arguments)};function t_(a,t){var r={};for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&t.indexOf(s)<0&&(r[s]=a[s]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(a);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(a,s[o])&&(r[s[o]]=a[s[o]]);return r}function r_(a,t,r,s){var o=arguments.length,u=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(a,t,r,s);else for(var g=a.length-1;g>=0;g--)(l=a[g])&&(u=(o<3?l(u):o>3?l(t,r,u):l(t,r))||u);return o>3&&u&&Object.defineProperty(t,r,u),u}function i_(a,t){return function(r,s){t(r,s,a)}}function s_(a,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,t)}function n_(a,t,r,s){function o(u){return u instanceof r?u:new r(function(l){l(u)})}return new(r||(r=Promise))(function(u,l){function g($){try{b(s.next($))}catch(S){l(S)}}function w($){try{b(s.throw($))}catch(S){l(S)}}function b($){$.done?u($.value):o($.value).then(g,w)}b((s=s.apply(a,t||[])).next())})}function o_(a,t){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},s,o,u,l;return l={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function g(b){return function($){return w([b,$])}}function w(b){if(s)throw new TypeError("Generator is already executing.");for(;r;)try{if(s=1,o&&(u=b[0]&2?o.return:b[0]?o.throw||((u=o.return)&&u.call(o),0):o.next)&&!(u=u.call(o,b[1])).done)return u;switch(o=0,u&&(b=[b[0]&2,u.value]),b[0]){case 0:case 1:u=b;break;case 4:return r.label++,{value:b[1],done:!1};case 5:r.label++,o=b[1],b=[0];continue;case 7:b=r.ops.pop(),r.trys.pop();continue;default:if(u=r.trys,!(u=u.length>0&&u[u.length-1])&&(b[0]===6||b[0]===2)){r=0;continue}if(b[0]===3&&(!u||b[1]>u[0]&&b[1]<u[3])){r.label=b[1];break}if(b[0]===6&&r.label<u[1]){r.label=u[1],u=b;break}if(u&&r.label<u[2]){r.label=u[2],r.ops.push(b);break}u[2]&&r.ops.pop(),r.trys.pop();continue}b=t.call(a,r)}catch($){b=[6,$],o=0}finally{s=u=0}if(b[0]&5)throw b[1];return{value:b[0]?b[1]:void 0,done:!0}}}function a_(a,t,r,s){s===void 0&&(s=r),a[s]=t[r]}function c_(a,t){for(var r in a)r!=="default"&&!t.hasOwnProperty(r)&&(t[r]=a[r])}function Eo(a){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&a[t],s=0;if(r)return r.call(a);if(a&&typeof a.length=="number")return{next:function(){return a&&s>=a.length&&(a=void 0),{value:a&&a[s++],done:!a}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Fh(a,t){var r=typeof Symbol=="function"&&a[Symbol.iterator];if(!r)return a;var s=r.call(a),o,u=[],l;try{for(;(t===void 0||t-- >0)&&!(o=s.next()).done;)u.push(o.value)}catch(g){l={error:g}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(l)throw l.error}}return u}function u_(){for(var a=[],t=0;t<arguments.length;t++)a=a.concat(Fh(arguments[t]));return a}function h_(){for(var a=0,t=0,r=arguments.length;t<r;t++)a+=arguments[t].length;for(var s=Array(a),o=0,t=0;t<r;t++)for(var u=arguments[t],l=0,g=u.length;l<g;l++,o++)s[o]=u[l];return s}function _i(a){return this instanceof _i?(this.v=a,this):new _i(a)}function l_(a,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(a,t||[]),o,u=[];return o={},l("next"),l("throw"),l("return"),o[Symbol.asyncIterator]=function(){return this},o;function l(R){s[R]&&(o[R]=function(j){return new Promise(function(x,K){u.push([R,j,x,K])>1||g(R,j)})})}function g(R,j){try{w(s[R](j))}catch(x){S(u[0][3],x)}}function w(R){R.value instanceof _i?Promise.resolve(R.value.v).then(b,$):S(u[0][2],R)}function b(R){g("next",R)}function $(R){g("throw",R)}function S(R,j){R(j),u.shift(),u.length&&g(u[0][0],u[0][1])}}function p_(a){var t,r;return t={},s("next"),s("throw",function(o){throw o}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(o,u){t[o]=a[o]?function(l){return(r=!r)?{value:_i(a[o](l)),done:o==="return"}:u?u(l):l}:u}}function f_(a){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=a[Symbol.asyncIterator],r;return t?t.call(a):(a=typeof Eo=="function"?Eo(a):a[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(u){r[u]=a[u]&&function(l){return new Promise(function(g,w){l=a[u](l),o(g,w,l.done,l.value)})}}function o(u,l,g,w){Promise.resolve(w).then(function(b){u({value:b,done:g})},l)}}function d_(a,t){return Object.defineProperty?Object.defineProperty(a,"raw",{value:t}):a.raw=t,a}function g_(a){if(a&&a.__esModule)return a;var t={};if(a!=null)for(var r in a)Object.hasOwnProperty.call(a,r)&&(t[r]=a[r]);return t.default=a,t}function y_(a){return a&&a.__esModule?a:{default:a}}function v_(a,t){if(!t.has(a))throw new TypeError("attempted to get private field on non-instance");return t.get(a)}function m_(a,t,r){if(!t.has(a))throw new TypeError("attempted to set private field on non-instance");return t.set(a,r),r}const w_=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return bo},__asyncDelegator:p_,__asyncGenerator:l_,__asyncValues:f_,__await:_i,__awaiter:n_,__classPrivateFieldGet:v_,__classPrivateFieldSet:m_,__createBinding:a_,__decorate:r_,__exportStar:c_,__extends:e_,__generator:o_,__importDefault:y_,__importStar:g_,__makeTemplateObject:d_,__metadata:s_,__param:i_,__read:Fh,__rest:t_,__spread:u_,__spreadArrays:h_,__values:Eo},Symbol.toStringTag,{value:"Module"})),Ds=Ao(w_);var hi={},no={},li={};const __=Object.freeze(Object.defineProperty({__proto__:null,IEvents:ur},Symbol.toStringTag,{value:"Module"})),b_=Ao(__);var Du;function E_(){if(Du)return li;Du=1,Object.defineProperty(li,"__esModule",{value:!0}),li.IHeartBeat=void 0;const a=b_;class t extends a.IEvents{constructor(s){super()}}return li.IHeartBeat=t,li}var qu;function Wh(){return qu||(qu=1,function(a){Object.defineProperty(a,"__esModule",{value:!0}),Ds.__exportStar(E_(),a)}(no)),no}var oo={},or={},ju;function I_(){if(ju)return or;ju=1,Object.defineProperty(or,"__esModule",{value:!0}),or.HEARTBEAT_EVENTS=or.HEARTBEAT_INTERVAL=void 0;const a=q;return or.HEARTBEAT_INTERVAL=a.FIVE_SECONDS,or.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},or}var Uu;function Bh(){return Uu||(Uu=1,function(a){Object.defineProperty(a,"__esModule",{value:!0}),Ds.__exportStar(I_(),a)}(oo)),oo}var Mu;function P_(){if(Mu)return hi;Mu=1,Object.defineProperty(hi,"__esModule",{value:!0}),hi.HeartBeat=void 0;const a=Ds,t=Ow(),r=q,s=Wh(),o=Bh();class u extends s.IHeartBeat{constructor(g){super(g),this.events=new t.EventEmitter,this.interval=o.HEARTBEAT_INTERVAL,this.interval=(g==null?void 0:g.interval)||o.HEARTBEAT_INTERVAL}static init(g){return a.__awaiter(this,void 0,void 0,function*(){const w=new u(g);return yield w.init(),w})}init(){return a.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(g,w){this.events.on(g,w)}once(g,w){this.events.once(g,w)}off(g,w){this.events.off(g,w)}removeListener(g,w){this.events.removeListener(g,w)}initialize(){return a.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(o.HEARTBEAT_EVENTS.pulse)}}return hi.HeartBeat=u,hi}(function(a){Object.defineProperty(a,"__esModule",{value:!0});const t=Ds;t.__exportStar(P_(),a),t.__exportStar(Wh(),a),t.__exportStar(Bh(),a)})(Ur);class S_ extends ur{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}}let O_=class extends ur{constructor(t,r){super(),this.core=t,this.logger=r,this.records=new Map}},R_=class{constructor(t,r){this.logger=t,this.core=r}},$_=class extends ur{constructor(t,r){super(),this.relayer=t,this.logger=r}},N_=class extends ur{constructor(t){super()}},C_=class{constructor(t,r,s,o){this.core=t,this.logger=r,this.name=s}},T_=class extends ur{constructor(t,r){super(),this.relayer=t,this.logger=r}},x_=class extends ur{constructor(t,r){super(),this.core=t,this.logger=r}},A_=class{constructor(t,r){this.projectId=t,this.logger=r}},D_=class{constructor(t,r){this.projectId=t,this.logger=r}},q_=class{constructor(t){this.opts=t,this.protocol="wc",this.version=2}},j_=class{constructor(t){this.client=t}};const U_=a=>JSON.stringify(a,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),M_=a=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=a.replace(t,'$1"$2n"$3');return JSON.parse(r,(s,o)=>typeof o=="string"&&o.match(/^\d+n$/)?BigInt(o.substring(0,o.length-1)):o)};function Gh(a){if(typeof a!="string")throw new Error(`Cannot safe json parse value of type ${typeof a}`);try{return M_(a)}catch{return a}}function Qh(a){return typeof a=="string"?a:U_(a)||""}var ne={};Object.defineProperty(ne,"__esModule",{value:!0});ne.getLocalStorage=ne.getLocalStorageOrThrow=ne.getCrypto=ne.getCryptoOrThrow=Jh=ne.getLocation=ne.getLocationOrThrow=Lo=ne.getNavigator=ne.getNavigatorOrThrow=Mo=ne.getDocument=ne.getDocumentOrThrow=ne.getFromWindowOrThrow=ne.getFromWindow=void 0;function lr(a){let t;return typeof window<"u"&&typeof window[a]<"u"&&(t=window[a]),t}ne.getFromWindow=lr;function Mr(a){const t=lr(a);if(!t)throw new Error(`${a} is not defined in Window`);return t}ne.getFromWindowOrThrow=Mr;function L_(){return Mr("document")}ne.getDocumentOrThrow=L_;function k_(){return lr("document")}var Mo=ne.getDocument=k_;function z_(){return Mr("navigator")}ne.getNavigatorOrThrow=z_;function H_(){return lr("navigator")}var Lo=ne.getNavigator=H_;function V_(){return Mr("location")}ne.getLocationOrThrow=V_;function K_(){return lr("location")}var Jh=ne.getLocation=K_;function F_(){return Mr("crypto")}ne.getCryptoOrThrow=F_;function W_(){return lr("crypto")}ne.getCrypto=W_;function B_(){return Mr("localStorage")}ne.getLocalStorageOrThrow=B_;function G_(){return lr("localStorage")}ne.getLocalStorage=G_;var ko={};Object.defineProperty(ko,"__esModule",{value:!0});var Yh=ko.getWindowMetadata=void 0;const Lu=ne;function Q_(){let a,t;try{a=Lu.getDocumentOrThrow(),t=Lu.getLocationOrThrow()}catch{return null}function r(){const S=a.getElementsByTagName("link"),R=[];for(let j=0;j<S.length;j++){const x=S[j],K=x.getAttribute("rel");if(K&&K.toLowerCase().indexOf("icon")>-1){const A=x.getAttribute("href");if(A)if(A.toLowerCase().indexOf("https:")===-1&&A.toLowerCase().indexOf("http:")===-1&&A.indexOf("//")!==0){let G=t.protocol+"//"+t.host;if(A.indexOf("/")===0)G+=A;else{const pe=t.pathname.split("/");pe.pop();const J=pe.join("/");G+=J+"/"+A}R.push(G)}else if(A.indexOf("//")===0){const G=t.protocol+A;R.push(G)}else R.push(A)}}return R}function s(...S){const R=a.getElementsByTagName("meta");for(let j=0;j<R.length;j++){const x=R[j],K=["itemprop","property","name"].map(A=>x.getAttribute(A)).filter(A=>A?S.includes(A):!1);if(K.length&&K){const A=x.getAttribute("content");if(A)return A}}return""}function o(){let S=s("name","og:site_name","og:title","twitter:title");return S||(S=a.title),S}function u(){return s("description","og:description","twitter:description","keywords")}const l=o(),g=u(),w=t.origin,b=r();return{description:g,url:w,icons:b,name:l}}Yh=ko.getWindowMetadata=Q_;const J_=":";function Y_(a){const[t,r]=a.split(J_);return{namespace:t,reference:r}}function Zh(a,t){return a.includes(":")?[a]:t.chains||[]}const Xh="base10",Ae="base16",Io="base64pad",zo="utf8",el=0,pr=1,Z_=0,ku=1,Po=12,Ho=32;function X_(){const a=kh.generateKeyPair();return{privateKey:nt(a.secretKey,Ae),publicKey:nt(a.publicKey,Ae)}}function So(){const a=zh.randomBytes(Ho);return nt(a,Ae)}function eb(a,t){const r=kh.sharedKey(dt(a,Ae),dt(t,Ae),!0),s=new Nw(qo.SHA256,r).expand(Ho);return nt(s,Ae)}function tb(a){const t=qo.hash(dt(a,Ae));return nt(t,Ae)}function Dr(a){const t=qo.hash(dt(a,zo));return nt(t,Ae)}function rb(a){return dt(`${a}`,Xh)}function Ei(a){return Number(nt(a,Xh))}function ib(a){const t=rb(typeof a.type<"u"?a.type:el);if(Ei(t)===pr&&typeof a.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof a.senderPublicKey<"u"?dt(a.senderPublicKey,Ae):void 0,s=typeof a.iv<"u"?dt(a.iv,Ae):zh.randomBytes(Po),o=new Hh.ChaCha20Poly1305(dt(a.symKey,Ae)).seal(s,dt(a.message,zo));return nb({type:t,sealed:o,iv:s,senderPublicKey:r})}function sb(a){const t=new Hh.ChaCha20Poly1305(dt(a.symKey,Ae)),{sealed:r,iv:s}=Os(a.encoded),o=t.open(s,r);if(o===null)throw new Error("Failed to decrypt");return nt(o,zo)}function nb(a){if(Ei(a.type)===pr){if(typeof a.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return nt($u([a.type,a.senderPublicKey,a.iv,a.sealed]),Io)}return nt($u([a.type,a.iv,a.sealed]),Io)}function Os(a){const t=dt(a,Io),r=t.slice(Z_,ku),s=ku;if(Ei(r)===pr){const g=s+Ho,w=g+Po,b=t.slice(s,g),$=t.slice(g,w),S=t.slice(w);return{type:r,sealed:S,iv:$,senderPublicKey:b}}const o=s+Po,u=t.slice(s,o),l=t.slice(o);return{type:r,sealed:l,iv:u}}function ob(a,t){const r=Os(a);return tl({type:Ei(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?nt(r.senderPublicKey,Ae):void 0,receiverPublicKey:t==null?void 0:t.receiverPublicKey})}function tl(a){const t=(a==null?void 0:a.type)||el;if(t===pr){if(typeof(a==null?void 0:a.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(a==null?void 0:a.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:a==null?void 0:a.senderPublicKey,receiverPublicKey:a==null?void 0:a.receiverPublicKey}}function zu(a){return a.type===pr&&typeof a.senderPublicKey=="string"&&typeof a.receiverPublicKey=="string"}var ab=Object.defineProperty,Hu=Object.getOwnPropertySymbols,cb=Object.prototype.hasOwnProperty,ub=Object.prototype.propertyIsEnumerable,Vu=(a,t,r)=>t in a?ab(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Ku=(a,t)=>{for(var r in t||(t={}))cb.call(t,r)&&Vu(a,r,t[r]);if(Hu)for(var r of Hu(t))ub.call(t,r)&&Vu(a,r,t[r]);return a};const hb="ReactNative",Ge={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},lb="js";function Vo(){return typeof ee.process<"u"&&typeof ee.process.versions<"u"&&typeof ee.process.versions.node<"u"}function Lr(){return!Mo()&&!!Lo()&&navigator.product===hb}function kr(){return!Vo()&&!!Lo()&&!!Mo()}function Ii(){return Lr()?Ge.reactNative:Vo()?Ge.node:kr()?Ge.browser:Ge.unknown}function pb(){var a;try{return Lr()&&typeof ee.global<"u"&&typeof(ee.global==null?void 0:ee.global.Application)<"u"?(a=ee.global.Application)==null?void 0:a.applicationId:void 0}catch{return}}function fb(a,t){let r=Ss.parse(a);return r=Ku(Ku({},r),t),a=Ss.stringify(r),a}function db(){return Yh()||{name:"",description:"",url:"",icons:[""]}}function gb(){if(Ii()===Ge.reactNative&&typeof ee.global<"u"&&typeof(ee.global==null?void 0:ee.global.Platform)<"u"){const{OS:r,Version:s}=ee.global.Platform;return[r,s].join("-")}const a=Tw();if(a===null)return"unknown";const t=a.os?a.os.replace(" ","").toLowerCase():"unknown";return a.type==="browser"?[t,a.name,a.version].join("-"):[t,a.version].join("-")}function yb(){var a;const t=Ii();return t===Ge.browser?[t,((a=Jh())==null?void 0:a.host)||"unknown"].join(":"):t}function vb(a,t,r){const s=gb(),o=yb();return[[a,t].join("-"),[lb,r].join("-"),s,o].join("/")}function mb({protocol:a,version:t,relayUrl:r,sdkVersion:s,auth:o,projectId:u,useOnCloseEvent:l,bundleId:g}){const w=r.split("?"),b=vb(a,t,s),$={auth:o,ua:b,projectId:u,useOnCloseEvent:l,origin:g||void 0},S=fb(w[1]||"",$);return w[0]+"?"+S}function ar(a,t){return a.filter(r=>t.includes(r)).length===a.length}function rl(a){return Object.fromEntries(a.entries())}function il(a){return new Map(Object.entries(a))}function Tr(a=q.FIVE_MINUTES,t){const r=q.toMiliseconds(a||q.FIVE_MINUTES);let s,o,u;return{resolve:l=>{u&&s&&(clearTimeout(u),s(l))},reject:l=>{u&&o&&(clearTimeout(u),o(l))},done:()=>new Promise((l,g)=>{u=setTimeout(()=>{g(new Error(t))},r),s=l,o=g})}}function bi(a,t,r){return new Promise(async(s,o)=>{const u=setTimeout(()=>o(new Error(r)),t);try{const l=await a;s(l)}catch(l){o(l)}clearTimeout(u)})}function sl(a,t){if(typeof t=="string"&&t.startsWith(`${a}:`))return t;if(a.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(a.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${a}`)}function wb(a){return sl("topic",a)}function _b(a){return sl("id",a)}function nl(a){const[t,r]=a.split(":"),s={id:void 0,topic:void 0};if(t==="topic"&&typeof r=="string")s.topic=r;else if(t==="id"&&Number.isInteger(Number(r)))s.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);return s}function ft(a,t){return q.fromMiliseconds(Date.now()+q.toMiliseconds(a))}function Bt(a){return Date.now()>=q.toMiliseconds(a)}function ve(a,t){return`${a}${t?`:${t}`:""}`}function ao(a=[],t=[]){return[...new Set([...a,...t])]}async function bb({id:a,topic:t,wcDeepLink:r}){try{if(!r)return;const s=typeof r=="string"?JSON.parse(r):r;let o=s==null?void 0:s.href;if(typeof o!="string")return;o.endsWith("/")&&(o=o.slice(0,-1));const u=`${o}/wc?requestId=${a}&sessionTopic=${t}`,l=Ii();l===Ge.browser?u.startsWith("https://")?window.open(u,"_blank","noreferrer noopener"):window.open(u,"_self","noreferrer noopener"):l===Ge.reactNative&&typeof(ee.global==null?void 0:ee.global.Linking)<"u"&&await ee.global.Linking.openURL(u)}catch(s){console.error(s)}}async function Eb(a,t){try{return await a.getItem(t)||(kr()?localStorage.getItem(t):void 0)}catch(r){console.error(r)}}const Ib="irn";function Oo(a){return(a==null?void 0:a.relay)||{protocol:Ib}}function Is(a){const t=Cw[a];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${a}`);return t}var Pb=Object.defineProperty,Fu=Object.getOwnPropertySymbols,Sb=Object.prototype.hasOwnProperty,Ob=Object.prototype.propertyIsEnumerable,Wu=(a,t,r)=>t in a?Pb(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Rb=(a,t)=>{for(var r in t||(t={}))Sb.call(t,r)&&Wu(a,r,t[r]);if(Fu)for(var r of Fu(t))Ob.call(t,r)&&Wu(a,r,t[r]);return a};function $b(a,t="-"){const r={},s="relay"+t;return Object.keys(a).forEach(o=>{if(o.startsWith(s)){const u=o.replace(s,""),l=a[o];r[u]=l}}),r}function Bu(a){a=a.includes("wc://")?a.replace("wc://",""):a,a=a.includes("wc:")?a.replace("wc:",""):a;const t=a.indexOf(":"),r=a.indexOf("?")!==-1?a.indexOf("?"):void 0,s=a.substring(0,t),o=a.substring(t+1,r).split("@"),u=typeof r<"u"?a.substring(r):"",l=Ss.parse(u);return{protocol:s,topic:Nb(o[0]),version:parseInt(o[1],10),symKey:l.symKey,relay:$b(l)}}function Nb(a){return a.startsWith("//")?a.substring(2):a}function Cb(a,t="-"){const r="relay",s={};return Object.keys(a).forEach(o=>{const u=r+t+o;a[o]&&(s[u]=a[o])}),s}function Tb(a){return`${a.protocol}:${a.topic}@${a.version}?`+Ss.stringify(Rb({symKey:a.symKey},Cb(a.relay)))}function zr(a){const t=[];return a.forEach(r=>{const[s,o]=r.split(":");t.push(`${s}:${o}`)}),t}function xb(a){const t=[];return Object.values(a).forEach(r=>{t.push(...zr(r.accounts))}),t}function Ab(a,t){const r=[];return Object.values(a).forEach(s=>{zr(s.accounts).includes(t)&&r.push(...s.methods)}),r}function Db(a,t){const r=[];return Object.values(a).forEach(s=>{zr(s.accounts).includes(t)&&r.push(...s.events)}),r}function qb(a,t){const r=Ps(a,t);if(r)throw new Error(r.message);const s={};for(const[o,u]of Object.entries(a))s[o]={methods:u.methods,events:u.events,chains:u.accounts.map(l=>`${l.split(":")[0]}:${l.split(":")[1]}`)};return s}function Ko(a){return a.includes(":")}function vi(a){return Ko(a)?a.split(":")[0]:a}const jb={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}},Ub={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 N(a,t){const{message:r,code:s}=Ub[a];return{message:t?`${r} ${t}`:r,code:s}}function ye(a,t){const{message:r,code:s}=jb[a];return{message:t?`${r} ${t}`:r,code:s}}function cr(a,t){return!!Array.isArray(a)}function qr(a){return Object.getPrototypeOf(a)===Object.prototype&&Object.keys(a).length}function xe(a){return typeof a>"u"}function be(a,t){return t&&xe(a)?!0:typeof a=="string"&&!!a.trim().length}function Fo(a,t){return t&&xe(a)?!0:typeof a=="number"&&!isNaN(a)}function Mb(a,t){const{requiredNamespaces:r}=t,s=Object.keys(a.namespaces),o=Object.keys(r);let u=!0;return ar(o,s)?(s.forEach(l=>{const{accounts:g,methods:w,events:b}=a.namespaces[l],$=zr(g),S=r[l];(!ar(Zh(l,S),$)||!ar(S.methods,w)||!ar(S.events,b))&&(u=!1)}),u):!1}function Rs(a){return be(a,!1)&&a.includes(":")?a.split(":").length===2:!1}function Lb(a){if(be(a,!1)&&a.includes(":")){const t=a.split(":");if(t.length===3){const r=t[0]+":"+t[1];return!!t[2]&&Rs(r)}}return!1}function kb(a){if(be(a,!1))try{return typeof new URL(a)<"u"}catch{return!1}return!1}function zb(a){var t;return(t=a==null?void 0:a.proposer)==null?void 0:t.publicKey}function Hb(a){return a==null?void 0:a.topic}function Vb(a,t){let r=null;return be(a==null?void 0:a.publicKey,!1)||(r=N("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}function Gu(a){let t=!0;return cr(a)?a.length&&(t=a.every(r=>be(r,!1))):t=!1,t}function Kb(a,t,r){let s=null;return cr(t)&&t.length?t.forEach(o=>{s||Rs(o)||(s=ye("UNSUPPORTED_CHAINS",`${r}, chain ${o} should be a string and conform to "namespace:chainId" format`))}):Rs(a)||(s=ye("UNSUPPORTED_CHAINS",`${r}, 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"] }`)),s}function Fb(a,t,r){let s=null;return Object.entries(a).forEach(([o,u])=>{if(s)return;const l=Kb(o,Zh(o,u),`${t} ${r}`);l&&(s=l)}),s}function Wb(a,t){let r=null;return cr(a)?a.forEach(s=>{r||Lb(s)||(r=ye("UNSUPPORTED_ACCOUNTS",`${t}, account ${s} should be a string and conform to "namespace:chainId:address" format`))}):r=ye("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Bb(a,t){let r=null;return Object.values(a).forEach(s=>{if(r)return;const o=Wb(s==null?void 0:s.accounts,`${t} namespace`);o&&(r=o)}),r}function Gb(a,t){let r=null;return Gu(a==null?void 0:a.methods)?Gu(a==null?void 0:a.events)||(r=ye("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=ye("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}function ol(a,t){let r=null;return Object.values(a).forEach(s=>{if(r)return;const o=Gb(s,`${t}, namespace`);o&&(r=o)}),r}function Qb(a,t,r){let s=null;if(a&&qr(a)){const o=ol(a,t);o&&(s=o);const u=Fb(a,t,r);u&&(s=u)}else s=N("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return s}function Ps(a,t){let r=null;if(a&&qr(a)){const s=ol(a,t);s&&(r=s);const o=Bb(a,t);o&&(r=o)}else r=N("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function al(a){return be(a.protocol,!0)}function Jb(a,t){let r=!1;return a?a&&cr(a)&&a.length&&a.forEach(s=>{r=al(s)}):r=!0,r}function Yb(a){return typeof a=="number"}function ke(a){return typeof a<"u"&&typeof a!==null}function Zb(a){return!(!a||typeof a!="object"||!a.code||!Fo(a.code,!1)||!a.message||!be(a.message,!1))}function Xb(a){return!(xe(a)||!be(a.method,!1))}function e0(a){return!(xe(a)||xe(a.result)&&xe(a.error)||!Fo(a.id,!1)||!be(a.jsonrpc,!1))}function t0(a){return!(xe(a)||!be(a.name,!1))}function Qu(a,t){return!(!Rs(t)||!xb(a).includes(t))}function r0(a,t,r){return be(r,!1)?Ab(a,t).includes(r):!1}function i0(a,t,r){return be(r,!1)?Db(a,t).includes(r):!1}function Ju(a,t,r){let s=null;const o=s0(a),u=n0(t),l=Object.keys(o),g=Object.keys(u),w=Yu(Object.keys(a)),b=Yu(Object.keys(t)),$=w.filter(S=>!b.includes(S));return $.length&&(s=N("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
15
+ ***************************************************************************** */var _o=function(a,t){return _o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)s.hasOwnProperty(o)&&(r[o]=s[o])},_o(a,t)};function Xw(a,t){_o(a,t);function r(){this.constructor=a}a.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var bo=function(){return bo=Object.assign||function(t){for(var r,s=1,o=arguments.length;s<o;s++){r=arguments[s];for(var u in r)Object.prototype.hasOwnProperty.call(r,u)&&(t[u]=r[u])}return t},bo.apply(this,arguments)};function e_(a,t){var r={};for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&t.indexOf(s)<0&&(r[s]=a[s]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(a);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(a,s[o])&&(r[s[o]]=a[s[o]]);return r}function t_(a,t,r,s){var o=arguments.length,u=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(a,t,r,s);else for(var g=a.length-1;g>=0;g--)(l=a[g])&&(u=(o<3?l(u):o>3?l(t,r,u):l(t,r))||u);return o>3&&u&&Object.defineProperty(t,r,u),u}function r_(a,t){return function(r,s){t(r,s,a)}}function i_(a,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,t)}function s_(a,t,r,s){function o(u){return u instanceof r?u:new r(function(l){l(u)})}return new(r||(r=Promise))(function(u,l){function g($){try{b(s.next($))}catch(S){l(S)}}function w($){try{b(s.throw($))}catch(S){l(S)}}function b($){$.done?u($.value):o($.value).then(g,w)}b((s=s.apply(a,t||[])).next())})}function n_(a,t){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},s,o,u,l;return l={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function g(b){return function($){return w([b,$])}}function w(b){if(s)throw new TypeError("Generator is already executing.");for(;r;)try{if(s=1,o&&(u=b[0]&2?o.return:b[0]?o.throw||((u=o.return)&&u.call(o),0):o.next)&&!(u=u.call(o,b[1])).done)return u;switch(o=0,u&&(b=[b[0]&2,u.value]),b[0]){case 0:case 1:u=b;break;case 4:return r.label++,{value:b[1],done:!1};case 5:r.label++,o=b[1],b=[0];continue;case 7:b=r.ops.pop(),r.trys.pop();continue;default:if(u=r.trys,!(u=u.length>0&&u[u.length-1])&&(b[0]===6||b[0]===2)){r=0;continue}if(b[0]===3&&(!u||b[1]>u[0]&&b[1]<u[3])){r.label=b[1];break}if(b[0]===6&&r.label<u[1]){r.label=u[1],u=b;break}if(u&&r.label<u[2]){r.label=u[2],r.ops.push(b);break}u[2]&&r.ops.pop(),r.trys.pop();continue}b=t.call(a,r)}catch($){b=[6,$],o=0}finally{s=u=0}if(b[0]&5)throw b[1];return{value:b[0]?b[1]:void 0,done:!0}}}function o_(a,t,r,s){s===void 0&&(s=r),a[s]=t[r]}function a_(a,t){for(var r in a)r!=="default"&&!t.hasOwnProperty(r)&&(t[r]=a[r])}function Eo(a){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&a[t],s=0;if(r)return r.call(a);if(a&&typeof a.length=="number")return{next:function(){return a&&s>=a.length&&(a=void 0),{value:a&&a[s++],done:!a}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Fh(a,t){var r=typeof Symbol=="function"&&a[Symbol.iterator];if(!r)return a;var s=r.call(a),o,u=[],l;try{for(;(t===void 0||t-- >0)&&!(o=s.next()).done;)u.push(o.value)}catch(g){l={error:g}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(l)throw l.error}}return u}function c_(){for(var a=[],t=0;t<arguments.length;t++)a=a.concat(Fh(arguments[t]));return a}function u_(){for(var a=0,t=0,r=arguments.length;t<r;t++)a+=arguments[t].length;for(var s=Array(a),o=0,t=0;t<r;t++)for(var u=arguments[t],l=0,g=u.length;l<g;l++,o++)s[o]=u[l];return s}function _i(a){return this instanceof _i?(this.v=a,this):new _i(a)}function h_(a,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(a,t||[]),o,u=[];return o={},l("next"),l("throw"),l("return"),o[Symbol.asyncIterator]=function(){return this},o;function l(R){s[R]&&(o[R]=function(j){return new Promise(function(x,K){u.push([R,j,x,K])>1||g(R,j)})})}function g(R,j){try{w(s[R](j))}catch(x){S(u[0][3],x)}}function w(R){R.value instanceof _i?Promise.resolve(R.value.v).then(b,$):S(u[0][2],R)}function b(R){g("next",R)}function $(R){g("throw",R)}function S(R,j){R(j),u.shift(),u.length&&g(u[0][0],u[0][1])}}function l_(a){var t,r;return t={},s("next"),s("throw",function(o){throw o}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(o,u){t[o]=a[o]?function(l){return(r=!r)?{value:_i(a[o](l)),done:o==="return"}:u?u(l):l}:u}}function p_(a){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=a[Symbol.asyncIterator],r;return t?t.call(a):(a=typeof Eo=="function"?Eo(a):a[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(u){r[u]=a[u]&&function(l){return new Promise(function(g,w){l=a[u](l),o(g,w,l.done,l.value)})}}function o(u,l,g,w){Promise.resolve(w).then(function(b){u({value:b,done:g})},l)}}function f_(a,t){return Object.defineProperty?Object.defineProperty(a,"raw",{value:t}):a.raw=t,a}function d_(a){if(a&&a.__esModule)return a;var t={};if(a!=null)for(var r in a)Object.hasOwnProperty.call(a,r)&&(t[r]=a[r]);return t.default=a,t}function g_(a){return a&&a.__esModule?a:{default:a}}function y_(a,t){if(!t.has(a))throw new TypeError("attempted to get private field on non-instance");return t.get(a)}function v_(a,t,r){if(!t.has(a))throw new TypeError("attempted to set private field on non-instance");return t.set(a,r),r}const m_=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return bo},__asyncDelegator:l_,__asyncGenerator:h_,__asyncValues:p_,__await:_i,__awaiter:s_,__classPrivateFieldGet:y_,__classPrivateFieldSet:v_,__createBinding:o_,__decorate:t_,__exportStar:a_,__extends:Xw,__generator:n_,__importDefault:g_,__importStar:d_,__makeTemplateObject:f_,__metadata:i_,__param:r_,__read:Fh,__rest:e_,__spread:c_,__spreadArrays:u_,__values:Eo},Symbol.toStringTag,{value:"Module"})),Ds=Ao(m_);var hi={},no={},li={};const w_=Object.freeze(Object.defineProperty({__proto__:null,IEvents:ur},Symbol.toStringTag,{value:"Module"})),__=Ao(w_);var Du;function b_(){if(Du)return li;Du=1,Object.defineProperty(li,"__esModule",{value:!0}),li.IHeartBeat=void 0;const a=__;class t extends a.IEvents{constructor(s){super()}}return li.IHeartBeat=t,li}var qu;function Wh(){return qu||(qu=1,function(a){Object.defineProperty(a,"__esModule",{value:!0}),Ds.__exportStar(b_(),a)}(no)),no}var oo={},or={},ju;function E_(){if(ju)return or;ju=1,Object.defineProperty(or,"__esModule",{value:!0}),or.HEARTBEAT_EVENTS=or.HEARTBEAT_INTERVAL=void 0;const a=q;return or.HEARTBEAT_INTERVAL=a.FIVE_SECONDS,or.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},or}var Uu;function Bh(){return Uu||(Uu=1,function(a){Object.defineProperty(a,"__esModule",{value:!0}),Ds.__exportStar(E_(),a)}(oo)),oo}var Mu;function I_(){if(Mu)return hi;Mu=1,Object.defineProperty(hi,"__esModule",{value:!0}),hi.HeartBeat=void 0;const a=Ds,t=ot,r=q,s=Wh(),o=Bh();class u extends s.IHeartBeat{constructor(g){super(g),this.events=new t.EventEmitter,this.interval=o.HEARTBEAT_INTERVAL,this.interval=(g==null?void 0:g.interval)||o.HEARTBEAT_INTERVAL}static init(g){return a.__awaiter(this,void 0,void 0,function*(){const w=new u(g);return yield w.init(),w})}init(){return a.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(g,w){this.events.on(g,w)}once(g,w){this.events.once(g,w)}off(g,w){this.events.off(g,w)}removeListener(g,w){this.events.removeListener(g,w)}initialize(){return a.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(o.HEARTBEAT_EVENTS.pulse)}}return hi.HeartBeat=u,hi}(function(a){Object.defineProperty(a,"__esModule",{value:!0});const t=Ds;t.__exportStar(I_(),a),t.__exportStar(Wh(),a),t.__exportStar(Bh(),a)})(Ur);class P_ extends ur{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}}let S_=class extends ur{constructor(t,r){super(),this.core=t,this.logger=r,this.records=new Map}},O_=class{constructor(t,r){this.logger=t,this.core=r}},R_=class extends ur{constructor(t,r){super(),this.relayer=t,this.logger=r}},$_=class extends ur{constructor(t){super()}},N_=class{constructor(t,r,s,o){this.core=t,this.logger=r,this.name=s}},C_=class extends ur{constructor(t,r){super(),this.relayer=t,this.logger=r}},T_=class extends ur{constructor(t,r){super(),this.core=t,this.logger=r}},x_=class{constructor(t,r){this.projectId=t,this.logger=r}},A_=class{constructor(t,r){this.projectId=t,this.logger=r}},D_=class{constructor(t){this.opts=t,this.protocol="wc",this.version=2}},q_=class{constructor(t){this.client=t}};const j_=a=>JSON.stringify(a,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),U_=a=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=a.replace(t,'$1"$2n"$3');return JSON.parse(r,(s,o)=>typeof o=="string"&&o.match(/^\d+n$/)?BigInt(o.substring(0,o.length-1)):o)};function Gh(a){if(typeof a!="string")throw new Error(`Cannot safe json parse value of type ${typeof a}`);try{return U_(a)}catch{return a}}function Qh(a){return typeof a=="string"?a:j_(a)||""}var ne={};Object.defineProperty(ne,"__esModule",{value:!0});ne.getLocalStorage=ne.getLocalStorageOrThrow=ne.getCrypto=ne.getCryptoOrThrow=Jh=ne.getLocation=ne.getLocationOrThrow=Lo=ne.getNavigator=ne.getNavigatorOrThrow=Mo=ne.getDocument=ne.getDocumentOrThrow=ne.getFromWindowOrThrow=ne.getFromWindow=void 0;function lr(a){let t;return typeof window<"u"&&typeof window[a]<"u"&&(t=window[a]),t}ne.getFromWindow=lr;function Mr(a){const t=lr(a);if(!t)throw new Error(`${a} is not defined in Window`);return t}ne.getFromWindowOrThrow=Mr;function M_(){return Mr("document")}ne.getDocumentOrThrow=M_;function L_(){return lr("document")}var Mo=ne.getDocument=L_;function k_(){return Mr("navigator")}ne.getNavigatorOrThrow=k_;function z_(){return lr("navigator")}var Lo=ne.getNavigator=z_;function H_(){return Mr("location")}ne.getLocationOrThrow=H_;function V_(){return lr("location")}var Jh=ne.getLocation=V_;function K_(){return Mr("crypto")}ne.getCryptoOrThrow=K_;function F_(){return lr("crypto")}ne.getCrypto=F_;function W_(){return Mr("localStorage")}ne.getLocalStorageOrThrow=W_;function B_(){return lr("localStorage")}ne.getLocalStorage=B_;var ko={};Object.defineProperty(ko,"__esModule",{value:!0});var Yh=ko.getWindowMetadata=void 0;const Lu=ne;function G_(){let a,t;try{a=Lu.getDocumentOrThrow(),t=Lu.getLocationOrThrow()}catch{return null}function r(){const S=a.getElementsByTagName("link"),R=[];for(let j=0;j<S.length;j++){const x=S[j],K=x.getAttribute("rel");if(K&&K.toLowerCase().indexOf("icon")>-1){const A=x.getAttribute("href");if(A)if(A.toLowerCase().indexOf("https:")===-1&&A.toLowerCase().indexOf("http:")===-1&&A.indexOf("//")!==0){let G=t.protocol+"//"+t.host;if(A.indexOf("/")===0)G+=A;else{const pe=t.pathname.split("/");pe.pop();const J=pe.join("/");G+=J+"/"+A}R.push(G)}else if(A.indexOf("//")===0){const G=t.protocol+A;R.push(G)}else R.push(A)}}return R}function s(...S){const R=a.getElementsByTagName("meta");for(let j=0;j<R.length;j++){const x=R[j],K=["itemprop","property","name"].map(A=>x.getAttribute(A)).filter(A=>A?S.includes(A):!1);if(K.length&&K){const A=x.getAttribute("content");if(A)return A}}return""}function o(){let S=s("name","og:site_name","og:title","twitter:title");return S||(S=a.title),S}function u(){return s("description","og:description","twitter:description","keywords")}const l=o(),g=u(),w=t.origin,b=r();return{description:g,url:w,icons:b,name:l}}Yh=ko.getWindowMetadata=G_;const Q_=":";function J_(a){const[t,r]=a.split(Q_);return{namespace:t,reference:r}}function Zh(a,t){return a.includes(":")?[a]:t.chains||[]}const Xh="base10",Ae="base16",Io="base64pad",zo="utf8",el=0,pr=1,Y_=0,ku=1,Po=12,Ho=32;function Z_(){const a=kh.generateKeyPair();return{privateKey:nt(a.secretKey,Ae),publicKey:nt(a.publicKey,Ae)}}function So(){const a=zh.randomBytes(Ho);return nt(a,Ae)}function X_(a,t){const r=kh.sharedKey(gt(a,Ae),gt(t,Ae),!0),s=new $w(qo.SHA256,r).expand(Ho);return nt(s,Ae)}function eb(a){const t=qo.hash(gt(a,Ae));return nt(t,Ae)}function Dr(a){const t=qo.hash(gt(a,zo));return nt(t,Ae)}function tb(a){return gt(`${a}`,Xh)}function Ei(a){return Number(nt(a,Xh))}function rb(a){const t=tb(typeof a.type<"u"?a.type:el);if(Ei(t)===pr&&typeof a.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof a.senderPublicKey<"u"?gt(a.senderPublicKey,Ae):void 0,s=typeof a.iv<"u"?gt(a.iv,Ae):zh.randomBytes(Po),o=new Hh.ChaCha20Poly1305(gt(a.symKey,Ae)).seal(s,gt(a.message,zo));return sb({type:t,sealed:o,iv:s,senderPublicKey:r})}function ib(a){const t=new Hh.ChaCha20Poly1305(gt(a.symKey,Ae)),{sealed:r,iv:s}=Os(a.encoded),o=t.open(s,r);if(o===null)throw new Error("Failed to decrypt");return nt(o,zo)}function sb(a){if(Ei(a.type)===pr){if(typeof a.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return nt($u([a.type,a.senderPublicKey,a.iv,a.sealed]),Io)}return nt($u([a.type,a.iv,a.sealed]),Io)}function Os(a){const t=gt(a,Io),r=t.slice(Y_,ku),s=ku;if(Ei(r)===pr){const g=s+Ho,w=g+Po,b=t.slice(s,g),$=t.slice(g,w),S=t.slice(w);return{type:r,sealed:S,iv:$,senderPublicKey:b}}const o=s+Po,u=t.slice(s,o),l=t.slice(o);return{type:r,sealed:l,iv:u}}function nb(a,t){const r=Os(a);return tl({type:Ei(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?nt(r.senderPublicKey,Ae):void 0,receiverPublicKey:t==null?void 0:t.receiverPublicKey})}function tl(a){const t=(a==null?void 0:a.type)||el;if(t===pr){if(typeof(a==null?void 0:a.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(a==null?void 0:a.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:a==null?void 0:a.senderPublicKey,receiverPublicKey:a==null?void 0:a.receiverPublicKey}}function zu(a){return a.type===pr&&typeof a.senderPublicKey=="string"&&typeof a.receiverPublicKey=="string"}var ob=Object.defineProperty,Hu=Object.getOwnPropertySymbols,ab=Object.prototype.hasOwnProperty,cb=Object.prototype.propertyIsEnumerable,Vu=(a,t,r)=>t in a?ob(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Ku=(a,t)=>{for(var r in t||(t={}))ab.call(t,r)&&Vu(a,r,t[r]);if(Hu)for(var r of Hu(t))cb.call(t,r)&&Vu(a,r,t[r]);return a};const ub="ReactNative",Ge={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},hb="js";function Vo(){return typeof ee.process<"u"&&typeof ee.process.versions<"u"&&typeof ee.process.versions.node<"u"}function Lr(){return!Mo()&&!!Lo()&&navigator.product===ub}function kr(){return!Vo()&&!!Lo()&&!!Mo()}function Ii(){return Lr()?Ge.reactNative:Vo()?Ge.node:kr()?Ge.browser:Ge.unknown}function lb(){var a;try{return Lr()&&typeof ee.global<"u"&&typeof(ee.global==null?void 0:ee.global.Application)<"u"?(a=ee.global.Application)==null?void 0:a.applicationId:void 0}catch{return}}function pb(a,t){let r=Ss.parse(a);return r=Ku(Ku({},r),t),a=Ss.stringify(r),a}function fb(){return Yh()||{name:"",description:"",url:"",icons:[""]}}function db(){if(Ii()===Ge.reactNative&&typeof ee.global<"u"&&typeof(ee.global==null?void 0:ee.global.Platform)<"u"){const{OS:r,Version:s}=ee.global.Platform;return[r,s].join("-")}const a=Cw();if(a===null)return"unknown";const t=a.os?a.os.replace(" ","").toLowerCase():"unknown";return a.type==="browser"?[t,a.name,a.version].join("-"):[t,a.version].join("-")}function gb(){var a;const t=Ii();return t===Ge.browser?[t,((a=Jh())==null?void 0:a.host)||"unknown"].join(":"):t}function yb(a,t,r){const s=db(),o=gb();return[[a,t].join("-"),[hb,r].join("-"),s,o].join("/")}function vb({protocol:a,version:t,relayUrl:r,sdkVersion:s,auth:o,projectId:u,useOnCloseEvent:l,bundleId:g}){const w=r.split("?"),b=yb(a,t,s),$={auth:o,ua:b,projectId:u,useOnCloseEvent:l,origin:g||void 0},S=pb(w[1]||"",$);return w[0]+"?"+S}function ar(a,t){return a.filter(r=>t.includes(r)).length===a.length}function rl(a){return Object.fromEntries(a.entries())}function il(a){return new Map(Object.entries(a))}function Tr(a=q.FIVE_MINUTES,t){const r=q.toMiliseconds(a||q.FIVE_MINUTES);let s,o,u;return{resolve:l=>{u&&s&&(clearTimeout(u),s(l))},reject:l=>{u&&o&&(clearTimeout(u),o(l))},done:()=>new Promise((l,g)=>{u=setTimeout(()=>{g(new Error(t))},r),s=l,o=g})}}function bi(a,t,r){return new Promise(async(s,o)=>{const u=setTimeout(()=>o(new Error(r)),t);try{const l=await a;s(l)}catch(l){o(l)}clearTimeout(u)})}function sl(a,t){if(typeof t=="string"&&t.startsWith(`${a}:`))return t;if(a.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(a.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${a}`)}function mb(a){return sl("topic",a)}function wb(a){return sl("id",a)}function nl(a){const[t,r]=a.split(":"),s={id:void 0,topic:void 0};if(t==="topic"&&typeof r=="string")s.topic=r;else if(t==="id"&&Number.isInteger(Number(r)))s.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);return s}function dt(a,t){return q.fromMiliseconds(Date.now()+q.toMiliseconds(a))}function Bt(a){return Date.now()>=q.toMiliseconds(a)}function ve(a,t){return`${a}${t?`:${t}`:""}`}function ao(a=[],t=[]){return[...new Set([...a,...t])]}async function _b({id:a,topic:t,wcDeepLink:r}){try{if(!r)return;const s=typeof r=="string"?JSON.parse(r):r;let o=s==null?void 0:s.href;if(typeof o!="string")return;o.endsWith("/")&&(o=o.slice(0,-1));const u=`${o}/wc?requestId=${a}&sessionTopic=${t}`,l=Ii();l===Ge.browser?u.startsWith("https://")?window.open(u,"_blank","noreferrer noopener"):window.open(u,"_self","noreferrer noopener"):l===Ge.reactNative&&typeof(ee.global==null?void 0:ee.global.Linking)<"u"&&await ee.global.Linking.openURL(u)}catch(s){console.error(s)}}async function bb(a,t){try{return await a.getItem(t)||(kr()?localStorage.getItem(t):void 0)}catch(r){console.error(r)}}const Eb="irn";function Oo(a){return(a==null?void 0:a.relay)||{protocol:Eb}}function Is(a){const t=Nw[a];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${a}`);return t}var Ib=Object.defineProperty,Fu=Object.getOwnPropertySymbols,Pb=Object.prototype.hasOwnProperty,Sb=Object.prototype.propertyIsEnumerable,Wu=(a,t,r)=>t in a?Ib(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Ob=(a,t)=>{for(var r in t||(t={}))Pb.call(t,r)&&Wu(a,r,t[r]);if(Fu)for(var r of Fu(t))Sb.call(t,r)&&Wu(a,r,t[r]);return a};function Rb(a,t="-"){const r={},s="relay"+t;return Object.keys(a).forEach(o=>{if(o.startsWith(s)){const u=o.replace(s,""),l=a[o];r[u]=l}}),r}function Bu(a){a=a.includes("wc://")?a.replace("wc://",""):a,a=a.includes("wc:")?a.replace("wc:",""):a;const t=a.indexOf(":"),r=a.indexOf("?")!==-1?a.indexOf("?"):void 0,s=a.substring(0,t),o=a.substring(t+1,r).split("@"),u=typeof r<"u"?a.substring(r):"",l=Ss.parse(u);return{protocol:s,topic:$b(o[0]),version:parseInt(o[1],10),symKey:l.symKey,relay:Rb(l)}}function $b(a){return a.startsWith("//")?a.substring(2):a}function Nb(a,t="-"){const r="relay",s={};return Object.keys(a).forEach(o=>{const u=r+t+o;a[o]&&(s[u]=a[o])}),s}function Cb(a){return`${a.protocol}:${a.topic}@${a.version}?`+Ss.stringify(Ob({symKey:a.symKey},Nb(a.relay)))}function zr(a){const t=[];return a.forEach(r=>{const[s,o]=r.split(":");t.push(`${s}:${o}`)}),t}function Tb(a){const t=[];return Object.values(a).forEach(r=>{t.push(...zr(r.accounts))}),t}function xb(a,t){const r=[];return Object.values(a).forEach(s=>{zr(s.accounts).includes(t)&&r.push(...s.methods)}),r}function Ab(a,t){const r=[];return Object.values(a).forEach(s=>{zr(s.accounts).includes(t)&&r.push(...s.events)}),r}function Db(a,t){const r=Ps(a,t);if(r)throw new Error(r.message);const s={};for(const[o,u]of Object.entries(a))s[o]={methods:u.methods,events:u.events,chains:u.accounts.map(l=>`${l.split(":")[0]}:${l.split(":")[1]}`)};return s}function Ko(a){return a.includes(":")}function vi(a){return Ko(a)?a.split(":")[0]:a}const qb={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}},jb={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 N(a,t){const{message:r,code:s}=jb[a];return{message:t?`${r} ${t}`:r,code:s}}function ye(a,t){const{message:r,code:s}=qb[a];return{message:t?`${r} ${t}`:r,code:s}}function cr(a,t){return!!Array.isArray(a)}function qr(a){return Object.getPrototypeOf(a)===Object.prototype&&Object.keys(a).length}function xe(a){return typeof a>"u"}function be(a,t){return t&&xe(a)?!0:typeof a=="string"&&!!a.trim().length}function Fo(a,t){return t&&xe(a)?!0:typeof a=="number"&&!isNaN(a)}function Ub(a,t){const{requiredNamespaces:r}=t,s=Object.keys(a.namespaces),o=Object.keys(r);let u=!0;return ar(o,s)?(s.forEach(l=>{const{accounts:g,methods:w,events:b}=a.namespaces[l],$=zr(g),S=r[l];(!ar(Zh(l,S),$)||!ar(S.methods,w)||!ar(S.events,b))&&(u=!1)}),u):!1}function Rs(a){return be(a,!1)&&a.includes(":")?a.split(":").length===2:!1}function Mb(a){if(be(a,!1)&&a.includes(":")){const t=a.split(":");if(t.length===3){const r=t[0]+":"+t[1];return!!t[2]&&Rs(r)}}return!1}function Lb(a){if(be(a,!1))try{return typeof new URL(a)<"u"}catch{return!1}return!1}function kb(a){var t;return(t=a==null?void 0:a.proposer)==null?void 0:t.publicKey}function zb(a){return a==null?void 0:a.topic}function Hb(a,t){let r=null;return be(a==null?void 0:a.publicKey,!1)||(r=N("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}function Gu(a){let t=!0;return cr(a)?a.length&&(t=a.every(r=>be(r,!1))):t=!1,t}function Vb(a,t,r){let s=null;return cr(t)&&t.length?t.forEach(o=>{s||Rs(o)||(s=ye("UNSUPPORTED_CHAINS",`${r}, chain ${o} should be a string and conform to "namespace:chainId" format`))}):Rs(a)||(s=ye("UNSUPPORTED_CHAINS",`${r}, 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"] }`)),s}function Kb(a,t,r){let s=null;return Object.entries(a).forEach(([o,u])=>{if(s)return;const l=Vb(o,Zh(o,u),`${t} ${r}`);l&&(s=l)}),s}function Fb(a,t){let r=null;return cr(a)?a.forEach(s=>{r||Mb(s)||(r=ye("UNSUPPORTED_ACCOUNTS",`${t}, account ${s} should be a string and conform to "namespace:chainId:address" format`))}):r=ye("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Wb(a,t){let r=null;return Object.values(a).forEach(s=>{if(r)return;const o=Fb(s==null?void 0:s.accounts,`${t} namespace`);o&&(r=o)}),r}function Bb(a,t){let r=null;return Gu(a==null?void 0:a.methods)?Gu(a==null?void 0:a.events)||(r=ye("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=ye("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}function ol(a,t){let r=null;return Object.values(a).forEach(s=>{if(r)return;const o=Bb(s,`${t}, namespace`);o&&(r=o)}),r}function Gb(a,t,r){let s=null;if(a&&qr(a)){const o=ol(a,t);o&&(s=o);const u=Kb(a,t,r);u&&(s=u)}else s=N("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return s}function Ps(a,t){let r=null;if(a&&qr(a)){const s=ol(a,t);s&&(r=s);const o=Wb(a,t);o&&(r=o)}else r=N("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function al(a){return be(a.protocol,!0)}function Qb(a,t){let r=!1;return a?a&&cr(a)&&a.length&&a.forEach(s=>{r=al(s)}):r=!0,r}function Jb(a){return typeof a=="number"}function ke(a){return typeof a<"u"&&typeof a!==null}function Yb(a){return!(!a||typeof a!="object"||!a.code||!Fo(a.code,!1)||!a.message||!be(a.message,!1))}function Zb(a){return!(xe(a)||!be(a.method,!1))}function Xb(a){return!(xe(a)||xe(a.result)&&xe(a.error)||!Fo(a.id,!1)||!be(a.jsonrpc,!1))}function e0(a){return!(xe(a)||!be(a.name,!1))}function Qu(a,t){return!(!Rs(t)||!Tb(a).includes(t))}function t0(a,t,r){return be(r,!1)?xb(a,t).includes(r):!1}function r0(a,t,r){return be(r,!1)?Ab(a,t).includes(r):!1}function Ju(a,t,r){let s=null;const o=i0(a),u=s0(t),l=Object.keys(o),g=Object.keys(u),w=Yu(Object.keys(a)),b=Yu(Object.keys(t)),$=w.filter(S=>!b.includes(S));return $.length&&(s=N("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
16
16
  Required: ${$.toString()}
17
17
  Received: ${Object.keys(t).toString()}`)),ar(l,g)||(s=N("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
18
18
  Required: ${l.toString()}
19
19
  Approved: ${g.toString()}`)),Object.keys(t).forEach(S=>{if(!S.includes(":")||s)return;const R=zr(t[S].accounts);R.includes(S)||(s=N("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${S}
20
20
  Required: ${S}
21
- Approved: ${R.toString()}`))}),l.forEach(S=>{s||(ar(o[S].methods,u[S].methods)?ar(o[S].events,u[S].events)||(s=N("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${S}`)):s=N("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${S}`))}),s}function s0(a){const t={};return Object.keys(a).forEach(r=>{var s;r.includes(":")?t[r]=a[r]:(s=a[r].chains)==null||s.forEach(o=>{t[o]={methods:a[r].methods,events:a[r].events}})}),t}function Yu(a){return[...new Set(a.map(t=>t.includes(":")?t.split(":")[0]:t))]}function n0(a){const t={};return Object.keys(a).forEach(r=>{if(r.includes(":"))t[r]=a[r];else{const s=zr(a[r].accounts);s==null||s.forEach(o=>{t[o]={accounts:a[r].accounts.filter(u=>u.includes(`${o}:`)),methods:a[r].methods,events:a[r].events}})}}),t}function o0(a,t){return Fo(a,!1)&&a<=t.max&&a>=t.min}function Zu(){const a=Ii();return new Promise(t=>{switch(a){case Ge.browser:t(a0());break;case Ge.reactNative:t(c0());break;case Ge.node:t(u0());break;default:t(!0)}})}function a0(){return kr()&&(navigator==null?void 0:navigator.onLine)}async function c0(){if(Lr()&&typeof ee.global<"u"&&ee.global!=null&&ee.global.NetInfo){const a=await(ee.global==null?void 0:ee.global.NetInfo.fetch());return a==null?void 0:a.isConnected}return!0}function u0(){return!0}function h0(a){switch(Ii()){case Ge.browser:l0(a);break;case Ge.reactNative:p0(a);break}}function l0(a){!Lr()&&kr()&&(window.addEventListener("online",()=>a(!0)),window.addEventListener("offline",()=>a(!1)))}function p0(a){var t;Lr()&&typeof ee.global<"u"&&ee.global!=null&&ee.global.NetInfo&&((t=ee.global)==null||t.NetInfo.addEventListener(r=>a(r==null?void 0:r.isConnected)))}const co={};let ws=class{static get(t){return co[t]}static set(t,r){co[t]=r}static delete(t){delete co[t]}};class Dt extends xw{constructor(t){super(t),this.events=new gt.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async request(t,r){return this.requestStrict(Ar(t.method,t.params||[],t.id||Vh().toString()),r)}async requestStrict(t,r){return new Promise(async(s,o)=>{if(!this.connection.connected)try{await this.open()}catch(u){o(u)}this.events.on(`${t.id}`,u=>{bt(u)?o(u.error):s(u.result)});try{await this.connection.send(t,r)}catch(u){o(u)}})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),Ns(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const f0=()=>typeof WebSocket<"u"?WebSocket:typeof ee.global<"u"&&typeof ee.global.WebSocket<"u"?ee.global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),d0=()=>typeof WebSocket<"u"||typeof ee.global<"u"&&typeof ee.global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Xu=a=>a.split("?")[0],eh=10,g0=f0();let y0=class{constructor(t){if(this.url=t,this.events=new gt.EventEmitter,this.registering=!1,!Nu(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=s=>{this.onClose(s),t()},this.socket.close()})}async send(t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Qh(t))}catch(r){this.onError(t.id,r)}}register(t=this.url){if(!Nu(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,o)=>{this.events.once("register_error",u=>{this.resetMaxListeners(),o(u)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return o(new Error("WebSocket connection is missing or invalid"));s(this.socket)})})}return this.url=t,this.registering=!0,new Promise((r,s)=>{const o=new URLSearchParams(t).get("origin"),u=Aw.isReactNative()?{headers:{origin:o}}:{rejectUnauthorized:!Dw(t)},l=new g0(t,[],u);d0()?l.onerror=g=>{const w=g;s(this.emitError(w.error))}:l.on("error",g=>{s(this.emitError(g))}),l.onopen=()=>{this.onOpen(l),r(l)}})}onOpen(t){t.onmessage=r=>this.onPayload(r),t.onclose=r=>this.onClose(r),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const r=typeof t.data=="string"?Gh(t.data):t.data;this.events.emit("payload",r)}onError(t,r){const s=this.parseError(r),o=s.message||s.toString(),u=Cs(t,o);this.events.emit("payload",u)}parseError(t,r=this.url){return Kh(t,Xu(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>eh&&this.events.setMaxListeners(eh)}emitError(t){const r=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${Xu(this.url)}`));return this.events.emit("register_error",r),r}};function v0(a,t){return t=t||{},new Promise(function(r,s){var o=new XMLHttpRequest,u=[],l=[],g={},w=function(){return{ok:(o.status/100|0)==2,statusText:o.statusText,status:o.status,url:o.responseURL,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(o.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([o.response]))},clone:w,headers:{keys:function(){return u},entries:function(){return l},get:function($){return g[$.toLowerCase()]},has:function($){return $.toLowerCase()in g}}}};for(var b in o.open(t.method||"get",a,!0),o.onload=function(){o.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function($,S,R){u.push(S=S.toLowerCase()),l.push([S,R]),g[S]=g[S]?g[S]+","+R:R}),r(w())},o.onerror=s,o.withCredentials=t.credentials=="include",t.headers)o.setRequestHeader(b,t.headers[b]);o.send(t.body||null)})}const m0=Object.freeze(Object.defineProperty({__proto__:null,default:v0},Symbol.toStringTag,{value:"Module"})),th=Ao(m0);var w0=self.fetch||(self.fetch=th.default||th);const _0=Rw(w0);var b0={};function E0(a,t){if(a.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var o=0;o<a.length;o++){var u=a.charAt(o),l=u.charCodeAt(0);if(r[l]!==255)throw new TypeError(u+" is ambiguous");r[l]=o}var g=a.length,w=a.charAt(0),b=Math.log(g)/Math.log(256),$=Math.log(256)/Math.log(g);function S(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var K=0,A=0,G=0,pe=x.length;G!==pe&&x[G]===0;)G++,K++;for(var J=(pe-G)*$+1>>>0,Z=new Uint8Array(J);G!==pe;){for(var ue=x[G],De=0,fe=J-1;(ue!==0||De<A)&&fe!==-1;fe--,De++)ue+=256*Z[fe]>>>0,Z[fe]=ue%g>>>0,ue=ue/g>>>0;if(ue!==0)throw new Error("Non-zero carry");A=De,G++}for(var $e=J-A;$e!==J&&Z[$e]===0;)$e++;for(var jt=w.repeat(K);$e<J;++$e)jt+=a.charAt(Z[$e]);return jt}function R(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var K=0;if(x[K]!==" "){for(var A=0,G=0;x[K]===w;)A++,K++;for(var pe=(x.length-K)*b+1>>>0,J=new Uint8Array(pe);x[K];){var Z=r[x.charCodeAt(K)];if(Z===255)return;for(var ue=0,De=pe-1;(Z!==0||ue<G)&&De!==-1;De--,ue++)Z+=g*J[De]>>>0,J[De]=Z%256>>>0,Z=Z/256>>>0;if(Z!==0)throw new Error("Non-zero carry");G=ue,K++}if(x[K]!==" "){for(var fe=pe-G;fe!==pe&&J[fe]===0;)fe++;for(var $e=new Uint8Array(A+(pe-fe)),jt=A;fe!==pe;)$e[jt++]=J[fe++];return $e}}}function j(x){var K=R(x);if(K)return K;throw new Error(`Non-${t} character`)}return{encode:S,decodeUnsafe:R,decode:j}}var I0=E0,P0=I0;const cl=a=>{if(a instanceof Uint8Array&&a.constructor.name==="Uint8Array")return a;if(a instanceof ArrayBuffer)return new Uint8Array(a);if(ArrayBuffer.isView(a))return new Uint8Array(a.buffer,a.byteOffset,a.byteLength);throw new Error("Unknown type, must be binary type")},S0=a=>new TextEncoder().encode(a),O0=a=>new TextDecoder().decode(a);class R0{constructor(t,r,s){this.name=t,this.prefix=r,this.baseEncode=s}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class $0{constructor(t,r,s){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=s}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return ul(this,t)}}class N0{constructor(t){this.decoders=t}or(t){return ul(this,t)}decode(t){const r=t[0],s=this.decoders[r];if(s)return s.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ul=(a,t)=>new N0({...a.decoders||{[a.prefix]:a},...t.decoders||{[t.prefix]:t}});class C0{constructor(t,r,s,o){this.name=t,this.prefix=r,this.baseEncode=s,this.baseDecode=o,this.encoder=new R0(t,r,s),this.decoder=new $0(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const qs=({name:a,prefix:t,encode:r,decode:s})=>new C0(a,t,r,s),Pi=({prefix:a,name:t,alphabet:r})=>{const{encode:s,decode:o}=P0(r,t);return qs({prefix:a,name:t,encode:s,decode:u=>cl(o(u))})},T0=(a,t,r,s)=>{const o={};for(let $=0;$<t.length;++$)o[t[$]]=$;let u=a.length;for(;a[u-1]==="=";)--u;const l=new Uint8Array(u*r/8|0);let g=0,w=0,b=0;for(let $=0;$<u;++$){const S=o[a[$]];if(S===void 0)throw new SyntaxError(`Non-${s} character`);w=w<<r|S,g+=r,g>=8&&(g-=8,l[b++]=255&w>>g)}if(g>=r||255&w<<8-g)throw new SyntaxError("Unexpected end of data");return l},x0=(a,t,r)=>{const s=t[t.length-1]==="=",o=(1<<r)-1;let u="",l=0,g=0;for(let w=0;w<a.length;++w)for(g=g<<8|a[w],l+=8;l>r;)l-=r,u+=t[o&g>>l];if(l&&(u+=t[o&g<<r-l]),s)for(;u.length*r&7;)u+="=";return u},Pe=({name:a,prefix:t,bitsPerChar:r,alphabet:s})=>qs({prefix:t,name:a,encode(o){return x0(o,s,r)},decode(o){return T0(o,s,r,a)}}),A0=qs({prefix:"\0",name:"identity",encode:a=>O0(a),decode:a=>S0(a)});var D0=Object.freeze({__proto__:null,identity:A0});const q0=Pe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var j0=Object.freeze({__proto__:null,base2:q0});const U0=Pe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var M0=Object.freeze({__proto__:null,base8:U0});const L0=Pi({prefix:"9",name:"base10",alphabet:"0123456789"});var k0=Object.freeze({__proto__:null,base10:L0});const z0=Pe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),H0=Pe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var V0=Object.freeze({__proto__:null,base16:z0,base16upper:H0});const K0=Pe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),F0=Pe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),W0=Pe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),B0=Pe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),G0=Pe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Q0=Pe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),J0=Pe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Y0=Pe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Z0=Pe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var X0=Object.freeze({__proto__:null,base32:K0,base32upper:F0,base32pad:W0,base32padupper:B0,base32hex:G0,base32hexupper:Q0,base32hexpad:J0,base32hexpadupper:Y0,base32z:Z0});const eE=Pi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),tE=Pi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var rE=Object.freeze({__proto__:null,base36:eE,base36upper:tE});const iE=Pi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),sE=Pi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var nE=Object.freeze({__proto__:null,base58btc:iE,base58flickr:sE});const oE=Pe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),aE=Pe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),cE=Pe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),uE=Pe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var hE=Object.freeze({__proto__:null,base64:oE,base64pad:aE,base64url:cE,base64urlpad:uE});const hl=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),lE=hl.reduce((a,t,r)=>(a[r]=t,a),[]),pE=hl.reduce((a,t,r)=>(a[t.codePointAt(0)]=r,a),[]);function fE(a){return a.reduce((t,r)=>(t+=lE[r],t),"")}function dE(a){const t=[];for(const r of a){const s=pE[r.codePointAt(0)];if(s===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(s)}return new Uint8Array(t)}const gE=qs({prefix:"🚀",name:"base256emoji",encode:fE,decode:dE});var yE=Object.freeze({__proto__:null,base256emoji:gE}),vE=ll,rh=128,mE=-128,wE=Math.pow(2,31);function ll(a,t,r){t=t||[],r=r||0;for(var s=r;a>=wE;)t[r++]=a&255|rh,a/=128;for(;a&mE;)t[r++]=a&255|rh,a>>>=7;return t[r]=a|0,ll.bytes=r-s+1,t}var _E=Ro,bE=128,ih=127;function Ro(a,s){var r=0,s=s||0,o=0,u=s,l,g=a.length;do{if(u>=g)throw Ro.bytes=0,new RangeError("Could not decode varint");l=a[u++],r+=o<28?(l&ih)<<o:(l&ih)*Math.pow(2,o),o+=7}while(l>=bE);return Ro.bytes=u-s,r}var EE=Math.pow(2,7),IE=Math.pow(2,14),PE=Math.pow(2,21),SE=Math.pow(2,28),OE=Math.pow(2,35),RE=Math.pow(2,42),$E=Math.pow(2,49),NE=Math.pow(2,56),CE=Math.pow(2,63),TE=function(a){return a<EE?1:a<IE?2:a<PE?3:a<SE?4:a<OE?5:a<RE?6:a<$E?7:a<NE?8:a<CE?9:10},xE={encode:vE,decode:_E,encodingLength:TE},pl=xE;const sh=(a,t,r=0)=>(pl.encode(a,t,r),t),nh=a=>pl.encodingLength(a),$o=(a,t)=>{const r=t.byteLength,s=nh(a),o=s+nh(r),u=new Uint8Array(o+r);return sh(a,u,0),sh(r,u,s),u.set(t,o),new AE(a,r,t,u)};class AE{constructor(t,r,s,o){this.code=t,this.size=r,this.digest=s,this.bytes=o}}const fl=({name:a,code:t,encode:r})=>new DE(a,t,r);class DE{constructor(t,r,s){this.name=t,this.code=r,this.encode=s}digest(t){if(t instanceof Uint8Array){const r=this.encode(t);return r instanceof Uint8Array?$o(this.code,r):r.then(s=>$o(this.code,s))}else throw Error("Unknown type, must be binary type")}}const dl=a=>async t=>new Uint8Array(await crypto.subtle.digest(a,t)),qE=fl({name:"sha2-256",code:18,encode:dl("SHA-256")}),jE=fl({name:"sha2-512",code:19,encode:dl("SHA-512")});var UE=Object.freeze({__proto__:null,sha256:qE,sha512:jE});const gl=0,ME="identity",yl=cl,LE=a=>$o(gl,yl(a)),kE={code:gl,name:ME,encode:yl,digest:LE};var zE=Object.freeze({__proto__:null,identity:kE});new TextEncoder,new TextDecoder;const oh={...D0,...j0,...M0,...k0,...V0,...X0,...rE,...nE,...hE,...yE};({...UE,...zE});function vl(a){return globalThis.Buffer!=null?new Uint8Array(a.buffer,a.byteOffset,a.byteLength):a}function HE(a=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?vl(globalThis.Buffer.allocUnsafe(a)):new Uint8Array(a)}function ml(a,t,r,s){return{name:a,prefix:t,encoder:{name:a,prefix:t,encode:r},decoder:{decode:s}}}const ah=ml("utf8","u",a=>"u"+new TextDecoder("utf8").decode(a),a=>new TextEncoder().encode(a.substring(1))),uo=ml("ascii","a",a=>{let t="a";for(let r=0;r<a.length;r++)t+=String.fromCharCode(a[r]);return t},a=>{a=a.substring(1);const t=HE(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);return t}),VE={utf8:ah,"utf-8":ah,hex:oh.base16,latin1:uo,ascii:uo,binary:uo,...oh};function KE(a,t="utf8"){const r=VE[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?vl(globalThis.Buffer.from(a,"utf-8")):r.decoder.decode(`${r.prefix}${a}`)}const wl="wc",FE=2,_l="core",Gt=`${wl}@2:${_l}:`,WE={logger:"error"},BE={database:":memory:"},GE="crypto",ch="client_ed25519_seed",QE=q.ONE_DAY,JE="keychain",YE="0.3",ZE="messages",XE="0.3",e1=q.SIX_HOURS,t1="publisher",bl="irn",r1="error",El="wss://relay.walletconnect.com",uh="wss://relay.walletconnect.org",i1="relayer",Re={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},s1="_subscription",xt={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},n1=q.ONE_SECOND,o1="2.11.0",a1=1e4,c1="0.3",u1="WALLETCONNECT_CLIENT_ID",pt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},h1="subscription",l1="0.3",p1=q.FIVE_SECONDS*1e3,f1="pairing",d1="0.3",pi={wc_pairingDelete:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:q.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:q.ONE_DAY,prompt:!1,tag:0},res:{ttl:q.ONE_DAY,prompt:!1,tag:0}}},mi={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},_t={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},g1="history",y1="0.3",v1="expirer",st={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},m1="0.3",ho="verify-api",xr="https://verify.walletconnect.com",No="https://verify.walletconnect.org",w1=[xr,No],_1="echo",b1="https://echo.walletconnect.com";class E1{constructor(t,r){this.core=t,this.logger=r,this.keychain=new Map,this.name=JE,this.version=YE,this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{if(!this.initialized){const s=await this.getKeyChain();typeof s<"u"&&(this.keychain=s),this.initialized=!0}},this.has=s=>(this.isInitialized(),this.keychain.has(s)),this.set=async(s,o)=>{this.isInitialized(),this.keychain.set(s,o),await this.persist()},this.get=s=>{this.isInitialized();const o=this.keychain.get(s);if(typeof o>"u"){const{message:u}=N("NO_MATCHING_KEY",`${this.name}: ${s}`);throw new Error(u)}return o},this.del=async s=>{this.isInitialized(),this.keychain.delete(s),await this.persist()},this.core=t,this.logger=ze(r,this.name)}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,rl(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?il(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class I1{constructor(t,r,s){this.core=t,this.logger=r,this.name=GE,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=o=>(this.isInitialized(),this.keychain.has(o)),this.getClientId=async()=>{this.isInitialized();const o=await this.getClientSeed(),u=Cu(o);return jw(u.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const o=X_();return this.setPrivateKey(o.publicKey,o.privateKey)},this.signJWT=async o=>{this.isInitialized();const u=await this.getClientSeed(),l=Cu(u),g=So();return await Uw(g,o,QE,l)},this.generateSharedKey=(o,u,l)=>{this.isInitialized();const g=this.getPrivateKey(o),w=eb(g,u);return this.setSymKey(w,l)},this.setSymKey=async(o,u)=>{this.isInitialized();const l=u||tb(o);return await this.keychain.set(l,o),l},this.deleteKeyPair=async o=>{this.isInitialized(),await this.keychain.del(o)},this.deleteSymKey=async o=>{this.isInitialized(),await this.keychain.del(o)},this.encode=async(o,u,l)=>{this.isInitialized();const g=tl(l),w=Qh(u);if(zu(g)){const R=g.senderPublicKey,j=g.receiverPublicKey;o=await this.generateSharedKey(R,j)}const b=this.getSymKey(o),{type:$,senderPublicKey:S}=g;return ib({type:$,symKey:b,message:w,senderPublicKey:S})},this.decode=async(o,u,l)=>{this.isInitialized();const g=ob(u,l);if(zu(g)){const w=g.receiverPublicKey,b=g.senderPublicKey;o=await this.generateSharedKey(w,b)}try{const w=this.getSymKey(o),b=sb({symKey:w,encoded:u});return Gh(b)}catch(w){this.logger.error(`Failed to decode message from topic: '${o}', clientId: '${await this.getClientId()}'`),this.logger.error(w)}},this.getPayloadType=o=>{const u=Os(o);return Ei(u.type)},this.getPayloadSenderPublicKey=o=>{const u=Os(o);return u.senderPublicKey?nt(u.senderPublicKey,Ae):void 0},this.core=t,this.logger=ze(r,this.name),this.keychain=s||new E1(this.core,this.logger)}get context(){return Qe(this.logger)}async setPrivateKey(t,r){return await this.keychain.set(t,r),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(ch)}catch{t=So(),await this.keychain.set(ch,t)}return KE(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class P1 extends R_{constructor(t,r){super(t,r),this.logger=t,this.core=r,this.messages=new Map,this.name=ZE,this.version=XE,this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const s=await this.getRelayerMessages();typeof s<"u"&&(this.messages=s),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(s){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(s)}finally{this.initialized=!0}}},this.set=async(s,o)=>{this.isInitialized();const u=Dr(o);let l=this.messages.get(s);return typeof l>"u"&&(l={}),typeof l[u]<"u"||(l[u]=o,this.messages.set(s,l),await this.persist()),u},this.get=s=>{this.isInitialized();let o=this.messages.get(s);return typeof o>"u"&&(o={}),o},this.has=(s,o)=>{this.isInitialized();const u=this.get(s),l=Dr(o);return typeof u[l]<"u"},this.del=async s=>{this.isInitialized(),this.messages.delete(s),await this.persist()},this.logger=ze(t,this.name),this.core=r}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,rl(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?il(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class S1 extends $_{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new gt.EventEmitter,this.name=t1,this.queue=new Map,this.publishTimeout=q.toMiliseconds(q.TEN_SECONDS),this.needsTransportRestart=!1,this.publish=async(s,o,u)=>{var l;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:o,opts:u}});try{const g=(u==null?void 0:u.ttl)||e1,w=Oo(u),b=(u==null?void 0:u.prompt)||!1,$=(u==null?void 0:u.tag)||0,S=(u==null?void 0:u.id)||Vh().toString(),R={topic:s,message:o,opts:{ttl:g,relay:w,prompt:b,tag:$,id:S}},j=setTimeout(()=>this.queue.set(S,R),this.publishTimeout);try{await await bi(this.rpcPublish(s,o,g,w,b,$,S),this.publishTimeout,"Failed to publish payload, please try again."),this.removeRequestFromQueue(S),this.relayer.events.emit(Re.publish,R)}catch(x){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(l=u==null?void 0:u.internal)!=null&&l.throwOnFailedPublish)throw this.removeRequestFromQueue(S),x;return}finally{clearTimeout(j)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:o,opts:u}})}catch(g){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(g),g}},this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.relayer=t,this.logger=ze(r,this.name),this.registerEventListeners()}get context(){return Qe(this.logger)}rpcPublish(t,r,s,o,u,l,g){var w,b,$,S;const R={method:Is(o.protocol).publish,params:{topic:t,message:r,ttl:s,prompt:u,tag:l},id:g};return xe((w=R.params)==null?void 0:w.prompt)&&((b=R.params)==null||delete b.prompt),xe(($=R.params)==null?void 0:$.tag)&&((S=R.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:R}),this.relayer.request(R)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{const{topic:r,message:s,opts:o}=t;await this.publish(r,s,o)})}registerEventListeners(){this.relayer.core.heartbeat.on(Ur.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Re.connection_stalled);return}this.checkQueue()}),this.relayer.on(Re.message_ack,t=>{this.removeRequestFromQueue(t.id.toString())})}}class O1{constructor(){this.map=new Map,this.set=(t,r)=>{const s=this.get(t);this.exists(t,r)||this.map.set(t,[...s,r])},this.get=t=>this.map.get(t)||[],this.exists=(t,r)=>this.get(t).includes(r),this.delete=(t,r)=>{if(typeof r>"u"){this.map.delete(t);return}if(!this.map.has(t))return;const s=this.get(t);if(!this.exists(t,r))return;const o=s.filter(u=>u!==r);if(!o.length){this.map.delete(t);return}this.map.set(t,o)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var R1=Object.defineProperty,$1=Object.defineProperties,N1=Object.getOwnPropertyDescriptors,hh=Object.getOwnPropertySymbols,C1=Object.prototype.hasOwnProperty,T1=Object.prototype.propertyIsEnumerable,lh=(a,t,r)=>t in a?R1(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,fi=(a,t)=>{for(var r in t||(t={}))C1.call(t,r)&&lh(a,r,t[r]);if(hh)for(var r of hh(t))T1.call(t,r)&&lh(a,r,t[r]);return a},lo=(a,t)=>$1(a,N1(t));class x1 extends T_{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new O1,this.events=new gt.EventEmitter,this.name=h1,this.version=l1,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Gt,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(s,o)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:o}});try{const u=Oo(o),l={topic:s,relay:u};this.pending.set(s,l);const g=await this.rpcSubscribe(s,u);return this.onSubscribe(g,l),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:o}}),g}catch(u){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(u),u}},this.unsubscribe=async(s,o)=>{await this.restartToComplete(),this.isInitialized(),typeof(o==null?void 0:o.id)<"u"?await this.unsubscribeById(s,o.id,o):await this.unsubscribeByTopic(s,o)},this.isSubscribed=async s=>this.topics.includes(s)?!0:await new Promise((o,u)=>{const l=new q.Watch;l.start(this.pendingSubscriptionWatchLabel);const g=setInterval(()=>{!this.pending.has(s)&&this.topics.includes(s)&&(clearInterval(g),l.stop(this.pendingSubscriptionWatchLabel),o(!0)),l.elapsed(this.pendingSubscriptionWatchLabel)>=p1&&(clearInterval(g),l.stop(this.pendingSubscriptionWatchLabel),u(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1),this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=ze(r,this.name),this.clientId=""}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(t,r){let s=!1;try{s=this.getSubscription(t).topic===r}catch{}return s}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,r){const s=this.topicMap.get(t);await Promise.all(s.map(async o=>await this.unsubscribeById(t,o,r)))}async unsubscribeById(t,r,s){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:s}});try{const o=Oo(s);await this.rpcUnsubscribe(t,r,o);const u=ye("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,r,u),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:s}})}catch(o){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(o),o}}async rpcSubscribe(t,r){const s={method:Is(r.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{await await bi(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Re.connection_stalled)}return Dr(t+this.clientId)}async rpcBatchSubscribe(t){if(!t.length)return;const r=t[0].relay,s={method:Is(r.protocol).batchSubscribe,params:{topics:t.map(o=>o.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{return await await bi(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Re.connection_stalled)}}rpcUnsubscribe(t,r,s){const o={method:Is(s.protocol).unsubscribe,params:{topic:t,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:o}),this.relayer.request(o)}onSubscribe(t,r){this.setSubscription(t,lo(fi({},r),{id:t})),this.pending.delete(r.topic)}onBatchSubscribe(t){t.length&&t.forEach(r=>{this.setSubscription(r.id,fi({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(t,r,s){this.events.removeAllListeners(r),this.hasSubscription(r,t)&&this.deleteSubscription(r,s),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,r){this.subscriptions.has(t)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:r}),this.addSubscription(t,r))}addSubscription(t,r){this.subscriptions.set(t,fi({},r)),this.topicMap.set(r.topic,t),this.events.emit(pt.created,r)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const r=this.subscriptions.get(t);if(!r){const{message:s}=N("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(s)}return r}deleteSubscription(t,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:r});const s=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(s.topic,t),this.events.emit(pt.deleted,lo(fi({},s),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(pt.sync)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){const s=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s)}}this.events.emit(pt.resubscribed)}async restore(){try{const t=await this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){const{message:r}=N("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const r=await this.rpcBatchSubscribe(t);cr(r)&&this.onBatchSubscribe(r.map((s,o)=>lo(fi({},t[o]),{id:s})))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const t=[];this.pending.forEach(r=>{t.push(r)}),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on(Ur.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.relayer.on(Re.connect,async()=>{await this.onConnect()}),this.relayer.on(Re.disconnect,()=>{this.onDisconnect()}),this.events.on(pt.created,async t=>{const r=pt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()}),this.events.on(pt.deleted,async t=>{const r=pt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),t())},this.pollingInterval)})}}var A1=Object.defineProperty,ph=Object.getOwnPropertySymbols,D1=Object.prototype.hasOwnProperty,q1=Object.prototype.propertyIsEnumerable,fh=(a,t,r)=>t in a?A1(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,j1=(a,t)=>{for(var r in t||(t={}))D1.call(t,r)&&fh(a,r,t[r]);if(ph)for(var r of ph(t))q1.call(t,r)&&fh(a,r,t[r]);return a};class U1 extends N_{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new gt.EventEmitter,this.name=i1,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.request=async r=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(r)}catch(s){throw this.logger.debug("Failed to Publish Request"),this.logger.error(s),s}},this.onPayloadHandler=r=>{this.onProviderPayload(r)},this.onConnectHandler=()=>{this.events.emit(Re.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Re.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(xt.payload,this.onPayloadHandler),this.provider.on(xt.connect,this.onConnectHandler),this.provider.on(xt.disconnect,this.onDisconnectHandler),this.provider.on(xt.error,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?ze(t.logger,this.name):Ts(xs({level:t.logger||r1})),this.messages=new P1(this.logger,t.core),this.subscriber=new x1(this,this.logger),this.publisher=new S1(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||El,this.projectId=t.projectId,this.bundleId=pb(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${uh}...`),await this.restartTransport(uh)}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},a1)}get context(){return Qe(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(t,r,s){this.isInitialized(),await this.publisher.publish(t,r,s),await this.recordMessageEvent({topic:t,message:r,publishedAt:Date.now()})}async subscribe(t,r){var s;this.isInitialized();let o=((s=this.subscriber.topicMap.get(t))==null?void 0:s[0])||"";if(o)return o;let u;const l=g=>{g.topic===t&&(this.subscriber.off(pt.created,l),u())};return await Promise.all([new Promise(g=>{u=g,this.subscriber.on(pt.created,l)}),new Promise(async g=>{o=await this.subscriber.subscribe(t,r),g()})]),o}async unsubscribe(t,r){this.isInitialized(),await this.subscriber.unsubscribe(t,r)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async transportClose(){this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await bi(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect()}async transportOpen(t){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(r=>{if(!this.initialized)return r();this.subscriber.once(pt.resubscribed,()=>{r()})}),new Promise(async(r,s)=>{try{await bi(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`)}catch(o){s(o);return}r()})])}catch(r){this.logger.error(r);const s=r;if(!this.isConnectionStalled(s.message))throw r;this.provider.events.emit(xt.disconnect)}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1}}}async restartTransport(t){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=t||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Zu())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(t){return this.staleConnectionErrors.some(r=>t.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Dt(new y0(mb({sdkVersion:o1,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:r,message:s}=t;await this.messages.set(r,s)}async shouldIgnoreMessageEvent(t){const{topic:r,message:s}=t;if(!s||s.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${s}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const o=this.messages.has(r,s);return o&&this.logger.debug(`Ignoring duplicate message: ${s}`),o}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),jo(t)){if(!t.method.endsWith(s1))return;const r=t.params,{topic:s,message:o,publishedAt:u}=r.data,l={topic:s,message:o,publishedAt:u};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(j1({type:"event",event:r.id},l)),this.events.emit(r.id,l),await this.acknowledgePayload(t),await this.onMessageEvent(l)}else Ns(t)&&this.events.emit(Re.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(Re.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const r=As(t.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(xt.payload,this.onPayloadHandler),this.provider.off(xt.connect,this.onConnectHandler),this.provider.off(xt.disconnect,this.onDisconnectHandler),this.provider.off(xt.error,this.onProviderErrorHandler)}async registerEventListeners(){this.events.on(Re.connection_stalled,()=>{this.restartTransport().catch(r=>this.logger.error(r))});let t=await Zu();h0(async r=>{this.initialized&&t!==r&&(t=r,r?await this.restartTransport().catch(s=>this.logger.error(s)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(s=>this.logger.error(s))))})}onProviderDisconnect(){this.events.emit(Re.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(t=>this.logger.error(t))},q.toMiliseconds(n1)))}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(t=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),t())},this.connectionStatusPollingInterval)});await this.restartTransport()}}}var M1=Object.defineProperty,dh=Object.getOwnPropertySymbols,L1=Object.prototype.hasOwnProperty,k1=Object.prototype.propertyIsEnumerable,gh=(a,t,r)=>t in a?M1(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,yh=(a,t)=>{for(var r in t||(t={}))L1.call(t,r)&&gh(a,r,t[r]);if(dh)for(var r of dh(t))k1.call(t,r)&&gh(a,r,t[r]);return a};class js extends C_{constructor(t,r,s,o=Gt,u=void 0){super(t,r,s,o),this.core=t,this.logger=r,this.name=s,this.map=new Map,this.version=c1,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(l=>{this.getKey&&l!==null&&!xe(l)?this.map.set(this.getKey(l),l):zb(l)?this.map.set(l.id,l):Hb(l)&&this.map.set(l.topic,l)}),this.cached=[],this.initialized=!0)},this.set=async(l,g)=>{this.isInitialized(),this.map.has(l)?await this.update(l,g):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:l,value:g}),this.map.set(l,g),await this.persist())},this.get=l=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:l}),this.getData(l)),this.getAll=l=>(this.isInitialized(),l?this.values.filter(g=>Object.keys(l).every(w=>Mw(g[w],l[w]))):this.values),this.update=async(l,g)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:l,update:g});const w=yh(yh({},this.getData(l)),g);this.map.set(l,w),await this.persist()},this.delete=async(l,g)=>{this.isInitialized(),this.map.has(l)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:l,reason:g}),this.map.delete(l),await this.persist())},this.logger=ze(r,this.name),this.storagePrefix=o,this.getKey=u}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const r=this.map.get(t);if(!r){const{message:s}=N("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:r}=N("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class z1{constructor(t,r){this.core=t,this.logger=r,this.name=f1,this.version=d1,this.events=new Do,this.initialized=!1,this.storagePrefix=Gt,this.ignoredPayloadTypes=[pr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:s})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...s])]},this.create=async()=>{this.isInitialized();const s=So(),o=await this.core.crypto.setSymKey(s),u=ft(q.FIVE_MINUTES),l={protocol:bl},g={topic:o,expiry:u,relay:l,active:!1},w=Tb({protocol:this.core.protocol,version:this.core.version,topic:o,symKey:s,relay:l});return await this.pairings.set(o,g),await this.core.relayer.subscribe(o),this.core.expirer.set(o,u),{topic:o,uri:w}},this.pair=async s=>{this.isInitialized(),this.isValidPair(s);const{topic:o,symKey:u,relay:l}=Bu(s.uri);let g;if(this.pairings.keys.includes(o)&&(g=this.pairings.get(o),g.active))throw new Error(`Pairing already exists: ${o}. Please try again with a new connection URI.`);const w=ft(q.FIVE_MINUTES),b={topic:o,relay:l,expiry:w,active:!1};return await this.pairings.set(o,b),this.core.expirer.set(o,w),s.activatePairing&&await this.activate({topic:o}),this.events.emit(mi.create,b),this.core.crypto.keychain.has(o)||(await this.core.crypto.setSymKey(u,o),await this.core.relayer.subscribe(o,{relay:l})),b},this.activate=async({topic:s})=>{this.isInitialized();const o=ft(q.THIRTY_DAYS);await this.pairings.update(s,{active:!0,expiry:o}),this.core.expirer.set(s,o)},this.ping=async s=>{this.isInitialized(),await this.isValidPing(s);const{topic:o}=s;if(this.pairings.keys.includes(o)){const u=await this.sendRequest(o,"wc_pairingPing",{}),{done:l,resolve:g,reject:w}=Tr();this.events.once(ve("pairing_ping",u),({error:b})=>{b?w(b):g()}),await l()}},this.updateExpiry=async({topic:s,expiry:o})=>{this.isInitialized(),await this.pairings.update(s,{expiry:o})},this.updateMetadata=async({topic:s,metadata:o})=>{this.isInitialized(),await this.pairings.update(s,{peerMetadata:o})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async s=>{this.isInitialized(),await this.isValidDisconnect(s);const{topic:o}=s;this.pairings.keys.includes(o)&&(await this.sendRequest(o,"wc_pairingDelete",ye("USER_DISCONNECTED")),await this.deletePairing(o))},this.sendRequest=async(s,o,u)=>{const l=Ar(o,u),g=await this.core.crypto.encode(s,l),w=pi[o].req;return this.core.history.set(s,l),this.core.relayer.publish(s,g,w),l.id},this.sendResult=async(s,o,u)=>{const l=As(s,u),g=await this.core.crypto.encode(o,l),w=await this.core.history.get(o,s),b=pi[w.request.method].res;await this.core.relayer.publish(o,g,b),await this.core.history.resolve(l)},this.sendError=async(s,o,u)=>{const l=Cs(s,u),g=await this.core.crypto.encode(o,l),w=await this.core.history.get(o,s),b=pi[w.request.method]?pi[w.request.method].res:pi.unregistered_method.res;await this.core.relayer.publish(o,g,b),await this.core.history.resolve(l)},this.deletePairing=async(s,o)=>{await this.core.relayer.unsubscribe(s),await Promise.all([this.pairings.delete(s,ye("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(s),o?Promise.resolve():this.core.expirer.del(s)])},this.cleanup=async()=>{const s=this.pairings.getAll().filter(o=>Bt(o.expiry));await Promise.all(s.map(o=>this.deletePairing(o.topic)))},this.onRelayEventRequest=s=>{const{topic:o,payload:u}=s;switch(u.method){case"wc_pairingPing":return this.onPairingPingRequest(o,u);case"wc_pairingDelete":return this.onPairingDeleteRequest(o,u);default:return this.onUnknownRpcMethodRequest(o,u)}},this.onRelayEventResponse=async s=>{const{topic:o,payload:u}=s,l=(await this.core.history.get(o,u.id)).request.method;switch(l){case"wc_pairingPing":return this.onPairingPingResponse(o,u);default:return this.onUnknownRpcMethodResponse(l)}},this.onPairingPingRequest=async(s,o)=>{const{id:u}=o;try{this.isValidPing({topic:s}),await this.sendResult(u,s,!0),this.events.emit(mi.ping,{id:u,topic:s})}catch(l){await this.sendError(u,s,l),this.logger.error(l)}},this.onPairingPingResponse=(s,o)=>{const{id:u}=o;setTimeout(()=>{Wt(o)?this.events.emit(ve("pairing_ping",u),{}):bt(o)&&this.events.emit(ve("pairing_ping",u),{error:o.error})},500)},this.onPairingDeleteRequest=async(s,o)=>{const{id:u}=o;try{this.isValidDisconnect({topic:s}),await this.deletePairing(s),this.events.emit(mi.delete,{id:u,topic:s})}catch(l){await this.sendError(u,s,l),this.logger.error(l)}},this.onUnknownRpcMethodRequest=async(s,o)=>{const{id:u,method:l}=o;try{if(this.registeredMethods.includes(l))return;const g=ye("WC_METHOD_UNSUPPORTED",l);await this.sendError(u,s,g),this.logger.error(g)}catch(g){await this.sendError(u,s,g),this.logger.error(g)}},this.onUnknownRpcMethodResponse=s=>{this.registeredMethods.includes(s)||this.logger.error(ye("WC_METHOD_UNSUPPORTED",s))},this.isValidPair=s=>{var o;if(!ke(s)){const{message:l}=N("MISSING_OR_INVALID",`pair() params: ${s}`);throw new Error(l)}if(!kb(s.uri)){const{message:l}=N("MISSING_OR_INVALID",`pair() uri: ${s.uri}`);throw new Error(l)}const u=Bu(s.uri);if(!((o=u==null?void 0:u.relay)!=null&&o.protocol)){const{message:l}=N("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(l)}if(!(u!=null&&u.symKey)){const{message:l}=N("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(l)}},this.isValidPing=async s=>{if(!ke(s)){const{message:u}=N("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(u)}const{topic:o}=s;await this.isValidPairingTopic(o)},this.isValidDisconnect=async s=>{if(!ke(s)){const{message:u}=N("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(u)}const{topic:o}=s;await this.isValidPairingTopic(o)},this.isValidPairingTopic=async s=>{if(!be(s,!1)){const{message:o}=N("MISSING_OR_INVALID",`pairing topic should be a string: ${s}`);throw new Error(o)}if(!this.pairings.keys.includes(s)){const{message:o}=N("NO_MATCHING_KEY",`pairing topic doesn't exist: ${s}`);throw new Error(o)}if(Bt(this.pairings.get(s).expiry)){await this.deletePairing(s);const{message:o}=N("EXPIRED",`pairing topic: ${s}`);throw new Error(o)}},this.core=t,this.logger=ze(r,this.name),this.pairings=new js(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Qe(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(Re.message,async t=>{const{topic:r,message:s}=t;if(!this.pairings.keys.includes(r)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(s)))return;const o=await this.core.crypto.decode(r,s);try{jo(o)?(this.core.history.set(r,o),this.onRelayEventRequest({topic:r,payload:o})):Ns(o)&&(await this.core.history.resolve(o),await this.onRelayEventResponse({topic:r,payload:o}),this.core.history.delete(r,o.id))}catch(u){this.logger.error(u)}})}registerExpirerEvents(){this.core.expirer.on(st.expired,async t=>{const{topic:r}=nl(t.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(mi.expire,{topic:r}))})}}class H1 extends O_{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new gt.EventEmitter,this.name=g1,this.version=y1,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.records.set(s.id,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(s,o,u)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:s,request:o,chainId:u}),this.records.has(o.id))return;const l={id:o.id,topic:s,request:{method:o.method,params:o.params||null},chainId:u,expiry:ft(q.THIRTY_DAYS)};this.records.set(l.id,l),this.events.emit(_t.created,l)},this.resolve=async s=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:s}),!this.records.has(s.id))return;const o=await this.getRecord(s.id);typeof o.response>"u"&&(o.response=bt(s)?{error:s.error}:{result:s.result},this.records.set(o.id,o),this.events.emit(_t.updated,o))},this.get=async(s,o)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:s,id:o}),await this.getRecord(o)),this.delete=(s,o)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:o}),this.values.forEach(u=>{if(u.topic===s){if(typeof o<"u"&&u.id!==o)return;this.records.delete(u.id),this.events.emit(_t.deleted,u)}})},this.exists=async(s,o)=>(this.isInitialized(),this.records.has(o)?(await this.getRecord(o)).topic===s:!1),this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.logger=ze(r,this.name)}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const t=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const s={topic:r.topic,request:Ar(r.request.method,r.request.params,r.id),chainId:r.chainId};return t.push(s)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const r=this.records.get(t);if(!r){const{message:s}=N("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(s)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(_t.sync)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:r}=N("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(_t.created,t=>{const r=_t.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(_t.updated,t=>{const r=_t.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(_t.deleted,t=>{const r=_t.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.core.heartbeat.on(Ur.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(t=>{q.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.delete(t.topic,t.id))})}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class V1 extends x_{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new gt.EventEmitter,this.name=v1,this.version=m1,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.expirations.set(s.target,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=s=>{try{const o=this.formatTarget(s);return typeof this.getExpiration(o)<"u"}catch{return!1}},this.set=(s,o)=>{this.isInitialized();const u=this.formatTarget(s),l={target:u,expiry:o};this.expirations.set(u,l),this.checkExpiry(u,l),this.events.emit(st.created,{target:u,expiration:l})},this.get=s=>{this.isInitialized();const o=this.formatTarget(s);return this.getExpiration(o)},this.del=s=>{if(this.isInitialized(),this.has(s)){const o=this.formatTarget(s),u=this.getExpiration(o);this.expirations.delete(o),this.events.emit(st.deleted,{target:o,expiration:u})}},this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.logger=ze(r,this.name)}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(t){if(typeof t=="string")return wb(t);if(typeof t=="number")return _b(t);const{message:r}=N("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(r)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(st.sync)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:r}=N("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const r=this.expirations.get(t);if(!r){const{message:s}=N("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}return r}checkExpiry(t,r){const{expiry:s}=r;q.toMiliseconds(s)-Date.now()<=0&&this.expire(t,r)}expire(t,r){this.expirations.delete(t),this.events.emit(st.expired,{target:t,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,r)=>this.checkExpiry(r,t))}registerEventListeners(){this.core.heartbeat.on(Ur.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(st.created,t=>{const r=st.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on(st.expired,t=>{const r=st.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on(st.deleted,t=>{const r=st.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class K1 extends A_{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.name=ho,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async s=>{if(this.verifyDisabled||Lr()||!kr())return;const o=this.getVerifyUrl(s==null?void 0:s.verifyUrl);this.verifyUrl!==o&&this.removeIframe(),this.verifyUrl=o;try{await this.createIframe()}catch(u){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(u)}if(!this.initialized){this.removeIframe(),this.verifyUrl=No;try{await this.createIframe()}catch(u){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(u),this.verifyDisabled=!0}}},this.register=async s=>{this.initialized?this.sendPost(s.attestationId):(this.addToQueue(s.attestationId),await this.init())},this.resolve=async s=>{if(this.isDevEnv)return"";const o=this.getVerifyUrl(s==null?void 0:s.verifyUrl);let u;try{u=await this.fetchAttestation(s.attestationId,o)}catch(l){this.logger.info(`failed to resolve attestation: ${s.attestationId} from url: ${o}`),this.logger.info(l),u=await this.fetchAttestation(s.attestationId,No)}return u},this.fetchAttestation=async(s,o)=>{this.logger.info(`resolving attestation: ${s} from url: ${o}`);const u=this.startAbortTimer(q.ONE_SECOND*2),l=await fetch(`${o}/attestation/${s}`,{signal:this.abortController.signal});return clearTimeout(u),l.status===200?await l.json():void 0},this.addToQueue=s=>{this.queue.push(s)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(s=>this.sendPost(s)),this.queue=[])},this.sendPost=s=>{var o;try{if(!this.iframe)return;(o=this.iframe.contentWindow)==null||o.postMessage(s,"*"),this.logger.info(`postMessage sent: ${s} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let s;const o=u=>{u.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",o),s())};await Promise.race([new Promise(u=>{if(document.getElementById(ho))return u();window.addEventListener("message",o);const l=document.createElement("iframe");l.id=ho,l.src=`${this.verifyUrl}/${this.projectId}`,l.style.display="none",document.body.append(l),this.iframe=l,s=u}),new Promise((u,l)=>setTimeout(()=>{window.removeEventListener("message",o),l("verify iframe load timeout")},q.toMiliseconds(q.FIVE_SECONDS)))])},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=s=>{let o=s||xr;return w1.includes(o)||(this.logger.info(`verify url: ${o}, not included in trusted list, assigning default: ${xr}`),o=xr),o},this.logger=ze(r,this.name),this.verifyUrl=xr,this.abortController=new AbortController,this.isDevEnv=Vo()&&b0.IS_VITEST}get context(){return Qe(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),q.toMiliseconds(t))}}class F1 extends D_{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.context=_1,this.registerDeviceToken=async s=>{const{clientId:o,token:u,notificationType:l,enableEncrypted:g=!1}=s,w=`${b1}/${this.projectId}/clients`;await _0(w,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:o,type:l,token:u,always_raw:g})})},this.logger=ze(r,this.context)}}var W1=Object.defineProperty,vh=Object.getOwnPropertySymbols,B1=Object.prototype.hasOwnProperty,G1=Object.prototype.propertyIsEnumerable,mh=(a,t,r)=>t in a?W1(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,wh=(a,t)=>{for(var r in t||(t={}))B1.call(t,r)&&mh(a,r,t[r]);if(vh)for(var r of vh(t))G1.call(t,r)&&mh(a,r,t[r]);return a};class Wo extends S_{constructor(t){super(t),this.protocol=wl,this.version=FE,this.name=_l,this.events=new gt.EventEmitter,this.initialized=!1,this.on=(s,o)=>this.events.on(s,o),this.once=(s,o)=>this.events.once(s,o),this.off=(s,o)=>this.events.off(s,o),this.removeListener=(s,o)=>this.events.removeListener(s,o),this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||El,this.customStoragePrefix=t!=null&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Ts(xs({level:(t==null?void 0:t.logger)||WE.logger}));this.logger=ze(r,this.name),this.heartbeat=new Ur.HeartBeat,this.crypto=new I1(this,this.logger,t==null?void 0:t.keychain),this.history=new H1(this,this.logger),this.expirer=new V1(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new qw(wh(wh({},BE),t==null?void 0:t.storageOptions)),this.relayer=new U1({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new z1(this,this.logger),this.verify=new K1(this.projectId||"",this.logger),this.echoClient=new F1(this.projectId||"",this.logger)}static async init(t){const r=new Wo(t);await r.initialize();const s=await r.crypto.getClientId();return await r.storage.setItem(u1,s),r}get context(){return Qe(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}}const Q1=Wo,Il="wc",Pl=2,Sl="client",Bo=`${Il}@${Pl}:${Sl}:`,po={name:Sl,logger:"error"},_h="WALLETCONNECT_DEEPLINK_CHOICE",J1="proposal",Ol="Proposal expired",Y1="session",_s=q.SEVEN_DAYS,Z1="engine",di={wc_sessionPropose:{req:{ttl:q.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1104},res:{ttl:q.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1106},res:{ttl:q.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:q.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:q.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1112},res:{ttl:q.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1115}}},fo={min:q.FIVE_MINUTES,max:q.SEVEN_DAYS},At={idle:"IDLE",active:"ACTIVE"},X1="request",eI=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var tI=Object.defineProperty,rI=Object.defineProperties,iI=Object.getOwnPropertyDescriptors,bh=Object.getOwnPropertySymbols,sI=Object.prototype.hasOwnProperty,nI=Object.prototype.propertyIsEnumerable,Eh=(a,t,r)=>t in a?tI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Le=(a,t)=>{for(var r in t||(t={}))sI.call(t,r)&&Eh(a,r,t[r]);if(bh)for(var r of bh(t))nI.call(t,r)&&Eh(a,r,t[r]);return a},gi=(a,t)=>rI(a,iI(t));class oI extends j_{constructor(t){super(t),this.name=Z1,this.events=new Do,this.initialized=!1,this.ignoredPayloadTypes=[pr],this.requestQueue={state:At.idle,queue:[]},this.sessionRequestQueue={state:At.idle,queue:[]},this.requestQueueDelay=q.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(di)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},q.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{await this.isInitialized();const s=gi(Le({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(s);const{pairingTopic:o,requiredNamespaces:u,optionalNamespaces:l,sessionProperties:g,relays:w}=s;let b=o,$,S=!1;if(b&&(S=this.client.core.pairing.pairings.get(b).active),!b||!S){const{topic:J,uri:Z}=await this.client.core.pairing.create();b=J,$=Z}const R=await this.client.core.crypto.generateKeyPair(),j=Le({requiredNamespaces:u,optionalNamespaces:l,relays:w??[{protocol:bl}],proposer:{publicKey:R,metadata:this.client.metadata}},g&&{sessionProperties:g}),{reject:x,resolve:K,done:A}=Tr(q.FIVE_MINUTES,Ol);if(this.events.once(ve("session_connect"),async({error:J,session:Z})=>{if(J)x(J);else if(Z){Z.self.publicKey=R;const ue=gi(Le({},Z),{requiredNamespaces:Z.requiredNamespaces,optionalNamespaces:Z.optionalNamespaces});await this.client.session.set(Z.topic,ue),await this.setExpiry(Z.topic,Z.expiry),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:Z.peer.metadata}),K(ue)}}),!b){const{message:J}=N("NO_MATCHING_KEY",`connect() pairing topic: ${b}`);throw new Error(J)}const G=await this.sendRequest({topic:b,method:"wc_sessionPropose",params:j}),pe=ft(q.FIVE_MINUTES);return await this.setProposal(G,Le({id:G,expiry:pe},j)),{uri:$,approval:A}},this.pair=async r=>(await this.isInitialized(),await this.client.core.pairing.pair(r)),this.approve=async r=>{await this.isInitialized(),await this.isValidApprove(r);const{id:s,relayProtocol:o,namespaces:u,sessionProperties:l}=r,g=this.client.proposal.get(s);let{pairingTopic:w,proposer:b,requiredNamespaces:$,optionalNamespaces:S}=g;w=w||"",qr($)||($=qb(u,"approve()"));const R=await this.client.core.crypto.generateKeyPair(),j=b.publicKey,x=await this.client.core.crypto.generateSharedKey(R,j);w&&s&&(await this.client.core.pairing.updateMetadata({topic:w,metadata:b.metadata}),await this.sendResult({id:s,topic:w,result:{relay:{protocol:o??"irn"},responderPublicKey:R}}),await this.client.proposal.delete(s,ye("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:w}));const K=Le({relay:{protocol:o??"irn"},namespaces:u,requiredNamespaces:$,optionalNamespaces:S,pairingTopic:w,controller:{publicKey:R,metadata:this.client.metadata},expiry:ft(_s)},l&&{sessionProperties:l});await this.client.core.relayer.subscribe(x),await this.sendRequest({topic:x,method:"wc_sessionSettle",params:K,throwOnFailedPublish:!0});const A=gi(Le({},K),{topic:x,pairingTopic:w,acknowledged:!1,self:K.controller,peer:{publicKey:b.publicKey,metadata:b.metadata},controller:R});return await this.client.session.set(x,A),await this.setExpiry(x,ft(_s)),{topic:x,acknowledged:()=>new Promise(G=>setTimeout(()=>G(this.client.session.get(x)),500))}},this.reject=async r=>{await this.isInitialized(),await this.isValidReject(r);const{id:s,reason:o}=r,{pairingTopic:u}=this.client.proposal.get(s);u&&(await this.sendError(s,u,o),await this.client.proposal.delete(s,ye("USER_DISCONNECTED")))},this.update=async r=>{await this.isInitialized(),await this.isValidUpdate(r);const{topic:s,namespaces:o}=r,u=await this.sendRequest({topic:s,method:"wc_sessionUpdate",params:{namespaces:o}}),{done:l,resolve:g,reject:w}=Tr();return this.events.once(ve("session_update",u),({error:b})=>{b?w(b):g()}),await this.client.session.update(s,{namespaces:o}),{acknowledged:l}},this.extend=async r=>{await this.isInitialized(),await this.isValidExtend(r);const{topic:s}=r,o=await this.sendRequest({topic:s,method:"wc_sessionExtend",params:{}}),{done:u,resolve:l,reject:g}=Tr();return this.events.once(ve("session_extend",o),({error:w})=>{w?g(w):l()}),await this.setExpiry(s,ft(_s)),{acknowledged:u}},this.request=async r=>{await this.isInitialized(),await this.isValidRequest(r);const{chainId:s,request:o,topic:u,expiry:l}=r,g=Lw(),{done:w,resolve:b,reject:$}=Tr(l,"Request expired. Please try again.");return this.events.once(ve("session_request",g),({error:S,result:R})=>{S?$(S):b(R)}),await Promise.all([new Promise(async S=>{await this.sendRequest({clientRpcId:g,topic:u,method:"wc_sessionRequest",params:{request:o,chainId:s},expiry:l,throwOnFailedPublish:!0}).catch(R=>$(R)),this.client.events.emit("session_request_sent",{topic:u,request:o,chainId:s,id:g}),S()}),new Promise(async S=>{const R=await Eb(this.client.core.storage,_h);bb({id:g,topic:u,wcDeepLink:R}),S()}),w()]).then(S=>S[2])},this.respond=async r=>{await this.isInitialized(),await this.isValidRespond(r);const{topic:s,response:o}=r,{id:u}=o;Wt(o)?await this.sendResult({id:u,topic:s,result:o.result,throwOnFailedPublish:!0}):bt(o)&&await this.sendError(u,s,o.error),this.cleanupAfterResponse(r)},this.ping=async r=>{await this.isInitialized(),await this.isValidPing(r);const{topic:s}=r;if(this.client.session.keys.includes(s)){const o=await this.sendRequest({topic:s,method:"wc_sessionPing",params:{}}),{done:u,resolve:l,reject:g}=Tr();this.events.once(ve("session_ping",o),({error:w})=>{w?g(w):l()}),await u()}else this.client.core.pairing.pairings.keys.includes(s)&&await this.client.core.pairing.ping({topic:s})},this.emit=async r=>{await this.isInitialized(),await this.isValidEmit(r);const{topic:s,event:o,chainId:u}=r;await this.sendRequest({topic:s,method:"wc_sessionEvent",params:{event:o,chainId:u}})},this.disconnect=async r=>{await this.isInitialized(),await this.isValidDisconnect(r);const{topic:s}=r;this.client.session.keys.includes(s)?(await this.sendRequest({topic:s,method:"wc_sessionDelete",params:ye("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession(s)):await this.client.core.pairing.disconnect({topic:s})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(s=>Mb(s,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{const s=this.client.core.pairing.pairings.get(r.pairingTopic),o=this.client.core.pairing.pairings.getAll().filter(u=>{var l,g;return((l=u.peerMetadata)==null?void 0:l.url)&&((g=u.peerMetadata)==null?void 0:g.url)===r.peer.metadata.url&&u.topic&&u.topic!==s.topic});if(o.length===0)return;this.client.logger.info(`Cleaning up ${o.length} duplicate pairing(s)`),await Promise.all(o.map(u=>this.client.core.pairing.disconnect({topic:u.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(s){this.client.logger.error(s)}},this.deleteSession=async(r,s)=>{const{self:o}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),this.client.session.delete(r,ye("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),s||this.client.core.expirer.del(r),this.client.core.storage.removeItem(_h).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===r&&this.deletePendingSessionRequest(u.id,ye("USER_DISCONNECTED"))})},this.deleteProposal=async(r,s)=>{await Promise.all([this.client.proposal.delete(r,ye("USER_DISCONNECTED")),s?Promise.resolve():this.client.core.expirer.del(r)])},this.deletePendingSessionRequest=async(r,s,o=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,s),o?Promise.resolve():this.client.core.expirer.del(r)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(u=>u.id!==r),o&&(this.sessionRequestQueue.state=At.idle)},this.setExpiry=async(r,s)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:s}),this.client.core.expirer.set(r,s)},this.setProposal=async(r,s)=>{await this.client.proposal.set(r,s),this.client.core.expirer.set(r,s.expiry)},this.setPendingSessionRequest=async r=>{const s=di.wc_sessionRequest.req.ttl,{id:o,topic:u,params:l,verifyContext:g}=r;await this.client.pendingRequest.set(o,{id:o,topic:u,params:l,verifyContext:g}),s&&this.client.core.expirer.set(o,ft(s))},this.sendRequest=async r=>{const{topic:s,method:o,params:u,expiry:l,relayRpcId:g,clientRpcId:w,throwOnFailedPublish:b}=r,$=Ar(o,u,w);if(kr()&&eI.includes(o)){const j=Dr(JSON.stringify($));this.client.core.verify.register({attestationId:j})}const S=await this.client.core.crypto.encode(s,$),R=di[o].req;return l&&(R.ttl=l),g&&(R.id=g),this.client.core.history.set(s,$),b?(R.internal=gi(Le({},R.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,S,R)):this.client.core.relayer.publish(s,S,R).catch(j=>this.client.logger.error(j)),$.id},this.sendResult=async r=>{const{id:s,topic:o,result:u,throwOnFailedPublish:l}=r,g=As(s,u),w=await this.client.core.crypto.encode(o,g),b=await this.client.core.history.get(o,s),$=di[b.request.method].res;l?($.internal=gi(Le({},$.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(o,w,$)):this.client.core.relayer.publish(o,w,$).catch(S=>this.client.logger.error(S)),await this.client.core.history.resolve(g)},this.sendError=async(r,s,o)=>{const u=Cs(r,o),l=await this.client.core.crypto.encode(s,u),g=await this.client.core.history.get(s,r),w=di[g.request.method].res;this.client.core.relayer.publish(s,l,w),await this.client.core.history.resolve(u)},this.cleanup=async()=>{const r=[],s=[];this.client.session.getAll().forEach(o=>{Bt(o.expiry)&&r.push(o.topic)}),this.client.proposal.getAll().forEach(o=>{Bt(o.expiry)&&s.push(o.id)}),await Promise.all([...r.map(o=>this.deleteSession(o)),...s.map(o=>this.deleteProposal(o))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===At.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=At.active;const r=this.requestQueue.queue.shift();if(r)try{this.processRequest(r),await new Promise(s=>setTimeout(s,300))}catch(s){this.client.logger.warn(s)}}this.requestQueue.state=At.idle},this.processRequest=r=>{const{topic:s,payload:o}=r,u=o.method;switch(u){case"wc_sessionPropose":return this.onSessionProposeRequest(s,o);case"wc_sessionSettle":return this.onSessionSettleRequest(s,o);case"wc_sessionUpdate":return this.onSessionUpdateRequest(s,o);case"wc_sessionExtend":return this.onSessionExtendRequest(s,o);case"wc_sessionPing":return this.onSessionPingRequest(s,o);case"wc_sessionDelete":return this.onSessionDeleteRequest(s,o);case"wc_sessionRequest":return this.onSessionRequest(s,o);case"wc_sessionEvent":return this.onSessionEventRequest(s,o);default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async r=>{const{topic:s,payload:o}=r,u=(await this.client.core.history.get(s,o.id)).request.method;switch(u){case"wc_sessionPropose":return this.onSessionProposeResponse(s,o);case"wc_sessionSettle":return this.onSessionSettleResponse(s,o);case"wc_sessionUpdate":return this.onSessionUpdateResponse(s,o);case"wc_sessionExtend":return this.onSessionExtendResponse(s,o);case"wc_sessionPing":return this.onSessionPingResponse(s,o);case"wc_sessionRequest":return this.onSessionRequestResponse(s,o);default:return this.client.logger.info(`Unsupported response method ${u}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:s}=r,{message:o}=N("MISSING_OR_INVALID",`Decoded payload on topic ${s} is not identifiable as a JSON-RPC request or a response.`);throw new Error(o)},this.onSessionProposeRequest=async(r,s)=>{const{params:o,id:u}=s;try{this.isValidConnect(Le({},s.params));const l=ft(q.FIVE_MINUTES),g=Le({id:u,pairingTopic:r,expiry:l},o);await this.setProposal(u,g);const w=Dr(JSON.stringify(s)),b=await this.getVerifyContext(w,g.proposer.metadata);this.client.events.emit("session_proposal",{id:u,params:g,verifyContext:b})}catch(l){await this.sendError(u,r,l),this.client.logger.error(l)}},this.onSessionProposeResponse=async(r,s)=>{const{id:o}=s;if(Wt(s)){const{result:u}=s;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:u});const l=this.client.proposal.get(o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:l});const g=l.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:g});const w=u.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:w});const b=await this.client.core.crypto.generateSharedKey(g,w);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});const $=await this.client.core.relayer.subscribe(b);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:$}),await this.client.core.pairing.activate({topic:r})}else bt(s)&&(await this.client.proposal.delete(o,ye("USER_DISCONNECTED")),this.events.emit(ve("session_connect"),{error:s.error}))},this.onSessionSettleRequest=async(r,s)=>{const{id:o,params:u}=s;try{this.isValidSessionSettleRequest(u);const{relay:l,controller:g,expiry:w,namespaces:b,requiredNamespaces:$,optionalNamespaces:S,sessionProperties:R,pairingTopic:j}=s.params,x=Le({topic:r,relay:l,expiry:w,namespaces:b,acknowledged:!0,pairingTopic:j,requiredNamespaces:$,optionalNamespaces:S,controller:g.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:g.publicKey,metadata:g.metadata}},R&&{sessionProperties:R});await this.sendResult({id:s.id,topic:r,result:!0}),this.events.emit(ve("session_connect"),{session:x}),this.cleanupDuplicatePairings(x)}catch(l){await this.sendError(o,r,l),this.client.logger.error(l)}},this.onSessionSettleResponse=async(r,s)=>{const{id:o}=s;Wt(s)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(ve("session_approve",o),{})):bt(s)&&(await this.client.session.delete(r,ye("USER_DISCONNECTED")),this.events.emit(ve("session_approve",o),{error:s.error}))},this.onSessionUpdateRequest=async(r,s)=>{const{params:o,id:u}=s;try{const l=`${r}_session_update`,g=ws.get(l);if(g&&this.isRequestOutOfSync(g,u)){this.client.logger.info(`Discarding out of sync request - ${u}`);return}this.isValidUpdate(Le({topic:r},o)),await this.client.session.update(r,{namespaces:o.namespaces}),await this.sendResult({id:u,topic:r,result:!0}),this.client.events.emit("session_update",{id:u,topic:r,params:o}),ws.set(l,u)}catch(l){await this.sendError(u,r,l),this.client.logger.error(l)}},this.isRequestOutOfSync=(r,s)=>parseInt(s.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,s)=>{const{id:o}=s;Wt(s)?this.events.emit(ve("session_update",o),{}):bt(s)&&this.events.emit(ve("session_update",o),{error:s.error})},this.onSessionExtendRequest=async(r,s)=>{const{id:o}=s;try{this.isValidExtend({topic:r}),await this.setExpiry(r,ft(_s)),await this.sendResult({id:o,topic:r,result:!0}),this.client.events.emit("session_extend",{id:o,topic:r})}catch(u){await this.sendError(o,r,u),this.client.logger.error(u)}},this.onSessionExtendResponse=(r,s)=>{const{id:o}=s;Wt(s)?this.events.emit(ve("session_extend",o),{}):bt(s)&&this.events.emit(ve("session_extend",o),{error:s.error})},this.onSessionPingRequest=async(r,s)=>{const{id:o}=s;try{this.isValidPing({topic:r}),await this.sendResult({id:o,topic:r,result:!0}),this.client.events.emit("session_ping",{id:o,topic:r})}catch(u){await this.sendError(o,r,u),this.client.logger.error(u)}},this.onSessionPingResponse=(r,s)=>{const{id:o}=s;setTimeout(()=>{Wt(s)?this.events.emit(ve("session_ping",o),{}):bt(s)&&this.events.emit(ve("session_ping",o),{error:s.error})},500)},this.onSessionDeleteRequest=async(r,s)=>{const{id:o}=s;try{this.isValidDisconnect({topic:r,reason:s.params}),await Promise.all([new Promise(u=>{this.client.core.relayer.once(Re.publish,async()=>{u(await this.deleteSession(r))})}),this.sendResult({id:o,topic:r,result:!0})]),this.client.events.emit("session_delete",{id:o,topic:r})}catch(u){this.client.logger.error(u)}},this.onSessionRequest=async(r,s)=>{const{id:o,params:u}=s;try{this.isValidRequest(Le({topic:r},u));const l=Dr(JSON.stringify(Ar("wc_sessionRequest",u,o))),g=this.client.session.get(r),w=await this.getVerifyContext(l,g.peer.metadata),b={id:o,topic:r,params:u,verifyContext:w};await this.setPendingSessionRequest(b),this.addSessionRequestToSessionRequestQueue(b),this.processSessionRequestQueue()}catch(l){await this.sendError(o,r,l),this.client.logger.error(l)}},this.onSessionRequestResponse=(r,s)=>{const{id:o}=s;Wt(s)?this.events.emit(ve("session_request",o),{result:s.result}):bt(s)&&this.events.emit(ve("session_request",o),{error:s.error})},this.onSessionEventRequest=async(r,s)=>{const{id:o,params:u}=s;try{const l=`${r}_session_event_${u.event.name}`,g=ws.get(l);if(g&&this.isRequestOutOfSync(g,o)){this.client.logger.info(`Discarding out of sync request - ${o}`);return}this.isValidEmit(Le({topic:r},u)),this.client.events.emit("session_event",{id:o,topic:r,params:u}),ws.set(l,o)}catch(l){await this.sendError(o,r,l),this.client.logger.error(l)}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=At.idle,this.processSessionRequestQueue()},q.toMiliseconds(this.requestQueueDelay))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===At.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=At.active,this.client.events.emit("session_request",r)}catch(s){this.client.logger.error(s)}},this.onPairingCreated=r=>{if(r.active)return;const s=this.client.proposal.getAll().find(o=>o.pairingTopic===r.topic);s&&this.onSessionProposeRequest(r.topic,Ar("wc_sessionPropose",{requiredNamespaces:s.requiredNamespaces,optionalNamespaces:s.optionalNamespaces,relays:s.relays,proposer:s.proposer,sessionProperties:s.sessionProperties},s.id))},this.isValidConnect=async r=>{if(!ke(r)){const{message:w}=N("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(w)}const{pairingTopic:s,requiredNamespaces:o,optionalNamespaces:u,sessionProperties:l,relays:g}=r;if(xe(s)||await this.isValidPairingTopic(s),!Jb(g)){const{message:w}=N("MISSING_OR_INVALID",`connect() relays: ${g}`);throw new Error(w)}!xe(o)&&qr(o)!==0&&this.validateNamespaces(o,"requiredNamespaces"),!xe(u)&&qr(u)!==0&&this.validateNamespaces(u,"optionalNamespaces"),xe(l)||this.validateSessionProps(l,"sessionProperties")},this.validateNamespaces=(r,s)=>{const o=Qb(r,"connect()",s);if(o)throw new Error(o.message)},this.isValidApprove=async r=>{if(!ke(r))throw new Error(N("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:s,namespaces:o,relayProtocol:u,sessionProperties:l}=r;await this.isValidProposalId(s);const g=this.client.proposal.get(s),w=Ps(o,"approve()");if(w)throw new Error(w.message);const b=Ju(g.requiredNamespaces,o,"approve()");if(b)throw new Error(b.message);if(!be(u,!0)){const{message:$}=N("MISSING_OR_INVALID",`approve() relayProtocol: ${u}`);throw new Error($)}xe(l)||this.validateSessionProps(l,"sessionProperties")},this.isValidReject=async r=>{if(!ke(r)){const{message:u}=N("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(u)}const{id:s,reason:o}=r;if(await this.isValidProposalId(s),!Zb(o)){const{message:u}=N("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(o)}`);throw new Error(u)}},this.isValidSessionSettleRequest=r=>{if(!ke(r)){const{message:b}=N("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(b)}const{relay:s,controller:o,namespaces:u,expiry:l}=r;if(!al(s)){const{message:b}=N("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(b)}const g=Vb(o,"onSessionSettleRequest()");if(g)throw new Error(g.message);const w=Ps(u,"onSessionSettleRequest()");if(w)throw new Error(w.message);if(Bt(l)){const{message:b}=N("EXPIRED","onSessionSettleRequest()");throw new Error(b)}},this.isValidUpdate=async r=>{if(!ke(r)){const{message:w}=N("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(w)}const{topic:s,namespaces:o}=r;await this.isValidSessionTopic(s);const u=this.client.session.get(s),l=Ps(o,"update()");if(l)throw new Error(l.message);const g=Ju(u.requiredNamespaces,o,"update()");if(g)throw new Error(g.message)},this.isValidExtend=async r=>{if(!ke(r)){const{message:o}=N("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(o)}const{topic:s}=r;await this.isValidSessionTopic(s)},this.isValidRequest=async r=>{if(!ke(r)){const{message:w}=N("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(w)}const{topic:s,request:o,chainId:u,expiry:l}=r;await this.isValidSessionTopic(s);const{namespaces:g}=this.client.session.get(s);if(!Qu(g,u)){const{message:w}=N("MISSING_OR_INVALID",`request() chainId: ${u}`);throw new Error(w)}if(!Xb(o)){const{message:w}=N("MISSING_OR_INVALID",`request() ${JSON.stringify(o)}`);throw new Error(w)}if(!r0(g,u,o.method)){const{message:w}=N("MISSING_OR_INVALID",`request() method: ${o.method}`);throw new Error(w)}if(l&&!o0(l,fo)){const{message:w}=N("MISSING_OR_INVALID",`request() expiry: ${l}. Expiry must be a number (in seconds) between ${fo.min} and ${fo.max}`);throw new Error(w)}},this.isValidRespond=async r=>{var s;if(!ke(r)){const{message:l}=N("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(l)}const{topic:o,response:u}=r;try{await this.isValidSessionTopic(o)}catch(l){throw(s=r==null?void 0:r.response)!=null&&s.id&&this.cleanupAfterResponse(r),l}if(!e0(u)){const{message:l}=N("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(u)}`);throw new Error(l)}},this.isValidPing=async r=>{if(!ke(r)){const{message:o}=N("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(o)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.isValidEmit=async r=>{if(!ke(r)){const{message:g}=N("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(g)}const{topic:s,event:o,chainId:u}=r;await this.isValidSessionTopic(s);const{namespaces:l}=this.client.session.get(s);if(!Qu(l,u)){const{message:g}=N("MISSING_OR_INVALID",`emit() chainId: ${u}`);throw new Error(g)}if(!t0(o)){const{message:g}=N("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(g)}if(!i0(l,u,o.name)){const{message:g}=N("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(g)}},this.isValidDisconnect=async r=>{if(!ke(r)){const{message:o}=N("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(o)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.getVerifyContext=async(r,s)=>{const o={verified:{verifyUrl:s.verifyUrl||xr,validation:"UNKNOWN",origin:s.url||""}};try{const u=await this.client.core.verify.resolve({attestationId:r,verifyUrl:s.verifyUrl});u&&(o.verified.origin=u.origin,o.verified.isScam=u.isScam,o.verified.validation=u.origin===new URL(s.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.info(u)}return this.client.logger.info(`Verify context: ${JSON.stringify(o)}`),o},this.validateSessionProps=(r,s)=>{Object.values(r).forEach(o=>{if(!be(o,!1)){const{message:u}=N("MISSING_OR_INVALID",`${s} must be in Record<string, string> format. Received: ${JSON.stringify(o)}`);throw new Error(u)}})}}async isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Re.message,async t=>{const{topic:r,message:s}=t;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s)))return;const o=await this.client.core.crypto.decode(r,s);try{jo(o)?(this.client.core.history.set(r,o),this.onRelayEventRequest({topic:r,payload:o})):Ns(o)?(await this.client.core.history.resolve(o),await this.onRelayEventResponse({topic:r,payload:o}),this.client.core.history.delete(r,o.id)):this.onRelayEventUnknownPayload({topic:r,payload:o})}catch(u){this.client.logger.error(u)}})}registerExpirerEvents(){this.client.core.expirer.on(st.expired,async t=>{const{topic:r,id:s}=nl(t.target);if(s&&this.client.pendingRequest.keys.includes(s))return await this.deletePendingSessionRequest(s,N("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s}))})}registerPairingEvents(){this.client.core.pairing.events.on(mi.create,t=>this.onPairingCreated(t))}isValidPairingTopic(t){if(!be(t,!1)){const{message:r}=N("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:r}=N("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(r)}if(Bt(this.client.core.pairing.pairings.get(t).expiry)){const{message:r}=N("EXPIRED",`pairing topic: ${t}`);throw new Error(r)}}async isValidSessionTopic(t){if(!be(t,!1)){const{message:r}=N("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(r)}if(!this.client.session.keys.includes(t)){const{message:r}=N("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(r)}if(Bt(this.client.session.get(t).expiry)){await this.deleteSession(t);const{message:r}=N("EXPIRED",`session topic: ${t}`);throw new Error(r)}}async isValidSessionOrPairingTopic(t){if(this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else if(this.client.core.pairing.pairings.keys.includes(t))this.isValidPairingTopic(t);else if(be(t,!1)){const{message:r}=N("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(r)}else{const{message:r}=N("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(r)}}async isValidProposalId(t){if(!Yb(t)){const{message:r}=N("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(r)}if(!this.client.proposal.keys.includes(t)){const{message:r}=N("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(r)}if(Bt(this.client.proposal.get(t).expiry)){await this.deleteProposal(t);const{message:r}=N("EXPIRED",`proposal id: ${t}`);throw new Error(r)}}}class aI extends js{constructor(t,r){super(t,r,J1,Bo),this.core=t,this.logger=r}}class cI extends js{constructor(t,r){super(t,r,Y1,Bo),this.core=t,this.logger=r}}class uI extends js{constructor(t,r){super(t,r,X1,Bo,s=>s.id),this.core=t,this.logger=r}}let hI=class Rl extends q_{constructor(t){super(t),this.protocol=Il,this.version=Pl,this.name=po.name,this.events=new gt.EventEmitter,this.on=(s,o)=>this.events.on(s,o),this.once=(s,o)=>this.events.once(s,o),this.off=(s,o)=>this.events.off(s,o),this.removeListener=(s,o)=>this.events.removeListener(s,o),this.removeAllListeners=s=>this.events.removeAllListeners(s),this.connect=async s=>{try{return await this.engine.connect(s)}catch(o){throw this.logger.error(o.message),o}},this.pair=async s=>{try{return await this.engine.pair(s)}catch(o){throw this.logger.error(o.message),o}},this.approve=async s=>{try{return await this.engine.approve(s)}catch(o){throw this.logger.error(o.message),o}},this.reject=async s=>{try{return await this.engine.reject(s)}catch(o){throw this.logger.error(o.message),o}},this.update=async s=>{try{return await this.engine.update(s)}catch(o){throw this.logger.error(o.message),o}},this.extend=async s=>{try{return await this.engine.extend(s)}catch(o){throw this.logger.error(o.message),o}},this.request=async s=>{try{return await this.engine.request(s)}catch(o){throw this.logger.error(o.message),o}},this.respond=async s=>{try{return await this.engine.respond(s)}catch(o){throw this.logger.error(o.message),o}},this.ping=async s=>{try{return await this.engine.ping(s)}catch(o){throw this.logger.error(o.message),o}},this.emit=async s=>{try{return await this.engine.emit(s)}catch(o){throw this.logger.error(o.message),o}},this.disconnect=async s=>{try{return await this.engine.disconnect(s)}catch(o){throw this.logger.error(o.message),o}},this.find=s=>{try{return this.engine.find(s)}catch(o){throw this.logger.error(o.message),o}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(s){throw this.logger.error(s.message),s}},this.name=(t==null?void 0:t.name)||po.name,this.metadata=(t==null?void 0:t.metadata)||db();const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Ts(xs({level:(t==null?void 0:t.logger)||po.logger}));this.core=(t==null?void 0:t.core)||new Q1(t),this.logger=ze(r,this.name),this.session=new cI(this.core,this.logger),this.proposal=new aI(this.core,this.logger),this.pendingRequest=new uI(this.core,this.logger),this.engine=new oI(this)}static async init(t){const r=new Rl(t);return await r.initialize(),r}get context(){return Qe(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}};const lI=a=>JSON.stringify(a,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),pI=a=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=a.replace(t,'$1"$2n"$3');return JSON.parse(r,(s,o)=>typeof o=="string"&&o.match(/^\d+n$/)?BigInt(o.substring(0,o.length-1)):o)};function fI(a){if(typeof a!="string")throw new Error(`Cannot safe json parse value of type ${typeof a}`);try{return pI(a)}catch{return a}}function Ih(a){return typeof a=="string"?a:lI(a)||""}var dI=Object.defineProperty,gI=Object.defineProperties,yI=Object.getOwnPropertyDescriptors,Ph=Object.getOwnPropertySymbols,vI=Object.prototype.hasOwnProperty,mI=Object.prototype.propertyIsEnumerable,Sh=(a,t,r)=>t in a?dI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Oh=(a,t)=>{for(var r in t||(t={}))vI.call(t,r)&&Sh(a,r,t[r]);if(Ph)for(var r of Ph(t))mI.call(t,r)&&Sh(a,r,t[r]);return a},Rh=(a,t)=>gI(a,yI(t));const wI={Accept:"application/json","Content-Type":"application/json"},_I="POST",$h={headers:wI,method:_I},Nh=10;let Jt=class{constructor(t,r=!1){if(this.url=t,this.disableProviderPing=r,this.events=new gt.EventEmitter,this.isAvailable=!1,this.registering=!1,!Tu(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async open(t=this.url){await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t){this.isAvailable||await this.register();try{const r=Ih(t),s=await(await xu(this.url,Rh(Oh({},$h),{body:r}))).json();this.onPayload({data:s})}catch(r){this.onError(t.id,r)}}async register(t=this.url){if(!Tu(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,o)=>{this.events.once("register_error",u=>{this.resetMaxListeners(),o(u)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return o(new Error("HTTP connection is missing or invalid"));s()})})}this.url=t,this.registering=!0;try{if(!this.disableProviderPing){const r=Ih({id:1,jsonrpc:"2.0",method:"test",params:[]});await xu(t,Rh(Oh({},$h),{body:r}))}this.onOpen()}catch(r){const s=this.parseError(r);throw this.events.emit("register_error",s),this.onClose(),s}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(t){if(typeof t.data>"u")return;const r=typeof t.data=="string"?fI(t.data):t.data;this.events.emit("payload",r)}onError(t,r){const s=this.parseError(r),o=s.message||s.toString(),u=Cs(t,o);this.events.emit("payload",u)}parseError(t,r=this.url){return Kh(t,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Nh&&this.events.setMaxListeners(Nh)}};const Ch="error",bI="wss://relay.walletconnect.com",EI="wc",II="universal_provider",Th=`${EI}@2:${II}:`,PI="https://rpc.walletconnect.com/v1/",qt={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var yi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ee.global<"u"?ee.global:typeof self<"u"?self:{},Co={exports:{}};/**
21
+ Approved: ${R.toString()}`))}),l.forEach(S=>{s||(ar(o[S].methods,u[S].methods)?ar(o[S].events,u[S].events)||(s=N("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${S}`)):s=N("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${S}`))}),s}function i0(a){const t={};return Object.keys(a).forEach(r=>{var s;r.includes(":")?t[r]=a[r]:(s=a[r].chains)==null||s.forEach(o=>{t[o]={methods:a[r].methods,events:a[r].events}})}),t}function Yu(a){return[...new Set(a.map(t=>t.includes(":")?t.split(":")[0]:t))]}function s0(a){const t={};return Object.keys(a).forEach(r=>{if(r.includes(":"))t[r]=a[r];else{const s=zr(a[r].accounts);s==null||s.forEach(o=>{t[o]={accounts:a[r].accounts.filter(u=>u.includes(`${o}:`)),methods:a[r].methods,events:a[r].events}})}}),t}function n0(a,t){return Fo(a,!1)&&a<=t.max&&a>=t.min}function Zu(){const a=Ii();return new Promise(t=>{switch(a){case Ge.browser:t(o0());break;case Ge.reactNative:t(a0());break;case Ge.node:t(c0());break;default:t(!0)}})}function o0(){return kr()&&(navigator==null?void 0:navigator.onLine)}async function a0(){if(Lr()&&typeof ee.global<"u"&&ee.global!=null&&ee.global.NetInfo){const a=await(ee.global==null?void 0:ee.global.NetInfo.fetch());return a==null?void 0:a.isConnected}return!0}function c0(){return!0}function u0(a){switch(Ii()){case Ge.browser:h0(a);break;case Ge.reactNative:l0(a);break}}function h0(a){!Lr()&&kr()&&(window.addEventListener("online",()=>a(!0)),window.addEventListener("offline",()=>a(!1)))}function l0(a){var t;Lr()&&typeof ee.global<"u"&&ee.global!=null&&ee.global.NetInfo&&((t=ee.global)==null||t.NetInfo.addEventListener(r=>a(r==null?void 0:r.isConnected)))}const co={};let ws=class{static get(t){return co[t]}static set(t,r){co[t]=r}static delete(t){delete co[t]}};class Dt extends Tw{constructor(t){super(t),this.events=new ot.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async request(t,r){return this.requestStrict(Ar(t.method,t.params||[],t.id||Vh().toString()),r)}async requestStrict(t,r){return new Promise(async(s,o)=>{if(!this.connection.connected)try{await this.open()}catch(u){o(u)}this.events.on(`${t.id}`,u=>{bt(u)?o(u.error):s(u.result)});try{await this.connection.send(t,r)}catch(u){o(u)}})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),Ns(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const p0=()=>typeof WebSocket<"u"?WebSocket:typeof ee.global<"u"&&typeof ee.global.WebSocket<"u"?ee.global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),f0=()=>typeof WebSocket<"u"||typeof ee.global<"u"&&typeof ee.global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Xu=a=>a.split("?")[0],eh=10,d0=p0();let g0=class{constructor(t){if(this.url=t,this.events=new ot.EventEmitter,this.registering=!1,!Nu(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=s=>{this.onClose(s),t()},this.socket.close()})}async send(t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Qh(t))}catch(r){this.onError(t.id,r)}}register(t=this.url){if(!Nu(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,o)=>{this.events.once("register_error",u=>{this.resetMaxListeners(),o(u)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return o(new Error("WebSocket connection is missing or invalid"));s(this.socket)})})}return this.url=t,this.registering=!0,new Promise((r,s)=>{const o=new URLSearchParams(t).get("origin"),u=xw.isReactNative()?{headers:{origin:o}}:{rejectUnauthorized:!Aw(t)},l=new d0(t,[],u);f0()?l.onerror=g=>{const w=g;s(this.emitError(w.error))}:l.on("error",g=>{s(this.emitError(g))}),l.onopen=()=>{this.onOpen(l),r(l)}})}onOpen(t){t.onmessage=r=>this.onPayload(r),t.onclose=r=>this.onClose(r),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const r=typeof t.data=="string"?Gh(t.data):t.data;this.events.emit("payload",r)}onError(t,r){const s=this.parseError(r),o=s.message||s.toString(),u=Cs(t,o);this.events.emit("payload",u)}parseError(t,r=this.url){return Kh(t,Xu(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>eh&&this.events.setMaxListeners(eh)}emitError(t){const r=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${Xu(this.url)}`));return this.events.emit("register_error",r),r}};function y0(a,t){return t=t||{},new Promise(function(r,s){var o=new XMLHttpRequest,u=[],l=[],g={},w=function(){return{ok:(o.status/100|0)==2,statusText:o.statusText,status:o.status,url:o.responseURL,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(o.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([o.response]))},clone:w,headers:{keys:function(){return u},entries:function(){return l},get:function($){return g[$.toLowerCase()]},has:function($){return $.toLowerCase()in g}}}};for(var b in o.open(t.method||"get",a,!0),o.onload=function(){o.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function($,S,R){u.push(S=S.toLowerCase()),l.push([S,R]),g[S]=g[S]?g[S]+","+R:R}),r(w())},o.onerror=s,o.withCredentials=t.credentials=="include",t.headers)o.setRequestHeader(b,t.headers[b]);o.send(t.body||null)})}const v0=Object.freeze(Object.defineProperty({__proto__:null,default:y0},Symbol.toStringTag,{value:"Module"})),th=Ao(v0);var m0=self.fetch||(self.fetch=th.default||th);const w0=Ow(m0);var _0={};function b0(a,t){if(a.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var o=0;o<a.length;o++){var u=a.charAt(o),l=u.charCodeAt(0);if(r[l]!==255)throw new TypeError(u+" is ambiguous");r[l]=o}var g=a.length,w=a.charAt(0),b=Math.log(g)/Math.log(256),$=Math.log(256)/Math.log(g);function S(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var K=0,A=0,G=0,pe=x.length;G!==pe&&x[G]===0;)G++,K++;for(var J=(pe-G)*$+1>>>0,Z=new Uint8Array(J);G!==pe;){for(var ue=x[G],De=0,fe=J-1;(ue!==0||De<A)&&fe!==-1;fe--,De++)ue+=256*Z[fe]>>>0,Z[fe]=ue%g>>>0,ue=ue/g>>>0;if(ue!==0)throw new Error("Non-zero carry");A=De,G++}for(var $e=J-A;$e!==J&&Z[$e]===0;)$e++;for(var jt=w.repeat(K);$e<J;++$e)jt+=a.charAt(Z[$e]);return jt}function R(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var K=0;if(x[K]!==" "){for(var A=0,G=0;x[K]===w;)A++,K++;for(var pe=(x.length-K)*b+1>>>0,J=new Uint8Array(pe);x[K];){var Z=r[x.charCodeAt(K)];if(Z===255)return;for(var ue=0,De=pe-1;(Z!==0||ue<G)&&De!==-1;De--,ue++)Z+=g*J[De]>>>0,J[De]=Z%256>>>0,Z=Z/256>>>0;if(Z!==0)throw new Error("Non-zero carry");G=ue,K++}if(x[K]!==" "){for(var fe=pe-G;fe!==pe&&J[fe]===0;)fe++;for(var $e=new Uint8Array(A+(pe-fe)),jt=A;fe!==pe;)$e[jt++]=J[fe++];return $e}}}function j(x){var K=R(x);if(K)return K;throw new Error(`Non-${t} character`)}return{encode:S,decodeUnsafe:R,decode:j}}var E0=b0,I0=E0;const cl=a=>{if(a instanceof Uint8Array&&a.constructor.name==="Uint8Array")return a;if(a instanceof ArrayBuffer)return new Uint8Array(a);if(ArrayBuffer.isView(a))return new Uint8Array(a.buffer,a.byteOffset,a.byteLength);throw new Error("Unknown type, must be binary type")},P0=a=>new TextEncoder().encode(a),S0=a=>new TextDecoder().decode(a);class O0{constructor(t,r,s){this.name=t,this.prefix=r,this.baseEncode=s}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class R0{constructor(t,r,s){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=s}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return ul(this,t)}}class $0{constructor(t){this.decoders=t}or(t){return ul(this,t)}decode(t){const r=t[0],s=this.decoders[r];if(s)return s.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ul=(a,t)=>new $0({...a.decoders||{[a.prefix]:a},...t.decoders||{[t.prefix]:t}});class N0{constructor(t,r,s,o){this.name=t,this.prefix=r,this.baseEncode=s,this.baseDecode=o,this.encoder=new O0(t,r,s),this.decoder=new R0(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const qs=({name:a,prefix:t,encode:r,decode:s})=>new N0(a,t,r,s),Pi=({prefix:a,name:t,alphabet:r})=>{const{encode:s,decode:o}=I0(r,t);return qs({prefix:a,name:t,encode:s,decode:u=>cl(o(u))})},C0=(a,t,r,s)=>{const o={};for(let $=0;$<t.length;++$)o[t[$]]=$;let u=a.length;for(;a[u-1]==="=";)--u;const l=new Uint8Array(u*r/8|0);let g=0,w=0,b=0;for(let $=0;$<u;++$){const S=o[a[$]];if(S===void 0)throw new SyntaxError(`Non-${s} character`);w=w<<r|S,g+=r,g>=8&&(g-=8,l[b++]=255&w>>g)}if(g>=r||255&w<<8-g)throw new SyntaxError("Unexpected end of data");return l},T0=(a,t,r)=>{const s=t[t.length-1]==="=",o=(1<<r)-1;let u="",l=0,g=0;for(let w=0;w<a.length;++w)for(g=g<<8|a[w],l+=8;l>r;)l-=r,u+=t[o&g>>l];if(l&&(u+=t[o&g<<r-l]),s)for(;u.length*r&7;)u+="=";return u},Pe=({name:a,prefix:t,bitsPerChar:r,alphabet:s})=>qs({prefix:t,name:a,encode(o){return T0(o,s,r)},decode(o){return C0(o,s,r,a)}}),x0=qs({prefix:"\0",name:"identity",encode:a=>S0(a),decode:a=>P0(a)});var A0=Object.freeze({__proto__:null,identity:x0});const D0=Pe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var q0=Object.freeze({__proto__:null,base2:D0});const j0=Pe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var U0=Object.freeze({__proto__:null,base8:j0});const M0=Pi({prefix:"9",name:"base10",alphabet:"0123456789"});var L0=Object.freeze({__proto__:null,base10:M0});const k0=Pe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),z0=Pe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var H0=Object.freeze({__proto__:null,base16:k0,base16upper:z0});const V0=Pe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),K0=Pe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),F0=Pe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),W0=Pe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),B0=Pe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),G0=Pe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Q0=Pe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),J0=Pe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Y0=Pe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Z0=Object.freeze({__proto__:null,base32:V0,base32upper:K0,base32pad:F0,base32padupper:W0,base32hex:B0,base32hexupper:G0,base32hexpad:Q0,base32hexpadupper:J0,base32z:Y0});const X0=Pi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),eE=Pi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var tE=Object.freeze({__proto__:null,base36:X0,base36upper:eE});const rE=Pi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),iE=Pi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var sE=Object.freeze({__proto__:null,base58btc:rE,base58flickr:iE});const nE=Pe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),oE=Pe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),aE=Pe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cE=Pe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var uE=Object.freeze({__proto__:null,base64:nE,base64pad:oE,base64url:aE,base64urlpad:cE});const hl=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),hE=hl.reduce((a,t,r)=>(a[r]=t,a),[]),lE=hl.reduce((a,t,r)=>(a[t.codePointAt(0)]=r,a),[]);function pE(a){return a.reduce((t,r)=>(t+=hE[r],t),"")}function fE(a){const t=[];for(const r of a){const s=lE[r.codePointAt(0)];if(s===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(s)}return new Uint8Array(t)}const dE=qs({prefix:"🚀",name:"base256emoji",encode:pE,decode:fE});var gE=Object.freeze({__proto__:null,base256emoji:dE}),yE=ll,rh=128,vE=-128,mE=Math.pow(2,31);function ll(a,t,r){t=t||[],r=r||0;for(var s=r;a>=mE;)t[r++]=a&255|rh,a/=128;for(;a&vE;)t[r++]=a&255|rh,a>>>=7;return t[r]=a|0,ll.bytes=r-s+1,t}var wE=Ro,_E=128,ih=127;function Ro(a,s){var r=0,s=s||0,o=0,u=s,l,g=a.length;do{if(u>=g)throw Ro.bytes=0,new RangeError("Could not decode varint");l=a[u++],r+=o<28?(l&ih)<<o:(l&ih)*Math.pow(2,o),o+=7}while(l>=_E);return Ro.bytes=u-s,r}var bE=Math.pow(2,7),EE=Math.pow(2,14),IE=Math.pow(2,21),PE=Math.pow(2,28),SE=Math.pow(2,35),OE=Math.pow(2,42),RE=Math.pow(2,49),$E=Math.pow(2,56),NE=Math.pow(2,63),CE=function(a){return a<bE?1:a<EE?2:a<IE?3:a<PE?4:a<SE?5:a<OE?6:a<RE?7:a<$E?8:a<NE?9:10},TE={encode:yE,decode:wE,encodingLength:CE},pl=TE;const sh=(a,t,r=0)=>(pl.encode(a,t,r),t),nh=a=>pl.encodingLength(a),$o=(a,t)=>{const r=t.byteLength,s=nh(a),o=s+nh(r),u=new Uint8Array(o+r);return sh(a,u,0),sh(r,u,s),u.set(t,o),new xE(a,r,t,u)};class xE{constructor(t,r,s,o){this.code=t,this.size=r,this.digest=s,this.bytes=o}}const fl=({name:a,code:t,encode:r})=>new AE(a,t,r);class AE{constructor(t,r,s){this.name=t,this.code=r,this.encode=s}digest(t){if(t instanceof Uint8Array){const r=this.encode(t);return r instanceof Uint8Array?$o(this.code,r):r.then(s=>$o(this.code,s))}else throw Error("Unknown type, must be binary type")}}const dl=a=>async t=>new Uint8Array(await crypto.subtle.digest(a,t)),DE=fl({name:"sha2-256",code:18,encode:dl("SHA-256")}),qE=fl({name:"sha2-512",code:19,encode:dl("SHA-512")});var jE=Object.freeze({__proto__:null,sha256:DE,sha512:qE});const gl=0,UE="identity",yl=cl,ME=a=>$o(gl,yl(a)),LE={code:gl,name:UE,encode:yl,digest:ME};var kE=Object.freeze({__proto__:null,identity:LE});new TextEncoder,new TextDecoder;const oh={...A0,...q0,...U0,...L0,...H0,...Z0,...tE,...sE,...uE,...gE};({...jE,...kE});function vl(a){return globalThis.Buffer!=null?new Uint8Array(a.buffer,a.byteOffset,a.byteLength):a}function zE(a=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?vl(globalThis.Buffer.allocUnsafe(a)):new Uint8Array(a)}function ml(a,t,r,s){return{name:a,prefix:t,encoder:{name:a,prefix:t,encode:r},decoder:{decode:s}}}const ah=ml("utf8","u",a=>"u"+new TextDecoder("utf8").decode(a),a=>new TextEncoder().encode(a.substring(1))),uo=ml("ascii","a",a=>{let t="a";for(let r=0;r<a.length;r++)t+=String.fromCharCode(a[r]);return t},a=>{a=a.substring(1);const t=zE(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);return t}),HE={utf8:ah,"utf-8":ah,hex:oh.base16,latin1:uo,ascii:uo,binary:uo,...oh};function VE(a,t="utf8"){const r=HE[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?vl(globalThis.Buffer.from(a,"utf-8")):r.decoder.decode(`${r.prefix}${a}`)}const wl="wc",KE=2,_l="core",Gt=`${wl}@2:${_l}:`,FE={logger:"error"},WE={database:":memory:"},BE="crypto",ch="client_ed25519_seed",GE=q.ONE_DAY,QE="keychain",JE="0.3",YE="messages",ZE="0.3",XE=q.SIX_HOURS,e1="publisher",bl="irn",t1="error",El="wss://relay.walletconnect.com",uh="wss://relay.walletconnect.org",r1="relayer",Re={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},i1="_subscription",xt={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},s1=q.ONE_SECOND,n1="2.11.0",o1=1e4,a1="0.3",c1="WALLETCONNECT_CLIENT_ID",ft={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},u1="subscription",h1="0.3",l1=q.FIVE_SECONDS*1e3,p1="pairing",f1="0.3",pi={wc_pairingDelete:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:q.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:q.ONE_DAY,prompt:!1,tag:0},res:{ttl:q.ONE_DAY,prompt:!1,tag:0}}},mi={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},_t={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},d1="history",g1="0.3",y1="expirer",st={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},v1="0.3",ho="verify-api",xr="https://verify.walletconnect.com",No="https://verify.walletconnect.org",m1=[xr,No],w1="echo",_1="https://echo.walletconnect.com";class b1{constructor(t,r){this.core=t,this.logger=r,this.keychain=new Map,this.name=QE,this.version=JE,this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{if(!this.initialized){const s=await this.getKeyChain();typeof s<"u"&&(this.keychain=s),this.initialized=!0}},this.has=s=>(this.isInitialized(),this.keychain.has(s)),this.set=async(s,o)=>{this.isInitialized(),this.keychain.set(s,o),await this.persist()},this.get=s=>{this.isInitialized();const o=this.keychain.get(s);if(typeof o>"u"){const{message:u}=N("NO_MATCHING_KEY",`${this.name}: ${s}`);throw new Error(u)}return o},this.del=async s=>{this.isInitialized(),this.keychain.delete(s),await this.persist()},this.core=t,this.logger=ze(r,this.name)}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,rl(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?il(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class E1{constructor(t,r,s){this.core=t,this.logger=r,this.name=BE,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=o=>(this.isInitialized(),this.keychain.has(o)),this.getClientId=async()=>{this.isInitialized();const o=await this.getClientSeed(),u=Cu(o);return qw(u.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const o=Z_();return this.setPrivateKey(o.publicKey,o.privateKey)},this.signJWT=async o=>{this.isInitialized();const u=await this.getClientSeed(),l=Cu(u),g=So();return await jw(g,o,GE,l)},this.generateSharedKey=(o,u,l)=>{this.isInitialized();const g=this.getPrivateKey(o),w=X_(g,u);return this.setSymKey(w,l)},this.setSymKey=async(o,u)=>{this.isInitialized();const l=u||eb(o);return await this.keychain.set(l,o),l},this.deleteKeyPair=async o=>{this.isInitialized(),await this.keychain.del(o)},this.deleteSymKey=async o=>{this.isInitialized(),await this.keychain.del(o)},this.encode=async(o,u,l)=>{this.isInitialized();const g=tl(l),w=Qh(u);if(zu(g)){const R=g.senderPublicKey,j=g.receiverPublicKey;o=await this.generateSharedKey(R,j)}const b=this.getSymKey(o),{type:$,senderPublicKey:S}=g;return rb({type:$,symKey:b,message:w,senderPublicKey:S})},this.decode=async(o,u,l)=>{this.isInitialized();const g=nb(u,l);if(zu(g)){const w=g.receiverPublicKey,b=g.senderPublicKey;o=await this.generateSharedKey(w,b)}try{const w=this.getSymKey(o),b=ib({symKey:w,encoded:u});return Gh(b)}catch(w){this.logger.error(`Failed to decode message from topic: '${o}', clientId: '${await this.getClientId()}'`),this.logger.error(w)}},this.getPayloadType=o=>{const u=Os(o);return Ei(u.type)},this.getPayloadSenderPublicKey=o=>{const u=Os(o);return u.senderPublicKey?nt(u.senderPublicKey,Ae):void 0},this.core=t,this.logger=ze(r,this.name),this.keychain=s||new b1(this.core,this.logger)}get context(){return Qe(this.logger)}async setPrivateKey(t,r){return await this.keychain.set(t,r),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(ch)}catch{t=So(),await this.keychain.set(ch,t)}return VE(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class I1 extends O_{constructor(t,r){super(t,r),this.logger=t,this.core=r,this.messages=new Map,this.name=YE,this.version=ZE,this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const s=await this.getRelayerMessages();typeof s<"u"&&(this.messages=s),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(s){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(s)}finally{this.initialized=!0}}},this.set=async(s,o)=>{this.isInitialized();const u=Dr(o);let l=this.messages.get(s);return typeof l>"u"&&(l={}),typeof l[u]<"u"||(l[u]=o,this.messages.set(s,l),await this.persist()),u},this.get=s=>{this.isInitialized();let o=this.messages.get(s);return typeof o>"u"&&(o={}),o},this.has=(s,o)=>{this.isInitialized();const u=this.get(s),l=Dr(o);return typeof u[l]<"u"},this.del=async s=>{this.isInitialized(),this.messages.delete(s),await this.persist()},this.logger=ze(t,this.name),this.core=r}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,rl(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?il(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class P1 extends R_{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new ot.EventEmitter,this.name=e1,this.queue=new Map,this.publishTimeout=q.toMiliseconds(q.TEN_SECONDS),this.needsTransportRestart=!1,this.publish=async(s,o,u)=>{var l;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:o,opts:u}});try{const g=(u==null?void 0:u.ttl)||XE,w=Oo(u),b=(u==null?void 0:u.prompt)||!1,$=(u==null?void 0:u.tag)||0,S=(u==null?void 0:u.id)||Vh().toString(),R={topic:s,message:o,opts:{ttl:g,relay:w,prompt:b,tag:$,id:S}},j=setTimeout(()=>this.queue.set(S,R),this.publishTimeout);try{await await bi(this.rpcPublish(s,o,g,w,b,$,S),this.publishTimeout,"Failed to publish payload, please try again."),this.removeRequestFromQueue(S),this.relayer.events.emit(Re.publish,R)}catch(x){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(l=u==null?void 0:u.internal)!=null&&l.throwOnFailedPublish)throw this.removeRequestFromQueue(S),x;return}finally{clearTimeout(j)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:o,opts:u}})}catch(g){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(g),g}},this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.relayer=t,this.logger=ze(r,this.name),this.registerEventListeners()}get context(){return Qe(this.logger)}rpcPublish(t,r,s,o,u,l,g){var w,b,$,S;const R={method:Is(o.protocol).publish,params:{topic:t,message:r,ttl:s,prompt:u,tag:l},id:g};return xe((w=R.params)==null?void 0:w.prompt)&&((b=R.params)==null||delete b.prompt),xe(($=R.params)==null?void 0:$.tag)&&((S=R.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:R}),this.relayer.request(R)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{const{topic:r,message:s,opts:o}=t;await this.publish(r,s,o)})}registerEventListeners(){this.relayer.core.heartbeat.on(Ur.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Re.connection_stalled);return}this.checkQueue()}),this.relayer.on(Re.message_ack,t=>{this.removeRequestFromQueue(t.id.toString())})}}class S1{constructor(){this.map=new Map,this.set=(t,r)=>{const s=this.get(t);this.exists(t,r)||this.map.set(t,[...s,r])},this.get=t=>this.map.get(t)||[],this.exists=(t,r)=>this.get(t).includes(r),this.delete=(t,r)=>{if(typeof r>"u"){this.map.delete(t);return}if(!this.map.has(t))return;const s=this.get(t);if(!this.exists(t,r))return;const o=s.filter(u=>u!==r);if(!o.length){this.map.delete(t);return}this.map.set(t,o)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var O1=Object.defineProperty,R1=Object.defineProperties,$1=Object.getOwnPropertyDescriptors,hh=Object.getOwnPropertySymbols,N1=Object.prototype.hasOwnProperty,C1=Object.prototype.propertyIsEnumerable,lh=(a,t,r)=>t in a?O1(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,fi=(a,t)=>{for(var r in t||(t={}))N1.call(t,r)&&lh(a,r,t[r]);if(hh)for(var r of hh(t))C1.call(t,r)&&lh(a,r,t[r]);return a},lo=(a,t)=>R1(a,$1(t));class T1 extends C_{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new S1,this.events=new ot.EventEmitter,this.name=u1,this.version=h1,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Gt,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(s,o)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:o}});try{const u=Oo(o),l={topic:s,relay:u};this.pending.set(s,l);const g=await this.rpcSubscribe(s,u);return this.onSubscribe(g,l),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:o}}),g}catch(u){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(u),u}},this.unsubscribe=async(s,o)=>{await this.restartToComplete(),this.isInitialized(),typeof(o==null?void 0:o.id)<"u"?await this.unsubscribeById(s,o.id,o):await this.unsubscribeByTopic(s,o)},this.isSubscribed=async s=>this.topics.includes(s)?!0:await new Promise((o,u)=>{const l=new q.Watch;l.start(this.pendingSubscriptionWatchLabel);const g=setInterval(()=>{!this.pending.has(s)&&this.topics.includes(s)&&(clearInterval(g),l.stop(this.pendingSubscriptionWatchLabel),o(!0)),l.elapsed(this.pendingSubscriptionWatchLabel)>=l1&&(clearInterval(g),l.stop(this.pendingSubscriptionWatchLabel),u(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1),this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=ze(r,this.name),this.clientId=""}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(t,r){let s=!1;try{s=this.getSubscription(t).topic===r}catch{}return s}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,r){const s=this.topicMap.get(t);await Promise.all(s.map(async o=>await this.unsubscribeById(t,o,r)))}async unsubscribeById(t,r,s){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:s}});try{const o=Oo(s);await this.rpcUnsubscribe(t,r,o);const u=ye("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,r,u),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:s}})}catch(o){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(o),o}}async rpcSubscribe(t,r){const s={method:Is(r.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{await await bi(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Re.connection_stalled)}return Dr(t+this.clientId)}async rpcBatchSubscribe(t){if(!t.length)return;const r=t[0].relay,s={method:Is(r.protocol).batchSubscribe,params:{topics:t.map(o=>o.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{return await await bi(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Re.connection_stalled)}}rpcUnsubscribe(t,r,s){const o={method:Is(s.protocol).unsubscribe,params:{topic:t,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:o}),this.relayer.request(o)}onSubscribe(t,r){this.setSubscription(t,lo(fi({},r),{id:t})),this.pending.delete(r.topic)}onBatchSubscribe(t){t.length&&t.forEach(r=>{this.setSubscription(r.id,fi({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(t,r,s){this.events.removeAllListeners(r),this.hasSubscription(r,t)&&this.deleteSubscription(r,s),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,r){this.subscriptions.has(t)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:r}),this.addSubscription(t,r))}addSubscription(t,r){this.subscriptions.set(t,fi({},r)),this.topicMap.set(r.topic,t),this.events.emit(ft.created,r)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const r=this.subscriptions.get(t);if(!r){const{message:s}=N("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(s)}return r}deleteSubscription(t,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:r});const s=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(s.topic,t),this.events.emit(ft.deleted,lo(fi({},s),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ft.sync)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){const s=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s)}}this.events.emit(ft.resubscribed)}async restore(){try{const t=await this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){const{message:r}=N("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const r=await this.rpcBatchSubscribe(t);cr(r)&&this.onBatchSubscribe(r.map((s,o)=>lo(fi({},t[o]),{id:s})))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const t=[];this.pending.forEach(r=>{t.push(r)}),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on(Ur.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.relayer.on(Re.connect,async()=>{await this.onConnect()}),this.relayer.on(Re.disconnect,()=>{this.onDisconnect()}),this.events.on(ft.created,async t=>{const r=ft.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()}),this.events.on(ft.deleted,async t=>{const r=ft.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),t())},this.pollingInterval)})}}var x1=Object.defineProperty,ph=Object.getOwnPropertySymbols,A1=Object.prototype.hasOwnProperty,D1=Object.prototype.propertyIsEnumerable,fh=(a,t,r)=>t in a?x1(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,q1=(a,t)=>{for(var r in t||(t={}))A1.call(t,r)&&fh(a,r,t[r]);if(ph)for(var r of ph(t))D1.call(t,r)&&fh(a,r,t[r]);return a};class j1 extends $_{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new ot.EventEmitter,this.name=r1,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.request=async r=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(r)}catch(s){throw this.logger.debug("Failed to Publish Request"),this.logger.error(s),s}},this.onPayloadHandler=r=>{this.onProviderPayload(r)},this.onConnectHandler=()=>{this.events.emit(Re.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Re.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(xt.payload,this.onPayloadHandler),this.provider.on(xt.connect,this.onConnectHandler),this.provider.on(xt.disconnect,this.onDisconnectHandler),this.provider.on(xt.error,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?ze(t.logger,this.name):Ts(xs({level:t.logger||t1})),this.messages=new I1(this.logger,t.core),this.subscriber=new T1(this,this.logger),this.publisher=new P1(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||El,this.projectId=t.projectId,this.bundleId=lb(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${uh}...`),await this.restartTransport(uh)}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},o1)}get context(){return Qe(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(t,r,s){this.isInitialized(),await this.publisher.publish(t,r,s),await this.recordMessageEvent({topic:t,message:r,publishedAt:Date.now()})}async subscribe(t,r){var s;this.isInitialized();let o=((s=this.subscriber.topicMap.get(t))==null?void 0:s[0])||"";if(o)return o;let u;const l=g=>{g.topic===t&&(this.subscriber.off(ft.created,l),u())};return await Promise.all([new Promise(g=>{u=g,this.subscriber.on(ft.created,l)}),new Promise(async g=>{o=await this.subscriber.subscribe(t,r),g()})]),o}async unsubscribe(t,r){this.isInitialized(),await this.subscriber.unsubscribe(t,r)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async transportClose(){this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await bi(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect()}async transportOpen(t){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(r=>{if(!this.initialized)return r();this.subscriber.once(ft.resubscribed,()=>{r()})}),new Promise(async(r,s)=>{try{await bi(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`)}catch(o){s(o);return}r()})])}catch(r){this.logger.error(r);const s=r;if(!this.isConnectionStalled(s.message))throw r;this.provider.events.emit(xt.disconnect)}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1}}}async restartTransport(t){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=t||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Zu())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(t){return this.staleConnectionErrors.some(r=>t.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Dt(new g0(vb({sdkVersion:n1,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:r,message:s}=t;await this.messages.set(r,s)}async shouldIgnoreMessageEvent(t){const{topic:r,message:s}=t;if(!s||s.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${s}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const o=this.messages.has(r,s);return o&&this.logger.debug(`Ignoring duplicate message: ${s}`),o}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),jo(t)){if(!t.method.endsWith(i1))return;const r=t.params,{topic:s,message:o,publishedAt:u}=r.data,l={topic:s,message:o,publishedAt:u};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(q1({type:"event",event:r.id},l)),this.events.emit(r.id,l),await this.acknowledgePayload(t),await this.onMessageEvent(l)}else Ns(t)&&this.events.emit(Re.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(Re.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const r=As(t.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(xt.payload,this.onPayloadHandler),this.provider.off(xt.connect,this.onConnectHandler),this.provider.off(xt.disconnect,this.onDisconnectHandler),this.provider.off(xt.error,this.onProviderErrorHandler)}async registerEventListeners(){this.events.on(Re.connection_stalled,()=>{this.restartTransport().catch(r=>this.logger.error(r))});let t=await Zu();u0(async r=>{this.initialized&&t!==r&&(t=r,r?await this.restartTransport().catch(s=>this.logger.error(s)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(s=>this.logger.error(s))))})}onProviderDisconnect(){this.events.emit(Re.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(t=>this.logger.error(t))},q.toMiliseconds(s1)))}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(t=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),t())},this.connectionStatusPollingInterval)});await this.restartTransport()}}}var U1=Object.defineProperty,dh=Object.getOwnPropertySymbols,M1=Object.prototype.hasOwnProperty,L1=Object.prototype.propertyIsEnumerable,gh=(a,t,r)=>t in a?U1(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,yh=(a,t)=>{for(var r in t||(t={}))M1.call(t,r)&&gh(a,r,t[r]);if(dh)for(var r of dh(t))L1.call(t,r)&&gh(a,r,t[r]);return a};class js extends N_{constructor(t,r,s,o=Gt,u=void 0){super(t,r,s,o),this.core=t,this.logger=r,this.name=s,this.map=new Map,this.version=a1,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(l=>{this.getKey&&l!==null&&!xe(l)?this.map.set(this.getKey(l),l):kb(l)?this.map.set(l.id,l):zb(l)&&this.map.set(l.topic,l)}),this.cached=[],this.initialized=!0)},this.set=async(l,g)=>{this.isInitialized(),this.map.has(l)?await this.update(l,g):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:l,value:g}),this.map.set(l,g),await this.persist())},this.get=l=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:l}),this.getData(l)),this.getAll=l=>(this.isInitialized(),l?this.values.filter(g=>Object.keys(l).every(w=>Uw(g[w],l[w]))):this.values),this.update=async(l,g)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:l,update:g});const w=yh(yh({},this.getData(l)),g);this.map.set(l,w),await this.persist()},this.delete=async(l,g)=>{this.isInitialized(),this.map.has(l)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:l,reason:g}),this.map.delete(l),await this.persist())},this.logger=ze(r,this.name),this.storagePrefix=o,this.getKey=u}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const r=this.map.get(t);if(!r){const{message:s}=N("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:r}=N("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class k1{constructor(t,r){this.core=t,this.logger=r,this.name=p1,this.version=f1,this.events=new Do,this.initialized=!1,this.storagePrefix=Gt,this.ignoredPayloadTypes=[pr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:s})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...s])]},this.create=async()=>{this.isInitialized();const s=So(),o=await this.core.crypto.setSymKey(s),u=dt(q.FIVE_MINUTES),l={protocol:bl},g={topic:o,expiry:u,relay:l,active:!1},w=Cb({protocol:this.core.protocol,version:this.core.version,topic:o,symKey:s,relay:l});return await this.pairings.set(o,g),await this.core.relayer.subscribe(o),this.core.expirer.set(o,u),{topic:o,uri:w}},this.pair=async s=>{this.isInitialized(),this.isValidPair(s);const{topic:o,symKey:u,relay:l}=Bu(s.uri);let g;if(this.pairings.keys.includes(o)&&(g=this.pairings.get(o),g.active))throw new Error(`Pairing already exists: ${o}. Please try again with a new connection URI.`);const w=dt(q.FIVE_MINUTES),b={topic:o,relay:l,expiry:w,active:!1};return await this.pairings.set(o,b),this.core.expirer.set(o,w),s.activatePairing&&await this.activate({topic:o}),this.events.emit(mi.create,b),this.core.crypto.keychain.has(o)||(await this.core.crypto.setSymKey(u,o),await this.core.relayer.subscribe(o,{relay:l})),b},this.activate=async({topic:s})=>{this.isInitialized();const o=dt(q.THIRTY_DAYS);await this.pairings.update(s,{active:!0,expiry:o}),this.core.expirer.set(s,o)},this.ping=async s=>{this.isInitialized(),await this.isValidPing(s);const{topic:o}=s;if(this.pairings.keys.includes(o)){const u=await this.sendRequest(o,"wc_pairingPing",{}),{done:l,resolve:g,reject:w}=Tr();this.events.once(ve("pairing_ping",u),({error:b})=>{b?w(b):g()}),await l()}},this.updateExpiry=async({topic:s,expiry:o})=>{this.isInitialized(),await this.pairings.update(s,{expiry:o})},this.updateMetadata=async({topic:s,metadata:o})=>{this.isInitialized(),await this.pairings.update(s,{peerMetadata:o})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async s=>{this.isInitialized(),await this.isValidDisconnect(s);const{topic:o}=s;this.pairings.keys.includes(o)&&(await this.sendRequest(o,"wc_pairingDelete",ye("USER_DISCONNECTED")),await this.deletePairing(o))},this.sendRequest=async(s,o,u)=>{const l=Ar(o,u),g=await this.core.crypto.encode(s,l),w=pi[o].req;return this.core.history.set(s,l),this.core.relayer.publish(s,g,w),l.id},this.sendResult=async(s,o,u)=>{const l=As(s,u),g=await this.core.crypto.encode(o,l),w=await this.core.history.get(o,s),b=pi[w.request.method].res;await this.core.relayer.publish(o,g,b),await this.core.history.resolve(l)},this.sendError=async(s,o,u)=>{const l=Cs(s,u),g=await this.core.crypto.encode(o,l),w=await this.core.history.get(o,s),b=pi[w.request.method]?pi[w.request.method].res:pi.unregistered_method.res;await this.core.relayer.publish(o,g,b),await this.core.history.resolve(l)},this.deletePairing=async(s,o)=>{await this.core.relayer.unsubscribe(s),await Promise.all([this.pairings.delete(s,ye("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(s),o?Promise.resolve():this.core.expirer.del(s)])},this.cleanup=async()=>{const s=this.pairings.getAll().filter(o=>Bt(o.expiry));await Promise.all(s.map(o=>this.deletePairing(o.topic)))},this.onRelayEventRequest=s=>{const{topic:o,payload:u}=s;switch(u.method){case"wc_pairingPing":return this.onPairingPingRequest(o,u);case"wc_pairingDelete":return this.onPairingDeleteRequest(o,u);default:return this.onUnknownRpcMethodRequest(o,u)}},this.onRelayEventResponse=async s=>{const{topic:o,payload:u}=s,l=(await this.core.history.get(o,u.id)).request.method;switch(l){case"wc_pairingPing":return this.onPairingPingResponse(o,u);default:return this.onUnknownRpcMethodResponse(l)}},this.onPairingPingRequest=async(s,o)=>{const{id:u}=o;try{this.isValidPing({topic:s}),await this.sendResult(u,s,!0),this.events.emit(mi.ping,{id:u,topic:s})}catch(l){await this.sendError(u,s,l),this.logger.error(l)}},this.onPairingPingResponse=(s,o)=>{const{id:u}=o;setTimeout(()=>{Wt(o)?this.events.emit(ve("pairing_ping",u),{}):bt(o)&&this.events.emit(ve("pairing_ping",u),{error:o.error})},500)},this.onPairingDeleteRequest=async(s,o)=>{const{id:u}=o;try{this.isValidDisconnect({topic:s}),await this.deletePairing(s),this.events.emit(mi.delete,{id:u,topic:s})}catch(l){await this.sendError(u,s,l),this.logger.error(l)}},this.onUnknownRpcMethodRequest=async(s,o)=>{const{id:u,method:l}=o;try{if(this.registeredMethods.includes(l))return;const g=ye("WC_METHOD_UNSUPPORTED",l);await this.sendError(u,s,g),this.logger.error(g)}catch(g){await this.sendError(u,s,g),this.logger.error(g)}},this.onUnknownRpcMethodResponse=s=>{this.registeredMethods.includes(s)||this.logger.error(ye("WC_METHOD_UNSUPPORTED",s))},this.isValidPair=s=>{var o;if(!ke(s)){const{message:l}=N("MISSING_OR_INVALID",`pair() params: ${s}`);throw new Error(l)}if(!Lb(s.uri)){const{message:l}=N("MISSING_OR_INVALID",`pair() uri: ${s.uri}`);throw new Error(l)}const u=Bu(s.uri);if(!((o=u==null?void 0:u.relay)!=null&&o.protocol)){const{message:l}=N("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(l)}if(!(u!=null&&u.symKey)){const{message:l}=N("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(l)}},this.isValidPing=async s=>{if(!ke(s)){const{message:u}=N("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(u)}const{topic:o}=s;await this.isValidPairingTopic(o)},this.isValidDisconnect=async s=>{if(!ke(s)){const{message:u}=N("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(u)}const{topic:o}=s;await this.isValidPairingTopic(o)},this.isValidPairingTopic=async s=>{if(!be(s,!1)){const{message:o}=N("MISSING_OR_INVALID",`pairing topic should be a string: ${s}`);throw new Error(o)}if(!this.pairings.keys.includes(s)){const{message:o}=N("NO_MATCHING_KEY",`pairing topic doesn't exist: ${s}`);throw new Error(o)}if(Bt(this.pairings.get(s).expiry)){await this.deletePairing(s);const{message:o}=N("EXPIRED",`pairing topic: ${s}`);throw new Error(o)}},this.core=t,this.logger=ze(r,this.name),this.pairings=new js(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Qe(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(Re.message,async t=>{const{topic:r,message:s}=t;if(!this.pairings.keys.includes(r)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(s)))return;const o=await this.core.crypto.decode(r,s);try{jo(o)?(this.core.history.set(r,o),this.onRelayEventRequest({topic:r,payload:o})):Ns(o)&&(await this.core.history.resolve(o),await this.onRelayEventResponse({topic:r,payload:o}),this.core.history.delete(r,o.id))}catch(u){this.logger.error(u)}})}registerExpirerEvents(){this.core.expirer.on(st.expired,async t=>{const{topic:r}=nl(t.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(mi.expire,{topic:r}))})}}class z1 extends S_{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new ot.EventEmitter,this.name=d1,this.version=g1,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.records.set(s.id,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(s,o,u)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:s,request:o,chainId:u}),this.records.has(o.id))return;const l={id:o.id,topic:s,request:{method:o.method,params:o.params||null},chainId:u,expiry:dt(q.THIRTY_DAYS)};this.records.set(l.id,l),this.events.emit(_t.created,l)},this.resolve=async s=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:s}),!this.records.has(s.id))return;const o=await this.getRecord(s.id);typeof o.response>"u"&&(o.response=bt(s)?{error:s.error}:{result:s.result},this.records.set(o.id,o),this.events.emit(_t.updated,o))},this.get=async(s,o)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:s,id:o}),await this.getRecord(o)),this.delete=(s,o)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:o}),this.values.forEach(u=>{if(u.topic===s){if(typeof o<"u"&&u.id!==o)return;this.records.delete(u.id),this.events.emit(_t.deleted,u)}})},this.exists=async(s,o)=>(this.isInitialized(),this.records.has(o)?(await this.getRecord(o)).topic===s:!1),this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.logger=ze(r,this.name)}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const t=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const s={topic:r.topic,request:Ar(r.request.method,r.request.params,r.id),chainId:r.chainId};return t.push(s)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const r=this.records.get(t);if(!r){const{message:s}=N("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(s)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(_t.sync)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:r}=N("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(_t.created,t=>{const r=_t.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(_t.updated,t=>{const r=_t.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(_t.deleted,t=>{const r=_t.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.core.heartbeat.on(Ur.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(t=>{q.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.delete(t.topic,t.id))})}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class H1 extends T_{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new ot.EventEmitter,this.name=y1,this.version=v1,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.expirations.set(s.target,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=s=>{try{const o=this.formatTarget(s);return typeof this.getExpiration(o)<"u"}catch{return!1}},this.set=(s,o)=>{this.isInitialized();const u=this.formatTarget(s),l={target:u,expiry:o};this.expirations.set(u,l),this.checkExpiry(u,l),this.events.emit(st.created,{target:u,expiration:l})},this.get=s=>{this.isInitialized();const o=this.formatTarget(s);return this.getExpiration(o)},this.del=s=>{if(this.isInitialized(),this.has(s)){const o=this.formatTarget(s),u=this.getExpiration(o);this.expirations.delete(o),this.events.emit(st.deleted,{target:o,expiration:u})}},this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.logger=ze(r,this.name)}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(t){if(typeof t=="string")return mb(t);if(typeof t=="number")return wb(t);const{message:r}=N("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(r)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(st.sync)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:r}=N("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const r=this.expirations.get(t);if(!r){const{message:s}=N("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}return r}checkExpiry(t,r){const{expiry:s}=r;q.toMiliseconds(s)-Date.now()<=0&&this.expire(t,r)}expire(t,r){this.expirations.delete(t),this.events.emit(st.expired,{target:t,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,r)=>this.checkExpiry(r,t))}registerEventListeners(){this.core.heartbeat.on(Ur.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(st.created,t=>{const r=st.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on(st.expired,t=>{const r=st.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on(st.deleted,t=>{const r=st.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}}}class V1 extends x_{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.name=ho,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async s=>{if(this.verifyDisabled||Lr()||!kr())return;const o=this.getVerifyUrl(s==null?void 0:s.verifyUrl);this.verifyUrl!==o&&this.removeIframe(),this.verifyUrl=o;try{await this.createIframe()}catch(u){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(u)}if(!this.initialized){this.removeIframe(),this.verifyUrl=No;try{await this.createIframe()}catch(u){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(u),this.verifyDisabled=!0}}},this.register=async s=>{this.initialized?this.sendPost(s.attestationId):(this.addToQueue(s.attestationId),await this.init())},this.resolve=async s=>{if(this.isDevEnv)return"";const o=this.getVerifyUrl(s==null?void 0:s.verifyUrl);let u;try{u=await this.fetchAttestation(s.attestationId,o)}catch(l){this.logger.info(`failed to resolve attestation: ${s.attestationId} from url: ${o}`),this.logger.info(l),u=await this.fetchAttestation(s.attestationId,No)}return u},this.fetchAttestation=async(s,o)=>{this.logger.info(`resolving attestation: ${s} from url: ${o}`);const u=this.startAbortTimer(q.ONE_SECOND*2),l=await fetch(`${o}/attestation/${s}`,{signal:this.abortController.signal});return clearTimeout(u),l.status===200?await l.json():void 0},this.addToQueue=s=>{this.queue.push(s)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(s=>this.sendPost(s)),this.queue=[])},this.sendPost=s=>{var o;try{if(!this.iframe)return;(o=this.iframe.contentWindow)==null||o.postMessage(s,"*"),this.logger.info(`postMessage sent: ${s} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let s;const o=u=>{u.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",o),s())};await Promise.race([new Promise(u=>{if(document.getElementById(ho))return u();window.addEventListener("message",o);const l=document.createElement("iframe");l.id=ho,l.src=`${this.verifyUrl}/${this.projectId}`,l.style.display="none",document.body.append(l),this.iframe=l,s=u}),new Promise((u,l)=>setTimeout(()=>{window.removeEventListener("message",o),l("verify iframe load timeout")},q.toMiliseconds(q.FIVE_SECONDS)))])},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=s=>{let o=s||xr;return m1.includes(o)||(this.logger.info(`verify url: ${o}, not included in trusted list, assigning default: ${xr}`),o=xr),o},this.logger=ze(r,this.name),this.verifyUrl=xr,this.abortController=new AbortController,this.isDevEnv=Vo()&&_0.IS_VITEST}get context(){return Qe(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),q.toMiliseconds(t))}}class K1 extends A_{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.context=w1,this.registerDeviceToken=async s=>{const{clientId:o,token:u,notificationType:l,enableEncrypted:g=!1}=s,w=`${_1}/${this.projectId}/clients`;await w0(w,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:o,type:l,token:u,always_raw:g})})},this.logger=ze(r,this.context)}}var F1=Object.defineProperty,vh=Object.getOwnPropertySymbols,W1=Object.prototype.hasOwnProperty,B1=Object.prototype.propertyIsEnumerable,mh=(a,t,r)=>t in a?F1(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,wh=(a,t)=>{for(var r in t||(t={}))W1.call(t,r)&&mh(a,r,t[r]);if(vh)for(var r of vh(t))B1.call(t,r)&&mh(a,r,t[r]);return a};class Wo extends P_{constructor(t){super(t),this.protocol=wl,this.version=KE,this.name=_l,this.events=new ot.EventEmitter,this.initialized=!1,this.on=(s,o)=>this.events.on(s,o),this.once=(s,o)=>this.events.once(s,o),this.off=(s,o)=>this.events.off(s,o),this.removeListener=(s,o)=>this.events.removeListener(s,o),this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||El,this.customStoragePrefix=t!=null&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Ts(xs({level:(t==null?void 0:t.logger)||FE.logger}));this.logger=ze(r,this.name),this.heartbeat=new Ur.HeartBeat,this.crypto=new E1(this,this.logger,t==null?void 0:t.keychain),this.history=new z1(this,this.logger),this.expirer=new H1(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new Dw(wh(wh({},WE),t==null?void 0:t.storageOptions)),this.relayer=new j1({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new k1(this,this.logger),this.verify=new V1(this.projectId||"",this.logger),this.echoClient=new K1(this.projectId||"",this.logger)}static async init(t){const r=new Wo(t);await r.initialize();const s=await r.crypto.getClientId();return await r.storage.setItem(c1,s),r}get context(){return Qe(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}}const G1=Wo,Il="wc",Pl=2,Sl="client",Bo=`${Il}@${Pl}:${Sl}:`,po={name:Sl,logger:"error"},_h="WALLETCONNECT_DEEPLINK_CHOICE",Q1="proposal",Ol="Proposal expired",J1="session",_s=q.SEVEN_DAYS,Y1="engine",di={wc_sessionPropose:{req:{ttl:q.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1104},res:{ttl:q.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1106},res:{ttl:q.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:q.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:q.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1112},res:{ttl:q.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1115}}},fo={min:q.FIVE_MINUTES,max:q.SEVEN_DAYS},At={idle:"IDLE",active:"ACTIVE"},Z1="request",X1=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var eI=Object.defineProperty,tI=Object.defineProperties,rI=Object.getOwnPropertyDescriptors,bh=Object.getOwnPropertySymbols,iI=Object.prototype.hasOwnProperty,sI=Object.prototype.propertyIsEnumerable,Eh=(a,t,r)=>t in a?eI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Le=(a,t)=>{for(var r in t||(t={}))iI.call(t,r)&&Eh(a,r,t[r]);if(bh)for(var r of bh(t))sI.call(t,r)&&Eh(a,r,t[r]);return a},gi=(a,t)=>tI(a,rI(t));class nI extends q_{constructor(t){super(t),this.name=Y1,this.events=new Do,this.initialized=!1,this.ignoredPayloadTypes=[pr],this.requestQueue={state:At.idle,queue:[]},this.sessionRequestQueue={state:At.idle,queue:[]},this.requestQueueDelay=q.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(di)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},q.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{await this.isInitialized();const s=gi(Le({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(s);const{pairingTopic:o,requiredNamespaces:u,optionalNamespaces:l,sessionProperties:g,relays:w}=s;let b=o,$,S=!1;if(b&&(S=this.client.core.pairing.pairings.get(b).active),!b||!S){const{topic:J,uri:Z}=await this.client.core.pairing.create();b=J,$=Z}const R=await this.client.core.crypto.generateKeyPair(),j=Le({requiredNamespaces:u,optionalNamespaces:l,relays:w??[{protocol:bl}],proposer:{publicKey:R,metadata:this.client.metadata}},g&&{sessionProperties:g}),{reject:x,resolve:K,done:A}=Tr(q.FIVE_MINUTES,Ol);if(this.events.once(ve("session_connect"),async({error:J,session:Z})=>{if(J)x(J);else if(Z){Z.self.publicKey=R;const ue=gi(Le({},Z),{requiredNamespaces:Z.requiredNamespaces,optionalNamespaces:Z.optionalNamespaces});await this.client.session.set(Z.topic,ue),await this.setExpiry(Z.topic,Z.expiry),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:Z.peer.metadata}),K(ue)}}),!b){const{message:J}=N("NO_MATCHING_KEY",`connect() pairing topic: ${b}`);throw new Error(J)}const G=await this.sendRequest({topic:b,method:"wc_sessionPropose",params:j}),pe=dt(q.FIVE_MINUTES);return await this.setProposal(G,Le({id:G,expiry:pe},j)),{uri:$,approval:A}},this.pair=async r=>(await this.isInitialized(),await this.client.core.pairing.pair(r)),this.approve=async r=>{await this.isInitialized(),await this.isValidApprove(r);const{id:s,relayProtocol:o,namespaces:u,sessionProperties:l}=r,g=this.client.proposal.get(s);let{pairingTopic:w,proposer:b,requiredNamespaces:$,optionalNamespaces:S}=g;w=w||"",qr($)||($=Db(u,"approve()"));const R=await this.client.core.crypto.generateKeyPair(),j=b.publicKey,x=await this.client.core.crypto.generateSharedKey(R,j);w&&s&&(await this.client.core.pairing.updateMetadata({topic:w,metadata:b.metadata}),await this.sendResult({id:s,topic:w,result:{relay:{protocol:o??"irn"},responderPublicKey:R}}),await this.client.proposal.delete(s,ye("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:w}));const K=Le({relay:{protocol:o??"irn"},namespaces:u,requiredNamespaces:$,optionalNamespaces:S,pairingTopic:w,controller:{publicKey:R,metadata:this.client.metadata},expiry:dt(_s)},l&&{sessionProperties:l});await this.client.core.relayer.subscribe(x),await this.sendRequest({topic:x,method:"wc_sessionSettle",params:K,throwOnFailedPublish:!0});const A=gi(Le({},K),{topic:x,pairingTopic:w,acknowledged:!1,self:K.controller,peer:{publicKey:b.publicKey,metadata:b.metadata},controller:R});return await this.client.session.set(x,A),await this.setExpiry(x,dt(_s)),{topic:x,acknowledged:()=>new Promise(G=>setTimeout(()=>G(this.client.session.get(x)),500))}},this.reject=async r=>{await this.isInitialized(),await this.isValidReject(r);const{id:s,reason:o}=r,{pairingTopic:u}=this.client.proposal.get(s);u&&(await this.sendError(s,u,o),await this.client.proposal.delete(s,ye("USER_DISCONNECTED")))},this.update=async r=>{await this.isInitialized(),await this.isValidUpdate(r);const{topic:s,namespaces:o}=r,u=await this.sendRequest({topic:s,method:"wc_sessionUpdate",params:{namespaces:o}}),{done:l,resolve:g,reject:w}=Tr();return this.events.once(ve("session_update",u),({error:b})=>{b?w(b):g()}),await this.client.session.update(s,{namespaces:o}),{acknowledged:l}},this.extend=async r=>{await this.isInitialized(),await this.isValidExtend(r);const{topic:s}=r,o=await this.sendRequest({topic:s,method:"wc_sessionExtend",params:{}}),{done:u,resolve:l,reject:g}=Tr();return this.events.once(ve("session_extend",o),({error:w})=>{w?g(w):l()}),await this.setExpiry(s,dt(_s)),{acknowledged:u}},this.request=async r=>{await this.isInitialized(),await this.isValidRequest(r);const{chainId:s,request:o,topic:u,expiry:l}=r,g=Mw(),{done:w,resolve:b,reject:$}=Tr(l,"Request expired. Please try again.");return this.events.once(ve("session_request",g),({error:S,result:R})=>{S?$(S):b(R)}),await Promise.all([new Promise(async S=>{await this.sendRequest({clientRpcId:g,topic:u,method:"wc_sessionRequest",params:{request:o,chainId:s},expiry:l,throwOnFailedPublish:!0}).catch(R=>$(R)),this.client.events.emit("session_request_sent",{topic:u,request:o,chainId:s,id:g}),S()}),new Promise(async S=>{const R=await bb(this.client.core.storage,_h);_b({id:g,topic:u,wcDeepLink:R}),S()}),w()]).then(S=>S[2])},this.respond=async r=>{await this.isInitialized(),await this.isValidRespond(r);const{topic:s,response:o}=r,{id:u}=o;Wt(o)?await this.sendResult({id:u,topic:s,result:o.result,throwOnFailedPublish:!0}):bt(o)&&await this.sendError(u,s,o.error),this.cleanupAfterResponse(r)},this.ping=async r=>{await this.isInitialized(),await this.isValidPing(r);const{topic:s}=r;if(this.client.session.keys.includes(s)){const o=await this.sendRequest({topic:s,method:"wc_sessionPing",params:{}}),{done:u,resolve:l,reject:g}=Tr();this.events.once(ve("session_ping",o),({error:w})=>{w?g(w):l()}),await u()}else this.client.core.pairing.pairings.keys.includes(s)&&await this.client.core.pairing.ping({topic:s})},this.emit=async r=>{await this.isInitialized(),await this.isValidEmit(r);const{topic:s,event:o,chainId:u}=r;await this.sendRequest({topic:s,method:"wc_sessionEvent",params:{event:o,chainId:u}})},this.disconnect=async r=>{await this.isInitialized(),await this.isValidDisconnect(r);const{topic:s}=r;this.client.session.keys.includes(s)?(await this.sendRequest({topic:s,method:"wc_sessionDelete",params:ye("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession(s)):await this.client.core.pairing.disconnect({topic:s})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(s=>Ub(s,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{const s=this.client.core.pairing.pairings.get(r.pairingTopic),o=this.client.core.pairing.pairings.getAll().filter(u=>{var l,g;return((l=u.peerMetadata)==null?void 0:l.url)&&((g=u.peerMetadata)==null?void 0:g.url)===r.peer.metadata.url&&u.topic&&u.topic!==s.topic});if(o.length===0)return;this.client.logger.info(`Cleaning up ${o.length} duplicate pairing(s)`),await Promise.all(o.map(u=>this.client.core.pairing.disconnect({topic:u.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(s){this.client.logger.error(s)}},this.deleteSession=async(r,s)=>{const{self:o}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),this.client.session.delete(r,ye("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),s||this.client.core.expirer.del(r),this.client.core.storage.removeItem(_h).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===r&&this.deletePendingSessionRequest(u.id,ye("USER_DISCONNECTED"))})},this.deleteProposal=async(r,s)=>{await Promise.all([this.client.proposal.delete(r,ye("USER_DISCONNECTED")),s?Promise.resolve():this.client.core.expirer.del(r)])},this.deletePendingSessionRequest=async(r,s,o=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,s),o?Promise.resolve():this.client.core.expirer.del(r)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(u=>u.id!==r),o&&(this.sessionRequestQueue.state=At.idle)},this.setExpiry=async(r,s)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:s}),this.client.core.expirer.set(r,s)},this.setProposal=async(r,s)=>{await this.client.proposal.set(r,s),this.client.core.expirer.set(r,s.expiry)},this.setPendingSessionRequest=async r=>{const s=di.wc_sessionRequest.req.ttl,{id:o,topic:u,params:l,verifyContext:g}=r;await this.client.pendingRequest.set(o,{id:o,topic:u,params:l,verifyContext:g}),s&&this.client.core.expirer.set(o,dt(s))},this.sendRequest=async r=>{const{topic:s,method:o,params:u,expiry:l,relayRpcId:g,clientRpcId:w,throwOnFailedPublish:b}=r,$=Ar(o,u,w);if(kr()&&X1.includes(o)){const j=Dr(JSON.stringify($));this.client.core.verify.register({attestationId:j})}const S=await this.client.core.crypto.encode(s,$),R=di[o].req;return l&&(R.ttl=l),g&&(R.id=g),this.client.core.history.set(s,$),b?(R.internal=gi(Le({},R.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,S,R)):this.client.core.relayer.publish(s,S,R).catch(j=>this.client.logger.error(j)),$.id},this.sendResult=async r=>{const{id:s,topic:o,result:u,throwOnFailedPublish:l}=r,g=As(s,u),w=await this.client.core.crypto.encode(o,g),b=await this.client.core.history.get(o,s),$=di[b.request.method].res;l?($.internal=gi(Le({},$.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(o,w,$)):this.client.core.relayer.publish(o,w,$).catch(S=>this.client.logger.error(S)),await this.client.core.history.resolve(g)},this.sendError=async(r,s,o)=>{const u=Cs(r,o),l=await this.client.core.crypto.encode(s,u),g=await this.client.core.history.get(s,r),w=di[g.request.method].res;this.client.core.relayer.publish(s,l,w),await this.client.core.history.resolve(u)},this.cleanup=async()=>{const r=[],s=[];this.client.session.getAll().forEach(o=>{Bt(o.expiry)&&r.push(o.topic)}),this.client.proposal.getAll().forEach(o=>{Bt(o.expiry)&&s.push(o.id)}),await Promise.all([...r.map(o=>this.deleteSession(o)),...s.map(o=>this.deleteProposal(o))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===At.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=At.active;const r=this.requestQueue.queue.shift();if(r)try{this.processRequest(r),await new Promise(s=>setTimeout(s,300))}catch(s){this.client.logger.warn(s)}}this.requestQueue.state=At.idle},this.processRequest=r=>{const{topic:s,payload:o}=r,u=o.method;switch(u){case"wc_sessionPropose":return this.onSessionProposeRequest(s,o);case"wc_sessionSettle":return this.onSessionSettleRequest(s,o);case"wc_sessionUpdate":return this.onSessionUpdateRequest(s,o);case"wc_sessionExtend":return this.onSessionExtendRequest(s,o);case"wc_sessionPing":return this.onSessionPingRequest(s,o);case"wc_sessionDelete":return this.onSessionDeleteRequest(s,o);case"wc_sessionRequest":return this.onSessionRequest(s,o);case"wc_sessionEvent":return this.onSessionEventRequest(s,o);default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async r=>{const{topic:s,payload:o}=r,u=(await this.client.core.history.get(s,o.id)).request.method;switch(u){case"wc_sessionPropose":return this.onSessionProposeResponse(s,o);case"wc_sessionSettle":return this.onSessionSettleResponse(s,o);case"wc_sessionUpdate":return this.onSessionUpdateResponse(s,o);case"wc_sessionExtend":return this.onSessionExtendResponse(s,o);case"wc_sessionPing":return this.onSessionPingResponse(s,o);case"wc_sessionRequest":return this.onSessionRequestResponse(s,o);default:return this.client.logger.info(`Unsupported response method ${u}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:s}=r,{message:o}=N("MISSING_OR_INVALID",`Decoded payload on topic ${s} is not identifiable as a JSON-RPC request or a response.`);throw new Error(o)},this.onSessionProposeRequest=async(r,s)=>{const{params:o,id:u}=s;try{this.isValidConnect(Le({},s.params));const l=dt(q.FIVE_MINUTES),g=Le({id:u,pairingTopic:r,expiry:l},o);await this.setProposal(u,g);const w=Dr(JSON.stringify(s)),b=await this.getVerifyContext(w,g.proposer.metadata);this.client.events.emit("session_proposal",{id:u,params:g,verifyContext:b})}catch(l){await this.sendError(u,r,l),this.client.logger.error(l)}},this.onSessionProposeResponse=async(r,s)=>{const{id:o}=s;if(Wt(s)){const{result:u}=s;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:u});const l=this.client.proposal.get(o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:l});const g=l.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:g});const w=u.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:w});const b=await this.client.core.crypto.generateSharedKey(g,w);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});const $=await this.client.core.relayer.subscribe(b);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:$}),await this.client.core.pairing.activate({topic:r})}else bt(s)&&(await this.client.proposal.delete(o,ye("USER_DISCONNECTED")),this.events.emit(ve("session_connect"),{error:s.error}))},this.onSessionSettleRequest=async(r,s)=>{const{id:o,params:u}=s;try{this.isValidSessionSettleRequest(u);const{relay:l,controller:g,expiry:w,namespaces:b,requiredNamespaces:$,optionalNamespaces:S,sessionProperties:R,pairingTopic:j}=s.params,x=Le({topic:r,relay:l,expiry:w,namespaces:b,acknowledged:!0,pairingTopic:j,requiredNamespaces:$,optionalNamespaces:S,controller:g.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:g.publicKey,metadata:g.metadata}},R&&{sessionProperties:R});await this.sendResult({id:s.id,topic:r,result:!0}),this.events.emit(ve("session_connect"),{session:x}),this.cleanupDuplicatePairings(x)}catch(l){await this.sendError(o,r,l),this.client.logger.error(l)}},this.onSessionSettleResponse=async(r,s)=>{const{id:o}=s;Wt(s)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(ve("session_approve",o),{})):bt(s)&&(await this.client.session.delete(r,ye("USER_DISCONNECTED")),this.events.emit(ve("session_approve",o),{error:s.error}))},this.onSessionUpdateRequest=async(r,s)=>{const{params:o,id:u}=s;try{const l=`${r}_session_update`,g=ws.get(l);if(g&&this.isRequestOutOfSync(g,u)){this.client.logger.info(`Discarding out of sync request - ${u}`);return}this.isValidUpdate(Le({topic:r},o)),await this.client.session.update(r,{namespaces:o.namespaces}),await this.sendResult({id:u,topic:r,result:!0}),this.client.events.emit("session_update",{id:u,topic:r,params:o}),ws.set(l,u)}catch(l){await this.sendError(u,r,l),this.client.logger.error(l)}},this.isRequestOutOfSync=(r,s)=>parseInt(s.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,s)=>{const{id:o}=s;Wt(s)?this.events.emit(ve("session_update",o),{}):bt(s)&&this.events.emit(ve("session_update",o),{error:s.error})},this.onSessionExtendRequest=async(r,s)=>{const{id:o}=s;try{this.isValidExtend({topic:r}),await this.setExpiry(r,dt(_s)),await this.sendResult({id:o,topic:r,result:!0}),this.client.events.emit("session_extend",{id:o,topic:r})}catch(u){await this.sendError(o,r,u),this.client.logger.error(u)}},this.onSessionExtendResponse=(r,s)=>{const{id:o}=s;Wt(s)?this.events.emit(ve("session_extend",o),{}):bt(s)&&this.events.emit(ve("session_extend",o),{error:s.error})},this.onSessionPingRequest=async(r,s)=>{const{id:o}=s;try{this.isValidPing({topic:r}),await this.sendResult({id:o,topic:r,result:!0}),this.client.events.emit("session_ping",{id:o,topic:r})}catch(u){await this.sendError(o,r,u),this.client.logger.error(u)}},this.onSessionPingResponse=(r,s)=>{const{id:o}=s;setTimeout(()=>{Wt(s)?this.events.emit(ve("session_ping",o),{}):bt(s)&&this.events.emit(ve("session_ping",o),{error:s.error})},500)},this.onSessionDeleteRequest=async(r,s)=>{const{id:o}=s;try{this.isValidDisconnect({topic:r,reason:s.params}),await Promise.all([new Promise(u=>{this.client.core.relayer.once(Re.publish,async()=>{u(await this.deleteSession(r))})}),this.sendResult({id:o,topic:r,result:!0})]),this.client.events.emit("session_delete",{id:o,topic:r})}catch(u){this.client.logger.error(u)}},this.onSessionRequest=async(r,s)=>{const{id:o,params:u}=s;try{this.isValidRequest(Le({topic:r},u));const l=Dr(JSON.stringify(Ar("wc_sessionRequest",u,o))),g=this.client.session.get(r),w=await this.getVerifyContext(l,g.peer.metadata),b={id:o,topic:r,params:u,verifyContext:w};await this.setPendingSessionRequest(b),this.addSessionRequestToSessionRequestQueue(b),this.processSessionRequestQueue()}catch(l){await this.sendError(o,r,l),this.client.logger.error(l)}},this.onSessionRequestResponse=(r,s)=>{const{id:o}=s;Wt(s)?this.events.emit(ve("session_request",o),{result:s.result}):bt(s)&&this.events.emit(ve("session_request",o),{error:s.error})},this.onSessionEventRequest=async(r,s)=>{const{id:o,params:u}=s;try{const l=`${r}_session_event_${u.event.name}`,g=ws.get(l);if(g&&this.isRequestOutOfSync(g,o)){this.client.logger.info(`Discarding out of sync request - ${o}`);return}this.isValidEmit(Le({topic:r},u)),this.client.events.emit("session_event",{id:o,topic:r,params:u}),ws.set(l,o)}catch(l){await this.sendError(o,r,l),this.client.logger.error(l)}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=At.idle,this.processSessionRequestQueue()},q.toMiliseconds(this.requestQueueDelay))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===At.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=At.active,this.client.events.emit("session_request",r)}catch(s){this.client.logger.error(s)}},this.onPairingCreated=r=>{if(r.active)return;const s=this.client.proposal.getAll().find(o=>o.pairingTopic===r.topic);s&&this.onSessionProposeRequest(r.topic,Ar("wc_sessionPropose",{requiredNamespaces:s.requiredNamespaces,optionalNamespaces:s.optionalNamespaces,relays:s.relays,proposer:s.proposer,sessionProperties:s.sessionProperties},s.id))},this.isValidConnect=async r=>{if(!ke(r)){const{message:w}=N("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(w)}const{pairingTopic:s,requiredNamespaces:o,optionalNamespaces:u,sessionProperties:l,relays:g}=r;if(xe(s)||await this.isValidPairingTopic(s),!Qb(g)){const{message:w}=N("MISSING_OR_INVALID",`connect() relays: ${g}`);throw new Error(w)}!xe(o)&&qr(o)!==0&&this.validateNamespaces(o,"requiredNamespaces"),!xe(u)&&qr(u)!==0&&this.validateNamespaces(u,"optionalNamespaces"),xe(l)||this.validateSessionProps(l,"sessionProperties")},this.validateNamespaces=(r,s)=>{const o=Gb(r,"connect()",s);if(o)throw new Error(o.message)},this.isValidApprove=async r=>{if(!ke(r))throw new Error(N("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:s,namespaces:o,relayProtocol:u,sessionProperties:l}=r;await this.isValidProposalId(s);const g=this.client.proposal.get(s),w=Ps(o,"approve()");if(w)throw new Error(w.message);const b=Ju(g.requiredNamespaces,o,"approve()");if(b)throw new Error(b.message);if(!be(u,!0)){const{message:$}=N("MISSING_OR_INVALID",`approve() relayProtocol: ${u}`);throw new Error($)}xe(l)||this.validateSessionProps(l,"sessionProperties")},this.isValidReject=async r=>{if(!ke(r)){const{message:u}=N("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(u)}const{id:s,reason:o}=r;if(await this.isValidProposalId(s),!Yb(o)){const{message:u}=N("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(o)}`);throw new Error(u)}},this.isValidSessionSettleRequest=r=>{if(!ke(r)){const{message:b}=N("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(b)}const{relay:s,controller:o,namespaces:u,expiry:l}=r;if(!al(s)){const{message:b}=N("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(b)}const g=Hb(o,"onSessionSettleRequest()");if(g)throw new Error(g.message);const w=Ps(u,"onSessionSettleRequest()");if(w)throw new Error(w.message);if(Bt(l)){const{message:b}=N("EXPIRED","onSessionSettleRequest()");throw new Error(b)}},this.isValidUpdate=async r=>{if(!ke(r)){const{message:w}=N("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(w)}const{topic:s,namespaces:o}=r;await this.isValidSessionTopic(s);const u=this.client.session.get(s),l=Ps(o,"update()");if(l)throw new Error(l.message);const g=Ju(u.requiredNamespaces,o,"update()");if(g)throw new Error(g.message)},this.isValidExtend=async r=>{if(!ke(r)){const{message:o}=N("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(o)}const{topic:s}=r;await this.isValidSessionTopic(s)},this.isValidRequest=async r=>{if(!ke(r)){const{message:w}=N("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(w)}const{topic:s,request:o,chainId:u,expiry:l}=r;await this.isValidSessionTopic(s);const{namespaces:g}=this.client.session.get(s);if(!Qu(g,u)){const{message:w}=N("MISSING_OR_INVALID",`request() chainId: ${u}`);throw new Error(w)}if(!Zb(o)){const{message:w}=N("MISSING_OR_INVALID",`request() ${JSON.stringify(o)}`);throw new Error(w)}if(!t0(g,u,o.method)){const{message:w}=N("MISSING_OR_INVALID",`request() method: ${o.method}`);throw new Error(w)}if(l&&!n0(l,fo)){const{message:w}=N("MISSING_OR_INVALID",`request() expiry: ${l}. Expiry must be a number (in seconds) between ${fo.min} and ${fo.max}`);throw new Error(w)}},this.isValidRespond=async r=>{var s;if(!ke(r)){const{message:l}=N("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(l)}const{topic:o,response:u}=r;try{await this.isValidSessionTopic(o)}catch(l){throw(s=r==null?void 0:r.response)!=null&&s.id&&this.cleanupAfterResponse(r),l}if(!Xb(u)){const{message:l}=N("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(u)}`);throw new Error(l)}},this.isValidPing=async r=>{if(!ke(r)){const{message:o}=N("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(o)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.isValidEmit=async r=>{if(!ke(r)){const{message:g}=N("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(g)}const{topic:s,event:o,chainId:u}=r;await this.isValidSessionTopic(s);const{namespaces:l}=this.client.session.get(s);if(!Qu(l,u)){const{message:g}=N("MISSING_OR_INVALID",`emit() chainId: ${u}`);throw new Error(g)}if(!e0(o)){const{message:g}=N("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(g)}if(!r0(l,u,o.name)){const{message:g}=N("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(g)}},this.isValidDisconnect=async r=>{if(!ke(r)){const{message:o}=N("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(o)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.getVerifyContext=async(r,s)=>{const o={verified:{verifyUrl:s.verifyUrl||xr,validation:"UNKNOWN",origin:s.url||""}};try{const u=await this.client.core.verify.resolve({attestationId:r,verifyUrl:s.verifyUrl});u&&(o.verified.origin=u.origin,o.verified.isScam=u.isScam,o.verified.validation=u.origin===new URL(s.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.info(u)}return this.client.logger.info(`Verify context: ${JSON.stringify(o)}`),o},this.validateSessionProps=(r,s)=>{Object.values(r).forEach(o=>{if(!be(o,!1)){const{message:u}=N("MISSING_OR_INVALID",`${s} must be in Record<string, string> format. Received: ${JSON.stringify(o)}`);throw new Error(u)}})}}async isInitialized(){if(!this.initialized){const{message:t}=N("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Re.message,async t=>{const{topic:r,message:s}=t;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s)))return;const o=await this.client.core.crypto.decode(r,s);try{jo(o)?(this.client.core.history.set(r,o),this.onRelayEventRequest({topic:r,payload:o})):Ns(o)?(await this.client.core.history.resolve(o),await this.onRelayEventResponse({topic:r,payload:o}),this.client.core.history.delete(r,o.id)):this.onRelayEventUnknownPayload({topic:r,payload:o})}catch(u){this.client.logger.error(u)}})}registerExpirerEvents(){this.client.core.expirer.on(st.expired,async t=>{const{topic:r,id:s}=nl(t.target);if(s&&this.client.pendingRequest.keys.includes(s))return await this.deletePendingSessionRequest(s,N("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s}))})}registerPairingEvents(){this.client.core.pairing.events.on(mi.create,t=>this.onPairingCreated(t))}isValidPairingTopic(t){if(!be(t,!1)){const{message:r}=N("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:r}=N("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(r)}if(Bt(this.client.core.pairing.pairings.get(t).expiry)){const{message:r}=N("EXPIRED",`pairing topic: ${t}`);throw new Error(r)}}async isValidSessionTopic(t){if(!be(t,!1)){const{message:r}=N("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(r)}if(!this.client.session.keys.includes(t)){const{message:r}=N("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(r)}if(Bt(this.client.session.get(t).expiry)){await this.deleteSession(t);const{message:r}=N("EXPIRED",`session topic: ${t}`);throw new Error(r)}}async isValidSessionOrPairingTopic(t){if(this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else if(this.client.core.pairing.pairings.keys.includes(t))this.isValidPairingTopic(t);else if(be(t,!1)){const{message:r}=N("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(r)}else{const{message:r}=N("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(r)}}async isValidProposalId(t){if(!Jb(t)){const{message:r}=N("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(r)}if(!this.client.proposal.keys.includes(t)){const{message:r}=N("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(r)}if(Bt(this.client.proposal.get(t).expiry)){await this.deleteProposal(t);const{message:r}=N("EXPIRED",`proposal id: ${t}`);throw new Error(r)}}}class oI extends js{constructor(t,r){super(t,r,Q1,Bo),this.core=t,this.logger=r}}class aI extends js{constructor(t,r){super(t,r,J1,Bo),this.core=t,this.logger=r}}class cI extends js{constructor(t,r){super(t,r,Z1,Bo,s=>s.id),this.core=t,this.logger=r}}let uI=class Rl extends D_{constructor(t){super(t),this.protocol=Il,this.version=Pl,this.name=po.name,this.events=new ot.EventEmitter,this.on=(s,o)=>this.events.on(s,o),this.once=(s,o)=>this.events.once(s,o),this.off=(s,o)=>this.events.off(s,o),this.removeListener=(s,o)=>this.events.removeListener(s,o),this.removeAllListeners=s=>this.events.removeAllListeners(s),this.connect=async s=>{try{return await this.engine.connect(s)}catch(o){throw this.logger.error(o.message),o}},this.pair=async s=>{try{return await this.engine.pair(s)}catch(o){throw this.logger.error(o.message),o}},this.approve=async s=>{try{return await this.engine.approve(s)}catch(o){throw this.logger.error(o.message),o}},this.reject=async s=>{try{return await this.engine.reject(s)}catch(o){throw this.logger.error(o.message),o}},this.update=async s=>{try{return await this.engine.update(s)}catch(o){throw this.logger.error(o.message),o}},this.extend=async s=>{try{return await this.engine.extend(s)}catch(o){throw this.logger.error(o.message),o}},this.request=async s=>{try{return await this.engine.request(s)}catch(o){throw this.logger.error(o.message),o}},this.respond=async s=>{try{return await this.engine.respond(s)}catch(o){throw this.logger.error(o.message),o}},this.ping=async s=>{try{return await this.engine.ping(s)}catch(o){throw this.logger.error(o.message),o}},this.emit=async s=>{try{return await this.engine.emit(s)}catch(o){throw this.logger.error(o.message),o}},this.disconnect=async s=>{try{return await this.engine.disconnect(s)}catch(o){throw this.logger.error(o.message),o}},this.find=s=>{try{return this.engine.find(s)}catch(o){throw this.logger.error(o.message),o}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(s){throw this.logger.error(s.message),s}},this.name=(t==null?void 0:t.name)||po.name,this.metadata=(t==null?void 0:t.metadata)||fb();const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Ts(xs({level:(t==null?void 0:t.logger)||po.logger}));this.core=(t==null?void 0:t.core)||new G1(t),this.logger=ze(r,this.name),this.session=new aI(this.core,this.logger),this.proposal=new oI(this.core,this.logger),this.pendingRequest=new cI(this.core,this.logger),this.engine=new nI(this)}static async init(t){const r=new Rl(t);return await r.initialize(),r}get context(){return Qe(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}};const hI=a=>JSON.stringify(a,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),lI=a=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=a.replace(t,'$1"$2n"$3');return JSON.parse(r,(s,o)=>typeof o=="string"&&o.match(/^\d+n$/)?BigInt(o.substring(0,o.length-1)):o)};function pI(a){if(typeof a!="string")throw new Error(`Cannot safe json parse value of type ${typeof a}`);try{return lI(a)}catch{return a}}function Ih(a){return typeof a=="string"?a:hI(a)||""}var fI=Object.defineProperty,dI=Object.defineProperties,gI=Object.getOwnPropertyDescriptors,Ph=Object.getOwnPropertySymbols,yI=Object.prototype.hasOwnProperty,vI=Object.prototype.propertyIsEnumerable,Sh=(a,t,r)=>t in a?fI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Oh=(a,t)=>{for(var r in t||(t={}))yI.call(t,r)&&Sh(a,r,t[r]);if(Ph)for(var r of Ph(t))vI.call(t,r)&&Sh(a,r,t[r]);return a},Rh=(a,t)=>dI(a,gI(t));const mI={Accept:"application/json","Content-Type":"application/json"},wI="POST",$h={headers:mI,method:wI},Nh=10;let Jt=class{constructor(t,r=!1){if(this.url=t,this.disableProviderPing=r,this.events=new ot.EventEmitter,this.isAvailable=!1,this.registering=!1,!Tu(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async open(t=this.url){await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t){this.isAvailable||await this.register();try{const r=Ih(t),s=await(await xu(this.url,Rh(Oh({},$h),{body:r}))).json();this.onPayload({data:s})}catch(r){this.onError(t.id,r)}}async register(t=this.url){if(!Tu(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,o)=>{this.events.once("register_error",u=>{this.resetMaxListeners(),o(u)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return o(new Error("HTTP connection is missing or invalid"));s()})})}this.url=t,this.registering=!0;try{if(!this.disableProviderPing){const r=Ih({id:1,jsonrpc:"2.0",method:"test",params:[]});await xu(t,Rh(Oh({},$h),{body:r}))}this.onOpen()}catch(r){const s=this.parseError(r);throw this.events.emit("register_error",s),this.onClose(),s}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(t){if(typeof t.data>"u")return;const r=typeof t.data=="string"?pI(t.data):t.data;this.events.emit("payload",r)}onError(t,r){const s=this.parseError(r),o=s.message||s.toString(),u=Cs(t,o);this.events.emit("payload",u)}parseError(t,r=this.url){return Kh(t,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Nh&&this.events.setMaxListeners(Nh)}};const Ch="error",_I="wss://relay.walletconnect.com",bI="wc",EI="universal_provider",Th=`${bI}@2:${EI}:`,II="https://rpc.walletconnect.com/v1/",qt={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var yi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ee.global<"u"?ee.global:typeof self<"u"?self:{},Co={exports:{}};/**
22
22
  * @license
23
23
  * Lodash <https://lodash.com/>
24
24
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
25
25
  * Released under MIT license <https://lodash.com/license>
26
26
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
27
27
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
28
- */(function(a,t){(function(){var r,s="4.17.21",o=200,u="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",g="Invalid `variable` option passed into `_.template`",w="__lodash_hash_undefined__",b=500,$="__lodash_placeholder__",S=1,R=2,j=4,x=1,K=2,A=1,G=2,pe=4,J=8,Z=16,ue=32,De=64,fe=128,$e=256,jt=512,Cl=30,Tl="...",xl=800,Al=16,Jo=1,Dl=2,ql=3,Si=1/0,dr=9007199254740991,jl=17976931348623157e292,Oi=NaN,yt=4294967295,Ul=yt-1,Ml=yt>>>1,Ll=[["ary",fe],["bind",A],["bindKey",G],["curry",J],["curryRight",Z],["flip",jt],["partial",ue],["partialRight",De],["rearg",$e]],gr="[object Arguments]",Ri="[object Array]",kl="[object AsyncFunction]",Hr="[object Boolean]",Vr="[object Date]",zl="[object DOMException]",$i="[object Error]",Ni="[object Function]",Yo="[object GeneratorFunction]",ot="[object Map]",Kr="[object Number]",Hl="[object Null]",Et="[object Object]",Zo="[object Promise]",Vl="[object Proxy]",Fr="[object RegExp]",at="[object Set]",Wr="[object String]",Ci="[object Symbol]",Kl="[object Undefined]",Br="[object WeakMap]",Fl="[object WeakSet]",Gr="[object ArrayBuffer]",yr="[object DataView]",Us="[object Float32Array]",Ms="[object Float64Array]",Ls="[object Int8Array]",ks="[object Int16Array]",zs="[object Int32Array]",Hs="[object Uint8Array]",Vs="[object Uint8ClampedArray]",Ks="[object Uint16Array]",Fs="[object Uint32Array]",Wl=/\b__p \+= '';/g,Bl=/\b(__p \+=) '' \+/g,Gl=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Xo=/&(?:amp|lt|gt|quot|#39);/g,ea=/[&<>"']/g,Ql=RegExp(Xo.source),Jl=RegExp(ea.source),Yl=/<%-([\s\S]+?)%>/g,Zl=/<%([\s\S]+?)%>/g,ta=/<%=([\s\S]+?)%>/g,Xl=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ep=/^\w*$/,tp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ws=/[\\^$.*+?()[\]{}|]/g,rp=RegExp(Ws.source),Bs=/^\s+/,ip=/\s/,sp=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,np=/\{\n\/\* \[wrapped with (.+)\] \*/,op=/,? & /,ap=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,cp=/[()=,{}\[\]\/\s]/,up=/\\(\\)?/g,hp=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ra=/\w*$/,lp=/^[-+]0x[0-9a-f]+$/i,pp=/^0b[01]+$/i,fp=/^\[object .+?Constructor\]$/,dp=/^0o[0-7]+$/i,gp=/^(?:0|[1-9]\d*)$/,yp=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ti=/($^)/,vp=/['\n\r\u2028\u2029\\]/g,xi="\\ud800-\\udfff",mp="\\u0300-\\u036f",wp="\\ufe20-\\ufe2f",_p="\\u20d0-\\u20ff",ia=mp+wp+_p,sa="\\u2700-\\u27bf",na="a-z\\xdf-\\xf6\\xf8-\\xff",bp="\\xac\\xb1\\xd7\\xf7",Ep="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Ip="\\u2000-\\u206f",Pp=" \\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",oa="A-Z\\xc0-\\xd6\\xd8-\\xde",aa="\\ufe0e\\ufe0f",ca=bp+Ep+Ip+Pp,Gs="['’]",Sp="["+xi+"]",ua="["+ca+"]",Ai="["+ia+"]",ha="\\d+",Op="["+sa+"]",la="["+na+"]",pa="[^"+xi+ca+ha+sa+na+oa+"]",Qs="\\ud83c[\\udffb-\\udfff]",Rp="(?:"+Ai+"|"+Qs+")",fa="[^"+xi+"]",Js="(?:\\ud83c[\\udde6-\\uddff]){2}",Ys="[\\ud800-\\udbff][\\udc00-\\udfff]",vr="["+oa+"]",da="\\u200d",ga="(?:"+la+"|"+pa+")",$p="(?:"+vr+"|"+pa+")",ya="(?:"+Gs+"(?:d|ll|m|re|s|t|ve))?",va="(?:"+Gs+"(?:D|LL|M|RE|S|T|VE))?",ma=Rp+"?",wa="["+aa+"]?",Np="(?:"+da+"(?:"+[fa,Js,Ys].join("|")+")"+wa+ma+")*",Cp="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Tp="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",_a=wa+ma+Np,xp="(?:"+[Op,Js,Ys].join("|")+")"+_a,Ap="(?:"+[fa+Ai+"?",Ai,Js,Ys,Sp].join("|")+")",Dp=RegExp(Gs,"g"),qp=RegExp(Ai,"g"),Zs=RegExp(Qs+"(?="+Qs+")|"+Ap+_a,"g"),jp=RegExp([vr+"?"+la+"+"+ya+"(?="+[ua,vr,"$"].join("|")+")",$p+"+"+va+"(?="+[ua,vr+ga,"$"].join("|")+")",vr+"?"+ga+"+"+ya,vr+"+"+va,Tp,Cp,ha,xp].join("|"),"g"),Up=RegExp("["+da+xi+ia+aa+"]"),Mp=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Lp=["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"],kp=-1,oe={};oe[Us]=oe[Ms]=oe[Ls]=oe[ks]=oe[zs]=oe[Hs]=oe[Vs]=oe[Ks]=oe[Fs]=!0,oe[gr]=oe[Ri]=oe[Gr]=oe[Hr]=oe[yr]=oe[Vr]=oe[$i]=oe[Ni]=oe[ot]=oe[Kr]=oe[Et]=oe[Fr]=oe[at]=oe[Wr]=oe[Br]=!1;var ie={};ie[gr]=ie[Ri]=ie[Gr]=ie[yr]=ie[Hr]=ie[Vr]=ie[Us]=ie[Ms]=ie[Ls]=ie[ks]=ie[zs]=ie[ot]=ie[Kr]=ie[Et]=ie[Fr]=ie[at]=ie[Wr]=ie[Ci]=ie[Hs]=ie[Vs]=ie[Ks]=ie[Fs]=!0,ie[$i]=ie[Ni]=ie[Br]=!1;var zp={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Hp={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Vp={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Kp={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Fp=parseFloat,Wp=parseInt,ba=typeof yi=="object"&&yi&&yi.Object===Object&&yi,Bp=typeof self=="object"&&self&&self.Object===Object&&self,Ee=ba||Bp||Function("return this")(),Xs=t&&!t.nodeType&&t,Yt=Xs&&!0&&a&&!a.nodeType&&a,Ea=Yt&&Yt.exports===Xs,en=Ea&&ba.process,Je=function(){try{var v=Yt&&Yt.require&&Yt.require("util").types;return v||en&&en.binding&&en.binding("util")}catch{}}(),Ia=Je&&Je.isArrayBuffer,Pa=Je&&Je.isDate,Sa=Je&&Je.isMap,Oa=Je&&Je.isRegExp,Ra=Je&&Je.isSet,$a=Je&&Je.isTypedArray;function He(v,E,_){switch(_.length){case 0:return v.call(E);case 1:return v.call(E,_[0]);case 2:return v.call(E,_[0],_[1]);case 3:return v.call(E,_[0],_[1],_[2])}return v.apply(E,_)}function Gp(v,E,_,T){for(var k=-1,Y=v==null?0:v.length;++k<Y;){var me=v[k];E(T,me,_(me),v)}return T}function Ye(v,E){for(var _=-1,T=v==null?0:v.length;++_<T&&E(v[_],_,v)!==!1;);return v}function Qp(v,E){for(var _=v==null?0:v.length;_--&&E(v[_],_,v)!==!1;);return v}function Na(v,E){for(var _=-1,T=v==null?0:v.length;++_<T;)if(!E(v[_],_,v))return!1;return!0}function Ut(v,E){for(var _=-1,T=v==null?0:v.length,k=0,Y=[];++_<T;){var me=v[_];E(me,_,v)&&(Y[k++]=me)}return Y}function Di(v,E){var _=v==null?0:v.length;return!!_&&mr(v,E,0)>-1}function tn(v,E,_){for(var T=-1,k=v==null?0:v.length;++T<k;)if(_(E,v[T]))return!0;return!1}function ae(v,E){for(var _=-1,T=v==null?0:v.length,k=Array(T);++_<T;)k[_]=E(v[_],_,v);return k}function Mt(v,E){for(var _=-1,T=E.length,k=v.length;++_<T;)v[k+_]=E[_];return v}function rn(v,E,_,T){var k=-1,Y=v==null?0:v.length;for(T&&Y&&(_=v[++k]);++k<Y;)_=E(_,v[k],k,v);return _}function Jp(v,E,_,T){var k=v==null?0:v.length;for(T&&k&&(_=v[--k]);k--;)_=E(_,v[k],k,v);return _}function sn(v,E){for(var _=-1,T=v==null?0:v.length;++_<T;)if(E(v[_],_,v))return!0;return!1}var Yp=nn("length");function Zp(v){return v.split("")}function Xp(v){return v.match(ap)||[]}function Ca(v,E,_){var T;return _(v,function(k,Y,me){if(E(k,Y,me))return T=Y,!1}),T}function qi(v,E,_,T){for(var k=v.length,Y=_+(T?1:-1);T?Y--:++Y<k;)if(E(v[Y],Y,v))return Y;return-1}function mr(v,E,_){return E===E?pf(v,E,_):qi(v,Ta,_)}function ef(v,E,_,T){for(var k=_-1,Y=v.length;++k<Y;)if(T(v[k],E))return k;return-1}function Ta(v){return v!==v}function xa(v,E){var _=v==null?0:v.length;return _?an(v,E)/_:Oi}function nn(v){return function(E){return E==null?r:E[v]}}function on(v){return function(E){return v==null?r:v[E]}}function Aa(v,E,_,T,k){return k(v,function(Y,me,re){_=T?(T=!1,Y):E(_,Y,me,re)}),_}function tf(v,E){var _=v.length;for(v.sort(E);_--;)v[_]=v[_].value;return v}function an(v,E){for(var _,T=-1,k=v.length;++T<k;){var Y=E(v[T]);Y!==r&&(_=_===r?Y:_+Y)}return _}function cn(v,E){for(var _=-1,T=Array(v);++_<v;)T[_]=E(_);return T}function rf(v,E){return ae(E,function(_){return[_,v[_]]})}function Da(v){return v&&v.slice(0,Ma(v)+1).replace(Bs,"")}function Ve(v){return function(E){return v(E)}}function un(v,E){return ae(E,function(_){return v[_]})}function Qr(v,E){return v.has(E)}function qa(v,E){for(var _=-1,T=v.length;++_<T&&mr(E,v[_],0)>-1;);return _}function ja(v,E){for(var _=v.length;_--&&mr(E,v[_],0)>-1;);return _}function sf(v,E){for(var _=v.length,T=0;_--;)v[_]===E&&++T;return T}var nf=on(zp),of=on(Hp);function af(v){return"\\"+Kp[v]}function cf(v,E){return v==null?r:v[E]}function wr(v){return Up.test(v)}function uf(v){return Mp.test(v)}function hf(v){for(var E,_=[];!(E=v.next()).done;)_.push(E.value);return _}function hn(v){var E=-1,_=Array(v.size);return v.forEach(function(T,k){_[++E]=[k,T]}),_}function Ua(v,E){return function(_){return v(E(_))}}function Lt(v,E){for(var _=-1,T=v.length,k=0,Y=[];++_<T;){var me=v[_];(me===E||me===$)&&(v[_]=$,Y[k++]=_)}return Y}function ji(v){var E=-1,_=Array(v.size);return v.forEach(function(T){_[++E]=T}),_}function lf(v){var E=-1,_=Array(v.size);return v.forEach(function(T){_[++E]=[T,T]}),_}function pf(v,E,_){for(var T=_-1,k=v.length;++T<k;)if(v[T]===E)return T;return-1}function ff(v,E,_){for(var T=_+1;T--;)if(v[T]===E)return T;return T}function _r(v){return wr(v)?gf(v):Yp(v)}function ct(v){return wr(v)?yf(v):Zp(v)}function Ma(v){for(var E=v.length;E--&&ip.test(v.charAt(E)););return E}var df=on(Vp);function gf(v){for(var E=Zs.lastIndex=0;Zs.test(v);)++E;return E}function yf(v){return v.match(Zs)||[]}function vf(v){return v.match(jp)||[]}var mf=function v(E){E=E==null?Ee:br.defaults(Ee.Object(),E,br.pick(Ee,Lp));var _=E.Array,T=E.Date,k=E.Error,Y=E.Function,me=E.Math,re=E.Object,ln=E.RegExp,wf=E.String,Ze=E.TypeError,Ui=_.prototype,_f=Y.prototype,Er=re.prototype,Mi=E["__core-js_shared__"],Li=_f.toString,te=Er.hasOwnProperty,bf=0,La=function(){var e=/[^.]+$/.exec(Mi&&Mi.keys&&Mi.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ki=Er.toString,Ef=Li.call(re),If=Ee._,Pf=ln("^"+Li.call(te).replace(Ws,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),zi=Ea?E.Buffer:r,kt=E.Symbol,Hi=E.Uint8Array,ka=zi?zi.allocUnsafe:r,Vi=Ua(re.getPrototypeOf,re),za=re.create,Ha=Er.propertyIsEnumerable,Ki=Ui.splice,Va=kt?kt.isConcatSpreadable:r,Jr=kt?kt.iterator:r,Zt=kt?kt.toStringTag:r,Fi=function(){try{var e=ir(re,"defineProperty");return e({},"",{}),e}catch{}}(),Sf=E.clearTimeout!==Ee.clearTimeout&&E.clearTimeout,Of=T&&T.now!==Ee.Date.now&&T.now,Rf=E.setTimeout!==Ee.setTimeout&&E.setTimeout,Wi=me.ceil,Bi=me.floor,pn=re.getOwnPropertySymbols,$f=zi?zi.isBuffer:r,Ka=E.isFinite,Nf=Ui.join,Cf=Ua(re.keys,re),we=me.max,Se=me.min,Tf=T.now,xf=E.parseInt,Fa=me.random,Af=Ui.reverse,fn=ir(E,"DataView"),Yr=ir(E,"Map"),dn=ir(E,"Promise"),Ir=ir(E,"Set"),Zr=ir(E,"WeakMap"),Xr=ir(re,"create"),Gi=Zr&&new Zr,Pr={},Df=sr(fn),qf=sr(Yr),jf=sr(dn),Uf=sr(Ir),Mf=sr(Zr),Qi=kt?kt.prototype:r,ei=Qi?Qi.valueOf:r,Wa=Qi?Qi.toString:r;function p(e){if(le(e)&&!z(e)&&!(e instanceof B)){if(e instanceof Xe)return e;if(te.call(e,"__wrapped__"))return Bc(e)}return new Xe(e)}var Sr=function(){function e(){}return function(i){if(!he(i))return{};if(za)return za(i);e.prototype=i;var n=new e;return e.prototype=r,n}}();function Ji(){}function Xe(e,i){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!i,this.__index__=0,this.__values__=r}p.templateSettings={escape:Yl,evaluate:Zl,interpolate:ta,variable:"",imports:{_:p}},p.prototype=Ji.prototype,p.prototype.constructor=p,Xe.prototype=Sr(Ji.prototype),Xe.prototype.constructor=Xe;function B(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=yt,this.__views__=[]}function Lf(){var e=new B(this.__wrapped__);return e.__actions__=qe(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=qe(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=qe(this.__views__),e}function kf(){if(this.__filtered__){var e=new B(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function zf(){var e=this.__wrapped__.value(),i=this.__dir__,n=z(e),c=i<0,h=n?e.length:0,f=Xd(0,h,this.__views__),d=f.start,y=f.end,m=y-d,I=c?y:d-1,P=this.__iteratees__,O=P.length,C=0,D=Se(m,this.__takeCount__);if(!n||!c&&h==m&&D==m)return yc(e,this.__actions__);var M=[];e:for(;m--&&C<D;){I+=i;for(var V=-1,L=e[I];++V<O;){var W=P[V],Q=W.iteratee,We=W.type,Te=Q(L);if(We==Dl)L=Te;else if(!Te){if(We==Jo)continue e;break e}}M[C++]=L}return M}B.prototype=Sr(Ji.prototype),B.prototype.constructor=B;function Xt(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i<n;){var c=e[i];this.set(c[0],c[1])}}function Hf(){this.__data__=Xr?Xr(null):{},this.size=0}function Vf(e){var i=this.has(e)&&delete this.__data__[e];return this.size-=i?1:0,i}function Kf(e){var i=this.__data__;if(Xr){var n=i[e];return n===w?r:n}return te.call(i,e)?i[e]:r}function Ff(e){var i=this.__data__;return Xr?i[e]!==r:te.call(i,e)}function Wf(e,i){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Xr&&i===r?w:i,this}Xt.prototype.clear=Hf,Xt.prototype.delete=Vf,Xt.prototype.get=Kf,Xt.prototype.has=Ff,Xt.prototype.set=Wf;function It(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i<n;){var c=e[i];this.set(c[0],c[1])}}function Bf(){this.__data__=[],this.size=0}function Gf(e){var i=this.__data__,n=Yi(i,e);if(n<0)return!1;var c=i.length-1;return n==c?i.pop():Ki.call(i,n,1),--this.size,!0}function Qf(e){var i=this.__data__,n=Yi(i,e);return n<0?r:i[n][1]}function Jf(e){return Yi(this.__data__,e)>-1}function Yf(e,i){var n=this.__data__,c=Yi(n,e);return c<0?(++this.size,n.push([e,i])):n[c][1]=i,this}It.prototype.clear=Bf,It.prototype.delete=Gf,It.prototype.get=Qf,It.prototype.has=Jf,It.prototype.set=Yf;function Pt(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i<n;){var c=e[i];this.set(c[0],c[1])}}function Zf(){this.size=0,this.__data__={hash:new Xt,map:new(Yr||It),string:new Xt}}function Xf(e){var i=us(this,e).delete(e);return this.size-=i?1:0,i}function ed(e){return us(this,e).get(e)}function td(e){return us(this,e).has(e)}function rd(e,i){var n=us(this,e),c=n.size;return n.set(e,i),this.size+=n.size==c?0:1,this}Pt.prototype.clear=Zf,Pt.prototype.delete=Xf,Pt.prototype.get=ed,Pt.prototype.has=td,Pt.prototype.set=rd;function er(e){var i=-1,n=e==null?0:e.length;for(this.__data__=new Pt;++i<n;)this.add(e[i])}function id(e){return this.__data__.set(e,w),this}function sd(e){return this.__data__.has(e)}er.prototype.add=er.prototype.push=id,er.prototype.has=sd;function ut(e){var i=this.__data__=new It(e);this.size=i.size}function nd(){this.__data__=new It,this.size=0}function od(e){var i=this.__data__,n=i.delete(e);return this.size=i.size,n}function ad(e){return this.__data__.get(e)}function cd(e){return this.__data__.has(e)}function ud(e,i){var n=this.__data__;if(n instanceof It){var c=n.__data__;if(!Yr||c.length<o-1)return c.push([e,i]),this.size=++n.size,this;n=this.__data__=new Pt(c)}return n.set(e,i),this.size=n.size,this}ut.prototype.clear=nd,ut.prototype.delete=od,ut.prototype.get=ad,ut.prototype.has=cd,ut.prototype.set=ud;function Ba(e,i){var n=z(e),c=!n&&nr(e),h=!n&&!c&&Ft(e),f=!n&&!c&&!h&&Nr(e),d=n||c||h||f,y=d?cn(e.length,wf):[],m=y.length;for(var I in e)(i||te.call(e,I))&&!(d&&(I=="length"||h&&(I=="offset"||I=="parent")||f&&(I=="buffer"||I=="byteLength"||I=="byteOffset")||$t(I,m)))&&y.push(I);return y}function Ga(e){var i=e.length;return i?e[Sn(0,i-1)]:r}function hd(e,i){return hs(qe(e),tr(i,0,e.length))}function ld(e){return hs(qe(e))}function gn(e,i,n){(n!==r&&!ht(e[i],n)||n===r&&!(i in e))&&St(e,i,n)}function ti(e,i,n){var c=e[i];(!(te.call(e,i)&&ht(c,n))||n===r&&!(i in e))&&St(e,i,n)}function Yi(e,i){for(var n=e.length;n--;)if(ht(e[n][0],i))return n;return-1}function pd(e,i,n,c){return zt(e,function(h,f,d){i(c,h,n(h),d)}),c}function Qa(e,i){return e&&mt(i,_e(i),e)}function fd(e,i){return e&&mt(i,Ue(i),e)}function St(e,i,n){i=="__proto__"&&Fi?Fi(e,i,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[i]=n}function yn(e,i){for(var n=-1,c=i.length,h=_(c),f=e==null;++n<c;)h[n]=f?r:Jn(e,i[n]);return h}function tr(e,i,n){return e===e&&(n!==r&&(e=e<=n?e:n),i!==r&&(e=e>=i?e:i)),e}function et(e,i,n,c,h,f){var d,y=i&S,m=i&R,I=i&j;if(n&&(d=h?n(e,c,h,f):n(e)),d!==r)return d;if(!he(e))return e;var P=z(e);if(P){if(d=tg(e),!y)return qe(e,d)}else{var O=Oe(e),C=O==Ni||O==Yo;if(Ft(e))return wc(e,y);if(O==Et||O==gr||C&&!h){if(d=m||C?{}:Mc(e),!y)return m?Kd(e,fd(d,e)):Vd(e,Qa(d,e))}else{if(!ie[O])return h?e:{};d=rg(e,O,y)}}f||(f=new ut);var D=f.get(e);if(D)return D;f.set(e,d),fu(e)?e.forEach(function(L){d.add(et(L,i,n,L,e,f))}):lu(e)&&e.forEach(function(L,W){d.set(W,et(L,i,n,W,e,f))});var M=I?m?jn:qn:m?Ue:_e,V=P?r:M(e);return Ye(V||e,function(L,W){V&&(W=L,L=e[W]),ti(d,W,et(L,i,n,W,e,f))}),d}function dd(e){var i=_e(e);return function(n){return Ja(n,e,i)}}function Ja(e,i,n){var c=n.length;if(e==null)return!c;for(e=re(e);c--;){var h=n[c],f=i[h],d=e[h];if(d===r&&!(h in e)||!f(d))return!1}return!0}function Ya(e,i,n){if(typeof e!="function")throw new Ze(l);return ci(function(){e.apply(r,n)},i)}function ri(e,i,n,c){var h=-1,f=Di,d=!0,y=e.length,m=[],I=i.length;if(!y)return m;n&&(i=ae(i,Ve(n))),c?(f=tn,d=!1):i.length>=o&&(f=Qr,d=!1,i=new er(i));e:for(;++h<y;){var P=e[h],O=n==null?P:n(P);if(P=c||P!==0?P:0,d&&O===O){for(var C=I;C--;)if(i[C]===O)continue e;m.push(P)}else f(i,O,c)||m.push(P)}return m}var zt=Pc(vt),Za=Pc(mn,!0);function gd(e,i){var n=!0;return zt(e,function(c,h,f){return n=!!i(c,h,f),n}),n}function Zi(e,i,n){for(var c=-1,h=e.length;++c<h;){var f=e[c],d=i(f);if(d!=null&&(y===r?d===d&&!Fe(d):n(d,y)))var y=d,m=f}return m}function yd(e,i,n,c){var h=e.length;for(n=H(n),n<0&&(n=-n>h?0:h+n),c=c===r||c>h?h:H(c),c<0&&(c+=h),c=n>c?0:gu(c);n<c;)e[n++]=i;return e}function Xa(e,i){var n=[];return zt(e,function(c,h,f){i(c,h,f)&&n.push(c)}),n}function Ie(e,i,n,c,h){var f=-1,d=e.length;for(n||(n=sg),h||(h=[]);++f<d;){var y=e[f];i>0&&n(y)?i>1?Ie(y,i-1,n,c,h):Mt(h,y):c||(h[h.length]=y)}return h}var vn=Sc(),ec=Sc(!0);function vt(e,i){return e&&vn(e,i,_e)}function mn(e,i){return e&&ec(e,i,_e)}function Xi(e,i){return Ut(i,function(n){return Nt(e[n])})}function rr(e,i){i=Vt(i,e);for(var n=0,c=i.length;e!=null&&n<c;)e=e[wt(i[n++])];return n&&n==c?e:r}function tc(e,i,n){var c=i(e);return z(e)?c:Mt(c,n(e))}function Ne(e){return e==null?e===r?Kl:Hl:Zt&&Zt in re(e)?Zd(e):lg(e)}function wn(e,i){return e>i}function vd(e,i){return e!=null&&te.call(e,i)}function md(e,i){return e!=null&&i in re(e)}function wd(e,i,n){return e>=Se(i,n)&&e<we(i,n)}function _n(e,i,n){for(var c=n?tn:Di,h=e[0].length,f=e.length,d=f,y=_(f),m=1/0,I=[];d--;){var P=e[d];d&&i&&(P=ae(P,Ve(i))),m=Se(P.length,m),y[d]=!n&&(i||h>=120&&P.length>=120)?new er(d&&P):r}P=e[0];var O=-1,C=y[0];e:for(;++O<h&&I.length<m;){var D=P[O],M=i?i(D):D;if(D=n||D!==0?D:0,!(C?Qr(C,M):c(I,M,n))){for(d=f;--d;){var V=y[d];if(!(V?Qr(V,M):c(e[d],M,n)))continue e}C&&C.push(M),I.push(D)}}return I}function _d(e,i,n,c){return vt(e,function(h,f,d){i(c,n(h),f,d)}),c}function ii(e,i,n){i=Vt(i,e),e=Hc(e,i);var c=e==null?e:e[wt(rt(i))];return c==null?r:He(c,e,n)}function rc(e){return le(e)&&Ne(e)==gr}function bd(e){return le(e)&&Ne(e)==Gr}function Ed(e){return le(e)&&Ne(e)==Vr}function si(e,i,n,c,h){return e===i?!0:e==null||i==null||!le(e)&&!le(i)?e!==e&&i!==i:Id(e,i,n,c,si,h)}function Id(e,i,n,c,h,f){var d=z(e),y=z(i),m=d?Ri:Oe(e),I=y?Ri:Oe(i);m=m==gr?Et:m,I=I==gr?Et:I;var P=m==Et,O=I==Et,C=m==I;if(C&&Ft(e)){if(!Ft(i))return!1;d=!0,P=!1}if(C&&!P)return f||(f=new ut),d||Nr(e)?qc(e,i,n,c,h,f):Jd(e,i,m,n,c,h,f);if(!(n&x)){var D=P&&te.call(e,"__wrapped__"),M=O&&te.call(i,"__wrapped__");if(D||M){var V=D?e.value():e,L=M?i.value():i;return f||(f=new ut),h(V,L,n,c,f)}}return C?(f||(f=new ut),Yd(e,i,n,c,h,f)):!1}function Pd(e){return le(e)&&Oe(e)==ot}function bn(e,i,n,c){var h=n.length,f=h,d=!c;if(e==null)return!f;for(e=re(e);h--;){var y=n[h];if(d&&y[2]?y[1]!==e[y[0]]:!(y[0]in e))return!1}for(;++h<f;){y=n[h];var m=y[0],I=e[m],P=y[1];if(d&&y[2]){if(I===r&&!(m in e))return!1}else{var O=new ut;if(c)var C=c(I,P,m,e,i,O);if(!(C===r?si(P,I,x|K,c,O):C))return!1}}return!0}function ic(e){if(!he(e)||og(e))return!1;var i=Nt(e)?Pf:fp;return i.test(sr(e))}function Sd(e){return le(e)&&Ne(e)==Fr}function Od(e){return le(e)&&Oe(e)==at}function Rd(e){return le(e)&&ys(e.length)&&!!oe[Ne(e)]}function sc(e){return typeof e=="function"?e:e==null?Me:typeof e=="object"?z(e)?ac(e[0],e[1]):oc(e):Ou(e)}function En(e){if(!ai(e))return Cf(e);var i=[];for(var n in re(e))te.call(e,n)&&n!="constructor"&&i.push(n);return i}function $d(e){if(!he(e))return hg(e);var i=ai(e),n=[];for(var c in e)c=="constructor"&&(i||!te.call(e,c))||n.push(c);return n}function In(e,i){return e<i}function nc(e,i){var n=-1,c=je(e)?_(e.length):[];return zt(e,function(h,f,d){c[++n]=i(h,f,d)}),c}function oc(e){var i=Mn(e);return i.length==1&&i[0][2]?kc(i[0][0],i[0][1]):function(n){return n===e||bn(n,e,i)}}function ac(e,i){return kn(e)&&Lc(i)?kc(wt(e),i):function(n){var c=Jn(n,e);return c===r&&c===i?Yn(n,e):si(i,c,x|K)}}function es(e,i,n,c,h){e!==i&&vn(i,function(f,d){if(h||(h=new ut),he(f))Nd(e,i,d,n,es,c,h);else{var y=c?c(Hn(e,d),f,d+"",e,i,h):r;y===r&&(y=f),gn(e,d,y)}},Ue)}function Nd(e,i,n,c,h,f,d){var y=Hn(e,n),m=Hn(i,n),I=d.get(m);if(I){gn(e,n,I);return}var P=f?f(y,m,n+"",e,i,d):r,O=P===r;if(O){var C=z(m),D=!C&&Ft(m),M=!C&&!D&&Nr(m);P=m,C||D||M?z(y)?P=y:de(y)?P=qe(y):D?(O=!1,P=wc(m,!0)):M?(O=!1,P=_c(m,!0)):P=[]:ui(m)||nr(m)?(P=y,nr(y)?P=yu(y):(!he(y)||Nt(y))&&(P=Mc(m))):O=!1}O&&(d.set(m,P),h(P,m,c,f,d),d.delete(m)),gn(e,n,P)}function cc(e,i){var n=e.length;if(n)return i+=i<0?n:0,$t(i,n)?e[i]:r}function uc(e,i,n){i.length?i=ae(i,function(f){return z(f)?function(d){return rr(d,f.length===1?f[0]:f)}:f}):i=[Me];var c=-1;i=ae(i,Ve(U()));var h=nc(e,function(f,d,y){var m=ae(i,function(I){return I(f)});return{criteria:m,index:++c,value:f}});return tf(h,function(f,d){return Hd(f,d,n)})}function Cd(e,i){return hc(e,i,function(n,c){return Yn(e,c)})}function hc(e,i,n){for(var c=-1,h=i.length,f={};++c<h;){var d=i[c],y=rr(e,d);n(y,d)&&ni(f,Vt(d,e),y)}return f}function Td(e){return function(i){return rr(i,e)}}function Pn(e,i,n,c){var h=c?ef:mr,f=-1,d=i.length,y=e;for(e===i&&(i=qe(i)),n&&(y=ae(e,Ve(n)));++f<d;)for(var m=0,I=i[f],P=n?n(I):I;(m=h(y,P,m,c))>-1;)y!==e&&Ki.call(y,m,1),Ki.call(e,m,1);return e}function lc(e,i){for(var n=e?i.length:0,c=n-1;n--;){var h=i[n];if(n==c||h!==f){var f=h;$t(h)?Ki.call(e,h,1):$n(e,h)}}return e}function Sn(e,i){return e+Bi(Fa()*(i-e+1))}function xd(e,i,n,c){for(var h=-1,f=we(Wi((i-e)/(n||1)),0),d=_(f);f--;)d[c?f:++h]=e,e+=n;return d}function On(e,i){var n="";if(!e||i<1||i>dr)return n;do i%2&&(n+=e),i=Bi(i/2),i&&(e+=e);while(i);return n}function F(e,i){return Vn(zc(e,i,Me),e+"")}function Ad(e){return Ga(Cr(e))}function Dd(e,i){var n=Cr(e);return hs(n,tr(i,0,n.length))}function ni(e,i,n,c){if(!he(e))return e;i=Vt(i,e);for(var h=-1,f=i.length,d=f-1,y=e;y!=null&&++h<f;){var m=wt(i[h]),I=n;if(m==="__proto__"||m==="constructor"||m==="prototype")return e;if(h!=d){var P=y[m];I=c?c(P,m,y):r,I===r&&(I=he(P)?P:$t(i[h+1])?[]:{})}ti(y,m,I),y=y[m]}return e}var pc=Gi?function(e,i){return Gi.set(e,i),e}:Me,qd=Fi?function(e,i){return Fi(e,"toString",{configurable:!0,enumerable:!1,value:Xn(i),writable:!0})}:Me;function jd(e){return hs(Cr(e))}function tt(e,i,n){var c=-1,h=e.length;i<0&&(i=-i>h?0:h+i),n=n>h?h:n,n<0&&(n+=h),h=i>n?0:n-i>>>0,i>>>=0;for(var f=_(h);++c<h;)f[c]=e[c+i];return f}function Ud(e,i){var n;return zt(e,function(c,h,f){return n=i(c,h,f),!n}),!!n}function ts(e,i,n){var c=0,h=e==null?c:e.length;if(typeof i=="number"&&i===i&&h<=Ml){for(;c<h;){var f=c+h>>>1,d=e[f];d!==null&&!Fe(d)&&(n?d<=i:d<i)?c=f+1:h=f}return h}return Rn(e,i,Me,n)}function Rn(e,i,n,c){var h=0,f=e==null?0:e.length;if(f===0)return 0;i=n(i);for(var d=i!==i,y=i===null,m=Fe(i),I=i===r;h<f;){var P=Bi((h+f)/2),O=n(e[P]),C=O!==r,D=O===null,M=O===O,V=Fe(O);if(d)var L=c||M;else I?L=M&&(c||C):y?L=M&&C&&(c||!D):m?L=M&&C&&!D&&(c||!V):D||V?L=!1:L=c?O<=i:O<i;L?h=P+1:f=P}return Se(f,Ul)}function fc(e,i){for(var n=-1,c=e.length,h=0,f=[];++n<c;){var d=e[n],y=i?i(d):d;if(!n||!ht(y,m)){var m=y;f[h++]=d===0?0:d}}return f}function dc(e){return typeof e=="number"?e:Fe(e)?Oi:+e}function Ke(e){if(typeof e=="string")return e;if(z(e))return ae(e,Ke)+"";if(Fe(e))return Wa?Wa.call(e):"";var i=e+"";return i=="0"&&1/e==-1/0?"-0":i}function Ht(e,i,n){var c=-1,h=Di,f=e.length,d=!0,y=[],m=y;if(n)d=!1,h=tn;else if(f>=o){var I=i?null:Gd(e);if(I)return ji(I);d=!1,h=Qr,m=new er}else m=i?[]:y;e:for(;++c<f;){var P=e[c],O=i?i(P):P;if(P=n||P!==0?P:0,d&&O===O){for(var C=m.length;C--;)if(m[C]===O)continue e;i&&m.push(O),y.push(P)}else h(m,O,n)||(m!==y&&m.push(O),y.push(P))}return y}function $n(e,i){return i=Vt(i,e),e=Hc(e,i),e==null||delete e[wt(rt(i))]}function gc(e,i,n,c){return ni(e,i,n(rr(e,i)),c)}function rs(e,i,n,c){for(var h=e.length,f=c?h:-1;(c?f--:++f<h)&&i(e[f],f,e););return n?tt(e,c?0:f,c?f+1:h):tt(e,c?f+1:0,c?h:f)}function yc(e,i){var n=e;return n instanceof B&&(n=n.value()),rn(i,function(c,h){return h.func.apply(h.thisArg,Mt([c],h.args))},n)}function Nn(e,i,n){var c=e.length;if(c<2)return c?Ht(e[0]):[];for(var h=-1,f=_(c);++h<c;)for(var d=e[h],y=-1;++y<c;)y!=h&&(f[h]=ri(f[h]||d,e[y],i,n));return Ht(Ie(f,1),i,n)}function vc(e,i,n){for(var c=-1,h=e.length,f=i.length,d={};++c<h;){var y=c<f?i[c]:r;n(d,e[c],y)}return d}function Cn(e){return de(e)?e:[]}function Tn(e){return typeof e=="function"?e:Me}function Vt(e,i){return z(e)?e:kn(e,i)?[e]:Wc(X(e))}var Md=F;function Kt(e,i,n){var c=e.length;return n=n===r?c:n,!i&&n>=c?e:tt(e,i,n)}var mc=Sf||function(e){return Ee.clearTimeout(e)};function wc(e,i){if(i)return e.slice();var n=e.length,c=ka?ka(n):new e.constructor(n);return e.copy(c),c}function xn(e){var i=new e.constructor(e.byteLength);return new Hi(i).set(new Hi(e)),i}function Ld(e,i){var n=i?xn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function kd(e){var i=new e.constructor(e.source,ra.exec(e));return i.lastIndex=e.lastIndex,i}function zd(e){return ei?re(ei.call(e)):{}}function _c(e,i){var n=i?xn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function bc(e,i){if(e!==i){var n=e!==r,c=e===null,h=e===e,f=Fe(e),d=i!==r,y=i===null,m=i===i,I=Fe(i);if(!y&&!I&&!f&&e>i||f&&d&&m&&!y&&!I||c&&d&&m||!n&&m||!h)return 1;if(!c&&!f&&!I&&e<i||I&&n&&h&&!c&&!f||y&&n&&h||!d&&h||!m)return-1}return 0}function Hd(e,i,n){for(var c=-1,h=e.criteria,f=i.criteria,d=h.length,y=n.length;++c<d;){var m=bc(h[c],f[c]);if(m){if(c>=y)return m;var I=n[c];return m*(I=="desc"?-1:1)}}return e.index-i.index}function Ec(e,i,n,c){for(var h=-1,f=e.length,d=n.length,y=-1,m=i.length,I=we(f-d,0),P=_(m+I),O=!c;++y<m;)P[y]=i[y];for(;++h<d;)(O||h<f)&&(P[n[h]]=e[h]);for(;I--;)P[y++]=e[h++];return P}function Ic(e,i,n,c){for(var h=-1,f=e.length,d=-1,y=n.length,m=-1,I=i.length,P=we(f-y,0),O=_(P+I),C=!c;++h<P;)O[h]=e[h];for(var D=h;++m<I;)O[D+m]=i[m];for(;++d<y;)(C||h<f)&&(O[D+n[d]]=e[h++]);return O}function qe(e,i){var n=-1,c=e.length;for(i||(i=_(c));++n<c;)i[n]=e[n];return i}function mt(e,i,n,c){var h=!n;n||(n={});for(var f=-1,d=i.length;++f<d;){var y=i[f],m=c?c(n[y],e[y],y,n,e):r;m===r&&(m=e[y]),h?St(n,y,m):ti(n,y,m)}return n}function Vd(e,i){return mt(e,Ln(e),i)}function Kd(e,i){return mt(e,jc(e),i)}function is(e,i){return function(n,c){var h=z(n)?Gp:pd,f=i?i():{};return h(n,e,U(c,2),f)}}function Or(e){return F(function(i,n){var c=-1,h=n.length,f=h>1?n[h-1]:r,d=h>2?n[2]:r;for(f=e.length>3&&typeof f=="function"?(h--,f):r,d&&Ce(n[0],n[1],d)&&(f=h<3?r:f,h=1),i=re(i);++c<h;){var y=n[c];y&&e(i,y,c,f)}return i})}function Pc(e,i){return function(n,c){if(n==null)return n;if(!je(n))return e(n,c);for(var h=n.length,f=i?h:-1,d=re(n);(i?f--:++f<h)&&c(d[f],f,d)!==!1;);return n}}function Sc(e){return function(i,n,c){for(var h=-1,f=re(i),d=c(i),y=d.length;y--;){var m=d[e?y:++h];if(n(f[m],m,f)===!1)break}return i}}function Fd(e,i,n){var c=i&A,h=oi(e);function f(){var d=this&&this!==Ee&&this instanceof f?h:e;return d.apply(c?n:this,arguments)}return f}function Oc(e){return function(i){i=X(i);var n=wr(i)?ct(i):r,c=n?n[0]:i.charAt(0),h=n?Kt(n,1).join(""):i.slice(1);return c[e]()+h}}function Rr(e){return function(i){return rn(Pu(Iu(i).replace(Dp,"")),e,"")}}function oi(e){return function(){var i=arguments;switch(i.length){case 0:return new e;case 1:return new e(i[0]);case 2:return new e(i[0],i[1]);case 3:return new e(i[0],i[1],i[2]);case 4:return new e(i[0],i[1],i[2],i[3]);case 5:return new e(i[0],i[1],i[2],i[3],i[4]);case 6:return new e(i[0],i[1],i[2],i[3],i[4],i[5]);case 7:return new e(i[0],i[1],i[2],i[3],i[4],i[5],i[6])}var n=Sr(e.prototype),c=e.apply(n,i);return he(c)?c:n}}function Wd(e,i,n){var c=oi(e);function h(){for(var f=arguments.length,d=_(f),y=f,m=$r(h);y--;)d[y]=arguments[y];var I=f<3&&d[0]!==m&&d[f-1]!==m?[]:Lt(d,m);if(f-=I.length,f<n)return Tc(e,i,ss,h.placeholder,r,d,I,r,r,n-f);var P=this&&this!==Ee&&this instanceof h?c:e;return He(P,this,d)}return h}function Rc(e){return function(i,n,c){var h=re(i);if(!je(i)){var f=U(n,3);i=_e(i),n=function(y){return f(h[y],y,h)}}var d=e(i,n,c);return d>-1?h[f?i[d]:d]:r}}function $c(e){return Rt(function(i){var n=i.length,c=n,h=Xe.prototype.thru;for(e&&i.reverse();c--;){var f=i[c];if(typeof f!="function")throw new Ze(l);if(h&&!d&&cs(f)=="wrapper")var d=new Xe([],!0)}for(c=d?c:n;++c<n;){f=i[c];var y=cs(f),m=y=="wrapper"?Un(f):r;m&&zn(m[0])&&m[1]==(fe|J|ue|$e)&&!m[4].length&&m[9]==1?d=d[cs(m[0])].apply(d,m[3]):d=f.length==1&&zn(f)?d[y]():d.thru(f)}return function(){var I=arguments,P=I[0];if(d&&I.length==1&&z(P))return d.plant(P).value();for(var O=0,C=n?i[O].apply(this,I):P;++O<n;)C=i[O].call(this,C);return C}})}function ss(e,i,n,c,h,f,d,y,m,I){var P=i&fe,O=i&A,C=i&G,D=i&(J|Z),M=i&jt,V=C?r:oi(e);function L(){for(var W=arguments.length,Q=_(W),We=W;We--;)Q[We]=arguments[We];if(D)var Te=$r(L),Be=sf(Q,Te);if(c&&(Q=Ec(Q,c,h,D)),f&&(Q=Ic(Q,f,d,D)),W-=Be,D&&W<I){var ge=Lt(Q,Te);return Tc(e,i,ss,L.placeholder,n,Q,ge,y,m,I-W)}var lt=O?n:this,Tt=C?lt[e]:e;return W=Q.length,y?Q=pg(Q,y):M&&W>1&&Q.reverse(),P&&m<W&&(Q.length=m),this&&this!==Ee&&this instanceof L&&(Tt=V||oi(Tt)),Tt.apply(lt,Q)}return L}function Nc(e,i){return function(n,c){return _d(n,e,i(c),{})}}function ns(e,i){return function(n,c){var h;if(n===r&&c===r)return i;if(n!==r&&(h=n),c!==r){if(h===r)return c;typeof n=="string"||typeof c=="string"?(n=Ke(n),c=Ke(c)):(n=dc(n),c=dc(c)),h=e(n,c)}return h}}function An(e){return Rt(function(i){return i=ae(i,Ve(U())),F(function(n){var c=this;return e(i,function(h){return He(h,c,n)})})})}function os(e,i){i=i===r?" ":Ke(i);var n=i.length;if(n<2)return n?On(i,e):i;var c=On(i,Wi(e/_r(i)));return wr(i)?Kt(ct(c),0,e).join(""):c.slice(0,e)}function Bd(e,i,n,c){var h=i&A,f=oi(e);function d(){for(var y=-1,m=arguments.length,I=-1,P=c.length,O=_(P+m),C=this&&this!==Ee&&this instanceof d?f:e;++I<P;)O[I]=c[I];for(;m--;)O[I++]=arguments[++y];return He(C,h?n:this,O)}return d}function Cc(e){return function(i,n,c){return c&&typeof c!="number"&&Ce(i,n,c)&&(n=c=r),i=Ct(i),n===r?(n=i,i=0):n=Ct(n),c=c===r?i<n?1:-1:Ct(c),xd(i,n,c,e)}}function as(e){return function(i,n){return typeof i=="string"&&typeof n=="string"||(i=it(i),n=it(n)),e(i,n)}}function Tc(e,i,n,c,h,f,d,y,m,I){var P=i&J,O=P?d:r,C=P?r:d,D=P?f:r,M=P?r:f;i|=P?ue:De,i&=~(P?De:ue),i&pe||(i&=-4);var V=[e,i,h,D,O,M,C,y,m,I],L=n.apply(r,V);return zn(e)&&Vc(L,V),L.placeholder=c,Kc(L,e,i)}function Dn(e){var i=me[e];return function(n,c){if(n=it(n),c=c==null?0:Se(H(c),292),c&&Ka(n)){var h=(X(n)+"e").split("e"),f=i(h[0]+"e"+(+h[1]+c));return h=(X(f)+"e").split("e"),+(h[0]+"e"+(+h[1]-c))}return i(n)}}var Gd=Ir&&1/ji(new Ir([,-0]))[1]==Si?function(e){return new Ir(e)}:ro;function xc(e){return function(i){var n=Oe(i);return n==ot?hn(i):n==at?lf(i):rf(i,e(i))}}function Ot(e,i,n,c,h,f,d,y){var m=i&G;if(!m&&typeof e!="function")throw new Ze(l);var I=c?c.length:0;if(I||(i&=-97,c=h=r),d=d===r?d:we(H(d),0),y=y===r?y:H(y),I-=h?h.length:0,i&De){var P=c,O=h;c=h=r}var C=m?r:Un(e),D=[e,i,n,c,h,P,O,f,d,y];if(C&&ug(D,C),e=D[0],i=D[1],n=D[2],c=D[3],h=D[4],y=D[9]=D[9]===r?m?0:e.length:we(D[9]-I,0),!y&&i&(J|Z)&&(i&=-25),!i||i==A)var M=Fd(e,i,n);else i==J||i==Z?M=Wd(e,i,y):(i==ue||i==(A|ue))&&!h.length?M=Bd(e,i,n,c):M=ss.apply(r,D);var V=C?pc:Vc;return Kc(V(M,D),e,i)}function Ac(e,i,n,c){return e===r||ht(e,Er[n])&&!te.call(c,n)?i:e}function Dc(e,i,n,c,h,f){return he(e)&&he(i)&&(f.set(i,e),es(e,i,r,Dc,f),f.delete(i)),e}function Qd(e){return ui(e)?r:e}function qc(e,i,n,c,h,f){var d=n&x,y=e.length,m=i.length;if(y!=m&&!(d&&m>y))return!1;var I=f.get(e),P=f.get(i);if(I&&P)return I==i&&P==e;var O=-1,C=!0,D=n&K?new er:r;for(f.set(e,i),f.set(i,e);++O<y;){var M=e[O],V=i[O];if(c)var L=d?c(V,M,O,i,e,f):c(M,V,O,e,i,f);if(L!==r){if(L)continue;C=!1;break}if(D){if(!sn(i,function(W,Q){if(!Qr(D,Q)&&(M===W||h(M,W,n,c,f)))return D.push(Q)})){C=!1;break}}else if(!(M===V||h(M,V,n,c,f))){C=!1;break}}return f.delete(e),f.delete(i),C}function Jd(e,i,n,c,h,f,d){switch(n){case yr:if(e.byteLength!=i.byteLength||e.byteOffset!=i.byteOffset)return!1;e=e.buffer,i=i.buffer;case Gr:return!(e.byteLength!=i.byteLength||!f(new Hi(e),new Hi(i)));case Hr:case Vr:case Kr:return ht(+e,+i);case $i:return e.name==i.name&&e.message==i.message;case Fr:case Wr:return e==i+"";case ot:var y=hn;case at:var m=c&x;if(y||(y=ji),e.size!=i.size&&!m)return!1;var I=d.get(e);if(I)return I==i;c|=K,d.set(e,i);var P=qc(y(e),y(i),c,h,f,d);return d.delete(e),P;case Ci:if(ei)return ei.call(e)==ei.call(i)}return!1}function Yd(e,i,n,c,h,f){var d=n&x,y=qn(e),m=y.length,I=qn(i),P=I.length;if(m!=P&&!d)return!1;for(var O=m;O--;){var C=y[O];if(!(d?C in i:te.call(i,C)))return!1}var D=f.get(e),M=f.get(i);if(D&&M)return D==i&&M==e;var V=!0;f.set(e,i),f.set(i,e);for(var L=d;++O<m;){C=y[O];var W=e[C],Q=i[C];if(c)var We=d?c(Q,W,C,i,e,f):c(W,Q,C,e,i,f);if(!(We===r?W===Q||h(W,Q,n,c,f):We)){V=!1;break}L||(L=C=="constructor")}if(V&&!L){var Te=e.constructor,Be=i.constructor;Te!=Be&&"constructor"in e&&"constructor"in i&&!(typeof Te=="function"&&Te instanceof Te&&typeof Be=="function"&&Be instanceof Be)&&(V=!1)}return f.delete(e),f.delete(i),V}function Rt(e){return Vn(zc(e,r,Jc),e+"")}function qn(e){return tc(e,_e,Ln)}function jn(e){return tc(e,Ue,jc)}var Un=Gi?function(e){return Gi.get(e)}:ro;function cs(e){for(var i=e.name+"",n=Pr[i],c=te.call(Pr,i)?n.length:0;c--;){var h=n[c],f=h.func;if(f==null||f==e)return h.name}return i}function $r(e){var i=te.call(p,"placeholder")?p:e;return i.placeholder}function U(){var e=p.iteratee||eo;return e=e===eo?sc:e,arguments.length?e(arguments[0],arguments[1]):e}function us(e,i){var n=e.__data__;return ng(i)?n[typeof i=="string"?"string":"hash"]:n.map}function Mn(e){for(var i=_e(e),n=i.length;n--;){var c=i[n],h=e[c];i[n]=[c,h,Lc(h)]}return i}function ir(e,i){var n=cf(e,i);return ic(n)?n:r}function Zd(e){var i=te.call(e,Zt),n=e[Zt];try{e[Zt]=r;var c=!0}catch{}var h=ki.call(e);return c&&(i?e[Zt]=n:delete e[Zt]),h}var Ln=pn?function(e){return e==null?[]:(e=re(e),Ut(pn(e),function(i){return Ha.call(e,i)}))}:io,jc=pn?function(e){for(var i=[];e;)Mt(i,Ln(e)),e=Vi(e);return i}:io,Oe=Ne;(fn&&Oe(new fn(new ArrayBuffer(1)))!=yr||Yr&&Oe(new Yr)!=ot||dn&&Oe(dn.resolve())!=Zo||Ir&&Oe(new Ir)!=at||Zr&&Oe(new Zr)!=Br)&&(Oe=function(e){var i=Ne(e),n=i==Et?e.constructor:r,c=n?sr(n):"";if(c)switch(c){case Df:return yr;case qf:return ot;case jf:return Zo;case Uf:return at;case Mf:return Br}return i});function Xd(e,i,n){for(var c=-1,h=n.length;++c<h;){var f=n[c],d=f.size;switch(f.type){case"drop":e+=d;break;case"dropRight":i-=d;break;case"take":i=Se(i,e+d);break;case"takeRight":e=we(e,i-d);break}}return{start:e,end:i}}function eg(e){var i=e.match(np);return i?i[1].split(op):[]}function Uc(e,i,n){i=Vt(i,e);for(var c=-1,h=i.length,f=!1;++c<h;){var d=wt(i[c]);if(!(f=e!=null&&n(e,d)))break;e=e[d]}return f||++c!=h?f:(h=e==null?0:e.length,!!h&&ys(h)&&$t(d,h)&&(z(e)||nr(e)))}function tg(e){var i=e.length,n=new e.constructor(i);return i&&typeof e[0]=="string"&&te.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function Mc(e){return typeof e.constructor=="function"&&!ai(e)?Sr(Vi(e)):{}}function rg(e,i,n){var c=e.constructor;switch(i){case Gr:return xn(e);case Hr:case Vr:return new c(+e);case yr:return Ld(e,n);case Us:case Ms:case Ls:case ks:case zs:case Hs:case Vs:case Ks:case Fs:return _c(e,n);case ot:return new c;case Kr:case Wr:return new c(e);case Fr:return kd(e);case at:return new c;case Ci:return zd(e)}}function ig(e,i){var n=i.length;if(!n)return e;var c=n-1;return i[c]=(n>1?"& ":"")+i[c],i=i.join(n>2?", ":" "),e.replace(sp,`{
28
+ */(function(a,t){(function(){var r,s="4.17.21",o=200,u="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",g="Invalid `variable` option passed into `_.template`",w="__lodash_hash_undefined__",b=500,$="__lodash_placeholder__",S=1,R=2,j=4,x=1,K=2,A=1,G=2,pe=4,J=8,Z=16,ue=32,De=64,fe=128,$e=256,jt=512,Cl=30,Tl="...",xl=800,Al=16,Jo=1,Dl=2,ql=3,Si=1/0,dr=9007199254740991,jl=17976931348623157e292,Oi=NaN,yt=4294967295,Ul=yt-1,Ml=yt>>>1,Ll=[["ary",fe],["bind",A],["bindKey",G],["curry",J],["curryRight",Z],["flip",jt],["partial",ue],["partialRight",De],["rearg",$e]],gr="[object Arguments]",Ri="[object Array]",kl="[object AsyncFunction]",Hr="[object Boolean]",Vr="[object Date]",zl="[object DOMException]",$i="[object Error]",Ni="[object Function]",Yo="[object GeneratorFunction]",at="[object Map]",Kr="[object Number]",Hl="[object Null]",Et="[object Object]",Zo="[object Promise]",Vl="[object Proxy]",Fr="[object RegExp]",ct="[object Set]",Wr="[object String]",Ci="[object Symbol]",Kl="[object Undefined]",Br="[object WeakMap]",Fl="[object WeakSet]",Gr="[object ArrayBuffer]",yr="[object DataView]",Us="[object Float32Array]",Ms="[object Float64Array]",Ls="[object Int8Array]",ks="[object Int16Array]",zs="[object Int32Array]",Hs="[object Uint8Array]",Vs="[object Uint8ClampedArray]",Ks="[object Uint16Array]",Fs="[object Uint32Array]",Wl=/\b__p \+= '';/g,Bl=/\b(__p \+=) '' \+/g,Gl=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Xo=/&(?:amp|lt|gt|quot|#39);/g,ea=/[&<>"']/g,Ql=RegExp(Xo.source),Jl=RegExp(ea.source),Yl=/<%-([\s\S]+?)%>/g,Zl=/<%([\s\S]+?)%>/g,ta=/<%=([\s\S]+?)%>/g,Xl=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ep=/^\w*$/,tp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ws=/[\\^$.*+?()[\]{}|]/g,rp=RegExp(Ws.source),Bs=/^\s+/,ip=/\s/,sp=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,np=/\{\n\/\* \[wrapped with (.+)\] \*/,op=/,? & /,ap=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,cp=/[()=,{}\[\]\/\s]/,up=/\\(\\)?/g,hp=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ra=/\w*$/,lp=/^[-+]0x[0-9a-f]+$/i,pp=/^0b[01]+$/i,fp=/^\[object .+?Constructor\]$/,dp=/^0o[0-7]+$/i,gp=/^(?:0|[1-9]\d*)$/,yp=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ti=/($^)/,vp=/['\n\r\u2028\u2029\\]/g,xi="\\ud800-\\udfff",mp="\\u0300-\\u036f",wp="\\ufe20-\\ufe2f",_p="\\u20d0-\\u20ff",ia=mp+wp+_p,sa="\\u2700-\\u27bf",na="a-z\\xdf-\\xf6\\xf8-\\xff",bp="\\xac\\xb1\\xd7\\xf7",Ep="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Ip="\\u2000-\\u206f",Pp=" \\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",oa="A-Z\\xc0-\\xd6\\xd8-\\xde",aa="\\ufe0e\\ufe0f",ca=bp+Ep+Ip+Pp,Gs="['’]",Sp="["+xi+"]",ua="["+ca+"]",Ai="["+ia+"]",ha="\\d+",Op="["+sa+"]",la="["+na+"]",pa="[^"+xi+ca+ha+sa+na+oa+"]",Qs="\\ud83c[\\udffb-\\udfff]",Rp="(?:"+Ai+"|"+Qs+")",fa="[^"+xi+"]",Js="(?:\\ud83c[\\udde6-\\uddff]){2}",Ys="[\\ud800-\\udbff][\\udc00-\\udfff]",vr="["+oa+"]",da="\\u200d",ga="(?:"+la+"|"+pa+")",$p="(?:"+vr+"|"+pa+")",ya="(?:"+Gs+"(?:d|ll|m|re|s|t|ve))?",va="(?:"+Gs+"(?:D|LL|M|RE|S|T|VE))?",ma=Rp+"?",wa="["+aa+"]?",Np="(?:"+da+"(?:"+[fa,Js,Ys].join("|")+")"+wa+ma+")*",Cp="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Tp="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",_a=wa+ma+Np,xp="(?:"+[Op,Js,Ys].join("|")+")"+_a,Ap="(?:"+[fa+Ai+"?",Ai,Js,Ys,Sp].join("|")+")",Dp=RegExp(Gs,"g"),qp=RegExp(Ai,"g"),Zs=RegExp(Qs+"(?="+Qs+")|"+Ap+_a,"g"),jp=RegExp([vr+"?"+la+"+"+ya+"(?="+[ua,vr,"$"].join("|")+")",$p+"+"+va+"(?="+[ua,vr+ga,"$"].join("|")+")",vr+"?"+ga+"+"+ya,vr+"+"+va,Tp,Cp,ha,xp].join("|"),"g"),Up=RegExp("["+da+xi+ia+aa+"]"),Mp=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Lp=["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"],kp=-1,oe={};oe[Us]=oe[Ms]=oe[Ls]=oe[ks]=oe[zs]=oe[Hs]=oe[Vs]=oe[Ks]=oe[Fs]=!0,oe[gr]=oe[Ri]=oe[Gr]=oe[Hr]=oe[yr]=oe[Vr]=oe[$i]=oe[Ni]=oe[at]=oe[Kr]=oe[Et]=oe[Fr]=oe[ct]=oe[Wr]=oe[Br]=!1;var ie={};ie[gr]=ie[Ri]=ie[Gr]=ie[yr]=ie[Hr]=ie[Vr]=ie[Us]=ie[Ms]=ie[Ls]=ie[ks]=ie[zs]=ie[at]=ie[Kr]=ie[Et]=ie[Fr]=ie[ct]=ie[Wr]=ie[Ci]=ie[Hs]=ie[Vs]=ie[Ks]=ie[Fs]=!0,ie[$i]=ie[Ni]=ie[Br]=!1;var zp={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Hp={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Vp={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Kp={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Fp=parseFloat,Wp=parseInt,ba=typeof yi=="object"&&yi&&yi.Object===Object&&yi,Bp=typeof self=="object"&&self&&self.Object===Object&&self,Ee=ba||Bp||Function("return this")(),Xs=t&&!t.nodeType&&t,Yt=Xs&&!0&&a&&!a.nodeType&&a,Ea=Yt&&Yt.exports===Xs,en=Ea&&ba.process,Je=function(){try{var v=Yt&&Yt.require&&Yt.require("util").types;return v||en&&en.binding&&en.binding("util")}catch{}}(),Ia=Je&&Je.isArrayBuffer,Pa=Je&&Je.isDate,Sa=Je&&Je.isMap,Oa=Je&&Je.isRegExp,Ra=Je&&Je.isSet,$a=Je&&Je.isTypedArray;function He(v,E,_){switch(_.length){case 0:return v.call(E);case 1:return v.call(E,_[0]);case 2:return v.call(E,_[0],_[1]);case 3:return v.call(E,_[0],_[1],_[2])}return v.apply(E,_)}function Gp(v,E,_,T){for(var k=-1,Y=v==null?0:v.length;++k<Y;){var me=v[k];E(T,me,_(me),v)}return T}function Ye(v,E){for(var _=-1,T=v==null?0:v.length;++_<T&&E(v[_],_,v)!==!1;);return v}function Qp(v,E){for(var _=v==null?0:v.length;_--&&E(v[_],_,v)!==!1;);return v}function Na(v,E){for(var _=-1,T=v==null?0:v.length;++_<T;)if(!E(v[_],_,v))return!1;return!0}function Ut(v,E){for(var _=-1,T=v==null?0:v.length,k=0,Y=[];++_<T;){var me=v[_];E(me,_,v)&&(Y[k++]=me)}return Y}function Di(v,E){var _=v==null?0:v.length;return!!_&&mr(v,E,0)>-1}function tn(v,E,_){for(var T=-1,k=v==null?0:v.length;++T<k;)if(_(E,v[T]))return!0;return!1}function ae(v,E){for(var _=-1,T=v==null?0:v.length,k=Array(T);++_<T;)k[_]=E(v[_],_,v);return k}function Mt(v,E){for(var _=-1,T=E.length,k=v.length;++_<T;)v[k+_]=E[_];return v}function rn(v,E,_,T){var k=-1,Y=v==null?0:v.length;for(T&&Y&&(_=v[++k]);++k<Y;)_=E(_,v[k],k,v);return _}function Jp(v,E,_,T){var k=v==null?0:v.length;for(T&&k&&(_=v[--k]);k--;)_=E(_,v[k],k,v);return _}function sn(v,E){for(var _=-1,T=v==null?0:v.length;++_<T;)if(E(v[_],_,v))return!0;return!1}var Yp=nn("length");function Zp(v){return v.split("")}function Xp(v){return v.match(ap)||[]}function Ca(v,E,_){var T;return _(v,function(k,Y,me){if(E(k,Y,me))return T=Y,!1}),T}function qi(v,E,_,T){for(var k=v.length,Y=_+(T?1:-1);T?Y--:++Y<k;)if(E(v[Y],Y,v))return Y;return-1}function mr(v,E,_){return E===E?pf(v,E,_):qi(v,Ta,_)}function ef(v,E,_,T){for(var k=_-1,Y=v.length;++k<Y;)if(T(v[k],E))return k;return-1}function Ta(v){return v!==v}function xa(v,E){var _=v==null?0:v.length;return _?an(v,E)/_:Oi}function nn(v){return function(E){return E==null?r:E[v]}}function on(v){return function(E){return v==null?r:v[E]}}function Aa(v,E,_,T,k){return k(v,function(Y,me,re){_=T?(T=!1,Y):E(_,Y,me,re)}),_}function tf(v,E){var _=v.length;for(v.sort(E);_--;)v[_]=v[_].value;return v}function an(v,E){for(var _,T=-1,k=v.length;++T<k;){var Y=E(v[T]);Y!==r&&(_=_===r?Y:_+Y)}return _}function cn(v,E){for(var _=-1,T=Array(v);++_<v;)T[_]=E(_);return T}function rf(v,E){return ae(E,function(_){return[_,v[_]]})}function Da(v){return v&&v.slice(0,Ma(v)+1).replace(Bs,"")}function Ve(v){return function(E){return v(E)}}function un(v,E){return ae(E,function(_){return v[_]})}function Qr(v,E){return v.has(E)}function qa(v,E){for(var _=-1,T=v.length;++_<T&&mr(E,v[_],0)>-1;);return _}function ja(v,E){for(var _=v.length;_--&&mr(E,v[_],0)>-1;);return _}function sf(v,E){for(var _=v.length,T=0;_--;)v[_]===E&&++T;return T}var nf=on(zp),of=on(Hp);function af(v){return"\\"+Kp[v]}function cf(v,E){return v==null?r:v[E]}function wr(v){return Up.test(v)}function uf(v){return Mp.test(v)}function hf(v){for(var E,_=[];!(E=v.next()).done;)_.push(E.value);return _}function hn(v){var E=-1,_=Array(v.size);return v.forEach(function(T,k){_[++E]=[k,T]}),_}function Ua(v,E){return function(_){return v(E(_))}}function Lt(v,E){for(var _=-1,T=v.length,k=0,Y=[];++_<T;){var me=v[_];(me===E||me===$)&&(v[_]=$,Y[k++]=_)}return Y}function ji(v){var E=-1,_=Array(v.size);return v.forEach(function(T){_[++E]=T}),_}function lf(v){var E=-1,_=Array(v.size);return v.forEach(function(T){_[++E]=[T,T]}),_}function pf(v,E,_){for(var T=_-1,k=v.length;++T<k;)if(v[T]===E)return T;return-1}function ff(v,E,_){for(var T=_+1;T--;)if(v[T]===E)return T;return T}function _r(v){return wr(v)?gf(v):Yp(v)}function ut(v){return wr(v)?yf(v):Zp(v)}function Ma(v){for(var E=v.length;E--&&ip.test(v.charAt(E)););return E}var df=on(Vp);function gf(v){for(var E=Zs.lastIndex=0;Zs.test(v);)++E;return E}function yf(v){return v.match(Zs)||[]}function vf(v){return v.match(jp)||[]}var mf=function v(E){E=E==null?Ee:br.defaults(Ee.Object(),E,br.pick(Ee,Lp));var _=E.Array,T=E.Date,k=E.Error,Y=E.Function,me=E.Math,re=E.Object,ln=E.RegExp,wf=E.String,Ze=E.TypeError,Ui=_.prototype,_f=Y.prototype,Er=re.prototype,Mi=E["__core-js_shared__"],Li=_f.toString,te=Er.hasOwnProperty,bf=0,La=function(){var e=/[^.]+$/.exec(Mi&&Mi.keys&&Mi.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ki=Er.toString,Ef=Li.call(re),If=Ee._,Pf=ln("^"+Li.call(te).replace(Ws,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),zi=Ea?E.Buffer:r,kt=E.Symbol,Hi=E.Uint8Array,ka=zi?zi.allocUnsafe:r,Vi=Ua(re.getPrototypeOf,re),za=re.create,Ha=Er.propertyIsEnumerable,Ki=Ui.splice,Va=kt?kt.isConcatSpreadable:r,Jr=kt?kt.iterator:r,Zt=kt?kt.toStringTag:r,Fi=function(){try{var e=ir(re,"defineProperty");return e({},"",{}),e}catch{}}(),Sf=E.clearTimeout!==Ee.clearTimeout&&E.clearTimeout,Of=T&&T.now!==Ee.Date.now&&T.now,Rf=E.setTimeout!==Ee.setTimeout&&E.setTimeout,Wi=me.ceil,Bi=me.floor,pn=re.getOwnPropertySymbols,$f=zi?zi.isBuffer:r,Ka=E.isFinite,Nf=Ui.join,Cf=Ua(re.keys,re),we=me.max,Se=me.min,Tf=T.now,xf=E.parseInt,Fa=me.random,Af=Ui.reverse,fn=ir(E,"DataView"),Yr=ir(E,"Map"),dn=ir(E,"Promise"),Ir=ir(E,"Set"),Zr=ir(E,"WeakMap"),Xr=ir(re,"create"),Gi=Zr&&new Zr,Pr={},Df=sr(fn),qf=sr(Yr),jf=sr(dn),Uf=sr(Ir),Mf=sr(Zr),Qi=kt?kt.prototype:r,ei=Qi?Qi.valueOf:r,Wa=Qi?Qi.toString:r;function p(e){if(le(e)&&!z(e)&&!(e instanceof B)){if(e instanceof Xe)return e;if(te.call(e,"__wrapped__"))return Bc(e)}return new Xe(e)}var Sr=function(){function e(){}return function(i){if(!he(i))return{};if(za)return za(i);e.prototype=i;var n=new e;return e.prototype=r,n}}();function Ji(){}function Xe(e,i){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!i,this.__index__=0,this.__values__=r}p.templateSettings={escape:Yl,evaluate:Zl,interpolate:ta,variable:"",imports:{_:p}},p.prototype=Ji.prototype,p.prototype.constructor=p,Xe.prototype=Sr(Ji.prototype),Xe.prototype.constructor=Xe;function B(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=yt,this.__views__=[]}function Lf(){var e=new B(this.__wrapped__);return e.__actions__=qe(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=qe(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=qe(this.__views__),e}function kf(){if(this.__filtered__){var e=new B(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function zf(){var e=this.__wrapped__.value(),i=this.__dir__,n=z(e),c=i<0,h=n?e.length:0,f=Xd(0,h,this.__views__),d=f.start,y=f.end,m=y-d,I=c?y:d-1,P=this.__iteratees__,O=P.length,C=0,D=Se(m,this.__takeCount__);if(!n||!c&&h==m&&D==m)return yc(e,this.__actions__);var M=[];e:for(;m--&&C<D;){I+=i;for(var V=-1,L=e[I];++V<O;){var W=P[V],Q=W.iteratee,We=W.type,Te=Q(L);if(We==Dl)L=Te;else if(!Te){if(We==Jo)continue e;break e}}M[C++]=L}return M}B.prototype=Sr(Ji.prototype),B.prototype.constructor=B;function Xt(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i<n;){var c=e[i];this.set(c[0],c[1])}}function Hf(){this.__data__=Xr?Xr(null):{},this.size=0}function Vf(e){var i=this.has(e)&&delete this.__data__[e];return this.size-=i?1:0,i}function Kf(e){var i=this.__data__;if(Xr){var n=i[e];return n===w?r:n}return te.call(i,e)?i[e]:r}function Ff(e){var i=this.__data__;return Xr?i[e]!==r:te.call(i,e)}function Wf(e,i){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Xr&&i===r?w:i,this}Xt.prototype.clear=Hf,Xt.prototype.delete=Vf,Xt.prototype.get=Kf,Xt.prototype.has=Ff,Xt.prototype.set=Wf;function It(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i<n;){var c=e[i];this.set(c[0],c[1])}}function Bf(){this.__data__=[],this.size=0}function Gf(e){var i=this.__data__,n=Yi(i,e);if(n<0)return!1;var c=i.length-1;return n==c?i.pop():Ki.call(i,n,1),--this.size,!0}function Qf(e){var i=this.__data__,n=Yi(i,e);return n<0?r:i[n][1]}function Jf(e){return Yi(this.__data__,e)>-1}function Yf(e,i){var n=this.__data__,c=Yi(n,e);return c<0?(++this.size,n.push([e,i])):n[c][1]=i,this}It.prototype.clear=Bf,It.prototype.delete=Gf,It.prototype.get=Qf,It.prototype.has=Jf,It.prototype.set=Yf;function Pt(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i<n;){var c=e[i];this.set(c[0],c[1])}}function Zf(){this.size=0,this.__data__={hash:new Xt,map:new(Yr||It),string:new Xt}}function Xf(e){var i=us(this,e).delete(e);return this.size-=i?1:0,i}function ed(e){return us(this,e).get(e)}function td(e){return us(this,e).has(e)}function rd(e,i){var n=us(this,e),c=n.size;return n.set(e,i),this.size+=n.size==c?0:1,this}Pt.prototype.clear=Zf,Pt.prototype.delete=Xf,Pt.prototype.get=ed,Pt.prototype.has=td,Pt.prototype.set=rd;function er(e){var i=-1,n=e==null?0:e.length;for(this.__data__=new Pt;++i<n;)this.add(e[i])}function id(e){return this.__data__.set(e,w),this}function sd(e){return this.__data__.has(e)}er.prototype.add=er.prototype.push=id,er.prototype.has=sd;function ht(e){var i=this.__data__=new It(e);this.size=i.size}function nd(){this.__data__=new It,this.size=0}function od(e){var i=this.__data__,n=i.delete(e);return this.size=i.size,n}function ad(e){return this.__data__.get(e)}function cd(e){return this.__data__.has(e)}function ud(e,i){var n=this.__data__;if(n instanceof It){var c=n.__data__;if(!Yr||c.length<o-1)return c.push([e,i]),this.size=++n.size,this;n=this.__data__=new Pt(c)}return n.set(e,i),this.size=n.size,this}ht.prototype.clear=nd,ht.prototype.delete=od,ht.prototype.get=ad,ht.prototype.has=cd,ht.prototype.set=ud;function Ba(e,i){var n=z(e),c=!n&&nr(e),h=!n&&!c&&Ft(e),f=!n&&!c&&!h&&Nr(e),d=n||c||h||f,y=d?cn(e.length,wf):[],m=y.length;for(var I in e)(i||te.call(e,I))&&!(d&&(I=="length"||h&&(I=="offset"||I=="parent")||f&&(I=="buffer"||I=="byteLength"||I=="byteOffset")||$t(I,m)))&&y.push(I);return y}function Ga(e){var i=e.length;return i?e[Sn(0,i-1)]:r}function hd(e,i){return hs(qe(e),tr(i,0,e.length))}function ld(e){return hs(qe(e))}function gn(e,i,n){(n!==r&&!lt(e[i],n)||n===r&&!(i in e))&&St(e,i,n)}function ti(e,i,n){var c=e[i];(!(te.call(e,i)&&lt(c,n))||n===r&&!(i in e))&&St(e,i,n)}function Yi(e,i){for(var n=e.length;n--;)if(lt(e[n][0],i))return n;return-1}function pd(e,i,n,c){return zt(e,function(h,f,d){i(c,h,n(h),d)}),c}function Qa(e,i){return e&&mt(i,_e(i),e)}function fd(e,i){return e&&mt(i,Ue(i),e)}function St(e,i,n){i=="__proto__"&&Fi?Fi(e,i,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[i]=n}function yn(e,i){for(var n=-1,c=i.length,h=_(c),f=e==null;++n<c;)h[n]=f?r:Jn(e,i[n]);return h}function tr(e,i,n){return e===e&&(n!==r&&(e=e<=n?e:n),i!==r&&(e=e>=i?e:i)),e}function et(e,i,n,c,h,f){var d,y=i&S,m=i&R,I=i&j;if(n&&(d=h?n(e,c,h,f):n(e)),d!==r)return d;if(!he(e))return e;var P=z(e);if(P){if(d=tg(e),!y)return qe(e,d)}else{var O=Oe(e),C=O==Ni||O==Yo;if(Ft(e))return wc(e,y);if(O==Et||O==gr||C&&!h){if(d=m||C?{}:Mc(e),!y)return m?Kd(e,fd(d,e)):Vd(e,Qa(d,e))}else{if(!ie[O])return h?e:{};d=rg(e,O,y)}}f||(f=new ht);var D=f.get(e);if(D)return D;f.set(e,d),fu(e)?e.forEach(function(L){d.add(et(L,i,n,L,e,f))}):lu(e)&&e.forEach(function(L,W){d.set(W,et(L,i,n,W,e,f))});var M=I?m?jn:qn:m?Ue:_e,V=P?r:M(e);return Ye(V||e,function(L,W){V&&(W=L,L=e[W]),ti(d,W,et(L,i,n,W,e,f))}),d}function dd(e){var i=_e(e);return function(n){return Ja(n,e,i)}}function Ja(e,i,n){var c=n.length;if(e==null)return!c;for(e=re(e);c--;){var h=n[c],f=i[h],d=e[h];if(d===r&&!(h in e)||!f(d))return!1}return!0}function Ya(e,i,n){if(typeof e!="function")throw new Ze(l);return ci(function(){e.apply(r,n)},i)}function ri(e,i,n,c){var h=-1,f=Di,d=!0,y=e.length,m=[],I=i.length;if(!y)return m;n&&(i=ae(i,Ve(n))),c?(f=tn,d=!1):i.length>=o&&(f=Qr,d=!1,i=new er(i));e:for(;++h<y;){var P=e[h],O=n==null?P:n(P);if(P=c||P!==0?P:0,d&&O===O){for(var C=I;C--;)if(i[C]===O)continue e;m.push(P)}else f(i,O,c)||m.push(P)}return m}var zt=Pc(vt),Za=Pc(mn,!0);function gd(e,i){var n=!0;return zt(e,function(c,h,f){return n=!!i(c,h,f),n}),n}function Zi(e,i,n){for(var c=-1,h=e.length;++c<h;){var f=e[c],d=i(f);if(d!=null&&(y===r?d===d&&!Fe(d):n(d,y)))var y=d,m=f}return m}function yd(e,i,n,c){var h=e.length;for(n=H(n),n<0&&(n=-n>h?0:h+n),c=c===r||c>h?h:H(c),c<0&&(c+=h),c=n>c?0:gu(c);n<c;)e[n++]=i;return e}function Xa(e,i){var n=[];return zt(e,function(c,h,f){i(c,h,f)&&n.push(c)}),n}function Ie(e,i,n,c,h){var f=-1,d=e.length;for(n||(n=sg),h||(h=[]);++f<d;){var y=e[f];i>0&&n(y)?i>1?Ie(y,i-1,n,c,h):Mt(h,y):c||(h[h.length]=y)}return h}var vn=Sc(),ec=Sc(!0);function vt(e,i){return e&&vn(e,i,_e)}function mn(e,i){return e&&ec(e,i,_e)}function Xi(e,i){return Ut(i,function(n){return Nt(e[n])})}function rr(e,i){i=Vt(i,e);for(var n=0,c=i.length;e!=null&&n<c;)e=e[wt(i[n++])];return n&&n==c?e:r}function tc(e,i,n){var c=i(e);return z(e)?c:Mt(c,n(e))}function Ne(e){return e==null?e===r?Kl:Hl:Zt&&Zt in re(e)?Zd(e):lg(e)}function wn(e,i){return e>i}function vd(e,i){return e!=null&&te.call(e,i)}function md(e,i){return e!=null&&i in re(e)}function wd(e,i,n){return e>=Se(i,n)&&e<we(i,n)}function _n(e,i,n){for(var c=n?tn:Di,h=e[0].length,f=e.length,d=f,y=_(f),m=1/0,I=[];d--;){var P=e[d];d&&i&&(P=ae(P,Ve(i))),m=Se(P.length,m),y[d]=!n&&(i||h>=120&&P.length>=120)?new er(d&&P):r}P=e[0];var O=-1,C=y[0];e:for(;++O<h&&I.length<m;){var D=P[O],M=i?i(D):D;if(D=n||D!==0?D:0,!(C?Qr(C,M):c(I,M,n))){for(d=f;--d;){var V=y[d];if(!(V?Qr(V,M):c(e[d],M,n)))continue e}C&&C.push(M),I.push(D)}}return I}function _d(e,i,n,c){return vt(e,function(h,f,d){i(c,n(h),f,d)}),c}function ii(e,i,n){i=Vt(i,e),e=Hc(e,i);var c=e==null?e:e[wt(rt(i))];return c==null?r:He(c,e,n)}function rc(e){return le(e)&&Ne(e)==gr}function bd(e){return le(e)&&Ne(e)==Gr}function Ed(e){return le(e)&&Ne(e)==Vr}function si(e,i,n,c,h){return e===i?!0:e==null||i==null||!le(e)&&!le(i)?e!==e&&i!==i:Id(e,i,n,c,si,h)}function Id(e,i,n,c,h,f){var d=z(e),y=z(i),m=d?Ri:Oe(e),I=y?Ri:Oe(i);m=m==gr?Et:m,I=I==gr?Et:I;var P=m==Et,O=I==Et,C=m==I;if(C&&Ft(e)){if(!Ft(i))return!1;d=!0,P=!1}if(C&&!P)return f||(f=new ht),d||Nr(e)?qc(e,i,n,c,h,f):Jd(e,i,m,n,c,h,f);if(!(n&x)){var D=P&&te.call(e,"__wrapped__"),M=O&&te.call(i,"__wrapped__");if(D||M){var V=D?e.value():e,L=M?i.value():i;return f||(f=new ht),h(V,L,n,c,f)}}return C?(f||(f=new ht),Yd(e,i,n,c,h,f)):!1}function Pd(e){return le(e)&&Oe(e)==at}function bn(e,i,n,c){var h=n.length,f=h,d=!c;if(e==null)return!f;for(e=re(e);h--;){var y=n[h];if(d&&y[2]?y[1]!==e[y[0]]:!(y[0]in e))return!1}for(;++h<f;){y=n[h];var m=y[0],I=e[m],P=y[1];if(d&&y[2]){if(I===r&&!(m in e))return!1}else{var O=new ht;if(c)var C=c(I,P,m,e,i,O);if(!(C===r?si(P,I,x|K,c,O):C))return!1}}return!0}function ic(e){if(!he(e)||og(e))return!1;var i=Nt(e)?Pf:fp;return i.test(sr(e))}function Sd(e){return le(e)&&Ne(e)==Fr}function Od(e){return le(e)&&Oe(e)==ct}function Rd(e){return le(e)&&ys(e.length)&&!!oe[Ne(e)]}function sc(e){return typeof e=="function"?e:e==null?Me:typeof e=="object"?z(e)?ac(e[0],e[1]):oc(e):Ou(e)}function En(e){if(!ai(e))return Cf(e);var i=[];for(var n in re(e))te.call(e,n)&&n!="constructor"&&i.push(n);return i}function $d(e){if(!he(e))return hg(e);var i=ai(e),n=[];for(var c in e)c=="constructor"&&(i||!te.call(e,c))||n.push(c);return n}function In(e,i){return e<i}function nc(e,i){var n=-1,c=je(e)?_(e.length):[];return zt(e,function(h,f,d){c[++n]=i(h,f,d)}),c}function oc(e){var i=Mn(e);return i.length==1&&i[0][2]?kc(i[0][0],i[0][1]):function(n){return n===e||bn(n,e,i)}}function ac(e,i){return kn(e)&&Lc(i)?kc(wt(e),i):function(n){var c=Jn(n,e);return c===r&&c===i?Yn(n,e):si(i,c,x|K)}}function es(e,i,n,c,h){e!==i&&vn(i,function(f,d){if(h||(h=new ht),he(f))Nd(e,i,d,n,es,c,h);else{var y=c?c(Hn(e,d),f,d+"",e,i,h):r;y===r&&(y=f),gn(e,d,y)}},Ue)}function Nd(e,i,n,c,h,f,d){var y=Hn(e,n),m=Hn(i,n),I=d.get(m);if(I){gn(e,n,I);return}var P=f?f(y,m,n+"",e,i,d):r,O=P===r;if(O){var C=z(m),D=!C&&Ft(m),M=!C&&!D&&Nr(m);P=m,C||D||M?z(y)?P=y:de(y)?P=qe(y):D?(O=!1,P=wc(m,!0)):M?(O=!1,P=_c(m,!0)):P=[]:ui(m)||nr(m)?(P=y,nr(y)?P=yu(y):(!he(y)||Nt(y))&&(P=Mc(m))):O=!1}O&&(d.set(m,P),h(P,m,c,f,d),d.delete(m)),gn(e,n,P)}function cc(e,i){var n=e.length;if(n)return i+=i<0?n:0,$t(i,n)?e[i]:r}function uc(e,i,n){i.length?i=ae(i,function(f){return z(f)?function(d){return rr(d,f.length===1?f[0]:f)}:f}):i=[Me];var c=-1;i=ae(i,Ve(U()));var h=nc(e,function(f,d,y){var m=ae(i,function(I){return I(f)});return{criteria:m,index:++c,value:f}});return tf(h,function(f,d){return Hd(f,d,n)})}function Cd(e,i){return hc(e,i,function(n,c){return Yn(e,c)})}function hc(e,i,n){for(var c=-1,h=i.length,f={};++c<h;){var d=i[c],y=rr(e,d);n(y,d)&&ni(f,Vt(d,e),y)}return f}function Td(e){return function(i){return rr(i,e)}}function Pn(e,i,n,c){var h=c?ef:mr,f=-1,d=i.length,y=e;for(e===i&&(i=qe(i)),n&&(y=ae(e,Ve(n)));++f<d;)for(var m=0,I=i[f],P=n?n(I):I;(m=h(y,P,m,c))>-1;)y!==e&&Ki.call(y,m,1),Ki.call(e,m,1);return e}function lc(e,i){for(var n=e?i.length:0,c=n-1;n--;){var h=i[n];if(n==c||h!==f){var f=h;$t(h)?Ki.call(e,h,1):$n(e,h)}}return e}function Sn(e,i){return e+Bi(Fa()*(i-e+1))}function xd(e,i,n,c){for(var h=-1,f=we(Wi((i-e)/(n||1)),0),d=_(f);f--;)d[c?f:++h]=e,e+=n;return d}function On(e,i){var n="";if(!e||i<1||i>dr)return n;do i%2&&(n+=e),i=Bi(i/2),i&&(e+=e);while(i);return n}function F(e,i){return Vn(zc(e,i,Me),e+"")}function Ad(e){return Ga(Cr(e))}function Dd(e,i){var n=Cr(e);return hs(n,tr(i,0,n.length))}function ni(e,i,n,c){if(!he(e))return e;i=Vt(i,e);for(var h=-1,f=i.length,d=f-1,y=e;y!=null&&++h<f;){var m=wt(i[h]),I=n;if(m==="__proto__"||m==="constructor"||m==="prototype")return e;if(h!=d){var P=y[m];I=c?c(P,m,y):r,I===r&&(I=he(P)?P:$t(i[h+1])?[]:{})}ti(y,m,I),y=y[m]}return e}var pc=Gi?function(e,i){return Gi.set(e,i),e}:Me,qd=Fi?function(e,i){return Fi(e,"toString",{configurable:!0,enumerable:!1,value:Xn(i),writable:!0})}:Me;function jd(e){return hs(Cr(e))}function tt(e,i,n){var c=-1,h=e.length;i<0&&(i=-i>h?0:h+i),n=n>h?h:n,n<0&&(n+=h),h=i>n?0:n-i>>>0,i>>>=0;for(var f=_(h);++c<h;)f[c]=e[c+i];return f}function Ud(e,i){var n;return zt(e,function(c,h,f){return n=i(c,h,f),!n}),!!n}function ts(e,i,n){var c=0,h=e==null?c:e.length;if(typeof i=="number"&&i===i&&h<=Ml){for(;c<h;){var f=c+h>>>1,d=e[f];d!==null&&!Fe(d)&&(n?d<=i:d<i)?c=f+1:h=f}return h}return Rn(e,i,Me,n)}function Rn(e,i,n,c){var h=0,f=e==null?0:e.length;if(f===0)return 0;i=n(i);for(var d=i!==i,y=i===null,m=Fe(i),I=i===r;h<f;){var P=Bi((h+f)/2),O=n(e[P]),C=O!==r,D=O===null,M=O===O,V=Fe(O);if(d)var L=c||M;else I?L=M&&(c||C):y?L=M&&C&&(c||!D):m?L=M&&C&&!D&&(c||!V):D||V?L=!1:L=c?O<=i:O<i;L?h=P+1:f=P}return Se(f,Ul)}function fc(e,i){for(var n=-1,c=e.length,h=0,f=[];++n<c;){var d=e[n],y=i?i(d):d;if(!n||!lt(y,m)){var m=y;f[h++]=d===0?0:d}}return f}function dc(e){return typeof e=="number"?e:Fe(e)?Oi:+e}function Ke(e){if(typeof e=="string")return e;if(z(e))return ae(e,Ke)+"";if(Fe(e))return Wa?Wa.call(e):"";var i=e+"";return i=="0"&&1/e==-1/0?"-0":i}function Ht(e,i,n){var c=-1,h=Di,f=e.length,d=!0,y=[],m=y;if(n)d=!1,h=tn;else if(f>=o){var I=i?null:Gd(e);if(I)return ji(I);d=!1,h=Qr,m=new er}else m=i?[]:y;e:for(;++c<f;){var P=e[c],O=i?i(P):P;if(P=n||P!==0?P:0,d&&O===O){for(var C=m.length;C--;)if(m[C]===O)continue e;i&&m.push(O),y.push(P)}else h(m,O,n)||(m!==y&&m.push(O),y.push(P))}return y}function $n(e,i){return i=Vt(i,e),e=Hc(e,i),e==null||delete e[wt(rt(i))]}function gc(e,i,n,c){return ni(e,i,n(rr(e,i)),c)}function rs(e,i,n,c){for(var h=e.length,f=c?h:-1;(c?f--:++f<h)&&i(e[f],f,e););return n?tt(e,c?0:f,c?f+1:h):tt(e,c?f+1:0,c?h:f)}function yc(e,i){var n=e;return n instanceof B&&(n=n.value()),rn(i,function(c,h){return h.func.apply(h.thisArg,Mt([c],h.args))},n)}function Nn(e,i,n){var c=e.length;if(c<2)return c?Ht(e[0]):[];for(var h=-1,f=_(c);++h<c;)for(var d=e[h],y=-1;++y<c;)y!=h&&(f[h]=ri(f[h]||d,e[y],i,n));return Ht(Ie(f,1),i,n)}function vc(e,i,n){for(var c=-1,h=e.length,f=i.length,d={};++c<h;){var y=c<f?i[c]:r;n(d,e[c],y)}return d}function Cn(e){return de(e)?e:[]}function Tn(e){return typeof e=="function"?e:Me}function Vt(e,i){return z(e)?e:kn(e,i)?[e]:Wc(X(e))}var Md=F;function Kt(e,i,n){var c=e.length;return n=n===r?c:n,!i&&n>=c?e:tt(e,i,n)}var mc=Sf||function(e){return Ee.clearTimeout(e)};function wc(e,i){if(i)return e.slice();var n=e.length,c=ka?ka(n):new e.constructor(n);return e.copy(c),c}function xn(e){var i=new e.constructor(e.byteLength);return new Hi(i).set(new Hi(e)),i}function Ld(e,i){var n=i?xn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function kd(e){var i=new e.constructor(e.source,ra.exec(e));return i.lastIndex=e.lastIndex,i}function zd(e){return ei?re(ei.call(e)):{}}function _c(e,i){var n=i?xn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function bc(e,i){if(e!==i){var n=e!==r,c=e===null,h=e===e,f=Fe(e),d=i!==r,y=i===null,m=i===i,I=Fe(i);if(!y&&!I&&!f&&e>i||f&&d&&m&&!y&&!I||c&&d&&m||!n&&m||!h)return 1;if(!c&&!f&&!I&&e<i||I&&n&&h&&!c&&!f||y&&n&&h||!d&&h||!m)return-1}return 0}function Hd(e,i,n){for(var c=-1,h=e.criteria,f=i.criteria,d=h.length,y=n.length;++c<d;){var m=bc(h[c],f[c]);if(m){if(c>=y)return m;var I=n[c];return m*(I=="desc"?-1:1)}}return e.index-i.index}function Ec(e,i,n,c){for(var h=-1,f=e.length,d=n.length,y=-1,m=i.length,I=we(f-d,0),P=_(m+I),O=!c;++y<m;)P[y]=i[y];for(;++h<d;)(O||h<f)&&(P[n[h]]=e[h]);for(;I--;)P[y++]=e[h++];return P}function Ic(e,i,n,c){for(var h=-1,f=e.length,d=-1,y=n.length,m=-1,I=i.length,P=we(f-y,0),O=_(P+I),C=!c;++h<P;)O[h]=e[h];for(var D=h;++m<I;)O[D+m]=i[m];for(;++d<y;)(C||h<f)&&(O[D+n[d]]=e[h++]);return O}function qe(e,i){var n=-1,c=e.length;for(i||(i=_(c));++n<c;)i[n]=e[n];return i}function mt(e,i,n,c){var h=!n;n||(n={});for(var f=-1,d=i.length;++f<d;){var y=i[f],m=c?c(n[y],e[y],y,n,e):r;m===r&&(m=e[y]),h?St(n,y,m):ti(n,y,m)}return n}function Vd(e,i){return mt(e,Ln(e),i)}function Kd(e,i){return mt(e,jc(e),i)}function is(e,i){return function(n,c){var h=z(n)?Gp:pd,f=i?i():{};return h(n,e,U(c,2),f)}}function Or(e){return F(function(i,n){var c=-1,h=n.length,f=h>1?n[h-1]:r,d=h>2?n[2]:r;for(f=e.length>3&&typeof f=="function"?(h--,f):r,d&&Ce(n[0],n[1],d)&&(f=h<3?r:f,h=1),i=re(i);++c<h;){var y=n[c];y&&e(i,y,c,f)}return i})}function Pc(e,i){return function(n,c){if(n==null)return n;if(!je(n))return e(n,c);for(var h=n.length,f=i?h:-1,d=re(n);(i?f--:++f<h)&&c(d[f],f,d)!==!1;);return n}}function Sc(e){return function(i,n,c){for(var h=-1,f=re(i),d=c(i),y=d.length;y--;){var m=d[e?y:++h];if(n(f[m],m,f)===!1)break}return i}}function Fd(e,i,n){var c=i&A,h=oi(e);function f(){var d=this&&this!==Ee&&this instanceof f?h:e;return d.apply(c?n:this,arguments)}return f}function Oc(e){return function(i){i=X(i);var n=wr(i)?ut(i):r,c=n?n[0]:i.charAt(0),h=n?Kt(n,1).join(""):i.slice(1);return c[e]()+h}}function Rr(e){return function(i){return rn(Pu(Iu(i).replace(Dp,"")),e,"")}}function oi(e){return function(){var i=arguments;switch(i.length){case 0:return new e;case 1:return new e(i[0]);case 2:return new e(i[0],i[1]);case 3:return new e(i[0],i[1],i[2]);case 4:return new e(i[0],i[1],i[2],i[3]);case 5:return new e(i[0],i[1],i[2],i[3],i[4]);case 6:return new e(i[0],i[1],i[2],i[3],i[4],i[5]);case 7:return new e(i[0],i[1],i[2],i[3],i[4],i[5],i[6])}var n=Sr(e.prototype),c=e.apply(n,i);return he(c)?c:n}}function Wd(e,i,n){var c=oi(e);function h(){for(var f=arguments.length,d=_(f),y=f,m=$r(h);y--;)d[y]=arguments[y];var I=f<3&&d[0]!==m&&d[f-1]!==m?[]:Lt(d,m);if(f-=I.length,f<n)return Tc(e,i,ss,h.placeholder,r,d,I,r,r,n-f);var P=this&&this!==Ee&&this instanceof h?c:e;return He(P,this,d)}return h}function Rc(e){return function(i,n,c){var h=re(i);if(!je(i)){var f=U(n,3);i=_e(i),n=function(y){return f(h[y],y,h)}}var d=e(i,n,c);return d>-1?h[f?i[d]:d]:r}}function $c(e){return Rt(function(i){var n=i.length,c=n,h=Xe.prototype.thru;for(e&&i.reverse();c--;){var f=i[c];if(typeof f!="function")throw new Ze(l);if(h&&!d&&cs(f)=="wrapper")var d=new Xe([],!0)}for(c=d?c:n;++c<n;){f=i[c];var y=cs(f),m=y=="wrapper"?Un(f):r;m&&zn(m[0])&&m[1]==(fe|J|ue|$e)&&!m[4].length&&m[9]==1?d=d[cs(m[0])].apply(d,m[3]):d=f.length==1&&zn(f)?d[y]():d.thru(f)}return function(){var I=arguments,P=I[0];if(d&&I.length==1&&z(P))return d.plant(P).value();for(var O=0,C=n?i[O].apply(this,I):P;++O<n;)C=i[O].call(this,C);return C}})}function ss(e,i,n,c,h,f,d,y,m,I){var P=i&fe,O=i&A,C=i&G,D=i&(J|Z),M=i&jt,V=C?r:oi(e);function L(){for(var W=arguments.length,Q=_(W),We=W;We--;)Q[We]=arguments[We];if(D)var Te=$r(L),Be=sf(Q,Te);if(c&&(Q=Ec(Q,c,h,D)),f&&(Q=Ic(Q,f,d,D)),W-=Be,D&&W<I){var ge=Lt(Q,Te);return Tc(e,i,ss,L.placeholder,n,Q,ge,y,m,I-W)}var pt=O?n:this,Tt=C?pt[e]:e;return W=Q.length,y?Q=pg(Q,y):M&&W>1&&Q.reverse(),P&&m<W&&(Q.length=m),this&&this!==Ee&&this instanceof L&&(Tt=V||oi(Tt)),Tt.apply(pt,Q)}return L}function Nc(e,i){return function(n,c){return _d(n,e,i(c),{})}}function ns(e,i){return function(n,c){var h;if(n===r&&c===r)return i;if(n!==r&&(h=n),c!==r){if(h===r)return c;typeof n=="string"||typeof c=="string"?(n=Ke(n),c=Ke(c)):(n=dc(n),c=dc(c)),h=e(n,c)}return h}}function An(e){return Rt(function(i){return i=ae(i,Ve(U())),F(function(n){var c=this;return e(i,function(h){return He(h,c,n)})})})}function os(e,i){i=i===r?" ":Ke(i);var n=i.length;if(n<2)return n?On(i,e):i;var c=On(i,Wi(e/_r(i)));return wr(i)?Kt(ut(c),0,e).join(""):c.slice(0,e)}function Bd(e,i,n,c){var h=i&A,f=oi(e);function d(){for(var y=-1,m=arguments.length,I=-1,P=c.length,O=_(P+m),C=this&&this!==Ee&&this instanceof d?f:e;++I<P;)O[I]=c[I];for(;m--;)O[I++]=arguments[++y];return He(C,h?n:this,O)}return d}function Cc(e){return function(i,n,c){return c&&typeof c!="number"&&Ce(i,n,c)&&(n=c=r),i=Ct(i),n===r?(n=i,i=0):n=Ct(n),c=c===r?i<n?1:-1:Ct(c),xd(i,n,c,e)}}function as(e){return function(i,n){return typeof i=="string"&&typeof n=="string"||(i=it(i),n=it(n)),e(i,n)}}function Tc(e,i,n,c,h,f,d,y,m,I){var P=i&J,O=P?d:r,C=P?r:d,D=P?f:r,M=P?r:f;i|=P?ue:De,i&=~(P?De:ue),i&pe||(i&=-4);var V=[e,i,h,D,O,M,C,y,m,I],L=n.apply(r,V);return zn(e)&&Vc(L,V),L.placeholder=c,Kc(L,e,i)}function Dn(e){var i=me[e];return function(n,c){if(n=it(n),c=c==null?0:Se(H(c),292),c&&Ka(n)){var h=(X(n)+"e").split("e"),f=i(h[0]+"e"+(+h[1]+c));return h=(X(f)+"e").split("e"),+(h[0]+"e"+(+h[1]-c))}return i(n)}}var Gd=Ir&&1/ji(new Ir([,-0]))[1]==Si?function(e){return new Ir(e)}:ro;function xc(e){return function(i){var n=Oe(i);return n==at?hn(i):n==ct?lf(i):rf(i,e(i))}}function Ot(e,i,n,c,h,f,d,y){var m=i&G;if(!m&&typeof e!="function")throw new Ze(l);var I=c?c.length:0;if(I||(i&=-97,c=h=r),d=d===r?d:we(H(d),0),y=y===r?y:H(y),I-=h?h.length:0,i&De){var P=c,O=h;c=h=r}var C=m?r:Un(e),D=[e,i,n,c,h,P,O,f,d,y];if(C&&ug(D,C),e=D[0],i=D[1],n=D[2],c=D[3],h=D[4],y=D[9]=D[9]===r?m?0:e.length:we(D[9]-I,0),!y&&i&(J|Z)&&(i&=-25),!i||i==A)var M=Fd(e,i,n);else i==J||i==Z?M=Wd(e,i,y):(i==ue||i==(A|ue))&&!h.length?M=Bd(e,i,n,c):M=ss.apply(r,D);var V=C?pc:Vc;return Kc(V(M,D),e,i)}function Ac(e,i,n,c){return e===r||lt(e,Er[n])&&!te.call(c,n)?i:e}function Dc(e,i,n,c,h,f){return he(e)&&he(i)&&(f.set(i,e),es(e,i,r,Dc,f),f.delete(i)),e}function Qd(e){return ui(e)?r:e}function qc(e,i,n,c,h,f){var d=n&x,y=e.length,m=i.length;if(y!=m&&!(d&&m>y))return!1;var I=f.get(e),P=f.get(i);if(I&&P)return I==i&&P==e;var O=-1,C=!0,D=n&K?new er:r;for(f.set(e,i),f.set(i,e);++O<y;){var M=e[O],V=i[O];if(c)var L=d?c(V,M,O,i,e,f):c(M,V,O,e,i,f);if(L!==r){if(L)continue;C=!1;break}if(D){if(!sn(i,function(W,Q){if(!Qr(D,Q)&&(M===W||h(M,W,n,c,f)))return D.push(Q)})){C=!1;break}}else if(!(M===V||h(M,V,n,c,f))){C=!1;break}}return f.delete(e),f.delete(i),C}function Jd(e,i,n,c,h,f,d){switch(n){case yr:if(e.byteLength!=i.byteLength||e.byteOffset!=i.byteOffset)return!1;e=e.buffer,i=i.buffer;case Gr:return!(e.byteLength!=i.byteLength||!f(new Hi(e),new Hi(i)));case Hr:case Vr:case Kr:return lt(+e,+i);case $i:return e.name==i.name&&e.message==i.message;case Fr:case Wr:return e==i+"";case at:var y=hn;case ct:var m=c&x;if(y||(y=ji),e.size!=i.size&&!m)return!1;var I=d.get(e);if(I)return I==i;c|=K,d.set(e,i);var P=qc(y(e),y(i),c,h,f,d);return d.delete(e),P;case Ci:if(ei)return ei.call(e)==ei.call(i)}return!1}function Yd(e,i,n,c,h,f){var d=n&x,y=qn(e),m=y.length,I=qn(i),P=I.length;if(m!=P&&!d)return!1;for(var O=m;O--;){var C=y[O];if(!(d?C in i:te.call(i,C)))return!1}var D=f.get(e),M=f.get(i);if(D&&M)return D==i&&M==e;var V=!0;f.set(e,i),f.set(i,e);for(var L=d;++O<m;){C=y[O];var W=e[C],Q=i[C];if(c)var We=d?c(Q,W,C,i,e,f):c(W,Q,C,e,i,f);if(!(We===r?W===Q||h(W,Q,n,c,f):We)){V=!1;break}L||(L=C=="constructor")}if(V&&!L){var Te=e.constructor,Be=i.constructor;Te!=Be&&"constructor"in e&&"constructor"in i&&!(typeof Te=="function"&&Te instanceof Te&&typeof Be=="function"&&Be instanceof Be)&&(V=!1)}return f.delete(e),f.delete(i),V}function Rt(e){return Vn(zc(e,r,Jc),e+"")}function qn(e){return tc(e,_e,Ln)}function jn(e){return tc(e,Ue,jc)}var Un=Gi?function(e){return Gi.get(e)}:ro;function cs(e){for(var i=e.name+"",n=Pr[i],c=te.call(Pr,i)?n.length:0;c--;){var h=n[c],f=h.func;if(f==null||f==e)return h.name}return i}function $r(e){var i=te.call(p,"placeholder")?p:e;return i.placeholder}function U(){var e=p.iteratee||eo;return e=e===eo?sc:e,arguments.length?e(arguments[0],arguments[1]):e}function us(e,i){var n=e.__data__;return ng(i)?n[typeof i=="string"?"string":"hash"]:n.map}function Mn(e){for(var i=_e(e),n=i.length;n--;){var c=i[n],h=e[c];i[n]=[c,h,Lc(h)]}return i}function ir(e,i){var n=cf(e,i);return ic(n)?n:r}function Zd(e){var i=te.call(e,Zt),n=e[Zt];try{e[Zt]=r;var c=!0}catch{}var h=ki.call(e);return c&&(i?e[Zt]=n:delete e[Zt]),h}var Ln=pn?function(e){return e==null?[]:(e=re(e),Ut(pn(e),function(i){return Ha.call(e,i)}))}:io,jc=pn?function(e){for(var i=[];e;)Mt(i,Ln(e)),e=Vi(e);return i}:io,Oe=Ne;(fn&&Oe(new fn(new ArrayBuffer(1)))!=yr||Yr&&Oe(new Yr)!=at||dn&&Oe(dn.resolve())!=Zo||Ir&&Oe(new Ir)!=ct||Zr&&Oe(new Zr)!=Br)&&(Oe=function(e){var i=Ne(e),n=i==Et?e.constructor:r,c=n?sr(n):"";if(c)switch(c){case Df:return yr;case qf:return at;case jf:return Zo;case Uf:return ct;case Mf:return Br}return i});function Xd(e,i,n){for(var c=-1,h=n.length;++c<h;){var f=n[c],d=f.size;switch(f.type){case"drop":e+=d;break;case"dropRight":i-=d;break;case"take":i=Se(i,e+d);break;case"takeRight":e=we(e,i-d);break}}return{start:e,end:i}}function eg(e){var i=e.match(np);return i?i[1].split(op):[]}function Uc(e,i,n){i=Vt(i,e);for(var c=-1,h=i.length,f=!1;++c<h;){var d=wt(i[c]);if(!(f=e!=null&&n(e,d)))break;e=e[d]}return f||++c!=h?f:(h=e==null?0:e.length,!!h&&ys(h)&&$t(d,h)&&(z(e)||nr(e)))}function tg(e){var i=e.length,n=new e.constructor(i);return i&&typeof e[0]=="string"&&te.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function Mc(e){return typeof e.constructor=="function"&&!ai(e)?Sr(Vi(e)):{}}function rg(e,i,n){var c=e.constructor;switch(i){case Gr:return xn(e);case Hr:case Vr:return new c(+e);case yr:return Ld(e,n);case Us:case Ms:case Ls:case ks:case zs:case Hs:case Vs:case Ks:case Fs:return _c(e,n);case at:return new c;case Kr:case Wr:return new c(e);case Fr:return kd(e);case ct:return new c;case Ci:return zd(e)}}function ig(e,i){var n=i.length;if(!n)return e;var c=n-1;return i[c]=(n>1?"& ":"")+i[c],i=i.join(n>2?", ":" "),e.replace(sp,`{
29
29
  /* [wrapped with `+i+`] */
30
- `)}function sg(e){return z(e)||nr(e)||!!(Va&&e&&e[Va])}function $t(e,i){var n=typeof e;return i=i??dr,!!i&&(n=="number"||n!="symbol"&&gp.test(e))&&e>-1&&e%1==0&&e<i}function Ce(e,i,n){if(!he(n))return!1;var c=typeof i;return(c=="number"?je(n)&&$t(i,n.length):c=="string"&&i in n)?ht(n[i],e):!1}function kn(e,i){if(z(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Fe(e)?!0:ep.test(e)||!Xl.test(e)||i!=null&&e in re(i)}function ng(e){var i=typeof e;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?e!=="__proto__":e===null}function zn(e){var i=cs(e),n=p[i];if(typeof n!="function"||!(i in B.prototype))return!1;if(e===n)return!0;var c=Un(n);return!!c&&e===c[0]}function og(e){return!!La&&La in e}var ag=Mi?Nt:so;function ai(e){var i=e&&e.constructor,n=typeof i=="function"&&i.prototype||Er;return e===n}function Lc(e){return e===e&&!he(e)}function kc(e,i){return function(n){return n==null?!1:n[e]===i&&(i!==r||e in re(n))}}function cg(e){var i=ds(e,function(c){return n.size===b&&n.clear(),c}),n=i.cache;return i}function ug(e,i){var n=e[1],c=i[1],h=n|c,f=h<(A|G|fe),d=c==fe&&n==J||c==fe&&n==$e&&e[7].length<=i[8]||c==(fe|$e)&&i[7].length<=i[8]&&n==J;if(!(f||d))return e;c&A&&(e[2]=i[2],h|=n&A?0:pe);var y=i[3];if(y){var m=e[3];e[3]=m?Ec(m,y,i[4]):y,e[4]=m?Lt(e[3],$):i[4]}return y=i[5],y&&(m=e[5],e[5]=m?Ic(m,y,i[6]):y,e[6]=m?Lt(e[5],$):i[6]),y=i[7],y&&(e[7]=y),c&fe&&(e[8]=e[8]==null?i[8]:Se(e[8],i[8])),e[9]==null&&(e[9]=i[9]),e[0]=i[0],e[1]=h,e}function hg(e){var i=[];if(e!=null)for(var n in re(e))i.push(n);return i}function lg(e){return ki.call(e)}function zc(e,i,n){return i=we(i===r?e.length-1:i,0),function(){for(var c=arguments,h=-1,f=we(c.length-i,0),d=_(f);++h<f;)d[h]=c[i+h];h=-1;for(var y=_(i+1);++h<i;)y[h]=c[h];return y[i]=n(d),He(e,this,y)}}function Hc(e,i){return i.length<2?e:rr(e,tt(i,0,-1))}function pg(e,i){for(var n=e.length,c=Se(i.length,n),h=qe(e);c--;){var f=i[c];e[c]=$t(f,n)?h[f]:r}return e}function Hn(e,i){if(!(i==="constructor"&&typeof e[i]=="function")&&i!="__proto__")return e[i]}var Vc=Fc(pc),ci=Rf||function(e,i){return Ee.setTimeout(e,i)},Vn=Fc(qd);function Kc(e,i,n){var c=i+"";return Vn(e,ig(c,fg(eg(c),n)))}function Fc(e){var i=0,n=0;return function(){var c=Tf(),h=Al-(c-n);if(n=c,h>0){if(++i>=xl)return arguments[0]}else i=0;return e.apply(r,arguments)}}function hs(e,i){var n=-1,c=e.length,h=c-1;for(i=i===r?c:i;++n<i;){var f=Sn(n,h),d=e[f];e[f]=e[n],e[n]=d}return e.length=i,e}var Wc=cg(function(e){var i=[];return e.charCodeAt(0)===46&&i.push(""),e.replace(tp,function(n,c,h,f){i.push(h?f.replace(up,"$1"):c||n)}),i});function wt(e){if(typeof e=="string"||Fe(e))return e;var i=e+"";return i=="0"&&1/e==-1/0?"-0":i}function sr(e){if(e!=null){try{return Li.call(e)}catch{}try{return e+""}catch{}}return""}function fg(e,i){return Ye(Ll,function(n){var c="_."+n[0];i&n[1]&&!Di(e,c)&&e.push(c)}),e.sort()}function Bc(e){if(e instanceof B)return e.clone();var i=new Xe(e.__wrapped__,e.__chain__);return i.__actions__=qe(e.__actions__),i.__index__=e.__index__,i.__values__=e.__values__,i}function dg(e,i,n){(n?Ce(e,i,n):i===r)?i=1:i=we(H(i),0);var c=e==null?0:e.length;if(!c||i<1)return[];for(var h=0,f=0,d=_(Wi(c/i));h<c;)d[f++]=tt(e,h,h+=i);return d}function gg(e){for(var i=-1,n=e==null?0:e.length,c=0,h=[];++i<n;){var f=e[i];f&&(h[c++]=f)}return h}function yg(){var e=arguments.length;if(!e)return[];for(var i=_(e-1),n=arguments[0],c=e;c--;)i[c-1]=arguments[c];return Mt(z(n)?qe(n):[n],Ie(i,1))}var vg=F(function(e,i){return de(e)?ri(e,Ie(i,1,de,!0)):[]}),mg=F(function(e,i){var n=rt(i);return de(n)&&(n=r),de(e)?ri(e,Ie(i,1,de,!0),U(n,2)):[]}),wg=F(function(e,i){var n=rt(i);return de(n)&&(n=r),de(e)?ri(e,Ie(i,1,de,!0),r,n):[]});function _g(e,i,n){var c=e==null?0:e.length;return c?(i=n||i===r?1:H(i),tt(e,i<0?0:i,c)):[]}function bg(e,i,n){var c=e==null?0:e.length;return c?(i=n||i===r?1:H(i),i=c-i,tt(e,0,i<0?0:i)):[]}function Eg(e,i){return e&&e.length?rs(e,U(i,3),!0,!0):[]}function Ig(e,i){return e&&e.length?rs(e,U(i,3),!0):[]}function Pg(e,i,n,c){var h=e==null?0:e.length;return h?(n&&typeof n!="number"&&Ce(e,i,n)&&(n=0,c=h),yd(e,i,n,c)):[]}function Gc(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=n==null?0:H(n);return h<0&&(h=we(c+h,0)),qi(e,U(i,3),h)}function Qc(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=c-1;return n!==r&&(h=H(n),h=n<0?we(c+h,0):Se(h,c-1)),qi(e,U(i,3),h,!0)}function Jc(e){var i=e==null?0:e.length;return i?Ie(e,1):[]}function Sg(e){var i=e==null?0:e.length;return i?Ie(e,Si):[]}function Og(e,i){var n=e==null?0:e.length;return n?(i=i===r?1:H(i),Ie(e,i)):[]}function Rg(e){for(var i=-1,n=e==null?0:e.length,c={};++i<n;){var h=e[i];c[h[0]]=h[1]}return c}function Yc(e){return e&&e.length?e[0]:r}function $g(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=n==null?0:H(n);return h<0&&(h=we(c+h,0)),mr(e,i,h)}function Ng(e){var i=e==null?0:e.length;return i?tt(e,0,-1):[]}var Cg=F(function(e){var i=ae(e,Cn);return i.length&&i[0]===e[0]?_n(i):[]}),Tg=F(function(e){var i=rt(e),n=ae(e,Cn);return i===rt(n)?i=r:n.pop(),n.length&&n[0]===e[0]?_n(n,U(i,2)):[]}),xg=F(function(e){var i=rt(e),n=ae(e,Cn);return i=typeof i=="function"?i:r,i&&n.pop(),n.length&&n[0]===e[0]?_n(n,r,i):[]});function Ag(e,i){return e==null?"":Nf.call(e,i)}function rt(e){var i=e==null?0:e.length;return i?e[i-1]:r}function Dg(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=c;return n!==r&&(h=H(n),h=h<0?we(c+h,0):Se(h,c-1)),i===i?ff(e,i,h):qi(e,Ta,h,!0)}function qg(e,i){return e&&e.length?cc(e,H(i)):r}var jg=F(Zc);function Zc(e,i){return e&&e.length&&i&&i.length?Pn(e,i):e}function Ug(e,i,n){return e&&e.length&&i&&i.length?Pn(e,i,U(n,2)):e}function Mg(e,i,n){return e&&e.length&&i&&i.length?Pn(e,i,r,n):e}var Lg=Rt(function(e,i){var n=e==null?0:e.length,c=yn(e,i);return lc(e,ae(i,function(h){return $t(h,n)?+h:h}).sort(bc)),c});function kg(e,i){var n=[];if(!(e&&e.length))return n;var c=-1,h=[],f=e.length;for(i=U(i,3);++c<f;){var d=e[c];i(d,c,e)&&(n.push(d),h.push(c))}return lc(e,h),n}function Kn(e){return e==null?e:Af.call(e)}function zg(e,i,n){var c=e==null?0:e.length;return c?(n&&typeof n!="number"&&Ce(e,i,n)?(i=0,n=c):(i=i==null?0:H(i),n=n===r?c:H(n)),tt(e,i,n)):[]}function Hg(e,i){return ts(e,i)}function Vg(e,i,n){return Rn(e,i,U(n,2))}function Kg(e,i){var n=e==null?0:e.length;if(n){var c=ts(e,i);if(c<n&&ht(e[c],i))return c}return-1}function Fg(e,i){return ts(e,i,!0)}function Wg(e,i,n){return Rn(e,i,U(n,2),!0)}function Bg(e,i){var n=e==null?0:e.length;if(n){var c=ts(e,i,!0)-1;if(ht(e[c],i))return c}return-1}function Gg(e){return e&&e.length?fc(e):[]}function Qg(e,i){return e&&e.length?fc(e,U(i,2)):[]}function Jg(e){var i=e==null?0:e.length;return i?tt(e,1,i):[]}function Yg(e,i,n){return e&&e.length?(i=n||i===r?1:H(i),tt(e,0,i<0?0:i)):[]}function Zg(e,i,n){var c=e==null?0:e.length;return c?(i=n||i===r?1:H(i),i=c-i,tt(e,i<0?0:i,c)):[]}function Xg(e,i){return e&&e.length?rs(e,U(i,3),!1,!0):[]}function ey(e,i){return e&&e.length?rs(e,U(i,3)):[]}var ty=F(function(e){return Ht(Ie(e,1,de,!0))}),ry=F(function(e){var i=rt(e);return de(i)&&(i=r),Ht(Ie(e,1,de,!0),U(i,2))}),iy=F(function(e){var i=rt(e);return i=typeof i=="function"?i:r,Ht(Ie(e,1,de,!0),r,i)});function sy(e){return e&&e.length?Ht(e):[]}function ny(e,i){return e&&e.length?Ht(e,U(i,2)):[]}function oy(e,i){return i=typeof i=="function"?i:r,e&&e.length?Ht(e,r,i):[]}function Fn(e){if(!(e&&e.length))return[];var i=0;return e=Ut(e,function(n){if(de(n))return i=we(n.length,i),!0}),cn(i,function(n){return ae(e,nn(n))})}function Xc(e,i){if(!(e&&e.length))return[];var n=Fn(e);return i==null?n:ae(n,function(c){return He(i,r,c)})}var ay=F(function(e,i){return de(e)?ri(e,i):[]}),cy=F(function(e){return Nn(Ut(e,de))}),uy=F(function(e){var i=rt(e);return de(i)&&(i=r),Nn(Ut(e,de),U(i,2))}),hy=F(function(e){var i=rt(e);return i=typeof i=="function"?i:r,Nn(Ut(e,de),r,i)}),ly=F(Fn);function py(e,i){return vc(e||[],i||[],ti)}function fy(e,i){return vc(e||[],i||[],ni)}var dy=F(function(e){var i=e.length,n=i>1?e[i-1]:r;return n=typeof n=="function"?(e.pop(),n):r,Xc(e,n)});function eu(e){var i=p(e);return i.__chain__=!0,i}function gy(e,i){return i(e),e}function ls(e,i){return i(e)}var yy=Rt(function(e){var i=e.length,n=i?e[0]:0,c=this.__wrapped__,h=function(f){return yn(f,e)};return i>1||this.__actions__.length||!(c instanceof B)||!$t(n)?this.thru(h):(c=c.slice(n,+n+(i?1:0)),c.__actions__.push({func:ls,args:[h],thisArg:r}),new Xe(c,this.__chain__).thru(function(f){return i&&!f.length&&f.push(r),f}))});function vy(){return eu(this)}function my(){return new Xe(this.value(),this.__chain__)}function wy(){this.__values__===r&&(this.__values__=du(this.value()));var e=this.__index__>=this.__values__.length,i=e?r:this.__values__[this.__index__++];return{done:e,value:i}}function _y(){return this}function by(e){for(var i,n=this;n instanceof Ji;){var c=Bc(n);c.__index__=0,c.__values__=r,i?h.__wrapped__=c:i=c;var h=c;n=n.__wrapped__}return h.__wrapped__=e,i}function Ey(){var e=this.__wrapped__;if(e instanceof B){var i=e;return this.__actions__.length&&(i=new B(this)),i=i.reverse(),i.__actions__.push({func:ls,args:[Kn],thisArg:r}),new Xe(i,this.__chain__)}return this.thru(Kn)}function Iy(){return yc(this.__wrapped__,this.__actions__)}var Py=is(function(e,i,n){te.call(e,n)?++e[n]:St(e,n,1)});function Sy(e,i,n){var c=z(e)?Na:gd;return n&&Ce(e,i,n)&&(i=r),c(e,U(i,3))}function Oy(e,i){var n=z(e)?Ut:Xa;return n(e,U(i,3))}var Ry=Rc(Gc),$y=Rc(Qc);function Ny(e,i){return Ie(ps(e,i),1)}function Cy(e,i){return Ie(ps(e,i),Si)}function Ty(e,i,n){return n=n===r?1:H(n),Ie(ps(e,i),n)}function tu(e,i){var n=z(e)?Ye:zt;return n(e,U(i,3))}function ru(e,i){var n=z(e)?Qp:Za;return n(e,U(i,3))}var xy=is(function(e,i,n){te.call(e,n)?e[n].push(i):St(e,n,[i])});function Ay(e,i,n,c){e=je(e)?e:Cr(e),n=n&&!c?H(n):0;var h=e.length;return n<0&&(n=we(h+n,0)),vs(e)?n<=h&&e.indexOf(i,n)>-1:!!h&&mr(e,i,n)>-1}var Dy=F(function(e,i,n){var c=-1,h=typeof i=="function",f=je(e)?_(e.length):[];return zt(e,function(d){f[++c]=h?He(i,d,n):ii(d,i,n)}),f}),qy=is(function(e,i,n){St(e,n,i)});function ps(e,i){var n=z(e)?ae:nc;return n(e,U(i,3))}function jy(e,i,n,c){return e==null?[]:(z(i)||(i=i==null?[]:[i]),n=c?r:n,z(n)||(n=n==null?[]:[n]),uc(e,i,n))}var Uy=is(function(e,i,n){e[n?0:1].push(i)},function(){return[[],[]]});function My(e,i,n){var c=z(e)?rn:Aa,h=arguments.length<3;return c(e,U(i,4),n,h,zt)}function Ly(e,i,n){var c=z(e)?Jp:Aa,h=arguments.length<3;return c(e,U(i,4),n,h,Za)}function ky(e,i){var n=z(e)?Ut:Xa;return n(e,gs(U(i,3)))}function zy(e){var i=z(e)?Ga:Ad;return i(e)}function Hy(e,i,n){(n?Ce(e,i,n):i===r)?i=1:i=H(i);var c=z(e)?hd:Dd;return c(e,i)}function Vy(e){var i=z(e)?ld:jd;return i(e)}function Ky(e){if(e==null)return 0;if(je(e))return vs(e)?_r(e):e.length;var i=Oe(e);return i==ot||i==at?e.size:En(e).length}function Fy(e,i,n){var c=z(e)?sn:Ud;return n&&Ce(e,i,n)&&(i=r),c(e,U(i,3))}var Wy=F(function(e,i){if(e==null)return[];var n=i.length;return n>1&&Ce(e,i[0],i[1])?i=[]:n>2&&Ce(i[0],i[1],i[2])&&(i=[i[0]]),uc(e,Ie(i,1),[])}),fs=Of||function(){return Ee.Date.now()};function By(e,i){if(typeof i!="function")throw new Ze(l);return e=H(e),function(){if(--e<1)return i.apply(this,arguments)}}function iu(e,i,n){return i=n?r:i,i=e&&i==null?e.length:i,Ot(e,fe,r,r,r,r,i)}function su(e,i){var n;if(typeof i!="function")throw new Ze(l);return e=H(e),function(){return--e>0&&(n=i.apply(this,arguments)),e<=1&&(i=r),n}}var Wn=F(function(e,i,n){var c=A;if(n.length){var h=Lt(n,$r(Wn));c|=ue}return Ot(e,c,i,n,h)}),nu=F(function(e,i,n){var c=A|G;if(n.length){var h=Lt(n,$r(nu));c|=ue}return Ot(i,c,e,n,h)});function ou(e,i,n){i=n?r:i;var c=Ot(e,J,r,r,r,r,r,i);return c.placeholder=ou.placeholder,c}function au(e,i,n){i=n?r:i;var c=Ot(e,Z,r,r,r,r,r,i);return c.placeholder=au.placeholder,c}function cu(e,i,n){var c,h,f,d,y,m,I=0,P=!1,O=!1,C=!0;if(typeof e!="function")throw new Ze(l);i=it(i)||0,he(n)&&(P=!!n.leading,O="maxWait"in n,f=O?we(it(n.maxWait)||0,i):f,C="trailing"in n?!!n.trailing:C);function D(ge){var lt=c,Tt=h;return c=h=r,I=ge,d=e.apply(Tt,lt),d}function M(ge){return I=ge,y=ci(W,i),P?D(ge):d}function V(ge){var lt=ge-m,Tt=ge-I,Ru=i-lt;return O?Se(Ru,f-Tt):Ru}function L(ge){var lt=ge-m,Tt=ge-I;return m===r||lt>=i||lt<0||O&&Tt>=f}function W(){var ge=fs();if(L(ge))return Q(ge);y=ci(W,V(ge))}function Q(ge){return y=r,C&&c?D(ge):(c=h=r,d)}function We(){y!==r&&mc(y),I=0,c=m=h=y=r}function Te(){return y===r?d:Q(fs())}function Be(){var ge=fs(),lt=L(ge);if(c=arguments,h=this,m=ge,lt){if(y===r)return M(m);if(O)return mc(y),y=ci(W,i),D(m)}return y===r&&(y=ci(W,i)),d}return Be.cancel=We,Be.flush=Te,Be}var Gy=F(function(e,i){return Ya(e,1,i)}),Qy=F(function(e,i,n){return Ya(e,it(i)||0,n)});function Jy(e){return Ot(e,jt)}function ds(e,i){if(typeof e!="function"||i!=null&&typeof i!="function")throw new Ze(l);var n=function(){var c=arguments,h=i?i.apply(this,c):c[0],f=n.cache;if(f.has(h))return f.get(h);var d=e.apply(this,c);return n.cache=f.set(h,d)||f,d};return n.cache=new(ds.Cache||Pt),n}ds.Cache=Pt;function gs(e){if(typeof e!="function")throw new Ze(l);return function(){var i=arguments;switch(i.length){case 0:return!e.call(this);case 1:return!e.call(this,i[0]);case 2:return!e.call(this,i[0],i[1]);case 3:return!e.call(this,i[0],i[1],i[2])}return!e.apply(this,i)}}function Yy(e){return su(2,e)}var Zy=Md(function(e,i){i=i.length==1&&z(i[0])?ae(i[0],Ve(U())):ae(Ie(i,1),Ve(U()));var n=i.length;return F(function(c){for(var h=-1,f=Se(c.length,n);++h<f;)c[h]=i[h].call(this,c[h]);return He(e,this,c)})}),Bn=F(function(e,i){var n=Lt(i,$r(Bn));return Ot(e,ue,r,i,n)}),uu=F(function(e,i){var n=Lt(i,$r(uu));return Ot(e,De,r,i,n)}),Xy=Rt(function(e,i){return Ot(e,$e,r,r,r,i)});function ev(e,i){if(typeof e!="function")throw new Ze(l);return i=i===r?i:H(i),F(e,i)}function tv(e,i){if(typeof e!="function")throw new Ze(l);return i=i==null?0:we(H(i),0),F(function(n){var c=n[i],h=Kt(n,0,i);return c&&Mt(h,c),He(e,this,h)})}function rv(e,i,n){var c=!0,h=!0;if(typeof e!="function")throw new Ze(l);return he(n)&&(c="leading"in n?!!n.leading:c,h="trailing"in n?!!n.trailing:h),cu(e,i,{leading:c,maxWait:i,trailing:h})}function iv(e){return iu(e,1)}function sv(e,i){return Bn(Tn(i),e)}function nv(){if(!arguments.length)return[];var e=arguments[0];return z(e)?e:[e]}function ov(e){return et(e,j)}function av(e,i){return i=typeof i=="function"?i:r,et(e,j,i)}function cv(e){return et(e,S|j)}function uv(e,i){return i=typeof i=="function"?i:r,et(e,S|j,i)}function hv(e,i){return i==null||Ja(e,i,_e(i))}function ht(e,i){return e===i||e!==e&&i!==i}var lv=as(wn),pv=as(function(e,i){return e>=i}),nr=rc(function(){return arguments}())?rc:function(e){return le(e)&&te.call(e,"callee")&&!Ha.call(e,"callee")},z=_.isArray,fv=Ia?Ve(Ia):bd;function je(e){return e!=null&&ys(e.length)&&!Nt(e)}function de(e){return le(e)&&je(e)}function dv(e){return e===!0||e===!1||le(e)&&Ne(e)==Hr}var Ft=$f||so,gv=Pa?Ve(Pa):Ed;function yv(e){return le(e)&&e.nodeType===1&&!ui(e)}function vv(e){if(e==null)return!0;if(je(e)&&(z(e)||typeof e=="string"||typeof e.splice=="function"||Ft(e)||Nr(e)||nr(e)))return!e.length;var i=Oe(e);if(i==ot||i==at)return!e.size;if(ai(e))return!En(e).length;for(var n in e)if(te.call(e,n))return!1;return!0}function mv(e,i){return si(e,i)}function wv(e,i,n){n=typeof n=="function"?n:r;var c=n?n(e,i):r;return c===r?si(e,i,r,n):!!c}function Gn(e){if(!le(e))return!1;var i=Ne(e);return i==$i||i==zl||typeof e.message=="string"&&typeof e.name=="string"&&!ui(e)}function _v(e){return typeof e=="number"&&Ka(e)}function Nt(e){if(!he(e))return!1;var i=Ne(e);return i==Ni||i==Yo||i==kl||i==Vl}function hu(e){return typeof e=="number"&&e==H(e)}function ys(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=dr}function he(e){var i=typeof e;return e!=null&&(i=="object"||i=="function")}function le(e){return e!=null&&typeof e=="object"}var lu=Sa?Ve(Sa):Pd;function bv(e,i){return e===i||bn(e,i,Mn(i))}function Ev(e,i,n){return n=typeof n=="function"?n:r,bn(e,i,Mn(i),n)}function Iv(e){return pu(e)&&e!=+e}function Pv(e){if(ag(e))throw new k(u);return ic(e)}function Sv(e){return e===null}function Ov(e){return e==null}function pu(e){return typeof e=="number"||le(e)&&Ne(e)==Kr}function ui(e){if(!le(e)||Ne(e)!=Et)return!1;var i=Vi(e);if(i===null)return!0;var n=te.call(i,"constructor")&&i.constructor;return typeof n=="function"&&n instanceof n&&Li.call(n)==Ef}var Qn=Oa?Ve(Oa):Sd;function Rv(e){return hu(e)&&e>=-9007199254740991&&e<=dr}var fu=Ra?Ve(Ra):Od;function vs(e){return typeof e=="string"||!z(e)&&le(e)&&Ne(e)==Wr}function Fe(e){return typeof e=="symbol"||le(e)&&Ne(e)==Ci}var Nr=$a?Ve($a):Rd;function $v(e){return e===r}function Nv(e){return le(e)&&Oe(e)==Br}function Cv(e){return le(e)&&Ne(e)==Fl}var Tv=as(In),xv=as(function(e,i){return e<=i});function du(e){if(!e)return[];if(je(e))return vs(e)?ct(e):qe(e);if(Jr&&e[Jr])return hf(e[Jr]());var i=Oe(e),n=i==ot?hn:i==at?ji:Cr;return n(e)}function Ct(e){if(!e)return e===0?e:0;if(e=it(e),e===Si||e===-1/0){var i=e<0?-1:1;return i*jl}return e===e?e:0}function H(e){var i=Ct(e),n=i%1;return i===i?n?i-n:i:0}function gu(e){return e?tr(H(e),0,yt):0}function it(e){if(typeof e=="number")return e;if(Fe(e))return Oi;if(he(e)){var i=typeof e.valueOf=="function"?e.valueOf():e;e=he(i)?i+"":i}if(typeof e!="string")return e===0?e:+e;e=Da(e);var n=pp.test(e);return n||dp.test(e)?Wp(e.slice(2),n?2:8):lp.test(e)?Oi:+e}function yu(e){return mt(e,Ue(e))}function Av(e){return e?tr(H(e),-9007199254740991,dr):e===0?e:0}function X(e){return e==null?"":Ke(e)}var Dv=Or(function(e,i){if(ai(i)||je(i)){mt(i,_e(i),e);return}for(var n in i)te.call(i,n)&&ti(e,n,i[n])}),vu=Or(function(e,i){mt(i,Ue(i),e)}),ms=Or(function(e,i,n,c){mt(i,Ue(i),e,c)}),qv=Or(function(e,i,n,c){mt(i,_e(i),e,c)}),jv=Rt(yn);function Uv(e,i){var n=Sr(e);return i==null?n:Qa(n,i)}var Mv=F(function(e,i){e=re(e);var n=-1,c=i.length,h=c>2?i[2]:r;for(h&&Ce(i[0],i[1],h)&&(c=1);++n<c;)for(var f=i[n],d=Ue(f),y=-1,m=d.length;++y<m;){var I=d[y],P=e[I];(P===r||ht(P,Er[I])&&!te.call(e,I))&&(e[I]=f[I])}return e}),Lv=F(function(e){return e.push(r,Dc),He(mu,r,e)});function kv(e,i){return Ca(e,U(i,3),vt)}function zv(e,i){return Ca(e,U(i,3),mn)}function Hv(e,i){return e==null?e:vn(e,U(i,3),Ue)}function Vv(e,i){return e==null?e:ec(e,U(i,3),Ue)}function Kv(e,i){return e&&vt(e,U(i,3))}function Fv(e,i){return e&&mn(e,U(i,3))}function Wv(e){return e==null?[]:Xi(e,_e(e))}function Bv(e){return e==null?[]:Xi(e,Ue(e))}function Jn(e,i,n){var c=e==null?r:rr(e,i);return c===r?n:c}function Gv(e,i){return e!=null&&Uc(e,i,vd)}function Yn(e,i){return e!=null&&Uc(e,i,md)}var Qv=Nc(function(e,i,n){i!=null&&typeof i.toString!="function"&&(i=ki.call(i)),e[i]=n},Xn(Me)),Jv=Nc(function(e,i,n){i!=null&&typeof i.toString!="function"&&(i=ki.call(i)),te.call(e,i)?e[i].push(n):e[i]=[n]},U),Yv=F(ii);function _e(e){return je(e)?Ba(e):En(e)}function Ue(e){return je(e)?Ba(e,!0):$d(e)}function Zv(e,i){var n={};return i=U(i,3),vt(e,function(c,h,f){St(n,i(c,h,f),c)}),n}function Xv(e,i){var n={};return i=U(i,3),vt(e,function(c,h,f){St(n,h,i(c,h,f))}),n}var em=Or(function(e,i,n){es(e,i,n)}),mu=Or(function(e,i,n,c){es(e,i,n,c)}),tm=Rt(function(e,i){var n={};if(e==null)return n;var c=!1;i=ae(i,function(f){return f=Vt(f,e),c||(c=f.length>1),f}),mt(e,jn(e),n),c&&(n=et(n,S|R|j,Qd));for(var h=i.length;h--;)$n(n,i[h]);return n});function rm(e,i){return wu(e,gs(U(i)))}var im=Rt(function(e,i){return e==null?{}:Cd(e,i)});function wu(e,i){if(e==null)return{};var n=ae(jn(e),function(c){return[c]});return i=U(i),hc(e,n,function(c,h){return i(c,h[0])})}function sm(e,i,n){i=Vt(i,e);var c=-1,h=i.length;for(h||(h=1,e=r);++c<h;){var f=e==null?r:e[wt(i[c])];f===r&&(c=h,f=n),e=Nt(f)?f.call(e):f}return e}function nm(e,i,n){return e==null?e:ni(e,i,n)}function om(e,i,n,c){return c=typeof c=="function"?c:r,e==null?e:ni(e,i,n,c)}var _u=xc(_e),bu=xc(Ue);function am(e,i,n){var c=z(e),h=c||Ft(e)||Nr(e);if(i=U(i,4),n==null){var f=e&&e.constructor;h?n=c?new f:[]:he(e)?n=Nt(f)?Sr(Vi(e)):{}:n={}}return(h?Ye:vt)(e,function(d,y,m){return i(n,d,y,m)}),n}function cm(e,i){return e==null?!0:$n(e,i)}function um(e,i,n){return e==null?e:gc(e,i,Tn(n))}function hm(e,i,n,c){return c=typeof c=="function"?c:r,e==null?e:gc(e,i,Tn(n),c)}function Cr(e){return e==null?[]:un(e,_e(e))}function lm(e){return e==null?[]:un(e,Ue(e))}function pm(e,i,n){return n===r&&(n=i,i=r),n!==r&&(n=it(n),n=n===n?n:0),i!==r&&(i=it(i),i=i===i?i:0),tr(it(e),i,n)}function fm(e,i,n){return i=Ct(i),n===r?(n=i,i=0):n=Ct(n),e=it(e),wd(e,i,n)}function dm(e,i,n){if(n&&typeof n!="boolean"&&Ce(e,i,n)&&(i=n=r),n===r&&(typeof i=="boolean"?(n=i,i=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&i===r?(e=0,i=1):(e=Ct(e),i===r?(i=e,e=0):i=Ct(i)),e>i){var c=e;e=i,i=c}if(n||e%1||i%1){var h=Fa();return Se(e+h*(i-e+Fp("1e-"+((h+"").length-1))),i)}return Sn(e,i)}var gm=Rr(function(e,i,n){return i=i.toLowerCase(),e+(n?Eu(i):i)});function Eu(e){return Zn(X(e).toLowerCase())}function Iu(e){return e=X(e),e&&e.replace(yp,nf).replace(qp,"")}function ym(e,i,n){e=X(e),i=Ke(i);var c=e.length;n=n===r?c:tr(H(n),0,c);var h=n;return n-=i.length,n>=0&&e.slice(n,h)==i}function vm(e){return e=X(e),e&&Jl.test(e)?e.replace(ea,of):e}function mm(e){return e=X(e),e&&rp.test(e)?e.replace(Ws,"\\$&"):e}var wm=Rr(function(e,i,n){return e+(n?"-":"")+i.toLowerCase()}),_m=Rr(function(e,i,n){return e+(n?" ":"")+i.toLowerCase()}),bm=Oc("toLowerCase");function Em(e,i,n){e=X(e),i=H(i);var c=i?_r(e):0;if(!i||c>=i)return e;var h=(i-c)/2;return os(Bi(h),n)+e+os(Wi(h),n)}function Im(e,i,n){e=X(e),i=H(i);var c=i?_r(e):0;return i&&c<i?e+os(i-c,n):e}function Pm(e,i,n){e=X(e),i=H(i);var c=i?_r(e):0;return i&&c<i?os(i-c,n)+e:e}function Sm(e,i,n){return n||i==null?i=0:i&&(i=+i),xf(X(e).replace(Bs,""),i||0)}function Om(e,i,n){return(n?Ce(e,i,n):i===r)?i=1:i=H(i),On(X(e),i)}function Rm(){var e=arguments,i=X(e[0]);return e.length<3?i:i.replace(e[1],e[2])}var $m=Rr(function(e,i,n){return e+(n?"_":"")+i.toLowerCase()});function Nm(e,i,n){return n&&typeof n!="number"&&Ce(e,i,n)&&(i=n=r),n=n===r?yt:n>>>0,n?(e=X(e),e&&(typeof i=="string"||i!=null&&!Qn(i))&&(i=Ke(i),!i&&wr(e))?Kt(ct(e),0,n):e.split(i,n)):[]}var Cm=Rr(function(e,i,n){return e+(n?" ":"")+Zn(i)});function Tm(e,i,n){return e=X(e),n=n==null?0:tr(H(n),0,e.length),i=Ke(i),e.slice(n,n+i.length)==i}function xm(e,i,n){var c=p.templateSettings;n&&Ce(e,i,n)&&(i=r),e=X(e),i=ms({},i,c,Ac);var h=ms({},i.imports,c.imports,Ac),f=_e(h),d=un(h,f),y,m,I=0,P=i.interpolate||Ti,O="__p += '",C=ln((i.escape||Ti).source+"|"+P.source+"|"+(P===ta?hp:Ti).source+"|"+(i.evaluate||Ti).source+"|$","g"),D="//# sourceURL="+(te.call(i,"sourceURL")?(i.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++kp+"]")+`
30
+ `)}function sg(e){return z(e)||nr(e)||!!(Va&&e&&e[Va])}function $t(e,i){var n=typeof e;return i=i??dr,!!i&&(n=="number"||n!="symbol"&&gp.test(e))&&e>-1&&e%1==0&&e<i}function Ce(e,i,n){if(!he(n))return!1;var c=typeof i;return(c=="number"?je(n)&&$t(i,n.length):c=="string"&&i in n)?lt(n[i],e):!1}function kn(e,i){if(z(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Fe(e)?!0:ep.test(e)||!Xl.test(e)||i!=null&&e in re(i)}function ng(e){var i=typeof e;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?e!=="__proto__":e===null}function zn(e){var i=cs(e),n=p[i];if(typeof n!="function"||!(i in B.prototype))return!1;if(e===n)return!0;var c=Un(n);return!!c&&e===c[0]}function og(e){return!!La&&La in e}var ag=Mi?Nt:so;function ai(e){var i=e&&e.constructor,n=typeof i=="function"&&i.prototype||Er;return e===n}function Lc(e){return e===e&&!he(e)}function kc(e,i){return function(n){return n==null?!1:n[e]===i&&(i!==r||e in re(n))}}function cg(e){var i=ds(e,function(c){return n.size===b&&n.clear(),c}),n=i.cache;return i}function ug(e,i){var n=e[1],c=i[1],h=n|c,f=h<(A|G|fe),d=c==fe&&n==J||c==fe&&n==$e&&e[7].length<=i[8]||c==(fe|$e)&&i[7].length<=i[8]&&n==J;if(!(f||d))return e;c&A&&(e[2]=i[2],h|=n&A?0:pe);var y=i[3];if(y){var m=e[3];e[3]=m?Ec(m,y,i[4]):y,e[4]=m?Lt(e[3],$):i[4]}return y=i[5],y&&(m=e[5],e[5]=m?Ic(m,y,i[6]):y,e[6]=m?Lt(e[5],$):i[6]),y=i[7],y&&(e[7]=y),c&fe&&(e[8]=e[8]==null?i[8]:Se(e[8],i[8])),e[9]==null&&(e[9]=i[9]),e[0]=i[0],e[1]=h,e}function hg(e){var i=[];if(e!=null)for(var n in re(e))i.push(n);return i}function lg(e){return ki.call(e)}function zc(e,i,n){return i=we(i===r?e.length-1:i,0),function(){for(var c=arguments,h=-1,f=we(c.length-i,0),d=_(f);++h<f;)d[h]=c[i+h];h=-1;for(var y=_(i+1);++h<i;)y[h]=c[h];return y[i]=n(d),He(e,this,y)}}function Hc(e,i){return i.length<2?e:rr(e,tt(i,0,-1))}function pg(e,i){for(var n=e.length,c=Se(i.length,n),h=qe(e);c--;){var f=i[c];e[c]=$t(f,n)?h[f]:r}return e}function Hn(e,i){if(!(i==="constructor"&&typeof e[i]=="function")&&i!="__proto__")return e[i]}var Vc=Fc(pc),ci=Rf||function(e,i){return Ee.setTimeout(e,i)},Vn=Fc(qd);function Kc(e,i,n){var c=i+"";return Vn(e,ig(c,fg(eg(c),n)))}function Fc(e){var i=0,n=0;return function(){var c=Tf(),h=Al-(c-n);if(n=c,h>0){if(++i>=xl)return arguments[0]}else i=0;return e.apply(r,arguments)}}function hs(e,i){var n=-1,c=e.length,h=c-1;for(i=i===r?c:i;++n<i;){var f=Sn(n,h),d=e[f];e[f]=e[n],e[n]=d}return e.length=i,e}var Wc=cg(function(e){var i=[];return e.charCodeAt(0)===46&&i.push(""),e.replace(tp,function(n,c,h,f){i.push(h?f.replace(up,"$1"):c||n)}),i});function wt(e){if(typeof e=="string"||Fe(e))return e;var i=e+"";return i=="0"&&1/e==-1/0?"-0":i}function sr(e){if(e!=null){try{return Li.call(e)}catch{}try{return e+""}catch{}}return""}function fg(e,i){return Ye(Ll,function(n){var c="_."+n[0];i&n[1]&&!Di(e,c)&&e.push(c)}),e.sort()}function Bc(e){if(e instanceof B)return e.clone();var i=new Xe(e.__wrapped__,e.__chain__);return i.__actions__=qe(e.__actions__),i.__index__=e.__index__,i.__values__=e.__values__,i}function dg(e,i,n){(n?Ce(e,i,n):i===r)?i=1:i=we(H(i),0);var c=e==null?0:e.length;if(!c||i<1)return[];for(var h=0,f=0,d=_(Wi(c/i));h<c;)d[f++]=tt(e,h,h+=i);return d}function gg(e){for(var i=-1,n=e==null?0:e.length,c=0,h=[];++i<n;){var f=e[i];f&&(h[c++]=f)}return h}function yg(){var e=arguments.length;if(!e)return[];for(var i=_(e-1),n=arguments[0],c=e;c--;)i[c-1]=arguments[c];return Mt(z(n)?qe(n):[n],Ie(i,1))}var vg=F(function(e,i){return de(e)?ri(e,Ie(i,1,de,!0)):[]}),mg=F(function(e,i){var n=rt(i);return de(n)&&(n=r),de(e)?ri(e,Ie(i,1,de,!0),U(n,2)):[]}),wg=F(function(e,i){var n=rt(i);return de(n)&&(n=r),de(e)?ri(e,Ie(i,1,de,!0),r,n):[]});function _g(e,i,n){var c=e==null?0:e.length;return c?(i=n||i===r?1:H(i),tt(e,i<0?0:i,c)):[]}function bg(e,i,n){var c=e==null?0:e.length;return c?(i=n||i===r?1:H(i),i=c-i,tt(e,0,i<0?0:i)):[]}function Eg(e,i){return e&&e.length?rs(e,U(i,3),!0,!0):[]}function Ig(e,i){return e&&e.length?rs(e,U(i,3),!0):[]}function Pg(e,i,n,c){var h=e==null?0:e.length;return h?(n&&typeof n!="number"&&Ce(e,i,n)&&(n=0,c=h),yd(e,i,n,c)):[]}function Gc(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=n==null?0:H(n);return h<0&&(h=we(c+h,0)),qi(e,U(i,3),h)}function Qc(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=c-1;return n!==r&&(h=H(n),h=n<0?we(c+h,0):Se(h,c-1)),qi(e,U(i,3),h,!0)}function Jc(e){var i=e==null?0:e.length;return i?Ie(e,1):[]}function Sg(e){var i=e==null?0:e.length;return i?Ie(e,Si):[]}function Og(e,i){var n=e==null?0:e.length;return n?(i=i===r?1:H(i),Ie(e,i)):[]}function Rg(e){for(var i=-1,n=e==null?0:e.length,c={};++i<n;){var h=e[i];c[h[0]]=h[1]}return c}function Yc(e){return e&&e.length?e[0]:r}function $g(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=n==null?0:H(n);return h<0&&(h=we(c+h,0)),mr(e,i,h)}function Ng(e){var i=e==null?0:e.length;return i?tt(e,0,-1):[]}var Cg=F(function(e){var i=ae(e,Cn);return i.length&&i[0]===e[0]?_n(i):[]}),Tg=F(function(e){var i=rt(e),n=ae(e,Cn);return i===rt(n)?i=r:n.pop(),n.length&&n[0]===e[0]?_n(n,U(i,2)):[]}),xg=F(function(e){var i=rt(e),n=ae(e,Cn);return i=typeof i=="function"?i:r,i&&n.pop(),n.length&&n[0]===e[0]?_n(n,r,i):[]});function Ag(e,i){return e==null?"":Nf.call(e,i)}function rt(e){var i=e==null?0:e.length;return i?e[i-1]:r}function Dg(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=c;return n!==r&&(h=H(n),h=h<0?we(c+h,0):Se(h,c-1)),i===i?ff(e,i,h):qi(e,Ta,h,!0)}function qg(e,i){return e&&e.length?cc(e,H(i)):r}var jg=F(Zc);function Zc(e,i){return e&&e.length&&i&&i.length?Pn(e,i):e}function Ug(e,i,n){return e&&e.length&&i&&i.length?Pn(e,i,U(n,2)):e}function Mg(e,i,n){return e&&e.length&&i&&i.length?Pn(e,i,r,n):e}var Lg=Rt(function(e,i){var n=e==null?0:e.length,c=yn(e,i);return lc(e,ae(i,function(h){return $t(h,n)?+h:h}).sort(bc)),c});function kg(e,i){var n=[];if(!(e&&e.length))return n;var c=-1,h=[],f=e.length;for(i=U(i,3);++c<f;){var d=e[c];i(d,c,e)&&(n.push(d),h.push(c))}return lc(e,h),n}function Kn(e){return e==null?e:Af.call(e)}function zg(e,i,n){var c=e==null?0:e.length;return c?(n&&typeof n!="number"&&Ce(e,i,n)?(i=0,n=c):(i=i==null?0:H(i),n=n===r?c:H(n)),tt(e,i,n)):[]}function Hg(e,i){return ts(e,i)}function Vg(e,i,n){return Rn(e,i,U(n,2))}function Kg(e,i){var n=e==null?0:e.length;if(n){var c=ts(e,i);if(c<n&&lt(e[c],i))return c}return-1}function Fg(e,i){return ts(e,i,!0)}function Wg(e,i,n){return Rn(e,i,U(n,2),!0)}function Bg(e,i){var n=e==null?0:e.length;if(n){var c=ts(e,i,!0)-1;if(lt(e[c],i))return c}return-1}function Gg(e){return e&&e.length?fc(e):[]}function Qg(e,i){return e&&e.length?fc(e,U(i,2)):[]}function Jg(e){var i=e==null?0:e.length;return i?tt(e,1,i):[]}function Yg(e,i,n){return e&&e.length?(i=n||i===r?1:H(i),tt(e,0,i<0?0:i)):[]}function Zg(e,i,n){var c=e==null?0:e.length;return c?(i=n||i===r?1:H(i),i=c-i,tt(e,i<0?0:i,c)):[]}function Xg(e,i){return e&&e.length?rs(e,U(i,3),!1,!0):[]}function ey(e,i){return e&&e.length?rs(e,U(i,3)):[]}var ty=F(function(e){return Ht(Ie(e,1,de,!0))}),ry=F(function(e){var i=rt(e);return de(i)&&(i=r),Ht(Ie(e,1,de,!0),U(i,2))}),iy=F(function(e){var i=rt(e);return i=typeof i=="function"?i:r,Ht(Ie(e,1,de,!0),r,i)});function sy(e){return e&&e.length?Ht(e):[]}function ny(e,i){return e&&e.length?Ht(e,U(i,2)):[]}function oy(e,i){return i=typeof i=="function"?i:r,e&&e.length?Ht(e,r,i):[]}function Fn(e){if(!(e&&e.length))return[];var i=0;return e=Ut(e,function(n){if(de(n))return i=we(n.length,i),!0}),cn(i,function(n){return ae(e,nn(n))})}function Xc(e,i){if(!(e&&e.length))return[];var n=Fn(e);return i==null?n:ae(n,function(c){return He(i,r,c)})}var ay=F(function(e,i){return de(e)?ri(e,i):[]}),cy=F(function(e){return Nn(Ut(e,de))}),uy=F(function(e){var i=rt(e);return de(i)&&(i=r),Nn(Ut(e,de),U(i,2))}),hy=F(function(e){var i=rt(e);return i=typeof i=="function"?i:r,Nn(Ut(e,de),r,i)}),ly=F(Fn);function py(e,i){return vc(e||[],i||[],ti)}function fy(e,i){return vc(e||[],i||[],ni)}var dy=F(function(e){var i=e.length,n=i>1?e[i-1]:r;return n=typeof n=="function"?(e.pop(),n):r,Xc(e,n)});function eu(e){var i=p(e);return i.__chain__=!0,i}function gy(e,i){return i(e),e}function ls(e,i){return i(e)}var yy=Rt(function(e){var i=e.length,n=i?e[0]:0,c=this.__wrapped__,h=function(f){return yn(f,e)};return i>1||this.__actions__.length||!(c instanceof B)||!$t(n)?this.thru(h):(c=c.slice(n,+n+(i?1:0)),c.__actions__.push({func:ls,args:[h],thisArg:r}),new Xe(c,this.__chain__).thru(function(f){return i&&!f.length&&f.push(r),f}))});function vy(){return eu(this)}function my(){return new Xe(this.value(),this.__chain__)}function wy(){this.__values__===r&&(this.__values__=du(this.value()));var e=this.__index__>=this.__values__.length,i=e?r:this.__values__[this.__index__++];return{done:e,value:i}}function _y(){return this}function by(e){for(var i,n=this;n instanceof Ji;){var c=Bc(n);c.__index__=0,c.__values__=r,i?h.__wrapped__=c:i=c;var h=c;n=n.__wrapped__}return h.__wrapped__=e,i}function Ey(){var e=this.__wrapped__;if(e instanceof B){var i=e;return this.__actions__.length&&(i=new B(this)),i=i.reverse(),i.__actions__.push({func:ls,args:[Kn],thisArg:r}),new Xe(i,this.__chain__)}return this.thru(Kn)}function Iy(){return yc(this.__wrapped__,this.__actions__)}var Py=is(function(e,i,n){te.call(e,n)?++e[n]:St(e,n,1)});function Sy(e,i,n){var c=z(e)?Na:gd;return n&&Ce(e,i,n)&&(i=r),c(e,U(i,3))}function Oy(e,i){var n=z(e)?Ut:Xa;return n(e,U(i,3))}var Ry=Rc(Gc),$y=Rc(Qc);function Ny(e,i){return Ie(ps(e,i),1)}function Cy(e,i){return Ie(ps(e,i),Si)}function Ty(e,i,n){return n=n===r?1:H(n),Ie(ps(e,i),n)}function tu(e,i){var n=z(e)?Ye:zt;return n(e,U(i,3))}function ru(e,i){var n=z(e)?Qp:Za;return n(e,U(i,3))}var xy=is(function(e,i,n){te.call(e,n)?e[n].push(i):St(e,n,[i])});function Ay(e,i,n,c){e=je(e)?e:Cr(e),n=n&&!c?H(n):0;var h=e.length;return n<0&&(n=we(h+n,0)),vs(e)?n<=h&&e.indexOf(i,n)>-1:!!h&&mr(e,i,n)>-1}var Dy=F(function(e,i,n){var c=-1,h=typeof i=="function",f=je(e)?_(e.length):[];return zt(e,function(d){f[++c]=h?He(i,d,n):ii(d,i,n)}),f}),qy=is(function(e,i,n){St(e,n,i)});function ps(e,i){var n=z(e)?ae:nc;return n(e,U(i,3))}function jy(e,i,n,c){return e==null?[]:(z(i)||(i=i==null?[]:[i]),n=c?r:n,z(n)||(n=n==null?[]:[n]),uc(e,i,n))}var Uy=is(function(e,i,n){e[n?0:1].push(i)},function(){return[[],[]]});function My(e,i,n){var c=z(e)?rn:Aa,h=arguments.length<3;return c(e,U(i,4),n,h,zt)}function Ly(e,i,n){var c=z(e)?Jp:Aa,h=arguments.length<3;return c(e,U(i,4),n,h,Za)}function ky(e,i){var n=z(e)?Ut:Xa;return n(e,gs(U(i,3)))}function zy(e){var i=z(e)?Ga:Ad;return i(e)}function Hy(e,i,n){(n?Ce(e,i,n):i===r)?i=1:i=H(i);var c=z(e)?hd:Dd;return c(e,i)}function Vy(e){var i=z(e)?ld:jd;return i(e)}function Ky(e){if(e==null)return 0;if(je(e))return vs(e)?_r(e):e.length;var i=Oe(e);return i==at||i==ct?e.size:En(e).length}function Fy(e,i,n){var c=z(e)?sn:Ud;return n&&Ce(e,i,n)&&(i=r),c(e,U(i,3))}var Wy=F(function(e,i){if(e==null)return[];var n=i.length;return n>1&&Ce(e,i[0],i[1])?i=[]:n>2&&Ce(i[0],i[1],i[2])&&(i=[i[0]]),uc(e,Ie(i,1),[])}),fs=Of||function(){return Ee.Date.now()};function By(e,i){if(typeof i!="function")throw new Ze(l);return e=H(e),function(){if(--e<1)return i.apply(this,arguments)}}function iu(e,i,n){return i=n?r:i,i=e&&i==null?e.length:i,Ot(e,fe,r,r,r,r,i)}function su(e,i){var n;if(typeof i!="function")throw new Ze(l);return e=H(e),function(){return--e>0&&(n=i.apply(this,arguments)),e<=1&&(i=r),n}}var Wn=F(function(e,i,n){var c=A;if(n.length){var h=Lt(n,$r(Wn));c|=ue}return Ot(e,c,i,n,h)}),nu=F(function(e,i,n){var c=A|G;if(n.length){var h=Lt(n,$r(nu));c|=ue}return Ot(i,c,e,n,h)});function ou(e,i,n){i=n?r:i;var c=Ot(e,J,r,r,r,r,r,i);return c.placeholder=ou.placeholder,c}function au(e,i,n){i=n?r:i;var c=Ot(e,Z,r,r,r,r,r,i);return c.placeholder=au.placeholder,c}function cu(e,i,n){var c,h,f,d,y,m,I=0,P=!1,O=!1,C=!0;if(typeof e!="function")throw new Ze(l);i=it(i)||0,he(n)&&(P=!!n.leading,O="maxWait"in n,f=O?we(it(n.maxWait)||0,i):f,C="trailing"in n?!!n.trailing:C);function D(ge){var pt=c,Tt=h;return c=h=r,I=ge,d=e.apply(Tt,pt),d}function M(ge){return I=ge,y=ci(W,i),P?D(ge):d}function V(ge){var pt=ge-m,Tt=ge-I,Ru=i-pt;return O?Se(Ru,f-Tt):Ru}function L(ge){var pt=ge-m,Tt=ge-I;return m===r||pt>=i||pt<0||O&&Tt>=f}function W(){var ge=fs();if(L(ge))return Q(ge);y=ci(W,V(ge))}function Q(ge){return y=r,C&&c?D(ge):(c=h=r,d)}function We(){y!==r&&mc(y),I=0,c=m=h=y=r}function Te(){return y===r?d:Q(fs())}function Be(){var ge=fs(),pt=L(ge);if(c=arguments,h=this,m=ge,pt){if(y===r)return M(m);if(O)return mc(y),y=ci(W,i),D(m)}return y===r&&(y=ci(W,i)),d}return Be.cancel=We,Be.flush=Te,Be}var Gy=F(function(e,i){return Ya(e,1,i)}),Qy=F(function(e,i,n){return Ya(e,it(i)||0,n)});function Jy(e){return Ot(e,jt)}function ds(e,i){if(typeof e!="function"||i!=null&&typeof i!="function")throw new Ze(l);var n=function(){var c=arguments,h=i?i.apply(this,c):c[0],f=n.cache;if(f.has(h))return f.get(h);var d=e.apply(this,c);return n.cache=f.set(h,d)||f,d};return n.cache=new(ds.Cache||Pt),n}ds.Cache=Pt;function gs(e){if(typeof e!="function")throw new Ze(l);return function(){var i=arguments;switch(i.length){case 0:return!e.call(this);case 1:return!e.call(this,i[0]);case 2:return!e.call(this,i[0],i[1]);case 3:return!e.call(this,i[0],i[1],i[2])}return!e.apply(this,i)}}function Yy(e){return su(2,e)}var Zy=Md(function(e,i){i=i.length==1&&z(i[0])?ae(i[0],Ve(U())):ae(Ie(i,1),Ve(U()));var n=i.length;return F(function(c){for(var h=-1,f=Se(c.length,n);++h<f;)c[h]=i[h].call(this,c[h]);return He(e,this,c)})}),Bn=F(function(e,i){var n=Lt(i,$r(Bn));return Ot(e,ue,r,i,n)}),uu=F(function(e,i){var n=Lt(i,$r(uu));return Ot(e,De,r,i,n)}),Xy=Rt(function(e,i){return Ot(e,$e,r,r,r,i)});function ev(e,i){if(typeof e!="function")throw new Ze(l);return i=i===r?i:H(i),F(e,i)}function tv(e,i){if(typeof e!="function")throw new Ze(l);return i=i==null?0:we(H(i),0),F(function(n){var c=n[i],h=Kt(n,0,i);return c&&Mt(h,c),He(e,this,h)})}function rv(e,i,n){var c=!0,h=!0;if(typeof e!="function")throw new Ze(l);return he(n)&&(c="leading"in n?!!n.leading:c,h="trailing"in n?!!n.trailing:h),cu(e,i,{leading:c,maxWait:i,trailing:h})}function iv(e){return iu(e,1)}function sv(e,i){return Bn(Tn(i),e)}function nv(){if(!arguments.length)return[];var e=arguments[0];return z(e)?e:[e]}function ov(e){return et(e,j)}function av(e,i){return i=typeof i=="function"?i:r,et(e,j,i)}function cv(e){return et(e,S|j)}function uv(e,i){return i=typeof i=="function"?i:r,et(e,S|j,i)}function hv(e,i){return i==null||Ja(e,i,_e(i))}function lt(e,i){return e===i||e!==e&&i!==i}var lv=as(wn),pv=as(function(e,i){return e>=i}),nr=rc(function(){return arguments}())?rc:function(e){return le(e)&&te.call(e,"callee")&&!Ha.call(e,"callee")},z=_.isArray,fv=Ia?Ve(Ia):bd;function je(e){return e!=null&&ys(e.length)&&!Nt(e)}function de(e){return le(e)&&je(e)}function dv(e){return e===!0||e===!1||le(e)&&Ne(e)==Hr}var Ft=$f||so,gv=Pa?Ve(Pa):Ed;function yv(e){return le(e)&&e.nodeType===1&&!ui(e)}function vv(e){if(e==null)return!0;if(je(e)&&(z(e)||typeof e=="string"||typeof e.splice=="function"||Ft(e)||Nr(e)||nr(e)))return!e.length;var i=Oe(e);if(i==at||i==ct)return!e.size;if(ai(e))return!En(e).length;for(var n in e)if(te.call(e,n))return!1;return!0}function mv(e,i){return si(e,i)}function wv(e,i,n){n=typeof n=="function"?n:r;var c=n?n(e,i):r;return c===r?si(e,i,r,n):!!c}function Gn(e){if(!le(e))return!1;var i=Ne(e);return i==$i||i==zl||typeof e.message=="string"&&typeof e.name=="string"&&!ui(e)}function _v(e){return typeof e=="number"&&Ka(e)}function Nt(e){if(!he(e))return!1;var i=Ne(e);return i==Ni||i==Yo||i==kl||i==Vl}function hu(e){return typeof e=="number"&&e==H(e)}function ys(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=dr}function he(e){var i=typeof e;return e!=null&&(i=="object"||i=="function")}function le(e){return e!=null&&typeof e=="object"}var lu=Sa?Ve(Sa):Pd;function bv(e,i){return e===i||bn(e,i,Mn(i))}function Ev(e,i,n){return n=typeof n=="function"?n:r,bn(e,i,Mn(i),n)}function Iv(e){return pu(e)&&e!=+e}function Pv(e){if(ag(e))throw new k(u);return ic(e)}function Sv(e){return e===null}function Ov(e){return e==null}function pu(e){return typeof e=="number"||le(e)&&Ne(e)==Kr}function ui(e){if(!le(e)||Ne(e)!=Et)return!1;var i=Vi(e);if(i===null)return!0;var n=te.call(i,"constructor")&&i.constructor;return typeof n=="function"&&n instanceof n&&Li.call(n)==Ef}var Qn=Oa?Ve(Oa):Sd;function Rv(e){return hu(e)&&e>=-9007199254740991&&e<=dr}var fu=Ra?Ve(Ra):Od;function vs(e){return typeof e=="string"||!z(e)&&le(e)&&Ne(e)==Wr}function Fe(e){return typeof e=="symbol"||le(e)&&Ne(e)==Ci}var Nr=$a?Ve($a):Rd;function $v(e){return e===r}function Nv(e){return le(e)&&Oe(e)==Br}function Cv(e){return le(e)&&Ne(e)==Fl}var Tv=as(In),xv=as(function(e,i){return e<=i});function du(e){if(!e)return[];if(je(e))return vs(e)?ut(e):qe(e);if(Jr&&e[Jr])return hf(e[Jr]());var i=Oe(e),n=i==at?hn:i==ct?ji:Cr;return n(e)}function Ct(e){if(!e)return e===0?e:0;if(e=it(e),e===Si||e===-1/0){var i=e<0?-1:1;return i*jl}return e===e?e:0}function H(e){var i=Ct(e),n=i%1;return i===i?n?i-n:i:0}function gu(e){return e?tr(H(e),0,yt):0}function it(e){if(typeof e=="number")return e;if(Fe(e))return Oi;if(he(e)){var i=typeof e.valueOf=="function"?e.valueOf():e;e=he(i)?i+"":i}if(typeof e!="string")return e===0?e:+e;e=Da(e);var n=pp.test(e);return n||dp.test(e)?Wp(e.slice(2),n?2:8):lp.test(e)?Oi:+e}function yu(e){return mt(e,Ue(e))}function Av(e){return e?tr(H(e),-9007199254740991,dr):e===0?e:0}function X(e){return e==null?"":Ke(e)}var Dv=Or(function(e,i){if(ai(i)||je(i)){mt(i,_e(i),e);return}for(var n in i)te.call(i,n)&&ti(e,n,i[n])}),vu=Or(function(e,i){mt(i,Ue(i),e)}),ms=Or(function(e,i,n,c){mt(i,Ue(i),e,c)}),qv=Or(function(e,i,n,c){mt(i,_e(i),e,c)}),jv=Rt(yn);function Uv(e,i){var n=Sr(e);return i==null?n:Qa(n,i)}var Mv=F(function(e,i){e=re(e);var n=-1,c=i.length,h=c>2?i[2]:r;for(h&&Ce(i[0],i[1],h)&&(c=1);++n<c;)for(var f=i[n],d=Ue(f),y=-1,m=d.length;++y<m;){var I=d[y],P=e[I];(P===r||lt(P,Er[I])&&!te.call(e,I))&&(e[I]=f[I])}return e}),Lv=F(function(e){return e.push(r,Dc),He(mu,r,e)});function kv(e,i){return Ca(e,U(i,3),vt)}function zv(e,i){return Ca(e,U(i,3),mn)}function Hv(e,i){return e==null?e:vn(e,U(i,3),Ue)}function Vv(e,i){return e==null?e:ec(e,U(i,3),Ue)}function Kv(e,i){return e&&vt(e,U(i,3))}function Fv(e,i){return e&&mn(e,U(i,3))}function Wv(e){return e==null?[]:Xi(e,_e(e))}function Bv(e){return e==null?[]:Xi(e,Ue(e))}function Jn(e,i,n){var c=e==null?r:rr(e,i);return c===r?n:c}function Gv(e,i){return e!=null&&Uc(e,i,vd)}function Yn(e,i){return e!=null&&Uc(e,i,md)}var Qv=Nc(function(e,i,n){i!=null&&typeof i.toString!="function"&&(i=ki.call(i)),e[i]=n},Xn(Me)),Jv=Nc(function(e,i,n){i!=null&&typeof i.toString!="function"&&(i=ki.call(i)),te.call(e,i)?e[i].push(n):e[i]=[n]},U),Yv=F(ii);function _e(e){return je(e)?Ba(e):En(e)}function Ue(e){return je(e)?Ba(e,!0):$d(e)}function Zv(e,i){var n={};return i=U(i,3),vt(e,function(c,h,f){St(n,i(c,h,f),c)}),n}function Xv(e,i){var n={};return i=U(i,3),vt(e,function(c,h,f){St(n,h,i(c,h,f))}),n}var em=Or(function(e,i,n){es(e,i,n)}),mu=Or(function(e,i,n,c){es(e,i,n,c)}),tm=Rt(function(e,i){var n={};if(e==null)return n;var c=!1;i=ae(i,function(f){return f=Vt(f,e),c||(c=f.length>1),f}),mt(e,jn(e),n),c&&(n=et(n,S|R|j,Qd));for(var h=i.length;h--;)$n(n,i[h]);return n});function rm(e,i){return wu(e,gs(U(i)))}var im=Rt(function(e,i){return e==null?{}:Cd(e,i)});function wu(e,i){if(e==null)return{};var n=ae(jn(e),function(c){return[c]});return i=U(i),hc(e,n,function(c,h){return i(c,h[0])})}function sm(e,i,n){i=Vt(i,e);var c=-1,h=i.length;for(h||(h=1,e=r);++c<h;){var f=e==null?r:e[wt(i[c])];f===r&&(c=h,f=n),e=Nt(f)?f.call(e):f}return e}function nm(e,i,n){return e==null?e:ni(e,i,n)}function om(e,i,n,c){return c=typeof c=="function"?c:r,e==null?e:ni(e,i,n,c)}var _u=xc(_e),bu=xc(Ue);function am(e,i,n){var c=z(e),h=c||Ft(e)||Nr(e);if(i=U(i,4),n==null){var f=e&&e.constructor;h?n=c?new f:[]:he(e)?n=Nt(f)?Sr(Vi(e)):{}:n={}}return(h?Ye:vt)(e,function(d,y,m){return i(n,d,y,m)}),n}function cm(e,i){return e==null?!0:$n(e,i)}function um(e,i,n){return e==null?e:gc(e,i,Tn(n))}function hm(e,i,n,c){return c=typeof c=="function"?c:r,e==null?e:gc(e,i,Tn(n),c)}function Cr(e){return e==null?[]:un(e,_e(e))}function lm(e){return e==null?[]:un(e,Ue(e))}function pm(e,i,n){return n===r&&(n=i,i=r),n!==r&&(n=it(n),n=n===n?n:0),i!==r&&(i=it(i),i=i===i?i:0),tr(it(e),i,n)}function fm(e,i,n){return i=Ct(i),n===r?(n=i,i=0):n=Ct(n),e=it(e),wd(e,i,n)}function dm(e,i,n){if(n&&typeof n!="boolean"&&Ce(e,i,n)&&(i=n=r),n===r&&(typeof i=="boolean"?(n=i,i=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&i===r?(e=0,i=1):(e=Ct(e),i===r?(i=e,e=0):i=Ct(i)),e>i){var c=e;e=i,i=c}if(n||e%1||i%1){var h=Fa();return Se(e+h*(i-e+Fp("1e-"+((h+"").length-1))),i)}return Sn(e,i)}var gm=Rr(function(e,i,n){return i=i.toLowerCase(),e+(n?Eu(i):i)});function Eu(e){return Zn(X(e).toLowerCase())}function Iu(e){return e=X(e),e&&e.replace(yp,nf).replace(qp,"")}function ym(e,i,n){e=X(e),i=Ke(i);var c=e.length;n=n===r?c:tr(H(n),0,c);var h=n;return n-=i.length,n>=0&&e.slice(n,h)==i}function vm(e){return e=X(e),e&&Jl.test(e)?e.replace(ea,of):e}function mm(e){return e=X(e),e&&rp.test(e)?e.replace(Ws,"\\$&"):e}var wm=Rr(function(e,i,n){return e+(n?"-":"")+i.toLowerCase()}),_m=Rr(function(e,i,n){return e+(n?" ":"")+i.toLowerCase()}),bm=Oc("toLowerCase");function Em(e,i,n){e=X(e),i=H(i);var c=i?_r(e):0;if(!i||c>=i)return e;var h=(i-c)/2;return os(Bi(h),n)+e+os(Wi(h),n)}function Im(e,i,n){e=X(e),i=H(i);var c=i?_r(e):0;return i&&c<i?e+os(i-c,n):e}function Pm(e,i,n){e=X(e),i=H(i);var c=i?_r(e):0;return i&&c<i?os(i-c,n)+e:e}function Sm(e,i,n){return n||i==null?i=0:i&&(i=+i),xf(X(e).replace(Bs,""),i||0)}function Om(e,i,n){return(n?Ce(e,i,n):i===r)?i=1:i=H(i),On(X(e),i)}function Rm(){var e=arguments,i=X(e[0]);return e.length<3?i:i.replace(e[1],e[2])}var $m=Rr(function(e,i,n){return e+(n?"_":"")+i.toLowerCase()});function Nm(e,i,n){return n&&typeof n!="number"&&Ce(e,i,n)&&(i=n=r),n=n===r?yt:n>>>0,n?(e=X(e),e&&(typeof i=="string"||i!=null&&!Qn(i))&&(i=Ke(i),!i&&wr(e))?Kt(ut(e),0,n):e.split(i,n)):[]}var Cm=Rr(function(e,i,n){return e+(n?" ":"")+Zn(i)});function Tm(e,i,n){return e=X(e),n=n==null?0:tr(H(n),0,e.length),i=Ke(i),e.slice(n,n+i.length)==i}function xm(e,i,n){var c=p.templateSettings;n&&Ce(e,i,n)&&(i=r),e=X(e),i=ms({},i,c,Ac);var h=ms({},i.imports,c.imports,Ac),f=_e(h),d=un(h,f),y,m,I=0,P=i.interpolate||Ti,O="__p += '",C=ln((i.escape||Ti).source+"|"+P.source+"|"+(P===ta?hp:Ti).source+"|"+(i.evaluate||Ti).source+"|$","g"),D="//# sourceURL="+(te.call(i,"sourceURL")?(i.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++kp+"]")+`
31
31
  `;e.replace(C,function(L,W,Q,We,Te,Be){return Q||(Q=We),O+=e.slice(I,Be).replace(vp,af),W&&(y=!0,O+=`' +
32
32
  __e(`+W+`) +
33
33
  '`),Te&&(m=!0,O+=`';
@@ -44,4 +44,4 @@ __p += '`),Q&&(O+=`' +
44
44
  function print() { __p += __j.call(arguments, '') }
45
45
  `:`;
46
46
  `)+O+`return __p
47
- }`;var V=Su(function(){return Y(f,D+"return "+O).apply(r,d)});if(V.source=O,Gn(V))throw V;return V}function Am(e){return X(e).toLowerCase()}function Dm(e){return X(e).toUpperCase()}function qm(e,i,n){if(e=X(e),e&&(n||i===r))return Da(e);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ct(i),f=qa(c,h),d=ja(c,h)+1;return Kt(c,f,d).join("")}function jm(e,i,n){if(e=X(e),e&&(n||i===r))return e.slice(0,Ma(e)+1);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ja(c,ct(i))+1;return Kt(c,0,h).join("")}function Um(e,i,n){if(e=X(e),e&&(n||i===r))return e.replace(Bs,"");if(!e||!(i=Ke(i)))return e;var c=ct(e),h=qa(c,ct(i));return Kt(c,h).join("")}function Mm(e,i){var n=Cl,c=Tl;if(he(i)){var h="separator"in i?i.separator:h;n="length"in i?H(i.length):n,c="omission"in i?Ke(i.omission):c}e=X(e);var f=e.length;if(wr(e)){var d=ct(e);f=d.length}if(n>=f)return e;var y=n-_r(c);if(y<1)return c;var m=d?Kt(d,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(d&&(y+=m.length-y),Qn(h)){if(e.slice(y).search(h)){var I,P=m;for(h.global||(h=ln(h.source,X(ra.exec(h))+"g")),h.lastIndex=0;I=h.exec(P);)var O=I.index;m=m.slice(0,O===r?y:O)}}else if(e.indexOf(Ke(h),y)!=y){var C=m.lastIndexOf(h);C>-1&&(m=m.slice(0,C))}return m+c}function Lm(e){return e=X(e),e&&Ql.test(e)?e.replace(Xo,df):e}var km=Rr(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Zn=Oc("toUpperCase");function Pu(e,i,n){return e=X(e),i=n?r:i,i===r?uf(e)?vf(e):Xp(e):e.match(i)||[]}var Su=F(function(e,i){try{return He(e,r,i)}catch(n){return Gn(n)?n:new k(n)}}),zm=Rt(function(e,i){return Ye(i,function(n){n=wt(n),St(e,n,Wn(e[n],e))}),e});function Hm(e){var i=e==null?0:e.length,n=U();return e=i?ae(e,function(c){if(typeof c[1]!="function")throw new Ze(l);return[n(c[0]),c[1]]}):[],F(function(c){for(var h=-1;++h<i;){var f=e[h];if(He(f[0],this,c))return He(f[1],this,c)}})}function Vm(e){return dd(et(e,S))}function Xn(e){return function(){return e}}function Km(e,i){return e==null||e!==e?i:e}var Fm=$c(),Wm=$c(!0);function Me(e){return e}function eo(e){return sc(typeof e=="function"?e:et(e,S))}function Bm(e){return oc(et(e,S))}function Gm(e,i){return ac(e,et(i,S))}var Qm=F(function(e,i){return function(n){return ii(n,e,i)}}),Jm=F(function(e,i){return function(n){return ii(e,n,i)}});function to(e,i,n){var c=_e(i),h=Xi(i,c);n==null&&!(he(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Xi(i,_e(i)));var f=!(he(n)&&"chain"in n)||!!n.chain,d=Nt(e);return Ye(h,function(y){var m=i[y];e[y]=m,d&&(e.prototype[y]=function(){var I=this.__chain__;if(f||I){var P=e(this.__wrapped__),O=P.__actions__=qe(this.__actions__);return O.push({func:m,args:arguments,thisArg:e}),P.__chain__=I,P}return m.apply(e,Mt([this.value()],arguments))})}),e}function Ym(){return Ee._===this&&(Ee._=If),this}function ro(){}function Zm(e){return e=H(e),F(function(i){return cc(i,e)})}var Xm=An(ae),ew=An(Na),tw=An(sn);function Ou(e){return kn(e)?nn(wt(e)):Td(e)}function rw(e){return function(i){return e==null?r:rr(e,i)}}var iw=Cc(),sw=Cc(!0);function io(){return[]}function so(){return!1}function nw(){return{}}function ow(){return""}function aw(){return!0}function cw(e,i){if(e=H(e),e<1||e>dr)return[];var n=yt,c=Se(e,yt);i=U(i),e-=yt;for(var h=cn(c,i);++n<e;)i(n);return h}function uw(e){return z(e)?ae(e,wt):Fe(e)?[e]:qe(Wc(X(e)))}function hw(e){var i=++bf;return X(e)+i}var lw=ns(function(e,i){return e+i},0),pw=Dn("ceil"),fw=ns(function(e,i){return e/i},1),dw=Dn("floor");function gw(e){return e&&e.length?Zi(e,Me,wn):r}function yw(e,i){return e&&e.length?Zi(e,U(i,2),wn):r}function vw(e){return xa(e,Me)}function mw(e,i){return xa(e,U(i,2))}function ww(e){return e&&e.length?Zi(e,Me,In):r}function _w(e,i){return e&&e.length?Zi(e,U(i,2),In):r}var bw=ns(function(e,i){return e*i},1),Ew=Dn("round"),Iw=ns(function(e,i){return e-i},0);function Pw(e){return e&&e.length?an(e,Me):0}function Sw(e,i){return e&&e.length?an(e,U(i,2)):0}return p.after=By,p.ary=iu,p.assign=Dv,p.assignIn=vu,p.assignInWith=ms,p.assignWith=qv,p.at=jv,p.before=su,p.bind=Wn,p.bindAll=zm,p.bindKey=nu,p.castArray=nv,p.chain=eu,p.chunk=dg,p.compact=gg,p.concat=yg,p.cond=Hm,p.conforms=Vm,p.constant=Xn,p.countBy=Py,p.create=Uv,p.curry=ou,p.curryRight=au,p.debounce=cu,p.defaults=Mv,p.defaultsDeep=Lv,p.defer=Gy,p.delay=Qy,p.difference=vg,p.differenceBy=mg,p.differenceWith=wg,p.drop=_g,p.dropRight=bg,p.dropRightWhile=Eg,p.dropWhile=Ig,p.fill=Pg,p.filter=Oy,p.flatMap=Ny,p.flatMapDeep=Cy,p.flatMapDepth=Ty,p.flatten=Jc,p.flattenDeep=Sg,p.flattenDepth=Og,p.flip=Jy,p.flow=Fm,p.flowRight=Wm,p.fromPairs=Rg,p.functions=Wv,p.functionsIn=Bv,p.groupBy=xy,p.initial=Ng,p.intersection=Cg,p.intersectionBy=Tg,p.intersectionWith=xg,p.invert=Qv,p.invertBy=Jv,p.invokeMap=Dy,p.iteratee=eo,p.keyBy=qy,p.keys=_e,p.keysIn=Ue,p.map=ps,p.mapKeys=Zv,p.mapValues=Xv,p.matches=Bm,p.matchesProperty=Gm,p.memoize=ds,p.merge=em,p.mergeWith=mu,p.method=Qm,p.methodOf=Jm,p.mixin=to,p.negate=gs,p.nthArg=Zm,p.omit=tm,p.omitBy=rm,p.once=Yy,p.orderBy=jy,p.over=Xm,p.overArgs=Zy,p.overEvery=ew,p.overSome=tw,p.partial=Bn,p.partialRight=uu,p.partition=Uy,p.pick=im,p.pickBy=wu,p.property=Ou,p.propertyOf=rw,p.pull=jg,p.pullAll=Zc,p.pullAllBy=Ug,p.pullAllWith=Mg,p.pullAt=Lg,p.range=iw,p.rangeRight=sw,p.rearg=Xy,p.reject=ky,p.remove=kg,p.rest=ev,p.reverse=Kn,p.sampleSize=Hy,p.set=nm,p.setWith=om,p.shuffle=Vy,p.slice=zg,p.sortBy=Wy,p.sortedUniq=Gg,p.sortedUniqBy=Qg,p.split=Nm,p.spread=tv,p.tail=Jg,p.take=Yg,p.takeRight=Zg,p.takeRightWhile=Xg,p.takeWhile=ey,p.tap=gy,p.throttle=rv,p.thru=ls,p.toArray=du,p.toPairs=_u,p.toPairsIn=bu,p.toPath=uw,p.toPlainObject=yu,p.transform=am,p.unary=iv,p.union=ty,p.unionBy=ry,p.unionWith=iy,p.uniq=sy,p.uniqBy=ny,p.uniqWith=oy,p.unset=cm,p.unzip=Fn,p.unzipWith=Xc,p.update=um,p.updateWith=hm,p.values=Cr,p.valuesIn=lm,p.without=ay,p.words=Pu,p.wrap=sv,p.xor=cy,p.xorBy=uy,p.xorWith=hy,p.zip=ly,p.zipObject=py,p.zipObjectDeep=fy,p.zipWith=dy,p.entries=_u,p.entriesIn=bu,p.extend=vu,p.extendWith=ms,to(p,p),p.add=lw,p.attempt=Su,p.camelCase=gm,p.capitalize=Eu,p.ceil=pw,p.clamp=pm,p.clone=ov,p.cloneDeep=cv,p.cloneDeepWith=uv,p.cloneWith=av,p.conformsTo=hv,p.deburr=Iu,p.defaultTo=Km,p.divide=fw,p.endsWith=ym,p.eq=ht,p.escape=vm,p.escapeRegExp=mm,p.every=Sy,p.find=Ry,p.findIndex=Gc,p.findKey=kv,p.findLast=$y,p.findLastIndex=Qc,p.findLastKey=zv,p.floor=dw,p.forEach=tu,p.forEachRight=ru,p.forIn=Hv,p.forInRight=Vv,p.forOwn=Kv,p.forOwnRight=Fv,p.get=Jn,p.gt=lv,p.gte=pv,p.has=Gv,p.hasIn=Yn,p.head=Yc,p.identity=Me,p.includes=Ay,p.indexOf=$g,p.inRange=fm,p.invoke=Yv,p.isArguments=nr,p.isArray=z,p.isArrayBuffer=fv,p.isArrayLike=je,p.isArrayLikeObject=de,p.isBoolean=dv,p.isBuffer=Ft,p.isDate=gv,p.isElement=yv,p.isEmpty=vv,p.isEqual=mv,p.isEqualWith=wv,p.isError=Gn,p.isFinite=_v,p.isFunction=Nt,p.isInteger=hu,p.isLength=ys,p.isMap=lu,p.isMatch=bv,p.isMatchWith=Ev,p.isNaN=Iv,p.isNative=Pv,p.isNil=Ov,p.isNull=Sv,p.isNumber=pu,p.isObject=he,p.isObjectLike=le,p.isPlainObject=ui,p.isRegExp=Qn,p.isSafeInteger=Rv,p.isSet=fu,p.isString=vs,p.isSymbol=Fe,p.isTypedArray=Nr,p.isUndefined=$v,p.isWeakMap=Nv,p.isWeakSet=Cv,p.join=Ag,p.kebabCase=wm,p.last=rt,p.lastIndexOf=Dg,p.lowerCase=_m,p.lowerFirst=bm,p.lt=Tv,p.lte=xv,p.max=gw,p.maxBy=yw,p.mean=vw,p.meanBy=mw,p.min=ww,p.minBy=_w,p.stubArray=io,p.stubFalse=so,p.stubObject=nw,p.stubString=ow,p.stubTrue=aw,p.multiply=bw,p.nth=qg,p.noConflict=Ym,p.noop=ro,p.now=fs,p.pad=Em,p.padEnd=Im,p.padStart=Pm,p.parseInt=Sm,p.random=dm,p.reduce=My,p.reduceRight=Ly,p.repeat=Om,p.replace=Rm,p.result=sm,p.round=Ew,p.runInContext=v,p.sample=zy,p.size=Ky,p.snakeCase=$m,p.some=Fy,p.sortedIndex=Hg,p.sortedIndexBy=Vg,p.sortedIndexOf=Kg,p.sortedLastIndex=Fg,p.sortedLastIndexBy=Wg,p.sortedLastIndexOf=Bg,p.startCase=Cm,p.startsWith=Tm,p.subtract=Iw,p.sum=Pw,p.sumBy=Sw,p.template=xm,p.times=cw,p.toFinite=Ct,p.toInteger=H,p.toLength=gu,p.toLower=Am,p.toNumber=it,p.toSafeInteger=Av,p.toString=X,p.toUpper=Dm,p.trim=qm,p.trimEnd=jm,p.trimStart=Um,p.truncate=Mm,p.unescape=Lm,p.uniqueId=hw,p.upperCase=km,p.upperFirst=Zn,p.each=tu,p.eachRight=ru,p.first=Yc,to(p,function(){var e={};return vt(p,function(i,n){te.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Ye(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Ye(["drop","take"],function(e,i){B.prototype[e]=function(n){n=n===r?1:we(H(n),0);var c=this.__filtered__&&!i?new B(this):this.clone();return c.__filtered__?c.__takeCount__=Se(n,c.__takeCount__):c.__views__.push({size:Se(n,yt),type:e+(c.__dir__<0?"Right":"")}),c},B.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ye(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==Jo||n==ql;B.prototype[e]=function(h){var f=this.clone();return f.__iteratees__.push({iteratee:U(h,3),type:n}),f.__filtered__=f.__filtered__||c,f}}),Ye(["head","last"],function(e,i){var n="take"+(i?"Right":"");B.prototype[e]=function(){return this[n](1).value()[0]}}),Ye(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");B.prototype[e]=function(){return this.__filtered__?new B(this):this[n](1)}}),B.prototype.compact=function(){return this.filter(Me)},B.prototype.find=function(e){return this.filter(e).head()},B.prototype.findLast=function(e){return this.reverse().find(e)},B.prototype.invokeMap=F(function(e,i){return typeof e=="function"?new B(this):this.map(function(n){return ii(n,e,i)})}),B.prototype.reject=function(e){return this.filter(gs(U(e)))},B.prototype.slice=function(e,i){e=H(e);var n=this;return n.__filtered__&&(e>0||i<0)?new B(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=H(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},B.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},B.prototype.toArray=function(){return this.take(yt)},vt(B.prototype,function(e,i){var n=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),h=p[c?"take"+(i=="last"?"Right":""):i],f=c||/^find/.test(i);h&&(p.prototype[i]=function(){var d=this.__wrapped__,y=c?[1]:arguments,m=d instanceof B,I=y[0],P=m||z(d),O=function(W){var Q=h.apply(p,Mt([W],y));return c&&C?Q[0]:Q};P&&n&&typeof I=="function"&&I.length!=1&&(m=P=!1);var C=this.__chain__,D=!!this.__actions__.length,M=f&&!C,V=m&&!D;if(!f&&P){d=V?d:new B(this);var L=e.apply(d,y);return L.__actions__.push({func:ls,args:[O],thisArg:r}),new Xe(L,C)}return M&&V?e.apply(this,y):(L=this.thru(O),M?c?L.value()[0]:L.value():L)})}),Ye(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ui[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);p.prototype[e]=function(){var h=arguments;if(c&&!this.__chain__){var f=this.value();return i.apply(z(f)?f:[],h)}return this[n](function(d){return i.apply(z(d)?d:[],h)})}}),vt(B.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";te.call(Pr,c)||(Pr[c]=[]),Pr[c].push({name:i,func:n})}}),Pr[ss(r,G).name]=[{name:"wrapper",func:r}],B.prototype.clone=Lf,B.prototype.reverse=kf,B.prototype.value=zf,p.prototype.at=yy,p.prototype.chain=vy,p.prototype.commit=my,p.prototype.next=wy,p.prototype.plant=by,p.prototype.reverse=Ey,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=Iy,p.prototype.first=p.prototype.head,Jr&&(p.prototype[Jr]=_y),p},br=mf();Yt?((Yt.exports=br)._=br,Xs._=br):Ee._=br}).call(yi)})(Co,Co.exports);var SI=Object.defineProperty,OI=Object.defineProperties,RI=Object.getOwnPropertyDescriptors,xh=Object.getOwnPropertySymbols,$I=Object.prototype.hasOwnProperty,NI=Object.prototype.propertyIsEnumerable,Ah=(a,t,r)=>t in a?SI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,bs=(a,t)=>{for(var r in t||(t={}))$I.call(t,r)&&Ah(a,r,t[r]);if(xh)for(var r of xh(t))NI.call(t,r)&&Ah(a,r,t[r]);return a},CI=(a,t)=>OI(a,RI(t));function Qt(a,t,r){var s;const o=Y_(a);return((s=t.rpcMap)==null?void 0:s[o.reference])||`${PI}?chainId=${o.namespace}:${o.reference}&projectId=${r}`}function fr(a){return a.includes(":")?a.split(":")[1]:a}function $l(a){return a.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function TI(a,t){const r=Object.keys(t.namespaces).filter(o=>o.includes(a));if(!r.length)return[];const s=[];return r.forEach(o=>{const u=t.namespaces[o].accounts;s.push(...u)}),s}function xI(a={},t={}){const r=Dh(a),s=Dh(t);return Co.exports.merge(r,s)}function Dh(a){var t,r,s,o;const u={};if(!qr(a))return u;for(const[l,g]of Object.entries(a)){const w=Ko(l)?[l]:g.chains,b=g.methods||[],$=g.events||[],S=g.rpcMap||{},R=vi(l);u[R]=CI(bs(bs({},u[R]),g),{chains:ao(w,(t=u[R])==null?void 0:t.chains),methods:ao(b,(r=u[R])==null?void 0:r.methods),events:ao($,(s=u[R])==null?void 0:s.events),rpcMap:bs(bs({},S),(o=u[R])==null?void 0:o.rpcMap)})}return u}function AI(a){return a.includes(":")?a.split(":")[2]:a}function DI(a){const t={};for(const[r,s]of Object.entries(a)){const o=s.methods||[],u=s.events||[],l=s.accounts||[],g=Ko(r)?[r]:s.chains?s.chains:$l(s.accounts);t[r]={chains:g,methods:o,events:u,accounts:l}}return t}function go(a){return typeof a=="number"?a:a.includes("0x")?parseInt(a,16):a.includes(":")?Number(a.split(":")[1]):Number(a)}const Nl={},ce=a=>Nl[a],yo=(a,t)=>{Nl[a]=t};class qI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class jI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(parseInt(t),r),this.chainId=parseInt(t),this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,r){const s=r||Qt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=parseInt(fr(r));t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}async handleSwitchChain(t){var r,s;let o=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const u=parseInt(o,16);if(this.isChainApproved(u))this.setDefaultChain(`${u}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:o}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${u}`);else throw new Error(`Failed to switch to chain 'eip155:${u}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class UI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class MI{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class LI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{const s=this.getCardanoRPCUrl(r),o=fr(r);t[o]=this.createHttpProvider(o,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}getCardanoRPCUrl(t){const r=this.namespace.rpcMap;if(r)return r[t]}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class kI{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class zI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class HI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||Qt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace);return typeof s>"u"?void 0:new Dt(new Jt(s,ce("disableProviderPing")))}}var VI=Object.defineProperty,KI=Object.defineProperties,FI=Object.getOwnPropertyDescriptors,qh=Object.getOwnPropertySymbols,WI=Object.prototype.hasOwnProperty,BI=Object.prototype.propertyIsEnumerable,jh=(a,t,r)=>t in a?VI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Es=(a,t)=>{for(var r in t||(t={}))WI.call(t,r)&&jh(a,r,t[r]);if(qh)for(var r of qh(t))BI.call(t,r)&&jh(a,r,t[r]);return a},vo=(a,t)=>KI(a,FI(t));class Go{constructor(t){this.events=new Do,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Ts(xs({level:(t==null?void 0:t.logger)||Ch})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Go(t);return await r.initialize(),r}async request(t,r){const[s,o]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Es({},t),chainId:`${s}:${o}`,topic:this.session.topic})}sendAsync(t,r,s){const o=new Date().getTime();this.request(t,s).then(u=>r(null,As(o,u))).catch(u=>r(u,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:ye("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}removeListener(t,r){this.events.removeListener(t,r)}off(t,r){this.events.off(t,r)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:o}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await o().then(u=>{this.session=u,this.namespaces||(this.namespaces=DI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==Ol)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,o]=this.validateChain(t);this.getProvider(s).setDefaultChain(o,r)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(cr(r)){for(const s of r)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await hI.init({logger:this.providerOpts.logger||Ch,relayUrl:this.providerOpts.relayUrl||bI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(r=>vi(r)))];yo("client",this.client),yo("events",this.events),yo("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=TI(r,this.session),o=$l(s),u=xI(this.namespaces,this.optionalNamespaces),l=vo(Es({},u[r]),{accounts:s,chains:o});switch(r){case"eip155":this.rpcProviders[r]=new jI({namespace:l});break;case"solana":this.rpcProviders[r]=new UI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new MI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new qI({namespace:l});break;case"cip34":this.rpcProviders[r]=new LI({namespace:l});break;case"elrond":this.rpcProviders[r]=new kI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new zI({namespace:l});break;case"near":this.rpcProviders[r]=new HI({namespace:l});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:r}=t,{event:s}=r;if(s.name==="accountsChanged"){const o=s.data;o&&cr(o)&&this.events.emit("accountsChanged",o.map(AI))}else if(s.name==="chainChanged"){const o=r.chainId,u=r.event.data,l=vi(o),g=go(o)!==go(u)?`${l}:${go(u)}`:o;this.onChainChanged(g)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:o}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=vo(Es({},u),{namespaces:o}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:r})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",vo(Es({},ye("USER_DISCONNECTED")),{data:t.topic}))}),this.on(qt.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var r;this.getProvider(t).updateNamespace((r=this.session)==null?void 0:r.namespaces[t])})}setNamespaces(t){const{namespaces:r,optionalNamespaces:s,sessionProperties:o}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=o,this.persist("namespaces",r),this.persist("optionalNamespaces",s)}validateChain(t){const[r,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,s];if(r&&!Object.keys(this.namespaces||{}).map(l=>vi(l)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&s)return[r,s];const o=vi(Object.keys(this.namespaces)[0]),u=this.rpcProviders[o].getDefaultChain();return[o,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[o,u]=this.validateChain(t);r||this.getProvider(o).setDefaultChain(u),((s=this.namespaces[o])!=null?s:this.namespaces[`${o}:${u}`]).defaultChain=u,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",u)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,r){this.client.core.storage.setItem(`${Th}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${Th}/${t}`)}}const GI=Go,QI="wc",JI="ethereum_provider",YI=`${QI}@2:${JI}:`,ZI="https://rpc.walletconnect.com/v1/",To=["eth_sendTransaction","personal_sign"],XI=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],xo=["chainChanged","accountsChanged"],eP=["chainChanged","accountsChanged","message","disconnect","connect"];var tP=Object.defineProperty,rP=Object.defineProperties,iP=Object.getOwnPropertyDescriptors,Uh=Object.getOwnPropertySymbols,sP=Object.prototype.hasOwnProperty,nP=Object.prototype.propertyIsEnumerable,Mh=(a,t,r)=>t in a?tP(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,wi=(a,t)=>{for(var r in t||(t={}))sP.call(t,r)&&Mh(a,r,t[r]);if(Uh)for(var r of Uh(t))nP.call(t,r)&&Mh(a,r,t[r]);return a},Lh=(a,t)=>rP(a,iP(t));function $s(a){return Number(a[0].split(":")[1])}function mo(a){return`0x${a.toString(16)}`}function oP(a){const{chains:t,optionalChains:r,methods:s,optionalMethods:o,events:u,optionalEvents:l,rpcMap:g}=a;if(!wo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||To,events:u||xo,rpcMap:wi({},t.length?{[$s(t)]:g[$s(t)]}:{})},b=u==null?void 0:u.filter(j=>!xo.includes(j)),$=s==null?void 0:s.filter(j=>!To.includes(j));if(!r&&!l&&!o&&!(b!=null&&b.length)&&!($!=null&&$.length))return{required:t.length?w:void 0};const S=(b==null?void 0:b.length)&&($==null?void 0:$.length)||!r,R={chains:[...new Set(S?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(o!=null&&o.length?o:XI))],events:[...new Set(w.events.concat(l!=null&&l.length?l:eP))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?R:void 0}}class Qo{constructor(){this.events=new gt.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=YI,this.on=(t,r)=>(this.events.on(t,r),this),this.once=(t,r)=>(this.events.once(t,r),this),this.removeListener=(t,r)=>(this.events.removeListener(t,r),this),this.off=(t,r)=>(this.events.off(t,r),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const r=new Qo;return await r.initialize(t),r}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,r){this.signer.sendAsync(t,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:r,optional:s}=oP(this.rpc);try{const o=await new Promise(async(l,g)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),g(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Lh(wi({namespaces:wi({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(b=>{l(b)}).catch(b=>{g(new Error(b.message))})});if(!o)return;const u=Yw(o.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:mo(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:r}=t,{event:s}=r;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const r=parseInt(t);this.chainId=r,this.events.emit("chainChanged",mo(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",Lh(wi({},Xw("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var r,s;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const r=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",mo(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,o]=t.split(":");return{chainId:`${r}:${s}`,address:o}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const o=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=o.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=o.length?(t==null?void 0:t.methods)||To:[],w=o.length?(t==null?void 0:t.events)||xo:[],b=(t==null?void 0:t.optionalMethods)||[],$=(t==null?void 0:t.optionalEvents)||[],S=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),R=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(j=>this.formatChainId(j)),optionalChains:u.map(j=>this.formatChainId(j)),methods:g,events:w,optionalMethods:b,optionalEvents:$,rpcMap:S,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:R,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(o=>{s[o]=this.getRpcUrl(o,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?$s(this.rpc.chains):$s(this.rpc.optionalChains),this.signer=await GI.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:s}=await $w(()=>import("./index-BfryJIfK.js").then(o=>o.i),__vite__mapDeps([0,1,2]));r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(wi({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:r,optionalChains:s,rpcMap:o}=t;r&&wo(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(o==null?void 0:o[u])||this.getRpcUrl(u)})),s&&wo(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(u=>this.formatChainId(u)),s.forEach(u=>{this.rpc.rpcMap[u]=(o==null?void 0:o[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${ZI}?chainId=eip155:${t}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(r=>this.parseAccount(r))}}const RP=Qo;export{RP as EthereumProvider,eP as OPTIONAL_EVENTS,XI as OPTIONAL_METHODS,xo as REQUIRED_EVENTS,To as REQUIRED_METHODS,Qo as default};
47
+ }`;var V=Su(function(){return Y(f,D+"return "+O).apply(r,d)});if(V.source=O,Gn(V))throw V;return V}function Am(e){return X(e).toLowerCase()}function Dm(e){return X(e).toUpperCase()}function qm(e,i,n){if(e=X(e),e&&(n||i===r))return Da(e);if(!e||!(i=Ke(i)))return e;var c=ut(e),h=ut(i),f=qa(c,h),d=ja(c,h)+1;return Kt(c,f,d).join("")}function jm(e,i,n){if(e=X(e),e&&(n||i===r))return e.slice(0,Ma(e)+1);if(!e||!(i=Ke(i)))return e;var c=ut(e),h=ja(c,ut(i))+1;return Kt(c,0,h).join("")}function Um(e,i,n){if(e=X(e),e&&(n||i===r))return e.replace(Bs,"");if(!e||!(i=Ke(i)))return e;var c=ut(e),h=qa(c,ut(i));return Kt(c,h).join("")}function Mm(e,i){var n=Cl,c=Tl;if(he(i)){var h="separator"in i?i.separator:h;n="length"in i?H(i.length):n,c="omission"in i?Ke(i.omission):c}e=X(e);var f=e.length;if(wr(e)){var d=ut(e);f=d.length}if(n>=f)return e;var y=n-_r(c);if(y<1)return c;var m=d?Kt(d,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(d&&(y+=m.length-y),Qn(h)){if(e.slice(y).search(h)){var I,P=m;for(h.global||(h=ln(h.source,X(ra.exec(h))+"g")),h.lastIndex=0;I=h.exec(P);)var O=I.index;m=m.slice(0,O===r?y:O)}}else if(e.indexOf(Ke(h),y)!=y){var C=m.lastIndexOf(h);C>-1&&(m=m.slice(0,C))}return m+c}function Lm(e){return e=X(e),e&&Ql.test(e)?e.replace(Xo,df):e}var km=Rr(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Zn=Oc("toUpperCase");function Pu(e,i,n){return e=X(e),i=n?r:i,i===r?uf(e)?vf(e):Xp(e):e.match(i)||[]}var Su=F(function(e,i){try{return He(e,r,i)}catch(n){return Gn(n)?n:new k(n)}}),zm=Rt(function(e,i){return Ye(i,function(n){n=wt(n),St(e,n,Wn(e[n],e))}),e});function Hm(e){var i=e==null?0:e.length,n=U();return e=i?ae(e,function(c){if(typeof c[1]!="function")throw new Ze(l);return[n(c[0]),c[1]]}):[],F(function(c){for(var h=-1;++h<i;){var f=e[h];if(He(f[0],this,c))return He(f[1],this,c)}})}function Vm(e){return dd(et(e,S))}function Xn(e){return function(){return e}}function Km(e,i){return e==null||e!==e?i:e}var Fm=$c(),Wm=$c(!0);function Me(e){return e}function eo(e){return sc(typeof e=="function"?e:et(e,S))}function Bm(e){return oc(et(e,S))}function Gm(e,i){return ac(e,et(i,S))}var Qm=F(function(e,i){return function(n){return ii(n,e,i)}}),Jm=F(function(e,i){return function(n){return ii(e,n,i)}});function to(e,i,n){var c=_e(i),h=Xi(i,c);n==null&&!(he(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Xi(i,_e(i)));var f=!(he(n)&&"chain"in n)||!!n.chain,d=Nt(e);return Ye(h,function(y){var m=i[y];e[y]=m,d&&(e.prototype[y]=function(){var I=this.__chain__;if(f||I){var P=e(this.__wrapped__),O=P.__actions__=qe(this.__actions__);return O.push({func:m,args:arguments,thisArg:e}),P.__chain__=I,P}return m.apply(e,Mt([this.value()],arguments))})}),e}function Ym(){return Ee._===this&&(Ee._=If),this}function ro(){}function Zm(e){return e=H(e),F(function(i){return cc(i,e)})}var Xm=An(ae),ew=An(Na),tw=An(sn);function Ou(e){return kn(e)?nn(wt(e)):Td(e)}function rw(e){return function(i){return e==null?r:rr(e,i)}}var iw=Cc(),sw=Cc(!0);function io(){return[]}function so(){return!1}function nw(){return{}}function ow(){return""}function aw(){return!0}function cw(e,i){if(e=H(e),e<1||e>dr)return[];var n=yt,c=Se(e,yt);i=U(i),e-=yt;for(var h=cn(c,i);++n<e;)i(n);return h}function uw(e){return z(e)?ae(e,wt):Fe(e)?[e]:qe(Wc(X(e)))}function hw(e){var i=++bf;return X(e)+i}var lw=ns(function(e,i){return e+i},0),pw=Dn("ceil"),fw=ns(function(e,i){return e/i},1),dw=Dn("floor");function gw(e){return e&&e.length?Zi(e,Me,wn):r}function yw(e,i){return e&&e.length?Zi(e,U(i,2),wn):r}function vw(e){return xa(e,Me)}function mw(e,i){return xa(e,U(i,2))}function ww(e){return e&&e.length?Zi(e,Me,In):r}function _w(e,i){return e&&e.length?Zi(e,U(i,2),In):r}var bw=ns(function(e,i){return e*i},1),Ew=Dn("round"),Iw=ns(function(e,i){return e-i},0);function Pw(e){return e&&e.length?an(e,Me):0}function Sw(e,i){return e&&e.length?an(e,U(i,2)):0}return p.after=By,p.ary=iu,p.assign=Dv,p.assignIn=vu,p.assignInWith=ms,p.assignWith=qv,p.at=jv,p.before=su,p.bind=Wn,p.bindAll=zm,p.bindKey=nu,p.castArray=nv,p.chain=eu,p.chunk=dg,p.compact=gg,p.concat=yg,p.cond=Hm,p.conforms=Vm,p.constant=Xn,p.countBy=Py,p.create=Uv,p.curry=ou,p.curryRight=au,p.debounce=cu,p.defaults=Mv,p.defaultsDeep=Lv,p.defer=Gy,p.delay=Qy,p.difference=vg,p.differenceBy=mg,p.differenceWith=wg,p.drop=_g,p.dropRight=bg,p.dropRightWhile=Eg,p.dropWhile=Ig,p.fill=Pg,p.filter=Oy,p.flatMap=Ny,p.flatMapDeep=Cy,p.flatMapDepth=Ty,p.flatten=Jc,p.flattenDeep=Sg,p.flattenDepth=Og,p.flip=Jy,p.flow=Fm,p.flowRight=Wm,p.fromPairs=Rg,p.functions=Wv,p.functionsIn=Bv,p.groupBy=xy,p.initial=Ng,p.intersection=Cg,p.intersectionBy=Tg,p.intersectionWith=xg,p.invert=Qv,p.invertBy=Jv,p.invokeMap=Dy,p.iteratee=eo,p.keyBy=qy,p.keys=_e,p.keysIn=Ue,p.map=ps,p.mapKeys=Zv,p.mapValues=Xv,p.matches=Bm,p.matchesProperty=Gm,p.memoize=ds,p.merge=em,p.mergeWith=mu,p.method=Qm,p.methodOf=Jm,p.mixin=to,p.negate=gs,p.nthArg=Zm,p.omit=tm,p.omitBy=rm,p.once=Yy,p.orderBy=jy,p.over=Xm,p.overArgs=Zy,p.overEvery=ew,p.overSome=tw,p.partial=Bn,p.partialRight=uu,p.partition=Uy,p.pick=im,p.pickBy=wu,p.property=Ou,p.propertyOf=rw,p.pull=jg,p.pullAll=Zc,p.pullAllBy=Ug,p.pullAllWith=Mg,p.pullAt=Lg,p.range=iw,p.rangeRight=sw,p.rearg=Xy,p.reject=ky,p.remove=kg,p.rest=ev,p.reverse=Kn,p.sampleSize=Hy,p.set=nm,p.setWith=om,p.shuffle=Vy,p.slice=zg,p.sortBy=Wy,p.sortedUniq=Gg,p.sortedUniqBy=Qg,p.split=Nm,p.spread=tv,p.tail=Jg,p.take=Yg,p.takeRight=Zg,p.takeRightWhile=Xg,p.takeWhile=ey,p.tap=gy,p.throttle=rv,p.thru=ls,p.toArray=du,p.toPairs=_u,p.toPairsIn=bu,p.toPath=uw,p.toPlainObject=yu,p.transform=am,p.unary=iv,p.union=ty,p.unionBy=ry,p.unionWith=iy,p.uniq=sy,p.uniqBy=ny,p.uniqWith=oy,p.unset=cm,p.unzip=Fn,p.unzipWith=Xc,p.update=um,p.updateWith=hm,p.values=Cr,p.valuesIn=lm,p.without=ay,p.words=Pu,p.wrap=sv,p.xor=cy,p.xorBy=uy,p.xorWith=hy,p.zip=ly,p.zipObject=py,p.zipObjectDeep=fy,p.zipWith=dy,p.entries=_u,p.entriesIn=bu,p.extend=vu,p.extendWith=ms,to(p,p),p.add=lw,p.attempt=Su,p.camelCase=gm,p.capitalize=Eu,p.ceil=pw,p.clamp=pm,p.clone=ov,p.cloneDeep=cv,p.cloneDeepWith=uv,p.cloneWith=av,p.conformsTo=hv,p.deburr=Iu,p.defaultTo=Km,p.divide=fw,p.endsWith=ym,p.eq=lt,p.escape=vm,p.escapeRegExp=mm,p.every=Sy,p.find=Ry,p.findIndex=Gc,p.findKey=kv,p.findLast=$y,p.findLastIndex=Qc,p.findLastKey=zv,p.floor=dw,p.forEach=tu,p.forEachRight=ru,p.forIn=Hv,p.forInRight=Vv,p.forOwn=Kv,p.forOwnRight=Fv,p.get=Jn,p.gt=lv,p.gte=pv,p.has=Gv,p.hasIn=Yn,p.head=Yc,p.identity=Me,p.includes=Ay,p.indexOf=$g,p.inRange=fm,p.invoke=Yv,p.isArguments=nr,p.isArray=z,p.isArrayBuffer=fv,p.isArrayLike=je,p.isArrayLikeObject=de,p.isBoolean=dv,p.isBuffer=Ft,p.isDate=gv,p.isElement=yv,p.isEmpty=vv,p.isEqual=mv,p.isEqualWith=wv,p.isError=Gn,p.isFinite=_v,p.isFunction=Nt,p.isInteger=hu,p.isLength=ys,p.isMap=lu,p.isMatch=bv,p.isMatchWith=Ev,p.isNaN=Iv,p.isNative=Pv,p.isNil=Ov,p.isNull=Sv,p.isNumber=pu,p.isObject=he,p.isObjectLike=le,p.isPlainObject=ui,p.isRegExp=Qn,p.isSafeInteger=Rv,p.isSet=fu,p.isString=vs,p.isSymbol=Fe,p.isTypedArray=Nr,p.isUndefined=$v,p.isWeakMap=Nv,p.isWeakSet=Cv,p.join=Ag,p.kebabCase=wm,p.last=rt,p.lastIndexOf=Dg,p.lowerCase=_m,p.lowerFirst=bm,p.lt=Tv,p.lte=xv,p.max=gw,p.maxBy=yw,p.mean=vw,p.meanBy=mw,p.min=ww,p.minBy=_w,p.stubArray=io,p.stubFalse=so,p.stubObject=nw,p.stubString=ow,p.stubTrue=aw,p.multiply=bw,p.nth=qg,p.noConflict=Ym,p.noop=ro,p.now=fs,p.pad=Em,p.padEnd=Im,p.padStart=Pm,p.parseInt=Sm,p.random=dm,p.reduce=My,p.reduceRight=Ly,p.repeat=Om,p.replace=Rm,p.result=sm,p.round=Ew,p.runInContext=v,p.sample=zy,p.size=Ky,p.snakeCase=$m,p.some=Fy,p.sortedIndex=Hg,p.sortedIndexBy=Vg,p.sortedIndexOf=Kg,p.sortedLastIndex=Fg,p.sortedLastIndexBy=Wg,p.sortedLastIndexOf=Bg,p.startCase=Cm,p.startsWith=Tm,p.subtract=Iw,p.sum=Pw,p.sumBy=Sw,p.template=xm,p.times=cw,p.toFinite=Ct,p.toInteger=H,p.toLength=gu,p.toLower=Am,p.toNumber=it,p.toSafeInteger=Av,p.toString=X,p.toUpper=Dm,p.trim=qm,p.trimEnd=jm,p.trimStart=Um,p.truncate=Mm,p.unescape=Lm,p.uniqueId=hw,p.upperCase=km,p.upperFirst=Zn,p.each=tu,p.eachRight=ru,p.first=Yc,to(p,function(){var e={};return vt(p,function(i,n){te.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Ye(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Ye(["drop","take"],function(e,i){B.prototype[e]=function(n){n=n===r?1:we(H(n),0);var c=this.__filtered__&&!i?new B(this):this.clone();return c.__filtered__?c.__takeCount__=Se(n,c.__takeCount__):c.__views__.push({size:Se(n,yt),type:e+(c.__dir__<0?"Right":"")}),c},B.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ye(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==Jo||n==ql;B.prototype[e]=function(h){var f=this.clone();return f.__iteratees__.push({iteratee:U(h,3),type:n}),f.__filtered__=f.__filtered__||c,f}}),Ye(["head","last"],function(e,i){var n="take"+(i?"Right":"");B.prototype[e]=function(){return this[n](1).value()[0]}}),Ye(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");B.prototype[e]=function(){return this.__filtered__?new B(this):this[n](1)}}),B.prototype.compact=function(){return this.filter(Me)},B.prototype.find=function(e){return this.filter(e).head()},B.prototype.findLast=function(e){return this.reverse().find(e)},B.prototype.invokeMap=F(function(e,i){return typeof e=="function"?new B(this):this.map(function(n){return ii(n,e,i)})}),B.prototype.reject=function(e){return this.filter(gs(U(e)))},B.prototype.slice=function(e,i){e=H(e);var n=this;return n.__filtered__&&(e>0||i<0)?new B(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=H(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},B.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},B.prototype.toArray=function(){return this.take(yt)},vt(B.prototype,function(e,i){var n=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),h=p[c?"take"+(i=="last"?"Right":""):i],f=c||/^find/.test(i);h&&(p.prototype[i]=function(){var d=this.__wrapped__,y=c?[1]:arguments,m=d instanceof B,I=y[0],P=m||z(d),O=function(W){var Q=h.apply(p,Mt([W],y));return c&&C?Q[0]:Q};P&&n&&typeof I=="function"&&I.length!=1&&(m=P=!1);var C=this.__chain__,D=!!this.__actions__.length,M=f&&!C,V=m&&!D;if(!f&&P){d=V?d:new B(this);var L=e.apply(d,y);return L.__actions__.push({func:ls,args:[O],thisArg:r}),new Xe(L,C)}return M&&V?e.apply(this,y):(L=this.thru(O),M?c?L.value()[0]:L.value():L)})}),Ye(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ui[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);p.prototype[e]=function(){var h=arguments;if(c&&!this.__chain__){var f=this.value();return i.apply(z(f)?f:[],h)}return this[n](function(d){return i.apply(z(d)?d:[],h)})}}),vt(B.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";te.call(Pr,c)||(Pr[c]=[]),Pr[c].push({name:i,func:n})}}),Pr[ss(r,G).name]=[{name:"wrapper",func:r}],B.prototype.clone=Lf,B.prototype.reverse=kf,B.prototype.value=zf,p.prototype.at=yy,p.prototype.chain=vy,p.prototype.commit=my,p.prototype.next=wy,p.prototype.plant=by,p.prototype.reverse=Ey,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=Iy,p.prototype.first=p.prototype.head,Jr&&(p.prototype[Jr]=_y),p},br=mf();Yt?((Yt.exports=br)._=br,Xs._=br):Ee._=br}).call(yi)})(Co,Co.exports);var PI=Object.defineProperty,SI=Object.defineProperties,OI=Object.getOwnPropertyDescriptors,xh=Object.getOwnPropertySymbols,RI=Object.prototype.hasOwnProperty,$I=Object.prototype.propertyIsEnumerable,Ah=(a,t,r)=>t in a?PI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,bs=(a,t)=>{for(var r in t||(t={}))RI.call(t,r)&&Ah(a,r,t[r]);if(xh)for(var r of xh(t))$I.call(t,r)&&Ah(a,r,t[r]);return a},NI=(a,t)=>SI(a,OI(t));function Qt(a,t,r){var s;const o=J_(a);return((s=t.rpcMap)==null?void 0:s[o.reference])||`${II}?chainId=${o.namespace}:${o.reference}&projectId=${r}`}function fr(a){return a.includes(":")?a.split(":")[1]:a}function $l(a){return a.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function CI(a,t){const r=Object.keys(t.namespaces).filter(o=>o.includes(a));if(!r.length)return[];const s=[];return r.forEach(o=>{const u=t.namespaces[o].accounts;s.push(...u)}),s}function TI(a={},t={}){const r=Dh(a),s=Dh(t);return Co.exports.merge(r,s)}function Dh(a){var t,r,s,o;const u={};if(!qr(a))return u;for(const[l,g]of Object.entries(a)){const w=Ko(l)?[l]:g.chains,b=g.methods||[],$=g.events||[],S=g.rpcMap||{},R=vi(l);u[R]=NI(bs(bs({},u[R]),g),{chains:ao(w,(t=u[R])==null?void 0:t.chains),methods:ao(b,(r=u[R])==null?void 0:r.methods),events:ao($,(s=u[R])==null?void 0:s.events),rpcMap:bs(bs({},S),(o=u[R])==null?void 0:o.rpcMap)})}return u}function xI(a){return a.includes(":")?a.split(":")[2]:a}function AI(a){const t={};for(const[r,s]of Object.entries(a)){const o=s.methods||[],u=s.events||[],l=s.accounts||[],g=Ko(r)?[r]:s.chains?s.chains:$l(s.accounts);t[r]={chains:g,methods:o,events:u,accounts:l}}return t}function go(a){return typeof a=="number"?a:a.includes("0x")?parseInt(a,16):a.includes(":")?Number(a.split(":")[1]):Number(a)}const Nl={},ce=a=>Nl[a],yo=(a,t)=>{Nl[a]=t};class DI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class qI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(parseInt(t),r),this.chainId=parseInt(t),this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,r){const s=r||Qt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=parseInt(fr(r));t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}async handleSwitchChain(t){var r,s;let o=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const u=parseInt(o,16);if(this.isChainApproved(u))this.setDefaultChain(`${u}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:o}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${u}`);else throw new Error(`Failed to switch to chain 'eip155:${u}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class jI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class UI{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class MI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{const s=this.getCardanoRPCUrl(r),o=fr(r);t[o]=this.createHttpProvider(o,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}getCardanoRPCUrl(t){const r=this.namespace.rpcMap;if(r)return r[t]}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class LI{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class kI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const o=fr(r);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Jt(s,ce("disableProviderPing")))}}class zI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=ce("events"),this.client=ce("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||Qt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Qt(t,this.namespace);return typeof s>"u"?void 0:new Dt(new Jt(s,ce("disableProviderPing")))}}var HI=Object.defineProperty,VI=Object.defineProperties,KI=Object.getOwnPropertyDescriptors,qh=Object.getOwnPropertySymbols,FI=Object.prototype.hasOwnProperty,WI=Object.prototype.propertyIsEnumerable,jh=(a,t,r)=>t in a?HI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,Es=(a,t)=>{for(var r in t||(t={}))FI.call(t,r)&&jh(a,r,t[r]);if(qh)for(var r of qh(t))WI.call(t,r)&&jh(a,r,t[r]);return a},vo=(a,t)=>VI(a,KI(t));class Go{constructor(t){this.events=new Do,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Ts(xs({level:(t==null?void 0:t.logger)||Ch})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Go(t);return await r.initialize(),r}async request(t,r){const[s,o]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Es({},t),chainId:`${s}:${o}`,topic:this.session.topic})}sendAsync(t,r,s){const o=new Date().getTime();this.request(t,s).then(u=>r(null,As(o,u))).catch(u=>r(u,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:ye("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}removeListener(t,r){this.events.removeListener(t,r)}off(t,r){this.events.off(t,r)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:o}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await o().then(u=>{this.session=u,this.namespaces||(this.namespaces=AI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==Ol)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,o]=this.validateChain(t);this.getProvider(s).setDefaultChain(o,r)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(cr(r)){for(const s of r)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await uI.init({logger:this.providerOpts.logger||Ch,relayUrl:this.providerOpts.relayUrl||_I,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(r=>vi(r)))];yo("client",this.client),yo("events",this.events),yo("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=CI(r,this.session),o=$l(s),u=TI(this.namespaces,this.optionalNamespaces),l=vo(Es({},u[r]),{accounts:s,chains:o});switch(r){case"eip155":this.rpcProviders[r]=new qI({namespace:l});break;case"solana":this.rpcProviders[r]=new jI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new UI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new DI({namespace:l});break;case"cip34":this.rpcProviders[r]=new MI({namespace:l});break;case"elrond":this.rpcProviders[r]=new LI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new kI({namespace:l});break;case"near":this.rpcProviders[r]=new zI({namespace:l});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:r}=t,{event:s}=r;if(s.name==="accountsChanged"){const o=s.data;o&&cr(o)&&this.events.emit("accountsChanged",o.map(xI))}else if(s.name==="chainChanged"){const o=r.chainId,u=r.event.data,l=vi(o),g=go(o)!==go(u)?`${l}:${go(u)}`:o;this.onChainChanged(g)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:o}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=vo(Es({},u),{namespaces:o}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:r})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",vo(Es({},ye("USER_DISCONNECTED")),{data:t.topic}))}),this.on(qt.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var r;this.getProvider(t).updateNamespace((r=this.session)==null?void 0:r.namespaces[t])})}setNamespaces(t){const{namespaces:r,optionalNamespaces:s,sessionProperties:o}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=o,this.persist("namespaces",r),this.persist("optionalNamespaces",s)}validateChain(t){const[r,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,s];if(r&&!Object.keys(this.namespaces||{}).map(l=>vi(l)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&s)return[r,s];const o=vi(Object.keys(this.namespaces)[0]),u=this.rpcProviders[o].getDefaultChain();return[o,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[o,u]=this.validateChain(t);r||this.getProvider(o).setDefaultChain(u),((s=this.namespaces[o])!=null?s:this.namespaces[`${o}:${u}`]).defaultChain=u,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",u)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,r){this.client.core.storage.setItem(`${Th}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${Th}/${t}`)}}const BI=Go,GI="wc",QI="ethereum_provider",JI=`${GI}@2:${QI}:`,YI="https://rpc.walletconnect.com/v1/",To=["eth_sendTransaction","personal_sign"],ZI=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],xo=["chainChanged","accountsChanged"],XI=["chainChanged","accountsChanged","message","disconnect","connect"];var eP=Object.defineProperty,tP=Object.defineProperties,rP=Object.getOwnPropertyDescriptors,Uh=Object.getOwnPropertySymbols,iP=Object.prototype.hasOwnProperty,sP=Object.prototype.propertyIsEnumerable,Mh=(a,t,r)=>t in a?eP(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,wi=(a,t)=>{for(var r in t||(t={}))iP.call(t,r)&&Mh(a,r,t[r]);if(Uh)for(var r of Uh(t))sP.call(t,r)&&Mh(a,r,t[r]);return a},Lh=(a,t)=>tP(a,rP(t));function $s(a){return Number(a[0].split(":")[1])}function mo(a){return`0x${a.toString(16)}`}function nP(a){const{chains:t,optionalChains:r,methods:s,optionalMethods:o,events:u,optionalEvents:l,rpcMap:g}=a;if(!wo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||To,events:u||xo,rpcMap:wi({},t.length?{[$s(t)]:g[$s(t)]}:{})},b=u==null?void 0:u.filter(j=>!xo.includes(j)),$=s==null?void 0:s.filter(j=>!To.includes(j));if(!r&&!l&&!o&&!(b!=null&&b.length)&&!($!=null&&$.length))return{required:t.length?w:void 0};const S=(b==null?void 0:b.length)&&($==null?void 0:$.length)||!r,R={chains:[...new Set(S?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(o!=null&&o.length?o:ZI))],events:[...new Set(w.events.concat(l!=null&&l.length?l:XI))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?R:void 0}}class Qo{constructor(){this.events=new ot.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=JI,this.on=(t,r)=>(this.events.on(t,r),this),this.once=(t,r)=>(this.events.once(t,r),this),this.removeListener=(t,r)=>(this.events.removeListener(t,r),this),this.off=(t,r)=>(this.events.off(t,r),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const r=new Qo;return await r.initialize(t),r}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,r){this.signer.sendAsync(t,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:r,optional:s}=nP(this.rpc);try{const o=await new Promise(async(l,g)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),g(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Lh(wi({namespaces:wi({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(b=>{l(b)}).catch(b=>{g(new Error(b.message))})});if(!o)return;const u=Jw(o.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:mo(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:r}=t,{event:s}=r;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const r=parseInt(t);this.chainId=r,this.events.emit("chainChanged",mo(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",Lh(wi({},Zw("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var r,s;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const r=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",mo(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,o]=t.split(":");return{chainId:`${r}:${s}`,address:o}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const o=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=o.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=o.length?(t==null?void 0:t.methods)||To:[],w=o.length?(t==null?void 0:t.events)||xo:[],b=(t==null?void 0:t.optionalMethods)||[],$=(t==null?void 0:t.optionalEvents)||[],S=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),R=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(j=>this.formatChainId(j)),optionalChains:u.map(j=>this.formatChainId(j)),methods:g,events:w,optionalMethods:b,optionalEvents:$,rpcMap:S,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:R,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(o=>{s[o]=this.getRpcUrl(o,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?$s(this.rpc.chains):$s(this.rpc.optionalChains),this.signer=await BI.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:s}=await Rw(()=>import("./index-BfryJIfK.js").then(o=>o.i),__vite__mapDeps([0,1,2]));r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(wi({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:r,optionalChains:s,rpcMap:o}=t;r&&wo(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(o==null?void 0:o[u])||this.getRpcUrl(u)})),s&&wo(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(u=>this.formatChainId(u)),s.forEach(u=>{this.rpc.rpcMap[u]=(o==null?void 0:o[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${YI}?chainId=eip155:${t}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(r=>this.parseAccount(r))}}const SP=Qo;export{SP as EthereumProvider,XI as OPTIONAL_EVENTS,ZI as OPTIONAL_METHODS,xo as REQUIRED_EVENTS,To as REQUIRED_METHODS,Qo as default};