accesly 0.1.3 → 0.2.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/index.d.mts +32 -3
- package/dist/index.d.ts +32 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -35,17 +35,40 @@ interface WalletInfo {
|
|
|
35
35
|
/** A single transaction record */
|
|
36
36
|
interface TransactionRecord {
|
|
37
37
|
id: string;
|
|
38
|
-
type: 'sent' | 'received';
|
|
38
|
+
type: 'sent' | 'received' | 'swap';
|
|
39
39
|
amount: string;
|
|
40
40
|
asset: string;
|
|
41
41
|
counterparty: string;
|
|
42
42
|
createdAt: string;
|
|
43
|
+
fromAmount?: string;
|
|
44
|
+
fromAsset?: string;
|
|
45
|
+
}
|
|
46
|
+
/** A non-XLM asset balance on the wallet */
|
|
47
|
+
interface AssetBalance {
|
|
48
|
+
code: string;
|
|
49
|
+
issuer: string;
|
|
50
|
+
balance: string;
|
|
43
51
|
}
|
|
44
52
|
/** Parameters for sending a payment */
|
|
45
53
|
interface SendPaymentParams {
|
|
46
54
|
destination: string;
|
|
47
55
|
amount: string;
|
|
48
56
|
memo?: string;
|
|
57
|
+
/** Asset code to send. Defaults to "XLM" if omitted. */
|
|
58
|
+
assetCode?: string;
|
|
59
|
+
/** Asset issuer address. Required when assetCode is not "XLM". */
|
|
60
|
+
assetIssuer?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Parameters for swapping assets via the Stellar DEX */
|
|
63
|
+
interface SwapParams {
|
|
64
|
+
/** Asset to sell: "XLM" | "USDC" | "EURC" */
|
|
65
|
+
fromAsset: string;
|
|
66
|
+
/** Asset to buy: "XLM" | "USDC" | "EURC" */
|
|
67
|
+
toAsset: string;
|
|
68
|
+
/** Exact amount to sell */
|
|
69
|
+
amount: string;
|
|
70
|
+
/** Minimum amount to receive (slippage protection) */
|
|
71
|
+
minReceive: string;
|
|
49
72
|
}
|
|
50
73
|
/** Result from signing a transaction */
|
|
51
74
|
interface SignResult {
|
|
@@ -62,16 +85,22 @@ interface AcceslyContextType {
|
|
|
62
85
|
wallet: WalletInfo | null;
|
|
63
86
|
/** Current XLM balance string, or null */
|
|
64
87
|
balance: string | null;
|
|
88
|
+
/** Non-XLM asset balances (USDC, EURC, etc.) */
|
|
89
|
+
assetBalances: AssetBalance[];
|
|
65
90
|
/** Last error message, or null */
|
|
66
91
|
error: string | null;
|
|
67
92
|
/** Open the auth popup and connect */
|
|
68
93
|
connect: () => Promise<void>;
|
|
69
94
|
/** Disconnect and clear all state */
|
|
70
95
|
disconnect: () => void;
|
|
71
|
-
/** Send a payment */
|
|
96
|
+
/** Send a payment (XLM, USDC, or EURC) */
|
|
72
97
|
sendPayment: (params: SendPaymentParams) => Promise<{
|
|
73
98
|
txHash: string;
|
|
74
99
|
}>;
|
|
100
|
+
/** Swap assets using the Stellar DEX */
|
|
101
|
+
swap: (params: SwapParams) => Promise<{
|
|
102
|
+
txHash: string;
|
|
103
|
+
}>;
|
|
75
104
|
/** Rotate wallet keys (generates new keypair, updates contract) */
|
|
76
105
|
rotateKeys: () => Promise<{
|
|
77
106
|
newStellarAddress: string;
|
|
@@ -116,4 +145,4 @@ declare function ConnectButton(): react_jsx_runtime.JSX.Element;
|
|
|
116
145
|
|
|
117
146
|
declare function useAccesly(): AcceslyContextType;
|
|
118
147
|
|
|
119
|
-
export { type AcceslyConfig, type AcceslyContextType, AcceslyProvider, ConnectButton, type SendPaymentParams, type SignResult, type TransactionRecord, type WalletInfo, useAccesly };
|
|
148
|
+
export { type AcceslyConfig, type AcceslyContextType, AcceslyProvider, type AssetBalance, ConnectButton, type SendPaymentParams, type SignResult, type SwapParams, type TransactionRecord, type WalletInfo, useAccesly };
|
package/dist/index.d.ts
CHANGED
|
@@ -35,17 +35,40 @@ interface WalletInfo {
|
|
|
35
35
|
/** A single transaction record */
|
|
36
36
|
interface TransactionRecord {
|
|
37
37
|
id: string;
|
|
38
|
-
type: 'sent' | 'received';
|
|
38
|
+
type: 'sent' | 'received' | 'swap';
|
|
39
39
|
amount: string;
|
|
40
40
|
asset: string;
|
|
41
41
|
counterparty: string;
|
|
42
42
|
createdAt: string;
|
|
43
|
+
fromAmount?: string;
|
|
44
|
+
fromAsset?: string;
|
|
45
|
+
}
|
|
46
|
+
/** A non-XLM asset balance on the wallet */
|
|
47
|
+
interface AssetBalance {
|
|
48
|
+
code: string;
|
|
49
|
+
issuer: string;
|
|
50
|
+
balance: string;
|
|
43
51
|
}
|
|
44
52
|
/** Parameters for sending a payment */
|
|
45
53
|
interface SendPaymentParams {
|
|
46
54
|
destination: string;
|
|
47
55
|
amount: string;
|
|
48
56
|
memo?: string;
|
|
57
|
+
/** Asset code to send. Defaults to "XLM" if omitted. */
|
|
58
|
+
assetCode?: string;
|
|
59
|
+
/** Asset issuer address. Required when assetCode is not "XLM". */
|
|
60
|
+
assetIssuer?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Parameters for swapping assets via the Stellar DEX */
|
|
63
|
+
interface SwapParams {
|
|
64
|
+
/** Asset to sell: "XLM" | "USDC" | "EURC" */
|
|
65
|
+
fromAsset: string;
|
|
66
|
+
/** Asset to buy: "XLM" | "USDC" | "EURC" */
|
|
67
|
+
toAsset: string;
|
|
68
|
+
/** Exact amount to sell */
|
|
69
|
+
amount: string;
|
|
70
|
+
/** Minimum amount to receive (slippage protection) */
|
|
71
|
+
minReceive: string;
|
|
49
72
|
}
|
|
50
73
|
/** Result from signing a transaction */
|
|
51
74
|
interface SignResult {
|
|
@@ -62,16 +85,22 @@ interface AcceslyContextType {
|
|
|
62
85
|
wallet: WalletInfo | null;
|
|
63
86
|
/** Current XLM balance string, or null */
|
|
64
87
|
balance: string | null;
|
|
88
|
+
/** Non-XLM asset balances (USDC, EURC, etc.) */
|
|
89
|
+
assetBalances: AssetBalance[];
|
|
65
90
|
/** Last error message, or null */
|
|
66
91
|
error: string | null;
|
|
67
92
|
/** Open the auth popup and connect */
|
|
68
93
|
connect: () => Promise<void>;
|
|
69
94
|
/** Disconnect and clear all state */
|
|
70
95
|
disconnect: () => void;
|
|
71
|
-
/** Send a payment */
|
|
96
|
+
/** Send a payment (XLM, USDC, or EURC) */
|
|
72
97
|
sendPayment: (params: SendPaymentParams) => Promise<{
|
|
73
98
|
txHash: string;
|
|
74
99
|
}>;
|
|
100
|
+
/** Swap assets using the Stellar DEX */
|
|
101
|
+
swap: (params: SwapParams) => Promise<{
|
|
102
|
+
txHash: string;
|
|
103
|
+
}>;
|
|
75
104
|
/** Rotate wallet keys (generates new keypair, updates contract) */
|
|
76
105
|
rotateKeys: () => Promise<{
|
|
77
106
|
newStellarAddress: string;
|
|
@@ -116,4 +145,4 @@ declare function ConnectButton(): react_jsx_runtime.JSX.Element;
|
|
|
116
145
|
|
|
117
146
|
declare function useAccesly(): AcceslyContextType;
|
|
118
147
|
|
|
119
|
-
export { type AcceslyConfig, type AcceslyContextType, AcceslyProvider, ConnectButton, type SendPaymentParams, type SignResult, type TransactionRecord, type WalletInfo, useAccesly };
|
|
148
|
+
export { type AcceslyConfig, type AcceslyContextType, AcceslyProvider, type AssetBalance, ConnectButton, type SendPaymentParams, type SignResult, type SwapParams, type TransactionRecord, type WalletInfo, useAccesly };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var Y="accesly_auth",Te="https://accesly.vercel.app",I=class extends Error{constructor(n,i){super(n),this.name="AcceslyApiError",this.status=i;}},G=class{constructor(n,i){this.appId=n,this.baseUrl=i||Te;}setTokens(n){localStorage.setItem(Y,JSON.stringify(n));}getTokens(){let n=localStorage.getItem(Y);if(!n)return null;try{return JSON.parse(n)}catch{return null}}clearTokens(){localStorage.removeItem(Y);}hasSession(){return this.getTokens()!==null}async request(n,i={},a=true){let p=this.getTokens(),b={"Content-Type":"application/json","x-accesly-key":this.appId,...p?{Authorization:`Bearer ${p.accessToken}`}:{}},u=await fetch(`${this.baseUrl}${n}`,{...i,headers:{...b,...i.headers}});if(u.status===401&&a&&p?.refreshToken){if(await this.refreshToken(p.refreshToken))return this.request(n,i,false);throw this.clearTokens(),new Error("Session expired. Please reconnect.")}if(!u.ok){let m=await u.json().catch(()=>({}));throw new I(m.error||m.details||`Request failed: ${u.status}`,u.status)}return u.json()}async refreshToken(n){try{let i=await fetch(`${this.baseUrl}/api/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:n})});if(!i.ok)return !1;let a=await i.json(),p=this.getTokens();return p&&this.setTokens({...p,accessToken:a.accessToken,refreshToken:a.refreshToken,expiresAt:a.expiresAt}),!0}catch{return false}}async getWalletInfo(){return this.request("/api/wallet/info")}async createWallet(){return this.request("/api/wallet/create",{method:"POST"})}async getBalance(){return this.request("/api/wallet/balance")}async sendPayment(n){return this.request("/api/wallet/send",{method:"POST",body:JSON.stringify(n)})}async getTransactions(n=20){return this.request(`/api/wallet/transactions?limit=${n}`)}async rotateKeys(){return this.request("/api/wallet/rotate",{method:"POST"})}async signTransaction(n){return this.request("/api/wallet/sign",{method:"POST",body:JSON.stringify({xdr:n,submit:false})})}async signAndSubmit(n){return this.request("/api/wallet/sign",{method:"POST",body:JSON.stringify({xdr:n,submit:true})})}};function ie(l,n){return new Promise((i,a)=>{let p=window.screenX+(window.innerWidth-450)/2,b=window.screenY+(window.innerHeight-600)/2,u=window.open(`${l}/auth/popup?appId=${n}`,"accesly-auth",`width=450,height=600,left=${p},top=${b},toolbar=no,menubar=no`);if(!u){a(new Error("Failed to open popup. Please allow popups for this site."));return}function m(x){x.origin.includes(new URL(l).host)&&(x.data?.type==="accesly-auth-success"&&(d(),i(x.data.payload)),x.data?.type==="accesly-auth-error"&&(d(),a(new Error(x.data.error||"Authentication failed"))));}let S=setInterval(()=>{u.closed&&(d(),a(new Error("Authentication cancelled")));},500);function d(){window.removeEventListener("message",m),clearInterval(S);}window.addEventListener("message",m);})}var Q=react.createContext(null),Be="https://accesly.vercel.app";function Ie({children:l,...n}){let i=n.baseUrl||Be,a=react.useMemo(()=>new G(n.appId,i),[n.appId,i]),[p,b]=react.useState(null),[u,m]=react.useState(null),[S,d]=react.useState(true),[x,T]=react.useState(false),[w,g]=react.useState(null);react.useEffect(()=>{a.hasSession()?P():d(false);},[a]),react.useEffect(()=>{if(!p)return;B();let s=setInterval(B,15e3);return ()=>clearInterval(s)},[p]);async function P(){g(null);try{let s=await a.getWalletInfo();b(s.wallet),n.onConnect?.(s.wallet);}catch(s){if(s instanceof I&&s.status===404){await A();return}s instanceof I&&s.status===401&&(a.clearTokens(),b(null)),g(s.message);}finally{d(false);}}async function A(){T(true),g(null);try{await a.createWallet();let s=await a.getWalletInfo();b(s.wallet),n.onConnect?.(s.wallet);}catch(s){g(s.message);}finally{T(false),d(false);}}async function B(){try{let D=(await a.getBalance()).balances.find(J=>J.asset==="native");m(D?.balance||"0");}catch{}}let $=react.useCallback(async()=>{g(null);try{let s=await ie(i,n.appId);a.setTokens(s),d(!0),await P();}catch(s){s.message!=="Authentication cancelled"&&g(s.message);}},[i,n.appId,a]),H=react.useCallback(()=>{a.clearTokens(),b(null),m(null),g(null),n.onDisconnect?.();},[a,n.onDisconnect]),W=react.useCallback(async s=>a.sendPayment(s),[a]),O=react.useCallback(async()=>a.rotateKeys(),[a]),L=react.useCallback(async(s=20)=>(await a.getTransactions(s)).transactions,[a]),V=react.useCallback(async()=>{await B();},[a]),_=react.useCallback(async()=>{await P();},[a]),z=react.useCallback(async s=>a.signTransaction(s),[a]),M=react.useCallback(async s=>a.signAndSubmit(s),[a]),N={loading:S,creating:x,wallet:p,balance:u,error:w,connect:$,disconnect:H,sendPayment:W,rotateKeys:O,getTransactions:L,refreshBalance:V,refreshWallet:_,signTransaction:z,signAndSubmit:M};return jsxRuntime.jsx(Q.Provider,{value:N,children:l})}function E(){let l=react.useContext(Q);if(!l)throw new Error('useAccesly must be used within an <AcceslyProvider>. Wrap your app with <AcceslyProvider appId="acc_xxxxx">.');return l}function le({onClose:l,onConnect:n}){return jsxRuntime.jsx("div",{style:C.overlay,onClick:l,children:jsxRuntime.jsxs("div",{style:C.modal,onClick:i=>i.stopPropagation(),children:[jsxRuntime.jsx("button",{onClick:l,style:C.closeBtn,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsxRuntime.jsx("div",{style:C.iconWrapper,children:jsxRuntime.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"#667eea",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),jsxRuntime.jsx("h2",{style:C.title,children:"Connect to Accesly"}),jsxRuntime.jsx("p",{style:C.subtitle,children:"Choose how you want to connect"}),jsxRuntime.jsxs("button",{onClick:n,style:C.googleBtn,children:[jsxRuntime.jsxs("svg",{style:C.googleIcon,viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),jsxRuntime.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),jsxRuntime.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),jsxRuntime.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]}),jsxRuntime.jsx("p",{style:C.footer,children:"Powered by Accesly"})]})})}var C={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,padding:"1rem",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},modal:{position:"relative",backgroundColor:"#141428",borderRadius:"20px",border:"1px solid #2a2a4a",padding:"2rem",width:"100%",maxWidth:"380px",textAlign:"center"},closeBtn:{position:"absolute",top:"1rem",right:"1rem",background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},iconWrapper:{width:"56px",height:"56px",borderRadius:"16px",backgroundColor:"rgba(102, 126, 234, 0.1)",border:"1px solid rgba(102, 126, 234, 0.2)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 1rem"},title:{fontSize:"1.3rem",fontWeight:700,color:"#e2e8f0",margin:"0 0 0.25rem"},subtitle:{color:"#64748b",fontSize:"0.85rem",margin:"0 0 1.5rem"},googleBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.75rem",padding:"0.85rem 1.5rem",backgroundColor:"#1a1a2e",color:"#e2e8f0",border:"1px solid #2a2a4a",borderRadius:"12px",fontSize:"0.95rem",fontWeight:500,cursor:"pointer",width:"100%",marginBottom:"1.25rem"},googleIcon:{width:"20px",height:"20px",flexShrink:0},footer:{color:"#475569",fontSize:"0.7rem",margin:0}};function de({onClose:l}){let{wallet:n,balance:i,disconnect:a,sendPayment:p,rotateKeys:b,getTransactions:u,refreshBalance:m,refreshWallet:S}=E(),[d,x]=react.useState("wallet"),[T,w]=react.useState("main"),[g,P]=react.useState(""),[A,B]=react.useState(""),[$,H]=react.useState(""),[W,O]=react.useState(false),[L,V]=react.useState(null),[_,z]=react.useState(null),[M,N]=react.useState([]),[s,D]=react.useState(false),[J,ue]=react.useState(0),[X,Z]=react.useState(false),[ee,te]=react.useState(null),[j,ne]=react.useState(null);if(react.useEffect(()=>{if(d!=="activity")return;oe();let o=setInterval(oe,15e3);return ()=>clearInterval(o)},[d,J]),!n)return null;async function oe(){D(true);try{let o=await u(20);N(o);}catch{}finally{D(false);}}async function ye(){if(!(!g||!A)){O(true),z(null);try{let o=await p({destination:g,amount:A,memo:$||void 0});V(o.txHash),m(),ue(c=>c+1);}catch(o){z(o.message);}finally{O(false);}}}function fe(){V(null),P(""),B(""),H(""),z(null),w("main");}async function me(){if(confirm("This will generate a new keypair and update your contract. Continue?")){Z(true),te(null);try{await b(),await S();}catch(o){te(o.message);}finally{Z(false);}}}function ge(){a(),l();}function q(o,c=6,ae=6){return o.length<=c+ae+3?o:`${o.slice(0,c)}...${o.slice(-ae)}`}async function re(o,c){await navigator.clipboard.writeText(o),ne(c),setTimeout(()=>ne(null),1500);}function he(o){let c=Math.floor((Date.now()-new Date(o).getTime())/1e3);return c<60?"just now":c<3600?`${Math.floor(c/60)}m ago`:c<86400?`${Math.floor(c/3600)}h ago`:c<172800?"yesterday":`${Math.floor(c/86400)}d ago`}let be=i?parseFloat(i).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):"---",xe=ze(n.stellarAddress),ve=[{key:"wallet",label:"Wallet"},{key:"activity",label:"Activity"},{key:"account",label:"Account"},{key:"security",label:"Security"}];return jsxRuntime.jsx("div",{style:e.overlay,onClick:l,children:jsxRuntime.jsxs("div",{style:e.panel,onClick:o=>o.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:e.header,children:[jsxRuntime.jsx("button",{onClick:l,style:e.closeBtn,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsxRuntime.jsx("div",{style:{...e.identicon,backgroundColor:xe}}),jsxRuntime.jsx("p",{style:e.headerAddr,children:q(n.stellarAddress,8,8)}),jsxRuntime.jsxs("p",{style:e.headerBalance,children:[be," ",jsxRuntime.jsx("span",{style:e.headerCurrency,children:"XLM"})]})]}),jsxRuntime.jsx("div",{style:e.tabBar,children:ve.map(o=>jsxRuntime.jsx("button",{onClick:()=>{x(o.key),w("main");},style:{...e.tab,...d===o.key?e.tabActive:{}},children:o.label},o.key))}),jsxRuntime.jsxs("div",{style:e.content,children:[d==="wallet"&&we(),d==="activity"&&ke(),d==="account"&&Ce(),d==="security"&&Se()]})]})});function we(){return L?jsxRuntime.jsxs("div",{style:e.centeredCol,children:[jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"8 12 11 15 16 9"})]}),jsxRuntime.jsx("p",{style:{color:"#34d399",fontWeight:600,margin:"0.5rem 0"},children:"Payment Sent"}),jsxRuntime.jsxs("p",{style:{color:"#64748b",fontSize:"0.75rem",fontFamily:"monospace"},children:[L.slice(0,12),"...",L.slice(-12)]}),jsxRuntime.jsx("button",{onClick:fe,style:e.primaryBtn,children:"Done"})]}):T==="send"?jsxRuntime.jsxs("div",{style:e.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>w("main"),style:e.backBtn,children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}),jsxRuntime.jsxs("div",{style:e.formGroup,children:[jsxRuntime.jsx("label",{style:e.formLabel,children:"Destination"}),jsxRuntime.jsx("input",{type:"text",placeholder:"G...",value:g,onChange:o=>P(o.target.value),maxLength:56,style:e.formInput})]}),jsxRuntime.jsxs("div",{style:e.formGroup,children:[jsxRuntime.jsx("label",{style:e.formLabel,children:"Amount (XLM)"}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:A,onChange:o=>B(o.target.value),min:"0.0000001",step:"any",style:e.formInput})]}),jsxRuntime.jsxs("div",{style:e.formGroup,children:[jsxRuntime.jsx("label",{style:e.formLabel,children:"Memo (optional)"}),jsxRuntime.jsx("input",{type:"text",placeholder:"What is this for?",value:$,onChange:o=>H(o.target.value),maxLength:28,style:e.formInput})]}),_&&jsxRuntime.jsx("p",{style:e.error,children:_}),jsxRuntime.jsx("button",{onClick:ye,disabled:W||!g||!A,style:{...e.primaryBtn,opacity:W||!g||!A?.5:1},children:W?"Sending...":"Send Payment"})]}):T==="receive"?jsxRuntime.jsxs("div",{style:e.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>w("main"),style:e.backBtn,children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}),jsxRuntime.jsxs("div",{style:e.centeredCol,children:[jsxRuntime.jsx("div",{style:e.receiveIconBig,children:jsxRuntime.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),jsxRuntime.jsx("p",{style:{color:"#e2e8f0",fontWeight:600,fontSize:"1rem",margin:0},children:"Receive XLM"}),jsxRuntime.jsx("p",{style:{color:"#64748b",fontSize:"0.8rem",margin:0,textAlign:"center"},children:"Share your Stellar address to receive payments"}),jsxRuntime.jsx("div",{style:e.addressBox,children:jsxRuntime.jsx("span",{style:e.addressText,children:n.stellarAddress})}),jsxRuntime.jsx("button",{onClick:()=>re(n.stellarAddress,"receive"),style:e.primaryBtn,children:j==="receive"?"Copied!":"Copy Address"})]})]}):jsxRuntime.jsx("div",{style:e.walletTab,children:jsxRuntime.jsxs("div",{style:e.actionRow,children:[jsxRuntime.jsxs("button",{onClick:()=>w("send"),style:e.actionBtn,children:[jsxRuntime.jsx("div",{style:e.actionIcon,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),jsxRuntime.jsx("polyline",{points:"5 12 12 5 19 12"})]})}),jsxRuntime.jsx("span",{style:e.actionLabel,children:"Send"})]}),jsxRuntime.jsxs("button",{onClick:()=>w("receive"),style:e.actionBtn,children:[jsxRuntime.jsx("div",{style:{...e.actionIcon,...e.actionIconReceive},children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),jsxRuntime.jsx("span",{style:e.actionLabel,children:"Receive"})]})]})})}function ke(){return s&&M.length===0?jsxRuntime.jsx("p",{style:e.emptyText,children:"Loading transactions..."}):M.length===0?jsxRuntime.jsx("p",{style:e.emptyText,children:"No transactions yet"}):jsxRuntime.jsx("div",{style:e.txList,children:M.map(o=>jsxRuntime.jsxs("div",{style:e.txRow,children:[jsxRuntime.jsx("div",{style:{...e.txIcon,backgroundColor:o.type==="received"?"rgba(52, 211, 153, 0.15)":"rgba(248, 113, 113, 0.15)"},children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:o.type==="received"?"#34d399":"#f87171",strokeWidth:"2.5",children:o.type==="received"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("polyline",{points:"19 12 12 19 5 12"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),jsxRuntime.jsx("polyline",{points:"5 12 12 5 19 12"})]})})}),jsxRuntime.jsxs("div",{style:e.txDetails,children:[jsxRuntime.jsx("span",{style:e.txType,children:o.type==="received"?"Received":"Sent"}),jsxRuntime.jsxs("span",{style:e.txCounterparty,children:[o.type==="received"?"from ":"to ",q(o.counterparty)]})]}),jsxRuntime.jsxs("div",{style:e.txAmountCol,children:[jsxRuntime.jsxs("span",{style:{...e.txAmount,color:o.type==="received"?"#34d399":"#f87171"},children:[o.type==="received"?"+":"-",parseFloat(o.amount).toLocaleString("en-US",{maximumFractionDigits:2})," ",o.asset]}),jsxRuntime.jsx("span",{style:e.txTime,children:he(o.createdAt)})]})]},o.id))})}function Ce(){let o=[{label:"Email",value:n.email,key:"email"},{label:"Contract ID",value:n.contractId,key:"contract",copy:true},{label:"Stellar Address",value:n.stellarAddress,key:"stellar",copy:true},{label:"Public Key",value:n.publicKey,key:"pubkey",copy:true},{label:"Created",value:new Date(n.createdAt).toLocaleDateString(),key:"created"}];return jsxRuntime.jsx("div",{style:e.fieldList,children:o.map(c=>jsxRuntime.jsxs("div",{style:e.field,children:[jsxRuntime.jsx("span",{style:e.fieldLabel,children:c.label}),c.copy?jsxRuntime.jsx("button",{onClick:()=>re(c.value,c.key),style:{...e.copyBtn,color:j===c.key?"#34d399":"#a5b4fc",borderColor:j===c.key?"#34d399":"#2a2a4a"},children:j===c.key?"Copied!":q(c.value,8,8)}):jsxRuntime.jsx("span",{style:e.fieldValue,children:c.value})]},c.key))})}function Se(){return jsxRuntime.jsxs("div",{style:e.securityTab,children:[jsxRuntime.jsxs("div",{style:e.fieldList,children:[jsxRuntime.jsxs("div",{style:e.field,children:[jsxRuntime.jsx("span",{style:e.fieldLabel,children:"Recovery"}),jsxRuntime.jsx("span",{style:{...e.fieldValue,color:"#34d399"},children:"Protected"})]}),jsxRuntime.jsxs("div",{style:e.field,children:[jsxRuntime.jsx("span",{style:e.fieldLabel,children:"Method"}),jsxRuntime.jsxs("span",{style:e.fieldValue,children:["Google (",n.email,")"]})]}),n.recoverySigners&&n.recoverySigners.length>0&&jsxRuntime.jsxs("div",{style:e.field,children:[jsxRuntime.jsx("span",{style:e.fieldLabel,children:"Signer"}),jsxRuntime.jsx("span",{style:e.fieldValue,children:q(n.recoverySigners[0].publicKey)})]})]}),ee&&jsxRuntime.jsx("p",{style:e.error,children:ee}),jsxRuntime.jsxs("button",{onClick:me,disabled:X,style:{...e.rotateBtn,opacity:X?.5:1},children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M21 2v6h-6"}),jsxRuntime.jsx("path",{d:"M3 12a9 9 0 0 1 15-6.7L21 8"}),jsxRuntime.jsx("path",{d:"M3 22v-6h6"}),jsxRuntime.jsx("path",{d:"M21 12a9 9 0 0 1-15 6.7L3 16"})]}),X?"Rotating...":"Rotate Keys"]}),jsxRuntime.jsxs("button",{onClick:ge,style:e.disconnectBtn,children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),jsxRuntime.jsx("polyline",{points:"16 17 21 12 16 7"}),jsxRuntime.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Disconnect"]})]})}}function ze(l){let n=0;for(let i=0;i<l.length;i++)n=l.charCodeAt(i)+((n<<5)-n);return `hsl(${Math.abs(n)%360}, 65%, 55%)`}var e={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,padding:"1rem",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},panel:{backgroundColor:"#0f0f1e",borderRadius:"20px",border:"1px solid #2a2a4a",width:"100%",maxWidth:"420px",maxHeight:"85vh",display:"flex",flexDirection:"column",overflow:"hidden"},header:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",padding:"1.5rem 1.5rem 1rem",background:"linear-gradient(180deg, #1a1a3a 0%, #0f0f1e 100%)"},closeBtn:{position:"absolute",top:"1rem",right:"1rem",background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},identicon:{width:"48px",height:"48px",borderRadius:"50%",marginBottom:"0.5rem"},headerAddr:{fontFamily:"monospace",fontSize:"0.8rem",color:"#8b8ba7",margin:"0 0 0.25rem"},headerBalance:{fontSize:"1.75rem",fontWeight:700,color:"#ffffff",margin:0},headerCurrency:{fontSize:"0.85rem",fontWeight:500,color:"#8b8ba7"},tabBar:{display:"flex",borderBottom:"1px solid #2a2a4a",padding:"0 0.5rem"},tab:{flex:1,padding:"0.75rem 0.5rem",background:"none",border:"none",borderBottomWidth:"2px",borderBottomStyle:"solid",borderBottomColor:"transparent",color:"#64748b",fontSize:"0.8rem",fontWeight:500,cursor:"pointer",transition:"color 0.2s, border-color 0.2s",borderRadius:0},tabActive:{color:"#e2e8f0",borderBottomColor:"#667eea"},content:{flex:1,overflowY:"auto",padding:"1rem 1.25rem 1.25rem"},walletTab:{display:"flex",flexDirection:"column",gap:"1rem"},actionRow:{display:"flex",gap:"1rem",justifyContent:"center"},actionBtn:{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.5rem",padding:"1.25rem 1.5rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"16px",cursor:"pointer",transition:"border-color 0.2s",flex:1},actionIcon:{width:"44px",height:"44px",borderRadius:"50%",backgroundColor:"rgba(102, 126, 234, 0.15)",display:"flex",alignItems:"center",justifyContent:"center",color:"#667eea"},actionIconReceive:{backgroundColor:"rgba(52, 211, 153, 0.15)",color:"#34d399"},actionLabel:{fontSize:"0.85rem",fontWeight:500,color:"#e2e8f0"},subView:{display:"flex",flexDirection:"column",gap:"0.75rem"},backBtn:{display:"flex",alignItems:"center",gap:"0.25rem",background:"none",border:"none",color:"#8b8ba7",fontSize:"0.8rem",cursor:"pointer",padding:"0 0 0.25rem",width:"fit-content"},formGroup:{display:"flex",flexDirection:"column",gap:"0.3rem"},formLabel:{color:"#8b8ba7",fontSize:"0.75rem",fontWeight:500},formInput:{backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"8px",padding:"0.65rem 0.75rem",color:"#e2e8f0",fontSize:"0.9rem",outline:"none",width:"100%",boxSizing:"border-box",fontFamily:"inherit"},primaryBtn:{backgroundColor:"#667eea",color:"#fff",border:"none",borderRadius:"10px",padding:"0.75rem",fontSize:"0.95rem",fontWeight:600,cursor:"pointer",width:"100%",marginTop:"0.25rem"},error:{color:"#f87171",fontSize:"0.8rem",margin:0,padding:"0.4rem 0.6rem",backgroundColor:"rgba(248, 113, 113, 0.1)",borderRadius:"6px"},centeredCol:{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.5rem",padding:"1rem 0"},receiveIconBig:{width:"64px",height:"64px",borderRadius:"50%",backgroundColor:"rgba(52, 211, 153, 0.15)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"0.25rem"},addressBox:{backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"8px",padding:"0.75rem",width:"100%",marginTop:"0.5rem"},addressText:{fontFamily:"monospace",fontSize:"0.7rem",color:"#a5b4fc",wordBreak:"break-all",lineHeight:1.5},txList:{display:"flex",flexDirection:"column"},txRow:{display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.65rem 0",borderBottom:"1px solid #1a1a2e"},txIcon:{width:"36px",height:"36px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},txDetails:{display:"flex",flexDirection:"column",flex:1,minWidth:0},txType:{color:"#e2e8f0",fontSize:"0.85rem",fontWeight:500},txCounterparty:{color:"#64748b",fontSize:"0.7rem",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},txAmountCol:{display:"flex",flexDirection:"column",alignItems:"flex-end",flexShrink:0},txAmount:{fontSize:"0.85rem",fontWeight:600},txTime:{color:"#64748b",fontSize:"0.65rem"},emptyText:{color:"#64748b",fontSize:"0.85rem",textAlign:"center",padding:"2rem 0"},fieldList:{display:"flex",flexDirection:"column"},field:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.6rem 0",borderBottom:"1px solid #1a1a2e"},fieldLabel:{color:"#8b8ba7",fontSize:"0.8rem"},fieldValue:{color:"#e2e8f0",fontSize:"0.8rem",fontWeight:500},copyBtn:{background:"none",border:"1px solid #2a2a4a",color:"#a5b4fc",padding:"0.2rem 0.5rem",borderRadius:"4px",fontSize:"0.72rem",fontFamily:"monospace",cursor:"pointer",transition:"color 0.2s, border-color 0.2s"},securityTab:{display:"flex",flexDirection:"column",gap:"1rem"},rotateBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.5rem",width:"100%",padding:"0.65rem",backgroundColor:"transparent",color:"#f59e0b",border:"1px solid rgba(245, 158, 11, 0.3)",borderRadius:"10px",fontSize:"0.85rem",fontWeight:600,cursor:"pointer"},disconnectBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.5rem",width:"100%",padding:"0.65rem",backgroundColor:"transparent",color:"#f87171",border:"1px solid rgba(248, 113, 113, 0.2)",borderRadius:"10px",fontSize:"0.85rem",fontWeight:500,cursor:"pointer"}};function Me(){let{wallet:l,balance:n,loading:i,creating:a,connect:p}=E(),[b,u]=react.useState(false),[m,S]=react.useState(false);if(i)return jsxRuntime.jsx("div",{style:v.pillLoading,children:jsxRuntime.jsx("div",{style:v.spinner})});if(!l)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:()=>u(true),style:a?v.pill:v.connectBtn,disabled:a,children:a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:v.spinnerSmall}),jsxRuntime.jsx("span",{style:v.pillText,children:"Creating wallet..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),"Connect Wallet"]})}),b&&jsxRuntime.jsx(le,{onClose:()=>u(false),onConnect:async()=>{u(false),await p();}})]});let d=l.stellarAddress,x=`${d.slice(0,4)}...${d.slice(-4)}`,T=n?`${parseFloat(n).toFixed(2)} XLM`:"--- XLM",w=De(d);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{onClick:()=>S(true),style:v.pill,children:[jsxRuntime.jsx("div",{style:{...v.identicon,backgroundColor:w}}),jsxRuntime.jsx("span",{style:v.pillAddr,children:x}),jsxRuntime.jsx("span",{style:v.divider}),jsxRuntime.jsx("span",{style:v.pillBalance,children:T})]}),m&&jsxRuntime.jsx(de,{onClose:()=>S(false)})]})}function De(l){let n=0;for(let i=0;i<l.length;i++)n=l.charCodeAt(i)+((n<<5)-n);return `hsl(${Math.abs(n)%360}, 65%, 55%)`}var v={connectBtn:{display:"flex",alignItems:"center",gap:"0.6rem",padding:"0.85rem 1.75rem",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",border:"none",borderRadius:"12px",fontSize:"1rem",fontWeight:600,cursor:"pointer",transition:"transform 0.15s, box-shadow 0.15s",boxShadow:"0 4px 15px rgba(102, 126, 234, 0.4)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},pill:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.85rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50px",cursor:"pointer",transition:"border-color 0.2s, box-shadow 0.2s",color:"#e2e8f0",fontSize:"0.85rem",fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},pillLoading:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.5rem 1.5rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50px",height:"42px"},identicon:{width:"24px",height:"24px",borderRadius:"50%",flexShrink:0},pillAddr:{fontFamily:"monospace",fontSize:"0.8rem",color:"#e2e8f0"},divider:{width:"1px",height:"16px",backgroundColor:"#3a3a5a"},pillBalance:{fontSize:"0.8rem",color:"#8b8ba7",fontWeight:500},pillText:{fontSize:"0.8rem",color:"#8b8ba7"},spinner:{width:"20px",height:"20px",border:"2px solid #2a2a4a",borderTop:"2px solid #667eea",borderRadius:"50%",animation:"accesly-spin 1s linear infinite"},spinnerSmall:{width:"16px",height:"16px",border:"2px solid #2a2a4a",borderTop:"2px solid #667eea",borderRadius:"50%",animation:"accesly-spin 1s linear infinite",flexShrink:0}};if(typeof document<"u"){let l="accesly-keyframes";if(!document.getElementById(l)){let n=document.createElement("style");n.id=l,n.textContent=`
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var pe="accesly_auth",Je="https://accesly.vercel.app",E=class extends Error{constructor(n,s){super(n),this.name="AcceslyApiError",this.status=s;}},ne=class{constructor(n,s){this.appId=n,this.baseUrl=s||Je;}setTokens(n){localStorage.setItem(pe,JSON.stringify(n));}getTokens(){let n=localStorage.getItem(pe);if(!n)return null;try{return JSON.parse(n)}catch{return null}}clearTokens(){localStorage.removeItem(pe);}hasSession(){return this.getTokens()!==null}async request(n,s={},r=true){let y=this.getTokens(),S={"Content-Type":"application/json","x-accesly-key":this.appId,...y?{Authorization:`Bearer ${y.accessToken}`}:{}},m=await fetch(`${this.baseUrl}${n}`,{...s,headers:{...S,...s.headers}});if(m.status===401&&r&&y?.refreshToken){if(await this.refreshToken(y.refreshToken))return this.request(n,s,false);throw this.clearTokens(),new Error("Session expired. Please reconnect.")}if(!m.ok){let h=await m.json().catch(()=>({}));throw new E(h.error||h.details||`Request failed: ${m.status}`,m.status)}return m.json()}async refreshToken(n){try{let s=await fetch(`${this.baseUrl}/api/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:n})});if(!s.ok)return !1;let r=await s.json(),y=this.getTokens();return y&&this.setTokens({...y,accessToken:r.accessToken,refreshToken:r.refreshToken,expiresAt:r.expiresAt}),!0}catch{return false}}async getWalletInfo(){return this.request("/api/wallet/info")}async createWallet(){return this.request("/api/wallet/create",{method:"POST"})}async getBalance(){return this.request("/api/wallet/balance")}async sendPayment(n){let s={destination:n.destination,amount:n.amount};return n.memo&&(s.memo=n.memo),n.assetCode&&n.assetCode!=="XLM"&&(s.asset_code=n.assetCode,n.assetIssuer&&(s.asset_issuer=n.assetIssuer)),this.request("/api/wallet/send",{method:"POST",body:JSON.stringify(s)})}async swap(n){return this.request("/api/wallet/swap",{method:"POST",body:JSON.stringify({from_asset:n.fromAsset,to_asset:n.toAsset,amount:n.amount,min_receive:n.minReceive})})}async getTransactions(n=20){return this.request(`/api/wallet/transactions?limit=${n}`)}async rotateKeys(){return this.request("/api/wallet/rotate",{method:"POST"})}async signTransaction(n){return this.request("/api/wallet/sign",{method:"POST",body:JSON.stringify({xdr:n,submit:false})})}async signAndSubmit(n){return this.request("/api/wallet/sign",{method:"POST",body:JSON.stringify({xdr:n,submit:true})})}};function Te(c,n){return new Promise((s,r)=>{let y=window.screenX+(window.innerWidth-450)/2,S=window.screenY+(window.innerHeight-600)/2,m=window.open(`${c}/auth/popup?appId=${n}`,"accesly-auth",`width=450,height=600,left=${y},top=${S},toolbar=no,menubar=no`);if(!m){r(new Error("Failed to open popup. Please allow popups for this site."));return}function h(C){C.origin.includes(new URL(c).host)&&(C.data?.type==="accesly-auth-success"&&(b(),s(C.data.payload)),C.data?.type==="accesly-auth-error"&&(b(),r(new Error(C.data.error||"Authentication failed"))));}let P=setInterval(()=>{m.closed&&(b(),r(new Error("Authentication cancelled")));},500);function b(){window.removeEventListener("message",h),clearInterval(P);}window.addEventListener("message",h);})}var ue=react.createContext(null),Ze="https://accesly.vercel.app";function et({children:c,...n}){let s=n.baseUrl||Ze,r=react.useMemo(()=>new ne(n.appId,s),[n.appId,s]),[y,S]=react.useState(null),[m,h]=react.useState(null),[P,b]=react.useState([]),[C,f]=react.useState(true),[H,W]=react.useState(false),[k,v]=react.useState(null);react.useEffect(()=>{r.hasSession()?L():f(false);},[r]),react.useEffect(()=>{if(!y)return;D();let l=setInterval(D,15e3);return ()=>clearInterval(l)},[y]);async function L(){v(null);try{let l=await r.getWalletInfo();S(l.wallet),n.onConnect?.(l.wallet);}catch(l){if(l instanceof E&&l.status===404){await R();return}l instanceof E&&l.status===401&&(r.clearTokens(),S(null)),v(l.message);}finally{f(false);}}async function R(){W(true),v(null);try{await r.createWallet();let l=await r.getWalletInfo();S(l.wallet),n.onConnect?.(l.wallet);}catch(l){v(l.message);}finally{W(false),f(false);}}async function D(){try{let l=await r.getBalance(),I=l.balances.find(x=>x.asset==="native");h(I?.balance||"0");let Y=l.balances.filter(x=>x.asset!=="native").map(x=>{let[Q,Z]=x.asset.split(":");return {code:Q,issuer:Z,balance:x.balance}});b(Y);}catch{}}let j=react.useCallback(async()=>{v(null);try{let l=await Te(s,n.appId);r.setTokens(l),f(!0),await L();}catch(l){l.message!=="Authentication cancelled"&&v(l.message);}},[s,n.appId,r]),X=react.useCallback(()=>{r.clearTokens(),S(null),h(null),b([]),v(null),n.onDisconnect?.();},[r,n.onDisconnect]),M=react.useCallback(async l=>r.sendPayment(l),[r]),ae=react.useCallback(async l=>r.swap(l),[r]),O=react.useCallback(async()=>r.rotateKeys(),[r]),K=react.useCallback(async(l=20)=>(await r.getTransactions(l)).transactions,[r]),_=react.useCallback(async()=>{await D();},[r]),N=react.useCallback(async()=>{await L();},[r]),J=react.useCallback(async l=>r.signTransaction(l),[r]),V=react.useCallback(async l=>r.signAndSubmit(l),[r]),F={loading:C,creating:H,wallet:y,balance:m,assetBalances:P,error:k,connect:j,disconnect:X,sendPayment:M,swap:ae,rotateKeys:O,getTransactions:K,refreshBalance:_,refreshWallet:N,signTransaction:J,signAndSubmit:V};return jsxRuntime.jsx(ue.Provider,{value:F,children:c})}function G(){let c=react.useContext(ue);if(!c)throw new Error('useAccesly must be used within an <AcceslyProvider>. Wrap your app with <AcceslyProvider appId="acc_xxxxx">.');return c}function Be({onClose:c,onConnect:n}){return jsxRuntime.jsx("div",{style:B.overlay,onClick:c,children:jsxRuntime.jsxs("div",{style:B.modal,onClick:s=>s.stopPropagation(),children:[jsxRuntime.jsx("button",{onClick:c,style:B.closeBtn,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsxRuntime.jsx("div",{style:B.iconWrapper,children:jsxRuntime.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"#667eea",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),jsxRuntime.jsx("h2",{style:B.title,children:"Connect to Accesly"}),jsxRuntime.jsx("p",{style:B.subtitle,children:"Choose how you want to connect"}),jsxRuntime.jsxs("button",{onClick:n,style:B.googleBtn,children:[jsxRuntime.jsxs("svg",{style:B.googleIcon,viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),jsxRuntime.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),jsxRuntime.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),jsxRuntime.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]}),jsxRuntime.jsx("p",{style:B.footer,children:"Powered by Accesly"})]})})}var B={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,padding:"1rem",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},modal:{position:"relative",backgroundColor:"#141428",borderRadius:"20px",border:"1px solid #2a2a4a",padding:"2rem",width:"100%",maxWidth:"380px",textAlign:"center"},closeBtn:{position:"absolute",top:"1rem",right:"1rem",background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},iconWrapper:{width:"56px",height:"56px",borderRadius:"16px",backgroundColor:"rgba(102, 126, 234, 0.1)",border:"1px solid rgba(102, 126, 234, 0.2)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 1rem"},title:{fontSize:"1.3rem",fontWeight:700,color:"#e2e8f0",margin:"0 0 0.25rem"},subtitle:{color:"#64748b",fontSize:"0.85rem",margin:"0 0 1.5rem"},googleBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.75rem",padding:"0.85rem 1.5rem",backgroundColor:"#1a1a2e",color:"#e2e8f0",border:"1px solid #2a2a4a",borderRadius:"12px",fontSize:"0.95rem",fontWeight:500,cursor:"pointer",width:"100%",marginBottom:"1.25rem"},googleIcon:{width:"20px",height:"20px",flexShrink:0},footer:{color:"#475569",fontSize:"0.7rem",margin:0}};var ye=["XLM","USDC","EURC"];function Pe({onClose:c}){let{wallet:n,balance:s,assetBalances:r,disconnect:y,sendPayment:S,swap:m,rotateKeys:h,getTransactions:P,refreshBalance:b,refreshWallet:C}=G(),[f,H]=react.useState("wallet"),[W,k]=react.useState("main"),[v,L]=react.useState(""),[R,D]=react.useState(""),[j,X]=react.useState(""),[M,ae]=react.useState("XLM"),[O,K]=react.useState(false),[_,N]=react.useState(null),[J,V]=react.useState(null),[F,l]=react.useState("USDC"),[I,Y]=react.useState("EURC"),[x,Q]=react.useState(""),[Z,Re]=react.useState("1"),[re,fe]=react.useState(false),[se,ge]=react.useState(null),[he,ie]=react.useState(null),[le,We]=react.useState([]),[Le,be]=react.useState(false),[De,Me]=react.useState(0),[ce,ve]=react.useState(false),[xe,we]=react.useState(null),[ee,Se]=react.useState(null);if(react.useEffect(()=>{if(f!=="activity")return;Ce();let a=setInterval(Ce,15e3);return ()=>clearInterval(a)},[f,De]),!n)return null;async function Ce(){be(true);try{let a=await P(20);We(a);}catch{}finally{be(false);}}async function Fe(){if(!(!v||!R)){K(true),V(null);try{let a=await S({destination:v,amount:R,memo:j||void 0,assetCode:M!=="XLM"?M:void 0});N(a.txHash),b(),Me(i=>i+1);}catch(a){V(a.message);}finally{K(false);}}}function ze(){N(null),L(""),D(""),X(""),V(null),k("main");}async function Ee(){if(x){fe(true),ie(null);try{let a=(parseFloat(x)*(1-parseFloat(Z)/100)).toFixed(7),i=await m({fromAsset:F,toAsset:I,amount:x,minReceive:a});ge(i.txHash),b();}catch(a){ie(a.message);}finally{fe(false);}}}function Ue(){ge(null),Q(""),ie(null),k("main");}async function $e(){if(confirm("This will generate a new keypair and update your contract. Continue?")){ve(true),we(null);try{await h(),await C();}catch(a){we(a.message);}finally{ve(false);}}}function He(){y(),c();}function te(a,i=6,u=6){return a.length<=i+u+3?a:`${a.slice(0,i)}...${a.slice(-u)}`}async function ke(a,i){await navigator.clipboard.writeText(a),Se(i),setTimeout(()=>Se(null),1500);}function Oe(a){let i=Math.floor((Date.now()-new Date(a).getTime())/1e3);return i<60?"just now":i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:i<172800?"yesterday":`${Math.floor(i/86400)}d ago`}let _e=s?parseFloat(s).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):"---",Ve=at(n.stellarAddress),Ge=[{key:"wallet",label:"Wallet"},{key:"activity",label:"Activity"},{key:"account",label:"Account"},{key:"security",label:"Security"}];return jsxRuntime.jsx("div",{style:t.overlay,onClick:c,children:jsxRuntime.jsxs("div",{style:t.panel,onClick:a=>a.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:t.header,children:[jsxRuntime.jsx("button",{onClick:c,style:t.closeBtn,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsxRuntime.jsx("div",{style:{...t.identicon,backgroundColor:Ve}}),jsxRuntime.jsx("p",{style:t.headerAddr,children:te(n.stellarAddress,8,8)}),jsxRuntime.jsxs("p",{style:t.headerBalance,children:[_e," ",jsxRuntime.jsx("span",{style:t.headerCurrency,children:"XLM"})]})]}),jsxRuntime.jsx("div",{style:t.tabBar,children:Ge.map(a=>jsxRuntime.jsx("button",{onClick:()=>{H(a.key),k("main");},style:{...t.tab,...f===a.key?t.tabActive:{}},children:a.label},a.key))}),jsxRuntime.jsxs("div",{style:t.content,children:[f==="wallet"&&qe(),f==="activity"&&je(),f==="account"&&Xe(),f==="security"&&Ke()]})]})});function qe(){if(_)return jsxRuntime.jsxs("div",{style:t.centeredCol,children:[jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"8 12 11 15 16 9"})]}),jsxRuntime.jsx("p",{style:{color:"#34d399",fontWeight:600,margin:"0.5rem 0"},children:"Payment Sent"}),jsxRuntime.jsxs("p",{style:{color:"#64748b",fontSize:"0.75rem",fontFamily:"monospace"},children:[_.slice(0,12),"...",_.slice(-12)]}),jsxRuntime.jsx("button",{onClick:ze,style:t.primaryBtn,children:"Done"})]});if(W==="send")return jsxRuntime.jsxs("div",{style:t.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>k("main"),style:t.backBtn,children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Destination"}),jsxRuntime.jsx("input",{type:"text",placeholder:"G...",value:v,onChange:u=>L(u.target.value),maxLength:56,style:t.formInput})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Asset"}),jsxRuntime.jsxs("select",{value:M,onChange:u=>ae(u.target.value),style:t.formInput,children:[jsxRuntime.jsx("option",{value:"XLM",children:"XLM \u2014 Stellar Lumens"}),jsxRuntime.jsx("option",{value:"USDC",children:"USDC \u2014 USD Coin"}),jsxRuntime.jsx("option",{value:"EURC",children:"EURC \u2014 Euro Coin"})]})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsxs("label",{style:t.formLabel,children:["Amount (",M,")"]}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:R,onChange:u=>D(u.target.value),min:"0.0000001",step:"any",style:t.formInput})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Memo (optional)"}),jsxRuntime.jsx("input",{type:"text",placeholder:"What is this for?",value:j,onChange:u=>X(u.target.value),maxLength:28,style:t.formInput})]}),J&&jsxRuntime.jsx("p",{style:t.error,children:J}),jsxRuntime.jsx("button",{onClick:Fe,disabled:O||!v||!R,style:{...t.primaryBtn,opacity:O||!v||!R?.5:1},children:O?"Sending...":"Send Payment"})]});if(W==="receive")return jsxRuntime.jsxs("div",{style:t.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>k("main"),style:t.backBtn,children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}),jsxRuntime.jsxs("div",{style:t.centeredCol,children:[jsxRuntime.jsx("div",{style:t.receiveIconBig,children:jsxRuntime.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),jsxRuntime.jsx("p",{style:{color:"#e2e8f0",fontWeight:600,fontSize:"1rem",margin:0},children:"Receive XLM"}),jsxRuntime.jsx("p",{style:{color:"#64748b",fontSize:"0.8rem",margin:0,textAlign:"center"},children:"Share your Stellar address to receive payments"}),jsxRuntime.jsx("div",{style:t.addressBox,children:jsxRuntime.jsx("span",{style:t.addressText,children:n.stellarAddress})}),jsxRuntime.jsx("button",{onClick:()=>ke(n.stellarAddress,"receive"),style:t.primaryBtn,children:ee==="receive"?"Copied!":"Copy Address"})]})]});if(W==="swap"){if(se)return jsxRuntime.jsxs("div",{style:t.centeredCol,children:[jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"8 12 11 15 16 9"})]}),jsxRuntime.jsx("p",{style:{color:"#34d399",fontWeight:600,margin:"0.5rem 0"},children:"Swap Complete"}),jsxRuntime.jsxs("p",{style:{color:"#64748b",fontSize:"0.75rem",fontFamily:"monospace"},children:[se.slice(0,12),"...",se.slice(-12)]}),jsxRuntime.jsx("button",{onClick:Ue,style:t.primaryBtn,children:"Done"})]});let u=ye.filter(d=>d!==F);return jsxRuntime.jsxs("div",{style:t.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>k("main"),style:t.backBtn,children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"From"}),jsxRuntime.jsx("select",{value:F,onChange:d=>{let z=d.target.value;l(z),z===I&&Y(ye.find(de=>de!==z));},style:t.formInput,children:ye.filter(d=>d!==I).map(d=>jsxRuntime.jsx("option",{value:d,children:d},d))})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:x,onChange:d=>Q(d.target.value),min:"0.0000001",step:"any",style:t.formInput})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"To"}),jsxRuntime.jsx("select",{value:I,onChange:d=>Y(d.target.value),style:t.formInput,children:u.map(d=>jsxRuntime.jsx("option",{value:d,children:d},d))})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Max Slippage (%)"}),jsxRuntime.jsx("input",{type:"number",placeholder:"1",value:Z,onChange:d=>Re(d.target.value),min:"0.01",max:"50",step:"0.1",style:t.formInput})]}),he&&jsxRuntime.jsx("p",{style:t.error,children:he}),jsxRuntime.jsx("button",{onClick:Ee,disabled:re||!x,style:{...t.primaryBtn,opacity:re||!x?.5:1},children:re?"Swapping...":`Swap ${F} \u2192 ${I}`})]})}let a={USDC:"#2775ca",EURC:"#3c7fc0"},i=["USDC","EURC"];return jsxRuntime.jsxs("div",{style:t.walletTab,children:[jsxRuntime.jsxs("div",{style:t.actionRow,children:[jsxRuntime.jsxs("button",{onClick:()=>k("send"),style:t.actionBtn,children:[jsxRuntime.jsx("div",{style:t.actionIcon,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),jsxRuntime.jsx("polyline",{points:"5 12 12 5 19 12"})]})}),jsxRuntime.jsx("span",{style:t.actionLabel,children:"Send"})]}),jsxRuntime.jsxs("button",{onClick:()=>k("receive"),style:t.actionBtn,children:[jsxRuntime.jsx("div",{style:{...t.actionIcon,...t.actionIconReceive},children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),jsxRuntime.jsx("span",{style:t.actionLabel,children:"Receive"})]}),jsxRuntime.jsxs("button",{onClick:()=>k("swap"),style:t.actionBtn,children:[jsxRuntime.jsx("div",{style:{...t.actionIcon,...t.actionIconSwap},children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("polyline",{points:"17 1 21 5 17 9"}),jsxRuntime.jsx("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),jsxRuntime.jsx("polyline",{points:"7 23 3 19 7 15"}),jsxRuntime.jsx("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"})]})}),jsxRuntime.jsx("span",{style:t.actionLabel,children:"Swap"})]})]}),jsxRuntime.jsx("div",{style:t.assetList,children:i.map(u=>{let d=r.find(Ne=>Ne.code===u),z=d?parseFloat(d.balance):0,de=z===0;return jsxRuntime.jsxs("div",{style:t.assetCard,children:[jsxRuntime.jsx("div",{style:{...t.assetDot,backgroundColor:a[u]||"#667eea"}}),jsxRuntime.jsxs("div",{style:t.assetInfo,children:[jsxRuntime.jsx("span",{style:t.assetCode,children:u}),de&&jsxRuntime.jsxs("span",{style:t.assetHint,children:["Want ",u,"? Use ",jsxRuntime.jsx("strong",{children:"Swap"})," to exchange your XLM."]})]}),jsxRuntime.jsx("span",{style:t.assetBalance,children:z.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})})]},u)})})]})}function je(){return Le&&le.length===0?jsxRuntime.jsx("p",{style:t.emptyText,children:"Loading transactions..."}):le.length===0?jsxRuntime.jsx("p",{style:t.emptyText,children:"No transactions yet"}):jsxRuntime.jsx("div",{style:t.txList,children:le.map(a=>{let i=a.type==="swap",u=i?"rgba(251, 191, 36, 0.15)":a.type==="received"?"rgba(52, 211, 153, 0.15)":"rgba(248, 113, 113, 0.15)",d=i?"#fbbf24":a.type==="received"?"#34d399":"#f87171";return jsxRuntime.jsxs("div",{style:t.txRow,children:[jsxRuntime.jsx("div",{style:{...t.txIcon,backgroundColor:u},children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:d,strokeWidth:"2.5",children:i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("polyline",{points:"17 1 21 5 17 9"}),jsxRuntime.jsx("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),jsxRuntime.jsx("polyline",{points:"7 23 3 19 7 15"}),jsxRuntime.jsx("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"})]}):a.type==="received"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("polyline",{points:"19 12 12 19 5 12"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),jsxRuntime.jsx("polyline",{points:"5 12 12 5 19 12"})]})})}),jsxRuntime.jsxs("div",{style:t.txDetails,children:[jsxRuntime.jsx("span",{style:t.txType,children:i?"Swap":a.type==="received"?"Received":"Sent"}),jsxRuntime.jsx("span",{style:t.txCounterparty,children:i?`${a.fromAsset} \u2192 ${a.asset}`:(a.type==="received"?"from ":"to ")+te(a.counterparty)})]}),jsxRuntime.jsxs("div",{style:t.txAmountCol,children:[jsxRuntime.jsx("span",{style:{...t.txAmount,color:d},children:i?`${parseFloat(a.fromAmount).toLocaleString("en-US",{maximumFractionDigits:4})} \u2192 ${parseFloat(a.amount).toLocaleString("en-US",{maximumFractionDigits:4})}`:`${a.type==="received"?"+":"-"}${parseFloat(a.amount).toLocaleString("en-US",{maximumFractionDigits:2})} ${a.asset}`}),jsxRuntime.jsx("span",{style:t.txTime,children:Oe(a.createdAt)})]})]},a.id)})})}function Xe(){let a=[{label:"Email",value:n.email,key:"email"},{label:"Contract ID",value:n.contractId,key:"contract",copy:true},{label:"Stellar Address",value:n.stellarAddress,key:"stellar",copy:true},{label:"Public Key",value:n.publicKey,key:"pubkey",copy:true},{label:"Created",value:new Date(n.createdAt).toLocaleDateString(),key:"created"}];return jsxRuntime.jsx("div",{style:t.fieldList,children:a.map(i=>jsxRuntime.jsxs("div",{style:t.field,children:[jsxRuntime.jsx("span",{style:t.fieldLabel,children:i.label}),i.copy?jsxRuntime.jsx("button",{onClick:()=>ke(i.value,i.key),style:{...t.copyBtn,color:ee===i.key?"#34d399":"#a5b4fc",borderColor:ee===i.key?"#34d399":"#2a2a4a"},children:ee===i.key?"Copied!":te(i.value,8,8)}):jsxRuntime.jsx("span",{style:t.fieldValue,children:i.value})]},i.key))})}function Ke(){return jsxRuntime.jsxs("div",{style:t.securityTab,children:[jsxRuntime.jsxs("div",{style:t.fieldList,children:[jsxRuntime.jsxs("div",{style:t.field,children:[jsxRuntime.jsx("span",{style:t.fieldLabel,children:"Recovery"}),jsxRuntime.jsx("span",{style:{...t.fieldValue,color:"#34d399"},children:"Protected"})]}),jsxRuntime.jsxs("div",{style:t.field,children:[jsxRuntime.jsx("span",{style:t.fieldLabel,children:"Method"}),jsxRuntime.jsxs("span",{style:t.fieldValue,children:["Google (",n.email,")"]})]}),n.recoverySigners&&n.recoverySigners.length>0&&jsxRuntime.jsxs("div",{style:t.field,children:[jsxRuntime.jsx("span",{style:t.fieldLabel,children:"Signer"}),jsxRuntime.jsx("span",{style:t.fieldValue,children:te(n.recoverySigners[0].publicKey)})]})]}),xe&&jsxRuntime.jsx("p",{style:t.error,children:xe}),jsxRuntime.jsxs("button",{onClick:$e,disabled:ce,style:{...t.rotateBtn,opacity:ce?.5:1},children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M21 2v6h-6"}),jsxRuntime.jsx("path",{d:"M3 12a9 9 0 0 1 15-6.7L21 8"}),jsxRuntime.jsx("path",{d:"M3 22v-6h6"}),jsxRuntime.jsx("path",{d:"M21 12a9 9 0 0 1-15 6.7L3 16"})]}),ce?"Rotating...":"Rotate Keys"]}),jsxRuntime.jsxs("button",{onClick:He,style:t.disconnectBtn,children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),jsxRuntime.jsx("polyline",{points:"16 17 21 12 16 7"}),jsxRuntime.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Disconnect"]})]})}}function at(c){let n=0;for(let s=0;s<c.length;s++)n=c.charCodeAt(s)+((n<<5)-n);return `hsl(${Math.abs(n)%360}, 65%, 55%)`}var t={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,padding:"1rem",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},panel:{backgroundColor:"#0f0f1e",borderRadius:"20px",border:"1px solid #2a2a4a",width:"100%",maxWidth:"420px",maxHeight:"85vh",display:"flex",flexDirection:"column",overflow:"hidden"},header:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",padding:"1.5rem 1.5rem 1rem",background:"linear-gradient(180deg, #1a1a3a 0%, #0f0f1e 100%)"},closeBtn:{position:"absolute",top:"1rem",right:"1rem",background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},identicon:{width:"48px",height:"48px",borderRadius:"50%",marginBottom:"0.5rem"},headerAddr:{fontFamily:"monospace",fontSize:"0.8rem",color:"#8b8ba7",margin:"0 0 0.25rem"},headerBalance:{fontSize:"1.75rem",fontWeight:700,color:"#ffffff",margin:0},headerCurrency:{fontSize:"0.85rem",fontWeight:500,color:"#8b8ba7"},tabBar:{display:"flex",borderBottom:"1px solid #2a2a4a",padding:"0 0.5rem"},tab:{flex:1,padding:"0.75rem 0.5rem",background:"none",border:"none",borderBottomWidth:"2px",borderBottomStyle:"solid",borderBottomColor:"transparent",color:"#64748b",fontSize:"0.8rem",fontWeight:500,cursor:"pointer",transition:"color 0.2s, border-color 0.2s",borderRadius:0},tabActive:{color:"#e2e8f0",borderBottomColor:"#667eea"},content:{flex:1,overflowY:"auto",padding:"1rem 1.25rem 1.25rem"},walletTab:{display:"flex",flexDirection:"column",gap:"1rem"},actionRow:{display:"flex",gap:"1rem",justifyContent:"center"},actionBtn:{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.5rem",padding:"1.25rem 1.5rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"16px",cursor:"pointer",transition:"border-color 0.2s",flex:1},actionIcon:{width:"44px",height:"44px",borderRadius:"50%",backgroundColor:"rgba(102, 126, 234, 0.15)",display:"flex",alignItems:"center",justifyContent:"center",color:"#667eea"},actionIconReceive:{backgroundColor:"rgba(52, 211, 153, 0.15)",color:"#34d399"},actionIconSwap:{backgroundColor:"rgba(251, 191, 36, 0.15)",color:"#fbbf24"},assetList:{display:"flex",flexDirection:"column",gap:"0.5rem"},assetCard:{display:"flex",alignItems:"center",gap:"0.65rem",padding:"0.65rem 0.85rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"12px"},assetDot:{width:"10px",height:"10px",borderRadius:"50%",flexShrink:0},assetInfo:{display:"flex",flexDirection:"column",flex:1},assetCode:{color:"#e2e8f0",fontSize:"0.85rem",fontWeight:600},assetHint:{color:"#64748b",fontSize:"0.68rem",marginTop:"1px"},assetBalance:{color:"#a5b4fc",fontSize:"0.85rem",fontWeight:500,fontFamily:"monospace"},actionLabel:{fontSize:"0.85rem",fontWeight:500,color:"#e2e8f0"},subView:{display:"flex",flexDirection:"column",gap:"0.75rem"},backBtn:{display:"flex",alignItems:"center",gap:"0.25rem",background:"none",border:"none",color:"#8b8ba7",fontSize:"0.8rem",cursor:"pointer",padding:"0 0 0.25rem",width:"fit-content"},formGroup:{display:"flex",flexDirection:"column",gap:"0.3rem"},formLabel:{color:"#8b8ba7",fontSize:"0.75rem",fontWeight:500},formInput:{backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"8px",padding:"0.65rem 0.75rem",color:"#e2e8f0",fontSize:"0.9rem",outline:"none",width:"100%",boxSizing:"border-box",fontFamily:"inherit"},primaryBtn:{backgroundColor:"#667eea",color:"#fff",border:"none",borderRadius:"10px",padding:"0.75rem",fontSize:"0.95rem",fontWeight:600,cursor:"pointer",width:"100%",marginTop:"0.25rem"},error:{color:"#f87171",fontSize:"0.8rem",margin:0,padding:"0.4rem 0.6rem",backgroundColor:"rgba(248, 113, 113, 0.1)",borderRadius:"6px"},centeredCol:{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.5rem",padding:"1rem 0"},receiveIconBig:{width:"64px",height:"64px",borderRadius:"50%",backgroundColor:"rgba(52, 211, 153, 0.15)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"0.25rem"},addressBox:{backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"8px",padding:"0.75rem",width:"100%",marginTop:"0.5rem"},addressText:{fontFamily:"monospace",fontSize:"0.7rem",color:"#a5b4fc",wordBreak:"break-all",lineHeight:1.5},txList:{display:"flex",flexDirection:"column"},txRow:{display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.65rem 0",borderBottom:"1px solid #1a1a2e"},txIcon:{width:"36px",height:"36px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},txDetails:{display:"flex",flexDirection:"column",flex:1,minWidth:0},txType:{color:"#e2e8f0",fontSize:"0.85rem",fontWeight:500},txCounterparty:{color:"#64748b",fontSize:"0.7rem",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},txAmountCol:{display:"flex",flexDirection:"column",alignItems:"flex-end",flexShrink:0},txAmount:{fontSize:"0.85rem",fontWeight:600},txTime:{color:"#64748b",fontSize:"0.65rem"},emptyText:{color:"#64748b",fontSize:"0.85rem",textAlign:"center",padding:"2rem 0"},fieldList:{display:"flex",flexDirection:"column"},field:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.6rem 0",borderBottom:"1px solid #1a1a2e"},fieldLabel:{color:"#8b8ba7",fontSize:"0.8rem"},fieldValue:{color:"#e2e8f0",fontSize:"0.8rem",fontWeight:500},copyBtn:{background:"none",border:"1px solid #2a2a4a",color:"#a5b4fc",padding:"0.2rem 0.5rem",borderRadius:"4px",fontSize:"0.72rem",fontFamily:"monospace",cursor:"pointer",transition:"color 0.2s, border-color 0.2s"},securityTab:{display:"flex",flexDirection:"column",gap:"1rem"},rotateBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.5rem",width:"100%",padding:"0.65rem",backgroundColor:"transparent",color:"#f59e0b",border:"1px solid rgba(245, 158, 11, 0.3)",borderRadius:"10px",fontSize:"0.85rem",fontWeight:600,cursor:"pointer"},disconnectBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.5rem",width:"100%",padding:"0.65rem",backgroundColor:"transparent",color:"#f87171",border:"1px solid rgba(248, 113, 113, 0.2)",borderRadius:"10px",fontSize:"0.85rem",fontWeight:500,cursor:"pointer"}};function rt(){let{wallet:c,balance:n,loading:s,creating:r,connect:y}=G(),[S,m]=react.useState(false),[h,P]=react.useState(false);if(s)return jsxRuntime.jsx("div",{style:T.pillLoading,children:jsxRuntime.jsx("div",{style:T.spinner})});if(!c)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:()=>m(true),style:r?T.pill:T.connectBtn,disabled:r,children:r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:T.spinnerSmall}),jsxRuntime.jsx("span",{style:T.pillText,children:"Creating wallet..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),"Connect Wallet"]})}),S&&jsxRuntime.jsx(Be,{onClose:()=>m(false),onConnect:async()=>{m(false),await y();}})]});let b=c.stellarAddress,C=`${b.slice(0,4)}...${b.slice(-4)}`,f=n?`${parseFloat(n).toFixed(2)} XLM`:"--- XLM",H=st(b);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{onClick:()=>P(true),style:T.pill,children:[jsxRuntime.jsx("div",{style:{...T.identicon,backgroundColor:H}}),jsxRuntime.jsx("span",{style:T.pillAddr,children:C}),jsxRuntime.jsx("span",{style:T.divider}),jsxRuntime.jsx("span",{style:T.pillBalance,children:f})]}),h&&jsxRuntime.jsx(Pe,{onClose:()=>P(false)})]})}function st(c){let n=0;for(let s=0;s<c.length;s++)n=c.charCodeAt(s)+((n<<5)-n);return `hsl(${Math.abs(n)%360}, 65%, 55%)`}var T={connectBtn:{display:"flex",alignItems:"center",gap:"0.6rem",padding:"0.85rem 1.75rem",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",border:"none",borderRadius:"12px",fontSize:"1rem",fontWeight:600,cursor:"pointer",transition:"transform 0.15s, box-shadow 0.15s",boxShadow:"0 4px 15px rgba(102, 126, 234, 0.4)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},pill:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.85rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50px",cursor:"pointer",transition:"border-color 0.2s, box-shadow 0.2s",color:"#e2e8f0",fontSize:"0.85rem",fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},pillLoading:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.5rem 1.5rem",backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50px",height:"42px"},identicon:{width:"24px",height:"24px",borderRadius:"50%",flexShrink:0},pillAddr:{fontFamily:"monospace",fontSize:"0.8rem",color:"#e2e8f0"},divider:{width:"1px",height:"16px",backgroundColor:"#3a3a5a"},pillBalance:{fontSize:"0.8rem",color:"#8b8ba7",fontWeight:500},pillText:{fontSize:"0.8rem",color:"#8b8ba7"},spinner:{width:"20px",height:"20px",border:"2px solid #2a2a4a",borderTop:"2px solid #667eea",borderRadius:"50%",animation:"accesly-spin 1s linear infinite"},spinnerSmall:{width:"16px",height:"16px",border:"2px solid #2a2a4a",borderTop:"2px solid #667eea",borderRadius:"50%",animation:"accesly-spin 1s linear infinite",flexShrink:0}};if(typeof document<"u"){let c="accesly-keyframes";if(!document.getElementById(c)){let n=document.createElement("style");n.id=c,n.textContent=`
|
|
2
2
|
@keyframes accesly-spin {
|
|
3
3
|
to { transform: rotate(360deg); }
|
|
4
4
|
}
|
|
5
|
-
`,document.head.appendChild(n);}}exports.AcceslyProvider=
|
|
5
|
+
`,document.head.appendChild(n);}}exports.AcceslyProvider=et;exports.ConnectButton=rt;exports.useAccesly=G;//# sourceMappingURL=index.js.map
|
|
6
6
|
//# sourceMappingURL=index.js.map
|