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