1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="d16246d4-cf61-cb4f-9a85-c10729d01e14")}catch(e){}}(); 2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,127247,e=>{"use strict";var t=e.i(789477),n=e.i(696150);e.s(["EARN_PROJECTION_INSET",0,{top:8,bottom:0},"EARN_PROJECTION_VIEWBOX_HEIGHT",0,100,"EARN_PROJECTION_VIEWBOX_WIDTH",0,100,"EarnProjectionPlot",0,function({line:e,area:a}){let s=(0,n.useId)().replaceAll(":",""),i=`earn-projection-fill-${s}`,r=`earn-projection-hatch-${s}`,l=`earn-projection-shape-${s}`,o=`earn-projection-fade-${s}`,u=`earn-projection-fade-mask-${s}`,d=""===a?"":`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path fill="white" d="${a}"/></svg>`)}`;return(0,t.jsxs)("div",{className:"pointer-events-none absolute inset-0 text-green-700 dark:text-green-500",children:[(0,t.jsxs)("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",className:"absolute inset-0 size-full","aria-hidden":"true",focusable:"false",children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:i,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.24}),(0,t.jsx)("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:.04})]})}),(0,t.jsx)("path",{d:a,fill:`url(#${i})`}),(0,t.jsx)("path",{d:e,fill:"none",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]}),""===d?null:(0,t.jsxs)("svg",{className:"absolute inset-0 size-full","aria-hidden":"true",focusable:"false",children:[(0,t.jsxs)("defs",{children:[(0,t.jsx)("pattern",{id:r,width:6,height:6,patternUnits:"userSpaceOnUse",children:(0,t.jsx)("path",{d:"M5 0h1L0 6V5zM6 5v1H5z",fill:"currentColor",fillRule:"evenodd"})}),(0,t.jsx)("mask",{id:l,children:(0,t.jsx)("image",{href:d,width:"100%",height:"100%",preserveAspectRatio:"none"})}),(0,t.jsxs)("linearGradient",{id:o,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"0%",stopColor:"#ffffff"}),(0,t.jsx)("stop",{offset:"40%",stopColor:"#ffffff"}),(0,t.jsx)("stop",{offset:"100%",stopColor:"#000000"})]}),(0,t.jsx)("mask",{id:u,maskContentUnits:"objectBoundingBox",children:(0,t.jsx)("rect",{width:"1",height:"1",fill:`url(#${o})`})})]}),(0,t.jsx)("g",{mask:`url(#${l})`,children:(0,t.jsx)("rect",{width:"100%",height:"100%",fill:`url(#${r})`,mask:`url(#${u})`,opacity:.28})})]})]})}])},192580,e=>{"use strict";function t(e,t,n){return e<=0?0:e*(1+t/100)**n}function n(e){return 1.08*Math.max(...e,1)}function a(e,t,n,a,s,i){let r=Math.max(s-i.top-i.bottom,1);return{x:n/20*a,y:i.top+(1-e/t)*r}}e.s(["DEFAULT_PROJECTION_PRINCIPAL",0,1e3,"buildProjectionSeries",0,function(e,n,a=20,s=80){return Array.from({length:s+1},(i,r)=>t(e,n,a*r/s))},"formatProjectionAmount",0,function(e){return new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}).format(e)},"formatProjectionAxisAmount",0,function(e){return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(e)},"projectValue",0,t,"projectionAxisTicks",0,function(e,t=6){if(!(e>0))return[0];let n=e/Math.max(t-1,1),a=10**Math.floor(Math.log10(n)),s=n/a,i=(s>=Math.sqrt(50)?10:s>=Math.sqrt(10)?5:s>=Math.sqrt(2)?2:1)*a,r=[];for(let t=0;t<=e+.01*i;t+=i)r.push(Number(t.toPrecision(12)));return r},"projectionChartPaths",0,function(e,t,s,i){if(e.length<2)return{line:"",area:""};let r=n(e),l=e.map((n,l)=>a(n,r,l/(e.length-1)*20,t,s,i)),o=l[0],u=l.at(-1);if(null==o||null==u)return{line:"",area:""};let d=l.map((e,t)=>`${0===t?"M":"L"} ${e.x.toFixed(2)} ${e.y.toFixed(2)}`).join(" "),c=s-i.bottom,g=`${d} L ${u.x.toFixed(2)} ${c.toFixed(2)} L ${o.x.toFixed(2)} ${c.toFixed(2)} Z`;return{line:d,area:g}},"projectionHorizonYears",0,function(e){return[e,e+10,e+20]},"projectionHoverLabel",0,function(e,t){return t<=0?"Now":`Year ${e+t}`},"projectionPlotPoint",0,a,"projectionScaleMax",0,n,"resolveProjectionPrincipal",0,function(e,t=null){let n=function(e){let t=e.trim().replace(/,/g,"");if(""===t)return null;let n=Number(t);return!Number.isFinite(n)||n<=0?null:n}(e);return null!=n?n:null!=t&&Number.isFinite(t)&&t>0?t:1e3},"snapProjectionYear",0,function(e){return Number.isFinite(e)?Math.min(20,Math.max(0,Math.round(20*e))):0}])},623278,e=>{"use strict";var t=e.i(789477);let n={"kV-gtSOLb":(0,t.jsxs)(t.Fragment,{children:["This yield vault is managed by the"," ",(0,t.jsx)("a",{href:"https://www.gauntlet.xyz",target:"_blank",rel:"noreferrer",className:"text-gray-900 underline dark:text-white",children:"Gauntlet"})," ","team and is built on Solana. Deposit and withdraw in SOL, with a $25 minimum for each. Your balance is shown as a USDC estimate and changes with the SOL price and vault yield."]}),gtUSDCp:(0,t.jsxs)(t.Fragment,{children:["This yield vault is managed by the"," ",(0,t.jsx)("a",{href:"https://www.gauntlet.xyz",target:"_blank",rel:"noreferrer",className:"text-gray-900 underline dark:text-white",children:"Gauntlet"})," ","team and is built on the Base blockchain."]}),TLO:(0,t.jsxs)(t.Fragment,{children:["This yield vault is provided by Taler, a NEAR ecosystem company, and managed by the"," ",(0,t.jsx)("a",{href:"https://www.628labs.xyz",target:"_blank",rel:"noreferrer",className:"text-gray-900 underline dark:text-white",children:"TAU Labs"})," ","team, and is built on Ethereum."]})};e.s(["VAULT_INFO_BY_SYMBOL",0,n])},23632,e=>{"use strict";var t=e.i(789477),n=e.i(155978),a=e.i(328283),s=e.i(711776),i=e.i(67781),r=e.i(493266),l=e.i(966321),o=e.i(696150),u=e.i(268514),d=e.i(962595),c=e.i(704040),g=e.i(565982),m=e.i(723980),p=e.i(833118),f=e.i(634181);function h({vault:e,userAddress:n,userChainType:a}){let s=(0,o.useRef)(null),i=null!=n&&null!=a?c.authIdentity.authHandleToIntentsUserId(n,a):null,r=`${i??""}:${e.vaultToken.defuseAssetId}`,{balances:l}=(0,f.useVaultDepositedBalances)([e],n??null,a??null,{isConfidential:!0}),u=l.get(e.vaultToken.defuseAssetId),d=u?.hasBalance??!1,x=d?u?.usdcValue!=null?`~${(0,p.formatValueAmount)(u.usdcValue)} USDC`:"Loading":"0 USDC",y=null!=e.apr?`${e.apr.toFixed(2)}%`:"â",k=e.metadata?.rateType??"APR",E=e.metadata?.tvlUsd!=null?(0,m.formatUsdAmount)(e.metadata.tvlUsd):"â",C=e.metadata?.displayFees??[];return(0,o.useEffect)(()=>{d&&"Loading"!==x&&(s.current={key:r,label:x})},[r,d,x]),(0,t.jsxs)("dl",{className:"divide-y divide-gray-200 pt-2 xl:pt-0 dark:divide-white/10",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-5 pb-6",children:[(0,t.jsxs)("div",{className:"flex flex-col items-start gap-1.5",children:[(0,t.jsx)("dt",{className:"font-medium text-gray-500 text-sm/5 dark:text-gray-400",children:k}),(0,t.jsx)("dd",{className:"font-semibold text-gray-900 text-xl/6 tracking-tight dark:text-white",children:y})]}),(0,t.jsxs)("div",{className:"flex flex-col items-start gap-1.5",children:[(0,t.jsx)("dt",{className:"font-medium text-gray-500 text-sm/5 dark:text-gray-400",children:"TVL"}),(0,t.jsx)("dd",{className:"font-semibold text-gray-900 text-xl/6 tracking-tight dark:text-white",children:E})]})]}),(0,t.jsx)("div",{className:"space-y-4 pt-6 pb-3",children:C.map(e=>(0,t.jsxs)("div",{className:"grid grid-cols-2 items-baseline gap-5",children:[(0,t.jsxs)("dt",{className:"flex flex-col items-start gap-1 font-medium text-gray-500 text-sm/5 dark:text-gray-400",children:[(0,t.jsx)("span",{children:e.label}),null!=e.badge&&(0,t.jsx)(g.default,{variant:"info",size:"sm",hideIcon:!0,children:e.badge})]}),(0,t.jsxs)("dd",{className:"font-semibold text-gray-900 text-sm/5 tracking-tight dark:text-white",children:[e.value,null!=e.description&&(0,t.jsxs)("span",{className:"font-medium text-gray-500 tracking-normal dark:text-gray-400",children:[" ",e.description]})]})]},e.label))})]})}
2var x=e.i(657585),y=e.i(654409),k=e.i(18578),E=e.i(382075);function C({paymentToken:e,prefetchedBalances:t=null,lockToPaymentFamily:n=!1}){let a=y.SwapUIMachineContext.useActorRef(),i=(0,E.useSelector)(a,e=>e.children.depositedBalanceRef),r=(0,E.useSelector)(i,x.balancesSelector),l=(0,E.useSelector)(i,x.isBalancesLoadedSelector)?r:t??r,u=y.SwapUIMachineContext.useSelector(e=>e.context.parsedFormValues.amountIn),c=y.SwapUIMachineContext.useSelector(e=>e.context.formValues.tokenIn),g=(0,o.useMemo)(()=>n?[e]:(0,d.getEarnPaymentTokens)(e),[n,e]),m=(0,o.useMemo)(()=>null==l?null:(0,d.resolveEarnDepositTokenIn)(e,g,l,u,n&&!(0,s.isSamePaymentFamily)(e,c)?void 0:c),[l,c,n,u,e,g]);return(0,o.useEffect)(()=>{if(null==m)return;let e=a.getSnapshot(),t=e.context.formValues.tokenIn;if((0,k.getDefuseAssetId)(t)===m.defuseAssetId)return;let{amountIn:n,amountOut:s,tokenOut:i,swapType:r}=e.context.formValues;a.send({type:"input",params:{tokenIn:m,tokenOut:i,amountIn:n,amountOut:s,swapType:r}})},[c,m,a]),null}var I=e.i(735645),b=e.i(528973),T=e.i(75175),N=e.i(557518),w=e.i(891341),S=e.i(475317),v=e.i(786491),A=e.i(973736),_=e.i(881287),j=e.i(494438),R=e.i(895756),F=e.i(266437);e.i(484236);var D=e.i(49076),M=e.i(658077),L=e.i(2358),P=e.i(610901),U=e.i(593562),O=e.i(241258),V=e.i(377589),H=e.i(484776),B=e.i(6661),W=e.i(144045),q=e.i(517494),$=e.i(515725),G=e.i(482810),Q=e.i(718183),z=e.i(925419),K=e.i(157946),Y=e.i(641395),X=e.i(166786);let J=(0,G.percentToSlippageBasisPoints)(.1),Z=(0,o.createContext)({onSubmit:()=>{},isEarnDisabled:!0});function ee({children:e,mode:n,paymentToken:a,tokenIn:s,tokenOut:i,tokenList:r,signMessage:l,userAddress:c,userChainType:g,quickEarn:m}){let{setValue:p}=(0,u.useFormContext)(),f=(0,Q.getAppFeeRecipient)(),h=(0,U.usePrivateModeStore)(e=>e.isPrivateModeEnabled);(0,q.assert)(s&&i,"TokenIn and TokenOut must be defined");let x="deposit"===n&&m?.source==="main",k=(0,o.useMemo)(()=>(0,Y.createEarnQuoteClient)({landInConfidential:x}),[x]);return(0,t.jsxs)(y.SwapUIMachineContext.Provider,{options:{input:{tokenIn:s,tokenOut:i,tokenList:r,slippageBasisPoints:J,isConfidential:h,appFeeRecipient:f,quoteClient:k}},logic:W.swapUIMachine.provide({actions:{updateUIAmount:({context:e})=>{let t=e.quote,n=e.formValues.swapType===N.QuoteRequest.swapType.EXACT_INPUT?"amountOut":"amountIn";null===t||"err"===t.tag?p(n,e.formValues[n],{shouldValidate:!1}):(""!==e.formValues.amountIn||""!==e.formValues.amountOut)&&p(n,e.formValues[n],{shouldValidate:!0})}},actors:{swap1csActor:B.swapIntent1csMachine.provide({actors:{signMessage:(0,K.fromPromise)(({input:e})=>l(e))},guards:{isWorseThanPrevious:({context:e})=>(0,B.isQuoteWorseThanPrevious)(e,{minPercentChange:d.EARN_ESTIMATE_CHANGE_THRESHOLD_PERCENT})}})}}),children:[(0,t.jsx)(et,{userAddress:c,userChainType:g}),(0,t.jsx)(en,{}),(0,t.jsx)(ea,{mode:n,paymentToken:a,userAddress:c,userChainType:g,lockToPaymentFamily:null!=m,children:e})]},`${n}-${h?"confidential":"public"}-${x?"land-conf":"land-same"}`)}function et({userAddress:e,userChainType:t}){let n=y.SwapUIMachineContext.useActorRef();return(0,o.useEffect)(()=>{null==e||null==t?n.send({type:"LOGOUT"}):n.send({type:"LOGIN",params:{userAddress:e,userChainType:t}})},[n,e,t]),null}function en(){let e=y.SwapUIMachineContext.useActorRef(),{registerSwap:t,hasActiveSwap:n}
2=(0,L.useSwapTrackerMachine)();return(0,o.useEffect)(()=>{let a=e.on("*",a=>{if("INTENT_PUBLISHED"===a.type){(0,R.invalidateBalanceQueries)();let a=e.getSnapshot(),s=a.context.intentCreationResult,{tokenIn:i,tokenOut:r}=a.context.formValues,l=a.context.isConfidential;if(s?.tag==="ok"){let{intentHash:e,intentDescription:a}=s.value,o="depositAddress"in s.value?s.value.depositAddress:void 0;n(o??e)||t({intentHash:e,depositAddress:o,tokenIn:i,tokenOut:r,intentDescription:a,is1cs:!0,isConfidential:l})}}"INTENT_SETTLED"===a.type&&(0,R.invalidateBalanceQueries)()});return()=>{a.unsubscribe()}},[e,t,n]),null}function ea({children:e,mode:n,paymentToken:a,userAddress:i,userChainType:r,lockToPaymentFamily:l}){let u=y.SwapUIMachineContext.useActorRef(),{isEarnDisabled:d}=(0,o.useContext)($.FeatureFlagsContext);return(0,t.jsx)(Z.Provider,{value:{onSubmit:()=>(function({actorRef:e,mode:t,paymentToken:n,userAddress:a,userChainType:i,lockToPaymentFamily:r,isEarnDisabled:l}){if(l)return;if(null==a||null==i)return void O.logger.warn("No user address provided");let o=e.getSnapshot().context.formValues.tokenIn,u=!0===r?(0,s.isSamePaymentFamily)(n,o):(0,X.isSupportedEarnPaymentToken)(n,o);"deposit"!==t||u?(e.getSnapshot().context.isConfidential||(0,z.trackEvent)("deposit"===t?"earn_vault_deposit_requested":"earn_vault_withdraw_requested"),e.send({type:"submit",params:{userAddress:a,userChainType:i,nearClient:H.nearClient}})):O.logger.error(Error("Earn deposit submission rejected for unsupported token"),{paymentTokenId:(0,k.getTokenId)(n),tokenInId:(0,k.getTokenId)(o)})})({actorRef:u,mode:n,paymentToken:a,userAddress:i,userChainType:r,lockToPaymentFamily:l,isEarnDisabled:d}),isEarnDisabled:d},children:e})}let es=["confirm","process","complete"];var ei=e.i(780545);function er(e){return e.context.formValues}var el=e.i(150788),eo=e.i(958115),eu=e.i(384681),ed=e.i(470733);
2function ec({inputId:e,symbol:n,icon:a,value:s,onChange:i,onMax:r,max:l,maxLabel:o,usdValue:u,disabled:d=!1,exceedsBalance:c,errorMessage:g,tokenSelector:p}){return(0,t.jsxs)("div",{className:(0,ed.default)("-outline-offset-1 flex w-full flex-col overflow-hidden rounded-2xl bg-white outline dark:bg-white/3",c||null!=g?"-outline-offset-2 outline-2 outline-red-500 dark:outline-red-500/50 dark:focus-within:outline-red-500":"has-[input:focus]:-outline-offset-2 outline-gray-200 has-[input:focus]:outline-2 has-[input:focus]:outline-gray-400 dark:outline-white/5"),children:[(0,t.jsxs)("label",{htmlFor:e,className:"relative flex w-full flex-1 cursor-text flex-col items-center justify-center px-0.5 pt-10 pb-7",children:[(0,t.jsxs)("span",{className:"sr-only",children:["Enter amount ",n]}),(0,t.jsxs)("div",{className:"flex max-w-full items-baseline justify-center gap-1",children:[(0,t.jsx)("input",{...eo.drawerSwipeIgnoreProps,id:e,type:"text",inputMode:"decimal",pattern:"[0-9]*[.]?[0-9]*",autoComplete:"off",placeholder:"0",disabled:d,value:s,onChange:e=>{let t=e.target.value.replace(",",".").replace(/[^0-9.]/g,""),n=t.split(".");i(n.length>2?`${n[0]}.${n.slice(1).join("")}`:t)},className:(0,ed.default)("field-sizing-content min-h-11 min-w-0 max-w-full appearance-none bg-transparent text-center font-semibold text-gray-900 tracking-tight outline-none dark:text-white","placeholder:font-semibold placeholder:text-gray-300 placeholder:tracking-tight dark:placeholder:text-gray-500",s.length>=15&&"text-2xl/none",s.length>=8&&s.length<15&&"text-3xl/none",s.length<8&&"text-4xl/none",d&&"opacity-50")}),(0,t.jsx)("span",{className:"shrink-0 font-semibold text-2xl/none text-gray-300 tracking-tight dark:text-gray-500",children:n})]}),(0,t.jsx)("div",{className:"mt-0.5",children:c?(0,t.jsx)(eu.default,{className:"text-center",children:"Amount is higher than your available balance."}):null!=g?(0,t.jsx)(eu.default,{className:"text-center",children:g}):(0,t.jsx)("div",{className:"text-center font-semibold text-base/5 text-gray-500 dark:text-gray-400",children:(0,m.formatUsdAmount)(u??0)})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 pb-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[p??(0,t.jsx)(el.default,{icon:a,sizeClassName:"size-9"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col items-start gap-1",children:[(0,t.jsx)("span",{className:"font-medium text-gray-500 text-sm/none dark:text-gray-400",children:null!=p?"Pay with":"Available"}),(0,t.jsx)("span",{className:"block max-w-full truncate font-semibold text-gray-700 text-sm/none min-[400px]:text-base/none dark:text-white","data-testid":"earn-available-amount",children:o})]})]}),(0,t.jsx)(b.default,{variant:"secondary",onClick:r,disabled:d||0n===l,children:"Use max"})]})]})}var eg=e.i(971754),em=e.i(336865),ep=e.i(145803),ef=e.i(511764),eh=e.i(757668),ex=e.i(162831);
2function ey({mode:e,amountIn:n,inputSymbol:a,stage:s,done:i,isError:r=!1,intentHash:l,txHash:o,priceChangeDialog:u,onPriceChangeConfirm:c,onPriceChangeCancel:g,onDone:p,onVisitEarn:f}){let h=null!=o?(0,em.blockExplorerTxLinkFactory)("near",o):null,x=r?"failed":i?"success":"processing";return(0,t.jsxs)("div",{"data-testid":"earn-status","data-earn-status":x,className:"-outline-offset-1 flex w-full flex-col space-y-4 overflow-hidden rounded-2xl bg-white p-5 outline outline-gray-200 dark:bg-gray-850 dark:outline-white/5",children:[(0,t.jsxs)("h3",{className:"font-semibold text-gray-900 text-xl/7 tracking-tight dark:text-white",children:["deposit"===e?"Depositing":"Withdrawing"," ",(0,m.formatDisplayAmount)(n)," ",a]}),(0,t.jsx)(ep.ProgressSteps,{stages:es,stageLabels:"deposit"===e?{confirm:"Confirm in wallet",process:"Depositing",complete:"Deposited"}:{confirm:"Confirm in wallet",process:"Starting withdrawal",complete:"Withdrawal requested"},displayStage:s,displayIndex:es.indexOf(s),isError:r,isSuccess:i,size:"md"}),null!=u&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)(I.default,{variant:"warning",children:["Due to transaction mechanics, your"," ","deposit"===e?"deposit":"withdrawal"," will have a maximum fee of ",(0,d.formatEstimateChangePercent)(u.previousOppositeAmount,u.pendingNewOppositeAmount)]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-1.5",children:[(0,t.jsx)(b.default,{type:"button",variant:"secondary",size:"xl",onClick:g,children:"Cancel"}),(0,t.jsx)(b.default,{type:"button",size:"xl",onClick:c,"data-testid":"confirm-new-price-button",children:"Accept"})]})]}),null!=l&&(0,t.jsxs)(ef.default,{children:[(0,t.jsxs)(ef.default.Row,{label:"Reference ID",children:[(0,eh.midTruncate)(l),(0,t.jsx)(eg.CopyButton,{text:l,ariaLabel:"Copy reference ID"})]}),null!=h&&null!=o&&(0,t.jsxs)(ef.default.Row,{label:"Transaction hash",children:[(0,eh.midTruncate)(o),(0,t.jsx)(eg.CopyButton,{text:o,ariaLabel:"Copy transaction hash"})]})]}),(i||r)&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(b.default,{size:"xl",fullWidth:!0,onClick:p,children:"Close"}),i&&!r&&f&&(0,t.jsx)("div",{className:"text-center",children:(0,t.jsx)(ex.default,{href:"/earn",onClick:f,className:"inline-block font-medium text-gray-500 text-sm/5 hover:text-gray-900 hover:underline focus-visible:rounded-sm focus-visible:outline-2 focus-visible:outline-gray-500 focus-visible:outline-offset-2 dark:text-gray-400 dark:hover:text-white",children:"View in Earn â"})})]})]})}function ek(e){let{inFlight:n,statusView:a,amountCard:r,isLoadingQuote:l,submitState:c,leftoverWarning:g,onSubmit:f,intentCreationResult:h}=function({mode:e,balanceToken:n,displayToken:a,onInFlightChange:r,onComplete:l,availableBalanceCache:c,onAvailableBalanceChange:g,prefetchedPaymentBalances:f=null,minimumDepositUsdc:h,quickEarn:C}){let{setValue:I,watch:b}=(0,u.useFormContext)(),T=y.SwapUIMachineContext.useActorRef(),H=y.SwapUIMachineContext.useSelector(e=>e),B=H.context.intentCreationResult,W=H.context.priceChangeDialog,{data:q}=(0,j.useTokensUsdPrices)(),{setModalType:$}=(0,_.useModalController)(F.ModalType.MODAL_SELECT_ASSETS),{tokenIn:G}=y.SwapUIMachineContext.useSelector(er),Q=n??G,z=b("amountIn"),K=b("amountOut"),[Y,J]=(0,o.useState)(""),ee=y.SwapUIMachineContext.useSelector(e=>e.context.quote?.tag==="err"),et=y.SwapUIMachineContext.useSelector(e=>null==e.context.user),{onSubmit:en,isEarnDisabled:ea}=(0,o.useContext)(Z),es=H.matches("submitting_1cs"),el=H.matches({editing:"waiting_quote"}),eo=(0,E.useSelector)(T,e=>e.matches("submitting_1cs")?e.children.swapRef1cs:void 0),eu=(0,E.useSelector)(eo,e=>{var t;return e?null==(t=e.value)?null:(0,v.extractStateValue)(t):null}),ed=B?.tag==="ok"?B.value.intentHash:null,ec=B?.tag==="ok"&&"depositAddress"in B.value?B.value.depositAddress:void 0,{trackedSwaps:eg}=(0,L.useSwapTrackerMachine)(),em=eg.find(e=>e.id===(ec??ed)),ep=(0,E.useSelector)(em?.actorRef,e=>{if(null==e)return null;let t=e.context;return{stateValue:(0,v.extractStateValue)(e.value),status:t.status??null,txHash:t.txHash??null}}),ef=null!=ec,eh=(0,V.useQuery)({queryKey:["earn-intent-settlement",ed],queryFn:()=>
2{if(null==ed)throw Error("intentHash is required");return(0,w.solverRelayWaitForSettlement)({intentHash:ed})},enabled:null!=ed&&!es&&!ef}),ex=ef?(0,A.is1csSuccess)(ep?.status):null!=em?(0,A.isIntentSuccess)(ep?.stateValue??""):eh.isSuccess,ey=ef?(0,A.is1csError)(ep?.status):null!=em?(0,A.isIntentError)(ep?.stateValue??""):eh.isError,ek=ep?.txHash??eh.data?.txHash??null,eE=null!=ed&&!es,eC=es||eE,eI=function(e){if(e.settled)return"complete";if(null!=e.intentHash)return"process";if(e.isSubmitting&&null!=e.swap1csStateValue)switch(e.swap1csStateValue){case"Fetching1csQuote":case"ValidatingQuote":case"AwaitingPriceChangeConfirmation":case"CreatingTransferMessage":case"GeneratingIntent":case"Signing":default:break;case"VerifyingSignature":case"VerifyingPublicKeyPresence":case"SubmittingIntent":case"BroadcastingIntent":case"Completed":return"process"}return"confirm"}({isSubmitting:es,swap1csStateValue:eu,intentHash:ed,settled:ex});(0,o.useEffect)(()=>{r?.(eC)},[eC,r]);let eb=(0,o.useRef)(C?.onDepositComplete);eb.current=C?.onDepositComplete;let eT=(0,o.useRef)(!1);(0,o.useEffect)(()=>{!ex||((0,R.invalidateBalanceQueries)(),"deposit"!==e||ey||eT.current||(eT.current=!0,eb.current?.()))},[ex,ey,e]);let eN=(0,E.useSelector)(T,e=>e.children.depositedBalanceRef),ew=(0,E.useSelector)(eN,x.balancesSelector),eS=(0,E.useSelector)(eN,x.isBalancesLoadedSelector),ev=eS?ew:f,eA=(0,E.useSelector)(eN,(0,x.balanceSelector)(G)),e_=(0,o.useMemo)(()=>null==f?null:(0,M.computeTotalBalanceDifferentDecimals)(G,f),[f,G]),ej=(0,U.usePrivateModeStore)(e=>e.isPrivateModeEnabled),eR=`${e}:${ej?"confidential":"public"}:${(0,k.getTokenId)(G)}`,eF=(eS?eA:null)??e_??c?.get(eR);(0,o.useEffect)(()=>{null!=eA&&g?.(eR,eA)},[eR,g,eA]);let eD=null!=eF&&null!=H.context.parsedFormValues.amountIn&&-1===(0,i.compareAmounts)(eF,H.context.parsedFormValues.amountIn),eM=(0,o.useMemo)(()=>"deposit"!==e||null==n||null==ev?[]:function(e,t){let n=[],a=new Set;for(let s of e){if((0,k.isBaseToken)(s)){if((t[s.defuseAssetId]??0n)<=0n||a.has(s.defuseAssetId))continue;a.add(s.defuseAssetId),n.push(s);continue}if(!(0,k.isUnifiedToken)(s))continue;let e=s.groupedTokens.filter(e=>(t[e.defuseAssetId]??0n)>0n);if(0!==e.length){if(1===e.length){let t=e[0];if(null==t||a.has(t.defuseAssetId)||a.has(s.unifiedAssetId))continue;a.add(s.unifiedAssetId),a.add(t.defuseAssetId),n.push(s);continue}for(let t of e)a.has(t.defuseAssetId)||(a.add(t.defuseAssetId),n.push(t))}}return n}((0,d.getEarnPaymentTokens)(n),ev),[e,n,ev]),eL="deposit"===e&&null==C&&eM.length>1,eP="deposit"===e&&!eL&&null!=n&&(0,s.isSamePaymentFamily)(n,G)?n:G,eU=(0,o.useCallback)(()=>{eM.length<2||$(F.ModalType.MODAL_SELECT_ASSETS,{fieldName:"paymentToken",paymentToken:eP,isHoldingsEnabled:!0,...null!=ev?{balances:ev}:{},chainIconMode:"always",subtitle:"chainName",tokenList:eM,onConfirm:e=>{let t=e.paymentToken;if(null==t||null==n||!(0,X.isSupportedEarnPaymentToken)(n,t))return void O.logger.warn("Earn payment token selection rejected",{paymentTokenId:null==n?null:(0,k.getTokenId)(n),selectedTokenId:null==t?null:(0,k.getTokenId)(t)});let a=(0,s.resolveBaseTokenForPayment)(t,ev),{tokenOut:i,swapType:r}=T.getSnapshot().context.formValues;I("amountIn",""),I("amountOut",""),T.send({type:"input",params:{tokenIn:a,tokenOut:i,amountIn:"",amountOut:"",swapType:r}})}})},[ev,n,eP,eM,$,I,T]),eO=eL?(0,t.jsx)(S.default,{selected:eP,handleSelect:eU,tokens:eM,"aria-label":(0,k.isBaseToken)(eP)?`Pay with ${eP.symbol} on ${eP.originChainName}`:`Pay with ${eP.symbol}`,dataTestId:"earn-pay-with-pill"}):void 0,eV=(0,D.default)(z,"deposit"===e?G:Q,q),eH="withdraw"===e&&null!=a,eB=eH?(0,ei.resolveVaultSharePriceInPaymentToken)({vaultToken:G,paymentToken:a,tokensUsdPriceData:q}):null,eW=null!=eB&&eB>0,eq=eH?a:eP,e$=(0,o.useMemo)(()=>eH?""!==Y?Y:""!==z&&null!=eB?(0,p.tokenAmountToValueInput)(z,eB):"":z,[eH,Y,z,eB]),eG=(0,o.useCallback)(()=>{if(null==eF)return;let e=(0,m.formatTokenValue)(eF.amount,eF.decimals);eW&&null!=eB&&J((0,p.tokenAmountToValueInput)(e,eB)),I("amountIn",e),I("amountOut",""),T.send({type:"input",params:{amountIn:e,amountOut:"",swapType:N.QuoteRequest.swapType.EXACT_INPUT}}
2)},[eW,eF,eB,I,T]),eQ=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(null!=C&&!eQ.current&&null!=eF&&!(eF.amount<=0n)){if(""!==z){eQ.current=!0;return}eQ.current=!0,eG()}},[C,eF]);let ez=(0,o.useCallback)(e=>{let t=eW&&null!=eB?(0,p.valueInputToTokenAmount)(e,G,eB):e;eH&&J(e),I("amountIn",t),I("amountOut",""),T.send({type:"input",params:{swapType:N.QuoteRequest.swapType.EXACT_INPUT,amountIn:t,amountOut:""}})},[eW,G,eB,eH,I,T]),eK=(0,o.useCallback)(()=>{T.send({type:"START_NEW_SWAP"}),I("amountIn",""),I("amountOut",""),J(""),l?.()},[T,I,l]),eY=eF?.amount??0n,eX=""===e$||""===z,eJ=""===K,eZ=null!=eF?(0,m.formatTokenValue)(eY,eF.decimals,{fractionDigits:4}):"0",e0=eW&&null!=eB?(0,p.parseDisplayNumber)(eZ)*eB:null,e1=eH?null!=eF&&0n===eY?`0 ${(0,P.getTokenLabel)(eq)}`:null!=e0?`~${(0,p.formatValueAmount)(e0)} ${(0,P.getTokenLabel)(eq)}`:"Loading price":null!=eF?`${(0,m.formatTokenValue)(eY,eF.decimals,{fractionDigits:2})} ${(0,P.getTokenLabel)(eq)}`:`0 ${(0,P.getTokenLabel)(eq)}`,e5="deposit"===e?"Deposit":"Withdraw",e2="deposit"===e?H.context.formValues.tokenOut:G,e4="USDC"===(0,X.getEarnVaultUsdUnitSymbol)(e2),e7="deposit"!==e||null!=n&&(0,X.isSupportedEarnPaymentToken)(n,G)?null:e4?"A supported stablecoin is required":`Only ${n?.symbol??"the configured token"} is supported`,e8="deposit"===e&&e4&&null!=n&&""!==K?(0,ei.resolveVaultSharePriceInPaymentToken)({vaultToken:e2,paymentToken:n,tokensUsdPriceData:q}):null,e3=null==e8?null:(0,p.parseDisplayNumber)(K)*e8,e6="deposit"===e&&""!==K?(0,ei.resolveVaultSharePriceUsd)({vaultToken:e2,tokensUsdPriceData:q}):null,e9=null==e6?null:(0,p.parseDisplayNumber)(K)*e6,te=(0,d.getEarnMinimumAmountError)({mode:e,minimumDepositUsdc:h,amountIn:e$,amountUsd:eV,quotedAmountUsdc:e3,quotedAmountUsd:e9,tokenIn:G,paymentToken:"deposit"===e?n:a,vaultToken:e2}),tt=e4?e0:(0,D.default)(eZ,G,q),tn=eH&&""!==e$?e4?(0,p.parseDisplayNumber)(e$):eV:null,ta="withdraw"===e?(0,d.getVaultUnspendableLeftoverWarning)({token:G,balanceUsdc:tt,spendUsdc:tn,minimumDepositUsdc:h,valueUnit:e4?"USDC":"USD"}):null,ts=(0,o.useMemo)(()=>(0,d.getEarnSubmitState)({isLoggedOut:et,amountInEmpty:eX,amountOutEmpty:eJ,isLoadingQuote:el,needsWithdrawPrice:eH&&!eW,balanceInsufficient:eD,validationError:e7??te,failedToGetAQuote:ee,quoteError:H.context.quote1csError,modeLabel:e5}),[et,eX,eJ,el,eH,eW,eD,e7,te,ee,H.context.quote1csError,e5]),ti="deposit"===e?"earn-deposit-amount":"earn-withdraw-amount",tr=(0,o.useMemo)(()=>eH?(0,P.getTokenLabel)(a??Q):"deposit"===e?(0,P.getTokenLabel)(eP):(0,P.getTokenLabel)(G),[eH,a,e,Q,eP,G]);return{inFlight:eC,statusView:{mode:e,amountIn:e$,inputSymbol:tr,stage:eI,done:ex,isError:ey,intentHash:ed,txHash:ek,priceChangeDialog:W,onPriceChangeConfirm:()=>T.send({type:"PRICE_CHANGE_CONFIRMED"}),onPriceChangeCancel:()=>T.send({type:"PRICE_CHANGE_CANCELLED"}),onDone:eK},amountCard:{inputId:ti,symbol:(0,P.getTokenLabel)(eq),icon:eq.icon,value:e$,onChange:ez,onMax:eG,max:eY,maxLabel:e1,usdValue:eV,disabled:eH&&!eW,exceedsBalance:eD,errorMessage:e7??te??ts.errorMessage,tokenSelector:eO},isLoadingQuote:el,submitState:ea?{disabled:!0,label:"Earn is temporarily unavailable"}:ts,leftoverWarning:ta,onSubmit:en,intentCreationResult:B}}(e);if((0,o.useEffect)(()=>{e.onAmountChange?.(r.value)},[r.value,e.onAmountChange]),n)return(0,t.jsx)(ey,{...a,onVisitEarn:e.quickEarn?e.onComplete:void 0});let C=(0,t.jsxs)(t.Fragment,{children:[e.children,(0,t.jsx)(ec,{...r}),null!=g&&""!==g&&(0,t.jsx)(I.default,{variant:"warning",className:"page"===e.variant?void 0:"mt-3",children:g})]});return(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault(),f()},children:["page"===e.variant?(0,t.jsx)("div",{className:"flex flex-col gap-3",children:C}):C,(0,t.jsx)(b.default,{"data-testid":"earn-submit",className:"page"===e.variant?"mt-6":"mt-3",type:"submit",size:"xl",fullWidth:!0,loading:!e.paused&&l,disabled:e.paused||c.disabled,children:e.paused?"deposit"===e.mode?"Deposits paused":"Withdrawals paused":c.label}),(0,t.jsx)(T.default,{intentCreationResult:h})]})}function eE({mode:e,vault:n,inFlight:s,onInFlightChange:i,onModeChange:r,onComplete:l,onAmountChange:u,signMessage:c,userAddress:g,userChainType:m,prefetchedPaymentBalances:p,quickEarn:f,showBalanceSummary:x,variant:y}){let k=(0,o.useMemo)(()=>
2(0,d.getEarnTokenList)(n),[n]),[E,C]=(0,o.useState)(()=>new Map),I=(0,o.useCallback)((e,t)=>{C(n=>{let a=n.get(e);if(a?.amount===t.amount&&a.decimals===t.decimals)return n;let s=new Map(n);return s.set(e,t),s})},[]);return(0,t.jsxs)(a.SwapWidgetProvider,{children:[x&&(0,t.jsx)(h,{vault:n,userAddress:g,userChainType:m}),(0,t.jsx)(eC,{mode:e,vault:n,tokenList:k,inFlight:s,onInFlightChange:i,onModeChange:r,onComplete:l,onAmountChange:u,signMessage:c,userAddress:g,userChainType:m,availableBalanceCache:E,onAvailableBalanceChange:I,prefetchedPaymentBalances:p,quickEarn:f,compact:!x,variant:y},e)]})}function eC({mode:e,vault:a,tokenList:o,inFlight:d,onInFlightChange:c,onModeChange:g,onComplete:m,onAmountChange:p,signMessage:f,userAddress:h,userChainType:x,availableBalanceCache:y,onAvailableBalanceChange:k,prefetchedPaymentBalances:E,quickEarn:I,compact:b,variant:T}){let N="deposit"===e,w=I?.token??a.paymentToken,S=N?(0,s.resolveBaseTokenForPayment)(w,E):a.vaultToken,v=N?a.vaultToken:(0,i.getAnyBaseTokenInfo)(w),A=(0,u.useForm)({mode:"onSubmit",reValidateMode:"onChange",defaultValues:{amountIn:"",amountOut:""}}),_=d||null!=I?null:(0,t.jsx)(r.default,{tabs:[{label:"Deposit",selected:"deposit"===e,onClick:()=>g("deposit")},{label:"Withdraw",selected:"withdraw"===e,onClick:()=>g("withdraw")}]});return(0,t.jsx)(u.FormProvider,{...A,children:(0,t.jsxs)(ee,{mode:e,paymentToken:w,tokenIn:S,tokenOut:v,tokenList:o,signMessage:f,userAddress:h,userChainType:x,quickEarn:I,children:[N&&(0,t.jsx)(C,{paymentToken:w,prefetchedBalances:E,lockToPaymentFamily:null!=I}),(0,t.jsx)(l.MeasuredHeightTransition,{view:d?"status":"form",children:(0,t.jsxs)("div",{className:"page"===T?void 0:b?"space-y-3":"space-y-3 pt-6",children:["page"!==T&&_,(0,t.jsx)(n.TokenListUpdater,{tokenList:o}),(0,t.jsx)(ek,{variant:T,mode:e,balanceToken:N?w:void 0,displayToken:w,onInFlightChange:c,onComplete:m,onAmountChange:p,availableBalanceCache:y,onAvailableBalanceChange:k,prefetchedPaymentBalances:E,minimumDepositUsdc:a.minimumDepositUsdc,quickEarn:I,paused:N?a.status?.enter===!1:a.status?.exit===!1,children:"page"===T?_:null})]})})]})})}e.s(["EarnVaultPanel",0,function({vault:e,signMessage:n,userAddress:a,userChainType:s,prefetchedPaymentBalances:i=null,quickEarn:r,showBalanceSummary:l=!1,variant:u="dialog",initialMode:d="deposit",onComplete:c,onAmountChange:g,onInFlightChange:m}){let[p,f]=(0,o.useState)(d),[h,x]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(h&&null!=m)return m(!0),()=>m(!1)},[h,m]),(0,t.jsx)(eE,{mode:r?"deposit":p,vault:e,inFlight:h,onInFlightChange:x,onModeChange:e=>{r||h||e===p||f(e)},onComplete:()=>{x(!1),c?.()},onAmountChange:g,signMessage:n,userAddress:a,userChainType:s,prefetchedPaymentBalances:i,quickEarn:r,showBalanceSummary:l,variant:u})}],23632)},795655,e=>{"use strict";var t=e.i(789477),n=e.i(317800),a=e.i(735645),s=e.i(528973),i=e.i(971754),r=e.i(150788),l=e.i(494438),o=e.i(336865),u=e.i(723980),d=e.i(298270),c=e.i(958115),g=e.i(384681),m=e.i(145803),p=e.i(493266),f=e.i(511764),h=e.i(564264),x=e.i(966321),y=e.i(277415),k=e.i(757668),E=e.i(548065),C=e.i(382075),I=e.i(470733),b=e.i(696150),T=e.i(364516),N=e.i(245164),w=e.i(987750),S=e.i(7637),v=e.i(891341),A=e.i(241258),_=e.i(186448),j=e.i(385989),R=e.i(651235),F=e.i(157946),D=e.i(5895),M=e.i(720549),L=e.i(578800),P=e.i(283278),U=e.i(603550),O=e.i(434737),V=e.i(63371),H=e.i(452878),B=e.i(755488),W=e.i(634573);async function q({amount:e,ensureAuthenticated:t,signerCredentials:n,userId:a}){if(!await t())throw Error("ERR_CONFIDENTIAL_AUTH_FAILED");let s=new Date((0,L.minutesFromNow)(5)).toISOString(),i=(0,O.verifyQuoteResult)(await (0,H.getUnshieldQuote)({amount:e.toString(),asset:W.WNEAR_ASSET_ID,userAddress:n.credential,authMethod:n.credentialType,deadline:s,slippageTolerance:100}));if("err"in i)throw Error(i.err);let r=i.ok.quote.depositAddress;if(null==r)throw Error("ERR_CONFIDENTIAL_FUNDING_ADDRESS_MISSING");let l=BigInt(i.ok.quote.amountOut);if(l<=0n)throw Error("ERR_CONFIDENTIAL_FUNDING_AMOUNT_INVALID");let o=await (0,V.generateIntent)({depositAddress:r,signerId:a,standard:U.AUTH_METHOD_TO_STANDARD[n.credentialType]});if("err"in o)throw Error(o.err);return{depositAddress:r,fundingQuote:i.ok,stakeAmount:l,walletMessage:(0,L.wrapPayloadAsWalletMessage)(o.ok.intent)}}async function $({fundingQuote:e,signature:t,signerCredentials:n}){(0,P.saveQuoteFromResult)({ok:e});let a=await (0,B.submitIntent)({signedIntent:N.prepareBroadcastRequest.prepareSwapSignedData(t,{userAddress:n.credential,userChainType:n.credentialType})});if("err"in a)throw Error(a.err);return a.ok.intentHash}e.i(582448);var G=e.i(989998),Q=e.i(180472),z=e.i(414583),K=e.i(517494),Y=e.i(771326),X=e.i(828820);function J(e,t,n){A.logger.error(t instanceof Error?t:Error(String(t)),{op:`nearStakingMachine.${e}`,intentHash:n.intentHash,amount:n.amount.toString()})}function Z(e){h.journeyAnalytics.started(e)}function ee(e){let t=e.analytics;if(null==t||null==e.intentHash)return;let n={namespace:"intent",key:e.intentHash};h.journeyAnalytics.completed({...t,operation:n})}function et(e,t,n){let a=e.analytics,s="string"!=typeof n?null:"ERR_USER_DIDNT_SIGN"===n||"ERR_WALLET_CANCEL_ACTION"===n||"ERR_WALLET_WEBAUTHN_TIMEOUT_OR_CANCELLED"===n?{failure_stage:t,failure_reason:"user_cancelled"}:"ERR_WALLET_POPUP_BLOCKED"===n||"ERR_SIGNED_DIFFERENT_ACCOUNT"===n?{failure_stage:t,failure_reason:"wallet_rejected"}:"RELAY_PUBLISH_SIGNATURE_EXPIRED"===n||"RELAY_PUBLISH_SIGNATURE_INVALID"===n||"RELAY_PUBLISH_NONCE_USED"===n||"RELAY_PUBLISH_INSUFFICIENT_BALANCE"===n||"RELAY_PUBLISH_PUBLIC_NOT_EXIST"===n?{failure_stage:t,failure_reason:"provider_rejected"}:null;null!=a&&null!=s&&h.journeyAnalytics.failed({...a,...s})}function en(e){return e.fundingConfirmed&&null!=e.stakeDeadline&&Date.parse(e.stakeDeadline)-3e4<=Date.now()}let ea=(0,_.setup)({types:{input:{},events:{},emitted:{},context:{}},actors:{prepareConfidentialFunding:(0,F.fromPromise)(async({input:e})=>q(e)),prepareWalletMessage:(0,F.fromPromise)(async({input:e})=>{let{nonce:t,deadline:n}=await M.bridgeSDK.intentBuilder().setDeadline(new Date((0,L.minutesFromN
2ow)(5))).build(),a="stake"===e.direction,s=a&&!await G.nearStakingContract.isFtStorageRegistered(e.lstContractId,D.config.env.contractID),i=a?0n:(await G.nearStakingContract.getUserWithdrawalRequest(e.lstContractId,e.userId)).totalAmount;return{walletMessage:T.messageFactory.makeSwapMessage({innerMessage:{signer_id:e.userId,deadline:n,intents:[{intent:"ft_withdraw",token:a?W.WNEAR_TOKEN_ACCOUNT_ID:e.lstContractId,receiver_id:e.lstContractId,amount:e.amount.toString(),msg:a?(0,Q.buildStakeMessage)(e.userId,{isStorageDeposit:s}):(0,Q.buildUnstakeMessage)(e.userId)}]},nonce:w.base64.decode(t)}),previousWithdrawalTotal:i,deadline:n}}),signIntent:Y.signIntentMachine,submitConfidentialFunding:(0,F.fromPromise)(async({input:e})=>$(e)),waitForConfidentialFunding:(0,F.fromPromise)(({input:e,signal:t})=>{let n=Date.parse(e.deadline),a=Number.isFinite(n)?Math.max(12e4,n-Date.now()+3e4):12e4;return(0,X.waitForConfidentialExecution)({depositAddress:e.depositAddress,signal:t,timeoutMs:a})}),publishIntent:(0,F.fromPromise)(({input:e})=>(0,S.solverRelayPublishIntent)(e).then(z.convertPublishIntentToLegacyFormat)),waitForIntentSettlement:(0,F.fromPromise)(({input:e})=>(0,v.solverRelayWaitForSettlement)({intentHash:e.intentHash}).then(e=>({...e,status:"SETTLED"}))),waitForWithdrawalRequest:(0,F.fromPromise)(({input:e,signal:t})=>G.nearStakingContract.waitForUserWithdrawalRequest(e.lstContractId,e.userId,{signal:t,previousTotalAmount:e.previousWithdrawalTotal}))},actions:{initializeOperation:(0,j.assign)(({event:e})=>((0,_.assertEvent)(e,"PROCEED"),{amount:e.params.amount,direction:e.params.direction,displayAmount:e.params.displayAmount,error:null,fundingConfirmed:!1,fundingDepositAddress:null,fundingIntentHash:null,fundingQuote:null,fundingSignature:null,intentHash:null,intentStatus:null,previousWithdrawalTotal:0n,signature:null,stakeDeadline:null,walletMessage:null,analytics:e.params.analytics})),resetOperation:(0,j.assign)({amount:0n,displayAmount:0n,error:null,fundingConfirmed:!1,fundingDepositAddress:null,fundingIntentHash:null,fundingQuote:null,fundingSignature:null,intentHash:null,intentStatus:null,previousWithdrawalTotal:0n,signature:null,stakeDeadline:null,walletMessage:null,analytics:null})}}).createMachine({initial:"idle",context:({input:e})=>({...e,amount:0n,displayAmount:0n,direction:"stake",signature:null,fundingDepositAddress:null,fundingConfirmed:!1,fundingIntentHash:null,fundingQuote:null,fundingSignature:null,intentHash:null,error:null,intentStatus:null,walletMessage:null,previousWithdrawalTotal:0n,stakeDeadline:null,analytics:null}),states:{idle:{on:{PROCEED:[{guard:({context:e,event:t})=>"stake"===t.params.direction&&e.fundFromConfidential,target:"prepareConfidentialFunding",actions:["initializeOperation",({event:e})=>Z(e.params.analytics)]},{target:"prepareWalletMessageToSign",actions:["initializeOperation",({event:e})=>Z(e.params.analytics)]}],RESET:{actions:"resetOperation"}}},prepareConfidentialFunding:{invoke:{src:"prepareConfidentialFunding",input:({context:e})=>({amount:e.amount,ensureAuthenticated:e.ensureAuthenticated,signerCredentials:e.signerCredentials,userId:e.userId}),onDone:{target:"signingConfidentialFunding",actions:(0,j.assign)({amount:({event:e})=>e.output.stakeAmount,displayAmount:({event:e})=>e.output.stakeAmount,fundingDepositAddress:({event:e})=>e.output.depositAddress,fundingQuote:({event:e})=>e.output.fundingQuote,walletMessage:({event:e})=>e.output.walletMessage})},onError:{target:"idle",actions:[({event:e,context:t})=>J("prepareConfidentialFunding",e.error,t),(0,j.assign)({error:"ERR_CONFIDENTIAL_FUNDING_PREPARE"})]}},tags:["busy"]},signingConfidentialFunding:{invoke:{src:"signIntent",input:({context:e})=>((0,K.assert)(null!==e.walletMessage),{signerCredentials:e.signerCredentials,signMessage:e.signMessage,walletMessage:e.walletMessage}),onDone:[{guard:({event:e})=>"ok"===e.output.tag,target:"prepareWalletMessageToSign",actions:(0,j.assign)({fundingSignature:({event:e})=>((0,K.assert)("ok"===e.output.tag),e.output.value.signatureResult),walletMessage:null})},{target:"idle",actions:[({event:e,context:t})=>{(0,K.assert)("err"===e.output.tag),J("signConfidentialFunding",Error(e.output.value.reason),t)},(0,j.assign)({error:({event:e})=>((0,K.assert)("err"===e.output.tag),e.output.value.reason)})]}],onError:{target:"idle",actions:[({event:e,context:t})=>J("signConfidentialFunding",e.error,t),(0,j.assign)({error:"EXCEPTION"})]}},tags:["busy"]},prepareWalletMessageToSign:{invoke:{src:"prepareWalletMessage",input:({context:e})=>({userId:e.userId,amount:e.amount,lstContractId:e.lstContractId,direction:e.direction}),onDone:{target:"signing",actions:(0,j.assign)({walletMessage:({event:e})=>e.output.walletMessage,previousWithdrawalTotal:({event:e})=>e.output.previousWithdrawalTotal,stakeDeadline:({event:e})=>e.output.deadline})},onError:[{guard:({context:e})=>e.fundingConfirmed,target:"stakeCompletionFailed",actions:[({event:e,context:t})=>J("prepareWalletMessage",e.error,t),(0,j.assign)({error:"ERR_FAILED_TO_PREPARE_MESSAGE_TO_SIGN"})]},{target:"idle",actions:[({event:e,context:t})=>J("prepareWalletMessage",e.error,t),(0,j.assign)({error:"ERR_FAILED_TO_PREPARE_MESSAGE_TO_SIGN"})]}]},tags:["busy"]},signing:{invoke:{src:"signIntent",input:({context:e})=>((0,K.assert)(null!==e.walletMessage),{signerCredentials:e.signerCredentials,signMessage:e.sign
2Message,walletMessage:e.walletMessage}),onDone:[{guard:({context:e,event:t})=>"ok"===t.output.tag&&"stake"===e.direction&&e.fundFromConfidential&&!e.fundingConfirmed,target:"submittingConfidentialFunding",actions:(0,j.assign)({signature:({event:e})=>((0,K.assert)("ok"===e.output.tag),e.output.value.signatureResult)})},{guard:({context:e,event:t})=>"ok"===t.output.tag&&en(e),target:"prepareWalletMessageToSign",actions:(0,j.assign)({signature:null,walletMessage:null})},{guard:({event:e})=>"ok"===e.output.tag,target:"publishing",actions:(0,j.assign)({signature:({event:e})=>((0,K.assert)("ok"===e.output.tag),e.output.value.signatureResult)})},{guard:({context:e})=>e.fundingConfirmed,target:"stakeCompletionFailed",actions:[({event:e,context:t})=>{(0,K.assert)("err"===e.output.tag),J("signStakeIntent",Error(e.output.value.reason),t)},(0,j.assign)({error:({event:e})=>((0,K.assert)("err"===e.output.tag),e.output.value.reason)})]},{target:"idle",actions:[({event:e,context:t})=>{(0,K.assert)("err"===e.output.tag),J("signIntent",Error(e.output.value.reason),t),et(t,"signing",e.output.value.reason)},(0,j.assign)({error:({event:e})=>((0,K.assert)("err"===e.output.tag),e.output.value.reason)})]}],onError:[{guard:({context:e})=>e.fundingConfirmed,target:"stakeCompletionFailed",actions:[({event:e,context:t})=>J("signStakeIntent",e.error,t),(0,j.assign)({error:"EXCEPTION"})]},{target:"idle",actions:[({event:e,context:t})=>J("signIntent",e.error,t),(0,j.assign)({error:"EXCEPTION"})]}]},tags:["busy"]},submittingConfidentialFunding:{invoke:{src:"submitConfidentialFunding",input:({context:e})=>((0,K.assert)(null!=e.fundingQuote),(0,K.assert)(null!=e.fundingSignature),{fundingQuote:e.fundingQuote,signature:e.fundingSignature,signerCredentials:e.signerCredentials}),onDone:{target:"waitingForConfidentialFunding",actions:(0,j.assign)({fundingIntentHash:({event:e})=>e.output,fundingSignature:null})},onError:{target:"confidentialFundingOutcomeUnknown",actions:[({event:e,context:t})=>J("submitConfidentialFunding",e.error,t),({context:e,event:t})=>et(e,"submission",t.error),(0,j.assign)({error:"CANT_CONFIRM_CONFIDENTIAL_FUNDING"})]}},tags:["busy"]},waitingForConfidentialFunding:{invoke:{src:"waitForConfidentialFunding",input:({context:e})=>((0,K.assert)(null!=e.fundingDepositAddress),(0,K.assert)(null!=e.fundingQuote),{deadline:e.fundingQuote.quoteRequest.deadline,depositAddress:e.fundingDepositAddress}),onDone:[{guard:({context:e,event:t})=>"success"===t.output&&en({...e,fundingConfirmed:!0}),target:"prepareWalletMessageToSign",actions:(0,j.assign)({error:null,fundingConfirmed:!0,signature:null,walletMessage:null})},{guard:({event:e})=>"success"===e.output,target:"publishing",actions:(0,j.assign)({error:null,fundingConfirmed:!0})},{guard:({event:e})=>"failed"===e.output,target:"idle",actions:(0,j.assign)({error:"CONFIDENTIAL_FUNDING_FAILED",signature:null})},{target:"confidentialFundingOutcomeUnknown",actions:(0,j.assign)({error:"CANT_CONFIRM_CONFIDENTIAL_FUNDING"})}],onError:{target:"confidentialFundingOutcomeUnknown",actions:[({event:e,context:t})=>J("waitForConfidentialFunding",e.error,t),(0,j.assign)({error:"CANT_CONFIRM_CONFIDENTIAL_FUNDING"})]}},tags:["busy"]},confidentialFundingOutcomeUnknown:{on:{RESET:{target:"waitingForConfidentialFunding",actions:(0,j.assign)({error:null})}},tags:["recoverable"]},publishing:{invoke:{src:"publishIntent",input:({context:e})=>((0,K.assert)(null!=e.signature),{multiPayload:N.prepareBroadcastRequest.prepareSwapSignedData(e.signature,{userAddress:e.signerCredentials.credential,userChainType:e.signerCredentials.credentialType}),quoteHashes:[]}),onDone:[{guard:({event:e})=>"ok"===e.output.tag,target:"settling",actions:[(0,j.assign)({signature:null,intentHash:({event:e})=>((0,K.assert)("ok"===e.output.tag),e.output.value)}),({context:e,event:t})=>{var n;let a;"ok"===t.output.tag&&(n=t.output.value,null==(a=e.analytics)||h.journeyAnalytics.submitted({...a,operation:{namespace:"intent",key:n}}))}]},{guard:({context:e})=>e.fundingConfirmed,target:"stakeCompletionFailed",actions:[({event:e,context:t})=>{(0,K.assert)("err"===e.output.tag),J("publishStakeIntent",Error(e.output.value.reason),t)},(0,j.assign)({error:"CANT_PUBLISH_STAKE"})]},{target:"idle",actions:[({event:e,context:t})=>{(0,K.assert)("err"===e.output.tag),J("publishIntent",Error(e.output.value.reason),t),et(t,"submission",e.output.value.reason)},(0,j.assign)({error:({event:e})=>((0,K.assert)("err"===e.output.tag),e.output.value.reason)})]}],onError:[{guard:({context:e})=>e.fundingConfirmed,target:"stakeCompletionFailed",actions:[({event:e,context:t})=>J("publishStakeIntent",e.error,t),(0,j.assign)({error:"CANT_PUBLISH_STAKE"})]},{target:"idle",actions:[({event:e,context:t})=>J("publishIntent",e.error,t),({context:e,event:t})=>et(e,"submission",t.error),(0,j.assign)({error:"EXCEPTION"})]}]},tags:["busy"]},stakeCompletionFailed:{on:{RESET:{target:"prepareWalletMessageToSign",actions:(0,j.assign)({error:null,signature:null,walletMessage:null})}},tags:["recoverable"]},settling:{invoke:{src:"waitForIntentSettlement",input:({context:e})=>((0,K.assert)(null!=e.intentHash),{intentHash:e.intentHash}),onDone:[{guard:({context:e})=>"unstake"===e.direction,target:"confirmingWithdrawalRequest",actions:(0,j.assign)({intentStatus:({event:e})=>e.output})},{target:"settled",actions:[(0,j.assign)({intentStatus:({event:e})=>e.output}),({context:e})=>ee(e)]}],onError:{target:"publishedOutcomeUnknown",actions:[({event:e,context:t})=>J("waitForIntentSettlement",e.error,t),(0,j.assign)({error:"CANT_GET_INTENT_STATUS"})]}},tags:["busy"]},confirmingWithdrawalRequest:{invoke:{src:"waitForWithdrawalRequest",input:({context:e})=>({lstContractId:e.lstContractId,userId:e.userId,previousWithdrawalTotal:e.previousWithdrawalTotal}),onDone:{target:"settled",actions:({context:e})=>ee(e)},onError:{target:"publishedOutcomeUnknown",actions:[({event:e,context:t})=>J("waitForWithdrawalRequest",e.error,t),(0,j.assign)({error:"CANT_CONFIRM_UNSTAKE_QUEUE"})]}},tags:["busy"]},publishedOutcomeUnknown:{on:{RESET:[{guard:({context:e})=>"unstake"===e.direction&&null!=e.intentStatus,target:"confirmingWithdrawalRequest"},{target:"settling"}]},tags:["recoverable"]},settled:{entry:(0,R.emit)({type:"STAKE_SETTLED"}),on:{RESET:{target:"idle",actions:"resetOperation"}}}}});var es=e.i(302227),ei=e.i(39463);let er=["confirm","process","complete"],el={stake:{confirm:"Confirm in wallet",process:"Staking NEAR",complete:"Staked"},unstake:{confirm:"Confirm in wallet",process:"Starting unstake",complete:"Unstake requested"}};function eo({variant:e,quickStake:n,userId:r,direction:l,amountText:o,max:u,maxLabel:d,usdValue:c,usdValueLabel:m,disabled:f,exceedsBalance:h,unstakeRateUnavailable:x,canSubmit:y,error:E,intentHash:C,onSwitchDirection:I,onAmountChange:b,onMax:T,onSubmit:N}){let w=(0,t.jsxs)(t.Fragment,{children:[!n&&(0,t.jsx)(p.default,{tabs:[{label:"Stake",onClick:()=>I("stake"),selected:"stake"===l,dataTestId:"earn-stake-tab"},{label:"Unstake",onClick:()=>I("unstake"),selected:"unstake"===l,dataTestId:"earn-unstake-tab"}]}),(0,t.jsx)(eu,{value:o,onChange:b,onMax:T,max:u,maxLabel:d,usdValue:c,usdValueLabel:m,disabled:f,exceedsBalance:h}),x&&(0,t.jsx)(g.default,{className:"text-center",children:"Staked balance is loading. Please try again in a moment."})]}),S=(0,t.jsxs)(a.default,{variant:"warning",className:"[&>div]:min-w-0",children:[(0,t.jsx)("h3",{className:"font-semibold",children:"Staking activity is public"}),(0,t.jsx)("p",{className:"mt-1 font-medium",children:"Staking and unstaking are linked to your near.com account address. Anyone who can link this address to you can also identify your staking activity."}),(0,t.jsxs)("p",{className:"mt-2 font-medium",children:["Visible address: ",(0,t.jsx)("code",{className:"break-all font-mono",children:r})]})]}),v=(0,t.jsx)(s.default,{"data-testid":"earn-stake-submit",size:"xl",fullWidth:!0,className:"page"===e?"mt-6":"",disabled:!y,onClick:N,children:"stake"===l?"page"===e?"Stake NEAR":"Stake":"page"===e?"Unstake NEAR":"Unstake"}),A=(0,t.jsxs)(t.Fragment,{children:[null!=E&&(0,t.jsx)(g.default,{className:"page"===e?"mt-3 text-center":"text-center",children:em(E)}),eg.has(E??"")&&null!=C&&(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center",children:[(0,t.jsx)("span",{className:"text-center font-medium text-gray-500 text-sm/4 dark:text-gray-400",children:"Reference ID for support"}),(0,t.jsxs)("div",{className:"flex items-center gap-1 rounded-lg bg-gray-150 px-2 py-1 dark:bg-gray-700",children:[(0,t.jsx)("span",{className:"font-bold font-mono text-gray-900 text-sm/4 dark:text-white",children:(0,k.midTruncate)(C,16)}),(0,t.jsx)(i.CopyButton,{text:C,ariaLabel:"Copy reference ID"})]})]})]});return"page"===e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[w,S]}),v,A]}):(0,t.jsxs)(t.Fragment,{children:[w,S,v,A]})}
2function eu({value:e,onChange:n,onMax:a,max:i,maxLabel:l,usdValue:o,usdValueLabel:d,disabled:m,exceedsBalance:p}){return(0,t.jsxs)("div",{className:(0,I.default)("-outline-offset-1 flex w-full flex-col overflow-hidden rounded-2xl bg-white outline dark:bg-white/3",p?"-outline-offset-2 outline-2 outline-red-500 dark:outline-red-500/50 dark:focus-within:outline-red-500":"has-[input:focus]:-outline-offset-2 outline-gray-200 has-[input:focus]:outline-2 has-[input:focus]:outline-gray-400 dark:outline-white/5"),children:[(0,t.jsxs)("label",{htmlFor:"stake-near-amount",className:"relative flex w-full flex-1 cursor-text flex-col items-center justify-center px-0.5 pt-10 pb-7",children:[(0,t.jsx)("span",{className:"sr-only",children:"Enter amount NEAR"}),(0,t.jsxs)("div",{className:"flex max-w-full items-baseline justify-center gap-0.5",children:[(0,t.jsx)("input",{...c.drawerSwipeIgnoreProps,id:"stake-near-amount",type:"text",inputMode:"decimal",pattern:"[0-9]*[.]?[0-9]*",autoComplete:"off",placeholder:"0",disabled:m,value:e,onChange:e=>{let t=e.target.value.replace(",",".").replace(/[^0-9.]/g,""),a=t.split(".");n(a.length>2?`${a[0]}.${a.slice(1).join("")}`:t)},className:(0,I.default)("field-sizing-content min-h-11 min-w-0 max-w-full appearance-none bg-transparent text-center font-semibold text-gray-900 tracking-tight outline-none dark:text-white","placeholder:font-semibold placeholder:text-gray-300 placeholder:tracking-tight dark:placeholder:text-gray-500",e.length>=15&&"text-2xl/none",e.length>=8&&e.length<15&&"text-3xl/none",e.length<8&&"text-4xl/none",m&&"opacity-50")}),(0,t.jsx)("span",{className:"shrink-0 font-semibold text-2xl/none text-gray-300 tracking-tight dark:text-gray-500",children:"NEAR"})]}),(0,t.jsx)("div",{className:"mt-0.5",children:p?(0,t.jsx)(g.default,{className:"text-center",children:"Amount is higher than your available balance."}):(0,t.jsx)("div",{className:"text-center font-semibold text-base/5 text-gray-500 dark:text-gray-400",children:d??(0,u.formatUsdAmount)(o??0)})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 pb-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,t.jsx)(r.default,{icon:W.NEAR_TOKEN_ICON,sizeClassName:"size-9"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col items-start gap-1",children:[(0,t.jsx)("span",{className:"font-medium text-gray-500 text-sm/none dark:text-gray-400",children:"Available"}),(0,t.jsx)("span",{"data-testid":"earn-stake-available",className:"block max-w-full truncate font-semibold text-gray-700 text-sm/none min-[400px]:text-base/none dark:text-white",children:l})]})]}),(0,t.jsx)(s.default,{variant:"secondary",onClick:a,disabled:m||0n===i,children:"Use max"})]})]})}function ed({direction:e,displayAmount:n,stage:a,done:r,error:l,recoverable:u,intentHash:d,intentStatus:c,doneLabel:p,onDone:h,onRetry:x}){let y=c?.txHash!=null?(0,o.blockExplorerTxLinkFactory)("near",c.txHash):null,E=c?.intentHash??d,C=c?.txHash??null,I=u?"failed":r?"success":"processing";return(0,t.jsxs)("div",{"data-testid":"earn-status","data-earn-status":I,className:"-outline-offset-1 flex w-full flex-col space-y-4 overflow-hidden rounded-2xl bg-white p-5 outline outline-gray-200 dark:bg-gray-850 dark:outline-white/5",children:[(0,t.jsxs)("h3",{className:"font-semibold text-gray-900 text-xl/7 tracking-tight dark:text-white",children:["stake"===e?"Staking ":"Unstaking ",(0,es.formatNear)(n)," NEAR"]}),(0,t.jsx)(m.ProgressSteps,{stages:er,stageLabels:el[e],displayStage:a,displayIndex:er.indexOf(a),isError:u,isSuccess:r,size:"md"}),null!=E&&(0,t.jsxs)(f.default,{children:[(0,t.jsxs)(f.default.Row,{label:"Reference ID",children:[(0,k.midTruncate)(E),(0,t.jsx)(i.CopyButton,{text:E,ariaLabel:"Copy reference ID"})]}),null!=y&&null!=C&&(0,t.jsxs)(f.default.Row,{label:"Transaction hash",children:[(0,k.midTruncate)(C),(0,t.jsx)(i.CopyButton,{text:C,ariaLabel:"Copy transaction hash"})]})]}),u&&null!=l&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.default,{className:"text-center",children:em(l)}),(0,t.jsx)(s.default,{size:"xl",fullWidth:!0,onClick:x,children:"Retry"})]}),r&&(0,t.jsx)(s.default,{size:"xl",fullWidth:!0,onClick:h,children:p})]})}let ec={ERR_USER_DIDNT_SIGN:"It seems the message wasnât signed in your wallet. Please try again.",ERR_WALLET_CANCEL_ACTION:"You cancelled the request in your wallet. You can try again when youâre ready.",ERR_WALLET_WEBAUTHN_TIMEOUT_OR_CANCELLED:"The wallet request was cancelled or timed out. Please try again.",ERR_FAILED_TO_PREPARE_MESSAGE_TO_SIGN:"Failed to prepare message for your wallet to sign. Please try again.",CANT_GET_INTENT_STATUS:"Intent was submitted but we couldnât confirm settlement. Check your balance in a minute.",CANT_CONFIRM_UNSTAKE_QUEUE:"Intent settled, but the withdrawal queue wasnât found yet. Refresh in a minute and check the intent if it still does not appear.",ERR_CONFIDENTIAL_FUNDING_PREPARE:"We couldnât prepare your confidential NEAR for staking. Please try again.",CONFIDENTIAL_FUNDING_FAILED:"Your confidential transfer did not complete. Your NEAR was not staked.",CANT_CONFIRM_CONFIDENTIAL_FUNDING:"Your confidential transfer was submitted, but its status is not available yet.",CANT_PUBLISH_STAKE:"Your NEAR is ready in Main, but the staking step did not submit. Retry to finish staking without moving funds again."},eg=new Set(["CANT_GET_INTENT_STATUS","CANT_CONFIRM_UNSTAKE_QUEUE","CANT_CONFIRM_CONFIDENTIAL_FUNDING","CANT_PUBLISH_STAKE"]);function em(e){return ec[e]??"Something went wrong. Please try again. If the problem continues, contact support."}e.s(["NearStakingForm",0,function({fundFromConfidential:e,position:a,userAddress:s,userChainType:i,signMessage:r,initialDirection:o="stake",variant:c="dialog",quickStake:g=!1,disabled:m=!1,onAmountChange:p,onComplete:f,onSettled:k,onInFlightChange:I}){let T=(0,E.useQueryClient)(),{data:N}=(0,l.useTokensUsdPrices)(),{ensureAuthenticated:w}=(0,y.usePrivateModeAuth)(),[S,v,A]=(0,C.useActor)(ea,{input:{userId:a.userId,signerCredentials:{credential:s,credentialType:i},signMessage:r,lstContractId:a.contractId,ensureAuthenticated:w,fundFromConfidential:e}}),[_,j]=(0,b.useState)(o),[R,F]=(0,b.useState)(""),D=S.tags.has("busy"),M=S.tags.has("recoverable"),L=S.matches("settled"),P=D||M||L,U=P?S.context.direction:_;
2(0,b.useEffect)(()=>{if(P&&null!=I)return I(!0),()=>I(!1)},[P,I]);let O="unstake"===_&&null==a.exchangeRate&&a.stakedLst>0n,V="stake"===_?a.availableNear:a.stakedNear,H=function(e){if(""===e.trim())return null;try{return(0,d.parseUnits)(e,W.NEAR_DECIMALS)}catch{return null}}(R),B=!O&&null!=H&&H>V,q=null==H?null:"stake"===_?H:(0,es.getUnstakeLstAmount)({inputNear:H,stakedNear:a.stakedNear,stakedLst:a.stakedLst,rate:a.exchangeRate}),$=!m&&!P&&null==S.context.intentHash&&!O&&null!=q&&q>0n&&!B,G=N?.[W.WNEAR_ASSET_ID]?.price,Q=null==H?null:Number((0,u.formatTokenValue)(H,W.NEAR_DECIMALS))*(G??0),z=null==H||null==G||!Number.isFinite(G)||G<0?null:Number((0,u.formatTokenValue)(H,W.NEAR_DECIMALS))*G,K=null!=z&&Number.isFinite(z)&&z>=0?{valueUsd:z,valueQuality:"estimated"}:{valueUsd:null,valueQuality:"unavailable"},Y=e=>{F(e),p?.(e)},X=(0,b.useEffectEvent)(()=>{T.invalidateQueries({queryKey:ei.nearStakingQueryKeys.withdrawalRequests()}),T.invalidateQueries({queryKey:ei.nearStakingQueryKeys.poolSnapshots()}),T.invalidateQueries({queryKey:n.balanceQueryPrefix}),k?.()});return(0,b.useEffect)(()=>{let e=A.on("STAKE_SETTLED",()=>X());return()=>e.unsubscribe()},[A]),(0,t.jsx)(x.MeasuredHeightTransition,{view:P?"status":"form",children:(0,t.jsx)("div",{className:"page"!==c||P?"space-y-3":void 0,children:P?(0,t.jsx)(ed,{direction:U,displayAmount:S.context.displayAmount,stage:function(e){switch(e){case"prepareConfidentialFunding":case"signingConfidentialFunding":case"prepareWalletMessageToSign":case"signing":default:return"confirm";case"submittingConfidentialFunding":case"waitingForConfidentialFunding":case"confidentialFundingOutcomeUnknown":case"publishing":case"stakeCompletionFailed":case"settling":case"confirmingWithdrawalRequest":return"process";case"settled":return"complete"}}(String(S.value)),done:L,error:S.context.error,recoverable:M,intentHash:S.context.intentHash??S.context.fundingIntentHash,intentStatus:S.context.intentStatus,doneLabel:"page"===c?"Done":"Close",onDone:()=>{v({type:"RESET"}),j(o),Y(""),f?.()},onRetry:()=>v({type:"RESET"})}):(0,t.jsx)(eo,{variant:c,quickStake:g,userId:a.userId,direction:_,amountText:R,max:V,maxLabel:O?"â NEAR":`${(0,es.formatNear)(V)} NEAR`,usdValue:Q,usdValueLabel:O?"â":void 0,disabled:m||D,exceedsBalance:B,unstakeRateUnavailable:O,canSubmit:$,error:S.context.error,intentHash:S.context.intentHash,onSwitchDirection:e=>{m||P||e===_||(j(e),Y(""),null!=S.context.error&&v({type:"RESET"}))},onAmountChange:Y,onMax:()=>Y((0,u.formatTokenValue)(V,W.NEAR_DECIMALS)),onSubmit:()=>{if(null==q||null==H)return;let e="stake"===_?{journey:{journeyId:h.journeyAnalytics.newId(),flow:"earn_stake",privacy:"public",valuation:K},surface:"earn",asset_id:W.WNEAR_ASSET_ID,asset_symbol:"NEAR",amount:(0,u.formatTokenValue)(H,W.NEAR_DECIMALS),market_id:"near-staking",has_existing_position:a.stakedLst>0n}:{journey:{journeyId:h.journeyAnalytics.newId(),flow:"earn_unstake",privacy:"public",valuation:K},surface:"earn",asset_id:W.WNEAR_ASSET_ID,asset_symbol:"NEAR",amount:(0,u.formatTokenValue)(H,W.NEAR_DECIMALS),market_id:"near-staking",has_existing_position:a.stakedLst>0n};v({type:"PROCEED",params:{amount:q,displayAmount:H,direction:_,analytics:e}})}})})})}],795655)}]); 3 4//# debugId=d16246d4-cf61-cb4f-9a85-c10729d01e14 5//# sourceMappingURL=07z75tstr9pcj.js.map
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.