1import{C as A,I as P,U,N as h,J as c,a0 as K,Q as W,R as S,Z as L,X as M,at as F,T as Q,W as q,D as z,G as H}from"./index-TRWtLqnG.js";import{r as a,n as g,c as D}from"./index-BaKVYbrQ.js";import"./index-BZ2PiRoR.js";import"./index-DM9s5T3d.js";import{M as j}from"./index-D-Z45UCS.js";import"./index-DkXNrvwK.js";import{S as n}from"./SwapController-BlALcmuQ.js";import"./index-Bm3c8JiI.js";import"./index-Dasc8aaP.js";import"./index-BSI3E0D6.js";import"./index-ZS5ZNCNR.js";import"./index-sKa6BoS2.js";import"./index-qpevMtlR.js";import"./ref-CmoQcpo0.js";const G={numericInputKeyDown(u,e,t){const i=["Backspace","Meta","Ctrl","a","A","c","C","x","X","v","V","ArrowLeft","ArrowRight","Tab"],s=u.metaKey||u.ctrlKey,o=u.key,r=o.toLocaleLowerCase(),l=r==="a",b=r==="c",I=r==="v",_=r==="x",E=o===",",O=o===".",B=o>="0"&&o<="9";!s&&(l||b||I||_)&&u.preventDefault(),e==="0"&&!E&&!O&&o==="0"&&u.preventDefault(),e==="0"&&B&&(t(o),u.preventDefault()),(E||O)&&(e||(t("0."),u.preventDefault()),(e!=null&&e.includes(".")||e!=null&&e.includes(","))&&u.preventDefault()),!B&&!i.includes(o)&&!O&&!E&&u.preventDefault()}},X=A` 2 :host { 3 width: 100%; 4 } 5 6 .details-container > wui-flex { 7 background: var(--wui-color-gray-glass-002); 8 border-radius: var(--wui-border-radius-xxs); 9 width: 100%; 10 } 11 12 .details-container > wui-flex > button { 13 border: none; 14 background: none; 15 padding: var(--wui-spacing-s); 16 border-radius: var(--wui-border-radius-xxs); 17 cursor: pointer; 18 } 19 20 .details-content-container { 21 padding: var(--wui-spacing-1xs); 22 padding-top: 0px; 23 display: flex; 24 align-items: center; 25 justify-content: center; 26 } 27 28 .details-content-container > wui-flex { 29 width: 100%; 30 } 31 32 .details-row { 33 width: 100%; 34 padding: var(--wui-spacing-s); 35 padding-left: var(--wui-spacing-s); 36 padding-right: var(--wui-spacing-1xs); 37 border-radius: calc(var(--wui-border-radius-5xs) + var(--wui-border-radius-4xs)); 38 background: var(--wui-color-gray-glass-002); 39 } 40 41 .details-row-title { 42 white-space: nowrap; 43 } 44 45 .details-row.provider-free-row { 46 padding-right: var(--wui-spacing-xs); 47 } 48`;var v=function(u,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(u,e,t,i);else for(var l=u.length-1;l>=0;l--)(r=u[l])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};const Z=K.CONVERT_SLIPPAGE_TOLERANCE;let m=class extends P{constructor(){var e;super(),this.unsubscribe=[],this.networkName=(e=U.state.activeCaipNetwork)==null?void 0:e.name,this.detailsOpen=!1,this.sourceToken=n.state.sourceToken,this.toToken=n.state.toToken,this.toTokenAmount=n.state.toTokenAmount,this.sourceTokenPriceInUSD=n.state.sourceTokenPriceInUSD,this.toTokenPriceInUSD=n.state.toTokenPriceInUSD,this.priceImpact=n.state.priceImpact,this.maxSlippage=n.state.maxSlippage,this.networkTokenSymbol=n.state.networkTokenSymbol,this.inputError=n.state.inputError,this.unsubscribe.push(n.subscribe(t=>{this.sourceToken=t.sourceToken,this.toToken=t.toToken,this.toTokenAmount=t.toTokenAmount,this.priceImpact=t.priceImpact,this.maxSlippage=t.maxSlippage,this.sourceTokenPriceInUSD=t.sourceTokenPriceInUSD,this.toTokenPriceInUSD=t.toTokenPriceInUSD,this.inputError=t.inputError}))}render(){const e=this.toTokenAmount&&this.maxSlippage?h.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString():null;if(!this.sourceToken||!this.toToken||this.inputError)return null;const t=this.sourceTokenPriceInUSD&&this.toTokenPriceInUSD?1/this.toTokenPriceInUSD*this.sourceTokenPriceInUSD:0;return c` 49 <wui-flex flexDirection="column" alignItems="center" gap="1xs" class="details-container"> 50 <wui-flex flexDirection="column"> 51 <button @click=${this.toggleDetails.bind(this)}> 52 <wui-flex justifyContent="space-between" .padding=${["0","xs","0","xs"]}> 53 <wui-flex justifyContent="flex-start" flexGrow="1" gap="xs"> 54 <wui-text variant="small-400" color="fg-100"> 55 1 ${this.sourceToken.symbol} = 56 ${h.formatNumberToLocalString(t,3)} 57 ${this.toToken.symbol} 58 </wui-text> 59 <wui-text variant="small-400" color="fg-200"> 60 $${h.formatNumberToLocalString(this.sourceTokenPriceInUSD)} 61 </wui-text> 62 </wui-flex> 63 <wui-icon name="chevronBottom"></wui-icon> 64 </wui-flex> 65 </button> 66 ${this.detailsOpen?c` 67 <wui-flex flexDirection="column" gap="xs" class="details-content-container"> 68 ${this.priceImpact?c` <wui-flex flexDirection="column" gap="xs"> 69 <wui-flex 70 justifyContent="space-between" 71 alignItems="center" 72 class="details-row" 73 > 74 <wui-flex alignItems="center" gap="xs"> 75 <wui-text class="details-row-title" variant="small-400" color="fg-150"> 76 Price impact 77 </wui-text> 78 <w3m-tooltip-trigger 79 text="Price impact reflects the change in market price due to your trade" 80 > 81 <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon> 82 </w3m-tooltip-trigger> 83 </wui-flex> 84 <wui-flex> 85 <wui-text variant="small-400" color="fg-200"> 86 ${h.formatNumberToLocalString(this.priceImpact,3)}% 87 </wui-text> 88 </wui-flex> 89 </wui-flex> 90 </wui-flex>`:null} 91 ${this.maxSlippage&&this.sourceToken.symbol?c`<wui-flex flexDirection="column" gap="xs"> 92 <wui-flex 93 justifyContent="space-between" 94 alignItems="center" 95 class="details-row" 96 > 97 <wui-flex alignItems="center" gap="xs"> 98 <wui-text class="details-row-title" variant="small-400" color="fg-150"> 99 Max. slippage 100 </wui-text> 101 <w3m-tooltip-trigger 102 text=${`Max slippage sets the minimum amount you must receive for the transaction to proceed. ${e?`Transaction will be reversed if you receive less than ${h.formatNumberToLocalString(e,6)} ${this.toToken.symbol} due to price changes.`:""}`} 103 > 104 <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon> 105 </w3m-tooltip-trigger> 106 </wui-flex> 107 <wui-flex> 108 <wui-text variant="small-400" color="fg-200"> 109 ${h.formatNumberToLocalString(this.maxSlippage,6)} 110 ${this.toToken.symbol} ${Z}% 111 </wui-text> 112 </wui-flex> 113 </wui-flex> 114 </wui-flex>`:null} 115 <wui-flex flexDirection="column" gap="xs"> 116 <wui-flex 117 justifyContent="space-between" 118 alignItems="center" 119 class="details-row provider-free-row" 120 > 121 <wui-flex alignItems="center" gap="xs"> 122 <wui-text class="details-row-title" variant="small-400" color="fg-150"> 123 Provider fee 124 </wui-text> 125 </wui-flex> 126 <wui-flex> 127 <wui-text variant="small-400" color="fg-200">0.85%</wui-text> 128 </wui-flex> 129 </wui-flex> 130 </wui-flex> 131 </wui-flex> 132 `:null} 133 </wui-flex> 134 </wui-flex> 135 `}toggleDetails(){this.detailsOpen=!this.detailsOpen}};
135m.styles=[X];v([a()],m.prototype,"networkName",void 0);v([g()],m.prototype,"detailsOpen",void 0);v([a()],m.prototype,"sourceToken",void 0);v([a()],m.prototype,"toToken",void 0);v([a()],m.prototype,"toTokenAmount",void 0);v([a()],m.prototype,"sourceTokenPriceInUSD",void 0);v([a()],m.prototype,"toTokenPriceInUSD",void 0);v([a()],m.prototype,"priceImpact",void 0);v([a()],m.prototype,"maxSlippage",void 0);v([a()],m.prototype,"networkTokenSymbol",void 0);v([a()],m.prototype,"inputError",void 0);m=v([D("w3m-swap-details")],m);const J=A` 136 :host { 137 width: 100%; 138 } 139 140 :host > wui-flex { 141 display: flex; 142 flex-direction: row; 143 justify-content: space-between; 144 align-items: center; 145 border-radius: var(--wui-border-radius-s); 146 padding: var(--wui-spacing-xl); 147 padding-right: var(--wui-spacing-s); 148 background-color: var(--wui-color-gray-glass-002); 149 box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002); 150 width: 100%; 151 height: 100px; 152 box-sizing: border-box; 153 position: relative; 154 } 155 156 wui-shimmer.market-value { 157 opacity: 0; 158 } 159 160 :host > wui-flex > svg.input_mask { 161 position: absolute; 162 inset: 0; 163 z-index: 5; 164 } 165 166 :host wui-flex .input_mask__border, 167 :host wui-flex .input_mask__background { 168 transition: fill var(--wui-duration-md) var(--wui-ease-out-power-1); 169 will-change: fill; 170 } 171 172 :host wui-flex .input_mask__border { 173 fill: var(--wui-color-gray-glass-020); 174 } 175 176 :host wui-flex .input_mask__background { 177 fill: var(--wui-color-gray-glass-002); 178 } 179`;var V=function(u,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(u,e,t,i);else for(var l=u.length-1;l>=0;l--)(r=u[l])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};let R=class extends P{constructor(){super(...arguments),this.target="sourceToken"}render(){return c` 180 <wui-flex class justifyContent="space-between"> 181 <wui-flex 182 flex="1" 183 flexDirection="column" 184 alignItems="flex-start" 185 justifyContent="center" 186 class="swap-input" 187 gap="xxs" 188 > 189 <wui-shimmer width="80px" height="40px" borderRadius="xxs" variant="light"></wui-shimmer> 190 </wui-flex> 191 ${this.templateTokenSelectButton()} 192 </wui-flex> 193 `}templateTokenSelectButton(){return c` 194 <wui-flex 195 class="swap-token-button" 196 flexDirection="column" 197 alignItems="flex-end" 198 justifyContent="center" 199 gap="xxs" 200 > 201 <wui-shimmer width="80px" height="40px" borderRadius="3xl" variant="light"></wui-shimmer> 202 </wui-flex> 203 `}};R.styles=[J];V([g()],R.prototype,"target",void 0);R=V([D("w3m-swap-input-skeleton")],R);const Y=A` 204 :host > wui-flex { 205 display: flex; 206 flex-direction: row; 207 justify-content: space-between; 208 align-items: center; 209 border-radius: var(--wui-border-radius-s); 210 background-color: var(--wui-color-gray-glass-002); 211 padding: var(--wui-spacing-xl); 212 padding-right: var(--wui-spacing-s); 213 width: 100%; 214 height: 100px; 215 box-sizing: border-box; 216 box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002); 217 position: relative; 218 transition: box-shadow var(--wui-ease-out-power-1) var(--wui-duration-lg); 219 will-change: background-color; 220 } 221 222 :host wui-flex.focus { 223 box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-005); 224 } 225 226 :host > wui-flex .swap-input, 227 :host > wui-flex .swap-token-button { 228 z-index: 10; 229 } 230 231 :host > wui-flex .swap-input { 232 -webkit-mask-image: linear-gradient( 233 270deg, 234 transparent 0px, 235 transparent 8px, 236 black 24px, 237 black 25px, 238 black 32px, 239 black 100% 240 ); 241 mask-image: linear-gradient( 242 270deg, 243 transparent 0px, 244 transparent 8px, 245 black 24px, 246 black 25px, 247 black 32px, 248 black 100% 249 ); 250 } 251 252 :host > wui-flex .swap-input input { 253 background: none; 254 border: none; 255 height: 42px; 256 width: 100%; 257 font-size: 32px; 258 font-style: normal; 259 font-weight: 400; 260 line-height: 130%; 261 letter-spacing: -1.28px; 262 outline: none; 263 caret-color: var(--wui-color-accent-100); 264 color: var(--wui-color-fg-100); 265 padding: 0px; 266 } 267 268 :host > wui-flex .swap-input input:focus-visible { 269 outline: none; 270 } 271 272 :host > wui-flex .swap-input input::-webkit-outer-spin-button, 273 :host > wui-flex .swap-input input::-webkit-inner-spin-button { 274 -webkit-appearance: none; 275 margin: 0; 276 } 277 278 .max-value-button { 279 background-color: transparent; 280 border: none; 281 cursor: pointer; 282 color: var(--wui-color-gray-glass-020); 283 padding-left: 0px; 284 } 285 286 .market-value { 287 min-height: 18px; 288 } 289`;var T=function(u,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(u,e,t,i);else for(var l=u.length-1;l>=0;l--)(r=u[l])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};const ee=5e-5;let x=class extends P{constructor(){super(...arguments),this.focused=!1,this.price=0,this.target="sourceToken",this.onSetAmount=null,this.onSetMaxValue=null}render(){const e=this.marketValue||"0",t=h.bigNumber(e).gt("0");return c` 290 <wui-flex class="${this.focused?"focus":""}" justifyContent="space-between"> 291 <wui-flex 292 flex="1" 293 flexDirection="column" 294 alignItems="flex-start" 295 justifyContent="center" 296 class="swap-input" 297 > 298 <input 299 data-testid="swap-input-${this.target}" 300 @focusin=${()=>this.onFocusChange(!0)} 301 @focusout=${()=>this.onFocusChange(!1)} 302 ?disabled=${this.disabled} 303 .value=${this.value}
304 @input=${this.dispatchInputChangeEvent} 305 @keydown=${this.handleKeydown} 306 placeholder="0" 307 type="text" 308 inputmode="decimal" 309 /> 310 <wui-text class="market-value" variant="small-400" color="fg-200"> 311 ${t?`$${h.formatNumberToLocalString(this.marketValue,2)}`:null} 312 </wui-text> 313 </wui-flex> 314 ${this.templateTokenSelectButton()} 315 </wui-flex> 316 `}handleKeydown(e){return G.numericInputKeyDown(e,this.value,t=>{var i;return(i=this.onSetAmount)==null?void 0:i.call(this,this.target,t)})}dispatchInputChangeEvent(e){if(!this.onSetAmount)return;const t=e.target.value.replace(/[^0-9.]/gu,"");t===","||t==="."?this.onSetAmount(this.target,"0."):t.endsWith(",")?this.onSetAmount(this.target,t.replace(",",".")):this.onSetAmount(this.target,t)}setMaxValueToInput(){var e;(e=this.onSetMaxValue)==null||e.call(this,this.target,this.balance)}templateTokenSelectButton(){return this.token?c` 317 <wui-flex 318 class="swap-token-button" 319 flexDirection="column" 320 alignItems="flex-end" 321 justifyContent="center" 322 gap="xxs" 323 > 324 <wui-token-button 325 data-testid="swap-input-token-${this.target}" 326 text=${this.token.symbol} 327 imageSrc=${this.token.logoUri} 328 @click=${this.onSelectToken.bind(this)} 329 > 330 </wui-token-button> 331 <wui-flex alignItems="center" gap="xxs"> ${this.tokenBalanceTemplate()} </wui-flex> 332 </wui-flex> 333 `:c` <wui-button 334 data-testid="swap-select-token-button-${this.target}" 335 class="swap-token-button" 336 size="md" 337 variant="accent" 338 @click=${this.onSelectToken.bind(this)} 339 > 340 Select token 341 </wui-button>`}tokenBalanceTemplate(){const e=h.multiply(this.balance,this.price),t=e?e==null?void 0:e.gt(ee):!1;return c` 342 ${t?c`<wui-text variant="small-400" color="fg-200"> 343 ${h.formatNumberToLocalString(this.balance,2)} 344 </wui-text>`:null} 345 ${this.target==="sourceToken"?this.tokenActionButtonTemplate(t):null} 346 `}tokenActionButtonTemplate(e){return e?c` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}> 347 <wui-text color="accent-100" variant="small-600">Max</wui-text> 348 </button>`:c` <button class="max-value-button" @click=${this.onBuyToken.bind(this)}> 349 <wui-text color="accent-100" variant="small-600">Buy</wui-text> 350 </button>`}onFocusChange(e){this.focused=e}onSelectToken(){W.sendEvent({type:"track",event:"CLICK_SELECT_TOKEN_TO_SWAP"}),S.push("SwapSelectToken",{target:this.target})}onBuyToken(){S.push("OnRampProviders")}};x.styles=[Y];T([g()],x.prototype,"focused",void 0);T([g()],x.prototype,"balance",void 0);T([g()],x.prototype,"value",void 0);T([g()],x.prototype,"price",void 0);T([g()],x.prototype,"marketValue",void 0);T([g()],x.prototype,"disabled",void 0);T([g()],x.prototype,"target",void 0);T([g()],x.prototype,"token",void 0);T([g()],x.prototype,"onSetAmount",void 0);T([g()],x.prototype,"onSetMaxValue",void 0);x=T([D("w3m-swap-input")],x);const te=A` 351 :host > wui-flex:first-child { 352 overflow-y: auto; 353 overflow-x: hidden; 354 scrollbar-width: none; 355 } 356 357 :host > wui-flex:first-child::-webkit-scrollbar {
358 display: none; 359 } 360 361 wui-loading-hexagon { 362 position: absolute; 363 } 364 365 .action-button { 366 width: 100%; 367 border-radius: var(--wui-border-radius-xs); 368 } 369 370 .action-button:disabled { 371 border-color: 1px solid var(--wui-color-gray-glass-005); 372 } 373 374 .swap-inputs-container { 375 position: relative; 376 } 377 378 .replace-tokens-button-container { 379 display: flex; 380 justify-content: center; 381 align-items: center; 382 position: absolute; 383 top: 50%; 384 left: 50%; 385 transform: translate(-50%, -50%); 386 gap: var(--wui-spacing-1xs); 387 border-radius: var(--wui-border-radius-xs); 388 background-color: var(--wui-color-modal-bg-base); 389 padding: var(--wui-spacing-xxs); 390 } 391 392 .replace-tokens-button-container > button { 393 display: flex; 394 justify-content: center; 395 align-items: center; 396 height: 40px; 397 width: 40px; 398 padding: var(--wui-spacing-xs); 399 border: none; 400 border-radius: var(--wui-border-radius-xxs); 401 background: var(--wui-color-gray-glass-002); 402 transition: background-color var(--wui-duration-md) var(--wui-ease-out-power-1); 403 will-change: background-color; 404 z-index: 20; 405 } 406 407 .replace-tokens-button-container > button:hover { 408 background: var(--wui-color-gray-glass-005); 409 } 410 411 .details-container > wui-flex { 412 background: var(--wui-color-gray-glass-002); 413 border-radius: var(--wui-border-radius-xxs); 414 width: 100%; 415 } 416 417 .details-container > wui-flex > button { 418 border: none; 419 background: none; 420 padding: var(--wui-spacing-s); 421 border-radius: var(--wui-border-radius-xxs); 422 transition: background 0.2s linear; 423 } 424 425 .details-container > wui-flex > button:hover { 426 background: var(--wui-color-gray-glass-002); 427 } 428 429 .details-content-container { 430 padding: var(--wui-spacing-1xs); 431 display: flex; 432 align-items: center; 433 justify-content: center; 434 } 435 436 .details-content-container > wui-flex { 437 width: 100%; 438 } 439 440 .details-row { 441 width: 100%; 442 padding: var(--wui-spacing-s) var(--wui-spacing-xl); 443 border-radius: var(--wui-border-radius-xxs); 444 background: var(--wui-color-gray-glass-002); 445 } 446`;var w=function(u,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(u,e,t,i);else for(var l=u.length-1;l>=0;l--)(r=u[l])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};let p=class extends P{constructor(){var e,t;super(),this.unsubscribe=[],this.initialParams=(e=S.state.data)==null?void 0:e.swap,this.detailsOpen=!1,this.caipAddress=L.state.caipAddress,this.caipNetworkId=(t=U.state.activeCaipNetwork)==null?void 0:t.caipNetworkId,this.initialized=n.state.initialized,this.loadingQuote=n.state.loadingQuote,this.loadingPrices=n.state.loadingPrices,this.loadingTransaction=n.state.loadingTransaction,this.sourceToken=n.state.sourceToken,this.sourceTokenAmount=n.state.sourceTokenAmount,this.sourceTokenPriceInUSD=n.state.sourceTokenPriceInUSD,this.toToken=n.state.toToken,this.toTokenAmount=n.state.toTokenAmount,this.toTokenPriceInUSD=n.state.toTokenPriceInUSD,this.inputError=n.state.inputError,this.fetchError=n.state.fetchError,this.lastTokenPriceUpdate=0,this.minTokenPriceUpdateInterval=1e4,this.visibilityChangeHandler=()=>{document!=null&&document.hidden?(clearInterval(this.interval),this.interval=void 0):this.startTokenPriceInterval()},this.startTokenPriceInterval=()=>{this.interval&&Date.now()-this.lastTokenPriceUpdate<this.minTokenPriceUpdateInterval||(this.lastTokenPriceUpdate&&Date.now()-this.lastTokenPriceUpdate>this.minTokenPriceUpdateInterval&&this.fetchTokensAndValues(),clearInterval(this.interval),this.interval=setInterval(()=>{this.fetchTokensAndValues()},this.minTokenPriceUpdateInterval))},this.watchTokensAndValues=()=>{!this.sourceToken||!this.toToken||(this.subscribeToVisibilityChange(),this.startTokenPriceInterval())},this.onDebouncedGetSwapCalldata=M.debounce(async()=>{await n.swapTokens()},200),U.subscribeKey("activeCaipNetwork",i=>this.onCaipNetworkChange({newCaipNetwork:i,resetSwapState:!0,initializeSwapState:!1})),L.subscribeKey("caipAddress",i=>this.onCaipAddressChange({newCaipAddress:i,resetSwapState:!0,initializeSwapState:!1}
446)),this.unsubscribe.push(U.subscribeKey("activeCaipNetwork",i=>this.onCaipNetworkChange({newCaipNetwork:i,resetSwapState:!1,initializeSwapState:!0})),L.subscribeKey("caipAddress",i=>this.onCaipAddressChange({newCaipAddress:i,resetSwapState:!1,initializeSwapState:!0})),F.subscribeKey("open",i=>{i||n.resetState()}),S.subscribeKey("view",i=>{i.includes("Swap")||n.resetValues()}),n.subscribe(i=>{this.initialized=i.initialized,this.loadingQuote=i.loadingQuote,this.loadingPrices=i.loadingPrices,this.loadingTransaction=i.loadingTransaction,this.sourceToken=i.sourceToken,this.sourceTokenAmount=i.sourceTokenAmount,this.sourceTokenPriceInUSD=i.sourceTokenPriceInUSD,this.toToken=i.toToken,this.toTokenAmount=i.toTokenAmount,this.toTokenPriceInUSD=i.toTokenPriceInUSD,this.inputError=i.inputError,this.fetchError=i.fetchError,i.sourceToken&&i.toToken&&this.watchTokensAndValues()}))}async firstUpdated(){n.initializeState(),this.watchTokensAndValues(),await this.handleSwapParameters()}disconnectedCallback(){this.unsubscribe.forEach(e=>e==null?void 0:e()),clearInterval(this.interval),document==null||document.removeEventListener("visibilitychange",this.visibilityChangeHandler)}render(){return c` 447 <wui-flex flexDirection="column" .padding=${["0","l","l","l"]} gap="s"> 448 ${this.initialized?this.templateSwap():this.templateLoading()} 449 </wui-flex> 450 `}subscribeToVisibilityChange(){document==null||document.removeEventListener("visibilitychange",this.visibilityChangeHandler),document==null||document.addEventListener("visibilitychange",this.visibilityChangeHandler)}fetchTokensAndValues(){n.getNetworkTokenPrice(),n.getMyTokensWithBalance(),n.swapTokens(),this.lastTokenPriceUpdate=Date.now()}templateSwap(){return c` 451 <wui-flex flexDirection="column" gap="s"> 452 <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container"> 453 ${this.templateTokenInput("sourceToken",this.sourceToken)} 454 ${this.templateTokenInput("toToken",this.toToken)} ${this.templateReplaceTokensButton()} 455 </wui-flex> 456 ${this.templateDetails()} ${this.templateActionButton()} 457 </wui-flex> 458 `}actionButtonLabel(){return this.fetchError?"Swap":!this.sourceToken||!this.toToken?"Select token":this.sourceTokenAmount?this.inputError?this.inputError:"Review swap":"Enter amount"}templateReplaceTokensButton(){return c` 459 <wui-flex class="replace-tokens-button-container"> 460 <button @click=${this.onSwitchTokens.bind(this)}> 461 <wui-icon name="recycleHorizontal" color="fg-250" size="lg"></wui-icon> 462 </button> 463 </wui-flex> 464 `}templateLoading(){return c` 465 <wui-flex flexDirection="column" gap="l"> 466 <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container"> 467 <w3m-swap-input-skeleton target="sourceToken"></w3m-swap-input-skeleton> 468 <w3m-swap-input-skeleton target="toToken"></w3m-swap-input-skeleton> 469 ${this.templateReplaceTokensButton()} 470 </wui-flex> 471 ${this.templateActionButton()} 472 </wui-flex> 473 `}templateTokenInput(e,t){var l,b;const i=(l=n.state.myTokensWithBalance)==null?void 0:l.find(I=>(I==null?void 0:I.address)===(t==null?void 0:t.address)),s=e==="toToken"?this.toTokenAmount:this.sourceTokenAmount,o=e==="toToken"?this.toTokenPriceInUSD:this.sourceTokenPriceInUSD,r=h.parseLocalStringToNumber(s)*o;return c`<w3m-swap-input 474 .value=${e==="toToken"?this.toTokenAmount:this.sourceTokenAmount} 475 .disabled=${e==="toToken"} 476 .onSetAmount=${this.handleChangeAmount.bind(this)} 477 target=${e} 478 .token=${t} 479 .balance=${(b=i==null?void 0:i.quantity)==null?void 0:b.numeric} 480 .price=${i==null?void 0:i.price} 481 .marketValue=${r} 482 .onSetMaxValue=${this.onSetMaxValue.bind(this)} 483 ></w3m-swap-input>`}onSetMaxValue(e,t){const i=h.bigNumber(t||"0");this.handleChangeAmount(e,i.gt(0)?i.toFixed(20):"0")}templateDetails(){return!this.sourceToken||!this.toToken||this.inputError?null:c`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`}handleChangeAmount(e,t){n.clearError(),e==="sourceToken"?n.setSourceTokenAmount(t):n.setToTokenAmount(t),this.onDebouncedGetSwapCalldata()}templateActionButton(){const e=!this.toToken||!this.sourceToken,t=!this.sourceTokenAmount,i=this.loadingQuote||this.loadingPrices||this.loadingTransaction,s=i||e||t||this.inputError;return c` <wui-flex gap="xs"> 484 <wui-button 485 data-testid="swap-action-button" 486 class="action-button" 487 fullWidth 488 size="lg" 489 borderRadius="xs" 490 variant=${e?"neutral":"main"} 491 .loading=${i} 492 .disabled=${s} 493 @click=${this.onSwapPreview.bind(this)} 494 > 495 ${this.actionButtonLabel()} 496 </wui-button>
496 497 </wui-flex>`}onSwitchTokens(){n.switchTokens()}async onSwapPreview(){var e,t;this.fetchError&&await n.swapTokens(),W.sendEvent({type:"track",event:"INITIATE_SWAP",properties:{network:this.caipNetworkId||"",swapFromToken:((e=this.sourceToken)==null?void 0:e.symbol)||"",swapToToken:((t=this.toToken)==null?void 0:t.symbol)||"",swapFromAmount:this.sourceTokenAmount||"",swapToAmount:this.toTokenAmount||"",isSmartAccount:Q(U.state.activeChain)===q.ACCOUNT_TYPES.SMART_ACCOUNT}}),S.push("SwapPreview")}async handleSwapParameters(){this.initialParams&&(n.state.initialized||await new Promise(t=>{const i=n.subscribeKey("initialized",s=>{s&&(i==null||i(),t())})}),await this.setSwapParameters(this.initialParams))}async setSwapParameters({amount:e,fromToken:t,toToken:i}){(!n.state.tokens||!n.state.myTokensWithBalance)&&await new Promise(r=>{const l=n.subscribeKey("myTokensWithBalance",b=>{b&&b.length>0&&(l==null||l(),r())});setTimeout(()=>{l==null||l(),r()},5e3)});const s=[...n.state.tokens||[],...n.state.myTokensWithBalance||[]];if(t){const o=s.find(r=>r.symbol.toLowerCase()===t.toLowerCase());o&&n.setSourceToken(o)}if(i){const o=s.find(r=>r.symbol.toLowerCase()===i.toLowerCase());o&&n.setToToken(o)}e&&!isNaN(Number(e))&&n.setSourceTokenAmount(e)}onCaipAddressChange({newCaipAddress:e,resetSwapState:t,initializeSwapState:i}){this.caipAddress!==e&&(this.caipAddress=e,t&&n.resetState(),i&&n.initializeState())}onCaipNetworkChange({newCaipNetwork:e,resetSwapState:t,initializeSwapState:i}){this.caipNetworkId!==(e==null?void 0:e.caipNetworkId)&&(this.caipNetworkId=e==null?void 0:e.caipNetworkId,t&&n.resetState(),i&&n.initializeState())}};p.styles=te;w([g({type:Object})],p.prototype,"initialParams",void 0);w([a()],p.prototype,"interval",void 0);w([a()],p.prototype,"detailsOpen",void 0);w([a()],p.prototype,"caipAddress",void 0);w([a()],p.prototype,"caipNetworkId",void 0);w([a()],p.prototype,"initialized",void 0);w([a()],p.prototype,"loadingQuote",void 0);w([a()],p.prototype,"loadingPrices",void 0);w([a()],p.prototype,"loadingTransaction",void 0);w([a()],p.prototype,"sourceToken",void 0);w([a()],p.prototype,"sourceTokenAmount",void 0);w([a()],p.prototype,"sourceTokenPriceInUSD",void 0);w([a()],p.prototype,"toToken",void 0);w([a()],p.prototype,"toTokenAmount",void 0);w([a()],p.prototype,"toTokenPriceInUSD",void 0);w([a()],p.prototype,"inputError",void 0);w([a()],p.prototype,"fetchError",void 0);w([a()],p.prototype,"lastTokenPriceUpdate",void 0);p=w([D("w3m-swap-view")],p);const ie=A` 498 :host > wui-flex:first-child { 499 overflow-y: auto; 500 overflow-x: hidden; 501 scrollbar-width: none; 502 } 503 504 :host > wui-flex:first-child::-webkit-scrollbar {
505 display: none; 506 } 507 508 .preview-container, 509 .details-container { 510 width: 100%; 511 } 512 513 .token-image { 514 width: 24px; 515 height: 24px; 516 box-shadow: 0 0 0 2px var(--wui-color-gray-glass-005); 517 border-radius: 12px; 518 } 519 520 wui-loading-hexagon { 521 position: absolute; 522 } 523 524 .token-item { 525 display: flex; 526 align-items: center; 527 justify-content: center; 528 gap: var(--wui-spacing-xxs); 529 padding: var(--wui-spacing-xs); 530 height: 40px; 531 border: none; 532 border-radius: 80px; 533 background: var(--wui-color-gray-glass-002); 534 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-002); 535 cursor: pointer; 536 transition: background 0.2s linear; 537 } 538 539 .token-item:hover { 540 background: var(--wui-color-gray-glass-005); 541 } 542 543 .preview-token-details-container { 544 width: 100%; 545 } 546 547 .details-row { 548 width: 100%; 549 padding: var(--wui-spacing-s) var(--wui-spacing-xl); 550 border-radius: var(--wui-border-radius-xxs); 551 background: var(--wui-color-gray-glass-002); 552 } 553 554 .action-buttons-container { 555 width: 100%; 556 gap: var(--wui-spacing-xs); 557 } 558 559 .action-buttons-container > button { 560 display: flex; 561 align-items: center; 562 justify-content: center; 563 background: transparent; 564 height: 48px; 565 border-radius: var(--wui-border-radius-xs); 566 border: none; 567 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010); 568 } 569 570 .action-buttons-container > button:disabled { 571 opacity: 0.8; 572 cursor: not-allowed; 573 } 574 575 .action-button > wui-loading-spinner { 576 display: inline-block; 577 } 578 579 .cancel-button:hover, 580 .action-button:hover { 581 cursor: pointer; 582 } 583 584 .action-buttons-container > wui-button.cancel-button { 585 flex: 2; 586 } 587 588 .action-buttons-container > wui-button.action-button { 589 flex: 4; 590 } 591 592 .action-buttons-container > button.action-button > wui-text { 593 color: white; 594 } 595 596 .details-container > wui-flex { 597 background: var(--wui-color-gray-glass-002); 598 border-radius: var(--wui-border-radius-xxs); 599 width: 100%; 600 } 601 602 .details-container > wui-flex > button { 603 border: none; 604 background: none; 605 padding: var(--wui-spacing-s); 606 border-radius: var(--wui-border-radius-xxs); 607 transition: background 0.2s linear; 608 } 609 610 .details-container > wui-flex > button:hover { 611 background: var(--wui-color-gray-glass-002); 612 } 613 614 .details-content-container { 615 padding: var(--wui-spacing-1xs); 616 display: flex; 617 align-items: center; 618 justify-content: center; 619 } 620 621 .details-content-container > wui-flex { 622 width: 100%; 623 } 624 625 .details-row { 626 width: 100%; 627 padding: var(--wui-spacing-s) var(--wui-spacing-xl); 628 border-radius: var(--wui-border-radius-xxs); 629 background: var(--wui-color-gray-glass-002); 630 } 631`;var f=function(u,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(u,e,t,i);else for(var l=u.length-1;l>=0;l--)(r=u[l])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};let d=class extends P{constructor(){super(),this.unsubscribe=[],this.detailsOpen=!0,this.approvalTransaction=n.state.approvalTransaction,this.swapTransaction=n.state.swapTransaction,this.sourceToken=n.state.sourceToken,this.sourceTokenAmount=n.state.sourceTokenAmount??"",this.sourceTokenPriceInUSD=n.state.sourceTokenPriceInUSD,this.toToken=n.state.toToken,this.toTokenAmount=n.state.toTokenAmount??"",this.toTokenPriceInUSD=n.state.toTokenPriceInUSD,this.caipNetwork=U.state.activeCaipNetwork,this.balanceSymbol=L.state.balanceSymbol,this.inputError=n.state.inputError,this.loadingQuote=n.state.loadingQuote,this.loadingApprovalTransaction=n.state.loadingApprovalTransaction,this.loadingBuildTransaction=n.state.loadingBuildTransaction,this.loadingTransaction=n.state.loadingTransaction,this.unsubscribe.push(L.subscribeKey("balanceSymbol",e=>{this.balanceSymbol!==e&&S.goBack()}),U.subscribeKey("activeCaipNetwork",e=>{this.caipNetwork!==e&&(this.caipNetwork=e)}),n.subscribe(e=>{this.approvalTransaction=e.approvalTransaction,this.swapTransaction=e.swapTransaction,this.sourceToken=e.sourceToken,this.toToken=e.toToken,this.toTokenPriceInUSD=e.toTokenPriceInUSD,this.sourceTokenAmount=e.sourceTokenAmount??"",this.toTokenAmount=e.toTokenAmount??"",this.inputError=e.inputError,e.inputError&&S.goBack(),this.loadingQuote=e.loadingQuote,this.loadingApprovalTransaction=e.loadingApprovalTransaction,this.loadingBuildTransaction=e.loadingBuildTransaction,this.loadingTransaction=e.loadingTransaction}))}firstUpdated(){n.getTransaction(),this.refreshTransaction()}
631disconnectedCallback(){this.unsubscribe.forEach(e=>e==null?void 0:e()),clearInterval(this.interval)}render(){return c` 632 <wui-flex flexDirection="column" .padding=${["0","l","l","l"]} gap="s"> 633 ${this.templateSwap()} 634 </wui-flex> 635 `}refreshTransaction(){this.interval=setInterval(()=>{n.getApprovalLoadingState()||n.getTransaction()},1e4)}templateSwap(){var b,I,_,E;const e=`${h.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${(b=this.sourceToken)==null?void 0:b.symbol}`,t=`${h.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${(I=this.toToken)==null?void 0:I.symbol}`,i=parseFloat(this.sourceTokenAmount)*this.sourceTokenPriceInUSD,s=parseFloat(this.toTokenAmount)*this.toTokenPriceInUSD,o=h.formatNumberToLocalString(i),r=h.formatNumberToLocalString(s),l=this.loadingQuote||this.loadingBuildTransaction||this.loadingTransaction||this.loadingApprovalTransaction;return c` 636 <wui-flex flexDirection="column" alignItems="center" gap="l"> 637 <wui-flex class="preview-container" flexDirection="column" alignItems="flex-start" gap="l"> 638 <wui-flex 639 class="preview-token-details-container" 640 alignItems="center" 641 justifyContent="space-between" 642 gap="l" 643 > 644 <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs"> 645 <wui-text variant="small-400" color="fg-150">Send</wui-text> 646 <wui-text variant="paragraph-400" color="fg-100">$${o}</wui-text> 647 </wui-flex> 648 <wui-token-button 649 flexDirection="row-reverse" 650 text=${e} 651 imageSrc=${(_=this.sourceToken)==null?void 0:_.logoUri} 652 > 653 </wui-token-button> 654 </wui-flex> 655 <wui-icon name="recycleHorizontal" color="fg-200" size="md"></wui-icon> 656 <wui-flex 657 class="preview-token-details-container" 658 alignItems="center" 659 justifyContent="space-between" 660 gap="l" 661 > 662 <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs"> 663 <wui-text variant="small-400" color="fg-150">Receive</wui-text> 664 <wui-text variant="paragraph-400" color="fg-100">$${r}</wui-text> 665 </wui-flex> 666 <wui-token-button 667 flexDirection="row-reverse" 668 text=${t} 669 imageSrc=${(E=this.toToken)==null?void 0:E.logoUri} 670 > 671 </wui-token-button> 672 </wui-flex> 673 </wui-flex> 674 675 ${this.templateDetails()} 676 677 <wui-flex flexDirection="row" alignItems="center" justifyContent="center" gap="xs"> 678 <wui-icon size="sm" color="fg-200" name="infoCircle"></wui-icon> 679 <wui-text variant="small-400" color="fg-200">Review transaction carefully</wui-text> 680 </wui-flex> 681 682 <wui-flex 683 class="action-buttons-container" 684 flexDirection="row" 685 alignItems="center" 686 justifyContent="space-between" 687 gap="xs" 688 > 689 <wui-button 690 class="cancel-button" 691 fullWidth 692 size="lg" 693 borderRadius="xs" 694 variant="neutral" 695 @click=${this.onCancelTransaction.bind(this)} 696 > 697 <wui-text variant="paragraph-600" color="fg-200">Cancel</wui-text> 698 </wui-button> 699 <wui-button 700 class="action-button" 701 fullWidth 702 size="lg" 703 borderRadius="xs" 704 variant="main" 705 ?loading=${l} 706 ?disabled=${l} 707 @click=${this.onSendTransaction.bind(this)} 708 > 709 <wui-text variant="paragraph-600" color="inverse-100"> 710 ${this.actionButtonLabel()} 711 </wui-text> 712 </wui-button> 713 </wui-flex> 714 </wui-flex> 715 `}templateDetails(){return!this.sourceToken||!this.toToken||this.inputError?null:c`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`}actionButtonLabel(){return this.loadingApprovalTransaction?"Approving...":this.approvalTransaction?"Approve":"Swap"}onCancelTransaction(){S.goBack()}onSendTransaction(){this.approvalTransaction?n.sendTransactionForApproval(this.approvalTransaction):n.sendTransactionForSwap(this.swapTransaction)}};d.styles=ie;f([a()],d.prototype,"interval",void 0);f([a()],d.prototype,"detailsOpen",void 0);f([a()],d.prototype,"approvalTransaction",void 0);f([a()],d.prototype,"swapTransaction",void 0);f([a()],d.prototype,"sourceToken",void 0);f([a()],d.prototype,"sourceTokenAmount",void 0);f([a()],d.prototype,"sourceTokenPriceInUSD",void 0);f([a()],d.prototype,"toToken",void 0);f([a()],d.prototype,"toTokenAmount",void 0);f([a()],d.prototype,"toTokenPriceInUSD",void 0);f([a()],d.prototype,"caipNetwork",void 0);f([a()],d.prototype,"balanceSymbol",void 0);f([a()],d.prototype,"inputError",void 0);f([a()],d.prototype,"loadingQuote",void 0);f([a()],d.prototype,"loadingApprovalTransaction",void 0);f([a()],d.prototype,"loadingBuildTransaction",void 0);f([a()],d.prototype,"loadingTransaction",void 0);d=f([D("w3m-swap-preview-view")],d);const oe=A` 716 :host { 717 height: 60px; 718 min-height: 60px; 719 } 720 721 :host > wui-flex { 722 cursor: pointer; 723 height: 100%; 724 display: flex; 725 column-gap: var(--wui-spacing-s); 726 padding: var(--wui-spacing-xs); 727 padding-right: var(--wui-spacing-l); 728 width: 100%; 729 background-color: transparent; 730 border-radius: var(--wui-border-radius-xs); 731 color: var(--wui-color-fg-250); 732 transition: 733 background-color var(--wui-ease-out-power-1) var(--wui-duration-lg), 734 opacity var(--wui-ease-out-power-1) var(--wui-duration-lg); 735 will-change: background-color, opacity; 736 } 737 738 @media (hover: hover) and (pointer: fine) { 739 :host > wui-flex:hover { 740 background-color: var(--wui-color-gray-glass-002); 741 } 742 743 :host > wui-flex:active { 744 background-color: var(--wui-color-gray-glass-005); 745 } 746 } 747 748 :host([disabled]) > wui-flex { 749 opacity: 0.6; 750 } 751 752 :host([disabled]) > wui-flex:hover { 753 background-color: transparent; 754 } 755 756 :host > wui-flex > wui-flex { 757 flex: 1; 758 } 759 760 :host > wui-flex > wui-image, 761 :host > wui-flex > .token-item-image-placeholder { 762 width: 40px; 763 max-width: 40px; 764 height: 40px; 765 border-radius: var(--wui-border-radius-3xl); 766 position: relative; 767 } 768 769 :host > wui-flex > .token-item-image-placeholder { 770 display: flex; 771 align-items: center; 772 justify-content: center; 773 } 774 775 :host > wui-flex > wui-image::after, 776 :host > wui-flex > .token-item-image-placeholder::after { 777 position: absolute; 778 content: ''; 779 inset: 0; 780 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010); 781 border-radius: var(--wui-border-radius-l); 782 } 783 784 button > wui-icon-box[data-variant='square-blue'] { 785 border-radius: var(--wui-border-radius-3xs); 786 position: relative; 787 border: none; 788 width: 36px; 789 height: 36px; 790 } 791`;var C=function(u,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(u,e,t,i);else for(var l=u.length-1;l>=0;l--)(r=u[l])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};let $=class extends P{constructor(){super(),this.observer=new IntersectionObserver(()=>{}),this.imageSrc=void 0,this.name=void 0,this.symbol=void 0,this.price=void 0,this.amount=void 0,this.visible=!1,this.imageError=!1,this.observer=new IntersectionObserver(e=>{e.forEach(t=>{t.isIntersecting?this.visible=!0:this.visible=!1})},{threshold:.1})}firstUpdated(){this.observer.observe(this)}disconnectedCallback(){this.observer.disconnect()}render(){var t;if(!this.visible)return null;const e=this.amount&&this.price?(t=h.multiply(this.price,this.amount))==null?void 0:t.toFixed(3):null;return c` 792 <wui-flex alignItems="center"> 793 ${this.visualTemplate()} 794 <wui-flex flexDirection="column" gap="3xs"> 795 <wui-flex justifyContent="space-between"> 796 <wui-text variant="paragraph-500" color="fg-100" lineClamp="1">${this.name}</wui-text> 797 ${e?c` 798 <wui-text variant="paragraph-500" color="fg-100"> 799 $${h.formatNumberToLocalString(e,3)} 800 </wui-text> 801 `:null} 802 </wui-flex> 803 <wui-flex justifyContent="space-between"> 804 <wui-text variant="small-400" color="fg-200" lineClamp="1">${this.symbol}</wui-text> 805 ${this.amount?c`<wui-text variant="small-400" color="fg-200"> 806 ${h.formatNumberToLocalString(this.amount,5)} 807 </wui-text>`:null} 808 </wui-flex> 809 </wui-flex> 810 </wui-flex> 811 `}visualTemplate(){return this.imageError?c`<wui-flex class="token-item-image-placeholder"> 812 <wui-icon name="image" color="inherit"></wui-icon> 813 </wui-flex>`:this.imageSrc?c`<wui-image 814 width="40" 815 height="40" 816 src=${this.imageSrc} 817 @onLoadError=${this.imageLoadError} 818 ></wui-image>`:null}imageLoadError(){this.imageError=!0}};$.styles=[z,H,oe];C([g()],$.prototype,"imageSrc",void 0);C([g()],$.prototype,"name",void 0);C([g()],$.prototype,"symbol",void 0);C([g()],$.prototype,"price",void 0);C([g()],$.prototype,"amount",void 0);C([a()],$.prototype,"visible",void 0);C([a()],$.prototype,"imageError",void 0);$=C([D("wui-token-list-item")],$);const ne=A` 819 :host > wui-flex:first-child { 820 column-gap: var(--wui-spacing-s); 821 padding: 7px var(--wui-spacing-l) 7px var(--wui-spacing-xs); 822 width: 100%; 823 } 824 825 wui-flex { 826 display: flex; 827 flex: 1; 828 } 829`;var se=function(u,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(u,e,t,i);else for(var l=u.length-1;l>=0;l--)(r=u[l])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};let N=class extends P{render(){return c` 830 <wui-flex alignItems="center"> 831 <wui-shimmer width="40px" height="40px"></wui-shimmer> 832 <wui-flex flexDirection="column" gap="2xs"> 833 <wui-shimmer width="72px" height="16px" borderRadius="4xs"></wui-shimmer> 834 <wui-shimmer width="148px" height="14px" borderRadius="4xs"></wui-shimmer> 835 </wui-flex> 836 <wui-flex flexDirection="column" gap="2xs" alignItems="flex-end"> 837 <wui-shimmer width="24px" height="12px" borderRadius="4xs"></wui-shimmer> 838 <wui-shimmer width="32px" height="12px" borderRadius="4xs"></wui-shimmer> 839 </wui-flex> 840 </wui-flex> 841 `}};N.styles=[z,ne];N=se([D("wui-token-list-item-loader")],N);const re=A` 842 :host { 843 --tokens-scroll--top-opacity: 0; 844 --tokens-scroll--bottom-opacity: 1; 845 --suggested-tokens-scroll--left-opacity: 0; 846 --suggested-tokens-scroll--right-opacity: 1; 847 } 848 849 :host > wui-flex:first-child { 850 overflow-y: hidden; 851 overflow-x: hidden; 852 scrollbar-width: none; 853 scrollbar-height: none; 854 } 855 856 :host > wui-flex:first-child::-webkit-scrollbar {
857 display: none; 858 } 859 860 wui-loading-hexagon { 861 position: absolute; 862 } 863 864 .suggested-tokens-container { 865 overflow-x: auto; 866 mask-image: linear-gradient( 867 to right, 868 rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 0px, 869 rgba(200, 200, 200, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 1px, 870 black 50px, 871 black 90px, 872 black calc(100% - 90px), 873 black calc(100% - 50px), 874 rgba(155, 155, 155, calc(1 - var(--suggested-tokens-scroll--right-opacity))) calc(100% - 1px), 875 rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--right-opacity))) 100% 876 ); 877 } 878 879 .suggested-tokens-container::-webkit-scrollbar { 880 display: none; 881 } 882 883 .tokens-container { 884 border-top: 1px solid var(--wui-color-gray-glass-005); 885 height: 100%; 886 max-height: 390px; 887 } 888 889 .tokens { 890 width: 100%; 891 overflow-y: auto; 892 mask-image: linear-gradient( 893 to bottom, 894 rgba(0, 0, 0, calc(1 - var(--tokens-scroll--top-opacity))) 0px, 895 rgba(200, 200, 200, calc(1 - var(--tokens-scroll--top-opacity))) 1px, 896 black 50px, 897 black 90px, 898 black calc(100% - 90px), 899 black calc(100% - 50px), 900 rgba(155, 155, 155, calc(1 - var(--tokens-scroll--bottom-opacity))) calc(100% - 1px), 901 rgba(0, 0, 0, calc(1 - var(--tokens-scroll--bottom-opacity))) 100% 902 ); 903 } 904 905 .network-search-input, 906 .select-network-button { 907 height: 40px; 908 } 909 910 .select-network-button { 911 border: none; 912 display: flex; 913 flex-direction: row; 914 align-items: center; 915 justify-content: center; 916 gap: var(--wui-spacing-xs); 917 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-005); 918 background-color: transparent; 919 border-radius: var(--wui-border-radius-xxs); 920 padding: var(--wui-spacing-xs); 921 align-items: center; 922 transition: background-color 0.2s linear; 923 } 924 925 .select-network-button:hover { 926 background-color: var(--wui-color-gray-glass-002); 927 } 928 929 .select-network-button > wui-image { 930 width: 26px; 931 height: 26px; 932 border-radius: var(--wui-border-radius-xs); 933 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010); 934 } 935`;var y=function(u,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(u,e,t,i);else for(var l=u.length-1;l>=0;l--)(r=u[l])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};let k=class extends P{constructor(){var e;super(),this.unsubscribe=[],this.targetToken=(e=S.state.data)==null?void 0:e.target,this.sourceToken=n.state.sourceToken,this.sourceTokenAmount=n.state.sourceTokenAmount,this.toToken=n.state.toToken,this.myTokensWithBalance=n.state.myTokensWithBalance,this.popularTokens=n.state.popularTokens,this.suggestedTokens=n.state.suggestedTokens,this.tokensLoading=n.state.tokensLoading,this.searchValue="",this.unsubscribe.push(n.subscribe(t=>{this.sourceToken=t.sourceToken,this.toToken=t.toToken,this.myTokensWithBalance=t.myTokensWithBalance,this.popularTokens=t.popularTokens,this.suggestedTokens=t.suggestedTokens,this.tokensLoading=t.tokensLoading}))}async firstUpdated(){await n.getTokenList()}updated(){var i,s;const e=(i=this.renderRoot)==null?void 0:i.querySelector(".suggested-tokens-container");e==null||e.addEventListener("scroll",this.handleSuggestedTokensScroll.bind(this));const t=(s=this.renderRoot)==null?void 0:s.querySelector(".tokens");t==null||t.addEventListener("scroll",this.handleTokenListScroll.bind(this))}disconnectedCallback(){var i,s;super.disconnectedCallback();const e=(i=this.renderRoot)==null?void 0:i.querySelector(".suggested-tokens-container"),t=(s=this.renderRoot)==null?void 0:s.querySelector(".tokens");e==null||e.removeEventListener("scroll",this.handleSuggestedTokensScroll.bind(this)),t==null||t.removeEventListener("scroll",this.handleTokenListScroll.bind(this)),clearInterval(this.interval)}render(){return c` 936 <wui-flex flexDirection="column" gap="s"> 937 ${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()} 938 </wui-flex> 939 `}onSelectToken(e){this.targetToken==="sourceToken"?n.setSourceToken(e):(n.setToToken(e),this.sourceToken&&this.sourceTokenAmount&&n.swapTokens()),S.goBack()}templateSearchInput(){return c` 940 <wui-flex .padding=${["3xs","s","0","s"]} gap="xs"> 941 <wui-input-text 942 data-testid="swap-select-token-search-input" 943 class="network-search-input" 944 size="sm" 945 placeholder="Search token" 946 icon="search" 947 .value=${this.searchValue} 948 @inputChange=${this.onSearchInputChange.bind(this)} 949 ></wui-input-text> 950 </wui-flex> 951 `}templateMyTokens(){const e=this.myTokensWithBalance?Object.values(this.myTokensWithBalance):[],t=this.filterTokensWithText(e,this.searchValue);return(t==null?void 0:t.length)>0?c`<wui-flex justifyContent="flex-start" padding="s"> 952 <wui-text variant="paragraph-500" color="fg-200">Your tokens</wui-text> 953 </wui-flex> 954 ${t.map(i=>{var o,r,l;const s=i.symbol===((o=this.sourceToken)==null?void 0:o.symbol)||i.symbol===((r=this.toToken)==null?void 0:r.symbol);return c` 955 <wui-token-list-item 956 data-testid="swap-select-token-item-${i.symbol}" 957 name=${i.name} 958 ?disabled=${s} 959 symbol=${i.symbol} 960 price=${i==null?void 0:i.price} 961 amount=${(l=i==null?void 0:i.quantity)==null?void 0:l.numeric} 962 imageSrc=${i.logoUri} 963 @click=${()=>{s||this.onSelectToken(i)}} 964 > 965 </wui-token-list-item> 966 `})}`:null}templateAllTokens(){const e=this.popularTokens?this.popularTokens:[],t=this.filterTokensWithText(e,this.searchValue);return this.tokensLoading?c` 967 <wui-token-list-item-loader></wui-token-list-item-loader> 968 <wui-token-list-item-loader></wui-token-list-item-loader> 969 <wui-token-list-item-loader></wui-token-list-item-loader> 970 <wui-token-list-item-loader></wui-token-list-item-loader> 971 <wui-token-list-item-loader></wui-token-list-item-loader> 972 `:(t==null?void 0:t.length)>0?c` 973 ${t.map(i=>c` 974 <wui-token-list-item 975 data-testid="swap-select-token-item-${i.symbol}" 976 name=${i.name} 977 symbol=${i.symbol} 978 imageSrc=${i.logoUri} 979 @click=${()=>this.onSelectToken(i)} 980 > 981 </wui-token-list-item> 982 `)} 983 `:null}templateTokens(){return c` 984 <wui-flex class="tokens-container"> 985 <wui-flex class="tokens" .padding=${["0","s","s","s"]} flexDirection="column"> 986 ${this.templateMyTokens()} 987 <wui-flex justifyContent="flex-start" padding="s"> 988 <wui-text variant="paragraph-500" color="fg-200">Tokens</wui-text> 989 </wui-flex> 990 ${this.templateAllTokens()} 991 </wui-flex> 992 </wui-flex> 993 `}templateSuggestedTokens(){const e=this.suggestedTokens?this.suggestedTokens.slice(0,8):null;return this.tokensLoading?c` 994 <wui-flex class="suggested-tokens-container" .padding=${["0","s","0","s"]} gap="xs"> 995 <wui-token-button loading></wui-token-button>
995 996 <wui-token-button loading></wui-token-button> 997 <wui-token-button loading></wui-token-button> 998 <wui-token-button loading></wui-token-button> 999 <wui-token-button loading></wui-token-button> 1000 </wui-flex> 1001 `:e?c` 1002 <wui-flex class="suggested-tokens-container" .padding=${["0","s","0","s"]} gap="xs"> 1003 ${e.map(t=>c` 1004 <wui-token-button 1005 text=${t.symbol} 1006 imageSrc=${t.logoUri} 1007 @click=${()=>this.onSelectToken(t)} 1008 > 1009 </wui-token-button> 1010 `)} 1011 </wui-flex> 1012 `:null}onSearchInputChange(e){this.searchValue=e.detail}handleSuggestedTokensScroll(){var t;const e=(t=this.renderRoot)==null?void 0:t.querySelector(".suggested-tokens-container");e&&(e.style.setProperty("--suggested-tokens-scroll--left-opacity",j.interpolate([0,100],[0,1],e.scrollLeft).toString()),e.style.setProperty("--suggested-tokens-scroll--right-opacity",j.interpolate([0,100],[0,1],e.scrollWidth-e.scrollLeft-e.offsetWidth).toString()))}handleTokenListScroll(){var t;const e=(t=this.renderRoot)==null?void 0:t.querySelector(".tokens");e&&(e.style.setProperty("--tokens-scroll--top-opacity",j.interpolate([0,100],[0,1],e.scrollTop).toString()),e.style.setProperty("--tokens-scroll--bottom-opacity",j.interpolate([0,100],[0,1],e.scrollHeight-e.scrollTop-e.offsetHeight).toString()))}filterTokensWithText(e,t){return e.filter(i=>`${i.symbol} ${i.name} ${i.address}`.toLowerCase().includes(t.toLowerCase())).sort((i,s)=>{const o=`${i.symbol} ${i.name} ${i.address}`.toLowerCase(),r=`${s.symbol} ${s.name} ${s.address}`.toLowerCase(),l=o.indexOf(t.toLowerCase()),b=r.indexOf(t.toLowerCase());return l-b})}};k.styles=re;y([a()],k.prototype,"interval",void 0);y([a()],k.prototype,"targetToken",void 0);y([a()],k.prototype,"sourceToken",void 0);y([a()],k.prototype,"sourceTokenAmount",void 0);y([a()],k.prototype,"toToken",void 0);y([a()],k.prototype,"myTokensWithBalance",void 0);y([a()],k.prototype,"popularTokens",void 0);y([a()],k.prototype,"suggestedTokens",void 0);y([a()],k.prototype,"tokensLoading",void 0);y([a()],k.prototype,"searchValue",void 0);k=y([D("w3m-swap-select-token-view")],k);export{d as W3mSwapPreviewView,k as W3mSwapSelectTokenView,p as W3mSwapView};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.