import{j as t,l as e,a as i,C as n,o as s,_ as r,m as o,R as a,N as l,M as c,S as u,d,y as h,J as f,r as p,k as w,E as x,a2 as m,a3 as g,q as $}from"./p-BxEPsDRj.js";import{n as b,r as v,c as k,U as y}from"./p-CrMmJdZ6.js";import"./p-CG_zIdXa.js";import"./p-DJATscC5.js";import"./p-CUUFsMGb.js";import{e as C,n as j}from"./p-B9-TeWdB.js";import"./p-x-xPR8Lc.js";import"./p-YV_GhS6X.js";import"./p-DJUlqjcR.js";import{S as R}from"./p-fC-zSJu1.js";import"./p-CGIQ9z_e.js";import"./p-DGY68jkO.js";import"./p-CbOrugAV.js";import"./p-bVKFXN0v.js";import{o as S}from"./p-zNe_7rLp.js";import"./p-BId5WtRC.js";import"buffer";import"events";import"ox";import"viem";import"viem/chains";import"./p-WZF-tHaR.js";import"./p-08zq6pz3.js";var D=t`
  :host {
    width: 100%;
    height: 100px;
    border-radius: ${({borderRadius:t})=>t["5"]};
    border: 1px solid ${({tokens:t})=>t.theme.foregroundPrimary};
    background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
    transition: background-color ${({durations:t})=>t["lg"]}
      ${({easings:t})=>t["ease-out-power-1"]};
    will-change: background-color;
    position: relative;
  }

  :host(:hover) {
    background-color: ${({tokens:t})=>t.theme.foregroundSecondary};
  }

  wui-flex {
    width: 100%;
    height: fit-content;
  }

  wui-button {
    display: ruby;
    color: ${({tokens:t})=>t.theme.textPrimary};
    margin: 0 ${({spacing:t})=>t["2"]};
  }

  .instruction {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
  }

  .paste {
    display: inline-flex;
  }

  textarea {
    background: transparent;
    width: 100%;
    font-family: ${({fontFamily:t})=>t.regular};
    font-style: normal;
    font-size: ${({textSize:t})=>t.large};
    font-weight: ${({fontWeight:t})=>t.regular};
    line-height: ${({typography:t})=>t["lg-regular"].lineHeight};
    letter-spacing: ${({typography:t})=>t["lg-regular"].letterSpacing};
    color: ${({tokens:t})=>t.theme.textSecondary};
    caret-color: ${({tokens:t})=>t.core.backgroundAccentPrimary};
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    padding: 0px;
    border: none;
    outline: none;
    appearance: none;
    resize: none;
    overflow: hidden;
  }
`;var I=undefined&&undefined.__decorate||function(t,e,i,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)if(o=t[a])r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r;return s>3&&r&&Object.defineProperty(e,i,r),r};let N=class t extends e{constructor(){super(...arguments);this.inputElementRef=C();this.instructionElementRef=C();this.readOnly=false;this.instructionHidden=Boolean(this.value);this.pasting=false;this.onDebouncedSearch=i.debounce((async t=>{if(!t.length){this.setReceiverAddress("");return}const e=n.state.activeChain;const o=i.isAddress(t,e);if(o){this.setReceiverAddress(t);return}try{const e=await s.getEnsAddress(t);if(e){r.setReceiverProfileName(t);r.setReceiverAddress(e);const i=await s.getEnsAvatar(t);r.setReceiverProfileImageUrl(i||undefined)}}catch(e){this.setReceiverAddress(t)}finally{r.setLoading(false)}}))}firstUpdated(){if(this.value){this.instructionHidden=true}this.checkHidden()}render(){if(this.readOnly){return o` <wui-flex
        flexDirection="column"
        justifyContent="center"
        gap="01"
        .padding=${["8","4","5","4"]}
      >
        <textarea
          spellcheck="false"
          ?disabled=${true}
          autocomplete="off"
          .value=${this.value??""}
        >
           ${this.value??""}</textarea
        >
      </wui-flex>`}return o` <wui-flex
      @click=${this.onBoxClick.bind(this)}
      flexDirection="column"
      justifyContent="center"
      gap="01"
      .padding=${["8","4","5","4"]}
    >
      <wui-text
        ${j(this.instructionElementRef)}
        class="instruction"
        color="secondary"
        variant="md-medium"
      >
        Type or
        <wui-button
          class="paste"
          size="md"
          variant="neutral-secondary"
          iconLeft="copy"
          @click=${this.onPasteClick.bind(this)}
        >
          <wui-icon size="sm" color="inherit" slot="iconLeft" name="copy"></wui-icon>
          Paste
        </wui-button>
        address
      </wui-text>
      <textarea
        spellcheck="false"
        ?disabled=${!this.instructionHidden}
        ${j(this.inputElementRef)}
        @input=${this.onInputChange.bind(this)}
        @blur=${this.onBlur.bind(this)}
        .value=${this.value??""}
        autocomplete="off"
      >
${this.value??""}</textarea
      >
    </wui-flex>`}async focusInput(){if(this.instructionElementRef.value){this.instructionHidden=true;await this.toggleInstructionFocus(false);this.instructionElementRef.value.style.pointerEvents="none";this.inputElementRef.value?.focus();if(this.inputElementRef.value){this.inputElementRef.value.selectionStart=this.inputElementRef.value.selectionEnd=this.inputElementRef.value.value.length}}}async focusInstruction(){if(this.instructionElementRef.value){this.instructionHidden=false;await this.toggleInstructionFocus(true);this.instructionElementRef.value.style.pointerEvents="auto";this.inputElementRef.value?.blur()}}async toggleInstructionFocus(t){if(this.instructionElementRef.value){await this.instructionElementRef.value.animate([{opacity:t?0:1},{opacity:t?1:0}],{duration:100,easing:"ease",fill:"forwards"}).finished}}onBoxClick(){if(!this.value&&!this.instructionHidden){this.focusInput()}}onBlur(){if(!this.value&&this.instructionHidden&&!this.pasting){this.focusInstruction()}}checkHidden(){if(this.instructionHidden){this.focusInput()}}async onPasteClick(){this.pasting=true;const t=await navigator.clipboard.readText();r.setReceiverAddress(t);this.focusInput()}onInputChange(t){const e=t.target;this.pasting=false;this.value=t.target?.value;if(e.value&&!this.instructionHidden){this.focusInput()}r.setLoading(true);this.onDebouncedSearch(e.value)}setReceiverAddress(t){r.setReceiverAddress(t);r.setReceiverProfileName(undefined);r.setReceiverProfileImageUrl(undefined);r.setLoading(false)}};N.styles=D;I([b()],N.prototype,"value",void 0);I([b({type:Boolean})],N.prototype,"readOnly",void 0);I([v()],N.prototype,"instructionHidden",void 0);I([v()],N.prototype,"pasting",void 0);N=I([k("w3m-input-address")],N);var A=t`
  :host {
    width: 100%;
    height: 100px;
    border-radius: ${({borderRadius:t})=>t["5"]};
    border: 1px solid ${({tokens:t})=>t.theme.foregroundPrimary};
    background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
    transition: background-color ${({durations:t})=>t["lg"]}
      ${({easings:t})=>t["ease-out-power-1"]};
    will-change: background-color;
    transition: all ${({easings:t})=>t["ease-out-power-1"]}
      ${({durations:t})=>t["lg"]};
  }

  :host(:hover) {
    background-color: ${({tokens:t})=>t.theme.foregroundSecondary};
  }

  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 T=undefined&&undefined.__decorate||function(t,e,i,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)if(o=t[a])r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r;return s>3&&r&&Object.defineProperty(e,i,r),r};let z=class t extends e{constructor(){super(...arguments);this.readOnly=false;this.isInsufficientBalance=false}render(){const t=this.readOnly||!this.token;return o` <wui-flex
      flexDirection="column"
      gap="01"
      .padding=${["5","3","4","3"]}
    >
      <wui-flex alignItems="center">
        <wui-input-amount
          @inputChange=${this.onInputChange.bind(this)}
          ?disabled=${t}
          .value=${this.sendTokenAmount?String(this.sendTokenAmount):""}
          ?error=${Boolean(this.isInsufficientBalance)}
        ></wui-input-amount>
        ${this.buttonTemplate()}
      </wui-flex>
      ${this.bottomTemplate()}
    </wui-flex>`}buttonTemplate(){if(this.token){return o`<wui-token-button
        text=${this.token.symbol}
        imageSrc=${this.token.iconUrl}
        @click=${this.handleSelectButtonClick.bind(this)}
      >
      </wui-token-button>`}return o`<wui-button
      size="md"
      variant="neutral-secondary"
      @click=${this.handleSelectButtonClick.bind(this)}
      >Select token</wui-button
    >`}handleSelectButtonClick(){if(!this.readOnly){a.push("WalletSendSelectToken")}}sendValueTemplate(){if(!this.readOnly&&this.token&&this.sendTokenAmount){const t=this.token.price;const e=t*this.sendTokenAmount;return o`<wui-text class="totalValue" variant="sm-regular" color="secondary"
        >${e?`$${l.formatNumberToLocalString(e,2)}`:"Incorrect value"}</wui-text
      >`}return null}maxAmountTemplate(){if(this.token){return o` <wui-text variant="sm-regular" color="secondary">
        ${y.roundNumber(Number(this.token.quantity.numeric),6,5)}
      </wui-text>`}return null}actionTemplate(){if(this.token){return o`<wui-link @click=${this.onMaxClick.bind(this)}>Max</wui-link>`}return null}bottomTemplate(){if(this.readOnly){return null}return o`<wui-flex alignItems="center" justifyContent="space-between">
      ${this.sendValueTemplate()}
      <wui-flex alignItems="center" gap="01" justifyContent="flex-end">
        ${this.maxAmountTemplate()} ${this.actionTemplate()}
      </wui-flex>
    </wui-flex>`}onInputChange(t){r.setTokenAmount(t.detail)}onMaxClick(){if(this.token){const t=l.bigNumber(this.token.quantity.numeric);r.setTokenAmount(Number(t.toFixed(20)))}}};z.styles=A;T([b({type:Object})],z.prototype,"token",void 0);T([b({type:Boolean})],z.prototype,"readOnly",void 0);T([b({type:Number})],z.prototype,"sendTokenAmount",void 0);T([b({type:Boolean})],z.prototype,"isInsufficientBalance",void 0);z=T([k("w3m-input-token")],z);var O=t`
  :host {
    display: block;
  }

  wui-flex {
    position: relative;
  }

  wui-icon-box {
    width: 32px;
    height: 32px;
    border-radius: ${({borderRadius:t})=>t["10"]} !important;
    border: 4px solid ${({tokens:t})=>t.theme.backgroundPrimary};
    background: ${({tokens:t})=>t.theme.foregroundPrimary};
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
  }

  wui-button {
    --local-border-radius: ${({borderRadius:t})=>t["4"]} !important;
  }

  .inputContainer {
    height: fit-content;
  }
`;var B=undefined&&undefined.__decorate||function(t,e,i,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)if(o=t[a])r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r;return s>3&&r&&Object.defineProperty(e,i,r),r};const E={INSUFFICIENT_FUNDS:"Insufficient Funds",INCORRECT_VALUE:"Incorrect Value",INVALID_ADDRESS:"Invalid Address",ADD_ADDRESS:"Add Address",ADD_AMOUNT:"Add Amount",SELECT_TOKEN:"Select Token",PREVIEW_SEND:"Preview Send"};let P=class t extends e{constructor(){super();this.unsubscribe=[];this.isTryingToChooseDifferentWallet=false;this.token=r.state.token;this.sendTokenAmount=r.state.sendTokenAmount;this.receiverAddress=r.state.receiverAddress;this.receiverProfileName=r.state.receiverProfileName;this.loading=r.state.loading;this.params=a.state.data?.send;this.caipAddress=n.getAccountData()?.caipAddress;this.message=E.PREVIEW_SEND;this.disconnecting=false;if(this.token&&!this.params){this.fetchBalances();this.fetchNetworkPrice()}const t=n.subscribeKey("activeCaipAddress",(e=>{if(!e&&this.isTryingToChooseDifferentWallet){this.isTryingToChooseDifferentWallet=false;c.open({view:"Connect",data:{redirectView:"WalletSend"}}).catch((()=>null));t()}}));this.unsubscribe.push(...[n.subscribeAccountStateProp("caipAddress",(t=>{this.caipAddress=t})),r.subscribe((t=>{this.token=t.token;this.sendTokenAmount=t.sendTokenAmount;this.receiverAddress=t.receiverAddress;this.receiverProfileName=t.receiverProfileName;this.loading=t.loading}))])}disconnectedCallback(){this.unsubscribe.forEach((t=>t()))}async firstUpdated(){await this.handleSendParameters()}render(){this.getMessage();const t=Boolean(this.params);return o` <wui-flex flexDirection="column" .padding=${["0","4","4","4"]}>
      <wui-flex class="inputContainer" gap="2" flexDirection="column">
        <w3m-input-token
          .token=${this.token}
          .sendTokenAmount=${this.sendTokenAmount}
          ?readOnly=${t}
          ?isInsufficientBalance=${this.message===E.INSUFFICIENT_FUNDS}
        ></w3m-input-token>
        <wui-icon-box size="md" variant="secondary" icon="arrowBottom"></wui-icon-box>
        <w3m-input-address
          ?readOnly=${t}
          .value=${this.receiverProfileName?this.receiverProfileName:this.receiverAddress}
        ></w3m-input-address>
      </wui-flex>
      ${this.buttonTemplate()}
    </wui-flex>`}async fetchBalances(){await r.fetchTokenBalance();r.fetchNetworkBalance()}async fetchNetworkPrice(){await R.getNetworkTokenPrice()}onButtonClick(){a.push("WalletSendPreview",{send:this.params})}onFundWalletClick(){a.push("FundWallet",{redirectView:"WalletSend"})}async onConnectDifferentWalletClick(){try{this.isTryingToChooseDifferentWallet=true;this.disconnecting=true;await s.disconnect()}finally{this.disconnecting=false}}getMessage(){this.message=E.PREVIEW_SEND;if(this.receiverAddress&&!i.isAddress(this.receiverAddress,n.state.activeChain)){this.message=E.INVALID_ADDRESS}if(!this.receiverAddress){this.message=E.ADD_ADDRESS}if(this.sendTokenAmount&&this.token&&this.sendTokenAmount>Number(this.token.quantity.numeric)){this.message=E.INSUFFICIENT_FUNDS}if(!this.sendTokenAmount){this.message=E.ADD_AMOUNT}if(this.sendTokenAmount&&this.token?.price){const t=this.sendTokenAmount*this.token.price;if(!t){this.message=E.INCORRECT_VALUE}}if(!this.token){this.message=E.SELECT_TOKEN}}buttonTemplate(){const t=!this.message.startsWith(E.PREVIEW_SEND);const e=this.message===E.INSUFFICIENT_FUNDS;const i=Boolean(this.params);if(e&&!i){return o`
        <wui-flex .margin=${["4","0","0","0"]} flexDirection="column" gap="4">
          <wui-button
            @click=${this.onFundWalletClick.bind(this)}
            size="lg"
            variant="accent-secondary"
            fullWidth
          >
            Fund Wallet
          </wui-button>

          <wui-separator data-testid="wui-separator" text="or"></wui-separator>

          <wui-button
            @click=${this.onConnectDifferentWalletClick.bind(this)}
            size="lg"
            variant="neutral-secondary"
            fullWidth
            ?loading=${this.disconnecting}
          >
            Connect a different wallet
          </wui-button>
        </wui-flex>
      `}return o`<wui-flex .margin=${["4","0","0","0"]}>
      <wui-button
        @click=${this.onButtonClick.bind(this)}
        ?disabled=${t}
        size="lg"
        variant="accent-primary"
        ?loading=${this.loading}
        fullWidth
      >
        ${this.message}
      </wui-button>
    </wui-flex>`}async handleSendParameters(){this.loading=true;if(!this.params){this.loading=false;return}const t=Number(this.params.amount);if(isNaN(t)){u.showError("Invalid amount");this.loading=false;return}const{namespace:e,chainId:i,assetAddress:s}=this.params;if(!d.SEND_PARAMS_SUPPORTED_CHAINS.includes(e)){u.showError(`Chain "${e}" is not supported for send parameters`);this.loading=false;return}const o=n.getCaipNetworkById(i,e);if(!o){u.showError(`Network with id "${i}" not found`);this.loading=false;return}try{const{balance:e,name:i,symbol:n,decimals:a}=await h.fetchERC20Balance({caipAddress:this.caipAddress,assetAddress:s,caipNetwork:o});if(!i||!n||!a||!e){u.showError("Token not found");return}r.setToken({name:i,symbol:n,chainId:o.id.toString(),address:`${o.chainNamespace}:${o.id}:${s}`,value:0,price:0,quantity:{decimals:a.toString(),numeric:e.toString()},iconUrl:f.getTokenImage(n)??""});r.setTokenAmount(t);r.setReceiverAddress(this.params.to)}catch(t){console.error("Failed to load token information:",t);u.showError("Failed to load token information")}finally{this.loading=false}}};P.styles=O;B([v()],P.prototype,"token",void 0);B([v()],P.prototype,"sendTokenAmount",void 0);B([v()],P.prototype,"receiverAddress",void 0);B([v()],P.prototype,"receiverProfileName",void 0);B([v()],P.prototype,"loading",void 0);B([v()],P.prototype,"params",void 0);B([v()],P.prototype,"caipAddress",void 0);B([v()],P.prototype,"message",void 0);B([v()],P.prototype,"disconnecting",void 0);P=B([k("w3m-wallet-send-view")],P);var W=t`
  .contentContainer {
    height: 440px;
    overflow: scroll;
    scrollbar-width: none;
  }

  .contentContainer::-webkit-scrollbar {
    display: none;
  }

  wui-icon-box {
    width: 40px;
    height: 40px;
    border-radius: ${({borderRadius:t})=>t["3"]};
  }
`;var V=undefined&&undefined.__decorate||function(t,e,i,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)if(o=t[a])r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r;return s>3&&r&&Object.defineProperty(e,i,r),r};let F=class t extends e{constructor(){super();this.unsubscribe=[];this.tokenBalances=r.state.tokenBalances;this.search="";this.onDebouncedSearch=i.debounce((t=>{this.search=t}));this.fetchBalancesAndNetworkPrice();this.unsubscribe.push(...[r.subscribe((t=>{this.tokenBalances=t.tokenBalances}))])}disconnectedCallback(){this.unsubscribe.forEach((t=>t()))}render(){return o`
      <wui-flex flexDirection="column">
        ${this.templateSearchInput()} <wui-separator></wui-separator> ${this.templateTokens()}
      </wui-flex>
    `}async fetchBalancesAndNetworkPrice(){if(!this.tokenBalances||this.tokenBalances?.length===0){await this.fetchBalances();await this.fetchNetworkPrice()}}async fetchBalances(){await r.fetchTokenBalance();r.fetchNetworkBalance()}async fetchNetworkPrice(){await R.getNetworkTokenPrice()}templateSearchInput(){return o`
      <wui-flex gap="2" padding="3">
        <wui-input-text
          @inputChange=${this.onInputChange.bind(this)}
          class="network-search-input"
          size="sm"
          placeholder="Search token"
          icon="search"
        ></wui-input-text>
      </wui-flex>
    `}templateTokens(){this.tokens=this.tokenBalances?.filter((t=>t.chainId===n.state.activeCaipNetwork?.caipNetworkId));if(this.search){this.filteredTokens=this.tokenBalances?.filter((t=>t.name.toLowerCase().includes(this.search.toLowerCase())))}else{this.filteredTokens=this.tokens}return o`
      <wui-flex
        class="contentContainer"
        flexDirection="column"
        .padding=${["0","3","0","3"]}
      >
        <wui-flex justifyContent="flex-start" .padding=${["4","3","3","3"]}>
          <wui-text variant="md-medium" color="secondary">Your tokens</wui-text>
        </wui-flex>
        <wui-flex flexDirection="column" gap="2">
          ${this.filteredTokens&&this.filteredTokens.length>0?this.filteredTokens.map((t=>o`<wui-list-token
                    @click=${this.handleTokenClick.bind(this,t)}
                    ?clickable=${true}
                    tokenName=${t.name}
                    tokenImageUrl=${t.iconUrl}
                    tokenAmount=${t.quantity.numeric}
                    tokenValue=${t.value}
                    tokenCurrency=${t.symbol}
                  ></wui-list-token>`)):o`<wui-flex
                .padding=${["20","0","0","0"]}
                alignItems="center"
                flexDirection="column"
                gap="4"
              >
                <wui-icon-box icon="coinPlaceholder" color="default" size="lg"></wui-icon-box>
                <wui-flex
                  class="textContent"
                  gap="2"
                  flexDirection="column"
                  justifyContent="center"
                  flexDirection="column"
                >
                  <wui-text variant="lg-medium" align="center" color="primary">
                    No tokens found
                  </wui-text>
                  <wui-text variant="lg-regular" align="center" color="secondary">
                    Your tokens will appear here
                  </wui-text>
                </wui-flex>
                <wui-link @click=${this.onBuyClick.bind(this)}>Buy</wui-link>
              </wui-flex>`}
        </wui-flex>
      </wui-flex>
    `}onBuyClick(){a.push("OnRampProviders")}onInputChange(t){this.onDebouncedSearch(t.detail)}handleTokenClick(t){r.setToken(t);r.setTokenAmount(undefined);a.goBack()}};F.styles=W;V([v()],F.prototype,"tokenBalances",void 0);V([v()],F.prototype,"tokens",void 0);V([v()],F.prototype,"filteredTokens",void 0);V([v()],F.prototype,"search",void 0);F=V([k("w3m-wallet-send-select-token-view")],F);var _=t`
  :host {
    height: 32px;
    display: flex;
    align-items: center;
    gap: ${({spacing:t})=>t[1]};
    border-radius: ${({borderRadius:t})=>t[32]};
    background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
    padding: ${({spacing:t})=>t[1]};
    padding-left: ${({spacing:t})=>t[2]};
  }

  wui-avatar,
  wui-image {
    width: 24px;
    height: 24px;
    border-radius: ${({borderRadius:t})=>t[16]};
  }

  wui-icon {
    border-radius: ${({borderRadius:t})=>t[16]};
  }
`;var U=undefined&&undefined.__decorate||function(t,e,i,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)if(o=t[a])r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r;return s>3&&r&&Object.defineProperty(e,i,r),r};let L=class t extends e{constructor(){super(...arguments);this.text=""}render(){return o`<wui-text variant="lg-regular" color="primary">${this.text}</wui-text>
      ${this.imageTemplate()}`}imageTemplate(){if(this.address){return o`<wui-avatar address=${this.address} .imageSrc=${this.imageSrc}></wui-avatar>`}else if(this.imageSrc){return o`<wui-image src=${this.imageSrc}></wui-image>`}return o`<wui-icon size="lg" color="inverse" name="networkPlaceholder"></wui-icon>`}};L.styles=[p,w,_];U([b({type:String})],L.prototype,"text",void 0);U([b({type:String})],L.prototype,"address",void 0);U([b({type:String})],L.prototype,"imageSrc",void 0);L=U([k("wui-preview-item")],L);var M=t`
  :host {
    display: flex;
    padding: ${({spacing:t})=>t[4]} ${({spacing:t})=>t[3]};
    width: 100%;
    background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
    border-radius: ${({borderRadius:t})=>t[4]};
  }

  wui-image {
    width: 20px;
    height: 20px;
    border-radius: ${({borderRadius:t})=>t[16]};
  }

  wui-icon {
    width: 20px;
    height: 20px;
  }
`;var J=undefined&&undefined.__decorate||function(t,e,i,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)if(o=t[a])r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r;return s>3&&r&&Object.defineProperty(e,i,r),r};let Y=class t extends e{constructor(){super(...arguments);this.imageSrc=undefined;this.textTitle="";this.textValue=undefined}render(){return o`
      <wui-flex justifyContent="space-between" alignItems="center">
        <wui-text variant="lg-regular" color="primary"> ${this.textTitle} </wui-text>
        ${this.templateContent()}
      </wui-flex>
    `}templateContent(){if(this.imageSrc){return o`<wui-image src=${this.imageSrc} alt=${this.textTitle}></wui-image>`}else if(this.textValue){return o` <wui-text variant="md-regular" color="secondary"> ${this.textValue} </wui-text>`}return o`<wui-icon size="inherit" color="default" name="networkPlaceholder"></wui-icon>`}};Y.styles=[p,w,M];J([b()],Y.prototype,"imageSrc",void 0);J([b()],Y.prototype,"textTitle",void 0);J([b()],Y.prototype,"textValue",void 0);Y=J([k("wui-list-content")],Y);var G=t`
  :host {
    display: flex;
    width: auto;
    flex-direction: column;
    gap: ${({spacing:t})=>t["1"]};
    border-radius: ${({borderRadius:t})=>t["5"]};
    background: ${({tokens:t})=>t.theme.foregroundPrimary};
    padding: ${({spacing:t})=>t["3"]} ${({spacing:t})=>t["2"]}
      ${({spacing:t})=>t["2"]} ${({spacing:t})=>t["2"]};
  }

  wui-list-content {
    width: -webkit-fill-available !important;
  }

  wui-text {
    padding: 0 ${({spacing:t})=>t["2"]};
  }

  wui-flex {
    margin-top: ${({spacing:t})=>t["2"]};
  }

  .network {
    cursor: pointer;
    transition: background-color ${({durations:t})=>t["lg"]}
      ${({easings:t})=>t["ease-out-power-1"]};
    will-change: background-color;
  }

  .network:focus-visible {
    border: 1px solid ${({tokens:t})=>t.core.textAccentPrimary};
    background-color: ${({tokens:t})=>t.core.glass010};
    -webkit-box-shadow: 0px 0px 0px 4px ${({tokens:t})=>t.core.foregroundAccent010};
    -moz-box-shadow: 0px 0px 0px 4px ${({tokens:t})=>t.core.foregroundAccent010};
    box-shadow: 0px 0px 0px 4px ${({tokens:t})=>t.core.foregroundAccent010};
  }

  .network:hover {
    background-color: ${({tokens:t})=>t.core.glass010};
  }

  .network:active {
    background-color: ${({tokens:t})=>t.core.glass010};
  }
`;var q=undefined&&undefined.__decorate||function(t,e,i,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)if(o=t[a])r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r;return s>3&&r&&Object.defineProperty(e,i,r),r};let H=class t extends e{constructor(){super(...arguments);this.params=a.state.data?.send}render(){return o` <wui-text variant="sm-regular" color="secondary">Details</wui-text>
      <wui-flex flexDirection="column" gap="1">
        <wui-list-content
          textTitle="Address"
          textValue=${y.getTruncateString({string:this.receiverAddress??"",charsStart:4,charsEnd:4,truncate:"middle"})}
        >
        </wui-list-content>
        ${this.networkTemplate()}
      </wui-flex>`}networkTemplate(){if(this.caipNetwork?.name){return o` <wui-list-content
        @click=${()=>this.onNetworkClick(this.caipNetwork)}
        class="network"
        textTitle="Network"
        imageSrc=${S(f.getNetworkImage(this.caipNetwork))}
      ></wui-list-content>`}return null}onNetworkClick(t){if(t&&!this.params){a.push("Networks",{network:t})}}};H.styles=G;q([b()],H.prototype,"receiverAddress",void 0);q([b({type:Object})],H.prototype,"caipNetwork",void 0);q([v()],H.prototype,"params",void 0);H=q([k("w3m-wallet-send-details")],H);var X=t`
  wui-avatar,
  wui-image {
    display: ruby;
    width: 32px;
    height: 32px;
    border-radius: ${({borderRadius:t})=>t["20"]};
  }

  .sendButton {
    width: 70%;
    --local-width: 100% !important;
    --local-border-radius: ${({borderRadius:t})=>t["4"]} !important;
  }

  .cancelButton {
    width: 30%;
    --local-width: 100% !important;
    --local-border-radius: ${({borderRadius:t})=>t["4"]} !important;
  }
`;var K=undefined&&undefined.__decorate||function(t,e,i,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)if(o=t[a])r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r;return s>3&&r&&Object.defineProperty(e,i,r),r};let Z=class t extends e{constructor(){super();this.unsubscribe=[];this.token=r.state.token;this.sendTokenAmount=r.state.sendTokenAmount;this.receiverAddress=r.state.receiverAddress;this.receiverProfileName=r.state.receiverProfileName;this.receiverProfileImageUrl=r.state.receiverProfileImageUrl;this.caipNetwork=n.state.activeCaipNetwork;this.loading=r.state.loading;this.params=a.state.data?.send;this.unsubscribe.push(...[r.subscribe((t=>{this.token=t.token;this.sendTokenAmount=t.sendTokenAmount;this.receiverAddress=t.receiverAddress;this.receiverProfileName=t.receiverProfileName;this.receiverProfileImageUrl=t.receiverProfileImageUrl;this.loading=t.loading})),n.subscribeKey("activeCaipNetwork",(t=>this.caipNetwork=t))])}disconnectedCallback(){this.unsubscribe.forEach((t=>t()))}render(){return o` <wui-flex flexDirection="column" .padding=${["0","4","4","4"]}>
      <wui-flex gap="2" flexDirection="column" .padding=${["0","2","0","2"]}>
        <wui-flex alignItems="center" justifyContent="space-between">
          <wui-flex flexDirection="column" gap="01">
            <wui-text variant="sm-regular" color="secondary">Send</wui-text>
            ${this.sendValueTemplate()}
          </wui-flex>
          <wui-preview-item
            text="${this.sendTokenAmount?y.roundNumber(this.sendTokenAmount,6,5):"unknown"} ${this.token?.symbol}"
            .imageSrc=${this.token?.iconUrl}
          ></wui-preview-item>
        </wui-flex>
        <wui-flex>
          <wui-icon color="default" size="md" name="arrowBottom"></wui-icon>
        </wui-flex>
        <wui-flex alignItems="center" justifyContent="space-between">
          <wui-text variant="sm-regular" color="secondary">To</wui-text>
          <wui-preview-item
            text="${this.receiverProfileName?y.getTruncateString({string:this.receiverProfileName,charsStart:20,charsEnd:0,truncate:"end"}):y.getTruncateString({string:this.receiverAddress?this.receiverAddress:"",charsStart:4,charsEnd:4,truncate:"middle"})}"
            address=${this.receiverAddress??""}
            .imageSrc=${this.receiverProfileImageUrl??undefined}
            .isAddress=${true}
          ></wui-preview-item>
        </wui-flex>
      </wui-flex>
      <wui-flex flexDirection="column" .padding=${["6","0","0","0"]}>
        <w3m-wallet-send-details
          .caipNetwork=${this.caipNetwork}
          .receiverAddress=${this.receiverAddress}
        ></w3m-wallet-send-details>
        <wui-flex justifyContent="center" gap="1" .padding=${["3","0","0","0"]}>
          <wui-icon size="sm" color="default" name="warningCircle"></wui-icon>
          <wui-text variant="sm-regular" color="secondary">Review transaction carefully</wui-text>
        </wui-flex>
        <wui-flex justifyContent="center" gap="3" .padding=${["4","0","0","0"]}>
          <wui-button
            class="cancelButton"
            @click=${this.onCancelClick.bind(this)}
            size="lg"
            variant="neutral-secondary"
          >
            Cancel
          </wui-button>
          <wui-button
            class="sendButton"
            @click=${this.onSendClick.bind(this)}
            size="lg"
            variant="accent-primary"
            .loading=${this.loading}
          >
            Send
          </wui-button>
        </wui-flex>
      </wui-flex></wui-flex
    >`}sendValueTemplate(){if(!this.params&&this.token&&this.sendTokenAmount){const t=this.token.price;const e=t*this.sendTokenAmount;return o`<wui-text variant="md-regular" color="primary"
        >$${e.toFixed(2)}</wui-text
      >`}return null}async onSendClick(){if(!this.sendTokenAmount||!this.receiverAddress){u.showError("Please enter a valid amount and receiver address");return}try{await r.sendToken();if(this.params){a.reset("WalletSendConfirmed")}else{u.showSuccess("Transaction started");a.replace("Account")}}catch(t){let e="Failed to send transaction. Please try again.";const i=t instanceof m&&t.originalName===g.PROVIDER_RPC_ERROR_NAME.USER_REJECTED_REQUEST;if(n.state.activeChain===$.CHAIN.SOLANA||i){if(t instanceof Error){e=t.message}}x.sendEvent({type:"track",event:i?"SEND_REJECTED":"SEND_ERROR",properties:r.getSdkEventProperties(t)});u.showError(e)}}onCancelClick(){a.goBack()}};Z.styles=X;K([v()],Z.prototype,"token",void 0);K([v()],Z.prototype,"sendTokenAmount",void 0);K([v()],Z.prototype,"receiverAddress",void 0);K([v()],Z.prototype,"receiverProfileName",void 0);K([v()],Z.prototype,"receiverProfileImageUrl",void 0);K([v()],Z.prototype,"caipNetwork",void 0);K([v()],Z.prototype,"loading",void 0);K([v()],Z.prototype,"params",void 0);Z=K([k("w3m-wallet-send-preview-view")],Z);var Q=t`
  .icon-box {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background-color: ${({spacing:t})=>t[16]};
    border: 8px solid ${({tokens:t})=>t.theme.borderPrimary};
    border-radius: ${({borderRadius:t})=>t.round};
  }
`;var tt=undefined&&undefined.__decorate||function(t,e,i,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)if(o=t[a])r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r;return s>3&&r&&Object.defineProperty(e,i,r),r};let et=class t extends e{constructor(){super();this.unsubscribe=[];this.unsubscribe.push(...[])}render(){return o`
      <wui-flex
        flexDirection="column"
        alignItems="center"
        gap="4"
        .padding="${["1","3","4","3"]}"
      >
        <wui-flex justifyContent="center" alignItems="center" class="icon-box">
          <wui-icon size="xxl" color="success" name="checkmark"></wui-icon>
        </wui-flex>

        <wui-text variant="h6-medium" color="primary">You successfully sent asset</wui-text>

        <wui-button
          fullWidth
          @click=${this.onCloseClick.bind(this)}
          size="lg"
          variant="neutral-secondary"
        >
          Close
        </wui-button>
      </wui-flex>
    `}onCloseClick(){c.close()}};et.styles=Q;et=tt([k("w3m-send-confirmed-view")],et);export{et as W3mSendConfirmedView,F as W3mSendSelectTokenView,Z as W3mWalletSendPreviewView,P as W3mWalletSendView};
//# sourceMappingURL=p-wIj3CeNF.js.map