@stacknet/userutils 0.5.6 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/index.d.cts +2 -2
- package/dist/adapters/index.d.ts +2 -2
- package/dist/{auth-DR2aYcor.d.cts → auth-c1d7Eji2.d.cts} +6 -0
- package/dist/{auth-DR2aYcor.d.ts → auth-c1d7Eji2.d.ts} +6 -0
- package/dist/components/index.cjs +2 -2
- package/dist/components/index.d.cts +25 -3
- package/dist/components/index.d.ts +25 -3
- package/dist/components/index.js +2 -2
- package/dist/config-CLzVWDrU.d.cts +177 -0
- package/dist/config-xNca5ufB.d.ts +177 -0
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.d.cts +52 -3
- package/dist/hooks/index.d.ts +52 -3
- package/dist/hooks/index.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +2 -2
- package/dist/server/index.d.cts +116 -21
- package/dist/server/index.d.ts +116 -21
- package/dist/server/index.js +2 -2
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/{types-CAoB_5kk.d.cts → types-B_Vj6cr4.d.cts} +1 -1
- package/dist/{types-Dghy_8Wh.d.ts → types-Cu0do-w-.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/config-Bjh8PEhY.d.cts +0 -123
- package/dist/config-_ZjAzNkJ.d.ts +0 -123
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),react=require('react'),jsxRuntime=require('react/jsx-runtime');function vt(...e){return tailwindMerge.twMerge(clsx.clsx(e))}function Nt(e){return e>=1e12?`${(e/1e12).toFixed(e%1e12===0?0:1)}T`:e>=1e9?`${(e/1e9).toFixed(e%1e9===0?0:1)}B`:e>=1e6?`${(e/1e6).toFixed(e%1e6===0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:e.toLocaleString()}function It(e,t){if(!e)return "/";if(e.startsWith("/")&&!e.startsWith("//"))return e;try{let s=new URL(e,t);return s.origin!==t?"/":s.pathname+s.search+s.hash}catch{return "/"}}function ee(e,t="#"){if(!e||typeof e!="string")return t;let s=e.trim();if(s===""||s==="#")return t;if(s.startsWith("/")||s.startsWith("./")||s.startsWith("../"))return s;try{let d=new URL(s);if(d.protocol==="http:"||d.protocol==="https:")return d.toString()}catch{}return t}function Pt(e){try{let t=e.split(".");if(t.length!==3)return null;let s=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(s)}catch{return null}}function te(){if(typeof document>"u")return null;try{let e=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith("stackauth_session="));if(!e)return null;let t=e.slice(18);return JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")))}catch{return null}}function F(e="__csrf"){if(typeof document>"u")return null;let t=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith(`${e}=`));return t?t.slice(e.length+1):null}function ne(){let[e,t]=react.useState(null),[s,d]=react.useState(true),u=react.useCallback(()=>{let i=te();i&&i.expiresAt>Date.now()?t({userId:i.userId,address:i.address,chain:i.chain,expiresAt:i.expiresAt,planId:i.planId,authMethod:i.authMethod}):t(null),d(false);},[]);react.useEffect(()=>{u();},[u]);let h=react.useCallback(async(i="")=>{try{let l=await fetch(`${i}/api/auth/session`);if(l.ok){let c=await l.json();if(c.session)return t(c.session),c.session}return t(null),null}catch{return null}},[]),g=!!e&&e.expiresAt>Date.now();return {session:e,loading:s,isAuthenticated:g,refresh:h,readSession:u}}function we(e="__csrf",t="x-csrf-token"){let[s,d]=react.useState(null);react.useEffect(()=>{d(F(e));},[e]);let u=s?{[t]:s}:{};return {token:s,headers:u}}function Se(){let[e,t]=react.useState({connected:false,address:null,chain:null,provider:null}),[s,d]=react.useState(null),u=react.useCallback(async(l="phantom")=>{d(null);try{let c=typeof window<"u"?window:null,m=l==="phantom"?c?.phantom?.solana||c?.solana:c?.solflare;if(!m)return d(`${l} wallet not found`),null;let a=(await m.connect()).publicKey.toString();return t({connected:!0,address:a,chain:"solana",provider:l}),a}catch(c){return d(c.message||"Failed to connect wallet"),null}},[]),h=react.useCallback(async()=>{d(null);try{let c=(typeof window<"u"?window:null)?.ethereum;if(!c)return d("MetaMask not found"),null;let m=c;c.providers?.length&&(m=c.providers.find(n=>n.isMetaMask)||c);let a=(await m.request({method:"eth_requestAccounts"}))[0];return a?(t({connected:!0,address:a,chain:"ethereum",provider:"metamask"}),a):(d("No account selected"),null)}catch(l){return d(l.message||"Failed to connect wallet"),null}},[]),g=react.useCallback(async(l,c)=>{d(null);let m=c?.chain||e.chain,o=c?.provider||e.provider,a=c?.address||e.address;try{if(m==="solana"){let n=typeof window<"u"?window:null,p=o==="solflare"?n?.solflare:n?.phantom?.solana||n?.solana;if(!p)throw new Error("Wallet not available");let r=new TextEncoder().encode(l),y=await p.signMessage(r,"utf8"),S=new Uint8Array(y.signature||y),w="";for(let T=0;T<S.byteLength;T++)w+=String.fromCharCode(S[T]);return btoa(w)}if(m==="ethereum"){let p=(typeof window<"u"?window:null)?.ethereum;if(p?.providers?.length&&(p=p.providers.find(y=>y.isMetaMask)||p),!p)throw new Error("MetaMask not available");return await p.request({method:"personal_sign",params:[l,a]})}throw new Error("No wallet connected")}catch(n){return d(n.message||"Signing failed"),null}},[e]),i=react.useCallback(()=>{t({connected:false,address:null,chain:null,provider:null}),d(null);},[]);return {wallet:e,error:s,connectSolana:u,connectEVM:h,signMessage:g,disconnect:i}}var Ot="https://stacknet.magma-rpc.com/auth/bridge",de="stacknet-auth-bridge";function xe(e){let t=e?.bridgeUrl||Ot,s=e?.disabled||false,d=react.useRef(null),[u,h]=react.useState({ready:false,known:false,identity:null,identityCount:0,resolvedStackId:null}),g=react.useRef([]),i=react.useRef(false),l=react.useCallback(n=>{let p={...n,protocol:de};i.current&&d.current?.contentWindow?d.current.contentWindow.postMessage(p,new URL(t).origin):g.current.push(p);},[t]);react.useEffect(()=>{if(s)return;let n=r=>{if(!(!r.data||r.data.protocol!==de)){try{if(r.origin!==new URL(t).origin)return}catch{return}switch(r.data.type){case "bridge:ready":i.current=true,h(y=>({...y,ready:true}));for(let y of g.current)d.current?.contentWindow?.postMessage(y,r.origin);g.current=[],d.current?.contentWindow?.postMessage({protocol:de,type:"auth:check"},r.origin),d.current?.contentWindow?.postMessage({protocol:de,type:"auth:resolve-stack"},r.origin);break;case "auth:status":h(y=>({...y,known:r.data.known,identity:r.data.identity,identityCount:r.data.identityCount||0}));break;case "auth:resolved-stack":h(y=>({...y,resolvedStackId:r.data.stackId||null}));break;}}};window.addEventListener("message",n);let p=document.createElement("iframe");return p.src=t,p.style.display="none",p.setAttribute("aria-hidden","true"),p.setAttribute("tabindex","-1"),p.setAttribute("sandbox","allow-scripts allow-same-origin"),document.body.appendChild(p),d.current=p,()=>{window.removeEventListener("message",n),p.parentNode&&p.parentNode.removeChild(p),d.current=null,i.current=false;}},[t,s]);let c=react.useCallback(n=>{l({type:"auth:connected",...n});},[l]),m=react.useCallback(n=>{l({type:"auth:disconnected",...n});},[l]),o=react.useCallback(()=>{l({type:"auth:clear"}),h({ready:u.ready,known:false,identity:null,identityCount:0,resolvedStackId:null});},[l,u.ready]),a=react.useCallback(()=>{l({type:"auth:check"});},[l]);return {...u,reportConnected:c,reportDisconnected:m,clearAll:o,refresh:a}}async function nt(e,t,s,d){let u=e.apiVersion||"v2",h=`${e.baseUrl}/api/${u}${s}`;try{let g=await fetch(h,{method:t,headers:{"Content-Type":"application/json"},body:d?JSON.stringify(d):void 0}),i=await g.json();return g.ok?i.success&&i.data!==void 0?{success:!0,data:i.data}:{success:!0,data:i}:{success:!1,error:i.error||{code:"UNKNOWN_ERROR",message:"Unknown error"}}}catch(g){return {success:false,error:{code:"NETWORK_ERROR",message:g instanceof Error?g.message:"Network error"}}}}function ve(e){return {getNetworkStatus:()=>nt(e,"GET","/network/status"),getWeb3Challenge:(t,s)=>nt(e,"POST",`/stacks/${encodeURIComponent(e.stackId)}/auth/web3/challenge`,{chain:t,address:s})}}function Ie(e={apiBaseUrl:""}){let{wallet:t,connectSolana:s,connectEVM:d,signMessage:u,disconnect:h}=Se(),{session:g,isAuthenticated:i,refresh:l,readSession:c}=ne(),{headers:m}=we(),o=xe({disabled:typeof window>"u"}),[a,n]=react.useState(false),[p,r]=react.useState(null),[y,S]=react.useState(false),w=e.apiBaseUrl||"",T=e.stacknetUrl||"https://stacknet.magma-rpc.com",x=e.stackId||o.resolvedStackId||"",C=ve({baseUrl:T,stackId:x}),z=react.useCallback(async(N,I,R,E)=>{n(true),r(null);try{let P=I;if(!P){let Z=await R();if(!Z)return n(!1),!1;P=Z;}let U=await C.getWeb3Challenge(N,P);if(!U.success||!U.data)return r("Failed to get challenge"),n(!1),!1;let _=await u(U.data.message,{chain:N,provider:E,address:P});if(!_)return n(!1),!1;let G={chain:N,message:U.data.message,signature:_,stackId:x};N==="solana"&&(G.publicKey=P);let V=await fetch(`${w}/api/auth/callback`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(G)});if(!V.ok){let Z=await V.json().catch(()=>({}));return r(Z.error||"Authentication failed"),n(!1),!1}return o.reportConnected({address:P,chain:N,method:E||(N==="solana"?"phantom":"metamask"),stackId:x}),c(),n(!1),!0}catch(P){return r(P.message||"Authentication failed"),n(false),false}},[w,C,u,c,o,x]),W=react.useCallback(async(N="phantom")=>{let I=await s(N);return I?z("solana",I,()=>s(N),N):false},[s,z]),j=react.useCallback(async()=>{let N=await d();return N?z("ethereum",N,d,"metamask"):false},[d,z]),b=react.useCallback(async N=>{n(true),r(null);try{let I=await fetch(`${w}/api/auth/otp`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({code:N})});if(!I.ok){let R=await I.json().catch(()=>({}));return r(R.error||"Invalid code"),n(!1),!1}return c(),n(!1),!0}catch(I){return r(I.message||"OTP verification failed"),n(false),false}},[w,c]),L=react.useCallback(async(N,I)=>{n(true),r(null);try{let R=I||`${window.location.origin}/api/auth/oauth/callback`,E=new URLSearchParams({provider:N,redirectUri:R,stackId:x}),P=await fetch(`${w}/api/auth/oauth/start?${E}`,{credentials:"include"});if(!P.ok){let _=await P.json().catch(()=>({}));return r(_.error||"Failed to start OAuth flow"),n(!1),!1}let U=await P.json();if(U.redirect_url){let _;try{_=new URL(U.redirect_url);}catch{return r("Invalid OAuth redirect URL"),n(!1),!1}let G=[/(^|\.)accounts\.google\.com$/,/(^|\.)discord\.com$/,/(^|\.)github\.com$/,/(^|\.)x\.com$/,/(^|\.)twitter\.com$/,/(^|\.)apple\.com$/];return _.protocol!=="https:"||!G.some(V=>V.test(_.hostname))?(r(`Refusing to redirect to non-OAuth host: ${_.hostname}`),n(!1),!1):(typeof sessionStorage<"u"&&(sessionStorage.setItem("oauth_state",U.state||""),sessionStorage.setItem("oauth_provider",N)),window.location.href=_.toString(),!0)}return r("No redirect URL returned"),n(!1),!1}catch(R){return r(R.message||"OAuth flow failed"),n(false),false}},[w,x]),A=react.useCallback(async(N,I,R)=>{n(true),r(null);try{if(typeof sessionStorage<"u"){let P=sessionStorage.getItem("oauth_state"),U=sessionStorage.getItem("oauth_provider");if(sessionStorage.removeItem("oauth_state"),sessionStorage.removeItem("oauth_provider"),!P||P!==R)return r("OAuth state mismatch \u2014 refusing to complete login"),n(!1),!1;if(U&&U!==N)return r("OAuth provider mismatch \u2014 refusing to complete login"),n(!1),!1}let E=await fetch(`${w}/api/auth/oauth/callback`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({provider:N,code:I,state:R,stackId:x})});if(!E.ok){let P=await E.json().catch(()=>({}));return r(P.error||"OAuth authentication failed"),n(!1),!1}return c(),n(!1),!0}catch(E){return r(E.message||"OAuth callback failed"),n(false),false}},[w,x,c]),D=react.useCallback(async()=>{t.address&&t.chain&&o.reportDisconnected({address:t.address,chain:t.chain,stackId:x});try{await fetch(`${w}/api/auth/logout`,{method:"POST",headers:m,credentials:"include"});}catch{}h(),c();},[w,m,h,c,t,o,x]);return react.useEffect(()=>{if(!e.autoConnect||y||i||!o.ready||!o.known||!o.identity)return;S(true);let{chain:N,method:I}=o.identity;N==="solana"&&(I==="phantom"||I==="solflare")?W(I):N==="ethereum"&&j();},[e.autoConnect,y,i,o,W,j]),{session:g,isAuthenticated:i,wallet:t,loading:a,error:p,authenticateSolana:W,authenticateEVM:j,authenticateOTP:b,authenticateOAuth:L,authenticateOAuthCallback:A,logout:D,refresh:()=>l(w),stackId:x,bridge:{ready:o.ready,known:o.known,identity:o.identity,identityCount:o.identityCount,resolvedStackId:o.resolvedStackId}}}function re(e,t="https://stacknet.magma-rpc.com"){let[s,d]=react.useState(null),[u,h]=react.useState(false),[g,i]=react.useState(null),l=react.useCallback(async m=>{h(true),i(null);try{let o=await fetch(`${t}/api/v2/stacks/${m}`);if(!o.ok)return i("Stack not found"),h(!1),null;let a=await o.json(),n=a.data?.stack||a.stack||a,p={id:n.id,name:n.name,displayName:n.displayName||n.name,description:n.description,logoUrl:n.logoUrl,webPageUrl:n.webPageUrl,allowedChains:n.allowedChains||[],features:n.features,stripeProvider:n.stripeProvider,oauthProviders:n.oauthProviders?.map(r=>({provider:r.provider,clientId:r.clientId,enabled:r.enabled!==!1}))};return d(p),h(!1),p}catch(o){return i(o.message),h(false),null}},[t]);react.useEffect(()=>{e&&l(e);},[e,l]);let c=s?Rt(s):[];return {config:s,loading:u,error:g,identityProviders:c,fetchConfig:l}}function Rt(e){let t=[];if(e.features?.web3Auth!==false&&(e.allowedChains.includes("solana")&&(t.push({type:"wallet",id:"phantom",name:"Phantom",chain:"solana"}),t.push({type:"wallet",id:"solflare",name:"Solflare",chain:"solana"})),(e.allowedChains.includes("ethereum")||e.allowedChains.includes("polygon")||e.allowedChains.includes("base"))&&t.push({type:"wallet",id:"metamask",name:"MetaMask",chain:"ethereum"})),e.features?.apiKeyAuth!==false&&t.push({type:"otp",id:"otp",name:"Access Code"}),e.features?.oauthAuth&&e.oauthProviders)for(let s of e.oauthProviders)s.enabled&&t.push({type:"oauth",id:s.provider,name:s.provider});return t}function Wt(e=""){let[t,s]=react.useState([]),[d,u]=react.useState(true),[h,g]=react.useState(null),i=react.useCallback(async()=>{try{let l=await fetch(`${e}/api/billing/plans`);if(l.ok){let c=await l.json();s(c.plans||c||[]);}}catch(l){g(l.message);}finally{u(false);}},[e]);return react.useEffect(()=>{i();},[i]),{plans:t,loading:d,error:h,refresh:i}}function Ft(e=""){let[t,s]=react.useState(null),[d,u]=react.useState(true),[h,g]=react.useState(null),i=react.useCallback(async()=>{try{let m=await fetch(`${e}/api/billing/subscription`);if(m.ok){let o=await m.json();s(o.plan?o:null);}}catch(m){g(m.message);}finally{u(false);}},[e]);react.useEffect(()=>{i();},[i]);let l=react.useCallback(async m=>{let o=F(),n=await(await fetch(`${e}/api/billing/subscribe`,{method:"POST",headers:{"Content-Type":"application/json",...o?{"x-csrf-token":o}:{}},body:JSON.stringify({planId:m})})).json();return n.url||n.checkoutUrl||null},[e]),c=react.useCallback(async()=>{let m=F();return (await fetch(`${e}/api/billing/cancel`,{method:"POST",headers:m?{"x-csrf-token":m}:{}})).ok?(await i(),true):false},[e,i]);return {subscription:t,loading:d,error:h,refresh:i,subscribe:l,cancel:c}}function Ht(e=""){let[t,s]=react.useState(null),[d,u]=react.useState(true),[h,g]=react.useState(null),i=react.useCallback(async()=>{try{let l=await fetch(`${e}/api/billing/usage`);if(l.ok){let c=await l.json();s(c);}}catch(l){g(l.message);}finally{u(false);}},[e]);return react.useEffect(()=>{i();},[i]),{usage:t,loading:d,error:h,refresh:i}}function Qt(e=""){let[t,s]=react.useState(false),[d,u]=react.useState(null),h=react.useCallback(async i=>{s(true),u(null);try{let l=F(),c=await fetch(`${e}/api/billing/prepaid`,{method:"POST",headers:{"Content-Type":"application/json",...l?{"x-csrf-token":l}:{}},body:JSON.stringify({amountCents:i})}),m=await c.json();return c.ok?m.url||null:(u(m.error||"Purchase failed"),null)}catch(l){return u(l.message),null}finally{s(false);}},[e]),g=react.useCallback(async i=>{s(true),u(null);try{let l=F(),c=await fetch(`${e}/api/billing/verify-prepaid`,{method:"POST",headers:{"Content-Type":"application/json",...l?{"x-csrf-token":l}:{}},body:JSON.stringify({sessionId:i})}),m=await c.json();return c.ok?m:(u(m.error||"Verification failed"),null)}catch(l){return u(l.message),null}finally{s(false);}},[e]);return {purchase:h,verifySession:g,loading:t,error:d}}function Jt(e="",t){let[s,d]=react.useState([]),[u,h]=react.useState(true),[g,i]=react.useState(null),l=t?.limit||50,c=t?.offset||0,m=react.useCallback(async()=>{try{let o=await fetch(`${e}/api/billing/history?limit=${l}&offset=${c}`);if(o.ok){let a=await o.json();d(a.records||a.history||(Array.isArray(a)?a:[]));}}catch(o){i(o.message);}finally{h(false);}},[e,l,c]);return react.useEffect(()=>{m();},[m]),{records:s,loading:u,error:g,refresh:m}}function Kt(){if(typeof document>"u")return null;let e=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith("__csrf="));return e?e.slice(7):null}function je(e,t){let[s,d]=react.useState(null),[u,h]=react.useState(true),[g,i]=react.useState(false),[l,c]=react.useState(null),m=t?.apiBaseUrl??"",o=t?.scope===void 0||t?.scope==="global"?"global":`stack:${t.scope.stackId}`,a=react.useCallback(r=>{let y=encodeURIComponent(r);if(o==="global")return `${m}/api/user/profile/${y}`;let S=o.slice(6);return `${m}/api/v2/stacks/${encodeURIComponent(S)}/members/${y}/profile`},[m,o]),n=react.useCallback(async()=>{if(!e){d(null),h(false);return}h(true),c(null);try{let r=await fetch(a(e));if(r.ok){let y=await r.json(),S=y.profile||y.data?.profile||y;d({mid:S.mid||e,username:S.username||"",avatarUrl:S.avatar_url||S.avatarUrl,bio:S.bio,paymentAddress:S.payment_address||S.paymentAddress,createdAt:S.created_at||S.createdAt,updatedAt:S.updated_at||S.updatedAt});}else if(r.status===404)d({mid:e,username:""});else throw new Error(`${r.status}`)}catch(r){c(r instanceof Error?r.message:"Failed to load profile");}finally{h(false);}},[e,a]);react.useEffect(()=>{n();},[n]);let p=react.useCallback(async r=>{if(!e)return false;i(true),c(null);try{let y=Kt(),S={};r.username!==void 0&&(S.username=r.username),r.avatarUrl!==void 0&&(S.avatar_url=r.avatarUrl),r.bio!==void 0&&(S.bio=r.bio),r.paymentAddress!==void 0&&(S.payment_address=r.paymentAddress);let w=await fetch(a(e),{method:"PUT",headers:{"Content-Type":"application/json",...y?{"x-csrf-token":y}:{}},credentials:"same-origin",body:JSON.stringify(S)});if(!w.ok){let C=await w.json().catch(()=>({}));throw new Error(C.error||C.message||`Update failed: ${w.status}`)}let T=await w.json(),x=T.profile||T.data?.profile||T;return d(C=>({mid:C?.mid||e,username:r.username??C?.username??"",avatarUrl:r.avatarUrl??C?.avatarUrl,bio:r.bio??C?.bio,paymentAddress:r.paymentAddress??x.payment_address??x.paymentAddress??C?.paymentAddress,createdAt:C?.createdAt,updatedAt:x.updated_at||x.updatedAt||Date.now()})),!0}catch(y){return c(y instanceof Error?y.message:"Update failed"),false}finally{i(false);}},[e,a]);return {profile:s,loading:u,saving:g,error:l,updateProfile:p,refresh:n}}var at="google-identity-services",qt="https://accounts.google.com/gsi/client";function Xt({stackId:e,stacknetUrl:t="https://stacknet.magma-rpc.com",apiBaseUrl:s="",autoPrompt:d=true,cancelOnTapOutside:u=true,onSuccess:h,onError:g,disabled:i=false}){let{config:l}=re(e,t),{isAuthenticated:c,loading:m,readSession:o}=ne(),[a,n]=react.useState(false),[p,r]=react.useState(null),[y,S]=react.useState(false),w=react.useRef(false),T=react.useRef(false),C=l?.oauthProviders?.find(b=>b.provider==="google"&&b.enabled&&b.clientId)?.clientId||null;react.useEffect(()=>{if(i||!C||typeof window>"u")return;if(document.getElementById(at)){S(true);return}let b=document.createElement("script");b.id=at,b.src=qt,b.async=true,b.defer=true,b.onload=()=>S(true),b.onerror=()=>{r("Failed to load Google sign-in"),g?.("Failed to load Google Identity Services script");},document.head.appendChild(b);},[i,C,g]);let z=react.useCallback(async b=>{n(true),r(null);try{let L=await fetch(`${s}/api/auth/google/one-tap`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({credential:b.credential,stackId:e})});if(!L.ok){let D=(await L.json().catch(()=>({}))).error||"Google sign-in failed";r(D),g?.(D),n(!1);return}o(),n(!1),h?.();}catch(L){let A=L.message||"Google sign-in failed";r(A),g?.(A),n(false);}},[s,e,o,h,g]);react.useEffect(()=>{if(i){console.debug("[GoogleOneTap] Disabled");return}if(!y){console.debug("[GoogleOneTap] Script not loaded yet, clientId:",C);return}if(!C){console.debug("[GoogleOneTap] No Google clientId from stack config");return}if(m){console.debug("[GoogleOneTap] Session still loading");return}if(c){console.debug("[GoogleOneTap] User already authenticated, skipping");return}if(!window.google?.accounts?.id){console.debug("[GoogleOneTap] GIS library not available on window");return}w.current||(console.debug("[GoogleOneTap] Initializing with clientId:",C),w.current=true,window.google.accounts.id.initialize({client_id:C,callback:z,auto_select:true,cancel_on_tap_outside:u}),d&&!T.current&&(T.current=true,console.debug("[GoogleOneTap] Showing prompt..."),window.google.accounts.id.prompt(b=>{b.isDisplayed?.()&&console.debug("[GoogleOneTap] Prompt displayed"),b.isNotDisplayed?.()&&console.debug("[GoogleOneTap] Not displayed:",b.getNotDisplayedReason?.()),b.isSkippedMoment?.()&&console.debug("[GoogleOneTap] Skipped:",b.getSkippedReason?.()),b.isDismissedMoment?.()&&console.debug("[GoogleOneTap] Dismissed:",b.getDismissedReason?.());})));},[i,y,C,m,c,z,d,u]),react.useEffect(()=>()=>{window.google?.accounts?.id&&w.current&&window.google.accounts.id.cancel();},[]);let W=react.useCallback(()=>{!window.google?.accounts?.id||!w.current||window.google.accounts.id.prompt();},[]),j=react.useCallback((b,L)=>{!b||!window.google?.accounts?.id||!w.current||window.google.accounts.id.renderButton(b,{theme:L?.theme||"filled_black",size:L?.size||"large",text:L?.text||"signin_with",width:L?.width});},[]);return {available:!!C,ready:y&&!!C,loading:a,error:p,prompt:W,renderButton:j,clientId:C}}var it=react.createContext(null);function nn(){let e=react.useContext(it);if(!e)throw new Error("useUserUtilsContext must be used within <UserUtilsProvider>");return e}function on({config:e,callbacks:t,children:s}){return jsxRuntime.jsx(it.Provider,{value:{config:e,callbacks:t},children:s})}function pe({length:e=6,onComplete:t,disabled:s=false,error:d,className:u="",inputClassName:h=""}){let [g,i]=react.useState(Array(e).fill("")),l=react.useCallback((o,a)=>{if(a.length>1){let p=a.replace(/\D/g,"").slice(0,e).split(""),r=[...g];p.forEach((S,w)=>{o+w<e&&(r[o+w]=S);}),i(r);let y=Math.min(o+p.length,e-1);document.getElementById(`userutils-otp-${y}`)?.focus(),r.every(S=>S!=="")&&setTimeout(()=>t(r.join("")),100);return}if(!/^\d?$/.test(a))return;let n=[...g];n[o]=a,i(n),a&&o<e-1&&document.getElementById(`userutils-otp-${o+1}`)?.focus(),a&&o===e-1&&n.every(p=>p!=="")&&setTimeout(()=>t(n.join("")),100);},[g,e,t]),c=react.useCallback((o,a)=>{if(a.key==="Backspace"&&!g[o]&&o>0){document.getElementById(`userutils-otp-${o-1}`)?.focus();let n=[...g];n[o-1]="",i(n);}if(a.key==="Enter"){let n=g.join("");n.length===e&&t(n);}},[g,e,t]);react.useCallback(()=>{i(Array(e).fill("")),document.getElementById("userutils-otp-0")?.focus();},[e]);return jsxRuntime.jsxs("div",{className:u,children:[jsxRuntime.jsx("div",{className:"flex gap-2 justify-center",children:g.map((o,a)=>jsxRuntime.jsx("input",{id:`userutils-otp-${a}`,type:"text",inputMode:"numeric",maxLength:e,value:o,onChange:n=>l(a,n.target.value),onKeyDown:n=>c(a,n),disabled:s,autoFocus:a===0,className:`w-12 h-14 text-center text-xl font-mono bg-secondary border border-primary/10 text-foreground focus:outline-none focus:border-primary/30 disabled:opacity-50 ${h}`},a))}),d&&jsxRuntime.jsx("p",{className:"text-center text-sm text-red-400 mt-2",children:d})]})}pe.displayName="OTPInput";var ln="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTA4IiBoZWlnaHQ9IjEwOCIgdmlld0JveD0iMCAwIDEwOCAxMDgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00Ni41MjY3IDY5LjkyMjlDNDIuMDA1NCA3Ni44NTA5IDM0LjQyOTIgODUuNjE4MiAyNC4zNDggODUuNjE4MkMxOS41ODI0IDg1LjYxODIgMTUgODMuNjU2MyAxNSA3NS4xMzQyQzE1IDUzLjQzMDUgNDQuNjMyNiAxOS44MzI3IDcyLjEyNjggMTkuODMyN0M4Ny43NjggMTkuODMyNyA5NCAzMC42ODQ2IDk0IDQzLjAwNzlDOTQgNTguODI1OCA4My43MzU1IDc2LjkxMjIgNzMuNTMyMSA3Ni45MTIyQzcwLjI5MzkgNzYuOTEyMiA2OC43MDUzIDc1LjEzNDIgNjguNzA1MyA3Mi4zMTRDNjguNzA1MyA3MS41NzgzIDY4LjgyNzUgNzAuNzgxMiA2OS4wNzE5IDY5LjkyMjlDNjUuNTg5MyA3NS44Njk5IDU4Ljg2ODUgODEuMzg3OCA1Mi41NzU0IDgxLjM4NzhDNDcuOTkzIDgxLjM4NzggNDUuNjcxMyA3OC41MDYzIDQ1LjY3MTMgNzQuNDU5OEM0NS42NzEzIDcyLjk4ODQgNDUuOTc2OCA3MS40NTU2IDQ2LjUyNjcgNjkuOTIyOVpNODMuNjc2MSA0Mi41Nzk0QzgzLjY3NjEgNDYuMTcwNCA4MS41NTc1IDQ3Ljk2NTggNzkuMTg3NSA0Ny45NjU4Qzc2Ljc4MTYgNDcuOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPgo=";function fe({className:e,style:t}){return jsxRuntime.jsx("img",{src:ln,alt:"Phantom",className:e,style:t})}function ge({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 507.83 470.86",children:[jsxRuntime.jsx("polygon",{fill:"#e2761b",stroke:"#e2761b",strokeLinecap:"round",strokeLinejoin:"round",points:"482.09 0.5 284.32 147.38 320.9 60.72 482.09 0.5"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"25.54 0.5 221.72 148.77 186.93 60.72 25.54 0.5"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"410.93 340.97 358.26 421.67 470.96 452.67 503.36 342.76 410.93 340.97"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"4.67 342.76 36.87 452.67 149.57 421.67 96.9 340.97 4.67 342.76"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"143.21 204.62 111.8 252.13 223.7 257.1 219.73 136.85 143.21 204.62"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"364.42 204.62 286.91 135.46 284.32 257.1 396.03 252.13 364.42 204.62"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"149.57 421.67 216.75 388.87 158.71 343.55 149.57 421.67"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"290.88 388.87 358.26 421.67 348.92 343.55 290.88 388.87"}),jsxRuntime.jsx("polygon",{fill:"#d7c1b3",stroke:"#d7c1b3",strokeLinecap:"round",strokeLinejoin:"round",points:"358.26 421.67 290.88 388.87 296.25 432.8 295.65 451.28 358.26 421.67"}),jsxRuntime.jsx("polygon",{fill:"#d7c1b3",stroke:"#d7c1b3",strokeLinecap:"round",strokeLinejoin:"round",points:"149.57 421.67 212.18 451.28 211.78 432.8 216.75 388.87 149.57 421.67"}),jsxRuntime.jsx("polygon",{fill:"#233447",stroke:"#233447",strokeLinecap:"round",strokeLinejoin:"round",points:"213.17 314.54 157.12 298.04 196.67 279.95 213.17 314.54"}),jsxRuntime.jsx("polygon",{fill:"#233447",stroke:"#233447",strokeLinecap:"round",strokeLinejoin:"round",points:"294.46 314.54 310.96 279.95 350.71 298.04 294.46 314.54"}),jsxRuntime.jsx("polygon",{fill:"#cd6116",stroke:"#cd6116",strokeLinecap:"round",strokeLinejoin:"round",points:"149.57 421.67 159.11 340.97 96.9 342.76 149.57 421.67"}),jsxRuntime.jsx("polygon",{fill:"#cd6116",stroke:"#cd6116",strokeLinecap:"round",strokeLinejoin:"round",points:"348.72 340.97 358.26 421.67 410.93 342.76 348.72 340.97"}),jsxRuntime.jsx("polygon",{fill:"#cd6116",stroke:"#cd6116",strokeLinecap:"round",strokeLinejoin:"round",points:"396.03 252.13 284.32 257.1 294.66 314.54 311.16 279.95 350.91 298.04 396.03 252.13"}),jsxRuntime.jsx("polygon",{fill:"#cd6116",stroke:"#cd6116",strokeLinecap:"round",strokeLinejoin:"round",points:"157.12 298.04 196.87 279.95 213.17 314.54 223.7 257.1 111.8 252.13 157.12 298.04"}),jsxRuntime.jsx("polygon",{fill:"#e4751f",stroke:"#e4751f",strokeLinecap:"round",strokeLinejoin:"round",points:"111.8 252.13 158.71 343.55 157.12 298.04 111.8 252.13"}),jsxRuntime.jsx("polygon",{fill:"#e4751f",stroke:"#e4751f",strokeLinecap:"round",strokeLinejoin:"round",points:"350.91 298.04 348.92 343.55 396.03 252.13 350.91 298.04"}),jsxRuntime.jsx("polygon",{fill:"#e4751f",stroke:"#e4751f",strokeLinecap:"round",strokeLinejoin:"round",points:"223.7 257.1 213.17 314.54 226.29 382.31 229.27 293.07 223.7 257.1"}),jsxRuntime.jsx("polygon",{fill:"#e4751f",stroke:"#e4751f",strokeLinecap:"round",strokeLinejoin:"round",points:"284.32 257.1 278.96 292.87 281.34 382.31 294.66 314.54 284.32 257.1"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"294.66 314.54 281.34 382.31 290.88 388.87 348.92 343.55 350.91 298.04 294.66 314.54"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"157.12 298.04 158.71 343.55 216.75 388.87 226.29 382.31 213.17 314.54 157.12 298.04"}),jsxRuntime.jsx("polygon",{fill:"#c0ad9e",stroke:"#c0ad9e",strokeLinecap:"round",strokeLinejoin:"round",points:"295.65 451.28 296.25 432.8 291.28 428.42 216.35 428.42 211.78 432.8 212.18 451.28 149.57 421.67 171.43 439.55 215.75 470.36 291.88 470.36 336.4 439.55 358.26 421.67 295.65 451.28"}),jsxRuntime.jsx("polygon",{fill:"#161616",stroke:"#161616",strokeLinecap:"round",strokeLinejoin:"round",points:"290.88 388.87 281.34 382.31 226.29 382.31 216.75 388.87 211.78 432.8 216.35 428.42 291.28 428.42 296.25 432.8 290.88 388.87"}),jsxRuntime.jsx("polygon",{fill:"#763d16",stroke:"#763d16",strokeLinecap:"round",strokeLinejoin:"round",points:"490.44 156.92 507.33 75.83 482.09 0.5 290.88 142.41 364.42 204.62 468.37 235.03 491.43 208.2 481.49 201.05 497.39 186.54 485.07 177 500.97 164.87 490.44 156.92"}),jsxRuntime.jsx("polygon",{fill:"#763d16",stroke:"#763d16",strokeLinecap:"round",strokeLinejoin:"round",points:"0.5 75.83 17.39 156.92 6.66 164.87 22.56 177 10.44 186.54 26.34 201.05 16.4 208.2 39.26 235.03 143.21 204.62 216.75 142.41 25.54 0.5 0.5 75.83"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"468.37 235.03 364.42 204.62 396.03 252.13 348.92 343.55 410.93 342.76 503.36 342.76 468.37 235.03"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"143.21 204.62 39.26 235.03 4.67 342.76 96.9 342.76 158.71 343.55 111.8 252.13 143.21 204.62"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"284.32 257.1 290.88 142.41 321.1 60.72 186.93 60.72 216.75 142.41 223.7 257.1 226.09 293.27 226.29 382.31 281.34 382.31 281.74 293.27 284.32 257.1"})]})}function We({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"0.5",width:"32",height:"32",rx:"4",fill:"#F1F2F9"}),jsxRuntime.jsx("path",{d:"M26.1001 16.2273C26.1001 15.5182 26.0365 14.8364 25.9183 14.1818H16.5001V18.05H21.8819C21.6501 19.3 20.9456 20.3591 19.8865 21.0682V23.5773H23.1183C25.0092 21.8364 26.1001 19.2727 26.1001 16.2273Z",fill:"#4285F4"}),jsxRuntime.jsx("path",{d:"M16.5001 26C19.2001 26 21.4637 25.1046 23.1182 23.5773L19.8864 21.0682C18.991 21.6682 17.8455 22.0227 16.5001 22.0227C13.8955 22.0227 11.691 20.2637 10.9046 17.9H7.56372V20.4909C9.20917 23.7591 12.591 26 16.5001 26Z",fill:"#34A853"}),jsxRuntime.jsx("path",{d:"M10.9047 17.8999C10.7047 17.2999 10.591 16.659 10.591 15.9999C10.591 15.3408 10.7047 14.6999 10.9047 14.0999V11.509H7.56376C6.86376 12.9025 6.49951 14.4405 6.50012 15.9999C6.50012 17.6136 6.88649 19.1408 7.56376 20.4908L10.9047 17.8999Z",fill:"#FBBC05"}),jsxRuntime.jsx("path",{d:"M16.5001 9.97726C17.9682 9.97726 19.2864 10.4818 20.3228 11.4727L23.191 8.60454C21.4591 6.99091 19.1955 6 16.5001 6C12.591 6 9.20917 8.2409 7.56372 11.5091L10.9046 14.1C11.691 11.7364 13.8955 9.97726 16.5001 9.97726Z",fill:"#EA4335"})]})}function $e({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"0.5",width:"32",height:"32",rx:"4",fill:"#5462EB"}),jsxRuntime.jsx("path",{d:"M23.5433 8.87438C22.2479 8.26174 20.8587 7.81038 19.4063 7.55187C19.3799 7.54688 19.3534 7.55934 19.3398 7.58428C19.1612 7.91179 18.9633 8.33905 18.8247 8.67487C17.2625 8.43382 15.7084 8.43382 14.1782 8.67487C14.0396 8.33158 13.8345 7.91179 13.6551 7.58428C13.6414 7.56018 13.615 7.54771 13.5886 7.55187C12.1369 7.80955 10.7478 8.26092 9.45159 8.87438C9.44037 8.87937 9.43075 8.88769 9.42437 8.89849C6.78947 12.9558 6.06766 16.9134 6.42176 20.8219C6.42336 20.841 6.43378 20.8593 6.4482 20.871C8.18663 22.1868 9.87059 22.9857 11.5233 23.5152C11.5497 23.5235 11.5778 23.5135 11.5946 23.491C11.9855 22.9408 12.334 22.3606 12.6328 21.7504C12.6505 21.7147 12.6336 21.6723 12.5976 21.6581C12.0448 21.442 11.5185 21.1785 11.0122 20.8793C10.9721 20.8552 10.9689 20.7961 11.0058 20.7679C11.1123 20.6856 11.2189 20.6 11.3206 20.5135C11.339 20.4977 11.3647 20.4944 11.3863 20.5044C14.7125 22.0696 18.3136 22.0696 21.6006 20.5044C21.6222 20.4936 21.6479 20.4969 21.6671 20.5127C21.7688 20.5991 21.8754 20.6856 21.9827 20.7679C22.0196 20.7961 22.0172 20.8552 21.9771 20.8793C21.4708 21.1843 20.9445 21.442 20.3909 21.6573C20.3548 21.6715 20.3388 21.7147 20.3564 21.7504C20.6617 22.3597 21.0101 22.9399 21.3939 23.4902C21.4099 23.5135 21.4387 23.5235 21.4652 23.5152C23.1259 22.9857 24.8099 22.1868 26.5483 20.871C26.5635 20.8593 26.5731 20.8419 26.5747 20.8228C26.9985 16.3041 25.8649 12.3789 23.5697 8.89931C23.5641 8.88769 23.5545 8.87937 23.5433 8.87438Z",fill:"#F7F7F7"})]})}function Fe({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"0.5",width:"32",height:"32",rx:"4",fill:"black"}),jsxRuntime.jsx("path",{d:"M8.53901 8L14.7164 16.2153L8.5 22.8947H9.89907L15.3415 17.0468L19.7389 22.8947H24.5L17.975 14.2173L23.7612 8H22.3621L17.3499 13.3858L13.3001 8H8.53901ZM10.5964 9.02501H12.7837L22.4422 21.8695H20.255L10.5964 9.02501Z",fill:"#F7F7F7"})]})}function Be({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"0.5",width:"32",height:"32",rx:"4",fill:"#000000"}),jsxRuntime.jsx("path",{d:"M21.3611 16.7384C21.3807 18.9244 23.2792 19.6519 23.3001 19.661C23.2841 19.7124 22.9971 20.6962 22.3005 21.7115C21.6987 22.5892 21.0742 23.4636 20.0904 23.4816C19.1237 23.4994 18.8127 22.9098 17.7076 22.9098C16.6029 22.9098 16.2574 23.4636 15.3423 23.4994C14.3928 23.5352 13.6694 22.5504 13.0626 21.676C11.8226 19.8879 10.8747 16.6229 12.1471 14.4182C12.7791 13.3234 13.9087 12.6304 15.1346 12.6126C16.0668 12.5948 16.9468 13.2378 17.5167 13.2378C18.0865 13.2378 19.1555 12.4647 20.2795 12.579C20.7501 12.5986 22.0715 12.7692 22.9207 14.0122C22.852 14.0549 21.3453 14.9328 21.3611 16.7384ZM19.5432 11.392C20.0472 10.7809 20.3862 9.93 20.2939 9.08325C19.5709 9.11221 18.6961 9.56574 18.1749 10.1763C17.708 10.717 17.2995 11.582 17.4096 12.4111C18.2158 12.4736 19.0391 12.003 19.5432 11.392Z",fill:"#FFFFFF"})]})}function mn({config:e,onSuccess:t,title:s="Log in or Sign up",showWallets:d,showOTP:u,hideHeader:h,onOTPSubmit:g,otpLabel:i="Access Code",oauthInline:l,oauthFirst:c,className:m=""}){let o=Ie(e),{isAuthenticated:a,wallet:n,loading:p,error:r,authenticateSolana:y,authenticateEVM:S,authenticateOTP:w,authenticateOAuth:T,bridge:x,stackId:C}=o,z=!e.stackId&&!C,W=e.stacknetUrl||"https://stacknet.magma-rpc.com",{config:j,identityProviders:b,loading:L}=re(C||e.stackId||null,W),[A,D]=react.useState(z?"stack-select":"select"),[N,I]=react.useState(null),[R,E]=react.useState(false),[P,U]=react.useState("idle"),[_,G]=react.useState(""),[V,Z]=react.useState([]),[mt,Ve]=react.useState(e.stackId||null),[le,ht]=react.useState(false),[yt,kt]=react.useState(false);react.useEffect(()=>{if(typeof window>"u")return;let f=()=>{let Y=window;ht(!!(Y.phantom?.solana?.isPhantom||Y.solana?.isPhantom));let q=Y.ethereum;kt(!!(q?.isMetaMask||q?.providers?.some(X=>X.isMetaMask)));};f(),window.addEventListener("ethereum#initialized",f);let H=setTimeout(f,500);return ()=>{window.removeEventListener("ethereum#initialized",f),clearTimeout(H);}},[]),react.useEffect(()=>{A==="stack-select"&&C&&(Ve(C),D("select"));},[A,C]),react.useEffect(()=>{if(!(!x.ready||!z)&&x.identity){let f=[];x.resolvedStackId&&f.push({stackId:x.resolvedStackId,domain:typeof window<"u"?window.location.origin:""}),Promise.all(f.map(async H=>{try{let Y=await fetch(`${W}/api/v2/stacks/${H.stackId}`);if(Y.ok){let q=await Y.json(),X=q.data?.stack||q;H.name=X.displayName||X.name,H.logoUrl=X.logoUrl;}}catch{}return H})).then(Z);}},[x.ready,x.identity,x.resolvedStackId,z,W]),react.useEffect(()=>{a&&A==="success"&&t?.();},[a,A,t]);let Ye=d||(b.length>0?b.filter(f=>f.type==="wallet").map(f=>f.id):["phantom","metamask"]),Je=u!==void 0?u:b.length>0?b.some(f=>f.type==="otp"):true,K=b.filter(f=>f.type==="oauth"),ke=new Set(c||[]),Ze=K.filter(f=>ke.has(f.id)),be=l?K.filter(f=>!ke.has(f.id)):K,Ke=async f=>{I(f),D("connecting"),await T(f)||D("error");},bt=async()=>{I("phantom"),D("connecting");let f=await y("phantom");D(f?"success":"error");},wt=async()=>{I("metamask"),D("connecting");let f=await S();D(f?"success":"error");},St=async f=>{U("verifying"),G(""),await(g||w)(f)?(U("success"),D("success")):(U("error"),G("Invalid or expired code"),setTimeout(()=>U("idle"),2e3));},qe=()=>{D(z&&!mt?"stack-select":"select"),I(null),E(false),U("idle"),G("");};return jsxRuntime.jsxs("div",{className:`w-full max-w-md space-y-3 ${m}`,children:[!h&&jsxRuntime.jsxs("div",{className:"mb-6 text-center",children:[j?.logoUrl&&A!=="stack-select"&&jsxRuntime.jsx("img",{src:ee(j.logoUrl),alt:j.displayName||"",className:"h-16 w-16 mx-auto mb-4 rounded-xl"}),j?.displayName&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-400 mb-2",children:j.displayName}),jsxRuntime.jsx("h1",{className:"font-semibold text-2xl text-white",children:"Log in or Sign up"})]}),A==="stack-select"&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-center text-sm text-zinc-400 mb-4",children:V.length>0?"Select a network to continue":"No previous connections found. Enter a Stack ID to continue."}),V.map(f=>jsxRuntime.jsxs("button",{onClick:()=>{Ve(f.stackId),D("select");},className:"flex w-full cursor-pointer items-center gap-4 rounded-xl border border-zinc-800 bg-[#25252f] p-4 transition-colors hover:bg-[#2d2d3a]",children:[f.logoUrl?jsxRuntime.jsx("img",{src:ee(f.logoUrl),alt:"",className:"h-10 w-10 flex-shrink-0"}):jsxRuntime.jsx("div",{className:"h-10 w-10 flex-shrink-0 bg-zinc-700 flex items-center justify-center text-zinc-400 text-sm font-mono",children:f.name?.[0]?.toUpperCase()||"S"}),jsxRuntime.jsxs("div",{className:"flex-1 text-left",children:[jsxRuntime.jsx("span",{className:"font-medium text-white",children:f.name||f.stackId}),jsxRuntime.jsx("p",{className:"text-xs text-zinc-500",children:f.domain})]}),jsxRuntime.jsx("span",{className:"text-xs text-zinc-600",children:"Previously connected"})]},f.stackId)),x.ready&&!x.known&&jsxRuntime.jsx("p",{className:"text-center text-xs text-zinc-600 mt-4",children:"Connect to a stack for the first time to get started."})]}),A==="select"&&L&&jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsx("div",{className:"h-6 w-6 border-2 border-zinc-600 border-t-white animate-spin",style:{borderRadius:"50%"}})}),r&&A==="error"&&jsxRuntime.jsxs("div",{className:"mb-4 border border-red-500/30 bg-red-500/10 p-4",children:[jsxRuntime.jsx("p",{className:"text-center text-red-400 text-sm",children:r}),jsxRuntime.jsx("button",{className:"mt-3 w-full text-sm text-zinc-400 hover:text-white",onClick:qe,children:"Try Again"})]}),A==="success"&&jsxRuntime.jsxs("div",{className:"border border-green-500/30 bg-green-500/10 p-6 text-center",children:[jsxRuntime.jsx("p",{className:"font-medium text-green-400 text-sm",children:"Connected!"}),jsxRuntime.jsx("p",{className:"mt-1 text-xs text-zinc-400",children:"Redirecting..."})]}),A==="connecting"&&p&&jsxRuntime.jsxs("div",{style:{border:"1px solid #27272a",background:"#25252f",padding:24,textAlign:"center"},children:[jsxRuntime.jsxs("div",{style:{width:40,height:40,margin:"0 auto 12px"},children:[N==="phantom"&&jsxRuntime.jsx(fe,{style:$}),N==="metamask"&&jsxRuntime.jsx(ge,{style:$})]}),jsxRuntime.jsx("p",{style:{fontWeight:500,fontSize:14,color:"#fff"},children:n.connected?"Signing message...":"Connecting wallet..."}),jsxRuntime.jsx("p",{style:{marginTop:4,fontSize:12,color:"#71717a"},children:"Please confirm in your wallet"}),jsxRuntime.jsx("button",{style:{marginTop:16,fontSize:14,color:"#71717a",background:"none",border:"none",cursor:"pointer"},onClick:qe,children:"Cancel"})]}),A==="select"&&!p&&!L&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Ze.map(f=>jsxRuntime.jsxs("button",{onClick:()=>Ke(f.id),style:ae,children:[jsxRuntime.jsx(ut,{provider:f.id}),jsxRuntime.jsx("span",{style:{fontWeight:500,color:"#fff"},children:pt(f.id,f.name)})]},f.id)),Ye.includes("phantom")&&jsxRuntime.jsxs("button",{onClick:bt,disabled:!le,style:{...ae,opacity:le?1:.5,cursor:le?"pointer":"not-allowed"},children:[jsxRuntime.jsx(fe,{style:{...$,borderRadius:8}}),jsxRuntime.jsx("span",{style:{flex:1,textAlign:"left",fontWeight:500,color:"#fff"},children:"Phantom"}),!le&&jsxRuntime.jsx("span",{style:{fontSize:12,color:"#71717a"},children:"Not installed"})]}),Ye.includes("metamask")&&yt&&jsxRuntime.jsxs("button",{onClick:wt,style:ae,children:[jsxRuntime.jsx(ge,{style:$}),jsxRuntime.jsx("span",{style:{flex:1,textAlign:"left",fontWeight:500,color:"#fff"},children:"MetaMask"})]}),Je&&!R&&jsxRuntime.jsxs("button",{onClick:()=>E(true),style:ae,children:[jsxRuntime.jsx("div",{style:{...$,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid #3f3f46",background:"#2a2a3e"},children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"#a1a1aa",children:jsxRuntime.jsx("path",{d:"M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Z"})})}),jsxRuntime.jsx("span",{style:{flex:1,textAlign:"left",fontWeight:500,color:"#fff"},children:i})]}),Je&&R&&jsxRuntime.jsxs("div",{style:{borderRadius:12,border:"1px solid #27272a",background:"#25252f",padding:24},children:[jsxRuntime.jsx("p",{style:{textAlign:"center",fontSize:14,color:"#a1a1aa",marginBottom:16},children:"Enter your 6-digit access code"}),jsxRuntime.jsx(pe,{onComplete:St,disabled:P==="verifying",error:_}),P==="verifying"&&jsxRuntime.jsx("p",{style:{textAlign:"center",fontSize:14,color:"#a1a1aa",marginTop:16},children:"Verifying..."}),P==="success"&&jsxRuntime.jsx("p",{style:{textAlign:"center",fontSize:14,color:"#4ade80",marginTop:16},children:"Verified!"}),j?.webPageUrl&&P==="idle"&&(()=>{let f=ee(j.webPageUrl);return f==="#"?null:jsxRuntime.jsx("a",{href:`${f.replace(/\/$/,"")}/connect/pair`,target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",fontSize:14,color:"#71717a",marginTop:16},children:"Get code"})})()]}),(l?be:K).length>0&&(!l||be.length>0)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!l&&Ze.length===0&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 0"},children:[jsxRuntime.jsx("div",{style:{flex:1,borderTop:"1px solid #27272a"}}),jsxRuntime.jsx("span",{style:{fontSize:12,color:"#52525b"},children:"or continue with"}),jsxRuntime.jsx("div",{style:{flex:1,borderTop:"1px solid #27272a"}})]}),(l?be:K.filter(f=>!ke.has(f.id))).map(f=>jsxRuntime.jsxs("button",{onClick:()=>Ke(f.id),style:ae,children:[jsxRuntime.jsx(ut,{provider:f.id}),jsxRuntime.jsx("span",{style:{fontWeight:500,color:"#fff"},children:pt(f.id,f.name)})]},f.id))]})]})]})}var $={width:40,height:40,flexShrink:0},ae={display:"flex",width:"100%",alignItems:"center",gap:12,borderRadius:12,border:"1px solid #27272a",background:"#25252f",padding:16,cursor:"pointer",transition:"background 0.15s"};function ut({provider:e}){switch(e){case "google":return jsxRuntime.jsx(We,{style:{...$,borderRadius:8}});case "discord":return jsxRuntime.jsx($e,{style:{...$,borderRadius:8}});case "twitter":return jsxRuntime.jsx(Fe,{style:{...$,borderRadius:8}});case "apple":return jsxRuntime.jsx(Be,{style:{...$,borderRadius:8}});default:return jsxRuntime.jsx("div",{style:{...$,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid #3f3f46",background:"#2a2a3e",fontSize:14,color:"#a1a1aa",fontFamily:"monospace"},children:e[0]?.toUpperCase()})}}function pt(e,t){return {google:"Google",discord:"Discord",twitter:"Twitter",apple:"Apple"}[e]||t||e}function kn({mid:e,apiBaseUrl:t="",scope:s,onSave:d,className:u}){let{profile:h,loading:g,saving:i,error:l,updateProfile:c}=je(e,{apiBaseUrl:t,scope:s}),[m,o]=react.useState(null),[a,n]=react.useState(null),[p,r]=react.useState(null),y=react.useRef(null),[S,w]=react.useState(false),T=m??h?.username??"",x=a??h?.bio??"",C=p??h?.avatarUrl,z=react.useCallback(b=>{let L=b.target.files?.[0];if(!L)return;let A=new FileReader;A.onload=()=>{r(A.result),w(true);},A.readAsDataURL(L);},[]),W=async()=>{await c({username:T||void 0,avatarUrl:p??h?.avatarUrl,bio:x||void 0})&&(w(false),d?.());};if(g)return jsxRuntime.jsxs("div",{className:u,style:{display:"grid",gap:"1.5rem"},children:[jsxRuntime.jsx("div",{style:{height:40,background:"var(--x-color-neutral-800, #333)",animation:"pulse 2s infinite"}}),jsxRuntime.jsx("div",{style:{height:40,background:"var(--x-color-neutral-800, #333)",animation:"pulse 2s infinite"}})]});let j=s==="global"||!s?"Global profile":`Stack profile (${s.stackId})`;return jsxRuntime.jsxs("div",{className:u,style:{display:"grid",gap:"1.5rem"},children:[jsxRuntime.jsx("p",{style:{fontSize:11,color:"var(--x-color-neutral-500, #91918D)",textTransform:"uppercase",letterSpacing:"0.05em"},children:j}),jsxRuntime.jsxs("div",{style:{display:"grid",gap:"1.5rem",gridTemplateColumns:"1fr 1fr"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[jsxRuntime.jsx("label",{style:{fontSize:14,color:"var(--x-color-neutral-400, #91918D)"},children:"Username"}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>y.current?.click(),style:{width:40,height:40,flexShrink:0,cursor:"pointer",overflow:"hidden",background:"var(--x-color-neutral-800, #262625)",border:"none",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:C?jsxRuntime.jsx("img",{src:C,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--x-color-neutral-500, #91918D)"},children:[jsxRuntime.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),jsxRuntime.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}),jsxRuntime.jsx("input",{type:"text",value:T,onChange:b=>{o(b.target.value),w(true);},placeholder:"Enter username",maxLength:30,style:{flex:1,padding:"0.75rem 1rem",fontSize:14,background:"var(--x-color-neutral-800, #262625)",color:"var(--x-color-neutral-100, #FAFAF7)",border:"none",outline:"none"}})]}),jsxRuntime.jsx("input",{ref:y,type:"file",accept:"image/*",onChange:z,style:{display:"none"}})]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[jsxRuntime.jsx("label",{style:{fontSize:14,color:"var(--x-color-neutral-400, #91918D)"},children:"Bio"}),jsxRuntime.jsx("input",{type:"text",value:x,onChange:b=>{n(b.target.value),w(true);},placeholder:"Tell us about yourself",maxLength:200,style:{width:"100%",padding:"0.75rem 1rem",fontSize:14,background:"var(--x-color-neutral-800, #262625)",color:"var(--x-color-neutral-100, #FAFAF7)",border:"none",outline:"none"}})]})]}),l&&jsxRuntime.jsx("p",{style:{fontSize:13,color:"var(--x-color-red-500, #BF4D43)"},children:l}),S&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[jsxRuntime.jsx("button",{onClick:W,disabled:i,style:{padding:"0.5rem 1.25rem",fontSize:13,fontWeight:700,background:"var(--x-color-blue-600, #165DFC)",color:"#FFF",border:"none",cursor:i?"wait":"pointer",opacity:i?.6:1},children:i?"Saving...":"Save"}),jsxRuntime.jsx("button",{onClick:()=>{o(null),n(null),r(null),w(false);},style:{padding:"0.5rem 1.25rem",fontSize:13,background:"var(--x-color-neutral-800, #262625)",color:"var(--x-color-neutral-400, #91918D)",border:"none",cursor:"pointer"},children:"Cancel"}),jsxRuntime.jsx("p",{style:{fontSize:11,color:"var(--x-color-neutral-500, #666663)",alignSelf:"center",marginLeft:"0.5rem"},children:"Profile updates cost 10M tokens"})]})]})}function bn({className:e}){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",className:e||"h-5 w-5",children:[jsxRuntime.jsxs("linearGradient",{id:"sol-g",x1:"7.233",x2:"24.766",y1:"24.766",y2:"7.234",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{offset:"0",stopColor:"#9945ff"}),jsxRuntime.jsx("stop",{offset:"0.2",stopColor:"#7962e7"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#00d18c"})]}),jsxRuntime.jsx("path",{fill:"#10111a",d:"M0 0h32v32H0z"}),jsxRuntime.jsx("path",{fill:"url(#sol-g)",fillRule:"evenodd",d:"M9.873 20.41a.65.65 0 0 1 .476-.21l14.662.012a.323.323 0 0 1 .238.54l-3.123 3.438a.64.64 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.64.64 0 0 1-.476-.21l-3.122-3.44a.323.323 0 0 1 .238-.54l14.662-.012a.64.64 0 0 1 .475.21zM9.873 7.81a.64.64 0 0 1 .476-.21l14.662.012a.322.322 0 0 1 .238.54l-3.123 3.438a.64.64 0 0 1-.475.21l-14.662-.012a.323.323 0 0 1-.238-.54z",clipRule:"evenodd"})]})}function wn({className:e}){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",className:e||"h-5 w-5",children:[jsxRuntime.jsx("rect",{width:"20",height:"20",rx:"4",fill:"#627EEA",fillOpacity:"0.2"}),jsxRuntime.jsx("path",{fill:"#627EEA",d:"M10 3l-4 6.5 4 2.5 4-2.5L10 3z"}),jsxRuntime.jsx("path",{fill:"#627EEA",fillOpacity:"0.6",d:"M6 9.5L10 12l4-2.5L10 17 6 9.5z"})]})}function Cn({className:e}){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",className:e||"h-8 w-8",children:[jsxRuntime.jsx("rect",{width:"512",height:"512",rx:"15%",fill:"#37aee2"}),jsxRuntime.jsx("path",{fill:"#c8daea",d:"M199 404c-11 0-10-4-13-14l-32-105 245-144"}),jsxRuntime.jsx("path",{fill:"#a9c9dd",d:"M199 404c7 0 11-4 16-8l45-43-56-34"}),jsxRuntime.jsx("path",{fill:"#f6fbfe",d:"M204 319l135 99c14 9 26 4 30-14l55-258c5-22-9-32-24-25L79 245c-21 8-21 21-4 26l83 26 190-121c9-5 17-3 11 4"})]})}function vn(e){let{apiBaseUrl:t,stacknetUrl:s="https://stacknet.magma-rpc.com",stackId:d="",transport:u,serviceKey:h,onAuthSuccess:g,onAuthError:i,onLogout:l}=e;async function c(o){if(!o.ok){let r=await o.json().catch(()=>({})),y=new Error(r.error||`Authentication failed (${o.status})`);throw i?.(y),y}let a=await o.json(),n=a.token||a.jwt,p=a.session||{userId:a.user?.id||a.userId||a.sub||"",address:a.user?.address||a.address,chain:a.user?.chain||a.chain,expiresAt:a.expiresAt||Date.now()+10080*60*1e3,authMethod:a.authMethod||a.method};return n&&await u.storeCredentials(n,p),g?.(p),p}return {async login(o,a){let n=await fetch(`${t}/api/auth/callback/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o,password:a})});return c(n)},async loginWeb3({chain:o,address:a,message:n,signature:p}){let r={chain:o,message:n,signature:p,stackId:d};o==="solana"&&(r.publicKey=a);let y=await fetch(`${t}/api/auth/callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});return c(y)},async loginOTP(o){let a=await fetch(`${t}/api/auth/otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:o})});return c(a)},async getSession(){let o=await u.getStoredSession();if(o&&o.expiresAt>Date.now())return o;try{let a=await u.getHeaders(),n=await fetch(`${t}/api/auth/session`,{headers:a});if(n.ok){let p=await n.json();if(p.session)return p.session}}catch{if(o)return o}return null},async checkSession(){let o=await u.getToken();if(!o)return false;try{let a=await fetch(`${t}/api/history?limit=1`,{headers:{Authorization:`Bearer ${o}`}});return a.ok?!0:a.status===401?(await u.clear(),!1):!0}catch{return true}},async getChallenge(o,a){let p=`${s}/api/v2/stacks/${encodeURIComponent(d)}/auth/web3/challenge`,r=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chain:o,address:a})});if(!r.ok)throw new Error("Failed to get challenge");let y=await r.json();return y.data||y},async logout(){try{let o=await u.getHeaders();await fetch(`${t}/api/auth/logout`,{method:"POST",headers:o});}catch{}await u.clear(),l?.();},async getHeaders(){let o=await u.getHeaders();return Object.keys(o).length>0?o:h?{Authorization:`Bearer ${h}`}:{}},async getToken(){return u.getToken()}}}function Nn(){return {async storeCredentials(e,t){},async getToken(){return null},async getHeaders(){return {}},async getStoredSession(){let e=te();return !e||e.expiresAt<=Date.now()?null:{userId:e.userId,address:e.address,chain:e.chain,expiresAt:e.expiresAt,planId:e.planId,authMethod:e.authMethod}},async clear(){}}}var He="stackauth_token",Qe="stackauth_session";function In(e){return {async storeCredentials(t,s){await e.setItemAsync(He,t),await e.setItemAsync(Qe,JSON.stringify(s));},async getToken(){try{return await e.getItemAsync(He)}catch{return null}},async getHeaders(){let t=await this.getToken();return t?{Authorization:`Bearer ${t}`}:{}},async getStoredSession(){try{let t=await e.getItemAsync(Qe);return t?JSON.parse(t):null}catch{return null}},async clear(){await e.deleteItemAsync(He).catch(()=>{}),await e.deleteItemAsync(Qe).catch(()=>{});}}}
|
|
2
|
-
exports.AppleIcon=
|
|
1
|
+
'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),react=require('react'),jsxRuntime=require('react/jsx-runtime');function Rt(...e){return tailwindMerge.twMerge(clsx.clsx(e))}function Et(e){return e>=1e12?`${(e/1e12).toFixed(e%1e12===0?0:1)}T`:e>=1e9?`${(e/1e9).toFixed(e%1e9===0?0:1)}B`:e>=1e6?`${(e/1e6).toFixed(e%1e6===0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:e.toLocaleString()}function _t(e,t){if(!e)return "/";if(e.startsWith("/")&&!e.startsWith("//"))return e;try{let r=new URL(e,t);return r.origin!==t?"/":r.pathname+r.search+r.hash}catch{return "/"}}function ne(e,t="#"){if(!e||typeof e!="string")return t;let r=e.trim();if(r===""||r==="#")return t;if(r.startsWith("/")||r.startsWith("./")||r.startsWith("../"))return r;try{let d=new URL(r);if(d.protocol==="http:"||d.protocol==="https:")return d.toString()}catch{}return t}function $t(e){try{let t=e.split(".");if(t.length!==3)return null;let r=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(r)}catch{return null}}function oe(){if(typeof document>"u")return null;try{let e=document.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith("stackauth_session="));if(!e)return null;let t=e.slice(18);return JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")))}catch{return null}}function Q(e="__csrf"){if(typeof document>"u")return null;let t=document.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith(`${e}=`));return t?t.slice(e.length+1):null}function re(){let[e,t]=react.useState(null),[r,d]=react.useState(true),p=react.useCallback(()=>{let a=oe();a&&a.expiresAt>Date.now()?t({userId:a.userId,address:a.address,chain:a.chain,expiresAt:a.expiresAt,planId:a.planId,authMethod:a.authMethod}):t(null),d(false);},[]);react.useEffect(()=>{p();},[p]);let y=react.useCallback(async(a="")=>{try{let l=await fetch(`${a}/api/auth/session`);if(l.ok){let c=await l.json();if(c.session)return t(c.session),c.session}return t(null),null}catch{return null}},[]),m=!!e&&e.expiresAt>Date.now();return {session:e,loading:r,isAuthenticated:m,refresh:y,readSession:p}}function Pe(e="__csrf",t="x-csrf-token"){let[r,d]=react.useState(null);react.useEffect(()=>{d(Q(e));},[e]);let p=r?{[t]:r}:{};return {token:r,headers:p}}function Ie(){let[e,t]=react.useState({connected:false,address:null,chain:null,provider:null}),[r,d]=react.useState(null),p=react.useCallback(async(l="phantom")=>{d(null);try{let c=typeof window<"u"?window:null,h=l==="phantom"?c?.phantom?.solana||c?.solana:c?.solflare;if(!h)return d(`${l} wallet not found`),null;let i=(await h.connect()).publicKey.toString();return t({connected:!0,address:i,chain:"solana",provider:l}),i}catch(c){return d(c.message||"Failed to connect wallet"),null}},[]),y=react.useCallback(async()=>{d(null);try{let c=(typeof window<"u"?window:null)?.ethereum;if(!c)return d("MetaMask not found"),null;let h=c;c.providers?.length&&(h=c.providers.find(n=>n.isMetaMask)||c);let i=(await h.request({method:"eth_requestAccounts"}))[0];return i?(t({connected:!0,address:i,chain:"ethereum",provider:"metamask"}),i):(d("No account selected"),null)}catch(l){return d(l.message||"Failed to connect wallet"),null}},[]),m=react.useCallback(async(l,c)=>{d(null);let h=c?.chain||e.chain,o=c?.provider||e.provider,i=c?.address||e.address;try{if(h==="solana"){let n=typeof window<"u"?window:null,g=o==="solflare"?n?.solflare:n?.phantom?.solana||n?.solana;if(!g)throw new Error("Wallet not available");let s=new TextEncoder().encode(l),k=await g.signMessage(s,"utf8"),C=new Uint8Array(k.signature||k),w="";for(let L=0;L<C.byteLength;L++)w+=String.fromCharCode(C[L]);return btoa(w)}if(h==="ethereum"){let g=(typeof window<"u"?window:null)?.ethereum;if(g?.providers?.length&&(g=g.providers.find(k=>k.isMetaMask)||g),!g)throw new Error("MetaMask not available");return await g.request({method:"personal_sign",params:[l,i]})}throw new Error("No wallet connected")}catch(n){return d(n.message||"Signing failed"),null}},[e]),a=react.useCallback(()=>{t({connected:false,address:null,chain:null,provider:null}),d(null);},[]);return {wallet:e,error:r,connectSolana:p,connectEVM:y,signMessage:m,disconnect:a}}var Jt="https://stacknet.magma-rpc.com/auth/bridge",fe="stacknet-auth-bridge";function Ae(e){let t=e?.bridgeUrl||Jt,r=e?.disabled||false,d=react.useRef(null),[p,y]=react.useState({ready:false,known:false,identity:null,identityCount:0,resolvedStackId:null}),m=react.useRef([]),a=react.useRef(false),l=react.useCallback(n=>{let g={...n,protocol:fe};a.current&&d.current?.contentWindow?d.current.contentWindow.postMessage(g,new URL(t).origin):m.current.push(g);},[t]);react.useEffect(()=>{if(r)return;let n=s=>{if(!(!s.data||s.data.protocol!==fe)){try{if(s.origin!==new URL(t).origin)return}catch{return}switch(s.data.type){case "bridge:ready":a.current=true,y(k=>({...k,ready:true}));for(let k of m.current)d.current?.contentWindow?.postMessage(k,s.origin);m.current=[],d.current?.contentWindow?.postMessage({protocol:fe,type:"auth:check"},s.origin),d.current?.contentWindow?.postMessage({protocol:fe,type:"auth:resolve-stack"},s.origin);break;case "auth:status":y(k=>({...k,known:s.data.known,identity:s.data.identity,identityCount:s.data.identityCount||0}));break;case "auth:resolved-stack":y(k=>({...k,resolvedStackId:s.data.stackId||null}));break;}}};window.addEventListener("message",n);let g=document.createElement("iframe");return g.src=t,g.style.display="none",g.setAttribute("aria-hidden","true"),g.setAttribute("tabindex","-1"),g.setAttribute("sandbox","allow-scripts allow-same-origin"),document.body.appendChild(g),d.current=g,()=>{window.removeEventListener("message",n),g.parentNode&&g.parentNode.removeChild(g),d.current=null,a.current=false;}},[t,r]);let c=react.useCallback(n=>{l({type:"auth:connected",...n});},[l]),h=react.useCallback(n=>{l({type:"auth:disconnected",...n});},[l]),o=react.useCallback(()=>{l({type:"auth:clear"}),y({ready:p.ready,known:false,identity:null,identityCount:0,resolvedStackId:null});},[l,p.ready]),i=react.useCallback(()=>{l({type:"auth:check"});},[l]);return {...p,reportConnected:c,reportDisconnected:h,clearAll:o,refresh:i}}async function dt(e,t,r,d){let p=e.apiVersion||"v2",y=`${e.baseUrl}/api/${p}${r}`;try{let m=await fetch(y,{method:t,headers:{"Content-Type":"application/json"},body:d?JSON.stringify(d):void 0}),a=await m.json();return m.ok?a.success&&a.data!==void 0?{success:!0,data:a.data}:{success:!0,data:a}:{success:!1,error:a.error||{code:"UNKNOWN_ERROR",message:"Unknown error"}}}catch(m){return {success:false,error:{code:"NETWORK_ERROR",message:m instanceof Error?m.message:"Network error"}}}}function Me(e){return {getNetworkStatus:()=>dt(e,"GET","/network/status"),getWeb3Challenge:(t,r)=>dt(e,"POST",`/stacks/${encodeURIComponent(e.stackId)}/auth/web3/challenge`,{chain:t,address:r})}}function Le(e={apiBaseUrl:""}){let{wallet:t,connectSolana:r,connectEVM:d,signMessage:p,disconnect:y}=Ie(),{session:m,isAuthenticated:a,refresh:l,readSession:c}=re(),{headers:h}=Pe(),o=Ae({disabled:typeof window>"u"}),[i,n]=react.useState(false),[g,s]=react.useState(null),[k,C]=react.useState(false),w=e.apiBaseUrl||"",L=e.stacknetUrl||"https://stacknet.magma-rpc.com",I=e.stackId||o.resolvedStackId||"",v=Me({baseUrl:L,stackId:I}),F=react.useCallback(async(P,S,N,_)=>{n(true),s(null);try{let A=S;if(!A){let Y=await N();if(!Y)return n(!1),!1;A=Y;}let z=await v.getWeb3Challenge(P,A);if(!z.success||!z.data)return s("Failed to get challenge"),n(!1),!1;let E=await p(z.data.message,{chain:P,provider:_,address:A});if(!E)return n(!1),!1;let J={chain:P,message:z.data.message,signature:E,stackId:I};P==="solana"&&(J.publicKey=A);let H=await fetch(`${w}/api/auth/callback`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(J)});if(!H.ok){let Y=await H.json().catch(()=>({}));return s(Y.error||"Authentication failed"),n(!1),!1}return o.reportConnected({address:A,chain:P,method:_||(P==="solana"?"phantom":"metamask"),stackId:I}),c(),n(!1),!0}catch(A){return s(A.message||"Authentication failed"),n(false),false}},[w,v,p,c,o,I]),U=react.useCallback(async(P="phantom")=>{let S=await r(P);return S?F("solana",S,()=>r(P),P):false},[r,F]),R=react.useCallback(async()=>{let P=await d();return P?F("ethereum",P,d,"metamask"):false},[d,F]),b=react.useCallback(async P=>{n(true),s(null);try{let S=await fetch(`${w}/api/auth/otp`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({code:P})});if(!S.ok){let N=await S.json().catch(()=>({}));return s(N.error||"Invalid code"),n(!1),!1}return c(),n(!1),!0}catch(S){return s(S.message||"OTP verification failed"),n(false),false}},[w,c]),T=react.useCallback(async(P,S)=>{n(true),s(null);try{let N=S||`${window.location.origin}/api/auth/oauth/callback`,_=new URLSearchParams({provider:P,redirectUri:N,stackId:I}),A=await fetch(`${w}/api/auth/oauth/start?${_}`,{credentials:"include"});if(!A.ok){let E=await A.json().catch(()=>({}));return s(E.error||"Failed to start OAuth flow"),n(!1),!1}let z=await A.json();if(z.redirect_url){let E;try{E=new URL(z.redirect_url);}catch{return s("Invalid OAuth redirect URL"),n(!1),!1}let J=[/(^|\.)accounts\.google\.com$/,/(^|\.)discord\.com$/,/(^|\.)github\.com$/,/(^|\.)x\.com$/,/(^|\.)twitter\.com$/,/(^|\.)apple\.com$/];return E.protocol!=="https:"||!J.some(H=>H.test(E.hostname))?(s(`Refusing to redirect to non-OAuth host: ${E.hostname}`),n(!1),!1):(typeof sessionStorage<"u"&&(sessionStorage.setItem("oauth_state",z.state||""),sessionStorage.setItem("oauth_provider",P)),window.location.href=E.toString(),!0)}return s("No redirect URL returned"),n(!1),!1}catch(N){return s(N.message||"OAuth flow failed"),n(false),false}},[w,I]),O=react.useCallback(async(P,S,N)=>{n(true),s(null);try{if(typeof sessionStorage<"u"){let A=sessionStorage.getItem("oauth_state"),z=sessionStorage.getItem("oauth_provider");if(sessionStorage.removeItem("oauth_state"),sessionStorage.removeItem("oauth_provider"),!A||A!==N)return s("OAuth state mismatch \u2014 refusing to complete login"),n(!1),!1;if(z&&z!==P)return s("OAuth provider mismatch \u2014 refusing to complete login"),n(!1),!1}let _=await fetch(`${w}/api/auth/oauth/callback`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({provider:P,code:S,state:N,stackId:I})});if(!_.ok){let A=await _.json().catch(()=>({}));return s(A.error||"OAuth authentication failed"),n(!1),!1}return c(),n(!1),!0}catch(_){return s(_.message||"OAuth callback failed"),n(false),false}},[w,I,c]),G=react.useCallback(async()=>{t.address&&t.chain&&o.reportDisconnected({address:t.address,chain:t.chain,stackId:I});try{await fetch(`${w}/api/auth/logout`,{method:"POST",headers:h,credentials:"include"});}catch{}y(),c();},[w,h,y,c,t,o,I]);return react.useEffect(()=>{if(!e.autoConnect||k||a||!o.ready||!o.known||!o.identity)return;C(true);let{chain:P,method:S}=o.identity;P==="solana"&&(S==="phantom"||S==="solflare")?U(S):P==="ethereum"&&R();},[e.autoConnect,k,a,o,U,R]),{session:m,isAuthenticated:a,wallet:t,loading:i,error:g,authenticateSolana:U,authenticateEVM:R,authenticateOTP:b,authenticateOAuth:T,authenticateOAuthCallback:O,logout:G,refresh:()=>l(w),stackId:I,bridge:{ready:o.ready,known:o.known,identity:o.identity,identityCount:o.identityCount,resolvedStackId:o.resolvedStackId}}}function ie(e,t="https://stacknet.magma-rpc.com"){let[r,d]=react.useState(null),[p,y]=react.useState(false),[m,a]=react.useState(null),l=react.useCallback(async h=>{y(true),a(null);try{let o=await fetch(`${t}/api/v2/stacks/${h}`);if(!o.ok)return a("Stack not found"),y(!1),null;let i=await o.json(),n=i.data?.stack||i.stack||i,g={id:n.id,name:n.name,displayName:n.displayName||n.name,description:n.description,logoUrl:n.logoUrl,webPageUrl:n.webPageUrl,allowedChains:n.allowedChains||[],features:n.features,stripeProvider:n.stripeProvider,oauthProviders:n.oauthProviders?.map(s=>({provider:s.provider,clientId:s.clientId,enabled:s.enabled!==!1}))};return d(g),y(!1),g}catch(o){return a(o.message),y(false),null}},[t]);react.useEffect(()=>{e&&l(e);},[e,l]);let c=r?Yt(r):[];return {config:r,loading:p,error:m,identityProviders:c,fetchConfig:l}}function Yt(e){let t=[];if(e.features?.web3Auth!==false&&(e.allowedChains.includes("solana")&&(t.push({type:"wallet",id:"phantom",name:"Phantom",chain:"solana"}),t.push({type:"wallet",id:"solflare",name:"Solflare",chain:"solana"})),(e.allowedChains.includes("ethereum")||e.allowedChains.includes("polygon")||e.allowedChains.includes("base"))&&t.push({type:"wallet",id:"metamask",name:"MetaMask",chain:"ethereum"})),e.features?.apiKeyAuth!==false&&t.push({type:"otp",id:"otp",name:"Access Code"}),e.features?.oauthAuth&&e.oauthProviders)for(let r of e.oauthProviders)r.enabled&&t.push({type:"oauth",id:r.provider,name:r.provider});return t}function Xt(e=""){let[t,r]=react.useState([]),[d,p]=react.useState(true),[y,m]=react.useState(null),a=react.useCallback(async()=>{try{let l=await fetch(`${e}/api/billing/plans`);if(l.ok){let c=await l.json();r(c.plans||c||[]);}}catch(l){m(l.message);}finally{p(false);}},[e]);return react.useEffect(()=>{a();},[a]),{plans:t,loading:d,error:y,refresh:a}}function tn(e=""){let[t,r]=react.useState(null),[d,p]=react.useState(true),[y,m]=react.useState(null),a=react.useCallback(async()=>{try{let h=await fetch(`${e}/api/billing/subscription`);if(h.ok){let o=await h.json();r(o.plan?o:null);}}catch(h){m(h.message);}finally{p(false);}},[e]);react.useEffect(()=>{a();},[a]);let l=react.useCallback(async h=>{let o=Q(),n=await(await fetch(`${e}/api/billing/subscribe`,{method:"POST",headers:{"Content-Type":"application/json",...o?{"x-csrf-token":o}:{}},body:JSON.stringify({planId:h})})).json();return n.url||n.checkoutUrl||null},[e]),c=react.useCallback(async()=>{let h=Q();return (await fetch(`${e}/api/billing/cancel`,{method:"POST",headers:h?{"x-csrf-token":h}:{}})).ok?(await a(),true):false},[e,a]);return {subscription:t,loading:d,error:y,refresh:a,subscribe:l,cancel:c}}function rn(e=""){let[t,r]=react.useState(null),[d,p]=react.useState(true),[y,m]=react.useState(null),a=react.useCallback(async()=>{try{let l=await fetch(`${e}/api/billing/usage`);if(l.ok){let c=await l.json();r(c);}}catch(l){m(l.message);}finally{p(false);}},[e]);return react.useEffect(()=>{a();},[a]),{usage:t,loading:d,error:y,refresh:a}}function sn(e=""){let[t,r]=react.useState(false),[d,p]=react.useState(null),y=react.useCallback(async a=>{r(true),p(null);try{let l=Q(),c=await fetch(`${e}/api/billing/prepaid`,{method:"POST",headers:{"Content-Type":"application/json",...l?{"x-csrf-token":l}:{}},body:JSON.stringify({amountCents:a})}),h=await c.json();return c.ok?h.url||null:(p(h.error||"Purchase failed"),null)}catch(l){return p(l.message),null}finally{r(false);}},[e]),m=react.useCallback(async a=>{r(true),p(null);try{let l=Q(),c=await fetch(`${e}/api/billing/verify-prepaid`,{method:"POST",headers:{"Content-Type":"application/json",...l?{"x-csrf-token":l}:{}},body:JSON.stringify({sessionId:a})}),h=await c.json();return c.ok?h:(p(h.error||"Verification failed"),null)}catch(l){return p(l.message),null}finally{r(false);}},[e]);return {purchase:y,verifySession:m,loading:t,error:d}}function cn(e="",t){let[r,d]=react.useState([]),[p,y]=react.useState(true),[m,a]=react.useState(null),l=t?.limit||50,c=t?.offset||0,h=react.useCallback(async()=>{try{let o=await fetch(`${e}/api/billing/history?limit=${l}&offset=${c}`);if(o.ok){let i=await o.json();d(i.records||i.history||(Array.isArray(i)?i:[]));}}catch(o){a(o.message);}finally{y(false);}},[e,l,c]);return react.useEffect(()=>{h();},[h]),{records:r,loading:p,error:m,refresh:h}}function un(){if(typeof document>"u")return null;let e=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith("__csrf="));return e?e.slice(7):null}function _e(e,t){let[r,d]=react.useState(null),[p,y]=react.useState(true),[m,a]=react.useState(false),[l,c]=react.useState(null),h=t?.apiBaseUrl??"",o=t?.scope===void 0||t?.scope==="global"?"global":`stack:${t.scope.stackId}`,i=react.useCallback(s=>{let k=encodeURIComponent(s);if(o==="global")return `${h}/api/user/profile/${k}`;let C=o.slice(6);return `${h}/api/v2/stacks/${encodeURIComponent(C)}/members/${k}/profile`},[h,o]),n=react.useCallback(async()=>{if(!e){d(null),y(false);return}y(true),c(null);try{let s=await fetch(i(e));if(s.ok){let k=await s.json(),C=k.profile||k.data?.profile||k;d({mid:C.mid||e,username:C.username||"",avatarUrl:C.avatar_url||C.avatarUrl,bio:C.bio,paymentAddress:C.payment_address||C.paymentAddress,createdAt:C.created_at||C.createdAt,updatedAt:C.updated_at||C.updatedAt});}else if(s.status===404)d({mid:e,username:""});else throw new Error(`${s.status}`)}catch(s){c(s instanceof Error?s.message:"Failed to load profile");}finally{y(false);}},[e,i]);react.useEffect(()=>{n();},[n]);let g=react.useCallback(async s=>{if(!e)return false;a(true),c(null);try{let k=un(),C={};s.username!==void 0&&(C.username=s.username),s.avatarUrl!==void 0&&(C.avatar_url=s.avatarUrl),s.bio!==void 0&&(C.bio=s.bio),s.paymentAddress!==void 0&&(C.payment_address=s.paymentAddress);let w=await fetch(i(e),{method:"PUT",headers:{"Content-Type":"application/json",...k?{"x-csrf-token":k}:{}},credentials:"same-origin",body:JSON.stringify(C)});if(!w.ok){let v=await w.json().catch(()=>({}));throw new Error(v.error||v.message||`Update failed: ${w.status}`)}let L=await w.json(),I=L.profile||L.data?.profile||L;return d(v=>({mid:v?.mid||e,username:s.username??v?.username??"",avatarUrl:s.avatarUrl??v?.avatarUrl,bio:s.bio??v?.bio,paymentAddress:s.paymentAddress??I.payment_address??I.paymentAddress??v?.paymentAddress,createdAt:v?.createdAt,updatedAt:I.updated_at||I.updatedAt||Date.now()})),!0}catch(k){return c(k instanceof Error?k.message:"Update failed"),false}finally{a(false);}},[e,i]);return {profile:r,loading:p,saving:m,error:l,updateProfile:g,refresh:n}}var gt="google-identity-services",pn="https://accounts.google.com/gsi/client";function fn({stackId:e,stacknetUrl:t="https://stacknet.magma-rpc.com",apiBaseUrl:r="",autoPrompt:d=true,cancelOnTapOutside:p=true,onSuccess:y,onError:m,disabled:a=false}){let{config:l}=ie(e,t),{isAuthenticated:c,loading:h,readSession:o}=re(),[i,n]=react.useState(false),[g,s]=react.useState(null),[k,C]=react.useState(false),w=react.useRef(false),L=react.useRef(false),v=l?.oauthProviders?.find(b=>b.provider==="google"&&b.enabled&&b.clientId)?.clientId||null;react.useEffect(()=>{if(a||!v||typeof window>"u")return;if(document.getElementById(gt)){C(true);return}let b=document.createElement("script");b.id=gt,b.src=pn,b.async=true,b.defer=true,b.onload=()=>C(true),b.onerror=()=>{s("Failed to load Google sign-in"),m?.("Failed to load Google Identity Services script");},document.head.appendChild(b);},[a,v,m]);let F=react.useCallback(async b=>{n(true),s(null);try{let T=await fetch(`${r}/api/auth/google/one-tap`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({credential:b.credential,stackId:e})});if(!T.ok){let G=(await T.json().catch(()=>({}))).error||"Google sign-in failed";s(G),m?.(G),n(!1);return}o(),n(!1),y?.();}catch(T){let O=T.message||"Google sign-in failed";s(O),m?.(O),n(false);}},[r,e,o,y,m]);react.useEffect(()=>{if(a){console.debug("[GoogleOneTap] Disabled");return}if(!k){console.debug("[GoogleOneTap] Script not loaded yet, clientId:",v);return}if(!v){console.debug("[GoogleOneTap] No Google clientId from stack config");return}if(h){console.debug("[GoogleOneTap] Session still loading");return}if(c){console.debug("[GoogleOneTap] User already authenticated, skipping");return}if(!window.google?.accounts?.id){console.debug("[GoogleOneTap] GIS library not available on window");return}w.current||(console.debug("[GoogleOneTap] Initializing with clientId:",v),w.current=true,window.google.accounts.id.initialize({client_id:v,callback:F,auto_select:true,cancel_on_tap_outside:p}),d&&!L.current&&(L.current=true,console.debug("[GoogleOneTap] Showing prompt..."),window.google.accounts.id.prompt(b=>{b.isDisplayed?.()&&console.debug("[GoogleOneTap] Prompt displayed"),b.isNotDisplayed?.()&&console.debug("[GoogleOneTap] Not displayed:",b.getNotDisplayedReason?.()),b.isSkippedMoment?.()&&console.debug("[GoogleOneTap] Skipped:",b.getSkippedReason?.()),b.isDismissedMoment?.()&&console.debug("[GoogleOneTap] Dismissed:",b.getDismissedReason?.());})));},[a,k,v,h,c,F,d,p]),react.useEffect(()=>()=>{window.google?.accounts?.id&&w.current&&window.google.accounts.id.cancel();},[]);let U=react.useCallback(()=>{!window.google?.accounts?.id||!w.current||window.google.accounts.id.prompt();},[]),R=react.useCallback((b,T)=>{!b||!window.google?.accounts?.id||!w.current||window.google.accounts.id.renderButton(b,{theme:T?.theme||"filled_black",size:T?.size||"large",text:T?.text||"signin_with",width:T?.width});},[]);return {available:!!v,ready:k&&!!v,loading:i,error:g,prompt:U,renderButton:R,clientId:v}}var mn="/api";function hn(e,t){return `${(t||(typeof window<"u"?window.location.origin:"")).replace(/\/$/,"")}/?ref=${encodeURIComponent(e)}`}function yn(e={}){let{shareBaseUrl:t,autoMint:r=true}=e,[d,p]=react.useState(null),[y,m]=react.useState(true),[a,l]=react.useState(null),c=react.useCallback(async()=>{m(true),l(null);try{let i=r?"POST":"GET",n=await fetch(`${mn}/social/join-code`,{method:i,credentials:"include"});if(!n.ok){p(null),n.status===401?l("not_authenticated"):l(`HTTP ${n.status}`);return}let g=await n.json();p(g?.code??null);}catch(i){l(i?.message||"network_error"),p(null);}finally{m(false);}},[r]);react.useEffect(()=>{c();},[c]);let h=d?hn(d,t):null,o=react.useCallback(async()=>{if(!h)return false;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(h),!0}catch{}return false},[h]);return {code:d,shareUrl:h,loading:y,error:a,refresh:c,copyShareLink:o}}var ht=react.createContext(null);function wn(){let e=react.useContext(ht);if(!e)throw new Error("useUserUtilsContext must be used within <UserUtilsProvider>");return e}function Cn({config:e,callbacks:t,children:r}){return jsxRuntime.jsx(ht.Provider,{value:{config:e,callbacks:t},children:r})}function ae({length:e=6,onComplete:t,disabled:r=false,error:d,className:p="",inputClassName:y=""}){let [m,a]=react.useState(Array(e).fill("")),l=react.useCallback((o,i)=>{if(i.length>1){let g=i.replace(/\D/g,"").slice(0,e).split(""),s=[...m];g.forEach((C,w)=>{o+w<e&&(s[o+w]=C);}),a(s);let k=Math.min(o+g.length,e-1);document.getElementById(`userutils-otp-${k}`)?.focus(),s.every(C=>C!=="")&&setTimeout(()=>t(s.join("")),100);return}if(!/^\d?$/.test(i))return;let n=[...m];n[o]=i,a(n),i&&o<e-1&&document.getElementById(`userutils-otp-${o+1}`)?.focus(),i&&o===e-1&&n.every(g=>g!=="")&&setTimeout(()=>t(n.join("")),100);},[m,e,t]),c=react.useCallback((o,i)=>{if(i.key==="Backspace"&&!m[o]&&o>0){document.getElementById(`userutils-otp-${o-1}`)?.focus();let n=[...m];n[o-1]="",a(n);}if(i.key==="Enter"){let n=m.join("");n.length===e&&t(n);}},[m,e,t]);react.useCallback(()=>{a(Array(e).fill("")),document.getElementById("userutils-otp-0")?.focus();},[e]);return jsxRuntime.jsxs("div",{className:p,children:[jsxRuntime.jsx("div",{className:"flex gap-2 justify-center",children:m.map((o,i)=>jsxRuntime.jsx("input",{id:`userutils-otp-${i}`,type:"text",inputMode:"numeric",maxLength:e,value:o,onChange:n=>l(i,n.target.value),onKeyDown:n=>c(i,n),disabled:r,autoFocus:i===0,className:`w-12 h-14 text-center text-xl font-mono bg-secondary border border-primary/10 text-foreground focus:outline-none focus:border-primary/30 disabled:opacity-50 ${y}`},i))}),d&&jsxRuntime.jsx("p",{className:"text-center text-sm text-red-400 mt-2",children:d})]})}ae.displayName="OTPInput";var Pn="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTA4IiBoZWlnaHQ9IjEwOCIgdmlld0JveD0iMCAwIDEwOCAxMDgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00Ni41MjY3IDY5LjkyMjlDNDIuMDA1NCA3Ni44NTA5IDM0LjQyOTIgODUuNjE4MiAyNC4zNDggODUuNjE4MkMxOS41ODI0IDg1LjYxODIgMTUgODMuNjU2MyAxNSA3NS4xMzQyQzE1IDUzLjQzMDUgNDQuNjMyNiAxOS44MzI3IDcyLjEyNjggMTkuODMyN0M4Ny43NjggMTkuODMyNyA5NCAzMC42ODQ2IDk0IDQzLjAwNzlDOTQgNTguODI1OCA4My43MzU1IDc2LjkxMjIgNzMuNTMyMSA3Ni45MTIyQzcwLjI5MzkgNzYuOTEyMiA2OC43MDUzIDc1LjEzNDIgNjguNzA1MyA3Mi4zMTRDNjguNzA1MyA3MS41NzgzIDY4LjgyNzUgNzAuNzgxMiA2OS4wNzE5IDY5LjkyMjlDNjUuNTg5MyA3NS44Njk5IDU4Ljg2ODUgODEuMzg3OCA1Mi41NzU0IDgxLjM4NzhDNDcuOTkzIDgxLjM4NzggNDUuNjcxMyA3OC41MDYzIDQ1LjY3MTMgNzQuNDU5OEM0NS42NzEzIDcyLjk4ODQgNDUuOTc2OCA3MS40NTU2IDQ2LjUyNjcgNjkuOTIyOVpNODMuNjc2MSA0Mi41Nzk0QzgzLjY3NjEgNDYuMTcwNCA4MS41NTc1IDQ3Ljk2NTggNzkuMTg3NSA0Ny45NjU4Qzc2Ljc4MTYgNDcuOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPgo=";function me({className:e,style:t}){return jsxRuntime.jsx("img",{src:Pn,alt:"Phantom",className:e,style:t})}function he({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 507.83 470.86",children:[jsxRuntime.jsx("polygon",{fill:"#e2761b",stroke:"#e2761b",strokeLinecap:"round",strokeLinejoin:"round",points:"482.09 0.5 284.32 147.38 320.9 60.72 482.09 0.5"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"25.54 0.5 221.72 148.77 186.93 60.72 25.54 0.5"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"410.93 340.97 358.26 421.67 470.96 452.67 503.36 342.76 410.93 340.97"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"4.67 342.76 36.87 452.67 149.57 421.67 96.9 340.97 4.67 342.76"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"143.21 204.62 111.8 252.13 223.7 257.1 219.73 136.85 143.21 204.62"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"364.42 204.62 286.91 135.46 284.32 257.1 396.03 252.13 364.42 204.62"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"149.57 421.67 216.75 388.87 158.71 343.55 149.57 421.67"}),jsxRuntime.jsx("polygon",{fill:"#e4761b",stroke:"#e4761b",strokeLinecap:"round",strokeLinejoin:"round",points:"290.88 388.87 358.26 421.67 348.92 343.55 290.88 388.87"}),jsxRuntime.jsx("polygon",{fill:"#d7c1b3",stroke:"#d7c1b3",strokeLinecap:"round",strokeLinejoin:"round",points:"358.26 421.67 290.88 388.87 296.25 432.8 295.65 451.28 358.26 421.67"}),jsxRuntime.jsx("polygon",{fill:"#d7c1b3",stroke:"#d7c1b3",strokeLinecap:"round",strokeLinejoin:"round",points:"149.57 421.67 212.18 451.28 211.78 432.8 216.75 388.87 149.57 421.67"}),jsxRuntime.jsx("polygon",{fill:"#233447",stroke:"#233447",strokeLinecap:"round",strokeLinejoin:"round",points:"213.17 314.54 157.12 298.04 196.67 279.95 213.17 314.54"}),jsxRuntime.jsx("polygon",{fill:"#233447",stroke:"#233447",strokeLinecap:"round",strokeLinejoin:"round",points:"294.46 314.54 310.96 279.95 350.71 298.04 294.46 314.54"}),jsxRuntime.jsx("polygon",{fill:"#cd6116",stroke:"#cd6116",strokeLinecap:"round",strokeLinejoin:"round",points:"149.57 421.67 159.11 340.97 96.9 342.76 149.57 421.67"}),jsxRuntime.jsx("polygon",{fill:"#cd6116",stroke:"#cd6116",strokeLinecap:"round",strokeLinejoin:"round",points:"348.72 340.97 358.26 421.67 410.93 342.76 348.72 340.97"}),jsxRuntime.jsx("polygon",{fill:"#cd6116",stroke:"#cd6116",strokeLinecap:"round",strokeLinejoin:"round",points:"396.03 252.13 284.32 257.1 294.66 314.54 311.16 279.95 350.91 298.04 396.03 252.13"}),jsxRuntime.jsx("polygon",{fill:"#cd6116",stroke:"#cd6116",strokeLinecap:"round",strokeLinejoin:"round",points:"157.12 298.04 196.87 279.95 213.17 314.54 223.7 257.1 111.8 252.13 157.12 298.04"}),jsxRuntime.jsx("polygon",{fill:"#e4751f",stroke:"#e4751f",strokeLinecap:"round",strokeLinejoin:"round",points:"111.8 252.13 158.71 343.55 157.12 298.04 111.8 252.13"}),jsxRuntime.jsx("polygon",{fill:"#e4751f",stroke:"#e4751f",strokeLinecap:"round",strokeLinejoin:"round",points:"350.91 298.04 348.92 343.55 396.03 252.13 350.91 298.04"}),jsxRuntime.jsx("polygon",{fill:"#e4751f",stroke:"#e4751f",strokeLinecap:"round",strokeLinejoin:"round",points:"223.7 257.1 213.17 314.54 226.29 382.31 229.27 293.07 223.7 257.1"}),jsxRuntime.jsx("polygon",{fill:"#e4751f",stroke:"#e4751f",strokeLinecap:"round",strokeLinejoin:"round",points:"284.32 257.1 278.96 292.87 281.34 382.31 294.66 314.54 284.32 257.1"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"294.66 314.54 281.34 382.31 290.88 388.87 348.92 343.55 350.91 298.04 294.66 314.54"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"157.12 298.04 158.71 343.55 216.75 388.87 226.29 382.31 213.17 314.54 157.12 298.04"}),jsxRuntime.jsx("polygon",{fill:"#c0ad9e",stroke:"#c0ad9e",strokeLinecap:"round",strokeLinejoin:"round",points:"295.65 451.28 296.25 432.8 291.28 428.42 216.35 428.42 211.78 432.8 212.18 451.28 149.57 421.67 171.43 439.55 215.75 470.36 291.88 470.36 336.4 439.55 358.26 421.67 295.65 451.28"}),jsxRuntime.jsx("polygon",{fill:"#161616",stroke:"#161616",strokeLinecap:"round",strokeLinejoin:"round",points:"290.88 388.87 281.34 382.31 226.29 382.31 216.75 388.87 211.78 432.8 216.35 428.42 291.28 428.42 296.25 432.8 290.88 388.87"}),jsxRuntime.jsx("polygon",{fill:"#763d16",stroke:"#763d16",strokeLinecap:"round",strokeLinejoin:"round",points:"490.44 156.92 507.33 75.83 482.09 0.5 290.88 142.41 364.42 204.62 468.37 235.03 491.43 208.2 481.49 201.05 497.39 186.54 485.07 177 500.97 164.87 490.44 156.92"}),jsxRuntime.jsx("polygon",{fill:"#763d16",stroke:"#763d16",strokeLinecap:"round",strokeLinejoin:"round",points:"0.5 75.83 17.39 156.92 6.66 164.87 22.56 177 10.44 186.54 26.34 201.05 16.4 208.2 39.26 235.03 143.21 204.62 216.75 142.41 25.54 0.5 0.5 75.83"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"468.37 235.03 364.42 204.62 396.03 252.13 348.92 343.55 410.93 342.76 503.36 342.76 468.37 235.03"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"143.21 204.62 39.26 235.03 4.67 342.76 96.9 342.76 158.71 343.55 111.8 252.13 143.21 204.62"}),jsxRuntime.jsx("polygon",{fill:"#f6851b",stroke:"#f6851b",strokeLinecap:"round",strokeLinejoin:"round",points:"284.32 257.1 290.88 142.41 321.1 60.72 186.93 60.72 216.75 142.41 223.7 257.1 226.09 293.27 226.29 382.31 281.34 382.31 281.74 293.27 284.32 257.1"})]})}function Je({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"0.5",width:"32",height:"32",rx:"4",fill:"#F1F2F9"}),jsxRuntime.jsx("path",{d:"M26.1001 16.2273C26.1001 15.5182 26.0365 14.8364 25.9183 14.1818H16.5001V18.05H21.8819C21.6501 19.3 20.9456 20.3591 19.8865 21.0682V23.5773H23.1183C25.0092 21.8364 26.1001 19.2727 26.1001 16.2273Z",fill:"#4285F4"}),jsxRuntime.jsx("path",{d:"M16.5001 26C19.2001 26 21.4637 25.1046 23.1182 23.5773L19.8864 21.0682C18.991 21.6682 17.8455 22.0227 16.5001 22.0227C13.8955 22.0227 11.691 20.2637 10.9046 17.9H7.56372V20.4909C9.20917 23.7591 12.591 26 16.5001 26Z",fill:"#34A853"}),jsxRuntime.jsx("path",{d:"M10.9047 17.8999C10.7047 17.2999 10.591 16.659 10.591 15.9999C10.591 15.3408 10.7047 14.6999 10.9047 14.0999V11.509H7.56376C6.86376 12.9025 6.49951 14.4405 6.50012 15.9999C6.50012 17.6136 6.88649 19.1408 7.56376 20.4908L10.9047 17.8999Z",fill:"#FBBC05"}),jsxRuntime.jsx("path",{d:"M16.5001 9.97726C17.9682 9.97726 19.2864 10.4818 20.3228 11.4727L23.191 8.60454C21.4591 6.99091 19.1955 6 16.5001 6C12.591 6 9.20917 8.2409 7.56372 11.5091L10.9046 14.1C11.691 11.7364 13.8955 9.97726 16.5001 9.97726Z",fill:"#EA4335"})]})}function Qe({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"0.5",width:"32",height:"32",rx:"4",fill:"#5462EB"}),jsxRuntime.jsx("path",{d:"M23.5433 8.87438C22.2479 8.26174 20.8587 7.81038 19.4063 7.55187C19.3799 7.54688 19.3534 7.55934 19.3398 7.58428C19.1612 7.91179 18.9633 8.33905 18.8247 8.67487C17.2625 8.43382 15.7084 8.43382 14.1782 8.67487C14.0396 8.33158 13.8345 7.91179 13.6551 7.58428C13.6414 7.56018 13.615 7.54771 13.5886 7.55187C12.1369 7.80955 10.7478 8.26092 9.45159 8.87438C9.44037 8.87937 9.43075 8.88769 9.42437 8.89849C6.78947 12.9558 6.06766 16.9134 6.42176 20.8219C6.42336 20.841 6.43378 20.8593 6.4482 20.871C8.18663 22.1868 9.87059 22.9857 11.5233 23.5152C11.5497 23.5235 11.5778 23.5135 11.5946 23.491C11.9855 22.9408 12.334 22.3606 12.6328 21.7504C12.6505 21.7147 12.6336 21.6723 12.5976 21.6581C12.0448 21.442 11.5185 21.1785 11.0122 20.8793C10.9721 20.8552 10.9689 20.7961 11.0058 20.7679C11.1123 20.6856 11.2189 20.6 11.3206 20.5135C11.339 20.4977 11.3647 20.4944 11.3863 20.5044C14.7125 22.0696 18.3136 22.0696 21.6006 20.5044C21.6222 20.4936 21.6479 20.4969 21.6671 20.5127C21.7688 20.5991 21.8754 20.6856 21.9827 20.7679C22.0196 20.7961 22.0172 20.8552 21.9771 20.8793C21.4708 21.1843 20.9445 21.442 20.3909 21.6573C20.3548 21.6715 20.3388 21.7147 20.3564 21.7504C20.6617 22.3597 21.0101 22.9399 21.3939 23.4902C21.4099 23.5135 21.4387 23.5235 21.4652 23.5152C23.1259 22.9857 24.8099 22.1868 26.5483 20.871C26.5635 20.8593 26.5731 20.8419 26.5747 20.8228C26.9985 16.3041 25.8649 12.3789 23.5697 8.89931C23.5641 8.88769 23.5545 8.87937 23.5433 8.87438Z",fill:"#F7F7F7"})]})}function Ve({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"0.5",width:"32",height:"32",rx:"4",fill:"black"}),jsxRuntime.jsx("path",{d:"M8.53901 8L14.7164 16.2153L8.5 22.8947H9.89907L15.3415 17.0468L19.7389 22.8947H24.5L17.975 14.2173L23.7612 8H22.3621L17.3499 13.3858L13.3001 8H8.53901ZM10.5964 9.02501H12.7837L22.4422 21.8695H20.255L10.5964 9.02501Z",fill:"#F7F7F7"})]})}function Ze({className:e,style:t}){return jsxRuntime.jsxs("svg",{className:e,style:t,viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"0.5",width:"32",height:"32",rx:"4",fill:"#000000"}),jsxRuntime.jsx("path",{d:"M21.3611 16.7384C21.3807 18.9244 23.2792 19.6519 23.3001 19.661C23.2841 19.7124 22.9971 20.6962 22.3005 21.7115C21.6987 22.5892 21.0742 23.4636 20.0904 23.4816C19.1237 23.4994 18.8127 22.9098 17.7076 22.9098C16.6029 22.9098 16.2574 23.4636 15.3423 23.4994C14.3928 23.5352 13.6694 22.5504 13.0626 21.676C11.8226 19.8879 10.8747 16.6229 12.1471 14.4182C12.7791 13.3234 13.9087 12.6304 15.1346 12.6126C16.0668 12.5948 16.9468 13.2378 17.5167 13.2378C18.0865 13.2378 19.1555 12.4647 20.2795 12.579C20.7501 12.5986 22.0715 12.7692 22.9207 14.0122C22.852 14.0549 21.3453 14.9328 21.3611 16.7384ZM19.5432 11.392C20.0472 10.7809 20.3862 9.93 20.2939 9.08325C19.5709 9.11221 18.6961 9.56574 18.1749 10.1763C17.708 10.717 17.2995 11.582 17.4096 12.4111C18.2158 12.4736 19.0391 12.003 19.5432 11.392Z",fill:"#FFFFFF"})]})}function Un({config:e,onSuccess:t,title:r="Log in or Sign up",showWallets:d,showOTP:p,hideHeader:y,onOTPSubmit:m,otpLabel:a="Access Code",showPreviewCode:l=false,onPreviewCodeSubmit:c,previewCodeLabel:h="Preview Code",oauthInline:o,oauthFirst:i,className:n=""}){let g=Le(e),{isAuthenticated:s,wallet:k,loading:C,error:w,authenticateSolana:L,authenticateEVM:I,authenticateOTP:v,authenticateOAuth:F,bridge:U,stackId:R}=g,b=!e.stackId&&!R,T=e.stacknetUrl||"https://stacknet.magma-rpc.com",{config:O,identityProviders:G,loading:P}=ie(R||e.stackId||null,T),[S,N]=react.useState(b?"stack-select":"select"),[_,A]=react.useState(null),[z,E]=react.useState(false),[J,H]=react.useState("idle"),[Y,we]=react.useState(""),[Xe,Ce]=react.useState(false),[Se,K]=react.useState("idle"),[vt,de]=react.useState(""),[et,Pt]=react.useState([]),[It,tt]=react.useState(e.stackId||null),[ue,Nt]=react.useState(false),[At,Mt]=react.useState(false);react.useEffect(()=>{if(typeof window>"u")return;let u=()=>{let j=window;Nt(!!(j.phantom?.solana?.isPhantom||j.solana?.isPhantom));let ee=j.ethereum;Mt(!!(ee?.isMetaMask||ee?.providers?.some(te=>te.isMetaMask)));};u(),window.addEventListener("ethereum#initialized",u);let $=setTimeout(u,500);return ()=>{window.removeEventListener("ethereum#initialized",u),clearTimeout($);}},[]),react.useEffect(()=>{S==="stack-select"&&R&&(tt(R),N("select"));},[S,R]),react.useEffect(()=>{if(!(!U.ready||!b)&&U.identity){let u=[];U.resolvedStackId&&u.push({stackId:U.resolvedStackId,domain:typeof window<"u"?window.location.origin:""}),Promise.all(u.map(async $=>{try{let j=await fetch(`${T}/api/v2/stacks/${$.stackId}`);if(j.ok){let ee=await j.json(),te=ee.data?.stack||ee;$.name=te.displayName||te.name,$.logoUrl=te.logoUrl;}}catch{}return $})).then(Pt);}},[U.ready,U.identity,U.resolvedStackId,b,T]),react.useEffect(()=>{s&&S==="success"&&t?.();},[s,S,t]);let nt=d||(G.length>0?G.filter(u=>u.type==="wallet").map(u=>u.id):["phantom","metamask"]),ot=p!==void 0?p:G.length>0?G.some(u=>u.type==="otp"):true,X=G.filter(u=>u.type==="oauth"),xe=new Set(i||[]),rt=X.filter(u=>xe.has(u.id)),ve=o?X.filter(u=>!xe.has(u.id)):X,st=async u=>{A(u),N("connecting"),await F(u)||N("error");},Tt=async()=>{A("phantom"),N("connecting");let u=await L("phantom");N(u?"success":"error");},Lt=async()=>{A("metamask"),N("connecting");let u=await I();N(u?"success":"error");},Ut=async u=>{H("verifying"),we(""),await(m||v)(u)?(H("success"),N("success")):(H("error"),we("Invalid or expired code"),setTimeout(()=>H("idle"),2e3));},Ot=async u=>{if(!/^\d{6}$/.test(u))return false;try{let $=await fetch(`${T.replace(/\/$/,"")}/v1/preview-codes/${encodeURIComponent(u)}`,{method:"GET",headers:{Accept:"application/json"}});if(!$.ok)return !1;let j=await $.json();return !j||j.code!==u||j.revoked===!0||typeof j.expiresAt=="number"&&j.expiresAt<=Date.now()||typeof j.tokensRemaining=="number"&&j.tokensRemaining<=0?!1:(typeof window<"u"&&window.localStorage&&window.localStorage.setItem("stacknet-api-key",`pc_${u}`),!0)}catch{return false}},jt=async u=>{K("verifying"),de(""),await(c||Ot)(u)?(K("success"),N("success")):(K("error"),de("Invalid or expired preview code"),setTimeout(()=>K("idle"),2e3));},it=()=>{N(b&&!It?"stack-select":"select"),A(null),E(false),H("idle"),we(""),Ce(false),K("idle"),de("");};return jsxRuntime.jsxs("div",{className:`w-full max-w-md space-y-3 ${n}`,children:[!y&&jsxRuntime.jsxs("div",{className:"mb-6 text-center",children:[O?.logoUrl&&S!=="stack-select"&&jsxRuntime.jsx("img",{src:ne(O.logoUrl),alt:O.displayName||"",className:"h-16 w-16 mx-auto mb-4 rounded-xl"}),O?.displayName&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-400 mb-2",children:O.displayName}),jsxRuntime.jsx("h1",{className:"font-semibold text-2xl text-white",children:"Log in or Sign up"})]}),S==="stack-select"&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-center text-sm text-zinc-400 mb-4",children:et.length>0?"Select a network to continue":"No previous connections found. Enter a Stack ID to continue."}),et.map(u=>jsxRuntime.jsxs("button",{onClick:()=>{tt(u.stackId),N("select");},className:"flex w-full cursor-pointer items-center gap-4 rounded-xl border border-zinc-800 bg-[#25252f] p-4 transition-colors hover:bg-[#2d2d3a]",children:[u.logoUrl?jsxRuntime.jsx("img",{src:ne(u.logoUrl),alt:"",className:"h-10 w-10 flex-shrink-0"}):jsxRuntime.jsx("div",{className:"h-10 w-10 flex-shrink-0 bg-zinc-700 flex items-center justify-center text-zinc-400 text-sm font-mono",children:u.name?.[0]?.toUpperCase()||"S"}),jsxRuntime.jsxs("div",{className:"flex-1 text-left",children:[jsxRuntime.jsx("span",{className:"font-medium text-white",children:u.name||u.stackId}),jsxRuntime.jsx("p",{className:"text-xs text-zinc-500",children:u.domain})]}),jsxRuntime.jsx("span",{className:"text-xs text-zinc-600",children:"Previously connected"})]},u.stackId)),U.ready&&!U.known&&jsxRuntime.jsx("p",{className:"text-center text-xs text-zinc-600 mt-4",children:"Connect to a stack for the first time to get started."})]}),S==="select"&&P&&jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsx("div",{className:"h-6 w-6 border-2 border-zinc-600 border-t-white animate-spin",style:{borderRadius:"50%"}})}),w&&S==="error"&&jsxRuntime.jsxs("div",{className:"mb-4 border border-red-500/30 bg-red-500/10 p-4",children:[jsxRuntime.jsx("p",{className:"text-center text-red-400 text-sm",children:w}),jsxRuntime.jsx("button",{className:"mt-3 w-full text-sm text-zinc-400 hover:text-white",onClick:it,children:"Try Again"})]}),S==="success"&&jsxRuntime.jsxs("div",{className:"border border-green-500/30 bg-green-500/10 p-6 text-center",children:[jsxRuntime.jsx("p",{className:"font-medium text-green-400 text-sm",children:"Connected!"}),jsxRuntime.jsx("p",{className:"mt-1 text-xs text-zinc-400",children:"Redirecting..."})]}),S==="connecting"&&C&&jsxRuntime.jsxs("div",{style:{border:"1px solid #27272a",background:"#25252f",padding:24,textAlign:"center"},children:[jsxRuntime.jsxs("div",{style:{width:40,height:40,margin:"0 auto 12px"},children:[_==="phantom"&&jsxRuntime.jsx(me,{style:B}),_==="metamask"&&jsxRuntime.jsx(he,{style:B})]}),jsxRuntime.jsx("p",{style:{fontWeight:500,fontSize:14,color:"#fff"},children:k.connected?"Signing message...":"Connecting wallet..."}),jsxRuntime.jsx("p",{style:{marginTop:4,fontSize:12,color:"#71717a"},children:"Please confirm in your wallet"}),jsxRuntime.jsx("button",{style:{marginTop:16,fontSize:14,color:"#71717a",background:"none",border:"none",cursor:"pointer"},onClick:it,children:"Cancel"})]}),S==="select"&&!C&&!P&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[rt.map(u=>jsxRuntime.jsxs("button",{onClick:()=>st(u.id),style:q,children:[jsxRuntime.jsx(wt,{provider:u.id}),jsxRuntime.jsx("span",{style:{fontWeight:500,color:"#fff"},children:Ct(u.id,u.name)})]},u.id)),nt.includes("phantom")&&jsxRuntime.jsxs("button",{onClick:Tt,disabled:!ue,style:{...q,opacity:ue?1:.5,cursor:ue?"pointer":"not-allowed"},children:[jsxRuntime.jsx(me,{style:{...B,borderRadius:8}}),jsxRuntime.jsx("span",{style:{flex:1,textAlign:"left",fontWeight:500,color:"#fff"},children:"Phantom"}),!ue&&jsxRuntime.jsx("span",{style:{fontSize:12,color:"#71717a"},children:"Not installed"})]}),nt.includes("metamask")&&At&&jsxRuntime.jsxs("button",{onClick:Lt,style:q,children:[jsxRuntime.jsx(he,{style:B}),jsxRuntime.jsx("span",{style:{flex:1,textAlign:"left",fontWeight:500,color:"#fff"},children:"MetaMask"})]}),ot&&!z&&jsxRuntime.jsxs("button",{onClick:()=>E(true),style:q,children:[jsxRuntime.jsx("div",{style:{...B,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid #3f3f46",background:"#2a2a3e"},children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"#a1a1aa",children:jsxRuntime.jsx("path",{d:"M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Z"})})}),jsxRuntime.jsx("span",{style:{flex:1,textAlign:"left",fontWeight:500,color:"#fff"},children:a})]}),l&&!Xe&&jsxRuntime.jsxs("button",{onClick:()=>Ce(true),style:q,children:[jsxRuntime.jsx("div",{style:{...B,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid #3f3f46",background:"#2a2a3e"},children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"#a1a1aa",children:jsxRuntime.jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm80-80h400v-40H280v40Zm0-120h400v-240H280v240Z"})})}),jsxRuntime.jsx("span",{style:{flex:1,textAlign:"left",fontWeight:500,color:"#fff"},children:h})]}),l&&Xe&&jsxRuntime.jsxs("div",{style:{borderRadius:12,border:"1px solid #27272a",background:"#25252f",padding:24},children:[jsxRuntime.jsx("p",{style:{textAlign:"center",fontSize:14,color:"#a1a1aa",marginBottom:16},children:"Enter your 6-digit preview code"}),jsxRuntime.jsx(ae,{onComplete:jt,disabled:Se==="verifying",error:vt}),Se==="verifying"&&jsxRuntime.jsx("p",{style:{textAlign:"center",fontSize:14,color:"#a1a1aa",marginTop:16},children:"Verifying..."}),Se==="success"&&jsxRuntime.jsx("p",{style:{textAlign:"center",fontSize:14,color:"#4ade80",marginTop:16},children:"Verified!"}),jsxRuntime.jsx("button",{onClick:()=>{Ce(false),K("idle"),de("");},style:{display:"block",marginTop:16,marginLeft:"auto",marginRight:"auto",fontSize:13,color:"#71717a",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}),ot&&z&&jsxRuntime.jsxs("div",{style:{borderRadius:12,border:"1px solid #27272a",background:"#25252f",padding:24},children:[jsxRuntime.jsx("p",{style:{textAlign:"center",fontSize:14,color:"#a1a1aa",marginBottom:16},children:"Enter your 6-digit access code"}),jsxRuntime.jsx(ae,{onComplete:Ut,disabled:J==="verifying",error:Y}),J==="verifying"&&jsxRuntime.jsx("p",{style:{textAlign:"center",fontSize:14,color:"#a1a1aa",marginTop:16},children:"Verifying..."}),J==="success"&&jsxRuntime.jsx("p",{style:{textAlign:"center",fontSize:14,color:"#4ade80",marginTop:16},children:"Verified!"}),O?.webPageUrl&&J==="idle"&&(()=>{let u=ne(O.webPageUrl);return u==="#"?null:jsxRuntime.jsx("a",{href:`${u.replace(/\/$/,"")}/connect/pair`,target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",fontSize:14,color:"#71717a",marginTop:16},children:"Get code"})})()]}),(o?ve:X).length>0&&(!o||ve.length>0)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!o&&rt.length===0&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 0"},children:[jsxRuntime.jsx("div",{style:{flex:1,borderTop:"1px solid #27272a"}}),jsxRuntime.jsx("span",{style:{fontSize:12,color:"#52525b"},children:"or continue with"}),jsxRuntime.jsx("div",{style:{flex:1,borderTop:"1px solid #27272a"}})]}),(o?ve:X.filter(u=>!xe.has(u.id))).map(u=>jsxRuntime.jsxs("button",{onClick:()=>st(u.id),style:q,children:[jsxRuntime.jsx(wt,{provider:u.id}),jsxRuntime.jsx("span",{style:{fontWeight:500,color:"#fff"},children:Ct(u.id,u.name)})]},u.id))]})]})]})}var B={width:40,height:40,flexShrink:0},q={display:"flex",width:"100%",alignItems:"center",gap:12,borderRadius:12,border:"1px solid #27272a",background:"#25252f",padding:16,cursor:"pointer",transition:"background 0.15s"};function wt({provider:e}){switch(e){case "google":return jsxRuntime.jsx(Je,{style:{...B,borderRadius:8}});case "discord":return jsxRuntime.jsx(Qe,{style:{...B,borderRadius:8}});case "twitter":return jsxRuntime.jsx(Ve,{style:{...B,borderRadius:8}});case "apple":return jsxRuntime.jsx(Ze,{style:{...B,borderRadius:8}});default:return jsxRuntime.jsx("div",{style:{...B,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid #3f3f46",background:"#2a2a3e",fontSize:14,color:"#a1a1aa",fontFamily:"monospace"},children:e[0]?.toUpperCase()})}}function Ct(e,t){return {google:"Google",discord:"Discord",twitter:"Twitter",apple:"Apple"}[e]||t||e}function Dn({mid:e,apiBaseUrl:t="",scope:r,onSave:d,className:p}){let{profile:y,loading:m,saving:a,error:l,updateProfile:c}=_e(e,{apiBaseUrl:t,scope:r}),[h,o]=react.useState(null),[i,n]=react.useState(null),[g,s]=react.useState(null),k=react.useRef(null),[C,w]=react.useState(false),L=h??y?.username??"",I=i??y?.bio??"",v=g??y?.avatarUrl,F=react.useCallback(b=>{let T=b.target.files?.[0];if(!T)return;let O=new FileReader;O.onload=()=>{s(O.result),w(true);},O.readAsDataURL(T);},[]),U=async()=>{await c({username:L||void 0,avatarUrl:g??y?.avatarUrl,bio:I||void 0})&&(w(false),d?.());};if(m)return jsxRuntime.jsxs("div",{className:p,style:{display:"grid",gap:"1.5rem"},children:[jsxRuntime.jsx("div",{style:{height:40,background:"var(--x-color-neutral-800, #333)",animation:"pulse 2s infinite"}}),jsxRuntime.jsx("div",{style:{height:40,background:"var(--x-color-neutral-800, #333)",animation:"pulse 2s infinite"}})]});let R=r==="global"||!r?"Global profile":`Stack profile (${r.stackId})`;return jsxRuntime.jsxs("div",{className:p,style:{display:"grid",gap:"1.5rem"},children:[jsxRuntime.jsx("p",{style:{fontSize:11,color:"var(--x-color-neutral-500, #91918D)",textTransform:"uppercase",letterSpacing:"0.05em"},children:R}),jsxRuntime.jsxs("div",{style:{display:"grid",gap:"1.5rem",gridTemplateColumns:"1fr 1fr"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[jsxRuntime.jsx("label",{style:{fontSize:14,color:"var(--x-color-neutral-400, #91918D)"},children:"Username"}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>k.current?.click(),style:{width:40,height:40,flexShrink:0,cursor:"pointer",overflow:"hidden",background:"var(--x-color-neutral-800, #262625)",border:"none",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:v?jsxRuntime.jsx("img",{src:v,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--x-color-neutral-500, #91918D)"},children:[jsxRuntime.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),jsxRuntime.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}),jsxRuntime.jsx("input",{type:"text",value:L,onChange:b=>{o(b.target.value),w(true);},placeholder:"Enter username",maxLength:30,style:{flex:1,padding:"0.75rem 1rem",fontSize:14,background:"var(--x-color-neutral-800, #262625)",color:"var(--x-color-neutral-100, #FAFAF7)",border:"none",outline:"none"}})]}),jsxRuntime.jsx("input",{ref:k,type:"file",accept:"image/*",onChange:F,style:{display:"none"}})]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[jsxRuntime.jsx("label",{style:{fontSize:14,color:"var(--x-color-neutral-400, #91918D)"},children:"Bio"}),jsxRuntime.jsx("input",{type:"text",value:I,onChange:b=>{n(b.target.value),w(true);},placeholder:"Tell us about yourself",maxLength:200,style:{width:"100%",padding:"0.75rem 1rem",fontSize:14,background:"var(--x-color-neutral-800, #262625)",color:"var(--x-color-neutral-100, #FAFAF7)",border:"none",outline:"none"}})]})]}),l&&jsxRuntime.jsx("p",{style:{fontSize:13,color:"var(--x-color-red-500, #BF4D43)"},children:l}),C&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[jsxRuntime.jsx("button",{onClick:U,disabled:a,style:{padding:"0.5rem 1.25rem",fontSize:13,fontWeight:700,background:"var(--x-color-blue-600, #165DFC)",color:"#FFF",border:"none",cursor:a?"wait":"pointer",opacity:a?.6:1},children:a?"Saving...":"Save"}),jsxRuntime.jsx("button",{onClick:()=>{o(null),n(null),s(null),w(false);},style:{padding:"0.5rem 1.25rem",fontSize:13,background:"var(--x-color-neutral-800, #262625)",color:"var(--x-color-neutral-400, #91918D)",border:"none",cursor:"pointer"},children:"Cancel"}),jsxRuntime.jsx("p",{style:{fontSize:11,color:"var(--x-color-neutral-500, #666663)",alignSelf:"center",marginLeft:"0.5rem"},children:"Profile updates cost 10M tokens"})]})]})}function zn({className:e}){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",className:e||"h-5 w-5",children:[jsxRuntime.jsxs("linearGradient",{id:"sol-g",x1:"7.233",x2:"24.766",y1:"24.766",y2:"7.234",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{offset:"0",stopColor:"#9945ff"}),jsxRuntime.jsx("stop",{offset:"0.2",stopColor:"#7962e7"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"#00d18c"})]}),jsxRuntime.jsx("path",{fill:"#10111a",d:"M0 0h32v32H0z"}),jsxRuntime.jsx("path",{fill:"url(#sol-g)",fillRule:"evenodd",d:"M9.873 20.41a.65.65 0 0 1 .476-.21l14.662.012a.323.323 0 0 1 .238.54l-3.123 3.438a.64.64 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.64.64 0 0 1-.476-.21l-3.122-3.44a.323.323 0 0 1 .238-.54l14.662-.012a.64.64 0 0 1 .475.21zM9.873 7.81a.64.64 0 0 1 .476-.21l14.662.012a.322.322 0 0 1 .238.54l-3.123 3.438a.64.64 0 0 1-.475.21l-14.662-.012a.323.323 0 0 1-.238-.54z",clipRule:"evenodd"})]})}function Rn({className:e}){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",className:e||"h-5 w-5",children:[jsxRuntime.jsx("rect",{width:"20",height:"20",rx:"4",fill:"#627EEA",fillOpacity:"0.2"}),jsxRuntime.jsx("path",{fill:"#627EEA",d:"M10 3l-4 6.5 4 2.5 4-2.5L10 3z"}),jsxRuntime.jsx("path",{fill:"#627EEA",fillOpacity:"0.6",d:"M6 9.5L10 12l4-2.5L10 17 6 9.5z"})]})}function _n({className:e}){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",className:e||"h-8 w-8",children:[jsxRuntime.jsx("rect",{width:"512",height:"512",rx:"15%",fill:"#37aee2"}),jsxRuntime.jsx("path",{fill:"#c8daea",d:"M199 404c-11 0-10-4-13-14l-32-105 245-144"}),jsxRuntime.jsx("path",{fill:"#a9c9dd",d:"M199 404c7 0 11-4 16-8l45-43-56-34"}),jsxRuntime.jsx("path",{fill:"#f6fbfe",d:"M204 319l135 99c14 9 26 4 30-14l55-258c5-22-9-32-24-25L79 245c-21 8-21 21-4 26l83 26 190-121c9-5 17-3 11 4"})]})}function Wn(e){let{apiBaseUrl:t,stacknetUrl:r="https://stacknet.magma-rpc.com",stackId:d="",transport:p,serviceKey:y,onAuthSuccess:m,onAuthError:a,onLogout:l}=e;async function c(o){if(!o.ok){let s=await o.json().catch(()=>({})),k=new Error(s.error||`Authentication failed (${o.status})`);throw a?.(k),k}let i=await o.json(),n=i.token||i.jwt,g=i.session||{userId:i.user?.id||i.userId||i.sub||"",address:i.user?.address||i.address,chain:i.user?.chain||i.chain,expiresAt:i.expiresAt||Date.now()+10080*60*1e3,authMethod:i.authMethod||i.method};return n&&await p.storeCredentials(n,g),m?.(g),g}return {async login(o,i){let n=await fetch(`${t}/api/auth/callback/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o,password:i})});return c(n)},async loginWeb3({chain:o,address:i,message:n,signature:g}){let s={chain:o,message:n,signature:g,stackId:d};o==="solana"&&(s.publicKey=i);let k=await fetch(`${t}/api/auth/callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return c(k)},async loginOTP(o){let i=await fetch(`${t}/api/auth/otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:o})});return c(i)},async getSession(){let o=await p.getStoredSession();if(o&&o.expiresAt>Date.now())return o;try{let i=await p.getHeaders(),n=await fetch(`${t}/api/auth/session`,{headers:i});if(n.ok){let g=await n.json();if(g.session)return g.session}}catch{if(o)return o}return null},async checkSession(){let o=await p.getToken();if(!o)return false;try{let i=await fetch(`${t}/api/history?limit=1`,{headers:{Authorization:`Bearer ${o}`}});return i.ok?!0:i.status===401?(await p.clear(),!1):!0}catch{return true}},async getChallenge(o,i){let g=`${r}/api/v2/stacks/${encodeURIComponent(d)}/auth/web3/challenge`,s=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chain:o,address:i})});if(!s.ok)throw new Error("Failed to get challenge");let k=await s.json();return k.data||k},async logout(){try{let o=await p.getHeaders();await fetch(`${t}/api/auth/logout`,{method:"POST",headers:o});}catch{}await p.clear(),l?.();},async getHeaders(){let o=await p.getHeaders();return Object.keys(o).length>0?o:y?{Authorization:`Bearer ${y}`}:{}},async getToken(){return p.getToken()}}}function Fn(){return {async storeCredentials(e,t){},async getToken(){return null},async getHeaders(){return {}},async getStoredSession(){let e=oe();return !e||e.expiresAt<=Date.now()?null:{userId:e.userId,address:e.address,chain:e.chain,expiresAt:e.expiresAt,planId:e.planId,authMethod:e.authMethod}},async clear(){}}}var Ke="stackauth_token",qe="stackauth_session";function Bn(e){return {async storeCredentials(t,r){await e.setItemAsync(Ke,t),await e.setItemAsync(qe,JSON.stringify(r));},async getToken(){try{return await e.getItemAsync(Ke)}catch{return null}},async getHeaders(){let t=await this.getToken();return t?{Authorization:`Bearer ${t}`}:{}},async getStoredSession(){try{let t=await e.getItemAsync(qe);return t?JSON.parse(t):null}catch{return null}},async clear(){await e.deleteItemAsync(Ke).catch(()=>{}),await e.deleteItemAsync(qe).catch(()=>{});}}}
|
|
2
|
+
exports.AppleIcon=Ze;exports.ConnectWidget=Un;exports.DiscordIcon=Qe;exports.EthereumIcon=Rn;exports.GoogleIcon=Je;exports.MetaMaskIcon=he;exports.OTPInput=ae;exports.PhantomIcon=me;exports.ProfileSettings=Dn;exports.SolanaIcon=zn;exports.TelegramIcon=_n;exports.TwitterIcon=Ve;exports.UserUtilsProvider=Cn;exports.cn=Rt;exports.createAuthClient=Wn;exports.createNativeTransport=Bn;exports.createStackNetClient=Me;exports.createWebTransport=Fn;exports.decodeJwtPayloadClient=$t;exports.formatTokens=Et;exports.readCSRFCookie=Q;exports.readSessionCookie=oe;exports.safeUrl=ne;exports.useAuthBridge=Ae;exports.useBillingHistory=cn;exports.useCSRFToken=Pe;exports.useGoogleOneTap=fn;exports.useJoinCode=yn;exports.usePlans=Xt;exports.usePrepaidCheckout=sn;exports.useProfile=_e;exports.useSession=re;exports.useStackAuth=Le;exports.useStackConfig=ie;exports.useSubscription=tn;exports.useUsage=rn;exports.useUserUtilsContext=wn;exports.useWeb3Wallet=Ie;exports.validateRedirectUrl=_t;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as APIResponse, N as NetworkStatus, W as Web3Chain } from './auth-
|
|
2
|
-
export { M as MPCNode, P as PublicSession, S as Session } from './auth-
|
|
3
|
-
export { B as BillingPlan, a as BillingRecord, P as PrepaidCheckoutResult, b as PrepaidVerifyResult, S as Subscription, U as UsageSummary, c as UserUtilsCallbacks, d as UserUtilsConfig } from './config-
|
|
1
|
+
import { A as APIResponse, N as NetworkStatus, W as Web3Chain } from './auth-c1d7Eji2.cjs';
|
|
2
|
+
export { M as MPCNode, P as PublicSession, S as Session } from './auth-c1d7Eji2.cjs';
|
|
3
|
+
export { B as BillingPlan, a as BillingRecord, P as PrepaidCheckoutResult, b as PrepaidVerifyResult, S as Subscription, U as UsageSummary, c as UserUtilsCallbacks, d as UserUtilsConfig } from './config-CLzVWDrU.cjs';
|
|
4
4
|
export { ProfileScope, ProfileUpdateInput, UserProfile } from './types/index.cjs';
|
|
5
5
|
export { cn, decodeJwtPayloadClient, formatTokens, readCSRFCookie, readSessionCookie, safeUrl, validateRedirectUrl } from './utils/index.cjs';
|
|
6
|
-
export { BridgeIdentity, GoogleOneTapConfig, StackPublicConfig, WalletState, useAuthBridge, useBillingHistory, useCSRFToken, useGoogleOneTap, usePlans, usePrepaidCheckout, useProfile, useSession, useStackAuth, useStackConfig, useSubscription, useUsage, useWeb3Wallet } from './hooks/index.cjs';
|
|
6
|
+
export { BridgeIdentity, GoogleOneTapConfig, StackPublicConfig, UseJoinCodeConfig, UseJoinCodeResult, WalletState, useAuthBridge, useBillingHistory, useCSRFToken, useGoogleOneTap, useJoinCode, usePlans, usePrepaidCheckout, useProfile, useSession, useStackAuth, useStackConfig, useSubscription, useUsage, useWeb3Wallet } from './hooks/index.cjs';
|
|
7
7
|
export { AppleIcon, ConnectWidget, ConnectWidgetProps, DiscordIcon, EthereumIcon, GoogleIcon, MetaMaskIcon, OTPInput, OTPInputProps, PhantomIcon, ProfileSettings, ProfileSettingsProps, SolanaIcon, TelegramIcon, TwitterIcon, UserUtilsProvider, UserUtilsProviderProps, useUserUtilsContext } from './components/index.cjs';
|
|
8
8
|
export { createAuthClient } from './core/index.cjs';
|
|
9
|
-
export { A as AuthClient, a as AuthClientConfig, b as AuthTransport } from './types-
|
|
9
|
+
export { A as AuthClient, a as AuthClientConfig, b as AuthTransport } from './types-B_Vj6cr4.cjs';
|
|
10
10
|
export { SecureStorage, createNativeTransport, createWebTransport } from './adapters/index.cjs';
|
|
11
11
|
import 'clsx';
|
|
12
12
|
import 'react/jsx-runtime';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as APIResponse, N as NetworkStatus, W as Web3Chain } from './auth-
|
|
2
|
-
export { M as MPCNode, P as PublicSession, S as Session } from './auth-
|
|
3
|
-
export { B as BillingPlan, a as BillingRecord, P as PrepaidCheckoutResult, b as PrepaidVerifyResult, S as Subscription, U as UsageSummary, c as UserUtilsCallbacks, d as UserUtilsConfig } from './config-
|
|
1
|
+
import { A as APIResponse, N as NetworkStatus, W as Web3Chain } from './auth-c1d7Eji2.js';
|
|
2
|
+
export { M as MPCNode, P as PublicSession, S as Session } from './auth-c1d7Eji2.js';
|
|
3
|
+
export { B as BillingPlan, a as BillingRecord, P as PrepaidCheckoutResult, b as PrepaidVerifyResult, S as Subscription, U as UsageSummary, c as UserUtilsCallbacks, d as UserUtilsConfig } from './config-xNca5ufB.js';
|
|
4
4
|
export { ProfileScope, ProfileUpdateInput, UserProfile } from './types/index.js';
|
|
5
5
|
export { cn, decodeJwtPayloadClient, formatTokens, readCSRFCookie, readSessionCookie, safeUrl, validateRedirectUrl } from './utils/index.js';
|
|
6
|
-
export { BridgeIdentity, GoogleOneTapConfig, StackPublicConfig, WalletState, useAuthBridge, useBillingHistory, useCSRFToken, useGoogleOneTap, usePlans, usePrepaidCheckout, useProfile, useSession, useStackAuth, useStackConfig, useSubscription, useUsage, useWeb3Wallet } from './hooks/index.js';
|
|
6
|
+
export { BridgeIdentity, GoogleOneTapConfig, StackPublicConfig, UseJoinCodeConfig, UseJoinCodeResult, WalletState, useAuthBridge, useBillingHistory, useCSRFToken, useGoogleOneTap, useJoinCode, usePlans, usePrepaidCheckout, useProfile, useSession, useStackAuth, useStackConfig, useSubscription, useUsage, useWeb3Wallet } from './hooks/index.js';
|
|
7
7
|
export { AppleIcon, ConnectWidget, ConnectWidgetProps, DiscordIcon, EthereumIcon, GoogleIcon, MetaMaskIcon, OTPInput, OTPInputProps, PhantomIcon, ProfileSettings, ProfileSettingsProps, SolanaIcon, TelegramIcon, TwitterIcon, UserUtilsProvider, UserUtilsProviderProps, useUserUtilsContext } from './components/index.js';
|
|
8
8
|
export { createAuthClient } from './core/index.js';
|
|
9
|
-
export { A as AuthClient, a as AuthClientConfig, b as AuthTransport } from './types-
|
|
9
|
+
export { A as AuthClient, a as AuthClientConfig, b as AuthTransport } from './types-Cu0do-w-.js';
|
|
10
10
|
export { SecureStorage, createNativeTransport, createWebTransport } from './adapters/index.js';
|
|
11
11
|
import 'clsx';
|
|
12
12
|
import 'react/jsx-runtime';
|