/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
"use strict";function onReady(){perf.mark("main:appReady"),Promise.all([nodeCachedDataDir.ensureExists(),userDefinedLocale]).then(([e,r])=>{r&&!nlsConfiguration&&(nlsConfiguration=lp.getNLSConfiguration(product.commit,userDataPath,metaDataFile,r)),nlsConfiguration||(nlsConfiguration=Promise.resolve(void 0)),nlsConfiguration.then(r=>{const t=r=>{r._languagePackSupport=!0,process.env.VSCODE_NLS_CONFIG=JSON.stringify(r),process.env.VSCODE_NODE_CACHED_DATA_DIR=e||"",perf.mark("willLoadMainBundle"),require("./bootstrap-amd").load("vs/code/electron-main/main",()=>{perf.mark("didLoadMainBundle")})};if(r)t(r);else{let e=app.getLocale();e?(e=e.toLowerCase(),lp.getNLSConfiguration(product.commit,userDataPath,metaDataFile,e).then(r=>{r||(r={locale:e,availableLanguages:{}}),t(r)})):t({locale:"en",availableLanguages:{}})}})},console.error)}function configureCommandlineSwitches(e){app.commandLine.appendSwitch("disable-color-correct-rendering");const r=getJSFlags(e);r&&app.commandLine.appendSwitch("--js-flags",r)}
function getJSFlags(e){const r=[];return e["js-flags"]&&r.push(e["js-flags"]),e["max-memory"]&&!/max_old_space_size=(\d+)/g.exec(e["js-flags"])&&r.push(`--max_old_space_size=${e["max-memory"]}`),r.length>0?r.join(" "):null}function getUserDataPath(e){return portable.isPortable?path.join(portable.portableDataPath,"user-data"):path.resolve(e["user-data-dir"]||paths.getDefaultUserDataPath(process.platform))}function parseCLIArgs(){return require("minimist")(process.argv,{string:["user-data-dir","locale","js-flags","max-memory"]})}function setCurrentWorkingDirectory(){try{"win32"===process.platform?(process.env.VSCODE_CWD=process.cwd(),process.chdir(path.dirname(app.getPath("exe")))):process.env.VSCODE_CWD&&process.chdir(process.env.VSCODE_CWD)}catch(e){console.error(e)}}function registerListeners(){const e=[];global.macOpenFiles=e,app.on("open-file",function(r,t){e.push(t)});const r=[],t=function(e,t){e.preventDefault(),r.push(t)};app.on("will-finish-launching",function(){app.on("open-url",t)}),
global.getOpenUrls=function(){return app.removeListener("open-url",t),r}}function getNodeCachedDir(){return new class{constructor(){this.value=this._compute()}ensureExists(){return bootstrap.mkdirp(this.value).then(()=>this.value,()=>{})}_compute(){if(process.argv.indexOf("--no-cached-data")>0)return;if(process.env.VSCODE_DEV)return;const e=product.commit;if(e)return path.join(userDataPath,"CachedData",e)}}}function stripComments(e){return e.replace(/("(?:[^\\"]*(?:\\.)?)*")|('(?:[^\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g,function(e,r,t,a,n){if(a)return"";if(n){const e=n.length;return e>2&&"\n"===n[e-1]?"\r"===n[e-2]?"\r\n":"\n":""}return e})}function getUserDefinedLocale(){const e=args.locale;if(e)return Promise.resolve(e.toLowerCase());const r=path.join(userDataPath,"User","locale.json");return bootstrap.readFile(r).then(e=>{e=stripComments(e);try{const r=JSON.parse(e).locale;return r&&"string"==typeof r?r.toLowerCase():void 0}catch(e){return}},()=>{})}
const perf=require("./vs/base/common/performance"),lp=require("./vs/base/node/languagePacks");perf.mark("main:started");const path=require("path"),bootstrap=require("./bootstrap"),paths=require("./paths"),product=require("../product.json"),app=require("electron").app,portable=bootstrap.configurePortable();bootstrap.enableASARSupport();const args=parseCLIArgs(),userDataPath=getUserDataPath(args);app.setPath("userData",userDataPath),setCurrentWorkingDirectory(),registerListeners();let nlsConfiguration=void 0;const userDefinedLocale=getUserDefinedLocale(),metaDataFile=path.join(__dirname,"nls.metadata.json");userDefinedLocale.then(e=>{e&&!nlsConfiguration&&(nlsConfiguration=lp.getNLSConfiguration(product.commit,userDataPath,metaDataFile,e))});const nodeCachedDataDir=getNodeCachedDir();configureCommandlineSwitches(args),app.once("ready",function(){if(args.trace){const e=require("electron").contentTracing,r={categoryFilter:args["trace-category-filter"]||"*",
traceOptions:args["trace-options"]||"record-until-full,enable-sampling"};e.startRecording(r,()=>onReady())}else onReady()});
//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/036a6b1d3ac84e5ca96a17a44e63a87971f8fcc8/core/main.js.map
