var CoinbaseWalletSdk=function(t){var e={};function n(r){if(e[r])return e[r].exports;var s=e[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(r,s,function(e){return t[e]}.bind(null,s));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=29)}([function(t,e,n){"use strict";(function(t){n.d(e,"m",(function(){return a})),n.d(e,"n",(function(){return c})),n.d(e,"k",(function(){return u})),n.d(e,"i",(function(){return l})),n.d(e,"b",(function(){return h})),n.d(e,"a",(function(){return d})),n.d(e,"j",(function(){return f})),n.d(e,"l",(function(){return b})),n.d(e,"c",(function(){return w})),n.d(e,"e",(function(){return _})),n.d(e,"f",(function(){return v})),n.d(e,"d",(function(){return k})),n.d(e,"g",(function(){return E})),n.d(e,"h",(function(){return C}));var r=n(1),s=n(4);const i=/^[0-9]*$/,o=/^[a-f0-9]*$/;function a(t){return c(crypto.getRandomValues(new Uint8Array(t)))}function c(t){return[...t].map(t=>t.toString(16).padStart(2,"0")).join("")}function u(t){return new Uint8Array(t.match(/.{1,2}/g).map(t=>Number.parseInt(t,16)))}function l(t,e=!1){const n=t.toString("hex");return Object(s.c)(e?"0x"+n:n)}function h(t){return l(_(t),!0)}function d(t){return Object(s.b)(t.toString(10))}function f(t){return Object(s.c)("0x"+BigInt(t).toString(16))}function p(t){return t.startsWith("0x")||t.startsWith("0X")}function g(t){return p(t)?t.slice(2):t}function b(t){return p(t)?"0x"+t.slice(2):"0x"+t}function y(t){if("string"!=typeof t)return!1;const e=g(t).toLowerCase();return o.test(e)}function m(t,e=!1){let n=function(t,e=!1){if("string"==typeof t){const n=g(t).toLowerCase();if(o.test(n))return Object(s.c)(e?"0x"+n:n)}throw r.a.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}(t,!1);return n.length%2==1&&(n=Object(s.c)("0"+n)),e?Object(s.c)("0x"+n):n}function w(t){if("string"==typeof t){const e=g(t).toLowerCase();if(y(e)&&40===e.length)return Object(s.a)(b(e))}throw r.a.rpc.invalidParams("Invalid Ethereum address: "+String(t))}function _(e){if(t.isBuffer(e))return e;if("string"==typeof e){if(y(e)){const n=m(e,!1);return t.from(n,"hex")}return t.from(e,"utf8")}throw r.a.rpc.invalidParams("Not binary data: "+String(e))}function v(t){if("number"==typeof t&&Number.isInteger(t))return Object(s.d)(t);if("string"==typeof t){if(i.test(t))return Object(s.d)(Number(t));if(y(t))return Object(s.d)(Number(BigInt(m(t,!0))))}throw r.a.rpc.invalidParams("Not an integer: "+String(t))}function k(t){if(null!==t&&("bigint"==typeof t||function(t){if(null==t||"function"!=typeof t.constructor)return!1;const{constructor:e}=t;return"function"==typeof e.config&&"number"==typeof e.EUCLID}(t)))return BigInt(t.toString(10));if("number"==typeof t)return BigInt(v(t));if("string"==typeof t){if(i.test(t))return BigInt(t);if(y(t))return BigInt(m(t,!0))}throw r.a.rpc.invalidParams("Not an integer: "+String(t))}function E(t){if("string"==typeof t)return JSON.parse(t);if("object"==typeof t)return t;throw r.a.rpc.invalidParams("Not a JSON string or an object: "+String(t))}function C(){const t=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:n}=document.location,r=t?t.getAttribute("href"):null;return!r||r.startsWith("javascript:")||r.startsWith("vbscript:")?`${e}//${n}/favicon.ico`:r.startsWith("http://")||r.startsWith("https://")||r.startsWith("data:")?r:r.startsWith("//")?e+r:`${e}//${n}${r}`}}).call(this,n(10).Buffer)},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(2),s=n(12);const i={rpc:{parse:t=>o(r.b.rpc.parse,t),invalidRequest:t=>o(r.b.rpc.invalidRequest,t),invalidParams:t=>o(r.b.rpc.invalidParams,t),methodNotFound:t=>o(r.b.rpc.methodNotFound,t),internal:t=>o(r.b.rpc.internal,t),server:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return o(e,t)},invalidInput:t=>o(r.b.rpc.invalidInput,t),resourceNotFound:t=>o(r.b.rpc.resourceNotFound,t),resourceUnavailable:t=>o(r.b.rpc.resourceUnavailable,t),transactionRejected:t=>o(r.b.rpc.transactionRejected,t),methodNotSupported:t=>o(r.b.rpc.methodNotSupported,t),limitExceeded:t=>o(r.b.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>a(r.b.provider.userRejectedRequest,t),unauthorized:t=>a(r.b.provider.unauthorized,t),unsupportedMethod:t=>a(r.b.provider.unsupportedMethod,t),disconnected:t=>a(r.b.provider.disconnected,t),chainDisconnected:t=>a(r.b.provider.chainDisconnected,t),unsupportedChain:t=>a(r.b.provider.unsupportedChain,t),custom:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:n,data:r}=t;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new l(e,n,r)}}};function o(t,e){const[n,r]=c(e);return new u(t,n||Object(s.a)(t),r)}function a(t,e){const[n,r]=c(e);return new l(t,n||Object(s.a)(t),r)}function c(t){if(t){if("string"==typeof t)return[t];if("object"==typeof t&&!Array.isArray(t)){const{message:e,data:n}=t;if(e&&"string"!=typeof e)throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}class u extends Error{constructor(t,e,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!e||"string"!=typeof e)throw new Error('"message" must be a nonempty string.');super(e),this.code=t,void 0!==n&&(this.data=n)}}class l extends u{constructor(t,e,n){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,e,n)}}},function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"a",(function(){return s}));const r={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}},s={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}}},function(t,e,n){"use strict";function r(t){return void 0!==t.errorMessage}n.d(e,"a",(function(){return r}))},function(t,e,n){"use strict";n.d(e,"c",(function(){return r})),n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return i})),n.d(e,"d",(function(){return o})),n.d(e,"e",(function(){return a}));const r=t=>t,s=t=>t,i=t=>t;function o(t){return Math.floor(t)}const a=t=>t},function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));class r{constructor(t,e){this.scope=t,this.module=e}storeObject(t,e){this.setItem(t,JSON.stringify(e))}loadObject(t){const e=this.getItem(t);return e?JSON.parse(e):void 0}setItem(t,e){localStorage.setItem(this.scopedKey(t),e)}getItem(t){return localStorage.getItem(this.scopedKey(t))}removeItem(t){localStorage.removeItem(this.scopedKey(t))}clear(){const t=this.scopedKey(""),e=[];for(let n=0;nlocalStorage.removeItem(t))}scopedKey(t){return`-${this.scope}${this.module?":"+this.module:""}:${t}`}static clearAll(){new r("CBWSDK").clear(),new r("walletlink").clear()}}},function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"a",(function(){return s}));const r="4.2.3",s="@coinbase/wallet-sdk"},function(t,e,n){"use strict";n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return o})),n.d(e,"a",(function(){return a}));var r=n(6),s=n(1);async function i(t,e){const n=Object.assign(Object.assign({},t),{jsonrpc:"2.0",id:crypto.randomUUID()}),s=await window.fetch(e,{method:"POST",body:JSON.stringify(n),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":r.b,"X-Cbw-Sdk-Platform":r.a}}),{result:i,error:o}=await s.json();if(o)throw o;return i}function o({metadata:t,preference:e}){var n,r;const{appName:s,appLogoUrl:i,appChainIds:o}=t;if("smartWalletOnly"!==e.options){const t=globalThis.coinbaseWalletExtension;if(t)return null===(n=t.setAppInfo)||void 0===n||n.call(t,s,i,o,e),t}const a=function(){var t,e;try{const n=globalThis;return null!==(t=n.ethereum)&&void 0!==t?t:null===(e=n.top)||void 0===e?void 0:e.ethereum}catch(t){return}}();if(null==a?void 0:a.isCoinbaseBrowser)return null===(r=a.setAppInfo)||void 0===r||r.call(a,s,i,o,e),a}function a(t){if(!t||"object"!=typeof t||Array.isArray(t))throw s.a.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:t});const{method:e,params:n}=t;if("string"!=typeof e||0===e.length)throw s.a.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:t});if(void 0!==n&&!Array.isArray(n)&&("object"!=typeof n||null===n))throw s.a.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:t});switch(e){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw s.a.provider.unsupportedMethod()}}},function(t,e,n){"use strict";n.d(e,"c",(function(){return r})),n.d(e,"b",(function(){return s})),n.d(e,"a",(function(){return i}));const r="walletUsername",s="Addresses",i="AppVersion"},function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"c",(function(){return s})),n.d(e,"a",(function(){return i}));const r="https://keys.coinbase.com/connect",s="https://www.walletlink.org",i="https://go.cb-w.com/walletlink"},function(t,e,n){"use strict";(function(t){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var r=n(21),s=n(22),i=n(23);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(t).length;default:if(r)return H(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,n);case"utf8":case"utf-8":return S(this,e,n);case"ascii":return x(this,e,n);case"latin1":case"binary":return A(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function b(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,s){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=s?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(s)return-1;n=t.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,s);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,s);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,s){var i,o=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,n/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(s){var l=-1;for(i=n;ia&&(n=a-c),i=n;i>=0;i--){for(var h=!0,d=0;ds&&(r=s):r=s;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var o=0;o>8,s=n%256,i.push(s),i.push(r);return i}(e,t.length-n),t,n,r)}function I(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function S(t,e,n){n=Math.min(t.length,n);for(var r=[],s=e;s239?4:u>223?3:u>191?2:1;if(s+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(i=t[s+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=t[s+1],o=t[s+2],128==(192&i)&&128==(192&o)&&(c=(15&u)<<12|(63&i)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=t[s+1],o=t[s+2],a=t[s+3],128==(192&i)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),s+=h}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},c.prototype.compare=function(t,e,n,r,s){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===s&&(s=this.length),e<0||n>t.length||r<0||s>this.length)throw new RangeError("out of range index");if(r>=s&&e>=n)return 0;if(r>=s)return-1;if(e>=n)return 1;if(this===t)return 0;for(var i=(s>>>=0)-(r>>>=0),o=(n>>>=0)-(e>>>=0),a=Math.min(i,o),u=this.slice(r,s),l=t.slice(e,n),h=0;hs)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return w(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":return v(this,t,e,n);case"latin1":case"binary":return k(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(t,e,n){var r="";n=Math.min(t.length,n);for(var s=e;sr)&&(n=r);for(var s="",i=e;in)throw new RangeError("Trying to access beyond buffer length")}function j(t,e,n,r,s,i){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||et.length)throw new RangeError("Index out of range")}function P(t,e,n,r){e<0&&(e=65535+e+1);for(var s=0,i=Math.min(t.length-n,2);s>>8*(r?s:1-s)}function R(t,e,n,r){e<0&&(e=4294967295+e+1);for(var s=0,i=Math.min(t.length-n,4);s>>8*(r?s:3-s)&255}function T(t,e,n,r,s,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(t,e,n,r,i){return i||T(t,0,n,4),s.write(t,e,n,r,23,4),n+4}function U(t,e,n,r,i){return i||T(t,0,n,8),s.write(t,e,n,r,52,8),n+8}c.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(s*=256);)r+=this[t+--e]*s;return r},c.prototype.readUInt8=function(t,e){return e||L(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||L(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||L(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||L(t,e,this.length);for(var r=this[t],s=1,i=0;++i=(s*=128)&&(r-=Math.pow(2,8*e)),r},c.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||L(t,e,this.length);for(var r=e,s=1,i=this[t+--r];r>0&&(s*=256);)i+=this[t+--r]*s;return i>=(s*=128)&&(i-=Math.pow(2,8*e)),i},c.prototype.readInt8=function(t,e){return e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||L(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(t,e){e||L(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(t,e){return e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||L(t,4,this.length),s.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||L(t,4,this.length),s.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||L(t,8,this.length),s.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||L(t,8,this.length),s.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||j(this,t,e,n,Math.pow(2,8*n)-1,0);var s=1,i=0;for(this[e]=255&t;++i=0&&(i*=256);)this[e+s]=t/i&255;return e+n},c.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):R(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):R(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var s=Math.pow(2,8*n-1);j(this,t,e,n,s-1,-s)}var i=0,o=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+n},c.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var s=Math.pow(2,8*n-1);j(this,t,e,n,s-1,-s)}var i=n-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+n},c.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):R(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):R(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,n){return D(this,t,e,!0,n)},c.prototype.writeFloatBE=function(t,e,n){return D(this,t,e,!1,n)},c.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},c.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},c.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--s)t[s+e]=this[s+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(s=0;s>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&n<57344){if(!s){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&i.push(239,191,189);continue}s=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),s=n;continue}n=65536+(s-55296<<10|n-56320)}else s&&(e-=3)>-1&&i.push(239,191,189);if(s=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function W(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function q(t,e,n,r){for(var s=0;s=e.length||s>=t.length);++s)e[s+n]=t[s];return s}}).call(this,n(20))},function(t,e,n){"use strict"; /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name},e.byteSwap32=function(t){for(let n=0;n=0&&tt().update(p(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,n)=>t(n).update(p(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,n)=>t(n).update(p(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(t));if(r.crypto&&"function"==typeof r.crypto.randomBytes)return r.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const r=n(26),s=n(14);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t);const i=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));const o=48,a=57,c=65,u=70,l=97,h=102;function d(t){return t>=o&&t<=a?t-o:t>=c&&t<=u?t-(c-10):t>=l&&t<=h?t-(l-10):void 0}function f(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function p(t){return"string"==typeof t&&(t=f(t)),(0,s.bytes)(t),t}e.nextTick=async()=>{};e.Hash=class{clone(){return this._cloneInto()}};const g={}.toString},function(t,e,n){"use strict";n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return i}));var r=n(2);function s(t,e="Unspecified error message."){if(t&&Number.isInteger(t)){const e=t.toString();if(c(r.a,e))return r.a[e].message;if(o(t))return"Unspecified server error."}return e}function i(t,{shouldIncludeStack:e=!1}={}){const n={};if(t&&"object"==typeof t&&!Array.isArray(t)&&c(t,"code")&&function(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!r.a[e]||!!o(t)}(t.code)){const e=t;n.code=e.code,e.message&&"string"==typeof e.message?(n.message=e.message,c(e,"data")&&(n.data=e.data)):(n.message=s(n.code),n.data={originalError:a(t)})}else n.code=r.b.rpc.internal,n.message=u(t,"message")?t.message:"Unspecified error message.",n.data={originalError:a(t)};return e&&(n.stack=u(t,"stack")?t.stack:void 0),n}function o(t){return t>=-32099&&t<=-32e3}function a(t){return t&&"object"==typeof t&&!Array.isArray(t)?Object.assign({},t):t}function c(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function u(t,e){return"object"==typeof t&&null!==t&&e in t&&"string"==typeof t[e]}},function(t,e,n){(function(e){const r=n(16),s=n(27),i={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},o={encodeData(t,n,i,o=!0){const a=["bytes32"],c=[this.hashType(t,i)];if(o){const u=(t,n,a)=>{if(void 0!==i[n])return["bytes32",null==a?"0x0000000000000000000000000000000000000000000000000000000000000000":r.keccak(this.encodeData(n,a,i,o))];if(void 0===a)throw new Error(`missing value for field ${t} of type ${n}`);if("bytes"===n)return["bytes32",r.keccak(a)];if("string"===n)return"string"==typeof a&&(a=e.from(a,"utf8")),["bytes32",r.keccak(a)];if(n.lastIndexOf("]")===n.length-1){const e=n.slice(0,n.lastIndexOf("[")),i=a.map(n=>u(t,e,n));return["bytes32",r.keccak(s.rawEncode(i.map(([t])=>t),i.map(([,t])=>t)))]}return[n,a]};for(const e of i[t]){const[t,r]=u(e.name,e.type,n[e.name]);a.push(t),c.push(r)}}else for(const s of i[t]){let t=n[s.name];if(void 0!==t)if("bytes"===s.type)a.push("bytes32"),t=r.keccak(t),c.push(t);else if("string"===s.type)a.push("bytes32"),"string"==typeof t&&(t=e.from(t,"utf8")),t=r.keccak(t),c.push(t);else if(void 0!==i[s.type])a.push("bytes32"),t=r.keccak(this.encodeData(s.type,t,i,o)),c.push(t);else{if(s.type.lastIndexOf("]")===s.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");a.push(s.type),c.push(t)}}return s.rawEncode(a,c)},encodeType(t,e){let n="",r=this.findTypeDependencies(t,e).filter(e=>e!==t);r=[t].concat(r.sort());for(const t of r){if(!e[t])throw new Error("No type definition specified: "+t);n+=t+"("+e[t].map(({name:t,type:e})=>e+" "+t).join(",")+")"}return n},findTypeDependencies(t,e,n=[]){if(t=t.match(/^\w*/)[0],n.includes(t)||void 0===e[t])return n;n.push(t);for(const r of e[t])for(const t of this.findTypeDependencies(r.type,e,n))!n.includes(t)&&n.push(t);return n},hashStruct(t,e,n,s=!0){return r.keccak(this.encodeData(t,e,n,s))},hashType(t,e){return r.keccak(this.encodeType(t,e))},sanitizeData(t){const e={};for(const n in i.properties)t[n]&&(e[n]=t[n]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(t,n=!0){const s=this.sanitizeData(t),i=[e.from("1901","hex")];return i.push(this.hashStruct("EIP712Domain",s.domain,s.types,n)),"EIP712Domain"!==s.primaryType&&i.push(this.hashStruct(s.primaryType,s.message,s.types,n)),r.keccak(e.concat(i))}};t.exports={TYPED_MESSAGE_SCHEMA:i,TypedDataUtils:o,hashForSignTypedDataLegacy:function(t){return function(t){const e=new Error("Expect argument to be non-empty array");if("object"!=typeof t||!t.length)throw e;const n=t.map((function(t){return"bytes"===t.type?r.toBuffer(t.value):t.value})),i=t.map((function(t){return t.type})),o=t.map((function(t){if(!t.name)throw e;return t.type+" "+t.name}));return s.soliditySHA3(["bytes32","bytes32"],[s.soliditySHA3(new Array(t.length).fill("string"),o),s.soliditySHA3(i,n)])}(t.data)},hashForSignTypedData_v3:function(t){return o.hash(t.data,!1)},hashForSignTypedData_v4:function(t){return o.hash(t.data)}}}).call(this,n(10).Buffer)},function(t,e,n){"use strict";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, not "+t)}function s(t){if("boolean"!=typeof t)throw new Error("boolean expected, not "+t)}function i(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function a(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function c(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function u(t,e){o(t);const n=e.outputLen;if(t.lengthObject(h.c)(t)))}this.initializeRelay()}getSession(){const t=this.initializeRelay(),{id:e,secret:n}=t.getWalletLinkSession();return{id:e,secret:n}}async handshake(){await this._eth_requestAccounts()}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var t;return null!==(t=this._storage.getItem("DefaultJsonRpcUrl"))&&void 0!==t?t:void 0}set jsonRpcUrl(t){this._storage.setItem("DefaultJsonRpcUrl",t)}updateProviderInfo(t,e){var n;this.jsonRpcUrl=t;const r=this.getChainId();this._storage.setItem("DefaultChainId",e.toString(10));Object(h.f)(e)!==r&&(null===(n=this.callback)||void 0===n||n.call(this,"chainChanged",Object(h.j)(e)))}async watchAsset(t){const e=Array.isArray(t)?t[0]:t;if(!e.type)throw u.a.rpc.invalidParams("Type is required");if("ERC20"!==(null==e?void 0:e.type))throw u.a.rpc.invalidParams(`Asset of type '${e.type}' is not supported`);if(!(null==e?void 0:e.options))throw u.a.rpc.invalidParams("Options are required");if(!(null==e?void 0:e.options.address))throw u.a.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:r,symbol:s,image:i,decimals:a}=e.options,c=this.initializeRelay(),l=await c.watchAsset(e.type,r,s,a,i,null==n?void 0:n.toString());return!Object(o.a)(l)&&!!l.result}async addEthereumChain(t){var e,n;const r=t[0];if(0===(null===(e=r.rpcUrls)||void 0===e?void 0:e.length))throw u.a.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!r.chainName||""===r.chainName.trim())throw u.a.rpc.invalidParams("chainName is a required field");if(!r.nativeCurrency)throw u.a.rpc.invalidParams("nativeCurrency is a required field");const s=Number.parseInt(r.chainId,16);if(s===this.getChainId())return!1;const i=this.initializeRelay(),{rpcUrls:a=[],blockExplorerUrls:c=[],chainName:l,iconUrls:h=[],nativeCurrency:d}=r,f=await i.addEthereumChain(s.toString(),a,h,c,l,d);if(Object(o.a)(f))return!1;if(!0===(null===(n=f.result)||void 0===n?void 0:n.isApproved))return this.updateProviderInfo(a[0],s),null;throw u.a.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(t){const e=t[0],n=Number.parseInt(e.chainId,16),r=this.initializeRelay(),s=await r.switchEthereumChain(n.toString(10),this.selectedAddress||void 0);if(Object(o.a)(s))throw s;const i=s.result;return i.isApproved&&i.rpcUrl.length>0&&this.updateProviderInfo(i.rpcUrl,n),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(t,e){var n;if(!Array.isArray(t))throw new Error("addresses is not an array");const r=t.map(t=>Object(h.c)(t));JSON.stringify(r)!==JSON.stringify(this._addresses)&&(this._addresses=r,null===(n=this.callback)||void 0===n||n.call(this,"accountsChanged",r),this._storage.setItem(i.b,r.join(" ")))}async request(t){const e=t.params||[];switch(t.method){case"eth_accounts":return[...this._addresses];case"eth_coinbase":return this.selectedAddress||null;case"net_version":return this.getChainId().toString(10);case"eth_chainId":return Object(h.j)(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(t);case"personal_sign":return this.personalSign(t);case"eth_signTransaction":return this._eth_signTransaction(e);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(e);case"eth_sendTransaction":return this._eth_sendTransaction(e);case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":return this.signTypedData(t);case"wallet_addEthereumChain":return this.addEthereumChain(e);case"wallet_switchEthereumChain":return this.switchEthereumChain(e);case"wallet_watchAsset":return this.watchAsset(e);default:if(!this.jsonRpcUrl)throw u.a.rpc.internal("No RPC URL set for chain");return Object(d.b)(t,this.jsonRpcUrl)}}_ensureKnownAddress(t){const e=Object(h.c)(t);if(!this._addresses.map(t=>Object(h.c)(t)).includes(e))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const n=e.from?Object(h.c)(e.from):this.selectedAddress;if(!n)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(n);return{fromAddress:n,toAddress:e.to?Object(h.c)(e.to):null,weiValue:null!=e.value?Object(h.d)(e.value):BigInt(0),data:e.data?Object(h.e)(e.data):t.alloc(0),nonce:null!=e.nonce?Object(h.f)(e.nonce):null,gasPriceInWei:null!=e.gasPrice?Object(h.d)(e.gasPrice):null,maxFeePerGas:null!=e.maxFeePerGas?Object(h.d)(e.maxFeePerGas):null,maxPriorityFeePerGas:null!=e.maxPriorityFeePerGas?Object(h.d)(e.maxPriorityFeePerGas):null,gasLimit:null!=e.gas?Object(h.d)(e.gas):null,chainId:e.chainId?Object(h.f)(e.chainId):this.getChainId()}}async ecRecover(t){const{method:e,params:n}=t;if(!Array.isArray(n))throw u.a.rpc.invalidParams();const r=this.initializeRelay(),s=await r.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:Object(h.b)(n[0]),signature:Object(h.b)(n[1]),addPrefix:"personal_ecRecover"===e}});if(Object(o.a)(s))throw s;return s.result}getChainId(){var t;return Number.parseInt(null!==(t=this._storage.getItem("DefaultChainId"))&&void 0!==t?t:"1",10)}async _eth_requestAccounts(){var t,e;if(this._addresses.length>0)return null===(t=this.callback)||void 0===t||t.call(this,"connect",{chainId:Object(h.j)(this.getChainId())}),this._addresses;const n=this.initializeRelay(),r=await n.requestEthereumAccounts();if(Object(o.a)(r))throw r;if(!r.result)throw new Error("accounts received is empty");return this._setAddresses(r.result),null===(e=this.callback)||void 0===e||e.call(this,"connect",{chainId:Object(h.j)(this.getChainId())}),this._addresses}async personalSign({params:t}){if(!Array.isArray(t))throw u.a.rpc.invalidParams();const e=t[1],n=t[0];this._ensureKnownAddress(e);const r=this.initializeRelay(),s=await r.sendRequest({method:"signEthereumMessage",params:{address:Object(h.c)(e),message:Object(h.b)(n),addPrefix:!0,typedDataJson:null}});if(Object(o.a)(s))throw s;return s.result}async _eth_signTransaction(t){const e=this._prepareTransactionParams(t[0]||{}),n=this.initializeRelay(),r=await n.signEthereumTransaction(e);if(Object(o.a)(r))throw r;return r.result}async _eth_sendRawTransaction(t){const e=Object(h.e)(t[0]),n=this.initializeRelay(),r=await n.submitEthereumTransaction(e,this.getChainId());if(Object(o.a)(r))throw r;return r.result}async _eth_sendTransaction(t){const e=this._prepareTransactionParams(t[0]||{}),n=this.initializeRelay(),r=await n.signAndSubmitEthereumTransaction(e);if(Object(o.a)(r))throw r;return r.result}async signTypedData(t){const{method:e,params:n}=t;if(!Array.isArray(n))throw u.a.rpc.invalidParams();const r=n["eth_signTypedData_v1"===e?1:0],i=n["eth_signTypedData_v1"===e?0:1];this._ensureKnownAddress(r);const a=this.initializeRelay(),c=await a.sendRequest({method:"signEthereumMessage",params:{address:Object(h.c)(r),message:(t=>{const n={eth_signTypedData_v1:s.a.hashForSignTypedDataLegacy,eth_signTypedData_v3:s.a.hashForSignTypedData_v3,eth_signTypedData_v4:s.a.hashForSignTypedData_v4,eth_signTypedData:s.a.hashForSignTypedData_v4};return Object(h.i)(n[e]({data:Object(h.g)(t)}),!0)})(i),typedDataJson:JSON.stringify(i,null,2),addPrefix:!1}});if(Object(o.a)(c))throw c;return c.result}initializeRelay(){return this._relay||(this._relay=new a.a({linkAPIUrl:c.c,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}}).call(this,n(10).Buffer)},function(t,e,n){(function(e){const{keccak_256:r}=n(24);function s(t){return e.allocUnsafe(t).fill(0)}function i(t,n){let r=t.toString(16);r.length%2!=0&&(r="0"+r);const s=r.match(/.{1,2}/g).map(t=>parseInt(t,16));for(;s.length>>3,i=(0,s.rotr)(n,17)^(0,s.rotr)(n,19)^n>>>10;a[t]=i+a[t-7]+r+a[t-16]|0}let{A:n,B:o,C:c,D:u,E:l,F:h,G:d,H:f}=this;for(let t=0;t<64;t++){const e=f+((0,s.rotr)(l,6)^(0,s.rotr)(l,11)^(0,s.rotr)(l,25))+(0,r.Chi)(l,h,d)+i[t]+a[t]|0,p=((0,s.rotr)(n,2)^(0,s.rotr)(n,13)^(0,s.rotr)(n,22))+(0,r.Maj)(n,o,c)|0;f=d,d=h,h=l,l=u+e|0,u=c,c=o,o=n,n=e+p|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,u=u+this.D|0,l=l+this.E|0,h=h+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,o,c,u,l,h,d,f)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}e.SHA256=c;class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,s.wrapConstructor)(()=>new c),e.sha224=(0,s.wrapConstructor)(()=>new u)},function(t,e,n){"use strict";n.d(e,"a",(function(){return Ut}));var r,s=n(8),i=n(0);class o{constructor(t){this.secret=t}async encrypt(t){const e=this.secret;if(64!==e.length)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.importKey("raw",Object(i.k)(e),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=new TextEncoder,o=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},r,s.encode(t)),a=o.slice(o.byteLength-16),c=o.slice(0,o.byteLength-16),u=new Uint8Array(a),l=new Uint8Array(c),h=new Uint8Array([...n,...u,...l]);return Object(i.n)(h)}async decrypt(t){const e=this.secret;if(64!==e.length)throw Error("secret must be 256 bits");return new Promise((n,r)=>{!async function(){const s=await crypto.subtle.importKey("raw",Object(i.k)(e),{name:"aes-gcm"},!1,["encrypt","decrypt"]),o=Object(i.k)(t),a=o.slice(0,12),c=o.slice(12,28),u=o.slice(28),l=new Uint8Array([...u,...c]),h={name:"AES-GCM",iv:new Uint8Array(a)};try{const t=await window.crypto.subtle.decrypt(h,s,l),e=new TextDecoder;n(e.decode(t))}catch(t){r(t)}}()})}}class a{constructor(t,e,n){this.linkAPIUrl=t,this.sessionId=e;const r=`${e}:${n}`;this.auth="Basic "+btoa(r)}async markUnseenEventsAsSeen(t){return Promise.all(t.map(t=>fetch(`${this.linkAPIUrl}/events/${t.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(t=>console.error("Unabled to mark event as failed:",t))}async fetchUnseenEvents(){var t;const e=await fetch(this.linkAPIUrl+"/events?unseen=true",{headers:{Authorization:this.auth}});if(e.ok){const{events:n,error:r}=await e.json();if(r)throw new Error("Check unseen events failed: "+r);const s=null!==(t=null==n?void 0:n.filter(t=>"Web3Response"===t.event).map(t=>({type:"Event",sessionId:this.sessionId,eventId:t.id,event:t.event,data:t.data})))&&void 0!==t?t:[];return this.markUnseenEventsAsSeen(s),s}throw new Error("Check unseen events failed: "+e.status)}}!function(t){t[t.DISCONNECTED=0]="DISCONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED"}(r||(r={}));class c{setConnectionStateListener(t){this.connectionStateListener=t}setIncomingDataListener(t){this.incomingDataListener=t}constructor(t,e=WebSocket){this.WebSocketClass=e,this.webSocket=null,this.pendingData=[],this.url=t.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((t,e)=>{var n;let s;try{this.webSocket=s=new this.WebSocketClass(this.url)}catch(t){return void e(t)}null===(n=this.connectionStateListener)||void 0===n||n.call(this,r.CONNECTING),s.onclose=t=>{var n;this.clearWebSocket(),e(new Error(`websocket error ${t.code}: ${t.reason}`)),null===(n=this.connectionStateListener)||void 0===n||n.call(this,r.DISCONNECTED)},s.onopen=e=>{var n;if(t(),null===(n=this.connectionStateListener)||void 0===n||n.call(this,r.CONNECTED),this.pendingData.length>0){[...this.pendingData].forEach(t=>this.sendData(t)),this.pendingData=[]}},s.onmessage=t=>{var e,n;if("h"===t.data)null===(e=this.incomingDataListener)||void 0===e||e.call(this,{type:"Heartbeat"});else try{const e=JSON.parse(t.data);null===(n=this.incomingDataListener)||void 0===n||n.call(this,e)}catch(t){}}})}disconnect(){var t;const{webSocket:e}=this;if(e){this.clearWebSocket(),null===(t=this.connectionStateListener)||void 0===t||t.call(this,r.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{e.close()}catch(t){}}}sendData(t){const{webSocket:e}=this;if(!e)return this.pendingData.push(t),void this.connect();e.send(t)}clearWebSocket(){const{webSocket:t}=this;t&&(this.webSocket=null,t.onclose=null,t.onerror=null,t.onmessage=null,t.onopen=null)}}var u=n(4);class l{constructor({session:t,linkAPIUrl:e,listener:n}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=Object(u.d)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=t=>{if(!t)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",e=>t.JsonRpcUrl&&this.handleChainUpdated(e,t.JsonRpcUrl)]]).forEach((e,n)=>{const r=t[n];void 0!==r&&e(r)})},this.handleDestroyed=t=>{var e;"1"===t&&(null===(e=this.listener)||void 0===e||e.resetAndReload())},this.handleAccountUpdated=async t=>{var e;const n=await this.cipher.decrypt(t);null===(e=this.listener)||void 0===e||e.accountUpdated(n)},this.handleMetadataUpdated=async(t,e)=>{var n;const r=await this.cipher.decrypt(e);null===(n=this.listener)||void 0===n||n.metadataUpdated(t,r)},this.handleWalletUsernameUpdated=async t=>{this.handleMetadataUpdated(s.c,t)},this.handleAppVersionUpdated=async t=>{this.handleMetadataUpdated(s.a,t)},this.handleChainUpdated=async(t,e)=>{var n;const r=await this.cipher.decrypt(t),s=await this.cipher.decrypt(e);null===(n=this.listener)||void 0===n||n.chainUpdated(r,s)},this.session=t,this.cipher=new o(t.secret),this.listener=n;const i=new c(e+"/rpc",WebSocket);i.setConnectionStateListener(async t=>{let e=!1;switch(t){case r.DISCONNECTED:if(!this.destroyed){const t=async()=>{await new Promise(t=>setTimeout(t,5e3)),this.destroyed||i.connect().catch(()=>{t()})};t()}break;case r.CONNECTED:e=await this.handleConnected(),this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},1e4),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case r.CONNECTING:}this.connected!==e&&(this.connected=e)}),i.setIncomingDataListener(t=>{var e;switch(t.type){case"Heartbeat":return void this.updateLastHeartbeat();case"IsLinkedOK":case"Linked":{const e="IsLinkedOK"===t.type?t.linked:void 0;this.linked=e||t.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":this.handleSessionMetadataUpdated(t.metadata);break;case"Event":this.handleIncomingEvent(t)}void 0!==t.id&&(null===(e=this.requestResolutions.get(t.id))||void 0===e||e(t))}),this.ws=i,this.http=new a(e,t.id,t.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:Object(u.d)(this.nextReqId++),sessionId:this.session.id,metadata:{__destroyed:"1"}},{timeout:1e3}),this.destroyed=!0,this.ws.disconnect(),this.listener=void 0)}get connected(){return this._connected}set connected(t){this._connected=t}get linked(){return this._linked}set linked(t){var e,n;this._linked=t,t&&(null===(e=this.onceLinked)||void 0===e||e.call(this)),null===(n=this.listener)||void 0===n||n.linkedUpdated(t)}setOnceLinked(t){return new Promise(e=>{this.linked?t().then(e):this.onceLinked=()=>{t().then(e),this.onceLinked=void 0}})}async handleIncomingEvent(t){var e;if("Event"!==t.type||"Web3Response"!==t.event)return;const n=await this.cipher.decrypt(t.data),r=JSON.parse(n);if("WEB3_RESPONSE"!==r.type)return;const{id:s,response:i}=r;null===(e=this.listener)||void 0===e||e.handleWeb3ResponseMessage(s,i)}async checkUnseenEvents(){if(this.connected){await new Promise(t=>setTimeout(t,250));try{await this.fetchUnseenEventsAPI()}catch(t){console.error("Unable to check for unseen events",t)}}else this.shouldFetchUnseenEventsOnConnect=!0}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1;(await this.http.fetchUnseenEvents()).forEach(t=>this.handleIncomingEvent(t))}async publishEvent(t,e,n=!1){const r=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{origin:location.origin,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),s={type:"PublishEvent",id:Object(u.d)(this.nextReqId++),sessionId:this.session.id,event:t,data:r,callWebhook:n};return this.setOnceLinked(async()=>{const t=await this.makeRequest(s);if("Fail"===t.type)throw new Error(t.error||"failed to publish event");return t.eventId})}sendData(t){this.ws.sendData(JSON.stringify(t))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>2e4)this.ws.disconnect();else try{this.ws.sendData("h")}catch(t){}}async makeRequest(t,e={timeout:6e4}){const n=t.id;let r;return this.sendData(t),Promise.race([new Promise((t,s)=>{r=window.setTimeout(()=>{s(new Error(`request ${n} timed out`))},e.timeout)}),new Promise(t=>{this.requestResolutions.set(n,e=>{clearTimeout(r),t(e),this.requestResolutions.delete(n)})})])}async handleConnected(){return"Fail"!==(await this.makeRequest({type:"HostSession",id:Object(u.d)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type&&(this.sendData({type:"IsLinked",id:Object(u.d)(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:Object(u.d)(this.nextReqId++),sessionId:this.session.id}),!0)}}class h{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const t=this._nextRequestId,e=Object(i.l)(t.toString(16));return this.callbacks.get(e)&&this.callbacks.delete(e),t}}var d=n(18),f=n(11);class p{constructor(t,e,n,r=!1){this.storage=t,this.id=e,this.secret=n,this.key=Object(f.bytesToHex)(Object(d.sha256)(`${e}, ${n} WalletLink`)),this._linked=!!r}static create(t){const e=Object(i.m)(16),n=Object(i.m)(32);return new p(t,e,n).save()}static load(t){const e=t.getItem("session:id"),n=t.getItem("session:linked"),r=t.getItem("session:secret");return e&&r?new p(t,e,r,"1"===n):null}get linked(){return this._linked}set linked(t){this._linked=t,this.persistLinked()}save(){return this.storage.setItem("session:id",this.id),this.storage.setItem("session:secret",this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem("session:linked",this._linked?"1":"0")}}var g=n(3);function b(){try{return function(){try{return null!==window.frameElement}catch(t){return!1}}()&&window.top?window.top.location:window.location}catch(t){return window.location}}function y(){var t,e;return null!==(e=null===(t=null===window||void 0===window?void 0:window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)").matches)&&void 0!==e&&e}function m(){const t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode('@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}')),document.documentElement.appendChild(t)}function w(t){var e,n,r="";if("string"==typeof t||"number"==typeof t)r+=t;else if("object"==typeof t)if(Array.isArray(t))for(e=0;e2&&(o.children=arguments.length>3?v.call(arguments,2):n),"function"==typeof t&&null!=t.defaultProps)for(i in t.defaultProps)void 0===o[i]&&(o[i]=t.defaultProps[i]);return N(t,o,r,s,null)}function N(t,e,n,r,s){var i={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==s?++E:s,__i:-1,__u:0};return null==s&&null!=k.vnode&&k.vnode(i),i}function B(t){return t.children}function H(t,e){this.props=t,this.context=e}function W(t,e){if(null==e)return t.__?W(t.__,t.__i+1):null;for(var n;ee&&C.sort(x));F.__r=0}function z(t,e,n,r,s,i,o,a,c,u,l){var h,d,f,p,g,b=r&&r.__k||j,y=e.length;for(n.__d=c,Z(n,e,b),c=n.__d,h=0;h0?N(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=t,s.__b=t.__b+1,i=null,-1!==(a=s.__i=Y(s,n,o,l))&&(l--,(i=n[a])&&(i.__u|=131072)),null==i||null===i.__v?(-1==a&&h--,"function"!=typeof s.type&&(s.__u|=65536)):a!==o&&(a==o-1?h--:a==o+1?h++:(a>o?h--:h++,s.__u|=65536))):s=t.__k[r]=null;if(l)for(r=0;r(null!=c&&0==(131072&c.__u)?1:0))for(;o>=0||a=0){if((c=e[o])&&0==(131072&c.__u)&&s==c.key&&i===c.type)return o;o--}if(a=n.__.length&&n.__.push({}),n.__[t]}function wt(t){return ut=1,function(t,e,n){var r=mt(it++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):St(void 0,e),function(t){var e=r.__N?r.__N[0]:r.__[0],n=r.t(e,t);e!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=ot,!ot.u)){var s=function(t,e,n){if(!r.__c.__H)return!0;var s=r.__c.__H.__.filter((function(t){return!!t.__c}));if(s.every((function(t){return!t.__N})))return!i||i.call(this,t,e,n);var o=!1;return s.forEach((function(t){if(t.__N){var e=t.__[0];t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(o=!0)}})),!(!o&&r.__c.props===t)&&(!i||i.call(this,t,e,n))};ot.u=!0;var i=ot.shouldComponentUpdate,o=ot.componentWillUpdate;ot.componentWillUpdate=function(t,e,n){if(this.__e){var r=i;i=void 0,s(t,e,n),i=r}o&&o.call(this,t,e,n)},ot.shouldComponentUpdate=s}return r.__N||r.__}(St,t)}function _t(){for(var t;t=lt.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Et),t.__H.__h.forEach(Ct),t.__H.__h=[]}catch(e){t.__H.__h=[],ht.__e(e,t.__v)}}ht.__b=function(t){ot=null,dt&&dt(t)},ht.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),yt&&yt(t,e)},ht.__r=function(t){ft&&ft(t),it=0;var e=(ot=t.__c).__H;e&&(at===ot?(e.__h=[],ot.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.i=t.__N=void 0}))):(e.__h.forEach(Et),e.__h.forEach(Ct),e.__h=[],it=0)),at=ot},ht.diffed=function(t){pt&&pt(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(1!==lt.push(e)&&ct===ht.requestAnimationFrame||((ct=ht.requestAnimationFrame)||kt)(_t)),e.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.i=void 0}))),at=ot=null},ht.__c=function(t,e){e.some((function(t){try{t.__h.forEach(Et),t.__h=t.__h.filter((function(t){return!t.__||Ct(t)}))}catch(n){e.some((function(t){t.__h&&(t.__h=[])})),e=[],ht.__e(n,t.__v)}})),gt&>(t,e)},ht.unmount=function(t){bt&&bt(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach((function(t){try{Et(t)}catch(t){e=t}})),n.__H=void 0,e&&ht.__e(e,n.__v))};var vt="function"==typeof requestAnimationFrame;function kt(t){var e,n=function(){clearTimeout(r),vt&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);vt&&(e=requestAnimationFrame(n))}function Et(t){var e=ot,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),ot=e}function Ct(t){var e=ot;t.__c=t.__(),ot=e}function It(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function St(t,e){return"function"==typeof e?e(t):e}class xt{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=y()}attach(t){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",t.appendChild(this.root),this.render()}presentItem(t){const e=this.nextItemKey++;return this.items.set(e,t),this.render(),()=>{this.items.delete(e),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&st(U("div",null,U(At,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([t,e])=>U(Mt,Object.assign({},e,{key:t}))))),this.root)}}const At=t=>U("div",{class:_("-cbwsdk-snackbar-container")},U("style",null,".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}"),U("div",{class:"-cbwsdk-snackbar"},t.children)),Mt=({autoExpand:t,message:e,menuItems:n})=>{const[r,s]=wt(!0),[i,o]=wt(null!=t&&t);!function(t,e){var n=mt(it++,3);!ht.__s&&It(n.__H,e)&&(n.__=t,n.i=e,ot.__H.__h.push(n))}(()=>{const t=[window.setTimeout(()=>{s(!1)},1),window.setTimeout(()=>{o(!0)},1e4)];return()=>{t.forEach(window.clearTimeout)}});return U("div",{class:_("-cbwsdk-snackbar-instance",r&&"-cbwsdk-snackbar-instance-hidden",i&&"-cbwsdk-snackbar-instance-expanded")},U("div",{class:"-cbwsdk-snackbar-instance-header",onClick:()=>{o(!i)}},U("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",U("div",{class:"-cbwsdk-snackbar-instance-header-message"},e),U("div",{class:"-gear-container"},!i&&U("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},U("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),U("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=",class:"-gear-icon",title:"Expand"}))),n&&n.length>0&&U("div",{class:"-cbwsdk-snackbar-instance-menu"},n.map((t,e)=>U("div",{class:_("-cbwsdk-snackbar-instance-menu-item",t.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:t.onClick,key:e},U("svg",{width:t.svgWidth,height:t.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},U("path",{"fill-rule":t.defaultFillRule,"clip-rule":t.defaultClipRule,d:t.path,fill:"#AAAAAA"})),U("span",{class:_("-cbwsdk-snackbar-instance-menu-item-info",t.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},t.info)))))};class Ot{constructor(){this.attached=!1,this.snackbar=new xt}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const t=document.documentElement,e=document.createElement("div");e.className="-cbwsdk-css-reset",t.appendChild(e),this.snackbar.attach(e),this.attached=!0,m()}showConnecting(t){let e;return e=t.isUnlinkedErrorState?{autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]}:{message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:t.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]},this.snackbar.presentItem(e)}}class Lt{constructor(){this.root=null,this.darkMode=y()}attach(){const t=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",t.appendChild(this.root),m()}present(t){this.render(t)}clear(){this.render(null)}render(t){this.root&&(st(null,this.root),t&&st(U(jt,Object.assign({},t,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const jt=({title:t,buttonText:e,darkMode:n,onButtonClick:r,onDismiss:s})=>{const i=n?"dark":"light";return U(At,{darkMode:n},U("div",{class:"-cbwsdk-redirect-dialog"},U("style",null,".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}"),U("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:s}),U("div",{class:_("-cbwsdk-redirect-dialog-box",i)},U("p",null,t),U("button",{onClick:r},e))))};var Pt=n(9);class Rt{constructor(){this.attached=!1,this.redirectDialog=new Lt}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(t){const e=new URL(Pt.a);e.searchParams.append("redirect_url",b().href),t&&e.searchParams.append("wl_url",t);const n=document.createElement("a");n.target="cbw-opener",n.href=e.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(t){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(t)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(t)},99)}showConnecting(t){return()=>{this.redirectDialog.clear()}}}var Tt=n(1),Dt=n(5);class Ut{constructor(t){var e;this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.userAgent),this.linkedUpdated=t=>{this.isLinked=t;const e=this.storage.getItem(s.b);if(t&&(this._session.linked=t),this.isUnlinkedErrorState=!1,e){const n=e.split(" "),r="true"===this.storage.getItem("IsStandaloneSigning");""===n[0]||t||!this._session.linked||r||(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(t,e)=>{this.storage.setItem(t,e)},this.chainUpdated=(t,e)=>{this.chainCallbackParams.chainId===t&&this.chainCallbackParams.jsonRpcUrl===e||(this.chainCallbackParams={chainId:t,jsonRpcUrl:e},this.chainCallback&&this.chainCallback(e,Number.parseInt(t,10)))},this.accountUpdated=t=>{this.accountsCallback&&this.accountsCallback([t]),Ut.accountRequestCallbackIds.size>0&&(Array.from(Ut.accountRequestCallbackIds.values()).forEach(e=>{this.invokeCallback(e,{method:"requestEthereumAccounts",result:[t]})}),Ut.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=t.linkAPIUrl,this.storage=t.storage,this.metadata=t.metadata,this.accountsCallback=t.accountsCallback,this.chainCallback=t.chainCallback;const{session:n,ui:r,connection:i}=this.subscribe();this._session=n,this.connection=i,this.relayEventManager=new h,this.ui=r,this.ui.attach()}subscribe(){const t=p.load(this.storage)||p.create(this.storage),{linkAPIUrl:e}=this,n=new l({session:t,linkAPIUrl:e,listener:this}),r=this.isMobileWeb?new Rt:new Ot;return n.connect(),{session:t,ui:r,connection:n}}resetAndReload(){this.connection.destroy().then(()=>{const t=p.load(this.storage);(null==t?void 0:t.id)===this._session.id&&Dt.a.clearAll(),document.location.reload()}).catch(t=>{})}signEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:Object(i.a)(t.weiValue),data:Object(i.i)(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?Object(i.a)(t.gasPriceInWei):null,maxFeePerGas:t.gasPriceInWei?Object(i.a)(t.gasPriceInWei):null,maxPriorityFeePerGas:t.gasPriceInWei?Object(i.a)(t.gasPriceInWei):null,gasLimit:t.gasLimit?Object(i.a)(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:Object(i.a)(t.weiValue),data:Object(i.i)(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?Object(i.a)(t.gasPriceInWei):null,maxFeePerGas:t.maxFeePerGas?Object(i.a)(t.maxFeePerGas):null,maxPriorityFeePerGas:t.maxPriorityFeePerGas?Object(i.a)(t.maxPriorityFeePerGas):null,gasLimit:t.gasLimit?Object(i.a)(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!0}})}submitEthereumTransaction(t,e){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:Object(i.i)(t,!0),chainId:e}})}getWalletLinkSession(){return this._session}sendRequest(t){let e=null;const n=Object(i.m)(8),r=r=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,t.method,r),null==e||e()};return new Promise((s,i)=>{e=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:r,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(n,t=>{if(null==e||e(),Object(g.a)(t))return i(new Error(t.errorMessage));s(t)}),this.publishWeb3RequestEvent(n,t)})}publishWeb3RequestEvent(t,e){const n={type:"WEB3_REQUEST",id:t,request:e};this.publishEvent("Web3Request",n,!0).then(t=>{}).catch(t=>{this.handleWeb3ResponseMessage(n.id,{method:e.method,errorMessage:t.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(e.method)}openCoinbaseWalletDeeplink(t){if(this.ui instanceof Rt)switch(t){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink()}}publishWeb3RequestCanceledEvent(t){const e={type:"WEB3_REQUEST_CANCELED",id:t};this.publishEvent("Web3RequestCanceled",e,!1).then()}publishEvent(t,e,n){return this.connection.publishEvent(t,e,n)}handleWeb3ResponseMessage(t,e){if("requestEthereumAccounts"===e.method)return Ut.accountRequestCallbackIds.forEach(t=>this.invokeCallback(t,e)),void Ut.accountRequestCallbackIds.clear();this.invokeCallback(t,e)}handleErrorResponse(t,e,n){var r;const s=null!==(r=null==n?void 0:n.message)&&void 0!==r?r:"Unspecified error message.";this.handleWeb3ResponseMessage(t,{method:e,errorMessage:s})}invokeCallback(t,e){const n=this.relayEventManager.callbacks.get(t);n&&(n(e),this.relayEventManager.callbacks.delete(t))}requestEthereumAccounts(){const{appName:t,appLogoUrl:e}=this.metadata,n={method:"requestEthereumAccounts",params:{appName:t,appLogoUrl:e}},r=Object(i.m)(8);return new Promise((t,e)=>{this.relayEventManager.callbacks.set(r,n=>{if(Object(g.a)(n))return e(new Error(n.errorMessage));t(n)}),Ut.accountRequestCallbackIds.add(r),this.publishWeb3RequestEvent(r,n)})}watchAsset(t,e,n,r,s,o){const a={method:"watchAsset",params:{type:t,options:{address:e,symbol:n,decimals:r,image:s},chainId:o}};let c=null;const u=Object(i.m)(8),l=t=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,a.method,t),null==c||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:l,onResetConnection:this.resetAndReload}),new Promise((t,e)=>{this.relayEventManager.callbacks.set(u,n=>{if(null==c||c(),Object(g.a)(n))return e(new Error(n.errorMessage));t(n)}),this.publishWeb3RequestEvent(u,a)})}addEthereumChain(t,e,n,r,s,o){const a={method:"addEthereumChain",params:{chainId:t,rpcUrls:e,blockExplorerUrls:r,chainName:s,iconUrls:n,nativeCurrency:o}};let c=null;const u=Object(i.m)(8),l=t=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,a.method,t),null==c||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:l,onResetConnection:this.resetAndReload}),new Promise((t,e)=>{this.relayEventManager.callbacks.set(u,n=>{if(null==c||c(),Object(g.a)(n))return e(new Error(n.errorMessage));t(n)}),this.publishWeb3RequestEvent(u,a)})}switchEthereumChain(t,e){const n={method:"switchEthereumChain",params:Object.assign({chainId:t},{address:e})};let r=null;const s=Object(i.m)(8),o=t=>{this.publishWeb3RequestCanceledEvent(s),this.handleErrorResponse(s,n.method,t),null==r||r()};return r=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:o,onResetConnection:this.resetAndReload}),new Promise((t,e)=>{this.relayEventManager.callbacks.set(s,n=>(null==r||r(),Object(g.a)(n)&&n.errorCode?e(Tt.a.provider.custom({code:n.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."})):Object(g.a)(n)?e(new Error(n.errorMessage)):void t(n))),this.publishWeb3RequestEvent(s,n)})}}Ut.accountRequestCallbackIds=new Set},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";e.byteLength=function(t){var e=u(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,r=u(t),o=r[0],a=r[1],c=new i(function(t,e,n){return 3*(e+n)/4-n}(0,o,a)),l=0,h=a>0?o-4:o;for(n=0;n>16&255,c[l++]=e>>8&255,c[l++]=255&e;2===a&&(e=s[t.charCodeAt(n)]<<2|s[t.charCodeAt(n+1)]>>4,c[l++]=255&e);1===a&&(e=s[t.charCodeAt(n)]<<10|s[t.charCodeAt(n+1)]<<4|s[t.charCodeAt(n+2)]>>2,c[l++]=e>>8&255,c[l++]=255&e);return c},e.fromByteArray=function(t){for(var e,n=t.length,s=n%3,i=[],o=0,a=n-s;oa?a:o+16383));1===s?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===s&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return i.join("")};for(var r=[],s=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function l(t,e,n){for(var s,i,o=[],a=e;a>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return o.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},function(t,e){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ e.read=function(t,e,n,r,s){var i,o,a=8*s-r-1,c=(1<>1,l=-7,h=n?s-1:0,d=n?-1:1,f=t[e+h];for(h+=d,i=f&(1<<-l)-1,f>>=-l,l+=a;l>0;i=256*i+t[e+h],h+=d,l-=8);for(o=i&(1<<-l)-1,i>>=-l,l+=r;l>0;o=256*o+t[e+h],h+=d,l-=8);if(0===i)i=1-u;else{if(i===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),i-=u}return(f?-1:1)*o*Math.pow(2,i-r)},e.write=function(t,e,n,r,s,i){var o,a,c,u=8*i-s-1,l=(1<>1,d=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,p=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=o+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(o++,c/=2),o+h>=l?(a=0,o=l):o+h>=1?(a=(e*c-1)*Math.pow(2,s),o+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,s),o=0));s>=8;t[n+f]=255&a,f+=p,a/=256,s-=8);for(o=o<0;t[n+f]=255&o,f+=p,o/=256,u-=8);t[n+f-p]|=128*g}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.shake256=e.shake128=e.keccak_512=e.keccak_384=e.keccak_256=e.keccak_224=e.sha3_512=e.sha3_384=e.sha3_256=e.sha3_224=e.Keccak=void 0,e.keccakP=w;const r=n(14),s=n(25),i=n(11),o=[],a=[],c=[],u=BigInt(0),l=BigInt(1),h=BigInt(2),d=BigInt(7),f=BigInt(256),p=BigInt(113);for(let t=0,e=l,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],o.push(2*(5*r+n)),a.push((t+1)*(t+2)/2%64);let s=u;for(let t=0;t<7;t++)e=(e<>d)*p)%f,e&h&&(s^=l<<(l<n>32?(0,s.rotlBH)(t,e,n):(0,s.rotlSH)(t,e,n),m=(t,e,n)=>n>32?(0,s.rotlBL)(t,e,n):(0,s.rotlSL)(t,e,n);function w(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const r=(e+8)%10,s=(e+2)%10,i=n[s],o=n[s+1],a=y(i,o,1)^n[r],c=m(i,o,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=a,t[e+n+1]^=c}let e=t[2],s=t[3];for(let n=0;n<24;n++){const r=a[n],i=y(e,s,r),c=m(e,s,r),u=o[n];e=t[u],s=t[u+1],t[u]=i,t[u+1]=c}for(let e=0;e<50;e+=10){for(let r=0;r<10;r++)n[r]=t[e+r];for(let r=0;r<10;r++)t[e+r]^=~n[(r+2)%10]&n[(r+4)%10]}t[0]^=g[r],t[1]^=b[r]}n.fill(0)}class _ extends i.Hash{constructor(t,e,n,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,r.number)(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,i.u32)(this.state)}keccak(){i.isLE||(0,i.byteSwap32)(this.state32),w(this.state32,this.rounds),i.isLE||(0,i.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(t){(0,r.exists)(this);const{blockLen:e,state:n}=this,s=(t=(0,i.toBytes)(t)).length;for(let r=0;r=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);t.set(e.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return(0,r.number)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,r.output)(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return t||(t=new _(e,n,r,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=r,t.enableXOF=i,t.destroyed=this.destroyed,t}}e.Keccak=_;const v=(t,e,n)=>(0,i.wrapConstructor)(()=>new _(e,t,n));e.sha3_224=v(6,144,28),e.sha3_256=v(6,136,32),e.sha3_384=v(6,104,48),e.sha3_512=v(6,72,64),e.keccak_224=v(1,144,28),e.keccak_256=v(1,136,32),e.keccak_384=v(1,104,48),e.keccak_512=v(1,72,64);const k=(t,e,n)=>(0,i.wrapXOFConstructorWithOpts)((r={})=>new _(e,t,void 0===r.dkLen?n:r.dkLen,!0));e.shake128=k(31,168,16),e.shake256=k(31,136,32)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=void 0,e.fromBig=i,e.split=o,e.add=_;const r=BigInt(2**32-1),s=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>s&r)}:{h:0|Number(t>>s&r),l:0|Number(t&r)}}function o(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;sBigInt(t>>>0)<>>0);e.toBig=a;const c=(t,e,n)=>t>>>n;e.shrSH=c;const u=(t,e,n)=>t<<32-n|e>>>n;e.shrSL=u;const l=(t,e,n)=>t>>>n|e<<32-n;e.rotrSH=l;const h=(t,e,n)=>t<<32-n|e>>>n;e.rotrSL=h;const d=(t,e,n)=>t<<64-n|e>>>n-32;e.rotrBH=d;const f=(t,e,n)=>t>>>n-32|e<<64-n;e.rotrBL=f;const p=(t,e)=>e;e.rotr32H=p;const g=(t,e)=>t;e.rotr32L=g;const b=(t,e,n)=>t<>>32-n;e.rotlSH=b;const y=(t,e,n)=>e<>>32-n;e.rotlSL=y;const m=(t,e,n)=>e<>>64-n;e.rotlBH=m;const w=(t,e,n)=>t<>>64-n;function _(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:0|s}}e.rotlBL=w;const v=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0);e.add3L=v;const k=(t,e,n,r)=>e+n+r+(t/2**32|0)|0;e.add3H=k;const E=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0);e.add4L=E;const C=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0;e.add4H=C;const I=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0);e.add5L=I;const S=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0;e.add5H=S;const x={fromBig:i,split:o,toBig:a,shrSH:c,shrSL:u,rotrSH:l,rotrSL:h,rotrBH:d,rotrBL:f,rotr32H:p,rotr32L:g,rotlSH:b,rotlSL:y,rotlBH:m,rotlBL:w,add:_,add3L:v,add3H:k,add4L:E,add4H:C,add5H:S,add5L:I};e.default=x},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},function(t,e,n){(function(e){const r=n(16);function s(t){return t.startsWith("int[")?"int256"+t.slice(3):"int"===t?"int256":t.startsWith("uint[")?"uint256"+t.slice(4):"uint"===t?"uint256":t.startsWith("fixed[")?"fixed128x128"+t.slice(5):"fixed"===t?"fixed128x128":t.startsWith("ufixed[")?"ufixed128x128"+t.slice(6):"ufixed"===t?"ufixed128x128":t}function i(t){return Number.parseInt(/^\D+(\d+)$/.exec(t)[1],10)}function o(t){var e=/^\D+(\d+)x(\d+)$/.exec(t);return[Number.parseInt(e[1],10),Number.parseInt(e[2],10)]}function a(t){var e=t.match(/(.*)\[(.*?)\]$/);return e?""===e[2]?"dynamic":Number.parseInt(e[2],10):null}function c(t){var e=typeof t;if("string"===e||"number"===e)return BigInt(t);if("bigint"===e)return t;throw new Error("Argument is not a number")}function u(t,n){var s,l,h,d;if("address"===t)return u("uint160",c(n));if("bool"===t)return u("uint8",n?1:0);if("string"===t)return u("bytes",new e(n,"utf8"));if(function(t){return t.lastIndexOf("]")===t.length-1}(t)){if(void 0===n.length)throw new Error("Not an array?");if("dynamic"!==(s=a(t))&&0!==s&&n.length>s)throw new Error("Elements exceed array size: "+s);for(d in h=[],t=t.slice(0,t.lastIndexOf("[")),"string"==typeof n&&(n=JSON.parse(n)),n)h.push(u(t,n[d]));if("dynamic"===s){var f=u("uint256",n.length);h.unshift(f)}return e.concat(h)}if("bytes"===t)return n=new e(n),h=e.concat([u("uint256",n.length),n]),n.length%32!=0&&(h=e.concat([h,r.zeros(32-n.length%32)])),h;if(t.startsWith("bytes")){if((s=i(t))<1||s>32)throw new Error("Invalid bytes width: "+s);return r.setLengthRight(n,32)}if(t.startsWith("uint")){if((s=i(t))%8||s<8||s>256)throw new Error("Invalid uint width: "+s);l=c(n);const e=r.bitLengthFromBigInt(l);if(e>s)throw new Error("Supplied uint exceeds width: "+s+" vs "+e);if(l<0)throw new Error("Supplied uint is negative");return r.bufferBEFromBigInt(l,32)}if(t.startsWith("int")){if((s=i(t))%8||s<8||s>256)throw new Error("Invalid int width: "+s);l=c(n);const e=r.bitLengthFromBigInt(l);if(e>s)throw new Error("Supplied int exceeds width: "+s+" vs "+e);const o=r.twosFromBigInt(l,256);return r.bufferBEFromBigInt(o,32)}if(t.startsWith("ufixed")){if(s=o(t),(l=c(n))<0)throw new Error("Supplied ufixed is negative");return u("uint256",l*BigInt(2)**BigInt(s[1]))}if(t.startsWith("fixed"))return s=o(t),u("int256",c(n)*BigInt(2)**BigInt(s[1]));throw new Error("Unsupported or invalid type: "+t)}function l(t){return"string"===t||"bytes"===t||"dynamic"===a(t)}function h(t,n){if(t.length!==n.length)throw new Error("Number of types are not matching the values");for(var o,a,u=[],l=0;l32)throw new Error("Invalid bytes width: "+o);u.push(r.setLengthRight(d,o))}else if(h.startsWith("uint")){if((o=i(h))%8||o<8||o>256)throw new Error("Invalid uint width: "+o);a=c(d);const t=r.bitLengthFromBigInt(a);if(t>o)throw new Error("Supplied uint exceeds width: "+o+" vs "+t);u.push(r.bufferBEFromBigInt(a,o/8))}else{if(!h.startsWith("int"))throw new Error("Unsupported or invalid type: "+h);{if((o=i(h))%8||o<8||o>256)throw new Error("Invalid int width: "+o);a=c(d);const t=r.bitLengthFromBigInt(a);if(t>o)throw new Error("Supplied int exceeds width: "+o+" vs "+t);const e=r.twosFromBigInt(a,o);u.push(r.bufferBEFromBigInt(e,o/8))}}}return e.concat(u)}t.exports={rawEncode:function(t,n){var r=[],i=[],o=32*t.length;for(var a in t){var c=s(t[a]),h=u(c,n[a]);l(c)?(r.push(u("uint256",o)),i.push(h),o+=h.length):r.push(h)}return e.concat(r.concat(i))},solidityPack:h,soliditySHA3:function(t,e){return r.keccak(h(t,e))}}}).call(this,n(10).Buffer)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const r=n(14),s=n(11);e.Chi=(t,e,n)=>t&e^~t&n;e.Maj=(t,e,n)=>t&e^t&n^e&n;class i extends s.Hash{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,s.createView)(this.buffer)}update(t){(0,r.exists)(this);const{view:e,buffer:n,blockLen:i}=this,o=(t=(0,s.toBytes)(t)).length;for(let r=0;ri-a&&(this.process(n,0),a=0);for(let t=a;t>s&i),a=Number(n&i),c=r?4:0,u=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+u,a,r)}(n,i-8,BigInt(8*this.length),o),this.process(n,0);const c=(0,s.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t{if(!(e instanceof Error))return e;const n=e;return Object.assign(Object.assign({},n.code?{code:n.code}:{}),{message:n.message})}))}async function u(t,e){return JSON.parse(await async function(t,{iv:e,cipherText:n}){const r=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},t,n);return(new TextDecoder).decode(r)}(e,t))}const l={storageKey:"ownPrivateKey",keyType:"private"},h={storageKey:"ownPublicKey",keyType:"public"},d={storageKey:"peerPublicKey",keyType:"public"};class f{constructor(){this.storage=new r.a("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(t){this.sharedSecret=null,this.peerPublicKey=t,await this.storeKey(d,t),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(h.storageKey),this.storage.removeItem(l.storageKey),this.storage.removeItem(d.storageKey)}async generateKeyPair(){const t=await async function(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}();this.ownPrivateKey=t.privateKey,this.ownPublicKey=t.publicKey,await this.storeKey(l,t.privateKey),await this.storeKey(h,t.publicKey)}async loadKeysIfNeeded(){if(null===this.ownPrivateKey&&(this.ownPrivateKey=await this.loadKey(l)),null===this.ownPublicKey&&(this.ownPublicKey=await this.loadKey(h)),null!==this.ownPrivateKey&&null!==this.ownPublicKey||await this.generateKeyPair(),null===this.peerPublicKey&&(this.peerPublicKey=await this.loadKey(d)),null===this.sharedSecret){if(null===this.ownPrivateKey||null===this.peerPublicKey)return;this.sharedSecret=await async function(t,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(t){const e=this.storage.getItem(t.storageKey);return e?a(t.keyType,e):null}async storeKey(t,e){const n=await o(t.keyType,e);this.storage.setItem(t.storageKey,n)}}var p=n(1),g=n(7);class b{constructor(t){var e,n,s;this.metadata=t.metadata,this.communicator=t.communicator,this.callback=t.callback,this.keyManager=new f,this.storage=new r.a("CBWSDK","SCWStateManager"),this.accounts=null!==(e=this.storage.loadObject("accounts"))&&void 0!==e?e:[],this.chain=this.storage.loadObject("activeChain")||{id:null!==(s=null===(n=t.metadata.appChainIds)||void 0===n?void 0:n[0])&&void 0!==s?s:1},this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(t){var e,n;const r=await this.createRequestMessage({handshake:{method:t.method,params:Object.assign({},this.metadata,null!==(e=t.params)&&void 0!==e?e:{})}}),s=await this.communicator.postRequestAndWaitForResponse(r);if("failure"in s.content)throw s.content.failure;const i=await a("public",s.sender);await this.keyManager.setPeerPublicKey(i);const o=(await this.decryptResponseMessage(s)).result;if("error"in o)throw o.error;const c=o.value;this.accounts=c,this.storage.storeObject("accounts",c),null===(n=this.callback)||void 0===n||n.call(this,"accountsChanged",c)}async request(t){var e;if(0===this.accounts.length)throw p.a.provider.unauthorized();switch(t.method){case"eth_requestAccounts":return null===(e=this.callback)||void 0===e||e.call(this,"connect",{chainId:Object(s.j)(this.chain.id)}),this.accounts;case"eth_accounts":return this.accounts;case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return Object(s.j)(this.chain.id);case"wallet_getCapabilities":return this.storage.loadObject("walletCapabilities");case"wallet_switchEthereumChain":return this.handleSwitchChainRequest(t);case"eth_ecRecover":case"personal_sign":case"personal_ecRecover":case"eth_signTransaction":case"eth_sendTransaction":case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":case"wallet_addEthereumChain":case"wallet_watchAsset":case"wallet_sendCalls":case"wallet_showCallsStatus":case"wallet_grantPermissions":return this.sendRequestToPopup(t);default:if(!this.chain.rpcUrl)throw p.a.rpc.internal("No RPC URL set for chain");return Object(g.b)(t,this.chain.rpcUrl)}}async sendRequestToPopup(t){var e,n;await(null===(n=(e=this.communicator).waitForPopupLoaded)||void 0===n?void 0:n.call(e));const r=await this.sendEncryptedRequest(t),s=(await this.decryptResponseMessage(r)).result;if("error"in s)throw s.error;return s.value}async cleanup(){var t,e;this.storage.clear(),await this.keyManager.clear(),this.accounts=[],this.chain={id:null!==(e=null===(t=this.metadata.appChainIds)||void 0===t?void 0:t[0])&&void 0!==e?e:1}}async handleSwitchChainRequest(t){var e;const n=t.params;if(!n||!(null===(e=n[0])||void 0===e?void 0:e.chainId))throw p.a.rpc.invalidParams();const r=Object(s.f)(n[0].chainId);if(this.updateChain(r))return null;const i=await this.sendRequestToPopup(t);return null===i&&this.updateChain(r),i}async sendEncryptedRequest(t){const e=await this.keyManager.getSharedSecret();if(!e)throw p.a.provider.unauthorized("No valid session found, try requestAccounts before other methods");const n=await c({action:t,chainId:this.chain.id},e),r=await this.createRequestMessage({encrypted:n});return this.communicator.postRequestAndWaitForResponse(r)}async createRequestMessage(t){const e=await o("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:e,content:t,timestamp:new Date}}async decryptResponseMessage(t){var e,n;const r=t.content;if("failure"in r)throw r.failure;const s=await this.keyManager.getSharedSecret();if(!s)throw p.a.provider.unauthorized("Invalid session");const i=await u(r.encrypted,s),o=null===(e=i.data)||void 0===e?void 0:e.chains;if(o){const t=Object.entries(o).map(([t,e])=>({id:Number(t),rpcUrl:e}));this.storage.storeObject("availableChains",t),this.updateChain(this.chain.id,t)}const a=null===(n=i.data)||void 0===n?void 0:n.capabilities;return a&&this.storage.storeObject("walletCapabilities",a),i}updateChain(t,e){var n;const r=null!=e?e:this.storage.loadObject("availableChains"),i=null==r?void 0:r.find(e=>e.id===t);return!!i&&(i!==this.chain&&(this.chain=i,this.storage.storeObject("activeChain",i),null===(n=this.callback)||void 0===n||n.call(this,"chainChanged",Object(s.j)(i.id))),!0)}}var y=n(15);const m=new r.a("CBWSDK","SignerConfigurator");async function w(t){const{communicator:e,metadata:n,handshakeRequest:r,callback:s}=t;(async function(t,e,n){await t.onMessage(({event:t})=>"WalletLinkSessionRequest"===t);const r=new y.a({metadata:e,callback:n});t.postMessage({event:"WalletLinkUpdate",data:{session:r.getSession()}}),await r.handshake(),t.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})})(e,n,s).catch(()=>{});const i={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},t.preference),{handshakeRequest:r})},{data:o}=await e.postRequestAndWaitForResponse(i);return o}var _=n(6),v=n(9);const{checkCrossOriginOpenerPolicy:k,getCrossOriginOpenerPolicy:E}=(()=>{let t;return{getCrossOriginOpenerPolicy:()=>void 0===t?"undefined":t,checkCrossOriginOpenerPolicy:async()=>{if("undefined"!=typeof window)try{const e=`${window.location.origin}${window.location.pathname}`,n=await fetch(e,{method:"HEAD"});if(!n.ok)throw new Error("HTTP error! status: "+n.status);const r=n.headers.get("Cross-Origin-Opener-Policy");t=null!=r?r:"null","same-origin"===t&&console.error("Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.\n\nPlease see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.")}catch(e){console.error("Error checking Cross-Origin-Opener-Policy:",e.message),t="error"}else t="non-browser-env"}}})();function C(t){const e=(window.innerWidth-420)/2+window.screenX,n=(window.innerHeight-540)/2+window.screenY;!function(t){const e={sdkName:_.a,sdkVersion:_.b,origin:window.location.origin,coop:E()};for(const[n,r]of Object.entries(e))t.searchParams.append(n,r.toString())}(t);const r=window.open(t,"Smart Wallet",`width=420, height=540, left=${e}, top=${n}`);if(null==r||r.focus(),!r)throw p.a.rpc.internal("Pop up window failed to open");return r}class I{constructor({url:t=v.b,metadata:e,preference:n}){this.popup=null,this.listeners=new Map,this.postMessage=async t=>{(await this.waitForPopupLoaded()).postMessage(t,this.url.origin)},this.postRequestAndWaitForResponse=async t=>{const e=this.onMessage(({requestId:e})=>e===t.id);return this.postMessage(t),await e},this.onMessage=async t=>new Promise((e,n)=>{const r=n=>{if(n.origin!==this.url.origin)return;const s=n.data;t(s)&&(e(s),window.removeEventListener("message",r),this.listeners.delete(r))};window.addEventListener("message",r),this.listeners.set(r,{reject:n})}),this.disconnect=()=>{var t;(t=this.popup)&&!t.closed&&t.close(),this.popup=null,this.listeners.forEach(({reject:t},e)=>{t(p.a.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",e)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=C(this.url),this.onMessage(({event:t})=>"PopupUnload"===t).then(this.disconnect).catch(()=>{}),this.onMessage(({event:t})=>"PopupLoaded"===t).then(t=>{this.postMessage({requestId:t.id,data:{version:_.b,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw p.a.rpc.internal();return this.popup})),this.url=new URL(t),this.metadata=e,this.preference=n}}var S=n(2),x=n(3),A=n(12);function M(t){const e=Object(A.b)(function(t){var e;if("string"==typeof t)return{message:t,code:S.b.rpc.internal};if(Object(x.a)(t)){const n=t.errorMessage,r=null!==(e=t.errorCode)&&void 0!==e?e:n.match(/(denied|rejected)/i)?S.b.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},t),{message:n,code:r,data:{method:t.method}})}return t}(t),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return n.searchParams.set("version",_.b),n.searchParams.set("code",e.code.toString()),n.searchParams.set("message",e.message),Object.assign(Object.assign({},e),{docUrl:n.href})}var O=n(17);class L extends O.EventEmitter{}var j=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s{let n;switch(t){case"standard":return n=e,`data:image/svg+xml,%3Csvg width='${e}' height='${n}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return n=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${n}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return n=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return n=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return n=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return n=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return n=e,`data:image/svg+xml,%3Csvg width='${e}' height='${n}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}})(t,e)}storeLatestVersion(){new r.a("CBWSDK").setItem("VERSION",_.b)}}}]);void 0===CoinbaseWalletSdk&&console.error("esm-webpack-plugin: nothing exported!");const _CoinbaseWalletSdk$CoinbaseWalletSDK=CoinbaseWalletSdk.CoinbaseWalletSDK;export{_CoinbaseWalletSdk$CoinbaseWalletSDK as CoinbaseWalletSDK};