import{i as f,a5 as d,aa as c,c as w,a as m,ay as O,L as I,K as x,$ as H,aL as l,x as u,aA as D,a3 as z,a4 as W,aM as q,aN as F,T as g,a7 as b,N as M,a9 as Y,a6 as K,R as _,a0 as G,a1 as J,a2 as Q}from"./index-Cr5N_0pd.js";import{S as L}from"./index-DUeQylCA.js";const X=f` :host { width: 100%; height: 100px; border-radius: var(--wui-border-radius-s); border: 1px solid var(--wui-color-gray-glass-002); background-color: var(--wui-color-gray-glass-002); transition: background-color var(--wui-ease-out-power-1) var(--wui-duration-lg); will-change: background-color; position: relative; } :host(:hover) { background-color: var(--wui-color-gray-glass-005); } wui-flex { width: 100%; height: fit-content; } wui-button { display: ruby; color: var(--wui-color-fg-100); margin: 0 var(--wui-spacing-xs); } .instruction { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; } .paste { display: inline-flex; } textarea { background: transparent; width: 100%; font-family: var(--w3m-font-family); font-size: var(--wui-font-size-medium); font-style: normal; font-weight: var(--wui-font-weight-light); line-height: 130%; letter-spacing: var(--wui-letter-spacing-medium); color: var(--wui-color-fg-100); caret-color: var(--wui-color-accent-100); box-sizing: border-box; -webkit-appearance: none; -moz-appearance: textfield; padding: 0px; border: none; outline: none; appearance: none; resize: none; overflow: hidden; } `;var E=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let A=class extends m{constructor(){super(...arguments),this.inputElementRef=O(),this.instructionElementRef=O(),this.instructionHidden=!!this.value,this.pasting=!1,this.onDebouncedSearch=I.debounce(async e=>{if(!e.length){this.setReceiverAddress("");return}const i=x.state.activeChain;if(I.isAddress(e,i)){this.setReceiverAddress(e);return}try{const r=await H.getEnsAddress(e);if(r){l.setReceiverProfileName(e),l.setReceiverAddress(r);const t=await H.getEnsAvatar(e);l.setReceiverProfileImageUrl(t||void 0)}}catch{this.setReceiverAddress(e)}finally{l.setLoading(!1)}})}firstUpdated(){this.value&&(this.instructionHidden=!0),this.checkHidden()}render(){return u` Type or Paste address `}async focusInput(){this.instructionElementRef.value&&(this.instructionHidden=!0,await this.toggleInstructionFocus(!1),this.instructionElementRef.value.style.pointerEvents="none",this.inputElementRef.value?.focus(),this.inputElementRef.value&&(this.inputElementRef.value.selectionStart=this.inputElementRef.value.selectionEnd=this.inputElementRef.value.value.length))}async focusInstruction(){this.instructionElementRef.value&&(this.instructionHidden=!1,await this.toggleInstructionFocus(!0),this.instructionElementRef.value.style.pointerEvents="auto",this.inputElementRef.value?.blur())}async toggleInstructionFocus(e){this.instructionElementRef.value&&await this.instructionElementRef.value.animate([{opacity:e?0:1},{opacity:e?1:0}],{duration:100,easing:"ease",fill:"forwards"}).finished}onBoxClick(){!this.value&&!this.instructionHidden&&this.focusInput()}onBlur(){!this.value&&this.instructionHidden&&!this.pasting&&this.focusInstruction()}checkHidden(){this.instructionHidden&&this.focusInput()}async onPasteClick(){this.pasting=!0;const e=await navigator.clipboard.readText();l.setReceiverAddress(e),this.focusInput()}onInputChange(e){const i=e.target;this.pasting=!1,this.value=e.target?.value,i.value&&!this.instructionHidden&&this.focusInput(),l.setLoading(!0),this.onDebouncedSearch(i.value)}setReceiverAddress(e){l.setReceiverAddress(e),l.setReceiverProfileName(void 0),l.setReceiverProfileImageUrl(void 0),l.setLoading(!1)}};A.styles=X;E([d()],A.prototype,"value",void 0);E([c()],A.prototype,"instructionHidden",void 0);E([c()],A.prototype,"pasting",void 0);A=E([w("w3m-input-address")],A);const Z=f` :host { position: relative; display: inline-block; } input { background: transparent; width: 100%; height: auto; font-family: var(--wui-font-family); color: var(--wui-color-fg-100); font-feature-settings: 'case' on; font-size: 32px; font-weight: var(--wui-font-weight-light); caret-color: var(--wui-color-accent-100); line-height: 130%; letter-spacing: -1.28px; box-sizing: border-box; -webkit-appearance: none; -moz-appearance: textfield; padding: 0px; } input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } input::placeholder { color: var(--wui-color-fg-275); } `;var B=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let C=class extends m{constructor(){super(...arguments),this.inputElementRef=O(),this.disabled=!1,this.value="",this.placeholder="0"}render(){return this.inputElementRef?.value&&this.value&&(this.inputElementRef.value.value=this.value),u` `}dispatchInputChangeEvent(e){const i=e.data;if(i&&this.inputElementRef?.value)if(i===","){const n=this.inputElementRef.value.value.replace(",",".");this.inputElementRef.value.value=n,this.value=`${this.value}${n}`}else q.test(i)||(this.inputElementRef.value.value=this.value.replace(new RegExp(i.replace(F,"\\$&"),"gu"),""));this.dispatchEvent(new CustomEvent("inputChange",{detail:this.inputElementRef.value?.value,bubbles:!0,composed:!0}))}};C.styles=[z,W,Z];B([d({type:Boolean})],C.prototype,"disabled",void 0);B([d({type:String})],C.prototype,"value",void 0);B([d({type:String})],C.prototype,"placeholder",void 0);C=B([w("wui-input-amount")],C);const ee=f` :host { width: 100%; height: 100px; border-radius: var(--wui-border-radius-s); border: 1px solid var(--wui-color-gray-glass-002); background-color: var(--wui-color-gray-glass-002); transition: background-color var(--wui-ease-out-power-1) var(--wui-duration-lg); will-change: background-color; } :host(:hover) { background-color: var(--wui-color-gray-glass-005); } wui-flex { width: 100%; height: fit-content; } wui-button { width: 100%; display: flex; justify-content: flex-end; } wui-input-amount { mask-image: linear-gradient( 270deg, transparent 0px, transparent 8px, black 24px, black 25px, black 32px, black 100% ); } .totalValue { width: 100%; } `;var V=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let R=class extends m{render(){return u` ${this.buttonTemplate()} ${this.sendValueTemplate()} ${this.maxAmountTemplate()} ${this.actionTemplate()} `}buttonTemplate(){return this.token?u` `:u`Select token`}handleSelectButtonClick(){g.push("WalletSendSelectToken")}sendValueTemplate(){if(this.token&&this.sendTokenAmount){const i=this.token.price*this.sendTokenAmount;return u`${i?`$${b.formatNumberToLocalString(i,2)}`:"Incorrect value"}`}return null}maxAmountTemplate(){return this.token?this.sendTokenAmount&&this.sendTokenAmount>Number(this.token.quantity.numeric)?u` ${b.roundNumber(Number(this.token.quantity.numeric),6,5)} `:u` ${b.roundNumber(Number(this.token.quantity.numeric),6,5)} `:null}actionTemplate(){return this.token?this.sendTokenAmount&&this.sendTokenAmount>Number(this.token.quantity.numeric)?u`Buy`:u`Max`:null}onInputChange(e){l.setTokenAmount(e.detail)}onMaxClick(){if(this.token){const e=M.bigNumber(this.token.quantity.numeric);l.setTokenAmount(Number(e.toFixed(20)))}}onBuyClick(){g.push("OnRampProviders")}};R.styles=ee;V([d({type:Object})],R.prototype,"token",void 0);V([d({type:Number})],R.prototype,"sendTokenAmount",void 0);R=V([w("w3m-input-token")],R);const te=f` :host { display: block; } wui-flex { position: relative; } wui-icon-box { width: 40px; height: 40px; border-radius: var(--wui-border-radius-xs) !important; border: 5px solid var(--wui-color-bg-125); background: var(--wui-color-bg-175); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3; } wui-button { --local-border-radius: var(--wui-border-radius-xs) !important; } .inputContainer { height: fit-content; } `;var $=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let p=class extends m{constructor(){super(),this.unsubscribe=[],this.token=l.state.token,this.sendTokenAmount=l.state.sendTokenAmount,this.receiverAddress=l.state.receiverAddress,this.receiverProfileName=l.state.receiverProfileName,this.loading=l.state.loading,this.message="Preview Send",this.token&&(this.fetchBalances(),this.fetchNetworkPrice()),this.unsubscribe.push(l.subscribe(e=>{this.token=e.token,this.sendTokenAmount=e.sendTokenAmount,this.receiverAddress=e.receiverAddress,this.receiverProfileName=e.receiverProfileName,this.loading=e.loading}))}disconnectedCallback(){this.unsubscribe.forEach(e=>e())}render(){return this.getMessage(),u` ${this.message} `}async fetchBalances(){await l.fetchTokenBalance(),l.fetchNetworkBalance()}async fetchNetworkPrice(){await L.getNetworkTokenPrice()}onButtonClick(){g.push("WalletSendPreview")}getMessage(){this.message="Preview Send",this.receiverAddress&&!I.isAddress(this.receiverAddress,x.state.activeChain)&&(this.message="Invalid Address"),this.receiverAddress||(this.message="Add Address"),this.sendTokenAmount&&this.token&&this.sendTokenAmount>Number(this.token.quantity.numeric)&&(this.message="Insufficient Funds"),this.sendTokenAmount||(this.message="Add Amount"),this.sendTokenAmount&&this.token?.price&&(this.sendTokenAmount*this.token.price||(this.message="Incorrect Value")),this.token||(this.message="Select Token")}};p.styles=te;$([c()],p.prototype,"token",void 0);$([c()],p.prototype,"sendTokenAmount",void 0);$([c()],p.prototype,"receiverAddress",void 0);$([c()],p.prototype,"receiverProfileName",void 0);$([c()],p.prototype,"loading",void 0);$([c()],p.prototype,"message",void 0);p=$([w("w3m-wallet-send-view")],p);const ie=f` .contentContainer { height: 440px; overflow: scroll; scrollbar-width: none; } .contentContainer::-webkit-scrollbar { display: none; } wui-icon-box { width: 40px; height: 40px; border-radius: var(--wui-border-radius-xxs); } `;var S=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let k=class extends m{constructor(){super(),this.unsubscribe=[],this.tokenBalances=l.state.tokenBalances,this.search="",this.onDebouncedSearch=I.debounce(e=>{this.search=e}),this.fetchBalancesAndNetworkPrice(),this.unsubscribe.push(l.subscribe(e=>{this.tokenBalances=e.tokenBalances}))}disconnectedCallback(){this.unsubscribe.forEach(e=>e())}render(){return u` ${this.templateSearchInput()} ${this.templateTokens()} `}async fetchBalancesAndNetworkPrice(){(!this.tokenBalances||this.tokenBalances?.length===0)&&(await this.fetchBalances(),await this.fetchNetworkPrice())}async fetchBalances(){await l.fetchTokenBalance(),l.fetchNetworkBalance()}async fetchNetworkPrice(){await L.getNetworkTokenPrice()}templateSearchInput(){return u` `}templateTokens(){return this.tokens=this.tokenBalances?.filter(e=>e.chainId===x.state.activeCaipNetwork?.caipNetworkId),this.search?this.filteredTokens=this.tokenBalances?.filter(e=>e.name.toLowerCase().includes(this.search.toLowerCase())):this.filteredTokens=this.tokens,u` Your tokens ${this.filteredTokens&&this.filteredTokens.length>0?this.filteredTokens.map(e=>u``):u` No tokens found Your tokens will appear here Buy `} `}onBuyClick(){g.push("OnRampProviders")}onInputChange(e){this.onDebouncedSearch(e.detail)}handleTokenClick(e){l.setToken(e),l.setTokenAmount(void 0),g.goBack()}};k.styles=ie;S([c()],k.prototype,"tokenBalances",void 0);S([c()],k.prototype,"tokens",void 0);S([c()],k.prototype,"filteredTokens",void 0);S([c()],k.prototype,"search",void 0);k=S([w("w3m-wallet-send-select-token-view")],k);const ne=f` :host { display: flex; gap: var(--wui-spacing-xs); border-radius: var(--wui-border-radius-3xl); border: 1px solid var(--wui-color-gray-glass-002); background: var(--wui-color-gray-glass-002); padding: var(--wui-spacing-2xs) var(--wui-spacing-xs) var(--wui-spacing-2xs) var(--wui-spacing-s); align-items: center; } wui-avatar, wui-icon, wui-image { width: 32px; height: 32px; border: 1px solid var(--wui-color-gray-glass-002); border-radius: var(--wui-border-radius-3xl); box-shadow: 0 0 0 2px var(--wui-color-gray-glass-002); } `;var N=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let y=class extends m{constructor(){super(...arguments),this.text="",this.address="",this.isAddress=!1}render(){return u`${this.text} ${this.imageTemplate()}`}imageTemplate(){return this.isAddress?u``:this.imageSrc?u``:u``}};y.styles=[z,W,ne];N([d()],y.prototype,"text",void 0);N([d()],y.prototype,"address",void 0);N([d()],y.prototype,"imageSrc",void 0);N([d({type:Boolean})],y.prototype,"isAddress",void 0);y=N([w("wui-preview-item")],y);const re=f` :host { display: flex; column-gap: var(--wui-spacing-s); padding: 17px 18px 17px var(--wui-spacing-m); width: 100%; background-color: var(--wui-color-gray-glass-002); border-radius: var(--wui-border-radius-xs); color: var(--wui-color-fg-250); } wui-image { width: var(--wui-icon-size-lg); height: var(--wui-icon-size-lg); border-radius: var(--wui-border-radius-3xl); } wui-icon { width: var(--wui-icon-size-lg); height: var(--wui-icon-size-lg); } `;var j=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let T=class extends m{constructor(){super(...arguments),this.imageSrc=void 0,this.textTitle="",this.textValue=void 0}render(){return u` ${this.textTitle} ${this.templateContent()} `}templateContent(){return this.imageSrc?u``:this.textValue?u` ${this.textValue} `:u``}};T.styles=[z,W,re];j([d()],T.prototype,"imageSrc",void 0);j([d()],T.prototype,"textTitle",void 0);j([d()],T.prototype,"textValue",void 0);T=j([w("wui-list-content")],T);const oe=f` :host { display: flex; width: auto; flex-direction: column; gap: var(--wui-border-radius-1xs); border-radius: var(--wui-border-radius-s); background: var(--wui-color-gray-glass-002); padding: var(--wui-spacing-s) var(--wui-spacing-1xs) var(--wui-spacing-1xs) var(--wui-spacing-1xs); } wui-text { padding: 0 var(--wui-spacing-1xs); } wui-flex { margin-top: var(--wui-spacing-1xs); } .network { cursor: pointer; transition: background-color var(--wui-ease-out-power-1) var(--wui-duration-lg); will-change: background-color; } .network:focus-visible { border: 1px solid var(--wui-color-accent-100); background-color: var(--wui-color-gray-glass-005); -webkit-box-shadow: 0px 0px 0px 4px var(--wui-box-shadow-blue); -moz-box-shadow: 0px 0px 0px 4px var(--wui-box-shadow-blue); box-shadow: 0px 0px 0px 4px var(--wui-box-shadow-blue); } .network:hover { background-color: var(--wui-color-gray-glass-005); } .network:active { background-color: var(--wui-color-gray-glass-010); } `;var U=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let P=class extends m{render(){return u` Details ${this.networkTemplate()} `}networkTemplate(){return this.caipNetwork?.name?u` this.onNetworkClick(this.caipNetwork)} class="network" textTitle="Network" imageSrc=${Y(K.getNetworkImage(this.caipNetwork))} >`:null}onNetworkClick(e){e&&g.push("Networks",{network:e})}};P.styles=oe;U([d()],P.prototype,"receiverAddress",void 0);U([d({type:Object})],P.prototype,"caipNetwork",void 0);P=U([w("w3m-wallet-send-details")],P);const se=f` wui-avatar, wui-image { display: ruby; width: 32px; height: 32px; border-radius: var(--wui-border-radius-3xl); } .sendButton { width: 70%; --local-width: 100% !important; --local-border-radius: var(--wui-border-radius-xs) !important; } .cancelButton { width: 30%; --local-width: 100% !important; --local-border-radius: var(--wui-border-radius-xs) !important; } `;var v=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let h=class extends m{constructor(){super(),this.unsubscribe=[],this.token=l.state.token,this.sendTokenAmount=l.state.sendTokenAmount,this.receiverAddress=l.state.receiverAddress,this.receiverProfileName=l.state.receiverProfileName,this.receiverProfileImageUrl=l.state.receiverProfileImageUrl,this.caipNetwork=x.state.activeCaipNetwork,this.loading=l.state.loading,this.unsubscribe.push(l.subscribe(e=>{this.token=e.token,this.sendTokenAmount=e.sendTokenAmount,this.receiverAddress=e.receiverAddress,this.receiverProfileName=e.receiverProfileName,this.receiverProfileImageUrl=e.receiverProfileImageUrl,this.loading=e.loading}),x.subscribeKey("activeCaipNetwork",e=>this.caipNetwork=e))}disconnectedCallback(){this.unsubscribe.forEach(e=>e())}render(){return u` Send ${this.sendValueTemplate()} To Review transaction carefully Cancel Send `}sendValueTemplate(){if(this.token&&this.sendTokenAmount){const i=this.token.price*this.sendTokenAmount;return u`$${i.toFixed(2)}`}return null}async onSendClick(){if(!this.sendTokenAmount||!this.receiverAddress){_.showError("Please enter a valid amount and receiver address");return}try{await l.sendToken(),_.showSuccess("Transaction started"),g.replace("Account")}catch(e){_.showError("Failed to send transaction. Please try again."),console.error("SendController:sendToken - failed to send transaction",e);const i=e instanceof Error?e.message:"Unknown error";G.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:i,isSmartAccount:J(x.state.activeChain)===Q.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.token?.symbol||"",amount:this.sendTokenAmount,network:x.state.activeCaipNetwork?.caipNetworkId||""}})}}onCancelClick(){g.goBack()}};h.styles=se;v([c()],h.prototype,"token",void 0);v([c()],h.prototype,"sendTokenAmount",void 0);v([c()],h.prototype,"receiverAddress",void 0);v([c()],h.prototype,"receiverProfileName",void 0);v([c()],h.prototype,"receiverProfileImageUrl",void 0);v([c()],h.prototype,"caipNetwork",void 0);v([c()],h.prototype,"loading",void 0);h=v([w("w3m-wallet-send-preview-view")],h);export{k as W3mSendSelectTokenView,h as W3mWalletSendPreviewView,p as W3mWalletSendView};