@spicenet-io/spiceflow-ui 3.2.2 → 3.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/README.md CHANGED
@@ -57,20 +57,20 @@ function App() {
57
57
  ### Building the Library
58
58
 
59
59
  ```bash
60
- npm run build
60
+ bun run build
61
61
  ```
62
62
 
63
63
  ### Type Checking
64
64
 
65
65
  ```bash
66
- npm run typecheck
66
+ bun run typecheck
67
67
  ```
68
68
 
69
69
  ### Linting
70
70
 
71
71
  ```bash
72
- npm run lint
73
- npm run lint:fix
72
+ bun run lint
73
+ bun run lint:fix
74
74
  ```
75
75
 
76
76
  ## Component Playground
@@ -82,7 +82,7 @@ This repository includes a lightweight React playground app for viewing and test
82
82
  1. Install dependencies (if not already done):
83
83
 
84
84
  ```bash
85
- npm install
85
+ bun install --frozen-lockfile
86
86
  ```
87
87
 
88
88
  2. Navigate to the playground directory:
@@ -94,13 +94,13 @@ This repository includes a lightweight React playground app for viewing and test
94
94
  3. Install playground dependencies:
95
95
 
96
96
  ```bash
97
- npm install
97
+ bun install --frozen-lockfile
98
98
  ```
99
99
 
100
100
  4. Start the development server:
101
101
 
102
102
  ```bash
103
- npm run dev
103
+ bun run dev
104
104
  ```
105
105
 
106
106
  The playground will open automatically at `http://localhost:3000`
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{jsx as C,jsxs as le}from"react/jsx-runtime";import{createContext as j,useEffect as _,useState as A,useCallback as ue,useContext as fe,useMemo as pe,useRef as me}from"react";import{getChainMeta as D,getTokensForChain as he,getDelegateContract as ge,ZERO_ADDRESS as ye,isNativeToken as N,getTokenByAddress as be,getChainIdsByNetwork as we}from"@spicenet-io/spiceflow-core";import{defineChain as xe,createPublicClient as Be,http as $e,isAddress as Ee,getAddress as ve,formatUnits as W}from"viem";import{readContract as Ce}from"viem/actions";class f extends Error{constructor(e,r,a={}){super(r),this.code=e,this.context=a,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,f)}}function Re(t){return t instanceof f}const z=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],Se="0xcA11bde05977b3631167028862bE2a173976CA11",ke={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},Te=new Set([5115]);function Ie(t){const e=ke[t.id]??(Te.has(t.id)?void 0:Se);return xe({id:t.id,name:t.name,nativeCurrency:t.nativeCurrency,rpcUrls:{default:{http:[t.rpcUrl]}},blockExplorers:{default:{name:t.displayName,url:t.blockExplorer}},testnet:t.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const Ue=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],R=Object.fromEntries(Ue.map(t=>D(t)).filter(t=>t!=null).map(t=>[t.id,{...t,viemChain:Ie(t),supportedTokens:he(t.id)}])),_e=R;let Y={};const M=new Map,H=t=>{Y={...t||{}},M.clear()},O=t=>{const e=Y[t];return e&&typeof e=="string"&&e.length>0?e:R[t]?.rpcUrl},E=t=>R[t],S=t=>{const e=D(t);return e?.displayName||e?.name||`Chain ${t}`},Ae=t=>{const e=ge(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e},Ne=(t,e,r)=>{const a=E(t);return a?.blockExplorer?`${a.blockExplorer}/tx/${e}`:"#"},J=t=>{const e=E(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);const r=O(t);if(!r)throw new Error(`No RPC URL configured for chain ID: ${t}`);const a=`${t}:${r}`,s=M.get(a);if(s)return s;const o=Be({chain:e.viemChain,transport:$e(r,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return M.set(a,o),o},Me=()=>{const t={};return Object.values(R).forEach(e=>{t[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:O(e.id)||e.rpcUrl}}),t},Oe=(t,e=[])=>{const r=E(t);if(!r)return[];const a=[];if(![11155111,421614,84532,688689].includes(t)){const o=e.find(i=>i.chainId===t&&i.isNative);o?a.push(o):a.push({address:ye,name:r.nativeCurrency.name,symbol:r.nativeCurrency.symbol,decimals:r.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t})}if(!r.supportedTokens)return a;const s=a.some(o=>o.isNative);return r.supportedTokens.forEach(o=>{if(s&&N(o.address))return;const i=e.find(c=>c.chainId===t&&c.address.toLowerCase()===o.address.toLowerCase());i?a.push(i):a.push({address:o.address,name:o.name,symbol:o.symbol,decimals:o.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:o.logo,isNative:!1,chainId:t})}),a},Pe=async(t,e)=>{const r=E(t);if(!r)throw new Error(`Unsupported chain ID: ${t}`);const a=e.toLowerCase();if(N(a)){if(!r.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return r.nativeCurrency.decimals}if(r.supportedTokens){const s=r.supportedTokens.find(o=>o.address.toLowerCase()===a);if(s)return s.decimals}try{if(!Ee(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const s=ve(e),o=J(t),i=await Ce(o,{address:s,abi:z,functionName:"decimals"});return Number(i)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${t}`)}},G=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",X="__SPICEFLOW_RELAYER_API_URL__";function Fe(t,e){const r=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!r)return e;const[,a,s,o]=r,i=Number(o),c=BigInt(a),l=BigInt(s);let d;for(const u of t.intents){const w=u.chainBatches.find(v=>v.chainId===i);if(w){d=w;break}}const h=d?.tokenTransfers.find(u=>u.from==="escrow"&&u.to.toLowerCase()===t.user.toLowerCase()&&!N(u.token));if(!h)return`Amount is too small to cover the estimated fee on ${S(i)}.`;const p=be(h.token,i),y=p?.decimals??18,b=p?.symbol??"tokens",x=W(c,y),n=W(l,y);return`Amount is too small to cover the estimated fee on ${S(i)}. Amount: ${x} ${b}. Estimated fee: ${n} ${b}.`}function Le(){if(typeof globalThis>"u")return;const t=globalThis[X];return typeof t=="string"&&t.length>0?t:void 0}class je{constructor(){this.baseUrl=G}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[X]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return Le()||this.baseUrl}async createAction(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(a,s)=>typeof s=="bigint"?s.toString():s)});if(!r.ok){const a=await r.text();throw new f("RELAYER_ERROR",`Relayer API error: ${r.status} - ${a}`,{httpStatus:r.status,responseBody:a,endpoint:"/actions"})}return await r.json()}async estimateActionFees(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(s,o)=>typeof o=="bigint"?o.toString():o)}),a=await r.json();if(!r.ok||!a.success||!a.data?.feeEstimate){const s=a.error?.message||`Relayer fee estimate error: ${r.status}`,o=Fe(e,s);throw new f("RELAYER_ERROR",o,{httpStatus:r.status,responseBody:JSON.stringify(a),endpoint:"/actions/fees/estimate"})}return a.data.feeEstimate}async estimateBatchGas(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/gas/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(s,o)=>typeof o=="bigint"?o.toString():o)}),a=await r.json();if(!r.ok||!a.success||!a.data?.gasFee){const s=a.error?.message||`Relayer gas estimate error: ${r.status}`;throw new f("RELAYER_ERROR",s,{httpStatus:r.status,responseBody:JSON.stringify(a),endpoint:"/actions/gas/estimate"})}return{gasFee:BigInt(a.data.gasFee),gasQuoteSource:a.data.gasQuoteSource}}async executeStep(e,r,a,s){const o=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${r}/steps/${a}`,i=fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});let c;try{c=await Promise.race([i,new Promise((l,d)=>setTimeout(()=>d(new f("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:r,stepIndex:a,endpoint:`/actions/${e}/intents/${r}/steps/${a}`})),1e4))])}catch(l){throw l}if(!c.ok){const l=await c.text();throw new f("RELAYER_EXECUTE_ERROR",`Execute step error: ${c.status} - ${l}`,{httpStatus:c.status,responseBody:l,endpoint:`/actions/${e}/intents/${r}/steps/${a}`,actionId:e})}return{success:!0,transactionHash:(await c.json()).transactionHash}}async checkStepStatus(e,r){const a=e.split("/");let s="";if(a.length>=2){const c=a[0],l=a[1];s=`${this.getEffectiveBaseUrl()}/actions/${c}/intents/${l}/steps/${r}`}else s=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${r}`;const o=await fetch(s);if(!o.ok)throw new f("RELAYER_STATUS_ERROR",`Intent step status check failed: ${o.status}`,{httpStatus:o.status,endpoint:s,intentId:e});const i=await o.json();return{success:!0,data:{status:i.status==="error"?"reverted":i.status,transactionHash:i.txid}}}async createWallet(e,r){const a=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok){const s=await a.text();throw new f("RELAYER_ERROR",`Create wallet error: ${a.status} - ${s}`,{httpStatus:a.status,endpoint:`/wallets/${e}`})}return a.json()}async getWallet(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`);if(!r.ok){const a=await r.text();throw new f("RELAYER_ERROR",`Get wallet error: ${r.status} - ${a}`,{httpStatus:r.status,endpoint:`/wallets/${e}`})}return r.json()}async createWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(a,s)=>typeof s=="bigint"?s.toString():s)});if(!r.ok){const a=await r.text();throw new f("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${a}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`);if(!r.ok){const a=await r.text();throw new f("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${a}`,{httpStatus:r.status,endpoint:`/withdrawals/${e}`})}return r.json()}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!e.ok)throw new f("RELAYER_ERROR",`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,endpoint:"/time"});return e.json()}}const g=new je,P=new Map;async function De(t,e){const r=t.toLowerCase(),a=P.get(r);if(a)return a;const s=(async()=>{try{await g.getWallet(t);return}catch{}const{unix_timestamp:o}=await g.getRollupTimestamp(),i=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${t.slice(2).toLowerCase()}. Nonce: ${o}`,c=await e(i),l=typeof c=="string"?c:c.signature;if(!l)throw new Error("Wallet returned no smart wallet signature");await g.createWallet(t,{timestamp:o,signature:l})})();P.set(r,s);try{await s}finally{P.delete(r)}}const We=(t,e)=>{const r=s=>e?e(s):S(s),a=[];return t.forEach((s,o)=>{const i=s.calls&&s.calls.length>0,c=s.tokenTransfers&&s.tokenTransfers.length>0;if(i||c){const l={stepId:o,status:o===0?"processing":"pending",chainId:s.chainId,chainName:r(s.chainId),description:"Processing transaction"};a.push(l)}}),a},q="spiceflow-mode",Q=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(q);return t==="embedded"?"7702":t==="external"?"ondemand":null}catch{return null}},ze=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(q,t==="7702"?"embedded":"external")}catch{}},Ye=()=>Q()!==null,Z=j(null),K=j(null),He=({children:t,provider:e,supportedChainIds:r,network:a="testnet",mode:s="7702",skipFlow:o=[],nativeChainId:i,appName:c="Spicenet",apiUrl:l,theme:d,rpcOverrides:h})=>{_(()=>{if(!l)return;const u=g.getBaseUrl();return g.setBaseUrl(l),()=>g.setBaseUrl(u)},[l]),_(()=>(H(h),()=>H(void 0)),[h]);const p=r??we(a),y=d??null,[b,x]=A(()=>Q()??s),n=ue(u=>{x(u),ze(u)},[]);return C(Z.Provider,{value:y,children:C(K.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:o,mode:b,setMode:n,network:a,nativeChainId:i,appName:c,apiUrl:l,rpcOverrides:h},children:t})})},Je={spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},typography:{fontFamily:'"Helvetica Neue", sans-serif',fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.75rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},shadows:{sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1)"},animation:{fast:"150ms ease-in-out",normal:"200ms ease-in-out",slow:"300ms ease-in-out"}},Ge={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#f3f4f6",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderHover:"#d1d5db",text:"#111827",textSecondary:"#374151",textMuted:"#6b7280",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},Xe={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#171717",background:"#141414",surface:"#1e1e1e",surfaceHover:"#2a2a2a",border:"#2d2d2d",borderHover:"#3a3a3a",text:"#ffffff",textSecondary:"#888888",textMuted:"#666666",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},V=(t="light")=>({mode:t,...Je,colors:t==="light"?Ge:Xe});function k(t,e){const r=t.replace("#",""),a=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-e))),s=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-e))),o=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-e)));return`#${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`}function qe(t,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??k(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??k(e?.shell??"#141414",.55),cardBg:e?.cardBg??"#1e1e1e",inputBg:e?.inputBg??"#171717",hoverBg:e?.hoverBg??"#2a2a2a",textPrimary:e?.textPrimary??"#ffffff",textSecondary:e?.textSecondary??"#888888",inputText:e?.inputText??"#e0e0e0",inputPlaceholder:e?.inputPlaceholder??"#555555",cardBorder:e?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:e?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:e?.buttonBorder??"rgba(255,255,255,0.12)",successBg:e?.successBg??"#0a1f18",successBorder:e?.successBorder??"#1a4a3a",successText:e?.successText??"#6ee7b7",warningBg:e?.warningBg??"#1f1a0d",warningBorder:e?.warningBorder??"#4a3820",warningText:e?.warningText??"#fbbf24",errorBg:e?.errorBg??"#1f0d0d",errorBorder:e?.errorBorder??"#4a2020",errorText:e?.errorText??"#f87171",infoBg:e?.infoBg??"#0d1325",infoBorder:e?.infoBorder??"#2a3a5a",infoText:e?.infoText??"#60a5fa"}}function Qe(t){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#e5e7eb",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fde68a",warningText:"#92400e",errorBg:"#fef2f2",errorBorder:"#fecaca",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function ee(t,e){const r=e?{...t,...e}:t,a=r.dark??!1,s=r.primaryColor,o=r.shell??(a?"#141414":"#ffffff");return{primaryColor:s,dark:a,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:o,shellBorder:k(o,a?.35:.085),shellInnerBorder:k(o,a?.55:.165),card:r.card??(a?"#1e1e1e":"#f9fafb"),input:a?"#171717":"#ffffff",hover:a?"#2a2a2a":"#f3f4f6",text:r.text??(a?"#ffffff":"#111827"),textMuted:r.textMuted??(a?"#888888":"#6b7280"),inputText:a?"#e0e0e0":"#111827",inputPlaceholder:a?"#555555":"#9ca3af",border:r.border??(a?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:a?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:a?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:a?"#0a1f18":"#d1fae5",successBorder:a?"#1a4a3a":"#6ee7b7",successText:a?"#6ee7b7":"#065f46",warningBg:a?"#1f1a0d":"#fef3c7",warningBorder:a?"#4a3820":"#fde68a",warningText:a?"#fbbf24":"#92400e",errorBg:a?"#1f0d0d":"#fef2f2",errorBorder:a?"#4a2020":"#fecaca",errorText:a?"#f87171":"#dc2626",infoBg:a?"#0d1325":"#dbeafe",infoBorder:a?"#2a3a5a":"#93c5fd",infoText:a?"#60a5fa":"#1e40af"}}function te(t,e){const r=fe(Z)??void 0;return pe(()=>{const a=r??{primaryColor:"#EA4B4B"},s={...t?.primaryColor?{primaryColor:t.primaryColor}:{},...t?.fontFamily?{fontFamily:t.fontFamily}:{},...e!==void 0?{dark:e}:{}},o=ee(a,s),{dark:i,primaryColor:c,appName:l}=o,d=V(i?"dark":"light"),h={...d,colors:{...d.colors,primary:c,primaryHover:`${c}dd`},typography:{...d.typography,fontFamily:o.fontFamily}},p={shell:o.shell,shellBorder:o.shellBorder,shellInnerBorder:o.shellInnerBorder,cardBg:o.card,inputBg:o.input,hoverBg:o.hover,textPrimary:o.text,textSecondary:o.textMuted,inputText:o.inputText,inputPlaceholder:o.inputPlaceholder,cardBorder:o.border,inputBorder:o.inputBorder,buttonBorder:o.buttonBorder,successBg:o.successBg,successBorder:o.successBorder,successText:o.successText,warningBg:o.warningBg,warningBorder:o.warningBorder,warningText:o.warningText,errorBg:o.errorBg,errorBorder:o.errorBorder,errorText:o.errorText,infoBg:o.infoBg,infoBorder:o.infoBorder,infoText:o.infoText};return{brand:r,theme:h,dark:i,appName:l,primaryColor:c,dk:p,palette:p}},[r,t,e])}const re="spiceflow-spinner-keyframes";function Ze(){if(typeof document>"u"||document.getElementById(re))return;const t=document.createElement("style");t.id=re,t.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(t)}const ae=({size:t=16,borderWidth:e=2,color:r="currentColor",style:a})=>{const s=me(!1);return _(()=>{s.current||(Ze(),s.current=!0)},[]),C("div",{role:"status","aria-label":"Loading",style:{width:`${t}px`,height:`${t}px`,border:`${e}px solid ${r}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...a}})},Ke=({variant:t="primary",size:e="md",loading:r=!1,fullWidth:a=!1,disabled:s,children:o,className:i="",style:c,theme:l,styles:d,dark:h,...p})=>{const{theme:y,dark:b,palette:x}=te(d,h),n=l||y,u=h??b,[w,v]=A(!1),[T,I]=A(!1),U=u?x.shell:"white",oe=()=>{switch(t){case"primary":return{backgroundColor:d?.button?.backgroundColor||n.colors.primary,color:d?.button?.color||"#ffffff",border:`1px solid ${d?.button?.backgroundColor||n.colors.primary}`};case"secondary":return{backgroundColor:n.colors.secondary,color:n.colors.text,border:`1px solid ${n.colors.border}`};case"success":return{backgroundColor:n.colors.success,color:n.colors.text,border:`1px solid ${n.colors.success}`};case"error":return{backgroundColor:n.colors.error,color:n.colors.text,border:`1px solid ${n.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:n.colors.textSecondary,border:`1px solid ${n.colors.border}`};case"outline":{const m=d?.button?.backgroundColor||n.colors.primary,L=d?.button?.color||(u?"#ffffff":"#0e0d0b"),B=d?.button?.borderColor||(u?`${n.colors.primary}88`:"#0e0d0b"),$=s||r,ie=u?"1px":"1.5px",ce=d?.button?.disabledBackgroundColor||`${m}88`,de=d?.button?.disabledColor||L;return{height:"56px",backgroundColor:$?ce:T?`${m}cc`:w?`${m}ee`:m,color:$?de:L,border:`${ie} solid ${B}`,borderRadius:d?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:$?.78:1,transform:$?"none":T?"scale(0.98)":w?"translateY(-2px)":"none",boxShadow:$?`3px 3px 0px ${U}, 4px 4px 0px ${B}`:T?`2px 2px 0px ${B}`:w?`5px 5px 0px ${U}, 6px 6px 0px ${B}`:`3px 3px 0px ${U}, 4px 4px 0px ${B}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},se=()=>{if(t==="outline")return{};switch(e){case"sm":return{padding:`${n.spacing.sm} ${n.spacing.md}`,fontSize:n.typography.fontSize.sm};case"md":return{padding:`${n.spacing.md} ${n.spacing.lg}`,fontSize:n.typography.fontSize.base};case"lg":return{padding:`${n.spacing.lg} ${n.spacing.xl}`,fontSize:n.typography.fontSize.lg};default:return{}}},ne={borderRadius:d?.button?.borderRadius||n.borderRadius.md,fontWeight:d?.button?.fontWeight||n.typography.fontWeight.medium,fontFamily:d?.button?.fontFamily||n.typography.fontFamily,fontSize:d?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:s||r?"not-allowed":"pointer",opacity:(s||r)&&t!=="outline"?.6:1,width:a?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:n.spacing.sm,...oe(),...se(),...d?.button?.fontSize&&{fontSize:d.button.fontSize}},F=s||r;return le("button",{type:p.type??"button","data-spiceflow-focus":!0,"aria-busy":r||void 0,"aria-disabled":F||void 0,style:{...ne,...c},className:i,disabled:F,onMouseEnter:m=>{v(!0),p.onMouseEnter?.(m)},onMouseLeave:m=>{v(!1),I(!1),p.onMouseLeave?.(m)},onMouseDown:m=>{I(!0),p.onMouseDown?.(m)},onMouseUp:m=>{I(!1),p.onMouseUp?.(m)},...p,children:[r&&C(ae,{size:16}),o]})};export{Ke as B,_e as C,G as R,ae as S,Me as a,J as b,V as c,K as d,De as e,S as f,E as g,Ne as h,Re as i,z as j,Oe as k,O as l,Ae as m,Pe as n,We as o,f as p,Ye as q,g as r,He as s,ee as t,te as u,qe as v,Qe as w};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ "use strict";const v=require("react/jsx-runtime"),h=require("react"),y=require("@spicenet-io/spiceflow-core"),b=require("viem"),ie=require("viem/actions");class f extends Error{constructor(e,r,a={}){super(r),this.code=e,this.context=a,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,f)}}function ce(t){return t instanceof f}const j=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],le="0xcA11bde05977b3631167028862bE2a173976CA11",de={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},ue=new Set([5115]);function fe(t){const e=de[t.id]??(ue.has(t.id)?void 0:le);return b.defineChain({id:t.id,name:t.name,nativeCurrency:t.nativeCurrency,rpcUrls:{default:{http:[t.rpcUrl]}},blockExplorers:{default:{name:t.displayName,url:t.blockExplorer}},testnet:t.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const pe=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],k=Object.fromEntries(pe.map(t=>y.getChainMeta(t)).filter(t=>t!=null).map(t=>[t.id,{...t,viemChain:fe(t),supportedTokens:y.getTokensForChain(t.id)}])),me=k;let D={};const F=new Map,W=t=>{D={...t||{}},F.clear()},M=t=>{const e=D[t];return e&&typeof e=="string"&&e.length>0?e:k[t]?.rpcUrl},R=t=>k[t],I=t=>{const e=y.getChainMeta(t);return e?.displayName||e?.name||`Chain ${t}`},he=t=>{const e=y.getDelegateContract(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e},ge=(t,e,r)=>{const a=R(t);return a?.blockExplorer?`${a.blockExplorer}/tx/${e}`:"#"},Y=t=>{const e=R(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);const r=M(t);if(!r)throw new Error(`No RPC URL configured for chain ID: ${t}`);const a=`${t}:${r}`,n=F.get(a);if(n)return n;const o=b.createPublicClient({chain:e.viemChain,transport:b.http(r,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return F.set(a,o),o},ye=()=>{const t={};return Object.values(k).forEach(e=>{t[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:M(e.id)||e.rpcUrl}}),t},be=(t,e=[])=>{const r=R(t);if(!r)return[];const a=[];if(![11155111,421614,84532,688689].includes(t)){const o=e.find(i=>i.chainId===t&&i.isNative);o?a.push(o):a.push({address:y.ZERO_ADDRESS,name:r.nativeCurrency.name,symbol:r.nativeCurrency.symbol,decimals:r.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t})}if(!r.supportedTokens)return a;const n=a.some(o=>o.isNative);return r.supportedTokens.forEach(o=>{if(n&&y.isNativeToken(o.address))return;const i=e.find(c=>c.chainId===t&&c.address.toLowerCase()===o.address.toLowerCase());i?a.push(i):a.push({address:o.address,name:o.name,symbol:o.symbol,decimals:o.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:o.logo,isNative:!1,chainId:t})}),a},we=async(t,e)=>{const r=R(t);if(!r)throw new Error(`Unsupported chain ID: ${t}`);const a=e.toLowerCase();if(y.isNativeToken(a)){if(!r.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return r.nativeCurrency.decimals}if(r.supportedTokens){const n=r.supportedTokens.find(o=>o.address.toLowerCase()===a);if(n)return n.decimals}try{if(!b.isAddress(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const n=b.getAddress(e),o=Y(t),i=await ie.readContract(o,{address:n,abi:j,functionName:"decimals"});return Number(i)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${t}`)}},z=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",H="__SPICEFLOW_RELAYER_API_URL__";function xe(t,e){const r=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!r)return e;const[,a,n,o]=r,i=Number(o),c=BigInt(a),d=BigInt(n);let l;for(const u of t.intents){const E=u.chainBatches.find(T=>T.chainId===i);if(E){l=E;break}}const g=l?.tokenTransfers.find(u=>u.from==="escrow"&&u.to.toLowerCase()===t.user.toLowerCase()&&!y.isNativeToken(u.token));if(!g)return`Amount is too small to cover the estimated fee on ${I(i)}.`;const p=y.getTokenByAddress(g.token,i),x=p?.decimals??18,B=p?.symbol??"tokens",$=b.formatUnits(c,x),s=b.formatUnits(d,x);return`Amount is too small to cover the estimated fee on ${I(i)}. Amount: ${$} ${B}. Estimated fee: ${s} ${B}.`}function Be(){if(typeof globalThis>"u")return;const t=globalThis[H];return typeof t=="string"&&t.length>0?t:void 0}class Ee{constructor(){this.baseUrl=z}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[H]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return Be()||this.baseUrl}async createAction(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(a,n)=>typeof n=="bigint"?n.toString():n)});if(!r.ok){const a=await r.text();throw new f("RELAYER_ERROR",`Relayer API error: ${r.status} - ${a}`,{httpStatus:r.status,responseBody:a,endpoint:"/actions"})}return await r.json()}async estimateActionFees(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(n,o)=>typeof o=="bigint"?o.toString():o)}),a=await r.json();if(!r.ok||!a.success||!a.data?.feeEstimate){const n=a.error?.message||`Relayer fee estimate error: ${r.status}`,o=xe(e,n);throw new f("RELAYER_ERROR",o,{httpStatus:r.status,responseBody:JSON.stringify(a),endpoint:"/actions/fees/estimate"})}return a.data.feeEstimate}async estimateBatchGas(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/actions/gas/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(n,o)=>typeof o=="bigint"?o.toString():o)}),a=await r.json();if(!r.ok||!a.success||!a.data?.gasFee){const n=a.error?.message||`Relayer gas estimate error: ${r.status}`;throw new f("RELAYER_ERROR",n,{httpStatus:r.status,responseBody:JSON.stringify(a),endpoint:"/actions/gas/estimate"})}return{gasFee:BigInt(a.data.gasFee),gasQuoteSource:a.data.gasQuoteSource}}async executeStep(e,r,a,n){const o=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${r}/steps/${a}`,i=fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});let c;try{c=await Promise.race([i,new Promise((d,l)=>setTimeout(()=>l(new f("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:r,stepIndex:a,endpoint:`/actions/${e}/intents/${r}/steps/${a}`})),1e4))])}catch(d){throw d}if(!c.ok){const d=await c.text();throw new f("RELAYER_EXECUTE_ERROR",`Execute step error: ${c.status} - ${d}`,{httpStatus:c.status,responseBody:d,endpoint:`/actions/${e}/intents/${r}/steps/${a}`,actionId:e})}return{success:!0,transactionHash:(await c.json()).transactionHash}}async checkStepStatus(e,r){const a=e.split("/");let n="";if(a.length>=2){const c=a[0],d=a[1];n=`${this.getEffectiveBaseUrl()}/actions/${c}/intents/${d}/steps/${r}`}else n=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${r}`;const o=await fetch(n);if(!o.ok)throw new f("RELAYER_STATUS_ERROR",`Intent step status check failed: ${o.status}`,{httpStatus:o.status,endpoint:n,intentId:e});const i=await o.json();return{success:!0,data:{status:i.status==="error"?"reverted":i.status,transactionHash:i.txid}}}async createWallet(e,r){const a=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok){const n=await a.text();throw new f("RELAYER_ERROR",`Create wallet error: ${a.status} - ${n}`,{httpStatus:a.status,endpoint:`/wallets/${e}`})}return a.json()}async getWallet(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`);if(!r.ok){const a=await r.text();throw new f("RELAYER_ERROR",`Get wallet error: ${r.status} - ${a}`,{httpStatus:r.status,endpoint:`/wallets/${e}`})}return r.json()}async createWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(a,n)=>typeof n=="bigint"?n.toString():n)});if(!r.ok){const a=await r.text();throw new f("RELAYER_ERROR",`Create withdrawal error: ${r.status} - ${a}`,{httpStatus:r.status,endpoint:"/withdrawals"})}return r.json()}async getWithdrawal(e){const r=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`);if(!r.ok){const a=await r.text();throw new f("RELAYER_ERROR",`Get withdrawal error: ${r.status} - ${a}`,{httpStatus:r.status,endpoint:`/withdrawals/${e}`})}return r.json()}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`);if(!e.ok)throw new f("RELAYER_ERROR",`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,endpoint:"/time"});return e.json()}}const w=new Ee,P=new Map;async function $e(t,e){const r=t.toLowerCase(),a=P.get(r);if(a)return a;const n=(async()=>{try{await w.getWallet(t);return}catch{}const{unix_timestamp:o}=await w.getRollupTimestamp(),i=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${t.slice(2).toLowerCase()}. Nonce: ${o}`,c=await e(i),d=typeof c=="string"?c:c.signature;if(!d)throw new Error("Wallet returned no smart wallet signature");await w.createWallet(t,{timestamp:o,signature:d})})();P.set(r,n);try{await n}finally{P.delete(r)}}const Ce=(t,e)=>{const r=n=>e?e(n):I(n),a=[];return t.forEach((n,o)=>{const i=n.calls&&n.calls.length>0,c=n.tokenTransfers&&n.tokenTransfers.length>0;if(i||c){const d={stepId:o,status:o===0?"processing":"pending",chainId:n.chainId,chainName:r(n.chainId),description:"Processing transaction"};a.push(d)}}),a},J="spiceflow-mode",G=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(J);return t==="embedded"?"7702":t==="external"?"ondemand":null}catch{return null}},Se=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(J,t==="7702"?"embedded":"external")}catch{}},ve=()=>G()!==null,q=h.createContext(null),X=h.createContext(null),Re=({children:t,provider:e,supportedChainIds:r,network:a="testnet",mode:n="7702",skipFlow:o=[],nativeChainId:i,appName:c="Spicenet",apiUrl:d,theme:l,rpcOverrides:g})=>{h.useEffect(()=>{if(!d)return;const u=w.getBaseUrl();return w.setBaseUrl(d),()=>w.setBaseUrl(u)},[d]),h.useEffect(()=>(W(g),()=>W(void 0)),[g]);const p=r??y.getChainIdsByNetwork(a),x=l??null,[B,$]=h.useState(()=>G()??n),s=h.useCallback(u=>{$(u),Se(u)},[]);return v.jsx(q.Provider,{value:x,children:v.jsx(X.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:o,mode:B,setMode:s,network:a,nativeChainId:i,appName:c,apiUrl:d,rpcOverrides:g},children:t})})},Te={spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},typography:{fontFamily:'"Helvetica Neue", sans-serif',fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.75rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},shadows:{sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1)"},animation:{fast:"150ms ease-in-out",normal:"200ms ease-in-out",slow:"300ms ease-in-out"}},ke={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#f3f4f6",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderHover:"#d1d5db",text:"#111827",textSecondary:"#374151",textMuted:"#6b7280",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},Ie={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#171717",background:"#141414",surface:"#1e1e1e",surfaceHover:"#2a2a2a",border:"#2d2d2d",borderHover:"#3a3a3a",text:"#ffffff",textSecondary:"#888888",textMuted:"#666666",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},Q=(t="light")=>({mode:t,...Te,colors:t==="light"?ke:Ie});function U(t,e){const r=t.replace("#",""),a=Math.max(0,Math.round(parseInt(r.substring(0,2),16)*(1-e))),n=Math.max(0,Math.round(parseInt(r.substring(2,4),16)*(1-e))),o=Math.max(0,Math.round(parseInt(r.substring(4,6),16)*(1-e)));return`#${a.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`}function Ue(t,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??U(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??U(e?.shell??"#141414",.55),cardBg:e?.cardBg??"#1e1e1e",inputBg:e?.inputBg??"#171717",hoverBg:e?.hoverBg??"#2a2a2a",textPrimary:e?.textPrimary??"#ffffff",textSecondary:e?.textSecondary??"#888888",inputText:e?.inputText??"#e0e0e0",inputPlaceholder:e?.inputPlaceholder??"#555555",cardBorder:e?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:e?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:e?.buttonBorder??"rgba(255,255,255,0.12)",successBg:e?.successBg??"#0a1f18",successBorder:e?.successBorder??"#1a4a3a",successText:e?.successText??"#6ee7b7",warningBg:e?.warningBg??"#1f1a0d",warningBorder:e?.warningBorder??"#4a3820",warningText:e?.warningText??"#fbbf24",errorBg:e?.errorBg??"#1f0d0d",errorBorder:e?.errorBorder??"#4a2020",errorText:e?.errorText??"#f87171",infoBg:e?.infoBg??"#0d1325",infoBorder:e?.infoBorder??"#2a3a5a",infoText:e?.infoText??"#60a5fa"}}function Ae(t){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#e5e7eb",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fde68a",warningText:"#92400e",errorBg:"#fef2f2",errorBorder:"#fecaca",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function Z(t,e){const r=e?{...t,...e}:t,a=r.dark??!1,n=r.primaryColor,o=r.shell??(a?"#141414":"#ffffff");return{primaryColor:n,dark:a,fontFamily:r.fontFamily??'"Helvetica Neue", sans-serif',appName:r.appName??"Spicenet",logo:r.logo,borderRadius:r.borderRadius??"8px",shell:o,shellBorder:U(o,a?.35:.085),shellInnerBorder:U(o,a?.55:.165),card:r.card??(a?"#1e1e1e":"#f9fafb"),input:a?"#171717":"#ffffff",hover:a?"#2a2a2a":"#f3f4f6",text:r.text??(a?"#ffffff":"#111827"),textMuted:r.textMuted??(a?"#888888":"#6b7280"),inputText:a?"#e0e0e0":"#111827",inputPlaceholder:a?"#555555":"#9ca3af",border:r.border??(a?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:a?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:a?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:a?"#0a1f18":"#d1fae5",successBorder:a?"#1a4a3a":"#6ee7b7",successText:a?"#6ee7b7":"#065f46",warningBg:a?"#1f1a0d":"#fef3c7",warningBorder:a?"#4a3820":"#fde68a",warningText:a?"#fbbf24":"#92400e",errorBg:a?"#1f0d0d":"#fef2f2",errorBorder:a?"#4a2020":"#fecaca",errorText:a?"#f87171":"#dc2626",infoBg:a?"#0d1325":"#dbeafe",infoBorder:a?"#2a3a5a":"#93c5fd",infoText:a?"#60a5fa":"#1e40af"}}function K(t,e){const r=h.useContext(q)??void 0;return h.useMemo(()=>{const a=r??{primaryColor:"#EA4B4B"},n={...t?.primaryColor?{primaryColor:t.primaryColor}:{},...t?.fontFamily?{fontFamily:t.fontFamily}:{},...e!==void 0?{dark:e}:{}},o=Z(a,n),{dark:i,primaryColor:c,appName:d}=o,l=Q(i?"dark":"light"),g={...l,colors:{...l.colors,primary:c,primaryHover:`${c}dd`},typography:{...l.typography,fontFamily:o.fontFamily}},p={shell:o.shell,shellBorder:o.shellBorder,shellInnerBorder:o.shellInnerBorder,cardBg:o.card,inputBg:o.input,hoverBg:o.hover,textPrimary:o.text,textSecondary:o.textMuted,inputText:o.inputText,inputPlaceholder:o.inputPlaceholder,cardBorder:o.border,inputBorder:o.inputBorder,buttonBorder:o.buttonBorder,successBg:o.successBg,successBorder:o.successBorder,successText:o.successText,warningBg:o.warningBg,warningBorder:o.warningBorder,warningText:o.warningText,errorBg:o.errorBg,errorBorder:o.errorBorder,errorText:o.errorText,infoBg:o.infoBg,infoBorder:o.infoBorder,infoText:o.infoText};return{brand:r,theme:g,dark:i,appName:d,primaryColor:c,dk:p,palette:p}},[r,t,e])}const V="spiceflow-spinner-keyframes";function Ne(){if(typeof document>"u"||document.getElementById(V))return;const t=document.createElement("style");t.id=V,t.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(t)}const ee=({size:t=16,borderWidth:e=2,color:r="currentColor",style:a})=>{const n=h.useRef(!1);return h.useEffect(()=>{n.current||(Ne(),n.current=!0)},[]),v.jsx("div",{role:"status","aria-label":"Loading",style:{width:`${t}px`,height:`${t}px`,border:`${e}px solid ${r}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...a}})},_e=({variant:t="primary",size:e="md",loading:r=!1,fullWidth:a=!1,disabled:n,children:o,className:i="",style:c,theme:d,styles:l,dark:g,...p})=>{const{theme:x,dark:B,palette:$}=K(l,g),s=d||x,u=g??B,[E,T]=h.useState(!1),[A,N]=h.useState(!1),_=u?$.shell:"white",te=()=>{switch(t){case"primary":return{backgroundColor:l?.button?.backgroundColor||s.colors.primary,color:l?.button?.color||"#ffffff",border:`1px solid ${l?.button?.backgroundColor||s.colors.primary}`};case"secondary":return{backgroundColor:s.colors.secondary,color:s.colors.text,border:`1px solid ${s.colors.border}`};case"success":return{backgroundColor:s.colors.success,color:s.colors.text,border:`1px solid ${s.colors.success}`};case"error":return{backgroundColor:s.colors.error,color:s.colors.text,border:`1px solid ${s.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:s.colors.textSecondary,border:`1px solid ${s.colors.border}`};case"outline":{const m=l?.button?.backgroundColor||s.colors.primary,L=l?.button?.color||(u?"#ffffff":"#0e0d0b"),C=l?.button?.borderColor||(u?`${s.colors.primary}88`:"#0e0d0b"),S=n||r,oe=u?"1px":"1.5px",ne=l?.button?.disabledBackgroundColor||`${m}88`,se=l?.button?.disabledColor||L;return{height:"56px",backgroundColor:S?ne:A?`${m}cc`:E?`${m}ee`:m,color:S?se:L,border:`${oe} solid ${C}`,borderRadius:l?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:S?.78:1,transform:S?"none":A?"scale(0.98)":E?"translateY(-2px)":"none",boxShadow:S?`3px 3px 0px ${_}, 4px 4px 0px ${C}`:A?`2px 2px 0px ${C}`:E?`5px 5px 0px ${_}, 6px 6px 0px ${C}`:`3px 3px 0px ${_}, 4px 4px 0px ${C}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},re=()=>{if(t==="outline")return{};switch(e){case"sm":return{padding:`${s.spacing.sm} ${s.spacing.md}`,fontSize:s.typography.fontSize.sm};case"md":return{padding:`${s.spacing.md} ${s.spacing.lg}`,fontSize:s.typography.fontSize.base};case"lg":return{padding:`${s.spacing.lg} ${s.spacing.xl}`,fontSize:s.typography.fontSize.lg};default:return{}}},ae={borderRadius:l?.button?.borderRadius||s.borderRadius.md,fontWeight:l?.button?.fontWeight||s.typography.fontWeight.medium,fontFamily:l?.button?.fontFamily||s.typography.fontFamily,fontSize:l?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:n||r?"not-allowed":"pointer",opacity:(n||r)&&t!=="outline"?.6:1,width:a?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:s.spacing.sm,...te(),...re(),...l?.button?.fontSize&&{fontSize:l.button.fontSize}},O=n||r;return v.jsxs("button",{type:p.type??"button","data-spiceflow-focus":!0,"aria-busy":r||void 0,"aria-disabled":O||void 0,style:{...ae,...c},className:i,disabled:O,onMouseEnter:m=>{T(!0),p.onMouseEnter?.(m)},onMouseLeave:m=>{T(!1),N(!1),p.onMouseLeave?.(m)},onMouseDown:m=>{N(!0),p.onMouseDown?.(m)},onMouseUp:m=>{N(!1),p.onMouseUp?.(m)},...p,children:[r&&v.jsx(ee,{size:16}),o]})};exports.Button=_e,exports.CHAIN_CONFIGS=me,exports.RELAYER_API_URL=z,exports.SpiceFlowProvider=Re,exports.SpiceFlowProviderContext=X,exports.SpiceflowError=f,exports.Spinner=ee,exports.buildDarkPalette=Ue,exports.buildLightPalette=Ae,exports.createInitialSteps=Ce,exports.createTheme=Q,exports.ensureSmartWallet=$e,exports.getAllAssetsForChain=be,exports.getChainConfig=R,exports.getChainName=I,exports.getChainsForAssets=ye,exports.getClientForChain=Y,exports.getDelegateContractAddress=he,exports.getExplorerUrl=ge,exports.getRpcUrlForChain=M,exports.getTokenDecimals=we,exports.hasStoredSpiceFlowMode=ve,exports.isSpiceflowError=ce,exports.j=j,exports.relayerService=w,exports.resolveTheme=Z,exports.useSpiceBrand=K;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-B--Fjq1m.js"),W=require("@dynamic-labs/sdk-react-core"),k=require("./providerWallet-cDeDz-zR.js");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions");const q=({onAuthSuccess:a,onAuthError:r,theme:h="light",className:i="",buttonText:o="Login with Dynamic",autoTrigger:l=!1})=>{const s=t.createTheme(h),[m,D]=c.useState(!1),[g,S]=c.useState(!1),w=W.useDynamicContext(),{user:E,primaryWallet:f,connectedWallets:b,handleLogOut:C,setShowAuthFlow:x,sdkHasLoaded:p,showAuthFlow:j}=w,n=(k.getDynamicEmbeddedWallet({connectedWallets:b,primaryWallet:f})||f)?.address,v=!!E,d=v&&!!n;c.useEffect(()=>{D(!0)},[]),c.useEffect(()=>{d&&n&&a&&a(n)},[d,n,a]),c.useEffect(()=>{l&&p&&m&&!d&&!j&&!g&&(S(!0),x(!0))},[l,p,m,d,j,g,x]);const N=()=>{try{x(!0)}catch(y){const u=`Dynamic login failed: ${String(y)}`;r?r(u):console.error(u)}},L=async()=>{try{await C()}catch(y){const u=`Dynamic logout failed: ${String(y)}`;r?r(u):console.error(u)}};return m?p?v&&!n?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):d&&n?e.jsx("div",{className:i,children:e.jsxs(t.Button,{variant:"primary",onClick:L,theme:s,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):l?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",onClick:N,theme:s,children:o})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:"Loading..."})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:o})})};class B extends c.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const F=a=>{const{theme:r="light",className:h="",buttonText:i="Login with Dynamic",onAuthError:o}=a,l=t.createTheme(r);return e.jsx(B,{fallback:e.jsx("div",{className:h,children:e.jsx(t.Button,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:l,children:i})}),children:e.jsx(q,{...a})})};exports.DynamicLogin=F;
2
+ "use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-Hm-OAnzQ.js"),W=require("@dynamic-labs/sdk-react-core"),k=require("./providerWallet-Ca-gOLIW.js");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions");const q=({onAuthSuccess:a,onAuthError:r,theme:h="light",className:i="",buttonText:o="Login with Dynamic",autoTrigger:l=!1})=>{const s=t.createTheme(h),[m,D]=c.useState(!1),[g,S]=c.useState(!1),w=W.useDynamicContext(),{user:E,primaryWallet:f,connectedWallets:b,handleLogOut:C,setShowAuthFlow:x,sdkHasLoaded:p,showAuthFlow:j}=w,n=(k.getDynamicEmbeddedWallet({connectedWallets:b,primaryWallet:f})||f)?.address,v=!!E,d=v&&!!n;c.useEffect(()=>{D(!0)},[]),c.useEffect(()=>{d&&n&&a&&a(n)},[d,n,a]),c.useEffect(()=>{l&&p&&m&&!d&&!j&&!g&&(S(!0),x(!0))},[l,p,m,d,j,g,x]);const N=()=>{try{x(!0)}catch(y){const u=`Dynamic login failed: ${String(y)}`;r?r(u):console.error(u)}},L=async()=>{try{await C()}catch(y){const u=`Dynamic logout failed: ${String(y)}`;r?r(u):console.error(u)}};return m?p?v&&!n?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):d&&n?e.jsx("div",{className:i,children:e.jsxs(t.Button,{variant:"primary",onClick:L,theme:s,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):l?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",onClick:N,theme:s,children:o})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:"Loading..."})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:o})})};class B extends c.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const F=a=>{const{theme:r="light",className:h="",buttonText:i="Login with Dynamic",onAuthError:o}=a,l=t.createTheme(r);return e.jsx(B,{fallback:e.jsx("div",{className:h,children:e.jsx(t.Button,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:l,children:i})}),children:e.jsx(q,{...a})})};exports.DynamicLogin=F;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as N,useEffect as f}from"react";import{B as d,c as S,S as b}from"./Button-dU4UsC56.js";import{useDynamicContext as j}from"@dynamic-labs/sdk-react-core";import{g as z}from"./providerWallet-DDywdl9_.js";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";const M=({onAuthSuccess:a,onAuthError:r,theme:m="light",className:t="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=S(m),[h,C]=N(!1),[x,E]=N(!1),L=j(),{user:W,primaryWallet:v,connectedWallets:k,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=L,n=(z({connectedWallets:k,primaryWallet:v})||v)?.address,w=!!W,l=w&&!!n;return f(()=>{C(!0)},[]),f(()=>{l&&n&&a&&a(n)},[l,n,a]),f(()=>{s&&u&&h&&!l&&!D&&!x&&(E(!0),p(!0))},[s,u,h,l,D,x,p]),h?u?w&&!n?e("div",{className:t,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):l&&n?e("div",{className:t,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:t,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:t,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:o})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class T extends A.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const B=a=>{const{theme:r="light",className:m="",buttonText:t="Login with Dynamic",onAuthError:o}=a,s=S(r);return e(T,{fallback:e("div",{className:m,children:e(d,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:s,children:t})}),children:e(M,{...a})})};export{B as DynamicLogin};
2
+ import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as N,useEffect as f}from"react";import{B as d,c as S,S as b}from"./Button-B1aDv3aK.js";import{useDynamicContext as j}from"@dynamic-labs/sdk-react-core";import{g as z}from"./providerWallet-uz6t-bDC.js";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";const M=({onAuthSuccess:a,onAuthError:r,theme:m="light",className:t="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=S(m),[h,C]=N(!1),[x,E]=N(!1),L=j(),{user:W,primaryWallet:v,connectedWallets:k,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=L,n=(z({connectedWallets:k,primaryWallet:v})||v)?.address,w=!!W,l=w&&!!n;return f(()=>{C(!0)},[]),f(()=>{l&&n&&a&&a(n)},[l,n,a]),f(()=>{s&&u&&h&&!l&&!D&&!x&&(E(!0),p(!0))},[s,u,h,l,D,x,p]),h?u?w&&!n?e("div",{className:t,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):l&&n?e("div",{className:t,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:t,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:t,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;r?r(c):console.error(c)}},theme:i,children:o})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:t,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class T extends A.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const B=a=>{const{theme:r="light",className:m="",buttonText:t="Login with Dynamic",onAuthError:o}=a,s=S(r);return e(T,{fallback:e("div",{className:m,children:e(d,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:s,children:t})}),children:e(M,{...a})})};export{B as DynamicLogin};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const e=require("react/jsx-runtime"),o=require("react"),c=require("./Button-B--Fjq1m.js"),f=require("@privy-io/react-auth");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions");const S=({onAuthSuccess:d,onAuthError:a,theme:v="light",className:l="",buttonText:g="Login with Privy",autoTrigger:h=!1})=>{const u=c.createTheme(v),[m,j]=o.useState(!1),[x,p]=o.useState(!1),{ready:i,authenticated:n,user:r}=f.usePrivy(),{login:L}=f.useLogin(),{logout:b}=f.useLogout();o.useEffect(()=>{j(!0)},[]),o.useEffect(()=>{h&&i&&!n&&m&&!x&&(p(!0),y())},[h,i,n,m,x]),o.useEffect(()=>{if(i&&n&&r&&d){const t=r.wallet?.address||r.email?.address;t&&d(t)}},[i,n,r,d]),o.useEffect(()=>{},[i,n,a]);const y=()=>{try{L()}catch(t){const s=`Login failed: ${String(t)}`;a?a(s):console.error(s)}},q=()=>{try{b()}catch(t){const s=`Logout failed: ${String(t)}`;a?a(s):console.error(s)}};if(!m)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:g})});if(!i)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:"Loading..."})});if(n&&r){const t=r.wallet?.address||r.email?.address,s=t?`${t.slice(0,6)}...${t.slice(-4)}`:"Connected";return e.jsx("div",{className:l,children:e.jsxs(c.Button,{variant:"primary",onClick:q,theme:u,children:["Logout (",s,")"]})})}return h?e.jsx("div",{className:l,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(c.Spinner,{size:40,borderWidth:3,color:"#3b82f6"}),e.jsx("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",onClick:y,theme:u,children:g})})};exports.PrivyLogin=S;
2
+ "use strict";const e=require("react/jsx-runtime"),o=require("react"),c=require("./Button-Hm-OAnzQ.js"),f=require("@privy-io/react-auth");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions");const S=({onAuthSuccess:d,onAuthError:a,theme:v="light",className:l="",buttonText:g="Login with Privy",autoTrigger:h=!1})=>{const u=c.createTheme(v),[m,j]=o.useState(!1),[x,p]=o.useState(!1),{ready:i,authenticated:n,user:r}=f.usePrivy(),{login:L}=f.useLogin(),{logout:b}=f.useLogout();o.useEffect(()=>{j(!0)},[]),o.useEffect(()=>{h&&i&&!n&&m&&!x&&(p(!0),y())},[h,i,n,m,x]),o.useEffect(()=>{if(i&&n&&r&&d){const t=r.wallet?.address||r.email?.address;t&&d(t)}},[i,n,r,d]),o.useEffect(()=>{},[i,n,a]);const y=()=>{try{L()}catch(t){const s=`Login failed: ${String(t)}`;a?a(s):console.error(s)}},q=()=>{try{b()}catch(t){const s=`Logout failed: ${String(t)}`;a?a(s):console.error(s)}};if(!m)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:g})});if(!i)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:"Loading..."})});if(n&&r){const t=r.wallet?.address||r.email?.address,s=t?`${t.slice(0,6)}...${t.slice(-4)}`:"Connected";return e.jsx("div",{className:l,children:e.jsxs(c.Button,{variant:"primary",onClick:q,theme:u,children:["Logout (",s,")"]})})}return h?e.jsx("div",{className:l,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(c.Spinner,{size:40,borderWidth:3,color:"#3b82f6"}),e.jsx("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",onClick:y,theme:u,children:g})})};exports.PrivyLogin=S;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as r,jsxs as y}from"react/jsx-runtime";import{useState as v,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-dU4UsC56.js";import{usePrivy as j,useLogin as w,useLogout as B}from"@privy-io/react-auth";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:g="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=v(!1),[p,b]=v(!1),{ready:o,authenticated:s,user:t}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&o&&!s&&h&&!p&&(b(!0),f())},[u,o,s,h,p]),c(()=>{if(o&&s&&t&&m){const e=t.wallet?.address||t.email?.address;e&&m(e)}},[o,s,t,m]),c(()=>{},[o,s,n]);const f=()=>{try{S()}catch(e){const i=`Login failed: ${String(e)}`;n?n(i):console.error(i)}},C=()=>{try{N()}catch(e){const i=`Logout failed: ${String(e)}`;n?n(i):console.error(i)}};if(!h)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:g})});if(!o)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(s&&t){const e=t.wallet?.address||t.email?.address,i=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:y(d,{variant:"primary",onClick:C,theme:l,children:["Logout (",i,")"]})})}return u?r("div",{className:a,children:y("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r($,{size:40,borderWidth:3,color:"#3b82f6"}),r("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):r("div",{className:a,children:r(d,{variant:"primary",onClick:f,theme:l,children:g})})};export{T as PrivyLogin};
2
+ import{jsx as r,jsxs as y}from"react/jsx-runtime";import{useState as v,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-B1aDv3aK.js";import{usePrivy as j,useLogin as w,useLogout as B}from"@privy-io/react-auth";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:g="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=v(!1),[p,b]=v(!1),{ready:o,authenticated:s,user:t}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&o&&!s&&h&&!p&&(b(!0),f())},[u,o,s,h,p]),c(()=>{if(o&&s&&t&&m){const e=t.wallet?.address||t.email?.address;e&&m(e)}},[o,s,t,m]),c(()=>{},[o,s,n]);const f=()=>{try{S()}catch(e){const i=`Login failed: ${String(e)}`;n?n(i):console.error(i)}},C=()=>{try{N()}catch(e){const i=`Logout failed: ${String(e)}`;n?n(i):console.error(i)}};if(!h)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:g})});if(!o)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(s&&t){const e=t.wallet?.address||t.email?.address,i=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:y(d,{variant:"primary",onClick:C,theme:l,children:["Logout (",i,")"]})})}return u?r("div",{className:a,children:y("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r($,{size:40,borderWidth:3,color:"#3b82f6"}),r("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):r("div",{className:a,children:r(d,{variant:"primary",onClick:f,theme:l,children:g})})};export{T as PrivyLogin};