const e=document.getElementById(`theme`),t=document.getElementById(`robotAddress`),n=document.getElementById(`remotePath`),r=document.getElementById(`liveSubscribeMode`),i=document.getElementById(`liveDiscard`),a=document.getElementById(`publishFilter`),o=document.getElementById(`coordinateSystem`),s=document.getElementById(`field3dModeAc`),c=document.getElementById(`field3dModeAcLabel`),l=document.getElementById(`field3dModeBattery`),u=document.getElementById(`field3dAntialiasing`),d=document.getElementById(`tbaApiKey`),f=document.getElementById(`exit`),p=document.getElementById(`confirm`),m=document.getElementById(`revPort`),h=document.getElementById(`revKey`);window.addEventListener(`message`,g=>{if(g.data===`port`){let _=g.ports[0];_.onmessage=g=>{if(typeof g.data==`object`&&`isFocused`in g.data){Array.from(document.getElementsByTagName(`button`)).forEach(e=>{g.data.isFocused?e.classList.remove(`blurred`):e.classList.add(`blurred`)});return}let v=g.data.platform,y=g.data.prefs;switch(v){case`linux`:e.children[0].hidden=!0,e.children[1].innerText=`Light`,e.children[2].innerText=`Dark`;break;case`lite`:document.body.classList.add(`lite`),c.innerText=`3D Mode`;break}e.value=y.theme,t.value=y.robotAddress,n.value=y.remotePath,r.value=y.liveSubscribeMode,i.value=y.liveDiscard.toString(),a.value=y.publishFilter,o.value=y.coordinateSystem,s.value=y.field3dModeAc,l.value=y.field3dModeBattery,u.value=y.field3dAntialiasing.toString(),d.value=y.tbaApiKey,m.value=y.revTelemetryPort.toString(),h.value=y.revTelemetryKey;function b(c){if(c){let c=`system`;e.value===`light`&&(c=`light`),e.value===`dark`&&(c=`dark`),e.value===`system`&&(c=`system`);let f=`low-bandwidth`;r.value===`low-bandwidth`&&(f=`low-bandwidth`),r.value===`logging`&&(f=`logging`);let p=`automatic`;o.value===`automatic`&&(p=`automatic`),o.value===`wall-alliance`&&(p=`wall-alliance`),o.value===`wall-blue`&&(p=`wall-blue`),o.value===`center-rotated`&&(p=`center-rotated`),o.value===`center-red`&&(p=`center-red`);let g=`standard`;s.value===`cinematic`&&(g=`cinematic`),s.value===`standard`&&(g=`standard`),s.value===`low-power`&&(g=`low-power`);let v=``;l.value===``&&(v=``),l.value===`cinematic`&&(v=`cinematic`),l.value===`standard`&&(v=`standard`),l.value===`low-power`&&(v=`low-power`);let b=parseInt(m.value);isNaN(b)&&(b=y.revTelemetryPort);let x={theme:c,robotAddress:t.value,remotePath:n.value,liveMode:y.liveMode,liveSubscribeMode:f,liveDiscard:Number(i.value),publishFilter:a.value,rlogPort:y.rlogPort,coordinateSystem:p,field3dModeAc:g,field3dModeBattery:v,field3dAntialiasing:u.value===`true`,tbaApiKey:d.value,userAssetsFolder:y.userAssetsFolder,skipHootNonProWarning:y.skipHootNonProWarning,ctreLicenseAccepted:y.ctreLicenseAccepted,systemcoreStaticAddress:y.systemcoreStaticAddress,hasScrolledLineGraph:y.hasScrolledLineGraph,hasScrolledTimeline:y.hasScrolledTimeline,revTelemetryKey:h.value,revTelemetryPort:b,revTelemetryHost:y.revTelemetryHost};_.postMessage(x)}else _.postMessage(y)}f.addEventListener(`click`,()=>{b(!1)}),p.addEventListener(`click`,()=>b(!0)),window.addEventListener(`keydown`,e=>{e.code===`Enter`&&b(!0)})}}});