@privy-io/react-auth 1.20.3-beta.1 → 1.20.3-beta.2
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 +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var El=Object.create;var go=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var _l=Object.getOwnPropertyNames;var Ll=Object.getPrototypeOf,Sl=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 _l(t))!Sl.call(e,n)&&n!==o&&go(e,n,{get:()=>t[n],enumerable:!(r=xl(t,n))||r.enumerable});return e};var Pl=(e,t,o)=>(o=e!=null?El(Ll(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((Gu,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 Ql(){return xt("document")}O.getDocumentOrThrow=Ql;function ec(){return ot("document")}O.getDocument=ec;function tc(){return xt("navigator")}O.getNavigatorOrThrow=tc;function oc(){return ot("navigator")}O.getNavigator=oc;function rc(){return xt("location")}O.getLocationOrThrow=rc;function nc(){return ot("location")}O.getLocation=nc;function ic(){return xt("crypto")}O.getCryptoOrThrow=ic;function ac(){return ot("crypto")}O.getCrypto=ac;function sc(){return xt("localStorage")}O.getLocalStorageOrThrow=sc;function lc(){return ot("localStorage")}O.getLocalStorage=lc});var Ui=Ie(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.getWindowMetadata=void 0;var Di=Ar();function cc(){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=cc});var Ki={};In(Ki,{BotInfo:()=>ji,BrowserInfo:()=>Gi,NodeInfo:()=>Hi,ReactNativeInfo:()=>$i,SearchBotDeviceInfo:()=>Vi,browserName:()=>hc,detect:()=>mc,detectOS:()=>qi,getNodeVersion:()=>Zi,parseUserAgent:()=>Tr});function mc(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!==""&&fc.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 hc(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=dc(n,gc(Bi-n.length))):n=[];var i=n.join("."),a=qi(e),s=uc.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 gc(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var dc,Gi,Hi,Vi,ji,$i,pc,uc,Bi,fc,Fi,Ji=Rn(()=>{dc=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}(),pc=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,uc=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Bi=3,fc=[["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",pc]],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(),bc=Yi.__importStar(Ui()),Ce=Yi.__importStar(Ar()),yc=(Ji(),On(Ki));function Wr(e){return(0,yc.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 vc(){return Ro()?Xi()||Qi():!1}x.isMobile=vc;function ea(){let e=Wr();return e&&e.name?e.name.toLowerCase()==="node":!1}x.isNode=ea;function wc(){return!ea()&&!!(0,x.getNavigator)()}x.isBrowser=wc;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 Cc(){return bc.getWindowMetadata()}x.getClientMeta=Cc});var ta={};In(ta,{safeJsonParse:()=>Ec,safeJsonStringify:()=>xc});function Ec(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 xc(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 _c=To(),ra=_c.__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 Lc(e,t){let o=(0,na.safeJsonStringify)(t),r=(0,Mr.getLocalStorage)();r&&r.setItem(e,o)}He.setLocal=Lc;function Sc(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=Sc;function Pc(e){let t=(0,Mr.getLocalStorage)();t&&t.removeItem(e)}He.removeLocal=Pc});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 kc=Or();ce.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function Ac(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=Ac;function Tc(e){let t=e.href.split("?")[0];(0,kc.setLocal)(ce.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}ce.saveMobileLinkInfo=Tc;function ia(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}ce.getMobileRegistryEntry=ia;function Wc(e,t){let o=e;return t&&(o=t.map(r=>ia(e,r)).filter(Boolean)),o}ce.getMobileLinkRegistry=Wc});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 Rc(){return sa+"/api/v2/wallets"}Pe.getWalletRegistryUrl=Rc;function Ic(){return sa+"/api/v2/dapps"}Pe.getDappRegistryUrl=Ic;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 Mc(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>la(o,t))}Pe.formatMobileRegistry=Mc});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 w2}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 kl 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(!kl.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 Nc}from"@ethersproject/address";var oi="1.20.3-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 Tl(){return typeof window<"u"&&window.localStorage?new Er:new Cr}var F=Tl();import Bl from"@coinbase/wallet-sdk";import{getAddress as Fl}from"@ethersproject/address";import{jsx as ai,jsxs as Wl}from"react/jsx-runtime";var we=({style:e,...t})=>Wl("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 Dl}from"@ethersproject/address";import{Web3Provider as Ul}from"@ethersproject/providers";import{ErrorCode as Rl}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===Rl.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))}},Il={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}},Ml={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}},Ol={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},...Ol,...Ml},Qe={...Il,...Ye};var Nl=12e4,_r=(e=new yt,t=Nl)=>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 El=Object.create;var go=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var _l=Object.getOwnPropertyNames;var Ll=Object.getPrototypeOf,Sl=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 _l(t))!Sl.call(e,n)&&n!==o&&go(e,n,{get:()=>t[n],enumerable:!(r=xl(t,n))||r.enumerable});return e};var Pl=(e,t,o)=>(o=e!=null?El(Ll(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((Gu,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 Ql(){return xt("document")}O.getDocumentOrThrow=Ql;function ec(){return ot("document")}O.getDocument=ec;function tc(){return xt("navigator")}O.getNavigatorOrThrow=tc;function oc(){return ot("navigator")}O.getNavigator=oc;function rc(){return xt("location")}O.getLocationOrThrow=rc;function nc(){return ot("location")}O.getLocation=nc;function ic(){return xt("crypto")}O.getCryptoOrThrow=ic;function ac(){return ot("crypto")}O.getCrypto=ac;function sc(){return xt("localStorage")}O.getLocalStorageOrThrow=sc;function lc(){return ot("localStorage")}O.getLocalStorage=lc});var Ui=Ie(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.getWindowMetadata=void 0;var Di=Ar();function cc(){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=cc});var Ki={};In(Ki,{BotInfo:()=>ji,BrowserInfo:()=>Gi,NodeInfo:()=>Hi,ReactNativeInfo:()=>$i,SearchBotDeviceInfo:()=>Vi,browserName:()=>hc,detect:()=>mc,detectOS:()=>qi,getNodeVersion:()=>Zi,parseUserAgent:()=>Tr});function mc(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!==""&&fc.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 hc(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=dc(n,gc(Bi-n.length))):n=[];var i=n.join("."),a=qi(e),s=uc.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 gc(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var dc,Gi,Hi,Vi,ji,$i,pc,uc,Bi,fc,Fi,Ji=Rn(()=>{dc=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}(),pc=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,uc=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Bi=3,fc=[["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",pc]],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(),bc=Yi.__importStar(Ui()),Ce=Yi.__importStar(Ar()),yc=(Ji(),On(Ki));function Wr(e){return(0,yc.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 vc(){return Ro()?Xi()||Qi():!1}x.isMobile=vc;function ea(){let e=Wr();return e&&e.name?e.name.toLowerCase()==="node":!1}x.isNode=ea;function wc(){return!ea()&&!!(0,x.getNavigator)()}x.isBrowser=wc;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 Cc(){return bc.getWindowMetadata()}x.getClientMeta=Cc});var ta={};In(ta,{safeJsonParse:()=>Ec,safeJsonStringify:()=>xc});function Ec(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 xc(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 _c=To(),ra=_c.__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 Lc(e,t){let o=(0,na.safeJsonStringify)(t),r=(0,Mr.getLocalStorage)();r&&r.setItem(e,o)}He.setLocal=Lc;function Sc(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=Sc;function Pc(e){let t=(0,Mr.getLocalStorage)();t&&t.removeItem(e)}He.removeLocal=Pc});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 kc=Or();ce.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function Ac(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=Ac;function Tc(e){let t=e.href.split("?")[0];(0,kc.setLocal)(ce.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}ce.saveMobileLinkInfo=Tc;function ia(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}ce.getMobileRegistryEntry=ia;function Wc(e,t){let o=e;return t&&(o=t.map(r=>ia(e,r)).filter(Boolean)),o}ce.getMobileLinkRegistry=Wc});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 Rc(){return sa+"/api/v2/wallets"}Pe.getWalletRegistryUrl=Rc;function Ic(){return sa+"/api/v2/dapps"}Pe.getDappRegistryUrl=Ic;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 Mc(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>la(o,t))}Pe.formatMobileRegistry=Mc});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 w2}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 kl 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(!kl.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 Nc}from"@ethersproject/address";var oi="1.20.3-beta.2";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 Tl(){return typeof window<"u"&&window.localStorage?new Er:new Cr}var F=Tl();import Bl from"@coinbase/wallet-sdk";import{getAddress as Fl}from"@ethersproject/address";import{jsx as ai,jsxs as Wl}from"react/jsx-runtime";var we=({style:e,...t})=>Wl("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 Dl}from"@ethersproject/address";import{Web3Provider as Ul}from"@ethersproject/providers";import{ErrorCode as Rl}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===Rl.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))}},Il={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}},Ml={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}},Ol={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},...Ol,...Ml},Qe={...Il,...Ye};var Nl=12e4,_r=(e=new yt,t=Nl)=>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}
|
|
@@ -1910,4 +1910,4 @@ Resources:
|
|
|
1910
1910
|
align-items: center;
|
|
1911
1911
|
justify-content: center;
|
|
1912
1912
|
height: 100%;
|
|
1913
|
-
`;import Ht from"tinycolor2";var fl="#FFFFFF",d2="#000000",p2=fl,u2="#1E1E1D";function f2(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function ft(e,t){let o=Math.max(0,Math.min(1,e.toHsl().l+t));return Ht({...e.toHsl(),l:o})}function ml({backgroundTheme:e,accentHex:t,successHex:o="#51BA81",errorHex:r="#EC6351",whiteHex:n=fl,blackHex:i=d2}){let a;switch(e){case"light":a=p2;break;case"dark":a=u2;break;default:a=e;break}let s=Ht(a),l=Ht(t),d=Ht(o),h=Ht(r),m=f2(s.getLuminance()),p=ft(s,m==="light"?-.04:.11),g=ft(s,m==="light"?-.88:.87),b=ft(s,m==="light"?-.77:.75),c=ft(s,m==="light"?-.43:.45).desaturate(m==="light"?60:20),y=ft(s,m==="light"?-.13:.25).desaturate(m==="light"?60:20),v=ft(l,.15),W=ft(l,-.06),P=Ht(l.getLuminance()>.5?i:n);return{colorScheme:m,background:s.toHslString(),background2:p.toHslString(),foreground:g.toHslString(),foreground2:b.toHslString(),foreground3:c.toHslString(),foreground4:y.toHslString(),accent:l.toHslString(),accentLight:v.toHslString(),accentDark:W.toHslString(),foregroundAccent:P.toHslString(),success:d.toHslString(),error:h.toHslString()}}var hl={appearance:{theme:"light",accentColor:"#676FFF"}};function kn(e,t){var r,n,i;return{id:e.id,name:e.name,showWalletLoginFirst:e.showWalletLoginFirst,allowlistConfig:e.allowlistConfig,walletAuth:e.walletAuth,emailAuth:e.emailAuth,smsAuth:e.smsAuth,googleOAuth:e.googleOAuth,twitterOAuth:e.twitterOAuth,discordOAuth:e.discordOAuth,githubOAuth:e.githubOAuth,termsAndConditionsUrl:e.termsAndConditionsUrl,privacyPolicyUrl:e.privacyPolicyUrl,appearance:{logo:((r=t==null?void 0:t.appearance)==null?void 0:r.logo)||e.logoUrl,palette:ml({backgroundTheme:((n=t==null?void 0:t.appearance)==null?void 0:n.theme)||hl.appearance.theme,accentHex:((i=t==null?void 0:t.appearance)==null?void 0:i.accentColor)||e.accentColor||hl.appearance.accentColor})}}}import{useRef as m2,useEffect as h2}from"react";var br=class{constructor(){this.callbacks={}}enqueue(t,o){this.callbacks[t]=o}dequeue(t,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${t} event: no event found for id ${o}`);switch(delete this.callbacks[o],t){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:connect":return r;case"privy:wallet:sign":return r;case"privy:wallet:recover":return r;default:throw new Error(`invalid wallet event type ${t}`)}}};import{jsx as v2}from"react/jsx-runtime";var g2=function(e){return()=>`id-${e++}`}(0);function b2(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function uo(e){return e.error!==void 0}var Vt=new br;function fo(e,t,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");return new Promise((n,i)=>{let a=g2();Vt.enqueue(a,{resolve:n,reject:i}),r.postMessage({id:a,event:e,data:t},"*")})}function y2(e){switch(e.event){case"privy:iframe:ready":let t=Vt.dequeue(e.event,e.id);return uo(e)?t.reject(new ze(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let o=Vt.dequeue(e.event,e.id);return uo(e)?o.reject(new ze(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let r=Vt.dequeue(e.event,e.id);return uo(e)?r.reject(new ze(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:sign":let n=Vt.dequeue(e.event,e.id);return uo(e)?n.reject(new ze(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:recover":let i=Vt.dequeue(e.event,e.id);return uo(e)?i.reject(new ze(e.error.type,e.error.message)):i.resolve(e.data)}}function gl(e){let t=m2(null);return h2(()=>{let o=t.current;if(!o)return;function r(s){s&&s.origin===e.origin&&b2(s.data)&&y2(s.data)}let n={create(s){return fo("privy:wallet:create",s,o)},connect(s){return fo("privy:wallet:connect",s,o)},sign(s){return fo("privy:wallet:sign",s,o)},recover(s){return fo("privy:wallet:recover",s,o)}};window.addEventListener("message",r);let i=()=>e.onLoad(n),a=(...s)=>{console.error("privy iframe failed to load: ",...s),e.onLoadFailed()};return di(()=>fo("privy:iframe:ready",{},o)).then(i,a),()=>window.removeEventListener("message",r)},[t.current]),v2("iframe",{ref:t,width:"0",height:"0",style:{visibility:"hidden"},src:_o(e.origin,`/apps/${e.appId}/embedded-wallets`)})}import{jsx as mo,jsxs as bl}from"react/jsx-runtime";function C2(e){return typeof e=="string"&&e.length===25}var ho;function E2(){if(!ho){let e=F.get(bt);return Promise.resolve(e||null)}return ho.getAccessToken()}var x2=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");!t||F.put(Zt,t)},_2=e=>{if(!C2(e.appId))throw new w("Cannot initialize the Privy provider with an invalid Privy app ID");return ho||(ho=new Qt({appId:e.appId,apiURL:bo})),mo(S2,{...e,client:ho})},L2=e=>{let t=!!(e!=null&&e.emailAuth),o=!!(e!=null&&e.smsAuth);return t&&o&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),o=!1),{email:t,sms:o,wallet:!!(e!=null&&e.walletAuth),google:!!(e!=null&&e.googleOAuth),twitter:!!(e!=null&&e.twitterOAuth),discord:!!(e!=null&&e.discordOAuth),github:!!(e!=null&&e.githubOAuth)}},S2=e=>{let t=e.client,[o,r]=te(!1),[n,i]=te(!1),[a,s]=te(!1),[l,d]=te(null),[h,m]=te(!1),[p,g]=te(null),[b,c]=te(!1),[y,v]=te(null),[W,P]=te({connecting:!1,connected:!1,connectError:null,connectRetry:E}),[R,I]=te(null),[z,fe]=te(null),[se,me]=te({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[j,B]=te(kn(se,e.config)),[N,G]=te(!1),[he,oe]=te({}),H=L2(j),ge=f=>{f&&g(f),r(!0)},jt=f=>{let u=e.createPrivyWalletOnLogin===!0;oe({login:{promptCreatePrivyWalletFlow:u}}),u&&G(!0),ge(f)};An(()=>{async function f(){let u=await t.getServerConfig();me(u),t.connectors.initialize(),be(),x2();let k=await t.getAuthenticatedUser();s(!!k),d(k),i(!0),c(!!k),yl()}f()},[t]),An(()=>{let f=kn(se,e.config);B(f)},[e.config,se]);let be=()=>{let f=new URLSearchParams(window.location.search),u=f.get("privy_oauth_code"),k=f.get("privy_oauth_state"),V=f.get("privy_oauth_provider");u&&k&&V&&(t.startAuthFlow(new ht(V,u,k)),jt("AWAITING_OAUTH_SCREEN"))},Je=f=>{f.promptConnect().then(()=>{P(u=>({...u,connected:!0,connectError:null}))}).catch(u=>{u instanceof Ee?console.error(u.cause?u.cause:u.message):console.error(u),P(k=>({...k,connectError:u}))}).finally(()=>{P(u=>({...u,connecting:!1}))})},yl=()=>{let u=new URLSearchParams(window.location.search).get("privy_wallet_client");if(!u)return;if(!t.connectors)throw new w("Connector not initialized");let k=new gt(t.connectors,u);t.startAuthFlow(k),Je(k),ge("AWAITING_CONNECTION")};An(()=>{n&&a&&l===null&&t.getAuthenticatedUser().then(d)},[n,a,l,t]);let yr=()=>{c(!0),ge("LINK_WALLET_SCREEN")},Tn=async(f,u)=>{let k=t.connectors.getConnectorByAddress(u);if(!k)return I(u),yr(),f;v({address:u,walletType:k.walletType,walletBranding:k.walletBranding,success:!1}),ge("SETTING_ACTIVE_WALLET");try{let V=await t.setActiveWallet(u,f);return v({address:u,walletType:k.walletType,walletBranding:k.walletBranding,success:!0}),V}catch(V){V instanceof w&&V.message==="Error setting the active wallet."&&(I(u),yr()),v({address:u,walletType:k.walletType,walletBranding:k.walletBranding,success:!1,error:V.message})}return f},vl={ready:n,authenticated:a,user:l,walletConnectors:t.connectors,linkWallet:yr,linkEmail:()=>{c(!0),ge("LINK_EMAIL_SCREEN")},linkPhone:()=>{c(!0),ge("LINK_PHONE_SCREEN")},linkGoogle:async()=>{await $t.initLoginWithOAuth("google")},linkTwitter:async()=>{await $t.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await $t.initLoginWithOAuth("discord")},linkGithub:async()=>{await $t.initLoginWithOAuth("github")},login:()=>{if(n&&a){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}jt()},logout:async()=>{await t.logout(),d(null),s(!1),g(null),c(!1),r(!1)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>t.connectors.getEthereumProvider(),getEthersProvider:()=>new w2(new et(t.connectors.getEthereumProvider())),getWeb3jsProvider:()=>new Co(t.connectors.getEthereumProvider()),unlinkWallet:async f=>{let u=await t.unlinkWallet(f);d(u);let k=u.linkedAccounts.filter(V=>V.type==="wallet");if(u&&k&&k.length>0){let V=k[0];u=await Tn(u,V.address)}return d(u),u},unlinkEmail:async f=>{let u=await t.unlinkEmail(f);return d(u),u},unlinkPhone:async f=>{let u=await t.unlinkPhone(f);return d(u),u},unlinkGoogle:async f=>{let u=await t.unlinkOAuth("google",f);return d(u),u},unlinkTwitter:async f=>{let u=await t.unlinkOAuth("twitter",f);return d(u),u},unlinkDiscord:async f=>{let u=await t.unlinkOAuth("discord",f);return d(u),u},unlinkGithub:async f=>{let u=await t.unlinkOAuth("github",f);return d(u),u},setActiveWallet:async f=>{if(!l)return;let u=await Tn(l,f);u&&d(u)},forkSession:()=>t.forkSession(),createWallet:()=>new Promise((f,u)=>{if(!a||!l){u(new Error("User must be authenticated before creating a Privy wallet"));return}if(J(l)){u(new Error("Only one Privy wallet per user is currently allowed"));return}G(!0),oe({createWallet:{onSuccess:f,onFailure:u,callAuthOnSuccessOnClose:!1}}),ge("EMBEDDED_WALLET_SCREEN")}),signMessage:(f,u)=>new Promise((k,V)=>{if(!a||!l){V(new Error("User must be authenticated before signing with a Privy wallet"));return}if(!J(l)){V(new Error("Must have a Privy wallet before signing"));return}if(typeof f!="string"||f.length<1){V(new Error("Message must be a non-empty string"));return}G(!0);let wl={message:f,onSuccess:k,onFailure:V,uiOptions:u||{}},Cl={onCompleteNavigateTo:"SIGN_REQUEST_SCREEN",onFailure:V};oe({signMessage:wl,connectWallet:Cl}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}),exportWallet:()=>new Promise((f,u)=>{if(!a||!l){u(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!J(l)){u(new Error("Must have a Privy wallet before exporting"));return}G(!0);let V={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:u},Wn={appId:e.appId,origin:bo,onSuccess:f,onFailure:u};oe({keyExport:Wn,connectWallet:V}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")})},$t=(()=>({isLinking:b,linkingHint:R,activeStatus:y,walletConnectionStatus:W,getAuthFlow:()=>t.authFlow,getAuthMeta:()=>{var f;return(f=t.authFlow)==null?void 0:f.meta},closePrivyModal:(f={shouldCallAuthOnSuccess:!0})=>{var k;let u=n&&a&&l;f.shouldCallAuthOnSuccess&&u&&((k=e.onSuccess)==null||k.call(e,l,h)),t.authFlow=void 0,I(null),g(null),c(!1),v(null),m(!1),r(!1)},initLoginWithWallet:(f,u)=>{if(!t.connectors)throw new w("Connector not initialized");f||(f="metamask");let k=new gt(t.connectors,f,u);t.startAuthFlow(k),P({connecting:!0,connected:!1,connectError:null,connectRetry:()=>Je(k)}),Je(k)},loginWithWallet:async()=>{if(!(t.authFlow instanceof gt))throw new w("Must initialize SIWE flow first.");let f,u;b?(f=await t.link(),f&&(f=Xt(f))):{user:f,isNewUser:u}=await t.authenticate(),d(f||l||null),m(u||!1),s(!0)},initLoginWithOAuth:async f=>{t.startAuthFlow(new ht(f));let u=await t.authFlow.getAuthorizationUrl();u&&u.url&&window.location.assign(u.url)},loginWithOAuth:async()=>{if(!(t.authFlow instanceof ht))throw new w("Must initialize OAuth flow before calling loginWithOAuth");let f,u;n&&a?f=await t.link():{user:f,isNewUser:u}=await t.authenticate(),d(f),m(u||!1),s(!0)},initLoginWithEmail:async f=>{let u=new zt(f);t.startAuthFlow(u),await u.sendCodeEmail()},initLoginWithSms:async f=>{let u=new qt(f);t.startAuthFlow(u),await u.sendSmsCode()},resendEmailCode:async()=>{var f;await((f=t.authFlow)==null?void 0:f.sendCodeEmail())},resendSmsCode:async()=>{var f;await((f=t.authFlow)==null?void 0:f.sendSmsCode())},loginWithCode:async f=>{if(t.authFlow instanceof zt)t.authFlow.meta.emailCode=f.trim();else if(t.authFlow instanceof qt)t.authFlow.meta.smsCode=f.trim();else throw new w("Must initialize a passwordless code flow first");let u,k;b?u=await t.link():{user:u,isNewUser:k}=await t.authenticate(),d(u||l||null),m(k||!1),s(!0)},refreshUser:async()=>{let f=await t.getAuthenticatedUser();return d(f),f},walletProxy:z}))();return bl($r.Provider,{value:vl,children:[e.children,bl(jr.Provider,{value:$t,children:[mo(ll,{theme:{...j.appearance.palette||{}}}),mo(hi,{appConfig:j,options:H,data:he,setModalData:oe,initialScreen:p,visible:o,authenticated:a,children:o&&mo(ul,{})}),N&&mo(gl,{appId:e.appId,origin:bo,onLoad:fe,onLoadFailed:()=>null})]})]})};export{et as AsExternalProvider,Yt as ConnectorManager,Qt as PrivyClient,_2 as PrivyProvider,Se as PrivyProxyProvider,vr as VERSION,Me as WalletConnector,E2 as getAccessToken,D as usePrivy};
|
|
1913
|
+
`;import Ht from"tinycolor2";var fl="#FFFFFF",d2="#000000",p2=fl,u2="#1E1E1D";function f2(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function ft(e,t){let o=Math.max(0,Math.min(1,e.toHsl().l+t));return Ht({...e.toHsl(),l:o})}function ml({backgroundTheme:e,accentHex:t,successHex:o="#51BA81",errorHex:r="#EC6351",whiteHex:n=fl,blackHex:i=d2}){let a;switch(e){case"light":a=p2;break;case"dark":a=u2;break;default:a=e;break}let s=Ht(a),l=Ht(t),d=Ht(o),h=Ht(r),m=f2(s.getLuminance()),p=ft(s,m==="light"?-.04:.11),g=ft(s,m==="light"?-.88:.87),b=ft(s,m==="light"?-.77:.75),c=ft(s,m==="light"?-.43:.45).desaturate(m==="light"?60:20),y=ft(s,m==="light"?-.13:.25).desaturate(m==="light"?60:20),v=ft(l,.15),W=ft(l,-.06),P=Ht(l.getLuminance()>.5?i:n);return{colorScheme:m,background:s.toHslString(),background2:p.toHslString(),foreground:g.toHslString(),foreground2:b.toHslString(),foreground3:c.toHslString(),foreground4:y.toHslString(),accent:l.toHslString(),accentLight:v.toHslString(),accentDark:W.toHslString(),foregroundAccent:P.toHslString(),success:d.toHslString(),error:h.toHslString()}}var hl={appearance:{theme:"light",accentColor:"#676FFF"}};function kn(e,t){var r,n,i;return{id:e.id,name:e.name,showWalletLoginFirst:e.showWalletLoginFirst,allowlistConfig:e.allowlistConfig,walletAuth:e.walletAuth,emailAuth:e.emailAuth,smsAuth:e.smsAuth,googleOAuth:e.googleOAuth,twitterOAuth:e.twitterOAuth,discordOAuth:e.discordOAuth,githubOAuth:e.githubOAuth,termsAndConditionsUrl:e.termsAndConditionsUrl,privacyPolicyUrl:e.privacyPolicyUrl,appearance:{logo:((r=t==null?void 0:t.appearance)==null?void 0:r.logo)||e.logoUrl,palette:ml({backgroundTheme:((n=t==null?void 0:t.appearance)==null?void 0:n.theme)||hl.appearance.theme,accentHex:((i=t==null?void 0:t.appearance)==null?void 0:i.accentColor)||e.accentColor||hl.appearance.accentColor})}}}import{useRef as m2,useEffect as h2}from"react";var br=class{constructor(){this.callbacks={}}enqueue(t,o){this.callbacks[t]=o}dequeue(t,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${t} event: no event found for id ${o}`);switch(delete this.callbacks[o],t){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:connect":return r;case"privy:wallet:sign":return r;case"privy:wallet:recover":return r;default:throw new Error(`invalid wallet event type ${t}`)}}};import{jsx as v2}from"react/jsx-runtime";var g2=function(e){return()=>`id-${e++}`}(0);function b2(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function uo(e){return e.error!==void 0}var Vt=new br;function fo(e,t,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");return new Promise((n,i)=>{let a=g2();Vt.enqueue(a,{resolve:n,reject:i}),r.postMessage({id:a,event:e,data:t},"*")})}function y2(e){switch(e.event){case"privy:iframe:ready":let t=Vt.dequeue(e.event,e.id);return uo(e)?t.reject(new ze(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let o=Vt.dequeue(e.event,e.id);return uo(e)?o.reject(new ze(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let r=Vt.dequeue(e.event,e.id);return uo(e)?r.reject(new ze(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:sign":let n=Vt.dequeue(e.event,e.id);return uo(e)?n.reject(new ze(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:recover":let i=Vt.dequeue(e.event,e.id);return uo(e)?i.reject(new ze(e.error.type,e.error.message)):i.resolve(e.data)}}function gl(e){let t=m2(null);return h2(()=>{let o=t.current;if(!o)return;function r(s){s&&s.origin===e.origin&&b2(s.data)&&y2(s.data)}let n={create(s){return fo("privy:wallet:create",s,o)},connect(s){return fo("privy:wallet:connect",s,o)},sign(s){return fo("privy:wallet:sign",s,o)},recover(s){return fo("privy:wallet:recover",s,o)}};window.addEventListener("message",r);let i=()=>e.onLoad(n),a=(...s)=>{console.error("privy iframe failed to load: ",...s),e.onLoadFailed()};return di(()=>fo("privy:iframe:ready",{},o)).then(i,a),()=>window.removeEventListener("message",r)},[t.current]),v2("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},src:_o(e.origin,`/apps/${e.appId}/embedded-wallets`)})}import{jsx as mo,jsxs as bl}from"react/jsx-runtime";function C2(e){return typeof e=="string"&&e.length===25}var ho;function E2(){if(!ho){let e=F.get(bt);return Promise.resolve(e||null)}return ho.getAccessToken()}var x2=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");!t||F.put(Zt,t)},_2=e=>{if(!C2(e.appId))throw new w("Cannot initialize the Privy provider with an invalid Privy app ID");return ho||(ho=new Qt({appId:e.appId,apiURL:bo})),mo(S2,{...e,client:ho})},L2=e=>{let t=!!(e!=null&&e.emailAuth),o=!!(e!=null&&e.smsAuth);return t&&o&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),o=!1),{email:t,sms:o,wallet:!!(e!=null&&e.walletAuth),google:!!(e!=null&&e.googleOAuth),twitter:!!(e!=null&&e.twitterOAuth),discord:!!(e!=null&&e.discordOAuth),github:!!(e!=null&&e.githubOAuth)}},S2=e=>{let t=e.client,[o,r]=te(!1),[n,i]=te(!1),[a,s]=te(!1),[l,d]=te(null),[h,m]=te(!1),[p,g]=te(null),[b,c]=te(!1),[y,v]=te(null),[W,P]=te({connecting:!1,connected:!1,connectError:null,connectRetry:E}),[R,I]=te(null),[z,fe]=te(null),[se,me]=te({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[j,B]=te(kn(se,e.config)),[N,G]=te(!1),[he,oe]=te({}),H=L2(j),ge=f=>{f&&g(f),r(!0)},jt=f=>{let u=e.createPrivyWalletOnLogin===!0;oe({login:{promptCreatePrivyWalletFlow:u}}),u&&G(!0),ge(f)};An(()=>{async function f(){let u=await t.getServerConfig();me(u),t.connectors.initialize(),be(),x2();let k=await t.getAuthenticatedUser();s(!!k),d(k),i(!0),c(!!k),yl()}f()},[t]),An(()=>{let f=kn(se,e.config);B(f)},[e.config,se]);let be=()=>{let f=new URLSearchParams(window.location.search),u=f.get("privy_oauth_code"),k=f.get("privy_oauth_state"),V=f.get("privy_oauth_provider");u&&k&&V&&(t.startAuthFlow(new ht(V,u,k)),jt("AWAITING_OAUTH_SCREEN"))},Je=f=>{f.promptConnect().then(()=>{P(u=>({...u,connected:!0,connectError:null}))}).catch(u=>{u instanceof Ee?console.error(u.cause?u.cause:u.message):console.error(u),P(k=>({...k,connectError:u}))}).finally(()=>{P(u=>({...u,connecting:!1}))})},yl=()=>{let u=new URLSearchParams(window.location.search).get("privy_wallet_client");if(!u)return;if(!t.connectors)throw new w("Connector not initialized");let k=new gt(t.connectors,u);t.startAuthFlow(k),Je(k),ge("AWAITING_CONNECTION")};An(()=>{n&&a&&l===null&&t.getAuthenticatedUser().then(d)},[n,a,l,t]);let yr=()=>{c(!0),ge("LINK_WALLET_SCREEN")},Tn=async(f,u)=>{let k=t.connectors.getConnectorByAddress(u);if(!k)return I(u),yr(),f;v({address:u,walletType:k.walletType,walletBranding:k.walletBranding,success:!1}),ge("SETTING_ACTIVE_WALLET");try{let V=await t.setActiveWallet(u,f);return v({address:u,walletType:k.walletType,walletBranding:k.walletBranding,success:!0}),V}catch(V){V instanceof w&&V.message==="Error setting the active wallet."&&(I(u),yr()),v({address:u,walletType:k.walletType,walletBranding:k.walletBranding,success:!1,error:V.message})}return f},vl={ready:n,authenticated:a,user:l,walletConnectors:t.connectors,linkWallet:yr,linkEmail:()=>{c(!0),ge("LINK_EMAIL_SCREEN")},linkPhone:()=>{c(!0),ge("LINK_PHONE_SCREEN")},linkGoogle:async()=>{await $t.initLoginWithOAuth("google")},linkTwitter:async()=>{await $t.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await $t.initLoginWithOAuth("discord")},linkGithub:async()=>{await $t.initLoginWithOAuth("github")},login:()=>{if(n&&a){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}jt()},logout:async()=>{await t.logout(),d(null),s(!1),g(null),c(!1),r(!1)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>t.connectors.getEthereumProvider(),getEthersProvider:()=>new w2(new et(t.connectors.getEthereumProvider())),getWeb3jsProvider:()=>new Co(t.connectors.getEthereumProvider()),unlinkWallet:async f=>{let u=await t.unlinkWallet(f);d(u);let k=u.linkedAccounts.filter(V=>V.type==="wallet");if(u&&k&&k.length>0){let V=k[0];u=await Tn(u,V.address)}return d(u),u},unlinkEmail:async f=>{let u=await t.unlinkEmail(f);return d(u),u},unlinkPhone:async f=>{let u=await t.unlinkPhone(f);return d(u),u},unlinkGoogle:async f=>{let u=await t.unlinkOAuth("google",f);return d(u),u},unlinkTwitter:async f=>{let u=await t.unlinkOAuth("twitter",f);return d(u),u},unlinkDiscord:async f=>{let u=await t.unlinkOAuth("discord",f);return d(u),u},unlinkGithub:async f=>{let u=await t.unlinkOAuth("github",f);return d(u),u},setActiveWallet:async f=>{if(!l)return;let u=await Tn(l,f);u&&d(u)},forkSession:()=>t.forkSession(),createWallet:()=>new Promise((f,u)=>{if(!a||!l){u(new Error("User must be authenticated before creating a Privy wallet"));return}if(J(l)){u(new Error("Only one Privy wallet per user is currently allowed"));return}G(!0),oe({createWallet:{onSuccess:f,onFailure:u,callAuthOnSuccessOnClose:!1}}),ge("EMBEDDED_WALLET_SCREEN")}),signMessage:(f,u)=>new Promise((k,V)=>{if(!a||!l){V(new Error("User must be authenticated before signing with a Privy wallet"));return}if(!J(l)){V(new Error("Must have a Privy wallet before signing"));return}if(typeof f!="string"||f.length<1){V(new Error("Message must be a non-empty string"));return}G(!0);let wl={message:f,onSuccess:k,onFailure:V,uiOptions:u||{}},Cl={onCompleteNavigateTo:"SIGN_REQUEST_SCREEN",onFailure:V};oe({signMessage:wl,connectWallet:Cl}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}),exportWallet:()=>new Promise((f,u)=>{if(!a||!l){u(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!J(l)){u(new Error("Must have a Privy wallet before exporting"));return}G(!0);let V={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:u},Wn={appId:e.appId,origin:bo,onSuccess:f,onFailure:u};oe({keyExport:Wn,connectWallet:V}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")})},$t=(()=>({isLinking:b,linkingHint:R,activeStatus:y,walletConnectionStatus:W,getAuthFlow:()=>t.authFlow,getAuthMeta:()=>{var f;return(f=t.authFlow)==null?void 0:f.meta},closePrivyModal:(f={shouldCallAuthOnSuccess:!0})=>{var k;let u=n&&a&&l;f.shouldCallAuthOnSuccess&&u&&((k=e.onSuccess)==null||k.call(e,l,h)),t.authFlow=void 0,I(null),g(null),c(!1),v(null),m(!1),r(!1)},initLoginWithWallet:(f,u)=>{if(!t.connectors)throw new w("Connector not initialized");f||(f="metamask");let k=new gt(t.connectors,f,u);t.startAuthFlow(k),P({connecting:!0,connected:!1,connectError:null,connectRetry:()=>Je(k)}),Je(k)},loginWithWallet:async()=>{if(!(t.authFlow instanceof gt))throw new w("Must initialize SIWE flow first.");let f,u;b?(f=await t.link(),f&&(f=Xt(f))):{user:f,isNewUser:u}=await t.authenticate(),d(f||l||null),m(u||!1),s(!0)},initLoginWithOAuth:async f=>{t.startAuthFlow(new ht(f));let u=await t.authFlow.getAuthorizationUrl();u&&u.url&&window.location.assign(u.url)},loginWithOAuth:async()=>{if(!(t.authFlow instanceof ht))throw new w("Must initialize OAuth flow before calling loginWithOAuth");let f,u;n&&a?f=await t.link():{user:f,isNewUser:u}=await t.authenticate(),d(f),m(u||!1),s(!0)},initLoginWithEmail:async f=>{let u=new zt(f);t.startAuthFlow(u),await u.sendCodeEmail()},initLoginWithSms:async f=>{let u=new qt(f);t.startAuthFlow(u),await u.sendSmsCode()},resendEmailCode:async()=>{var f;await((f=t.authFlow)==null?void 0:f.sendCodeEmail())},resendSmsCode:async()=>{var f;await((f=t.authFlow)==null?void 0:f.sendSmsCode())},loginWithCode:async f=>{if(t.authFlow instanceof zt)t.authFlow.meta.emailCode=f.trim();else if(t.authFlow instanceof qt)t.authFlow.meta.smsCode=f.trim();else throw new w("Must initialize a passwordless code flow first");let u,k;b?u=await t.link():{user:u,isNewUser:k}=await t.authenticate(),d(u||l||null),m(k||!1),s(!0)},refreshUser:async()=>{let f=await t.getAuthenticatedUser();return d(f),f},walletProxy:z}))();return bl($r.Provider,{value:vl,children:[e.children,bl(jr.Provider,{value:$t,children:[mo(ll,{theme:{...j.appearance.palette||{}}}),mo(hi,{appConfig:j,options:H,data:he,setModalData:oe,initialScreen:p,visible:o,authenticated:a,children:o&&mo(ul,{})}),N&&mo(gl,{appId:e.appId,origin:bo,onLoad:fe,onLoadFailed:()=>null})]})]})};export{et as AsExternalProvider,Yt as ConnectorManager,Qt as PrivyClient,_2 as PrivyProvider,Se as PrivyProxyProvider,vr as VERSION,Me as WalletConnector,E2 as getAccessToken,D as usePrivy};
|
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),Gr=(e,t)=>{for(var o in t)Ro(e,o,{get:t[o],enumerable:!0})},Kn=(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)):{},Kn(t||!e||!e.__esModule?Ro(o,"default",{value:e,enumerable:!0}):o,e)),Hr=e=>Kn(Ro({},"__esModule",{value:!0}),e);var Zo=ot((Np,qo)=>{var Di,Ui,Bi,Fi,Gi,Hi,Vi,ji,$i,$o,Yr,zi,qi,Zi,jt,Ki,Ji,Yi,Xi,Qi,ea,ta,oa,ra,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])};Di=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)},Ui=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},Bi=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},Fi=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},Gi=function(r,n){return function(i,a){n(i,a,r)}},Hi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Vi=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())})},ji=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)&&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.")},Yr=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},zi=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(Yr(arguments[n]));return r},qi=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)},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(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])}},Ji=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}},Yi=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)}},Xi=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};Qi=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},ea=function(r){return r&&r.__esModule?r:{default:r}},ta=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)},oa=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},ra=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",Di),e("__assign",Ui),e("__rest",Bi),e("__decorate",Fi),e("__param",Gi),e("__metadata",Hi),e("__awaiter",Vi),e("__generator",ji),e("__exportStar",$i),e("__createBinding",zo),e("__values",$o),e("__read",Yr),e("__spread",zi),e("__spreadArrays",qi),e("__spreadArray",Zi),e("__await",jt),e("__asyncGenerator",Ki),e("__asyncDelegator",Ji),e("__asyncValues",Yi),e("__makeTemplateObject",Xi),e("__importStar",Qi),e("__importDefault",ea),e("__classPrivateFieldGet",ta),e("__classPrivateFieldSet",oa),e("__classPrivateFieldIn",ra)})});var Xr=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 ia=ot(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.getWindowMetadata=void 0;var na=Xr();function $l(){let e,t;try{e=na.getDocumentOrThrow(),t=na.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 ga={};Gr(ga,{BotInfo:()=>pa,BrowserInfo:()=>la,NodeInfo:()=>ca,ReactNativeInfo:()=>ua,SearchBotDeviceInfo:()=>da,browserName:()=>Yl,detect:()=>Jl,detectOS:()=>ma,getNodeVersion:()=>ha,parseUserAgent:()=>Qr});function Jl(e){return e?Qr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ua:typeof navigator<"u"?Qr(navigator.userAgent):ha()}function fa(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=fa(e);return t?t[0]:null}function Qr(e){var t=fa(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new pa;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<aa&&(n=zl(n,Xl(aa-n.length))):n=[];var i=n.join("."),a=ma(e),s=Zl.exec(e);return s&&s[1]?new da(o,i,a,s[1]):new la(o,i,a)}function ma(e){for(var t=0,o=sa.length;t<o;t++){var r=sa[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function ha(){var e=typeof process<"u"&&process.version;return e?new ca(process.version.slice(1)):null}function Xl(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var zl,la,ca,da,pa,ua,ql,Zl,aa,Kl,sa,ba=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},la=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),ca=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),da=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}(),pa=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),ua=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)/,aa=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]],sa=[["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 tn=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 ya=Zo(),Ql=ya.__importStar(ia()),Ie=ya.__importStar(Xr()),ec=(ba(),Hr(ga));function en(e){return(0,ec.detect)(e)}S.detectEnv=en;function Jo(){let e=en();return e&&e.os?e.os:void 0}S.detectOS=Jo;function va(){let e=Jo();return e?e.toLowerCase().includes("android"):!1}S.isAndroid=va;function wa(){let e=Jo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}S.isIOS=wa;function tc(){return Jo()?va()||wa():!1}S.isMobile=tc;function Ca(){let e=en();return e&&e.name?e.name.toLowerCase()==="node":!1}S.isNode=Ca;function oc(){return!Ca()&&!!(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 Ea={};Gr(Ea,{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 xa=Zn(()=>{});var on=ot(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.safeJsonStringify=zt.safeJsonParse=void 0;var ac=Zo(),_a=ac.__importStar((xa(),Hr(Ea)));zt.safeJsonParse=_a.safeJsonParse;zt.safeJsonStringify=_a.safeJsonStringify});var nn=ot(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.removeLocal=dt.getLocal=dt.setLocal=void 0;var La=on(),rn=tn();function sc(e,t){let o=(0,La.safeJsonStringify)(t),r=(0,rn.getLocalStorage)();r&&r.setItem(e,o)}dt.setLocal=sc;function lc(e){let t=null,o=null,r=(0,rn.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,La.safeJsonParse)(o),t}dt.getLocal=lc;function cc(e){let t=(0,rn.getLocalStorage)();t&&t.removeItem(e)}dt.removeLocal=cc});var Pa=ot(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.getMobileLinkRegistry=be.getMobileRegistryEntry=be.saveMobileLinkInfo=be.formatIOSMobile=be.mobileLinkChoiceKey=void 0;var dc=nn();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 Sa(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}be.getMobileRegistryEntry=Sa;function fc(e,t){let o=e;return t&&(o=t.map(r=>Sa(e,r)).filter(Boolean)),o}be.getMobileLinkRegistry=fc});var Ta=ot(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.formatMobileRegistry=Ke.formatMobileRegistryEntry=Ke.getDappRegistryUrl=Ke.getWalletRegistryUrl=void 0;var ka="https://registry.walletconnect.com";function mc(){return ka+"/api/v2/wallets"}Ke.getWalletRegistryUrl=mc;function hc(){return ka+"/api/v2/dapps"}Ke.getDappRegistryUrl=hc;function Aa(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=Aa;function gc(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Aa(o,t))}Ke.formatMobileRegistry=gc});var Wa=ot(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});var yo=Zo();yo.__exportStar(tn(),kt);yo.__exportStar(on(),kt);yo.__exportStar(nn(),kt);yo.__exportStar(Pa(),kt);yo.__exportStar(Ta(),kt)});var D1={};Gr(D1,{AsExternalProvider:()=>ct,ConnectorManager:()=>qt,PrivyClient:()=>Kt,PrivyProvider:()=>bl,PrivyProxyProvider:()=>Ue,VERSION:()=>Oo,WalletConnector:()=>Ze,getAccessToken:()=>gl,usePrivy:()=>G});module.exports=Hr(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 Jn=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(!Jn.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 Yn=()=>"/api/v1/sessions",Xn=()=>"/api/v1/sessions/logout",Qn=()=>"/api/v1/sessions/fork",ei=()=>"/api/v1/sessions/fork/recover",ti=()=>"/api/v1/siwe/init",oi=()=>"/api/v1/siwe/authenticate",ri=()=>"/api/v1/siwe/link",ni=()=>"/api/v1/passwordless/init",ii=()=>"/api/v1/passwordless/authenticate",ai=()=>"/api/v1/passwordless/link",si=()=>"/api/v1/passwordless_sms/init",li=()=>"/api/v1/passwordless_sms/authenticate",ci=()=>"/api/v1/passwordless_sms/link",di=()=>"/api/v1/oauth/init",pi=()=>"/api/v1/oauth/authenticate",ui=()=>"/api/v1/oauth/link",fi=()=>"/api/v1/siwe/unlink",mi=()=>"/api/v1/passwordless/unlink",hi=()=>"/api/v1/passwordless_sms/unlink",gi=()=>"/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=ii(),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=ai();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=ni();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=pi(),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=ui();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=di();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(oi(),{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(ri(),{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(ti(),{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=li(),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=ci();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=si();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw oe(o)}}};var Ua=require("@ethersproject/address");var bi="1.20.3-beta.1";var yi="https://api.privy.io/v0",Io=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",Mo="4df5e2316331463a9130964bd6078dfa",vi=1e4,We=1400,Oo=bi;var Ft="privy:token",No="privy:refresh_token",go="privy:session_transfer_token",Do="privy:connectors",Vr="walletconnect",wi=3e4;var jr=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)}},$r=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 $r:new jr}var z=kl();var _i=L(require("@coinbase/wallet-sdk")),Li=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 Ei=require("@ethersproject/address"),xi=require("@ethersproject/providers");var Ci=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===Ci.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)},zr=class extends De{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},Ht=class extends zr{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,qr=(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),qr()]).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),Gr=(e,t)=>{for(var o in t)Ro(e,o,{get:t[o],enumerable:!0})},Kn=(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)):{},Kn(t||!e||!e.__esModule?Ro(o,"default",{value:e,enumerable:!0}):o,e)),Hr=e=>Kn(Ro({},"__esModule",{value:!0}),e);var Zo=ot((Np,qo)=>{var Di,Ui,Bi,Fi,Gi,Hi,Vi,ji,$i,$o,Yr,zi,qi,Zi,jt,Ki,Ji,Yi,Xi,Qi,ea,ta,oa,ra,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])};Di=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)},Ui=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},Bi=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},Fi=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},Gi=function(r,n){return function(i,a){n(i,a,r)}},Hi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Vi=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())})},ji=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)&&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.")},Yr=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},zi=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(Yr(arguments[n]));return r},qi=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)},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(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])}},Ji=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}},Yi=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)}},Xi=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};Qi=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},ea=function(r){return r&&r.__esModule?r:{default:r}},ta=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)},oa=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},ra=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",Di),e("__assign",Ui),e("__rest",Bi),e("__decorate",Fi),e("__param",Gi),e("__metadata",Hi),e("__awaiter",Vi),e("__generator",ji),e("__exportStar",$i),e("__createBinding",zo),e("__values",$o),e("__read",Yr),e("__spread",zi),e("__spreadArrays",qi),e("__spreadArray",Zi),e("__await",jt),e("__asyncGenerator",Ki),e("__asyncDelegator",Ji),e("__asyncValues",Yi),e("__makeTemplateObject",Xi),e("__importStar",Qi),e("__importDefault",ea),e("__classPrivateFieldGet",ta),e("__classPrivateFieldSet",oa),e("__classPrivateFieldIn",ra)})});var Xr=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 ia=ot(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.getWindowMetadata=void 0;var na=Xr();function $l(){let e,t;try{e=na.getDocumentOrThrow(),t=na.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 ga={};Gr(ga,{BotInfo:()=>pa,BrowserInfo:()=>la,NodeInfo:()=>ca,ReactNativeInfo:()=>ua,SearchBotDeviceInfo:()=>da,browserName:()=>Yl,detect:()=>Jl,detectOS:()=>ma,getNodeVersion:()=>ha,parseUserAgent:()=>Qr});function Jl(e){return e?Qr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ua:typeof navigator<"u"?Qr(navigator.userAgent):ha()}function fa(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=fa(e);return t?t[0]:null}function Qr(e){var t=fa(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new pa;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<aa&&(n=zl(n,Xl(aa-n.length))):n=[];var i=n.join("."),a=ma(e),s=Zl.exec(e);return s&&s[1]?new da(o,i,a,s[1]):new la(o,i,a)}function ma(e){for(var t=0,o=sa.length;t<o;t++){var r=sa[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function ha(){var e=typeof process<"u"&&process.version;return e?new ca(process.version.slice(1)):null}function Xl(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var zl,la,ca,da,pa,ua,ql,Zl,aa,Kl,sa,ba=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},la=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),ca=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),da=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}(),pa=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),ua=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)/,aa=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]],sa=[["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 tn=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 ya=Zo(),Ql=ya.__importStar(ia()),Ie=ya.__importStar(Xr()),ec=(ba(),Hr(ga));function en(e){return(0,ec.detect)(e)}S.detectEnv=en;function Jo(){let e=en();return e&&e.os?e.os:void 0}S.detectOS=Jo;function va(){let e=Jo();return e?e.toLowerCase().includes("android"):!1}S.isAndroid=va;function wa(){let e=Jo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}S.isIOS=wa;function tc(){return Jo()?va()||wa():!1}S.isMobile=tc;function Ca(){let e=en();return e&&e.name?e.name.toLowerCase()==="node":!1}S.isNode=Ca;function oc(){return!Ca()&&!!(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 Ea={};Gr(Ea,{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 xa=Zn(()=>{});var on=ot(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.safeJsonStringify=zt.safeJsonParse=void 0;var ac=Zo(),_a=ac.__importStar((xa(),Hr(Ea)));zt.safeJsonParse=_a.safeJsonParse;zt.safeJsonStringify=_a.safeJsonStringify});var nn=ot(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.removeLocal=dt.getLocal=dt.setLocal=void 0;var La=on(),rn=tn();function sc(e,t){let o=(0,La.safeJsonStringify)(t),r=(0,rn.getLocalStorage)();r&&r.setItem(e,o)}dt.setLocal=sc;function lc(e){let t=null,o=null,r=(0,rn.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,La.safeJsonParse)(o),t}dt.getLocal=lc;function cc(e){let t=(0,rn.getLocalStorage)();t&&t.removeItem(e)}dt.removeLocal=cc});var Pa=ot(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.getMobileLinkRegistry=be.getMobileRegistryEntry=be.saveMobileLinkInfo=be.formatIOSMobile=be.mobileLinkChoiceKey=void 0;var dc=nn();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 Sa(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}be.getMobileRegistryEntry=Sa;function fc(e,t){let o=e;return t&&(o=t.map(r=>Sa(e,r)).filter(Boolean)),o}be.getMobileLinkRegistry=fc});var Ta=ot(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.formatMobileRegistry=Ke.formatMobileRegistryEntry=Ke.getDappRegistryUrl=Ke.getWalletRegistryUrl=void 0;var ka="https://registry.walletconnect.com";function mc(){return ka+"/api/v2/wallets"}Ke.getWalletRegistryUrl=mc;function hc(){return ka+"/api/v2/dapps"}Ke.getDappRegistryUrl=hc;function Aa(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=Aa;function gc(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Aa(o,t))}Ke.formatMobileRegistry=gc});var Wa=ot(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});var yo=Zo();yo.__exportStar(tn(),kt);yo.__exportStar(on(),kt);yo.__exportStar(nn(),kt);yo.__exportStar(Pa(),kt);yo.__exportStar(Ta(),kt)});var D1={};Gr(D1,{AsExternalProvider:()=>ct,ConnectorManager:()=>qt,PrivyClient:()=>Kt,PrivyProvider:()=>bl,PrivyProxyProvider:()=>Ue,VERSION:()=>Oo,WalletConnector:()=>Ze,getAccessToken:()=>gl,usePrivy:()=>G});module.exports=Hr(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 Jn=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(!Jn.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 Yn=()=>"/api/v1/sessions",Xn=()=>"/api/v1/sessions/logout",Qn=()=>"/api/v1/sessions/fork",ei=()=>"/api/v1/sessions/fork/recover",ti=()=>"/api/v1/siwe/init",oi=()=>"/api/v1/siwe/authenticate",ri=()=>"/api/v1/siwe/link",ni=()=>"/api/v1/passwordless/init",ii=()=>"/api/v1/passwordless/authenticate",ai=()=>"/api/v1/passwordless/link",si=()=>"/api/v1/passwordless_sms/init",li=()=>"/api/v1/passwordless_sms/authenticate",ci=()=>"/api/v1/passwordless_sms/link",di=()=>"/api/v1/oauth/init",pi=()=>"/api/v1/oauth/authenticate",ui=()=>"/api/v1/oauth/link",fi=()=>"/api/v1/siwe/unlink",mi=()=>"/api/v1/passwordless/unlink",hi=()=>"/api/v1/passwordless_sms/unlink",gi=()=>"/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=ii(),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=ai();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=ni();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=pi(),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=ui();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=di();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(oi(),{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(ri(),{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(ti(),{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=li(),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=ci();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=si();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw oe(o)}}};var Ua=require("@ethersproject/address");var bi="1.20.3-beta.2";var yi="https://api.privy.io/v0",Io=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",Mo="4df5e2316331463a9130964bd6078dfa",vi=1e4,We=1400,Oo=bi;var Ft="privy:token",No="privy:refresh_token",go="privy:session_transfer_token",Do="privy:connectors",Vr="walletconnect",wi=3e4;var jr=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)}},$r=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 $r:new jr}var z=kl();var _i=L(require("@coinbase/wallet-sdk")),Li=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 Ei=require("@ethersproject/address"),xi=require("@ethersproject/providers");var Ci=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===Ci.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)},zr=class extends De{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},Ht=class extends zr{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,qr=(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),qr()]).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}
|
|
@@ -1910,4 +1910,4 @@ Resources:
|
|
|
1910
1910
|
align-items: center;
|
|
1911
1911
|
justify-content: center;
|
|
1912
1912
|
height: 100%;
|
|
1913
|
-
`;var Nt=L(require("tinycolor2")),dl="#FFFFFF",S1="#000000",P1=dl,k1="#1E1E1D";function A1(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function Ot(e,t){let o=Math.max(0,Math.min(1,e.toHsl().l+t));return(0,Nt.default)({...e.toHsl(),l:o})}function pl({backgroundTheme:e,accentHex:t,successHex:o="#51BA81",errorHex:r="#EC6351",whiteHex:n=dl,blackHex:i=S1}){let a;switch(e){case"light":a=P1;break;case"dark":a=k1;break;default:a=e;break}let s=(0,Nt.default)(a),l=(0,Nt.default)(t),d=(0,Nt.default)(o),h=(0,Nt.default)(r),m=A1(s.getLuminance()),p=Ot(s,m==="light"?-.04:.11),g=Ot(s,m==="light"?-.88:.87),b=Ot(s,m==="light"?-.77:.75),c=Ot(s,m==="light"?-.43:.45).desaturate(m==="light"?60:20),y=Ot(s,m==="light"?-.13:.25).desaturate(m==="light"?60:20),C=Ot(l,.15),M=Ot(l,-.06),A=(0,Nt.default)(l.getLuminance()>.5?i:n);return{colorScheme:m,background:s.toHslString(),background2:p.toHslString(),foreground:g.toHslString(),foreground2:b.toHslString(),foreground3:c.toHslString(),foreground4:y.toHslString(),accent:l.toHslString(),accentLight:C.toHslString(),accentDark:M.toHslString(),foregroundAccent:A.toHslString(),success:d.toHslString(),error:h.toHslString()}}var ul={appearance:{theme:"light",accentColor:"#676FFF"}};function $n(e,t){var r,n,i;return{id:e.id,name:e.name,showWalletLoginFirst:e.showWalletLoginFirst,allowlistConfig:e.allowlistConfig,walletAuth:e.walletAuth,emailAuth:e.emailAuth,smsAuth:e.smsAuth,googleOAuth:e.googleOAuth,twitterOAuth:e.twitterOAuth,discordOAuth:e.discordOAuth,githubOAuth:e.githubOAuth,termsAndConditionsUrl:e.termsAndConditionsUrl,privacyPolicyUrl:e.privacyPolicyUrl,appearance:{logo:((r=t==null?void 0:t.appearance)==null?void 0:r.logo)||e.logoUrl,palette:pl({backgroundTheme:((n=t==null?void 0:t.appearance)==null?void 0:n.theme)||ul.appearance.theme,accentHex:((i=t==null?void 0:t.appearance)==null?void 0:i.accentColor)||e.accentColor||ul.appearance.accentColor})}}}var Br=require("react");var Ur=class{constructor(){this.callbacks={}}enqueue(t,o){this.callbacks[t]=o}dequeue(t,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${t} event: no event found for id ${o}`);switch(delete this.callbacks[o],t){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:connect":return r;case"privy:wallet:sign":return r;case"privy:wallet:recover":return r;default:throw new Error(`invalid wallet event type ${t}`)}}};var ml=require("react/jsx-runtime"),T1=function(e){return()=>`id-${e++}`}(0);function W1(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Ao(e){return e.error!==void 0}var po=new Ur;function To(e,t,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");return new Promise((n,i)=>{let a=T1();po.enqueue(a,{resolve:n,reject:i}),r.postMessage({id:a,event:e,data:t},"*")})}function R1(e){switch(e.event){case"privy:iframe:ready":let t=po.dequeue(e.event,e.id);return Ao(e)?t.reject(new bt(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let o=po.dequeue(e.event,e.id);return Ao(e)?o.reject(new bt(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let r=po.dequeue(e.event,e.id);return Ao(e)?r.reject(new bt(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:sign":let n=po.dequeue(e.event,e.id);return Ao(e)?n.reject(new bt(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:recover":let i=po.dequeue(e.event,e.id);return Ao(e)?i.reject(new bt(e.error.type,e.error.message)):i.resolve(e.data)}}function fl(e){let t=(0,Br.useRef)(null);return(0,Br.useEffect)(()=>{let o=t.current;if(!o)return;function r(s){s&&s.origin===e.origin&&W1(s.data)&&R1(s.data)}let n={create(s){return To("privy:wallet:create",s,o)},connect(s){return To("privy:wallet:connect",s,o)},sign(s){return To("privy:wallet:sign",s,o)},recover(s){return To("privy:wallet:recover",s,o)}};window.addEventListener("message",r);let i=()=>e.onLoad(n),a=(...s)=>{console.error("privy iframe failed to load: ",...s),e.onLoadFailed()};return Ti(()=>To("privy:iframe:ready",{},o)).then(i,a),()=>window.removeEventListener("message",r)},[t.current]),(0,ml.jsx)("iframe",{ref:t,width:"0",height:"0",style:{visibility:"hidden"},src:Go(e.origin,`/apps/${e.appId}/embedded-wallets`)})}var lt=require("react/jsx-runtime");function I1(e){return typeof e=="string"&&e.length===25}var Wo;function gl(){if(!Wo){let e=z.get(Ft);return Promise.resolve(e||null)}return Wo.getAccessToken()}var M1=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");!t||z.put(go,t)},bl=e=>{if(!I1(e.appId))throw new E("Cannot initialize the Privy provider with an invalid Privy app ID");return Wo||(Wo=new Kt({appId:e.appId,apiURL:Io})),(0,lt.jsx)(N1,{...e,client:Wo})},O1=e=>{let t=!!(e!=null&&e.emailAuth),o=!!(e!=null&&e.smsAuth);return t&&o&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),o=!1),{email:t,sms:o,wallet:!!(e!=null&&e.walletAuth),google:!!(e!=null&&e.googleOAuth),twitter:!!(e!=null&&e.twitterOAuth),discord:!!(e!=null&&e.discordOAuth),github:!!(e!=null&&e.githubOAuth)}},N1=e=>{let t=e.client,[o,r]=(0,Q.useState)(!1),[n,i]=(0,Q.useState)(!1),[a,s]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null),[h,m]=(0,Q.useState)(!1),[p,g]=(0,Q.useState)(null),[b,c]=(0,Q.useState)(!1),[y,C]=(0,Q.useState)(null),[M,A]=(0,Q.useState)({connecting:!1,connected:!1,connectError:null,connectRetry:_}),[N,D]=(0,Q.useState)(null),[ee,Le]=(0,Q.useState)(null),[ge,Se]=(0,Q.useState)({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[J,j]=(0,Q.useState)($n(ge,e.config)),[H,q]=(0,Q.useState)(!1),[Pe,ue]=(0,Q.useState)({}),Z=O1(J),ke=f=>{f&&g(f),r(!0)},uo=f=>{let u=e.createPrivyWalletOnLogin===!0;ue({login:{promptCreatePrivyWalletFlow:u}}),u&&q(!0),ke(f)};(0,Q.useEffect)(()=>{async function f(){let u=await t.getServerConfig();Se(u),t.connectors.initialize(),Ae(),M1();let T=await t.getAuthenticatedUser();s(!!T),d(T),i(!0),c(!!T),yl()}f()},[t]),(0,Q.useEffect)(()=>{let f=$n(ge,e.config);j(f)},[e.config,ge]);let Ae=()=>{let f=new URLSearchParams(window.location.search),u=f.get("privy_oauth_code"),T=f.get("privy_oauth_state"),K=f.get("privy_oauth_provider");u&&T&&K&&(t.startAuthFlow(new Ut(K,u,T)),uo("AWAITING_OAUTH_SCREEN"))},Et=f=>{f.promptConnect().then(()=>{A(u=>({...u,connected:!0,connectError:null}))}).catch(u=>{u instanceof De?console.error(u.cause?u.cause:u.message):console.error(u),A(T=>({...T,connectError:u}))}).finally(()=>{A(u=>({...u,connecting:!1}))})},yl=()=>{let u=new URLSearchParams(window.location.search).get("privy_wallet_client");if(!u)return;if(!t.connectors)throw new E("Connector not initialized");let T=new Bt(t.connectors,u);t.startAuthFlow(T),Et(T),ke("AWAITING_CONNECTION")};(0,Q.useEffect)(()=>{n&&a&&l===null&&t.getAuthenticatedUser().then(d)},[n,a,l,t]);let Fr=()=>{c(!0),ke("LINK_WALLET_SCREEN")},zn=async(f,u)=>{let T=t.connectors.getConnectorByAddress(u);if(!T)return D(u),Fr(),f;C({address:u,walletType:T.walletType,walletBranding:T.walletBranding,success:!1}),ke("SETTING_ACTIVE_WALLET");try{let K=await t.setActiveWallet(u,f);return C({address:u,walletType:T.walletType,walletBranding:T.walletBranding,success:!0}),K}catch(K){K instanceof E&&K.message==="Error setting the active wallet."&&(D(u),Fr()),C({address:u,walletType:T.walletType,walletBranding:T.walletBranding,success:!1,error:K.message})}return f},vl={ready:n,authenticated:a,user:l,walletConnectors:t.connectors,linkWallet:Fr,linkEmail:()=>{c(!0),ke("LINK_EMAIL_SCREEN")},linkPhone:()=>{c(!0),ke("LINK_PHONE_SCREEN")},linkGoogle:async()=>{await fo.initLoginWithOAuth("google")},linkTwitter:async()=>{await fo.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await fo.initLoginWithOAuth("discord")},linkGithub:async()=>{await fo.initLoginWithOAuth("github")},login:()=>{if(n&&a){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}uo()},logout:async()=>{await t.logout(),d(null),s(!1),g(null),c(!1),r(!1)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>t.connectors.getEthereumProvider(),getEthersProvider:()=>new hl.Web3Provider(new ct(t.connectors.getEthereumProvider())),getWeb3jsProvider:()=>new Uo(t.connectors.getEthereumProvider()),unlinkWallet:async f=>{let u=await t.unlinkWallet(f);d(u);let T=u.linkedAccounts.filter(K=>K.type==="wallet");if(u&&T&&T.length>0){let K=T[0];u=await zn(u,K.address)}return d(u),u},unlinkEmail:async f=>{let u=await t.unlinkEmail(f);return d(u),u},unlinkPhone:async f=>{let u=await t.unlinkPhone(f);return d(u),u},unlinkGoogle:async f=>{let u=await t.unlinkOAuth("google",f);return d(u),u},unlinkTwitter:async f=>{let u=await t.unlinkOAuth("twitter",f);return d(u),u},unlinkDiscord:async f=>{let u=await t.unlinkOAuth("discord",f);return d(u),u},unlinkGithub:async f=>{let u=await t.unlinkOAuth("github",f);return d(u),u},setActiveWallet:async f=>{if(!l)return;let u=await zn(l,f);u&&d(u)},forkSession:()=>t.forkSession(),createWallet:()=>new Promise((f,u)=>{if(!a||!l){u(new Error("User must be authenticated before creating a Privy wallet"));return}if(re(l)){u(new Error("Only one Privy wallet per user is currently allowed"));return}q(!0),ue({createWallet:{onSuccess:f,onFailure:u,callAuthOnSuccessOnClose:!1}}),ke("EMBEDDED_WALLET_SCREEN")}),signMessage:(f,u)=>new Promise((T,K)=>{if(!a||!l){K(new Error("User must be authenticated before signing with a Privy wallet"));return}if(!re(l)){K(new Error("Must have a Privy wallet before signing"));return}if(typeof f!="string"||f.length<1){K(new Error("Message must be a non-empty string"));return}q(!0);let wl={message:f,onSuccess:T,onFailure:K,uiOptions:u||{}},Cl={onCompleteNavigateTo:"SIGN_REQUEST_SCREEN",onFailure:K};ue({signMessage:wl,connectWallet:Cl}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")}),exportWallet:()=>new Promise((f,u)=>{if(!a||!l){u(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!re(l)){u(new Error("Must have a Privy wallet before exporting"));return}q(!0);let K={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:u},qn={appId:e.appId,origin:Io,onSuccess:f,onFailure:u};ue({keyExport:qn,connectWallet:K}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")})},fo=(()=>({isLinking:b,linkingHint:N,activeStatus:y,walletConnectionStatus:M,getAuthFlow:()=>t.authFlow,getAuthMeta:()=>{var f;return(f=t.authFlow)==null?void 0:f.meta},closePrivyModal:(f={shouldCallAuthOnSuccess:!0})=>{var T;let u=n&&a&&l;f.shouldCallAuthOnSuccess&&u&&((T=e.onSuccess)==null||T.call(e,l,h)),t.authFlow=void 0,D(null),g(null),c(!1),C(null),m(!1),r(!1)},initLoginWithWallet:(f,u)=>{if(!t.connectors)throw new E("Connector not initialized");f||(f="metamask");let T=new Bt(t.connectors,f,u);t.startAuthFlow(T),A({connecting:!0,connected:!1,connectError:null,connectRetry:()=>Et(T)}),Et(T)},loginWithWallet:async()=>{if(!(t.authFlow instanceof Bt))throw new E("Must initialize SIWE flow first.");let f,u;b?(f=await t.link(),f&&(f=wo(f))):{user:f,isNewUser:u}=await t.authenticate(),d(f||l||null),m(u||!1),s(!0)},initLoginWithOAuth:async f=>{t.startAuthFlow(new Ut(f));let u=await t.authFlow.getAuthorizationUrl();u&&u.url&&window.location.assign(u.url)},loginWithOAuth:async()=>{if(!(t.authFlow instanceof Ut))throw new E("Must initialize OAuth flow before calling loginWithOAuth");let f,u;n&&a?f=await t.link():{user:f,isNewUser:u}=await t.authenticate(),d(f),m(u||!1),s(!0)},initLoginWithEmail:async f=>{let u=new mo(f);t.startAuthFlow(u),await u.sendCodeEmail()},initLoginWithSms:async f=>{let u=new ho(f);t.startAuthFlow(u),await u.sendSmsCode()},resendEmailCode:async()=>{var f;await((f=t.authFlow)==null?void 0:f.sendCodeEmail())},resendSmsCode:async()=>{var f;await((f=t.authFlow)==null?void 0:f.sendSmsCode())},loginWithCode:async f=>{if(t.authFlow instanceof mo)t.authFlow.meta.emailCode=f.trim();else if(t.authFlow instanceof ho)t.authFlow.meta.smsCode=f.trim();else throw new E("Must initialize a passwordless code flow first");let u,T;b?u=await t.link():{user:u,isNewUser:T}=await t.authenticate(),d(u||l||null),m(T||!1),s(!0)},refreshUser:async()=>{let f=await t.getAuthenticatedUser();return d(f),f},walletProxy:ee}))();return(0,lt.jsxs)(mn.Provider,{value:vl,children:[e.children,(0,lt.jsxs)(fn.Provider,{value:fo,children:[(0,lt.jsx)(al,{theme:{...J.appearance.palette||{}}}),(0,lt.jsx)(Ni,{appConfig:J,options:Z,data:Pe,setModalData:ue,initialScreen:p,visible:o,authenticated:a,children:o&&(0,lt.jsx)(cl,{})}),H&&(0,lt.jsx)(fl,{appId:e.appId,origin:Io,onLoad:Le,onLoadFailed:()=>null})]})]})};0&&(module.exports={AsExternalProvider,ConnectorManager,PrivyClient,PrivyProvider,PrivyProxyProvider,VERSION,WalletConnector,getAccessToken,usePrivy});
|
|
1913
|
+
`;var Nt=L(require("tinycolor2")),dl="#FFFFFF",S1="#000000",P1=dl,k1="#1E1E1D";function A1(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function Ot(e,t){let o=Math.max(0,Math.min(1,e.toHsl().l+t));return(0,Nt.default)({...e.toHsl(),l:o})}function pl({backgroundTheme:e,accentHex:t,successHex:o="#51BA81",errorHex:r="#EC6351",whiteHex:n=dl,blackHex:i=S1}){let a;switch(e){case"light":a=P1;break;case"dark":a=k1;break;default:a=e;break}let s=(0,Nt.default)(a),l=(0,Nt.default)(t),d=(0,Nt.default)(o),h=(0,Nt.default)(r),m=A1(s.getLuminance()),p=Ot(s,m==="light"?-.04:.11),g=Ot(s,m==="light"?-.88:.87),b=Ot(s,m==="light"?-.77:.75),c=Ot(s,m==="light"?-.43:.45).desaturate(m==="light"?60:20),y=Ot(s,m==="light"?-.13:.25).desaturate(m==="light"?60:20),C=Ot(l,.15),M=Ot(l,-.06),A=(0,Nt.default)(l.getLuminance()>.5?i:n);return{colorScheme:m,background:s.toHslString(),background2:p.toHslString(),foreground:g.toHslString(),foreground2:b.toHslString(),foreground3:c.toHslString(),foreground4:y.toHslString(),accent:l.toHslString(),accentLight:C.toHslString(),accentDark:M.toHslString(),foregroundAccent:A.toHslString(),success:d.toHslString(),error:h.toHslString()}}var ul={appearance:{theme:"light",accentColor:"#676FFF"}};function $n(e,t){var r,n,i;return{id:e.id,name:e.name,showWalletLoginFirst:e.showWalletLoginFirst,allowlistConfig:e.allowlistConfig,walletAuth:e.walletAuth,emailAuth:e.emailAuth,smsAuth:e.smsAuth,googleOAuth:e.googleOAuth,twitterOAuth:e.twitterOAuth,discordOAuth:e.discordOAuth,githubOAuth:e.githubOAuth,termsAndConditionsUrl:e.termsAndConditionsUrl,privacyPolicyUrl:e.privacyPolicyUrl,appearance:{logo:((r=t==null?void 0:t.appearance)==null?void 0:r.logo)||e.logoUrl,palette:pl({backgroundTheme:((n=t==null?void 0:t.appearance)==null?void 0:n.theme)||ul.appearance.theme,accentHex:((i=t==null?void 0:t.appearance)==null?void 0:i.accentColor)||e.accentColor||ul.appearance.accentColor})}}}var Br=require("react");var Ur=class{constructor(){this.callbacks={}}enqueue(t,o){this.callbacks[t]=o}dequeue(t,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${t} event: no event found for id ${o}`);switch(delete this.callbacks[o],t){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:connect":return r;case"privy:wallet:sign":return r;case"privy:wallet:recover":return r;default:throw new Error(`invalid wallet event type ${t}`)}}};var ml=require("react/jsx-runtime"),T1=function(e){return()=>`id-${e++}`}(0);function W1(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Ao(e){return e.error!==void 0}var po=new Ur;function To(e,t,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");return new Promise((n,i)=>{let a=T1();po.enqueue(a,{resolve:n,reject:i}),r.postMessage({id:a,event:e,data:t},"*")})}function R1(e){switch(e.event){case"privy:iframe:ready":let t=po.dequeue(e.event,e.id);return Ao(e)?t.reject(new bt(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let o=po.dequeue(e.event,e.id);return Ao(e)?o.reject(new bt(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let r=po.dequeue(e.event,e.id);return Ao(e)?r.reject(new bt(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:sign":let n=po.dequeue(e.event,e.id);return Ao(e)?n.reject(new bt(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:recover":let i=po.dequeue(e.event,e.id);return Ao(e)?i.reject(new bt(e.error.type,e.error.message)):i.resolve(e.data)}}function fl(e){let t=(0,Br.useRef)(null);return(0,Br.useEffect)(()=>{let o=t.current;if(!o)return;function r(s){s&&s.origin===e.origin&&W1(s.data)&&R1(s.data)}let n={create(s){return To("privy:wallet:create",s,o)},connect(s){return To("privy:wallet:connect",s,o)},sign(s){return To("privy:wallet:sign",s,o)},recover(s){return To("privy:wallet:recover",s,o)}};window.addEventListener("message",r);let i=()=>e.onLoad(n),a=(...s)=>{console.error("privy iframe failed to load: ",...s),e.onLoadFailed()};return Ti(()=>To("privy:iframe:ready",{},o)).then(i,a),()=>window.removeEventListener("message",r)},[t.current]),(0,ml.jsx)("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},src:Go(e.origin,`/apps/${e.appId}/embedded-wallets`)})}var lt=require("react/jsx-runtime");function I1(e){return typeof e=="string"&&e.length===25}var Wo;function gl(){if(!Wo){let e=z.get(Ft);return Promise.resolve(e||null)}return Wo.getAccessToken()}var M1=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");!t||z.put(go,t)},bl=e=>{if(!I1(e.appId))throw new E("Cannot initialize the Privy provider with an invalid Privy app ID");return Wo||(Wo=new Kt({appId:e.appId,apiURL:Io})),(0,lt.jsx)(N1,{...e,client:Wo})},O1=e=>{let t=!!(e!=null&&e.emailAuth),o=!!(e!=null&&e.smsAuth);return t&&o&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),o=!1),{email:t,sms:o,wallet:!!(e!=null&&e.walletAuth),google:!!(e!=null&&e.googleOAuth),twitter:!!(e!=null&&e.twitterOAuth),discord:!!(e!=null&&e.discordOAuth),github:!!(e!=null&&e.githubOAuth)}},N1=e=>{let t=e.client,[o,r]=(0,Q.useState)(!1),[n,i]=(0,Q.useState)(!1),[a,s]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null),[h,m]=(0,Q.useState)(!1),[p,g]=(0,Q.useState)(null),[b,c]=(0,Q.useState)(!1),[y,C]=(0,Q.useState)(null),[M,A]=(0,Q.useState)({connecting:!1,connected:!1,connectError:null,connectRetry:_}),[N,D]=(0,Q.useState)(null),[ee,Le]=(0,Q.useState)(null),[ge,Se]=(0,Q.useState)({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[J,j]=(0,Q.useState)($n(ge,e.config)),[H,q]=(0,Q.useState)(!1),[Pe,ue]=(0,Q.useState)({}),Z=O1(J),ke=f=>{f&&g(f),r(!0)},uo=f=>{let u=e.createPrivyWalletOnLogin===!0;ue({login:{promptCreatePrivyWalletFlow:u}}),u&&q(!0),ke(f)};(0,Q.useEffect)(()=>{async function f(){let u=await t.getServerConfig();Se(u),t.connectors.initialize(),Ae(),M1();let T=await t.getAuthenticatedUser();s(!!T),d(T),i(!0),c(!!T),yl()}f()},[t]),(0,Q.useEffect)(()=>{let f=$n(ge,e.config);j(f)},[e.config,ge]);let Ae=()=>{let f=new URLSearchParams(window.location.search),u=f.get("privy_oauth_code"),T=f.get("privy_oauth_state"),K=f.get("privy_oauth_provider");u&&T&&K&&(t.startAuthFlow(new Ut(K,u,T)),uo("AWAITING_OAUTH_SCREEN"))},Et=f=>{f.promptConnect().then(()=>{A(u=>({...u,connected:!0,connectError:null}))}).catch(u=>{u instanceof De?console.error(u.cause?u.cause:u.message):console.error(u),A(T=>({...T,connectError:u}))}).finally(()=>{A(u=>({...u,connecting:!1}))})},yl=()=>{let u=new URLSearchParams(window.location.search).get("privy_wallet_client");if(!u)return;if(!t.connectors)throw new E("Connector not initialized");let T=new Bt(t.connectors,u);t.startAuthFlow(T),Et(T),ke("AWAITING_CONNECTION")};(0,Q.useEffect)(()=>{n&&a&&l===null&&t.getAuthenticatedUser().then(d)},[n,a,l,t]);let Fr=()=>{c(!0),ke("LINK_WALLET_SCREEN")},zn=async(f,u)=>{let T=t.connectors.getConnectorByAddress(u);if(!T)return D(u),Fr(),f;C({address:u,walletType:T.walletType,walletBranding:T.walletBranding,success:!1}),ke("SETTING_ACTIVE_WALLET");try{let K=await t.setActiveWallet(u,f);return C({address:u,walletType:T.walletType,walletBranding:T.walletBranding,success:!0}),K}catch(K){K instanceof E&&K.message==="Error setting the active wallet."&&(D(u),Fr()),C({address:u,walletType:T.walletType,walletBranding:T.walletBranding,success:!1,error:K.message})}return f},vl={ready:n,authenticated:a,user:l,walletConnectors:t.connectors,linkWallet:Fr,linkEmail:()=>{c(!0),ke("LINK_EMAIL_SCREEN")},linkPhone:()=>{c(!0),ke("LINK_PHONE_SCREEN")},linkGoogle:async()=>{await fo.initLoginWithOAuth("google")},linkTwitter:async()=>{await fo.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await fo.initLoginWithOAuth("discord")},linkGithub:async()=>{await fo.initLoginWithOAuth("github")},login:()=>{if(n&&a){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}uo()},logout:async()=>{await t.logout(),d(null),s(!1),g(null),c(!1),r(!1)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>t.connectors.getEthereumProvider(),getEthersProvider:()=>new hl.Web3Provider(new ct(t.connectors.getEthereumProvider())),getWeb3jsProvider:()=>new Uo(t.connectors.getEthereumProvider()),unlinkWallet:async f=>{let u=await t.unlinkWallet(f);d(u);let T=u.linkedAccounts.filter(K=>K.type==="wallet");if(u&&T&&T.length>0){let K=T[0];u=await zn(u,K.address)}return d(u),u},unlinkEmail:async f=>{let u=await t.unlinkEmail(f);return d(u),u},unlinkPhone:async f=>{let u=await t.unlinkPhone(f);return d(u),u},unlinkGoogle:async f=>{let u=await t.unlinkOAuth("google",f);return d(u),u},unlinkTwitter:async f=>{let u=await t.unlinkOAuth("twitter",f);return d(u),u},unlinkDiscord:async f=>{let u=await t.unlinkOAuth("discord",f);return d(u),u},unlinkGithub:async f=>{let u=await t.unlinkOAuth("github",f);return d(u),u},setActiveWallet:async f=>{if(!l)return;let u=await zn(l,f);u&&d(u)},forkSession:()=>t.forkSession(),createWallet:()=>new Promise((f,u)=>{if(!a||!l){u(new Error("User must be authenticated before creating a Privy wallet"));return}if(re(l)){u(new Error("Only one Privy wallet per user is currently allowed"));return}q(!0),ue({createWallet:{onSuccess:f,onFailure:u,callAuthOnSuccessOnClose:!1}}),ke("EMBEDDED_WALLET_SCREEN")}),signMessage:(f,u)=>new Promise((T,K)=>{if(!a||!l){K(new Error("User must be authenticated before signing with a Privy wallet"));return}if(!re(l)){K(new Error("Must have a Privy wallet before signing"));return}if(typeof f!="string"||f.length<1){K(new Error("Message must be a non-empty string"));return}q(!0);let wl={message:f,onSuccess:T,onFailure:K,uiOptions:u||{}},Cl={onCompleteNavigateTo:"SIGN_REQUEST_SCREEN",onFailure:K};ue({signMessage:wl,connectWallet:Cl}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")}),exportWallet:()=>new Promise((f,u)=>{if(!a||!l){u(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!re(l)){u(new Error("Must have a Privy wallet before exporting"));return}q(!0);let K={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:u},qn={appId:e.appId,origin:Io,onSuccess:f,onFailure:u};ue({keyExport:qn,connectWallet:K}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")})},fo=(()=>({isLinking:b,linkingHint:N,activeStatus:y,walletConnectionStatus:M,getAuthFlow:()=>t.authFlow,getAuthMeta:()=>{var f;return(f=t.authFlow)==null?void 0:f.meta},closePrivyModal:(f={shouldCallAuthOnSuccess:!0})=>{var T;let u=n&&a&&l;f.shouldCallAuthOnSuccess&&u&&((T=e.onSuccess)==null||T.call(e,l,h)),t.authFlow=void 0,D(null),g(null),c(!1),C(null),m(!1),r(!1)},initLoginWithWallet:(f,u)=>{if(!t.connectors)throw new E("Connector not initialized");f||(f="metamask");let T=new Bt(t.connectors,f,u);t.startAuthFlow(T),A({connecting:!0,connected:!1,connectError:null,connectRetry:()=>Et(T)}),Et(T)},loginWithWallet:async()=>{if(!(t.authFlow instanceof Bt))throw new E("Must initialize SIWE flow first.");let f,u;b?(f=await t.link(),f&&(f=wo(f))):{user:f,isNewUser:u}=await t.authenticate(),d(f||l||null),m(u||!1),s(!0)},initLoginWithOAuth:async f=>{t.startAuthFlow(new Ut(f));let u=await t.authFlow.getAuthorizationUrl();u&&u.url&&window.location.assign(u.url)},loginWithOAuth:async()=>{if(!(t.authFlow instanceof Ut))throw new E("Must initialize OAuth flow before calling loginWithOAuth");let f,u;n&&a?f=await t.link():{user:f,isNewUser:u}=await t.authenticate(),d(f),m(u||!1),s(!0)},initLoginWithEmail:async f=>{let u=new mo(f);t.startAuthFlow(u),await u.sendCodeEmail()},initLoginWithSms:async f=>{let u=new ho(f);t.startAuthFlow(u),await u.sendSmsCode()},resendEmailCode:async()=>{var f;await((f=t.authFlow)==null?void 0:f.sendCodeEmail())},resendSmsCode:async()=>{var f;await((f=t.authFlow)==null?void 0:f.sendSmsCode())},loginWithCode:async f=>{if(t.authFlow instanceof mo)t.authFlow.meta.emailCode=f.trim();else if(t.authFlow instanceof ho)t.authFlow.meta.smsCode=f.trim();else throw new E("Must initialize a passwordless code flow first");let u,T;b?u=await t.link():{user:u,isNewUser:T}=await t.authenticate(),d(u||l||null),m(T||!1),s(!0)},refreshUser:async()=>{let f=await t.getAuthenticatedUser();return d(f),f},walletProxy:ee}))();return(0,lt.jsxs)(mn.Provider,{value:vl,children:[e.children,(0,lt.jsxs)(fn.Provider,{value:fo,children:[(0,lt.jsx)(al,{theme:{...J.appearance.palette||{}}}),(0,lt.jsx)(Ni,{appConfig:J,options:Z,data:Pe,setModalData:ue,initialScreen:p,visible:o,authenticated:a,children:o&&(0,lt.jsx)(cl,{})}),H&&(0,lt.jsx)(fl,{appId:e.appId,origin:Io,onLoad:Le,onLoadFailed:()=>null})]})]})};0&&(module.exports={AsExternalProvider,ConnectorManager,PrivyClient,PrivyProvider,PrivyProxyProvider,VERSION,WalletConnector,getAccessToken,usePrivy});
|