try{let e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`70f8a6c3-7931-439c-9fc5-bb993118dc5d`,e._sentryDebugIdIdentifier=`sentry-dbid-70f8a6c3-7931-439c-9fc5-bb993118dc5d`)}catch{}import{o as e}from"./rolldown-runtime-eb2nym32.js";import{t}from"./useLocation-fu2554ly.js";import{st as n}from"./xds-react-components-lks62tbl.js";import{Ag as r,Dg as i,Fg as a,Gp as o,Ig as s,Kp as c,ch as l,dn as u,lh as d,or as f,pr as p,sh as m}from"./entry.client-dr7r6s9a.js";import{t as h}from"./DialogShell-k2jpaw9r.js";import{n as g,t as _}from"./ChangeGamertagInput-nruk26ee.js";import{n as v,t as y}from"./getChangeGamertagRouterEnvironmentHooks-e2ysxgj6.js";import{n as b,r as x,t as S}from"./routes-bxal063z.js";var C=a(),w=e(f(),1),T=e(s(),1),E=r(),D=u(({currentGamertag:e,disableButtons:t,errorReservation:r,handleNext:i,handleRandom:a,handleReserve:o,navigateBack:s,randomGamertag:c,reservation:l})=>{let{t:u}=d(`ChangeGamertagDialog`),[f,p]=(0,T.useState)(``),m=v.useComponent(),y={title:{text:u(`Customize your classic gamertag`,{shortKey:`change_classic_gamertag_title`}),sizeClassName:`type-section3`},containerClassName:`flex-1 items-center`};return(0,T.useEffect)(()=>{c&&p(c)},[c]),(0,T.useEffect)(()=>{l&&i()},[l]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(h.NavigationHeader,{showClose:!0,onBack:s,className:`ps-template-overlays-modal-container-padding-2-left-&-right content-between items-baseline self-stretch p-internal-gap-regular`,title:y}),(0,E.jsxs)(n,{className:(0,w.default)(`overflow-y-auto sbar`,`[--scrollbar-track-margin-top:var(--modal-spacing)]`,`flex flex-1 flex-col self-stretch`,`px-template-overlays-modal-container-padding-2-left-&-right`,`items-start gap-internal-gap-static-regular`),children:[(0,E.jsx)(`p`,{className:`text-action-noninteractive-content-rest type-body`,children:u(`Your classic gamertag will continue to be used in existing games. The recommended classic gamertag below aligns with your new gamertag and helps people recognize you across games and other experiences.`,{shortKey:`change_classic_gamertag_description`})}),(0,E.jsx)(x,{label1:e,label2:u(`Suggested classic gamertag`,{shortKey:`suggested_classic_gamertag`})}),(0,E.jsx)(_,{errorReservation:r,gamertag:f,maxLength:15,setGamertag:p,statusInfo:u(`Up to 15 characters, including spaces. Must both start with a letter and only use latin alphanumeric characters`,{shortKey:`customize_rules_classic_gamertag`})})]}),(0,E.jsxs)(`div`,{className:(0,w.default)(`flex flex-col gap-internal-gap-regular`,`px-template-overlays-modal-container-padding-2-left-&-right pb-template-overlays-modal-container-padding-2-top-&-bottom`),children:[(0,E.jsx)(g,{disableButtons:t,disableNext:f.trim().length<1,handleNext:()=>{o(f)},handleRandom:a,nextButtonText:u(`Save changes`,{shortKey:`save_changes`})}),(0,E.jsx)(m,{})]})]})},()=>{let e=t(),{gamertag:n}=m(),r=o(),{trackUserAction:a}=l(),s=y(),u=()=>{a(`BackButton`,{},`Press`),s()},d=c({from:b.changeClassicGamertag}),[f,p]=(0,T.useState)(!0),[h,g]=(0,T.useState)(``),{data:_,isLoading:v,refetch:x}=i({...n.queries.generatedGamertags.getActiveUserQuery().getOptions({count:1}),enabled:!f}),{data:C,error:w,isLoading:E}=i({...n.queries.reserveGamertag.getActiveUserQuery().getOptions({classicGamertag:h}),enabled:!!h});return{currentGamertag:d.gamertag??``,disableButtons:v||E,errorReservation:w,handleNext:()=>{if(C){let t={gamertag:C.gamertag,modernGamertag:d.modernGamertag,modernGamertagSuffix:d.modernGamertagSuffix,uniqueModernGamertag:d.uniqueModernGamertag,classicTranslationLevel:C.classicTranslationLevel,promptForClassicGamertag:C.promptForClassicGamertag};a(`NavigateInModal`,{destination:S.confirmNewGamertag,source:e.pathname},`Press`),r({to:S.confirmNewGamertag,search:t})}},handleRandom:()=>{a(`GenerateRandomGamertag`,{wasClassic:!0},`Press`),f?p(!1):x()},handleReserve:async e=>{g(e)},navigateBack:u,randomGamertag:_?.[0],reservation:C}}),O=()=>{let e=(0,C.c)(2),t=D.useComponent(),n;return e[0]===t?n=e[1]:(n=(0,E.jsx)(p,{location:`ChangeClassicGamertagScreen`,children:(0,E.jsx)(t,{})}),e[0]=t,e[1]=n),n};export{O as ChangeClassicGamertag};