"use strict";var e=require("viem"),r=require("@privy-io/js-sdk-core"),n=require("./getPublicClient-CFd_sHBk.js"),a=require("./getErc20Balance-BS-Z8fp9.js"),i=require("react/jsx-runtime"),t=require("react"),s=require("./ModalHeader-Cpls13mi.js"),o=require("./Layouts-D3TOcPhm.js"),l=require("./FundWalletMethodHeader-DHJHs1si.js"),c=require("./Row-CMqYn75Q.js"),d=require("./ErrorMessage-BfTVyue9.js"),u=require("./Value-mhPsfsxe.js"),h=require("./Subtitle-CR8zM7ZJ.js"),m=require("./Title-ifTy35V5.js"),g=require("@heroicons/react/24/outline/WalletIcon"),p=require("styled-components"),j=require("./getChainName-C4rO8-3n.js"),x=require("./Chip-C6r7fZiR.js"),b=require("./NetworkIcon-BZ9Mj6vV.js"),y=require("./shared-DBm7PUrg.js"),f=require("@headlessui/react"),v=require("@heroicons/react/24/outline/ChevronDownIcon"),C=require("./formatErc20TokenAmount-DxwoWe7e.js"),q=require("./ethers-DEImj_8B.js"),w=require("./styles-DHDp429W.js");function k(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var N=/*#__PURE__*/k(g),S=/*#__PURE__*/k(v);const B=({balance:e,className:r,chain:n})=>/*#__PURE__*/i.jsx(y.Box,{className:r,$state:void 0,children:/*#__PURE__*/i.jsx(F,{balance:e,chain:n})}),F=({balance:e,chain:r})=>/*#__PURE__*/i.jsxs(i.Fragment,{children:[/*#__PURE__*/i.jsxs(A,{children:[/*#__PURE__*/i.jsx(I,{chainId:"object"==typeof r?r.id:"solana"}),/*#__PURE__*/i.jsx(u.Value,{children:"object"==typeof r?r.name:j.getChainName(r)})]}),/*#__PURE__*/i.jsxs(x.Chip,{isLoading:!1,isPulsing:!1,color:"gray",children:[/*#__PURE__*/i.jsx(T,{children:/*#__PURE__*/i.jsx(N.default,{})}),e]})]});let A=p.styled.div`
  display: flex;
  align-items: center;
`,T=p.styled.div`
  height: 0.75rem;
  width: 0.75rem;
  margin-right: 0.2rem;
`,I=p.styled(b.NetworkIcon)`
  height: 1.25rem;
  width: 1.25rem;
  display: inline-block;
  margin-right: 0.5rem;
  border-radius: 4px;
`;const E=({options:e,onSelect:r,selected:n,className:a})=>/*#__PURE__*/i.jsxs(f.Menu,{as:M,children:[/*#__PURE__*/i.jsxs(f.MenuButton,{as:R,children:[/*#__PURE__*/i.jsx(F,{balance:n.balance,chain:n.chain}),/*#__PURE__*/i.jsx(P,{height:16})]}),/*#__PURE__*/i.jsx(f.MenuItems,{as:W,className:a,children:e.map(((e,n)=>/*#__PURE__*/i.jsx(f.MenuItem,{as:L,onClick:()=>r(n),children:/*#__PURE__*/i.jsx(F,{balance:e.balance,chain:e.chain})},n)))})]});let M=p.styled.div`
  width: 100%;
  position: relative;
`,W=p.styled.div`
  width: 100%;
  margin-top: 0.5rem;
  position: absolute;
  background-color: var(--privy-color-background);
  border-radius: var(--privy-border-radius-md);
  overflow-x: hidden;
  overflow-y: auto;
  box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
  max-height: 11.75rem;

  && {
    border: solid 1px var(--privy-color-foreground-4);
  }

  z-index: 1;
`,L=p.styled.button`
  width: 100%;
  display: flex;
  justify-content: space-between;

  && {
    padding: 1rem;
  }

  :not(:last-child) {
    border-bottom: solid 1px var(--privy-color-foreground-4);
  }

  :hover {
    background: var(--privy-color-background-2);
  }
`,P=p.styled(S.default)`
  height: 1rem;
  margin-left: 0.5rem;
`,R=p.styled.button`
  ${y.BoxStyles}

  /* Push the chip all the way to the right */
  span {
    margin-left: auto;
  }

  ${P} {
    transition: rotate 100ms ease-in;
  }

  &[aria-expanded='true'] {
    ${P} {
      rotate: -180deg;
    }
  }
`;exports.BridgeNetworkSelectionView=({displayName:e,errorMessage:n,configuredFundingChain:a,formattedBalance:g,fundingAmount:p,fundingCurrency:x,fundingAmountInUsd:b,options:y,selectedOption:f,isPreparing:v,isSubmitting:k,addressToFund:N,fundingWalletAddress:S,onSubmit:F,onSelect:A,onAmountChange:T})=>{let I=t.useRef(null);/*#__PURE__*/return i.jsxs(i.Fragment,{children:[/*#__PURE__*/i.jsx(l.t,{}),/*#__PURE__*/i.jsx(o.RefactorSpacerTop,{}),/*#__PURE__*/i.jsx(m.Title,{children:"Transfer from another network"}),/*#__PURE__*/i.jsxs(h.Subtitle,{children:["You need more funds on the"," ","object"==typeof a?a.name:j.getChainName(a)," ","network. Bridge from another blockchain network."]}),/*#__PURE__*/i.jsxs(w.FundingQuantityWrapper,{style:{marginTop:"2rem"},children:[/*#__PURE__*/i.jsxs(w.FundingQuantity,{onClick:()=>I.current?.focus(),children:[/*#__PURE__*/i.jsx(w.FundingAmountInput,{ref:I,value:p,onChange:e=>{let r=e.target.value;if(/^[0-9.]*$/.test(r)&&r.split(".").length-1<=1){let e=/\.$/.test(r)?".":"",n=Number(r.replace(/\.$/,"")||"0");if(Number.isNaN(n))return void T("0");T(n.toString()+e)}}}),/*#__PURE__*/i.jsx(w.FundingCurrency,{children:x})]}),b&&/*#__PURE__*/i.jsx(w.FundingDollars,{children:b})]}),/*#__PURE__*/i.jsxs(c.Row,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/i.jsx(u.LabelSm,{children:"From"}),/*#__PURE__*/i.jsx(u.LabelSm,{children:r.formatWalletAddress(S)})]}),/*#__PURE__*/i.jsx(E,{selected:{chain:f.chain,balance:f.isErc20Quote?C.formatErc20TokenAmount({amount:f.erc20Balance??0n,decimals:6})+" USDC":q.getNativeCurrencyFromWei(f.balance,f.chain.nativeCurrency.symbol,3,!0)},options:y.map((({chain:e,balance:r,isErc20Quote:n,erc20Balance:a})=>({chain:e,balance:n?C.formatErc20TokenAmount({amount:a??0n,decimals:6})+" USDC":q.getNativeCurrencyFromWei(r,e.nativeCurrency.symbol,3,!0)}))),onSelect:A}),/*#__PURE__*/i.jsxs(c.Row,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/i.jsx(u.LabelSm,{children:"To"}),/*#__PURE__*/i.jsx(u.LabelSm,{children:r.formatWalletAddress(N)})]}),/*#__PURE__*/i.jsx(B,{chain:a,balance:g}),/*#__PURE__*/i.jsx(d.ErrorMessage,{style:{marginTop:"1rem"},children:n}),/*#__PURE__*/i.jsxs(s.PrimaryButtonWithoutGray,{style:{marginTop:"1rem"},loading:k||v,disabled:v||k,onClick:F,children:["Confirm with ",e]}),/*#__PURE__*/i.jsx(o.RefactorSpacerBottom,{}),/*#__PURE__*/i.jsx(s.BlobbyFooter,{})]})},exports.getBalanceForChains=({chains:i,appId:t,address:s,rpcConfig:o})=>Promise.all(i.map((async i=>{let l=e.createPublicClient({chain:i,transport:e.http(n.getJsonRpcEndpointFromChain(i,o,t))}),c=await l.getBalance({address:s}).catch((()=>0n)),d=null,u=r.UsdcAddressMap[i.id];if(u){let{balance:e}=await a.getErc20Balance({address:s,chain:i,rpcConfig:o,appId:t,erc20Address:u});d=e}return{balance:c,erc20Balance:d,erc20Address:u,chain:i}})));
//# sourceMappingURL=BridgeNetworkSelectionView-DmRXV-NJ.js.map
