@spicenet-io/spiceflow-ui 1.10.9 → 1.10.10

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.cjs.js CHANGED
@@ -40,7 +40,7 @@
40
40
  from { transform: rotate(0deg); }
41
41
  to { transform: rotate(360deg); }
42
42
  }
43
- `})]})})},Fo=[{id:"external",label:"External Wallet"},{id:"embedded",label:"Embedded Wallet"}],gs=({withdrawBatches:t,externalWithdrawBatches:o,tokens:r,supportedTokens:n,enableSpiceBalanceUpdate:s=!1,theme:c="light",styles:i,className:d="",withdrawInputHook:g,defaultSelectedAsset:f,filterChains:u,withdrawMode:l="external",onWithdrawModeChange:C,externalWalletAddress:A,embeddedWalletAddress:w,onWithdrawSuccess:k,onWithdrawError:p})=>{const b=de.createTheme(c),y={...b,typography:{...b.typography,fontFamily:i?.fontFamily||b.typography.fontFamily},colors:{...b.colors,primary:i?.primaryColor||b.colors.primary,primaryHover:i?.primaryColor?`${i.primaryColor}dd`:b.colors.primaryHover}},B=Dt(),{isReady:m,isAuthenticated:h,isConnected:x,address:S,provider:F,actions:W}=B,[I,G]=a.useState(()=>f?{asset:f,amount:""}:null),[Y,ee]=a.useState([]),[_,q]=a.useState(!1),[M,T]=a.useState(null),E=a.useMemo(()=>!r||r.length===0?[]:!n||n.length===0?r:r.filter(z=>n.some(oe=>oe.toLowerCase()===z.symbol.toLowerCase())),[r,n]),H=a.useCallback(async()=>{if(!E||E.length===0||!w){ee([]);return}q(!0),T(null);try{const z=await Promise.all(E.map(async oe=>{try{const Fe=await Te(oe.chainId).readContract({address:oe.address,abi:re.erc20Abi,functionName:"balanceOf",args:[w]}),Re=parseFloat(re.formatUnits(Fe,oe.decimals));return{address:oe.address,symbol:oe.symbol,name:oe.name,decimals:oe.decimals,chainId:oe.chainId,balance:Fe,balanceFormatted:Re,balanceUsd:0,isNative:!1,logoURI:oe.logoURI}}catch(Fe){return console.error(`Failed to fetch balance for ${oe.symbol}:`,Fe),{address:oe.address,symbol:oe.symbol,name:oe.name,decimals:oe.decimals,chainId:oe.chainId,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,isNative:!1,logoURI:oe.logoURI}}}));ee(z)}catch(z){console.error("Failed to fetch token balances:",z),T(z instanceof Error?z.message:"Failed to fetch token balances")}finally{q(!1)}},[E,w]);a.useEffect(()=>{H()},[H]),a.useEffect(()=>{if(!E||E.length===0)return;const z=setInterval(()=>{H()},3e4);return()=>clearInterval(z)},[H,E]),Y.some(z=>z.balanceFormatted>0);const[X,se]=a.useState(!1),[U,te]=a.useState(null),[xe,he]=a.useState(!1),[Se,R]=a.useState(!1),[P,ie]=a.useState(!1),[v,Z]=a.useState(l),[K,ae]=a.useState(null),[ne,J]=a.useState(null),ue=a.useRef(null),Ie=a.useMemo(()=>v==="external"?A:w,[v,A,w]),N=a.useCallback(z=>{Z(z),C?.(z)},[C]),{intentStatus:O,startStatusPolling:ye,clearStatus:be}=St({checkStepStatus:(z,oe)=>we.checkStepStatus(z,oe)});a.useEffect(()=>{if(O?.overallStatus==="success"&&O.intentId&&ue.current!==O.intentId&&I&&S){const z=O.steps.find(oe=>oe.transactionHash);if(z?.transactionHash)if(ue.current=O.intentId,s){const oe=re.parseUnits(I.amount,I.asset.decimals);we.submitSpiceDeposit({user:S,txHash:z.transactionHash,sender:S,tokenAddress:I.asset.address,chainId:I.asset.chainId,amount:oe.toString(),isDeposit:!1}).then(()=>{H()}).catch(()=>{ue.current=null})}else H()}},[O,S,s]),a.useEffect(()=>{g&&g.assetAmount!==I?.amount&&I&&G({...I,amount:g.assetAmount})},[g?.assetAmount,I]);const je=a.useCallback(()=>{te(null)},[]),Be=z=>{G({asset:z,amount:I?.amount||""}),je()},ke=a.useCallback(z=>{I&&(a.startTransition(()=>{G({...I,amount:z}),je()}),g&&g.setAssetAmount(z))},[I,g,je]),ce=async()=>{if(!(!I||!S||t.length===0)){if(!Ie){te(`Please provide a ${v==="external"?"external":"embedded"} wallet address`);return}if(!m||!h){te(`Please authenticate with ${F||"wallet provider"} to continue`);return}se(!0),te(null),ie(!0);try{const z=v==="external"&&o?[...t,...o]:[...t],oe=[...new Set(z.map(pe=>pe.chainId))],Fe=[];for(const pe of oe){const qe=Te(pe),rt=pt(pe),et=await Ne.getAccountNonce(S,qe),Ge=await W.signAuthorization({contractAddress:rt,chainId:pe,nonce:Number(et)});Fe.push(Ge)}const Re=Ne.hashChainBatches(z),Ze=Math.floor(Date.now()/1e3)+60*10,ot=Ne.getIntentHash(0n,BigInt(Ze),Re),$e=await W.signMessage({raw:ot}),nt=typeof $e=="string"?$e:$e.signature;if(!nt)throw new Error("Failed to sign intent authorization");const _e={mode:"7702",signatureType:"ecdsa",signature:nt,nbf:0,exp:Ze,chainBatches:Re.map(pe=>({hash:pe.hash,chainId:pe.chainId,tokenTransfers:[{from:"solver",to:S,token:"0x0000000000000000000000000000000000000000",amount:re.parseUnits("0.01",18)}],calls:pe.calls}))},me=await we.createAction({user:S,chainAuthorizations:Fe.map(pe=>({...pe,r:pe.r,s:pe.s,yParity:pe.yParity,address:pe.address,chainId:Number(pe.chainId),nonce:Number(pe.nonce)})),intents:[_e]});if(me){const pe=Ft(z,Ge=>`Chain ${Ge}`),[qe,rt]=me.intentIds[0].split("/"),et=parseInt(rt||"0",10);ye(me.intentIds[0],pe);for(let Ge=0;Ge<z.length;Ge++)await we.executeStep(qe,et,Ge,{action:"execute"})}}catch(z){const oe=z instanceof Error?z.message:"Withdraw failed";te(oe),p?.(oe)}finally{se(!1)}}},ze=a.useMemo(()=>{let z=Y;return u&&u.length>0&&(z=z.filter(oe=>u.includes(oe.chainId))),z},[Y,u]),j=I&&I.amount&&parseFloat(I.amount)>0&&parseFloat(I.amount)<=I.asset.balanceFormatted&&x&&!X&&t.length>0&&!!Ie,$=M||U,le={backgroundColor:i?.container?.backgroundColor||i?.primaryBackground||y.colors.background,border:`1px solid ${i?.container?.borderColor||y.colors.border}`,borderRadius:i?.container?.borderRadius||y.borderRadius.lg,padding:i?.container?.padding||y.spacing.md,width:i?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:y.colors.text,fontFamily:y.typography.fontFamily,boxShadow:i?.container?.boxShadow||(y.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")},fe=O?e.jsx(Nt,{type:"withdraw",isOpen:!!O&&O.overallStatus!=="processing",isProcessing:X||O?.overallStatus==="processing",onRetryTx:()=>{be(),ie(!1),ce()},onNewTx:()=>{be(),ie(!1),G(null),ue.current=null,H()},onClose:()=>{be(),ie(!1)},onComplete:()=>{be(),ie(!1),G(null),ue.current=null,H()},results:O?.overallStatus==="success"||O?.overallStatus==="failed"?O.steps.map(z=>({asset:{symbol:I?.asset.symbol||"Token",address:I?.asset.address||""},txHash:z.transactionHash||"",success:z.status==="success",amount:I?.amount})):void 0,chainName:I?tt(t[t.length-1].chainId):"Network",explorerUrl:I?Bt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:y}):null;return e.jsxs("div",{style:{...le,position:"relative"},className:d,children:[fe&&e.jsx("div",{style:{position:"absolute",top:0,left:"-25px",right:"-25px",bottom:"-16px"},children:e.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",pointerEvents:"auto"},children:fe})}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},children:e.jsx("label",{style:{fontSize:"12px",fontWeight:590,color:y.mode==="light"?"#374151":"#d1d5db"},children:"Withdraw To"})}),e.jsx("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:Fo.map(z=>{const oe=v===z.id,Fe=z.id==="external"?A:w,Re=Fe?`${Fe.slice(0,6)}...${Fe.slice(-4)}`:null;return e.jsxs("button",{onClick:()=>N(z.id),onMouseEnter:()=>ae(z.id),onMouseLeave:()=>{ae(null),J(null)},onMouseDown:()=>J(z.id),onMouseUp:()=>J(null),style:{padding:"8px 12px",borderRadius:"8px",border:`1px solid ${oe?"#EA4B4B7A":K===z.id?"#F4A5A5":y.mode==="light"?"#e5e7eb":"#374151"}`,backgroundColor:oe?y.mode==="light"?"#FEF2F2":"#451a1a":ne===z.id?y.mode==="light"?"#f5f5f5":"#2d2d2d":K===z.id?y.mode==="light"?"#fafafa":"#333333":y.mode==="light"?"white":"#1f1f1f",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"4px",transition:"all 150ms ease",transform:ne===z.id?"scale(0.96)":K===z.id?"translateY(-1px)":"none",boxShadow:oe?"0 0 0 3px #FBDBDB":ne===z.id?"0 1px 2px rgba(0, 0, 0, 0.05)":K===z.id?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:510,color:y.mode==="light"?"#3C3E42":"#e5e7eb"},children:z.label}),Re&&e.jsx("span",{style:{fontSize:"10px",fontWeight:500,color:y.mode==="light"?"#939291":"#6b7280",fontFamily:'"IBM Plex Mono", monospace'},children:Re})]},z.id)})})]}),e.jsx("div",{style:{marginBottom:y.spacing.sm},children:e.jsx(ht,{assets:ze,selectedAsset:I||void 0,onAssetSelect:Be,onAmountChange:ke,loading:_,label:"Amount",showBalance:!0,showMaxButton:!0,theme:y,styles:i})}),$&&e.jsx("div",{style:{backgroundColor:i?.errorMessage?.backgroundColor||(y.mode==="light"?"#fef2f2":`${i?.statusDisplay?.errorColor||y.colors.error}20`),border:`1px solid ${i?.errorMessage?.borderColor||(y.mode==="light"?"#fecaca":i?.statusDisplay?.errorColor||y.colors.error)}`,borderRadius:i?.errorMessage?.borderRadius||y.borderRadius.md,padding:i?.errorMessage?.padding||y.spacing.md,marginBottom:y.spacing.sm},children:e.jsx("p",{style:{color:i?.errorMessage?.color||i?.statusDisplay?.errorColor||y.colors.error,fontSize:i?.errorMessage?.fontSize||y.typography.fontSize.sm,fontWeight:i?.errorMessage?.fontWeight,fontFamily:i?.errorMessage?.fontFamily||y.typography.fontFamily,margin:0},children:$})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:y.spacing.sm},children:e.jsx(de.Button,{variant:"outline",fullWidth:!0,onClick:ce,onMouseEnter:()=>he(!0),onMouseLeave:()=>{he(!1),R(!1)},onMouseDown:()=>R(!0),onMouseUp:()=>R(!1),loading:X,disabled:!j||!x,theme:y,styles:i,style:{width:"100%",padding:"8px",backgroundColor:j?Se?"#d43d3d":xe?"#f05555":"#ea4b4b":"#d1d5db",color:j?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:j?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:j?Se?"scale(0.98)":xe?"translateY(-2px)":"none":"none",boxShadow:Se?"1px 1px 0px black":xe&&j?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:m?h?x?X?"Executing Withdraw...":I?I.amount?parseFloat(I.amount)>I.asset.balanceFormatted?"Insufficient Balance":t.length===0?"No Withdraw Batches":Ie?"Execute Withdraw":`Set ${v==="external"?"External":"Embedded"} Wallet`:"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},Eo=({isOpen:t,onClose:o,title:r="Withdraw",maxWidth:n="480px",withdrawBatches:s,externalWithdrawBatches:c,tokens:i,supportedTokens:d,enableSpiceBalanceUpdate:g=!1,theme:f="light",styles:u,className:l,withdrawInputHook:C,defaultSelectedAsset:A,filterChains:w,withdrawMode:k,onWithdrawModeChange:p,externalWalletAddress:b,embeddedWalletAddress:y,onWithdrawSuccess:B,onWithdrawError:m})=>{const h=de.createTheme(f),x=S=>{B?.(S)};return e.jsx(xt,{isOpen:t,onClose:o,title:r,subtitle:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e.jsx("img",{src:Yt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e.jsx("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:"Withdraw your vault tokens to your external or embedded wallet."})]}),styles:u,theme:h,maxWidth:n,children:e.jsx("div",{style:{padding:"0 24px 24px 24px"},children:e.jsx(gs,{withdrawBatches:s,externalWithdrawBatches:c,tokens:i,supportedTokens:d,enableSpiceBalanceUpdate:g,theme:f,styles:{...u,container:{...u?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:l,withdrawInputHook:C,defaultSelectedAsset:A,filterChains:w,withdrawMode:k,onWithdrawModeChange:p,externalWalletAddress:b,embeddedWalletAddress:y,onWithdrawSuccess:x,onWithdrawError:m})})})};/**
43
+ `})]})})},Fo=[{id:"external",label:"External Wallet"},{id:"embedded",label:"Embedded Wallet"}],gs=({withdrawBatches:t,externalWithdrawBatches:o,tokens:r,supportedTokens:n,enableSpiceBalanceUpdate:s=!1,theme:c="light",styles:i,className:d="",withdrawInputHook:g,defaultSelectedAsset:f,filterChains:u,withdrawMode:l="external",onWithdrawModeChange:C,externalWalletAddress:A,embeddedWalletAddress:w,onWithdrawSuccess:k,onWithdrawError:p})=>{const b=de.createTheme(c),y={...b,typography:{...b.typography,fontFamily:i?.fontFamily||b.typography.fontFamily},colors:{...b.colors,primary:i?.primaryColor||b.colors.primary,primaryHover:i?.primaryColor?`${i.primaryColor}dd`:b.colors.primaryHover}},B=Dt(),{isReady:m,isAuthenticated:h,isConnected:x,address:S,provider:F,actions:W}=B,[I,G]=a.useState(()=>f?{asset:f,amount:""}:null),[Y,ee]=a.useState([]),[_,q]=a.useState(!1),[M,T]=a.useState(null),E=a.useMemo(()=>!r||r.length===0?[]:!n||n.length===0?r:r.filter(z=>n.some(oe=>oe.toLowerCase()===z.symbol.toLowerCase())),[r,n]),H=a.useCallback(async()=>{if(!E||E.length===0||!w){ee([]);return}q(!0),T(null);try{const z=await Promise.all(E.map(async oe=>{try{const Fe=await Te(oe.chainId).readContract({address:oe.address,abi:re.erc20Abi,functionName:"balanceOf",args:[w]}),Re=parseFloat(re.formatUnits(Fe,oe.decimals));return{address:oe.address,symbol:oe.symbol,name:oe.name,decimals:oe.decimals,chainId:oe.chainId,balance:Fe,balanceFormatted:Re,balanceUsd:0,isNative:!1,logoURI:oe.logoURI}}catch(Fe){return console.error(`Failed to fetch balance for ${oe.symbol}:`,Fe),{address:oe.address,symbol:oe.symbol,name:oe.name,decimals:oe.decimals,chainId:oe.chainId,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,isNative:!1,logoURI:oe.logoURI}}}));ee(z)}catch(z){console.error("Failed to fetch token balances:",z),T(z instanceof Error?z.message:"Failed to fetch token balances")}finally{q(!1)}},[E,w]);a.useEffect(()=>{H()},[H]),a.useEffect(()=>{if(!E||E.length===0)return;const z=setInterval(()=>{H()},3e4);return()=>clearInterval(z)},[H,E]),Y.some(z=>z.balanceFormatted>0);const[X,se]=a.useState(!1),[U,te]=a.useState(null),[xe,he]=a.useState(!1),[Se,R]=a.useState(!1),[P,ie]=a.useState(!1),[v,Z]=a.useState(l),[K,ae]=a.useState(null),[ne,J]=a.useState(null),ue=a.useRef(null),Ie=a.useMemo(()=>v==="external"?A:w,[v,A,w]),N=a.useCallback(z=>{Z(z),C?.(z)},[C]),{intentStatus:O,startStatusPolling:ye,clearStatus:be}=St({checkStepStatus:(z,oe)=>we.checkStepStatus(z,oe)});a.useEffect(()=>{if(O?.overallStatus==="success"&&O.intentId&&ue.current!==O.intentId&&I&&S){const z=O.steps.find(oe=>oe.transactionHash);if(z?.transactionHash)if(ue.current=O.intentId,s){const oe=re.parseUnits(I.amount,I.asset.decimals);we.submitSpiceDeposit({user:S,txHash:z.transactionHash,sender:S,tokenAddress:I.asset.address,chainId:I.asset.chainId,amount:oe.toString(),isDeposit:!0}).then(()=>{H()}).catch(()=>{ue.current=null})}else H()}},[O,S,s]),a.useEffect(()=>{g&&g.assetAmount!==I?.amount&&I&&G({...I,amount:g.assetAmount})},[g?.assetAmount,I]);const je=a.useCallback(()=>{te(null)},[]),Be=z=>{G({asset:z,amount:I?.amount||""}),je()},ke=a.useCallback(z=>{I&&(a.startTransition(()=>{G({...I,amount:z}),je()}),g&&g.setAssetAmount(z))},[I,g,je]),ce=async()=>{if(!(!I||!S||t.length===0)){if(!Ie){te(`Please provide a ${v==="external"?"external":"embedded"} wallet address`);return}if(!m||!h){te(`Please authenticate with ${F||"wallet provider"} to continue`);return}se(!0),te(null),ie(!0);try{const z=v==="external"&&o?[...t,...o]:[...t],oe=[...new Set(z.map(pe=>pe.chainId))],Fe=[];for(const pe of oe){const qe=Te(pe),rt=pt(pe),et=await Ne.getAccountNonce(S,qe),Ge=await W.signAuthorization({contractAddress:rt,chainId:pe,nonce:Number(et)});Fe.push(Ge)}const Re=Ne.hashChainBatches(z),Ze=Math.floor(Date.now()/1e3)+60*10,ot=Ne.getIntentHash(0n,BigInt(Ze),Re),$e=await W.signMessage({raw:ot}),nt=typeof $e=="string"?$e:$e.signature;if(!nt)throw new Error("Failed to sign intent authorization");const _e={mode:"7702",signatureType:"ecdsa",signature:nt,nbf:0,exp:Ze,chainBatches:Re.map(pe=>({hash:pe.hash,chainId:pe.chainId,tokenTransfers:[{from:"solver",to:S,token:"0x0000000000000000000000000000000000000000",amount:re.parseUnits("0.01",18)}],calls:pe.calls}))},me=await we.createAction({user:S,chainAuthorizations:Fe.map(pe=>({...pe,r:pe.r,s:pe.s,yParity:pe.yParity,address:pe.address,chainId:Number(pe.chainId),nonce:Number(pe.nonce)})),intents:[_e]});if(me){const pe=Ft(z,Ge=>`Chain ${Ge}`),[qe,rt]=me.intentIds[0].split("/"),et=parseInt(rt||"0",10);ye(me.intentIds[0],pe);for(let Ge=0;Ge<z.length;Ge++)await we.executeStep(qe,et,Ge,{action:"execute"})}}catch(z){const oe=z instanceof Error?z.message:"Withdraw failed";te(oe),p?.(oe)}finally{se(!1)}}},ze=a.useMemo(()=>{let z=Y;return u&&u.length>0&&(z=z.filter(oe=>u.includes(oe.chainId))),z},[Y,u]),j=I&&I.amount&&parseFloat(I.amount)>0&&parseFloat(I.amount)<=I.asset.balanceFormatted&&x&&!X&&t.length>0&&!!Ie,$=M||U,le={backgroundColor:i?.container?.backgroundColor||i?.primaryBackground||y.colors.background,border:`1px solid ${i?.container?.borderColor||y.colors.border}`,borderRadius:i?.container?.borderRadius||y.borderRadius.lg,padding:i?.container?.padding||y.spacing.md,width:i?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:y.colors.text,fontFamily:y.typography.fontFamily,boxShadow:i?.container?.boxShadow||(y.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")},fe=O?e.jsx(Nt,{type:"withdraw",isOpen:!!O&&O.overallStatus!=="processing",isProcessing:X||O?.overallStatus==="processing",onRetryTx:()=>{be(),ie(!1),ce()},onNewTx:()=>{be(),ie(!1),G(null),ue.current=null,H()},onClose:()=>{be(),ie(!1)},onComplete:()=>{be(),ie(!1),G(null),ue.current=null,H()},results:O?.overallStatus==="success"||O?.overallStatus==="failed"?O.steps.map(z=>({asset:{symbol:I?.asset.symbol||"Token",address:I?.asset.address||""},txHash:z.transactionHash||"",success:z.status==="success",amount:I?.amount})):void 0,chainName:I?tt(t[t.length-1].chainId):"Network",explorerUrl:I?Bt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:y}):null;return e.jsxs("div",{style:{...le,position:"relative"},className:d,children:[fe&&e.jsx("div",{style:{position:"absolute",top:0,left:"-25px",right:"-25px",bottom:"-16px"},children:e.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",pointerEvents:"auto"},children:fe})}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},children:e.jsx("label",{style:{fontSize:"12px",fontWeight:590,color:y.mode==="light"?"#374151":"#d1d5db"},children:"Withdraw To"})}),e.jsx("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:Fo.map(z=>{const oe=v===z.id,Fe=z.id==="external"?A:w,Re=Fe?`${Fe.slice(0,6)}...${Fe.slice(-4)}`:null;return e.jsxs("button",{onClick:()=>N(z.id),onMouseEnter:()=>ae(z.id),onMouseLeave:()=>{ae(null),J(null)},onMouseDown:()=>J(z.id),onMouseUp:()=>J(null),style:{padding:"8px 12px",borderRadius:"8px",border:`1px solid ${oe?"#EA4B4B7A":K===z.id?"#F4A5A5":y.mode==="light"?"#e5e7eb":"#374151"}`,backgroundColor:oe?y.mode==="light"?"#FEF2F2":"#451a1a":ne===z.id?y.mode==="light"?"#f5f5f5":"#2d2d2d":K===z.id?y.mode==="light"?"#fafafa":"#333333":y.mode==="light"?"white":"#1f1f1f",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"4px",transition:"all 150ms ease",transform:ne===z.id?"scale(0.96)":K===z.id?"translateY(-1px)":"none",boxShadow:oe?"0 0 0 3px #FBDBDB":ne===z.id?"0 1px 2px rgba(0, 0, 0, 0.05)":K===z.id?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:510,color:y.mode==="light"?"#3C3E42":"#e5e7eb"},children:z.label}),Re&&e.jsx("span",{style:{fontSize:"10px",fontWeight:500,color:y.mode==="light"?"#939291":"#6b7280",fontFamily:'"IBM Plex Mono", monospace'},children:Re})]},z.id)})})]}),e.jsx("div",{style:{marginBottom:y.spacing.sm},children:e.jsx(ht,{assets:ze,selectedAsset:I||void 0,onAssetSelect:Be,onAmountChange:ke,loading:_,label:"Amount",showBalance:!0,showMaxButton:!0,theme:y,styles:i})}),$&&e.jsx("div",{style:{backgroundColor:i?.errorMessage?.backgroundColor||(y.mode==="light"?"#fef2f2":`${i?.statusDisplay?.errorColor||y.colors.error}20`),border:`1px solid ${i?.errorMessage?.borderColor||(y.mode==="light"?"#fecaca":i?.statusDisplay?.errorColor||y.colors.error)}`,borderRadius:i?.errorMessage?.borderRadius||y.borderRadius.md,padding:i?.errorMessage?.padding||y.spacing.md,marginBottom:y.spacing.sm},children:e.jsx("p",{style:{color:i?.errorMessage?.color||i?.statusDisplay?.errorColor||y.colors.error,fontSize:i?.errorMessage?.fontSize||y.typography.fontSize.sm,fontWeight:i?.errorMessage?.fontWeight,fontFamily:i?.errorMessage?.fontFamily||y.typography.fontFamily,margin:0},children:$})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:y.spacing.sm},children:e.jsx(de.Button,{variant:"outline",fullWidth:!0,onClick:ce,onMouseEnter:()=>he(!0),onMouseLeave:()=>{he(!1),R(!1)},onMouseDown:()=>R(!0),onMouseUp:()=>R(!1),loading:X,disabled:!j||!x,theme:y,styles:i,style:{width:"100%",padding:"8px",backgroundColor:j?Se?"#d43d3d":xe?"#f05555":"#ea4b4b":"#d1d5db",color:j?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:j?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:j?Se?"scale(0.98)":xe?"translateY(-2px)":"none":"none",boxShadow:Se?"1px 1px 0px black":xe&&j?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:m?h?x?X?"Executing Withdraw...":I?I.amount?parseFloat(I.amount)>I.asset.balanceFormatted?"Insufficient Balance":t.length===0?"No Withdraw Batches":Ie?"Execute Withdraw":`Set ${v==="external"?"External":"Embedded"} Wallet`:"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},Eo=({isOpen:t,onClose:o,title:r="Withdraw",maxWidth:n="480px",withdrawBatches:s,externalWithdrawBatches:c,tokens:i,supportedTokens:d,enableSpiceBalanceUpdate:g=!1,theme:f="light",styles:u,className:l,withdrawInputHook:C,defaultSelectedAsset:A,filterChains:w,withdrawMode:k,onWithdrawModeChange:p,externalWalletAddress:b,embeddedWalletAddress:y,onWithdrawSuccess:B,onWithdrawError:m})=>{const h=de.createTheme(f),x=S=>{B?.(S)};return e.jsx(xt,{isOpen:t,onClose:o,title:r,subtitle:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e.jsx("img",{src:Yt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e.jsx("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:"Withdraw your vault tokens to your external or embedded wallet."})]}),styles:u,theme:h,maxWidth:n,children:e.jsx("div",{style:{padding:"0 24px 24px 24px"},children:e.jsx(gs,{withdrawBatches:s,externalWithdrawBatches:c,tokens:i,supportedTokens:d,enableSpiceBalanceUpdate:g,theme:f,styles:{...u,container:{...u?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:l,withdrawInputHook:C,defaultSelectedAsset:A,filterChains:w,withdrawMode:k,onWithdrawModeChange:p,externalWalletAddress:b,embeddedWalletAddress:y,onWithdrawSuccess:x,onWithdrawError:m})})})};/**
44
44
  * @license lucide-react v0.562.0 - ISC
45
45
  *
46
46
  * This source code is licensed under the ISC license.
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ import{defineChain as go,createPublicClient as fo,http as mo,isAddress as Kt,get
40
40
  from { transform: rotate(0deg); }
41
41
  to { transform: rotate(360deg); }
42
42
  }
43
- `})]})})},ur=[{id:"external",label:"External Wallet"},{id:"embedded",label:"Embedded Wallet"}],Vo=({withdrawBatches:t,externalWithdrawBatches:r,tokens:i,supportedTokens:n,enableSpiceBalanceUpdate:o=!1,theme:c="light",styles:a,className:d="",withdrawInputHook:g,defaultSelectedAsset:m,filterChains:u,withdrawMode:l="external",onWithdrawModeChange:A,externalWalletAddress:w,embeddedWalletAddress:I,onWithdrawSuccess:k,onWithdrawError:p})=>{const b=De(c),x={...b,typography:{...b.typography,fontFamily:a?.fontFamily||b.typography.fontFamily},colors:{...b.colors,primary:a?.primaryColor||b.colors.primary,primaryHover:a?.primaryColor?`${a.primaryColor}dd`:b.colors.primaryHover}},R=jt(),{isReady:y,isAuthenticated:h,isConnected:f,address:S,provider:v,actions:D}=R,[F,K]=C(()=>m?{asset:m,amount:""}:null),[j,ne]=C([]),[te,P]=C(!1),[H,T]=C(null),E=Me(()=>!i||i.length===0?[]:!n||n.length===0?i:i.filter(N=>n.some(ae=>ae.toLowerCase()===N.symbol.toLowerCase())),[i,n]),V=oe(async()=>{if(!E||E.length===0||!I){ne([]);return}P(!0),T(null);try{const N=await Promise.all(E.map(async ae=>{try{const Fe=await je(ae.chainId).readContract({address:ae.address,abi:Xt,functionName:"balanceOf",args:[I]}),Qe=parseFloat(un(Fe,ae.decimals));return{address:ae.address,symbol:ae.symbol,name:ae.name,decimals:ae.decimals,chainId:ae.chainId,balance:Fe,balanceFormatted:Qe,balanceUsd:0,isNative:!1,logoURI:ae.logoURI}}catch(Fe){return console.error(`Failed to fetch balance for ${ae.symbol}:`,Fe),{address:ae.address,symbol:ae.symbol,name:ae.name,decimals:ae.decimals,chainId:ae.chainId,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,isNative:!1,logoURI:ae.logoURI}}}));ne(N)}catch(N){console.error("Failed to fetch token balances:",N),T(N instanceof Error?N.message:"Failed to fetch token balances")}finally{P(!1)}},[E,I]);_(()=>{V()},[V]),_(()=>{if(!E||E.length===0)return;const N=setInterval(()=>{V()},3e4);return()=>clearInterval(N)},[V,E]),j.some(N=>N.balanceFormatted>0);const[$,ie]=C(!1),[z,re]=C(null),[me,ge]=C(!1),[Ie,L]=C(!1),[J,de]=C(!1),[B,G]=C(l),[O,le]=C(null),[se,Z]=C(null),he=Le(null),ke=Me(()=>B==="external"?w:I,[B,w,I]),q=oe(N=>{G(N),A?.(N)},[A]),{intentStatus:X,startStatusPolling:be,clearStatus:Ce}=Bt({checkStepStatus:(N,ae)=>we.checkStepStatus(N,ae)});_(()=>{if(X?.overallStatus==="success"&&X.intentId&&he.current!==X.intentId&&F&&S){const N=X.steps.find(ae=>ae.transactionHash);if(N?.transactionHash)if(he.current=X.intentId,o){const ae=Ze(F.amount,F.asset.decimals);we.submitSpiceDeposit({user:S,txHash:N.transactionHash,sender:S,tokenAddress:F.asset.address,chainId:F.asset.chainId,amount:ae.toString(),isDeposit:!1}).then(()=>{V()}).catch(()=>{he.current=null})}else V()}},[X,S,o]),_(()=>{g&&g.assetAmount!==F?.amount&&F&&K({...F,amount:g.assetAmount})},[g?.assetAmount,F]);const Be=oe(()=>{re(null)},[]),We=N=>{K({asset:N,amount:F?.amount||""}),Be()},Se=oe(N=>{F&&(Co(()=>{K({...F,amount:N}),Be()}),g&&g.setAssetAmount(N))},[F,g,Be]),pe=async()=>{if(!(!F||!S||t.length===0)){if(!ke){re(`Please provide a ${B==="external"?"external":"embedded"} wallet address`);return}if(!y||!h){re(`Please authenticate with ${v||"wallet provider"} to continue`);return}ie(!0),re(null),de(!0);try{const N=B==="external"&&r?[...t,...r]:[...t],ae=[...new Set(N.map(ue=>ue.chainId))],Fe=[];for(const ue of ae){const Ke=je(ue),pt=yt(ue),at=await Ut(S,Ke),et=await D.signAuthorization({contractAddress:pt,chainId:ue,nonce:Number(at)});Fe.push(et)}const Qe=zt(N),_e=Math.floor(Date.now()/1e3)+60*10,dt=Vt(0n,BigInt(_e),Qe),rt=await D.signMessage({raw:dt}),ct=typeof rt=="string"?rt:rt.signature;if(!ct)throw new Error("Failed to sign intent authorization");const it={mode:"7702",signatureType:"ecdsa",signature:ct,nbf:0,exp:_e,chainBatches:Qe.map(ue=>({hash:ue.hash,chainId:ue.chainId,tokenTransfers:[{from:"solver",to:S,token:"0x0000000000000000000000000000000000000000",amount:Ze("0.01",18)}],calls:ue.calls}))},xe=await we.createAction({user:S,chainAuthorizations:Fe.map(ue=>({...ue,r:ue.r,s:ue.s,yParity:ue.yParity,address:ue.address,chainId:Number(ue.chainId),nonce:Number(ue.nonce)})),intents:[it]});if(xe){const ue=Dt(N,et=>`Chain ${et}`),[Ke,pt]=xe.intentIds[0].split("/"),at=parseInt(pt||"0",10);be(xe.intentIds[0],ue);for(let et=0;et<N.length;et++)await we.executeStep(Ke,at,et,{action:"execute"})}}catch(N){const ae=N instanceof Error?N.message:"Withdraw failed";re(ae),p?.(ae)}finally{ie(!1)}}},Pe=Me(()=>{let N=j;return u&&u.length>0&&(N=N.filter(ae=>u.includes(ae.chainId))),N},[j,u]),W=F&&F.amount&&parseFloat(F.amount)>0&&parseFloat(F.amount)<=F.asset.balanceFormatted&&f&&!$&&t.length>0&&!!ke,ee=H||z,ce={backgroundColor:a?.container?.backgroundColor||a?.primaryBackground||x.colors.background,border:`1px solid ${a?.container?.borderColor||x.colors.border}`,borderRadius:a?.container?.borderRadius||x.borderRadius.lg,padding:a?.container?.padding||x.spacing.md,width:a?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:x.colors.text,fontFamily:x.typography.fontFamily,boxShadow:a?.container?.boxShadow||(x.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")},ye=X?e(io,{type:"withdraw",isOpen:!!X&&X.overallStatus!=="processing",isProcessing:$||X?.overallStatus==="processing",onRetryTx:()=>{Ce(),de(!1),pe()},onNewTx:()=>{Ce(),de(!1),K(null),he.current=null,V()},onClose:()=>{Ce(),de(!1)},onComplete:()=>{Ce(),de(!1),K(null),he.current=null,V()},results:X?.overallStatus==="success"||X?.overallStatus==="failed"?X.steps.map(N=>({asset:{symbol:F?.asset.symbol||"Token",address:F?.asset.address||""},txHash:N.transactionHash||"",success:N.status==="success",amount:F?.amount})):void 0,chainName:F?st(t[t.length-1].chainId):"Network",explorerUrl:F?Nt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:x}):null;return s("div",{style:{...ce,position:"relative"},className:d,children:[ye&&e("div",{style:{position:"absolute",top:0,left:"-25px",right:"-25px",bottom:"-16px"},children:e("div",{style:{position:"absolute",width:"100%",height:"100%",pointerEvents:"auto"},children:ye})}),s("div",{style:{marginBottom:"16px"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},children:e("label",{style:{fontSize:"12px",fontWeight:590,color:x.mode==="light"?"#374151":"#d1d5db"},children:"Withdraw To"})}),e("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:ur.map(N=>{const ae=B===N.id,Fe=N.id==="external"?w:I,Qe=Fe?`${Fe.slice(0,6)}...${Fe.slice(-4)}`:null;return s("button",{onClick:()=>q(N.id),onMouseEnter:()=>le(N.id),onMouseLeave:()=>{le(null),Z(null)},onMouseDown:()=>Z(N.id),onMouseUp:()=>Z(null),style:{padding:"8px 12px",borderRadius:"8px",border:`1px solid ${ae?"#EA4B4B7A":O===N.id?"#F4A5A5":x.mode==="light"?"#e5e7eb":"#374151"}`,backgroundColor:ae?x.mode==="light"?"#FEF2F2":"#451a1a":se===N.id?x.mode==="light"?"#f5f5f5":"#2d2d2d":O===N.id?x.mode==="light"?"#fafafa":"#333333":x.mode==="light"?"white":"#1f1f1f",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"4px",transition:"all 150ms ease",transform:se===N.id?"scale(0.96)":O===N.id?"translateY(-1px)":"none",boxShadow:ae?"0 0 0 3px #FBDBDB":se===N.id?"0 1px 2px rgba(0, 0, 0, 0.05)":O===N.id?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:[e("span",{style:{fontSize:"14px",fontWeight:510,color:x.mode==="light"?"#3C3E42":"#e5e7eb"},children:N.label}),Qe&&e("span",{style:{fontSize:"10px",fontWeight:500,color:x.mode==="light"?"#939291":"#6b7280",fontFamily:'"IBM Plex Mono", monospace'},children:Qe})]},N.id)})})]}),e("div",{style:{marginBottom:x.spacing.sm},children:e(bt,{assets:Pe,selectedAsset:F||void 0,onAssetSelect:We,onAmountChange:Se,loading:te,label:"Amount",showBalance:!0,showMaxButton:!0,theme:x,styles:a})}),ee&&e("div",{style:{backgroundColor:a?.errorMessage?.backgroundColor||(x.mode==="light"?"#fef2f2":`${a?.statusDisplay?.errorColor||x.colors.error}20`),border:`1px solid ${a?.errorMessage?.borderColor||(x.mode==="light"?"#fecaca":a?.statusDisplay?.errorColor||x.colors.error)}`,borderRadius:a?.errorMessage?.borderRadius||x.borderRadius.md,padding:a?.errorMessage?.padding||x.spacing.md,marginBottom:x.spacing.sm},children:e("p",{style:{color:a?.errorMessage?.color||a?.statusDisplay?.errorColor||x.colors.error,fontSize:a?.errorMessage?.fontSize||x.typography.fontSize.sm,fontWeight:a?.errorMessage?.fontWeight,fontFamily:a?.errorMessage?.fontFamily||x.typography.fontFamily,margin:0},children:ee})}),e("div",{style:{display:"flex",flexDirection:"column",gap:x.spacing.sm},children:e(qe,{variant:"outline",fullWidth:!0,onClick:pe,onMouseEnter:()=>ge(!0),onMouseLeave:()=>{ge(!1),L(!1)},onMouseDown:()=>L(!0),onMouseUp:()=>L(!1),loading:$,disabled:!W||!f,theme:x,styles:a,style:{width:"100%",padding:"8px",backgroundColor:W?Ie?"#d43d3d":me?"#f05555":"#ea4b4b":"#d1d5db",color:W?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:W?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:W?Ie?"scale(0.98)":me?"translateY(-2px)":"none":"none",boxShadow:Ie?"1px 1px 0px black":me&&W?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:y?h?f?$?"Executing Withdraw...":F?F.amount?parseFloat(F.amount)>F.asset.balanceFormatted?"Insufficient Balance":t.length===0?"No Withdraw Batches":ke?"Execute Withdraw":`Set ${B==="external"?"External":"Embedded"} Wallet`:"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},hr=({isOpen:t,onClose:r,title:i="Withdraw",maxWidth:n="480px",withdrawBatches:o,externalWithdrawBatches:c,tokens:a,supportedTokens:d,enableSpiceBalanceUpdate:g=!1,theme:m="light",styles:u,className:l,withdrawInputHook:A,defaultSelectedAsset:w,filterChains:I,withdrawMode:k,onWithdrawModeChange:p,externalWalletAddress:b,embeddedWalletAddress:x,onWithdrawSuccess:R,onWithdrawError:y})=>{const h=De(m),f=S=>{R?.(S)};return e(At,{isOpen:t,onClose:r,title:i,subtitle:s("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e("img",{src:ao,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:"Withdraw your vault tokens to your external or embedded wallet."})]}),styles:u,theme:h,maxWidth:n,children:e("div",{style:{padding:"0 24px 24px 24px"},children:e(Vo,{withdrawBatches:o,externalWithdrawBatches:c,tokens:a,supportedTokens:d,enableSpiceBalanceUpdate:g,theme:m,styles:{...u,container:{...u?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:l,withdrawInputHook:A,defaultSelectedAsset:w,filterChains:I,withdrawMode:k,onWithdrawModeChange:p,externalWalletAddress:b,embeddedWalletAddress:x,onWithdrawSuccess:f,onWithdrawError:y})})})};/**
43
+ `})]})})},ur=[{id:"external",label:"External Wallet"},{id:"embedded",label:"Embedded Wallet"}],Vo=({withdrawBatches:t,externalWithdrawBatches:r,tokens:i,supportedTokens:n,enableSpiceBalanceUpdate:o=!1,theme:c="light",styles:a,className:d="",withdrawInputHook:g,defaultSelectedAsset:m,filterChains:u,withdrawMode:l="external",onWithdrawModeChange:A,externalWalletAddress:w,embeddedWalletAddress:I,onWithdrawSuccess:k,onWithdrawError:p})=>{const b=De(c),x={...b,typography:{...b.typography,fontFamily:a?.fontFamily||b.typography.fontFamily},colors:{...b.colors,primary:a?.primaryColor||b.colors.primary,primaryHover:a?.primaryColor?`${a.primaryColor}dd`:b.colors.primaryHover}},R=jt(),{isReady:y,isAuthenticated:h,isConnected:f,address:S,provider:v,actions:D}=R,[F,K]=C(()=>m?{asset:m,amount:""}:null),[j,ne]=C([]),[te,P]=C(!1),[H,T]=C(null),E=Me(()=>!i||i.length===0?[]:!n||n.length===0?i:i.filter(N=>n.some(ae=>ae.toLowerCase()===N.symbol.toLowerCase())),[i,n]),V=oe(async()=>{if(!E||E.length===0||!I){ne([]);return}P(!0),T(null);try{const N=await Promise.all(E.map(async ae=>{try{const Fe=await je(ae.chainId).readContract({address:ae.address,abi:Xt,functionName:"balanceOf",args:[I]}),Qe=parseFloat(un(Fe,ae.decimals));return{address:ae.address,symbol:ae.symbol,name:ae.name,decimals:ae.decimals,chainId:ae.chainId,balance:Fe,balanceFormatted:Qe,balanceUsd:0,isNative:!1,logoURI:ae.logoURI}}catch(Fe){return console.error(`Failed to fetch balance for ${ae.symbol}:`,Fe),{address:ae.address,symbol:ae.symbol,name:ae.name,decimals:ae.decimals,chainId:ae.chainId,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,isNative:!1,logoURI:ae.logoURI}}}));ne(N)}catch(N){console.error("Failed to fetch token balances:",N),T(N instanceof Error?N.message:"Failed to fetch token balances")}finally{P(!1)}},[E,I]);_(()=>{V()},[V]),_(()=>{if(!E||E.length===0)return;const N=setInterval(()=>{V()},3e4);return()=>clearInterval(N)},[V,E]),j.some(N=>N.balanceFormatted>0);const[$,ie]=C(!1),[z,re]=C(null),[me,ge]=C(!1),[Ie,L]=C(!1),[J,de]=C(!1),[B,G]=C(l),[O,le]=C(null),[se,Z]=C(null),he=Le(null),ke=Me(()=>B==="external"?w:I,[B,w,I]),q=oe(N=>{G(N),A?.(N)},[A]),{intentStatus:X,startStatusPolling:be,clearStatus:Ce}=Bt({checkStepStatus:(N,ae)=>we.checkStepStatus(N,ae)});_(()=>{if(X?.overallStatus==="success"&&X.intentId&&he.current!==X.intentId&&F&&S){const N=X.steps.find(ae=>ae.transactionHash);if(N?.transactionHash)if(he.current=X.intentId,o){const ae=Ze(F.amount,F.asset.decimals);we.submitSpiceDeposit({user:S,txHash:N.transactionHash,sender:S,tokenAddress:F.asset.address,chainId:F.asset.chainId,amount:ae.toString(),isDeposit:!0}).then(()=>{V()}).catch(()=>{he.current=null})}else V()}},[X,S,o]),_(()=>{g&&g.assetAmount!==F?.amount&&F&&K({...F,amount:g.assetAmount})},[g?.assetAmount,F]);const Be=oe(()=>{re(null)},[]),We=N=>{K({asset:N,amount:F?.amount||""}),Be()},Se=oe(N=>{F&&(Co(()=>{K({...F,amount:N}),Be()}),g&&g.setAssetAmount(N))},[F,g,Be]),pe=async()=>{if(!(!F||!S||t.length===0)){if(!ke){re(`Please provide a ${B==="external"?"external":"embedded"} wallet address`);return}if(!y||!h){re(`Please authenticate with ${v||"wallet provider"} to continue`);return}ie(!0),re(null),de(!0);try{const N=B==="external"&&r?[...t,...r]:[...t],ae=[...new Set(N.map(ue=>ue.chainId))],Fe=[];for(const ue of ae){const Ke=je(ue),pt=yt(ue),at=await Ut(S,Ke),et=await D.signAuthorization({contractAddress:pt,chainId:ue,nonce:Number(at)});Fe.push(et)}const Qe=zt(N),_e=Math.floor(Date.now()/1e3)+60*10,dt=Vt(0n,BigInt(_e),Qe),rt=await D.signMessage({raw:dt}),ct=typeof rt=="string"?rt:rt.signature;if(!ct)throw new Error("Failed to sign intent authorization");const it={mode:"7702",signatureType:"ecdsa",signature:ct,nbf:0,exp:_e,chainBatches:Qe.map(ue=>({hash:ue.hash,chainId:ue.chainId,tokenTransfers:[{from:"solver",to:S,token:"0x0000000000000000000000000000000000000000",amount:Ze("0.01",18)}],calls:ue.calls}))},xe=await we.createAction({user:S,chainAuthorizations:Fe.map(ue=>({...ue,r:ue.r,s:ue.s,yParity:ue.yParity,address:ue.address,chainId:Number(ue.chainId),nonce:Number(ue.nonce)})),intents:[it]});if(xe){const ue=Dt(N,et=>`Chain ${et}`),[Ke,pt]=xe.intentIds[0].split("/"),at=parseInt(pt||"0",10);be(xe.intentIds[0],ue);for(let et=0;et<N.length;et++)await we.executeStep(Ke,at,et,{action:"execute"})}}catch(N){const ae=N instanceof Error?N.message:"Withdraw failed";re(ae),p?.(ae)}finally{ie(!1)}}},Pe=Me(()=>{let N=j;return u&&u.length>0&&(N=N.filter(ae=>u.includes(ae.chainId))),N},[j,u]),W=F&&F.amount&&parseFloat(F.amount)>0&&parseFloat(F.amount)<=F.asset.balanceFormatted&&f&&!$&&t.length>0&&!!ke,ee=H||z,ce={backgroundColor:a?.container?.backgroundColor||a?.primaryBackground||x.colors.background,border:`1px solid ${a?.container?.borderColor||x.colors.border}`,borderRadius:a?.container?.borderRadius||x.borderRadius.lg,padding:a?.container?.padding||x.spacing.md,width:a?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:x.colors.text,fontFamily:x.typography.fontFamily,boxShadow:a?.container?.boxShadow||(x.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")},ye=X?e(io,{type:"withdraw",isOpen:!!X&&X.overallStatus!=="processing",isProcessing:$||X?.overallStatus==="processing",onRetryTx:()=>{Ce(),de(!1),pe()},onNewTx:()=>{Ce(),de(!1),K(null),he.current=null,V()},onClose:()=>{Ce(),de(!1)},onComplete:()=>{Ce(),de(!1),K(null),he.current=null,V()},results:X?.overallStatus==="success"||X?.overallStatus==="failed"?X.steps.map(N=>({asset:{symbol:F?.asset.symbol||"Token",address:F?.asset.address||""},txHash:N.transactionHash||"",success:N.status==="success",amount:F?.amount})):void 0,chainName:F?st(t[t.length-1].chainId):"Network",explorerUrl:F?Nt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:x}):null;return s("div",{style:{...ce,position:"relative"},className:d,children:[ye&&e("div",{style:{position:"absolute",top:0,left:"-25px",right:"-25px",bottom:"-16px"},children:e("div",{style:{position:"absolute",width:"100%",height:"100%",pointerEvents:"auto"},children:ye})}),s("div",{style:{marginBottom:"16px"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},children:e("label",{style:{fontSize:"12px",fontWeight:590,color:x.mode==="light"?"#374151":"#d1d5db"},children:"Withdraw To"})}),e("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:ur.map(N=>{const ae=B===N.id,Fe=N.id==="external"?w:I,Qe=Fe?`${Fe.slice(0,6)}...${Fe.slice(-4)}`:null;return s("button",{onClick:()=>q(N.id),onMouseEnter:()=>le(N.id),onMouseLeave:()=>{le(null),Z(null)},onMouseDown:()=>Z(N.id),onMouseUp:()=>Z(null),style:{padding:"8px 12px",borderRadius:"8px",border:`1px solid ${ae?"#EA4B4B7A":O===N.id?"#F4A5A5":x.mode==="light"?"#e5e7eb":"#374151"}`,backgroundColor:ae?x.mode==="light"?"#FEF2F2":"#451a1a":se===N.id?x.mode==="light"?"#f5f5f5":"#2d2d2d":O===N.id?x.mode==="light"?"#fafafa":"#333333":x.mode==="light"?"white":"#1f1f1f",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"4px",transition:"all 150ms ease",transform:se===N.id?"scale(0.96)":O===N.id?"translateY(-1px)":"none",boxShadow:ae?"0 0 0 3px #FBDBDB":se===N.id?"0 1px 2px rgba(0, 0, 0, 0.05)":O===N.id?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:[e("span",{style:{fontSize:"14px",fontWeight:510,color:x.mode==="light"?"#3C3E42":"#e5e7eb"},children:N.label}),Qe&&e("span",{style:{fontSize:"10px",fontWeight:500,color:x.mode==="light"?"#939291":"#6b7280",fontFamily:'"IBM Plex Mono", monospace'},children:Qe})]},N.id)})})]}),e("div",{style:{marginBottom:x.spacing.sm},children:e(bt,{assets:Pe,selectedAsset:F||void 0,onAssetSelect:We,onAmountChange:Se,loading:te,label:"Amount",showBalance:!0,showMaxButton:!0,theme:x,styles:a})}),ee&&e("div",{style:{backgroundColor:a?.errorMessage?.backgroundColor||(x.mode==="light"?"#fef2f2":`${a?.statusDisplay?.errorColor||x.colors.error}20`),border:`1px solid ${a?.errorMessage?.borderColor||(x.mode==="light"?"#fecaca":a?.statusDisplay?.errorColor||x.colors.error)}`,borderRadius:a?.errorMessage?.borderRadius||x.borderRadius.md,padding:a?.errorMessage?.padding||x.spacing.md,marginBottom:x.spacing.sm},children:e("p",{style:{color:a?.errorMessage?.color||a?.statusDisplay?.errorColor||x.colors.error,fontSize:a?.errorMessage?.fontSize||x.typography.fontSize.sm,fontWeight:a?.errorMessage?.fontWeight,fontFamily:a?.errorMessage?.fontFamily||x.typography.fontFamily,margin:0},children:ee})}),e("div",{style:{display:"flex",flexDirection:"column",gap:x.spacing.sm},children:e(qe,{variant:"outline",fullWidth:!0,onClick:pe,onMouseEnter:()=>ge(!0),onMouseLeave:()=>{ge(!1),L(!1)},onMouseDown:()=>L(!0),onMouseUp:()=>L(!1),loading:$,disabled:!W||!f,theme:x,styles:a,style:{width:"100%",padding:"8px",backgroundColor:W?Ie?"#d43d3d":me?"#f05555":"#ea4b4b":"#d1d5db",color:W?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:W?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:W?Ie?"scale(0.98)":me?"translateY(-2px)":"none":"none",boxShadow:Ie?"1px 1px 0px black":me&&W?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:y?h?f?$?"Executing Withdraw...":F?F.amount?parseFloat(F.amount)>F.asset.balanceFormatted?"Insufficient Balance":t.length===0?"No Withdraw Batches":ke?"Execute Withdraw":`Set ${B==="external"?"External":"Embedded"} Wallet`:"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},hr=({isOpen:t,onClose:r,title:i="Withdraw",maxWidth:n="480px",withdrawBatches:o,externalWithdrawBatches:c,tokens:a,supportedTokens:d,enableSpiceBalanceUpdate:g=!1,theme:m="light",styles:u,className:l,withdrawInputHook:A,defaultSelectedAsset:w,filterChains:I,withdrawMode:k,onWithdrawModeChange:p,externalWalletAddress:b,embeddedWalletAddress:x,onWithdrawSuccess:R,onWithdrawError:y})=>{const h=De(m),f=S=>{R?.(S)};return e(At,{isOpen:t,onClose:r,title:i,subtitle:s("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e("img",{src:ao,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:"Withdraw your vault tokens to your external or embedded wallet."})]}),styles:u,theme:h,maxWidth:n,children:e("div",{style:{padding:"0 24px 24px 24px"},children:e(Vo,{withdrawBatches:o,externalWithdrawBatches:c,tokens:a,supportedTokens:d,enableSpiceBalanceUpdate:g,theme:m,styles:{...u,container:{...u?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:l,withdrawInputHook:A,defaultSelectedAsset:w,filterChains:I,withdrawMode:k,onWithdrawModeChange:p,externalWalletAddress:b,embeddedWalletAddress:x,onWithdrawSuccess:f,onWithdrawError:y})})})};/**
44
44
  * @license lucide-react v0.562.0 - ISC
45
45
  *
46
46
  * This source code is licensed under the ISC license.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "1.10.9",
3
+ "version": "1.10.10",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",