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]=`04ca3003-97a7-46b7-ae7e-349628e96ab4`,e._sentryDebugIdIdentifier=`sentry-dbid-04ca3003-97a7-46b7-ae7e-349628e96ab4`)}catch{}import{o as e}from"./rolldown-runtime-nx40z1zs.js";import{$m as t,Ag as n,Gu as r,Lm as i,Oi as a,_r as o,ei as s,jg as c,ng as l,xr as u}from"./entry.client-mpghtlrl.js";import{y as d}from"./xds-react-components-ihgca01z.js";import{Mt as f}from"./xds-icons-m106f2fc.js";var p=e(c(),1),m=n(),h=/^\d{1,3}(\.\d{1,3}){3}$/,g=/^[0-9a-fA-F:.]+(%[A-Za-z0-9._-]+)?$/;function _(e){let t=e.trim();if(t.startsWith(`[`)){let e=t.indexOf(`]`);return e===-1||t[e+1]!==`:`?null:{ip:t.substring(1,e),port:t.substring(e+2),isIpv6:!0}}let n=t.lastIndexOf(`:`);return n===-1||n===t.length-1?null:{ip:t.substring(0,n),port:t.substring(n+1),isIpv6:!1}}function v(e){return h.test(e)}function y(e){return g.test(e)}function b(e){if(!/^\d+$/.test(e))return!1;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=1024&&t<=65535}function x(e){let t=_(e);return t?(t.isIpv6?y(t.ip):v(t.ip))?b(t.port)?{kind:`valid`}:{kind:`invalid-port`}:{kind:`invalid-ip`}:{kind:`invalid-format`}}var S=`127.0.0.1:9002`,C=`play-xbox.devTools.ipConnect.lastIpAddress`;function w(){if(typeof window>`u`)return S;try{let e=window.localStorage.getItem(C);return e&&e.length>0?e:S}catch{return S}}function T(e){if(!(typeof window>`u`))try{window.localStorage.setItem(C,e)}catch{}}var E=l(),D=o(e=>{let n=(0,m.c)(26),{ipAddress:r,setIpAddress:i,handleConnect:a,errorKind:o}=e,{t:c}=t(`ConfigureIPConnectPage`),l;bb0:switch(o){case`invalid-format`:{let e;n[0]===c?e=n[1]:(e=c(`Enter an address in the form 'ip:port' (e.g. 127.0.0.1:9002) or '[ipv6]:port'.`,{shortKey:`invalid_format_a1b2c3`}),n[0]=c,n[1]=e),l=e;break bb0}case`invalid-ip`:{let e;n[2]===c?e=n[3]:(e=c(`Enter a valid IPv4 or IPv6 address.`,{shortKey:`invalid_ip_d4e5f6`}),n[2]=c,n[3]=e),l=e;break bb0}case`invalid-port`:{let e;n[4]===c?e=n[5]:(e=c(`Port must be a number between 1024 and 65535.`,{shortKey:`invalid_port_g7h8i9`}),n[4]=c,n[5]=e),l=e;break bb0}case null:default:l=null}let p=l,h;n[6]===c?h=n[7]:(h=c(`Enter the ip address and port to connect to`,{shortKey:`address_connect_enter_432324`}),n[6]=c,n[7]=h);let g;n[8]===h?g=n[9]:(g=(0,E.jsx)(`h2`,{className:`type-title2`,id:`ip-address-title`,children:h}),n[8]=h,n[9]=g);let _=p!==null,v;n[10]===p?v=n[11]:(v=p===null?void 0:(0,E.jsxs)(`div`,{className:`flex flex-row items-center gap-internal-icon-and-text-gap-regular`,children:[(0,E.jsx)(s,{icon:(0,E.jsx)(f,{}),size:`caption`,className:`text-feedback-status-standard-content-icon-error`}),(0,E.jsx)(`p`,{className:`text-noninteractive-content-primary-content type-caption`,children:p})]}),n[10]=p,n[11]=v);let y;n[12]!==r||n[13]!==i||n[14]!==_||n[15]!==v?(y=(0,E.jsx)(d,{value:r,onChange:i,"aria-labelledby":`ip-address-title`,"aria-invalid":_,className:`w-full`,statusInfo:v}),n[12]=r,n[13]=i,n[14]=_,n[15]=v,n[16]=y):y=n[16];let b;n[17]===c?b=n[18]:(b=c(`Connect`,{shortKey:`connect_6412ef`}),n[17]=c,n[18]=b);let x;n[19]!==a||n[20]!==b?(x=(0,E.jsx)(u,{as:`button`,size:`standard`,kind:`brand`,onPress:a,className:`w-full`,children:b}),n[19]=a,n[20]=b,n[21]=x):x=n[21];let S;return n[22]!==g||n[23]!==y||n[24]!==x?(S=(0,E.jsx)(`div`,{className:`flex min-h-screen flex-col items-center justify-center p-internal-container-padding-regular`,children:(0,E.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-internal-container-padding-regular rounded-noninteractive-container-regular bg-container-backgrounds-elevation-background-level-2 p-internal-container-padding-regular`,children:[g,y,x]})}),n[22]=g,n[23]=y,n[24]=x,n[25]=S):S=n[25],S},()=>{let[e,t]=(0,p.useState)(S),[n,i]=(0,p.useState)(null);return(0,p.useEffect)(()=>{let e=w();e!==`127.0.0.1:9002`&&t(e)},[]),{ipAddress:e,setIpAddress:(0,p.useCallback)(e=>{t(e),i(null)},[]),handleConnect:(0,p.useCallback)(()=>{let t=e.trim(),n=x(t);if(n.kind!==`valid`){i(n.kind);return}T(t);let a=r.internal.devTools.ipConnect.launch.$buildPath({}),o=new URLSearchParams(window.location.search);o.set(`ipAddress`,t),window.location.assign(`${a}?${o.toString()}`)},[e]),errorKind:n}}),O=i(a(()=>(0,E.jsx)(D.useComponent(),{}),`ConfigureIPConnectPage`));export{O as default};