accesly 0.2.2 → 0.2.3
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.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var ge="accesly_auth",tt="https://accesly.vercel.app",ee=class extends Error{constructor(n,i){super(n),this.name="AcceslyApiError",this.status=i;}},ie=class{constructor(n,i){this.appId=n,this.baseUrl=i||tt;}setTokens(n){localStorage.setItem(ge,JSON.stringify(n));}getTokens(){let n=localStorage.getItem(ge);if(!n)return null;try{return JSON.parse(n)}catch{return null}}clearTokens(){localStorage.removeItem(ge);}hasSession(){return this.getTokens()!==null}async request(n,i={},r=true){let m=this.getTokens(),k={"Content-Type":"application/json","x-accesly-key":this.appId,...m?{Authorization:`Bearer ${m.accessToken}`}:{}},u=await fetch(`${this.baseUrl}${n}`,{...i,headers:{...k,...i.headers}});if(u.status===401&&r&&m?.refreshToken){if(await this.refreshToken(m.refreshToken))return this.request(n,i,false);throw this.clearTokens(),new Error("Session expired. Please reconnect.")}if(!u.ok){let b=await u.json().catch(()=>({}));throw new ee(b.error||b.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 r=await i.json(),m=this.getTokens();return m&&this.setTokens({...m,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 i={destination:n.destination,amount:n.amount};return n.memo&&(i.memo=n.memo),n.assetCode&&n.assetCode!=="XLM"&&(i.asset_code=n.assetCode,n.assetIssuer&&(i.asset_issuer=n.assetIssuer)),this.request("/api/wallet/send",{method:"POST",body:JSON.stringify(i)})}async estimateSwap(n,i,r){return this.request(`/api/wallet/swap-estimate?from_asset=${n}&to_asset=${i}&amount=${r}`)}async swap(n){let i={from_asset:n.fromAsset,to_asset:n.toAsset,amount:n.amount,min_receive:n.minReceive};return n.path&&(i.path=n.path),this.request("/api/wallet/swap",{method:"POST",body:JSON.stringify(i)})}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(c,n){return new Promise((i,r)=>{let m=window.screenX+(window.innerWidth-450)/2,k=window.screenY+(window.innerHeight-600)/2,u=window.open(`${c}/auth/popup?appId=${n}`,"accesly-auth",`width=450,height=600,left=${m},top=${k},toolbar=no,menubar=no`);if(!u){r(new Error("Failed to open popup. Please allow popups for this site."));return}function b(A){A.origin.includes(new URL(c).host)&&(A.data?.type==="accesly-auth-success"&&(x(),i(A.data.payload)),A.data?.type==="accesly-auth-error"&&(x(),r(new Error(A.data.error||"Authentication failed"))));}let v=setInterval(()=>{u.closed&&(x(),r(new Error("Authentication cancelled")));},500);function x(){window.removeEventListener("message",b),clearInterval(v);}window.addEventListener("message",b);})}var he=react.createContext(null),at="https://accesly.vercel.app";function st({children:c,...n}){let i=n.baseUrl||at,r=react.useMemo(()=>new ie(n.appId,i),[n.appId,i]),[m,k]=react.useState(null),[u,b]=react.useState(null),[v,x]=react.useState([]),[A,w]=react.useState(true),[B,M]=react.useState(false),[h,S]=react.useState(null);react.useEffect(()=>{r.hasSession()?L():w(false);},[r]),react.useEffect(()=>{if(!m)return;U();let o=setInterval(U,15e3);return ()=>clearInterval(o)},[m]);async function L(){S(null);try{let o=await r.getWalletInfo();k(o.wallet),n.onConnect?.(o.wallet);}catch(o){if(o instanceof ee&&o.status===404){await I();return}o instanceof ee&&o.status===401&&(r.clearTokens(),k(null)),S(o.message);}finally{w(false);}}async function I(){M(true),S(null);try{await r.createWallet();let o=await r.getWalletInfo();k(o.wallet),n.onConnect?.(o.wallet);}catch(o){S(o.message);}finally{M(false),w(false);}}async function U(){try{let o=await r.getBalance(),T=o.balances.find(H=>H.asset==="native");b(T?.balance||"0");let F=o.balances.filter(H=>H.asset!=="native").map(H=>{let[ae,ce]=H.asset.split(":");return {code:ae,issuer:ce,balance:H.balance}});x(F);}catch{}}let V=react.useCallback(async()=>{S(null);try{let o=await Ie(i,n.appId);r.setTokens(o),w(!0),await L();}catch(o){o.message!=="Authentication cancelled"&&S(o.message);}},[i,n.appId,r]),j=react.useCallback(()=>{r.clearTokens(),k(null),b(null),x([]),S(null),n.onDisconnect?.();},[r,n.onDisconnect]),$=react.useCallback(async o=>r.sendPayment(o),[r]),G=react.useCallback(async(o,T,F)=>r.estimateSwap(o,T,F),[r]),q=react.useCallback(async o=>r.swap(o),[r]),D=react.useCallback(async()=>r.rotateKeys(),[r]),X=react.useCallback(async(o=20)=>(await r.getTransactions(o)).transactions,[r]),N=react.useCallback(async()=>{await U();},[r]),Y=react.useCallback(async()=>{await L();},[r]),K=react.useCallback(async o=>r.signTransaction(o),[r]),_=react.useCallback(async o=>r.signAndSubmit(o),[r]),Q={loading:A,creating:B,wallet:m,balance:u,assetBalances:v,error:h,connect:V,disconnect:j,sendPayment:$,estimateSwap:G,swap:q,rotateKeys:D,getTransactions:X,refreshBalance:N,refreshWallet:Y,signTransaction:K,signAndSubmit:_};return jsxRuntime.jsx(he.Provider,{value:Q,children:c})}function J(){let c=react.useContext(he);if(!c)throw new Error('useAccesly must be used within an <AcceslyProvider>. Wrap your app with <AcceslyProvider appId="acc_xxxxx">.');return c}function Ee({onClose:c,onConnect:n}){return jsxRuntime.jsx("div",{style:O.overlay,onClick:c,children:jsxRuntime.jsxs("div",{style:O.modal,onClick:i=>i.stopPropagation(),children:[jsxRuntime.jsx("button",{onClick:c,style:O.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:O.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:O.title,children:"Connect to Accesly"}),jsxRuntime.jsx("p",{style:O.subtitle,children:"Choose how you want to connect"}),jsxRuntime.jsxs("button",{onClick:n,style:O.googleBtn,children:[jsxRuntime.jsxs("svg",{style:O.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:O.footer,children:"Powered by Accesly"})]})})}var O={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 be=["XLM","USDC","EURC"];function Me({onClose:c}){let{wallet:n,balance:i,assetBalances:r,disconnect:m,sendPayment:k,swap:u,rotateKeys:b,getTransactions:v,refreshBalance:x,refreshWallet:A}=J(),[w,B]=react.useState("wallet"),[M,h]=react.useState("main"),[S,L]=react.useState(""),[I,U]=react.useState(""),[V,j]=react.useState(""),[$,G]=react.useState("XLM"),[q,D]=react.useState(false),[X,N]=react.useState(null),[Y,K]=react.useState(null),[_,Q]=react.useState("USDC"),[o,T]=react.useState("EURC"),[F,H]=react.useState(""),[ae,ce]=react.useState("1"),[de,xe]=react.useState(false),[pe,we]=react.useState(null),[Se,ue]=react.useState(null),[me,Fe]=react.useState([]),[ze,Ce]=react.useState(false),[Ue,$e]=react.useState(0),[ye,ke]=react.useState(false),[Ae,Te]=react.useState(null),[se,Be]=react.useState(null);if(react.useEffect(()=>{if(w!=="activity")return;Re();let s=setInterval(Re,15e3);return ()=>clearInterval(s)},[w,Ue]),!n)return null;async function Re(){Ce(true);try{let s=await v(20);Fe(s);}catch{}finally{Ce(false);}}async function He(){if(!(!S||!I)){D(true),K(null);try{let s=await k({destination:S,amount:I,memo:V||void 0,assetCode:$!=="XLM"?$:void 0});N(s.txHash),x(),$e(l=>l+1);}catch(s){K(s.message);}finally{D(false);}}}function Oe(){N(null),L(""),U(""),j(""),K(null),h("main");}async function _e(){if(F){xe(true),ue(null);try{let s=(parseFloat(F)*(1-parseFloat(ae)/100)).toFixed(7),l=await u({fromAsset:_,toAsset:o,amount:F,minReceive:s});we(l.txHash),x();}catch(s){ue(s.message);}finally{xe(false);}}}function Ve(){we(null),H(""),ue(null),h("main");}async function je(){if(confirm("This will generate a new keypair and update your contract. Continue?")){ke(true),Te(null);try{await b(),await A();}catch(s){Te(s.message);}finally{ke(false);}}}function Ge(){m(),c();}function re(s,l=6,g=6){return s.length<=l+g+3?s:`${s.slice(0,l)}...${s.slice(-g)}`}async function Pe(s,l){await navigator.clipboard.writeText(s),Be(l),setTimeout(()=>Be(null),1500);}function qe(s){let l=Math.floor((Date.now()-new Date(s).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<172800?"yesterday":`${Math.floor(l/86400)}d ago`}let Xe=i?parseFloat(i).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):"---",Ne=ct(n.stellarAddress),Ke=[{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:s=>s.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:Ne}}),jsxRuntime.jsx("p",{style:t.headerAddr,children:re(n.stellarAddress,8,8)}),jsxRuntime.jsxs("p",{style:t.headerBalance,children:[Xe," ",jsxRuntime.jsx("span",{style:t.headerCurrency,children:"XLM"})]})]}),jsxRuntime.jsx("div",{style:t.tabBar,children:Ke.map(s=>jsxRuntime.jsx("button",{onClick:()=>{B(s.key),h("main");},style:{...t.tab,...w===s.key?t.tabActive:{}},children:s.label},s.key))}),jsxRuntime.jsxs("div",{style:t.content,children:[w==="wallet"&&Je(),w==="activity"&&Ye(),w==="account"&&Qe(),w==="security"&&Ze()]})]})});function Je(){if(X)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:[X.slice(0,12),"...",X.slice(-12)]}),jsxRuntime.jsx("button",{onClick:Oe,style:t.primaryBtn,children:"Done"})]});if(M==="send")return jsxRuntime.jsxs("div",{style:t.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>h("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:S,onChange:g=>L(g.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:$,onChange:g=>G(g.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 (",$,")"]}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:I,onChange:g=>U(g.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:V,onChange:g=>j(g.target.value),maxLength:28,style:t.formInput})]}),Y&&jsxRuntime.jsx("p",{style:t.error,children:Y}),jsxRuntime.jsx("button",{onClick:He,disabled:q||!S||!I,style:{...t.primaryBtn,opacity:q||!S||!I?.5:1},children:q?"Sending...":"Send Payment"})]});if(M==="receive")return jsxRuntime.jsxs("div",{style:t.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>h("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:()=>Pe(n.stellarAddress,"receive"),style:t.primaryBtn,children:se==="receive"?"Copied!":"Copy Address"})]})]});if(M==="swap"){if(pe)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:[pe.slice(0,12),"...",pe.slice(-12)]}),jsxRuntime.jsx("button",{onClick:Ve,style:t.primaryBtn,children:"Done"})]});let g=be.filter(y=>y!==_);return jsxRuntime.jsxs("div",{style:t.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>h("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:_,onChange:y=>{let Z=y.target.value;Q(Z),Z===o&&T(be.find(fe=>fe!==Z));},style:t.formInput,children:be.filter(y=>y!==o).map(y=>jsxRuntime.jsx("option",{value:y,children:y},y))})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:F,onChange:y=>H(y.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:o,onChange:y=>T(y.target.value),style:t.formInput,children:g.map(y=>jsxRuntime.jsx("option",{value:y,children:y},y))})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Max Slippage (%)"}),jsxRuntime.jsx("input",{type:"number",placeholder:"1",value:ae,onChange:y=>ce(y.target.value),min:"0.01",max:"50",step:"0.1",style:t.formInput})]}),Se&&jsxRuntime.jsx("p",{style:t.error,children:Se}),jsxRuntime.jsx("button",{onClick:_e,disabled:de||!F,style:{...t.primaryBtn,opacity:de||!F?.5:1},children:de?"Swapping...":`Swap ${_} \u2192 ${o}`})]})}let s={USDC:"#2775ca",EURC:"#3c7fc0"},l=["USDC","EURC"];return jsxRuntime.jsxs("div",{style:t.walletTab,children:[jsxRuntime.jsxs("div",{style:t.actionRow,children:[jsxRuntime.jsxs("button",{onClick:()=>h("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:()=>h("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:()=>h("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:l.map(g=>{let y=r.find(et=>et.code===g),Z=y?parseFloat(y.balance):0,fe=Z===0;return jsxRuntime.jsxs("div",{style:t.assetCard,children:[jsxRuntime.jsx("div",{style:{...t.assetDot,backgroundColor:s[g]||"#667eea"}}),jsxRuntime.jsxs("div",{style:t.assetInfo,children:[jsxRuntime.jsx("span",{style:t.assetCode,children:g}),fe&&jsxRuntime.jsxs("span",{style:t.assetHint,children:["Want ",g,"? 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})})]},g)})})]})}function Ye(){return ze&&me.length===0?jsxRuntime.jsx("p",{style:t.emptyText,children:"Loading transactions..."}):me.length===0?jsxRuntime.jsx("p",{style:t.emptyText,children:"No transactions yet"}):jsxRuntime.jsx("div",{style:t.txList,children:me.map(s=>{let l=s.type==="swap",g=l?"rgba(251, 191, 36, 0.15)":s.type==="received"?"rgba(52, 211, 153, 0.15)":"rgba(248, 113, 113, 0.15)",y=l?"#fbbf24":s.type==="received"?"#34d399":"#f87171";return jsxRuntime.jsxs("div",{style:t.txRow,children:[jsxRuntime.jsx("div",{style:{...t.txIcon,backgroundColor:g},children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:y,strokeWidth:"2.5",children:l?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"})]}):s.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:l?"Swap":s.type==="received"?"Received":"Sent"}),jsxRuntime.jsx("span",{style:t.txCounterparty,children:l?`${s.fromAsset} \u2192 ${s.asset}`:(s.type==="received"?"from ":"to ")+re(s.counterparty)})]}),jsxRuntime.jsxs("div",{style:t.txAmountCol,children:[jsxRuntime.jsx("span",{style:{...t.txAmount,color:y},children:l?`${parseFloat(s.fromAmount).toLocaleString("en-US",{maximumFractionDigits:4})} \u2192 ${parseFloat(s.amount).toLocaleString("en-US",{maximumFractionDigits:4})}`:`${s.type==="received"?"+":"-"}${parseFloat(s.amount).toLocaleString("en-US",{maximumFractionDigits:2})} ${s.asset}`}),jsxRuntime.jsx("span",{style:t.txTime,children:qe(s.createdAt)})]})]},s.id)})})}function Qe(){let s=[{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:s.map(l=>jsxRuntime.jsxs("div",{style:t.field,children:[jsxRuntime.jsx("span",{style:t.fieldLabel,children:l.label}),l.copy?jsxRuntime.jsx("button",{onClick:()=>Pe(l.value,l.key),style:{...t.copyBtn,color:se===l.key?"#34d399":"#a5b4fc",borderColor:se===l.key?"#34d399":"#2a2a4a"},children:se===l.key?"Copied!":re(l.value,8,8)}):jsxRuntime.jsx("span",{style:t.fieldValue,children:l.value})]},l.key))})}function Ze(){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:re(n.recoverySigners[0].publicKey)})]})]}),Ae&&jsxRuntime.jsx("p",{style:t.error,children:Ae}),jsxRuntime.jsxs("button",{onClick:je,disabled:ye,style:{...t.rotateBtn,opacity:ye?.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"})]}),ye?"Rotating...":"Rotate Keys"]}),jsxRuntime.jsxs("button",{onClick:Ge,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 ct(c){let n=0;for(let i=0;i<c.length;i++)n=c.charCodeAt(i)+((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 dt(){let{wallet:c,balance:n,loading:i,creating:r,connect:m}=J(),[k,u]=react.useState(false),[b,v]=react.useState(false);if(i)return jsxRuntime.jsx("div",{style:E.pillLoading,children:jsxRuntime.jsx("div",{style:E.spinner})});if(!c)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:()=>u(true),style:r?E.pill:E.connectBtn,disabled:r,children:r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:E.spinnerSmall}),jsxRuntime.jsx("span",{style:E.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"]})}),k&&jsxRuntime.jsx(Ee,{onClose:()=>u(false),onConnect:async()=>{u(false),await m();}})]});let x=c.stellarAddress,A=`${x.slice(0,4)}...${x.slice(-4)}`,w=n?`${parseFloat(n).toFixed(2)} XLM`:"--- XLM",B=pt(x);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{onClick:()=>v(true),style:E.pill,children:[jsxRuntime.jsx("div",{style:{...E.identicon,backgroundColor:B}}),jsxRuntime.jsx("span",{style:E.pillAddr,children:A}),jsxRuntime.jsx("span",{style:E.divider}),jsxRuntime.jsx("span",{style:E.pillBalance,children:w})]}),b&&jsxRuntime.jsx(Me,{onClose:()=>v(false)})]})}function pt(c){let n=0;for(let i=0;i<c.length;i++)n=c.charCodeAt(i)+((n<<5)-n);return `hsl(${Math.abs(n)%360}, 65%, 55%)`}var E={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}};var De=["XLM","USDC","EURC"];function yt({onClose:c,onSuccess:n}){let{estimateSwap:i,swap:r}=J(),[m,k]=react.useState("XLM"),[u,b]=react.useState("USDC"),[v,x]=react.useState(""),[A,w]=react.useState("1"),[B,M]=react.useState(null),[h,S]=react.useState(false),[L,I]=react.useState(null),[U,V]=react.useState(false),[j,$]=react.useState(null),[G,q]=react.useState(null),D=react.useRef(null);react.useEffect(()=>{M(null),I(null);let o=parseFloat(v);if(!(!v||isNaN(o)||o<=0||m===u))return S(true),D.current&&clearTimeout(D.current),D.current=setTimeout(async()=>{try{let T=await i(m,u,v);M(T);}catch(T){I(T.message||"Could not get estimate");}finally{S(false);}},600),()=>{D.current&&clearTimeout(D.current);}},[v,m,u]);function X(){k(u),b(m),x(""),M(null),I(null);}function N(){if(!B)return "0.0000001";let o=parseFloat(B.destinationAmount)*(1-parseFloat(A||"1")/100);return Math.max(o,1e-7).toFixed(7)}async function Y(o){if(o.preventDefault(),!!B){V(true),$(null);try{let T=await r({fromAsset:m,toAsset:u,amount:v,minReceive:N(),path:B.path});q(T.txHash),n?.();}catch(T){$(T.message||"Swap failed");}finally{V(false);}}}if(G)return jsxRuntime.jsx("div",{style:d.overlay,onClick:c,children:jsxRuntime.jsxs("div",{style:d.modal,onClick:o=>o.stopPropagation(),children:[jsxRuntime.jsx("div",{style:d.successIcon,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("h2",{style:d.successTitle,children:"Swap Complete"}),jsxRuntime.jsxs("p",{style:d.successHash,children:[G.slice(0,12),"...",G.slice(-12)]}),jsxRuntime.jsx("button",{onClick:c,style:d.primaryBtn,children:"Done"})]})});let K=De.filter(o=>o!==m),_=De.filter(o=>o!==u),Q=!!B&&!h&&!U;return jsxRuntime.jsx("div",{style:d.overlay,onClick:c,children:jsxRuntime.jsxs("div",{style:d.modal,onClick:o=>o.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:d.header,children:[jsxRuntime.jsx("h2",{style:d.title,children:"Swap"}),jsxRuntime.jsx("button",{onClick:c,style:d.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.jsxs("form",{onSubmit:Y,style:d.form,children:[jsxRuntime.jsxs("div",{style:d.group,children:[jsxRuntime.jsx("label",{style:d.label,children:"From"}),jsxRuntime.jsxs("div",{style:d.row,children:[jsxRuntime.jsx("select",{value:m,onChange:o=>k(o.target.value),style:{...d.input,width:"130px",flexShrink:0},children:_.map(o=>jsxRuntime.jsx("option",{value:o,children:o},o))}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:v,onChange:o=>x(o.target.value),required:true,min:"0.0000001",step:"any",style:{...d.input,flex:1}})]})]}),jsxRuntime.jsx("div",{style:d.flipRow,children:jsxRuntime.jsx("button",{type:"button",onClick:X,style:d.flipBtn,title:"Flip assets",children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",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.jsxs("div",{style:d.group,children:[jsxRuntime.jsx("label",{style:d.label,children:"To"}),jsxRuntime.jsx("select",{value:u,onChange:o=>b(o.target.value),style:d.input,children:K.map(o=>jsxRuntime.jsx("option",{value:o,children:o},o))})]}),jsxRuntime.jsxs("div",{style:d.estimateBox,children:[h&&jsxRuntime.jsx("p",{style:d.estimateText,children:"Fetching rate..."}),!h&&B&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("p",{style:d.estimateAmount,children:["\u2248 ",parseFloat(B.destinationAmount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:6})," ",u]}),jsxRuntime.jsxs("p",{style:d.estimateMin,children:["Min received: ",N()," ",u," (after ",A,"% slippage)"]})]}),!h&&L&&jsxRuntime.jsx("p",{style:d.estimateError,children:L}),!h&&!B&&!L&&v&&jsxRuntime.jsx("p",{style:d.estimateText,children:"Enter an amount to see the rate"})]}),jsxRuntime.jsxs("div",{style:d.group,children:[jsxRuntime.jsx("label",{style:d.label,children:"Max Slippage (%)"}),jsxRuntime.jsx("input",{type:"number",value:A,onChange:o=>w(o.target.value),min:"0.1",max:"50",step:"0.1",style:d.input})]}),j&&jsxRuntime.jsx("p",{style:d.error,children:j}),jsxRuntime.jsx("button",{type:"submit",disabled:!Q,style:{...d.primaryBtn,opacity:Q?1:.45},children:U?"Swapping...":h?"Getting rate...":`Swap ${m} \u2192 ${u}`})]})]})})}var d={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},modal:{backgroundColor:"#141428",borderRadius:"16px",border:"1px solid #2a2a4a",padding:"1.75rem",width:"100%",maxWidth:"420px"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.25rem"},title:{fontSize:"1.25rem",fontWeight:600,color:"#e2e8f0",margin:0},closeBtn:{background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},form:{display:"flex",flexDirection:"column",gap:"0.85rem"},group:{display:"flex",flexDirection:"column",gap:"0.3rem"},label:{color:"#8b8ba7",fontSize:"0.78rem",fontWeight:500},row:{display:"flex",gap:"0.5rem"},input:{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"},flipRow:{display:"flex",justifyContent:"center",margin:"-0.1rem 0"},flipBtn:{background:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50%",width:"34px",height:"34px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"#667eea"},estimateBox:{backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"10px",padding:"0.75rem 1rem",minHeight:"54px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"0.2rem"},estimateText:{color:"#64748b",fontSize:"0.82rem",margin:0,textAlign:"center"},estimateAmount:{color:"#e2e8f0",fontSize:"1.1rem",fontWeight:700,margin:0},estimateMin:{color:"#64748b",fontSize:"0.75rem",margin:0},estimateError:{color:"#f87171",fontSize:"0.82rem",margin:0},error:{color:"#f87171",fontSize:"0.85rem",margin:0,padding:"0.45rem 0.65rem",backgroundColor:"rgba(248,113,113,0.1)",borderRadius:"6px"},primaryBtn:{backgroundColor:"#667eea",color:"#fff",border:"none",borderRadius:"10px",padding:"0.8rem",fontSize:"1rem",fontWeight:600,cursor:"pointer",width:"100%"},successIcon:{display:"flex",justifyContent:"center",marginBottom:"1rem"},successTitle:{color:"#34d399",fontSize:"1.25rem",fontWeight:600,textAlign:"center",margin:"0 0 0.5rem"},successHash:{color:"#64748b",fontSize:"0.8rem",fontFamily:"monospace",textAlign:"center",marginBottom:"1.5rem"}};if(typeof document<"u"){let c="accesly-keyframes";if(!document.getElementById(c)){let n=document.createElement("style");n.id=c,n.textContent=`
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var ge="accesly_auth",tt="https://accesly.vercel.app",ee=class extends Error{constructor(n,i){super(n),this.name="AcceslyApiError",this.status=i;}},ie=class{constructor(n,i){this.appId=n,this.baseUrl=i||tt;}setTokens(n){localStorage.setItem(ge,JSON.stringify(n));}getTokens(){let n=localStorage.getItem(ge);if(!n)return null;try{return JSON.parse(n)}catch{return null}}clearTokens(){localStorage.removeItem(ge);}hasSession(){return this.getTokens()!==null}async request(n,i={},r=true){let m=this.getTokens(),k={"Content-Type":"application/json","x-accesly-key":this.appId,...m?{Authorization:`Bearer ${m.accessToken}`}:{}},u=await fetch(`${this.baseUrl}${n}`,{...i,headers:{...k,...i.headers}});if(u.status===401&&r&&m?.refreshToken){if(await this.refreshToken(m.refreshToken))return this.request(n,i,false);throw this.clearTokens(),new Error("Session expired. Please reconnect.")}if(!u.ok){let v=await u.json().catch(()=>({}));throw new ee(v.error||v.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 r=await i.json(),m=this.getTokens();return m&&this.setTokens({...m,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 i={destination:n.destination,amount:n.amount};return n.memo&&(i.memo=n.memo),n.assetCode&&n.assetCode!=="XLM"&&(i.asset_code=n.assetCode,n.assetIssuer&&(i.asset_issuer=n.assetIssuer)),this.request("/api/wallet/send",{method:"POST",body:JSON.stringify(i)})}async estimateSwap(n,i,r){return this.request(`/api/wallet/swap-estimate?from_asset=${n}&to_asset=${i}&amount=${r}`)}async swap(n){let i={from_asset:n.fromAsset,to_asset:n.toAsset,amount:n.amount,min_receive:n.minReceive};return n.path&&(i.path=n.path),this.request("/api/wallet/swap",{method:"POST",body:JSON.stringify(i)})}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(c,n){return new Promise((i,r)=>{let m=window.screenX+(window.innerWidth-450)/2,k=window.screenY+(window.innerHeight-600)/2,u=window.open(`${c}/auth/popup?appId=${n}`,"accesly-auth",`width=450,height=600,left=${m},top=${k},toolbar=no,menubar=no`);if(!u){r(new Error("Failed to open popup. Please allow popups for this site."));return}function v(A){A.origin.includes(new URL(c).host)&&(A.data?.type==="accesly-auth-success"&&(w(),i(A.data.payload)),A.data?.type==="accesly-auth-error"&&(w(),r(new Error(A.data.error||"Authentication failed"))));}let x=setInterval(()=>{u.closed&&(w(),r(new Error("Authentication cancelled")));},500);function w(){window.removeEventListener("message",v),clearInterval(x);}window.addEventListener("message",v);})}var he=react.createContext(null),at="https://accesly.vercel.app";function st({children:c,...n}){let i=n.baseUrl||at,r=react.useMemo(()=>new ie(n.appId,i),[n.appId,i]),[m,k]=react.useState(null),[u,v]=react.useState(null),[x,w]=react.useState([]),[A,S]=react.useState(true),[B,M]=react.useState(false),[h,b]=react.useState(null);react.useEffect(()=>{r.hasSession()?L():S(false);},[r]),react.useEffect(()=>{if(!m)return;U();let o=setInterval(U,15e3);return ()=>clearInterval(o)},[m]);async function L(){b(null);try{let o=await r.getWalletInfo();k(o.wallet),n.onConnect?.(o.wallet);}catch(o){if(o instanceof ee&&o.status===404){await I();return}o instanceof ee&&o.status===401&&(r.clearTokens(),k(null)),b(o.message);}finally{S(false);}}async function I(){M(true),b(null);try{await r.createWallet();let o=await r.getWalletInfo();k(o.wallet),n.onConnect?.(o.wallet);}catch(o){b(o.message);}finally{M(false),S(false);}}async function U(){try{let o=await r.getBalance(),T=o.balances.find(H=>H.asset==="native");v(T?.balance||"0");let F=o.balances.filter(H=>H.asset!=="native").map(H=>{let[ae,ce]=H.asset.split(":");return {code:ae,issuer:ce,balance:H.balance}});w(F);}catch{}}let V=react.useCallback(async()=>{b(null);try{let o=await Ie(i,n.appId);r.setTokens(o),S(!0),await L();}catch(o){o.message!=="Authentication cancelled"&&b(o.message);}},[i,n.appId,r]),j=react.useCallback(()=>{r.clearTokens(),k(null),v(null),w([]),b(null),n.onDisconnect?.();},[r,n.onDisconnect]),$=react.useCallback(async o=>r.sendPayment(o),[r]),G=react.useCallback(async(o,T,F)=>r.estimateSwap(o,T,F),[r]),q=react.useCallback(async o=>r.swap(o),[r]),D=react.useCallback(async()=>r.rotateKeys(),[r]),X=react.useCallback(async(o=20)=>(await r.getTransactions(o)).transactions,[r]),N=react.useCallback(async()=>{await U();},[r]),Y=react.useCallback(async()=>{await L();},[r]),K=react.useCallback(async o=>r.signTransaction(o),[r]),_=react.useCallback(async o=>r.signAndSubmit(o),[r]),Q={loading:A,creating:B,wallet:m,balance:u,assetBalances:x,error:h,connect:V,disconnect:j,sendPayment:$,estimateSwap:G,swap:q,rotateKeys:D,getTransactions:X,refreshBalance:N,refreshWallet:Y,signTransaction:K,signAndSubmit:_};return jsxRuntime.jsx(he.Provider,{value:Q,children:c})}function J(){let c=react.useContext(he);if(!c)throw new Error('useAccesly must be used within an <AcceslyProvider>. Wrap your app with <AcceslyProvider appId="acc_xxxxx">.');return c}function Ee({onClose:c,onConnect:n}){return jsxRuntime.jsx("div",{style:O.overlay,onClick:c,children:jsxRuntime.jsxs("div",{style:O.modal,onClick:i=>i.stopPropagation(),children:[jsxRuntime.jsx("button",{onClick:c,style:O.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:O.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:O.title,children:"Connect to Accesly"}),jsxRuntime.jsx("p",{style:O.subtitle,children:"Choose how you want to connect"}),jsxRuntime.jsxs("button",{onClick:n,style:O.googleBtn,children:[jsxRuntime.jsxs("svg",{style:O.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:O.footer,children:"Powered by Accesly"})]})})}var O={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 be=["XLM","USDC","EURC"];function Me({onClose:c}){let{wallet:n,balance:i,assetBalances:r,disconnect:m,sendPayment:k,swap:u,rotateKeys:v,getTransactions:x,refreshBalance:w,refreshWallet:A}=J(),[S,B]=react.useState("wallet"),[M,h]=react.useState("main"),[b,L]=react.useState(""),[I,U]=react.useState(""),[V,j]=react.useState(""),[$,G]=react.useState("XLM"),[q,D]=react.useState(false),[X,N]=react.useState(null),[Y,K]=react.useState(null),[_,Q]=react.useState("USDC"),[o,T]=react.useState("EURC"),[F,H]=react.useState(""),[ae,ce]=react.useState("1"),[de,xe]=react.useState(false),[pe,we]=react.useState(null),[Se,ue]=react.useState(null),[me,Fe]=react.useState([]),[ze,Ce]=react.useState(false),[Ue,$e]=react.useState(0),[ye,ke]=react.useState(false),[Ae,Te]=react.useState(null),[se,Be]=react.useState(null);if(react.useEffect(()=>{if(S!=="activity")return;Re();let s=setInterval(Re,15e3);return ()=>clearInterval(s)},[S,Ue]),!n)return null;async function Re(){Ce(true);try{let s=await x(20);Fe(s);}catch{}finally{Ce(false);}}async function He(){if(!(!b||!I)){D(true),K(null);try{let s=await k({destination:b,amount:I,memo:V||void 0,assetCode:$!=="XLM"?$:void 0});N(s.txHash),w(),$e(l=>l+1);}catch(s){K(s.message);}finally{D(false);}}}function Oe(){N(null),L(""),U(""),j(""),K(null),h("main");}async function _e(){if(F){xe(true),ue(null);try{let s=(parseFloat(F)*(1-parseFloat(ae)/100)).toFixed(7),l=await u({fromAsset:_,toAsset:o,amount:F,minReceive:s});we(l.txHash),w();}catch(s){ue(s.message);}finally{xe(false);}}}function Ve(){we(null),H(""),ue(null),h("main");}async function je(){if(confirm("This will generate a new keypair and update your contract. Continue?")){ke(true),Te(null);try{await v(),await A();}catch(s){Te(s.message);}finally{ke(false);}}}function Ge(){m(),c();}function re(s,l=6,g=6){return s.length<=l+g+3?s:`${s.slice(0,l)}...${s.slice(-g)}`}async function Pe(s,l){await navigator.clipboard.writeText(s),Be(l),setTimeout(()=>Be(null),1500);}function qe(s){let l=Math.floor((Date.now()-new Date(s).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<172800?"yesterday":`${Math.floor(l/86400)}d ago`}let Xe=i?parseFloat(i).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):"---",Ne=ct(n.stellarAddress),Ke=[{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:s=>s.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:Ne}}),jsxRuntime.jsx("p",{style:t.headerAddr,children:re(n.stellarAddress,8,8)}),jsxRuntime.jsxs("p",{style:t.headerBalance,children:[Xe," ",jsxRuntime.jsx("span",{style:t.headerCurrency,children:"XLM"})]})]}),jsxRuntime.jsx("div",{style:t.tabBar,children:Ke.map(s=>jsxRuntime.jsx("button",{onClick:()=>{B(s.key),h("main");},style:{...t.tab,...S===s.key?t.tabActive:{}},children:s.label},s.key))}),jsxRuntime.jsxs("div",{style:t.content,children:[S==="wallet"&&Je(),S==="activity"&&Ye(),S==="account"&&Qe(),S==="security"&&Ze()]})]})});function Je(){if(X)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:[X.slice(0,12),"...",X.slice(-12)]}),jsxRuntime.jsx("button",{onClick:Oe,style:t.primaryBtn,children:"Done"})]});if(M==="send")return jsxRuntime.jsxs("div",{style:t.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>h("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:b,onChange:g=>L(g.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:$,onChange:g=>G(g.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 (",$,")"]}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:I,onChange:g=>U(g.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:V,onChange:g=>j(g.target.value),maxLength:28,style:t.formInput})]}),Y&&jsxRuntime.jsx("p",{style:t.error,children:Y}),jsxRuntime.jsx("button",{onClick:He,disabled:q||!b||!I,style:{...t.primaryBtn,opacity:q||!b||!I?.5:1},children:q?"Sending...":"Send Payment"})]});if(M==="receive")return jsxRuntime.jsxs("div",{style:t.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>h("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:()=>Pe(n.stellarAddress,"receive"),style:t.primaryBtn,children:se==="receive"?"Copied!":"Copy Address"})]})]});if(M==="swap"){if(pe)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:[pe.slice(0,12),"...",pe.slice(-12)]}),jsxRuntime.jsx("button",{onClick:Ve,style:t.primaryBtn,children:"Done"})]});let g=be.filter(y=>y!==_);return jsxRuntime.jsxs("div",{style:t.subView,children:[jsxRuntime.jsxs("button",{onClick:()=>h("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:_,onChange:y=>{let Z=y.target.value;Q(Z),Z===o&&T(be.find(fe=>fe!==Z));},style:t.formInput,children:be.filter(y=>y!==o).map(y=>jsxRuntime.jsx("option",{value:y,children:y},y))})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:F,onChange:y=>H(y.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:o,onChange:y=>T(y.target.value),style:t.formInput,children:g.map(y=>jsxRuntime.jsx("option",{value:y,children:y},y))})]}),jsxRuntime.jsxs("div",{style:t.formGroup,children:[jsxRuntime.jsx("label",{style:t.formLabel,children:"Max Slippage (%)"}),jsxRuntime.jsx("input",{type:"number",placeholder:"1",value:ae,onChange:y=>ce(y.target.value),min:"0.01",max:"50",step:"0.1",style:t.formInput})]}),Se&&jsxRuntime.jsx("p",{style:t.error,children:Se}),jsxRuntime.jsx("button",{onClick:_e,disabled:de||!F,style:{...t.primaryBtn,opacity:de||!F?.5:1},children:de?"Swapping...":`Swap ${_} \u2192 ${o}`})]})}let s={USDC:"#2775ca",EURC:"#3c7fc0"},l=["USDC","EURC"];return jsxRuntime.jsxs("div",{style:t.walletTab,children:[jsxRuntime.jsxs("div",{style:t.actionRow,children:[jsxRuntime.jsxs("button",{onClick:()=>h("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:()=>h("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:()=>h("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:l.map(g=>{let y=r.find(et=>et.code===g),Z=y?parseFloat(y.balance):0,fe=Z===0;return jsxRuntime.jsxs("div",{style:t.assetCard,children:[jsxRuntime.jsx("div",{style:{...t.assetDot,backgroundColor:s[g]||"#667eea"}}),jsxRuntime.jsxs("div",{style:t.assetInfo,children:[jsxRuntime.jsx("span",{style:t.assetCode,children:g}),fe&&jsxRuntime.jsxs("span",{style:t.assetHint,children:["Want ",g,"? 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})})]},g)})})]})}function Ye(){return ze&&me.length===0?jsxRuntime.jsx("p",{style:t.emptyText,children:"Loading transactions..."}):me.length===0?jsxRuntime.jsx("p",{style:t.emptyText,children:"No transactions yet"}):jsxRuntime.jsx("div",{style:t.txList,children:me.map(s=>{let l=s.type==="swap",g=l?"rgba(251, 191, 36, 0.15)":s.type==="received"?"rgba(52, 211, 153, 0.15)":"rgba(248, 113, 113, 0.15)",y=l?"#fbbf24":s.type==="received"?"#34d399":"#f87171";return jsxRuntime.jsxs("div",{style:t.txRow,children:[jsxRuntime.jsx("div",{style:{...t.txIcon,backgroundColor:g},children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:y,strokeWidth:"2.5",children:l?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"})]}):s.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:l?"Swap":s.type==="received"?"Received":"Sent"}),jsxRuntime.jsx("span",{style:t.txCounterparty,children:l?`${s.fromAsset} \u2192 ${s.asset}`:(s.type==="received"?"from ":"to ")+re(s.counterparty)})]}),jsxRuntime.jsxs("div",{style:t.txAmountCol,children:[jsxRuntime.jsx("span",{style:{...t.txAmount,color:y},children:l?`${parseFloat(s.fromAmount).toLocaleString("en-US",{maximumFractionDigits:4})} \u2192 ${parseFloat(s.amount).toLocaleString("en-US",{maximumFractionDigits:4})}`:`${s.type==="received"?"+":"-"}${parseFloat(s.amount).toLocaleString("en-US",{maximumFractionDigits:2})} ${s.asset}`}),jsxRuntime.jsx("span",{style:t.txTime,children:qe(s.createdAt)})]})]},s.id)})})}function Qe(){let s=[{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:s.map(l=>jsxRuntime.jsxs("div",{style:t.field,children:[jsxRuntime.jsx("span",{style:t.fieldLabel,children:l.label}),l.copy?jsxRuntime.jsx("button",{onClick:()=>Pe(l.value,l.key),style:{...t.copyBtn,color:se===l.key?"#34d399":"#a5b4fc",borderColor:se===l.key?"#34d399":"#2a2a4a"},children:se===l.key?"Copied!":re(l.value,8,8)}):jsxRuntime.jsx("span",{style:t.fieldValue,children:l.value})]},l.key))})}function Ze(){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:re(n.recoverySigners[0].publicKey)})]})]}),Ae&&jsxRuntime.jsx("p",{style:t.error,children:Ae}),jsxRuntime.jsxs("button",{onClick:je,disabled:ye,style:{...t.rotateBtn,opacity:ye?.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"})]}),ye?"Rotating...":"Rotate Keys"]}),jsxRuntime.jsxs("button",{onClick:Ge,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 ct(c){let n=0;for(let i=0;i<c.length;i++)n=c.charCodeAt(i)+((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 dt(){let{wallet:c,balance:n,loading:i,creating:r,connect:m}=J(),[k,u]=react.useState(false),[v,x]=react.useState(false);if(i)return jsxRuntime.jsx("div",{style:E.pillLoading,children:jsxRuntime.jsx("div",{style:E.spinner})});if(!c)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:()=>u(true),style:r?E.pill:E.connectBtn,disabled:r,children:r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:E.spinnerSmall}),jsxRuntime.jsx("span",{style:E.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"]})}),k&&jsxRuntime.jsx(Ee,{onClose:()=>u(false),onConnect:async()=>{u(false),await m();}})]});let w=c.stellarAddress,A=`${w.slice(0,4)}...${w.slice(-4)}`,S=n?`${parseFloat(n).toFixed(2)} XLM`:"--- XLM",B=pt(w);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{onClick:()=>x(true),style:E.pill,children:[jsxRuntime.jsx("div",{style:{...E.identicon,backgroundColor:B}}),jsxRuntime.jsx("span",{style:E.pillAddr,children:A}),jsxRuntime.jsx("span",{style:E.divider}),jsxRuntime.jsx("span",{style:E.pillBalance,children:S})]}),v&&jsxRuntime.jsx(Me,{onClose:()=>x(false)})]})}function pt(c){let n=0;for(let i=0;i<c.length;i++)n=c.charCodeAt(i)+((n<<5)-n);return `hsl(${Math.abs(n)%360}, 65%, 55%)`}var E={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}};var De=["XLM","USDC","EURC"];function yt({onClose:c,onSuccess:n}){let{estimateSwap:i,swap:r}=J(),[m,k]=react.useState("XLM"),[u,v]=react.useState("USDC"),[x,w]=react.useState(""),[A,S]=react.useState("1"),[B,M]=react.useState(null),[h,b]=react.useState(false),[L,I]=react.useState(null),[U,V]=react.useState(false),[j,$]=react.useState(null),[G,q]=react.useState(null),D=react.useRef(null);react.useEffect(()=>{M(null),I(null),b(false);let o=parseFloat(x);if(!(!x||isNaN(o)||o<=0||m===u))return b(true),D.current&&clearTimeout(D.current),D.current=setTimeout(async()=>{try{let T=await i(m,u,x);M(T);}catch(T){I(T.message||"Could not get estimate");}finally{b(false);}},600),()=>{D.current&&clearTimeout(D.current),b(false);}},[x,m,u,i]);function X(){k(u),v(m),w(""),M(null),I(null);}function N(){if(!B)return "0.0000001";let o=parseFloat(B.destinationAmount)*(1-parseFloat(A||"1")/100);return Math.max(o,1e-7).toFixed(7)}async function Y(o){if(o.preventDefault(),!!B){V(true),$(null);try{let T=await r({fromAsset:m,toAsset:u,amount:x,minReceive:N(),path:B.path});q(T.txHash),n?.();}catch(T){$(T.message||"Swap failed");}finally{V(false);}}}if(G)return jsxRuntime.jsx("div",{style:d.overlay,onClick:c,children:jsxRuntime.jsxs("div",{style:d.modal,onClick:o=>o.stopPropagation(),children:[jsxRuntime.jsx("div",{style:d.successIcon,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("h2",{style:d.successTitle,children:"Swap Complete"}),jsxRuntime.jsxs("p",{style:d.successHash,children:[G.slice(0,12),"...",G.slice(-12)]}),jsxRuntime.jsx("button",{onClick:c,style:d.primaryBtn,children:"Done"})]})});let K=De.filter(o=>o!==m),_=De.filter(o=>o!==u),Q=!!B&&!h&&!U;return jsxRuntime.jsx("div",{style:d.overlay,onClick:c,children:jsxRuntime.jsxs("div",{style:d.modal,onClick:o=>o.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:d.header,children:[jsxRuntime.jsx("h2",{style:d.title,children:"Swap"}),jsxRuntime.jsx("button",{onClick:c,style:d.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.jsxs("form",{onSubmit:Y,style:d.form,children:[jsxRuntime.jsxs("div",{style:d.group,children:[jsxRuntime.jsx("label",{style:d.label,children:"From"}),jsxRuntime.jsxs("div",{style:d.row,children:[jsxRuntime.jsx("select",{value:m,onChange:o=>k(o.target.value),style:{...d.input,width:"130px",flexShrink:0},children:_.map(o=>jsxRuntime.jsx("option",{value:o,children:o},o))}),jsxRuntime.jsx("input",{type:"number",placeholder:"0.00",value:x,onChange:o=>w(o.target.value),required:true,min:"0.0000001",step:"any",style:{...d.input,flex:1}})]})]}),jsxRuntime.jsx("div",{style:d.flipRow,children:jsxRuntime.jsx("button",{type:"button",onClick:X,style:d.flipBtn,title:"Flip assets",children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",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.jsxs("div",{style:d.group,children:[jsxRuntime.jsx("label",{style:d.label,children:"To"}),jsxRuntime.jsx("select",{value:u,onChange:o=>v(o.target.value),style:d.input,children:K.map(o=>jsxRuntime.jsx("option",{value:o,children:o},o))})]}),jsxRuntime.jsxs("div",{style:d.estimateBox,children:[h&&jsxRuntime.jsx("p",{style:d.estimateText,children:"Fetching rate..."}),!h&&B&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("p",{style:d.estimateAmount,children:["\u2248 ",parseFloat(B.destinationAmount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:6})," ",u]}),jsxRuntime.jsxs("p",{style:d.estimateMin,children:["Min received: ",N()," ",u," (after ",A,"% slippage)"]})]}),!h&&L&&jsxRuntime.jsx("p",{style:d.estimateError,children:L}),!h&&!B&&!L&&x&&jsxRuntime.jsx("p",{style:d.estimateText,children:"Enter an amount to see the rate"})]}),jsxRuntime.jsxs("div",{style:d.group,children:[jsxRuntime.jsx("label",{style:d.label,children:"Max Slippage (%)"}),jsxRuntime.jsx("input",{type:"number",value:A,onChange:o=>S(o.target.value),min:"0.1",max:"50",step:"0.1",style:d.input})]}),j&&jsxRuntime.jsx("p",{style:d.error,children:j}),jsxRuntime.jsx("button",{type:"submit",disabled:!Q,style:{...d.primaryBtn,opacity:Q?1:.45},children:U?"Swapping...":h?"Getting rate...":`Swap ${m} \u2192 ${u}`})]})]})})}var d={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},modal:{backgroundColor:"#141428",borderRadius:"16px",border:"1px solid #2a2a4a",padding:"1.75rem",width:"100%",maxWidth:"420px"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.25rem"},title:{fontSize:"1.25rem",fontWeight:600,color:"#e2e8f0",margin:0},closeBtn:{background:"none",border:"none",color:"#64748b",cursor:"pointer",padding:"4px"},form:{display:"flex",flexDirection:"column",gap:"0.85rem"},group:{display:"flex",flexDirection:"column",gap:"0.3rem"},label:{color:"#8b8ba7",fontSize:"0.78rem",fontWeight:500},row:{display:"flex",gap:"0.5rem"},input:{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"},flipRow:{display:"flex",justifyContent:"center",margin:"-0.1rem 0"},flipBtn:{background:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"50%",width:"34px",height:"34px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"#667eea"},estimateBox:{backgroundColor:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:"10px",padding:"0.75rem 1rem",minHeight:"54px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"0.2rem"},estimateText:{color:"#64748b",fontSize:"0.82rem",margin:0,textAlign:"center"},estimateAmount:{color:"#e2e8f0",fontSize:"1.1rem",fontWeight:700,margin:0},estimateMin:{color:"#64748b",fontSize:"0.75rem",margin:0},estimateError:{color:"#f87171",fontSize:"0.82rem",margin:0},error:{color:"#f87171",fontSize:"0.85rem",margin:0,padding:"0.45rem 0.65rem",backgroundColor:"rgba(248,113,113,0.1)",borderRadius:"6px"},primaryBtn:{backgroundColor:"#667eea",color:"#fff",border:"none",borderRadius:"10px",padding:"0.8rem",fontSize:"1rem",fontWeight:600,cursor:"pointer",width:"100%"},successIcon:{display:"flex",justifyContent:"center",marginBottom:"1rem"},successTitle:{color:"#34d399",fontSize:"1.25rem",fontWeight:600,textAlign:"center",margin:"0 0 0.5rem"},successHash:{color:"#64748b",fontSize:"0.8rem",fontFamily:"monospace",textAlign:"center",marginBottom:"1.5rem"}};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
|
}
|