const presence = new Presence({
		clientId: "996589941926670366",
	}),
	startTimestamp = Math.floor(Date.now() / 1000);

interface Stauts {
	file: string;
	workspace: string;
	editor: {
		lang: string;
	};
}

const enum Assets {
	Logo = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/logo.png",
	Ahk = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/0.png",
	Android = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/1.png",
	Astro = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/2.png",
	Arduino = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/3.png",
	Autoit = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/4.png",
	Brainfuck = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/5.png",
	Applescript = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/6.png",
	Appveyor = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/7.png",
	Asp = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/8.png",
	Assembly = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/9.png",
	Angular = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/10.png",
	Ansible = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/11.png",
	Babel = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/12.png",
	Bower = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/13.png",
	Bat = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/14.png",
	Coffee = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/15.png",
	Crystal = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/16.png",
	Cpp = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/17.png",
	Css = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/18.png",
	D = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/19.png",
	Codeclimate = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/20.png",
	Clojure = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/21.png",
	Cmake = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/22.png",
	Csharp = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/23.png",
	Circleci = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/24.png",
	Cssmap = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/25.png",
	Dart = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/26.png",
	C = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/27.png",
	Cargo = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/28.png",
	Cuda = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/29.png",
	Editorconfig = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/30.png",
	Erlang = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/31.png",
	Elixir = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/32.png",
	Firebase = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/33.png",
	Elm = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/34.png",
	Denizen = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/35.png",
	Debugging = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/36.png",
	Flowconfig = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/37.png",
	Docker = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/38.png",
	Fsharp = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/39.png",
	Eslint = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/40.png",
	Env = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/41.png",
	Ejs = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/42.png",
	Gatsbyjs = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/43.png",
	Delphi = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/44.png",
	Hjson = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/45.png",
	Groovy = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/46.png",
	Gemfile = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/47.png",
	Haxe = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/48.png",
	Handlebars = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/49.png",
	Gulp = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/50.png",
	Graphql = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/51.png",
	Godot = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/52.png",
	Go = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/53.png",
	Html = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/54.png",
	Gradle = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/55.png",
	Haskell = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/56.png",
	Git = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/57.png",
	Heroku = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/58.png",
	Harbour = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/59.png",
	Jupyter = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/60.png",
	Idle = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/61.png",
	Json = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/62.png",
	Julia = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/63.png",
	IdleVscodeInsiders = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/64.png",
	Js = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/65.png",
	Jest = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/66.png",
	Jsx = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/67.png",
	Laravel = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/68.png",
	Java = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/69.png",
	Jsmap = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/70.png",
	IdleVscode = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/71.png",
	Kotlin = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/72.png",
	Http = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/73.png",
	Jar = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/74.png",
	Log = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/75.png",
	Livescript = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/76.png",
	Lisp = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/77.png",
	Lua = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/78.png",
	Npm = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/79.png",
	Manifest = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/80.png",
	Metal = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/81.png",
	Nim = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/82.png",
	Marko = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/83.png",
	Makefile = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/84.png",
	Nix = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/85.png",
	Objc = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/86.png",
	Nodemon = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/87.png",
	Markdown = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/88.png",
	Markdownx = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/89.png",
	Postcss = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/90.png",
	Pascal = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/91.png",
	Pawn = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/92.png",
	Powershell = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/93.png",
	Python = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/94.png",
	Purescript = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/95.png",
	Processing = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/96.png",
	Php = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/97.png",
	Odin = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/98.png",
	Perl = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/99.png",
	Prettier = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/100.png",
	Prisma = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/101.png",
	Ocaml = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/102.png",
	Ponylang = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/103.png",
	Pug = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/104.png",
	Ruby = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/105.png",
	Sql = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/106.png",
	Sqf = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/107.png",
	R = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/108.png",
	Svelte = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/109.png",
	Scss = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/110.png",
	Terraform = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/111.png",
	Scala = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/112.png",
	Sourcepawn = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/113.png",
	Tex = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/114.png",
	Shell = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/115.png",
	Stylus = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/116.png",
	Swift = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/117.png",
	Rust = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/118.png",
	Svg = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/119.png",
	Tsmap = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/120.png",
	Vala = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/121.png",
	Vscode = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/122.png",
	V = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/123.png",
	Ts = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/124.png",
	Toml = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/125.png",
	Text = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/126.png",
	TypescriptDef = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/127.png",
	Vitestconfig = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/128.png",
	Twig = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/129.png",
	Viteconfig = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/130.png",
	Vb = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/131.png",
	Tsx = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/132.png",
	Turbo = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/133.png",
	Travis = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/134.png",
	VscodeInsiders = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/135.png",
	Yaml = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/136.png",
	Xml = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/137.png",
	Wasm = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/138.png",
	Vueconfig = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/139.png",
	Vue = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/140.png",
	Yarn = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/141.png",
	Webpack = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/142.png",
	Vscodeignore = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/143.png",
	Zig = "https://cdn.rcd.gg/PreMiD/websites/V/vscode.dev/assets/144.png",
}

// https://github.com/iCrawl/discord-vscode/blob/master/src/data/languages.json @iCrawl
// https://github.com/leonardssh/vscord/tree/main/assets/icons @leonardssh
const KNOWN_LANGUAGES: { language: string; image: string }[] = [
		{ language: "abap", image: Assets.Text },
		{ language: "ansible", image: Assets.Ansible },
		{ language: "bat", image: Assets.Bat },
		{ language: "bibtex", image: Assets.Text },
		{ language: "clojure", image: Assets.Clojure },
		{ language: "coffeescript", image: Assets.Coffee },
		{ language: "c", image: Assets.C },
		{ language: "cpp", image: Assets.Cpp },
		{ language: "csharp", image: Assets.Csharp },
		{ language: "css", image: Assets.Css },
		{ language: "diff", image: Assets.Manifest },
		{ language: "dockerfile", image: Assets.Docker },
		{ language: "fsharp", image: Assets.Fsharp },
		{ language: "git-commit", image: Assets.Manifest },
		{ language: "git-rebase", image: Assets.Manifest },
		{ language: "go", image: Assets.Go },
		{ language: "groovy", image: Assets.Groovy },
		{ language: "handlebars", image: Assets.Handlebars },
		{ language: "haml", image: Assets.Text },
		{ language: "html", image: Assets.Html },
		{ language: "ini", image: Assets.Manifest },
		{ language: "java", image: Assets.Java },
		{ language: "javascript", image: Assets.Js },
		{ language: "javascriptreact", image: Assets.Jsx },
		{ language: "jsx", image: Assets.Jsx },
		{ language: "json", image: Assets.Json },
		{ language: "jsonc", image: Assets.Json },
		{ language: "jupyter", image: Assets.Jupyter },
		{ language: "latex", image: Assets.Text },
		{ language: "less", image: Assets.Text },
		{ language: "lua", image: Assets.Lua },
		{ language: "makefile", image: Assets.Makefile },
		{ language: "markdown", image: Assets.Markdown },
		{ language: "objective-c", image: Assets.Objc },
		{ language: "objective-cpp", image: Assets.Objc },
		{ language: "odin", image: Assets.Odin },
		{ language: "perl", image: Assets.Perl },
		{ language: "perl6", image: Assets.Perl },
		{ language: "php", image: Assets.Php },
		{ language: "plaintext", image: Assets.Text },
		{ language: "powershell", image: Assets.Powershell },
		{ language: "jade", image: Assets.Pug },
		{ language: "pug", image: Assets.Pug },
		{ language: "prisma", image: Assets.Prisma },
		{ language: "python", image: Assets.Python },
		{ language: "r", image: Assets.R },
		{ language: "razor", image: Assets.Html },
		{ language: "ruby", image: Assets.Ruby },
		{ language: "rust", image: Assets.Rust },
		{ language: "scss", image: Assets.Scss },
		{ language: "sass", image: Assets.Scss },
		{ language: "shaderlab", image: Assets.Manifest },
		{ language: "shellscript", image: Assets.Shell },
		{ language: "slim", image: Assets.Text },
		{ language: "sql", image: Assets.Sql },
		{ language: "stylus", image: Assets.Stylus },
		{ language: "swift", image: Assets.Swift },
		{ language: "typescript", image: Assets.Ts },
		{ language: "typescriptreact", image: Assets.Tsx },
		{ language: "tex", image: Assets.Tex },
		{ language: "vb", image: Assets.Vb },
		{ language: "vue", image: Assets.Vue },
		{ language: "vue-html", image: Assets.Vue },
		{ language: "xml", image: Assets.Xml },
		{ language: "xsl", image: Assets.Xml },
		{ language: "yaml", image: Assets.Yaml },
	],
	KNOWN_EXTENSIONS: { [key: string]: { image: string } } = {
		"nodemon.json": { image: Assets.Nodemon },
		"package.json": { image: Assets.Npm },
		"turbo.json": { image: Assets.Turbo },
		"/\\.prettier((rc)|(\\.(toml|yml|yaml|json|js))?$){2}/i": {
			image: Assets.Prettier,
		},
		"/\\.eslint((rc|ignore)|(\\.(json|js))?$){2}/i": { image: Assets.Eslint },
		"/\\prettier.config.js/i": { image: Assets.Prettier },
		"/vue.config\\.(js|ts)/i": { image: Assets.Vueconfig },
		"/vite.config\\.(js|ts)/i": { image: Assets.Viteconfig },
		"/vitest.config\\.(js|ts|mjs)/i": { image: Assets.Vitestconfig },
		"/jest.config\\.(js|ts)/i": { image: Assets.Jest },
		"/gatsby-(browser|node|ssr|config)\\.js/i": { image: Assets.Gatsbyjs },
		"/webpack(\\.dev|\\.development|\\.prod|\\.production)?\\.config(\\.babel)?\\.(js|jsx|coffee|ts|json|json5|yaml|yml)/i":
			{
				image: Assets.Webpack,
			},
		"babel.config.js": { image: Assets.Babel },
		".ahk": { image: Assets.Ahk },
		".ahkl": { image: Assets.Ahk },
		".astro": { image: Assets.Astro },
		"androidmanifest.xml": { image: Assets.Android },
		"/^angular[^.]*\\.js$/i": { image: Assets.Angular },
		".applescript": { image: Assets.Applescript },
		"/(\\.)?appveyor\\.yml/i": { image: Assets.Appveyor },
		".ino": { image: Assets.Arduino },
		".swf": { image: Assets.Text },
		".as": { image: Assets.Text },
		".jsfl": { image: Assets.Text },
		".swc": { image: Assets.Text },
		".asp": { image: Assets.Asp },
		".asax": { image: Assets.Asp },
		".ascx": { image: Assets.Asp },
		".ashx": { image: Assets.Asp },
		".asmx": { image: Assets.Asp },
		".aspx": { image: Assets.Asp },
		".axd": { image: Assets.Asp },
		"/\\.(l?a|[ls]?o|out|s|a51|asm|axf|elf|prx|puff|z80)$/i": {
			image: Assets.Assembly,
		},
		".agc": { image: Assets.Assembly },
		".ko": { image: Assets.Assembly },
		".lst": { image: Assets.Assembly },
		"/\\.((c([+px]{2}?)?-?)?objdump|bsdiff|bin|dat|pak|pdb)$/i": {
			image: Assets.Assembly,
		},
		".d-objdump": { image: Assets.Assembly },
		"/\\.gcode|\\.gco/i": { image: Assets.Assembly },
		"/\\.rpy[bc]$/i": { image: Assets.Assembly },
		"/\\.py[co]$/i": { image: Assets.Assembly },
		".swp": { image: Assets.Assembly },
		".DS_Store": { image: Assets.Assembly },
		".au3": { image: Assets.Autoit },
		"/\\.babelrc/i": { image: Assets.Babel },
		".bat": { image: Assets.Bat },
		".batch": { image: Assets.Bat },
		".cmd": { image: Assets.Bat },
		"/\\.(exe|com|msi)$/i": { image: Assets.Bat },
		".reg": { image: Assets.Bat },
		"/^(\\.bowerrc|bower\\.json|Bowerfile)$/i": { image: Assets.Bower },
		"/\\.bf?$/i": { image: Assets.Brainfuck },
		"/\\.c$/i": { image: Assets.C },
		"/(cargo.toml|cargo.lock)/i": { image: Assets.Cargo },
		".casc": { image: Assets.Text },
		".cas": { image: Assets.Text },
		".cfc": { image: Assets.Text },
		".cfm": { image: Assets.Text },
		"circle.yml": { image: Assets.Circleci },
		".clj": { image: Assets.Clojure },
		".cl2": { image: Assets.Clojure },
		".cljc": { image: Assets.Clojure },
		".cljx": { image: Assets.Clojure },
		".hic": { image: Assets.Clojure },
		"/\\.cljs(cm)?$/i": { image: Assets.Clojure },
		".cmake": { image: Assets.Cmake },
		"/^CMakeLists\\.txt$/": { image: Assets.Cmake },
		"/\\.codeclimate\\.(yml|json)/i": { image: Assets.Codeclimate },
		".coffee": { image: Assets.Coffee },
		".cjsx": { image: Assets.Coffee },
		".coffee.ecr": { image: Assets.Coffee },
		".coffee.erb": { image: Assets.Coffee },
		".litcoffee": { image: Assets.Coffee },
		".iced": { image: Assets.Coffee },
		"/\\.c[+px]{2}$|\\.cc$/i": { image: Assets.Cpp },
		"/\\.h[+px]{2}$/i": { image: Assets.Cpp },
		"/\\.[it]pp$/i": { image: Assets.Cpp },
		"/\\.(tcc|inl)$/i": { image: Assets.Cpp },
		".cats": { image: Assets.Cpp },
		".idc": { image: Assets.Cpp },
		".w": { image: Assets.Cpp },
		".nc": { image: Assets.Cpp },
		".upc": { image: Assets.Cpp },
		".xpm": { image: Assets.Cpp },
		"/\\.e?cr$/i": { image: Assets.Crystal },
		".cs": { image: Assets.Csharp },
		".csx": { image: Assets.Csharp },
		".cshtml": { image: Assets.Html },
		".css": { image: Assets.Css },
		".css.map": { image: Assets.Cssmap },
		".cu": { image: Assets.Cuda },
		"/\\.di?$/i": { image: Assets.D },
		".dart": { image: Assets.Dart },
		".dfm": { image: Assets.Delphi },
		".dpr": { image: Assets.Delphi },
		".dsc": { image: Assets.Denizen },
		".dm": { image: Assets.Text },
		".dme": { image: Assets.Text },
		".dmm": { image: Assets.Text },
		"/^(Dockerfile|docker-compose)|\\.docker(file|ignore)$/i": {
			image: Assets.Docker,
		},
		"/^docker-sync\\.yml$/i": { image: Assets.Docker },
		".editorconfig": { image: Assets.Editorconfig },
		".ejs": { image: Assets.Ejs },
		".ex": { image: Assets.Elixir },
		"/\\.(exs|l?eex)$/i": { image: Assets.Elixir },
		"/^mix\\.(exs?|lock)$/i": { image: Assets.Elixir },
		".elm": { image: Assets.Elm },
		".env": { image: Assets.Env },
		".erl": { image: Assets.Erlang },
		".beam": { image: Assets.Erlang },
		".hrl": { image: Assets.Erlang },
		".xrl": { image: Assets.Erlang },
		".yrl": { image: Assets.Erlang },
		".app.src": { image: Assets.Erlang },
		"/^Emakefile$/": { image: Assets.Erlang },
		"/^rebar(\\.config)?\\.lock$/i": { image: Assets.Erlang },
		"/(\\.firebaserc|firebase\\.json)/i": { image: Assets.Firebase },
		".flowconfig": { image: Assets.Flowconfig },
		".fs": { image: Assets.Fsharp },
		".fsi": { image: Assets.Fsharp },
		".fsscript": { image: Assets.Fsharp },
		".fsx": { image: Assets.Fsharp },
		"/^Gemfile(\\.lock)?$/i": { image: Assets.Gemfile },
		"/^\\.git|^\\.keep$|\\.mailmap$/i": { image: Assets.Git },
		".go": { image: Assets.Go },
		".gd": { image: Assets.Godot },
		".gradle": { image: Assets.Gradle },
		gradlew: { image: Assets.Gradle },
		".gql": { image: Assets.Graphql },
		".graphql": { image: Assets.Graphql },
		".groovy": { image: Assets.Groovy },
		".gvy": { image: Assets.Groovy },
		".gy": { image: Assets.Groovy },
		".gsh": { image: Assets.Groovy },
		"/gruntfile\\.(js|coffee)/i": { image: Assets.Text },
		"gulpfile.js": { image: Assets.Gulp },
		"/\\.(hbs|handlebars|(mu)?stache)$/i": { image: Assets.Handlebars },
		".prg": { image: Assets.Harbour },
		".hbp": { image: Assets.Harbour },
		".hbc": { image: Assets.Harbour },
		".rc": { image: Assets.Harbour },
		".fmg": { image: Assets.Harbour },
		".hs": { image: Assets.Haskell },
		".hsc": { image: Assets.Haskell },
		".c2hs": { image: Assets.Haskell },
		".lhs": { image: Assets.Haskell },
		".hx": { image: Assets.Haxe },
		".hxml": { image: Assets.Haxe },
		"/^procfile/i": { image: Assets.Heroku },
		"heroku.yml": { image: Assets.Heroku },
		".hjson": { image: Assets.Hjson },
		"/\\.x?html?$/i": { image: Assets.Html },
		".http": { image: Assets.Http },
		".rest": { image: Assets.Http },
		".jar": { image: Assets.Jar },
		".java": { image: Assets.Java },
		".j2": { image: Assets.Text },
		".jinja": { image: Assets.Text },
		".js": { image: Assets.Js },
		".es6": { image: Assets.Js },
		".es": { image: Assets.Js },
		".mjs": { image: Assets.Js },
		".js.map": { image: Assets.Jsmap },
		".json": { image: Assets.Json },
		".jsonc": { image: Assets.Json },
		".jsx": { image: Assets.Jsx },
		"/\\.(jil|jl)/i": { image: Assets.Julia },
		".ipynb": { image: Assets.Jupyter },
		".kt": { image: Assets.Kotlin },
		".ktm": { image: Assets.Kotlin },
		".kts": { image: Assets.Kotlin },
		".less": { image: Assets.Text },
		".lsp": { image: Assets.Lisp },
		".lisp": { image: Assets.Lisp },
		".l": { image: Assets.Lisp },
		".nl": { image: Assets.Lisp },
		".ny": { image: Assets.Lisp },
		".podsl": { image: Assets.Lisp },
		".sexp": { image: Assets.Lisp },
		".ss": { image: Assets.Lisp },
		".scm": { image: Assets.Lisp },
		".ls": { image: Assets.Livescript },
		".log": { image: Assets.Log },
		".lua": { image: Assets.Lua },
		".pd_lua": { image: Assets.Lua },
		".rbxs": { image: Assets.Lua },
		".wlua": { image: Assets.Lua },
		"/^Makefile/": { image: Assets.Makefile },
		"/^mk\\.config$/": { image: Assets.Makefile },
		"/\\.(mk|mak|make)$/i": { image: Assets.Makefile },
		"/^BSDmakefile$/i": { image: Assets.Makefile },
		"/^GNUmakefile$/i": { image: Assets.Makefile },
		"/^makefile\\.sco$/i": { image: Assets.Makefile },
		"/^Kbuild$/": { image: Assets.Makefile },
		"/^makefile$/": { image: Assets.Makefile },
		"/^mkfile$/i": { image: Assets.Makefile },
		"/^\\.?qmake$/i": { image: Assets.Makefile },
		"/\\.(h|geo|topo)$/i": { image: Assets.Manifest },
		".cson": { image: Assets.Manifest },
		".json5": { image: Assets.Manifest },
		".ndjson": { image: Assets.Manifest },
		".fea": { image: Assets.Manifest },
		".json.eex": { image: Assets.Manifest },
		".proto": { image: Assets.Manifest },
		".pytb": { image: Assets.Manifest },
		".pydeps": { image: Assets.Manifest },
		"/\\.pot?$/i": { image: Assets.Manifest },
		".ejson": { image: Assets.Manifest },
		".edn": { image: Assets.Manifest },
		".eam.fs": { image: Assets.Manifest },
		".qml": { image: Assets.Manifest },
		".qbs": { image: Assets.Manifest },
		".ston": { image: Assets.Manifest },
		".ttl": { image: Assets.Manifest },
		".rviz": { image: Assets.Manifest },
		".syntax": { image: Assets.Manifest },
		".webmanifest": { image: Assets.Manifest },
		"/^pkginfo$/": { image: Assets.Manifest },
		"/^mime\\.types$/i": { image: Assets.Manifest },
		"/^METADATA\\.pb$/": { image: Assets.Manifest },
		"/[\\/\\\\](?:magic[\\/\\\\]Magdir|file[\\/\\\\]magic)[\\/\\\\][-.\\w]+$/i":
			{
				image: Assets.Manifest,
			},
		"/(\\\\|\\/)dev[-\\w]+\\1(?:[^\\\\\\/]+\\1)*(?!DESC|NOTES)(?:[A-Z][-A-Z]*)(?:\\.in)?$/":
			{
				image: Assets.Manifest,
			},
		"lib/icons/.icondb.js": { image: Assets.Manifest },
		"/\\.git[\\/\\\\](.*[\\/\\\\])?(HEAD|ORIG_HEAD|packed-refs|logs[\\/\\\\](.+[\\/\\\\])?[^\\/\\\\]+)$/":
			{
				image: Assets.Manifest,
			},
		"/\\.(md|mdown|markdown|mkd|mkdown|mdwn|mkdn|rmd|ron|pmd)$/i": {
			image: Assets.Markdown,
		},
		".mdx": { image: Assets.Markdownx },
		".marko": { image: Assets.Marko },
		".nim": { image: Assets.Nim },
		".nims": { image: Assets.Nim },
		".nimble": { image: Assets.Nim },
		".nix": { image: Assets.Nix },
		".npmrc": { image: Assets.Npm },
		".npmignore": { image: Assets.Npm },
		"/\\.mm?$/i": { image: Assets.Objc },
		".pch": { image: Assets.Objc },
		".x": { image: Assets.Objc },
		".ml": { image: Assets.Ocaml },
		".mli": { image: Assets.Ocaml },
		".eliom": { image: Assets.Ocaml },
		".eliomi": { image: Assets.Ocaml },
		".ml4": { image: Assets.Ocaml },
		".mll": { image: Assets.Ocaml },
		".mly": { image: Assets.Ocaml },
		".mt": { image: Assets.Metal },
		".odin": { image: Assets.Odin },
		"/\\.pas(cal)?$/i": { image: Assets.Pascal },
		".lpr": { image: Assets.Pascal },
		".p": { image: Assets.Pawn },
		".inc": { image: Assets.Pawn },
		".sma": { image: Assets.Pawn },
		".pwn": { image: Assets.Pawn },
		".sp": { image: Assets.Sourcepawn },
		"/\\.p(er)?l$/i": { image: Assets.Perl },
		".al": { image: Assets.Perl },
		".ph": { image: Assets.Perl },
		".plx": { image: Assets.Perl },
		".pm": { image: Assets.Perl },
		"/\\.(psgi|xs)$/i": { image: Assets.Perl },
		".pl6": { image: Assets.Perl },
		"/\\.[tp]6$|\\.6pl$/i": { image: Assets.Perl },
		"/\\.(pm6|p6m)$/i": { image: Assets.Perl },
		".6pm": { image: Assets.Perl },
		".nqp": { image: Assets.Perl },
		".p6l": { image: Assets.Perl },
		".pod6": { image: Assets.Perl },
		"/^Rexfile$/": { image: Assets.Perl },
		"/\\.php([st\\d]|_cs)?$/i": { image: Assets.Php },
		"/^Phakefile/": { image: Assets.Php },
		".pony": { image: Assets.Ponylang },
		".pcss": { image: Assets.Postcss },
		".ps1": { image: Assets.Powershell },
		".psd1": { image: Assets.Powershell },
		".psm1": { image: Assets.Powershell },
		".ps1xml": { image: Assets.Powershell },
		".prettierignore": { image: Assets.Prettier },
		"prisma.yml": { image: Assets.Prisma },
		".pde": { image: Assets.Processing },
		".jade": { image: Assets.Pug },
		".pug": { image: Assets.Pug },
		".purs": { image: Assets.Purescript },
		".py": { image: Assets.Python },
		".ipy": { image: Assets.Python },
		".isolate": { image: Assets.Python },
		".pep": { image: Assets.Python },
		".gyp": { image: Assets.Python },
		".gypi": { image: Assets.Python },
		".pyde": { image: Assets.Python },
		".pyp": { image: Assets.Python },
		".pyt": { image: Assets.Python },
		".py3": { image: Assets.Python },
		".pyi": { image: Assets.Python },
		".pyw": { image: Assets.Python },
		".tac": { image: Assets.Python },
		".wsgi": { image: Assets.Python },
		".xpy": { image: Assets.Python },
		".rpy": { image: Assets.Python },
		"/\\.?(pypirc|pythonrc|python-venv)$/i": { image: Assets.Python },
		"/^(SConstruct|SConscript)$/": { image: Assets.Python },
		"/^(Snakefile|WATCHLISTS)$/": { image: Assets.Python },
		"/^wscript$/": { image: Assets.Python },
		"/\\.(r|Rprofile|rsx|rd)$/i": { image: Assets.R },
		"/\\.res?i?$/i": { image: Assets.Text },
		"/\\.(rb|ru|ruby|erb|gemspec|god|mspec|pluginspec|podspec|rabl|rake|opal)$/i":
			{
				image: Assets.Ruby,
			},
		"/^\\.?(irbrc|gemrc|pryrc|ruby-(gemset|version))$/i": {
			image: Assets.Ruby,
		},
		"/^(Appraisals|(Rake|[bB]uild|Cap|Danger|Deliver|Fast|Guard|Jar|Maven|Pod|Puppet|Snap)file(\\.lock)?)$/":
			{
				image: Assets.Ruby,
			},
		"/\\.(jbuilder|rbuild|rb[wx]|builder)$/i": { image: Assets.Ruby },
		"/^rails$/": { image: Assets.Ruby },
		".watchr": { image: Assets.Ruby },
		".rs": { image: Assets.Rust },
		"/\\.(sc|scala)$/i": { image: Assets.Scala },
		".scss": { image: Assets.Scss },
		".sass": { image: Assets.Scss },
		"/\\.(sh|rc|bats|bash|tool|install|command)$/i": { image: Assets.Shell },
		"/^(\\.?bash(rc|[-_]?(profile|login|logout|history|prompt))|_osc|config|install-sh|PKGBUILD)$/i":
			{
				image: Assets.Shell,
			},
		"/\\.(ksh|mksh|pdksh)$/i": { image: Assets.Shell },
		".sh-session": { image: Assets.Shell },
		"/\\.zsh(-theme|_history)?$|^\\.?(antigen|zpreztorc|zlogin|zlogout|zprofile|zshenv|zshrc)$/i":
			{
				image: Assets.Shell,
			},
		"/\\.fish$|^\\.fishrc$/i": { image: Assets.Shell },
		"/^\\.?(login|profile)$/": { image: Assets.Shell },
		".inputrc": { image: Assets.Shell },
		".tmux": { image: Assets.Shell },
		"/^(configure|config\\.(guess|rpath|status|sub)|depcomp|libtool|compile)$/":
			{
				image: Assets.Shell,
			},
		"/^\\/(private\\/)?etc\\/([^\\/]+\\/)*(profile$|nanorc$|rc\\.|csh\\.)/i": {
			image: Assets.Shell,
		},
		"/^\\.?cshrc$/i": { image: Assets.Shell },
		".profile": { image: Assets.Shell },
		".tcsh": { image: Assets.Shell },
		".csh": { image: Assets.Shell },
		".sk": { image: Assets.Text },
		".sqf": { image: Assets.Sqf },
		"/\\.(my)?sql$/i": { image: Assets.Sql },
		".ddl": { image: Assets.Sql },
		".udf": { image: Assets.Sql },
		".hql": { image: Assets.Sql },
		".viw": { image: Assets.Sql },
		".prc": { image: Assets.Sql },
		".cql": { image: Assets.Sql },
		".db2": { image: Assets.Sql },
		"/\\.(styl|stylus)$/i": { image: Assets.Stylus },
		".svelte": { image: Assets.Svelte },
		".svg": { image: Assets.Svg },
		".swift": { image: Assets.Swift },
		".tex": { image: Assets.Tex },
		".ltx": { image: Assets.Tex },
		".aux": { image: Assets.Tex },
		".sty": { image: Assets.Tex },
		".dtx": { image: Assets.Tex },
		".cls": { image: Assets.Tex },
		".ins": { image: Assets.Tex },
		".lbx": { image: Assets.Tex },
		".mkiv": { image: Assets.Tex },
		".mkvi": { image: Assets.Tex },
		".mkii": { image: Assets.Tex },
		".texi": { image: Assets.Tex },
		"/^hyphen(ex)?\\.(cs|den|det|fr|sv|us)$/": { image: Assets.Tex },
		"/\\.te?xt$/i": { image: Assets.Text },
		".rtf": { image: Assets.Text },
		"/\\.i?nfo$/i": { image: Assets.Text },
		".msg": { image: Assets.Text },
		"/\\.(utxt|utf8)$/i": { image: Assets.Text },
		".toml": { image: Assets.Toml },
		".travis.yml": { image: Assets.Travis },
		".ts.map": { image: Assets.Tsmap },
		"/.*\\.d\\.ts/i": { image: Assets.TypescriptDef },
		".ts": { image: Assets.Ts },
		".tsx": { image: Assets.Tsx },
		".twig": { image: Assets.Twig },
		".v": { image: Assets.V },
		".vh": { image: Assets.V },
		".vala": { image: Assets.Vala },
		".vapi": { image: Assets.Vala },
		".vb": { image: Assets.Vb },
		".vbs": { image: Assets.Vb },
		".vbhtml": { image: Assets.Vb },
		".vbproj": { image: Assets.Vb },
		".vba": { image: Assets.Text },
		".vcxproj": { image: Assets.Text },
		".vscodeignore": { image: Assets.Vscodeignore },
		".vue": { image: Assets.Vue },
		".wat": { image: Assets.Wasm },
		".wast": { image: Assets.Wasm },
		".wasm": { image: Assets.Wasm },
		".xml": { image: Assets.Xml },
		"/\\.ya?ml$/i": { image: Assets.Yaml },
		"/^yarn(\\.lock)?$/i": { image: Assets.Yarn },
		".yarnrc": { image: Assets.Yarn },
		".zig": { image: Assets.Zig },
		"/\\.(tfvars|tf)$/i": { image: Assets.Terraform },
	};

presence.on("UpdateData", async () => {
	const [
			detailIdling,
			customDetail,
			customState,
			customSmallText,
			customEmpty,
			timestamps,
			buttons,
		] = await Promise.all([
			presence.getSetting<string>("customIdling"),
			presence.getSetting<string>("customDetail"),
			presence.getSetting<string>("customState"),
			presence.getSetting<string>("customImageText"),
			presence.getSetting<string>("customEmpty"),
			presence.getSetting<boolean>("timeStamps"),
			presence.getSetting<boolean>("buttons"),
		]),
		presenceData: PresenceData = {
			largeImageKey: Assets.Logo,
			smallImageKey: Assets.Vscode,
			startTimestamp,
		},
		status: Stauts = {
			file: document.querySelector(".tab.active a")?.textContent,
			workspace: document
				.querySelector("div.pane-header[aria-label='Folders Section'] h3")
				?.getAttribute("title"),
			editor: {
				lang: document.querySelector("#status\\.editor\\.mode")?.textContent,
			},
		},
		{ file, workspace, editor } = status,
		findExtension = Object.keys(KNOWN_EXTENSIONS).find(key => {
			if (file?.endsWith(key)) return true;
			const match = /^\/(.*)\/([mgiy]+)$/.exec(key);
			if (!match) return false;
			return new RegExp(match[1], match[2]).test(file);
		});

	if (!file || !workspace) {
		presenceData.details = detailIdling;
		presenceData.largeImageKey = Assets.IdleVscode;
		if (presenceData.buttons) delete presenceData.buttons;
	} else {
		presenceData.state = Replace(customState, customEmpty);
		presenceData.details = Replace(customDetail, customEmpty);
		presenceData.smallImageText = Replace(customSmallText, customEmpty);
		presenceData.largeImageKey =
			KNOWN_EXTENSIONS[findExtension]?.image ||
			KNOWN_LANGUAGES.find(key =>
				key.language.includes(editor.lang?.toLowerCase())
			)?.image ||
			Assets.Logo;
	}

	if (buttons && document.location.pathname?.split("/")[1] === "github") {
		presenceData.buttons = [
			{
				label: "View Repository",
				url: document.location.href.replace("vscode.dev/github", "github.com"),
			},
		];
	}

	if (!timestamps) delete presenceData.startTimestamp;
	if (!buttons) delete presenceData.buttons;
	if (presenceData.details) presence.setActivity(presenceData);
	else presence.setActivity();
});

function Replace(value: string, empty: string) {
	for (const [string, selector] of Object.entries({
		"%file%": [".tab.active a"],
		"%branch%": ["#status\\.scm\\.0"],
		"%error%": ["#status\\.problems > a > span.codiconcodicon-error"],
		"%problems%": ["#status\\.problems > a > span.codicon.codicon-warning"],
		"%workspace%": [
			"div.pane-header[aria-label='Folders Section'] h3",
			"title",
		],
		"%lang%": ["#status\\.editor\\.mode"],
		"%encoding%": ["#status\\.editor\\.encoding"],
		"%selection%": ["#status\\.editor\\.selection"],
	})) {
		value = value.replace(
			string,
			selector[1]
				? document
						.querySelector(selector[0])
						?.getAttribute(selector[1])
						?.trim() || empty
				: document.querySelector(selector[0])?.textContent?.trim() || empty
		);
	}
	return value;
}
