@privy-io/react-auth 1.20.0 → 1.20.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Cl=Object.create;var go=Object.defineProperty;var El=Object.getOwnPropertyDescriptor;var xl=Object.getOwnPropertyNames;var _l=Object.getPrototypeOf,Ll=Object.prototype.hasOwnProperty;var Rn=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ie=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),In=(e,t)=>{for(var o in t)go(e,o,{get:t[o],enumerable:!0})},Mn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of xl(t))!Ll.call(e,n)&&n!==o&&go(e,n,{get:()=>t[n],enumerable:!(r=El(t,n))||r.enumerable});return e};var Sl=(e,t,o)=>(o=e!=null?Cl(_l(e)):{},Mn(t||!e||!e.__esModule?go(o,"default",{value:e,enumerable:!0}):o,e)),On=e=>Mn(go({},"__esModule",{value:!0}),e);var To=Ie((Fu,Ao)=>{var gi,bi,yi,vi,wi,Ci,Ei,xi,_i,Po,kr,Li,Si,Pi,Et,ki,Ai,Ti,Wi,Ri,Ii,Mi,Oi,Ni,ko;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(o(t,o(r)))}):typeof Ao=="object"&&typeof Ao.exports=="object"?e(o(t,o(Ao.exports))):e(o(t));function o(r,n){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(i,a){return r[i]=n?n(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])};gi=function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function i(){this.constructor=r}r.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)},bi=Object.assign||function(r){for(var n,i=1,a=arguments.length;i<a;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},yi=function(r,n){var i={};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&n.indexOf(a)<0&&(i[a]=r[a]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(r);s<a.length;s++)n.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(r,a[s])&&(i[a[s]]=r[a[s]]);return i},vi=function(r,n,i,a){var s=arguments.length,l=s<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,i):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,n,i,a);else for(var h=r.length-1;h>=0;h--)(d=r[h])&&(l=(s<3?d(l):s>3?d(n,i,l):d(n,i))||l);return s>3&&l&&Object.defineProperty(n,i,l),l},wi=function(r,n){return function(i,a){n(i,a,r)}},Ci=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Ei=function(r,n,i,a){function s(l){return l instanceof i?l:new i(function(d){d(l)})}return new(i||(i=Promise))(function(l,d){function h(g){try{p(a.next(g))}catch(b){d(b)}}function m(g){try{p(a.throw(g))}catch(b){d(b)}}function p(g){g.done?l(g.value):s(g.value).then(h,m)}p((a=a.apply(r,n||[])).next())})},xi=function(r,n){var i={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,s,l,d;return d={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function h(p){return function(g){return m([p,g])}}function m(p){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(l=p[0]&2?s.return:p[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,p[1])).done)return l;switch(s=0,l&&(p=[p[0]&2,l.value]),p[0]){case 0:case 1:l=p;break;case 4:return i.label++,{value:p[1],done:!1};case 5:i.label++,s=p[1],p=[0];continue;case 7:p=i.ops.pop(),i.trys.pop();continue;default:if(l=i.trys,!(l=l.length>0&&l[l.length-1])&&(p[0]===6||p[0]===2)){i=0;continue}if(p[0]===3&&(!l||p[1]>l[0]&&p[1]<l[3])){i.label=p[1];break}if(p[0]===6&&i.label<l[1]){i.label=l[1],l=p;break}if(l&&i.label<l[2]){i.label=l[2],i.ops.push(p);break}l[2]&&i.ops.pop(),i.trys.pop();continue}p=n.call(r,i)}catch(g){p=[6,g],s=0}finally{a=l=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},_i=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&ko(n,r,i)},ko=Object.create?function(r,n,i,a){a===void 0&&(a=i);var s=Object.getOwnPropertyDescriptor(n,i);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(r,a,s)}:function(r,n,i,a){a===void 0&&(a=i),r[a]=n[i]},Po=function(r){var n=typeof Symbol=="function"&&Symbol.iterator,i=n&&r[n],a=0;if(i)return i.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&a>=r.length&&(r=void 0),{value:r&&r[a++],done:!r}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},kr=function(r,n){var i=typeof Symbol=="function"&&r[Symbol.iterator];if(!i)return r;var a=i.call(r),s,l=[],d;try{for(;(n===void 0||n-- >0)&&!(s=a.next()).done;)l.push(s.value)}catch(h){d={error:h}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(d)throw d.error}}return l},Li=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(kr(arguments[n]));return r},Si=function(){for(var r=0,n=0,i=arguments.length;n<i;n++)r+=arguments[n].length;for(var a=Array(r),s=0,n=0;n<i;n++)for(var l=arguments[n],d=0,h=l.length;d<h;d++,s++)a[s]=l[d];return a},Pi=function(r,n,i){if(i||arguments.length===2)for(var a=0,s=n.length,l;a<s;a++)(l||!(a in n))&&(l||(l=Array.prototype.slice.call(n,0,a)),l[a]=n[a]);return r.concat(l||Array.prototype.slice.call(n))},Et=function(r){return this instanceof Et?(this.v=r,this):new Et(r)},ki=function(r,n,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=i.apply(r,n||[]),s,l=[];return s={},d("next"),d("throw"),d("return"),s[Symbol.asyncIterator]=function(){return this},s;function d(c){a[c]&&(s[c]=function(y){return new Promise(function(v,W){l.push([c,y,v,W])>1||h(c,y)})})}function h(c,y){try{m(a[c](y))}catch(v){b(l[0][3],v)}}function m(c){c.value instanceof Et?Promise.resolve(c.value.v).then(p,g):b(l[0][2],c)}function p(c){h("next",c)}function g(c){h("throw",c)}function b(c,y){c(y),l.shift(),l.length&&h(l[0][0],l[0][1])}},Ai=function(r){var n,i;return n={},a("next"),a("throw",function(s){throw s}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(s,l){n[s]=r[s]?function(d){return(i=!i)?{value:Et(r[s](d)),done:s==="return"}:l?l(d):d}:l}},Ti=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r[Symbol.asyncIterator],i;return n?n.call(r):(r=typeof Po=="function"?Po(r):r[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(l){i[l]=r[l]&&function(d){return new Promise(function(h,m){d=r[l](d),s(h,m,d.done,d.value)})}}function s(l,d,h,m){Promise.resolve(m).then(function(p){l({value:p,done:h})},d)}},Wi=function(r,n){return Object.defineProperty?Object.defineProperty(r,"raw",{value:n}):r.raw=n,r};var o=Object.create?function(r,n){Object.defineProperty(r,"default",{enumerable:!0,value:n})}:function(r,n){r.default=n};Ri=function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)i!=="default"&&Object.prototype.hasOwnProperty.call(r,i)&&ko(n,r,i);return o(n,r),n},Ii=function(r){return r&&r.__esModule?r:{default:r}},Mi=function(r,n,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!a:!n.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(r):a?a.value:n.get(r)},Oi=function(r,n,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?r!==n||!s:!n.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(r,i):s?s.value=i:n.set(r,i),i},Ni=function(r,n){if(n===null||typeof n!="object"&&typeof n!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?n===r:r.has(n)},e("__extends",gi),e("__assign",bi),e("__rest",yi),e("__decorate",vi),e("__param",wi),e("__metadata",Ci),e("__awaiter",Ei),e("__generator",xi),e("__exportStar",_i),e("__createBinding",ko),e("__values",Po),e("__read",kr),e("__spread",Li),e("__spreadArrays",Si),e("__spreadArray",Pi),e("__await",Et),e("__asyncGenerator",ki),e("__asyncDelegator",Ai),e("__asyncValues",Ti),e("__makeTemplateObject",Wi),e("__importStar",Ri),e("__importDefault",Ii),e("__classPrivateFieldGet",Mi),e("__classPrivateFieldSet",Oi),e("__classPrivateFieldIn",Ni)})});var Ar=Ie(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.getLocalStorage=O.getLocalStorageOrThrow=O.getCrypto=O.getCryptoOrThrow=O.getLocation=O.getLocationOrThrow=O.getNavigator=O.getNavigatorOrThrow=O.getDocument=O.getDocumentOrThrow=O.getFromWindowOrThrow=O.getFromWindow=void 0;function ot(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}O.getFromWindow=ot;function xt(e){let t=ot(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}O.getFromWindowOrThrow=xt;function Xl(){return xt("document")}O.getDocumentOrThrow=Xl;function Ql(){return ot("document")}O.getDocument=Ql;function ec(){return xt("navigator")}O.getNavigatorOrThrow=ec;function tc(){return ot("navigator")}O.getNavigator=tc;function oc(){return xt("location")}O.getLocationOrThrow=oc;function rc(){return ot("location")}O.getLocation=rc;function nc(){return xt("crypto")}O.getCryptoOrThrow=nc;function ic(){return ot("crypto")}O.getCrypto=ic;function ac(){return xt("localStorage")}O.getLocalStorageOrThrow=ac;function sc(){return ot("localStorage")}O.getLocalStorage=sc});var Ui=Ie(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.getWindowMetadata=void 0;var Di=Ar();function lc(){let e,t;try{e=Di.getDocumentOrThrow(),t=Di.getLocationOrThrow()}catch{return null}function o(){let m=e.getElementsByTagName("link"),p=[];for(let g=0;g<m.length;g++){let b=m[g],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let v=t.protocol+"//"+t.host;if(y.indexOf("/")===0)v+=y;else{let W=t.pathname.split("/");W.pop(),v+=W.join("/")+"/"+y}p.push(v)}else if(y.indexOf("//")===0){let v=t.protocol+y;p.push(v)}else p.push(y)}}return p}function r(...m){let p=e.getElementsByTagName("meta");for(let g=0;g<p.length;g++){let b=p[g],c=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?m.includes(y):!1);if(c.length&&c){let y=b.getAttribute("content");if(y)return y}}return""}function n(){let m=r("name","og:site_name","og:title","twitter:title");return m||(m=e.title),m}function i(){return r("description","og:description","twitter:description","keywords")}let a=n(),s=i(),l=t.origin,d=o();return{description:s,url:l,icons:d,name:a}}Wo.getWindowMetadata=lc});var Ki={};In(Ki,{BotInfo:()=>ji,BrowserInfo:()=>Gi,NodeInfo:()=>Hi,ReactNativeInfo:()=>$i,SearchBotDeviceInfo:()=>Vi,browserName:()=>mc,detect:()=>fc,detectOS:()=>qi,getNodeVersion:()=>Zi,parseUserAgent:()=>Tr});function fc(e){return e?Tr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new $i:typeof navigator<"u"?Tr(navigator.userAgent):Zi()}function zi(e){return e!==""&&uc.reduce(function(t,o){var r=o[0],n=o[1];if(t)return t;var i=n.exec(e);return!!i&&[r,i]},!1)}function mc(e){var t=zi(e);return t?t[0]:null}function Tr(e){var t=zi(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new ji;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<Bi&&(n=cc(n,hc(Bi-n.length))):n=[];var i=n.join("."),a=qi(e),s=pc.exec(e);return s&&s[1]?new Vi(o,i,a,s[1]):new Gi(o,i,a)}function qi(e){for(var t=0,o=Fi.length;t<o;t++){var r=Fi[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function Zi(){var e=typeof process<"u"&&process.version;return e?new Hi(process.version.slice(1)):null}function hc(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var cc,Gi,Hi,Vi,ji,$i,dc,pc,Bi,uc,Fi,Ji=Rn(()=>{cc=function(){for(var e=0,t=0,o=arguments.length;t<o;t++)e+=arguments[t].length;for(var r=Array(e),n=0,t=0;t<o;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,n++)r[n]=i[a];return r},Gi=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),Hi=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),Vi=function(){function e(t,o,r,n){this.name=t,this.version=o,this.os=r,this.bot=n,this.type="bot-device"}return e}(),ji=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),$i=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),dc=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,pc=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Bi=3,uc=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",dc]],Fi=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]]});var Rr=Ie(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.getClientMeta=x.getLocalStorage=x.getLocalStorageOrThrow=x.getCrypto=x.getCryptoOrThrow=x.getLocation=x.getLocationOrThrow=x.getNavigator=x.getNavigatorOrThrow=x.getDocument=x.getDocumentOrThrow=x.getFromWindowOrThrow=x.getFromWindow=x.isBrowser=x.isNode=x.isMobile=x.isIOS=x.isAndroid=x.detectOS=x.detectEnv=void 0;var Yi=To(),gc=Yi.__importStar(Ui()),Ce=Yi.__importStar(Ar()),bc=(Ji(),On(Ki));function Wr(e){return(0,bc.detect)(e)}x.detectEnv=Wr;function Ro(){let e=Wr();return e&&e.os?e.os:void 0}x.detectOS=Ro;function Xi(){let e=Ro();return e?e.toLowerCase().includes("android"):!1}x.isAndroid=Xi;function Qi(){let e=Ro();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}x.isIOS=Qi;function yc(){return Ro()?Xi()||Qi():!1}x.isMobile=yc;function ea(){let e=Wr();return e&&e.name?e.name.toLowerCase()==="node":!1}x.isNode=ea;function vc(){return!ea()&&!!(0,x.getNavigator)()}x.isBrowser=vc;x.getFromWindow=Ce.getFromWindow;x.getFromWindowOrThrow=Ce.getFromWindowOrThrow;x.getDocumentOrThrow=Ce.getDocumentOrThrow;x.getDocument=Ce.getDocument;x.getNavigatorOrThrow=Ce.getNavigatorOrThrow;x.getNavigator=Ce.getNavigator;x.getLocationOrThrow=Ce.getLocationOrThrow;x.getLocation=Ce.getLocation;x.getCryptoOrThrow=Ce.getCryptoOrThrow;x.getCrypto=Ce.getCrypto;x.getLocalStorageOrThrow=Ce.getLocalStorageOrThrow;x.getLocalStorage=Ce.getLocalStorage;function wc(){return gc.getWindowMetadata()}x.getClientMeta=wc});var ta={};In(ta,{safeJsonParse:()=>Cc,safeJsonStringify:()=>Ec});function Cc(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return JSON.parse(e)}catch{return e}}function Ec(e){return typeof e=="string"?e:JSON.stringify(e)}var oa=Rn(()=>{});var Ir=Ie(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.safeJsonStringify=_t.safeJsonParse=void 0;var xc=To(),ra=xc.__importStar((oa(),On(ta)));_t.safeJsonParse=ra.safeJsonParse;_t.safeJsonStringify=ra.safeJsonStringify});var Or=Ie(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.removeLocal=He.getLocal=He.setLocal=void 0;var na=Ir(),Mr=Rr();function _c(e,t){let o=(0,na.safeJsonStringify)(t),r=(0,Mr.getLocalStorage)();r&&r.setItem(e,o)}He.setLocal=_c;function Lc(e){let t=null,o=null,r=(0,Mr.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,na.safeJsonParse)(o),t}He.getLocal=Lc;function Sc(e){let t=(0,Mr.getLocalStorage)();t&&t.removeItem(e)}He.removeLocal=Sc});var aa=Ie(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.getMobileLinkRegistry=ce.getMobileRegistryEntry=ce.saveMobileLinkInfo=ce.formatIOSMobile=ce.mobileLinkChoiceKey=void 0;var Pc=Or();ce.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function kc(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}ce.formatIOSMobile=kc;function Ac(e){let t=e.href.split("?")[0];(0,Pc.setLocal)(ce.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}ce.saveMobileLinkInfo=Ac;function ia(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}ce.getMobileRegistryEntry=ia;function Tc(e,t){let o=e;return t&&(o=t.map(r=>ia(e,r)).filter(Boolean)),o}ce.getMobileLinkRegistry=Tc});var ca=Ie(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.formatMobileRegistry=Pe.formatMobileRegistryEntry=Pe.getDappRegistryUrl=Pe.getWalletRegistryUrl=void 0;var sa="https://registry.walletconnect.com";function Wc(){return sa+"/api/v2/wallets"}Pe.getWalletRegistryUrl=Wc;function Rc(){return sa+"/api/v2/dapps"}Pe.getDappRegistryUrl=Rc;function la(e,t="mobile"){var o;return{name:e.name||"",shortName:e.metadata.shortName||"",color:e.metadata.colors.primary||"",logo:(o=e.image_url.sm)!==null&&o!==void 0?o:"",universalLink:e[t].universal||"",deepLink:e[t].native||""}}Pe.formatMobileRegistryEntry=la;function Ic(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>la(o,t))}Pe.formatMobileRegistry=Ic});var da=Ie(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});var Kt=To();Kt.__exportStar(Rr(),rt);Kt.__exportStar(Ir(),rt);Kt.__exportStar(Or(),rt);Kt.__exportStar(aa(),rt);Kt.__exportStar(ca(),rt)});import{Web3Provider as v2}from"@ethersproject/providers";import{useEffect as An,useState as te}from"react";var E=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import Pl from"axios";var Ee=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},mt=class extends Ee{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},w=class extends Ee{constructor(o,r){super(o,r);this.type="client_error"}};var q=class extends Ee{constructor(o,r){super(o,r);this.type="connector_error"}},Z=e=>{if(e instanceof Ee)return e;if(!Pl.isAxiosError(e))return ye(e);if(!e.response)return new mt("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new mt(t||"ApiError",e.response.status,o||r,e)},ye=e=>e instanceof Ee?e:e instanceof Error?new w(e.message,e):new w(`Internal error: ${e}`);var Nn=()=>"/api/v1/sessions",Dn=()=>"/api/v1/sessions/logout",Un=()=>"/api/v1/sessions/fork",Bn=()=>"/api/v1/sessions/fork/recover",Fn=()=>"/api/v1/siwe/init",Gn=()=>"/api/v1/siwe/authenticate",Hn=()=>"/api/v1/siwe/link",Vn=()=>"/api/v1/passwordless/init",jn=()=>"/api/v1/passwordless/authenticate",$n=()=>"/api/v1/passwordless/link",zn=()=>"/api/v1/passwordless_sms/init",qn=()=>"/api/v1/passwordless_sms/authenticate",Zn=()=>"/api/v1/passwordless_sms/link",Kn=()=>"/api/v1/oauth/init",Jn=()=>"/api/v1/oauth/authenticate",Yn=()=>"/api/v1/oauth/link",Xn=()=>"/api/v1/siwe/unlink",Qn=()=>"/api/v1/passwordless/unlink",ei=()=>"/api/v1/passwordless_sms/unlink",ti=()=>"/api/v1/oauth/unlink";var zt=class{constructor(t){this.meta={email:t}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let t=jn(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw Z(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let t=$n();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw Z(t)}}async sendCodeEmail(t){if(!this.api)throw new w("Auth flow has no API instance");if(t&&(this.meta.email=t),!this.meta.email)throw new w("Email must be set when initialzing authentication.");try{let o=Vn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw Z(o)}}};var ht=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");try{let t=Jn(),o=await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw Z(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");try{let t=Yn();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw Z(t)}}async getAuthorizationUrl(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.provider)throw new w("Provider must be set when initialzing OAuth authentication.");try{let t=Kn();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw Z(t)}}};var gt=class{constructor(t,o,r){this._meta={walletType:o,walletId:r},this.connectors=t,this.walletConnector=this.connectors.createWalletConnector(o,null,r)}get meta(){return{...this._meta,walletName:this.walletConnector.walletBranding.name,walletIcon:this.walletConnector.walletBranding.icon}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Gn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(t){throw Z(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Hn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(t){throw Z(t)}}async promptConnect(){if(!this.api)throw new w("Auth flow has no API instance");let t=await this.walletConnector.connect({showPrompt:!0});return await this.buildSiweMessage(t),t}async sign(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.preparedMessage){let o=await this.walletConnector.connect({showPrompt:!1});await this.buildSiweMessage(o)}if(!this.preparedMessage)throw new w("Could not prepare SIWE message");let t=await this.walletConnector.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async buildSiweMessage(t){if(!this.api)throw new w("Auth flow has no API instance");let o=t.address,r=t.chainId,n=await this.api.post(Fn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var qt=class{constructor(t){this.meta={phoneNumber:t}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let t=qn(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw Z(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let t=Zn();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw Z(t)}}async sendSmsCode(t){if(!this.api)throw new w("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),!this.meta.phoneNumber)throw new w("phone nNumber must be set when initialzing authentication.");try{let o=zn();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw Z(o)}}};import{getAddress as Oc}from"@ethersproject/address";var oi="1.20.0";var ri="https://api.privy.io/v0",bo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",yo="4df5e2316331463a9130964bd6078dfa",ni=1e4,ve=1400,vr=oi;var bt="privy:token",vo="privy:refresh_token",Zt="privy:session_transfer_token",wo="privy:connectors",wr="walletconnect",ii=3e4;var Cr=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},Er=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Al(){return typeof window<"u"&&window.localStorage?new Er:new Cr}var F=Al();import Ul from"@coinbase/wallet-sdk";import{getAddress as Bl}from"@ethersproject/address";import{jsx as ai,jsxs as Tl}from"react/jsx-runtime";var we=({style:e,...t})=>Tl("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[ai("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),ai("path",{fillRule:"evenodd",clipRule:"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"})]});import{getAddress as Nl}from"@ethersproject/address";import{Web3Provider as Dl}from"@ethersproject/providers";import{ErrorCode as Wl}from"@ethersproject/logger";var yt=class extends q{constructor(){super("Wallet timeout");this.type="wallet_error"}},Xe=class extends q{constructor(){super("User rejected connection");this.type="wallet_error"}},Le=e=>{if(e instanceof q)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new vt(e);return e.code===Wl.ACTION_REJECTED&&(t.details=Ye.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new vt(e):new q("Unknown connector error",e)},xr=class extends Ee{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},vt=class extends xr{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(Ye).find(l=>l.eipCode===r.code);this.details=n||Ye.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=Ye.E32002_CONNECTION_ALREADY_PENDING:this.details=Ye.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ye.E32002_WALLET_LOCKED))}},Rl={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Il={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Ml={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},Ye={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Ml,...Il},Qe={...Rl,...Ye};var Ol=12e4,_r=(e=new yt,t=Ol)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),Se=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(t,o)};this.setWalletProvider=t=>{this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new q(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),_r()]).catch(o=>{throw Le(o)})}},et=class extends Se{constructor(o){super(o)}},Co=class extends Se{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Me=class{constructor(t,o,r){this.createSiweMessage=(t,o,r,n,i,a,s)=>`${r} wants you to sign in with your Ethereum account:
1
+ var Cl=Object.create;var go=Object.defineProperty;var El=Object.getOwnPropertyDescriptor;var xl=Object.getOwnPropertyNames;var _l=Object.getPrototypeOf,Ll=Object.prototype.hasOwnProperty;var Rn=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ie=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),In=(e,t)=>{for(var o in t)go(e,o,{get:t[o],enumerable:!0})},Mn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of xl(t))!Ll.call(e,n)&&n!==o&&go(e,n,{get:()=>t[n],enumerable:!(r=El(t,n))||r.enumerable});return e};var Sl=(e,t,o)=>(o=e!=null?Cl(_l(e)):{},Mn(t||!e||!e.__esModule?go(o,"default",{value:e,enumerable:!0}):o,e)),On=e=>Mn(go({},"__esModule",{value:!0}),e);var To=Ie((Fu,Ao)=>{var gi,bi,yi,vi,wi,Ci,Ei,xi,_i,Po,kr,Li,Si,Pi,Et,ki,Ai,Ti,Wi,Ri,Ii,Mi,Oi,Ni,ko;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(o(t,o(r)))}):typeof Ao=="object"&&typeof Ao.exports=="object"?e(o(t,o(Ao.exports))):e(o(t));function o(r,n){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(i,a){return r[i]=n?n(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])};gi=function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function i(){this.constructor=r}r.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)},bi=Object.assign||function(r){for(var n,i=1,a=arguments.length;i<a;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},yi=function(r,n){var i={};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&n.indexOf(a)<0&&(i[a]=r[a]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(r);s<a.length;s++)n.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(r,a[s])&&(i[a[s]]=r[a[s]]);return i},vi=function(r,n,i,a){var s=arguments.length,l=s<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,i):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,n,i,a);else for(var h=r.length-1;h>=0;h--)(d=r[h])&&(l=(s<3?d(l):s>3?d(n,i,l):d(n,i))||l);return s>3&&l&&Object.defineProperty(n,i,l),l},wi=function(r,n){return function(i,a){n(i,a,r)}},Ci=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Ei=function(r,n,i,a){function s(l){return l instanceof i?l:new i(function(d){d(l)})}return new(i||(i=Promise))(function(l,d){function h(g){try{p(a.next(g))}catch(b){d(b)}}function m(g){try{p(a.throw(g))}catch(b){d(b)}}function p(g){g.done?l(g.value):s(g.value).then(h,m)}p((a=a.apply(r,n||[])).next())})},xi=function(r,n){var i={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,s,l,d;return d={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function h(p){return function(g){return m([p,g])}}function m(p){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(l=p[0]&2?s.return:p[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,p[1])).done)return l;switch(s=0,l&&(p=[p[0]&2,l.value]),p[0]){case 0:case 1:l=p;break;case 4:return i.label++,{value:p[1],done:!1};case 5:i.label++,s=p[1],p=[0];continue;case 7:p=i.ops.pop(),i.trys.pop();continue;default:if(l=i.trys,!(l=l.length>0&&l[l.length-1])&&(p[0]===6||p[0]===2)){i=0;continue}if(p[0]===3&&(!l||p[1]>l[0]&&p[1]<l[3])){i.label=p[1];break}if(p[0]===6&&i.label<l[1]){i.label=l[1],l=p;break}if(l&&i.label<l[2]){i.label=l[2],i.ops.push(p);break}l[2]&&i.ops.pop(),i.trys.pop();continue}p=n.call(r,i)}catch(g){p=[6,g],s=0}finally{a=l=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},_i=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&ko(n,r,i)},ko=Object.create?function(r,n,i,a){a===void 0&&(a=i);var s=Object.getOwnPropertyDescriptor(n,i);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(r,a,s)}:function(r,n,i,a){a===void 0&&(a=i),r[a]=n[i]},Po=function(r){var n=typeof Symbol=="function"&&Symbol.iterator,i=n&&r[n],a=0;if(i)return i.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&a>=r.length&&(r=void 0),{value:r&&r[a++],done:!r}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},kr=function(r,n){var i=typeof Symbol=="function"&&r[Symbol.iterator];if(!i)return r;var a=i.call(r),s,l=[],d;try{for(;(n===void 0||n-- >0)&&!(s=a.next()).done;)l.push(s.value)}catch(h){d={error:h}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(d)throw d.error}}return l},Li=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(kr(arguments[n]));return r},Si=function(){for(var r=0,n=0,i=arguments.length;n<i;n++)r+=arguments[n].length;for(var a=Array(r),s=0,n=0;n<i;n++)for(var l=arguments[n],d=0,h=l.length;d<h;d++,s++)a[s]=l[d];return a},Pi=function(r,n,i){if(i||arguments.length===2)for(var a=0,s=n.length,l;a<s;a++)(l||!(a in n))&&(l||(l=Array.prototype.slice.call(n,0,a)),l[a]=n[a]);return r.concat(l||Array.prototype.slice.call(n))},Et=function(r){return this instanceof Et?(this.v=r,this):new Et(r)},ki=function(r,n,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=i.apply(r,n||[]),s,l=[];return s={},d("next"),d("throw"),d("return"),s[Symbol.asyncIterator]=function(){return this},s;function d(c){a[c]&&(s[c]=function(y){return new Promise(function(v,W){l.push([c,y,v,W])>1||h(c,y)})})}function h(c,y){try{m(a[c](y))}catch(v){b(l[0][3],v)}}function m(c){c.value instanceof Et?Promise.resolve(c.value.v).then(p,g):b(l[0][2],c)}function p(c){h("next",c)}function g(c){h("throw",c)}function b(c,y){c(y),l.shift(),l.length&&h(l[0][0],l[0][1])}},Ai=function(r){var n,i;return n={},a("next"),a("throw",function(s){throw s}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(s,l){n[s]=r[s]?function(d){return(i=!i)?{value:Et(r[s](d)),done:s==="return"}:l?l(d):d}:l}},Ti=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r[Symbol.asyncIterator],i;return n?n.call(r):(r=typeof Po=="function"?Po(r):r[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(l){i[l]=r[l]&&function(d){return new Promise(function(h,m){d=r[l](d),s(h,m,d.done,d.value)})}}function s(l,d,h,m){Promise.resolve(m).then(function(p){l({value:p,done:h})},d)}},Wi=function(r,n){return Object.defineProperty?Object.defineProperty(r,"raw",{value:n}):r.raw=n,r};var o=Object.create?function(r,n){Object.defineProperty(r,"default",{enumerable:!0,value:n})}:function(r,n){r.default=n};Ri=function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)i!=="default"&&Object.prototype.hasOwnProperty.call(r,i)&&ko(n,r,i);return o(n,r),n},Ii=function(r){return r&&r.__esModule?r:{default:r}},Mi=function(r,n,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!a:!n.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(r):a?a.value:n.get(r)},Oi=function(r,n,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?r!==n||!s:!n.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(r,i):s?s.value=i:n.set(r,i),i},Ni=function(r,n){if(n===null||typeof n!="object"&&typeof n!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?n===r:r.has(n)},e("__extends",gi),e("__assign",bi),e("__rest",yi),e("__decorate",vi),e("__param",wi),e("__metadata",Ci),e("__awaiter",Ei),e("__generator",xi),e("__exportStar",_i),e("__createBinding",ko),e("__values",Po),e("__read",kr),e("__spread",Li),e("__spreadArrays",Si),e("__spreadArray",Pi),e("__await",Et),e("__asyncGenerator",ki),e("__asyncDelegator",Ai),e("__asyncValues",Ti),e("__makeTemplateObject",Wi),e("__importStar",Ri),e("__importDefault",Ii),e("__classPrivateFieldGet",Mi),e("__classPrivateFieldSet",Oi),e("__classPrivateFieldIn",Ni)})});var Ar=Ie(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.getLocalStorage=O.getLocalStorageOrThrow=O.getCrypto=O.getCryptoOrThrow=O.getLocation=O.getLocationOrThrow=O.getNavigator=O.getNavigatorOrThrow=O.getDocument=O.getDocumentOrThrow=O.getFromWindowOrThrow=O.getFromWindow=void 0;function ot(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}O.getFromWindow=ot;function xt(e){let t=ot(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}O.getFromWindowOrThrow=xt;function Xl(){return xt("document")}O.getDocumentOrThrow=Xl;function Ql(){return ot("document")}O.getDocument=Ql;function ec(){return xt("navigator")}O.getNavigatorOrThrow=ec;function tc(){return ot("navigator")}O.getNavigator=tc;function oc(){return xt("location")}O.getLocationOrThrow=oc;function rc(){return ot("location")}O.getLocation=rc;function nc(){return xt("crypto")}O.getCryptoOrThrow=nc;function ic(){return ot("crypto")}O.getCrypto=ic;function ac(){return xt("localStorage")}O.getLocalStorageOrThrow=ac;function sc(){return ot("localStorage")}O.getLocalStorage=sc});var Ui=Ie(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.getWindowMetadata=void 0;var Di=Ar();function lc(){let e,t;try{e=Di.getDocumentOrThrow(),t=Di.getLocationOrThrow()}catch{return null}function o(){let m=e.getElementsByTagName("link"),p=[];for(let g=0;g<m.length;g++){let b=m[g],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let v=t.protocol+"//"+t.host;if(y.indexOf("/")===0)v+=y;else{let W=t.pathname.split("/");W.pop(),v+=W.join("/")+"/"+y}p.push(v)}else if(y.indexOf("//")===0){let v=t.protocol+y;p.push(v)}else p.push(y)}}return p}function r(...m){let p=e.getElementsByTagName("meta");for(let g=0;g<p.length;g++){let b=p[g],c=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?m.includes(y):!1);if(c.length&&c){let y=b.getAttribute("content");if(y)return y}}return""}function n(){let m=r("name","og:site_name","og:title","twitter:title");return m||(m=e.title),m}function i(){return r("description","og:description","twitter:description","keywords")}let a=n(),s=i(),l=t.origin,d=o();return{description:s,url:l,icons:d,name:a}}Wo.getWindowMetadata=lc});var Ki={};In(Ki,{BotInfo:()=>ji,BrowserInfo:()=>Gi,NodeInfo:()=>Hi,ReactNativeInfo:()=>$i,SearchBotDeviceInfo:()=>Vi,browserName:()=>mc,detect:()=>fc,detectOS:()=>qi,getNodeVersion:()=>Zi,parseUserAgent:()=>Tr});function fc(e){return e?Tr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new $i:typeof navigator<"u"?Tr(navigator.userAgent):Zi()}function zi(e){return e!==""&&uc.reduce(function(t,o){var r=o[0],n=o[1];if(t)return t;var i=n.exec(e);return!!i&&[r,i]},!1)}function mc(e){var t=zi(e);return t?t[0]:null}function Tr(e){var t=zi(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new ji;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<Bi&&(n=cc(n,hc(Bi-n.length))):n=[];var i=n.join("."),a=qi(e),s=pc.exec(e);return s&&s[1]?new Vi(o,i,a,s[1]):new Gi(o,i,a)}function qi(e){for(var t=0,o=Fi.length;t<o;t++){var r=Fi[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function Zi(){var e=typeof process<"u"&&process.version;return e?new Hi(process.version.slice(1)):null}function hc(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var cc,Gi,Hi,Vi,ji,$i,dc,pc,Bi,uc,Fi,Ji=Rn(()=>{cc=function(){for(var e=0,t=0,o=arguments.length;t<o;t++)e+=arguments[t].length;for(var r=Array(e),n=0,t=0;t<o;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,n++)r[n]=i[a];return r},Gi=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),Hi=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),Vi=function(){function e(t,o,r,n){this.name=t,this.version=o,this.os=r,this.bot=n,this.type="bot-device"}return e}(),ji=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),$i=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),dc=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,pc=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Bi=3,uc=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",dc]],Fi=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]]});var Rr=Ie(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.getClientMeta=x.getLocalStorage=x.getLocalStorageOrThrow=x.getCrypto=x.getCryptoOrThrow=x.getLocation=x.getLocationOrThrow=x.getNavigator=x.getNavigatorOrThrow=x.getDocument=x.getDocumentOrThrow=x.getFromWindowOrThrow=x.getFromWindow=x.isBrowser=x.isNode=x.isMobile=x.isIOS=x.isAndroid=x.detectOS=x.detectEnv=void 0;var Yi=To(),gc=Yi.__importStar(Ui()),Ce=Yi.__importStar(Ar()),bc=(Ji(),On(Ki));function Wr(e){return(0,bc.detect)(e)}x.detectEnv=Wr;function Ro(){let e=Wr();return e&&e.os?e.os:void 0}x.detectOS=Ro;function Xi(){let e=Ro();return e?e.toLowerCase().includes("android"):!1}x.isAndroid=Xi;function Qi(){let e=Ro();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}x.isIOS=Qi;function yc(){return Ro()?Xi()||Qi():!1}x.isMobile=yc;function ea(){let e=Wr();return e&&e.name?e.name.toLowerCase()==="node":!1}x.isNode=ea;function vc(){return!ea()&&!!(0,x.getNavigator)()}x.isBrowser=vc;x.getFromWindow=Ce.getFromWindow;x.getFromWindowOrThrow=Ce.getFromWindowOrThrow;x.getDocumentOrThrow=Ce.getDocumentOrThrow;x.getDocument=Ce.getDocument;x.getNavigatorOrThrow=Ce.getNavigatorOrThrow;x.getNavigator=Ce.getNavigator;x.getLocationOrThrow=Ce.getLocationOrThrow;x.getLocation=Ce.getLocation;x.getCryptoOrThrow=Ce.getCryptoOrThrow;x.getCrypto=Ce.getCrypto;x.getLocalStorageOrThrow=Ce.getLocalStorageOrThrow;x.getLocalStorage=Ce.getLocalStorage;function wc(){return gc.getWindowMetadata()}x.getClientMeta=wc});var ta={};In(ta,{safeJsonParse:()=>Cc,safeJsonStringify:()=>Ec});function Cc(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return JSON.parse(e)}catch{return e}}function Ec(e){return typeof e=="string"?e:JSON.stringify(e)}var oa=Rn(()=>{});var Ir=Ie(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.safeJsonStringify=_t.safeJsonParse=void 0;var xc=To(),ra=xc.__importStar((oa(),On(ta)));_t.safeJsonParse=ra.safeJsonParse;_t.safeJsonStringify=ra.safeJsonStringify});var Or=Ie(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.removeLocal=He.getLocal=He.setLocal=void 0;var na=Ir(),Mr=Rr();function _c(e,t){let o=(0,na.safeJsonStringify)(t),r=(0,Mr.getLocalStorage)();r&&r.setItem(e,o)}He.setLocal=_c;function Lc(e){let t=null,o=null,r=(0,Mr.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,na.safeJsonParse)(o),t}He.getLocal=Lc;function Sc(e){let t=(0,Mr.getLocalStorage)();t&&t.removeItem(e)}He.removeLocal=Sc});var aa=Ie(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.getMobileLinkRegistry=ce.getMobileRegistryEntry=ce.saveMobileLinkInfo=ce.formatIOSMobile=ce.mobileLinkChoiceKey=void 0;var Pc=Or();ce.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function kc(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}ce.formatIOSMobile=kc;function Ac(e){let t=e.href.split("?")[0];(0,Pc.setLocal)(ce.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}ce.saveMobileLinkInfo=Ac;function ia(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}ce.getMobileRegistryEntry=ia;function Tc(e,t){let o=e;return t&&(o=t.map(r=>ia(e,r)).filter(Boolean)),o}ce.getMobileLinkRegistry=Tc});var ca=Ie(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.formatMobileRegistry=Pe.formatMobileRegistryEntry=Pe.getDappRegistryUrl=Pe.getWalletRegistryUrl=void 0;var sa="https://registry.walletconnect.com";function Wc(){return sa+"/api/v2/wallets"}Pe.getWalletRegistryUrl=Wc;function Rc(){return sa+"/api/v2/dapps"}Pe.getDappRegistryUrl=Rc;function la(e,t="mobile"){var o;return{name:e.name||"",shortName:e.metadata.shortName||"",color:e.metadata.colors.primary||"",logo:(o=e.image_url.sm)!==null&&o!==void 0?o:"",universalLink:e[t].universal||"",deepLink:e[t].native||""}}Pe.formatMobileRegistryEntry=la;function Ic(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>la(o,t))}Pe.formatMobileRegistry=Ic});var da=Ie(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});var Kt=To();Kt.__exportStar(Rr(),rt);Kt.__exportStar(Ir(),rt);Kt.__exportStar(Or(),rt);Kt.__exportStar(aa(),rt);Kt.__exportStar(ca(),rt)});import{Web3Provider as v2}from"@ethersproject/providers";import{useEffect as An,useState as te}from"react";var E=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import Pl from"axios";var Ee=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},mt=class extends Ee{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},w=class extends Ee{constructor(o,r){super(o,r);this.type="client_error"}};var q=class extends Ee{constructor(o,r){super(o,r);this.type="connector_error"}},Z=e=>{if(e instanceof Ee)return e;if(!Pl.isAxiosError(e))return ye(e);if(!e.response)return new mt("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new mt(t||"ApiError",e.response.status,o||r,e)},ye=e=>e instanceof Ee?e:e instanceof Error?new w(e.message,e):new w(`Internal error: ${e}`);var Nn=()=>"/api/v1/sessions",Dn=()=>"/api/v1/sessions/logout",Un=()=>"/api/v1/sessions/fork",Bn=()=>"/api/v1/sessions/fork/recover",Fn=()=>"/api/v1/siwe/init",Gn=()=>"/api/v1/siwe/authenticate",Hn=()=>"/api/v1/siwe/link",Vn=()=>"/api/v1/passwordless/init",jn=()=>"/api/v1/passwordless/authenticate",$n=()=>"/api/v1/passwordless/link",zn=()=>"/api/v1/passwordless_sms/init",qn=()=>"/api/v1/passwordless_sms/authenticate",Zn=()=>"/api/v1/passwordless_sms/link",Kn=()=>"/api/v1/oauth/init",Jn=()=>"/api/v1/oauth/authenticate",Yn=()=>"/api/v1/oauth/link",Xn=()=>"/api/v1/siwe/unlink",Qn=()=>"/api/v1/passwordless/unlink",ei=()=>"/api/v1/passwordless_sms/unlink",ti=()=>"/api/v1/oauth/unlink";var zt=class{constructor(t){this.meta={email:t}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let t=jn(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw Z(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let t=$n();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw Z(t)}}async sendCodeEmail(t){if(!this.api)throw new w("Auth flow has no API instance");if(t&&(this.meta.email=t),!this.meta.email)throw new w("Email must be set when initialzing authentication.");try{let o=Vn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw Z(o)}}};var ht=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");try{let t=Jn(),o=await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw Z(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");try{let t=Yn();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw Z(t)}}async getAuthorizationUrl(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.provider)throw new w("Provider must be set when initialzing OAuth authentication.");try{let t=Kn();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw Z(t)}}};var gt=class{constructor(t,o,r){this._meta={walletType:o,walletId:r},this.connectors=t,this.walletConnector=this.connectors.createWalletConnector(o,null,r)}get meta(){return{...this._meta,walletName:this.walletConnector.walletBranding.name,walletIcon:this.walletConnector.walletBranding.icon}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Gn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(t){throw Z(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Hn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(t){throw Z(t)}}async promptConnect(){if(!this.api)throw new w("Auth flow has no API instance");let t=await this.walletConnector.connect({showPrompt:!0});return await this.buildSiweMessage(t),t}async sign(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.preparedMessage){let o=await this.walletConnector.connect({showPrompt:!1});await this.buildSiweMessage(o)}if(!this.preparedMessage)throw new w("Could not prepare SIWE message");let t=await this.walletConnector.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async buildSiweMessage(t){if(!this.api)throw new w("Auth flow has no API instance");let o=t.address,r=t.chainId,n=await this.api.post(Fn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var qt=class{constructor(t){this.meta={phoneNumber:t}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let t=qn(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw Z(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let t=Zn();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw Z(t)}}async sendSmsCode(t){if(!this.api)throw new w("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),!this.meta.phoneNumber)throw new w("phone nNumber must be set when initialzing authentication.");try{let o=zn();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw Z(o)}}};import{getAddress as Oc}from"@ethersproject/address";var oi="1.20.1-beta.1";var ri="https://api.privy.io/v0",bo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",yo="4df5e2316331463a9130964bd6078dfa",ni=1e4,ve=1400,vr=oi;var bt="privy:token",vo="privy:refresh_token",Zt="privy:session_transfer_token",wo="privy:connectors",wr="walletconnect",ii=3e4;var Cr=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},Er=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Al(){return typeof window<"u"&&window.localStorage?new Er:new Cr}var F=Al();import Ul from"@coinbase/wallet-sdk";import{getAddress as Bl}from"@ethersproject/address";import{jsx as ai,jsxs as Tl}from"react/jsx-runtime";var we=({style:e,...t})=>Tl("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[ai("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),ai("path",{fillRule:"evenodd",clipRule:"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"})]});import{getAddress as Nl}from"@ethersproject/address";import{Web3Provider as Dl}from"@ethersproject/providers";import{ErrorCode as Wl}from"@ethersproject/logger";var yt=class extends q{constructor(){super("Wallet timeout");this.type="wallet_error"}},Xe=class extends q{constructor(){super("User rejected connection");this.type="wallet_error"}},Le=e=>{if(e instanceof q)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new vt(e);return e.code===Wl.ACTION_REJECTED&&(t.details=Ye.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new vt(e):new q("Unknown connector error",e)},xr=class extends Ee{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},vt=class extends xr{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(Ye).find(l=>l.eipCode===r.code);this.details=n||Ye.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=Ye.E32002_CONNECTION_ALREADY_PENDING:this.details=Ye.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ye.E32002_WALLET_LOCKED))}},Rl={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Il={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Ml={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},Ye={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Ml,...Il},Qe={...Rl,...Ye};var Ol=12e4,_r=(e=new yt,t=Ol)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),Se=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(t,o)};this.setWalletProvider=t=>{this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new q(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),_r()]).catch(o=>{throw Le(o)})}},et=class extends Se{constructor(o){super(o)}},Co=class extends Se{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Me=class{constructor(t,o,r){this.createSiweMessage=(t,o,r,n,i,a,s)=>`${r} wants you to sign in with your Ethereum account:
2
2
  ${o}
3
3
 
4
4
  ${s}
@@ -596,7 +596,7 @@ Resources:
596
596
  background-position: 0% 50%;
597
597
  }
598
598
  }
599
- `;import{Fragment as zd,jsx as Te,jsxs as Wt}from"react/jsx-runtime";var ns=()=>{var m;let{user:e}=D(),{closePrivyModal:t}=A(),{data:o}=C(),r=J(e),{onSuccess:n,onFailure:i,callAuthOnSuccessOnClose:a}=o.createWallet,s=()=>{r?(n(r),t({shouldCallAuthOnSuccess:a})):i(new Error("Failed to create wallet"))},l="Your digital wallet",d="You\u2019re all set! This wallet is all yours and can only ever be accessed by you.",h=tt(r.address);return Wt(zd,{children:[Te(L,{onClose:s}),Wt(Fd,{children:[Wt("div",{children:[Te(X,{title:l,description:d}),Wt(Gd,{children:[Te(rs,{}),Wt(Hd,{children:[Te("p",{children:((m=e==null?void 0:e.email)==null?void 0:m.address)||""}),Wt(Vd,{children:[Te(jd,{children:h})," ",Te(Ho,{color:"var(--privy-color-foreground)"})]})]})]}),Te($d,{children:Te(Ko,{text:r.address,itemName:"Address"})})]}),Te(ne,{onClick:s,children:"I\u2019m all set"})]}),Te(U,{protectedByPrivy:!0})]})},Fd=Rt.div`
599
+ `;import{Fragment as zd,jsx as Te,jsxs as Wt}from"react/jsx-runtime";var ns=()=>{var m;let{user:e}=D(),{closePrivyModal:t}=A(),{data:o}=C(),r=J(e),{onSuccess:n,onFailure:i,callAuthOnSuccessOnClose:a}=o.createWallet,s=()=>{r?(n(r),t({shouldCallAuthOnSuccess:a})):i(new Error("Failed to create wallet"))},l="Your account",d="You\u2019re all set! This account is tied to a digital wallet. It can only ever be accessed by you.",h=tt(r.address);return Wt(zd,{children:[Te(L,{onClose:s}),Wt(Fd,{children:[Wt("div",{children:[Te(X,{title:l,description:d}),Wt(Gd,{children:[Te(rs,{}),Wt(Hd,{children:[Te("p",{children:((m=e==null?void 0:e.email)==null?void 0:m.address)||""}),Wt(Vd,{children:[Te(jd,{children:h})," ",Te(Ho,{color:"var(--privy-color-foreground)"})]})]})]}),Te($d,{children:Te(Ko,{text:r.address,itemName:"Address"})})]}),Te(ne,{onClick:s,children:"I\u2019m all set"})]}),Te(U,{protectedByPrivy:!0})]})},Fd=Rt.div`
600
600
  display: flex;
601
601
  height: 100%;
602
602
  flex-direction: column;
@@ -866,7 +866,7 @@ Resources:
866
866
  transition: none;
867
867
  }
868
868
  `}
869
- `;import{useEffect as _1,useState as dn}from"react";import pn,{css as L1}from"styled-components";import{Fragment as A1,jsx as Fe,jsxs as Xo}from"react/jsx-runtime";var ms=()=>{let{authenticated:e,getAccessToken:t,user:o}=D(),{walletProxy:r,refreshUser:n,closePrivyModal:i}=A(),{navigate:a,data:s}=C(),[l,d]=dn(null),[h,m]=dn(""),[p,g]=dn(!1),{onFailure:b,callAuthOnSuccessOnClose:c}=s.createWallet;_1(()=>{e||(a("LANDING"),b(new Error("User must be authenticated before creating a Privy wallet")))},[e]);let y=()=>{b(new Error("User exited before creating a wallet")),i({shouldCallAuthOnSuccess:c})},v=I=>{d(I)},W=J(o),P=W?()=>{g(!0),setTimeout(()=>{g(!1),a("EMBEDDED_WALLET_CREATED_SCREEN")},350)}:async()=>{g(!0);let I=await t();if(I&&l!==null)try{await(r==null?void 0:r.create({accessToken:I,recoveryPin:l})),m(""),await n()}catch(z){m("An error has occurred, please try again."),console.error(z)}finally{g(!1)}},R=!!W;return Xo(A1,{children:[Fe(L,{onClose:y}),Xo(S1,{children:[Xo("div",{children:[Fe(X,{title:R?"Secure your PIN":"Set your PIN",description:R?"Don\u2019t lose this PIN. You\u2019ll need it to access your wallet across devices.":"To finish setting up your account, please set up a PIN."}),Fe(Jo,{onChange:v,disabled:p,readOnly:R,errorReasonOverride:h}),R?Fe(Ko,{text:l||""}):null]}),Xo(P1,{children:[Fe("h4",{children:"Why am I doing this?"}),R?Fe("p",{children:"This PIN allows you to access your wallet across devices. If you lose it, there is no way to recover your wallet."}):Fe("p",{children:"A digital wallet is being created on this device for your account. This PIN allows you to access it across devices."})]}),Fe(k1,{loading:p||!r,disabled:!l,onClick:P,warn:R,hideAnimations:!W&&p,children:R?"I have saved my PIN":"Create your wallet"})]}),Fe(U,{protectedByPrivy:!0})]})},S1=pn.div`
869
+ `;import{useEffect as _1,useState as dn}from"react";import pn,{css as L1}from"styled-components";import{Fragment as A1,jsx as Fe,jsxs as Xo}from"react/jsx-runtime";var ms=()=>{let{authenticated:e,getAccessToken:t,user:o}=D(),{walletProxy:r,refreshUser:n,closePrivyModal:i}=A(),{navigate:a,data:s}=C(),[l,d]=dn(null),[h,m]=dn(""),[p,g]=dn(!1),{onFailure:b,callAuthOnSuccessOnClose:c}=s.createWallet;_1(()=>{e||(a("LANDING"),b(new Error("User must be authenticated before creating a Privy wallet")))},[e]);let y=()=>{b(new Error("User exited before creating a wallet")),i({shouldCallAuthOnSuccess:c})},v=I=>{d(I)},W=J(o),P=W?()=>{g(!0),setTimeout(()=>{g(!1),a("EMBEDDED_WALLET_CREATED_SCREEN")},350)}:async()=>{g(!0);let I=await t();if(I&&l!==null)try{await(r==null?void 0:r.create({accessToken:I,recoveryPin:l})),m(""),await n()}catch(z){m("An error has occurred, please try again."),console.error(z)}finally{g(!1)}},R=!!W;return Xo(A1,{children:[Fe(L,{onClose:y}),Xo(S1,{children:[Xo("div",{children:[Fe(X,{title:R?"Secure your PIN":"Set your PIN",description:R?"Don\u2019t lose this PIN. You\u2019ll need it to access your full account on another device.":"You will need it when you sign in on a different device."}),Fe(Jo,{onChange:v,disabled:p,readOnly:R,errorReasonOverride:h}),R?Fe(Ko,{text:l||""}):null]}),Xo(P1,{children:[Fe("h4",{children:"Why am I doing this?"}),R?Fe("p",{children:"This PIN allows you to access your account on another device. If you lose it, there is no way to recover your full account."}):Fe("p",{children:"For your security, your account is tied to this device. Your PIN allows you to access it across devices."})]}),Fe(k1,{loading:p||!r,disabled:!l,onClick:P,warn:R,hideAnimations:!W&&p,children:R?"I have saved my PIN":"Set PIN"})]}),Fe(U,{protectedByPrivy:!0})]})},S1=pn.div`
870
870
  display: flex;
871
871
  height: 100%;
872
872
  flex-direction: column;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var El=Object.create;var Ro=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var _l=Object.getOwnPropertyNames;var Ll=Object.getPrototypeOf,Sl=Object.prototype.hasOwnProperty;var zn=(e,t)=>()=>(e&&(t=e(e=0)),t);var ot=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Fr=(e,t)=>{for(var o in t)Ro(e,o,{get:t[o],enumerable:!0})},qn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _l(t))!Sl.call(e,n)&&n!==o&&Ro(e,n,{get:()=>t[n],enumerable:!(r=xl(t,n))||r.enumerable});return e};var L=(e,t,o)=>(o=e!=null?El(Ll(e)):{},qn(t||!e||!e.__esModule?Ro(o,"default",{value:e,enumerable:!0}):o,e)),Gr=e=>qn(Ro({},"__esModule",{value:!0}),e);var Zo=ot((Np,qo)=>{var Oi,Ni,Di,Ui,Bi,Fi,Gi,Hi,Vi,$o,Jr,ji,$i,zi,jt,qi,Zi,Ki,Ji,Yi,Xi,Qi,ea,ta,zo;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(o(t,o(r)))}):typeof qo=="object"&&typeof qo.exports=="object"?e(o(t,o(qo.exports))):e(o(t));function o(r,n){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(i,a){return r[i]=n?n(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])};Oi=function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function i(){this.constructor=r}r.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)},Ni=Object.assign||function(r){for(var n,i=1,a=arguments.length;i<a;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},Di=function(r,n){var i={};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&n.indexOf(a)<0&&(i[a]=r[a]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(r);s<a.length;s++)n.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(r,a[s])&&(i[a[s]]=r[a[s]]);return i},Ui=function(r,n,i,a){var s=arguments.length,l=s<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,i):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,n,i,a);else for(var h=r.length-1;h>=0;h--)(d=r[h])&&(l=(s<3?d(l):s>3?d(n,i,l):d(n,i))||l);return s>3&&l&&Object.defineProperty(n,i,l),l},Bi=function(r,n){return function(i,a){n(i,a,r)}},Fi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Gi=function(r,n,i,a){function s(l){return l instanceof i?l:new i(function(d){d(l)})}return new(i||(i=Promise))(function(l,d){function h(g){try{p(a.next(g))}catch(b){d(b)}}function m(g){try{p(a.throw(g))}catch(b){d(b)}}function p(g){g.done?l(g.value):s(g.value).then(h,m)}p((a=a.apply(r,n||[])).next())})},Hi=function(r,n){var i={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,s,l,d;return d={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function h(p){return function(g){return m([p,g])}}function m(p){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(l=p[0]&2?s.return:p[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,p[1])).done)return l;switch(s=0,l&&(p=[p[0]&2,l.value]),p[0]){case 0:case 1:l=p;break;case 4:return i.label++,{value:p[1],done:!1};case 5:i.label++,s=p[1],p=[0];continue;case 7:p=i.ops.pop(),i.trys.pop();continue;default:if(l=i.trys,!(l=l.length>0&&l[l.length-1])&&(p[0]===6||p[0]===2)){i=0;continue}if(p[0]===3&&(!l||p[1]>l[0]&&p[1]<l[3])){i.label=p[1];break}if(p[0]===6&&i.label<l[1]){i.label=l[1],l=p;break}if(l&&i.label<l[2]){i.label=l[2],i.ops.push(p);break}l[2]&&i.ops.pop(),i.trys.pop();continue}p=n.call(r,i)}catch(g){p=[6,g],s=0}finally{a=l=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},Vi=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&zo(n,r,i)},zo=Object.create?function(r,n,i,a){a===void 0&&(a=i);var s=Object.getOwnPropertyDescriptor(n,i);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(r,a,s)}:function(r,n,i,a){a===void 0&&(a=i),r[a]=n[i]},$o=function(r){var n=typeof Symbol=="function"&&Symbol.iterator,i=n&&r[n],a=0;if(i)return i.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&a>=r.length&&(r=void 0),{value:r&&r[a++],done:!r}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},Jr=function(r,n){var i=typeof Symbol=="function"&&r[Symbol.iterator];if(!i)return r;var a=i.call(r),s,l=[],d;try{for(;(n===void 0||n-- >0)&&!(s=a.next()).done;)l.push(s.value)}catch(h){d={error:h}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(d)throw d.error}}return l},ji=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(Jr(arguments[n]));return r},$i=function(){for(var r=0,n=0,i=arguments.length;n<i;n++)r+=arguments[n].length;for(var a=Array(r),s=0,n=0;n<i;n++)for(var l=arguments[n],d=0,h=l.length;d<h;d++,s++)a[s]=l[d];return a},zi=function(r,n,i){if(i||arguments.length===2)for(var a=0,s=n.length,l;a<s;a++)(l||!(a in n))&&(l||(l=Array.prototype.slice.call(n,0,a)),l[a]=n[a]);return r.concat(l||Array.prototype.slice.call(n))},jt=function(r){return this instanceof jt?(this.v=r,this):new jt(r)},qi=function(r,n,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=i.apply(r,n||[]),s,l=[];return s={},d("next"),d("throw"),d("return"),s[Symbol.asyncIterator]=function(){return this},s;function d(c){a[c]&&(s[c]=function(y){return new Promise(function(C,M){l.push([c,y,C,M])>1||h(c,y)})})}function h(c,y){try{m(a[c](y))}catch(C){b(l[0][3],C)}}function m(c){c.value instanceof jt?Promise.resolve(c.value.v).then(p,g):b(l[0][2],c)}function p(c){h("next",c)}function g(c){h("throw",c)}function b(c,y){c(y),l.shift(),l.length&&h(l[0][0],l[0][1])}},Zi=function(r){var n,i;return n={},a("next"),a("throw",function(s){throw s}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(s,l){n[s]=r[s]?function(d){return(i=!i)?{value:jt(r[s](d)),done:s==="return"}:l?l(d):d}:l}},Ki=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r[Symbol.asyncIterator],i;return n?n.call(r):(r=typeof $o=="function"?$o(r):r[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(l){i[l]=r[l]&&function(d){return new Promise(function(h,m){d=r[l](d),s(h,m,d.done,d.value)})}}function s(l,d,h,m){Promise.resolve(m).then(function(p){l({value:p,done:h})},d)}},Ji=function(r,n){return Object.defineProperty?Object.defineProperty(r,"raw",{value:n}):r.raw=n,r};var o=Object.create?function(r,n){Object.defineProperty(r,"default",{enumerable:!0,value:n})}:function(r,n){r.default=n};Yi=function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)i!=="default"&&Object.prototype.hasOwnProperty.call(r,i)&&zo(n,r,i);return o(n,r),n},Xi=function(r){return r&&r.__esModule?r:{default:r}},Qi=function(r,n,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!a:!n.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(r):a?a.value:n.get(r)},ea=function(r,n,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?r!==n||!s:!n.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(r,i):s?s.value=i:n.set(r,i),i},ta=function(r,n){if(n===null||typeof n!="object"&&typeof n!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?n===r:r.has(n)},e("__extends",Oi),e("__assign",Ni),e("__rest",Di),e("__decorate",Ui),e("__param",Bi),e("__metadata",Fi),e("__awaiter",Gi),e("__generator",Hi),e("__exportStar",Vi),e("__createBinding",zo),e("__values",$o),e("__read",Jr),e("__spread",ji),e("__spreadArrays",$i),e("__spreadArray",zi),e("__await",jt),e("__asyncGenerator",qi),e("__asyncDelegator",Zi),e("__asyncValues",Ki),e("__makeTemplateObject",Ji),e("__importStar",Yi),e("__importDefault",Xi),e("__classPrivateFieldGet",Qi),e("__classPrivateFieldSet",ea),e("__classPrivateFieldIn",ta)})});var Yr=ot(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.getLocalStorage=U.getLocalStorageOrThrow=U.getCrypto=U.getCryptoOrThrow=U.getLocation=U.getLocationOrThrow=U.getNavigator=U.getNavigatorOrThrow=U.getDocument=U.getDocumentOrThrow=U.getFromWindowOrThrow=U.getFromWindow=void 0;function Pt(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}U.getFromWindow=Pt;function $t(e){let t=Pt(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}U.getFromWindowOrThrow=$t;function Ol(){return $t("document")}U.getDocumentOrThrow=Ol;function Nl(){return Pt("document")}U.getDocument=Nl;function Dl(){return $t("navigator")}U.getNavigatorOrThrow=Dl;function Ul(){return Pt("navigator")}U.getNavigator=Ul;function Bl(){return $t("location")}U.getLocationOrThrow=Bl;function Fl(){return Pt("location")}U.getLocation=Fl;function Gl(){return $t("crypto")}U.getCryptoOrThrow=Gl;function Hl(){return Pt("crypto")}U.getCrypto=Hl;function Vl(){return $t("localStorage")}U.getLocalStorageOrThrow=Vl;function jl(){return Pt("localStorage")}U.getLocalStorage=jl});var ra=ot(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.getWindowMetadata=void 0;var oa=Yr();function $l(){let e,t;try{e=oa.getDocumentOrThrow(),t=oa.getLocationOrThrow()}catch{return null}function o(){let m=e.getElementsByTagName("link"),p=[];for(let g=0;g<m.length;g++){let b=m[g],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let C=t.protocol+"//"+t.host;if(y.indexOf("/")===0)C+=y;else{let M=t.pathname.split("/");M.pop(),C+=M.join("/")+"/"+y}p.push(C)}else if(y.indexOf("//")===0){let C=t.protocol+y;p.push(C)}else p.push(y)}}return p}function r(...m){let p=e.getElementsByTagName("meta");for(let g=0;g<p.length;g++){let b=p[g],c=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?m.includes(y):!1);if(c.length&&c){let y=b.getAttribute("content");if(y)return y}}return""}function n(){let m=r("name","og:site_name","og:title","twitter:title");return m||(m=e.title),m}function i(){return r("description","og:description","twitter:description","keywords")}let a=n(),s=i(),l=t.origin,d=o();return{description:s,url:l,icons:d,name:a}}Ko.getWindowMetadata=$l});var ma={};Fr(ma,{BotInfo:()=>ca,BrowserInfo:()=>aa,NodeInfo:()=>sa,ReactNativeInfo:()=>da,SearchBotDeviceInfo:()=>la,browserName:()=>Yl,detect:()=>Jl,detectOS:()=>ua,getNodeVersion:()=>fa,parseUserAgent:()=>Xr});function Jl(e){return e?Xr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new da:typeof navigator<"u"?Xr(navigator.userAgent):fa()}function pa(e){return e!==""&&Kl.reduce(function(t,o){var r=o[0],n=o[1];if(t)return t;var i=n.exec(e);return!!i&&[r,i]},!1)}function Yl(e){var t=pa(e);return t?t[0]:null}function Xr(e){var t=pa(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new ca;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<na&&(n=zl(n,Xl(na-n.length))):n=[];var i=n.join("."),a=ua(e),s=Zl.exec(e);return s&&s[1]?new la(o,i,a,s[1]):new aa(o,i,a)}function ua(e){for(var t=0,o=ia.length;t<o;t++){var r=ia[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function fa(){var e=typeof process<"u"&&process.version;return e?new sa(process.version.slice(1)):null}function Xl(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var zl,aa,sa,la,ca,da,ql,Zl,na,Kl,ia,ha=zn(()=>{zl=function(){for(var e=0,t=0,o=arguments.length;t<o;t++)e+=arguments[t].length;for(var r=Array(e),n=0,t=0;t<o;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,n++)r[n]=i[a];return r},aa=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),sa=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),la=function(){function e(t,o,r,n){this.name=t,this.version=o,this.os=r,this.bot=n,this.type="bot-device"}return e}(),ca=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),da=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),ql=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Zl=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,na=3,Kl=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",ql]],ia=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]]});var en=ot(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.getClientMeta=S.getLocalStorage=S.getLocalStorageOrThrow=S.getCrypto=S.getCryptoOrThrow=S.getLocation=S.getLocationOrThrow=S.getNavigator=S.getNavigatorOrThrow=S.getDocument=S.getDocumentOrThrow=S.getFromWindowOrThrow=S.getFromWindow=S.isBrowser=S.isNode=S.isMobile=S.isIOS=S.isAndroid=S.detectOS=S.detectEnv=void 0;var ga=Zo(),Ql=ga.__importStar(ra()),Ie=ga.__importStar(Yr()),ec=(ha(),Gr(ma));function Qr(e){return(0,ec.detect)(e)}S.detectEnv=Qr;function Jo(){let e=Qr();return e&&e.os?e.os:void 0}S.detectOS=Jo;function ba(){let e=Jo();return e?e.toLowerCase().includes("android"):!1}S.isAndroid=ba;function ya(){let e=Jo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}S.isIOS=ya;function tc(){return Jo()?ba()||ya():!1}S.isMobile=tc;function va(){let e=Qr();return e&&e.name?e.name.toLowerCase()==="node":!1}S.isNode=va;function oc(){return!va()&&!!(0,S.getNavigator)()}S.isBrowser=oc;S.getFromWindow=Ie.getFromWindow;S.getFromWindowOrThrow=Ie.getFromWindowOrThrow;S.getDocumentOrThrow=Ie.getDocumentOrThrow;S.getDocument=Ie.getDocument;S.getNavigatorOrThrow=Ie.getNavigatorOrThrow;S.getNavigator=Ie.getNavigator;S.getLocationOrThrow=Ie.getLocationOrThrow;S.getLocation=Ie.getLocation;S.getCryptoOrThrow=Ie.getCryptoOrThrow;S.getCrypto=Ie.getCrypto;S.getLocalStorageOrThrow=Ie.getLocalStorageOrThrow;S.getLocalStorage=Ie.getLocalStorage;function rc(){return Ql.getWindowMetadata()}S.getClientMeta=rc});var wa={};Fr(wa,{safeJsonParse:()=>nc,safeJsonStringify:()=>ic});function nc(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return JSON.parse(e)}catch{return e}}function ic(e){return typeof e=="string"?e:JSON.stringify(e)}var Ca=zn(()=>{});var tn=ot(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.safeJsonStringify=zt.safeJsonParse=void 0;var ac=Zo(),Ea=ac.__importStar((Ca(),Gr(wa)));zt.safeJsonParse=Ea.safeJsonParse;zt.safeJsonStringify=Ea.safeJsonStringify});var rn=ot(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.removeLocal=dt.getLocal=dt.setLocal=void 0;var xa=tn(),on=en();function sc(e,t){let o=(0,xa.safeJsonStringify)(t),r=(0,on.getLocalStorage)();r&&r.setItem(e,o)}dt.setLocal=sc;function lc(e){let t=null,o=null,r=(0,on.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,xa.safeJsonParse)(o),t}dt.getLocal=lc;function cc(e){let t=(0,on.getLocalStorage)();t&&t.removeItem(e)}dt.removeLocal=cc});var La=ot(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.getMobileLinkRegistry=be.getMobileRegistryEntry=be.saveMobileLinkInfo=be.formatIOSMobile=be.mobileLinkChoiceKey=void 0;var dc=rn();be.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function pc(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}be.formatIOSMobile=pc;function uc(e){let t=e.href.split("?")[0];(0,dc.setLocal)(be.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}be.saveMobileLinkInfo=uc;function _a(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}be.getMobileRegistryEntry=_a;function fc(e,t){let o=e;return t&&(o=t.map(r=>_a(e,r)).filter(Boolean)),o}be.getMobileLinkRegistry=fc});var ka=ot(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.formatMobileRegistry=Ke.formatMobileRegistryEntry=Ke.getDappRegistryUrl=Ke.getWalletRegistryUrl=void 0;var Sa="https://registry.walletconnect.com";function mc(){return Sa+"/api/v2/wallets"}Ke.getWalletRegistryUrl=mc;function hc(){return Sa+"/api/v2/dapps"}Ke.getDappRegistryUrl=hc;function Pa(e,t="mobile"){var o;return{name:e.name||"",shortName:e.metadata.shortName||"",color:e.metadata.colors.primary||"",logo:(o=e.image_url.sm)!==null&&o!==void 0?o:"",universalLink:e[t].universal||"",deepLink:e[t].native||""}}Ke.formatMobileRegistryEntry=Pa;function gc(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Pa(o,t))}Ke.formatMobileRegistry=gc});var Aa=ot(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});var yo=Zo();yo.__exportStar(en(),kt);yo.__exportStar(tn(),kt);yo.__exportStar(rn(),kt);yo.__exportStar(La(),kt);yo.__exportStar(ka(),kt)});var D1={};Fr(D1,{AsExternalProvider:()=>ct,ConnectorManager:()=>qt,PrivyClient:()=>Kt,PrivyProvider:()=>bl,PrivyProxyProvider:()=>Ue,VERSION:()=>Oo,WalletConnector:()=>Ze,getAccessToken:()=>gl,usePrivy:()=>G});module.exports=Gr(D1);var hl=require("@ethersproject/providers"),Q=require("react");var _=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var Zn=L(require("axios")),De=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},Dt=class extends De{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},E=class extends De{constructor(o,r){super(o,r);this.type="client_error"}};var te=class extends De{constructor(o,r){super(o,r);this.type="connector_error"}},oe=e=>{if(e instanceof De)return e;if(!Zn.default.isAxiosError(e))return Te(e);if(!e.response)return new Dt("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new Dt(t||"ApiError",e.response.status,o||r,e)},Te=e=>e instanceof De?e:e instanceof Error?new E(e.message,e):new E(`Internal error: ${e}`);var Kn=()=>"/api/v1/sessions",Jn=()=>"/api/v1/sessions/logout",Yn=()=>"/api/v1/sessions/fork",Xn=()=>"/api/v1/sessions/fork/recover",Qn=()=>"/api/v1/siwe/init",ei=()=>"/api/v1/siwe/authenticate",ti=()=>"/api/v1/siwe/link",oi=()=>"/api/v1/passwordless/init",ri=()=>"/api/v1/passwordless/authenticate",ni=()=>"/api/v1/passwordless/link",ii=()=>"/api/v1/passwordless_sms/init",ai=()=>"/api/v1/passwordless_sms/authenticate",si=()=>"/api/v1/passwordless_sms/link",li=()=>"/api/v1/oauth/init",ci=()=>"/api/v1/oauth/authenticate",di=()=>"/api/v1/oauth/link",pi=()=>"/api/v1/siwe/unlink",ui=()=>"/api/v1/passwordless/unlink",fi=()=>"/api/v1/passwordless_sms/unlink",mi=()=>"/api/v1/oauth/unlink";var mo=class{constructor(t){this.meta={email:t}}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new E("Email and email code must be set prior to calling authenticate.");try{let t=ri(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw oe(t)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new E("Email and email code must be set prior to calling authenticate.");try{let t=ni();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw oe(t)}}async sendCodeEmail(t){if(!this.api)throw new E("Auth flow has no API instance");if(t&&(this.meta.email=t),!this.meta.email)throw new E("Email must be set when initialzing authentication.");try{let o=oi();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw oe(o)}}};var Ut=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new E("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new E("User denied confirmation during OAuth flow");try{let t=ci(),o=await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw oe(t)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new E("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new E("User denied confirmation during OAuth flow");try{let t=di();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw oe(t)}}async getAuthorizationUrl(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.provider)throw new E("Provider must be set when initialzing OAuth authentication.");try{let t=li();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw oe(t)}}};var Bt=class{constructor(t,o,r){this._meta={walletType:o,walletId:r},this.connectors=t,this.walletConnector=this.connectors.createWalletConnector(o,null,r)}get meta(){return{...this._meta,walletName:this.walletConnector.walletBranding.name,walletIcon:this.walletConnector.walletBranding.icon}}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(ei(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(t){throw oe(t)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(ti(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(t){throw oe(t)}}async promptConnect(){if(!this.api)throw new E("Auth flow has no API instance");let t=await this.walletConnector.connect({showPrompt:!0});return await this.buildSiweMessage(t),t}async sign(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.preparedMessage){let o=await this.walletConnector.connect({showPrompt:!1});await this.buildSiweMessage(o)}if(!this.preparedMessage)throw new E("Could not prepare SIWE message");let t=await this.walletConnector.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async buildSiweMessage(t){if(!this.api)throw new E("Auth flow has no API instance");let o=t.address,r=t.chainId,n=await this.api.post(Qn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var ho=class{constructor(t){this.meta={phoneNumber:t}}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new E("phone number and sms code must be set prior to calling authenticate.");try{let t=ai(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw oe(t)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new E("phone number and sms code must be set prior to calling authenticate.");try{let t=si();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw oe(t)}}async sendSmsCode(t){if(!this.api)throw new E("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),!this.meta.phoneNumber)throw new E("phone nNumber must be set when initialzing authentication.");try{let o=ii();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw oe(o)}}};var Na=require("@ethersproject/address");var hi="1.20.0";var gi="https://api.privy.io/v0",Io=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",Mo="4df5e2316331463a9130964bd6078dfa",bi=1e4,We=1400,Oo=hi;var Ft="privy:token",No="privy:refresh_token",go="privy:session_transfer_token",Do="privy:connectors",Hr="walletconnect",yi=3e4;var Vr=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},jr=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function kl(){return typeof window<"u"&&window.localStorage?new jr:new Vr}var z=kl();var Ei=L(require("@coinbase/wallet-sdk")),xi=require("@ethersproject/address");var bo=require("react/jsx-runtime"),Re=({style:e,...t})=>(0,bo.jsxs)("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,bo.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,bo.jsx)("path",{fillRule:"evenodd",clipRule:"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"})]});var wi=require("@ethersproject/address"),Ci=require("@ethersproject/providers");var vi=require("@ethersproject/logger");var Gt=class extends te{constructor(){super("Wallet timeout");this.type="wallet_error"}},_t=class extends te{constructor(){super("User rejected connection");this.type="wallet_error"}},qe=e=>{if(e instanceof te)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new Ht(e);return e.code===vi.ErrorCode.ACTION_REJECTED&&(t.details=xt.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new Ht(e):new te("Unknown connector error",e)},$r=class extends De{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},Ht=class extends $r{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(xt).find(l=>l.eipCode===r.code);this.details=n||xt.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=xt.E32002_CONNECTION_ALREADY_PENDING:this.details=xt.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=xt.E32002_WALLET_LOCKED))}},Al={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Tl={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Wl={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},xt={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Wl,...Tl},Lt={...Al,...xt};var Rl=12e4,zr=(e=new Gt,t=Rl)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),Ue=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(t,o)};this.setWalletProvider=t=>{this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new te(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),zr()]).catch(o=>{throw qe(o)})}},ct=class extends Ue{constructor(o){super(o)}},Uo=class extends Ue{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Ze=class{constructor(t,o,r){this.createSiweMessage=(t,o,r,n,i,a,s)=>`${r} wants you to sign in with your Ethereum account:
1
+ "use strict";var El=Object.create;var Ro=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var _l=Object.getOwnPropertyNames;var Ll=Object.getPrototypeOf,Sl=Object.prototype.hasOwnProperty;var zn=(e,t)=>()=>(e&&(t=e(e=0)),t);var ot=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Fr=(e,t)=>{for(var o in t)Ro(e,o,{get:t[o],enumerable:!0})},qn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _l(t))!Sl.call(e,n)&&n!==o&&Ro(e,n,{get:()=>t[n],enumerable:!(r=xl(t,n))||r.enumerable});return e};var L=(e,t,o)=>(o=e!=null?El(Ll(e)):{},qn(t||!e||!e.__esModule?Ro(o,"default",{value:e,enumerable:!0}):o,e)),Gr=e=>qn(Ro({},"__esModule",{value:!0}),e);var Zo=ot((Np,qo)=>{var Oi,Ni,Di,Ui,Bi,Fi,Gi,Hi,Vi,$o,Jr,ji,$i,zi,jt,qi,Zi,Ki,Ji,Yi,Xi,Qi,ea,ta,zo;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(o(t,o(r)))}):typeof qo=="object"&&typeof qo.exports=="object"?e(o(t,o(qo.exports))):e(o(t));function o(r,n){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(i,a){return r[i]=n?n(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])};Oi=function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function i(){this.constructor=r}r.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)},Ni=Object.assign||function(r){for(var n,i=1,a=arguments.length;i<a;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},Di=function(r,n){var i={};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&n.indexOf(a)<0&&(i[a]=r[a]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(r);s<a.length;s++)n.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(r,a[s])&&(i[a[s]]=r[a[s]]);return i},Ui=function(r,n,i,a){var s=arguments.length,l=s<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,i):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,n,i,a);else for(var h=r.length-1;h>=0;h--)(d=r[h])&&(l=(s<3?d(l):s>3?d(n,i,l):d(n,i))||l);return s>3&&l&&Object.defineProperty(n,i,l),l},Bi=function(r,n){return function(i,a){n(i,a,r)}},Fi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Gi=function(r,n,i,a){function s(l){return l instanceof i?l:new i(function(d){d(l)})}return new(i||(i=Promise))(function(l,d){function h(g){try{p(a.next(g))}catch(b){d(b)}}function m(g){try{p(a.throw(g))}catch(b){d(b)}}function p(g){g.done?l(g.value):s(g.value).then(h,m)}p((a=a.apply(r,n||[])).next())})},Hi=function(r,n){var i={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,s,l,d;return d={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function h(p){return function(g){return m([p,g])}}function m(p){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(l=p[0]&2?s.return:p[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,p[1])).done)return l;switch(s=0,l&&(p=[p[0]&2,l.value]),p[0]){case 0:case 1:l=p;break;case 4:return i.label++,{value:p[1],done:!1};case 5:i.label++,s=p[1],p=[0];continue;case 7:p=i.ops.pop(),i.trys.pop();continue;default:if(l=i.trys,!(l=l.length>0&&l[l.length-1])&&(p[0]===6||p[0]===2)){i=0;continue}if(p[0]===3&&(!l||p[1]>l[0]&&p[1]<l[3])){i.label=p[1];break}if(p[0]===6&&i.label<l[1]){i.label=l[1],l=p;break}if(l&&i.label<l[2]){i.label=l[2],i.ops.push(p);break}l[2]&&i.ops.pop(),i.trys.pop();continue}p=n.call(r,i)}catch(g){p=[6,g],s=0}finally{a=l=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},Vi=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&zo(n,r,i)},zo=Object.create?function(r,n,i,a){a===void 0&&(a=i);var s=Object.getOwnPropertyDescriptor(n,i);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(r,a,s)}:function(r,n,i,a){a===void 0&&(a=i),r[a]=n[i]},$o=function(r){var n=typeof Symbol=="function"&&Symbol.iterator,i=n&&r[n],a=0;if(i)return i.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&a>=r.length&&(r=void 0),{value:r&&r[a++],done:!r}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},Jr=function(r,n){var i=typeof Symbol=="function"&&r[Symbol.iterator];if(!i)return r;var a=i.call(r),s,l=[],d;try{for(;(n===void 0||n-- >0)&&!(s=a.next()).done;)l.push(s.value)}catch(h){d={error:h}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(d)throw d.error}}return l},ji=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(Jr(arguments[n]));return r},$i=function(){for(var r=0,n=0,i=arguments.length;n<i;n++)r+=arguments[n].length;for(var a=Array(r),s=0,n=0;n<i;n++)for(var l=arguments[n],d=0,h=l.length;d<h;d++,s++)a[s]=l[d];return a},zi=function(r,n,i){if(i||arguments.length===2)for(var a=0,s=n.length,l;a<s;a++)(l||!(a in n))&&(l||(l=Array.prototype.slice.call(n,0,a)),l[a]=n[a]);return r.concat(l||Array.prototype.slice.call(n))},jt=function(r){return this instanceof jt?(this.v=r,this):new jt(r)},qi=function(r,n,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=i.apply(r,n||[]),s,l=[];return s={},d("next"),d("throw"),d("return"),s[Symbol.asyncIterator]=function(){return this},s;function d(c){a[c]&&(s[c]=function(y){return new Promise(function(C,M){l.push([c,y,C,M])>1||h(c,y)})})}function h(c,y){try{m(a[c](y))}catch(C){b(l[0][3],C)}}function m(c){c.value instanceof jt?Promise.resolve(c.value.v).then(p,g):b(l[0][2],c)}function p(c){h("next",c)}function g(c){h("throw",c)}function b(c,y){c(y),l.shift(),l.length&&h(l[0][0],l[0][1])}},Zi=function(r){var n,i;return n={},a("next"),a("throw",function(s){throw s}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(s,l){n[s]=r[s]?function(d){return(i=!i)?{value:jt(r[s](d)),done:s==="return"}:l?l(d):d}:l}},Ki=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r[Symbol.asyncIterator],i;return n?n.call(r):(r=typeof $o=="function"?$o(r):r[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(l){i[l]=r[l]&&function(d){return new Promise(function(h,m){d=r[l](d),s(h,m,d.done,d.value)})}}function s(l,d,h,m){Promise.resolve(m).then(function(p){l({value:p,done:h})},d)}},Ji=function(r,n){return Object.defineProperty?Object.defineProperty(r,"raw",{value:n}):r.raw=n,r};var o=Object.create?function(r,n){Object.defineProperty(r,"default",{enumerable:!0,value:n})}:function(r,n){r.default=n};Yi=function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)i!=="default"&&Object.prototype.hasOwnProperty.call(r,i)&&zo(n,r,i);return o(n,r),n},Xi=function(r){return r&&r.__esModule?r:{default:r}},Qi=function(r,n,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!a:!n.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(r):a?a.value:n.get(r)},ea=function(r,n,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?r!==n||!s:!n.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(r,i):s?s.value=i:n.set(r,i),i},ta=function(r,n){if(n===null||typeof n!="object"&&typeof n!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?n===r:r.has(n)},e("__extends",Oi),e("__assign",Ni),e("__rest",Di),e("__decorate",Ui),e("__param",Bi),e("__metadata",Fi),e("__awaiter",Gi),e("__generator",Hi),e("__exportStar",Vi),e("__createBinding",zo),e("__values",$o),e("__read",Jr),e("__spread",ji),e("__spreadArrays",$i),e("__spreadArray",zi),e("__await",jt),e("__asyncGenerator",qi),e("__asyncDelegator",Zi),e("__asyncValues",Ki),e("__makeTemplateObject",Ji),e("__importStar",Yi),e("__importDefault",Xi),e("__classPrivateFieldGet",Qi),e("__classPrivateFieldSet",ea),e("__classPrivateFieldIn",ta)})});var Yr=ot(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.getLocalStorage=U.getLocalStorageOrThrow=U.getCrypto=U.getCryptoOrThrow=U.getLocation=U.getLocationOrThrow=U.getNavigator=U.getNavigatorOrThrow=U.getDocument=U.getDocumentOrThrow=U.getFromWindowOrThrow=U.getFromWindow=void 0;function Pt(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}U.getFromWindow=Pt;function $t(e){let t=Pt(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}U.getFromWindowOrThrow=$t;function Ol(){return $t("document")}U.getDocumentOrThrow=Ol;function Nl(){return Pt("document")}U.getDocument=Nl;function Dl(){return $t("navigator")}U.getNavigatorOrThrow=Dl;function Ul(){return Pt("navigator")}U.getNavigator=Ul;function Bl(){return $t("location")}U.getLocationOrThrow=Bl;function Fl(){return Pt("location")}U.getLocation=Fl;function Gl(){return $t("crypto")}U.getCryptoOrThrow=Gl;function Hl(){return Pt("crypto")}U.getCrypto=Hl;function Vl(){return $t("localStorage")}U.getLocalStorageOrThrow=Vl;function jl(){return Pt("localStorage")}U.getLocalStorage=jl});var ra=ot(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.getWindowMetadata=void 0;var oa=Yr();function $l(){let e,t;try{e=oa.getDocumentOrThrow(),t=oa.getLocationOrThrow()}catch{return null}function o(){let m=e.getElementsByTagName("link"),p=[];for(let g=0;g<m.length;g++){let b=m[g],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let C=t.protocol+"//"+t.host;if(y.indexOf("/")===0)C+=y;else{let M=t.pathname.split("/");M.pop(),C+=M.join("/")+"/"+y}p.push(C)}else if(y.indexOf("//")===0){let C=t.protocol+y;p.push(C)}else p.push(y)}}return p}function r(...m){let p=e.getElementsByTagName("meta");for(let g=0;g<p.length;g++){let b=p[g],c=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?m.includes(y):!1);if(c.length&&c){let y=b.getAttribute("content");if(y)return y}}return""}function n(){let m=r("name","og:site_name","og:title","twitter:title");return m||(m=e.title),m}function i(){return r("description","og:description","twitter:description","keywords")}let a=n(),s=i(),l=t.origin,d=o();return{description:s,url:l,icons:d,name:a}}Ko.getWindowMetadata=$l});var ma={};Fr(ma,{BotInfo:()=>ca,BrowserInfo:()=>aa,NodeInfo:()=>sa,ReactNativeInfo:()=>da,SearchBotDeviceInfo:()=>la,browserName:()=>Yl,detect:()=>Jl,detectOS:()=>ua,getNodeVersion:()=>fa,parseUserAgent:()=>Xr});function Jl(e){return e?Xr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new da:typeof navigator<"u"?Xr(navigator.userAgent):fa()}function pa(e){return e!==""&&Kl.reduce(function(t,o){var r=o[0],n=o[1];if(t)return t;var i=n.exec(e);return!!i&&[r,i]},!1)}function Yl(e){var t=pa(e);return t?t[0]:null}function Xr(e){var t=pa(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new ca;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<na&&(n=zl(n,Xl(na-n.length))):n=[];var i=n.join("."),a=ua(e),s=Zl.exec(e);return s&&s[1]?new la(o,i,a,s[1]):new aa(o,i,a)}function ua(e){for(var t=0,o=ia.length;t<o;t++){var r=ia[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function fa(){var e=typeof process<"u"&&process.version;return e?new sa(process.version.slice(1)):null}function Xl(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var zl,aa,sa,la,ca,da,ql,Zl,na,Kl,ia,ha=zn(()=>{zl=function(){for(var e=0,t=0,o=arguments.length;t<o;t++)e+=arguments[t].length;for(var r=Array(e),n=0,t=0;t<o;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,n++)r[n]=i[a];return r},aa=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),sa=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),la=function(){function e(t,o,r,n){this.name=t,this.version=o,this.os=r,this.bot=n,this.type="bot-device"}return e}(),ca=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),da=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),ql=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Zl=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,na=3,Kl=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",ql]],ia=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]]});var en=ot(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.getClientMeta=S.getLocalStorage=S.getLocalStorageOrThrow=S.getCrypto=S.getCryptoOrThrow=S.getLocation=S.getLocationOrThrow=S.getNavigator=S.getNavigatorOrThrow=S.getDocument=S.getDocumentOrThrow=S.getFromWindowOrThrow=S.getFromWindow=S.isBrowser=S.isNode=S.isMobile=S.isIOS=S.isAndroid=S.detectOS=S.detectEnv=void 0;var ga=Zo(),Ql=ga.__importStar(ra()),Ie=ga.__importStar(Yr()),ec=(ha(),Gr(ma));function Qr(e){return(0,ec.detect)(e)}S.detectEnv=Qr;function Jo(){let e=Qr();return e&&e.os?e.os:void 0}S.detectOS=Jo;function ba(){let e=Jo();return e?e.toLowerCase().includes("android"):!1}S.isAndroid=ba;function ya(){let e=Jo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}S.isIOS=ya;function tc(){return Jo()?ba()||ya():!1}S.isMobile=tc;function va(){let e=Qr();return e&&e.name?e.name.toLowerCase()==="node":!1}S.isNode=va;function oc(){return!va()&&!!(0,S.getNavigator)()}S.isBrowser=oc;S.getFromWindow=Ie.getFromWindow;S.getFromWindowOrThrow=Ie.getFromWindowOrThrow;S.getDocumentOrThrow=Ie.getDocumentOrThrow;S.getDocument=Ie.getDocument;S.getNavigatorOrThrow=Ie.getNavigatorOrThrow;S.getNavigator=Ie.getNavigator;S.getLocationOrThrow=Ie.getLocationOrThrow;S.getLocation=Ie.getLocation;S.getCryptoOrThrow=Ie.getCryptoOrThrow;S.getCrypto=Ie.getCrypto;S.getLocalStorageOrThrow=Ie.getLocalStorageOrThrow;S.getLocalStorage=Ie.getLocalStorage;function rc(){return Ql.getWindowMetadata()}S.getClientMeta=rc});var wa={};Fr(wa,{safeJsonParse:()=>nc,safeJsonStringify:()=>ic});function nc(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return JSON.parse(e)}catch{return e}}function ic(e){return typeof e=="string"?e:JSON.stringify(e)}var Ca=zn(()=>{});var tn=ot(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.safeJsonStringify=zt.safeJsonParse=void 0;var ac=Zo(),Ea=ac.__importStar((Ca(),Gr(wa)));zt.safeJsonParse=Ea.safeJsonParse;zt.safeJsonStringify=Ea.safeJsonStringify});var rn=ot(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.removeLocal=dt.getLocal=dt.setLocal=void 0;var xa=tn(),on=en();function sc(e,t){let o=(0,xa.safeJsonStringify)(t),r=(0,on.getLocalStorage)();r&&r.setItem(e,o)}dt.setLocal=sc;function lc(e){let t=null,o=null,r=(0,on.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,xa.safeJsonParse)(o),t}dt.getLocal=lc;function cc(e){let t=(0,on.getLocalStorage)();t&&t.removeItem(e)}dt.removeLocal=cc});var La=ot(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.getMobileLinkRegistry=be.getMobileRegistryEntry=be.saveMobileLinkInfo=be.formatIOSMobile=be.mobileLinkChoiceKey=void 0;var dc=rn();be.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function pc(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}be.formatIOSMobile=pc;function uc(e){let t=e.href.split("?")[0];(0,dc.setLocal)(be.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}be.saveMobileLinkInfo=uc;function _a(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}be.getMobileRegistryEntry=_a;function fc(e,t){let o=e;return t&&(o=t.map(r=>_a(e,r)).filter(Boolean)),o}be.getMobileLinkRegistry=fc});var ka=ot(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.formatMobileRegistry=Ke.formatMobileRegistryEntry=Ke.getDappRegistryUrl=Ke.getWalletRegistryUrl=void 0;var Sa="https://registry.walletconnect.com";function mc(){return Sa+"/api/v2/wallets"}Ke.getWalletRegistryUrl=mc;function hc(){return Sa+"/api/v2/dapps"}Ke.getDappRegistryUrl=hc;function Pa(e,t="mobile"){var o;return{name:e.name||"",shortName:e.metadata.shortName||"",color:e.metadata.colors.primary||"",logo:(o=e.image_url.sm)!==null&&o!==void 0?o:"",universalLink:e[t].universal||"",deepLink:e[t].native||""}}Ke.formatMobileRegistryEntry=Pa;function gc(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Pa(o,t))}Ke.formatMobileRegistry=gc});var Aa=ot(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});var yo=Zo();yo.__exportStar(en(),kt);yo.__exportStar(tn(),kt);yo.__exportStar(rn(),kt);yo.__exportStar(La(),kt);yo.__exportStar(ka(),kt)});var D1={};Fr(D1,{AsExternalProvider:()=>ct,ConnectorManager:()=>qt,PrivyClient:()=>Kt,PrivyProvider:()=>bl,PrivyProxyProvider:()=>Ue,VERSION:()=>Oo,WalletConnector:()=>Ze,getAccessToken:()=>gl,usePrivy:()=>G});module.exports=Gr(D1);var hl=require("@ethersproject/providers"),Q=require("react");var _=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var Zn=L(require("axios")),De=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},Dt=class extends De{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},E=class extends De{constructor(o,r){super(o,r);this.type="client_error"}};var te=class extends De{constructor(o,r){super(o,r);this.type="connector_error"}},oe=e=>{if(e instanceof De)return e;if(!Zn.default.isAxiosError(e))return Te(e);if(!e.response)return new Dt("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new Dt(t||"ApiError",e.response.status,o||r,e)},Te=e=>e instanceof De?e:e instanceof Error?new E(e.message,e):new E(`Internal error: ${e}`);var Kn=()=>"/api/v1/sessions",Jn=()=>"/api/v1/sessions/logout",Yn=()=>"/api/v1/sessions/fork",Xn=()=>"/api/v1/sessions/fork/recover",Qn=()=>"/api/v1/siwe/init",ei=()=>"/api/v1/siwe/authenticate",ti=()=>"/api/v1/siwe/link",oi=()=>"/api/v1/passwordless/init",ri=()=>"/api/v1/passwordless/authenticate",ni=()=>"/api/v1/passwordless/link",ii=()=>"/api/v1/passwordless_sms/init",ai=()=>"/api/v1/passwordless_sms/authenticate",si=()=>"/api/v1/passwordless_sms/link",li=()=>"/api/v1/oauth/init",ci=()=>"/api/v1/oauth/authenticate",di=()=>"/api/v1/oauth/link",pi=()=>"/api/v1/siwe/unlink",ui=()=>"/api/v1/passwordless/unlink",fi=()=>"/api/v1/passwordless_sms/unlink",mi=()=>"/api/v1/oauth/unlink";var mo=class{constructor(t){this.meta={email:t}}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new E("Email and email code must be set prior to calling authenticate.");try{let t=ri(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw oe(t)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new E("Email and email code must be set prior to calling authenticate.");try{let t=ni();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw oe(t)}}async sendCodeEmail(t){if(!this.api)throw new E("Auth flow has no API instance");if(t&&(this.meta.email=t),!this.meta.email)throw new E("Email must be set when initialzing authentication.");try{let o=oi();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw oe(o)}}};var Ut=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new E("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new E("User denied confirmation during OAuth flow");try{let t=ci(),o=await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw oe(t)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new E("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new E("User denied confirmation during OAuth flow");try{let t=di();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw oe(t)}}async getAuthorizationUrl(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.provider)throw new E("Provider must be set when initialzing OAuth authentication.");try{let t=li();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw oe(t)}}};var Bt=class{constructor(t,o,r){this._meta={walletType:o,walletId:r},this.connectors=t,this.walletConnector=this.connectors.createWalletConnector(o,null,r)}get meta(){return{...this._meta,walletName:this.walletConnector.walletBranding.name,walletIcon:this.walletConnector.walletBranding.icon}}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(ei(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(t){throw oe(t)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(ti(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(t){throw oe(t)}}async promptConnect(){if(!this.api)throw new E("Auth flow has no API instance");let t=await this.walletConnector.connect({showPrompt:!0});return await this.buildSiweMessage(t),t}async sign(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.preparedMessage){let o=await this.walletConnector.connect({showPrompt:!1});await this.buildSiweMessage(o)}if(!this.preparedMessage)throw new E("Could not prepare SIWE message");let t=await this.walletConnector.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async buildSiweMessage(t){if(!this.api)throw new E("Auth flow has no API instance");let o=t.address,r=t.chainId,n=await this.api.post(Qn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var ho=class{constructor(t){this.meta={phoneNumber:t}}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new E("phone number and sms code must be set prior to calling authenticate.");try{let t=ai(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw oe(t)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new E("phone number and sms code must be set prior to calling authenticate.");try{let t=si();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw oe(t)}}async sendSmsCode(t){if(!this.api)throw new E("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),!this.meta.phoneNumber)throw new E("phone nNumber must be set when initialzing authentication.");try{let o=ii();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw oe(o)}}};var Na=require("@ethersproject/address");var hi="1.20.1-beta.1";var gi="https://api.privy.io/v0",Io=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",Mo="4df5e2316331463a9130964bd6078dfa",bi=1e4,We=1400,Oo=hi;var Ft="privy:token",No="privy:refresh_token",go="privy:session_transfer_token",Do="privy:connectors",Hr="walletconnect",yi=3e4;var Vr=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},jr=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function kl(){return typeof window<"u"&&window.localStorage?new jr:new Vr}var z=kl();var Ei=L(require("@coinbase/wallet-sdk")),xi=require("@ethersproject/address");var bo=require("react/jsx-runtime"),Re=({style:e,...t})=>(0,bo.jsxs)("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,bo.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,bo.jsx)("path",{fillRule:"evenodd",clipRule:"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"})]});var wi=require("@ethersproject/address"),Ci=require("@ethersproject/providers");var vi=require("@ethersproject/logger");var Gt=class extends te{constructor(){super("Wallet timeout");this.type="wallet_error"}},_t=class extends te{constructor(){super("User rejected connection");this.type="wallet_error"}},qe=e=>{if(e instanceof te)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new Ht(e);return e.code===vi.ErrorCode.ACTION_REJECTED&&(t.details=xt.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new Ht(e):new te("Unknown connector error",e)},$r=class extends De{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},Ht=class extends $r{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(xt).find(l=>l.eipCode===r.code);this.details=n||xt.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=xt.E32002_CONNECTION_ALREADY_PENDING:this.details=xt.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=xt.E32002_WALLET_LOCKED))}},Al={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Tl={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Wl={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},xt={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Wl,...Tl},Lt={...Al,...xt};var Rl=12e4,zr=(e=new Gt,t=Rl)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),Ue=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(t,o)};this.setWalletProvider=t=>{this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new te(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),zr()]).catch(o=>{throw qe(o)})}},ct=class extends Ue{constructor(o){super(o)}},Uo=class extends Ue{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Ze=class{constructor(t,o,r){this.createSiweMessage=(t,o,r,n,i,a,s)=>`${r} wants you to sign in with your Ethereum account:
2
2
  ${o}
3
3
 
4
4
  ${s}
@@ -596,7 +596,7 @@ Resources:
596
596
  background-position: 0% 50%;
597
597
  }
598
598
  }
599
- `;var X=require("react/jsx-runtime"),hs=()=>{var m;let{user:e}=G(),{closePrivyModal:t}=W(),{data:o}=x(),r=re(e),{onSuccess:n,onFailure:i,callAuthOnSuccessOnClose:a}=o.createWallet,s=()=>{r?(n(r),t({shouldCallAuthOnSuccess:a})):i(new Error("Failed to create wallet"))},l="Your digital wallet",d="You\u2019re all set! This wallet is all yours and can only ever be accessed by you.",h=St(r.address);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{onClose:s}),(0,X.jsxs)(Yc,{children:[(0,X.jsxs)("div",{children:[(0,X.jsx)(ce,{title:l,description:d}),(0,X.jsxs)(Xc,{children:[(0,X.jsx)(ms,{}),(0,X.jsxs)(Qc,{children:[(0,X.jsx)("p",{children:((m=e==null?void 0:e.email)==null?void 0:m.address)||""}),(0,X.jsxs)(ed,{children:[(0,X.jsx)(td,{children:h})," ",(0,X.jsx)(dr,{color:"var(--privy-color-foreground)"})]})]})]}),(0,X.jsx)(od,{children:(0,X.jsx)(yr,{text:r.address,itemName:"Address"})})]}),(0,X.jsx)(me,{onClick:s,children:"I\u2019m all set"})]}),(0,X.jsx)(V,{protectedByPrivy:!0})]})},Yc=Wt.default.div`
599
+ `;var X=require("react/jsx-runtime"),hs=()=>{var m;let{user:e}=G(),{closePrivyModal:t}=W(),{data:o}=x(),r=re(e),{onSuccess:n,onFailure:i,callAuthOnSuccessOnClose:a}=o.createWallet,s=()=>{r?(n(r),t({shouldCallAuthOnSuccess:a})):i(new Error("Failed to create wallet"))},l="Your account",d="You\u2019re all set! This account is tied to a digital wallet. It can only ever be accessed by you.",h=St(r.address);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{onClose:s}),(0,X.jsxs)(Yc,{children:[(0,X.jsxs)("div",{children:[(0,X.jsx)(ce,{title:l,description:d}),(0,X.jsxs)(Xc,{children:[(0,X.jsx)(ms,{}),(0,X.jsxs)(Qc,{children:[(0,X.jsx)("p",{children:((m=e==null?void 0:e.email)==null?void 0:m.address)||""}),(0,X.jsxs)(ed,{children:[(0,X.jsx)(td,{children:h})," ",(0,X.jsx)(dr,{color:"var(--privy-color-foreground)"})]})]})]}),(0,X.jsx)(od,{children:(0,X.jsx)(yr,{text:r.address,itemName:"Address"})})]}),(0,X.jsx)(me,{onClick:s,children:"I\u2019m all set"})]}),(0,X.jsx)(V,{protectedByPrivy:!0})]})},Yc=Wt.default.div`
600
600
  display: flex;
601
601
  height: 100%;
602
602
  flex-direction: column;
@@ -866,7 +866,7 @@ Resources:
866
866
  transition: none;
867
867
  }
868
868
  `}
869
- `;var ro=require("react"),no=L(require("styled-components"));var ie=require("react/jsx-runtime"),xs=()=>{let{authenticated:e,getAccessToken:t,user:o}=G(),{walletProxy:r,refreshUser:n,closePrivyModal:i}=W(),{navigate:a,data:s}=x(),[l,d]=(0,ro.useState)(null),[h,m]=(0,ro.useState)(""),[p,g]=(0,ro.useState)(!1),{onFailure:b,callAuthOnSuccessOnClose:c}=s.createWallet;(0,ro.useEffect)(()=>{e||(a("LANDING"),b(new Error("User must be authenticated before creating a Privy wallet")))},[e]);let y=()=>{b(new Error("User exited before creating a wallet")),i({shouldCallAuthOnSuccess:c})},C=D=>{d(D)},M=re(o),A=M?()=>{g(!0),setTimeout(()=>{g(!1),a("EMBEDDED_WALLET_CREATED_SCREEN")},350)}:async()=>{g(!0);let D=await t();if(D&&l!==null)try{await(r==null?void 0:r.create({accessToken:D,recoveryPin:l})),m(""),await n()}catch(ee){m("An error has occurred, please try again."),console.error(ee)}finally{g(!1)}},N=!!M;return(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(k,{onClose:y}),(0,ie.jsxs)(Sd,{children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)(ce,{title:N?"Secure your PIN":"Set your PIN",description:N?"Don\u2019t lose this PIN. You\u2019ll need it to access your wallet across devices.":"To finish setting up your account, please set up a PIN."}),(0,ie.jsx)(wr,{onChange:C,disabled:p,readOnly:N,errorReasonOverride:h}),N?(0,ie.jsx)(yr,{text:l||""}):null]}),(0,ie.jsxs)(Pd,{children:[(0,ie.jsx)("h4",{children:"Why am I doing this?"}),N?(0,ie.jsx)("p",{children:"This PIN allows you to access your wallet across devices. If you lose it, there is no way to recover your wallet."}):(0,ie.jsx)("p",{children:"A digital wallet is being created on this device for your account. This PIN allows you to access it across devices."})]}),(0,ie.jsx)(kd,{loading:p||!r,disabled:!l,onClick:A,warn:N,hideAnimations:!M&&p,children:N?"I have saved my PIN":"Create your wallet"})]}),(0,ie.jsx)(V,{protectedByPrivy:!0})]})},Sd=no.default.div`
869
+ `;var ro=require("react"),no=L(require("styled-components"));var ie=require("react/jsx-runtime"),xs=()=>{let{authenticated:e,getAccessToken:t,user:o}=G(),{walletProxy:r,refreshUser:n,closePrivyModal:i}=W(),{navigate:a,data:s}=x(),[l,d]=(0,ro.useState)(null),[h,m]=(0,ro.useState)(""),[p,g]=(0,ro.useState)(!1),{onFailure:b,callAuthOnSuccessOnClose:c}=s.createWallet;(0,ro.useEffect)(()=>{e||(a("LANDING"),b(new Error("User must be authenticated before creating a Privy wallet")))},[e]);let y=()=>{b(new Error("User exited before creating a wallet")),i({shouldCallAuthOnSuccess:c})},C=D=>{d(D)},M=re(o),A=M?()=>{g(!0),setTimeout(()=>{g(!1),a("EMBEDDED_WALLET_CREATED_SCREEN")},350)}:async()=>{g(!0);let D=await t();if(D&&l!==null)try{await(r==null?void 0:r.create({accessToken:D,recoveryPin:l})),m(""),await n()}catch(ee){m("An error has occurred, please try again."),console.error(ee)}finally{g(!1)}},N=!!M;return(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(k,{onClose:y}),(0,ie.jsxs)(Sd,{children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)(ce,{title:N?"Secure your PIN":"Set your PIN",description:N?"Don\u2019t lose this PIN. You\u2019ll need it to access your full account on another device.":"You will need it when you sign in on a different device."}),(0,ie.jsx)(wr,{onChange:C,disabled:p,readOnly:N,errorReasonOverride:h}),N?(0,ie.jsx)(yr,{text:l||""}):null]}),(0,ie.jsxs)(Pd,{children:[(0,ie.jsx)("h4",{children:"Why am I doing this?"}),N?(0,ie.jsx)("p",{children:"This PIN allows you to access your account on another device. If you lose it, there is no way to recover your full account."}):(0,ie.jsx)("p",{children:"For your security, your account is tied to this device. Your PIN allows you to access it across devices."})]}),(0,ie.jsx)(kd,{loading:p||!r,disabled:!l,onClick:A,warn:N,hideAnimations:!M&&p,children:N?"I have saved my PIN":"Set PIN"})]}),(0,ie.jsx)(V,{protectedByPrivy:!0})]})},Sd=no.default.div`
870
870
  display: flex;
871
871
  height: 100%;
872
872
  flex-direction: column;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/react-auth",
3
- "version": "1.20.0",
3
+ "version": "1.20.1-beta.1",
4
4
  "description": "React client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",