PageSourceSearch

https://pancakeswap.finance/_next/static/chunks/7799-06588b09ababf9f5.js

js pancakeswap.finance collected 2026-09-24 08:44:23 UTC 1,387,320 bytes, 72 lines download raw bytes

1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4ceac21b-816b-44a2-9fae-9fbd9923eb37",e._sentryDebugIdIdentifier="sentry-dbid-4ceac21b-816b-44a2-9fae-9fbd9923eb37")}catch(e){}(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[227,673,2464,3054,3577,5958,7799],{854:(e,t,n)=>{"use strict";n.d(t,{Af:()=>p,ZJ:()=>c});var i=n(778401),r=n(12518),a=n(347626),s=n(871883),o=n(591260);let l=new TextEncoder;function c(e,t={}){var n,i;return"number"==typeof e||"bigint"==typeof e?(n=e,i=t,h((0,o.cK)(n,i))):"boolean"==typeof e?function(e,t={}){let n=new Uint8Array(1);return(n[0]=Number(e),"number"==typeof t.size)?((0,s.Sl)(n,{size:t.size}),(0,a.eV)(n,{size:t.size})):n}(e,t):(0,r.q)(e)?h(e,t):p(e,t)}let d={zero:48,nine:57,A:65,F:70,a:97,f:102};function u(e){return e>=d.zero&&e<=d.nine?e-d.zero:e>=d.A&&e<=d.F?e-(d.A-10):e>=d.a&&e<=d.f?e-(d.a-10):void 0}function h(e,t={}){let n=e;t.size&&((0,s.Sl)(n,{size:t.size}),n=(0,a.eV)(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);let o=r.length/2,l=new Uint8Array(o);for(let e=0,t=0;e<o;e++){let n=u(r.charCodeAt(t++)),a=u(r.charCodeAt(t++));if(void 0===n||void 0===a)throw new i.C(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);l[e]=16*n+a}return l}function p(e,t={}){let n=l.encode(e);return"number"==typeof t.size?((0,s.Sl)(n,{size:t.size}),(0,a.eV)(n,{dir:"right",size:t.size})):n}},9514:(e,t,n)=>{"use strict";n.d(t,{O:()=>u});var i=n(760483),r=n(996976),a=n(341028),s=n(152963),o=n(445185),l=n(872282),c=n(963323),d=n(898745);function u(e){return{estimateUserOperationGas:t=>(0,r.C)(e,t),getChainId:()=>(0,i.T)(e),getSupportedEntryPoints:()=>(0,a.c)(e),getUserOperation:t=>(0,s.l)(e,t),getUserOperationReceipt:t=>(0,o.b)(e,t),prepareUserOperation:t=>(0,l.u)(e,t),sendUserOperation:t=>(0,c.$)(e,t),waitForUserOperationReceipt:t=>(0,d.V)(e,t)}}},11394:(e,t,n)=>{"use strict";n.d(t,{u:()=>a});var i=n(264419),r=n(518327);function a(e){let t={...e};return e.actualGasCost&&(t.actualGasCost=BigInt(e.actualGasCost)),e.actualGasUsed&&(t.actualGasUsed=BigInt(e.actualGasUsed)),e.logs&&(t.logs=e.logs.map(e=>(0,i.e)(e))),e.receipt&&(t.receipt=(0,r.uL)(t.receipt)),t}},12518:(e,t,n)=>{"use strict";function i(e,{strict:t=!0}={}){return!!e&&"string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x"))}n.d(t,{q:()=>i})},15196:e=>{var t=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;e.exports=function(e){return e.match(t)||[]}},22941:(e,t,n)=>{"use strict";function i(e){return!!e&&"object"==typeof e&&"BYTES_PER_ELEMENT"in e&&1===e.BYTES_PER_ELEMENT&&"Uint8Array"===e.constructor.name}n.d(t,{a:()=>i})},34117:(e,t,n)=>{"use strict";n.d(t,{X:()=>r});var i=n(738344);function r(e,t){if(!/^(-?)([0-9]*)\.?([0-9]*)$/.test(e))throw new i.g({value:e});let[n,r="0"]=e.split("."),a=n.startsWith("-");if(a&&(n=n.slice(1)),r=r.replace(/(0+)$/,""),0===t)1===Math.round(Number(`.${r}`))&&(n=`${BigInt(n)+1n}`),r="";else if(r.length>t){let[e,i,a]=[r.slice(0,t-1),r.slice(t-1,t),r.slice(t)],s=Math.round(Number(`${i}.${a}`));(r=s>9?`${BigInt(e)+BigInt(1)}0`.padStart(e.length+1,"0"):`${e}${s}`).length>t&&(r=r.slice(1),n=`${BigInt(n)+1n}`),r=r.slice(0,t)}else r=r.padEnd(t,"0");return BigInt(`${a?"-":""}${n}${r}`)}},34138:(e,t,n)=>{"use strict";n.d(t,{I:()=>r});var i=n(584671);function r(e,t={}){let{key:n="custom",methods:a,name:s="Custom Provider",retryDelay:o}=t;return({retryCount:r})=>(0,i.o)({key:n,methods:a,name:s,request:e.request.bind(e),retryCount:t.retryCount??r,retryDelay:o,type:"custom"})}},34140:(e,t,n)=>{"use strict";n.d(t,{a:()=>a});var i=n(865449),r=n(615633);function a(e){return{getPaymasterData:t=>(0,i.l)(e,t),getPaymasterStubData:t=>(0,r.L)(e,t)}}},34228:(e,t,n)=>{"use strict";n.d(t,{$:()=>x,A:()=>el,B:()=>l,C:()=>g,D:()=>w,E:()=>em,F:()=>ey,G:()=>ef,H:()=>eg,I:()=>u,J:()=>s,K:()=>eu,L:()=>eh,M:()=>ep,N:()=>L,O:()=>z,P:()=>o,Q:()=>C,R:()=>S,S:()=>Z,T:()=>N,U:()=>ec,V:()=>ex,W:()=>ew,X:()=>ev,Y:()=>eb,Z:()=>v,_:()=>b,a:()=>h,a0:()=>_,a1:()=>E,a2:()=>T,a3:()=>Y,a4:()=>ed,a5:()=>R,a6:()=>I,a7:()=>H,a8:()=>W,a9:()=>A,aa:()=>e_,ab:()=>eC,ac:()=>ee,ad:()=>X,ae:()=>Q,af:()=>m,ag:()=>
1f,ah:()=>y,ai:()=>p,b:()=>U,c:()=>M,d:()=>c,e:()=>P,f:()=>d,g:()=>j,h:()=>k,i:()=>O,j:()=>J,k:()=>G,l:()=>es,m:()=>ea,n:()=>er,o:()=>K,p:()=>D,q:()=>ei,r:()=>en,s:()=>et,t:()=>q,u:()=>F,v:()=>B,w:()=>$,x:()=>V,y:()=>a,z:()=>eo});var i,r=n(769829);class a extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(e,t,n){super(e),t instanceof Error&&(this.cause=t),this.privyErrorCode=n}}class s extends a{constructor(e,t,n,i,r,a){super(n,i,r),this.type=e,this.status=t,this.data=a}}class o extends a{constructor(e,t,n){super(e,t,n),this.type="client_error"}}class l extends o{constructor(){super("Request timed out",void 0,"client_request_timeout")}}class c extends a{constructor(e,t,n){super(e,t,n),this.type="connector_error"}}let d=e=>{if(e instanceof a)return e;if(!(e instanceof r.F))return u(e);if(!e.response)return new s("api_error",null,e.message,e);let{type:t,message:n,error:i,code:o}=e.data;return new s(t||"ApiError",e.response.status,n||i,e,o,e.data)},u=e=>e instanceof a?e:e instanceof Error?new o(e.message,e):new o(`Internal error: ${e}`);var h=((i={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",i.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",i.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",i.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",i.INVALID_DATA="invalid_data",i.INVALID_CAPTCHA="invalid_captcha",i.LINKED_TO_ANOTHER_USER="linked_to_another_user",i.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",i.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",i.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",i.USER_EXITED_UPDATE_FLOW="exited_update_flow",i.ALLOWLIST_REJECTED="allowlist_rejected",i.OAUTH_USER_DENIED="oauth_user_denied",i.OAUTH_UNEXPECTED="oauth_unexpected",i.UNKNOWN_AUTH_ERROR="unknown_auth_error",i.USER_EXITED_AUTH_FLOW="exited_auth_flow",i.USER_EXITED_LINK_FLOW="exited_link_flow",i.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",i.MUST_BE_AUTHENTICATED="must_be_authenticated",i.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",i.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",i.CLIENT_REQUEST_TIMEOUT="client_request_timeout",i.INVALID_CREDENTIALS="invalid_credentials",i.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",i.UNKNOWN_MFA_ERROR="unknown_mfa_error",i.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",i.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",i.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",i.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",i.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",i.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",i.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",i.TRANSACTION_FAILURE="transaction_failure",i.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",i.NOT_SUPPORTED="not_supported",i.CAPTCHA_TIMEOUT="captcha_timeout",i.INVALID_MESSAGE="invalid_message",i.UNABLE_TO_SIGN="unable_to_sign",i.CAPTCHA_FAILURE="captcha_failure",i.CAPTCHA_DISABLED="captcha_disabled",i.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",i.TOO_MANY_REQUESTS="too_many_requests",i.USER_LIMIT_REACHED="max_accounts_reached",i.DISALLOWED_LOGIN_METHOD="disallowed_login_method",i.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",i.PASSKEY_NOT_ALLOWED="passkey_not_allowed",i.USER_DOES_NOT_EXIST="user_does_not_exist",i.INSUFFICIENT_BALANCE="insufficient_balance",i.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",i.BUFFER_NOT_DEFINED="buffer_not_defined",i.UNSUPPORTED_WALLET_TYPE="unsupported_wallet_type",i);class p extends o{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}}class m extends o{constructor(e="Embedded wallet error",t){super(e,t,"unknown_embedded_wallet_error")}}class y extends o{constructor(e="User must be authenticated"){super(e,void 0,"must_be_authenticated")}}class f extends o{constructor(e){super("This application is in development mode and must be upgraded to production to log in new users.",e,"max_accounts_reached")}}let g="/api/v1/sessions",w="/api/v1/sessions/logout",v="/api/v1/siwe/init",b="/api/v1/siwe/authenticate",x="/api/v1/siwe/link",_="/api/v1/siwe/link_smart_wallet",C="/api/v1/siwe/unlink",I="/api/v1/siwe/transfer",E="/api/v1/siws/init",T="/api/v1/siws/authenticate",A="/api/v1/siws/link",S="/api/v1/siws/unlink",k="/api/v1/farcaster/init",P="/api/v1/farcaster/authenticate",j="/api/v1/farcaster/link",O="/api/v1/farcaster/status",N="/api/v1/farcaster/unlink",R="/api/v1/farcaster/transfer",M="/api/v1/passwordless/init",D="/api/v1/passwordless/authenticate",U="/api/v1/passwordless/link",L="/api/v1/passwordless/unlink",F="/api/v1/passwordless/update",W="/api/v1/passwordless/transfer",$="/api/v1/passwordless_sms/init",B="/api/v1/passwordless_sms/link",z="/api/v1/passwordless_sms/unlink",q="/api/v1/passwordless_sms/authenticate",V="/api/v1/passwordless_sms/update",H="/api/v1/passwordless_sms/transfer",G="/api/v1/oauth/init",K="/api/v1/oauth/authenticate",J="/api/v1/oauth/link",Z="/api/v1/oauth/unlink",Y="/api/v1/oauth/transfer",Q="/api/v1/recovery/oauth/init",X="/api/v1/recovery/oauth/init_icloud",ee="/api/v1/recovery/oauth/authenticate",et="/api/v1/passkeys/link/init",en="/api/v1/passkeys/authenticate/init",ei="/api/v1/passkeys/register/init",er="/api/v1/passkeys/link",ea="/api/v1/passkeys/authenticate",es="/api/v1/passkeys/register",eo="/api/v1/telegram/authenticate",el="/api/v1/telegram/link",ec="/api/v1/telegram/unlink",ed="/api/v1/telegram/transfer",eu="/api/v1/mfa/passwordless_sms/init",eh="/api/v1/mfa/passkeys/init",ep="/api/v1/users/me/accept_terms",em="/api/v1/analytics_events",ey="/api/v1/custom_jwt_account/authenticate",ef="/api/v1/custom_jwt_account/link",eg="/api/v1/guest/authenticate",ew="/api/v1/plugins/moonpay_on_ramp/sign",ev="/api/v1/funding/coinbase_on_ramp/init",eb="/api/v1/funding/coinbase_on_ramp/status",ex="/api/v1/wallets/revoke",e_="/api/v1/users/me",eC="/api/v1/scan/transaction"},37107:(e,t,n)=>{"use strict";n.d(t,{Ty:()=>r,u:()=>a});var i=n(778401);class r extends i.C{constructor({max:e,min:t,signed:n,size:i,value:r}){super(`Number "${r}" is not in safe ${i?`${8*i}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}
1i.C,i.C,i.C;class a extends i.C{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}},37902:(e,t,n)=>{"use strict";n.d(t,{K:()=>r});var i=n(559482);function r(e){let{authorization:t,factory:n,factoryData:r}=e;if("0x7702"===n||"0x7702000000000000000000000000000000000000"===n){if(!t)return"0x7702000000000000000000000000000000000000";let e=t.address;return(0,i.xW)([e,r??"0x"])}return n?(0,i.xW)([n,r??"0x"]):"0x"}},38316:(e,t,n)=>{"use strict";n.d(t,{lm:()=>L});var i=n(605199),r=n(448398),a=n(414270),s=n(806363),o=n(559482),l=n(352401),c=n(333625),d=n(607186),u=n(128897),h=n(174562),p=n(814001),m=n(916544),y=n(382487),f=n(760483),g=n(603181),w=n(749397),v=n(329086),b=n(448953),x=n(569993),_=n(691730),C=n(945849),I=n(286836),E=n(288497),T=n(695764),A=n(985980),S=n(521880),k=n(129239),P=n(340335),j=n(624078),O=n(841869);let N=[{inputs:[{internalType:"address",name:"_implementation",type:"address"},{internalType:"bytes",name:"_data",type:"bytes"},{internalType:"uint256",name:"_index",type:"uint256"}],name:"createAccount",outputs:[{internalType:"address",name:"proxy",type:"address"}],stateMutability:"payable",type:"function"}],R={"0.2.1":{ECDSA_VALIDATOR:"0xd9AB5096a832b9ce79914329DAEE236f8Eea0390",ACCOUNT_LOGIC:"0xf048AD83CB2dfd6037A43902a2A5Be04e53cd2Eb",FACTORY_ADDRESS:"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3"},"0.2.2":{ECDSA_VALIDATOR:"0xd9AB5096a832b9ce79914329DAEE236f8Eea0390",ACCOUNT_LOGIC:"0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5",FACTORY_ADDRESS:"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3"},"0.2.3":{ECDSA_VALIDATOR:"0xd9AB5096a832b9ce79914329DAEE236f8Eea0390",ACCOUNT_LOGIC:"0xD3F582F6B4814E989Ee8E96bc3175320B5A540ab",FACTORY_ADDRESS:"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3"},"0.2.4":{ECDSA_VALIDATOR:"0xd9AB5096a832b9ce79914329DAEE236f8Eea0390",ACCOUNT_LOGIC:"0xd3082872F8B06073A021b4602e022d5A070d7cfC",FACTORY_ADDRESS:"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3"},"0.3.0-beta":{ECDSA_VALIDATOR:"0x8104e3Ad430EA6d354d013A6789fDFc71E671c43",ACCOUNT_LOGIC:"0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27",FACTORY_ADDRESS:"0x6723b44Abeec4E71eBE3232BD5B455805baDD22f",META_FACTORY_ADDRESS:"0xd703aaE79538628d27099B8c4f621bE4CCd142d5",WEB_AUTHN_VALIDATOR:"0xbA45a2BFb8De3D24cA9D7F1B551E14dFF5d690Fd"},"0.3.1":{ECDSA_VALIDATOR:"0x845ADb2C711129d4f3966735eD98a9F09fC4cE57",ACCOUNT_LOGIC:"0xBAC849bB641841b44E965fB01A4Bf5F074f84b4D",FACTORY_ADDRESS:"0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419",META_FACTORY_ADDRESS:"0xd703aaE79538628d27099B8c4f621bE4CCd142d5",WEB_AUTHN_VALIDATOR:"0xbA45a2BFb8De3D24cA9D7F1B551E14dFF5d690Fd"},"0.3.2":{ECDSA_VALIDATOR:"0x845ADb2C711129d4f3966735eD98a9F09fC4cE57",ACCOUNT_LOGIC:"0xD830D15D3dc0C269F3dBAa0F3e8626d33CFdaBe1",FACTORY_ADDRESS:"0x7a1dBAB750f12a90EB1B60D2Ae3aD17D4D81EfFe",META_FACTORY_ADDRESS:"0xd703aaE79538628d27099B8c4f621bE4CCd142d5"},"0.3.3":{ECDSA_VALIDATOR:"0x845ADb2C711129d4f3966735eD98a9F09fC4cE57",ACCOUNT_LOGIC:"0xE264dCCc54e4b6906c0D1Fee11D4326c06D33c80",FACTORY_ADDRESS:"0xE30c76Dc9eCF1c19F6Fec070674E1b4eFfE069FA",META_FACTORY_ADDRESS:"0xd703aaE79538628d27099B8c4f621bE4CCd142d5"}},M=e=>(0,o.aP)([E.g8.VALIDATOR,e]),D=async e=>{if("local"===e.type)return e.address;if((0,P.W)(e)){let t=i.aD(e.publicKey),n=(0,c.S)(r.uK(a.ZJ(e.id)));return(0,d.h)([{components:[{name:"x",type:"uint256"},{name:"y",type:"uint256"}],name:"webAuthnData",type:"tuple"},{name:"authenticatorIdHash",type:"bytes32"}],[{x:t.x,y:t.y},n])}throw Error("Invalid owner type")},U=async({entryPointVersion:e,kernelVersion:t,validatorData:n,index:i,factoryAddress:r,accountLogicAddress:a,validatorAddress:o,useMetaFactory:c})=>{let d=(({entryPoint:{version:e},kernelVersion:t,validatorData:n,validatorAddress:i})=>"0.6"===e?(0,l.p)({abi:x.m,functionName:"initialize",args:[i,n]}):"0.3.0-beta"===t?(0,l.p)({abi:_.J8,functionName:"initialize",args:[M(i),s.Xd,n,"0x"]}):(0,l.p)({abi:_.wd,functionName:"initialize",args:[M(i),s.Xd,n,"0x",[]]}))({entryPoint:{version:e},kernelVersion:t,validatorAddress:o,validatorData:n});return"0.6"===e?(0,l.p)({abi:N,functionName:"createAccount",args:[a,d,i]}):c?(0,l.p)({abi:I.h,functionName:"deployWithFactory",args:[r,d,(0,u.nj)(i,{size:32})]}
1):(0,l.p)({abi:C.j,functionName:"createAccount",args:[d,(0,u.nj)(i,{size:32})]})};async function L(e){var t;let n,{client:i,address:r,index:a=0n,owners:l,version:c,validatorAddress:u,factoryAddress:x,metaFactoryAddress:_,accountLogicAddress:C,useMetaFactory:I=!0}=e,N="webAuthn"===l[0].type,L=N?l[0]:await (0,b.F)({owner:l[0]}),F={address:e.entryPoint?.address??h.oi,abi:(e.entryPoint?.version??"0.7")==="0.6"?p.hw:p.qe,version:e.entryPoint?.version??"0.7"},W=(t=F.version,c||("0.6"===t?"0.2.2":"0.3.0-beta")),{accountLogicAddress:$,validatorAddress:B,factoryAddress:z,metaFactoryAddress:q}=(({validatorAddress:e,accountLogicAddress:t,factoryAddress:n,metaFactoryAddress:i,kernelVersion:r,isWebAuthn:a})=>{let o=R[r],l=e??(a?o.WEB_AUTHN_VALIDATOR:o.ECDSA_VALIDATOR),c=t??o.ACCOUNT_LOGIC;return{validatorAddress:l,accountLogicAddress:c,factoryAddress:n??o.FACTORY_ADDRESS,metaFactoryAddress:i??o?.META_FACTORY_ADDRESS??s.Xd}})({validatorAddress:u,accountLogicAddress:C,factoryAddress:x,metaFactoryAddress:_,kernelVersion:W,isWebAuthn:N});if(!B)throw Error("Validator address is required");let V=async e=>U({entryPointVersion:F.version,kernelVersion:W,validatorData:await D(L),index:a,factoryAddress:z,accountLogicAddress:$,validatorAddress:B,useMetaFactory:e}),H=async()=>n||(n=i.chain?i.chain.id:await (0,g.T)(i,f.T,"getChainId")({})),G=e=>async()=>({factory:"0.6"===F.version||!1===e?z:q,factoryData:await V(e)}),{accountAddress:K,getFactoryArgs:J}=await (async()=>{let e=G("optional"===I||I);if(r&&"optional"!==I)return{accountAddress:r,getFactoryArgs:e};let{factory:t,factoryData:n}=await e(),a=await (0,v.s)(i,{factory:t,factoryData:n,entryPointAddress:F.address});if(r===a)return{accountAddress:a,getFactoryArgs:e};if("optional"===I&&a===s.Xd){e=G(!1);let{factory:t,factoryData:n}=await e();a=await (0,v.s)(i,{factory:t,factoryData:n,entryPointAddress:F.address})}return{accountAddress:a,getFactoryArgs:e}})();return(0,m.q)({client:i,entryPoint:F,getFactoryArgs:J,getAddress:async()=>K,encodeCalls:async e=>(0,A.r)({calls:e,kernelVersion:W}),decodeCalls:async e=>(0,T.L)({callData:e,kernelVersion:W}),async getNonce(t){return(0,w.p)(i,{address:await this.getAddress(),entryPointAddress:F.address,key:(0,S.I)(W,B,e.nonceKey??0n)})},getStubSignature:async()=>(0,k.c)(W)?(0,o.aP)([E.am,E.rR]):(0,P.W)(L)?(0,d.h)([{name:"authenticatorData",type:"bytes"},{name:"clientDataJSON",type:"string"},{name:"responseTypeLocation",type:"uint256"},{name:"r",type:"uint256"},{name:"s",type:"uint256"},{name:"usePrecompiled",type:"bool"}],["0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000",'{"type":"webauthn.get","challenge":"tbxXNFS9X_4Byr1cMwqKrIGB-_30a0QhZ6y7ucM0BOE","origin":"http://localhost:3000","crossOrigin":false, "other_keys_can_be_added_here":"do not compare clientDataJSON against a template. See https://goo.gl/yabPex"}',1n,0x635bc6d0f68ff895cae8a288ecf7542a6a9cd555df784b73e1e2ea7e9104b1dbn,0x15e9015d280cb19527881c625fee43fd3a405d5b0d199a8c8e6589a7381209e4n,!1]):E.rR,async sign({hash:e}){return this.signMessage({message:e})},async signMessage({message:e}){let t=await (0,j.l)({owner:L,message:e,accountAddress:await this.getAddress(),kernelVersion:"0.3.3"===W?"0.3.2":W,chainId:await H()});return(0,k.c)(W)?t:(0,o.aP)([M(B),t])},async signTypedData(e){let t=await (0,O.C)({owner:L,chainId:await H(),...e,accountAddress:await this.getAddress(),kernelVersion:"0.3.3"===W?"0.3.2":W});return(0,k.c)(W)?t:(0,o.aP)([M(B),t])},async signUserOperation(e){let{chainId:t=await H(),...n}=e,i=(0,y.Z)({userOperation:{...n,sender:n.sender??await this.getAddress(),signature:"0x"},entryPointAddress:F.address,entryPointVersion:F.version,chainId:t}),r=(0,P.W)(L)?await (0,j.l)({owner:L,message:{raw:i},chainId:t,accountAddress:await this.getAddress(),kernelVersion:W}):await L.signMessage({message:{raw:i}});return(0,k.c)(W)?(0,o.aP)(["0x00000000",r]):r}})}},43866:(e,t,n)=>{"use strict";n.d(t,{i:()=>i});let i={id:0xaa37dc,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0}},47668:(e,t,n)=>{"use strict";n.d(t,{EP:()=>x});var i=n(323287),r=n(529533),a=n(806363),s=n(125644),o=n(97644),l=n(607186),c=n(352401),d=n(787944),u=n(620103),h=n(480331),p=n(128897),m=n(991439),y=n(886834),f=n(317121),g=n(814001),w=n(382487),v=n(916544);let b={"1.1":"0xba5ed110efdba3d005bfc882d75358acbbb85842",1:"0x0ba5ed0c6aa8c49038f819e587e2633c4a9f428a"};async function x(e){let{client:t,ownerIndex:n=0,owners:i,nonce:l=0n,version:d="1"}=e,h=e.address,p={abi:g.hw,address:a.B9,version:"0.6"},f={abi:A,address:b[d]},x=i.map(e=>{if("string"==typeof e)return(0,u.eV)(e);if("webAuthn"===e.type)return e.publicKey;if("local"===e.type)return(0,u.eV)(e.address);throw new s.C("invalid owner type")}),S=(()=>{let e=i[n]??i[0];return"string"==typeof e?{address:e,type:"address"}:e})();return(0,v.q)({client:t,entryPoint:p,extend:{abi:T,factory:f},async decodeCalls(e){let t=(0,o.J)({abi:T,data:e});if("execute"===t.functionName)return[{to:t.args[0],value:t.args[1],data:t.args[2]}];if("executeBatch"===t.functionName)return t.args[0].map(e=>({to:e.target,value:e.value,data:e.data}));throw new s.C(`unable to decode calls for "${t.functionName}"`)},encodeCalls:async e=>1===e.length?(0,c.p)({abi:T,functionName:"execute",args:[e[0].to,e[0].value??0n,e[0].data??"0x"]}):(0,c.p)({abi:T,functionName:"executeBatch",args:[e.map(e=>({data:e.data??"0x",target:e.to,value:e.value??0n}))]}),getAddress:async()=>h??=await (0,r.J)(t,{...f,functionName:"getAddress",args:[x,l]}),async getFactoryArgs(){let e=(0,c.p)({abi:f.abi,functionName:"
1createAccount",args:[x,l]});return{factory:f.address,factoryData:e}},getStubSignature:async()=>"webAuthn"===S.type?"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000":E({ownerIndex:n,signature:"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"}),async sign(e){let i=I({address:await this.getAddress(),chainId:t.chain.id,hash:e.hash});if("address"===S.type)throw Error("owner cannot sign");return E({ownerIndex:n,signature:await _({owner:S,typedData:i})})},async signMessage(e){let{message:i}=e,r=I({address:await this.getAddress(),chainId:t.chain.id,hash:(0,m.A)(i)});if("address"===S.type)throw Error("owner cannot sign");return E({ownerIndex:n,signature:await _({owner:S,typedData:r})})},async signTypedData(e){let{domain:i,types:r,primaryType:a,message:s}=e,o=I({address:await this.getAddress(),chainId:t.chain.id,hash:(0,y.Zh)({domain:i,message:s,primaryType:a,types:r})});if("address"===S.type)throw Error("owner cannot sign");return E({ownerIndex:n,signature:await _({owner:S,typedData:o})})},async signUserOperation(e){let{chainId:i=t.chain.id,...r}=e,a=await this.getAddress(),s=(0,w.Z)({chainId:i,entryPointAddress:p.address,entryPointVersion:p.version,userOperation:{...r,sender:a}});if("address"===S.type)throw Error("owner cannot sign");return E({ownerIndex:n,signature:await C({hash:s,owner:S})})},userOperation:{async estimateGas(e){if("webAuthn"===S.type)return{verificationGasLimit:BigInt(Math.max(Number(e.verificationGasLimit??0n),8e5))}}}})}async function _({typedData:e,owner:t}){return"local"===t.type&&t.signTypedData?t.signTypedData(e):C({hash:(0,y.Zh)(e),owner:t})}async function C({hash:e,owner:t}){if("webAuthn"===t.type){let{signature:n,webauthn:r}=await t.sign({hash:e});return function({webauthn:e,signature:t}){let{r:n,s:r}=i.aD(t);return(0,l.h)([{components:[{name:"authenticatorData",type:"bytes"},{name:"clientDataJSON",type:"bytes"},{name:"challengeIndex",type:"uint256"},{name:"typeIndex",type:"uint256"},{name:"r",type:"uint256"},{name:"s",type:"uint256"}],type:"tuple"}],[{authenticatorData:e.authenticatorData,clientDataJSON:(0,p.i3)(e.clientDataJSON),challengeIndex:BigInt(e.challengeIndex),typeIndex:BigInt(e.typeIndex),r:n,s:r}])}({signature:n,webauthn:r})}if(t.sign)return t.sign({hash:e});throw new s.C("`owner` does not support raw sign.")}function I({address:e,chainId:t,hash:n}){return{domain:{chainId:t,name:"Coinbase Smart Wallet",verifyingContract:e,version:"1"},types:{CoinbaseSmartWalletMessage:[{name:"hash",type:"bytes32"}]},primaryType:"CoinbaseSmartWalletMessage",message:{hash:n}}}function E(e){let{ownerIndex:t=0}=e,n=(()=>{if(65!==(0,h.E)(e.signature))return e.signature;let t=(0,f.u)(e.signature);return(0,d.P)(["bytes32","bytes32","uint8"],[t.r,t.s,0===t.yParity?27:28])})();return(0,l.h)([{components:[{name:"ownerIndex",type:"uint8"},{name:"signatureData",type:"bytes"}],type:"tuple"}],[{ownerIndex:t,signatureData:n}])}let T=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"owner",type:"bytes"}],name:"AlreadyOwner",type:"error"},{inputs:[],name:"Initialized",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidEthereumAddressOwner",type:"error"},{inputs:[{name:"key",type:"uint256"}],name:"InvalidNonceKey",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidOwnerBytesLength",type:"error"},{inputs:[],name:"LastOwner",type:"error"},{inputs:[{name:"index",type:"uint256"}],name:"NoOwnerAtIndex",type:"error"},{inputs:[{name:"ownersRemaining",type:"uint256"}],name:"NotLastOwner",type:"error"},{inputs:[{name:"selector",type:"bytes4"}],name:"SelectorNotAllowed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"UnauthorizedCallContext",type:"error"},{inputs:[],name:"UpgradeFailed",type:"error"},{inputs:[{name:"index",type:"uint256"},{name:"expectedOwner",type:"bytes"},{name:"actualOwner",type:"bytes"}],name:"WrongOwnerAtIndex",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"AddOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"RemoveOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"REPLAYABLE_NONCE_KEY",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"addOwnerAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"addOwnerPublicKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"functionSelector",type:"bytes4"}],name:"canSkipChainIdValidation",outputs:[{name:"",type:"bool"}],stateMutability:"pure",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"entryPoint",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"calls",type:"bytes[]"}],name:"executeWithoutChainIdValidation",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHashWithoutChainId",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"$",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"owners",type:"bytes[]"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"isOwnerAddress",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"bytes"}],name:"isOwnerBytes",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"isOwnerPublicKey",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"result",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextOwnerIndex",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"}],name:"ownerAtIndex",outputs:[{name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ownerCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeLastOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeOwnerAtIndex",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"removedOwnersCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"}],name:"replaySafeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"newImplementation",type:"address"},{name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"missingAccountFunds",type:"uint256"}],name:"validateUserOp",outputs:[{name:"validationData",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],A=[{inputs:[{name:"implementation_",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"OwnerRequired",type:"error"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"createAccount",outputs:[{name:"account",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"getAddress",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initCodeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"}]},53717:(e,t,n)=>{"use strict";async function i(e,t){let{id:n}=t;await e.request({method:"wallet_showCallsStatus",params:[n]})}n.d(t,{J:()=>i})}
1,61948:(e,t,n)=>{"use strict";n.d(t,{c:()=>h});var i=n(125644),r=n(292118),a=n(603181),s=n(348059),o=n(750408),l=n(727258),c=n(331507),d=n(95190),u=n(704932);async function h(e,t){let n,{id:i,pollingInterval:h=e.pollingInterval,status:m=({statusCode:e})=>200===e||e>=300,retryCount:y=4,retryDelay:f=({count:e})=>200*~~(1<<e),timeout:g=6e4,throwOnFailure:w=!1}=t,v=(0,d.A)(["waitForCallsStatus",e.uid,i]),{promise:b,resolve:x,reject:_}=(0,l.Y)(),C=(0,s.lB)(v,{resolve:x,reject:_},t=>{let s=(0,o.w)(async()=>{let o=e=>{clearTimeout(n),s(),e(),C()};try{let n=await (0,c.b)(async()=>{let t=await (0,a.T)(e,u.k,"getCallsStatus")({id:i});if(w&&"failure"===t.status)throw new r.q(t);return t},{retryCount:y,delay:f});if(!m(n))return;o(()=>t.resolve(n))}catch(e){o(()=>t.reject(e))}},{interval:h,emitOnBegin:!0});return s});return n=g?setTimeout(()=>{C(),clearTimeout(n),_(new p({id:i}))},g):void 0,await b}class p extends i.C{constructor({id:e}){super(`Timed out while waiting for call bundle with id "${e}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}},69159:(e,t,n)=>{"use strict";n.d(t,{D:()=>r});var i=n(525868);let r=async(e,t)=>await e.request({method:"pm_validateSponsorshipPolicies",params:[(0,i._)(t.userOperation),t.entryPointAddress,t.sponsorshipPolicyIds]})},73754:(e,t,n)=>{"use strict";n.d(t,{h:()=>c});var i=n(609810),r=n(69159),a=n(526725),s=n(749067),o=n(504799),l=n(950607);let c=({entryPoint:e})=>t=>({getUserOperationGasPrice:async()=>(0,s.$)(t),getUserOperationStatus:async e=>(0,o.D)(t,e),sendCompressedUserOperation:async n=>(0,i.O)(t,{...n,entryPointAddress:e.address}),sponsorUserOperation:async n=>(0,l.t)(t,{...n,entryPoint:e}),validateSponsorshipPolicies:async n=>(0,r.D)(t,{...n,entryPointAddress:e.address}),getTokenQuotes:async n=>(0,a.X)(t,{...n,chain:n.chain,entryPointAddress:e.address})})},77242:(e,t,n)=>{"use strict";n.d(t,{Sl:()=>r,X:()=>s,eV:()=>o,kK:()=>a});var i=n(448398);function r(e,t){if(i.Ej(e)>t)throw new i.u({givenSize:i.Ej(e),maxSize:t})}function a(e,t){if("number"==typeof t&&t>0&&t>i.Ej(e)-1)throw new i.ii({offset:t,position:"start",size:i.Ej(e)})}function s(e,t,n){if("number"==typeof t&&"number"==typeof n&&i.Ej(e)!==n-t)throw new i.ii({offset:n,position:"end",size:i.Ej(e)})}function o(e,t={}){let{dir:n,size:r=32}=t;if(0===r)return e;let a=e.replace("0x","");if(a.length>2*r)throw new i.Fl({size:Math.ceil(a.length/2),targetSize:r,type:"Hex"});return`0x${a["right"===n?"padEnd":"padStart"](2*r,"0")}`}},85144:(e,t,n)=>{"use strict";n.d(t,{s:()=>r});var i=n(225572);async function r(e){return(await e.request({method:"eth_requestAccounts"},{dedupe:!0,retryCount:0})).map(e=>(0,i.b)(e))}},89606:(e,t,n)=>{"use strict";var i;n.d(t,{$b:()=>i,Vy:()=>c});let r=[];!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(i||(i={}));let a={debug:i.DEBUG,verbose:i.VERBOSE,info:i.INFO,warn:i.WARN,error:i.ERROR,silent:i.SILENT},s=i.INFO,o={[i.DEBUG]:"log",[i.VERBOSE]:"log",[i.INFO]:"info",[i.WARN]:"warn",[i.ERROR]:"error"},l=(e,t,...n)=>{if(t<e.logLevel)return;let i=new Date().toISOString(),r=o[t];if(r)console[r](`[${i}]  ${e.name}:`,...n);else throw Error(`Attempted to log a message with an invalid logType (value: ${t})`)};class c{constructor(e){this.name=e,this._logLevel=s,this._logHandler=l,this._userLogHandler=null,r.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in i))throw TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?a[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,i.DEBUG,...e),this._logHandler(this,i.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,i.VERBOSE,...e),this._logHandler(this,i.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,i.INFO,...e),this._logHandler(this,i.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,i.WARN,...e),this._logHandler(this,i.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,i.ERROR,...e),this._logHandler(this,i.ERROR,...e)}}},96158:(e,t,n)=>{"use strict";function i(e){let t={...e};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.maxFeePerGas&&(t.maxFeePerGas=BigInt(e.maxFeePerGas)),e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=BigInt(e.maxPriorityFeePerGas)),e.nonce&&(t.nonce=BigInt(e.nonce)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),t}n.d(t,{o:()=>i})},102319:(e,t,n)=>{"use strict";async function i(e){return await e.request({method:"wallet_getPermissions"},{dedupe:!0})}n.d(t,{V:()=>i})}
1,105493:(e,t,n)=>{"use strict";let i,r,a,s,o,l,c,d,u;n.d(t,{H:()=>In,P:()=>Sa,a:()=>mY,aP:()=>TC,aQ:()=>EB,aR:()=>TQ,e:()=>yQ,k:()=>yK,p:()=>wT,q:()=>pF,u:()=>fu});var h=n(350979),p=n(373200),m=n(25963),y=n(800094),f=n(225572),g=n(128897),w=n(275943),v=n(54492);let b=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","mfa_timeout","missing_or_invalid_mfa","mfa_verification_max_attempts_reached"];(tw={}).MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",tw.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",tw.INVALID_DATA="invalid_data",tw.LINKED_TO_ANOTHER_USER="linked_to_another_user",tw.ALLOWLIST_REJECTED="allowlist_rejected",tw.OAUTH_USER_DENIED="oauth_user_denied",tw.UNKNOWN_AUTH_ERROR="unknown_auth_error",tw.USER_EXITED_AUTH_FLOW="exited_auth_flow",tw.MUST_BE_AUTHENTICATED="must_be_authenticated",tw.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",tw.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",tw.CLIENT_REQUEST_TIMEOUT="client_request_timeout",tw.INVALID_CREDENTIALS="invalid_credentials";class x extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(e,t,n){super(e),t instanceof Error&&(this.cause=t),this.privyErrorCode=n}}class _ extends Error{constructor(e,t){super(t),this.type=e}}class C extends x{constructor(e,t,n){super(e,t,n),this.type="connector_error"}}class I extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}let E={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},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},E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don’t see your wallet? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don’t see your wallet? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail
1:"Don’t see your wallet? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}};function T(e){let t;return"string"==typeof(t=e.type)&&b.includes(t)&&"wallet_not_on_device"===e.type}var A=n(343750),S=n(737958),k=n(527699);class P extends Error{constructor({error:e,code:t}){super(e),this.error=e,this.code=t}}class j extends Error{constructor({error:e,code:t}){super(e),this.code=t,this.error=e}}class O extends Error{constructor({error:e,code:t,response:n}){super(e),this.code=t,this.error=e,this.response=n}}var N=n(715599).Buffer;async function R(e,t){let n=k(t);if(void 0===n)throw new j({error:"Failed to prepare the payload for signing",code:"invalid_input"});let i=N.from(n).toString("base64"),{signature:r}=await e({message:i});return{signature:r}}async function M(e,t,{wallet_id:n,...i}){let r={version:1,url:e.getCompiledPath(S.H_,{params:{wallet_id:n}}),method:S.H_.method,headers:{"privy-app-id":e.app.appId},body:{...i}},{signature:a}=await R(t,r);return await e.fetchPrivyRoute(S.H_,{body:i,params:{wallet_id:n},headers:{"privy-authorization-signature":a}})}var D=n(683978),U=n(113627),L=n(925848);async function F(e,{request:t}){return await e.fetchPrivyRoute(S.GK,{body:t})}var W=n(30346),$=n(371311),B=n(431999),z=n(189309),q=n(493804),V=n(655786);let H=(e,t)=>(0,$.h)(String(e),t),G=(e,t)=>`+${(0,B.K)(t)} ${e}`,K=(0,q.X)().map(e=>({code:e,callCode:(0,B.K)(e)}));var J=n(217625),Z=n(663272),Y=n(675708),Q=n(756924),X=n(111280),ee=n(183529),et=n(828701),en=n(790357),ei=n(192344),er=n(43866),ea=n(933087),es=n(633793),eo=n(297660),el=n(988586);let ec={[U.r.id]:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",[ei.G.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[ee.R.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[er.i.id]:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",[et.n.id]:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",[ea.n.id]:"0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",[Y.E.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[es.Z.id]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[Z.m.id]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[eo.C.id]:"0x5425890298aed601595a70ab815c96711a31bc65",[J.D.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[el.Y.id]:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},ed={"mainnet-beta":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",devnet:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",testnet:""};var eu=n(532013),eh=n(684038);function ep(e){return e?`${e.slice(0,5)}…${e.slice(-4)}`:""}function em({amount:e,decimals:t}){return(0,eh.J)(BigInt(e),t)}let ey=new Set([U.r.id,Y.E.id,ee.R.id,et.n.id,J.D.id]),ef=new Set([U.r.id,Y.E.id,et.n.id,ee.R.id]),eg={buy:"CARD",send:"CRYPTO_ACCOUNT"},ew={USDC:"2b92315d-eab7-5bef-84fa-089a131333f5",ETH:"d85dce9b-5b73-5c3c-8978-522ce1d1c1b4",BTC:"5b71fc48-3dd3-540c-809b-f8c94d0e68b5",SOL:"4f039497-3af8-5bb3-951c-6df9afa9be1c",POL:"026bcc1e-9163-591c-a709-34dd18b2e7a1"};U.r.id,Y.E.id,ee.R.id,et.n.id,J.D.id;let ev={prod:{url:"https://api.moonpay.com/v1",key:"pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL"},sandbox:{url:"https://api.moonpay.com/v1",key:"pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI"}},eb=new Set([U.r.id,J.D.id,Y.E.id,et.n.id,Z.m.id,Q.A.id]),ex=new Set([U.r.id,J.D.id,ee.R.id,Y.E.id,et.n.id]);var e_=n(839542);class eC{async invokeRpc({method:e,params:t}){let n=await fetch(this.cluster.rpcUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:(0,e_.A)(),method:e,params:t})});return await n.json()}async getBalance(e){try{let t=await this.invokeRpc({method:"getBalance",params:[e]});return t.error?null:BigInt(t.result.value)}catch(e){return null}}async getTokenAccountsByOwner(e,t){try{let n=await this.invokeRpc({method:"getTokenAccountsByOwner",params:[e,{mint:t},{encoding:"jsonParsed"}]});if(n.error)return null;let i=n.result.value.at(0)?.account?.data?.parsed?.info?.tokenAmount;return i?{amount:BigInt(i.amount),decimals:i.decimals}:null}catch(e){return null}}async getAccountInfo(e){try{let t=await this.invokeRpc({method:"getAccountInfo",params:[e,{encoding:"jsonParsed"}]});if(t.error)return null;let n=t.result.value?.data?.parsed?.info;return n?{decimals:n.decimals}:null}catch(e){return null}}constructor(e){this.cluster=e}}var eI=n(597811),eE=n(57849),eT=n(932301);function eA(e){if("number"==typeof e||"bigint"==typeof e||"string"==typeof e)return e;if("function"==typeof e.toHexString)return e.toHexString();throw Error(`Expected numeric value but received ${e}`)}let eS=e=>[J.D.id,el.Y.id].includes(e),ek=async(e,t)=>{if(!eS(e.chainId))throw Error("Invalid chain ID for Arbitrum gas estimation.");
1if(void 0===e.type&&(e.type=2),e.maxFeePerGas)return e;try{let{lastBaseFeePerGas:n}=await t.getFeeData();if(n){let t=n.mul(eT.gH.from(120)).div(eT.gH.from(100));e.maxFeePerGas=eA(t),e.maxPriorityFeePerGas=eA(eT.gH.from(0))}}catch(e){throw Error(`Failed to set gas price for Arbitrum transaction: ${e}.`)}return e},eP=e=>[56,97].includes(e),ej=async(e,t)=>{if(!eP(e.chainId))throw Error("Invalid chain ID for BSC gas estimation.");if(void 0===e.type?e.type=0:(1==e.type||2==e.type)&&console.warn("Transaction request type specified is incompatible for chain and will result in undefined behavior.  Please use transaction type 0."),!e.gasPrice){let n=await t.getFeeData();e.gasPrice=n.gasPrice?.toHexString()}return e};var eO=n(636976),eN=n(790518);let eR=e=>[Y.E.id,es.Z.id,ee.R.id,er.i.id,en.L.id,eO.q.id,eN.a.id,81457,0xa0c71fd].includes(e),eM=async(e,t)=>{if(!eR(e.chainId))throw Error("Invalid chain ID for OP Stack gas estimation.");if(void 0===e.type&&(e.type=2),e.gasPrice&&(console.warn("`gasPrice` is not supported on this chain and will be ignored. Use `maxPriorityFeePerGas` and/or `maxFeePerGas` instead."),delete e.gasPrice),e.maxPriorityFeePerGas&&e.maxFeePerGas)return e;try{if(e.maxPriorityFeePerGas||(e.maxPriorityFeePerGas=await t.send("eth_maxPriorityFeePerGas",[])),e.maxFeePerGas&&(console.warn("maxFeePerGas is specified without maxPriorityFeePerGas - this can result in hung transactions."),e.maxPriorityFeePerGas>=e.maxFeePerGas))throw Error("Overridden maxFeePerGas is less than or equal to the calculated maxPriorityFeePerGas. Please set both values or maxPriorityFeePerGas alone for correct gas estimation.");if(!e.maxFeePerGas){let{lastBaseFeePerGas:n}=await t.getFeeData();if(!n)throw Error("Unable to fetch baseFee for last block.");let i=eT.gH.from(n).mul(eT.gH.from(126)).div(eT.gH.from(100)).add(eT.gH.from(e.maxPriorityFeePerGas));e.maxFeePerGas=eA(i)}}catch(e){throw Error(`Failed to set gas price for OP stack transaction: ${e}.`)}return e};var eD=n(12819),eU=n(752040);let eL=eU(fetch,{retries:3,retryDelay:500}),eF=e=>[et.n.id,ea.n.id].includes(e),eW=e=>({maxPriorityFee:(0,eD.parseUnits)(e.maxPriorityFee.toFixed(9),"gwei").toHexString(),maxFee:(0,eD.parseUnits)(e.maxFee.toFixed(9),"gwei").toHexString()}),e$=async e=>{let t="";switch(e){case et.n.id:t="https://gasstation.polygon.technology/v2";break;case ea.n.id:t="https://gasstation.polygon.technology/amoy";break;default:throw Error(`chainId ${e} does not support polygon gas stations`)}let n=await eL(t),i=await n.json();if(n.status>399)throw i;return(e=>({safeLow:eW(e.safeLow),standard:eW(e.standard),fast:eW(e.fast)}))(i)};async function eB(e){if(!eF(e.chainId))throw Error("Invalid chain ID for Polygon gas estimation.");if(void 0===e.type&&(e.type=2),e.maxPriorityFeePerGas&&e.maxFeePerGas)return e;try{let{standard:t}=await e$(e.chainId);e.maxPriorityFeePerGas||(e.maxPriorityFeePerGas=t.maxPriorityFee),e.maxFeePerGas||(e.maxFeePerGas=t.maxFee),e.gasPrice&&(console.warn("`gasPrice` is not supported on this chain and will be ignored. Use `maxPriorityFeePerGas` and/or `maxFeePerGas` instead."),delete e.gasPrice)}catch(e){throw Error(`Failed to set gas prices from Polygon gas station with error: ${e}.`)}return e}let ez=async(e,t)=>{if(void 0===e.type&&(e.type=2),2===e.type){if(!e.maxFeePerGas||!e.maxPriorityFeePerGas){let n=await t.getFeeData();e.maxFeePerGas||(e.maxFeePerGas=n.maxFeePerGas?.toHexString()),e.maxPriorityFeePerGas||(e.maxPriorityFeePerGas=n.maxPriorityFeePerGas?.toHexString())}}else if(!e.gasPrice){let n=await t.getFeeData();e.gasPrice=n.gasPrice?.toHexString()}return e};async function eq(e,t){try{return(await t.estimateGas(e)).toHexString()}catch(i){let n;if("message"in i&&i.message.includes("insufficient funds")&&(console.warn(`Gas estimation failed with error: ${i}. Retrying gas estimation by omitting the 'value'`),n=await async function({txRequest:e,provider:t}){try{let n={...e,value:void 0};return(await t.estimateGas(n)).toHexString()}catch(e){return console.warn(`Gas estimation failed with error: ${e} when omitting the 'value'`),null}}({txRequest:e,provider:t})),n||(console.warn(`Gas estimation failed with error: ${i}. Retrying gas estimation by omitting the 'from'`),n=await async function({txRequest:e,provider:t}){try{let n={...e,from:void 0};return(await t.estimateGas(n)).toHexString()}catch(e){return console.warn(`Gas estimation failed with error: ${e} when omitting the 'from' address`),null}}({txRequest:e,provider:t})),!n)throw i;return n}}let eV=(e,t,n,i)=>{let r=Number(e),a=t.find(e=>e.id===r);if(!a)throw new C(`Unsupported chainId ${e}`,4901);return new eE.B(a.rpcUrls.privyWalletOverride&&a.rpcUrls.privyWalletOverride.http[0]?a.rpcUrls.privyWalletOverride.http[0]:n.rpcUrls&&n.rpcUrls[r]?n.rpcUrls[r]:a.rpcUrls.privy?.http[0]?{url:a.rpcUrls.privy.http[0],headers:{"privy-app-id":i.appId}}:a.rpcUrls.public?.http[0]?a.rpcUrls.public?.http[0]:a.rpcUrls.default?.http[0])};function eH(e){return/^-?0x[a-f0-9]+$/i.test(e)}
1async function eG(e,t,n){if(t.chainId=Number(t.chainId),function(e){for(let t of["gasLimit","gasPrice","value","maxPriorityFeePerGas","maxFeePerGas"]){let n=e[t];if(void 0!==n&&!function(e){let t="number"==typeof e,n="bigint"==typeof e,i="string"==typeof e&&eH(e);return t||n||i}(n))throw Error(`Transaction request property '${t}' must be a valid number, bigint, or hex string representing a quantity`)}if("number"!=typeof e.chainId)throw Error("Transaction request property 'chainId' must be a number")}(t),t.from||(t.from=e),!t.nonce){let i=new eI.VoidSigner(e,n);t.nonce=await i.getTransactionCount("pending")}return t.gasLimit||(t.gas?(t.gasLimit=t.gas,delete t.gas):t.gasLimit=await eq(t,n)),"string"==typeof t.type&&eH(t.type)&&(t.type=Number(t.type)),[23294,23295].includes(t.chainId)&&(t.type=0),0===(t=eF(t.chainId)?await eB(t):eS(t.chainId)?await ek(t,n):eR(t.chainId)?await eM(t,n):eP(t.chainId)?await ej(t,n):await ez(t,n)).type&&delete t.accessList,2!==t.type&&(delete t.maxPriorityFeePerGas,delete t.maxFeePerGas),t}let eK={path:"/api/v1/apps/:app_id/smart_wallets",method:"GET"};class eJ{getConfig(){return this._privyInternal.config}async getSmartWalletConfig(){return this._smartWalletConfig||(this._smartWalletConfig=await this._privyInternal.fetch(eK,{params:{app_id:this.appId}})),this._smartWalletConfig}get appId(){return this._privyInternal.appId}constructor(e){this._privyInternal=e}}let eZ={path:"/api/v1/apps/:app_id/cross-app/connections",method:"GET"};var eY=n(743044);class eQ{static parse(e){try{return new eQ(e)}catch(e){return null}}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=eY.i(e)}}class eX{async updateOnCrossAppAuthentication(e,t){let n=t.access_token,i=eX.providerAccessTokenStorageKey(e);await this._storage.put(i,n)}async getProviderAccessToken(e){let t=eX.providerAccessTokenStorageKey(e),n=await this._storage.get(t);if("string"!=typeof n)return null;try{if(new eQ(n).isExpired())throw Error("JWT is expired");return n}catch{return await this._storage.del(t),null}}async getCrossAppConnections(){return await this._privyInternal.fetch(eZ,{params:{app_id:this._privyInternal.appId}})}constructor(e,t){this._privyInternal=e,this._storage=t}}eX.providerAccessTokenStorageKey=e=>`privy:cross-app:${e}`;class e0{async revoke(){await this._privyInternal.fetch(S.xh,{})}constructor(e){this._privyInternal=e}}class e1{async sign({message:e}){return await this.request({method:"sign",params:{message:new TextDecoder("utf8").decode(e)}})}async signTransaction({psbt:e}){return await this.request({method:"signTransaction",params:{psbt:e}})}async request(e){if(!await this._privyInternal.getAccessToken())throw new j({error:"Missing access token",code:"attempted_rpc_call_before_logged_in"});return this.handleIFrameRpc(e)}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessToken();if(!t)throw Error("Missing access token. User must be authenticated.");return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address}),(await this._proxy.rpcWallet({accessToken:t,request:e,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,hdWalletIndex:this._account.wallet_index,chainType:this._account.chain_type})).response.data}catch(n){console.error(n);let t=n instanceof Error?n.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:t}),new j({code:"embedded_wallet_request_error",error:t})}}toJSON(){return`PrivyEmbeddedBitcoinProvider { address: '${this._account.address}', request: [Function] }`}constructor({proxy:e,privyInternal:t,account:n,entropyId:i,entropyIdVerifier:r}){this._proxy=e,this._privyInternal=t,this._account=n,this._entropyId=i,this._entropyIdVerifier=r}}async function e2({context:e,chainType:t}){return{wallet:await F(e,{request:{chain_type:t,owner_id:void 0}})}}let e3=e=>!!e.id&&"privy-v2"===e.recovery_method;function e4(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}class e5{enqueue(e,t){this.callbacks[e]=t}dequeue(e,t){let n=this.callbacks[t];if(!n)throw Error(`cannot dequeue ${e} event: no event found for id ${t}`);switch(delete this.callbacks[t],e){case"privy:iframe:ready":case"privy:wallets:create":case"privy:user-signer:sign":case"privy:wallets:add":case"privy:wallets:set-recovery":case"privy:wallets:connect":case"privy:wallets:recover":case"privy:wallets:rpc":case"privy:wallet:create":case"privy:wallet:connect":case"privy:wallet:recover":case"privy:wallet:rpc":case"privy:solana-wallet:create":case"privy:solana-wallet:create-additional":case"privy:solana-wallet:connect":case"privy:solana-wallet:recover":case"privy:solana-wallet:rpc":case"privy:delegated-actions:consent":case"privy:mfa:verify":case"privy:mfa:init-enrollment":case"privy:mfa:submit-enrollment":case"privy:mfa:unenroll":case"privy:mfa:clear":return n;default:throw Error(`invalid wallet event type ${e}`)}}constructor(){this.callbacks={}}}async function e6(e,t,n,i,r=!1,a,s){let o=r,l=async a=>{if(o){a===+!r?i():n.current?.reject(new _("missing_or_invalid_mfa","MFA verification failed, retry."));let o=await new Promise((e,i)=>{t.current={resolve:e,reject:i},setTimeout(()=>
1{let e=new _("mfa_timeout","Timed out waiting for MFA code");n.current?.reject(e),i(e)},s)});return await e(o)}return await e()},c=null;for(let e=0;e<a;e++)try{c=await l(e),n.current?.resolve(void 0);break}catch(e){if("missing_or_invalid_mfa"!==e.type)throw n.current?.resolve(void 0),e;o=!0}if(null===c){let e=new _("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw n.current?.reject(e),e}return c}let e8=(tv=0,()=>"id-"+tv++),e7=(e,t)=>"bigint"==typeof t?t.toString():t,e9=(e,{ms:t,msg:n})=>Promise.race([e,e4(t??15e3).then(()=>Promise.reject(Error(n)))]),te=new e5;class tt{invokeWithMfa(e,t){return e9(e6(n=>e9(this.waitForReady().then(()=>e(n)),{msg:t.timeoutMsg,ms:t.timeoutMs}),this.mfa.rootPromise,this.mfa.submitPromise,()=>this.mfa.emit("mfaRequired"),t.mfaAlwaysRequired??!1,4,3e5),{msg:"Operation reached timeout: MFA verification",ms:126e4})}reload(){return this.ready=!1,this._embeddedWalletMessagePoster.reload()}ping(e=15e3){return e9(this.invoke("privy:iframe:ready",{}),{msg:"Ping reached timeout",ms:e})}create(e){return e9(this.waitForReady().then(()=>this.invoke("privy:wallet:create",e)),{msg:"Operation reached timeout: create"})}rpc(e){return this.invokeWithMfa(t=>this.invoke("privy:wallet:rpc",{...t,...e}),{timeoutMsg:"Operation reached timeout: rpc"})}createSolana(e){return this.invokeWithMfa(t=>this.invoke("privy:solana-wallet:create",{...t,...e}),{timeoutMsg:"Operation reached timeout: create",timeoutMs:6e4})}createAdditionalSolana(e){return e9(this.waitForReady().then(()=>this.invoke("privy:solana-wallet:create-additional",e)),{msg:"Operation reached timeout: create"})}solanaRpc(e){return this.invokeWithMfa(t=>this.invoke("privy:solana-wallet:rpc",{...t,...e}),{timeoutMsg:"Operation reached timeout: solana-rpc"})}delegateWallets(e){return e9(this.waitForReady().then(()=>this.invoke("privy:delegated-actions:consent",e)),{msg:"Operation reached timeout: delegated-actions:consent"})}verifyMfa(e){return this.invokeWithMfa(t=>this.invoke("privy:mfa:verify",{...t,...e}),{timeoutMsg:"Operation reached timeout: mfa:verify",mfaAlwaysRequired:!0})}initEnrollMfa(e){return this.invokeWithMfa(t=>this.invoke("privy:mfa:init-enrollment",{...t,...e}),{timeoutMsg:"Operation reached timeout: mfa:init-enrollment"})}submitEnrollMfa(e){return this.invokeWithMfa(t=>this.invoke("privy:mfa:submit-enrollment",{...t,...e}),{timeoutMsg:"Operation reached timeout: mfa:submit-enrollment"})}unenrollMfa(e){return this.invokeWithMfa(t=>this.invoke("privy:mfa:unenroll",{...t,...e}),{timeoutMsg:"Operation reached timeout: mfa:unenroll",mfaAlwaysRequired:!0})}clearMfa(e){return e9(this.waitForReady().then(()=>this.invoke("privy:mfa:clear",e)),{msg:"Operation reached timeout: mfa:clear"})}createWallet(e){return this.invokeWithMfa(t=>this.invoke("privy:wallets:create",{...t,...e}),{timeoutMsg:"Operation reached timeout: create",timeoutMs:6e4})}signWithUserSigner(e){return this.invokeWithMfa(t=>this.invoke("privy:user-signer:sign",{...t,...e}),{timeoutMsg:"Operation reached timeout: user-signer:sign"})}addWallet(e){return e9(this.waitForReady().then(()=>this.invoke("privy:wallets:add",e)),{msg:"Operation reached timeout: wallets:add"})}setRecovery(e){return this.invokeWithMfa(t=>this.invoke("privy:wallets:set-recovery",{...t,...e}),{timeoutMsg:"Operation reached timeout: wallets:set-recovery",timeoutMs:6e4})}connect(e){return e9(this.waitForReady().then(()=>this.invoke("privy:wallets:connect",e)),{msg:"Operation reached timeout: wallets:connect"})}recover(e){return this.invokeWithMfa(t=>this.invoke("privy:wallets:recover",{...t,...e}),{timeoutMsg:"Operation reached timeout: wallets:recover",timeoutMs:6e4})}rpcWallet(e){return this.invokeWithMfa(t=>this.invoke("privy:wallets:rpc",{...t,...e}),{timeoutMsg:"Operation reached timeout: wallets:rpc"})}handleEmbeddedWalletMessages(e){let{reject:t,resolve:n}=te.dequeue(e.event,e.id);return void 0!==e.error?t(new _(e.error.type,e.error.message)):n(e.data)}waitForReady(){return this.ready?Promise.resolve():new Promise(async(e,t)=>{for(;!this.ready;)this.invoke("privy:iframe:ready",{}).then(()=>{this.ready=!0,e()}).catch(t),await e4(150)})}invoke(e,t){let n=`${e}${JSON.stringify(t,e7)}`;if("privy:wallet:create"===e||"privy:solana-wallet:create"===e){let e=this.cache.get(n);if(e)return e}let i=new Promise((n,i)=>
1{let r=e8();te.enqueue(r,{resolve:n,reject:i}),this._embeddedWalletMessagePoster.postMessage(JSON.stringify({id:r,event:e,data:t}),"*")}).finally(()=>{this.cache.delete(n)});return this.cache.set(n,i),i}constructor(e,t){this.ready=!1,this.cache=new Map,this._embeddedWalletMessagePoster=e,this.mfa=t}}var tn=n(393569);let ti=["eth_sign","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];var tr=n(715599).Buffer;let ta=e=>/^0x[0-9a-fA-F]*$/.test(e),ts=e=>tr.from(e,"utf8"),to=e=>`0x${e.toString("hex")}`;var tl=n(715599).Buffer;function tc(e){return"number"==typeof e||"bigint"==typeof e?`0x${BigInt(e).toString(16)}`:"string"==typeof e?ta(e)?e:to(ts(e)):void 0}async function td({context:e,account:t,rpcRequest:n}){switch(n.chainType){case"ethereum":return async function({context:e,account:t,rpcRequest:n}){var i;switch(n.method){case"personal_sign":{let[i]=n.params,r=await M(e,e.signRequest,{chain_type:"ethereum",method:"personal_sign",wallet_id:t.id,params:i.startsWith("0x")?{message:i.slice(2),encoding:"hex"}:{message:i,encoding:"utf-8"}});if("personal_sign"!==r.method)throw Error("Unable to sign message");return{data:r.data.signature}}case"eth_signTransaction":{let[i]=n.params,r=await M(e,e.signRequest,{chain_type:"ethereum",method:"eth_signTransaction",wallet_id:t.id,params:{transaction:{from:i.from,to:i.to,nonce:tc(i.nonce),chain_id:tc(i.chainId),data:function(e){if(void 0!==e)return"string"==typeof e?ta(e)?e:to(ts(e)):to(tl.from(Uint8Array.from(e)))}(i.data),value:tc(i.value),type:i.type,gas_limit:tc(i.gasLimit),gas_price:tc(i.gasPrice),max_fee_per_gas:tc(i.maxFeePerGas),max_priority_fee_per_gas:tc(i.maxPriorityFeePerGas)}}});if("eth_signTransaction"!==r.method)throw Error("Unable to sign transaction");return{data:r.data.signed_transaction}}case"eth_signTypedData_v4":{let[,r]=n.params,a=await M(e,e.signRequest,{chain_type:"ethereum",method:n.method,wallet_id:t.id,params:{typed_data:("string"==typeof(i=r)&&(i=JSON.parse(i)),{types:i.types,primary_type:String(i.primaryType),domain:i.domain,message:i.message})}});if("eth_signTypedData_v4"!==a.method)throw Error("Unable to sign typed data");return{data:a.data.signature}}case"eth_sign":{let[,i]=n.params,r=await M(e,e.signRequest,{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:ta(i)?i:to(ts(i))}});if("secp256k1_sign"!==r.method)throw Error("Unable to sign message");return{data:r.data.signature}}case"secp256k1_sign":{let[i]=n.params,r=await M(e,e.signRequest,{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:ta(i)?i:to(ts(i))}});if("secp256k1_sign"!==r.method)throw Error("Unable to sign message");return{data:r.data.signature}}case"csw_signUserOperation":case"eth_sendTransaction":case"eth_populateTransactionRequest":throw Error(`This wallet does not support the method: ${n.method}`)}}({context:e,account:t,rpcRequest:n.request});case"solana":return async function({context:e,account:t,rpcRequest:n}){if("signMessage"===n.method){let{message:i}=n.params,r=await M(e,e.signRequest,{chain_type:"solana",method:"signMessage",wallet_id:t.id,params:{message:i,encoding:"base64"}});if("signMessage"!==r.method)throw Error("Unable to sign message");return{data:r.data.signature}}}({context:e,account:t,rpcRequest:n.request})}}class tu extends tn.A{async request(e){let t;if(t=e.method,ti.includes(t))return this.handleIFrameRpc(e);switch(e.method){case"eth_accounts":case"eth_requestAccounts":return this._account.address?[this._account.address]:[];case"eth_chainId":return`0x${this._chainId.toString(16)}`;case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":{let t=e.params?.[0];return this.handleSendTransaction(t)}case"eth_populateTransactionRequest":{let t=e.params?.[0];return this.handlePopulateTransaction(t)}default:return this.handleJsonRpc(e)}}ensureChainId(e){let t={chainId:this._chainId,...e};return this.internalSwitchEthereumChain(t.chainId),t}internalSwitchEthereumChain(e){e&&Number(e)!==this._chainId&&(this._chainId=Number(e),this._jsonRpcProvider=eV(this._chainId,this._chains,{rpcUrls:[]},{appId:this._privyInternal.appId}
1),this.emit("chainChanged",e))}async handlePopulateTransaction(e){let t=this.ensureChainId(e);return eG(this._account.address,t,this._jsonRpcProvider)}async handleSendTransaction(e){let t=this.ensureChainId(e),n=await eG(this._account.address,t,this._jsonRpcProvider),i=await this.handleIFrameRpc({method:"eth_signTransaction",params:[n]});return await this.handleJsonRpc({method:"eth_sendRawTransaction",params:[i]})}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:`0x${this._chainId.toString(16)}`};this.internalSwitchEthereumChain(t.chainId);try{return await this._jsonRpcProvider.send("eth_estimateGas",[t])}catch(e){console.warn(`Gas estimation failed with error: ${e}. Retrying gas estimation by omitting the 'from' address`);try{return delete t.from,await this._jsonRpcProvider.send("eth_estimateGas",[t])}catch(t){throw console.warn(`Gas estimation failed with error: ${t} when omitting the 'from' address`),e}}}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new I(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new I(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.internalSwitchEthereumChain(t)}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessToken();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address});let n=this._account;if(e3(n)){let{data:i}=await td({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._walletProxy.signWithUserSigner({accessToken:t,message:e})},account:n,rpcRequest:{chainType:"ethereum",request:e}});return i}try{await this._walletProxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t})}catch(n){let e=T(n);if(e&&"privy"===this._account.recovery_method)await this._walletProxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t});else{if(!e||!this._onNeedsRecovery)throw n;{let e;await new Promise(async(t,n)=>{e=setTimeout(()=>n(new j({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"})),12e4),await this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>t(!0)})}).finally(()=>clearTimeout(e))}}}return(await this._walletProxy.rpcWallet({accessToken:t,request:e,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,hdWalletIndex:this._account.wallet_index,chainType:"ethereum"})).response.data}catch(n){console.error(n);let t=n instanceof Error?n.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:t}),new j({code:"embedded_wallet_request_error",error:t})}}async handleJsonRpc(e){return this._jsonRpcProvider.send(e.method,e.params??[])}toJSON(){return`PrivyEIP1193Provider { address: '${this._account.address}', chainId: ${this._chainId}, request: [Function] }`}constructor({walletProxy:e,privyInternal:t,account:n,entropyId:i,entropyIdVerifier:r,chains:a,onNeedsRecovery:s,chainId:o=a[0].id,appApi:l}){super(),this._walletProxy=e,this._privyInternal=t,this._account=n,this._entropyId=i,this._entropyIdVerifier=r,this._chainId=o,this._chains=a,this._onNeedsRecovery=s,this._jsonRpcProvider=eV(o,a,{rpcUrls:[]},{appId:l.appId}),this._appApi=l}}function th(e){return"version"in e}function tp(e,t){let n=(th(e)?e.message:e.compileMessage()).staticAccountKeys.find(e=>e.toBase58()===t);if(!n)throw Error(`Transaction does not contain public key ${t}`);return n}var tm=n(715599).Buffer;class ty{async request(e){if(!await this._privyInternal.getAccessToken())throw new j({error:"Missing access token",code:"attempted_rpc_call_before_logged_in"});switch(e.method){case"signAndSendTransaction":return await this.handleSignAndSendTransaction(e);case"signTransaction":return await this.handleSignTransaction(e);default:return await this.handleIFrameRpc(e)}}get _publicKey(){return this._account.address}
1async connectAndRecover(e){if("privy-v2"!==this._account.recovery_method)try{await this._proxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:e})}catch(n){let t=T(n);if(t&&"privy"===this._account.recovery_method)await this._proxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:e});else{if(!t||!this._onNeedsRecovery)throw n;{let e;await new Promise(async(t,n)=>{e=setTimeout(()=>n(new j({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"})),12e4),await this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>t(!0)})}).finally(()=>clearTimeout(e))}}}}async signMessageRpc(e,t){let n=this._account;if(!e3(n))return(await this._proxy.rpcWallet({accessToken:t,request:e,chainType:"solana",hdWalletIndex:this._account.wallet_index,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier})).response.data;{let{data:i}=await td({context:{app:this._app,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._proxy.signWithUserSigner({accessToken:t,message:e})},account:n,rpcRequest:{chainType:"solana",request:e}});return{signature:i}}}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessToken();if(!t)throw Error("Missing privy token. User must be logged in");return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address}),await this.connectAndRecover(t),await this.signMessageRpc(e,t)}catch(n){console.error(n);let t=n instanceof Error?n.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:t}),new j({code:"embedded_wallet_request_error",error:t})}}async handleSignAndSendTransaction(e){try{let t=await this._privyInternal.getAccessToken();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address}),await this.connectAndRecover(t);let{transaction:n,connection:i,options:r}=e.params,a=tp(n,this._account.address),s=th(n)?tm.from(n.message.serialize()):n.serializeMessage(),{signature:o}=await this.signMessageRpc({method:"signMessage",params:{message:s.toString("base64")}},t);return n.addSignature(a,tm.from(o,"base64")),{signature:await i.sendRawTransaction(n.serialize(),r)}}catch(n){console.error(n);let t=n instanceof Error?n.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:t}),new j({code:"embedded_wallet_request_error",error:t})}}async handleSignTransaction(e){try{let t=await this._privyInternal.getAccessToken();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address}),await this.connectAndRecover(t);let{transaction:n}=e.params,i=tp(n,this._account.address),r=th(n)?tm.from(n.message.serialize()):n.serializeMessage(),{signature:a}=await this.signMessageRpc({method:"signMessage",params:{message:r.toString("base64")}},t);return n.addSignature(i,tm.from(a,"base64")),{signedTransaction:n}}catch(n){console.error(n);let t=n instanceof Error?n.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.wallet_index,error:t}),new j({code:"embedded_wallet_request_error",error:t})}}toJSON(){return`PrivyEmbeddedSolanaProvider { address: '${this._account.address}', request: [Function] }`}constructor({proxy:e,privyInternal:t,account:n,entropyId:i,entropyIdVerifier:r,onNeedsRecovery:a,app:s}){this._proxy=e,this._privyInternal=t,this._account=n,this._entropyId=i,this._entropyIdVerifier=r,this._onNeedsRecovery=a,this._app=s}}
1class tf{setMessagePoster(e){this._proxy=new tt(e,this._mfaPromises),this._mfa.setProxy(this._proxy)}async signWithUserSigner(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let t=await this._privyInternal.getAccessToken();if(!t)throw new j({error:"User must be logged in to sign a message with the user signer",code:"user_signer_sign_error"});let{signature:n}=await this._proxy.signWithUserSigner({accessToken:t,message:e.message});return{signature:n}}async add(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await e2({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:e.chainType});else{let t=await this._privyInternal.getAccessToken();if(!t)throw new j({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.addWallet({accessToken:t,...e})}let{user:t}=await this._privyInternal.refreshSession();return{user:t}}async getBitcoinProvider({wallet:e,entropyId:t,entropyIdVerifier:n,recoveryPassword:i,recoveryAccessToken:r,recoverySecretOverride:a}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessToken())throw Error("User must be logged in to create an embedded wallet");return e3(e)||await this._load({entropyId:t,entropyIdVerifier:n,wallet:e,recoveryPassword:i,recoveryAccessToken:r,recoverySecretOverride:a}),new e1({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:t,entropyIdVerifier:n})}async create({password:e,recoveryMethod:t,recoveryToken:n,recoveryKey:i,recoverySecretOverride:r,iCloudRecordNameOverride:a,solanaAccount:s,skipCallbacks:o}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode){if(t&&!t.startsWith("privy"))throw new j({error:"User-controlled server wallets do not support custom recovery methods",code:"embedded_wallet_creation_error"});await e2({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"ethereum"})}else{let o;if(o=t||(e?"user-passcode":"privy"),e&&"string"!=typeof e)throw Error("Invalid recovery password, must be a string");if("privy"===o&&this._privyInternal.config?.embedded_wallet_config.require_user_password_on_create)throw Error("Password not provided yet is required by App configuration");let l=await this._privyInternal.getAccessToken();if(!l)throw Error("User must be logged in to create an embedded wallet");let{address:c}=await this._proxy.create({accessToken:l,recoveryMethod:o,recoveryKey:i,recoveryPassword:e,recoveryAccessToken:n,recoverySecretOverride:r,iCloudRecordNameOverride:a,solanaAddress:s?.address});if(!c)throw Error("Failed to create wallet")}return await this._privyInternal.refreshSession(o)}async createSolana(e){if(!this._proxy)throw new j({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await e2({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"solana"});else{let t=await this._privyInternal.getAccessToken();if(!t)throw new j({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});e?.ethereumAccount&&await this.getProvider(e.ethereumAccount);let{publicKey:n}=await this._proxy.createSolana({accessToken:t,ethereumAddress:e?.ethereumAccount?.address});if(!n)throw new j({error:"Failed to create wallet",code:"embedded_wallet_creation_error"})}return await this._privyInternal.refreshSession()}async delegateWallets({delegatedWallets:e,rootWallet:t}){if(!this._proxy)throw new j({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let n=await this._privyInternal.getAccessToken();if(!n)throw new j({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.delegateWallets({accessToken:n,delegatedWallets:e,rootWallet:t})}async getProvider(e,t,n,i,r){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");
1return e3(e)||await this._load({wallet:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:t,recoveryKey:r,recoveryAccessToken:n,recoverySecretOverride:i}),new tu({account:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}async getEthereumProvider({wallet:e,entropyId:t,entropyIdVerifier:n,recoveryPassword:i,recoveryAccessToken:r,recoverySecretOverride:a,recoveryKey:s,onNeedsRecovery:o}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessToken())throw Error("User must be logged in to create an embedded wallet");return e3(e)||(!o||i||r||a||s)&&await this._load({entropyId:t,entropyIdVerifier:n,wallet:e,recoveryPassword:i,recoveryAccessToken:r,recoverySecretOverride:a,recoveryKey:s}),new tu({account:e,entropyId:t,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,onNeedsRecovery:o,appApi:this._appApi})}async getSolanaProvider(e,t,n,i,r,a,s){if(!this._proxy)throw new j({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return e3(e)||(!s||i||r||a)&&await this._load({wallet:e,entropyId:t,entropyIdVerifier:n,recoveryPassword:i,recoveryAccessToken:r,recoverySecretOverride:a}),new ty({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:t,entropyIdVerifier:n,onNeedsRecovery:s,app:this._appApi})}async setRecovery(e){let{wallet:t,...n}=e;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(e3(t))throw new j({error:"This wallet does not support setting recovery methods",code:"unsupported_recovery_method"});(function({currentRecoveryMethod:e,upgradeToRecoveryMethod:t}){switch(e){case"privy":case"user-passcode":case"recovery-encryption-key":return;case"icloud":case"google-drive":if(e===t)throw Error("Cannot upgrade to the existing cloud platform");return;default:throw Error("Unknown recovery method")}})({currentRecoveryMethod:t.recovery_method,upgradeToRecoveryMethod:"icloud-native"===n.recoveryMethod?"icloud":n.recoveryMethod}),await this._load("solana"===t.chain_type?{wallet:t,entropyId:t.address,entropyIdVerifier:"solana-address-ver
1ifier"}:{wallet:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier"});let i=await this._privyInternal.getAccessToken();if(!i)throw Error("User must be logged in to interact with embedded wallets");let r=t.recovery_method;this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_started",{address:t.address,target_recovery_method:n.recoveryMethod,existing_recovery_method:r});try{let e;if("user-passcode"===n.recoveryMethod)e={recoveryMethod:"user-passcode",recoveryPassword:n.password};else if("google-drive"===n.recoveryMethod)e={recoveryMethod:"google-drive",recoveryAccessToken:n.recoveryAccessToken};else if("icloud"===n.recoveryMethod)e={recoveryMethod:"icloud",recoveryAccessToken:n.recoveryAccessToken};else if("icloud-native"===n.recoveryMethod)e={recoveryMethod:"icloud-native",iCloudRecordNameOverride:n.iCloudRecordNameOverride,recoverySecretOverride:n.recoverySecretOverride};else if("recovery-encryption-key"===n.recoveryMethod)e={recoveryMethod:"recovery-encryption-key",recoveryKey:n.recoveryKey};else{if("privy"!==n.recoveryMethod)throw Error(`Unknown recovery method: ${n.recoveryMethod}`);e={recoveryMethod:"privy"}}await this._proxy.setRecovery({accessToken:i,entropyId:t.address,entropyIdVerifier:"solana"===t.chain_type?"solana-address-ver
1ifier":"ethereum-address-verifier",...e}),this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_completed",{address:t.address,target_recovery_method:n.recoveryMethod,existing_recovery_method:r});let{user:a}=await this._privyInternal.refreshSession();return{user:a,provider:"ethereum"!==t.chain_type?null:new tu({account:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}}catch(e){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:e instanceof Error?e.message:"Unable to recover wallet"}),e}}getURL(){let e=new URL(`${this._privyInternal.baseUrl}/apps/${this._privyInternal.appId}/embedded-wallets`);return this._privyInternal.caid&&e.searchParams.append("caid",this._privyInternal.caid),this._privyInternal.appClientId&&e.searchParams.append("client_id",this._privyInternal.appClientId),e.href}get chains(){return this._chains}onMessage(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return this._proxy.handleEmbeddedWalletMessages(e)}reload(){this._proxy?this._proxy.reload():console.warn("Attempted to reload proxy before initialized")}async ping(e){try{if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._proxy.ping(e),!0}catch(e){return console.error(e),!1}}async _load({entropyId:e,entropyIdVerifier:t,wallet:n,recoveryPassword:i,recoveryKey:r,recoveryAccessToken:a,recoverySecretOverride:s}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let o=await this._privyInternal.getAccessToken();if(!o)throw Error("User must be logged in to interact with embedded wallets");try{return await this._proxy.connect({accessToken:o,entropyId:e,entropyIdVerifier:t}),e}catch(l){if(T(l))try{if("privy"===n.recovery_method){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:n.address,recovery_method:n.recovery_method});let i=await this._proxy.recover({accessToken:o,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:n.address,recovery_method:n.recovery_method}),i.entropyId}if("user-passcode"===n.recovery_method&&i){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:n.address,recovery_method:n.recovery_method});let r=await this._proxy.recover({accessToken:o,recoveryPassword:i,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:n.address,recovery_method:n.recovery_method}),r.entropyId}if(["google-drive","icloud"].includes(n.recovery_method)&&a){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:n.address,recovery_method:n.recovery_method});let i=await this._proxy.recover({accessToken:o,recoveryAccessToken:a,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:n.address,recovery_method:n.recovery_method}),i.entropyId}if("icloud"===n.recovery_method&&s){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:n.address,recovery_method:"icloud-native"});let i=await this._proxy.recover({accessToken:o,recoverySecretOverride:s,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:n.address,recovery_method:"icloud-native"}),i.entropyId}if("recovery-encryption-key"===n.recovery_method&&r){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:n.address,recovery_method:n.recovery_method});let i=await this._proxy.recover({accessToken:o,recoveryKey:r,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:n.address,recovery_method:n.recovery_method}),i.entropyId}}catch(t){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_failed",{address:n.address,recovery_method:n.recovery_method,error:t instanceof Error?t.message:`Unable to re
1cover wallet: ${e}`}),t}throw l}}constructor(e,t,n,i,r,a){if(this._chains=Array.from(A.m),this._privyInternal=e,t&&(this._proxy=new tt(t,r),i.setProxy(this._proxy)),n){let e=(0,D._)(n);this._chains=e}this._mfa=i,this._mfaPromises=r,this._appApi=a}}class tg extends tn.A{constructor(){super(),this.rootPromise={current:null},this.submitPromise={current:null}}}var tw,tv,tb,tx=((tb={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",tb.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",tb.MISSING_OR_INVALID_PRIVY_CLIENT_ID="missing_or_invalid_privy_client_id",tb.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",tb.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",tb.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",tb.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",tb.INVALID_DATA="invalid_data",tb.INVALID_CREDENTIALS="invalid_credentials",tb.INVALID_CAPTCHA="invalid_captcha",tb.LINKED_TO_ANOTHER_USER="linked_to_another_user",tb.ALLOWLIST_REJECTED="allowlist_rejected",tb.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",tb.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",tb.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",tb.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",tb.TOO_MANY_REQUESTS="too_many_requests",tb.INVALID_ORIGIN="invalid_origin",tb.MISSING_ORIGIN="missing_origin",tb.INVALID_NATIVE_APP_ID="invalid_native_app_id",tb.TOKEN_ALREADY_USED="token_already_used",tb.ALREADY_LOGGED_OUT="already_logged_out",tb.NOT_SUPPORTED="not_supported",tb.USER_UNSUBSCRIBED="user_unsubscribed",tb.MAX_APPS_REACHED="max_apps_reached",tb.USER_LIMIT_REACHED="max_accounts_reached",tb.DEVICE_REVOKED="device_revoked",tb.WALLET_PASSWORD_EXISTS="wallet_password_exists",tb.OAUTH_STATE_MISMATCH="oauth_state_mismatch",tb.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",tb.MAX_TEST_ACCOUNTS_REACHED="max_test_accounts_reached",tb.DISALLOWED_LOGIN_METHOD="disallowed_login_method",tb.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",tb.DISALLOWED_RECOVERY_METHOD="disallowed_recovery_method",tb.LEGACY_DASHBOARD_LOGIN_CONFIGURATION="legacy_dashboard_login_configuration",tb.CANNOT_SET_PASSWORD="cannot_set_password",tb.INVALID_PKCE_PARAMETERS="invalid_pkce_parameters",tb.INVALID_APP_URL_SCHEME_CONFIGURATION="invalid_app_url_scheme_configuration",tb.CROSS_APP_CONNECTION_NOT_ALLOWED="cross_app_connection_not_allowed",tb.USER_DOES_NOT_EXIST="user_does_not_exist",tb.ALREADY_EXISTS="resource_already_exists",tb.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",tb.USER_HAS_NOT_DELEGATED_WALLET="user_has_not_delegated_wallet",tb.FEATURE_NOT_ENABLED="feature_not_enabled",tb.INSUFFICIENT_FUNDS="insufficient_funds",tb.TRANSACTION_BROADCAST_FAILURE="transaction_broadcast_failure",tb.INVALID_POLICY_FORMAT="invalid_policy_format",tb.POLICY_VIOLATION="policy_violation",tb.AUTHORIZATION_KEY_HAS_ASSOCIATED_WALLETS="authorization_key_has_associated_wallets",tb.INVALID_REQUEST="invalid_request",tb);let t_={path:"/api/v1/apps/:app_id",method:"GET"},tC={path:"/api/v1/analytics_events",method:"POST"},tI={path:"/api/v1/sessions",method:"POST"},tE={path:"/api/v1/sessions/logout",method:"POST"};var tT=n(872767),tA=n(999523);let tS=Promise.allSettled.bind(Promise)??(e=>Promise.all(e.map(e=>e.then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e}))))),tk="privy:token",tP="privy-token",tj="privy:refresh_token",tO="privy-refresh-token",tN="privy:id-token",tR="privy-id-token",tM="privy-session";class tD extends tn.A{set isUsingServerCookies(e){this._isUsingServerCookies=e}async getToken(){let e=await this._storage.get(tk);try{return"string"==typeof e?new eQ(e).value:null}catch(e){return console.error(e),await this.destroyLocalState({reason:"getToken_error"}),null}}async getRefreshToken(){let e=await this._storage.get(tj);return"string"==typeof e?e:null}async getIdentityToken(){let e=await this._storage.get(tN);return"string"==typeof e?e:null}get mightHaveServerCookies(){try{let e=tA.A.get(tM);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e,t){return this.mightHaveServerCookies||"string"==typeof e&&"string"==typeof t}tokenIsActive(e){if(!e)return!1;let t=eQ.parse(e);return null!==t&&!t.isExpired(30)}async destroyLocalState(e){await tS([this._storage.del(tk),this._storage.del(tj),this._storage.del(tN),this._storage.del(this.GUEST_CREDENTIAL_STORAGE_KEY)]),tA.A.remove(tP),tA.A.remove(tO),tA.A.remove(tR),tA.A.remove(tM),e?.reason&&this.emit
1("storage_cleared",{reason:e.reason})}async storeToken(e){if("string"==typeof e){let t=await this._storage.get(tk);if(await this._storage.put(tk,e),!this._isUsingServerCookies){let t=eQ.parse(e)?.expiration;tA.A.set(tP,e,{sameSite:"Strict",secure:!0,expires:t?new Date(1e3*t):void 0})}t!==e&&this.emit("token_stored",{cookiesEnabled:this._isUsingServerCookies})}else{let e=await this._storage.get(tk);await this._storage.del(tk),tA.A.remove(tP),null!==e&&this.emit("token_cleared",{reason:"set_with_non_string_value"})}}async storeRefreshToken(e){"string"==typeof e?(await this._storage.put(tj,e),this._isUsingServerCookies||(tA.A.set(tM,"t",{sameSite:"Strict",secure:!0,expires:30}),tA.A.set(tO,e,{sameSite:"Strict",secure:!0,expires:30})),this.emit("refresh_token_stored",{cookiesEnabled:this._isUsingServerCookies})):(await this._storage.del(tj),tA.A.remove(tO),tA.A.remove(tM),this.emit("refresh_token_cleared",{reason:"set_with_non_string_value"}))}async updateWithTokensResponse(e){let t=(await tS([this.storeToken(e.token),this.storeRefreshToken(e.refresh_token),this.storeIdentityToken(e.identity_token),this.processOAuthTokens(e.oauth_tokens)])).filter(e=>"rejected"===e.status);t.length>0&&this.emit("error_storing_tokens",t.map(e=>String(e.reason)).join(", "))}async processOAuthTokens(e){e&&this.emit("oauth_tokens_granted",e)}async storeIdentityToken(e){if("string"==typeof e){let t=await this._storage.get(tN);if(await this._storage.put(tN,e),!this._isUsingServerCookies){let t=eQ.parse(e)?.expiration;tA.A.set(tR,e,{sameSite:"Strict",secure:!0,expires:t?new Date(1e3*t):void 0})}t!==e&&this.emit("identity_token_stored",{cookiesEnabled:this._isUsingServerCookies})}else{let e=await this._storage.get(tN);await this._storage.del(tN),tA.A.remove(tR),null!==e&&this.emit("identity_token_cleared",{reason:"set_with_non_string_value"})}}async getOrCreateGuestCredential(){let e=this._storage.get(this.GUEST_CREDENTIAL_STORAGE_KEY);if(e&&"string"==typeof e)return e;let t=tT.l(crypto.getRandomValues(new Uint8Array(32)));return await this._storage.put(this.GUEST_CREDENTIAL_STORAGE_KEY,t),t}constructor(e){super(),this._isUsingServerCookies=!1,this._storage=e.storage,this.GUEST_CREDENTIAL_STORAGE_KEY=`privy:guest:${e.appId}`}}tD.events=["storage_cleared","token_cleared","refresh_token_cleared","identity_token_cleared","token_stored","refresh_token_stored","identity_token_stored","oauth_tokens_granted","error_storing_tokens"];let tU=()=>{},tL={NONE:-1/0,ERROR:1,WARN:2,INFO:3,DEBUG:1/0},tF="privy:caid";class tW{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new j({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:n}){let i;return`${this.baseUrl}${i=e.path,t?Object.entries(t).reduce((e,[t,n])=>e.replace(`:${t}`,`${n}`),i):i}${function(e){let t=new URLSearchParams;for(let n in e)null!=e[n]&&t.append(n,String(e[n]));return Array.from(t).length?"?"+t.toString():""}(n)}`}async fetch(e,{body:t,params:n,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let s=new Request(this.getPath(e,{params:n,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),o=await a(s),l=await this._fetch(s,o),c=await l.json();if(l.status>299)throw new P(c);return c}async _beforeRequestWithoutInitialize(e){let t,n=await this.session.getToken(),i=new Headers(e.headers);i.set("privy-app-id",this.appId),this.appClientId&&i.set("privy-client-id",this.appClientId),i.set("privy-client",this._sdkVersion),n&&i.set("Authorization",`Bearer ${n}`),i.set("Content-Type","application/json"),i.set("Accept","application/json");let r=await this._getOrGenerateClientAnalyticsId();return r&&i.set("privy-ca-id",r),this.nativeAppIdentifier&&i.set("x-native-app-identifier",this.nativeAppIdentifier),{signal:(t=new AbortController,setTimeout(()=>t.abort(),2e4),t.signal),headers:i,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessToken(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(t_,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(tF);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=(0,e_.A)()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(tF,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(tF)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(tC,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new j({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,n=t??"key",i=this._cache.get(n);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let r=this._refreshSession(t,e);this._cache.set(n,r);try{return await r}finally{this._cache.delete(n)}}async _refreshSession(e,t){let n=await this.session.getToken();if(!this.session.hasRefreshCredentials(n,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new P({code:tx.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{this.logger.debug(`[privy:refresh] fetching: ${tI.path}`);let n=await this.fetch(tI,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=n.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),t||this.callbacks?.setUser?.(n.user),"set"===i&&(await this.session.updateWithTokensResponse(n),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&n.token&&(await this.session.storeToken(n.token),this.logger.debug("[privy:refresh] access token stored"),n.identity_token&&(this.logger.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(n.identity_token))),this.logger.debug("[privy:refresh] returning response"),n}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof P&&e.code===tx.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}
1async getAccessToken(){let[e,t]=await Promise.all([this.session.getToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),n=await this.session.getToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),n===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??n}return e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${(0,e_.A)()}`,t="blobby";await this._storage.put(e,t);let n=await this._storage.get(e);return await this._storage.del(e),n===t}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.52.4",this._cache=new Map,this.logger=(({level:e}={level:"ERROR"})=>({get level(){return e},error:tL[e]>=tL.ERROR?console.error:tU,warn:tL[e]>=tL.WARN?console.warn:tU,info:tL[e]>=tL.INFO?console.info:tU,debug:tL[e]>=tL.DEBUG?console.debug:tU}))({level:e.logLevel??"ERROR"}),this._storage=e.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=e.baseUrl??"https://auth.privy.io",this.appId=e.appId,this.appClientId=e.appClientId,this._sdkVersion=e.sdkVersion??this._sdkVersion,this.callbacks=e.callbacks,this.nativeAppIdentifier=e.nativeAppIdentifier,this.session=new tD({storage:this._storage,isUsingServerCookies:!1,appId:e.appId}),this._fetch=eU(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})})}}let t$={path:"/api/v1/users/me/accept_terms",method:"POST"};class tB{async get(){let{user:e}=await this._privyInternal.refreshSession();return{user:e}}async acceptTerms(){return{user:await this._privyInternal.fetch(t$,{})}}constructor(e){this._privyInternal=e}}let tz={path:"/api/v1/custom_jwt_account/authenticate",method:"POST"},tq=e=>e?e.linked_accounts.filter(tV).sort((e,t)=>e.wallet_index-t.wallet_index):[],tV=e=>"wallet"===e.type&&"privy"===e.wallet_client_type&&"embedded"===e.connector_type&&"ethereum"===e.chain_type,tH=e=>tq(e).find(e=>0===e.wallet_index)??null,tG=e=>e?e.linked_accounts.filter(tK).sort((e,t)=>e.wallet_index-t.wallet_index):[],tK=e=>"wallet"===e.type&&"privy"===e.wallet_client_type&&"embedded"===e.connector_type&&"solana"===e.chain_type,tJ=async(e,t,n)=>{let i=((e,t)=>!("off"===t||tq(e).length>0||e.linked_accounts.filter(e=>"wallet"===e.type&&"ethereum"===e.chain_type).length>0&&"all-users"!==t))(t.user,n?.ethereum?.createOnLogin??"off"),r=((e,t)=>!("off"===t||tG(e).length>0||e.linked_accounts.filter(e=>"wallet"===e.type&&"solana"===e.chain_type).length>0&&"all-users"!==t))(t.user,n?.solana?.createOnLogin??"off");if(i&&r){let n=await e.create({recoveryMethod:"privy",skipCallbacks:!0});return{...await e.createSolana({ethereumAccount:tH(n.user)??void 0}),is_new_user:t.is_new_user,oauth_tokens:t.oauth_tokens}}return i?{...await e.create({recoveryMethod:"privy",solanaAccount:tG(t.user).find(e=>0===e.wallet_index)??null??void 0}),is_new_user:t.is_new_user,oauth_tokens:t.oauth_tokens}:r?{...await e.createSolana({ethereumAccount:tH(t.user)??void 0}),is_new_user:t.is_new_user,oauth_tokens:t.oauth_tokens}:t};class tZ{async syncWithToken(e,t,n){let i=await this._privyInternal.fetch(tz,{body:{token:e,mode:n}});await this._privyInternal.session.updateWithTokensResponse(i);let r=await tJ(this._embedded,i,t?.embedded);return this._privyInternal.callbacks?.setUser?.(r.user),r}constructor(e,t){this._privyInternal=e,this._embedded=t}}let tY={path:"/api/v1/passwordless/authenticate",method:"POST"},tQ={path:"/api/v1/passwordless/init",method:"POST"},tX={path:"/api/v1/passwordless/link",method:"POST"},t0={path:"/api/v1/passwordless/unlink",method:"POST"},t1={path:"/api/v1/passwordless/update",method:"POST"};class t2{async sendCode(e,t){return this._privyInternal.fetch(tQ,{body:{email:e,token:t}})}async loginWithCode(e,t,n,i){let r=await this._privyInternal.fetch(tY,{body:{email:e,code:t,mode:n}});await this._privyInternal.session.updateWithTokensResponse(r);let a=await tJ(this._embedded,r,i?.embedded);return this._privyInternal.callbacks?.setUser?.(a.user),a}async linkWithCode(e,t){await this._privyInternal.fetch(tX,{body:{email:e,code:t}});let n=await this._privyInternal.refreshSession();return{user:n.user,identity_token:n.identity_token}}async updateEmail({oldEmailAddress:e,newEmailAddress:t,code:n}){await this._privyInternal.fetch(t1,{body:{oldAddress:e,newAddress:t,code:n}});let i=await this._privyInternal.refreshSession();return{user:i.user,identity_token:i.identity_token}}async unlink(e){await this._privyInternal.fetch(t0,{body:{address:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}constructor(e,t){this._privyInternal=e,this._embedded=t}}let t3={path:"/api/v1/farcaster/init",method:"POST"},t4={path:"/api/v1/farcaster/authenticate",method:"POST"},t5={path:"/api/v1/farcaster/link",method:"POST"},t6={path:"/api/v1/farcaster/unlink",method:"POST"},t8={path:"/api/v1/farcaster/status",method:"GET"},t7={path:"/api/v2/farcaster/init",method:"POST"},t9={path:"/api/v2/farcaster/authenticate",method:"POST"};class ne{async initializeAuth({relyingParty:e,redirectUrl:t,token:n}){return await this._privyInternal.fetch(t3,{body:{relying_party:e,redirect_url:t,token:n}})}async getFarcasterStatus({channel_token:e}){return await this._privyInternal.fetch(t8,{headers:{"farcaster-channel-token":e}})}async authenticate({channel_token:e,message:t,signature:n,fid:i,mode:r},a){let s=await this._privyInternal.fetch(t4,{body:{channel_token:e,message:t,signature:n,fid:i,mode:r}});await this._privyInternal.session.updateWithTokensResponse(s);let o=await tJ(this._embedded,s,a?.embedded);return this._privyInternal.callbacks?.setUser?.(o.user),o}async link({channel_token:e,message:t,signature:n,fid:i}){await this._privyInternal.fetch(t5,{body:{channel_token:e,message:t,signature:n,fid:i}});let r=await this._privyInternal.refreshSession();return{user:r.user,identity_token:r.identity_token}}async unlink({fid:e}
1){await this._privyInternal.fetch(t6,{body:{fid:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}constructor(e,t){this._privyInternal=e,this._embedded=t}}class nt{async initializeAuth(){return await this._privyInternal.fetch(t7,{body:{}})}async authenticate({message:e,signature:t,fid:n},i){let r=await this._privyInternal.fetch(t9,{body:{message:e,signature:t,fid:n}});await this._privyInternal.session.updateWithTokensResponse(r);let a=await tJ(this._embedded,r,i?.embedded);return this._privyInternal.callbacks?.setUser?.(a.user),a}constructor(e,t){this._privyInternal=e,this._embedded=t}}let nn={path:"/api/v1/guest/authenticate",method:"POST"};class ni{async create(e){let t=await this._privyInternal.session.getOrCreateGuestCredential(),n=await this._privyInternal.fetch(nn,{body:{guest_credential:t}});await this._privyInternal.session.updateWithTokensResponse(n);let i=await tJ(this._embedded,n,e?.embedded);return this._privyInternal.callbacks?.setUser?.(i.user),i}constructor(e,t){this._privyInternal=e,this._embedded=t}}let nr={path:"/api/v1/oauth/authenticate",method:"POST"},na={path:"/api/v1/oauth/init",method:"POST"},ns={path:"/api/v1/oauth/link",method:"POST"},no={path:"/api/v1/oauth/unlink",method:"POST"},nl="privy:state_code",nc="privy:code_verifier";async function nd(e,t){let n=(new TextEncoder).encode(e);return new Uint8Array(await t("SHA-256",n))}function nu(){return tT.l(crypto.getRandomValues(new Uint8Array(36)))}async function nh({codeVerifier:e,method:t="S256",digest:n=crypto.subtle.digest.bind(crypto.subtle)}){if("S256"!=t)return e;{let t=await nd(e,n);return tT.l(t)}}class np{async generateURL(e,t){let n=nu(),i=nu(),r=await nh({codeVerifier:n,digest:this._crypto?.digest});return await Promise.all([this._storage.put(nc,n),this._storage.put(nl,i)]),this._privyInternal.fetch(na,{body:{redirect_to:t,provider:e,code_challenge:r,state_code:i}})}async loginWithCode(e,t,n,i,r,a){let[s,o]=await Promise.all([this._storage.get(nc),this._storage.get(nl)]);if(o!==t)throw this._privyInternal.createAnalyticsEvent("possible_phishing_attempt",{flow:"oauth",provider:n,storedStateCode:o??"",returnedStateCode:t??""}),new j({code:"pkce_state_code_mismatch",error:"Unexpected auth flow. This may be a phishing attempt."});let l=await this._privyInternal.fetch(nr,{body:{authorization_code:e,code_type:i,state_code:o,code_verifier:s,mode:r}});await this._privyInternal.session.updateWithTokensResponse(l);let c=await tJ(this._embedded,l,a?.embedded);return await Promise.all([this._storage.del(nc),this._storage.del(nl)]),this._privyInternal.callbacks?.setUser?.(c.user),c}async linkWithCode(e,t,n,i){let[r,a]=await Promise.all([this._storage.get(nc),this._storage.get(nl)]);if(a!==t)throw this._privyInternal.createAnalyticsEvent("possible_phishing_attempt",{flow:"oauth",provider:n,storedStateCode:a??"",returnedStateCode:t??""}),new j({code:"pkce_state_code_mismatch",error:"Unexpected auth flow. This may be a phishing attempt."});let s=await this._privyInternal.fetch(ns,{body:{authorization_code:e,code_type:i,state_code:a,code_verifier:r}});await this._privyInternal.session.processOAuthTokens(s.oauth_tokens);let o=await this._privyInternal.refreshSession();return await Promise.all([this._storage.del(nc),this._storage.del(nl)]),{user:o.user,identity_token:o.identity_token}}async unlink(e,t){await this._privyInternal.fetch(no,{body:{provider:e,subject:t}});let n=await this._privyInternal.refreshSession();return{user:n.user,identity_token:n.identity_token}}constructor(e,t,n,i){this._privyInternal=e,this._embedded=t,this._storage=n,this._crypto=i}}let nm={path:"/api/v1/passkeys/link",method:"POST"},ny={path:"/api/v1/passkeys/authenticate",method:"POST"},nf={path:"/api/v1/passkeys/register",method:"POST"},ng={path:"/api/v1/passkeys/authenticate/init",method:"POST"},nw={path:"/api/v1/passkeys/register/init",method:"POST"},nv={path:"/api/v1/passkeys/link/init",method:"POST"};class nb{async generateRegistrationOptions(e){return await this._privyInternal.fetch(nv,{body:{relying_party:e}})}async generateAuthenticationOptions(e){return await this._privyInternal.fetch(ng,{body:{relying_party:e}})}async generateSignupOptions(e){return await this._privyInternal.fetch(nw,{body:{relying_party:e}})}async loginWithPasskey(e,t,n,i){let r=await this._privyInternal.fetch(ny,{body:{relying_party:n,challenge:t,authenticator_response:this._transformAuthenticationResponseToSnakeCase(e)}});await this._privyInternal.session.updateWithTokensResponse(r);let a=await tJ(this._embedded,r,i?.embedded);return this._privyInternal.callbacks?.setUser?.(a.user),a}async signupWithPasskey(e,t,n){let i=await this._privyInternal.fetch(nf,{body:{relying_party:t,authenticator_response:this._transformRegistrationResponseToSnakeCase(e)}});await this._privyInternal.session.updateWithTokensResponse(i);let r=await tJ(this._embedded,i,n?.embedded);return this._privyInternal.callbacks?.setUser?.(r.user),r}async linkWithPasskey(e,t){await this._privyInternal.fetch(nm,{body:{relying_party:t,authenticator_response:this._transformRegistrationResponseToSnakeCase(e)}});let n=await this._privyInternal.refreshSession();return{user:n.user,identity_token:n.identity_token}}_transformRegistrationResponseToSnakeCase(e){return{type:e.type,id:e.id,raw_i
1d:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData||void 0,transports:e.response.transports||void 0,public_key:e.response.publicKey||void 0,public_key_algorithm:e.response.publicKeyAlgorithm||void 0},authenticator_attachment:e.authenticatorAttachment||void 0,client_extension_results:{app_id:e.clientExtensionResults.appid||void 0,cred_props:e.clientExtensionResults.credProps||void 0,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret||void 0}}}_transformAuthenticationResponseToSnakeCase(e){return{type:e.type,id:e.id,raw_id:e.rawId,response:{signature:e.response.signature,client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,user_handle:e.response.userHandle||void 0},authenticator_attachment:e.authenticatorAttachment||void 0,client_extension_results:{app_id:e.clientExtensionResults.appid||void 0,cred_props:e.clientExtensionResults.credProps||void 0,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret||void 0}}}constructor(e,t){this._privyInternal=e,this._embedded=t}}let nx={path:"/api/v1/passwordless_sms/authenticate",method:"POST"},n_={path:"/api/v1/passwordless_sms/init",method:"POST"},nC={path:"/api/v1/passwordless_sms/link",method:"POST"},nI={path:"/api/v1/passwordless_sms/unlink",method:"POST"},nE={path:"/api/v1/passwordless_sms/update",method:"POST"};class nT{async sendCode(e,t){return this._privyInternal.fetch(n_,{body:{phoneNumber:e,token:t}})}async loginWithCode(e,t,n,i){let r=await this._privyInternal.fetch(nx,{body:{phoneNumber:e,code:t,mode:n}});await this._privyInternal.session.updateWithTokensResponse(r);let a=await tJ(this._embedded,r,i?.embedded);return this._privyInternal.callbacks?.setUser?.(a.user),a}async linkWithCode(e,t){await this._privyInternal.fetch(nC,{body:{phoneNumber:e,code:t}});let n=await this._privyInternal.refreshSession();return{user:n.user,identity_token:n.identity_token}}async updatePhone({oldPhoneNumber:e,newPhoneNumber:t,code:n}){await this._privyInternal.fetch(nE,{body:{old_phone_number:e,new_phone_number:t,code:n}});let i=await this._privyInternal.refreshSession();return{user:i.user,identity_token:i.identity_token}}async unlink(e){await this._privyInternal.fetch(nI,{body:{phoneNumber:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}constructor(e,t){this._privyInternal=e,this._embedded=t}}let nA={path:"/api/v1/siwe/init",method:"POST"},nS={path:"/api/v1/siwe/authenticate",method:"POST"},nk={path:"/api/v1/siwe/link",method:"POST"},nP={path:"/api/v1/siwe/link_smart_wallet",method:"POST"},nj={path:"/api/v1/siwe/unlink",method:"POST"};class nO{async unlinkWallet(e){await this._privyInternal.fetch(nj,{body:{address:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}async linkWithSiwe(e,t,n){let i=t||this._wallet,r=n||this._preparedMessage;if(!i)throw Error("A wallet must be provided in the init step or as an argument to linkWithSiwe");if(!r)throw Error("A message must be generated and signed before being used to link a wallet to privy");await this._privyInternal.fetch(nk,{body:{message:r,signature:e,chainId:i.chainId,walletClientType:i.walletClientType,connectorType:i.connectorType}});let a=await this._privyInternal.refreshSession();return{user:a.user,identity_token:a.identity_token}}async loginWithSiwe(e,t,n,i,r){let a=t||this._wallet,s=n||this._preparedMessage;if(!a)throw Error("A wallet must be provided in the init step or as an argument to loginWithSiwe");if(!s)throw Error("A message must be generated and signed before being used to login to privy with a wallet");let o=await this._privyInternal.fetch(nS,{body:{signature:e,message:s,chainId:a.chainId,walletClientType:a.walletClientType,connectorType:a.connectorType,mode:i}});await this._privyInternal.session.updateWithTokensResponse(o);let l=await tJ(this._embedded,o,r?.embedded);return this._privyInternal.callbacks?.setUser?.(l.user),l}async init(e,t,n){var i;this._wallet=e;let{nonce:r}=await this._privyInternal.fetch(nA,{body:{address:e.address}}),a=`${(i={chainId:e.chainId.toString().replace("eip155:",""),address:e.address,issuedAt:(new Date).toISOString(),statement:"By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",domain:t,nonce:r,uri:n}).domain} wants you to sign in with your Ethereum account:
2${i.address}
3
4${i.statement}
5
6URI: ${i.uri}
7Version: 1
8Chain ID: ${i.chainId}
9Nonce: ${i.nonce}
10Issued At: ${i.issuedAt}
11Resources:
12- https://privy.io`;return this._preparedMessage=a,{nonce:r,message:a}}constructor(e,t){this._wallet=void 0,this._privyInternal=e,this._embedded=t}}let nN={path:"/api/v1/siws/init",method:"POST"},nR={path:"/api/v1/siws/authenticate",method:"POST"},nM={path:"/api/v1/siws/link",method:"POST"},nD={path:"/api/v1/siws/unlink",method:"POST"};class nU{async unlink({address:e}){await this._privyInternal.fetch(nD,{body:{address:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}async link({message:e,signature:t,walletClientType:n,connectorType:i}){await this._privyInternal.fetch(nM,{body:{message:e,signature:t,walletClientType:n,connectorType:i}});let r=await this._privyInternal.refreshSession();return{user:r.user,identity_token:r.identity_token}}async login({mode:e,message:t,signature:n,walletClientType:i,connectorType:r,opts:a}){let s=await this._privyInternal.fetch(nR,{body:{signature:n,message:t,walletClientType:i,connectorType:r,mode:e}});await this._privyInternal.session.updateWithTokensResponse(s);let o=await tJ(this._embedded,s,a?.embedded);return this._privyInternal.callbacks?.setUser?.(o.user),o}async fetchNonce({address:e}){let{nonce:t}=await this._privyInternal.fetch(nN,{body:{address:e}});return{nonce:t}}constructor(e,t){this._privyInternal=e,this._embedded=t}}class nL{async link(e,t,n){await this._privyInternal.fetch(nP,{body:{message:e,signature:t,smart_wallet_type:n}});let i=await this._privyInternal.refreshSession();return{user:i.user,identity_token:i.identity_token}}async init(e){var t;let{nonce:n}=await this._privyInternal.fetch(nA,{body:{address:e.address}});return{nonce:n,message:`${(t={chainId:e.chainId.toString().replace("eip155:",""),address:e.address,issuedAt:(new Date).toISOString(),statement:"By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",domain:"privy.io",uri:"https://auth.privy.io",nonce:n}).domain} wants you to sign in with your Ethereum account:
13${t.address}
14
15${t.statement}
16
17URI: ${t.uri}
18Version: 1
19Chain ID: ${t.chainId}
20Nonce: ${t.nonce}
21Issued At: ${t.issuedAt}
22Resources:
23- https://privy.io`}}constructor(e){this._privyInternal=e}}class nF{async logout(){try{let e=await this._privyInternal.session.getRefreshToken()??void 0;await this._privyInternal.fetch(tE,{body:{refresh_token:e}})}catch(e){console.warn("Error destroying session")}await Promise.all([this._privyInternal.session.destroyLocalState({reason:"logout"}),this._privyInternal.destroyClientAnalyticsId()]),this._privyInternal.callbacks?.setUser?.(null)}constructor(e,t,n,i){this._privyInternal=e,this.customProvider=new tZ(this._privyInternal,t),this.phone=new nT(this._privyInternal,t),this.email=new t2(this._privyInternal,t),this.oauth=new np(this._privyInternal,t,n,i),this.guest=new ni(this._privyInternal,t),this.siwe=new nO(this._privyInternal,t),this.siws=new nU(this._privyInternal,t),this.smartWallet=new nL(this._privyInternal),this.passkey=new nb(this._privyInternal,t),this.farcaster=new ne(this._privyInternal,t),this.farcasterV2=new nt(this._privyInternal,t)}}let nW={path:"/api/v1/funding/coinbase_on_ramp/init",method:"POST"},n$={path:"/api/v1/funding/coinbase_on_ramp/status",method:"GET"};class nB{async initOnRampSession(e){return await this._privyInternal.fetch(nW,{body:e})}async getStatus(e){return await this._privyInternal.fetch(n$,{query:{partnerUserId:e}})}constructor(e){this._privyInternal=e}}let nz={path:"/api/v1/plugins/moonpay_on_ramp/sign",method:"POST"},nq=class{async sign(e){return await this._privyInternal.fetch(nz,{body:e})}async getTransactionStatus({transactionId:e,useSandbox:t}){let{url:n,key:i}=ev[t?"sandbox":"prod"],r=await eU(fetch,{retries:3,retryDelay:500})(`${n}/transactions/ext/${e}?apiKey=${i}`);if(!r.ok)throw new O({error:`Failed to fetch transaction status for Transaction ${e}`,code:"failed_to_fetch_moonpay_transaction_status",response:r});let a=await r.json();return Array.isArray(a)?a.at(0):void 0}constructor(e){this._privyInternal=e}};
23class nV{constructor(e){this.moonpay=new nq(e),this.coinbase=new nB(e)}}let nH={path:"/api/v1/mfa/passkeys/init",method:"POST"},nG=class{async generateAuthenticationOptions(e){return await this._privyInternal.fetch(nH,{body:e})}constructor(e){this._privyInternal=e}},nK={path:"/api/v1/mfa/passwordless_sms/init",method:"POST"};class nJ{async sendCode(e){return await this._privyInternal.fetch(nK,{body:e})}constructor(e){this._privyInternal=e}}class nZ{setProxy(e){this.proxy=e}async getAccessToken(){let e=await this.privyInternal.getAccessToken();if(!e)throw new j({error:"Missing access token",code:"attempted_rpc_call_before_logged_in"});return e}async verifyMfa(){if(!this.proxy)throw new j({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return await this.proxy.verifyMfa({accessToken:await this.getAccessToken()})}async initEnrollMfa(e){if(!this.proxy)throw new j({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return await this.proxy.initEnrollMfa({...e,accessToken:await this.getAccessToken()})}async submitEnrollMfa(e){if(!this.proxy)throw new j({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});let t=await this.proxy.submitEnrollMfa({...e,accessToken:await this.getAccessToken()});return await this.privyInternal.refreshSession(),t}async unenrollMfa(e){if(!this.proxy)throw new j({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});let t=await this.proxy.unenrollMfa({method:e,accessToken:await this.getAccessToken()});return await this.privyInternal.refreshSession(),t}async clearMfa(e){if(!this.proxy)throw new j({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return await this.proxy.clearMfa(e)}constructor(e,t){this.proxy=t,this.privyInternal=e,this.sms=new nJ(e),this.passkey=new nG(e)}}let nY={path:"/api/v1/embedded_wallets/:address/recovery/key_material",method:"POST"},nQ={path:"/api/v1/recovery/oauth/init",method:"POST"},nX={path:"/api/v1/recovery/oauth/authenticate",method:"POST"},n0={path:"/api/v1/recovery/oauth/init_icloud",method:"POST"},n1={path:"/api/v1/recovery/configuration_icloud",method:"POST"};class n2{async init(e){return this._privyInternal.fetch(n0,{body:{client_type:e}})}async getICloudConfiguration(e){return this._privyInternal.fetch(n1,{body:{client_type:e}})}constructor(e){this._privyInternal=e}}class n3{async generateURL(e){let t=nu(),n=nu(),i=await nh({codeVerifier:t,digest:this._crypto?.digest});return await Promise.all([this._storage.put(nc,t),this._storage.put(nl,n)]),this._privyInternal.fetch(nQ,{body:{redirect_to:e,code_challenge:i,state_code:n}})}async authorize(e,t){let[n,i]=await Promise.all([this._storage.get(nc),this._storage.get(nl)]);if(i!==t)throw this._privyInternal.createAnalyticsEvent("possible_phishing_attempt",{flow:"recovery_oauth",storedStateCode:i??"",returnedStateCode:t??""}),new j({code:"pkce_state_code_mismatch",error:"Unexpected auth flow. This may be a phishing attempt."});let r=await this._privyInternal.fetch(nX,{body:{authorization_code:e,state_code:i,code_verifier:n}});return await Promise.all([this._storage.del(nc),this._storage.del(nl)]),r}constructor(e,t,n){this._privyInternal=e,this._storage=t,this._crypto=n}}class n4{async getRecoveryKeyMaterial(e,t){return this._privyInternal.fetch(nY,{body:{chain_type:t},params:{address:e}})}constructor(e,t,n){this._privyInternal=e,this.auth=new n3(this._privyInternal,t,n),this.icloudAuth=new n2(this._privyInternal)}}class n5{async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}getCompiledPath(e,t){return this._privyInternal.getPath(e,t)}
23async fetchPrivyRoute(e,t){return this._privyInternal.fetch(e,t)}get logger(){return this._privyInternal.logger}constructor({clientId:e,...t}){this._privyInternal=new tW({...t,appClientId:e}),this.mfa=new nZ(this._privyInternal),this.mfaPromises=new tg,this.app=new eJ(this._privyInternal),this.embeddedWallet=new tf(this._privyInternal,t.embeddedWalletMessagePoster,t.supportedChains,this.mfa,this.mfaPromises,this.app),this.user=new tB(this._privyInternal),this.auth=new nF(this._privyInternal,this.embeddedWallet,t.storage,t.crypto),this.recovery=new n4(this._privyInternal,t.storage,t.crypto),this.funding=new nV(this._privyInternal),this.delegated=new e0(this._privyInternal),this.crossApp=new eX(this._privyInternal,t.storage)}}var n6=n(34228),n8=n(631930),n7=n(703260),n9=n(760401),ie=n(182913),it=n(270360),ii=n(34138),ir=n(789609),ia=n(352401),is=n(889810),io=n(97644),il=n(999622),ic=n(161877),id=n(216883);let iu={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844",4:"eip7702"},ih={legacy:0,eip2930:1,eip1559:2,eip4844:3,eip7702:4},ip=e=>void 0!==e?BigInt(e):void 0;function im(e){let t,{type:n=2,...i}="string"==typeof e?JSON.parse(e):e;i.accessList&&Array.isArray(i.accessList)?t=i.accessList.map(e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e):i.accessList&&(t=Object.entries(i.accessList).map(e=>({address:e[0],storageKeys:e[1]})));let r=Number(i.chainId??1),a=(0,w.q)(i.data)?i.data:i.data?(0,g.nj)(Uint8Array.from(i.data)):void 0,s=i.nonce?Number(i.nonce):void 0,o={chainId:r,data:a,nonce:s,value:ip(i.value),gas:ip(i.gas??i.gasLimit)},l=Number(n);if(0===l)return{...i,type:iu[l],...o,gasPrice:ip(i.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===l)return{...i,type:iu[l],...o,gasPrice:ip(i.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===l)return{...i,type:iu[l],...o,nonce:s,accessList:t,maxFeePerGas:ip(i.maxFeePerGas),maxPriorityFeePerGas:ip(i.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw Error(`Unsupported transaction type: ${n}`)}var iy=n(333062),ig=n(872743),iw=n(582606),iv=n(558437),ib=n(824693),ix=n(956349),i_=n(441234),iC=n(804785),iI=n(38872),iE=n(118172),iT=n(210931),iA=n(989844),iS=n(973502),ik=n(653349),iP=n(667286),ij=n(9769),iO=n(398805),iN=n.n(iO),iR=n(69001),iM=n(597901),iD=n(307244),iU=n(692838),iL=n(492331),iF=n(558500),iW=n(299035),i$=n(505614),iB=n(722034),iz=n(923727),iq=n(715599).Buffer;function iV(e){let[t,n]=e.split(":");return{namespace:t,reference:n}}function iH(e,t=[]){let n=[];return Object.keys(e).forEach(i=>{if(t.length&&!t.includes(i))return;let r=e[i];n.push(...r.accounts)}),n}function iG(e,t){return e.includes(":")?[e]:t.chains||[]}var iK=Object.defineProperty,iJ=Object.defineProperties,iZ=Object.getOwnPropertyDescriptors,iY=Object.getOwnPropertySymbols,iQ=Object.prototype.hasOwnProperty,iX=Object.prototype.propertyIsEnumerable,i0=(e,t,n)=>t in e?iK(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,i1=(e,t)=>{for(var n in t||(t={}))iQ.call(t,n)&&i0(e,n,t[n]);if(iY)for(var n of iY(t))iX.call(t,n)&&i0(e,n,t[n]);return e};let i2={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};function i3(){return"u">typeof iz&&"u">typeof iz.versions&&"u">typeof iz.versions.node}function i4(){return!(0,iD.getDocument)()&&!!(0,iD.getNavigator)()&&"ReactNative"===navigator.product}function i5(){return!i3()&&!!(0,iD.getNavigator)()&&!!(0,iD.getDocument)()}function i6(){return i4()?i2.reactNative:i3()?i2.node:i5()?i2.browser:i2.unknown}function i8(){var e;try{return i4()&&"u">typeof n.g&&"u">typeof(null==n.g?void 0:n.g.Application)?null==(e=n.g.Application)?void 0:e.applicationId:void 0}catch{return}}function i7(){return(0,iU.g)()||{name:"",description:"",url:"",icons:[""]}}function i9(e,t,i){let r=function(){if(i6()===i2.reactNative&&"u">typeof n.g&&"u">typeof(null==n.g?void 0:n.g.Platform)){let{OS:e,Version:t}=n.g.Platform;return[e,t].join("-")}let e=(0,iR.o0)();if(null===e)return"unknown";let t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),a=function(){var e;let t=i6();return t===i2.browser?[t,(null==(e=(0,iD.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),["js",i].join("-"),r,a].join("/")}function re(e,t){return e.filter(e=>t.includes(e)).length===e.length}function rt(e){return Object.fromEntries(e.entries())}function rn(e){return new Map(Object.entries(e))}function ri(e=iM.FIVE_MINUTES,t){let n,i,r,a,s=(0,iM.toMiliseconds)(e||iM.FIVE_MINUTES);return{resolve:e=>
23{r&&n&&(clearTimeout(r),n(e),a=Promise.resolve(e))},reject:e=>{r&&i&&(clearTimeout(r),i(e))},done:()=>new Promise((e,o)=>{if(a)return e(a);r=setTimeout(()=>{let e=Error(t);a=Promise.reject(e),o(e)},s),n=e,i=o})}}function rr(e,t,n){return new Promise(async(i,r)=>{let a=setTimeout(()=>r(Error(n)),t);try{let t=await e;i(t)}catch(e){r(e)}clearTimeout(a)})}function ra(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw Error(`Unknown expirer target type: ${e}`)}function rs(e){let[t,n]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof n)i.topic=n;else if("id"===t&&Number.isInteger(Number(n)))i.id=Number(n);else throw Error(`Invalid target, expected id:number or topic:string, got ${t}:${n}`);return i}function ro(e,t){return(0,iM.fromMiliseconds)((t||Date.now())+(0,iM.toMiliseconds)(e))}function rl(e){return Date.now()>=(0,iM.toMiliseconds)(e)}function rc(e,t){return`${e}${t?`:${t}`:""}`}function rd(e=[],t=[]){return[...new Set([...e,...t])]}async function ru({id:e,topic:t,wcDeepLink:i}){var r,a;try{if(!i)return;let s="string"==typeof i?JSON.parse(i):i,o=s?.href;if("string"!=typeof o)return;let l=function(e,t,n){let i=`requestId=${t}&sessionTopic=${n}`;e.endsWith("/")&&(e=e.slice(0,-1));let r=`${e}`;if(e.startsWith("https://t.me")){let t=e.includes("?")?"&startapp=":"?startapp=";r=`${r}${t}${function(e,t=!1){let n=iq.from(e).toString("base64");return t?n.replace(/[=]/g,""):n}(i,!0)}`}else r=`${r}/wc?${i}`;return r}(o,e,t),c=i6();if(c===i2.browser){let e;if(!(null!=(r=(0,iD.getDocument)())&&r.hasFocus()))return void console.warn("Document does not have focus, skipping deeplink.");a=l,e="_self",!function(){try{return window.self!==window.top}catch{return!1}}()?("u">typeof window&&(window.TelegramWebviewProxy||window.Telegram||window.TelegramWebviewProxyProto)||a.startsWith("https://")||a.startsWith("http://"))&&(e="_blank"):e="_top",window.open(a,e,"noreferrer noopener")}else c===i2.reactNative&&"u">typeof(null==n.g?void 0:n.g.Linking)&&await n.g.Linking.openURL(l)}catch(e){console.error(e)}}async function rh(e,t){let n="";try{if(i5()&&(n=localStorage.getItem(t)))return n;n=await e.getItem(t)}catch(e){console.error(e)}return n}function rp(e,t){if(!e.includes(t))return null;let n=e.split(/([&,?,=])/),i=n.indexOf(t);return n[i+2]}function rm(){return"u">typeof crypto&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function ry(){return"u">typeof iz&&"true"===iz.env.IS_VITEST}function rf(e){return iq.from(e,"base64").toString("utf-8")}function rg(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function rw(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function rv(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.wrapConstructor");rg(e.outputLen),rg(e.blockLen)}function rb(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function rx(e,t){rw(e);let n=t.outputLen;if(e.length<n)throw Error("digestInto() expects output buffer of length at least "+n)}let r_=BigInt(0x100000000-1),rC=BigInt(32),rI="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function rE(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rT(e,t){return e<<32-t|e>>>t}let rA=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];function rS(e){for(let n=0;n<e.length;n++){var t;e[n]=(t=e[n])<<24&0xff000000|t<<8&0xff0000|t>>>8&65280|t>>>24&255}}function rk(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),rw(e),e}class rP{clone(){return this._cloneInto()}}function rj(e){let t=t=>e().update(rk(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function rO(e=32){if(rI&&"function"==typeof rI.getRandomValues)return rI.getRandomValues(new Uint8Array(e));if(rI&&"function"==typeof rI.randomBytes)return rI.randomBytes(e);throw Error("crypto.getRandomValues must be defined")}let rN=[],rR=[],rM=[],rD=BigInt(0),rU=BigInt(1),rL=BigInt(2),rF=BigInt(7),rW=BigInt(256),r$=BigInt(113);for(let e=0,t=rU,n=1,i=0;e<24;e++){[n,i]=[i,(2*n+3*i)%5],rN.push(2*(5*i+n)),rR.push((e+1)*(e+2)/2%64);let r=rD;for(let e=0;e<7;e++)(t=(t<<rU^(t>>rF)*r$)%rW)&rL&&(r^=rU<<(rU<<BigInt(e))-rU);rM.push(r)}let[rB,rz]=function(e,t=!1){let n=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){let{h:a,l:s}=function(e,t=!1){return t?{h:Number(e&r_),l:Number(e>>rC&r_)}:{h:0|Number(e>>rC&r_),l:0|Number(e&r_)}}(e[r],t);[n[r],i[r]]=[a,s]}return[n,i]}
23(rM,!0),rq=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),rV=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class rH extends rP{constructor(e,t,n,i=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rg(n),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}(this.state)}keccak(){rA||rS(this.state32),function(e,t=24){let n=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let i=(t+8)%10,r=(t+2)%10,a=n[r],s=n[r+1],o=rq(a,s,1)^n[i],l=rV(a,s,1)^n[i+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=l}let t=e[2],r=e[3];for(let n=0;n<24;n++){let i=rR[n],a=rq(t,r,i),s=rV(t,r,i),o=rN[n];t=e[o],r=e[o+1],e[o]=a,e[o+1]=s}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)n[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=rB[i],e[1]^=rz[i]}n.fill(0)}(this.state32,this.rounds),rA||rS(this.state32),this.posOut=0,this.pos=0}update(e){rb(this);let{blockLen:t,state:n}=this,i=(e=rk(e)).length;for(let r=0;r<i;){let a=Math.min(t-this.pos,i-r);for(let t=0;t<a;t++)n[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,(128&t)!=0&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){rb(this,!1),rw(e),this.finish();let t=this.state,{blockLen:n}=this;for(let i=0,r=e.length;i<r;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+a),i),this.posOut+=a,i+=a}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rg(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(rx(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:n,outputLen:i,rounds:r,enableXOF:a}=this;return e||(e=new rH(t,n,i,a,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=n,e.outputLen=i,e.enableXOF=a,e.destroyed=this.destroyed,e}}let rG=rj(()=>new rH(136,1,32));function rK(e){let t=`�Ethereum Signed Message:
24${e.length}`,n=new TextEncoder().encode(t+e);return"0x"+iq.from(rG(n)).toString("hex")}async function rJ(e,t,n,i,r,a){switch(n.t){case"eip191":return await rZ(e,t,n.s);case"eip1271":return await rY(e,t,n.s,i,r,a);default:throw Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${n.t}`)}}async function rZ(e,t,n){return(await (0,iL.x)({hash:rK(t),signature:n})).toLowerCase()===e.toLowerCase()}async function rY(e,t,n,i,r,a){let s=iV(i);if(!s.namespace||!s.reference)throw Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let s="0x1626ba7e",o=n.substring(2),l=rK(t).substring(2),c=s+l+"00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041"+o,d=await fetch(`${a||"https://rpc.walletconnect.org/v1"}/?chainId=${i}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:c},"latest"]})}),{result:u}=await d.json();return!!u&&u.slice(0,s.length).toLowerCase()===s.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}var rQ=Object.defineProperty,rX=Object.defineProperties,r0=Object.getOwnPropertyDescriptors,r1=Object.getOwnPropertySymbols,r2=Object.prototype.hasOwnProperty,r3=Object.prototype.propertyIsEnumerable,r4=(e,t,n)=>t in e?rQ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;let r5=e=>e?.split(":"),r6=e=>{let t=e&&r5(e);if(t)return t[2]+":"+t[3]},r8=e=>{let t=e&&r5(e);if(t)return t.pop()};async function r7(e){let{cacao:t,projectId:n}=e,{s:i,p:r}=t,a=r9(r,r.iss),s=r8(r.iss);return await rJ(s,a,i,r6(r.iss),n)}let r9=(e,t)=>
24{let n=`${e.domain} wants you to sign in with your Ethereum account:`,i=r8(t);if(!e.aud&&!e.uri)throw Error("Either `aud` or `uri` is required to construct the message");let r=e.statement||void 0,a=`URI: ${e.aud||e.uri}`,s=`Version: ${e.version}`,o=`Chain ID: ${(e=>{let t=e&&r5(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,l=`Nonce: ${e.nonce}`,c=`Issued At: ${e.iat}`,d=e.exp?`Expiration Time: ${e.exp}`:void 0,u=e.nbf?`Not Before: ${e.nbf}`:void 0,h=e.requestId?`Request ID: ${e.requestId}`:void 0,p=e.resources?`Resources:${e.resources.map(e=>`
25- ${e}`).join("")}`:void 0,m=aa(e.resources);return m&&(r=function(e="",t){ae(t);let n="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(n))return e;let i=[],r=0;Object.keys(t.att).forEach(e=>{let n=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));n.sort((e,t)=>e.action.localeCompare(t.action));let a={};n.forEach(e=>{a[e.ability]||(a[e.ability]=[]),a[e.ability].push(e.action)});let s=Object.keys(a).map(t=>(r++,`(${r}) '${t}': '${a[t].join("', '")}' for '${e}'.`));i.push(s.join(", ").replace(".,","."))});let a=i.join(" "),s=`${n}${a}`;return`${e?e+" ":""}${s}`}(r,an(m))),[n,i,"",r,"",a,s,o,l,c,d,u,h,p].filter(e=>null!=e).join(`
26`)};function ae(e){if(!e)throw Error("No recap provided, value is undefined");if(!e.att)throw Error("No `att` property found");let t=Object.keys(e.att);if(!(null!=t&&t.length))throw Error("No resources found in `att` property");t.forEach(t=>{let n=e.att[t];if(Array.isArray(n)||"object"!=typeof n)throw Error(`Resource must be an object: ${t}`);if(!Object.keys(n).length)throw Error(`Resource object is empty: ${t}`);Object.keys(n).forEach(e=>{let t=n[e];if(!Array.isArray(t))throw Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function at(e){return ae(e),`urn:recap:${iq.from(JSON.stringify(e)).toString("base64").replace(/=/g,"")}`}function an(e){var t;let n=(t=e.replace("urn:recap:",""),JSON.parse(iq.from(t,"base64").toString("utf-8")));return ae(n),n}function ai(e){var t;let n=an(e);ae(n);let i=null==(t=n.att)?void 0:t.eip155;return i?Object.keys(i).map(e=>e.split("/")[1]):[]}function ar(e){let t=an(e);ae(t);let n=[];return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&n.push(e[0].chains)})}),[...new Set(n.flat())]}function aa(e){if(!e)return;let t=e?.[e.length-1];return t&&t.includes("urn:recap:")?t:void 0}function as(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function ao(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function al(e,...t){if(!ao(e))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function ac(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function ad(e){if("boolean"!=typeof e)throw Error(`boolean expected, not ${e}`)}let au=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([0x11223344]).buffer)[0])throw Error("Non little-endian hardware is not supported");function ah(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}(e);else if(ao(e))e=ay(e);else throw Error("Uint8Array expected, got "+typeof e);return e}function ap(e,t,n=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw Error("invalid output length, expected "+e+", got: "+t.length);if(n&&t.byteOffset%4!=0)throw Error("invalid output, must be aligned");return t}function am(e,t,n,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,i);let r=BigInt(32),a=BigInt(0xffffffff),s=Number(n>>r&a),o=Number(n&a),l=4*!!i,c=4*!i;e.setUint32(t+l,s,i),e.setUint32(t+c,o,i)}function ay(e){return Uint8Array.from(e)}function af(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}let ag=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),aw=ag("expand 16-byte k"),av=ag("expand 32-byte k"),ab=au(aw),ax=au(av);function a_(e,t){return e<<t|e>>>32-t}function aC(e){return e.byteOffset%4==0}let aI=0x100000000-1,aE=new Uint32Array,aT=(e,t)=>255&e[t++]|(255&e[t++])<<8;class aA{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,al(e=ah(e),32);let t=aT(e,0),n=aT(e,2),i=aT(e,4),r=aT(e,6),a=aT(e,8),s=aT(e,10),o=aT(e,12),l=aT(e,14);this.r[0]=8191&t,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|r<<9)&8191,this.r[4]=(r>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|s<<2)&8191,this.r[7]=(s>>>11|o<<5)&8065,this.r[8]=(o>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let t=0;t<8;t++)this.pad[t]=aT(e,16+2*t)}process(e,t,n=!1){let{h:i,r:r}=this,a=r[0],s=r[1],o=r[2],l=r[3],c=r[4],d=r[5],u=r[6],h=r[7],p=r[8],m=r[9],y=aT(e,t+0),f=aT(e,t+2),g=aT(e,t+4),w=aT(e,t+6),v=aT(e,t+8),b=aT(e,t+10),x=aT(e,t+12),_=aT(e,t+14),C=i[0]+(8191&y),I=i[1]+((y>>>
2613|f<<3)&8191),E=i[2]+((f>>>10|g<<6)&8191),T=i[3]+((g>>>7|w<<9)&8191),A=i[4]+((w>>>4|v<<12)&8191),S=i[5]+(v>>>1&8191),k=i[6]+((v>>>14|b<<2)&8191),P=i[7]+((b>>>11|x<<5)&8191),j=i[8]+((x>>>8|_<<8)&8191),O=i[9]+(_>>>5|2048*!n),N=0,R=0+C*a+5*m*I+5*p*E+5*h*T+5*u*A;N=R>>>13,R&=8191,R+=5*d*S+5*c*k+5*l*P+5*o*j+5*s*O,N+=R>>>13,R&=8191;let M=N+C*s+I*a+5*m*E+5*p*T+5*h*A;N=M>>>13,M&=8191,M+=5*u*S+5*d*k+5*c*P+5*l*j+5*o*O,N+=M>>>13,M&=8191;let D=N+C*o+I*s+E*a+5*m*T+5*p*A;N=D>>>13,D&=8191,D+=5*h*S+5*u*k+5*d*P+5*c*j+5*l*O,N+=D>>>13,D&=8191;let U=N+C*l+I*o+E*s+T*a+5*m*A;N=U>>>13,U&=8191,U+=5*p*S+5*h*k+5*u*P+5*d*j+5*c*O,N+=U>>>13,U&=8191;let L=N+C*c+I*l+E*o+T*s+A*a;N=L>>>13,L&=8191,L+=5*m*S+5*p*k+5*h*P+5*u*j+5*d*O,N+=L>>>13,L&=8191;let F=N+C*d+I*c+E*l+T*o+A*s;N=F>>>13,F&=8191,F+=S*a+5*m*k+5*p*P+5*h*j+5*u*O,N+=F>>>13,F&=8191;let W=N+C*u+I*d+E*c+T*l+A*o;N=W>>>13,W&=8191,W+=S*s+k*a+5*m*P+5*p*j+5*h*O,N+=W>>>13,W&=8191;let $=N+C*h+I*u+E*d+T*c+A*l;N=$>>>13,$&=8191,$+=S*o+k*s+P*a+5*m*j+5*p*O,N+=$>>>13,$&=8191;let B=N+C*p+I*h+E*u+T*d+A*c;N=B>>>13,B&=8191,B+=S*l+k*o+P*s+j*a+5*m*O,N+=B>>>13,B&=8191;let z=N+C*m+I*p+E*h+T*u+A*d;N=z>>>13,z&=8191,z+=S*c+k*l+P*o+j*s+O*a,N+=z>>>13,z&=8191,R=8191&(N=(N=(N<<2)+N|0)+R|0),N>>>=13,M+=N,i[0]=R,i[1]=M,i[2]=D,i[3]=U,i[4]=L,i[5]=F,i[6]=W,i[7]=$,i[8]=B,i[9]=z}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+i,i=n[t]>>>13,n[t]&=8191;n[9]-=8192;let r=(1^i)-1;for(let e=0;e<10;e++)n[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|n[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let a=e[0]+t[0];e[0]=65535&a;for(let n=1;n<8;n++)a=(e[n]+t[n]|0)+(a>>>16)|0,e[n]=65535&a;af(n)}update(e){ac(this);let{buffer:t,blockLen:n}=this,i=(e=ah(e)).length;for(let r=0;r<i;){let a=Math.min(n-this.pos,i-r);if(a===n){for(;n<=i-r;r+=n)this.process(e,r);continue}t.set(e.subarray(r,r+a),this.pos),this.pos+=a,r+=a,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){af(this.h,this.r,this.buffer,this.pad)}digestInto(e){ac(this),function(e,t){al(e);let n=t.outputLen;if(e.length<n)throw Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=n[t]>>>0,e[r++]=n[t]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}}let aS=function(e){let t=(t,n)=>e(n).update(ah(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}(e=>new aA(e)),ak=function(e,t){let{allowShortKeys:n,extendNonceFn:i,counterLength:r,counterRight:a,rounds:s}=function(e,t){if(null==t||"object"!=typeof t)throw Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw Error("core must be a function");return as(r),as(s),ad(a),ad(n),(t,o,l,c,d=0)=>{al(t),al(o),al(l);let u=l.length;if(void 0===c&&(c=new Uint8Array(u)),al(c),as(d),d<0||d>=aI)throw Error("arx: counter overflow");if(c.length<u)throw Error(`arx: output (${c.length}) is shorter than data (${u})`);let h=[],p=t.length,m,y;if(32===p)h.push(m=ay(t)),y=ax;else if(16===p&&n)(m=new Uint8Array(32)).set(t),m.set(t,16),y=ab,h.push(m);else throw Error(`arx: invalid 32-byte key, got length=${p}`);aC(o)||h.push(o=ay(o));let f=au(m);
26if(i){if(24!==o.length)throw Error("arx: extended nonce must be 24 bytes");i(y,f,au(o.subarray(0,16)),f),o=o.subarray(16)}let g=16-r;if(g!==o.length)throw Error(`arx: nonce must be ${g} or 16 bytes`);if(12!==g){let e=new Uint8Array(12);e.set(o,a?0:12-o.length),o=e,h.push(o)}return function(e,t,n,i,r,a,s,o){let l=r.length,c=new Uint8Array(64),d=au(c),u=aC(r)&&aC(a),h=u?au(r):aE,p=u?au(a):aE;for(let m=0;m<l;s++){if(e(t,n,i,d,s,o),s>=aI)throw Error("arx: counter overflow");let y=Math.min(64,l-m);if(u&&64===y){let e=m/4;if(m%4!=0)throw Error("arx: invalid block position");for(let t=0,n;t<16;t++)p[n=e+t]=h[n]^d[t];m+=64;continue}for(let e=0,t;e<y;e++)a[t=m+e]=r[t]^c[e];m+=y}}(e,y,f,au(o),l,c,d,s),af(...h),c}}(function(e,t,n,i,r,a=20){let s=e[0],o=e[1],l=e[2],c=e[3],d=t[0],u=t[1],h=t[2],p=t[3],m=t[4],y=t[5],f=t[6],g=t[7],w=n[0],v=n[1],b=n[2],x=s,_=o,C=l,I=c,E=d,T=u,A=h,S=p,k=m,P=y,j=f,O=g,N=r,R=w,M=v,D=b;for(let e=0;e<a;e+=2)k=k+(N=a_(N^(x=x+E|0),16))|0,x=x+(E=a_(E^k,12))|0,k=k+(N=a_(N^x,8))|0,E=a_(E^k,7),P=P+(R=a_(R^(_=_+T|0),16))|0,_=_+(T=a_(T^P,12))|0,P=P+(R=a_(R^_,8))|0,T=a_(T^P,7),j=j+(M=a_(M^(C=C+A|0),16))|0,C=C+(A=a_(A^j,12))|0,j=j+(M=a_(M^C,8))|0,A=a_(A^j,7),O=O+(D=a_(D^(I=I+S|0),16))|0,I=I+(S=a_(S^O,12))|0,O=O+(D=a_(D^I,8))|0,S=a_(S^O,7),j=j+(D=a_(D^(x=x+T|0),16))|0,x=x+(T=a_(T^j,12))|0,j=j+(D=a_(D^x,8))|0,T=a_(T^j,7),O=O+(N=a_(N^(_=_+A|0),16))|0,_=_+(A=a_(A^O,12))|0,O=O+(N=a_(N^_,8))|0,A=a_(A^O,7),k=k+(R=a_(R^(C=C+S|0),16))|0,C=C+(S=a_(S^k,12))|0,k=k+(R=a_(R^C,8))|0,S=a_(S^k,7),P=P+(M=a_(M^(I=I+E|0),16))|0,I=I+(E=a_(E^P,12))|0,P=P+(M=a_(M^I,8))|0,E=a_(E^P,7);let U=0;i[U++]=s+x|0,i[U++]=o+_|0,i[U++]=l+C|0,i[U++]=c+I|0,i[U++]=d+E|0,i[U++]=u+T|0,i[U++]=h+A|0,i[U++]=p+S|0,i[U++]=m+k|0,i[U++]=y+P|0,i[U++]=f+j|0,i[U++]=g+O|0,i[U++]=r+N|0,i[U++]=w+R|0,i[U++]=v+M|0,i[U++]=b+D|0},{counterRight:!1,counterLength:4,allowShortKeys:!1}),aP=new Uint8Array(16),aj=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(aP.subarray(n))},aO=new Uint8Array(32);function aN(e,t,n,i,r){let a=e(t,n,aO),s=aS.create(a);r&&aj(s,r),aj(s,i);let o=new Uint8Array(16),l=new DataView(o.buffer,o.byteOffset,o.byteLength);am(l,0,BigInt(r?r.length:0),!0),am(l,8,BigInt(i.length),!0),s.update(o);let c=s.digest();return af(a,o),c}let aR=((e,t)=>{function n(i,...r){if(al(i),void 0!==e.nonceLength){let t=r[0];if(!t)throw Error("nonce / iv required");e.varSizeNonce?al(t):al(t,e.nonceLength)}let a=e.tagLength;a&&void 0!==r[1]&&al(r[1]);let s=t(i,...r),o=(e,t)=>{if(void 0!==t){if(2!==e)throw Error("cipher output not supported");al(t)}},l=!1;return{encrypt(e,t){if(l)throw Error("cannot encrypt() twice with same key + nonce");return l=!0,al(e),o(s.encrypt.length,t),s.encrypt(e,t)},decrypt(e,t){if(al(e),a&&e.length<a)throw Error("invalid ciphertext length: smaller than tagLength="+a);return o(s.decrypt.length,t),s.decrypt(e,t)}}}return Object.assign(n,e),n})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,n,i)=>({encrypt(r,a){let s=r.length;(a=ap(s+16,a,!1)).set(r);let o=a.subarray(0,-16);e(t,n,o,o,1);let l=aN(e,t,n,o,i);return a.set(l,s),af(l),a},decrypt(r,a){a=ap(r.length-16,a,!1);let s=r.subarray(0,-16),o=r.subarray(-16),l=aN(e,t,n,s,i);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let i=0;i<e.length;i++)n|=e[i]^t[i];return 0===n}(o,l))throw Error("invalid tag");return a.set(r.subarray(0,-16)),e(t,n,a,a,1),af(l),a}}))(ak));class aM extends rP{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,rv(e);let n=rk(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,r=new Uint8Array(i);r.set(n.length>i?e.create().update(n).digest():n);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),r.fill(0)}update(e){return rb(this),this.iHash.update(e),this}digestInto(e){rb(this),rw(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:i,destroyed:r,blockLen:a,outputLen:s}=this;return e.finished=i,e.destroyed=r,e.blockLen=a,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let aD=(e,t,n)=>new aM(e,t).update(n).digest();aD.create=(e,t)=>
26new aM(e,t);let aU=new Uint8Array([0]),aL=new Uint8Array;class aF extends rP{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=rE(this.buffer)}update(e){rb(this);let{view:t,buffer:n,blockLen:i}=this,r=(e=rk(e)).length;for(let a=0;a<r;){let s=Math.min(i-this.pos,r-a);if(s===i){let t=rE(e);for(;i<=r-a;a+=i)this.process(t,a);continue}n.set(e.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){rb(this),rx(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:r}=this,{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>i-a&&(this.process(n,0),a=0);for(let e=a;e<i;e++)t[e]=0;(function(e,t,n,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,i);let r=BigInt(32),a=BigInt(0xffffffff),s=Number(n>>r&a),o=Number(n&a),l=4*!!i,c=4*!i;e.setUint32(t+l,s,i),e.setUint32(t+c,o,i)})(n,i-8,BigInt(8*this.length),r),this.process(n,0);let s=rE(e),o=this.outputLen;if(o%4)throw Error("_sha2: outputLen should be aligned to 32bit");let l=o/4,c=this.get();if(l>c.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)s.setUint32(4*e,c[e],r)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:r,destroyed:a,pos:s}=this;return e.length=i,e.pos=s,e.finished=r,e.destroyed=a,i%t&&e.buffer.set(n),e}}let aW=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),a$=new Uint32Array([0x6a09e66
267,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),aB=new Uint32Array(64);class az extends aF{constructor(){super(64,32,8,!1),this.A=0|a$[0],this.B=0|a$[1],this.C=0|a$[2],this.D=0|a$[3],this.E=0|a$[4],this.F=0|a$[5],this.G=0|a$[6],this.H=0|a$[7]}get(){let{A:e,B:t,C:n,D:i,E:r,F:a,G:s,H:o}=this;return[e,t,n,i,r,a,s,o]}set(e,t,n,i,r,a,s,o){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|r,this.F=0|a,this.G=0|s,this.H=0|o}process(e,t){for(let n=0;n<16;n++,t+=4)aB[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=aB[e-15],n=aB[e-2],i=rT(t,7)^rT(t,18)^t>>>3,r=rT(n,17)^rT(n,19)^n>>>10;aB[e]=r+aB[e-7]+i+aB[e-16]|0}let{A:n,B:i,C:r,D:a,E:s,F:o,G:l,H:c}=this;for(let e=0;e<64;e++){var d,u,h,p;let t=c+(rT(s,6)^rT(s,11)^rT(s,25))+((d=s)&o^~d&l)+aW[e]+aB[e]|0,m=(rT(n,2)^rT(n,13)^rT(n,22))+((u=n)&(h=i)^u&(p=r)^h&p)|0;c=l,l=o,o=s,s=a+t|0,a=r,r=i,i=n,n=t+m|0}n=n+this.A|0,i=i+this.B|0,r=r+this.C|0,a=a+this.D|0,s=s+this.E|0,o=o+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,i,r,a,s,o,l,c)}roundClean(){aB.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}let aq=rj(()=>new az),aV=BigInt(0),aH=BigInt(1),aG=BigInt(2);function aK(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function aJ(e){if(!aK(e))throw Error("Uint8Array expected")}function aZ(e,t){if("boolean"!=typeof t)throw Error(e+" boolean expected, got "+t)}let aY=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function aQ(e){aJ(e);let t="";for(let n=0;n<e.length;n++)t+=aY[e[n]];return t}function aX(e){let t=e.toString(16);return 1&t.length?"0"+t:t}function a0(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);return""===e?aV:BigInt("0x"+e)}let a1={_0:48,_9:57,A:65,F:70,a:97,f:102};function a2(e){return e>=a1._0&&e<=a1._9?e-a1._0:e>=a1.A&&e<=a1.F?e-(a1.A-10):e>=a1.a&&e<=a1.f?e-(a1.a-10):void 0}function a3(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);let t=e.length,n=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let i=new Uint8Array(n);for(let t=0,r=0;t<n;t++,r+=2){let n=a2(e.charCodeAt(r)),a=a2(e.charCodeAt(r+1));if(void 0===n||void 0===a)throw Error('hex string expected, got non-hex character "'+(e[r]+e[r+1])+'" at index '+r);i[t]=16*n+a}return i}function a4(e){return a0(aQ(e))}function a5(e){return aJ(e),a0(aQ(Uint8Array.from(e).reverse()))}function a6(e,t){return a3(e.toString(16).padStart(2*t,"0"))}function a8(e,t){return a6(e,t).reverse()}function a7(e,t,n){let i;if("string"==typeof t)try{i=a3(t)}catch(t){throw Error(e+" must be hex string or Uint8Array, cause: "+t)}else if(aK(t))i=Uint8Array.from(t);else throw Error(e+" must be hex string or Uint8Array");let r=i.length;if("number"==typeof n&&r!==n)throw Error(e+" of length "+n+" expected, got "+r);return i}function a9(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];aJ(i),t+=i.length}let n=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){let r=e[t];n.set(r,i),i+=r.length}return n}let se=e=>"bigint"==typeof e&&aV<=e;function st(e,t,n){return se(e)&&se(t)&&se(n)&&t<=e&&e<n}function sn(e,t,n,i){if(!st(t,n,i))throw Error("expected valid "+e+": "+n+" <= n < "+i+", got "+t)}function si(e){let t;for(t=0;e>aV;e>>=aH,t+=1);return t}let sr=e=>(aG<<BigInt(e-1))-aH,sa=e=>new Uint8Array(e),ss=e=>Uint8Array.from(e);function so(e,t,n){if("number"!=typeof e||e<2)throw Error("hashLen must be a number");if("number"!=typeof t||t<2)throw Error("qByteLen must be a number");if("function"!=typeof n)throw Error("hmacFn must be a function");let i=sa(e),r=sa(e),a=0,s=()=>{i.fill(1),r.fill(0),a=0},o=(...e)=>n(r,i,...e),l=(e=sa())=>{r=o(ss([0]),e),i=o(),0!==e.length&&(r=o(ss([1]),e),i=o())},c=()=>{if(a++>=1e3)throw Error("drbg: tried 1000 values");let e=0,n=[];for(;e<t;){let t=(i=o()).slice();n.push(t),e+=i.length}return a9(...n)};return(e,t)=>{let n;for(s(),l(e);!(n=t(c()));)l();return s(),n}}let sl={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||aK(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function sc(e,t,n={}){let i=(t,n,i)=>{let r=sl[n];if("function"!=typeof r)throw Error("invalid validator function");let a=e[t];if(!(i&&void 0===a)&&!r(a,e))throw Error("param "+String(t)+" is invali
26d. Expected "+n+", got "+a)};for(let[e,n]of Object.entries(t))i(e,n,!1);for(let[e,t]of Object.entries(n))i(e,t,!0);return e}function sd(e){let t=new WeakMap;return(n,...i)=>{let r=t.get(n);if(void 0!==r)return r;let a=e(n,...i);return t.set(n,a),a}}var su=Object.freeze({__proto__:null,isBytes:aK,abytes:aJ,abool:aZ,bytesToHex:aQ,numberToHexUnpadded:aX,hexToNumber:a0,hexToBytes:a3,bytesToNumberBE:a4,bytesToNumberLE:a5,numberToBytesBE:a6,numberToBytesLE:a8,numberToVarBytesBE:function(e){return a3(aX(e))},ensureBytes:a7,concatBytes:a9,equalBytes:function(e,t){if(e.length!==t.length)return!1;let n=0;for(let i=0;i<e.length;i++)n|=e[i]^t[i];return 0===n},utf8ToBytes:function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))},inRange:st,aInRange:sn,bitLen:si,bitGet:function(e,t){return e>>BigInt(t)&aH},bitSet:function(e,t,n){return e|(n?aH:aV)<<BigInt(t)},bitMask:sr,createHmacDrbg:so,validateObject:sc,notImplemented:()=>{throw Error("not implemented")},memoized:sd});let sh=BigInt(0),sp=BigInt(1),sm=BigInt(2),sy=BigInt(3),sf=BigInt(4),sg=BigInt(5),sw=BigInt(8);function sv(e,t){let n=e%t;return n>=sh?n:t+n}function sb(e,t,n){if(t<sh)throw Error("invalid exponent, negatives unsupported");if(n<=sh)throw Error("invalid modulus");if(n===sp)return sh;let i=sp;for(;t>sh;)t&sp&&(i=i*e%n),e=e*e%n,t>>=sp;return i}function sx(e,t,n){let i=e;for(;t-- >sh;)i*=i,i%=n;return i}function s_(e,t){if(e===sh)throw Error("invert: expected non-zero number");if(t<=sh)throw Error("invert: expected positive modulus, got "+t);let n=sv(e,t),i=t,r=sh,a=sp;for(;n!==sh;){let e=i/n,t=i%n,s=r-a*e;i=n,n=t,r=a,a=s}if(i!==sp)throw Error("invert: does not exist");return sv(r,t)}let sC=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function sI(e,t){let n=void 0!==t?t:e.toString(2).length,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function sE(e,t,n=!1,i={}){let r;if(e<=sh)throw Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:a,nByteLength:s}=sI(e,t);if(s>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let o=Object.freeze({ORDER:e,isLE:n,BITS:a,BYTES:s,MASK:sr(a),ZERO:sh,ONE:sp,create:t=>sv(t,e),isValid:t=>{if("bigint"!=typeof t)throw Error("invalid field element: expected bigint, got "+typeof t);return sh<=t&&t<e},is0:e=>e===sh,isOdd:e=>(e&sp)===sp,neg:t=>sv(-t,e),eql:(e,t)=>e===t,sqr:t=>sv(t*t,e),add:(t,n)=>sv(t+n,e),sub:(t,n)=>sv(t-n,e),mul:(t,n)=>sv(t*n,e),pow:(e,t)=>(function(e,t,n){if(n<sh)throw Error("invalid exponent, negatives unsupported");if(n===sh)return e.ONE;if(n===sp)return t;let i=e.ONE,r=t;for(;n>sh;)n&sp&&(i=e.mul(i,r)),r=e.sqr(r),n>>=sp;return i})(o,e,t),div:(t,n)=>sv(t*s_(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>s_(t,e),sqrt:i.sqrt||(t=>(r||(r=function(e){if(e%sf===sy){let t=(e+sp)/sf;return function(e,n){let i=e.pow(n,t);if(!e.eql(e.sqr(i),n))throw Error("Cannot find square root");return i}}if(e%sw===sg){let t=(e-sg)/sw;return function(e,n){let i=e.mul(n,sm),r=e.pow(i,t),a=e.mul(n,r),s=e.mul(e.mul(a,sm),r),o=e.mul(a,e.sub(s,e.ONE));if(!e.eql(e.sqr(o),n))throw Error("Cannot find square root");return o}}return function(e){let t,n,i,r=(e-sp)/sm;for(t=e-sp,n=0;t%sm===sh;t/=sm,n++);for(i=sm;i<e&&sb(i,r,e)!==e-sp;i++)if(i>1e3)throw Error("Cannot find square root: likely non-prime P");if(1===n){let t=(e+sp)/sf;return function(e,n){let i=e.pow(n,t);if(!e.eql(e.sqr(i),n))throw Error("Cannot find square root");return i}}let a=(t+sp)/sm;return function(e,s){if(e.pow(s,r)===e.neg(e.ONE))throw Error("Cannot find square root");let o=n,l=e.pow(e.mul(e.ONE,i),t),c=e.pow(s,a),d=e.pow(s,t);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(d);t<o&&!e.eql(n,e.ONE);t++)n=e.sqr(n);let n=e.pow(l,sp<<BigInt(o-t-1));l=e.sqr(n),c=e.mul(c,n),d=e.mul(d,l),o=t}return c}}(e)}(e)),r(o,t))),invertBatch:e=>(function(e,t){let n=Array(t.length),i=t.reduce((t,i,r)=>e.is0(i)?t:(n[r]=t,e.mul(t,i)),e.ONE),r=e.inv(i);return t.reduceRight((t,i,r)=>e.is0(i)?t:(n[r]=e.mul(t,n[r]),e.mul(t,i)),r),n})(o,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?a8(e,s):a6(e,s),fromBytes:e=>{if(e.length!==s)throw Error("Field.fromBytes: expected "+s+" bytes, got "+e.length);return n?a5(e):a4(e)}});return Object.freeze(o)}function sT(e){if("bigint"!=typeof e)throw Error("field order must be bigint");return Math.ceil(e.toString(2).length/8)}function sA(e){let t=sT(e);return t+Math.ceil(t/2)}let sS=BigInt(0),sk=BigInt(1);function sP(e,t){let n=t.negate();return e?n:t}function sj(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function sO(e,t){return sj(e,t),{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}}let sN=new WeakMap,sR=new WeakMap;function sM(e){return sR.get(e)||1}function sD(e){return sc(e.Fp,sC.reduce((e,t)=>
26(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),sc(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...sI(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);let sU=BigInt(0),sL=BigInt(1),sF=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);let sW=BigInt(1),s$=BigInt(2),sB=BigInt(3),sz=BigInt(5);BigInt(8);let sq=function(e){let t=(sc(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})),{P:n}=t,i=e=>sv(e,n),r=t.montgomeryBits,a=Math.ceil(r/8),s=t.nByteLength,o=t.adjustScalarBytes||(e=>e),l=t.powPminus2||(e=>sb(e,n-BigInt(2),n));function c(e,t,n){let r=i(e*(t-n));return[t=i(t-r),n=i(n+r)]}let d=(t.a-BigInt(2))/BigInt(4);function u(e,t){let u=function(e,t){sn("u",e,sU,n),sn("scalar",t,sU,n);let a=sL,s=sU,o=e,u=sL,h=sU,p;for(let n=BigInt(r-1);n>=sU;n--){let r=t>>n&sL;h^=r,a=(p=c(h,a,o))[0],o=p[1],s=(p=c(h,s,u))[0],u=p[1],h=r;let l=a+s,m=i(l*l),y=a-s,f=i(y*y),g=m-f,w=o+u,v=i((o-u)*l),b=i(w*y),x=v+b,_=v-b;o=i(x*x),u=i(e*i(_*_)),a=i(m*f),s=i(g*(m+i(d*g)))}return a=(p=c(h,a,o))[0],o=p[1],s=(p=c(h,s,u))[0],u=p[1],i(a*l(s))}(function(e){let t=a7("u coordinate",e,a);return 32===s&&(t[31]&=127),a5(t)}(t),function(e){let t=a7("scalar",e),n=t.length;if(n!==a&&n!==s)throw Error("invalid scalar, expected "+(""+a+" or ")+s+" bytes, got "+n);return a5(o(t))}(e));if(u===sU)throw Error("invalid private or public key received");return a8(i(u),a)}let h=a8(i(t.Gu),a);function p(e){return u(e,h)}return{scalarMult:u,scalarMultBase:p,getSharedSecret:(e,t)=>u(e,t),getPublicKey:e=>p(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:h}}({P:sF,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{let{pow_p_5_8:t,b2:n}=function(e){let t=BigInt(10),n=BigInt(20),i=BigInt(40),r=BigInt(80),a=e*e%sF*e%sF,s=sx(a,s$,sF)*a%sF,o=sx(s,sW,sF)*e%sF,l=sx(o,sz,sF)*o%sF,c=sx(l,t,sF)*l%sF,d=sx(c,n,sF)*c%sF,u=sx(d,i,sF)*d%sF,h=sx(u,r,sF)*u%sF,p=sx(h,r,sF)*u%sF,m=sx(p,t,sF)*l%sF;return{pow_p_5_8:sx(m,s$,sF)*e%sF,b2:a}}(e);return sv(sx(t,sB,sF)*n,sF)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:rO});function sV(e){void 0!==e.lowS&&aZ("lowS",e.lowS),void 0!==e.prehash&&aZ("prehash",e.prehash)}let{bytesToNumberBE:sH,hexToBytes:sG}=su;class sK extends Error{constructor(e=""){super(e)}}let sJ={Err:sK,_tlv:{encode:(e,t)=>{let{Err:n}=sJ;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");let i=t.length/2,r=aX(i);if(r.length/2&128)throw new n("tlv.encode: long form length too big");let a=i>127?aX(r.length/2|128):"";return aX(e)+a+r+t},decode(e,t){let{Err:n}=sJ,i=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new n("tlv.decode: wrong tlv");let r=t[i++],a=0;if(128&r){let e=127&r;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");let s=t.subarray(i,i+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(let e of s)a=a<<8|e;if(i+=e,a<128)throw new n("tlv.decode(long): not minimal encoding")}else a=r;let s=t.subarray(i,i+a);if(s.length!==a)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(i+a)}}},_int:{encode(e){let{Err:t}=sJ;if(e<sZ)throw new t("integer: negative integers are not allowed");let n=aX(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){let{Err:t}=sJ;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return sH(e)}},toSig(e){let{Err:t,_int:n,_tlv:i}=sJ,r="string"==typeof e?sG(e):e;aJ(r);let{v:a,l:s}=i.decode(48,r);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:o,l:l}=i.decode(2,a),{v:c,l:d}=i.decode(2,l);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(o),s:n.decode(c)}},hexFromSig(e){let{_tlv:t,_int:n}=sJ,i=t.encode(2,n.encode(e.r)),r=t.encode(2,n.encode(e.s));return t.encode(48,i+r)}},sZ=BigInt(0),sY=BigInt(1);BigInt(2);let sQ=BigInt(3);BigInt(4);let sX=sE(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),s0=function(e,t){let n=t=>(function(e){let t=function(e){let t=sD(e);return sc(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:i}=t,r=n.BYTES+1,a=2*n.BYTES+1;function s(e){return sv(e,i)}let{ProjectivePoint:o,normPrivateKeyToScalar:l,weierstrassEquation:c,isWithinCurveOrder:d}=function(e){var t;let n=function(e){let t=sD(e);sc(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});
vendor: 4,867 bytes, line 26
26let{endo:n,Fp:i,a:r}=t;if(n){if(!i.eql(r,i.ZERO))throw Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:i}=n,r=sE(n.n,n.nBitLength),a=n.toBytes||((e,t,n)=>{let r=t.toAffine();return a9(Uint8Array.from([4]),i.toBytes(r.x),i.toBytes(r.y))}),s=n.fromBytes||(e=>{let t=e.subarray(1);return{x:i.fromBytes(t.subarray(0,i.BYTES)),y:i.fromBytes(t.subarray(i.BYTES,2*i.BYTES))}});function o(e){let{a:t,b:r}=n,a=i.sqr(e),s=i.mul(a,e);return i.add(i.add(s,i.mul(e,t)),r)}if(!i.eql(i.sqr(n.Gy),o(n.Gx)))throw Error("bad generator point: equation left != right");function l(e){let t,{allowedPrivateKeyLengths:i,nByteLength:r,wrapPrivateKey:a,n:s}=n;if(i&&"bigint"!=typeof e){if(aK(e)&&(e=aQ(e)),"string"!=typeof e||!i.includes(e.length))throw Error("invalid private key");e=e.padStart(2*r,"0")}try{t="bigint"==typeof e?e:a4(a7("private key",e,r))}catch{throw Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return a&&(t=sv(t,s)),sn("private key",t,sY,s),t}function c(e){if(!(e instanceof h))throw Error("ProjectivePoint expected")}let d=sd((e,t)=>{let{px:n,py:r,pz:a}=e;if(i.eql(a,i.ONE))return{x:n,y:r};let s=e.is0();null==t&&(t=s?i.ONE:i.inv(a));let o=i.mul(n,t),l=i.mul(r,t),c=i.mul(a,t);if(s)return{x:i.ZERO,y:i.ZERO};if(!i.eql(c,i.ONE))throw Error("invZ was invalid");return{x:o,y:l}}),u=sd(e=>{if(e.is0()){if(n.allowInfinityPoint&&!i.is0(e.py))return;throw Error("bad point: ZERO")}let{x:t,y:r}=e.toAffine();if(!i.isValid(t)||!i.isValid(r))throw Error("bad point: x or y not FE");let a=i.sqr(r),s=o(t);if(!i.eql(a,s))throw Error("bad point: equation left != right");if(!e.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});class h{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!i.isValid(e))throw Error("x required");if(null==t||!i.isValid(t))throw Error("y required");if(null==n||!i.isValid(n))throw Error("z required");Object.freeze(this)}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!i.isValid(t)||!i.isValid(n))throw Error("invalid affine point");if(e instanceof h)throw Error("projective point not allowed");let r=e=>i.eql(e,i.ZERO);return r(t)&&r(n)?h.ZERO:new h(t,n,i.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=i.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(h.fromAffine)}static fromHex(e){let t=h.fromAffine(s(a7("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(l(e))}static msm(e,t){return function(e,t,n,i){if(function(e,t){if(!Array.isArray(e))throw Error("array expected");e.forEach((e,n)=>{if(!(e instanceof t))throw Error("invalid point at index "+n)})}(n,e),function(e,t){if(!Array.isArray(e))throw Error("array of scalars expected");e.forEach((e,n)=>{if(!t.isValid(e))throw Error("invalid scalar at index "+n)})}(i,t),n.length!==i.length)throw Error("arrays of points and scalars must have equal length");let r=e.ZERO,a=si(BigInt(n.length)),s=a>12?a-3:a>4?a-2:a?2:1,o=(1<<s)-1,l=Array(o+1).fill(r),c=Math.floor((t.BITS-1)/s)*s,d=r;for(let e=c;e>=0;e-=s){l.fill(r);for(let t=0;t<i.length;t++){let r=Number(i[t]>>BigInt(e)&BigInt(o));l[r]=l[r].add(n[t])}let t=r;for(let e=l.length-1,n=r;e>0;e--)n=n.add(l[e]),t=t.add(n);if(d=d.add(t),0!==e)for(let e=0;e<s;e++)d=d.double()}return d}(h,r,e,t)}_setWindowSize(e){m.setWindowSize(this,e)}assertValidity(){u(this)}hasEvenY(){let{y:e}=this.toAffine();if(i.isOdd)return!i.isOdd(e);throw Error("Field doesn't support isOdd")}equals(e){c(e);let{px:t,py:n,pz:r}=this,{px:a,py:s,pz:o}=e,l=i.eql(i.mul(t,o),i.mul(a,r)),d=i.eql(i.mul(n,o),i.mul(s,r));return l&&d}negate(){return new h(this.px,i.neg(this.py),this.pz)}double(){let{a:e,b:t}=n,r=i.mul(t,sQ),{px:a,py:s,pz:o}=this,l=i.ZERO,c=i.ZERO,d=i.ZERO,u=i.mul(a,a),p=i.mul(s,s),m=i.mul(o,o),y=i.mul(a,s);return y=i.add(y,y),d=i.mul(a,o),d=i.add(d,d),l=i.mul(e,d),c=i.mul(r,m),c=i.add(l,c),l=i.sub(p,c),c=i.add(p,c),c=i.mul(l,c),l=i.mul(y,l),d=i.mul(r,d),m=i.mul(e,m),y=i.sub(u,m),y=i.mul(e,y),y=i.add(y,d),d=i.add(u,u),u=i.add(d,u),u=i.add(u,m),u=i.mul(u,y),c=i.add(c,u),m=i.mul(s,o),m=i.add(m,m),u=i.mul(m,y),l=i.sub(l,u),d=i.mul(m,p),d=i.add(d,d),new h(l,c,d=i.add(d,d))}add(e){c(e);let{px:t,py:r,pz:a}=this,{px:s,py:o,pz:l}=e,d=i.ZERO,u=i.ZERO,p=i.ZERO,m=n.a,y=i.mul(n.b,sQ),f=i.mul(t,s),g=i.mul(r,o),w=i.mul(a,l),v=i.add(t,r),b=i.add(s,o);v=i.mul(v,b),b=i.add(f,g),v=i.sub(v,b),b=i.add(t,a);let x=i.add(s,l);return b=i.mul(b,x),x=i.add(f,w),b=i.sub(b,x),x=i.add(r,a),d=i.add(o,l),x=i.mul(x,d),d=i.add(g,w),x=i.sub(x,d),p=i.mul(m,b),d=i.mul(y,w),p=i.add(d,p),d=i.sub(g,p),p=i.add(g,p),u=i.mul(d,p),g=i.add(f,f),g=i.add(g,f),w=i.mul(m,w
26),b=i.mul(y,b),g=i.add(g,w),w=i.sub(f,w),w=i.mul(m,w),b=i.add(b,w),f=i.mul(g,b),u=i.add(u,f),f=i.mul(x,b),d=i.mul(v,d),d=i.sub(d,f),f=i.mul(v,g),p=i.mul(x,p),new h(d,u,p=i.add(p,f))}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return m.wNAFCached(this,e,h.normalizeZ)}multiplyUnsafe(e){let{endo:t,n:r}=n;sn("scalar",e,sZ,r);let a=h.ZERO;if(e===sZ)return a;if(this.is0()||e===sY)return this;if(!t||m.hasPrecomputes(this))return m.wNAFCachedUnsafe(this,e,h.normalizeZ);let{k1neg:s,k1:o,k2neg:l,k2:c}=t.splitScalar(e),d=a,u=a,p=this;for(;o>sZ||c>sZ;)o&sY&&(d=d.add(p)),c&sY&&(u=u.add(p)),p=p.double(),o>>=sY,c>>=sY;return s&&(d=d.negate()),l&&(u=u.negate()),u=new h(i.mul(u.px,t.beta),u.py,u.pz),d.add(u)}multiply(e){let t,r,{endo:a,n:s}=n;if(sn("scalar",e,sY,s),a){let{k1neg:n,k1:s,k2neg:o,k2:l}=a.splitScalar(e),{p:c,f:d}=this.wNAF(s),{p:u,f:p}=this.wNAF(l);c=m.constTimeNegate(n,c),u=m.constTimeNegate(o,u),u=new h(i.mul(u.px,a.beta),u.py,u.pz),t=c.add(u),r=d.add(p)}else{let{p:n,f:i}=this.wNAF(e);t=n,r=i}return h.normalizeZ([t,r])[0]}multiplyAndAddUnsafe(e,t,n){let i=h.BASE,r=(e,t)=>t!==sZ&&t!==sY&&e.equals(i)?e.multiply(t):e.multiplyUnsafe(t),a=r(this,t).add(r(e,n));return a.is0()?void 0:a}toAffine(e){return d(this,e)}isTorsionFree(){let{h:e,isTorsionFree:t}=n;if(e===sY)return!0;if(t)return t(h,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:e,clearCofactor:t}=n;return e===sY?this:t?t(h,this):this.multiplyUnsafe(n.h)}toRawBytes(e=!0){return aZ("isCompressed",e),this.assertValidity(),a(h,this,e)}toHex(e=!0){return aZ("isCompressed",e),aQ(this.toRawBytes(e))}}h.BASE=new h(n.Gx,n.Gy,i.ONE),h.ZERO=new h(i.ZERO,i.ONE,i.ZERO);let p=n.nBitLength,m=(t=n.endo?Math.ceil(p/2):p,{constTimeNegate:sP,hasPrecomputes:e=>1!==sM(e),unsafeLadder(e,t,n=h.ZERO){let i=e;for(;t>sS;)t&sk&&(n=n.add(i)),i=i.double(),t>>=sk;return n},precomputeWindow(e,n){let{windows:i,windowSize:r}=sO(n,t),a=[],s=e,o=s;for(let e=0;e<i;e++){o=s,a.push(o);for(let e=1;e<r;e++)o=o.add(s),a.push(o);s=o.double()}return a},wNAF(e,n,i){let{windows:r,windowSize:a}=sO(e,t),s=h.ZERO,o=h.BASE,l=BigInt(2**e-1),c=2**e,d=BigInt(e);for(let e=0;e<r;e++){let t=e*a,r=Number(i&l);i>>=d,r>a&&(r-=c,i+=sk);let u=t+Math.abs(r)-1,h=e%2!=0,p=r<0;0===r?o=o.add(sP(h,n[t])):s=s.add(sP(p,n[u]))}return{p:s,f:o}},wNAFUnsafe(e,n,i,r=h.ZERO){let{windows:a,windowSize:s}=sO(e,t),o=BigInt(2**e-1),l=2**e,c=BigInt(e);for(let e=0;e<a;e++){let t=e*s;if(i===sS)break;let a=Number(i&o);if(i>>=c,a>s&&(a-=l,i+=sk),0===a)continue;let d=n[t+Math.abs(a)-1];a<0&&(d=d.negate()),r=r.add(d)}return r}
vendor: 4,528 bytes, line 26
26,getPrecomputes(e,t,n){let i=sN.get(t);return i||(i=this.precomputeWindow(t,e),1!==e&&sN.set(t,n(i))),i},wNAFCached(e,t,n){let i=sM(e);return this.wNAF(i,this.getPrecomputes(i,e,n),t)},wNAFCachedUnsafe(e,t,n,i){let r=sM(e);return 1===r?this.unsafeLadder(e,t,i):this.wNAFUnsafe(r,this.getPrecomputes(r,e,n),t,i)},setWindowSize(e,n){sj(n,t),sR.set(e,n),sN.delete(e)}});return{CURVE:n,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:function(e){return st(e,sY,n.n)}}}({...t,toBytes(e,t,i){let r=t.toAffine(),a=n.toBytes(r.x);return aZ("isCompressed",i),i?a9(Uint8Array.from([t.hasEvenY()?2:3]),a):a9(Uint8Array.from([4]),a,n.toBytes(r.y))},fromBytes(e){let t=e.length,i=e[0],s=e.subarray(1);if(t===r&&(2===i||3===i)){let e,t=a4(s);if(!st(t,sY,n.ORDER))throw Error("Point is not on curve");let r=c(t);try{e=n.sqrt(r)}catch(e){throw Error("Point is not on curve"+(e instanceof Error?": "+e.message:""))}return(1&i)==1!=((e&sY)===sY)&&(e=n.neg(e)),{x:t,y:e}}if(t===a&&4===i)return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))};throw Error("invalid Point, expected length of "+r+", or uncompressed "+a+", got "+t)}}),u=e=>aQ(a6(e,t.nByteLength)),h=(e,t,n)=>a4(e.slice(t,n));class p{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){let n=t.nByteLength;return new p(h(e=a7("compactSignature",e,2*n),0,n),h(e,n,2*n))}static fromDER(e){let{r:t,s:n}=sJ.toSig(a7("DER",e));return new p(t,n)}assertValidity(){sn("r",this.r,sY,i),sn("s",this.s,sY,i)}addRecoveryBit(e){return new p(this.r,this.s,e)}recoverPublicKey(e){let{r:r,s:a,recovery:l}=this,c=f(a7("msgHash",e));if(null==l||![0,1,2,3].includes(l))throw Error("recovery id invalid");let d=2===l||3===l?r+t.n:r;if(d>=n.ORDER)throw Error("recovery id 2 or 3 invalid");let h=(1&l)==0?"02":"03",p=o.fromHex(h+u(d)),m=s_(d,i),y=s(-c*m),g=s(a*m),w=o.BASE.multiplyAndAddUnsafe(p,y,g);if(!w)throw Error("point at infinify");return w.assertValidity(),w}hasHighS(){return this.s>i>>sY}normalizeS(){return this.hasHighS()?new p(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return a3(this.toDERHex())}toDERHex(){return sJ.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return a3(this.toCompactHex())}toCompactHex(){return u(this.r)+u(this.s)}}function m(e){let t=aK(e),n="string"==typeof e,i=(t||n)&&e.length;return t?i===r||i===a:n?i===2*r||i===2*a:e instanceof o}let y=t.bits2int||function(e){if(e.length>8192)throw Error("input is too large");let n=a4(e),i=8*e.length-t.nBitLength;return i>0?n>>BigInt(i):n},f=t.bits2int_modN||function(e){return s(y(e))},g=sr(t.nBitLength);function w(e){return sn("num < 2^"+t.nBitLength,e,sZ,g),a6(e,t.nByteLength)}let v={lowS:t.lowS,prehash:!1},b={lowS:t.lowS,prehash:!1};return o.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return o.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(m(e))throw Error("first arg must be private key");if(!m(t))throw Error("second arg must be public key");return o.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,r,a=v){let{seed:c,k2sig:u}=function(e,r,a=v){if(["recovered","canonical"].some(e=>e in a))throw Error("sign() legacy options not supported");let{hash:c,randomBytes:u}=t,{lowS:h,prehash:m,extraEntropy:g}=a;null==h&&(h=!0),e=a7("msgHash",e),sV(a),m&&(e=a7("prehashed msgHash",c(e)));let b=f(e),x=l(r),_=[w(x),w(b)];if(null!=g&&!1!==g){let e=!0===g?u(n.BYTES):g;_.push(a7("extraEntropy",e))}return{seed:a9(..._),k2sig:function(e){var t;let n=y(e);if(!d(n))return;let r=s_(n,i),a=o.BASE.multiply(n).toAffine(),l=s(a.x);if(l===sZ)return;let c=s(r*s(b+l*x));if(c===sZ)return;let u=2*(a.x!==l)|Number(a.y&sY),m=c;return h&&c>i>>sY&&(m=(t=c)>i>>sY?s(-t):t,u^=1),new p(l,m,u)}}}(e,r,a);return so(t.hash.outputLen,t.nByteLength,t.hmac)(c,u)},verify:function(e,n,r,a=b){let l,c;n=a7("msgHash",n),r=a7("publicKey",r);let{lowS:d,prehash:u,format:h}=a;if(sV(a),"strict"in a)throw Error("options.strict was renamed to lowS");if(void 0!==h&&"compact"!==h&&"der"!==h)throw Error("format must be compact or der");let m="string"==typeof e||aK(e),y=!m&&!h&&"object"==typeof e&&null!==e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!m&&!y)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");try{if(y&&(l=new p(e.r,e.s)),m){try{"compact"!==h&&(l=p.fromDER(e))}catch(e){if(!(e instanceof sJ.Err))throw e}l||"der"===h||(l=p.fromCompact(e))}c=o.fromHex(r)}catch{return!1}if(!l||d&&l.hasHighS())return!1;u&&(n=t.hash(n));
26let{r:g,s:w}=l,v=f(n),x=s_(w,i),_=s(v*x),C=s(g*x),I=o.BASE.multiplyAndAddUnsafe(c,_,C)?.toAffine();return!!I&&s(I.x)===g},ProjectivePoint:o,Signature:p,utils:{isValidPrivateKey(e){try{return l(e),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let e=sA(t.n);return function(e,t,n=!1){let i=e.length,r=sT(t),a=sA(t);if(i<16||i<a||i>1024)throw Error("expected "+a+"-1024 bytes of input, got "+i);let s=sv(n?a5(e):a4(e),t-sp)+sp;return n?a8(s,r):a6(s,r)}(t.randomBytes(e),t.n)},precompute:(e=8,t=o.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}})({...e,hash:t,hmac:(e,...n)=>aD(t,e,function(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];rw(i),t+=i.length}let n=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){let r=e[t];n.set(r,i),i+=r.length}return n}(...n)),randomBytes:rO});return{...n(t),create:n}}({a:sX.create(BigInt("-3")),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:sX,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},aq),s1="base10",s2="base16",s3="base64pad",s4="base64url",s5="utf8";function s6(){let e=rO(32);return(0,i$.dI)(e,s2)}function s8(e){let t=aq((0,i$.sH)(e,s2));return(0,i$.dI)(t,s2)}function s7(e){let t=aq((0,i$.sH)(e,s5));return(0,i$.dI)(t,s2)}function s9(e){return(0,i$.sH)(`${e}`,s1)}function oe(e){return Number((0,i$.dI)(e,s1))}function ot(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function on(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4;return t+"=".repeat(n)}function oi(e){if(2===oe(e.type))return(0,i$.dI)((0,i$.xW)([e.type,e.sealed]),s3);if(1===oe(e.type)){if(typeof e.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");return(0,i$.dI)((0,i$.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),s3)}return(0,i$.dI)((0,i$.xW)([e.type,e.iv,e.sealed]),s3)}function or(e){let t=(e.encoding||s3)===s4?on(e.encoded):e.encoded,n=(0,i$.sH)(t,s3),i=n.slice(0,1);if(1===oe(i)){let e=n.slice(1,33),t=n.slice(33,45);return{type:i,sealed:n.slice(45),iv:t,senderPublicKey:e}}if(2===oe(i))return{type:i,sealed:n.slice(1),iv:rO(12)};let r=n.slice(1,13);return{type:i,sealed:n.slice(13),iv:r}}function oa(e){let t=e?.type||0;if(1===t){if(typeof e?.senderPublicKey>"u")throw Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function os(e){return 1===e.type&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function oo(e){return e?.relay||{protocol:"irn"}}function ol(e){let t=iB.CG[e];if(typeof t>"u")throw Error(`Relay Protocol not supported: ${e}`);return t}function oc(e){var t;if(!e.includes("wc:")){let t=rf(e);null!=t&&t.includes("wc:")&&(e=t)}let n=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),i=-1!==e.indexOf("?")?e.indexOf("?"):void 0,r=e.substring(0,n),a=e.substring(n+1,i).split("@"),s=new URLSearchParams("u">typeof i?e.substring(i):""),o={};s.forEach((e,t)=>{o[t]=e});let l="string"==typeof o.methods?o.methods.split(","):void 0;return{protocol:r,topic:(t=a[0]).startsWith("//")?t.substring(2):t,version:parseInt(a[1],10),symKey:o.symKey,relay:function(e,t="-"){let n={},i="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(i)){let r=t.replace(i,""),a=e[t];n[r]=a}}),n}(o),methods:l,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function od(e){let t=new URLSearchParams,n=function(e,t="-"){let n={};return Object.keys(e).forEach(i=>{e[i]&&(n["relay"+t+i]=e[i])}),n}(e.relay);Object.keys(n).sort().forEach(e=>{t.set(e,n[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));let i=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${i}`}function ou(e,t,n){return`${e}?wc_ev=${n}&topic=${t}`}function oh(e){let t=[];
26return e.forEach(e=>{let[n,i]=e.split(":");t.push(`${n}:${i}`)}),t}function op(e){return e.includes(":")}function om(e){return op(e)?e.split(":")[0]:e}function oy(e,t){let n=function(e){let t={};return e?.forEach(e=>{var n;let[i,r]=e.split(":");t[i]||(t[i]={accounts:[],chains:[],events:[],methods:[]}),t[i].accounts.push(e),null==(n=t[i].chains)||n.push(`${i}:${r}`)}),t}(t=t.map(e=>e.replace("did:pkh:","")));for(let[t,i]of Object.entries(n))i.methods?i.methods=rd(i.methods,e):i.methods=e,i.events=["chainChanged","accountsChanged"];return n}Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;let of={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},og={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function ow(e,t){let{message:n,code:i}=og[e];return{message:t?`${n} ${t}`:n,code:i}}function ov(e,t){let{message:n,code:i}=of[e];return{message:t?`${n} ${t}`:n,code:i}}function ob(e,t){return!!Array.isArray(e)&&(!("u">typeof t)||!e.length||e.every(t))}function ox(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function o_(e){return typeof e>"u"}function oC(e,t){return!!(t&&o_(e))||"string"==typeof e&&!!e.trim().length}function oI(e,t){return!!(t&&o_(e))||"number"==typeof e&&!isNaN(e)}function oE(e){return!!(oC(e,!1)&&e.includes(":"))&&2===e.split(":").length}function oT(e){let t=!0;return ob(e)?e.length&&(t=e.every(e=>oC(e,!1))):t=!1,t}function oA(e,t){let n=null;return Object.values(e).forEach(e=>{var i;let r;if(n)return;let a=(i=`${t}, namespace`,r=null,oT(e?.methods)?oT(e?.events)||(r=ov("UNSUPPORTED_EVENTS",`${i}, events should be an array of strings or empty array for no events`)):r=ov("UNSUPPORTED_METHODS",`${i}, methods should be an array of strings or empty array for no methods`),r);a&&(n=a)}),n}function oS(e,t){let n=null;if(e&&ox(e)){let i,r=oA(e,t);r&&(n=r);let a=(i=null,Object.values(e).forEach(e=>{var n,r;let a;if(i)return;let s=(n=e?.accounts,r=`${t} namespace`,a=null,ob(n)?n.forEach(e=>{a||function(e){if(oC(e,!1)&&e.includes(":")){let t=e.split(":");if(3===t.length){let e=t[0]+":"+t[1];return!!t[2]&&oE(e)}}return!1}(e)||(a=ov("UNSUPPORTED_ACCOUNTS",`${r}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):a=ov("UNSUPPORTED_ACCOUNTS",`${r}
26, accounts should be an array of strings conforming to "namespace:chainId:address" format`),a);s&&(i=s)}),i);a&&(n=a)}else n=ow("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return n}function ok(e){return oC(e.protocol,!0)}function oP(e){return"u">typeof e}function oj(e,t){return!(!oE(t)||!(function(e){let t=[];return Object.values(e).forEach(e=>{t.push(...oh(e.accounts))}),t})(e).includes(t))}function oO(e,t,n){let i=null,r=function(e){let t={};return Object.keys(e).forEach(n=>{var i;n.includes(":")?t[n]=e[n]:null==(i=e[n].chains)||i.forEach(i=>{t[i]={methods:e[n].methods,events:e[n].events}})}),t}(e),a=function(e){let t={};return Object.keys(e).forEach(n=>{if(n.includes(":"))t[n]=e[n];else{let i=oh(e[n].accounts);i?.forEach(i=>{t[i]={accounts:e[n].accounts.filter(e=>e.includes(`${i}:`)),methods:e[n].methods,events:e[n].events}})}}),t}(t),s=Object.keys(r),o=Object.keys(a),l=oN(Object.keys(e)),c=oN(Object.keys(t)),d=l.filter(e=>!c.includes(e));return d.length&&(i=ow("NON_CONFORMING_NAMESPACES",`${n} namespaces keys don't satisfy requiredNamespaces.
27      Required: ${d.toString()}
28      Received: ${Object.keys(t).toString()}`)),re(s,o)||(i=ow("NON_CONFORMING_NAMESPACES",`${n} namespaces chains don't satisfy required namespaces.
29      Required: ${s.toString()}
30      Approved: ${o.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||i)return;let r=oh(t[e].accounts);r.includes(e)||(i=ow("NON_CONFORMING_NAMESPACES",`${n} namespaces accounts don't satisfy namespace accounts for ${e}
31        Required: ${e}
32        Approved: ${r.toString()}`))}),s.forEach(e=>{i||(re(r[e].methods,a[e].methods)?re(r[e].events,a[e].events)||(i=ow("NON_CONFORMING_NAMESPACES",`${n} namespaces events don't satisfy namespace events for ${e}`)):i=ow("NON_CONFORMING_NAMESPACES",`${n} namespaces methods don't satisfy namespace methods for ${e}`))}),i}function oN(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function oR(){let e=i6();return new Promise(t=>{switch(e){case i2.browser:t(i5()&&navigator?.onLine);break;case i2.reactNative:t(oM());break;case i2.node:default:t(!0)}})}async function oM(){if(i4()&&"u">typeof n.g&&null!=n.g&&n.g.NetInfo){let e=await (null==n.g?void 0:n.g.NetInfo.fetch());return e?.isConnected}return!0}let oD={};class oU{static get(e){return oD[e]}static set(e,t){oD[e]=t}static delete(e){delete oD[e]}}var oL=n(285088),oF=n(67374),oW=n(794310),o$=n(406227),oB=n(373800),oz=n(554169),oq=n(88294),oV=n(217874),oH=n(715599).Buffer,oG=n(923727);let oK="core",oJ=`wc@2:${oK}:`,oZ={logger:"error"},oY={database:":memory:"},oQ="client_ed25519_seed",oX=iM.ONE_DAY,o0=iM.SIX_HOURS,o1="wss://relay.walletconnect.org",o2={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",publish:"relayer_publish"},o3={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},o4="2.19.2",o5={link_mode:"link_mode",relay:"relay"},o6={inbound:"inbound",outbound:"outbound"},o8="WALLETCONNECT_LINK_MODE_APPS",o7={created:"subscription_created",deleted:"subscription_deleted",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},o9=(iM.FIVE_SECONDS,{wc_pairingDelete:{req:{ttl:iM.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:iM.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:iM.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:iM.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:iM.ONE_DAY,prompt:!1,tag:0},res:{ttl:iM.ONE_DAY,prompt:!1,tag:0}}}),le={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},lt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},ln={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},li="https://verify.walletconnect.org",lr=`${li}/v3`,la=["https://verify.walletconnect.com",li],ls={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal"},lo={no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_listener_not_found:"proposal_listener_not_found"},ll={session_approve_started:"session_approve_started",session_namespaces_validation_success:"session_namespaces_validation_success",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},lc={no_internet_connection:"no_internet_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},ld={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"}
32,lu={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"};var lh=function(e,t){if(e.length>=255)throw TypeError("Alphabet too long");for(var n=new Uint8Array(256),i=0;i<n.length;i++)n[i]=255;for(var r=0;r<e.length;r++){var a=e.charAt(r),s=a.charCodeAt(0);if(255!==n[s])throw TypeError(a+" is ambiguous");n[s]=r}var o=e.length,l=e.charAt(0),c=Math.log(o)/Math.log(256),d=Math.log(256)/Math.log(o);function u(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[0]){for(var i=0,r=0;e[t]===l;)i++,t++;for(var a=(e.length-t)*c+1>>>0,s=new Uint8Array(a);e[t];){var d=n[e.charCodeAt(t)];if(255===d)return;for(var u=0,h=a-1;(0!==d||u<r)&&-1!==h;h--,u++)d+=o*s[h]>>>0,s[h]=d%256>>>0,d=d/256>>>0;if(0!==d)throw Error("Non-zero carry");r=u,t++}if(" "!==e[t]){for(var p=a-r;p!==a&&0===s[p];)p++;for(var m=new Uint8Array(i+(a-p)),y=i;p!==a;)m[y++]=s[p++];return m}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===t.length)return"";for(var n=0,i=0,r=0,a=t.length;r!==a&&0===t[r];)r++,n++;for(var s=(a-r)*d+1>>>0,c=new Uint8Array(s);r!==a;){for(var u=t[r],h=0,p=s-1;(0!==u||h<i)&&-1!==p;p--,h++)u+=256*c[p]>>>0,c[p]=u%o>>>0,u=u/o>>>0;if(0!==u)throw Error("Non-zero carry");i=h,r++}for(var m=s-i;m!==s&&0===c[m];)m++;for(var y=l.repeat(n);m<s;++m)y+=e.charAt(c[m]);return y},decodeUnsafe:u,decode:function(e){var n=u(e);if(n)return n;throw Error(`Non-${t} character`)}}};let lp=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error("Unknown type, must be binary type")};class lm{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ly{constructor(e,t,n){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return lg(this,e)}}class lf{constructor(e){this.decoders=e}or(e){return lg(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}let lg=(e,t)=>new lf({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class lw{constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new lm(e,t,n),this.decoder=new ly(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}let lv=({name:e,prefix:t,encode:n,decode:i})=>new lw(e,t,n,i),lb=({prefix:e,name:t,alphabet:n})=>{let{encode:i,decode:r}=lh(n,t);return lv({prefix:e,name:t,encode:i,decode:e=>lp(r(e))})},lx=({name:e,prefix:t,bitsPerChar:n,alphabet:i})=>lv({prefix:t,name:e,encode:e=>((e,t,n)=>{let i="="===t[t.length-1],r=(1<<n)-1,a="",s=0,o=0;for(let i=0;i<e.length;++i)for(o=o<<8|e[i],s+=8;s>n;)s-=n,a+=t[r&o>>s];if(s&&(a+=t[r&o<<n-s]),i)for(;a.length*n&7;)a+="=";return a})(e,i,n),decode:t=>((e,t,n,i)=>{let r={};for(let e=0;e<t.length;++e)r[t[e]]=e;let a=e.length;for(;"="===e[a-1];)--a;let s=new Uint8Array(a*n/8|0),o=0,l=0,c=0;for(let t=0;t<a;++t){let a=r[e[t]];if(void 0===a)throw SyntaxError(`Non-${i} character`);l=l<<n|a,(o+=n)>=8&&(o-=8,s[c++]=255&l>>o)}if(o>=n||255&l<<8-o)throw SyntaxError("Unexpected end of data");return s})(t,i,n,e)});var l_=Object.freeze({__proto__:null,identity:lv({prefix:"\0",name:"identity",encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)})}),lC=Object.freeze({__proto__:null,base2:lx({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})}),lI=Object.freeze({__proto__:null,base8:lx({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})}),lE=Object.freeze({__proto__:null,base10:lb({prefix:"9",name:"base10",alphabet:"0123456789"})}),lT=Object.freeze({__proto__:null,base16:lx({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper:lx({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});let lA=lx({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),lS=lx({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),lk=lx({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),lP=lx({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),lj=lx({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),lO=lx({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),lN=lx({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5});var lR=Object.freeze({__proto__:null,base32:lA,base32upper:lS,base32pad:lk,base32padupper:lP,base32hex:lj,base32hexupper:lO,base32hexpad:lN,base32hexpadupper:lx({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z:lx({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})}),lM=Object.freeze({__proto__:null,base36:lb({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper:lb({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})}),lD=Object.freeze({__proto__:null,base58btc:lb({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr:lb({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});let lU=lx({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
32+/",bitsPerChar:6}),lL=lx({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6});var lF=Object.freeze({__proto__:null,base64:lU,base64pad:lL,base64url:lx({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad:lx({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});let lW=Array.from("\uD83D\uDE80\uD83E\uDE90☄\uD83D\uDEF0\uD83C\uDF0C\uD83C\uDF11\uD83C\uDF12\uD83C\uDF13\uD83C\uDF14\uD83C\uDF15\uD83C\uDF16\uD83C\uDF17\uD83C\uDF18\uD83C\uDF0D\uD83C\uDF0F\uD83C\uDF0E\uD83D\uDC09☀\uD83D\uDCBB\uD83D\uDDA5\uD83D\uDCBE\uD83D\uDCBF\uD83D\uDE02❤\uD83D\uDE0D\uD83E\uDD23\uD83D\uDE0A\uD83D\uDE4F\uD83D\uDC95\uD83D\uDE2D\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE05\uD83D\uDC4F\uD83D\uDE01\uD83D\uDD25\uD83E\uDD70\uD83D\uDC94\uD83D\uDC96\uD83D\uDC99\uD83D\uDE22\uD83E\uDD14\uD83D\uDE06\uD83D\uDE44\uD83D\uDCAA\uD83D\uDE09☺\uD83D\uDC4C\uD83E\uDD17\uD83D\uDC9C\uD83D\uDE14\uD83D\uDE0E\uD83D\uDE07\uD83C\uDF39\uD83E\uDD26\uD83C\uDF89\uD83D\uDC9E✌✨\uD83E\uDD37\uD83D\uDE31\uD83D\uDE0C\uD83C\uDF38\uD83D\uDE4C\uD83D\uDE0B\uD83D\uDC97\uD83D\uDC9A\uD83D\uDE0F\uD83D\uDC9B\uD83D\uDE42\uD83D\uDC93\uD83E\uDD29\uD83D\uDE04\uD83D\uDE00\uD83D\uDDA4\uD83D\uDE03\uD83D\uDCAF\uD83D\uDE48\uD83D\uDC47\uD83C\uDFB6\uD83D\uDE12\uD83E\uDD2D❣\uD83D\uDE1C\uD83D\uDC8B\uD83D\uDC40\uD83D\uDE2A\uD83D\uDE11\uD83D\uDCA5\uD83D\uDE4B\uD83D\uDE1E\uD83D\uDE29\uD83D\uDE21\uD83E\uDD2A\uD83D\uDC4A\uD83E\uDD73\uD83D\uDE25\uD83E\uDD24\uD83D\uDC49\uD83D\uDC83\uD83D\uDE33✋\uD83D\uDE1A\uD83D\uDE1D\uD83D\uDE34\uD83C\uDF1F\uD83D\uDE2C\uD83D\uDE43\uD83C\uDF40\uD83C\uDF37\uD83D\uDE3B\uD83D\uDE13⭐✅\uD83E\uDD7A\uD83C\uDF08\uD83D\uDE08\uD83E\uDD18\uD83D\uDCA6✔\uD83D\uDE23\uD83C\uDFC3\uD83D\uDC90☹\uD83C\uDF8A\uD83D\uDC98\uD83D\uDE20☝\uD83D\uDE15\uD83C\uDF3A\uD83C\uDF82\uD83C\uDF3B\uD83D\uDE10\uD83D\uDD95\uD83D\uDC9D\uD83D\uDE4A\uD83D\uDE39\uD83D\uDDE3\uD83D\uDCAB\uD83D\uDC80\uD83D\uDC51\uD83C\uDFB5\uD83E\uDD1E\uD83D\uDE1B\uD83D\uDD34\uD83D\uDE24\uD83C\uDF3C\uD83D\uDE2B⚽\uD83E\uDD19☕\uD83C\uDFC6\uD83E\uDD2B\uD83D\uDC48\uD83D\uDE2E\uD83D\uDE46\uD83C\uDF7B\uD83C\uDF43\uD83D\uDC36\uD83D\uDC81\uD83D\uDE32\uD83C\uDF3F\uD83E\uDDE1\uD83C\uDF81⚡\uD83C\uDF1E\uD83C\uDF88❌✊\uD83D\uDC4B\uD83D\uDE30\uD83E\uDD28\uD83D\uDE36\uD83E\uDD1D\uD83D\uDEB6\uD83D\uDCB0\uD83C\uDF53\uD83D\uDCA2\uD83E\uDD1F\uD83D\uDE41\uD83D\uDEA8\uD83D\uDCA8\uD83E\uDD2C✈\uD83C\uDF80\uD83C\uDF7A\uD83E\uDD13\uD83D\uDE19\uD83D\uDC9F\uD83C\uDF31\uD83D\uDE16\uD83D\uDC76\uD83E\uDD74▶➡❓\uD83D\uDC8E\uD83D\uDCB8⬇\uD83D\uDE28\uD83C\uDF1A\uD83E\uDD8B\uD83D\uDE37\uD83D\uDD7A⚠\uD83D\uDE45\uD83D\uDE1F\uD83D\uDE35\uD83D\uDC4E\uD83E\uDD32\uD83E\uDD20\uD83E\uDD27\uD83D\uDCCC\uD83D\uDD35\uD83D\uDC85\uD83E\uDDD0\uD83D\uDC3E\uD83C\uDF52\uD83D\uDE17\uD83E\uDD11\uD83C\uDF0A\uD83E\uDD2F\uD83D\uDC37☎\uD83D\uDCA7\uD83D\uDE2F\uD83D\uDC86\uD83D\uDC46\uD83C\uDFA4\uD83D\uDE47\uD83C\uDF51❄\uD83C\uDF34\uD83D\uDCA3\uD83D\uDC38\uD83D\uDC8C\uD83D\uDCCD\uD83E\uDD40\uD83E\uDD22\uD83D\uDC45\uD83D\uDCA1\uD83D\uDCA9\uD83D\uDC50\uD83D\uDCF8\uD83D\uDC7B\uD83E\uDD10\uD83E\uDD2E\uD83C\uDFBC\uD83E\uDD75\uD83D\uDEA9\uD83C\uDF4E\uD83C\uDF4A\uD83D\uDC7C\uD83D\uDC8D\uD83D\uDCE3\uD83E\uDD42"),l$=lW.reduce((e,t,n)=>(e[n]=t,e),[]),lB=lW.reduce((e,t,n)=>(e[t.codePointAt(0)]=n,e),[]);var lz=Object.freeze({__proto__:null,base256emoji:lv({prefix:"\uD83D\uDE80",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+=l$[t],"")},decode:function(e){let t=[];for(let n of e){let e=lB[n.codePointAt(0)];if(void 0===e)throw Error(`Non-base256emoji character: ${n}`);t.push(e)}return new Uint8Array(t)}})});function lq(e,t,n){t=t||[],n=n||0;for(var i=n;e>=0x80000000;)t[n++]=255&e|128,e/=128;for(;-128&e;)t[n++]=255&e|128,e>>>=7;return t[n]=0|e,lq.bytes=n-i+1,t}var lV={encode:lq,encodingLength:function(e){return e<128?1:e<16384?2:e<2097152?3:e<0x10000000?4:e<0x800000000?5:e<0x40000000000?6:e<0x2000000000000?7:e<0x100000000000000?8:e<0x8000000000000000?9:10}};let lH=(e,t,n=0)=>(lV.encode(e,t,n),t),lG=e=>lV.encodingLength(e),lK=(e,t)=>{let n=t.byteLength,i=lG(e),r=i+lG(n),a=new Uint8Array(r+n);return lH(e,a,0),lH(n,a,i),a.set(t,r),new lJ(e,n,t,a)};
32class lJ{constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}}let lZ=({name:e,code:t,encode:n})=>new lY(e,t,n);class lY{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?lK(this.code,t):t.then(e=>lK(this.code,e))}throw Error("Unknown type, must be binary type")}}let lQ=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t));var lX=Object.freeze({__proto__:null,sha256:lZ({name:"sha2-256",code:18,encode:lQ("SHA-256")}),sha512:lZ({name:"sha2-512",code:19,encode:lQ("SHA-512")})}),l0=Object.freeze({__proto__:null,identity:{code:0,name:"identity",encode:lp,digest:e=>lK(0,lp(e))}});new TextEncoder,new TextDecoder;let l1={...l_,...lC,...lI,...lE,...lT,...lR,...lM,...lD,...lF,...lz};function l2(e,t,n,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:i}}}({...lX,...l0});let l3=l2("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),l4=l2("ascii","a",e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},e=>{let t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}),l5={utf8:l3,"utf-8":l3,hex:l1.base16,latin1:l4,ascii:l4,binary:l4,...l1};var l6=Object.defineProperty,l8=(e,t,n)=>((e,t,n)=>t in e?l6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class l7{constructor(e,t){this.core=e,this.logger=t,l8(this,"keychain",new Map),l8(this,"name","keychain"),l8(this,"version","0.3"),l8(this,"initialized",!1),l8(this,"storagePrefix",oJ),l8(this,"init",async()=>{if(!this.initialized){let e=await this.getKeyChain();"u">typeof e&&(this.keychain=e),this.initialized=!0}}),l8(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),l8(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),l8(this,"get",e=>{this.isInitialized();let t=this.keychain.get(e);if(typeof t>"u"){let{message:t}=ow("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}),l8(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,oW.U5)(t,this.name)}get context(){return(0,oW.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,rt(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return"u">typeof e?rn(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}}var l9=Object.defineProperty,ce=(e,t,n)=>((e,t,n)=>t in e?l9(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class ct{constructor(e,t,n){this.core=e,this.logger=t,ce(this,"name","crypto"),ce(this,"keychain"),ce(this,"randomSessionIdentifier",s6()),ce(this,"initialized",!1),ce(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),ce(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),ce(this,"getClientId",async()=>{this.isInitialized();let e=await this.getClientSeed(),t=iW.TZ(e);return iW.UF(t.publicKey)}),ce(this,"generateKeyPair",()=>{this.isInitialized();let e=function(){let e=sq.utils.randomPrivateKey(),t=sq.getPublicKey(e);return{privateKey:(0,i$.dI)(e,s2),publicKey:(0,i$.dI)(t,s2)}}();return this.setPrivateKey(e.publicKey,e.privateKey)}),ce(this,"signJWT",async e=>{this.isInitialized();let t=await this.getClientSeed(),n=iW.TZ(t),i=this.randomSessionIdentifier;return await iW.FA(i,e,oX,n)}),ce(this,"generateSharedKey",(e,t,n)=>{this.isInitialized();let i=function(e,t){var n;let i,r=sq.getSharedSecret((0,i$.sH)(e,s2),(0,i$.sH)(t,s2)),a=(i=void 0,function(e,t,n,i=32){if(rv(e),rg(i),i>255*e.outputLen)throw Error("Length should be <= 255*HashLen");let r=Math.ceil(i/e.outputLen);void 0===n&&(n=aL);let a=new Uint8Array(r*e.outputLen),s=aD.create(e,t),o=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let t=0;t<r;t++)aU[0]=t+1,o.update(0===t?aL:l).update(n).update(aU).digestInto(l),a.set(l,e.outputLen*t),s._cloneInto(o);return s.destroy(),o.destroy(),l.fill(0),aU.fill(0),a.slice(0,i)}(aq,(n=void 0,rv(aq),void 0===n&&(n=new Uint8Array(aq.outputLen)),aD(aq,rk(n),rk(r))),i,32));return(0,i$.dI)(a,s2)}(this.getPrivateKey(e),t);return this.setSymKey(i,n)}),ce(this,"setSymKey",async(e,t)=>{this.isInitialized();let n=t||s8(e);return await this.keychain.set(n,e),n}),ce(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),ce(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),ce(this,"encode",async(e,t,n)=>{this.isInitialized();let i=oa(n),r=(0,oB.h)(t);if(2===i.type)return function(e,t){let n=s9(2),i=rO(12),r=oi({type:n,sealed:(0,i$.sH)(e,s5),iv:i});return t===s4?ot(r):r}(r,n?.encoding);
32if(os(i)){let t=i.senderPublicKey,n=i.receiverPublicKey;e=await this.generateSharedKey(t,n)}let a=this.getSymKey(e),{type:s,senderPublicKey:o}=i;return function(e){let t=s9("u">typeof e.type?e.type:0);if(1===oe(t)&&typeof e.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");let n="u">typeof e.senderPublicKey?(0,i$.sH)(e.senderPublicKey,s2):void 0,i="u">typeof e.iv?(0,i$.sH)(e.iv,s2):rO(12),r=oi({type:t,sealed:aR((0,i$.sH)(e.symKey,s2),i).encrypt((0,i$.sH)(e.message,s5)),iv:i,senderPublicKey:n});return e.encoding===s4?ot(r):r}({type:s,symKey:a,message:r,senderPublicKey:o,encoding:n?.encoding})}),ce(this,"decode",async(e,t,n)=>{this.isInitialized();let i=function(e,t){let n=or({encoded:e,encoding:t?.encoding});return oa({type:oe(n.type),senderPublicKey:"u">typeof n.senderPublicKey?(0,i$.dI)(n.senderPublicKey,s2):void 0,receiverPublicKey:t?.receiverPublicKey})}(t,n);if(2===i.type){let e=function(e,t){let{sealed:n}=or({encoded:e,encoding:t});return(0,i$.dI)(n,s5)}(t,n?.encoding);return(0,oB.j)(e)}if(os(i)){let t=i.receiverPublicKey,n=i.senderPublicKey;e=await this.generateSharedKey(t,n)}try{let i=this.getSymKey(e),r=function(e){let t=(0,i$.sH)(e.symKey,s2),{sealed:n,iv:i}=or({encoded:e.encoded,encoding:e.encoding}),r=aR(t,i).decrypt(n);if(null===r)throw Error("Failed to decrypt");return(0,i$.dI)(r,s5)}({symKey:i,encoded:t,encoding:n?.encoding});return(0,oB.j)(r)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),ce(this,"getPayloadType",(e,t=s3)=>oe(or({encoded:e,encoding:t}).type)),ce(this,"getPayloadSenderPublicKey",(e,t=s3)=>{let n=or({encoded:e,encoding:t});return n.senderPublicKey?(0,i$.dI)(n.senderPublicKey,s2):void 0}),this.core=e,this.logger=(0,oW.U5)(t,this.name),this.keychain=n||new l7(this.core,this.logger)}get context(){return(0,oW.oI)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(oQ)}catch{e=s6(),await this.keychain.set(oQ,e)}return function(e,t="utf8"){let n=l5[t];if(!n)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(e,"utf8"):n.decoder.decode(`${n.prefix}${e}`)}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}}var cn=Object.defineProperty,ci=Object.defineProperties,cr=Object.getOwnPropertyDescriptors,ca=Object.getOwnPropertySymbols,cs=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable,cl=(e,t,n)=>t in e?cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cc=(e,t,n)=>cl(e,"symbol"!=typeof t?t+"":t,n);class cd extends o$.dQ{constructor(e,t){super(e,t),this.logger=e,this.core=t,cc(this,"messages",new Map),cc(this,"messagesWithoutClientAck",new Map),cc(this,"name","messages"),cc(this,"version","0.3"),cc(this,"initialized",!1),cc(this,"storagePrefix",oJ),cc(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let e=await this.getRelayerMessages();"u">typeof e&&(this.messages=e);let t=await this.getRelayerMessagesWithoutClientAck();"u">typeof t&&(this.messagesWithoutClientAck=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}}),cc(this,"set",async(e,t,n)=>{this.isInitialized();let i=s7(t),r=this.messages.get(e);if(typeof r>"u"&&(r={}),"u">typeof r[i])return i;if(r[i]=t,this.messages.set(e,r),n===o6.inbound){let n=this.messagesWithoutClientAck.get(e)||{};this.messagesWithoutClientAck.set(e,ci(((e,t)=>{for(var n in t||(t={}))cs.call(t,n)&&cl(e,n,t[n]);if(ca)for(var n of ca(t))co.call(t,n)&&cl(e,n,t[n]);return e})({},n),cr({[i]:t})))}return await this.persist(),i}),cc(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),cc(this,"getWithoutAck",e=>{this.isInitialized();let t={};for(let n of e){let e=this.messagesWithoutClientAck.get(n)||{};t[n]=Object.values(e)}return t}),cc(this,"has",(e,t)=>(this.isInitialized(),"u">typeof this.get(e)[s7(t)])),cc(this,"ack",async(e,t)=>{this.isInitialized();let n=this.messagesWithoutClientAck.get(e);if(typeof n>"u")return;let i=s7(t);delete n[i],0===Object.keys(n).length?this.messagesWithoutClientAck.delete(e):this.messagesWithoutClientAck.set(e,n),await this.persist()}),cc(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),this.messagesWithoutClientAck.delete(e),await this.persist()}),this.logger=(0,oW.U5)(e,this.name),this.core=t}
32get context(){return(0,oW.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,rt(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,rt(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return"u">typeof e?rn(e):void 0}async getRelayerMessagesWithoutClientAck(){let e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return"u">typeof e?rn(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}}var cu=Object.defineProperty,ch=Object.defineProperties,cp=Object.getOwnPropertyDescriptors,cm=Object.getOwnPropertySymbols,cy=Object.prototype.hasOwnProperty,cf=Object.prototype.propertyIsEnumerable,cg=(e,t,n)=>t in e?cu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cw=(e,t)=>{for(var n in t||(t={}))cy.call(t,n)&&cg(e,n,t[n]);if(cm)for(var n of cm(t))cf.call(t,n)&&cg(e,n,t[n]);return e},cv=(e,t)=>ch(e,cp(t)),cb=(e,t,n)=>cg(e,"symbol"!=typeof t?t+"":t,n);class cx extends o$.qE{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,cb(this,"events",new iO.EventEmitter),cb(this,"name","publisher"),cb(this,"queue",new Map),cb(this,"publishTimeout",(0,iM.toMiliseconds)(iM.ONE_MINUTE)),cb(this,"initialPublishTimeout",(0,iM.toMiliseconds)(15*iM.ONE_SECOND)),cb(this,"needsTransportRestart",!1),cb(this,"publish",async(e,t,n)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:n}});let r=n?.ttl||o0,a=oo(n),s=n?.prompt||!1,o=n?.tag||0,l=n?.id||(0,oq.getBigIntRpcId)().toString(),c={topic:e,message:t,opts:{ttl:r,relay:a,prompt:s,tag:o,id:l,attestation:n?.attestation,tvf:n?.tvf}},d=`Failed to publish payload, please try again. id:${l} tag:${o}`;try{let i=new Promise(async i=>{let a=({id:e})=>{c.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(o2.publish,a),i(c))};this.relayer.events.on(o2.publish,a);let d=rr(new Promise((i,a)=>{this.rpcPublish({topic:e,message:t,ttl:r,prompt:s,tag:o,id:l,attestation:n?.attestation,tvf:n?.tvf}).then(i).catch(e=>{this.logger.warn(e,e?.message),a(e)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${l} tag:${o}`);try{await d,this.events.removeListener(o2.publish,a)}catch(e){this.queue.set(l,cv(cw({},c),{attempt:1})),this.logger.warn(e,e?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:l,topic:e,message:t,opts:n}}),await rr(i,this.publishTimeout,d)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(i=n?.internal)&&i.throwOnFailedPublish)throw e}finally{this.queue.delete(l)}}),cb(this,"on",(e,t)=>{this.events.on(e,t)}),cb(this,"once",(e,t)=>{this.events.once(e,t)}),cb(this,"off",(e,t)=>{this.events.off(e,t)}),cb(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,oW.U5)(t,this.name),this.registerEventListeners()}get context(){return(0,oW.oI)(this.logger)}async rpcPublish(e){var t,n,i,r;let{topic:a,message:s,ttl:o=o0,prompt:l,tag:c,id:d,attestation:u,tvf:h}=e,p={method:ol(oo().protocol).publish,params:cw({topic:a,message:s,ttl:o,prompt:l,tag:c,attestation:u},h),id:d};o_(null==(t=p.params)?void 0:t.prompt)&&(null==(n=p.params)||delete n.prompt),o_(null==(i=p.params)?void 0:i.tag)&&(null==(r=p.params)||delete r.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:p});let m=await this.relayer.request(p);return this.relayer.events.emit(o2.publish,e),this.logger.debug("Successfully Published Payload"),m}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{let n=e.attempt+1;this.queue.set(t,cv(cw({},e),{attempt:n}));let{topic:i,message:r,opts:a,attestation:s}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${n}`),await this.rpcPublish(cv(cw({},e),{topic:i,message:r,ttl:a.ttl,prompt:a.prompt,tag:a.tag,id:a.id,attestation:s,tvf:a.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(oL.li.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(o2.connection_stalled);return}this.checkQueue()}),this.relayer.on(o2.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var c_=Object.defineProperty,cC=(e,t,n)=>((e,t,n)=>t in e?c_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class cI{constructor(){cC(this,"map",new Map),cC(this,"set",(e,t)=>{let n=this.get(e);this.exists(e,t)||this.map.set(e,[...n,t])}),cC(this,"get",e=>this.map.get(e)||[]),cC(this,"exists",(e,t)=>this.get(e).includes(t)),cC(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);
32if(!this.map.has(e))return;let n=this.get(e);if(!this.exists(e,t))return;let i=n.filter(e=>e!==t);if(!i.length)return void this.map.delete(e);this.map.set(e,i)}),cC(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var cE=Object.defineProperty,cT=Object.defineProperties,cA=Object.getOwnPropertyDescriptors,cS=Object.getOwnPropertySymbols,ck=Object.prototype.hasOwnProperty,cP=Object.prototype.propertyIsEnumerable,cj=(e,t,n)=>t in e?cE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cO=(e,t)=>{for(var n in t||(t={}))ck.call(t,n)&&cj(e,n,t[n]);if(cS)for(var n of cS(t))cP.call(t,n)&&cj(e,n,t[n]);return e},cN=(e,t)=>cT(e,cA(t)),cR=(e,t,n)=>cj(e,"symbol"!=typeof t?t+"":t,n);class cM extends o$.mF{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,cR(this,"subscriptions",new Map),cR(this,"topicMap",new cI),cR(this,"events",new iO.EventEmitter),cR(this,"name","subscription"),cR(this,"version","0.3"),cR(this,"pending",new Map),cR(this,"cached",[]),cR(this,"initialized",!1),cR(this,"storagePrefix",oJ),cR(this,"subscribeTimeout",(0,iM.toMiliseconds)(iM.ONE_MINUTE)),cR(this,"initialSubscribeTimeout",(0,iM.toMiliseconds)(15*iM.ONE_SECOND)),cR(this,"clientId"),cR(this,"batchSubscribeTopicsLimit",500),cR(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),cR(this,"subscribe",async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{let n=oo(t),i={topic:e,relay:n,transportType:t?.transportType};this.pending.set(e,i);let r=await this.rpcSubscribe(e,n,t);return"string"==typeof r&&(this.onSubscribe(r,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),r}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),cR(this,"unsubscribe",async(e,t)=>{this.isInitialized(),"u">typeof t?.id?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),cR(this,"isSubscribed",e=>new Promise(t=>{t(this.topicMap.topics.includes(e))})),cR(this,"isKnownTopic",e=>new Promise(t=>{t(this.topicMap.topics.includes(e)||this.pending.has(e)||this.cached.some(t=>t.topic===e))})),cR(this,"on",(e,t)=>{this.events.on(e,t)}),cR(this,"once",(e,t)=>{this.events.once(e,t)}),cR(this,"off",(e,t)=>{this.events.off(e,t)}),cR(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),cR(this,"start",async()=>{await this.onConnect()}),cR(this,"stop",async()=>{await this.onDisconnect()}),cR(this,"restart",async()=>{await this.restore(),await this.onRestart()}),cR(this,"checkPending",async()=>{if(0===this.pending.size&&(!this.initialized||!this.relayer.connected))return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),cR(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(oL.li.pulse,async()=>{await this.checkPending()}),this.events.on(o7.created,async e=>{let t=o7.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(o7.deleted,async e=>{let t=o7.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,oW.U5)(t,this.name),this.clientId=""}get context(){return(0,oW.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let n=!1;try{n=this.getSubscription(e).topic===t}catch{}return n}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let n=this.topicMap.get(e);await Promise.all(n.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}});try{let i=oo(n);await this.restartToComplete({topic:e,id:t,relay:i}),await this.rpcUnsubscribe(e,t,i);let r=ov("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,n){var i;n&&n?.transportType!==o5.relay||await this.restartToComplete({topic:e,id:e,relay:t});let r={method:ol(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});let a=null==(i=n?.internal)?void 0:i.throwOnFailedPublish;
32try{let t=await this.getSubscriptionId(e);if(n?.transportType===o5.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(r).catch(e=>this.logger.warn(e))},(0,iM.toMiliseconds)(iM.ONE_SECOND)),t;let i=new Promise(async t=>{let n=i=>{i.topic===e&&(this.events.removeListener(o7.created,n),t(i.id))};this.events.on(o7.created,n);try{let i=await rr(new Promise((e,t)=>{this.relayer.request(r).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(o7.created,n),t(i)}catch{}}),s=await rr(i,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!s&&a)throw Error(`Subscribing to ${e} failed, please try again`);return s?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(o2.connection_stalled),a)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t={method:ol(e[0].relay.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{await await rr(new Promise(e=>{this.relayer.request(t).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(o2.connection_stalled)}}async rpcBatchFetchMessages(e){let t;if(!e.length)return;let n={method:ol(e[0].relay.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{t=await await rr(new Promise((e,t)=>{this.relayer.request(n).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(o2.connection_stalled)}return t}rpcUnsubscribe(e,t,n){let i={method:ol(n.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,t){this.setSubscription(e,cN(cO({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,cO({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,n){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,cO({},t)),this.topicMap.set(t.topic,e),this.events.emit(o7.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:t}=ow("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(o7.deleted,cN(cO({},n),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(o7.sync)}async onRestart(){if(this.cached.length){let e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let n=0;n<t;n++){let t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit(o7.resubscribed)}async restore(){try{let e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){let{message:e}=ow("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async e=>cN(cO({}
32,e),{id:await this.getSubscriptionId(e.topic)})))))}async batchFetchMessages(e){var t;if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let n=await this.rpcBatchFetchMessages(e);n&&n.messages&&(await (t=(0,iM.toMiliseconds)(iM.ONE_SECOND),new Promise(e=>setTimeout(e,t))),await this.relayer.handleBatchMessageEvents(n.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}async restartToComplete(e){this.relayer.connected||this.relayer.connecting||(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return s7(e+await this.getClientId())}}var cD=Object.defineProperty,cU=Object.getOwnPropertySymbols,cL=Object.prototype.hasOwnProperty,cF=Object.prototype.propertyIsEnumerable,cW=(e,t,n)=>t in e?cD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c$=(e,t)=>{for(var n in t||(t={}))cL.call(t,n)&&cW(e,n,t[n]);if(cU)for(var n of cU(t))cF.call(t,n)&&cW(e,n,t[n]);return e},cB=(e,t,n)=>cW(e,"symbol"!=typeof t?t+"":t,n);class cz extends o$.m5{constructor(e){super(e),cB(this,"protocol","wc"),cB(this,"version",2),cB(this,"core"),cB(this,"logger"),cB(this,"events",new iO.EventEmitter),cB(this,"provider"),cB(this,"messages"),cB(this,"subscriber"),cB(this,"publisher"),cB(this,"name","relayer"),cB(this,"transportExplicitlyClosed",!1),cB(this,"initialized",!1),cB(this,"connectionAttemptInProgress",!1),cB(this,"relayUrl"),cB(this,"projectId"),cB(this,"packageName"),cB(this,"bundleId"),cB(this,"hasExperiencedNetworkDisruption",!1),cB(this,"pingTimeout"),cB(this,"heartBeatTimeout",(0,iM.toMiliseconds)(iM.THIRTY_SECONDS+iM.FIVE_SECONDS)),cB(this,"reconnectTimeout"),cB(this,"connectPromise"),cB(this,"reconnectInProgress",!1),cB(this,"requestsInFlight",[]),cB(this,"connectTimeout",(0,iM.toMiliseconds)(15*iM.ONE_SECOND)),cB(this,"request",async e=>{var t,n;this.logger.debug("Publishing Request Payload");let i=e.id||(0,oq.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:i,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");let r=`${i}:${(null==(n=e.params)?void 0:n.tag)||""}`;this.requestsInFlight.push(r);let a=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==r),a}catch(e){throw this.logger.debug(`Failed to Publish Request: ${i}`),e}}),cB(this,"resetPingTimeout",()=>{i3()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,n,i;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(i=null==(n=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:n.terminate)||i.call(n)}catch(e){this.logger.warn(e,e?.message)}},this.heartBeatTimeout))}),cB(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),cB(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \uD83D\uDEDC"),this.startPingTimeout(),this.events.emit(o2.connect)}),cB(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \uD83D\uDED1"),this.requestsInFlight=[],this.onProviderDisconnect()}),cB(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit(o2.error,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),cB(this,"registerProviderListeners",()=>{this.provider.on(o3.payload,this.onPayloadHandler),this.provider.on(o3.connect,this.onConnectHandler),this.provider.on(o3.disconnect,this.onDisconnectHandler),this.provider.on(o3.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger="u">typeof e.logger&&"string"!=typeof e.logger?(0,oW.U5)(e.logger,this.name):(0,oW.h6)((0,oW.iP)({level:e.logger||"error"})),this.messages=new cd(this.logger,e.core),this.subscriber=new cM(this,this.logger),this.publisher=new cx(this,this.logger),this.relayUrl=e?.relayUrl||o1,this.projectId=e.projectId,i4()&&"u">typeof n.g&&"u">typeof(null==n.g?void 0:n.g.Platform)&&(null==n.g?void 0:n.g.Platform.OS)==="android"?this.packageName=i8():i4()&&"u">typeof n.g&&"u">typeof(null==n.g?void 0:n.g.Platform)&&(null==n.g?void 0:n.g.Platform.OS)==="ios"&&(this.bundleId=i8()),this.provider={}}
32async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return(0,oW.oI)(this.logger)}get connected(){var e,t,n;return(null==(n=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:n.readyState)===1}get connecting(){var e,t,n;return(null==(n=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:n.readyState)===0||void 0!==this.connectPromise}async publish(e,t,n){this.isInitialized(),await this.publisher.publish(e,t,n),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:o5.relay},o6.outbound)}async subscribe(e,t){var n,i,r;this.isInitialized(),null!=t&&t.transportType&&t?.transportType!=="relay"||await this.toEstablishConnection();let a=typeof(null==(n=t?.internal)?void 0:n.throwOnFailedPublish)>"u"||(null==(i=t?.internal)?void 0:i.throwOnFailedPublish),s=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"",o,l=t=>{t.topic===e&&(this.subscriber.off(o7.created,l),o())};return await Promise.all([new Promise(e=>{o=e,this.subscriber.on(o7.created,l)}),new Promise(async(n,i)=>{s=await this.subscriber.subscribe(e,c$({internal:{throwOnFailedPublish:a}},t)).catch(e=>{a&&i(e)})||s,n()})]),s}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await rr(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics)return void this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,n)=>{await this.connect(e).then(t).catch(n).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await oR())throw Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0)return void this.logger.trace("Batch message events is empty. Ignoring...");let t=e.sort((e,t)=>e.publishedAt-t.publishedAt);for(let e of(this.logger.debug(`Batch of ${t.length} message events sorted`),t))try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:n}=e;if(!t.sessionExists){let e=ro(iM.FIVE_MINUTES);await this.core.pairing.pairings.set(n,{topic:n,expiry:e,relay:{protocol:"irn"},active:!1})}this.events.emit(o2.message,e),await this.recordMessageEvent(e,o6.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(e,t)=>{let n=()=>
32{t(Error("Connection interrupted while trying to subscribe"))};this.provider.once(o3.disconnect,n),await rr(new Promise((e,t)=>{this.provider.connect().then(e).catch(t)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(e=>{t(e)}).finally(()=>{this.provider.off(o3.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,t)=>{let n=()=>{t(Error("Connection interrupted while trying to subscribe"))};this.provider.once(o3.disconnect,n),await this.subscriber.start().then(e).catch(t).finally(()=>{this.provider.off(o3.disconnect,n)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop(),this.logger.warn({},e.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(e=>setTimeout(e,(0,iM.toMiliseconds)(+t))),t++}}startPingTimeout(){var e,t,n,i,r;if(i3())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(r=null==(i=null==(n=this.provider)?void 0:n.connection)?void 0:i.socket)||r.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new oz.F(new oV.A(function({protocol:e,version:t,relayUrl:n,sdkVersion:i,auth:r,projectId:a,useOnCloseEvent:s,bundleId:o,packageName:l}){let c=n.split("?"),d=i9(e,t,i),u=function(e,t){let n=new URLSearchParams(e);for(let e of Object.keys(t).sort())if(t.hasOwnProperty(e)){let i=t[e];void 0!==i&&n.set(e,i)}return n.toString()}(c[1]||"",{auth:r,ua:d,projectId:a,useOnCloseEvent:s||void 0,packageName:l||void 0,bundleId:o||void 0});return c[0]+"?"+u}({sdkVersion:o4,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,t){let{topic:n,message:i}=e;await this.messages.set(n,i,t)}async shouldIgnoreMessageEvent(e){let{topic:t,message:n}=e;if(!n||0===n.length)return this.logger.warn(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn(`Ignoring message for unknown topic ${t}`),!0;let i=this.messages.has(t,n);return i&&this.logger.warn(`Ignoring duplicate message: ${n}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,oq.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;let t=e.params,{topic:n,message:i,publishedAt:r,attestation:a}=t.data,s={topic:n,message:i,publishedAt:r,transportType:o5.relay,attestation:a};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(c$({type:"event",event:t.id},s)),this.events.emit(t.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}else(0,oq.isJsonRpcResponse)(e)&&this.events.emit(o2.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,o6.inbound),this.events.emit(o2.message,e))}async acknowledgePayload(e){let t=(0,oq.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(o3.payload,this.onPayloadHandler),this.provider.off(o3.connect,this.onConnectHandler),this.provider.off(o3.disconnect,this.onDisconnectHandler),this.provider.off(o3.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await oR();var t,i,r=async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,e?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))};switch(i6()){case i2.browser:t=r,!i4()&&i5()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)));break;case i2.reactNative:i=r,i4()&&"u">typeof n.g&&null!=n.g&&n.g.NetInfo&&n.g?.NetInfo.addEventListener(e=>i(e?.isConnected));case i2.node:}}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(o2.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,iM.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),this.connected||await this.connect()}}function cq(){}function cV(e){if(!e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function cH(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}
32function cG(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}let cK="[object Arguments]",cJ="[object Object]";var cZ=Object.defineProperty,cY=Object.getOwnPropertySymbols,cQ=Object.prototype.hasOwnProperty,cX=Object.prototype.propertyIsEnumerable,c0=(e,t,n)=>t in e?cZ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c1=(e,t)=>{for(var n in t||(t={}))cQ.call(t,n)&&c0(e,n,t[n]);if(cY)for(var n of cY(t))cX.call(t,n)&&c0(e,n,t[n]);return e},c2=(e,t,n)=>c0(e,"symbol"!=typeof t?t+"":t,n);class c3 extends o$.pi{constructor(e,t,n,i=oJ,r){super(e,t,n,i),this.core=e,this.logger=t,this.name=n,c2(this,"map",new Map),c2(this,"version","0.3"),c2(this,"cached",[]),c2(this,"initialized",!1),c2(this,"getKey"),c2(this,"storagePrefix",oJ),c2(this,"recentlyDeleted",[]),c2(this,"recentlyDeletedLimit",200),c2(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{this.getKey&&null!==e&&!o_(e)?this.map.set(this.getKey(e),e):function(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}(e)?this.map.set(e.id,e):e?.topic&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),c2(this,"set",async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())}),c2(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),c2(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(n=>{var i;return i=t[n],function e(t,n,i,r,a,s,o){let l=o(t,n,i,r,a,s);if(void 0!==l)return l;if(typeof t==typeof n)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return t===n;case"number":return t===n||Object.is(t,n)}return function t(n,i,r,a){if(Object.is(n,i))return!0;let s=cG(n),o=cG(i);if(s===cK&&(s=cJ),o===cK&&(o=cJ),s!==o)return!1;switch(s){case"[object String]":return n.toString()===i.toString();case"[object Number]":{let e=n.valueOf(),t=i.valueOf();return e===t||Number.isNaN(e)&&Number.isNaN(t)}case"[object Boolean]":case"[object Date]":case"[object Symbol]":return Object.is(n.valueOf(),i.valueOf());case"[object RegExp]":return n.source===i.source&&n.flags===i.flags;case"[object Function]":return n===i}let l=(r=r??new Map).get(n),c=r.get(i);if(null!=l&&null!=c)return l===i;r.set(n,i),r.set(i,n);try{switch(s){case"[object Map]":if(n.size!==i.size)return!1;for(let[t,s]of n.entries())if(!i.has(t)||!e(s,i.get(t),t,n,i,r,a))return!1;return!0;case"[object Set]":{if(n.size!==i.size)return!1;let t=Array.from(n.values()),s=Array.from(i.values());for(let o=0;o<t.length;o++){let l=t[o],c=s.findIndex(t=>e(l,t,void 0,n,i,r,a));if(-1===c)return!1;s.splice(c,1)}return!0}case"[object Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":case"[object BigUint64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object BigInt64Array]":case"[object Float32Array]":case"[object Float64Array]":if("u">typeof oH&&oH.isBuffer(n)!==oH.isBuffer(i)||n.length!==i.length)return!1;for(let t=0;t<n.length;t++)if(!e(n[t],i[t],t,n,i,r,a))return!1;return!0;case"[object ArrayBuffer]":return n.byteLength===i.byteLength&&t(new Uint8Array(n),new Uint8Array(i),r,a);case"[object DataView]":return n.byteLength===i.byteLength&&n.byteOffset===i.byteOffset&&t(new Uint8Array(n),new Uint8Array(i),r,a);case"[object Error]":return n.name===i.name&&n.message===i.message;case cJ:{if(!(t(n.constructor,i.constructor,r,a)||cV(n)&&cV(i)))return!1;let s=[...Object.keys(n),...cH(n)],o=[...Object.keys(i),...cH(i)];if(s.length!==o.length)return!1;for(let t=0;t<s.length;t++){let o=s[t],l=n[o];if(!Object.hasOwn(i,o))return!1;let c=i[o];if(!e(l,c,o,n,i,r,a))return!1}return!0}default:return!1}}finally{r.delete(n),r.delete(i)}}(t,n,s,o)}(i,e[n],void 0,void 0,void 0,void 0,cq)})):this.values)),c2(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});let n=c1(c1({},this.getData(e)),t);this.map.set(e,n),await this.persist()}),c2(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",ke
32y:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,oW.U5)(t,this.name),this.storagePrefix=i,this.getKey=r}get context(){return(0,oW.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:t}=ow("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),Error(t)}let{message:t}=ow("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:e}=ow("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}}var c4=Object.defineProperty,c5=(e,t,n)=>((e,t,n)=>t in e?c4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class c6{constructor(e,t){this.core=e,this.logger=t,c5(this,"name","pairing"),c5(this,"version","0.3"),c5(this,"events",new(iN())),c5(this,"pairings"),c5(this,"initialized",!1),c5(this,"storagePrefix",oJ),c5(this,"ignoredPayloadTypes",[1]),c5(this,"registeredMethods",[]),c5(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),c5(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),c5(this,"create",async e=>{this.isInitialized();let t=s6(),n=await this.core.crypto.setSymKey(t),i=ro(iM.FIVE_MINUTES),r={protocol:"irn"},a={topic:n,expiry:i,relay:r,active:!1,methods:e?.methods},s=od({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:t,relay:r,expiryTimestamp:i,methods:e?.methods});return this.events.emit(le.create,a),this.core.expirer.set(n,i),await this.pairings.set(n,a),await this.core.relayer.subscribe(n,{transportType:e?.transportType}),{topic:n,uri:s}}),c5(this,"pair",async e=>{let t;this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[ls.pairing_started]}});this.isValidPair(e,n);let{topic:i,symKey:r,relay:a,expiryTimestamp:s,methods:o}=oc(e.uri);if(n.props.properties.topic=i,n.addTrace(ls.pairing_uri_validation_success),n.addTrace(ls.pairing_uri_not_expired),this.pairings.keys.includes(i)){if(t=this.pairings.get(i),n.addTrace(ls.existing_pairing),t.active)throw n.setError(lo.active_pairing_already_exists),Error(`Pairing already exists: ${i}. Please try again with a new connection URI.`);n.addTrace(ls.pairing_not_expired)}let l=s||ro(iM.FIVE_MINUTES),c={topic:i,relay:a,expiry:l,active:!1,methods:o};this.core.expirer.set(i,l),await this.pairings.set(i,c),n.addTrace(ls.store_new_pairing),e.activatePairing&&await this.activate({topic:i}),this.events.emit(le.create,c),n.addTrace(ls.emit_inactive_pairing),this.core.crypto.keychain.has(i)||await this.core.crypto.setSymKey(r,i),n.addTrace(ls.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(lo.no_internet_connection)}try{await this.core.relayer.subscribe(i,{relay:a})}catch(e){throw n.setError(lo.subscribe_pairing_topic_failure),e}return n.addTrace(ls.subscribe_pairing_topic_success),c}),c5(this,"activate",async({topic:e})=>{this.isInitialized();let t=ro(iM.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),c5(this,"ping",async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");let{topic:t}=e;if(this.pairings.keys.includes(t)){let e=await this.sendRequest(t,"wc_pairingPing",{}),{done:n,resolve:i,reject:r}=ri();this.events.once(rc("pairing_ping",e),({error:e})=>{e?r(e):i()}),await n()}}),c5(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),c5(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),c5(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),c5(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);let{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",ov("USER_DISCONNECTED")),await this.deletePairing(t))}),c5(this,"formatUriFromPairing",e=>{this.isInitialized();let{topic:t,relay:n,expiry:i,methods:r}=e,a=this.core.crypto.keychain.get(t);return od({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:a,relay:n,expiryTimestamp:i,methods:r})}),c5(this,"sendRequest",async(e,t,n)=>{let i=(0,oq.formatJsonRpcRequest)(t,n),r=await this.core.crypto.encode(e,i),a=o9[t].req;return this.core.history.set(e,i),this.core.relayer.publish(e,r,a),i.id}),c5(this,"sendResult",async(e,t,n)=>{let i=(0,oq.formatJsonRpcResult)(e,n),r=await this.core.crypto.encode(t,i),a=o9[(await this.core.history.get(t,e)).request.method].res;await this.core.relayer.publish(t,r,a),await this.core.history.resolve(i)}),c5(this,"sendError",async(e,t,n)=>{let i=(0,oq.formatJsonRpcError)(e,n),r=await this.core.crypto.encode(t,i),a=(await this.core.history.get(t,e)).request.method,s=o9[a]?o9[a].res:o9.unregistered_method.res;await this.core.relayer.publish(t,r,s),await this.core.history.resolve(i)}),c5(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,ov("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),c5(this,"cleanup",async()=>{let e=this.pairings.getAll().filter(e=>rl(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),c5(this,"onRelayEventRequest",async e=>{let{topic:t,payload:n}=e;switch(n.method){case"wc_pairingPing":return await this.onPairingPingRequest(t,n);case"wc_pairingDelete":return await this.onPairingDeleteRequest(t,n);default:return await this.onUnknownRpcMethodRequest(t,n)}}),c5(this,"onRelayEventResponse",async e=>{let{topic:t,payload:n}=e,i=(await this.core.history.get(t,n.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(t,n):this.onUnknownRpcMethodResponse(i)}),c5(this,"onPairingPingRequest",async(e,t)=>{let{id:n}=t;try{this.isValidPing({topic:e}),await this.sendResult(n,e,!0),this.events.emit(le.ping,{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.logger.error(t)}}),c5(this,"onPairingPingResponse",(e,t)=>{let{id:n}=t;setTimeout(()=>{(0,oq.isJsonRpcResult)(t)?this.events.emit(rc("pairing_ping",n),{}):(0,oq.isJsonRpcError)(t)&&this.events.emit(rc("pairing_ping",n),{error:t.error})},500)}),c5(this,"onPairingDeleteRequest",async(e,t)=>{let{id:n}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit(le.delete,{id:n,topic:e})}catch(t){await this.sendError(n,e,t),this.logger.error(t)}}),c5(this,"onUnknownRpcMethodRequest",async(e,t)=>{let{id:n,method:i}=t;try{if(this.registeredMethods.includes(i))return;let t=ov("WC_METHOD_UNSUPPORTED",i);await this.sendError(n,e,t),this.logger.error(t)}catch(t){await this.sendError(n,e,t),this.logger.error(t)}}),c5(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error(ov("WC_METHOD_UNSUPPORTED",e))}),c5(this,"isValidPair",(e,t)=>{var n;if(!oP(e)){let{message:n}=ow("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(lo.malformed_pairing_uri),Error(n)}if(!function(e){function t(e){try{return"u">typeof new URL(e)}catch{return!1}}try{if(oC(e,!1)){if(t(e))return!0;let n=rf(e);return t(n)}}catch{}return!1}(e.uri)){let{message:n}=ow("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(lo.malformed_pairing_uri),Error(n)}let i=oc(e?.uri);if(!(null!=(n=i?.relay)&&n.protocol)){let{message:e}=ow("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(lo.malformed_pairing_uri),Error(e)}if(!(null!=i&&i.symKey)){let{message:e}=ow("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(lo.malformed_pairing_uri),Error(e)}if(null!=i&&i.expiryTimestamp&&(0,iM.toMiliseconds)(i?.expiryTimestamp)<Date.now()){t.setError(lo.pairing_expired);let{message:e}=ow("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw Error(e)}}),c5(this,"isValidPing",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`ping() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidPairingTopic(t)}),c5(this,"isValidDisconnect",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidPairingTopic(t)}),c5(this,"isValidPairingTopic",async e=>{if(!oC(e,!1)){let{message:t}=ow("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw Error(t)}if(!this.pairings.keys.includes(e)){let{message:t}=ow("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw Error(t)}if(rl(this.pairings.get(e).expiry)){await this.deletePairing(e);let{message:t}=ow("EXPIRED",`pairing topic: ${e}`);throw Error(t)}}),this.core=e,this.logger=(0,oW.U5)(t,this.name),this.pairings=new c3(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,oW.oI)(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}registerRelayerEvents(){this.core.relayer.on(o2.message,async e=>{let{topic:t,message:n,transportType:i}=e;if(this.pairings.keys.includes(t)&&i!==o5.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))try{let e=await this.core.crypto.decode(t,n);(0,oq.isJsonRpcRequest)(e)?(this.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e})):(0,oq.isJsonRpcResponse)(e)&&(await this.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e}),this.core.history.delete(t,e.id)),await this.core.relayer.messages.ack(t,n)}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(ln.expired,async e=>{let{topic:t}=rs(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(le.expire,{topic:t}))})}}var c8=Object.defineProperty,c7=(e,t,n)=>((e,t,n)=>t in e?c8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class c9 extends o$.lZ{constructor(e,t){super(e,t),this.core=e,this.logger=t,c7(this,"records",new Map),c7(this,"events",new iO.EventEmitter),c7(this,"name","history"),c7(this,"version","0.3"),c7(this,"cac
32hed",[]),c7(this,"initialized",!1),c7(this,"storagePrefix",oJ),c7(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.records.set(e.id,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),c7(this,"set",(e,t,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:n}),this.records.has(t.id))return;let i={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:n,expiry:ro(iM.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit(lt.created,i)}),c7(this,"resolve",async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;let t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,oq.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(lt.updated,t))}),c7(this,"get",async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t))),c7(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(n=>{n.topic===e&&("u">typeof t&&n.id!==t||(this.records.delete(n.id),this.events.emit(lt.deleted,n)))}),this.persist()}),c7(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),c7(this,"on",(e,t)=>{this.events.on(e,t)}),c7(this,"once",(e,t)=>{this.events.once(e,t)}),c7(this,"off",(e,t)=>{this.events.off(e,t)}),c7(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,oW.U5)(t,this.name)}get context(){return(0,oW.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if("u">typeof t.response)return;let n={topic:t.topic,request:(0,oq.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(n)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:t}=ow("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(lt.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:e}=ow("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(lt.created,e=>{let t=lt.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(lt.updated,e=>{let t=lt.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(lt.deleted,e=>{let t=lt.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(oL.li.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,iM.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(lt.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}}
32var de=Object.defineProperty,dt=(e,t,n)=>((e,t,n)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class dn extends o$.Vx{constructor(e,t){super(e,t),this.core=e,this.logger=t,dt(this,"expirations",new Map),dt(this,"events",new iO.EventEmitter),dt(this,"name","expirer"),dt(this,"version","0.3"),dt(this,"cached",[]),dt(this,"initialized",!1),dt(this,"storagePrefix",oJ),dt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.expirations.set(e.target,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),dt(this,"has",e=>{try{let t=this.formatTarget(e);return"u">typeof this.getExpiration(t)}catch{return!1}}),dt(this,"set",(e,t)=>{this.isInitialized();let n=this.formatTarget(e),i={target:n,expiry:t};this.expirations.set(n,i),this.checkExpiry(n,i),this.events.emit(ln.created,{target:n,expiration:i})}),dt(this,"get",e=>{this.isInitialized();let t=this.formatTarget(e);return this.getExpiration(t)}),dt(this,"del",e=>{if(this.isInitialized(),this.has(e)){let t=this.formatTarget(e),n=this.getExpiration(t);this.expirations.delete(t),this.events.emit(ln.deleted,{target:t,expiration:n})}}),dt(this,"on",(e,t)=>{this.events.on(e,t)}),dt(this,"once",(e,t)=>{this.events.once(e,t)}),dt(this,"off",(e,t)=>{this.events.off(e,t)}),dt(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,oW.U5)(t,this.name)}get context(){return(0,oW.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return ra("topic",e);if("number"==typeof e)return ra("id",e);let{message:t}=ow("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(ln.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:e}=ow("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:t}=ow("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),Error(t)}return t}checkExpiry(e,t){let{expiry:n}=t;(0,iM.toMiliseconds)(n)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(ln.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(oL.li.pulse,()=>this.checkExpirations()),this.events.on(ln.created,e=>{let t=ln.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(ln.expired,e=>{let t=ln.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(ln.deleted,e=>{let t=ln.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}}var di=Object.defineProperty,dr=(e,t,n)=>((e,t,n)=>t in e?di(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class da extends o$.zl{constructor(e,t,n){super(e,t,n),this.core=e,this.logger=t,this.store=n,dr(this,"name","verify-api"),dr(this,"abortController"),dr(this,"isDevEnv"),dr(this,"verifyUrlV3",lr),dr(this,"storagePrefix",oJ),dr(this,"version",2),dr(this,"publicKey"),dr(this,"fetchPromise"),dr(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,iM.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),dr(this,"register",async e=>{if(!i5()||this.isDevEnv)return;let t=window.location.origin,{id:n,decryptedId:i}=e,r=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${n}&decryptedId=${i}`;try{let e=(0,iD.getDocument)(),t=this.startAbortTimer(5*iM.ONE_SECOND),i=await new Promise((i,a)=>{let s=()=>{window.removeEventListener("message",l),e.body.removeChild(o),a("attestation aborted")};this.abortController.signal.addEventListener("abort",s);let o=e.createElement("iframe");o.src=r,o.style.display="none",o.addEventListener("error",s,{signal:this.abortController.signal});let l=r=>{if(r.data&&"string"==typeof r.data)try{let a=JSON.parse(r.data);if("verify_attestation"===a.type){if((0,iW.Cq)(a.attestation).payload.id!==n)return;clearInterval(t),e.body.removeChild(o),this.abortController.signal.removeEventListener("abort",s),window.removeEventListener("message",l),i(null===a.attestation?"":a.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(o),window.addEventListener("message",l,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",i),i}catch(e){this.logger.warn(e)}return""}),dr(this,"resolve",async e=>{if(this.isDevEnv)return"";let{attestationId:t,hash:n,encryptedId:i}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,iW.Cq)(t).payload.id!==i)return;let e=await this.isValidJwtAttestation(t);
32if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!n)return;let r=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(n,r)}),dr(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);let n=this.startAbortTimer(5*iM.ONE_SECOND),i=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(n),200===i.status?await i.json():void 0}),dr(this,"getVerifyUrl",e=>{let t=e||li;return la.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${li}`),t=li),t}),dr(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let e=this.startAbortTimer(iM.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),dr(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),dr(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),dr(this,"isValidJwtAttestation",async e=>{let t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}let n=await this.fetchAndPersistPublicKey();try{if(n)return this.validateAttestation(e,n)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),dr(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),dr(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{let t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});let e=await this.fetchPromise;return this.fetchPromise=void 0,e}),dr(this,"validateAttestation",(e,t)=>{let n=function(e,t){let[n,i,r]=e.split("."),a=iq.from(on(r),"base64");if(64!==a.length)throw Error("Invalid signature length");let s=a.slice(0,32),o=a.slice(32,64),l=aq(`${n}.${i}`),c=function(e){let t=iq.from(e.x,"base64"),n=iq.from(e.y,"base64");return(0,i$.xW)([new Uint8Array([4]),t,n])}(t);if(!s0.verify((0,i$.xW)([s,o]),l,c))throw Error("Invalid signature");return(0,iW.Cq)(e).payload}(e,t.publicKey),i={hasExpired:(0,iM.toMiliseconds)(n.exp)<Date.now(),payload:n};if(i.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),Error("JWT attestation expired");return{origin:i.payload.origin,isScam:i.payload.isScam,isVerified:i.payload.isVerified}}),this.logger=(0,oW.U5)(t,this.name),this.abortController=new AbortController,this.isDevEnv=ry(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,oW.oI)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,iM.toMiliseconds)(e))}}var ds=Object.defineProperty,dl=(e,t,n)=>((e,t,n)=>t in e?ds(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class dc extends o$.GF{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,dl(this,"context","echo"),dl(this,"registerDeviceToken",async e=>{let{clientId:t,token:n,notificationType:i,enableEncrypted:r=!1}=e,a=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:i,token:n,always_raw:r})})}),this.logger=(0,oW.U5)(t,this.context)}}var dd=Object.defineProperty,du=Object.getOwnPropertySymbols,dh=Object.prototype.hasOwnProperty,dp=Object.prototype.propertyIsEnumerable,dm=(e,t,n)=>t in e?dd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dy=(e,t)=>{for(var n in t||(t={}))dh.call(t,n)&&dm(e,n,t[n]);if(du)for(var n of du(t))dp.call(t,n)&&dm(e,n,t[n]);return e}
32,df=(e,t,n)=>dm(e,"symbol"!=typeof t?t+"":t,n);class dg extends o$.$Q{constructor(e,t,n=!0){super(e,t,n),this.core=e,this.logger=t,df(this,"context","event-client"),df(this,"storagePrefix",oJ),df(this,"storageVersion",.1),df(this,"events",new Map),df(this,"shouldPersist",!1),df(this,"init",async()=>{if(!ry())try{let e={eventId:rm(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:i9(this.core.relayer.protocol,this.core.relayer.version,o4)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),df(this,"createEvent",e=>{let{event:t="ERROR",type:n="",properties:{topic:i,trace:r}}=e,a=rm(),s=this.core.projectId||"",o=dy({eventId:a,timestamp:Date.now(),props:{event:t,type:n,properties:{topic:i,trace:r}},bundleId:s,domain:this.getAppDomain()},this.setMethods(a));return this.telemetryEnabled&&(this.events.set(a,o),this.shouldPersist=!0),o}),df(this,"getEvent",e=>{let{eventId:t,topic:n}=e;if(t)return this.events.get(t);let i=Array.from(this.events.values()).find(e=>e.props.properties.topic===n);if(i)return dy(dy({},i),this.setMethods(i.eventId))}),df(this,"deleteEvent",e=>{let{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),df(this,"setEventListeners",()=>{this.core.heartbeat.on(oL.li.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,iM.fromMiliseconds)(Date.now())-(0,iM.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),df(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),df(this,"addTrace",(e,t)=>{let n=this.events.get(e);n&&(n.props.properties.trace.push(t),this.events.set(e,n),this.shouldPersist=!0)}),df(this,"setError",(e,t)=>{let n=this.events.get(e);n&&(n.props.type=t,n.timestamp=Date.now(),this.events.set(e,n),this.shouldPersist=!0)}),df(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),df(this,"restore",async()=>{try{let e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,dy(dy({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),df(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;let e=[];for(let[t,n]of this.events)n.props.type&&e.push(n);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(let t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),df(this,"sendEvent",async e=>{let t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${o4}${t}`,{method:"POST",body:JSON.stringify(e)})}),df(this,"getAppDomain",()=>i7().url),this.logger=(0,oW.U5)(t,this.context),this.telemetryEnabled=n,n?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var dw=Object.defineProperty,dv=Object.getOwnPropertySymbols,db=Object.prototype.hasOwnProperty,dx=Object.prototype.propertyIsEnumerable,d_=(e,t,n)=>t in e?dw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dC=(e,t)=>{for(var n in t||(t={}))db.call(t,n)&&d_(e,n,t[n]);if(dv)for(var n of dv(t))dx.call(t,n)&&d_(e,n,t[n]);return e},dI=(e,t,n)=>d_(e,"symbol"!=typeof t?t+"":t,n);class dE extends o$.ZP{constructor(e){var t;super(e),dI(this,"protocol","wc"),dI(this,"version",2),dI(this,"name",oK),dI(this,"relayUrl"),dI(this,"projectId"),dI(this,"customStoragePrefix"),dI(this,"events",new iO.EventEmitter),dI(this,"logger"),dI(this,"heartbeat"),dI(this,"relayer"),dI(this,"crypto"),dI(this,"storage"),dI(this,"history"),dI(this,"expirer"),dI(this,"pairing"),dI(this,"verify"),dI(this,"echoClient"),dI(this,"linkModeSupportedApps"),dI(this,"eventClient"),dI(this,"initialized",!1),dI(this,"logChunkController"),dI(this,"on",(e,t)=>this.events.on(e,t)),dI(this,"once",(e,t)=>this.events.once(e,t)),dI(this,"off",(e,t)=>this.events.off(e,t)),dI(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),dI(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:n})=>{if(!e||!t)return;let i={topic:e,message:t,publishedAt:Date.now(),transportType:o5.link_mode};this.relayer.onLinkMessageEvent(i,{sessionExists:n})});let n=this.getGlobalCore(e?.customStoragePrefix);if(n)try{return this.customStoragePrefix=n.customStoragePrefix,this.logger=n.logger,this.heartbeat=n.heartbeat,this.crypto=n.crypto,this.history=n.history,this.expirer=n.expirer,this.storage=n.storage,this.relayer=n.relayer,this.pairing=n.pairing,this.verify=n.verify,this.echoClient=n.echoClient,this.linkModeSupportedApps=n.linkModeSupportedApps,this.eventClient=n.eventClient,this.initialized=n.initialized,this.logChunkController=n.logChunkController,n}catch(e){console.warn("Failed to copy global core",e)}this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||o1,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=(0,oW.iP)({level:"string"==typeof e?.logger&&e.logger?e.logger:oZ.logger,name:oK}),{logger:r,chunkLoggerController:a}=(0,oW.D5)({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=a,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,oW.U5)(r,this.name),this.heartbeat=new oL.VH,this.crypto=new ct(this,this.logger,e?.keychain),this.history=new c9(this,this.logger),this.expirer=new dn(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new oF.A(dC(dC({},oY),e?.storageOptions)),this.relayer=new cz({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new c6(this,this.logger),this.verify=new da(this,this.logger,this.storage),this.echoClient=new dc(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new dg(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this)}static async init(e){let t=new dE(e);await t.initialize();let n=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",n),t}get context(){return(0,oW.oI)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(o8,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(
32),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(o8)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;let t=`_walletConnectCore_${e}`,n=`${t}_count`;return globalThis[n]=(globalThis[n]||0)+1,globalThis[n]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[n]} times.`),globalThis[t]}catch(e){console.warn("Failed to get global WalletConnect core",e);return}}setGlobalCore(e){var t;try{if(this.isGlobalCoreDisabled())return;let n=`_walletConnectCore_${(null==(t=e.opts)?void 0:t.customStoragePrefix)||""}`;globalThis[n]=e}catch(e){console.warn("Failed to set global WalletConnect core",e)}}isGlobalCoreDisabled(){try{return"u">typeof oG&&"true"===oG.env.DISABLE_GLOBAL_CORE}catch{return!0}}}let dT="client",dA=`wc@2:${dT}:`,dS={name:dT,logger:"error"},dk="WALLETCONNECT_DEEPLINK_CHOICE",dP="Proposal expired",dj=iM.SEVEN_DAYS,dO={wc_sessionPropose:{req:{ttl:iM.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:iM.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:iM.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:iM.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:iM.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:iM.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:iM.ONE_DAY,prompt:!1,tag:1104},res:{ttl:iM.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:iM.ONE_DAY,prompt:!1,tag:1106},res:{ttl:iM.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:iM.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:iM.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:iM.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:iM.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:iM.ONE_DAY,prompt:!1,tag:1112},res:{ttl:iM.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:iM.ONE_DAY,prompt:!1,tag:1114},res:{ttl:iM.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:iM.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:iM.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:iM.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:iM.FIVE_MINUTES,prompt:!1,tag:1119}}},dN={min:iM.FIVE_MINUTES,max:iM.SEVEN_DAYS},dR={idle:"IDLE",active:"ACTIVE"},dM={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},dD=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],dU="[email protected]:auth:",dL=`${dU}:PUB_KEY`;var dF=Object.defineProperty,dW=Object.defineProperties,d$=Object.getOwnPropertyDescriptors,dB=Object.getOwnPropertySymbols,dz=Object.prototype.hasOwnProperty,dq=Object.prototype.propertyIsEnumerable,dV=(e,t,n)=>t in e?dF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dH=(e,t)=>{for(var n in t||(t={}))dz.call(t,n)&&dV(e,n,t[n]);if(dB)for(var n of dB(t))dq.call(t,n)&&dV(e,n,t[n]);return e},dG=(e,t)=>
32dW(e,d$(t)),dK=(e,t,n)=>dV(e,"symbol"!=typeof t?t+"":t,n);class dJ extends o$.yJ{constructor(e){super(e),dK(this,"name","engine"),dK(this,"events",new(iN())),dK(this,"initialized",!1),dK(this,"requestQueue",{state:dR.idle,queue:[]}),dK(this,"sessionRequestQueue",{state:dR.idle,queue:[]}),dK(this,"requestQueueDelay",iM.ONE_SECOND),dK(this,"expectedPairingMethodMap",new Map),dK(this,"recentlyDeletedMap",new Map),dK(this,"recentlyDeletedLimit",200),dK(this,"relayMessageCache",[]),dK(this,"pendingSessions",new Map),dK(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(dO)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,iM.toMiliseconds)(this.requestQueueDelay)))}),dK(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let t=dG(dH({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);let{pairingTopic:n,requiredNamespaces:i,optionalNamespaces:r,sessionProperties:a,scopedProperties:s,relays:o}=t,l=n,c,d=!1;try{if(l){let e=this.client.core.pairing.pairings.get(l);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),d=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),e}if(!l||!d){let{topic:e,uri:t}=await this.client.core.pairing.create();l=e,c=t}if(!l){let{message:e}=ow("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw Error(e)}let u=await this.client.core.crypto.generateKeyPair(),h=dO.wc_sessionPropose.req.ttl||iM.FIVE_MINUTES,p=ro(h),m=dG(dH(dH({requiredNamespaces:i,optionalNamespaces:r,relays:o??[{protocol:"irn"}],proposer:{publicKey:u,metadata:this.client.metadata},expiryTimestamp:p,pairingTopic:l},a&&{sessionProperties:a}),s&&{scopedProperties:s}),{id:(0,oq.payloadId)()}),y=rc("session_connect",m.id),{reject:f,resolve:g,done:w}=ri(h,dP),v=({id:e})=>{e===m.id&&(this.client.events.off("proposal_expire",v),this.pendingSessions.delete(m.id),this.events.emit(y,{error:{message:dP,code:0}}))};return this.client.events.on("proposal_expire",v),this.events.once(y,({error:e,session:t})=>{this.client.events.off("proposal_expire",v),e?f(e):t&&g(t)}),await this.sendRequest({topic:l,method:"wc_sessionPropose",params:m,throwOnFailedPublish:!0,clientRpcId:m.id}),await this.setProposal(m.id,m),{uri:c,approval:w}}),dK(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}}),dK(this,"approve",async e=>{var t,n,i;let r=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[ll.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw r.setError(lc.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),r.setError(lc.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),r.setError(lc.session_approve_namespace_validation_failure),e}let{id:a,relayProtocol:s,namespaces:o,sessionProperties:l,scopedProperties:c,sessionConfig:d}=e,u=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:r.eventId});let{pairingTopic:h,proposer:p,requiredNamespaces:m,optionalNamespaces:y}=u,f=null==(n=this.client.core.eventClient)?void 0:n.getEvent({topic:h});f||(f=null==(i=this.client.core.eventClient)?void 0:i.createEvent({type:ll.session_approve_started,properties:{topic:h,trace:[ll.session_approve_started,ll.session_namespaces_validation_success]}}));let g=await this.client.core.crypto.generateKeyPair(),w=p.publicKey,v=await this.client.core.crypto.generateSharedKey(g,w),b=dH(dH(dH({relay:{protocol:s??"irn"},namespaces:o,controller:{publicKey:g,metadata:this.client.metadata},expiry:ro(dj)},l&&{sessionProperties:l}),c&&{scopedProperties:c}),d&&{sessionConfig:d}),x=o5.relay;f.addTrace(ll.subscribing_session_topic);try{await this.client.core.relayer.subscribe(v,{transportType:x})}catch(e){throw f.setError(lc.subscribe_session_topic_failure),e}f.addTrace(ll.subscribe_session_topic_success);let _=dG(dH({},b),{topic:v,requiredNamespaces:m,optionalNamespaces:y,pairingTopic:h,acknowledged:!1,self:b.controller,peer:{publicKey:p.publicKey,metadata:p.metadata},controller:g,transportType:o5.relay});await this.client.session.set(v,_),f.addTrace(ll.store_session);try{f.addTrace(ll.publishing_session_settle),await this.sendRequest({topic:v,method:"wc_sessionSettle",params:b,throwOnFailedPublish:!0}).catch(e=>{throw f?.setError(lc.session_settle_publish_failure),e}),f.addTrace(ll.session_settle_publish_success),f.addTrace(ll.publishing_session_approve),await this.sendResult({id:a,topic:h,result:{relay:{protocol:s??"irn"},responderPublicKey:g},throwOnFailedPublish:!0}).catch(e=>{throw f?.setError(lc.session_approve_publish_failure),e}),f.addTrace(ll.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(v,ov("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(v),e}return this.client.core.eventClient.deleteEvent({eventId:f.eventId}),await this.client.core.pairing.updateMetadata({topic:h,metadata:p.metadata}),await this.client.proposal.delete(a,ov("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:h}),await this.setExpiry(v,ro(dj)),{topic:v,acknowledged:()=>Promise.resolve(this.client.session.get(v))}}),dK(this,"reject",async e=>{let t;this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}let{id:n,reason:i}=e;try{t=this.client.proposal.get(n).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${n}) failed`),e}
32t&&(await this.sendError({id:n,topic:t,error:i,rpcOpts:dO.wc_sessionPropose.reject}),await this.client.proposal.delete(n,ov("USER_DISCONNECTED")))}),dK(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}let{topic:t,namespaces:n}=e,{done:i,resolve:r,reject:a}=ri(),s=(0,oq.payloadId)(),o=(0,oq.getBigIntRpcId)().toString(),l=this.client.session.get(t).namespaces;return this.events.once(rc("session_update",s),({error:e})=>{e?a(e):r()}),await this.client.session.update(t,{namespaces:n}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:o}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:l}),a(e)}),{acknowledged:i}}),dK(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}let{topic:t}=e,n=(0,oq.payloadId)(),{done:i,resolve:r,reject:a}=ri();return this.events.once(rc("session_extend",n),({error:e})=>{e?a(e):r()}),await this.setExpiry(t,ro(dj)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(e=>{a(e)}),{acknowledged:i}}),dK(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}let{chainId:t,request:n,topic:i,expiry:r=dO.wc_sessionRequest.req.ttl}=e,a=this.client.session.get(i);a?.transportType===o5.relay&&await this.confirmOnlineStateOrThrow();let s=(0,oq.payloadId)(),o=(0,oq.getBigIntRpcId)().toString(),{done:l,resolve:c,reject:d}=ri(r,"Request expired. Please try again.");this.events.once(rc("session_request",s),({error:e,result:t})=>{e?d(e):c(t)});let u="wc_sessionRequest",h=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(h)return await this.sendRequest({clientRpcId:s,relayRpcId:o,topic:i,method:u,params:{request:dG(dH({},n),{expiryTimestamp:ro(r)}),chainId:t},expiry:r,throwOnFailedPublish:!0,appLink:h}).catch(e=>d(e)),this.client.events.emit("session_request_sent",{topic:i,request:n,chainId:t,id:s}),await l();let p={request:dG(dH({},n),{expiryTimestamp:ro(r)}),chainId:t},m=this.shouldSetTVF(u,p);return await Promise.all([new Promise(async e=>{await this.sendRequest(dH({clientRpcId:s,relayRpcId:o,topic:i,method:u,params:p,expiry:r,throwOnFailedPublish:!0},m&&{tvf:this.getTVFParams(s,p)})).catch(e=>d(e)),this.client.events.emit("session_request_sent",{topic:i,request:n,chainId:t,id:s}),e()}),new Promise(async e=>{var t;if(!(null!=(t=a.sessionConfig)&&t.disableDeepLink)){let e=await rh(this.client.core.storage,dk);await ru({id:s,topic:i,wcDeepLink:e})}e()}),l()]).then(e=>e[2])}),dK(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);let{topic:t,response:n}=e,{id:i}=n,r=this.client.session.get(t);r.transportType===o5.relay&&await this.confirmOnlineStateOrThrow();let a=this.getAppLinkIfEnabled(r.peer.metadata,r.transportType);(0,oq.isJsonRpcResult)(n)?await this.sendResult({id:i,topic:t,result:n.result,throwOnFailedPublish:!0,appLink:a}):(0,oq.isJsonRpcError)(n)&&await this.sendError({id:i,topic:t,error:n.error,appLink:a}),this.cleanupAfterResponse(e)}),dK(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}let{topic:t}=e;if(this.client.session.keys.includes(t)){let e=(0,oq.payloadId)(),n=(0,oq.getBigIntRpcId)().toString(),{done:i,resolve:r,reject:a}=ri();this.events.once(rc("session_ping",e),({error:e})=>{e?a(e):r()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:n}),i()])}else this.client.core.pairing.pairings.keys.includes(t)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:t}))}),dK(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);let{topic:t,event:n,chainId:i}=e,r=(0,oq.getBigIntRpcId)().toString(),a=(0,oq.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:n,chainId:i},throwOnFailedPublish:!0,relayRpcId:r,clientRpcId:a})}),dK(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);let{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:ov("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(t))await this.client.core.pairing.disconnect({topic:t});else{let{message:e}=ow("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw Error(e)}}),dK(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(function(e,t){let{requiredNamespaces:n}=t,i=Object.keys(e.namespaces),r=Object.keys(n),a=!0;return!!re(r,i)&&(i.forEach(t=>{let{accounts:i,methods:r,events:s}=e.namespaces[t],o=oh(i),l=n[t];re(iG(t,l),o)&&re(l.methods,r)&&re(l.events,s)||(a=!1)}),a)})(t,e)))),dK(this,"getPendingSessionRequests",()=>
32this.client.pendingRequest.getAll()),dK(this,"authenticate",async(e,t)=>{var n,i,r;let a;this.isInitialized(),this.isValidAuthenticate(e);let s=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(n=this.client.metadata.redirect)?void 0:n.linkMode),o=s?o5.link_mode:o5.relay;o===o5.relay&&await this.confirmOnlineStateOrThrow();let{chains:l,statement:c="",uri:d,domain:u,nonce:h,type:p,exp:m,nbf:y,methods:f=[],expiry:g}=e,w=[...e.resources||[]],{topic:v,uri:b}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:v,uri:b}});let x=await this.client.core.crypto.generateKeyPair(),_=s8(x);if(await Promise.all([this.client.auth.authKeys.set(dL,{responseTopic:_,publicKey:x}),this.client.auth.pairingTopics.set(_,{topic:_,pairingTopic:v})]),await this.client.core.relayer.subscribe(_,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${v}`),f.length>0){let{namespace:e}=iV(l[0]),t=at(function(e,t,n,i={}){return n?.sort((e,t)=>e.localeCompare(t)),{att:{[e]:function(e,t,n={}){return Object.assign({},...(t=t?.sort((e,t)=>e.localeCompare(t))).map(t=>({[`${e}/${t}`]:[n]})))}(t,n,i)}}}(e,"request",f));aa(w)&&(i=t,r=w.pop(),t=at(function(e,t){ae(e),ae(t);let n=Object.keys(e.att).concat(Object.keys(t.att)).sort((e,t)=>e.localeCompare(t)),i={att:{}};return n.forEach(n=>{var r,a;Object.keys((null==(r=e.att)?void 0:r[n])||{}).concat(Object.keys((null==(a=t.att)?void 0:a[n])||{})).sort((e,t)=>e.localeCompare(t)).forEach(r=>{var a,s;i.att[n]=rX(((e,t)=>{for(var n in t||(t={}))r2.call(t,n)&&r4(e,n,t[n]);if(r1)for(var n of r1(t))r3.call(t,n)&&r4(e,n,t[n]);return e})({},i.att[n]),r0({[r]:(null==(a=e.att[n])?void 0:a[r])||(null==(s=t.att[n])?void 0:s[r])}))})}),i}(an(i),an(r)))),w.push(t)}let C=g&&g>dO.wc_sessionAuthenticate.req.ttl?g:dO.wc_sessionAuthenticate.req.ttl,I={authPayload:{type:p??"caip122",chains:l,statement:c,aud:d,domain:u,version:"1",nonce:h,iat:new Date().toISOString(),exp:m,nbf:y,resources:w},requester:{publicKey:x,metadata:this.client.metadata},expiryTimestamp:ro(C)},E={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:l,methods:[...new Set(["personal_sign",...f])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:v,proposer:{publicKey:x,metadata:this.client.metadata},expiryTimestamp:ro(dO.wc_sessionPropose.req.ttl),id:(0,oq.payloadId)()},{done:T,resolve:A,reject:S}=ri(C,"Request expired"),k=(0,oq.payloadId)(),P=rc("session_connect",E.id),j=rc("session_request",k),O=async({error:e,session:t})=>{this.events.off(j,N),e?S(e):t&&A({session:t})},N=async e=>{var n,i,r;let a;if(await this.deletePendingAuthRequest(k,{message:"fulfilled",code:0}),e.error){let t=ov("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(P,O),S(e.error.message))}await this.deleteProposal(E.id),this.events.off(P,O);let{cacaos:s,responder:l}=e.result,c=[],d=[];for(let e of s){await r7({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),S(ov("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:t}=e,n=aa(t.resources),i=[r6(t.iss)],r=r8(t.iss);if(n){let e=ai(n),t=ar(n);c.push(...e),i.push(...t)}for(let e of i)d.push(`${e}:${r}`)}let u=await this.client.core.crypto.generateSharedKey(x,l.publicKey);c.length>0&&(a={topic:u,acknowledged:!0,self:{publicKey:x,metadata:this.client.metadata},peer:l,controller:l.publicKey,expiry:ro(dj),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:v,namespaces:oy([...new Set(c)],[...new Set(d)]),transportType:o},await this.client.core.relayer.subscribe(u,{transportType:o}),await this.client.session.set(u,a),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:l.metadata}),a=this.client.session.get(u)),null!=(n=this.client.metadata.redirect)&&n.linkMode&&null!=(i=l.metadata.redirect)&&i.linkMode&&null!=(r=l.metadata.redirect)&&r.universal&&t&&(this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.session.update(u,{transportType:o5.link_mode})),A({auths:s,session:a})};this.events.once(P,O),this.events.once(j,N);try{if(s){let e=(0,oq.formatJsonRpcRequest)("wc_sessionAuthenticate",I,k);this.client.core.history.set(v,e);let n=await this.client.core.crypto.encode("",e,{type:2,encoding:s4});a=ou(t,v,n)}else await Promise.all([this.sendRequest({topic:v,method:"wc_sessionAuthenticate",params:I,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:k}),this.sendRequest({topic:v,method:"wc_sessionPropose",params:E,expiry:dO.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:E.id})])}catch(e){throw this.events.off(P,O),this.events.off(j,N),e}return await this.setProposal(E.id,E),await this.setAuthRequest(k,{request:dG(dH({},I),{verifyContext:{}}),pairingTopic:v,transportType:o}),{uri:a??b,response:T}}),dK(this,"approveSessionAuthenticate",async e=>{let t,{id:n,auths:i}=e,r=this.client.core.eventClient.createEvent({properties:{topic:n.toString(),trace:[ld.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw r.setError(lu.no_internet_connection),e}let a=this.getPendingAuthRequest(n);if(!a)throw r.setError(lu.authenticated_session_pending_request_not_found),Error(`Could not find pending auth request with id ${n}`);let s=a.transportType||o5.relay;s===o5.relay&&await this.confirmOnlineStateOrThrow();let o=a.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),c=s8(o),d={type:1,receiverPublicKey:o,senderPublicKey:l},u=[],h=[];for(let e of i){if(!await r7({cacao:e,projectId:this.client.core.projectId}
32)){r.setError(lu.invalid_cacao);let e=ov("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:n,topic:c,error:e,encodeOpts:d}),Error(e.message)}r.addTrace(ld.cacaos_verified);let{p:t}=e,i=aa(t.resources),a=[r6(t.iss)],s=r8(t.iss);if(i){let e=ai(i),t=ar(i);u.push(...e),a.push(...t)}for(let e of a)h.push(`${e}:${s}`)}let p=await this.client.core.crypto.generateSharedKey(l,o);if(r.addTrace(ld.create_authenticated_session_topic),u?.length>0){t={topic:p,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:o,metadata:a.requester.metadata},controller:o,expiry:ro(dj),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:a.pairingTopic,namespaces:oy([...new Set(u)],[...new Set(h)]),transportType:s},r.addTrace(ld.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(p,{transportType:s})}catch(e){throw r.setError(lu.subscribe_authenticated_session_topic_failure),e}r.addTrace(ld.subscribe_authenticated_session_topic_success),await this.client.session.set(p,t),r.addTrace(ld.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:a.pairingTopic,metadata:a.requester.metadata})}r.addTrace(ld.publishing_authenticated_session_approve);try{await this.sendResult({topic:c,id:n,result:{cacaos:i,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:d,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(a.requester.metadata,s)})}catch(e){throw r.setError(lu.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(n,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:a.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:r.eventId}),{session:t}}),dK(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();let{id:t,reason:n}=e,i=this.getPendingAuthRequest(t);if(!i)throw Error(`Could not find pending auth request with id ${t}`);i.transportType===o5.relay&&await this.confirmOnlineStateOrThrow();let r=i.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),s=s8(r);await this.sendError({id:t,topic:s,error:n,encodeOpts:{type:1,receiverPublicKey:r,senderPublicKey:a},rpcOpts:dO.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(i.requester.metadata,i.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,ov("USER_DISCONNECTED"))}),dK(this,"formatAuthMessage",e=>{this.isInitialized();let{request:t,iss:n}=e;return r9(t,n)}),dK(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{let e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),dK(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{let t=this.client.core.pairing.pairings.get(e.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(n=>{var i,r;return(null==(i=n.peerMetadata)?void 0:i.url)&&(null==(r=n.peerMetadata)?void 0:r.url)===e.peer.metadata.url&&n.topic&&n.topic!==t.topic});if(0===n.length)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}}),dK(this,"deleteSession",async e=>{var t;let{topic:n,expirerHasDeleted:i=!1,emitEvent:r=!0,id:a=0}=e,{self:s}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ov("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(s.publicKey)&&await this.client.core.crypto.deleteKeyPair(s.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),i||this.client.core.expirer.del(n),this.client.core.storage.removeItem(dk).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===n&&this.deletePendingSessionRequest(e.id,ov("USER_DISCONNECTED"))}),n===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=dR.idle),r&&this.client.events.emit("session_delete",{id:a,topic:n})}),dK(this,"deleteProposal",async(e,t)=>{if(t)try{let t=this.client.proposal.get(e),n=this.client.core.eventClient.getEvent({topic:t.pairingTopic});n?.setError(lc.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,ov("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),dK(this,"deletePendingSessionRequest",async(e,t,n=!1)=>
32{await Promise.all([this.client.pendingRequest.delete(e,t),n?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),n&&(this.sessionRequestQueue.state=dR.idle,this.client.events.emit("session_request_expire",{id:e}))}),dK(this,"deletePendingAuthRequest",async(e,t,n=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),n?Promise.resolve():this.client.core.expirer.del(e)])}),dK(this,"setExpiry",async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))}),dK(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,ro(dO.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),dK(this,"setAuthRequest",async(e,t)=>{let{request:n,pairingTopic:i,transportType:r=o5.relay}=t;this.client.core.expirer.set(e,n.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:e,pairingTopic:i,verifyContext:n.verifyContext,transportType:r})}),dK(this,"setPendingSessionRequest",async e=>{let{id:t,topic:n,params:i,verifyContext:r}=e,a=i.request.expiryTimestamp||ro(dO.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,a),await this.client.pendingRequest.set(t,{id:t,topic:n,params:i,verifyContext:r})}),dK(this,"sendRequest",async e=>{let t,i,{topic:r,method:a,params:s,expiry:o,relayRpcId:l,clientRpcId:c,throwOnFailedPublish:d,appLink:u,tvf:h}=e,p=(0,oq.formatJsonRpcRequest)(a,s,c),m=!!u;try{let e=m?s4:s3;t=await this.client.core.crypto.encode(r,p,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${r} failed`),e}if(dD.includes(a)){let e=s7(JSON.stringify(p)),n=s7(t);i=await this.client.core.verify.register({id:n,decryptedId:e})}let y=dO[a].req;if(y.attestation=i,o&&(y.ttl=o),l&&(y.id=l),this.client.core.history.set(r,p),m){let e=ou(u,r,t);await n.g.Linking.openURL(e,this.client.name)}else{let e=dO[a].req;o&&(e.ttl=o),l&&(e.id=l),e.tvf=dG(dH({},h),{correlationId:p.id}),d?(e.internal=dG(dH({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,t,e)):this.client.core.relayer.publish(r,t,e).catch(e=>this.client.logger.error(e))}return p.id}),dK(this,"sendResult",async e=>{let t,i,r,{id:a,topic:s,result:o,throwOnFailedPublish:l,encodeOpts:c,appLink:d}=e,u=(0,oq.formatJsonRpcResult)(a,o),h=d&&"u">typeof(null==n.g?void 0:n.g.Linking);try{let e=h?s4:s3;t=await this.client.core.crypto.encode(s,u,dG(dH({},c||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),e}try{let e=(i=await this.client.core.history.get(s,a)).request;try{this.shouldSetTVF(e.method,e.params)&&(r=this.getTVFParams(a,e.params,o))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${a}) failed`),e}if(h){let e=ou(d,s,t);await n.g.Linking.openURL(e,this.client.name)}else{let e=dO[i.request.method].res;e.tvf=dG(dH({},r),{correlationId:a}),l?(e.internal=dG(dH({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,t,e)):this.client.core.relayer.publish(s,t,e).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(u)}),dK(this,"sendError",async e=>{let t,i,{id:r,topic:a,error:s,encodeOpts:o,rpcOpts:l,appLink:c}=e,d=(0,oq.formatJsonRpcError)(r,s),u=c&&"u">typeof(null==n.g?void 0:n.g.Linking);try{let e=u?s4:s3;t=await this.client.core.crypto.encode(a,d,dG(dH({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${a} failed`),e}try{i=await this.client.core.history.get(a,r)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${a}, ${r}) failed`),e}if(u){let e=ou(c,a,t);await n.g.Linking.openURL(e,this.client.name)}else{let e=i.request.method,n=l||dO[e].res;this.client.core.relayer.publish(a,t,n)}await this.client.core.history.resolve(d)}),dK(this,"cleanup",async()=>{let e=[],t=[];
32this.client.session.getAll().forEach(t=>{let n=!1;rl(t.expiry)&&(n=!0),this.client.core.crypto.keychain.has(t.topic)||(n=!0),n&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{rl(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),dK(this,"onProviderMessageEvent",async e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):await this.onRelayMessage(e)}),dK(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),dK(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===dR.active)return void this.client.logger.info("Request queue already active, skipping...");for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=dR.active;let e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=dR.idle}),dK(this,"processRequest",async e=>{let{topic:t,payload:n,attestation:i,transportType:r,encryptedId:a}=e,s=n.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:s}))switch(s){case"wc_sessionPropose":return await this.onSessionProposeRequest
32({topic:t,payload:n,attestation:i,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,n);case"wc_sessionPing":return await this.onSessionPingRequest(t,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:n,attestation:i,encryptedId:a,transportType:r});case"wc_sessionEvent":return await this.onSessionEventRequest(t,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:n,attestation:i,encryptedId:a,transportType:r});default:return this.client.logger.info(`Unsupported request method ${s}`)}}),dK(this,"onRelayEventResponse",async e=>{let{topic:t,payload:n,transportType:i}=e,r=(await this.client.core.history.get(t,n.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,n,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,n);case"wc_sessionExtend":return this.onSessionExtendResponse(t,n);case"wc_sessionPing":return this.onSessionPingResponse(t,n);case"wc_sessionRequest":return this.onSessionRequestResponse(t,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,n);default:return this.client.logger.info(`Unsupported response method ${r}`)}}),dK(this,"onRelayEventUnknownPayload",e=>{let{topic:t}=e,{message:n}=ow("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw Error(n)}),dK(this,"shouldIgnorePairingRequest",e=>{let{topic:t,requestMethod:n}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(n))&&!!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),dK(this,"onSessionProposeRequest",async e=>{let{topic:t,payload:n,attestation:i,encryptedId:r}=e,{params:a,id:s}=n;try{let e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError(lo.proposal_listener_not_found)),this.isValidConnect(dH({},n.params));let o=a.expiryTimestamp||ro(dO.wc_sessionPropose.req.ttl),l=dH({id:s,pairingTopic:t,expiryTimestamp:o},a);await this.setProposal(s,l);let c=await this.getVerifyContext({attestationId:i,hash:s7(JSON.stringify(n)),encryptedId:r,metadata:l.proposer.metadata});e?.addTrace(ls.emit_session_proposal),this.client.events.emit("session_proposal",{id:s,params:l,verifyContext:c})}catch(e){await this.sendError({id:s,topic:t,error:e,rpcOpts:dO.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),dK(this,"onSessionProposeResponse",async(e,t,n)=>{let{id:i}=t;if((0,oq.isJsonRpcResult)(t)){let{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});let a=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});let s=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:s});let o=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:o});let l=await this.client.core.crypto.generateSharedKey(s,o);this.pendingSessions.set(i,{sessionTopic:l,pairingTopic:e,proposalId:i,publicKey:s});let c=await this.client.core.relayer.subscribe(l,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:c}),await this.client.core.pairing.activate({topic:e})}else if((0,oq.isJsonRpcError)(t)){await this.client.proposal.delete(i,ov("USER_DISCONNECTED"));let e=rc("session_connect",i);if(0===this.events.listenerCount(e))throw Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),dK(this,"onSessionSettleRequest",async(e,t)=>{let{id:n,params:i}=t;try{this.isValidSessionSettleRequest(i);let{relay:n,controller:r,expiry:a,namespaces:s,sessionProperties:o,scopedProperties:l,sessionConfig:c}=t.params,d=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!d)return this.client.logger.error(`Pending session not found for topic ${e}`);let u=this.client.proposal.get(d.proposalId),h=dG(dH(dH(dH({topic:e,relay:n,expiry:a,namespaces:s,acknowledged:!0,pairingTopic:d.pairingTopic,requiredNamespaces:u.requiredNamespaces,optionalNamespaces:u.optionalNamespaces,controller:r.publicKey,self:{publicKey:d.publicKey,metadata:this.client.metadata},peer:{publicKey:r.publicKey,metadata:r.metadata}},o&&{sessionProperties:o}),l&&{scopedProperties:l}),c&&{sessionConfig:c}
32),{transportType:o5.relay});await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),await this.client.core.pairing.updateMetadata({topic:d.pairingTopic,metadata:h.peer.metadata}),this.client.events.emit("session_connect",{session:h}),this.events.emit(rc("session_connect",d.proposalId),{session:h}),this.pendingSessions.delete(d.proposalId),this.deleteProposal(d.proposalId,!1),this.cleanupDuplicatePairings(h),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:n,topic:e,error:t}),this.client.logger.error(t)}}),dK(this,"onSessionSettleResponse",async(e,t)=>{let{id:n}=t;(0,oq.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(rc("session_approve",n),{})):(0,oq.isJsonRpcError)(t)&&(await this.client.session.delete(e,ov("USER_DISCONNECTED")),this.events.emit(rc("session_approve",n),{error:t.error}))}),dK(this,"onSessionUpdateRequest",async(e,t)=>{let{params:n,id:i}=t;try{let t=`${e}_session_update`,r=oU.get(t);if(r&&this.isRequestOutOfSync(r,i)){this.client.logger.warn(`Discarding out of sync request - ${i}`),this.sendError({id:i,topic:e,error:ov("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(dH({topic:e},n));try{oU.set(t,i),await this.client.session.update(e,{namespaces:n.namespaces}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw oU.delete(t),e}this.client.events.emit("session_update",{id:i,topic:e,params:n})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),dK(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),dK(this,"onSessionUpdateResponse",(e,t)=>{let{id:n}=t,i=rc("session_update",n);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);(0,oq.isJsonRpcResult)(t)?this.events.emit(rc("session_update",n),{}):(0,oq.isJsonRpcError)(t)&&this.events.emit(rc("session_update",n),{error:t.error})}),dK(this,"onSessionExtendRequest",async(e,t)=>{let{id:n}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,ro(dj)),await this.sendResult({id:n,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:e})}catch(t){await this.sendError({id:n,topic:e,error:t}),this.client.logger.error(t)}}),dK(this,"onSessionExtendResponse",(e,t)=>{let{id:n}=t,i=rc("session_extend",n);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);(0,oq.isJsonRpcResult)(t)?this.events.emit(rc("session_extend",n),{}):(0,oq.isJsonRpcError)(t)&&this.events.emit(rc("session_extend",n),{error:t.error})}),dK(this,"onSessionPingRequest",async(e,t)=>{let{id:n}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:n,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:e})}catch(t){await this.sendError({id:n,topic:e,error:t}),this.client.logger.error(t)}}),dK(this,"onSessionPingResponse",(e,t)=>{let{id:n}=t,i=rc("session_ping",n);setTimeout(()=>{if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners 2176`);(0,oq.isJsonRpcResult)(t)?this.events.emit(rc("session_ping",n),{}):(0,oq.isJsonRpcError)(t)&&this.events.emit(rc("session_ping",n),{error:t.error})},500)}),dK(this,"onSessionDeleteRequest",async(e,t)=>{let{id:n}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise(t=>{this.client.core.relayer.once(o2.publish,async()=>{t(await this.deleteSession({topic:e,id:n}))})}),this.sendResult({id:n,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:ov("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),dK(this,"onSessionRequest",async e=>{var t,n,i;let{topic:r,payload:a,attestation:s,encryptedId:o,transportType:l}=e,{id:c,params:d}=a;try{await this.isValidRequest(dH({topic:r},d));let e=this.client.session.get(r),a=await this.getVerifyContext({attestationId:s,hash:s7(JSON.stringify((0,oq.formatJsonRpcRequest)("wc_sessionRequest",d,c))),encryptedId:o,metadata:e.peer.metadata,transportType:l}),u={id:c,topic:r,params:d,verifyContext:a};await this.setPendingSessionRequest(u),l===o5.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(n=e.peer.metadata.redirect)?void 0:n.universal),null!=(i=this.client.signConfig)&&i.disableRequestQueue?this.emitSessionRequest(u):(this.addSessionRequestToSessionRequestQueue(u),this.processSessionRequestQueue())}
32catch(e){await this.sendError({id:c,topic:r,error:e}),this.client.logger.error(e)}}),dK(this,"onSessionRequestResponse",(e,t)=>{let{id:n}=t,i=rc("session_request",n);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);(0,oq.isJsonRpcResult)(t)?this.events.emit(rc("session_request",n),{result:t.result}):(0,oq.isJsonRpcError)(t)&&this.events.emit(rc("session_request",n),{error:t.error})}),dK(this,"onSessionEventRequest",async(e,t)=>{let{id:n,params:i}=t;try{let t=`${e}_session_event_${i.event.name}`,r=oU.get(t);if(r&&this.isRequestOutOfSync(r,n))return void this.client.logger.info(`Discarding out of sync request - ${n}`);this.isValidEmit(dH({topic:e},i)),this.client.events.emit("session_event",{id:n,topic:e,params:i}),oU.set(t,n)}catch(t){await this.sendError({id:n,topic:e,error:t}),this.client.logger.error(t)}}),dK(this,"onSessionAuthenticateResponse",(e,t)=>{let{id:n}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,oq.isJsonRpcResult)(t)?this.events.emit(rc("session_request",n),{result:t.result}):(0,oq.isJsonRpcError)(t)&&this.events.emit(rc("session_request",n),{error:t.error})}),dK(this,"onSessionAuthenticateRequest",async e=>{var t;let{topic:n,payload:i,attestation:r,encryptedId:a,transportType:s}=e;try{let{requester:e,authPayload:o,expiryTimestamp:l}=i.params,c=await this.getVerifyContext({attestationId:r,hash:s7(JSON.stringify(i)),encryptedId:a,metadata:e.metadata,transportType:s}),d={requester:e,pairingTopic:n,id:i.id,authPayload:o,verifyContext:c,expiryTimestamp:l};await this.setAuthRequest(i.id,{request:d,pairingTopic:n,transportType:s}),s===o5.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:i.params,id:i.id,verifyContext:c})}catch(a){this.client.logger.error(a);let e=i.params.requester.publicKey,t=await this.client.core.crypto.generateKeyPair(),r=this.getAppLinkIfEnabled(i.params.requester.metadata,s);await this.sendError({id:i.id,topic:n,error:a,encodeOpts:{type:1,receiverPublicKey:e,senderPublicKey:t},rpcOpts:dO.wc_sessionAuthenticate.autoReject,appLink:r})}}),dK(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),dK(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=dR.idle,this.processSessionRequestQueue()},(0,iM.toMiliseconds)(this.requestQueueDelay))}),dK(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{let n=rc("session_request",e.request.id);if(0===this.events.listenerCount(n))throw Error(`emitting ${n} without any listeners`);this.events.emit(rc("session_request",e.request.id),{error:t})})}),dK(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===dR.active)return void this.client.logger.info("session request queue is already active.");let e=this.sessionRequestQueue.queue[0];if(!e)return void this.client.logger.info("session request queue is empty.");try{this.sessionRequestQueue.state=dR.active,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}}),dK(this,"emitSessionRequest",e=>{this.client.events.emit("session_request",e)}),dK(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;let t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);
32t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,oq.formatJsonRpcRequest)("wc_sessionPropose",dG(dH({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties,scopedProperties:t.scopedProperties}),t.id)})}),dK(this,"isValidConnect",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw Error(t)}let{pairingTopic:t,requiredNamespaces:n,optionalNamespaces:i,sessionProperties:r,scopedProperties:a,relays:s}=e;if(o_(t)||await this.isValidPairingTopic(t),!function(e,t){let n=!1;return t&&!e?n=!0:e&&ob(e)&&e.length&&e.forEach(e=>{n=ok(e)}),n}(s,!0)){let{message:e}=ow("MISSING_OR_INVALID",`connect() relays: ${s}`);throw Error(e)}if(o_(n)||0===ox(n)||this.validateNamespaces(n,"requiredNamespaces"),o_(i)||0===ox(i)||this.validateNamespaces(i,"optionalNamespaces"),o_(r)||this.validateSessionProps(r,"sessionProperties"),!o_(a)){this.validateSessionProps(a,"scopedProperties");let e=Object.keys(n||{}).concat(Object.keys(i||{}));if(!Object.keys(a).every(t=>e.includes(t)))throw Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(e)}`)}}),dK(this,"validateNamespaces",(e,t)=>{let n=function(e,t,n){let i=null;if(e&&ox(e)){let r,a=oA(e,t);a&&(i=a);let s=(r=null,Object.entries(e).forEach(([e,i])=>{var a,s;let o;if(r)return;let l=(a=iG(e,i),s=`${t} ${n}`,o=null,ob(a)&&a.length?a.forEach(e=>{o||oE(e)||(o=ov("UNSUPPORTED_CHAINS",`${s}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):oE(e)||(o=ov("UNSUPPORTED_CHAINS",`${s}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),o);l&&(r=l)}),r);s&&(i=s)}else i=ow("MISSING_OR_INVALID",`${t}, ${n} should be an object with data`);return i}(e,"connect()",t);if(n)throw Error(n.message)}),dK(this,"isValidApprove",async e=>{if(!oP(e))throw Error(ow("MISSING_OR_INVALID",`approve() params: ${e}`).message);let{id:t,namespaces:n,relayProtocol:i,sessionProperties:r,scopedProperties:a}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);let s=this.client.proposal.get(t),o=oS(n,"approve()");if(o)throw Error(o.message);let l=oO(s.requiredNamespaces,n,"approve()");if(l)throw Error(l.message);if(!oC(i,!0)){let{message:e}=ow("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw Error(e)}if(o_(r)||this.validateSessionProps(r,"sessionProperties"),!o_(a)){this.validateSessionProps(a,"scopedProperties");let e=new Set(Object.keys(n));if(!Object.keys(a).every(t=>e.has(t)))throw Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(e).join(", ")}`)}}),dK(this,"isValidReject",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`reject() params: ${e}`);throw Error(t)}let{id:t,reason:n}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!function(e){return!(!e||"object"!=typeof e||!e.code||!oI(e.code,!1)||!e.message||!oC(e.message,!1))}(n)){let{message:e}=ow("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw Error(e)}}),dK(this,"isValidSessionSettleRequest",e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw Error(t)}let{relay:t,controller:n,namespaces:i,expiry:r}=e;if(!ok(t)){let{message:e}=ow("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw Error(e)}let a=function(e,t){let n=null;return oC(e?.publicKey,!1)||(n=ow("MISSING_OR_INVALID",`${t} controller public key should be a string`)),n}(n,"onSessionSettleRequest()");if(a)throw Error(a.message);let s=oS(i,"onSessionSettleRequest()");if(s)throw Error(s.message);if(rl(r)){let{message:e}=ow("EXPIRED","onSessionSettleRequest()");throw Error(e)}}),dK(this,"isValidUpdate",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`update() params: ${e}`);throw Error(t)}let{topic:t,namespaces:n}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);
32let i=this.client.session.get(t),r=oS(n,"update()");if(r)throw Error(r.message);let a=oO(i.requiredNamespaces,n,"update()");if(a)throw Error(a.message)}),dK(this,"isValidExtend",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`extend() params: ${e}`);throw Error(t)}let{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),dK(this,"isValidRequest",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`request() params: ${e}`);throw Error(t)}let{topic:t,request:n,chainId:i,expiry:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);let{namespaces:a}=this.client.session.get(t);if(!oj(a,i)){let{message:e}=ow("MISSING_OR_INVALID",`request() chainId: ${i}`);throw Error(e)}if(!function(e){return!(o_(e)||!oC(e.method,!1))}(n)){let{message:e}=ow("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw Error(e)}if(!function(e,t,n){return!!oC(n,!1)&&(function(e,t){let n=[];return Object.values(e).forEach(e=>{oh(e.accounts).includes(t)&&n.push(...e.methods)}),n})(e,t).includes(n)}(a,i,n.method)){let{message:e}=ow("MISSING_OR_INVALID",`request() method: ${n.method}`);throw Error(e)}if(r&&!function(e,t){return oI(e,!1)&&e<=t.max&&e>=t.min}(r,dN)){let{message:e}=ow("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${dN.min} and ${dN.max}`);throw Error(e)}}),dK(this,"isValidRespond",async e=>{var t;if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`respond() params: ${e}`);throw Error(t)}let{topic:n,response:i}=e;try{await this.isValidSessionTopic(n)}catch(n){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),n}if(!function(e){return!(o_(e)||o_(e.result)&&o_(e.error)||!oI(e.id,!1)||!oC(e.jsonrpc,!1))}(i)){let{message:e}=ow("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw Error(e)}}),dK(this,"isValidPing",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`ping() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),dK(this,"isValidEmit",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`emit() params: ${e}`);throw Error(t)}let{topic:t,event:n,chainId:i}=e;await this.isValidSessionTopic(t);let{namespaces:r}=this.client.session.get(t);if(!oj(r,i)){let{message:e}=ow("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw Error(e)}if(!function(e){return!(o_(e)||!oC(e.name,!1))}(n)||!function(e,t,n){return!!oC(n,!1)&&(function(e,t){let n=[];return Object.values(e).forEach(e=>{oh(e.accounts).includes(t)&&n.push(...e.events)}),n})(e,t).includes(n)}(r,i,n.name)){let{message:e}=ow("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw Error(e)}}),dK(this,"isValidDisconnect",async e=>{if(!oP(e)){let{message:t}=ow("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),dK(this,"isValidAuthenticate",e=>{let{chains:t,uri:n,domain:i,nonce:r}=e;if(!Array.isArray(t)||0===t.length)throw Error("chains is required and must be a non-empty array");if(!oC(n,!1))throw Error("uri is required parameter");if(!oC(i,!1))throw Error("domain is required parameter");if(!oC(r,!1))throw Error("nonce is required parameter");if([...new Set(t.map(e=>iV(e).namespace))].length>1)throw Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:a}=iV(t[0]);if("eip155"!==a)throw Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),dK(this,"getVerifyContext",async e=>{let{attestationId:t,hash:n,encryptedId:i,metadata:r,transportType:a}=e,s={verified:{verifyUrl:r.verifyUrl||li,validation:"UNKNOWN",origin:r.url||""}};try{if(a===o5.link_mode){let e=this.getAppLinkIfEnabled(r,a);return s.verified.validation=e&&new URL(e).origin===new URL(r.url).origin?"VALID":"INVALID",s}let e=await this.client.core.verify.resolve({attestationId:t,hash:n,encryptedId:i,verifyUrl:r.verifyUrl});e&&(s.verified.origin=e.origin,s.verified.isScam=e.isScam,s.verified.validation=e.origin===new URL(r.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(s)}`),s}),dK(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach((n,i)=>{if(null==n){let{message:r}=ow("MISSING_OR_INVALID",`${t} must contain an existing value for each key. Received: ${n} for key ${Object.keys(e)[i]}`);throw Error(r)}})}),dK(this,"getPendingAuthRequest",e=>{let t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),dK(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0,t=this.recentlyDeletedLimit/2;
32for(let n of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(n)}}}),dK(this,"checkRecentlyDeleted",e=>{let t=this.recentlyDeletedMap.get(e);if(t){let{message:n}=ow("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw Error(n)}}),dK(this,"isLinkModeEnabled",(e,t)=>{var i,r,a,s,o,l,c,d,u;return!!e&&t===o5.link_mode&&(null==(r=null==(i=this.client.metadata)?void 0:i.redirect)?void 0:r.linkMode)===!0&&(null==(s=null==(a=this.client.metadata)?void 0:a.redirect)?void 0:s.universal)!==void 0&&(null==(l=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:l.universal)!==""&&(null==(c=e?.redirect)?void 0:c.universal)!==void 0&&(null==(d=e?.redirect)?void 0:d.universal)!==""&&(null==(u=e?.redirect)?void 0:u.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&"u">typeof(null==n.g?void 0:n.g.Linking)}),dK(this,"getAppLinkIfEnabled",(e,t)=>{var n;return this.isLinkModeEnabled(e,t)?null==(n=e?.redirect)?void 0:n.universal:void 0}),dK(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;let t=rp(e,"topic")||"",n=decodeURIComponent(rp(e,"wc_ev")||""),i=this.client.session.keys.includes(t);i&&this.client.session.update(t,{transportType:o5.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:n,sessionExists:i})}),dK(this,"registerLinkModeListeners",async()=>{var e;if(ry()||i4()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){let e=null==n.g?void 0:n.g.Linking;if("u">typeof e){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);let t=await e.getInitialURL();t&&setTimeout(()=>{this.handleLinkModeMessage({url:t})},50)}}}),dK(this,"shouldSetTVF",(e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;let{request:n}=t;return Object.keys(dM).includes(n.method)}),dK(this,"getTVFParams",(e,t,n)=>{var i,r;try{let a=t.request.method,s=this.extractTxHashesFromResult(a,n);return dG(dH({correlationId:e,rpcMethods:[a],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(r=null==(i=t.request.params)?void 0:i[0])?void 0:r.to]}),{txHashes:s})}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}}),dK(this,"isValidContractData",e=>{var t;if(!e)return!1;try{let n=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!n.startsWith("0x"))return!1;let i=n.slice(2);return!!/^[0-9a-fA-F]*$/.test(i)&&i.length%2==0}catch{}return!1}),dK(this,"extractTxHashesFromResult",(e,t)=>{try{let n=dM[e];if("string"==typeof t)return[t];let i=t[n.key];if(ob(i))return"solana_signAllTransactions"===e?i.map(e=>(function(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let i=n[0];if(0===i)throw Error("No signatures found");if(n.length<1+64*i)throw Error("Transaction data too short for claimed signature count");if(n.length<100)throw Error("Transaction too short");let r=iq.from(e,"base64").slice(1,65);return iF.A.encode(r)})(e)):i;if("string"==typeof i)return[i]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}async processPendingMessageEvents(){try{let e=this.client.session.keys,t=this.client.core.relayer.messages.getWithoutAck(e);for(let[e,n]of Object.entries(t))for(let t of n)try{await this.onProviderMessageEvent({topic:e,message:t,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${t}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){let{message:e}=ow("NOT_INITIALIZED",this.name);throw Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(o2.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){let{topic:t,message:n,attestation:i,transportType:r}=e,{publicKey:a}=this.client.auth.authKeys.keys.includes(dL)?this.client.auth.authKeys.get(dL):{responseTopic:void 0,publicKey:void 0};try{let e=await this.client.core.crypto.decode(t,n,{receiverPublicKey:a,encoding:r===o5.link_mode?s4:s3});(0,oq.isJsonRpcRequest)(e)?(this.client.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e,attestation:i,transportType:r,encryptedId:s7(n)})):(0,oq.isJsonRpcResponse)(e)?(await this.client.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e,transportType:r}),this.client.core.history.delete(t,e.id)):await this.onRelayEventUnknownPayload({topic:t,payload:e,transportType:r}),await this.client.core.relayer.messages.ack(t,n)}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(ln.expired,async e=>
32{let{topic:t,id:n}=rs(e.target);return n&&this.client.pendingRequest.keys.includes(n)?await this.deletePendingSessionRequest(n,ow("EXPIRED"),!0):n&&this.client.auth.requests.keys.includes(n)?await this.deletePendingAuthRequest(n,ow("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n})))})}registerPairingEvents(){this.client.core.pairing.events.on(le.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(le.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!oC(e,!1)){let{message:t}=ow("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=ow("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw Error(t)}if(rl(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=ow("EXPIRED",`pairing topic: ${e}`);throw Error(t)}}async isValidSessionTopic(e){if(!oC(e,!1)){let{message:t}=ow("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=ow("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw Error(t)}if(rl(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=ow("EXPIRED",`session topic: ${e}`);throw Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=ow("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(oC(e,!1)){let{message:t}=ow("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw Error(t)}else{let{message:t}=ow("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw Error(t)}}async isValidProposalId(e){if("number"!=typeof e){let{message:t}=ow("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=ow("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw Error(t)}if(rl(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=ow("EXPIRED",`proposal id: ${e}`);throw Error(t)}}}class dZ extends c3{constructor(e,t){super(e,t,"proposal",dA),this.core=e,this.logger=t}}class dY extends c3{constructor(e,t){super(e,t,"session",dA),this.core=e,this.logger=t}}class dQ extends c3{constructor(e,t){super(e,t,"request",dA,e=>e.id),this.core=e,this.logger=t}}class dX extends c3{constructor(e,t){super(e,t,"authKeys",dU,()=>dL),this.core=e,this.logger=t}}class d0 extends c3{constructor(e,t){super(e,t,"pairingTopics",dU),this.core=e,this.logger=t}}class d1 extends c3{constructor(e,t){super(e,t,"requests",dU,e=>e.id),this.core=e,this.logger=t}}var d2=Object.defineProperty,d3=(e,t,n)=>((e,t,n)=>t in e?d2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class d4{constructor(e,t){this.core=e,this.logger=t,d3(this,"authKeys"),d3(this,"pairingTopics"),d3(this,"requests"),this.authKeys=new dX(this.core,this.logger),this.pairingTopics=new d0(this.core,this.logger),this.requests=new d1(this.core,this.logger)}
32async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var d5=Object.defineProperty,d6=(e,t,n)=>((e,t,n)=>t in e?d5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class d8 extends o$.S9{constructor(e){super(e),d6(this,"protocol","wc"),d6(this,"version",2),d6(this,"name",dS.name),d6(this,"metadata"),d6(this,"core"),d6(this,"logger"),d6(this,"events",new iO.EventEmitter),d6(this,"engine"),d6(this,"session"),d6(this,"proposal"),d6(this,"pendingRequest"),d6(this,"auth"),d6(this,"signConfig"),d6(this,"on",(e,t)=>this.events.on(e,t)),d6(this,"once",(e,t)=>this.events.once(e,t)),d6(this,"off",(e,t)=>this.events.off(e,t)),d6(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),d6(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),d6(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),d6(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),d6(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||dS.name,this.metadata=function(e){var t,n;let i=i7();try{let r,a;return null!=e&&e.url&&i.url&&e.url!==i.url&&(console.warn(`The configured WalletConnect 'metadata.url':${e.url} differs from the actual page url:${i.url}. This is probably unintended and can lead to issues.`),e.url=i.url),null!=(t=e?.icons)&&t.length&&e.icons.length>0&&(e.icons=e.icons.filter(e=>""!==e)),r=i1(i1({},i),e),a={url:e?.url||i.url,name:e?.name||i.name,description:e?.description||i.description,icons:null!=(n=e?.icons)&&n.length&&e.icons.length>0?e.icons:i.icons},iJ(r,iZ(a))}catch(t){return console.warn("Error populating app metadata",t),e||i}}(e?.metadata),this.signConfig=e?.signConfig;let t="u">typeof e?.logger&&"string"!=typeof e?.logger?e.logger:(0,oW.h6)((0,oW.iP)({level:e?.logger||dS.logger}));this.core=e?.core||new dE(e),this.logger=(0,oW.U5)(t,this.name),this.session=new dY(this.core,this.logger),this.proposal=new dZ(this.core,this.logger),this.pendingRequest=new dQ(this.core,this.logger),this.engine=new dJ(this),this.auth=new d4(this.core,this.logger)}static async init(e){let t=new d8(e);return await t.initialize(),t}get context(){return(0,oW.oI)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},(0,iM.toMiliseconds)(iM.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var d7=n(339505),d9=n(715599).Buffer;let ue="error",ut="wc@2:universal_provider:",un="https://rpc.walletconnect.org/v1/",ui="generic",ur=`${un}bundler`,ua={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function us(){}function uo(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function ul(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function uc(e){return"object"==typeof e&&null!==e}function ud(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}
32function uu(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}let uh="[object String]",up="[object Number]",um="[object Boolean]",uy="[object Arguments]";function uf(e,t,n,i=new Map,r){let a=r?.(e,t,n,i);if(null!=a)return a;if(uo(e))return e;if(i.has(e))return i.get(e);if(Array.isArray(e)){let t=Array(e.length);i.set(e,t);for(let a=0;a<e.length;a++)t[a]=uf(e[a],a,n,i,r);return Object.hasOwn(e,"index")&&(t.index=e.index),Object.hasOwn(e,"input")&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){let t=new Map;for(let[a,s]of(i.set(e,t),e))t.set(a,uf(s,a,n,i,r));return t}if(e instanceof Set){let t=new Set;for(let a of(i.set(e,t),e))t.add(uf(a,void 0,n,i,r));return t}if("u">typeof d9&&d9.isBuffer(e))return e.subarray();if(ul(e)){let t=new(Object.getPrototypeOf(e)).constructor(e.length);i.set(e,t);for(let a=0;a<e.length;a++)t[a]=uf(e[a],a,n,i,r);return t}if(e instanceof ArrayBuffer||"u">typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return i.set(e,t),ug(t,e,n,i,r),t}if("u">typeof File&&e instanceof File){let t=new File([e],e.name,{type:e.type});return i.set(e,t),ug(t,e,n,i,r),t}if(e instanceof Blob){let t=new Blob([e],{type:e.type});return i.set(e,t),ug(t,e,n,i,r),t}if(e instanceof Error){let t=new e.constructor;return i.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,ug(t,e,n,i,r),t}if("object"==typeof e&&function(e){switch(uu(e)){case uy:case"[object Array]":case"[object ArrayBuffer]":case"[object DataView]":case um:case"[object Date]":case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Map]":case up:case"[object Object]":case"[object RegExp]":case"[object Set]":case uh:case"[object Symbol]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return!0;default:return!1}}(e)){let t=Object.create(Object.getPrototypeOf(e));return i.set(e,t),ug(t,e,n,i,r),t}return e}function ug(e,t,n=e,i,r){let a=[...Object.keys(t),...ud(t)];for(let s=0;s<a.length;s++){let o=a[s],l=Object.getOwnPropertyDescriptor(e,o);(null==l||l.writable)&&(e[o]=uf(t[o],o,n,i,r))}}function uw(e){var t;return t=(t,n,i,r)=>{let a=void 0;if(null!=a)return a;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case up:case uh:case um:{let t=new e.constructor(e?.valueOf());return ug(t,e),t}case uy:{let t={};return ug(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}},uf(e,void 0,e,new Map,t)}function uv(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===uu(e)}var ub=Object.defineProperty,ux=Object.defineProperties,u_=Object.getOwnPropertyDescriptors,uC=Object.getOwnPropertySymbols,uI=Object.prototype.hasOwnProperty,uE=Object.prototype.propertyIsEnumerable,uT=(e,t,n)=>t in e?ub(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uA=(e,t)=>{for(var n in t||(t={}))uI.call(t,n)&&uT(e,n,t[n]);if(uC)for(var n of uC(t))uE.call(t,n)&&uT(e,n,t[n]);return e},uS=(e,t)=>ux(e,u_(t));function uk(e,t,n){var i;let r=iV(e);return(null==(i=t.rpcMap)?void 0:i[r.reference])||`${un}?chainId=${r.namespace}:${r.reference}&projectId=${n}`}function uP(e){return e.includes(":")?e.split(":")[1]:e}function uj(e){return e.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function uO(e={},t={}){return function(e,...t){return function(e,...t){let n=t.slice(0,-1),i=t[t.length-1],r=e;for(let e=0;e<n.length;e++)r=function e(t,n,i,r){if(uo(t)&&(t=Object(t)),null==n||"object"!=typeof n)return t;if(r.has(n))return function(e){if(uo(e))return e;if(Array.isArray(e)||ul(e)||e instanceof ArrayBuffer||"u">typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);let t=Object.getPrototypeOf(e),n=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new n(e);if(e instanceof RegExp){let t=new n(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new n(e.buffer.slice(0));if(e instanceof Error){let t=new n(e.message);return t.stack=e.stack,t.name=e.name,t.cause=e.cause,t}return"u">typeof File&&e instanceof File?new n([e],e.name,{type:e.type,lastModified:e.lastModified}):"object"==typeof e?Object.assign(Object.create(t),e):e}(r.get(n));if(r.set(n,t),Array.isArray(n)){n=n.slice();for(let e=0;e<n.length;e++)n[e]=n[e]??void 0}let a=[...Object.keys(n),...ud(n)];for(let s=0;s<a.length;s++){let o=a[s],l=n[o],c=t[o];if(uv(l)&&(l={...l}),uv(c)&&(c={...c}),"u">typeof d9&&d9.isBuffer(l)&&(l=uw(l)),Array.isArray(l))if("object"==typeof c&&null!=c){let e=[],t=Reflect.ownKeys(c);for(let n=0;n<t.length;n++){let i=t[n];e[i]=c[i]}c=e}else c=[];let d=i(c,l,o,t,n,r);null!=d?t[o]=d:Array.isArray(l)||uc(c)&&uc(l)?t[o]=e(c,l,i,r):null==c&&function(e){if("object"!=typeof e||null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;
32if("[object Object]"!==Object.prototype.toString.call(e)){let t=e[Symbol.toStringTag];return null!=t&&!!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable&&e.toString()===`[object ${t}]`}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(l)?t[o]=e({},l,i,r):null==c&&ul(l)?t[o]=uw(l):(void 0===c||void 0!==l)&&(t[o]=l)}return t}(r,n[e],i,new Map);return r}(e,...t,us)}(uN(e),uN(t))}function uN(e){var t,n,i,r;let a={};if(!ox(e))return a;for(let[s,o]of Object.entries(e)){let e=op(s)?[s]:o.chains,l=o.methods||[],c=o.events||[],d=o.rpcMap||{},u=om(s);a[u]=uS(uA(uA({},a[u]),o),{chains:rd(e,null==(t=a[u])?void 0:t.chains),methods:rd(l,null==(n=a[u])?void 0:n.methods),events:rd(c,null==(i=a[u])?void 0:i.events),rpcMap:uA(uA({},d),null==(r=a[u])?void 0:r.rpcMap)})}return a}function uR(e){return e.includes(":")?e.split(":")[2]:e}function uM(e){let t={};for(let[n,i]of Object.entries(e)){let e=i.methods||[],r=i.events||[],a=i.accounts||[],s=op(n)?[n]:i.chains?i.chains:uj(i.accounts);t[n]={chains:s,methods:e,events:r,accounts:a}}return t}function uD(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):isNaN(Number(e=e.includes(":")?e.split(":")[1]:e))?e:Number(e)}let uU={},uL=e=>uU[e],uF=(e,t)=>{uU[e]=t};var uW=Object.defineProperty,u$=(e,t,n)=>((e,t,n)=>t in e?uW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class uB{constructor(e){u$(this,"name","polkadot"),u$(this,"client"),u$(this,"httpProviders"),u$(this,"events"),u$(this,"namespace"),u$(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){let e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var n;let i=uP(t);e[i]=this.createHttpProvider(i,null==(n=this.namespace.rpcMap)?void 0:n[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||uk(e,this.namespace,this.client.core.projectId);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);return new oz.F(new d7.A(n,uL("disableProviderPing")))}}var uz=Object.defineProperty,uq=Object.defineProperties,uV=Object.getOwnPropertyDescriptors,uH=Object.getOwnPropertySymbols,uG=Object.prototype.hasOwnProperty,uK=Object.prototype.propertyIsEnumerable,uJ=(e,t,n)=>t in e?uz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uZ=(e,t)=>{for(var n in t||(t={}))uG.call(t,n)&&uJ(e,n,t[n]);if(uH)for(var n of uH(t))uK.call(t,n)&&uJ(e,n,t[n]);return e},uY=(e,t)=>uq(e,uV(t)),uQ=(e,t,n)=>uJ(e,"symbol"!=typeof t?t+"":t,n);class uX{constructor(e){uQ(this,"name","eip155"),uQ(this,"client"),uQ(this,"chainId"),uQ(this,"namespace"),uQ(this,"httpProviders"),uQ(this,"events"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){let n=t||uk(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);return new oz.F(new d7.V(n,uL("disableProviderPing")))}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var n;let i=parseInt(uP(t));e[i]=this.createHttpProvider(i,null==(n=this.namespace.rpcMap)?void 0:n[t])}),e}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){let e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,n;let i=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0",r=parseInt(i=i.startsWith("0x")?i:`0x${i}`,16);if(this.isChainApproved(r))this.setDefaultChain(`${r}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:null==(n=this.namespace.chains)?void 0:n[0]}),this.setDefaultChain(`${r}`);else throw Error(`Failed to switch to chain 'eip155:${r}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,n,i;let r=null==(n=null==(t=e.request)?void 0:t.params)?void 0:n[0];if(!r)throw Error("Missing address parameter in `wallet_getCapabilities` request");let a=this.client.session.get(e.topic),s=(null==(i=a?.sessionProperties)?void 0:i.capabilities)||{};if(null!=s&&s[r])return s?.[r];let o=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:uY(uZ({},a.sessionProperties||{}),{capabilities:uY(uZ({},s||{}),{[r]:o})})})}catch(e){console.warn("Failed to update session with capabilities",e)}return o}async getCallStatus(e){var t,n;let i=this.client.session.get(e.topic),r=null==(t=i.sessionProperties)?void 0:t.bundler_name;if(r){let t=this.getBundlerUrl(e.chainId,r);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}let a=null==(n=i.sessionProperties)?void 0:n.bundler_url;if(a)try{return await this.getUserOperationReceipt(a,e)}catch(e){console.warn("Failed to fetch call status from custom bundler",e,a)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var n;let i=new URL(e),r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,oq.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(n=t.request.params)?void 0:n[0]]))});if(!r.ok)throw Error(`Failed to fetch user operation receipt - ${r.status}`);return await r.json()}
32getBundlerUrl(e,t){return`${ur}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var u0=Object.defineProperty,u1=(e,t,n)=>((e,t,n)=>t in e?u0(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class u2{constructor(e){u1(this,"name","solana"),u1(this,"client"),u1(this,"httpProviders"),u1(this,"events"),u1(this,"namespace"),u1(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var n;let i=uP(t);e[i]=this.createHttpProvider(i,null==(n=this.namespace.rpcMap)?void 0:n[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||uk(e,this.namespace,this.client.core.projectId);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);return new oz.F(new d7.A(n,uL("disableProviderPing")))}}var u3=Object.defineProperty,u4=(e,t,n)=>((e,t,n)=>t in e?u3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class u5{constructor(e){u4(this,"name","cosmos"),u4(this,"client"),u4(this,"httpProviders"),u4(this,"events"),u4(this,"namespace"),u4(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var n;let i=uP(t);e[i]=this.createHttpProvider(i,null==(n=this.namespace.rpcMap)?void 0:n[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||uk(e,this.namespace,this.client.core.projectId);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);return new oz.F(new d7.A(n,uL("disableProviderPing")))}}var u6=Object.defineProperty,u8=(e,t,n)=>((e,t,n)=>t in e?u6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class u7{constructor(e){u8(this,"name","algorand"),u8(this,"client"),u8(this,"httpProviders"),u8(this,"events"),u8(this,"namespace"),u8(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){let n=t||uk(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.chainId=e,this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var n;e[t]=this.createHttpProvider(t,null==(n=this.namespace.rpcMap)?void 0:n[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||uk(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new oz.F(new d7.A(n,uL("disableProviderPing")))}}var u9=Object.defineProperty,he=(e,t,n)=>((e,t,n)=>t in e?u9(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class ht{constructor(e){he(this,"name","cip34"),he(this,"client"),he(this,"httpProviders"),he(this,"events"),he(this,"namespace"),he(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{let n=this.getCardanoRPCUrl(t),i=uP(t);e[i]=this.createHttpProvider(i,n)}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){let t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||this.getCardanoRPCUrl(e);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);return new oz.F(new d7.A(n,uL("disableProviderPing")))}}var hn=Object.defineProperty,hi=(e,t,n)=>((e,t,n)=>t in e?hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class hr{constructor(e){hi(this,"name","elrond"),hi(this,"client"),hi(this,"httpProviders"),hi(this,"events"),hi(this,"namespace"),hi(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var n;let i=uP(t);e[i]=this.createHttpProvider(i,null==(n=this.namespace.rpcMap)?void 0:n[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||uk(e,this.namespace,this.client.core.projectId);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);return new oz.F(new d7.A(n,uL("disableProviderPing")))}}var ha=Object.defineProperty,hs=(e,t,n)=>((e,t,n)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class ho{constructor(e){hs(this,"name","multiversx"),hs(this,"client"),hs(this,"httpProviders"),hs(this,"events"),hs(this,"namespace"),hs(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var n;let i=uP(t);e[i]=this.createHttpProvider(i,null==(n=this.namespace.rpcMap)?void 0:n[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||uk(e,this.namespace,this.client.core.projectId);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);return new oz.F(new d7.A(n,uL("disableProviderPing")))}}var hl=Object.defineProperty,hc=(e,t,n)=>((e,t,n)=>t in e?hl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class hd{constructor(e){hc(this,"name","near"),hc(this,"client"),hc(this,"httpProviders"),hc(this,"events"),hc(this,"namespace"),hc(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){let n=t||uk(`${this.name}:${e}`,this.namespace);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var n;e[t]=this.createHttpProvider(t,null==(n=this.namespace.rpcMap)?void 0:n[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||uk(e,this.namespace);return typeof n>"u"?void 0:new oz.F(new d7.A(n,uL("disableProviderPing")))}}var hu=Object.defineProperty,hh=(e,t,n)=>((e,t,n)=>t in e?hu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class hp{constructor(e){hh(this,"name","tezos"),hh(this,"client"),hh(this,"httpProviders"),hh(this,"events"),hh(this,"namespace"),hh(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){let n=t||uk(`${this.name}:${e}`,this.namespace);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||uk(e,this.namespace);return typeof n>"u"?void 0:new oz.F(new d7.A(n))}}var hm=Object.defineProperty,hy=(e,t,n)=>((e,t,n)=>t in e?hm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class hf{constructor(e){hy(this,"name",ui),hy(this,"client"),hy(this,"httpProviders"),hy(this,"events"),hy(this,"namespace"),hy(this,"chainId"),this.namespace=e.namespace,this.events=uL("events"),this.client=uL("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(ua.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(
32e=>e.split(":")[2]))]:[]}createHttpProviders(){var e,t;let n={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e=>{let t=iV(e);n[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)}),n}getHttpProvider(e){let t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){let n=t||uk(e,this.namespace,this.client.core.projectId);if(!n)throw Error(`No RPC url provided for chainId: ${e}`);return new oz.F(new d7.A(n,uL("disableProviderPing")))}}var hg=Object.defineProperty,hw=Object.defineProperties,hv=Object.getOwnPropertyDescriptors,hb=Object.getOwnPropertySymbols,hx=Object.prototype.hasOwnProperty,h_=Object.prototype.propertyIsEnumerable,hC=(e,t,n)=>t in e?hg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hI=(e,t)=>{for(var n in t||(t={}))hx.call(t,n)&&hC(e,n,t[n]);if(hb)for(var n of hb(t))h_.call(t,n)&&hC(e,n,t[n]);return e},hE=(e,t)=>hw(e,hv(t)),hT=(e,t,n)=>hC(e,"symbol"!=typeof t?t+"":t,n);class hA{constructor(e){hT(this,"client"),hT(this,"namespaces"),hT(this,"optionalNamespaces"),hT(this,"sessionProperties"),hT(this,"scopedProperties"),hT(this,"events",new(iN())),hT(this,"rpcProviders",{}),hT(this,"session"),hT(this,"providerOpts"),hT(this,"logger"),hT(this,"uri"),hT(this,"disableProviderPing",!1),this.providerOpts=e,this.logger="u">typeof e?.logger&&"string"!=typeof e?.logger?e.logger:(0,oW.h6)((0,oW.iP)({level:e?.logger||ue})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){let t=new hA(e);return await t.initialize(),t}async request(e,t,n){let[i,r]=this.validateChain(t);if(!this.session)throw Error("Please call connect() before request()");return await this.getProvider(i).request({request:hI({},e),chainId:`${i}:${r}`,topic:this.session.topic,expiry:n})}sendAsync(e,t,n,i){let r=new Date().getTime();this.request(e,n,i).then(e=>t(null,(0,oq.formatJsonRpcResult)(r,e))).catch(e=>t(e,void 0))}async enable(){if(!this.client)throw Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:ov("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();let{uri:n,response:i}=await this.client.authenticate(e,t);n&&(this.uri=n,this.events.emit("display_uri",n));let r=await i();if(this.session=r.session,this.session){let e=uM(this.session.namespaces);this.namespaces=uO(this.namespaces,e),await this.persist("namespaces",this.namespaces),this.onConnect()}return r}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){let{uri:t,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});t&&(this.uri=t,this.events.emit("display_uri",t));let i=await n();this.session=i;let r=uM(i.namespaces);return this.namespaces=uO(this.namespaces,r),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;let[n,i]=this.validateChain(e),r=this.getProvider(n);r.name===ui?r.setDefaultChain(`${n}:${i}`,t):r.setDefaultChain(i,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");let t=this.client.pairing.getAll();if(ob(t)){for(let n of t)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,t;if(this.client=this.providerOpts.client||await d8.init({core:this.providerOpts.core,logger:this.providerOpts.logger||ue,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(n){throw this.logger.error("Failed to get session",n),Error(`The provided session: ${null==(t=null==(e=this.providerOpts)?void 0:e.session)?void 0:t.topic} doesn't exist in the Sign client`)}else{let e=this.client.session.getAll();this.session=e[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw Error("Sign Client not initialized");if(!this.session)throw Error("Session not initialized. Please call connect() before enable()");let e=[...new Set(Object.keys(this.session.namespaces).map(e=>om(e)))];uF("client",this.client),uF("events",this.events),uF("disableProviderPing",this.disableProviderPing),e.forEach(e
32=>{if(!this.session)return;let t=function(e,t){let n=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!n.length)return[];let i=[];return n.forEach(e=>{let n=t.namespaces[e].accounts;i.push(...n)}),i}(e,this.session),n=uj(t),i=hE(hI({},uO(this.namespaces,this.optionalNamespaces)[e]),{accounts:t,chains:n});switch(e){case"eip155":this.rpcProviders[e]=new uX({namespace:i});break;case"algorand":this.rpcProviders[e]=new u7({namespace:i});break;case"solana":this.rpcProviders[e]=new u2({namespace:i});break;case"cosmos":this.rpcProviders[e]=new u5({namespace:i});break;case"polkadot":this.rpcProviders[e]=new uB({namespace:i});break;case"cip34":this.rpcProviders[e]=new ht({namespace:i});break;case"elrond":this.rpcProviders[e]=new hr({namespace:i});break;case"multiversx":this.rpcProviders[e]=new ho({namespace:i});break;case"near":this.rpcProviders[e]=new hd({namespace:i});break;case"tezos":this.rpcProviders[e]=new hp({namespace:i});break;default:this.rpcProviders[ui]?this.rpcProviders[ui].updateNamespace(i):this.rpcProviders[ui]=new hf({namespace:i})}})}registerEventListeners(){if(typeof this.client>"u")throw Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var t;let{topic:n}=e;n===(null==(t=this.session)?void 0:t.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var t;let{params:n,topic:i}=e;if(i!==(null==(t=this.session)?void 0:t.topic))return;let{event:r}=n;if("accountsChanged"===r.name){let e=r.data;e&&ob(e)&&this.events.emit("accountsChanged",e.map(uR))}else if("chainChanged"===r.name){let e=n.chainId,t=n.event.data,i=om(e),r=uD(e)!==uD(t)?`${i}:${uD(t)}`:e;this.onChainChanged(r)}else this.events.emit(r.name,r.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var n,i;if(e!==(null==(n=this.session)?void 0:n.topic))return;let{namespaces:r}=t,a=null==(i=this.client)?void 0:i.session.get(e);this.session=hE(hI({},a),{namespaces:r}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{var t;e.topic===(null==(t=this.session)?void 0:t.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",hE(hI({},ov("USER_DISCONNECTED")),{data:e.topic})))}),this.on(ua.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[ui]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){let{namespaces:t,optionalNamespaces:n,sessionProperties:i,scopedProperties:r}=e;t&&Object.keys(t).length&&(this.namespaces=t),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.scopedProperties=r}validateChain(e){let[t,n]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,n];if(t&&!Object.keys(this.namespaces||{}).map(e=>om(e)).includes(t))throw Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&n)return[t,n];
32let i=om(Object.keys(this.namespaces)[0]),r=this.rpcProviders[i].getDefaultChain();return[i,r]}async requestAccounts(){let[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,t=!1){if(!this.namespaces)return;let[n,i]=this.validateChain(e);if(!i)return;this.updateNamespaceChain(n,i),this.events.emit("chainChanged",i);let r=this.getProvider(n).getDefaultChain();t||this.getProvider(n).setDefaultChain(i),this.emitAccountsChangedOnChainChange({namespace:n,previousChainId:r,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:t,newChainId:n}){var i,r;try{if(t===n)return;let a=null==(r=null==(i=this.session)?void 0:i.namespaces[e])?void 0:r.accounts;if(!a)return;let s=a.filter(e=>e.includes(`${n}:`)).map(uR);if(!ob(s))return;this.events.emit("accountsChanged",s)}catch(e){this.logger.warn("Failed to emit accountsChanged on chain change",e)}}updateNamespaceChain(e,t){if(!this.namespaces)return;let n=this.namespaces[e]?e:`${e}:${t}`;this.namespaces[n]?this.namespaces[n]&&(this.namespaces[n].defaultChain=t):this.namespaces[n]={chains:[],methods:[],events:[],defaultChain:t}}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,t){var n;let i=(null==(n=this.session)?void 0:n.topic)||"";await this.client.core.storage.setItem(`${ut}/${e}${i}`,t)}async getFromStore(e){var t;let n=(null==(t=this.session)?void 0:t.topic)||"";return await this.client.core.storage.getItem(`${ut}/${e}${n}`)}async deleteFromStore(e){var t;let n=(null==(t=this.session)?void 0:t.topic)||"";await this.client.core.storage.removeItem(`${ut}/${e}${n}`)}async cleanupStorage(){var e;try{if((null==(e=this.client)?void 0:e.session.length)>0)return;for(let e of(await this.client.core.storage.getKeys()))e.startsWith(ut)&&await this.client.core.storage.removeItem(e)}catch(e){this.logger.warn("Failed to cleanup storage",e)}}}let hS=["eth_sendTransaction","personal_sign"],hk=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],hP=["chainChanged","accountsChanged"],hj=["chainChanged","accountsChanged","message","disconnect","connect"];var hO=Object.defineProperty,hN=Object.defineProperties,hR=Object.getOwnPropertyDescriptors,hM=Object.getOwnPropertySymbols,hD=Object.prototype.hasOwnProperty,hU=Object.prototype.propertyIsEnumerable,hL=(e,t,n)=>t in e?hO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hF=(e,t)=>{for(var n in t||(t={}))hD.call(t,n)&&hL(e,n,t[n]);if(hM)for(var n of hM(t))hU.call(t,n)&&hL(e,n,t[n]);return e},hW=(e,t)=>hN(e,hR(t)),h$=(e,t,n)=>hL(e,"symbol"!=typeof t?t+"":t,n);function hB(e){return Number(e[0].split(":")[1])}function hz(e){return`0x${e.toString(16)}`}class hq{constructor(){h$(this,"events",new iO.EventEmitter),h$(this,"namespace","eip155"),h$(this,"accounts",[]),h$(this,"signer"),h$(this,"chainId",1),h$(this,"modal"),h$(this,"rpc"),h$(this,"STORAGE_KEY","wc@2:ethereum_provider:"),h$(this,"on",(e,t)=>(this.events.on(e,t),this)),h$(this,"once",(e,t)=>(this.events.once(e,t),this)),h$(this,"removeListener",(e,t)=>(this.events.removeListener(e,t),this)),h$(this,"off",(e,t)=>(this.events.off(e,t),this)),h$(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){let t=new hq;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,n){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),n)}get connected(){return!!this.signer.client&&this.signer.client.core.relayer.connected}get connecting(){return!!this.signer.client&&this.signer.client.core.relayer.connecting}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);let{required:t,optional:n}=function(e){let{chains:t,optionalChains:n,methods:i,optionalMethods:r,events:a,optionalEvents:s,rpcMap:o}=e;if(!ob(t))throw Error("Invalid chains");let l={chains:t,methods:i||hS,events:a||hP,rpcMap:hF({},t.length?{[hB(t)]:o[hB(t)]}:{})},c=a?.filter(e=>!hP.includes(e)),d=i?.filter(e=>!hS.includes(e));if(!n&&!s&&!r&&!(null!=c&&c.length)&&!(null!=d&&d.length))return{required:t.length?l:void 0};let u={chains:[...new Set(c?.length&&d?.length||!n?l.chains.concat(n||[]):n)],methods:[...new Set(l.methods.concat(null!=r&&r.length?r:hk))],events:[...new Set(l.events.concat(null!=s&&s.length?s:hj))],rpcMap:o};return{required:t.length?l:void 0,optional:n.length?u:void 0}}(this.rpc);try{let i=await new Promise(async(i,r)=>{var a;this.rpc.showQrModal&&(null==(a=this.modal)||a.subscribeModal(e=>{e.open||this.signer.session||(this.signer.abortPairingAttempt(),r(Error("Connection request reset. Please try again.")))}));let s=null!=e&&e.scopedProperties?{[this.namespace]:e.scopedProperties}:void 0;await this.signer.connect(hW(hF({namespaces:hF({},t&&{[this.namespace]:t})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:e?.pairingTopic,scopedProperties:s})).then(e=>{i(e)}).catch(e=>{r(Error(e.message))})});if(!i)return;let r=iH(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:r),this.setAccounts(r),this.events.emit("connect",{chainId:hz(this.chainId)})}catch(e){throw this.signer.logger.error(e),e}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e?.chains});try{let n=await new Promise(async(n,i)=>{var r;this.rpc.showQrModal&&(null==(r=this.modal)||r.subscribeModal(e=>{e.open||this.signer.session||(this.signer.abortPairingAttempt(),i(Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(hW(hF({},e),{chains:this.rpc.chains}),t).then(e=>{n(e)}).catch(e=>{i(Error(e.message))})}),i=n.session;if(i){let e=iH(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:e),this.setAccounts(e),this.events.emit("connect",{chainId:hz(this.chainId)})}return n}catch(e){throw this.signer.logger.error(e),e}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{let{params:t}=e,{event:n}=t;"accountsChanged"===n.name?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===n.name?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",e)}),this.signer.on("accountsChanged",e=>{this.accounts=this.parseAccounts(e),this.events.emit("accountsChanged",this.accounts)}),this.signer.on("chainChanged",e=>{let t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",hz(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",hW(hF({},ov("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,n;this.rpc.showQrModal&&(null==(t=this.modal)||t.closeModal(),null==(n=this.modal)||n.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return"string"==typeof e&&e.startsWith(`${this.namespace}:`)}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){let t=e.filter(e=>this.isCompatibleChainId(e)).map(e=>this.parseChainId(e));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",hz(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){let t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){let[t,n,i]=e.split(":");return{chainId:`${t}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,n;let i=null!=(t=e?.chains)?t:[],r=null!=(n=e?.optionalChains)?n:[],a=i.concat(r);if(!a.length)throw Error("No chains specified in either `chains` or `optionalChains`");let s=i.length?e?.methods||hS:[],o=i.length?e?.events||hP:[],l=e?.optionalMethods||[],c=e?.optionalEvents||[],d=e?.rpcMap||this.buildRpcMap(a,e.projectId),u=e?.qrModalOptions||void 0;return{chains:i?.map(e=>this.formatChainId(e)),optionalChains:r.map(e=>this.formatChainId(e)),methods:s,events:o,optionalMethods:l,optionalEvents:c,rpcMap:d,showQrModal:!!(null!=e&&e.showQrModal),qrModalOptions:u,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){let n={};
32return e.forEach(e=>{n[e]=this.getRpcUrl(e,t)}),n}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?hB(this.rpc.chains):hB(this.rpc.optionalChains),this.signer=await hA.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{let{WalletConnectModal:t}=await Promise.all([n.e(3469),n.e(9398)]).then(n.bind(n,820602));e=t}catch{throw Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(hF({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(e){throw this.signer.logger.error(e),Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;let{chains:t,optionalChains:n,rpcMap:i}=e;t&&ob(t)&&(this.rpc.chains=t.map(e=>this.formatChainId(e)),t.forEach(e=>{this.rpc.rpcMap[e]=i?.[e]||this.getRpcUrl(e)})),n&&ob(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n?.map(e=>
32this.formatChainId(e)),n.forEach(e=>{this.rpc.rpcMap[e]=i?.[e]||this.getRpcUrl(e)}))}getRpcUrl(e,t){var n;return(null==(n=this.rpc.rpcMap)?void 0:n[e])||`https://rpc.walletconnect.org/v1/?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{let e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t?.accounts),this.setAccounts(t?.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return"string"==typeof e||e instanceof String?[this.parseAccount(e)]:e.map(e=>this.parseAccount(e))}}var hV=n(312676),hH=n(905433),hG=n(565095),hK=n(557156),hJ=n(219722),hZ=n(961517),hY=n(751280),hQ=n(968072),hX=n(385037),h0=n(448496),h1=n(210960),h2=n(696377),h3=n(40947),h4=n(817044),h5=n(508596),h6=n(869964),h8=n(798085),h7=n(78350),h9=n(447022),pe=n(225903),pt=n(239959),pn=n(992720),pi=n(157811),pr=n(782202),pa=n(920676),ps=n(407996),po=n(942143),pl=n(831505),pc=n(255685),pd=n(654023),pu=n(747994),ph=n(10967),pp=n(547197),pm=n(171246),py=n(611864),pf=n(800378),pg=n(754094),pw=n(433745),pv=n(452394),pb=n(679894),px=n(925067),p_=n(869159),pC=n(194537),pI=n(345872),pE=n(679585),pT=n(686925),pA=n(774831),pS=n(715599).Buffer;function pk(e){return e?{"privy-ui":"t"}:void 0}class pP{async authenticate(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new n6.P("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(n6.p,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw(0,n6.f)(e)}}async link(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new n6.P("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(n6.b,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw(0,n6.f)(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new n6.P("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new n6.P("Email must be set when initialzing authentication.");let i=pk(n);try{return await this.api.post(n6.c,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...i}})}catch(e){throw(0,n6.f)(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class pj extends pP{async link(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new n6.P("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(n6.u,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw(0,n6.f)(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class pO{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e)}del(e){localStorage.removeItem(e)}getKeys(){return Object.entries(localStorage).map(([e])=>e)}}function pN(){try{let e="privy:__session_storage__test",t=new pO;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var pR="undefined"!=typeof window&&window.localStorage?new pO:new class{get(e){return this._cache[e]}put(e,t){void 0!==t?this._cache[e]=t:this.del(e)}del(e){delete this._cache[e]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};let pM=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom||"isPhantom"in e?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,pD=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;
32if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==pM(e))return!1;if(e.providers){for(let t of e.providers)if(!pD(t))return!1}return!0},pU=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0}return!1},pL=(e,t,n,i)=>{let r=Number(e),a=t.find(e=>e.id===r);if(!a)throw new n6.d(`Unsupported chainId ${e}`,4901);return(0,n7.l)({transport:(0,n9.L)(pF(a,n,i.appId)),chain:a})},pF=(e,t,n)=>{let i,r=e.id,a=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])i=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[a])i=t.rpcUrls[a];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",n),i=t.toString()}else i=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!i)throw new n6.d(`No RPC url found for ${r}`);return i},pW=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),p$=(e,t=3,n=4,i="ethereum")=>{if(!e)return"";let r=2*("ethereum"===i);return t+n+r+3>=e.length?e:`${e.slice(0,r+t)}...${e.slice(e.length-n,e.length)}`},pB=(e,t=3,n=4)=>p$(e,t,n,"solana"),pz=e=>new Promise(t=>setTimeout(t,e)),pq=(e,t={})=>{let n=t.delayMs||150,i=t.maxAttempts||270;return new Promise(async(r,a)=>{let s=!1,o=0;for(;!s&&o<i;){if(t.abortSignal?.aborted)return;e().then(e=>{s=!0,r(e)},(...e)=>{s=!0,a(...e)}),o+=1,await pz(n)}s||a(Error("Exceeded max attempts before resolving function"))})},pV=(e,t,n={},i={})=>{let r=new URL(t,e);for(let[e,t]of Object.entries(n))void 0!==t&&r.searchParams.set(e,t);let a=Object.entries(i);if(a.length>0){let e=new URLSearchParams;for(let[t,n]of a)e.append(t,n);r.hash=e.toString()}return r.href},pH=e=>"string"==typeof e?e:"0x"+e.toString(16);async function pG({store:e,walletList:t,externalWalletConfig:n,walletChainType:i,timeout:r=3e3}){let a=!1,s=window;return new Promise(o=>{function l(){if(a)return;a=!0,window.removeEventListener("ethereum#initialized",l);let r=e.getProviders();console.debug("Detected injected providers:",r.map(e=>e.info));let s=[];for(let e of r)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===i&&"app.phantom"===e.info.rdns||s.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==i)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let n=[];if(t.providers?.length)for(let e of t.providers)e&&n.push(e);return n.push(e.ethereum),n}()){let t=pM(e);if(!r.some(e=>e.info.name===t)){if(pD(e,!0)&&!s.find(e=>"metamask"===e.type)){s.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!s.find(e=>"phantom"===e.type)){s.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!s.find(e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==n.coinbaseWallet?.config?.preference?.options)){s.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}s.find(e=>"unknown_browser_extension"===e.type)||s.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}o(s)}s.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout(()=>{l()},r))})}function pK(e){return`eip155:${String(Number(e))}`}let pJ=(e,t,n,i)=>{let r=Number(e),a=t.find(e=>e.id===r);if(!a)throw new n6.d(`Unsupported chainId ${e}`,4901);return pF(a,n,i)},pZ=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},n=e.types.EIP712Domain??Object.entries(e.domain).map(([e,n])=>{if(null!=n&&"string"==typeof e&&e in t)return{name:e,type:t[e]}}).filter(e=>void 0!==e);return{...e,types:{...e.types,EIP712Domain:n}}},pY=["c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96","4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0","225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f","1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369","c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb2870
325e95034a","ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18","bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6","74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d","afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7","f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d","84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04","0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150","38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662","9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0","c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576","8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4","e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4","f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2","138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98","47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83","7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26","8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3","031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa","2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568","dd43441a6368ec9046540c46c5fdc58f79926d1
327ce61a176444568ca7c970dcd","2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01","b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f","0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92","719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3","942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef","8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2","07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80","8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819","bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a","cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e","94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43","2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715","14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc","576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd","49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd","19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b","5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b","d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b","50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b","9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8","6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa","41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071","14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd","a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1","971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709","18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1","15c8b91ade1a4e58f3ce4e7a0dd7f42b47db0c8df7e0d84f63eb39bcb96c4e0f","541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf"];function pQ(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let pX="WALLETCONNECT_DEEPLINK_CHOICE";function p0(e){return e.startsWith("http://")||e.startsWith("https://")}function p1(e,t){if(p0(e))return p2(e,t);let n=e;return n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function p2(e,t){if(!p0(e))return p1(e,t);let n=e;return n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function p3(e,t){window.open(e,t,"noreferrer noopener")}class p4{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}class p5{get meta(){return this._meta}async authenticate(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.channelToken)throw new n6.P("Auth flow must be initialized first");try{let e=await this.api.post(n6.e,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new n6.P("No response from authentication");return e}catch(e){throw(0,n6.f)(e)}}async link(){if(!this.api)throw new n6.P("Auth flow has no API instance");try{return await this.api.post(n6.g,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw(0,n6.f)(e)}}async _startChannelOnce(){if(!this.api)throw new n6.P("Auth flow has no API instance");let e=await this.api.post(n6.h,{token:this.captchaToken});y.Fr&&!y.un&&e.connect_uri&&p3(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new n6.P("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.channelToken)throw new n6.P("Auth flow must be initialized first");let e=await this.api.get(n6.i,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1}
32,this.captchaToken=e,this.startChannelOnce=new p4(this._startChannelOnce.bind(this)),this.pollForReady=new p4(this._pollForReady.bind(this)),this._meta.disableSignup=t}}let p6="https://auth.privy.io",p8="privy:token",p7="privy-token",p9="privy:refresh_token",me="privy:pat",mt="privy:id_token",mn="privy-id-token",mi="privy-session",mr="privy:caid",ma=e=>`privy:guest:${e}`,ms=e=>`privy:cross-app:${e}`,mo="privy:state_code",ml="privy:code_verifier",mc="privy:headless_oauth",md="privy:oauth_disable_signup",mu=e=>`privy:wallet:${e}`,mh="privy:connectors",mp="privy:connections";function mm(e){return crypto.getRandomValues(new Uint8Array(e))}function my(){return tT.l(mm(36))}async function mf(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return tT.l(t)}}class mg{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new n6.P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new n6.P("User denied confirmation during OAuth flow");let e=function(){let e=pR.get(ml);if(!e)throw new n6.P("Authentication error.");return e}();try{let t=await this.api.post(n6.o,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return pR.del(ml),pR.del(mc),pR.del(md),t}catch(t){let e=(0,n6.f)(t);if(e.privyErrorCode)throw new n6.P(e.message||"Invalid code during OAuth flow.",void 0,e.privyErrorCode);if("User denied confirmation during OAuth flow"===e.message)throw new n6.P("Invalid code during oauth flow.",void 0,n6.a.OAUTH_USER_DENIED);throw new n6.P("Invalid code during OAuth flow.",void 0,n6.a.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new n6.P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new n6.P("User denied confirmation during OAuth flow");let e=pR.get(ml);if(!e)throw new n6.P("Authentication error.");try{let t=await this.api.post(n6.j,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return pR.del(ml),t}catch(e){throw(0,n6.f)(e)}}async getAuthorizationUrl(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.provider)throw new n6.P("Provider must be set when initializing OAuth authentication.");let e=my();pR.put(ml,e);let t=my();pR.put(mo,t);let n=await mf(e);this.meta.withPrivyUi||pR.put(mc,!0),this.meta.disableSignup?pR.put(md,!0):pR.del(md);let i=pk(this.meta.withPrivyUi);try{return await this.api.post(n6.k,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...i}})}catch(e){throw(0,n6.f)(e)}}constructor(e){this.meta=e}}function mw(e){return e.charAt(0).toUpperCase()+e.slice(1)}let mv=({style:e,...t})=>(0,h.jsxs)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...e},...t,children:[(0,h.jsx)("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),(0,h.jsx)("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089
32C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]}),mb=({style:e,...t})=>(0,h.jsxs)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...e},...t,children:[(0,h.jsx)("g",{clipPath:"url(#clip0)",children:(0,h.jsx)("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),(0,h.jsx)("defs",{children:(0,h.jsx)("clipPath",{id:"clip0",children:(0,h.jsx)("rect",{width:"71",height:"55",fill:"white"})})})]}),mx=({style:e,...t})=>(0,h.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...t,children:(0,h.jsx)("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.3
3262 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})}),m_=({style:e})=>(0,h.jsx)(pp.A,{style:{color:"var(--privy-color-error)",...e}}),mC=({style:e,...t})=>(0,h.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...e},...t,children:[(0,h.jsx)("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),(0,h.jsx)("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),(0,h.jsx)("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),(0,h.jsx)("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});function mI(e){return(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...e,children:[(0,h.jsxs)("defs",{children:[(0,h.jsxs)("linearGradient",{id:"b",children:[(0,h.jsx)("stop",{offset:"0",stopColor:"#3771c8"}),(0,h.jsx)("stop",{stopColor:"#3771c8",offset:".128"}),(0,h.jsx)("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),(0,h.jsxs)("linearGradient",{id:"a",children:[(0,h.jsx)("stop",{offset:"0",stopColor:"#fd5"}),(0,h.jsx)("stop",{offset:".1",stopColor:"#fd5"}),(0,h.jsx)("stop",{offset:".5",stopColor:"#ff543e"}),(0,h.jsx)("stop",{offset:"1",stopColor:"#c837ab"})]}),(0,h.jsx)("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),(0,h.jsx)("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),(0,h.jsx)("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),(0,h.jsx)("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.
32004 1)"}),(0,h.jsx)("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}function mE(e){return(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 320",width:24,height:24,...e,children:(0,h.jsx)("g",{children:(0,h.jsxs)("g",{children:[(0,h.jsx)("rect",{fill:"#06c755",width:"320",height:"320",rx:"72.14"}),(0,h.jsx)("path",{fill:"#fff",d:"M266.66,144.92c0-47.74-47.86-86.58-106.69-86.58S53.28,97.18,53.28,144.92c0,42.8,38,78.65,89.22,85.42,3.48.75,8.21,2.29,9.4,5.26,1.08,2.7.71,6.93.35,9.65,0,0-1.25,7.53-1.52,9.13-.47,2.7-2.15,10.55,9.24,5.76s61.44-36.18,83.82-61.95h0C259.25,181.24,266.66,164,266.66,144.92Z"}),(0,h.jsx)("path",{fill:"#06c755",d:"M231.16,172.49h-30a2,2,0,0,1-2-2v0h0V123.94h0v0a2,2,0,0,1,2-2h30a2,2,0,0,1,2,2v7.57a2,2,0,0,1-2,2H210.79v7.85h20.37a2,2,0,0,1,2,2V151a2,2,0,0,1-2,2H210.79v7.86h20.37a2,2,0,0,1,2,2v7.56A2,2,0,0,1,231.16,172.49Z"}),(0,h.jsx)("path",{fill:"#06c755",d:"M120.29,172.49a2,2,0,0,0,2-2v-7.56a2,2,0,0,0-2-2H99.92v-37a2,2,0,0,0-2-2H90.32a2,2,0,0,0-2,2v46.53h0v0a2,2,0,0,0,2,2h30Z"}),(0,h.jsx)("rect",{fill:"#06c755",x:"128.73",y:"121.85",width:"11.64",height:"50.64",rx:"2.04"}),(0,h.jsx)("path",{fill:"#06c755",d:"M189.84,121.85h-7.56a2,2,0,0,0-2,2v27.66l-21.3-28.77a1.2,1.2,0,0,0-.17-.21v0l-.12-.12,0,0-.11-.09-.06,0-.11-.08-.06,0-.11-.06-.07,0-.11,0-.07,0-.12,0-.08,0-.12,0h-.08l-.11,0h-7.71a2,2,0,0,0-2,2v46.56a2,2,0,0,0,2,2h7.57a2,2,0,0,0,2-2V142.81l21.33,28.8a2,2,0,0,0,.52.52h0l.12.08.06,0,.1.05.1,0,.07,0,.14,0h0a2.42,2.42,0,0,0,.54.07h7.52a2,2,0,0,0,2-2V123.89A2,2,0,0,0,189.84,121.85Z"})]})})})}function mT({style:e,...t}){return(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...e},...t,children:(0,h.jsx)("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:(0,h.jsx)("g",{transform:"scale(5.12,5.12)",children:(0,h.jsx)("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}function mA(e){return(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...e,children:[(0,h.jsx)("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),(0,h.jsx)("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}function mS(e){return(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...e,children:[(0,h.jsx)("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),(0,h.jsx)("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259
32-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),(0,h.jsx)("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}let mk=({style:e,...t})=>(0,h.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...e},...t,children:(0,h.jsx)("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})}),mP={google:{name:"Google",component:mC},discord:{name:"Discord",component:mb},github:{name:"Github",component:mx},linkedin:{name:"LinkedIn",component:mT},twitter:{name:"Twitter",component:mk},spotify:{name:"Spotify",component:mA},instagram:{name:"Instagram",component:mI},tiktok:{name:"Tiktok",component:mS},line:{name:"LINE",component:mE},apple:{name:"Apple",component:mv}},mj=e=>e in mP?mP[e]:{name:"Unknown",component:m_};function mO(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),pR.del(mo),window.history.replaceState({},"",e)}class mN{async initRegisterFlow(e){if(!this.api)throw new n6.P("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new n6.P("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new n6.P("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await n.e(1190).then(n.bind(n,601190));if(!this.api)throw new n6.P("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new n6.P("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(n6.l,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new n6.P("Passkey request timed out or rejected by user.",void 0,n6.a.PASSKEY_NOT_ALLOWED);throw(0,n6.f)(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await n.e(1190).then(n.bind(n,601190));if(!this.api)throw new n6.P("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new n6.P("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map(e=>({type:"public-key",id:e}))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let n=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(n6.m,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new n6.P("Passkey request timed out or rejected by user.",void 0,n6.a.PASSKEY_NOT_ALLOWED);throw(0,n6.f)(e)}}async link(){let e=await n.e(1190).then(n.bind(n,601190));if(!this.api)throw new n6.P("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new n6.P("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(n6.n,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new n6.P("Passkey request timed out or rejected by user.",void 0,n6.a.PASSKEY_NOT_ALLOWED);throw(0,n6.f)(e)}}async _initRegisterOnce(e){if(!this.api)throw new n6.P("Auth flow has no API instance");let t=pk(e);return await this.api.post(n6.q,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new n6.P("Auth flow has no API instance");let t=pk(e);return await this.api.post(n6.r,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new n6.P("Auth flow has no API instance");return await this.api.post(n6.s,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map(e=>({type:e.type,alg:e.alg})),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map(e=>({id:e.id,type:e.type,transports:e.transports})),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_i
32d:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map(e=>({id:e.id,type:e.type,transports:e.transports}))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new p4(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new p4(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new p4(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}let mR=({address:e,chainId:t,nonce:n})=>`${window.location.host} wants you to sign in with your Ethereum account:
33${e}
34
35By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.
36
37URI: ${window.location.origin}
38Version: 1
39Chain ID: ${t}
40Nonce: ${n}
41Issued At: ${(new Date).toISOString()}
42Resources:
43- https://privy.io`;class mM{get meta(){return{connectorType:this.wallet?.connectorType,walletClientType:this.wallet?.walletClientType,chainId:this.wallet?.chainId,address:this.wallet?.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new n6.P("SiweFlow has no client instance");try{if(this.preparedMessage&&this.signature)return await this.client.authenticateWithSiweInternal({message:this.preparedMessage,signature:this.signature,chainId:this.wallet?.chainId,walletClientType:this.wallet?.walletClientType,connectorType:this.wallet?.connectorType,mode:this._meta.disableSignup?"no-signup":"login-or-sign-up"});if(!this.wallet)throw new n6.P("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw(0,n6.f)(e)}}async link(){if(!this.client)throw new n6.P("SiweFlow has no client instance");try{if(!this.wallet)throw new n6.P("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw(0,n6.f)(e)}}async sign(){if(!this.client)throw new n6.P("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new n6.P("Could not prepare SIWE message");if(!this.wallet)throw new n6.P("SiweFlow has no wallet instance");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new n6.P("SiweFlow has no client instance");if(!this.wallet)throw new n6.P("UI SiweFlow has no wallet instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new n6.P("SiweFlow has no client instance");if(!this.wallet)throw new n6.P("SiweFlow has no wallet instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=mR({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,i=!1,r){this._meta={disableSignup:!1}
43,this.getNonceOnce=new p4(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=n,this.client=e,this._meta.disableSignup=i,this.preparedMessage=r?.message,this.signature=r?.signature}}let mD=(...e)=>{if(void 0===pS)throw new n6.P("Buffer is not defined.",void 0,n6.a.BUFFER_NOT_DEFINED);return pS.from(...e)};class mU{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup,messageType:this._meta.messageType}}set messageType(e){this._meta.messageType=e}async authenticate(){if(!this.client)throw new n6.P("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up",messageType:this.meta.messageType})}catch(e){throw(0,n6.f)(e)}}async link(){if(!this.client)throw new n6.P("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,messageType:this.meta.messageType})}catch(e){throw(0,n6.f)(e)}}async sign(){let e,t;if(!this.client)throw new n6.P("SiwsFlow has no client instance");await this.buildMessage();let n="transaction"===this.meta.messageType;if(!this.preparedMessage)throw new n6.P("Could not prepare SIWS message");if(!n&&!this.wallet.signMessage||n&&!this.wallet.signTransaction)throw new n6.P("Wallet does not support the necessary signing methods");if(n&&this._siwsTransactionMethods){let n=await this.wallet.signTransaction(this._siwsTransactionMethods.deserializeTransactionFromB64String(this.preparedMessage));e=n.serialize().toString("base64"),t=mD(n.signatures[0]?.signature??pS.from("missing signature")).toString("base64")}else e=this.preparedMessage,t=mD(await this.wallet.signMessage(mD(this.preparedMessage))).toString("base64");return{message:e,signature:t}}async _getNonceOnce(){if(!this.client)throw new n6.P("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new n6.P("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),"transaction"===this.meta.messageType&&this._siwsTransactionMethods?this.preparedMessage=this._siwsTransactionMethods.prepareSiwsTransactionWithMemo({address:e,nonce:this.nonce}):this.preparedMessage=(({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:
44${e}
45
46You are proving you own ${e}.
47
48URI: ${window.location.origin}
49Version: 1
50Chain ID: mainnet
51Nonce: ${t}
52Issued At: ${(new Date).toISOString()}
53Resources:
54- https://privy.io`)({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,i=!1,r="plain",a){this._meta={disableSignup:!1,messageType:"plain"},this.getNonceOnce=new p4(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=n,this.client=t,this._meta.disableSignup=i,this._meta.messageType=r,this._siwsTransactionMethods=a}}class mL{async authenticate(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new n6.P("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(n6.t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw(0,n6.f)(e)}}async link(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new n6.P("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(n6.v,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw(0,n6.f)(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new n6.P("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new n6.P("phone nNumber must be set when initialzing authentication.");let i=pk(n);try{return await this.api.post(n6.w,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...i}})}catch(e){throw(0,n6.f)(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:n}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:n??!1}}}class mF extends mL{async link(){if(!this.api)throw new n6.P("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new n6.P("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(n6.x,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw(0,n6.f)(e)}}constructor(e,t,n){super({phoneNumber:t,captchaToken:n}),this.meta={phoneNumber:t,captchaToken:n,oldPhoneNumber:e,disableSignup:!1}}}let mW=(0,m.createContext)({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:n8.a,setError:n8.a,setExecuting:n8.a,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:n8.a,reset:n8.a,execute:n8.a});class m$ extends n6.y{constructor(e,t,n){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=n}}let mB=({children:e,id:t,captchaSiteKey:n,captchaEnabled:i})=>{let r=(0,m.useRef)(null),[a,s]=(0,m.useState)(),[o,l]=(0,m.useState)(),[c,d]=(0,m.useState)(!1),u=(0,m.useMemo)(()=>i?c||a||o?!c||a||o?a&&!o?{status:"success",token:a}:o?{status:"error",error:o}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"},[i,a,o,c]);return(0,h.jsx)(mW.Provider,{value:{...u,ref:r,enabled:i,siteKey:n,appI
54d:t,setToken:s,setError:l,setExecuting:d,remove(){i&&(r.current?.remove(),d(!1),l(void 0),s(void 0))},reset(){i&&(r.current?.reset(),d(!1),l(void 0),s(void 0))},execute(){i&&(d(!0),r.current?.execute())},async waitForResult(){if(!i)return"";try{return await function(e,{interval:t=100,timeout:n=5e3}={}){return new Promise((i,r)=>{let a,s=0,o=()=>{s>=n?r("Max attempts reached without result"):(a=e(),s+=t,null==a?setTimeout(o,t):i(a))};o()})}(()=>r.current?.getResponse(),{interval:200,timeout:2e4})}catch(e){throw new m$("Captcha failed",null,n6.a.CAPTCHA_TIMEOUT)}}},children:e})},mz=()=>(0,m.useContext)(mW);class mq{async authenticate(){if(!this.api)throw new n6.P("Auth flow has no API instance");try{return await this.api.post(n6.z,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw(0,n6.f)(e)}}async link(){if(!this.api)throw new n6.P("Auth flow has no API instance");try{return await this.api.post(n6.A,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw(0,n6.f)(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function mV(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===n6.a.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===n6.a.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===n6.a.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===n6.a.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===n6.a.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===n6.a.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===n6.a.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof m$&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function mH(e){return Object.fromEntries(decodeURIComponent(e).split("&").map(e=>e.split("=").map(decodeURIComponent)))}function mG(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}class mK{static parse(e){try{return new mK(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return eY.i(e),e}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=eY.i(e)}}class mJ extends mK{static parse(e){try{return new mJ(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}let mZ=e=>{if("ethereum"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier"};if("solana"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"solana-address-ver
54ifier"};throw Error("Failed to get account entropy details")},mY=(e,t)=>{if(t?.imported)return mZ(t);let n=(0,ic.h)(e);if(!n)throw Error("Failed to find primary wallet");return mZ(n)},mQ=({style:e,...t})=>(0,h.jsxs)("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,h.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,h.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"})]});class mX extends n6.d{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class m0 extends n6.d{constructor(){super("User rejected connection"),this.type="wallet_error"}}let m1=e=>e instanceof n6.d?e:e?.code?new m3(e):new n6.d("Unknown connector error",e);class m2 extends n6.y{constructor(e,t,n){super(e),this.type="provider_error",this.code=t,this.data=n}}class m3 extends m2{constructor(e){super(e.message,e.code,e.data);let t=Object.values(E).find(t=>t.eipCode===e.code);this.details=t||E.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=E.E32002_CONNECTION_ALREADY_PENDING:this.details=E.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=E.E32002_WALLET_LOCKED))}}let m4={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},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...E};function m5(e){return"ethereum"===e.type}function m6(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i?.address!==r?.address||i&&r&&m5(i)&&m5(r)&&i?.chainId!==r?.chainId||i?.connectorType!==r?.connectorType||i?.connectedAt!==r?.connectedAt||i?.walletClientType!==r?.walletClientType||i?.isConnected!==r?.isConnected||i?.linked!==r?.linked)return!1}return!0}class m8 extends tn.A{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}let m7=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||12e4;function m9(e){return"ethereum"===e.chainType}class ye extends m8{buildConnectedWallet(e,t,n,i){let r=async()=>!!this.wallets.find(t=>(0,f.b)(t.address)===(0,f.b)(e));return{type:"ethereum",address:(0,f.b)(e),chainId:t,meta:n,imported:i,switchChain:async n=>{let i,a;if(!r)throw new n6.d("Wallet is not currently connected.");let s=this.wallets.find(t=>(0,f.b)(t.address)===(0,f.b)(e))?.chainId;if(!s)throw new n6.d("Unable to determine current chainId.");if("number"==typeof n?(i=`0x${n.toString(16)}`,a=n):(i=n,a=Number(n)),s===pK(i))return;let o=this.chains.find(e=>e.id===a);if(!o)throw new n6.d(`Unsupported chainId: ${n}`);let l=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:i}]})};try{return await l()}catch(e){if(((e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");case"rabby_wallet":return e.message.includes("Unrecognized chain ID");default:return 4902===e.code||e.message?.includes("4902")}})(e,this.walletClientType))return"rabby_wallet"===this.walletClientType&&await pz(300),await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:i,chainName:o.name,nativeCurrency:o.nativeCurrency,rpcUrls:[o.rpcUrls.default?.http[0]??""],blockExplorerUrls:[o.blockExplorers?.default.url??""]}]}),l();if("rainbow"===this.walletClientType&&e.message?.includes("wallet_switchEthereumChain"))throw new n6.d(`Rainbow does not support the chainId ${t}`);throw e}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:r,getEthereumProvider:async()=>
54{if(!await r())throw new n6.d("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await r())throw new n6.d("Wallet is not currently connected.");return await this.sign(e)},disconnect:()=>{this.disconnect()}}}async syncAccounts(e){let t,n=e;try{if(void 0===n){let e=await pq(()=>this.proxyProvider.request({method:"eth_accounts"}),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,e),Array.isArray(e)&&(n=e)}}catch(e){console.debug("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",e)}if(!n||!Array.isArray(n)||n.length<=0||!n[0])return;let i=n[0],r=(0,f.b)(i),a=[];if("privy"===this.walletClientType){let e=pR.get(mu(r));this.chains.find(t=>t.id===Number(e))||(pR.del(mu(r)),e=null),t=e||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}catch(e){console.warn(`Unable to switch embedded wallet to chain ID ${t} on initialization`)}}else try{let e=await pq(()=>this.proxyProvider.request({method:"eth_chainId"}),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,e),"string"==typeof e)t=e;else{if("number"!=typeof e)throw Error("Invalid chainId returned from provider");t=`0x${e.toString(16)}`}}catch(e){console.warn("Failed to get chainId from provider, defaulting to 0x1",e),t="0x1"}let s=pK(t);if(!a.find(e=>(0,f.b)(e.address)===r)){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};a.push(this.buildConnectedWallet((0,f.b)(i),s,e,"embedded_imported"===this.connectorType))}m6(a,this.wallets)||(this.wallets=a,this.emit("walletsUpdated"))}async getConnectedWallet(){let e=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort((e,t)=>t.connectedAt-e.connectedAt).find(t=>e.find(e=>(0,f.b)(e)===(0,f.b)(t.address)))||null}async isConnected(){let e=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0}async sign(e){return await this.connect({showPrompt:!1}),this.proxyProvider.request({method:"personal_sign",params:[(0,g.nj)(e),this.wallets[0]?.address]})}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}constructor(e,t,n,i){super(e),this.chainType="ethereum",this.onAccountsChanged=e=>{0===e.length?this.onDisconnect():this.syncAccounts(e)},this.onChainChanged=e=>{this.wallets.forEach(t=>{t.chainId=pK(e),"privy"===this.walletClientType&&pR.put(mu(t.address),e)}),this.emit("walletsUpdated")},this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")},this.onConnect=async()=>{this.connected=!0,"coinbase_wallet"===this.connectorType&&await pz(500),this.syncAccounts()},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=n,this.rpcConfig=i,this.rpcTimeoutDuration=m7(i,e),this.connected=!1,this.initialized=!1}}class yt{on(e,t){if(this.walletProvider)return this.walletProvider.on(e,t);this._subscriptions.push({eventName:e,listener:t})}async request(e){if(!this.walletProvider)throw new n6.d(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),this.walletTimeout()]).catch(e=>{throw m1(e)})}constructor(e,t){this.removeListener=(e,t)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(e,t)}catch(e){console.warn("Unable to remove wallet provider listener")}},this.walletTimeout=(e=new mX,t=this.rpcTimeoutDuration)=>new Promise((n,i)=>setTimeout(()=>{i(e)},t)),this.setWalletProvider=e=>
54{this.walletProvider&&this._subscriptions.forEach(e=>{this.removeListener(e.eventName,e.listener)}),this.walletProvider=e,this._subscriptions.forEach(e=>{this.walletProvider?.on(e.eventName,e.listener)})},this.walletProvider=e,this.rpcTimeoutDuration=t||12e4,this._subscriptions=[]}}let yn=[1,0xaa36a7,137,10,8453,84532,42161,7777777,43114,56];class yi extends ye{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new n6.d("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw m1(e)}}updateConnectionPreference(e){this.coinbaseWalletConfig={...this.coinbaseWalletConfig,preference:{...this.coinbaseWalletConfig.preference,options:e}},this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",i=(0,id._)({...this.coinbaseWalletConfig}),this.proxyProvider.setWalletProvider(i.getProvider())}constructor(e,t,n,r){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new yt(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.coinbaseWalletConfig={...r,appChainIds:[t.id].concat(e.map(e=>e.id))},this.walletClientType="smartWalletOnly"===this.coinbaseWalletConfig.preference?.options?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!i){let e="eoaOnly"!==this.coinbaseWalletConfig.preference?.options?(this.coinbaseWalletConfig.appChainIds??[]).filter(e=>!yn.includes(e)):[];e.length>0&&!e.every(e=>A.o.has(e))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${e.join(", ")}`),i=(0,id._)(this.coinbaseWalletConfig)}this.proxyProvider.setWalletProvider(i.getProvider())}}let yr=({...e})=>(0,h.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,h.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:e.color||"var(--privy-color-foreground-3)"})});class ya extends ye{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[pH(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:yr,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}constructor({provider:e,chains:t,defaultChain:n,rpcConfig:i,imported:r,walletIndex:a}){super("privy",t,n,i),this.connectorType="embedded",this.proxyProvider=e,this.walletIndex=a,r&&(this.connectorType="embedded_imported"),this.subscribeListeners()}}let ys=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];
54class yo extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}class yl extends tn.A{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new yo(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await A7()||!this.address)throw new yo("Disconnected",4900);let{hash:n}=await Sn(t,{address:this.address});return n}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new yo(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await A7()||!this.address)throw new yo("Disconnected",4900);let{signature:n}=await St(t,{address:this.address});return n}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new yo(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new yo(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=pL(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],n=e.params[1],{signature:i}=await A9({message:t},{address:n});return i}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],n="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:i}=await Se(pZ(n),{address:t});return i}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:pH(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...im(t)})}async request(e){let t;switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return pH(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(t=e.method,!ys.includes(t))return this.publicClient.request({method:e.method,params:e.params});{let t=await A7();if(await Si({address:this.address}),!t||!this.address)throw new yo("Disconnected",4900);try{let n={method:e.method,params:e.params},i=this.walletAccount;return i&&(0,ic.c)(i)?this.handleWalletApiRequest(n,i,t):(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:n})).response.data}catch(e){throw console.error(e),new yo("Disconnected",4900)}}}async handleWalletApiRequest(e,t,n){let i=this.privyClient;if(!i)throw new yo("Disconnected",4900);if("secp256k1_sign"===e.method){let r=await M(i,async({message:e})=>this.walletProxy.signWithUserSigner({accessToken:n,message:e}),{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:e.params[0]}});if("secp256k1_sign"!==r.method)throw new yo(`Invalid params for ${e.method}`,4200);return r.data.signature}throw new yo(`Method not supported: ${e.method}`,4200)}constructor({walletProxy:e,address:t,entropyId:n,entropyIdVerifier:i,rpcConfig:r,chains:a,appId:s,chainId:o=1,walletIndex:l,privyClient:c,walletAccount:d}){super(),this.walletProxy=e,this.address=t,this.entropyId=n,this.entropyIdVerifier=i,this.chainId=o,this.rpcConfig=r,this.chains=a,this.publicClient=pL(o,this.chains,r,{appId:s}),this.rpcTimeoutDuration=m7(r,"privy"),this.appId=s,this.walletIndex=l,this.privyClient=c,this.walletAccount=d}}class yc extends ye{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}
54async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:n,walletClientType:i,defaultChain:r}){super(i,[],r,{}),this.connectorType="null",this.proxyProvider=new yt(void 0,12e4),this.id=e,this.name=t,this.icon=n,this.connectorType=i}}let yd=({style:e,...t})=>(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...e},...t,children:(0,h.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})}),yu=({style:e,...t})=>(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...e},...t,children:[(0,h.jsx)("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),(0,h.jsx)("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),(0,h.jsx)("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),(0,h.jsx)("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),(0,h.jsx)("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),(0,h.jsx)("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),(0,h.jsx)("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),(0,h.jsx)("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),(0,h.jsx)("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),(0,h.jsx)("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),(0,h.jsx)("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),(0,h.jsx)("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),(0,h.jsx)("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]}),yh=({style:e,...t})=>(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...e},...t,children:[(0,h.jsx)("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),(0,h.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});function yp(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var ym=0;class yy extends ye{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit
54("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new n6.d("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw m1(e)}}constructor(e,t,n,i,r){super(r||"unknown",e,t,n),this.connectorType="injected",this.proxyProvider=new yt(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=i;let a=i.provider;this.proxyProvider.setWalletProvider(a)}}var yf="__private_"+ym+++"__walletBranding";class yg extends ye{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return yp(this,yf)[yf]??{name:"Browser Extension",icon:yd,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new n6.d("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw m1(e)}}constructor(e,t,n,i,r){super(r??"unknown",e,t,n),Object.defineProperty(this,yf,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new yt(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(i),"metamask"===r?yp(this,yf)[yf]={name:"MetaMask",icon:yu,id:"io.metamask"}:"phantom"===r&&(yp(this,yf)[yf]={name:"Phantom",icon:yh,id:"phantom"})}}class yw extends yy{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{y.Fr||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new n6.d("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw m1(e)}}}let yv=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","crypto.com_wallet_extension","crypto.com_onchain","binance","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","privy","unknown","phantom","solflare","glow","backpack"],yb=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:y.gm?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let i=y_({client:this.client,isSolana:t,connectOnly:n});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${i}?ref=${i}`}},solflare:{client:"solflare",name:"Solflare",installLink:y.gm?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let i=y_({client:this.client,isSolana:t,connectOnly:n});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${i}?ref=${i}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcb
54cmnbpgliof",chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let i=y_({client:this.client,isSolana:t,connectOnly:n});return`${e?"backpack://ul/v1/":"https://backpack.com/ul/v1/"}browse/${i}?ref=${i}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",chainTypes:["solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return"https://www.okx.com/download?deeplink="+encodeURIComponent("okx://wallet/dapp/url?dappUrl="+y_({client:this.client,isSolana:e,connectOnly:t}))}}});function yx({connectorType:e,walletClientType:t}){for(let n of yv)if(e===n||t===n)return yb[n]}function y_({client:e,isSolana:t,connectOnly:n}){let i=new URL(window.location.href);return i.searchParams.set("privy_connector",t?"solana_adapter":"injected"),i.searchParams.set("privy_wallet_client",e),i.searchParams.set("privy_connect_only",String(n)),encodeURIComponent(i.href.replace(/\/$/g,""))}let yC=()=>{let e=pR.get(mp);return e&&Array.isArray(e)&&e.map(e=>(e=>e&&"string"==typeof e.address&&"string"==typeof e.connectorType&&"string"==typeof e.walletClientType&&"number"==typeof e.connectedAt)(e)).every(Boolean)?e:[]},yI=["phantom","glow","solflare","backpack","okx_wallet","walletconnect"];function yE(e){return"solana"===e.chainType}function yT(e){return"solana"===e.type}class yA extends m8{get isInstalled(){return"Installed"===this.adapter.readyState}get wallet(){return this.adapter.wallet}buildConnectedWallet(e,t){let n,i,r,a;if("Installed"!==e.readyState||!e.publicKey)throw Error("Wallet is not connected.");return"signMessage"in e&&(n=async(...t)=>{if(!e.connected)throw Error("Wallet is not connected.");return await e.signMessage(t[0])}),"sendTransaction"in e&&(i=async(...t)=>await e.sendTransaction(t[0],t[1],t[2])),"signTransaction"in e&&(r=async t=>await e.signTransaction(t)),"signAllTransactions"in e&&(a=async t=>await e.signAllTransactions(t)),{type:"solana",address:e.publicKey.toBase58(),meta:t,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>e.connected,disconnect:()=>{try{e.disconnect()}catch(e){console.error("Wallet does not support programmatic disconnect")}},getProvider:(0,n8.n)(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:n??(0,n8.n)(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:i??(0,n8.n)(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:r??(0,n8.n)(`${this.walletClientType||""} wallet does not support 'signTransaction'`),signAllTransactions:a??(0,n8.n)(`${this.walletClientType||""} wallet does not support 'signAllTransactions'`)}}async syncAccounts(){if("Installed"===this.adapter.readyState&&this.adapter.publicKey){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find(e=>this.adapter.publicKey&&e.address===this.adapter.publicKey.toBase58())||(this.wallets=[this.buildConnectedWallet(this.adapter,e)],this.emit("walletsUpdated"))}else this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"))}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAttemptAutoConnect()&&await this.adapter.autoConnect().catch(()=>{}),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort((e,t)=>t.connectedAt-e.connectedAt)[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}shouldAttemptAutoConnect(){return!(!this.autoConnectEnabled||!yI.includes(this.walletClientType))&&("phantom"!==this.walletClientType||yC().some(({walletClientType:e})=>"phantom"===e))}constructor(e,t){super(e.name.toLowerCase().split(" ").join("_")),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=()=>{this.adapter.disconnect().then(()=>
54this.onDisconnect()).catch(e=>console.error("Error disconnecting",e))},this.promptConnection=async()=>{try{await this.adapter.connect()}catch(e){throw m1(e)}},this.onDisconnect=()=>{this.syncAccounts()},this.onConnect=e=>{this.syncAccounts()},this.onError=e=>{this.syncAccounts()},this.onReadyStateChange=e=>{"Installed"!==e&&(this.connected=!1),this.syncAccounts()},this.adapter=e,this.autoConnectEnabled=t,this.wallets=[]}}class yS extends yA{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:n}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new yt(void 0,12e4),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=n}}let yk=(0,hV.v)(()=>({listings:[]})),yP=yk.setState,yj=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return yk.getState().listings.find(({homepage:e})=>{let n;try{n=new URL(e).hostname}catch(e){return!1}return t.includes(n)})},yO=e=>yk(({listings:t})=>t.find(({slug:t})=>yN(t)===yN(e)));function yN(e){return"cryptocom"===e?"cryptocom-defi":"binance"===e?"binance-defi":e.replace(/[-_]wallet$/,"")}function yR({src:e,...t}){return(0,h.jsx)("img",{src:e,...t,style:{display:"none"}})}let yM={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",externalWallets:{coinbaseWallet:{connectionOptions:"all"}},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}},yD=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","ronin_wallet","haha_wallet","wallet_connect","detected_wallets","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe","solflare","backpack","binance"]),yU=e=>yD.has(e),yL=(e,t,n)=>n.indexOf(e)===t,yF="11111111111111111111111111111111";function yW(e){return e.includes("testnet")?"testnet":e.includes("devnet")?"devnet":"mainnet-beta"}let y$="#FFFFFF";function yB(e,t){let n=Math.max(0,Math.min(1,e.toHsl().l+t));return(0,iw.A)({...e.toHsl(),l:n})}function yz(e,t,n,i){let r,a,s,o,l,c,d,u,h,p,m,y,f,g,w,v,b=n?console.warn:()=>{};t?.loginMethods?(r=t.loginMethods.includes("email"),a=t.loginMethods.includes("sms"),o=t.loginMethods.includes("wallet"),l=t.loginMethods.includes("google"),c=t.loginMethods.includes("twitter"),d=t.loginMethods.includes("discord"),p=t.loginMethods.includes("spotify"),m=t.loginMethods.includes("instagram"),u=t.loginMethods.includes("tiktok"),h=t.loginMethods.includes("line"),f=t.loginMethods.includes("github"),y=t.loginMethods.includes("linkedin"),g=t.loginMethods.includes("apple"),w=t.loginMethods.includes("farcaster"),v=t.loginMethods.includes("telegram"),s=t.loginMethods.includes("passkey")):(r=e.email_auth,a=e.sms_auth,o=e.wallet_auth||e.solana_wallet_auth,l=e.google_oauth,c=e.twitter_oauth,d=e.discord_oauth,f=e.github_oauth,p=e.spotify_oauth,m=e.instagram_oauth,u=e.tiktok_oauth,h=e.line_oauth,y=e.linkedin_oauth,g=e.apple_oauth,w=e.farcaster_auth,v=e.telegram_auth,s=e.passkey_auth),e.passkey_auth&&(s=!0),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(s=!1);let x=[r,a].filter(Boolean),_=[l,c,d,f,p,m,u,h,y,g,w,v].filter(Boolean),C=[o].filter(Boolean),I=t?.loginMethods?.includes("passkey")??!1,E=e.passkeys_for_signup_enabled??!1,T=[s&&(E||I)].filter(Boolean);if(x.length+_.length+C.length+T.length===0)throw Error("You must enable at least one login method");let S=void 0!==t?.appearance?.showWalletLoginFirst?t?.appearance?.showWalletLoginFirst:e.show_wallet_login_first;S&&0===C.length?(b("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),S=!1):S||_.length+x.length!==0||(b
54("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),S=!0);let k=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&b("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let P=(({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(yU).filter(yL):e?e.filter(yU).filter(yL):yM.appearance.walletList)({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),j=(({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],n=[];for(let n of(e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`"),e.primary.slice(1)))t.includes(n)?console.warn(`Duplicated login method: ${n}`):t.push(n);for(let i of e.overflow??[])t.includes(i)||n.includes(i)?console.warn(`Duplicated login method: ${i}`):n.push(i);return{primary:t,overflow:n}})({input:t?.loginMethodsAndOrder}),O=t?.intl?.defaultCountry??"US",{chains:N,defaultChain:R}=function({supportedChains:e,defaultChainFromConfig:t}){let n;if(e){if(0===e.length)throw Error("`supportedChains` must contain at least one chain");n=(0,D._)(e)}else n=[...A.m];let i=e?n[0]:U.r,r=t??i;if(!n.find(e=>e.id===r.id))throw Error("`defaultChain` must be included in `supportedChains`");return{chains:n,defaultChain:r}}({supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain}),M=!!t?.defaultChain,L=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,F=t?.embeddedWallets?.requireUserPasswordOnCreate,W=t?.embeddedWallets?.createOnLogin,$=L?"all-users":e.embedded_wallet_config.ethereum.create_on_login,B=e.embedded_wallet_config.solana.create_on_login,z={"mainnet-beta":{rpcUrl:"https://api.mainnet-beta.solana.com",blockExplorerUrl:"https://explorer.solana.com"},testnet:{rpcUrl:"https://api.testnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=testnet"},devnet:{rpcUrl:"https://api.devnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=devnet"}};if(t?.solanaClusters)for(let e of t.solanaClusters){let{name:t,rpcUrl:n,blockExplorerUrl:i}=e;z[t]={rpcUrl:n??z[t].rpcUrl,blockExplorerUrl:i??z[t].blockExplorerUrl}}e.solana_wallet_auth&&!t?.externalWallets?.solana?.connectors&&console.warn("App configuration has Solana wallet login enabled, but no Solana wallet connectors have been passed to Privy. Make sure to pass Solana connectors to the `config.externalWallets.solana.connectors` field of the `PrivyProvider`");let q=e.telegram_auth_config?{botId:e.telegram_auth_config.bot_id,botName:e.telegram_auth_config.bot_name,linkEnabled:e.telegram_auth_config.link_enabled,seamlessAuthEnabled:e.telegram_auth_config.seamless_auth_enabled}:void 0,V=e.funding_config?{methods:e.funding_config.methods,options:e.funding_config.options,defaultRecommendedAmount:e.funding_config.default_recommended_amount,defaultRecommendedCurrency:e.funding_config.default_recommended_currency,promptFundingOnWalletCreation:e.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:e.funding_config.cross_chain_bridging_enabled}:void 0;return{id:e.id,name:e.name,allowlistConfig:{errorTitle:e.allowlist_config.error_title,errorDetail:e.allowlist_config.error_detail,errorCtaText:e.allowlist_config.cta_text,errorCtaLink:e.allowlist_config.cta_link},legacyWalletUiConfig:e.legacy_wallet_ui_config,appearance:{logo:t?.appearance?.logo??e.logo_url??void 0,landingHeader:t?.appearance?.landingHeader??yM.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:function({backgroundTheme:e,accentHex:t}){var n;let i;switch(e){case"light":i=y$;break;case"dark":i="#1E1E1D";break;default:i=e}let r=(0,iw.A)(i),a=(0,iw.A)(t),s=(0,iw.A)("#51BA81"),o=(0,iw.A)("#FFB74D"),l=(0,iw.A)("#EC6351"),c=((n=r.getLuminance())<.8&&n>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),n>.5?"light":"dark"),d=yB(r,"light"===c?-.04:.11),u=yB(r,"light"===c?-.08:.16),h=yB(r,"light"===c?-.88:.87),p=yB(r,"light"===c?-.7:.75),m=yB(r,"light"===c?-.43:.45).desaturate("light"===c?60:20),y=yB(r,"light"===c?-.08:.25).desaturate("light"===c?60:20),f=yB(a,.15),g=yB(a,.25),w=yB(a,-.06),v=yB(a,-.6),b=yB(l,.3),x=yB(o,.3),_=(0,iw.A)(a.getLuminance()>.5?"#040217":y$),C=yB(s,-.16),I=yB(s,.4);return{colorScheme:c,background:r.toHslString(),background2:d.toHslString(),background3:u.toHslString(),foreground:h.toHslString(),foreground2:p.toHslString(),foreground3:m.toHslString(),foreground4:y.toHslString(),accent:a.toHslString(),accentLight:f.toHslString(),accentLightest:g.toHslString(),accentDark:w.toHslString(),accentDarkest:v.toHslString(),foregroundAccent:_.toHslString(),success:s.toHslString(),successDark:C.toHslString(),successLight:I.toHslString(),error:l.toHslString(),errorLight:b.toHslString(),warn:o.toHslString(),warnLight:x.toHslString()}}({backgroundTheme:t?.appearance?.theme??yM.appearance.theme,accentHex:t?.appearance?.accentColor??e.accent_color??yM.appearance.accentColor}),loginGroupPriority:S?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:P,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.wallet_auth??!1,solanaWalletAuth:e.solana_wallet_auth??!1})},loginMethods:{wallet:o,email:r,sms:a,passkey:s,google:l,twitter:c,discord:d,github:f,spotify:p,instagram:m,tiktok:u,line:h,linkedin:y,apple:g,farcaster:w,telegram:v},disablePlusEmails:e.disable_plus_emails,loginMethodsAndOrder:j,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.terms_and_conditions_url,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacy_policy_url,requireUsersAcceptTerms:e.require_users_accept_terms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.wallet_connect_cloud_project_id??yM.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:t?.externalWallets?.signatureRequestTimeouts??{}},chains:N,solanaClusters:z,defaultChain:R,intl:{defaultCountry:O},shouldEnforceDefaultChainOnConnect:M,captchaEnabled:e.captcha_enabled??yM.captchaEnabled,captchaSiteKey:e.captcha_site_key,externalWallets:{coinbaseWallet:{config:{appName:e.n
54ame,appLogoUrl:e.logo_url,preference:{options:t?.externalWallets?.coinbaseWallet?.connectionOptions??yM.externalWallets.coinbaseWallet.connectionOptions,...t?.externalWallets?.coinbaseWallet?.config?.preference},...t?.externalWallets?.coinbaseWallet?.config}},walletConnect:{enabled:k,appKit:t?.externalWallets?.walletConnect?.appKit},solana:{connectors:t?.externalWallets?.solana?.connectors},disableAllExternalWallets:t?.externalWallets?.disableAllExternalWallets??!1},embeddedWallets:{requireUserOwnedRecoveryOnCreate:F??(!L&&(e.embedded_wallet_config.require_user_owned_recovery_on_create??!1)),userOwnedRecoveryOptions:L?["user-passcode"]:e.embedded_wallet_config.user_owned_recovery_options,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:W??t?.embeddedWallets?.ethereum?.createOnLogin??$},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??B},mode:e.embedded_wallet_config.mode,showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforce_wallet_uis??!0,extendedCalldataDecoding:t?.embeddedWallets?.extendedCalldataDecoding??!1,transactionScanning:{enabled:t?.embeddedWallets?.transactionScanning?.enabled??!1,domain:t?.embeddedWallets?.transactionScanning?.domain??i??"https://auth.privy.io"}}
54,mfa:{methods:e.mfa_methods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink},customAuth:L?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:q,passkeysForSignupEnabled:e.passkeys_for_signup_enabled},headless:!!t?.headless,render:{standalone:t?._render?.standalone??yM._render.standalone},fundingConfig:V,fundingMethodConfig:{...t?.fundingMethodConfig??yM.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??yM.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??yM.fundingMethodConfig.moonpay.useSandbox}},whatsAppEnabled:!!e.whatsapp_enabled}}let yq={show_wallet_login_first:!0,allowlist_config:{error_title:null,error_detail:null,cta_text:null,cta_link:null},wallet_auth:!0,email_auth:!0,sms_auth:!1,google_oauth:!1,twitter_oauth:!1,discord_oauth:!1,github_oauth:!1,linkedin_oauth:!1,apple_oauth:!1,disable_plus_emails:!1,terms_and_conditions_url:null,privacy_policy_url:null,embedded_wallet_config:{create_on_login:"off",ethereum:{create_on_login:"off"},solana:{create_on_login:"off"},require_user_owned_recovery_on_create:!1,user_owned_recovery_options:["user-passcode"],mode:"user-controlled-server-wallets-only"},fiat_on_ramp_enabled:!1,captcha_enabled:!1,captcha_site_key:"",enforce_wallet_uis:!1,legacy_wallet_ui_config:!1,id:"",name:"",passkeys_for_signup_enabled:!1,whatsapp_enabled:!1},yV=yz(yq,void 0,!1),yH=(0,m.createContext)({appConfig:yV,isServerConfigLoaded:!1}),yG=({children:e,client:t,legacyClient:n,clientConfig:i})=>{let[r,a]=(0,m.useState)(null),s=(0,m.useMemo)(()=>yz(r??yq,i,!!r,"undefined"!=typeof window?window.location.origin:void 0),[r,i]);return(0,m.useEffect)(()=>{if(!r)return;let e=function(e){if(!e)return{};let{appearance:t,supportedChains:n,defaultChain:i,externalWallets:r,...a}=e;return{...a,...n?{supportedChains:n.map(e=>e.id)}:void 0,...i?{defaultChain:i.id}:void 0,...r?{walletConnect:r.walletConnect?{enabled:r.walletConnect.enabled}
54:void 0,coinbaseWallet:r.coinbaseWallet,solana:{connectors:r.solana?.connectors?.get().map(e=>e.walletClientType)}}:void 0}}(i),t=(function(e,t=0){let n=0xdeadbeef^t,i=0x41c6ce57^t;for(let t,r=0;r<e.length;r++)n=Math.imul(n^(t=e.charCodeAt(r)),0x9e3779b1),i=Math.imul(i^t,0x5f356495);return n=Math.imul(n^n>>>16,0x85ebca6b)^Math.imul(i^i>>>13,0xc2b2ae35),0x100000000*(2097151&(i=Math.imul(i^i>>>16,0x85ebca6b)^Math.imul(n^n>>>13,0xc2b2ae35)))+(n>>>0)})(JSON.stringify(e)).toString(),a=`privy:sent:${r.id}:${t}`;localStorage.getItem(a)||(n.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(a,"t"))},[i,r]),(0,m.useEffect)(()=>{r||(async()=>{try{await t.initialize();let e=t.app.getConfig();e.custom_api_url&&n.updateApiUrl(e.custom_api_url),a(e)}catch(e){console.warn("Error generating app config: ",e)}})()},[]),(0,h.jsx)(yH.Provider,{value:{appConfig:s,isServerConfigLoaded:!!r},children:e})},yK=()=>{let{appConfig:e}=(0,m.useContext)(yH);return e},yJ=()=>{let{isServerConfigLoaded:e}=(0,m.useContext)(yH);return e},yZ=(0,m.createContext)({app:yV,currentScreen:null,lastScreen:null,navigate:n8.a,navigateBack:n8.a,resetNavigation:n8.a,setModalData:n8.a,onUserCloseViaDialogOrKeybindRef:void 0}),yY=e=>{let t=yK(),n=e.authenticated,[i,r]=(0,m.useState)(e.initialScreen);(0,m.useEffect)(()=>{n||!e.initialScreen||e.initialScreen.isUnauthenticatedScreem||e.setInitialScreen(null)},[n]);let a=(0,m.useRef)(null);(0,m.useEffect)(()=>{e.open||(a.current=null)},[e.open]),(0,m.useEffect)(()=>{a.current=null},[e.initialScreen]);let s={app:t,data:e.data,setModalData:e.setModalData,currentScreen:e.initialScreen,lastScreen:i,navigate:(t,n=!0)=>{e.setInitialScreen(t),n&&r(e.initialScreen)},navigateBack:()=>{e.setInitialScreen(i)},resetNavigation:()=>{e.setInitialScreen(null),r(null)},onUserCloseViaDialogOrKeybindRef:a};return(0,h.jsxs)(yZ.Provider,{value:s,children:[("string"==typeof t.appearance.logo||"img"===t.appearance.logo?.type)&&(0,h.jsx)(yR,{src:"string"==typeof t.appearance.logo?t.appearance.logo:t.a
54ppearance.logo.props.src}),e.children]})},yQ=()=>(0,m.useContext)(yZ),yX=({style:e,...t})=>{let{app:n}=yQ();return(0,h.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,h.jsx)("rect",{width:"28",height:"28",rx:"3",fill:"dark"===n?.appearance.palette.colorScheme?"#3396ff":"#141414"}),(0,h.jsx)("g",{clipPath:"url(#clip0_1765_9946)",children:(0,h.jsx)("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),(0,h.jsx)("defs",{children:(0,h.jsx)("clipPath",{id:"clip0_1765_9946",children:(0,h.jsx)("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};class y0 extends ye{async initialize(){let e=await this.createProvider();this.provider=e,this.proxyProvider.setWalletProvider(e),this.subscribeListeners(),e.session&&(this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=yj(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown"),this.connected=!0,await this.syncAccounts()),this.initialized=!0,this.emit("initialized");let{createAppKit:t}=await Promise.all([n.e(3469),n.e(6280),n.e(6875),n.e(4237)]).then(n.bind(n,381428));this.modal??=t({projectId:this.walletConnectCloudProjectId,themeVariables:{"--w3m-z-index":1e6},networks:this.chains,includeWalletIds:pY,allowUnsupportedChain:!0}),this.modal.subscribeState(e=>{e.open||this.walletProvider?.session||!this.onQrModalClosed||this.onQrModalClosed()})}async connect(e){return e.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){let e=this.walletProvider?.session?.peer.metadata.icons?.[0];return{name:(this.walletProvider?.session?.peer.metadata.name||"").replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,"")||"WalletConnect",icon:"string"==typeof e?e:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAHdElNRQfoDAIVODUC+w+GAAAGsUlEQVRYw6WXbYwWVxXHf+fOLAtCXYS2QJdIaClipGCTknXXNqBQMVHbfmhItH4Aral+IAEaG03UxJgYKQJGTUxtDWjaxDSNtcZqIGDwpRuW1oYiVqpdpZSlpC3qysu+PHPP3w/3mXnmeXZbPzjJZO7cefn/z/mfe865xlscq3dGDIguGiHLaMQVLja4s87FShcLo5jtApdddnHexUmHIy475JmdUkPRAQMu7gzT4ljnxJpdk0QPmMFkyAKN2OfOFpc2uuh1J3MZDrjAvXmVEQUuoosRxw642FcEG7IoDxiFxNiu8NYE+vcUYIFYRKKs113bXWx2Z34CoQZsVHOiCZ7mopdzdsFhv8NexEgRDHMxUSNREbh1bwNZwBsFblmfu/a4a6AEENYO5i3AOoEWeEUCF4MOOxBDMQAOk99OJALA2u80sBCwWGBZWG/yRwMaCAbBIAsQTJT3gea1OWfNeaPzvjoHEI85rA8ObtB1v7cIdJkIHgkh9AXpocy0LJjIKvB2wPpZB0v3wkrw5jdNEjeYeMhFX3BAyfn2ke9NUrgB9LrrcZcGJFCld4fWNddXbvbWfWzGR6xJFZsBGh0cBh3bBIxIEGTQ3W0h4NuDaSAzyAxCmGq11Vzf5uaa1aG8p+WFtrEYQGwvjICJkAEqvC+YNmcmMlMNvEaCdrcbyUvQAWDTjVuESHObM6cPGWHmzDwLaEtmzG9Z3qF1zUpXmuuZBb1z4bqeNC6f0WE1NtUTwHzEloiy3BvFisy0sYoLlQtT6XW15md2Qf9SY+2Ngfdca/TMSm/9ewz+/Boc/It45h/i4kSTsKw90SQJsPTvjSZbkWemDW7qTRZ0JEYJWSKxZJ7xmf6M224MzMzbX1s8F1YugjtvMg6eErt/4/z1jUrz1rXUKxnZC2zIg2mdBTK1mFUOKC1fOt/48kdz
54VixIz86Nij+eEacvpJWyZJ5xy7th8VzjjpuMJfMCW58QL73ekXPVlhsyE+vyzFiplJyauEIyrGIquruMq7qTxk+dcB495rzyTzFepCUWLIFv/kBg081Gd55WUk1IDGFTS89K++TDYxddzKnWcbluHd450xgdh7EGrOo1rr868PMTzqWJRGZ2d8oB/xpL33Xnxl2rjeNn4blXRXduzJ4B5y+28kWscAwXl+yeR654FFZPHoUb710YuPeDOUdPO48di1xptKpeEeHqOcYXNwQKGd88EDk3mqxtxPSfGRlsXRtYt8z4ytPOH/7eqpg1Aso7fYKgK4NPrMpYvsC4/poMA34yVJIQC3sCD9yecdsNyaV5yPj6ryJnR1PAvSNP4J+/1cgDfLbfePaMGGtM7Qdyl12WmKOmXgKKAp54vmBRTxfLrjE+tSYjBPjRM5FrrzIeuD2jf2lLzw8vN4JlfPVp581LsO1DgXv7jSzAiXPw/d+JiYLpjsu26Yfjf5O0rF5WoxsNT9G/bX0XKxakmPjlSee6HlizJJXSX7/oRDc+vjKR+f2wODcKd78/gR8/C9uedF44myJxmhh4OY/ipMQyqaWxmjn95TfEroMFOzbkvG+RceeqViPx1Aln1yEnOow1AnffHCpJAJ5/Vex4UvzptZRdY/O/1dJIS/NkcNmR6MTYah6qzseA4TfFtw4UvHBW1bc/O+7sPhwZHYf/jMODh5yfPudVbXj2TAJ/8XxrOZagNamj4Ei2/GNfuyRxh8t6BG2l15up+MIVODEiFr8rcPS0+O6RBF6mrrEGHHtFzOo2Lo7Dl37hvPQ6mNV6R9JYKgnYWcE37K5HlE2OT/5A0udaPUBHH+BQOMzuNsYLuDyZflTW+fTcmJFDHhJhaZqewMuewXDxcDR9IYyPN6Jj+6K4MF2vV8qBtZJScqVRNi6lpGONVJis5mpKi1WbgwsY+zIsBpcR8mzIZfuTRVZrtdu9odrptR/Xx5XONXJqBmCN0P6YMUQq9WJiwt0Je102WHdbpxSqydMObBWYdwDWLVcqcIMYe3NPjg0Ht84od0Ajju1w2XCr9e6QoqM9V23ZtnmI6cfAMMb9AY0YEHdb6oobEh4y3H3Ize6LsmGvN5IdUnhttdQ9UVrfLk/ljWEZ9wXsqAdQk1EA+O22GcgdZTke/bAs3OPY4HSdcB20HhvVtTMu0jmI8ekAhz2IICj2hKpNqI60NcuIRUHEej1quzubXa2tmZhenrfZmv3YYQ9ipDAIgvHptmblccuDjdRcmjFpWbDi/9ycZjZkRbk5jYztai/AUwiUx+qdEQB/m+25i9lxyvbcjrg45Lmd0uT/3p7/Fw6ODf+WO019AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTEyLTAyVDIxOjU2OjQ4KzAwOjAwMVpslgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0xMi0wMlQyMTo1Njo0OCswMDowMEAH1CoAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMTItMDJUMjE6NTY6NTMrMDA6MDDZv6GRAAAAAElFTkSuQmCC",id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(e){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletClientType=e,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,function(){try{localStorage.removeItem(pX)}catch{}}(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise((e,t)=>{this.onQrModalClosed=()=>{t(new m0)},(async()=>{let t="",n=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(n?.length&&(t=n[0]),!t||""===t)throw new n6.d("Unable to retrieve address");this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=yj(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown",this.proxyProvider.rpcTimeoutDuration=m7(this.rpcConfig,this.walletClientType)),this.connected=!0,await this.syncAccounts(n),e()})().catch(e=>{t(e?m1(e):new n6.d("Unknown error during connection"))}).finally(()=>this.modal?.close())})}disconnect(){this.walletProvider?.disconnect().then(()=>this.onDisconnect()).catch(()=>console.warn("Unable to disconnect Wallet Connect provider"))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(e){this.proxyProvider.setWalletProvider(e)}async createProvider(){let e={};for(let t of this.chains){let n=pJ(t.id,this.chains,this.rpcConfig,this.privyAppId);n&&(e[t.id]=n)}let t=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],n=this.chains.map(e=>e.id),i=await hq.init({projectId:this.walletConnectCloudProjectId,chains:t,optionalChains:n,optionalEvents:hj,optionalMethods:hk,rpcMap:e,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.origin,icons:[]}});return i.on("display_uri",e=>{if(i.signer.abortPairingAttempt(),this.walletEntry){let{redirect:t,href:n}=function(e,t){let n=pQ(t);if(n.deepLink)return p1(n.deepLink,e);if(n.universalLink)return p2(n.universalLink,e);throw new n6.P(`Unsupported wallet ${t.id}`)}(e,this.walletEntry);(function({href:e,name:t}){try{localStorage.setItem(pX,JSON.stringify({href:e,name:t}))}catch{}})({href:n,name:this.walletEntry.metadata?.shortName||this.walletEntry.name}),this.redirectUri=t;let i=function(e,t){let n=pQ(t);if(n.universalLink)return p2(n.universalLink,e)}(e,this.walletEntry);i?.redirect&&(this.fallbackUniversalRedirectUri=i.redirect),y.Fr?(p3(t,"_self"),this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri})):this.showPrivyQrModal?this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri}):this.modal?.open({uri:e})}else this.modal?.open({uri:e})}),i.on("connect",()=>{this.modal?.close(),i.session?.peer.metadata.url&&(this.walletEntry=yj(i.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown")}),i}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider?.enable()}setWalletEntry(e,t){this.walletEntry=e,this.showPrivyQrModal=t}constructor({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:i,shouldEnforceDefaultChainOnConnect:r,privyAppId:a,privyAppName:s,walletClientType:o,appKit:l}){super(o||"unknown",n,i,t),this.connectorType="wallet_connect_v2",this.privyAppId=a,this.privyAppName=s,this.walletConnectCloudProjectId=e,this.rpcConfig=t,this.shouldEnforceDefaultChainOnConnect=r,this.proxyProvider=new yt(void 0,this.rpcTimeoutDuration),this.modal=l,o&&(this.walletEntry=yk.getState().listings.find(({slug:e})=>yN(e)===yN(o)),this.walletClientType=o)}}class y1 extends tn.A{get wallets(){let e=new Set,t=this.walletConnectors.flatMap(e=>e.wallets).sort((e,t)=>
54e.connectedAt&&t.connectedAt?t.connectedAt-e.connectedAt:0).filter(t=>{let n=`${t.address}${t.walletClientType}${t.connectorType}${t.meta.id}`;return!e.has(n)&&(e.add(n),!0)}),n=t.findIndex(e=>e.address===(this.activeWallet?this.activeWallet:"unknown"));return n>=0&&t.unshift(t.splice(n,1)[0]),t}async initialize(e){if(this.initialized&&!e||(e&&this.removeAllConnectors(),pR.get(mh)&&(pR.getKeys().forEach(e=>{e.startsWith("walletconnect")&&pR.del(e)}),pR.del(mh)),this.externalWalletConfig.disableAllExternalWallets))return;let t=pG({store:this.store,walletList:this.walletList,externalWalletConfig:this.externalWalletConfig,walletChainType:this.walletChainType}).then(e=>{e.forEach(({type:e,eip6963InjectedProvider:t,legacyInjectedProvider:n})=>{this.createEthereumWalletConnector({connectorType:"injected",walletClientType:e,providers:{eip6963InjectedProvider:t,legacyInjectedProvider:n}})})});for(let e of(this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector({connectorType:"coinbase_wallet",walletClientType:"coinbase_wallet"}),Object.values(yb)))!e.isInstalled&&this.walletList.includes(e.client)&&(["ethereum-only","ethereum-and-solana"].includes(this.walletChainType)&&e.chainTypes.includes("ethereum")&&this.createEthereumWalletConnector({connectorType:"null",walletClientType:e.client,walletConfig:e}),["ethereum-and-solana","solana-only"].includes(this.walletChainType)&&e.chainTypes.includes("solana")&&this.addSolanaWalletConnector(new yS({id:e.client,name:e.name})));this.externalWalletConfig.walletConnect.enabled&&this.createEthereumWalletConnector({connectorType:"wallet_connect_v2",walletClientType:"unknown"}),this.externalWalletConfig.solana.connectors?.get().forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.(e=>{e?.forEach(this.addSolanaWalletConnector)}),await t,this.initialized=!0}findWalletConnector(e,t){return"wallet_connect_v2"===e?this.walletConnectors.filter(m9).find(t=>t.connectorType===e)??null:this.walletConnectors.filter(m9).find(n=>n.connectorType===e&&n.walletClientType===t)??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(yE).find(t=>"unknown"===t.walletClientType?t.walletBranding.id===e:t.walletClientType===e)??null}findEmbeddedWalletConnectors(){return this.walletConnectors.filter(e=>"embedded"===e.connectorType)}onInitialized(e){e.wallets.forEach(e=>{let t=this.storedConnections.find(t=>t.address===e.address&&t.connectorType===e.connectorType&&("solana"===e.type&&"unknown"===t.walletClientType&&"unknown"===e.walletClientType?e.meta.id===t.id:t.walletClientType===e.walletClientType));t&&(e.connectedAt=t.connectedAt)}),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&this.emit("walletsUpdated")}addEmbeddedWalletConnectors({walletProxy:e,user:t,embeddedWallets:n,defaultChain:i,appId:r,privyClient:a}){let{entropyId:s,entropyIdVerifier:o}=mY(t);for(let t of n){let n=this.findEmbeddedWalletConnectors().find(e=>e.walletIndex===t.walletIndex);if(n&&m9(n))n.proxyProvider.walletProxy=e;else{let n=new ya({provider:new yl({walletProxy:e,address:t.address,entropyId:s,entropyIdVerifier:o,rpcConfig:this.rpcConfig,chains:this.chains,appId:r,chainId:i.id,walletIndex:t.walletIndex,privyClient:a,walletAccount:t}),chains:this.chains,defaultChain:i,rpcConfig:this.rpcConfig,imported:!1,walletIndex:t.walletIndex});this.addWalletConnector(n)}}}addImportedWalletConnector(e,t,n,i){let r=this.findWalletConnector("embedded_imported","privy");if(r&&m9(r))r.proxyProvider.walletProxy=e;else{let r=new ya({provider:new yl({walletProxy:e,address:t,entropyId:t,entropyIdVerifier:"ethereum-address-verifier",walletIndex:0,rpcConfig:this.rpcConfig,chains:this.chains,appId:i,chainId:n.id}),chains:this.chains,walletIndex:0,defaultChain:n,rpcConfig:this.rpcConfig,imported:!0});this.addWalletConnector(r)}}removeEmbeddedWalletConnectors(){this.walletConnectors=this.walletConnectors.filter(e=>"embedded"!==e.connectorType),this.storedConnections=yC(),this.emit("walletsUpdated")}removeImportedWalletConnector(){let e=this.findWalletConnector("embedded_imported","privy");if(e){let t=this.walletConnectors.indexOf(e);this.walletConnectors.splice(t,1),this.storedConnections=yC(),this.emit
54("walletsUpdated")}}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:n,walletConfig:i}){let r=this.findWalletConnector(e,t);if(r&&m9(r))return r instanceof y0&&r.resetConnection(t),r;let a="injected"!==e?"coinbase_wallet"===e?new yi(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig.coinbaseWallet.config):"null"!==e?new y0({walletConnectCloudProjectId:this.walletConnectCloudProjectId,rpcConfig:this.rpcConfig,chains:this.chains,defaultChain:this.defaultChain,shouldEnforceDefaultChainOnConnect:this.shouldEnforceDefaultChainOnConnect,privyAppId:this.privyAppId,privyAppName:this.privyAppName,walletClientType:t,appKit:this.appKit}):i?new yc({id:i.client,name:i.name,defaultChain:this.defaultChain,walletClientType:i.client}):null:"metamask"===t&&n?.eip6963InjectedProvider?new yw(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask"):"metamask"===t&&n?.legacyInjectedProvider?new yg(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask"):"phantom"===t&&n?.legacyInjectedProvider?new yg(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom"):n?.legacyInjectedProvider&&"unknown_browser_extension"===t?new yg(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider):n?.eip6963InjectedProvider?new yy(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,t):void 0;return a&&this.addWalletConnector(a),a||null}addWalletConnector(e){this.walletConnectors.push(e),e.on("initialized",()=>this.onInitialized(e)),e.on("walletsUpdated",()=>this.onWalletsUpdated(e)),e.initialize().catch(e=>{console.debug("Failed to initialize connector",e)})}async activeWalletSign(e){let t=this.wallets,n=t.length>0?t[0]:null;return n&&m5(n)?n.sign(e):null}setActiveWallet(e){this.activeWallet=(0,f.b)(e),this.emit("walletsUpdated")}setWalletList(e){this.walletList=e,this.initialized&&this.initialize(!0).catch(console.error)}removeAllConnectors(){for(let e of this.walletConnectors)e.removeAllListeners();this.walletConnectors=[]}constructor(e,t,n,i,r,a,s,o,l,c,d,u){super(),this.addSolanaWalletConnector=async e=>{let t=this.findSolanaWalletConnector(e.walletClientType);if(!t||"null"===t.connectorType){if("null"===t?.connectorType){let e=this.walletConnectors.indexOf(t);this.walletConnectors.splice(e,1)}this.addWalletConnector(e)}},this.getEthereumProvider=()=>{let e=this.wallets[0],t=this.walletConnectors.find(t=>t.wallets.find(t=>t.address===e?.address));return e&&t?t.proxyProvider:new yt},this.privyAppId=e,this.walletConnectCloudProjectId=t,this.rpcConfig=n,this.chains=i,this.defaultChain=r,this.walletConnectors=[],this.initialized=!1,this.store=a,this.walletList=s,this.shouldEnforceDefaultChainOnConnect=o,this.externalWalletConfig=l,this.privyAppName=c,this.walletChainType=d||"ethereum-only",this.appKit=u,this.storedConnections=yC()}}let y2=[n6.C,n6.D,n6.E];class y3{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw(0,n6.f)(e)}}async post(e,t,n){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...n})}catch(e){throw(0,n6.f)(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw(0,n6.f)(e)}}constructor({appId:e,appClientId:t,client:n,defaults:i}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=n.clientAnalyticsId,this.sdkVersion="2.17.3",this.client=n,this.defaults=i,this.fallbackApiUrl=n.fallbackApiUrl,this.baseFetch=pm.OT.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:e,options:t})=>{let n=new Headers(t.headers);n.set("privy-app-id",this.appId),this.appClientId&&n.set("privy-client-id",this.appClientId),n.set("privy-ca-id",this.clientAnalyticsId||""),n.set("privy-client",`react-auth:${this.sdkVersion}`);let i=y2.includes(e.toString());if(!n.has("authorization")){let e=await this.client.getAccessToken({disableAutoRefresh:i});null!==e&&n.set("authorization",`Bearer ${e}`)}t.headers=n,t.retryDelay&&"number"==typeof t.retryDelay&&(t.retryDelay=3*t.retryDelay)},onRequestError:({error:e})=>
54{if(e instanceof DOMException&&"AbortError"===e.name)throw new n6.B}})}}let y4=/paymaster\.biconomy\.io\/api/i,y5={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};class y6{async authenticate(){if(!this.api)throw new n6.P("Auth flow has no API instance");try{return await this.api.post(n6.F,{token:this.meta.token})}catch(e){throw(0,n6.f)(e)}}async link(){if(!this.api)throw new n6.P("Auth flow has no API instance");try{return await this.api.post(n6.G,{token:this.meta.token})}catch(e){throw(0,n6.f)(e)}}constructor(e){this.meta={token:e}}}class y8{getOrCreateGuestCredential(e){let t=ma(e);if(pN()){if(pR.get(t))return pR.get(t);{let e=tT.l(mm(32));return pR.put(t,e),e}}return tT.l(mm(32))}async authenticate(){if(!this.api)throw new n6.P("Auth flow has no API instance");try{return await this.api.post(n6.H,{guest_credential:this.meta.guestCredential})}catch(e){throw(0,n6.f)(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function y7(){return!(y.nr&&window.location.origin.startsWith("http://localhost"))}let y9=(0,hV.v)(()=>({identityToken:null}));var fe,ft=((fe={}).PRIVY="privy_access_token",fe.CUSTOMER="customer_access_token",fe);class fn{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(p8)}get privyAccessToken(){return this._getToken(me)}_getToken(e){try{let t=pR.get(e);return"string"==typeof t?mK.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=pR.get(p9);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=pR.get(ms(e));if("string"!=typeof t)return null;{let n=new mK(t);return n.isExpired()?(pR.del(ms(e)),null):n.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=tA.A.get(mi);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e="privy_access_token"){let t="string"==typeof this.getToken(e),n="string"==typeof this.refreshToken&&"deprecated"!==this.refreshToken;return this.mightHaveServerCookies||t&&n}hasActiveAccessToken(e){let t=mK.parse(this.getToken(e));return null!==t&&!t.isExpired(30)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(e,t){"string"==typeof t?pR.put(ms(e),t):pR.del(ms(e))}updateIdentityToken(e){"string"==typeof e?this.storeIdentityToken(e):this.clearIdentityToken()}async _authenticate(e){try{let t=await e.authenticate(),{user:n,is_new_user:i,oauth_tokens:r}=t;this.handleTokenResponse(t);let a=r?{provider:r.provider,accessToken:r.access_token,accessTokenExpiresInSeconds:r.access_token_expires_in_seconds,refreshToken:r.refresh_token,refreshTokenExpiresInSeconds:r.refresh_token_expires_in_seconds,scopes:r.scopes}:void 0;return this._trackAuthenticateEvents(e,i),{user:(0,ic.i)(n),isNewUser:i,oAuthTokens:a}}catch(e){throw console.warn("Error authenticating session"),(0,n6.I)(e)}}_trackAuthenticateEvents(e,t){let n=e instanceof pP?"email":e instanceof mL?"sms":e instanceof mM?"siwe":e instanceof y8?"guest":e instanceof y6?"custom_auth":e instanceof mg?e.meta.provider:null;n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:n,isNewUser:t}}),"siwe"===n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:e.meta.connectorType,walletClientType:e.meta.walletClientType}})}async _link(e){try{let t=await e.link(),n=t.oauth_tokens,i=n?{provider:n.provider,accessToken:n.access_token,accessTokenExpiresInSeconds:n.access_token_expires_in_seconds,refreshToken:n.refresh_token,refreshTokenExpiresInSeconds:n.refresh_token_expires_in_seconds,scopes:n.scopes}:void 0;return{user:(0,ic.i)(t),oAuthTokens:i}}catch(e){throw console.warn("Error linking account"),(0,n6.I)(e)}}async _refresh(){if(!this.api)throw new n6.P("Session has no API instance");if(!this.client)throw new n6.P("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let e=this.token,t=this.refreshToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let n;if(!(e&&t||this.mightHaveServerCookies))return null;{let i={};e&&(i.authorization=`Bearer ${e}`),n=await this.api.post(n6.C,t?{refresh_token:t}:{},{headers:i})}return this.handleTokenResponse(n),(0,ic.i)(n.user)}catch(e){if(e instanceof n6.J&&e.privyErrorCode===n6.a.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw(0,n6.I)(e)}}handleTokenResponse(e){e.session_update_action&&"set"!==e.session_update_action?"clear"===e.session_update_action?this.destroyLocalState():"ignore"===e.session_update_action&&(e.token&&(this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token)),e.identity_token&&this.storeIdentityToken(e.identity_token)):this._storeAllTokens(e)}_storeAllTokens(e){this.storeRefreshToken(e.refresh_token),this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),e.identity_token&&this.storeIdentityToken(e.identity_token)}async _destroy(){try{await this.api?.post(n6.D,{refresh_token:this.refreshToken})}catch(e){console.warn("Error destroying session")}this.destroyLocalState()}destroyLocalState(){this.storeRefreshToken(null),this.storeCustomerAccessToken(null),this.storePrivyAccessToken(null),this.clearIdentityToken()}storeCustomerAccessToken(e){if("string"==typeof e){let t=pR.get(p8);if(pR.put(p8,e),!this.client?.useServerCookies){let t=mK.parse(e)?.expiration;
54tA.A.set(p7,e,{sameSite:"Strict",secure:y7(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else pR.del(p8),tA.A.remove(p7),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(pR.put(p9,e),this.client?.useServerCookies||tA.A.set(mi,"t",{sameSite:"Strict",secure:y7(),expires:30})):(pR.del(p9),tA.A.remove("privy-refresh-token"),tA.A.remove(mi))}storePrivyAccessToken(e){"string"==typeof e?pR.put(me,e):pR.del(me)}storeIdentityToken(e){if(y9.setState({identityToken:e}),this.client?.useServerCookies)return;pR.put(mt,e);let t=mK.parse(e)?.expiration;tA.A.set(mn,e,{sameSite:"Strict",secure:y7(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){pR.del(mt),y9.setState({identityToken:null}),tA.A.remove(mn)}constructor(){this.authenticateOnce=new p4(async e=>this._authenticate(e)),this.linkOnce=new p4(async e=>this._link(e)),this.refreshOnce=new p4(this._refresh.bind(this)),this.destroyOnce=new p4(this._destroy.bind(this))}}var fi=0,fr="__private_"+fi+++"__getOrGenerateClientAnalyticsId";class fa{getAppId(){return this.appId}initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:i,store:r,walletList:a,shouldEnforceDefaultChainOnConnect:s,externalWalletConfig:o,appName:l,walletChainType:c,appKit:d}){this.connectors||(this.connectors=new y1(this.appId,e,t,n,i,r,a,s,o,l,c,d))}generateApi(){let e=new y3({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=e,e}updateApiUrl(e){this.apiUrl=e||this.fallbackApiUrl,this.api=this.generateApi(),e&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new n6.P("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new n6.P("No auth flow in progress.");let{oAuthTokens:e}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:e}}storeProviderAccessToken(e,t){this.session.storeProviderAccessToken(e,t)}getProviderAccessToken(e){return this.session.getProviderAccessToken(e)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(e){e.linkedAccounts.filter(e=>"cross_app"===e.type).forEach(e=>{this.storeProviderAccessToken(e.providerApp.id,null)})}startAuthFlow(e){return e.api=this.api,this.authFlow=e,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(n6.K,{action:"verify"})}catch(e){throw(0,n6.f)(e)}}async initMfaPasskeyVerification(){try{let e;return{rpId:(e=(await this.api.post(n6.L,{})).options).rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map(e=>({id:e.id,type:e.type,transports:e.transports}))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}catch(e){throw(0,n6.f)(e)}}async getCrossAppProviderDetails(e){try{return this._cachedProviderAppDetails[e]||(this._cachedProviderAppDetails[e]=await this.api.get(`/api/v1/apps/${e}/cross-app/details`)),this._cachedProviderAppDetails[e]}catch(e){console.error("Error fetching cross app provider details",e)}}async acceptTerms(){try{let e=await this.api.post(n6.M,{});return(0,ic.i)(e)}catch(e){throw(0,n6.I)(e)}}async unlinkEmail(e){try{let t=await this.api.post(n6.N,{address:e});return await this.getAuthenticatedUser()??(0,ic.i)(t)}catch(e){throw(0,n6.I)(e)}}async unlinkPhone(e){try{let t=await this.api.post(n6.O,{phoneNumber:e});return await this.getAuthenticatedUser()??(0,ic.i)(t)}catch(e){throw(0,n6.I)(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(n6.Q,{address:e});return await this.getAuthenticatedUser()??(0,ic.i)(t)}catch(e){throw(0,n6.I)(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(n6.R,{address:e});return await this.getAuthenticatedUser()??(0,ic.i)(t)}catch(e){throw(0,n6.I)(e)}}async unlinkOAuth(e,t){try{let n=await this.api.post(n6.S,{provider:e,subject:t});return await this.getAuthenticatedUser()??(0,ic.i)(n)}catch(e){throw(0,n6.I)(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(n6.T,{fid:e});return await this.getAuthenticatedUser()??(0,ic.i)(t)}catch(e){throw(0,n6.I)(e)}}async unlinkTelegram(e){try{let t=await this.api.post(n6.U,{telegram_user_id:e});return await this.getAuthenticatedUser()??(0,ic.i)(t)}catch(e){throw(0,n6.I)(e)}}async revokeDelegatedWallet(){try{await this.api.post(n6.V,{})}catch(e){throw(0,n6.I)(e)}}async createAnalyticsEvent({eventName:e,payload:t,timestamp:n,options:i}){if("undefined"!=typeof window)try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(n6.E,{event_name:e,client_id:this.clientAnalyticsId,payload:{...t||{}
54,clientTimestamp:n?n.toISOString():(new Date).toISOString()}},{retry:-1,keepalive:i?.keepAlive??!1})}catch(e){console.log("Unable to submit event. This is not an issue.")}}async signMoonpayOnRampUrl(e){try{return this.api.post(n6.W,e)}catch(e){throw(0,n6.I)(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(n6.X,e)}catch(e){throw(0,n6.I)(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${n6.Y}?partnerUserId=${e}`)}catch(e){throw(0,n6.I)(e)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(e){return await this.getPrivyAccessToken(e)||await this.getCustomerAccessToken(e)}async getCustomerAccessToken(e){return await this._getToken(ft.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(ft.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?mJ.parse(this.session.getToken(e))?.appId!==this.appId?(await this.logout(),null):this.session.getToken(e):(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials(e)?(await this.session.refresh(),this.session.getToken(e)):null:null}async getSmartWalletsConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let n=await this.api.get(`/api/v1/apps/${this.appId}/smart_wallets`,{baseURL:this.fallbackApiUrl,headers:e});return n.enabled?{enabled:n.enabled,smartWalletType:n.smart_wallet_type,configuredNetworks:n.configured_networks.map(e=>{let t,n;return{chainId:e.chain_id,bundlerUrl:e.bundler_url,paymasterUrl:e.paymaster_url,paymasterContext:(t=e.paymaster_url,n=e.paymaster_context,t&&y4.test(t)?y5:n&&n.policy_id?{policyId:n.policy_id}:void 0)}})}:{enabled:n.enabled}}catch(e){throw(0,n6.I)(e)}}async getUsdTokenPrice(e){try{return(await this.api.get(`/api/v1/token_price?chainId=${e.id}&tokenSymbol=${e.nativeCurrency.symbol}`)).usd}catch(t){return void console.error(`Unable to fetch token price for chain with id ${e.id}`)}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch(e){return void console.error("Unable to fetch token price for SOL")}}async getSplTokenMetadata({mintAddress:e,cluster:t}){try{return await this.api.get(`/api/v1/spl_token_info?mint_address=${e}&cluster=${t}`)}catch(n){return void console.error(`Unable to fetch token metadata for ${t}:${e}`)}}async requestFarcasterSignerStatus(e){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:e})}catch(e){throw console.error("Unable to fetch Farcaster signer status"),e}}async generateSiweNonce({address:e,captchaToken:t}){try{return(await this.api.post(n6.Z,{address:e,token:t})).nonce}catch(e){throw(0,n6.I)(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:i,connectorType:r,mode:a}){return await this.api.post(n6._,{message:e,signature:t,chainId:n,walletClientType:i,connectorType:r,mode:a})}async linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:i,connectorType:r}){return await this.api.post(n6.$,{message:e,signature:t,chainId:n,walletClientType:i,connectorType:r})}async linkSmartWallet({message:e,signature:t,smartWalletType:n}){try{let i=await this.api.post(n6.a0,{message:e,signature:t,smart_wallet_type:n});return(0,ic.i)(i)}catch(e){throw(0,n6.I)(e)}}async linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:i,connectorType:r}){try{let a=await this.linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:i,connectorType:r});return(0,ic.i)(a)}catch(e){throw(0,n6.I)(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(n6.a1,{address:e,token:t})).nonce}catch(e){throw(0,n6.I)(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:i,mode:r,messageType:a="plain"}){return await this.api.post(n6.a2,{message:e,signature:t,walletClientType:n,connectorType:i,mode:r,message_type:a})}async sendAccountTransferRequest({nonce:e,account:t,accountType:n,externalWalletMetadata:i,telegramAuthResult:r,telegramWebAppData:a,farcasterEmbeddedAddress:s,oAuthUserInfo:o}){try{let l,c;switch(n){case"email":l=n6.a8,c={nonce:e,email:t};break;case"sms":l=n6.a7,c={nonce:e,phoneNumber:t};break;case"siwe":if(l=n6.a6,!i)throw Error("Wallet parameters must be defined");c={nonce:e,address:t,...i};break;case"farcaster":l=n6.a5,c={nonce:e,farcaster_id:t,farcaster_embedded_address:s};break;case"telegram":l=n6.a4,c={nonce:e,telegram_auth_result:r,telegram_web_app_data:a};break;
54case"custom":case"guest":case"passkey":throw Error("Invalid transfer account type");default:l=n6.a3,c={nonce:e,userInfo:o}}let d=await this.api.post(l,c);return await this.getAuthenticatedUser()??(0,ic.i)(d)}catch(e){throw(0,n6.I)(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:i,messageType:r="plain"}){return await this.api.post(n6.a9,{message:e,signature:t,walletClientType:n,connectorType:i,message_type:r})}async linkWithSiws({message:e,signature:t,walletClientType:n,connectorType:i,messageType:r="plain"}){try{let a=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:i,messageType:r});return(0,ic.i)(a)}catch(e){throw(0,n6.I)(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(n6.aa);return this.session.updateIdentityToken(e.identity_token),(0,ic.i)(e.user)}catch(e){throw(0,n6.I)(e)}}async scanTransaction(e){try{return await this.api.post(n6.ab,e)}catch(e){throw(0,n6.I)(e)}}constructor({apiUrl:e=p6,appId:t,appClientId:n,timeout:i=2e4}){Object.defineProperty(this,fr,{value:fs}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==p6&&e.startsWith("https://privy."),this.timeout=i,this.appId=t,this.appClientId=n,this.clientAnalyticsId=(function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e})(this,fr)[fr](),r||(r=new fn),this.session=r,this.api=this.generateApi(),this.session.client=this}}function fs(){if("undefined"==typeof window)return null;try{let e=pR.get(mr);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=(0,e_.A)();try{return pR.put(mr,e),e}catch(t){return e}}let fo=({delayedExecution:e,...t})=>{let{enabled:n,siteKey:i,appId:r,setError:a,setToken:s,setExecuting:o,ref:l}=mz(),[,c]=(0,m.useMemo)(()=>i?.split("t:")||[],[i]);if((0,m.useEffect)(()=>l.current?.remove,[]),!n)return null;if(!c)throw Error("Unsupported captcha site key");return(0,h.jsx)("div",{className:"hidden h-0 w-0",children:(0,h.jsx)(iy.Xs,{...t,ref:l,siteKey:c,options:{action:r,size:"invisible",...e?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{t.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{t.onError?.(),a("Captcha failed"),o(!1)},onSuccess:e=>{t.onSuccess?.(e),s(e),o(!1)},onExpire:()=>{t.onExpire?.();try{l.current?.reset(),a(void 0),s(void 0)}catch(e){a("expired_and_failed_reset")}}})})},fl={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},connectOrCreateWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},update:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},setWalletRecovery:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},signTransaction:{onSuccess:[],onError:[]},signSolanaTransaction:{onSuccess:[],onError:[]},signSolanaMessage:{onSuccess:[],onError:[]},sendSolanaTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]},fundSolanaWallet:{onUserExited:[]},customAuth:{onAuthenticated:[],onUnauthenticated:[]}},fc=(0,m.createContext)(void 0),fd=()=>(0,m.useContext)(fc);function fu(e,t){if(!t)return;let n=fd().current[e];return(0,m.useEffect)(()=>{for(let[i,r]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,i)||console.warn(`Invalid event type "${i}" for action "${e}"`),n[i]?.push(r);return()=>{for(let[i,r]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,i)||console.warn(`Invalid event type "${i}" for action "${e}"`),n[i]=n[i]?.filter(e=>e!==r)}},[t])}function fh(e,t,n,...i){for(let r of e.current[t][n])r(...i)}function fp(){let e=fd();return(t,n,...i)=>fh(e,t,n,...i)}let fm=ig.I4.div.withConfig({displayName:"Grow",componentId:"sc-ddbf22b4-0"})(["text-align:left;flex-grow:1;"]),fy=ig.I4.div.withConfig({displayName:"AlignBottom",componentId:"sc-ddbf22b4-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),ff=ig.I4.div.withConfig({displayName:"LoginMethodContainer",componentId:"sc-ddbf22b4-2"})(["display:flex;flex-direction:column;gap:12px;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]),fg=(0,ig.I4)(ff).withConfig({displayName:"LoginMethodContainerWithScrollShadows",componentId:"sc-ddbf22b4-3"})([""," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;max-height:400px;overflow-y:auto;scrollbar-width:none;padding:2px;"],e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0),fw=(0,ig.AH)(["&&{width:100%;font-size:16px;line-height:24px;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-mdlg);transition:background-color 200ms ease;cursor:pointer;&:hover{background-color:var(--privy-color-background-2);}&:disabled{cursor:pointer;background-color:var(--privy-color-background-2);}svg{height:24px;max-height:24px;max-width:24px;}}"]),fv=ig.I4.div.withConfig({displayName:"Subtitle",componentId:"sc-ddbf22b4-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),fb=ig.I4.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-ddbf22b4-5"})(["",""],fw),fx=ig.I4.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-ddbf22b4-6"})(["",""],fw),f_=ig.I4.div.withConfig({displayName:"Hide",componentId:"sc-ddbf22b4-7"})(["width:100%;height:100%;min-height:inherit;display:flex;flex-direction:column;",""],e=>e.$if?"display: none;":""),fC=ig.I4.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-ddbf22b4-8"})(["width:100%;height:100%;padding:",";"],e=>e.$withPadding?"64px 0px":"0px"),fI=ig.I4.div.withConfig({displayName:"Header",componentId:"sc-ddbf22b4-9"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-bottom:32px;gap:12px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]);function fE(){let{promptMfa:e,init:t,submit:n,cancel:i,mfaMethods:r}=(0,m.useContext)(ic.P);return{promptMfa:e,init:t,submit:n,cancel:i,mfaMethods:r}}function fT(e){return(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 460 40",...e,children:(0,h.jsx)("g",{fill:e.color||"var(--privy-color-foreground)",children:(0,h.jsx)("path",{d:"M0 15.4v15.38h4.64V19.96h3.58c2.47 0 3.63-.01 3.77-.02 1-.08 1.49-.15 2.18-.3a9.45 9.45 0 0 0 4.6-2.37c1.66-1.57 2.64-3.87 2.81-6.56.02-.3.02-1.19 0-1.49-.1-1.77-.56-3.35-1.36-4.72A8.84 8.84 0 0 0 15.14.57c-.93-.3-1.75-.43-3.09-.54C11.9.02 10.2 0 5.93 0H0ZM10.85 4c1.85.05 3.1.45 4.16 1.3.22.17.54.49.69.68a5.97 5.97 0 0 1 1.19 3.13c.04.35.04 1.36 0 1.71-.08.68-.23 1.3-.44 1.85a4.8 4.8 0 0 1-1.09 1.68A5.63 5.63 0 0 1 12 15.92c-.6.08-.4.08-4.01.09H4.64V3.98h2.9c1.6 0 3.08 0 3.31.02ZM187.65 5.71v5.72h-.27l-.09-.14a15.9 15.9 0 0 0-1.21-1.73c-.43-.5-1-.95-1.7-1.36-.54-.3-1.05-.5-1.73-.63a8.98 8.98 0 0 0-1.7-.17 8.84 8.84 0 0 0-7.8 4.03 12.95 12.95 0 0 0-2.03 6.39c-.07.98-.06 2.15.02 3.13.2 2.47.87 4.53 2.02 6.25a8.98 8.98 0 0 0 10.22 3.65 6.5 6.5 0 0 0 2.8-1.93c.41-.51.84-1.1 1.1-1.55l.1-.17h.37v3.58h4.38V0h-4.48Zm-5.24 5.54c1.3.14 2.3.6 3.17 1.48.9.9 1.5 2.09 1.85 3.64.36 1.6.39 3.72.06 5.43a8.13 8.13 0 0 1-1.54 3.62 5.1 5.1 0 0 1-3.93 1.96 6.13 6.13 0 0 1-2.32-.31 5.87 5.87 0 0 1-3.33-3.5c-.39-1-.62-2.05-.72-3.32-.03
54-.32-.04-1.35-.02-1.73.08-1.56.4-2.91.96-4.05a6.2 6.2 0 0 1 1.06-1.58 5.08 5.08 0 0 1 3.6-1.66c.25-.02.9 0 1.16.02ZM210.07 15.39l.01 15.38h4.38l.01-3.57h.37l.09.15c.24.44.84 1.26 1.21 1.7a6.79 6.79 0 0 0 2.57 1.75 9.3 9.3 0 0 0 6.86-.49 9.28 9.28 0 0 0 4.05-4.07A13.05 13.05 0 0 0 231 21.6c.21-1.73.18-3.7-.09-5.32a13.03 13.03 0 0 0-1.5-4.3 9.1 9.1 0 0 0-3.75-3.63 9.15 9.15 0 0 0-4.43-.96 7.46 7.46 0 0 0-2.8.5A7.07 7.07 0 0 0 216 9.7c-.4.52-.82 1.12-1.1 1.59l-.07.14h-.27V0h-4.5Zm11.13-4.14c1.07.1 1.94.44 2.7 1.04a6.1 6.1 0 0 1 1.64 1.98c.43.84.78 2 .94 3.11.15 1.16.16 2.4.02 3.54a9.34 9.34 0 0 1-1.39 4.03 5.33 5.33 0 0 1-2.69 2.15c-.9.3-2.04.38-3.06.2a5.14 5.14 0 0 1-3.45-2.37 6.03 6.03 0 0 1-.45-.8c-.5-1.03-.8-2.2-.92-3.58-.04-.49-.06-.89-.05-1.53.01-.76.05-1.23.13-1.85.38-2.53 1.47-4.38 3.15-5.31a5.46 5.46 0 0 1 2.3-.63 10 10 0 0 1 1.13.02ZM69.05 2.17l-.01 2.77V7.7h-3.36v3.6h3.36v6.8l.01 7.15c.06 1.4.4 2.44 1.1 3.37a5.8 5.8 0 0 0 2.97 2.07c.91.3 1.83.42 2.9.38a8.71 8.71 0 0 0 2.66-.48l-.8-3.7-.38.06a4.96 4.96 0 0 1-2.43-.06c-.33-.1-.56-.25-.8-.49-.4-.41-.6-.88-.7-1.67-.02-.2-.02-.62-.03-6.82v-6.6h4.73V7.7h-4.73V2.16h-4.49ZM133.34 2.17V7.7h-3.39v3.6h3.38v6.9l.01 7.17a5.66 5.66 0 0 0 2.36 4.49c.85.6 2.03 1.03 3.26 1.17.85.1 2.03.05 2.81-.1.3-.06.75-.18 1-.26l.2-.06v-.05l-.81-3.67-.37.06a4.99 4.99 0 0 1-1.8.09c-.85-.13-1.32-.4-1.7-.97a2.63 2.63 0 0 1-.39-1.04c-.06-.4-.06 0-.06-7.1V11.3h4.7V7.7h-4.7l-.01-2.77V2.16h-4.49ZM293.41 2.36a14.56 14.56 0 0 0-13.7 16.07 14.59 14.59 0 0 0 21.86 11.08 14.5 14.5 0 0 0 7.11-14.07 14.61 14.61 0 0 0-6.53-10.73 14.49 14.49 0 0 0-8.74-2.35ZM350.8 2.36a10.17 10.17 0 0 0-7.56 4.2c-.16.2-.45.63-.58.83l-.05.1h-.47l-.01-4.36h-7.36v36.4h7.82V27.27h.49l.05.07a11.3 11.3 0 0 0 7.49 4.15 10.52 10.52 0 0 0 9.38-4.1c1.66-2.1 2.73-4.9 3.07-8.06.1-.87.13-1.4.13-2.37 0-.8 0-1.1-.07-1.76a15.95 15.95 0 0 0-3.23-8.72 12.8 12.8 0 0 0-1.85-1.84 10.49 10.49 0 0 0-7.26-2.28Zm-.94 6.05c1.27.15 2.33.65 3.2 1.5.98.96 1.67 2.31 2.03 4 .34 1.57.38 3.68.12 5.39a9.78 9.78 0 0 1-1.04 3.25c-.14.25-.44.69-.6.89a5.35 5.35 0 0 1-4.31 2.07 5.25 5.25 0 0 1-4.41-1.9 7.35 7.35 0 0 1-1.26-2.32 14.09 14.09 0 0 1-.62-4.83c.05-1.98.38-3.53 1.02-4.85a5.63 5.63 0 0 1 2.5-2.65c.66-.34 1.3-.5 2.14-.58.18-.02 1.04 0 1.23.03ZM363.63 3.1l-.01 3.2v3.16h1.43c1.26.01 1.44.02 1.54.04.42.09.66.28.79.62.08.23.08.08.08 2.96a911.57 911.57 0 0 1 .03 10.18v7.54h7.82v-7.4l.01-7.83c.03-.94.11-1.63.27-2.28.46-1.9 1.54-2.93 3.35-3.23.52-.08.2-.08 5-.08h4.4V3.08h-3.1c-3.48 0-3.91.01-4.67.1-1.83.2-3.04.79-3.96 1.88-.5.6-.9 1.32-1.26 2.26l-.06.17h-.46V3.09h-5.6c-4.46 0-5.6 0-5.6.02ZM390.8 16.95V30.8h3.87l3.86-.01V3.09h-7.73ZM400.6 3.1l-.01.4v.38l4.66 13.4 4.69 13.47.02.05h10.3l.03-.05 4.67-13.45 4.67-13.4V3.1h-7.43l-6.7 19.26h-.5l-3.28-9.5-3.31-9.64-.05-.12h-3.88l-3.88.01ZM430.98 3.1c-.01 0-.02.19-.02.4v.39l5.08 14.59c2.8 8.02 5.08 14.6 5.08 14.61.01.02-.22.02-4.8.02h-4.82v6.42h4.95c5.09 0 5.23 0 5.87-.06 3.15-.28 5.29-1.63 6.63-4.15.28-.55.44-.95.87-2.16L459 6.78l1-2.89v-.8h-7.43l-6.69 19.26h-.5l-3.27-9.46-3.31-9.64-.06-.16h-3.88l-3.88.01ZM36.57 7.36c-1.36.1-2.6.6-3.62 1.45a5.65 5.65 0 0 0-1.67 2.42l-.05.13H31V7.7h-4.35v23.08h4.5v-7.3c0-8 0-7.34.08-7.82a4.89 4.89 0 0 1 2.06-3.18c.83-.58 1.74-.89 2.87-.98a11.87 11.87 0 0 1 2.8.25H39v-4.3l-.21-.02c-.61-.07-1.74-.1-2.22-.07ZM51.08 7.41c-2.33.12-4.3.84-5.95 2.16a9.89 9.89 0 0 0-2.03 2.2 12.5 12.5 0 0 0-2 5.78 18.04 18.04 0 0 0 0 3.65 12.13 12.13 0 0 0 2.26 6.05 9.74 9.74 0 0 0 5 3.52c2.11.64 4.7.64 6.8 0a9.78 9.78 0 0 0 4.88-3.37c1.38-1.78 2.19-4 2.4-6.58.13-1.46.06-3.06-.18-4.42a11.24 11.24 0 0 0-3.58-6.6 10 10 0 0 0-5.75-2.35c-.56-.06-1.31-.07-1.85-.04Zm1.42 3.78c.88.1 1.62.34 2.28.75a6.13 6.13 0 0 1 1.99 2.15 10.31 10.31 0 0 1 1.2 5c.02 1.23-.12 2.44-.42 3.51a7.14 7.14 0 0 1-1.81 3.32c-.61.6-1.2.98-1.95 1.24a6 6 0 0 1-2 .3 5.7 5.7 0 0 1-2.72-.6 5 5 0 0 1-1.28-.94A7.1 7.1 0 0 1 46 22.73c-.57-1.99-.6-4.46-.08-6.5a7.24 7.24 0 0 1 2.03-3.67 5.13 5.13 0 0 1 3.35-1.4 11 11 0 0 1 1.2.03ZM92.05 7.4c-.96.06-1.56.15-2.3.33a9.62 9.62 0 0 0-6.09 4.66 13.5 13.5 0 0 0-1.71 7c0 .83 0 1.04.06 1.6.16 1.77.58 3.32 1.29 4.7A9.72 9.72 0 0 0 90.28 31c1.84.37 4.08.32 5.85-.13a9.07 9.07 0 0 0 5.02-3.1A7.64 7.64 0 0 0 102.5 25l-2.11-.39-2.11-.38-.08.13a4.72 4.72 0 0 1-2.35 2.55 6.3 6.3 0 0 1-2.23.58c-.29.03-1.13.03-1.44 0a6.35 6.35 0 0 1-3.02-1.04 5.93 5.93 0 0 1-2.02-2.43 8.44 8.44 0 0 1-.72-3.18v-.26h16.38v-.81c0-1.83-.06-2.76-.25-3.87-.2-1.22-.53-2.24-1.05-3.28a8.9 8.9 0 0 0-2.66-3.26 10.1 10.1 0 0 0-5.34-1.94 18.3 18.3 0 0 0-1.46-.03Zm1.3 3.75c1.2.13 2.19.55 3.05 1.3a5.8 5.8 0 0 1 1.78 2.96c.13.51.21 1.17.21 1.66v.15H86.43v-.12c.08-.97.3-1.78.72-2.61.5-1 1.2-1.8 2.14-2.42a5.32 5.32 0 0 1 2.9-.95c.2-.01.97 0 1.17.03ZM116.79 7.41c-2 .1-3.73.65-5.22 1.65a10.7 10.7 0 0 0-4.25 6.06 16.1 16.1 0 0 0-.5 5.8c.2 2.17.84 4.13 1.88 5.76.58.9 1.32 1.73 2.15 2.4a9.37 9.37 0 0 0 3.6 1.8 12.06 12.06 0 0 0 3.92.34 10.2 10.2 0 0 0 3.84-.95 8.31 8.31 0 0 0 4.76-6.75l.01-.04h-4.37l-.05.16a4.87 4.87 0 0 1-4.24 3.75c-.59.07-1.32.06-1.93-.05a5.47 5.47 0 0 1-3.5-2.27c-.56-.75-1-1.73-1.26-2.79a13.8 13.8 0 0 1-.16-5.24 7.77 7.77 0 0 1 2.1-4.3 5.48 5.48 0 0 1 2.15-1.3 6.4 6.4 0 0 1 3.89.1c.59.21 1.03.5 1.5.96a5.32 5.32 0 0 1 1.46 2.5l.04.15h4.37v-.06a8.22 8.22 0 0 0-5.31-6.94 10.98 10.98 0 0 0-4.88-.74ZM156.2 7.41a9.87 9.87 0 0 0-6 2.29 11.02 11.
5402 0 0 0-3.41 5.43c-.52 1.78-.68 3.9-.48 5.97.17 1.8.63 3.38 1.37 4.8a9.68 9.68 0 0 0 5.91 4.86c1.65.48 3.63.61 5.53.36 3.72-.49 6.55-2.62 7.56-5.69.12-.39.13-.42.1-.43-.02 0-4.13-.75-4.19-.75-.03 0-.04 0-.1.16-.18.42-.45.9-.72 1.22-.16.2-.49.53-.7.7-.67.54-1.5.9-2.43 1.08-.48.08-.83.11-1.41.11-.64 0-1.07-.04-1.6-.15a5.76 5.76 0 0 1-3.93-2.83 8 8 0 0 1-.99-3.79v-.16h16.38v-1.11l-.02-1.43c-.1-2.25-.53-4-1.35-5.59a9.24 9.24 0 0 0-6.18-4.75c-1.04-.26-2.2-.36-3.33-.3Zm1.45 3.74a5.35 5.35 0 0 1 3.66 1.94 6.1 6.1 0 0 1 1.38 4.01v.12h-11.97v-.06c0-.02 0-.14.02-.25a6.6 6.6 0 0 1 2.15-4.32 5.73 5.73 0 0 1 3.5-1.46c.25-.02 1 0 1.26.02ZM233.58 7.82l8.37 23.22a49.22 49.22 0 0 1-.67 1.9 5.36 5.36 0 0 1-1.14 1.8c-.41.4-.82.58-1.48.69-.27.04-1.03.03-1.35 0a8.05 8.05 0 0 1-1.1-.23l-1.08 3.67c0 .02.32.14.66.22.83.21 1.57.29 2.56.28.56-.01.8-.03 1.24-.1 2.71-.4 4.66-2.09 5.86-5.08l9.64-26.44c0-.02-4.82-.06-4.83-.05l-2.93 8.96-2.91 8.94h-.24l-.22-.65-2.91-8.95-2.7-8.3H233.53ZM293.05 35.8c-1.18.04-1.93.09-2.8.16-2.52.24-4.53.69-5.43 1.23-.7.41-.76.86-.2 1.28.88.66 3.29 1.19 6.36 1.4a48.55 48.55 0 0 0 5.75.05c3.47-.19 6.24-.78 7.11-1.5.22-.19.3-.34.3-.53 0-.1 0-.12-.04-.22-.35-.69-2.32-1.3-5.25-1.63a41.09 41.09 0 0 0-5.8-.24Zm0 0"})})})}let fA=ig.I4.div.withConfig({displayName:"TermsAndConditionsContainer",componentId:"sc-bdb69ecc-0"})(["margin-top:16px;font-size:13px;text-align:center;color:var(--privy-color-foreground-3);&& > a{color:var(--privy-color-accent);}"]);function fS({app:{legal:{privacyPolicyUrl:e,termsAndConditionsUrl:t,requireUsersAcceptTerms:n}},alwaysShowImplicitConsent:i}){let r=!(!e||!t);return(!n||i)&&(t||e)?(0,h.jsxs)(fA,{children:["By logging in I agree to the"," ",t&&(0,h.jsx)("a",{href:t,target:"_blank",children:r?"Terms":"Terms of Service"}),r&&" & ",e&&(0,h.jsx)("a",{href:e,target:"_blank",children:"Privacy Policy"})]}):(0,h.jsx)(fA,{})}let fk=()=>{let{appearance:e}=yK();return(0,h.jsx)(fP,{children:e.footerLogo??(0,h.jsx)("a",{href:"https://www.privy.io/",target:"_blank",id:"protected-by-privy",children:(0,h.jsx)(fT,{height:13,width:150})})})},fP=ig.I4.div.withConfig({displayName:"ModalFooter",componentId:"sc-bdb69ecc-1"})(["display:flex;align-items:center;justify-content:center;padding-top:8px;padding-bottom:12px;gap:8px;font-size:13px;&& a{padding:0.5rem 0;&:hover{text-decoration:none;}}@media all and (display-mode:standalone){padding-bottom:30px;}"]),fj=({backFn:e})=>(0,h.jsx)("div",{children:(0,h.jsx)(fM,{onClick:e,children:(0,h.jsx)(iC.A,{height:"16px",width:"16px",strokeWidth:2})})}),fO=({infoFn:e})=>(0,h.jsx)("div",{children:(0,h.jsx)(fD,{"aria-label":"info",onClick:e,children:(0,h.jsx)(iI.A,{height:"22px",width:"22px",strokeWidth:2})})}),fN=e=>(0,h.jsx)("div",{children:(0,h.jsx)(fM,{"aria-label":"close modal",onClick:e.onClose,children:(0,h.jsx)(iE.A,{height:"16px",width:"16px",strokeWidth:2})})}),fR=({backFn:e,infoFn:t,onClose:n,title:i,closeable:r=!0})=>{let{closePrivyModal:a}=(0,n8.u)(),s=yK();return(0,h.jsxs)(fU,{children:[(0,h.jsxs)(fL,{children:[e&&(0,h.jsx)(fj,{backFn:e}),t&&(0,h.jsx)(fO,{infoFn:t})]}),i&&(0,h.jsx)(fW,{id:"privy-dialog-title",children:i}),(0,h.jsx)(fF,{children:!s.render.standalone&&r&&(0,h.jsx)(fN,{onClose:n||(()=>a())})})]})},fM=ig.I4.button.withConfig({displayName:"StyledButton",componentId:"sc-f295093d-0"})(["&&{cursor:pointer;display:flex;opacity:0.6;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-full);padding:4px;> svg{margin:auto;color:var(--privy-color-foreground);}:hover{opacity:1;}}"]),fD=(0,ig.I4)(fM).withConfig({displayName:"TransparentStyledButton",componentId:"sc-f295093d-1"})(["&&{background-color:transparent;}"]),fU=ig.I4.div.withConfig({displayName:"StyledHeader",componentId:"sc-f295093d-2"})(["padding:16px 0;display:flex;align-items:center;justify-content:space-between;h2{font-size:16px;line-height:24px;font-weight:600;color:var(--privy-color-foreground);}"]),fL=ig.I4.div.withConfig({displayName:"LeftActionContainer",componentId:"sc-f295093d-3"})(["flex:1;align-items:center;display:flex;gap:8px;"]),fF=ig.I4.div.withConfig({displayName:"RightActionContainer",componentId:"sc-f295093d-4"})(["flex:1;display:flex;justify-content:flex-end;"]),fW=ig.I4.div.withConfig({displayName:"TitleContainer",componentId:"sc-f295093d-5"})(["overflow:hidden;white-space:nowrap;max-width:100%;text-overflow:ellipsis;text-align:center;color:var(--privy-color-foreground-2);"]),f$=ig.I4.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a63b1990-0"})(["display:flex;flex-direction:column;align-items:center;padding:0px 0px 30px;@media (max-width:440px){padding:10px 10px 20px;}"]),fB=ig.I4.div.withConfig({displayName:"Title",componentId:"sc-a63b1990-1"})(["font-size:18px;line-height:30px;text-align:center;font-weight:600;margin-bottom:10px;"]),fz=ig.I4.div.withConfig({displayName:"SubTitle",componentId:"sc-a63b1990-2"})(["font-size:0.875rem;text-align:center;"]),fq=ig.I4.div.withConfig({displayName:"Container",componentId:"sc-a63b1990-3"})(["display:flex;flex-direction:column;align-items:center;gap:10px;flex-grow:1;padding:20px 0;@media (max-width:440px){padding:10px 10px 20px;}"]),fV=ig.I4.div.withConfig({displayName:"List",componentId:"sc-a63b1990-4"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.75rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),fH=ig.I4.div.withConfig({displayName:"ListItemIcon",componentId:"sc-a63b1990-5"})(["width:25px;display:flex;align-items:center;justify-content:flex-start;> svg{z-index:2;height:25px !important;width:25px !important;color:var(--privy-color-accent);}"]),fG=ig.I4.div.withConfig({displayName:"ListItem",componentId:"sc-a63b1990-6"})(["display:flex;align-items:center;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;"]),fK=ig.I4.div.withConfig({displayName:"BottomSection",componentId:"sc-a63b1990-7"})(["display:flex;flex-direction:column;gap:10px;padding-top:20px;"]),fJ=ig.I4.div.withConfig({displayName:"MethodList",componentId:"sc-a63b1990-8"})(["display:flex;flex-direction:column;align-items:stretch;gap:1rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),fZ=ig.I4.div.withConfig({displayName:"MethodListItem",componentId:"sc-a63b1990-9"})(["display:flex;gap:5px;width:100%;position:relative;"]),fY=ig.I4.button.withConfig({displayName:"RemoveMethodButton",componentId:"sc-a63b1990-10"})(["&&{background-color:transparent;color:var(--privy-color-foreground-3);padding:0 0.75rem;display:flex;align-items:center;height:100%;> svg{z-index:2;height:20px !important;width:20px !important;}}&&:hover{color:var(--privy-color-error);}"]),fQ=ig.I4.div.withConfig({displayName:"MethodText",componentId:"sc-a63b1990-11"})(["display:flex;align-items:center;gap:0.5rem;> svg{z-index:2;height:20px !important;width:20px !important;}"]),fX=ig.I4.div.withConfig({displayName:"ExtraText",componentId:"sc-a63b1990-12"})(["display:flex;align-items:center;gap:6px;font-weight:400 !important;color:",";> svg{z-index:2;height:18px !important;width:18px !important;display:flex !important;align-items:flex-end;}"],e=>e.isAccent?"var(--privy-color-accent)":"var(--privy-color-foreground-3)"),f0=ig.I4.div.withConfig({displayName:"SmsInsecureText",componentId:"sc-a63b1990-13"})(["width:100%;display:flex;justify-content:space-between;"]),f1=ig.I4.p.withConfig({displayName:"TermsText",componentId:"sc-a63b1990-14"})(["text-align:left;width:100%;color:var(--privy-color-foreground-3) !important;"]),f2=ig.I4.button.withConfig({displayName:"PrimaryTextButton",componentId:"sc-a63b1990-15"})(["display:flex;flex-direction:row;align-items:center;justify-content:center;user-select:none;&{width:100%;cursor:pointer;border-radius:var(--privy-border-radius-md);font-size:0.875rem;line-height:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{color:",";background-color:transparent;padding:0.5rem 0px;}&:hover{text-decoration:underline;}"],e=>"dark"===e.theme?"var(--privy-color-foreground-2)":"var(--privy-color-accent)"),f3=ig.I4.div.withConfig({displayName:"IconWrapper",componentId:"sc-a63b1990-16"})(["display:flex;align-items:center;justify-content:center;color:var(--privy-color-accent);width:100%;> svg{z-index:2;width:3rem;height:3rem;}"]),f4=ig.I4.div.withConfig({displayName:"ErrorMessage",componentId:"sc-a63b1990-17"})(["color:var(--privy-color-error);"]),f5=({handleClose:e,user:t,onSelect:n})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:e},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(i_.A,{})}),(0,h.jsx)(fB,{children:"Verify your identity"}),(0,h.jsx)(fz,{children:"Choose a verification method"}),(0,h.jsxs)(fJ,{children:[t.mfaMethods.includes("totp")&&(0,h.jsxs)(fb,{onClick:()=>n("totp"),children:[(0,h.jsx)(iv.A,{}),"Authenticator App"]},"totp"),t.mfaMethods.includes("sms")&&(0,h.jsxs)(fb,{onClick:()=>n("sms"),children:[(0,h.jsx)(ix.A,{}),"SMS"]},"sms"),t.mfaMethods.includes("passkey")&&(0,h.jsxs)(fb,{onClick:()=>n("passkey"),children:[(0,h.jsx)(ib.A,{}),"Passkey"]},"passkey")]}),(0,h.jsx)(fP,{})]}
54),f6=({success:e,fail:t})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f8,{className:e?"success":t?"fail":""}),(0,h.jsx)(f7,{className:e?"success":t?"fail":""})]}),f8=ig.I4.span.withConfig({displayName:"Loader",componentId:"sc-ce7792e2-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";border-bottom-color:transparent;border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1.2s linear infinite;transition:border-color 800ms;}@keyframes rotation{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}&&&.success{border-color:var(--privy-color-success);border-bottom-color:var(--privy-color-success);}&&&.fail{border-color:var(--privy-color-error);border-bottom-color:var(--privy-color-error);}"],e=>e.color??"var(--privy-color-accent)"),f7=(0,ig.I4)(f8).withConfig({displayName:"LoaderFaint",componentId:"sc-ce7792e2-1"})(["&&{border-bottom-color:",";animation:none;opacity:0.5;}"],e=>e.color??"var(--privy-color-accent)"),f9=e=>(0,h.jsx)(ge,{color:e.color||"var(--privy-color-foreground-3)"}),ge=(0,ig.I4)(f8).withConfig({displayName:"StyledButtonLoader",componentId:"sc-ce7792e2-2"})(["&&{height:1rem;width:1rem;margin:2px 0;border-width:1.5px;transition:border-color 200ms ease;}"]),gt=ig.I4.button.withConfig({displayName:"Button",componentId:"sc-b2dfb420-0"})(["display:flex;flex-direction:row;align-items:center;justify-content:center;user-select:none;&{width:100%;cursor:pointer;border-radius:var(--privy-border-radius-md);font-size:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{padding:12px 16px;}"]),gn=({children:e,loading:t,disabled:n,success:i,loadingText:r="Loading...",...a})=>(0,h.jsx)(gs,{disabled:t||n,$success:i,...a,children:t?(0,h.jsxs)("span",{children:[(0,h.jsx)(f9,{}),r?(0,h.jsx)("span",{children:r}):null]}):e}),gi=({children:e,loading:t,disabled:n,...i})=>(0,h.jsx)(gr,{disabled:n,...i,children:t?(0,h.jsx)(f9,{color:"var(--privy-color-foreground-accent)"}):e}),gr=(0,ig.I4)(gt).withConfig({displayName:"StyledPrimaryButtonWithoutGray",componentId:"sc-b2dfb420-1"})(["position:relative;&&{background-color:var(--privy-color-accent);color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:disabled,&:hover:disabled,&:active:disabled{cursor:not-allowed;pointer-events:none;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent-dark);}"]),ga=({children:e,loading:t,disabled:n,loadingText:i="Loading...",...r})=>(0,h.jsx)(gs,{as:"a",disabled:t||n,...r,children:t?(0,h.jsxs)("span",{children:[(0,h.jsx)(f9,{}),i?(0,h.jsx)("span",{children:i}):null]}):e}),gs=(0,ig.I4)(gt).withConfig({displayName:"StyledPrimaryButton",componentId:"sc-b2dfb420-2"})(["position:relative;&&{background-color:",";color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:",";}&:active{background-color:",";}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}"," > span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],e=>e.$warn?"var(--privy-color-error)":e.$success?"var(--privy-color-success)":"var(--privy-color-accent)",e=>e.$warn?"var(--privy-color-error)":e.$success?"var(--privy-color-success)":"var(--privy-color-accent-dark)",e=>e.$warn?"var(--privy-color-error)":e.$success?"var(--privy-color-success)":"var(--privy-color-accent-dark)",e=>e.disabled?(0,ig.AH)(["&&&,&&&:hover,&&&:active{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;pointer-events:none;}"]):""),go=({children:e,loading:t,disabled:n,loadingText:i="Loading...",...r})=>(0,h.jsx)(gl,{disabled:t||n,...r,children:t?(0,h.jsxs)("span",{children:[(0,h.jsx)(f9,{}),i?(0,h.jsx)("span",{children:i}):null]}):e}),gl=(0,ig.I4)(gt).withConfig({displayName:"StyledSecondaryButton",componentId:"sc-b2dfb420-3"})(["&&{border-width:1px;border-color:",";color:var(--privy-color-foreground);transition:border-color 200ms ease;}&:hover,&:active{border-color:",";}&:hover:disabled,&:active:disabled{border-color:var(--privy-color-foreground-accent);color:var(--privy-color-foreground-3);cursor:not-allowed;}>
54 span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],e=>e.$warn?"var(--privy-color-error)":"var(--privy-color-foreground-4)",e=>e.$warn?"var(--privy-color-error)":"var(--privy-color-foreground-3)"),gc=ig.I4.button.withConfig({displayName:"SoftCtaButton",componentId:"sc-b2dfb420-4"})(["&&{padding:12px 16px;font-weight:500;text-align:center;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent);border-radius:var(--privy-border-radius-sm);min-width:144px;opacity:",";transition:opacity 200ms ease,background-color 200ms ease,color 200ms ease;user-select:none;"," &:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}}"],e=>e.invisible?"0":"1",e=>e.invisible&&(0,ig.AH)(["pointer-events:none;"])),gd=({children:e,onClick:t,disabled:n,isSubmitting:i,...r})=>(0,h.jsxs)(gu,{$isSubmitting:i,onClick:t,disabled:n,...r,children:[(0,h.jsx)("span",{children:e}),(0,h.jsx)("span",{children:(0,h.jsx)(f9,{})})]}),gu=ig.I4.button.withConfig({displayName:"StyledEmbeddedButton",componentId:"sc-b2dfb420-6"})(["&&{color:var(--privy-color-accent);font-size:16px;font-style:normal;font-weight:500;line-height:24px;cursor:pointer;border-radius:0px var(--privy-border-radius-mdlg) var(--privy-border-radius-mdlg) 0px;border:none;transition:color 200ms ease;@media (min-width:441px){font-size:14px;}:hover{color:var(--privy-color-accent-dark);}&& > :first-child{opacity:",";}&& > :last-child{position:absolute;display:flex;top:50%;left:50%;transform:translate3d(-50%,-50%,0);opacity:",";}:disabled,:hover:disabled{color:var(--privy-color-foreground-3);cursor:not-allowed;}}"],e=>+!e.$isSubmitting,e=>+!!e.$isSubmitting),gh=({label:e,children:t,valueStyles:n})=>(0,h.jsxs)(gp,{children:[(0,h.jsx)("div",{children:e}),(0,h.jsx)(gm,{style:{...n},children:t})]}),gp=ig.I4.div.withConfig({displayName:"StyledDetailsRow",componentId:"sc-4ebfdd45-0"})(["display:flex;align-items:center;justify-content:space-between;width:100%;> :first-child{color:var(--privy-color-foreground-3);text-align:left;}> :last-child{color:var(--privy-color-foreground-2);text-align:right;}"]),gm=ig.I4.div.withConfig({displayName:"ValueWrapper",componentId:"sc-4ebfdd45-1"})(["font-size:14px;line-height:100%;display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-full);background-color:var(--privy-color-background-2);padding:4px 8px;"]),gy=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2}),gf=e=>gy.format(e),gg=(e,t)=>{let n=gf(t*parseFloat(e));return"$0.00"!==n?n:"<$0.01"},gw=(e,t)=>{let n=gf(t*parseFloat((0,eu.c)(e)));return"$0.00"===n?"<$0.01":n},gv=(e,t,n=6,i=!1)=>`${gb(e,n,i)} ${t}`,gb=(e,t=6,n=!1)=>{let i=parseFloat((0,eu.c)(e)).toFixed(t).replace(/0+$/,"").replace(/\.$/,"");return n?i:`${"0"===i?"<0.001":i}`},gx=e=>e.reduce((e,t)=>e+t,0n);async function g_(e,t){try{return await e}catch{return t}}let gC="11111111111111111111111111111111",gI=["CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C","CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"],gE=["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"],gT=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2});function gA(e,t=6,n=!1,i=!1){let r=(parseFloat(e.toString())/1e9).toFixed(t).replace(/0+$/,"").replace(/\.$/,""),a=i?"":" SOL";return n?`${r}${a}`:`${"0"===r?"<0.001":r}${a}`}function gS(e,t){let n=parseFloat(e.toString())/1e9,i=gT.format(t*n);return"$0.00"===i?"<$0.01":i}function gk({amount:e,fee:t,tokenPrice:n,isUsdc:i}){let r=BigInt(Math.floor(parseFloat(e)*10**(i?6:9))),a=i?r:r+t;return{fundingAmountInBaseUnit:r,fundingAmountInUsd:n?gS(r,n):void 0,totalPriceInUsd:n?gS(a,n):void 0,totalPriceInNativeCurrency:gA(a),feePriceInNativeCurrency:gA(t),feePriceInUsd:n?gS(t,n):void 0}}let gP={"mainnet-beta":{EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:{symbol:"USDC",decimals:6,address:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"}
54,Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:{symbol:"USDT",decimals:6,address:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"},So11111111111111111111111111111111111111112:{symbol:"SOL",decimals:9,address:"So11111111111111111111111111111111111111112"}},devnet:{"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU":{symbol:"USDC",decimals:6,address:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"},EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS:{symbol:"USDT",decimals:6,address:"EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS"},So11111111111111111111111111111111111111112:{symbol:"SOL",decimals:9,address:"So11111111111111111111111111111111111111112"}},testnet:{}};async function gj(e,t,n){let i=gP[e];if(!i[n]){let r=await t.getSplTokenMetadata({mintAddress:n,cluster:e});r&&(i[n]={address:n,symbol:r.symbol,decimals:r.decimals})}return i[n]}function gO(e){return"version"in e}function gN(e,t){let n=(gO(e)?e.message:e.compileMessage()).staticAccountKeys.find(e=>e.toBase58()===t);if(!n)throw Error(`Transaction does not contain public key ${t}`);return n}function gR(e,t,n){return{signature:e,parsedTransaction:n??null,signedTransaction:t,fees:BigInt(n?.meta?.fee||0)}}async function gM(e,t){let{value:n}=await t.simulateTransaction(e);if("BlockhashNotFound"===n.err)throw Error("Simulation failed: Blockhash not found");return null==n.err&&n.logs?.every(e=>!/insufficient funds/gi.test(e))}async function gD({tx:e,connection:t,client:n,checkFunds:i}){let r=gO(e)?e.message:e.compileMessage(),a=r.staticAccountKeys[0]?.toBase58()??"",s=await async function(e,t){return BigInt((gO(e)?(await t.getFeeForMessage(e.message)).value:await e.getEstimatedFee(t))??0)}(e,t),o=!i||await g_(gM(e,t),!0),l={},c=[],d=await async function(e,t){return[...e.staticAccountKeys.map(e=>e),...(await Promise.all(e.addressTableLookups.map(async e=>t.getAddressLookupTable(e.accountKey).then(({value:e})=>e)))).map((t,n)=>[...e.addressTableLookups[n]?.writableIndexes.map(e=>{let i=t?.state.addresses[e];if(i)return{key:i,isWritable:!0,altIdx:n}})??[],...e.addressTableLookups[n]?.readonlyIndexes.map(e=>{let i=t?.state.addresses[e];if(i)return{key:i,isWritable:!1,altIdx:n}})??[]]).flat().filter(e=>!!e).sort((e,t)=>e.isWritable!==t.isWritable?e.isWritable?-1:1:e.altIdx-t.altIdx).map(({key:e})=>e)]}(r,t);for(let e of r.compiledInstructions){let i=r.staticAccountKeys[e.programIdIndex]?.toBase58()||"";if("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"!==i&&"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"!==i)if(i!==gC){if("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"===i){let t=await g_(function(e,t,n){let[i,r,a,s]=e.accountKeyIndexes.map(e=>t[e]);return{type:"ata-creation",program:n,payer:i?.toBase58(),ata:r?.toBase58(),owner:a?.toBase58(),mint:s?.toBase58()}}(e,d,i));if(!t){c.push({type:"unknown",program:i,discriminator:e.data[0]});continue}if(c.push(t),t.ata&&t.owner&&t.mint){l[t.ata]={owner:t.owner,mint:t.mint};continue}}if(gI.includes(i)){let r=await g_(gW(e,d,t,n,i));if(!r){c.push({type:"unknown",program:i,discriminator:e.data[0]});continue}c.push(r)}else if(gE.includes(i)){let r=await g_(g$(e,d,t,n,i));if(!r){c.push({type:"unknown",program:i,discriminator:e.data[0]});continue}c.push(r)}else c.push({type:"unknown",program:i,discriminator:e.data[0]})}else{let t=await g_(gF(e,d));if(!t){c.push({type:"unknown",program:i,discriminator:e.data[0]});continue}c.push(t)}else{let r=await g_(gL(e,d,t,n,l,i));if(!r){c.push({type:"unknown",program:i,discriminator:e.data[0]});continue}c.push(r),"spl-transfer"===r.type&&(r.fromAta&&r.fromAccount&&r.token.address&&(l[r.fromAta]??={owner:r.fromAccount,mint:r.token.address}),r.toAta&&r.toAccount&&r.token.address&&(l[r.toAta]??={owner:r.toAccount,mint:r.token.address}))}}return{spender:a,fee:s,instructions:c,hasFunds:!!o}}function gU(e,t=0){try{return function(e,t=0){let n=0n;for(let i=0;i<8;i++)n|=BigInt(e[t+i])<<BigInt(8*i);return n}(e,t)}catch{}try{return e.readBigInt64LE(t)}catch{}let n=mD(e);try{return((e,t=0)=>{let n=e[t],i=e[t+7];if(!n||!i)throw Error(`Buffer offset out of range: first: ${n}, last: ${i}.`);return(BigInt(e[t+4]+256*e[t+5]+65536*e[t+6]+(i<<24))<<32n)+BigInt(n+256*e[++t]+65536*e[++t]+0x1000000*e[++t])})(n)}catch{}try{return n.subarray(t).readBigInt64LE()}catch{}try{return n.readBigInt64LE(t)}catch{}return 0n}async function gL(e,t,n,i,r,a){let s=e.data[0],o=e.accountKeyIndexes.map(e=>t[e]);if(1===s){let[e,t,n]=o;return{type:"spl-init-account",program:a,account:e?.toBase58(),mint:t?.toBase58(),owner:n?.toBase58()}}if(3===s){let t,s,[l,c,d]=o,u="",h=c?r[c.toBase58()]:void 0;if(h)t=h.owner,u=h.mint;else if(c){let e=await n.getParsedAccountInfo(c,"confirmed"),i=e.value?.data;t=i?.parsed?.info?.owner,u=i?.parsed?.info?.mint??"",s=i?.parsed?.info?.tokenAmount?.decimals}if(!u&&l){let e=await n.getParsedAccountInfo(l,"confirmed"),t=e.value?.data;u=t?.parsed?.info?.mint??""}let p=yW(n.rpcEndpoint),m=await gj(p,i,u),y=m?.symbol??"";return s??=m?.decimals??9,{type:"spl-transfer",program:a,fromAta:l?.toBase58(),fromAccount:d?.toBase58(),toAta:c?.toBase58(),toAccount:t,value:gU(e.data,1),token:{symbol
54:y,decimals:s,address:u}}}if(9===s){let[e,t,n]=o;return{type:"spl-close-account",program:a,source:e?.toBase58(),destination:t?.toBase58(),owner:n?.toBase58()}}if(17===s)return{type:"spl-sync-native",program:a};throw Error(`Token program instruction type ${s} not supported`)}async function gF(e,t){let n=e.data[0],i=e.accountKeyIndexes.map(e=>t[e]);if(0===n){let[,t]=i;return{type:"create-account",program:gC,account:t?.toBase58(),value:gU(e.data,4),withSeed:!1}}if(2===n){let[t,n]=i;return{type:"sol-transfer",program:gC,fromAccount:t?.toBase58(),toAccount:n?.toBase58(),token:{symbol:"SOL",decimals:9},value:gU(e.data,4),withSeed:!1}}if(3===n){let[,t]=i,n=gU(e.data.slice(e.data.length-32-8-8));return{type:"create-account",program:gC,account:t?.toBase58(),withSeed:!0,value:n}}if(11===n){let[t,n]=i;return{type:"sol-transfer",program:gC,fromAccount:t?.toBase58(),toAccount:n?.toBase58(),value:gU(e.data,4),token:{symbol:"SOL",decimals:9},withSeed:!0}}throw Error(`System program instruction type ${n} not supported`)}async function gW(e,t,n,i,r){let a=e.accountKeyIndexes.map(e=>t[e]?.toBase58()),s=e.data[0],o=yW(n.rpcEndpoint);if(143===s){let t=a[10],n=a[11];return{type:"raydium-swap-base-input",program:r,mintIn:t,mintOut:n,tokenIn:t?await gj(o,i,t):void 0,tokenOut:n?await gj(o,i,n):void 0,amountIn:gU(e.data,8),minimumAmountOut:gU(e.data,16)}}if(55===s){let t=a[10],n=a[11];return{type:"raydium-swap-base-output",program:r,mintIn:t,mintOut:n,tokenIn:t?await gj(o,i,t):void 0,tokenOut:n?await gj(o,i,n):void 0,maxAmountIn:gU(e.data,8),amountOut:gU(e.data,16)}}throw Error(`Raydium swap program instruction type ${s} not supported`)}async function g$(e,t,n,i,r){let a=e.data[0],s=e.accountKeyIndexes.map(e=>t[e]),o=yW(n.rpcEndpoint);if([208,51,239,151,123,43,237,92].includes(a)){let t=s[5]?.toBase58(),n=s[6]?.toBase58();return{type:"jupiter-swap-exact-out-route",program:r,mintIn:t,mintOut:n,tokenIn:t?await gj(o,i,t):void 0,tokenOut:n?await gj(o,i,n):void 0,outAmount:gU(e.data,e.data.length-1-2-8-8),quotedInAmount:gU(e.data,e.data.length-1-2-8)}}if([176,209,105,168,154,125,69,62].includes(a)){let t=s[7]?.toBase58(),n=s[8]?.toBase58();return{type:"jupiter-swap-exact-out-route",program:r,mintIn:t,mintOut:n,tokenIn:t?await gj(o,i,t):void 0,tokenOut:n?await gj(o,i,n):void 0,outAmount:gU(e.data,e.data.length-1-2-8-8),quotedInAmount:gU(e.data,e.data.length-1-2-8)}}if([193,32,155,51,65,214,156,129].includes(a)){let t=s[7]?.toBase58(),n=s[8]?.toBase58();return{type:"jupiter-swap-shared-accounts-route",program:r,mintIn:t,mintOut:n,tokenIn:t?await gj(o,i,t):void 0,tokenOut:n?await gj(o,i,n):void 0,inAmount:gU(e.data,e.data.length-1-2-8-8),quotedOutAmount:gU(e.data,e.data.length-1-2-8)}}throw[62,198,214,193,213,159,108,210].includes(a)&&console.warn("Jupiter swap program instruction 'claim' not implemented"),[116,206,27,191,166,19,0,73].includes(a)&&console.warn("Jupiter swap program instruction 'claim_token' not implemented"),[26,74,236,151,104,64,183,249].includes(a)&&console.warn("Jupiter swap program instruction 'close_token' not implemented"),[229,194,212,172,8,10,134,147].includes(a)&&console.warn("Jupiter swap program instruction 'create_open_orders' not implemented"),[28,226,32,148,188,136,113,171].includes(a)&&console.warn("Jupiter swap program instruction 'create_program_open_orders' not implemented"),[232,242,197,253,240,143,129,52].includes(a)&&console.warn("Jupiter swap program instruction 'create_token_ledger' not implemented"),[147,241,123,100,244,132,174,118].includes(a)&&console.warn("Jupiter swap program instruction 'create_token_account' not implemented"),[229,23,203,151,122,227,173,42].includes(a)&&console.warn("Jupiter swap program instruction 'route' not implemented"),[150,86,71,116,167,93,14,104].includes(a)&&console.warn("Jupiter swap program instruction 'route_with_token_ledger' not implemented"),[228,85,185,112,78,79,77,2].includes(a)&&console.warn("Jupiter swap program instruction 'set_token_ledger' not implemented"),[230,121,143,80,119,159,106,170].includes(a)&&console.warn("Jupiter swap program instruction 'shared_accounts_route_with_token_ledger' not implemented"),Error(`Jupiter swap program instruction type ${a} not supported`)}let gB=({weiQuantities:e,tokenPrice:t,tokenSymbol:n})=>{let i=gx(e),r=t?gw(i,t):void 0,a=gv(i,n);return(0,h.jsx)(gV,{children:r||a})},gz=({weiQuantities:e,tokenPrice:t,tokenSymbol:n})=>{let i=gx(e),r=t?gw(i,t):void 0,a=gv(i,n);return(0,h.jsx)(gV,{children:r?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(gH,{children:"USD"}),"<$0.01"===r?(0,h.jsxs)(gK,{children:[(0,h.jsx)(gG,{children:"<"}),"$0.01"]}):r]}):a})},gq=({quantities:e,tokenPrice:t,tokenSymbol:n="SOL",tokenDecimals:i=9})=>{let r=e.reduce((e,t)=>
54e+t,0n),a=t&&"SOL"===n&&9===i?gS(r,t):void 0,s="SOL"===n&&9===i?gA(r):`${(0,eh.J)(r,i)} ${n}`;return(0,h.jsx)(gV,{children:a?(0,h.jsx)(h.Fragment,{children:"<$0.01"===a?(0,h.jsxs)(gK,{children:[(0,h.jsx)(gG,{children:"<"}),"$0.01"]}):a}):s})},gV=ig.I4.span.withConfig({displayName:"StyledPriceDisplay",componentId:"sc-596cd423-0"})(["font-size:14px;line-height:140%;display:flex;gap:4px;align-items:center;"]),gH=ig.I4.span.withConfig({displayName:"StyledPriceUnit",componentId:"sc-596cd423-1"})(["font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);"]),gG=ig.I4.span.withConfig({displayName:"TinyLessThan",componentId:"sc-596cd423-2"})(["font-size:10px;"]),gK=ig.I4.span.withConfig({displayName:"FlexCenter",componentId:"sc-596cd423-3"})(["display:flex;align-items:center;"]),gJ=ig.I4.div.withConfig({displayName:"BottomPusherContainer",componentId:"sc-cb963810-0"})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-end;margin-top:auto;gap:16px;flex-grow:100;"]),gZ=ig.I4.div.withConfig({displayName:"CenteredItem",componentId:"sc-cb963810-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;flex-grow:1;width:100%;"]),gY=ig.I4.div.withConfig({displayName:"HorizontallyCenteredItem",componentId:"sc-cb963810-2"})(["display:flex;flex-direction:column;align-items:center;width:100%;"]),gQ=(0,ig.I4)(gZ).withConfig({displayName:"CenteredItemWithPadding",componentId:"sc-cb963810-3"})(["padding:20px 0;"]),gX=(0,ig.I4)(gZ).withConfig({displayName:"CenteredItemWithGap",componentId:"sc-cb963810-4"})(["gap:16px;"]),g0=ig.I4.div.withConfig({displayName:"FlexContainer",componentId:"sc-cb963810-5"})(["display:flex;flex-direction:column;width:100%;"]),g1=ig.I4.div.withConfig({displayName:"FixedGappedContainer",componentId:"sc-cb963810-6"})(["display:flex;flex-direction:column;gap:8px;"]),g2=ig.I4.div.withConfig({displayName:"StyledCalloutSection",componentId:"sc-cb963810-8"})(["display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;text-align:left;gap:8px;padding:16px;margin-top:16px;margin-bottom:16px;width:100%;background:var(--privy-color-background-2);border-radius:var(--privy-border-radius-md);&& h4{color:var(--privy-color-foreground-3);font-size:14px;text-decoration:underline;font-weight:medium;}&& p{color:var(--privy-color-foreground-3);font-size:14px;}"]),g3=ig.I4.div.withConfig({displayName:"RefactorSpacerTop",componentId:"sc-cb963810-9"})(["height:16px;"]),g4=ig.I4.div.withConfig({displayName:"RefactorSpacerBottom",componentId:"sc-cb963810-10"})(["height:12px;"]),g5=ig.I4.div.withConfig({displayName:"RelativeContainer",componentId:"sc-cb963810-11"})(["position:relative;"]),g6=ig.I4.div.withConfig({displayName:"ConfigurableSpacer",componentId:"sc-cb963810-12"})(["height:","px;"],e=>e.height??"12"),g8=ig.I4.div.withConfig({displayName:"Circle",componentId:"sc-cb963810-13"})(["background-color:var(--privy-color-accent);display:flex;justify-content:center;align-items:center;border-radius:50%;border-color:white;border-width:2px !important;"]),g7=({gas:e,tokenPrice:t,tokenSymbol:n})=>(0,h.jsxs)(g0,{style:{paddingBottom:"12px"},children:[(0,h.jsxs)(we,{children:[(0,h.jsx)(wn,{children:"Est. Fees"}),(0,h.jsx)("div",{children:(0,h.jsx)(gz,{weiQuantities:[BigInt(e)],tokenPrice:t,tokenSymbol:n})})]}),t&&(0,h.jsx)(wt,{children:`${gv(BigInt(e),n)}`})]}),g9=({value:e,gas:t,tokenPrice:n,tokenSymbol:i})=>{let r=BigInt(e??0)+BigInt(t);return(0,h.jsxs)(g0,{children:[(0,h.jsxs)(we,{children:[(0,h.jsx)(wn,{children:"Total (including fees)"}),(0,h.jsx)("div",{children:(0,h.jsx)(gz,{weiQuantities:[BigInt(e||0),BigInt(t)],tokenPrice:n,tokenSymbol:i})})]}),n&&(0,h.jsx)(wt,{children:gv(r,i)})]})},we=ig.I4.div.withConfig({displayName:"TransactionTotalRow",componentId:"sc-f8ef9b74-0"})(["display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-top:4px;"]),wt=ig.I4.div.withConfig({displayName:"ValueConversionRow",componentId:"sc-f8ef9b74-1"})(["display:flex;flex-direction:row;height:12px;font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);font-weight:400;"]),wn=ig.I4.div.withConfig({displayName:"TotalText",componentId:"sc-f8ef9b74-2"})(["font-size:14px;line-height:22.4px;font-weight:400;"]),wi=(0,m.createContext)(void 0),wr=(0,m.createContext)(void 0),wa=({defaultValue:e,children:t})=>{let[n,i]=(0,m.useState)(e||null);return(0,h.jsx)(wi.Provider,{value:{activePanel:n,togglePanel:e=>{i(n===e?null:e)}},children:(0,h.jsx)(wd,{children:t})})},ws=({value:e,children:t})=>{let{activePanel:n,togglePanel:i}=(0,m.useContext)(wi),r=n===e;return(0,h.jsx)(wr.Provider,{value:{onToggle:()=>i(e),value:e},children:(0,h.jsx)(wm,{isActive:r?"true":"false","data-open":String(r),children:t})})},wo=({children:e})=>{let{activePanel:t}=(0,m.useContext)(wi),{onToggle:n,value:i}=(0,m.useContext)(wr),r=t===i;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(wu,{onClick:n,"data-open":String(r),children:[(0,h.jsx)(wp,{children:e}),(0,h.jsx)(wg,{isactive:r?"true":"false",children:(0,h.jsx)(iS.A,{height:"16px",width:"16px",strokeWidth:"2"})})]}),(0,h.jsx)(wh,{})]})},wl=({children:e})=>{let{activePanel:t}=(0,m.useContext)(wi),{value:n}=(0,m.useContext)(wr);return(0,h.jsx)(wy,{"data-open":String(t===n),children:(0,h.jsx)(wf,{children:e})})},wc=({children:e})=>{let{activePanel:t}=(0,m.useContext)(wi),{value:n}=(0,m.useContext)(wr);return(0,h.jsx)(wf,{children:"function"==typeof e?e({isActive:t===n}):e})}
54,wd=ig.I4.div.withConfig({displayName:"AccordionRoot",componentId:"sc-d25f9267-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;"]),wu=ig.I4.div.withConfig({displayName:"AccordionTriggerContainer",componentId:"sc-d25f9267-1"})(["display:flex;justify-content:space-between;align-items:center;width:100%;cursor:pointer;padding-bottom:8px;"]),wh=ig.I4.div.withConfig({displayName:"AccordionDivider",componentId:"sc-d25f9267-2"})(["width:100%;&&{border-top:1px solid;border-color:var(--privy-color-foreground-4);}padding-bottom:12px;"]),wp=ig.I4.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-d25f9267-3"})(["font-size:14px;font-weight:500;line-height:19.6px;width:100%;padding-right:8px;"]),wm=ig.I4.div.withConfig({displayName:"AccordionPanelContainer",componentId:"sc-d25f9267-4"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;padding:12px;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),wy=ig.I4.div.withConfig({displayName:"AccordionContentContainer",componentId:"sc-d25f9267-5"})(["position:relative;overflow:hidden;transition:max-height 25ms ease-out;&[data-open='true']{max-height:700px;}&[data-open='false']{max-height:0;}"]),wf=ig.I4.div.withConfig({displayName:"ContentWrapper",componentId:"sc-d25f9267-6"})(["display:flex;flex-direction:column;gap:12px;flex:1 1 auto;min-height:1px;"]),wg=ig.I4.div.withConfig({displayName:"IconWrapper",componentId:"sc-d25f9267-7"})(["transform:",";"],e=>"true"===e.isactive?"rotate(180deg)":"rotate(0deg)"),ww=({walletAddress:e,chainId:t=1,network:n,rpcEndpoint:i})=>{var r;return(0,h.jsx)(wv,{href:"ethereum"===n?((e,t)=>{let{chains:n}=(0,n8.u)(),i=`https://etherscan.io/address/${t}`,r=`${((e,t)=>{let n=Number(e),i=t.find(e=>e.id===n);if(!i)throw new n6.d(`Unsupported chainId ${e}`,4901);return i.blockExplorers?.default.url})(e,n)}/address/${t}`;if(!r)return i;try{new URL(r)}catch{return i}return r})(t,e):(r=yW(i||""),`https://explorer.solana.com/account/${e}?cluster=${r}`),target:"_blank",children:p$(e)})},wv=ig.I4.a.withConfig({displayName:"StyledLink",componentId:"sc-adda23e5-0"})(["&:hover{text-decoration:underline;}"]),wb=({from:e,to:t,txn:n,transactionInfo:i,tokenPrice:r,gas:a,tokenSymbol:s})=>{let o=BigInt(n?.value||0);return(0,h.jsx)(wa,{...yK().render.standalone?{defaultValue:"details"}:{},children:(0,h.jsxs)(ws,{value:"details",children:[(0,h.jsx)(wo,{children:(0,h.jsxs)(wx,{children:[(0,h.jsx)("div",{children:i?.title||"Details"}),(0,h.jsx)(w_,{children:(0,h.jsx)(gB,{weiQuantities:[o],tokenPrice:r,tokenSymbol:s})})]})}),(0,h.jsxs)(wl,{children:[(0,h.jsx)(gh,{label:"From",children:(0,h.jsx)(ww,{walletAddress:e,chainId:n.chainId||1,network:"ethereum"})}),(0,h.jsx)(gh,{label:"To",children:(0,h.jsx)(ww,{walletAddress:t,chainId:n.chainId||1,network:"ethereum"})}),i&&i.action&&(0,h.jsx)(gh,{label:"Action",children:i.action}),a&&(0,h.jsx)(g7,{value:n.value,gas:a,tokenPrice:r,tokenSymbol:s})]}),(0,h.jsx)(wc,{children:({isActive:e})=>(0,h.jsx)(g9,{value:n.value,displayFee:e,gas:a||"0x0",tokenPrice:r,tokenSymbol:s})})]})})},wx=ig.I4.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-e1259f7b-0"})(["display:flex;flex-direction:row;justify-content:space-between;"]),w_=ig.I4.div.withConfig({displayName:"TotalText",componentId:"sc-e1259f7b-1"})(["flex-shrink:0;padding-left:8px;"]),wC=({enabled:e=!0}={})=>{let{showFiatPrices:t,getUsdPriceForSol:n}=(0,n8.u)(),[i,r]=(0,m.useState)(!0),[a,s]=(0,m.useState)(void 0),[o,l]=(0,m.useState)(void 0);return(0,m.useEffect)(()=>{(async()=>{if(t&&e)try{r(!0);let e=await n();e?l(e):s(Error("Unable to fetch SOL price"))}catch(e){s(e)}finally{r(!1)}else r(!1)})()}
54,[]),{solPrice:o,isSolPriceLoading:i,solPriceError:a}};function wI(e){let{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:i}=(e=>{let{showFiatPrices:t,getUsdTokenPrice:n,chains:i}=(0,n8.u)(),[r,a]=(0,m.useState)(!0),[s,o]=(0,m.useState)(void 0),[l,c]=(0,m.useState)(void 0);return(0,m.useEffect)(()=>{e||=1;let r=(0,L.u)(i).find(t=>t.id===Number(e));(async()=>{if(t){if(!r)return a(!1),o(Error(`Unable to fetch token price on chain id ${e}`));try{a(!0);let e=await n(r);e?c(e):o(Error(`Unable to fetch token price on chain id ${r.id}`))}catch(e){o(e)}finally{a(!1)}}else a(!1)})()},[e]),{tokenPrice:l,isTokenPriceLoading:r,tokenPriceError:s}})("solana"===e?-1:e),{solPrice:r,isSolPriceLoading:a,solPriceError:s}=wC({enabled:"solana"===e});return"solana"===e?{tokenPrice:r,isTokenPriceLoading:a,tokenPriceError:s}:{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:i}}let wE=(0,m.createContext)(null);function wT(){let e=(0,m.useContext)(wE);return null===e?(console.warn("`useWallets` was called outside the PrivyProvider component"),{wallets:[],ready:!1}):e}async function wA(e,t,n,i){let r=im(e),a=await (async()=>i?await i():await t.prepareTransactionRequest({...r,account:{address:n,type:"json-rpc"}}))();return{...a,type:ih[a.type]}}let wS=({pendingTransaction:e})=>{let{getAccessToken:t}=(0,ic.u)(),{wallets:n}=wT(),{walletProxy:i,rpcConfig:r,chains:a,appId:s,nativeTokenSymbolForChainId:o}=(0,n8.u)(),[l,c]=(0,m.useState)(null),[d,u]=(0,m.useState)(e),{tokenPrice:p}=wI(d.chainId),y=o(e.chainId)||"ETH",f=(0,m.useMemo)(()=>n.find(e=>"privy"===e.walletClientType),[n]);return(0,m.useEffect)(()=>{(async function(){if(!await t()||!i||!f)return d;let e=pL(d.chainId,a,r,{appId:s}),n=await wA(d,e,f.address);return c((0,g.nj)(BigInt(n.gas??0))),n})().then(u).catch(console.error)},[i]),f?(0,h.jsx)(wk,{children:(0,h.jsx)(wb,{from:f.address,to:d.to,txn:d,gas:l??void 0,tokenPrice:p,tokenSymbol:y})}):null},wk=ig.I4.div.withConfig({displayName:"TransactionInfoWrapper",componentId:"sc-ec4f9711-0"})(["width:100%;padding:1rem 0;"]),wP=ig.I4.div.withConfig({displayName:"StackedContainer",componentId:"sc-f7e7d474-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]),wj=({style:e,...t})=>(0,h.jsx)("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...e},fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:(0,h.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.71369 17.5625V10.375C3.71369 6.44625 6.85845 3.25 10.7238 3.25H17.7953C18.6783 3.25 19.3941 2.52244 19.3941 1.625C19.3941 0.727562 18.6783 0 17.7953 0H10.7238C5.09529 0 0.516113 4.65419 0.516113 10.375V17.5625C0.516113 18.4599 1.23194 19.1875 2.1149 19.1875C2.99787 19.1875 3.71369 18.4599 3.71369 17.5625ZM17.7953 60.7501C18.6783 60.7501 19.3941 61.4777 19.3941 62.3751C19.3941 63.2726 18.6783 64.0001 17.7953 64.0001H10.7238C5.09529 64.0001 0.516113 59.3459 0.516113 53.6251V46.4376C0.516113 45.5402 1.23194 44.8126 2.1149 44.8126C2.99787 44.8126 3.71369 45.5402 3.71369 46.4376V53.6251C3.71369 57.5538 6.85845 60.7501 10.7238 60.7501H17.7953ZM63.4839 46.4376V53.6251C63.4839 59.3459 58.9048 64.0001 53.2763 64.0001H46.2047C45.3217 64.0001 44.6059 63.2726 44.6059 62.3751C44.6059 61.4777 45.3217 60.7501 46.2047 60.7501H53.2763C57.1416 60.7501 60.2864 57.5538 60.2864 53.6251V46.4376C60.2864 45.5402 61.0022 44.8126 61.8851 44.8126C62.7681 44.8126 63.4839 45.5402 63.4839 46.4376ZM63.4839 10.375V17.5625C63.4839 18.4599 62.7681 19.1875 61.8851 19.1875C61.0022 19.1875 60.2864 18.4599 60.2864 17.5625V10.375C60.2864 6.44625 57.1416 3.25 53.2763 3.25H46.2047C45.3217 3.25 44.6059 2.52244 44.6059 1.625C44.6059 0.727562 45.3217 0 46.2047 0H53.2763C58.9048 0 63.4839 4.65419 63.4839 10.375ZM43.0331 47.3022C43.7067 46.6698 43.7483 45.6022 43.1262 44.9176C42.5039 44.233 41.4536 44.1906 40.78 44.823C38.3832 47.0732 35.265 48.3125 31.9997 48.3125C28.7344 48.3125 25.6162 47.0732 23.2194 44.823C22.5457 44.1906 21.4955 44.233 20.8732 44.9176C20.251 45.6022 20.2927 46.6698 20.9
54663 47.3022C23.9784 50.1301 27.8968 51.6875 31.9997 51.6875C36.1026 51.6875 40.021 50.1301 43.0331 47.3022ZM35.3207 24.1249V36.1249C35.3207 38.5029 33.4173 40.4374 31.0777 40.4374H29.7249C28.8079 40.4374 28.0646 39.6819 28.0646 38.7499C28.0646 37.8179 28.8079 37.0624 29.7249 37.0624H31.0777C31.5863 37.0624 32.0001 36.6419 32.0001 36.1249V24.1249C32.0001 23.1929 32.7434 22.4374 33.6604 22.4374C34.5774 22.4374 35.3207 23.1929 35.3207 24.1249ZM46.7581 28.8437V24.0312C46.7581 23.151 46.056 22.4374 45.19 22.4374C44.324 22.4374 43.622 23.151 43.622 24.0312V28.8437C43.622 29.7239 44.324 30.4374 45.19 30.4374C46.056 30.4374 46.7581 29.7239 46.7581 28.8437ZM17.6109 28.8437C17.6109 29.7239 18.313 30.4374 19.1789 30.4374C20.0449 30.4374 20.747 29.7239 20.747 28.8437V24.0312C20.747 23.151 20.0449 22.4374 19.1789 22.4374C18.313 22.4374 17.6109 23.151 17.6109 24.0312V28.8437Z"})}),wO=({hasBlockingError:e,error:t,onClose:n,onBack:i,handleSubmit:r,account:a,submitSuccess:s})=>{let{pendingTransaction:o}=(0,n8.u)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:n},"header"),(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:s,fail:!!t}),(0,h.jsx)(t?iA.A:wj,{style:{width:"38px",height:"38px"}})]})}),(0,h.jsx)(fB,{style:{marginTop:"1rem"},children:"Verifying with passkey"}),(0,h.jsxs)(fV,{children:[(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(i_.A,{})}),"Approve this action using your touch, face, PIN, or hardware key."]}),(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(iT.A,{})}),"You last added a passkey on"," ",a?.firstVerifiedAt?.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),"."]})]}),o&&(0,h.jsx)(fq,{children:(0,h.jsx)(wS,{pendingTransaction:o})}),t&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f4,{style:{marginTop:"1.25rem"},children:t.message}),(0,h.jsx)(gn,{disabled:e,onClick:r,style:{marginTop:"1.25rem"},children:"Try again"})]}),i&&(0,h.jsx)(f2,{style:{marginTop:"1rem"},onClick:i,children:"Choose another method"}),(0,h.jsx)(fP,{})]})},wN=Array(6).fill("");var wR,wM=((wR=wM||{})[wR.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",wR[wR.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",wR);function wD(e){return/^[0-9]{1}$/.test(e)}function wU(e){return 6===e.length&&e.every(wD)}let wL=({onChange:e,disabled:t,errorReasonOverride:n,success:i})=>{let[r,a]=(0,m.useState)(wN),[s,o]=(0,m.useState)(null),[l,c]=(0,m.useState)(null),d=async t=>{t.preventDefault();let n=t.currentTarget.value.replace(/\s+/g,"");if(""===n)return;let i=r.reduce((e,t)=>e+Number(wD(t)),0),s=n.split(""),l=!s.every(wD),d=s.length+i>6;if(l)return o("Passcode can only be numbers"),void c(1);if(d)return o("Passcode must be exactly 6 numbers"),void c(1);o(null),c(null);let u=Number(t.currentTarget.name?.charAt(4)),h=[...n||[""]].slice(0,6-u),p=[...r.slice(0,u),...h,...r.slice(u+h.length)];a(p);let m=Math.min(Math.max(u+h.length,0),5),y=document.querySelector(`input[name=pin-${m}]`);if(y?.focus(),wU(p))try{await e(p.join(""));let t=document.querySelector(`input[name=pin-${m}]`);t?.blur()}catch(e){c(1),o(e.message)}else try{await e(null)}catch(e){c(1),o(e.message)}},u=i?"success":n||s?"fail":"";return(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(wF,{children:[(0,h.jsx)("div",{children:r.map((n,i)=>(0,h.jsx)("input",{name:`pin-${i}`,type:"text",value:r[i],onChange:d,onKeyUp:t=>{"Backspace"===t.key&&(t=>{1===l&&(o(null),c(null));let n=[...r.slice(0,t),"",...r.slice(t+1)];if(a(n),t>0){let e=document.querySelector(`input[name=pin-${t-1}]`);e?.focus()}wU(n)?e(n.join("")):e(null)})(i)},inputMode:"numeric",autoFocus:0===i,pattern:"[0-9]",className:u,autoComplete:y.Fr?"one-time-code":"off",disabled:t},i))}),(0,h.jsx)("div",{children:(0,h.jsx)(wW,{$fail:!!n||!!s,children:n||s})})]})})},wF=ig.I4.div.withConfig({displayName:"PinInputContainer",componentId:"sc-7a171f6-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;@media (max-width:440px){margin-top:8px;margin-bottom:8px;}> div:nth-child(1){display:flex;justify-content:center;gap:0.5rem;width:100%;border-radius:var(--privy-border-radius-md);> input{border:1px solid var(--privy-color-foreground-4);background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);padding:8px 10px;height:58px;width:46px;text-align:center;font-size:18px;}> input:disabled{background:var(--privy-color-background-2);}> input:focus{border:1px solid var(--privy-color-accent);}> input:invalid{border:1px solid var(--privy-color-error);}> input.success{border:1px solid var(--privy-color-success);}> input.fail{border:1px solid var(--privy-color-error);animation:shake 180ms;animation-iteration-count:2;}}@keyframes shake{0%{transform:translate(1px,0px);}33%{transform:translate(-1px,0px);}67%{transform:translate(-1px,0px);}100%{transform:translate(1px,0px);}}"]),wW=ig.I4.div.withConfig({displayName:"InputHelp",componentId:"sc-7a171f6-1"})(["line-height:20px;font-size:13px;display:flex;justify-content:flex-start;width:100%;color:",";"],e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)"),w$=({selectedMethod:e,submitSuccess:t,hasBlockingError:n,onClose:i,onBack:r,handleSubmitCode:a})=>{let{app:s}=yQ(),{pendingTransaction:o}=(0,n8.u)();switch(e){case"sms":return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:i},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(ix.A,{})}),(0,h.jsx)(fB,{children:"Enter verification code"}),(0,h.jsxs)(fq,{children:[(0,h.jsx)(wL,{success:t,disabled:n,onChange:a}),(0,h.jsxs)(fz,{children:["To continue, please enter the 6-digit code sent to your ",(0,h.jsx)("strong",{children:"mobile device"})]}),o&&(0,h.jsx)(wS,{pendingTransaction:o})]}),r&&(0,h.jsx)(f2,{theme:s?.appearance.palette.colorScheme,onClick:r,children:"Choose another method"}),(0,h.jsx)(go,{onClick:i,children:"Cancel"}),(0,h.jsx)(fP,{})]});case"totp":return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:i},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(iv.A,{})}),(0,h.jsx)(fB,{children:"Enter verification code"}),(0,h.jsxs)(fq,{children:[(0,h.jsx)(wL,{success:t,disabled:n,onChange:a}),(0,h.jsxs)(fz,{children:["To continue, please enter the 6-digit code generated from your"," ",(0,h.jsx)("strong",{children:"authenticator app"})]}),o&&(0,h.jsx)(wS,{pendingTransaction:o})]}),r&&(0,h.jsx)(f2,{theme:s?.appearance.palette.colorScheme,onClick:r,children:"Choose another method"}),(0,h.jsx)(go,{onClick:i,children:"Cancel"}),(0,h.jsx)(fP,{})]});default:return null}}
54,wB=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];class wz extends Error{constructor(e,t){super(t),this.type=e}}function wq(e){let t=e.type;return"string"==typeof t&&wB.includes(t)}function wV(e){return wq(e)&&"wallet_not_on_device"===e.type}function wH(e){return!!wq(e)&&"mfa_timeout"===e.type}function wG(e){return!!wq(e)&&"missing_or_invalid_mfa"===e.type}function wK(e){return!(!wq(e)||!e.message.includes("code 429"))}function wJ(e){let t;return"string"==typeof(t=e.type)&&"client_error"===t&&"MFA canceled"===e.message}let wZ=e=>!function(e){return!!wq(e)&&"mfa_verification_max_attempts_reached"===e.type}(e)?wG(e)?{isBlocking:!1,error:Error("The code you entered is not valid")}:wH(e)?{isBlocking:!0,error:Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")}:(console.error(e),{isBlocking:!1,error:Error("Something went wrong.")}):{isBlocking:!0,error:Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")},wY=({open:e,onClose:t})=>{let{user:n}=(0,ic.u)(),[i,r]=(0,m.useState)(n?.mfaMethods[0]??null),{init:a,cancel:s,submit:o}=fE(),[l,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(null),[p,y]=(0,m.useState)();(0,m.useEffect)(()=>{r(n?.mfaMethods[0]??null)},[n?.mfaMethods]);let f=(0,m.useRef)(!1);async function g(e){y(void 0);try{if(!e||!i)return;await o(i,e),c(!0),y(void 0),t()}catch(e){throw wZ(e).error}}async function w(e){if("passkey"!==e)try{r(e),await a(e)}catch(e){console.error(e)}else try{r(e);let n=await a(e);if(!n)throw Error("something went wrong");u(n),await o(e,n),c(!0),y(void 0),t()}catch(e){y(wZ(e))}}(0,m.useEffect)(()=>{!f.current&&i&&e&&(f.current=!0,w(i).finally(()=>{f.current=!1}))},[e]);let v=()=>{r(null),y(void 0),s(),t()};return e&&n?"passkey"===i?(0,h.jsx)(wO,{account:n.linkedAccounts.filter(e=>"passkey"===e.type&&e.enrolledInMfa).sort((e,t)=>t.firstVerifiedAt.valueOf()-e.firstVerifiedAt.valueOf())[0],submitSuccess:l,hasBlockingError:p?.isBlocking??!1,error:p?.error,onClose:v,onBack:()=>{r(null),y(void 0)},handleSubmit:()=>g(d).catch(y)}):i?(0,h.jsx)(w$,{submitSuccess:l,hasBlockingError:p?.isBlocking??!1,handleSubmitCode:g,selectedMethod:i,onClose:v,onBack:n.mfaMethods.length>1?()=>r(null):void 0}):(0,h.jsx)(f5,{user:n,onSelect:w,handleClose:v}):null},wQ=(0,ig.DU)([":root{--privy-border-radius-sm:6px;--privy-border-radius-md:12px;--privy-border-radius-mdlg:16px;--privy-border-radius-lg:24px;--privy-border-radius-full:9999px;--privy-color-background:",";--privy-color-background-2:",";--privy-color-background-3:",";--privy-color-foreground:",";--privy-color-foreground-2:",";--privy-color-foreground-3:",";--privy-color-foreground-4:",";--privy-color-foreground-accent:",";--privy-color-accent:",";--privy-color-accent-light:",";--privy-color-accent-lightest:",";--privy-color-accent-dark:",";--privy-color-accent-darkest:",";--privy-color-success:",";--privy-color-success-dark:",";--privy-color-success-light:",";--privy-color-error:",";--privy-color-error-light:",";--privy-color-warn:",";--privy-color-warn-light:",";--privy-height-modal-full:620px;--privy-height-modal-compact:480px;};"],e=>e.theme.background,e=>e.theme.background2,e=>e.theme.background3,e=>e.theme.foreground,e=>e.theme.foreground2,e=>e.theme.foreground3,e=>e.theme.foreground4,e=>e.theme.foregroundAccent,e=>e.theme.accent,e=>e.theme.accentLight,e=>e.theme.accentLightest,e=>e.theme.accentDark,e=>e.theme.accentDarkest,e=>e.theme.success,e=>e.theme.successDark,e=>e.theme.successLight,e=>e.theme.error,e=>e.theme.errorLight,e=>e.theme.warn,e=>e.theme.warnLight),wX=ig.I4.div.withConfig({displayName:"StylesWrapper",componentId:"sc-bc1e45b4-0"})([""," color:var(--privy-color-foreground-2);h3{font-size:16px;line-height:24px;font-weight:500;color:var(--privy-color-foreground-2);}h4{font-size:14px;line-height:20px;font-weight:500;color:var(--privy-color-foreground);}p{font-size:13px;line-height:20px;color:var(--privy-color-foreground-2);}
54button:focus,input:focus,optgroup:focus,select:focus,textarea:focus{outline:none;border-color:var(--privy-color-accent-light);box-shadow:0 0 0 1px var(--privy-color-accent-light);}.mobile-only{@media (min-width:441px){display:none;}}@keyframes fadein{0%{opacity:0;}100%{opacity:1;}}"],"\n  *,\n  ::before,\n  ::after {\n    box-sizing: border-box;\n    border-width: 0;\n    border-style: solid;\n  }\n\n  line-height: 1.15;\n  -webkit-text-size-adjust: 100%;\n  -moz-tab-size: 4;\n  tab-size: 4;\n  font-feature-settings: normal;\n\n  margin: 0;\n  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n    'Apple Color Emoji', 'Segoe UI Emoji';\n\n  hr {\n    height: 0;\n    color: inherit;\n    border-top-width: 1px;\n  }\n\n  abbr:where([title]) {\n    text-decoration: underline dotted;\n  }\n\n  h1,\n  h2,\n  h3,\n  h4,\n  h5,\n  h6 {\n    font-size: inherit;\n    font-weight: inherit;\n    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\
54n    'Apple Color Emoji', 'Segoe UI Emoji';\n    display: inline;\n  }\n\n  a {\n    color: inherit;\n    text-decoration: inherit;\n  }\n\n  b,\n  strong {\n    font-weight: bolder;\n  }\n\n  code,\n  kbd,\n  samp,\n  pre {\n    font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\n    font-size: 1em;\n  }\n\n  small {\n    font-size: 80%;\n  }\n\n  sub,\n  sup {\n    font-size: 75%;\n    line-height: 0;\n    position: relative;\n    vertical-align: baseline;\n  }\n\n  sub {\n    bottom: -0.25em;\n  }\n\n  sup {\n    top: -0.5em;\n  }\n\n  table {\n    text-indent: 0;\n    border-color: inherit;\n    border-collapse: collapse;\n  }\n\n  button,\n  input,\n  optgroup,\n  select,\n  textarea {\n    font-family: inherit;\n    font-size: 100%;\n    font-weight: inherit;\n    line-height: inherit;\n    color: inherit;\n    margin: 0;\n    padding: 0;\n  }\n\n  button,\n  select {\n    text-transform: none;\n  }\n\n  button,\n  [type='button'],\n  [type='reset'],\n  [type='submit'] {\n    -webkit-appearance: button;\n    background-color: transparent;\n    background-image: none;\n  }\n\n  ::-moz-focus-inner {\n    border-style: none;\n    padding: 0;\n  }\n\n  :-moz-focusring {\n    outline: 1px dotted ButtonText;\n  }\n\n  :-moz-ui-invalid {\n    box-shadow: none;\n  }\n\n  legend {\n    padding: 0;\n  }\n\n  progress {\n    vertical-align: baseline;\n  }\n\n  ::-webkit-inner-spin-button,\n  ::-webkit-outer-spin-button {\n    height: auto;\n  }\n\n  [type='search'] {\n    -webkit-appearance: textfield;\n    outline-offset: -2px;\n  }\n\n  ::-webkit-search-decoration {\n    -webkit-appearance: none;\n  }\n\n  ::-webkit-file-upload-button {\n    -webkit-appearance: button;\n    font: inherit;\n  }\n\n  summary {\n    display: list-item;\n  }\n\n  blockquote,\n  dl,\n  dd,\n  h1,\n  h2,\n  h3,\n  h4,\n  h5,\n  h6,\n  hr,\n  figure,\n  p,\n  pre {\n    margin: 0;\n  }\n\n  fieldset {\n    margin: 0;\n    padding: 0;\n  }\n\n  legend {\n    padding: 0;\n  }\n\n  ol,\n  ul,\n  menu {\n    list-style: none;\n    margin: 0;\n    padding: 0;\n  }\n\n  textarea {\n    resize: vertical;\n  }\n\n  input::placeholder,\n  textarea::placeholder {\n    opacity: 1;\n    color: #9ca3af;\n  }\n\n  button,\n  [role='button'] {\n    cursor: pointer;\n  }\n\n  :disabled {\n    cursor: default;\n  }\n\n  img,\n  svg,\n  video,\n  canvas,\n  audio,\n  iframe,\n  embed,\n  object {\n    display: block;\n  }\n\n  img,\n  video {\n    max-width: 100%;\n    height: auto;\n  }\n\n  [hidden] {\n    display: none;\n  }\n"),w0=({children:e,open:t,onClick:n,...i})=>(0,h.jsx)(ik.e,{show:t,as:m.Fragment,children:(0,h.jsxs)(iP.lG,{onClose:n,...i,as:w2,children:[(0,h.jsx)(ik._,{as:m.Fragment,enterFrom:"entering",leaveTo:"leaving",children:(0,h.jsx)(w1,{id:"privy-dialog-backdrop","aria-hidden":"true"})}),(0,h.jsx)(w3,{children:(0,h.jsx)(ik._,{as:m.Fragment,enterFrom:"entering",leaveTo:"leaving",children:(0,h.jsx)(iP.Lj,{as:w4,children:e})})})]})}),w1=ig.I4.div.withConfig({displayName:"Backdrop",componentId:"sc-3cfde0b5-0"})(["position:fixed;inset:0;transition:backdrop-filter 100ms ease;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);&.entering,&.leaving{backdrop-filter:unset;-webkit-backdrop-filter:unset;}"]),w2=ig.I4.div.withConfig({displayName:"DialogWrapper",componentId:"sc-3cfde0b5-1"})(["position:relative;z-index:999999;"]),w3=ig.I4.div.withConfig({displayName:"DialogContainer",componentId:"sc-3cfde0b5-2"})(["position:fixed;inset:0;display:flex;align-items:center;justify-content:center;width:100vw;min-height:100vh;"]),w4=ig.I4.div.withConfig({displayName:"Panel",componentId:"sc-3cfde0b5-3"})(["padding:0;background:transparent;border:none;width:100%;pointer-events:auto;outline:none;display:block;@media (max-width:440px){opacity:1;transform:translate3d(0,0,0);transition:transform 200ms ease-in;position:fixed;bottom:0;&.entering,&.leaving{opacity:0;transform:translate3d(0,100%,0);transition:transform 150ms ease-in 0ms,opacity 0ms ease 150ms;}}@media (min-width:441px){opacity:1;transition:opacity 100ms ease-in;&.entering,&.leaving{opacity:0;transition-delay:5ms;}margin:auto;width:360px;box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]),w5=ig.I4.div.withConfig({displayName:"CenterItem",componentId:"sc-3cfde0b5-4"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;"]),w6=({isMfaVerifying:e,onMfaVerificationComplete:t})=>{let{ready:n,isModalOpen:i}=(0,ic.u)(),{headless:r}=yK(),{currentScreen:a}=yQ(),{status:s,execute:o,reset:l,enabled:c}=mz(),d=i&&a&&a.isCaptchaRequired&&!r&&"ready"===s;return(0,m.useEffect)(()=>{d&&o()},[d]),(0,m.useEffect)(()=>
54{!i&&c&&l()},[i,c]),a&&!n&&a.isShownBeforeReady?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{}),(0,h.jsx)(g3,{}),(0,h.jsx)(w5,{children:(0,h.jsx)(f8,{})}),(0,h.jsx)(g4,{}),(0,h.jsx)(fP,{})]}):!a&&e?(0,h.jsx)(wY,{open:e,onClose:t}):a?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f_,{$if:!!e,children:(0,h.jsx)(a.component,{})}),(0,h.jsx)(f_,{$if:!e,children:(0,h.jsx)(wY,{open:e,onClose:t})})]}):null},w8=({isMfaVerifying:e,onMfaVerificationComplete:t})=>{let n=(0,m.useRef)(null);return(0,h.jsx)(ve,{style:{height:(e=>{let[t,n]=(0,m.useState)("auto");return(0,m.useEffect)(()=>{let t=new ResizeObserver(e=>{n(e[0]?.contentRect.height??"auto")});return e.current&&t.observe(e.current),()=>{e.current&&t.unobserve(e.current)}},[e.current]),t})(n)},id:"privy-modal-content",children:(0,h.jsx)("div",{ref:n,children:(0,h.jsx)(w6,{isMfaVerifying:e,onMfaVerificationComplete:t})})})},w7=({open:e})=>{let t=yK(),{gracefulClosePrivyModal:n}=(()=>{let{closePrivyModal:e}=(0,n8.u)(),{onUserCloseViaDialogOrKeybindRef:t}=yQ();return{gracefulClosePrivyModal:(0,m.useCallback)(()=>{if(!t?.current)return e({shouldCallAuthOnSuccess:!1});t.current()},[e])}})(),[i,r]=(0,m.useState)(!1);fu("configureMfa",{onMfaRequired:()=>{t.mfa.noPromptOnMfaRequired||r(!0)}});let a=e||i;return t.render.standalone?(0,h.jsx)(wX,{children:(0,h.jsx)(w9,{id:"privy-modal-content",children:(0,h.jsx)(w6,{isMfaVerifying:i,onMfaVerificationComplete:()=>r(!1)})})}):(0,h.jsx)(w0,{open:a,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>n(),children:(0,h.jsx)(wX,{children:(0,h.jsx)(w8,{isMfaVerifying:i,onMfaVerificationComplete:()=>r(!1)})})})},w9=ig.I4.div.withConfig({displayName:"ContentWrapper",componentId:"sc-df48cc55-0"})(["display:flex;flex-direction:column;text-align:center;font-size:14px;line-height:20px;width:100%;background:var(--privy-color-background);padding:0 16px;"]),ve=(0,ig.I4)(w9).withConfig({displayName:"BaseModal",componentId:"sc-df48cc55-1"})(["transition:height 150ms ease-out;overflow-x:hidden;overflow-y:auto;scrollbar-width:none;max-height:calc(100svh - 32px);border-radius:var(--privy-border-radius-lg) var(--privy-border-radius-lg) 0 0;box-shadow:0px 0px 36px rgba(55,65,81,0.15);@media (min-width:441px){box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]);function vt(e){let t=(0,m.useRef)(null),n=(0,m.useRef)();return(0,m.useEffect)(()=>{n.current?.remove(),n.current=function({botUsername:e,scriptHost:t}){let n=document.createElement("script"),{origin:i}=new URL(t);return n.async=!0,n.src=`${i}/js/telegram-login.js`,n.setAttribute("data-telegram-login",e),n.setAttribute("data-request-access","write"),n.setAttribute("data-lang","en"),n}(e),t.current?.after(n.current)},[e]),(0,h.jsx)("div",{ref:t,hidden:!0})}let vn=()=>{let{solanaWallets:e}=(0,n8.u)(),{ready:t,wallets:n}=wT();return(0,m.useEffect)(()=>{if(t){let t=[...n,...e].map(e=>({address:e.address,connectorType:e.connectorType,walletClientType:e.walletClientType,connectedAt:e.connectedAt,id:e.meta.id}));pR.put(mp,t)}},[t,n,e]),null};async function vi(e,t,n,i,r,a=!1){let s=a,o=async o=>{if(s&&t&&t.length>0){o===+!a?r("configureMfa","onMfaRequired",{mfaMethods:t}):i.current?.reject(new wz("missing_or_invalid_mfa","MFA verification failed, retry."));let s=await new Promise((e,t)=>{n.current={resolve:e,reject:t},setTimeout(()=>{let e=new wz("mfa_timeout","Timed out waiting for MFA code");i.current?.reject(e),t(e)},3e5)});return await e(s)}return await e()},l=null;for(let e=0;e<4;e++)try{l=await o(e),i.current?.resolve(void 0);break}catch(e){if("missing_or_invalid_mfa"!==e.type)throw i.current?.resolve(void 0),e;s=!0}if(null===l){let e=new wz("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw i.current?.reject(e),e}return l}let vr=(Cl=0,()=>"id-"+Cl++);function va(e){return void 0!==e.error}let vs=new class{enqueue(e,t){this.callbacks[e]=t}dequeue(e,t){let n=this.callbacks[t];if(!n)throw Error(`cannot dequeue ${e} event: no event found for id ${t}`);switch(delete this.callbacks[t],e){case"privy:iframe:ready":case"privy:user-signer:sign":case"privy:wallets:add":case"privy:wallets:import":case"privy:wallets:set-recovery":case"privy:wallets:connect":case"privy:wallets:recover":case"privy:wallets:rpc":case"privy:wallet:create":case"privy:mfa:verify":case"privy:mfa:init-enrollment":case"privy:mfa:submit-enrollment":case"privy:mfa:unenroll":case"privy:mfa:clear":case"privy:auth:unlink-passkey":case"privy:farcaster:init-signer":case"privy:farcaster:sign":case"privy:solana-wallet:create":case"privy:delegated-actions:consent":return n;default:throw Error(`invalid wallet event type ${e}`)}}constructor(){this.callbacks={}}},vo=new Map,vl=(e,t)=>
54"bigint"==typeof t?t.toString():t;function vc(e,t,n,i){let r=n.contentWindow;if(!r)throw Error("iframe not initialized");let a=`${e}${JSON.stringify(t,vl)}`;if("privy:wallet:create"===e){let e=vo.get(a);if(e)return e}let s=new Promise((n,a)=>{let s=vr();vs.enqueue(s,{resolve:n,reject:a}),r.postMessage({id:s,event:e,data:t},i)}).finally(()=>{vo.delete(a)});return vo.set(a,s),s}function vd(e){let t=yJ(),n=(0,m.useRef)(null),i=(0,m.useRef)(e.mfaMethods),r=fp(),[a,s]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{i.current=e.mfaMethods},[e.mfaMethods]),(0,m.useEffect)(()=>{if(!a)return;let t=n.current;if(!t)return;function s(t){var n;t&&t.origin===e.origin&&"string"==typeof(n=t.data).event&&/^privy:.+/.test(n.event)&&function(e){switch(e.event){case"privy:iframe:ready":let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data);case"privy:user-signer:sign":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:add":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:set-recovery":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:connect":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:recover":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:rpc":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallet:create":let n=vs.dequeue(e.event,e.id);return va(e)?n.reject(new wz(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallets:import":let i=vs.dequeue(e.event,e.id);return va(e)?i.reject(new wz(e.error.type,e.error.message)):i.resolve(e.data);case"privy:mfa:verify":let r=vs.dequeue(e.event,e.id);return va(e)?r.reject(new wz(e.error.type,e.error.message)):r.resolve(e.data);case"privy:mfa:init-enrollment":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:submit-enrollment":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:unenroll":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:clear":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:auth:unlink-passkey":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:solana-wallet:create":let a=vs.dequeue(e.event,e.id);return va(e)?a.reject(new wz(e.error.type,e.error.message)):a.resolve(e.data);case"privy:farcaster:init-signer":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:farcaster:sign":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:delegated-actions:consent":{let t=vs.dequeue(e.event,e.id);return va(e)?t.reject(new wz(e.error.type,e.error.message)):t.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}(t.data)}let o={signWithUserSigner:n=>vi(i=>vc("privy:user-signer:sign",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),addWallet:n=>vi(i=>vc("privy:wallets:add",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),setRecovery:n=>vi(i=>vc("privy:wallets:set-recovery",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),connect:n=>vi(i=>vc("privy:wallets:connect",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),recover:n=>vi(i=>vc("privy:wallets:recover",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r,!n.recoveryAccessToken&&!n.recoveryPassword&&!n.recoverySecretOverride),rpc:n=>
54vi(i=>vc("privy:wallets:rpc",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),create:n=>vc("privy:wallet:create",n,t,e.origin),importWallet:n=>vc("privy:wallets:import",n,t,e.origin),createSolana:n=>vi(i=>vc("privy:solana-wallet:create",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),createDelegatedAction:n=>vc("privy:delegated-actions:consent",n,t,e.origin),verifyMfa:n=>vi(i=>vc("privy:mfa:verify",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r,!0),initEnrollMfa:n=>vi(i=>vc("privy:mfa:init-enrollment",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),submitEnrollMfa:n=>vi(i=>vc("privy:mfa:submit-enrollment",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),unenrollMfa:n=>vi(i=>vc("privy:mfa:unenroll",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),clearMfa:n=>vc("privy:mfa:clear",n,t,e.origin),unlinkPasskeyAccount:n=>vi(i=>vc("privy:auth:unlink-passkey",{...n,...i},t,e.origin),i.current,e.mfaPromise,e.mfaSubmitPromise,r),initFarcasterSigner:n=>vc("privy:farcaster:init-signer",n,t,e.origin),signFarcasterMessage:n=>vc("privy:farcaster:sign",n,t,e.origin)};window.addEventListener("message",s);let l=new AbortController;return pq(()=>vc("privy:iframe:ready",{},t,e.origin),{abortSignal:l.signal}).then(()=>e.onLoad(o),(...t)=>{console.warn("Privy iframe failed to load: ",...t),e.onLoadFailed()}),()=>{window.removeEventListener("message",s),l.abort()}},[a]),t?(0,h.jsx)("iframe",{ref:n,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>s(!0),src:pV(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId,client_id:e.appClientId})}):null}function vu(e){return["ethereum","solana"].includes(e.chainType)}let vh=e=>e.linkedAccounts.filter(e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.delegated);async function vp({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWalletIndex:i,walletProxy:r,transactionRequest:a,requesterAppId:s}){return(await r.rpc({entropyId:t,entropyIdVerifier:n,hdWalletIndex:i??0,chainType:"ethereum",accessToken:e,requesterAppId:s,request:{method:"eth_signTransaction",params:[a]}})).response.data}function vm(e){let t=e.replace("eip155:","");if(t)return parseInt(t);throw Error("Chain ID not compatible with CAIP-2 format.")}let vy="popup-privy-oauth",vf="PRIVY_OAUTH_USE_BROADCAST_CHANNEL";class vg{async authenticate(){if(!this.api)throw new n6.P("Auth flow has no API instance");try{return await this.api.post(n6.o,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw(0,n6.f)(e)}}async link(){if(!this.api)throw new n6.P("Auth flow has no API instance");try{return await this.api.post(n6.j,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw(0,n6.f)(e)}}constructor({authorizationCode:e,stateCode:t,codeVerifier:n,provider:i}){this.meta={authorizationCode:e,stateCode:t,codeVerifier:n,provider:i}}}async function vw({api:e,requesterAppId:t,providerAppId:n}){let i=(await e.get(`/api/v1/apps/${t}/cross-app/connections`)).connections.find(e=>e.provider_app_id===n);if(!i)throw new n6.P("Invalid connected app");return{name:i.provider_app_name,logoUrl:i.provider_app_icon_url||void 0,apiUrl:i.provider_app_custom_api_url,readOnly:i.read_only}}let vv=()=>window.open(void 0,void 0,vb({w:440,h:680})),vb=({w:e,h:t})=>{let n=void 0!==window.screenLeft?window.screenLeft:window.screenX,i=void 0!==window.screenTop?window.screenTop:window.screenY,r=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,a=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;return`toolbar=0,location=0,menubar=0,height=${t},width=${e},popup=1,left=${(r-e)/2/(r/window.screen.availWidth)+n},top=${(a-t)/2/(a/window.screen.availHeight)+i}`},vx=async({user:e,address:t,client:n,request:i,requesterAppId:r,reconnect:a})=>{n.createAnalyticsEvent({eventName:"cross_app_request_started",payload:{address:t,method:i.method}});let s=e?.linkedAccounts.find(e=>"cross_app"===e.type&&(e.embeddedWallets.some(e=>e.address===t)||e.smartWallets.some(e=>e.address===t)));if(!e||!s)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Cannot request a signature with this wallet address",address:t}}),new n6.P("Cannot request a signature with this wallet address");let o=n.getProviderAccessToken(s.providerApp.id),l=await vw({api:n.api,requesterAppId:r,providerAppId:s.providerApp.id});if(!o){if(l.readOnly)throw console.error("cannot transact against a read-only provider app"),new n6.P("Cannot transact against a read-only provider app");await a({appId:s.providerApp.id,action:"link"})&&(o=n.getProviderAccessToken(s.providerApp.id))}if(!o)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Transactions require a valid token",address:t}}),new n6.P("Transactions require a valid token");let c=vv();if(!c)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Missing token",address:t}}),new n6.P("Failed to initialize signature request");let d=new URL(`${l.apiUrl}/oauth/transact`);return d.searchParams.set("token",o||""),d.searchParams.set("request",v_(i)),c.location=d.href,new Promise((e,r)=>{let a=setTimeout(()=>{d(),r(new n6.P("Request timeout")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Request timeout",address:t}})},12e4),o=setInterval(()=>{c.closed&&(d(),r(new n6.P("User rejected request")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"User rejected request",address:t}}))},300),l=a=>{a.data&&("set"===a.data.token?.action&&void 0!==a.data.token?.value?n.storeProviderAccessToken(s.providerApp.id,a.data.token.value):"clear"===a.data.token?.action&&n.storeProviderAccessToken(s.providerApp.id,null),"PRIVY_CROSS_APP_ACTION_RESPONSE"===a.data.type&&a.data.result&&(d(),e(a.data.result),n.createAnalyticsEvent({eventName:"cross_app_request_success",payload:{address:t,method:i.method}})),"PRIVY_CROSS_APP_ACTION_ERROR"===a.data.type&&a.data.error&&(d(),r(a.data.error),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:a.data.error,address:t}})))};window.addEventListener("message",l);let d=()=>{c.close(),clearInterval(o),clearTimeout(a),window.removeEventListener("message",l)}})},v_=e=>JSON.stringify({content:{request:{request:vC(e,g.nj)}},timestamp:Date.now(),callbackUrl:window.origin}),vC=(e,t)=>"bigint"==typeof e?t(e):Array.isArray(e)?e.map(e=>vC(e,t)):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,vC(n,t)])):e,vI=({title:e,description:t,children:n,...i})=>(0,h.jsx)(vA,{...i,children:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("h3",{children:e}),"string"==typeof t?(0,h.jsx)("p",{children:t}):t,n]})}),vE=(0,ig.I4)(vI).withConfig({displayName:"PaddedScreenHeader",componentId:"sc-523a75d6-0"})(["margin-bottom:24px;"]),vT=({title:e,description:t,icon:n,children:i,...r})=>(0,h.jsxs)(vS,{...r,children:[n||null,(0,h.jsx)("h3",{children:e}),t&&"string"==typeof t?(0,h.jsx)("p",{children:t}):t,i]}),vA=ig.I4.div.withConfig({displayName:"StyledSection",componentId:"sc-523a75d6-1"})(["display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;text-align:left;gap:8px;width:100%;margin-bottom:24px;&& h3{font-size:17px;color:var(--privy-color-foreground);}&& p{color:var(--privy-color-foreground-2);font-size:14px;}"]),vS=(0,ig.I4)(vA).withConfig({displayName:"CenteredStyledSection",componentId:"sc-523a75d6-2"})(["align-items:center;text-align:center;gap:16px;h3{margin-bottom:24px;}"]),vk=e=>(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 21 20",...e,children:[(0,h.jsx)("path",{fill:"url(#icloud-gradient)",d:"M12.34 7.315a4.26 4.26 0 0 0-3.707 2.18 2.336 2.336 0 0 0-1.02-.236 2.336 2.336 0 0 0-2.3 1.963 3.217 3.217 0 0 0 1.244 6.181c.135-.001.27-.01.404-.029h8.943c.047.004.094.006.141.007.045-.001.09-.004.135-.007h.214v-.016a2.99 2.99 0 0 0 1.887-.988c.487-.55.757-1.261.757-1.998v-.006a3.017 3.017 0 0 0-.69-1.915 2.992 2.992 
540 0 0-1.748-1.034 4.26 4.26 0 0 0-4.26-4.102Z"}),(0,h.jsx)("defs",{children:(0,h.jsxs)("linearGradient",{id:"icloud-gradient",x1:19.086,x2:3.333,y1:14.38,y2:14.163,gradientUnits:"userSpaceOnUse",children:[(0,h.jsx)("stop",{stopColor:"#3E82F4"}),(0,h.jsx)("stop",{offset:1,stopColor:"#93DCF7"})]})})]}),vP=({style:e,...t})=>(0,h.jsxs)("svg",{width:"16",height:"14",style:e,viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[(0,h.jsxs)("g",{clipPath:"url(#clip0_2115_829)",children:[(0,h.jsx)("path",{d:"M2.34709 12.9404L2.3471 12.9404L2.34565 12.938L1.64031 11.7448L1.64004 11.7444L0.651257 10.0677C0.640723 10.0496 0.630746 10.0314 0.621325 10.0129H4.16461L2.39424 13.0139C2.3775 12.9901 2.36178 12.9656 2.34709 12.9404Z",fill:"#0066DA",stroke:"#6366F1"}),(0,h.jsx)("path",{d:"M8 4.48713L5.47995 0.215332C5.23253 0.358922 5.02176 0.556358 4.87514 0.80764L0.219931 8.70508C0.076007 8.95094 0.000191627 9.22937 0 9.51277H5.04009L8 4.48713Z",fill:"#00AC47"}),(0,h.jsx)("path",{d:"M13.48 13.7847C13.7274 13.6411 13.9382 13.4437 14.0848 13.1924L14.3781 12.6988L15.7801 10.3206C15.9267 10.0693 16.0001 9.79114 16.0001 9.51294H10.9596L12.0321 11.577L13.48 13.7847Z",fill:"#EA4335"}),(0,h.jsx)("path",{d:"M8.00003 4.48718L10.5201 0.215385C10.2726 0.0717949 9.98857 0 9.69533 0H6.30472C6.01148 0 5.7274 0.0807692 5.47998 0.215385L8.00003 4.48718Z",fill:"#00832D"}),(0,h.jsx)("path",{d:"M10.9599 9.51294H5.04007L2.52002 13.7847C2.76744 13.9283 3.05152 14.0001 3.34476 14.0001H12.6552C12.9484 14.0001 13.2325 13.9194 13.4799 13.7847L10.9599 9.51294Z",fill:"#2684FC"}),(0,h.jsx)("path",{d:"M13.4525 4.75636L11.1249 0.80764C10.9782 0.556358 10.7675 0.358922 10.52 0.215332L8 4.48713L10.9599 9.51277H15.9908C15.9908 9.23456 15.9175 8.95636 15.7709 8.70508L13.4525 4.75636Z",fill:"#FFBA00"})]}),(0,h.jsx)("defs",{children:(0,h.jsx)("clipPath",{id:"clip0_2115_829",children:(0,h.jsx)("rect",{width:"16",height:"14",fill:"white"})})})]});async function vj({url:e,popup:t,provider:n}){return t.location=e,new Promise((e,n)=>{function i(){t?.close(),window.removeEventListener("message",r)}function r(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(e(t.data),i()),"https://cdn.apple-cloudkit.com"===t.origin&&t.data.ckSession&&(e({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:t.data.ckSession}),i()),"PRIVY_OAUTH_ERROR"===t.data.type&&(n(t.data.error),i()))}window.addEventListener("message",r)})}async function vO({api:e,provider:t,stateCode:n,codeVerifier:i,authorizationCode:r}){if(!r||!n)throw new n6.P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===r)throw new n6.P("User denied confirmation during OAuth flow");try{return(await e.post(n6.ac,{authorization_code:r,state_code:n,code_verifier:i,provider:t})).access_token}catch(t){let e=(0,n6.f)(t);if(e.privyErrorCode)throw new n6.P(e.message||"Invalid code during OAuth flow.",void 0,e.privyErrorCode);if("User denied confirmation during OAuth flow"===e.message)throw new n6.P("Invalid code during oauth flow.",void 0,n6.a.OAUTH_USER_DENIED);throw new n6.P("Invalid code during OAuth flow.",void 0,n6.a.UNKNOWN_AUTH_ERROR)}}async function vN({api:e,provider:t}){let n=my(),i=my(),r=await mf(n);try{return"icloud"===t?{url:(await e.post(n6.ad,{client_type:"web"})).url}:{url:(await e.post(n6.ae,{redirect_to:window.location.href,code_challenge:r,state_code:i})).url,codeVerifier:n,stateCode:i,provider:t}}catch(e){throw(0,n6.f)(e)}}let vR=(e,{chainType:t,walletIndex:n}={})=>e?.linkedAccounts.filter(e=>"wallet"===e.type&&"privy"===e.walletClientType&&(void 0===n||e.walletIndex===n)&&(void 0===t||e.chainType===t))??[],vM=async({user:e,accessToken:t,proxy:n,refreshSessionAndUser:i,privy:r,appConfig:a,recoverEmbeddedWallet:s,setUser:o,walletIndex:l,chainType:c,recoveryMethod:d,recoveryPassword:u,recoveryAccessToken:h})=>{if(0===l)if("user-controlled-server-wallets-only"===a.embeddedWallets.mode)await F(r,{request:{chain_type:c}});else if("ethereum"===c){let i=(0,ic.j)(e);i&&await s({address:i.address}),await n.create({accessToken:t,solanaAddress:i?.address,recoveryMethod:d,recoveryPassword:u,recoveryAccessToken:h})}else{if("solana"!==c)throw Error("Invalid input to create wallet");{let i=(0,ic.g)(e);i&&await s({address:i.address}),await n.createSolana({accessToken:t,ethereumAddress:i?.address,recoveryMethod:d,recoveryPassword:u,recoveryAccessToken:h})}}else if("user-controlled-server-wallets-only"===a.embeddedWallets.mode)await F(r,{request:{chain_type:c}});else{let{entropyId:i,entropyIdVerifier:r}=mY(e);await s(),await n.addWallet({accessToken:t,entropyId:i,entropyIdVerifier:r,chainType:c,hdWalletIndex:l})}let p=await i(),m=vR(p,{chainType:c,walletIndex:l})[0];return o(p),{user:p,account:m}},vD=()=>{let{getAccessToken:e}=(0,ic.u)(),{walletProxy:t,recoverEmbeddedWallet:n,setUser:i,refreshSessionAndUser:r,privy:a}=(0,n8.u)(),s=yK();return{create:async({walletIndex:o,chainType:l,latestUser:c,recoveryMethod:d,recoveryPassword:u,recoveryAccessToken:h})=>{let p=c;p||(p=await r());let m=await e();if(!p||!m||!t)throw Error("User must be authenticated before creating a Privy wallet");return await vM({appConfig:s,user:p,refreshSessionAndUser:r,privy:a,accessToken:m,proxy:t,recoverEmbeddedWallet:n,setUser:i,walletIndex:o,chainType:l,recoveryMethod:d,recoveryPassword:u,recoveryAccessToken:h})}}},vU={component:()=>{let{user:e}=(0,ic.u)(),{closePrivyModal:t,isNewUserThisSession:n,updateWallets:i}=(0,n8.u)(),{app:r,data:a,onUserCloseViaDialogOrKeybindRef:s}=yQ(),{onSuccess:o,onFailure:l,callAuthOnSuccessOnClose:c}=a.createWallet,d=()=>{let n=(0,ic.g)(e)??(0,ic.j)(e);e&&n?(i(),o({user:e,account:n})):l(Error("Failed to create wallet")),t({shouldCallAuthOnSuccess:c})};return(0,m.useEffect)(()=>{let e=setTimeout(d,2500);return()=>clearTimeout(e)},[]),s.current=d,(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:d}),(0,h.jsx)(g3,{}),(0,h.jsxs)(gX,{children:[(0,h.jsx)(h5.A,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),(0,h.jsx)(vT,{title:n?"Welcome"+(r?.name?` to ${r?.name}`:""):"All set!",description:n?"You’ve successfully created an account.":"Your account is secured."})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}},vL=ig.I4.div.withConfig({displayName:"RecoveryContainer",componentId:"sc-12b46968-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),vF=ig.I4.div.withConfig({displayName:"RecoveryExplainerContainer",componentId:"sc-12b46968-1"})(["padding-bottom:24px;"]),vW={"google-drive":{name:"Google Drive",component:vP},icloud:{name:"iCloud",component:vk}},v$={component:()=>{let{logout:e}=(0,ic.u)(),{navigate:t,setModalData:n,data:i}=yQ(),{closePrivyModal:r,createAnalyticsEvent:a}=(0,n8.u)(),{execute:s}=(()=>{let{client:e,walletProxy:t,refreshSessionAndUser:n}=(0,n8.u)(),{data:i}=yQ(),{getAccessToken:r,user:a}=(0,ic.u)(),s=fp(),{create:o}=vD();return{execute:async({provider:l,action:c,popup:d,shouldCreateEth:u,shouldCreateSol:h})=>{let p,m;if(!e)throw new n6.P("Missing client");function y(t){if(!t&&e)throw e.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:l}}),new n6.P("Recovery OAuth failed")}
54switch(l){case"google-drive":{let t,n,{url:i,codeVerifier:a,stateCode:s}=await vN({api:e.api,provider:l});y(i);try{let r=await vj({url:i,popup:d,provider:l});if(t=r.stateCode,n=r.authorizationCode,t!==s)throw e.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:l,storedStateCode:s??"",returnedStateCode:t??""}}),new n6.P("Unexpected auth flow. This may be a phishing attempt.",void 0,n6.a.OAUTH_UNEXPECTED)}catch(t){throw e.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:l}}),new n6.P("Recovery OAuth failed")}[p,m]=await Promise.all([r(),vO({api:e.api,provider:l,codeVerifier:a,stateCode:t,authorizationCode:n})]);break}case"icloud":{let{url:t}=await vN({api:e.api,provider:l});y(t);let{ckWebAuthToken:n}=await vj({url:t,popup:d,provider:l});m=n,p=await r()}}if(!t)throw new n6.P("Cannot connect to wallet proxy");if(!p)throw new n6.P("Unable to authorize user");switch(c){case"recover":{let n=i?.recoverWallet?.entropyId,r=i?.recoverWallet?.entropyIdVerifier;if(!n||!r)throw new n6.P("Recovery OAuth failed");e.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:n,recoveryMethod:l}}),await t.recover({accessToken:p,entropyId:n,entropyIdVerifier:r,recoveryAccessToken:m}),e.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:n,recoveryMethod:l}});break}case"create-wallet":{let t;if(e.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),u&&h)t=await o({recoveryMethod:l,recoveryAccessToken:m,chainType:"ethereum",walletIndex:0,latestUser:a}),t=await o({chainType:"solana",walletIndex:0,latestUser:t.user});else if(h)t=await o({recoveryMethod:l,recoveryAccessToken:m,chainType:"solana",walletIndex:0,latestUser:a});else{if(!u)throw Error("Invalid args to create wallet");t=await o({recoveryMethod:l,recoveryAccessToken:m,chainType:"ethereum",walletIndex:0,latestUser:a})}if(!t)throw s("createWallet","onError",n6.a.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");e.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.account.address}}),s("createWallet","onSuccess",{wallet:t.account});break}case"set-recovery":{let i=(0,ic.h)(a);if(!i)throw s("setWalletRecovery","onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");e.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:i.address,existingRecoveryMethod:i.recoveryMethod,targetRecoveryMethod:l}});let{entropyId:r,entropyIdVerifier:o}=mY(a);await t.setRecovery({accessToken:p,entropyId:r,entropyIdVerifier:o,recoveryMethod:l,recoveryAccessToken:m});let c=(0,ic.h)(await n());if(!c)throw s("createWallet","onError",n6.a.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");e.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:i.address,existingRecoveryMethod:i.recoveryMethod,targetRecoveryMethod:l}}),s("setWalletRecovery","onSuccess",{method:l,wallet:c});break}default:throw new n6.P("Unsupported recovery action")}}}})(),[o,l]=(0,m.useState)(!1),{provider:c,action:d,isInAccountCreateFlow:u,shouldCreateEth:p,shouldCreateSol:y}=i?.recoveryOAuthStatus,[f,g]=(0,m.useState)(void 0),[w,v]=(0,m.useState)("create-wallet"===d);if("user-passcode"===c)throw Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let b=vW[c].name,x=vW[c].component,_=i?.recoverWallet?.onCompleteNavigateTo,C=new p4(async(e="create-wallet")=>(v(!0),new Promise((t,n)=>{setTimeout(async()=>{try{let n=window.open();await s({provider:c,action:e,popup:n,shouldCreateEth:p,shouldCreateSol:y}),l(!0),t()}catch(t){g({message:`${"recover"===e?"Recovery":"Back up"} with ${b} unsuccessful`,detail:"recover"===d?`Please verify that you are selecting the ${b} account associated with your backup.`:"",retryable:!0}),n()}},0)})));(0,m.useEffect)(()=>{"recover"!==d&&C.execute(u?"create-wallet":"set-recovery")},[]),(0,m.useEffect)(()=>{if(!o)return;let i=setTimeout(()=>{u?(n({createWallet:{onSuccess:()=>{},onFailure:t=>{a({eventName:"embedded_wallet_creation_failure_logout",payload:{error:t,screen:"RecoveryOAuthScreen"}}),e()},callAuthOnSuccessOnClose:!0,shouldCreateEth:!1,shouldCreateSol:!1}}),t(vU)):r({shouldCallAuthOnSuccess:!1})},1400);return()=>clearTimeout(i)},[o]);let I=(0,m.useCallback)(async()=>{await C.execute("recover"),_?t(_):l(!0)},[]),E="google-drive"===c?"Google Drive":"Apple iCloud",T=o&&`Successfully ${"recover"===d?"recovered":"backed up"} with ${E}.`||f&&f.message||`${"recover"===d?"Recovering":"Backing up"} with ${E}...`,A=f?f.detail:"";return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{}),w?(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(vL,{children:[(0,h.jsx)(vT,{title:T,icon:(0,h.jsx)(x,{style:{width:"38px",height:"38px"}}),description:A}),f&&f?.retryable?(0,h.jsx)(gn,{onClick:()=>{mO(),g(void 0),"create-wallet"===d?C.execute("create-wallet"):I()},disabled:!o&&!f?.retryable,children:"Try again"}):null]})}):(0,h.jsxs)(vL,{children:[(0,h.jsx)(vT,{title:"Confirm it's really you",icon:(0,h.jsx)(x,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${E} where your account is backed up.`}),(0,h.jsxs)(gn,{onClick:I,children:["Confirm with ",E]})]}),(0,h.jsx)(fk,{})]})}},vB=ig.I4.div.withConfig({displayName:"IconContainer",componentId:"sc-ccfae04f-0"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;"]),vz={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy","privy-v2":"Privy"},vq=({onClose:e})=>(0,h.jsxs)(vF,{children:[(0,h.jsx)(vT,{title:"Why do I need to secure my account?",icon:(0,h.jsx)(iI.A,{width:48}),description:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),(0,h.jsx)("p",{children:"To use this app on new devices, secure account secrets using a password, your Google or your Apple account. It’s important you don’t lose access to the method you choose."})]})}),(0,h.jsx)(gn,{onClick:e,children:"Select backup method"})]}),vV={component:()=>{let[e,t]=(0,m.useState)(!1),{navigate:n,lastScreen:i,navigateBack:r,setModalData:a,data:s,onUserCloseViaDialogOrKeybindRef:o}=yQ(),{user:l}=(0,ic.u)(),{embeddedWallets:c}=yK(),{closePrivyModal:d}=(0,n8.u)(),u=(0,ic.h)(l),p=null===u,{isInAccountCreateFlow:y,isResettingPassword:f,shouldCreateEth:g,shouldCreateSol:w}=s.recoverySelection,v=u&&"privy"!==u.recoveryMethod,b=v?(0,h.jsxs)("span",{children:["Your account is currently secured using"," ",(0,h.jsx)("strong",{children:vz[u?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function x(e){a({recoveryOAuthStatus:{provider:e,action:p?"create-wallet":"set-recovery",isInAccountCreateFlow:y,shouldCreateEth:g,shouldCreateSol:w}}),n(v$)}function _(){s?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),d({shouldCallAuthOnSuccess:s?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return o.current=_,(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:_,backFn:e?()=>t(!1):i?r:void 0,infoFn:i||e?void 0:()=>t(!0)},"header"),e?(0,h.jsx)(vq,{onClose:()=>t(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(vT,{title:v?"Update backup method":"Secure your account",icon:(0,h.jsx)(h9.A,{width:48}),description:b}),(0,h.jsx)(vL,{children:c.userOwnedRecoveryOptions.filter(e=>!["icloud","google-drive"].includes(u?.recoveryMethod||"")||e!==u?.recoveryMethod).sort().map(e=>{switch(e){case"google-drive":return(0,h.jsxs)(fb,{onClick:()=>x("google-drive"),children:[(0,h.jsx)(vB,{children:(0,h.jsx)(vP,{style:{width:18}})}),"Back up to Google Drive"]},e);case"icloud":return(0,h.jsxs)(fb,{onClick:()=>x("icloud"),children:[(0,h.jsx)(vB,{children:(0,h.jsx)(vk,{style:{width:24}})}),"Back up to Apple iCloud"]},e);case"user-passcode":return(0,h.jsxs)(fb,{onClick:()=>{n(function({isCreatingWallet:e,skipSplashScreen:t}){return e?C$:t?CR:CM}({isCreatingWallet:p,skipSplashScreen:!0}))},children:[(0,h.jsx)(vB,{children:(0,h.jsx)(pe.A,{style:{width:18}})}),f?"Reset your":"Set a"," password"]},e);default:return null}})})]}),(0,h.jsx)(fk,{})]})}},vH=(0,ig.AH)(["font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;text-align:left;transition:color 0.1s ease-in;"]),vG=ig.I4.span.withConfig({displayName:"StatusText",componentId:"sc-acac4b9-0"})([""," transition:color 0.1s ease-in;color:",";text-transform:",";&[aria-hidden='true']{visibility:hidden;}"],vH,({error:e})=>e?"var(--privy-color-error)":"var(--privy-color-foreground-3)",({error:e})=>e?"":"capitalize"),vK=ig.I4.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-acac4b9-1"})(["display:flex;flex-direction:column;justify-content:center;flex-grow:1;"]),vJ=(0,ig.I4)(gn).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-acac4b9-2"})(["",""],({$hideAnimations:e})=>e&&(0,ig.AH)(["&&{transition:none;}"])),vZ=(0,ig.AH)(["&&{width:100%;border-width:1px;border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);background:var(--privy-color-background);color:var(--privy-color-foreground);padding:12px;font-size:16px;font-style:normal;font-weight:300;line-height:22px;}"]),vY=ig.I4.input.withConfig({displayName:"PasswordInput",componentId:"sc-acac4b9-3"})([""," &::placeholder{color:var(--privy-color-foreground-3);font-style:italic;font-size:14px;}overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"],vZ),vQ=ig.I4.div.withConfig({displayName:"PasswordDisplay",componentId:"sc-acac4b9-4"})(["",""],vZ),vX=ig.I4.div.withConfig({displayName:"PasswordContainer",componentId:"sc-acac4b9-5"})(["position:relative;width:100%;display:flex;align-items:center;justify-content:",";"],({centered:e})=>e?"center":"space-between"),v0=ig.I4.div.withConfig({displayName:"Header",componentId:"sc-acac4b9-6"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:32px 0;gap:4px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]),v1=ig.I4.div.withConfig({displayName:"Details",componentId:"sc-acac4b9-7"})(["display:flex;flex-direction:column;gap:10px;padding-bottom:1rem;"]),v2=ig.I4.div.withConfig({displayName:"DetailItem",componentId:"sc-acac4b9-8"})(["display:flex;text-align:left;align-items:center;gap:8px;max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;margin:0 8px;color:var(--privy-color-foreground-2);> :first-child{min-width:24px;}"]),v3=(0,ig.I4)(gt).withConfig({displayName:"ExportButton",componentId:"sc-acac4b9-10"})(["display:flex;flex:1;gap:4px;justify-content:center;&&{background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);border-width:1px;}"]),v4=ig.I4.div.withConfig({displayName:"InputRightIcons",componentId:"sc-acac4b9-11"})(["position:absolute;right:0.5rem;display:flex;flex-direction:row;justify-content:space-around;align-items:center;"]),v5=(0,ig.I4)(pt.A).withConfig({displayName:"RegenerateIcon",componentId:"sc-acac4b9-12"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),v6=(0,ig.I4)(pi.A).withConfig({displayName:"HiddenIcon",componentId:"sc-acac4b9-13"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),v8=(0,ig.I4)(pn.A).withConfig({displayName:"ShownIcon",componentId:"sc-acac4b9-14"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),v7=ig.I4.progress.withConfig({displayName:"StrengthMeter",componentId:"sc-acac4b9-15"}
54)(["height:4px;width:100%;margin:8px 0;::-webkit-progress-bar{border-radius:8px;background:var(--privy-color-foreground-4);}::-webkit-progress-value{border-radius:8px;transition:all 0.1s ease-out;background:",";}"],({label:e})=>("Strong"===e?"#78dca6":"Medium"===e&&"var(--privy-color-warn)")||"var(--privy-color-error)"),v9=({buttonHideAnimations:e,buttonLoading:t,password:n,onSubmit:i,onBack:r})=>{let[a,s]=(0,m.useState)(!0),[o,l]=(0,m.useState)(!1),[c,d]=(0,m.useState)(""),u=n===c;return(0,m.useEffect)(()=>{c&&!o&&l(!0)},[c]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{closeable:!1,backFn:r}),(0,h.jsx)(g3,{}),(0,h.jsxs)(vK,{children:[(0,h.jsxs)(v0,{children:[(0,h.jsx)(iA.A,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),(0,h.jsx)("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm your password"}),(0,h.jsx)("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please re-enter your password below to continue."})]}),(0,h.jsxs)(vX,{children:[(0,h.jsx)(vY,{value:c,onChange:e=>d(e.target.value),onKeyUp:e=>{"Enter"===e.key&&i()},onBlur:()=>l(!0),placeholder:"confirm your password",type:a?"password":"text",style:{paddingRight:"2.3rem"}}),(0,h.jsx)(v4,{style:{right:"0.75rem"},children:a?(0,h.jsx)(v6,{onClick:()=>s(!1)}):(0,h.jsx)(v8,{onClick:()=>s(!0)})})]}),(0,h.jsx)(vG,{"aria-hidden":!o||u,error:!0,children:"Passwords do not match"})]}),(0,h.jsx)(vJ,{onClick:i,loading:t,disabled:!u,$hideAnimations:e,children:"Continue"}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})},be=({className:e,checked:t,color:n="var(--privy-color-accent)",...i})=>(0,h.jsx)("label",{children:(0,h.jsxs)(bt,{className:e,children:[(0,h.jsx)(bi,{checked:t,...i}),(0,h.jsx)(br,{color:n,checked:t,children:(0,h.jsx)(bn,{viewBox:"0 0 24 24",children:(0,h.jsx)("polyline",{points:"20 6 9 17 4 12"})})})]})}),bt=ig.I4.div.withConfig({displayName:"CheckboxContainer",componentId:"sc-db51b935-1"})(["display:inline-block;vertical-align:middle;"]),bn=ig.I4.svg.withConfig({displayName:"Icon",componentId:"sc-db51b935-2"})(["fill:none;stroke:white;stroke-width:3px;"]),bi=ig.I4.input.attrs({type:"checkbox"}).withConfig({displayName:"HiddenCheckbox",componentId:"sc-db51b935-3"})(["border:0;clip:rect(0 0 0 0);clippath:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px;"]),br=ig.I4.div.withConfig({displayName:"StyledCheckbox",componentId:"sc-db51b935-4"})(["display:inline-block;width:18px;height:18px;transition:all 150ms;cursor:pointer;border-color:",";border-radius:3px;background:",";&&{border-width:1px;}",":focus + &{box-shadow:0 0 0 1px ",";}","{visibility:",";}"],e=>e.color,e=>e.checked?e.color:"var(--privy-color-background)",bi,e=>e.color,bn,e=>e.checked?"visible":"hidden"),ba=({buttonHideAnimations:e,buttonLoading:t,onSubmit:n,onBack:i,config:r})=>{let[a,s]=(0,m.useState)(!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{closeable:!1,backFn:i}),(0,h.jsx)(g3,{}),(0,h.jsxs)(vK,{children:[(0,h.jsxs)(v0,{children:[(0,h.jsx)(iA.A,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-error)"}),(0,h.jsx)("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm you have saved"}),(0,h.jsx)("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Losing access to your password means you will lose access to your account."})]}),(0,h.jsx)(v1,{children:(0,h.jsxs)(v2,{style:{color:"var(--privy-color-error)",cursor:"pointer"},onClick:e=>{e.preventDefault(),s(e=>!e)},children:[(0,h.jsx)(be,{color:"var(--privy-color-error)",readOnly:!0,checked:a}),(0,h.jsx)(h.Fragment,{children:"I understand that if I lose my password and device, I will lose access to my account and my assets."})]})})]}),(0,h.jsxs)(bs,{children:["user"===r.initiatedBy&&(0,h.jsx)(go,{onClick:r.onCancel,disabled:t,children:"Cancel"}),(0,h.jsx)(vJ,{onClick:n,loading:t,$hideAnimations:e,disabled:!a,children:"Set Password"})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})},bs=ig.I4.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-d1659c5f-0"})(["display:flex;gap:10px;"]),bo=/[a-z]/,bl=/[A-Z]/,bc=/[0-9]/,bd="!@#$%^&*()\\-_+.",bu=`a-zA-Z0-9${bd}`,bh=RegExp(`[${bd}]`),bp=RegExp(`[${bu}]`),bm=RegExp(`^[${bu}]{6,}$`),by=()=>hG.ki(4,hK.P),bf=({buttonHideAnimations:e,buttonLoading:t,password:n="",config:i,isResettingPassword:r,onSubmit:a,onClose:s,onBack:o,onPasswordChange:l,onPasswordGenerate:c})=>{let[d,u]=(0,m.useState)(!1),[p,y]=(0,m.useState)(!1);(0,m.useEffect)(()=>{n&&!p&&y(!0)},[n]);let f=(0,m.useMemo)(()=>p?6>(n?.length||0)?"Password must be at least 6 characters":bm.test(n||"")?null:`Invalid characters used ( ${((e="")=>[...new Set(e.split("").filter(e=>!bp.test(e)).map(e=>e.replace(" ","SPACE")))])(n).join(" ")} )`:null,[n,p]),g=(0,m.useMemo)(()=>f?{value:0,label:"Weak"}:function(e=""){let t=function(e=""){return(.3*function(e){if(e.length<8)return 0;let t=0;return bo.test(e)&&(t+=1),bl.test(e)&&(t+=1),bc.test(e)&&(t+=1),bh.test(e)&&(t+=1),Math.max(0,Math.min(1,t/3))}(e)+hH(e)/95)/2}(e);return{value:t,label:t>.9?"Strong":t>.5?"Medium":"Weak"}}(n),[n,f]),w=(0,m.useMemo)(()=>!n?.length||!!f,[f,n]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:s,closeable:"user"===i.initiatedBy,backFn:o}),(0,h.jsx)(g3,{}),(0,h.jsxs)(vK,{children:[(0,h.jsxs)(v0,{children:[(0,h.jsx)(pr.A,{height:48,width:48,stroke:"var(--privy-color-accent)"}),(0,h.jsxs)("h3",{style:{color:"var(--privy-color-foreground)"},children:[r?"Reset":"Set"," your password"]}),(0,h.jsx)("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Select a strong, memorable password to secure your account."})]}),(0,h.jsxs)(vX,{children:[(0,h.jsx)(vY,{value:n,onChange:e=>l(e.target.value),onKeyUp:e=>{"Enter"===e.key&&a()},placeholder:"enter or generate a strong password",type:d?"password":"text",style:{paddingRight:"3.8rem"}}),(0,h.jsxs)(v4,{style:{width:"3.5rem"},children:[d?(0,h.jsx)(v6,{onClick:()=>u(!1)}):(0,h.jsx)(v8,{onClick:()=>u(!0)}),(0,h.jsx)(v5,{onClick:c})]})]}),(0,h.jsx)(v7,{value:0===g.value?.01:g.value,label:g.label}),(0,h.jsx)(vG,{error:!!f,children:f||`Password Strength: ${p?g.label:"--"}`}),(0,h.jsxs)(bw,{children:[(0,h.jsx)(bg,{children:(0,h.jsxs)(v1,{children:[(0,h.jsxs)(v2,{children:[(0,h.jsx)(h5.A,{width:24,height:24,fill:"var(--privy-color-accent)"}),"This password is used to secure your account."]}),(0,h.jsxs)(v2,{children:[(0,h.jsx)(h5.A,{width:24,height:24,fill:"var(--privy-color-accent)"}),"Use it to log in on a new environment, like another browser or device."]})]})}),(0,h.jsx)(vJ,{onClick:a,loading:t,disabled:w,$hideAnimations:e,children:"Continue"})]})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})},bg=(0,ig.I4)(v1).withConfig({displayName:"DetailsContainer",componentId:"sc-2da5fe90-0"})(["flex:1;padding-top:1rem;"]),bw=ig.I4.div.withConfig({displayName:"LowerContainer",componentId:"sc-2da5fe90-1"})(["display:flex;flex-direction:column;height:100%;"]),bv=({buttonHideAnimations:e,buttonLoading:t,appName:n,password:i,onSubmit:r,onBack:a})=>{let[s,o]=(0,m.useState)(!1),[l,c]=(0,m.useState)(!0),d=(0,m.useCallback)(()=>{o(!0),i&&navigator.clipboard.writeText(i)},[i]),u=(0,m.useCallback)(()=>{let e=document.createElement("a"),t=n.toLowerCase().replace(/[^a-z\s]/g,"").replace(/\s/g,"-"),r=new Blob([bb(n,i)],{type:"text/plain"}),a=URL.createObjectURL(r);e.href=a,e.target="_blank",e.download=`${t}-privy-wallet-recovery.txt`,document.body.appendChild(e),e.click(),setTimeout(()=>{e.remove(),URL.revokeObjectURL(a)},5e3)},[i]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:a,closeable:!1}),(0,h.jsx)(g3,{}),(0,h.jsxs)(vK,{children:[(0,h.jsxs)(v0,{children:[(0,h.jsx)(iA.A,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),(0,h.jsx)("h3",{style:{color:"var(--privy-color-foreground)"},children:"Save your password"}),(0,h.jsx)("p",{style:{color:"var(--privy-color-foreground-2)"},children:"For your security, this password cannot be reset, so keep it somewhere safe."})]}),(0,h.jsxs)(vX,{centered:!0,children:[(0,h.jsx)(vQ,{children:l?"•".repeat(i.length):i}),(0,h.jsx)(v4,{style:{right:"0.75rem"},children:l?(0,h.jsx)(v6,{onClick:()=>c(!1)}):(0,h.jsx)(v8,{onClick:()=>c(!0)})})]}),(0,h.jsxs)("div",{style:{display:"flex",margin:"12px 0",gap:"12px"},children:[(0,h.jsx)(v3,{onClick:d,children:(0,h.jsxs)(h.Fragment,s?{children:[(0,h.jsx)(ps.A,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copied"]}:{children:[(0,h.jsx)(po.A,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copy"]})}),(0,h.jsxs)(v3,{onClick:u,children:[(0,h.jsx)(pa.A,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Download"]})]})]}),(0,h.jsx)(vJ,{onClick:r,loading:t,$hideAnimations:e,children:"Continue"}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})},bb=(e,t)=>`Your wallet recovery password for ${e} is
55
56${t}
57
58You will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`,bx=({error:e,onClose:t})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{closeable:!1}),(0,h.jsx)(g3,{}),(0,h.jsxs)(gX,e?{children:[(0,h.jsx)(h4.A,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),(0,h.jsx)(vT,{title:"Something went wrong",description:e})]}:{children:[(0,h.jsx)(h5.A,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}),(0,h.jsx)(vT,{title:"Success"})]}),(0,h.jsx)(gn,{onClick:t,children:"Close"}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]}),b_=(e,t)=>
58{switch(e){case"creating":return"back"===t?e:"saving";case"saving":return"back"===t?"creating":"confirming";case"confirming":return"back"===t?"saving":"finalizing";case"finalizing":return"back"===t?"confirming":"done";default:return e}},bC=({onSubmit:e,...t})=>{let{lastScreen:n,navigate:i}=yQ(),{send:r,state:a}=(()=>{let[e,t]=(0,m.useReducer)(b_,"creating");return{send:t,state:e}})(),s=(0,m.useCallback)(async()=>{"finalizing"===a&&await e(),r("next")},[a,r,e]);(0,m.useEffect)(()=>{let e;return"done"===a&&"automatic"===t.config.initiatedBy&&(e=setTimeout(()=>t.onClose?.(),1400)),()=>{e&&clearTimeout(e)}},[a,t.config.initiatedBy,t.onClose]);let o=(0,m.useCallback)(()=>{r("back")},[r]),l=(0,m.useCallback)(()=>{i(vV)},[n,i]);return"creating"===a?(0,h.jsx)(bf,{...t,onSubmit:s,onBack:n===vV?l:void 0}):"saving"===a?(0,h.jsx)(bv,{...t,onSubmit:s,onBack:o}):"confirming"===a?(0,h.jsx)(v9,{...t,onSubmit:s,onBack:o}):"finalizing"===a?(0,h.jsx)(ba,{...t,onSubmit:s,onBack:o}):"done"===a?(0,h.jsx)(bx,{...t,onSubmit:s}):null},bI={apple_oauth:"apple",custom_auth:"custom",discord_oauth:"discord",email:"email",farcaster:"farcaster",github_oauth:"github",google_oauth:"google",instagram_oauth:"instagram",linkedin_oauth:"linkedin",passkey:"passkey",phone:"sms",spotify_oauth:"spotify",telegram:"telegram",tiktok_oauth:"tiktok",line_oauth:"line",twitter_oauth:"twitter",wallet:"siwe",smart_wallet:"siwe",cross_app:"privy:"},bE=e=>{let t=bI[e];return"wallet"===e||"phone"===e?{displayName:e,loginMethod:t}:{displayName:t,loginMethod:t}},bT=(0,m.createContext)({}),bA=({children:e})=>{let t=yK(),[n,i]=(0,m.useState)({});return fu("login",{onComplete:({loginAccount:e})=>{e&&"passkey"!==e.type&&"cross_app"!==e.type&&("wallet"!==e.type||"privy"!==e.walletClientType)&&(pR.put(bS(t.id),e.type),"wallet"===e.type?(pR.put(bk(t.id),e.walletClientType),pR.put(bP(t.id),e.chainType),i({accountType:e.type,walletClientType:e.walletClientType,chainType:e.chainType})):(pR.del(bk(t.id)),pR.del(bP(t.id)),i({accountType:e.type})))}}),(0,m.useEffect)(()=>{if(!t.id)return;let e=pR.get(bS(t.id)),n=pR.get(bk(t.id)),r=pR.get(bP(t.id));e&&i("wallet"===e?{accountType:e,walletClientType:n,chainType:r}:{accountType:e})},[t.id]),(0,h.jsx)(bT.Provider,{value:n,children:e})},bS=e=>`privy:${e}:recent-login-method`,bk=e=>`privy:${e}:recent-login-wallet-client`,bP=e=>`privy:${e}:recent-login-chain-type`,bj=()=>(0,m.useContext)(bT),bO=()=>{let{app:e}=yQ(),t=e?.appearance?.logo,n=`${e?.name} logo`,i={maxHeight:"90px",maxWidth:"180px"};return t?"string"==typeof t?(0,h.jsx)("img",{src:t,alt:n,style:i}):"svg"===t.type||"img"===t.type?m.cloneElement(t,{alt:n,style:i}):(console.warn("`config.appearance.logo` must be a string, or an SVG / IMG element. Nothing will be rendered."),null):null},bN=e=>{let{app:t}=yQ();return t?.appearance.logo?(0,h.jsx)(bR,{...e,children:(0,h.jsx)(bO,{})}):null},bR=ig.I4.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a206bd44-0"})(["display:flex;flex-direction:column;align-items:center;padding:24px 0;flex-grow:1;justify-content:center;"]),bM=({name:e,logoUrl:t,size:n="38px"})=>"string"==typeof t?(0,h.jsx)("img",{src:t,alt:`${e??"Provider app"} logo`,style:{width:n,height:n,maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):(0,h.jsx)("span",{}),bD=({appId:e})=>{let[t,n]=(0,m.useState)(void 0),{startCrossAppAuthFlow:i,authenticated:r}=(0,ic.u)(),{client:a}=(0,n8.u)();return(0,m.useEffect)(()=>{(async()=>{a&&n(await a.getCrossAppProviderDetails(e))})()},[a]),(0,h.jsx)(fb,{onClick:()=>i({appId:e,action:r?"link":"login"}),disabled:!t,children:t?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(bM,{name:t.name,logoUrl:t.icon_url||void 0,size:"24px"})," ",t.name]}):(0,h.jsx)(f9,{})})},bU=(e,t)=>!(0,ic.g)(e)&&("all-users"===t||"users-without-wallets"===t&&!bL(e).length),bL=e=>e.linkedAccounts.filter(e=>"wallet"===e.type&&"ethereum"===e.chainType),bF=(e,t)=>!(0,ic.j)(e)&&("all-users"===t||"users-without-wallets"===t&&!bW(e).length),bW=e=>e.linkedAccounts.filter(e=>"wallet"===e.type&&"solana"===e.chainType),b$=(e,t)=>bU(e,t.ethereum.createOnLogin)||bF(e,t.solana.createOnLogin),bB=ig.I4.span.withConfig({displayName:"CircleBackgroun
58d",componentId:"sc-c9f33cd-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";background-color:",";border-radius:50%;display:inline-block;box-sizing:border-box;}"],e=>e.color??"var(--privy-color-accent)",e=>e.color??"var(--privy-color-accent)"),bz={component:()=>{let{navigate:e,app:t,setModalData:n,data:i}=yQ(),{getAuthMeta:r,client:a}=(0,n8.u)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{}),(0,h.jsxs)(bq,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(bB,{color:"var(--privy-color-warn-light)"}),(0,h.jsx)(iI.A,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-warn)"})]})}),(0,h.jsxs)(bV,{children:[(0,h.jsx)("h3",{children:"Account not found"}),(0,h.jsxs)("p",{children:["Please try logging in again or go to ",t.name," to create an account."]})]}),(0,h.jsx)(fm,{}),(0,h.jsx)(gn,{onClick:()=>{let t=r();n({...i,login:{...i?.login,...t?.disableSignup?{disableSignup:!0}:{}}}),a?.authFlow&&(a.authFlow=void 0),e(CN)},children:"Try logging in again"})]})]})}},bq=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-feca2100-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;margin-top:24px;"]),bV=ig.I4.div.withConfig({displayName:"GappedContainer",componentId:"sc-feca2100-1"})(["display:flex;flex-direction:column;gap:8px;"]),bH=ig.I4.span.withConfig({displayName:"CircleBorder",componentId:"sc-9056b8b8-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";border-bottom-color:transparent;border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1.2s linear infinite;transition:border-color 800ms;border-bottom-color:",";}"],e=>e.color??"var(--privy-color-accent)",e=>e.color??"var(--privy-color-accent)"),bG=({address:e,showCopyIcon:t,url:n,className:i})=>{let[r,a]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(r){let e=setTimeout(()=>a(!1),2e3);return()=>clearTimeout(e)}},[r]),n?(0,h.jsx)("a",{title:e,className:i,href:`${n}/address/${e}`,target:"_blank",children:p$(e)}):(0,h.jsxs)("button",{title:e,className:i,onClick:t=>(t.stopPropagation(),navigator.clipboard.writeText(e).then(()=>a(!0)).catch(console.error)),children:[p$(e),(0,h.jsx)(t&&r?bJ:bK,{})]})},bK=(0,ig.I4)(h0.A).withConfig({displayName:"StyledSquare2StackIcon",componentId:"sc-980a92a-0"})(["&&{display:inline;}stroke-width:2;height:0.875rem;width:0.875rem;margin-left:0.125rem;color:var(--privy-color-foreground-3);"]),bJ=(0,ig.I4)(hX.A).withConfig({displayName:"StyledCheckIcon",componentId:"sc-980a92a-1"})(["&&{display:inline;}stroke-width:2;height:0.875rem;width:0.875rem;margin-left:0.125rem;color:var(--privy-color-success);"]);function bZ(e){return(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e,children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,h.jsx)("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),(0,h.jsx)("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})}let bY="0x0000000000000000000000000000000000000000",bQ=({originCurrency:e,destinationCurrency:t,...n})=>({tradeType:"EXPECTED_OUTPUT",originCurrency:e??bY,destinationCurrency:t??bY,...n}),bX="https://api.relay.link",b0="https://api.testnets.relay.link",b1=async({input:e,isTestnet:t})=>{let n=await fetch((t?b0:bX)+"/quote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),i=await n.json();if(!(n.ok||"string"==typeof i.message&&i.message.startsWith("Invalid address")))throw console.error("Relay error:",i),Error(i.message??"Error fetching quote from relay");return i},b2=e=>{let t=e.steps[0]?.items?.[0];if(t)return{from:t.data.from,to:t.data.to,value:Number(t.data.value),chainId:Number(t.data.chainId),data:t.data.data}};function b3({transactionHash:e,wallet:t,isTestnet:n,bridgingStatus:i,setBridgingStatus:r,onSuccess:a,onFailure:s}){(0,m.useEffect)(()=>{if(e&&t&&i){if(["delayed","waiting","pending"].includes(i)){let t=setInterval(async()=>{try{let t=await async function({transactionHash:e,isTestnet:t}){let n=await fetch((t?b0:bX)+"/requests/v2?hash="+e),i=await n.json();if(!n.ok){if("message"in i&&"string"==typeof i.message)throw Error(i.message);throw Error("Error fetching request from relay")}return i.requests.at(0)?.status??"pending"}({transactionHash:e,isTestnet:n});r(t)}catch(e){console.error(e)}},1e3);return()=>clearInterval(t)}"success"===i?a({transactionHash:e,wallet:t}):["refund","failure"].includes(i)&&s({error:new b4(e,n)})}},[i,e,n,t])}class b4 extends n6.P{constructor(e,t){super("We were unable to complete the bridging transaction. Funds will be refunded on your wallet.",void 0,n6.a.TRANSACTION_FAILURE),this.relayLink=t?`https://testnets.relay.link/transaction/${e}`:`https://relay.link/transaction/${e}`}}let b5=({style:e,...t})=>(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...t,children:(0,h.jsx)("path",{fillRule:"evenodd",d:"M12 1.5a5.25 5.25 0 00-5.25 5.25v3a3 3 0 00-3 3v6.75a3 3 0 003 3h10.5a3 3 0 003-3v-6.75a3 3 0 00-3-3v-3c0-2.9-2.35-5.25-5.25-5.25zm3.75 8.25v-3a3.75 3.75 0 10-7.5 0v3h7.5z",clipRule:"evenodd"})}),b6={component:()=>{let{navigate:e,navigateBack:t,data:n,lastScreen:i,currentScreen:r}
58=yQ(),a=n?.errorModalData?.previousScreen||(i===r?void 0:i);return(0,h.jsx)(b8,{error:n?.errorModalData?.error||Error(),backFn:()=>a?e(a,!1):t(),onClick:()=>e(a||CN,!1)})}},b8=({error:e,backFn:t,onClick:n})=>{let{reset:i}=mz(),{app:r}=yQ(),a=((e,t)=>{let n=(0,h.jsx)(iA.A,{height:38,width:38,stroke:"var(--privy-color-error)"});if(e instanceof b4)return{title:"Transaction failed",detail:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("p",{children:e.message}),(0,h.jsxs)("p",{children:["Check the"," ",(0,h.jsx)(xe,{href:e.relayLink,target:"_blank",children:"refund status"}),"."]})]}),ctaText:"Try again",icon:n};if(e instanceof n6.P)switch(e.privyErrorCode){case n6.a.CLIENT_REQUEST_TIMEOUT:return{title:"Timed out",detail:e.message,ctaText:"Try again",icon:n};case n6.a.INSUFFICIENT_BALANCE:return{title:"Insufficient balance",detail:e.message,ctaText:"Try again",icon:n};case n6.a.TRANSACTION_FAILURE:return{title:"Transaction failure",detail:e.message,ctaText:"Try again",icon:n};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:n}}if(e instanceof wz&&"twilio_verification_failed"===e.type)return{title:"Something went wrong",detail:e.message,ctaText:"Try again",icon:(0,h.jsx)(ix.A,{height:38,width:38,stroke:"var(--privy-color-error)"})};if(!(e instanceof n6.y))return e instanceof n6.J&&e.status&&[400,422].includes(e.status)?{title:"Something went wrong",detail:e.message,ctaText:"Try again",icon:n}:{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:n};switch(e.privyErrorCode){case n6.a.INVALID_CAPTCHA:return{title:"Something went wrong",detail:"Please try again.",ctaText:"Try again",icon:n};case n6.a.DISALLOWED_LOGIN_METHOD:return{title:"Not allowed",detail:e.message,ctaText:"Try another method",icon:n};case n6.a.ALLOWLIST_REJECTED:return{title:t.errorTitle||"You don't have access to this app",detail:t.errorDetail||"Have you been invited?",ctaText:t.errorCtaText||"Try another account",icon:(0,h.jsx)(b5,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})};case n6.a.CAPTCHA_FAILURE:return{title:"Something went wrong",detail:"You did not pass CAPTCHA. Please try again.",ctaText:"Try again",icon:(0,h.jsx)("span",{})};case n6.a.CAPTCHA_TIMEOUT:return{title:"Something went wrong",detail:"Something went wrong! Please try again later.",ctaText:"Try again",icon:(0,h.jsx)("span",{})};case n6.a.LINKED_TO_ANOTHER_USER:return{title:"Authentication failed",detail:"This account has already been linked to another user.",ctaText:"Try again",icon:n};case n6.a.NOT_SUPPORTED:return{title:"This region is not supported",detail:"SMS authentication from this region is not available",ctaText:"Try another method",icon:n};case n6.a.TOO_MANY_REQUESTS:return{title:"Request failed",detail:"Too many attempts.",ctaText:"Try again later",icon:n};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:n}}})(e,r.allowlistConfig);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:t}),(0,h.jsxs)(b7,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(bH,{color:"var(--privy-color-error)"}),a.icon]})}),(0,h.jsxs)(b9,{children:[(0,h.jsx)("h3",{children:a.title}),"string"==typeof a.detail?(0,h.jsx)("p",{children:a.detail}):a.detail]}),(0,h.jsx)(gn,{color:"var(--privy-color-error)",onClick:()=>{e instanceof n6.y&&(e.privyErrorCode===n6.a.INVALID_CAPTCHA&&i(),e.privyErrorCode===n6.a.ALLOWLIST_REJECTED&&r.allowlistConfig.errorCtaLink)?window.location.href=r.allowlistConfig.errorCtaLink:n?.()},children:a.ctaText})]})]})},b7=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-b0d5228e-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),b9=ig.I4.div.withConfig({displayName:"GappedContainer",componentId:"sc-b0d5228e-1"})(["display:flex;flex-direction:column;gap:8px;"]),xe=ig.I4.a.withConfig({displayName:"Link",componentId:"sc-b0d5228e-2"})(["color:var(--privy-color-accent) !important;font-weight:600;"]),xt=({onTransfer:e,isTransferring:t,transferSuccess:n})=>(0,h.jsx)(gn,{...n?{success:!0,children:"Success!"}:{warn:!0,loading:t,onClick:e,children:"Transfer and delete account"}}),xn=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-3505eb4c-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;width:100%;padding-bottom:16px;"]),xi=ig.I4.div.withConfig({displayName:"GappedContainer",componentId:"sc-3505eb4c-1"})(["display:flex;flex-direction:column;&& p{font-size:14px;}width:100%;gap:16px;"]),xr=ig.I4.div.withConfig({displayName:"DisclosedAccountContainer",componentId:"sc-3505eb4c-2"})(["display:flex;cursor:pointer;align-items:center;width:100%;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-md);padding:8px 10px;font-size:14px;font-weight:500;gap:8px;"]),xa=(0,ig.I4)(h1.A).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-3505eb4c-3"})(["position:relative;width:",";height:",";color:var(--privy-color-foreground-3);margin-left:auto;"],({$iconSize:e})=>`${e}px`,({$iconSize:e})=>`${e}px`),xs=(0,ig.I4)(h0.A).withConfig({displayName:"StyledCopyIcon",componentId:"sc-3505eb4c-4"})(["position:relative;width:15px;height:15px;color:var(--privy-color-foreground-3);margin-left:auto;"]),xo=ig.I4.ol.withConfig({displayName:"ListContainer",componentId:"sc-3505eb4c-5"})(["display:flex;flex-direction:column;font-size:14px;width:100%;text-align:left;"]),xl=ig.I4.li.withConfig({displayName:"ListItem",componentId:"sc-3505eb4c-6"})(["font-size:14px;list-style-type:auto;list-style-position:outside;margin-left:1rem;margin-bottom:0.5rem;&:last-child{margin-bottom:0;}"]),xc=ig.I4.div.withConfig({displayName:"CircleContainer",componentId:"sc-3505eb4c-7"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),xd=()=>(0,h.jsx)(xc,{children:(0,h.jsx)(xa,{$iconSize:60})}),xu=({address:e,onClose:t,onRetry:n,onTransfer:i,isTransferring:r,transferSuccess:a})=>{let{defaultChain:s}=yK(),o=s.blockExplorers?.default.url??"https://etherscan.io";return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:t,backFn:n}),(0,h.jsxs)(xn,{children:[(0,h.jsx)(xd,{}),(0,h.jsxs)(xi,{children:[(0,h.jsx)("h3",{children:"Check account assets before transferring"}),(0,h.jsx)("p",{children:"Before transferring, ensure there are no assets in the other account. Assets in that account will not transfer automatically and may be lost."}),(0,h.jsxs)(xo,{children:[(0,h.jsx)("p",{children:" To check your balance, you can:"}),(0,h.jsx)(xl,{children:"Log out and log back into the other account, or "}),(0,h.jsxs)(xl,{children:["Copy your wallet address and use a"," ",(0,h.jsx)("u",{children:(0,h.jsx)("a",{target:"_blank",href:o,children:"block explorer"})})," ","to see if the account holds any assets."]})]}),(0,h.jsxs)(xr,{onClick:()=>navigator.clipboard.writeText(e).catch(console.error),children:[(0,h.jsx)(hQ.A,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),(0,h.jsx)(bG,{address:e,showCopyIcon:!1}),(0,h.jsx)(xs,{})]}),(0,h.jsx)(xt,{onTransfer:i,isTransferring:r,transferSuccess:a})]})]}),(0,h.jsx)(fk,{})]})},xh={component:()=>{let{initiateAccountTransfer:e,closePrivyModal:t}=(0,n8.u)(),{data:n,navigate:i,lastScreen:r,setModalData:a}=yQ(),[s,o]=(0,m.useState)(void 0),[l,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(!1),p=async()=>{try{if(!n?.accountTransfer?.nonce||!n?.accountTransfer?.account)throw Error("missing account transfer inputs");u(!0),await e({nonce:n?.accountTransfer?.nonce,account:n?.accountTransfer?.account,accountType:n?.accountTransfer?.linkMethod,externalWalletMetadata:n?.accountTransfer?.externalWalletMetadata,telegramWebAppData:n?.accountTransfer?.telegramWebAppData,telegramAuthResult:n?.accountTransfer?.telegramAuthResult,farcasterEmbeddedAddress:n?.accountTransfer?.farcasterEmbeddedAddress,oAuthUserInfo:n?.accountTransfer?.oAuthUserInfo}),c(!0),u(!1),setTimeout(t,1e3)}
58catch(e){a({errorModalData:{error:e,previousScreen:r||xh}}),i(b6,!0)}};return s?(0,h.jsx)(xu,{address:s,onClose:t,onRetry:()=>o(void 0),onTransfer:p,isTransferring:d,transferSuccess:l}):(0,h.jsx)(xp,{onClose:t,onInfo:()=>o(n?.accountTransfer?.embeddedWalletAddress),onContinue:()=>o(n?.accountTransfer?.embeddedWalletAddress),onTransfer:p,isTransferring:d,transferSuccess:l,data:n})}},xp=({onClose:e,onContinue:t,onInfo:n,onTransfer:i,transferSuccess:r,isTransferring:a,data:s})=>{if(!s?.accountTransfer?.linkMethod||!s?.accountTransfer?.displayName)return;let o={method:s?.accountTransfer?.linkMethod,handle:s?.accountTransfer?.displayName,disclosedAccount:s?.accountTransfer?.embeddedWalletAddress?{type:"wallet",handle:s?.accountTransfer?.embeddedWalletAddress}:void 0};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{closeable:!0}),(0,h.jsxs)(xn,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(bH,{color:"var(--privy-color-error)"}),(0,h.jsx)(iA.A,{height:38,width:38,stroke:"var(--privy-color-error)"})]})}),(0,h.jsxs)(xi,{children:[(0,h.jsxs)("h3",{children:[function(e){switch(e){case"sms":return"Phone number";case"email":return"Email address";case"siwe":return"Wallet address";case"linkedin":return"LinkedIn profile";case"google":case"apple":case"discord":case"github":case"instagram":case"spotify":case"tiktok":case"line":case"twitter":case"telegram":case"farcaster":return`${mw(e.replace("_oauth",""))} profile`;default:return e}}(o.method)," is associated with another account"]}),(0,h.jsxs)("p",{children:["Do you want to transfer",(0,h.jsx)("b",{children:o.handle?` ${o.handle}`:""})," to this account instead? This will delete your other account."]}),(0,h.jsx)(xm,{onClick:n,disclosedAccount:o.disclosedAccount})]}),(0,h.jsxs)(xi,{style:{gap:12,marginTop:12},children:[s?.accountTransfer?.embeddedWalletAddress?(0,h.jsx)(gn,{onClick:t,children:"Continue"}):(0,h.jsx)(xt,{onTransfer:i,transferSuccess:r,isTransferring:a}),(0,h.jsx)(go,{onClick:e,children:"No thanks"})]})]}),(0,h.jsx)(fk,{})]})};function xm({disclosedAccount:e,onClick:t}){return e?(0,h.jsxs)(xr,{onClick:t,children:[(0,h.jsx)(hQ.A,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),(0,h.jsx)(bG,{address:e.handle,showCopyIcon:!1}),(0,h.jsx)(bZ,{width:15,height:15,color:"var(--privy-color-foreground-3)",style:{marginLeft:"auto"}})]}):null}let xy=()=>(0,h.jsx)(xf,{children:(0,h.jsxs)(xg,{children:[(0,h.jsx)(xw,{}),(0,h.jsx)(xv,{})]})}),xf=ig.I4.div.withConfig({displayName:"LoadingContainer",componentId:"sc-85b54ede-0"})(["display:flex;justify-content:center;align-items:center;flex-grow:1;margin:12px;padding:16px;@media all and (display-mode:standalone){margin-bottom:30px;}"]),xg=ig.I4.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-85b54ede-1"})(["position:relative;height:140px;width:140px;opacity:1;animation:fadein 200ms ease;"]),xw=ig.I4.div.withConfig({displayName:"CircleFixed",componentId:"sc-85b54ede-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;&&{border:4px solid var(--privy-color-accent-light);border-radius:50%;}"]),xv=ig.I4.div.withConfig({displayName:"CircleRotate",componentId:"sc-85b54ede-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:var(--privy-color-accent) transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]),xb={component:()=>{let{app:e,setModalData:t,navigate:n,data:i,onUserCloseViaDialogOrKeybindRef:r}=yQ(),[a,s]=(0,m.useState)(""),{embeddedWallets:o}=yK(),{authenticated:l,user:c,getAccessToken:d}=(0,ic.u)(),{closePrivyModal:u,walletProxy:p}=(0,n8.u)(),{onSuccess:y,onFailure:f,callAuthOnSuccessOnClose:g,shouldCreateEth:w,shouldCreateSol:v}=i.createWallet,b=!0===e?.embeddedWallets.requireUserOwnedRecoveryOnCreate,[x,_]=(0,m.useState)(null),{create:C}=vD(),I=w??(!!c&&bU(c,e.embeddedWallets.ethereum.createOnLogin)),E=v??(!!c&&bF(c,e.embeddedWallets.solana.createOnLogin)),T=new p4(async()=>{let e=await d();if(c&&e&&p)try{let e;if(I&&E)e=await C({chainType:"ethereum",walletIndex:0,latestUser:c}),e=await C({chainType:"solana",walletIndex:0,latestUser:e.user});else if(E)e=await C({chainType:"solana",walletIndex:0,latestUser:c});else{if(!I)return void u({shouldCallAuthOnSuccess:g});e=await C({chainType:"ethereum",walletIndex:0,latestUser:c})}_(e),n(vU)}catch(e){s(e.message)}});return(0,m.useEffect)(()=>l&&c?b?(t({...i,createWallet:{...i.createWallet,shouldCreateEth:I,shouldCreateSol:E},recoverySelection:{...i?.recoverySelection,isInAccountCreateFlow:!0,shouldCreateEth:I,shouldCreateSol:E}}),n(CH({walletAction:"create",showAutomaticRecovery:!1,availableRecoveryMethods:o.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:!1,isResettingPassword:!1}))):void T.execute():(n(CN),void f(Error("User must be authenticated before creating a Privy wallet"))),[b,l]),r.current=()=>null,a?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{closeable:!1}),(0,h.jsxs)(gX,{children:[(0,h.jsx)(h4.A,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),(0,h.jsx)(vT,{title:"Something went wrong",description:a})]}),(0,h.jsx)(gn,{onClick:()=>{x?(y(x),u({shouldCallAuthOnSuccess:g})):(f(new n6.af("User wallet creation failed")),u({shouldCallAuthOnSuccess:!1}))},children:"Close"}),(0,h.jsx)(xx,{})]}):(0,h.jsx)(xy,{})}},xx=ig.I4.div.withConfig({displayName:"BottomSpacing",componentId:"sc-1a8a319a-0"}
58)(["height:44px;"]),x_={component:()=>{let{user:e,logout:t}=(0,ic.u)(),{app:n,onUserCloseViaDialogOrKeybindRef:i,setModalData:r,navigate:a}=yQ(),{acceptTerms:s,closePrivyModal:o,createAnalyticsEvent:l}=(0,n8.u)(),c=e=>{e?.preventDefault(),o({shouldCallAuthOnSuccess:!1}),t()};return i.current=c,(0,h.jsx)(xC,{termsAndConditionsUrl:n?.legal.termsAndConditionsUrl,privacyPolicyUrl:n?.legal.privacyPolicyUrl,onAccept:async i=>{i.preventDefault(),await s(),e&&b$(e,n.embeddedWallets)?(r({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),l({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AffirmativeConsentScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),a(xb)):o()},onDecline:c})}},xC=({termsAndConditionsUrl:e,privacyPolicyUrl:t,onAccept:n,onDecline:i})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{closeable:!1}),(0,h.jsx)(h3.A,{width:56,height:56,fill:"var(--privy-color-accent)",style:{margin:"auto"}}),(0,h.jsx)(fB,{style:{marginTop:24},children:"One last step"}),(0,h.jsx)(fz,{children:"By signing up, you agree to our terms and privacy policy."}),(0,h.jsxs)(ff,{style:{marginTop:24},children:[e&&(0,h.jsxs)(fx,{target:"_blank",href:e,children:["View Terms ",(0,h.jsx)(h2.A,{style:{marginLeft:"auto"}})]}),t&&(0,h.jsxs)(fx,{target:"_blank",href:t,children:["View Privacy Policy ",(0,h.jsx)(h2.A,{style:{marginLeft:"auto"}})]})]}),(0,h.jsxs)(xI,{style:{marginTop:24},children:[(0,h.jsx)(go,{onClick:i,children:"No thanks"}),(0,h.jsx)(gn,{onClick:n,children:"Accept"})]}),(0,h.jsx)(fk,{})]}),xI=ig.I4.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-9abb9a03-0"})(["display:flex;gap:10px;"]),xE=({...e})=>(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...e,children:[(0,h.jsxs)("g",{clipPath:"url(#clip0_2856_1743)",children:[(0,h.jsx)("path",{d:"M22.1673 8.24075V16.3642C22.1673 17.3256 21.3421 18.105 20.3241 18.105H17.0028M22.1673 8.24075C22.1673 7.27936 21.3421 6.5 20.3241 6.5H11.5302M22.1673 8.24075V8.42852C22.1673 9.03302 21.8352 9.59423 21.2901 9.91105L15.1463 13.4818C14.5539 13.8261 13.8067 13.8261 13.2143 13.4818L10.1621 11.5401",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,h.jsx)("path",{d:"M3.12913 6.64816C0.508085 12.9507 3.49251 20.1847 9.79504 22.8057L11.5068 23.5176C12.4522 23.9108 13.7783 23.2222 14.1714 22.2768L14.6054 21.2333C14.7687 20.8406 14.6438 20.3871 14.3024 20.1334L11.2872 17.8927C10.9878 17.6702 10.5843 17.6488 10.2632 17.8384L9.11575 18.5156C8.78274 18.7121 8.3597 18.6844 8.07552 18.4221C5.94293 16.4542 4.77629 13.6264 4.90096 10.7273C4.91757 10.3409 5.19796 10.023 5.57269 9.92753L6.86381 9.59869C7.22522 9.50664 7.49627 9.20696 7.55169 8.83815L8.10986 5.12321C8.17306 4.70259 7.94188 4.29293 7.54915 4.1296L6.50564 3.69564C5.56026 3.30248 4.23416 3.99103 3.84101 4.9364L3.12913 6.64816Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,h.jsx)("defs",{children:(0,h.jsx)("clipPath",{id:"clip0_2856_1743",children:(0,h.jsx)("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]}),xT=({chainType:e,withPadding:t})=>{let n="";return n="ethereum-only"===e||"ethereum-and-solana"===e?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",(0,h.jsx)(fC,{$withPadding:t,children:(0,h.jsxs)(fI,{children:[(0,h.jsx)(iI.A,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),(0,h.jsx)("h3",{children:"No wallets available"}),(0,h.jsxs)("p",{children:["Please download an external wallet provider, like ",n,"."]})]})},"empty-wallet-state")},xA=(0,ig.i7)(["from,to{background:var(--privy-color-foreground-4);color:var(--privy-color-foreground-4);}50%{background:var(--privy-color-foreground-accent);color:var(--privy-color-foreground-accent);}"]),xS=(0,ig.AH)(["",""],e=>e.$isLoading?(0,ig.AH)(["width:35%;animation:"," 2s linear infinite;border-radius:var(--privy-border-radius-sm);"],xA):""),xk=({children:e,color:t,isLoading:n,isPulsing:i,...r})=>(0,h.jsx)(xP,{$color:t,$isLoading:n,$isPulsing:i,...r,children:e}),xP=ig.I4.span.withConfig({displayName:"StyledSpan",componentId:"sc-eba15c9-0"})(["padding:0.125rem 0.5rem;font-size:0.75rem;font-weight:500;line-height:1.125rem;border-radius:var(--privy-border-radius-sm);display:flex;align-items:center;"," ",""],e=>{let t,n;"green"===e.$color&&(t="var(--privy-color-success-dark)",n="var(--privy-color-success-light)"),"red"===e.$color&&(t="var(--privy-color-error)",n="var(--privy-color-error-light)"),"gray"===e.$color&&(t="var(--privy-color-foreground-2)",n="var(--privy-color-background-2)");let i=(0,ig.i7)(["from,to{background-color:",";}50%{background-color:rgba(",",0.8);}"],n,n);return(0,ig.AH)(["color:",";background-color:",";",";"],t,n,e.$isPulsing&&(0,ig.AH)(["animation:"," 3s linear infinite;"],i))},xS),xj=({style:e,...t})=>(0,h.jsxs)("svg",{width:"1000",height:"1000",viewBox:"0 0 1000 1000",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",...e},...t,children:[(0,h.jsx)("rect",{width:"1000",height:"1000",rx:"200",fill:"#855DCD"}),(0,h.jsx)("path",{d:"M257.778 155.556H742.222V844.444H671.111V528.889H670.414C662.554 441.677 589.258 373.333 500 373.333C410.742 373.333 337.446 441.677 329.586 528.889H328.889
58V844.444H257.778V155.556Z",fill:"white"}),(0,h.jsx)("path",{d:"M128.889 253.333L157.778 351.111H182.222V746.667C169.949 746.667 160 756.616 160 768.889V795.556H155.556C143.283 795.556 133.333 805.505 133.333 817.778V844.444H382.222V817.778C382.222 805.505 372.273 795.556 360 795.556H355.556V768.889C355.556 756.616 345.606 746.667 333.333 746.667H306.667V253.333H128.889Z",fill:"white"}),(0,h.jsx)("path",{d:"M675.556 746.667C663.283 746.667 653.333 756.616 653.333 768.889V795.556H648.889C636.616 795.556 626.667 805.505 626.667 817.778V844.444H875.556V817.778C875.556 805.505 865.606 795.556 853.333 795.556H848.889V768.889C848.889 756.616 838.94 746.667 826.667 746.667V351.111H851.111L880 253.333H702.222V746.667H675.556Z",fill:"white"})]}),xO=({icon:e})=>(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(xN,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{}),"string"==typeof e?(0,h.jsx)("span",{style:{background:`url('${e}')`,height:"38px",width:"38px",borderRadius:"6px",margin:"auto",backgroundSize:"cover"}}):e?(0,h.jsx)(e,{style:{width:"38px",height:"38px"}}):(0,h.jsx)("span",{})]})})}),xN=ig.I4.div.withConfig({displayName:"StackedContainer",componentId:"sc-26c1d9b9-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]),xR={component:()=>{let{lastScreen:e,currentScreen:t,data:n,navigateBack:i,navigate:r,setModalData:a}=yQ(),{status:s,token:o,waitForResult:l,reset:c,execute:d}=mz(),u=(0,m.useRef)([]),p=e=>{u.current=[e,...u.current]},[y,f]=(0,m.useState)(!0);(0,m.useEffect)(()=>(p(setTimeout(f,1e3,!1)),()=>{u.current.forEach(e=>clearTimeout(e)),u.current=[]}),[]);let[g,w]=(0,m.useState)(""),[v,b]=(0,m.useState)("Checking that you are a human..."),[x,_]=(0,m.useState)((0,h.jsx)(gn,{onClick:()=>{},disabled:!0,children:"Continue"})),[C,I]=(0,m.useState)(!1),[E,T]=(0,m.useState)(3),A=n?.captchaModalData,S=async t=>{try{await A?.callback(t),A?.onSuccessNavigateTo&&r(A?.onSuccessNavigateTo,!1)}catch(t){if(t instanceof m$)return;a({errorModalData:{error:t,previousScreen:e||CN}}),r(A?.onErrorNavigateTo||b6,!1)}};(0,m.useEffect)(()=>{"success"===s?p(setTimeout(async()=>{let e=await l();!e||A?.userIntentRequired||S(e)},1e3)):"ready"===s&&p(setTimeout(()=>{"ready"===s&&d()},500))},[s]),(0,m.useEffect)(()=>{if(!y)switch(s){case"success":w("Success!"),b("CAPTCHA passed successfully."),_((0,h.jsx)(gn,{onClick:()=>{I(!0),S(o)},disabled:!A?.userIntentRequired,loading:C,children:A?.userIntentRequired?"Continue":"Continuing..."})),setTimeout(()=>{I(!0),S(o)},2e3);break;case"loading":w(""),b("Checking that you are a human..."),_((0,h.jsx)(gn,{onClick:()=>{},disabled:!0,children:"Continue"}));break;case"error":w("Something went wrong"),E<=0?(b("If you use an adblocker or VPN, try disabling and re-attempting."),_(null)):(b("You did not pass CAPTCHA. Please try again."),_((0,h.jsx)(gn,{onClick:k,children:"Retry"})))}},[s,y,C]);let k=async()=>{if(E<=0)return;T(e=>e-1),c(),d();let e=await l();!e||A?.userIntentRequired||S(e)};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:e&&t!==e?i:void 0}),(0,h.jsxs)(xM,{children:["success"===s?(0,h.jsx)(h5.A,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}):"error"===s?(0,h.jsx)(h4.A,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}):(0,h.jsx)(xO,{}),(0,h.jsxs)(g1,{children:[g?(0,h.jsx)("h3",{children:g}):null,(0,h.jsx)("p",{children:v})]}),x]}),(0,h.jsx)(fP,{})]})}},xM=ig.I4.div.withConfig({displayName:"CaptchaContainer",componentId:"sc-1be5b3b9-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),xD=({style:e,color:t,...n})=>(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:t||"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...n,children:(0,h.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}),xU=({color:e,...t})=>(0,h.jsx)("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 115.77 122.88",xmlSpace:"preserve",...t,children:(0,h.jsx)("g",{children:(0,h.jsx)("path",{fill:e||"currentColor",className:"st0",d:"M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.5
587,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"})})}),xL=e=>{let[t,n]=(0,m.useState)(!1);return(0,h.jsxs)(xF,{color:e.color,onClick:()=>{n(!0),navigator.clipboard.writeText(e.text),setTimeout(()=>n(!1),1500)},$justCopied:t,children:[t?(0,h.jsx)(xD,{style:{height:"14px",width:"14px"},strokeWidth:"2"}):(0,h.jsx)(xU,{style:{height:"14px",width:"14px"}}),t?"Copied":"Copy"," ",e.itemName?e.itemName:"to Clipboard"]})},xF=ig.I4.button.withConfig({displayName:"StyledCopytoClipboardButton",componentId:"sc-46f4187f-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],e=>e.$justCopied?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)",e=>e.$justCopied?"medium":"normal",e=>e.$justCopied?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"),xW=e=>{let[t,n]=(0,m.useState)(!1);return(0,h.jsx)(x$,{color:e.color,href:e.url,target:"_blank",rel:"noreferrer noopener",onClick:()=>{n(!0),setTimeout(()=>n(!1),1500)},justOpened:t,children:e.text})},x$=ig.I4.a.withConfig({displayName:"StyledOpenLinkButton",componentId:"sc-4e695c83-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],e=>e.justOpened?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)",e=>e.justOpened?"medium":"normal",e=>e.justOpened?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"),xB=()=>(0,h.jsx)("svg",{width:"200",height:"200",viewBox:"-77 -77 200 200",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px"},children:(0,h.jsx)("rect",{width:"50",height:"50",fill:"black",rx:10,ry:10})}),xz=(e,t,n,i,r)=>{for(let a=t;a<t+i;a++)for(let t=n;t<n+r;t++){let n=e?.[t];n&&n[a]&&(n[a]=0)}return e},xq=({x:e,y:t,cellSize:n,bgColor:i,fgColor:r})=>(0,h.jsx)(h.Fragment,{children:[0,1,2].map(a=>(0,h.jsx)("circle",{r:n*(7-2*a)/2,cx:e+7*n/2,cy:t+7*n/2,fill:a%2!=0?i:r},`finder-${e}-${t}-${a}`))}),xV=({cellSize:e,matrixSize:t,bgColor:n,fgColor:i})=>(0,h.jsx)(h.Fragment,{children:[[0,0],[(t-7)*e,0],[0,(t-7)*e]].map(([t,r])=>(0,h.jsx)(xq,{x:t,y:r,cellSize:e,bgColor:n,fgColor:i},`finder-${t}-${r}`))}),xH=({matrix:e,cellSize:t,color:n})=>(0,h.jsx)(h.Fragment,{children:e.map((e,i)=>e.map((e,r)=>e?(0,h.jsx)("rect",{height:t-.4,width:t-.4,x:i*t+.1*t,y:r*t+.1*t,rx:.5*t,ry:.5*t,fill:n},`cell-${i}-${r}`):(0,h.jsx)(m.Fragment,{},`circle-${i}-${r}`)))}),xG=({cellSize:e,matrixSize:t,element:n,sizePercentage:i,bgColor:r})=>{if(!n)return(0,h.jsx)(h.Fragment,{});let a=t*(i||.14),s=Math.floor(t/2-a/2),o=Math.floor(t/2+a/2);(o-s)%2!=t%2&&(o+=1);let l=(o-s)*e,c=l-.2*l,d=s*e;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("rect",{x:s*e,y:s*e,width:l,height:l,fill:r}),(0,h.jsx)(n,{x:d+.1*l,y:d+.1*l,height:c,width:c})]})},xK=e=>{let t=e.outputSize,n=((e,t)=>{let n=h6.create(e,{errorCorrectionLevel:t}).modules,i=((e,t)=>{let n=e.slice(0),i=[];for(;n.length;)i.push(n.splice(0,t));return i})(Array.from(n.data),n.size);return i=xz(i,0,0,7,7),i=xz(i,i.length-7,0,7,7),xz(i,0,i.length-7,7,7)})(e.url,e.errorCorrectionLevel),i=t/n.length,r=function(e,{min:t,max:n}){return Math.min(Math.max(e,t),n)}(2*i,{min:.025*t,max:.036*t});return(0,h.jsxs)("svg",{height:e.outputSize,width:e.outputSize,viewBox:`0 0 ${e.outputSize} ${e.outputSize}`,style:{height:"100%",width:"100%",padding:`${r}px`},children:[(0,h.jsx)(xH,{matrix:n,cellSize:i,color:e.fgColor}),(0,h.jsx)(xV,{cellSize:i,matrixSize:n.length,fgColor:e.fgColor,bgColor:e.bgColor}),(0,h.jsx)(xG,{cellSize:i,element:e.logo?.element,bgColor:e.bgColor,matrixSize:n.length})]})},xJ=ig.I4.div.attrs({className:"ph-no-capture"}).withConfig({displayName:"QrContainer",componentId:"sc-597e27f3-0"})(["display:flex;justify-content:center;align-items:center;height:",";width:",";margin:auto;background-color:",";&&{border-width:2px;border-color:",";border-radius:var(--privy-border-radius-md);}"],e=>`${e.$size}px`,e=>`${e.$size}px`,e=>e.$bgColor,e=>e.$borderColor),xZ=e=>{let{appearance:t}=yK(),n=e.bgColor||"#FFFFFF",i=e.fgColor||"#000000",r=e.size||160,a="dark"===t.palette.colorScheme?n:i;return(0,h.jsx)(xJ,{$size:r,$bgColor:n,$fgColor:i,$borderColor:a,children:(0,h.jsx)(xK,{url:e.url,logo:{element:e.squareLogoElement??xB},outputSize:r,bgColor:n,fgColor:i,errorCorrectionLevel:e.errorCorrectionLevel||"Q"})})},xY={component:()=>{let{navigate:e,app:t}=yQ(),n=t?.allowlistConfig.errorTitle||"You don't have access to this app",i=t?.allowlistConfig.errorDetail||"Have you been invited?",r=t?.allowlistConfig.errorCtaText||"Try another account";return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{}),(0,h.jsxs)(xQ,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(bH,{}),(0,h.jsx)(b5,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})]})}
58),(0,h.jsxs)(xX,{children:[(0,h.jsx)("string"==typeof n?"h3":h.Fragment,{children:n}),(0,h.jsx)("string"==typeof i?"p":h.Fragment,{children:i})]}),t?.allowlistConfig.errorCtaLink?(0,h.jsx)(gn,{as:"a",href:t.allowlistConfig.errorCtaLink,children:r}):(0,h.jsx)(gn,{onClick:()=>{e(CN)},children:r})]})]})}},xQ=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-274cb2fe-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),xX=ig.I4.div.withConfig({displayName:"GappedContainer",componentId:"sc-274cb2fe-1"})(["display:flex;flex-direction:column;gap:8px;"]),x0=({style:e,...t})=>(0,h.jsx)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"38px",width:"38px",...e},...t,children:(0,h.jsx)("path",{d:"M20 13.6V20M20 26.4H20.016M36 20C36 28.8365 28.8366 36 20 36C11.1635 36 4.00001 28.8365 4.00001 20C4.00001 11.1634 11.1635 3.99999 20 3.99999C28.8366 3.99999 36 11.1634 36 20Z",stroke:"currentColor",strokeWidth:"3.2",strokeLinecap:"round",strokeLinejoin:"round"})}),x1={component:()=>{let{navigate:e}=yQ();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{}),(0,h.jsxs)(x2,{children:[(0,h.jsx)(x3,{children:(0,h.jsx)(x0,{})}),(0,h.jsxs)(x4,{children:[(0,h.jsx)("h3",{children:"Unable to sign in"}),(0,h.jsx)("p",{children:"This application has reached its user limit and cannot sign in new users."})]}),(0,h.jsx)(gn,{onClick:()=>{e(CN)},children:"Go back"})]}),(0,h.jsx)(fk,{})]})}},x2=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-b3ae112e-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-top:8px;padding-bottom:32px;"]),x3=ig.I4.div.withConfig({displayName:"IconContainer",componentId:"sc-b3ae112e-1"})(["display:flex;align-items:center;justify-content:center;height:72px;aspect-ratio:1;color:var(--privy-color-error);background-color:var(--privy-color-error-light);border-radius:50%;"]),x4=ig.I4.div.withConfig({displayName:"GappedContainer",componentId:"sc-b3ae112e-2"})(["display:flex;flex-direction:column;gap:8px;"]),x5="#8a63d2",x6={component:()=>{let{authenticated:e,logout:t,ready:n,user:i}=(0,ic.u)(),{lastScreen:r,navigate:a,navigateBack:s,setModalData:o,app:l}=yQ(),{getAuthFlow:c,loginWithFarcaster:d,closePrivyModal:u,createAnalyticsEvent:p}=(0,n8.u)(),[f,g]=(0,m.useState)(void 0),[w,v]=(0,m.useState)(!1),[b,x]=(0,m.useState)(!1),_=(0,m.useRef)([]),C=c(),I=C?.meta.connectUri;return(0,m.useEffect)(()=>{let e=Date.now(),t=setInterval(async()=>{let n=await C.pollForReady.execute(),i=Date.now()-e;if(n){clearInterval(t),v(!0);try{await d(),x(!0)}catch(t){let e={retryable:!1,message:"Authentication failed"};if(t?.privyErrorCode===n6.a.ALLOWLIST_REJECTED)return void a(xY);if(t?.privyErrorCode===n6.a.USER_LIMIT_REACHED)return console.error(new n6.ag(t).toString()),void a(x1);if(t?.privyErrorCode===n6.a.USER_DOES_NOT_EXIST)return void a(bz);if(t?.privyErrorCode===n6.a.LINKED_TO_ANOTHER_USER)e.detail=t.message??"This account has already been linked to another user.";else{if(t?.privyErrorCode===n6.a.ACCOUNT_TRANSFER_REQUIRED&&t.data?.data?.nonce)return o({accountTransfer:{nonce:t.data?.data?.nonce,account:t.data?.data?.subject,displayName:t.data?.data?.account?.displayName,linkMethod:"farcaster",embeddedWalletAddress:t.data?.data?.otherUser?.embeddedWalletAddress,farcasterEmbeddedAddress:t.data?.data?.otherUser?.farcasterEmbeddedAddress}}),void a(xh);t?.privyErrorCode===n6.a.INVALID_CREDENTIALS?(e.retryable=!0,e.detail="Something went wrong. Try again."):t?.privyErrorCode===n6.a.TOO_MANY_REQUESTS&&(e.detail="Too many requests. Please wait before trying again.")}g(e)}}else i>12e4&&(clearInterval(t),g({retryable:!0,message:"Authentication failed",detail:"The request timed out. Try again."}))},2e3);return()=>{clearInterval(t),_.current.forEach(e=>clearTimeout(e))}},[]),(0,m.useEffect)(()=>{if(n&&e&&b&&i){if(l?.legal.requireUsersAcceptTerms&&!i.hasAcceptedTerms){let e=setTimeout(()=>{a(x_)},1400);return()=>clearTimeout(e)}b&&(b$(i,l.embeddedWallets)?_.current.push(setTimeout(()=>{o({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),p({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"FarcasterConnectStatusScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),a(xb)},1400)):_.current.push(setTimeout(()=>u({shouldCallAuthOnSuccess:!0,isSuccess:!0}),1400)))}},[b,n,e,i]),(0,h.jsxs)(h.Fragment,y.Fr||w?{children:[(0,h.jsx)(fR,{backFn:r?s:void 0,onClose:u},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(h.Fragment,y.un?{children:(0,h.jsxs)(x7,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:b,fail:!!f}),(0,h.jsx)(xj,{style:{width:"38px",height:"38px"}})]})}),(0,h.jsxs)(g1,{children:[(0,h.jsx)(fB,{children:f?f.message:"Sign in with Farcaster"}),(0,h.jsx)(fz,{children:f?f.detail:"To sign in with Farcaster, please open the Warpcast app."})]}),I&&(0,h.jsx)(gn,{onClick:e=>{e.preventDefault(),window.location.href=I},children:"Open Warpcast app"})]})}:{children:(0,h.jsxs)(x8,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:b,fail:!!f}),(0,h.jsx)(xj,{style:{width:"38px",height:"38px"}})]})}),(0,h.jsxs)(g1,{children:[(0,h.jsx)(fB,{children:f?f.message:"Signing in with Farcaster"}),(0,h.jsx)(fz,{children:f?f.detail:"This should only take a moment"}),(0,h.jsx)(gZ,{children:I&&y.Fr&&(0,h.jsx)(xW,{text:"Take me to Warpcast",url:I,color:x5})})]})]})}),(0,h.jsx)(fP,{})]}:{children:[(0,h.jsx)(fR,{backFn:r?s:void 0,onClose:u},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(x8,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(fB,{children:"Sign in with Farcaster"}),(0,h.jsx)(fz,{children:"Scan with your phone's camera to continue."}),(0,h.jsx)(gQ,{children:I?(0,h.jsx)(xZ,{url:I,size:275,squareLogoElement:xj}):(0,h.jsx)(f8,{})}),(0,h.jsxs)(gZ,{children:[(0,h.jsx)(fz,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),I&&(0,h.jsx)(xL,{text:I,itemName:"link",color:x5})]})]})}),(0,h.jsx)(fP,{})]})}},x8=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-69a6d91f-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),x7=ig.I4.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-69a6d91f-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),x9=()=>{let[e,t]=(0,m.useState)(!1),{currentScreen:n,navigate:i,setModalData:r,data:a}=yQ(),{enabled:s,token:o}=mz(),{initLoginWithFarcaster:l}=(0,n8.u)(),{accountType:c}=bj();return(0,h.jsxs)(fb,{onClick:async()=>{t(!0);try{s&&!o?(r({captchaModalData:{callback:e=>l(e,a?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:x6,onErrorNavigateTo:b6}}),i(xR)):(await l(o,a?.login?.disableSignup),i(x6))}
58catch(e){r({errorModalData:{error:e,previousScreen:n||CN}}),i(b6)}finally{t(!1)}},disabled:!1,children:[(0,h.jsx)(xj,{})," Farcaster",e&&(0,h.jsx)(f9,{}),"farcaster"===c&&(0,h.jsx)(_e,{color:"gray",children:"Recent"})]})},_e=(0,ig.I4)(xk).withConfig({displayName:"StyledChip",componentId:"sc-30c9632d-0"})(["margin-left:auto;"]),_t=({style:e,...t})=>(0,h.jsxs)("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...e},xmlns:"http://www.w3.org/2000/svg",...t,children:[(0,h.jsxs)("g",{clipPath:"url(#clip0_113_33841)",children:[(0,h.jsx)("path",{d:"M39.1193 0.943398C34.636 -0.174912 29.9185 -0.334713 25.328 0.656273C24.9732 0.732859 24.7477 1.08253 24.8243 1.43729C24.9009 1.79205 25.2506 2.01756 25.6053 1.94097C30.0015 0.991934 34.53 1.14842 38.8375 2.22802C49.1385 4.80983 57.7129 12.5548 60.9786 22.6718C62.2416 26.5843 62.7781 30.7505 62.8855 35.1167C62.8945 35.4795 63.1958 35.7664 63.5586 35.7575C63.9215 35.7485 64.2083 35.4472 64.1994 35.0843C64.0905 30.6582 63.5477 26.3849 62.2536 22.3432C58.8621 11.7515 49.9005 3.63265 39.1193 0.943398Z"}),(0,h.jsx)("path",{d:"M21.9931 2.93163C22.343 2.83511 22.5484 2.47325 22.4518 2.12339C22.3553 1.77352 21.9935 1.56815 21.6436 1.66466C16.8429 2.98903 10.0898 7.56519 5.91628 13.6786C5.91465 13.681 5.91304 13.6834 5.91145 13.6858C2.24684 19.2083 -0.0503572 26.1484 0.591012 32.8828C0.591623 32.8892 0.592328 32.8956 0.593127 32.902C0.746837 34.1317 1.00488 35.3591 1.26323 36.5879C1.80735 39.1761 2.35282 41.7706 1.92765 44.4064C1.86986 44.7647 2.11347 45.102 2.47177 45.1598C2.83007 45.2176 3.16738 44.974 3.22518 44.6157C3.66961 41.8605 3.11776 39.173 2.56581 36.4851C2.31054 35.2419 2.05525 33.9987 1.89847 32.7486C1.29525 26.3851 3.46802 19.7466 7.00418 14.416C11.0189 8.5373 17.5201 4.16562 21.9931 2.93163Z"}),(0,h.jsx)("path",{d:"M30.6166 4.39985C38.8671 3.89603 47.1159 7.26314 52.6556 13.7139C52.8921 13.9893 52.8605 14.4042 52.5852 14.6406C52.3099 14.8771 51.895 14.8455 51.6585 14.5702C46.3904 8.43576 38.541 5.23144 30.6927 5.71195C30.6899 5.71212 30.6871 5.71227 30.6843 5.71241C20.7592 6.19265 11.4643 12.9257 8.04547 22.3603C7.92183 22.7016 7.54498 22.8779 7.20375 22.7543C6.86253 22.6306 6.68616 22.2538 6.80981 21.9126C10.4114 11.9735 20.1717 4.90702 30.6166 4.39985Z"}),(0,h.jsx)("path",{d:"M54.6576 16.5848C54.4553 16.2836 54.047 16.2033 53.7457 16.4057C53.4444 16.608 53.3642 17.0163 53.5665 17.3176C56.6376 21.8904 57.9074 26.8665 58.4094 32.7717C58.4401 33.1333 58.7582 33.4016 59.1199 33.3708C59.4815 33.3401 59.7497 33.022 59.719 32.6604C59.206 26.6261 57.8965 21.4076 54.6576 16.5848Z"}),(0,h.jsx)("path",{d:"M59.2796 35.4504C59.6419 35.4277 59.9539 35.703 59.9765 36.0653C60.2242 40.0279 60.2265 44.5112 59.7881 47.8243C59.7405 48.1841 59.4102 48.4372 59.0504 48.3896C58.6906 48.342 58.4376 48.0117 58.4852 47.6519C58.9077 44.4586 58.91 40.0704 58.6648 36.1473C58.6421 35.785 58.9174 35.473 59.2796 35.4504Z"}),(0,h.jsx)("path",{d:"M7.05311 25.5432C7.13829 25.1904 6.92135 24.8354 6.56855 24.7502C6.21576 24.665 5.86071 24.882 5.77553 25.2348C5.2932 27.2325 5.0428 29.2847 5.03288 31.3388C5.02266 33.4559 5.41742 35.5225 5.81234 37.5899C6.1354 39.2811 6.45855 40.9728 6.5602 42.6932C6.69373 44.9531 6.21839 47.2163 5.39698 49.3703C5.26766 49.7094 5.43774 50.0891 5.77685 50.2184C6.11596 50.3477 6.4957 50.1777 6.62502 49.8386C7.49325 47.5617 8.01954 45.1092 7.87221 42.6157C7.77126 40.9071 7.44813 39.2252 7.12512 37.5439C6.73099 35.4925 6.33704 33.442 6.34716 31.3451C6.35659 29.3933 6.59455 27.4425 7.05311 25.5432Z"}),(0,h.jsx)("path",{d:"M24.2964 10.94C24.4317 11.2768 24.2683 11.6595 23.9315 11.7947C17.1187 14.5307 12.0027 20.7047 10.959 27.9852C10.523 31.0269 10.9941 34.0398 11.465 37.052C11.7303 38.7483 11.9954 40.4443 12.0985 42.1451C12.3221 45.833 11.902 49.8839 9.50192 53.5696C9.30387 53.8737 8.89677 53.9597 8.59264 53.7617C8.28851 53.5636 8.20251 53.1565 8.40056 52.8524C10.5873 49.4944 11.0012 45.7644 10.7867 42.2246C10.6821 40.499 10.4185 38.7833 10.1552 37.0686C9.68265 33.9923 9.21067 30.9195 9.65804 27.7987C10.7724 20.025 16.221 13.4748 23.4417 10.5751C23.7785 10.4399 24.1612 10.6032 24.2964 10.94Z"}),(0,h.jsx)("path",{d:"M47.3662 14.6814C41.9915 9.64741 34.2017 7.89046 27.122 9.4433
58C26.7675 9.52105 26.5432 9.87147 26.6209 10.226C26.6987 10.5805 27.0491 10.8048 27.4036 10.7271C34.1075 9.25665 41.4426 10.934 46.4677 15.6406C50.7033 19.6077 53.1628 25.38 53.8066 31.6779C53.8435 32.0389 54.1661 32.3017 54.5272 32.2648C54.8883 32.2279 55.151 31.9053 55.1141 31.5442C54.4456 25.0047 51.8822 18.9111 47.3662 14.6814Z"}),(0,h.jsx)("path",{d:"M54.9766 34.6738C55.3376 34.6368 55.6604 34.8994 55.6975 35.2604C56.3216 41.337 56.0526 47.9003 55.1104 54.2496C55.0571 54.6086 54.7229 54.8565 54.3639 54.8032C54.0049 54.7499 53.7571 54.4157 53.8103 54.0567C54.7394 47.7957 55.001 41.3439 54.39 35.3947C54.353 35.0336 54.6156 34.7109 54.9766 34.6738Z"}),(0,h.jsx)("path",{d:"M32.0659 13.3553C21.9959 13.3553 13.814 21.3892 13.814 31.3219C13.814 32.3829 13.9081 33.4225 14.0876 34.4334C14.1511 34.7907 14.4922 35.029 14.8495 34.9655C15.2069 34.9021 15.4451 34.561 15.3817 34.2036C15.2155 33.2677 15.1283 32.305 15.1283 31.3219C15.1283 22.1352 22.7014 14.6696 32.0659 14.6696C36.2978 14.6696 40.1642 16.1949 43.1319 18.7152C43.4086 18.9501 43.8233 18.9163 44.0582 18.6396C44.2931 18.363 44.2593 17.9483 43.9827 17.7134C40.7847 14.9975 36.6188 13.3553 32.0659 13.3553Z"}),(0,h.jsx)("path",{d:"M45.455 20.1635C45.717 19.9123 46.133 19.921 46.3842 20.183C49.2843 23.2072 50.2126 27.9605 50.8269 31.9494C51.5188 36.4426 51.6244 40.826 51.6244 42.8585C51.6244 43.2214 51.3302 43.5156 50.9673 43.5156C50.6044 43.5156 50.3101 43.2214 50.3101 42.8585C50.3101 40.8589 50.2055 36.5497 49.5279 32.1494C48.9577 28.4462 48.1356 23.9082 45.4356 21.0927C45.1844 20.8307 45.1931 20.4147 45.455 20.1635Z"}),(0,h.jsx)("path",{d:"M51.4576 46.6219C51.4864 46.2601 51.2165 45.9435 50.8547 45.9146C50.493 45.8858 50.1763 46.1557 50.1474 46.5175C49.8247 50.5654 49.403 54.6088 48.5474 58.3439C48.4663 58.6977 48.6874 59.0502 49.0412 59.1312C49.3949 59.2123 49.7474 58.9912 49.8285 58.6374C50.7067 54.8039 51.134 50.6806 51.4576 46.6219Z"}),(0,h.jsx)("path",{d:"M15.1454 36.852C15.5015 36.7819 15.847 37.0137 15.9171 37.3698C17.3066 44.4257 16.3467 50.8355 12.6672 56.4502C12.4682 56.7537 12.0609 56.8385 11.7573 56.6396C11.4538 56.4407 11.369 56.0333 11.5679 55.7298C15.0299 50.4469 15.9617 44.3985 14.6276 37.6238C14.5575 37.2677 14.7893 36.9221 15.1454 36.852Z"}),(0,h.jsx)("path",{d:"M32.0659 17.631C25.5291 17.631 19.1165 22.691 18.462 29.0504C18.1754 31.8345 18.578 34.5769 18.9807 37.3204C19.3323 39.7159 19.684 42.1124 19.5772 44.5381C19.3328 50.0898 17.7039 54.6726 14.905 58.4471C14.6888 58.7386 14.7499 59.1502 15.0414 59.3663C15.333 59.5825 15.7445 59.5214 15.9607 59.2299C18.9293 55.2266 20.6354 50.386 20.8903 44.5959C20.9966 42.1811 20.6438 39.7923 20.2912 37.4051C19.888 34.6752 19.4851 31.9473 19.7694 29.1849C20.3444 23.5983 26.0946 18.9453 32.0659 18.9453C34.851 18.9453 42.057 20.4534 44.3492 27.9205C45.7856 32.5998 46.1774 38.9326 45.8295 45.0849C45.4816 51.2364 44.3994 57.12 42.9442 60.8928C42.8136 61.2314 42.9822 61.6118 43.3208 61.7424C43.6594 61.873 44.0398 61.7044 44.1704 61.3658C45.6929 57.4186 46.7895 51.386 47.1417 45.1591C47.4938 38.9329 47.1068 32.4249 45.6056 27.5348C43.0612 19.2461 35.0851 17.631 32.0659 17.631Z"}),(0,h.jsx)("path",{d:"M21.9529 56.4512C22.2569 56.6494 22.3426 57.0566 22.1444 57.3606C21.7369 57.9854 21.3784 58.6391 21.0199 59.2928C20.6614 59.9465 20.3028 60.6004 19.8953 61.2253C19.697 61.5293 19.2898 61.615 18.9858 61.4167C18.6819 61.2184 18.5962 60.8113 18.7944 60.5073C19.2019 59.8825 19.5604 59.2288 19.9189 58.5751C20.2774 57.9213 20.636 57.2675 21.0435 56.6426C21.2418 56.3386 21.649 56.2529 21.9529 56.4512Z"}),(0,h.jsx)("path",{d:"M27.5799 24.4525C27.8816 24.2508 27.9625 23.8426 27.7608 23.541C27.559 23.2393 27.1509 23.1583 26.8492 23.3601C24.247 25.1006 22.6505 27.494 22.6505 31.0002C22.6505 33.088 23.0203 34.7946 23.3997 36.5449C23.9674 39.1641 24.3524 41.7777 24.2832 44.468C24.1992 47.7349 23.56 50.7201 22.3313 53.564C22.1873 53.8971 22.3407 54.2839 22.6739 54.4278C23.0071 54.5718 23.3938 54.4184 23.5378 54.0852C24.8369 51.0784 25.509 47.9266 25.5971 44.5018C25.6689 41.7062 25.2732 38.9892 24.6845 36.267C24.3042 34.509 23.9648 32.9394 23.9648 31.0002C23.9648 27.9961 25.2863 25.9866 27.5799 24.4525Z"}),(0,h.jsx)("path",{d:"M30.1447 22.1436C32.8717 21.5877 35.8061 22.2746 37.966 24.0228C41.8241 27.1455 42.3372 32.8403 42.753 37.4549L42.7742 37.69C43.3115 43.6385 42.6964 49.4163 41.4575 55.2186C41.3817 55.5736 41.0326 55.7999 40.6776 55.7241C40.3227 55.6483 40.0964 55.2991 40.1722 54.9442C41.3926 49.2288 41.9873 43.5885 41.4652 37.8082C41.4479 37.6169 41.4307 37.4228 41.4133 37.2264L41.4131 37.2235C41.0438 33.0534 40.5812 27.8304 37.1392 25.0444C35.2926 23.5498 32.7599 22.9518 30.4073 23.4314C30.0517 23.5039 29.7046 23.2744 29.6321 22.9188C29.5596 22.5632 29.7891 22.2161 30.1447 22.1436Z"}),(0,h.jsx)("path",{d:"M40.5287 58.4885C40.6183 58.1368 40.4057 57.7791 40.054 57.6896C39.7023 57.6 39.3446 57.8126 39.2551 58.1643C38.8578 59.7247 38.2456 61.1333 37.4695 62.43
5801C37.2831 62.7415 37.3844 63.145 37.6958 63.3314C38.0072 63.5178 38.4108 63.4165 38.5972 63.1051C39.4336 61.7075 40.0977 60.1816 40.5287 58.4885Z"}),(0,h.jsx)("path",{d:"M37.3152 48.9521C37.6756 48.9948 37.9332 49.3215 37.8906 49.682C37.2699 54.9267 35.8688 59.6042 33.6205 63.6613C33.4446 63.9787 33.0446 64.0934 32.7272 63.9175C32.4097 63.7416 32.295 63.3417 32.4709 63.0242C34.6226 59.1416 35.9811 54.6339 36.5854 49.5275C36.6281 49.1671 36.9548 48.9095 37.3152 48.9521Z"}),(0,h.jsx)("path",{d:"M37.1798 30.6556C36.7242 28.2212 34.6349 26.3591 32.0985 26.3591C28.6638 26.3591 26.254 29.8212 27.1032 33.0422C28.54 38.7279 28.7759 44.2077 27.8032 49.4855L27.8025 49.4893C26.9584 54.228 25.3374 58.4908 23.1263 62.1031C22.9368 62.4127 23.0342 62.8172 23.3437 63.0067C23.6533 63.1962 24.0578 63.0988 24.2473 62.7893C26.5488 59.0292 28.2249 54.6109 29.0961 49.7218C30.106 44.2403 29.8558 38.5684 28.3765 32.7168L28.3748 32.7099C27.7378 30.3005 29.5133 27.6734 32.0985 27.6734C33.9641 27.6734 35.5393 29.0459 35.8871 30.8929C36.8436 36.4411 37.3418 41.5862 36.9871 46.016C36.9581 46.3778 37.2279 46.6945 37.5897 46.7235C37.9515 46.7525 38.2682 46.4827 38.2972 46.1209C38.6649 41.5294 38.1459 36.2576 37.1815 30.6648C37.1809 30.6617 37.1804 30.6586 37.1798 30.6556Z"}),(0,h.jsx)("path",{d:"M30.1376 59.1171C30.4604 59.283 30.5876 59.6792 30.4217 60.002L28.6804 63.3906C28.5145 63.7134 28.1184 63.8406 27.7956 63.6747C27.4728 63.5088 27.3456 63.1127 27.5114 62.7899L29.2527 59.4013C29.4186 59.0785 29.8147 58.9513 30.1376 59.1171Z"}),(0,h.jsx)("path",{d:"M32.5872 31.2892C32.5042 30.9359 32.1505 30.7168 31.7972 30.7998C31.4439 30.8828 31.2247 31.2365 31.3077 31.5898C33.5238 41.0232 33.2194 49.3066 30.5201 56.363C30.3905 56.702 30.5602 57.0819 30.8991 57.2115C31.2381 57.3412 31.618 57.1715 31.7477 56.8326C34.5622 49.475 34.8483 40.9141 32.5872 31.2892Z"})]}),(0,h.jsx)("defs",{children:(0,h.jsx)("clipPath",{id:"clip0_113_33841",children:(0,h.jsx)("rect",{width:"64",height:"64",fill:"white",transform:"translate(0.483887)"})})})]}),_n={component:()=>{let{app:e,lastScreen:t,currentScreen:n,navigateBack:i,data:r,setModalData:a,navigate:s}=yQ(),{loginWithPasskey:o,signupWithPasskey:l,closePrivyModal:c,createAnalyticsEvent:d}=(0,n8.u)(),{user:u,logout:p}=(0,ic.u)(),{passkeySignupFlow:y}=r?.passkeyAuthModalData??{},[f,g]=(0,m.useState)("loading"),[w,v]=(0,m.useState)(null),b=(0,m.useRef)([]),x=e=>{b.current=[e,...b.current]};(0,m.useEffect)(()=>()=>{b.current.forEach(e=>clearTimeout(e)),b.current=[]},[]);let _=async()=>{g("loading");try{y?await l():await o(),g("success")}catch(e){v(e),g("error")}};return(0,m.useEffect)(()=>{if("success"===f&&u){if(e?.legal.requireUsersAcceptTerms&&!u.hasAcceptedTerms)return void x(setTimeout(()=>{s(x_)},900));if(!b$(u,e?.embeddedWallets))return void x(setTimeout(()=>{c({shouldCallAuthOnSuccess:!0,isSuccess:!0})},1400));x(setTimeout(()=>{a({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),d({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"PasskeyStatusScreen"}}),p()},callAuthOnSuccessOnClose:!0}}),s(xb)},900))}},[u,f]),(0,m.useEffect)(()=>{_()},[]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:t&&n!==t?i:void 0}),(0,h.jsxs)(_i,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:"success"===f,fail:"error"===f}),(0,h.jsx)(_t,{style:{width:"38px",height:"38px"}})]})}),(0,h.jsxs)(g1,{children:[(0,h.jsx)("h3",{children:(()=>{switch(f){case"loading":return"Waiting for passkey";case"success":return"Success";case"error":return"Something went wrong"}})()}),(0,h.jsx)("p",{style:{whiteSpace:"pre-wrap"},children:(()=>{switch(f){case"loading":return y?"Please follow prompts to register your passkey.":"Please follow prompts to verify your passkey.\nYou will have to sign up with another method first to register a passkey for your account.";case"success":return"You've successfully logged in with your passkey.";case"error":if(w instanceof n6.y){if(w.privyErrorCode===n6.a.CANNOT_LINK_MORE_OF_TYPE)return"Cannot link more passkeys to account.";if(w.privyErrorCode===n6.a.PASSKEY_NOT_ALLOWED)return"Passkey request timed out or rejected by user.\nYou will have to sign up with another method first to register a passkey for your account."}return"An unknown error occurred.\nYou will have to sign up with another method first to register a passkey for your account."}})()})]}),(()=>{switch(f){case"loading":case"success":return(0,h.jsx)(gn,{onClick:()=>{},disabled:!0,children:"Continue"});case"error":return(0,h.jsx)(gn,{onClick:_,disabled:!1,children:"Retry"})}})()]}),(0,h.jsx)(fP,{})]})}},_i=ig.I4.div.withConfig({displayName:"Container",componentId:"sc-46c03a59-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),_r={component:()=>{let{enabled:e,token:t}=mz(),{lastScreen:n,currentScreen:i,navigateBack:r,navigate:a,setModalData:s}=yQ(),{initSignupWithPasskey:o,initLoginWithPasskey:l}=(0,n8.u)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:n&&i!==n?r:void 0}),(0,h.jsx)(f$,{children:(0,h.jsxs)(_a,{children:[(0,h.jsx)(wj,{}),(0,h.jsx)(_t,{})]})}),(0,h.jsx)(fB,{children:"Log in or create a new account?"}),(0,h.jsx)(fz,{children:"Create a new account with a passkey or use a passkey to log in to an existing account."}),(0,h.jsxs)(fK,{children:[(0,h.jsx)(gn,{onClick:async()=>{e&&!t?(s({passkeyAuthModalData:{passkeySignupFlow:!0},captchaModalData:{callback:e=>o({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:_n,onErrorNavigateTo:b6}}),a(xR)):(await o({withPrivyUi:!0}),s({passkeyAuthModalData:{passkeySignupFlow:!0}}),a(_n))},children:"Create new account"}),(0,h.jsx)(f2,{onClick:async()=>{e&&!t?(s({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>l({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:_n,onErrorNavigateTo:b6}}),a(xR)):(await l({withPrivyUi:!0}),s({passkeyAuthModalData:{passkeySignupFlow:!1}}),a(_n))},children:"Log in with a passkey"})]}),(0,h.jsx)(fk,{})]})}},_a=ig.I4.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-f058c8a2-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent);stroke:var(--privy-color-accent);
58fill:var(--privy-color-accent);}"]),_s=()=>{let{enabled:e,token:t}=mz(),{navigate:n,setModalData:i,app:r,data:a}=yQ(),{initLoginWithPasskey:s}=(0,n8.u)(),o=()=>{r.loginConfig.passkeysForSignupEnabled?n(_r):(async()=>{e&&!t?(i({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>s({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:_n,onErrorNavigateTo:b6}}),n(xR)):(await s({withPrivyUi:!0}),i({passkeyAuthModalData:{passkeySignupFlow:!1}}),n(_n))})()};return 0===(0,m.useMemo)(()=>{let e=a?.login?.loginMethods;return e?e.filter(e=>"passkey"!==e).length:Object.entries(r.loginMethods).filter(([e,t])=>t).filter(([e])=>"passkey"!==e).length},[r.loginMethods,a?.login])?(0,h.jsxs)(fb,{onClick:o,children:[(0,h.jsx)(ib.A,{})," Continue with passkey"]}):(0,h.jsx)(_l,{onClick:o,children:"I have a passkey"})},_o=(0,ig.AH)(["&&{width:100%;font-size:0.875rem;line-height:1rem;display:flex;gap:0.5rem;justify-content:center;align-items:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]),_l=ig.I4.button.withConfig({displayName:"StyledLink",componentId:"sc-1c6127e5-0"})(["",""],_o),_c=({value:e,onChange:t})=>(0,h.jsx)("select",{value:e,onChange:t,children:K.map(e=>(0,h.jsxs)("option",{value:e.code,children:[e.code," +",e.callCode]},e.code))}),_d=(0,m.forwardRef)((e,t)=>{let{app:n}=yQ(),[i,r]=(0,m.useState)(!1),{accountType:a}=bj(),[s,o]=(0,m.useState)(""),[l,c]=(0,m.useState)(n?.intl.defaultCountry??"US"),d=H(s,l),u=new z.Q(l),p=(e=>{let t=(0,V.a)(e,W.A)?.formatInternational();return t?.substring(t.indexOf(" ")+1)})(l),y=(0,B.K)(l),f=!d,[g,w]=(0,m.useState)(!1),v=y.length,b=t=>{let n=t.target.value;c(n),o(""),e.onChange&&e.onChange({rawPhoneNumber:s,qualifiedPhoneNumber:G(s,n),countryCode:n,isValid:H(s,l)})},x=(t,n)=>{try{let i=t.replace(/\D/g,"")===s.replace(/\D/g,"")?t:u.input(t);o(i),e.onChange&&e.onChange({rawPhoneNumber:i,qualifiedPhoneNumber:G(t,n),countryCode:n,isValid:H(t,n)})}catch(e){console.error("Error processing phone number:",e)}},_=()=>{w(!0);let t=G(s,l);e.onSubmit({rawPhoneNumber:s,qualifiedPhoneNumber:t,countryCode:l,isValid:H(s,l)}).finally(()=>w(!1))};return(0,m.useEffect)(()=>{if(e.defaultValue){let t=(e=>{let t=new z.Q;t.input(e);let n=t.getCountry()||"US",i=t.getCallingCode()||"1";return{countryCode:n,phone:e.replace("+"+i,"")}})(e.defaultValue);u.reset(),b({target:{value:t.countryCode}}),x(t.phone,t.countryCode)}},[e.defaultValue]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(_u,{children:(0,h.jsxs)(_h,{$callingCodeLength:v,$stacked:e.stacked,children:[(0,h.jsx)(_c,{value:l,onChange:b}),(0,h.jsx)("input",{ref:t,id:"phone-number-input",className:"login-method-button",type:"tel",placeholder:p,onFocus:()=>r(!0),onChange:e=>{x(e.target.value,l)},onKeyUp:e=>{"Enter"===e.key&&_()},value:s,autoComplete:"tel"}),"phone"!==a||i||e.hideRecent?e.stacked||e.noIncludeSubmitButton?(0,h.jsx)("span",{}):(0,h.jsx)(gd,{isSubmitting:g,onClick:_,disabled:f,children:"Submit"}):(0,h.jsx)(xk,{color:"gray",children:"Recent"})]})}),e.stacked&&!e.noIncludeSubmitButton?(0,h.jsx)(gn,{loading:g,loadingText:null,onClick:_,disabled:f,children:"Submit"}):null]})}),_u=ig.I4.div.withConfig({displayName:"InputContainer",componentId:"sc-2a729487-0"})(["width:100%;"]),_h=ig.I4.label.withConfig({displayName:"PhoneNumberInput",componentId:"sc-2a729487-1"})(["--country-code-dropdown-width:calc(54px + calc(12 * ","px));--phone-input-extra-padding-left:calc(12px + calc(3 * ","px));display:block;position:relative;width:100%;@media (min-width:441px){--country-code-dropdown-width:calc(52px + calc(10 * ","px));}&& > select{font-size:16px;height:24px;position:absolute;margin:13px calc(var(--country-code-dropdown-width) / 4);line-height:24px;width:var(--country-code-dropdown-width);background-color:var(--privy-color-background);background-size:auto;background-position-x:right;cursor:pointer;@media (min-width:441px){font-size:14px;width:var(--country-code-dropdown-width);}:focus{outline:none;box-shadow:none;}}&& > input{font-size:16px;line-height:24px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width:calc(100% - var(--country-code-dropdown-width));padding:12px 88px 12px calc(var(--country-code-dropdown-width) + var(--phone-input-extra-padding-left));padding-right:",";flex-grow:1;background:var(--privy-color-background);border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-mdlg);width:100%;:focus{outline:none;border-color:var(--privy-color-accent);}:autofill,:-webkit-autofill{background:var(--privy-color-background);}@media (min-width:441px){font-size:14px;padding-right:78px;}}&& > :last-child{right:16px;position:absolute;top:50%;transform:translate(0,-50%);}&& > button:last-child{right:0px;line-height:24px;padding:13px 17px;:focus{outline:none;border-color:var(--privy-color-accent);}}&& > input::placeholder{color:var(--privy-color-foreground-3);}"],e=>e.$callingCodeLength,e=>e.$callingCodeLength,e=>e.$callingCodeLength,e=>e.$stacked?"16px":"88px"),_p=({isEditable:e,setIsEditable:t,defaultValue:n})=>{let i=(0,m.useRef)(null),{authenticated:r}=(0,ic.u)(),{navigate:a,setModalData:s,currentScreen:o,data:l}=yQ(),{initLoginWithSms:c}=(0,n8.u)(),{enabled:d,token:u}=mz(),{whatsAppEnabled:p}=yK();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f_,{$if:!e,children:(0,h.jsx)(_d,{ref:i,onSubmit:async function({qualifiedPhoneNumber:e}
58){if(!d||u||r)try{await c({phoneNumber:e,captchaToken:u,withPrivyUi:!0,disableSignup:l?.login?.disableSignup}),a(Cp)}catch(e){s({errorModalData:{error:e,previousScreen:o||CN}}),a(b6)}else s({captchaModalData:{callback:t=>c({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:l?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:Cp,onErrorNavigateTo:b6}}),a(xR)},defaultValue:n})}),(0,h.jsx)(f_,{$if:e,children:(0,h.jsxs)(fb,{onClick:()=>{t(),setTimeout(()=>{i.current?.focus()},0)},children:[(0,h.jsx)(ix.A,{})," Continue with ",p?"WhatsApp":"SMS"]})})]})},_m={apple:{logo:(0,h.jsx)(mv,{}),displayName:"Apple"},discord:{logo:(0,h.jsx)(mb,{}),displayName:"Discord"},github:{logo:(0,h.jsx)(mx,{}),displayName:"GitHub"},google:{logo:(0,h.jsx)(mC,{}),displayName:"Google"},linkedin:{logo:(0,h.jsx)(mT,{}),displayName:"LinkedIn"},spotify:{logo:(0,h.jsx)(mA,{}),displayName:"Spotify"},instagram:{logo:(0,h.jsx)(mI,{}),displayName:"Instagram"},twitter:{logo:(0,h.jsx)(mk,{}),displayName:"Twitter"},tiktok:{logo:(0,h.jsx)(mS,{}),displayName:"TikTok"},line:{logo:(0,h.jsx)(mE,{}),displayName:"LINE"}},_y=({provider:e})=>{let{enabled:t,token:n}=mz(),{navigate:i,setModalData:r,data:a}=yQ(),[s,o]=(0,m.useState)(!1),{initLoginWithOAuth:l}=(0,n8.u)(),{accountType:c}=bj(),d=(0,m.useMemo)(()=>c&&"guest"!==c&&"authorization_key"!==c&&"cross_app"!==c?bE(c):null,[c]),{displayName:u,logo:p}=_m[e];return(0,h.jsxs)(fb,{onClick:()=>{o(!0),setTimeout(()=>{o(!1)},2e3),t&&!n?(r({captchaModalData:{callback:t=>l(e,t,a?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:b6}}),i(xR)):l(e,void 0,a?.login?.disableSignup)},disabled:s,children:[p," ",u,d?.loginMethod===e&&(0,h.jsx)(_f,{color:"gray",children:"Recent"})]})},_f=(0,ig.I4)(xk).withConfig({displayName:"StyledChip",componentId:"sc-209315e7-0"})(["margin-left:auto;"]);function _g(e){return(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 240 240",...e,children:[(0,h.jsx)("defs",{children:(0,h.jsxs)("linearGradient",{x1:"120",y1:"240",x2:"120",gradientUnits:"userSpaceOnUse",id:"telegram-linear-gradient",children:[(0,h.jsx)("stop",{offset:"0",stopColor:"#1d93d2"}),(0,h.jsx)("stop",{offset:"1",stopColor:"#38b0e3"})]})}),(0,h.jsx)("title",{children:"Telegram_logo"}),(0,h.jsx)("circle",{cx:"120",cy:"120",r:"120",fill:"url(#telegram-linear-gradient)"}),(0,h.jsx)("path",{d:"M81.229,128.772l14.237,39.406s1.78,3.687,3.686,3.687,30.255-29.492,30.255-29.492l31.525-60.89L81.737,118.6Z",fill:"#c8daea"}),(0,h.jsx)("path",{d:"M100.106,138.878l-2.733,29.046s-1.144,8.9,7.754,0,17.415-15.763,17.415-15.763",fill:"#a9c6d8"}),(0,h.jsx)("path",{d:"M81.486,130.178,52.2,120.636s-3.5-1.42-2.373-4.64c.232-.664.7-1.229,2.1-2.2,6.489-4.523,120.106-45.36,120.106-45.36s3.208-1.081,5.1-.362a2.766,2.766,0,0,1,1.885,2.055,9.357,9.357,0,0,1,.254,2.585c-.009.752-.1,1.449-.169,2.542-.692,11.165-21.4,94.493-21.4,94.493s-1.239,4.876-5.678,5.043A8.13,8.13,0,0,1,146.1,172.5c-8.711-7.493-38.819-27.727-45.472-32.177a1.27,1.27,0,0,1-.546-.9c-.093-.469.417-1.05.417-1.05s52.426-46.6,53.821-51.492c.108-.379-.3-.566-.848-.4-3.482,1.281-63.844,39.4-70.506,43.607A3.21,3.21,0,0,1,81.486,130.178Z",fill:"#fff"})]})}let _w={component:()=>{let{authenticated:e,logout:t,ready:n,user:i}=(0,ic.u)(),{app:r,setModalData:a,navigate:s,resetNavigation:o,data:l}=yQ(),{initLoginWithTelegram:c,loginWithTelegram:d,updateWallets:u,setReadyToTrue:p,closePrivyModal:y,
58createAnalyticsEvent:f,getAuthMeta:g}=(0,n8.u)(),[w,v]=(0,m.useState)(!1),[b,x]=(0,m.useState)(void 0),_=mz();async function C(){try{let t=await async function(){let t;if(!e){if(_.enabled&&"error"===_.status)throw new m$(_.error,null,n6.a.CAPTCHA_FAILURE);return _.enabled&&"success"!==_.status&&(_.execute(),t=await _.waitForResult()),t}}();await d({captchaToken:t}),v(!0),p(!0)}catch(n){if(n?.privyErrorCode===n6.a.ALLOWLIST_REJECTED)return x(void 0),o(),void s(xY);if(n?.privyErrorCode===n6.a.USER_LIMIT_REACHED)return console.error(new n6.ag(n).toString()),x(void 0),o(),void s(x1);if(n?.privyErrorCode===n6.a.USER_DOES_NOT_EXIST)return x(void 0),o(),void s(bz);if(n?.privyErrorCode===n6.a.ACCOUNT_TRANSFER_REQUIRED&&n.data?.data?.nonce)return x(void 0),o(),a({accountTransfer:{nonce:n.data?.data?.nonce,account:n.data?.data?.subject,telegramAuthResult:g()?.telegramAuthResult,telegramWebAppData:g()?.telegramWebAppData,displayName:n.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:n.data?.data?.otherUser?.embeddedWalletAddress}}),void s(xh);let{retryable:e,detail:t}=mV(n);x({retryable:e,detail:t,message:"Authentication failed"})}}(0,m.useEffect)(()=>{C()},[]),(0,m.useEffect)(()=>{if(!(n&&e&&w&&i))return;if(r?.legal.requireUsersAcceptTerms&&!i.hasAcceptedTerms){let e=setTimeout(()=>{s(x_)},1400);return()=>clearTimeout(e)}if(b$(i,r.embeddedWallets)){let e=setTimeout(()=>{a({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),f({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:"telegram",screen:"TelegramAuthScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),s(xb)},1400);return()=>clearTimeout(e)}u();let o=setTimeout(()=>y({shouldCallAuthOnSuccess:!0,isSuccess:!0}),1400);return()=>clearTimeout(o)},[n,e,w,i]);let I=w?"Successfully connected with Telegram":b?b.message:"Verifying connection to Telegram",E="";return E=w?"You’re good to go!":b?b.detail:"Just a few moments more",(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{}),(0,h.jsx)(g3,{}),(0,h.jsxs)(_v,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:w,fail:!!b}),(0,h.jsx)(_g,{style:{width:"38px",height:"38px"}})]})}),(0,h.jsxs)(g1,{children:[(0,h.jsx)("h3",{children:I}),(0,h.jsx)("p",{children:E})]}),b&&b?.retryable?(0,h.jsx)(gc,{onClick:async()=>{try{x(void 0),l?.telegramAuthModalData?.seamlessAuth||await c(void 0,l?.login?.disableSignup),await C()}catch(n){let{retryable:e,detail:t}=mV(n);x({retryable:e,detail:t,message:"Authentication failed"})}},disabled:!w&&!b?.retryable,children:"Retry"}):null]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fP,{})]})},isCaptchaRequired:!0},_v=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-491d0b9b-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),_b=()=>{let{enabled:e,token:t}=mz(),{navigate:n,setModalData:i,data:r}=yQ(),[a,s]=(0,m.useState)(!1),{initLoginWithTelegram:o}=(0,n8.u)(),{accountType:l}=bj();async function c(e){try{await o(e,r?.login?.disableSignup),i({telegramAuthModalData:{seamlessAuth:!1}}),n(_w)}catch(e){console.error(e),s(!1)}}return(0,h.jsxs)(fb,{onClick:async function(){if(s(!0),e&&!t)return i({captchaModalData:{callback:c,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:b6}}),void n(xR);await c(t)},disabled:a,children:[(0,h.jsx)(_g,{}),"Telegram","telegram"===l&&(0,h.jsx)(_x,{color:"gray",children:"Recent"})]})},_x=(0,ig.I4)(xk).withConfig({displayName:"StyledChip",componentId:"sc-d81b85b5-0"})(["margin-left:auto;"]),__=({icon:e,name:t})=>"string"==typeof e?(0,h.jsx)("img",{alt:`${t||"wallet"} logo`,src:e,style:{height:24,width:24,borderRadius:4}}):void 0===e?(0,h.jsx)(hQ.A,{}):e?(0,h.jsx)(e,{}):null;function _C(e){let t=e.toLowerCase();return!!window?.webkit?.messageHandlers?.ReactNativeWebView||!!window?.ReactNativeWebView||["fbav","fban","instagram","snapchat","linkedinapp"].some(e=>t.includes(e))}let _I=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses")?.split(" ").filter(e=>(0,w.q)(e,{strict:!0})).map(e=>(0,f.b)(e));return!!t?.length&&!!e?.linkedAccounts.filter(e=>"wallet"==e.type&&t.includes(e.address)).length},_E=(0,m.createContext)({plugins:{current:{}}}),_T=({children:e})=>{let t=(0,m.useRef)({});return(0,h.jsx)(_E.Provider,{value:{plugins:t},children:e})},_A=()=>{let{plugins:e}=(0,m.useContext)(_E);return(0,m.useCallback)(t=>e.current[t],[e])},_S=Symbol("solana-ledger-plugin"),_k=e=>(0,h.jsx)("svg",{id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",viewBox:"-0.625 12.48 397.647 399.546",width:"2500",height:"674",preserveAspectRatio:"none",...e,children:(0,h.jsx)("g",{children:(0,h.jsx)("path",{fill:"#333745",d:"M 333.9 12.8 L 150.9 12.8 L 150.9 258.4 L 396.5 258.4 L 396.5 76.7 C 396.6 42.2 368.4 12.8 333.9 12.8 Z M 94.7 12.8 L 64 12.8 C 29.5 12.8 0 40.9 0 76.8 L 0 107.5 L 94.7 107.5 L 94.7 12.8 Z M 0 165 L 94.7 165 L 94.7 259.7 L 0 259.7 L 0 165 Z M 301.9 410.6 L 332.6 410.6 C 367.1 410.6 396.6 382.5 396.6 346.6 L 396.6 316 L 301.9 316 
58L 301.9 410.6 Z M 150.9 316 L 245.6 316 L 245.6 410.7 L 150.9 410.7 L 150.9 316 Z M 0 316 L 0 346.7 C 0 381.2 28.1 410.7 64 410.7 L 94.7 410.7 L 94.7 316 L 0 316 Z"})})}),_P={component:function(){let{data:e,setModalData:t,navigateBack:n,lastScreen:i,navigate:r}=yQ();function a(n){t("wallet"===n?{...e,login:{...e?.login,isSigningInWithLedgerSolana:!1}}:{...e,login:{...e?.login,isSigningInWithLedgerSolana:!0}}),r(_L)}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:i&&i!==_L?n:void 0}),(0,h.jsxs)(_j,{children:[(0,h.jsxs)(_O,{children:[(0,h.jsx)(yh,{style:{width:"48px",height:"48px"}}),(0,h.jsx)(h8.A,{width:24,height:24}),(0,h.jsx)(_k,{style:{width:"48px",height:"48px"}})]}),(0,h.jsxs)(_N,{children:[(0,h.jsx)(_R,{children:"Phantom supports Ledger"}),(0,h.jsxs)(_M,{children:["Are you using a Ledger hardware wallet?",(0,h.jsx)("br",{}),"Continue to sign with Ledger"]})]}),(0,h.jsxs)(_D,{children:[(0,h.jsx)(go,{onClick:()=>a("wallet"),children:"Continue without Ledger"}),(0,h.jsx)(gn,{onClick:()=>a("ledger"),children:"Continue with Ledger"})]})]}),(0,h.jsx)(fk,{})]})}},_j=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-8c598100-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),_O=ig.I4.div.withConfig({displayName:"IconContainer",componentId:"sc-8c598100-1"})(["display:flex;align-items:center;justify-content:center;gap:8px;"]),_N=ig.I4.div.withConfig({displayName:"TextContainer",componentId:"sc-8c598100-2"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;"]),_R=ig.I4.p.withConfig({displayName:"Title",componentId:"sc-8c598100-3"})(["&&{font-size:18px;font-weight:600;}"]),_M=ig.I4.p.withConfig({displayName:"Subtitle",componentId:"sc-8c598100-4"})(["&&{font-size:14px;}"]),_D=ig.I4.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-8c598100-5"})(["width:100%;display:flex;flex-direction:column;gap:10px;margin-top:24px;"]),_U=e=>e?.privyErrorCode===n6.a.LINKED_TO_ANOTHER_USER?m4.ERROR_USER_EXISTS:e instanceof m3&&!e.details.default?e.details:e instanceof mX?m4.ERROR_TIMED_OUT:e instanceof m0?m4.ERROR_USER_REJECTED_CONNECTION:e?.privyErrorCode===n6.a.CANNOT_LINK_MORE_OF_TYPE?m4.ERROR_USER_LIMIT_REACHED:m4.ERROR_WALLET_CONNECTION,_L={component:()=>{let e,[t,n]=(0,m.useState)(!1),[i,r]=(0,m.useState)(!1),[a,s]=(0,m.useState)(void 0),{authenticated:o,logout:l}=(0,ic.u)(),{app:c,navigate:d,navigateBack:u,lastScreen:p,currentScreen:f,setModalData:g,data:w}=yQ(),{getAuthFlow:v,walletConnectionStatus:b,closePrivyModal:x,initLoginWithWallet:_,loginWithWallet:C,updateWallets:I,createAnalyticsEvent:E}=(0,n8.u)(),{walletConnectors:T}=(0,ic.u)(),[A,S]=(0,m.useState)(0),{user:k}=(0,ic.u)(),P=_A(),[j]=(0,m.useState)(k?.linkedAccounts.length||0),[O,N]=(0,m.useState)(""),[R,M]=(0,m.useState)(""),[D,U]=(0,m.useState)(!1),{hasTabbedAway:L}=function(){let[e,t]=(0,m.useState)(!1),n=(0,m.useCallback)(()=>{document.hidden&&t(!0)},[]);return(0,m.useEffect)(()=>(document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)),[n]),{hasTabbedAway:e,reset:()=>t(!1)}}(),{enabled:F,token:W}=mz(),$=yO(b?.connector?.walletClientType||"unknown"),B=y.Fr&&"wallet_connect_v2"===b?.connector?.connectorType||y.Fr&&"coinbase_wallet"===b?.connector?.connectorType||y.Fr&&"injected"===b?.connector?.connectorType&&"phantom"===b?.connector?.walletClientType,z="connected"===b?.status,q="switching_to_supported_chain"===b?.status;(0,m.useEffect)(()=>{let e=v(),t=e instanceof mM||e instanceof mU?e:void 0;z&&"solana"===b.connector?.chainType&&"phantom"===b.connector?.walletClientType&&P(_S)&&void 0===w?.login?.isSigningInWithLedgerSolana?d(_P,!1):(z&&!t&&(!F||W||o?_(b.connectedWallet,W,w?.login?.disableSignup,w?.login?.isSigningInWithLedgerSolana?"transaction":"plain").then(()=>{U(!0)}):(g({captchaModalData:{callback:e=>_(b.connectedWallet,e,w?.login?.disableSignup,w?.login?.isSigningInWithLedgerSolana?"transaction":"plain").then(()=>{U(!0)}),userIntentRequired:!1,onSuccessNavigateTo:_L,onErrorNavigateTo:b6}}),d(xR,!1))),t instanceof mU&&w?.login?.isSigningInWithLedgerSolana&&(t.messageType="transaction"),t&&B&&z&&!t.preparedMessage?t.buildMessage():t&&!B&&z&&(i||(async()=>{r(!0),s(void 0);try{"wallet_connect_v2"===b?.connector?.connectorType&&"metamask"===b?.connector?.walletClientType&&await pz(2500),await H()}catch(e){console.warn("Auto-prompted signature failed",e)}finally{r(!1)}})()))},[A,z,D]),(0,m.useEffect)(()=>
58{if(k&&t){if(c?.legal.requireUsersAcceptTerms&&!k.hasAcceptedTerms){let e=setTimeout(()=>{d(x_)},900);return()=>clearTimeout(e)}if(b$(k,c.embeddedWallets)){let e=setTimeout(()=>{g({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),E({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"ConnectionStatusScreen"}}),l()},callAuthOnSuccessOnClose:!0}}),d(xb)},900);return()=>clearTimeout(e)}I();let e=setTimeout(()=>x({shouldCallAuthOnSuccess:!0,isSuccess:!0}),1400);return()=>clearTimeout(e)}},[k,t]);let V=e=>{if(e?.privyErrorCode!==n6.a.ALLOWLIST_REJECTED){if(e?.privyErrorCode===n6.a.USER_LIMIT_REACHED)return console.error(new n6.ag(e).toString()),void d(x1);if(e?.privyErrorCode!==n6.a.USER_DOES_NOT_EXIST)return e?.privyErrorCode===n6.a.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce?(g({accountTransfer:{nonce:e.data?.data?.nonce,account:v()?.meta.address,displayName:e.data?.data?.account?.displayName,externalWalletMetadata:{walletClientType:v()?.meta.walletClientType,chainId:v()?.meta.chainId,connectorType:v()?.meta.connectorType},linkMethod:"siwe",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void d(xh)):void s(_U(e));d(bz)}else d(xY)};async function H(){try{await C(),n(!0)}catch(e){V(e)}finally{r(!1)}}(0,m.useEffect)(()=>{b?.connectError&&V(b?.connectError)},[b]),((e,t)=>{let n=(0,m.useRef)(()=>{});(0,m.useEffect)(()=>{n.current=e}),(0,m.useEffect)(()=>{if(null!==t){let e=setInterval(()=>n.current(),t||0);return()=>clearInterval(e)}},[t])})(()=>{let e="wallet_connect_v2"===G&&b?.connector instanceof y0?b.connector.redirectUri:void 0;e&&N(e);let t="wallet_connect_v2"===G&&b?.connector instanceof y0?b.connector.fallbackUniversalRedirectUri:void 0;t&&M(t)},b?.connector instanceof y0&&!O?500:null);let G=b?.connector?.connectorType||"injected",K=b?.connector?.walletClientType||"unknown",J=$?.metadata?.shortName||$?.name||b?.connector?.walletBranding.name||"Browser Extension",Z=$?.image_url?.md||b?.connector?.walletBranding.icon||(e=>(0,h.jsx)(yd,{...e})),Y="Browser Extension"===J?J.toLowerCase():J;e=t?`Successfully connected with ${Y}`:a?a.message:q?"Switching networks":z?i&&B?"Signing":"Sign to verify":`Waiting for ${Y}`;let Q="Don’t see your wallet? Check your other browser windows.";t?Q=j===(k?.linkedAccounts.length||0)?"Wallet was already linked.":"You’re good to go!":A>=2&&a?Q="Unable to connect wallet":a?Q=a.detail:q?Q="Switch your wallet to the requested network.":z&&B?Q="Sign the message in your wallet to verify it belongs to you.":"metamask"===K&&y.Fr?Q="Click continue to open and connect MetaMask.":"metamask"===K?Q="For the best experience, connect only one wallet at a time.":"wallet_connect"===G?Q="Open your mobile wallet app to continue":"coinbase_wallet"===G?pU()||(Q=_I(k)?"Continue with the Coinbase app. Not the right wallet? Reset your connection below.":"Open the Coinbase app on your phone to continue."):w?.login?.isSigningInWithLedgerSolana&&(Q="Ledger requires a transaction to verify your identity. You’ll sign a transaction that performs no onchain action.");let X=T?.walletConnectors?.find(e=>"coinbase_wallet"===e.walletClientType),ee="coinbase_wallet"===K&&(_I(k)||a===m4.ERROR_USER_EXISTS);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:p&&f!==p?u:void 0}),(0,h.jsxs)(_F,{children:[(0,h.jsx)(_$,{walletLogo:Z,success:t,fail:!!a}),(0,h.jsxs)(g1,{children:[(0,h.jsx)("h3",{children:e}),(0,h.jsx)("p",{children:Q}),z||!O||L?null:(0,h.jsxs)("p",{children:["Still here?"," ",(0,h.jsx)("a",{href:O,target:"_blank",style:{textDecoration:"underline"},children:"Try connecting again"}),R&&(0,h.jsxs)(h.Fragment,{children:[" ","or"," ",(0,h.jsx)("a",{href:R,target:"_blank",style:{textDecoration:"underline"},children:"use this different link"})]})]})]}),ee?(0,h.jsx)(gn,{onClick:()=>X&&X?.disconnect(),disabled:t,children:"Use a different wallet"}):a==m4.ERROR_USER_EXISTS&&f!==p?(0,h.jsx)(gn,{onClick:u,children:"Use a different wallet"}):z&&!t&&B?(0,h.jsx)(gn,{onClick:()=>{r(!0),H()},disabled:i,children:i?"Signing":"Sign with your wallet"}):!t&&a?.retryable&&A<2?(0,h.jsx)(gn,{onClick:()=>{S(A+1),s(void 0),z?(r(!0),H()):b?.connectRetry()},disabled:!t&&(!a?.retryable||A>=2),children:"Retry"}):t||a?null:(0,h.jsx)(gn,{onClick:()=>{},disabled:!0,children:"Connecting"})]}),(0,h.jsx)(fP,{})]})}},_F=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-a555d5b3-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),_W=ig.I4.div.withConfig({displayName:"StackedContainer",componentId:"sc-a555d5b3-1"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;
58left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]),_$=e=>{let t=e.walletLogo;return(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(_W,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:e.success,fail:e.fail}),"string"==typeof t?(0,h.jsx)("span",{style:{background:`url('${t}') 0 0 / contain`,height:"38px",width:"38px",borderRadius:"6px",margin:"auto",backgroundSize:"contain"}}):(0,h.jsx)(t,{style:{width:"38px",height:"38px"}})]})})})},_B={component:()=>{let e,{navigateBack:t,navigate:n,lastScreen:i,currentScreen:r,data:a,setModalData:s}=yQ(),{walletConnectionStatus:o,closePrivyModal:l}=(0,n8.u)(),[c,d]=(0,m.useState)(void 0),[u,p]=(0,m.useState)(0),f=yO(o?.connector?.walletClientType||"unknown"),g="connected"===o?.status,w="switching_to_supported_chain"===o?.status;(0,m.useEffect)(()=>{if(g){let e;if(a?.externalConnectWallet?.onCompleteNavigateTo){let t=a.externalConnectWallet.onCompleteNavigateTo,i=o.connectedWallet?.address;e=setTimeout(()=>{a.funding&&s({...a,funding:{...a.funding,connectedWalletAddress:i}}),n(t({walletChainType:o.connector?.chainType}))},1400)}else e=setTimeout(l,1400);return()=>clearTimeout(e)}},[g]),(0,m.useEffect)(()=>{o?.connectError&&d(_U(o?.connectError))},[o]);let v=o?.connector?.connectorType||"injected",b=o?.connector?.walletClientType||"unknown",x=f?.metadata?.shortName||f?.name||o?.connector?.walletBranding.name||"Browser Extension",_=f?.image_url?.md||o?.connector?.walletBranding.icon||(e=>(0,h.jsx)(yd,{...e})),C="Browser Extension"===x?x.toLowerCase():x;e=g?`Successfully connected with ${C}`:c?c.message:w?"Switching networks":`Waiting for ${C}`;let I="Don’t see your wallet? Check your other browser windows.";return g?I="You’re good to go!":u>=2&&c?I="Unable to connect wallet":c?I=c.detail:w?I="Switch your wallet to the requested network.":"metamask"===b&&y.Fr?I="Click to continue to open and connect MetaMask.":"metamask"===b?I="For the best experience, connect only one wallet at a time.":"wallet_connect_v2"===v?I="Open your mobile wallet app to continue":"coinbase_wallet"===v&&(I="Open the Coinbase app on your phone to continue."),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:r===i?void 0:t}),(0,h.jsxs)(_z,{children:[(0,h.jsx)(_$,{walletLogo:_,success:g,fail:!!c}),(0,h.jsxs)(g1,{children:[(0,h.jsx)("h3",{children:e}),(0,h.jsx)("p",{children:I})]}),c==m4.ERROR_USER_EXISTS?(0,h.jsx)(gn,{onClick:t,children:"Use a different wallet"}):!g&&c?.retryable&&u<2?(0,h.jsx)(gn,{onClick:()=>{p(u+1),d(void 0),o?.connectRetry()},disabled:!g&&(!c?.retryable||u>=2),children:"Retry"}):!g&&c&&u>=2?(0,h.jsx)(gn,{onClick:t,children:"Use a different wallet"}):null]}),(0,h.jsx)(fP,{})]})}},_z=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-604d07cd-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),_q=({style:e,...t})=>(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"17",height:"17",viewBox:"0 0 17 17",style:{height:"1.25rem",width:"1.25rem",...e},...t,children:(0,h.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 8.67993C16.5 9.82986 15.853 10.8287 14.9032 11.3322C15.2188 12.3599 14.97 13.5237 14.1569 14.3368C13.3437 15.1499 12.18 15.3987 11.1523 15.0831C10.6488 16.0329 9.64993 16.6799 8.5 16.6799C7.35007 16.6799 6.35126 16.0329 5.84771 15.0831C4.82003 15.3987 3.65627 15.1499 2.84314 14.3368C2.03001 13.5237 1.78124 12.3599 2.09681 11.3322C1.14699 10.8287 0.5 9.82986 0.5 8.67993C0.5 7.53 1.14699 6.53119 2.0968 6.02764C1.78125 4.99996 2.03003 3.83621 2.84315 3.02309C3.65627 2.20997 4.82002 1.96119 5.8477 2.27675C6.35125 1.32692 7.35007 0.679932 8.5 0.679932C9.64992 0.679932 10.6487 1.32691 11.1523 2.27672C12.18 1.96115 13.3437 2.20993 14.1569 3.02305C14.97 3.83618 15.2188 4.99996 14.9032 6.02764C15.853 6.53119 16.5 7.53 16.5 8.67993ZM12.2659 6.68856C12.5654 6.40238 12.5761 5.92763 12.29 5.62818C12.0038 5.32873 11.529 5.31797 11.2296 5.60416C9.73022 7.03711 8.40877 8.65489 7.3018 10.4211L5.78033 8.89963C5.48744 8.60673 5.
5801256 8.60673 4.71967 8.89963C4.42678 9.19252 4.42678 9.66739 4.71967 9.96029L6.92031 12.1609C7.08544 12.3261 7.31807 12.4048 7.54957 12.374C7.78106 12.3432 7.98499 12.2064 8.1012 12.0038C9.23027 10.0356 10.6362 8.24613 12.2659 6.68856Z",fill:"var(--privy-color-accent)"})}),_V=ig.I4.div.withConfig({displayName:"TodoList",componentId:"sc-491785d-0"})(["display:flex;flex-direction:column;justify-content:flex-start;gap:4px;"]),_H=ig.I4.div.withConfig({displayName:"TodoSpacer",componentId:"sc-491785d-1"})(["&&&{margin-left:7px;border-left:2px solid var(--privy-color-foreground-4);height:12px;}"]),_G=({children:e})=>(0,h.jsxs)(_K,{children:[(0,h.jsx)(_q,{style:{width:"16px",height:"16px"}}),e]}),_K=ig.I4.div.withConfig({displayName:"TodoItemWrapper",componentId:"sc-491785d-2"})(["display:flex;justify-content:flex-start;justify-items:center;text-align:left;gap:8px;&&{a{text-decoration:underline;color:var(--privy-color-accent);}svg{margin-top:auto;margin-bottom:auto;}}"]),_J=({name:e,installLink:t})=>(0,h.jsxs)(gZ,{children:[(0,h.jsx)(vI,{title:`Create a ${e} wallet`.replace(/wallet wallet/gi,"wallet"),description:"Follow the instructions below to get started."}),(0,h.jsxs)(_V,{children:[(0,h.jsx)(_G,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)("span",{children:"Install the "})," ",(0,h.jsxs)("a",{href:t,target:"_blank",children:[e," browser extension"]})]})}),(0,h.jsx)(_H,{}),(0,h.jsx)(_G,{children:"Set up your first wallet"}),(0,h.jsx)(_H,{}),(0,h.jsx)(_G,{children:"Store your recovery phrase in a safe place!"})]}),(0,h.jsx)(gc,{onClick:()=>window.location.reload(),style:{marginTop:"20px"},children:"Reload the page to use your wallet"})]}),_Z={component:()=>{let{navigateBack:e,data:t}=yQ();if(!t?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:n}=t.installWalletModalData;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:e},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(_J,{...n}),(0,h.jsx)(g4,{}),(0,h.jsxs)(fP,{children:[(0,h.jsx)("span",{children:"Still not sure? "}),(0,h.jsx)("a",{target:"_blank",href:"https://solana.com/docs/intro/wallets",children:"Learn more"})]})]})}},_Y={component:()=>{let{ready:e}=(0,ic.u)(),{data:t}=yQ(),[n,i]=(0,m.useState)(!1);if(!t?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:r,connectOnly:a,chainType:s}=t.installWalletModalData,o=r.getMobileRedirect({useUniversalLink:!n,isSolana:"solana"===s,connectOnly:a}),l=r.name.replace(/ wallet/gi,""),c={title:`Redirecting to ${l} Mobile Wallet`,description:`We'll take you to the ${l} Mobile Wallet app to continue your login experience.`,footnote:""};return e&&(c.description=`For the best experience, we'll automatically log you into the ${l} Mobile Wallet in-app browser.`,c.footnote="You can always return here to login via other methods."),n&&(c.title="Still here?",c.description=`You may need to install the ${r.name} mobile app.`,c.footnote=`Once you're done, you can connect with ${r.name} wallet to complete the login.`),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(vE,{title:c.title,description:c.description}),(0,h.jsxs)(gJ,{children:[(0,h.jsx)(ga,{href:o,onClick:()=>setTimeout(()=>i(!0),1e3),loading:e&&!o,children:n?"Go to App Store":"Continue"}),c.footnote?(0,h.jsx)("p",{children:c.footnote}):null]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}},_Q=({provider:e,displayName:t,logo:n,connectOnly:i,connector:r})=>{let a,{navigate:s,setModalData:o}=yQ(),{connectWallet:l}=(0,n8.u)(),c=bj(),d=yO(e),u="wallet_connect_v2"===r.connectorType?e:r.walletClientType,p=window.matchMedia("(display-mode: standalone)").matches,m=yx({connectorType:r.connectorType,walletClientType:u});a=m&&m.chainTypes.includes(r.chainType)?()=>{m.isInstalled||"solana"===r.chainType&&"isInstalled"in r&&r.isInstalled?(l(r,u),s(i?_B:_L)):y.Fr?(o({installWalletModalData:{walletConfig:m,chainType:r.chainType,connectOnly:i}}),s(_Y)):(o({installWalletModalData:{walletConfig:m,chainType:r.chainType,connectOnly:i}}),s(_Z))}:"coinbase_wallet"!==r.connectorType||"eoaOnly"!==r.coinbaseWalletConfig.preference?.options||!y.Fr||p||pU()?()=>{(!_C(window.navigator.userAgent)||event?.isTrusted)&&(l(r,u),s(i?_B:_L))}:()=>{window.location.href=`https://go.cb-w.com/dapp?cb_url=${encodeURI(window.location.href)}`};let f=t||d?.metadata?.shortName||d?.name||r.walletClientType;return(0,h.jsxs)(_X,{onClick:a,children:[(0,h.jsx)(__,{icon:n||d?.image_url?.md,name:f}),(0,h.jsx)("span",{children:f}),(0,h.jsxs)(_1,{id:"chip-container",children:[c?.walletClientType===u&&c?.chainType===r.chainType?(0,h.jsx)(_0,{color:"gray",children:"Recent"}):(0,h.jsx)("span",{id:"connect-text",children:"Connect"}),"solana"===r.chainType&&(0,h.jsx)(_0,{color:"gray",children:"Solana"})]})]})},_X=(0,ig.I4)(fb).withConfig({displayName:"ConnectWalletButton",componentId:"sc-5903b412-0"})(["> #chip-container > #connect-text{font-weight:500;color:var(--privy-color-accent);opacity:0;transition:opacity 0.1s ease-out;}:hover > #chip-container > #connect-text{opacity:1;}@media (max-width:440px){> #chip-container > #connect-text{display:none;}}"]),_0=(0,ig.I4)(xk).withConfig({displayName:"StyledChip",componentId:"sc-5903b412-1"})(["margin-left:auto;"]),_1=ig.I4.div.withConfig({displayName:"ChipContainer",componentId:"sc-5903b412-2"})(["display:flex;flex-wrap:wrap;gap:8px;margin-left:auto;"]),_2=["coinbase_wallet"],_3=["metamask","okx_wallet","rainbow","uniswap","bybit_wallet","ronin_wallet","haha_wallet","uniswap_extension","zerion","rabby_wallet","cryptocom","binance"],_4=["safe"],_5=["phantom","backpack","solflare","universal_profile"],_6=({wallets:e})=>{let{app:t}=yQ();return 0===e.length?(0,h.jsx)(xT,{chainType:t.appearance.walletChainType,withPadding:!0}):(0,h.jsx)(h.Fragment,{children:e})}
58,_8=({walletList:e,walletChainType:t,connectors:n,connectOnly:i,ignore:r,walletConnectEnabled:a,forceWallet:s})=>{let o=[],l=[],c=[],d=n.filter(e=>"ethereum-only"===t?"ethereum"===e.chainType:"solana-only"!==t||"solana"===e.chainType),u=d.find(e=>"wallet_connect_v2"===e.connectorType);for(let[n,p]of(s?[s.wallet]:e).entries()){if("detected_ethereum_wallets"===p||"detected_wallets"===p)for(let[e,t]of d.filter(({chainType:e,connectorType:t,walletClientType:n})=>"solana"!==e&&("uniswap_wallet_extension"===n||"uniswap_extension"===n?!r.includes("uniswap"):"crypto.com_wallet_extension"===n||"crypto.com_onchain"===n?!r.includes("cryptocom"):"injected"===t&&!r.includes(n))).entries()){let{walletClientType:r,walletBranding:a,chainType:s}=t;("unknown"===r?l:o).push((0,h.jsx)(_Q,{connectOnly:i,provider:r,logo:a.icon,displayName:a.name,connector:t},`${n}-${p}-${r}-${s}-${e}`))}if("detected_solana_wallets"===p||"detected_wallets"===p)for(let[e,a]of d.filter(({chainType:e,walletClientType:n})=>{if("solana"===e)return"ethereum-only"!==t&&!r.includes(n)}).entries()){let{walletClientType:t,walletBranding:r,chainType:s}=a;("unknown"===t?l:o).push((0,h.jsx)(_Q,{connectOnly:i,provider:t,logo:r.icon,displayName:r.name,connector:a},`${n}-${p}-${t}-${s}-${e}`))}if(_5.includes(p)){let e=d.find(e=>"injected"===e.connectorType&&e.walletClientType===p||e.connectorType===p);if(e&&o.push((0,h.jsx)(_Q,{connectOnly:i,provider:p,connector:e},`${n}-${p}`)),"solana-only"===t||"ethereum-and-solana"===t){let e=d.find(({chainType:e,walletClientType:t})=>"solana"===e&&t===p);e&&o.push((0,h.jsx)(_Q,{connectOnly:i,provider:p,connector:e},`${p}-solana`))}}else if(_3.includes(p)){let e=d.find(e=>"uniswap"===p?"uniswap_wallet_extension"===e.walletClientType||"uniswap_extension"===e.walletClientType:"cryptocom"===p?"crypto.com_wallet_extension"===e.walletClientType||"crypto.com_onchain"===e.walletClientType:"injected"===e.connectorType&&e.walletClientType===p);if(a&&!e&&(e=u),e&&o.push((0,h.jsx)(_Q,{connectOnly:i,provider:p,connector:e,logo:"injected"===e.connectorType?e.walletBranding.icon:void 0,displayName:"injected"===e.connectorType?e.walletBranding.name:void 0},`${n}-${p}`)),"solana-only"===t||"ethereum-and-solana"===t){let e=d.find(({chainType:e,walletClientType:t})=>"solana"===e&&t===p);e&&o.push((0,h.jsx)(_Q,{connectOnly:i,provider:p,connector:e},`${p}-solana`))}}else if(_2.includes(p)){let e=d.find(({connectorType:e})=>e===p);e&&o.push((0,h.jsx)(_Q,{connectOnly:i,provider:p,connector:e},`${n}-${p}`))}else if(_4.includes(p))u&&c.push((0,h.jsx)(_Q,{connectOnly:i,provider:p,connector:u},`${n}-${p}`));else if("wallet_connect"===p)u&&c.push((0,h.jsx)(_Q,{connectOnly:i,provider:p,connector:u,logo:u.walletBranding.icon,displayName:"Wallet Connect"},`${n}-${p}`));else if(p===s?.wallet){let t="ethereum"===s.chainType&&e.includes("detected_ethereum_wallets"),r="solana"===s.chainType&&e.includes("detected_solana_wallets");if(e.includes("detected_wallets")||t||r){let e=d.find(({walletClientType:e})=>e===p);e&&o.push((0,h.jsx)(_Q,{connectOnly:i,provider:p,displayName:e.walletBranding?.name,logo:e.walletBranding?.icon,connector:e},`${n}-${p}`))}}}return[...l,...o,...c]},_7=({onClick:e,text:t})=>(0,h.jsxs)(fb,{onClick:e,children:[(0,h.jsx)(hQ.A,{}),(0,h.jsx)(fm,{children:t}),(0,h.jsx)(h7.A,{})]}),_9=({onClick:e,text:t,icon:n})=>(0,h.jsxs)(fb,{onClick:e,children:[n,(0,h.jsx)(fm,{children:t}),(0,h.jsx)(h7.A,{})]}),Ce=({connectOnly:e})=>{let{closePrivyModal:t,connectors:n}=(0,n8.u)(),{data:i,onUserCloseViaDialogOrKeybindRef:r}=yQ(),a=yK(),{accountType:s,walletClientType:o,chainType:l}=bj(),c=(0,m.useMemo)(()=>s&&"guest"!==s&&"authorization_key"!==s&&"cross_app"!==s?bE(s):null,[s]),d=i?.login,{email:u,sms:p,google:y,twitter:f,discord:g,github:w,spotify:v,instagram:b,tiktok:x,line:_,linkedin:C,apple:I,wallet:E,farcaster:T,telegram:A}=(0,m.useMemo)(()=>d?.loginMethods?((e,t=!0)=>e.reduce((e,n)=>({...e,[n]:t}),{}))(d.loginMethods,!0):null,[d])??a.loginMethods,{passkey:S}=a.loginMethods,k=[u&&"email",p&&"sms",y&&"google",f&&"twitter",g&&"discord",w&&"github",v&&"spotify",b&&"instagram",x&&"tiktok",_&&"line",C&&"linkedin",I&&"apple",T&&"farcaster",A&&"telegram"].filter(e=>!!e),P=k.length>0,j=(0,m.useMemo)(()=>E&&!P?"web3-first":E&&a?.appearance.loginGroupPriority||"web2-first",[E,P,a?.appearance.loginGroupPriority]),O=a?.appearance.hideDirectWeb2Inputs,[N,R]=(0,m.useState)("default"),[M,D]=(0,m.useState)(Ca({mostRecentlyUsedAccountType:s,smsAvailable:p,emailAvailable:u,prefilledType:d?.prefill?.type}));(0,m.useEffect)(()=>{D(Ca({mostRecentlyUsedAccountType:s,smsAvailable:p,emailAvailable:u,prefilledType:d?.prefill?.type}))},[u,p,s]);let U=()=>{t({shouldCallAuthOnSuccess:!0}),setTimeout(()=>{R("default")},150)};r.current=U;let L=[];o&&E?L.push(o):c?.loginMethod&&k.includes(c.loginMethod)&&L.push(c.loginMethod);let F=t=>"email"===t?(0,h.jsx)(Ck,{isEditable:"email"===M,setIsEditable:()=>{D("email")},defaultValue:"email"===d?.prefill?.type?d.prefill.value:void 0},t):"sms"===t?(0,h.jsx)(_p,{isEditable:"sms"===M,setIsEditable:()=>{D("sms")},defaultValue:"phone"===d?.prefill?.type?d.prefill.value:void 0},t):"apple"===t?(0,h.jsx)(_y,{provider:"apple"},t):"discord"===t?(0,h.jsx)(_y,{provider:"discord"},t):"farcaster"===t?(0,h.jsx)(x9,{},t):"github"===t?(0,h.jsx)(_y,{provider:"github"},t):"google"===t?(0,h.jsx)(_y,{provider:"google"},t):"linkedin"===t?(0,h.jsx)(_y,{provider:"linkedin"},t):"tiktok"===t?(0,h.jsx)(_y,{provider:"tiktok"},t):"line"===t?(0,h.jsx)(_y,{provider:"line"},t):"spotify"===t?(0,h.jsx)(_y,{provider:"spotify"},t):"instagram"===t?(0,h.jsx)(_y,{provider:"instagram"},t):"twitter"===t?(0,h.jsx)(_y,{provider:"twitter"},t):"telegram"===t?(0,h.jsx)(_b,{},t):_8({walletList:a.appearance.walletList,walletChainType:d?.walletChainType??a.appearance.walletChainType,connectors:n,connectOnly:e,ignore:[],walletConnectEnabled:a.externalWallets.walletConnect.enabled,forceWallet:{wallet:t,chainType:l??"ethereum"}}),W=_8({walletList:a.appearance.walletList.filter(e=>e!==o),walletChainType:d?.walletChainType??a.appearance.walletChainType,connectors:n,connectOnly:e,ignore:[...a.appearance.walletList,o],walletConnectEnabled:a.externalWallets.walletConnect.enabled}),$=k.filter(e=>e!==c?.loginMethod).flatMap(F),B=L.flatMap(F);"web3-first"===j&&"default"===N?W.unshift(...B):"web2-first"===j&&$.unshift(...B);let z=k.filter(e=>"email"!==e&&"sms"!==e),q=Cn({priority:j,email:u,sms:p,social:z}),V=Ci({priority:j,email:u,sms:p,social:z}),H=(0,h.jsx)(_7,{text:Cr({priority:j}),onClick:()=>R("web3-overflow")}),G=(0,h.jsx)(_9,{text:q,icon:V,onClick:()=>R("web2-overflow")}),K=+!O,J=E&&W.length>0,Z=0===$.length&&E&&0===W.length,Y=5-!!J,Q=W.length>0?W:(0,h.jsx)(xT,{chainType:a.appearance.walletChainType,withPadding:!0});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{title:a.appearance.landingHeader,onClose:U,backFn:"default"===N?void 0:()=>{R("default")}}),"default"===N&&(0,h.jsx)(Ct,{}),"default"===N&&("string"==typeof a.appearance.loginMessage?(0,h.jsx)(fv,{children:a.appearance.loginMessage}):a.appearance.loginMessage),(0,h.jsx)(fy,{style:{overflow:"hidden",padding:2},children:(0,h.jsxs)(ff,{children:["default"===N&&"web2-first"===j&&(0,h.jsxs)(h.Fragment,{children:[$.length>Y?$.slice(0,Y-1):$,$.length>Y&&G,J&&H,Z&&(0,h.jsx)(xT,{chainType:a.appearance.walletChainType})]}),"default"===N&&"web3-first"===j&&(0,h.jsxs)(h.Fragment,{children:[E&&(0,h.jsxs)(h.Fragment,{children:[W.length>Y?W.slice(0,Y-1):W,W.length>Y&&H]}),$.length>K&&G,$.length===K&&$[0],Z&&(0,h.jsx)(xT,{chainType:a.appearance.walletChainType})]}),"web2-overflow"===N&&(0,h.jsx)(h.Fragment,{children:"web3-first"===j?$:$.slice(3)}),"web3-overflow"===N?Q:[],S&&"default"===N&&(0,h.jsx)(_s,{})]})}),a&&(0,h.jsx)(fS,{app:a}),(0,h.jsx)(fk,{})]})},Ct=(0,ig.I4)(bN).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-5f067b17-0"})(["margin-bottom:16px;"]),Cn=({priority:e,email:t,sms:n,social:i})=>"web2-first"===e?"Other socials":t&&n&&i.length>0||t&&i.length>0?"Log in with email or socials":n&&i.length>0?"Log in with sms or socials":t&&n?"Continue with email or sms":t?"Continue with email":n?"Continue with sms":"Log in with a social account",Ci=({priority:e,email:t,sms:n,social:i})=>"web2-first"===e||i.length>0?(0,h.jsx)(hJ.A,{}):t&&n?(0,h.jsx)(xE,{}):t?(0,h.jsx)(hZ.A,{}):n?(0,h.jsx)(ix.A,{}):null,Cr=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets",Ca=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:n,prefilledType:i})=>
58n&&("email"===e&&"phone"!==i||"email"===i)||!t||"phone"!==e&&"phone"!==i?"email":"sms",Cs={component:()=>{let{app:e}=yQ();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?(0,h.jsx)(CP,{connectOnly:!0}):(0,h.jsx)(Ce,{connectOnly:!0})}},Co=Array(6).fill("");var Cl,Cc,Cd,Cu=((Cc=Cu||{})[Cc.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",Cc[Cc.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",Cc),Ch=((Cd=Ch||{})[Cd.EMAIL=0]="EMAIL",Cd[Cd.SMS=1]="SMS",Cd);let Cp={component:()=>{let{app:e,navigate:t,lastScreen:n,navigateBack:i,setModalData:r,onUserCloseViaDialogOrKeybindRef:a}=yQ(),{closePrivyModal:s,resendEmailCode:o,resendSmsCode:l,getAuthMeta:c,loginWithCode:d,updateWallets:u,createAnalyticsEvent:p}=(0,n8.u)(),{authenticated:f,logout:g,user:w}=(0,ic.u)(),{whatsAppEnabled:v}=yK(),[b,x]=(0,m.useState)(Co),[_,C]=(0,m.useState)(!1),[I,E]=(0,m.useState)(null),[T,A]=(0,m.useState)(null),[S,k]=(0,m.useState)(0);a.current=()=>null;let P=+!c()?.email;(0,m.useEffect)(()=>{if(S){let e=setTimeout(()=>{k(S-1)},1e3);return()=>clearTimeout(e)}},[S]),(0,m.useEffect)(()=>{if(f&&_&&w){if(e?.legal.requireUsersAcceptTerms&&!w.hasAcceptedTerms){let e=setTimeout(()=>{t(x_)},900);return()=>clearTimeout(e)}if(b$(w,e.embeddedWallets)){let e=setTimeout(()=>{r({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),p({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AwaitingPasswordlessCodeScreen"}}),g()},callAuthOnSuccessOnClose:!0}}),t(xb)},900);return()=>clearTimeout(e)}{u();let e=setTimeout(()=>s({shouldCallAuthOnSuccess:!0,isSuccess:!0}),1400);return()=>clearTimeout(e)}}},[f,_,w]),(0,m.useEffect)(()=>{if(I&&0===T){let e=setTimeout(()=>{x(Co),E(null);let e=document.querySelector("input[name=code-0]");e?.focus()},1400);return()=>clearTimeout(e)}},[I]);let j=e=>{e.preventDefault();let i=e.currentTarget.value.replace(" ","");if(""===i)return;if(isNaN(Number(i)))return E("Code should be numeric"),void A(1);E(null),A(null);let a=Number(e.currentTarget.name?.charAt(5)),s=[...i||[""]].slice(0,6-a),o=[...b.slice(0,a),...s,...b.slice(a+s.length)];x(o);let l=Math.min(Math.max(a+s.length,0),5);if(!isNaN(Number(e.currentTarget.value))){let e=document.querySelector(`input[name=code-${l}]`);e?.focus()}if(o.every(e=>e&&!isNaN(+e))){let e=document.querySelector(`input[name=code-${l}]`);e?.blur(),d(o.join("")).then(()=>C(!0)).catch(e=>{if(e instanceof n6.J&&e.privyErrorCode===n6.a.INVALID_CREDENTIALS)E("Invalid or expired verification code");else if(e instanceof n6.J&&e.privyErrorCode===n6.a.CANNOT_LINK_MORE_OF_TYPE)E(e.message);else{if(e instanceof n6.J&&e.privyErrorCode===n6.a.USER_LIMIT_REACHED)return console.error(new n6.ag(e).toString()),void t(x1);if(e instanceof n6.J&&e.privyErrorCode===n6.a.USER_DOES_NOT_EXIST)return void t(bz);if(e instanceof n6.J&&e.privyErrorCode===n6.a.LINKED_TO_ANOTHER_USER)return r({errorModalData:{error:e,previousScreen:n??Cp}}),void t(b6,!1);if(e instanceof n6.J&&e.privyErrorCode===n6.a.DISALLOWED_PLUS_EMAIL)return r({inlineError:{error:e}}),void t(Cs,!1);if(e instanceof n6.J&&e.privyErrorCode===n6.a.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return r({accountTransfer:{nonce:e.data?.data?.nonce,account:0===P?c()?.email:c()?.phoneNumber,displayName:e.data?.data?.account?.displayName,linkMethod:0===P?"email":"sms",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void t(xh);E("Issue verifying code")}A(0)})}},O=0==P?(0,h.jsx)(hZ.A,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"}):(0,h.jsx)(ix.A,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),N=(0,h.jsxs)("p",0==P?{children:["Please check ",(0,h.jsx)(Cb,{children:c()?.email})," for an email from privy.io and enter your code below."]}:{children:["Please check ",(0,h.jsx)(Cb,{children:c()?.phoneNumber})," for a",v?" WhatsApp":""," message from ",e?.name||"Privy"," and enter your code below."]});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:()=>i()},"header"),(0,h.jsxs)(Cm,{children:[(0,h.jsx)(vT,{title:"Enter confirmation code",description:N,icon:O}),(0,h.jsxs)(gY,{children:[(0,h.jsxs)(Cy,{children:[(0,h.jsx)(Cf,{$fail:!!I,$success:_,children:(0,h.jsx)("span",{children:I||(_?"Success!":"")}
58)}),(0,h.jsx)("div",{children:b.map((e,t)=>(0,h.jsx)("input",{name:`code-${t}`,type:"text",value:b[t],onChange:j,onKeyUp:e=>{"Backspace"===e.key&&(e=>{if(1===T&&(E(null),A(null)),x([...b.slice(0,e),"",...b.slice(e+1)]),e>0){let t=document.querySelector(`input[name=code-${e-1}]`);t?.focus()}})(t)},inputMode:"numeric",autoFocus:0===t,pattern:"[0-9]",className:`${_?"success":""} ${I?"fail":""}`,autoComplete:y.Fr?"one-time-code":"off"},t))})]}),(0,h.jsxs)(Cg,{children:[(0,h.jsxs)("span",{children:["Didn't get ",0==P?"an email":"a message","?"]}),S?(0,h.jsxs)(Cv,{children:[(0,h.jsx)(hY.A,{color:"var(--privy-color-foreground)",strokeWidth:1.33,height:"12px",width:"12px"}),(0,h.jsx)("span",{children:"Code sent"})]}):(0,h.jsx)(Cw,{children:(0,h.jsx)("button",{onClick:async()=>{k(30),0==P?await o():await l()},children:"Resend code"})})]})]})]}),(0,h.jsx)(fk,{})]})}},Cm=ig.I4.div.withConfig({displayName:"PasswordlessCodeContainer",componentId:"sc-2171637e-0"})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:center;margin:auto;gap:16px;flex-grow:1;"]),Cy=ig.I4.div.withConfig({displayName:"CodeInput",componentId:"sc-2171637e-1"})(["display:flex;flex-direction:column;width:100%;gap:8px;> div:last-child{display:flex;justify-content:center;gap:0.5rem;width:100%;border-radius:var(--privy-border-radius-md);> input{border:1px solid var(--privy-color-foreground-4);background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);padding:8px 10px;height:58px;width:46px;text-align:center;font-size:18px;}> input:focus{border:1px solid var(--privy-color-accent);}> input:invalid{border:1px solid var(--privy-color-error);}> input.success{border:1px solid var(--privy-color-success);}> input.fail{border:1px solid var(--privy-color-error);animation:shake 180ms;animation-iteration-count:2;}}@keyframes shake{0%{transform:translate(1px,0px);}33%{transform:translate(-1px,0px);}67%{transform:translate(-1px,0px);}100%{transform:translate(1px,0px);}}"]),Cf=ig.I4.div.withConfig({displayName:"InputHelp",componentId:"sc-2171637e-2"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-end;width:100%;"],e=>e.$success?"var(--privy-color-success)":e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)"),Cg=ig.I4.div.withConfig({displayName:"HelpText",componentId:"sc-2171637e-3"})(["font-size:13px;color:var(--privy-color-foreground);display:flex;gap:8px;align-items:center;width:100%;margin-top:16px;padding-bottom:32px;"]),Cw=ig.I4.div.withConfig({displayName:"ResendButtonContainer",componentId:"sc-2171637e-4"})(["color:var(--privy-color-accent);padding:2px 0;> button{text-decoration:underline;}"]),Cv=ig.I4.div.withConfig({displayName:"Badge",componentId:"sc-2171637e-5"})(["display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-sm);padding:2px 8px;gap:4px;background:var(--privy-color-background-2);color:var(--privy-color-foreground-2);"]),Cb=ig.I4.span.withConfig({displayName:"BoldWrappingSpan",componentId:"sc-2171637e-6"})(["font-weight:500;word-break:break-all;"]),Cx=ig.I4.span.withConfig({displayName:"ErrorMessage",componentId:"sc-fcb8cd50-0"})(["text-align:left;font-size:0.75rem;font-weight:500;line-height:1.125rem;color:var(--privy-color-error);"]),C_=ig.I4.label.withConfig({displayName:"BaseEmailForm",componentId:"sc-6423bc41-0"})(["display:block;position:relative;width:100%;> svg{position:absolute;margin:13px 17px;height:24px;width:24px;color:var(--privy-color-foreground-3);}&& > input{background-color:#f00;font-size:16px;line-height:24px;padding:12px 88px 12px 52px;flex-grow:1;background:var(--privy-color-background);border:1px solid ",";border-radius:var(--privy-border-radius-mdlg);width:100%;@media (min-width:441px){font-size:14px;padding-right:78px;}:focus{outline:none;border-color:",";box-shadow:",";}:autofill,:-webkit-autofill{background:var(--privy-color-background);}&& > input::placeholder{color:var(--privy-color-foreground-3);}&:disabled{opacity:0.4;cursor:not-allowed;}&:disabled,&:disabled:hover,&:disabled > span{color:var(--privy-color-foreground-3);}}&& > button:last-child{right:0px;line-height:24px;padding:13px 17px;:focus{outline:none;}&:disabled{opacity:0.4;cursor:not-allowed;}&:disabled,&:disabled:hover,&:disabled > span{color:var(--privy-color-foreground-3);}}"],({$error:e})=>e?"var(--privy-color-error) !important":"var(--privy-color-foreground-4)",({$error:e})=>e?"var(--privy-color-error) !important":"var(--privy-color-accent-light)",({$error:e})=>e?"none":"0 0 0 1px var(--privy-color-accent-light)"),CC=(0,ig.I4)(C_).withConfig({displayName:"EmailUpdateForm",componentId:"sc-6423bc41-1"})(["background-color:var(--privy-color-background);transition:background-color 200ms ease;&& > button{right:0;line-height:24px;position:absolute;padding:13px 17px;background-color:#090;:focus{outline:none;border-color:var(--privy-color-accent);}}"]),CI=(0,ig.I4)(C_).withConfig({displayName:"EmailInputForm",componentId:"sc-6423bc41-2"})(["&& > input{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-right:",";border:1px solid ",";&& > input::placeholder{color:var(--privy-color-foreground-3);}}&& > :last-child{right:16px;position:absolute;top:50%;transform:translate(0,-50%);}&& > button:last-child{right:0px;line-height:24px;padding:13px 17px;:focus{outline:none;}}"],e=>e.$stacked?"16px":"88px",({$error:e})=>e?"var(--privy-color-error) !important":"var(--privy-color-foreground-4)"),CE=ig.I4.div.withConfig({displayName:"InputContainerForm",componentId:"sc-6423bc41-3"})(["width:100%;&& > ","{display:block;text-align:left;padding-left:var(--privy-border-radius-mdlg);padding-bottom:5px;}"],Cx),CT=(0,m.forwardRef)((e,t)=>
58{let[n,i]=(0,m.useState)(e.defaultValue||""),[r,a]=(0,m.useState)(""),[s,o]=(0,m.useState)(!1),{authenticated:l}=(0,ic.u)(),{initLoginWithEmail:c}=(0,n8.u)(),{navigate:d,setModalData:u,currentScreen:p,data:y}=yQ(),{enabled:f,token:g}=mz(),[w,v]=(0,m.useState)(!1),{accountType:b}=bj(),x=yK();(0,m.useEffect)(()=>{!n&&x.disablePlusEmails&&y?.inlineError?.error instanceof n6.y&&y?.inlineError?.error.privyErrorCode===n6.a.DISALLOWED_PLUS_EMAIL&&!r&&a("Please enter a valid email address without a '+'."),r&&a("")},[n]);let _=pW(n),C=s||!_,I=()=>{u({login:y?.login,inlineError:void 0}),!f||g||l?(o(!0),c({email:n,captchaToken:g,disableSignup:y?.login?.disableSignup,withPrivyUi:!0}).then(()=>{d(Cp)}).catch(e=>{u({errorModalData:{error:e,previousScreen:p||CN}}),d(b6)}).finally(()=>{o(!1)})):(u({captchaModalData:{callback:e=>c({email:n,captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:Cp,onErrorNavigateTo:b6}}),d(xR))};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(CA,{children:[r&&(0,h.jsx)(Cx,{style:{display:"block",marginTop:"0.25rem",textAlign:"left"},children:r}),(0,h.jsxs)(CS,{stacked:e.stacked,$error:!!r,children:[(0,h.jsx)(hZ.A,{}),(0,h.jsx)("input",{ref:t,id:"email-input",className:"login-method-button",type:"email",placeholder:"[email protected]",onFocus:()=>v(!0),onChange:e=>i(e.target.value),onKeyUp:e=>{"Enter"===e.key&&I()},value:n,autoComplete:"email"}),"email"!==b||w?e.stacked?(0,h.jsx)("span",{}):(0,h.jsx)(gd,{isSubmitting:s,onClick:I,disabled:C,children:"Submit"}):(0,h.jsx)(xk,{color:"gray",children:"Recent"})]})]}),e.stacked?(0,h.jsx)(gn,{loadingText:null,loading:s,disabled:C,onClick:I,children:"Submit"}):null]})}),CA=CE,CS=CI,Ck=({isEditable:e,setIsEditable:t,defaultValue:n})=>{let i=(0,m.useRef)(null);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f_,{$if:!e,children:(0,h.jsx)(CT,{ref:i,defaultValue:n})}),(0,h.jsx)(f_,{$if:e,children:(0,h.jsxs)(fb,{onClick:()=>{t(),setTimeout(()=>{i.current?.focus()},0)},children:[(0,h.jsx)(hZ.A,{})," Continue with Email"]})})]})},CP=({connectOnly:e})=>{let{closePrivyModal:t,connectors:n}=(0,n8.u)(),{app:i,onUserCloseViaDialogOrKeybindRef:r,data:a}=yQ(),{appearance:{palette:{colorScheme:s}}}=yK(),{accountType:o,walletClientType:l,chainType:c}=bj(),d=(0,m.useMemo)(()=>o&&"guest"!==o&&"authorization_key"!==o&&"cross_app"!==o?bE(o):null,[o]),u=i.loginMethodsAndOrder?.primary??[],p=i.loginMethodsAndOrder?.overflow??[],y=(0,m.useMemo)(()=>[...u,...p],[u,p]),f=i.loginMethods.passkey,g=a?.login,w=[];l&&y.includes(l)?w.push(l):o&&y.includes(d?.loginMethod)&&w.push(d?.loginMethod);let[v,b]=(0,m.useState)("default"),[x,_]=(0,m.useState)(Ca({mostRecentlyUsedAccountType:o,smsAvailable:y.includes("sms"),emailAvailable:y.includes("email"),prefilledType:g?.prefill?.type}));(0,m.useEffect)(()=>{_(Ca({mostRecentlyUsedAccountType:o,smsAvailable:y.includes("sms"),emailAvailable:y.includes("email"),prefilledType:g?.prefill?.type}))},[y,o]),(0,m.useEffect)(()=>{"phone"===o&&_("sms");let e=y.indexOf("sms"),t=y.indexOf("email");e>-1&&e<t&&_("sms")},[o,u,p]);let C=()=>{t({shouldCallAuthOnSuccess:!0}),setTimeout(()=>{b("default")},150)};r.current=C;let I=t=>"email"===t?(0,h.jsx)(Ck,{isEditable:"email"===x,setIsEditable:()=>{_("email")},defaultValue:"email"===g?.prefill?.type?g.prefill.value:void 0},t):"sms"===t?(0,h.jsx)(_p,{isEditable:"sms"===x,setIsEditable:()=>{_("sms")},defaultValue:"phone"===g?.prefill?.type?g.prefill.value:void 0},t):"apple"===t?(0,h.jsx)(_y,{provider:"apple"},t):"discord"===t?(0,h.jsx)(_y,{provider:"discord"},t):"farcaster"===t?(0,h.jsx)(x9,{},t):"github"===t?(0,h.jsx)(_y,{provider:"github"},t):"google"===t?(0,h.jsx)(_y,{provider:"google"},t):"linkedin"===t?(0,h.jsx)(_y,{provider:"linkedin"},t):"spotify"===t?(0,h.jsx)(_y,{provider:"spotify"},t):"instagram"===t?(0,h.jsx)(_y,{provider:"instagram"},t):"tiktok"===t?(0,h.jsx)(_y,{provider:"tiktok"},t):"line"===t?(0,h.jsx)(_y,{provider:"line"},t):"twitter"===t?(0,h.jsx)(_y,{provider:"twitter"},t):"telegram"===t?(0,h.jsx)(_b,{},t):t.startsWith("privy:")?(0,h.jsx)(bD,{appId:t.replace("privy:","")},t):_8({walletList:i.appearance.walletList,walletChainType:g?.walletChainType??i.appearance.walletChainType,connectors:n,connectOnly:e,ignore:y,walletConnectEnabled:i.externalWallets.walletConnect.enabled,forceWallet:{wallet:t,chainType:c??"ethereum"}}),E=w.flatMap(I),T=u.filter(e=>e!==l&&e!==d?.loginMethod).flatMap(I),A=p.filter(e=>e!==l&&e!==d?.loginMethod).flatMap(I),[S,k]=((e,t)=>{let n=[],i=[];for(let[r,a]of e.entries())r<t?n.push(a):i.push(a);return[n,i]})([...E,...T,...A],Cj({primary:T.length+E.length,overflow:A.length}));return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{title:i.appearance.landingHeader,onClose:C,backFn:"default"===v?void 0:()=>{b("default")}}),"default"===v&&(0,h.jsx)(CO,{}),"default"===v&&("string"==typeof i.appearance.loginMessage?(0,h.jsx)(fv,{children:i.appearance.loginMessage}):i.appearance.loginMessage),(0,h.jsx)(fy,{style:{overflow:"hidden"},children:(0,h.jsxs)(fg,{$colorScheme:s,children:["default"===v&&(0,h.jsxs)(h.Fragment,{children:[S,k.length>0&&(0,h.jsx)(_9,{text:"More options",icon:(0,h.jsx)(hJ.A,{}),onClick:()=>b("overflow")})]}),"overflow"===v&&(0,h.jsx)(h.Fragment,{children:k}),f&&"default"===v&&(0,h.jsx)(_s,{})]})}),i&&(0,h.jsx)(fS,{app:i}),(0,h.jsx)(fk,{})]})},Cj=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,CO=(0,ig.I4)(bN).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-d846420a-0"})(["margin-bottom:16px;"]),CN={component:()=>{let{app:e}=yQ();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?(0,h.jsx)(CP,{connectOnly:!1}):(0,h.jsx)(Ce,{connectOnly:!1})},isCaptchaRequired:!0,isUnauthenticatedScreem:!0},CR={component:()=>{let[e,t]=(0,m.useState)(null),[n,i]=(0,m.useState)(!1),[r,a]=(0,m.useState)(null),[s,o]=(0,m.useState)(""),{authenticated:l,getAccessToken:c,user:d}=(0,ic.u)(),{walletProxy:u,refreshSessionAndUser:p,closePrivyModal:y,
58createAnalyticsEvent:f}=(0,n8.u)(),{app:g,navigate:w,data:v,onUserCloseViaDialogOrKeybindRef:b}=yQ(),{onSuccess:x,onFailure:_}=v.setWalletPassword,C=(0,ic.h)(d),I="user-passcode"===e?.recoveryMethod,E="user-passcode"===C?.recoveryMethod;(0,m.useEffect)(()=>{l||(w(CN),_(new n6.ah("User must be authenticated before setting a password on a Privy wallet")))},[l]);let T=()=>(r?_(r):I?x(e):_(new n6.af("Exited before password was added to wallet")),void y({shouldCallAuthOnSuccess:!1}));return b.current=T,(0,h.jsx)(bC,{appName:g?.name||"privy",config:{initiatedBy:"user",onCancel:T},error:r?"An error has occurred, please try again.":void 0,buttonLoading:n,buttonHideAnimations:!1,password:s,isResettingPassword:E,onPasswordGenerate:()=>o(by()),onPasswordChange:o,onSubmit:async()=>{I?(x(e),y({shouldCallAuthOnSuccess:!1})):(i(!0),a(null),await (async()=>{let e=await c();if(e&&d&&C?.address&&s&&u)try{f({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:C.address,existingRecoveryMethod:C.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:E}});let{entropyId:n,entropyIdVerifier:i}=mY(d);if(!(await u.setRecovery({accessToken:e,entropyId:n,entropyIdVerifier:i,recoveryPassword:s,recoveryMethod:"user-passcode"})).entropyId)return a(new n6.af("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:C.address,existingRecoveryMethod:C.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:E,reason:"error setting password"}});let r=await p(),o=(0,ic.h)(r);if(!o)return a(new n6.af("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:C.address,existingRecoveryMethod:C.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:E,reason:"wallet disconnected"}});t(o),f({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:C.address,existingRecoveryMethod:C.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:E}})}catch(e){console.warn(e),a(e instanceof Error?e:Error("Error setting password on privy wallet")),f({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:C.address,reason:e}})}})(),i(!1))},onClose:T})}},CM={component:()=>{let{closePrivyModal:e}=(0,n8.u)(),{data:t,navigate:n,onUserCloseViaDialogOrKeybindRef:i}=yQ(),{onFailure:r}=t.setWalletPassword,a=()=>{r(new n6.af("Exited before password was added to wallet")),e({shouldCallAuthOnSuccess:!1})};return i.current=a,(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:a}),(0,h.jsx)(g3,{}),(0,h.jsxs)(gX,{children:[(0,h.jsxs)(g5,{children:[(0,h.jsx)(hJ.A,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),(0,h.jsx)(g8,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:(0,h.jsx)(pl.A,{width:"12px",height:"12px",fill:"white"})})]}),(0,h.jsxs)(vT,{title:"Secure Your Account",children:["Please set a password to secure your account.",(0,h.jsx)("p",{children:"Losing access to this password and this device will make your account inaccessible."})]})]}),(0,h.jsx)(gn,{onClick:()=>{n(CR)},children:"Add password"}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}},CD={component:()=>{let[e,t]=(0,m.useState)(!0),{authenticated:n,getAccessToken:i,user:r}=(0,ic.u)(),{walletProxy:a,closePrivyModal:s,createAnalyticsEvent:o}=(0,n8.u)(),{navigate:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=yQ(),[u,p]=(0,m.useState)(void 0),[y,f]=(0,m.useState)(""),[g,w]=(0,m.useState)(!1),{entropyId:v,entropyIdVerifier:b,onCompleteNavigateTo:x,onSuccess:_,onFailure:C}=c.recoverWallet,I=(e="User exited before their wallet could be recovered")=>{s({shouldCallAuthOnSuccess:!1}),C("string"==typeof e?new n6.af(e):e)};return d.current=I,(0,m.useEffect)(()=>{if(!n)return I("User must be authenticated and have a Privy wallet before it can be recovered")},[n]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:I}),(0,h.jsx)(g3,{}),(0,h.jsxs)(CL,{children:[(0,h.jsxs)(CU,{children:[(0,h.jsx)(i_.A,{height:48,width:48,stroke:"var(--privy-color-accent)"}),(0,h.jsx)("h3",{style:{color:"var(--privy-color-foreground)"},children:"Enter your password"}),(0,h.jsx)("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),(0,h.jsxs)("div",{children:[(0,h.jsxs)(vX,{children:[(0,h.jsx)(vY,{type:e?"password":"text",onCh
58ange:e=>(e=>{e&&p(e)})(e.target.value),disabled:g,style:{paddingRight:"2.3rem"}}),(0,h.jsx)(v4,{style:{right:"0.75rem"},children:e?(0,h.jsx)(v6,{onClick:()=>t(!1)}):(0,h.jsx)(v8,{onClick:()=>t(!0)})})]}),!!y&&(0,h.jsx)(CF,{children:y})]}),(0,h.jsxs)("div",{children:[(0,h.jsxs)(g2,{children:[(0,h.jsx)("h4",{children:"Why is this necessary?"}),(0,h.jsx)("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),(0,h.jsx)(CW,{loading:g||!a,disabled:!u,onClick:async()=>{w(!0);let e=await i(),t=(0,ic.b)(r,v);if(!e||!t||null===u)return I("User must be authenticated and have a Privy wallet before it can be recovered");try{o({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t.address}}),await a?.recover({accessToken:e,entropyId:v,entropyIdVerifier:b,recoveryPassword:u}),f(""),x?l(x):s({shouldCallAuthOnSuccess:!1}),_?.(t),o({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}})}catch(e){!function(e){return wq(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)}(e)?f("An error has occurred, please try again."):f("Invalid recovery password, please try again.")}finally{w(!1)}},warn:!1,$hideAnimations:!v&&g,children:"Recover your account"})]})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}},CU=ig.I4.div.withConfig({displayName:"Header",componentId:"sc-93ed4ea8-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:20px 0;gap:4px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]),CL=ig.I4.div.withConfig({displayName:"Content",componentId:"sc-93ed4ea8-1"})(["display:flex;flex-direction:column;justify-content:space-between;"]),CF=ig.I4.div.withConfig({displayName:"ErrorMessage",componentId:"sc-93ed4ea8-2"})(["line-height:20px;height:20px;font-size:13px;color:var(--privy-color-error);text-align:left;margin-top:0.5rem;"]),CW=(0,ig.I4)(gn).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-93ed4ea8-3"})(["",""],({$hideAnimations:e})=>e&&(0,ig.AH)(["&&{transition:none;}"])),C$={component:()=>{let{app:e,navigate:t,data:n,onUserCloseViaDialogOrKeybindRef:i}=yQ(),[r,a]=(0,m.useState)(""),[s,o]=(0,m.useState)(!1),[l,c]=(0,m.useState)(),[d,u]=(0,m.useState)(null),{create:p}=vD(),{authenticated:y,user:f}=(0,ic.u)(),{closePrivyModal:g,isNewUserThisSession:w,initializeWalletProxy:v}=(0,n8.u)(),{onSuccess:b,onFailure:x,callAuthOnSuccessOnClose:_,shouldCreateEth:C,shouldCreateSol:I}=n.createWallet,[E,T]=(0,m.useState)(null),A=new p4(async()=>{try{let e;if(C&&I)e=await p({recoveryMethod:"user-passcode",recoveryPassword:l,chainType:"ethereum",walletIndex:0,latestUser:f}),e=await p({chainType:"solana",walletIndex:0,latestUser:e.user});else if(I)e=await p({recoveryMethod:"user-passcode",recoveryPassword:l,chainType:"solana",walletIndex:0,latestUser:f});else{if(!C)throw Error("Invalid args to create wallet");e=await p({recoveryMethod:"user-passcode",recoveryPassword:l,chainType:"ethereum",walletIndex:0,latestUser:f})}T(e),w?t(vU):(b(e),g({shouldCallAuthOnSuccess:_}))}catch(e){a(e.message)}});return(0,m.useEffect)(()=>{d||v(3e4).then(e=>u(e))},[d]),(0,m.useEffect)(()=>{if(!y||!f)return t(CN),void x(Error("User must be authenticated before creating a Privy wallet"))},[y]),i.current=()=>null,(0,h.jsx)(bC,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:!d,buttonLoading:s,buttonHideAnimations:!E&&s,isResettingPassword:!1,error:r,password:l||"",onClose:()=>{E&&"user-passcode"!==E.account.recoveryMethod?(x(new n6.af("User created a wallet but failed to set a password for it")),g({shouldCallAuthOnSuccess:!1})):E?(b(E),g({shouldCallAuthOnSuccess:_})):(x(new n6.af("User wallet creation failed")),g({shouldCallAuthOnSuccess:!1}))},onPasswordChange:c,onPasswordGenerate:()=>c(by()),onSubmit:async()=>(o(!0),A.execute().then(()=>new Promise(e=>setTimeout(e,250))).finally(()=>o(!1)))})}},CB=ig.I4.div.withConfig({displayName:"WithCircleBorder",componentId:"sc-e4fc5563-0"})(["&&{border-width:4px;}display:flex;justify-content:center;align-items:center;padding:1rem;aspect-ratio:1;border-style:solid;border-color:",";border-radius:50%;"],e=>e.$color??"var(--privy-color-accent)"),Cz=ig.I4.span.withConfig({displayName:"Subtitle",componentId:"sc-7a11f796-0"})(["margin-top:4px;color:var(--privy-color-foreground);text-align:center;font-size:0.875rem;font-weight:400;line-height:1.375rem;&& a{color:var(--privy-color-accent);}"]),Cq=ig.I4.span.withConfig({displayName:"Title",componentId:"sc-66de63c-0"})(["color:var(--privy-color-foreground);font-size:1.125rem;font-weight:600;line-height:1.875rem;text-align:center;"]),CV={component:()=>{let{user:e,getAccessToken:t}=(0,ic.u)(),{walletProxy:n,refreshSessionAndUser:i,closePrivyModal:r}=(0,n8.u)(),a=yQ(),{entropyId:s,entropyIdVerifier:o}=a.data?.recoverWallet,[l,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(null),[p,y]=(0,m.useState)(null);function f(){if(!l){if(p)return a.data?.setWalletPassword?.onFailure(p),void r();if(!d)return a.data?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),void r()}}return a.onUserCloseViaDialogOrKeybindRef.current=f,(0,h.jsxs)(h.Fragment,p?{children:[(0,h.jsx)(fR,{onClose:f},"header"),(0,h.jsx)(CB,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:(0,h.jsx)(iA.A,{height:38,width:38,stroke:"var(--privy-color-error)"})}),(0,h.jsx)(Cq,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),(0,h.jsx)(fm,{style:{minHeight:"2rem"}}),(0,h.jsx)(gi,{onClick:()=>y(null),children:"Try again"}),(0,h.jsx)(fk,{})]}:{children:[(0,h.jsx)(fR,{onClose:f},"header"),(0,h.jsx)(h9.A,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),(0,h.jsx)(Cq,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),(0,h.jsx)(Cz,{style:{marginTop:"1rem"}
58,children:"When you log into a new device, you’ll only need to authenticate to access your account. Never get logged out if you forget your password."}),(0,h.jsx)(fm,{style:{minHeight:"2rem"}}),(0,h.jsx)(gi,{loading:l,disabled:!(!l&&!d),onClick:()=>(async function(){c(!0);try{let l=await t(),c=(0,ic.b)(e,s);if(!l||!n||!c)return;if(!(await n.setRecovery({accessToken:l,entropyId:s,entropyIdVerifier:o,existingRecoveryMethod:c.recoveryMethod,recoveryMethod:"privy"})).entropyId)throw Error("Unable to set recovery on wallet");let d=await i();if(!d)throw Error("Unable to set recovery on wallet");let h=(0,ic.b)(d,c.address);if(!h)throw Error("Unabled to set recovery on wallet");u(!!d),setTimeout(()=>{a.data?.setWalletPassword?.onSuccess(h),r()},1400)}catch(e){y(e)}finally{c(!1)}})(),children:d?"Success":"Confirm"}),(0,h.jsx)(fk,{})]})}};function CH({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:n,isResettingPassword:i,showAutomaticRecovery:r}){return r?CV:n||1===t.length?function({isCreatingWallet:e,skipSplashScreen:t}){return e?C$:t?CR:CM}({isCreatingWallet:"create"===e,skipSplashScreen:i}):vV}function CG(e){switch(e){case"user-passcode":return CD;case"google-drive":case"icloud":return v$;default:throw Error("Recovery method not supported")}}let CK=({children:e,theme:t})=>(0,h.jsxs)(CJ,{$theme:t,children:[(0,h.jsx)(pd.A,{width:"1.25rem",color:"dark"===t?"var(--privy-color-accent-light)":"var(--privy-color-accent-dark)",style:{minWidth:"1.25rem"}}),e]}),CJ=ig.I4.div.withConfig({displayName:"Container",componentId:"sc-c3403117-0"})(["display:flex;gap:0.5rem;background-color:var(--privy-color-warn-light);color:var(--privy-color-foreground);align-items:flex-start;text-align:left;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);}"]),CZ=ig.I4.div.withConfig({displayName:"Column",componentId:"sc-cfc52180-0"})(["display:flex;flex-direction:column;"]),CY=ig.I4.span.withConfig({displayName:"LabelXs",componentId:"sc-4c43f9fd-0"})(["color:var(--privy-color-foreground-3);font-size:0.75rem;font-weight:500;line-height:1.125rem;"]),CQ=(0,ig.AH)(["&&{border-width:1px;padding:0.5rem 1rem;}width:100%;text-align:left;border:solid 1px var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);display:flex;justify-content:space-between;align-items:center;",""],e=>"error"===e.$state?"border-color: var(--privy-color-error);":""),CX=ig.I4.div.withConfig({displayName:"Box",componentId:"sc-1660059c-0"})(["",""],CQ),C0=({errMsg:e,balance:t,address:n,isLoading:i,className:r,title:a,isPulsing:s,showIcon:o,statusColor:l="green"})=>{let c;return c=l||(e?"red":"green"),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(CX,{className:r,$state:e?"error":void 0,children:[(0,h.jsxs)(CZ,{children:[(0,h.jsx)(CY,{children:a||"Pay with"}),(0,h.jsx)(bG,{address:n,showCopyIcon:o||!!e})]}),void 0!==t&&(0,h.jsx)(xk,{isLoading:i,isPulsing:s,color:c,children:t})]}),e&&(0,h.jsx)(Cx,{style:{marginTop:"0.25rem"},children:e})]})};function C1({rpcConfig:e,appId:t,address:n,chain:i}){let{chains:r}=(0,n8.u)(),[a,s]=(0,m.useState)(0n),[o,l]=(0,m.useState)(!1),c=(0,m.useMemo)(()=>{let n=i||r[0];if(n)return(0,n7.l)({chain:i,transport:(0,n9.L)(pF(n,e,t))})},[i,e,t]),d=(0,m.useCallback)(async()=>{if(!n||!c)return;l(!0);let e=await c.getBalance({address:n}).catch(console.error);return e?(s(e),l(!1),e):void 0},[c,n,s]);return(0,m.useEffect)(()=>{d().catch(console.error)},[]),{balance:a,isLoading:o,reloadBalance:d}}let C2="sdk_fiat_on_ramp_completed_with_status",C3=async({chain:e,address:t,appId:n,rpcConfig:i,erc20Address:r})=>{let a=(0,n7.l)({chain:e,transport:(0,n9.L)(pF(e,i,n))});return{balance:await a.readContract({address:r,abi:C4,functionName:"balanceOf",args:[t]}).catch(()=>0n),chain:e}},C4=[{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],C5=Symbol("solana-funding-plugin"),C6=async({emitPrivyEvent:e,getAccessToken:t,initializeWalletProxy:n,refreshSessionAndUser:i,user:r},{privateKey:a,chainType:s})=>{if("user-controlled-server-wallets-only"===yK().embeddedWallets.mode)throw e("linkAccount","onError",n6.a.UNSUPPORTED_WALLET_TYPE,{linkMethod:"siwe"}),new n6.P("Importing wallets is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!r)throw e("linkAccount","onError",n6.a.MUST_BE_AUTHENTICATED,{linkMethod:"siwe"}),new n6.P("User must be authenticated before linking an account.");let[o,l]=await Promise.all([t(),n(15e3)]);if(!l||!o)throw e("linkAccount","onError",n6.a.MUST_BE_AUTHENTICATED,{linkMethod:"siwe"}),new n6.P("User must be authenticated before linking an account.");await l.importWallet({privateKey:a,accessToken:o,chainType:s});let c=await i(),d="solana"===s?(0,ic.e)(c):(0,ic.k)(c);if(!d)throw e("createWallet","onError",n6.a.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to import wallet");return e("createWallet","onSuccess",{wallet:d}),d};class C8{async handleSignMessage(e){if(!e.params||"string"!=typeof e.params.message)throw Error("Message must be provided as a string for Solana signMessage RPC");let t=await this.signMessage(mD(e.params.message,"base64"));return{signature:mD(t).toString("base64")}}
58async request(e){if(console.debug("EmbeddedSolanaProvider.request() called with args",e),!await A7())throw Error("User must be authenticated to use embedded Solana wallet");if(!await Sr({address:this.address}))throw new n6.P("Unable to connect to Solana embedded wallet");if("signMessage"===e.method)return await this.handleSignMessage(e);throw Error("Embedded Solana provider does not yet support this RPC method.")}constructor(e,t,n){this.walletProxy=e,this.address=t,this.signMessage=n}}async function C7({tx:e,accessToken:t,walletProxy:n,entropyId:i,entropyIdVerifier:r,transactingWalletAddress:a,transactingWalletIndex:s}){let o=gN(e,a),l=gO(e)?mD(e.message.serialize()):e.serializeMessage(),{response:c}=await n.rpc({accessToken:t,entropyId:i,entropyIdVerifier:r,chainType:"solana",hdWalletIndex:s,request:{method:"signMessage",params:{message:l.toString("base64")}}}),d=mD(c.data.signature,"base64");return e.addSignature(o,d),e}let C9=async({accessToken:e,appConfig:t,privy:n,emitPrivyEvent:i,proxy:r,refreshSessionAndUser:a,recoverEmbeddedWallet:s,user:o,walletIndex:l,setModalData:c,openModal:d,chainType:u,setUser:h})=>{if(l<0)throw i("createWallet","onError",n6.a.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${l}
58) is invalid.`);let p=(0,ic.h)(o);if(l>0&&!p)throw i("createWallet","onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),Error("Must have an existing embedded wallet to create an additional wallet.");if(t.embeddedWallets.requireUserOwnedRecoveryOnCreate&&"user-controlled-server-wallets-only"===t.embeddedWallets.mode)throw i("createWallet","onError",n6.a.EMBEDDED_WALLET_CREATE_ERROR),Error("User owned recovery not yet supported for this app.");if(!p&&t.embeddedWallets.requireUserOwnedRecoveryOnCreate)return await Ie({emitPrivyEvent:i,setModalData:c,openModal:d,chainType:u});let m=vR(o,{chainType:u,walletIndex:l})[0];if(m)return{user:o,account:m};if(0===l&&!r)return Ie({emitPrivyEvent:i,setModalData:c,openModal:d,chainType:u});if(!r)throw i("createWallet","onError",n6.a.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return vM({appConfig:t,walletIndex:l,chainType:u,user:o,accessToken:e,proxy:r,refreshSessionAndUser:a,privy:n,recoverEmbeddedWallet:s,setUser:h})},Ie=async({emitPrivyEvent:e,setModalData:t,openModal:n,chainType:i})=>new Promise((r,a)=>{t({createWallet:{onSuccess:({user:t,account:n})=>{e("createWallet","onSuccess",{wallet:n}),r({user:t,account:n})},onFailure:t=>{e("createWallet","onError",n6.a.UNKNOWN_EMBEDDED_WALLET_ERROR),a(t)},callAuthOnSuccessOnClose:!1,shouldCreateEth:"ethereum"===i,shouldCreateSol:"solana"===i}}),n(xb)}),It=()=>{let e=yK(),t=fp(),{setModalData:n}=yQ(),{getAccessToken:i}=(0,ic.u)(),{initializeWalletProxy:r,recoverEmbeddedWallet:a,setUser:s,openModal:o,refreshSessionAndUser:l,privy:c}=(0,n8.u)();return{create:async({chainType:d,options:u,latestUser:h})=>{let p=h;if(p||(p=await l()),!p)throw t("createWallet","onError",n6.a.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return await (async({appConfig:e,getAccessToken:t,initializeWalletProxy:n,user:i,privy:r,emitPrivyEvent:a,recoverEmbeddedWallet:s,setModalData:o,openModal:l,setUser:c,options:d,timeoutDuration:u,refreshSessionAndUser:h,chainType:p})=>{let[m,y]=await Promise.all([n(u),t()]);if(!y||!i)throw a("createWallet","onError",n6.a.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");if(!m&&e.customAuth?.enabled)throw a("createWallet","onError",n6.a.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(d&&"walletIndex"in d&&"number"==typeof d.walletIndex){if("user-controlled-server-wallets-only"===e.embeddedWallets.mode)throw a("createWallet","onError",n6.a.INVALID_DATA),Error("Invalid input, use `createAdditional` instead of `walletIndex` to create additional wallets.");return C9({accessToken:y,appConfig:e,privy:r,emitPrivyEvent:a,openModal:l,proxy:m,refreshSessionAndUser:h,recoverEmbeddedWallet:s,setModalData:o,user:i,walletIndex:d.walletIndex,chainType:p,setUser:c})}let f=d&&"createAdditional"in d&&d.createAdditional,g=vR(i,{chainType:p});if(g[0]&&!f)throw a("createWallet","onError",n6.a.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");return C9({accessToken:y,appConfig:e,privy:r,emitPrivyEvent:a,openModal:l,proxy:m,recoverEmbeddedWallet:s,setModalData:o,user:i,walletIndex:(g.reduce((e,t)=>!e||e.walletIndex<t.walletIndex?t:e,null)?.walletIndex??-1)+1,chainType:p,refreshSessionAndUser:h,setUser:c})})({appConfig:e,privy:c,getAccessToken:i,refreshSessionAndUser:l,initializeWalletProxy:r,user:p,emitPrivyEvent:t,recoverEmbeddedWallet:a,setModalData:n,openModal:o,setUser:s,options:u,timeoutDuration:3e4,chainType:d})}}},In=()=>{let{importWallet:e}=(()=>{let{getAccessToken:e,user:t}=(0,ic.u)(),{refreshSessionAndUser:n,initializeWalletProxy:i}=(0,n8.u)(),r=fp();return{importWallet:(0,m.useCallback)(({privateKey:a})=>C6({getAccessToken:e,user:t,initializeWalletProxy:i,refreshSessionAndUser:n,emitPrivyEvent:r},{privateKey:a,chainType:"ethereum"}),[t,e,n,i,r])}})(),{createWallet:t}=function(e){let{create:t}=It();return fu("createWallet",void 0),{createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let{account:n}=await t({chainType:"ethereum",options:e});return n}}}();return{...(0,m.useContext)(ic.P),importWallet:e,createWallet:t}},Ii=e=>e.filter(e=>"wallets"===e.method||("exchange"===e.method?"coinbase"===e.provider:"card"===e.method||"payment-request"===e.method?"coinbase"===e.provider||"moonpay"===e.provider:(e.method,!1))),Ir=e=>!!e.fundingConfig&&Ii(e.fundingConfig.options).length>=1,Ia=({children:e,theme:t})=>(0,h.jsxs)(Is,{$theme:t,children:[(0,h.jsx)(iA.A,{width:"3rem",color:"var(--privy-color-error)"}),e]}),Is=ig.I4.div.withConfig({displayName:"Container",componentId:"sc-5400b18f-0"})(["display:flex;gap:0.5rem;"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.75rem;font-weight:400;line-height:1.125rem;padding:0.5rem 0.75rem;&&{border:1px solid var(--privy-color-error);border-radius:var(--privy-border-radius-sm);}"],e=>"dark"===e.$theme?"color: var(--privy-color-error);":"background-color: var(--privy-color-error-light);"),Io=e=>(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 210.2",xmlSpace:"preserve",...e,children:(0,h.jsx)("path",{d:"M93.6,27.1C87.6,34.2,78,39.8,68.4,39c-1.2-9.6,3.5-19.8,9-26.1c6-7.3,16.5-12.5,25-12.9  C103.4,10,99.5,19.8,93.6,27.1 M102.3,40.9c-13.9-0.8-25.8,7.9-32.4,7.9c-6.7,0-16.8-7.5-27.8-7.3c-14.3,0.2-27.6,8.3-34.9,21.2  c-15,25.8-3.9,64,10.6,85c7.1,10.4,15.6,21.8,26.8,21.4c10.6-0.4,14.8-6.9,27.6-6.9c12.9,0,16.6,6.9,27.8,6.7  c11.6-0.2,18.9-10.4,26-20.8c8.1-11.8,11.4-23.3,11.6-23.9c-0.2-0.2-22.4-8.7-22.6-34.3c-0.2-21.4,17.5-31.6,18.3-32.2  C123.3,42.9,107.7,41.3,102.3,40.9 M182.6,11.9v155.9h24.2v-53.3h33.5c30.6,0,52.1-21,52.1-51.4c0-30.4-21.1-51.2-51.3-51.2H182.6z   M206.8,32.3h27.9c21,0,33,11.2,33,30.9c0,19.7-12,31-33.1,31h-27.8V32.3z M336.6,169c15.2,0,29.3-7.7,35.7-19.9h0.5v18.7h22.4V90.2  c0-22.5-18-37-45.7-37c-25.7,0-44.7,14.7-45.4,34.9h21.8c1.8-9.6,10.7-15.9,22.9-15.9c14.8,0,23.1,6.9,23.1,19.6v8.6l-30.2,1.8  c-28.1,1.7-43.3,13.2-43.3,33.2C298.4,155.6,314.1,169,336.6,169z M343.1,150.5c-12.9,0-21.1-6.2-21.1-15.7c0-9.8,7.9-15.5,23-16.4  l26.9-1.7v8.8C371.9,140.1,359.5,150.5,343.1,150.5z M425.1,210.2c23.6,0,34.7-9,44.4-36.3L512,54.7h-24.6l-28.5,92.1h-0.5  l-28.5-92.1h-25.3l41,113.5l-2.2,6.9c-3.7,11.7-9.7,
5816.2-20.4,16.2c-1.9,0-5.6-0.2-7.1-0.4v18.7C417.3,210,423.3,210.2,425.1,210.2z"})}),Il=e=>(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 38.1",xmlSpace:"preserve",...e,children:[(0,h.jsx)("path",{style:{fill:"#5F6368"},d:"M37.8,19.7V29h-3V6h7.8c1.9,0,3.7,0.7,5.1,2c1.4,1.2,2.1,3,2.1,4.9c0,1.9-0.7,3.6-2.1,4.9c-1.4,1.3-3.1,2-5.1,2  L37.8,19.7L37.8,19.7z M37.8,8.8v8h5c1.1,0,2.2-0.4,2.9-1.2c1.6-1.5,1.6-4,0.1-5.5c0,0-0.1-0.1-0.1-0.1c-0.8-0.8-1.8-1.3-2.9-1.2  L37.8,8.8L37.8,8.8z"}),(0,h.jsx)("path",{style:{fill:"#5F6368"},d:"M56.7,12.8c2.2,0,3.9,0.6,5.2,1.8s1.9,2.8,1.9,4.8V29H61v-2.2h-0.1c-1.2,1.8-2.9,2.7-4.9,2.7  c-1.7,0-3.2-0.5-4.4-1.5c-1.1-1-1.8-2.4-1.8-3.9c0-1.6,0.6-2.9,1.8-3.9c1.2-1,2.9-1.4,4.9-1.4c1.8,0,3.2,0.3,4.3,1v-0.7  c0-1-0.4-2-1.2-2.6c-0.8-0.7-1.8-1.1-2.9-1.1c-1.7,0-3,0.7-3.9,2.1l-2.6-1.6C51.8,13.8,53.9,12.8,56.7,12.8z M52.9,24.2  c0,0.8,0.4,1.5,1,1.9c0.7,0.5,1.5,0.8,2.3,0.8c1.2,0,2.4-0.5,3.3-1.4c1-0.9,1.5-2,1.5-3.2c-0.9-0.7-2.2-1.1-3.9-1.1  c-1.2,0-2.2,0.3-3,0.9C53.3,22.6,52.9,23.3,52.9,24.2z"}),(0,h.jsx)("path",{style:{fill:"#5F6368"},d:"M80,13.3l-9.9,22.7h-3l3.7-7.9l-6.5-14.7h3.2l4.7,11.3h0.1l4.6-11.3H80z"}),(0,h.jsx)("path",{style:{fill:"#4285F4"},d:"M25.9,17.7c0-0.9-0.1-1.8-0.2-2.7H13.2v5.1h7.1c-0.3,1.6-1.2,3.1-2.6,4v3.3H22C24.5,25.1,25.9,21.7,25.9,17.7z"}),(0,h.jsx)("path",{style:{fill:"#34A853"},d:"M13.2,30.6c3.6,0,6.6-1.2,8.8-3.2l-4.3-3.3c-1.2,0.8-2.7,1.3-4.5,1.3c-3.4,0-6.4-2.3-7.4-5.5H1.4v3.4  C3.7,27.8,8.2,30.6,13.2,30.6z"}),(0,h.jsx)("path",{style:{fill:"#FBBC04"},d:"M5.8,19.9c-0.6-1.6-0.6-3.4,0-5.1v-3.4H1.4c-1.9,3.7-1.9,8.1,0,11.9L5.8,19.9z"}),(0,h.jsx)("path",{style:{fill:"#EA4335"},d:"M13.2,9.4c1.9,0,3.7,0.7,5.1,2l0,0l3.8-3.8c-2.4-2.2-5.6-3.5-8.8-3.4c-5,0-9.6,2.8-11.8,7.3l4.4,3.4  C6.8,11.7,9.8,9.4,13.2,9.4z"})]}),Ic=e=>{let[t,n]=(0,m.useState)();return(0,m.useEffect)(()=>{e().then(e=>{n(e)}).catch(()=>{})},[]),t},Id=({...e})=>(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[(0,h.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,h.jsx)("path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2"}),(0,h.jsx)("path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21"})]}),Iu=async({address:e,chain:t,rpcConfig:n,privyAppId:i})=>{try{let r=(0,n7.l)({chain:t,transport:(0,n9.L)(pF(t,n,i))}),[a,s]=await Promise.all([r.readContract({abi:Ih,address:e,functionName:"symbol"}),r.readContract({abi:Ih,address:e,functionName:"decimals"})]);return{decimals:s,symbol:a}}catch(e){return console.log(e),null}},Ih=[{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}],Ip=({size:e})=>(0,h.jsx)(Im,{$size:e,children:(0,h.jsxs)(Iy,{children:[(0,h.jsx)(If,{}),(0,h.jsx)(Ig,{})]})}),Im=ig.I4.div.withConfig({displayName:"LoadingContainer",componentId:"sc-3ddaba1c-0"})(["--spinner-size:",";display:flex;justify-content:center;align-items:center;flex-grow:1;@media all and (display-mode:standalone){margin-bottom:30px;}"],e=>e.$size?e.$size:"96px"),Iy=ig.I4.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-3ddaba1c-1"})(["position:relative;height:var(--spinner-size);width:var(--spinner-size);opacity:1;animation:fadein 200ms ease;"]),If=ig.I4.div.withConfig({displayName:"CircleFixed",componentId:"sc-3ddaba1c-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);&&{border:4px solid #f1f2f9;border-radius:50%;}"]),Ig=ig.I4.div.withConfig({displayName:"CircleRotate",componentId:"sc-3ddaba1c-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:#cbcde1 transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]),Iw=ig.I4.span.withConfig({displayName:"Rows",componentId:"sc-b764aab6-0"})(["display:flex;flex-direction:column;gap:0.35rem;width:100%;"]),Iv=ig.I4.span.withConfig({displayName:"Row",componentId:"sc-b764aab6-1"})(["display:flex;width:100%;justify-content:space-between;gap:0.5rem;"]),Ib=ig.I4.span.withConfig({displayName:"LabelSm",componentId:"sc-6c002d6-0"})(["color:var(--privy-color-foreground-3);font-size:0.875rem;font-weight:400;line-height:1.375rem;"]),Ix=(0,ig.I4)(Ib).withConfig({displayName:"LabelSmPrimary",componentId:"sc-6c002d6-1"})(["color:var(--privy-color-accent);"]),I_=ig.I4.span.withConfig({displayName:"Value",componentId:"sc-72aa026-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;",""],xS),IC=e=>(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",version:"1.1",id:"Layer_1",x:"0px",y:"0px",viewBox:"0 0 397.7 311.7",enableBackgroun
58d:"new 0 0 397.7 311.7",xmlSpace:"preserve",...e,children:[(0,h.jsxs)("linearGradient",{id:"SVGID_1_",gradientUnits:"userSpaceOnUse",x1:"360.8791",y1:"351.4553",x2:"141.213",y2:"-69.2936",gradientTransform:"matrix(1 0 0 -1 0 314)",children:[(0,h.jsx)("stop",{offset:"0",stopColor:"#00FFA3"}),(0,h.jsx)("stop",{offset:"1",stopColor:"#DC1FFF"})]}),(0,h.jsx)("path",{d:"M64.6,237.9c2.4-2.4,5.7-3.8,9.2-3.8h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5  c-5.8,0-8.7-7-4.6-11.1L64.6,237.9z",fill:"url(#SVGID_1_)"}),(0,h.jsxs)("linearGradient",{id:"SVGID_2_",gradientUnits:"userSpaceOnUse",x1:"264.8291",y1:"401.6014",x2:"45.163",y2:"-19.1475",gradientTransform:"matrix(1 0 0 -1 0 314)",children:[(0,h.jsx)("stop",{offset:"0",stopColor:"#00FFA3"}),(0,h.jsx)("stop",{offset:"1",stopColor:"#DC1FFF"})]}),(0,h.jsx)("path",{d:"M64.6,3.8C67.1,1.4,70.4,0,73.8,0h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5  c-5.8,0-8.7-7-4.6-11.1L64.6,3.8z",fill:"url(#SVGID_2_)"}),(0,h.jsxs)("linearGradient",{id:"SVGID_3_",gradientUnits:"userSpaceOnUse",x1:"312.5484",y1:"376.688",x2:"92.8822",y2:"-44.061",gradientTransform:"matrix(1 0 0 -1 0 314)",children:[(0,h.jsx)("stop",{offset:"0",stopColor:"#00FFA3"}),(0,h.jsx)("stop",{offset:"1",stopColor:"#DC1FFF"})]}),(0,h.jsx)("path",{d:"M333.1,120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8,0-8.7,7-4.6,11.1l62.7,62.7c2.4,2.4,5.7,3.8,9.2,3.8h317.4  c5.8,0,8.7-7,4.6-11.1L333.1,120.1z",fill:"url(#SVGID_3_)"})]}),II={[J.D.id]:e=>(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",version:"1.1",id:"Layer_1",x:"0px",y:"0px",viewBox:"0 0 2500 2500",xmlSpace:"preserve",...e,children:(0,h.jsx)("g",{id:"Layer_x0020_1",children:(0,h.jsxs)("g",{id:"_2405588477232",children:[(0,h.jsx)("rect",{fill:"none",width:"2500",height:"2500"}),(0,h.jsx)("g",{children:(0,h.jsxs)("g",{children:[(0,h.jsx)("path",{fill:"#213147",d:"M226,760v980c0,63,33,120,88,152l849,490c54,31,121,31,175,0l849-490c54-31,88-89,88-152V760      c0-63-33-120-88-152l-849-490c-54-31-121-31-175,0L314,608c-54,31-87,89-87,152H226z"}),(0,h.jsx)("g",{children:(0,h.jsxs)("g",{children:[(0,h.jsx)("g",{children:(0,h.jsx)("path",{fill:"#12AAFF",d:"M1435,1440l-121,332c-3,9-3,19,0,29l208,571l241-139l-289-793C1467,1422,1442,1422,1435,1440z"})}),(0,h.jsx)("g",{children:(0,h.jsx)("path",{fill:"#12AAFF",d:"M1678,882c-7-18-32-18-39,0l-121,332c-3,9-3,19,0,29l341,935l241-139L1678,883V882z"})})]})}),(0,h.jsx)("g",{children:(0,h.jsx)("path",{fill:"#9DCCED",d:"M1250,155c6,0,12,2,17,5l918,530c11,6,17,18,17,30v1060c0,12-7,24-17,30l-918,530c-5,3-11,5-17,5       s-12-2-17-5l-918-530c-11-6-17-18-17-30V719c0-12,7-24,17-30l918-530c5-3,11-5,17-5l0,0V155z M1250,0c-33,0-65,8-95,25L237,555       c-59,34-95,96-95,164v1060c0,68,36,130,95,164l918,530c29,17,62,25,95,25s65-8,95-25l918-530c59-34,95-96,95-164V719       c0-68-36-130-95-164L1344,25c-29-17-62-25-95-25l0,0H1250z"})}),(0,h.jsx)("polygon",{fill:"#213147",points:"642,2179 727,1947 897,2088 738,2234     "}),(0,h.jsxs)("g",{children:[(0,h.jsx)("path",{fill:"#FFFFFF",d:"M1172,644H939c-17,0-33,11-39,27L401,2039l241,139l550-1507c5-14-5-28-19-28L1172,644z"}),(0,h.jsx)("path",{fill:"#FFFFFF",d:"M1580,644h-233c-17,0-33,11-39,27L738,2233l241,139l620-1701c5-14-5-28-19-28V644z"})]})]})})]})})}),[Z.m.id]:e=>(0,h.jsxs)("svg",{width:"1503",height:"1504",viewBox:"0 0 1503 1504",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,h.jsx)("rect",{x:"287",y:"258",width:"928",height:"844",fill:"white"}),(0,h.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1502.5 752C1502.5 1166.77 1166.27 1503 751.5 1503C336.734 1503 0.5 1166.77 0.5 752C0.5 337.234 336.734 1 751.5 1C1166.27 1 1502.5 337.234 1502.5 752ZM538.688 1050.86H392.94C362.314 1050.86 347.186 1050.86 337.962 1044.96C327.999 1038.5 321.911 1027.8 321.173 1015.99C320.619 1005.11 328.184 991.822 343.312 965.255L703.182 330.935C718.495 303.999 726.243 290.531 736.021 285.55C746.537 280.2 759.083 280.2 769.599 285.55C779.377 290.531 787.126 303.999 802.438 330.935L876.42 460.079L876.797 460.738C893.336 489.635 901.723 504.289 905.385 519.669C909.443 536.458 909.443 554.169 905.385 570.958C901.695 586.455 893.393 601.215 876.604 630.549L687.573 964.702L687.084 965.558C670.436 994.693 661.999 1009.46 650.306 1020.6C637.576 1032.78 622.263 1041.63 605.474 1046.62C590.161 1050.86 573.004 1050.86 538.688 1050.86ZM906.75 1050.86H1115.59C1146.4 1050.86 1161.9 1050.86 1171.13 1044.78C1181.09 1038.32 1187.36 1027.43 1187.92 1015.63C1188.45 1005.1 1181.05 992.33 1166.55 967.307C1166.05 966.455 1165.55 965.588 1165.04 964.706L1060.43 785.75L1059.24 783.735C1044.54 758.877 1037.12 746.324 1027.59 741.472C1017.08 736.121 1004.71 736.121 994.199 741.472C984.605 746.453 976.857 759.552 961.544 785.934L857.306 964.891L856.949 965.507C841.69 991.847 834.064 1005.01 834.614 1015.81C835.352 1027.62 841.44 1038.5 851.402 1044.96C860.443 1050.86 875.94 1050.86 906.75 1050.86Z",fill:"#E84142"})]}),[Y.E.id]:e=>(0,h.jsxs)("svg",{width:"146",height:"146",viewBox:"0 0 146 146",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,h.jsx)("circle",{cx:"73",cy:"73",r:"73",fill:"#0052FF"}),(0,h.jsx)("path",{d:"M73.323 123.729C101.617 123.729 124.553 100.832 124.553 72.5875C124.553 44.343 101.617 21.4463 73.323 21.4463C46.4795 21.4463 24.4581 42.0558 22.271 68.2887H89.9859V76.8864H22.271C24.4581 103.119 46.4795 123.729 73.323 123.729Z",fill:"white"})]}),[Q.A.id]:e=>(0,h.jsxs)("svg",{fill:"none",height:"400",viewBox:"0 0 400 400",width:"400",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,h.jsx)("path",{d:"m0 0h400v400h-400z",fill:"#fcff52"}),(0,h.jsx)("path",{d:"m300 100h-200v200h199.996v-69.813h-33.191c-11.442 25.468-37.194 43.206-66.665 43.206-40.63 0-73.533-33.187-73.533-73.533s32.903-73.249 73.533-73.249c30.043 0 55.795 18.313 67.24 44.349h32.62z",fill:"#000"})]}),[X._.id]:e=>(0,h.jsxs)("svg",{width:"200",height:"208",viewBox:"0 0 200 208",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,h.jsx)("rect",{width:"199.4",height:"207.623",fill:"#121212"}),(0,h.jsxs)("g",{"clip-path":"url(#clip0_2303_643)",children:[(0,h.jsx)("path",{d:"M132.369 155.99H49.7001V68.8854H68.6148V139.109H132.369V155.981V155.99Z",fill:"white"}),(0,h.jsx)("path",{d:"M132.369 85.7575C141.687 85.7575 149.241 78.2036 149.241 68.8855C149.241 59.5673 141.687 52.0134 132.369 52.0134C123.05 52.0134 115.497 59.5673 115.497 68.8855C115.497 78.2036 123.05 85.7575 132.369 85.7575Z",fill:"white"})]}),(0,h.jsx)("defs",{children:(0,h.jsx)("clipPath",{id:"clip0_2303_643",children:(0,h.jsx)("rect",{width:"99.5407",height:"103.977",fill:"white",transform:"translate(49.7001 52.0134)"})})})]}),[U.r.id]:e=>(0,h.jsxs)("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 327.5 533.3",enableBackgroun
58d:"new 0 0 327.5 533.3;",xmlSpace:"preserve",...e,children:[(0,h.jsx)("path",{fill:"#8492B2",d:"M163.7,197.2V0L0,271.6L163.7,197.2z"}),(0,h.jsx)("path",{fill:"#62688F",d:"M163.7,368.4V197.2L0,271.6L163.7,368.4z M163.7,197.2l163.7,74.4L163.7,0V197.2z"}),(0,h.jsx)("path",{fill:"#454A75",d:"M163.7,197.2v171.2l163.7-96.8L163.7,197.2z"}),(0,h.jsx)("path",{fill:"#8492B2",d:"M163.7,399.4L0,302.7l163.7,230.7V399.4z"}),(0,h.jsx)("path",{fill:"#62688F",d:"M327.5,302.7l-163.8,96.7v134L327.5,302.7z"})]}),[ee.R.id]:e=>(0,h.jsxs)("svg",{width:"500",height:"500",viewBox:"0 0 500 500",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,h.jsx)("circle",{cx:"250",cy:"250",r:"250",fill:"#FF0420"}),(0,h.jsx)("path",{d:"M177.133 316.446C162.247 316.446 150.051 312.943 140.544 305.938C131.162 298.808 126.471 288.676 126.471 275.541C126.471 272.789 126.784 269.411 127.409 265.408C129.036 256.402 131.35 245.581 134.352 232.947C142.858 198.547 164.812 181.347 200.213 181.347C209.845 181.347 218.476 182.973 226.107 186.225C233.738 189.352 239.742 194.106 244.12 200.486C248.498 206.74 250.688 214.246 250.688 223.002C250.688 225.629 250.375 228.944 249.749 232.947C247.873 244.08 245.621 254.901 242.994 265.408C238.616 282.546 231.048 295.368 220.29 303.874C209.532 312.255 195.147 316.446 177.133 316.446ZM179.76 289.426C186.766 289.426 192.707 287.362 197.586 283.234C202.59 279.106 206.155 272.789 208.281 264.283C211.158 252.524 213.348 242.266 214.849 233.51C215.349 230.883 215.599 228.194 215.599 225.441C215.599 214.058 209.657 208.366 197.774 208.366C190.768 208.366 184.764 210.43 179.76 214.558C174.882 218.687 171.379 225.004 169.253 233.51C167.001 241.891 164.749 252.149 162.498 264.283C161.997 266.784 161.747 269.411 161.747 272.163C161.747 283.672 167.752 289.426 179.76 289.426Z",fill:"white"}),(0,h.jsx)("path",{d:"M259.303 314.57C257.927 314.57 256.863 314.132 256.113 313.256C255.487 312.255 255.3 311.13 255.55 309.879L281.444 187.914C281.694 186.538 282.382 185.412 283.508 184.536C284.634 183.661 285.822 183.223 287.073 183.223H336.985C350.87 183.223 362.003 186.1 370.384 191.854C378.891 197.609 383.144 205.927 383.144 216.81C383.144 219.937 382.769 223.19 382.018 226.567C378.891 240.953 372.574 251.586 363.067 258.466C353.685 265.346 340.8 268.786 324.413 268.786H299.082L290.451 309.879C290.2 311.255 289.512 312.38 288.387 313.256C287.261 314.132 286.072 314.57 284.822 314.57H259.303ZM325.727 242.892C330.98 242.892 335.546 241.453 339.424 238.576C343.427 235.699 346.054 231.571 347.305 226.192C347.68 224.065 347.868 222.189 347.868 220.563C347.868 216.935 346.805 214.183 344.678 212.307C342.551 210.305 338.924 209.305 333.795 209.305H311.278L304.148 242.892H325.727Z",fill:"white"})]}),[et.n.id]:e=>(0,h.jsxs)("svg",{width:"360",height:"360",viewBox:"0 0 360 360",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,h.jsx)("rect",{width:"360",height:"360",rx:"180",fill:"#6C00F6"}),(0,h.jsx)("path",{d:"M157.743 154.241L141.052 144.58L90.9766 173.561V231.519L141.052 260.5L191.13 231.519V141.359L218.948 125.26L246.77 141.359V173.561L218.948 189.66L202.257 180.002V205.759L218.948 215.42L269.024 186.439V128.481L218.948 99.5L168.873 128.481V218.641L141.052 234.74L113.233 218.641V186.439L141.052 170.34L157.743 179.998V154.241Z",fill:"white"})]}),[en.L.id]:e=>(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"30",height:"30",viewBox:"0 0 30 30",fill:"none",...e,children:[(0,h.jsx)("g",{clipPath:"url(#clip0)",children:(0,h.jsx)("g",{clipPath:"url(#clip1)",children:(0,h.jsx)("path",{d:"M14.9188 29.8373C6.67944 29.8373 0.00012207 23.1581 0.00012207 14.9187C0.00012207 6.67931 6.67944 0 14.9188 0C23.1581 0 29.8373 6.67931 29.8373 14.9187C29.8373 23.1581 23.1581 29.8373 14.9188 29.8373Z",fill:"url(#paint0)"})})}),(0,h.jsxs)("defs",{children:[(0,h.jsxs)("radialGradient",{id:"paint0",cx:"0",cy:"0",r:"1",gradientUnits:"userSpaceOnUse",gradientTransform:"translate(21.6921 8.02215) rotate(180) scale(25.2008)",children:[(0,h.jsx)("stop",{offset:"0.00682297",stopColor:"#F2CEFE"}),(0,h.jsx)("stop",{offset:"0.1913",stopColor:"#AFBAF1"}),(0,h.jsx)("stop",{offset:"0.4982",stopColor:"#4281D3"}),(0,h.jsx)("stop",{offset:"0.666667",stopColor:"#2E427D"}),(0,h.jsx)("stop",{offset:"0.822917",stopColor:"#230101"}),(0,h.jsx)("stop",{offset:"1",stopColor:"#8F6B40"})]}),(0,h.jsx)("clipPath",{id:"clip0",children:(0,h.jsx)("rect",{width:"30",height:"30",fill:"white"})}),(0,h.jsx)("clipPath",{id:"clip1",children:(0,h.jsx)("rect",{width:"30",height:"30",fill:"white"})})]})]})},IE=({chainId:e,...t})=>
58{if("solana"===e)return(0,h.jsx)(IC,{...t});let n=II[e];return(0,h.jsx)(n||pp.A,{...t})},IT=({wallet:e,displayName:t,addressToFund:n,chainId:i,chainName:r,isBridging:a,isErc20Flow:s,totalPriceInNativeCurrency:o,totalPriceInUsd:l,gasPriceInNativeCurrency:c,gasPriceInUsd:d})=>{let u=yO(e.walletClientType);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(Ip,{}),(0,h.jsx)(gZ,{style:{marginTop:"16px"},children:(0,h.jsx)(__,{icon:u?.image_url?.md,name:e.walletClientType})}),(0,h.jsx)(vT,{style:{marginTop:"8px",marginBottom:"12px"},title:`${a?"Bridging":"Confirming"} with ${t}`}),!a&&!s&&(0,h.jsxs)(Iw,{children:[(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Total"}),(0,h.jsx)(I_,{children:l||o})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"To"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:n,showCopyIcon:!1})})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Network"}),(0,h.jsx)(I_,{children:(0,h.jsxs)(IA,{children:[(0,h.jsx)(IE,{chainId:i,height:16,width:16})," ",r]})})]}),c&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Estimated fee"}),(0,h.jsx)(I_,{children:d||c})]})]}),(0,h.jsx)(g6,{height:24}),(0,h.jsx)(fk,{})]})},IA=ig.I4.div.withConfig({displayName:"NetworkColumn",componentId:"sc-ec6320ce-0"})(["display:flex;flex-direction:row;align-items:center;gap:4px;"]),IS={component:()=>{let{closePrivyModal:e,createAnalyticsEvent:t}=(0,n8.u)(),{navigate:n,setModalData:i,app:r,data:a}=yQ(),{wallets:s}=TS(),o=_A(),[l,c]=(0,m.useState)(0n),[d,u]=(0,m.useState)(null),[p,y]=(0,m.useState)(!1),[f,g]=(0,m.useState)(!1),w=(0,m.useRef)(!1);if(!a?.funding||"solana"!==a.funding.chainType)throw Error("Invalid funding data");let{address:v,amount:b,cluster:x,connectedWalletAddress:_}=a.funding,C=function({name:e,rpcUrl:t}){if(t)return t;switch(e){case"mainnet-beta":return"https://api.mainnet-beta.solana.com";case"testnet":return"https://api.testnet.solana.com";case"devnet":return"https://api.devnet.solana.com"}}(x),{tokenPrice:I}=wI("solana"),{fundingAmountInBaseUnit:E,totalPriceInUsd:T,totalPriceInNativeCurrency:A,feePriceInNativeCurrency:S,feePriceInUsd:k}=gk({amount:b,fee:l,tokenPrice:I,isUsdc:a.funding.isUSDC}),P=_?s.find(({address:e})=>e===_):s[0],j=yO(P?.walletClientType||"unknown"),O=j?.name||"wallet";return(0,m.useEffect)(()=>{(async()=>{if("solana"===P?.type&&P.sendTransaction&&!p&&!w.current){w.current=!0;try{let e=o(C5);if(!e)throw new n6.P("Unable to load solana plugin");let{connection:n,transaction:i}=a.funding?.isUSDC?await e.createSplTransferTransaction({from:P.address,to:v,amount:E,mintAddress:ed[x.name],cluster:x}):await e.createTransferTransaction({from:P.address,to:v,amount:E,cluster:x}),r=await i.getEstimatedFee(n);null!=r&&c(BigInt(r)),y(!0);let s=await n.simulateTransaction(i);if(s.value.err)return s.value.logs?.find(e=>/insufficient (lamports|funds)/gi.test(e))?void u(new n6.P(`Wallet ${p$(P.address,void 0,void 0,"solana")} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",s.value.err),void u(new n6.P("Something went wrong",void 0,n6.a.TRANSACTION_FAILURE)));let l=await P.sendTransaction(i,n),{value:d,token:h}=a.funding?.isUSDC?{value:(0,eh.J)(E,6),token:"USDC"}:{value:(0,eh.J)(E,9),token:"SOL"};t({eventName:C2,payload:{provider:"external",status:"success",txHash:l,rpcEndpoint:C,address:P.address,value:d,chainType:"solana",clusterName:x.name,token:h,destinationAddress:v,destinationValue:d,destinationChainType:"solana",destinationClusterName:x.name,destinationToken:h}}),y(!1),g(!0)}catch(e){if(console.error(e),y(!1),/user rejected the request/gi.test(e.message||""))return void u(new n6.P("Transaction was rejected by the user",void 0,n6.a.TRANSACTION_FAILURE));u(new n6.P("Something went wrong",void 0,n6.a.TRANSACTION_FAILURE))}}})().catch(console.error).finally(()=>w.current=!1)},[]),(0,m.useEffect)(()=>{d&&(i({funding:a?.funding,sendTransaction:a?.sendTransaction,errorModalData:{error:d,previousScreen:Eu}}),n(b6,!1))},[d]),(0,m.useEffect)(()=>{if(!f)return;let t=setTimeout(e,4e3);return()=>clearTimeout(t)},[f]),f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(g3,{}),(0,h.jsxs)(gX,{children:[(0,h.jsx)(pc.A,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),(0,h.jsx)(vT,{title:"Success!",description:`You’ve successfully added ${b} ${a.funding?.isUSDC?"USDC":"SOL"} to your ${r.name} wallet. It may take a minute before the funds are available to use.`})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]}):P&&p?(0,h.jsx)(IT,{wallet:P,displayName:O,addressToFund:v,isBridging:!1,isErc20Flow:!!a.funding?.isUSDC,totalPriceInUsd:T,totalPriceInNativeCurrency:A,gasPriceInUsd:k,gasPriceInNativeCurrency:S,chainId:"solana",chainName:x.name}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(Ip,{}),(0,h.jsx)("div",{style:{marginTop:"1rem"}}),(0,h.jsx)(fk,{})]})}},Ik=[{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],IP=2n**256n-1n,Ij=({amount:e,decimals:t})=>e===IP?"Maximum":Intl.NumberFormat(void 0,{maximumFractionDigits:t}).format(Number(e)/10**t),IO=({chains:e,appId:t,address:n,rpcConfig:i,includeUsdc:r})=>Promise.all(e.map(async e=>{let a=(0,n7.l)({chain:e,transport:(0,n9.L)(pF(e,i,t))}),s=await a.getBalance({address:n}).catch(()=>0n),o=null,l=ec[e.id];if(r&&l){let{balance:r}=await C3({address:n,chain:e,rpcConfig:i,appId:t,erc20Address:l});o=r}return{balance:s,erc20Balance:o,erc20Address:l,chain:e}})),IN=({balance:e,className:t,chain:n})=>(0,h.jsx)(CX,{className:t,$state:void 0,children:(0,h.jsx)(IR,{balance:e,chain:n})}),IR=({balance:e,chain:t})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(IM,{children:[(0,h.jsx)(IU,{chainId:"id"in t?t.id:"solana"}),(0,h.jsx)(I_,{children:t.name})]}),(0,h.jsxs)(xk,{isLoading:!1,isPulsing:!1,color:"gray",children:[(0,h.jsx)(ID,{children:(0,h.jsx)(hQ.A,{})}),e]})]}),IM=ig.I4.div.withConfig({displayName:"Container",componentId:"sc-d24ae982-0"})(["display:flex;align-items:center;"]),ID=ig.I4.div.withConfig({displayName:"IconContainer",componentId:"sc-d24ae982-1"}
58)(["height:0.75rem;width:0.75rem;margin-right:0.2rem;"]),IU=(0,ig.I4)(IE).withConfig({displayName:"StyledNetworkIcon",componentId:"sc-d24ae982-2"})(["height:1.25rem;width:1.25rem;display:inline-block;margin-right:0.5rem;border-radius:4px;"]),IL=({options:e,onSelect:t,selected:n,className:i})=>(0,h.jsxs)(ij.W1,{as:IF,children:[(0,h.jsxs)(ij.IU,{as:Iz,children:[(0,h.jsx)(IR,{balance:n.balance,chain:n.chain}),(0,h.jsx)(IB,{height:16})]}),(0,h.jsx)(ij.c,{as:IW,className:i,children:e.map((e,n)=>(0,h.jsx)(ij.Dr,{as:I$,onClick:()=>t(n),children:(0,h.jsx)(IR,{balance:e.balance,chain:e.chain})},n))})]}),IF=ig.I4.div.withConfig({displayName:"Wrapper",componentId:"sc-31c00f79-0"})(["width:100%;position:relative;"]),IW=ig.I4.div.withConfig({displayName:"Popover",componentId:"sc-31c00f79-1"})(["width:100%;margin-top:0.5rem;position:absolute;background-color:var(--privy-color-background);border-radius:var(--privy-border-radius-md);overflow-x:hidden;overflow-y:auto;box-shadow:0px 1px 2px 0px rgba(16,24,40,0.05);max-height:11.75rem;&&{border:solid 1px var(--privy-color-foreground-4);}z-index:1;"]),I$=ig.I4.button.withConfig({displayName:"Button",componentId:"sc-31c00f79-2"})(["width:100%;display:flex;justify-content:space-between;&&{padding:1rem;}:not(:last-child){border-bottom:solid 1px var(--privy-color-foreground-4);}:hover{background:var(--privy-color-background-2);}"]),IB=(0,ig.I4)(iS.A).withConfig({displayName:"StyledChevronIcon",componentId:"sc-31c00f79-3"})(["height:1rem;margin-left:0.5rem;"]),Iz=ig.I4.button.withConfig({displayName:"StyledMenuButton",componentId:"sc-31c00f79-4"})([""," span{margin-left:auto;}","{transition:rotate 100ms ease-in;}&[aria-expanded='true']{","{rotate:-180deg;}}"],CQ,IB,IB),Iq=({passkeys:e,expanded:t,onUnlink:n,onExpand:i})=>{let[r,a]=(0,m.useState)([]),s=t?e.length:2;return(0,h.jsxs)("div",{children:[(0,h.jsx)(I1,{children:"Your passkeys"}),(0,h.jsxs)(IY,{children:[e.slice(0,s).map(e=>(0,h.jsxs)(I4,{children:[(0,h.jsxs)("div",{children:[(0,h.jsx)(I2,{children:(e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device")(e)}),(0,h.jsxs)(I3,{children:["Last used: ",(e.latestVerifiedAt??e.verifiedAt).toLocaleString()]})]}),(0,h.jsx)(I6,{disabled:r.includes(e.credentialId),onClick:()=>(async e=>{a(t=>t.concat([e])),await n(e),a(t=>t.filter(t=>t!==e))})(e.credentialId),children:r.includes(e.credentialId)?(0,h.jsx)(f9,{}):(0,h.jsx)(p_.A,{height:"1.6em"})})]},e.credentialId)),e.length>2&&!t&&(0,h.jsx)(IZ,{onClick:i,children:"View all"})]})]})},IV=()=>(0,h.jsxs)(IY,{children:[(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(pC.A,{})}),"Log in with Touch ID, Face ID, or a security key."]}),(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(pl.A,{})}),"More secure than a password."]}),(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(px.A,{})}),"Takes seconds to set up and use."]})]}),IH={component:()=>{let{user:e,unlinkPasskey:t}=(0,ic.u)(),{linkWithPasskey:n,closePrivyModal:i}=(0,n8.u)(),r=e?.linkedAccounts.filter(e=>"passkey"===e.type),[a,s]=(0,m.useState)(!1),[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(!1),[u,p]=(0,m.useState)(!1);(0,m.useEffect)(()=>{0===r.length&&p(!1)},[r.length]);let y=async e=>(s(!0),await t(e).then(()=>d(!0)).catch(e=>{e instanceof n6.y&&e.privyErrorCode===n6.a.MISSING_MFA_CREDENTIALS?l("Cannot unlink a passkey enrolled in MFA"):l("Unknown error occurred.")}).finally(()=>{s(!1)}));return(0,h.jsxs)(h.Fragment,c?{children:[(0,h.jsx)(fR,{onClose:()=>i()},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(pc.A,{})}),(0,h.jsx)(IQ,{style:{marginBottom:"1.5rem"},children:"Passkeys updated"}),(0,h.jsx)(IX,{children:" "}),(0,h.jsx)(fK,{children:(0,h.jsx)(gn,{onClick:()=>i(),children:"Done"})}),(0,h.jsx)(fP,{})]}:u?{children:[(0,h.jsx)(fR,{backFn:()=>p(!1),onClose:()=>i()},"header"),(0,h.jsx)(Iq,{passkeys:r,expanded:u,onUnlink:y,onExpand:()=>p(!0)}),(0,h.jsx)(fP,{})]}:{children:[(0,h.jsx)(fR,{onClose:()=>i()},"header"),(0,h.jsx)(f$,{children:(0,h.jsxs)(IG,{children:[(0,h.jsx)(wj,{}),(0,h.jsx)(_t,{})]})}),(0,h.jsx)(IQ,{children:"Secure your account with a passkey"}),(0,h.jsx)(I0,{}),0===r.length?(0,h.jsx)(IV,{}):(0,h.jsx)(Iq,{passkeys:r,expanded:u,onUnlink:y,onExpand:()=>p(!0)}),(0,h.jsxs)(fK,{style:{marginTop:"12px"},children:[o&&(0,h.jsx)(IK,{$fail:!0,children:o}),(0,h.jsx)(gn,{onClick:()=>{s(!0),n().then(()=>d(!0)).catch(e=>{if(e instanceof n6.y){if(e.privyErrorCode===n6.a.CANNOT_LINK_MORE_OF_TYPE)return void l("Cannot link more passkeys to account.");if(e.privyErrorCode===n6.a.PASSKEY_NOT_ALLOWED)return void l("Passkey request timed out or rejected by user.")}l("Unknown error occurred.")}).finally(()=>{s(!1)})},loading:a,children:"Add new passkey"})]}),(0,h.jsx)(fP,{})]})}},IG=ig.I4.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-d6832d36-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent) !important;stroke:var(--privy-color-accent) !important;
58fill:var(--privy-color-accent) !important;}"]),IK=ig.I4.div.withConfig({displayName:"InputHelp",componentId:"sc-d6832d36-1"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-beginngin;width:100%;"],e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)"),IJ=(0,ig.AH)(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]),IZ=ig.I4.button.withConfig({displayName:"LinkButton",componentId:"sc-d6832d36-2"})(["",""],IJ),IY=ig.I4.div.withConfig({displayName:"List",componentId:"sc-d6832d36-3"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.8rem;padding:0.5rem 0rem 0rem;flex-grow:1;width:100%;"]),IQ=ig.I4.div.withConfig({displayName:"ModalTitle",componentId:"sc-d6832d36-4"})(["font-size:18px;line-height:18px;text-align:center;font-weight:600;"]),IX=ig.I4.div.withConfig({displayName:"ModalSubTitle",componentId:"sc-d6832d36-5"})(["font-size:0.875rem;text-align:center;margin-top:10px;"]),I0=ig.I4.div.withConfig({displayName:"SectionSpacer",componentId:"sc-d6832d36-6"})(["height:32px;"]),I1=ig.I4.div.withConfig({displayName:"PasskeyListTitle",componentId:"sc-d6832d36-7"})(["line-height:20px;height:20px;font-size:1em;font-weight:450;display:flex;justify-content:flex-beginning;width:100%;"]),I2=ig.I4.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-d6832d36-8"})(["font-size:1em;line-height:1.3em;font-weight:500;color:var(--privy-color-foreground-2);padding:0.2em 0;"]),I3=ig.I4.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-d6832d36-9"})(["font-size:0.875rem;line-height:1rem;color:#64668b;padding:0.2em 0;"]),I4=ig.I4.div.withConfig({displayName:"PasskeyListItem",componentId:"sc-d6832d36-10"})(["display:flex;align-items:center;justify-content:space-between;padding:1em;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;border-radius:8px;border:1px solid #e2e3f0 !important;width:100%;height:5em;"]),I5=(0,ig.AH)([":focus,:hover,:active{outline:none;}display:flex;width:2em;height:2em;justify-content:center;align-items:center;svg{color:var(--privy-color-error);}svg:hover{color:var(--privy-color-foreground-3);}"]),I6=ig.I4.button.withConfig({displayName:"PasskeyItemUnlinkButton",componentId:"sc-d6832d36-11"})(["",""],I5),I8=ig.I4.div.withConfig({displayName:"FundingMethodContainer",componentId:"sc-eaaa12a-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),I7=ig.I4.div.withConfig({displayName:"IconContainer",componentId:"sc-eaaa12a-1"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;svg{border-radius:var(--privy-border-radius-sm);}"]),I9=ig.I4.div.withConfig({displayName:"FundingQuantityWrapper",componentId:"sc-eaaa12a-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:8px;"]),Ee=ig.I4.div.withConfig({displayName:"FundingQuantity",componentId:"sc-eaaa12a-3"})(["display:flex;align-items:center;gap:4px;width:100%;padding:0 16px;border-width:1px !important;border-radius:12px;cursor:text;&:focus-within{border-color:var(--privy-color-accent);}"]),Et=ig.I4.input.withConfig({displayName:"FundingAmountInput",componentId:"sc-eaaa12a-5"})(["background-color:var(--privy-color-background);width:100%;&:focus{outline:none !important;border:none !important;box-shadow:none !important;}&&{font-size:26px;}"]),En=(0,ig.I4)(Et).withConfig({displayName:"FundingAmountInputLarge",componentId:"sc-eaaa12a-6"})(["&&{font-size:42px;}"]),Ei=ig.I4.div.withConfig({displayName:"FundingCurrency",componentId:"sc-eaaa12a-8"})(["font-size:18px;"]),Er=ig.I4.div.withConfig({displayName:"FundingDollars",componentId:"sc-eaaa12a-9"})(["font-size:12px;color:var(--privy-color-foreground-3);height:20px;"]),Ea=ig.I4.div.withConfig({displayName:"InfoButtonText",componentId:"sc-eaaa12a-13"})([""]),Es=ig.I4.a.withConfig({displayName:"InfoButtonLink",componentId:"sc-eaaa12a-14"})(["&&{color:var(--privy-color-accent);}cursor:pointer;"]),Eo=({displayName:e,errorMessage:t,configuredFundingChain:n,formattedBalance:i,fundingAmount:r,fundingCurrency:a,fundingAmountInUsd:s,options:o,selectedOption:l,isPreparing:c,isSubmitting:d,addressToFund:u,fundingWalletAddress:p,onSubmit:y,onSelect:f,onAmountChange:g,erc20ContractInfo:w})=>{let v=(0,m.useRef)(null);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(g3,{}),(0,h.jsx)(Cq,{children:"Transfer from another network"}),(0,h.jsxs)(Cz,{children:["You need more funds on the ",n.name," network. Bridge from another blockchain network."]}),(0,h.jsxs)(I9,{style:{marginTop:"2rem"},children:[(0,h.jsxs)(Ee,{onClick:()=>v.current?.focus(),children:[(0,h.jsx)(Et,{ref:v,value:r,onChange:e=>{let t=e.target.value;if(/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1){let e=/\.$/.test(t)?".":"",n=Number(t.replace(/\.$/,"")||"0");if(Number.isNaN(n))return void g("0");g(n.toString()+e)}}}),(0,h.jsx)(Ei,{children:a})]}),s&&(0,h.jsx)(Er,{children:s})]}),(0,h.jsxs)(Iv,{style:{marginTop:"1.5rem"},children:[(0,h.jsx)(Ib,{children:"From"}),(0,h.jsx)(Ib,{children:ep(p)})]}),(0,h.jsx)(IL,{selected:{chain:l.chain,balance:l.isErc20Quote?Ij({amount:l.erc20Balance??0n,decimals:w?.decimals??6})+` ${w?.symbol||""}`:gv(l.balance,l.chain.nativeCurrency.symbol,3,!0)},options:o.map(({chain:e,balance:t,isErc20Quote:n,erc20Balance:i})=>({chain:e,balance:n?Ij({amount:i??0n,decimals:w?.decimals??6})+` ${w?.symbol||""}`:gv(t,e.nativeCurrency.symbol,3,!0)})),onSelect:f}),(0,h.jsxs)(Iv,{style:{marginTop:"1.5rem"},children:[(0,h.jsx)(Ib,{children:"To"}),(0,h.jsx)(Ib,{children:ep(u)})]}),(0,h.jsx)(IN,{chain:n,balance:i}),(0,h.jsx)(Cx,{style:{marginTop:"1rem"},children:t}),(0,h.jsxs)(gi,{style:{marginTop:"1rem"},loading:d||c,disabled:c||d,onClick:y,children:["Confirm with ",e]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})},El={component:()=>{let{rpcConfig:e,appId:t,closePrivyModal:n,createAnalyticsEvent:i}=(0,n8.u)(),{navigate:r,setModalData:a,app:s,data:o}=yQ(),{wallets:l}=wT(),[c,d]=(0,m.useState)(!1),[u,p]=(0,m.useState)(0n),[y,f]=(0,m.useState)(!1),[g,w]=(0,m.useState)(null),[v,b]=(0,m.useState)(null),[x,_]=(0,m.useState)([]),[C,I]=(0,m.useState)(0),[E,T]=(0,m.useState)(!1),[A,S]=(0,m.useState)(!1),[k,P]=(0,m.useState)(!1),[j,O]=(0,m.useState)(!1),[N,R]=(0,m.useState)(),[M,D]=(0,m.useState)();if(!o?.funding||"ethereum"!==o.funding.chainType)throw Error("Invalid funding data");let{erc20ContractInfo:U,chain:F,connectedWalletAddress:W}=o.funding,$=o.funding.address,B=o.funding.erc20Address,[z,q]=(0,m.useState)(o.funding.amount);(0,m.useEffect)(()=>{B&&!U&&w(Error("Unable to fetch token details"))},[]);let V=!!B&&!!U,H=V?BigInt(parseFloat(z)*10**U.decimals):(0,ie.g)(z),G=W?l.find(({address:e})=>e===W):l[0],K=yO(G?.walletClientType||"unknown"),J=K?.name||"wallet",[Z,Y]=(0,m.useState)(null);(0,m.useEffect)(()=>{(async()=>
58{if(!G)return;let e=await G.getEthereumProvider();Y((0,it.F)({account:G.address,transport:(0,ii.I)(e)}).extend(ir.$))})().catch(console.error)},[G]);let[Q,X]=(0,m.useState)(0n);(0,m.useEffect)(()=>{(0,n7.l)({chain:F,transport:(0,n9.L)(pF(F,e,t))}).getBalance({address:$}).then(X).catch(console.error)},[]);let[ee,et]=(0,m.useState)(0n);(0,m.useEffect)(()=>{V&&C3({chain:F,address:$,appId:t,rpcConfig:e,erc20Address:B}).then(e=>et(e.balance)).catch(console.error)},[]);let{tokenPrice:en}=wI(F.id),[ei,er]=(0,m.useState)({to:$,chain:F,value:H,data:void 0});(0,m.useEffect)(()=>{(async()=>{let n,r;if(!Z||!G||E||k)return;T(!0);let a=(0,n7.l)({chain:ei.chain,transport:(0,n9.L)(pF(ei.chain,e,t))});if(V&&!ei.data)return await a.simulateContract({address:B,chain:ei.chain,abi:Ik,functionName:"transfer",args:[$,H],account:G.address}).catch(e=>{console.warn("Simulated token transfer failed with error, fetching bridge options.",e)})?(T(!1),void er({to:B,chain:ei.chain,data:(0,ia.p)({abi:Ik,functionName:"transfer",args:[$,H]}),value:"0x0"})):(T(!1),void f(!0));try{n=await a.prepareTransactionRequest({account:G.address,to:ei.to,chain:ei.chain,data:ei.data,value:BigInt(ei.value??0)})}catch(e){if(console.error(e),x.length>1)b(e.shortMessage??"Something went wrong");else if(A&&0===x.length)return void w(new n6.P(`Wallet ${p$(G.address)} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE))}if(!n)return T(!1),void f(!0);T(!1),P(!0),d(!0),p(n.gas);try{await Z.switchChain({id:ei.chain.id})}catch(e){await Z.addChain({chain:ei.chain}),await Z.switchChain({id:ei.chain.id})}try{r=await Z.sendTransaction(n)}catch(e){if(console.error(e),"TransactionExecutionError"===e.name)if(x.length<1){let t=e.shortMessage;(e.shortMessage.includes("rejected the request")||e.details.includes("rejected the request"))&&(t="User rejected the request."),w(new n6.P(t,void 0,n6.a.TRANSACTION_FAILURE))}else b(e.shortMessage??"Something went wrong")}if(r)return await Z.waitForTransactionReceipt({hash:r}),P(!1),A?(R(r),void D("pending")):(O(!0),void i({eventName:C2,payload:{provider:"external",status:"success",txHash:r,address:G.address,chainId:ei.chain.id,chainType:"ethereum",value:ei.value?(0,eh.J)(BigInt(ei.value),U?.decimals??18):void 0,token:U?.symbol??B??"ETH",destinationAddress:$,destinationChainId:F.id,destinationChainType:"ethereum",destinationValue:H?(0,eh.J)(H,U?.decimals??18):void 0,destinationToken:U?.symbol??B??F.nativeCurrency.name}}));P(!1)})().catch(console.error)},[Z,ei]),(0,m.useEffect)(()=>{(async()=>{if(!y||!Z||!G)return;let n=(0,L.u)(s.chains).filter(e=>e.id!==F.id&&!!e.testnet==!!F.testnet);V&&n.unshift(F);let i=await IO({chains:n,address:G.address,appId:t,rpcConfig:e,includeUsdc:o.funding?.isUSDC}),r=V?i.filter(e=>e.balance>0n):i.filter(e=>e.balance>H);if(r.length<1)return void w(new n6.P(`Wallet ${p$(G.address)} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE));r.sort((e,t)=>Number(V?(t.erc20Balance??0n)-(e.erc20Balance??0n):t.balance-e.balance));let a=r.flatMap(e=>{let t=[{...e,isErc20Quote:!1,isTestnet:!!F.testnet,input:bQ({amount:H.toString(),user:G.address,recipient:$,destinationChainId:F.id,destinationCurrency:B,originChainId:e.chain.id})}];return V&&B&&(e.erc20Balance??0n)>=H&&t.push({...e,isErc20Quote:!0,isTestnet:!!F.testnet,input:bQ({amount:H.toString(),user:G.address,recipient:$,destinationChainId:F.id,destinationCurrency:B,originChainId:e.chain.id,originCurrency:e.erc20Address})}),t}),l=(await Promise.allSettled(a.map(async e=>({...e,quote:await b1(e)})))).filter(e=>"fulfilled"===e.status).map(e=>e.value);if(l.length<1)return void w(new n6.P(`Wallet ${p$(G.address)} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE));let c=l.map(e=>({bridgeTx:b2(e.quote),balance:e.balance,chain:e.chain,erc20Balance:e.erc20Balance,isErc20Quote:e.isErc20Quote})).filter(e=>!!e.bridgeTx);if(c.length>1)return void _(c);let d=c[0];d?(S(!0),er({data:d.bridgeTx.data,to:d.bridgeTx.to,value:d.bridgeTx.value,chain:d.chain})):w(new n6.P(`Wallet ${p$(G.address)} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE))})().catch(console.error)},[y]),b3({transactionHash:N,wallet:G,isTestnet:!!F.testnet,bridgingStatus:M,setBridgingStatus:D,onSuccess({transactionHash:e,wallet:t}){S(!1),O(!0),i({eventName:C2,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:ei.chain.id,chainType:"ethereum",value:ei.value?(0,eh.J)(BigInt(ei.value),U?.decimals??18):void 0,token:U?.symbol??B??"ETH",destinationAddress:$,destinationChainId:F.id,destinationChainType:"ethereum",destinationValue:H?(0,eh.J)(H,U?.decimals??18):void 0,destinationToken:U?.symbol??B??F.nativeCurrency.name}})},onFailure({error:e}){S(!1),w(e)}}),(0,m.useEffect)(()=>{g&&(a({funding:o?.funding,sendTransaction:o?.sendTransaction,errorMod
58alData:{error:g,previousScreen:Eu}}),r(b6,!1))},[g]);let ea=!V&&en?gg(z??"0",en):void 0,es=V?u:gx([u,H]),eo=es&&en?gw(es,en):void 0,el=es?gv(es,o?.funding?.erc20Address?o?.funding?.erc20ContractInfo?.symbol||"ETH":o?.funding?.chain.nativeCurrency.symbol||"ETH"):void 0,ec=u&&en?gw(u,en):void 0,ed=u?gv(u,F?.nativeCurrency?.symbol||"ETH"):void 0;if((0,m.useEffect)(()=>{if(!j)return;let e=setTimeout(n,4e3);return()=>clearTimeout(e)},[j]),j)return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(g3,{}),(0,h.jsxs)(gX,{children:[(0,h.jsx)(pc.A,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),(0,h.jsx)(vT,{title:"Success!",description:`You’ve successfully added ${z} ${V?U.symbol:F.nativeCurrency.symbol} to your ${s.name} wallet. It may take a minute before the funds are available to use.`})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]});let eu=V?`${Ij({amount:ee,decimals:U.decimals})}  ${U.symbol}`:gv(Q,F.nativeCurrency.symbol,3,!0),ep=x[C];return x.length>1&&ep?(0,h.jsx)(Eo,{displayName:J,configuredFundingChain:F,erc20ContractInfo:U,formattedBalance:eu,fundingAmount:z,fundingCurrency:V?U.symbol:F.nativeCurrency.symbol,fundingAmountInUsd:ea,options:x,selectedOption:ep,isPreparing:E,isSubmitting:k,addressToFund:$,fundingWalletAddress:G?.address||"",errorMessage:v,onSubmit:()=>{o.funding?.amount!==z?(async function(){if(G&&ep)try{let e=await b1({isTestnet:!!F.testnet,input:bQ({amount:H.toString(),user:G.address,recipient:$,destinationChainId:F.id,destinationCurrency:B,originChainId:ep.chain.id})}),t=b2(e);if(!t)throw Error("Invalid transaction request");S(!0),er({data:t.data,to:t.to,value:t.value,chain:ep.chain})}catch(e){console.error(e),w(new n6.P("Unable to fetch quotes for bridging",e,n6.a.INSUFFICIENT_BALANCE))}})().catch(console.error):er({to:ep.bridgeTx.to,data:ep.bridgeTx.data,value:ep.bridgeTx.value,chain:ep.chain})},onSelect:e=>{e!==C&&(b(null),I(e))},onAmountChange:q}):c&&u&&G&&o?.funding?(0,h.jsx)(IT,{wallet:G,displayName:J,addressToFund:$,isBridging:A,isErc20Flow:V,totalPriceInUsd:eo,totalPriceInNativeCurrency:el,gasPriceInUsd:ec,gasPriceInNativeCurrency:ed,chainId:F.id,chainName:F.name}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(Ip,{}),(0,h.jsx)("div",{style:{marginTop:"1rem"}}),(0,h.jsx)(fk,{})]})}},Ec={component:function(){let{closePrivyModal:e,createAnalyticsEvent:t}=(0,n8.u)(),{navigate:n,setModalData:i,app:r,data:a}=yQ(),{wallets:s}=TS(),o=(0,m.useRef)(!1),l=_A(),[c,d]=(0,m.useState)(!1),[u,p]=(0,m.useState)(!1),[y,f]=(0,m.useState)(null),[g,w]=(0,m.useState)(),[v,b]=(0,m.useState)();if(!a?.funding||"ethereum"!==a.funding.chainType)throw Error("Invalid funding data");let{amount:x,connectedWalletAddress:_,chain:C,cluster:I,isUSDC:E}=a.funding,T=a.funding.address,A=a.funding.erc20Address,S=a.funding.isUSDC?"USDC":C.nativeCurrency.symbol,k=I??{name:"mainnet-beta"},P=_?s.find(({address:e})=>e===_):s[0],j=yO(P?.walletClientType||"unknown"),O=j?.name||"wallet";return(0,m.useEffect)(()=>{(async function(){if(!P||!C||o.current)return;let e=l(C5);if(!e)return void f(new n6.P("Unable to solana plugin"));o.current=!0,C?.testnet&&console.warn("Solana testnets are not supported for bridging");let t=E?1e6*parseFloat(x):(0,ie.g)(x),n=await b1({isTestnet:!!C.testnet,input:bQ({amount:t.toString(),user:P.address,recipient:T,destinationChainId:C.id,originChainId:0x2f3fb341,originCurrency:E?"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v":yF,destinationCurrency:E?A:void 0})}).catch(console.error);if(!n)return void f(new n6.P(`Unable to fetch quotes for bridging. Wallet ${pB(P.address)} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE));let i=await e.createBridgeTransactionFromRelayQuote({quote:n,from:P.address,cluster:k});if(i)try{d(!0);
58let{connection:e,transaction:t}=i,r=await e.simulateTransaction(t);if(r.value.err)return r.value.logs?.find(e=>/insufficient (lamports|funds)/gi.test(e))?void f(new n6.P(`Wallet ${pB(P?.address)} does not have enough funds. ${n.details.currencyIn.amountFormatted} ${S} are needed to complete the transaction.`,void 0,n6.a.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",r.value.err),void f(new n6.P("Something went wrong",void 0,n6.a.TRANSACTION_FAILURE)));let a=await P.sendTransaction(t,e),s=await e.confirmTransaction(a);if(s.value.err)return console.error("Transaction failed:",s.value.err),void f(new n6.P("Something went wrong",void 0,n6.a.TRANSACTION_FAILURE));w(a),b("pending")}catch(e){if(console.error(e),/user rejected the request/gi.test(e.message||""))return void f(new n6.P("Transaction was rejected by the user",void 0,n6.a.TRANSACTION_FAILURE));f(new n6.P("Something went wrong",void 0,n6.a.TRANSACTION_FAILURE))}else f(new n6.P(`Unable to select bridge option from quotes. Wallet ${pB(P.address)} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE))})().catch(console.error)},[]),b3({transactionHash:g,wallet:P,isTestnet:!1,bridgingStatus:v,setBridgingStatus:b,onSuccess({transactionHash:e,wallet:n}){d(!1),p(!0),t({eventName:C2,payload:{provider:"external",status:"success",txHash:e,address:n.address,chainType:"solana",clusterName:k.name,token:"SOL",destinationAddress:T,destinationChainId:C.id,destinationChainType:"ethereum",destinationValue:x,destinationToken:E?"USDC":"ETH"}})},onFailure({error:e}){d(!1),f(e)}}),(0,m.useEffect)(()=>{if(!u)return;let t=setTimeout(e,4e3);return()=>clearTimeout(t)},[u]),(0,m.useEffect)(()=>{y&&(i({funding:a?.funding,sendTransaction:a?.sendTransaction,errorModalData:{error:y,previousScreen:Eu}}),n(b6,!1))},[y]),u?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(g3,{}),(0,h.jsxs)(gX,{children:[(0,h.jsx)(pc.A,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),(0,h.jsx)(vT,{title:"Success!",description:`You’ve successfully added ${x} ${S} to your ${r.name} wallet. It may take a minute before the funds are available to use.`})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]}):c&&P?(0,h.jsx)(IT,{wallet:P,displayName:O,addressToFund:T,isBridging:c,isErc20Flow:!1,chainId:C.id,chainName:C.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(Ip,{}),(0,h.jsx)("div",{style:{marginTop:"1rem"}}),(0,h.jsx)(fk,{})]})}},Ed={component:()=>{let{data:e,setModalData:t}=yQ(),n=e?.funding,i="solana"===n.chainType,r=(0,m.useRef)(null),{tokenPrice:a}=wI(i?"solana":n.chain.id),s=i?void 0:n,o=!(!s?.erc20Address||s?.erc20ContractInfo),l=i?n.isUSDC?"USDC":"SOL":n.erc20Address?n.erc20ContractInfo?.symbol:n.chain.nativeCurrency.symbol||"ETH",c=parseFloat(n.amount),d=!isNaN(c)&&c>0,u=a?gg(n.amount,a):void 0;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(Cq,{children:"Confirm or edit amount"}),(0,h.jsxs)(g0,{style:{marginTop:"32px"},children:[(0,h.jsx)(I9,{children:o?(0,h.jsx)(Ip,{size:"50px"}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Ee,{onClick:()=>r.current?.focus(),children:[(0,h.jsx)(En,{ref:r,value:n.amount,onChange:i=>{let r=i.target.value;/^[0-9.]*$/.test(r)&&r.split(".").length-1<=1&&t({...e,funding:{...n,amount:r}})}}),(0,h.jsx)(Ei,{children:l})]}),!s?.erc20Address&&(0,h.jsx)(Er,{children:u&&d?`${u} USD`:""})]})}),(0,h.jsx)(gi,{style:{marginTop:"1rem"},disabled:!d,onClick:n.onContinueWithExternalWallet,children:"Continue"})]}),(0,h.jsx)(fk,{})]})}},Eu={component:()=>{let e,{connectors:t}=(0,n8.u)(),{app:n,setModalData:i,data:r,navigate:a}=yQ(),{wallets:s}=wT(),{wallets:o}=TS(),[l,c]=(0,m.useState)("default"),d="solana"===r?.funding?.chainType,u=!!r?.funding?.crossChainBridgingEnabled;e="ethereum"===r?.funding?.chainType?r.funding.erc20Address&&!r.funding.isUSDC?"ethereum-only":u&&!r.funding.chain.testnet?"ethereum-and-solana":"ethereum-only":u&&!r.funding?.isUSDC?"ethereum-and-solana":"solana-only";let p=s.filter(e=>"privy"!==e.walletClientType),y=p.map(e=>e.walletClientType),f=o.filter(e=>"privy"!==e.walletClientType),g=f.map(e=>e.walletClientType),w=[],v={...r.funding};v.usingDefaultFundingMethod&&(v.usingDefaultFundingMethod=!1);let b=({address:e,walletChainType:t})=>{i({...r,funding:{...v,connectedWalletAddress:e,onContinueWithExternalWallet:()=>a(_({destChainType:d?"solana":"ethereum",sourceChainType:t}))}}),a(Ed)};"solana-only"!==e&&w.push(...p.map((e,t)=>(0,h.jsx)(Eh,{onClick:()=>b({address:e.address,walletChainType:"ethereum"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},t))),"ethereum-only"!==e&&w.push(...f.map((e,t)=>(0,h.jsx)(Eh,{onClick:()=>b({address:e.address,walletChainType:"solana"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},t))),w.push(..._8({walletList:n.appearance.walletList.filter(e=>!p.some(t=>t.walletClientType===e)&&!f.some(t=>t.walletClientType===e)),walletChainType:e,connectors:t,connectOnly:!0,ignore:[...n.appearance.walletList,...y,...g],walletConnectEnabled:n.externalWallets.walletConnect.enabled}));let x=(0,h.jsx)(_7,{text:"More wallets",onClick:()=>c("overflow")}),_=({sourceChainType:e,destChainType:t})=>"ethereum"===e&&"solana"===t?T0:"ethereum"===e&&"ethereum"===t?El:"solana"===e&&"ethereum"===t?Ec:IS;return(0,m.useEffect)(()=>{i({...r,externalConnectWallet:{onCompleteNavigateTo:({walletChainType:e})=>(i({...r,funding:{...v,onContinueWithExternalWallet:()=>{a(_({destChainType:d?"solana":"ethereum",sourceChainType:e??"ethereum"}))}}}),Ed)}})},[]),(0,h.jsxs)(h.Fragment,"overflow"===l?{children:[(0,h.jsx)(fR,{backFn:()=>c("default")},"header"),(0,h.jsxs)(ff,{children:[(0,h.jsx)(Cz,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),w]}),(0,h.jsx)(fk,{})]}:{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(vT,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),(0,h.jsxs)(ff,{children:[w.length>4?w.slice(0,3):w,w.length>4&&x]}),(0,h.jsx)(fk,{})]})}},Eh=({onClick:e,icon:t,name:n,chainType:i})=>(0,h.jsxs)(fb,{onClick:e,children:[(0,h.jsx)(I7,{style:{width:20},children:(0,h.jsx)("img",{src:t})}),n,(0,h.jsx)(xk,{color:"gray",style:{marginLeft:"auto"},children:"Connected"}),"solana"===i&&(0,h.jsx)(xk,{color:"gray",children:"Solana"})]}),Ep={component:()=>{let{data:e,setModalData:t,navigate:n,navigateBack:i}=yQ(),{closePrivyModal:r,createAnalyticsEvent:a,client:s}=(0,n8.u)(),[o,l]=(0,m.useState)("pending-in-flow"),c=(0,m.useRef)(0),d={...e?.funding,showAlternateFundingMethod:!0};d.usingDefaultFundingMethod&&(d.usingDefaultFundingMethod=!1);let{partnerUserId:u,popup:p}=e?.coinbaseOnrampStatus??{};return(0,m.useEffect)(()=>
58{if("pending-in-flow"===o||"pending-after-flow"===o){let e=setInterval(async()=>{if(u)try{let{status:e}=await s.getCoinbaseOnRampStatus({partnerUserId:u});if("success"===e)return void l("success");if("failure"===e)throw Error("There was an error completing Coinbase Onramp flow.");if(c.current>=3)return t({funding:d}),void n(EP);p?.closed&&(c.current=c.current+1,l("pending-after-flow"))}catch(e){console.error(e),l("error"),a({eventName:C2,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),t({funding:{...d,errorMessage:"Something went wrong adding funds. Please try again or use another method."}}),n(EP)}},1500);return()=>clearInterval(e)}},[u,p,o]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{title:"Fund account",backFn:()=>{t({funding:d}),i()}},"header"),(0,h.jsx)(Em,{status:o,onClickCta:r}),(0,h.jsx)(fk,{})]})}},Em=({status:e,onClickCta:t})=>{let{title:n,body:i,cta:r}=(0,m.useMemo)(()=>(e=>{switch(e){case"success":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"pending-after-flow":return{title:"In Progress",body:"Almost done. Retrieving transaction status from Coinbase",cta:""};case"error":case"pending-in-flow":return{title:"In Progress",body:"Go back to Coinbase Onramp to finish funding your account.",cta:""}}})(e),[e]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Eg,{children:[(0,h.jsx)(Ey,{isSucccess:"success"===e}),(0,h.jsxs)(g1,{children:[(0,h.jsx)("h3",{children:n}),(0,h.jsx)(Ef,{children:i})]})]}),r&&(0,h.jsx)(gn,{onClick:t,children:r})]})},Ey=({isSucccess:e})=>{if(!e){let e="var(--privy-color-foreground-4)";return(0,h.jsxs)("div",{style:{position:"relative"},children:[(0,h.jsx)(f8,{color:e,style:{position:"absolute"}}),(0,h.jsx)(f7,{color:e}),(0,h.jsx)(mQ,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let t=e?h5.A:()=>(0,h.jsx)(h8.A,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}}),n=e?"var(--privy-color-success)":"var(--privy-color-foreground-4)";return(0,h.jsx)("div",{style:{borderColor:n,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:t&&(0,h.jsx)(t,{width:"4rem",height:"4rem",color:n})})},Ef=ig.I4.p.withConfig({displayName:"StatusBody",componentId:"sc-ebf88779-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),Eg=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-ebf88779-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]),Ew={[U.r.id]:"ethereum",[Y.E.id]:"base",[ee.R.id]:"optimism",[et.n.id]:"polygon",[J.D.id]:"arbitrum"},Ev=(e,t,n,i,r,a)=>new Promise(async(s,o)=>{let l=vv();if(!l)return void o(Error("Unable to initialize flow"));let c="ethereum"===t.chainType?function(e){let t=Ew[e];if(!t)throw new n6.P(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}(t.chain.id):"solana",d=t.isUSDC?"USDC":"ethereum"===t.chainType?"ETH":"SOL",u=await e.initCoinbaseOnRamp({addresses:[{address:t.address,blockchains:[c]}],assets:[d]}),{url:h}=function({appId:e,input:t,amount:n,blockchain:i,asset:r,experience:a}){let s=new URL("https://pay.coinbase.com/buy/select-asset");return s.searchParams.set("appId",t.app_id),s.searchParams.set("sessionToken",t.session_token),s.searchParams.set("endPartnerName",`privy:${e}`),s.searchParams.set("defaultExperience",a),s.searchParams.set("presetCryptoAmount",n.startsWith(".")?`0${n}`:n),s.searchParams.set("defaultNetwork",i),s.searchParams.set("defaultPaymentMethod",eg[a]),s.searchParams.set("defaultAsset",ew[r]),s.searchParams.set("partnerUserId",t.partner_user_id),{url:s}}({appId:e.getAppId(),input:u,amount:t.amount,blockchain:c,asset:d,experience:a});l.location=h.toString();let p={...r?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(p.usingDefaultFundingMethod=!1),n({funding:p,coinbaseOnrampStatus:{popup:l}}),i(Ep),e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),setTimeout(()=>{n({funding:p,coinbaseOnrampStatus:{partnerUserId:u.partner_user_id,popup:l}})},5e3),s()}),Eb=({size:e=61,...t})=>(0,h.jsx)("svg",{width:e,height:e,viewBox:"0 0 61 61",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:(0,h.jsxs)("g",{id:"moonpay_symbol_wht 2",children:[(0,h.jsx)("rect",{x:"1.3374",y:"1",width:"59",height:"59",rx:"11.5",fill:"#7715F5"}),(0,h.jsx)("path",{id:"Vector",d:"M43.8884 23.3258C45.0203 23.3258 46.1268 22.9901 47.068 22.3613C48.0091 21.7324 48.7427 20.8386 49.1759 19.7928C49.6091 18.747 49.7224 17.5962 49.5016 16.4861C49.2807 15.3759 48.7357 14.3561 47.9353 13.5557C47.1349 12.7553 46.1151 12.2102 45.0049 11.9893C43.8947 11.7685 42.7439 11.8819 41.6982 12.3151C40.6524 12.7482 39.7585 13.4818 39.1297 14.423C38.5008 15.3641 38.1651 16.4707 38.1651 17.6026C38.165 18.3542 38.3131 19.0985 38.6007 19.7929C38.8883 20.4873 39.3098 21.1182 39.8413 21.6496C40.3728 22.1811 41.0037 22.6027 41.6981 22.8903C42.3925 23.1778 43.1367 23.3259 43.8884 23.3258ZM26.3395 49.1017C23.5804 49.1017 20.8832 48.2836 18.5891 46.7507C16.295 45.2178 14.5069 43.039 13.4511 40.49C12.3952 37.9409 12.1189 35.1359 12.6572 32.4298C13.1955 29.7237 14.5241 27.238 16.4751 25.287C18.4262 23.336 20.9118 22.0074 23.6179 21.4691C26.324 20.9308 29.129 21.2071 31.6781 22.2629C34.2272 23.3189 36.406 25.1069 37.9389 27.401C39.4717 29.6952 40.2899 32.3923 40.2899 35.1514C40.2899 36.9835 39.9291 38.7975 39.2281 40.49C38.527 42.1826 37.4994 43.7205 36.204 45.0159C34.9086 46.3113 33.3707 47.3389 31.6781 48.04C29.9856 48.741 28.1715 49.1018 26.3395 49.1017Z",fill:"white"})]})}),Ex={component:()=>{let{app:e,data:t,setModalData:n,navigateBack:i}=yQ(),{closePrivyModal:r}=(0,n8.u)(),{externalTransactionId:a}=t?.moonpayStatus,s=function(e,t=!1){let[n,i]=(0,m.useState)(null),{createAnalyticsEvent:r}=(0,n8.u)(),{data:a,navigate:s,setModalData:o}=yQ(),l=a?.funding,c=(0,m.useRef)(0);return(0,m.useEffect)(()=>{let n=setInterval(async()=>
58{if(e)try{let[a]=await async function(e,t){return(0,pm.OT)(`https://api.moonpay.com/v1/transactions/ext/${e}`,{query:{apiKey:t?"pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI":"pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL"}})}(e,t),c="waitingAuthorization"===a.status&&"credit_debit_card"===a.paymentMethod?"pending":a.status;if(["failed","completed","awaitingAuthorization"].includes(c)&&(r({eventName:C2,payload:{status:c,provider:Ej,paymentMethod:a.paymentMethod,cardPaymentType:a.cardPaymentType,currency:a.currency?.code,baseCurrencyAmount:a.baseCurrencyAmount,quoteCurrencyAmount:a.quoteCurrencyAmount,feeAmount:a.feeAmount,extraFeeAmount:a.extraFeeAmount,networkFeeAmount:a.networkFeeAmount,isSandbox:t}}),clearInterval(n)),"failed"===c||"serviceFailure"===c)return o({funding:{...l,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),void s(EP);i(c)}catch(e){404!==e.response?.status&&(c.current+=1),c.current>=3&&(r({eventName:C2,payload:{status:"serviceFailure",provider:Ej}}),clearInterval(n),o({funding:{...l,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),s(EP))}},3e3);return()=>clearInterval(n)},[e,c]),n}(a||null,e.fundingMethodConfig.moonpay.useSandbox??!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{title:"Fund account",backFn:()=>{let e={...t?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),n({funding:e}),i()}}),(0,h.jsx)(E_,{status:s,onClickCta:r}),(0,h.jsx)(fk,{})]})}},E_=({status:e,onClickCta:t})=>{let{title:n,body:i,cta:r}=(0,m.useMemo)(()=>(e=>{switch(e){case"completed":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"waitingAuthorization":return{title:"Processing payment",body:"This may take up to a few hours. You will receive an email when the purchase is complete.",cta:"Continue"};default:return{title:"In Progress",body:"Go back to MoonPay to finish funding your account.",cta:""}}})(e),[e]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(EE,{children:[(0,h.jsx)(EC,{status:e}),(0,h.jsxs)(g1,{children:[(0,h.jsx)("h3",{children:n}),(0,h.jsx)(EI,{children:i})]})]}),r&&(0,h.jsx)(gn,{onClick:t,children:r})]})},EC=({status:e})=>{if(!e||"pending"===e){let e="var(--privy-color-foreground-4)";return(0,h.jsxs)("div",{style:{position:"relative"},children:[(0,h.jsx)(f8,{color:e,style:{position:"absolute"}}),(0,h.jsx)(f7,{color:e}),(0,h.jsx)(Eb,{size:"3rem",style:{position:"absolute",top:"1rem",left:"1rem"}})]})}let t=(e=>{switch(e){case"completed":return h5.A;case"waitingAuthorization":return()=>(0,h.jsx)(h8.A,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}});default:return}})(e),n=(e=>e?({completed:"var(--privy-color-success)",failed:"var(--privy-color-error)",serviceFailure:"var(--privy-color-error)",waitingAuthorization:"var(--privy-color-accent)",pending:"var(--privy-color-foreground-4)"})[e]:"var(--privy-color-foreground-4)")(e);return(0,h.jsx)("div",{style:{borderColor:n,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:t&&(0,h.jsx)(t,{width:"4rem",height:"4rem",color:n})})},EI=ig.I4.p.withConfig({displayName:"StatusBody",componentId:"sc-7f0a56e4-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),EE=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-7f0a56e4-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]),ET=async(e,t,n,i,r,a,s,o)=>{let l=vv();if(!l)throw Error("Unable to initialize flow");let c="ethereum"===t.chainType?t.moonpayConfigOverride?.currencyCode??function(e,t){switch(e){case J.D.id:return"native-currency"===t?"ETH_ARBITRUM":"USDC_ARBITRUM";case Z.m.id:return"AVAX_CCHAIN";case Y.E.id:return"native-currency"===t?"ETH_BASE":"USDC_BASE";case Q.A.id:return"CELO_CELO";case et.n.id:return"native-currency"===t?"MATIC_POLYGON":"USDC_POLYGON";case U.r.id:return"native-currency"===t?"ETH_ETHEREUM":"USDC_ETHEREUM";default:return console.warn(`Chain ${e} not supported by Moonpay, defaulting to Ethereum mainnet`),"ETH_ETHEREUM"}}(t.chain.id,i):t.isUSDC?"USDC_SOL":"SOL",{signedUrl:d,externalTransactionId:u}=await e.signMoonpayOnRampUrl({address:t.address,useSandbox:n.fundingMethodConfig.moonpay.useSandbox??!1,config:{uiConfig:{accentColor:n.appearance.palette.accent,theme:n.appearance.palette.colorScheme},...t.moonpayConfigOverride,paymentMethod:o,currencyCode:c,quoteCurrencyAmount:t.moonpayConfigOverride?.quoteCurrencyAmount??parseFloat(t.amount)}});e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"moonpay",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),l.location=d;let h={...s?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(h.usingDefaultFundingMethod=!1),r({moonpayStatus:{},funding:h}),a(Ex),setTimeout(()=>{r({moonpayStatus:{externalTransactionId:u},funding:h})},8e3)},EA=async e=>"undefined"!=typeof window&&"PaymentRequest"in window&&await new window.PaymentRequest([{supportedMethods:e}],{id:"0",total:{label:"Item",amount:{currency:"USD",value:"1.00"}}}).canMakePayment(),ES=()=>EA("https://apple.com/apple-pay"),Ek=()=>EA("https://google.com/pay"),EP={component:()=>{let{wallets:e}=wT(),{wallets:t}=TS(),{navigate:n,data:i,setModalData:r}=yQ(),{client:a}=(0,n8.u)(),s=yK(),o=i?.funding,l=Ic(ES),c=Ic(Ek),d="solana"===o.chainType,u=d?void 0:o,p=(0,m.useMemo)(()=>((e,t,n,i,r,a)=>{let s,o,l="solana"===n.chainType,c=l?void 0:n,d=n.isUSDC?"USDC":c?.erc20Address?void 0:"native-currency",u=!!l||d&&function(e,t){switch(t){case"native-currency":return eb.has(e);case"USDC":return ex.has(e);default:return console.warn("Unknown asset passed to MoonPay Onramp"),!1}}(Number(n.chain.id),d),h=!!l||d&&((e,t)=>{switch(t){case"native-currency":return ey.has(e);case"USDC":return ef.has(e);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}})(Number(n.chain.id),d),p=[];for(let s of(n.preferredCardProvider&&n.supportedOptions.sort(e=>e.provider===n.preferredCardProvider?-1:1),n.supportedOptions))"card"===s.method&&"coinbase"===s.provider&&h&&p.push(()=>Ev(t,n,i,r,a,"buy")),"card"===s.method&&"moonpay"===s.provider&&u&&d&&p.push(()=>ET(t,n,e,d,i,r,a,"credit_debit_card"));for(let e of n.supportedOptions)"exchange"===e.method&&"coinbase"===e.provider&&h&&(s=()=>Ev(t,n,i,r,a,"buy"));for(let e of a?.funding?.supportedOptions??[])"wallets"===e.method&&(o=()=>r(Eu));return{onFundWithCard:p,onFundWithExchange:s,onFundWithWallet:o}})(s,a,o,r,n,i),[s,a,o,i,r,n]);(0,m.useEffect)(()=>
58{if(o?.defaultFundingMethod&&o.usingDefaultFundingMethod)switch(r({funding:{...o,usingDefaultFundingMethod:!1}}),o?.defaultFundingMethod){case"card":p.onFundWithCard[0]&&p.onFundWithCard[0]();break;case"exchange":p.onFundWithExchange&&p.onFundWithExchange();break;case"wallet":p.onFundWithWallet&&p.onFundWithWallet();break;case"manual":n(Tk)}},[]),(0,m.useEffect)(()=>{u?.erc20Address&&!u.erc20ContractInfo&&Iu({address:u.erc20Address,chain:u.chain,rpcConfig:s.rpcConfig,privyAppId:s.id}).then(e=>{r({...i,funding:{...u,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}})}).catch(console.error)},[u?.erc20Address,u?.chain]);let y=d?t.find(({address:e})=>e===o.address):e.find(({address:e})=>(0,f.b)(e)===(0,f.b)(o.address)),g=yO(y?.walletClientType||"unknown"),w=g?.name||"wallet",v=y&&"privy"!==y.walletClientType?w:s.name,b=!(!u?.erc20Address||u?.erc20ContractInfo);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsxs)("h3",{children:["Add funds to your"," ",v?.toLowerCase().endsWith("wallet")?v:v+" wallet"]}),(0,h.jsxs)(I8,{children:[o.errorMessage&&(0,h.jsx)(Ia,{theme:s.appearance.palette.colorScheme,children:o.errorMessage}),p.onFundWithCard?.[0]&&(0,h.jsxs)(fb,{disabled:b,onClick:p.onFundWithCard[0],children:[(0,h.jsx)(I7,{children:(0,h.jsx)(pu.A,{style:{width:24}})}),"Pay with card",l?(0,h.jsx)(Io,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):c?(0,h.jsx)(Il,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):null]}),p.onFundWithExchange&&(0,h.jsxs)(fb,{disabled:b,onClick:p.onFundWithExchange,children:[(0,h.jsx)(I7,{children:(0,h.jsx)(h8.A,{style:{width:24}})}),"Transfer from an exchange"]}),p.onFundWithWallet&&(0,h.jsxs)(fb,{disabled:b,onClick:p.onFundWithWallet,children:[(0,h.jsx)(I7,{children:(0,h.jsx)(Id,{style:{width:24}})}),"Transfer from wallet"]}),(0,h.jsxs)(fb,{disabled:b,onClick:()=>n(Tk),children:[(0,h.jsx)(I7,{children:(0,h.jsx)(ph.A,{style:{width:24}})}),"Receive funds"]}),o?.showAlternateFundingMethod&&p.onFundWithCard?.[1]&&(0,h.jsx)(CK,{theme:s.appearance.palette.colorScheme,children:(0,h.jsxs)(Ea,{children:["Having trouble or facing location restrictions?"," ",(0,h.jsx)(Es,{onClick:p.onFundWithCard[1],children:"Try a different provider."})]})})]}),(0,h.jsx)(fk,{})]})}},Ej="moonpay";function EO(e){return!!e&&(void 0!==e.chain||void 0!==e.amount)}let EN={[U.r.id]:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",[ei.G.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[ee.R.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[er.i.id]:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",[et.n.id]:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",[ea.n.id]:"0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",[Y.E.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[es.Z.id]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[Z.m.id]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[eo.C.id]:"0x5425890298aed601595a70ab815c96711a31bc65",[J.D.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[el.Y.id]:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},ER=({address:e,appConfig:t,fundWalletConfig:n,methodScreen:i,chainIdOverride:r,comingFromSendTransactionScreen:a=!1})=>{let s,o;if(!t.fundingConfig)throw Error("Wallet funding is not enabled");let l=Ii(t.fundingConfig.options);if(l.length<1)throw Error("Wallet funding is not enabled");s=r||(EO(n)&&n.chain?n.chain.id:vm(t.fundingConfig.defaultRecommendedCurrency.chain));let c=t.chains.find(e=>e.id===s);if(!c)throw new n6.P(`Funding chain ${s} is not in PrivyProvider chains list`);let d=EO(n)&&n.amount?n.amount:t.fundingConfig.defaultRecommendedAmount,u=!1;function h(){if(!s)return;let e=EN[s];l.find(e=>"wallets"===e.method)&&!e&&console.warn("Attempting to fund with USDC on chain where USDC address is not known. Funding via external wallet will be disabled."),o=e,u=!0}EO(n)&&"asset"in n?"USDC"===n.asset?h():"string"!=typeof n.asset&&"erc20"in n.asset&&(u=(o=n.asset.erc20)===EN[c.id]):"USDC"===t.fundingConfig.defaultRecommendedCurrency.asset&&h();let p=n?.defaultFundingMethod;return{chainType:"ethereum",address:e,amount:d,chain:c,erc20Address:o,erc20ContractInfo:u?{symbol:"USDC",decimals:6}:void 0,isUSDC:u,methodScreen:i,supportedOptions:l,comingFromSendTransactionScreen:a,defaultFundingMethod:p,usingDefaultFundingMethod:!!p,preferredCardProvider:n?.card?.preferredProvider,crossChainBridgingEnabled:t.fundingConfig.crossChainBridgingEnabled??!1,cluster:{name:"mainnet-beta",rpcUrl:t.solanaClusters["mainnet-beta"].rpcUrl},...!function(e){return!!e&&void 0!==e.config&&void 0!==e.provider}(n)?{}:{moonpayConfigOverride:n.config},uiConfig:n&&"uiConfig"in n?n.uiConfig:void 0}},EM=({children:e,theme:t})=>(0,h.jsxs)(ED,{$theme:t,children:[(0,h.jsx)(iA.A,{width:"1.25rem",color:"dark"===t?"#FDE68A":"var(--privy-color-warn)"}),e]}),ED=ig.I4.div.withConfig({displayName:"Container",componentId:"sc-97f152b3-0"})(["display:flex;gap:0.5rem;background-color:",";"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);}"],e=>"dark"===e.$theme?"var(--privy-color-background-2)":"var(--privy-color-warn-light)",e=>"dark"===e.$theme?"color: #FDE68A;":"");function EU(e){let[t,n]=(0,m.useState)(e.dimensions.width),[i,r]=(0,m.useState)(void 0),a=(0,m.useRef)(null);(0,m.useEffect)(()=>
58{if(a.current&&void 0===t){let{width:e}=a.current.getBoundingClientRect();n(e)}let e=getComputedStyle(document.documentElement);r({background:e.getPropertyValue("--privy-color-background"),background2:e.getPropertyValue("--privy-color-background-2"),foreground3:e.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:e.getPropertyValue("--privy-color-foreground-accent"),accent:e.getPropertyValue("--privy-color-accent"),accentDark:e.getPropertyValue("--privy-color-accent-dark"),success:e.getPropertyValue("--privy-color-success"),colorScheme:e.getPropertyValue("color-scheme")})},[]);let s="ethereum"===e.chainType&&!e.imported&&!e.isUnifiedWallet;return(0,h.jsx)("div",{ref:a,children:t&&(0,h.jsxs)(EW,{children:[(0,h.jsx)("iframe",{style:{position:"absolute",zIndex:1},width:t,height:e.dimensions.height,allow:"clipboard-write self *",src:pV(e.origin,`/apps/${e.appId}/embedded-wallets/export`,e.isUnifiedWallet?{v:"1-unified",wallet_id:e.walletId,client_id:e.appClientId,width:`${t}px`,caid:e.clientAnalyticsId,phrase_export:s,...i}:{v:"1",entropy_id:e.entropyId,entropy_id_verifier:e.entropyIdVerifier,hd_wallet_index:e.hdWalletIndex,chain_type:e.chainType,client_id:e.appClientId,width:`${t}px`,caid:e.clientAnalyticsId,phrase_export:s,...i},{token:e.accessToken})}),(0,h.jsx)(E$,{children:"Loading..."}),s&&(0,h.jsx)(E$,{children:"Loading..."})]})})}let EL={component:()=>{let[e,t]=(0,m.useState)(null),{authenticated:n,user:i}=(0,ic.u)(),{closePrivyModal:r,createAnalyticsEvent:a,clientAnalyticsId:s,client:o}=(0,n8.u)(),l=yK(),{data:c,onUserCloseViaDialogOrKeybindRef:d}
58=yQ(),{onFailure:u,onSuccess:p,origin:y,appId:f,appClientId:g,entropyId:w,entropyIdVerifier:v,walletId:b,hdWalletIndex:x,chainType:_,address:C,isUnifiedWallet:I,imported:E}=c.keyExport,T=e=>{r({shouldCallAuthOnSuccess:!1}),u("string"==typeof e?Error(e):e)},A=()=>{r({shouldCallAuthOnSuccess:!1}),p(),a({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:C}})};return(0,m.useEffect)(()=>{if(!n)return T("User must be authenticated before exporting their wallet");o.getAccessToken().then(t).catch(T)},[n,i]),d.current=A,(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:A}),(0,h.jsxs)(EF,{children:[(0,h.jsx)(Cq,{children:"Export wallet"}),(0,h.jsxs)(Cz,{children:["Copy either your private key or seed phrase to export your wallet."," ",(0,h.jsx)("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),(0,h.jsx)(EM,{theme:l.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),(0,h.jsx)(C0,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:C,showIcon:!0}),(0,h.jsx)("div",{style:{width:"100%"}
58,children:e&&(0,h.jsx)(EU,{origin:y,appId:f,appClientId:g,accessToken:e,clientAnalyticsId:s,entropyId:w,entropyIdVerifier:v,walletId:b,hdWalletIndex:x,isUnifiedWallet:I,imported:E,chainType:_,dimensions:{height:"44px"}})})]}),(0,h.jsx)(fk,{})]})}},EF=ig.I4.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-7b921328-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),EW=ig.I4.div.withConfig({displayName:"ButtonContainer",componentId:"sc-7b921328-1"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),E$=ig.I4.div.withConfig({displayName:"LoadingButton",componentId:"sc-7b921328-2"})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:16px;font-weight:500;border-radius:var(--privy-border-radius-md);background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);"]),EB={component:()=>{let{authenticated:e,user:t,getAccessToken:n}=(0,ic.u)(),{closePrivyModal:i,createAnalyticsEvent:r,walletProxy:a}=(0,n8.u)(),{navigate:s,data:o,setModalData:l,onUserCloseViaDialogOrKeybindRef:c}=yQ(),d=(0,m.useMemo)(()=>Date.now(),[]),[u,p]=(0,m.useState)(!1),{onCompleteNavigateTo:y,onFailure:f,shouldForceMFA:g,entropyId:w,entropyIdVerifier:v,recoveryMethod:b,connectingWalletAddress:x,isUnifiedWallet:_=!1}=o?.connectWallet,C=e=>{u||(p(!0),f("string"==typeof e?Error(e):e))};(0,m.useEffect)(()=>{let t;return e?a?((async()=>{let e=await n();if(!e)return C("User must be authenticated and have a Privy wallet before it can be connected");try{_||await a.connect({accessToken:e,entropyId:w,entropyIdVerifier:v}),g&&await a.verifyMfa({accessToken:e});let n=(Date.now()-d)/1e3;y===EL&&n<1?t=setTimeout(()=>{s(y,!1)},1e3*(1-n)):s(y,!1)}catch(e){if(wV(e)&&"privy"===b){let e=await n();if(!e)return C("User must be authenticated and have a Privy wallet before it can be recovered");try{r({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:x}});let t=await a?.recover({accessToken:e,entropyId:w,entropyIdVerifier:v});t?.entropyId||C(Error("Unable to recover wallet")),y?s(y):i({shouldCallAuthOnSuccess:!1}),r({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:x}}),s(y)}catch(e){C("An error has occurred, please try again.")}}else wV(e)&&"privy"!==b&&"privy-v2"!==b?(l({...o,recoverWallet:{entropyId:w,entropyIdVerifier:v,onCompleteNavigateTo:y,onFailure:f},recoveryOAuthStatus:{provider:b,action:"recover",isInAccountCreateFlow:!1,shouldCreateEth:!1,shouldCreateSol:!1}}),s(CG(b))):C(e)}})(),()=>clearTimeout(t)):void 0:C("User must be authenticated and have a Privy wallet before it can be connected")},[e,t,a]);let I=()=>{C("User exited before wallet could be connected"),i({shouldCallAuthOnSuccess:!1})};return c.current=I,(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:I}),u?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(gX,{children:[(0,h.jsx)(h4.A,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),(0,h.jsx)(vT,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),(0,h.jsx)(gn,{onClick:()=>i({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):(0,h.jsx)(xy,{}),(0,h.jsx)(Ez,{})]})}},Ez=ig.I4.div.withConfig({displayName:"BottomSpacing",componentId:"sc-1ec92f42-0"})(["height:44px;"]),Eq=(0,ig.I4)(Ib).withConfig({displayName:"InteractiveLabel",componentId:"sc-b57d0824-0"})(["cursor:pointer;display:inline-flex;gap:8px;align-items:center;color:var(--privy-color-accent);svg{fill:var(--privy-color-accent);}"]);var EV=({iconUrl:e,value:t,symbol:n,usdValue:i,nftName:r,nftCount:a,$isLoading:s})=>s?(0,h.jsx)(EH,{$isLoading:s}):(0,h.jsxs)("div",{children:[(0,h.jsxs)(EH,{$isLoading:s,children:[e&&(0,h.jsx)(EK,{src:e,alt:"Token icon"}),a&&a>1?a+"x":void 0," ",r,t," ",n]}),i&&(0,h.jsxs)(EG,{$isLoading:s,children:["$",i]})]});let EH=ig.I4.span.withConfig({displayName:"Value",componentId:"sc-f3c0f2da-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],xS),EG=ig.I4.span.withConfig({displayName:"Subvalue",componentId:"sc-f3c0f2da-1"})(["color:var(--privy-color-foreground-2);font-size:12px;font-weight:400;line-height:18px;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],xS),EK=ig.I4.img.withConfig({displayName:"TokenIcon",componentId:"sc-f3c0f2da-2"})(["height:14px;width:14px;margin-right:4px;object-fit:contain;"]),EJ=e=>
58{let{chain:t,transactionDetails:n,isTokenContractInfoLoading:i,symbol:r}=e,{action:a,functionName:s}=n;return(0,h.jsx)(CX,{children:(0,h.jsxs)(Iw,{children:["transaction"!==a&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Action"}),(0,h.jsx)(I_,{children:s})]}),"mint"===s&&"args"in n&&n.args.filter(e=>e).map((e,n)=>(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:`Param ${n}`}),(0,h.jsx)(I_,{children:"string"==typeof e&&(0,v.P)(e)?(0,h.jsx)(bG,{address:e,url:t?.blockExplorers?.default?.url,showCopyIcon:!1}):e?.toString()})]},n)),"setApprovalForAll"===s&&n.operator&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Operator"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:n.operator,url:t?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===s&&void 0!==n.approved&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Set approval to"}),(0,h.jsx)(I_,{children:n.approved?"true":"false"})]}),"transfer"===s||"transferFrom"===s||"safeTransferFrom"===s||"approve"===s?(0,h.jsxs)(h.Fragment,{children:["formattedAmount"in n&&n.formattedAmount&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Amount"}),(0,h.jsxs)(I_,{$isLoading:i,children:[n.formattedAmount," ",r]})]}),"tokenId"in n&&n.tokenId&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token ID"}),(0,h.jsx)(I_,{children:n.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===s&&(0,h.jsxs)(h.Fragment,{children:["amounts"in n&&n.amounts&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Amounts"}),(0,h.jsx)(I_,{children:n.amounts.join(", ")})]}),"tokenIds"in n&&n.tokenIds&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token IDs"}),(0,h.jsx)(I_,{children:n.tokenIds.join(", ")})]})]}),"approve"===s&&n.spender&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Spender"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:n.spender,url:t?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===s||"safeTransferFrom"===s||"safeBatchTransferFrom"===s)&&n.transferFrom&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Transferring from"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:n.transferFrom,url:t?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===s||"safeTransferFrom"===s||"safeBatchTransferFrom"===s)&&n.transferTo&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Transferring to"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:n.transferTo,url:t?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})},EZ={success:"background: var(--privy-color-success-lightest, #dcfce7);",warn:"background: var(--privy-color-warn-lightest, #fff7e6);",error:"background: var(--privy-color-error-lightest, #fde8e8);"},EY=ig.I4.div.withConfig({displayName:"Pill",componentId:"sc-8c138024-0"})(["border-radius:var(--privy-border-radius-md,8px);padding:12px;text-align:left;margin-top:23px;",""],e=>EZ[e.variant]),EQ=({variant:e,setPreventMaliciousTransaction:t,preventMaliciousTransaction:n})=>"warn"===e?(0,h.jsx)(EY,{variant:e,children:(0,h.jsxs)("div",{className:"flex flex-row",children:[(0,h.jsx)(EX,{$variant:e}),(0,h.jsxs)("p",{children:[(0,h.jsx)("b",{children:"Warning: Suspicious transaction"}),(0,h.jsx)("br",{}),"This has been flagged as a potentially deceptive request. Approving could put your assets or funds at risk."]})]})}):"error"===e?(0,h.jsx)(EY,{variant:e,children:(0,h.jsxs)("div",{className:"flex flex-col",children:[(0,h.jsxs)("div",{className:"flex flex-row",children:[(0,h.jsx)(EX,{$variant:e}),(0,h.jsxs)("p",{children:[(0,h.jsx)("b",{children:"This is a malicious transaction"}),(0,h.jsx)("br",{}),"This transaction transfers tokens to a known malicious address. Proceeding may result in the loss of valuable assets."]})]}),(0,h.jsxs)("div",{className:"mt-3 flex flex-row gap-2",children:[(0,h.jsx)(be,{color:"var(--privy-color-error)",checked:!n,readOnly:!0,onClick:()=>t(!n)}),(0,h.jsx)("p",{children:"I understand and want to proceed anyways."})]})]})}):void 0,EX=(0,ig.I4)(iA.A).withConfig({displayName:"StyledExclamationTriangleIcon",componentId:"sc-91effb27-0"})(["width:20px;height:20px;stroke-width:2px;flex-shrink:0;display:inline-block;margin-right:8px;",";"],({$variant:e})=>"error"===e?"color: var(--privy-color-error)":"color: var(--privy-color-warn)"),E0=({transactionIndex:e,maxIndex:t})=>"number"!=typeof e||0===t?"":` (${e+1} / ${t+1})`,E1=({img:e,submitError:t,prepareError:n,onClose:i,action:r,title:a,subtitle:s,txValue:o,to:l,tokenAddress:c,network:d,missingFunds:u,fee:p,from:y,cta:f,disabled:g,chain:w,isSubmitting:v,isPreparing:b,isTokenPriceLoading:x,isTokenContractInfoLoading:_,isSponsored:C,symbol:I,balance:E,onClick:T,transactionDetail
58s:A,transactionIndex:S,maxIndex:k,onBack:P,chainName:j,validation:O,hasScanDetails:N,setIsScanDetailsOpen:R,preventMaliciousTransaction:M,setPreventMaliciousTransaction:D,tokensSent:U,tokensReceived:L,isScanning:F,isCancellable:W})=>{let{showTransactionDetails:$,setShowTransactionDetails:B,hasMoreDetails:z,isErc20Ish:q}=(e=>{let[t,n]=(0,m.useState)(!1),i=!0,r=!1;return(!e||e.isErc20Ish||"transaction"===e.action)&&(i=!1),i&&(r=Object.entries(e||{}).some(([e,t])=>t&&!["action","isErc20Ish","isNFTIsh"].includes(e))),{showTransactionDetails:t,setShowTransactionDetails:n,hasMoreDetails:i&&r,isErc20Ish:e?.isErc20Ish}})(A),V=q&&_||b||x||F;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:i,backFn:P}),e&&(0,h.jsx)(E6,{children:e}),(0,h.jsxs)(Cq,{style:{marginTop:e?"1.5rem":0},children:[a,(0,h.jsx)(E0,{maxIndex:k,transactionIndex:S})]}),(0,h.jsx)(Cz,{children:s}),(0,h.jsxs)(Iw,{style:{marginTop:"2rem"},children:[(!!U[0]||V)&&(0,h.jsxs)(Iv,{children:[L.length>0?(0,h.jsx)(Ib,{children:"Send"}):(0,h.jsx)(Ib,{children:"approve"===r?"Approval amount":"Amount"}),(0,h.jsx)("div",{className:"flex flex-col",children:U.map((e,t)=>(0,h.jsx)(EV,{iconUrl:e.iconUrl,value:e.value,usdValue:e.usdValue,symbol:e.symbol,nftName:e.nftName,nftCount:e.nftCount},t))})]}),L.length>0&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Receive"}),(0,h.jsx)("div",{className:"flex flex-col",children:L.map((e,t)=>(0,h.jsx)(EV,{iconUrl:e.iconUrl,value:e.value,usdValue:e.usdValue,symbol:e.symbol,nftName:e.nftName,nftCount:e.nftCount},t))})]}),A&&"spender"in A&&A?.spender?(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Spender"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:A.spender,url:w?.blockExplorers?.default?.url})})]}):null,l&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"To"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:l,url:w?.blockExplorers?.default?.url})})]}),c&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token address"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:c,url:w?.blockExplorers?.default?.url})})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Network"}),(0,h.jsx)(I_,{children:d})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Estimated fee"}),(0,h.jsx)(I_,{$isLoading:b||x||void 0===C,children:C?"Sponsored":p})]}),z&&!N&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Iv,{className:"cursor-pointer",onClick:()=>B(!$),children:(0,h.jsxs)(Ix,{className:"flex items-center gap-x-1",children:["Details"," ",(0,h.jsx)(iS.A,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:$?"rotate(180deg)":void 0}})]})}),$&&A&&(0,h.jsx)(EJ,{action:r,chain:w,transactionDetails:A,isTokenContractInfoLoading:_,symbol:I})]}),N&&(0,h.jsx)(Iv,{children:(0,h.jsxs)(Eq,{onClick:()=>R(!0),children:[(0,h.jsx)("span",{className:"text-color-primary",children:"Details"}),(0,h.jsx)(py.A,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),(0,h.jsx)(fm,{}),t?(0,h.jsx)(Cx,{style:{marginTop:"2rem"},children:t.message}):n&&0===S?(0,h.jsx)(Cx,{style:{marginTop:"2rem"},children:n.shortMessage??E5}):null,(0,h.jsx)(EQ,{variant:O,preventMaliciousTransaction:M,setPreventMaliciousTransaction:D}),(0,h.jsx)(E3,{$useSmallMargins:!(!n&&!t&&"warn"!==O&&"error"!==O),title:Number(o)>0?void 0:!1!==C?"Your wallet":void 0,address:y,balance:E,isLoading:b||x,errMsg:b||n||t||!u?void 0:`Add funds on ${w?.name??j} to complete transaction.`}),(0,h.jsx)(gn,{style:{marginTop:"1rem"},loading:v,disabled:g||b,onClick:T,children:f}),W&&(0,h.jsx)(gd,{style:{marginTop:"1rem"},onClick:i,isSubmitting:!1,children:"Not now"}),(0,h.jsx)(fk,{})]})},E2=({img:e,title:t,subtitle:n,cta:i,instructions:r,network:a,blockExplorerUrl:s,isMissingFunds:o,submitError:l,parseError:c,total:d,swap:u,transactingWalletAddress:p,fee:y,balance:f,disabled:g,isSubmitting:w,isPreparing:v,isTokenPriceLoading:b,onClick:x,onClose:_,onBack:C})=>{let I=v||b,[E,T]=(0,m.useState)(!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:_,backFn:C}),e&&(0,h.jsx)(E6,{children:e}),(0,h.jsx)(Cq,{style:{marginTop:e?"1.5rem":0},children:t}),(0,h.jsx)(Cz,{children:n}),(0,h.jsxs)(Iw,{style:{marginTop:"2rem",marginBottom:".5rem"},children:[(d||I)&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Amount"}),(0,h.jsx)(I_,{$isLoading:I,children:d})]}),u&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Swap"}),(0,h.jsx)(I_,{children:u})]}),a&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Network"}),(0,h.jsx)(I_,{children:a})]}),(y||I)&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Estimated fee"}),(0,h.jsx)(I_,{$isLoading:I,children:y})]})]}),(0,h.jsx)(Iv,{children:(0,h.jsxs)(Eq,{onClick:()=>T(e=>!e),children:[(0,h.jsx)("span",{children:"Advanced"}),(0,h.jsx)(iS.A,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:E?"rotate(180deg)":void 0}})]})}),E&&(0,h.jsx)(h.Fragment,{children:r.map((e,t)=>"sol-transfer"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsxs)(CY,{children:["Transfer ",e.withSeed?"with seed":""]})}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Amount"}),(0,h.jsxs)(I_,{children:[em({amount:e.value,decimals:e.token.decimals})," ",e.token.symbol]})]}),!!e.toAccount&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Destination"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.toAccount,url:s})})]})]},t):"spl-transfer"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsxs)(CY,{children:["Transfer ",e.token.symbol]})}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Amount"}),(0,h.jsx)(I_,{children:e.value.toString()})]}),!!e.fromAta&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Source"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.fromAta,url:s})})]}),!!e.toAta&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Destination"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.toAta,url:s})})]}),!!e.token.address&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.token.address,url:s})})]})]},t):"ata-creation"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsx)(CY,{children:"Create token account"})}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Program ID"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.program,url:s})})]}),!!e.owner&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Owner"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.owner,url:s})})]})]},t):"create-account"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsxs)(CY,{children:["Create account ",e.withSeed?"with seed":""]})}),!!e.account&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Account"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.account,url:s})})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Amount"}),(0,h.jsxs)(I_,{children:[em({amount:e.value,decimals:9})," SOL"]})]})]},t):"spl-init-account"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsx)(CY,{children:"Initialize token account"})}),!!e.account&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Account"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.account,url:s})})]}),!!e.mint&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Mint"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.mint,url:s})})]}),!!e.owner&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Owner"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.owner,url:s})})]})]},t):"spl-close-account"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsx)(CY,{children:"Close token account"})}),!!e.source&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Source"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.source,url:s})})]}),!!e.destination&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Destination"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.destination,url:s})})]}),!!e.owner&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Owner"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.owner,url:s})})]})]},t):"spl-sync-native"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsx)(CY,{children:"Sync native"})}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Program ID"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.program,url:s})})]})]},t):"raydium-swap-base-input"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsxs)(CY,{children:["Raydium swap"," ",e.tokenIn&&e.tokenOut?`${e.tokenIn.symbol} → ${e.tokenOut.symbol}`:""]})}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Amount in"}),(0,h.jsx)(I_,{children:e.amountIn.toString()})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Minimum amount out"}),(0,h.jsx)(I_,{children:e.minimumAmountOut.toString()})]}),e.mintIn&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token in"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.mintIn,url:s})})]}),e.mintOut&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token out"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.mintOut,url:s})})]})]},t):"raydium-swap-base-output"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsxs)(CY,{children:["Raydium swap"," ",e.tokenIn&&e.tokenOut?`${e.tokenIn.symbol} → ${e.tokenOut.symbol}`:""]})}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Max amount in"}),(0,h.jsx)(I_,{children:e.maxAmountIn.toString()})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Amount out"}),(0,h.jsx)(I_,{children:e.amountOut.toString()})]}),e.mintIn&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token in"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.mintIn,url:s})})]}),e.mintOut&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token out"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.mintOut,url:s})})]})]},t):"jupiter-swap-shared-accounts-route"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsxs)(CY,{children:["Jupiter swap"," ",e.tokenIn&&e.tokenOut?`${e.tokenIn.symbol} → ${e.tokenOut.symbol}`:""]})}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"In amount"}),(0,h.jsx)(I_,{children:e.inAmount.toString()})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Quoted out amount"}),(0,h.jsx)(I_,{children:e.quotedOutAmount.toString()})]}),e.mintIn&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token in"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.mintIn,url:s})})]}),e.mintOut&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token out"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.mintOut,url:s})})]})]},t):"jupiter-swap-exact-out-route"===e.type?(0,h.jsxs)(E4,{children:[(0,h.jsx)(Iv,{children:(0,h.jsxs)(CY,{children:["Jupiter swap"," ",e.tokenIn&&e.tokenOut?`${e.tokenIn.symbol} → ${e.tokenOut.symbol}`:""]})}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Quoted in amount"}),(0,h.jsx)(I_,{children:e.quotedInAmount.toString()})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Amount out"}),(0,h.jsx)(I_,{children:e.outAmount.toString()})]}),e.mintIn&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token in"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.mintIn,url:s})})]}),e.mintOut&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Token out"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.mintOut,url:s})})]})]},t):(0,h.jsxs)(E4,{children:[(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Program ID"}),(0,h.jsx)(I_,{children:(0,h.jsx)(bG,{address:e.program,url:s})})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Data"}),(0,h.jsx)(I_,{children:e.discriminator})]})]},t))}),(0,h.jsx)(fm,{}),l?(0,h.jsx)(Cx,{style:{marginTop:"2rem"},children:l.message}):c?(0,h.jsx)(Cx,{style:{marginTop:"2rem"},children:E5}):null,(0,h.jsx)(E3,{$useSmallMargins:!(!c&&!l),title:"Your wallet",address:p,balance:f,isLoading:v||b,errMsg:v||c||l||!o?void 0:"Add funds on Solana to complete transaction."}),(0,h.jsx)(gn,{style:{marginTop:"1rem"},loading:w,disabled:g||v,onClick:x,children:i}),(0,h.jsx)(fk,{})]})},E3=(0,ig.I4)(C0).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-fffdbdce-0"})(["",""],e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;"),E4=(0,ig.I4)(Iw).withConfig({displayName:"InstructionRows",componentId:"sc-fffdbdce-1"})(["margin-top:0.5rem;border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-sm);padding:0.5rem;"]),E5="There was an error preparing your transaction. Your transaction request will likely fail.",E6=ig.I4.div.withConfig({displayName:"ImageContainer",componentId:"sc-fffdbdce-2"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),E8=()=>(0,h.jsxs)(Tn,{children:[(0,h.jsx)(Tr,{}),(0,h.jsx)(Ti,{})]}),E7=({transactionError:e,chainId:t,onClose:n,onRetry:i,network:r,connection:a,transactionHash:s})=>{let{chains:o}=(0,n8.u)(),[l,c]=(0,m.useState)(!1),{errorCode:d,errorMessage:u}=((e,t)=>{if("ethereum"===t)return{errorCode:e.details??e.message,errorMessage:e.shortMessage};let n=e.txSignature,i=e?.transactionMessage||"Something went wrong.";if(Array.isArray(e.logs)){let t=e.logs.find(e=>/insufficient (lamports|funds)/gi.test(e));t&&(i=t)}return{transactionHash:n,errorMessage:i}})(e,r),p=(({chains:e,chainId:t,network:n,connection:i,transactionHash:r})=>{var a,s;return"ethereum"===n?e.find(e=>e.id===t)?.blockExplorers?.default.url??"https://etherscan.io":(a=r||"",s=yW(i?.rpcEndpoint||""),`https://explorer.solana.com/tx/${a}
58?cluster=${s}`)})({chains:o,chainId:t,network:r,connection:a,transactionHash:s});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:n}),(0,h.jsxs)(E9,{children:[(0,h.jsx)(E8,{}),(0,h.jsx)(Te,{children:d}),(0,h.jsx)(Tt,{children:"Please try again."}),(0,h.jsxs)(To,{children:[(0,h.jsx)(Ts,{children:"Error message"}),(0,h.jsx)(Tc,{$clickable:!1,children:u})]}),s&&(0,h.jsxs)(To,{children:[(0,h.jsx)(Ts,{children:"Transaction hash"}),(0,h.jsxs)(Tl,{children:["Copy this hash to view details about the transaction on a"," ",(0,h.jsx)("u",{children:(0,h.jsx)("a",{href:p,children:"block explorer"})}),"."]}),(0,h.jsxs)(Tc,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(s),c(!0)},children:[s,(0,h.jsx)(Th,{clicked:l})]})]}),(0,h.jsx)(Ta,{onClick:()=>i({resetNonce:!!s}),children:"Retry transaction"})]}),(0,h.jsx)(fP,{})]})},E9=ig.I4.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-92716bea-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),Te=ig.I4.span.withConfig({displayName:"ErrorCode",componentId:"sc-92716bea-1"})(["color:var(--privy-color-foreground);text-align:center;font-size:1.125rem;font-weight:500;line-height:1.25rem;text-align:center;margin:10px;"]),Tt=ig.I4.span.withConfig({displayName:"Subtitle",componentId:"sc-92716bea-2"})(["margin-top:4px;margin-bottom:10px;color:var(--privy-color-foreground-3);text-align:center;font-size:0.875rem;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;"]),Tn=ig.I4.div.withConfig({displayName:"CircleContainer",componentId:"sc-92716bea-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),Ti=(0,ig.I4)(h1.A).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-92716bea-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),Tr=ig.I4.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-92716bea-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),Ta=(0,ig.I4)(gn).withConfig({displayName:"RetryButton",componentId:"sc-92716bea-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),Ts=ig.I4.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-92716bea-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),To=ig.I4.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-92716bea-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),Tl=ig.I4.text.withConfig({displayName:"HelperText",componentId:"sc-92716bea-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),Tc=ig.I4.span.withConfig({displayName:"TextBox",componentId:"sc-92716bea-10"})(["position:relative;width:100%;background-color:var(--privy-color-background-2);padding:8px 12px;border-radius:10px;margin-top:5px;font-size:14px;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;",""],e=>e.$clickable&&"cursor: pointer;\n  transition: background-color 0.3s;\n  padding-right: 45px;\n\n  &:hover {\n    background-color: var(--privy-color-foreground-4);\n  }"),Td=(0,ig.I4)(pg.A).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-92716bea-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),Tu=(0,ig.I4)(ps.A).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-92716bea-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),Th=({clicked:e})=>(0,h.jsx)(e?Tu:Td,{}),Tp=({instruction:e,fees:t,transactionInfo:n,solPrice:i,rpcEndpoint:r})=>(0,h.jsxs)(Iw,{children:[n?.action&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Action"}),(0,h.jsx)(I_,{children:n.action})]}),null!=e?.total&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Total"}),(0,h.jsx)(I_,{children:e.total})]}),!e?.total&&null!=e?.amount&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Total"}),(0,h.jsx)(I_,{children:(0,h.jsx)(gq,{quantities:[e.amount,t],tokenPrice:i})})]}),(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"Fees"}),(0,h.jsx)(I_,{children:(0,h.jsx)(gq,{quantities:[t],tokenPrice:i})})]}),e?.to&&(0,h.jsxs)(Iv,{children:[(0,h.jsx)(Ib,{children:"To"}),(0,h.jsx)(I_,{children:(0,h.jsx)(ww,{walletAddress:e.to,rpcEndpoint:r,network:"solana"})})]})]}),Tm=({fees:e,onClose:t,receiptHeader:n,receiptDescription:i,transactionInfo:r,solPrice:a,rpcEndpoint:s,signOnly:o,instruction:l})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:t}
58),(0,h.jsx)(wP,{style:{marginBottom:"16px"},children:(0,h.jsxs)("div",{children:[(0,h.jsx)(bB,{color:"var(--privy-color-success-light)"}),(0,h.jsx)(pc.A,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),(0,h.jsx)(vT,{title:n??`Transaction ${o?"signed":"complete"}!`,description:i??"You're all set."}),(0,h.jsx)(Tp,{solPrice:a,instruction:l,fees:e,transactionInfo:r,rpcEndpoint:s}),(0,h.jsx)(fm,{}),(0,h.jsx)(Ty,{loading:!1,onClick:t,children:"Close"}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]}),Ty=(0,ig.I4)(gn).withConfig({displayName:"SubmitButton",componentId:"sc-df6d4eec-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),Tf={component:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:t,setModalData:n,navigate:i}=yQ(),{client:r,closePrivyModal:a,walletProxy:s,showFiatPrices:o}=(0,n8.u)(),l=yK(),{user:c}=(0,ic.u)(),[d,u]=(0,m.useState)(e?.sendSolanaTransaction?.transactionRequest),[p,y]=(0,m.useState)(),[f,g]=(0,m.useState)(),[w,v]=(0,m.useState)({value:0n,isLoading:!1}),[b,x]=(0,m.useState)(!1),[_,C]=(0,m.useState)(),[I,E]=(0,m.useState)(),T=e?.sendSolanaTransaction?.connection,A=e?.sendSolanaTransaction?.transactingWallet,S=!!e?.sendSolanaTransaction?.signOnly,k=A?.imported?(0,ic.e)(c):(0,ic.h)(c),P=yW(T?.rpcEndpoint||""),{solPrice:j,isSolPriceLoa
58ding:O}=wC({enabled:o}),N=(0,m.useMemo)(()=>{if(!p)return;let e=p.spender,t=gA(p.fee),n=gA(w.value,3,!0),i=p.instructions.filter(e=>["sol-transfer","spl-transfer","raydium-swap-base-input","raydium-swap-base-output","jupiter-swap-shared-accounts-route","jupiter-swap-exact-out-route"].includes(e.type)),r=i.at(0);return!r||i.length>1?{fee:t,spender:e,balance:n}:"sol-transfer"===r.type?{fee:t,spender:e,balance:n,total:gA(r.value)}:"spl-transfer"===r.type?{fee:t,spender:e,balance:n,total:`${em({amount:r.value,decimals:r.token.decimals})} ${r.token.symbol}`}:"raydium-swap-base-input"===r.type&&r.tokenIn&&r.tokenOut?{fee:t,spender:e,balance:n,swap:`${em({amount:r.amountIn,decimals:r.tokenIn.decimals})} ${r.tokenIn.symbol} → ${em({amount:r.minimumAmountOut,decimals:r.tokenOut.decimals})} ${r.tokenOut.symbol}`}:"raydium-swap-base-output"===r.type&&r.tokenIn&&r.tokenOut?{fee:t,spender:e,balance:n,swap:`${em({amount:r.maxAmountIn,decimals:r.tokenIn.decimals})} ${r.tokenIn.symbol} → ${em({amount:r.amountOut,decimals:r.tokenOut.decimals})} ${r.tokenOut.symbol}`}:"jupiter-swap-shared-accounts-route"===r.type&&r.tokenIn&&r.tokenOut?{fee:t,spender:e,balance:n,swap:`${em({amount:r.inAmount,decimals:r.tokenIn.decimals})} ${r.tokenIn.symbol} → ${em({amount:r.quotedOutAmount,decimals:r.tokenOut.decimals})} ${r.tokenOut.symbol}`}:"jupiter-swap-exact-out-route"===r.type&&r.tokenIn&&r.tokenOut?{fee:t,spender:e,balance:n,swap:`${em({amount:r.quotedInAmount,decimals:r.tokenIn.decimals})} ${r.tokenIn.symbol} → ${em({amount:r.outAmount,decimals:r.tokenOut.decimals})} ${r.tokenOut.symbol}`}:{fee:t,spender:e,balance:n}},[p,A?.address,w]),R=(0,m.useMemo)(()=>{let e;if(!p||!o||!j||O)return;function t(...e){return gS(e.reduce((e,t)=>e+t,0n),j??0)}A?.address===p.spender&&(e=t(p.fee));let n=t(w.value),i=p.instructions.filter(e=>"sol-transfer"===e.type||"spl-transfer"===e.type).at(0);return!i||p.instructions.length>1?{fee:e,balance:n}:"sol-transfer"===i.type?{fee:e,balance:n,total:t(i.value,A?.address===p.spender?p.fee:0n)}:"spl-transfer"===i.type?{fee:e,balance:n,total:`${em({amount:i.value,decimals:i.token.decimals})} ${i.token.symbol}`}:{fee:e,balance:n}},[p,o,j,O,A?.address,w]);if((0,m.useEffect)(()=>{!async function(){if(d&&T&&r)try{g(void 0);let e=await gD({tx:d,connection:T,client:r,checkFunds:!S});y(e)}catch(e){console.error("Failed to prepare transaction",e),g(e)}}()},[d,T,r,S]),(0,m.useEffect)(()=>{(async function(){if(!A||!T)return;v({value:w.value,isLoading:!0});let e=new eC({name:"mainnet-beta",rpcUrl:T.rpcEndpoint});v({value:await e.getBalance(A.address).catch(()=>0n)??0n,isLoading:!1})})().catch(console.error)},[p,T]),!(d&&e?.sendSolanaTransaction&&A&&T)){let t=Error("Invalid transaction request");return(0,h.jsx)(b8,{error:t,onClick:()=>{e?.sendSolanaTransaction?.onFailure(t),a({shouldCallAuthOnSuccess:!1})}})}let M=()=>{if(!b)return _?e?.sendSolanaTransaction?.onSuccess(_):e?.sendSolanaTransaction?.onFailure(I??f??Error("User exited the modal before submitting the transaction")),a({shouldCallAuthOnSuccess:!1})};t.current=M;let D=e.sendSolanaTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?(0,h.jsx)("img",{src:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,U=!!(e.funding&&e.funding.supportedOptions.length>0),L=!p?.hasFunds&&U;if(_){let t=p?.instructions.filter(e=>"sol-transfer"===e.type||"spl-transfer"===e.type),n=1===t?.length?t?.at(0):void 0;return(0,h.jsx)(Tm,{fees:_.fees,onClose:M,transactionInfo:e.sendSolanaTransaction?.uiOptions.transactionInfo,solPrice:j,receiptHeader:e.sendSolanaTransaction?.uiOptions.successHeader,receiptDescription:e.sendSolanaTransaction?.uiOptions.successDescription,rpcEndpoint:T.rpcEndpoint,signOnly:S,instruction:"sol-transfer"===n?.type?{to:n.toAccount,amount:n.value}:{to:n?.toAccount||n?.toAta,total:N?.total}})}return I?(0,h.jsx)(E7,{transactionError:I,connection:T,onClose:M,network:"solana",onRetry:async()=>{E(void 0);let{blockhash:e}=await T.getLatestBlockhash();gO(d)?d.message.recentBlockhash=e:d.recentBlockhash=e,u(d)}}):(0,h.jsx)(E2,{img:D,title:e.sendSolanaTransaction?.uiOptions?.transactionInfo?.title||"Confirm transaction",subtitle:e.sendSolanaTransaction?.uiOptions?.description||`${l.name} wants your permission to approve the following transaction.`,cta:L?"Add funds":e.sendSolanaTransaction?.uiOptions?.buttonText||"Approve",instructions:p?.instructions??[],network:"mainnet-beta"==P?"Solana":P,blockExplorerUrl:l.solanaClusters[P].blockExplorerUrl,total:o?R?.total:N?.total,fee:o?R?.fee:N?.fee,balance:o?R?.balance:N?.balance,swap:N?.swap,transactingWalletAddress:A.address,disabled:!p?.hasFunds&&!U,isSubmitting:b,isPreparing:!p||w.isLoading,isTokenPriceLoading:o&&O,isMissingFunds:!p?.hasFunds,submitError:I??void 0,parseError:f,onClick:L?async()=>
58{if(A){if(!U)throw Error("Funding wallet is not enabled");n({...e,funding:{...e.funding,methodScreen:EP}}),i(EP)}}:async()=>{try{if(x(!0),b||!A||!s||!c||!k)return;let t=await e.sendSolanaTransaction.onConfirm();C(t)}catch(e){console.warn({transaction:d,error:e}),E(e)}finally{x(!1)}},onClose:M})}},Tg=ig.I4.img.withConfig({displayName:"StyledLogo",componentId:"sc-68c1b1ea-0"})(["&&{height:",";width:",";border-radius:16px;margin-bottom:12px;}"],e=>"sm"===e.size?"65px":"140px",e=>"sm"===e.size?"65px":"140px"),Tw=({data:e})=>{let t=e=>"object"==typeof e&&null!==e?(0,h.jsx)(Tb,{children:Object.entries(e).map(([e,n])=>(0,h.jsxs)("li",{children:[(0,h.jsxs)("strong",{children:[e,":"]})," ",t(n)]},e))}):(0,h.jsx)("span",{children:String(e)});return(0,h.jsx)("div",{children:t(e)})},Tv=ig.I4.div.withConfig({displayName:"Message",componentId:"sc-ccf49562-0"})(["margin-top:1.5rem;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-md);padding:12px;text-align:left;max-height:310px;overflow:scroll;white-space:pre-wrap;width:100%;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]),Tb=ig.I4.ul.withConfig({displayName:"MessageList",componentId:"sc-ccf49562-1"})(["margin-left:12px !important;white-space:nowrap;&:first-child{margin-left:0 !important;}strong{font-weight:500 !important;}"]),Tx=({data:e})=>(0,h.jsx)(Tv,{children:(0,h.jsx)(Tw,{data:e})}),T_=e=>{let{types:t,primaryType:n,...i}=e.typedData;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Tx,{data:i}),(0,h.jsx)(xL,{text:JSON.stringify(e.typedData,null,2),itemName:"full payload to clipboard"})," "]})},TC={component:()=>{let{authenticated:e}=(0,ic.u)(),{initializeWalletProxy:t,closePrivyModal:n}=(0,n8.u)(),{navigate:i,data:r,onUserCloseViaDialogOrKeybindRef:a}=yQ(),[s,o]=(0,m.useState)(!0),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(),[p,y]=(0,m.useState)(null),[f,g]=(0,m.useState)(!1),v=null!==p;(0,m.useEffect)(()=>{e||i(CN)},[e]),(0,m.useEffect)(()=>{t(3e4).then(e=>{o(!1),e||(c("An error has occurred, please try again."),u(new m3(new m2(l,E.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))})},[]);let{method:b,data:x,confirmAndSign:_,onSuccess:C,onFailure:I,uiOptions:T}=r.signMessage,A={title:T?.title||"Sign message",description:T?.description||"Signing this message will not cost you any fees.",buttonText:T?.buttonText||"Sign and continue"},S=e=>{e?C(e):I(d||new m3(new m2("The user rejected the request.",E.E4001_USER_REJECTED_REQUEST.eipCode))),n({shouldCallAuthOnSuccess:!1}),setTimeout(()=>{y(null),c(""),u(void 0)},200)};return a.current=()=>{S(p)},(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:()=>S(p)}),(0,h.jsx)(g3,{}),T?.iconUrl&&"string"==typeof T.iconUrl?(0,h.jsx)(TT,{children:(0,h.jsx)(Tg,{size:"sm",src:T.iconUrl,alt:"app image"})}):null,(0,h.jsx)(Cq,{children:A.title}),(0,h.jsx)(Cz,{children:A.description}),"personal_sign"===b&&(0,h.jsx)(Tv,{children:(e=>{if(!(0,w.q)(e))return e;try{let t=(0,is.IQ)(e);return t.includes("�")?e:t}catch{return e}})(x)}),"eth_signTypedData_v4"===b&&(0,h.jsx)(T_,{typedData:x}),"solana_signMessage"===b&&(0,h.jsx)(Tv,{children:x}),(0,h.jsx)(TA,{}),(0,h.jsx)(TI,{$fail:!0,children:l}),(0,h.jsx)(gi,{disabled:f||v||s,loading:f,onClick:async()=>{g(!0),c("");try{let e=await _();y(e),g(!1),setTimeout(()=>{S(e)},1400)}catch(e){console.error(e),c("An error has occurred, please try again."),u(new m3(new m2(l,E.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),g(!1)}},children:f?"Signing...":v?(0,h.jsxs)(TE,{children:[(0,h.jsx)(xD,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",(0,h.jsx)("span",{children:"Success"})]}):A.buttonText}),T?.isCancellable&&(0,h.jsx)(gd,{style:{marginTop:"1rem"},onClick:()=>S(null),isSubmitting:!1,children:"Not now"}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}},TI=ig.I4.div.withConfig({displayName:"InputHelp",componentId:"sc-af56055-0"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-start;width:100%;margin-top:16px;margin-bottom:4px;"],e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)"),TE=ig.I4.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-af56055-1"})(["display:flex;align-items:center;gap:8px;"]),TT=ig.I4.div.withConfig({displayName:"IconContainer",componentId:"sc-af56055-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),TA=ig.I4.div.withConfig({displayName:"Grow",componentId:"sc-af56055-3"})(["flex-grow:1;"]),TS=()=>{let{exportSolanaWallet:e,solanaWallets:t,walletProxy:n,recoverEmbeddedWallet:i,privy:r}=(0,n8.u)(),{sendTransaction:a}=function(e){let t=yK(),{getAccessToken:n,user:i}=In(),{setModalData:r}=yQ(),{isHeadlessSigning:a,openModal:s,walletProxy:o,recoverEmbeddedWallet:l,privy:c}=(0,n8.u)(),d=fp(),{signWithUserSigner:u}=(0,ic.a)();return fu("sendSolanaTransaction",void 0),{sendTransaction:async({transaction:e,connection:h,uiOptions:p,transactionOptions:m,fundWalletConfig:y,address:f})=>await (({privy:e,appConfig:t,getAccessToken:n,isHeadlessSigning:i,emitPrivyEvent:r,setModalData:a,openModal:s,walletProxy:o,user:l,signWithUserSigner:c,recoverEmbeddedWallet:d},{transaction:u,connection:h,transactionOptions:p,fundWalletConfig:m,uiOptions:y,address:f,signOnly:g})=>new Promise(async(w,v)=>{let{requesterAppId:b}=y||{},x=g?"signSolanaTransaction":"sendSolanaTransaction";if(!l)return r(x,"onError",n6.a.MUST_BE_AUTHENTICATED),void v(new n6.P("User must be authenticated before signing with a Privy wallet",n6.a.MUST_BE_AUTHENTICATED));let _=f?(0,ic.b)(l,f):(0,ic.j)(l);if(!_)return r(x,"onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),void v(new n6.P("Must have a Privy wallet before signing",n6.a.EMBEDDED_WALLET_NOT_FOUND));let C=(0,ic.c)(_);if(!await d({address:_.address}
58).catch(()=>!1))throw r(x,"onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),new n6.P(`Cannot sendSolanaTransaction before embedded wallet ${_.address} is connected`,n6.a.EMBEDDED_WALLET_NOT_FOUND);let I=async()=>{let t=await n();if(!t||!o)throw r(x,"onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),v(new n6.P("Must have valid access token and Privy wallet to send transaction",n6.a.EMBEDDED_WALLET_NOT_FOUND)),new n6.P("Must have valid access token and Privy wallet to send transaction",n6.a.EMBEDDED_WALLET_NOT_FOUND);try{let n,a;if(!await d({address:_.address}))throw r(x,"onError",n6.a.UNKNOWN_CONNECT_WALLET_ERROR),v(new n6.P("Unable to connect to wallet",n6.a.UNKNOWN_CONNECT_WALLET_ERROR)),new n6.P("Unable to connect to wallet",n6.a.UNKNOWN_CONNECT_WALLET_ERROR);if(i({showWalletUIs:y?.showWalletUIs})&&!g)try{if(!await gM(u,h))throw r(x,"onError",n6.a.INSUFFICIENT_BALANCE),v(new n6.P("Solana wallet has insufficient funds for this transaction.",n6.a.INSUFFICIENT_BALANCE)),new n6.P("Solana wallet has insufficient funds for this transaction.",n6.a.INSUFFICIENT_BALANCE)}catch(e){throw console.error(e),r(x,"onError",n6.a.TRANSACTION_FAILURE),v(new n6.P(e instanceof Error?e.message:"Transaction failed.",n6.a.TRANSACTION_FAILURE)),new n6.P(e instanceof Error?e.message:"Transaction failed.",n6.a.TRANSACTION_FAILURE)}let{entropyId:s,entropyIdVerifier:m}=mY(l);if(C){let t=gO(u)?mD(u.message.serialize()):u.serializeMessage(),i=await M(e,c,{chain_type:"solana",method:"signMessage",params:{message:t.toString("base64"),encoding:"base64"},wallet_id:_.id});if(!i.data||!("signature"in i.data))throw Error("Failed to sign transaction");u.addSignature(gN(u,_.address),mD(i.data.signature,"base64")),n=u}else n=await C7({accessToken:t,tx:u,walletProxy:o,entropyId:s,entropyIdVerifier:m,transactingWalletAddress:_.address,transactingWalletIndex:_.walletIndex??0});if(g)return a=gR("",n,null),r("signSolanaTransaction","onSuccess",{signedTransaction:n}),w(a),a;{let{signature:e,receipt:t}=await async function({tx:e,connection:t,transactionOptions:n}){let i;try{let r=e.serialize();i=await t.sendRawTransaction(r,n);let a=await t.confirmTransaction(i);if(a.value.err||a.value.err){let e=a.value.err||a.value.err;if("string"==typeof e)throw Error(e);throw e}return{signature:i,signedTransaction:e,receipt:await t.getParsedTransaction(i,{maxSupportedTransactionVersion:0})}}catch(e){throw e.txSignature=i,e}}({tx:n,connection:h,transactionOptions:p});a=gR(e,u,t),r("sendSolanaTransaction","onSuccess",{response:a})}return w(a),a}catch(e){throw r(x,"onError",n6.a.TRANSACTION_FAILURE),v(e),e}};if(i({showWalletUIs:y?.showWalletUIs}))I();else{let{entropyId:e,entropyIdVerifier:n}=mY(l,_),i={recoveryMethod:_.recoveryMethod,connectingWalletAddress:_.address,entropyId:e,entropyIdVerifier:n,isUnifiedWallet:C,onCompleteNavigateTo:Tf,onFailure:e=>{r(x,"onError",n6.a.UNKNOWN_CONNECT_WALLET_ERROR),v(e)}},o=Ir(t)?function({address:e,fundWalletConfig:t,appConfig:n,comingFromSendTransactionScreen:i,methodScreen:r}){if(!n.fundingConfig)throw Error("Wallet funding is not enabled");let a=Ii(n.fundingConfig.options);if(a.length<1)throw Error("Wallet funding is not enabled");if("USDC"===t?.asset&&"testnet"===t?.cluster?.name)throw Error("USDC funding is not supported on the Solana testnet");let s=t?.amount??n.fundingConfig.defaultRecommendedAmount,o=t?.defaultFundingMethod;return{chainType:"solana",address:e,supportedOptions:a,amount:s,isUSDC:"USDC"===t?.asset,methodScreen:r,comingFromSendTransactionScreen:i,cluster:{name:t?.cluster?.name??"mainnet-beta",rpcUrl:n.solanaClusters[t?.cluster?.name??"mainnet-beta"].rpcUrl},crossChainBridgingEnabled:n.fundingConfig.crossChainBridgingEnabled??!1,defaultFundingMethod:o,preferredCardProvider:t?.card?.preferredProvider,usingDefaultFundingMethod:!!o,uiConfig:t?.uiConfig}}({address:_.address,appConfig:t,methodScreen:EP,fundWalletConfig:m,comingFromSendTransactionScreen:!0}):void 0;a({connectWallet:i,sendSolanaTransaction:{transactionRequest:u,connection:h,transactionOptions:p,transactingWallet:_,onConfirm:I,onSuccess:e=>{g?r("signSolanaTransaction","onSuccess",{signedTransaction:e.signedTransaction}):r("sendSolanaTransaction","onSuccess",{response:e}),w(e)},onFailure:e=>{r(x,"onError",n6.a.TRANSACTION_FAILURE),v(e)},uiOptions:y||{},requesterAppId:b,signOnly:g},funding:o}),s(EB)}}))({privy:c,appConfig:t,getAccessToken:n,isHeadlessSigning:a,emitPrivyEvent:d,setModalData:r,openModal:s,walletProxy:o,user:i,signWithUserSigner:u,recoverEmbeddedWallet:l},{transaction:e,connection:h,transactionOptions:m,uiOptions:p,fundWalletConfig:y,address:f,signOnly:!1})}}(),{signMessage:s}=function(e){let{isHeadlessSigning:t,walletProxy:n,initializeWalletProxy:i,recoverEmbeddedWallet:r,openModal:a,privy:s}=(0,n8.u)(),{user:o,getAccessToken:l}=In(),c=fp(),{setModalData:d}=yQ(),{signWithUserSigner:u}=(0,ic.a)();
58return fu("signSolanaMessage",void 0),{signMessage:({message:e,options:h})=>new Promise(async(p,m)=>{if(!o)return c("signSolanaMessage","onError",n6.a.MUST_BE_AUTHENTICATED),void m(Error("User must be authenticated before signing with a Privy wallet"));let y=h?.address?(0,ic.b)(o,h.address):(0,ic.j)(o);if(!y)return c("signSolanaMessage","onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),void m(Error("Must have a Privy wallet before signing"));let{entropyId:f,entropyIdVerifier:g}=mY(o,y),w=(0,ic.c)(y),v=mD(e).toString("base64");if(v.length<1)return c("signMessage","onError",n6.a.INVALID_MESSAGE),void m(Error("Message must be a non-empty string"));let b=async()=>{let e;if(!o)throw Error("User must be authenticated before signing with a Privy wallet");let t=await l();if(!t)throw Error("User must be authenticated to use their embedded wallet.");let a=n??await i(15e3);if(!a)throw Error("Failed to initialize embedded wallet proxy.");if(!await r({address:y.address}))throw Error("Unable to connect to wallet");if(w){let t=await M(s,u,{chain_type:"solana",method:"signMessage",params:{message:v,encoding:"base64"},wallet_id:y.id});if(!t.data||!("signature"in t.data))throw Error("Failed to sign message");e=t.data.signature}else{let{response:n}=await a.rpc({accessToken:t,entropyId:f,entropyIdVerifier:g,chainType:"solana",hdWalletIndex:y.walletIndex??0,request:{method:"signMessage",params:{message:v}}});e=n.data.signature}return e};if(t({showWalletUIs:h?.uiOptions?.showWalletUIs}))try{let e=await b(),t=new Uint8Array(mD(e,"base64"));c("signSolanaMessage","onSuccess",{signature:t}),p(t)}catch(e){m(e)}else d({signMessage:{method:"solana_signMessage",data:v,confirmAndSign:b,onSuccess:e=>{let t=new Uint8Array(mD(e,"base64"));c("signSolanaMessage","onSuccess",{signature:t}),p(t)},onFailure:e=>{m(e)},uiOptions:h?.uiOptions},connectWallet:{recoveryMethod:y.recoveryMethod,connectingWalletAddress:y.address,entropyId:f,entropyIdVerifier:g,isUnifiedWallet:w,onCompleteNavigateTo:TC,onFailure:e=>{c("signSolanaMessage","onError",n6.a.UNKNOWN_CONNECT_WALLET_ERROR),m(e)}}}),a(EB)})}}(),{create:o}=It(),{signWithUserSigner:l}=(0,ic.a)(),{user:c,getAccessToken:d}=In(),{ready:u}=wT(),h=(0,m.useMemo)(()=>{if(!n)return t;let e=[...(0,ic.d)(c),(0,ic.e)(c)].filter(e=>!!e).map(e=>({type:"solana",imported:e.imported,address:e.address,connectedAt:Date.now(),walletClientType:"privy",connectorType:"embedded",walletIndex:e.walletIndex??void 0,meta:{name:"Privy Wallet",icon:void 0,id:"io.privy.solana.wallet"},linked:!0,fund(){throw new n6.P("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:()=>{throw new n6.P("Cannot unlink an embedded Solana wallet")},async getProvider(){return new C8(n,e.address,this.signMessage)},signMessage:async t=>await s({message:t,options:{address:e.address,uiOptions:{showWalletUIs:!1}}}),async sendTransaction(t,n,i){let{signature:r}=await a({transaction:t,connection:n,transactionOptions:i,address:e.address});return r},async signTransaction(t){let a=await d();if(!a||!n)throw new n6.P("Must have valid access token and Privy wallet to send transaction",n6.a.MUST_BE_AUTHENTICATED);if(!await i({address:e.address}).catch(()=>!1))throw new n6.P("Wallet couldn't be connected",n6.a.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:s,entropyIdVerifier:o}=mY(c,e);if((0,ic.c)(e)){let n=gO(t)?mD(t.message.serialize()):t.serializeMessage(),i=await M(r,l,{chain_type:"solana",method:"signMessage",params:{message:n.toString("base64"),encoding:"base64"},wallet_id:e.id});if(i.data&&"signature"in i.data)return t.addSignature(gN(t,e.address),mD(i.data.signature,"base64")),t;throw Error("Failed to sign transaction")}return await C7({tx:t,accessToken:a,walletProxy:n,entropyId:s,entropyIdVerifier:o,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0})},async signAllTransactions(t){let a=await d();if(!a||!n)throw new n6.P("Must have valid access token and Privy wallet to send transaction",n6.a.MUST_BE_AUTHENTICATED);if(!await i({address:e.address}).catch(()=>!1))throw new n6.P("Wallet couldn't be connected",n6.a.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:s,entropyIdVerifier:o}=mY(c,e);if((0,ic.c)(e))return await Promise.all(t.map(async t=>{let n=gO(t)?mD(t.message.serialize()):t.serializeMessage(),i=await M(r,l,{chain_type:"solana",method:"signMessage",params:{message:n.toString("base64"),encoding:"base64"},wallet_id:e.id});if(i.data&&"signature"in i.data)return t.addSignature(gN(t,e.address),mD(i.data.signature,"base64")),t;throw Error("Failed to sign transaction")}));for(let i of t)await C7({tx:i,accessToken:a,walletProxy:n,entropyId:s,entropyIdVerifier:o,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0});return t},loginOrLink:async()=>{throw new n6.P("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{},isConnected:async()=>!0}));return t.concat(e)},[c,n,d,t]);return{ready:!(!u||!n),createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let{account:t}=await o({chainType:"solana",options:e});return t},exportWallet:e,wallets:h}},Tk={component:()=>{let{wallets:e}=wT(),{wallets:t}=TS(),{data:n,setModalData:i,navigate:r,lastScreen:a}=yQ(),{rpcConfig:s,appId:o,createAnalyticsEvent:l,closePrivyModal:c}=(0,n8.u)(),d=yK(),[u,p]=(0,m.useState)(void 0),[y,f]=(0,m.useState)(!1),g=_A(),w=n?.funding,{reloadBalance:v}=C1({rpcConfig:s,appId:o,address:"ethereum"===w.chainType?w.address:void 0,chain:"ethereum"===w.chainType?w.chain:void 0}),b="solana"===w.chainType,x=b?w.isUSDC?"USDC":"SOL":w.erc20Address?w.erc20ContractInfo?.symbol
58:w.chain.nativeCurrency.symbol,_=b?t.find(({address:e})=>e===w.address):e.find(({address:e})=>p$(e)===p$(w.address));if(!w)return i({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:a||EP},funding:n?.funding,sendTransaction:n?.sendTransaction}),r(b6),(0,h.jsx)(h.Fragment,{});(0,m.useEffect)(()=>{let e=b?async function(){if("solana"!==w.chainType)return;let e=g(C5);e?(w.isUSDC?e.getTokenBalance({address:w.address,cluster:w.cluster,mintAddress:ed[w.cluster.name]}).then(({amount:e})=>e):e.getBalance({address:w.address,cluster:w.cluster})).then(e=>{let t=BigInt(e);u&&t>u&&(f(!0),l({eventName:C2,payload:{provider:"manual",status:"success",chainType:"solana",address:_?.address,value:w.isUSDC?(0,eh.J)(t-u,6):(0,eh.J)(t-u,9),token:w.isUSDC?"USDC":"SOL"}})),p(t)}):console.warn("Unable to load solana plugin, skipping balance")}:async function(){"ethereum"===w.chainType&&(async()=>{if(!w.erc20Address)return await v()??BigInt(0);{let{balance:e}=await C3({chain:w.chain,address:w.address,erc20Address:w.erc20Address,rpcConfig:s,appId:o});return e}})().then(e=>{u&&e>u&&(f(!0),l({eventName:C2,payload:{provider:"manual",status:"success",chainType:"ethereum",address:_?.address,chainId:w.chain.id,value:(0,eh.J)(e-u,w.erc20ContractInfo?.decimals??18),token:w.erc20ContractInfo?.symbol??w.erc20Address??"ETH"}})),p(e)}).catch(()=>p(void 0))},t=setInterval(e,2e3);return e(),()=>clearInterval(t)},[u]);let C=(0,m.useMemo)(()=>void 0!==u&&u>=parseFloat(w.amount),[u,w.amount]),I=(0,m.useMemo)(()=>null==u?"":w.isUSDC?em({amount:u,decimals:6}):b?gA(u,3,!0,!0):null!=w.erc20ContractInfo?.decimals?em({amount:u,decimals:w.erc20ContractInfo.decimals}):function({wei:e,precision:t=3}){return parseFloat((0,eu.c)(e)).toFixed(t).replace(/0+$/,"").replace(/\.$/,"")}({wei:u}),[u,b,w]),E="ethereum"===w.chainType?w.chain.name:Tj[w.cluster.name],T=(0,m.useMemo)(()=>""===w.uiConfig?.receiveFundsTitle?null:(0,h.jsx)(Cq,{children:w.uiConfig?.receiveFundsTitle??`Receive ${w.amount} ${x??""}`.trim()}),[w.uiConfig?.receiveFundsTitle,w.amount,x]),A=(0,m.useMemo)(()=>""===w.uiConfig?.receiveFundsSubtitle?null:(0,h.jsx)(Cz,{children:w.uiConfig?.receiveFundsSubtitle??`Scan this code or copy your wallet address to receive funds on ${E}.`}),[w.uiConfig?.receiveFundsSubtitle,E]),S="solana"===w.chainType&&w.isUSDC&&ed[w.cluster.name]?`?spl-token=${ed[w.cluster.name]}`:"";return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),T,A,(0,h.jsxs)(g0,{style:{gap:"1rem",margin:T||A?"1rem 0":"0"},children:[(0,h.jsx)(xZ,{url:`${w.chainType}:${w.address}${S}`,size:200,squareLogoElement:TP}),(0,h.jsxs)(CK,{theme:d.appearance.palette.colorScheme,children:["Make sure to send funds on ",E,"."]}),(0,h.jsx)(C0,{title:"Your wallet",errMsg:void 0,showIcon:!0,isLoading:!w||void 0===u,isPulsing:!C,balance:`${I} ${x}`,address:w.address,statusColor:C?"green":"gray"}),y&&(0,h.jsx)(gn,{onClick:()=>c({shouldCallAuthOnSuccess:!1,isSuccess:!0}),children:"Continue"})]}),(0,h.jsx)(fk,{})]})}},TP=({...e})=>(0,h.jsx)(yr,{color:"black",...e}),Tj={devnet:"Devnet","mainnet-beta":"Solana",testnet:"Testnet"},TO=[{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],TN=ig.I4.div.withConfig({displayName:"Container",componentId:"sc-b3a607dd-0"})(["display:flex;flex-direction:column;min-height:72px;"]);var TR=({onBack:e,details:t})=>(0,h.jsxs)(TN,{children:[(0,h.jsx)(fR,{backFn:e}),(0,h.jsx)(Tx,{data:t}),(0,h.jsx)(fk,{})]});let TM=({txn:e,receipt:t,transactionInfo:n,onClose:i,tokenPrice:r,tokenSymbol:a,receiptHeader:s,receiptDescription:o})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:i}),(0,h.jsx)(vI,{title:s??"Transaction complete!",description:o??"You're all set."}),(0,h.jsx)(wb,{tokenPrice:r,from:t.from,to:t.to,gas:(({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return(0,g.nj)(e*t)}catch(e){return}})(t),txn:e,transactionInfo:n,tokenSymbol:a}),(0,h.jsx)(fm,{}),(0,h.jsx)(TD,{loading:!1,onClick:i,children:"All Done"}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]}),TD=(0,ig.I4)(gn).withConfig({displayName:"SubmitButton",componentId:"sc-f70d0f7a-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),TU=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],TL=[{name:"from",type:"address"},{name:"param2",type:"address"},{name:"param3",type:"bytes"},{name:"param4",type:"tuple",components:[]},{type:"tuple",components:[{name:"param5",type:"address"},{name:"param6",type:"uint256"},{name:"param7",type:"uint256"},{name:"encodedInitData",type:"bytes"}]}],TF=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],TW=[{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"payable",type:"function"}],T$=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],TB=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Tz=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Tq=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenIds",type:"uint256[]"},{name:"_amounts",type:"uint256[]"},{name:"_data",type:"bytes"}],name:"safeBatchTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],TV=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"},{name:"_amount",type:"uint256"},{name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],TH=(e,t)=>{let n=TG(TF,e);if(n)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:n.args[0],amount:n.args[
581]};let i=TG(Ik,e);if(i)return{action:"transfer",functionName:"transfer",isErc20Ish:!0,isNFTIsh:!1,transferTo:i.args[0],amount:i.args[1]};if(!t)return{action:"transaction",functionName:"",isErc20Ish:!1,isNFTIsh:!1};let r=TG(TU,e);if(r&&"string"==typeof r.args[1]){let e=TK(r.args[1]);if(e&&e[4].encodedInitData)return TH(e[4].encodedInitData,t)}let a=TG(TB,e);if(a)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:a.args[0],approved:a.args[1]};let s=TG(Tz,e);if(s)return{action:"transfer",functionName:"transferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:s.args[0],transferTo:s.args[1],tokenId:s.args[2]};let o=TG(T$,e);if(o)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:o.args[0],transferTo:o.args[1],tokenId:o.args[2]};let l=TG(TV,e);if(l)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:l.args[0],transferTo:l.args[1],tokenId:l.args[2],amount:l.args[3]};let c=TG(Tq,e);if(c)return{action:"batch transfer",functionName:"safeBatchTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:c.args[0],transferTo:c.args[1],tokenIds:c.args[2],amounts:c.args[3]};let d=TG(TW,e);return d?{action:"mint",functionName:d.functionName,isNFTIsh:!0,isErc20Ish:!1,args:d.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}},TG=(e,t)=>{try{let n=(0,io.J)({abi:e,data:t});return{functionName:n.functionName,args:n.args||[]}}catch(e){return null}},TK=e=>{try{if("string"==typeof e)return(0,il.n)(TL,`0x${e.slice(10)}`)}catch(e){return null}},TJ=e=>`${parseFloat(e).toFixed(2)}`,TZ=new m3(new m2("There was an issue preparing your transaction",E.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),TY=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0,TQ={component:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:t,setModalData:n,navigate:i}=yQ(),{rpcConfig:r,chains:a,closePrivyModal:s,walletProxy:o,showFiatPrices:l}=(0,n8.u)(),{getAccessToken:c,user:d}=(0,ic.u)(),u=yK(),[p,y]=(0,m.useState)(0),[f,g]=(0,m.useState)(0),[w,v]=(0,m.useState)(TY(e,p)),[b,x]=(0,m.useState)(null),[_,I]=(0,m.useState)(),[T,A]=(0,m.useState)(!1),[S,k]=(0,m.useState)(null),[P,j]=(0,m.useState)(null),[O,N]=(0,m.useState)(null),[R,M]=(0,m.useState)(void 0),[D,U]=(0,m.useState)(void 0),[L,F]=(0,m.useState)(!1),[W,$]=(0,m.useState)(!1),[B,z]=(0,m.useState)([]),[q,V]=(0,m.useState)([]),[H,G]=(0,m.useState)("uninitiated"),[K,J]=(0,m.useState)(void 0);if(!w||!e?.sendTransaction||!e?.sendTransaction)return(0,h.jsx)(b8,{error:Error("Invalid transaction request"),onClick:()=>{e?.sendTransaction?.onFailure(TZ),s({shouldCallAuthOnSuccess:!1})}});let{entropyId:Z,entropyIdVerifier:Y,transactingWalletIndex:Q,transactingWalletAddress:X}=e.sendTransaction,ee=(0,m.useMemo)(()=>a.find(e=>Number(e.id)===Number(w.chainId)),[w.chainId]),et=ee?.nativeCurrency.symbol??"ETH",en=(0,m.useMemo)(()=>TH(w.data,!!u.embeddedWallets.extendedCalldataDecoding),[w.data]),{action:ei,isErc20Ish:er,isNFTIsh:ea}=en,{toAddress:es,tokenAddress:eo}=(0,m.useMemo)(()=>({toAddress:en.isErc20Ish?en.transferTo:w.to??void 0,tokenAddress:en.isErc20Ish?w.to:void 0}),[en]);(0,m.useEffect)(()=>{w.to&&ee&&er&&Iu({address:w.to,chain:ee,rpcConfig:u.rpcConfig,privyAppId:u.id}).then(x).catch(console.error)},[w.to,ee]);let{tokenPrice:el,isTokenPriceLoading:ec}=wI(w.chainId),{balance:ed}=C1({rpcConfig:u.rpcConfig,appId:u.id,address:X,chain:ee}),eh=function({rpcConfig:e,appId:t,address:n,chain:i,tokenInfo:r}){let{chains:a}=(0,n8.u)(),[s,o]=(0,m.useState)(null),[l,c]=(0,m.useState)(!1),d=(0,m.useMemo)(()=>{let n=i||a[0];if(n)return(0,n7.l)({chain:i,transport:(0,n9.L)(((e,t,n)=>{let i,r=e.id,a=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])i=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[a])i=t.rpcUrls[a];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",n),i=t.toString()}else i=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!i)throw new C(`No RPC url found for ${r}`);return i})(n,e,t))})},[i,e,t]),u=(0,m.useCallback)(async()=>
58{if(n&&d&&r.address)try{return c(!0),await d.readContract({address:r.address,abi:TO,functionName:"balanceOf",args:[n]})}catch(e){console.error(e)}finally{c(!1)}},[d,n,r?.address,i]);return(0,m.useEffect)(()=>{u().then(e=>null!=e&&o(e))},[u]),{balance:s,isLoading:l&&null==s,formattedBalance:em({amount:s??BigInt(0),decimals:r.decimals})}}({rpcConfig:u.rpcConfig,appId:u.id,address:X,tokenInfo:{address:eo||"",decimals:b?.decimals??18},chain:ee}),ep=(0,m.useMemo)(()=>pL(Number(w.chainId),a,r,{appId:u.id}),[w.chainId,r]),ey=((e,t,n,i)=>{let[r,a]=(0,m.useState)(null),{getAccessToken:s}=(0,ic.u)(),{walletProxy:o}=(0,n8.u)();return(0,m.useEffect)(()=>{r&&a(null),(async()=>{if(!await s()||!o||!t)return null;let r=[],a=!0,l=await wA(e,n,t,i).catch(t=>(t.message&&t.message.includes("Insufficient balance for transaction")||t.details&&t.details.includes("insufficient funds")?a=!1:r.push(t),e));return{tx:l,totalGasEstimate:l.gas,hasFunds:a,errors:r}})().then(a)},[e]),r})(w,X,ep,e?.sendTransaction?.prepareTransactionRequest);(0,m.useEffect)(()=>{v(TY(e,p))},[p]),(0,m.useEffect)(()=>{e.sendTransaction?.getIsSponsored?e.sendTransaction.getIsSponsored().then(I).catch(console.error):I(!1)},[e.sendTransaction.getIsSponsored]);let ef=()=>{if(!T)return S?e?.sendTransaction?.onSuccess({hash:S}):O||ey?.errors[0]?e?.sendTransaction?.onFailure(O??ey?.errors[0]??TZ):e?.sendTransaction?.onFailure(new m3(new m2("The user rejected the request",E.E4001_USER_REJECTED_REQUEST.eipCode))),s({shouldCallAuthOnSuccess:!1})};t.current=ef;let eg=!!(e.funding&&e.funding.supportedOptions.length>0),ew=gv(BigInt(ey?.totalGasEstimate??0n),et),ev=l&&el?gw(BigInt(ey?.totalGasEstimate??0n),el):void 0,eb=gv(ed??0n,et,void 0,!0),ex=l&&el?gw(ed??0n,el):void 0,e_=b&&!eh.isLoading&&er&&"approve"!==ei?`${eh.formattedBalance} ${b.symbol}`:void 0,eC=e.sendTransaction?.uiOptions?.transactionInfo?.title;eC||(eC="approve"===ei?er?"Confirm address":"Confirm action":`Approve ${ei}`);let eI=e.sendTransaction?.uiOptions?.description||(er&&"approve"===ei?`${u.name} would like your permission for ${p$(en.spender)} to spend tokens on your behalf.`:`${u.name} wants your permission to approve the following transaction.`),eE=e.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?(0,h.jsx)("img",{src:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,eT=!(!ey||ey.errors[0]||ey.hasFunds||!1!==_),eA=eT&&eg,eS=eA?"Add funds":e.sendTransaction?.uiOptions?.buttonText||(p<f?"Continue":"Approve");if((0,m.useEffect)(()=>{e.sendTransaction?.scanTransaction&&u.embeddedWallets.transactionScanning.enabled&&"uninitiated"===H&&(G("in progress"),e.sendTransaction.scanTransaction().then(e=>{(e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?U("safe"):"Warning"===e.validation.result_type?U("warn"):"Malicious"===e.validation.result_type&&(U("error"),$(!0))),"Success"!==e.simulation.status)throw Error("Simulation failed");{M(e.simulation.params);let{assetsIn:t,assetsOut:n}=function(e,t){let n=[],i=[];if(e){for(let t of e)if(t.in[0]){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.in[0].value?{nftName:t.asset.name,nftCount:t.in.length}:{iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price?TJ(t.in[0].usd_price):void 0},n.push(e)}else if(t.out[0]?.value){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.out[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.out[0].value,symbol:t.asset.symbol,usdValue:t.out[0].usd_price?TJ(t.out[0].usd_price):void 0},i.push(e)}}for(let e of t)for(let t of Object.keys(e.spenders)){let n;n="ERC721"===e.asset.type||"approve_for_all"===e.spenders[t]?.value?{nftName:e.asset.name}:{iconUrl:e.asset.logo_url,value:e.spenders[t]?.value,symbol:e.asset.symbol,usdValue:e.spenders[t]?.usd_price?TJ(e.spenders[t]?.usd_price):void 0},i.push(n)}return{assetsIn:n,assetsOut:i}}(e.simulation.assets_diffs,e.simulation.exposures);if(0===n.length&&0===t.length)throw Error("No tokens found");z(n),V(t)}})(e),G("completed")}
58).catch(()=>G("failed")))},[!!e.sendTransaction?.scanTransaction]),(0,m.useEffect)(()=>{e.sendTransaction?.scanTransaction&&"failed"!==H||((t,n,i)=>{if(g((e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(e)),n.isErc20Ish&&n.amount&&i){let e=Ij({amount:n.amount,decimals:i.decimals});J(e),z([{value:e,symbol:i?.symbol}])}else if(t.value){let e=BigInt(t.value),n=el&&gw(e,el);z(l&&n?[{value:n}]:[{value:gb(e),symbol:et}])}else z(l?[{value:"$0"}]:[{value:"0",symbol:et}])})(ey?.tx??w,en,b)},[w,ey?.tx,en,b,H]),P)return(0,h.jsx)(TM,{txn:ey?.tx??w,onClose:ef,receipt:P,transactionInfo:e.sendTransaction?.uiOptions.transactionInfo,tokenPrice:el,tokenSymbol:et,receiptHeader:e.sendTransaction?.uiOptions.successHeader,receiptDescription:e.sendTransaction?.uiOptions.successDescription});if(O)return(0,h.jsx)(E7,{transactionError:O,transactionHash:S??void 0,network:"ethereum",chainId:ey?.tx.chainId??w.chainId,onClose:ef,onRetry:({resetNonce:e})=>{N(null);let t={...ey?.tx??w};e&&(t.nonce=void 0),v(t)}});let ek=0!==f&&"number"==typeof p&&0!==p?()=>{y(p-1)}:void 0;return L&&R?(0,h.jsx)(TR,{details:R,onBack:()=>F(!1)}):(0,h.jsx)(E1,{transactionIndex:p,onBack:ek,maxIndex:f,disabled:eT&&!eg||W,isSubmitting:T,submitError:O,isPreparing:!ey,isTokenPriceLoading:ec,isTokenContractInfoLoading:!ea&&!b,prepareError:ey?.errors[0],symbol:b?.symbol,chain:ee,img:eE,title:eC,subtitle:eI,txValue:w.value,fee:ev??ew,isSponsored:_,from:X??"",to:es,tokenAddress:eo??void 0,network:u.chains.find(e=>e.id===w.chainId)?.name??"",transactionDetails:{...en,formattedAmount:K},cta:eS,missingFunds:eT,action:ei,balance:e_??ex??eb,onClose:ef,onClick:eA?async()=>{if(X){if(!eg)throw Error("Funding wallet is not enabled");n({...e,funding:{...e.funding,methodScreen:EP,chainType:"ethereum",amount:(0,eu.c)(BigInt(ey?.tx.value??0)+BigInt(ey?.totalGasEstimate?.toString()??0)),chain:ee}}),i(EP)}}:async()=>{if(p<f)y(p+1);else{A(!0);try{let t=await c();if(T||!t||!o||!d)return;let n=e?.sendTransaction?.onConfirm?await e.sendTransaction.onConfirm():await async function({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWalletIndex:i,walletProxy:r,transactionRequest:a,publicClient:s,requesterAppId:o}){let l=await vp({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWalletIndex:i,walletProxy:r,transactionRequest:a,requesterAppId:o});return await s.sendRawTransaction({serializedTransaction:l})}({accessToken:t,transactingWalletIndex:Q,entropyId:Z,entropyIdVerifier:Y,walletProxy:o,transactionRequest:ey?.tx??w,publicClient:ep,requesterAppId:e.sendTransaction?.requesterAppId});if(k(n),e.sendTransaction?.signOnly)return await new Promise(e=>setTimeout(e,1400)),e?.sendTransaction?.onSuccess({hash:n}),s({shouldCallAuthOnSuccess:!1});let i=await ep.waitForTransactionReceipt({hash:n});if("reverted"===i.status)throw Error("Transaction failed");j(i)}catch(e){console.warn({transaction:ey?.tx??w,error:e}),N(e)}finally{A(!1)}}},validation:D,hasScanDetails:!!R,setIsScanDetailsOpen:F,preventMaliciousTransaction:W,setPreventMaliciousTransaction:$,tokensSent:B,tokensReceived:q,isScanning:"in progress"===H,isCancellable:e.sendTransaction?.uiOptions?.isCancellable??!1})}};function TX({title:e}){let{currentScreen:t,navigateBack:n,navigate:i,data:r,setModalData:a}=yQ();return(0,h.jsx)(fR,{title:e,backFn:t===Tk?n:t===r?.funding?.methodScreen?r.funding.comingFromSendTransactionScreen?()=>i(TQ):void 0:r?.funding?.methodScreen?()=>{let e=r.funding;e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),a({funding:e}),i(e.methodScreen)}:void 0})}let T0={component:()=>{let{rpcConfig:e,appId:t,closePrivyModal:n,createAnalyticsEvent:i}=(0,n8.u)(),{navigate:r,setModalData:a,app:s,data:o}=yQ(),{wallets:l}=wT(),c=_A(),[d,u]=(0,m.useState)(null),[p,y]=(0,m.useState)(null),[f,g]=(0,m.useState)([]),[w,v]=(0,m.useState)(0),[b,x]=(0,m.useState)(!1),[_,C]=(0,m.useState)(!1),[I,E]=(0,m.useState)(!1),[T,A]=(0,m.useState)(!1),[S,k]=(0,m.useState)(),[P,j]=(0,m.useState)();if(!o?.funding||"solana"!==o.funding.chainType)throw Error("Invalid funding data");let{address:O,cluster:N,connectedWalletAddress:R}=o.funding,[M,D]=(0,m.useState)(o.funding.amount),U=R?l.find(({address:e})=>e===R):l[0],F=yO(U?.walletClientType||"unknown"),W=F?.name||"wallet",[$,B]=(0,m.useState)(null);(0,m.useEffect)(()=>{(async()=>
58{if(!U)return;let e=await U.getEthereumProvider();B((0,it.F)({account:U.address,transport:(0,ii.I)(e)}).extend(ir.$))})().catch(console.error)},[U]);let[z,q]=(0,m.useState)(0n),V=gA(z);(0,m.useEffect)(()=>{let e=c(C5);e?e.getBalance({address:O,cluster:N}).then(e=>q(BigInt(e))):console.warn("Unable to load solana plugin, skipping balance")},[]);let[H,G]=(0,m.useState)(),{tokenPrice:K}=wI("solana"),{fundingAmountInBaseUnit:J,fundingAmountInUsd:Z}=gk({amount:M,fee:0n,tokenPrice:K,isUsdc:o.funding.isUSDC});if((0,m.useEffect)(()=>{(async()=>{if(!$||!U)return;let n=["testnet","devnet"].includes(N.name);n&&console.warn("Solana testnets are not supported for bridging");let i=(0,L.u)(s.chains).filter(({testnet:e})=>!!e===n),r=(await IO({chains:i,address:U.address,appId:t,rpcConfig:e})).filter(e=>e.balance>0n);if(r.length<1)return void u(new n6.P(`Wallet ${p$(U.address)} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE));r.sort((e,t)=>Number(t.balance-e.balance));let a=(await Promise.allSettled(r.map(async e=>({...e,quote:await b1({isTestnet:!1,input:bQ({amount:J.toString(),user:U.address,recipient:O,destinationChainId:0x2f3fb341,destinationCurrency:yF,originChainId:e.chain.id})})})))).filter(e=>"fulfilled"===e.status).map(e=>e.value);if(a.length<1)return void u(new n6.P(`Unable to fetch quotes for bridging. Wallet ${p$(U.address)} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE));let o=a.map(({quote:e,balance:t,chain:n})=>({bridgeTx:b2(e),balance:t,chain:n,isErc20Quote:!1})).filter(({bridgeTx:e})=>!!e);if(o.length>1)return void g(o);let l=o.at(0);l?(C(!0),G({data:l.bridgeTx.data,to:l.bridgeTx.to,value:l.bridgeTx.value,chain:l.chain})):u(new n6.P(`Unable to select bridge option from quotes. Wallet ${p$(U.address)} does not have enough funds.`,void 0,n6.a.INSUFFICIENT_BALANCE))})().catch(console.error)},[$]),(0,m.useEffect)(()=>{(async()=>{let n,r;if(!$||!U||b||I||!H)return;x(!0);let a=(0,n7.l)({chain:H.chain,transport:(0,n9.L)(pF(H.chain,e,t))});try{n=await a.prepareTransactionRequest({account:U.address,to:H.to,chain:H.chain,data:H.data,value:BigInt(H.value??0)})}catch(e){console.error(e),f.length>1&&y(e.shortMessage??"Something went wrong")}if(n){x(!1),E(!0);try{await $.switchChain({id:H.chain.id})}catch(e){await $.addChain({chain:H.chain}),await $.switchChain({id:H.chain.id})}try{r=await $.sendTransaction(n)}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(f.length<1?u(new n6.P(e.shortMessage,void 0,n6.a.TRANSACTION_FAILURE)):y(e.shortMessage??"Something went wrong"))}if(r)return await $.waitForTransactionReceipt({hash:r}),_?(j("pending"),void k(r)):(E(!1),A(!0),void i({eventName:C2,payload:{provider:"external",status:"success",txHash:r,address:U.address,chainId:H.chain.id,chainType:"ethereum",value:H.value?(0,eh.J)(BigInt(H.value),18):void 0,token:"ETH",destination:O,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:(0,eh.J)(J,9),destinationToken:"SOL"}}));E(!1)}else x(!1)})().catch(console.error)},[$,H]),b3({transactionHash:S,wallet:U,isTestnet:!1,bridgingStatus:P,setBridgingStatus:j,onSuccess({transactionHash:e,wallet:t}){C(!1),A(!0),i({eventName:C2,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:H?.chain.id,chainType:"ethereum",value:H?.value?(0,eh.J)(BigInt(H.value),18):void 0,token:"ETH",destination:O,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:(0,eh.J)(J,9),destinationToken:"SOL"}})},onFailure({error:e}){C(!1),u(e)}}),(0,m.useEffect)(()=>{d&&(a({funding:o?.funding,sendTransaction:o?.sendTransaction,errorModalData:{error:d,previousScreen:Eu}}),r(b6,!1))},[d]),(0,m.useEffect)(()=>{if(!T)return;let e=setTimeout(n,4e3);return()=>clearTimeout(e)},[T]),T)return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(g3,{}),(0,h.jsxs)(gX,{children:[(0,h.jsx)(pc.A,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),(0,h.jsx)(vT,{title:"Success!",description:`You’ve successfully added ${M} SOL to your ${s.name} wallet. It may take a minute before the funds are available to use.`})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]});let Y=f[w];return f.length>1&&Y?(0,h.jsx)(Eo,{displayName:W,configuredFundingChain:N,formattedBalance:V,fundingAmount:M,fundingCurrency:"SOL",fundingAmountInUsd:Z,options:f,selectedOption:Y,isPreparing:b,isSubmitting:I,addressToFund:O,fundingWalletAddress:U?.address||"",errorMessage:p,onSubmit:()=>{o.funding?.amount!==M?(async function(){if(U&&Y)try{let e=await b1({isTestnet:!1,input:bQ({amount:J.toString(),user:U.address,recipient:O,de
58stinationChainId:0x2f3fb341,destinationCurrency:yF,originChainId:Y.chain.id})}),t=b2(e);if(!t)throw Error("Invalid transaction request");C(!0),G({data:t.data,to:t.to,value:t.value,chain:Y.chain})}catch(e){console.error(e),u(new n6.P("Unable to fetch quotes for bridging",e,n6.a.INSUFFICIENT_BALANCE))}})().catch(console.error):G({to:Y.bridgeTx.to,data:Y.bridgeTx.data,value:Y.bridgeTx.value,chain:Y.chain})},onSelect:e=>{e!==w&&(y(null),v(e))},onAmountChange:D}):I&&U?(0,h.jsx)(IT,{wallet:U,displayName:W,addressToFund:O,isBridging:_,isErc20Flow:!1,chainId:"solana",chainName:N.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TX,{}),(0,h.jsx)(Ip,{}),(0,h.jsx)("div",{style:{marginTop:"1rem"}}),(0,h.jsx)(fk,{})]})}},T1=new Map([[EP,null],[Eu,"external"],[El,"external"],[IS,"external"],[T0,"external"],[Ec,"external"],[Tk,"manual"],[Ex,"moonpay"]]),T2=()=>((()=>{let e=yK(),{user:t,getAccessToken:n}=(0,ic.u)(),{refreshSessionAndUser:i,walletProxy:r}=(0,n8.u)();(0,m.useEffect)(()=>{(async()=>{if("legacy-embedded-wallets-only"===e.embeddedWallets.mode||!t)return;let a=(0,ic.h)(t);if(!a||(0,ic.c)(a)||!vu(a)||!r)return;let s=await n();if(!s)return;let o=a.imported?[a]:t.linkedAccounts.filter(e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported).filter(vu),{entropyId:l,entropyIdVerifier:c}=mY(t,a);try{await r.connect({accessToken:s,entropyId:l,entropyIdVerifier:c})}catch(e){if(!wV(e)||"privy"!==a.recoveryMethod)return void console.debug("Unable to migrate wallet: ",e);await r.recover({accessToken:s,entropyId:l,entropyIdVerifier:c})}try{await r.createDelegatedAction({accessToken:s,rootWallet:{address:a.address,chainType:a.chainType,imported:a.imported},delegatedWallets:o}),await i()}catch(e){console.debug("Unable to migrate wallet: ",e)}})()},[t,r,e])})(),null),T3={component:()=>{let{app:e,data:t}=yQ(),n=yK(),i=t?.externalConnectWallet?.suggestedAddress,r=t?.externalConnectWallet?.description??(i?`Connect the wallet with address ${p$(i)} ${e?.name?`to ${e.name}.`:"."}`:`Connect a wallet to ${e?.name}`),{connectors:a}=(0,n8.u)(),s=_8({walletList:t?.externalConnectWallet?.walletList??e.appearance.walletList,walletChainType:t?.externalConnectWallet?.walletChainType??e.appearance.walletChainType,connectors:a,connectOnly:!0,ignore:e.appearance.walletList,walletConnectEnabled:e.externalWallets.walletConnect.enabled});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{},"header"),s.length>0&&(0,h.jsx)(vE,{title:"Connect your wallet",description:r}),(0,h.jsx)(fg,{$colorScheme:n.appearance.palette.colorScheme,children:(0,h.jsx)(_6,{wallets:s})}),(0,h.jsx)(fk,{})]})}},T4=({...e})=>(0,h.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,h.jsx)("path",{d:"M4 12L12 4M4 4L12 12",stroke:"black",strokeOpacity:"0.8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),T5={phantom:{mobile:{native:"phantom://",universal:"https://phantom.app/ul/"}},solflare:{mobile:{native:void 0,universal:"https://solflare.com/ul/v1/"}}};var T6=e=>(0,h.jsxs)("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,h.jsx)("path",{d:"m0 0h32v32h-32z",fill:"#5469d4"}),(0,h.jsx)("path",{d:"m15.997 5.333-.143.486v14.106l.143.143 6.548-3.87z",fill:"#c2ccf4"}),(0,h.jsx)("path",{d:"m15.996 5.333-6.548 10.865 6.548 3.87z",fill:"#fff"}),(0,h.jsx)("path",{d:"m15.997 21.306-.08.098v5.025l.08.236 6.552-9.227z",fill:"#c2ccf4"}),(0,h.jsx)("path",{d:"m15.996 26.665v-5.36l-6.548-3.867z",fill:"#fff"}),(0,h.jsx)("path",{d:"m15.995 20.07 6.548-3.87-6.548-2.976v6.847z",fill:"#8698e8"}),(0,h.jsx)("path",{d:"m9.448 16.2 6.548 3.87v-6.846z",fill:"#c2ccf4"})]}),T8=e=>(0,h.jsxs)("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,h.jsxs)("linearGradient",{id:"a",gradientUnits:"userSpaceOnUse",x1:"7.233",x2:"24.766",y1:"24.766",y2:"7.234",children:[(0,h.jsx)("stop",{offset:"0",stopColor:"#9945ff"}),(0,h.jsx)("stop",{offset:".2",stopColor:"#7962e7"}),(0,h.jsx)("stop",{offset:"1",stopColor:"#00d18c"})]}),(0,h.jsx)("path",{d:"m0 0h32v32h-32z",fill:"#10111a"}),(0,h.jsx)("path",{clipRule:"evenodd",d:"m9.873 20.41a.645.645 0 0 1 .476-.21l14.662.012a.323.323 0 0 1 .238.54l-3.123 3.438a.643.643 0 0 1 -.475.21l-14.662-.012a.323.323 0 0 1 -.238-.54zm15.376-2.862a.322.322 0 0 1 -.238.54l-14.662.012a.642.642 0 0 1 -.476-.21l-3.122-3.44a.323.323 0 0 1 .238-.54l14.662-.012a.644.644 0 0 1 .475.21zm-15.376-9.738a.644.644 0 0 1 .476-.21l14.662.012a.322.322 0 0 1 .238.54l-3.123 3.438a.643.643 0 0 1 -.475.21l-14.662-.012a.323.323 0 0 1 -.238-.54z",fill:"url(#a)",fillRule:"evenodd"})]});let T7=ig.I4.div.withConfig({displayName:"Header",componentId:"sc-5622aaf1-0"})(["display:flex;justify-content:space-between;align-items:center;"]),T9=ig.I4.button.withConfig({displayName:"CloseButton",componentId:"sc-5622aaf1-1"})(["padding:0.25rem;height:30px;width:30px;display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-full);background:var(--privy-color-background-2);"]),Ae=ig.I4.div.withConfig({displayName:"WalletIconWithActiveIndicator",componentId:"sc-5622aaf1-2"})(["position:relative;&::after{content:' ';border-radius:var(--privy-border-radius-full);height:6px;width:6px;background-color:var(--privy-color-success);position:absolute;right:-3px;bottom:-3px;}"]),At=ig.I4.img.withConfig({displayName:"WalletIcon",componentId:"sc-5622aaf1-3"})(["width:1.5rem;height:1.5rem;border-radius:0.25rem;object-fit:contain;"]),An=ig.I4.div.withConfig({displayName:"ScrollContainer",componentId:"sc-5622aaf1-5"})(["display:flex;flex-direction:column;gap:0.5rem;max-height:24rem;overflow-y:scroll;&::-webkit-scrollbar{display:none;}scrollbar-gutter:stable both-edges;scrollbar-width:none;-ms-overflow-style:none;"," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;"],e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0);class Ai{isEth(e){return e.chains.some(e=>e.startsWith("eip155:"))}isSol(e){return e.chains.some(e=>e.startsWith("solana:"))}normalize(e){return e.replace(/[-_]wallet$/,"").replace(/[-_]extension$/,"").toLowerCase()}inAllowList(e,t){if(!this.normalizedAllowList||0===this.normalizedAllowList.length||"listing"===t&&this.includeWalletConnect)return!0;let n=this.normalize(e);return this.normalizedAllowList.some(e=>n===this.normalize(e))}chainMatches(e){return"ethereum-only"===this.chainFilter?"ethereum"===e:"solana-only"!==this.chainFilter||"solana"===e}connectorOk(e){return!!("null"!==e.connectorType&&this.chainMatches(e.chainType)&&(this.inAllowList(e.walletClientType,"connector")||("injected"===e.connectorType||"s
58olana_adapter"===e.connectorType)&&(this.detectedGeneric||"ethereum"===e.chainType&&this.detectedEth||"solana"===e.chainType&&this.detectedSol)))}listingOk(e){if(e.slug.includes("coinbase"))return!1;if("ethereum-only"===this.chainFilter){if(!this.isEth(e))return!1}else if("solana-only"===this.chainFilter&&!this.isSol(e))return!1;return!!this.inAllowList(e.slug,"listing")}getWallets(e,t){let n=new Map,i=e=>{let t=n.get(e.id);if(t){t.chainType!==e.chainType&&(t.chainType="multi");let n=new Set(t.chains);e.chains.forEach(e=>n.add(e)),t.chains=Array.from(n),!t.icon&&e.icon&&(t.icon=e.icon),!t.url&&e.url&&(t.url=e.url),!t.listing&&e.listing&&(t.listing=e.listing)}else n.set(e.id,e)};e.filter(e=>this.connectorOk(e)).forEach(e=>{let t=this.normalize(e.walletClientType);i({id:t,label:e.walletBranding?.name??t,source:"connector",connector:e,chainType:e.chainType,icon:"string"==typeof e.walletBranding?.icon?e.walletBranding.icon:void 0,url:void 0,chains:["ethereum"===e.chainType?"eip155":"solana"]})}),t.filter(e=>this.listingOk(e)).forEach(e=>{let t=this.isEth(e),n=this.isSol(e);i({id:e.slug,label:e.name,source:"listing",listing:e,chainType:t&&n?"multi":t?"ethereum":"solana",icon:e.image_url?.sm,url:e.homepage,chains:e.chains})});let r=Array.from(n.values()),a=new Map;return this.normalizedAllowList?.forEach((e,t)=>{a.set(this.normalize(e),t)}),{wallets:r.slice().sort((e,t)=>{let n=this.normalize(e.id),i=this.normalize(t.id);"binanceus"===n||"binance-defi"===n?n="binance":"universalprofiles"===n?n="universal_profile":"cryptocom-defi"===n&&(n="cryptocom"),"binanceus"===i||"binance-defi"===i?i="binance":"universalprofiles"===i?i="universal_profile":"cryptocom-defi"===i&&(i="cryptocom");let r=a.has(n),s=a.has(i);return r&&s?a.get(n)-a.get(i):r?-1:s?1:"connector"===e.source&&"listing"===t.source?-1:"listing"===e.source&&"connector"===t.source?1:e.label.toLowerCase().localeCompare(t.label.toLowerCase())}),walletCount:r.length}}constructor(e,t){this.chainFilter=e,t&&t.length>0&&(this.normalizedAllowList=t.map(String)),this.detectedGeneric=this.normalizedAllowList?.includes("detected_wallets")??!1,this.detectedEth=this.normalizedAllowList?.includes("detected_ethereum_wallets")??!1,this.detectedSol=this.normalizedAllowList?.includes("detected_solana_wallets")??!1,this.includeWalletConnect=this.normalizedAllowList?.includes("wallet_connect")??!1}}let Ar=(0,hV.v)(()=>({isModalOpen:!1,resolvers:null}));(0,hV.v)(()=>({}));let Aa=e=>!e||"string"!=typeof e&&(e instanceof yc||e instanceof yS),As=({index:e,style:t,data:n})=>{let i=n.wallets[e],{walletChainType:r,handleWalletClick:a}=n,s={...t,boxSizing:"border-box"};return i?(0,h.jsxs)(Ao,{style:s,onClick:()=>a(i),children:[i.icon&&(i.connector&&!Aa(i.connector)?(0,h.jsx)(Ae,{children:(0,h.jsx)(At,{src:i.icon})}):(0,h.jsx)(At,{src:i.icon})),(0,h.jsx)(Ah,{children:i.label}),(0,h.jsx)(Al,{children:"ethereum-only"!==r&&"solana-only"!==r&&(0,h.jsxs)(h.Fragment,{children:[i.chains?.some(e=>e.startsWith("eip155"))&&(0,h.jsx)(T6,{}),i.chains?.some(e=>e.startsWith("solana"))&&(0,h.jsx)(T8,{})]})})]}):null},Ao=ig.I4.button.withConfig({displayName:"Button",componentId:"sc-d6b00860-0"})(["button&{gap:0.5rem;align-items:center;display:flex;position:relative;text-align:left;font-weight:500;transition:background 200ms ease-in;width:calc(100% - 4px);border-radius:var(--privy-border-radius-mdlg);margin:0 2px;padding:1em;border:1px solid var(--privy-color-foreground-4);}svg{stroke-width:2.5;width:100%;max-height:1rem;max-width:1rem;flex-shrink:0;}&:hover{background:var(--privy-color-background-2);}"]),Al=ig.I4.span.withConfig({displayName:"ButtonBadge",componentId:"sc-d6b00860-1"})(["display:flex;align-items:center;justify-content:end;margin-left:auto;position:relative;& > svg{border-radius:var(--privy-border-radius-full);}& > svg:not(:last-child){border-radius:var(--privy-border-radius-full);margin-right:-0.375rem;}"]),Ac=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-d6b00860-2"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;h3{margin-top:1.5rem;font-size:1rem;font-weight:500;line-height:1.5rem;}"]),Ad=ig.I4.div.withConfig({displayName:"SearchDivider",componentId:"sc-d6b00860-3"})(["width:100%;height:0.5rem;background:radial-gradient(circle at bottom center,transparent 50%,white 100%);"]),Au=ig.I4.div.withConfig({displayName:"EmptyContainer",componentId:"sc-d6b00860-4"})(["height:60px;display:flex;align-items:center;justify-content:center;text-align:center;"]),Ah=ig.I4.span.withConfig({displayName:"WalletName",componentId:"sc-d6b00860-5"})(["text-overflow:ellipsis;whitespace:nowrap;"]),Ap=(0,ig.I4)(vT).withConfig({displayName:"StyledCenteredScreenHeader",componentId:"sc-d6b00860-6"})(["gap:8px;margin-bottom:8px;h3{margin-bottom:0;}"]),Am={component:()=>{let{closePrivyModal:e}=(0,n8.u)(),{app:t,data:n}=yQ(),i=n?.externalConnectWallet?.description,r=(0,m.useRef)(n?.externalConnectWallet?.suggestedAddress).current,a=(0,m.useRef)(n?.externalConnectWallet?.walletList??t.appearance.walletList),s=(0,m.useRef)(n?.externalConnectWallet?.walletChainType??t.appearance.walletChainType);
58return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Ay,{connectOnly:!0,walletList:a.current,walletChainType:s.current,onClose:e,onConnect:e,suggestedAddress:r,customDescription:i,app:t}),t&&(0,h.jsx)(fS,{app:t,alwaysShowImplicitConsent:!0}),(0,h.jsx)(fk,{})]})},isUnauthenticatedScreem:!0},Ay=(0,ig.I4)(({showHeader:e=!0,className:t,suggestedAddress:n,customDescription:i,connectOnly:r,...a})=>{let s=yK(),{connectors:o}=(0,n8.u)(),l=a.walletChainType||s.appearance.walletChainType,c=a.walletList||s.appearance?.walletList,{onBack:d,onClose:u,app:p}=a,{selected:f,setSelected:g,qrUrl:w,setQrUrl:v,connecting:b,uiState:x,wallets:_,handleConnect:C,handleBack:I,showSearchBar:E,isInitialConnectView:T,title:A,search:S,setSearch:k}=function({onConnect:e,onBack:t,onClose:n,walletList:i,walletChainType:r,app:a}){let s=yK(),{connectors:o}=(0,n8.u)(),l=yk(e=>e.listings),c=r??s.appearance.walletChainType,d=i??s.appearance?.walletList,u=(0,m.useMemo)(()=>new Ai(c,d),[c,d]),{wallets:h,walletCount:p}=(0,m.useMemo)(()=>u.getWallets(o,l),[u,o,l]),[f,g]=(0,m.useState)(""),w=(0,m.useMemo)(()=>f?h.filter(e=>e.label.toLowerCase().includes(f.toLowerCase())):h,[f,h]),[v,b]=(0,m.useState)(),[x,_]=(0,m.useState)(),[C,I]=(0,m.useState)(),[E,T]=(0,m.useState)(),A=!v&&!x&&!C,S=A&&(p>6||f.length>0),k=o.find(e=>"wallet_connect_v2"===e.connectorType),P=(0,m.useCallback)(async(t,n)=>{if(t){if(T("loading"),"string"==typeof t)return I({connector:t,name:n?.name??"Wallet",icon:n?.icon}),void window.open(t,"_blank");I({connector:t,name:n?.name??t.walletBranding.name??"Wallet",icon:n?.icon??t.walletBranding.icon});try{let n=await t.connect({showPrompt:!0});if(!n)return void T("error");T("success"),(({address:e,client:t,appId:n})=>{let i,r=`${t}:${e}`;n&&pR.put((i=n,`privy:${i}:active-wallet-connection`),r),Ar.setState({wallet:r})})({address:n.address,client:n.walletClientType,appId:s.id}),setTimeout(()=>{e()},1400)}catch(e){T("error")}}},[s.id,e]),j=(0,m.useCallback)(()=>x?(T(void 0),I(void 0),void _(void 0)):C?(T(void 0),void I(void 0)):v?(T(void 0),I(void 0),void b(void 0)):"error"===E||"loading"===E?(T(void 0),void I(void 0)):void t?.(),[x,C,v,E,t]),O=(0,m.useMemo)(()=>C?.connector===k&&x&&y.Fr?`Go to ${C.name} to continue`:C?.connector===k&&x?`Scan code to connect to ${C.name}`:"string"==typeof C?.connector?`Open or install ${C.name}`:v&&!C?"Select network":C?null:"Connect wallet",[C,x,v,k]);return{selected:v,setSelected:b,qrUrl:x,setQrUrl:_,connecting:C,uiState:E,search:f,setSearch:g,wallets:w,walletCount:p,wc:k,isInitialConnectView:A,showSearchBar:S,title:O,handleConnect:P,handleBack:j,onClose:n,onConnect:e,app:a}}({...a,walletList:c,walletChainType:l}),P=o.find(e=>"wallet_connect_v2"===e.connectorType),j=_.length>0,O=(0,m.useRef)(null),N=(0,pw.Te)({count:_.length,getScrollElement:()=>O.current,estimateSize:()=>54,overscan:6,gap:5}),R=(0,m.useCallback)(async e=>{let t,n=e.chains?.some(e=>e.startsWith("eip155")),i=e.chains?.some(e=>e.startsWith("solana")),a=yb[e.id];if(i&&a)t=a.getMobileRedirect({isSolana:!0,connectOnly:!!r,useUniversalLink:!1});else{let n=e.listing?.mobile?.native;t=e.listing?.mobile?.universal||n||e.url}if(n&&i){let n=e.id.toLowerCase(),i=o.filter(e=>e.walletClientType.toLowerCase()===n&&!("ethereum"===e.chainType&&e instanceof yc||"solana"===e.chainType&&e instanceof yS)),r=i.find(e=>"ethereum"===e.chainType),a=i.find(e=>"solana"===e.chainType);if(!r&&e.listing){let t=T5[e.listing.slug]?{...e.listing,...T5[e.listing.slug]}:e.listing;P.setWalletEntry(t,v),await P.resetConnection(e.id),r=P}if(!a&&t&&(a=t),r||a)return void g({eth:r,sol:a,name:e.label,icon:e.icon})}if(Aa(e.connector)){if(n||i||e.url||e.listing){if(n&&e.listing){let t=T5[e.listing.slug]?{...e.listing,...T5[e.listing.slug]}:e.listing;P.setWalletEntry(t,v),await P.resetConnection(e.id)}if(n&&i)return void g({eth:P,sol:t,name:e.label,icon:e.icon});if(i)return void await C(t,{name:e.label,icon:e.icon});if(n)return void(e.listing?await C(P,{name:e.label,icon:e.icon}):e.url?await C(e.url,{name:e.label,icon:e.icon}):console.warn("Cannot connect to EVM wallet without connector or listing details:",e.label));if(e.url)return void await C(e.url,{name:e.label,icon:e.icon})}}else await C(e.connector,{name:e.label,icon:e.icon})},[P,C,g,v,I,u,p,T,A,i,n,s,o]);return(0,h.jsxs)("div",{className:t,children:[e&&(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(T7,{children:[d||!T?(0,h.jsx)(T9,{onClick:I,children:(0,h.jsx)(iC.A,{height:"1rem",width:"1rem",strokeWidth:1.5})}):(0,h.jsx)("div",{}),(0,h.jsx)(T9,{onClick:u,children:(0,h.jsx)(T4,{})})]})}),(0,h.jsx)(Ap,{title:e&&A||"",description:b&&!w&&"string"==typeof b.connector?`To connect to ${b.name}, install and open the app. Then confirm the connection when prompted.`:T?i??(n?(0,h.jsxs)("span",{children:["Connect the wallet with address ",(0,h.jsx)(bG,{address:n})," ",p?.name?`to ${p.name}.`:"."]}):p?`Connect a wallet to your ${p.name} account`:null):null}),E&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(CC,{style:{marginTop:"0.5rem",background:"transparent"},children:[(0,h.jsx)(pf.A,{}),(0,h.jsx)("input",{className:"login-method-button",type:"text",placeholder:"Search wallets",onChange:e=>k(e.target.value),value:S})]}),(0,h.jsx)(Ad,{})]}),(0,h.jsxs)(An,{ref:O,$colorScheme:s.appearance.palette.colorScheme,style:{marginBottom:w?"0.5rem":void 0},children:[w&&(0,h.jsxs)(h.Fragment,{children:[y.Fr?(0,h.jsxs)(Ac,{children:[b?.icon?(0,h.jsx)(_$,{walletLogo:b.icon,success:"success"===x,fail:"error"===x}):null,(0,h.jsxs)("h3",{children:["Waiting for ",b?.name??"connection"]})]}):(0,h.jsx)(xZ,{size:280,url:w.universal??w.native,squareLogoElement:b?.icon?"string"==typeof b.icon?e=>(0,h.jsx)("svg",{...e,children:(0,h.jsx)("image",{href:b.icon,height:e.height,width:e.width})}):b.icon:yX}),y.Fr&&"loading"===x&&(0,h.jsx)(gn,{style:{marginTop:"0.5rem"},onClick:()=>
58window.open(w.universal??w.native,"_blank"),children:"Open in app"})]}),b&&!w&&"string"!=typeof b.connector&&(0,h.jsxs)(Ac,{children:[b.icon?(0,h.jsx)(_$,{walletLogo:b.icon,success:"success"===x,fail:"error"===x}):null,(0,h.jsxs)("h3",{children:["Waiting for ",b.name]}),(0,h.jsx)(Cz,{children:"error"===x?"Please try connecting again.":"For the best experience, connect only one wallet at a time."}),"error"===x&&(0,h.jsx)(gn,{style:{marginTop:"1.5rem"},onClick:()=>C(b.connector,{name:b.name,icon:b.icon}),children:"Retry"})]}),b&&!w&&"string"==typeof b.connector&&(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(Ao,{onClick:()=>window.open(b.connector,"_blank"),children:[b.icon&&("string"==typeof b.icon?(0,h.jsx)(At,{src:b.icon}):(0,h.jsx)(b.icon,{})),(0,h.jsx)(Ah,{children:b.name})]})}),f?.eth&&!b&&(0,h.jsxs)(Ao,{onClick:()=>C(f.eth,{name:f.name,icon:f.icon}),children:[f.icon&&("string"==typeof f.icon?(0,h.jsx)(At,{src:f.icon}):(0,h.jsx)(f.icon,{})),(0,h.jsx)(Ah,{children:f.name}),(0,h.jsx)(Al,{children:(0,h.jsx)(T6,{})})]}),f?.sol&&!b&&(0,h.jsxs)(Ao,{onClick:()=>C(f.sol,{name:f.name,icon:f.icon}),children:[f.icon&&("string"==typeof f.icon?(0,h.jsx)(At,{src:f.icon}):(0,h.jsx)(f.icon,{})),(0,h.jsx)(Ah,{children:f.name}),(0,h.jsx)(Al,{children:(0,h.jsx)(T8,{})})]}),T&&(0,h.jsxs)(h.Fragment,{children:[!j&&(0,h.jsx)(Au,{children:"No wallets found. Try another search."}),_.length>0&&(0,h.jsx)("div",{style:{height:54*Math.min(_.length+1,5),width:"100%"},children:(0,h.jsx)("div",{style:{height:`${N.getTotalSize()}px`,width:"100%",position:"relative"},children:N.getVirtualItems().map(e=>(0,h.jsx)(As,{index:e.index,style:{position:"absolute",top:0,left:0,height:`${e.size}px`,transform:`translateY(${e.start}px)`},data:{wallets:_,walletChainType:l,handleWalletClick:R}},e.key))})})]})]})]})}).withConfig({displayName:"StyledConnectWalletView",componentId:"sc-23b509eb-0"})(["padding:0;padding-top:1em;"]),Af={component:()=>{let e=yK(),{data:t,navigate:n,setModalData:i,onUserCloseViaDialogOrKeybindRef:r}=yQ(),{crossAppAuthFlow:a,updateWallets:s,closePrivyModal:o,createAnalyticsEvent:l}=(0,n8.u)(),{logout:c}=function(e){let{logout:t}=(0,m.useContext)(ic.P);return fu("logout",void 0),{logout:t}}(),[d,u]=(0,m.useState)({}),p=t?.crossAppAuth,y={id:p.appId,name:p.name,logoUrl:p.logoUrl},f=new n6.P(`There was an issue connecting your ${y.name} account. Please try again.`),g=new p4(async e=>{if(p.popup)try{let t=await a({appId:e,popup:p.popup,action:p.action});u({data:t})}catch(e){e instanceof n6.P?u({error:e}):(e instanceof n6.J&&p.popup&&p.popup.close(),u({error:f}))}else u({error:f})}),w=()=>{d.data&&(s(),p.onSuccess(d.data),o({shouldCallAuthOnSuccess:!0,isSuccess:!0})),p.onError(d.error??new n6.P("User canceled flow")),o({shouldCallAuthOnSuccess:!1,isSuccess:!1})};r.current=w,(0,m.useEffect)(()=>{y.id.length&&g.execute(y.id)},[y.id]),(0,m.useEffect)(()=>{if(!d.data)return;let t=d.data;if(e.legal.requireUsersAcceptTerms&&!t.hasAcceptedTerms){let e=setTimeout(()=>{n(x_)},1400);return()=>clearTimeout(e)}if(b$(t,e.embeddedWallets)){let e=setTimeout(()=>{i({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),l({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${y.id}`,screen:"CrossAppAuthScreen"}}),c()},callAuthOnSuccessOnClose:!0}}),n(xb)},1400);return()=>clearTimeout(e)}let r=setTimeout(w,1400);return()=>clearTimeout(r)},[d.data]);let{title:v,subtitle:b}=(0,m.useMemo)(()=>d.data?{title:`Successfully connected with ${y.name}`,subtitle:"You're good to go!"}:d.error?{title:"Authentication failed",subtitle:d.error.message}:{title:`Connecting to ${y.name}`,subtitle:`Please check the pop-up from ${y.name} to continue`},[d,y.name]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:w}),(0,h.jsx)(g3,{}),(0,h.jsxs)(Ag,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:!!d.data,fail:!!d.error}),(0,h.jsx)(bM,{name:y.name,logoUrl:y.logoUrl})]})}),(0,h.jsxs)(g1,{children:[(0,h.jsx)("h3",{children:v}),(0,h.jsx)("p",{children:b})]})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fP,{})]})}},Ag=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-33c02367-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),Aw={component:()=>{let{app:e,data:t}=yQ(),{closePrivyModal:n}=(0,n8.u)(),[i,r]=(0,m.useState)(!1),[a,s]=(0,m.useState)(),{address:o,onDelegate:l,onSuccess:c,onError:d}=t.delegatedActions.consent,u=async()=>{i?c():d(a??new n6.P("User declined delegating actions.")),n({shouldCallAuthOnSuccess:!1})};return(0,m.useEffect)(()=>
58{if(!i&&!a)return;let e=setTimeout(u,2500);return()=>clearTimeout(e)},[i,a]),(0,h.jsxs)(h.Fragment,i||a?{children:[(0,h.jsx)(fR,{onClose:u}),(0,h.jsx)(g3,{}),(0,h.jsxs)(gY,{children:[a?(0,h.jsx)(h1.A,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):(0,h.jsx)(pc.A,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),(0,h.jsx)(g6,{height:20}),(0,h.jsx)(vT,{title:a?"Something went wrong":"Success!",description:a?"Please try again.":`You’ve successfully granted delegated action permissions to ${e.name}.`})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]}:{children:[(0,h.jsx)(fR,{closeable:!0,onClose:u}),(0,h.jsx)(pv.A,{width:56,height:56,style:{margin:"auto"}}),(0,h.jsx)(fB,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),(0,h.jsxs)(fz,{style:{marginBottom:24,textWrap:"pretty"},children:["By confirming, ",e.name," will be able to use your wallet for you even when you're not around. You can revoke this later."]}),(0,h.jsx)(Ab,{showIcon:!0,address:o,title:"Wallet",isLoading:!1}),(0,h.jsxs)(Av,{style:{marginTop:24},children:[(0,h.jsx)(go,{onClick:u,children:"Not now"}),(0,h.jsx)(gn,{onClick:async()=>{try{await l(),r(!0)}catch(e){s(e)}},children:"Accept"})]}),(0,h.jsx)(fk,{})]})}},Av=ig.I4.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-bdb7bc51-0"})(["display:flex;gap:10px;"]),Ab=(0,ig.I4)(C0).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-bdb7bc51-1"})(["margin-top:1.5rem;"]),Ax={component:()=>{let{app:e,data:t}=yQ(),{closePrivyModal:n}=(0,n8.u)(),[i,r]=(0,m.useState)(!1),[a,s]=(0,m.useState)(),{onRevoke:o,onSuccess:l,onError:c}=t.delegatedActions.revoke,d=async()=>{i?l():c(a??new n6.P("User declined revoking access to their delegated wallet.")),n({shouldCallAuthOnSuccess:!1})};return(0,m.useEffect)(()=>{if(!i&&!a)return;let e=setTimeout(d,2500);return()=>clearTimeout(e)},[i,a]),(0,h.jsxs)(h.Fragment,i||a?{children:[(0,h.jsx)(fR,{onClose:d}),(0,h.jsx)(g3,{}),(0,h.jsxs)(gY,{children:[a?(0,h.jsx)(h1.A,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):(0,h.jsx)(pc.A,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),(0,h.jsx)(g6,{height:20}),(0,h.jsx)(vT,{title:a?"Something went wrong":"Success!",description:a?"Please try again.":"You've successfully revoked permissions."})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]}:{children:[(0,h.jsx)(fR,{closeable:!0,onClose:d}),(0,h.jsx)(pb.A,{width:56,height:56,style:{margin:"auto"}}),(0,h.jsx)(fB,{style:{marginTop:24},children:"Revoke offline access to wallet"}),(0,h.jsxs)(fz,{children:["By confirming, ",e.name," will no longer be able to use this wallet on your behalf when you are not online."]}),(0,h.jsxs)(A_,{style:{marginTop:24},children:[(0,h.jsx)(go,{onClick:d,children:"Deny"}),(0,h.jsx)(gn,{onClick:async()=>{try{await o(),r(!0)}catch(e){s(e)}},children:"Confirm"})]}),(0,h.jsx)(fk,{})]})}},A_=ig.I4.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-993a839-0"})(["display:flex;gap:10px;"]),AC="#8a63d2",AI={component:()=>{let{lastScreen:e,navigateBack:t,data:n,app:i}=yQ(),{requestFarcasterSignerStatus:r,closePrivyModal:a}=(0,n8.u)(),[s,o]=(0,m.useState)(void 0),[l,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(!1),p=(0,m.useRef)([]),f=n?.farcasterSigner;(0,m.useEffect)(()=>{let e=Date.now(),t=setInterval(async()=>{if(!f?.public_key)return clearInterval(t),void o({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===f.status&&(clearInterval(t),c(!1),u(!0),p.current.push(setTimeout(()=>a({shouldCallAuthOnSuccess:!1,isSuccess:!0}),1400)));let n=await r(f?.public_key),i=Date.now()-e;"approved"===n.status?(clearInterval(t),c(!1),u(!0),p.current.push(setTimeout(()=>a({shouldCallAuthOnSuccess:!1,isSuccess:!0}),1400))):i>3e5?(clearInterval(t),o({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===n.status&&(clearInterval(t),o({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))},2e3);return()=>{clearInterval(t),p.current.forEach(e=>clearTimeout(e))}},[]);let g="pending_approval"===f?.status?f.signer_approval_url:void 0;return(0,h.jsxs)(h.Fragment,y.Fr||l?{children:[(0,h.jsx)(fR,{backFn:e?t:void 0,onClose:a},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(h.Fragment,y.un?{children:(0,h.jsxs)(AT,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:d,fail:!!s}),(0,h.jsx)(xj,{style:{width:"38px",height:"38px"}})]})}),(0,h.jsxs)(g1,{children:[(0,h.jsx)(fB,{children:s?s.message:"Add a signer to Farcaster"}),(0,h.jsx)(fz,{children:s?s.detail:"This will allow "+i.name+" to add casts, like
58s, follows, and more on your behalf."})]}),g&&(0,h.jsx)(gn,{onClick:e=>{e.preventDefault(),window.location.href=g},children:"Open Warpcast app"})]})}:{children:(0,h.jsxs)(AE,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:d,fail:!!s}),(0,h.jsx)(xj,{style:{width:"38px",height:"38px"}})]})}),(0,h.jsxs)(g1,{children:[(0,h.jsx)(fB,{children:s?s.message:"Requesting signer from Farcaster"}),(0,h.jsx)(fz,{children:s?s.detail:"This should only take a moment"}),(0,h.jsx)(gZ,{children:g&&y.Fr&&(0,h.jsx)(xW,{text:"Take me to Warpcast",url:g,color:AC})})]})]})}),(0,h.jsx)(fP,{})]}:{children:[(0,h.jsx)(fR,{backFn:e?t:void 0,onClose:a},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(AE,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(fB,{children:"Add a signer to Farcaster"}),(0,h.jsxs)(fz,{children:["This will allow ",i.name," to add casts, likes, follows, and more on your behalf."]}),(0,h.jsx)(gQ,{children:"pending_approval"===f?.status?(0,h.jsx)(xZ,{url:f.signer_approval_url,size:275,squareLogoElement:xj}):(0,h.jsx)(f8,{})}),(0,h.jsxs)(gZ,{children:[(0,h.jsx)(fz,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===f?.status&&(0,h.jsx)(xL,{text:f.signer_approval_url,itemName:"link",color:AC})]})]})}),(0,h.jsx)(fP,{})]})}},AE=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-6e8f76e5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),AT=ig.I4.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e8f76e5-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),AA={component:()=>{let{closePrivyModal:e}=(0,n8.u)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{},"header"),(0,h.jsx)(AS,{children:(0,h.jsx)(h2.A,{style:{width:32,height:32}})}),(0,h.jsx)(vE,{title:"Could not log in with provider",description:"It looks like you're using an in-app browser.  To log in, please try again using an external browser.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),(0,h.jsx)(gJ,{children:(0,h.jsx)(gn,{onClick:()=>e(),children:"Close"})}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}},AS=ig.I4.div.withConfig({displayName:"StyledCircle",componentId:"sc-7bde5742-0"})(["border-radius:50%;height:68px;width:68px;display:flex;align-items:center;justify-content:center;background-color:var(--privy-color-accent);color:white;margin:0 auto 24px auto;"]),Ak={component:()=>{let{app:e}=yQ();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(vT,{title:"Connect your email",description:`Add your email to your ${e?.name} account`,icon:(0,h.jsx)(hZ.A,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),(0,h.jsx)(gJ,{children:(0,h.jsx)(CT,{stacked:!0})}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}},AP={component:()=>{let{app:e,currentScreen:t,data:n,navigate:i,setModalData:r}=yQ(),{initLoginWithSms:a}=(0,n8.u)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(vT,{title:"Connect your phone",description:`Add your number to your ${e?.name} account`,icon:(0,h.jsx)(ix.A,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),(0,h.jsx)(gJ,{children:(0,h.jsx)(_d,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await a({phoneNumber:e,withPrivyUi:!0}),i(Cp)}catch(e){r({errorModalData:{error:e,previousScreen:n?.errorModalData?.previousScreen||t||AP}}),i(b6)}},hideRecent:!0})}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}},Aj={component:()=>{let{app:e,data:t}=yQ(),n=t?.externalConnectWallet?.suggestedAddress,i=t?.externalConnectWallet?.description??(n?(0,h.jsxs)("span",{children:["Link the wallet with address ",(0,h.jsx)(bG,{showCopyIcon:!1,address:n})," ",e?.name?`to ${e.name}.`:"."]}):`Link a wallet to your ${e?.name} account`),{connectors:r}=(0,n8.u)(),a=_8({walletList:t?.externalConnectWallet?.walletList??e.appearance.walletList,walletChainType:t?.externalConnectWallet?.walletChainType??e.appearance.walletChainType,connectors:r,connectOnly:!1,ignore:e.appearance.walletList,walletConnectEnabled:e.externalWallets.walletConnect.enabled});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{},"header"),a.length>0&&(0,h.jsx)(vE,{title:"Link your wallet",description:i}),(0,h.jsx)(ff,{children:(0,h.jsx)(_6,{wallets:a})}),(0,h.jsx)(fk,{})]})}},AO=({style:e,...t})=>(0,h.jsxs)("svg",{width:"164",height:"164",viewBox:"0 0 164 164",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...e},...t,children:[(0,h.jsx)("circle",{cx:"82",cy:"82",r:"80",stroke:"#EC6351","
58stroke-width":"4","stroke-linecap":"round"}),(0,h.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M81.9999 100.788C93.3288 100.788 102.513 91.6043 102.513 80.2754C102.513 68.9465 93.3288 59.7626 81.9999 59.7626C70.671 59.7626 61.4871 68.9465 61.4871 80.2754C61.4871 91.6043 70.671 100.788 81.9999 100.788ZM88.3236 71.8304C88.9093 71.2446 89.8591 71.2446 90.4449 71.8304C91.0307 72.4161 91.0307 73.3659 90.4449 73.9517L84.121 80.2756L90.445 86.5996C91.0308 87.1854 91.0308 88.1351 90.445 88.7209C89.8592 89.3067 88.9095 89.3067 88.3237 88.7209L81.9997 82.3969L75.6756 88.7209C75.0899 89.3067 74.1401 89.3067 73.5543 88.7209C72.9685 88.1351 72.9685 87.1854 73.5543 86.5996L79.8783 80.2756L73.5544 73.9517C72.9686 73.3659 72.9686 72.4161 73.5544 71.8304C74.1402 71.2446 75.09 71.2446 75.6758 71.8304L81.9997 78.1543L88.3236 71.8304Z",fill:"#EC6351"})]}),AN={component:()=>{let{closePrivyModal:e}=(0,n8.u)(),{navigate:t}=yQ();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(AO,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),(0,h.jsx)(vE,{title:"Could not connect with wallet",description:"Please check that Phantom multichain is enabled and try again.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),(0,h.jsxs)(gJ,{children:[(0,h.jsx)(gn,{onClick:()=>t(CN),children:"Try again"}),(0,h.jsx)(go,{onClick:()=>e(),children:"Cancel"})]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}};function AR(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:i,submitEnrollmentWithTotp:r,submitEnrollmentWithPasskey:a,unenroll:s,enrollInMfa:o}=(0,m.useContext)(ic.P);return{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:i,submitEnrollmentWithTotp:r,submitEnrollmentWithPasskey:a,unenrollWithSms:()=>s("sms"),unenrollWithTotp:()=>s("totp"),unenrollWithPasskey:e=>s("passkey",e),showMfaEnrollmentModal:()=>o(!0),closeMfaEnrollmentModal:()=>o(!1)}}let AM=e=>(0,h.jsxs)(AD,{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"88",height:"89",viewBox:"0 0 88 89",...e,children:[(0,h.jsx)("rect",{y:"0.666016",width:"88",height:"88",rx:"44"}),(0,h.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M45.2463 20.9106C44.5473 20.2486 43.4527 20.2486 42.7537 20.9106C37.8798 25.5263 31.3034 28.3546 24.0625 28.3546C23.9473 28.3546 23.8323 28.3539 23.7174 28.3525C22.9263 28.3427 22.2202 28.8471 21.9731 29.5987C20.9761 32.6311 20.4375 35.8693 20.4375 39.2297C20.4375 53.5896 30.259 65.651 43.5482 69.0714C43.8446 69.1477 44.1554 69.1477 44.4518 69.0714C57.741 65.651 67.5625 53.5896 67.5625 39.2297C67.5625 35.8693 67.0239 32.6311 66.0269 29.5987C65.7798 28.8471 65.0737 28.3427 64.2826 28.3525C64.1677 28.3539 64.0527 28.3546 63.9375 28.3546C56.6966 28.3546 50.1202 25.5263 45.2463 20.9106ZM52.7249 40.2829C53.3067 39.4683 53.1181 38.3363 52.3035 37.7545C51.4889 37.1726 50.3569 37.3613 49.7751 38.1759L41.9562 49.1223L38.0316 45.1977C37.3238 44.4899 36.1762 44.4899 35.4684 45.1977C34.7605 45.9056 34.7605 47.0532 35.4684 47.761L40.9059 53.1985C41.2826 53.5752 41.806 53.7671 42.337 53.7232C42.868 53.6792 43.3527 53.4039 43.6624 52.9704L52.7249 40.2829Z"})]}),AD=ig.I4.svg.withConfig({displayName:"StyledSvg",componentId:"sc-59fa943f-0"}
58)(["height:90px;width:90px;> rect{","}> path{fill:white;}"],e=>"success"===e.color?"fill: var(--privy-color-success);":"fill: var(--privy-color-accent);"),AU=({showIntro:e,userMfaMethods:t,appMfaMethods:n,userHasAuthSms:i,isTotpLoading:r,isPasskeyLoading:a,error:s,onClose:o,onBackToIntro:l,handleSelectMethod:c,setRemovingMfaMethod:d})=>{let u=t.reduce((e,t)=>({...e,[t]:!0}),{}),p=n.reduce((e,t)=>({...e,[t]:!0}),{});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:e?l:void 0,onClose:o},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(i_.A,{})}),(0,h.jsx)(fB,{children:"Choose a verification method"}),t.length>0?(0,h.jsx)(fz,{children:"To add or delete verification methods, verification is required."}):(0,h.jsx)(fz,{children:"How would you like to verify your identity? You can change this later."}),s&&(0,h.jsx)(f4,{style:{marginTop:"1.25rem"},children:s.message}),(0,h.jsxs)(fJ,{children:[(p.totp||u.totp)&&(0,h.jsxs)(fZ,{children:[(0,h.jsx)(fb,{style:{justifyContent:"center"},disabled:u.totp||r,onClick:()=>c("totp"),children:r?(0,h.jsx)(f8,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):(0,h.jsxs)(f0,{children:[(0,h.jsxs)(fQ,{children:[(0,h.jsx)(iv.A,{}),"Authenticator app"]}),u.totp?(0,h.jsx)(AL,{color:"green",children:"Enabled"}):(0,h.jsx)(fX,{children:"Recommended"})]})}),u.totp&&(0,h.jsx)(fY,{style:{position:"absolute",right:0},onClick:()=>d("totp"),children:(0,h.jsx)(pE.A,{})})]},"totp"),(p.sms||u.sms)&&(0,h.jsxs)(fZ,{children:[(0,h.jsx)(fb,{disabled:u.sms||i,onClick:()=>c("sms"),children:(0,h.jsxs)(f0,{children:[(0,h.jsxs)(fQ,{children:[(0,h.jsx)(ix.A,{}),"SMS"]}),u.sms&&(0,h.jsx)(AL,{color:"green",children:"Enabled"}),i&&(0,h.jsx)(fX,{children:"Disabled"})]})}),u.sms&&(0,h.jsx)(fY,{style:{position:"absolute",right:0},onClick:()=>d("sms"),children:(0,h.jsx)(pE.A,{})})]},"sms"),(p.passkey||u.passkey)&&(0,h.jsxs)(fZ,{children:[(0,h.jsx)(fb,{style:{justifyContent:"center"},onClick:()=>c("passkey"),disabled:u.passkey||a,children:a?(0,h.jsx)(f8,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):(0,h.jsxs)(f0,{children:[(0,h.jsxs)(fQ,{children:[(0,h.jsx)(ib.A,{}),"Passkey"]}),u.passkey?(0,h.jsx)(AL,{color:"green",children:"Enabled"}):(0,h.jsx)(fX,{isAccent:!0,children:(0,h.jsx)(h7.A,{})})]})}),u.passkey&&(0,h.jsx)(fY,{style:{position:"absolute",right:0},onClick:()=>d("passkey"),children:(0,h.jsx)(pE.A,{})})]},"passkey")]}),(0,h.jsx)(fP,{})]})},AL=(0,ig.I4)(xk).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]),AF=({appName:e,onComplete:t,onClose:n,onReset:i})=>{let{user:r}=(0,ic.u)(),{data:a}=yQ(),{initLinkWithPasskey:s,linkWithPasskey:o}=(0,n8.u)(),{initEnrollmentWithPasskey:l,submitEnrollmentWithPasskey:c}=AR(),[d,u]=(0,m.useState)(!1),[p,y]=(0,m.useState)(!1),[f,g]=(0,m.useState)(!1),[w,v]=(0,m.useState)(null),b=(0,m.useMemo)(()=>r?.linkedAccounts.filter(e=>"passkey"===e.type)??[],[r]),x=()=>{a?.mfaEnrollmentFlow?.onSuccess(),t()},_=async e=>{u(!0);try{await l(),await c({credentialIds:e},{removeForLogin:a?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),g(!0)}catch(e){v(e)}finally{u(!1)}},C=async()=>{y(!0),v(null);try{await s();let e=await o(),t=e?.linkedAccounts.filter(e=>"passkey"===e.type).map(e=>e.credentialId)??[];await _(t)}catch(e){v(e)}finally{y(!1)}};return 0===b.length||p?(0,h.jsx)(AW,{onReset:i,onClose:n,onClick:C,isCreating:p}):f?(0,h.jsx)(AB,{appName:e,onClick:x,onClose:x}):w?(0,h.jsx)(b8,{error:w,backFn:()=>v(null),onClick:()=>v(null)}):(0,h.jsx)(A$,{passkeys:b,isSubmitting:d,isCreating:p,onReset:i,onClose:n,onSubmitEnrollment:()=>_(b.map(e=>e.credentialId)),onAddPasskey:C})},AW=({onReset:e,onClose:t,onClick:n,isCreating:i})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:e,onClose:t},"header"),(0,h.jsx)(f$,{children:(0,h.jsxs)(IG,{children:[(0,h.jsx)(wj,{}),(0,h.jsx)(_t,{})]})}),(0,h.jsx)(fB,{children:"Set up passkey verification"}),(0,h.jsxs)(fV,{children:[(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(i_.A,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(px.A,{})}),"Takes seconds to set up and use"]}),(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(pT.A,{})}),"Use your passkey to verify transactions and login to your account"]})]}),(0,h.jsx)(gn,{style:{marginTop:"2.25rem"},onClick:n,loading:i,children:"Add a new passkey"}),(0,h.jsx)(fP,{})]}),A$=({onReset:e,onClose:t,onAddPasskey:n,onSubmitEnrollment:i,passkeys:r,isSubmitting:a,isCreating:s})=>{let[o,l]=(0,m.useState)(!1),c=o?r.length:r.length>3?2:3;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:o?()=>l(!1):e,onClose:t},"header"),!o&&(0,h.jsx)(f$,{children:(0,h.jsxs)(IG,{children:[(0,h.jsx)(wj,{}),(0,h.jsx)(_t,{})]})}),(0,h.jsx)(fB,{children:"Enable your passkeys for verification"}
58),(0,h.jsxs)(fV,{children:[r.slice(0,c).map(e=>(0,h.jsxs)(Az,{children:[(0,h.jsx)(Aq,{children:AH(e)}),(0,h.jsxs)(AV,{children:["Last used: ",e.latestVerifiedAt?.toLocaleString()]})]},e.credentialId)),!o&&r.length>3&&(0,h.jsx)(AG,{onClick:()=>l(!0),children:"View All"})]}),(0,h.jsx)(gn,{style:{marginTop:"1.5rem"},onClick:i,loading:a,children:"Enable passkeys"}),r.length<5&&(0,h.jsx)(AG,{style:{marginTop:"0.5rem"},onClick:n,disabled:s,children:s?(0,h.jsx)(f8,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),(0,h.jsx)(fP,{})]})},AB=({appName:e,onClick:t,onClose:n})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:n},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(pc.A,{})}),(0,h.jsx)(fB,{children:"Passkey verification added"}),(0,h.jsxs)(fz,{children:["From now on, you'll use the passkey whenever you use your ",e," wallet."]}),(0,h.jsx)(fK,{children:(0,h.jsx)(gn,{onClick:t,children:"Done"})}),(0,h.jsx)(fP,{})]}),Az=ig.I4.div.withConfig({displayName:"PasskeyItem",componentId:"sc-d5b2bf9c-0"})(["&&{padding:0.75rem 1rem;text-align:left;border-radius:0.5rem;border:1px solid var(--privy-color-foreground-4);width:100%;}"]),Aq=ig.I4.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-d5b2bf9c-1"})(["font-size:0.875rem;line-height:1.375rem;font-weight:500;color:var(--privy-color-foreground-1);"]),AV=ig.I4.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-d5b2bf9c-2"})(["font-size:0.75rem;font-weight:400;line-height:1.125rem;color:var(--privy-color-foreground-2);"]),AH=e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device",AG=ig.I4.button.withConfig({displayName:"StyledLink",componentId:"sc-d5b2bf9c-3"})(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:0.75rem 1rem;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent);:focus{outline:none;box-shadow:none;}}"]),AK=({appName:e,onComplete:t,onReset:n,onClose:i})=>{let[r,a]=(0,m.useState)(""),[s,o]=(0,m.useState)(!1),[l,c]=(0,m.useState)(null),[d,u]=(0,m.useState)("enroll"),{initEnrollmentWithSms:p,submitEnrollmentWithSms:y}=AR(),{app:f,data:g}=yQ();function w(){g?.mfaEnrollmentFlow?.onSuccess(),t()}return l?(0,h.jsx)(b8,{error:l,backFn:()=>c(null),onClick:()=>c(null)}):(0,h.jsxs)(h.Fragment,"enroll"===d?{children:[(0,h.jsx)(fR,{backFn:n,onClose:i},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(ix.A,{})}),(0,h.jsx)(fB,{children:"Set up SMS verification"}),(0,h.jsxs)(fz,{children:["We'll text a verification code to this mobile device whenever you use your ",e," ","wallet."]}),(0,h.jsxs)(fq,{children:[(0,h.jsx)(_d,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await p({phoneNumber:e}),a(e),u("verify")}catch(e){c(e)}},hideRecent:!0}),(0,h.jsxs)(f1,{children:["By providing your mobile number, you agree to receive text messages from ",f?.name,". Some carrier charges may apply"]})]}),(0,h.jsx)(fP,{})]}:s?{children:[(0,h.jsx)(fR,{onClose:w},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(pc.A,{})}),(0,h.jsx)(fB,{children:"SMS verification added"}),(0,h.jsxs)(fz,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",e," wallet."]}),(0,h.jsx)(fK,{children:(0,h.jsx)(gn,{onClick:w,children:"Done"})}),(0,h.jsx)(fP,{})]}:{children:[(0,h.jsx)(fR,{backFn:function(){"verify"===d?u("enroll"):n()},onClose:i},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(ix.A,{})}),(0,h.jsx)(fB,{children:"Enter enrollment code"}),(0,h.jsxs)(fq,{children:[(0,h.jsx)(wL,{onChange:async function(e){try{if(!e)return;await y({phoneNumber:r,mfaCode:e}),o(!0)}catch(e){if(wK(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");
58if(wG(e))throw Error("The code you entered is not valid");if(wH(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw wJ(e)?Error("Verification canceled"):Error("Unknown error")}}}),(0,h.jsxs)(fz,{children:["To continue, enter the 6-digit code sent to ",(0,h.jsx)("strong",{children:`*${r.replaceAll("-","").slice(-4)}`})]})]}),(0,h.jsx)(fP,{})]})},AJ=({size:e,authUrl:t})=>(0,h.jsx)(xZ,{url:t,squareLogoElement:pA.A,size:e,fgColor:"#1F1F1F"}),AZ=({onComplete:e,onClose:t,onReset:n,totpInfo:i})=>{let[r,a]=(0,m.useState)("enroll"),[s,o]=(0,m.useState)(!1),{submitEnrollmentWithTotp:l}=AR(),{data:c}=yQ();function d(){c?.mfaEnrollmentFlow?.onSuccess(),e()}return(0,h.jsxs)(h.Fragment,"enroll"===r?{children:[(0,h.jsx)(fR,{backFn:n,onClose:t},"header"),(0,h.jsx)(fB,{children:"Scan QR code"}),(0,h.jsx)(fz,{children:"Open your authenticator app and scan the QR code to continue."}),(0,h.jsx)(gQ,{children:(0,h.jsx)(AJ,{authUrl:i.authUrl,size:200})}),(0,h.jsxs)(fK,{children:[(0,h.jsx)(gZ,{children:(0,h.jsx)(xL,{itemName:"setup key",text:i.secret})}),(0,h.jsx)(gn,{onClick:function(){a("verify")},children:"Continue"})]}),(0,h.jsx)(fP,{})]}:s?{children:[(0,h.jsx)(fR,{onClose:d},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(pc.A,{})}),(0,h.jsx)(fB,{children:"Authenticator app verification added"}),(0,h.jsxs)(fz,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",i.appName," wallet."]}),(0,h.jsx)(fK,{children:(0,h.jsx)(gn,{onClick:d,children:"Done"})}),(0,h.jsx)(fP,{})]}:{children:[(0,h.jsx)(fR,{backFn:function(){"verify"===r?a("enroll"):n()},onClose:t},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(iv.A,{})}),(0,h.jsx)(fB,{children:"Enter enrollment code"}),(0,h.jsx)(fq,{children:(0,h.jsx)(wL,{onChange:async function(e){try{if(!e)return;await l({mfaCode:e}),o(!0)}catch(e){if(wK(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(wG(e))throw Error("The code you entered is not valid");if(wH(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw wJ(e)?Error("Verification canceled"):Error("Unknown error")}}})}),(0,h.jsxs)(fz,{children:["To continue, enter the 6-digit code generated from your ",(0,h.jsx)("strong",{children:"authenticator app"})]}),(0,h.jsx)(fP,{})]})},AY={component:()=>{let{user:e,enrollInMfa:t,ready:n}=(0,ic.u)(),[i,r]=(0,m.useState)(null),{unenrollWithSms:a,unenrollWithTotp:s,unenrollWithPasskey:o}=AR(),{app:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=yQ(),{closePrivyModal:u}=(0,n8.u)(),{promptMfa:p}=fE(),{initEnrollmentWithTotp:y}=AR(),[f,g]=(0,m.useState)(!1),[w,v]=(0,m.useState)(null),[b,x]=(0,m.useState)(null),_=()=>{u({shouldCallAuthOnSuccess:!0}),t(!1),setTimeout(()=>{r(null),v(null)},500)},{initEnrollmentWithPasskey:C,submitEnrollmentWithPasskey:I}=AR(),[E,T]=(0,m.useState)(!1),[A,S]=(0,m.useState)(null);d.current=_;let k=e?.mfaMethods.includes("sms"),P=!!e?.phone,j=e?.mfaMethods.includes("totp"),O=e?.mfaMethods.includes("passkey"),N=k||j||O,R=e?.linkedAccounts.filter(e=>"passkey"===e.type).map(e=>e.credentialId)??[];function M(){r(null),v(null)}if((0,m.useEffect)(()=>{N&&g(!0)},[N]),!n||!e||!l)return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:_},"header"),(0,h.jsx)(f$,{children:(0,h.jsx)(AM,{})}),(0,h.jsx)(fq,{children:(0,h.jsx)(f8,{})}),(0,h.jsx)(fP,{})]});if("sms"===i)return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:M,onClose:_},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(iI.A,{})}),(0,h.jsx)(fB,{children:"Remove SMS verification?"}),(0,h.jsxs)(fz,{children:["MFA adds an extra layer of security to your ",l?.name," account. Make sure you have other methods to secure your account."]}),(0,h.jsx)(fK,{children:(0,h.jsx)(gn,{warn:!0,onClick:async function(){r(null);try{await a()}catch(e){r(null)}},children:"Remove SMS for MFA"})}),(0,h.jsx)(fP,{})]});if("totp"===i)return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:M,onClose:_},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(iI.A,{})}),(0,h.jsx)(fB,{children:"Remove Authenticator App verification?"}),(0,h.jsxs)(fz,{children:["MFA adds an extra layer of security to your ",l?.name," account. Make sure you have other methods to secure your account."]}),(0,h.jsx)(fK,{children:(0,h.jsx)(gn,{warn:!0,onClick:async function(){r(null);try{await s()}catch(e){r(null)}},children:"Remove Authenticator App for MFA"})}),(0,h.jsx)(fP,{})]});if("passkey"===i){let e=c?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{backFn:M,onClose:_},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(iI.A,{})}),(0,h.jsx)(fB,{children:"Are you sure you want to remove this passkey?"}),(0,h.jsx)(fz,{children:e?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),(0,h.jsx)(fK,{children:(0,h.jsx)(gn,{warn:!0,onClick:async function(){r(null);try{await o({removeForLogin:c?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){r(null)}},children:"Yes, remove"})}),(0,h.jsx)(fP,{})]})}if(0===c.mfaEnrollmentFlow.mfaMethods.length&&!N)return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:_},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(i_.A,{})}),(0,h.jsx)(fB,{children:"Add more security"}),(0,h.jsxs)(fz,{children:[l?.name," does not have any verification methods enabled."]}),(0,h.jsx)(fK,{children:(0,h.jsx)(gn,{onClick:_,children:"Close"})}),(0,h.jsx)(fP,{})]});let D=!N&&!f;return D?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{onClose:_},"header"),(0,h.jsx)(f3,{style:{marginBottom:"1.5rem"},children:(0,h.jsx)(i_.A,{})}),(0,h.jsx)(fB,{children:"Transaction Protection"}),(0,h.jsx)(fz,{children:"Set up transaction protection to add an extra layer of security to your account"}
58),(0,h.jsxs)(fV,{children:[(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(pC.A,{})}),"Enable 2-Step verification for your ",l?.name," wallet."]}),(0,h.jsxs)(fG,{children:[(0,h.jsx)(fH,{children:(0,h.jsx)(pI.A,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),(0,h.jsxs)(fK,{children:[(0,h.jsx)(gn,{onClick:()=>g(!0),children:"Continue"}),(0,h.jsx)(go,{onClick:_,children:"Not now"})]}),(0,h.jsx)(fP,{})]}):"sms"===w?(0,h.jsx)(AK,{appName:l?.name||"Privy",onComplete:_,onReset:M,onClose:_}):"totp"===w&&b?(0,h.jsx)(AZ,{onComplete:_,onClose:_,onReset:M,totpInfo:{...b,appName:l?.name||"Privy"}}):"passkey"===w?(0,h.jsx)(AF,{appName:l?.name||"Privy",onComplete:_,onReset:M,onClose:_}):(0,h.jsx)(AU,{showIntro:D,userMfaMethods:e.mfaMethods,appMfaMethods:l.mfa.methods,userHasAuthSms:P,onBackToIntro:function(){g(!1)},handleSelectMethod:async function(e){return await p().catch(S),"totp"===e?(v(e),x(null),void y().then(e=>{x(e)}).catch(()=>{x(null),M()})):"passkey"===e&&1===R.length?await async function(){T(!0);try{await C(),await I({credentialIds:R},{removeForLogin:c?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){S(e)}finally{T(!1)}}():void v(e)},isTotpLoading:"totp"===w&&!b,isPasskeyLoading:E,error:A,onClose:_,setRemovingMfaMethod:async e=>{await p().catch(S),r(e)}})}},AQ={component:()=>{let{authenticated:e,logout:t,ready:n,user:i}=(0,ic.u)(),{app:r,setModalData:a,navigate:s,resetNavigation:o}=yQ(),{getAuthMeta:l,initLoginWithOAuth:c,loginWithOAuth:d,updateWallets:u,setReadyToTrue:p,closePrivyModal:y,
58createAnalyticsEvent:f}=(0,n8.u)(),[g,w]=(0,m.useState)(!1),[v,b]=(0,m.useState)(void 0),x=l()?.provider||"google",{name:_,component:C}=mj(x);(0,m.useEffect)(()=>{d(x).then(()=>{w(!0),p(!0)}).catch(e=>{if(p(!1),e?.privyErrorCode===n6.a.ALLOWLIST_REJECTED)return b(void 0),o(),void s(xY);if(e?.privyErrorCode===n6.a.USER_LIMIT_REACHED)return console.error(new n6.ag(e).toString()),b(void 0),o(),void s(x1);if(e?.privyErrorCode===n6.a.USER_DOES_NOT_EXIST)return b(void 0),o(),void s(bz);if(e?.privyErrorCode===n6.a.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return b(void 0),o(),a({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:l()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void s(xh);let{retryable:t,detail:n}=function(e,t){let n={detail:"",retryable:!1},i=mw(t);if(e?.privyErrorCode===n6.a.LINKED_TO_ANOTHER_USER&&(n.detail="This account has already been linked to another user."),e?.privyErrorCode===n6.a.INVALID_CREDENTIALS&&(n.retryable=!0,n.detail="Something went wrong. Try again."),e.privyErrorCode===n6.a.OAUTH_USER_DENIED&&(n.detail=`Retry and check ${i} to finish connecting your account.`,n.retryable=!0),e?.privyErrorCode===n6.a.TOO_MANY_REQUESTS&&(n.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===n6.a.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=mj(t).name;n.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===n6.a.OAUTH_ACCOUNT_SUSPENDED){let e=mj(t).name;n.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===n6.a.CANNOT_LINK_MORE_OF_TYPE&&(n.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===n6.a.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(n.detail="Something went wrong. Please try again."),n}(e,x);b({retryable:t,detail:n,message:"Authentication failed"})}).finally(()=>{mO()})},[_,x]),(0,m.useEffect)(()=>{if(n&&e&&g&&i){if(r?.legal.requireUsersAcceptTerms&&!i.hasAcceptedTerms){let e=setTimeout(()=>{s(x_)},1400);return()=>clearTimeout(e)}if(b$(i,r.embeddedWallets)){let e=setTimeout(()=>{a({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),f({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:x,screen:"OAuthStatusScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),s(xb)},1400);return()=>clearTimeout(e)}{let e=setTimeout(()=>y({shouldCallAuthOnSuccess:!0,isSuccess:!0}),1400);return u(),()=>clearTimeout(e)}}},[n,e,g,i]);let I=g?`Successfully connected with ${_}`:v?v.message:`Verifying connection to ${_}`,E="";return E=g?"You’re good to go!":v?v.detail:"Just a few moments more",(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{}),(0,h.jsx)(g3,{}),(0,h.jsxs)(AX,{children:[(0,h.jsx)(wP,{children:(0,h.jsxs)("div",{children:[(0,h.jsx)(f6,{success:g,fail:!!v}),(0,h.jsx)(C,{style:{width:"38px",height:"38px"}})]})}),(0,h.jsxs)(g1,{children:[(0,h.jsx)("h3",{children:I}),(0,h.jsx)("p",{children:E})]}),v&&v?.retryable?(0,h.jsx)(gc,{onClick:()=>{mO(),c(x),b(void 0)},disabled:!g&&!v?.retryable,children:"Retry"}):null]}),(0,h.jsx)(g4,{}),(0,h.jsx)(fP,{})]})}},AX=ig.I4.div.withConfig({displayName:"ConnectContainer",componentId:"sc-89bb91a9-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),A0=(0,m.forwardRef)((e,t)=>{let[n,i]=(0,m.useState)(""),[r,a]=(0,m.useState)(""),[s,o]=(0,m.useState)(!1),{authenticated:l,user:c}=(0,ic.u)(),{initUpdateEmail:d}=(0,n8.u)(),{navigate:u,setModalData:p,currentScreen:y}=yQ(),{enabled:f,token:g}=mz(),w=yK(),v=pW(n)&&(w.disablePlusEmails&&n.includes("+")?(r||a("Please enter a valid email address without a '+'."),!1):(r&&a(""),!0)),b=s||!v,x=()=>{!f||g||l?(async e=>{if(!c?.email)throw Error("User is required to have an email address to update it.");o(!0);try{await d({oldAddress:c.email.address,newAddress:n,captchaToken:e}),u(Cp)}
58catch(e){p({errorModalData:{error:e,previousScreen:y||CN}})}o(!1)})(g):(p({captchaModalData:{callback:e=>{if(!c?.email)throw Error("User is required to have an email address to update it.");return d({oldAddress:c.email.address,newAddress:n,captchaToken:e})},userIntentRequired:!1,onSuccessNavigateTo:Cp,onErrorNavigateTo:b6}}),u(xR))};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(A1,{children:[r&&(0,h.jsx)(Cx,{style:{marginTop:"0.25rem",textAlign:"left"},children:r}),(0,h.jsxs)(A2,{$error:!!r,children:[(0,h.jsx)(hZ.A,{}),(0,h.jsx)("input",{ref:t,id:"email-input",type:"email",placeholder:"[email protected]",onChange:e=>i(e.target.value),onKeyUp:e=>{"Enter"===e.key&&x()},value:n,autoComplete:"email"}),e.stacked?null:(0,h.jsx)(gd,{isSubmitting:s,onClick:x,disabled:b,children:"Submit"})]})]}),e.stacked?(0,h.jsx)(gn,{loadingText:null,loading:s,disabled:b,onClick:x,children:"Submit"}):null]})}),A1=CE,A2=CC,A3={component:()=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(vT,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:(0,h.jsx)(hZ.A,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),(0,h.jsx)(gJ,{children:(0,h.jsx)(A0,{stacked:!0})}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})},A4={component:()=>{let{currentScreen:e,data:t,navigate:n,setModalData:i}=yQ(),{user:r}=(0,ic.u)(),{initUpdatePhone:a}=(0,n8.u)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fR,{},"header"),(0,h.jsx)(g3,{}),(0,h.jsx)(vT,{title:"Update your phone number",description:"Add the phone number you'd like to use going forward. We'll send you a confirmation code",icon:(0,h.jsx)(ix.A,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),(0,h.jsx)(gJ,{children:(0,h.jsx)(_d,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:s}){try{if(!r?.phone?.number)throw Error("User is required to have an phone number to update it.");await a(r?.phone?.number,s),n(Cp)}catch(r){i({errorModalData:{error:r,previousScreen:t?.errorModalData?.previousScreen||e||AP}}),n(b6)}},hideRecent:!0})}),(0,h.jsx)(g4,{}),(0,h.jsx)(fk,{})]})}},A5=(0,hV.v)(()=>({jwtAuthFlowState:{status:"not-enabled"}}));function A6({customAuth:e}){let{jwtAuthFlowState:t}=function({customAuth:e}){let t=fp(),n=(0,m.useRef)(),i=(0,m.useCallback)(e=>(n.current=e,()=>{n.current=void 0}),[]),r=e?.getCustomAccessToken??(()=>Promise.resolve(void 0)),{state:a}=function({subscribe:e,getExternalJwt:t,enabled:n=!0,onAuthenticated:i,onUnauthenticated:r,onError:a}){let{client:s,onCustomAuthAuthenticated:o}=(0,n8.u)(),{logout:l,authenticated:c,ready:d}=In();if(!s)throw new n6.P("`useSyncJwtBasedAuthState` must be used within a `PrivyProvider`");let[u,h]=(0,m.useState)({status:"initial"}),p=(0,m.useRef)(),y=(0,m.useRef)(!1),f=(0,m.useRef)(t);(0,m.useEffect)(()=>{f.current=t},[t]);let g=(0,m.useRef)(i);(0,m.useEffect)(()=>{g.current=i},[i]);let w=(0,m.useRef)(r);(0,m.useEffect)(()=>{w.current=r},[r]);let v=(0,m.useRef)(a);return(0,m.useEffect)(()=>{v.current=a},[a]),(0,m.useEffect)(()=>{if(!n||!d)return;let t=async()=>{if(!y.current){y.current=!0;try{h({status:"loading"});let e=await f.current();if(void 0!==p.current&&p.current===e)return void h({status:"done"});if(!e)return c&&(await l(),w.current?.()),p.current=e,void h({status:"done"});s.startAuthFlow(new y6(e));let{user:t,isNewUser:n=!1}=await s.authenticate();if(!t)throw new n6.P("Failed to sync with custom auth provider");g.current?.({user:t,isNewUser:n}),o(t,n),p.current=e,h({status:"done"})}catch(e){if(console.warn(e),await l().catch(()=>{}),w.current?.(),e instanceof n6.J&&e.privyErrorCode===n6.a.LINKED_TO_ANOTHER_USER)return h({status:"initial"}),void setTimeout(()=>{t()},0);v.current?.(e),h({status:"error",error:e})}finally{y.current=!1}}};return t(),e(t)},[e,s,o,c,l,n,d]),n?{state:u}:{state:{status:"not-enabled"}}}({enabled:!0===e?.enabled,subscribe:i,getExternalJwt:r,onAuthenticated:({user:e,isNewUser:n})=>{t("login","onComplete",{user:e,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),t("customAuth","onAuthenticated",{user:e})},onUnauthenticated:()=>{t("customAuth","onUnauthenticated")},onError:e=>{t("login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR)}});return(0,m.useEffect)(()=>{(async()=>{e&&!e.isLoading&&n.current?.()})()},[e?.enabled,e?.getCustomAccessToken,e?.isLoading]),{jwtAuthFlowState:a}}({customAuth:e});return(0,m.useEffect)(()=>{A5.setState({jwtAuthFlowState:t})},[t]),null}let A8=(0,m.createContext)(!1);async function A7(){return a?a.getAccessToken():Promise.resolve(pR.get(me)||pR.get(p8)||null)}let A9=(e,t)=>
58s(e,t),Se=(e,t)=>o(e,t),St=(e,t)=>l(e,t),Sn=(e,t)=>c(e,t),Si=e=>d(e),Sr=e=>u(e),Sa=({config:e,...t})=>{var n;if((()=>{if((0,m.useContext)(A8))throw new n6.P("Multiple PrivyProvider instances found","Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree.")})(),"undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new n6.P("Embedded wallet is only available over HTTPS");if("string"!=typeof(n=t.appId)||25!==n.length)throw new n6.P("Cannot initialize the Privy provider with an invalid Privy app ID");a||(a=new fa({appId:t.appId,appClientId:t.clientId,apiUrl:t.apiUrl}));let i=Object.assign({},e),r=(0,m.useMemo)(()=>new n5({appId:t.appId,clientId:t.clientId,storage:pR,baseUrl:t.apiUrl,sdkVersion:"react-auth:2.17.3"}),[]);return(0,h.jsx)(yG,{client:r,legacyClient:a,clientConfig:i,children:(0,h.jsx)(_T,{children:(0,h.jsx)(Ss,{...t,client:a,privy:r})})})},Ss=e=>{let t=e.client,i=e.privy,r=_A();(()=>{let e=yK();(0,m.useEffect)(()=>{(async e=>{let t=new URL("v3/wallets","https://explorer-api.walletconnect.com");t.searchParams.append("projectId",e);let n=await fetch(t);return n.ok?Object.values((await n.json()).listings).sort(({slug:e},{slug:t})=>"rainbow"===e&&"metamask"===t?1:"metamask"===e||"rainbow"===e?-1:1):(console.debug(`Failed to fetch WalletConnect listings: ${await n.text().catch(()=>"No response.")}`),[])})(e.walletConnectCloudProjectId).then(e=>yP({listings:e})).catch(console.error)},[e.walletConnectCloudProjectId])})();let[a,b]=(0,m.useState)(!1),[x,_]=(0,m.useState)(!1),[C,I]=(0,m.useState)(!1),[E,T]=(0,m.useState)(null),[A,S]=(0,m.useState)([]),[k,P]=(0,m.useState)([]),[j,O]=(0,m.useState)(!1),[N,R]=(0,m.useState)(null),[D,U]=(0,m.useState)(!1),[L,F]=(0,m.useState)({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:n8.a}),[W,$]=(0,m.useState)({status:"initial"}),[B,z]=(0,m.useState)({status:"initial"}),[q,V]=(0,m.useState)({status:"initial"}),[H,G]=(0,m.useState)({status:"initial"}),[K,J]=(0,m.useState)({status:"initial"}),[Z,Y]=(0,m.useState)({status:"initial"}),[Q,X]=(0,m.useState)(null),ee=yK(),et=yJ(),[en,ei]=(0,m.useState)({}),[er,ea]=(0,m.useState)(null),es=(0,m.useRef)(null),[eo,el]=(0,m.useState)(!1),[ec,ed]=(0,m.useState)(!1),eu=(0,m.useRef)(null),eh=(0,m.useRef)(null),ep=(0,m.useRef)(fl),[em,ey]=(0,m.useState)(!1);t.onStoreCustomerAccessToken=e=>{e&&fh(ep,"accessToken","onAccessTokenGranted",{accessToken:e})},t.onDeleteCustomerAccessToken=()=>{T(null),I(!1),fh(ep,"accessToken","onAccessTokenRemoved")};let ef=(0,m.useRef)(null),eg=(0,m.useRef)(null),ew=(0,m.useRef)(!1),ev=({showWalletUIs:e})=>ew.current?ew.current:void 0!==e?!e:!ee.embeddedWallets.showWalletUIs,eb=e=>{R(e),setTimeout(()=>{b(!0)},15)};(0,m.useEffect)(()=>{if(!E)return void t.connectors?.removeEmbeddedWalletConnectors();let n=(0,ic.g)(E),r=(0,ic.l)(E),a=(0,ic.k)(E);n&&r.length||t.connectors?.removeEmbeddedWalletConnectors(),a||t.connectors?.removeImportedWalletConnector(),t.connectors?Q?(n&&t.connectors.addEmbeddedWalletConnectors({walletProxy:Q,user:E,embeddedWallets:r,defaultChain:ee.defaultChain,appId:e.appId,privyClient:i}),a&&t.connectors.addImportedWalletConnector(Q,a.address,ee.defaultChain,e.appId)):console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized"):console.debug("Failed to add embedded wallet connector: Client connectors not initialized")},[Q,E]),(0,m.useEffect)(()=>{Q&&es.current?.(Q)},[Q]);let ex=(0,m.useCallback)((e,t)=>{T(e),O(t),I(!0),ed(!0)},[]);(0,m.useEffect)(()=>{ec&&Q&&E&&(async()=>{let e=bU(E,ee.embeddedWallets.ethereum.createOnLogin),t=bF(E,ee.embeddedWallets.solana.createOnLogin),n=await A7();if(n){if(e&&t){let e=await Q.create({accessToken:n});return await Q.createSolana({accessToken:n,ethereumAddress:e?.address}),void ed(!1)}if(t)return await Q.createSolana({accessToken:n,ethereumAddress:(0,ic.g)(E)?.address}),await eW.refreshSessionAndUser(),void ed(!1);if(e)return await Q.create({accessToken:n}),void ed(!1)}})().catch(console.error)},[ec&&Q&&E]),(0,m.useEffect)(()=>
58{if(ee.externalWallets.solana.connectors)return ee.externalWallets.solana.connectors.onMount(),()=>ee.externalWallets.solana.connectors?.onUnmount()},[ee.externalWallets.solana.connectors]),(0,m.useEffect)(()=>{!x&&et&&async function(){let e,n=e_(),i=eC(),r=(0,p.y)();t.initializeConnectorManager({walletConnectCloudProjectId:ee.walletConnectCloudProjectId,rpcConfig:ee.rpcConfig,chains:ee.chains,defaultChain:ee.defaultChain,store:r,walletList:ee.appearance.walletList,shouldEnforceDefaultChainOnConnect:ee.shouldEnforceDefaultChainOnConnect,externalWalletConfig:ee.externalWallets,appName:ee.name??"Privy",walletChainType:ee.appearance.walletChainType,appKit:ee.externalWallets.walletConnect.appKit}),t.connectors?.on("connectorInitialized",()=>{e&&clearTimeout(e);let n=t.connectors.walletConnectors.length,i=t.connectors.walletConnectors.reduce((e,t)=>e+ +!!t.initialized,0);i===n?ey(!0):e=setTimeout(()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:i,expected:n}),ey(!0)},1500)}),t.connectors?.initialize().then(()=>{eS()});let a=await t.getAuthenticatedUser(),s=!!a;ee.legal.requireUsersAcceptTerms&&a&&!a.hasAcceptedTerms?(await t.logout(),eW.setReadyToTrue(!0),fh(ep,"logout","onSuccess")):(ee.customAuth?.enabled||(I(!!a),a&&fh(ep,"login","onComplete",{user:a,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),T(a)),n?eg.current=s?"link":"login":i&&!s?(eg.current="login",ei({telegramAuthModalData:{seamlessAuth:!0}}),eb(_w)):eW.setReadyToTrue(!!a))}()},[t,er,x,et]),(0,m.useEffect)(()=>{if(x){if(!E||!E.linkedAccounts.find(e=>"wallet"===e.type&&"privy"===e.walletClientType))return void el(!!Q);if([...A].some(e=>"privy"===e.walletClientType))return void el(!0);el(!!Q)}},[x,E,A,Q]),(0,m.useEffect)(()=>{t.connectors?.setWalletList(ee.appearance.walletList)},[ee.appearance.walletList.join()]);let e_=()=>{let e=function(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),n=e.get("privy_oauth_state"),i=e.get("privy_oauth_provider");if(!t||!n||!i)return{inProgress:!1};let r=!1;try{r=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:n,provider:i,withPrivyUi:!pR.get(mc),popupFlow:null!==window.opener&&r,disableSignup:!!pR.get(md)}}();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&e.provider.startsWith("privy:")&&!e.popupFlow&&(new BroadcastChannel(vy).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(t.startAuthFlow(new mg(e)),eb(AQ),!0))},eC=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),n=e.get("hash"),i=Number(e.get("auth_date")||""),r=e.get("first_name");if(t&&r&&i&&n)return Object.fromEntries(e.entries())}())?(mG(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=mH(e.replace("#tgWebAppData=","")),{user:n,auth_date:i,hash:r}=t;return n&&i&&r?t:void 0}())?(mG(),{flowType:"web-app",authData:e}):void 0}();if(!e||!ee.loginMethods.telegram||!ee.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let n=new mq;return t.startAuthFlow(n),"login-url"===e.flowType&&(n.meta.telegramWebAppData=void 0,n.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(n.meta.telegramAuthResult=void 0,n.meta.telegramWebAppData=e.authData),!0},eI=async(e,n,i,r)=>{if("solana_adapter"!==e)eE(await t.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:n})||null,n,i,r);else{let e=t.connectors?.findSolanaWalletConnector(n);if(!e)return;eE(e,n,i,r)}};async function eE(e,t,n,i){if(!e)return F({status:"disconnected",connectedWallet:null,connectError:new n6.d("Unable to connect to wallet."),connector:null,connectRetry:n8.a}),i?.(null,n);F({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:n8.a}),e instanceof y0&&t&&await e.resetConnection(t),F({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>eE(e,t,n,i)});try{let t=await e.connect({showPrompt:!0});if((!t||m5(t))&&ee.shouldEnforceDefaultChainOnConnect&&!ee.chains.find(e=>e.id===Number(t?.chainId.replace("eip155:","")))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){F(t=>
58({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:n8.a}));try{await t?.switchChain(ee.defaultChain.id),t&&(t.chainId=pK((0,g.nj)(ee.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${ee.defaultChain.id}`)}}return F(e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:n8.a})),t&&fh(ep,"connectWallet","onSuccess",{wallet:t}),i?.(t,n)}catch(e){return e instanceof n6.y?(console.warn(e.cause?e.cause:e.message),fh(ep,"connectWallet","onError",e.privyErrorCode||n6.a.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),fh(ep,"connectWallet","onError",n6.a.UNKNOWN_CONNECT_WALLET_ERROR)),F(t=>({...t,status:"disconnected",connectedWallet:null,connectError:e})),i?.(null,n)}}let eT=async(e,n,i)=>{if(null===e||!m5(e))return;let r=new mM(t,e,n,i);t.startAuthFlow(r)},eA=async(e,n,i,a="plain")=>{let s=r(_S);if("transaction"===a&&!s)throw new n6.P("useSolanaLedger plugin hook must be mounted");if(null===e||!yT(e))return;let o=new mU(e,t,n,i,a,s?{deserializeTransactionFromB64String:s.deserializeTransactionFromB64String,prepareSiwsTransactionWithMemo:s.prepareSiwsTransactionWithMemo}:void 0);t.startAuthFlow(o)},eS=()=>{let e=new URLSearchParams(window.location.search),n=e.get("privy_connector"),i=e.get("privy_wallet_client"),r="true"===e.get("privy_connect_only");if(!n||!i)return;let a=yx({connectorType:n,walletClientType:i});if(!a||!a.isInstalled)return eb(AN);if(!t.connectors)throw new n6.P("Connector not initialized");eb(r?_B:_L);let s=new URL(window.location.href);s.searchParams.delete("privy_connector"),s.searchParams.delete("privy_wallet_client"),s.searchParams.delete("privy_connect_only"),window.history.pushState({},"",s),eI(n,i,void 0,r?void 0:"solana_adapter"===n?eA:eT)};(0,m.useEffect)(()=>{x&&C&&null===E&&t.getAuthenticatedUser().then(T)},[x,C,E,t]);let ek=e=>{if(!C)throw fh(ep,"linkAccount","onError",n6.a.MUST_BE_AUTHENTICATED,{linkMethod:e}),new n6.P("User must be authenticated before linking an account.")},eP=e=>{if(!C||!E)return!1;if("privy"===e.walletClientType)return!0;for(let t of E.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},ej=async e=>{let n;if(!t.connectors)throw new n6.P("Connector not initialized");n="ethereum"===e.type?t.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:t.connectors.findSolanaWalletConnector(e.walletClientType)||null,F(t=>({...t,connector:n,status:"connected",connectedWallet:e,connectError:null,connectRetry:n8.a})),ee.captchaEnabled&&!C?(ei({captchaModalData:{callback:t=>m5(e)?eT(e,t):eA(e,t),userIntentRequired:!1,onSuccessNavigateTo:_L,onErrorNavigateTo:b6}}),eb(xR)):(m5(e)?await eT(e):await eA(e),eb(_L))},eO=()=>{S(e=>{let n=t.connectors?.wallets.filter(m5).map(e=>({...e,linked:eP(e),loginOrLink:async()=>{if(!await e.isConnected())throw new n6.P("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new n6.P("Cannot link or login with embedded wallet");ej(e)},fund:async t=>{await eW.fundWallet(e.address,t)},unlink:async()=>{if(!C)throw new n6.P("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new n6.P("Cannot unlink an embedded wallet");T(await t.unlinkEthereumWallet(e.address))}}))||[];return m6(e,n)?e:n}),P(e=>{let n=(t.connectors?.wallets??[]).filter(yT).map(e=>({...e,linked:eP(e),loginOrLink:async()=>{if(!await e.isConnected())throw new n6.P("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new n6.P("Cannot link or login with embedded wallet");ej(e)},fund:async()=>{throw new n6.P("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!C)throw new n6.P("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new n6.P("Cannot unlink an embedded wallet");T(await t.unlinkSolanaWallet(e.address))}}));return m6(e,n)?e:n})};(0,m.useEffect)(()=>{eO()},[E?.linkedAccounts,C,x]),(0,m.useEffect)(()=>{if(x){if(!t.connectors)throw new n6.P("Connector not initialized");eO(),t.connectors.on("walletsUpdated",eO)}},[x]),(0,m.useEffect)(()=>{[...ee.loginMethodsAndOrder?.primary??[],...ee.loginMethodsAndOrder?.overflow??[]].filter(e=>
58e.startsWith("privy:")).forEach(e=>t.getCrossAppProviderDetails(e.replace("privy:","")))},[!!t]);let eN=({transaction:n,uiOptions:r,fundWalletConfig:a,address:s,signOnly:o})=>new Promise(async(l,c)=>{let{requesterAppId:d}=r||{},u=o?"signTransaction":"sendTransaction",h=s?(0,ic.b)(E,s):(0,ic.g)(E);if(!h&&s){let e=(0,ic.m)(A,s);if(e)try{let t=await e.getEthereumProvider(),i={...n,from:s,chainId:n.chainId||Number(e.chainId.replace("eip155:","")),value:void 0!==n.value?(0,g.nj)(n.value):void 0},r=await t.request({method:"sendTransaction"===u?"eth_sendTransaction":"eth_signTransaction",params:[i]});return fh(ep,u,"onSuccess",{hash:r}),void l({hash:r})}catch(e){return fh(ep,u,"onError",n6.a.TRANSACTION_FAILURE),void c(e??new m3("Unable to "+u+e))}}if(!h)return fh(ep,u,"onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),void c(new n6.P("No embedded or connected wallet found for address."));if(!C||!E)return fh(ep,u,"onError",n6.a.MUST_BE_AUTHENTICATED),void c(Error("User must be authenticated before signing with a Privy wallet"));let p=h.address,m=h.walletIndex??0,{entropyId:y,entropyIdVerifier:v}=mY(E,h),b=e$.wallets.find(e=>"privy"===e.walletClientType&&(0,f.b)(e.address)===(0,f.b)(p));if(!b)return fh(ep,u,"onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have a Privy wallet before signing"));let x=await b.getEthereumProvider(),_=await x.request({method:"eth_chainId"}),I=n.chainId?Number(n.chainId):vm(_);(e=>{if(!ee.chains.map(e=>e.id).includes(e))throw new n6.d(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,n6.a.UNSUPPORTED_CHAIN_ID)})(I);let T={...n,from:n.from??p,chainId:I},S=await A7();if(!S||!Q)return fh(ep,u,"onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have valid access token and Privy wallet to send transaction"));let k=pL(T.chainId,ee.chains,ee.rpcConfig,{appId:e.appId}),P=(0,ic.c)(h),j=async()=>{try{let e;if(!await eW.recoverEmbeddedWallet({address:p}))throw fh(ep,u,"onError",n6.a.UNKNOWN_CONNECT_WALLET_ERROR),c(Error("Unable to connect to wallet")),Error("Unable to connect to wallet");let t=o?T:await wA(T,k,T.from);if(P){let n=e=>null==e?void 0:(0,g.nj)(e),r=await M(i,async({message:e})=>await Q.signWithUserSigner({accessToken:S,requesterAppId:d,message:e}),{chain_type:"ethereum",method:"eth_signTransaction",params:{transaction:{from:t.from,to:t.to,nonce:n(t.nonce),chain_id:n(t.chainId),data:(0,w.q)(t.data)?t.data?t.data:(0,g.nj)(Uint8Array.from(t.data)):void 0,value:n(t.value),type:t.type,gas_limit:n(t.gasLimit??t.gas),gas_price:n(t.gasPrice??t.gas),max_fee_per_gas:n(t.maxFeePerGas),max_priority_fee_per_gas:n(t.maxPriorityFeePerGas)}},wallet_id:h.id});if(!r.data||!("signed_transaction"in r.data))throw new m3("Unable to sign transaction");e=r.data.signed_transaction}else e=await vp({accessToken:S,entropyId:y,entropyIdVerifier:v,transactingWalletIndex:m,walletProxy:Q,transactionRequest:t,requesterAppId:d});if(o)return fh(ep,"signTransaction","onSuccess",{signature:e}),e;{let t=await k.sendRawTransaction({serializedTransaction:e});return fh(ep,"sendTransaction","onSuccess",{hash:t}),t}}catch(e){throw fh(ep,u,"onError",n6.a.TRANSACTION_FAILURE),e}};if(ev({showWalletUIs:r?.showWalletUIs}))j().then(e=>{o?fh(ep,"signTransaction","onSuccess",{signature:e}):fh(ep,"sendTransaction","onSuccess",{hash:e}),l({hash:e})}).catch(e=>{fh(ep,u,"onError",n6.a.TRANSACTION_FAILURE),c(e)});else{let e={connectingWalletAddress:p,recoveryMethod:h.recoveryMethod,entropyId:y,entropyIdVerifier:v,onCompleteNavigateTo:TQ,isUnifiedWallet:P,onFailure:e=>{fh(ep,u,"onError",n6.a.UNKNOWN_CONNECT_WALLET_ERROR),c(e)}},n=Ir(ee)?ER({address:p,appConfig:ee,fundWalletConfig:a,methodScreen:EP,chainIdOverride:T.chainId,comingFromSendTransactionScreen:!0}):void 0;ei({connectWallet:e,sendTransaction:{transactionRequest:T,transactingWalletIndex:m,transactingWalletAddress:p,entropyId:y,entropyIdVerifier:v,signOnly:o,scanTransaction:async()=>{let e=await wA(T,k,T.from);return await t.scanTransaction({metadata:{domain:ee.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})},onConfirm:()=>j(),onSuccess:e=>{o?fh(ep,"signTransaction","onSuccess",{signature:e.hash}):fh(ep,"sendTransaction","onSuccess",{hash:e.hash}),l(e)},onFailure:e=>{fh(ep,u,"onError",n6.a.TRANSACTION_FAILURE),c(e)},uiOptions:r||{},fundWalletConfig:a,requesterAppId:d},funding:n}),eb(EB)}});function eR(){return new Promise(async(e,t)=>{let n=await A7();
58if(!n||!Q)throw Error("Must have valid access token to enroll in MFA");try{await Q.verifyMfa({accessToken:n}),e()}catch(e){t(e)}})}let eM=e=>e?.linkedAccounts.filter(e=>null!==e.latestVerifiedAt&&("wallet"!==e.type||"privy"!==e.walletClientType)).sort((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime())[0],eD=e=>{let t=E?.linkedAccounts.filter(t=>t.type===e).length??0,{displayName:n,loginMethod:i}=bE(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw fh(ep,"linkAccount","onError",n6.a.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:i}),new n6.P(`User already has an account of type ${n} linked.`)};async function eU({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){R(null);let n=t?"setWalletPassword":"setWalletRecovery";if(!C||!E)throw fh(ep,n,"onError",n6.a.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let i=(0,ic.h)(E);if(!i||!Q)throw fh(ep,n,"onError",n6.a.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");let r=(0,ic.c)(i);if(r)throw fh(ep,n,"onError",n6.a.UNSUPPORTED_WALLET_TYPE),new n6.P("User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");try{await eR()}catch(e){throw fh(ep,n,"onError",n6.a.MISSING_MFA_CREDENTIALS),e}return new Promise((a,s)=>{let o="user-passcode"===i.recoveryMethod,l=CH({walletAction:"update",availableRecoveryMethods:ee.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:o,showAutomaticRecovery:e}),{entropyId:c,entropyIdVerifier:d}=mY(E),u={recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,onCompleteNavigateTo:l,shouldForceMFA:!1,entropyId:c,isUnifiedWallet:r,entropyIdVerifier:d,onFailure:e=>{fh(ep,n,"onError",n6.a.UNKNOWN_CONNECT_WALLET_ERROR),s(e)}};ei({setWalletPassword:{onSuccess:e=>{fh(ep,n,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{fh(ep,n,"onError",n6.a.USER_EXITED_SET_PASSWORD_FLOW),s(e)},callAuthOnSuccessOnClose:!1},recoverWallet:{entropyId:c,entropyIdVerifier:d,onFailure:s},connectWallet:u,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:o,shouldCreateEth:!1,shouldCreateSol:!1}}),eb(EB)})}async function eL({appId:e,action:n}){let i=await A7();if("link"===n&&!i)throw fh(ep,"linkAccount","onError",n6.a.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new n6.P("User must be authenticated before linking an account.");if("login"===n&&i)throw fh(ep,"login","onError",n6.a.UNKNOWN_AUTH_ERROR),new n6.P("Attempted to log in, but user is already logged in. Use a `link` helper instead.");ef.current=`privy:${e}`,eg.current=n;let r=vv();return t.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise(async(i,a)=>{let{name:s,logoUrl:o}=await vw({api:t.api,providerAppId:e,requesterAppId:ee.id});ei({crossAppAuth:{appId:e,name:s,logoUrl:o,action:n,popup:r,onSuccess:i,onError:a}}),eb(Af)})}let eF={ready:x,authenticated:C,user:E,walletConnectors:t.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),ei({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType,description:e?.description}}),eb(C?T3:Am)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),ek("siwe"),ef.current="siwe",eg.current="link",ei({...en,externalConnectWallet:{...en.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),eb(Aj)},startCrossAppAuthFlow:eL,linkEmail:()=>{ek("email"),eD("email"),ef.current="email",eg.current="link",eb(Ak)},linkPhone:()=>{ek("sms"),eD("phone"),ef.current="sms",eg.current="link",eb(AP)},linkGoogle:async()=>{ek("google"),eD("google_oauth"),eg.current="link",await eW.initLoginWithOAuth("google")},linkTwitter:async()=>{ek("twitter"),eD("twitter_oauth"),eg.current="link",await eW.initLoginWithOAuth("twitter")},linkDiscord:async()=>{ek("discord"),eD("discord_oauth"),eg.current="link",await eW.initLoginWithOAuth("discord")},linkGithub:async()=>{ek("github"),eD("github_oauth"),eg.current="link",await eW.initLoginWithOAuth("github")},linkSpotify:async()=>{ek("spotify"),eD("spotify_oauth"),eg.current="link",await eW.initLoginWithOAuth("spotify")},linkInstagram:async()=>{ek("instagram"),eD("instagram_oauth"),eg.current="link",await eW.initLoginWithOAuth("instagram")},linkTiktok:async()=>{ek("tiktok"),eD("tiktok_oauth"),eg.current="link",await eW.initLoginWithOAuth("tiktok")},linkLine:async()=>{ek("line"),eD("line_oauth"),eg.current="link",await eW.initLoginWithOAuth("line")},linkLinkedIn:async()=>{ek("linkedin"),eD("linkedin_oauth"),eg.current="link",await eW.initLoginWithOAuth("linkedin")},linkApple:async()=>{ek("apple"),eD("apple_oauth"),eg.current="link",await eW.initLoginWithOAuth("apple")},linkPasskey:async()=>{ek("passkey"),eD("passkey"),await eW.initLinkWithPasskey(),eb(IH)},linkTelegram:async e=>{if(ek("telegram"),eD("telegram"),eg.current="link",ef.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let n=new mq;t.startAuthFlow(n),n.meta.telegramAuthResult=void 0,n.meta.telegramWebAppData=mH(e.launchParams.initDataRaw),ei({telegramAuthModalData:{seamlessAuth:!0}}),eb(_w)}else fh(ep,"linkAccount","onError",n6.a.INVALID_DATA,{linkMethod:"telegram"});else await eW.initLoginWithTelegram();eb(_w)},linkFarcaster:async()=>{ek("farcaster"),eD("farcaster"),await eW.initLoginWithFarcaster(),eg.current="link",ef.current="farcaster",eb(x6)},updateEmail:()=>{if(ek("email"),!E?.email)throw new n6.P("User does not have an email linked to their account.");eg.current="update",ef.current="email",eb(A3)},updatePhone:()=>{if(ek("sms"),!E?.phone)throw new n6.P("User does not have a phone number linked to their account.");eg.current="update",ef.current="sms",eb(A4)},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!x){let e=await new Promise(e=>{ea(t=>e.bind(t))});if(ea(null),e)return void console.warn(t)}!E||E.isGuest?(eg.current="login",ei({login:e}),eb(CN)):console.warn(t)},connectOrCreateWallet:async()=>{x||(await new Promise(e=>{ea(()=>e)}
58),ea(null)),C?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(eg.current="connect-or-create",eb(Cs))},logout:async()=>{if(eg.current=null,ef.current=null,E&&t.clearProviderAcccessTokens(E),R(null),await t.logout(),E&&Q)try{await Q.clearMfa({userId:E.id})}catch(e){}T(null),I(!1),fh(ep,"logout","onSuccess"),b(!1),pR.del(mr),pR.del(ma(ee.id))},getAccessToken:(0,m.useCallback)(()=>t.getCustomerAccessToken(),[t]),unlinkWallet:async e=>{let n;return T(n=e.startsWith("0x")?await t.unlinkEthereumWallet(e):await t.unlinkSolanaWallet(e)),n},unlinkEmail:async e=>{let n=await t.unlinkEmail(e);return T(n),n},unlinkPhone:async e=>{let n=await t.unlinkPhone(e);return T(n),n},unlinkGoogle:async e=>{let n=await t.unlinkOAuth("google",e);return T(n),n},unlinkTwitter:async e=>{let n=await t.unlinkOAuth("twitter",e);return T(n),n},unlinkDiscord:async e=>{let n=await t.unlinkOAuth("discord",e);return T(n),n},unlinkGithub:async e=>{let n=await t.unlinkOAuth("github",e);return T(n),n},unlinkSpotify:async e=>{let n=await t.unlinkOAuth("spotify",e);return T(n),n},unlinkInstagram:async e=>{let n=await t.unlinkOAuth("instagram",e);return T(n),n},unlinkTiktok:async e=>{let n=await t.unlinkOAuth("tiktok",e);return T(n),n},unlinkLine:async e=>{let n=await t.unlinkOAuth("line",e);return T(n),n},unlinkLinkedIn:async e=>{let n=await t.unlinkOAuth("linkedin",e);return T(n),n},unlinkApple:async e=>{let n=await t.unlinkOAuth("apple",e);return T(n),n},unlinkFarcaster:async e=>{let n=await t.unlinkFarcaster(e);return T(n),n},unlinkTelegram:async e=>{let n=await t.unlinkTelegram(e);return T(n),n},unlinkPasskey:async e=>{let n=await A7();if(!n)throw Error("Must have valid access token to enroll in MFA");if(!Q)throw Error("Wallet proxy not initialized.");let i=ee.passkeys.shouldUnenrollMfaOnUnlink;await Q.unlinkPasskeyAccount({credentialId:e,accessToken:n,removeAsMfa:i});let r=await t.getAuthenticatedUser();return T(r),r},unlinkCrossAppAccount:async({subject:e})=>{let n=E?.linkedAccounts.find(t=>"cross_app"===t.type&&t.subject===e)?.providerApp;if(!n)throw new n6.P("Invalid subject");t.storeProviderAccessToken(n.id,null);let i=await t.unlinkOAuth(`privy:${n.id}`,e);return T(i),i},setWalletRecovery:async e=>eU({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>eU({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,n)=>new Promise(async(r,a)=>{let{requesterAppId:s}=n?.uiOptions||{},o=e.message,l=n?.address?(0,ic.b)(E,n.address):(0,ic.g)(E);if(!l&&void 0!==n?.address){let e=(0,ic.m)(A,n.address);if(e)try{let t=await e.getEthereumProvider(),n=await t.request({method:"personal_sign",params:[o,e.address]});return fh(ep,"signMessage","onSuccess",{signature:n}),void r({signature:n})}catch(e){return fh(ep,"signMessage","onError",n6.a.UNABLE_TO_SIGN),void a(e??new m3("Unable to sign message"))}}if(!l)throw new n6.P("No embedded or connected wallet found for address.");if(!C||!E)return fh(ep,"signMessage","onError",n6.a.MUST_BE_AUTHENTICATED),void a(Error("User must be authenticated before signing with a Privy wallet"));let c=l.address,d=l.walletIndex??0,{entropyId:u,entropyIdVerifier:h}=mY(E,l),p=(0,ic.c)(l);if("string"!=typeof o||o.length<1)return fh(ep,"signMessage","onError",n6.a.INVALID_MESSAGE),void a(Error("Message must be a non-empty string"));let m=async()=>{let n;if(!C)throw Error("User must be authenticated before signing with a Privy wallet");let r=await A7();if(!Q||!r||!await eW.recoverEmbeddedWallet({address:c}))throw Error("Unable to connect to wallet");if(t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:c,requesterAppId:s}}
58),p){let t=(0,w.q)(e.message,{strict:!0}),a=await M(i,async({message:e})=>await Q.signWithUserSigner({accessToken:r,requesterAppId:s,message:e}),{chain_type:"ethereum",method:"personal_sign",params:t?{message:o.slice(2),encoding:"hex"}:{message:o,encoding:"utf-8"},wallet_id:l.id});if(!a.data||!("signature"in a.data))throw new m3("Unable to sign message");n=a.data.signature}else{let{response:e}=await Q.rpc({accessToken:r,entropyId:u,entropyIdVerifier:h,chainType:"ethereum",hdWalletIndex:d,requesterAppId:s,request:{method:"personal_sign",params:[o,c]}});n=e.data}return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:c,requesterAppId:s}}),n};if(ev({showWalletUIs:n?.uiOptions?.showWalletUIs}))try{let e=await m();fh(ep,"signMessage","onSuccess",{signature:e}),r({signature:e})}catch(e){fh(ep,"signMessage","onError",n6.a.UNABLE_TO_SIGN),a(e??new m3("Unable to sign message"))}else ei({signMessage:{method:"personal_sign",data:o,confirmAndSign:m,onSuccess:e=>{fh(ep,"signMessage","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{fh(ep,"signMessage","onError",n6.a.UNABLE_TO_SIGN),a(e)},uiOptions:n?.uiOptions||{}},connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:c,entropyId:u,entropyIdVerifier:h,onCompleteNavigateTo:TC,isUnifiedWallet:p,onFailure:e=>{fh(ep,"signMessage","onError",n6.a.UNKNOWN_CONNECT_WALLET_ERROR),a(e)}}}),eb(EB)}),signTypedData:(e,n)=>new Promise(async(r,a)=>{let{requesterAppId:s}=n?.uiOptions||{},o=n?.address?(0,ic.b)(E,n.address):(0,ic.g)(E);if(!o&&n?.address){let t=(0,ic.m)(A,n.address);if(t)try{let n=await t.getEthereumProvider(),i=pZ(e),a=await n.request({method:"eth_signTypedData_v4",params:[t.address,i]});return fh(ep,"signTypedData","onSuccess",{signature:a}),void r({signature:a})}catch(e){return fh(ep,"signTypedData","onError",n6.a.UNABLE_TO_SIGN),void a(e??new m3("Unable to sign typed data "+e))}}if(!o)throw new n6.P("No embedded or connected wallet found for address.");if(!C||!E)return fh(ep,"signTypedData","onError",n6.a.MUST_BE_AUTHENTICATED),void a(Error("User must be authenticated before signing with a Privy wallet"));let l=o.address,c=o.walletIndex??0,{entropyId:d,entropyIdVerifier:u}=mY(E,o),h=(0,ic.c)(o),p=pZ(e),m=async()=>{let e;if(!C)throw Error("User must be authenticated before signing with a Privy wallet");let n=await A7();if(!Q||!n||!await eW.recoverEmbeddedWallet({address:l}))throw Error("Unable to connect to wallet");if(t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:l,requesterAppId:s}}),h){let{domain:t,types:r,primaryType:a,message:l}=p,c=await M(i,async({message:e})=>await Q.signWithUserSigner({accessToken:n,requesterAppId:s,message:e}),{chain_type:"ethereum",method:"eth_signTypedData_v4",params:{typed_data:{domain:t,types:r,primary_type:a,message:l}},wallet_id:o.id});if(!c.data||!("signature"in c.data))throw new m3("Unable to sign message");e=c.data.signature}else{let{response:t}=await Q.rpc({accessToken:n,entropyId:d,entropyIdVerifier:u,chainType:"ethereum",hdWalletIndex:c,requesterAppId:s,request:{method:"eth_signTypedData_v4",params:[l,p]}});e=t.data}return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:l,requesterAppId:s}}),e};if(ev({showWalletUIs:n?.uiOptions?.showWalletUIs}))try{let e=await m();fh(ep,"signTypedData","onSuccess",{signature:e}),r({signature:e})}catch(e){fh(ep,"signTypedData","onError",n6.a.UNABLE_TO_SIGN),a(e??new m3("Unable to sign message"))}else ei({signMessage:{method:"eth_signTypedData_v4",data:p,confirmAndSign:m,onSuccess:e=>{fh(ep,"signTypedData","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{fh(ep,"signTypedData","onError",n6.a.UNABLE_TO_SIGN),a(e)},uiOptions:n?.uiOptions||{}},connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:d,isUnifiedWallet:h,entropyIdVerifier:u,onCompleteNavigateTo:TC,onFailure:e=>{fh(ep,"signMessage","onError",n6.a.UNKNOWN_CONNECT_WALLET_ERROR),a(e)}}}),eb(EB)}),sendTransaction:async(e,t)=>await eN({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await eN({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:n=>new Promise(async(i,r)=>{if(!C||!E)return void r(Error("User must be authenticated before exporting their Privy wallet"));n&&"target"in n&&n&&(n=void 0);let a=n?.address?(0,ic.b)(E,n.address):(0,ic.g)(E),s=(0,ic.h)(E);if(!a||!s)return void r(new n6.P("User must have an embedded wallet."));let o=a.address,{entropyId:l,entropyIdVerifier:c}=mY(E,a),d=(0,ic.c)(a);if(!o)return void r(Error("User does not have an HD Ethereum wallet. To export an imported wallet, pass the `address` of the wallet to `exportWallet`."));
58if(!(0,v.P)(o))return void r(Error("Must provide a valid Ethereum address."));let u={recoveryMethod:a.recoveryMethod,connectingWalletAddress:a.address,isUnifiedWallet:d,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:EL,onFailure:r,shouldForceMFA:!0};ei(en),await A7()&&Q?Q?vu(a)?(ei({keyExport:{appId:e.appId,appClientId:e.clientId,origin:t.apiUrl,address:a.address,entropyId:l,entropyIdVerifier:c,hdWalletIndex:a.walletIndex,chainType:a.chainType,walletId:a.id,isUnifiedWallet:d,imported:a.imported,onSuccess:i,onFailure:r},connectWallet:u}),eb(EB)):r(Error(`Export is not supported for ${a.chainType} wallets`)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))}),promptMfa:eR,async init(e){switch(e){case"sms":return void await t.initMfaSmsVerification();case"passkey":return await t.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new n6.P("Invalid MFA code");eu.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise((e,t)=>{eh.current={resolve:e,reject:t}});break;case"passkey":let i;if("string"==typeof t)throw new n6.P("Invalid authenticator response");let r=await n.e(1190).then(n.bind(n,601190)),a={id:(i=await r.startAuthentication(t)).id,raw_id:i.rawId,response:{client_data_json:i.response.clientDataJSON,authenticator_data:i.response.authenticatorData,signature:i.response.signature,user_handle:i.response.userHandle},authenticator_attachment:i.authenticatorAttachment,client_extension_results:{app_id:i.clientExtensionResults.appid,cred_props:i.clientExtensionResults.credProps,hmac_create_secret:i.clientExtensionResults.hmacCreateSecret},type:i.type};eu.current?.resolve({mfaMethod:e,mfaCode:a,relyingParty:window.origin}),await new Promise((e,t)=>{eh.current={resolve:e,reject:t}});break;default:throw eu.current?.reject(new n6.P("Unsupported MFA method")),new n6.P(`Unsupported MFA method: ${e}`)}},cancel(){eu.current?.reject(new n6.P("MFA canceled"))},async initEnrollmentWithSms(e){let t=await A7();if(!t||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise((t,n)=>{if(!e)return eW.closePrivyModal(),void t();ee.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),ei({mfaEnrollmentFlow:{mfaMethods:ee.mfa.methods,shouldUnlinkOnUnenrollMfa:ee.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:n}}),eb(AY)}),async initEnrollmentWithTotp(){let e=await A7();if(!e||!Q)throw Error("Must have valid access token to enroll in MFA");let t=await Q.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let n=await A7();if(!n||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.submitEnrollMfa({method:"sms",accessToken:n,phoneNumber:e.phoneNumber,code:e.mfaCode}),T(await t.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let n=await A7();if(!n||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.submitEnrollMfa({method:"totp",accessToken:n,code:e.mfaCode}),T(await t.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},n={}){let i=await A7();if(!i||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.submitEnrollMfa({method:"passkey",accessToken:i,credentialIds:e,removeForLogin:n.removeForLogin}),T(await t.getAuthenticatedUser())},async unenroll(e,n={}){let i=await A7();if(!i||!Q)throw Error("Must have valid access token to remove MFA");"passkey"===e?await Q.submitEnrollMfa({method:"passkey",accessToken:i,credentialIds:[],removeForLogin:n.removeForLogin}):await Q.unenrollMfa({method:e,accessToken:i}),T(await t.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await A7(),n=E?.linkedAccounts.find(e=>"wallet"===e.type&&"privy"===e.walletClientType);
58if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if((0,ic.c)(n))throw new n6.P("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!E?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await eW.recoverEmbeddedWallet({address:n.address}))throw Error("Unable to connect to wallet");let i=await Q.initFarcasterSigner({address:n.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===i.status&&T(await t.getAuthenticatedUser()||E||null),ei({farcasterSigner:i}),eb(AI)},getFarcasterSignerPublicKey:async()=>{let e,t=await A7(),n=E?.linkedAccounts.find(e=>"wallet"===e.type&&"privy"===e.walletClientType);if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if((0,ic.c)(n))throw new n6.P("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!E?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await eW.recoverEmbeddedWallet({address:n.address}))throw Error("Unable to connect to wallet");if(!E.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=E.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map(e=>parseInt(e,16)))},signFarcasterMessage:async e=>{let t=await A7(),i=E?.linkedAccounts.find(e=>"wallet"===e.type&&"privy"===e.walletClientType);if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!i)throw Error("Must have an embedded wallet to use Farcaster signers");if((0,ic.c)(i))throw new n6.P("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!E?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await eW.recoverEmbeddedWallet({address:i.address}))throw Error("Unable to connect to wallet");if(!E.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let r=await n.e(1190).then(n.bind(n,601190)),a=await Q.signFarcasterMessage({address:i.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:r.bufferToBase64URLString(e)},fid:BigInt(E.farcaster.fid),relyingParty:window.origin});return new Uint8Array(r.base64URLStringToBuffer(a.signature))},signMessageWithCrossAppWallet(e,{address:n,chainId:i}){let r=E?.linkedAccounts.some(e=>"cross_app"===e.type&&e.smartWallets.some(e=>e.address===n));return vx({user:E,client:t,address:n,requesterAppId:ee.id,request:{method:r?"privy_signSmartWalletMessage":"personal_sign",params:[e,n],chainId:i},reconnect:eL})},signTypedDataWithCrossAppWallet(e,{address:n,chainId:i}){let r=E?.linkedAccounts.some(e=>"cross_app"===e.type&&e.smartWallets.some(e=>e.address===n)),a=pZ(e);return vx({user:E,client:t,address:n,requesterAppId:ee.id,request:{method:r?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[n,a],chainId:i},reconnect:eL})},sendTransactionWithCrossAppWallet(e,{address:n}){let i=E?.linkedAccounts.some(e=>"cross_app"===e.type&&e.smartWallets.some(e=>e.address===n));return vx({user:E,client:t,address:n,requesterAppId:ee.id,request:{method:i?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:eL})},isModalOpen:a,mfaMethods:ee.mfa.methods};s=eF.signMessage,o=eF.signTypedData,c=async(e,t)=>await eN({transaction:e,...t,signOnly:!1}),l=async(e,t)=>({signature:(await eN({transaction:e,...t,signOnly:!0})).hash});let eW={privy:i,setAuthenticated:I,setUser:T,setIsNewUser:O,isNewUserThisSession:j,pendingTransaction:null,walletConnectionStatus:L,connectors:t.connectors?.walletConnectors??[],solanaWallets:k,rpcConfig:ee.rpcConfig,chains:ee.chains,appId:e.appId,showFiatPrices:"native-token"!==ee.embeddedWallets.priceDisplay.primary,clientAnalyticsId:t.clientAnalyticsId,onCustomAuthAuthenticated:ex,hideWalletUIs:ew,isHeadlessSigning:(0,m.useCallback)(ev,[ee.embeddedWallets.showWalletUIs]),emailOtpState:B,setEmailOtpState:z,smsOtpState:q,setSmsOtpState:V,oAuthState:K,setOAuthState:J,telegramAuthState:Z,setTelegramAuthState:Y,siweState:H,setSiweState:G,isHeadlessOAuthLoading:D,nativeTokenSymbolForChainId:e=>ee.chains.find(t=>
58t.id===Number(e))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(Q)return Q;let t=new Promise(e=>{es.current=e}),n=new Promise(t=>setTimeout(()=>t(null),e)),i=await Promise.race([t,n]);return es.current=null,i},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>t.authFlow?.meta,client:t,closePrivyModal:async(n={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let i,a=x&&C&&E;a&&ef.current&&(i=eM(E)),"login"===eg.current?n.shouldCallAuthOnSuccess&&a&&ef.current?fh(ep,"login","onComplete",{user:E,isNewUser:j,wasAlreadyAuthenticated:!1,loginMethod:ef.current,loginAccount:i??null}):fh(ep,"login","onError",n6.a.USER_EXITED_AUTH_FLOW):"link"===eg.current&&i?n.isSuccess&&a&&ef.current?fh(ep,"linkAccount","onSuccess",{user:E,linkMethod:ef.current,linkedAccount:i}):ef.current&&fh(ep,"linkAccount","onError",n6.a.USER_EXITED_LINK_FLOW,{linkMethod:ef.current}):"update"===eg.current&&i?n.isSuccess&&a&&ef.current?fh(ep,"update","onSuccess",{user:E,updateMethod:ef.current,updatedAccount:i}):ef.current&&fh(ep,"update","onError",n6.a.USER_EXITED_UPDATE_FLOW,{linkMethod:ef.current}):"connect-or-create"===eg.current&&(A[0]?fh(ep,"connectOrCreateWallet","onSuccess",{wallet:A[0]}):fh(ep,"connectOrCreateWallet","onError",n6.a.USER_EXITED_AUTH_FLOW));let s=N&&T1.has(N),o=N===b6&&en.errorModalData&&T1.has(en.errorModalData.previousScreen);if((s||o)&&en.funding){let t,n=T1.get(N)??null;if("solana"===en.funding.chainType){let e=r(C5);if(e)try{t=BigInt(await e.getBalance({address:en.funding.address,cluster:en.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");fh(ep,"fundSolanaWallet","onUserExited",{address:en.funding.address,cluster:en.funding.cluster,fundingMethod:n,balance:t})}else{let i=pL(en.funding.chain.id,ee.chains,ee.rpcConfig,{appId:e.appId});try{t=await i.getBalance({address:en.funding.address})}catch{console.error("Unable to pull wallet balance")}fh(ep,"fundWallet","onUserExited",{address:en.funding.address,chain:en.funding.chain,fundingMethod:n,balance:t})}}ei(e=>({...e,externalConnectWallet:{suggestedAddress:void 0}})),eg.current=null,ef.current=null,O(!1),b(!1),setTimeout(()=>{t.authFlow=void 0},200)},openPrivyModal:eb,connectWallet:eE,initLoginWithWallet:async(e,t,n,i)=>{m5(e)?(ef.current="siwe",eT(e,t,n)):(ef.current="siws",eA(e,t,n,i))},loginWithWallet:async()=>{let e,n,i;if(!x)throw new n6.ai;if(t.authFlow instanceof mM?e="siwe":t.authFlow instanceof mU&&(e="siws"),!e)throw new n6.P("Must initialize SIWE/SIWS flow first.");if(null!==await t.getAccessToken())try{({user:n}=await t.link()),ef.current=e}catch(t){throw fh(ep,"linkAccount","onError",t.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:n,isNewUser:i}=await t.authenticate()),ef.current=e}catch(e){throw fh(ep,"login","onError",e.privyErrorCode||n6.a.GENERIC_CONNECT_WALLET_ERROR),e}T(n||E||null),O(i||!1),I(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:n})=>new Promise(async(i,r)=>{let a=await A7();if(!C||!E||!a)throw new n6.P("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new n6.P("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let s=eW.walletProxy??await eW.initializeWalletProxy(15e3);if(!s)throw new n6.P("Wallet proxy not initialized.");if((({address:e,user:t})=>!!vh(t).find(t=>t.address===e))({address:e,user:E}))return i();let o=(0,ic.b)(E,e);if(!o)throw new n6.P("Address to delegate is not associated with current user.");if((0,ic.c)(o))throw new n6.P("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let l=(({address:e,user:t})=>{let n=t.linkedAccounts.find(t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e);if(!n)throw new n6.P("Address to delegate is not associated with current user.");if(!vu(n))throw new n6.P(`useDelegatedActions is not supported for ${n.chainType} wallets. Use the useSessionSigners hook to provision server side access on behalf of your users.`);return{address:n.address,chainType:n.chainType,walletIndex:n.walletIndex??0}})({address:e,user:E}),c=(({address:e,user:t})=>{let n=t.linkedAccounts.find(t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e);if(!n)throw new n6.P("Address to delegate is not associated with current user.");let i=n.imported?n:(0,ic.h)(t);if(!i)throw new n6.P("Unable to determine root address for delegated address.");
58if(!vu(i))throw new n6.P(`useDelegatedActions is not supported for ${i.chainType} wallets. Use the useSessionSigners hook to provision server side access on behalf of your users.`);return{address:i.address,chainType:i.chainType,imported:i.imported}})({address:e,user:E}),d=async()=>{await s.createDelegatedAction({accessToken:a,rootWallet:c,delegatedWallets:[l]}),await eW.refreshSessionAndUser()};if(await eW.recoverEmbeddedWallet({address:e}),n)ei({delegatedActions:{consent:{address:e,onDelegate:d,onSuccess:async()=>{i()},onError:async e=>{r(e)}}}}),eb(Aw);else try{await d(),i()}catch(e){r(e)}}),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise(async(n,i)=>{if(!C||!E)throw new n6.P("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");let r=vh(E);if(0===r.length)throw new n6.P("User has no delegated wallets to revoke.");if(r.some(ic.c))throw new n6.P("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let a=async()=>{await t.revokeDelegatedWallet(),await eW.refreshSessionAndUser()};if(e)ei({delegatedActions:{revoke:{onRevoke:a,onSuccess:async()=>{n()},onError:async e=>{i(e)}}}}),eb(Ax);else try{await a(),n()}catch(e){i(e)}}),initLoginWithFarcaster:async(e,n)=>{let i=new p5(e,n);t.startAuthFlow(i);try{ef.current="farcaster",await i.initializeFarcasterConnect()}catch(e){throw"login"===eg.current?fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR):"link"===eg.current&&fh(ep,"linkAccount","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,n;if(!x)throw new n6.ai;if(!(t.authFlow instanceof p5))throw new n6.P("Must initialize Farcaster flow first.");if(null!==await t.getAccessToken())try{({user:e}=await t.link()),ef.current="farcaster"}catch(e){throw fh(ep,"linkAccount","onError",e.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:n}=await t.authenticate()),ef.current="farcaster"}catch(e){throw fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR),e}T(e||null),O(n||!1),I(!0)},async crossAppAuthFlow({appId:e,popup:n,action:i}){let r=`privy:${e}`;ef.current=r;let{url:a,stateCode:s,codeVerifier:o}=await async function({api:e,appId:t}){let n=my(),i=my(),r=await mf(n);try{let{url:a}=await e.post(n6.k,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:r,state_code:i});return{url:a,stateCode:i,codeVerifier:n}}catch(e){throw(0,n6.f)(e)}}({api:t.api,appId:e});if(!a)throw t.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new n6.P("No authorization URL returned for cross-app auth.");try{let l=await async function({url:e,popup:t}){return t.location=e,new Promise((e,n)=>{let i,r=setTimeout(()=>{n(new n6.P("Authorization request timed out after 2 minutes.")),a()},12e4);function a(){t?.close(),window.removeEventListener("message",o)}let s=setInterval(()=>{t?.closed&&!i&&(a(),clearInterval(s),clearTimeout(r),n(new n6.P("User rejected request")))},300);function o(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(r),e(t.data),a()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(r),n(new n6.P(t.data.error)),a()),t.data.type===vf&&((i=new BroadcastChannel(vy)).onmessage=o))}window.addEventListener("message",o)})}({url:a,popup:n,provider:r}),c=l.stateCode,d=l.authorizationCode;if(c!==s)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:r,storedStateCode:s??"",returnedStateCode:c??""}}),new n6.P("Unexpected auth flow. This may be a phishing attempt.",void 0,n6.a.OAUTH_UNEXPECTED);let u=await async function({appId:e,stateCode:t,codeVerifier:n,authorizationCode:i,action:r,client:a}){if(!i||!t)throw new n6.P("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===i)throw new n6.P("User denied confirmation during cross-app auth flow");try{let s=new vg({authorizationCode:i,stateCode:t,codeVerifier:n,provider:`privy:${e}`});a.startAuthFlow(s);let o="link"===r?await a.link():await a.authenticate(),l=o.oAuthTokens?.accessToken;return console.debug(),l}catch(t){let e=(0,n6.f)(t);if(e.privyErrorCode)throw new n6.P(e.message||"Invalid code during cross-app auth flow.",void 0,e.privyErrorCode);
58if("User denied confirmation during cross-app auth flow"===e.message)throw new n6.P("Invalid code during cross-app auth flow.",void 0,n6.a.OAUTH_USER_DENIED);throw new n6.P("Invalid code during cross-app auth flow.",void 0,n6.a.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:o,stateCode:c,authorizationCode:d,action:i,client:t});u&&t.storeProviderAccessToken(e,u);let h=await eW.refreshSessionAndUser();if(!h)throw new n6.P("Unable to update user");return t.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),h}catch(e){throw t.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:r}}),e}},async initLoginWithOAuth(e,n,i){if(ef.current=e,!pN()||"google"===e&&_C(window.navigator.userAgent))return void eb(AA);"twitter"===e&&window.opener&&window.opener.postMessage({type:vf},"*"),pR.del(mc),pR.del(md);let r=new mg({provider:e,disableSignup:!!i,withPrivyUi:!0});n&&r.addCaptchaToken(n),t.startAuthFlow(r);let a=await t.authFlow.getAuthorizationUrl();a&&a.url&&("twitter"===e&&y.m0&&(a.url=a.url.replace("x.com","twitter.com")),window.location.assign(a.url))},async initLoginWithTelegram(e,n){if(!x)throw new n6.ai;ef.current="telegram";let i=new mq(e,n);t.startAuthFlow(i),Y({status:"loading"}),i.meta.telegramWebAppData=void 0,i.meta.telegramAuthResult=await new Promise((e,t)=>ee.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:ee.loginConfig.telegramAuthConfiguration.botId,request_access:!0},n=>n?e(n):t(new n6.P("Telegram auth failed or was canceled by the client"))):t(new n6.P("Telegram was not initialized")):t(new n6.P("Telegram Auth configuration is not loaded")))},async loginWithTelegram(e){let n,i;if(!(t.authFlow instanceof mq))throw new n6.P("Must initialize Telegram flow before calling loginWithTelegram");t.authFlow.meta.captchaToken||=e?.captchaToken;let r=await A7(),a=e?.intent||eg.current;if("login"===a)try{let e=await t.authenticate();n=e.user,i=e.isNewUser,ef.current="telegram"}catch(e){throw fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR),e}else{if("link"!==a)throw new n6.P("Unknown auth intent");try{n=(await t.link()).user,ef.current="telegram"}catch(e){throw fh(ep,"linkAccount","onError",e.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}T(n),O(i||!1),I(!0),Y({status:"done"});let s=n?.linkedAccounts.find(({type:e})=>"telegram"===e)||null;return{user:n,isNewUser:i||!1,wasAlreadyAuthenticated:!!r,loginAccount:s}},async loginWithOAuth(e){let n,i,r;if(!(t.authFlow instanceof mg))throw new n6.P("Must initialize OAuth flow before calling loginWithOAuth");let a=pR.get(mo),s=t.authFlow.meta.stateCode;if(a!==s)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:a??"",returnedStateCode:s??""}}),new n6.P("Unexpected auth flow. This may be a phishing attempt.",void 0,n6.a.OAUTH_UNEXPECTED);if(null!==await t.getAccessToken())try{let i=await t.link();n=i.user,r=i.oAuthTokens,ef.current=e}catch(t){throw fh(ep,"linkAccount","onError",t.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let a=await t.authenticate();n=a.user,i=a.isNewUser,r=a.oAuthTokens,ef.current=e}catch(t){throw"login"===eg.current?fh(ep,"login","onError",t.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR):"link"===eg.current&&fh(ep,"linkAccount","onError",t.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return T(n),O(i||!1),I(!0),r&&n&&fh(ep,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:n}),r},passkeyAuthState:W,setPasskeyAuthState:$,async initSignupWithPasskey({captchaToken:e,withPrivyUi:n}){let i=new mN({captchaToken:e,setPasskeyAuthState:$});t.startAuthFlow(i),eg.current="login";try{ef.current="passkey",$({status:"generating-challenge"}),await i.initRegisterFlow(n),$({status:"awaiting-passkey"})}catch(e){throw $({status:"error",error:e}),fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,n;if(!x)throw new n6.ai;if(!(t.authFlow instanceof mN))throw new n6.P("Must initialize Passkey flow first.");
58if("passkey"!==ef.current){let e=new n6.P("Must init login with Passkey flow first.");throw $({status:"error",error:e}),e}let i=await A7();try{ef.current="passkey",$({status:"awaiting-passkey"}),{user:e,isNewUser:n}=await t.authenticate()}catch(e){throw $({status:"error",error:e}),fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR),e}T(e),O(n||!1),I(!0),$({status:"done"});let r=e?.linkedAccounts.find(({type:e})=>"passkey"===e)||null;return{user:e,isNewUser:n||!1,wasAlreadyAuthenticated:!!i,loginAccount:r}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:n}){let i=new mN({captchaToken:e,setPasskeyAuthState:$});t.startAuthFlow(i),eg.current="login";try{ef.current="passkey",$({status:"generating-challenge"}),await i.initAuthenticationFlow(n),$({status:"awaiting-passkey"})}catch(e){throw $({status:"error",error:e}),fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let n,i;if(!x)throw new n6.ai;if(!(t.authFlow instanceof mN))throw new n6.P("Must initialize Passkey flow first.");if(e?.credentialIds&&(t.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==ef.current){let e=new n6.P("Must init login with Passkey flow first.");throw $({status:"error",error:e}),e}let r=await A7();try{ef.current="passkey",$({status:"awaiting-passkey"}),{user:n,isNewUser:i}=await t.authenticate()}catch(e){throw $({status:"error",error:e}),fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR),e}T(n),O(i||!1),I(!0),$({status:"done"});let a=n?.linkedAccounts.find(({type:e})=>"passkey"===e)||null;return{user:n,isNewUser:i||!1,wasAlreadyAuthenticated:!!r,loginAccount:a}},async initLinkWithPasskey(e){let n=new mN({captchaToken:e});t.startAuthFlow(n),eg.current="link",ef.current="passkey",$({status:"generating-challenge"});try{await n.initLinkFlow(),$({status:"awaiting-passkey"})}catch(e){throw fh(ep,"linkAccount","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),$({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!x)throw new n6.ai;if(!(t.authFlow instanceof mN))throw new n6.P("Must initialize Passkey flow first.");if("passkey"!==ef.current)throw new n6.P("Must init login with Passkey flow first.");try{ef.current="passkey",{user:e}=await t.link()}catch(e){throw fh(ep,"linkAccount","onError",e.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return T(e||E||null),$({status:"done"}),e},async initLoginWithHeadlessOAuth(e,n,i){if(!pN()||"google"===e&&_C(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser.  To log in, please try again using an external browser.");let r=new mg({provider:e,withPrivyUi:!1,disableSignup:i??!1});n&&r.addCaptchaToken(n),J({status:"loading"});let a=await t.startAuthFlow(r).getAuthorizationUrl();a?.url&&window.location.assign(a.url)},async loginWithHeadlessOAuth(e){let n,i,r;U(!0),J({status:"loading"}),t.startAuthFlow(new mg(e));let a=pR.get(mo),s=e.stateCode;if(a!==s)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:a??"",returnedStateCode:s??""}}),U(!1),new n6.P("Unexpected auth flow. This may be a phishing attempt.",void 0,n6.a.OAUTH_UNEXPECTED);if(null!==await t.getAccessToken())try{({user:n,oAuthTokens:r}=await t.link()),ef.current=e.provider;let i=eM(n);n&&i&&fh(ep,"linkAccount","onSuccess",{user:n,linkMethod:ef.current,linkedAccount:i})}catch(t){throw U(!1),fh(ep,"linkAccount","onError",t.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:n,isNewUser:i,oAuthTokens:r}=await t.authenticate()),ef.current=e.provider;let a=eM(n);n&&a&&void 0!==i&&fh(ep,"login","onComplete",{user:n,isNewUser:i,wasAlreadyAuthenticated:!1,loginMethod:ef.current,loginAccount:a})}catch(e){throw U(!1),J({status:"error",error:e}),fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR),e}return T(n),O(i||!1),I(!0),U(!1),J({status:"done"}),r&&n&&fh(ep,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:n}),n??void 0},initLoginWithEmail:async({email:e,captchaToken:n,disableSignup:i,withPrivyUi:r})=>{let a=new pP({email:e,captchaToken:n,disableSignup:i});t.startAuthFlow(a);try{ef.current="email",z({status:"sending-code"}),await a.sendCodeEmail({withPrivyUi:r}),z({status:"awaiting-code-input"})}catch(e){throw z({status:"error",error:e}),"login"===eg.current?fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR):"link"===eg.current&&fh(ep,"linkAccount","onError",e.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async({oldAddress:e,newAddress:n,captchaToken:i})=>{let r=new pj(e,n,i);t.startAuthFlow(r);try{await r.sendCodeEmail({withPrivyUi:!0})}catch(e){fh(ep,"update","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR,{linkMethod:ef.current})}},initUpdatePhone:async(e,n,i)=>{let r=new mF(e,n,i);t.startAuthFlow(r);try{await r.sendSmsCode({withPrivyUi:!0})}catch(e){fh(ep,"update","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR,{linkMethod:ef.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:n,disableSignup:i,withPrivyUi:r})=>{V({status:"sending-code"});let a=new mL({phoneNumber:e,captchaToken:n,disableSignup:i});t.startAuthFlow(a);try{ef.current="sms",await a.sendSmsCode({withPrivyUi:r}),V({status:"awaiting-code-input"})}catch(e){throw V({status:"error",error:e}),"login"===eg.current?fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR):"link"===eg.current&&fh(ep,"linkAccount","onError",e.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await t.authFlow?.sendCodeEmail({withPrivyUi:!0})},resendSmsCode:async()=>{await t.authFlow?.sendSmsCode({withPrivyUi:!0})},loginWithCode:async e=>{let n,i;function r(e){t.authFlow instanceof pP?z(e):t.authFlow instanceof mL&&V(e)}if(r({status:"submitting-code"}),!x){let e=new n6.ai;throw r({status:"error",error:e}),e}if(t.authFlow instanceof pP)t.authFlow.meta.emailCode=e.trim();else{if(!(t.authFlow instanceof mL)){let e=new n6.P("Must initialize a passwordless code flow first");throw r({status:"error",error:e}),e}t.authFlow.meta.smsCode=e.trim()}let a=await A7();if("link"===eg.current)try{({user:n}=await t.link())}catch(e){throw r({status:"error",error:e}),fh(ep,"linkAccount","onError",e.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:ef.current}),e}else if("update"===eg.current)try{({user:n}=await t.link())}catch(e){throw r({status:"error",error:e}),fh(ep,"update","onError",e.privyErrorCode||n6.a.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:ef.current}),e}else try{({user:n,isNewUser:i}=await t.authenticate())}catch(e){throw r({status:"error",error:e}),fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR),e}let s=n||E;T(s||null),O(i||!1),I(!0),r({status:"done"});let o=null;return t.authFlow instanceof pP?o=s?.linkedAccounts.find(({type:e})=>"email"===e)||null:t.authFlow instanceof mL&&(o=s?.linkedAccounts.find(({type:e})=>"phone"===e)||null),{user:s,isNewUser:i||!1,wasAlreadyAuthenticated:!!a,linkedAccount:o}},generateSiweMessage:async({address:e,chainId:n,captchaToken:i})=>{eg.current=C?"link":"login",ef.current="siwe",G({status:"generating-message"});let r=await t.generateSiweNonce({address:e,captchaToken:i});return G({status:"awaiting-signature"}),mR({address:e,chainId:n.replace("eip155:",""),nonce:r})},generateSiweMessageForSmartWallet:async({address:e,chainId:n})=>{let i=await t.generateSiweNonce({address:e});return mR({address:e,chainId:n.replace("eip155:",""),nonce:i})},linkSmartWallet:async({message:e,signature:n,smartWalletType:i})=>{let r;r=await t.linkSmartWallet({message:e,signature:n,smartWalletType:i}),T((r=await eW.refreshSessionAndUser()??r)||E||null)},loginWithSiwe:async({message:e,signature:n,captchaToken:i,disableSignup:r})=>{let a,s=null;try{if(E)throw Error("User already authenticated");let o=new mM(t,void 0,i,r,{message:e,signature:n});t.startAuthFlow(o),ef.current="siwe",eg.current="login",G({status:"submitting-signature"});let l=await t.authenticate();if({user:s,isNewUser:a}=l,!s)throw Error("Authentication failed - no user returned")}catch(e){throw fh(ep,"login","onError",e.privyErrorCode||n6.a.UNKNOWN_AUTH_ERROR),G({status:"error",error:e}),e}return T(s),O(a||!1),I(!0),G({status:"done"}),eg.current=null,ef.current=null,s},linkWithSiwe:async({message:e,signature:n,chainId:i,walletClientType:r,connectorType:a})=>{let s;ek("siwe");let o=null;try{G({status:"submitting-signature"}),s=await t.linkWithSiwe({message:e,signature:n,chainId:i,walletClientType:r,connectorType:a}),s=await eW.refreshSessionAndUser()??s,G({status:"done"}),(o=eM(s)||null)&&fh(ep,"linkAccount","onSuccess",{user:s,linkMethod:"siwe",linkedAccount:o})}catch(e){throw fh(ep,"linkAccount","onError",e.privyErrorCode||n6.a.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),eg.current=null,ef.current=null,G({status:"error",error:e}),e}let l=s||E;return T(l||null),eg.current=null,ef.current=null,{user:l,linkedAccount:o}},refreshSessionAndUser:async()=>{let e=await t.getAuthenticatedUser();return I(!!e),T(e),e},walletProxy:Q,createAnalyticsEvent:({eventName:e,payload:n,timestamp:i})=>t.createAnalyticsEvent({eventName:e,payload:n,timestamp:i}),acceptTerms:async()=>{let e=await t.acceptTerms();return T(e),e},getUsdTokenPrice:e=>t.getUsdTokenPrice(e),getUsdPriceForSol:()=>t.getUsdPriceForSol(),getSplTokenMetadata:e=>
58t.getSplTokenMetadata(e),recoverEmbeddedWallet:async e=>new Promise(async(n,i)=>{if(!E)return void n(!0);let r=e?.address?(0,ic.b)(E,e.address):(0,ic.h)(E)||(0,ic.k)(E)||(0,ic.e)(E);if(!r||(0,ic.c)(r))return void n(!0);let a=await A7();if(!a||!Q||!r)return void i(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:s,entropyIdVerifier:o}=mY(E,r);try{await Q.connect({accessToken:a,entropyId:s,entropyIdVerifier:o}),n(!0)}catch(e){if(wV(e)&&"privy"===r.recoveryMethod){let e;t.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:r.address}});try{e=await Q.recover({entropyId:s,entropyIdVerifier:o,accessToken:a})}catch(e){return void i(e)}e.entropyId||i(Error("Unable to recover wallet")),t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:r.address}}),n(!0)}else wV(e)&&"privy"!==r.recoveryMethod&&"privy-v2"!==r.recoveryMethod?(ei({recoverWallet:{entropyId:s,entropyIdVerifier:o,onFailure:i,onSuccess:()=>n(!0)},recoveryOAuthStatus:{provider:r.recoveryMethod,action:"recover",shouldCreateEth:!1,shouldCreateSol:!1}}),eb(CG(r.recoveryMethod))):i(e)}}),exportSolanaWallet:n=>new Promise(async(i,r)=>{if(!C||!E)return void r(Error("User must be authenticated before exporting their Privy wallet"));let a=n?.address?(0,ic.b)(E,n.address):(0,ic.j)(E),s=(0,ic.h)(E);if(!a||!s)return void r(new n6.P("User must have an embedded wallet."));let{entropyId:o,entropyIdVerifier:l}=mY(E,a);if(!a||!s)return void r(Error("Must have a Privy wallet before exporting"));let c=(0,ic.c)(a);if(!await A7()||!Q)return void r(Error("Must have valid access token to enroll in MFA"));if(!Q)return void r(Error("Must have a Privy wallet before exporting"));let d={recoveryMethod:a.recoveryMethod,connectingWalletAddress:a.address,isUnifiedWallet:c,entropyId:o,entropyIdVerifier:l,onCompleteNavigateTo:EL,onFailure:r,shouldForceMFA:!0};vu(a)?(ei({connectWallet:d,keyExport:{appId:e.appId,appClientId:e.clientId,origin:t.apiUrl,address:a.address,entropyId:o,entropyIdVerifier:l,hdWalletIndex:a.walletIndex,chainType:a.chainType,walletId:a.id,isUnifiedWallet:c,imported:a.imported,onSuccess:i,onFailure:r}}),eb(EB)):r(Error(`Export is not supported for ${a.chainType} wallets`))}),setReadyToTrue:e=>{_(!0),er?.(e)},updateWallets:()=>eO(),fundWallet:async(e,t)=>{ei({funding:ER({address:e,appConfig:ee,fundWalletConfig:t,methodScreen:EP})}),eb(EP)},openModal:eb,requestFarcasterSignerStatus:async e=>{let n=await A7(),i=E?.linkedAccounts.find(e=>"wallet"===e.type&&"privy"===e.walletClientType);if(!n)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!i)throw Error("Must have an embedded wallet to use Farcaster signers");if(!E?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let r=await t.requestFarcasterSignerStatus(e);return"approved"===r.status&&T(await t.getAuthenticatedUser()||E||null),r},connectCoinbaseSmartWallet:async()=>{ee.externalWallets.coinbaseWallet.config.preference={...ee.externalWallets.coinbaseWallet.config.preference,options:"smartWalletOnly"};let e=t.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||t.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),eE(e);await eI("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:e,account:n,accountType:i,externalWalletMetadata:r,telegramAuthResult:a,telegramWebAppData:s,farcasterEmbeddedAddress:o,oAuthUserInfo:l})=>{let c=await t.sendAccountTransferRequest({nonce:e,account:n,accountType:i,externalWalletMetadata:r,telegramAuthResult:a,telegramWebAppData:s,farcasterEmbeddedAddress:o,oAuthUserInfo:l});return T(c),c},inProgressAuthFlowRef:eg,inProgressLoginOrLinkMethodRef:ef};d=eW.recoverEmbeddedWallet,u=eW.recoverEmbeddedWallet;let e$=(0,m.useMemo)(()=>({wallets:A,ready:eo&&em}),[A,eo,em]),eB=t.authFlow instanceof mq,ez=!ee.headless&&ee.captchaEnabled&&!C&&(x||eB);return(0,h.jsx)(A8.Provider,{value:!0,children:(0,h.jsx)(ic.P.Provider,{value:eF,children:(0,h.jsx)(fc.Provider,{value:ep,children:(0,h.jsx)(wE.Provider,{value:e$,children:(0,h.jsx)(mB,{...ee,children:(0,h.jsxs)(n8.I.Provider,{value:eW,children:[(0,h.jsx)(bA,{children:(0,h.jsxs)(yY,{data:en,setModalData:ei,setInitialScreen:R,initialScreen:N,authenticated:C,open:a,children:[e.children,(0,h.jsx)(A6,{customAuth:ee.customAuth}),ez&&(0,h.jsx)(fo,{delayedExecution:!1}),(0,h.jsx)(vn,{}),(0,h.jsx)(T2,{}),(0,h.jsx)(wQ,{theme:{...ee.appearance.palette||{}}}),!ee.render.standalone&&(0,h.jsx)(w7,{open:a})]})}
58),(0,h.jsx)(vd,{appId:e.appId,appClientId:e.clientId,clientAnalyticsId:t.clientAnalyticsId,origin:t.apiUrl,mfaMethods:E?.mfaMethods,mfaPromise:eu,mfaSubmitPromise:eh,onLoad:X,onLoadFailed:()=>null}),ee.loginConfig.telegramAuthConfiguration&&(0,h.jsx)(f_,{$if:!0,children:(0,h.jsx)(vt,{scriptHost:e.apiUrl||p6,botUsername:ee.loginConfig.telegramAuthConfiguration.botName})})]})})})})})})}},111280:(e,t,n)=>{"use strict";n.d(t,{_:()=>i});let i={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1}},113627:(e,t,n)=>{"use strict";n.d(t,{r:()=>i});let i={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://mainnet.rpc.privy.systems"]},alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}}},116274:(e,t,n)=>{"use strict";n.d(t,{A7:()=>a,F0:()=>U,Kg:()=>N,Mj:()=>p,Py:()=>j,Qn:()=>o,RK:()=>w,U5:()=>D,Ug:()=>b,WF:()=>R,XS:()=>s,ZH:()=>v,Zt:()=>C,_R:()=>h,_e:()=>x,_p:()=>E,bS:()=>L,bn:()=>f,cF:()=>d,dE:()=>m,di:()=>I,ei:()=>M,et:()=>u,g1:()=>F,im:()=>y,lP:()=>l,ln:()=>S,oP:()=>T,pY:()=>g,s$:()=>P,sA:()=>k,tS:()=>O,wG:()=>_,wJ:()=>A,x7:()=>c,zs:()=>r});var i=n(125644);class r extends i.C{constructor({cause:e}){super("Smart Account is not deployed.",{cause:e,metaMessages:["This could arise when:","- No `factory`/`factoryData` or `initCode` properties are provided for Smart Account deployment.","- An incorrect `sender` address is provided."],name:"AccountNotDeployedError"})}}Object.defineProperty(r,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa20/});class a extends i.C{constructor({cause:e,data:t,message:n}={}){let i=n?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${i?`with reason: ${i}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t}}Object.defineProperty(a,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32521}),Object.defineProperty(a,"message",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class s extends i.C{constructor({cause:e}){super("Failed to send funds to beneficiary.",{cause:e,name:"FailedToSendToBeneficiaryError"})}}Object.defineProperty(s,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa91/});class o extends i.C{constructor({cause:e}){super("Gas value overflowed.",{cause:e,metaMessages:["This could arise when:","- one of the gas values exceeded 2**120 (uint120)"].filter(
vendor: 7,969 bytes, line 58
58Boolean),name:"GasValuesOverflowError"})}}Object.defineProperty(o,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa94/});class l extends i.C{constructor({cause:e}){super("The `handleOps` function was called by the Bundler with a gas limit too low.",{cause:e,name:"HandleOpsOutOfGasError"})}}Object.defineProperty(l,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa95/});class c extends i.C{constructor({cause:e,factory:t,factoryData:n,initCode:i}){super("Failed to simulate deployment for Smart Account.",{cause:e,metaMessages:["This could arise when:","- Invalid `factory`/`factoryData` or `initCode` properties are present","- Smart Account deployment execution ran out of gas (low `verificationGasLimit` value)","- Smart Account deployment execution reverted with an error\n",t&&`factory: ${t}`,n&&`factoryData: ${n}`,i&&`initCode: ${i}`].filter(Boolean),name:"InitCodeFailedError"})}}Object.defineProperty(c,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa13/});class d extends i.C{constructor({cause:e,factory:t,factoryData:n,initCode:i}){super("Smart Account initialization implementation did not create an account.",{cause:e,metaMessages:["This could arise when:","- `factory`/`factoryData` or `initCode` properties are invalid","- Smart Account initialization implementation is incorrect\n",t&&`factory: ${t}`,n&&`factoryData: ${n}`,i&&`initCode: ${i}`].filter(Boolean),name:"InitCodeMustCreateSenderError"})}}Object.defineProperty(d,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa15/});class u extends i.C{constructor({cause:e,factory:t,factoryData:n,initCode:i,sender:r}){super("Smart Account initialization implementation does not return the expected sender.",{cause:e,metaMessages:["This could arise when:","Smart Account initialization implementation does not return a sender address\n",t&&`factory: ${t}`,n&&`factoryData: ${n}`,i&&`initCode: ${i}`,r&&`sender: ${r}`].filter(Boolean),name:"InitCodeMustReturnSenderError"})}}Object.defineProperty(u,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa14/});class h extends i.C{constructor({cause:e}){super("Smart Account does not have sufficient funds to execute the User Operation.",{cause:e,metaMessages:["This could arise when:","- the Smart Account does not have sufficient funds to cover the required prefund, or","- a Paymaster was not provided"].filter(Boolean),name:"InsufficientPrefundError"})}}Object.defineProperty(h,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa21/});class p extends i.C{constructor({cause:e}){super("Bundler attempted to call an invalid function on the EntryPoint.",{cause:e,name:"InternalCallOnlyError"})}}Object.defineProperty(p,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa92/});class m extends i.C{constructor({cause:e}){super("Bundler used an invalid aggregator for handling aggregated User Operations.",{cause:e,name:"InvalidAggregatorError"})}}Object.defineProperty(m,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa96/});class y extends i.C{constructor({cause:e,nonce:t}){super("Invalid Smart Account nonce used for User Operation.",{cause:e,metaMessages:[t&&`nonce: ${t}`].filter(Boolean),name:"InvalidAccountNonceError"})}}Object.defineProperty(y,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa25/});class f extends i.C{constructor({cause:e}){super("Bundler has not set a beneficiary address.",{cause:e,name:"InvalidBeneficiaryError"})}}Object.defineProperty(f,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa90/});class g extends i.C{constructor({cause:e}){super("Invalid fields set on User Operation.",{cause:e,name:"InvalidFieldsError"})}}Object.defineProperty(g,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class w extends i.C{constructor({cause:e,paymasterAndData:t}){super("Paymaster properties provided are invalid.",{cause:e,metaMessages:["This could arise when:","- the `paymasterAndData` property is of an incorrect length\n",t&&`paymasterAndData: ${t}`].filter(Boolean),name:"InvalidPaymasterAndDataError"})}}Object.defineProperty(w,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa93/});class v extends i.C{constructor({cause:e}){super("Paymaster deposit for the User Operation is too low.",{cause:e,metaMessages:["This could arise when:","- the Paymaster has deposited less than the expected amount via the `deposit` function"].filter(Boolean),name:"PaymasterDepositTooLowError"})}}Object.defineProperty(v,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32508}),Object.defineProperty(v,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa31/});class b extends i.C{constructor({cause:e}){super("The `validatePaymasterUserOp` function on the Paymaster reverted.",{cause:e,name:"PaymasterFunctionRevertedError"})}}Object.defineProperty(b,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa33/});class x extends i.C{constructor({cause:e}){super("The Paymaster contract has not been deployed.",{cause:e,name:"PaymasterNotDeployedError"})}}Object.defineProperty(x,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa30/});class _ extends i.C{constructor({cause:e}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:e,name:"PaymasterRateLimitError"})}}Object.defineProperty(_,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32504});class C extends i.C{constructor({cause:e}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:e,name:"PaymasterStakeTooLowError"})}}Object.defineProperty(C,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32505});class I extends i.C{constructor({cause:e}){super("Paymaster `postOp` function reverted.",{cause:e,name:"PaymasterPostOpFunctionRevertedError"})}}Object.defineProperty(I,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa50/});class E extends i.C{constructor({cause:e,factory:t,factoryData:n,initCode:i}){super("Smart Account has already been deployed.",{cause:e,metaMessages:["Remove the following properties and try again:",t&&"`factory`",n&&"`factoryData`",i&&"`initCode`"].filter(Boolean),name:"SenderAlreadyConstructedError"})}}Object.defineProperty(E,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa10/});class T extends i.C{constructor({cause:e}){super("UserOperation rejected because account signature check failed (or paymaster signature, if the paymaster uses its data as signature).",{cause:e,name:"SignatureCheckFailedError"})}}Object.defineProperty(T,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32507});class A extends i.C{constructor({cause:e}){super("The `validateUserOp` function on the Smart Account reverted.",{cause:e,name:"SmartAccountFunctionRevertedError"})}}Object.defineProperty(A,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa23/});class S extends i.C{constructor({cause:e}){super("UserOperation rejected because account specified unsupported signature aggregator.",{cause:e,name:"UnsupportedSignatureAggregatorError"})}}Object.defineProperty(S,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32506});class k extends i.C{constructor({cause:e}){super("User Operation expired.",{cause:e,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validateUserOp` on the Smart Account are not satisfied"].filter(Boolean),name:"UserOperationExpiredError"})}}Object.defineProperty(k,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa22/});class P extends i.C{constructor({cause:e}){super("Paymaster for User Operation expired.",{cause:e,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validatePaymasterUserOp` on the Paymaster are not satisfied"].filter(Boolean),name:"UserOperationPaymasterExpiredError"})}}Object.defineProperty(P,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa32/});
58class j extends i.C{constructor({cause:e}){super("Signature provided for the User Operation is invalid.",{cause:e,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Smart Account"].filter(Boolean),name:"UserOperationSignatureError"})}}Object.defineProperty(j,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa24/});class O extends i.C{constructor({cause:e}){super("Signature provided for the User Operation is invalid.",{cause:e,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Paymaster"].filter(Boolean),name:"UserOperationPaymasterSignatureError"})}}Object.defineProperty(O,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa34/});class N extends i.C{constructor({cause:e}){super("User Operation rejected by EntryPoint's `simulateValidation` during account creation or validation.",{cause:e,name:"UserOperationRejectedByEntryPointError"})}}Object.defineProperty(N,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32500});class R extends i.C{constructor({cause:e}){super("User Operation rejected by Paymaster's `validatePaymasterUserOp`.",{cause:e,name:"UserOperationRejectedByPaymasterError"})}}Object.defineProperty(R,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32501});class M extends i.C{constructor({cause:e}){super("User Operation rejected with op code validation error.",{cause:e,name:"UserOperationRejectedByOpCodeError"})}}Object.defineProperty(M,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32502});class D extends i.C{constructor({cause:e}){super("UserOperation out of time-range: either wallet or paymaster returned a time-range, and it is already expired (or will expire soon).",{cause:e,name:"UserOperationOutOfTimeRangeError"})}}Object.defineProperty(D,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32503});class U extends i.C{constructor({cause:e}){super(`An error occurred while executing user operation: ${e?.shortMessage}`,{cause:e,name:"UnknownBundlerError"})}}class L extends i.C{constructor({cause:e}){super("User Operation verification gas limit exceeded.",{cause:e,metaMessages:["This could arise when:","- the gas used for verification exceeded the `verificationGasLimit`"].filter(Boolean),name:"VerificationGasLimitExceededError"})}}Object.defineProperty(L,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa40/});class F extends i.C{constructor({cause:e}){super("User Operation verification gas limit is too low.",{cause:e,metaMessages:["This could arise when:","- the `verificationGasLimit` is too low to verify the User Operation"].filter(Boolean),name:"VerificationGasLimitTooLowError"})}}Object.defineProperty(F,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa41/})},121581:(e,t,n)=>{"use strict";n.d(t,{C:()=>s});var i=n(824413),r=n(797036),a=n(155341);async function s(e,{account:t=e.account,domain:n,message:s,primaryType:o,types:l}){if(!t)throw new a.T({docsPath:"/docs/actions/wallet/signMessage"});let c=(0,r.J)(t),d={EIP712Domain:(0,i.H4)({domain:n}),...l};return(0,i.$$)({domain:n,message:s,primaryType:o,types:d}),c.signTypedData({domain:n,primaryType:o,types:d,message:s})}},125281:(e,t,n)=>{"use strict";n.d(t,{cY:()=>y,FA:()=>P,g:()=>k,u:()=>d,Uj:()=>c,tD:()=>U,bD:()=>function e(t,n){if(t===n)return!0;let i=Object.keys(t),r=Object.keys(n);for(let a of i){if(!r.includes(a))return!1;let i=t[a],s=n[a];if(N(i)&&N(s)){if(!e(i,s))return!1}else if(i!==s)return!1}for(let e of r)if(!i.includes(e))return!1;return!0},hp:()=>D,T9:()=>p,Tj:()=>h,XA:()=>m,Ku:()=>W,ZQ:()=>x,sr:()=>I,zJ:()=>f,c1:()=>C,Im:()=>O,lT:()=>T,zW:()=>A,jZ:()=>_,lV:()=>E,gE:()=>g,Am:()=>R,I9:()=>M,P1:()=>b,eX:()=>S});var i=n(923727);let r=function(e){let t=[],n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);r<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:((64512&r)==55296&&i+1<e.length&&(64512&e.charCodeAt(i+1))==56320?(r=65536+((1023&r)<<10)+(1023&e.charCodeAt(++i)),t[n++]=r>>18|240,t[n++]=r>>12&63|128):t[n++]=r>>12|224,t[n++]=r>>6&63|128),t[n++]=63&r|128)}return t},a=function(e){let t=[],n=0,i=0;for(;n<e.length;){let r=e[n++];if(r<128)t[i++]=String.fromCharCode(r);else if(r>191&&r<224){let a=e[n++];t[i++]=String.fromCharCode((31&r)<<6|63&a)}else if(r>239&&r<365){let a=e[n++],s=((7&r)<<18|(63&a)<<12|(63&e[n++])<<6|63&e[n++])-65536;t[i++]=String.fromCharCode(55296+(s>>10)),t[i++]=String.fromCharCode(56320+(1023&s))}else{let a=e[n++],s=e[n++];
58t[i++]=String.fromCharCode((15&r)<<12|(63&a)<<6|63&s)}}return t.join("")},s={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();let n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let t=0;t<e.length;t+=3){let r=e[t],a=t+1<e.length,s=a?e[t+1]:0,o=t+2<e.length,l=o?e[t+2]:0,c=r>>2,d=(3&r)<<4|s>>4,u=(15&s)<<2|l>>6,h=63&l;!o&&(h=64,a||(u=64)),i.push(n[c],n[d],n[u],n[h])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(r(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):a(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();let n=t?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let t=0;t<e.length;){let r=n[e.charAt(t++)],a=t<e.length?n[e.charAt(t)]:0,s=++t<e.length?n[e.charAt(t)]:64,l=++t<e.length?n[e.charAt(t)]:64;if(++t,null==r||null==a||null==s||null==l)throw new o;let c=r<<2|a>>4;if(i.push(c),64!==s){let e=a<<4&240|s>>2;if(i.push(e),64!==l){let e=s<<6&192|l;i.push(e)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class o extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}let l=function(e){let t=r(e);return s.encodeByteArray(t,!0)},c=function(e){return l(e).replace(/\./g,"")},d=function(e){try{return s.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null},u=()=>{try{return function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__||(()=>{if(void 0===i||void 0===i.env)return;let e=i.env.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)})()||(()=>{let e;if("undefined"==typeof document)return;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}let t=e&&d(e[1]);return t&&JSON.parse(t)})()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}},h=e=>{var t,n;return null==(n=null==(t=u())?void 0:t.emulatorHosts)?void 0:n[e]},p=()=>{var e;return null==(e=u())?void 0:e.config},m=e=>{var t;return null==(t=u())?void 0:t[`_${e}`]};class y{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,n))}}}function f(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch(e){return!1}}async function g(e){return(await fetch(e,{credentials:"include"})).ok}let w={},v=!1;function b(e,t){if("undefined"==typeof window||"undefined"==typeof document||!f(window.location.host)||w[e]===t||w[e]||v)return;function n(e){return`__firebase__banner__${e}`}w[e]=t;let i="__firebase__banner",r=function(){let e={prod:[],emulator:[]};for(let t of Object.keys(w))w[t]?e.emulator.push(t):e.prod.push(t);return e}().prod.length>0;function a(){let e,t,a=(e=document.getElementById(i),t=!1,e||((e=document.createElement("div")).setAttribute("id",i),t=!0),{created:t,element:e}),s=n("text"),o=document.getElementById(s)||document.createElement("span"),l=n("learnmore"),c=document.getElementById(l)||document.createElement("a"),d=n("preprendIcon"),u=document.getElementById(d)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(a.created){let e=a.element;e.style.display="flex",e.style.background="#7faaf0",e.style.position="fixed",e.style.bottom="5px",e.style.left="5px",e.style.padding=".5em",e.style.borderRadius="5px",e.style.alignItems="center",c.setAttribute("id",l),c.innerText="Learn more",c.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",c.setAttribute("target","__blank"),c.style.paddingLeft="5px",c.style.textDecoration="underline";let t=function(){let e=document.createElement("span");
58return e.style.cursor="pointer",e.style.marginLeft="16px",e.style.fontSize="24px",e.innerHTML=" &times;",e.onclick=()=>{v=!0;let e=document.getElementById(i);e&&e.remove()},e}();u.setAttribute("width","24"),u.setAttribute("id",d),u.setAttribute("height","24"),u.setAttribute("viewBox","0 0 24 24"),u.setAttribute("fill","none"),u.style.marginLeft="-6px",e.append(u,o,c,t),document.body.appendChild(e)}r?(o.innerText="Preview backend disconnected.",u.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
59<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
60</g>
61<defs>
62<clipPath id="clip0_6013_33858">
63<rect width="24" height="24" fill="white"/>
64</clipPath>
65</defs>`):(u.innerHTML=`<g clip-path="url(#clip0_6083_34804)">
66<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
67</g>
68<defs>
69<clipPath id="clip0_6083_34804">
70<rect width="24" height="24" fill="white"/>
71</clipPath>
72</defs>`,o.innerText="Preview backend running in this workspace."),o.setAttribute("id",s)}"loading"===document.readyState?window.addEventListener("DOMContentLoaded",a):a()}function x(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function _(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(x())}function C(){return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent}function I(){let e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function E(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function T(){let e=x();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}function A(){try{return"object"==typeof indexedDB}catch(e){return!1}}function S(){return new Promise((e,t)=>{try{let n=!0,i="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(i);r.onsuccess=()=>{r.result.close(),n||self.indexedDB.deleteDatabase(i),e(!0)},r.onupgradeneeded=()=>{n=!1},r.onerror=()=>{var e;t((null==(e=r.error)?void 0:e.message)||"")}}catch(e){t(e)}})}class k extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,k.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,P.prototype.create)}}class P{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){var n,i;let r=t[0]||{},a=`${this.service}/${e}`,s=this.errors[e],o=s?(n=s,i=r,n.replace(j,(e,t)=>{let n=i[t];return null!=n?String(n):`<${t}?>`})):"Error",l=`${this.serviceName}: ${o} (${a}).`;return new k(a,l,r)}}let j=/\{\$([^}]+)}/g;function O(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function N(e){return null!==e&&"object"==typeof e}function R(e){let t=[];
72for(let[n,i]of Object.entries(e))Array.isArray(i)?i.forEach(e=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(i));return t.length?"&"+t.join("&"):""}function M(e){let t={};return e.replace(/^\?/,"").split("&").forEach(e=>{if(e){let[n,i]=e.split("=");t[decodeURIComponent(n)]=decodeURIComponent(i)}}),t}function D(e){let t=e.indexOf("?");if(!t)return"";let n=e.indexOf("#",t);return e.substring(t,n>0?n:void 0)}function U(e,t){let n=new L(e,t);return n.subscribe.bind(n)}class L{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(e=>{this.error(e)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,n){let i;if(void 0===e&&void 0===t&&void 0===n)throw Error("Missing Observer.");void 0===(i=!function(e,t){if("object"!=typeof e||null===e)return!1;for(let n of t)if(n in e&&"function"==typeof e[n])return!0;return!1}(e,["next","error","complete"])?{next:e,error:t,complete:n}:e).next&&(i.next=F),void 0===i.error&&(i.error=F),void 0===i.complete&&(i.complete=F);let r=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch(e){}}),this.observers.push(i),r}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function F(){}function W(e){return e&&e._delegate?e._delegate:e}},129239:(e,t,n)=>{"use strict";n.d(t,{c:()=>i});let i=e=>/0\.2\.\d+/.test(e)},142974:(e,t,n)=>{"use strict";n.d(t,{m:()=>l});var i=n(352401),r=n(607186),a=n(559482),s=n(128897),o=n(738829);function l({mode:e,callData:t}){if(t.length>1&&e?.type!=="batchcall")throw Error(`mode ${JSON.stringify(e)} does not supported for batchcall calldata`);let n=[{type:"function",name:"execute",inputs:[{name:"execMode",type:"bytes32",internalType:"ExecMode"},{name:"executionCalldata",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"}];if(t.length>1)return(0,i.p)({abi:n,functionName:"execute",args:[(0,o.s)(e),(0,r.h)([{name:"executionBatch",type:"tuple[]",components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"callData",type:"bytes"}]}],[t.map(e=>({target:e.to,value:e.value??0n,callData:e.data??"0x"}))])]});let l=0===t.length?void 0:t[0];if(!l)throw Error("No calls to encode");return(0,i.p)({abi:n,functionName:"execute",args:[(0,o.s)(e),(0,a.aP)([l.to,(0,s.nj)(l.value??0n,{size:32}),l.data??"0x"])]})}},152963:(e,t,n)=>{"use strict";n.d(t,{l:()=>a});var i=n(976168),r=n(96158);async function a(e,{hash:t}){let n=await e.request({method:"eth_getUserOperationByHash",params:[t]},{dedupe:!0});if(!n)throw new i.Kh({hash:t});let{blockHash:a,blockNumber:s,entryPoint:o,transactionHash:l,userOperation:c}=n;return{blockHash:a,blockNumber:BigInt(s),entryPoint:o,transactionHash:l,userOperation:(0,r.o)(c)}}},155341:(e,t,n)=>{"use strict";n.d(t,{T:()=>r});var i=n(125644);class r extends i.C{constructor({docsPath:e}={}){super("Could not find an Account to execute with this Action.\nPlease provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client.",{docsPath:e,docsSlug:"account",name:"AccountNotFoundError"})}}},155950:(e,t,n)=>{var i=n(643171),r=n(353689),a=n(476316),s=RegExp("['’]","g");e.exports=function(e){return function(t){return i(a(r(t).replace(s,"")),e,"")}}},161877:(e,t,n)=>{"use strict";n.d(t,{P:()=>x,a:()=>C,b:()=>f,c:()=>b,d:()=>u,e:()=>m,g:()=>l,h:()=>w,i:()=>v,j:()=>h,k:()=>p,l:()=>c,m:()=>g,u:()=>_});var i=n(225572),r=n(25963),a=n(631930);function s(e){return e?new Date(1e3*e):null}function o(e,t){return e.slice().sort((e,t)=>
72(e.firstVerifiedAt??e.verifiedAt).getTime()-(t.firstVerifiedAt??t.verifiedAt).getTime()).find(e=>e.type===t)}let l=e=>e?c(e).find(e=>0===e.walletIndex)??null:null,c=e=>e?d(e,"ethereum"):[],d=(e,t)=>e.linkedAccounts.filter(e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&e.chainType===t),u=e=>e?d(e,"solana"):[],h=e=>e?u(e).find(e=>0===e.walletIndex)??null:null,p=e=>e?.linkedAccounts.find(e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType)||null,m=e=>e?.linkedAccounts.find(e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType)||null,y=(e,t)=>e===t||!(!e.startsWith("0x")||!t.startsWith("0x"))&&(0,i.b)(e)===(0,i.b)(t),f=(e,t)=>e?.linkedAccounts.find(e=>"wallet"===e.type&&"privy"===e.walletClientType&&y(e.address,t))||null,g=(e,t)=>e.find(e=>y(e.address,t))||null,w=e=>l(e)??h(e);function v(e){if(!e)return null;let t=function(e){let t=[];for(let n of e){let e=n.type;switch(n.type){case"wallet":let i={id:n.id,address:n.address,type:n.type,imported:n.imported,delegated:n.delegated,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at),chainType:n.chain_type,walletClientType:n.wallet_client_type,connectorType:n.connector_type,recoveryMethod:n.recovery_method,walletIndex:n.wallet_index};t.push(i);break;case"smart_wallet":let r={address:n.address,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at),smartWalletType:n.smart_wallet_type};t.push(r);break;case"cross_app":let a={type:n.type,subject:n.subject,embeddedWallets:n.embedded_wallets,smartWallets:n.smart_wallets,providerApp:{id:n.provider_app_id},verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(a);break;case"email":let o={address:n.address,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(o);break;case"phone":let l={number:n.phoneNumber,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(l);break;case"google_oauth":let c={subject:n.subject,email:n.email,name:n.name,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(c);break;case"spotify_oauth":let d={subject:n.subject,email:n.email,name:n.name,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(d);break;case"instagram_oauth":let u={subject:n.subject,username:n.username,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(u);break;case"twitter_oauth":let h={subject:n.subject,username:n.username,name:n.name,type:n.type,profilePictureUrl:n.profile_picture_url,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(h);break;case"discord_oauth":let p={subject:n.subject,username:n.username,email:n.email,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(p);break;case"github_oauth":let m={subject:n.subject,username:n.username,name:n.name,email:n.email,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(m);break;case"tiktok_oauth":let y={subject:n.subject,username:n.username,name:n.name,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(y);break;case"line_oauth":let f={subject:n.subject,name:n.name,email:n.email,profilePictureUrl:n.profile_picture_url,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(f);break;case"linkedin_oauth":let g={subject:n.subject,name:n.name,email:n.email,vanityName:n.vanity_name,type:n.type,verifiedAt:s(n.verified_at),first
72VerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(g);break;case"apple_oauth":let w={subject:n.subject,email:n.email,type:n.type,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(w);break;case"custom_auth":t.push({type:n.type,customUserId:n.custom_user_id,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)});break;case"farcaster":let v={type:n.type,fid:n.fid,ownerAddress:n.owner_address,displayName:n.display_name,username:n.username,bio:n.bio,pfp:n.profile_picture_url,url:n.homepage_url,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at),signerPublicKey:n.signer_public_key};t.push(v);break;case"passkey":let b={type:n.type,enrolledInMfa:n.enrolled_in_mfa,credentialId:n.credential_id,authenticatorName:n.authenticator_name,createdWithDevice:n.created_with_device,createdWithOs:n.created_with_os,createdWithBrowser:n.created_with_browser,verifiedAt:s(n.verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(b);break;case"telegram":let x={type:n.type,telegramUserId:n.telegram_user_id,firstName:n.first_name,lastName:n.last_name,username:n.username,photoUrl:n.photo_url,verifiedAt:s(n.first_verified_at),firstVerifiedAt:s(n.first_verified_at),latestVerifiedAt:s(n.latest_verified_at)};t.push(x);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),n=o(t,"wallet"),i=o(t,"smart_wallet"),r=o(t,"email"),a=o(t,"phone"),l=o(t,"google_oauth"),c=o(t,"twitter_oauth"),d=o(t,"discord_oauth"),u=o(t,"github_oauth"),h=o(t,"spotify_oauth"),p=o(t,"instagram_oauth"),m=o(t,"tiktok_oauth"),y=o(t,"line_oauth"),f=o(t,"linkedin_oauth"),g=o(t,"apple_oauth"),w=o(t,"farcaster"),v=o(t,"telegram"),b=e.mfa_methods.map(({type:e,verified_at:t})=>({type:e,verifiedAt:s(t)}));return{id:e.id,createdAt:s(e.created_at),linkedAccounts:t,email:r&&{address:r?.address},phone:a&&{number:a?.number},wallet:n&&{id:n.id,address:n.address,chainType:n.chainType,walletClientType:n.walletClientType,connectorType:n.connectorType,recoveryMethod:n.recoveryMethod,imported:n.imported,delegated:n.delegated,walletIndex:n.walletIndex},smartWallet:i&&{address:i.address,smartWalletType:i.smartWalletType},google:l&&{subject:l.subject,email:l.email,name:l.name},twitter:c&&{subject:c.subject,username:c.username,name:c.name,profilePictureUrl:c.profilePictureUrl},discord:d&&{subject:d.subject,username:d.username,email:d.email},github:u&&{subject:u.subject,username:u.username,name:u.name,email:u.email},spotify:h&&{subject:h.subject,email:h.email,name:h.name},instagram:p&&{subject:p.subject,username:p.username},tiktok:m&&{subject:m.subject,username:m.username,name:m.name},line:y&&{subject:y.subject,name:y.name,email:y.email,profilePictureUrl:y.profilePictureUrl},linkedin:f&&{subject:f.subject,name:f.name,email:f.email,vanityName:f.vanityName},apple:g&&{subject:g.subject,email:g.email},farcaster:w&&{fid:w.fid,ownerAddress:w.ownerAddress,displayName:w.displayName,username:w.username,bio:w.bio,pfp:w.pfp,url:w.url,signerPublicKey:w.signerPublicKey},telegram:v&&{telegramUserId:v.telegramUserId,firstName:v.firstName,lastName:v.lastName,username:v.username,photoUrl:v.photoUrl},delegatedWallets:[],mfaMethods:b.map(e=>e.type),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}let b=e=>!!e.id&&"privy-v2"===e.recoveryMethod,x=(0,r.createContext)({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:a.a,login:a.a,connectOrCreateWallet:a.a,linkEmail:a.a,linkPhone:a.a,linkFarcaster:a.a,linkWallet:a.a,startCrossAppAuthFlow:a.a,linkGoogle:a.a,linkTwitter:a.a,linkDiscord:a.a,linkGithub:a.a,linkSpotify:a.a,linkInstagram:a.a,linkTelegram:a.a,linkTiktok:a.a,linkLine:a.a,linkLinkedIn:a.a,linkApple:a.a,linkPasskey:a.a,updateEmail:a.a,updatePhone:a.a,logout:a.a,getAccessToken:a.a,unlinkEmail:a.a,unlinkPhone:a.a,unlinkWallet:a.a,unlinkGoogle:a.a,unlinkTwitter:a.a,unlinkDiscord:a.a,unlinkGithub:a.a,unlinkSpotify:a.a,unlinkInstagram:a.a,unlinkTiktok:a.a,unlinkLine:a.a,unlinkLinkedIn:a.a,unlinkApple:a.a,unlinkCrossAppAccount:a.a,unlinkFarcaster:a.a,unlinkTelegram:a.a,unlinkPasskey:a.a,signMessage:a.a,signTypedData:a.a,enrollInMfa:a.a,initEnrollmentWithSms:a.a,initEnrollmentWithTotp:a.a,initEnrollmentWithPasskey:a.a,promptMfa:a.a,init:a.a,submitEnrollmentWithSms:a.a,submitEnrollmentWithTotp:a.a,submitEnrollmentWithPasskey:a.a,unenroll:a.a,submit:a.a,cancel:a.a,sendTransaction:a.a,signTransaction:a.a,exportWallet:a.a,setWalletPassword:a.a,setWalletRecovery:a.a,requestFarcasterSignerFromWarpcast:a.a,getFarcasterSignerPublicKey:a.a,signFarcasterMessage:a.a,signMessageWithCrossAppWallet:a.a,signTypedDataWithCrossAppWallet:a.a,sendTransactionWithCrossAppWallet:a.a,isModalOpen:!1,mfaMethods:[]}),_=()=>(0,r.useContext)(x),C=()=>{let{getAccessToken:e}=_(),{walletProxy:t}=(0,a.u)();return(0,r.useMemo)(()=>({signWithUserSigner:async({message:n})=>{if(!t)throw Error("Wallet proxy not initialized");let i=await e();if(!i)throw Error("User must be authenticated");let{signature:r}=await t.signWithUserSigner({accessToken:i,message:n});return{signature:r}}}),[t,e])}}
72,164972:(e,t,n)=>{"use strict";n.d(t,{L:()=>r});var i=n(97644);let r=async e=>{try{let t=(0,i.J)({abi:[{inputs:[{internalType:"address[]",name:"dest",type:"address[]"},{internalType:"uint256[]",name:"value",type:"uint256[]"},{internalType:"bytes[]",name:"func",type:"bytes[]"}],name:"executeBatch",outputs:[],stateMutability:"nonpayable",type:"function"}],data:e}),n=[];for(let e=0;e<t.args[0].length;e++)n.push({to:t.args[0][e],value:t.args[1][e],data:t.args[2][e]});return n}catch(e){}let t=(0,i.J)({abi:[{inputs:[{internalType:"address",name:"dest",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"func",type:"bytes"}],name:"execute",outputs:[],stateMutability:"nonpayable",type:"function"}],data:e});return[{to:t.args[0],value:t.args[1],data:t.args[2]}]}},172034:(e,t,n)=>{"use strict";n.d(t,{c:()=>_});var i=n(352401),r=n(787944),a=n(889810),s=n(333625),o=n(788882),l=n(97644),c=n(607186),d=n(452652),u=n(174562),h=n(814001),p=n(916544),m=n(382487),y=n(575665),f=n(749397),g=n(448953),w=n(270854);let v={ECDSA_OWNERSHIP_REGISTRY_MODULE:"0x0000001c5b32F37F5beA87BDD5374eB2aC54eA8e",FACTORY_ADDRESS:"0x000000a56Aaca3e9a4C479ea6b6CD0DbcB6634F5",ACCOUNT_V2_0_LOGIC:"0x0000002512019Dafb59528B82CB92D3c5D2423aC",DEFAULT_FALLBACK_HANDLER_ADDRESS:"0x0bBa6d96BD616BedC6BFaa341742FD43c60b83C1"},b=async({owner:e,index:t,ecdsaModuleAddress:n})=>{if(!e)throw Error("Owner account not found");let r=(0,i.p)({abi:w.B,functionName:"initForSmartAccount",args:[e]});return(0,i.p)({abi:w.z,functionName:"deployCounterFactualAccount",args:[n,r,t]})},x=async({factoryAddress:e,accountLogicAddress:t,fallbackHandlerAddress:n,ecdsaModuleAddress:l,owner:c,index:d=BigInt(0)})=>{let u=(0,i.p)({abi:w.B,functionName:"initForSmartAccount",args:[c]}),h=(0,i.p)({abi:w.B,functionName:"init",args:[n,l,u]}),p=(0,r.P)(["bytes","uint256"],["0x6080346100aa57601f61012038819003918201601f19168301916001600160401b038311848410176100af578084926020946040528339810103126100aa57516001600160a01b0381168082036100aa5715610065573055604051605a90816100c68239f35b60405162461bcd60e51b815260206004820152601e60248201527f496e76616c696420696d706c656d656e746174696f6e206164647265737300006044820152606490fd5b600080fd5b634e487b7160e01b600052604160045260246000fdfe608060405230546000808092368280378136915af43d82803e156020573d90f35b3d90fdfea2646970667358221220a03b18dce0be0b4c9afe58a9eb85c35205e2cf087da098bbf1d23945bf89496064736f6c63430008110033",(0,a.uU)(t)]),m=(0,s.S)((0,r.P)(["bytes32","uint256"],[(0,s.S)((0,r.P)(["bytes"],[h])),d]));return(0,o.RZ)({from:e,salt:m,bytecode:p,opcode:"CREATE2"})};async function _(e){let{owners:t,client:n,index:r=0n,address:a,accountLogicAddress:s=v.ACCOUNT_V2_0_LOGIC,fallbackHandlerAddress:o=v.DEFAULT_FALLBACK_HANDLER_ADDRESS,ecdsaModuleAddress:_=v.ECDSA_OWNERSHIP_REGISTRY_MODULE,factoryAddress:C=v.FACTORY_ADDRESS}=e,I=await (0,g.F)({owner:t[0]}),E={address:e.entryPoint?.address??u.B9,abi:h.hw,version:e.entryPoint?.version??"0.6"},T=a,A=async()=>({factory:C,factoryData:await b({owner:I.address,index:r,ecdsaModuleAddress:_})});return(0,p.q)({client:n,entryPoint:E,getFactoryArgs:A,getAddress:async()=>T||(T=await x({owner:I.address,ecdsaModuleAddress:_,factoryAddress:C,accountLogicAddress:s,fallbackHandlerAddress:o,index:r})),async getNonce(t){let i=await this.getAddress();return(0,f.p)(n,{address:i,entryPointAddress:E.address,key:e?.nonceKey??t?.key})},encodeCalls:async e=>{if(e.length>1)return(0,i.p)({abi:w.B,functionName:"executeBatch_y6U",args:[e.map(e=>e.to),e.map(e=>e.value??0n),e.map(e=>e.data??"0x")]});let t=0===e.length?void 0:e[0];if(!t)throw Error("No calls to encode");return(0,i.p)({abi:w.B,functionName:"execute_ncC",args:[t.to,t.value??0n,t.data??"0x"]})},decodeCalls:async e=>{let t=(0,l.J)({abi:w.B,data:e});if("execute_ncC"===t.functionName)return[{to:t.args[0],value:t.args[1],data:t.args[2]}];if("executeBatch_y6U"===t.functionName){let e=[];for(let n=0;n<t.args[0].length;n++)e.push({to:t.args[0][n],value:t.args[1][n],data:t.args[2][n]});return e}throw Error("Invalid function name")},async getStubSignature(){let e=_.substring(2).padEnd(40,"0");return`0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000${e}000000000000000000000000000000000000000000000000000000000000004181d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b00000000000000000000000000000000000000000000000000000000000000`},async sign({hash:e}){return this.signMessage({message:e})},async signMessage({message:e}){let t=await I.signMessage({message:e}),n=Number.parseInt(t.slice(-2),16);if(![27,28].includes(n)){let e=n+27;t=t.slice(0,-2)+e.toString(16)}return(0,c.h)([{type:"bytes"},{type:"address"}],[t,_])},async signTypedData(e){let t=await I.signTypedData(e),n=Number.parseInt(t.slice(-2),16);if(![27,28].includes(n)){let e=n+27;t=t.slice(0,-2)+e.toString(16)}return(0,c.h)([{type:"bytes"},{type:"address"}],[t,_])},async signUserOperation(e){let{chainId:t=n.chain?.id,...i}=e;if(!t)throw Error("Chain id not found");let r=(0,m.Z)({userOperation:{...i,sender:i.sender??await this.getAddress(),signature:"0x"},entryPointAddress:E.address,entryPointVersion:E.version,chainId:t}),a=await (0,y.l)(n,{account:I,message:{raw:r}});return(0,c.h)((0,d.m)("bytes, address"),[a,_])}})}}
72,174562:(e,t,n)=>{"use strict";n.d(t,{B9:()=>i,oi:()=>r});let i="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",r="0x0000000071727De22E5E9d8BAf0edAc6f37da032"},182913:(e,t,n)=>{"use strict";n.d(t,{g:()=>a});var i=n(333835),r=n(211690);function a(e,t="wei"){return(0,r.X)(e,i.eL[t])}},183529:(e,t,n)=>{"use strict";n.d(t,{R:()=>i});let i={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-mainnet.rpc.privy.systems"]},alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}}},192344:(e,t,n)=>{"use strict";n.d(t,{G:()=>i});let i={id:0xaa36a7,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{privy:{http:["https://sepolia.rpc.privy.systems"]},alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0}},211690:(e,t,n)=>{"use strict";n.d(t,{X:()=>r});var i=n(856935);function r(e,t){if(!/^(-?)([0-9]*)\.?([0-9]*)$/.test(e))throw new i.g({value:e});let[n,r="0"]=e.split("."),a=n.startsWith("-");if(a&&(n=n.slice(1)),r=r.replace(/(0+)$/,""),0===t)1===Math.round(Number(`.${r}`))&&(n=`${BigInt(n)+1n}`),r="";else if(r.length>t){let[e,i,a]=[r.slice(0,t-1),r.slice(t-1,t),r.slice(t)],s=Math.round(Number(`${i}.${a}`));(r=s>9?`${BigInt(e)+BigInt(1)}0`.padStart(e.length+1,"0"):`${e}${s}`).length>t&&(r=r.slice(1),n=`${BigInt(n)+1n}`),r=r.slice(0,t)}else r=r.padEnd(t,"0");return BigInt(`${a?"-":""}${n}${r}`)}},215757:(e,t,n)=>{"use strict";n.d(t,{m:()=>h});var i=n(291765),r=n(77954),a=n(420719),s=n(660876),o=n(878314),l=n(683112),c=n(371965),d=n(309353);let u="/docs/contract/encodeDeployData";function h(e){let{abi:t,args:n,bytecode:c,deploymentType:h,salt:m}=e;if(!n||0===n.length){let{functionName:e,argsContractDeployer:t}=p(h,m??i.t,(0,o.nj)((0,d.Y)(c)),"0x");return(0,s.p)({abi:l.hl,functionName:e,args:t})}let y=t.find(e=>"type"in e&&"constructor"===e.type);if(!y)throw new r.YW({docsPath:u});if(!("inputs"in y)||!y.inputs||0===y.inputs.length)throw new r.YF({docsPath:u});let f=(0,a.h)(y.inputs,n),{functionName:g,argsContractDeployer:w}=p(h,m??i.t,(0,o.nj)((0,d.Y)(c)),f);return(0,s.p)({abi:l.hl,functionName:g,args:w})}function p(e,t,n,i){let r=[t,n,i];return({create:{functionName:"create",argsContractDeployer:r},create2:{functionName:"create2",argsContractDeployer:r},createAccount:{functionName:"createAccount",argsContractDeployer:[...r,c.t]},create2Account:{functionName:"create2Account",argsContractDeployer:[...r,c.t]}})[e||"create"]}},216146:(e,t,n)=>{"use strict";n.d(t,{w:()=>s});var i=n(215354),r=n(593449),a=n(678425);function s(e){if(!(0,a.H)(e))throw new r.K;(0,i.c)(e)}},217625:(e,t,n)=>{"use strict";n.d(t,{D:()=>i});let i={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-mainnet.rpc.privy.systems"]},alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}}},223181:(e,t,n)=>{e.exports=n(155950)(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})}
72,244552:(e,t,n)=>{"use strict";n.d(t,{x7:()=>a});var i=n(890565),r=n(516033);n(206284),n(715599).Buffer;let a=(0,i.w3)([(0,i.DH)("mintAuthorityOption"),(0,r.jE)("mintAuthority"),(0,r._l)("supply"),(0,i.u8)("decimals"),(0,r.lc)("isInitialized"),(0,i.DH)("freezeAuthorityOption"),(0,r.jE)("freezeAuthority")]);a.span},263400:(e,t,n)=>{"use strict";n.d(t,{v:()=>l});var i=n(963323),r=n(898745),a=n(797036),s=n(603181),o=n(155341);async function l(e,t){let n;if("to"in t){let{account:r=e.account,data:l,maxFeePerGas:c,maxPriorityFeePerGas:d,to:u,value:h,nonce:p}=t;if(!r)throw new o.T({docsPath:"/docs/actions/wallet/sendTransaction"});let m=(0,a.J)(r);if(!u)throw Error("Missing to address");n=await (0,s.T)(e,i.$,"sendUserOperation")({...t,calls:[{to:u,value:h||BigInt(0),data:l||"0x"}],account:m,maxFeePerGas:c,maxPriorityFeePerGas:d,nonce:p?BigInt(p):void 0})}else n=await (0,s.T)(e,i.$,"sendUserOperation")({...t});let l=await (0,s.T)(e,r.V,"waitForUserOperationReceipt")({hash:n});return l?.receipt.transactionHash}},269470:(e,t,n)=>{"use strict";n.d(t,{k:()=>_});var i,r=n(352401),a=n(97644),s=n(559482),o=n(991439),l=n(886834),c=n(174562),d=n(814001),u=n(916544),h=n(382487),p=n(760483),m=n(575665),y=n(603181),f=n(749397),g=n(329086),w=n(448953);let v=async(e,t=BigInt(0))=>{if(!e)throw Error("Owner account not found");return(0,r.p)({abi:[{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"salt",type:"uint256"}],name:"createAccount",outputs:[{internalType:"contract LightAccount",name:"ret",type:"address"}],stateMutability:"nonpayable",type:"function"}],functionName:"createAccount",args:[e,t]})};async function b(e,t,n,i){return e.signTypedData({domain:{chainId:Number(t),name:"LightAccount",verifyingContract:n,version:"1"},types:{LightAccountMessage:[{name:"message",type:"bytes"}]},message:{message:i},primaryType:"LightAccountMessage"})}let x={"1.1.0":{factoryAddress:"0x00004EC70002a32400f8ae005A26081065620D20"},"2.0.0":{factoryAddress:"0x0000000000400CdFef5E2714E63d8040b700BC24"}};async function _(e){let t,{version:n,factoryAddress:_,address:C,owner:I,client:E,index:T=BigInt(0),nonceKey:A}=e,S=await (0,w.F)({owner:I}),k={address:e.entryPoint?.address??c.oi,abi:(e.entryPoint?.version??"0.7")==="0.6"?d.hw:d.qe,version:e.entryPoint?.version??"0.7"},{factoryAddress:P}=((e,{factoryAddress:t})=>({factoryAddress:t??x[e].factoryAddress}))(n,{factoryAddress:_}),j=C,O=async()=>t||(t=E.chain?E.chain.id:await (0,y.T)(E,p.T,"getChainId")({})),N=async()=>({factory:P,factoryData:await v(S.address,T)});return(0,u.q)({client:E,entryPoint:k,getFactoryArgs:N,async getAddress(){if(j)return j;let{factory:e,factoryData:t}=await N();return j=await (0,g.s)(E,{factory:e,factoryData:t,entryPointAddress:k.address})},async encodeCalls(e){if(e.length>1)return(0,r.p)({abi:[{inputs:[{internalType:"address[]",name:"dest",type:"address[]"},{internalType:"uint256[]",name:"value",type:"uint256[]"},{internalType:"bytes[]",name:"func",type:"bytes[]"}],name:"executeBatch",outputs:[],stateMutability:"nonpayable",type:"function"}],functionName:"executeBatch",args:[e.map(e=>e.to),e.map(e=>e.value??0n),e.map(e=>e.data??"0x")]});let t=0===e.length?void 0:e[0];if(!t)throw Error("No calls to encode");return(0,r.p)({abi:[{inputs:[{internalType:"address",name:"dest",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"func",type:"bytes"}],name:"execute",outputs:[],stateMutability:"nonpayable",type:"function"}],functionName:"execute",args:[t.to,t.value??0n,t.data??"0x"]})},async decodeCalls(e){try{let t=(0,a.J)({abi:[{inputs:[{internalType:"address[]",name:"dest",type:"address[]"},{internalType:"uint256[]",name:"value",type:"uint256[]"},{internalType:"bytes[]",name:"func",type:"bytes[]"}],name:"executeBatch",outputs:[],stateMutability:"nonpayable",type:"function"}],data:e});if("executeBatch"===t.functionName){let e=[];for(let n=0;n<t.args[0].length;n++)e.push({to:t.args[0][n],value:t.args[1][n],data:t.args[2][n]});return e}throw Error("Invalid function name")}catch(n){let t=(0,a.J)({abi:[{inputs:[{internalType:"address",name:"dest",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"func",type:"bytes"}],name:"execute",outputs:[],stateMutability:"nonpayable",type:"function"}],data:e});return[{to:t.args[0],value:t.args[1],data:t.args[2]}]}},async getNonce(e){return(0,f.p)(E,{address:await this.getAddress(),entryPointAddress:k.address,key:A??e?.key})},async getStubSignature(){let e="0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";switch(n){case"1.1.0":return e;case"2.0.0":return(0,s.xW)([i.EOA,e]);default:throw Error("Unknown Light Account version")}},async sign({hash:e}){return this.signMessage({message:e})},async signMessage({message:e}){let t=await b(S,await O(),await this.getAddress(),(0,o.A)(e));switch(n){case"1.1.0":return t;case"2.0.0":return(0,s.xW)([i.EOA,t]);default:throw Error("Unknown Light Account version")}},async signTypedData(e){let t=await b(S,await O(),await this.getAddress(),(0,l.Zh)(e));switch(n){case"1.1.0":return t;case"2.0.0":return(0,s.xW)([i.EOA,t]);default:throw Error("Unknown Light Account version")}},async signUserOperation(e){let{chainId:t=await O(),...r}=e,a=(0,h.Z)({userOperation:{...r,signature:"0x"},entryPointAddress:k.address,entryPointVersion:k.version,chainId:t}),o=await (0,m.l)(E,{account:S,message:{raw:a}});switch(n){case"1.1.0":return o;case"2.0.0":return(0,s.xW)([i.EOA,o]);default:throw Error("Unknown Light Account version")}}})}(i||(i={})).EOA="0x00"},270360:(e,t,n)=>{"use strict";n.d(t,{F:()=>a});var i=n(356273),r=n(569696);function a(e){let{key:t="wallet",name:n="Wallet Client",transport:a}=e;return(0,i.U)({...e,key:t,name:n,transport:a,type:"walletClient"}).extend(r.D)}}
72,270854:(e,t,n)=>{"use strict";n.d(t,{B:()=>r,z:()=>i});let i=[{inputs:[{internalType:"address",name:"moduleSetupContract",type:"address"},{internalType:"bytes",name:"moduleSetupData",type:"bytes"},{internalType:"uint256",name:"index",type:"uint256"}],name:"deployCounterFactualAccount",outputs:[{internalType:"address",name:"proxy",type:"address"}],stateMutability:"nonpayable",type:"function"}],r=[{inputs:[{internalType:"address",name:"handler",type:"address"},{internalType:"address",name:"moduleSetupContract",type:"address"},{internalType:"bytes",name:"moduleSetupData",type:"bytes"}],name:"init",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"eoaOwner",type:"address"}],name:"initForSmartAccount",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"dest",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"func",type:"bytes"}],name:"execute_ncC",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address[]",name:"dest",type:"address[]"},{internalType:"uint256[]",name:"value",type:"uint256[]"},{internalType:"bytes[]",name:"func",type:"bytes[]"}],name:"executeBatch_y6U",outputs:[],stateMutability:"nonpayable",type:"function"}]},286836:(e,t,n)=>{"use strict";n.d(t,{h:()=>i});let i=[{type:"function",name:"deployWithFactory",inputs:[{name:"factory",type:"address",internalType:"contract KernelFactory"},{name:"createData",type:"bytes",internalType:"bytes"},{name:"salt",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"payable"}]},288497:(e,t,n)=>{"use strict";var i;n.d(t,{am:()=>a,g8:()=>s,rR:()=>r,xQ:()=>i});let r="0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",a="0x00000000",s={ROOT:"0x00",VALIDATOR:"0x01",PERMISSION:"0x02"};!function(e){e.DEFAULT="0x00",e.ENABLE="0x01"}(i||(i={}))},291765:(e,t,n)=>{"use strict";n.d(t,{I:()=>i,t:()=>r});let i="0x6492649264926492649264926492649264926492649264926492649264926492",r="0x0000000000000000000000000000000000000000000000000000000000000000"},292118:(e,t,n)=>{"use strict";n.d(t,{q:()=>r});var i=n(125644);class r extends i.C{constructor(e){super(`Call bundle failed with status: ${e.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=e}}},297660:(e,t,n)=>{"use strict";n.d(t,{C:()=>i});let i={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0}},297895:(e,t,n)=>{"use strict";n.d(t,{E:()=>s});var i=n(352401),r=n(603181),a=n(263400);async function s(e,{abi:t,address:n,args:s,dataSuffix:o,functionName:l,...c}){let d=(0,i.p)({abi:t,args:s,functionName:l});return await (0,r.T)(e,a.v,"sendTransaction")({data:`${d}${o?o.replace("0x",""):""}`,to:n,...c})}},317121:(e,t,n)=>{"use strict";n.d(t,{u:()=>a});var i=n(941703),r=n(128897);function a(e){let{r:t,s:n}=i.secp256k1.Signature.fromCompact(e.slice(2,130)),a=Number(`0x${e.slice(130)}`),[s,o]=(()=>{if(0===a||1===a)return[void 0,a];if(27===a)return[BigInt(a),0];if(28===a)return[BigInt(a),1];throw Error("Invalid yParityOrV value")})();return void 0!==s?{r:(0,r.cK)(t,{size:32}),s:(0,r.cK)(n,{size:32}),v:s,yParity:o}:{r:(0,r.cK)(t,{size:32}),s:(0,r.cK)(n,{size:32}),yParity:o}}},328414:(e,t,n)=>{"use strict";Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable},329086:(e,t,n)=>{"use strict";n.d(t,{s:()=>d});var i=n(125644),r=n(559482),a=n(266431),s=n(999622),o=n(98408),l=n(603181);let c=[{inputs:[{internalType:"address",name:"_entryPoint",type:"address"},{internalType:"bytes",name:"initCode",type:"bytes"}],stateMutability:"payable",type:"constructor"}];i.C;let d=async(e,t)=>{let{initCode:n,entryPointAddress:i,factory:d,factoryData:u}=t;if(!n&&!d&&!u)throw Error("Either `initCode` or `factory` and `factoryData` must be provided");let h=n||(0,r.xW)([d,u]),{data:p}=await (0,l.T)(e,o.T,"call")({data:(0,a.m)({abi:c,bytecode:"0x60806040526102a28038038091610015826100ae565b6080396040816080019112610093576080516001600160a01b03811681036100935760a0516001600160401b0381116100935
72782609f82011215610093578060800151610061816100fc565b9361006f60405195866100d9565b81855260a082840101116100935761008e9160a0602086019101610117565b610196565b600080fd5b634e487b7160e01b600052604160045260246000fd5b6080601f91909101601f19168101906001600160401b038211908210176100d457604052565b610098565b601f909101601f19168101906001600160401b038211908210176100d457604052565b6001600160401b0381116100d457601f01601f191660200190565b60005b83811061012a5750506000910152565b818101518382015260200161011a565b6040916020825261015a8151809281602086015260208686019101610117565b601f01601f1916010190565b3d15610191573d90610177826100fc565b9161018560405193846100d9565b82523d6000602084013e565b606090565b600091908291826040516101cd816101bf6020820195639b249f6960e01b87526024830161013a565b03601f1981018352826100d9565b51925af16101d9610166565b906102485760048151116000146101f7576024015160005260206000f35b60405162461bcd60e51b8152602060048201526024808201527f67657453656e64657241646472657373206661696c656420776974686f7574206044820152636461746160e01b6064820152608490fd5b60405162461bcd60e51b815260206004820152602b60248201527f67657453656e6465724164647265737320646964206e6f74207265766572742060448201526a185cc8195e1c1958dd195960aa1b6064820152608490fdfe",args:[i,h]})});if(!p)throw Error("Failed to get sender address");return(0,s.n)([{type:"address"}],p)[0]}},337791:(e,t,n)=>{"use strict";n.d(t,{j:()=>s});var i=n(12518),r=n(871883),a=n(591260);async function s({hash:e,signature:t}){let s=(0,i.q)(e)?e:(0,a.nj)(e),{secp256k1:l}=await n.e(522).then(n.bind(n,890522)),c=(()=>{if("object"==typeof t&&"r"in t&&"s"in t){let{r:e,s:n,v:i,yParity:a}=t,s=o(Number(a??i));return new l.Signature((0,r.uU)(e),(0,r.uU)(n)).addRecoveryBit(s)}let e=(0,i.q)(t)?t:(0,a.nj)(t),n=o((0,r.ME)(`0x${e.slice(130)}`));return l.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(n)})().recoverPublicKey(s.substring(2)).toHex(!1);return`0x${c}`}function o(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw Error("Invalid yParityOrV value")}},340335:(e,t,n)=>{"use strict";n.d(t,{W:()=>i});let i=e=>"webAuthn"===e.type},341028:(e,t,n)=>{"use strict";function i(e){return e.request({method:"eth_supportedEntryPoints"})}n.d(t,{c:()=>i})},343750:(e,t,n)=>{"use strict";n.d(t,{m:()=>b,o:()=>x});var i=n(217625),r=n(988586),a=n(663272),s=n(297660),o=n(675708),l=n(633793),c=n(756924),d=n(111280),u=n(113627),h=n(183529),p=n(43866),m=n(828701),y=n(933087),f=n(192344),g=n(790357),w=n(790518),v=n(636976);let b=[u.r,f.G,{id:17e3,name:"Holesky",network:"holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://ethereum-holesky.publicnode.com"]},public:{http:["https://ethereum-holesky.publicnode.com"]}},blockExplorers:{etherscan:{name:"EtherScan",url:"https://holesky.etherscan.io"},default:{name:"EtherScan",url:"https://holesky.etherscan.io"}}},i.D,r.Y,h.R,p.i,m.n,y.n,c.A,{id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0},{id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}},{id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}},o.E,l.Z,{id:80085,network:"berachain-artio",name:"Berachain Artio",nativeCurrency:{name:"BERA",symbol
72:"BERA",decimals:18},rpcUrls:{default:{http:["https://berachain-artio.rpc.privy.systems"]},public:{http:["https://berachain-artio.rpc.privy.systems"]}},blockExplorers:{default:{name:"Beratrail",url:"https://artio.beratrail.io"}},testnet:!0},{id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network"}}},d._,{id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0},a.m,s.C,g.L,v.q,w.a,{id:690,name:"Redstone",network:"redstone",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.redstonechain.com"]},public:{http:["https://rpc.redstonechain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.redstone.xyz/"}}},{id:17069,name:"Garnet Holesky",network:"garnet-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.garnetchain.com"]},public:{http:["https://rpc.garnetchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.garnetchain.com"}}}],x=new Set(b.map(e=>e.id))},345475:(e,t,n)=>{"use strict";function i(e){let t={};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),t}n.d(t,{V:()=>i})},347626:(e,t,n)=>{"use strict";n.d(t,{eV:()=>r});var i=n(851318);function r(e,{dir:t,size:n=32}={}){return"string"==typeof e?function(e,{dir:t,size:n=32}={}){if(null===n)return e;let r=e.replace("0x","");if(r.length>2*n)throw new i.Fl({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new i.Fl({size:e.length,targetSize:n,type:"bytes"});let r=new Uint8Array(n);for(let i=0;i<n;i++){let a="right"===t;r[a?i:n-i-1]=e[a?i:e.length-i-1]}return r}(e,{dir:t,size:n})}},349271:(e,t,n)=>{"use strict";n.d(t,{k:()=>a});var i=n(529533),r=n(603181);let a=async(e,t)=>{let{adminAddress:n,factoryAddress:a,salt:s}=t;return(0,r.T)(e,i.J,"readContract")({address:a,abi:[{inputs:[{name:"_adminSigner",type:"address"},{name:"_data",type:"bytes"}],name:"getAddress",outputs:[{type:"address"}],stateMutability:"view",type:"function"}],functionName:"getAddress",args:[n,s]})}},353689:(e,t,n)=>{var i=n(857658),r=n(115743),a=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u01
727f]/g,s=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");e.exports=function(e){return(e=r(e))&&e.replace(a,i).replace(s,"")}},361775:(e,t,n)=>{"use strict";n.d(t,{L8:()=>r}),n(920506);var i=n(538790);function r(e){let{source:t}=e,n=new Map,r=new i.A(8192),a=new Map,s=({address:e,chainId:t})=>`${e}.${t}`;return{async consume({address:e,chainId:n,client:i}){let a=s({address:e,chainId:n}),o=this.get({address:e,chainId:n,client:i});this.increment({address:e,chainId:n});let l=await o;return await t.set({address:e,chainId:n},l),r.set(a,l),l},async increment({address:e,chainId:t}){let i=s({address:e,chainId:t}),r=n.get(i)??0;n.set(i,r+1)},async get({address:e,chainId:i,client:o}){let l=s({address:e,chainId:i}),c=a.get(l);return c||(c=(async()=>{try{let n=await t.get({address:e,chainId:i,client:o}),a=r.get(l)??0;if(a>0&&n<=a)return a+1;return r.delete(l),n}finally{this.reset({address:e,chainId:i})}})(),a.set(l,c)),(n.get(l)??0)+await c},reset({address:e,chainId:t}){let i=s({address:e,chainId:t});n.delete(i),a.delete(i)}}}},364591:(e,t,n)=>{"use strict";n.d(t,{v:()=>w});var i=n(797036),r=n(347220),a=n(125644),s=n(261919),o=n(690627),l=n(637155),c=n(255936),d=n(675438),u=n(603181),h=n(538790),p=n(721939),m=n(760483),y=n(766075),f=n(13359);let g=new h.A(128);async function w(e,t){let{account:n=e.account,chain:h=e.chain,accessList:w,authorizationList:v,blobs:b,data:x,gas:_,gasPrice:C,maxFeePerBlobGas:I,maxFeePerGas:E,maxPriorityFeePerGas:T,nonce:A,type:S,value:k,...P}=t;if(void 0===n)throw new r.T({docsPath:"/docs/actions/wallet/sendTransaction"});let j=n?(0,i.J)(n):null;try{(0,p.c)(t);let n=await (async()=>t.to?t.to:null!==t.to&&v&&v.length>0?await (0,s.g)({authorization:v[0]}).catch(()=>{throw new a.C("`to` is required. Could not infer from `authorizationList`.")}):void 0)();if(j?.type==="json-rpc"||null===j){let t;null!==h&&(t=await (0,u.T)(e,m.T,"getChainId")({}),(0,o.v)({currentChainId:t,chain:h}));let i=e.chain?.formatters?.transactionRequest?.format,r=(i||d.Bv)({...(0,c.o)(P,{format:i}),accessList:w,authorizationList:v,blobs:b,chainId:t,data:x,from:j?.address,gas:_,gasPrice:C,maxFeePerBlobGas:I,maxFeePerGas:E,maxPriorityFeePerGas:T,nonce:A,to:n,type:S,value:k},"sendTransaction"),a=g.get(e.uid);try{return await e.request({method:a?"wallet_sendTransaction":"eth_sendTransaction",params:[r]},{retryCount:0})}catch(t){if(!1===a)throw t;if("InvalidInputRpcError"===t.name||"InvalidParamsRpcError"===t.name||"MethodNotFoundRpcError"===t.name||"MethodNotSupportedRpcError"===t.name)return await e.request({method:"wallet_sendTransaction",params:[r]},{retryCount:0}).then(t=>(g.set(e.uid,!0),t)).catch(n=>{if("MethodNotFoundRpcError"===n.name||"MethodNotSupportedRpcError"===n.name)throw g.set(e.uid,!1),t;throw n});throw t}}if(j?.type==="local"){let t=await (0,u.T)(e,y.ft,"prepareTransactionRequest")({account:j,accessList:w,authorizationList:v,blobs:b,chain:h,data:x,gas:_,gasPrice:C,maxFeePerBlobGas:I,maxFeePerGas:E,maxPriorityFeePerGas:T,nonce:A,nonceManager:j.nonceManager,parameters:[...y.MM,"sidecars"],type:S,value:k,...P,to:n}),i=h?.serializers?.transaction,r=await j.signTransaction(t,{serializer:i});return await (0,u.T)(e,f.L,"sendRawTransaction")({serializedTransaction:r})}if(j?.type==="smart")throw new r.Z({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"});throw new r.Z({docsPath:"/docs/actions/wallet/sendTransaction",type:j?.type})}catch(e){if(e instanceof r.Z)throw e;throw(0,l.p)(e,{...t,account:j,chain:t.chain||void 0})}}},371137:(e,t,n)=>{"use strict";n.d(t,{o:()=>o});var i=n(854),r=n(752492);class a extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=this.keys().next().value;e&&this.delete(e)}return this}}let s=new a(8192);function o(e,t){if(s.has(`${e}.${t}`))return s.get(`${e}.${t}`);let n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),a=(0,r.S)((0,i.Af)(n),"bytes"),o=(t?n.substring(`${t}0x`.length):n).split("");for(let e=0;e<40;e+=2)a[e>>1]>>4>=8&&o[e]&&(o[e]=o[e].toUpperCase()),(15&a[e>>1])>=8&&o[e+1]&&(o[e+1]=o[e+1].toUpperCase());let l=`0x${o.join("")}`;return s.set(`${e}.${t}`,l),l}},371965:(e,t,n)=>{"use strict";n.d(t,{t:()=>i});let i=1},372359:()=>{},381725:(e,t,n)=>{"use strict";n.d(t,{Wp:()=>i.Wp});var i=n(755582);(0,i.KO)("firebase","11.10.0","app")},382487:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var i=n(607186),r=n(333625),a=n(886834),s=n(37902),o=n(940937),l=n(572178);function c(e){let{chainId:t,entryPointAddress:n,entryPointVersion:c}=e,d=e.userOperation,{authorization:u,callData:h="0x",callGasLimit:p,maxFeePerGas:m,maxPriorityFeePerGas:y,nonce:f,paymasterAndData:g="0x",preVerificationGas:w,sender:v,verificationGasLimit:b}=d;if("0.8"===c)return(0,a.Zh)((0,o.t)({chainId:t,entryPointAddress:n,userOperation:d}));let x=(()=>
72{if("0.6"===c){let e=d.initCode?.slice(0,42),t=d.initCode?.slice(42),n=(0,s.K)({authorization:u,factory:e,factoryData:t});return(0,i.h)([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"bytes32"}],[v,f,(0,r.S)(n),(0,r.S)(h),p,b,w,m,y,(0,r.S)(g)])}if("0.7"===c){let e=(0,l.W)(d);return(0,i.h)([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[e.sender,e.nonce,(0,r.S)(e.initCode),(0,r.S)(e.callData),e.accountGasLimits,e.preVerificationGas,e.gasFees,(0,r.S)(e.paymasterAndData)])}throw Error(`entryPointVersion "${c}" not supported.`)})();return(0,r.S)((0,i.h)([{type:"bytes32"},{type:"address"},{type:"uint256"}],[(0,r.S)(x),n,BigInt(t)]))}},402954:(e,t,n)=>{"use strict";n.d(t,{N:()=>a});var i=n(116274);let r=[i.A7,i.pY,i.ZH,i.wG,i.Zt,i.oP,i.ln,i.U5,i.Kg,i.WF,i.ei];function a(e,t){let n=(e.details||"").toLowerCase();if(i.zs.message.test(n))return new i.zs({cause:e});if(i.XS.message.test(n))return new i.XS({cause:e});if(i.Qn.message.test(n))return new i.Qn({cause:e});if(i.lP.message.test(n))return new i.lP({cause:e});if(i.x7.message.test(n))return new i.x7({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(i.cF.message.test(n))return new i.cF({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(i.et.message.test(n))return new i.et({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode,sender:t.sender});if(i._R.message.test(n))return new i._R({cause:e});if(i.Mj.message.test(n))return new i.Mj({cause:e});if(i.im.message.test(n))return new i.im({cause:e,nonce:t.nonce});if(i.dE.message.test(n))return new i.dE({cause:e});if(i.bn.message.test(n))return new i.bn({cause:e});if(i.RK.message.test(n))return new i.RK({cause:e});if(i.ZH.message.test(n))return new i.ZH({cause:e});if(i.Ug.message.test(n))return new i.Ug({cause:e});if(i._e.message.test(n))return new i._e({cause:e});if(i.di.message.test(n))return new i.di({cause:e});if(i.wJ.message.test(n))return new i.wJ({cause:e});if(i._p.message.test(n))return new i._p({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(i.sA.message.test(n))return new i.sA({cause:e});if(i.s$.message.test(n))return new i.s$({cause:e});if(i.tS.message.test(n))return new i.tS({cause:e});if(i.Py.message.test(n))return new i.Py({cause:e});if(i.bS.message.test(n))return new i.bS({cause:e});if(i.g1.message.test(n))return new i.g1({cause:e});let a=e.walk(e=>r.some(t=>t.code===e.code));if(a){if(a.code===i.A7.code)return new i.A7({cause:e,data:a.data,message:a.details});if(a.code===i.pY.code)return new i.pY({cause:e});if(a.code===i.ZH.code)return new i.ZH({cause:e});if(a.code===i.wG.code)return new i.wG({cause:e});if(a.code===i.Zt.code)return new i.Zt({cause:e});if(a.code===i.oP.code)return new i.oP({cause:e});if(a.code===i.ln.code)return new i.ln({cause:e});if(a.code===i.U5.code)return new i.U5({cause:e});if(a.code===i.Kg.code)return new i.Kg({cause:e});if(a.code===i.WF.code)return new i.WF({cause:e});if(a.code===i.ei.code)return new i.ei({cause:e})}return new i.F0({cause:e})}},405810:(e,t,n)=>{"use strict";n.d(t,{W:()=>u});var i=n(797036),r=n(347220),a=n(690627),s=n(128897),o=n(675438),l=n(603181),c=n(721939),d=n(760483);async function u(e,t){let{account:n=e.account,chain:u=e.chain,...h}=t;if(!n)throw new r.T({docsPath:"/docs/actions/wallet/signTransaction"});let p=(0,i.J)(n);(0,c.c)({account:p,...t});let m=await (0,l.T)(e,d.T,"getChainId")({});null!==u&&(0,a.v)({currentChainId:m,chain:u});let y=u?.formatters||e.chain?.formatters,f=y?.transactionRequest?.format||o.Bv;return p.signTransaction?p.signTransaction({...h,chainId:m},{serializer:e.chain?.serializers?.transaction}):await e.request({method:"eth_signTransaction",params:[{...f(h,"signTransaction"),chainId:(0,s.cK)(m),from:p.address}]},{retryCount:0})}},406227:(e,t,n)=>{"use strict";n.d(t,{$Q:()=>v,GF:()=>w,S9:()=>_,Vx:()=>f,ZP:()=>l,dQ:()=>u,lZ:()=>d,m5:()=>p,mF:()=>y,pi:()=>m,qE:()=>h,yJ:()=>C,zl:()=>g});var i=n(804182),r=n(398805),a=n.n(r),s=Object.defineProperty,o=(e,t,n)=>((e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class l extends i.H{constructor(e){super(),this.opts=e,o(this,"protocol","wc"),o(this,"version",2)}}var c=Object.defineProperty;class d extends i.H{constructor(e,t){super(),this.core=e,this.logger=t,((e,t,n
72)=>((e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n))(this,"records",new Map)}}class u{constructor(e,t){this.logger=e,this.core=t}}class h extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class p extends i.H{constructor(e){super()}}class m{constructor(e,t,n,i){this.core=e,this.logger=t,this.name=n}}class y extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class f extends i.H{constructor(e,t){super(),this.core=e,this.logger=t}}class g{constructor(e,t,n){this.core=e,this.logger=t,this.store=n}}class w{constructor(e,t){this.projectId=e,this.logger=t}}class v{constructor(e,t,n){this.core=e,this.logger=t,this.telemetryEnabled=n}}var b=Object.defineProperty,x=(e,t,n)=>((e,t,n)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);a();class _{constructor(e){this.opts=e,x(this,"protocol","wc"),x(this,"version",2)}}r.EventEmitter;class C{constructor(e){this.client=e}}},414270:(e,t,n)=>{"use strict";n.d(t,{ZJ:()=>a});let i=new TextEncoder;Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[t,e.charCodeAt(0)]);let r={...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[e.charCodeAt(0),t])),61:0,45:62,95:63};function a(e){let t=e.replace(/=+$/,""),n=t.length,a=new Uint8Array(n+3);i.encodeInto(t+"===",a);for(let e=0,n=0;e<t.length;e+=4,n+=3){let t=(r[a[e]]<<18)+(r[a[e+1]]<<12)+(r[a[e+2]]<<6)+r[a[e+3]];a[n]=t>>16,a[n+1]=t>>
728&255,a[n+2]=255&t}return new Uint8Array(a.buffer,0,(n>>2)*3+(n%4&&n%4-1))}},443046:(e,t,n)=>{"use strict";n.d(t,{C:()=>s});var i=n(797036),r=n(347220),a=n(824413);async function s(e,t){let{account:n=e.account,domain:s,message:o,primaryType:l}=t;if(!n)throw new r.T({docsPath:"/docs/actions/wallet/signTypedData"});let c=(0,i.J)(n),d={EIP712Domain:(0,a.H4)({domain:s}),...t.types};if((0,a.$$)({domain:s,message:o,primaryType:l,types:d}),c.signTypedData)return c.signTypedData({domain:s,message:o,primaryType:l,types:d});let u=(0,a.v8)({domain:s,message:o,primaryType:l,types:d});return e.request({method:"eth_signTypedData_v4",params:[c.address,u]},{retryCount:0})}},443864:(e,t,n)=>{"use strict";n.d(t,{W:()=>s});var i=n(41481),r=n(678425),a=n(629484);async function s(e,t){return(0,r.H)(t)?(0,a.a)(e,t):await (0,i.W)(e,t)}},444245:(e,t,n)=>{var i=n(115743);e.exports=function(){var e=arguments,t=i(e[0]);return e.length<3?t:t.replace(e[1],e[2])}},444881:(e,t,n)=>{"use strict";n.d(t,{v:()=>s});var i=n(146364),r=n(678425),a=n(477469);async function s(e,t){return(0,r.H)(t)?(0,a.b)(e,t):(0,i.v)(e,t)}},445185:(e,t,n)=>{"use strict";n.d(t,{b:()=>a});var i=n(976168),r=n(11394);async function a(e,{hash:t}){let n=await e.request({method:"eth_getUserOperationReceipt",params:[t]},{dedupe:!0});if(!n)throw new i.oX({hash:t});return(0,r.u)(n)}},448398:(e,t,n)=>{"use strict";n.d(t,{Ej:()=>c,Fl:()=>h,HT:()=>s,di:()=>l,ii:()=>u,u:()=>d,uK:()=>o});var i=n(479656),r=(n(491803),n(77242));let a=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function s(e){return e instanceof Uint8Array?o(e):Array.isArray(e)?o(new Uint8Array(e)):e}function o(e,t={}){var n,i;let s="";for(let t=0;t<e.length;t++)s+=a[e[t]];let l=`0x${s}`;return"number"==typeof t.size?(r.Sl(l,t.size),n=l,i=t.size,r.eV(n,{dir:"right",size:i})):l}function l(e,t,n,i={}){let{strict:a}=i;r.kK(e,t);let s=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return a&&r.X(s,t,n),s}function c(e){return Math.ceil((e.length-2)/2)}i.C,i.C,i.C,i.C,i.C;class d extends i.C{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class u extends i.C{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class h extends i.C{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}},448953:(e,t,n)=>{"use strict";n.d(t,{F:()=>l});var i=n(270360),r=n(34138),a=n(700660),s=n(443046),o=n(603181);async function l({owner:e,address:t}){let n;if("type"in e&&"local"===e.type)return e;if("request"in e){if(!t)try{[t]=await e.request({method:"eth_requestAccounts"})}catch{[t]=await e.request({method:"eth_accounts"})}if(!t)throw Error("address is required");n=(0,i.F)({account:t,transport:(0,r.I)(e)})}return n||(n=e),(0,a.t)({address:n.account.address,signMessage:async({message:e})=>n.signMessage({message:e}),signTypedData:async e=>(0,o.T)(n,s.C,"signTypedData")(e),async signTransaction(e){throw Error("Smart account signer doesn't need to sign transactions")}})}},455535:(e,t,n)=>{"use strict";n.d(t,{L:()=>l});var i=n(356273),r=n(9514),a=n(34140),s=n(174562),o=n(73754);function l(e){let{key:t="public",name:n="Pimlico Bundler Client",entryPoint:l}=e;return(0,i.U)({...e,key:t,name:n,type:"pimlicoClient"}).extend(r.O).extend(a.a).extend((0,o.h)({entryPoint:{address:l?.address??s.oi,version:l?.version??"0.7"}}))}},458811:(e,t,n)=>{"use strict";n.d(t,{y:()=>c});var i=n(559482),r=n(999622),a=n(607186),s=n(787944),o=n(448953),l=n(488792);async function c(e){let{chainId:t,entryPoint:n,validAfter:c=0,validUntil:d=0,safe4337ModuleAddress:u,version:h,owners:p,signatures:m,account:y,...f}=e,{safe4337ModuleAddress:g}=(0,l.qc)(h,n.version,{safe4337ModuleAddress:u}),w={safe:f.sender,callData:f.callData,nonce:f.nonce,initCode:f.initCode??"0x",maxFeePerGas:f.maxFeePerGas,maxPriorityFeePerGas:f.maxPriorityFeePerGas,preVerificationGas:f.preVerificationGas,verificationGasLimit:f.verificationGasLimit,callGasLimit:f.callGasLimit,paymasterAndData:f.paymasterAndData??"0x",validAfter:c,validUntil:d,entryPoint:n.address};if("initCode"in f&&(w.paymasterAndData=f.paymasterAndData??"0x"),"factory"in f){if(f.factory&&f.factoryData&&(w.initCode=(0,i.aP)([f.factory,f.factoryData])),!f.sender)throw Error("Sender is required");w.paymasterAndData=(0,l.kC)({...f,sender:f.sender})}let v=[await (0,o.F)({owner:y})],b=[];m&&(b=(0,r.n)([{components:[{type:"address",name:"signer"},{type:"bytes",name:"data"}],name:"signatures",type:"tuple[]"}],m)[0]);let x=[...b,...await Promise.all(v.map(async e=>({signer:e.address,data:await e.signTypedData({domain:{chainId:t,verifyingContract:g},types:"0.6"===n.version?l.Lx:l.Cx,primaryType:"SafeOp",message:w})})))];
72if(x.length!==p.length)return(0,a.h)([{components:[{type:"address",name:"signer"},{type:"bytes",name:"data"}],name:"signatures",type:"tuple[]"}],[x]);x.sort((e,t)=>e.signer.toLowerCase().localeCompare(t.signer.toLowerCase()));let _=(0,i.xW)(x.map(e=>e.data));return(0,s.P)(["uint48","uint48","bytes"],[c,d,_])}},469080:(e,t,n)=>{"use strict";n.d(t,{c:()=>s});var i=n(788557),r=n(215757),a=n(477469);function s(e,t){let{abi:n,args:s,bytecode:o,deploymentType:l,salt:c,...d}=t,u=(0,r.m)({abi:n,args:s,bytecode:o,deploymentType:l,salt:c});return d.factoryDeps=d.factoryDeps||[],d.factoryDeps.includes(o)||d.factoryDeps.push(o),(0,a.b)(e,{...d,data:u,to:"create2"===l||"create2Account"===l?i.Lt:i.Z2})}},476316:(e,t,n)=>{var i=n(15196),r=n(799851),a=n(115743),s=n(604576);e.exports=function(e,t,n){return(e=a(e),void 0===(t=n?void 0:t))?r(e)?s(e):i(e):e.match(t)||[]}},477469:(e,t,n)=>{"use strict";n.d(t,{b:()=>p});var i=n(583665),r=n(548506),a=n(150876),s=n(847162),o=n(123103),l=n(73148),c=n(669568),d=n(735868),u=n(216146),h=n(443864);async function p(e,t){let{account:n=e.account,chain:p=e.chain}=t,m=n?(0,i.J)(n):e.account;if(!m)throw new o.T({docsPath:"/docs/actions/wallet/sendTransaction"});try{let n;(0,u.w)(t);let i=await (0,a.ft)(e,{...t,nonceManager:m.nonceManager,parameters:["gas","nonce","fees"]});null!==p&&(n=await (0,d.T)(e,r.T,"getChainId")({}),(0,l.v)({currentChainId:n,chain:p}));let o=await (0,h.W)(e,{...i,chainId:n});return await (0,d.T)(e,s.L,"sendRawTransaction")({serializedTransaction:o})}catch(e){throw(0,c.p)(e,{...t,account:m,chain:p})}}},479632:(e,t,n)=>{"use strict";n.d(t,{S:()=>r});var i=n(128897);async function r(e,{id:t}){await e.request({method:"wallet_switchEthereumChain",params:[{chainId:(0,i.cK)(t)}]},{retryCount:0})}},479656:(e,t,n)=>{"use strict";n.d(t,{C:()=>r});var i=n(510223);class r extends Error{constructor(e,t={}){let n=(()=>{if(t.cause instanceof r){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause?.message?t.cause.message:t.details})(),a=t.cause instanceof r&&t.cause.docsPath||t.docsPath,s=`https://oxlib.sh${a??""}`;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||a?["",n?`Details: ${n}`:void 0,a?`See: ${s}`:void 0]:[]].filter(e=>"string"==typeof e).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${i.r}`}),this.cause=t.cause,this.details=n,this.docs=s,this.docsPath=a,this.shortMessage=e}walk(e){return function e(t,n){return n?.(t)?t:t&&"object"==typeof t&&"cause"in t&&t.cause?e(t.cause,n):n?null:t}(this,e)}}},486200:(e,t,n)=>{"use strict";n.d(t,{HF:()=>eX,ny:()=>e1,xI:()=>nf,p:()=>te,df:()=>t$,CI:()=>tr});var i=n(755582),r=n(125281),a=n(89606),s=n(980594),o=n(842071);function l(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}let c=new r.FA("auth","Firebase",l()),d=new a.Vy("@firebase/auth");function u(e,...t){d.logLevel<=a.$b.ERROR&&d.error(`Auth (${i.MF}): ${e}`,...t)}function h(e,...t){throw f(e,...t)}function p(e,...t){return f(e,...t)}function m(e,t,n){let i=Object.assign(Object.assign({},l()),{[t]:n});return new r.FA("auth","Firebase",i).create(t,{appName:e.name})}function y(e){return m(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function f(e,...t){if("string"!=typeof e){let n=t[0],i=[...t.slice(1)];
72return i[0]&&(i[0].appName=e.name),e._errorFactory.create(n,...i)}return c.create(e,...t)}function g(e,t,...n){if(!e)throw f(t,...n)}function w(e){let t="INTERNAL ASSERTION FAILED: "+e;throw u(t),Error(t)}function v(){var e;return"undefined"!=typeof self&&(null==(e=self.location)?void 0:e.href)||""}function b(){var e;return"undefined"!=typeof self&&(null==(e=self.location)?void 0:e.protocol)||null}class x{constructor(e,t){var n;this.shortDelay=e,this.longDelay=t,n="Short delay should be less than long delay!",t>e||w(n),this.isMobile=(0,r.jZ)()||(0,r.lV)()}get(){return!("undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&("http:"===b()||"https:"===b()||(0,r.sr)()||"connection"in navigator))||navigator.onLine?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function _(e,t){var n,i;n=e.emulator,i="Emulator should always be set here",n||w(i);let{url:r}=e.emulator;return t?`${r}${t.startsWith("/")?t.slice(1):t}`:r}class C{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void w("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void w("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void w("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}let I={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-rec
72aptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"},E=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],T=new x(3e4,6e4);function A(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function S(e,t,n,i,a={}){return k(e,a,async()=>{let a={},s={};i&&("GET"===t?s=i:a={body:JSON.stringify(i)});let o=(0,r.Am)(Object.assign({key:e.config.apiKey},s)).slice(1),l=await e._getAdditionalHeaders();l["Content-Type"]="application/json",e.languageCode&&(l["X-Firebase-Locale"]=e.languageCode);let c=Object.assign({method:t,headers:l},a);return(0,r.c1)()||(c.referrerPolicy="no-referrer"),e.emulatorConfig&&(0,r.zJ)(e.emulatorConfig.host)&&(c.credentials="include"),C.fetch()(await j(e,e.config.apiHost,n,o),c)})}async function k(e,t,n){e._canInitEmulator=!1;let i=Object.assign(Object.assign({},I),t);try{let t=new O(e),r=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();let a=await r.json();if("needConfirmation"in a)throw N(e,"account-exists-with-different-credential",a);if(r.ok&&!("errorMessage"in a))return a;{let[t,n]=(r.ok?a.errorMessage:a.error.message).split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===t)throw N(e,"credential-already-in-use",a);if("EMAIL_EXISTS"===t)throw N(e,"email-already-in-use",a);if("USER_DISABLED"===t)throw N(e,"user-disabled",a);let s=i[t]||t.toLowerCase().replace(/[_\s]+/g,"-");if(n)throw m(e,s,n);h(e,s)}}catch(t){if(t instanceof r.g)throw t;h(e,"network-request-failed",{message:String(t)})}}async function P(e,t,n,i,r={}){let a=await S(e,t,n,i,r);return"mfaPendingCredential"in a&&h(e,"multi-factor-auth-required",{_serverResponse:a}),a}async function j(e,t,n,i){let r=`${t}${n}?${i}`,a=e.config.emulator?_(e.config,r):`${e.config.apiScheme}://${r}`;return E.includes(n)&&(await e._persistenceManagerAvailable,"COOKIE"===e._getPersistenceType())?e._getPersistence()._getFinalTarget(a).toString():a}class O{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(p(this.auth,"network-request-failed")),T.get())})}}function N(e,t,n){let i={appName:e.name};n.email&&(i.email=n.email),n.phoneNumber&&(i.phoneNumber=n.phoneNumber);let r=p(e,t,i);return r.customData._tokenResponse=n,r}function R(e){return void 0!==e&&void 0!==e.enterprise}class M{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],void 0===e.recaptchaKey)throw Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||0===this.recaptchaEnforcementState.length)return null;for(let t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)switch(t.enforcementState){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function D(e,t){return S(e,"GET","/v2/recaptchaConfig",A(e,t))}async function U(e,t){return S(e,"POST","/v1/accounts:delete",t)}async function L(e,t){return S(e,"POST","/v1/accounts:lookup",t)}function F(e){if(e)try{let t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}async function W(e,t=!1){let n=(0,r.Ku)(e),i=await n.getIdToken(t),a=B(i);g(a&&a.exp&&a.auth_time&&a.iat,n.auth,"internal-error");let s="object"==typeof a.firebase?a.firebase:void 0,o=null==s?void 0:s.sign_in_provider;return{claims:a,token:i,authTime:F($(a.auth_time)),issuedAtTime:F($(a.iat)),expirationTime:F($(a.exp)),signInProvider:o||null,signInSecondFactor:(null==s?void 0:s.sign_in_second_factor)||null}}function $(e){return 1e3*Number(e)}function B(e){let[t,n,i]=e.split(".");if(void 0===t||void 0===n||void 0===i)return u("JWT malformed, contained fewer than 3 sections"),null;try{let e=(0,r.u)(n);if(!e)return u("Failed to decode base64 JWT payload"),null;return JSON.parse(e)}catch(e){return u("Caught error parsing JWT payload as JSON",null==e?void 0:e.toString()),null}}function z(e){let t=B(e);return g(t,"internal-error"),g(void 0!==t.exp,"internal-error"),g(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}async function q(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof r.g&&function({code:e}){return"auth/user-disabled"===e||"auth/user-token-expired"===e}(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}class V{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(e){var t;if(!e)return this.errorBackoff=3e4,Math.max(0,(null!=(t=this.user.stsTokenManager.expirationTime)?t:0)-Date.now()-3e5);{let e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}}schedule(e=!1){if(!this.isRunning)return;let t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(null==e?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}class H{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=F(this.lastLoginAt),this.creationTime=F(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function G(e){var t,n,i;let r=e.auth,a=await e.getIdToken(),s=await q(e,L(r,{idToken:a}));g(null==s?void 0:s.users.length,r,"internal-error");let o=s.users[0];e._notifyReloadListener(o);let l=(null==(t=o.providerUserInfo)?void 0:t.length)?J(o.providerUserInfo):[],c=(n=e.providerData,i=l,[...n.filter(e=>!i.some(t=>t.providerId===e.providerId)),...i]),d=e.isAnonymous,u=!(e.email&&o.passwordHash)&&!(null==c?void 0:c.length);Object.assign(e,{uid:o.localId,displayName:o.displayName||null,photoURL:o.photoUrl||null,email:o.email||null,emailVerified:o.emailVerified||!1,phoneNumber:o.phoneNumber||null,tenantId:o.tenantId||null,providerData:c,metadata:new H(o.createdAt,o.lastLoginAt),isAnonymous:!!d&&u})}async function K(e){let t=(0,r.Ku)(e);await G(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function J(e){return e.map(e=>{var{providerId:t}=e,n=(0,s.__rest)(e,["providerId"]);
72return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})}async function Z(e,t){let n=await k(e,{},async()=>{let n=(0,r.Am)({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:i,apiKey:a}=e.config,s=await j(e,i,"/v1/token",`key=${a}`),o=await e._getAdditionalHeaders();o["Content-Type"]="application/x-www-form-urlencoded";let l={method:"POST",headers:o,body:n};return e.emulatorConfig&&(0,r.zJ)(e.emulatorConfig.host)&&(l.credentials="include"),C.fetch()(s,l)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function Y(e,t){return S(e,"POST","/v2/accounts:revokeToken",A(e,t))}class Q{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){g(e.idToken,"internal-error"),g(void 0!==e.idToken,"internal-error"),g(void 0!==e.refreshToken,"internal-error");let t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):z(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){g(0!==e.length,"internal-error");let t=z(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(g(this.refreshToken,e,"user-token-expired"),this.refreshToken)?(await this.refresh(e,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){let{accessToken:n,refreshToken:i,expiresIn:r}=await Z(e,t);this.updateTokensAndExpiration(n,i,Number(r))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){let{refreshToken:n,accessToken:i,expirationTime:r}=t,a=new Q;return n&&(g("string"==typeof n,"internal-error",{appName:e}),a.refreshToken=n),i&&(g("string"==typeof i,"internal-error",{appName:e}),a.accessToken=i),r&&(g("number"==typeof r,"internal-error",{appName:e}),a.expirationTime=r),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Q,this.toJSON())}_performRefresh(){return w("not implemented")}}function X(e,t){g("string"==typeof e||void 0===e,"internal-error",{appName:t})}class ee{constructor(e){var{uid:t,auth:n,stsTokenManager:i}=e,r=(0,s.__rest)(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new V(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=n,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=r.displayName||null,this.email=r.email||null,this.emailVerified=r.emailVerified||!1,this.phoneNumber=r.phoneNumber||null,this.photoURL=r.photoURL||null,this.isAnonymous=r.isAnonymous||!1,this.tenantId=r.tenantId||null,this.providerData=r.providerData?[...r.providerData]:[],this.metadata=new H(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){let t=await q(this,this.stsTokenManager.getToken(this.auth,e));return g(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return W(this,e)}reload(){return K(this)}_assign(e){this!==e&&(g(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(e=>Object.assign({},e)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){let t=new ee(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){g(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await G(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if((0,i.xZ)(this.auth.app))return Promise.reject(y(this.auth));let e=await this.getIdToken();return await q(this,U(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isA
72nonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var n,i,r,a,s,o,l,c;let d=null!=(n=t.displayName)?n:void 0,u=null!=(i=t.email)?i:void 0,h=null!=(r=t.phoneNumber)?r:void 0,p=null!=(a=t.photoURL)?a:void 0,m=null!=(s=t.tenantId)?s:void 0,y=null!=(o=t._redirectEventId)?o:void 0,f=null!=(l=t.createdAt)?l:void 0,w=null!=(c=t.lastLoginAt)?c:void 0,{uid:v,emailVerified:b,isAnonymous:x,providerData:_,stsTokenManager:C}=t;g(v&&C,e,"internal-error");let I=Q.fromJSON(this.name,C);g("string"==typeof v,e,"internal-error"),X(d,e.name),X(u,e.name),g("boolean"==typeof b,e,"internal-error"),g("boolean"==typeof x,e,"internal-error"),X(h,e.name),X(p,e.name),X(m,e.name),X(y,e.name),X(f,e.name),X(w,e.name);let E=new ee({uid:v,auth:e,email:u,emailVerified:b,displayName:d,isAnonymous:x,photoURL:p,phoneNumber:h,tenantId:m,stsTokenManager:I,createdAt:f,lastLoginAt:w});return _&&Array.isArray(_)&&(E.providerData=_.map(e=>Object.assign({},e))),y&&(E._redirectEventId=y),E}static async _fromIdTokenResponse(e,t,n=!1){let i=new Q;i.updateFromServerResponse(t);let r=new ee({uid:t.localId,auth:e,stsTokenManager:i,isAnonymous:n});return await G(r),r}static async _fromGetAccountInfoResponse(e,t,n){let i=t.users[0];g(void 0!==i.localId,"internal-error");let r=void 0!==i.providerUserInfo?J(i.providerUserInfo):[],a=!(i.email&&i.passwordHash)&&!(null==r?void 0:r.length),s=new Q;s.updateFromIdToken(n);let o=new ee({uid:i.localId,auth:e,stsTokenManager:s,isAnonymous:a});return Object.assign(o,{uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:r,metadata:new H(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!(null==r?void 0:r.length)}),o}}let et=new Map;function en(e){var t,n;t="Expected a class definition",e instanceof Function||w(t);let i=et.get(e);return i?(n="Instance stored in cache mismatched with class",i instanceof e||w(n)):(i=new e,et.set(e,i)),i}class ei{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){let t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}function er(e,t,n){return`firebase:${e}:${t}:${n}`}ei.type="NONE";class ea{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;let{config:i,name:r}=this.auth;this.fullUserKey=er(this.userKey,i.apiKey,r),this.fullPersistenceKey=er("persistence",i.apiKey,r),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){let e=await this.persistence._get(this.fullUserKey);if(!e)return null;if("string"==typeof e){let t=await L(this.auth,{idToken:e}).catch(()=>void 0);return t?ee._fromGetAccountInfoResponse(this.auth,t,e):null}return ee._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;let t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new ea(en(ei),e,n);let i=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e),r=i[0]||en(ei),a=er(n,e.config.apiKey,e.name),s=null;for(let n of t)try{let t=await n._get(a);if(t){let i;if("string"==typeof t){let n=await L(e,{idToken:t}).catch(()=>void 0);if(!n)break;i=await ee._fromGetAccountInfoResponse(e,n,t)}else i=ee._fromJSON(e,t);n!==r&&(s=i),r=n;break}}catch(e){}let o=i.filter(e=>e._shouldAllowMigration);return r._shouldAllowMigration&&o.length&&(r=o[0],s&&await r._set(a,s.toJSON()),await Promise.all(t.map(async e=>{if(e!==r)try{await e._remove(a)}catch(e){}}))),new ea(r,e,n)}}function es(e){let t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";{if(ed(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(eo(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(eh(t))return"Blackberry";if(ep(t))return"Webos";if(el(t))return"Safari";if((t.includes("chrome/")||ec(t))&&!t.includes("edge/"))return"Chrome";if(eu(t))return"Android";let n=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/);if((null==n?void 0:n.length)===2)return n[1]}return"Other"}function eo(e=(0,r.ZQ)()){return/firefox\//i.test(e)}function el(e=(0,r.ZQ)()){let t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function ec(e=(0,r.ZQ)()){return/crios\//i.test(e)}function ed(e=(0,r.ZQ)()){return/iemobile/i.test(e)}function eu(e=(0,r.ZQ)()){return/android/i.test(e)}function eh(e=(0,r.ZQ)()){return/blackberry/i.test(e)}function ep(e=(0,r.ZQ)()){return/webos/i.test(e)}function em(e=(0,r.ZQ)()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function ey(e=(0,r.ZQ)()){return em(e)||eu(e)||ep(e)||eh(e)||/windows phone/i.test(e)||ed(e)}function ef(e,t=[]){let n;switch(e){case"Browser":n=es((0,r.ZQ)());break;case"Worker":n=`${es((0,r.ZQ)())}-${e}`;break;default:n=e}let a=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${i.MF}/${a}`}class eg{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){let n=t=>new Promise((n,i)=>{try{let i=e(t);n(i)}catch(e){i(e)}});n.onAbort=t,this.queue.push(n);let i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;let t=[];try{for(let n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(e){for(let e of(t.reverse(),t))try{e()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==e?void 0:e.message})}}}async function ew(e,t={}){return S(e,"GET","/v2/passwordPolicy",A(e,t))}class ev{constructor(e){var t,n,i,r;let a=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=null!=(t=a.minPasswordLength)?t:6,a.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=a.maxPasswordLength),void 0!==a.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=a.containsLowercaseCharacter),void 0!==a.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=a.containsUppercaseCharacter),void 0!==a.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=a.containsNumericCharacter),void 0!==a.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=a.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=null!=(i=null==(n=e.allowedNonAlphanumericCharacters)?void 0:n.join(""))?i:"",this.forceUpgradeOnSignin=null!=(r=e.forceUpgradeOnSignin)&&r,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,n,i,r,a,s;let o={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,o),this.validatePasswordCharacterOptions(e,o),o.isValid&&
72(o.isValid=null==(t=o.meetsMinPasswordLength)||t),o.isValid&&(o.isValid=null==(n=o.meetsMaxPasswordLength)||n),o.isValid&&(o.isValid=null==(i=o.containsLowercaseLetter)||i),o.isValid&&(o.isValid=null==(r=o.containsUppercaseLetter)||r),o.isValid&&(o.isValid=null==(a=o.containsNumericCharacter)||a),o.isValid&&(o.isValid=null==(s=o.containsNonAlphanumericCharacter)||s),o}validatePasswordLengthOptions(e,t){let n=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),i&&(t.meetsMaxPasswordLength=e.length<=i)}validatePasswordCharacterOptions(e,t){let n;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(let i=0;i<e.length;i++)n=e.charAt(i),this.updatePasswordCharacterOptionsStatuses(t,n>="a"&&n<="z",n>="A"&&n<="Z",n>="0"&&n<="9",this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,i,r){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=n)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=i)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=r))}}class eb{constructor(e,t,n,i){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new e_(this),this.idTokenSubscription=new e_(this),this.beforeStateQueue=new eg(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=c,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=i.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=en(t)),this._initializationPromise=this.queue(async()=>{var n,i,r;if(!this._deleted){if(this.persistenceManager=await ea.create(this,e),null==(n=this._resolvePersistenceManagerAvailable)||n.call(this),!this._deleted){if(null==(i=this._popupRedirectResolver)?void 0:i._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(t),this.lastNotifiedUid=(null==(r=this.currentUser)?void 0:r.uid)||null,this._deleted||(this._isInitialized=!0)}}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;let e=await this.assertedPersistence.getCurrentUser();if(this.currentUser||e){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{let t=await L(this,{idToken:e}),n=await ee._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(n)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if((0,i.xZ)(this.app)){let e=this.app.settings.authIdToken;return e?new Promise(t=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(e).then(t,t))}):this.directlySetCurrentUser(null)}let n=await this.assertedPersistence.getCurrentUser(),r=n,a=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();let n=null==(t=this.redirectUser)?void 0:t._redirectEventId,i=null==r?void 0:r._redirectEventId,s=await this.tryRedirectSignIn(e);(!n||n===i)&&(null==s?void 0:s.user)&&(r=s.user,a=!0)}if(!r)return this.directlySetCurrentUser(null);
72if(!r._redirectEventId){if(a)try{await this.beforeStateQueue.runMiddleware(r)}catch(e){r=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return(g(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId)?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch(e){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await G(e)}catch(e){if((null==e?void 0:e.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;let e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if((0,i.xZ)(this.app))return Promise.reject(y(this));let t=e?(0,r.Ku)(e):null;return t&&g(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&g(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return(0,i.xZ)(this.app)?Promise.reject(y(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return(0,i.xZ)(this.app)?Promise.reject(y(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(en(e))})}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();let t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){let e=new ev(await ew(this));null===this.tenantId?this._projectPasswordPolicy=e:this._tenantPasswordPolicies[this.tenantId]=e}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new r.FA("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{let n=this.onAuthStateChanged(()=>{n(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){let t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()};null!=this.tenantId&&(t.tenantId=this.tenantId),await Y(this,t)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null==(e=this._currentUser)?void 0:e.toJSON()}}async _setRedirectUser(e,t){let n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){let t=e&&en(e)||this._popupRedirectResolver;g(t,this,"argument-error"),this.redirectPersistenceManager=await ea.create(this,[en(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,n;return(this._isInitialized&&await this.queue(async()=>{}),(null==(t=this._currentUser)?void 0:t._redirectEventId)===e)?this._currentUser:(null==(n=this.redirectUser)?void 0:n._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);let n=null!=(t=null==(e=this.currentUser)?void 0:e.uid)?t:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,i){if(this._deleted)return()=>{};let r="function"==typeof t?t:t.next.bind(t),a=!1,s=this._isInitialized?Promise.resolve():this._initializationPromise;if(g(s,this,"internal-error"),s.then(()=>{a||r(this.currentUser)}),"function"==typeof t){let r=e.addObserver(t,n,i);return()=>{a=!0,r()}}{let n=e.addObserver(t);return()=>{a=!0,n()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return g(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=ef(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;let t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);let n=await (null==(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))?void 0:e.getHeartbeatsHeader());n&&(t["X-Firebase-Client"]=n);let i=await this._getAppCheckToken();return i&&(t["X-Firebase-AppCheck"]=i),t}async _getAppCheckToken(){var e;if((0,i.xZ)(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let t=await (null==(e=this.appCheckServiceProvider.getImmediate({optional:!0}))?void 0:e.getToken());return(null==t?void 0:t.error)&&function(e,...t){d.logLevel<=a.$b.WARN&&d.warn(`Auth (${i.MF}): ${e}`,...t)}(`Error while retrieving App Check token: ${t.error}`),null==t?void 0:t.token}}function ex(e){return(0,r.Ku)(e)}class e_{constructor(e){this.auth=e,this.observer=null,this.addObserver=(0,r.tD)(e=>this.observer=e)}get next(){return g(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let eC={async loadJS(){throw Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function eI(e){return`__${e}${Math.floor(1e6*Math.random())}`}class eE{constructor(){this.enterprise=new eT}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class eT{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}let eA="NO_RECAPTCHA";class eS{constructor(e){this.type="recaptcha-enterprise",this.auth=ex(e)}async verify(e="verify",t=!1){async function n(e){if(!t){if(null==e.tenantId&&null!=e._agentRecaptchaConfig)return e._agentRecaptchaConfig.siteKey;if(null!=e.tenantId&&void 0!==e._tenantRecaptchaConfigs[e.tenantId])return e._tenantRecaptchaConfigs[e.tenantId].siteKey}return new Promise(async(t,n)=>
72{D(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(i=>{if(void 0===i.recaptchaKey)n(Error("recaptcha Enterprise site key undefined"));else{let n=new M(i);return null==e.tenantId?e._agentRecaptchaConfig=n:e._tenantRecaptchaConfigs[e.tenantId]=n,t(n.siteKey)}}).catch(e=>{n(e)})})}function i(t,n,i){let r=window.grecaptcha;R(r)?r.enterprise.ready(()=>{r.enterprise.execute(t,{action:e}).then(e=>{n(e)}).catch(()=>{n(eA)})}):i(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new eE().execute("siteKey",{action:"verify"}):new Promise((e,r)=>{n(this.auth).then(n=>{if(!t&&R(window.grecaptcha))i(n,e,r);else{var a;if("undefined"==typeof window)return void r(Error("RecaptchaVerifier is only supported in browser"));let t=eC.recaptchaEnterpriseScript;0!==t.length&&(t+=n),(a=t,eC.loadJS(a)).then(()=>{i(n,e,r)}).catch(e=>{r(e)})}}).catch(e=>{r(e)})})}}async function ek(e,t,n,i=!1,r=!1){let a,s=new eS(e);if(r)a=eA;else try{a=await s.verify(n)}catch(e){a=await s.verify(n,!0)}let o=Object.assign({},t);if("mfaSmsEnrollment"===n||"mfaSmsSignIn"===n){if("phoneEnrollmentInfo"in o){let e=o.phoneEnrollmentInfo.phoneNumber,t=o.phoneEnrollmentInfo.recaptchaToken;Object.assign(o,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:t,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in o){let e=o.phoneSignInInfo.recaptchaToken;Object.assign(o,{phoneSignInInfo:{recaptchaToken:e,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return o}return i?Object.assign(o,{captchaResp:a}):Object.assign(o,{captchaResponse:a}),Object.assign(o,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(o,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),o}async function eP(e,t,n,i,r){var a,s;if("EMAIL_PASSWORD_PROVIDER"===r)if(null==(a=e._getRecaptchaConfig())||!a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER"))return i(e,t).catch(async r=>{if("auth/missing-recaptcha-token"!==r.code)return Promise.reject(r);{console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);let r=await ek(e,t,n,"getOobCode"===n);return i(e,r)}});else{let r=await ek(e,t,n,"getOobCode"===n);return i(e,r)}if("PHONE_PROVIDER"!==r)return Promise.reject(r+" provider is not supported.");if(null==(s=e._getRecaptchaConfig())?void 0:s.isProviderEnabled("PHONE_PROVIDER")){let r=await ek(e,t,n);return i(e,r).catch(async r=>{var a;if((null==(a=e._getRecaptchaConfig())?void 0:a.getProviderEnforcementState("PHONE_PROVIDER"))==="AUDIT"&&("auth/missing-recaptcha-token"===r.code||"auth/invalid-app-credential"===r.code)){console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${n} flow.`);let r=await ek(e,t,n,!1,!0);return i(e,r)}return Promise.reject(r)})}{let r=await ek(e,t,n,!1,!0);return i(e,r)}}async function ej(e){let t=ex(e),n=new M(await D(t,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}));null==t.tenantId?t._agentRecaptchaConfig=n:t._tenantRecaptchaConfigs[t.tenantId]=n,n.isAnyProviderEnabled()&&new eS(t).verify()}function eO(e){let t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function eN(e){if(!e)return null;let t=Number(e);return isNaN(t)?null:t}class eR{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return w("not implemented")}_getIdTokenResponse(e){return w("not implemented")}_linkToIdToken(e,t){return w("not implemented")}_getReauthenticationResolver(e){return w("not implemented")}}async function eM(e,t){return S(e,"POST","/v1/accounts:signUp",t)}async function eD(e,t){return P(e,"POST","/v1/accounts:signInWithPassword",A(e,t))}async function eU(e,t){return P(e,"POST","/v1/accounts:signInWithEmailLink",A(e,t))}async function eL(e,t){return P(e,"POST","/v1/accounts:signInWithEmailLink",A(e,t))}class eF extends eR{constructor(e,t,n,i=null){super("password",n),this._email=e,this._password=t,this._tenantId=i}static _fromEmailAndPassword(e,t){return new eF(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new eF(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){let t="string"==typeof e?JSON.parse(e):e;if((null==t?void 0:t.email)&&(null==t?void 0:t.password)){if("password"===t.signInMethod)return this._fromEmailAndPassword(t.email,t.password);else if("emailLink"===t.signInMethod)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":return eP(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",eD,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return eU(e,{email:this._email,oobCode:this._password});default:h(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return eP(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",eM,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return eL(e,{idToken:t,email:this._email,oobCode:this._password});default:h(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function eW(e,t){return P(e,"POST","/v1/accounts:signInWithIdp",A(e,t))}class e$ extends eR{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){let t=new e$(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&
72(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):h("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){let t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:i}=t,r=(0,s.__rest)(t,["providerId","signInMethod"]);if(!n||!i)return null;let a=new e$(n,i);return a.idToken=r.idToken||void 0,a.accessToken=r.accessToken||void 0,a.secret=r.secret,a.nonce=r.nonce,a.pendingToken=r.pendingToken||null,a}_getIdTokenResponse(e){return eW(e,this.buildRequest())}_linkToIdToken(e,t){let n=this.buildRequest();return n.idToken=t,eW(e,n)}_getReauthenticationResolver(e){let t=this.buildRequest();return t.autoCreate=!1,eW(e,t)}buildRequest(){let e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{let t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=(0,r.Am)(t)}return e}}async function eB(e,t){return S(e,"POST","/v1/accounts:sendVerificationCode",A(e,t))}async function ez(e,t){return P(e,"POST","/v1/accounts:signInWithPhoneNumber",A(e,t))}async function eq(e,t){let n=await P(e,"POST","/v1/accounts:signInWithPhoneNumber",A(e,t));if(n.temporaryProof)throw N(e,"account-exists-with-different-credential",n);return n}let eV={USER_NOT_FOUND:"user-not-found"};async function eH(e,t){return P(e,"POST","/v1/accounts:signInWithPhoneNumber",A(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),eV)}class eG extends eR{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new eG({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new eG({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return ez(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return eq(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return eH(e,this._makeVerificationRequest())}_makeVerificationRequest(){let{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:i}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:i}}toJSON(){let e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){"string"==typeof e&&(e=JSON.parse(e));let{verificationId:t,verificationCode:n,phoneNumber:i,temporaryProof:r}=e;return n||t||i||r?new eG({verificationId:t,verificationCode:n,phoneNumber:i,temporaryProof:r}):null}}class eK{constructor(e){var t,n,i,a,s,o;let l=(0,r.I9)((0,r.hp)(e)),c=null!=(t=l.apiKey)?t:null,d=null!=(n=l.oobCode)?n:null,u=function(e){switch(e){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!=(i=l.mode)?i:null);g(c&&d&&u,"argument-error"),this.apiKey=c,this.operation=u,this.code=d,this.continueUrl=null!=(a=l.continueUrl)?a:null,this.languageCode=null!=(s=l.lang)?s:null,this.tenantId=null!=(o=l.tenantId)?o:null}static parseLink(e){let t=function(e){let t=(0,r.I9)((0,r.hp)(e)).link,n=t?(0,r.I9)((0,r.hp)(t)).deep_link_id:null,i=(0,r.I9)((0,r.hp)(e)).deep_link_id;return(i?(0,r.I9)((0,r.hp)(i)).link:null)||i||n||t||e}(e);try{return new eK(t)}catch(e){return null}}}class eJ{constructor(){this.providerId=eJ.PROVIDER_ID}static credential(e,t){return eF._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){let n=eK.parseLink(t);return g(n,"argument-error"),eF._fromEmailAndCode(e,n.code,n.tenantId)}}eJ.PROVIDER_ID="password",eJ.EMAIL_PASSWORD_SIGN_IN_METHOD="password",eJ.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class eZ{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class eY extends eZ{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class eQ extends eY{constructor(){super("facebook.com")}static credential(e){return e$._fromParams({providerId:eQ.PROVIDER_ID,signInMethod:eQ.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return eQ.credentialFromTaggedObject(e)}static credentialFromError(e){return eQ.credentialFromTaggedObject(e.customData||{})}
72static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return eQ.credential(e.oauthAccessToken)}catch(e){return null}}}eQ.FACEBOOK_SIGN_IN_METHOD="facebook.com",eQ.PROVIDER_ID="facebook.com";class eX extends eY{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return e$._fromParams({providerId:eX.PROVIDER_ID,signInMethod:eX.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return eX.credentialFromTaggedObject(e)}static credentialFromError(e){return eX.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return eX.credential(t,n)}catch(e){return null}}}eX.GOOGLE_SIGN_IN_METHOD="google.com",eX.PROVIDER_ID="google.com";class e0 extends eY{constructor(){super("github.com")}static credential(e){return e$._fromParams({providerId:e0.PROVIDER_ID,signInMethod:e0.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return e0.credentialFromTaggedObject(e)}static credentialFromError(e){return e0.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return e0.credential(e.oauthAccessToken)}catch(e){return null}}}e0.GITHUB_SIGN_IN_METHOD="github.com",e0.PROVIDER_ID="github.com";class e1 extends eY{constructor(){super("twitter.com")}static credential(e,t){return e$._fromParams({providerId:e1.PROVIDER_ID,signInMethod:e1.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return e1.credentialFromTaggedObject(e)}static credentialFromError(e){return e1.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return e1.credential(t,n)}catch(e){return null}}}e1.TWITTER_SIGN_IN_METHOD="twitter.com",e1.PROVIDER_ID="twitter.com";class e2{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,i=!1){return new e2({user:await ee._fromIdTokenResponse(e,n,i),providerId:e3(n),_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){return await e._updateTokensIfNecessary(n,!0),new e2({user:e,providerId:e3(n),_tokenResponse:n,operationType:t})}}function e3(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}class e4 extends r.g{constructor(e,t,n,i){var r;super(t.code,t.message),this.operationType=n,this.user=i,Object.setPrototypeOf(this,e4.prototype),this.customData={appName:e.name,tenantId:null!=(r=e.tenantId)?r:void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,i){return new e4(e,t,n,i)}}function e5(e,t,n,i){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{if("auth/multi-factor-auth-required"===n.code)throw e4._fromErrorAndOperation(e,n,t,i);throw n})}async function e6(e,t,n=!1){let i=await q(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return e2._forOperation(e,"link",i)}async function e8(e,t,n=!1){let{auth:r}=e;if((0,i.xZ)(r.app))return Promise.reject(y(r));let a="reauthenticate";try{let i=await q(e,e5(r,a,t,e),n);g(i.idToken,r,"internal-error");let s=B(i.idToken);g(s,r,"internal-error");let{sub:o}=s;return g(e.uid===o,r,"user-mismatch"),e2._forOperation(e,a,i)}catch(e){throw(null==e?void 0:e.code)==="auth/user-not-found"&&h(r,"user-mismatch"),e}}async function e7(e,t,n=!1){if((0,i.xZ)(e.app))return Promise.reject(y(e));let r="signIn",a=await e5(e,r,t),s=await e2._fromIdTokenResponse(e,r,a);return n||await e._updateCurrentUser(s.user),s}async function e9(e,t){return P(e,"POST","/v1/accounts:signInWithCustomToken",A(e,t))}async function te(e,t){if((0,i.xZ)(e.app))return Promise.reject(y(e));let n=ex(e),r=await e9(n,{token:t,returnSecureToken:!0}),a=await e2._fromIdTokenResponse(n,"signIn",r);return await n._updateCurrentUser(a.user),a}class tt{constructor(e,t){this.factorId=e,this.uid=t.mfaEnrollmentId,this.enrollmentTime=new Date(t.enrolledAt).toUTCString(),this.displayName=t.displayName}static _fromServerResponse(e,t){return"phoneInfo"in t?tn._fromServerResponse(e,t):"totpInfo"in t?ti._fromServerResponse(e,t):h(e,"internal-error")}}class tn extends tt{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new tn(t)}}class ti extends tt{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new ti(t)}}function tr(e){return(0,r.Ku)(e).signOut()}function ta(e,t){return S(e,"POST","/v2/accounts/mfaEnrollment:start",A(e,t))}new WeakMap;let ts="__sak";class to{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{if(!this.storage)return Promise.resolve(!1);return this.storage.setItem(ts,"1"),this.storage.removeItem(ts),Promise.resolve(!0)}catch(e){return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){let t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}class tl extends to{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=ey(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(let t of Object.keys(this.listeners)){let n=this.storage.getItem(t),i=this.localCache[t];n!==i&&e(t,i,n)}}
72onStorageEvent(e,t=!1){if(!e.key)return void this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)});let n=e.key;t?this.detachListener():this.stopPolling();let i=()=>{let e=this.storage.getItem(n);(t||this.localCache[n]!==e)&&this.notifyListeners(n,e)},a=this.storage.getItem(n);(0,r.lT)()&&10===document.documentMode&&a!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,10):i()}notifyListeners(e,t){this.localCache[e]=t;let n=this.listeners[e];if(n)for(let e of Array.from(n))e(t?JSON.parse(t):t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:n}),!0)})},1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){let t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}function tc(e){var t,n;let i=e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),r=RegExp(`${i}=([^;]+)`);return null!=(n=null==(t=document.cookie.match(r))?void 0:t[1])?n:null}function td(e){let t="http:"===window.location.protocol;return`${t?"__dev_":"__HOST-"}FIREBASE_${e.split(":")[3]}`}tl.type="LOCAL";class tu{constructor(){this.type="COOKIE",this.listenerUnsubscribes=new Map}_getFinalTarget(e){let t=new URL(`${window.location.origin}/__cookies__`);return t.searchParams.set("finalTarget",e),t}async _isAvailable(){var e;return("boolean"!=typeof isSecureContext||!!isSecureContext)&&"undefined"!=typeof navigator&&"undefined"!=typeof document&&(null==(e=navigator.cookieEnabled)||e)}async _set(e,t){}async _get(e){if(!this._isAvailable())return null;let t=td(e);if(window.cookieStore){let e=await window.cookieStore.get(t);return null==e?void 0:e.value}return tc(t)}async _remove(e){if(!this._isAvailable()||!await this._get(e))return;let t=td(e);document.cookie=`${t}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;Priority=High`,await fetch("/__cookies__",{method:"DELETE"}).catch(()=>void 0)}_addListener(e,t){if(!this._isAvailable())return;let n=td(e);if(window.cookieStore){let e=e=>{let i=e.changed.find(e=>e.name===n);i&&t(i.value),e.deleted.find(e=>e.name===n)&&t(null)};return this.listenerUnsubscribes.set(t,()=>window.cookieStore.removeEventListener("change",e)),window.cookieStore.addEventListener("change",e)}let i=tc(n),r=setInterval(()=>{let e=tc(n);e!==i&&(t(e),i=e)},1e3);this.listenerUnsubscribes.set(t,()=>clearInterval(r))}_removeListener(e,t){let n=this.listenerUnsubscribes.get(t);n&&(n(),this.listenerUnsubscribes.delete(t))}}tu.type="COOKIE";class th extends to{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}th.type="SESSION";class tp{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){let t=this.receivers.find(t=>t.isListeningto(e));if(t)return t;let n=new tp(e);return this.receivers.push(n),n}isListeningto(e){return this.eventTarget===e}async handleEvent(e){let{eventId:t,eventType:n,data:i}=e.data,r=this.handlersMap[n];if(!(null==r?void 0:r.size))return;e.ports[0].postMessage({status:"ack",eventId:t,eventType:n});let a=Array.from(r).map(async t=>t(e.origin,i)),s=await Promise.all(a.map(async e=>{try{let t=await e;return{fulfilled:!0,value:t}}catch(e){return{fulfilled:!1,reason:e}}}));e.ports[0].postMessage({status:"done",eventId:t,eventType:n,response:s})}_subscribe(e,t){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),t&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function tm(e="",t=10){let n="";for(let e=0;e<t;e++)n+=Math.floor(10*Math.random());return e+n}tp.receivers=[];class ty{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,n=50){let i,r,a="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!a)throw Error("connection_unavailable");return new Promise((s,o)=>{let l=tm("",20);a.port1.start();let c=setTimeout(()=>{o(Error("unsupported_event"))},n);r={messageChannel:a,onMessage(e){if(e.data.eventId===l)switch(e.data.status){case"ack":clearTimeout(c),i=setTimeout(()=>{o(Error("timeout"))},3e3);break;case"done":clearTimeout(i),s(e.data.response);break;default:clearTimeout(c),clearTimeout(i),o(Error("invalid_response"))}}},this.handlers.add(r),a.port1.addEventListener("message",r.onMessage),this.target.postMessage({eventType:e,eventId:l,data:t},[a.port2])}).finally(()=>{r&&this.removeMessageHandler(r)})}}function tf(){return window}
72function tg(){return void 0!==tf().WorkerGlobalScope&&"function"==typeof tf().importScripts}async function tw(){if(!(null==navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}}let tv="firebaseLocalStorageDb",tb="firebaseLocalStorage",tx="fbase_key";class t_{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function tC(e,t){return e.transaction([tb],t?"readwrite":"readonly").objectStore(tb)}function tI(){let e=indexedDB.open(tv,1);return new Promise((t,n)=>{e.addEventListener("error",()=>{n(e.error)}),e.addEventListener("upgradeneeded",()=>{let t=e.result;try{t.createObjectStore(tb,{keyPath:tx})}catch(e){n(e)}}),e.addEventListener("success",async()=>{let n=e.result;n.objectStoreNames.contains(tb)?t(n):(n.close(),await new t_(indexedDB.deleteDatabase(tv)).toPromise(),t(await tI()))})})}async function tE(e,t,n){return new t_(tC(e,!0).put({[tx]:t,value:n})).toPromise()}async function tT(e,t){let n=tC(e,!1).get(t),i=await new t_(n).toPromise();return void 0===i?null:i.value}function tA(e,t){return new t_(tC(e,!0).delete(t)).toPromise()}class tS{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db||(this.db=await tI()),this.db}async _withRetries(e){let t=0;for(;;)try{let t=await this._openDb();return await e(t)}catch(e){if(t++>3)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return tg()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=tp._getInstance(tg()?self:null),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await tw(),!this.activeServiceWorker)return;this.sender=new ty(this.activeServiceWorker);let n=await this.sender._send("ping",{},800);n&&(null==(e=n[0])?void 0:e.fulfilled)&&(null==(t=n[0])?void 0:t.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null==(t=null==navigator?void 0:navigator.serviceWorker)?void 0:t.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(e){}}async _isAvailable(){try{if(!indexedDB)return!1;let e=await tI();return await tE(e,ts,"1"),await tA(e,ts),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>tE(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){let t=await this._withRetries(t=>tT(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>tA(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){let e=await this._withRetries(e=>new t_(tC(e,!1).getAll()).toPromise());if(!e||0!==this.pendingWrites)return[];let t=[],n=new Set;if(0!==e.length)for(let{fbase_key:i,value:r}of e)n.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(r)&&(this.notifyListeners(i,r),t.push(i));for(let e of Object.keys(this.localCache))this.localCache[e]&&!n.has(e)&&(this.notifyListeners(e,null),t.push(e));return t}notifyListeners(e,t){this.localCache[e]=t;let n=this.listeners[e];if(n)for(let e of Array.from(n))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}function tk(e,t){return S(e,"POST","/v2/accounts/mfaSignIn:start",A(e,t))}tS.type="LOCAL",eI("rcb"),new x(3e4,6e4);let tP="recaptcha";async function tj(e,t,n){var i;if(!e._getRecaptchaConfig())try{await ej(e)}catch(e){console.log("Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.")}try{let r;if(r="string"==typeof t?{phoneNumber:t}
72:t,"session"in r){let t=r.session;if("phoneNumber"in r){g("enroll"===t.type,e,"internal-error");let i={idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:r.phoneNumber,clientType:"CLIENT_TYPE_WEB"}},a=async(e,t)=>{if(t.phoneEnrollmentInfo.captchaResponse===eA){g((null==n?void 0:n.type)===tP,e,"argument-error");let i=await tO(e,t,n);return ta(e,i)}return ta(e,t)},s=eP(e,i,"mfaSmsEnrollment",a,"PHONE_PROVIDER");return(await s.catch(e=>Promise.reject(e))).phoneSessionInfo.sessionInfo}{g("signin"===t.type,e,"internal-error");let a=(null==(i=r.multiFactorHint)?void 0:i.uid)||r.multiFactorUid;g(a,e,"missing-multi-factor-info");let s={mfaPendingCredential:t.credential,mfaEnrollmentId:a,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}},o=async(e,t)=>{if(t.phoneSignInInfo.captchaResponse===eA){g((null==n?void 0:n.type)===tP,e,"argument-error");let i=await tO(e,t,n);return tk(e,i)}return tk(e,t)},l=eP(e,s,"mfaSmsSignIn",o,"PHONE_PROVIDER");return(await l.catch(e=>Promise.reject(e))).phoneResponseInfo.sessionInfo}}{let t={phoneNumber:r.phoneNumber,clientType:"CLIENT_TYPE_WEB"},i=async(e,t)=>{if(t.captchaResponse===eA){g((null==n?void 0:n.type)===tP,e,"argument-error");let i=await tO(e,t,n);return eB(e,i)}return eB(e,t)},a=eP(e,t,"sendVerificationCode",i,"PHONE_PROVIDER");return(await a.catch(e=>Promise.reject(e))).sessionInfo}}finally{null==n||n._reset()}}async function tO(e,t,n){g(n.type===tP,e,"argument-error");let i=await n.verify();g("string"==typeof i,e,"argument-error");let r=Object.assign({},t);if("phoneEnrollmentInfo"in r){let e=r.phoneEnrollmentInfo.phoneNumber,t=r.phoneEnrollmentInfo.captchaResponse,n=r.phoneEnrollmentInfo.clientType,a=r.phoneEnrollmentInfo.recaptchaVersion;return Object.assign(r,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:i,captchaResponse:t,clientType:n,recaptchaVersion:a}}),r}if(!("phoneSignInInfo"in r))return Object.assign(r,{recaptchaToken:i}),r;{let e=r.phoneSignInInfo.captchaResponse,t=r.phoneSignInInfo.clientType,n=r.phoneSignInInfo.recaptchaVersion;return Object.assign(r,{phoneSignInInfo:{recaptchaToken:i,captchaResponse:e,clientType:t,recaptchaVersion:n}}),r}}class tN{constructor(e){this.providerId=tN.PROVIDER_ID,this.auth=ex(e)}verifyPhoneNumber(e,t){return tj(this.auth,e,(0,r.Ku)(t))}static credential(e,t){return eG._fromVerification(e,t)}static credentialFromResult(e){return tN.credentialFromTaggedObject(e)}static credentialFromError(e){return tN.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{phoneNumber:t,temporaryProof:n}=e;return t&&n?eG._fromTokenResponse(t,n):null}}function tR(e,t){return t?en(t):(g(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}tN.PROVIDER_ID="phone",tN.PHONE_SIGN_IN_METHOD="phone";class tM extends eR{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return eW(e,this._buildIdpRequest())}_linkToIdToken(e,t){return eW(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return eW(e,this._buildIdpRequest())}_buildIdpRequest(e){let t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function tD(e){return e7(e.auth,new tM(e),e.bypassAuthState)}function tU(e){let{auth:t,user:n}=e;return g(n,t,"internal-error"),e8(n,new tM(e),e.bypassAuthState)}async function tL(e){let{auth:t,user:n}=e;return g(n,t,"internal-error"),e6(n,new tM(e),e.bypassAuthState)}class tF{constructor(e,t,n,i,r=!1){this.auth=e,this.resolver=n,this.user=i,this.bypassAuthState=r,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}})}async onAuthEvent(e){let{urlResponse:t,sessionId:n,postBody:i,tenantId:r,error:a,type:s}=e;if(a)return void this.reject(a);let o={auth:this.auth,requestUri:t,sessionId:n,tenantId:r||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(s)(o))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return tD;case"linkViaPopup":case"linkViaRedirect":return tL;case"reauthViaPopup":case"reauthViaRedirect":return tU;default:h(this.auth,"internal-error")}}resolve(e){var t,n;t=this.pendingPromise,n="Pending promise was never set",t||w(n),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){var t,n;t=this.pendingPromise,n="Pending promise was never set",t||w(n),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}let tW=new x(2e3,1e4);async function t$(e,t,n){if((0,i.xZ)(e.app))return Promise.reject(p(e,"operation-not-supported-in-this-environment"));let r=ex(e);if(!(t instanceof eZ))throw eZ.name!==t.constructor.name&&h(e,"argument-error"),m(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`);let a=tR(r,n);return new tB(r,"signInViaPopup",t,a).executeNotNull()}class tB extends tF{constructor(e,t,n,i,r){super(e,t,i,r),this.provider=n,this.authWindow=null,this.pollId=null,tB.currentPopupAction&&tB.currentPopupAction.cancel(),tB.currentPopupAction=this}async executeNotNull(){let e=await this.execute();return g(e,this.auth,"internal-error"),e}async onExecution(){var e,t;e=1===this.filter.length,t="Popup operations only handle one event",e||w(t);let n=tm();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],n),this.authWindow.associatedEvent=n,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(p(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return(null==(e=this.authWindow)?void 0:e.associatedEvent)||null}cancel(){this.reject(p(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,tB.currentPopupAction=null}pollUserCancellation(){let e=()=>{var t,n;if(null==(n=null==(t=this.authWindow)?void 0:t.window)?void 0:n.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(p(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,tW.get())};e()}}tB.currentPopupAction=null;let tz=new Map;class tq extends tF{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=tz.get(this.auth._key());if(!e){try{let t=await tV(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}tz.set(this.auth._key(),e)}return this.bypassAuthState||tz.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);
72if("unknown"===e.type)return void this.resolve(null);if(e.eventId){let t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function tV(e,t){var n;let i=er("pendingRedirect",(n=t).config.apiKey,n.name),r=en(e._redirectPersistence);if(!await r._isAvailable())return!1;let a=await r._get(i)==="true";return await r._remove(i),a}function tH(e,t){tz.set(e._key(),t)}async function tG(e,t,n=!1){if((0,i.xZ)(e.app))return Promise.reject(y(e));let r=ex(e),a=tR(r,t),s=new tq(r,a,n),o=await s.execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,t)),o}class tK{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return tZ(e);default:return!1}}(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var n;if(e.error&&!tZ(e)){let i=(null==(n=e.error.code)?void 0:n.split("auth/")[1])||"internal-error";t.onError(p(this.auth,i))}else t.onAuthEvent(e)}isEventForConsumer(e,t){let n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(tJ(e))}saveEventToCache(e){this.cachedEventUids.add(tJ(e)),this.lastProcessedEventTime=Date.now()}}function tJ(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function tZ({type:e,error:t}){return"unknown"===e&&(null==t?void 0:t.code)==="auth/no-auth-event"}async function tY(e,t={}){return S(e,"GET","/v1/projects",t)}let tQ=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,tX=/^https?/;async function t0(e){if(e.config.emulator)return;let{authorizedDomains:t}=await tY(e);for(let e of t)try{if(function(e){let t=v(),{protocol:n,hostname:i}=new URL(t);if(e.startsWith("chrome-extension://")){let r=new URL(e);return""===r.hostname&&""===i?"chrome-extension:"===n&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===n&&r.hostname===i}if(!tX.test(n))return!1;if(tQ.test(e))return i===e;let r=e.replace(/\./g,"\\.");return RegExp("^(.+\\."+r+"|"+r+")$","i").test(i)}(e))return}catch(e){}h(e,"unauthorized-domain")}let t1=new x(3e4,6e4);function t2(){let e=tf().___jsl;if(null==e?void 0:e.H){for(let t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}}let t3=null,t4=new x(5e3,15e3),t5={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},t6=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function t8(e){let t=await (t3=t3||new Promise((t,n)=>{var i,r,a,s;function o(){t2(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{t2(),n(p(e,"network-request-failed"))},timeout:t1.get()})}if(null==(r=null==(i=tf().gapi)?void 0:i.iframes)?void 0:r.Iframe)t(gapi.iframes.getContext());else if(null==(a=tf().gapi)?void 0:a.load)o();else{let t=eI("iframefcb");return tf()[t]=()=>{gapi.load?o():n(p(e,"network-request-failed"))},(s=`${eC.gapiScript}?onload=${t}`,eC.loadJS(s)).catch(e=>n(e))}}).catch(e=>{throw t3=null,e})),n=tf().gapi;return g(n,e,"internal-error"),t.open({where:document.body,url:function(e){let t=e.config;g(t.authDomain,e,"auth-domain-config-required");let n=t.emulator?_(t,"emulator/auth/iframe"):`https://${e.config.authDomain}
72/__/auth/iframe`,a={apiKey:t.apiKey,appName:e.name,v:i.MF},s=t6.get(e.config.apiHost);s&&(a.eid=s);let o=e._getFrameworks();return o.length&&(a.fw=o.join(",")),`${n}?${(0,r.Am)(a).slice(1)}`}(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:t5,dontclear:!0},t=>new Promise(async(n,i)=>{await t.restyle({setHideOnLeave:!1});let r=p(e,"network-request-failed"),a=tf().setTimeout(()=>{i(r)},t4.get());function s(){tf().clearTimeout(a),n(t)}t.ping(s).then(s,()=>{i(r)})}))}let t7={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class t9{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}let ne=encodeURIComponent("fac");async function nt(e,t,n,a,s,o){g(e.config.authDomain,e,"auth-domain-config-required"),g(e.config.apiKey,e,"invalid-api-key");let l={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:a,v:i.MF,eventId:s};if(t instanceof eZ)for(let[n,i]of(t.setDefaultLanguage(e.languageCode),l.providerId=t.providerId||"",(0,r.Im)(t.getCustomParameters())||(l.customParameters=JSON.stringify(t.getCustomParameters())),Object.entries(o||{})))l[n]=i;if(t instanceof eY){let e=t.getScopes().filter(e=>""!==e);e.length>0&&(l.scopes=e.join(","))}for(let t of(e.tenantId&&(l.tid=e.tenantId),Object.keys(l)))void 0===l[t]&&delete l[t];let c=await e._getAppCheckToken(),d=c?`#${ne}=${encodeURIComponent(c)}`:"";return`${function({config:e}){return e.emulator?_(e,"emulator/auth/handler"):`https://${e.authDomain}/__/auth/handler`}(e)}?${(0,r.Am)(l).slice(1)}${d}`}let nn="webStorageSupport";class ni{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=th,this._completeRedirectFn=tG,this._overrideRedirectResult=tH}async _openPopup(e,t,n,i){var a,s,o;s=null==(a=this.eventManagers[e._key()])?void 0:a.manager,o="_initialize() not called before _openPopup()",s||w(o);let l=await nt(e,t,n,v(),i);return function(e,t,n,i=500,a=600){let s=Math.max((window.screen.availHeight-a)/2,0).toString(),o=Math.max((window.screen.availWidth-i)/2,0).toString(),l="",c=Object.assign(Object.assign({},t7),{width:i.toString(),height:a.toString(),top:s,left:o}),d=(0,r.ZQ)().toLowerCase();n&&(l=ec(d)?"_blank":n),eo(d)&&(t=t||"http://localhost",c.scrollbars="yes");let u=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,"");if(function(e=(0,r.ZQ)()){var t;return em(e)&&!!(null==(t=window.navigator)?void 0:t.standalone)}(d)&&"_self"!==l)return function(e,t){let n=document.createElement("a");n.href=e,n.target=t;let i=document.createEvent("MouseEvent");i.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(i)}(t||"",l),new t9(null);let h=window.open(t||"",l,u);g(h,e,"popup-blocked");try{h.focus()}catch(e){}return new t9(h)}(e,l,tm())}async _openRedirect(e,t,n,i){var r;return await this._originValidation(e),r=await nt(e,t,n,v(),i),tf().location.href=r,new Promise(()=>{})}_initialize(e){let t=e._key();if(this.eventManagers[t]){var n;let{manager:e,promise:i}=this.eventManagers[t];return e?Promise.resolve(e):(n="If manager is not set, promise should be",i||w(n),i)}let i=this.initAndGetManager(e);return this.eventManagers[t]={promise:i},i.catch(()=>{delete this.eventManagers[t]}),i}async initAndGetManager(e){let t=await t8(e),n=new tK(e);return t.register("authEvent",t=>(g(null==t?void 0:t.authEvent,e,"invalid-auth-event"),{status:n.onEvent(t.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(nn,{type:nn},n=>{var i;let r=null==(i=null==n?void 0:n[0])?void 0:i[nn];void 0!==r&&t(!!r),h(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){let t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=t0(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return ey()||el()||em()}}class nr{constructor(e){this.factorId=e}_process(e,t,n){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,n);case"signin":return this._finalizeSignIn(e,t.credential);default:return w("unexpected MultiFactorSessionType")}}}class na extends nr{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new na(e)}_finalizeEnroll(e,t,n){return S(e,"POST","/v2/accounts/mfaEnrollment:finalize",A(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()}))}_finalizeSignIn(e,t){return S(e,"POST","/v2/accounts/mfaSignIn:finalize",A(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()}))}}class ns{constructor(){}static assertion(e){return na._fromCredential(e)}}ns.FACTOR_ID="phone";class no{static assertionForEnrollment(e,t){return nl._fromSecret(e,t)}static assertionForSignIn(e,t){return nl._fromEnrollmentId(e,t)}static async generateSecret(e){var t,n;g(void 0!==(null==(t=e.user)?void 0:t.auth),"internal-error");let i=await S(n=e.user.auth,"POST","/v2/accounts/mfaEnrollment:start",A(n,{idToken:e.credential,totpEnrollmentInfo:{}}));return nc._fromStartTotpMfaEnrollmentResponse(i,e.user.auth)}}no.FACTOR_ID="totp";class nl extends nr{constructor(e,t,n){super("totp"),this.otp=e,this.enrollmentId=t,this.secret=n}static _fromSecret(e,t){return new nl(t,void 0,e)}static _fromEnrollmentId(e,t){return new nl(t,e)}async _finalizeEnroll(e,t,n){return g(void 0!==this.secret,e,"argument-error"),S(e,"POST","/v2/accounts/mfaEnrollment:finalize",A(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)}))}async _finalizeSignIn(e,t){g(void 0!==this.enrollmentId&&void 0!==this.otp,e,"argument-error");let n={verificationCode:this.otp};return S(e,"POST","/v2/accounts/mfaSignIn:finalize",A(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n}))}}class nc{constructor(e,t,n,i,r,a,s){this.sessionInfo=a,this.auth=s,this.secretKey=e,this.hashingAlgorithm=t,this.co
72deLength=n,this.codeIntervalSeconds=i,this.enrollmentCompletionDeadline=r}static _fromStartTotpMfaEnrollmentResponse(e,t){return new nc(e.totpSessionInfo.sharedSecretKey,e.totpSessionInfo.hashingAlgorithm,e.totpSessionInfo.verificationCodeLength,e.totpSessionInfo.periodSec,new Date(e.totpSessionInfo.finalizeEnrollmentTime).toUTCString(),e.totpSessionInfo.sessionInfo,t)}_makeTotpVerificationInfo(e){return{sessionInfo:this.sessionInfo,verificationCode:e}}generateQrCodeUrl(e,t){var n;let i=!1;return(nd(e)||nd(t))&&(i=!0),i&&(nd(e)&&(e=(null==(n=this.auth.currentUser)?void 0:n.email)||"unknownuser"),nd(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}}function nd(e){return void 0===e||(null==e?void 0:e.length)===0}var nu="@firebase/auth",nh="1.10.8";class np{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null==(e=this.auth.currentUser)?void 0:e.uid)||null}async getToken(e){return(this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser)?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;let t=this.auth.onIdTokenChanged(t=>{e((null==t?void 0:t.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();let t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){g(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}let nm=(0,r.XA)("authIdTokenMaxAge")||300,ny=null;function nf(e=(0,i.Sx)()){let t=(0,i.j6)(e,"auth");if(t.isInitialized())return t.getImmediate();let n=function(e,t){let n=(0,i.j6)(e,"auth");if(n.isInitialized()){let e=n.getImmediate(),i=n.getOptions();if((0,r.bD)(i,null!=t?t:{}))return e;h(e,"already-initialized")}return n.initialize({options:t})}(e,{popupRedirectResolver:ni,persistence:[tS,tl,th]}),a=(0,r.XA)("authTokenSyncURL");if(a&&"boolean"==typeof isSecureContext&&isSecureContext){let e=new URL(a,location.origin);if(location.origin===e.origin){let t,i=(t=e.toString(),async e=>{let n=e&&await e.getIdTokenResult(),i=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(i&&i>nm)return;let r=null==n?void 0:n.token;ny!==r&&(ny=r,await fetch(t,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});(0,r.Ku)(n).beforeAuthStateChanged(i,()=>i(n.currentUser)),(0,r.Ku)(n).onIdTokenChanged(e=>i(e),void 0,void 0)}}let s=(0,r.Tj)("auth");return s&&function(e,t,n){let i=ex(e);g(/^https?:\/\//.test(t),i,"invalid-emulator-scheme");let a=eO(t),{host:s,port:o}=function(e){let t=eO(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};let i=n[2].split("@").pop()||"",r=/^(\[[^\]]+\])(:|$)/.exec(i);if(r){let e=r[1];return{host:e,port:eN(i.substr(e.length+1))}}{let[e,t]=i.split(":");return{host:e,port:eN(t)}}}(t),l=null===o?"":`:${o}`,c={url:`${a}//${s}${l}/`},d=Object.freeze({host:s,port:o,protocol:a.replace(":",""),options:Object.freeze({disableWarnings:!1})});if(!i._canInitEmulator){g(i.config.emulator&&i.emulatorConfig,i,"emulator-config-failed"),g((0,r.bD)(c,i.config.emulator)&&(0,r.bD)(d,i.emulatorConfig),i,"emulator-config-failed");return}i.config.emulator=c,i.emulatorConfig=d,i.settings.appVerificationDisabledForTesting=!0,(0,r.zJ)(s)?((0,r.gE)(`${a}//${s}${l}`),(0,r.P1)("Auth",!0)):function(){function e(){let e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only.  Do not use with production credentials."),"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",e):e())}()}(n,`http://${s}`),n}eC={loadJS:e=>
72new Promise((t,n)=>{let i=document.createElement("script");i.setAttribute("src",e),i.onload=t,i.onerror=e=>{let t=p("internal-error");t.customData=e,n(t)},i.type="text/javascript",i.charset="UTF-8",(function(){var e,t;return null!=(t=null==(e=document.getElementsByTagName("head"))?void 0:e[0])?t:document})().appendChild(i)}),gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="},function(e){(0,i.om)(new o.uA("auth",(t,{options:n})=>{let i=t.getProvider("app").getImmediate(),r=t.getProvider("heartbeat"),a=t.getProvider("app-check-internal"),{apiKey:s,authDomain:o}=i.options;g(s&&!s.includes(":"),"invalid-api-key",{appName:i.name});let l=new eb(i,r,a,{apiKey:s,authDomain:o,clientPlatform:e,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ef(e)}),c=(null==n?void 0:n.persistence)||[],d=(Array.isArray(c)?c:[c]).map(en);return(null==n?void 0:n.errorMap)&&l._updateErrorMap(n.errorMap),l._initializeWithPersistence(d,null==n?void 0:n.popupRedirectResolver),l},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider("auth-internal").initialize()})),(0,i.om)(new o.uA("auth-internal",e=>new np(ex(e.getProvider("auth").getImmediate())),"PRIVATE").setInstantiationMode("EXPLICIT")),(0,i.KO)(nu,nh,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(e)),(0,i.KO)(nu,nh,"esm2017")}("Browser")},488792:(e,t,n)=>{"use strict";n.d(t,{Cx:()=>$,Lx:()=>W,X$:()=>ee,kC:()=>K,qc:()=>Z});var i=n(991439),r=n(886834),a=n(787944),s=n(352401),o=n(806363),l=n(333625),c=n(607186),d=n(559482),u=n(620103),h=n(128897),p=n(889810),m=n(788882),y=n(97644),f=n(480331),g=n(225572),w=n(821196),v=n(849319),b=n(174562),x=n(814001),_=n(916544),C=n(529533),I=n(760483),E=n(603181),T=n(749397),A=n(654230),S=n(142974),k=n(630397),P=n(448953),j=n(458811);let O=[{inputs:[{internalType:"bytes",name:"transactions",type:"bytes"}],name:"multiSend",outputs:[],stateMutability:"payable",type:"function"}],N=[{type:"function",name:"initSafe7579",inputs:[{name:"safe7579",type:"address",internalType:"address"},{name:"executors",type:"tuple[]",internalType:"struct ModuleInit[]",components:[{name:"module",type:"address",internalType:"address"},{name:"initData",type:"bytes",internalType:"bytes"}]},{name:"fallbacks",type:"tuple[]",internalType:"struct ModuleInit[]",components:[{name:"module",type:"address",internalType:"address"},{name:"initData",type:"bytes",internalType:"bytes"}]},{name:"hooks",type:"tuple[]",internalType:"struct ModuleInit[]",components:[{name:"module",type:"address",internalType:"address"},{name:"initData",type:"bytes",internalType:"bytes"}]},{name:"attesters",type:"address[]",internalType:"address[]"},{name:"threshold",type:"uint8",internalType:"uint8"}],outputs:[],stateMutability:"nonpayable"}],R=[{type:"function",name:"preValidationSetup",inputs:[{name:"initHash",type:"bytes32",internalType:"bytes32"},{name:"to",type:"address",internalType:"address"},{name:"preInit",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"}],M=[{inputs:[{internalType:"address[]",name:"modules",type:"address[]"}],name:"enableModules",outputs:[],stateMutability:"nonpayable",type:"function"}],D=[{inputs:[{internalType:"address[]",name:"_owners",type:"address[]"},{internalType:"uint256",name:"_threshold",type:"uint256"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"address",name:"fallbackHandler",type:"address"},{internalType:"address",name:"paymentToken",type:"address"},{internalType:"uint256",name:"payment",type:"uint256"},{internalType:"address payable",name:"paymentReceiver",type:"address"}],name:"setup",outputs:[],stateMutability:"nonpayable",type:"function"}],U=[{inputs:[{internalType:"address",name:"_singleton",type:"address"},{internalType:"bytes",name:"initializer",type:"bytes"}
72,{internalType:"uint256",name:"saltNonce",type:"uint256"}],name:"createProxyWithNonce",outputs:[{internalType:"contract SafeProxy",name:"proxy",type:"address"}],stateMutability:"nonpayable",type:"function"}],L=[{type:"function",name:"setupSafe",inputs:[{name:"initData",type:"tuple",internalType:"struct Safe7579Launchpad.InitData",components:[{name:"singleton",type:"address",internalType:"address"},{name:"owners",type:"address[]",internalType:"address[]"},{name:"threshold",type:"uint256",internalType:"uint256"},{name:"setupTo",type:"address",internalType:"address"},{name:"setupData",type:"bytes",internalType:"bytes"},{name:"safe7579",type:"address",internalType:"contract ISafe7579"},{name:"validators",type:"tuple[]",internalType:"struct ModuleInit[]",components:[{name:"module",type:"address",internalType:"address"},{name:"initData",type:"bytes",internalType:"bytes"}]},{name:"callData",type:"bytes",internalType:"bytes"}]}],outputs:[],stateMutability:"nonpayable"}],F=[{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"uint8",name:"operation",type:"uint8"}],name:"executeUserOpWithErrorString",outputs:[],stateMutability:"nonpayable",type:"function"}],W={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},$={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint128",name:"verificationGasLimit"},{type:"uint128",name:"callGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint128",name:"maxPriorityFeePerGas"},{type:"uint128",name:"maxFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},B={"1.4.1":{"0.6":{SAFE_MODULE_SETUP_ADDRESS:"0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",SAFE_4337_MODULE_ADDRESS:"0xa581c4A4DB7175302464fF3C06380BC3270b4037",SAFE_PROXY_FACTORY_ADDRESS:"0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",SAFE_SINGLETON_ADDRESS:"0x41675C099F32341bf84BFc5382aF534df5C7461a",MULTI_SEND_ADDRESS:"0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",MULTI_SEND_CALL_ONLY_ADDRESS:"0x9641d764fc13c8B624c04430C7356C1C7C8102e2"},"0.7":{SAFE_MODULE_SETUP_ADDRESS:"0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47",SAFE_4337_MODULE_ADDRESS:"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",SAFE_PROXY_FACTORY_ADDRESS:"0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",SAFE_SINGLETON_ADDRESS:"0x41675C099F32341bf84BFc5382aF534df5C7461a",MULTI_SEND_ADDRESS:"0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",MULTI_SEND_CALL_ONLY_ADDRESS:"0x9641d764fc13c8B624c04430C7356C1C7C8102e2"}}},z=(e,t)=>{let n=Number.parseInt(t.slice(-2),16);if(![0,1,27,28].includes(n))throw Error("Invalid signature");return"eth_sign"===e&&(n<27&&(n+=27),n+=4),"eth_signTypedData"===e&&n<27&&(n+=27),t.slice(0,-2)+n.toString(16)},q=e=>"string"==typeof e||e.raw?(0,i.A)(e):(0,r.Zh)(e),V=e=>{let t=`0x${e.map(e=>(e=>(0,a.P)(["uint8","address","uint256","uint256","bytes"],[e.operation,e.to,e.value,BigInt(e.data.slice(2).length/2),e.data]).slice(2))(e)).join("")}`;return(0,s.p)({abi:O,functionName:"multiSend",args:[t]})},H=({safe4337ModuleAddress:e,safeSingletonAddress:t,erc7579LaunchpadAddress:n,owners:i,validators:r,executors:a,fallbacks:o,hooks:l,attesters:c,threshold:d,attestersThreshold:u})=>({singleton:t,owners:i,threshold:d,setupTo:n,setupData:(0,s.p)({abi:N,functionName:"initSafe7579",args:[e,a.map(e=>({module:e.address,initData:e.context})),o.map(e=>({module:e.address,initData:e.context})),l.map(e=>({module:e.address,initData:e.context})),c.sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())),u]}),safe7579:e,validators:r}),G=async({owners:e,threshold:t,safeModuleSetupAddress:n,safe4337ModuleAddress:i,multiSendAddress:r,safeSingletonAddress:a,erc7579LaunchpadAddress:d,setupTransactions:u=[],safeModules:h=[],validators:p=[],executors:m=[],fallbacks:y=[],hooks:f=[],attesters:g=[],attestersThreshold:w=0,paymentToken:v=o.Xd,payment:b=BigInt(0),paymentReceiver:x=o.Xd})=>{if(d){let n=H({safe4337ModuleAddress:i,safeSingletonAddress:a,erc7579LaunchpadAddress:d,owners:e,validators:p,executors:m,fallbacks:y,threshold:t,hooks:f,attesters:g,attestersThreshold:w}),r=(0,l.S)((0,c.h)([{internalType:"address",name:"singleton",type:"address"},{internalType:"address[]",name:"owners",type:"address[]"},{internalType:"uint256",name:"threshold",type:"uint256"},{internalType:"address",name:"setupTo",type:"address"},{internalType:"bytes",name:"setupData",type:"bytes"},{internalType:"contract ISafe7579",name:"safe7579",type:"address"},{internalType:"struct ModuleInit[]",name:"validators",type:"tuple[]",components:[{internalType:"address",name:"module",type:"address"},{internalType:"bytes",name:"initData",type:"bytes"}]}],[n.singleton,n.owners,n.threshold,n.setupTo,n.setupData,n.safe7579,n.validators.map(e=>({module:e.address,initData:e.context}))]));return(0,s.p)({abi:R,functionName:"preValidationSetup",args:[r,o.Xd,"0x"]})}let _=V([{to:n,data:(0,s.p)({abi:M,functionName:"enableModules",args:[[i,...h]]}),value:BigInt(0),operation:1},...u.map(e=>({...e,operation:0}))]);return(0,s.p)({abi:D,functionName:"setup",args:[e,t,r,_,i,v,b,x]})};function K(e){return e.paymaster?(0,d.xW)([e.paymaster,(0,u.eV)((0,h.nj)(e.paymasterVerificationGasLimit||BigInt(0)),{size:16}),(0,u.eV)((0,h.nj)(e.paymasterPostOpGasLimit||BigInt(0)),{size:16}),e.paymasterData||"0x"]):"0x"}let J=async({owners:e,threshold:t,safeModuleSetupAddress:n,safe4337ModuleAddress:i,safeSingletonAddress:r,erc7579LaunchpadAddress:a,multiSendAddress:o,paymentToken:l,payment:c,paymentReceiver:d,saltNonce:u=BigInt(0),setupTransactions:h=[],safeModules:p=[],validators:m=[],executors:y=[],fallbacks:f=[],hooks:g=[],attesters:w=[],attestersThreshold:v=0})=>{let b=await G({owners:e,threshold:t,safeModuleSetupAddress:n,safe4337ModuleAddress:i,multiSendAddress:o,setupTransactions:h,safeSingletonAddress:r,safeModules:p,erc7579LaunchpadAddress:a,validators:m,executors:y,fallbacks:f,hooks:g,attesters:w,attestersThreshold:v,paymentToken:l,payment:c,paymentReceiver:d});
72return(0,s.p)({abi:U,functionName:"createProxyWithNonce",args:[a??r,b,u]})},Z=(e,t,{addModuleLibAddress:n,safeModuleSetupAddress:i,safe4337ModuleAddress:r,safeProxyFactoryAddress:a,safeSingletonAddress:s,multiSendAddress:o,multiSendCallOnlyAddress:l})=>{let c=i??n??B[e][t].SAFE_MODULE_SETUP_ADDRESS,d=r??B[e][t].SAFE_4337_MODULE_ADDRESS,u=a??B[e][t].SAFE_PROXY_FACTORY_ADDRESS,h=s??B[e][t].SAFE_SINGLETON_ADDRESS;return{safeModuleSetupAddress:c,safe4337ModuleAddress:d,safeProxyFactoryAddress:u,safeSingletonAddress:h,multiSendAddress:o??B[e][t].MULTI_SEND_ADDRESS,multiSendCallOnlyAddress:l??B[e][t].MULTI_SEND_CALL_ONLY_ADDRESS}};function Y(e){return void 0!==e.erc7579LaunchpadAddress}let Q=[{inputs:[],name:"proxyCreationCode",outputs:[{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"pure",type:"function"}],X=async({client:e,owners:t,threshold:n,safeModuleSetupAddress:i,safe4337ModuleAddress:r,safeProxyFactoryAddress:s,safeSingletonAddress:o,multiSendAddress:c,erc7579LaunchpadAddress:d,paymentToken:u,payment:h,paymentReceiver:y,setupTransactions:f=[],safeModules:g=[],saltNonce:w=BigInt(0),validators:v=[],executors:b=[],fallbacks:x=[],hooks:_=[],attesters:I=[],attestersThreshold:E=0})=>{let T=await (0,C.J)(e,{abi:Q,address:s,functionName:"proxyCreationCode"}),A=await G({owners:t,threshold:n,safeModuleSetupAddress:i,safe4337ModuleAddress:r,multiSendAddress:c,setupTransactions:f,safeSingletonAddress:o,safeModules:g,erc7579LaunchpadAddress:d,validators:v,executors:b,fallbacks:x,hooks:_,attesters:I,attestersThreshold:E,paymentToken:u,payment:h,paymentReceiver:y}),S=(0,a.P)(["bytes","uint256"],[T,(0,p.uU)(d??o)]),k=(0,l.S)((0,a.P)(["bytes32","uint256"],[(0,l.S)((0,a.P)(["bytes"],[A])),w]));return(0,m.RZ)({from:s,salt:k,bytecode:S,opcode:"CREATE2"})};async function ee(e){let t,n,i,l,c,{client:u,owners:h,address:p,threshold:m=BigInt(h.length),version:C,safe4337ModuleAddress:N,safeProxyFactoryAddress:R,safeSingletonAddress:M,erc7579LaunchpadAddress:D,saltNonce:U=BigInt(0),validUntil:W=0,validAfter:$=0,nonceKey:B,paymentToken:G,payment:K,paymentReceiver:Q,onchainIdentifier:ee}=e,et=await Promise.all(h.map(async e=>"account"in e?e.account:"request"in e?(0,P.F)({owner:e}):e)),en=await Promise.all(h.filter(e=>"type"in e&&"local"===e.type||"request"in e||"account"in e).map(e=>(0,P.F)({owner:e}))),ei={address:e.entryPoint?.address??b.oi,abi:(e.entryPoint?.version??"0.7")==="0.6"?x.hw:x.qe,version:e.entryPoint?.version??"0.7"},er=[],ea=[],es=[],eo=[],el=[],ec=[],ed=0;Y(e)||(n=e.safeModuleSetupAddress,i=e.multiSendAddress,l=e.multiSendCallOnlyAddress,c=e.safeModules,er=e.setupTransactions??[]),Y(e)&&(ea=e.validators??[],es=e.executors??[],eo=e.fallbacks??[],el=e.hooks??[],ec=e.attesters??[],ed=e.attestersThreshold??0);let{safeModuleSetupAddress:eu,safe4337ModuleAddress:eh,safeProxyFactoryAddress:ep,safeSingletonAddress:em,multiSendAddress:ey,multiSendCallOnlyAddress:ef}=Z(C,ei.version,{safeModuleSetupAddress:n,safe4337ModuleAddress:N,safeProxyFactoryAddress:R,safeSingletonAddress:M,multiSendAddress:i,multiSendCallOnlyAddress:l}),eg=p,ew=async()=>t||(t=u.chain?u.chain.id:await (0,E.T)(u,I.T,"getChainId")({})),ev=async()=>({factory:ep,factoryData:await J({owners:et.map(e=>e.address),threshold:m,safeModuleSetupAddress:eu,safe4337ModuleAddress:eh,safeSingletonAddress:em,multiSendAddress:ey,erc7579LaunchpadAddress:D,saltNonce:U,setupTransactions:er,safeModules:c,validators:ea,executors:es,fallbacks:eo,hooks:el,attesters:ec,attestersThreshold:ed,paymentToken:G,payment:K,paymentReceiver:Q})});return(0,_.q)({client:u,entryPoint:ei,getFactoryArgs:ev,getAddress:async()=>eg||(eg=await X({client:u,owners:et.map(e=>e.address),threshold:m,safeModuleSetupAddress:eu,safe4337ModuleAddress:eh,safeProxyFactoryAddress:ep,safeSingletonAddress:em,multiSendAddress:ey,erc7579LaunchpadAddress:D,saltNonce:U,setupTransactions:er,safeModules:c,validators:ea,executors:es,fallbacks:eo,hooks:el,attesters:ec,attestersThreshold:ed,paymentToken:G,payment:K,paymentReceiver:Q})),async encodeCalls(e){let t,n,i,r=e.length>1;if(D){if(!await (0,k.F)(u,await this.getAddress())){let t=H({safe4337ModuleAddress:eh,safeSingletonAddress:em,erc7579LaunchpadAddress:D,owners:et.map(e=>e.address),threshold:m,validators:ea,executors:es,fallbacks:eo,hooks:el,attesters:ec,attestersThreshold:ed});return(0,s.p)({abi:L,functionName:"setupSafe",args:[{...t,validators:t.validators.map(e=>({module:e.address,initData:e.context})),callData:(0,S.m)({mode:{type:r?"batchcall":"call",revertOnError:!1,selector:"0x",context:"0x"},callData:e})}]})}return(0,S.m)({mode:{type:r?"batchcall":"call",revertOnError:!1,selector:"0x",context:"0x"},callData:e})}let a=0;if(r)t=ef,n=BigInt(0),i=V(e.map(e=>({to:e.to,value:e.value??0n,data:e.data??"0x",operation:0}))),a=1;else{let r=0===e.length?void 0:e[0];if(!r)throw Error("No calls to encode");t=r.to,i=r.data??"0x",n=r.value??0n}let o=(0,s.p)({abi:F,functionName:"executeUserOpWithErrorString",args:[t,n,i,a]});return ee?(0,d.xW)([o,ee]):o},async decodeCalls(e){try{let t=(0,y.J)({abi:L,data:e});
72return(0,A.w)(t.args[0].callData).callData}catch(e){}try{return(0,A.w)(e).callData}catch(e){}let t=(0,y.J)({abi:F,data:e}),n=t.args[0],i=t.args[1],r=t.args[2];if(n===ef){let e=(0,y.J)({abi:O,data:r}).args[0],t=[],n=0,i=(0,f.E)(e);for(;n<i;){n+=1;let i=(0,g.b)((0,w.di)(e,n,n+20));n+=20;let r=BigInt((0,w.di)(e,n,n+32));n+=32;let a=Number(BigInt((0,w.di)(e,n,n+32))*BigInt(2));n+=32;let s=(0,w.di)(e,n,n+a);n+=a,t.push({to:i,value:r,data:s})}return t}return[{to:n,value:i,data:r}]},async getNonce(e){return(0,T.p)(u,{address:await this.getAddress(),entryPointAddress:ei.address,key:B??e?.key})},getStubSignature:async()=>(0,a.P)(["uint48","uint48","bytes"],[0,0,`0x${et.map(e=>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").join("")}`]),async sign({hash:e}){return this.signMessage({message:e})},async signMessage({message:e}){if(en.length!==et.length)throw Error("Owners length mismatch, currently not supported");let t=(0,r.Zh)({domain:{chainId:await ew(),verifyingContract:await this.getAddress()},types:{SafeMessage:[{name:"message",type:"bytes"}]},primaryType:"SafeMessage",message:{message:q(e)}}),n=await Promise.all(en.map(async e=>({signer:e.address,data:z("eth_sign",await e.signMessage({message:{raw:(0,v.ZJ)(t)}}))})));n.sort((e,t)=>e.signer.toLowerCase().localeCompare(t.signer.toLowerCase()));let i=(0,d.xW)(n.map(e=>e.data));return D?(0,d.xW)([o.Xd,i]):i},async signTypedData(e){if(en.length!==et.length)throw Error("Owners length mismatch, currently not supported");let t=await Promise.all(en.map(async t=>({signer:t.address,data:z("eth_signTypedData",await t.signTypedData({domain:{chainId:await ew(),verifyingContract:await this.getAddress()},types:{SafeMessage:[{name:"message",type:"bytes"}]},primaryType:"SafeMessage",message:{message:q(e)}}))})));t.sort((e,t)=>e.signer.toLowerCase().localeCompare(t.signer.toLowerCase()));let n=(0,d.xW)(t.map(e=>e.data));return D?(0,d.xW)([o.Xd,n]):n},async signUserOperation(e){let t,{chainId:n=await ew(),...i}=e;if(en.length!==et.length)throw Error("Owners length mismatch use SafeSmartAccount.signUserOperation from `permissionless/accounts/safe`");for(let e of en)t=await (0,j.y)({...i,version:C,entryPoint:ei,owners:en,account:e,chainId:await ew(),signatures:t,validAfter:$,validUntil:W,safe4337ModuleAddress:eh});if(!t)throw Error("No signatures found");return t}})}},491803:(e,t,n)=>{"use strict";function i(e,t,n){return JSON.stringify(e,(e,n)=>"function"==typeof t?t(e,n):"bigint"==typeof n?n.toString()+"#__bigint":n,n)}n.d(t,{A:()=>i})},492331:(e,t,n)=>{"use strict";n.d(t,{x:()=>a});var i=n(709278),r=n(337791);async function a({hash:e,signature:t}){return(0,i.M)(await (0,r.j)({hash:e,signature:t}))}},503261:(e,t,n)=>{"use strict";function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach(function(t){!function(e,t,n){var i;(t="symbol"==typeof(i=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?i:String(i))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t){var n={};for(var i in e)n[i]=t(e[i],i);return n}n.d(t,{c:()=>o});var s=(e,t,n)=>{for(var i of Object.keys(e)){var r;if(e[i]!==(null!=(r=t[i])?r:n[i]))return!1}return!0},o=e=>{var t=t=>{var n=e.defaultClassName,i=r(r({},e.defaultVariants),t);for(var a in i){var o,l=null!=(o=i[a])?o:e.defaultVariants[a];if(null!=l){var c=l;"boolean"==typeof c&&(c=!0===c?"true":"false");
72var d=e.variantClassNames[a][c];d&&(n+=" "+d)}}for(var[u,h]of e.compoundVariants)s(u,i,e.defaultVariants)&&(n+=" "+h);return n};return t.variants=()=>Object.keys(e.variantClassNames),t.classNames={get base(){return e.defaultClassName.split(" ")[0]},get variants(){return a(e.variantClassNames,e=>a(e,e=>e.split(" ")[0]))}},t}},504283:(e,t,n)=>{"use strict";n.d(t,{o:()=>s});var i=n(356273),r=n(9514),a=n(562039);function s(e){let{client:t,key:n="bundler",name:s="Bundler Client",paymaster:o,paymasterContext:l,bundlerTransport:c,userOperation:d}=e,u=Object.assign((0,i.U)({...e,chain:e.chain??t?.chain,transport:c,key:n,name:s,type:"bundlerClient"}),{client:t,paymaster:o,paymasterContext:l,userOperation:d});if(e.userOperation?.prepareUserOperation){let t=e.userOperation.prepareUserOperation;return u.extend(r.O).extend(e=>({prepareUserOperation:n=>t(e,n)})).extend(r.O).extend(e=>({prepareUserOperation:n=>t(e,n)})).extend(a.g)}return u.extend(r.O).extend(a.g)}},504799:(e,t,n)=>{"use strict";n.d(t,{D:()=>i});let i=async(e,{hash:t})=>e.request({method:"pimlico_getUserOperationStatus",params:[t]})},508011:(e,t,n)=>{"use strict";n.d(t,{F:()=>a});var i=n(797036),r=n(128897);async function a(e,t={}){let{account:n=e.account,chainId:s}=t,o=n?(0,i.J)(n):void 0,l=s?[o?.address,[(0,r.cK)(s)]]:[o?.address],c=await e.request({method:"wallet_getCapabilities",params:l}),d={};for(let[e,t]of Object.entries(c))for(let[n,i]of(d[Number(e)]={},Object.entries(t)))"addSubAccount"===n&&(n="unstable_addSubAccount"),d[Number(e)][n]=i;return"number"==typeof s?d[s]:d}},510223:(e,t,n)=>{"use strict";n.d(t,{r:()=>i});let i="0.1.1"},519563:(e,t,n)=>{"use strict";n.d(t,{j:()=>r});var i=n(128897);async function r(e,{chain:t}){let{id:n,name:r,nativeCurrency:a,rpcUrls:s,blockExplorers:o}=t;await e.request({method:"wallet_addEthereumChain",params:[{chainId:(0,i.cK)(n),chainName:r,nativeCurrency:a,rpcUrls:s.default.http,blockExplorerUrls:o?Object.values(o).map(({url:e})=>e):void 0}]},{dedupe:!0,retryCount:0})}},521880:(e,t,n)=>{"use strict";n.d(t,{I:()=>c});var i=n(47100),r=n(620103),a=n(559482),s=n(128897),o=n(288497),l=n(129239);let c=(e,t,n=0n)=>{if((0,l.c)(e))return n;if(n>i.Au)throw Error(`nonce key must be equal or less than 2 bytes(maxUint16) for Kernel version ${e}`);let c=o.xQ.DEFAULT,d=o.g8.ROOT;return BigInt((0,r.eV)((0,a.aP)([c,d,t,(0,s.nj)(n,{size:2})]),{size:24}))}},525868:(e,t,n)=>{"use strict";n.d(t,{_:()=>function e(t){if("function"!=typeof t)return null==t||"string"==typeof t||"boolean"==typeof t?t:"bigint"==typeof t?(0,i.nj)(t):null!=t._isBigNumber||"object"!=typeof t?(0,i.nj)(t).replace(/^0x0/,"0x"):Array.isArray(t)?t.map(t=>e(t)):Object.keys(t).reduce((n,i)=>(n[i]=e(t[i]),n),{})}});var i=n(128897)},526725:(e,t,n)=>{"use strict";n.d(t,{X:()=>s});var i=n(397118),r=n(128897),a=n(889810);let s=async(e,t)=>{let n=t.chain?.id??e.chain?.id;if(!n)throw new i.jF;return(await e.request({method:"pimlico_getTokenQuotes",params:[{tokens:t.tokens},t.entryPointAddress,(0,r.cK)(n)]})).quotes.map(e=>({...e,balanceSlot:e.balanceSlot?(0,a.uU)(e.balanceSlot):void 0,allowanceSlot:e.allowanceSlot?(0,a.uU)(e.allowanceSlot):void 0,postOpGas:(0,a.uU)(e.postOpGas),exchangeRate:(0,a.uU)(e.exchangeRate),exchangeRateNativeToUsd:(0,a.uU)(e.exchangeRateNativeToUsd)}))}},530487:(e,t,n)=>{"use strict";n.d(t,{t:()=>r});var i=n(225572);async function r(e){return e.account?.type==="local"?[e.account.address]:(await e.request({method:"eth_accounts"},{dedupe:!0})).map(e=>(0,i.o)(e))}},538960:(e,t,n)=>{"use strict";n.d(t,{g:()=>G});var i,r,a,s,o,l,c,d,u,h,p,m,y,f,g,w,v,b,x,_,C,I,E,T,A=n(901257),S=n(521652),k=n(27283),P=n(740136),j=n(867121),O=n(111934),N=n(449314),R=n(48397);let M=["solana:mainnet","solana:devnet","solana:testnet","solana:localnet"];function D(e){return M.includes(e)}var U=function(e,t,n,i){if("a"===n&&!i)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},L=function(e,t,n,i,r){if("m"===i)throw TypeError("Private method is not writable");if("a"===i&&!r)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};let F=[S.R,k.q,P.F];class W{get address(){return U(this,i,"f")}get publicKey(){return U(this,r,"f").slice()}get chains(){return U(this,a,"f").slice()}get features(){return U(this,s,"f").slice()}get label(){return U(this,o,"f")}get icon(){return U(this,l,"f")}constructor({address:e,publicKey:t,label:n,icon:c}){i.set(this,void 0),r.set(this,void 0),a.set(this,void 0),s.set(this,void 0),o.set(this,void 0),l.set(this,void 0),new.target===W&&Object.freeze(this),L(this,i,e,"f"),L(this,r,t,"f"),L(this,a,M,"f"),L(this,s,F,"f"),L(this,o,n,"f"),L(this,l,c,"f")}}i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap;var $=n(206284),B=n(385307),z=n.n(B),q=function(e,t,n,i){return new(n||(n=Prom
72ise))(function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(s,o)}l((i=i.apply(e,t||[])).next())})},V=function(e,t,n,i){if("a"===n&&!i)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},H=function(e,t,n,i,r){if("m"===i)throw TypeError("Private method is not writable");if("a"===i&&!r)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};class G{get version(){return V(this,u,"f")}get name(){return V(this,h,"f")}get icon(){return V(this,p,"f")}get chains(){return[A.CE,A.sE,A.re]}get features(){return{[O.u]:{version:"1.0.0",connect:V(this,_,"f")},[N.w]:{version:"1.0.0",disconnect:V(this,C,"f")},[R.j]:{version:"1.0.0",on:V(this,f,"f")},[S.R]:{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:V(this,I,"f")},[k.q]:{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:V(this,E,"f")},[P.F]:{version:"1.0.0",signMessage:V(this,T,"f")}}}get accounts(){return V(this,y,"f")?[V(this,y,"f")]:[]}constructor(){c.add(this),d.set(this,{}),u.set(this,"1.0.0"),h.set(this,"Solflare"),p.set(this,"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJTIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MCA1MCI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiMwMjA1MGE7c3Ryb2tlOiNmZmVmNDY7c3Ryb2tlLW1pdGVybGltaXQ6MTA7c3Ryb2tlLXdpZHRoOi41cHg7fS5jbHMtMntmaWxsOiNmZmVmNDY7fTwvc3R5bGU+PC9kZWZzPjxyZWN0IGNsYXNzPSJjbHMtMiIgeD0iMCIgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiByeD0iMTIiIHJ5PSIxMiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTI0LjIzLDI2LjQybDIuNDYtMi4zOCw0LjU5LDEuNWMzLjAxLDEsNC41MSwyLjg0LDQuNTEsNS40MywwLDEuOTYtLjc1LDMuMjYtMi4yNSw0LjkzbC0uNDYuNS4xNy0xLjE3Yy42Ny00LjI2LS41OC02LjA5LTQuNzItNy40M2wtNC4zLTEuMzhoMFpNMTguMDUsMTEuODVsMTIuNTIsNC4xNy0yLjcxLDIuNTktNi41MS0yLjE3Yy0yLjI1LS43NS0zLjAxLTEuOTYtMy4zLTQuNTF2LS4wOGgwWk0xNy4zLDMzLjA2bDIuODQtMi43MSw1LjM0LDEuNzVjMi44LjkyLDMuNzYsMi4xMywzLjQ2LDUuMThsLTExLjY1LTQuMjJoMFpNMTMuNzEsMjAuOTVjMC0uNzkuNDItMS41NCwxLjEzLTIuMTcuNzUsMS4wOSwyLjA1LDIuMDUsNC4wOSwyLjcxbDQuNDIsMS40Ni0yLjQ2LDIuMzgtNC4zNC0xLjQyYy0yLS42Ny0yLjg0LTEuNjctMi44NC0yLjk2TTI2LjgyLDQyLjg3YzkuMTgtNi4wOSwxNC4xMS0xMC4yMywxNC4xMS0xNS4zMiwwLTMuMzgtMi01LjI2LTYuNDMtNi43MmwtMy4zNC0xLjEzLDkuMTQtOC43Ny0xLjg0LTEuOTYtMi43MSwyLjM4LTEyLjgxLTQuMjJjLTMuOTcsMS4yOS04Ljk3LDUuMDktOC45Nyw4Ljg5LDAsLjQyLjA0LjgzLjE3LDEuMjktMy4zLDEuODgtNC42MywzLjYzLTQuNjMsNS44LDAsMi4wNSwxLjA5LDQuMDksNC41NSw1LjIybDIuNzUuOTItOS41Miw5LjE0LDEuODQsMS45NiwyLjk2LTIuNzEsMTQuNzMsNS4yMmgwWiIvPjwvc3ZnPg=="),m.set(this,void 0),y.set(this,null),f.set(this,(e,t)=>{var n;return(null==(n=V(this,d,"f")[e])?void 0:n.push(t))||(V(this,d,"f")[e]=[t]),()=>V(this,c,"m",w).call(this,e,t)}),v.set(this,()=>{if(V(this,m,"f").publicKey){let e=V(this,y,"f"),t=V(this,m,"f").publicKey;e&&e.address===t.toString()&&e.publicKey.toString()===t.toString()||(H(this,y,new W({address:t.toString(),publicKey:t.toBytes()}),"f"),V(this,c,"m",g).call(this,"change",{accounts:this.accounts}))}}),b.set(this,()=>{V(this,y,"f")&&(H(this,y,null,"f"),V(this,c,"m",g).call(this,"change",{accounts:this.accounts}))}),x.set(this,()=>{V(this,m,"f").publicKey?V(this,v,"f").call(this):V(this,b,"f").call(this)}),_.set(this,()=>q(this,void 0,void 0,function*(){var e,t;if(!V(this,y,"f")){if(!(null==window?void 0:window.solflare)&&!(null==window?void 0:window.SolflareApp)){let n=(null==(t=null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.toLowerCase)?void 0:t.call(e))||"";if(n.includes("iphone")||n.includes("ipad")){let e=encodeURIComponent(window.location.href),t=encodeURIComponent(window.location.origin);throw window.location.href=`https://solflare.com/ul/v1/browse/${e}?ref=${t}`,Error("redirected to Solflare")}}yield V(this,m,"f").connect()}return V(this,v,"f").call(this),{accounts:this.accounts}})),C.set(this,()=>q(this,void 0,void 0,function*(){yield V(this,m,"f").disconnect()})),I.set(this,(...e)=>q(this,void 0,void 0,function*(){if(!V(this,y,"f"))throw Error("not connected");let t=[];if(1===e.length){let{transaction:n,account:i,chain:r,options:a}=e[0],{minContextSlot:s,preflightCommitment:o,skipPreflight:l,maxRetries:c}=a||{};if(i!==V(this,y,"f"))throw Error("invalid account");if(!D(r))throw Error("invalid chain");let d=yield V(this,m,"f").signAndSendTransaction($.VersionedTransaction.deserialize(n),{preflightCommitment:o,minContextSlot:s,maxRetries:c,skipPreflight:l});t.push({signature:z().decode(d)})}else if(e.length>1)for(let n of e)t.push(...yield V(this,I,"f").call(this,n));return t})),E.set(this,(...e)=>q(this,void 0,void 0,function*(){if(!V(this,y,"f"))throw Error("not connected");let t=[];if(1===e.length){let{transaction:n,account:i,chain:r}=e[0];if(i!==V(this,y,"f"))throw Error("invalid account");if(r&&!D(r))throw Error("invalid chain");let a=yield V(this,m,"f").signTransaction($.VersionedTransaction.deserialize(n));t.push({signedTransaction:a.serialize()})}else if(e.length>1){let n;for(let t of e){if(t.account!==V(this,y,"f"))throw Error("invalid account");if(t.chain){if(!D(t.chain))throw Error("invalid chain");if(n){if(t.chain!==n)throw Error("conflicting chain")}else n=t.chain}}let i=e.map(({transaction:e})=>$.VersionedTransaction.deserialize(e)),r=yield V(this,m,"f").signAllTransactions(i);t.push(...r.map(e=>({signedTransaction:e.serialize()})))}return t})),T.set(this,(...e)=>q(this,void 0,void 0,function*(){if(!V(this,y,"f"))throw Error("not connected");let t=[];if(1===e.length){let{message:n,account:i}=e[0];if(i!==V(this,y,"f"))throw Error("invalid account");let r=yield V(this,m,"f").signMessage(n);t.push({signedMessage:n,signature:r})}else if(e.length>1)for(let n of e)t.push(...yield V(this,T,"f").call(this,n));return t})),H(this,m,new j.default({params:{adapterVersion:"1.0.4"}}),"f"),V(this,m,"f").on("connect",V(this,v,"f"),this),V(this,m,"f").on("disconnect",V(this,b,"f"),this),V(this,m,"f").on("accountChanged",V(this,x,"f"),this),V(this,v,"f").call(this)}}d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap,m=new WeakMap,y=new WeakMap,f=new WeakMap,v=new WeakMap,b=new WeakMap,x=new WeakMap,_=new WeakMap,C=new WeakMap,I=new WeakMap,E=new WeakMap,T=new WeakMap,c=new WeakSet,g=function(e,...t){var n;
72null==(n=V(this,d,"f")[e])||n.forEach(e=>e.apply(null,t))},w=function(e,t){var n;V(this,d,"f")[e]=null==(n=V(this,d,"f")[e])?void 0:n.filter(e=>t!==e)}},545700:(e,t,n)=>{"use strict";n.d(t,{r:()=>r});var i=n(352401);let r=async e=>{if(e.length>1)return(0,i.p)({abi:[{inputs:[{internalType:"address[]",name:"dest",type:"address[]"},{internalType:"uint256[]",name:"value",type:"uint256[]"},{internalType:"bytes[]",name:"func",type:"bytes[]"}],name:"executeBatch",outputs:[],stateMutability:"nonpayable",type:"function"}],functionName:"executeBatch",args:[e.map(e=>e.to),e.map(e=>e.value??0n),e.map(e=>e.data??"0x")]});let t=0===e.length?void 0:e[0];if(!t)throw Error("No calls to encode");return(0,i.p)({abi:[{inputs:[{internalType:"address",name:"dest",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"func",type:"bytes"}],name:"execute",outputs:[],stateMutability:"nonpayable",type:"function"}],functionName:"execute",args:[t.to,t.value??0n,t.data??"0x"]})}},555242:(e,t,n)=>{"use strict";n.d(t,{vt:()=>r,On:()=>s});let i=()=>{let e,t,n=new Promise((n,i)=>{e=n,t=i});return{resolve:e,reject:t,value:n}},r=(e,t)=>{let n=e.name??`batcher:${Math.random().toString(16).slice(2)})`,r=e.scheduler??a(10),s=globalThis.__BATSHIT_DEVTOOLS__?.for(n),o=t??{seq:0,batch:new Set,currentRequest:i(),timer:void 0,start:null,latest:null};return s?.create({seq:o.seq}),{fetch:t=>{o.start||(o.start=Date.now()),o.latest=Date.now(),o.batch.add(t),clearTimeout(o.timer);let n=r(o.start,o.latest,o.batch.size);s?.queue({seq:o.seq,query:t,batch:[...o.batch],scheduled:n,latest:o.latest,start:o.start});let a=()=>
72{let t=o.seq,n=e.fetcher([...o.batch]),r=o.currentRequest;return s?.fetch({seq:t,batch:[...o.batch]}),o.batch=new Set,o.currentRequest=i(),o.timer=void 0,o.start=null,o.latest=null,n.then(e=>{s?.data({seq:t,data:e}),r.resolve(e)}).catch(e=>{s?.error({seq:t,error:e}),r.reject(e)}),o.seq++,n};if("immediate"===n){let n=o.currentRequest;return a(),n.value.then(n=>e.resolver(n,t))}return"never"===n?o.currentRequest.value.then(n=>e.resolver(n,t)):(o.timer=setTimeout(a,n),o.currentRequest.value.then(n=>e.resolver(n,t)))}}},a=e=>(t,n)=>e-(n-t),s=({windowMs:e,maxBatchSize:t})=>(n,i,r)=>r>=t?"immediate":e-(i-n)},562039:(e,t,n)=>{"use strict";n.d(t,{g:()=>o});var i=n(263400),r=n(815278),a=n(121581),s=n(297895);function o(e){return{sendTransaction:t=>(0,i.v)(e,t),signMessage:t=>(0,r.l)(e,t),signTypedData:t=>(0,a.C)(e,t),writeContract:t=>(0,s.E)(e,t)}}},565456:(e,t,n)=>{"use strict";n.d(t,{J:()=>l});var i=n(224473),r=n(664392),a=n(265098),s=n(374886),o=n(319970);function l(e){let{abi:t,data:n}=e,l=(0,r.di)(n,0,4),c=t.find(e=>"function"===e.type&&l===(0,a.V)((0,o.B)(e)));if(!c)throw new i.EB(l,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:c.name,args:"inputs"in c&&c.inputs&&c.inputs.length>0?(0,s.n)(c.inputs,(0,r.di)(n,4)):void 0}}},569696:(e,t,n)=>{"use strict";n.d(t,{D:()=>T});var i=n(760483),r=n(519563),a=n(753346),s=n(530487),o=n(704932),l=n(508011),c=n(102319),d=n(944315),u=n(766075),h=n(85144),p=n(645184),m=n(726122),y=n(13359),f=n(364591),g=n(53717),w=n(677987),v=n(575665),b=n(405810),x=n(443046),_=n(479632),C=n(61948),I=n(764014),E=n(934172);function T(e){return{addChain:t=>(0,r.j)(e,t),deployContract:t=>(0,a.c)(e,t),getAddresses:()=>(0,s.t)(e),getCallsStatus:t=>(0,o.k)(e,t),getCapabilities:t=>(0,l.F)(e,t),getChainId:()=>(0,i.T)(e),getPermissions:()=>(0,c.V)(e),prepareAuthorization:t=>(0,d.h)(e,t),prepareTransactionRequest:t=>(0,u.ft)(e,t),requestAddresses:()=>(0,h.s)(e),requestPermissions:t=>(0,p.u)(e,t),sendCalls:t=>(0,m.yM)(e,t),sendRawTransaction:t=>(0,y.L)(e,t),sendTransaction:t=>(0,f.v)(e,t),showCallsStatus:t=>(0,g.J)(e,t),signAuthorization:t=>(0,w.V)(e,t),signMessage:t=>(0,v.l)(e,t),signTransaction:t=>(0,b.W)(e,t),signTypedData:t=>(0,x.C)(e,t),switchChain:t=>(0,_.S)(e,t),waitForCallsStatus:t=>(0,C.c)(e,t),watchAsset:t=>(0,I.w)(e,t),writeContract:t=>(0,E.E)(e,t)}}},569993:(e,t,n)=>{"use strict";n.d(t,{V:()=>i,m:()=>r});let i=[{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"enum Operation",name:"",type:"uint8"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct Call[]",name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"}],r=[{inputs:[{internalType:"contract IKernelValidator",name:"_defaultValidator",type:"address"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"}]},572178:(e,t,n)=>{"use strict";n.d(t,{W:()=>o});var i=n(559482),r=n(620103),a=n(128897),s=n(37902);function o(e){let{callGasLimit:t,callData:n,maxPriorityFeePerGas:o,maxFeePerGas:l,paymaster:c,paymasterData:d,paymasterPostOpGasLimit:u,paymasterVerificationGasLimit:h,sender:p,signature:m="0x",verificationGasLimit:y}=e,f=(0,i.xW)([(0,r.eV)((0,a.cK)(y||0n),{size:16}),(0,r.eV)((0,a.cK)(t||0n),{size:16})]),g=(0,s.K)(e),w=(0,i.xW)([(0,r.eV)((0,a.cK)(o||0n),{size:16}),(0,r.eV)((0,a.cK)(l||0n),{size:16})]),v=e.nonce??0n;return{accountGasLimits:f,callData:n,initCode:g,gasFees:w,nonce:v,paymasterAndData:c?(0,i.xW)([c,(0,r.eV)((0,a.cK)(h||0n),{size:16}),(0,r.eV)((0,a.cK)(u||0n),{size:16}),d||"0x"]):"0x",preVerificationGas:e.preVerificationGas??0n,sender:p,signature:m}}},575665:(e,t,n)=>{"use strict";n.d(t,{l:()=>s});var i=n(797036),r=n(347220),a=n(128897);async function s(e,{account:t=e.account,message:n}){if(!t)throw new r.T({docsPath:"/docs/actions/wallet/signMessage"});let s=(0,i.J)(t);if(s.signMessage)return s.signMessage({message:n});let o="string"==typeof n?(0,a.i3)(n):n.raw instanceof Uint8Array?(0,a.nj)(n.raw):n.raw;return e.request({method:"personal_sign",params:[o,s.address]},{retryCount:0})}},589385:(e,t,n)=>{"use strict";n.d(t,{E:()=>o});var i=n(775576),r=n(607186),a=n(559482),s=n(849319);function o(e){let{address:t,data:n,signature:o,to:l="hex"}=e,c=(0,a.aP)([(0,r.h)([{type:"address"},{type:"bytes"},{type:"bytes"}],[t,n,o]),i.I]);return"hex"===l?c:(0,s.aT)(c)}},591260:(e,t,n)=>{"use strict";n.d(t,{cK:()=>c,nj:()=>o});var i=n(37107),r=n(347626),a=n(871883);let s=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function o(e,t={}){return"number"==typeof e||"bigint"==typeof e?c(e,t):"string"==typeof e?function(e,t={}){return l(d.encode(e),t)}(e,t):"boolean"==typeof e?function(e,t={}){let n=`0x${Number(e)}`;return"number"==typeof t.size?((0,a.Sl)(n,{size:t.size}),(0,r.eV)(n,{size:t.size})):n}(e,t):l(e,t)}function l(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=s[e[t]];let i=`0x${n}`;return"number"==typeof t.size?((0,a.Sl)(i,{size:t.size}),(0,r.eV)(i,{dir:"right",size:t.size})):i}function c(e,t={}){let n,{signed:a,size:s}=t,o=BigInt(e);s?n=a?(1n<<8n*BigInt(s)-1n)-1n:2n**(8n*BigInt(s))-1n:"number"==typeof e&&(n=BigInt(Number.MAX_SAFE_INTEGER));let l="bigint"==typeof n&&a?-n-1n:0;if(n&&o>n||o<l){let t="bigint"==typeof e?"n":"";throw new i.Ty({max:n?`${n}${t}`:void 0,min:`${l}${t}`,signed:a,size:s,value:`${e}${t}`})}let d=`0x${(a&&o<0?(1n<<BigInt(8*s))+BigInt(o):o).toString(16)}`;return s?(0,r.eV)(d,{size:s}):d}let d=new TextEncoder},604576:e=>{var t="\ud800-\udfff",n="\\u2700-\\u27bf",i="a-z\\xdf-\\xf6\\xf8-\\xff",r="A-Z\\xc0-\\xd6\\xd8-\\xde",a="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",s="['’]",o="["+a+"]",l="["+i+"]",c="[^"+t+a+"\\d+"+n+i+r+"]",d="(?:\ud83c[\udde6-\uddff]){2}
72",u="[\ud800-\udbff][\udc00-\udfff]",h="["+r+"]",p="(?:"+l+"|"+c+")",m="(?:"+h+"|"+c+")",y="(?:"+s+"(?:d|ll|m|re|s|t|ve))?",f="(?:"+s+"(?:D|LL|M|RE|S|T|VE))?",g="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\ud83c[\udffb-\udfff])?",w="[\\ufe0e\\ufe0f]?",v="(?:\\u200d(?:"+["[^"+t+"]",d,u].join("|")+")"+w+g+")*",b="(?:"+["["+n+"]",d,u].join("|")+")"+(w+g+v),x=RegExp([h+"?"+l+"+"+y+"(?="+[o,h,"$"].join("|")+")",m+"+"+f+"(?="+[o,h+p,"$"].join("|")+")",h+"?"+p+"+"+y,h+"+"+f,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])|\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])|\\d+",b].join("|"),"g");e.exports=function(e){return e.match(x)||[]}},605199:(e,t,n)=>{"use strict";n.d(t,{aD:()=>a});var i=n(479656),r=n(448398);function a(e){if(132!==e.length&&130!==e.length&&68!==e.length)throw new s({publicKey:e});if(130===e.length)return{prefix:4,x:BigInt(r.di(e,0,32)),y:BigInt(r.di(e,32,64))};if(132===e.length){let t=Number(r.di(e,0,1));return{prefix:t,x:BigInt(r.di(e,1,33)),y:BigInt(r.di(e,33,65))}}return{prefix:Number(r.di(e,0,1)),x:BigInt(r.di(e,1,33))}}n(491803),i.C,i.C,i.C,i.C;class s extends i.C{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${r.Ej(r.HT(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}}},609810:(e,t,n)=>{"use strict";n.d(t,{O:()=>i});let i=async(e,t)=>{let{compressedUserOperation:n,inflatorAddress:i,entryPointAddress:r}=t;return e.request({method:"pimlico_sendCompressedUserOperation",params:[n,i,r]})}},615633:(e,t,n)=>{"use strict";n.d(t,{L:()=>s});var i=n(889810),r=n(128897),a=n(707799);async function s(e,t){let{chainId:n,entryPointAddress:s,context:o,...l}=t,c=(0,a.P)(l),{paymasterPostOpGasLimit:d,paymasterVerificationGasLimit:u,...h}=await e.request({method:"pm_getPaymasterStubData",params:[{...c,callGasLimit:c.callGasLimit??"0x0",verificationGasLimit:c.verificationGasLimit??"0x0",preVerificationGas:c.preVerificationGas??"0x0"},s,(0,r.cK)(n),o]});return{...h,...d&&{paymasterPostOpGasLimit:(0,i.uU)(d)},...u&&{paymasterVerificationGasLimit:(0,i.uU)(u)}}}},619174:(e,t,n)=>{var i=n(224813),r=n(980544);e.exports=function(e,t,n){var a=null==e?0:e.length;return a?i(e,(t=n||void 0===t?1:r(t))<0?0:t,a):[]}},624078:(e,t,n)=>{"use strict";n.d(t,{l:()=>l});var i=n(738417),r=n(991439),a=n(607186),s=n(340335),o=n(723505);async function l({message:e,owner:t,accountAddress:n,kernelVersion:l,chainId:c}){if((0,s.W)(t)){let s;if("string"==typeof e)s=(0,o.Q)((0,r.A)(e),{kernelVersion:l,accountAddress:n,chainId:c});else if("raw"in e&&"string"==typeof e.raw)s=e.raw;else if("raw"in e&&e.raw instanceof Uint8Array)s=e.raw.toString();else throw Error("Unsupported message format");let{signature:d,webauthn:u}=await t.sign({hash:s}),h=i.aD(d);return(0,a.h)([{name:"authenticatorData",type:"bytes"},{name:"clientDataJSON",type:"string"},{name:"responseTypeLocation",type:"uint256"},{name:"r",type:"uint256"},{name:"s",type:"uint256"},{name:"usePrecompiled",type:"bool"}],[u.authenticatorData,u.clientDataJSON,BigInt(u.typeIndex),BigInt(h.r),BigInt(h.s),!1])}if("0.2.1"===l||"0.2.2"===l)return t.signMessage({message:e});let d=(0,o.Q)((0,r.A)(e),{kernelVersion:l,accountAddress:n,chainId:c});return t.signMessage({message:{raw:d}})}},627817:(e,t,n)=>{"use strict";n.d(t,{g:()=>r});var i=n(730720);function r(e){let{route:t,searchParams:n,routeParams:r}=e;if(n&&r){let e=(0,i.dJ)(n),a=(0,i.mF)(t,r);return`${a}${e}`}if(r&&!n)return(0,i.mF)(t,r);if(!n||r)return t;{let e=(0,i.dJ)(n);return`${t}${e}`}}n(328414)},629484:(e,t,n)=>{"use strict";n.d(t,{a:()=>u});var i=n(583665),r=n(548506),a=n(381017),s=n(123103),o=n(120319),l=n(73148),c=n(735868),d=n(216146);async function u(e,t){let{account:n=e.account,chain:u=e.chain,...h}=t,p=n?(0,i.J)(n):e.account;if(!p)throw new s.T({docsPath:"/docs/actions/wallet/signTransaction"});if((0,d.w)({account:p,chain:u,...t}),!u?.custom?.getEip712Domain)throw new o.C("`getEip712Domain` not found on chain.");if(!u?.serializers?.transaction)throw new o.C("transaction serializer not found on chain.");let m=await (0,c.T)(e,r.T,"getChainId")({});null!==u&&(0,l.v)({currentChainId:m,chain:u});let y=u?.custom.getEip712Domain({...h,chainId:m,from:p.address,type:"eip712"}),f=await (0,a.C)(e,{...y,account:p});return u?.serializers?.transaction({chainId:m,...h,customSignature:f,type:"eip712"},{r:"0x0",s:"0x0",v:0n})}},630397:(e,t,n)=>{"use strict";n.d(t,{F:()=>r});var i=n(555512);let r=async(e,t)=>!!await (0,i.Q)(e,{address:t})},631930:(e,t,n)=>{"use strict";n.d(t,{I:()=>s,a:()=>r,n:()=>a,u:()=>
72o});var i=n(25963);let r=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},a=e=>()=>{throw Error(e.trim())},s=(0,i.createContext)({setAuthenticated:r,setUser:r,setIsNewUser:r,isNewUserThisSession:!1,walletConnectionStatus:null,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",onCustomAuthAuthenticated:r,hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:r,initializeWalletProxy:r,getAuthMeta:r,getAuthFlow:r,closePrivyModal:r,openPrivyModal:r,connectWallet:r,initLoginWithWallet:r,loginWithWallet:r,initLoginWithFarcaster:r,loginWithFarcaster:r,loginWithCode:r,initLoginWithEmail:r,initLoginWithSms:r,initUpdateEmail:r,initUpdatePhone:r,resendEmailCode:r,resendSmsCode:r,initLoginWithHeadlessOAuth:r,loginWithHeadlessOAuth:r,crossAppAuthFlow:r,initLoginWithOAuth:r,loginWithOAuth:r,passkeyAuthState:{status:"initial"},setPasskeyAuthState:r,initSignupWithPasskey:r,signupWithPasskey:r,initLoginWithPasskey:r,loginWithPasskey:r,initLinkWithPasskey:r,linkWithPasskey:r,refreshSessionAndUser:r,walletProxy:null,createAnalyticsEvent:r,acceptTerms:r,getUsdTokenPrice:r,getUsdPriceForSol:r,getSplTokenMetadata:r,recoverEmbeddedWallet:r,updateWallets:r,fundWallet:r,openModal:r,setReadyToTrue:r,requestFarcasterSignerStatus:r,initLoginWithTelegram:r,loginWithTelegram:r,generateSiweMessage:r,generateSiweMessageForSmartWallet:r,loginWithSiwe:r,linkWithSiwe:r,linkSmartWallet:r,delegateWallet:r,revokeDelegatedWallets:r,exportSolanaWallet:r,connectCoinbaseSmartWallet:r,initiateAccountTransfer:r,emailOtpState:{status:"initial"},setEmailOtpState:r,smsOtpState:{status:"initial"},setSmsOtpState:r,siweState:{status:"initial"},setSiweState:r,oAuthState:{status:"initial"},setOAuthState:r,telegramAuthState:{status:"initial"},setTelegramAuthState:r,isHeadlessOAuthLoading:!1,isHeadlessSigning:r,inProgressAuthFlowRef:{current:null},inProgressLoginOrLinkMethodRef:{current:null}}),o=()=>(0,i.useContext)(s)},633370:(e,t,n)=>{var i=n(19773),r=n(22363);e.exports=function(e){return"number"==typeof e||r(e)&&"[object Number]"==i(e)}},633793:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});let i={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0}},636976:(e,t,n)=>{"use strict";n.d(t,{q:()=>i});let i={id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0}},637155:(e,t,n)=>{"use strict";n.d(t,{p:()=>s});var i=n(295521),r=n(410387),a=n(935197);function s(e,{docsPath:t,...n}){let s=(()=>{let t=(0,a.l)(e,n);return t instanceof i.RM?e:t})();return new r.$s(s,{docsPath:t,...n})}},643171:e=>{e.exports=function(e,t,n,i){var r=-1,a=null==e?0:e.length;for(i&&a&&(n=e[++r]);++r<a;)n=t(n,e[r],r,e);return n}},645184:(e,t,n)=>{"use strict";async function i(e,t){return e.request({method:"wallet_requestPermissions",params:[t]},{retryCount:0})}n.d(t,{u:()=>i})},654230:(e,t,n)=>{"use strict";n.d(t,{w:()=>l});var i=n(97644),r=n(821196),a=n(999622),s=n(225572),o=n(480331);function l(e){let t,n=(0,i.J)({abi:[{type:"function",name:"execute",inputs:[{name:"execMode",type:"bytes32",internalType:"ExecMode"},{name:"executionCalldata",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"}],data:e}),l=n.args[0],c=n.args[1],d=(0,r.di)(l,0,1),u=(0,r.di)(l,1,2),h=(0,r.di)(l,3,7),p=(0,r.di)(l,7);switch(BigInt(d)){case BigInt(0):t="call";break;case BigInt(1):t="batchcall";break;case BigInt(255):t="delegatecall";break;default:throw Error("Invalid call type")}let m={type:t,revertOnError:BigInt(u)===BigInt(1),selector:h,context:p};if("batchcall"===m.type){let[e]=(0,a.n)([{name:"executionBatch",type:"tuple[]",components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"callData",type:"bytes"}]}],c);return{mode:m,callData:e.map(e=>({to:e.target,value:e.value,data:e.callData}))}}let y=(0,s.b)((0,r.di)(c,0,20));return{mode:m,callData:[{to:y,value:BigInt((0,r.di)(c,20,52)),data:(0,o.E)(c)>52?(0,r.di)(c,52):"0x"}]}}},654882:(e,t,n)=>{"use strict";n.d(t,{x:()=>m});var i=n(350979),r=n(207357),a=n(25963),s=n(341305),o=n(993445),l=n(936800),c=n(105493),d=n(161877);let u=async(e,t)=>{let n=await Promise.all(e.map(async e=>{let n=await e.getEthereumProvider(),i=t.connectors.find(t=>
72t.id===e.meta.id);if(i)return i;let r=(0,l.b)({target:{provider:n,id:e.meta.id,name:e.meta.name,icon:e.meta.icon}});return t._internal.connectors.setup(r)}));return t._internal.connectors.setState(n),n},h=async(e,t,n)=>{await Promise.all([n.storage?.removeItem(`${e.meta.id}.disconnected`),n.storage?.setItem("recentConnectorId",t.id)]);let i=Number(e.chainId.replace("eip155:",""));n.chains.find(e=>e.id===i)||(i=n.chains[0].id);let r=new Map([[t.uid,{accounts:[e.address],chainId:i,connector:t}]]);n.setState(e=>({...e,chainId:i,connections:r,current:t.uid,status:"connected"}))},p=({children:e,setActiveWalletForWagmi:t})=>((({setActiveWalletForWagmi:e})=>{let{wallets:t,ready:n}=(0,c.p)(),{user:i}=(0,c.H)(),r=(0,s.U)(),{reconnect:l}=(0,o.R)();(function(e){let{connectWallet:t}=(0,a.useContext)(d.P);(0,c.u)("connectWallet",e)})({onSuccess:async({wallet:t})=>{await r.storage?.removeItem(`${t.meta.id}.disconnected`),e||(await r.storage?.setItem("recentConnectorId",t.meta.id),l())}}),function(e){let{login:t}=(0,a.useContext)(d.P);(0,c.u)("login",e)}({onComplete:async({user:e,loginAccount:t})=>{t&&"wallet"!==t.type&&e.linkedAccounts.find(e=>"wallet"===e.type&&"privy"===e.walletClientType)&&(await r.storage?.removeItem("io.privy.wallet.disconnected"),l())}}),(0,a.useEffect)(()=>{e&&(async()=>{let n=e({wallets:t,user:i});if(!n)return(e=>{e._internal.connectors.setState([]),e.setState(e=>({chainId:e.chainId,connections:new Map,current:null,status:"disconnected"}))})(r),l();let[a]=await u([n],r);a?(await h(n,a,r),l()):console.error(`Failed to setup connector for ${n.address}`)})()},[t,i,e]),(0,a.useEffect)(()=>{e||u(t,r).then(()=>{n&&l()})},[t,!e,n])})({setActiveWalletForWagmi:t}),(0,i.jsx)(i.Fragment,{children:e})),m=({children:e,setActiveWalletForWagmi:t,...n})=>(0,i.jsx)(r.x,{reconnectOnMount:!1,...n,children:(0,i.jsx)(p,{setActiveWalletForWagmi:t,children:e})})},656189:e=>{e.exports=function(e){return function(t){return null==e?void 0:e[t]}}},663272:(e,t,n)=>{"use strict";n.d(t,{m:()=>i});let i={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}}},664419:(e,t,n)=>{"use strict";n.d(t,{d:()=>s});var i=n(966055),r=n(526919),a=n(538960);class s extends i.c{constructor({disableMetaMask:e}={}){super({wallet:new a.g}),e||(0,r.R)()}}},675708:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});let i={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-mainnet.rpc.privy.systems"]},blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}}}},677987:(e,t,n)=>{"use strict";n.d(t,{V:()=>s});var i=n(797036),r=n(347220),a=n(944315);async function s(e,t){let{account:n=e.account}=t;if(!n)throw new r.T({docsPath:"/docs/eip7702/signAuthorization"});let s=(0,i.J)(n);if(!s.signAuthorization)throw new r.Z({docsPath:"/docs/eip7702/signAuthorization",metaMessages:["The `signAuthorization` Action does not support JSON-RPC Accounts."],type:s.type});let o=await (0,a.h)(e,t);return s.signAuthorization(o)}},683112:(e,t,n)=>{"use strict";n.d(t,{hl:()=>i});let i=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"accountAddress",type:"address"},{indexed:!1,internalType:"enum IContractDeployer.AccountNonceOrdering",name:"nonceOrdering",type:"uint8"}],name:"AccountNonceOrderingUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"accountAddress",type:"address"},{indexed:!1,internalType:"enum IContractDeployer.AccountAbstractionVersion",name:"aaVersion",type:"uint8"}],name:"AccountVersionUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"deployerAddress",type:"address"},{indexed:!0,internalType:"bytes32",name:"bytecodeHash",type:"bytes32"},{indexed:!0,internalType:"address",name:"contractAddress",type:"address"}],name:"ContractDeployed",type:"event"},{inputs:[{internalType:"bytes32",name:"_salt",type:"bytes32"},{internalType:"bytes32",name:"_bytecodeHash",type:"bytes32"},{internalType:"bytes",name:"_input",type:"bytes"}],name:"create",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"_salt",type:"bytes32"},{internalType:"bytes32",name:"_bytecodeHash",type:"bytes32"},{internalType:"bytes",name:"_input",type:"bytes"}],name:"create2",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"_salt",type:"bytes32"},{internalType:"bytes32",name:"_bytecodeHash",type:"bytes32"},{internalType:"bytes",name:"_input",type:"bytes"},{internalType:"enum IContractDeployer.AccountAbstractionVersion",name:"_aaVersion",type:"uint8"}],name:"create2Account",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes32",name:"_bytecodeHash",type:"bytes32"},{internalType:"bytes",name:"_input",type:"bytes"},{internalType:"enum IContractDeployer.AccountAbstractionVersion",name:"_aaVersion",type:"uint8"}],name:"createAccount",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"_address",type:"address"}],name:"extendedAccountVersion",outputs:[{internalType:"enum IContractDeployer.AccountAbstractionVersion",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_keccak256BytecodeHash",type:"bytes32"}],name:"forceDeployKeccak256",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"bytecodeHash",type:"bytes32"},{internalType:"address",name:"newAddress",type:"address"},{internalType:"bool",name:"callConstructor",type:"bool"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"input",type:"bytes"}],internalType:"struct ContractDeployer.ForceDeployment",name:"_deployment",type:"tuple"},{internalType:"address",name:"_sender",type:"address"}],name:"forceDeployOnAddress",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"bytecodeHash",type:"bytes32"},{internalType:"address",name:"newAddress",type:"address"},{internalType:"bool",name:"callConstructor",type:"bool"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"input",type:"bytes"}],internalType:"struct ContractDeployer.ForceDeployment[]",name:"_deployments",type:"tuple[]"}],name:"forceDeployOnAddresses",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"_address",type:"address"}],name:"getAccountInfo",outputs:[{components:[{internalType:"enum IContractDeployer.AccountAbstractionVersion",name:"supportedAAVersion",type:"uint8"},{internalType:"enum IContractDeployer.AccountNonceOrdering",name:"nonceOrdering",type:"uint8"}],internalType:"struct IContractDeployer.AccountInfo",name:"info",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_sender",type:"address"},{internalType:"uint256",name:"_senderNonce",type:"uint256"}],name:"getNewAddressCreate",outputs:[{internalType:"address",name:"newAddress",type:"address"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"_sender",type:"address"},{internalType:"bytes32",name:"_bytecodeHash",type:"bytes32"},{internalType:"bytes32",name:"_salt",type:"bytes32"},{internalType:"bytes",name:"_input",type:"bytes"}],name:"getNewAddressCreate2",outputs:[{internalType:"address",name:"newAddress",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"enum IContractDeployer.AccountAbstractionVersion",name:"_version",type:"uint8"}],name:"updateAccountVersion",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"enum IContractDeployer.AccountNonceOrdering",name:"_nonceOrdering",type:"uint8"}],name:"updateNonceOrdering",outputs:[],stateMutability:"nonpayable",type:"function"}]},683978:(e,t,n)=>{"use strict";n.d(t,{_:()=>r});var i=n(343750);let r=e=>e.map(e=>{if(e.rpcUrls.privyWalletOverride)return e;let t=i.m.find(t=>
72t.id===e.id),n=t?.rpcUrls.privy?.http[0];return n?function(e,t){return{...e,rpcUrls:{...e.rpcUrls,privy:{http:[t]}}}}(e,n):e})},690627:(e,t,n)=>{"use strict";n.d(t,{v:()=>r});var i=n(397118);function r({chain:e,currentChainId:t}){if(!e)throw new i.jF;if(t!==e.id)throw new i.EH({chain:e,currentChainId:t})}},691730:(e,t,n)=>{"use strict";n.d(t,{J8:()=>i,wd:()=>r});let i=[{type:"function",name:"initialize",inputs:[{name:"_rootValidator",type:"bytes21",internalType:"ValidationId"},{name:"hook",type:"address",internalType:"contract IHook"},{name:"validatorData",type:"bytes",internalType:"bytes"},{name:"hookData",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"}],r=[{type:"function",name:"initialize",inputs:[{name:"_rootValidator",type:"bytes21",internalType:"ValidationId"},{name:"hook",type:"address",internalType:"contract IHook"},{name:"validatorData",type:"bytes",internalType:"bytes"},{name:"hookData",type:"bytes",internalType:"bytes"},{name:"initConfig",type:"bytes[]",internalType:"bytes[]"}],outputs:[],stateMutability:"nonpayable"}]},695764:(e,t,n)=>{"use strict";n.d(t,{L:()=>o});var i=n(97644),r=n(654230),a=n(569993),s=n(129239);let o=({kernelVersion:e,callData:t})=>{if((0,s.c)(e)){let e=(0,i.J)({abi:a.V,data:t});if("executeBatch"===e.functionName)return e.args[0].map(e=>({to:e.to,value:e.value,data:e.data}));if("execute"===e.functionName){let[t,n,i]=e.args;return[{to:t,value:n,data:i}]}throw Error("Invalid function name")}return(0,r.w)(t).callData}},700660:(e,t,n)=>{"use strict";n.d(t,{t:()=>a});var i=n(649663),r=n(54492);function a(e){if("string"==typeof e){if(!(0,r.P)(e,{strict:!1}))throw new i.M({address:e});return{address:e,type:"json-rpc"}}if(!(0,r.P)(e.address,{strict:!1}))throw new i.M({address:e.address});return{address:e.address,nonceManager:e.nonceManager,sign:e.sign,signAuthorization:e.signAuthorization,signMessage:e.signMessage,signTransaction:e.signTransaction,signTypedData:e.signTypedData,source:"custom",type:"local"}}},704932:(e,t,n)=>{"use strict";n.d(t,{k:()=>l});var i=n(821196),r=n(87206),a=n(889810),s=n(518327),o=n(726122);async function l(e,t){async function n(t){if(t.endsWith(o.vB.slice(2))){let n=(0,r.B)((0,i.iN)(t,-64,-32)),s=(0,i.iN)(t,0,-64).slice(2).match(/.{1,64}/g),l=await Promise.all(s.map(t=>o.BH.slice(2)!==t?e.request({method:"eth_getTransactionReceipt",params:[`0x${t}`]},{dedupe:!0}):void 0)),c=l.some(e=>null===e)?100:l.every(e=>e?.status==="0x1")?200:l.every(e=>e?.status==="0x0")?500:600;return{atomic:!1,chainId:(0,a.ME)(n),receipts:l.filter(Boolean),status:c,version:"2.0.0"}}return e.request({method:"wallet_getCallsStatus",params:[t]})}let{atomic:l=!1,chainId:c,receipts:d,version:u="2.0.0",...h}=await n(t.id),[p,m]=(()=>{let e=h.status;return e>=100&&e<200?["pending",e]:e>=200&&e<300?["success",e]:e>=300&&e<700?["failure",e]:"CONFIRMED"===e?["success",200]:"PENDING"===e?["pending",100]:[void 0,e]})();return{...h,atomic:l,chainId:c?(0,a.ME)(c):void 0,receipts:d?.map(e=>({...e,blockNumber:(0,a.uU)(e.blockNumber),gasUsed:(0,a.uU)(e.gasUsed),status:s.Lj[e.status]}))??[],statusCode:m,status:p,version:u}}},707799:(e,t,n)=>{"use strict";n.d(t,{P:()=>a});var i=n(128897),r=n(620103);function a(e){var t;let n={};return void 0!==e.callData&&(n.callData=e.callData),void 0!==e.callGasLimit&&(n.callGasLimit=(0,i.cK)(e.callGasLimit)),void 0!==e.factory&&(n.factory=e.factory),void 0!==e.factoryData&&(n.factoryData=e.factoryData),void 0!==e.initCode&&(n.initCode=e.initCode),void 0!==e.maxFeePerGas&&(n.maxFeePerGas=(0,i.cK)(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=(0,i.cK)(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(n.nonce=(0,i.cK)(e.nonce)),void 0!==e.paymaster&&(n.paymaster=e.paymaster),void 0!==e.paymasterAndData&&(n.paymasterAndData=e.paymasterAndData||"0x"),void 0!==e.paymasterData&&(n.paymasterData=e.paymasterData),void 0!==e.paymasterPostOpGasLimit&&(n.paymasterPostOpGasLimit=(0,i.cK)(e.paymasterPostOpGasLimit)),void 0!==e.paymasterVerificationGasLimit&&(n.paymasterVerificationGasLimit=(0,i.cK)(e.paymasterVerificationGasLimit)),void 0!==e.preVerificationGas&&(n.preVerificationGas=(0,i.cK)(e.preVerificationGas)),void 0!==e.sender&&(n.sender=e.sender),void 0!==e.signature&&(n.signature=e.signature),void 0!==e.verificationGasLimit&&(n.verificationGasLimit=(0,i.cK)(e.verificationGasLimit)),void 0!==e.authorization&&(n.eip7702Auth={address:(t=e.authorization).address,chainId:(0,i.cK)(t.chainId),nonce:(0,i.cK)(t.nonce),r:t.r?(0,i.cK)(BigInt(t.r),{size:32}):(0,r.eV)("0x",{size:32}),s:t.s?(0,i.cK)(BigInt(t.s),{size:32}):(0,r.eV)("0x",{size:32}),yParity:t.yParity?(0,i.cK)(t.yParity,{size:1}):(0,r.eV)("0x",{size:32})}),n}}
72,709278:(e,t,n)=>{"use strict";n.d(t,{M:()=>a});var i=n(371137),r=n(752492);function a(e){let t=(0,r.S)(`0x${e.substring(4)}`).substring(26);return(0,i.o)(`0x${t}`)}},717556:(e,t,n)=>{var i=n(633370);e.exports=function(e){return i(e)&&e!=+e}},719638:(e,t,n)=>{"use strict";n.d(t,{l:()=>r});var i=n(991439);async function r({message:e,admin:t,accountAddress:n,chainId:r}){let a=(0,i.A)(e);return t.signTypedData({domain:{name:"Account",version:"1",chainId:r,verifyingContract:n},primaryType:"AccountMessage",types:{AccountMessage:[{name:"message",type:"bytes"}]},message:{message:a}})}},723505:(e,t,n)=>{"use strict";n.d(t,{Q:()=>c});var i=n(333625),r=n(607186),a=n(128897),s=n(559482),o=n(824413),l=n(129239);let c=(e,{accountAddress:t,kernelVersion:n,chainId:c})=>{let d=(0,o.KU)({domain:{name:"Kernel",version:n,chainId:c,verifyingContract:t}}),u=(0,l.c)(n)?e:(0,i.S)((0,r.h)([{type:"bytes32"},{type:"bytes32"}],[(0,i.S)((0,a.i3)("Kernel(bytes32 hash)")),e]));return(0,i.S)((0,s.aP)(["0x1901",d,u]))}},726122:(e,t,n)=>{"use strict";n.d(t,{BH:()=>p,vB:()=>h,yM:()=>m});var i=n(797036),r=n(125644),a=n(970684),s=n(352401),o=n(559482),l=n(889810),c=n(128897),d=n(637155),u=n(364591);let h="0x5792579257925792579257925792579257925792579257925792579257925792",p=(0,c.cK)(0,{size:32});async function m(e,t){let{account:n=e.account,capabilities:m,chain:y=e.chain,experimental_fallback:f,experimental_fallbackDelay:g=32,forceAtomic:w=!1,id:v,version:b="2.0.0"}=t,x=n?(0,i.J)(n):null,_=t.calls.map(e=>{let t=e.abi?(0,s.p)({abi:e.abi,functionName:e.functionName,args:e.args}):e.data;return{data:e.dataSuffix&&t?(0,o.xW)([t,e.dataSuffix]):t,to:e.to,value:e.value?(0,c.cK)(e.value):void 0}});try{let t=await e.request({method:"wallet_sendCalls",params:[{atomicRequired:w,calls:_,capabilities:m,chainId:(0,c.cK)(y.id),from:x?.address,id:v,version:b}]},{retryCount:0});if("string"==typeof t)return{id:t};return t}catch(n){if(f&&("MethodNotFoundRpcError"===n.name||"MethodNotSupportedRpcError"===n.name||"UnknownRpcError"===n.name||n.details.toLowerCase().includes("does not exist / is not available")||n.details.toLowerCase().includes("missing or invalid. request()")||n.details.toLowerCase().includes("did not match any variant of untagged enum")||n.details.toLowerCase().includes("account upgraded to unsupported contract")||n.details.toLowerCase().includes("eip-7702 not supported")||n.details.toLowerCase().includes("unsupported wc_ method")||n.details.toLowerCase().includes("feature toggled misconfigured"))){if(m&&Object.values(m).some(e=>!e.optional)){let e="non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";throw new a.L5(new r.C(e,{details:e}))}if(w&&_.length>1){let e="`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";throw new a.jz(new r.C(e,{details:e}))}let t=[];for(let n of _){let i=(0,u.v)(e,{account:x,chain:y,data:n.data,to:n.to,value:n.value?(0,l.uU)(n.value):void 0});t.push(i),g>0&&await new Promise(e=>setTimeout(e,g))}let n=await Promise.allSettled(t);if(n.every(e=>"rejected"===e.status))throw n[0].reason;let i=n.map(e=>"fulfilled"===e.status?e.value:p);return{id:(0,o.xW)([...i,(0,c.cK)(y.id,{size:32}),h])}}throw(0,d.p)(n,{...t,account:x,chain:t.chain})}}},730720:(e,t,n)=>{"use strict";function i(e){if("string"==typeof e&&""!==e)return encodeURIComponent(e);if("number"==typeof e||"boolean"==typeof e)return encodeURIComponent(e.toString());if(Array.isArray(e)||"object"==typeof e||null===e)return encodeURIComponent(JSON.stringify(e));throw Error("only null, non-empty string, number, boolean, array, and object are able to be encoded")}function r(e){let t=[];for(let[n,r]of Object.entries(e))void 0===r||""===r?t.push(n):t.push(`${n}=${i(r)}`);let n=`?${t.join("&")}`;return"?"===n?"":n}function a(e){if(void 0===e)return e;try{return JSON.parse(decodeURIComponent(e))}catch(t){return e}}function s(e){let t={};for(let[n,i]of Object.entries(e))t[n]=Array.isArray(i)?i.map(a):a(i);return t}function o(e,t){let n=e.split("/").map(e=>{var t;return(t=e).startsWith("[")&&t.endsWith("]")&&!t.includes("...")?{type:"dynamic",value:t.slice(1,-1)}:t.startsWith("[[")&&t.endsWith("]]")&&t.includes("...")?{type:"optionalCatchAll",value:t.slice(5,-2)}:t.startsWith("[")&&t.endsWith("]")&&t.includes("...")?{type:"catchAll",value:t.slice(4,-1)}:{type:"static",value:t}}),r=[];for(let e of n)if("static"===e.type)r.push(e.value);else if("dynamic"===e.type){let n=t[e.value];if(void 0!==n)r.push(i(n));else throw Error(`Missing value for dynamic segment "${e.value}"`)}else if("catchAll"===e.type){let n=t[e.value];if(Array.isArray(n))r.push(...n.map(e=>i(e)));else if(void 0!==n)r.push(i(n));else throw Error(`Missing value for catch-all segment "${e.value}"`)}else if("optionalCatchAll"===e.type){let n=t[e.value];Array.isArray(n)?r.push(...n.map(e=>i(e))):void 0!==n&&r.push(i(n))}return r.join("/")}n.d(t,{dJ:()=>r,mF:()=>o,td:()=>s})}
72,737958:(e,t,n)=>{"use strict";n.d(t,{GK:()=>i,H_:()=>r,xh:()=>a});let i={path:"/api/v1/wallets",method:"POST"},r={path:"/api/v1/wallets/:wallet_id/rpc",method:"POST"},a={path:"/api/v1/wallets/revoke",method:"POST"}},738344:(e,t,n)=>{"use strict";n.d(t,{g:()=>r});var i=n(843341);class r extends i.C{constructor({value:e}){super(`Number \`${e}\` is not a valid decimal number.`,{name:"InvalidDecimalNumberError"})}}},738417:(e,t,n)=>{"use strict";n.d(t,{aD:()=>a});var i=n(479656),r=n(448398);function a(e){if(130!==e.length&&132!==e.length)throw new s({signature:e});let t=BigInt(r.di(e,0,32)),n=BigInt(r.di(e,32,64)),i=(()=>{let t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{var n=t;if(0===n||27===n)return 0;if(1===n||28===n)return 1;if(n>=35)return+(n%2==0);throw new l({value:n})}catch{throw new o({value:t})}})();return void 0===i?{r:t,s:n}:{r:t,s:n,yParity:i}}n(491803);class s extends i.C{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${r.Ej(r.HT(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}i.C,i.C,i.C;class o extends i.C{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class l extends i.C{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}},738829:(e,t,n)=>{"use strict";n.d(t,{s:()=>s});var i=n(787944),r=n(128897),a=n(849319);function s({type:e,revertOnError:t,selector:n,context:s}){return(0,i.P)(["bytes1","bytes1","bytes4","bytes4","bytes22"],[(0,r.nj)((0,a.ZJ)(function(e){switch(e){case"call":return"0x00";case"batchcall":return"0x01";case"delegatecall":return"0xff"}}(e),{size:1})),(0,r.nj)((0,a.ZJ)(t?"0x01":"0x00",{size:1})),(0,r.nj)((0,a.ZJ)("0x0",{size:4})),(0,r.nj)((0,a.ZJ)(n??"0x",{size:4})),(0,r.nj)((0,a.ZJ)(s??"0x",{size:22}))])}},744104:(e,t,n)=>{"use strict";n.d(t,{P:()=>o});var i=n(523347),r=n(469080),a=n(444881),s=n(443864);function o(){return e=>({sendTransaction:t=>(0,a.v)(e,t),signTransaction:t=>(0,s.W)(e,t),deployContract:t=>(0,r.c)(e,t),writeContract:t=>(0,i.E)(Object.assign(e,{sendTransaction:t=>(0,a.v)(e,t)}),t)})}},749067:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});let i=async e=>{let t=await e.request({method:"pimlico_getUserOperationGasPrice",params:[]});return{slow:{maxFeePerGas:BigInt(t.slow.maxFeePerGas),maxPriorityFeePerGas:BigInt(t.slow.maxPriorityFeePerGas)},standard:{maxFeePerGas:BigInt(t.standard.maxFeePerGas),maxPriorityFeePerGas:BigInt(t.standard.maxPriorityFeePerGas)},fast:{maxFeePerGas:BigInt(t.fast.maxFeePerGas),maxPriorityFeePerGas:BigInt(t.fast.maxPriorityFeePerGas)}}}},749397:(e,t,n)=>{"use strict";n.d(t,{p:()=>a});var i=n(529533),r=n(603181);let a=async(e,t)=>{let{address:n,entryPointAddress:a,key:s=BigInt(0)}=t;return await (0,r.T)(e,i.J,"readContract")({address:a,abi:[{inputs:[{name:"sender",type:"address"},{name:"key",type:"uint192"}],name:"getNonce",outputs:[{name:"nonce",type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"getNonce",args:[n,s]})}},752492:(e,t,n)=>{"use strict";n.d(t,{S:()=>o});var i=n(450405),r=n(12518),a=n(854),s=n(591260);function o(e,t){let n=(0,i.lY)((0,r.q)(e,{strict:!1})?(0,a.ZJ)(e):e);return"bytes"===(t||"hex")?n:(0,s.nj)(n)}},753346:(e,t,n)=>{"use strict";n.d(t,{c:()=>a});var i=n(266431),r=n(364591);function a(e,t){let{abi:n,args:a,bytecode:s,...o}=t,l=(0,i.m)({abi:n,args:a,bytecode:s});return(0,r.v)(e,{...o,...o.authorizationList?{to:null}:{},data:l})}},755582:(e,t,n)=>{"use strict";n.d(t,{KO:()=>E,MF:()=>_,Sx:()=>I,Wp:()=>C,j6:()=>w,om:()=>g,xZ:()=>v});var i=n(842071),r=n(89606),a=n(125281),s=n(825833);class o{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(!function(e){let t=e.getComponent();return(null==t?void 0:t.type)==="VERSION"}(e))return null;{let t=e.getImmediate();return`${t.library}/${t.version}`}}).filter(e=>e).join(" ")}}let l="@firebase/app",c="0.13.2",d=new r.Vy("@firebase/app"),u="[DEFAULT]",h={[l]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/data-connect":"fire-data-connect","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","@firebase/ai":"fire-vertex","fire-js":"fire-js",firebase:"fire-js-all"},p=new Map,m=new Map,y=new Map;function f(e,t){try{e.container.addComponent(t)}catch(n){d.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function g(e){let t=e.name;if(y.has(t))return d.debug(`There were multiple attempts to register component ${t}.`),!1;
72for(let n of(y.set(t,e),p.values()))f(n,e);for(let t of m.values())f(t,e);return!0}function w(e,t){let n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function v(e){return null!=e&&void 0!==e.settings}let b=new a.FA("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});class x{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new i.uA("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw b.create("app-deleted",{appName:this._name})}}let _="11.10.0";function C(e,t={}){let n=e;"object"!=typeof t&&(t={name:t});let r=Object.assign({name:u,automaticDataCollectionEnabled:!0},t),s=r.name;if("string"!=typeof s||!s)throw b.create("bad-app-name",{appName:String(s)});if(n||(n=(0,a.T9)()),!n)throw b.create("no-options");let o=p.get(s);if(o)if((0,a.bD)(n,o.options)&&(0,a.bD)(r,o.config))return o;else throw b.create("duplicate-app",{appName:s});let l=new i.h1(s);for(let e of y.values())l.addComponent(e);let c=new x(n,r,l);return p.set(s,c),c}function I(e=u){let t=p.get(e);if(!t&&e===u&&(0,a.T9)())return C();if(!t)throw b.create("no-app",{appName:e});return t}function E(e,t,n){var r;let a=null!=(r=h[e])?r:e;n&&(a+=`-${n}`);let s=a.match(/\s|\//),o=t.match(/\s|\//);if(s||o){let e=[`Unable to register library "${a}" with version "${t}":`];s&&e.push(`library name "${a}" contains illegal characters (whitespace or "/")`),s&&o&&e.push("and"),o&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),d.warn(e.join(" "));return}g(new i.uA(`${a}-version`,()=>({library:a,version:t}),"VERSION"))}let T="firebase-heartbeat-store",A=null;function S(){return A||(A=(0,s.P2)("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(T)}catch(e){console.warn(e)}}}).catch(e=>{throw b.create("idb-open",{originalErrorMessage:e.message})})),A}async function k(e){try{let t=(await S()).transaction(T),n=await t.objectStore(T).get(j(e));return await t.done,n}catch(e){if(e instanceof a.g)d.warn(e.message);else{let t=b.create("idb-get",{originalErrorMessage:null==e?void 0:e.message});d.warn(t.message)}}}async function P(e,t){try{let n=(await S()).transaction(T,"readwrite"),i=n.objectStore(T);await i.put(t,j(e)),await n.done}catch(e){if(e instanceof a.g)d.warn(e.message);else{let t=b.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});d.warn(t.message)}}}function j(e){return`${e.name}!${e.options.appId}`}class O{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider("app").getImmediate();this._storage=new R(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){var e,t;try{let n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=N();if((null==(e=this._heartbeatsCache)?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,(null==(t=this._heartbeatsCache)?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(e=>e.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:n}),this._heartbeatsCache.heartbeats.length>30){let e=function(e){if(0===e.length)return -1;let t=0,n=e[0].date;for(let i=1;i<e.length;i++)e[i].date<n&&(n=e[i].date,t=i);return t}(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){d.warn(e)}}async getHeartbeatsHeader(){var e;try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,(null==(e=this._heartbeatsCache)?void 0:e.heartbeats)==null||0===this._heartbeatsCache.heartbeats.length)return"";let t=N(),{heartbeatsToSend:n,unsentEntries:i}=function(e,t=1024){let n=[],i=e.slice();for(let r of e){let e=n.find(e=>e.agent===r.agent);if(e){if(e.dates.push(r.date),M(n)>t){e.dates.pop();break}}else if(n.push({agent:r.agent,dates:[r.date]}),M(n)>t){n.pop();break}i=i.slice(1)}return{heartbeatsToSend:n,unsentEntries:i}}(this._heartbeatsCache.heartbeats),r=(0,a.Uj)(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=t,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}catch(e){return d.warn(e),""}}}function N(){return new Date().toISOString().substring(0,10)}class R{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!(0,a.zW)()&&(0,a.eX)().then(()=>!0).catch(()=>!1)}async read(){if(!await this._canUseIndexedDBPromise)return{heartbeats:[]};{let e=await k(this.app);return(null==e?void 0:e.heartbeats)?e:{heartbeats:[]}}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){let n=await this.read();return P(this.app,{lastSentHeartbeatDate:null!=(t=e.lastSentHeartbeatDate)?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){let n=await this.read();return P(this.app,{lastSentHeartbeatDate:null!=(t=e.lastSentHeartbeatDate)?t:n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...e.heartbeats]})}}}function M(e){return(0,a.Uj)(JSON.stringify({version:2,heartbeats:e})).length}g(new i.uA("platform-logger",e=>new o(e),"PRIVATE")),g(new i.uA("heartbeat",e=>new O(e),"PRIVATE")),E(l,c,""),E(l,c,"esm2017"),E("fire-js","")},756924:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});let i={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol
72:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1}},763105:(e,t,n)=>{"use strict";n.d(t,{b:()=>T,R:()=>A});var i=n(350979),r=n(25963),a=n(161877),s=n(105493),o=n(34228);function l(e){return e.find(e=>"privy"===e.walletClientType&&"embedded"===e.connectorType&&!e.imported)??null}var c=n(703260),d=n(760401),u=n(631930),h=n(504283),p=n(488792),m=n(38316),y=n(172034),f=n(269470),g=n(950588),w=n(455535),v=n(174562),b=n(47668);let x={address:v.B9,version:"0.6"},_={address:v.oi,version:"0.7"},C=({calls:e,chain:t,maxPriorityFeePerGas:n,maxFeePerGas:i,nonce:r})=>e.map(e=>({to:e.to||void 0,data:e.data,value:e.value,chainId:t.id,nonce:r,maxFeePerGas:i,maxPriorityFeePerGas:n})),I=async({chain:e,paymasterContext:t,account:n,signer:i,user:r,smartWalletsConfig:a,rpcConfig:l,privyAppId:u})=>{if(!(a?.enabled&&r&&n&&i))return;let v=a?.configuredNetworks.find(t=>t.chainId===`eip155:${e.id}`);if(!v)throw new o.P(`The chain ${e.name} (eip155:${e.id}) must be configured in the smart wallet configuration in your dashboard`);let C=r.smartWallet?.smartWalletType??a.smartWalletType,I=(0,s.q)(e,l,u),E=(0,c.l)({chain:e,transport:(0,d.L)(I)}),T=t??v.paymasterContext,A=await (async({owner:e,smartWalletType:t,chain:n,publicClient:i,bundlerUrl:r,paymasterUrl:a,paymasterContext:s})=>{let o=await (({owner:e,smartWalletType:t,publicClient:n})=>{switch(t){case"safe":return(0,p.X$)({client:n,entryPoint:_,owners:[e],version:"1.4.1"});case"kernel":return(0,m.lm)({client:n,version:"0.3.1",entryPoint:_,useMetaFactory:"optional",owners:[e]});case"biconomy":return(0,y.c)({client:n,owners:[e],entryPoint:x});case"light_account":return(0,f.k)({client:n,entryPoint:x,owner:e,version:"1.1.0"});case"coinbase_smart_wallet":return async function({client:e,owner:t}){let[n]=await t.request({method:"eth_accounts"});if(!n)throw Error("Unable to request embedded owner for eth_accounts");return await (0,b.EP)({client:e,owners:[{type:"local",source:"privy",address:n,sign:async({hash:e})=>await t.request({method:"secp256k1_sign",params:[e]})}]})}({client:n,owner:e});case"thirdweb":return(0,g.L)({client:n,entryPoint:_,owner:e});default:throw Error(`Invalid smart account type: ${t}.`)}})({owner:e,smartWalletType:t,publicClient:i}),l=(0,w.L)({transport:(0,d.L)(r),entryPoint:o.entryPoint}),c=a?(0,w.L)({transport:(0,d.L)(a),entryPoint:o.entryPoint}):void 0;return(0,h.o)({account:o,chain:n,paymaster:c,paymasterContext:s,bundlerTransport:(0,d.L)(r),userOperation:{estimateFeesPerGas:async()=>{if(["public.pimlico.io","api.pimlico.io"].some(e=>r.includes(e)))return await l.getUserOperationGasPrice().then(e=>e.fast);if(["rpc.zerodev.app"].some(e=>r.includes(e)))return(await l.request({method:"zd_getUserOperationGasPrice",params:[]})).fast;if(["g.alchemy.com"].some(e=>r.includes(e))){let[e,t]=await Promise.all([i.getBlock({blockTag:"latest"}),l.request({method:"rundler_maxPriorityFeePerGas",params:[]})]);if(!e.baseFeePerGas||!t)throw Error("Failed to get block or maxPriorityFeePerGasEstimate");return{maxFeePerGas:150n*e.baseFeePerGas/100n+BigInt(t.toString()),maxPriorityFeePerGas:BigInt(t.toString())}}{let e=await i.estimateFeesPerGas(),t=r.includes("api.developer.coinbase.com")?175n:150n;return{...e,maxFeePerGas:e.maxFeePerGas*t/100n,maxPriorityFeePerGas:e.maxPriorityFeePerGas*t/100n}}}}})})({owner:i,smartWalletType:C,chain:e,publicClient:E,paymasterContext:T,...v});if(!A)throw new o.P(`Failed to create smart wallet client for chain ${e.name} (eip155:${e.id})`);return A};n(800094),n(393569),n(582606),n(905433),n(557156),n(869964),n(999523);let E=(0,r.createContext)({client:void 0,getClientForChain:u.a}),T=({config:e,children:t})=>(0,i.jsx)(P,{children:(0,i.jsx)(j,{config:e,children:(0,i.jsx)(N,{children:t})})}),A=()=>{let{client:e,getClientForChain:t}=(0,r.useContext)(E);return{client:e,getClientForChain:t}},S=(0,r.createContext)({config:void 0}),k=()=>{let{config:e}=(0,r.useContext)(S);return{config:e}},P=({children:e})=>{let[t,n]=(0,r.useState)(void 0),{client:a}=(0,u.u)();return(0,r.useEffect)(()=>{!t&&a&&(async()=>{try{if(!a)return void console.warn("No client found");let e=await a.getSmartWalletsConfig();n(e)}catch(e){console.warn("Error generating smart wallet config: ",e)}})()},[!!a]),(0,i.jsx)(S.Provider,{value:{config:t},children:e})},j=({config:e,children:t})=>{let{config:n}=k(),{appId:c}=(0,u.u)(),{chains:d,defaultChain:h,rpcConfig:p}=(0,s.k)(),{wallets:m}=(0,s.p)(),{user:y}=(0,a.u)(),[f,g]=(0,r.useState)(),{wrapSmartAccountClientWithUIs:w}=(()=>{let{hideWalletUIs:e,openPrivyModal:t,isHeadlessSigning:n}=(0,u.u)(),{setModalData:i}=(0,s.e)(),{user:r}=(0,a.u)(),o=(0,a.g)(r),l=!!o&&(0,a.c)(o);return{wrapSmartAccountClientWithUIs:a=>({...a,sendTransaction:async(c,d)=>
72{if(n({showWalletUIs:d?.uiOptions?.showWalletUIs}))return e.current=!0,await a.sendTransaction(c).finally(()=>e.current=!1);let u=[];"calls"in c&&void 0!==c.calls?u=[...c.calls]:"to"in c&&(u=[{to:c.to,value:c.value||BigInt(0),data:c.data||"0x"}]);let h=async()=>{if(!a.paymaster)return!1;let{paymasterData:e,paymasterAndData:t}=await a.prepareUserOperation({calls:u,maxFeePerGas:c.maxFeePerGas,maxPriorityFeePerGas:c.maxPriorityFeePerGas,nonce:c.nonce?BigInt(c.nonce):void 0});return Number(t??e??0)>0};return new Promise(async(n,p)=>{e.current=!0;let{entropyId:m,entropyIdVerifier:y}=(0,s.a)(r);i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,isUnifiedWallet:l,entropyId:m,entropyIdVerifier:y,onCompleteNavigateTo:s.aR,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:u,chain:a.chain,maxPriorityFeePerGas:c.maxPriorityFeePerGas,maxFeePerGas:c.maxFeePerGas,nonce:c.nonce?BigInt(c.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:a.account.address,entropyId:m,entropyIdVerifier:y,getIsSponsored:h,signOnly:!1,onConfirm:()=>a.sendTransaction(c),onSuccess:e=>n(e.hash),onFailure:p,uiOptions:d?.uiOptions??{}}}),t(s.aQ)}).finally(()=>{e.current=!1})},signMessage:async(c,d)=>n({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await a.signMessage(c).finally(()=>e.current=!1)):new Promise(async(n,u)=>{let{entropyId:h,entropyIdVerifier:p}=(0,s.a)(r);e.current=!0,i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,isUnifiedWallet:l,entropyId:h,entropyIdVerifier:p,onCompleteNavigateTo:s.aP,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof c.message?c.message:c.message.raw.toString(),confirmAndSign:()=>a.signMessage(c),onSuccess:e=>n(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(s.aQ)}).finally(()=>{e.current=!1}),signTypedData:async(c,d)=>n({showWalletUIs:d?.uiOptions?.showWalletUIs})?(e.current=!0,await a.signTypedData(c).finally(()=>e.current=!1)):new Promise(async(n,u)=>{e.current=!0;let{entropyId:h,entropyIdVerifier:p}=(0,s.a)(r);i({connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,isUnifiedWallet:l,entropyId:h,entropyIdVerifier:p,onCompleteNavigateTo:s.aP,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:c,confirmAndSign:()=>a.signTypedData(c),onSuccess:e=>n(e),onFailure:u,uiOptions:d?.uiOptions??{}}}),t(s.aQ)}).finally(()=>{e.current=!1})})}})(),v=(0,a.g)(y),b=l(m);return(0,r.useEffect)(()=>{(async()=>{if(!n?.enabled)return;let t=n.configuredNetworks.find(e=>e.chainId===`eip155:${h.id}`)?h:d.find(e=>n.configuredNetworks.map(e=>e.chainId).includes(`eip155:${e.id}`));if(!t)throw new o.P("Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.");g(await I({chain:t,privyAppId:c,paymasterContext:e?.paymasterContext,rpcConfig:p,account:v,signer:await b?.getEthereumProvider(),user:y,smartWalletsConfig:n}))})()},[!!n?.enabled,!!y?.smartWallet,!!b,!!v]),(0,i.jsx)(O.Provider,{value:{client:f,config:e,getClientForChain:async({id:t})=>{let i=await I({chain:d.find(e=>e.id===t),privyAppId:c,paymasterContext:e?.paymasterContext,rpcConfig:p,account:v,signer:await b?.getEthereumProvider(),user:y,smartWalletsConfig:n});if(!i)throw new o.P(`Failed to create smart wallet client for chain id: ${t}`);return w(i)}},children:t})},O=(0,r.createContext)({client:void 0,config:void 0,getClientForChain:u.a}),N=({children:e})=>{let{client:t,config:n,getClientForChain:c}=(()=>{let{client:e,config:t,getClientForChain:n}=(0,r.useContext)(O);return{client:e,config:t,getClientForChain:n}})(),{config:d}=k(),{wrapSmartAccountClient:h}=(({clientConfig:e,smartWalletsConfig:t})=>{let{hideWalletUIs:n,openPrivyModal:i,appId:c,isHeadlessSigning:d}=(0,u.u)(),h=(0,s.k)(),{setModalData:p}=(0,s.e)(),{user:m}=(0,a.u)(),{chains:y}=(0,s.k)(),{chainId:f,clients:g,setChainId:w,chainIdState:v}=(()=>{let e=(0,r.useRef)(),[t,n]=(0,r.useState)();return{clients:(0,r.useRef)({}),setChainId:t=>{e.current=t,n(t)},chainId:e,chainIdState:t}})(),b=y.find(e=>e.id===v),{wallets:x}=(0,s.p)(),_=(0,a.g)(m),E=l(x),T=!!_&&(0,a.c)(_),A=(0,r.useCallback)(async()=>f.current,[f]),S=(0,r.useCallback)(async({id:n})=>{if(!g.current[n]){let i=await I({chain:y.find(e=>e.id===n),account:_,signer:await E?.getEthereumProvider(),user:m,paymasterContext:e?.paymasterContext,smartWalletsConfig:t,rpcConfig:h.rpcConfig,privyAppId:c});i&&(g.current[n]=i)}w(n)},[y,e,x,m,t]);return{wrapSmartAccountClient:e=>(g.current[e.chain.id]=e,v||w(e.chain.id),{...e,sendTransaction:async(e,t)=>{let r=g.current[f.current];
72if(!r)throw new o.P(`Smart wallet client for chain (eip155:${f.current}) not found`);if(delete e.account,d({showWalletUIs:t?.uiOptions?.showWalletUIs}))return n.current=!0,await r.sendTransaction(e).finally(()=>n.current=!1);let a=[];"calls"in e&&void 0!==e.calls?a=[...e.calls]:"to"in e&&(a=[{to:e.to,value:e.value||BigInt(0),data:e.data||"0x"}]);let l=async()=>{let{paymasterAndData:t,paymasterData:n,maxFeePerGas:i,maxPriorityFeePerGas:s}=await r.prepareUserOperation({calls:a,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0});return 0===Number(i)&&0===Number(s)||Number(t??n??0)>0};return new Promise(async(o,c)=>{n.current=!0;let{entropyId:d,entropyIdVerifier:u}=(0,s.a)(m);p({connectWallet:{recoveryMethod:_.recoveryMethod,connectingWalletAddress:_.address,isUnifiedWallet:T,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:s.aR,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:a,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),transactingWalletIndex:0,transactingWalletAddress:r.account.address,entropyId:d,entropyIdVerifier:u,getIsSponsored:l,signOnly:!1,onConfirm:()=>r.sendTransaction(e),onSuccess:e=>o(e.hash),onFailure:c,uiOptions:t?.uiOptions??{}}}),i(s.aQ)}).finally(()=>{n.current=!1})},signMessage:async(e,t)=>{let r=g.current[f.current];if(!r)throw new o.P(`Smart wallet client for chain (eip155:${f.current}) not found`);return d({showWalletUIs:t?.uiOptions?.showWalletUIs})?(n.current=!0,await r.signMessage(e).finally(()=>n.current=!1)):new Promise(async(a,o)=>{let{entropyId:l,entropyIdVerifier:c}=(0,s.a)(m);n.current=!0,p({connectWallet:{recoveryMethod:_.recoveryMethod,connectingWalletAddress:_.address,isUnifiedWallet:T,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:s.aP,onFailure:()=>{}},signMessage:{method:"personal_sign",data:"string"==typeof e.message?e.message:e.message.raw.toString(),confirmAndSign:()=>r.signMessage(e),onSuccess:e=>a(e),onFailure:o,uiOptions:t?.uiOptions??{}}}),i(s.aQ)}).finally(()=>{n.current=!1})},signTypedData:async(e,t)=>{let r=g.current[f.current];if(!r)throw new o.P(`Smart wallet client for chain (eip155:${f.current}) not found`);return delete e.account,d({showWalletUIs:t?.uiOptions?.showWalletUIs})?(n.current=!0,await r.signTypedData(e).finally(()=>n.current=!1)):new Promise(async(a,o)=>{n.current=!0;let{entropyId:l,entropyIdVerifier:c}=(0,s.a)(m);p({connectWallet:{recoveryMethod:_.recoveryMethod,connectingWalletAddress:_.address,isUnifiedWallet:T,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:s.aP,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>a(e),onFailure:o,uiOptions:t?.uiOptions??{}}}),i(s.aQ)}).finally(()=>{n.current=!1})},getChainId:A,chain:b,switchChain:S})}})({clientConfig:n,smartWalletsConfig:d}),{user:p}=(0,a.u)(),{generateSiweMessageForSmartWallet:m,linkSmartWallet:y,hideWalletUIs:f}=(0,u.u)();return(0,r.useEffect)(()=>{(async()=>{if(t&&p&&!p?.smartWallet&&d?.enabled)try{let e=await m({address:t.account.address,chainId:`eip155:${t.chain.id}`});f.current=!0;let n=await t.signMessage({message:e});await y({signature:n,message:e,smartWalletType:d.smartWalletType})}catch(e){console.error("Error creating smart wallet:",e)}finally{f.current=!1}})()},[!!t,!!p?.smartWallet,!!d?.enabled]),(0,i.jsx)(E.Provider,{value:{client:p?.smartWallet&&t?h(t):void 0,getClientForChain:c},children:e})}},764014:(e,t,n)=>{"use strict";async function i(e,t){return await e.request({method:"wallet_watchAsset",params:t},{retryCount:0})}n.d(t,{w:()=>i})},775576:(e,t,n)=>{"use strict";n.d(t,{I:()=>i});let i="0x6492649264926492649264926492649264926492649264926492649264926492"},776144:(e,t,n)=>{"use strict";n.d(t,{E:()=>r});var i=n(12518);function r(e){return(0,i.q)(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}},778401:(e,t,n)=>{"use strict";n.d(t,{C:()=>a});let i="2.23.2",r={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${i}`};
72class a extends Error{constructor(e,t={}){let n=t.cause instanceof a?t.cause.details:t.cause?.message?t.cause.message:t.details,s=t.cause instanceof a&&t.cause.docsPath||t.docsPath,o=r.getDocsUrl?.({...t,docsPath:s});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...o?[`Docs: ${o}`]:[],...n?[`Details: ${n}`]:[],...r.version?[`Version: ${r.version}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=s,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=i}walk(e){return function e(t,n){return n?.(t)?t:t&&"object"==typeof t&&"cause"in t&&void 0!==t.cause?e(t.cause,n):n?null:t}(this,e)}}},787288:(e,t,n)=>{var i=n(224813),r=n(980544);e.exports=function(e,t,n){return e&&e.length?i(e,0,(t=n||void 0===t?1:r(t))<0?0:t):[]}},787944:(e,t,n)=>{"use strict";n.d(t,{P:()=>d});var i=n(70061),r=n(649663),a=n(54492),s=n(559482),o=n(620103),l=n(128897),c=n(741336);function d(e,t){if(e.length!==t.length)throw new i.YE({expectedLength:e.length,givenLength:t.length});let n=[];for(let d=0;d<e.length;d++){let u=e[d],h=t[d];n.push(function e(t,n,d=!1){if("address"===t){if(!(0,a.P)(n))throw new r.M({address:n});return(0,o.eV)(n.toLowerCase(),{size:d?32:null})}if("string"===t)return(0,l.i3)(n);if("bytes"===t)return n;if("bool"===t)return(0,o.eV)((0,l.$P)(n),{size:d?32:1});let u=t.match(c.Ge);if(u){let[e,t,i="256"]=u,r=Number.parseInt(i,10)/8;return(0,l.cK)(n,{size:d?32:r,signed:"int"===t})}let h=t.match(c.BD);if(h){let[e,t]=h;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new i.BI({expectedSize:Number.parseInt(t,10),givenSize:(n.length-2)/2});return(0,o.eV)(n,{dir:"right",size:d?32:null})}let p=t.match(c.D5);if(p&&Array.isArray(n)){let[t,i]=p,r=[];for(let t=0;t<n.length;t++)r.push(e(i,n[t],!0));return 0===r.length?"0x":(0,s.aP)(r)}throw new i.Wl(t)}(u,h))}return(0,s.aP)(n)}},788557:(e,t,n)=>{"use strict";n.d(t,{Lt:()=>r,Z2:()=>i});let i="0x0000000000000000000000000000000000008006",r="0x0000000000000000000000000000000000010000"},788882:(e,t,n)=>{"use strict";n.d(t,{RZ:()=>u});var i=n(559482),r=n(22941),a=n(620103),s=n(821196),o=n(849319),l=n(850666),c=n(333625),d=n(225572);function u(e){return"CREATE2"===e.opcode?function(e){let t=(0,o.ZJ)((0,d.b)(e.from)),n=(0,a.eV)((0,r.a)(e.salt)?e.salt:(0,o.ZJ)(e.salt),{size:32}),l="bytecodeHash"in e?(0,r.a)(e.bytecodeHash)?e.bytecodeHash:(0,o.ZJ)(e.bytecodeHash):(0,c.S)(e.bytecode,"bytes");return(0,d.b)((0,s.di)((0,c.S)((0,i.xW)([(0,o.ZJ)("0xff"),t,n,l])),12))}(e):function(e){let t=(0,o.ZJ)((0,d.b)(e.from)),n=(0,o.ZJ)(e.nonce);return 0===n[0]&&(n=new Uint8Array([])),(0,d.b)(`0x${(0,c.S)((0,l.EQ)([t,n],"bytes")).slice(26)}`)}(e)}},790357:(e,t,n)=>{"use strict";n.d(t,{L:()=>i});let i={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}}},790518:(e,t,n)=>{"use strict";n.d(t,{a:()=>i});let i={id:0x3b9ac9ff,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0}},799851:e=>{var t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;e.exports=function(e){return t.test(e)}},808725:(e,t,n)=>{"use strict";n.d(t,{C:()=>s});var i=n(824413),r=n(886834),a=n(607186);async function s(e){let{admin:t,accountAddress:n,chainId:s,...o}=e;if(o.domain?.verifyingContract?.toLowerCase()===n)return t.signTypedData({...o});let{message:l,primaryType:c,types:d,domain:u}=o,h={EIP712Domain:(0,i.H4)({domain:u}),...d};(0,i.$$)({domain:u,message:l,primaryType:c,types:h});let p=(0,r.Zh)({message:l,primaryType:c,types:h,domain:u}),m=(0,a.h)([{type:"bytes32"}],[p]);return t.signTypedData({domain:{name:"Account",version:"1",chainId:s,verifyingContract:n},primaryType:"AccountMessage",types:{AccountMessage:[{name:"message",type:"bytes"}]},message:{message:m}}
72)}},811021:e=>{e.exports=function(e){return void 0===e}},814001:(e,t,n)=>{"use strict";n.d(t,{hw:()=>i,qe:()=>r});let i=[{inputs:[{name:"preOpGas",type:"uint256"},{name:"paid",type:"uint256"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"targetSuccess",type:"bool"},{name:"targetResult",type:"bytes"}],name:"ExecutionResult",type:"error"},{inputs:[{name:"opIndex",type:"uint256"},{name:"reason",type:"string"}],name:"FailedOp",type:"error"},{inputs:[{name:"sender",type:"address"}],name:"SenderAddressResult",type:"error"},{inputs:[{name:"aggregator",type:"address"}],name:"SignatureValidationFailed",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"}],name:"ValidationResult",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"},{components:[{name:"aggregator",type:"address"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"stakeInfo",type:"tuple"}],name:"aggregatorInfo",type:"tuple"}],name:"ValidationResultWithAggregation",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"factory",type:"address"},{indexed:!1,name:"paymaster",type:"address"}],name:"AccountDeployed",type:"event"},{anonymous:!1,inputs:[],name:"BeforeExecution",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalDeposit",type:"uint256"}],name:"Deposited",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"aggregator",type:"address"}],name:"SignatureAggregatorChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalStaked",type:"uint256"},{indexed:!1,name:"unstakeDelaySec",type:"uint256"}],name:"StakeLocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawTime",type:"uint256"}],name:"StakeUnlocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"StakeWithdrawn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!0,name:"paymaster",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"success",type:"bool"},{indexed:!1,name:"actualGasCost",type:"uint256"},{indexed:!1,name:"actualGasUsed",type:"uint256"}],name:"UserOperationEvent",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"revertReason",type:"bytes"}],name:"UserOperationRevertReason",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"Withdrawn",type:"event"},{inputs:[],name:"SIG_VALIDATION_FAILED",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"},{name:"sender",type:"address"},{name:"paymasterAndData",type:"bytes"}],name:"_validateSenderAndPaymaster",outputs:[],stateMutability:"view",type:"function"},{inputs:[{name:"unstakeDelaySec",type:"uint32"}],name:"addStake",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"",type:"address"}],name:"deposits",outputs:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"getDepositInfo",outputs:[{components:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],name:"info",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{name:"sender",type:"address"},{name:"key",type:"uint192"}],name:"getNonce",outputs:[{name:"nonce",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"}],name:"getSenderAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOps",type:"tuple[]"},{name:"aggregator",type:"address"},{name:"signature",type:"bytes"}],name:"opsPerAggregator",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleAggregatedOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"ops",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"key",type:"uint192"}],name:"incrementNonce",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"callData",type:"bytes"},{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"paymaster",type:"address"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"}],name:"mUserOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"prefund",type:"uint256"},{name:"contextOffset",type:"uint256"},{name:"preOpGas",type:"uint256"}],name:"opInfo",type:"tuple"},{name:"context",type:"bytes"}],name:"innerHandleOp",outputs:[{name:"actualGasCost",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"",type:"address"},{name:"",type:"uint192"}],name:"nonceSequenceNumber",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"op",type:"tuple"},{name:"target",type:"address"},{name:"targetCallData",type:"bytes"}],name:"simulateHandleOp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"simulateValidation",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unlockStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"}],name:"withdrawStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"},{name:"withdrawAmount",type:"uint256"}],name:"withdrawTo",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}
72],r=[{inputs:[{name:"success",type:"bool"},{name:"ret",type:"bytes"}],name:"DelegateAndRevert",type:"error"},{inputs:[{name:"opIndex",type:"uint256"},{name:"reason",type:"string"}],name:"FailedOp",type:"error"},{inputs:[{name:"opIndex",type:"uint256"},{name:"reason",type:"string"},{name:"inner",type:"bytes"}],name:"FailedOpWithRevert",type:"error"},{inputs:[{name:"returnData",type:"bytes"}],name:"PostOpReverted",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[{name:"sender",type:"address"}],name:"SenderAddressResult",type:"error"},{inputs:[{name:"aggregator",type:"address"}],name:"SignatureValidationFailed",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"factory",type:"address"},{indexed:!1,name:"paymaster",type:"address"}],name:"AccountDeployed",type:"event"},{anonymous:!1,inputs:[],name:"BeforeExecution",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalDeposit",type:"uint256"}],name:"Deposited",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"revertReason",type:"bytes"}],name:"PostOpRevertReason",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"aggregator",type:"address"}],name:"SignatureAggregatorChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalStaked",type:"uint256"},{indexed:!1,name:"unstakeDelaySec",type:"uint256"}],name:"StakeLocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawTime",type:"uint256"}],name:"StakeUnlocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"StakeWithdrawn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!0,name:"paymaster",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"success",type:"bool"},{indexed:!1,name:"actualGasCost",type:"uint256"},{indexed:!1,name:"actualGasUsed",type:"uint256"}],name:"UserOperationEvent",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"nonce",type:"uint256"}],name:"UserOperationPrefundTooLow",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"revertReason",type:"bytes"}],name:"UserOperationRevertReason",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"Withdrawn",type:"event"},{inputs:[{name:"unstakeDelaySec",type:"uint32"}],name:"addStake",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"data",type:"bytes"}],name:"delegateAndRevert",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"",type:"address"}],name:"deposits",outputs:[{name:"deposit",type:"uint256"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"getDepositInfo",outputs:[{components:[{name:"deposit",type:"uint256"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],name:"info",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{name:"sender",type:"address"},{name:"key",type:"uint192"}],name:"getNonce",outputs:[{name:"nonce",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"}],name:"getSenderAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"accountGasLimits",type:"bytes32"},{name:"preVerificationGas",type:"uint256"},{name:"gasFees",type:"bytes32"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"accountGasLimits",type:"bytes32"},{name:"preVerificationGas",type:"uint256"},{name:"gasFees",type:"bytes32"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOps",type:"tuple[]"},{name:"aggregator",type:"address"},{name:"signature",type:"bytes"}],name:"opsPerAggregator",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleAggregatedOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"accountGasLimits",type:"bytes32"},{name:"preVerificationGas",type:"uint256"},{name:"gasFees",type:"bytes32"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"ops",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"key",type:"uint192"}],name:"incrementNonce",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"callData",type:"bytes"},{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"callGasLimit",type:"uint256"},{name:"paymasterVerificationGasLimit",type:"uint256"},{name:"paymasterPostOpGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"paymaster",type:"address"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"}],name:"mUserOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"prefund",type:"uint256"},{name:"contextOffset",type:"uint256"},{name:"preOpGas",type:"uint256"}],name:"opInfo",type:"tuple"},{name:"context",type:"bytes"}],name:"innerHandleOp",outputs:[{name:"actualGasCost",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"",type:"address"},{name:"",type:"uint192"}],name:"nonceSequenceNumber",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"unlockStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"}],name:"withdrawStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"},{name:"withdrawAmount",type:"uint256"}],name:"withdrawTo",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}]},815278:(e,t,n)=>{"use strict";n.d(t,{l:()=>a});var i=n(797036),r=n(155341);async function a(e,{account:t=e.account,message:n}){if(!t)throw new r.T({docsPath:"/docs/actions/wallet/signMessage"});return(0,i.J)(t).signMessage({message:n})}},828701:(e,t,n)=>{"use strict";n.d(t,{n:()=>i});let i={id:137,name:"Polygon Mainnet",network:"polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-mainnet.rpc.privy.systems"]},alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}}},841869:(e,t,n)=>{"use strict";n.d(t,{C:()=>l});var i=n(824413),r=n(886834),a=n(340335),s=n(624078),o=n(723505);async function l(e){let{owner:t,accountAddress:n,kernelVersion:l,chainId:c,...d}=e;if(("0.2.1"===l||"0.2.2"===l)&&!(0,a.W)(t))return t.signTypedData({...d});let{message:u,primaryType:h,types:p,domain:m}=d,y={EIP712Domain:(0,i.H4)({domain:m}),...p};(0,i.$$)({domain:m,message:u,primaryType:h,types:y});let f=(0,r.Zh)({message:u,primaryType:h,types:y,domain:m}),g=(0,o.Q)(f,{kernelVersion:l,accountAddress:n,chainId:c});return(0,a.W)(t)?(0,s.l)({message:{raw:g},owner:t,accountAddress:n,kernelVersion:l,chainId:c}):t.signMessage({message:{raw:g}})}},842071:(e,t,n)=>{"use strict";n.d(t,{h1:()=>o,uA:()=>r});var i=n(125281);
72class r{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}let a="[DEFAULT]";class s{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let e=new i.cY;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{let n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;let n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),i=null!=(t=null==e?void 0:e.optional)&&t;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(i)return null;throw e}if(i)return null;throw Error(`Service ${this.name} is not available`)}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if("EAGER"===e.instantiationMode)try{this.getOrInitializeService({instanceIdentifier:a})}catch(e){}for(let[e,t]of this.instancesDeferred.entries()){let n=this.normalizeInstanceIdentifier(e);try{let e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch(e){}}}}clearInstance(e=a){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=a){return this.instances.has(e)}getOptions(e=a){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let i=this.getOrInitializeService({instanceIdentifier:n,options:t});for(let[e,t]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(e)&&t.resolve(i);return i}onInit(e,t){var n;let i=this.normalizeInstanceIdentifier(t),r=null!=(n=this.onInitCallbacks.get(i))?n:new Set;r.add(e),this.onInitCallbacks.set(i,r);let a=this.instances.get(i);return a&&e(a,i),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){let n=this.onInitCallbacks.get(t);if(n)for(let i of n)try{i(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){var n;let i=this.instances.get(e);if(!i&&this.component&&(i=this.component.instanceFactory(this.container,{instanceIdentifier:(n=e)===a?void 0:n,options:t}),this.instances.set(e,i),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(i,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,i)}catch(e){}return i||null}normalizeInstanceIdentifier(e=a){return this.component?this.component.multipleInstances?e:a:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class o{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let t=this.getProvider(e.name);if(t.isComponentSet())throw Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);let t=new s(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}},851318:(e,t,n)=>{"use strict";n.d(t,{Fl:()=>r});var i=n(778401);i.C;class r extends i.C{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}i.C},853667:(e,t,n)=>{e.exports=n(894277)(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]})},856935:(e,t,n)=>{"use strict";n.d(t,{g:()=>r});var i=n(125644);class r extends i.C{constructor({value:e}){super(`Number \`${e}\` is not a valid decimal number.`,{name:"InvalidDecimalNumberError"})}}},857658:(e,t,n)=>{e.exports=n(656189)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"})}
vendor: 2,273 bytes, line 72
72,865449:(e,t,n)=>{"use strict";n.d(t,{l:()=>s});var i=n(889810),r=n(128897),a=n(707799);async function s(e,t){let{chainId:n,entryPointAddress:s,context:o,...l}=t,c=(0,a.P)(l),{paymasterPostOpGasLimit:d,paymasterVerificationGasLimit:u,...h}=await e.request({method:"pm_getPaymasterData",params:[{...c,callGasLimit:c.callGasLimit??"0x0",verificationGasLimit:c.verificationGasLimit??"0x0",preVerificationGas:c.preVerificationGas??"0x0"},s,(0,r.cK)(n),o]});return{...h,...d&&{paymasterPostOpGasLimit:(0,i.uU)(d)},...u&&{paymasterVerificationGasLimit:(0,i.uU)(u)}}}},871883:(e,t,n)=>{"use strict";n.d(t,{ME:()=>o,Sl:()=>a,uU:()=>s});var i=n(37107),r=n(776144);function a(e,{size:t}){if((0,r.E)(e)>t)throw new i.u({givenSize:(0,r.E)(e),maxSize:t})}function s(e,t={}){let{signed:n}=t;t.size&&a(e,{size:t.size});let i=BigInt(e);if(!n)return i;let r=(e.length-2)/2;return i<=(1n<<8n*BigInt(r)-1n)-1n?i:i-BigInt(`0x${"f".padStart(2*r,"f")}`)-1n}function o(e,t={}){return Number(s(e,t))}},872282:(e,t,n)=>{"use strict";n.d(t,{u:()=>y});var i=n(797036),r=n(944315),a=n(946680),s=n(760483),o=n(347220),l=n(352401),c=n(559482),d=n(603181),u=n(865449),h=n(615633),p=n(996976);let m=["factory","fees","gas","paymaster","nonce","signature","authorization"];async function y(e,t){let n,{account:y=e.account,parameters:f=m,stateOverride:g}=t;if(!y)throw new o.T;let w=(0,i.J)(y),v=t.paymaster??e?.paymaster,b="string"==typeof v?v:void 0,{getPaymasterStubData:x,getPaymasterData:_}=(()=>{if(!0===v)return{getPaymasterStubData:t=>(0,d.T)(e,h.L,"getPaymasterStubData")(t),getPaymasterData:t=>(0,d.T)(e,u.l,"getPaymasterData")(t)};if("object"==typeof v){let{getPaymasterStubData:e,getPaymasterData:t}=v;return{getPaymasterStubData:t&&e?e:t,getPaymasterData:t&&e?t:void 0}}return{getPaymasterStubData:void 0,getPaymasterData:void 0}})(),C=t.paymasterContext?t.paymasterContext:e?.paymasterContext,I={...t,paymaster:b,sender:w.address},[E,T,A,S,k]=await Promise.all([(async()=>t.calls?w.encodeCalls(t.calls.map(e=>e.abi?{data:(0,l.p)(e),to:e.to,value:e.value}:e)):t.callData)(),(async()=>{if(!f.includes("factory"))return;if(t.initCode)return{initCode:t.initCode};if(t.factory&&t.factoryData)return{factory:t.factory,factoryData:t.factoryData};let{factory:e,factoryData:n}=await w.getFactoryArgs();
72return"0.6"===w.entryPoint.version?{initCode:e&&n?(0,c.xW)([e,n]):void 0}:{factory:e,factoryData:n}})(),(async()=>{if(f.includes("fees")){if("bigint"==typeof t.maxFeePerGas&&"bigint"==typeof t.maxPriorityFeePerGas)return I;if(e?.userOperation?.estimateFeesPerGas){let t=await e.userOperation.estimateFeesPerGas({account:w,bundlerClient:e,userOperation:I});return{...I,...t}}try{let n=e.client??e,i=await (0,d.T)(n,a._,"estimateFeesPerGas")({chain:n.chain,type:"eip1559"});return{maxFeePerGas:"bigint"==typeof t.maxFeePerGas?t.maxFeePerGas:BigInt(2n*i.maxFeePerGas),maxPriorityFeePerGas:"bigint"==typeof t.maxPriorityFeePerGas?t.maxPriorityFeePerGas:BigInt(2n*i.maxPriorityFeePerGas)}}catch{return}}})(),(async()=>{if(f.includes("nonce"))return"bigint"==typeof t.nonce?t.nonce:w.getNonce()})(),(async()=>{if(f.includes("authorization")){if("object"==typeof t.authorization)return t.authorization;if(w.authorization&&!await w.isDeployed())return{...await (0,r.h)(w.client,w.authorization),r:"0xfffffffffffffffffffffffffffffff000000000000000000000000000000000",s:"0x7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",yParity:1}}})()]);async function P(){return n||(e.chain?e.chain.id:n=await (0,d.T)(e,s.T,"getChainId")({}))}void 0!==E&&(I.callData=E),void 0!==T&&(I={...I,...T}),void 0!==A&&(I={...I,...A}),void 0!==S&&(I.nonce=S),void 0!==k&&(I.authorization=k),f.includes("signature")&&(void 0!==t.signature?I.signature=t.signature:I.signature=await w.getStubSignature(I)),"0.6"!==w.entryPoint.version||I.initCode||(I.initCode="0x");let j=!1;if(f.includes("paymaster")&&x&&!b&&!t.paymasterAndData){let{isFinal:e=!1,sponsor:t,...n}=await x({chainId:await P(),entryPointAddress:w.entryPoint.address,context:C,...I});j=e,I={...I,...n}}if("0.6"!==w.entryPoint.version||I.paymasterAndData||(I.paymasterAndData="0x"),f.includes("gas")){if(w.userOperation?.estimateGas){let e=await w.userOperation.estimateGas(I);I={...I,...e}}if(void 0===I.callGasLimit||void 0===I.preVerificationGas||void 0===I.verificationGasLimit||I.paymaster&&void 0===I.paymasterPostOpGasLimit||I.paymaster&&void 0===I.paymasterVerificationGasLimit){let t=await (0,d.T)(e,p.C,"estimateUserOperationGas")({account:w,callGasLimit:0n,preVerificationGas:0n,verificationGasLimit:0n,stateOverride:g,...I.paymaster?{paymasterPostOpGasLimit:0n,paymasterVerificationGasLimit:0n}:{},...I});I={...I,callGasLimit:I.callGasLimit??t.callGasLimit,preVerificationGas:I.preVerificationGas??t.preVerificationGas,verificationGasLimit:I.verificationGasLimit??t.verificationGasLimit,paymasterPostOpGasLimit:I.paymasterPostOpGasLimit??t.paymasterPostOpGasLimit,paymasterVerificationGasLimit:I.paymasterVerificationGasLimit??t.paymasterVerificationGasLimit}}}if(f.includes("paymaster")&&_&&!b&&!t.paymasterAndData&&!j){let e=await _({chainId:await P(),entryPointAddress:w.entryPoint.address,context:C,...I});I={...I,...e}}return delete I.calls,delete I.parameters,delete I.paymasterContext,"string"!=typeof I.paymaster&&delete I.paymaster,I}},873006:(e,t,n)=>{"use strict";n.d(t,{u:()=>a});var i=n(941703),r=n(878314);function a(e){let{r:t,s:n}=i.secp256k1.Signature.fromCompact(e.slice(2,130)),a=Number(`0x${e.slice(130)}`),[s,o]=(()=>{if(0===a||1===a)return[void 0,a];if(27===a)return[BigInt(a),0];if(28===a)return[BigInt(a),1];throw Error("Invalid yParityOrV value")})();return void 0!==s?{r:(0,r.cK)(t,{size:32}),s:(0,r.cK)(n,{size:32}),v:s,yParity:o}:{r:(0,r.cK)(t,{size:32}),s:(0,r.cK)(n,{size:32}),yParity:o}}},888491:e=>{e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},898745:(e,t,n)=>{"use strict";n.d(t,{V:()=>c});var i=n(603181),r=n(348059),a=n(750408),s=n(95190),o=n(976168),l=n(445185);function c(e,t){let{hash:n,pollingInterval:c=e.pollingInterval,retryCount:d,timeout:u=12e4}=t,h=0,p=(0,s.A)(["waitForUserOperationReceipt",e.uid,n]);return new Promise((t,s)=>{let m=(0,r.lB)(p,{resolve:t,reject:s},t=>{let r=e=>{s(),e(),m()},s=(0,a.w)(async()=>{d&&h>=d&&r(()=>t.reject(new o.Wm({hash:n})));try{let a=await (0,i.T)(e,l.b,"getUserOperationReceipt")({hash:n});r(()=>t.resolve(a))}catch(e){"UserOperationReceiptNotFoundError"!==e.name&&r(()=>t.reject(e))}h++},{emitOnBegin:!0,interval:c});return u&&setTimeout(()=>r(()=>t.reject(new o.Wm({hash:n}))),u),s})})}},916544:(e,t,n)=>{"use strict";n.d(t,{q:()=>c});var i=n(420732),r=n(555512),a=n(529533),s=n(603181),o=n(361775),l=n(589385);async function c(e){let{extend:t,nonceKeyManager:n=(0,o.L8)({source:{get:()=>Date.now(),set(){}}}),...c}=e,d=!1,u=await e.getAddress();return{...t,...c,address:u,async getFactoryArgs(){return"isDeployed"in this&&await this.isDeployed()?{factory:void 0,factoryData:void 0}:e.getFactoryArgs()},async getNonce(t){let r=t?.key??BigInt(await n.consume({address:u,chainId:e.client.chain.id,client:e.client}));return e.getNonce?await e.getNonce({...t,key:r}):await (0,a.J)(e.client,{abi:(0,i.U)(["function getNonce(address, uint192) pure returns (uint256)"]),address:e.entryPoint.address,functionName:"getNonce",args:[u,r]})},isDeployed:async()=>!!d||(d=!!await (0,s.T)(e.client,r.Q,"getCode")({address:u})),...e.sign?{async sign(t){let[{factory:n,factoryData:i},r]=await Promise.all([this.getFactoryArgs(),e.sign(t)]);return n&&i?(0,l.E)({address:n,data:i,signature:r}):r}}:{},async signMessage(t){let[{factory:n,factoryData:i},r]=await Promise.all([this.getFactoryArgs(),e.signMessage(t)]);return n&&i&&"0x7702"!==n?(0,l.E)({address:n,data:i,signature:r}):r},async signTypedData(t){let[{factory:n,factoryData:i},r]=await Promise.all([this.getFactoryArgs(),e.signTypedData(t)]);return n&&i&&"0x7702"!==n?(0,l.E)({address:n,data:i,signature:r}):r},type:"smart"}}},916626:(e,t,n)=>{"use strict";n.d(t,{n:()=>o});var i=n(564729),r=n(538960),a=n(526919);let s=!1;function o({disableMetaMask:e}={}){"undefined"!=typeof window&&!s&&(window&&window.solflareWalletStandardInitialized||(s=!0,window&&(window.solflareWalletStandardInitialized=!0),e||(0,a.R)(),(0,i.L)(new r.g)))}}
72,925848:(e,t,n)=>{"use strict";n.d(t,{u:()=>r});var i=n(343750);function r(e){let t=e.filter(e=>!i.o.has(e.id));return i.m.concat(t)}},927024:(e,t,n)=>{"use strict";n.d(t,{t:()=>r});var i=n(352401);let r=async({admin:e,salt:t})=>(0,i.p)({abi:[{inputs:[{internalType:"address",name:"_admin",type:"address"},{internalType:"bytes",name:"_salt",type:"bytes"}],name:"createAccount",outputs:[{internalType:"address",type:"address"}],stateMutability:"nonpayable",type:"function"}],functionName:"createAccount",args:[e,t]})},933087:(e,t,n)=>{"use strict";n.d(t,{n:()=>i});let i={id:80002,name:"Polygon Amoy",network:"polygon-amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-amoy.rpc.privy.systems"]},infura:{http:["https://polygon-amoy.infura.io/v3"],webSocket:["wss://polygon-amoy.infura.io/ws/v3"]},default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"OK LINK",url:"https://www.oklink.com/amoy"}},testnet:!0}},934172:(e,t,n)=>{"use strict";n.d(t,{E:()=>c});var i=n(797036),r=n(347220),a=n(352401),s=n(998299),o=n(603181),l=n(364591);async function c(e,t){let{abi:n,account:c=e.account,address:d,args:u,dataSuffix:h,functionName:p,...m}=t;if(void 0===c)throw new r.T({docsPath:"/docs/contract/writeContract"});let y=c?(0,i.J)(c):null,f=(0,a.p)({abi:n,args:u,functionName:p});try{return await (0,o.T)(e,l.v,"sendTransaction")({data:`${f}${h?h.replace("0x",""):""}`,to:d,account:y,...m})}catch(e){throw(0,s.j)(e,{abi:n,address:d,args:u,docsPath:"/docs/contract/writeContract",functionName:p,sender:y?.address})}}},940937:(e,t,n)=>{"use strict";n.d(t,{t:()=>a});var i=n(572178);let r={PackedUserOperation:[{type:"address",name:"sender"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"bytes32",name:"accountGasLimits"},{type:"uint256",name:"preVerificationGas"},{type:"bytes32",name:"gasFees"},{type:"bytes",name:"paymasterAndData"}]};function a(e){let{chainId:t,entryPointAddress:n,userOperation:a}=e;return{types:r,primaryType:"PackedUserOperation",domain:{name:"ERC4337",version:"1",chainId:t,verifyingContract:n},message:(0,i.W)(a)}}},944315:(e,t,n)=>{"use strict";n.d(t,{h:()=>c});var i=n(797036),r=n(347220),a=n(520928),s=n(603181),o=n(760483),l=n(920506);async function c(e,t){let{account:n=e.account,chainId:c,nonce:d}=t;if(!n)throw new r.T({docsPath:"/docs/eip7702/prepareAuthorization"});let u=(0,i.J)(n),h=(()=>
72{if(t.executor)return"self"===t.executor?t.executor:(0,i.J)(t.executor)})(),p={address:t.contractAddress??t.address,chainId:c,nonce:d};return void 0===p.chainId&&(p.chainId=e.chain?.id??await (0,s.T)(e,o.T,"getChainId")({})),void 0===p.nonce&&(p.nonce=await (0,s.T)(e,l.y,"getTransactionCount")({address:u.address,blockTag:"pending"}),("self"===h||h?.address&&(0,a.h)(h.address,u.address))&&(p.nonce+=1)),p}},945849:(e,t,n)=>{"use strict";n.d(t,{j:()=>i});let i=[{type:"function",name:"createAccount",inputs:[{name:"data",type:"bytes",internalType:"bytes"},{name:"salt",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"payable"}]},948458:(e,t,n)=>{var i=n(881660);e.exports=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?i(e,void 0,t):[]}},950588:(e,t,n)=>{"use strict";n.d(t,{L:()=>v});var i=n(760483),r=n(749397),a=n(174562),s=n(814001),o=n(916544),l=n(382487),c=n(603181),d=n(128897),u=n(448953),h=n(164972),p=n(545700),m=n(349271),y=n(927024),f=n(719638),g=n(808725);let w={"0.6":{"1.5.20":{factoryAddress:"0x85e23b94e7F5E9cC1fF78BCe78cfb15B81f0DF00"}},"0.7":{"1.5.20":{factoryAddress:"0x4be0ddfebca9a5a4a617dee4dece99e7c862dceb"}}};async function v(e){let t,n={address:e.entryPoint?.address??a.oi,abi:(e.entryPoint?.version??"0.7")==="0.6"?s.hw:s.qe,version:e.entryPoint?.version??"0.7"},{owner:v,client:b,salt:x,version:_,address:C,factoryAddress:I=w[n.version][_??"1.5.20"].factoryAddress}=e,E=await (0,u.F)({owner:v}),T=C,A=async()=>t||(t=b.chain?b.chain.id:await (0,c.T)(b,i.T,"getChainId")({})),S=async()=>({factory:I,factoryData:await (0,y.t)({admin:E.address,salt:x?(0,d.nj)(x):"0x"})});return(0,o.q)({client:b,entryPoint:n,getFactoryArgs:S,getAddress:async()=>T||(T=await (0,m.k)(b,{adminAddress:E.address,factoryAddress:I,salt:x?(0,d.nj)(x):"0x"})),encodeCalls:async e=>(0,p.r)(e),decodeCalls:async e=>(0,h.L)(e),async getNonce(t){return(0,r.p)(b,{address:await this.getAddress(),entryPointAddress:n.address,key:e?.nonceKey??t?.key})},getStubSignature:async()=>"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",async sign({hash:e}){return this.signMessage({message:e})},async signMessage({message:e}){return(0,f.l)({admin:E,chainId:await A(),accountAddress:await this.getAddress(),message:e})},async signTypedData(e){return(0,g.C)({admin:E,chainId:await A(),accountAddress:await this.getAddress(),...e})},async signUserOperation(e){let{chainId:t=await A(),...i}=e;return E.signMessage({message:{raw:(0,l.Z)({userOperation:{...i,sender:i.sender??await this.getAddress(),signature:"0x"},entryPointAddress:n.address,entryPointVersion:n.version,chainId:t})}})}})}},950607:(e,t,n)=>{"use strict";n.d(t,{t:()=>r});var i=n(525868);let r=async(e,t)=>{let{sponsorshipPolicyId:n,paymasterContext:r,userOperation:a,entryPoint:s}=t,o=void 0!==n?{...r??{},sponsorshipPolicyId:n}:r,l=await e.request({method:"pm_sponsorUserOperation",params:o?[(0,i._)(a),s.address,o]:[(0,i._)(a),s.address]});return"0.6"===s.version?{paymasterAndData:l.paymasterAndData,preVerificationGas:BigInt(l.preVerificationGas),verificationGasLimit:BigInt(l.verificationGasLimit),callGasLimit:BigInt(l.callGasLimit)}:{callGasLimit:BigInt(l.callGasLimit),verificationGasLimit:BigInt(l.verificationGasLimit),preVerificationGas:BigInt(l.preVerificationGas),paymaster:l.paymaster,paymasterVerificationGasLimit:BigInt(l.paymasterVerificationGasLimit),paymasterPostOpGasLimit:BigInt(l.paymasterPostOpGasLimit),paymasterData:l.paymasterData}}},963323:(e,t,n)=>{"use strict";n.d(t,{$:()=>c});var i=n(797036),r=n(347220),a=n(603181),s=n(976704),o=n(707799),l=n(872282);async function c(e,t){let{account:n=e.account,entryPointAddress:c}=t;if(!n&&!t.sender)throw new r.T;let d=n?(0,i.J)(n):void 0,u=d?await (0,a.T)(e,l.u,"prepareUserOperation")(t):t,h=t.signature||await d?.signUserOperation?.(u),p=(0,o.P)({...u,signature:h});try{return await e.request({method:"eth_sendUserOperation",params:[p,c??d?.entryPoint?.address]},{retryCount:0})}catch(n){let e=t.calls;throw(0,s.t)(n,{...u,...e?{calls:e}:{},signature:h})}}},976168:(e,t,n)=>{"use strict";n.d(t,{Kh:()=>l,Wm:()=>c,oX:()=>o,tN:()=>s});var i=n(125644),r=n(410387),a=n(471851);class s extends i.C{constructor(e,{callData:t,callGasLimit:n,docsPath:i,factory:s,factoryData:o,init
72Code:l,maxFeePerGas:c,maxPriorityFeePerGas:d,nonce:u,paymaster:h,paymasterAndData:p,paymasterData:m,paymasterPostOpGasLimit:y,paymasterVerificationGasLimit:f,preVerificationGas:g,sender:w,signature:v,verificationGasLimit:b}){super(e.shortMessage,{cause:e,docsPath:i,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",(0,r.aO)({callData:t,callGasLimit:n,factory:s,factoryData:o,initCode:l,maxFeePerGas:void 0!==c&&`${(0,a.Q)(c)} gwei`,maxPriorityFeePerGas:void 0!==d&&`${(0,a.Q)(d)} gwei`,nonce:u,paymaster:h,paymasterAndData:p,paymasterData:m,paymasterPostOpGasLimit:y,paymasterVerificationGasLimit:f,preVerificationGas:g,sender:w,signature:v,verificationGasLimit:b})].filter(Boolean),name:"UserOperationExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class o extends i.C{constructor({hash:e}){super(`User Operation receipt with hash "${e}" could not be found. The User Operation may not have been processed yet.`,{name:"UserOperationReceiptNotFoundError"})}}class l extends i.C{constructor({hash:e}){super(`User Operation with hash "${e}" could not be found.`,{name:"UserOperationNotFoundError"})}}class c extends i.C{constructor({hash:e}){super(`Timed out while waiting for User Operation with hash "${e}" to be confirmed.`,{name:"WaitForUserOperationReceiptTimeoutError"})}}},976704:(e,t,n)=>{"use strict";n.d(t,{t:()=>c});var i=n(125644),r=n(588365),a=n(88531),s=n(116274),o=n(976168),l=n(402954);function c(e,{calls:t,docsPath:n,...c}){let d=(()=>{let n=(0,l.N)(e,c);if(t&&n instanceof s.A7){let e,s=(n.walk(t=>{if("string"==typeof t.data||"string"==typeof t.data?.revertData||!(t instanceof i.C)&&"string"==typeof t.message){let n=(t.data?.revertData||t.data||t.message).match?.(/(0x[A-Za-z0-9]*)/);if(n)return e=n[1],!0}return!1}),e),o=t?.filter(e=>e.abi);if(s&&o.length>0)return function(e){let{calls:t,revertData:n}=e,{abi:i,functionName:s,args:o,to:l}=(()=>{let e=t?.filter(e=>!!e.abi);if(1===e.length)return e[0];let i=e.filter(e=>{try{return!!(0,a.W)({abi:e.abi,data:n})}catch{return!1}});return 1===i.length?i[0]:{abi:[],functionName:e.reduce((e,t)=>`${e?`${e} | `:""}${t.functionName}`,""),args:void 0,to:void 0}})(),c="0x"===n?new r.rR({functionName:s}):new r.M({abi:i,data:n,functionName:s});return new r.bG(c,{abi:i,args:o,contractAddress:l,functionName:s})}({calls:o,revertData:s})}return n})();return new o.tN(d,{docsPath:n,...c})}},985980:(e,t,n)=>{"use strict";n.d(t,{r:()=>o});var i=n(352401),r=n(142974),a=n(569993),s=n(129239);let o=({kernelVersion:e,calls:t})=>{if((0,s.c)(e)){if(t.length>1)return(0,i.p)({abi:a.V,functionName:"executeBatch",args:[t.map(e=>({to:e.to,value:e.value??0n,data:e.data??"0x"}))]});let e=0===t.length?void 0:t[0];if(!e)throw Error("No calls to encode");return(0,i.p)({abi:a.V,functionName:"execute",args:[e.to,e.value??0n,e.data??"0x",0]})}return(0,r.m)({mode:{type:t.length>1?"batchcall":"call",revertOnError:!1,selector:"0x",context:"0x"},callData:t})}},988586:(e,t,n)=>{"use strict";n.d(t,{Y:()=>i});let i={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-sepolia.rpc.privy.systems"]}
72,default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0}},996976:(e,t,n)=>{"use strict";n.d(t,{C:()=>u});var i=n(797036),r=n(347220),a=n(603181),s=n(458666),o=n(976704),l=n(345475),c=n(707799),d=n(872282);async function u(e,t){let{account:n=e.account,entryPointAddress:u,stateOverride:h}=t;if(!n&&!t.sender)throw new r.T;let p=n?(0,i.J)(n):void 0,m=(0,s.yH)(h),y=p?await (0,a.T)(e,d.u,"prepareUserOperation")({...t,parameters:["authorization","factory","nonce","paymaster","signature"]}):t;try{let t=[(0,c.P)(y),u??p?.entryPoint?.address],n=await e.request({method:"eth_estimateUserOperationGas",params:m?[...t,m]:[...t]});return(0,l.V)(n)}catch(n){let e=t.calls;throw(0,o.t)(n,{...y,...e?{calls:e}:{}})}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.