import{jsxs as e,jsx as r}from"react/jsx-runtime";import{ChevronDown as o}from"lucide-react";import{useState as t,useRef as n,useCallback as i,useMemo as l}from"react";import{styled as a}from"styled-components";import{w as d}from"./index-C5jxD-zy.mjs";import{S as s}from"./ScreenLayout-Caq5mGD8.mjs";const c=({currency:o="usd",value:a,onChange:s,inputMode:c="decimal",autoFocus:p})=>{let[m,h]=t("0"),g=n(null),v=a??m,y=d[o]?.symbol??"$",b=i((e=>{let r=e.target.value,o=(r=r.replace(/[^\d.]/g,"")).split(".");o.length>2&&(r=o[0]+"."+o.slice(1).join("")),2===o.length&&o[1].length>2&&(r=`${o[0]}.${o[1].slice(0,2)}`),r.length>1&&"0"===r[0]&&"."!==r[1]&&(r=r.slice(1)),(""===r||"."===r)&&(r="0"),s?s(r):h(r)}),[s]),w=i((e=>{!(["Delete","Backspace","Tab","Escape","Enter",".","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key)||(e.ctrlKey||e.metaKey)&&["a","c","v","x"].includes(e.key.toLowerCase()))&&(e.key>="0"&&e.key<="9"||e.preventDefault())}),[]),x=l((()=>(v.includes("."),v)),[v]);/*#__PURE__*/return e(f,{onClick:()=>g.current?.focus(),children:[/*#__PURE__*/r(u,{children:y}),x,/*#__PURE__*/r("input",{ref:g,type:"text",inputMode:c,value:x,onChange:b,onKeyDown:w,autoFocus:p,placeholder:"0",style:{width:1,height:"1rem",opacity:0,alignSelf:"center",fontSize:"1rem"}}),/*#__PURE__*/r(u,{style:{opacity:0},children:y})]})},p=({selectedAsset:t,onEditSourceAsset:n})=>{let{icon:i}=d[t];/*#__PURE__*/return e(m,{onClick:n,children:[/*#__PURE__*/r(h,{children:i}),/*#__PURE__*/r(g,{children:t.toLocaleUpperCase()}),/*#__PURE__*/r(v,{children:/*#__PURE__*/r(o,{})})]})};let f=a.span`
  background-color: var(--privy-color-background);
  width: 100%;
  text-align: center;
  border: none;
  font-kerning: none;
  font-feature-settings: 'calt' off;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  cursor: pointer;

  &:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
  }

  && {
    color: var(--privy-color-foreground);
    font-size: 3.75rem;
    font-style: normal;
    font-weight: 600;
    line-height: 5.375rem;
  }
`,u=a.span`
  color: var(--privy-color-foreground);
  font-kerning: none;
  font-feature-settings: 'calt' off;
  font-size: 1rem;
  font-style: normal;
  font-weight: 600;
  line-height: 1.5rem;
  margin-top: 0.75rem;
`,m=a.button`
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: auto;
  gap: 0.5rem;
  border: 1px solid var(--privy-color-border-default);
  border-radius: var(--privy-border-radius-full);

  && {
    margin: auto;
    padding: 0.5rem 1rem;
  }
`,h=a.div`
  svg {
    width: 1rem;
    height: 1rem;
    border-radius: var(--privy-border-radius-full);
    overflow: hidden;
    border: solid 0.1px var(--privy-color-border-default);
  }
`,g=a.span`
  color: var(--privy-color-foreground);
  font-kerning: none;
  font-feature-settings: 'calt' off;
  font-size: 0.875rem;
  font-style: normal;
  font-weight: 500;
  line-height: 1.375rem;
`,v=a.div`
  color: var(--privy-color-foreground);

  svg {
    width: 1.25rem;
    height: 1.25rem;
  }
`;const y=({opts:o,isLoading:t,onSelectSource:n})=>/*#__PURE__*/r(s,{showClose:!1,showBack:!0,onBack:()=>n(o.source.selectedAsset),title:"Select currency",children:/*#__PURE__*/r(b,{children:o.source.assets.map((o=>{let{icon:i,name:l}=d[o];/*#__PURE__*/return r(w,{onClick:()=>n(o),disabled:t,children:/*#__PURE__*/e(x,{children:[/*#__PURE__*/r(k,{children:i}),/*#__PURE__*/e(C,{children:[/*#__PURE__*/r(S,{children:l}),/*#__PURE__*/r(A,{children:o.toLocaleUpperCase()})]})]})},o)}))})});let b=a.div`
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-height: 20.875rem;
  overflow-y: auto;
  scrollbar-width: none;

  &::-webkit-scrollbar {
    display: none;
  }
`,w=a.button`
  border-color: var(--privy-color-border-default);
  border-width: 1px;
  border-radius: var(--privy-border-radius-mdlg);
  border-style: solid;
  display: flex;

  && {
    padding: 0.75rem 1rem;
  }
`,x=a.div`
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
`,k=a.div`
  svg {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--privy-border-radius-full);
    overflow: hidden;
    border: solid 0.1px var(--privy-color-border-default);
  }
`,C=a.div`
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
`,S=a.span`
  color: var(--privy-color-foreground);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25rem;
`,A=a.span`
  color: var(--privy-color-foreground-3);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.125rem;
`;export{c as A,p as C,y as S};
//# sourceMappingURL=SelectSourceAsset-BFTx8rzA.mjs.map
