(()=>{"use strict";var e={140(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getDesktopLoggerBridge=function(){return{logString:(e,t)=>{o(e,t)},logError:e=>{i(e)}}},t.logString=o,t.logError=i;const r=n(288);function o(e,t){r.ipcRenderer.send("desktop_log_message",e,t)}function i(e){e instanceof Error?o("err",e.message):o("err","unknown error type in logger bridge")}},386(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.kWindowsRExe=t.checkForNewLanguage=void 0,t.normalizeSeparators=r,t.createAliasedPath=function(e,t){e=r(e);let n=r(t||"");return e.endsWith("/")&&(e=e.slice(0,-1)),n.endsWith("/")&&(n=n.slice(0,-1)),e===n?"~":(e.startsWith(n)&&e.substring(n.length).startsWith("/")&&(e="~"+e.substring(n.length)),r(e))},t.normalizeSeparatorsNative=function(e){return r(e,"win32"===process.platform?"\\":"/")};const n=e=>{if("undefined"!=typeof window){const t=window.localStorage.getItem(e);return{isSet:""!==t&&!!t,value:t}}return{isSet:!1,value:""}};function r(e,t="/"){let n="";return(e.startsWith("\\\\")||e.startsWith("//"))&&(n=`${t}${t}`,e=e.substring(2)),`${n}${e.replace(/[\\/]+/g,t)}`}t.checkForNewLanguage=async()=>new Promise(e=>{const t=(new Date).getTime(),r=setInterval(()=>{if((new Date).getTime()>t+5e3)clearInterval(r),e("en");else{const o=n("LAST_TIME");if(o.isSet){const i=n("LOCALE");i.isSet&&t<=parseInt(""+o.value,10)+3e3&&(clearInterval(r),e(""+i.value))}}},100)}),t.kWindowsRExe="Rterm.exe"},288(e){e.exports=require("electron")}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}(()=>{const e=n(288),t=n(140),r=n(386);e.contextBridge.exposeInMainWorld("desktopLogger",(0,t.getDesktopLoggerBridge)()),e.ipcRenderer.on("css",(e,t)=>{const n=document.createElement("style");n.setAttribute("language","text/css"),n.innerText=t,document.head.appendChild(n)}),e.ipcRenderer.on("initialize",(t,n)=>{const o=document.getElementById("use-default-32"),s=document.getElementById("use-default-64"),c=document.getElementById("use-custom"),a=document.getElementById("select"),d=document.getElementById("button-ok"),l=document.getElementById("button-download"),u=n.useDefault32BitR,g=n.default32bitPath;g&&(o.removeAttribute("disabled"),o.checked=u);const m=n.useDefault64BitR,p=n.default64bitPath;p&&(s.removeAttribute("disabled"),s.checked=m);const f=n.rInstalls,h=n.renderingEngine;document.getElementById("rendering-engine").value=h;const v=document.getElementById("select"),w={};f.sort((e,t)=>t.localeCompare(e));const b=document.getElementById("select");b.disabled=!(f.length>0&&c.checked),f.forEach(async t=>{if(t=(0,r.normalizeSeparatorsNative)(await e.ipcRenderer.invoke("path_normalize",t)),w[t])return;w[t]=!0;const o=`${t}/bin/x64/${r.kWindowsRExe}`;if(await e.ipcRenderer.invoke("fs_existsSync",o)){const e=window.document.createElement("option");e.value=o,e.innerText=`[64-bit] ${t}`,v.appendChild(e),!m&&i(n.selectedRVersion,o)&&(document.getElementById("use-custom").checked=!0,b.disabled=!1,b.selectedIndex=v.childElementCount-1,b.focus())}const s=`${t}/bin/i386/${r.kWindowsRExe}`;if(await e.ipcRenderer.invoke("fs_existsSync",s)){const e=window.document.createElement("option");e.value=s,e.innerText=`[32-bit] ${t}`,v.appendChild(e),!u&&i(n.selectedRVersion,s)&&(document.getElementById("use-custom").checked=!0,b.disabled=!1,b.selectedIndex=v.childElementCount-1,b.focus())}}),c.checked=!g&&!p&&f.length>0,b.disabled=!c.checked,f.length>0&&l.remove(),d.disabled=!(c.checked&&a.value||o.checked||s.checked)});const o={useDefault32bit:async t=>await e.ipcRenderer.invoke("use-default-32bit",t),useDefault64bit:async t=>await e.ipcRenderer.invoke("use-default-64bit",t),use:async t=>await e.ipcRenderer.invoke("use-custom",t),browse:async t=>await e.ipcRenderer.invoke("browse-r-exe",t),cancel:()=>{e.ipcRenderer.send("cancel")},downloadR:async()=>{await e.ipcRenderer.invoke("download-r")}};function i(e,t){return(0,r.normalizeSeparatorsNative)(e)===(0,r.normalizeSeparatorsNative)(t)}e.contextBridge.exposeInMainWorld("callbacks",o)})()})();
//# sourceMappingURL=preload.js.map